Skip to content
This repository was archived by the owner on Apr 23, 2026. It is now read-only.

Commit e963db2

Browse files
committed
handle empty withdrawals
1 parent bcd6dd0 commit e963db2

2 files changed

Lines changed: 17 additions & 3 deletions

File tree

core/data_availability.go

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package core
22

33
import (
4+
"errors"
45
"fmt"
56

67
"github.com/ledgerwatch/erigon-lib/common"
@@ -11,9 +12,16 @@ import (
1112

1213
// IsDataAvailable it checks that the blobTx block has available blob data
1314
func IsDataAvailable(chain consensus.ChainHeaderReader, header *types.Header, body *types.RawBody) (err error) {
14-
if !chain.Config().IsCancun(header.Number.Uint64(), header.Time) {
15+
if body.Sidecars == nil || len(body.Sidecars) == 0 {
1516
return nil
1617
}
18+
if !chain.Config().IsCancun(header.Number.Uint64(), header.Time) {
19+
if body.Sidecars == nil {
20+
return nil
21+
} else {
22+
return errors.New("sidecars present in block body before cancun")
23+
}
24+
}
1725

1826
current := chain.CurrentHeader()
1927
if header.Number.Uint64()+params.MinBlocksForBlobRequests < current.Number.Uint64() {

turbo/stages/bodydownload/body_algos.go

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ func (bd *BodyDownload) RequestMoreBodies(tx kv.RwTx, blockReader services.FullB
165165
var tripleHash TripleHash
166166
copy(tripleHash[:], header.UncleHash.Bytes())
167167
copy(tripleHash[length.Hash:], header.TxHash.Bytes())
168-
if header.WithdrawalsHash != nil {
168+
if header.WithdrawalsHash != nil && *header.WithdrawalsHash != (libcommon.Hash{}) {
169169
copy(tripleHash[2*length.Hash:], header.WithdrawalsHash.Bytes())
170170
} else {
171171
copy(tripleHash[2*length.Hash:], types.EmptyRootHash.Bytes())
@@ -299,7 +299,13 @@ Loop:
299299
for i := range txs {
300300
uncleHash := types.CalcUncleHash(uncles[i])
301301
txHash := types.DeriveSha(RawTransactions(txs[i]))
302-
withdrawalsHash := types.DeriveSha(withdrawals[i])
302+
var withdrawalsHash libcommon.Hash
303+
if len(withdrawals[i]) == 0 {
304+
withdrawalsHash = types.EmptyRootHash
305+
} else {
306+
withdrawalsHash = types.DeriveSha(withdrawals[i])
307+
}
308+
303309
var tripleHash TripleHash
304310
copy(tripleHash[:], uncleHash.Bytes())
305311
copy(tripleHash[length.Hash:], txHash.Bytes())

0 commit comments

Comments
 (0)