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

Ruint v1.5.1 #1

Merged
merged 2 commits into from
Oct 25, 2022
Merged
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
6 changes: 3 additions & 3 deletions Cargo.lock

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

2 changes: 2 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ default-members = ["crates/revm"]

[profile.release]
# debug = true
lto = true
codegen-units = 1

[profile.ethtests]
inherits = "test"
Expand Down
12 changes: 10 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,16 @@ run tests with command: `cargo run --release -- statetest tests/GeneralStateTest

`GeneralStateTests` contains all tests related to EVM.

## Running benchmarks

```shell
cargo run --package revm-test --release --bin snailtracer
```

```shell
cargo flamegraph --root --freq 4000 --min-width 0.001 --package revm-test --bin snailtracer
```

# Used by

* Foundry project (as their main EVM): https://github.com/foundry-rs/foundry
Expand All @@ -46,5 +56,3 @@ run tests with command: `cargo run --release -- statetest tests/GeneralStateTest
There is public telegram group: https://t.me/+Ig4WDWOzikA3MzA0

Or if you want to hire me or contact me directly, here is my email: dragan0rakita@gmail.com and telegram: https://t.me/draganrakita


2 changes: 1 addition & 1 deletion crates/revm/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ parking_lot = { version = "0.12", optional = true }
primitive-types = { version = "0.11", default-features = false, features = ["rlp"] }
revm_precompiles = { path = "../revm_precompiles", version = "1.1.1", default-features = false }
rlp = { version = "0.5", default-features = false } # used for create2 address calculation
ruint = { version = "1.5.0", features = ["rlp"] }
ruint = { version = "1.5.1", features = ["rlp"] }
serde = { version = "1.0", features = ["derive","rc"], optional = true }
sha3 = { version = "0.10", default-features = false }
tokio = { version = "1.21", features = ["rt-multi-thread", "macros"], optional = true }
Expand Down
6 changes: 3 additions & 3 deletions crates/revm/src/instructions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -86,9 +86,9 @@ pub fn eval<H: Host, S: Spec>(opcode: u8, interp: &mut Interpreter, host: &mut H
246_u8..=249_u8 => Return::OpcodeNotFound,
251_u8..=252_u8 => Return::OpcodeNotFound,*/
opcode::STOP => Return::Stop,
opcode::ADD => op2_u256_tuple!(interp, overflowing_add),
opcode::MUL => op2_u256_tuple!(interp, overflowing_mul),
Copy link
Author

Choose a reason for hiding this comment

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

Computing whether a mul overflows is actually a surprising amount of extra work. Since we don't need that here, better to use the wrapping version. (No extra cost for add/sub, but changing those too for symmetry and to remove all uses of op2_u256_tuple.)

opcode::SUB => op2_u256_tuple!(interp, overflowing_sub),
opcode::ADD => op2_u256!(interp, wrapping_add),
opcode::MUL => op2_u256!(interp, wrapping_mul),
opcode::SUB => op2_u256!(interp, wrapping_sub),
opcode::DIV => op2_u256_fn!(interp, arithmetic::div),
opcode::SDIV => op2_u256_fn!(interp, arithmetic::sdiv),
opcode::MOD => op2_u256_fn!(interp, arithmetic::rem),
Expand Down
19 changes: 0 additions & 19 deletions crates/revm/src/instructions/macros.rs
Original file line number Diff line number Diff line change
Expand Up @@ -210,25 +210,6 @@ macro_rules! op2_u256 {
}};
}

macro_rules! op2_u256_tuple {
( $interp:expr, $op:ident) => {{
// gas!($interp, $gas);

pop_top!($interp, op1, op2);
let (ret, ..) = op1.$op(*op2);
*op2 = ret;

Return::Continue
}};
( $interp:expr, $op:ident ) => {{
pop_top!($interp, op1, op2);
let (ret, ..) = op1.$op(op2);
*op2 = ret;

Return::Continue
}};
}

macro_rules! op2_u256_fn {
( $interp:expr, $op:path ) => {{
// gas!($interp, $gas);
Expand Down
2 changes: 1 addition & 1 deletion crates/revm/src/instructions/memory.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ pub fn mload(interp: &mut Interpreter) -> Return {
memory_resize!(interp, index, 32);
push!(
interp,
U256::try_from_be_slice(interp.memory.get_slice(index, 32)).unwrap()
U256::from_be_bytes::<32>(interp.memory.get_slice(index, 32).try_into().unwrap())
);
Return::Continue
}
Expand Down