-
Notifications
You must be signed in to change notification settings - Fork 8
Dep: update revm to 20 #94
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
Merged
Merged
Changes from all commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
c5e8702
wip
prestwich 35115c6
wip
prestwich dce0563
wip
prestwich 6b254fa
fixing
prestwich 5bfc96f
chore: fix doctests
prestwich 3195d07
fix: doclinks
prestwich edbba34
lint: clippy
prestwich 374e94b
chore: depend on stable
prestwich 8479f40
nit:
prestwich b8222c3
docs: slight cleanup
prestwich a45a98a
chore: update example
prestwich 4985c26
chore: fix examples
prestwich 4d05e4d
nit: remove note
prestwich fa30e1a
chore: clean up syscalls
prestwich 564c2f9
docs: slight cleanup
prestwich 76589ec
Update src/builder.rs
prestwich File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
use crate::{evm::Trevm, helpers::Ctx, states::EvmNeedsCfg}; | ||
use revm::{ | ||
database::in_memory_db::InMemoryDB, primitives::hardfork::SpecId, Database, MainBuilder, | ||
}; | ||
|
||
/// Error that can occur when building a Trevm instance. | ||
#[derive(Debug, Clone, thiserror::Error)] | ||
#[non_exhaustive] | ||
pub enum TrevmBuilderError { | ||
/// Database not set. | ||
#[error("Database not set")] | ||
DatabaseNotSet, | ||
} | ||
|
||
/// A builder for [`Trevm`] that allows configuring the EVM. | ||
#[derive(Debug, Clone)] | ||
pub struct TrevmBuilder<Db, Insp> { | ||
pub(crate) db: Option<Db>, | ||
pub(crate) insp: Insp, | ||
pub(crate) spec: SpecId, | ||
} | ||
|
||
impl TrevmBuilder<InMemoryDB, ()> { | ||
/// Create a new builder with the default database and inspector. | ||
#[allow(clippy::new_without_default)] // default would make bad devex :( | ||
pub const fn new() -> Self { | ||
Self { db: None, insp: (), spec: SpecId::PRAGUE } | ||
} | ||
} | ||
|
||
impl<Db, Insp> TrevmBuilder<Db, Insp> { | ||
/// Set the database for the EVM. | ||
pub fn with_db<Odb>(self, db: Odb) -> TrevmBuilder<Odb, Insp> | ||
where | ||
Db: Database, | ||
{ | ||
TrevmBuilder { db: Some(db), insp: self.insp, spec: self.spec } | ||
} | ||
|
||
/// Set the inspector for the EVM. | ||
pub fn with_insp<OInsp>(self, insp: OInsp) -> TrevmBuilder<Db, OInsp> { | ||
TrevmBuilder { db: self.db, insp, spec: self.spec } | ||
} | ||
|
||
/// Set the spec id for the EVM. | ||
pub const fn with_spec_id(mut self, spec: SpecId) -> Self { | ||
self.spec = spec; | ||
self | ||
} | ||
|
||
/// Build the Trevm instance. | ||
pub fn build_trevm(self) -> Result<EvmNeedsCfg<Db, Insp>, TrevmBuilderError> | ||
where | ||
Db: Database, | ||
{ | ||
let db = self.db.ok_or(TrevmBuilderError::DatabaseNotSet)?; | ||
let ctx = Ctx::new(db, self.spec); | ||
let evm = ctx.build_mainnet_with_inspector(self.insp); | ||
Ok(Trevm::from(evm)) | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
i don't exactly remember why we couldn't elide this lifetime before—what was the reason?
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.
so that it could appear in the return types of the functions without being a generic lifetime on the function