Skip to content

Commit

Permalink
Fix sidecar boardcast issue (#388)
Browse files Browse the repository at this point in the history
  • Loading branch information
blxdyx authored May 11, 2024
1 parent 1c9e207 commit 2393bd8
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 5 deletions.
2 changes: 1 addition & 1 deletion core/data_availability.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ func IsDataAvailable(chain consensus.ChainHeaderReader, header *types.Header, bo
}

if len(blobTxs) != len(sidecars) {
return fmt.Errorf("blob info mismatch: sidecars %d, versionedHashes:%d", len(sidecars), len(blobTxs))
return fmt.Errorf("number %d, hash %v, blob info mismatch: have %d, want:%d", header.Number.Uint64(), header.Hash(), len(sidecars), len(blobTxs))
}

// check blob amount
Expand Down
3 changes: 1 addition & 2 deletions eth/stagedsync/stage_bodies.go
Original file line number Diff line number Diff line change
Expand Up @@ -239,8 +239,7 @@ func BodiesForward(

if cfg.chanConfig.Parlia != nil && cfg.chanConfig.IsCancun(headerNumber, header.Time) {
if err = core.IsDataAvailable(cr, header, rawBody); err != nil {
u.UnwindTo(blockHeight-1, BadBlock(header.Hash(), fmt.Errorf("CheckDataAvaliabe failed: %w", err)))
return true, err
return false, err
}
}

Expand Down
2 changes: 2 additions & 0 deletions p2p/sentry/sentry_multi_client/broadcast.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,8 @@ func (cs *MultiClient) BroadcastNewBlock(ctx context.Context, header *types.Head
Sidecars: body.Sidecars,
})

//log.Debug("broadcastNewBlock", "number", block.NumberU64(), "hash", block.Hash(), "len(sidecar)", len(body.Sidecars))

if err != nil {
log.Error("broadcastNewBlock", "err", err)
return
Expand Down
1 change: 1 addition & 0 deletions p2p/sentry/sentry_multi_client/sentry_multi_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -521,6 +521,7 @@ func (cs *MultiClient) newBlock66(ctx context.Context, inreq *proto_sentry.Inbou
request.Block = request.Block.WithSidecars(request.Sidecars)
}

log.Trace("NewBlockMsg", "number", request.Block.NumberU64(), "hash", request.Block.Hash(), "Sidecar", len(request.Sidecars), "PeerID", fmt.Sprintf("%x", sentry2.ConvertH512ToPeerID(inreq.PeerId))[:8])
if segments, penalty, err := cs.Hd.SingleHeaderAsSegment(headerRaw, request.Block.Header(), true /* penalizePoSBlocks */); err == nil {
if penalty == headerdownload.NoPenalty {
propagate := !cs.ChainConfig.TerminalTotalDifficultyPassed
Expand Down
2 changes: 1 addition & 1 deletion params/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ var (
const (
VersionMajor = 1 // Major version component of the current release
VersionMinor = 2 // Minor version component of the current release
VersionMicro = 7 // Patch version component of the current release
VersionMicro = 8 // Patch version component of the current release
VersionModifier = "dev" // Modifier component of the current release
VersionKeyCreated = "ErigonVersionCreated"
VersionKeyFinished = "ErigonVersionFinished"
Expand Down
12 changes: 11 additions & 1 deletion turbo/stages/bodydownload/body_algos.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"bytes"
"context"
"fmt"
"github.com/ledgerwatch/erigon/params"
"math/big"

"github.com/holiman/uint256"
Expand Down Expand Up @@ -154,7 +155,8 @@ func (bd *BodyDownload) RequestMoreBodies(tx kv.RwTx, blockReader services.FullB
} else {
// Perhaps we already have this block
block, _, _ := bd.br.BlockWithSenders(context.Background(), tx, hash, blockNum)
if block != nil {
withoutSidecar := header.BlobGasUsed == nil || *header.BlobGasUsed == 0
if block != nil && withoutSidecar {
bd.addBodyToCache(blockNum, block.RawBody())
dataflow.BlockBodyDownloadStates.AddChange(blockNum, dataflow.BlockBodyInDb)
request = false
Expand Down Expand Up @@ -192,6 +194,14 @@ func (bd *BodyDownload) checkPrefetchedBlock(hash libcommon.Hash, tx kv.RwTx, bl
return false
}

if header.BlobGasUsed != nil {
want := *header.BlobGasUsed / params.BlobTxBlobGasPerBlob
if want != uint64(len(body.Sidecars)) {
bd.logger.Debug("Prefetched Block Error", "Number", header.Number.Uint64(), "Hash", header.Hash(), "want", want, "actual", len(body.Sidecars))
return false
}
}

// Block is prefetched, no need to request
bd.deliveriesH[blockNum] = header

Expand Down

0 comments on commit 2393bd8

Please sign in to comment.