Skip to content

Commit c79bb6b

Browse files
authored
Merge pull request #1803 from 0xPolygon/v2.3.1-beta-candidate
Merge v2.3.1 to master
2 parents efefa47 + d48990e commit c79bb6b

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

51 files changed

+1546
-872
lines changed

.github/workflows/codeql.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ on:
1111
jobs:
1212
analyze:
1313
name: Analyze
14-
runs-on: ${{ (matrix.language == 'swift' && 'macos-latest') || 'ubuntu-latest' }}
14+
runs-on: ${{ (matrix.language == 'swift' && 'macos-latest') || 'ubuntu24.04-16core-64GB-600SSD-bor' }}
1515
timeout-minutes: ${{ (matrix.language == 'swift' && 120) || 360 }}
1616
permissions:
1717
actions: read

.github/workflows/govulncheck.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ on: [push, pull_request]
44
jobs:
55
govulncheck:
66
name: Run govulncheck
7-
runs-on: ubuntu-latest
7+
runs-on: ubuntu24.04-16core-64GB-600SSD-bor
88
steps:
99
- uses: actions/setup-go@v5
1010
with:

.github/workflows/kurtosis-e2e.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ env:
2121
jobs:
2222
e2e-tests:
2323
name: E2E Tests
24-
runs-on: ubuntu-latest
24+
runs-on: ubuntu24.04-16core-64GB-600SSD-bor
2525
timeout-minutes: 30
2626

2727
steps:

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ env:
2121
jobs:
2222
e2e-tests:
2323
name: E2E Tests
24-
runs-on: ubuntu-latest
24+
runs-on: ubuntu24.04-16core-64GB-600SSD-bor
2525
timeout-minutes: 45
2626

2727
steps:

.github/workflows/release.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ on:
1111

1212
jobs:
1313
goreleaser:
14-
runs-on: ubuntu-latest-8-cores
14+
runs-on: ubuntu24.04-16core-64GB-600SSD-bor
1515
steps:
1616
- name: Checkout
1717
uses: actions/checkout@v4

.github/workflows/stale.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ on:
1111

1212
jobs:
1313
stale:
14-
runs-on: ubuntu-latest
14+
runs-on: ubuntu24.04-16core-64GB-600SSD-bor
1515
permissions:
1616
issues: write
1717
pull-requests: write

consensus/bor/api.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ func (api *API) GetSnapshotProposerSequence(blockNrOrHash *rpc.BlockNumberOrHash
9898
return BlockSigners{}, errUnknownBlock
9999
}
100100

101-
snapNumber := rpc.BlockNumber(header.Number.Int64() - 1)
101+
snapNumber := rpc.BlockNumber(header.Number.Int64())
102102
snap, err := api.GetSnapshot(&snapNumber)
103103

104104
var difficulties = make(map[common.Address]uint64)
@@ -161,7 +161,7 @@ func (api *API) GetSnapshotProposer(blockNrOrHash *rpc.BlockNumberOrHash) (commo
161161
return common.Address{}, errUnknownBlock
162162
}
163163

164-
snapNumber := rpc.BlockNumber(header.Number.Int64() - 1)
164+
snapNumber := rpc.BlockNumber(header.Number.Int64())
165165
snap, err := api.GetSnapshot(&snapNumber)
166166

167167
if err != nil {

core/blockchain.go

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2327,7 +2327,7 @@ func (bc *BlockChain) InsertChainStateless(chain types.Blocks, witnesses []*stat
23272327
}
23282328

23292329
// Process the block using stateless execution
2330-
statedb, err := bc.ProcessBlockWithWitnesses(block, witness)
2330+
statedb, res, err := bc.ProcessBlockWithWitnesses(block, witness)
23312331
if err != nil {
23322332
return processed, err
23332333
}
@@ -2342,6 +2342,7 @@ func (bc *BlockChain) InsertChainStateless(chain types.Blocks, witnesses []*stat
23422342
processed++
23432343

23442344
stats.processed = processed
2345+
stats.usedGas += res.GasUsed
23452346

23462347
stats.report(chain, i, 0, 0, 0, 0, true, true)
23472348
}
@@ -2925,7 +2926,7 @@ func (bc *BlockChain) processBlock(block *types.Block, statedb *state.StateDB, s
29252926
author := NewEVMBlockContext(block.Header(), bc.hc, nil).Coinbase
29262927

29272928
// Run the stateless self-cross-validation
2928-
crossStateRoot, crossReceiptRoot, _, err := ExecuteStateless(bc.chainConfig, bc.vmConfig, task, witness, &author, bc.engine, diskdb)
2929+
crossStateRoot, crossReceiptRoot, _, _, err := ExecuteStateless(bc.chainConfig, bc.vmConfig, task, witness, &author, bc.engine, diskdb)
29292930
if err != nil {
29302931
return nil, fmt.Errorf("stateless self-validation failed: %v", err)
29312932
}
@@ -3658,15 +3659,15 @@ func (bc *BlockChain) SubscribeChain2HeadEvent(ch chan<- Chain2HeadEvent) event.
36583659
}
36593660

36603661
// ProcessBlockWithWitnesses processes a block in stateless mode using the provided witnesses.
3661-
func (bc *BlockChain) ProcessBlockWithWitnesses(block *types.Block, witness *stateless.Witness) (*state.StateDB, error) {
3662+
func (bc *BlockChain) ProcessBlockWithWitnesses(block *types.Block, witness *stateless.Witness) (*state.StateDB, *ProcessResult, error) {
36623663
if witness == nil {
3663-
return nil, errors.New("nil witness")
3664+
return nil, nil, errors.New("nil witness")
36643665
}
36653666

36663667
// Validate witness.
36673668
if err := stateless.ValidateWitnessPreState(witness, bc); err != nil {
36683669
log.Error("Witness validation failed during stateless processing", "blockNumber", block.Number(), "blockHash", block.Hash(), "err", err)
3669-
return nil, fmt.Errorf("witness validation failed: %w", err)
3670+
return nil, nil, fmt.Errorf("witness validation failed: %w", err)
36703671
}
36713672

36723673
// Remove critical computed fields from the block to force true recalculation
@@ -3679,25 +3680,25 @@ func (bc *BlockChain) ProcessBlockWithWitnesses(block *types.Block, witness *sta
36793680
// Bor: Calculate EvmBlockContext with Root and ReceiptHash to properly get the author
36803681
author := NewEVMBlockContext(block.Header(), bc.hc, nil).Coinbase
36813682

3682-
crossStateRoot, crossReceiptRoot, statedb, err := ExecuteStateless(bc.chainConfig, bc.vmConfig, task, witness, &author, bc.engine, bc.statedb.TrieDB().Disk())
3683+
crossStateRoot, crossReceiptRoot, statedb, res, err := ExecuteStateless(bc.chainConfig, bc.vmConfig, task, witness, &author, bc.engine, bc.statedb.TrieDB().Disk())
36833684

36843685
// Currently, we don't return the error, because we don't have a way to handle Span update statelessly
36853686
// TODO: Return the error once we have a way to handle Span update
36863687
if err != nil {
36873688
log.Error("Stateless self-validation failed", "block", block.Number(), "hash", block.Hash(), "error", err)
3688-
return nil, err
3689+
return nil, nil, err
36893690
}
36903691
if crossStateRoot != block.Root() {
36913692
log.Error("Stateless self-validation root mismatch", "block", block.Number(), "hash", block.Hash(), "cross", crossStateRoot, "local", block.Root())
36923693
err = fmt.Errorf("stateless self-validation state root mismatch: remote %x != local %x", block.Root(), crossStateRoot)
3693-
return nil, err
3694+
return nil, nil, err
36943695
}
36953696
if crossReceiptRoot != block.ReceiptHash() {
36963697
log.Error("Stateless self-validation receipt root mismatch", "block", block.Number(), "hash", block.Hash(), "cross", crossReceiptRoot, "local", block.ReceiptHash())
36973698
err = fmt.Errorf("stateless self-validation receipt root mismatch: remote %x != local %x", block.ReceiptHash(), crossReceiptRoot)
3698-
return nil, err
3699+
return nil, nil, err
36993700
}
3700-
return statedb, nil
3701+
return statedb, res, nil
37013702
}
37023703

37033704
// startHeaderVerificationLoop starts a background goroutine that periodically

core/blockchain_reader.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,11 @@ func (bc *BlockChain) GetBodyRLP(hash common.Hash) rlp.RawValue {
156156
return body
157157
}
158158

159+
// HasWitness checks if a witness is present in the database or not.
160+
func (bc *BlockChain) HasWitness(hash common.Hash) bool {
161+
return rawdb.HasWitness(bc.db, hash)
162+
}
163+
159164
// HasBlock checks if a block is fully present in the database or not.
160165
func (bc *BlockChain) HasBlock(hash common.Hash, number uint64) bool {
161166
if bc.blockCache.Contains(hash) {

core/rawdb/accessors_chain.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -675,7 +675,6 @@ func ReadReceiptsRLP(db ethdb.Reader, hash common.Hash, number uint64) rlp.RawVa
675675
}
676676
// If not, try reading from leveldb
677677
data, _ = db.Get(blockReceiptsKey(number, hash))
678-
679678
return nil
680679
})
681680

0 commit comments

Comments
 (0)