mirror of
https://github.com/arnaucube/hermez-node.git
synced 2026-02-07 11:26:44 +01:00
Sync ForgerCommitment and use it in coord
Previously the coordinator was erroneously using Slot.BatchesLen to determine when anyone can forge. The correct behaviour is implmenented with the boolean flag `ForgerCommitment`, that is set to true only when there's a batch before the deadline within a slot. Delete Slot.BatchesLen, and the synchronization code of this value from the Synchronizer, as this is not needed
This commit is contained in:
@@ -190,9 +190,10 @@ func (c *Coordinator) syncSCVars(vars synchronizer.SCVariablesPtr) {
|
||||
|
||||
func (c *Coordinator) canForge(stats *synchronizer.Stats) bool {
|
||||
anyoneForge := false
|
||||
if stats.Sync.Auction.CurrentSlot.BatchesLen == 0 &&
|
||||
c.consts.Auction.RelativeBlock(stats.Eth.LastBlock.Num+1) > int64(c.vars.Auction.SlotDeadline) {
|
||||
log.Debug("Coordinator: anyone can forge in the current slot (slotDeadline passed)")
|
||||
if !stats.Sync.Auction.CurrentSlot.ForgerCommitment &&
|
||||
c.consts.Auction.RelativeBlock(stats.Eth.LastBlock.Num+1) >= int64(c.vars.Auction.SlotDeadline) {
|
||||
log.Debugw("Coordinator: anyone can forge in the current slot (slotDeadline passed)",
|
||||
"block", stats.Eth.LastBlock.Num)
|
||||
anyoneForge = true
|
||||
}
|
||||
if stats.Sync.Auction.CurrentSlot.Forger == c.cfg.ForgerAddress || anyoneForge {
|
||||
|
||||
Reference in New Issue
Block a user