Skip to content

Conversation

@etzellux
Copy link
Collaborator

@etzellux etzellux commented Nov 16, 2023

Copy link
Contributor

@gokselcoban gokselcoban left a 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)
Copy link
Contributor

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.

Suggested change
assert(Gtxn[1].RekeyTo == Global.ZeroAddress)
assert(Txn.RekeyTo == Global.ZeroAddress)

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

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

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

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)

Copy link
Contributor

@gokselcoban gokselcoban left a 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)
Copy link
Contributor

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.

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

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

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

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.

Copy link
Collaborator Author

@etzellux etzellux Nov 29, 2023

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.

Copy link
Contributor

@gokselcoban gokselcoban left a 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.
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
# Assert Gtxn[1]'s transaction_id.

Comment on lines +17 to +22
# 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
Copy link
Contributor

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.

Comment on lines 110 to 112
else:
exit(0)
end
Copy link
Contributor

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

Choose a reason for hiding this comment

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

Suggested change
return b"\x00" * (128 - len(string)) + string
return b"\x00" * (n - len(string)) + string

@etzellux etzellux marked this pull request as draft February 6, 2024 12:23
@etzellux
Copy link
Collaborator Author

etzellux commented Feb 7, 2024

Continueing on #7

@etzellux etzellux closed this Feb 7, 2024
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.

3 participants