Skip to content
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

Derive Clone for EvmEnv #204

Closed
wants to merge 1 commit into from
Closed

Derive Clone for EvmEnv #204

wants to merge 1 commit into from

Conversation

intoverflow
Copy link
Member

@intoverflow intoverflow commented Aug 24, 2024

Why?

Imagine a situation where the host wants to generate multiple Steel proofs, all using the same RPC provider and block number. In this case, one might start by setting up an EthEvmEnv:

let env = EthEvmEnv::from_rpc(args.rpc_url, block_number).await?.with_chain_spec(chain_spec);

Later, each time we want to use Steel, we work from a fresh clone of env.

In this way, we can avoid passing the RPC and block number around (less verbose and maybe less error prone)

@intoverflow intoverflow marked this pull request as ready for review August 24, 2024 21:23
Copy link
Contributor

@Wollac Wollac left a comment

Choose a reason for hiding this comment

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

With #91 we've introduced the ability to execute multiple calls using the same EvmEnv, so this feature would only be useful in a case where multiple independent Steel proofs (but still referencing the same block) are to be generated within the same host file.
I am a bit reluctant to make the env clonable, as this would also clone the underlying DB with all its current entries. This could lead to errors or misunderstandings as to whether the cloned envs have the same state or not.
If this is really a realistic use case, are there perhaps simple alternatives? Like maybe introducing an EnvBuilder?

@intoverflow
Copy link
Member Author

You make some very good points. I will think some more and get back to you.

@intoverflow
Copy link
Member Author

this feature would only be useful in a case where multiple independent Steel proofs (but still referencing the same block) are to be generated within the same host file

This is exactly the situation I'm in. Basically, I need to do a bunch of separate Steel proofs, which I then roll-up into one proof. Right now I'm doing something like this:

let env = EthEvmEnv::from_rpc(args.rpc_url, BlockNumberOrTag::Number(args.block_number)).await?.with_chain_spec(chain_spec);

...

let foo_receipt = foo(env.clone(), foo_args)?;
let bar_receipt = bar(env.clone(), bar_args)?;

...

This saves me from needing to pass the RPC url, block number, chain_spec.

A builder would be just as good for this purpose, and also (as you point out) would be less error prone. I'll close this PR and maybe we can make the builder happen this week

@intoverflow intoverflow deleted the tcarstens/clone branch September 3, 2024 23:43
Wollac added a commit that referenced this pull request Sep 4, 2024
Add the `EvmEnvBuilder` to simplify the creation of an `EvmEnv` on the
host.
See #204 for more context.

---------

Co-authored-by: Victor Graf <[email protected]>
nategraf added a commit that referenced this pull request Sep 10, 2024
Add the `EvmEnvBuilder` to simplify the creation of an `EvmEnv` on the
host.
See #204 for more context.

---------

Co-authored-by: Victor Graf <[email protected]>
nategraf added a commit that referenced this pull request Sep 10, 2024
Add the `EvmEnvBuilder` to simplify the creation of an `EvmEnv` on the
host.
See #204 for more context.

---------

Co-authored-by: Victor Graf <[email protected]>
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