Skip to content

Commit

Permalink
Merge pull request #42 from NethermindEth/mu/zk-request-config
Browse files Browse the repository at this point in the history
Retrieve zkvm RequestProofBodyParam from startup parameters
  • Loading branch information
mikhailUshakoff authored Dec 9, 2024
2 parents 642fb2a + d9f96b4 commit 4542ec3
Show file tree
Hide file tree
Showing 4 changed files with 99 additions and 21 deletions.
48 changes: 48 additions & 0 deletions packages/taiko-client/cmd/flags/prover.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,48 @@ var (
Value: 10 * time.Minute,
EnvVars: []string{"RAIKO_REQUEST_TIMEOUT"},
}
RaikoSP1Recursion = &cli.StringFlag{
Name: "raiko.sp1Recursion",
Usage: "SP1 recursion type",
Value: "plonk",
Category: proverCategory,
EnvVars: []string{"RAIKO_SP1_RECURSION"},
}
RaikoSP1Prover = &cli.StringFlag{
Name: "raiko.sp1Prover",
Usage: "SP1 prover type",
Value: "network",
Category: proverCategory,
EnvVars: []string{"RAIKO_SP1_PROVER"},
}
RaikoRISC0Bonsai = &cli.BoolFlag{
Name: "raiko.risc0Bonsai",
Usage: "Use RISC0 bonsai prover",
Category: proverCategory,
Value: true,
EnvVars: []string{"RAIKO_RISC0_BONSAI"},
}
RaikoRISC0Snark = &cli.BoolFlag{
Name: "raiko.risc0Snark",
Usage: "Use snark for RISC0 proof generation",
Category: proverCategory,
Value: true,
EnvVars: []string{"RAIKO_RISC0_SNARK"},
}
RaikoRISC0Profile = &cli.BoolFlag{
Name: "raiko.risc0Profile",
Usage: "Use profile for RISC0 proof generation",
Category: proverCategory,
Value: false,
EnvVars: []string{"RAIKO_RISC0_PROFILE"},
}
RaikoRISC0ExecutionPo2 = &cli.Uint64Flag{
Name: "raiko.risc0ExecutionPo2",
Usage: "Execution steps for RISC0 proof generation",
Category: proverCategory,
Value: 20,
EnvVars: []string{"RAIKO_RISC0_EXECUTION_PO2"},
}
StartingBlockID = &cli.Uint64Flag{
Name: "prover.startingBlockID",
Usage: "If set, prover will start proving blocks from the block with this ID",
Expand Down Expand Up @@ -227,4 +269,10 @@ var ProverFlags = MergeFlags(CommonFlags, []cli.Flag{
BlockConfirmations,
RaikoRequestTimeout,
RaikoZKVMHostEndpoint,
RaikoSP1Recursion,
RaikoSP1Prover,
RaikoRISC0Bonsai,
RaikoRISC0Snark,
RaikoRISC0Profile,
RaikoRISC0ExecutionPo2,
}, TxmgrFlags)
12 changes: 12 additions & 0 deletions packages/taiko-client/prover/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,12 @@ type Config struct {
RaikoZKVMHostEndpoint string
RaikoJWT string
RaikoRequestTimeout time.Duration
RaikoSP1Recursion string
RaikoSP1Prover string
RaikoRISC0Bonsai bool
RaikoRISC0Snark bool
RaikoRISC0Profile bool
RaikoRISC0ExecutionPo2 *big.Int
L1NodeVersion string
L2NodeVersion string
BlockConfirmations uint64
Expand Down Expand Up @@ -148,6 +154,12 @@ func NewConfigFromCliContext(c *cli.Context) (*Config, error) {
RaikoZKVMHostEndpoint: c.String(flags.RaikoZKVMHostEndpoint.Name),
RaikoJWT: common.Bytes2Hex(jwtSecret),
RaikoRequestTimeout: c.Duration(flags.RaikoRequestTimeout.Name),
RaikoSP1Recursion: c.String(flags.RaikoSP1Recursion.Name),
RaikoSP1Prover: c.String(flags.RaikoSP1Prover.Name),
RaikoRISC0Bonsai: c.Bool(flags.RaikoRISC0Bonsai.Name),
RaikoRISC0Snark: c.Bool(flags.RaikoRISC0Snark.Name),
RaikoRISC0Profile: c.Bool(flags.RaikoRISC0Profile.Name),
RaikoRISC0ExecutionPo2: new(big.Int).SetUint64(c.Uint64(flags.RaikoRISC0ExecutionPo2.Name)),
StartingBlockID: startingBlockID,
Dummy: c.Bool(flags.Dummy.Name),
GuardianProverMinorityAddress: common.HexToAddress(c.String(flags.GuardianProverMinority.Name)),
Expand Down
32 changes: 22 additions & 10 deletions packages/taiko-client/prover/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -121,19 +121,31 @@ func (p *Prover) initProofSubmitters(
}
case encoding.TierZkVMRisc0ID:
producer = &proofProducer.ZKvmProofProducer{
ZKProofType: proofProducer.ZKProofTypeR0,
RaikoHostEndpoint: p.cfg.RaikoZKVMHostEndpoint,
JWT: p.cfg.RaikoJWT,
Dummy: p.cfg.Dummy,
RaikoRequestTimeout: p.cfg.RaikoRequestTimeout,
ZKProofType: proofProducer.ZKProofTypeR0,
RaikoHostEndpoint: p.cfg.RaikoZKVMHostEndpoint,
JWT: p.cfg.RaikoJWT,
Dummy: p.cfg.Dummy,
RaikoRequestTimeout: p.cfg.RaikoRequestTimeout,
RaikoSP1Recursion: p.cfg.RaikoSP1Recursion,
RaikoSP1Prover: p.cfg.RaikoSP1Prover,
RaikoRISC0Bonsai: p.cfg.RaikoRISC0Bonsai,
RaikoRISC0Snark: p.cfg.RaikoRISC0Snark,
RaikoRISC0Profile: p.cfg.RaikoRISC0Profile,
RaikoRISC0ExecutionPo2: p.cfg.RaikoRISC0ExecutionPo2,
}
case encoding.TierZkVMSp1ID:
producer = &proofProducer.ZKvmProofProducer{
ZKProofType: proofProducer.ZKProofTypeSP1,
RaikoHostEndpoint: p.cfg.RaikoZKVMHostEndpoint,
JWT: p.cfg.RaikoJWT,
Dummy: p.cfg.Dummy,
RaikoRequestTimeout: p.cfg.RaikoRequestTimeout,
ZKProofType: proofProducer.ZKProofTypeSP1,
RaikoHostEndpoint: p.cfg.RaikoZKVMHostEndpoint,
JWT: p.cfg.RaikoJWT,
Dummy: p.cfg.Dummy,
RaikoRequestTimeout: p.cfg.RaikoRequestTimeout,
RaikoSP1Recursion: p.cfg.RaikoSP1Recursion,
RaikoSP1Prover: p.cfg.RaikoSP1Prover,
RaikoRISC0Bonsai: p.cfg.RaikoRISC0Bonsai,
RaikoRISC0Snark: p.cfg.RaikoRISC0Snark,
RaikoRISC0Profile: p.cfg.RaikoRISC0Profile,
RaikoRISC0ExecutionPo2: p.cfg.RaikoRISC0ExecutionPo2,
}
case encoding.TierGuardianMinorityID:
producer = proofProducer.NewGuardianProofProducer(encoding.TierGuardianMinorityID, p.cfg.EnableLivenessBondProof)
Expand Down
28 changes: 17 additions & 11 deletions packages/taiko-client/prover/proof_producer/zkvm_producer.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,17 @@ type ProofDataV2 struct {

// ZKvmProofProducer generates a ZK proof for the given block.
type ZKvmProofProducer struct {
ZKProofType string // ZK Proof type
RaikoHostEndpoint string
RaikoRequestTimeout time.Duration
JWT string // JWT provided by Raiko
Dummy bool
ZKProofType string // ZK Proof type
RaikoHostEndpoint string
RaikoRequestTimeout time.Duration
JWT string // JWT provided by Raiko
Dummy bool
RaikoSP1Recursion string
RaikoSP1Prover string
RaikoRISC0Bonsai bool
RaikoRISC0Snark bool
RaikoRISC0Profile bool
RaikoRISC0ExecutionPo2 *big.Int
DummyProofProducer
}

Expand Down Expand Up @@ -164,8 +170,8 @@ func (s *ZKvmProofProducer) requestProof(
Prover: opts.ProverAddress.Hex()[2:],
Graffiti: opts.Graffiti,
SP1: &SP1RequestProofBodyParam{
Recursion: "plonk",
Prover: "network",
Recursion: s.RaikoSP1Recursion,
Prover: s.RaikoSP1Prover,
},
}
default:
Expand All @@ -175,10 +181,10 @@ func (s *ZKvmProofProducer) requestProof(
Prover: opts.ProverAddress.Hex()[2:],
Graffiti: opts.Graffiti,
RISC0: &RISC0RequestProofBodyParam{
Bonsai: true,
Snark: true,
Profile: false,
ExecutionPo2: big.NewInt(20),
Bonsai: s.RaikoRISC0Bonsai,
Snark: s.RaikoRISC0Snark,
Profile: s.RaikoRISC0Profile,
ExecutionPo2: s.RaikoRISC0ExecutionPo2,
},
}
}
Expand Down

0 comments on commit 4542ec3

Please sign in to comment.