Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add a mark for latest block #432

Merged
merged 1 commit into from
Jul 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions core/data_availability.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
)

// IsDataAvailable it checks that the blobTx block has available blob data
func IsDataAvailable(chain consensus.ChainHeaderReader, header *types.Header, body *types.RawBody) (err error) {
func IsDataAvailable(chain consensus.ChainHeaderReader, header *types.Header, body *types.RawBody, latest uint64) (err error) {
if !chain.Config().IsCancun(header.Number.Uint64(), header.Time) {
if body.Sidecars != nil {
return errors.New("sidecars present in block body before cancun")
Expand All @@ -19,7 +19,7 @@ func IsDataAvailable(chain consensus.ChainHeaderReader, header *types.Header, bo
}

current := chain.CurrentHeader()
if header.Number.Uint64()+params.MinBlocksForBlobRequests < current.Number.Uint64() {
if header.Number.Uint64()+params.MinBlocksForBlobRequests < max(current.Number.Uint64(), latest) {
// if we needn't check DA of this block, just clean it
body.CleanSidecars()
return nil
Expand Down
2 changes: 1 addition & 1 deletion eth/stagedsync/stage_bodies.go
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ func BodiesForward(
metrics.UpdateBlockConsumerBodyDownloadDelay(header.Time, header.Number.Uint64(), logger)

if cfg.chanConfig.Parlia != nil && cfg.chanConfig.IsCancun(headerNumber, header.Time) {
if err = core.IsDataAvailable(cr, header, rawBody); err != nil {
if err = core.IsDataAvailable(cr, header, rawBody, cfg.bd.LatestBlock); err != nil {
return false, err
}
}
Expand Down
3 changes: 3 additions & 0 deletions p2p/sentry/sentry_multi_client/sentry_multi_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -575,6 +575,9 @@ func (cs *MultiClient) newBlock66(ctx context.Context, inreq *proto_sentry.Inbou
return fmt.Errorf("singleHeaderAsSegment failed: %w", err)
}
cs.Bd.AddToPrefetch(request.Block.Header(), request.Block.RawBody())
if cs.Bd.LatestBlock < request.Block.NumberU64() {
cs.Bd.LatestBlock = request.Block.NumberU64()
}
outreq := proto_sentry.PeerMinBlockRequest{
PeerId: inreq.PeerId,
MinBlock: request.Block.NumberU64(),
Expand Down
1 change: 1 addition & 0 deletions turbo/stages/bodydownload/body_data_struct.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ type BodyDownload struct {
bodyCacheLimit int // Limit of body Cache size
blockBufferSize int
br services.FullBlockReader
LatestBlock uint64
logger log.Logger
}

Expand Down
Loading