Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

wip: use offchain sub interval #397

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions proposer/op/proposer/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,8 @@ type CLIConfig struct {
MaxConcurrentProofRequests uint64
// Mock is a flag to use the mock OP Succinct server.
Mock bool
// Submission interval, must be greater than onchain minbound
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: period

SubmissionInterval uint64
}

func (c *CLIConfig) Check() error {
Expand Down Expand Up @@ -158,6 +160,7 @@ func NewConfig(ctx *cli.Context) *CLIConfig {
OPSuccinctServerUrl: ctx.String(flags.OPSuccinctServerUrlFlag.Name),
MaxConcurrentProofRequests: ctx.Uint64(flags.MaxConcurrentProofRequestsFlag.Name),
Mock: ctx.Bool(flags.MockFlag.Name),
SubmissionInterval: ctx.Uint64(flags.SubmissionIntervalFlag.Name),
DGFAddress: ctx.String(flags.DGFAddressFlag.Name),

// NOTE(fakedev9999): GameType 6 is the game type for the op-succinct proof system.
Expand Down
6 changes: 6 additions & 0 deletions proposer/op/proposer/flags/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,12 @@ var (
Value: false,
EnvVars: prefixEnvVars("OP_SUCCINCT_MOCK"),
}
SubmissionIntervalFlag = &cli.Uint64Flag{
Name: "submission-interval",
Usage: "Submission interval, must be greater than onchain minbound. O = uses onchain value.",
Value: 0,
EnvVars: prefixEnvVars("SUBMISSION_INTERVAL"),
}

// Legacy Flags
L2OutputHDPathFlag = txmgr.L2OutputHDPathFlag
Expand Down
11 changes: 11 additions & 0 deletions proposer/op/proposer/prove.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"encoding/json"
"fmt"
"io"
"math/big"
"net"
"net/http"
"strings"
Expand Down Expand Up @@ -245,6 +246,16 @@ func (l *L2OutputSubmitter) DeriveAggProofs(ctx context.Context) error {
return fmt.Errorf("failed to get next L2OO output: %w", err)
}

// Calculate how it would be using the offchain value
if l.Cfg.SubmissionInterval != 0 {
offChainMinTo := latest.Uint64() + l.Cfg.SubmissionInterval
if offChainMinTo < minTo.Uint64() {
return fmt.Errorf("next block using offchain submission interval cannot be lower than onchain min bound")
}

minTo = new(big.Int).SetUint64(offChainMinTo)
}

created, end, err := l.db.TryCreateAggProofFromSpanProofs(latest.Uint64(), minTo.Uint64())
if err != nil {
return fmt.Errorf("failed to create agg proof from span proofs: %w", err)
Expand Down
3 changes: 3 additions & 0 deletions proposer/op/proposer/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,9 @@ type ProposerConfig struct {
OPSuccinctServerUrl string
MaxConcurrentProofRequests uint64
Mock bool

// How frequently aggregate proofs and propose outputs
SubmissionInterval uint64
}

type ProposerService struct {
Expand Down
Loading