Skip to content

Commit a8eab63

Browse files
authored
#272 manage starage and holder accounts (#274)
* #272 get free accounts on each call * #272 create and delete account on every ethereum trx * #272 simplify index aquiring * #272 move realisation into *tools module * #272 lot of changes * #272 better iterative tests * #272 merge fix * #272 disabe combined instructions * #272 back to resources * #272 return tag instead of emptiness flag
1 parent 06b85c2 commit a8eab63

File tree

4 files changed

+211
-101
lines changed

4 files changed

+211
-101
lines changed

proxy/core/acceptor/pool.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,9 @@
2727
LOCK = multiprocessing.Lock()
2828

2929
proxy_id_glob = multiprocessing.Value('i', 0)
30+
new_acc_id_glob = multiprocessing.Value('i', 0)
31+
manager = multiprocessing.Manager()
32+
acc_list_glob = manager.list()
3033

3134

3235
class AcceptorPool:

proxy/plugin/solana_rest_api.py

Lines changed: 3 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,8 @@
2525
import base58
2626
import traceback
2727
import threading
28-
from .solana_rest_api_tools import EthereumAddress, create_account_with_seed, getTokens, \
29-
getAccountInfo, call_signed, call_emulated, \
30-
Trx, EthereumError, create_collateral_pool_address, getTokenAddr, STORAGE_SIZE, neon_config_load, MINIMAL_GAS_PRICE
28+
from .solana_rest_api_tools import EthereumAddress, getTokens, getAccountInfo, \
29+
call_signed, call_emulated, EthereumError, neon_config_load, MINIMAL_GAS_PRICE
3130
from solana.rpc.commitment import Commitment, Confirmed
3231
from web3 import Web3
3332
import logging
@@ -45,27 +44,6 @@
4544

4645
EXTRA_GAS = int(os.environ.get("EXTRA_GAS", "0"))
4746

48-
class PermanentAccounts:
49-
def __init__(self, client, signer, proxy_id):
50-
self.operator = signer.public_key()
51-
self.operator_token = getTokenAddr(self.operator)
52-
self.proxy_id = proxy_id
53-
54-
proxy_id_bytes = proxy_id.to_bytes((proxy_id.bit_length() + 7) // 8, 'big')
55-
56-
storage_seed = keccak_256(b"storage" + proxy_id_bytes).hexdigest()[:32]
57-
storage_seed = bytes(storage_seed, 'utf8')
58-
self.storage = create_account_with_seed(client, funding=signer, base=signer, seed=storage_seed, storage_size=STORAGE_SIZE)
59-
60-
holder_seed = keccak_256(b"holder" + proxy_id_bytes).hexdigest()[:32]
61-
holder_seed = bytes(holder_seed, 'utf8')
62-
self.holder = create_account_with_seed(client, funding=signer, base=signer, seed=holder_seed, storage_size=STORAGE_SIZE)
63-
64-
collateral_pool_index = proxy_id % 4
65-
self.collateral_pool_index_buf = collateral_pool_index.to_bytes(4, 'little')
66-
self.collateral_pool_address = create_collateral_pool_address(collateral_pool_index)
67-
68-
6947
class EthereumModel:
7048
def __init__(self):
7149
# Initialize user account
@@ -98,7 +76,6 @@ def __init__(self):
9876
proxy_id_glob.value += 1
9977
logger.debug("worker id {}".format(self.proxy_id))
10078

101-
self.perm_accs = PermanentAccounts(self.client, self.signer, self.proxy_id)
10279
neon_config_load(self)
10380
pass
10481

@@ -415,7 +392,7 @@ def eth_sendRawTransaction(self, rawTrx):
415392
]
416393
})
417394
try:
418-
signature = call_signed(self.signer, self.client, trx, self.perm_accs, steps=250)
395+
signature = call_signed(self.signer, self.client, trx, steps=250)
419396

420397
logger.debug('Transaction signature: %s %s', signature, eth_signature)
421398

0 commit comments

Comments
 (0)