Skip to content

Commit 688c36c

Browse files
authored
chore(interpreter): rename some macros (#1304)
1 parent aec666a commit 688c36c

File tree

7 files changed

+28
-28
lines changed

7 files changed

+28
-28
lines changed

crates/interpreter/src/instructions/contract.rs

+7-7
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ pub fn resize_memory(
3939

4040
/// EOF Create instruction
4141
pub fn eofcreate<H: Host + ?Sized>(interpreter: &mut Interpreter, _host: &mut H) {
42-
error_on_disabled_eof!(interpreter);
42+
require_eof!(interpreter);
4343
gas!(interpreter, EOF_CREATE_GAS);
4444
let initcontainer_index = unsafe { *interpreter.instruction_pointer };
4545
pop!(interpreter, value, salt, data_offset, data_size);
@@ -92,7 +92,7 @@ pub fn eofcreate<H: Host + ?Sized>(interpreter: &mut Interpreter, _host: &mut H)
9292
}
9393

9494
pub fn txcreate<H: Host + ?Sized>(interpreter: &mut Interpreter, host: &mut H) {
95-
error_on_disabled_eof!(interpreter);
95+
require_eof!(interpreter);
9696
gas!(interpreter, EOF_CREATE_GAS);
9797
pop!(
9898
interpreter,
@@ -171,7 +171,7 @@ pub fn txcreate<H: Host + ?Sized>(interpreter: &mut Interpreter, host: &mut H) {
171171
}
172172

173173
pub fn return_contract<H: Host + ?Sized>(interpreter: &mut Interpreter, _host: &mut H) {
174-
error_on_not_init_eof!(interpreter);
174+
require_init_eof!(interpreter);
175175
let deploy_container_index = unsafe { read_u16(interpreter.instruction_pointer) };
176176
pop!(interpreter, aux_data_offset, aux_data_size);
177177
let aux_data_size = as_usize_or_fail!(interpreter, aux_data_size);
@@ -280,7 +280,7 @@ pub fn extcall_gas_calc<H: Host + ?Sized>(
280280
}
281281

282282
pub fn extcall<H: Host + ?Sized, SPEC: Spec>(interpreter: &mut Interpreter, host: &mut H) {
283-
error_on_disabled_eof!(interpreter);
283+
require_eof!(interpreter);
284284
pop_address!(interpreter, target_address);
285285

286286
// input call
@@ -315,7 +315,7 @@ pub fn extcall<H: Host + ?Sized, SPEC: Spec>(interpreter: &mut Interpreter, host
315315
}
316316

317317
pub fn extdcall<H: Host + ?Sized, SPEC: Spec>(interpreter: &mut Interpreter, host: &mut H) {
318-
error_on_disabled_eof!(interpreter);
318+
require_eof!(interpreter);
319319
pop_address!(interpreter, target_address);
320320

321321
// input call
@@ -348,7 +348,7 @@ pub fn extdcall<H: Host + ?Sized, SPEC: Spec>(interpreter: &mut Interpreter, hos
348348
}
349349

350350
pub fn extscall<H: Host + ?Sized>(interpreter: &mut Interpreter, host: &mut H) {
351-
error_on_disabled_eof!(interpreter);
351+
require_eof!(interpreter);
352352
pop_address!(interpreter, target_address);
353353

354354
// input call
@@ -382,7 +382,7 @@ pub fn create<const IS_CREATE2: bool, H: Host + ?Sized, SPEC: Spec>(
382382
interpreter: &mut Interpreter,
383383
host: &mut H,
384384
) {
385-
error_on_static_call!(interpreter);
385+
require_non_staticcall!(interpreter);
386386

387387
// EIP-1014: Skinny CREATE2
388388
if IS_CREATE2 {

crates/interpreter/src/instructions/control.rs

+6-6
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ use crate::{
66
};
77

88
pub fn rjump<H: Host + ?Sized>(interpreter: &mut Interpreter, _host: &mut H) {
9-
error_on_disabled_eof!(interpreter);
9+
require_eof!(interpreter);
1010
gas!(interpreter, gas::BASE);
1111
let offset = unsafe { read_i16(interpreter.instruction_pointer) } as isize;
1212
// In spec it is +3 but pointer is already incremented in
@@ -15,7 +15,7 @@ pub fn rjump<H: Host + ?Sized>(interpreter: &mut Interpreter, _host: &mut H) {
1515
}
1616

1717
pub fn rjumpi<H: Host + ?Sized>(interpreter: &mut Interpreter, _host: &mut H) {
18-
error_on_disabled_eof!(interpreter);
18+
require_eof!(interpreter);
1919
gas!(interpreter, gas::CONDITION_JUMP_GAS);
2020
pop!(interpreter, condition);
2121
// In spec it is +3 but pointer is already incremented in
@@ -29,7 +29,7 @@ pub fn rjumpi<H: Host + ?Sized>(interpreter: &mut Interpreter, _host: &mut H) {
2929
}
3030

3131
pub fn rjumpv<H: Host + ?Sized>(interpreter: &mut Interpreter, _host: &mut H) {
32-
error_on_disabled_eof!(interpreter);
32+
require_eof!(interpreter);
3333
gas!(interpreter, gas::CONDITION_JUMP_GAS);
3434
pop!(interpreter, case);
3535
let case = as_isize_saturated!(case);
@@ -83,7 +83,7 @@ pub fn jumpdest_or_nop<H: Host + ?Sized>(interpreter: &mut Interpreter, _host: &
8383
}
8484

8585
pub fn callf<H: Host + ?Sized>(interpreter: &mut Interpreter, _host: &mut H) {
86-
error_on_disabled_eof!(interpreter);
86+
require_eof!(interpreter);
8787
gas!(interpreter, gas::LOW);
8888

8989
let idx = unsafe { read_u16(interpreter.instruction_pointer) } as usize;
@@ -104,7 +104,7 @@ pub fn callf<H: Host + ?Sized>(interpreter: &mut Interpreter, _host: &mut H) {
104104
}
105105

106106
pub fn retf<H: Host + ?Sized>(interpreter: &mut Interpreter, _host: &mut H) {
107-
error_on_disabled_eof!(interpreter);
107+
require_eof!(interpreter);
108108
gas!(interpreter, gas::RETF_GAS);
109109

110110
let Some(fframe) = interpreter.function_stack.pop() else {
@@ -115,7 +115,7 @@ pub fn retf<H: Host + ?Sized>(interpreter: &mut Interpreter, _host: &mut H) {
115115
}
116116

117117
pub fn jumpf<H: Host + ?Sized>(interpreter: &mut Interpreter, _host: &mut H) {
118-
error_on_disabled_eof!(interpreter);
118+
require_eof!(interpreter);
119119
gas!(interpreter, gas::LOW);
120120

121121
let idx = unsafe { read_u16(interpreter.instruction_pointer) } as usize;

crates/interpreter/src/instructions/data.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ use crate::{
77
};
88

99
pub fn data_load<H: Host + ?Sized>(interpreter: &mut Interpreter, _host: &mut H) {
10-
error_on_disabled_eof!(interpreter);
10+
require_eof!(interpreter);
1111
gas!(interpreter, DATA_LOAD_GAS);
1212
pop_top!(interpreter, offset);
1313

@@ -27,7 +27,7 @@ pub fn data_load<H: Host + ?Sized>(interpreter: &mut Interpreter, _host: &mut H)
2727
}
2828

2929
pub fn data_loadn<H: Host + ?Sized>(interpreter: &mut Interpreter, _host: &mut H) {
30-
error_on_disabled_eof!(interpreter);
30+
require_eof!(interpreter);
3131
gas!(interpreter, VERYLOW);
3232
let offset = unsafe { read_u16(interpreter.instruction_pointer) } as usize;
3333

@@ -48,15 +48,15 @@ pub fn data_loadn<H: Host + ?Sized>(interpreter: &mut Interpreter, _host: &mut H
4848
}
4949

5050
pub fn data_size<H: Host + ?Sized>(interpreter: &mut Interpreter, _host: &mut H) {
51-
error_on_disabled_eof!(interpreter);
51+
require_eof!(interpreter);
5252
gas!(interpreter, BASE);
5353
let data_size = interpreter.eof().expect("eof").header.data_size;
5454

5555
push!(interpreter, U256::from(data_size));
5656
}
5757

5858
pub fn data_copy<H: Host + ?Sized>(interpreter: &mut Interpreter, _host: &mut H) {
59-
error_on_disabled_eof!(interpreter);
59+
require_eof!(interpreter);
6060
gas!(interpreter, VERYLOW);
6161
pop!(interpreter, mem_offset, offset, size);
6262

crates/interpreter/src/instructions/host.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ pub fn sload<H: Host + ?Sized, SPEC: Spec>(interpreter: &mut Interpreter, host:
133133
}
134134

135135
pub fn sstore<H: Host + ?Sized, SPEC: Spec>(interpreter: &mut Interpreter, host: &mut H) {
136-
error_on_static_call!(interpreter);
136+
require_non_staticcall!(interpreter);
137137

138138
pop!(interpreter, index, value);
139139
let Some(SStoreResult {
@@ -160,7 +160,7 @@ pub fn sstore<H: Host + ?Sized, SPEC: Spec>(interpreter: &mut Interpreter, host:
160160
/// Store value to transient storage
161161
pub fn tstore<H: Host + ?Sized, SPEC: Spec>(interpreter: &mut Interpreter, host: &mut H) {
162162
check!(interpreter, CANCUN);
163-
error_on_static_call!(interpreter);
163+
require_non_staticcall!(interpreter);
164164
gas!(interpreter, gas::WARM_STORAGE_READ_COST);
165165

166166
pop!(interpreter, index, value);
@@ -180,7 +180,7 @@ pub fn tload<H: Host + ?Sized, SPEC: Spec>(interpreter: &mut Interpreter, host:
180180
}
181181

182182
pub fn log<const N: usize, H: Host + ?Sized>(interpreter: &mut Interpreter, host: &mut H) {
183-
error_on_static_call!(interpreter);
183+
require_non_staticcall!(interpreter);
184184

185185
pop!(interpreter, offset, len);
186186
let len = as_usize_or_fail!(interpreter, len);
@@ -213,7 +213,7 @@ pub fn log<const N: usize, H: Host + ?Sized>(interpreter: &mut Interpreter, host
213213
}
214214

215215
pub fn selfdestruct<H: Host + ?Sized, SPEC: Spec>(interpreter: &mut Interpreter, host: &mut H) {
216-
error_on_static_call!(interpreter);
216+
require_non_staticcall!(interpreter);
217217
pop_address!(interpreter, target);
218218

219219
let Some(res) = host.selfdestruct(interpreter.contract.target_address, target) else {

crates/interpreter/src/instructions/macros.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
33
/// Fails the instruction if the current call is static.
44
#[macro_export]
5-
macro_rules! error_on_static_call {
5+
macro_rules! require_non_staticcall {
66
($interp:expr) => {
77
if $interp.is_static {
88
$interp.instruction_result = $crate::InstructionResult::StateChangeDuringStaticCall;
@@ -13,7 +13,7 @@ macro_rules! error_on_static_call {
1313

1414
/// Error if the current call is executing EOF.
1515
#[macro_export]
16-
macro_rules! error_on_disabled_eof {
16+
macro_rules! require_eof {
1717
($interp:expr) => {
1818
if !$interp.is_eof {
1919
$interp.instruction_result = $crate::InstructionResult::EOFOpcodeDisabledInLegacy;
@@ -24,7 +24,7 @@ macro_rules! error_on_disabled_eof {
2424

2525
/// Error if not init eof call.
2626
#[macro_export]
27-
macro_rules! error_on_not_init_eof {
27+
macro_rules! require_init_eof {
2828
($interp:expr) => {
2929
if !$interp.is_eof_init {
3030
$interp.instruction_result = $crate::InstructionResult::ReturnContractInNotInitEOF;

crates/interpreter/src/instructions/stack.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ pub fn swap<const N: usize, H: Host + ?Sized>(interpreter: &mut Interpreter, _ho
5252
}
5353

5454
pub fn dupn<H: Host + ?Sized>(interpreter: &mut Interpreter, _host: &mut H) {
55-
error_on_disabled_eof!(interpreter);
55+
require_eof!(interpreter);
5656
gas!(interpreter, gas::VERYLOW);
5757
let imm = unsafe { *interpreter.instruction_pointer };
5858
if let Err(result) = interpreter.stack.dup(imm as usize + 1) {
@@ -62,7 +62,7 @@ pub fn dupn<H: Host + ?Sized>(interpreter: &mut Interpreter, _host: &mut H) {
6262
}
6363

6464
pub fn swapn<H: Host + ?Sized>(interpreter: &mut Interpreter, _host: &mut H) {
65-
error_on_disabled_eof!(interpreter);
65+
require_eof!(interpreter);
6666
gas!(interpreter, gas::VERYLOW);
6767
let imm = unsafe { *interpreter.instruction_pointer };
6868
if let Err(result) = interpreter.stack.swap(imm as usize + 1) {
@@ -72,7 +72,7 @@ pub fn swapn<H: Host + ?Sized>(interpreter: &mut Interpreter, _host: &mut H) {
7272
}
7373

7474
pub fn exchange<H: Host + ?Sized>(interpreter: &mut Interpreter, _host: &mut H) {
75-
error_on_disabled_eof!(interpreter);
75+
require_eof!(interpreter);
7676
gas!(interpreter, gas::VERYLOW);
7777
let imm = unsafe { *interpreter.instruction_pointer };
7878
let n = (imm >> 4) + 1;

crates/interpreter/src/instructions/system.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ pub fn returndatacopy<H: Host + ?Sized, SPEC: Spec>(interpreter: &mut Interprete
145145

146146
/// Part of EOF `<https://eips.ethereum.org/EIPS/eip-7069>`.
147147
pub fn returndataload<H: Host + ?Sized>(interpreter: &mut Interpreter, _host: &mut H) {
148-
error_on_disabled_eof!(interpreter);
148+
require_eof!(interpreter);
149149
gas!(interpreter, gas::VERYLOW);
150150
pop_top!(interpreter, offset);
151151
let offset_usize = as_usize_or_fail!(interpreter, offset);

0 commit comments

Comments
 (0)