-
Notifications
You must be signed in to change notification settings - Fork 94
refactor(withdrawer): read from block subscription stream and get events on each block #1207
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
crates/astria-bridge-withdrawer/src/bridge_withdrawer/ethereum/watcher.rs
Outdated
Show resolved
Hide resolved
crates/astria-bridge-withdrawer/src/bridge_withdrawer/ethereum/watcher.rs
Outdated
Show resolved
Hide resolved
crates/astria-bridge-withdrawer/src/bridge_withdrawer/ethereum/watcher.rs
Outdated
Show resolved
Hide resolved
event_tx: mpsc::Sender<(WithdrawalEvent, LogMeta)>, | ||
from_block: u64, | ||
async fn sync_from_next_rollup_block_height( | ||
provider: Arc<Provider<Ws>>, |
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.
Seems like in almost all places we're using Arc<Provider<Ws>>
we can get away with just &Provider<Ws>
. Looks like the only place we need the provider wrapped in an Arc
is in IAstriaWithdrawer::new
, and we can just create one inline there.
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.
unfortunately it needs to be in an Arc
due to the loop here:
loop {
select! {
() = shutdown_token.cancelled() => {
info!("block watcher shutting down");
return Ok(());
}
block = block_rx.next() => {
if let Some(block) = block {
get_and_send_events_at_block(
provider.clone(),
contract_address,
block,
&converter,
&submitter_handle,
)
.await
.wrap_err("failed to get and send events at block")?;
}
}
}
}
have to clone it otherwise it gets moved in the previous loop iteration
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.
You should be able to change get_and_send_events_at_block
to take provider: &Provider<Ws>
too though (and all the other places taking an Arc
)?
crates/astria-bridge-withdrawer/src/bridge_withdrawer/ethereum/watcher.rs
Outdated
Show resolved
Hide resolved
crates/astria-bridge-withdrawer/src/bridge_withdrawer/ethereum/watcher.rs
Show resolved
Hide resolved
crates/astria-bridge-withdrawer/src/bridge_withdrawer/ethereum/watcher.rs
Outdated
Show resolved
Hide resolved
crates/astria-bridge-withdrawer/src/bridge_withdrawer/ethereum/watcher.rs
Outdated
Show resolved
Hide resolved
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.
Approved, but I still think wrapping Provider
in an Arc
is not required (except in just the single place indicated in the comment). Not a huge deal though - just a micro-optimization to avoid using atomic ref-counting :)
* main: (27 commits) refactor(sequencer): fix prepare proposal metrics (#1211) refactor(bridge-withdrawer): move generated contract bindings to crate (#1237) fix(sequencer) fix wrong metric and remove unused metric (#1240) feat(sequencer): implement transaction fee query (#1196) chore(cli)!: remove unmaintained rollup subcommand (#1235) release(sequencer): 0.14.1 patch release (#1233) feat(sequencer-utils): generate example genesis state (#1224) feat(sequencer): implement abci query for bridge account info (#1189) feat(charts): bridge-withdrawer, smoke test, various chart improvements (#1141) chore(charts): update for new geth update (#1226) chore(chart)!: dusk-8 chart version updates (#1223) release(conductor): fix conductor release version (#1222) release: dusk-8 versions (#1219) fix(core): revert `From` ed25519_consensus types for crypto mod (#1220) Refactor(chart, sequencer): restructure sequencer chart, adjust configs (#1193) refactor(withdrawer): read from block subscription stream and get events on each block (#1207) feat(core): implement with verification key for address builder and crypto improvements (#1218) feat(proto, sequencer)!: use full IBC ICS20 denoms instead of IDs (#1209) chore(chart): update evm chart for new prefix field (#1214) chore: bump penumbra deps (#1216) ...
Summary
refactor the bridge withdrawer to read only from one block subscription stream instead of a block stream + event streams. then, when a new block is received, the events for that block are batched and sent to the submitter.
Background
this fixes race conditions between the block/event streams and ensures proper batching; ie. that one rollup block = one sequencer tx.
Changes
Testing
unit tests