diff --git a/proxy/plugin/solana_rest_api.py b/proxy/plugin/solana_rest_api.py index a3e2489b6..5bd1d0b13 100644 --- a/proxy/plugin/solana_rest_api.py +++ b/proxy/plugin/solana_rest_api.py @@ -27,7 +27,7 @@ import threading from .solana_rest_api_tools import EthereumAddress, create_account_with_seed, evm_loader_id, getTokens, \ getAccountInfo, solana_cli, call_signed, solana_url, call_emulated, \ - Trx, EthereumError, create_collateral_pool_address, getTokenAddr, STORAGE_SIZE, neon_config_load + Trx, EthereumError, create_collateral_pool_address, getTokenAddr, STORAGE_SIZE, neon_config_load, MINIMAL_GAS_PRICE from solana.rpc.commitment import Commitment, Confirmed from web3 import Web3 import logging @@ -113,7 +113,7 @@ def net_version(self): return str(int(chainId,base=16)) def eth_gasPrice(self): - return hex(1*10**9) + return hex(MINIMAL_GAS_PRICE) def eth_estimateGas(self, param): try: @@ -387,6 +387,9 @@ def eth_sendRawTransaction(self, rawTrx): logger.debug('eth_sendRawTransaction rawTrx=%s', rawTrx) trx = EthTrx.fromString(bytearray.fromhex(rawTrx[2:])) logger.debug("%s", json.dumps(trx.as_dict(), cls=JsonEncoder, indent=3)) + if trx.gasPrice < MINIMAL_GAS_PRICE: + raise Exception("The transaction gasPrice is less then the minimum allowable value ({}<{})".format(trx.gasPrice, MINIMAL_GAS_PRICE)) + eth_signature = '0x' + bytes(Web3.keccak(bytes.fromhex(rawTrx[2:]))).hex() sender = trx.sender() diff --git a/proxy/plugin/solana_rest_api_tools.py b/proxy/plugin/solana_rest_api_tools.py index 5648be3b5..45efa542d 100644 --- a/proxy/plugin/solana_rest_api_tools.py +++ b/proxy/plugin/solana_rest_api_tools.py @@ -46,6 +46,7 @@ USE_COMBINED_START_CONTINUE = os.environ.get("USE_COMBINED_START_CONTINUE", "YES") == "YES" CONTINUE_COUNT_FACTOR = int(os.environ.get("CONTINUE_COUNT_FACTOR", "3")) TIMEOUT_TO_RELOAD_NEON_CONFIG = int(os.environ.get("TIMEOUT_TO_RELOAD_NEON_CONFIG", "3600")) +MINIMAL_GAS_PRICE=int(os.environ.get("MINIMAL_GAS_PRICE", 1))*10**9 ACCOUNT_SEED_VERSION=b'\1' diff --git a/proxy/run-proxy.sh b/proxy/run-proxy.sh index 0250e6adf..f1723d498 100755 --- a/proxy/run-proxy.sh +++ b/proxy/run-proxy.sh @@ -15,6 +15,7 @@ if [ "$CONFIG" == "ci" ]; then [[ -z "$NEON_CLI_TIMEOUT" ]] && export NEON_CLI_TIMEOUT="0.5" [[ -z "$USE_COMBINED_START_CONTINUE" ]] && export USE_COMBINED_START_CONTINUE="YES" [[ -z "$CONTINUE_COUNT_FACTOR" ]] && export CONTINUE_COUNT_FACTOR="3" + [[ -z "$MINIMAL_GAS_PRICE" ]] && export MINIMAL_GAS_PRICE=0 elif [ "$CONFIG" == "local" ]; then [[ -z "$SOLANA_URL" ]] && export SOLANA_URL="http://localhost:8899" [[ -z "$EVM_LOADER" ]] && export EVM_LOADER=deploy @@ -24,6 +25,7 @@ elif [ "$CONFIG" == "local" ]; then [[ -z "$NEON_CHAIN_ID" ]] && export NEON_CHAIN_ID=0x6f [[ -z "$EXTRA_GAS" ]] && export EXTRA_GAS=0 [[ -z "$NEON_CLI_TIMEOUT" ]] && export NEON_CLI_TIMEOUT="0.9" + [[ -z "$MINIMAL_GAS_PRICE" ]] && export MINIMAL_GAS_PRICE=0 elif [ "$CONFIG" == "devnet" ]; then [[ -z "$SOLANA_URL" ]] && export SOLANA_URL="https://api.devnet.solana.com" [[ -z "$EVM_LOADER" ]] && export EVM_LOADER=eeLSJgWzzxrqKv1UxtRVVH8FX3qCQWUs9QuAjJpETGU @@ -33,6 +35,7 @@ elif [ "$CONFIG" == "devnet" ]; then [[ -z "$NEON_CHAIN_ID" ]] && export NEON_CHAIN_ID=0x6e [[ -z "$EXTRA_GAS" ]] && export EXTRA_GAS=90000 [[ -z "$NEON_CLI_TIMEOUT" ]] && export NEON_CLI_TIMEOUT="10" + [[ -z "$MINIMAL_GAS_PRICE" ]] && export MINIMAL_GAS_PRICE=1 elif [ "$CONFIG" == "testnet" ]; then [[ -z "$SOLANA_URL" ]] && export SOLANA_URL="https://api.testnet.solana.com" [[ -z "$EVM_LOADER" ]] && export EVM_LOADER=eeLSJgWzzxrqKv1UxtRVVH8FX3qCQWUs9QuAjJpETGU @@ -42,6 +45,7 @@ elif [ "$CONFIG" == "testnet" ]; then [[ -z "$NEON_CHAIN_ID" ]] && export NEON_CHAIN_ID=0x6f [[ -z "$EXTRA_GAS" ]] && export EXTRA_GAS=90000 [[ -z "$NEON_CLI_TIMEOUT" ]] && export NEON_CLI_TIMEOUT="15" + [[ -z "$MINIMAL_GAS_PRICE" ]] && export MINIMAL_GAS_PRICE="1" elif [ "$CONFIG" != "custom" ]; then exit 1 fi diff --git a/proxy/test_cancel_hanged.py b/proxy/test_cancel_hanged.py index d9519a476..7b3b0152d 100644 --- a/proxy/test_cancel_hanged.py +++ b/proxy/test_cancel_hanged.py @@ -1,7 +1,7 @@ import os import sys -from proxy.plugin.solana_rest_api_tools import sysinstruct, ETH_TOKEN_MINT_ID, system, send_transaction +from proxy.plugin.solana_rest_api_tools import sysinstruct, ETH_TOKEN_MINT_ID, system, send_transaction, MINIMAL_GAS_PRICE sys.path.append("/spl/bin/") os.environ['SOLANA_URL'] = "http://solana:8899" @@ -149,7 +149,7 @@ def deploy_contract(self): def create_hanged_transaction(self): print("\ncommit_two_event_trx") right_nonce = proxy.eth.get_transaction_count(proxy.eth.default_account) - trx_store = self.storage_contract.functions.addReturnEventTwice(1, 1).buildTransaction({'nonce': right_nonce}) + trx_store = self.storage_contract.functions.addReturnEventTwice(1, 1).buildTransaction({'nonce': right_nonce, 'gasPrice': MINIMAL_GAS_PRICE}) trx_store_signed = proxy.eth.account.sign_transaction(trx_store, eth_account.key) (from_addr, sign, msg) = make_instruction_data_from_tx(trx_store_signed.rawTransaction.hex())