Skip to content

Refactor payload builder to accept generic builder tx #217

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

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

Conversation

avalonche
Copy link
Contributor

📝 Summary

Refactor to allow the payload builder accept generics for how to construct the builder tx.

💡 Motivation and Context

Easier to add custom logic to builder tx based on the payload builder such as contract calls etc.


✅ I have completed the following steps:

  • Run make lint
  • Run make test
  • Added tests (if applicable)

if let Some(flashtestations_builder_tx) = &self.flashtestations_builder_tx {
// We only include flashtestations txs in the last flashblock

let mut simulation_state = self.simulate_builder_txs_state::<FlashblocksExtraCtx>(
Copy link
Contributor Author

Choose a reason for hiding this comment

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

returns empty vec for now

}
}

pub fn simulate_builder_tx<ExtraCtx: Debug + Default>(
Copy link
Contributor Author

Choose a reason for hiding this comment

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

replace with flashblocks builder tx contract call

EvmExecutionError(Box<dyn core::error::Error + Send + Sync>),
/// Any other builder transaction errors.
#[error(transparent)]
Other(Box<dyn core::error::Error + Send + Sync>),
Copy link
Collaborator

Choose a reason for hiding this comment

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

Wdyt about using anyhow in here?

/// Current flashblock index
pub flashblock_index: u64,
/// Target flashblock count
pub target_flashblock_count: u64,
/// Whether the current flashblock is the first fallback block
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can we determine this from index?


let (payload, fb_payload, mut bundle_state) = build_block(db, &ctx, &mut info)?;

best_payload.set(payload.clone());
self.ws_pub
.publish(&fb_payload)
.map_err(PayloadBuilderError::other)?;
// We set the first fallback block flag to false after building the first fallback block
Copy link
Collaborator

Choose a reason for hiding this comment

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

i'd rather handle via index
this side effect seems like something that would cause a bug in the long run

let mut info = execute_pre_steps(&mut db, &ctx)?;
let sequencer_tx_time = sequencer_tx_start_time.elapsed();
ctx.metrics.sequencer_tx_duration.record(sequencer_tx_time);
ctx.metrics.sequencer_tx_gauge.set(sequencer_tx_time);

// If we have payload with txpool we add first builder tx right after deposits
if !ctx.attributes().no_tx_pool {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why have you removed this?
If we are building deposits only block we shouldn't include builder tx

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I thought this was never hit since rollup-boost does not send if no_tx_pool = true but I'll add it back in

Copy link
Collaborator

Choose a reason for hiding this comment

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

You are correct, buy removing this will break no_txpool support in case we change boost

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants