Skip to content

Commit dbdb945

Browse files
committed
feat: fix renamed functions for system_call
1 parent df46793 commit dbdb945

File tree

5 files changed

+87
-33
lines changed

5 files changed

+87
-33
lines changed

MIGRATION_GUIDE.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
# v83 tag (revm v28.0.0) from v82 tag (revm v27.1.0)
2+
3+
* `SystemCallEvm` functions got renamed and old ones are deprecated. Renaming is done to align it with other API calls.
4+
* `transact_system_call_finalize` is now `system_call`.
5+
* `transact_system_call` is now `system_call_one`.
6+
17
# v82 tag (revm v27.1.0) from v81 tag (revm v27.0.3)
28

39
* `ContextTr` gained `Host` supertrait.

crates/ee-tests/src/op_revm_tests.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1134,7 +1134,7 @@ fn test_system_call() {
11341134

11351135
let mut evm = ctx.build_op();
11361136

1137-
let _ = evm.system_call_one(SYSTEM_ADDRESS, BENCH_TARGET, bytes!("0x0001"));
1137+
let _ = evm.system_call_one(BENCH_TARGET, bytes!("0x0001"));
11381138
let state = evm.finalize();
11391139

11401140
assert!(state.get(&SYSTEM_ADDRESS).is_none());

crates/handler/src/system_call.rs

Lines changed: 45 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -72,14 +72,19 @@ impl SystemCallTx for TxEnv {
7272
/// beneficiary. They are used before and after block execution to insert or obtain blockchain state.
7373
///
7474
/// It act similar to `transact` function and sets default Tx with data and system contract as a target.
75+
///
76+
/// # Note
77+
///
78+
/// Only one function needs implementation [`SystemCallEvm::system_call_one_with_caller`], other functions
79+
/// are derived from it.
7580
pub trait SystemCallEvm: ExecuteEvm {
7681
/// System call is a special transaction call that is used to call a system contract.
7782
///
7883
/// Transaction fields are reset and set in [`SystemCallTx`] and data and target are set to
7984
/// given values.
8085
///
8186
/// Block values are taken into account and will determent how system call will be executed.
82-
fn system_call_one(
87+
fn system_call_one_with_caller(
8388
&mut self,
8489
caller: Address,
8590
system_contract_address: Address,
@@ -92,62 +97,71 @@ pub trait SystemCallEvm: ExecuteEvm {
9297
/// given values.
9398
///
9499
/// Block values are taken into account and will determent how system call will be executed.
95-
#[deprecated(since = "0.1.0", note = "Use `system_call_one` instead")]
96-
fn transact_system_call_with_caller(
100+
fn system_call_one(
97101
&mut self,
98-
caller: Address,
99102
system_contract_address: Address,
100103
data: Bytes,
101104
) -> Result<Self::ExecutionResult, Self::Error> {
102-
self.system_call_one(caller, system_contract_address, data)
105+
self.system_call_one_with_caller(SYSTEM_ADDRESS, system_contract_address, data)
103106
}
104107

105-
/// Calls [`SystemCallEvm::system_call_one`] with [`SYSTEM_ADDRESS`] as a caller.
106-
#[deprecated(
107-
since = "0.1.0",
108-
note = "Use `system_call_one` with SYSTEM_ADDRESS instead"
109-
)]
110-
fn transact_system_call(
108+
/// Internally calls [`SystemCallEvm::system_call_with_caller`].
109+
fn system_call(
111110
&mut self,
112111
system_contract_address: Address,
113112
data: Bytes,
114-
) -> Result<Self::ExecutionResult, Self::Error> {
115-
self.system_call_one(SYSTEM_ADDRESS, system_contract_address, data)
113+
) -> Result<ExecResultAndState<Self::ExecutionResult, Self::State>, Self::Error> {
114+
self.system_call_with_caller(SYSTEM_ADDRESS, system_contract_address, data)
116115
}
117116

118-
/// Transact the system call and finalize.
119-
///
120-
/// Internally calls combo of `system_call_one` and `finalize` functions.
121-
fn system_call(
117+
/// Internally calls [`SystemCallEvm::system_call_one`] and [`ExecuteEvm::finalize`] functions to obtain the changed state.
118+
fn system_call_with_caller(
122119
&mut self,
120+
caller: Address,
123121
system_contract_address: Address,
124122
data: Bytes,
125123
) -> Result<ExecResultAndState<Self::ExecutionResult, Self::State>, Self::Error> {
126-
self.system_call_with_caller(SYSTEM_ADDRESS, system_contract_address, data)
124+
let result = self.system_call_one_with_caller(caller, system_contract_address, data)?;
125+
let state = self.finalize();
126+
Ok(ExecResultAndState::new(result, state))
127127
}
128128

129-
/// Transact the system call and finalize.
129+
/// System call is a special transaction call that is used to call a system contract.
130130
///
131-
/// Internally calls combo of `transact_system_call` and `finalize` functions.
132-
#[deprecated(since = "0.1.0", note = "Use `system_call` instead")]
133-
fn transact_system_call_finalize(
131+
/// Transaction fields are reset and set in [`SystemCallTx`] and data and target are set to
132+
/// given values.
133+
///
134+
/// Block values are taken into account and will determent how system call will be executed.
135+
#[deprecated(since = "0.1.0", note = "Use `system_call_one_with_caller` instead")]
136+
fn transact_system_call_with_caller(
134137
&mut self,
138+
caller: Address,
135139
system_contract_address: Address,
136140
data: Bytes,
137-
) -> Result<ExecResultAndState<Self::ExecutionResult, Self::State>, Self::Error> {
138-
self.system_call(system_contract_address, data)
141+
) -> Result<Self::ExecutionResult, Self::Error> {
142+
self.system_call_one_with_caller(caller, system_contract_address, data)
139143
}
140144

141-
/// Calls [`SystemCallEvm::system_call_one`] and `finalize` functions.
142-
fn system_call_with_caller(
145+
/// Calls [`SystemCallEvm::system_call_one`] with [`SYSTEM_ADDRESS`] as a caller.
146+
#[deprecated(since = "0.1.0", note = "Use `system_call_one` instead")]
147+
fn transact_system_call(
148+
&mut self,
149+
system_contract_address: Address,
150+
data: Bytes,
151+
) -> Result<Self::ExecutionResult, Self::Error> {
152+
self.system_call_one(system_contract_address, data)
153+
}
154+
155+
/// Transact the system call and finalize.
156+
///
157+
/// Internally calls combo of `transact_system_call` and `finalize` functions.
158+
#[deprecated(since = "0.1.0", note = "Use `system_call` instead")]
159+
fn transact_system_call_finalize(
143160
&mut self,
144-
caller: Address,
145161
system_contract_address: Address,
146162
data: Bytes,
147163
) -> Result<ExecResultAndState<Self::ExecutionResult, Self::State>, Self::Error> {
148-
let result = self.system_call_one(caller, system_contract_address, data)?;
149-
let state = self.finalize();
150-
Ok(ExecResultAndState::new(result, state))
164+
self.system_call(system_contract_address, data)
151165
}
152166

153167
/// Calls [`SystemCallEvm::system_call_one`] and `finalize` functions.
@@ -210,7 +224,7 @@ where
210224
INST: InstructionProvider<Context = CTX, InterpreterTypes = EthInterpreter>,
211225
PRECOMPILES: PrecompileProvider<CTX, Output = InterpreterResult>,
212226
{
213-
fn system_call_one(
227+
fn system_call_one_with_caller(
214228
&mut self,
215229
caller: Address,
216230
system_contract_address: Address,

crates/inspector/src/inspect.rs

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,4 +161,38 @@ pub trait InspectSystemCallEvm: InspectEvm + SystemCallEvm {
161161
let state = self.finalize();
162162
Ok(ExecResultAndState::new(output, state))
163163
}
164+
165+
/// Inspect a system call with a given inspector and caller.
166+
///
167+
/// Similar to [`InspectEvm::inspect_one`] but for system calls.
168+
fn inspect_one_system_call_with_inspector_and_caller(
169+
&mut self,
170+
caller: Address,
171+
system_contract_address: Address,
172+
data: Bytes,
173+
inspector: Self::Inspector,
174+
) -> Result<Self::ExecutionResult, Self::Error> {
175+
self.set_inspector(inspector);
176+
self.inspect_one_system_call_with_caller(caller, system_contract_address, data)
177+
}
178+
179+
/// Inspect a system call with a given inspector and finalize the state.
180+
///
181+
/// Similar to [`InspectEvm::inspect`] but for system calls.
182+
fn inspect_system_call_with_inspector_and_caller(
183+
&mut self,
184+
caller: Address,
185+
system_contract_address: Address,
186+
data: Bytes,
187+
inspector: Self::Inspector,
188+
) -> Result<ExecResultAndState<Self::ExecutionResult, Self::State>, Self::Error> {
189+
let output = self.inspect_one_system_call_with_inspector_and_caller(
190+
caller,
191+
system_contract_address,
192+
data,
193+
inspector,
194+
)?;
195+
let state = self.finalize();
196+
Ok(ExecResultAndState::new(output, state))
197+
}
164198
}

crates/op-revm/src/api/exec.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ where
129129
CTX: OpContextTr<Tx: SystemCallTx> + ContextSetters,
130130
PRECOMPILE: PrecompileProvider<CTX, Output = InterpreterResult>,
131131
{
132-
fn system_call_one(
132+
fn system_call_one_with_caller(
133133
&mut self,
134134
caller: Address,
135135
system_contract_address: Address,

0 commit comments

Comments
 (0)