@@ -766,18 +766,18 @@ func CheckCommitmentHistAtBlk(ctx context.Context, db kv.TemporalRoDB, br servic
766766 }
767767 // commitment branch data view: as of beginning of the block
768768 // plain state data view: as of end of the block
769- splitStateReader := commitmentdb .NewSplitHistoryReader (tx , minTxNum , toTxNum /* withHistory */ , true )
769+ splitStateReader := commitmentdb .NewSplitHistoryReader (tx , minTxNum , toTxNum , true /* withHistory */ )
770770 sd .GetCommitmentCtx ().SetStateReader (splitStateReader )
771771 sd .GetCommitmentCtx ().SetTrace (logger .Enabled (ctx , log .LvlTrace ))
772772 sd .GetCommitmentContext ().SetDeferBranchUpdates (false )
773773 latestTxNum , latestBlockNum , err := sd .SeekCommitment (ctx , tx ) // seek commitment again with new history state reader
774774 if err != nil {
775775 return err
776776 }
777- if latestBlockNum != blockNum {
778- return fmt .Errorf ("commitment state blockNum doesn't match blockNum: %d != %d" , latestBlockNum , blockNum )
777+ if blockNum > 0 && latestBlockNum != blockNum - 1 { // commitment domain reads branches at end of blockNum-1
778+ return fmt .Errorf ("commitment state blockNum doesn't match blockNum-1 : %d != %d" , latestBlockNum , blockNum - 1 )
779779 }
780- if latestTxNum != maxTxNum {
780+ if latestTxNum != minTxNum {
781781 return fmt .Errorf ("commitment state txNum doesn't match maxTxNum: %d != %d" , latestTxNum , maxTxNum )
782782 }
783783 logger .Info ("commitment recalc info" , "blockNum" , blockNum , "minTxNum" , minTxNum , "maxTxNum" , maxTxNum , "toTxNum" , toTxNum )
0 commit comments