From 8972ee1d70ae08736f74348e3467880e712e9a30 Mon Sep 17 00:00:00 2001 From: David Date: Thu, 21 Dec 2023 10:00:05 +0800 Subject: [PATCH] feat(prover): remove capacity manager (#478) --- go.mod | 2 +- prover/capacity_manager/capacity_manager.go | 102 --------------- .../capacity_manager/capacity_manager_test.go | 53 -------- prover/capacity_manager/slots_manager.go | 119 ----------------- prover/capacity_manager/slots_manager_test.go | 123 ------------------ prover/prover.go | 41 ------ prover/prover_test.go | 5 - prover/server/api.go | 6 +- prover/server/api_test.go | 1 - prover/server/server.go | 7 +- prover/server/server_test.go | 3 +- testutils/helper.go | 4 +- testutils/suite.go | 3 +- 13 files changed, 9 insertions(+), 460 deletions(-) delete mode 100644 prover/capacity_manager/capacity_manager.go delete mode 100644 prover/capacity_manager/capacity_manager_test.go delete mode 100644 prover/capacity_manager/slots_manager.go delete mode 100644 prover/capacity_manager/slots_manager_test.go diff --git a/go.mod b/go.mod index 8edc069c5..87a89e920 100644 --- a/go.mod +++ b/go.mod @@ -9,6 +9,7 @@ require ( github.com/ethereum/go-ethereum v1.13.4 github.com/go-resty/resty/v2 v2.7.0 github.com/labstack/echo/v4 v4.11.1 + github.com/labstack/gommon v0.4.0 github.com/phayes/freeport v0.0.0-20220201140144-74d24b5ae9f5 github.com/prysmaticlabs/prysm/v4 v4.0.1 github.com/stretchr/testify v1.8.4 @@ -63,7 +64,6 @@ require ( github.com/klauspost/cpuid/v2 v2.2.4 // indirect github.com/kr/pretty v0.3.1 // indirect github.com/kr/text v0.2.0 // indirect - github.com/labstack/gommon v0.4.0 // indirect github.com/mailru/easyjson v0.7.7 // indirect github.com/mattn/go-colorable v0.1.13 // indirect github.com/mattn/go-isatty v0.0.19 // indirect diff --git a/prover/capacity_manager/capacity_manager.go b/prover/capacity_manager/capacity_manager.go deleted file mode 100644 index d1c8c0ff3..000000000 --- a/prover/capacity_manager/capacity_manager.go +++ /dev/null @@ -1,102 +0,0 @@ -package capacity_manager - -import ( - "sync" - "time" - - "github.com/ethereum/go-ethereum/log" -) - -// CapacityManager manages the prover capacity concurrent-safely. -type CapacityManager struct { - slotsManager *slotsManager - mutex sync.RWMutex -} - -// New creates a new CapacityManager instance. -func New(capacity uint64) *CapacityManager { - return &CapacityManager{ - slotsManager: &slotsManager{[]*capacitySlot{}, capacity}, - } -} - -// ReadCapacity reads the current capacity. -func (m *CapacityManager) ReadCapacity() uint64 { - m.mutex.RLock() - defer m.mutex.RUnlock() - - log.Info( - "Reading capacity", - "maxCapacity", m.slotsManager.MaxSlots(), - "currentCapacity", m.slotsManager.MaxSlots()-m.slotsManager.Len(), - "currentUsage", m.slotsManager.Len(), - ) - - return m.slotsManager.MaxSlots() - m.slotsManager.Len() -} - -// ReleaseOneCapacity releases one capacity. -func (m *CapacityManager) ReleaseOneCapacity(blockID uint64) (uint64, bool) { - m.mutex.Lock() - defer m.mutex.Unlock() - - if blockID == BlockIDPlaceHolder { - return m.slotsManager.MaxSlots() - m.slotsManager.Len(), false - } - - if ok := m.slotsManager.removeItemByBlockID(blockID); !ok { - log.Info( - "Can not release capacity", - "blockID", blockID, - "maxCapacity", m.slotsManager.MaxSlots(), - "currentCapacity", m.slotsManager.MaxSlots()-m.slotsManager.Len(), - "currentUsage", m.slotsManager.Len(), - ) - return m.slotsManager.MaxSlots() - m.slotsManager.Len(), false - } - - log.Info( - "Released capacity", - "blockID", blockID, - "maxCapacity", m.slotsManager.MaxSlots(), - "currentCapacity", m.slotsManager.MaxSlots()-m.slotsManager.Len(), - "currentUsage", m.slotsManager.Len(), - ) - - return m.slotsManager.MaxSlots() - m.slotsManager.Len(), true -} - -func (m *CapacityManager) HoldOneCapacity(expiry time.Duration) bool { - m.mutex.Lock() - defer m.mutex.Unlock() - - return m.slotsManager.HoldOneSlot(expiry) -} - -// TakeOneCapacity takes one capacity. -func (m *CapacityManager) TakeOneCapacity(blockID uint64) (uint64, bool) { - m.mutex.Lock() - defer m.mutex.Unlock() - - if ok := m.slotsManager.TakeOneSlot(blockID); !ok { - log.Info( - "Could not take one capacity", - "blockID", blockID, - "maxCapacity", m.slotsManager.MaxSlots(), - "currentCapacity", m.slotsManager.MaxSlots()-m.slotsManager.Len(), - "currentUsage", m.slotsManager.Len(), - ) - - return m.slotsManager.MaxSlots() - m.slotsManager.Len(), true - } - - log.Info( - "Took one capacity", - "blockID", blockID, - "maxCapacity", m.slotsManager.MaxSlots(), - "currentCapacity", m.slotsManager.MaxSlots()-m.slotsManager.Len(), - "currentUsage", m.slotsManager.Len(), - ) - - return m.slotsManager.MaxSlots() - m.slotsManager.Len(), true -} diff --git a/prover/capacity_manager/capacity_manager_test.go b/prover/capacity_manager/capacity_manager_test.go deleted file mode 100644 index 62c8c13be..000000000 --- a/prover/capacity_manager/capacity_manager_test.go +++ /dev/null @@ -1,53 +0,0 @@ -package capacity_manager - -import ( - "testing" - "time" - - "github.com/stretchr/testify/suite" -) - -var ( - testCapacity uint64 = 5 -) - -type CapacityManagerTestSuite struct { - suite.Suite - m *CapacityManager -} - -func (s *CapacityManagerTestSuite) SetupTest() { - s.m = New(testCapacity) -} - -func (s *CapacityManagerTestSuite) TestReadCapacity() { - s.Equal(testCapacity, s.m.ReadCapacity()) -} - -func (s *CapacityManagerTestSuite) TestTakeOneCapacity() { - s.True(s.m.HoldOneCapacity(1 * time.Minute)) - capacity, ok := s.m.TakeOneCapacity(1) - s.True(ok) - s.Equal(testCapacity-1, capacity) - s.Equal(testCapacity-1, s.m.ReadCapacity()) -} - -func (s *CapacityManagerTestSuite) TestReleaseOneCapacity() { - var blockID uint64 = 1 - _, released := s.m.ReleaseOneCapacity(blockID) - s.Equal(false, released) - - s.True(s.m.HoldOneCapacity(1 * time.Minute)) - _, ok := s.m.TakeOneCapacity(blockID) - s.True(ok) - - capacity, released := s.m.ReleaseOneCapacity(blockID) - s.True(released) - - s.Equal(testCapacity, capacity) - s.Equal(testCapacity, s.m.ReadCapacity()) -} - -func TestCapacityManagerTestSuite(t *testing.T) { - suite.Run(t, new(CapacityManagerTestSuite)) -} diff --git a/prover/capacity_manager/slots_manager.go b/prover/capacity_manager/slots_manager.go deleted file mode 100644 index 89297631b..000000000 --- a/prover/capacity_manager/slots_manager.go +++ /dev/null @@ -1,119 +0,0 @@ -package capacity_manager - -import ( - "sort" - "time" -) - -// BlockIDPlaceHolder is a special blockID which represents a temporarily holen slot with no blockID. -const BlockIDPlaceHolder = 0 - -// capacitySlot represents a block slot with an expired time. -type capacitySlot struct { - blockID uint64 - expiredAt *time.Time -} - -// slotsManager manages all the block slots with a max capacity. -type slotsManager struct { - slots []*capacitySlot - maxSlots uint64 -} - -// sort sorts the slots by expired time, if a slot has no expired time, it will be put at the end. -func (s *slotsManager) sort() { - sort.Slice(s.slots, func(i, j int) bool { - if s.slots[i].expiredAt == nil && s.slots[j].expiredAt == nil { - return false - } - if s.slots[i].expiredAt == nil && s.slots[j].expiredAt != nil { - return false - } - if s.slots[i].expiredAt != nil && s.slots[j].expiredAt == nil { - return true - } - - return s.slots[i].expiredAt.Before(*s.slots[j].expiredAt) - }) -} - -// removeItemByBlockID removes a slot by blockID, if the blockID is BlockIDPlaceHolder, -// it will remove the first slot with expired time, otherwise it will remove the slot with the blockID. -func (s *slotsManager) removeItemByBlockID(id uint64) bool { - defer s.sort() - - if len(s.slots) == 0 { - return false - } - - if id == BlockIDPlaceHolder { - if s.slots[0].expiredAt != nil { - s.slots[0] = s.slots[len(s.slots)-1] - s.slots = s.slots[:len(s.slots)-1] - return true - } - - return false - } - - for i := range s.slots { - if s.slots[i].blockID == id { - s.slots[i] = s.slots[len(s.slots)-1] - s.slots = s.slots[:len(s.slots)-1] - return true - } - } - - return false -} - -// clearOneExpiredSlots tries to remove one expired slot. -func (s *slotsManager) clearOneExpiredSlots() { - defer s.sort() - - for i := range s.slots { - if s.slots[i].expiredAt != nil && s.slots[i].expiredAt.Before(time.Now()) { - s.slots[i] = s.slots[len(s.slots)-1] - s.slots = s.slots[:len(s.slots)-1] - return - } - } -} - -// HoldOneSlot holds one slot with an expired time. -func (s *slotsManager) HoldOneSlot(expiry time.Duration) bool { - defer s.sort() - - s.clearOneExpiredSlots() - - if len(s.slots) >= int(s.maxSlots) { - return false - } - - expiredAt := time.Now().Add(expiry) - s.slots = append(s.slots, &capacitySlot{blockID: BlockIDPlaceHolder, expiredAt: &expiredAt}) - return true -} - -// TakeOneSlot tries to taken one holden slot (blockID == BlockIDPlaceHolder), if there is no holden slot, -// it will return false. -func (s *slotsManager) TakeOneSlot(blockID uint64) bool { - defer s.sort() - - if ok := s.removeItemByBlockID(BlockIDPlaceHolder); !ok { - return false - } - - s.slots = append(s.slots, &capacitySlot{blockID: blockID}) - return true -} - -// Len returns the current usage of the slots. -func (s *slotsManager) Len() uint64 { - return uint64(len(s.slots)) -} - -// MaxSlots returns the max capacity of the slots. -func (s *slotsManager) MaxSlots() uint64 { - return s.maxSlots -} diff --git a/prover/capacity_manager/slots_manager_test.go b/prover/capacity_manager/slots_manager_test.go deleted file mode 100644 index 9533a8e25..000000000 --- a/prover/capacity_manager/slots_manager_test.go +++ /dev/null @@ -1,123 +0,0 @@ -package capacity_manager - -import ( - "testing" - "time" - - "github.com/stretchr/testify/suite" -) - -type SlotsManagerTestSuite struct { - suite.Suite - m *slotsManager -} - -func (s *SlotsManagerTestSuite) SetupTest() { - now := time.Now() - oneHourLater := time.Now().Add(1 * time.Hour) - - s.m = &slotsManager{[]*capacitySlot{ - {blockID: BlockIDPlaceHolder, expiredAt: &now}, - {blockID: BlockIDPlaceHolder, expiredAt: &oneHourLater}, - {blockID: 3, expiredAt: nil}, - }, testCapacity} -} - -func (s *SlotsManagerTestSuite) TestSort() { - now := time.Now() - oneHourLater := time.Now().Add(1 * time.Hour) - - s.m.slots = []*capacitySlot{ - {blockID: 1, expiredAt: nil}, - {blockID: 2, expiredAt: &oneHourLater}, - {blockID: 3, expiredAt: &now}, - } - - s.m.sort() - s.Equal(3, int(s.m.slots[0].blockID)) - s.Equal(2, int(s.m.slots[1].blockID)) - s.Equal(1, int(s.m.slots[2].blockID)) - - s.m.slots = []*capacitySlot{ - {blockID: 1, expiredAt: &now}, - {blockID: 2, expiredAt: &oneHourLater}, - {blockID: 3, expiredAt: nil}, - } - - s.m.sort() - s.Equal(1, int(s.m.slots[0].blockID)) - s.Equal(2, int(s.m.slots[1].blockID)) - s.Equal(3, int(s.m.slots[2].blockID)) -} - -func (s *SlotsManagerTestSuite) TestRemoveItemByBlockID() { - s.True(s.m.removeItemByBlockID(3)) - s.Equal(2, len(s.m.slots)) - s.Equal(BlockIDPlaceHolder, int(s.m.slots[0].blockID)) - s.Equal(BlockIDPlaceHolder, int(s.m.slots[1].blockID)) -} - -func (s *SlotsManagerTestSuite) TestRemoveItemByBlockIDWithPlaceHolder() { - s.True(s.m.removeItemByBlockID(BlockIDPlaceHolder)) - s.Equal(2, len(s.m.slots)) - s.Equal(BlockIDPlaceHolder, int(s.m.slots[0].blockID)) - s.Equal(3, int(s.m.slots[1].blockID)) -} - -func (s *SlotsManagerTestSuite) TestClearOneExpiredSlots() { - oneHourBefore := time.Now().Add(-1 * time.Hour) - - s.m.slots = []*capacitySlot{ - {blockID: 1, expiredAt: &oneHourBefore}, - {blockID: 2, expiredAt: nil}, - {blockID: 3, expiredAt: nil}, - } - - s.m.clearOneExpiredSlots() - - s.Equal(2, len(s.m.slots)) - s.Equal(3, int(s.m.slots[0].blockID)) - s.Equal(2, int(s.m.slots[1].blockID)) -} - -func (s *SlotsManagerTestSuite) TestHoldOneSlot() { - oneHourLater := time.Now().Add(1 * time.Hour) - twoHoursLater := time.Now().Add(2 * time.Hour) - - s.m = &slotsManager{[]*capacitySlot{ - {blockID: BlockIDPlaceHolder, expiredAt: &oneHourLater}, - {blockID: BlockIDPlaceHolder, expiredAt: &twoHoursLater}, - {blockID: 3, expiredAt: nil}, - }, testCapacity} - - s.m.HoldOneSlot(30 * time.Minute) - - s.Equal(uint64(4), s.m.Len()) -} - -func (s *SlotsManagerTestSuite) TestTakeOneSlot() { - oneHourLater := time.Now().Add(1 * time.Hour) - twoHoursLater := time.Now().Add(2 * time.Hour) - - s.m = &slotsManager{[]*capacitySlot{ - {blockID: BlockIDPlaceHolder, expiredAt: &oneHourLater}, - {blockID: BlockIDPlaceHolder, expiredAt: &twoHoursLater}, - {blockID: 3, expiredAt: nil}, - }, testCapacity} - - s.m.TakeOneSlot(4) - - s.Equal(uint64(3), s.m.Len()) - - for _, slot := range s.m.slots { - if slot.blockID == 4 { - return - } - } - - s.FailNow("slot has not been taken correctly") -} - -func TestSlotsManagerTestSuite(t *testing.T) { - suite.Run(t, new(SlotsManagerTestSuite)) -} diff --git a/prover/prover.go b/prover/prover.go index dee3ea229..48bb4b784 100644 --- a/prover/prover.go +++ b/prover/prover.go @@ -25,7 +25,6 @@ import ( "github.com/taikoxyz/taiko-client/metrics" eventIterator "github.com/taikoxyz/taiko-client/pkg/chain_iterator/event_iterator" "github.com/taikoxyz/taiko-client/pkg/rpc" - capacity "github.com/taikoxyz/taiko-client/prover/capacity_manager" guardianproversender "github.com/taikoxyz/taiko-client/prover/guardian_prover_sender" proofProducer "github.com/taikoxyz/taiko-client/prover/proof_producer" proofSubmitter "github.com/taikoxyz/taiko-client/prover/proof_submitter" @@ -34,7 +33,6 @@ import ( ) var ( - errNoCapacity = errors.New("no prover capacity available") errTierNotFound = errors.New("tier not found") ) @@ -88,9 +86,6 @@ type Prover struct { proposeConcurrencyGuard chan struct{} submitProofConcurrencyGuard chan struct{} - // Capacity-related configs - capacityManager *capacity.CapacityManager - ctx context.Context wg sync.WaitGroup } @@ -109,7 +104,6 @@ func (p *Prover) InitFromCli(ctx context.Context, c *cli.Context) error { func InitFromConfig(ctx context.Context, p *Prover, cfg *Config) (err error) { p.cfg = cfg p.ctx = ctx - p.capacityManager = capacity.New(cfg.Capacity) p.proverPrivateKey = cfg.L1ProverPrivKey // Clients @@ -288,7 +282,6 @@ func InitFromConfig(ctx context.Context, p *Prover, cfg *Config) (err error) { MinSgxAndPseZkevmTierFee: p.cfg.MinSgxAndPseZkevmTierFee, MaxExpiry: p.cfg.MaxExpiry, MaxBlockSlippage: p.cfg.MaxBlockSlippage, - CapacityManager: p.capacityManager, TaikoL1Address: p.cfg.TaikoL1Address, AssignmentHookAddress: p.cfg.AssignmentHookAddress, Rpc: p.rpc, @@ -788,11 +781,6 @@ func (p *Prover) handleNewBlockProposedEvent(ctx context.Context, e *bindings.Ta metrics.ProverProofsAssigned.Inc(1) - // Make sure to take a capacity before requesting proof. - if err := p.takeOneCapacity(e.BlockId); err != nil { - return err - } - if proofSubmitter := p.selectSubmitter(e.Meta.MinTier); proofSubmitter != nil { return proofSubmitter.RequestProof(ctx, e) } @@ -845,7 +833,6 @@ func (p *Prover) submitProofOp(ctx context.Context, proofWithHeader *proofProduc defer func() { <-p.submitProofConcurrencyGuard - p.releaseOneCapacity(proofWithHeader.BlockID) }() if err := backoff.Retry( @@ -956,9 +943,6 @@ func (p *Prover) onTransitionProved(ctx context.Context, event *bindings.TaikoL1 if err := proofSubmitter.Producer().Cancel(ctx, event.BlockId); err != nil { return err } - // No need to check if the release is successful here, since this L2 block might - // be assigned to other provers. - p.capacityManager.ReleaseOneCapacity(event.BlockId.Uint64()) } // If this prover is in contest mode, we check the validity of this proof and if it's invalid, @@ -1151,11 +1135,6 @@ func (p *Prover) requestProofByBlockID( return nil } - // Make sure to take a capacity before requesting proof. - if err := p.takeOneCapacity(event.BlockId); err != nil { - return err - } - if transitionProvedEvent != nil { return p.proofContester.SubmitContest( ctx, @@ -1308,26 +1287,6 @@ func (p *Prover) IsGuardianProver() bool { return p.cfg.GuardianProverAddress != common.Address{} } -// takeOneCapacity takes one capacity from the capacity manager. -func (p *Prover) takeOneCapacity(blockID *big.Int) error { - if !p.IsGuardianProver() { - if _, ok := p.capacityManager.TakeOneCapacity(blockID.Uint64()); !ok { - return errNoCapacity - } - } - - return nil -} - -// releaseOneCapacity releases one capacity to the capacity manager. -func (p *Prover) releaseOneCapacity(blockID *big.Int) { - if !p.IsGuardianProver() { - if _, released := p.capacityManager.ReleaseOneCapacity(blockID.Uint64()); !released { - log.Error("Failed to release capacity", "id", blockID) - } - } -} - // heartbeatInterval sends a heartbeat to the guardian prover health check server // on an interval func (p *Prover) heartbeatInterval(ctx context.Context) { diff --git a/prover/prover_test.go b/prover/prover_test.go index f291edc39..14d26c4db 100644 --- a/prover/prover_test.go +++ b/prover/prover_test.go @@ -77,7 +77,6 @@ func (s *ProverTestSuite) SetupTest() { p.srv = testutils.NewTestProverServer( &s.ClientTestSuite, l1ProverPrivKey, - p.capacityManager, proverServerUrl, ) @@ -383,10 +382,6 @@ func (s *ProverTestSuite) TestProveOp() { s.Equal(header.ParentHash, common.BytesToHash(event.Tran.ParentHash[:])) } -func (s *ProverTestSuite) TestReleaseOneCapacity() { - s.NotPanics(func() { s.p.releaseOneCapacity(common.Big1) }) -} - func (s *ProverTestSuite) TestStartSubscription() { s.NotPanics(s.p.initSubscription) s.NotPanics(s.p.closeSubscription) diff --git a/prover/server/api.go b/prover/server/api.go index 1a47b25de..c29728bb8 100644 --- a/prover/server/api.go +++ b/prover/server/api.go @@ -38,7 +38,6 @@ type Status struct { MinSgxTierFee uint64 `json:"minSgxTierFee"` MinPseZkevmTierFee uint64 `json:"minPseZkevmTierFee"` MaxExpiry uint64 `json:"maxExpiry"` - CurrentCapacity uint64 `json:"currentCapacity"` Prover string `json:"prover"` } @@ -56,7 +55,6 @@ func (srv *ProverServer) GetStatus(c echo.Context) error { MinSgxTierFee: srv.minSgxTierFee.Uint64(), MinPseZkevmTierFee: srv.minPseZkevmTierFee.Uint64(), MaxExpiry: uint64(srv.maxExpiry.Seconds()), - CurrentCapacity: srv.capacityManager.ReadCapacity(), Prover: srv.proverAddress.Hex(), }) } @@ -170,8 +168,8 @@ func (srv *ProverServer) CreateAssignment(c echo.Context) error { return echo.NewHTTPError(http.StatusUnprocessableEntity, "expiry too long") } - if ok := srv.capacityManager.HoldOneCapacity(time.Duration(req.Expiry) * time.Second); !ok { - log.Warn("Prover unable to hold a capacity", "proposerIP", c.RealIP()) + // Check if the prover has any capacity now. + if len(srv.proposeConcurrencyGuard) == cap(srv.proposeConcurrencyGuard) { return echo.NewHTTPError(http.StatusUnprocessableEntity, "prover does not have capacity") } diff --git a/prover/server/api_test.go b/prover/server/api_test.go index 19f91801e..7482fa40e 100644 --- a/prover/server/api_test.go +++ b/prover/server/api_test.go @@ -26,7 +26,6 @@ func (s *ProverServerTestSuite) TestGetStatusSuccess() { s.Equal(s.s.minSgxTierFee.Uint64(), status.MinSgxTierFee) s.Equal(s.s.minSgxAndPseZkevmTierFee.Uint64(), status.MinSgxTierFee) s.Equal(uint64(s.s.maxExpiry.Seconds()), status.MaxExpiry) - s.Greater(status.CurrentCapacity, uint64(0)) s.NotEmpty(status.Prover) } diff --git a/prover/server/server.go b/prover/server/server.go index c712fe291..b65e04ca6 100644 --- a/prover/server/server.go +++ b/prover/server/server.go @@ -14,7 +14,6 @@ import ( echo "github.com/labstack/echo/v4" "github.com/labstack/echo/v4/middleware" "github.com/taikoxyz/taiko-client/pkg/rpc" - capacity "github.com/taikoxyz/taiko-client/prover/capacity_manager" ) // @title Taiko Prover API @@ -41,7 +40,7 @@ type ProverServer struct { maxExpiry time.Duration maxSlippage uint64 maxProposedIn uint64 - capacityManager *capacity.CapacityManager + proposeConcurrencyGuard chan struct{} taikoL1Address common.Address assignmentHookAddress common.Address rpc *rpc.Client @@ -60,7 +59,7 @@ type NewProverServerOpts struct { MaxExpiry time.Duration MaxBlockSlippage uint64 MaxProposedIn uint64 - CapacityManager *capacity.CapacityManager + ProposeConcurrencyGuard chan struct{} TaikoL1Address common.Address AssignmentHookAddress common.Address Rpc *rpc.Client @@ -82,7 +81,7 @@ func New(opts *NewProverServerOpts) (*ProverServer, error) { maxExpiry: opts.MaxExpiry, maxProposedIn: opts.MaxProposedIn, maxSlippage: opts.MaxBlockSlippage, - capacityManager: opts.CapacityManager, + proposeConcurrencyGuard: opts.ProposeConcurrencyGuard, taikoL1Address: opts.TaikoL1Address, assignmentHookAddress: opts.AssignmentHookAddress, rpc: opts.Rpc, diff --git a/prover/server/server_test.go b/prover/server/server_test.go index 50f971e45..1890f0e85 100644 --- a/prover/server/server_test.go +++ b/prover/server/server_test.go @@ -19,7 +19,6 @@ import ( "github.com/phayes/freeport" "github.com/stretchr/testify/suite" "github.com/taikoxyz/taiko-client/pkg/rpc" - capacity "github.com/taikoxyz/taiko-client/prover/capacity_manager" ) type ProverServerTestSuite struct { @@ -53,7 +52,7 @@ func (s *ProverServerTestSuite) SetupTest() { MinPseZkevmTierFee: common.Big1, MinSgxAndPseZkevmTierFee: common.Big1, MaxExpiry: time.Hour, - CapacityManager: capacity.New(1024), + ProposeConcurrencyGuard: make(chan struct{}, 1024), TaikoL1Address: common.HexToAddress(os.Getenv("TAIKO_L1_ADDRESS")), AssignmentHookAddress: common.HexToAddress(os.Getenv("ASSIGNMENT_HOOK_ADDRESS")), Rpc: rpcClient, diff --git a/testutils/helper.go b/testutils/helper.go index 1204bb1ed..edb29f7a6 100644 --- a/testutils/helper.go +++ b/testutils/helper.go @@ -21,7 +21,6 @@ import ( "github.com/go-resty/resty/v2" "github.com/phayes/freeport" "github.com/taikoxyz/taiko-client/bindings" - capacity "github.com/taikoxyz/taiko-client/prover/capacity_manager" "github.com/taikoxyz/taiko-client/prover/server" ) @@ -175,7 +174,6 @@ func DepositEtherToL2(s *ClientTestSuite, depositerPrivKey *ecdsa.PrivateKey, re func NewTestProverServer( s *ClientTestSuite, proverPrivKey *ecdsa.PrivateKey, - capacityManager *capacity.CapacityManager, url *url.URL, ) *server.ProverServer { protocolConfig, err := s.RpcClient.TaikoL1.GetConfig(nil) @@ -188,8 +186,8 @@ func NewTestProverServer( MinPseZkevmTierFee: common.Big1, MinSgxAndPseZkevmTierFee: common.Big1, MaxExpiry: 24 * time.Hour, - CapacityManager: capacityManager, TaikoL1Address: common.HexToAddress(os.Getenv("TAIKO_L1_ADDRESS")), + ProposeConcurrencyGuard: make(chan struct{}, 1024), Rpc: s.RpcClient, LivenessBond: protocolConfig.LivenessBond, IsGuardian: true, diff --git a/testutils/suite.go b/testutils/suite.go index 8f936fd7c..f49c2a282 100644 --- a/testutils/suite.go +++ b/testutils/suite.go @@ -16,7 +16,6 @@ import ( "github.com/taikoxyz/taiko-client/bindings" "github.com/taikoxyz/taiko-client/pkg/jwt" "github.com/taikoxyz/taiko-client/pkg/rpc" - capacity "github.com/taikoxyz/taiko-client/prover/capacity_manager" "github.com/taikoxyz/taiko-client/prover/server" ) @@ -77,7 +76,7 @@ func (s *ClientTestSuite) SetupTest() { s.Nil(err) s.ProverEndpoints = []*url.URL{LocalRandomProverEndpoint()} - s.proverServer = NewTestProverServer(s, l1ProverPrivKey, capacity.New(1024), s.ProverEndpoints[0]) + s.proverServer = NewTestProverServer(s, l1ProverPrivKey, s.ProverEndpoints[0]) balance, err := rpcCli.TaikoToken.BalanceOf(nil, crypto.PubkeyToAddress(l1ProverPrivKey.PublicKey)) s.Nil(err)