-
Notifications
You must be signed in to change notification settings - Fork 95
fix(cli, bridge-withdrawer): dont fail entire block due to bad withdraw event #1409
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
Conversation
7e94407 to
dd28ebb
Compare
842d582 to
55eb921
Compare
joroshiba
left a comment
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.
LGTM
SuperFluffy
left a comment
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 PR contains a lot of renames that I don't think are necessary (and partially confusing, talking about "logs" where "actions" are promised).
| /// Converts a rollup-side smart contract event log to a sequencer-side ics20 withdrawal action. | ||
| /// | ||
| /// # Errors | ||
| /// - If the log does not contain a block number. | ||
| /// - If the log does not contain a transaction hash. | ||
| /// - If the log cannot be decoded as a sequencer withdrawal event. | ||
| /// - If the log does not contain a `recipient` field. | ||
| /// - If the memo cannot be encoded to json. | ||
| /// - If calculating the amount using the asset withdrawal divisor overflows. | ||
| /// | ||
| /// # Panics | ||
| /// - If getting a withdrawal event type that it was not configured for. For example, if the | ||
| /// configuration was specified to only get sequencer withdrawal events but an ICS20 | ||
| /// withdrawal is received. | ||
| pub fn log_to_ics20_withdrawal_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.
I don't see why this needs to be a pub method? I don't think it's used anywhere outside this lib? You can then also remove the doc comment.
| } | ||
|
|
||
| #[derive(Debug, thiserror::Error)] | ||
| enum GetWithdrawalLogsErrorKind { |
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.
Making this an enum seems unnecessary?
| #[derive(Debug, thiserror::Error)] | ||
| #[error(transparent)] | ||
| pub struct GetWithdrawalActionsError(GetWithdrawalActionsErrorKind); | ||
| pub struct GetWithdrawalLogsError(GetWithdrawalLogsErrorKind); |
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 think you are leaking concepts that don't appear at the high level. Please change this back.
| /// Converts a rollup-side smart contract event log to a sequencer-side ics20 withdrawal action. | ||
| /// | ||
| /// # Errors | ||
| /// - If the log does not contain a block number. | ||
| /// - If the log does not contain a transaction hash. | ||
| /// - If the log cannot be decoded as a sequencer withdrawal event. | ||
| /// - If the log does not contain a `recipient` field. | ||
| /// - If the memo cannot be encoded to json. | ||
| /// - If calculating the amount using the asset withdrawal divisor overflows. | ||
| /// | ||
| /// # Panics | ||
| /// - If getting a withdrawal event type that it was not configured for. For example, if the | ||
| /// configuration was specified to only get sequencer withdrawal events but an ICS20 | ||
| /// withdrawal is received. |
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.
Remove this doc comment.
| .wrap_err_with(|| { | ||
| format!( | ||
| "failed getting actions for block; block hash: `{block_hash}`, block height: \ | ||
| "failed getting logs for block; block hash: `{block_hash}`, block height: \ |
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 not correct. The actions_fetcher is promising to give you actions. Why is this talking about logs? That's confusing.
| })?; | ||
| })? | ||
| .into_iter() | ||
| .filter_map(|r| { |
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 am ambivalent about changing this logic in the CLI at this point. I am fine with adding a flag that filters out bad actions, but I would leave this to a followup.
55eb921 to
2e6c958
Compare
SuperFluffy
left a comment
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 is a much neater change. Thank you!
The message in the error event looks a bit wonky. See my suggestion.
crates/astria-bridge-withdrawer/src/bridge_withdrawer/ethereum/watcher.rs
Outdated
Show resolved
Hide resolved
| })?; | ||
| })? | ||
| .into_iter() | ||
| .collect::<Result<_, _>>()?; |
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.
Not the most efficient, but I guess it doesn't matter in this case.
crates/astria-bridge-withdrawer/src/bridge_withdrawer/ethereum/watcher.rs
Outdated
Show resolved
Hide resolved
56235ae to
e2bb4cf
Compare
Co-authored-by: Richard Janis Goldschmidt <github@aberrat.io>
Co-authored-by: Richard Janis Goldschmidt <github@aberrat.io>
e2bb4cf to
b2d4087
Compare
* main: chore: ibc e2e smoke test (#1284) chore(metrics): restrict `metrics` crate usage to `astria-telemetry` (#1192) fix(charts)!: sequencer-relayer chart correct startup env var (#1437) chore(bridge-withdrawer): Add instrumentation (#1324) chore(conductor): Add instrumentation (#1330) fix(cli, bridge-withdrawer): dont fail entire block due to bad withdraw event (#1409) feat(sequencer, bridge-withdrawer)!: enforce withdrawals consumed (#1391)
…aw event (#1409) ## Summary Brief summary of the changes made, ie "what?" ## Background Brief background on why these changes were made, ie "why?" ## Changes - Separate the errors for getting logs from the conversion errors - Conversion returns a `Result<Vec<Result<Action, WithdrawalConversionError>>, GetWithdrawalLogsError> ` instead of `Result<Vec<Action>, GetWithdrawalActionsError>` - Handle failed conversions in the cli and withdrawer crates ## Testing - Unit tests for the conversions will be added in a subsequent PR: ## Breaking Changelist - This fixes the bug described in #1251, where a single withdrawal which fails to be converted to an action will cause the entire rollup block's batch of withdrawals to fail, causing the withdrawer to be stuck. ## Related Issues closes #1251 --------- Co-authored-by: Richard Janis Goldschmidt <github@aberrat.io>
…aw event (#1409) ## Summary Brief summary of the changes made, ie "what?" ## Background Brief background on why these changes were made, ie "why?" ## Changes - Separate the errors for getting logs from the conversion errors - Conversion returns a `Result<Vec<Result<Action, WithdrawalConversionError>>, GetWithdrawalLogsError> ` instead of `Result<Vec<Action>, GetWithdrawalActionsError>` - Handle failed conversions in the cli and withdrawer crates ## Testing - Unit tests for the conversions will be added in a subsequent PR: ## Breaking Changelist - This fixes the bug described in #1251, where a single withdrawal which fails to be converted to an action will cause the entire rollup block's batch of withdrawals to fail, causing the withdrawer to be stuck. ## Related Issues closes #1251 --------- Co-authored-by: Richard Janis Goldschmidt <github@aberrat.io>
Summary
Brief summary of the changes made, ie "what?"
Background
Brief background on why these changes were made, ie "why?"
Changes
Result<Vec<Result<Action, WithdrawalConversionError>>, GetWithdrawalLogsError>instead ofResult<Vec<Action>, GetWithdrawalActionsError>Testing
Breaking Changelist
Related Issues
closes #1251