@@ -109,7 +109,7 @@ type statefulPrecompileOutput struct {
109109 ChainID * big.Int
110110 Addresses * libevm.AddressContext
111111 StateValue common.Hash
112- ValueReceived * uint256.Int
112+ CallValue * uint256.Int
113113 ReadOnly bool
114114 BlockNumber , Difficulty * big.Int
115115 BlockTime uint64
@@ -169,7 +169,7 @@ func TestNewStatefulPrecompile(t *testing.T) {
169169 ChainID : env .ChainConfig ().ChainID ,
170170 Addresses : env .Addresses (),
171171 StateValue : env .ReadOnlyState ().GetState (precompile , slot ),
172- ValueReceived : env .Value (),
172+ CallValue : env .Value (),
173173 ReadOnly : env .ReadOnly (),
174174 BlockNumber : env .BlockNumber (),
175175 BlockTime : env .BlockTime (),
@@ -197,12 +197,13 @@ func TestNewStatefulPrecompile(t *testing.T) {
197197 }
198198 input := rng .Bytes (8 )
199199 stateValue := rng .Hash ()
200- transferValue := rng .Uint256 ()
200+ callCallerValue := rng .Uint256 ()
201+ callPrecompileValue := rng .Uint256 ()
201202 chainID := rng .BigUint64 ()
202203
203204 caller := common .HexToAddress ("CA11E12" ) // caller of the precompile
204205 eoa := common .HexToAddress ("E0A" ) // caller of the precompile-caller
205- callerContract := vm .NewContract (vm .AccountRef (eoa ), vm .AccountRef (caller ), uint256 . NewInt ( 0 ) , 1e6 )
206+ callerContract := vm .NewContract (vm .AccountRef (eoa ), vm .AccountRef (caller ), callCallerValue , 1e6 )
206207
207208 state , evm := ethtest .NewZeroEVM (
208209 t ,
@@ -225,10 +226,10 @@ func TestNewStatefulPrecompile(t *testing.T) {
225226 }
226227
227228 tests := []struct {
228- name string
229- call func () ([]byte , uint64 , error )
230- wantAddresses * libevm.AddressContext
231- wantTransferValue * uint256.Int
229+ name string
230+ call func () ([]byte , uint64 , error )
231+ wantAddresses * libevm.AddressContext
232+ wantCallValue * uint256.Int
232233 // Note that this only covers evm.readOnly being true because of the
233234 // precompile's call. See TestInheritReadOnly for alternate case.
234235 wantReadOnly bool
@@ -237,21 +238,21 @@ func TestNewStatefulPrecompile(t *testing.T) {
237238 {
238239 name : "EVM.Call()" ,
239240 call : func () ([]byte , uint64 , error ) {
240- return evm .Call (callerContract , precompile , input , gasLimit , transferValue )
241+ return evm .Call (callerContract , precompile , input , gasLimit , callPrecompileValue )
241242 },
242243 wantAddresses : & libevm.AddressContext {
243244 Origin : eoa ,
244245 EVMSemantic : rawAddresses ,
245246 Raw : & rawAddresses ,
246247 },
247- wantReadOnly : false ,
248- wantTransferValue : transferValue ,
249- wantCallType : vm .Call ,
248+ wantReadOnly : false ,
249+ wantCallValue : callPrecompileValue ,
250+ wantCallType : vm .Call ,
250251 },
251252 {
252253 name : "EVM.CallCode()" ,
253254 call : func () ([]byte , uint64 , error ) {
254- return evm .CallCode (callerContract , precompile , input , gasLimit , transferValue )
255+ return evm .CallCode (callerContract , precompile , input , gasLimit , callPrecompileValue )
255256 },
256257 wantAddresses : & libevm.AddressContext {
257258 Origin : eoa ,
@@ -261,9 +262,9 @@ func TestNewStatefulPrecompile(t *testing.T) {
261262 },
262263 Raw : & rawAddresses ,
263264 },
264- wantReadOnly : false ,
265- wantTransferValue : transferValue ,
266- wantCallType : vm .CallCode ,
265+ wantReadOnly : false ,
266+ wantCallValue : callPrecompileValue ,
267+ wantCallType : vm .CallCode ,
267268 },
268269 {
269270 name : "EVM.DelegateCall()" ,
@@ -278,9 +279,9 @@ func TestNewStatefulPrecompile(t *testing.T) {
278279 },
279280 Raw : & rawAddresses ,
280281 },
281- wantReadOnly : false ,
282- wantTransferValue : uint256 . NewInt ( 0 ),
283- wantCallType : vm .DelegateCall ,
282+ wantReadOnly : false ,
283+ wantCallValue : callCallerValue , // Important difference from [vm.EVM.Call]
284+ wantCallType : vm .DelegateCall ,
284285 },
285286 {
286287 name : "EVM.StaticCall()" ,
@@ -292,9 +293,9 @@ func TestNewStatefulPrecompile(t *testing.T) {
292293 EVMSemantic : rawAddresses ,
293294 Raw : & rawAddresses ,
294295 },
295- wantReadOnly : true ,
296- wantTransferValue : uint256 .NewInt (0 ),
297- wantCallType : vm .StaticCall ,
296+ wantReadOnly : true ,
297+ wantCallValue : uint256 .NewInt (0 ),
298+ wantCallType : vm .StaticCall ,
298299 },
299300 }
300301
@@ -304,7 +305,7 @@ func TestNewStatefulPrecompile(t *testing.T) {
304305 ChainID : chainID ,
305306 Addresses : tt .wantAddresses ,
306307 StateValue : stateValue ,
307- ValueReceived : tt .wantTransferValue ,
308+ CallValue : tt .wantCallValue ,
308309 ReadOnly : tt .wantReadOnly ,
309310 BlockNumber : header .Number ,
310311 BlockTime : header .Time ,
0 commit comments