diff options
author | Péter Szilágyi <peterke@gmail.com> | 2017-02-13 23:13:40 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-02-13 23:13:40 +0800 |
commit | 0850f68fd17586370b102aa516739476db4913c2 (patch) | |
tree | 5d2f140139f3763a7da3c20a88acff96b58ec8ad /core/vm/runtime | |
parent | f8f428cc18c5f70814d7b3937128781bac14bffd (diff) | |
parent | 57f4e9025757254536a738bb4771712038f1e763 (diff) | |
download | dexon-0850f68fd17586370b102aa516739476db4913c2.tar dexon-0850f68fd17586370b102aa516739476db4913c2.tar.gz dexon-0850f68fd17586370b102aa516739476db4913c2.tar.bz2 dexon-0850f68fd17586370b102aa516739476db4913c2.tar.lz dexon-0850f68fd17586370b102aa516739476db4913c2.tar.xz dexon-0850f68fd17586370b102aa516739476db4913c2.tar.zst dexon-0850f68fd17586370b102aa516739476db4913c2.zip |
Merge pull request #3668 from obscuren/revert-gas64
Revert "params: core, core/vm, miner: 64bit gas instructions (#3514)"
Diffstat (limited to 'core/vm/runtime')
-rw-r--r-- | core/vm/runtime/env.go | 2 | ||||
-rw-r--r-- | core/vm/runtime/runtime.go | 14 | ||||
-rw-r--r-- | core/vm/runtime/runtime_test.go | 4 |
3 files changed, 9 insertions, 11 deletions
diff --git a/core/vm/runtime/env.go b/core/vm/runtime/env.go index 9aa88e669..a25c6d71c 100644 --- a/core/vm/runtime/env.go +++ b/core/vm/runtime/env.go @@ -36,7 +36,7 @@ func NewEnv(cfg *Config, state *state.StateDB) *vm.EVM { BlockNumber: cfg.BlockNumber, Time: cfg.Time, Difficulty: cfg.Difficulty, - GasLimit: new(big.Int).SetUint64(cfg.GasLimit), + GasLimit: cfg.GasLimit, GasPrice: new(big.Int), } diff --git a/core/vm/runtime/runtime.go b/core/vm/runtime/runtime.go index cf46603db..b5adb982c 100644 --- a/core/vm/runtime/runtime.go +++ b/core/vm/runtime/runtime.go @@ -17,7 +17,6 @@ package runtime import ( - "math" "math/big" "time" @@ -38,7 +37,7 @@ type Config struct { Coinbase common.Address BlockNumber *big.Int Time *big.Int - GasLimit uint64 + GasLimit *big.Int GasPrice *big.Int Value *big.Int DisableJit bool // "disable" so it's enabled by default @@ -69,8 +68,8 @@ func setDefaults(cfg *Config) { if cfg.Time == nil { cfg.Time = big.NewInt(time.Now().Unix()) } - if cfg.GasLimit == 0 { - cfg.GasLimit = math.MaxUint64 + if cfg.GasLimit == nil { + cfg.GasLimit = new(big.Int).Set(common.MaxBig) } if cfg.GasPrice == nil { cfg.GasPrice = new(big.Int) @@ -113,7 +112,7 @@ func Execute(code, input []byte, cfg *Config) ([]byte, *state.StateDB, error) { receiver.SetCode(crypto.Keccak256Hash(code), code) // Call the code with the given configuration. - ret, _, err := vmenv.Call( + ret, err := vmenv.Call( sender, receiver.Address(), input, @@ -141,13 +140,12 @@ func Create(input []byte, cfg *Config) ([]byte, common.Address, error) { ) // Call the code with the given configuration. - code, address, _, err := vmenv.Create( + return vmenv.Create( sender, input, cfg.GasLimit, cfg.Value, ) - return code, address, err } // Call executes the code given by the contract's address. It will return the @@ -162,7 +160,7 @@ func Call(address common.Address, input []byte, cfg *Config) ([]byte, error) { sender := cfg.State.GetOrNewStateObject(cfg.Origin) // Call the code with the given configuration. - ret, _, err := vmenv.Call( + ret, err := vmenv.Call( sender, address, input, diff --git a/core/vm/runtime/runtime_test.go b/core/vm/runtime/runtime_test.go index 8ad74a89a..1e618b688 100644 --- a/core/vm/runtime/runtime_test.go +++ b/core/vm/runtime/runtime_test.go @@ -39,8 +39,8 @@ func TestDefaults(t *testing.T) { if cfg.Time == nil { t.Error("expected time to be non nil") } - if cfg.GasLimit == 0 { - t.Error("didn't expect gaslimit to be zero") + if cfg.GasLimit == nil { + t.Error("expected time to be non nil") } if cfg.GasPrice == nil { t.Error("expected time to be non nil") |