From bed641486e79e346c7ca49190cb77c18859621bf Mon Sep 17 00:00:00 2001 From: David Date: Tue, 21 May 2024 22:58:03 +0800 Subject: [PATCH] feat(taiko-client): remove `raiko` from guardian prover (#17289) Co-authored-by: maskpp --- packages/taiko-client/cmd/flags/prover.go | 13 ++++++------- packages/taiko-client/prover/config.go | 4 ++++ packages/taiko-client/prover/init.go | 18 ++---------------- .../prover/proof_producer/guardian_producer.go | 14 +++----------- .../proof_producer/guardian_producer_test.go | 8 ++++---- 5 files changed, 19 insertions(+), 38 deletions(-) diff --git a/packages/taiko-client/cmd/flags/prover.go b/packages/taiko-client/cmd/flags/prover.go index 79ddd149eb..10efcbad89 100644 --- a/packages/taiko-client/cmd/flags/prover.go +++ b/packages/taiko-client/cmd/flags/prover.go @@ -24,13 +24,6 @@ var ( Category: proverCategory, EnvVars: []string{"PROVER_CAPACITY"}, } - RaikoHostEndpoint = &cli.StringFlag{ - Name: "raiko.host", - Usage: "RPC endpoint of a Raiko host service", - Required: true, - Category: proverCategory, - EnvVars: []string{"RAIKO_HOST"}, - } ) // Optional flags used by prover. @@ -42,6 +35,12 @@ var ( Category: proverCategory, EnvVars: []string{"PROVER_SET"}, } + RaikoHostEndpoint = &cli.StringFlag{ + Name: "raiko.host", + Usage: "RPC endpoint of a Raiko host service", + Category: proverCategory, + EnvVars: []string{"RAIKO_HOST"}, + } RaikoL1Endpoint = &cli.StringFlag{ Name: "raiko.l1", Usage: "L1 RPC endpoint which will be sent to the Raiko service", diff --git a/packages/taiko-client/prover/config.go b/packages/taiko-client/prover/config.go index c66ae3fdc6..732f2503b8 100644 --- a/packages/taiko-client/prover/config.go +++ b/packages/taiko-client/prover/config.go @@ -159,6 +159,10 @@ func NewConfigFromCliContext(c *cli.Context) (*Config, error) { return nil, err } + if !c.IsSet(flags.GuardianProverMajority.Name) && !c.IsSet(flags.RaikoHostEndpoint.Name) { + return nil, errors.New("empty raiko host endpoint") + } + return &Config{ L1WsEndpoint: c.String(flags.L1WSEndpoint.Name), L1HttpEndpoint: c.String(flags.L1HTTPEndpoint.Name), diff --git a/packages/taiko-client/prover/init.go b/packages/taiko-client/prover/init.go index c56d3926b7..26b8a4454f 100644 --- a/packages/taiko-client/prover/init.go +++ b/packages/taiko-client/prover/init.go @@ -116,23 +116,9 @@ func (p *Prover) initProofSubmitters( Dummy: p.cfg.Dummy, } case encoding.TierGuardianMinorityID: - producer = proofProducer.NewGuardianProofProducer(&proofProducer.SGXProofProducer{ - RaikoHostEndpoint: p.cfg.RaikoHostEndpoint, - L1Endpoint: p.cfg.RaikoL1Endpoint, - L1BeaconEndpoint: p.cfg.RaikoL1BeaconEndpoint, - L2Endpoint: p.cfg.RaikoL2Endpoint, - ProofType: proofProducer.ProofTypeCPU, - Dummy: p.cfg.Dummy, - }, encoding.TierGuardianMinorityID, p.cfg.EnableLivenessBondProof) + producer = proofProducer.NewGuardianProofProducer(encoding.TierGuardianMinorityID, p.cfg.EnableLivenessBondProof) case encoding.TierGuardianMajorityID: - producer = proofProducer.NewGuardianProofProducer(&proofProducer.SGXProofProducer{ - RaikoHostEndpoint: p.cfg.RaikoHostEndpoint, - L1Endpoint: p.cfg.RaikoL1Endpoint, - L1BeaconEndpoint: p.cfg.RaikoL1BeaconEndpoint, - L2Endpoint: p.cfg.RaikoL2Endpoint, - ProofType: proofProducer.ProofTypeCPU, - Dummy: p.cfg.Dummy, - }, encoding.TierGuardianMajorityID, p.cfg.EnableLivenessBondProof) + producer = proofProducer.NewGuardianProofProducer(encoding.TierGuardianMajorityID, p.cfg.EnableLivenessBondProof) default: return fmt.Errorf("unsupported tier: %d", tier.ID) } diff --git a/packages/taiko-client/prover/proof_producer/guardian_producer.go b/packages/taiko-client/prover/proof_producer/guardian_producer.go index 86dc956b8c..ea4dd8fa73 100644 --- a/packages/taiko-client/prover/proof_producer/guardian_producer.go +++ b/packages/taiko-client/prover/proof_producer/guardian_producer.go @@ -13,18 +13,17 @@ import ( // GuardianProofProducer always returns an optimistic (dummy) proof. type GuardianProofProducer struct { + DummyProofProducer returnLivenessBond bool tier uint16 - *SGXProofProducer } func NewGuardianProofProducer( - sgxProofProducer *SGXProofProducer, tier uint16, returnLivenessBond bool, ) *GuardianProofProducer { return &GuardianProofProducer{ - SGXProofProducer: sgxProofProducer, + DummyProofProducer: DummyProofProducer{}, returnLivenessBond: returnLivenessBond, tier: tier, } @@ -32,7 +31,7 @@ func NewGuardianProofProducer( // RequestProof implements the ProofProducer interface. func (g *GuardianProofProducer) RequestProof( - ctx context.Context, + _ context.Context, opts *ProofRequestOptions, blockID *big.Int, meta *bindings.TaikoDataBlockMetadata, @@ -57,13 +56,6 @@ func (g *GuardianProofProducer) RequestProof( }, nil } - // Each guardian prover should check the block hash with raiko at first, - // before submitting the guardian proof, if raiko can return a proof without - // any error, which means the block hash is valid. - if _, err := g.SGXProofProducer.RequestProof(ctx, opts, blockID, meta, header); err != nil { - return nil, err - } - return g.DummyProofProducer.RequestProof(opts, blockID, meta, header, g.Tier()) } diff --git a/packages/taiko-client/prover/proof_producer/guardian_producer_test.go b/packages/taiko-client/prover/proof_producer/guardian_producer_test.go index a2738671ce..ce5b6819b4 100644 --- a/packages/taiko-client/prover/proof_producer/guardian_producer_test.go +++ b/packages/taiko-client/prover/proof_producer/guardian_producer_test.go @@ -33,7 +33,7 @@ func TestGuardianProducerRequestProof(t *testing.T) { } var ( - producer = NewGuardianProofProducer(&SGXProofProducer{Dummy: true}, encoding.TierGuardianMajorityID, false) + producer = NewGuardianProofProducer(encoding.TierGuardianMajorityID, false) blockID = common.Big32 ) res, err := producer.RequestProof( @@ -70,7 +70,7 @@ func TestGuardianProducerRequestProofReturnLivenessBond(t *testing.T) { } var ( - producer = NewGuardianProofProducer(&SGXProofProducer{Dummy: true}, encoding.TierGuardianMajorityID, true) + producer = NewGuardianProofProducer(encoding.TierGuardianMajorityID, true) blockID = common.Big32 ) res, err := producer.RequestProof( @@ -108,7 +108,7 @@ func TestMinorityRequestProof(t *testing.T) { } var ( - producer = NewGuardianProofProducer(&SGXProofProducer{Dummy: true}, encoding.TierGuardianMinorityID, false) + producer = NewGuardianProofProducer(encoding.TierGuardianMinorityID, false) blockID = common.Big32 ) res, err := producer.RequestProof( @@ -145,7 +145,7 @@ func TestRequestMinorityProofReturnLivenessBond(t *testing.T) { } var ( - producer = NewGuardianProofProducer(&SGXProofProducer{Dummy: true}, encoding.TierGuardianMinorityID, true) + producer = NewGuardianProofProducer(encoding.TierGuardianMinorityID, true) blockID = common.Big32 ) res, err := producer.RequestProof(