From 22014b2f2b9bf4f35590273c64b888920ce82ffc Mon Sep 17 00:00:00 2001 From: jeff <113397187+cyberhorsey@users.noreply.github.com> Date: Mon, 25 Sep 2023 22:09:06 -0700 Subject: [PATCH] feat(prover): add more capacity related logs (#408) Co-authored-by: David --- pkg/rpc/utils.go | 6 ++++++ prover/capacity_manager/capacity_manager.go | 13 ++++++++++++- prover/server/api.go | 14 +++++++++++++- 3 files changed, 31 insertions(+), 2 deletions(-) diff --git a/pkg/rpc/utils.go b/pkg/rpc/utils.go index 664254c37..d889d884e 100644 --- a/pkg/rpc/utils.go +++ b/pkg/rpc/utils.go @@ -54,6 +54,8 @@ func CheckProverBalance( return false, err } + log.Info("Prover's deposited taikoTokenBalance", "balance", depositedBalance.String(), "address", prover.Hex()) + if bond.Cmp(depositedBalance) > 0 { // Check allowance on taiko token contract allowance, err := rpc.TaikoToken.Allowance(&bind.CallOpts{Context: ctxWithTimeout}, prover, taikoL1Address) @@ -61,12 +63,16 @@ func CheckProverBalance( return false, err } + log.Info("Prover allowance for TaikoL1 contract", "allowance", allowance.String(), "address", prover.Hex()) + // Check prover's taiko token balance balance, err := rpc.TaikoToken.BalanceOf(&bind.CallOpts{Context: ctxWithTimeout}, prover) if err != nil { return false, err } + log.Info("Prover's wallet taiko token balance", "balance", balance.String(), "address", prover.Hex()) + if bond.Cmp(allowance) > 0 || bond.Cmp(balance) > 0 { log.Info( "Assigned prover does not have required on-chain token balance or allowance", diff --git a/prover/capacity_manager/capacity_manager.go b/prover/capacity_manager/capacity_manager.go index 27355c4fd..78164f1cf 100644 --- a/prover/capacity_manager/capacity_manager.go +++ b/prover/capacity_manager/capacity_manager.go @@ -2,6 +2,8 @@ package capacity_manager import ( "sync" + + "github.com/ethereum/go-ethereum/log" ) // CapacityManager manages the prover capacity concurrent-safely. @@ -20,6 +22,8 @@ func (m *CapacityManager) ReadCapacity() uint64 { m.mutex.RLock() defer m.mutex.RUnlock() + log.Info("Reading capacity", "capacity", m.capacity) + return m.capacity } @@ -29,18 +33,25 @@ func (m *CapacityManager) ReleaseOneCapacity() uint64 { defer m.mutex.Unlock() m.capacity += 1 + + log.Info("Released capacity", "capacityAfterRelease", m.capacity) + return m.capacity } -// TakeOneCapacity takes one capacitĀ·y. +// TakeOneCapacity takes one capacity. func (m *CapacityManager) TakeOneCapacity() (uint64, bool) { m.mutex.Lock() defer m.mutex.Unlock() if m.capacity == 0 { + log.Info("Could not take one capacity", "capacity", m.capacity) return 0, false } m.capacity -= 1 + + log.Info("Took one capacity", "capacityAfterTaking", m.capacity) + return m.capacity, true } diff --git a/prover/server/api.go b/prover/server/api.go index 8045494ab..921d81145 100644 --- a/prover/server/api.go +++ b/prover/server/api.go @@ -80,15 +80,27 @@ func (srv *ProverServer) CreateAssignment(c echo.Context) error { } if req.Fee.Cmp(srv.minProofFee) < 0 { + log.Warn( + "Proof fee too low", + "reqFee", req.Fee.String(), + "srvMinProofFee", srv.minProofFee.String(), + "proposerIP", c.RealIP(), + ) return echo.NewHTTPError(http.StatusUnprocessableEntity, "proof fee too low") } if req.Expiry > uint64(time.Now().Add(srv.maxExpiry).Unix()) { + log.Warn( + "Expiry too long", + "requestExpiry", req.Expiry, + "srvMaxExpiry", srv.maxExpiry, + "proposerIP", c.RealIP(), + ) return echo.NewHTTPError(http.StatusUnprocessableEntity, "expiry too long") } if srv.capacityManager.ReadCapacity() == 0 { - log.Warn("Prover does not have capacity") + log.Warn("Prover does not have capacity", "proposerIP", c.RealIP()) return echo.NewHTTPError(http.StatusUnprocessableEntity, "prover does not have capacity") }