Merge pull request #646 from hermeznetwork/fix/forgerCommitment Fix Synchronizer not setting slot.ForgerCommitment to true
Eduard S eduard@iden3.io
Wed, 17 Mar 2021 13:53:07 +0100
1 files changed,
5 insertions(+),
7 deletions(-)
jump to
M
synchronizer/synchronizer.go
→
synchronizer/synchronizer.go
@@ -335,7 +335,7 @@ func (s *Synchronizer) updateCurrentSlot(slot *common.Slot, reset bool, hasBatch bool) error {
// We want the next block because the current one is already mined blockNum := s.stats.Sync.LastBlock.Num + 1 slotNum := s.consts.Auction.SlotNum(blockNum) - firstBatchBlockNum := s.stats.Sync.LastBlock.Num + syncLastBlockNum := s.stats.Sync.LastBlock.Num if reset { // Using this query only to know if there dbFirstBatchBlockNum, err := s.historyDB.GetFirstBatchBlockNumBySlot(slotNum)@@ -345,7 +345,7 @@ } else if tracerr.Unwrap(err) == sql.ErrNoRows {
hasBatch = false } else { hasBatch = true - firstBatchBlockNum = dbFirstBatchBlockNum + syncLastBlockNum = dbFirstBatchBlockNum } slot.ForgerCommitment = false } else if slotNum > slot.SlotNum {@@ -354,15 +354,13 @@ slot.ForgerCommitment = false
} slot.SlotNum = slotNum slot.StartBlock, slot.EndBlock = s.consts.Auction.SlotBlocks(slot.SlotNum) + if hasBatch && s.consts.Auction.RelativeBlock(syncLastBlockNum) < int64(s.vars.Auction.SlotDeadline) { + slot.ForgerCommitment = true + } // If Synced, update the current coordinator if s.stats.Synced() && blockNum >= s.consts.Auction.GenesisBlockNum { if err := s.setSlotCoordinator(slot); err != nil { return tracerr.Wrap(err) - } - if hasBatch && - s.consts.Auction.RelativeBlock(firstBatchBlockNum) < - int64(s.vars.Auction.SlotDeadline) { - slot.ForgerCommitment = true } // TODO: Remove this SANITY CHECK once this code is tested enough