From 968fcc207e3c95edb057b571baaf2b597c9eb140 Mon Sep 17 00:00:00 2001 From: Pantani Date: Thu, 11 Mar 2021 23:26:17 -0300 Subject: [PATCH] Add the option to force or not a forgeBatch at the beginning of the slot --- cli/node/cfg.buidler.toml | 1 + config/config.go | 5 +++++ coordinator/coordinator.go | 5 +++++ coordinator/pipeline.go | 2 +- node/node.go | 1 + 5 files changed, 13 insertions(+), 1 deletion(-) diff --git a/cli/node/cfg.buidler.toml b/cli/node/cfg.buidler.toml index 6951813..940d8a6 100644 --- a/cli/node/cfg.buidler.toml +++ b/cli/node/cfg.buidler.toml @@ -64,6 +64,7 @@ ForgeDelay = "10s" ForgeNoTxsDelay = "0s" PurgeByExtDelInterval = "1m" MustForgeAtSlotDeadline = true +IgnoreSlotCommitment = false [Coordinator.FeeAccount] Address = "0x56232B1c5B10038125Bc7345664B4AFD745bcF8E" diff --git a/config/config.go b/config/config.go index f35b361..cb3d451 100644 --- a/config/config.go +++ b/config/config.go @@ -104,6 +104,11 @@ type Coordinator struct { // MustForgeAtSlotDeadline enables the coordinator to forge slots if // the empty slots reach the slot deadline. MustForgeAtSlotDeadline bool + // IgnoreSlotCommitment IgnoreSlotCommitment disables forcing the + // coordinator to forge a slot immediately when the slot is not + // committed. If set to false, the coordinator will immediately forge + // a batch at the beginning of a slot if it's the slot winner. + IgnoreSlotCommitment bool // SyncRetryInterval is the waiting interval between calls to the main // handler of a synced block after an error SyncRetryInterval Duration `validate:"required"` diff --git a/coordinator/coordinator.go b/coordinator/coordinator.go index 12a5ef2..a1d3aa9 100644 --- a/coordinator/coordinator.go +++ b/coordinator/coordinator.go @@ -87,6 +87,11 @@ type Config struct { // MustForgeAtSlotDeadline enables the coordinator to forge slots if // the empty slots reach the slot deadline. MustForgeAtSlotDeadline bool + // IgnoreSlotCommitment disables forcing the coordinator to forge a + // slot immediately when the slot is not committed. If set to false, + // the coordinator will immediately forge a batch at the beginning of + // a slot if it's the slot winner. + IgnoreSlotCommitment bool // SyncRetryInterval is the waiting interval between calls to the main // handler of a synced block after an error SyncRetryInterval time.Duration diff --git a/coordinator/pipeline.go b/coordinator/pipeline.go index d272587..149d49d 100644 --- a/coordinator/pipeline.go +++ b/coordinator/pipeline.go @@ -414,7 +414,7 @@ func (p *Pipeline) forgeBatch(batchNum common.BatchNum) (batchInfo *BatchInfo, e var coordIdxs []common.Idx // Check if the slot is not yet fulfilled - slotCommitted := false + slotCommitted := p.cfg.IgnoreSlotCommitment if p.stats.Sync.Auction.CurrentSlot.ForgerCommitment || p.stats.Sync.Auction.CurrentSlot.SlotNum == p.state.lastSlotForged { slotCommitted = true diff --git a/node/node.go b/node/node.go index 6cdb060..4d94343 100644 --- a/node/node.go +++ b/node/node.go @@ -338,6 +338,7 @@ func NewNode(mode Mode, cfg *config.Node) (*Node, error) { ForgeRetryInterval: cfg.Coordinator.ForgeRetryInterval.Duration, ForgeDelay: cfg.Coordinator.ForgeDelay.Duration, MustForgeAtSlotDeadline: cfg.Coordinator.MustForgeAtSlotDeadline, + IgnoreSlotCommitment: cfg.Coordinator.IgnoreSlotCommitment, ForgeNoTxsDelay: cfg.Coordinator.ForgeNoTxsDelay.Duration, SyncRetryInterval: cfg.Coordinator.SyncRetryInterval.Duration, PurgeByExtDelInterval: cfg.Coordinator.PurgeByExtDelInterval.Duration,