Skip to content

Conversation

@itamarreif
Copy link
Contributor

@itamarreif itamarreif commented Aug 27, 2024

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

Related Issues

closes #1251

@itamarreif itamarreif self-assigned this Aug 27, 2024
@itamarreif itamarreif added bug Something isn't working bridging bridge-withdrawer code touching the bridge-withdrawer service labels Aug 27, 2024
@itamarreif itamarreif force-pushed the itamarreif/bridge-withdrawer/address-fix branch from 7e94407 to dd28ebb Compare August 28, 2024 20:27
@itamarreif itamarreif marked this pull request as ready for review August 28, 2024 20:39
@itamarreif itamarreif requested a review from a team as a code owner August 28, 2024 20:39
@itamarreif itamarreif requested a review from noot August 28, 2024 20:39
@itamarreif itamarreif force-pushed the itamarreif/bridge-withdrawer/address-fix branch from 842d582 to 55eb921 Compare August 28, 2024 22:26
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.

LGTM

@itamarreif itamarreif added the ENG-674 Zelic's July 15 audit label Aug 29, 2024
Copy link
Contributor

@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.

This PR contains a lot of renames that I don't think are necessary (and partially confusing, talking about "logs" where "actions" are promised).

Comment on lines 372 to 386
/// 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(
Copy link
Contributor

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 {
Copy link
Contributor

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);
Copy link
Contributor

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.

Comment on lines 441 to 454
/// 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.
Copy link
Contributor

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: \
Copy link
Contributor

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| {
Copy link
Contributor

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.

@itamarreif itamarreif force-pushed the itamarreif/bridge-withdrawer/address-fix branch from 55eb921 to 2e6c958 Compare August 29, 2024 21:08
Copy link
Contributor

@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.

Nice, this is a much neater change. Thank you!

The message in the error event looks a bit wonky. See my suggestion.

})?;
})?
.into_iter()
.collect::<Result<_, _>>()?;
Copy link
Contributor

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.

@itamarreif itamarreif force-pushed the itamarreif/bridge-withdrawer/address-fix branch from 56235ae to e2bb4cf Compare August 29, 2024 21:29
itamarreif and others added 3 commits August 29, 2024 17:30
Co-authored-by: Richard Janis Goldschmidt <github@aberrat.io>
Co-authored-by: Richard Janis Goldschmidt <github@aberrat.io>
@itamarreif itamarreif force-pushed the itamarreif/bridge-withdrawer/address-fix branch from e2bb4cf to b2d4087 Compare August 29, 2024 21:30
@itamarreif itamarreif enabled auto-merge August 29, 2024 21:30
@itamarreif itamarreif added this pull request to the merge queue Aug 29, 2024
Merged via the queue into main with commit 3e24c50 Aug 29, 2024
@itamarreif itamarreif deleted the itamarreif/bridge-withdrawer/address-fix branch August 29, 2024 21:42
steezeburger added a commit that referenced this pull request Sep 3, 2024
* 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)
jbowen93 pushed a commit that referenced this pull request Sep 3, 2024
…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>
jbowen93 pushed a commit that referenced this pull request Sep 6, 2024
…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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bridge-withdrawer code touching the bridge-withdrawer service bridging bug Something isn't working ENG-674 Zelic's July 15 audit

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bridge withdrawer shouldnt panic on bad single withdrawal address

4 participants