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

Showcase custom opcode clz on revm evm framework #2031

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ members = [
"examples/uniswap_get_reserves",
"examples/uniswap_v2_usdc_swap",
"examples/erc20_gas",
#"examples/custom_opcodes",
"examples/instruction_table_override",
]
resolver = "2"
default-members = ["crates/revm"]
Expand Down
2 changes: 1 addition & 1 deletion crates/database/src/in_memory_db.rs
Original file line number Diff line number Diff line change
Expand Up @@ -389,7 +389,7 @@ impl AccountState {
}
}

/// Custom benchmarking DB that only has account info for the zero address.
/// Custom benchmarking DB that only has account info for the FFADDRESS address.
///
/// Any other address will return an empty account.
#[derive(Debug, Default, Clone)]
Expand Down
2 changes: 1 addition & 1 deletion crates/interpreter/src/instructions/macros.rs
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ macro_rules! popn {
};
};
}

#[macro_export]
macro_rules! popn_top {
([ $($x:ident),* ], $top:ident, $interpreterreter:expr $(,$ret:expr)? ) => {
let Some(([$( $x ),*], $top)) = $interpreterreter.stack.popn_top() else {
Expand Down
274 changes: 0 additions & 274 deletions examples/custom_opcodes/src/lib.rs

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[package]
name = "example-custom-opcodes"
name = "example-instruction-table-override"
version = "0.0.0"
publish = false
authors.workspace = true
Expand All @@ -9,6 +9,7 @@ license.workspace = true
repository.workspace = true
readme.workspace = true


[package.metadata.docs.rs]
all-features = true
rustdoc-args = ["--cfg", "docsrs"]
Expand All @@ -22,5 +23,9 @@ rust_2018_idioms = "deny"
all = "warn"

[dependencies]
# Core revm dependencies
revm.workspace = true
database.workspace = true
database = { workspace = true }

# Error handling
anyhow = "1.0.89"
15 changes: 15 additions & 0 deletions examples/instruction_table_override/src/exec.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
use crate::handler::CustomOpcodeHandler;
use revm::{
context_interface::{
result::{EVMError, HaltReason, InvalidTransaction, ResultAndState},
DatabaseGetter,
},
database_interface::Database,
handler::handler::{EthContext, EthHandler},
};

pub fn transact_custom_opcode<DB: Database, CTX: EthContext + DatabaseGetter<Database = DB>>(
ctx: &mut CTX,
) -> Result<ResultAndState<HaltReason>, EVMError<<DB as Database>::Error, InvalidTransaction>> {
CustomOpcodeHandler::<CTX, _>::new().run(ctx)
}
Loading
Loading