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

Commit 93e0660

Browse files
feat(prover): update SGXProducer (#566)
1 parent 069b8a5 commit 93e0660

File tree

9 files changed

+52
-25
lines changed

9 files changed

+52
-25
lines changed

bindings/.githead

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
11af1ccb4ba671543084d1d5b99dfddf4749670f
1+
0496ff40e374354b83d17121e4760391fed90a31

cmd/flags/common.go

+5
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,11 @@ var (
3535
Required: true,
3636
Category: commonCategory,
3737
}
38+
L1BeaconEndpoint = &cli.StringFlag{
39+
Name: "l1.beacon",
40+
Usage: "HTTP RPC endpoint of a L1 beacon node",
41+
Category: commonCategory,
42+
}
3843
L2HTTPEndpoint = &cli.StringFlag{
3944
Name: "l2.http",
4045
Usage: "HTTP RPC endpoint of a L2 taiko-geth execution engine",

cmd/flags/driver.go

-6
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,6 @@ var (
1414
Required: true,
1515
Category: driverCategory,
1616
}
17-
L1BeaconEndpoint = &cli.StringFlag{
18-
Name: "l1.beacon",
19-
Usage: "HTTP RPC endpoint of a L1 consensus client",
20-
Required: true,
21-
Category: driverCategory,
22-
}
2317
JWTSecret = &cli.StringFlag{
2418
Name: "jwtSecret",
2519
Usage: "Path to a JWT secret to use for authenticated RPC endpoints",

driver/config.go

+4
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,10 @@ func NewConfigFromCliContext(c *cli.Context) (*Config, error) {
3838
return nil, errors.New("empty L2 check point URL")
3939
}
4040

41+
if !c.IsSet(flags.L1BeaconEndpoint.Name) {
42+
return nil, errors.New("empty L1 beacon endpoint")
43+
}
44+
4145
var timeout = c.Duration(flags.RPCTimeout.Name)
4246
return &Config{
4347
ClientConfig: &rpc.ClientConfig{

driver/config_test.go

+4
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import (
1212

1313
var (
1414
l1Endpoint = os.Getenv("L1_NODE_WS_ENDPOINT")
15+
l1BeaconEndpoint = os.Getenv("L1_NODE_HTTP_ENDPOINT")
1516
l2Endpoint = os.Getenv("L2_EXECUTION_ENGINE_WS_ENDPOINT")
1617
l2CheckPoint = os.Getenv("L2_EXECUTION_ENGINE_HTTP_ENDPOINT")
1718
l2EngineEndpoint = os.Getenv("L2_EXECUTION_ENGINE_AUTH_ENDPOINT")
@@ -27,6 +28,7 @@ func (s *DriverTestSuite) TestNewConfigFromCliContext() {
2728
c, err := NewConfigFromCliContext(ctx)
2829
s.Nil(err)
2930
s.Equal(l1Endpoint, c.L1Endpoint)
31+
s.Equal(l1BeaconEndpoint, c.L1BeaconEndpoint)
3032
s.Equal(l2Endpoint, c.L2Endpoint)
3133
s.Equal(l2EngineEndpoint, c.L2EngineEndpoint)
3234
s.Equal(taikoL1, c.TaikoL1Address.String())
@@ -44,6 +46,7 @@ func (s *DriverTestSuite) TestNewConfigFromCliContext() {
4446
s.Nil(app.Run([]string{
4547
"TestNewConfigFromCliContext",
4648
"--" + flags.L1WSEndpoint.Name, l1Endpoint,
49+
"--" + flags.L1BeaconEndpoint.Name, l1BeaconEndpoint,
4750
"--" + flags.L2WSEndpoint.Name, l2Endpoint,
4851
"--" + flags.L2AuthEndpoint.Name, l2EngineEndpoint,
4952
"--" + flags.TaikoL1Address.Name, taikoL1,
@@ -78,6 +81,7 @@ func (s *DriverTestSuite) SetupApp() *cli.App {
7881
app := cli.NewApp()
7982
app.Flags = []cli.Flag{
8083
&cli.StringFlag{Name: flags.L1WSEndpoint.Name},
84+
&cli.StringFlag{Name: flags.L1BeaconEndpoint.Name},
8185
&cli.StringFlag{Name: flags.L2WSEndpoint.Name},
8286
&cli.StringFlag{Name: flags.L2AuthEndpoint.Name},
8387
&cli.StringFlag{Name: flags.TaikoL1Address.Name},

prover/config.go

+6
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ import (
1919
type Config struct {
2020
L1WsEndpoint string
2121
L1HttpEndpoint string
22+
L1BeaconEndpoint string
2223
L2WsEndpoint string
2324
L2HttpEndpoint string
2425
TaikoL1Address common.Address
@@ -69,6 +70,10 @@ func NewConfigFromCliContext(c *cli.Context) (*Config, error) {
6970
return nil, fmt.Errorf("invalid L1 prover private key: %w", err)
7071
}
7172

73+
if !c.IsSet(flags.L1BeaconEndpoint.Name) {
74+
return nil, errors.New("empty L1 beacon endpoint")
75+
}
76+
7277
var startingBlockID *big.Int
7378
if c.IsSet(flags.StartingBlockID.Name) {
7479
startingBlockID = new(big.Int).SetUint64(c.Uint64(flags.StartingBlockID.Name))
@@ -139,6 +144,7 @@ func NewConfigFromCliContext(c *cli.Context) (*Config, error) {
139144
return &Config{
140145
L1WsEndpoint: c.String(flags.L1WSEndpoint.Name),
141146
L1HttpEndpoint: c.String(flags.L1HTTPEndpoint.Name),
147+
L1BeaconEndpoint: c.String(flags.L1BeaconEndpoint.Name),
142148
L2WsEndpoint: c.String(flags.L2WSEndpoint.Name),
143149
L2HttpEndpoint: c.String(flags.L2HTTPEndpoint.Name),
144150
TaikoL1Address: common.HexToAddress(c.String(flags.TaikoL1Address.Name)),

prover/config_test.go

+15-11
Original file line numberDiff line numberDiff line change
@@ -13,17 +13,18 @@ import (
1313
)
1414

1515
var (
16-
l1WsEndpoint = os.Getenv("L1_NODE_WS_ENDPOINT")
17-
l1HttpEndpoint = os.Getenv("L1_NODE_HTTP_ENDPOINT")
18-
l1NodeVersion = "1.0.0"
19-
l2WsEndpoint = os.Getenv("L2_EXECUTION_ENGINE_WS_ENDPOINT")
20-
l2HttpEndpoint = os.Getenv("L2_EXECUTION_ENGINE_HTTP_ENDPOINT")
21-
l2NodeVersion = "0.1.0"
22-
taikoL1 = os.Getenv("TAIKO_L1_ADDRESS")
23-
taikoL2 = os.Getenv("TAIKO_L2_ADDRESS")
24-
allowance = "10000000000000000000000000000000000000000000000000"
25-
rpcTimeout = 5 * time.Second
26-
minTierFee = 1024
16+
l1WsEndpoint = os.Getenv("L1_NODE_WS_ENDPOINT")
17+
l1HttpEndpoint = os.Getenv("L1_NODE_HTTP_ENDPOINT")
18+
l1BeaconEndpoint = os.Getenv("L1_NODE_HTTP_ENDPOINT")
19+
l1NodeVersion = "1.0.0"
20+
l2WsEndpoint = os.Getenv("L2_EXECUTION_ENGINE_WS_ENDPOINT")
21+
l2HttpEndpoint = os.Getenv("L2_EXECUTION_ENGINE_HTTP_ENDPOINT")
22+
l2NodeVersion = "0.1.0"
23+
taikoL1 = os.Getenv("TAIKO_L1_ADDRESS")
24+
taikoL2 = os.Getenv("TAIKO_L2_ADDRESS")
25+
allowance = "10000000000000000000000000000000000000000000000000"
26+
rpcTimeout = 5 * time.Second
27+
minTierFee = 1024
2728
)
2829

2930
func (s *ProverTestSuite) TestNewConfigFromCliContextGuardianProver() {
@@ -33,6 +34,7 @@ func (s *ProverTestSuite) TestNewConfigFromCliContextGuardianProver() {
3334
s.Nil(err)
3435
s.Equal(l1WsEndpoint, c.L1WsEndpoint)
3536
s.Equal(l1HttpEndpoint, c.L1HttpEndpoint)
37+
s.Equal(l1BeaconEndpoint, c.L1BeaconEndpoint)
3638
s.Equal(l2WsEndpoint, c.L2WsEndpoint)
3739
s.Equal(l2HttpEndpoint, c.L2HttpEndpoint)
3840
s.Equal(taikoL1, c.TaikoL1Address.String())
@@ -69,6 +71,7 @@ func (s *ProverTestSuite) TestNewConfigFromCliContextGuardianProver() {
6971
"TestNewConfigFromCliContextGuardianProver",
7072
"--" + flags.L1WSEndpoint.Name, l1WsEndpoint,
7173
"--" + flags.L1HTTPEndpoint.Name, l1HttpEndpoint,
74+
"--" + flags.L1BeaconEndpoint.Name, l1BeaconEndpoint,
7275
"--" + flags.L2WSEndpoint.Name, l2WsEndpoint,
7376
"--" + flags.L2HTTPEndpoint.Name, l2HttpEndpoint,
7477
"--" + flags.TaikoL1Address.Name, taikoL1,
@@ -111,6 +114,7 @@ func (s *ProverTestSuite) SetupApp() *cli.App {
111114
app.Flags = []cli.Flag{
112115
&cli.StringFlag{Name: flags.L1WSEndpoint.Name},
113116
&cli.StringFlag{Name: flags.L1HTTPEndpoint.Name},
117+
&cli.StringFlag{Name: flags.L1BeaconEndpoint.Name},
114118
&cli.StringFlag{Name: flags.L2WSEndpoint.Name},
115119
&cli.StringFlag{Name: flags.L2HTTPEndpoint.Name},
116120
&cli.StringFlag{Name: flags.TaikoL1Address.Name},

prover/proof_producer/sgx_producer.go

+10-6
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ import (
2525
type SGXProofProducer struct {
2626
RaikoHostEndpoint string // a proverd RPC endpoint
2727
L1Endpoint string // a L1 node RPC endpoint
28+
L1BeaconEndpoint string // a L1 beacon node RPC endpoint
2829
L2Endpoint string // a L2 execution engine's RPC endpoint
2930
*DummyProofProducer
3031
}
@@ -39,12 +40,13 @@ type SGXRequestProofBody struct {
3940

4041
// SGXRequestProofBodyParam represents the JSON body of RequestProofBody's `param` field.
4142
type SGXRequestProofBodyParam struct {
42-
Type string `json:"type"`
43-
Block *big.Int `json:"block"`
44-
L2RPC string `json:"l2Rpc"`
45-
L1RPC string `json:"l1Rpc"`
46-
Prover string `json:"prover"`
47-
Graffiti string `json:"graffiti"`
43+
Type string `json:"type"`
44+
Block *big.Int `json:"block"`
45+
L2RPC string `json:"l2Rpc"`
46+
L1RPC string `json:"l1Rpc"`
47+
L1BeaconRPC string `json:"l1BeaconRpc"`
48+
Prover string `json:"prover"`
49+
Graffiti string `json:"graffiti"`
4850
}
4951

5052
// SGXRequestProofBodyResponse represents the JSON body of the response of the proof requests.
@@ -68,11 +70,13 @@ type RaikoHostOutput struct {
6870
func NewSGXProducer(
6971
raikoHostEndpoint string,
7072
l1Endpoint string,
73+
l1BeaconEndpoint string,
7174
l2Endpoint string,
7275
) (*SGXProofProducer, error) {
7376
return &SGXProofProducer{
7477
RaikoHostEndpoint: raikoHostEndpoint,
7578
L1Endpoint: l1Endpoint,
79+
L1BeaconEndpoint: l1BeaconEndpoint,
7680
L2Endpoint: l2Endpoint,
7781
}, nil
7882
}

prover/prover.go

+7-1
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,12 @@ func InitFromConfig(ctx context.Context, p *Prover, cfg *Config) (err error) {
162162
case encoding.TierOptimisticID:
163163
producer = &proofProducer.OptimisticProofProducer{DummyProofProducer: new(proofProducer.DummyProofProducer)}
164164
case encoding.TierSgxID:
165-
sgxProducer, err := proofProducer.NewSGXProducer(cfg.RaikoHostEndpoint, cfg.L1HttpEndpoint, cfg.L2HttpEndpoint)
165+
sgxProducer, err := proofProducer.NewSGXProducer(
166+
cfg.RaikoHostEndpoint,
167+
cfg.L1HttpEndpoint,
168+
cfg.L1BeaconEndpoint,
169+
cfg.L2HttpEndpoint,
170+
)
166171
if err != nil {
167172
return err
168173
}
@@ -186,6 +191,7 @@ func InitFromConfig(ctx context.Context, p *Prover, cfg *Config) (err error) {
186191
sgxProducer, err := proofProducer.NewSGXProducer(
187192
cfg.RaikoHostEndpoint,
188193
cfg.L1HttpEndpoint,
194+
cfg.L1BeaconEndpoint,
189195
cfg.L2HttpEndpoint,
190196
)
191197
if err != nil {

0 commit comments

Comments
 (0)