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

Commit

Permalink
feat(prover): add --oracleProofSubmissionDelay flag (#320)
Browse files Browse the repository at this point in the history
  • Loading branch information
davidtaikocha committed Jul 18, 2023
1 parent 99dca23 commit b216e2a
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 7 deletions.
6 changes: 6 additions & 0 deletions cmd/flags/prover.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,12 @@ var (
Usage: "Private key of oracle prover",
Category: proverCategory,
}
OracleProofSubmissionDelay = &cli.Uint64Flag{
Name: "oracleProofSubmissionDelay",
Usage: "Oracle proof submission delay in seconds",
Value: 0,
Category: proverCategory,
}
Graffiti = &cli.StringFlag{
Name: "graffiti",
Usage: "When string is passed, adds additional graffiti info to proof evidence",
Expand Down
2 changes: 2 additions & 0 deletions prover/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ type Config struct {
Dummy bool
OracleProver bool
OracleProverPrivateKey *ecdsa.PrivateKey
OracleProofSubmissionDelay time.Duration
Graffiti string
RandomDummyProofDelayLowerBound *time.Duration
RandomDummyProofDelayUpperBound *time.Duration
Expand Down Expand Up @@ -114,6 +115,7 @@ func NewConfigFromCliContext(c *cli.Context) (*Config, error) {
Dummy: c.Bool(flags.Dummy.Name),
OracleProver: c.Bool(flags.OracleProver.Name),
OracleProverPrivateKey: oracleProverPrivKey,
OracleProofSubmissionDelay: time.Duration(c.Uint64(flags.OracleProofSubmissionDelay.Name)) * time.Second,
Graffiti: c.String(flags.Graffiti.Name),
RandomDummyProofDelayLowerBound: randomDummyProofDelayLowerBound,
RandomDummyProofDelayUpperBound: randomDummyProofDelayUpperBound,
Expand Down
20 changes: 13 additions & 7 deletions prover/proof_producer/special_proof_producer.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"errors"
"fmt"
"math/big"
"time"

"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/core/types"
Expand All @@ -28,6 +29,7 @@ type SpecialProofProducer struct {
proverPrivKey *ecdsa.PrivateKey
anchorTxValidator *anchorTxValidator.AnchorTxValidator
graffiti [32]byte
delay time.Duration
}

// NewSpecialProofProducer creates a new NewSpecialProofProducer instance, which can be either
Expand All @@ -38,6 +40,7 @@ func NewSpecialProofProducer(
taikoL2Address common.Address,
protocolSpecialProverAddress common.Address,
graffiti string,
delay time.Duration,
) (*SpecialProofProducer, error) {
proverAddress := crypto.PubkeyToAddress(proverPrivKey.PublicKey)
if proverAddress != protocolSpecialProverAddress {
Expand All @@ -54,6 +57,7 @@ func NewSpecialProofProducer(
proverPrivKey,
anchorValidator,
rpc.StringToBytes32(graffiti),
delay,
}, nil
}

Expand Down Expand Up @@ -123,13 +127,15 @@ func (p *SpecialProofProducer) RequestProof(
return fmt.Errorf("failed to sign evidence: %w", err)
}

resultCh <- &ProofWithHeader{
BlockID: blockID,
Header: header,
Meta: meta,
ZkProof: proof,
Opts: opts,
}
time.AfterFunc(p.delay, func() {
resultCh <- &ProofWithHeader{
BlockID: blockID,
Header: header,
Meta: meta,
ZkProof: proof,
Opts: opts,
}
})

return nil
}
Expand Down
1 change: 1 addition & 0 deletions prover/prover.go
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,7 @@ func InitFromConfig(ctx context.Context, p *Prover, cfg *Config) (err error) {
p.cfg.TaikoL2Address,
specialProverAddress,
p.cfg.Graffiti,
p.cfg.OracleProofSubmissionDelay,
); err != nil {
return err
}
Expand Down

0 comments on commit b216e2a

Please sign in to comment.