Skip to content

Commit

Permalink
tidy
Browse files Browse the repository at this point in the history
  • Loading branch information
taratorio committed Nov 8, 2024
1 parent 1438b7c commit 2168b99
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 16 deletions.
4 changes: 2 additions & 2 deletions polygon/bor/bor.go
Original file line number Diff line number Diff line change
Expand Up @@ -385,9 +385,9 @@ func New(
execCtx: context.Background(),
logger: logger,
closeCh: make(chan struct{}),
useBridgeReader: bridgeReader != nil && !reflect.ValueOf(bridgeReader).IsNil(),
useBridgeReader: bridgeReader != nil && !reflect.ValueOf(bridgeReader).IsNil(), // needed for interface nil caveat
bridgeReader: bridgeReader,
useSpanReader: spanReader != nil && !reflect.ValueOf(spanReader).IsNil(),
useSpanReader: spanReader != nil && !reflect.ValueOf(spanReader).IsNil(), // needed for interface nil caveat
spanReader: spanReader,
}

Expand Down
1 change: 1 addition & 0 deletions polygon/bridge/reader.go
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,7 @@ func (r *RemoteReader) EventTxnLookup(ctx context.Context, borTxHash libcommon.H
}

func (r *RemoteReader) Close() {
// no-op as there is no attached store
}

func (r *RemoteReader) EnsureVersionCompatibility() bool {
Expand Down
24 changes: 12 additions & 12 deletions polygon/sync/sync.go
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ func (s *Sync) commitExecution(ctx context.Context, newTip *types.Header, finali
return nil
}

func (s *Sync) handleMilestoneTipMismatch(ctx context.Context, ccb *CanonicalChainBuilder, ms EventNewMilestone) error {
func (s *Sync) handleMilestoneTipMismatch(ctx context.Context, ccb *CanonicalChainBuilder, event EventNewMilestone) error {
// the milestone doesn't correspond to the tip of the chain
// unwind to the previous verified milestone
// and download the blocks of the new milestone
Expand All @@ -132,10 +132,10 @@ func (s *Sync) handleMilestoneTipMismatch(ctx context.Context, ccb *CanonicalCha
s.logger.Debug(
syncLogPrefix("local chain tip does not match the milestone, unwinding to the previous verified root"),
"rootNum", rootNum,
"milestoneId", ms.Id,
"milestoneStart", ms.StartBlock(),
"milestoneEnd", ms.EndBlock(),
"milestoneRootHash", ms.RootHash(),
"milestoneId", event.Id,
"milestoneStart", event.StartBlock(),
"milestoneEnd", event.EndBlock(),
"milestoneRootHash", event.RootHash(),
)

if err := s.bridgeSync.Unwind(ctx, rootNum); err != nil {
Expand All @@ -150,7 +150,7 @@ func (s *Sync) handleMilestoneTipMismatch(ctx context.Context, ccb *CanonicalCha
err = errors.New("unexpected empty headers from p2p since new milestone")
return fmt.Errorf(
"%w: rootNum=%d, milestoneId=%d, milestoneStart=%d, milestoneEnd=%d, milestoneRootHash=%s",
err, rootNum, ms.Id, ms.StartBlock(), ms.EndBlock(), ms.RootHash(),
err, rootNum, event.Id, event.StartBlock(), event.EndBlock(), event.RootHash(),
)
}

Expand Down Expand Up @@ -367,8 +367,8 @@ func (s *Sync) applyNewBlockOnTip(ctx context.Context, event EventNewBlock, ccb
return nil
}

func (s *Sync) applyNewBlockHashesOnTip(ctx context.Context, e EventNewBlockHashes, ccb *CanonicalChainBuilder) error {
for _, hashOrNum := range e.NewBlockHashes {
func (s *Sync) applyNewBlockHashesOnTip(ctx context.Context, event EventNewBlockHashes, ccb *CanonicalChainBuilder) error {
for _, hashOrNum := range event.NewBlockHashes {
if (hashOrNum.Number <= ccb.Root().Number.Uint64()) || ccb.ContainsHash(hashOrNum.Hash) {
continue
}
Expand All @@ -379,7 +379,7 @@ func (s *Sync) applyNewBlockHashesOnTip(ctx context.Context, e EventNewBlockHash
s.logger.Warn(syncLogPrefix("bad block hash received from peer"),
"blockHash", hashOrNum.Hash,
"blockNum", hashOrNum.Number,
"peerId", e.PeerId,
"peerId", event.PeerId,
)
return nil
}
Expand All @@ -391,13 +391,13 @@ func (s *Sync) applyNewBlockHashesOnTip(ctx context.Context, e EventNewBlockHash
)

fetchOpts := []p2p.FetcherOption{p2p.WithMaxRetries(0), p2p.WithResponseTimeout(time.Second)}
newBlocks, err := s.p2pService.FetchBlocksBackwardsByHash(ctx, hashOrNum.Hash, 1, e.PeerId, fetchOpts...)
newBlocks, err := s.p2pService.FetchBlocksBackwardsByHash(ctx, hashOrNum.Hash, 1, event.PeerId, fetchOpts...)
if err != nil {
if s.ignoreFetchBlocksErrOnTipEvent(err) {
s.logger.Debug(
syncLogPrefix("applyNewBlockHashesOnTip: failed to fetch complete blocks, ignoring event"),
"err", err,
"peerId", e.PeerId,
"peerId", event.PeerId,
"lastBlockNum", hashOrNum.Number,
)

Expand All @@ -409,7 +409,7 @@ func (s *Sync) applyNewBlockHashesOnTip(ctx context.Context, e EventNewBlockHash

newBlockEvent := EventNewBlock{
NewBlock: newBlocks.Data[0],
PeerId: e.PeerId,
PeerId: event.PeerId,
Source: EventSourceP2PNewBlockHashes,
}

Expand Down
2 changes: 1 addition & 1 deletion turbo/jsonrpc/bor_api.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ func NewBorAPI(base *BaseAPI, db kv.RoDB, spanProducersReader spanProducersReade
return &BorImpl{
BaseAPI: base,
db: db,
useSpanProducersReader: spanProducersReader != nil && !reflect.ValueOf(spanProducersReader).IsNil(),
useSpanProducersReader: spanProducersReader != nil && !reflect.ValueOf(spanProducersReader).IsNil(), // needed for interface nil caveat
spanProducersReader: spanProducersReader,
}
}
Expand Down
2 changes: 1 addition & 1 deletion turbo/jsonrpc/eth_api.go
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ func NewBaseApi(f *rpchelper.Filters, stateCache kvcache.Cache, blockReader serv
receiptsGenerator: receipts.NewGenerator(receiptsCacheLimit, blockReader, engine),
borReceiptGenerator: receipts.NewBorGenerator(receiptsCacheLimit, blockReader, engine),
dirs: dirs,
useBridgeReader: bridgeReader != nil && !reflect.ValueOf(bridgeReader).IsNil(),
useBridgeReader: bridgeReader != nil && !reflect.ValueOf(bridgeReader).IsNil(), // needed for interface nil caveat
bridgeReader: bridgeReader,
}
}
Expand Down

0 comments on commit 2168b99

Please sign in to comment.