Skip to content
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 BridgeTransfer action #1934

Open
wants to merge 14 commits into
base: main
Choose a base branch
from

Conversation

noot
Copy link
Collaborator

@noot noot commented Jan 28, 2025

Summary

implement BridgeTransfer action which transfers funds from one bridge account to another. essentially, it atomically performs a BridgeUnlock and a BridgeLock.

Background

this is functionality we want and BridgeUnlocking to another bridge account wouldn't create a Deposit correctly. the issue is that BridgeUnlock does not contain all the information needed to create a deposit event, namely destination_chain_address, so BridgeUnlock directly into another bridge account doesn't work as a lock. BridgeLock from a bridge account to another also doesn't contain the desired withdrawal information (eg rollup_withdrawal_event_id). an atomic BridgeUnlock/BridgeLock combo would only work if the BridgeUnlock unlocks the funds to itself, providing rollup_withdrawal_event_id, and then BridgeLocks to the receiving account. BridgeUnlock cannot go directly into a different account as the bridge would no longer be able to access it. however this seems unwieldly as opposed to just having one action which makes the intention clear.

Changes

  • slightly refactor BridgeUnlock to move checks to their own function
  • also slightly refactor BridgeLock to move execution and Deposit emission to their own function
  • implement BridgeTransfer action using existing BridgeUnlock checks and BridgeLock execution logic.

Testing

unit tests

Changelogs

Changelogs updated.

Breaking Changelist

  • a new action was added, which is a breaking sequencer change.

Related Issues

closes #1921

@github-actions github-actions bot added proto pertaining to the Astria Protobuf spec sequencer pertaining to the astria-sequencer crate labels Jan 28, 2025
@noot noot marked this pull request as ready for review January 28, 2025 01:45
@noot noot requested review from a team and joroshiba as code owners January 28, 2025 01:45

// The memo field can be used to provide unique identifying additional
// information about the bridge unlock transaction.
string memo = 5;
Copy link
Member

Choose a reason for hiding this comment

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

Do we need a memo here?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

not necessarily, do you see any future use for it? i left it because BridgeUnlock has it, but don't think BridgeUnlock necessarily needs it either. removed for now

@SuperFluffy
Copy link
Member

Can we have smoke tests for this?

@SuperFluffy
Copy link
Member

Request to expand the background section: why this over a bridge-lock followed by bridge-unlock? Execution of our transactions is by definition atomic (because processing of transactions (and their actions) is sequential).

Is the atomicity of bridge-lock-unlock not enough? Does this mean that the only innovation of this feature is a different deposit being emitted? Is there another reason to have this? Could we address this by amending how we emit deposit events?

@noot
Copy link
Collaborator Author

noot commented Feb 3, 2025

Is the atomicity of bridge-lock-unlock not enough? Does this mean that the only innovation of this feature is a different deposit being emitted? Is there another reason to have this? Could we address this by amending how we emit deposit events?

the issue isn't deposit events. the issue is that BridgeUnlock does not contain all the information needed to create a deposit event, namely destination_chain_address, so BridgeUnlock directly into another bridge account doesn't work as a lock. BridgeLock from a bridge account to another also doesn't contain the desired withdrawal information (eg rollup_withdrawal_event_id). an atomic BridgeUnlock/BridgeLock combo would only work if the BridgeUnlock unlocks the funds to itself, providing rollup_withdrawal_event_id, and then BridgeLocks to the receiving account. BridgeUnlock cannot go directly into a different account as the bridge would no longer be able to access it. however this seems unwieldly as opposed to just having one action which makes the intention clear.

@SuperFluffy
Copy link
Member

Is the atomicity of bridge-lock-unlock not enough? Does this mean that the only innovation of this feature is a different deposit being emitted? Is there another reason to have this? Could we address this by amending how we emit deposit events?

the issue isn't deposit events. the issue is that BridgeUnlock does not contain all the information needed to create a deposit event, namely destination_chain_address, so BridgeUnlock directly into another bridge account doesn't work as a lock. BridgeLock from a bridge account to another also doesn't contain the desired withdrawal information (eg rollup_withdrawal_event_id). an atomic BridgeUnlock/BridgeLock combo would only work if the BridgeUnlock unlocks the funds to itself, providing rollup_withdrawal_event_id, and then BridgeLocks to the receiving account. BridgeUnlock cannot go directly into a different account as the bridge would no longer be able to access it. however this seems unwieldly as opposed to just having one action which makes the intention clear.

Please add this to the PR description before merging.

Copy link
Member

@SuperFluffy SuperFluffy left a comment

Choose a reason for hiding this comment

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

astria-core needs an entry for this change.

Copy link
Member

@joroshiba joroshiba left a comment

Choose a reason for hiding this comment

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

approving for snapshot changes + proto changes. One small nit on the validation.

Noting by default this action can't be done as it is disabled because there are no fees, correct?

/// - if the `to` field is invalid
/// - if the `amount` field is invalid
/// - if the `fee_asset` field is invalid
/// - if the `from` field is invalid
Copy link
Member

Choose a reason for hiding this comment

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

should there also be validation that the destination_chain_address is set, as well as some restrictions on it's length?

Maybe this is more a sequencer concern, notice we don't have this on bridge lock but probably should? There's a limit to what a reasonable sized destination address is.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
proto pertaining to the Astria Protobuf spec sequencer pertaining to the astria-sequencer crate
Projects
None yet
Development

Successfully merging this pull request may close these issues.

implement BridgeTransfer action
4 participants