-
Notifications
You must be signed in to change notification settings - Fork 1
tests: adds a test for host and rollup transaction simulation #190
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
base: dylan/fix-deadline-cutoff
Are you sure you want to change the base?
tests: adds a test for host and rollup transaction simulation #190
Conversation
- 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.
|
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.
This stack of pull requests is managed by Graphite. Learn more about stacking. |
|
|
||
| /// 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))] |
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.
Made public for testing purposes.
| pub async fn new( | ||
| host_provider: HostProvider, | ||
| ru_provider: RuProvider, | ||
| quincey: Quincey, | ||
| ) -> eyre::Result<Self> { |
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.
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.
| 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) | ||
| } |
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.
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.
|
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 |

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.