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 -1
View File
@@ -71,7 +71,7 @@ type BlockContext struct {
Coinbase common.Address // Provides information for COINBASE
GasLimit uint64 // Provides information for GASLIMIT
BlockNumber *big.Int // Provides information for NUMBER
Time *big.Int // Provides information for TIME
Time uint64 // Provides information for TIME
Difficulty *big.Int // Provides information for DIFFICULTY
BaseFee *big.Int // Provides information for BASEFEE
Random *common.Hash // Provides information for PREVRANDAO
+1 -2
View File
@@ -460,8 +460,7 @@ func opCoinbase(pc *uint64, interpreter *EVMInterpreter, scope *ScopeContext) ([
}
func opTimestamp(pc *uint64, interpreter *EVMInterpreter, scope *ScopeContext) ([]byte, error) {
v, _ := uint256.FromBig(interpreter.evm.Context.Time)
scope.Stack.push(v)
scope.Stack.push(new(uint256.Int).SetUint64(interpreter.evm.Context.Time))
return nil, nil
}
+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{