Skip to content

Conversation

@dylanlott
Copy link
Contributor

@dylanlott dylanlott commented Dec 3, 2025

tests: adds a test for host and rollup transaction simulation

This PR adds a test that makes an anvil instance for the host and rollup provider and then uses that to simulate the block building loop.

  • Refactors the SimulateTask and EnvTask constructors to take Providers instead of privately setting them up for easier swapping at test time.

- this commit refactors the constructor functions of a the Simulator
and Env tasks to use a provider that is passed in instead of connected
internally for easier testing.
Copy link
Contributor Author

Warning

This pull request is not mergeable via GitHub because a downstack PR is open. Once all requirements are satisfied, merge this PR as a stack on Graphite.
Learn more

This stack of pull requests is managed by Graphite. Learn more about stacking.

@dylanlott dylanlott mentioned this pull request Dec 3, 2025
@dylanlott dylanlott changed the title wip: working on getting bundle integration tests working tests: adds a test for host and rollup transaction simulation Dec 3, 2025

/// Construct a [`BlockEnv`] for the next host block from the previous host header.
fn construct_host_env(&self, previous: Header) -> Environment {
#[instrument(skip(self, previous), fields(previous_number = %previous.number))]
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Made public for testing purposes.

Comment on lines +205 to +209
pub async fn new(
host_provider: HostProvider,
ru_provider: RuProvider,
quincey: Quincey,
) -> eyre::Result<Self> {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

NB: These are passed in at construction time for test purposes, but to improve here, we could make our tasks generic over Host and Rollup providers and make this a little bit more idiomatic.

Comment on lines +166 to +195
fn spawn_host_anvil() -> (AnvilInstance, HostProvider, PrivateKeySigner) {
let anvil = Anvil::new().chain_id(constants().host_chain_id()).spawn();
let key = anvil.keys()[0].clone();
let signer = PrivateKeySigner::from_bytes(&B256::from_slice(&key.to_bytes())).unwrap();
let wallet = anvil.wallet().expect("anvil wallet");
let provider = ProviderBuilder::new_with_network()
.disable_recommended_fillers()
.filler(BlobGasFiller)
.with_gas_estimation()
.with_nonce_management(SimpleNonceManager::default())
.fetch_chain_id()
.wallet(wallet)
.connect_http(anvil.endpoint_url());

(anvil, provider, signer)
}

fn spawn_rollup_anvil() -> (AnvilInstance, RuProvider, Vec<PrivateKeySigner>) {
let anvil = Anvil::new().chain_id(constants().ru_chain_id()).spawn();
let signers: Vec<_> = anvil
.keys()
.iter()
.take(2)
.map(|key| PrivateKeySigner::from_bytes(&B256::from_slice(&key.to_bytes())).unwrap())
.collect();
assert!(signers.len() >= 2, "rollup anvil must provide at least two accounts");
let provider = RootProvider::new_http(anvil.endpoint_url());

(anvil, provider, signers)
}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

NB: These are intentionally not forked off of RPC so that they don't rely on Pecorino state at all yet. These are simply simulating "dumb" Signet bundles. The next step to shore these up is going to be forking them off of the actual host and rollup RPCs (once Pecorino is running again) and then making these "smart" bundles that actually call Signet contracts.

@prestwich
Copy link
Member

rather than use anvil forking, we have direct control over the contents of the DB caches that the sim task uses. we should insert changes into the DB directly, instead of using a middleware layer to do it. effectively, the DB underlying the sim task IS a forking layer for the chain, and we shouldn't use external middleware to do something we can do in-process

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