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

chore(core, sequencer): move stateless checks to domain type parsing #1770

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

Conversation

ethanoroshiba
Copy link
Contributor

@ethanoroshiba ethanoroshiba commented Oct 30, 2024

Summary

Moved stateless checks for Ics20Withdrawal and BridgeUnlock to occur when the types are parsed from protobuf.

Background

Made more sense to check these fields sooner in the process rather than later, and be able to consolidate some of the checks that are shared between BridgeUnlock and Ics20Withdrawal.

Changes

  • Moved stateless checks for Ics20Withdrawal and BridgeUnlock to profobuf try_from_raw and try_from_raw_ref impls.

Testing

Passing all tests.

Changelogs

No updates required.

Related Issues

closes #1430

@github-actions github-actions bot added the sequencer pertaining to the astria-sequencer crate label Oct 30, 2024
if timeout_time == 0 {
return Err(Ics20WithdrawalError::invalid_timeout_time());
}
if amount == 0 {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Do we even need to check this? Protobuf represents 0 values as empty, and when decoding this it should result in None I think

Comment on lines +1061 to +1062
let parsed_withdrawal: Ics20WithdrawalFromRollup =
serde_json::from_str(&memo).map_err(Ics20WithdrawalError::parse_memo)?;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Should we edit our domain type Ics20Withdrawal to then include the parsed withdrawal as well? Then, we don't have to parse again during check_and_execute

@ethanoroshiba ethanoroshiba marked this pull request as ready for review October 30, 2024 18:18
@ethanoroshiba ethanoroshiba requested a review from a team as a code owner October 30, 2024 18:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
sequencer pertaining to the astria-sequencer crate
Projects
None yet
Development

Successfully merging this pull request may close these issues.

refactor stateless checks to be done on types with withdrawals
1 participant