Skip to content

Commit

Permalink
Fix for crosslink snap db. (#4675)
Browse files Browse the repository at this point in the history
* Fix for crosslink snap db.

* Fix for possible race for new block post consensus job.
  • Loading branch information
Frozen committed May 25, 2024
1 parent 3d29596 commit 8abcc74
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions node/node_newblock.go
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,16 @@ func (node *Node) ProposeNewBlock(commitSigs chan []byte) (*types.Block, error)
AnErr("[ProposeNewBlock] pending crosslink is already committed onchain", err)
continue
}
last, err := node.Blockchain().ReadShardLastCrossLink(pending.ShardID())
if err != nil {
utils.Logger().Debug().
AnErr("[ProposeNewBlock] failed to read last crosslink", err)
// no return
}
// if pending crosslink is older than the last crosslink, delete it and continue
if err == nil && exist == nil && last != nil && last.BlockNum() >= pending.BlockNum() {
invalidToDelete = append(invalidToDelete, pending)
}

// Crosslink is already verified before it's accepted to pending,
// no need to verify again in proposal.
Expand Down

0 comments on commit 8abcc74

Please sign in to comment.