Skip to content

Commit

Permalink
add a mark for latest block (node-real#432)
Browse files Browse the repository at this point in the history
  • Loading branch information
blxdyx authored and MakarovSg committed Jul 19, 2024
1 parent 58e62fe commit d35a878
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 3 deletions.
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

0 comments on commit d35a878

Please sign in to comment.