Skip to content

Commit bef5e89

Browse files
committed
fix(core/vm): defensive treatment of ErrOutOfGas in stateful precompiles
1 parent d210cc4 commit bef5e89

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

core/vm/contracts.libevm.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
package vm
1818

1919
import (
20+
"errors"
2021
"fmt"
2122
"math/big"
2223

@@ -97,7 +98,11 @@ func (args *evmCallArgs) run(p PrecompiledContract, input []byte) (ret []byte, e
9798
case statefulPrecompile:
9899
env := args.env()
99100
ret, err := p(env, input)
100-
args.gasRemaining = env.Gas()
101+
if errors.Is(err, ErrOutOfGas) {
102+
args.gasRemaining = 0
103+
} else {
104+
args.gasRemaining = env.Gas()
105+
}
101106
return ret, err
102107
}
103108
}

0 commit comments

Comments
 (0)