Skip to content

Commit b73c33c

Browse files
authored
Introduce the concept of Etable in core (#186)
1 parent 60d5d18 commit b73c33c

File tree

4 files changed

+404
-380
lines changed

4 files changed

+404
-380
lines changed

core/src/eval/misc.rs

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,15 @@ use core::cmp::min;
44
use primitive_types::{H256, U256};
55

66
#[inline]
7-
pub fn codesize(state: &mut Machine) -> Control {
7+
pub fn codesize<S>(state: &mut Machine<S>) -> Control {
88
let size = U256::from(state.code.len());
99
trace_op!("CodeSize: {}", size);
1010
push_u256!(state, size);
1111
Control::Continue(1)
1212
}
1313

1414
#[inline]
15-
pub fn codecopy(state: &mut Machine) -> Control {
15+
pub fn codecopy<S>(state: &mut Machine<S>) -> Control {
1616
pop_u256!(state, memory_offset, code_offset, len);
1717
trace_op!("CodeCopy: {}", len);
1818

@@ -27,7 +27,7 @@ pub fn codecopy(state: &mut Machine) -> Control {
2727
}
2828

2929
#[inline]
30-
pub fn calldataload(state: &mut Machine) -> Control {
30+
pub fn calldataload<S>(state: &mut Machine<S>) -> Control {
3131
pop_u256!(state, index);
3232

3333
let mut load = [0u8; 32];
@@ -48,15 +48,15 @@ pub fn calldataload(state: &mut Machine) -> Control {
4848
}
4949

5050
#[inline]
51-
pub fn calldatasize(state: &mut Machine) -> Control {
51+
pub fn calldatasize<S>(state: &mut Machine<S>) -> Control {
5252
let len = U256::from(state.data.len());
5353
trace_op!("CallDataSize: {}", len);
5454
push_u256!(state, len);
5555
Control::Continue(1)
5656
}
5757

5858
#[inline]
59-
pub fn calldatacopy(state: &mut Machine) -> Control {
59+
pub fn calldatacopy<S>(state: &mut Machine<S>) -> Control {
6060
pop_u256!(state, memory_offset, data_offset, len);
6161
trace_op!("CallDataCopy: {}", len);
6262

@@ -75,14 +75,14 @@ pub fn calldatacopy(state: &mut Machine) -> Control {
7575
}
7676

7777
#[inline]
78-
pub fn pop(state: &mut Machine) -> Control {
78+
pub fn pop<S>(state: &mut Machine<S>) -> Control {
7979
pop!(state, _val);
8080
trace_op!("Pop [@{}]: {}", state.stack.len(), _val);
8181
Control::Continue(1)
8282
}
8383

8484
#[inline]
85-
pub fn mload(state: &mut Machine) -> Control {
85+
pub fn mload<S>(state: &mut Machine<S>) -> Control {
8686
pop_u256!(state, index);
8787
trace_op!("MLoad: {}", index);
8888
try_or_fail!(state.memory.resize_offset(index, U256::from(32)));
@@ -93,7 +93,7 @@ pub fn mload(state: &mut Machine) -> Control {
9393
}
9494

9595
#[inline]
96-
pub fn mstore(state: &mut Machine) -> Control {
96+
pub fn mstore<S>(state: &mut Machine<S>) -> Control {
9797
pop_u256!(state, index);
9898
pop!(state, value);
9999
trace_op!("MStore: {}, {}", index, value);
@@ -106,7 +106,7 @@ pub fn mstore(state: &mut Machine) -> Control {
106106
}
107107

108108
#[inline]
109-
pub fn mstore8(state: &mut Machine) -> Control {
109+
pub fn mstore8<S>(state: &mut Machine<S>) -> Control {
110110
pop_u256!(state, index, value);
111111
try_or_fail!(state.memory.resize_offset(index, U256::one()));
112112
let index = as_usize_or_fail!(index);
@@ -118,7 +118,7 @@ pub fn mstore8(state: &mut Machine) -> Control {
118118
}
119119

120120
#[inline]
121-
pub fn jump(state: &mut Machine) -> Control {
121+
pub fn jump<S>(state: &mut Machine<S>) -> Control {
122122
pop_u256!(state, dest);
123123
let dest = as_usize_or_fail!(dest, ExitError::InvalidJump);
124124
trace_op!("Jump: {}", dest);
@@ -131,7 +131,7 @@ pub fn jump(state: &mut Machine) -> Control {
131131
}
132132

133133
#[inline]
134-
pub fn jumpi(state: &mut Machine) -> Control {
134+
pub fn jumpi<S>(state: &mut Machine<S>) -> Control {
135135
pop_u256!(state, dest);
136136
pop!(state, value);
137137

@@ -150,20 +150,20 @@ pub fn jumpi(state: &mut Machine) -> Control {
150150
}
151151

152152
#[inline]
153-
pub fn pc(state: &mut Machine, position: usize) -> Control {
153+
pub fn pc<S>(state: &mut Machine<S>, position: usize) -> Control {
154154
trace_op!("PC");
155155
push_u256!(state, U256::from(position));
156156
Control::Continue(1)
157157
}
158158

159159
#[inline]
160-
pub fn msize(state: &mut Machine) -> Control {
160+
pub fn msize<S>(state: &mut Machine<S>) -> Control {
161161
push_u256!(state, state.memory.effective_len());
162162
Control::Continue(1)
163163
}
164164

165165
#[inline]
166-
pub fn push(state: &mut Machine, n: usize, position: usize) -> Control {
166+
pub fn push<S>(state: &mut Machine<S>, n: usize, position: usize) -> Control {
167167
let end = min(position + 1 + n, state.code.len());
168168
let slice = &state.code[(position + 1)..end];
169169
let mut val = [0u8; 32];
@@ -176,7 +176,7 @@ pub fn push(state: &mut Machine, n: usize, position: usize) -> Control {
176176
}
177177

178178
#[inline]
179-
pub fn dup(state: &mut Machine, n: usize) -> Control {
179+
pub fn dup<S>(state: &mut Machine<S>, n: usize) -> Control {
180180
let value = match state.stack.peek(n - 1) {
181181
Ok(value) => value,
182182
Err(e) => return Control::Exit(e.into()),
@@ -187,7 +187,7 @@ pub fn dup(state: &mut Machine, n: usize) -> Control {
187187
}
188188

189189
#[inline]
190-
pub fn swap(state: &mut Machine, n: usize) -> Control {
190+
pub fn swap<S>(state: &mut Machine<S>, n: usize) -> Control {
191191
let val1 = match state.stack.peek(0) {
192192
Ok(value) => value,
193193
Err(e) => return Control::Exit(e.into()),
@@ -209,7 +209,7 @@ pub fn swap(state: &mut Machine, n: usize) -> Control {
209209
}
210210

211211
#[inline]
212-
pub fn ret(state: &mut Machine) -> Control {
212+
pub fn ret<S>(state: &mut Machine<S>) -> Control {
213213
trace_op!("Return");
214214
pop_u256!(state, start, len);
215215
try_or_fail!(state.memory.resize_offset(start, len));
@@ -218,7 +218,7 @@ pub fn ret(state: &mut Machine) -> Control {
218218
}
219219

220220
#[inline]
221-
pub fn revert(state: &mut Machine) -> Control {
221+
pub fn revert<S>(state: &mut Machine<S>) -> Control {
222222
trace_op!("Revert");
223223
pop_u256!(state, start, len);
224224
try_or_fail!(state.memory.resize_offset(start, len));

0 commit comments

Comments
 (0)