Skip to content

Conversation

@otselnik
Copy link
Contributor

@otselnik otselnik commented Nov 23, 2021

Changes:

  • Environment variables acquiring moved to proxy.environment.py
  • Environment variables name capitalized
  • proxy/common_neon/transaction_sender.py TransactionSender class is responsible for preparing transaction execution and handling send errors
  • create_account_list_by_emulate should be moved out of TransactionSender to own module or class
  • init_perm_accs free_perm_accs create_account_with_seed create_multiple_accounts_with_seed functions should be extracted out of TransactionSender class too later
  • proxy/common_neon/transaction_sender.py NoniterativeTransactionSender responsible for creating and sending transactions of non-iterative execution
  • proxy/common_neon/transaction_sender.py IterativeTransactionSender responsible for iterative execution. It creates and sends transactions of iterative execution and controls transaction flow in the iterative process
  • proxy/common_neon/neon_instruction.py NeonInstruction forms solana instructions/transactions
  • proxy/common_neon/solana_interactor.py contains classes and functions for interaction with the Solana cluster and process its responses
  • proxy/common_neon/solana_interactor.py SolanaInteractor is responsible for sending transactions to the Solana and waiting for responses, It also provides functions to get the Solana state
  • proxy/common_neon/costs.py contains SQLCost class and functions to process transaction costs
  • proxy/common_neon/address.py functions to manipulate with addresses
  • proxy/common_neon/emulator_interactor.py functions to work with neon-cli emulation. create_account_list_by_emulate should be move here I gues
  • proxy/common_neon/layouts.py
  • proxy/common_neon/errors.py
  • proxy/common_neon/constants.py

return self


def create_collateral_pool_address(self, collateral_pool_index):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

def __bytes__(self): return self.data


def accountWithSeed(base, seed, program=PublicKey(EVM_LOADER_ID)):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

program redundant


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))
Copy link
Contributor

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):
Copy link
Contributor

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
Copy link
Contributor

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)
Copy link
Contributor

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)
Copy link
Contributor

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:])
Copy link
Contributor

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

@rozhkovdmitrii rozhkovdmitrii self-requested a review November 25, 2021 12:51
rozhkovdmitrii
rozhkovdmitrii previously approved these changes Nov 25, 2021
elapsed_time += CONFIRMATION_CHECK_DELAY
#if not resp["result"]:
raise RuntimeError("could not confirm transaction: ", tx_sig)
#return resp
Copy link
Contributor

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"]:
Copy link
Contributor

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)
Copy link
Contributor

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
Copy link
Contributor

@rozhkovdmitrii rozhkovdmitrii Nov 25, 2021

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

rozhkovdmitrii
rozhkovdmitrii previously approved these changes Nov 26, 2021
Comment on lines 90 to 91
self.operator_pda_account = operator
self.operator_associated_token_address = getTokenAddr(self.operator_pda_account)
Copy link
Contributor

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.

Copy link
Contributor

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.

Copy link
Contributor Author

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?

Copy link
Contributor

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 )

Copy link
Contributor

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

@s-medvedev s-medvedev merged commit e74e568 into develop Dec 2, 2021
@s-medvedev s-medvedev deleted the 291_proxy_refactoring branch December 2, 2021 13:47
vasiliy-zaznobin pushed a commit that referenced this pull request Dec 7, 2021
* #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]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants