Skip to content
This repository was archived by the owner on May 11, 2024. It is now read-only.

Commit fcb5f96

Browse files
committed
feat(prover): make guardian provers connecting to their local raiko service
1 parent c0a5ddd commit fcb5f96

File tree

4 files changed

+18
-10
lines changed

4 files changed

+18
-10
lines changed

prover/config.go

-5
Original file line numberDiff line numberDiff line change
@@ -118,11 +118,6 @@ func NewConfigFromCliContext(c *cli.Context) (*Config, error) {
118118
}
119119
}
120120

121-
// If we are not running a guardian prover, a raiko host endpoint is required.
122-
if !c.IsSet(flags.GuardianProver.Name) && !c.IsSet(flags.RaikoHostEndpoint.Name) {
123-
return nil, errors.New("raiko host not provided")
124-
}
125-
126121
var (
127122
raikoL1Endpoint = c.String(flags.RaikoL1Endpoint.Name)
128123
raikoL1BeaconEndpoint = c.String(flags.RaikoL1BeaconEndpoint.Name)

prover/init.go

+7-1
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,13 @@ func (p *Prover) initProofSubmitters(
113113
Dummy: p.cfg.Dummy,
114114
}
115115
case encoding.TierGuardianID:
116-
producer = proofProducer.NewGuardianProofProducer(p.cfg.EnableLivenessBondProof)
116+
producer = proofProducer.NewGuardianProofProducer(&proofProducer.SGXProofProducer{
117+
RaikoHostEndpoint: p.cfg.RaikoHostEndpoint,
118+
L1Endpoint: p.cfg.RaikoL1Endpoint,
119+
L1BeaconEndpoint: p.cfg.RaikoL1BeaconEndpoint,
120+
L2Endpoint: p.cfg.RaikoL2Endpoint,
121+
Dummy: p.cfg.Dummy,
122+
}, p.cfg.EnableLivenessBondProof)
117123
default:
118124
return fmt.Errorf("unsupported tier: %d", tier.ID)
119125
}

prover/proof_producer/guardian_producer.go

+9-2
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,12 @@ import (
1515
// GuardianProofProducer always returns an optimistic (dummy) proof.
1616
type GuardianProofProducer struct {
1717
returnLivenessBond bool
18-
DummyProofProducer
18+
*SGXProofProducer
1919
}
2020

21-
func NewGuardianProofProducer(returnLivenessBond bool) *GuardianProofProducer {
21+
func NewGuardianProofProducer(sgxProofProducer *SGXProofProducer, returnLivenessBond bool) *GuardianProofProducer {
2222
return &GuardianProofProducer{
23+
SGXProofProducer: sgxProofProducer,
2324
returnLivenessBond: returnLivenessBond,
2425
}
2526
}
@@ -51,6 +52,12 @@ func (g *GuardianProofProducer) RequestProof(
5152
}, nil
5253
}
5354

55+
// Each guardian prover should check the block hash with raiko at first,
56+
// before submitting the guardian proof.
57+
if _, err := g.SGXProofProducer.requestProof(opts); err != nil {
58+
return nil, err
59+
}
60+
5461
return g.DummyProofProducer.RequestProof(opts, blockID, meta, header, g.Tier())
5562
}
5663

prover/proof_producer/guardian_producer_test.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ func TestGuardianProducerRequestProof(t *testing.T) {
3333
}
3434

3535
var (
36-
producer = NewGuardianProofProducer(false)
36+
producer = NewGuardianProofProducer(&SGXProofProducer{Dummy: true}, false)
3737
blockID = common.Big32
3838
)
3939
res, err := producer.RequestProof(
@@ -70,7 +70,7 @@ func TestGuardianProducerRequestProofReturnLivenessBond(t *testing.T) {
7070
}
7171

7272
var (
73-
producer = NewGuardianProofProducer(true)
73+
producer = NewGuardianProofProducer(&SGXProofProducer{Dummy: true}, true)
7474
blockID = common.Big32
7575
)
7676
res, err := producer.RequestProof(

0 commit comments

Comments
 (0)