@@ -72,14 +72,19 @@ impl SystemCallTx for TxEnv {
72
72
/// beneficiary. They are used before and after block execution to insert or obtain blockchain state.
73
73
///
74
74
/// 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.
75
80
pub trait SystemCallEvm : ExecuteEvm {
76
81
/// System call is a special transaction call that is used to call a system contract.
77
82
///
78
83
/// Transaction fields are reset and set in [`SystemCallTx`] and data and target are set to
79
84
/// given values.
80
85
///
81
86
/// 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 (
83
88
& mut self ,
84
89
caller : Address ,
85
90
system_contract_address : Address ,
@@ -92,62 +97,71 @@ pub trait SystemCallEvm: ExecuteEvm {
92
97
/// given values.
93
98
///
94
99
/// 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 (
97
101
& mut self ,
98
- caller : Address ,
99
102
system_contract_address : Address ,
100
103
data : Bytes ,
101
104
) -> 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)
103
106
}
104
107
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 (
111
110
& mut self ,
112
111
system_contract_address : Address ,
113
112
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)
116
115
}
117
116
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 (
122
119
& mut self ,
120
+ caller : Address ,
123
121
system_contract_address : Address ,
124
122
data : Bytes ,
125
123
) -> 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) )
127
127
}
128
128
129
- /// Transact the system call and finalize .
129
+ /// System call is a special transaction call that is used to call a system contract .
130
130
///
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 (
134
137
& mut self ,
138
+ caller : Address ,
135
139
system_contract_address : Address ,
136
140
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)
139
143
}
140
144
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 (
143
160
& mut self ,
144
- caller : Address ,
145
161
system_contract_address : Address ,
146
162
data : Bytes ,
147
163
) -> 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)
151
165
}
152
166
153
167
/// Calls [`SystemCallEvm::system_call_one`] and `finalize` functions.
@@ -210,7 +224,7 @@ where
210
224
INST : InstructionProvider < Context = CTX , InterpreterTypes = EthInterpreter > ,
211
225
PRECOMPILES : PrecompileProvider < CTX , Output = InterpreterResult > ,
212
226
{
213
- fn system_call_one (
227
+ fn system_call_one_with_caller (
214
228
& mut self ,
215
229
caller : Address ,
216
230
system_contract_address : Address ,
0 commit comments