Skip to content
Merged
Changes from 1 commit
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
90a4e56
#291 extract transaction sender class
otselnik Nov 14, 2021
143913b
#291 move perm accs to transaction sender
otselnik Nov 16, 2021
16c9bff
#291 fix state
otselnik Nov 22, 2021
f2c0303
#291 fix errors
otselnik Nov 23, 2021
57f3b53
Merge remote-tracking branch 'origin/develop' into 291_proxy_refactoring
otselnik Nov 23, 2021
3369f67
#291 merge fixes
otselnik Nov 23, 2021
af721bb
#291 refactoring
otselnik Nov 23, 2021
e512bb8
#291 move EXTRA_GAS to environment
otselnik Nov 23, 2021
8dc5e29
#291 capitalize CONFIRMATION_CHECK_DELAY
otselnik Nov 23, 2021
8dce2a5
#291 sort imports
otselnik Nov 23, 2021
cef8f21
#291 relative paths
otselnik Nov 24, 2021
1bf8383
#291 Should be fixed in #326
otselnik Nov 24, 2021
9672438
#291 testing chnages
otselnik Nov 24, 2021
2d42b73
fix storage account check
sinev-valentine Nov 24, 2021
ac2755c
Merge remote-tracking branch 'origin/develop' into 291_proxy_refactoring
otselnik Nov 24, 2021
3519c61
Merge branch '371_add_FinalizedStorage_to_check' into 291_proxy_refac…
otselnik Nov 24, 2021
bf313a2
#291 rename `trx_with_create_and_airdrop` -> `make_trx_with_create_an…
otselnik Nov 24, 2021
3093fcc
Merge remote-tracking branch 'origin/develop' into 291_proxy_refactoring
otselnik Nov 24, 2021
e3c4e33
#295 fix state
otselnik Nov 24, 2021
9b57e53
#291 iterative combined
otselnik Nov 25, 2021
ccffcf4
#295 do not get measurments
otselnik Nov 25, 2021
4d685db
#291 pull request fixes
otselnik Nov 25, 2021
6f63338
Merge remote-tracking branch 'origin/develop' into 291_proxy_refactoring
otselnik Nov 25, 2021
4546926
Merge branch '291_proxy_refactoring' into 295_iterative_execution
otselnik Nov 25, 2021
7befc6b
#295 turn combined instructions ON
otselnik Nov 29, 2021
b5010f8
#295 make neon_instructions return transasactions
otselnik Nov 29, 2021
5ebf76a
Merge remote-tracking branch 'origin/develop' into 291_proxy_refactoring
otselnik Dec 2, 2021
b464b1e
#291 merge fix
otselnik Dec 2, 2021
79088c6
#295 get rid of `USE_COMBINED_START_CONTINUE`
otselnik Dec 2, 2021
52173a0
Merge branch '291_proxy_refactoring' into 295_iterative_execution
otselnik Dec 2, 2021
4fe15e9
#295 requested fixes
otselnik Dec 2, 2021
607e74e
Merge remote-tracking branch 'origin/develop' into 295_iterative_exec…
otselnik Dec 2, 2021
d9f762a
#295 call_continue_bucked refactoring
otselnik Dec 2, 2021
842ec7d
#295 fix
otselnik Dec 3, 2021
78de121
#295 leave only combined iterative transactions
otselnik Dec 3, 2021
47cf219
#295 move constants into class
otselnik Dec 3, 2021
0eebc1f
#295 refactoring
otselnik Dec 3, 2021
cec7a38
Merge remote-tracking branch 'origin/develop' into 295_iterative_exec…
otselnik Dec 6, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
#295 move constants into class
  • Loading branch information
otselnik committed Dec 3, 2021
commit 47cf219d7504115d6da431ec5bf7de374cf625f8
46 changes: 24 additions & 22 deletions proxy/common_neon/transaction_sender.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,6 @@
logger.setLevel(logging.DEBUG)


CONTINUE_REGULAR = 'ContinueV02'
CONTINUE_COMBINED = 'PartialCallOrContinueFromRawEthereumTX'
CONTINUE_HOLDER_COMB = 'ExecuteTrxFromAccountDataIterativeOrContinue'


class TransactionSender:
def __init__(self, solana_interactor: SolanaInteractor, eth_trx: EthTrx, steps: int) -> None:
self.sender = solana_interactor
Expand Down Expand Up @@ -329,24 +324,31 @@ def call_signed_noniterative(self):


class IterativeTransactionSender:
CONTINUE_REGULAR = 'ContinueV02'
CONTINUE_COMBINED = 'PartialCallOrContinueFromRawEthereumTX'
CONTINUE_HOLDER_COMB = 'ExecuteTrxFromAccountDataIterativeOrContinue'

def __init__(self, solana_interactor: SolanaInteractor, neon_instruction: NeonInstruction, create_acc_trx: Transaction, eth_trx: EthTrx, steps: int, steps_emulated: int):
self.sender = solana_interactor
self.instruction = neon_instruction
self.create_acc_trx = create_acc_trx
self.eth_trx = eth_trx
self.steps = steps
self.steps_emulated = steps_emulated
self.instruction_type = self.CONTINUE_REGULAR


def call_signed_iterative_combined(self):
self.create_accounts_for_trx()
return self.call_continue(CONTINUE_COMBINED)
self.instruction_type = self.CONTINUE_COMBINED
return self.call_continue()


def call_signed_with_holder_combined(self):
self.write_trx_to_holder_account()
self.create_accounts_for_trx()
return self.call_continue(CONTINUE_HOLDER_COMB)
self.instruction_type = self.CONTINUE_HOLDER_COMB
return self.call_continue()


def create_accounts_for_trx(self):
Expand Down Expand Up @@ -376,10 +378,10 @@ def write_trx_to_holder_account(self):
self.sender.collect_results(receipts, eth_trx=self.eth_trx, reason='WriteHolder')


Copy link
Contributor

Choose a reason for hiding this comment

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

single blank line in python classes separates methods

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think we need just some issue for styling. Not here

def call_continue(self, instruction_type):
def call_continue(self):
return_result = None
try:
return_result = self.call_continue_bucked(instruction_type)
return_result = self.call_continue_bucked()
except Exception as err:
logger.debug("call_continue_bucked_combined exception: {}".format(str(err)))

Expand Down Expand Up @@ -433,14 +435,14 @@ def call_cancel(self):
return result['result']['transaction']['signatures'][0]


def call_continue_bucked(self, instruction_type):
logger.debug("Send bucked combined: %s", instruction_type)
def call_continue_bucked(self):
logger.debug("Send bucked combined: %s", self.instruction_type)
steps = self.steps

receipts = []
for index in range(math.ceil(self.steps_emulated/self.steps) + self.addition_count(instruction_type)):
for index in range(math.ceil(self.steps_emulated/self.steps) + self.addition_count()):
try:
Copy link
Contributor

Choose a reason for hiding this comment

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

This method is too heave, you can isolate some logically independent parts

trx = self.make_bucked_trx(instruction_type, steps, index)
trx = self.make_bucked_trx(steps, index)

receipts.append(self.sender.send_transaction_unconfirmed(trx))
except SendTransactionError as err:
Expand All @@ -461,34 +463,34 @@ def call_continue_bucked(self, instruction_type):
else:
raise

return self.collect_bucked_results(receipts, instruction_type)
return self.collect_bucked_results(receipts, self.instruction_type)


@staticmethod
def addition_count(instruction_type):
def addition_count(self):
'''
How many transactions are needed depending on trx type:
CONTINUE_COMBINED: 2 (1 for begin and 1 for decreased steps)
CONTINUE_HOLDER_COMB: 1 for begin
0 otherwise
'''
addition_count = 0
if instruction_type == CONTINUE_COMBINED:
if self.instruction_type == self.CONTINUE_COMBINED:
addition_count = 2
elif instruction_type == CONTINUE_HOLDER_COMB:
elif self.instruction_type == self.CONTINUE_HOLDER_COMB:
addition_count = 1
return addition_count


def make_bucked_trx(self, instruction_type, steps, index):
if instruction_type == CONTINUE_REGULAR:
def make_bucked_trx(self, steps, index):
if self.instruction_type == self.CONTINUE_REGULAR:
return self.instruction.make_continue_transaction(steps, index)
elif instruction_type == CONTINUE_COMBINED:
elif self.instruction_type == self.CONTINUE_COMBINED:
return self.instruction.make_partial_call_or_continue_transaction(steps - index)
elif instruction_type == CONTINUE_HOLDER_COMB:
elif self.instruction_type == self.CONTINUE_HOLDER_COMB:
return self.instruction.make_partial_call_or_continue_from_account_data(steps, index)
else:
raise Exception("Unknown continue type: {}".format(instruction_type))
raise Exception("Unknown continue type: {}".format(self.instruction_type))


def collect_bucked_results(self, receipts, reason):
Expand Down