@@ -19,60 +19,50 @@ import (
1919// initProofSubmitter initializes the proof submitter from the non-zero verifier addresses set in protocol.
2020func (p * Prover ) initProofSubmitter (ctx context.Context , txBuilder * transaction.ProveBatchesTxBuilder ) error {
2121 var (
22- // ZKVM proof producers.
23- zkvmProducer producer.ProofProducer
24-
2522 // All activated proof types in protocol.
2623 proofTypes = make ([]producer.ProofType , 0 , proofSubmitter .MaxNumSupportedProofTypes )
2724
2825 // VerifierIDs
2926 sgxGethVerifierID uint8 = 1
30- sgxRethVerifierID uint8 = 4
3127 risc0RethVerifierID uint8 = 5
3228 sp1RethVerifierID uint8 = 6
3329
3430 err error
3531 )
3632
37- sgxGethProducer := & producer.SgxGethProofProducer {
38- RaikoHostEndpoint : p .cfg .RaikoHostEndpoint ,
39- VerifierID : sgxGethVerifierID ,
40- ApiKey : p .cfg .RaikoApiKey ,
41- RaikoRequestTimeout : p .cfg .RaikoRequestTimeout ,
42- Dummy : p .cfg .Dummy ,
33+ // A ZK-only prover can only finalize against a proof verifier that accepts the
34+ // [RISC0, SP1] sub-proof pair (ZkRequiredVerifier, live with the Unzen hardfork).
35+ // That is not checkable on-chain (areVerifiersSufficient is internal), so surface the
36+ // configured verifier loudly for the operator to check: on the pre-Unzen
37+ // MainnetVerifier every ZK-only submission reverts with CV_VERIFIERS_INSUFFICIENT.
38+ if p .cfg .ZkOnlyProofs {
39+ if inboxConfig , err := p .rpc .ShastaClients .Inbox .GetConfig (& bind.CallOpts {Context : ctx }); err != nil {
40+ log .Warn ("ZK-only proof mode is enabled, but fetching the inbox's proof verifier failed" , "error" , err )
41+ } else {
42+ log .Warn (
43+ "ZK-only proof mode is enabled: the inbox's proof verifier must accept the [RISC0, SP1] " +
44+ "sub-proof pair (ZkRequiredVerifier, live with the Unzen hardfork), " +
45+ "otherwise every proof submission will revert" ,
46+ "proofVerifier" , inboxConfig .ProofVerifier ,
47+ )
48+ }
4349 }
44- // Initialize the sgx proof producer.
45- proofTypes = append (proofTypes , producer .ProofTypeSgx )
46- sgxRethProducer := & producer.ComposeProofProducer {
47- SgxGethProducer : sgxGethProducer ,
48- VerifierIDs : map [producer.ProofType ]uint8 {
49- producer .ProofTypeSgx : sgxRethVerifierID ,
50- },
50+
51+ // Initialize the zk verifiers and zkvm proof producers.
52+ verifierIDs := map [producer.ProofType ]uint8 {
53+ producer .ProofTypeSgxGeth : sgxGethVerifierID ,
54+ producer .ProofTypeZKR0 : risc0RethVerifierID ,
55+ producer .ProofTypeZKSP1 : sp1RethVerifierID ,
56+ }
57+ proofTypes = append (proofTypes , producer .ProofTypeZKR0 , producer .ProofTypeZKSP1 )
58+
59+ zkvmProducer := & producer.ComposeProofProducer {
60+ VerifierIDs : verifierIDs ,
5161 RaikoHostEndpoint : p .cfg .RaikoHostEndpoint ,
52- ProofType : producer .ProofTypeSgx ,
5362 ApiKey : p .cfg .RaikoApiKey ,
5463 RaikoRequestTimeout : p .cfg .RaikoRequestTimeout ,
5564 Dummy : p .cfg .Dummy ,
5665 }
57-
58- // Initialize the zk verifiers and zkvm proof producers.
59- var zkVerifierIDs = make (map [producer.ProofType ]uint8 , proofSubmitter .MaxNumSupportedZkTypes )
60- proofTypes = append (proofTypes , producer .ProofTypeZKR0 )
61- zkVerifierIDs [producer .ProofTypeZKR0 ] = risc0RethVerifierID
62- proofTypes = append (proofTypes , producer .ProofTypeZKSP1 )
63- zkVerifierIDs [producer .ProofTypeZKSP1 ] = sp1RethVerifierID
64-
65- if len (p .cfg .RaikoZKVMHostEndpoint ) != 0 {
66- zkvmProducer = & producer.ComposeProofProducer {
67- VerifierIDs : zkVerifierIDs ,
68- SgxGethProducer : sgxGethProducer ,
69- RaikoHostEndpoint : p .cfg .RaikoZKVMHostEndpoint ,
70- ApiKey : p .cfg .RaikoApiKey ,
71- RaikoRequestTimeout : p .cfg .RaikoRequestTimeout ,
72- ProofType : producer .ProofTypeZKR0 ,
73- Dummy : p .cfg .Dummy ,
74- }
75- }
7666 // Init proof buffers.
7767 var (
7868 proofBuffers = make (map [producer.ProofType ]* producer.ProofBuffer , proofSubmitter .MaxNumSupportedProofTypes )
@@ -86,8 +76,6 @@ func (p *Prover) initProofSubmitter(ctx context.Context, txBuilder *transaction.
8676 for _ , proofType := range proofTypes {
8777 cacheMaps [proofType ] = cmap .New [* producer.ProofResponse ]()
8878 switch proofType {
89- case producer .ProofTypeOp , producer .ProofTypeSgx :
90- proofBuffers [proofType ] = producer .NewProofBuffer (p .cfg .SGXProofBufferSize )
9179 case producer .ProofTypeZKR0 , producer .ProofTypeZKSP1 :
9280 proofBuffers [proofType ] = producer .NewProofBuffer (p .cfg .ZKVMProofBufferSize )
9381 default :
@@ -97,7 +85,6 @@ func (p *Prover) initProofSubmitter(ctx context.Context, txBuilder *transaction.
9785
9886 if p .proofSubmitter , err = proofSubmitter .NewProofSubmitter (
9987 p .ctx ,
100- sgxRethProducer ,
10188 zkvmProducer ,
10289 p .batchProofGenerationCh ,
10390 p .batchesAggregationNotify ,
@@ -117,6 +104,7 @@ func (p *Prover) initProofSubmitter(ctx context.Context, txBuilder *transaction.
117104 new (big.Int ).SetUint64 (p .cfg .ProposalWindowSize ),
118105 new (big.Int ).SetUint64 (p .cfg .MaxRisc0ProofProposalDistance ),
119106 p .cfg .ForceSP1Proof ,
107+ p .cfg .ZkOnlyProofs ,
120108 ); err != nil {
121109 return fmt .Errorf ("failed to initialize proof submitter: %w" , err )
122110 }
0 commit comments