Skip to content

Commit

Permalink
feat(taiko-client): remove raiko from guardian prover (#17289)
Browse files Browse the repository at this point in the history
Co-authored-by: maskpp <[email protected]>
  • Loading branch information
davidtaikocha and mask-pp authored May 21, 2024
1 parent dc313ff commit bed6414
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 38 deletions.
13 changes: 6 additions & 7 deletions packages/taiko-client/cmd/flags/prover.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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",
Expand Down
4 changes: 4 additions & 0 deletions packages/taiko-client/prover/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down
18 changes: 2 additions & 16 deletions packages/taiko-client/prover/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down
14 changes: 3 additions & 11 deletions packages/taiko-client/prover/proof_producer/guardian_producer.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,26 +13,25 @@ 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,
}
}

// RequestProof implements the ProofProducer interface.
func (g *GuardianProofProducer) RequestProof(
ctx context.Context,
_ context.Context,
opts *ProofRequestOptions,
blockID *big.Int,
meta *bindings.TaikoDataBlockMetadata,
Expand All @@ -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())
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -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(
Expand Down

0 comments on commit bed6414

Please sign in to comment.