-
Notifications
You must be signed in to change notification settings - Fork 20
#291 Proxy refactoring #324
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
| return self | ||
|
|
||
|
|
||
| def create_collateral_pool_address(self, collateral_pool_index): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
proxy/common_neon/address.py
Outdated
| def __bytes__(self): return self.data | ||
|
|
||
|
|
||
| def accountWithSeed(base, seed, program=PublicKey(EVM_LOADER_ID)): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
program redundant
proxy/common_neon/address.py
Outdated
|
|
||
| def accountWithSeed(base, seed, program=PublicKey(EVM_LOADER_ID)): | ||
| result = PublicKey(sha256(bytes(base) + bytes(seed) + bytes(program)).digest()) | ||
| logger.debug('accountWithSeed %s', str(result)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
logging here redundant
| ) | ||
|
|
||
|
|
||
| def make_create_eth_account_trx(self, eth_address, code_acc=None): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Original definition is:
def make_create_eth_account_trx(signer: SolanaAccount, eth_address: EthereumAddress, evm_loader_id, code_acc=None) \
-> Tuple[Transaction, PublicKey]:|
|
||
| class NeonInstruction: | ||
| def __init__(self, operator): | ||
| self.operator = operator |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
self.operator_pda_account: SolanaAccount = operator_pda_account
| class NeonInstruction: | ||
| def __init__(self, operator): | ||
| self.operator = operator | ||
| self.operator_token = getTokenAddr(self.operator) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
operator_associated_token_address: PulicKey = ...
|
|
||
|
|
||
| def make_transfer_instruction(self, associated_token_account: PublicKey) -> TransactionInstruction: | ||
| owner_associated_token_account = getTokenAddr(self.operator) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Already have operator_token )
| for acc_desc in output_json["accounts"]: | ||
| if acc_desc["new"] == False: | ||
|
|
||
| address = bytes.fromhex(acc_desc["address"][2:]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It was dropped from develop branch before
| elapsed_time += CONFIRMATION_CHECK_DELAY | ||
| #if not resp["result"]: | ||
| raise RuntimeError("could not confirm transaction: ", tx_sig) | ||
| #return resp |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
was removed from develop before
| return | ||
| time.sleep(CONFIRMATION_CHECK_DELAY) | ||
| elapsed_time += CONFIRMATION_CHECK_DELAY | ||
| #if not resp["result"]: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
was removed from here before
| status = resp['result']['value'][0] | ||
| if status and (status['confirmationStatus'] == 'finalized' or \ | ||
| status['confirmationStatus'] == 'confirmed' and status['confirmations'] >= confirmations): | ||
| # logger.debug('Confirmed transaction:', resp) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
was removed from here before
| result = self.call_continue_step() | ||
| signature = check_if_continue_returned(result) | ||
| if signature: | ||
| return signature |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The same as return check_if_continue_returned(result)?
In other case you should check it like that:
if signature is not None:
and return None explicitly
| self.operator_pda_account = operator | ||
| self.operator_associated_token_address = getTokenAddr(self.operator_pda_account) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I suggest renaming back.
We can talk about PDA (Program Derived Address) account only when it is built this way. For the operator's account, it's not correct, because the operator uses their own Solana account, which can't be PDA. So, this name confuse.
Which information gives operator_associated_token_address? I think operator_neon_balance will be better in this case.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, you're right!
I propose instead of associated_token_address use operator_neon_address here and neon_address everywhere it is needed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So, what in the end?
operator_associated_token_address -> operator_neon_balance
associated_token_address -> neon_address or neon_balance?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
operator_neon_address i think. getTokenAddr actually doesn't return a balance )
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's stop on operator_neon_address
* #291 extract transaction sender class * #291 move perm accs to transaction sender * #291 fix state * #291 fix errors * #291 merge fixes * #291 refactoring * #291 move EXTRA_GAS to environment * #291 capitalize CONFIRMATION_CHECK_DELAY * #291 sort imports * #291 relative paths * #291 Should be fixed in #326 * #291 testing chnages * fix storage account check * #291 rename `trx_with_create_and_airdrop` -> `make_trx_with_create_and_airdrop` * #291 pull request fixes * #291 merge fix * #291 rename operator and associated token accounts Co-authored-by: sinev-valentine <[email protected]>
Changes:
proxy.environment.pyproxy/common_neon/transaction_sender.pyTransactionSenderclass is responsible for preparing transaction execution and handling send errorscreate_account_list_by_emulateshould be moved out ofTransactionSenderto own module or classinit_perm_accsfree_perm_accscreate_account_with_seedcreate_multiple_accounts_with_seedfunctions should be extracted out ofTransactionSenderclass too laterproxy/common_neon/transaction_sender.pyNoniterativeTransactionSenderresponsible for creating and sending transactions of non-iterative executionproxy/common_neon/transaction_sender.pyIterativeTransactionSenderresponsible for iterative execution. It creates and sends transactions of iterative execution and controls transaction flow in the iterative processproxy/common_neon/neon_instruction.pyNeonInstructionforms solana instructions/transactionsproxy/common_neon/solana_interactor.pycontains classes and functions for interaction with the Solana cluster and process its responsesproxy/common_neon/solana_interactor.pySolanaInteractoris responsible for sending transactions to the Solana and waiting for responses, It also provides functions to get the Solana stateproxy/common_neon/costs.pycontainsSQLCostclass and functions to process transaction costsproxy/common_neon/address.pyfunctions to manipulate with addressesproxy/common_neon/emulator_interactor.pyfunctions to work withneon-cliemulation.create_account_list_by_emulateshould be move here I guesproxy/common_neon/layouts.pyproxy/common_neon/errors.pyproxy/common_neon/constants.py