Skip to content

Commit eb74892

Browse files
author
Lorenzo Feroleto
committed
Merge branch 'main' of https://github.com/lorenzofero/revm into shared_memory
2 parents b524b18 + 516f62c commit eb74892

File tree

17 files changed

+481
-299
lines changed

17 files changed

+481
-299
lines changed

Cargo.lock

+2-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

bins/revme/src/statetest/runner.rs

+5-4
Original file line numberDiff line numberDiff line change
@@ -190,10 +190,11 @@ pub fn execute_test_suite(
190190
unit.env.parent_blob_gas_used,
191191
unit.env.parent_excess_blob_gas,
192192
) {
193-
env.block.excess_blob_gas = Some(calc_excess_blob_gas(
194-
parent_blob_gas_used.to(),
195-
parent_excess_blob_gas.to(),
196-
));
193+
env.block
194+
.set_blob_excess_gas_and_price(calc_excess_blob_gas(
195+
parent_blob_gas_used.to(),
196+
parent_excess_blob_gas.to(),
197+
));
197198
}
198199

199200
// tx env

crates/interpreter/src/instructions/arithmetic.rs

+11-11
Original file line numberDiff line numberDiff line change
@@ -5,67 +5,67 @@ use crate::{
55
Host, InstructionResult, Interpreter,
66
};
77

8-
pub fn wrapped_add(interpreter: &mut Interpreter, _host: &mut dyn Host) {
8+
pub fn wrapped_add<H: Host>(interpreter: &mut Interpreter, _host: &mut H) {
99
gas!(interpreter, gas::VERYLOW);
1010
pop_top!(interpreter, op1, op2);
1111
*op2 = op1.wrapping_add(*op2);
1212
}
1313

14-
pub fn wrapping_mul(interpreter: &mut Interpreter, _host: &mut dyn Host) {
14+
pub fn wrapping_mul<H: Host>(interpreter: &mut Interpreter, _host: &mut H) {
1515
gas!(interpreter, gas::LOW);
1616
pop_top!(interpreter, op1, op2);
1717
*op2 = op1.wrapping_mul(*op2);
1818
}
1919

20-
pub fn wrapping_sub(interpreter: &mut Interpreter, _host: &mut dyn Host) {
20+
pub fn wrapping_sub<H: Host>(interpreter: &mut Interpreter, _host: &mut H) {
2121
gas!(interpreter, gas::VERYLOW);
2222
pop_top!(interpreter, op1, op2);
2323
*op2 = op1.wrapping_sub(*op2);
2424
}
2525

26-
pub fn div(interpreter: &mut Interpreter, _host: &mut dyn Host) {
26+
pub fn div<H: Host>(interpreter: &mut Interpreter, _host: &mut H) {
2727
gas!(interpreter, gas::LOW);
2828
pop_top!(interpreter, op1, op2);
2929
if *op2 != U256::ZERO {
3030
*op2 = op1.wrapping_div(*op2);
3131
}
3232
}
3333

34-
pub fn sdiv(interpreter: &mut Interpreter, _host: &mut dyn Host) {
34+
pub fn sdiv<H: Host>(interpreter: &mut Interpreter, _host: &mut H) {
3535
gas!(interpreter, gas::LOW);
3636
pop_top!(interpreter, op1, op2);
3737
*op2 = i256_div(op1, *op2);
3838
}
3939

40-
pub fn rem(interpreter: &mut Interpreter, _host: &mut dyn Host) {
40+
pub fn rem<H: Host>(interpreter: &mut Interpreter, _host: &mut H) {
4141
gas!(interpreter, gas::LOW);
4242
pop_top!(interpreter, op1, op2);
4343
if *op2 != U256::ZERO {
4444
*op2 = op1.wrapping_rem(*op2);
4545
}
4646
}
4747

48-
pub fn smod(interpreter: &mut Interpreter, _host: &mut dyn Host) {
48+
pub fn smod<H: Host>(interpreter: &mut Interpreter, _host: &mut H) {
4949
gas!(interpreter, gas::LOW);
5050
pop_top!(interpreter, op1, op2);
5151
if *op2 != U256::ZERO {
5252
*op2 = i256_mod(op1, *op2)
5353
}
5454
}
5555

56-
pub fn addmod(interpreter: &mut Interpreter, _host: &mut dyn Host) {
56+
pub fn addmod<H: Host>(interpreter: &mut Interpreter, _host: &mut H) {
5757
gas!(interpreter, gas::MID);
5858
pop_top!(interpreter, op1, op2, op3);
5959
*op3 = op1.add_mod(op2, *op3)
6060
}
6161

62-
pub fn mulmod(interpreter: &mut Interpreter, _host: &mut dyn Host) {
62+
pub fn mulmod<H: Host>(interpreter: &mut Interpreter, _host: &mut H) {
6363
gas!(interpreter, gas::MID);
6464
pop_top!(interpreter, op1, op2, op3);
6565
*op3 = op1.mul_mod(op2, *op3)
6666
}
6767

68-
pub fn exp<SPEC: Spec>(interpreter: &mut Interpreter, _host: &mut dyn Host) {
68+
pub fn exp<H: Host, SPEC: Spec>(interpreter: &mut Interpreter, _host: &mut H) {
6969
pop_top!(interpreter, op1, op2);
7070
gas_or_fail!(interpreter, gas::exp_cost::<SPEC>(*op2));
7171
*op2 = op1.pow(*op2);
@@ -86,7 +86,7 @@ pub fn exp<SPEC: Spec>(interpreter: &mut Interpreter, _host: &mut dyn Host) {
8686
/// `y | !mask` where `|` is the bitwise `OR` and `!` is bitwise negation. Similarly, if
8787
/// `b == 0` then the yellow paper says the output should start with all zeros, then end with
8888
/// bits from `b`; this is equal to `y & mask` where `&` is bitwise `AND`.
89-
pub fn signextend(interpreter: &mut Interpreter, _host: &mut dyn Host) {
89+
pub fn signextend<H: Host>(interpreter: &mut Interpreter, _host: &mut H) {
9090
gas!(interpreter, gas::LOW);
9191
pop_top!(interpreter, op1, op2);
9292
if op1 < U256::from(32) {

crates/interpreter/src/instructions/bitwise.rs

+14-14
Original file line numberDiff line numberDiff line change
@@ -6,67 +6,67 @@ use crate::{
66
};
77
use core::cmp::Ordering;
88

9-
pub fn lt(interpreter: &mut Interpreter, _host: &mut dyn Host) {
9+
pub fn lt<H: Host>(interpreter: &mut Interpreter, _host: &mut H) {
1010
gas!(interpreter, gas::VERYLOW);
1111
pop_top!(interpreter, op1, op2);
1212
*op2 = U256::from(op1 < *op2);
1313
}
1414

15-
pub fn gt(interpreter: &mut Interpreter, _host: &mut dyn Host) {
15+
pub fn gt<H: Host>(interpreter: &mut Interpreter, _host: &mut H) {
1616
gas!(interpreter, gas::VERYLOW);
1717
pop_top!(interpreter, op1, op2);
1818
*op2 = U256::from(op1 > *op2);
1919
}
2020

21-
pub fn slt(interpreter: &mut Interpreter, _host: &mut dyn Host) {
21+
pub fn slt<H: Host>(interpreter: &mut Interpreter, _host: &mut H) {
2222
gas!(interpreter, gas::VERYLOW);
2323
pop_top!(interpreter, op1, op2);
2424
*op2 = U256::from(i256_cmp(&op1, op2) == Ordering::Less);
2525
}
2626

27-
pub fn sgt(interpreter: &mut Interpreter, _host: &mut dyn Host) {
27+
pub fn sgt<H: Host>(interpreter: &mut Interpreter, _host: &mut H) {
2828
gas!(interpreter, gas::VERYLOW);
2929
pop_top!(interpreter, op1, op2);
3030
*op2 = U256::from(i256_cmp(&op1, op2) == Ordering::Greater);
3131
}
3232

33-
pub fn eq(interpreter: &mut Interpreter, _host: &mut dyn Host) {
33+
pub fn eq<H: Host>(interpreter: &mut Interpreter, _host: &mut H) {
3434
gas!(interpreter, gas::VERYLOW);
3535
pop_top!(interpreter, op1, op2);
3636
*op2 = U256::from(op1 == *op2);
3737
}
3838

39-
pub fn iszero(interpreter: &mut Interpreter, _host: &mut dyn Host) {
39+
pub fn iszero<H: Host>(interpreter: &mut Interpreter, _host: &mut H) {
4040
gas!(interpreter, gas::VERYLOW);
4141
pop_top!(interpreter, op1);
4242
*op1 = U256::from(*op1 == U256::ZERO);
4343
}
4444

45-
pub fn bitand(interpreter: &mut Interpreter, _host: &mut dyn Host) {
45+
pub fn bitand<H: Host>(interpreter: &mut Interpreter, _host: &mut H) {
4646
gas!(interpreter, gas::VERYLOW);
4747
pop_top!(interpreter, op1, op2);
4848
*op2 = op1 & *op2;
4949
}
5050

51-
pub fn bitor(interpreter: &mut Interpreter, _host: &mut dyn Host) {
51+
pub fn bitor<H: Host>(interpreter: &mut Interpreter, _host: &mut H) {
5252
gas!(interpreter, gas::VERYLOW);
5353
pop_top!(interpreter, op1, op2);
5454
*op2 = op1 | *op2;
5555
}
5656

57-
pub fn bitxor(interpreter: &mut Interpreter, _host: &mut dyn Host) {
57+
pub fn bitxor<H: Host>(interpreter: &mut Interpreter, _host: &mut H) {
5858
gas!(interpreter, gas::VERYLOW);
5959
pop_top!(interpreter, op1, op2);
6060
*op2 = op1 ^ *op2;
6161
}
6262

63-
pub fn not(interpreter: &mut Interpreter, _host: &mut dyn Host) {
63+
pub fn not<H: Host>(interpreter: &mut Interpreter, _host: &mut H) {
6464
gas!(interpreter, gas::VERYLOW);
6565
pop_top!(interpreter, op1);
6666
*op1 = !*op1;
6767
}
6868

69-
pub fn byte(interpreter: &mut Interpreter, _host: &mut dyn Host) {
69+
pub fn byte<H: Host>(interpreter: &mut Interpreter, _host: &mut H) {
7070
gas!(interpreter, gas::VERYLOW);
7171
pop_top!(interpreter, op1, op2);
7272

@@ -80,23 +80,23 @@ pub fn byte(interpreter: &mut Interpreter, _host: &mut dyn Host) {
8080
}
8181

8282
/// EIP-145: Bitwise shifting instructions in EVM
83-
pub fn shl<SPEC: Spec>(interpreter: &mut Interpreter, _host: &mut dyn Host) {
83+
pub fn shl<H: Host, SPEC: Spec>(interpreter: &mut Interpreter, _host: &mut H) {
8484
check!(interpreter, CONSTANTINOPLE);
8585
gas!(interpreter, gas::VERYLOW);
8686
pop_top!(interpreter, op1, op2);
8787
*op2 <<= as_usize_saturated!(op1);
8888
}
8989

9090
/// EIP-145: Bitwise shifting instructions in EVM
91-
pub fn shr<SPEC: Spec>(interpreter: &mut Interpreter, _host: &mut dyn Host) {
91+
pub fn shr<H: Host, SPEC: Spec>(interpreter: &mut Interpreter, _host: &mut H) {
9292
check!(interpreter, CONSTANTINOPLE);
9393
gas!(interpreter, gas::VERYLOW);
9494
pop_top!(interpreter, op1, op2);
9595
*op2 >>= as_usize_saturated!(op1);
9696
}
9797

9898
/// EIP-145: Bitwise shifting instructions in EVM
99-
pub fn sar<SPEC: Spec>(interpreter: &mut Interpreter, _host: &mut dyn Host) {
99+
pub fn sar<H: Host, SPEC: Spec>(interpreter: &mut Interpreter, _host: &mut H) {
100100
check!(interpreter, CONSTANTINOPLE);
101101
gas!(interpreter, gas::VERYLOW);
102102
pop_top!(interpreter, op1, op2);

crates/interpreter/src/instructions/control.rs

+9-9
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use crate::{
44
Host, InstructionResult, Interpreter,
55
};
66

7-
pub fn jump(interpreter: &mut Interpreter, _host: &mut dyn Host) {
7+
pub fn jump<H: Host>(interpreter: &mut Interpreter, _host: &mut H) {
88
gas!(interpreter, gas::MID);
99
pop!(interpreter, dest);
1010
let dest = as_usize_or_fail!(interpreter, dest, InstructionResult::InvalidJump);
@@ -18,7 +18,7 @@ pub fn jump(interpreter: &mut Interpreter, _host: &mut dyn Host) {
1818
}
1919
}
2020

21-
pub fn jumpi(interpreter: &mut Interpreter, _host: &mut dyn Host) {
21+
pub fn jumpi<H: Host>(interpreter: &mut Interpreter, _host: &mut H) {
2222
gas!(interpreter, gas::HIGH);
2323
pop!(interpreter, dest, value);
2424
if value != U256::ZERO {
@@ -34,11 +34,11 @@ pub fn jumpi(interpreter: &mut Interpreter, _host: &mut dyn Host) {
3434
}
3535
}
3636

37-
pub fn jumpdest(interpreter: &mut Interpreter, _host: &mut dyn Host) {
37+
pub fn jumpdest<H: Host>(interpreter: &mut Interpreter, _host: &mut H) {
3838
gas!(interpreter, gas::JUMPDEST);
3939
}
4040

41-
pub fn pc(interpreter: &mut Interpreter, _host: &mut dyn Host) {
41+
pub fn pc<H: Host>(interpreter: &mut Interpreter, _host: &mut H) {
4242
gas!(interpreter, gas::BASE);
4343
// - 1 because we have already advanced the instruction pointer in `Interpreter::step`
4444
push!(interpreter, U256::from(interpreter.program_counter() - 1));
@@ -60,24 +60,24 @@ fn return_inner(interpreter: &mut Interpreter, result: InstructionResult) {
6060
interpreter.instruction_result = result;
6161
}
6262

63-
pub fn ret(interpreter: &mut Interpreter, _host: &mut dyn Host) {
63+
pub fn ret<H: Host>(interpreter: &mut Interpreter, _host: &mut H) {
6464
return_inner(interpreter, InstructionResult::Return)
6565
}
6666

6767
/// EIP-140: REVERT instruction
68-
pub fn revert<SPEC: Spec>(interpreter: &mut Interpreter, _host: &mut dyn Host) {
68+
pub fn revert<H: Host, SPEC: Spec>(interpreter: &mut Interpreter, _host: &mut H) {
6969
check!(interpreter, BYZANTIUM);
7070
return_inner(interpreter, InstructionResult::Revert)
7171
}
7272

73-
pub fn stop(interpreter: &mut Interpreter, _host: &mut dyn Host) {
73+
pub fn stop<H: Host>(interpreter: &mut Interpreter, _host: &mut H) {
7474
interpreter.instruction_result = InstructionResult::Stop;
7575
}
7676

77-
pub fn invalid(interpreter: &mut Interpreter, _host: &mut dyn Host) {
77+
pub fn invalid<H: Host>(interpreter: &mut Interpreter, _host: &mut H) {
7878
interpreter.instruction_result = InstructionResult::InvalidFEOpcode;
7979
}
8080

81-
pub fn not_found(interpreter: &mut Interpreter, _host: &mut dyn Host) {
81+
pub fn not_found<H: Host>(interpreter: &mut Interpreter, _host: &mut H) {
8282
interpreter.instruction_result = InstructionResult::OpcodeNotFound;
8383
}

0 commit comments

Comments
 (0)