joystream
joystream copied to clipboard
`Argo` bridge runtime pallet
See background in #5084
Goal
Develop argoBridge
runtime pallet that will be used for Argo bridge operations.
Required functionalities:
- Allowing users to request bridging to Ethereum.
- Allowing bridge operators to finalise transfers from Ethereum.
- Proper security model as described in the background issue.
- Letting the Council adjust pallet configuration via a proposal.
Pallet
State
-
status
: enum with options{ type: 'active' } | { type: 'paused' } | { type: 'thawn'; thawn_started_at: 123456 }
. -
operator_account
: account ID. -
pauser_accounts
: list of account IDs with permission to pause the bridge operations. -
mint_allowance
: number indicating number of tokens that the bridge pallet is able to mint. This should always equaltotal_burned - total_minted
. -
bridging_fee
: amount of JOY burned as a fee for each transfer. -
thawn_duration
: number of blocks needed before bridge unpause can be finalised.
Proposal
Single 3/3 proposal allowing the Council to update the following state values:
-
operator_account
-
pauser_accounts
-
bridging_fee
-
thawn_duration
Emits BridgeConfigUpdated(config)
event
Extrinsics
-
request_outbound_transfer(dest_account, amount, expected_fee)
- callable by anybody:- Checks that the
status
is{ type: 'active' }
. - Burns the fee
- Burns
amount
of JOY from sender account, increasesmint_allowance
byamount
- Computes
transfer_id
by hashing(dest_account, amount, block_number, call_index_in_block)
- Emits an event
OutboundTransferRequested(transfer_id, dest_account, amount, paid_fee)
- Checks that the
-
finalize_inbound_transfer(dest_account, amount, request_block, request_nonce)
- callable byoperator_account
only:- Checks that the
status
is{ type: 'active' }
. - Computes
transfer_id
by hashing(dest_account, amount, request_block, request_nonce)
- Checks that
amount
is not bigger than currentmint_allowance
- Decreases
mint_allowance
byamount
, mintsamount
of JOY tokens todest_account
- Emits an event
InboundTransferFinalized(transfer_id)
- Checks that the
-
pause_bridge()
- callable by any ofpauser_accounts
:- Changes
status
to{ type: 'paused' }
- Emits an event
BridgePaused(pauser)
- Changes
-
init_unpause_bridge()
- callable by any ofpauser_accounts
:- Changes
status
to{ type: 'thawn'; thawn_started_at: current_block }
- Emits an event
BridgeThawnStarted(pauser)
- Changes
-
finish_unpause_bridge()
- callable byoperator_account
only:- Checks that
status.type === 'thawn
&& current_block > status.thawn_started_at + thawn_duration` - Changes
status
to{ type: 'active' }
- Emits an event
BridgeThawnFinished()
- Checks that