Merge branch 'dev' into feature/clear-stale-staking-data

feature/dev-engine_test
static 12 months ago
commit ad438fd5dc
  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()). utils.Logger().Debug().Uint64("receivedNum", block.NumberU64()).
Uint64("currentNum", curBeaconHeight).Msg("beacon block sync message rejected") Uint64("currentNum", curBeaconHeight).Msg("beacon block sync message rejected")
return nil, 0, errors.New("beacon block height smaller than current height beyond tolerance") 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 { } else if block.NumberU64() <= curBeaconHeight {
utils.Logger().Debug().Uint64("receivedNum", block.NumberU64()). utils.Logger().Debug().Uint64("receivedNum", block.NumberU64()).
Uint64("currentNum", curBeaconHeight).Msg("beacon block sync message ignored") Uint64("currentNum", curBeaconHeight).Msg("beacon block sync message ignored")

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

@ -231,7 +231,16 @@ func (node *Node) doBeaconSyncing() {
// If Downloader is not working, we need also deal with blocks from beaconBlockChannel // If Downloader is not working, we need also deal with blocks from beaconBlockChannel
go func(node *Node) { go func(node *Node) {
// TODO ek – infinite loop; add shutdown/cleanup logic // 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) }(node)
} }

Loading…
Cancel
Save