Skip to content

Commit 925a3a8

Browse files
Merge pull request #1947 from 0xPolygon/revert-1941-v2.5.6-candidate
Revert "V2.5.6 candidate"
2 parents 85b5ef7 + f305a54 commit 925a3a8

File tree

15 files changed

+410
-661
lines changed

15 files changed

+410
-661
lines changed

.github/workflows/kurtosis-e2e.yml

Lines changed: 3 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -20,31 +20,15 @@ env:
2020

2121
jobs:
2222
e2e-tests:
23-
runs-on: ubuntu-latest
23+
name: E2E Tests
24+
runs-on: ubuntu24.04-16core-64GB-600SSD-bor
2425
timeout-minutes: 30
2526

2627
steps:
27-
# This is needed because the job fails with "System.IO.IOException: No space left on device".
28-
- name: Free disk space
29-
uses: jlumbroso/[email protected]
30-
with:
31-
android: false
32-
docker-images: false
33-
dotnet: true
34-
haskell: true
35-
large-packages: false
36-
swap-storage: false
37-
tool-cache: true
38-
3928
- name: Install dependencies on Linux
4029
if: runner.os == 'Linux'
4130
run: sudo apt update && sudo apt install build-essential
4231

43-
- name: Install Go
44-
uses: actions/setup-go@v6
45-
with:
46-
go-version: 'stable'
47-
4832
- name: Checkout bor
4933
uses: actions/checkout@v5
5034
with:
@@ -68,7 +52,7 @@ jobs:
6852
uses: actions/checkout@v5
6953
with:
7054
repository: 0xPolygon/kurtosis-pos
71-
ref: v1.2.6
55+
ref: v1.2.2
7256
path: kurtosis-pos
7357

7458
- name: Pre kurtosis run

.github/workflows/kurtosis-stateless-e2e.yml

Lines changed: 4 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Stateless Sync E2E Tests
1+
name: Stateless Sync Tests
22

33
on:
44
push:
@@ -20,22 +20,11 @@ env:
2020

2121
jobs:
2222
e2e-tests:
23-
runs-on: ubuntu-latest
23+
name: E2E Tests
24+
runs-on: ubuntu24.04-16core-64GB-600SSD-bor
2425
timeout-minutes: 45
2526

2627
steps:
27-
# This is needed because the job fails with "System.IO.IOException: No space left on device".
28-
- name: Free disk space
29-
uses: jlumbroso/[email protected]
30-
with:
31-
android: false
32-
docker-images: false
33-
dotnet: true
34-
haskell: true
35-
large-packages: false
36-
swap-storage: false
37-
tool-cache: true
38-
3928
- name: Install dependencies on Linux
4029
if: runner.os == 'Linux'
4130
run: sudo apt update && sudo apt install build-essential
@@ -63,7 +52,7 @@ jobs:
6352
uses: actions/checkout@v5
6453
with:
6554
repository: 0xPolygon/kurtosis-pos
66-
ref: v1.2.6
55+
ref: v1.2.2
6756
path: kurtosis-pos
6857

6958
- name: Pre kurtosis run

consensus/bor/bor.go

Lines changed: 8 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -252,8 +252,7 @@ type Bor struct {
252252
// The block time defined by the miner. Needs to be larger or equal to the consensus block time. If not set (default = 0), the miner will use the consensus block time.
253253
blockTime time.Duration
254254

255-
// Cache to store the actual times of the parent blocks
256-
parentActualTimeCache *lru.Cache
255+
lastMinedBlockTime time.Time
257256

258257
quit chan struct{}
259258
closeOnce sync.Once
@@ -327,8 +326,6 @@ func New(
327326
},
328327
})
329328

330-
c.parentActualTimeCache, _ = lru.New(10)
331-
332329
// make sure we can decode all the GenesisAlloc in the BorConfig.
333330
for key, genesisAlloc := range c.config.BlockAlloc {
334331
if _, err := decodeGenesisAlloc(genesisAlloc); err != nil {
@@ -1020,31 +1017,20 @@ func (c *Bor) Prepare(chain consensus.ChainHeaderReader, header *types.Header) e
10201017

10211018
if c.blockTime > 0 && c.config.IsRio(header.Number) {
10221019
// Only enable custom block time for Rio and later
1023-
1024-
parentBlockTime := time.Unix(int64(parent.Time), 0)
1025-
// Default to parent block timestamp
1026-
parentActualBlockTime := parentBlockTime
1027-
// If we have the parent's ActualTime locally (by parent hash), prefer it
1028-
if c.parentActualTimeCache != nil {
1029-
if v, ok := c.parentActualTimeCache.Get(header.ParentHash); ok {
1030-
if at, ok := v.(time.Time); ok && at.After(parentBlockTime) {
1031-
parentActualBlockTime = at
1032-
}
1033-
}
1020+
parentActualTime := c.lastMinedBlockTime
1021+
if parentActualTime.IsZero() || parentActualTime.Before(time.Unix(int64(parent.Time), 0)) {
1022+
parentActualTime = time.Unix(int64(parent.Time), 0)
10341023
}
1035-
actualNewBlockTime := parentActualBlockTime.Add(c.blockTime)
1024+
actualNewBlockTime := parentActualTime.Add(c.blockTime)
1025+
c.lastMinedBlockTime = actualNewBlockTime
10361026
header.Time = uint64(actualNewBlockTime.Unix())
10371027
header.ActualTime = actualNewBlockTime
10381028
} else {
10391029
header.Time = parent.Time + CalcProducerDelay(number, succession, c.config)
10401030
}
10411031

1042-
now := time.Now()
1043-
if header.Time < uint64(now.Unix()) {
1044-
header.Time = uint64(now.Unix())
1045-
if c.blockTime > 0 && c.config.IsRio(header.Number) {
1046-
header.ActualTime = now
1047-
}
1032+
if header.Time < uint64(time.Now().Unix()) {
1033+
header.Time = uint64(time.Now().Unix())
10481034
}
10491035

10501036
return nil
@@ -1323,10 +1309,6 @@ func (c *Bor) Seal(chain consensus.ChainHeaderReader, block *types.Block, witnes
13231309
return err
13241310
}
13251311

1326-
if c.parentActualTimeCache != nil && !header.ActualTime.IsZero() {
1327-
c.parentActualTimeCache.Add(header.Hash(), header.ActualTime)
1328-
}
1329-
13301312
// Wait until sealing is terminated or delay timeout.
13311313
log.Info("Waiting for slot to sign and propagate", "number", number, "hash", header.Hash(), "delay-in-sec", uint(delay), "delay", common.PrettyDuration(delay))
13321314

consensus/bor/bor_test.go

Lines changed: 14 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ func (s *fakeSpanner) CommitSpan(ctx context.Context, _ borTypes.Span, _ []stake
5050
}
5151

5252
// newChainAndBorForTest centralizes common Bor + HeaderChain initialization for tests
53-
func newChainAndBorForTest(t *testing.T, sp Spanner, borCfg *params.BorConfig, devFake bool, signerAddr common.Address, genesisTime uint64) (*core.BlockChain, *Bor) {
53+
func newChainAndBorForTest(t *testing.T, sp Spanner, borCfg *params.BorConfig, devFake bool, signerAddr common.Address) (*core.BlockChain, *Bor) {
5454
cfg := &params.ChainConfig{ChainID: big.NewInt(1), Bor: borCfg}
5555

5656
b := &Bor{chainConfig: cfg, config: cfg.Bor, DevFakeAuthor: devFake}
@@ -76,9 +76,8 @@ func newChainAndBorForTest(t *testing.T, sp Spanner, borCfg *params.BorConfig, d
7676
if devFake && signerAddr != (common.Address{}) {
7777
b.authorizedSigner.Store(&signer{signer: signerAddr})
7878
}
79-
b.parentActualTimeCache, _ = lru.New(10)
8079

81-
genspec := &core.Genesis{Config: cfg, Timestamp: genesisTime}
80+
genspec := &core.Genesis{Config: cfg}
8281
db := rawdb.NewMemoryDatabase()
8382
_ = genspec.MustCommit(db, triedb.NewDatabase(db, triedb.HashDefaults))
8483
chain, err := core.NewBlockChain(rawdb.NewMemoryDatabase(), genspec, b, core.DefaultConfig())
@@ -393,7 +392,7 @@ func TestPerformSpanCheck(t *testing.T) {
393392
t.Run(c.name, func(t *testing.T) {
394393
sp := &fakeSpanner{vals: []*valset.Validator{{Address: addr2, VotingPower: 1}}}
395394
borCfg := &params.BorConfig{Sprint: map[string]uint64{"0": 64}, Period: map[string]uint64{"0": 2}}
396-
chain, b := newChainAndBorForTest(t, sp, borCfg, false, common.Address{}, uint64(time.Now().Unix()))
395+
chain, b := newChainAndBorForTest(t, sp, borCfg, false, common.Address{})
397396

398397
var parents []*types.Header
399398
var parentHash common.Hash
@@ -470,7 +469,7 @@ func TestGetVeBlopSnapshot(t *testing.T) {
470469
t.Run(c.name, func(t *testing.T) {
471470
sp := &fakeSpanner{vals: c.spVals}
472471
borCfg := &params.BorConfig{Sprint: map[string]uint64{"0": 64}, Period: map[string]uint64{"0": 2}, RioBlock: big.NewInt(0)}
473-
chain, b := newChainAndBorForTest(t, sp, borCfg, false, common.Address{}, uint64(time.Now().Unix()))
472+
chain, b := newChainAndBorForTest(t, sp, borCfg, false, common.Address{})
474473
h := &types.Header{Number: big.NewInt(int64(c.targetNum))}
475474
snap, err := b.getVeBlopSnapshot(chain.HeaderChain(), h, nil, c.checkNewSpan)
476475
require.NoError(t, err)
@@ -517,7 +516,7 @@ func TestSnapshot(t *testing.T) {
517516
sp := &fakeSpanner{vals: c.spVals}
518517
// Configure RioBlock far in the future so IsRio(header.Number) == false
519518
borCfg := &params.BorConfig{Sprint: map[string]uint64{"0": 64}, Period: map[string]uint64{"0": 2}, RioBlock: big.NewInt(1_000_000)}
520-
chain, b := newChainAndBorForTest(t, sp, borCfg, false, common.Address{}, uint64(time.Now().Unix()))
519+
chain, b := newChainAndBorForTest(t, sp, borCfg, false, common.Address{})
521520
gen := chain.HeaderChain().GetHeaderByNumber(0)
522521
require.NotNil(t, gen)
523522
target := &types.Header{Number: big.NewInt(1), ParentHash: gen.Hash()}
@@ -591,7 +590,7 @@ func TestCustomBlockTimeValidation(t *testing.T) {
591590
Period: map[string]uint64{"0": tc.consensusPeriod},
592591
RioBlock: big.NewInt(0), // Enable Rio from genesis
593592
}
594-
chain, b := newChainAndBorForTest(t, sp, borCfg, true, addr1, uint64(time.Now().Unix()))
593+
chain, b := newChainAndBorForTest(t, sp, borCfg, true, addr1)
595594
b.blockTime = tc.blockTime
596595

597596
// Get genesis block as parent
@@ -627,7 +626,7 @@ func TestCustomBlockTimeCalculation(t *testing.T) {
627626
Period: map[string]uint64{"0": 2},
628627
RioBlock: big.NewInt(0),
629628
}
630-
chain, b := newChainAndBorForTest(t, sp, borCfg, true, addr1, uint64(time.Now().Unix()))
629+
chain, b := newChainAndBorForTest(t, sp, borCfg, true, addr1)
631630
b.blockTime = 5 * time.Second
632631

633632
genesis := chain.HeaderChain().GetHeaderByNumber(0)
@@ -653,7 +652,7 @@ func TestCustomBlockTimeCalculation(t *testing.T) {
653652
Period: map[string]uint64{"0": 2},
654653
RioBlock: big.NewInt(0),
655654
}
656-
chain, b := newChainAndBorForTest(t, sp, borCfg, true, addr1, uint64(time.Now().Unix()))
655+
chain, b := newChainAndBorForTest(t, sp, borCfg, true, addr1)
657656
b.blockTime = 3 * time.Second
658657

659658
genesis := chain.HeaderChain().GetHeaderByNumber(0)
@@ -679,23 +678,22 @@ func TestCustomBlockTimeCalculation(t *testing.T) {
679678
Period: map[string]uint64{"0": 2},
680679
RioBlock: big.NewInt(0),
681680
}
682-
chain, b := newChainAndBorForTest(t, sp, borCfg, true, addr1, uint64(time.Now().Unix()))
681+
chain, b := newChainAndBorForTest(t, sp, borCfg, true, addr1)
683682
b.blockTime = 4 * time.Second
684683

685684
genesis := chain.HeaderChain().GetHeaderByNumber(0)
686685
require.NotNil(t, genesis)
687686
baseTime := genesis.Time
688-
parentHash := genesis.Hash()
689687

690688
if baseTime > 10 {
691-
b.parentActualTimeCache.Add(parentHash, time.Unix(int64(baseTime-10), 0))
689+
b.lastMinedBlockTime = time.Unix(int64(baseTime-10), 0)
692690
} else {
693-
b.parentActualTimeCache.Add(parentHash, time.Unix(0, 0))
691+
b.lastMinedBlockTime = time.Unix(0, 0)
694692
}
695693

696694
header := &types.Header{
697695
Number: big.NewInt(1),
698-
ParentHash: parentHash,
696+
ParentHash: genesis.Hash(),
699697
}
700698

701699
err := b.Prepare(chain.HeaderChain(), header)
@@ -720,7 +718,7 @@ func TestCustomBlockTimeBackwardCompatibility(t *testing.T) {
720718
BackupMultiplier: map[string]uint64{"0": 2},
721719
RioBlock: big.NewInt(0),
722720
}
723-
chain, b := newChainAndBorForTest(t, sp, borCfg, true, addr1, uint64(time.Now().Unix()))
721+
chain, b := newChainAndBorForTest(t, sp, borCfg, true, addr1)
724722
b.blockTime = 0
725723

726724
genesis := chain.HeaderChain().GetHeaderByNumber(0)
@@ -738,53 +736,6 @@ func TestCustomBlockTimeBackwardCompatibility(t *testing.T) {
738736
})
739737
}
740738

741-
func TestCustomBlockTimeClampsToNowAlsoUpdatesActualTime(t *testing.T) {
742-
t.Parallel()
743-
744-
addr1 := common.HexToAddress("0x1")
745-
// Force parent time far in the past so that after adding blockTime, header.Time is still < now
746-
// and the "clamp to now" block triggers.
747-
pastParentTime := time.Now().Add(-10 * time.Minute).Unix()
748-
749-
sp := &fakeSpanner{vals: []*valset.Validator{{Address: addr1, VotingPower: 1}}}
750-
borCfg := &params.BorConfig{
751-
Sprint: map[string]uint64{"0": 64},
752-
Period: map[string]uint64{"0": 2},
753-
RioBlock: big.NewInt(0), // Rio enabled from genesis
754-
}
755-
chain, b := newChainAndBorForTest(t, sp, borCfg, true, addr1, uint64(pastParentTime))
756-
757-
// Enable custom block time (must be >= Period to avoid validation error)
758-
b.blockTime = 5 * time.Second
759-
760-
genesis := chain.HeaderChain().GetHeaderByNumber(0)
761-
require.NotNil(t, genesis)
762-
763-
header := &types.Header{
764-
Number: big.NewInt(1),
765-
ParentHash: genesis.Hash(),
766-
}
767-
768-
before := time.Now()
769-
err := b.Prepare(chain.HeaderChain(), header)
770-
after := time.Now()
771-
772-
require.NoError(t, err)
773-
774-
// Validate the clamp happened: header.Time should be "now-ish", not the past-derived time.
775-
require.GreaterOrEqual(t, int64(header.Time), before.Unix(), "header.Time should be clamped up to now")
776-
require.LessOrEqual(t, int64(header.Time), after.Unix()+1, "header.Time should be close to now")
777-
778-
// Critical regression assertion:
779-
// When custom blockTime is enabled for Rio, clamping header.Time to now must also set ActualTime = now.
780-
require.False(t, header.ActualTime.IsZero(), "ActualTime should be set when blockTime > 0 and Rio is enabled")
781-
require.GreaterOrEqual(t, header.ActualTime.Unix(), before.Unix(), "ActualTime should be updated to now when clamping occurs")
782-
require.LessOrEqual(t, header.ActualTime.Unix(), after.Unix()+1, "ActualTime should be close to now when clamping occurs")
783-
784-
// Optional: since clamping sets both from the same `now`, they should match on Unix seconds.
785-
require.Equal(t, int64(header.Time), header.ActualTime.Unix(), "header.Time and ActualTime should align after clamping")
786-
}
787-
788739
func TestVerifySealRejectsOversizedDifficulty(t *testing.T) {
789740
t.Parallel()
790741

@@ -806,7 +757,7 @@ func TestVerifySealRejectsOversizedDifficulty(t *testing.T) {
806757
}
807758

808759
// devFake=false, we need real signatures for the sake of this test
809-
chain, b := newChainAndBorForTest(t, sp, borCfg, false, common.Address{}, uint64(time.Now().Unix()))
760+
chain, b := newChainAndBorForTest(t, sp, borCfg, false, common.Address{})
810761

811762
parent := chain.HeaderChain().GetHeaderByNumber(0)
812763
require.NotNil(t, parent)

core/parallel_state_processor.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ func (task *ExecutionTask) Settle() {
182182

183183
coinbaseBalance := task.finalStateDB.GetBalance(task.coinbase)
184184

185-
task.finalStateDB.ApplyMVWriteSet(task.statedb.MVWriteList())
185+
task.finalStateDB.ApplyMVWriteSet(task.statedb.MVFullWriteList())
186186

187187
for _, l := range task.statedb.GetLogs(task.tx.Hash(), task.blockNumber.Uint64(), task.blockHash, task.blockTime) {
188188
task.finalStateDB.AddLog(l)

core/state/journal.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ import (
2323
"sort"
2424

2525
"github.com/ethereum/go-ethereum/common"
26-
"github.com/ethereum/go-ethereum/core/blockstm"
2726
"github.com/ethereum/go-ethereum/crypto"
2827
"github.com/holiman/uint256"
2928
)
@@ -324,7 +323,6 @@ func (ch selfDestructChange) revert(s *StateDB) {
324323
obj := s.getStateObject(ch.account)
325324
if obj != nil {
326325
obj.selfDestructed = false
327-
RevertWrite(s, blockstm.NewSubpathKey(ch.account, SuicidePath))
328326
}
329327
}
330328

core/state/statedb.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -421,7 +421,7 @@ func (s *StateDB) ApplyMVWriteSet(writes []blockstm.WriteDescriptor) {
421421
s.SetCode(addr, sr.GetCode(addr))
422422
case SuicidePath:
423423
stateObject := s.getStateObject(addr)
424-
if stateObject != nil && sr.HasSelfDestructed(addr) {
424+
if stateObject != nil {
425425
s.SelfDestruct(addr)
426426
}
427427
default:

0 commit comments

Comments
 (0)