diff --git a/proxy/core/acceptor/pool.py b/proxy/core/acceptor/pool.py index beaa0733e..dd4cdc59e 100644 --- a/proxy/core/acceptor/pool.py +++ b/proxy/core/acceptor/pool.py @@ -27,6 +27,9 @@ LOCK = multiprocessing.Lock() proxy_id_glob = multiprocessing.Value('i', 0) +new_acc_id_glob = multiprocessing.Value('i', 0) +manager = multiprocessing.Manager() +acc_list_glob = manager.list() class AcceptorPool: diff --git a/proxy/plugin/solana_rest_api.py b/proxy/plugin/solana_rest_api.py index 32952a7c2..54a19ecf4 100644 --- a/proxy/plugin/solana_rest_api.py +++ b/proxy/plugin/solana_rest_api.py @@ -25,9 +25,8 @@ import base58 import traceback import threading -from .solana_rest_api_tools import EthereumAddress, create_account_with_seed, getTokens, \ - getAccountInfo, call_signed, call_emulated, \ - Trx, EthereumError, create_collateral_pool_address, getTokenAddr, STORAGE_SIZE, neon_config_load, MINIMAL_GAS_PRICE +from .solana_rest_api_tools import EthereumAddress, getTokens, getAccountInfo, \ + call_signed, call_emulated, EthereumError, neon_config_load, MINIMAL_GAS_PRICE from solana.rpc.commitment import Commitment, Confirmed from web3 import Web3 import logging @@ -45,27 +44,6 @@ EXTRA_GAS = int(os.environ.get("EXTRA_GAS", "0")) -class PermanentAccounts: - def __init__(self, client, signer, proxy_id): - self.operator = signer.public_key() - self.operator_token = getTokenAddr(self.operator) - self.proxy_id = proxy_id - - proxy_id_bytes = proxy_id.to_bytes((proxy_id.bit_length() + 7) // 8, 'big') - - storage_seed = keccak_256(b"storage" + proxy_id_bytes).hexdigest()[:32] - storage_seed = bytes(storage_seed, 'utf8') - self.storage = create_account_with_seed(client, funding=signer, base=signer, seed=storage_seed, storage_size=STORAGE_SIZE) - - holder_seed = keccak_256(b"holder" + proxy_id_bytes).hexdigest()[:32] - holder_seed = bytes(holder_seed, 'utf8') - self.holder = create_account_with_seed(client, funding=signer, base=signer, seed=holder_seed, storage_size=STORAGE_SIZE) - - collateral_pool_index = proxy_id % 4 - self.collateral_pool_index_buf = collateral_pool_index.to_bytes(4, 'little') - self.collateral_pool_address = create_collateral_pool_address(collateral_pool_index) - - class EthereumModel: def __init__(self): # Initialize user account @@ -98,7 +76,6 @@ def __init__(self): proxy_id_glob.value += 1 logger.debug("worker id {}".format(self.proxy_id)) - self.perm_accs = PermanentAccounts(self.client, self.signer, self.proxy_id) neon_config_load(self) pass @@ -415,7 +392,7 @@ def eth_sendRawTransaction(self, rawTrx): ] }) try: - signature = call_signed(self.signer, self.client, trx, self.perm_accs, steps=250) + signature = call_signed(self.signer, self.client, trx, steps=250) logger.debug('Transaction signature: %s %s', signature, eth_signature) diff --git a/proxy/plugin/solana_rest_api_tools.py b/proxy/plugin/solana_rest_api_tools.py index 2564506ef..8a748d717 100644 --- a/proxy/plugin/solana_rest_api_tools.py +++ b/proxy/plugin/solana_rest_api_tools.py @@ -30,6 +30,7 @@ from web3.auto import w3 from proxy.environment import neon_cli, evm_loader_id, ETH_TOKEN_MINT_ID, COLLATERAL_POOL_BASE, read_elf_params from .eth_proto import Trx +from ..core.acceptor.pool import new_acc_id_glob, acc_list_glob from ..indexer.sql_dict import POSTGRES_USER, POSTGRES_HOST, POSTGRES_DB, POSTGRES_PASSWORD import psycopg2 @@ -40,13 +41,17 @@ NEW_USER_AIRDROP_AMOUNT = int(os.environ.get("NEW_USER_AIRDROP_AMOUNT", "0")) location_bin = ".deploy_contract.bin" confirmation_check_delay = float(os.environ.get("NEON_CONFIRMATION_CHECK_DELAY", "0.1")) -USE_COMBINED_START_CONTINUE = os.environ.get("USE_COMBINED_START_CONTINUE", "YES") == "YES" +USE_COMBINED_START_CONTINUE = os.environ.get("USE_COMBINED_START_CONTINUE", "NO") == "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' +COLLATERALL_POOL_MAX=10 + +EMPTY_STORAGE_TAG=0 + sysvarclock = "SysvarC1ock11111111111111111111111111111111" sysinstruct = "Sysvar1nstructions1111111111111111111111111" keccakprog = "KeccakSecp256k11111111111111111111111111111" @@ -133,11 +138,60 @@ def __new__(cls): cls.instance.operator_cost = SQLCost() return cls.instance +class PermanentAccounts: + def __init__(self, client, signer): + while True: + with new_acc_id_glob.get_lock(): + try: + self.acc_id = acc_list_glob.pop(0) + except IndexError: + self.acc_id = new_acc_id_glob.value + new_acc_id_glob.value += 1 + + logger.debug("LOCK RESOURCES {}".format(self.acc_id)) + + self.operator = signer.public_key() + self.operator_token = getTokenAddr(self.operator) + + acc_id_bytes = self.acc_id.to_bytes((self.acc_id.bit_length() + 7) // 8, 'big') + + storage_seed = keccak_256(b"storage" + acc_id_bytes).hexdigest()[:32] + storage_seed = bytes(storage_seed, 'utf8') + + holder_seed = keccak_256(b"holder" + acc_id_bytes).hexdigest()[:32] + holder_seed = bytes(holder_seed, 'utf8') + + try: + self.storage, self.holder = create_multiple_accounts_with_seed( + client, + funding=signer, + base=signer, + seeds=[storage_seed, holder_seed], + sizes=[STORAGE_SIZE, STORAGE_SIZE] + ) + except Exception as err: + logger.warn("Account is locked err({}) id({}) owner({})".format(str(err), self.acc_id, signer.public_key())) + else: + break + + def __del__(self): + logger.debug("FREE RESOURCES {}".format(self.acc_id)) + with new_acc_id_glob.get_lock(): + acc_list_glob.append(self.acc_id) + + class TransactionInfo: - def __init__(self, caller_token, eth_accounts, nonce): + def __init__(self, caller_token, eth_accounts, eth_trx): + self.eth_trx = eth_trx + self.caller_token = caller_token self.eth_accounts = eth_accounts - self.nonce = nonce + self.nonce = eth_trx.nonce + + hash = keccak_256(eth_trx.unsigned_msg()).digest() + collateral_pool_index = int().from_bytes(hash[:4], "little") % COLLATERALL_POOL_MAX + self.collateral_pool_index_buf = collateral_pool_index.to_bytes(4, 'little') + self.collateral_pool_address = create_collateral_pool_address(collateral_pool_index) class AccountInfo(NamedTuple): ether: eth_keys.PublicKey @@ -164,6 +218,33 @@ def write_holder_layout(nonce, offset, data): len(data).to_bytes(8, byteorder='little')+ data) +def get_account_info(client, storage_account): + opts = { + "encoding": "base64", + "commitment": "confirmed", + "dataSlice": { + "offset": 0, + "length": 16, + } + } + + result = client._provider.make_request("getAccountInfo", str(storage_account), opts) + logger.debug("\n{}".format(json.dumps(result, indent=4, sort_keys=True))) + + info = result['result']['value'] + if info is None: + logger.debug("Can't get information about {}".format(storage_account)) + return None + + data = base64.b64decode(info['data'][0]) + + account_tag = data[0] + lamports = info['lamports'] + owner = info['owner'] + + return (account_tag, lamports, owner) + + def accountWithSeed(base, seed, program): # logger.debug(type(base), str(base), type(seed), str(seed), type(program), str(program)) result = PublicKey(sha256(bytes(base) + bytes(seed) + bytes(program)).digest()) @@ -218,6 +299,36 @@ def create_account_with_seed(client, funding, base, seed, storage_size, eth_trx= return account +def create_multiple_accounts_with_seed(client, funding, base, seeds, sizes): + accounts = [] + trx = Transaction() + + for seed, storage_size in zip(seeds, sizes): + account = accountWithSeed(base.public_key(), seed, PublicKey(evm_loader_id)) + accounts.append(account) + + minimum_balance = client.get_minimum_balance_for_rent_exemption(storage_size, commitment=Confirmed)["result"] + + account_info = get_account_info(client, account) + if account_info is None: + logger.debug("Minimum balance required for account {}".format(minimum_balance)) + + trx.add(createAccountWithSeedTrx(funding.public_key(), base.public_key(), seed, minimum_balance, storage_size, PublicKey(evm_loader_id))) + else: + (tag, lamports, owner) = account_info + if lamports < minimum_balance: + raise Exception("insufficient balance") + if PublicKey(owner) != PublicKey(evm_loader_id): + raise Exception("wrong owner") + if tag != EMPTY_STORAGE_TAG: + raise Exception("not empty") + + if len(trx.instructions) > 0: + send_transaction(client, trx, funding) + + return accounts + + def make_keccak_instruction_data(check_instruction_index, msg_len, data_start): if check_instruction_index > 255 and check_instruction_index < 0: raise Exception("Invalid index for instruction - {}".format(check_instruction_index)) @@ -472,33 +583,33 @@ def check_if_continue_returned(result): return (False, ()) -def call_continue(signer, client, perm_accs, trx_accs, steps, eth_trx): +def call_continue(signer, client, perm_accs, trx_info, steps): try: - return call_continue_iterative(signer, client, perm_accs, trx_accs, steps, eth_trx) + return call_continue_iterative(signer, client, perm_accs, trx_info, steps) except Exception as err: logger.debug("call_continue_iterative exception:") logger.debug(str(err)) - return sol_instr_21_cancel(signer, client, perm_accs, trx_accs, eth_trx) + return sol_instr_21_cancel(signer, client, perm_accs, trx_info) -def call_continue_iterative(signer, client, perm_accs, trx_accs, step_count, eth_trx): +def call_continue_iterative(signer, client, perm_accs, trx_info, step_count): while True: logger.debug("Continue iterative step:") - result = sol_instr_10_continue(signer, client, perm_accs, trx_accs, step_count, eth_trx) + result = sol_instr_10_continue(signer, client, perm_accs, trx_info, step_count) (succeed, signature) = check_if_continue_returned(result) if succeed: return signature -def sol_instr_10_continue(signer, client, perm_accs, trx_accs, initial_step_count, eth_trx): +def sol_instr_10_continue(signer, client, perm_accs, trx_info, initial_step_count): step_count = initial_step_count while step_count > 0: trx = Transaction() - trx.add(make_continue_instruction(perm_accs, trx_accs, step_count)) + trx.add(make_continue_instruction(signer, perm_accs, trx_info, step_count)) logger.debug("Step count {}".format(step_count)) try: - result = send_measured_transaction(client, trx, signer, eth_trx, 'ContinueV02') + result = send_measured_transaction(client, trx, signer, trx_info.eth_trx, 'ContinueV02') return result except SendTransactionError as err: if check_if_program_exceeded_instructions(err.result): @@ -508,53 +619,62 @@ def sol_instr_10_continue(signer, client, perm_accs, trx_accs, initial_step_coun raise Exception("Can't execute even one EVM instruction") -def sol_instr_21_cancel(signer, client, perm_accs, trx_accs, eth_trx): +def sol_instr_21_cancel(signer, client, perm_accs, trx_info): + operator = signer.public_key() + operator_token = getTokenAddr(operator) + trx = Transaction() trx.add(TransactionInstruction( program_id=evm_loader_id, - data=bytearray.fromhex("15") + trx_accs.nonce.to_bytes(8, 'little'), + data=bytearray.fromhex("15") + trx_info.nonce.to_bytes(8, 'little'), keys=[ AccountMeta(pubkey=perm_accs.storage, is_signer=False, is_writable=True), - AccountMeta(pubkey=perm_accs.operator, is_signer=True, is_writable=True), - AccountMeta(pubkey=perm_accs.operator_token, is_signer=False, is_writable=True), - AccountMeta(pubkey=trx_accs.caller_token, is_signer=False, is_writable=True), + AccountMeta(pubkey=operator, is_signer=True, is_writable=True), + AccountMeta(pubkey=operator_token, is_signer=False, is_writable=True), + AccountMeta(pubkey=trx_info.caller_token, is_signer=False, is_writable=True), AccountMeta(pubkey=incinerator, is_signer=False, is_writable=True), AccountMeta(pubkey=system, is_signer=False, is_writable=False), - ] + trx_accs.eth_accounts + [ + ] + trx_info.eth_accounts + [ AccountMeta(pubkey=sysinstruct, is_signer=False, is_writable=False), ] + obligatory_accounts )) logger.debug("Cancel") - result = send_measured_transaction(client, trx, signer, eth_trx, 'CancelWithNonce') + result = send_measured_transaction(client, trx, signer, trx_info.eth_trx, 'CancelWithNonce') return result['result']['transaction']['signatures'][0] -def make_partial_call_instruction(perm_accs, trx_accs, step_count, call_data): +def make_partial_call_instruction(signer, perm_accs, trx_info, step_count, call_data): + operator = signer.public_key() + operator_token = getTokenAddr(operator) + return TransactionInstruction( program_id = evm_loader_id, - data = bytearray.fromhex("13") + perm_accs.collateral_pool_index_buf + step_count.to_bytes(8, byteorder="little") + call_data, + data = bytearray.fromhex("13") + trx_info.collateral_pool_index_buf + step_count.to_bytes(8, byteorder="little") + call_data, keys = [ AccountMeta(pubkey=perm_accs.storage, is_signer=False, is_writable=True), AccountMeta(pubkey=sysinstruct, is_signer=False, is_writable=False), - AccountMeta(pubkey=perm_accs.operator, is_signer=True, is_writable=True), - AccountMeta(pubkey=perm_accs.collateral_pool_address, is_signer=False, is_writable=True), - AccountMeta(pubkey=perm_accs.operator_token, is_signer=False, is_writable=True), - AccountMeta(pubkey=trx_accs.caller_token, is_signer=False, is_writable=True), + AccountMeta(pubkey=operator, is_signer=True, is_writable=True), + AccountMeta(pubkey=trx_info.collateral_pool_address, is_signer=False, is_writable=True), + AccountMeta(pubkey=operator_token, is_signer=False, is_writable=True), + AccountMeta(pubkey=trx_info.caller_token, is_signer=False, is_writable=True), AccountMeta(pubkey=system, is_signer=False, is_writable=False), - ] + trx_accs.eth_accounts + [ + ] + trx_info.eth_accounts + [ AccountMeta(pubkey=sysinstruct, is_signer=False, is_writable=False), ] + obligatory_accounts ) -def make_continue_instruction(perm_accs, trx_accs, step_count, index=None): - data = bytearray.fromhex("14") + perm_accs.collateral_pool_index_buf + step_count.to_bytes(8, byteorder="little") +def make_continue_instruction(signer, perm_accs, trx_info, step_count, index=None): + operator = signer.public_key() + operator_token = getTokenAddr(operator) + + data = bytearray.fromhex("14") + trx_info.collateral_pool_index_buf + step_count.to_bytes(8, byteorder="little") if index: data = data + index.to_bytes(8, byteorder="little") @@ -564,53 +684,59 @@ def make_continue_instruction(perm_accs, trx_accs, step_count, index=None): keys = [ AccountMeta(pubkey=perm_accs.storage, is_signer=False, is_writable=True), - AccountMeta(pubkey=perm_accs.operator, is_signer=True, is_writable=True), - AccountMeta(pubkey=perm_accs.collateral_pool_address, is_signer=False, is_writable=True), - AccountMeta(pubkey=perm_accs.operator_token, is_signer=False, is_writable=True), - AccountMeta(pubkey=trx_accs.caller_token, is_signer=False, is_writable=True), + AccountMeta(pubkey=operator, is_signer=True, is_writable=True), + AccountMeta(pubkey=trx_info.collateral_pool_address, is_signer=False, is_writable=True), + AccountMeta(pubkey=operator_token, is_signer=False, is_writable=True), + AccountMeta(pubkey=trx_info.caller_token, is_signer=False, is_writable=True), AccountMeta(pubkey=system, is_signer=False, is_writable=False), - ] + trx_accs.eth_accounts + [ + ] + trx_info.eth_accounts + [ AccountMeta(pubkey=sysinstruct, is_signer=False, is_writable=False), ] + obligatory_accounts ) -def make_call_from_account_instruction(perm_accs, trx_accs, step_count = 0): +def make_call_from_account_instruction(signer, perm_accs, trx_info, step_count = 0): + operator = signer.public_key() + operator_token = getTokenAddr(operator) + return TransactionInstruction( program_id = evm_loader_id, - data = bytearray.fromhex("16") + perm_accs.collateral_pool_index_buf + step_count.to_bytes(8, byteorder="little"), + data = bytearray.fromhex("16") + trx_info.collateral_pool_index_buf + step_count.to_bytes(8, byteorder="little"), keys = [ AccountMeta(pubkey=perm_accs.holder, is_signer=False, is_writable=True), AccountMeta(pubkey=perm_accs.storage, is_signer=False, is_writable=True), - AccountMeta(pubkey=perm_accs.operator, is_signer=True, is_writable=True), - AccountMeta(pubkey=perm_accs.collateral_pool_address, is_signer=False, is_writable=True), - AccountMeta(pubkey=perm_accs.operator_token, is_signer=False, is_writable=True), - AccountMeta(pubkey=trx_accs.caller_token, is_signer=False, is_writable=True), + AccountMeta(pubkey=operator, is_signer=True, is_writable=True), + AccountMeta(pubkey=trx_info.collateral_pool_address, is_signer=False, is_writable=True), + AccountMeta(pubkey=operator_token, is_signer=False, is_writable=True), + AccountMeta(pubkey=trx_info.caller_token, is_signer=False, is_writable=True), AccountMeta(pubkey=system, is_signer=False, is_writable=False), - ] + trx_accs.eth_accounts + [ + ] + trx_info.eth_accounts + [ AccountMeta(pubkey=sysinstruct, is_signer=False, is_writable=False), ] + obligatory_accounts ) -def make_05_call_instruction(perm_accs, trx_accs, call_data): +def make_05_call_instruction(signer, trx_info, call_data): + operator = signer.public_key() + operator_token = getTokenAddr(operator) + return TransactionInstruction( program_id = evm_loader_id, - data = bytearray.fromhex("05") + perm_accs.collateral_pool_index_buf + call_data, + data = bytearray.fromhex("05") + trx_info.collateral_pool_index_buf + call_data, keys = [ AccountMeta(pubkey=sysinstruct, is_signer=False, is_writable=False), - AccountMeta(pubkey=perm_accs.operator, is_signer=True, is_writable=True), - AccountMeta(pubkey=perm_accs.collateral_pool_address, is_signer=False, is_writable=True), - AccountMeta(pubkey=perm_accs.operator_token, is_signer=False, is_writable=True), - AccountMeta(pubkey=trx_accs.caller_token, is_signer=False, is_writable=True), + AccountMeta(pubkey=operator, is_signer=True, is_writable=True), + AccountMeta(pubkey=trx_info.collateral_pool_address, is_signer=False, is_writable=True), + AccountMeta(pubkey=operator_token, is_signer=False, is_writable=True), + AccountMeta(pubkey=trx_info.caller_token, is_signer=False, is_writable=True), AccountMeta(pubkey=system, is_signer=False, is_writable=False), - ] + trx_accs.eth_accounts + obligatory_accounts + ] + trx_info.eth_accounts + obligatory_accounts ) @@ -808,14 +934,14 @@ def create_account_list_by_emulate(signer, client, eth_trx): AccountMeta(pubkey=caller_token, is_signer=False, is_writable=True), ] + add_keys_05 - trx_accs = TransactionInfo(caller_token, eth_accounts, eth_trx.nonce) + trx_info = TransactionInfo(caller_token, eth_accounts, eth_trx) - return (trx_accs, sender_ether, trx) + return (trx_info, sender_ether, trx) -def call_signed(signer, client, eth_trx, perm_accs, steps): +def call_signed(signer, client, eth_trx, steps): - (trx_accs, sender_ether, create_acc_trx) = create_account_list_by_emulate(signer, client, eth_trx) + (trx_info, sender_ether, create_acc_trx) = create_account_list_by_emulate(signer, client, eth_trx) call_iterative = False call_from_holder = False @@ -827,7 +953,7 @@ def call_signed(signer, client, eth_trx, perm_accs, steps): try: logger.debug("Try single trx call") - return call_signed_noniterative(signer, client, eth_trx, perm_accs, trx_accs, msg, create_acc_trx) + return call_signed_noniterative(signer, client, eth_trx, trx_info, msg, create_acc_trx) except Exception as err: logger.debug(str(err)) errStr = str(err) @@ -840,21 +966,25 @@ def call_signed(signer, client, eth_trx, perm_accs, steps): else: raise - if call_iterative: - try: - return call_signed_iterative(signer, client, eth_trx, perm_accs, trx_accs, steps, msg, create_acc_trx) - except Exception as err: - logger.debug(str(err)) - if str(err).startswith("transaction too large:"): - logger.debug("Transaction too large, call call_signed_with_holder_acc():") - call_from_holder = True - else: - raise + perm_accs = PermanentAccounts(client, signer) + try: + if call_iterative: + try: + return call_signed_iterative(signer, client, eth_trx, perm_accs, trx_info, steps, msg, create_acc_trx) + except Exception as err: + logger.debug(str(err)) + if str(err).startswith("transaction too large:"): + logger.debug("Transaction too large, call call_signed_with_holder_acc():") + call_from_holder = True + else: + raise - if call_from_holder: - return call_signed_with_holder_acc(signer, client, eth_trx, perm_accs, trx_accs, steps, create_acc_trx) + if call_from_holder: + return call_signed_with_holder_acc(signer, client, eth_trx, perm_accs, trx_info, steps, create_acc_trx) + finally: + del perm_accs -def call_signed_iterative(signer, client, eth_trx, perm_accs, trx_accs, steps, msg, create_acc_trx): +def call_signed_iterative(signer, client, eth_trx, perm_accs, trx_info, steps, msg, create_acc_trx): if len(create_acc_trx.instructions): precall_txs = Transaction() precall_txs.add(create_acc_trx) @@ -867,15 +997,15 @@ def call_signed_iterative(signer, client, eth_trx, perm_accs, trx_accs, steps, m keys=[ AccountMeta(pubkey=keccakprog, is_signer=False, is_writable=False), ])) - precall_txs.add(make_partial_call_instruction(perm_accs, trx_accs, 0, msg)) + precall_txs.add(make_partial_call_instruction(signer, perm_accs, trx_info, 0, msg)) logger.debug("Partial call") send_measured_transaction(client, precall_txs, signer, eth_trx, 'PartialCallFromRawEthereumTXv02') - return call_continue(signer, client, perm_accs, trx_accs, steps, eth_trx) + return call_continue(signer, client, perm_accs, trx_info, steps) -def call_signed_noniterative(signer, client, eth_trx, perm_accs, trx_accs, msg, create_acc_trx): +def call_signed_noniterative(signer, client, eth_trx, trx_info, msg, create_acc_trx): call_txs_05 = Transaction() call_txs_05.add(create_acc_trx) call_txs_05.add(TransactionInstruction( @@ -884,27 +1014,27 @@ def call_signed_noniterative(signer, client, eth_trx, perm_accs, trx_accs, msg, keys=[ AccountMeta(pubkey=keccakprog, is_signer=False, is_writable=False), ])) - call_txs_05.add(make_05_call_instruction(perm_accs, trx_accs, msg)) + call_txs_05.add(make_05_call_instruction(signer, trx_info, msg)) result = send_measured_transaction(client, call_txs_05, signer, eth_trx, 'CallFromRawEthereumTX') return result['result']['transaction']['signatures'][0] -def call_signed_with_holder_acc(signer, client, eth_trx, perm_accs, trx_accs, steps, create_acc_trx): +def call_signed_with_holder_acc(signer, client, eth_trx, perm_accs, trx_info, steps, create_acc_trx): - write_trx_to_holder_account(signer, client, perm_accs.holder, perm_accs.proxy_id, eth_trx) + write_trx_to_holder_account(signer, client, perm_accs.holder, perm_accs.acc_id, eth_trx) if len(create_acc_trx.instructions): precall_txs = Transaction() precall_txs.add(create_acc_trx) send_measured_transaction(client, precall_txs, signer, eth_trx, 'create_accounts_for_deploy') precall_txs = Transaction() - precall_txs.add(make_call_from_account_instruction(perm_accs, trx_accs)) + precall_txs.add(make_call_from_account_instruction(signer, perm_accs, trx_info)) # ExecuteTrxFromAccountDataIterative logger.debug("ExecuteTrxFromAccountDataIterative:") send_measured_transaction(client, precall_txs, signer, eth_trx, 'ExecuteTrxFromAccountDataIterativeV02') - return call_continue(signer, client, perm_accs, trx_accs, steps, eth_trx) + return call_continue(signer, client, perm_accs, trx_info, steps) def createEtherAccountTrx(client, ether, evm_loader_id, signer, code_acc=None): @@ -973,7 +1103,7 @@ def createERC20TokenAccountTrx(signer, token_info): -def write_trx_to_holder_account(signer, client, holder, proxy_id, eth_trx): +def write_trx_to_holder_account(signer, client, holder, acc_id, eth_trx): msg = eth_trx.signature() + len(eth_trx.unsigned_msg()).to_bytes(8, byteorder="little") + eth_trx.unsigned_msg() # Write transaction to transaction holder account @@ -985,7 +1115,7 @@ def write_trx_to_holder_account(signer, client, holder, proxy_id, eth_trx): trx = Transaction() # logger.debug("sender_sol %s %s %s", sender_sol, holder, acc.public_key()) trx.add(TransactionInstruction(program_id=evm_loader_id, - data=write_holder_layout(proxy_id, offset, part), + data=write_holder_layout(acc_id, offset, part), keys=[ AccountMeta(pubkey=holder, is_signer=False, is_writable=True), AccountMeta(pubkey=signer.public_key(), is_signer=True, is_writable=False), diff --git a/proxy/run-proxy.sh b/proxy/run-proxy.sh index ac01288a5..262ed2e1e 100755 --- a/proxy/run-proxy.sh +++ b/proxy/run-proxy.sh @@ -10,7 +10,7 @@ if [ "$CONFIG" == "ci" ]; then [[ -z "$NEW_USER_AIRDROP_AMOUNT" ]] && export NEW_USER_AIRDROP_AMOUNT=100 [[ -z "$EXTRA_GAS" ]] && export EXTRA_GAS=100000 [[ -z "$NEON_CLI_TIMEOUT" ]] && export NEON_CLI_TIMEOUT="0.5" - [[ -z "$USE_COMBINED_START_CONTINUE" ]] && export USE_COMBINED_START_CONTINUE="YES" + [[ -z "$USE_COMBINED_START_CONTINUE" ]] && export USE_COMBINED_START_CONTINUE="NO" [[ -z "$CONTINUE_COUNT_FACTOR" ]] && export CONTINUE_COUNT_FACTOR="3" [[ -z "$MINIMAL_GAS_PRICE" ]] && export MINIMAL_GAS_PRICE=0 [[ -z "$POSTGRES_HOST" ]] && export POSTGRES_HOST="postgres"