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

Commit

Permalink
proveunassigned blocks, skip 0 address proofs
Browse files Browse the repository at this point in the history
  • Loading branch information
cyberhorsey committed Jul 12, 2023
1 parent e953e3e commit e10ae42
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 11 deletions.
8 changes: 4 additions & 4 deletions cmd/flags/prover.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,9 +81,9 @@ var (
Category: proverCategory,
Value: 15,
}
ProveExpiredProofs = &cli.BoolFlag{
Name: "prover.proveExpiredProofs",
Usage: "Whether you want to prover expired proofs, or only work on assigned proofs",
ProveUnassignedBlocks = &cli.BoolFlag{
Name: "prover.ProveUnassignedBlocks",
Usage: "Whether you want to prove unassigned blocks, or only work on assigned proofs",
Category: proverCategory,
Value: true,
}
Expand All @@ -106,5 +106,5 @@ var ProverFlags = MergeFlags(CommonFlags, []cli.Flag{
Graffiti,
TaikoProverPoolL1Address,
CheckProofWindowExpiredInterval,
ProveExpiredProofs,
ProveUnassignedBlocks,
})
4 changes: 2 additions & 2 deletions prover/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ type Config struct {
BackOffMaxRetrys uint64
BackOffRetryInterval time.Duration
CheckProofWindowExpiredInterval time.Duration
ProveExpiredProofs bool
ProveUnassignedBlocks bool
}

// NewConfigFromCliContext creates a new config instance from command line flags.
Expand Down Expand Up @@ -122,6 +122,6 @@ func NewConfigFromCliContext(c *cli.Context) (*Config, error) {
CheckProofWindowExpiredInterval: time.Duration(
c.Uint64(flags.CheckProofWindowExpiredInterval.Name),
) * time.Second,
ProveExpiredProofs: c.Bool(flags.ProveExpiredProofs.Name),
ProveUnassignedBlocks: c.Bool(flags.ProveUnassignedBlocks.Name),
}, nil
}
6 changes: 3 additions & 3 deletions prover/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ var testFlags = []cli.Flag{
&cli.StringFlag{Name: flags.Graffiti.Name},
&cli.StringFlag{Name: flags.TaikoProverPoolL1Address.Name},
&cli.Uint64Flag{Name: flags.CheckProofWindowExpiredInterval.Name},
&cli.BoolFlag{Name: flags.ProveExpiredProofs.Name},
&cli.BoolFlag{Name: flags.ProveUnassignedBlocks.Name},
}

func (s *ProverTestSuite) TestNewConfigFromCliContext_OracleProver() {
Expand Down Expand Up @@ -63,7 +63,7 @@ func (s *ProverTestSuite) TestNewConfigFromCliContext_OracleProver() {
)
s.Equal("", c.Graffiti)
s.Equal(30*time.Second, c.CheckProofWindowExpiredInterval)
s.Equal(true, c.ProveExpiredProofs)
s.Equal(true, c.ProveUnassignedBlocks)
s.Nil(new(Prover).InitFromCli(context.Background(), ctx))

return err
Expand All @@ -85,7 +85,7 @@ func (s *ProverTestSuite) TestNewConfigFromCliContext_OracleProver() {
"-" + flags.OracleProverPrivateKey.Name, os.Getenv("L1_PROVER_PRIVATE_KEY"),
"-" + flags.Graffiti.Name, "",
"-" + flags.CheckProofWindowExpiredInterval.Name, "30",
"-" + flags.ProveExpiredProofs.Name, "true",
"-" + flags.ProveUnassignedBlocks.Name, "true",
}))
}

Expand Down
15 changes: 14 additions & 1 deletion prover/prover.go
Original file line number Diff line number Diff line change
Expand Up @@ -508,14 +508,18 @@ func (p *Prover) onBlockProposed(
}

if !skipProofWindowExpiredCheck {
if block.AssignedProver == zeroAddress {
// anyone can prove, dont need to check the proofWindowExpired
}

proofWindowExpired := uint64(time.Now().Unix()) > block.ProposedAt+block.ProofWindow
// zero address means anyone can prove, proofWindowExpired means anyone can prove even if not zero address
if block.AssignedProver != p.proverAddress && block.AssignedProver != zeroAddress && !proofWindowExpired {
log.Info("Proposed block not proveable", "blockID", event.BlockId, "prover", block.AssignedProver.Hex())

// if we cant prove it now, but config is set to wait and try to prove
// expired proofs
if p.cfg.ProveExpiredProofs {
if p.cfg.ProveUnassignedBlocks {
p.currentBlocksWaitingForProofWindowMutex.Lock()
p.currentBlocksWaitingForProofWindow[event.Meta.Id] = event.Raw.BlockNumber
p.currentBlocksWaitingForProofWindowMutex.Unlock()
Expand All @@ -524,6 +528,15 @@ func (p *Prover) onBlockProposed(
return nil
}

// if set not to prove unassigned blocks, this block is still not provable
// by us even though its open proving.
if block.AssignedProver == zeroAddress && !p.cfg.ProveUnassignedBlocks {
log.Info("Skipping proposed open proving block, not assigned to us",
"blockID", event.BlockId,
)
return nil
}

log.Info(
"Proposed block is proveable",
"blockID", event.BlockId,
Expand Down
2 changes: 1 addition & 1 deletion prover/prover_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ func (s *ProverTestSuite) SetupTest() {
Dummy: true,
MaxConcurrentProvingJobs: 1,
CheckProofWindowExpiredInterval: 5 * time.Second,
ProveExpiredProofs: true,
ProveUnassignedBlocks: true,
})))
s.p = p
s.cancel = cancel
Expand Down

0 comments on commit e10ae42

Please sign in to comment.