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

Commit

Permalink
feat(prover): set default --prover.proveUnassignedBlocks and `--mod…
Browse files Browse the repository at this point in the history
…e.contester` value for guardian provers (#492)
  • Loading branch information
davidtaikocha committed Jan 10, 2024
1 parent c6dd524 commit 023ff7f
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 6 deletions.
19 changes: 14 additions & 5 deletions prover/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,7 @@ type Config struct {

// NewConfigFromCliContext creates a new config instance from command line flags.
func NewConfigFromCliContext(c *cli.Context) (*Config, error) {
l1ProverPrivKeyStr := c.String(flags.L1ProverPrivKey.Name)

l1ProverPrivKey, err := crypto.ToECDSA(common.Hex2Bytes(l1ProverPrivKeyStr))
l1ProverPrivKey, err := crypto.ToECDSA(common.Hex2Bytes(c.String(flags.L1ProverPrivKey.Name)))
if err != nil {
return nil, fmt.Errorf("invalid L1 prover private key: %w", err)
}
Expand Down Expand Up @@ -108,8 +106,19 @@ func NewConfigFromCliContext(c *cli.Context) (*Config, error) {

var guardianProverHealthCheckServerEndpoint *url.URL
if c.IsSet(flags.GuardianProverHealthCheckServerEndpoint.Name) {
guardianProverHealthCheckServerEndpoint, err = url.Parse(c.String(flags.GuardianProverHealthCheckServerEndpoint.Name))
if err != nil {
if guardianProverHealthCheckServerEndpoint, err = url.Parse(
c.String(flags.GuardianProverHealthCheckServerEndpoint.Name),
); err != nil {
return nil, err
}
}

// If we are running a guardian prover, we need to prove unassigned blocks and run in contester mode by default.
if c.IsSet(flags.GuardianProver.Name) {
if err := c.Set(flags.ProveUnassignedBlocks.Name, "true"); err != nil {
return nil, err
}
if err := c.Set(flags.ContesterMode.Name, "true"); err != nil {
return nil, err
}
}
Expand Down
4 changes: 3 additions & 1 deletion prover/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@ func (s *ProverTestSuite) TestNewConfigFromCliContextGuardianProver() {
)
s.True(c.Dummy)
s.Equal("", c.Graffiti)
s.Equal(true, c.ProveUnassignedBlocks)
s.True(c.ProveUnassignedBlocks)
s.True(c.ContesterMode)
s.Equal(rpcTimeout, *c.RPCTimeout)
s.Equal(uint64(8), c.Capacity)
s.Equal(uint64(minTierFee), c.MinOptimisticTierFee.Uint64())
Expand Down Expand Up @@ -126,6 +127,7 @@ func (s *ProverTestSuite) SetupApp() *cli.App {
&cli.Uint64Flag{Name: flags.MaxProposedIn.Name},
&cli.StringFlag{Name: flags.ProverAssignmentHookAddress.Name},
&cli.StringFlag{Name: flags.Allowance.Name},
&cli.StringFlag{Name: flags.ContesterMode.Name},
}
app.Action = func(ctx *cli.Context) error {
_, err := NewConfigFromCliContext(ctx)
Expand Down

0 comments on commit 023ff7f

Please sign in to comment.