-
Notifications
You must be signed in to change notification settings - Fork 75
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
feat(sequencer)!: implement bridge unlock action and derestrict transfers #1034
Conversation
1f18d0e
to
6921aaf
Compare
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.
Just a few minor comments/questions.
if state | ||
.get_bridge_account_rollup_id(&from) | ||
.await | ||
.context("failed to get bridge account rollup ID from state")? |
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 is identical to the context being applied just above (at line 95) and a third in ics20_transfer.rs. It might be useful to change both strings in this file to hold a little more info to disambiguate the three, e.g. "failed to get bridge account rollup ID for transfer [sender|recipient] from state"
let bridged_asset_id = state | ||
.get_bridge_account_asset_ids(&from) | ||
.await | ||
.context("failed to get bridge account asset 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.
This context appears in four different places. Maybe there should be a separate PR where we deduplicate error contexts across the crate?
6921aaf
to
d8b3e1c
Compare
// ensure that if the sender is a bridge account, that the asset being transferred is not | ||
// the same asset as the bridge account's asset. The bridge account should be using | ||
// the `BridgeUnlockAction` for that. |
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'm not sure if we need this logic - i think we should either not allow Transfer
s out of bridge accounts at all, or allow them but not place any restrictions on them. this seems unnecessary, as if the bridge account owner wanted to transfer out the same asset but was restricted from using Transfer
, they could still just use BridgeUnlock
and leave the memo empty (or put something random)
I think we should remove this part for now and have a bigger discussion on what actions/accounting should look like
|
||
// ensure the bridge account's tracked asset is being transferred. | ||
let allowed_asset_id = state | ||
.get_bridge_account_asset_ids(&from) |
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.
since this returns just 1 asset id now, can you rename the fn to get_bridge_account_asset_id
?
// the asset to be transferred | ||
bytes asset_id = 3; |
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.
don't think we need this field - since bridge accounts only allow one asset to be bridged, we know using BridgeUnlockAction
must also withdraw that same asset
// It's the same as a `TransferAction` but with the added | ||
// `memo` field. | ||
message BridgeUnlockAction { | ||
// the address of the bridge account to transfer to |
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.
// the address of the bridge account to transfer to | |
// the address to withdraw funds to |
|
||
#[instrument(skip_all)] | ||
async fn execute<S: StateWriteExt>(&self, state: &mut S, from: Address) -> Result<()> { | ||
let transfer_action = TransferAction { |
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.
the memo is unused, which is fine, when we decide on the memo structure we should also store that (or data extracted from it). maybe add a comment here about that?
866e53d
to
fd71308
Compare
409d494
to
44be7d3
Compare
@@ -1142,7 +1142,7 @@ async fn update_mempool_after_finalization<S: StateReadExt>( | |||
|
|||
for (tx, priority) in mempool.inner().await.iter_mut() { | |||
match TransactionPriority::new( | |||
tx.nonce(), | |||
(*tx).nonce(), |
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.
why the change here?
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.
it was giving me linting errors, i think i messed up my vscode. i removed it!
let signed_tx = tx.into_signed(&bridge_signing_key); | ||
app.execute_transaction(signed_tx) | ||
.await | ||
.expect("failed while executing bridge unlock action"); |
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.
.expect("failed while executing bridge unlock action"); | |
.expect("executing bridge unlock action should succeed"); |
app.state | ||
.get_account_balance(bridge_address, asset_id) | ||
.await | ||
.expect("failed while getting account balance"), |
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.
.expect("failed while getting account balance"), | |
.expect("getting account balance should succeed"), |
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.
nice, this looks good!
1c58448
to
75e3e59
Compare
Summary
Implements bridge accounts'
BridgeUnlock
action and allows bridge accounts to transfer assets like normal.Background
We need a
BridgeUnlock
action to help with tracking/proving that withdraws for rollup specific events happened. This PR implements the ground work for that by adding a new action with amemo:bytes
field that is currently unused.We also decided that it's unnecessary to have restrictions on the bridge account in terms of normal transfers in/out of the account. The bridge account is already a privileged actor and having the restrictions on transfer would make normal account maintenance (like gas funding) messy.
Changes
BridgeUnlockAction
for transferring out a bridge's bridged assetTesting
unit tests
Breaking Changelist
BridgeUnlock
Related Issues
closes #983