Skip to content

Commit

Permalink
feat(validator): apply PR reviews
Browse files Browse the repository at this point in the history
  • Loading branch information
seolaoh committed Jan 7, 2025
1 parent 38ca498 commit 0bcd758
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 11 deletions.
22 changes: 13 additions & 9 deletions kroma-validator/challenger.go
Original file line number Diff line number Diff line change
Expand Up @@ -504,7 +504,7 @@ func (c *Challenger) handleOutput(outputIndex *big.Int) {

type ChallengeWithData struct {
Challenge bindings.TypesChallenge
Retry bool
Processing bool
ZkVMWitness string
ZkVMProof *chal.ZkVMProofResponse
}
Expand All @@ -516,7 +516,7 @@ func (c *Challenger) handleChallenge(outputIndex *big.Int, asserter common.Addre

isAsserter := asserter == c.cfg.TxManager.From()
isChallenger := challenger == c.cfg.TxManager.From()
challengeWithData := &ChallengeWithData{bindings.TypesChallenge{}, false, "", nil}
var challengeWithData *ChallengeWithData

ticker := time.NewTicker(c.cfg.ChallengePollInterval)
defer ticker.Stop()
Expand All @@ -543,7 +543,11 @@ func (c *Challenger) handleChallenge(outputIndex *big.Int, asserter common.Addre
c.log.Error("unable to get challenge", "err", err, "outputIndex", outputIndex, "challenger", challenger)
continue
}
challengeWithData.Challenge = challenge
if challengeWithData == nil {
challengeWithData = &ChallengeWithData{Challenge: challenge}
} else {
challengeWithData.Challenge = challenge
}

output, err := c.GetL2Output(c.ctx, outputIndex)
if err != nil {
Expand Down Expand Up @@ -638,8 +642,8 @@ func (c *Challenger) handleChallenge(outputIndex *big.Int, asserter common.Addre
c.log.Error("failed to create prove fault tx", "err", err, "outputIndex", outputIndex)
continue
}
if challengeWithData.Retry {
challengeWithData.Retry = false
if challengeWithData.Processing {
challengeWithData.Processing = false
continue
}
if err := c.submitChallengeTx(tx); err != nil {
Expand Down Expand Up @@ -1036,11 +1040,11 @@ func (c *Challenger) proveFaultWithZkVm(
if err != nil {
return nil, fmt.Errorf("failed to request witness(target block number: %s): %w", targetBlockNumber.String(), err)
}
challengeWithData.Retry = true
challengeWithData.Processing = true
return nil, nil
case chal.RequestProcessing:
c.log.Info("witness generation is in progress", "targetBlockNumber", targetBlockNumber)
challengeWithData.Retry = true
challengeWithData.Processing = true
return nil, nil
case chal.RequestCompleted:
c.log.Info("witness generation is completed", "targetBlockNumber", targetBlockNumber)
Expand All @@ -1064,11 +1068,11 @@ func (c *Challenger) proveFaultWithZkVm(
if err != nil {
return nil, fmt.Errorf("failed to request proof(target block number: %s): %w", targetBlockNumber.String(), err)
}
challengeWithData.Retry = true
challengeWithData.Processing = true
return nil, nil
case chal.RequestProcessing:
c.log.Info("proof generation is in progress", "targetBlockNumber", targetBlockNumber)
challengeWithData.Retry = true
challengeWithData.Processing = true
return nil, nil
case chal.RequestCompleted:
c.log.Info("proof generation is completed", "targetBlockNumber", targetBlockNumber)
Expand Down
4 changes: 2 additions & 2 deletions op-e2e/actions/l2_challenger.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,10 +106,10 @@ func (v *L2Validator) ActProveFault(t Testing, outputIndex *big.Int, skipSelectP
challenge, err := v.challenger.GetChallenge(t.Ctx(), outputIndex, v.address)
require.NoError(t, err, "unable to get challenge")

challengeWithData := &val.ChallengeWithData{Challenge: challenge, Retry: false, ZkVMWitness: "", ZkVMProof: nil}
challengeWithData := &val.ChallengeWithData{Challenge: challenge, Processing: false, ZkVMWitness: "", ZkVMProof: nil}
tx, err := v.challenger.ProveFault(t.Ctx(), challengeWithData, outputIndex, skipSelectPosition)
require.NoError(t, err, "unable to create prove fault tx")
require.False(t, challengeWithData.Retry, "prove fault retry not allowed since using test data")
require.False(t, challengeWithData.Processing, "prove fault retry not allowed since using test data")

err = v.l1.SendTransaction(t.Ctx(), tx)
require.NoError(t, err)
Expand Down

0 comments on commit 0bcd758

Please sign in to comment.