all: make timestamp-based fork checks based on uint64 (#26474)

This PR changes the API so that uint64 is used for fork timestamps.
It's a good choice because types.Header also uses uint64 for time.

Co-authored-by: Felix Lange <fjl@twurst.com>
This commit is contained in:
Martin Holst Swende
2023-01-25 12:12:28 +01:00
committed by GitHub
co-authored by Felix Lange
parent 59a48e0289
commit 2b57a27d9e
27 changed files with 100 additions and 82 deletions
+1 -5
View File
@@ -19,7 +19,6 @@ package runtime
import (
"math"
"math/big"
"time"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/core/rawdb"
@@ -37,7 +36,7 @@ type Config struct {
Origin common.Address
Coinbase common.Address
BlockNumber *big.Int
Time *big.Int
Time uint64
GasLimit uint64
GasPrice *big.Int
Value *big.Int
@@ -74,9 +73,6 @@ func setDefaults(cfg *Config) {
if cfg.Difficulty == nil {
cfg.Difficulty = new(big.Int)
}
if cfg.Time == nil {
cfg.Time = big.NewInt(time.Now().Unix())
}
if cfg.GasLimit == 0 {
cfg.GasLimit = math.MaxUint64
}
+1 -4
View File
@@ -48,9 +48,6 @@ func TestDefaults(t *testing.T) {
t.Error("expected difficulty to be non nil")
}
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")
}
@@ -174,7 +171,7 @@ func benchmarkEVM_Create(bench *testing.B, code string) {
State: statedb,
GasLimit: 10000000,
Difficulty: big.NewInt(0x200000),
Time: new(big.Int).SetUint64(0),
Time: 0,
Coinbase: common.Address{},
BlockNumber: new(big.Int).SetUint64(1),
ChainConfig: &params.ChainConfig{