diff --git a/proxy/plugin/solana_rest_api.py b/proxy/plugin/solana_rest_api.py index 115ef7d16..a3e2489b6 100644 --- a/proxy/plugin/solana_rest_api.py +++ b/proxy/plugin/solana_rest_api.py @@ -21,7 +21,7 @@ from ..http.server import HttpWebServerBasePlugin, httpProtocolTypes from .eth_proto import Trx as EthTrx from solana.rpc.api import Client as SolanaClient -from sha3 import keccak_256, shake_256 +from sha3 import keccak_256 import base58 import traceback import threading @@ -49,15 +49,15 @@ 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') - signer_public_key_bytes = bytes(signer.public_key()) - storage_seed = shake_256(b"storage" + proxy_id_bytes + signer_public_key_bytes).hexdigest(16) + 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 = shake_256(b"holder" + proxy_id_bytes + signer_public_key_bytes).hexdigest(16) + 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) diff --git a/proxy/plugin/solana_rest_api_tools.py b/proxy/plugin/solana_rest_api_tools.py index a46fab3cd..8e1011e80 100644 --- a/proxy/plugin/solana_rest_api_tools.py +++ b/proxy/plugin/solana_rest_api_tools.py @@ -94,7 +94,6 @@ AccountMeta(pubkey=sysvarclock, is_signer=False, is_writable=False), ] - class TransactionAccounts: def __init__(self, caller_token, eth_accounts): self.caller_token = caller_token @@ -118,10 +117,11 @@ def create_account_layout(lamports, space, ether, nonce): nonce=nonce )) -def write_layout(offset, data): - return (bytes.fromhex("00000000")+ - offset.to_bytes(4, byteorder="little")+ - len(data).to_bytes(8, byteorder="little")+ +def write_holder_layout(nonce, offset, data): + return (bytes.fromhex('12')+ + nonce.to_bytes(8, byteorder='little')+ + offset.to_bytes(4, byteorder='little')+ + len(data).to_bytes(8, byteorder='little')+ data) def accountWithSeed(base, seed, program): @@ -1059,7 +1059,7 @@ def call_signed_noniterative(signer, client, ethTrx, perm_accs, trx_accs, msg, c def call_signed_with_holder_acc(signer, client, ethTrx, perm_accs, trx_accs, steps, create_acc_trx): - write_trx_to_holder_account(signer, client, perm_accs.holder, ethTrx) + write_trx_to_holder_account(signer, client, perm_accs.holder, perm_accs.proxy_id, ethTrx) if len(create_acc_trx.instructions): precall_txs = Transaction() @@ -1142,7 +1142,7 @@ def createERC20TokenAccountTrx(signer, token_info): -def write_trx_to_holder_account(signer, client, holder, ethTrx): +def write_trx_to_holder_account(signer, client, holder, proxy_id, ethTrx): msg = ethTrx.signature() + len(ethTrx.unsigned_msg()).to_bytes(8, byteorder="little") + ethTrx.unsigned_msg() # Write transaction to transaction holder account @@ -1154,7 +1154,7 @@ def write_trx_to_holder_account(signer, client, holder, ethTrx): 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_layout(offset, part), + data=write_holder_layout(proxy_id, offset, part), keys=[ AccountMeta(pubkey=holder, is_signer=False, is_writable=True), AccountMeta(pubkey=signer.public_key(), is_signer=True, is_writable=False), @@ -1167,7 +1167,6 @@ def write_trx_to_holder_account(signer, client, holder, ethTrx): confirm_transaction(client, rcpt) logger.debug("confirmed: %s", rcpt) - def _getAccountData(client, account, expected_length, owner=None): info = client.get_account_info(account, commitment=Confirmed)['result']['value'] if info is None: