aboutsummaryrefslogtreecommitdiffstats
path: root/core/vm
diff options
context:
space:
mode:
authorPéter Szilágyi <peterke@gmail.com>2017-11-13 19:47:27 +0800
committerPéter Szilágyi <peterke@gmail.com>2018-01-03 20:45:35 +0800
commit6f69cdd109b1dd692b8dfb15e7c53d2051fbc946 (patch)
treec92974f8b82209073ad1ee3faec6e149f834bf69 /core/vm
parentb8caba97099ee5eed33c3b80dd4ea540722e7d8f (diff)
downloaddexon-6f69cdd109b1dd692b8dfb15e7c53d2051fbc946.tar
dexon-6f69cdd109b1dd692b8dfb15e7c53d2051fbc946.tar.gz
dexon-6f69cdd109b1dd692b8dfb15e7c53d2051fbc946.tar.bz2
dexon-6f69cdd109b1dd692b8dfb15e7c53d2051fbc946.tar.lz
dexon-6f69cdd109b1dd692b8dfb15e7c53d2051fbc946.tar.xz
dexon-6f69cdd109b1dd692b8dfb15e7c53d2051fbc946.tar.zst
dexon-6f69cdd109b1dd692b8dfb15e7c53d2051fbc946.zip
all: switch gas limits from big.Int to uint64
Diffstat (limited to 'core/vm')
-rw-r--r--core/vm/evm.go2
-rw-r--r--core/vm/gas_table.go6
-rw-r--r--core/vm/instructions.go2
-rw-r--r--core/vm/interface.go4
-rw-r--r--core/vm/noop.go4
-rw-r--r--core/vm/runtime/env.go4
6 files changed, 9 insertions, 13 deletions
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,
}