-
Notifications
You must be signed in to change notification settings - Fork 20
#295 iterative execution #332
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
Changes from 1 commit
90a4e56
143913b
16c9bff
f2c0303
57f3b53
3369f67
af721bb
e512bb8
8dc5e29
8dce2a5
cef8f21
1bf8383
9672438
2d42b73
ac2755c
3519c61
bf313a2
3093fcc
e3c4e33
9b57e53
ccffcf4
4d685db
6f63338
4546926
7befc6b
b5010f8
5ebf76a
b464b1e
79088c6
52173a0
4fe15e9
607e74e
d9f762a
842ec7d
78de121
47cf219
0eebc1f
cec7a38
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
- Loading branch information
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -121,18 +121,18 @@ def create_collateral_pool_address(collateral_pool_index): | |
| return accountWithSeed(PublicKey(COLLATERAL_POOL_BASE), str.encode(seed)) | ||
|
|
||
|
|
||
| def create_account_with_seed_trx(self, account, seed, lamports, space): | ||
| def create_account_with_seed_trx(self, account, seed, lamports, space) -> Transaction: | ||
| seed_str = str(seed, 'utf8') | ||
| logger.debug("createAccountWithSeedTrx base(%s) account(%s) seed(%s)", type(self.operator_pda_account),account, seed_str) | ||
| return TransactionInstruction( | ||
| return Transaction().add(TransactionInstruction( | ||
| keys=[ | ||
| AccountMeta(pubkey=self.operator_pda_account, is_signer=True, is_writable=True), | ||
| AccountMeta(pubkey=account, is_signer=False, is_writable=True), | ||
| AccountMeta(pubkey=self.operator_pda_account, is_signer=True, is_writable=False), | ||
| ], | ||
| program_id=SYS_PROGRAM_ID, | ||
| data=create_account_with_seed_layout(self.operator_pda_account, seed_str, lamports, space) | ||
| ) | ||
| )) | ||
|
|
||
|
|
||
| def make_create_eth_account_trx(self, eth_address: EthereumAddress, code_acc=None) -> Tuple[Transaction, PublicKey]: | ||
|
|
@@ -301,7 +301,7 @@ def make_partial_call_instruction(self) -> TransactionInstruction: | |
|
|
||
| AccountMeta(pubkey=SYSVAR_INSTRUCTION_PUBKEY, is_signer=False, is_writable=False), | ||
| ] + obligatory_accounts | ||
| ) | ||
| ) | ||
|
|
||
|
|
||
| def make_iterative_call_transaction(self, length_before: int = 0) -> Transaction: | ||
|
|
@@ -311,7 +311,7 @@ def make_iterative_call_transaction(self, length_before: int = 0) -> Transaction | |
| return trx | ||
|
|
||
|
|
||
| def make_call_from_account_instruction(self) -> Transaction: | ||
| def make_call_from_account_transaction(self) -> Transaction: | ||
| return Transaction().add(TransactionInstruction( | ||
| program_id = EVM_LOADER_ID, | ||
| data = bytearray.fromhex("16") + self.collateral_pool_index_buf + int(0).to_bytes(8, byteorder="little"), | ||
|
|
@@ -332,7 +332,7 @@ def make_call_from_account_instruction(self) -> Transaction: | |
| )) | ||
|
|
||
|
|
||
| def make_continue_instruction(self, steps, index=None) -> Transaction: | ||
| def make_continue_transaction(self, steps, index=None) -> Transaction: | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The same. Annotations on arguments |
||
| data = bytearray.fromhex("14") + self.collateral_pool_index_buf + steps.to_bytes(8, byteorder="little") | ||
| if index: | ||
| data = data + index.to_bytes(8, byteorder="little") | ||
|
|
@@ -356,7 +356,7 @@ def make_continue_instruction(self, steps, index=None) -> Transaction: | |
| )) | ||
|
|
||
|
|
||
| def make_cancel_instruction(self) -> Transaction: | ||
| def make_cancel_transaction(self) -> Transaction: | ||
| return Transaction().add(TransactionInstruction( | ||
| program_id = EVM_LOADER_ID, | ||
| data = bytearray.fromhex("15") + self.eth_trx.nonce.to_bytes(8, 'little'), | ||
|
|
@@ -408,7 +408,7 @@ def make_partial_call_or_continue_from_account_data(self, steps, index=None) -> | |
| data = bytearray.fromhex("0E") + self.collateral_pool_index_buf + steps.to_bytes(8, byteorder='little') | ||
| if index: | ||
| data = data + index.to_bytes(8, byteorder="little") | ||
| return TransactionInstruction( | ||
| return Transaction().add(TransactionInstruction( | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. transaction = Transaction()
transaction.add(...)
# or extend_trx_with
# or instruction = make_continue_instruction
return transaction() |
||
| program_id = EVM_LOADER_ID, | ||
| data = data, | ||
| keys = [ | ||
|
|
@@ -425,4 +425,4 @@ def make_partial_call_or_continue_from_account_data(self, steps, index=None) -> | |
|
|
||
| AccountMeta(pubkey=SYSVAR_INSTRUCTION_PUBKEY, is_signer=False, is_writable=False), | ||
| ] + obligatory_accounts | ||
| ) | ||
| )) | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -365,7 +365,7 @@ def call_signed_with_holder_acc(self): | |
| self.create_accounts_for_trx_if_needed() | ||
|
|
||
| logger.debug("ExecuteTrxFromAccountDataIterative:") | ||
| call_txs = self.instruction.make_call_from_account_instruction() | ||
| call_txs = self.instruction.make_call_from_account_transaction() | ||
| self.sender.send_measured_transaction(call_txs, self.eth_trx, 'ExecuteTrxFromAccountDataIterativeV02') | ||
|
|
||
| return self.call_continue(CONTINUE_REGULAR) | ||
|
|
@@ -438,7 +438,7 @@ def call_continue_step_by_step(self): | |
| def call_continue_step(self): | ||
| step_count = self.steps | ||
| while step_count > 0: | ||
| trx = self.instruction.make_continue_instruction(step_count) | ||
| trx = self.instruction.make_continue_transaction(step_count) | ||
|
|
||
| logger.debug("Step count {}".format(step_count)) | ||
| try: | ||
|
|
@@ -453,7 +453,7 @@ def call_continue_step(self): | |
|
|
||
|
|
||
| def call_cancel(self): | ||
| trx = self.instruction.make_cancel_instruction() | ||
| trx = self.instruction.make_cancel_transaction() | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Stay look wierd.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. if you want you can use this function the same way and it will work. trx = Transaction();
cancel_instruction = self.instraction.make_cancel_transaction()
trx.add(cancel_instruction)For me shorter - better
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. "shorter" tends to get |
||
|
|
||
| logger.debug("Cancel") | ||
| result = self.sender.send_measured_transaction(trx, self.eth_trx, 'CancelWithNonce') | ||
|
|
@@ -475,7 +475,7 @@ def call_continue_bucked(self, instruction_type): | |
| try: | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 = Transaction() | ||
| if instruction_type == CONTINUE_REGULAR: | ||
| trx = self.instruction.make_continue_instruction(steps, index) | ||
| trx = self.instruction.make_continue_transaction(steps, index) | ||
|
||
| elif instruction_type == CONTINUE_COMBINED: | ||
| trx = self.instruction.make_partial_call_or_continue_transaction(steps - index) | ||
| elif instruction_type == CONTINUE_HOLDER_COMB: | ||
|
|
||
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.
eth_account,pda_accountorassociated_token_accountThere 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.
In my opinion, it is a good start, but for adding annotations everywhere, there should be a separate issue.