-
Notifications
You must be signed in to change notification settings - Fork 5
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
[SPEC] Proposals and their Contracts on Cosmwasm/Cosmos-SDK chains #63
Comments
14 tasks
@duguorong009 please fill in the applicable proposal details here. These will be added to the docs site once completed! Thanks! |
@dutterbutter |
Closed in tangle-network/webb-rs#64 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Proposals
Types
0x00000000
More on
resourceId
resourceId serves the purpose of representing the
target chain contract
.In
cosmwasm/cosmos-sdk
chains, the contract address is normally63 ~ 65 bytes string
.So, here we introduce extra tweak to contract address to make it fit into resourceId(32 bytes string).
The tweak is to
keccak256(contract_address) & take last 20 bytes
.These
last 20 bytes
becomes thetarget execution contract address(hashed)
in the resourceId.Finally, the resourceId is created by concatenating the following parts:
6 zeroes(6 bytes)
+target contract(20 bytes)
+chainIdType(6 bytes)
(Ref: #55 (comment))
More on
chain_id
chain_id serves the purpose of representing the
blockchain network
.In
cosmwasm/cosmos-sdk
chains, thechain_id
isstring
, unlike theevm
chains(number
)For example, the
chain_id
forjuno
mainnet isjuno-1
.So, here we introduce extra tweak to
chain_id
to make it(string) to4 bytes number
.The tweak is to
keccak256(chain_id(string)) & take last 4 bytes
.These
last 4 bytes
becomes the chain_id in proposals.(Ref: #39 (comment))
More on
functionSig
functionSig comes from the
evm
proposal, sinceevm
chain contracts make use of it.However, in
cosmwasm
, functionSig is not needed, sincecosmwasm
leaves only one execute entry & does multiplexing the input message for different action.So, here we just fill the
0
in the place of functionSig(0x00000000) for compatibility with otherwebb
proposals.Overarching schema
(
bytes32 resourceId
,bytes4 functionSig(zeroes)
,bytes4 proposalNonce
,message(the length of this is proposal specific)
)Terminology: We will call the (resourceId, zeroes, nonce) as the proposal header. The proposal header is a total of 40 bytes.
Example proposals
1.
resourceId
ProposalContract Flow:
Bridge/SignatureBridge
->AnchorHandler/TokenWrapperHandler
implementation (specifically goes tosetResource
withinAnchorHandler/TokenWrapperHandler
)Proposal Data: (
resourceId
,functionSig
,nonce
,message
)Total Bytes:
32 + 4 + 4 + size of message
2. Anchor Update Proposal
Contract Flow:
Bridge/SignatureBridge
->AnchorHandler
->Anchor
Proposal Data: (
resourceId
,functionSig
,nonce
,message
)Total Bytes:
32 + 4 + 4 + size of message
3. Set/Change Wrapping Fee(fee_percentage) Proposal
Contract Flow:
Bridge/SignatureBridge
->TokenWrapperHandler
->GovernedTokenWrapper
Proposal Data: (
resourceId
,functionSig
,nonce
,message
)Total Bytes:
32 + 4 + 4 + size of message
4. Add Token Proposal
Contract Flow:
Bridge/SignatureBridge
->TokenWrapperHandler
->GovernedTokenWrapper
Proposal Data: (
resourceId
,functionSig
,nonce
,message
)Total Bytes:
32 + 4 + 4 + size of message
5. Remove Token Proposal
Contract Flow:
Bridge/SignatureBridge
->TokenWrapperHandler
->GovernedTokenWrapper
Proposal Data: (
resourceId
,functionSig
,nonce
,message
)Total Bytes:
32 + 4 + 4 + size of message
6. Set/Update Fee Recipient Proposal
Contract Flow:
Bridge/SignatureBridge
->TokenWrapperHandler
->GovernedTokenWrapper
Proposal Data: (
resourceId
,functionSig
,nonce
,message
)Total Bytes:
32 + 4 + 4 + size of message
7. MaxDepositLimit Update Proposal
Contract Flow:
Bridge/SignatureBridge
->AnchorHandler
->VAnchor
Proposal Data: (
resourceId
,functionSig
,nonce
,message
)Total Bytes:
32 + 4 + 4 + size of message
8. MinWithdrawalLimit Update Proposal
Contract Flow:
Bridge/SignatureBridge
->AnchorHandler
->VAnchor
Proposal Data: (
resourceId
,functionSig
,nonce
,message
)Total Bytes:
32 + 4 + 4 + size of message
9. Rescue Tokens Proposal
Contract Flow:
Bridge/SignatureBridge
->TreasuryHandler
->Treasury
Proposal Data: (
resourceId
,functionSig
,nonce
,message
)Total Bytes:
32 + 4 + 4 + size of message
10. Set TreasuryHandler Proposal
Contract Flow:
Bridge/SignatureBridge
->TreasuryHandler
->Treasury
Proposal Data: (
resourceId
,functionSig
,nonce
,message
)Total Bytes:
32 + 4 + 4 + size of message
Questions/Issues
evm
orsubstrate
), these proposals include variant-length data.The variant-length is mainly because of different length of address in different
cosmwasm/cosmos-sdk
chains.For example, in
juno
chain, the length of contract address is63 bytes string
In
terra2.0
chain, the length is64 bytes string
Is it okay to use these variant-length proposal? or should go to fixed-length proposal with
padding
?Another variant-length data comes from the
Uint128
data type, much used incosmwasm
contracts.Uint128
type is serialize/deserialized inString
type, and its maximum length is39 bytes
.How should we handle this type? keeping variant-length data? or should go to fixed-length(39 bytes) data
MaxExtLimitUpdate
&MaxFeeLimitUpdate
proposals seem to be needless.What is the reason for that?
For every
Uint128
(u128) type, the current proposals use the16 bytes
.So, we should add more utils to support the conversion between
raw bytes
andUint128(or u128(or String))
.The
feeRecipient
proposal has one tiny issue. Since thefeeRecipient
could be eithercontract address
(63 ~ 65bytes) or
wallet address
(43 ~ 45bytes), we could think ofpadding the address
to fit it into longest length(63 ~ 65).So, as well as
resourceId
approach, applyleft-zero-padding
so that max length is65 bytes
?For example,
becomes
NOTE
In every proposal, there is
sig
, which is the signature ofgovernor
on theproposal data
.This signature is used for verifying if the caller of
SignatureBridge
contact is the realgovernor
.The text was updated successfully, but these errors were encountered: