@@ -146,13 +146,16 @@ func TestNewStatefulPrecompile(t *testing.T) {
146146 const gasLimit = 1e6
147147 gasCost := rng .Uint64n (gasLimit )
148148
149- run := func (env vm.PrecompileEnvironment , input []byte , suppliedGas uint64 ) ([]byte , uint64 , error ) {
149+ run := func (env vm.PrecompileEnvironment , input []byte ) ([]byte , error ) {
150150 if got , want := env .StateDB () != nil , ! env .ReadOnly (); got != want {
151- return nil , 0 , fmt .Errorf ("PrecompileEnvironment().StateDB() must be non-nil i.f.f. not read-only; got non-nil? %t; want %t" , got , want )
151+ return nil , fmt .Errorf ("PrecompileEnvironment().StateDB() must be non-nil i.f.f. not read-only; got non-nil? %t; want %t" , got , want )
152152 }
153153 hdr , err := env .BlockHeader ()
154154 if err != nil {
155- return nil , 0 , err
155+ return nil , err
156+ }
157+ if ! env .UseGas (gasCost ) {
158+ return nil , vm .ErrOutOfGas
156159 }
157160
158161 out := & statefulPrecompileOutput {
@@ -166,7 +169,7 @@ func TestNewStatefulPrecompile(t *testing.T) {
166169 Input : input ,
167170 IncomingCallType : env .IncomingCallType (),
168171 }
169- return out .Bytes (), suppliedGas - gasCost , nil
172+ return out .Bytes (), nil
170173 }
171174 hooks := & hookstest.Stub {
172175 PrecompileOverrides : map [common.Address ]libevm.PrecompiledContract {
@@ -318,11 +321,11 @@ func TestInheritReadOnly(t *testing.T) {
318321 hooks := & hookstest.Stub {
319322 PrecompileOverrides : map [common.Address ]libevm.PrecompiledContract {
320323 precompile : vm .NewStatefulPrecompile (
321- func (env vm.PrecompileEnvironment , input []byte , suppliedGas uint64 ) ([]byte , uint64 , error ) {
324+ func (env vm.PrecompileEnvironment , input []byte ) ([]byte , error ) {
322325 if env .ReadOnly () {
323- return []byte {ifReadOnly }, suppliedGas , nil
326+ return []byte {ifReadOnly }, nil
324327 }
325- return []byte {ifNotReadOnly }, suppliedGas , nil
328+ return []byte {ifNotReadOnly }, nil
326329 },
327330 ),
328331 },
@@ -535,21 +538,21 @@ func TestPrecompileMakeCall(t *testing.T) {
535538
536539 hooks := & hookstest.Stub {
537540 PrecompileOverrides : map [common.Address ]libevm.PrecompiledContract {
538- sut : vm .NewStatefulPrecompile (func (env vm.PrecompileEnvironment , input []byte , suppliedGas uint64 ) (ret []byte , remainingGas uint64 , err error ) {
541+ sut : vm .NewStatefulPrecompile (func (env vm.PrecompileEnvironment , input []byte ) (ret []byte , err error ) {
539542 var opts []vm.CallOption
540543 if bytes .Equal (input , unsafeCallerProxyOptSentinel ) {
541544 opts = append (opts , vm .WithUNSAFECallerAddressProxying ())
542545 }
543546 // We are ultimately testing env.Call(), hence why this is the SUT.
544- return env .Call (dest , precompileCallData , suppliedGas , uint256 .NewInt (0 ), opts ... )
547+ return env .Call (dest , precompileCallData , env . Gas () , uint256 .NewInt (0 ), opts ... )
545548 }),
546- dest : vm .NewStatefulPrecompile (func (env vm.PrecompileEnvironment , input []byte , suppliedGas uint64 ) (ret []byte , remainingGas uint64 , err error ) {
549+ dest : vm .NewStatefulPrecompile (func (env vm.PrecompileEnvironment , input []byte ) (ret []byte , err error ) {
547550 out := & statefulPrecompileOutput {
548551 Addresses : env .Addresses (),
549552 ReadOnly : env .ReadOnly (),
550553 Input : input , // expected to be callData
551554 }
552- return out .Bytes (), suppliedGas , nil
555+ return out .Bytes (), nil
553556 }),
554557 },
555558 }
@@ -696,8 +699,8 @@ func TestPrecompileCallWithTracer(t *testing.T) {
696699
697700 hooks := & hookstest.Stub {
698701 PrecompileOverrides : map [common.Address ]libevm.PrecompiledContract {
699- precompile : vm .NewStatefulPrecompile (func (env vm.PrecompileEnvironment , input []byte , suppliedGas uint64 ) (ret []byte , remainingGas uint64 , err error ) {
700- return env .Call (contract , nil , suppliedGas , uint256 .NewInt (0 ))
702+ precompile : vm .NewStatefulPrecompile (func (env vm.PrecompileEnvironment , input []byte ) (ret []byte , err error ) {
703+ return env .Call (contract , nil , env . Gas () , uint256 .NewInt (0 ))
701704 }),
702705 },
703706 }
0 commit comments