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

Commit

Permalink
feat(prover): allow assigned prover to do more (#699)
Browse files Browse the repository at this point in the history
  • Loading branch information
davidtaikocha authored Apr 8, 2024
1 parent 5dec1b1 commit 283c4cb
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 51 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ jobs:
with:
repository: taikoxyz/taiko-mono
path: ${{ env.TAIKO_MONO_DIR }}
ref: relax_assigned_prover_req_0
ref: fix_protocol_issue

- name: Install Foundry
uses: foundry-rs/foundry-toolchain@v1
Expand Down
5 changes: 1 addition & 4 deletions prover/event_handler/assignment_expired.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,7 @@ func (h *AssignmentExpiredEventHandler) Handle(
"assignedProver", e.AssignedProver,
"minTier", e.Meta.MinTier,
)
// If Proof assignment window is expired, then the assigned prover can not submit new proofs for it anymore.
if h.proverAddress == e.AssignedProver {
return nil
}

// Check if we still need to generate a new proof for that block.
proofStatus, err := rpc.GetBlockProofStatus(ctx, h.rpc, e.BlockId, h.proverAddress)
if err != nil {
Expand Down
64 changes: 18 additions & 46 deletions prover/event_handler/block_proposed.go
Original file line number Diff line number Diff line change
Expand Up @@ -281,63 +281,35 @@ func (h *BlockProposedEventHandler) checkExpirationAndSubmitProof(
return fmt.Errorf("failed to check if the proving window is expired: %w", err)
}

if windowExpired {
// If the proving window is expired, we need to check if the current prover is the assigned prover
// at first, if yes, we should skip proving this block, if no, then we check if the current prover
// wants to prove unassigned blocks.
// If the proving window is not expired, we need to check if the current prover is the assigned prover,
// if no and the current prover wants to prove unassigned blocks, then we should wait for its expiration.
if !windowExpired && e.AssignedProver != h.proverAddress {
log.Info(
"Proposed block's proving window has expired",
"Proposed block is not provable by current prover at the moment",
"blockID", e.BlockId,
"prover", e.AssignedProver,
"timeToExpire", timeToExpire,
"minTier", e.Meta.MinTier,
)
if e.AssignedProver == h.proverAddress {
log.Warn(
"Assigned prover is the current prover, but the proving window has expired, skip proving",
"blockID", e.BlockId,
"prover", e.AssignedProver,
)
return nil
}
// If the current prover doesn't want to prove unassigned blocks, we should skip proving this block.
if !h.proveUnassignedBlocks {
log.Info(
"Skip proving expired blocks",
"blockID", e.BlockId,
"prover", e.AssignedProver,
)
return nil
}
} else {
// If the proving window is not expired, we need to check if the current prover is the assigned prover,
// if no and the current prover wants to prove unassigned blocks, then we should wait for its expiration.
if e.AssignedProver != h.proverAddress {

if h.proveUnassignedBlocks {
log.Info(
"Proposed block is not provable by current prover at the moment",
"Add proposed block to wait for proof window expiration",
"blockID", e.BlockId,
"prover", e.AssignedProver,
"assignProver", e.AssignedProver,
"timeToExpire", timeToExpire,
)

if h.proveUnassignedBlocks {
log.Info(
"Add proposed block to wait for proof window expiration",
"blockID", e.BlockId,
"prover", e.AssignedProver,
"timeToExpire", timeToExpire,
)
time.AfterFunc(
// Add another 60 seconds, to ensure one more L1 block will be mined before the proof submission
timeToExpire+proofExpirationDelay,
func() { h.assignmentExpiredCh <- e },
)
}

return nil
time.AfterFunc(
// Add another 60 seconds, to ensure one more L1 block will be mined before the proof submission
timeToExpire+proofExpirationDelay,
func() { h.assignmentExpiredCh <- e },
)
}

return nil
}

// The current prover is the assigned prover, or the proving window is expired,
// try to submit a proof for this proposed block.
tier := e.Meta.MinTier
if h.tierToOverride != 0 {
tier = h.tierToOverride
Expand All @@ -346,7 +318,7 @@ func (h *BlockProposedEventHandler) checkExpirationAndSubmitProof(
log.Info(
"Proposed block is provable",
"blockID", e.BlockId,
"prover", e.AssignedProver,
"assignProver", e.AssignedProver,
"minTier", e.Meta.MinTier,
"tier", tier,
)
Expand Down

0 comments on commit 283c4cb

Please sign in to comment.