Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
NDEV-813 add readonly mode for proxy
  • Loading branch information
afalaleev committed Oct 27, 2022
commit 8e079da550c2bfcbe98a44ca47b79097945a5111
6 changes: 6 additions & 0 deletions proxy/common_neon/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ def __init__(self):
self._recheck_resource_after_uses_cnt = self._env_int("RECHECK_RESOURCE_AFTER_USES_CNT", 10, 60)
self._retry_on_fail = self._env_int("RETRY_ON_FAIL", 1, 10)
self._enable_private_api = self._env_bool("ENABLE_PRIVATE_API", False)
self._enable_send_tx_api = self._env_bool("ENABLE_SEND_TX_API", True)
self._use_earliest_block_if_0_passed = self._env_bool("USE_EARLIEST_BLOCK_IF_0_PASSED", False)
self._account_permission_update_int = self._env_int("ACCOUNT_PERMISSION_UPDATE_INT", 10, 60 * 5)
self._allow_underpriced_tx_wo_chainid = self._env_bool("ALLOW_UNDERPRICED_TX_WITHOUT_CHAINID", False)
Expand Down Expand Up @@ -148,6 +149,10 @@ def retry_on_fail(self) -> int:
def enable_private_api(self) -> bool:
return self._enable_private_api

@property
def enable_send_tx_api(self) -> bool:
return self._enable_send_tx_api

@property
def use_earliest_block_if_0_passed(self) -> bool:
return self._use_earliest_block_if_0_passed
Expand Down Expand Up @@ -298,6 +303,7 @@ def __str__(self):
f"RECHECK_RESOURCE_AFTER_USES_CNT: {self.recheck_resource_after_uses_cnt}",
f"RETRY_ON_FAIL: {self.retry_on_fail}",
f"ENABLE_PRIVATE_API: {self.enable_private_api}",
f"ENABLE_SEND_TX_API: {self.enable_send_tx_api}",
f"USE_EARLIEST_BLOCK_IF_0_PASSED: {self.use_earliest_block_if_0_passed}",
f"ACCOUNT_PERMISSION_UPDATE_INT: {self.account_permission_update_int}",
f"ALLOW_UNDERPRICED_TX_WITHOUT_CHAINID: {self.allow_underpriced_tx_wo_chainid}",
Expand Down
14 changes: 8 additions & 6 deletions proxy/neon_rpc_api_model/neon_rpc_api_worker.py
Original file line number Diff line number Diff line change
Expand Up @@ -785,16 +785,18 @@ def is_allowed_api(self, method_name: str) -> bool:
f'Neon EVM {self.web3_clientVersion()}'
)

if self._config.enable_private_api:
return True
if method_name == 'eth_sendRawTransaction':
return self._config.enable_send_tx_api

private_method_list = (
private_method_set = {
"eth_accounts",
"eth_sign",
"eth_sendTransaction",
"eth_signTransaction",
)
}

if method_name in private_method_set:
if (not self._config.enable_send_tx_api) or (not self._config.enable_private_api):
return False

if method_name in private_method_list:
return False
return True