Skip to content

Commit

Permalink
showcase custom opcode clz
Browse files Browse the repository at this point in the history
  • Loading branch information
FredCoen committed Jan 28, 2025
1 parent be92e1d commit 7608e7b
Show file tree
Hide file tree
Showing 9 changed files with 192 additions and 278 deletions.
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/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

0 comments on commit 7608e7b

Please sign in to comment.