From 560b7e6c7b2ca1e350d8913ab776d92c4e45f50d Mon Sep 17 00:00:00 2001 From: Jeffery Walsh Date: Wed, 27 Sep 2023 19:47:36 -0700 Subject: [PATCH] fix logging and a test --- prover/capacity_manager/capacity_manager.go | 14 ++++++++++---- prover/config_test.go | 1 + 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/prover/capacity_manager/capacity_manager.go b/prover/capacity_manager/capacity_manager.go index f2145a493..1f0d0074d 100644 --- a/prover/capacity_manager/capacity_manager.go +++ b/prover/capacity_manager/capacity_manager.go @@ -44,7 +44,7 @@ func (m *CapacityManager) ReleaseOneCapacity(blockID uint64) (uint64, bool) { if _, ok := m.capacity[blockID]; !ok { log.Info("Can not release capacity", "blockID", blockID, - "currentCapacity", len(m.capacity), + "currentCapacity", m.maxCapacity-uint64(len(m.capacity)), "maxCapacity", m.maxCapacity) return uint64(len(m.capacity)), false } @@ -62,13 +62,17 @@ func (m *CapacityManager) TakeOneCapacity(blockID uint64) (uint64, bool) { defer m.mutex.Unlock() if len(m.capacity) == int(m.maxCapacity) { - log.Info("Could not take one capacity", "blockID", blockID, "capacity", len(m.capacity)) + log.Info("Could not take one capacity", + "blockID", blockID, + "currentCapacity", m.maxCapacity-uint64(len(m.capacity))) return 0, false } m.capacity[blockID] = true - log.Info("Took one capacity", "blockID", blockID, "capacityAfterTaking", len(m.capacity)) + log.Info("Took one capacity", + "blockID", blockID, + "capacityAfterTaking", m.maxCapacity-uint64(len(m.capacity))) return m.maxCapacity - uint64((len(m.capacity))), true } @@ -82,7 +86,9 @@ func (m *CapacityManager) TakeOneTempCapacity() (uint64, bool) { m.clearExpiredTempCapacities() if len(m.capacity)+len(m.tempCapacity) >= int(m.maxCapacity) { - log.Info("Could not take one temp capacity", "capacity", len(m.capacity), "tempCapacity", len(m.tempCapacity)) + log.Info("Could not take one temp capacity", + "capacity", m.maxCapacity-uint64(len(m.capacity)), + "tempCapacity", len(m.tempCapacity)) return 0, false } diff --git a/prover/config_test.go b/prover/config_test.go index 0f73d726c..130c507de 100644 --- a/prover/config_test.go +++ b/prover/config_test.go @@ -203,6 +203,7 @@ func (s *ProverTestSuite) SetupApp() *cli.App { &cli.Uint64Flag{Name: flags.ProverCapacity.Name}, &cli.Uint64Flag{Name: flags.MinProofFee.Name}, &cli.Uint64Flag{Name: flags.ProveBlockTxGasLimit.Name}, + &cli.DurationFlag{Name: flags.TempCapacityExpiresAt.Name}, } app.Action = func(ctx *cli.Context) error { _, err := NewConfigFromCliContext(ctx)