-
Notifications
You must be signed in to change notification settings - Fork 47
refactor: clean up and improve flashblocks build_payload
#260
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
|
@SozinM I have fixed the timing, let me know how it looks! |
| ctx: &mut OpPayloadBuilderCtx<FlashblocksExtraCtx>, | ||
| info: &mut ExecutionInfo<ExtraExecutionInfo>, | ||
| total_gas_per_batch: &mut u64, | ||
| total_da_per_batch: &mut Option<u64>, | ||
| builder_tx_da_size: u64, | ||
| builder_tx_gas: u64, | ||
| state: &mut State<DB>, | ||
| best_txs: &mut NextBestFlashblocksTxs<Pool>, | ||
| block_cancel: &CancellationToken, | ||
| flashblocks_per_block: u64, | ||
| message: Vec<u8>, | ||
| best_payload: &BlockCell<OpBuiltPayload>, | ||
| gas_per_batch: u64, | ||
| da_per_batch: Option<u64>, | ||
| span: &tracing::Span, |
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.
the gas / da / config variables can be part of the flashblocks ctx I feel. It would reduce the number of arguments here
| builder_tx_da_size: u64, | ||
| builder_tx_gas: u64, |
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.
there shouldn't be a need to pass this in, can be recalculated for each flashblock. in the future different builder transactions will be inserted depending on whether its the first / last flashblock so it needs to be dynamically calculated per flashblock
| total_gas_per_batch: u64, | ||
| total_da_per_batch: Option<u64>, | ||
| gas_per_batch: u64, | ||
| da_per_batch: Option<u64>, |
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.
could you add some comments around what the different fields are here
| if let Some(da_limit) = total_da_per_batch.as_mut() { | ||
| *da_limit = da_limit.saturating_sub(builder_tx_da_size); | ||
| } | ||
| ctx.extra_ctx.total_da_per_batch = total_da_per_batch; |
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.
why not directly assign ctx.extra_ctx.total_da_per_batch to da_per_batch? Same with the other ctx.extra_ctx assignments, may be worth adding a method for modifying these fields here
| } | ||
| } | ||
|
|
||
| ctx.extra_ctx.total_gas_per_batch = total_gas_per_batch; |
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.
can simplify with ctx.extra_ctx.total_gas_per_batch += ctx.extra_ctx.gas_per_batch;
| .unwrap_or(0); | ||
|
|
||
| // Continue with flashblock building | ||
| let mut total_gas_per_batch = ctx.extra_ctx.total_gas_per_batch; |
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.
nit: should be named target_gas_for_batch
avalonche
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.
some nits, great work!



📝 Summary
build_payloadinto separate functions for readability, specifically moved the code executed within the loop to build a flashblock to its ownbuild_next_flashblockfn (didn't change any logic here)spawn_timer_taskin favour of select statements with ticker insidebuild_payloadfor clarity💡 Motivation and Context
dug into #209 (this PR also improves the logging) and saw opportunity for clean up
✅ I have completed the following steps:
make lintmake test