Removed outdated check. (#4574)

* Removed outdated check.

* Fallback for old sync for BeaconBlockChannel.
pull/4577/head
Konstantin 1 year ago committed by GitHub
parent b7b7fbf2b3
commit fe1d97a460
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 4
      node/node.go
  2. 2
      node/node_handler.go
  3. 11
      node/node_syncing.go

@ -499,10 +499,6 @@ func (node *Node) validateNodeMessage(ctx context.Context, payload []byte) (
utils.Logger().Debug().Uint64("receivedNum", block.NumberU64()).
Uint64("currentNum", curBeaconHeight).Msg("beacon block sync message rejected")
return nil, 0, errors.New("beacon block height smaller than current height beyond tolerance")
} else if block.NumberU64()-beaconBlockHeightTolerance > curBeaconHeight {
utils.Logger().Debug().Uint64("receivedNum", block.NumberU64()).
Uint64("currentNum", curBeaconHeight).Msg("beacon block sync message rejected")
return nil, 0, errors.Errorf("beacon block height too much higher than current height beyond tolerance, block %d, current %d, epoch %d , current %d", block.NumberU64(), curBeaconHeight, block.Epoch().Uint64(), curBeaconBlock.Epoch().Uint64())
} else if block.NumberU64() <= curBeaconHeight {
utils.Logger().Debug().Uint64("receivedNum", block.NumberU64()).
Uint64("currentNum", curBeaconHeight).Msg("beacon block sync message ignored")

@ -76,8 +76,6 @@ func (node *Node) HandleNodeMessage(
if node.Blockchain().ShardID() != shard.BeaconChainShardID {
for _, block := range blocks {
if block.ShardID() == 0 {
utils.Logger().Info().
Msgf("Beacon block being handled by block channel: %d", block.NumberU64())
if block.IsLastBlockInEpoch() {
go func(blk *types.Block) {
node.BeaconBlockChannel <- blk

@ -231,7 +231,16 @@ func (node *Node) doBeaconSyncing() {
// If Downloader is not working, we need also deal with blocks from beaconBlockChannel
go func(node *Node) {
// TODO ek – infinite loop; add shutdown/cleanup logic
for _ = range node.BeaconBlockChannel {
for b := range node.BeaconBlockChannel {
if b != nil && b.IsLastBlockInEpoch() {
_, err := node.EpochChain().InsertChain(types.Blocks{b}, true)
if err != nil {
utils.Logger().Error().Err(err).Msgf("[SYNC] InsertChain failed shard: %d epoch:%d number:%d", b.Header().ShardID(), b.Epoch().Uint64(), b.NumberU64())
} else {
utils.Logger().Info().
Msgf("Beacon block being handled by block channel: epoch: %d, number: %d", b.Epoch().Uint64(), b.NumberU64())
}
}
}
}(node)
}

Loading…
Cancel
Save