Skip to content
This repository has been archived by the owner on May 11, 2024. It is now read-only.

Commit

Permalink
feat(prover): fix a tier selection issue (#534)
Browse files Browse the repository at this point in the history
  • Loading branch information
davidtaikocha committed Jan 26, 2024
1 parent 338af66 commit 5a9def5
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 4 deletions.
8 changes: 7 additions & 1 deletion prover/prover.go
Original file line number Diff line number Diff line change
Expand Up @@ -794,17 +794,23 @@ func (p *Prover) handleNewBlockProposedEvent(ctx context.Context, e *bindings.Ta
}
}

tier := e.Meta.MinTier
if p.IsGuardianProver() {
tier = encoding.TierGuardianID
}

log.Info(
"Proposed block is provable",
"blockID", e.BlockId,
"prover", e.AssignedProver,
"expiresAt", provingWindowExpiresAt,
"minTier", e.Meta.MinTier,
"currentTier", tier,
)

metrics.ProverProofsAssigned.Inc(1)

if proofSubmitter := p.selectSubmitter(e.Meta.MinTier); proofSubmitter != nil {
if proofSubmitter := p.selectSubmitter(tier); proofSubmitter != nil {
return proofSubmitter.RequestProof(ctx, e)
}

Expand Down
16 changes: 13 additions & 3 deletions prover/prover_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,10 @@ func (s *ProverTestSuite) TestContestWrongBlocks() {
contesterKey, err := crypto.ToECDSA(common.FromHex(os.Getenv("L1_CONTRACT_OWNER_PRIVATE_KEY")))
s.Nil(err)

s.NotNil(s.initProver(context.Background(), contesterKey))
s.NotNil(s.initProver(
context.Background(),
contesterKey,
))
s.p.cfg.ContesterMode = true

s.Greater(header.Number.Uint64(), uint64(0))
Expand All @@ -247,8 +250,13 @@ func (s *ProverTestSuite) TestContestWrongBlocks() {
s.Equal(header.ParentHash, common.BytesToHash(contestedEvent.Tran.ParentHash[:]))

s.Nil(s.p.onTransitionContested(context.Background(), contestedEvent))

s.p.cfg.GuardianProverAddress = common.HexToAddress(os.Getenv("GUARDIAN_PROVER_CONTRACT_ADDRESS"))
s.True(s.p.IsGuardianProver())

s.p.rpc.GuardianProver, err = bindings.NewGuardianProver(s.p.cfg.GuardianProverAddress, s.p.rpc.L1)
s.Nil(err)

approvedSink := make(chan *bindings.GuardianProverApproved)
approvedSub, err := s.p.rpc.GuardianProver.WatchApproved(nil, approvedSink, [](*big.Int){})
s.Nil(err)
Expand Down Expand Up @@ -455,7 +463,10 @@ func TestProverTestSuite(t *testing.T) {
suite.Run(t, new(ProverTestSuite))
}

func (s *ProverTestSuite) initProver(ctx context.Context, key *ecdsa.PrivateKey) *url.URL {
func (s *ProverTestSuite) initProver(
ctx context.Context,
key *ecdsa.PrivateKey,
) *url.URL {
proverServerURL := testutils.LocalRandomProverEndpoint()
port, err := strconv.Atoi(proverServerURL.Port())
s.Nil(err)
Expand All @@ -475,7 +486,6 @@ func (s *ProverTestSuite) initProver(ctx context.Context, key *ecdsa.PrivateKey)
TaikoL2Address: common.HexToAddress(os.Getenv("TAIKO_L2_ADDRESS")),
TaikoTokenAddress: common.HexToAddress(os.Getenv("TAIKO_TOKEN_ADDRESS")),
AssignmentHookAddress: common.HexToAddress(os.Getenv("ASSIGNMENT_HOOK_ADDRESS")),
GuardianProverAddress: common.HexToAddress(os.Getenv("GUARDIAN_PROVER_CONTRACT_ADDRESS")),
L1ProverPrivKey: key,
Dummy: true,
ProveUnassignedBlocks: true,
Expand Down

0 comments on commit 5a9def5

Please sign in to comment.