@@ -16,18 +16,35 @@ import (
1616 "github.com/taikoxyz/taiko-mono/packages/taiko-client/prover/proof_submitter/transaction"
1717)
1818
19+ const (
20+ sgxGethVerifierID uint8 = 1
21+ sgxRethVerifierID uint8 = 4
22+ risc0RethVerifierID uint8 = 5
23+ sp1RethVerifierID uint8 = 6
24+ )
25+
26+ func verifierIDsByProofType () map [producer.ProofType ]uint8 {
27+ return map [producer.ProofType ]uint8 {
28+ producer .ProofTypeSgxGeth : sgxGethVerifierID ,
29+ producer .ProofTypeSgx : sgxRethVerifierID ,
30+ producer .ProofTypeZKR0 : risc0RethVerifierID ,
31+ producer .ProofTypeZKSP1 : sp1RethVerifierID ,
32+ }
33+ }
34+
35+ func enabledProofTypes (forceSGXProof bool , zkOnlyProofs bool ) []producer.ProofType {
36+ if forceSGXProof && ! zkOnlyProofs {
37+ return []producer.ProofType {producer .ProofTypeSgx }
38+ }
39+ return []producer.ProofType {producer .ProofTypeZKR0 , producer .ProofTypeZKSP1 }
40+ }
41+
1942// initProofSubmitter initializes the proof submitter from the non-zero verifier addresses set in protocol.
2043func (p * Prover ) initProofSubmitter (ctx context.Context , txBuilder * transaction.ProveBatchesTxBuilder ) error {
2144 var (
2245 // All activated proof types in protocol.
23- proofTypes = make ([]producer.ProofType , 0 , proofSubmitter .MaxNumSupportedProofTypes )
24-
25- // VerifierIDs
26- sgxGethVerifierID uint8 = 1
27- risc0RethVerifierID uint8 = 5
28- sp1RethVerifierID uint8 = 6
29-
30- err error
46+ proofTypes = enabledProofTypes (p .cfg .ForceSGXProof , p .cfg .ZkOnlyProofs )
47+ err error
3148 )
3249
3350 // A ZK-only prover can only finalize against a proof verifier that accepts the
@@ -47,14 +64,20 @@ func (p *Prover) initProofSubmitter(ctx context.Context, txBuilder *transaction.
4764 )
4865 }
4966 }
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 ,
67+ if p .cfg .ForceSGXProof && ! p .cfg .ZkOnlyProofs {
68+ if inboxConfig , err := p .rpc .ShastaClients .Inbox .GetConfig (& bind.CallOpts {Context : ctx }); err != nil {
69+ log .Warn ("Force SGX proof mode is enabled, but fetching the inbox's proof verifier failed" , "error" , err )
70+ } else {
71+ log .Warn (
72+ "Force SGX proof mode is enabled: the inbox's proof verifier must accept the " +
73+ "[SGX_GETH, SGX_RETH] sub-proof pair, otherwise every proof submission will revert" ,
74+ "proofVerifier" , inboxConfig .ProofVerifier ,
75+ )
76+ }
5677 }
57- proofTypes = append (proofTypes , producer .ProofTypeZKR0 , producer .ProofTypeZKSP1 )
78+
79+ // Initialize proof verifier IDs and the Raiko proof producer.
80+ verifierIDs := verifierIDsByProofType ()
5881
5982 zkvmProducer := & producer.ComposeProofProducer {
6083 VerifierIDs : verifierIDs ,
@@ -76,7 +99,7 @@ func (p *Prover) initProofSubmitter(ctx context.Context, txBuilder *transaction.
7699 for _ , proofType := range proofTypes {
77100 cacheMaps [proofType ] = cmap .New [* producer.ProofResponse ]()
78101 switch proofType {
79- case producer .ProofTypeZKR0 , producer .ProofTypeZKSP1 :
102+ case producer .ProofTypeSgx , producer . ProofTypeZKR0 , producer .ProofTypeZKSP1 :
80103 proofBuffers [proofType ] = producer .NewProofBuffer (p .cfg .ZKVMProofBufferSize )
81104 default :
82105 return fmt .Errorf ("unexpected proof type: %s" , proofType )
@@ -104,6 +127,7 @@ func (p *Prover) initProofSubmitter(ctx context.Context, txBuilder *transaction.
104127 new (big.Int ).SetUint64 (p .cfg .ProposalWindowSize ),
105128 new (big.Int ).SetUint64 (p .cfg .MaxRisc0ProofProposalDistance ),
106129 p .cfg .ForceSP1Proof ,
130+ p .cfg .ForceSGXProof ,
107131 p .cfg .ZkOnlyProofs ,
108132 ); err != nil {
109133 return fmt .Errorf ("failed to initialize proof submitter: %w" , err )
0 commit comments