Skip to content

Commit b43da37

Browse files
all: rebase on uint64 timestamps
1 parent 3481ebc commit b43da37

File tree

9 files changed

+13
-10
lines changed

9 files changed

+13
-10
lines changed

cmd/evm/internal/t8ntool/transition.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -262,7 +262,7 @@ func Transition(ctx *cli.Context) error {
262262
return NewError(ErrorConfig, errors.New("EIP-1559 config but missing 'currentBaseFee' in env section"))
263263
}
264264
}
265-
if chainConfig.IsShanghai(big.NewInt(int64(prestate.Env.Number))) && prestate.Env.Withdrawals == nil {
265+
if chainConfig.IsShanghai(prestate.Env.Number) && prestate.Env.Withdrawals == nil {
266266
return NewError(ErrorConfig, errors.New("Shanghai config but missing 'withdrawals' in env section"))
267267
}
268268
isMerged := chainConfig.TerminalTotalDifficulty != nil && chainConfig.TerminalTotalDifficulty.BitLen() == 0

consensus/beacon/consensus.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -261,7 +261,7 @@ func (beacon *Beacon) verifyHeader(chain consensus.ChainHeaderReader, header, pa
261261
return err
262262
}
263263
// Verify existence / non-existence of withdrawalsHash.
264-
shanghai := chain.Config().IsShanghai(new(big.Int).SetUint64(header.Time))
264+
shanghai := chain.Config().IsShanghai(header.Time)
265265
if shanghai && header.WithdrawalsHash == nil {
266266
return fmt.Errorf("missing withdrawalsHash")
267267
}
@@ -335,7 +335,7 @@ func (beacon *Beacon) Finalize(chain consensus.ChainHeaderReader, header *types.
335335
return
336336
}
337337
// If withdrawals have been activated, process each one.
338-
if chain.Config().IsShanghai(new(big.Int).SetUint64(header.Time)) {
338+
if chain.Config().IsShanghai(header.Time) {
339339
for _, w := range withdrawals {
340340
// Amount is in gwei, turn into wei
341341
amount := new(big.Int).Mul(new(big.Int).SetUint64(w.Amount), big.NewInt(params.GWei))

consensus/clique/clique.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -298,7 +298,7 @@ func (c *Clique) verifyHeader(chain consensus.ChainHeaderReader, header *types.H
298298
if header.GasLimit > params.MaxGasLimit {
299299
return fmt.Errorf("invalid gasLimit: have %v, max %v", header.GasLimit, params.MaxGasLimit)
300300
}
301-
if chain.Config().IsShanghai(new(big.Int).SetUint64(header.Time)) {
301+
if chain.Config().IsShanghai(header.Time) {
302302
return fmt.Errorf("clique does not support shanghai fork")
303303
}
304304
// If all checks passed, validate any special fields for hard forks

consensus/ethash/consensus.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -310,7 +310,7 @@ func (ethash *Ethash) verifyHeader(chain consensus.ChainHeaderReader, header, pa
310310
if diff := new(big.Int).Sub(header.Number, parent.Number); diff.Cmp(big.NewInt(1)) != 0 {
311311
return consensus.ErrInvalidNumber
312312
}
313-
if chain.Config().IsShanghai(new(big.Int).SetUint64(header.Time)) {
313+
if chain.Config().IsShanghai(header.Time) {
314314
return fmt.Errorf("ethash does not support shanghai fork")
315315
}
316316
// Verify the engine specific seal securing the block

core/chain_makers.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -303,7 +303,7 @@ func GenerateChain(config *params.ChainConfig, parent *types.Block, engine conse
303303
}
304304
if b.engine != nil {
305305
// Finalize and seal the block
306-
shanghai := config.IsShanghai(new(big.Int).SetUint64(b.header.Time))
306+
shanghai := config.IsShanghai(b.header.Time)
307307
if shanghai && b.withdrawals == nil {
308308
// need to make empty list to denote non-nil, but empty withdrawals to calc withdrawals hash
309309
b.withdrawals = make([]*types.Withdrawal, 0)

core/genesis.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -469,7 +469,7 @@ func (g *Genesis) ToBlock() *types.Block {
469469
head.BaseFee = new(big.Int).SetUint64(params.InitialBaseFee)
470470
}
471471
}
472-
if g.Config != nil && g.Config.IsShanghai(big.NewInt(int64(g.Timestamp))) {
472+
if g.Config != nil && g.Config.IsShanghai(g.Timestamp) {
473473
head.WithdrawalsHash = &types.EmptyRootHash
474474
}
475475
return types.NewBlock(head, nil, nil, nil, trie.NewStackTrie(nil))

core/state_processor.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ func (p *StateProcessor) Process(block *types.Block, statedb *state.StateDB, cfg
8787
allLogs = append(allLogs, receipt.Logs...)
8888
}
8989
// Fail if Shanghai not enabled and len(withdrawals) is non-zero.
90-
if !p.config.IsShanghai(new(big.Int).SetUint64(block.Time())) && block.Withdrawals() != nil {
90+
if !p.config.IsShanghai(block.Time()) && block.Withdrawals() != nil {
9191
return nil, nil, 0, fmt.Errorf("non-nil withdrawal before shanghai")
9292
}
9393
// Finalize the block, applying any consensus engine specific extras (e.g. block rewards)

eth/catalyst/api_test.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1005,7 +1005,8 @@ func TestSimultaneousNewBlock(t *testing.T) {
10051005
func TestWithdrawals(t *testing.T) {
10061006
genesis, blocks := generateMergeChain(10, true)
10071007
// Set shanghai time to last block + 5 seconds (first post-merge block)
1008-
genesis.Config.ShanghaiTime = big.NewInt(int64(blocks[len(blocks)-1].Time()) + 5)
1008+
time := blocks[len(blocks)-1].Time() + 5
1009+
genesis.Config.ShanghaiTime = &time
10091010

10101011
n, ethservice := startEthService(t, genesis, blocks)
10111012
ethservice.Merger().ReachTTD()

eth/protocols/eth/handler_test.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,8 @@ var (
4747
testAddr = crypto.PubkeyToAddress(testKey.PublicKey)
4848
)
4949

50+
func u64(val uint64) *uint64 { return &val }
51+
5052
// testBackend is a mock implementation of the live Ethereum message handler. Its
5153
// purpose is to allow testing the request/reply workflows and wire serialization
5254
// in the `eth` protocol without actually doing any data processing.
@@ -90,7 +92,7 @@ func newTestBackendWithGenerator(blocks int, shanghai bool, generator func(int,
9092
ArrowGlacierBlock: big.NewInt(0),
9193
GrayGlacierBlock: big.NewInt(0),
9294
MergeNetsplitBlock: big.NewInt(0),
93-
ShanghaiTime: big.NewInt(0),
95+
ShanghaiTime: u64(0),
9496
TerminalTotalDifficulty: big.NewInt(0),
9597
TerminalTotalDifficultyPassed: true,
9698
Ethash: new(params.EthashConfig),

0 commit comments

Comments
 (0)