mirror of
https://github.com/arnaucube/hermez-node.git
synced 2026-02-06 19:06:42 +01:00
Merge pull request #646 from hermeznetwork/fix/forgerCommitment
Fix Synchronizer not setting slot.ForgerCommitment to true
This commit is contained in:
@@ -335,7 +335,7 @@ func (s *Synchronizer) updateCurrentSlot(slot *common.Slot, reset bool, hasBatch
|
|||||||
// We want the next block because the current one is already mined
|
// We want the next block because the current one is already mined
|
||||||
blockNum := s.stats.Sync.LastBlock.Num + 1
|
blockNum := s.stats.Sync.LastBlock.Num + 1
|
||||||
slotNum := s.consts.Auction.SlotNum(blockNum)
|
slotNum := s.consts.Auction.SlotNum(blockNum)
|
||||||
firstBatchBlockNum := s.stats.Sync.LastBlock.Num
|
syncLastBlockNum := s.stats.Sync.LastBlock.Num
|
||||||
if reset {
|
if reset {
|
||||||
// Using this query only to know if there
|
// Using this query only to know if there
|
||||||
dbFirstBatchBlockNum, err := s.historyDB.GetFirstBatchBlockNumBySlot(slotNum)
|
dbFirstBatchBlockNum, err := s.historyDB.GetFirstBatchBlockNumBySlot(slotNum)
|
||||||
@@ -345,7 +345,7 @@ func (s *Synchronizer) updateCurrentSlot(slot *common.Slot, reset bool, hasBatch
|
|||||||
hasBatch = false
|
hasBatch = false
|
||||||
} else {
|
} else {
|
||||||
hasBatch = true
|
hasBatch = true
|
||||||
firstBatchBlockNum = dbFirstBatchBlockNum
|
syncLastBlockNum = dbFirstBatchBlockNum
|
||||||
}
|
}
|
||||||
slot.ForgerCommitment = false
|
slot.ForgerCommitment = false
|
||||||
} else if slotNum > slot.SlotNum {
|
} else if slotNum > slot.SlotNum {
|
||||||
@@ -354,16 +354,14 @@ func (s *Synchronizer) updateCurrentSlot(slot *common.Slot, reset bool, hasBatch
|
|||||||
}
|
}
|
||||||
slot.SlotNum = slotNum
|
slot.SlotNum = slotNum
|
||||||
slot.StartBlock, slot.EndBlock = s.consts.Auction.SlotBlocks(slot.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 Synced, update the current coordinator
|
||||||
if s.stats.Synced() && blockNum >= s.consts.Auction.GenesisBlockNum {
|
if s.stats.Synced() && blockNum >= s.consts.Auction.GenesisBlockNum {
|
||||||
if err := s.setSlotCoordinator(slot); err != nil {
|
if err := s.setSlotCoordinator(slot); err != nil {
|
||||||
return tracerr.Wrap(err)
|
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
|
// TODO: Remove this SANITY CHECK once this code is tested enough
|
||||||
// BEGIN SANITY CHECK
|
// BEGIN SANITY CHECK
|
||||||
|
|||||||
Reference in New Issue
Block a user