Skip to content

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

@avalonche avalonche force-pushed the builder-tx branch 3 times, most recently from 4e28c2e to c461c24 Compare September 9, 2025 22:59
}
}

pub trait BuilderTransactions<ExtraCtx: Debug + Default = ()>: Debug {
Copy link
Contributor

@noot noot Sep 11, 2025

Choose a reason for hiding this comment

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

it'd be a lot cleaner to have this as an enum as opposed to a trait, so you don't need to use generic BuilderTransactions everywhere.

eg.

pub enum BuilderTransactions {
    Flashblocks(FlashblocksBuilderTx),
    Standard(StandardBuilderTx),
    Flashtestations(FlashtestationsBuilderTx),
}

impl BuilderTransactions {
    pub fn simulate_builder_txs(&self, ...) {
        match self {
            Self::Flashblocks(inner) => inner.simulate_builder_txs(...),
            Self::Standard(inner) => inner.simulate_builder_txs(...),
            Self::Flashtestations(inner) => inner.simulate_builder_txs(...),
        }
    }
    
    pub fn add_builder_txs(&self, ...) { ... }
    pub fn simulate_builder_txs_state(&self, ...) {...}
}

you can also get rid of the ExtraCtx generic param as well with this, as each type (FlashblocksBuilderTx, etc) can contain its own context.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sounds good but I would try the enum approach in a follow up PR to refactor the existing generic builder tx

Copy link
Contributor

Choose a reason for hiding this comment

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

that would be great!

@avalonche avalonche merged commit 6b1752f into main Sep 17, 2025
4 checks passed
@avalonche avalonche deleted the builder-tx branch September 17, 2025 17:21
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.

3 participants