-
Notifications
You must be signed in to change notification settings - Fork 0
Executor Contracts #3
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
gokselcoban
left a comment
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 checked the contract part for now. It looks good overall, thank you!
| assert(Txn.GroupIndex == 1) | ||
|
|
||
| # Assert that there is no rekeying | ||
| assert(Gtxn[1].RekeyTo == Global.ZeroAddress) |
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.
Using the Txn instead of Gtxn[1] will improve the readability.
| assert(Gtxn[1].RekeyTo == Global.ZeroAddress) | |
| assert(Txn.RekeyTo == Global.ZeroAddress) |
contracts/arbitrary_executor_logic_signature/arbitrary_executor_logic_signature.tl
Outdated
Show resolved
Hide resolved
| #tealish version git+https://github.com/Hipo/tealish.git@e8d1b27620220bc4e520d7d3b6d62523e13a7723 | ||
|
|
||
| # Assert that Gtxn[0] is an appcall to execution validator | ||
| assert(Gtxn[0].ApplicationID == 10000) |
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.
Maybe the app id should be a parameter/variable. I couldn't be sure.
| log(Concat(method("proposal(byte[59],uint64,uint64,uint64,uint64,uint64,uint64,uint64,uint64,uint64,uint64,bool,bool,bool,bool,address)"), proposal_id, proposal_data)) | ||
| log(Concat(method("proposal(byte[59],uint64,uint64,uint64,uint64,uint64,uint64,uint64,uint64,uint64,uint64,bool,bool,bool,bool,address, byte[128])"), proposal_id, proposal_data)) | ||
| log(Concat(method("create_proposal(address,byte[59])"), user_address, proposal_id)) | ||
| log(proposal.execution_hash) |
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 guess this is added for testing purposes.
| bytes proposal_data | ||
| _, proposal_data = box_get(proposal_box_name) | ||
| log(Concat(method("proposal(byte[59],uint64,uint64,uint64,uint64,uint64,uint64,uint64,uint64,uint64,uint64,bool,bool,bool,bool,address)"), proposal_id, proposal_data)) | ||
| log(Concat(method("proposal(byte[59],uint64,uint64,uint64,uint64,uint64,uint64,uint64,uint64,uint64,uint64,bool,bool,bool,bool,address, byte[128])"), proposal_id, proposal_data)) |
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.
FYI. There are other logs that should be updated, too.
Maybe we can handle it together with state change.
#1 (comment)
gokselcoban
left a comment
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.
Great work, it looks clear!
| # Assert proposal.execution_hash | ||
| # hash(method_name, pool_address: address, total_fee_share, protocol_fee_ratio) | ||
|
|
||
| bytes execution_hash = Lpad(sha256(Concat(Concat(Concat("set_fee_for_pool", Txn.Accounts[1]), total_fee_share), protocol_fee_ratio)), 128) |
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.
FYI: Concat supports multiple parameters, thanks to Tealish.
| bytes execution_hash = Lpad(sha256(Concat(Concat(Concat("set_fee_for_pool", Txn.Accounts[1]), total_fee_share), protocol_fee_ratio)), 128) | |
| bytes execution_hash = Lpad(sha256(Concat("set_fee_for_pool", Txn.Accounts[1], total_fee_share, protocol_fee_ratio)), 128) |
| # Assert proposal.execution_hash | ||
| # hash(method_name, address, amount) | ||
|
|
||
| bytes execution_hash = Lpad(sha256(Concat(Concat("send_algo", Txn.Accounts[0]), amount_as_bytes), 128) |
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.
FYI: Maybe we can convert amount (amount_as_bytes) to int first and then convert it to byte to make sure it is 8 bytes.
| exit(1) | ||
| end | ||
|
|
||
| block send_asa: |
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.
FYI: Maybe we can determine the transaction type (Pay or Axfer) according to asset_id. Two method is not required in this case.
|
|
||
| inner_txn: | ||
| TypeEnum: Axfer | ||
| Sender: Global.CurrentApplicationAddress |
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.
To make it clear.
We should set the fee collector address to the app account.
If we want to continue using the same executor app, if we change the fee collector, we can rekey the fee collector to the app account. In this case, we should send the transaction on behalf of the fee collector. The Sender parameter should be added to the hash.
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 aggree, the fee collector and treasury management app is conflicting in this manner.
gokselcoban
left a comment
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.
This looks good overall!
| # proposal checks | ||
| assert(proposal_state == PROPOSAL_STATE_SUCCEEDED) | ||
|
|
||
| # Assert Gtxn[1]'s transaction_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.
| # Assert Gtxn[1]'s transaction_id. |
| # Assert that there is no rekeying | ||
| int start = 0 | ||
| int end = Global.GroupSize | ||
| for i in start:end: | ||
| assert(Gtxn[i].RekeyTo == Global.ZeroAddress) | ||
| end |
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.
Ideally, Txn.RekeyTo == Global.ZeroAddress) should be enough.
Governors should know the TXN fields before approving it.
| else: | ||
| exit(0) | ||
| end |
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.
FYI: There is no signed integer in the AVM. You can safely update elif as else.
tests/common.py
Outdated
| def lpad(string: bytes, n: int) -> bytes: | ||
| assert(n > 0) | ||
|
|
||
| return b"\x00" * (128 - len(string)) + string |
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.
| return b"\x00" * (128 - len(string)) + string | |
| return b"\x00" * (n - len(string)) + string |
|
Continueing on #7 |
https://github.com/Hipo/private-tinyman-py-sdk/tree/executors