From 6f69cdd109b1dd692b8dfb15e7c53d2051fbc946 Mon Sep 17 00:00:00 2001 From: Péter Szilágyi Date: Mon, 13 Nov 2017 13:47:27 +0200 Subject: all: switch gas limits from big.Int to uint64 --- core/vm/evm.go | 2 +- core/vm/gas_table.go | 6 ++---- core/vm/instructions.go | 2 +- core/vm/interface.go | 4 ++-- core/vm/noop.go | 4 ++-- core/vm/runtime/env.go | 4 +--- 6 files changed, 9 insertions(+), 13 deletions(-) (limited to 'core/vm') diff --git a/core/vm/evm.go b/core/vm/evm.go index a3f3a97cb..8796a633e 100644 --- a/core/vm/evm.go +++ b/core/vm/evm.go @@ -69,7 +69,7 @@ type Context struct { // Block information Coinbase common.Address // Provides information for COINBASE - GasLimit *big.Int // Provides information for GASLIMIT + GasLimit uint64 // Provides information for GASLIMIT BlockNumber *big.Int // Provides information for NUMBER Time *big.Int // Provides information for TIME Difficulty *big.Int // Provides information for DIFFICULTY diff --git a/core/vm/gas_table.go b/core/vm/gas_table.go index ff109af57..83adba428 100644 --- a/core/vm/gas_table.go +++ b/core/vm/gas_table.go @@ -17,8 +17,6 @@ package vm import ( - "math/big" - "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/common/math" "github.com/ethereum/go-ethereum/params" @@ -130,7 +128,7 @@ func gasSStore(gt params.GasTable, evm *EVM, contract *Contract, stack *Stack, m // 0 => non 0 return params.SstoreSetGas, nil } else if !common.EmptyHash(val) && common.EmptyHash(common.BigToHash(y)) { - evm.StateDB.AddRefund(new(big.Int).SetUint64(params.SstoreRefundGas)) + evm.StateDB.AddRefund(params.SstoreRefundGas) return params.SstoreClearGas, nil } else { @@ -405,7 +403,7 @@ func gasSuicide(gt params.GasTable, evm *EVM, contract *Contract, stack *Stack, } if !evm.StateDB.HasSuicided(contract.Address()) { - evm.StateDB.AddRefund(new(big.Int).SetUint64(params.SuicideRefundGas)) + evm.StateDB.AddRefund(params.SuicideRefundGas) } return gas, nil } diff --git a/core/vm/instructions.go b/core/vm/instructions.go index 1d1585fca..766172501 100644 --- a/core/vm/instructions.go +++ b/core/vm/instructions.go @@ -472,7 +472,7 @@ func opDifficulty(pc *uint64, evm *EVM, contract *Contract, memory *Memory, stac } func opGasLimit(pc *uint64, evm *EVM, contract *Contract, memory *Memory, stack *Stack) ([]byte, error) { - stack.push(math.U256(new(big.Int).Set(evm.GasLimit))) + stack.push(math.U256(new(big.Int).SetUint64(evm.GasLimit))) return nil, nil } diff --git a/core/vm/interface.go b/core/vm/interface.go index c0c52732b..1ef91cf1d 100644 --- a/core/vm/interface.go +++ b/core/vm/interface.go @@ -39,8 +39,8 @@ type StateDB interface { SetCode(common.Address, []byte) GetCodeSize(common.Address) int - AddRefund(*big.Int) - GetRefund() *big.Int + AddRefund(uint64) + GetRefund() uint64 GetState(common.Address, common.Hash) common.Hash SetState(common.Address, common.Hash, common.Hash) diff --git a/core/vm/noop.go b/core/vm/noop.go index 2a04a9565..b71ead0d7 100644 --- a/core/vm/noop.go +++ b/core/vm/noop.go @@ -55,8 +55,8 @@ func (NoopStateDB) GetCodeHash(common.Address) common.Hash func (NoopStateDB) GetCode(common.Address) []byte { return nil } func (NoopStateDB) SetCode(common.Address, []byte) {} func (NoopStateDB) GetCodeSize(common.Address) int { return 0 } -func (NoopStateDB) AddRefund(*big.Int) {} -func (NoopStateDB) GetRefund() *big.Int { return nil } +func (NoopStateDB) AddRefund(uint64) {} +func (NoopStateDB) GetRefund() uint64 { return 0 } func (NoopStateDB) GetState(common.Address, common.Hash) common.Hash { return common.Hash{} } func (NoopStateDB) SetState(common.Address, common.Hash, common.Hash) {} func (NoopStateDB) Suicide(common.Address) bool { return false } diff --git a/core/vm/runtime/env.go b/core/vm/runtime/env.go index 818da1be2..31c9b9cf9 100644 --- a/core/vm/runtime/env.go +++ b/core/vm/runtime/env.go @@ -17,8 +17,6 @@ package runtime import ( - "math/big" - "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/core" "github.com/ethereum/go-ethereum/core/vm" @@ -35,7 +33,7 @@ func NewEnv(cfg *Config) *vm.EVM { BlockNumber: cfg.BlockNumber, Time: cfg.Time, Difficulty: cfg.Difficulty, - GasLimit: new(big.Int).SetUint64(cfg.GasLimit), + GasLimit: cfg.GasLimit, GasPrice: cfg.GasPrice, } -- cgit