Skip to content
This repository was archived by the owner on Nov 25, 2025. It is now read-only.

Commit 6f05cd5

Browse files
committed
AccessibleState returns remaining gas
1 parent 94d7e25 commit 6f05cd5

File tree

3 files changed

+5
-4
lines changed

3 files changed

+5
-4
lines changed

nativeasset/contract.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ func (c *NativeAssetCall) Run(accessibleState contract.AccessibleState, caller c
141141
stateDB.SubBalanceMultiCoin(caller, assetID, assetAmount)
142142
stateDB.AddBalanceMultiCoin(to, assetID, assetAmount)
143143

144-
ret, err = accessibleState.Call(to, callData, remainingGas, new(uint256.Int), vm.WithUNSAFECallerAddressProxying())
144+
ret, remainingGas, err = accessibleState.Call(to, callData, remainingGas, new(uint256.Int), vm.WithUNSAFECallerAddressProxying())
145145

146146
// When an error was returned by the EVM or when setting the creation code
147147
// above we revert to the snapshot and consume any gas remaining. Additionally

params/hooks_libevm.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -172,8 +172,9 @@ func (a accessableState) GetSnowContext() *snow.Context {
172172
return GetExtra(a.env.ChainConfig()).SnowCtx
173173
}
174174

175-
func (a accessableState) Call(addr common.Address, input []byte, gas uint64, value *uint256.Int, opts ...vm.CallOption) (ret []byte, err error) {
176-
return a.env.Call(addr, input, gas, value, opts...)
175+
func (a accessableState) Call(addr common.Address, input []byte, gas uint64, value *uint256.Int, opts ...vm.CallOption) (ret []byte, gasRemaining uint64, err error) {
176+
ret, err = a.env.Call(addr, input, gas, value, opts...)
177+
return ret, a.env.Gas(), err
177178
}
178179

179180
type precompileBlockContext struct {

precompile/contract/interfaces.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ type AccessibleState interface {
6161
GetBlockContext() BlockContext
6262
GetSnowContext() *snow.Context
6363
GetChainConfig() precompileconfig.ChainConfig
64-
Call(addr common.Address, input []byte, gas uint64, value *uint256.Int, opts ...vm.CallOption) (ret []byte, _ error)
64+
Call(addr common.Address, input []byte, gas uint64, value *uint256.Int, opts ...vm.CallOption) (ret []byte, gasRemaining uint64, _ error)
6565
}
6666

6767
// ConfigurationBlockContext defines the interface required to configure a precompile.

0 commit comments

Comments
 (0)