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

feat(prover): update SGXProducer #566

Merged
merged 4 commits into from
Feb 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion bindings/.githead
Original file line number Diff line number Diff line change
@@ -1 +1 @@
11af1ccb4ba671543084d1d5b99dfddf4749670f
0496ff40e374354b83d17121e4760391fed90a31
5 changes: 5 additions & 0 deletions cmd/flags/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,11 @@ var (
Required: true,
Category: commonCategory,
}
L1BeaconEndpoint = &cli.StringFlag{
Name: "l1.beacon",
Usage: "HTTP RPC endpoint of a L1 beacon node",
Category: commonCategory,
}
L2HTTPEndpoint = &cli.StringFlag{
Name: "l2.http",
Usage: "HTTP RPC endpoint of a L2 taiko-geth execution engine",
Expand Down
6 changes: 0 additions & 6 deletions cmd/flags/driver.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,6 @@ var (
Required: true,
Category: driverCategory,
}
L1BeaconEndpoint = &cli.StringFlag{
Name: "l1.beacon",
Usage: "HTTP RPC endpoint of a L1 consensus client",
Required: true,
Category: driverCategory,
}
JWTSecret = &cli.StringFlag{
Name: "jwtSecret",
Usage: "Path to a JWT secret to use for authenticated RPC endpoints",
Expand Down
4 changes: 4 additions & 0 deletions driver/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,10 @@ func NewConfigFromCliContext(c *cli.Context) (*Config, error) {
return nil, errors.New("empty L2 check point URL")
}

if !c.IsSet(flags.L1BeaconEndpoint.Name) {
return nil, errors.New("empty L1 beacon endpoint")
}

var timeout = c.Duration(flags.RPCTimeout.Name)
return &Config{
ClientConfig: &rpc.ClientConfig{
Expand Down
4 changes: 4 additions & 0 deletions driver/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import (

var (
l1Endpoint = os.Getenv("L1_NODE_WS_ENDPOINT")
l1BeaconEndpoint = os.Getenv("L1_NODE_HTTP_ENDPOINT")
l2Endpoint = os.Getenv("L2_EXECUTION_ENGINE_WS_ENDPOINT")
l2CheckPoint = os.Getenv("L2_EXECUTION_ENGINE_HTTP_ENDPOINT")
l2EngineEndpoint = os.Getenv("L2_EXECUTION_ENGINE_AUTH_ENDPOINT")
Expand All @@ -27,6 +28,7 @@ func (s *DriverTestSuite) TestNewConfigFromCliContext() {
c, err := NewConfigFromCliContext(ctx)
s.Nil(err)
s.Equal(l1Endpoint, c.L1Endpoint)
s.Equal(l1BeaconEndpoint, c.L1BeaconEndpoint)
s.Equal(l2Endpoint, c.L2Endpoint)
s.Equal(l2EngineEndpoint, c.L2EngineEndpoint)
s.Equal(taikoL1, c.TaikoL1Address.String())
Expand All @@ -44,6 +46,7 @@ func (s *DriverTestSuite) TestNewConfigFromCliContext() {
s.Nil(app.Run([]string{
"TestNewConfigFromCliContext",
"--" + flags.L1WSEndpoint.Name, l1Endpoint,
"--" + flags.L1BeaconEndpoint.Name, l1BeaconEndpoint,
"--" + flags.L2WSEndpoint.Name, l2Endpoint,
"--" + flags.L2AuthEndpoint.Name, l2EngineEndpoint,
"--" + flags.TaikoL1Address.Name, taikoL1,
Expand Down Expand Up @@ -78,6 +81,7 @@ func (s *DriverTestSuite) SetupApp() *cli.App {
app := cli.NewApp()
app.Flags = []cli.Flag{
&cli.StringFlag{Name: flags.L1WSEndpoint.Name},
&cli.StringFlag{Name: flags.L1BeaconEndpoint.Name},
&cli.StringFlag{Name: flags.L2WSEndpoint.Name},
&cli.StringFlag{Name: flags.L2AuthEndpoint.Name},
&cli.StringFlag{Name: flags.TaikoL1Address.Name},
Expand Down
6 changes: 6 additions & 0 deletions prover/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import (
type Config struct {
L1WsEndpoint string
L1HttpEndpoint string
L1BeaconEndpoint string
L2WsEndpoint string
L2HttpEndpoint string
TaikoL1Address common.Address
Expand Down Expand Up @@ -69,6 +70,10 @@ func NewConfigFromCliContext(c *cli.Context) (*Config, error) {
return nil, fmt.Errorf("invalid L1 prover private key: %w", err)
}

if !c.IsSet(flags.L1BeaconEndpoint.Name) {
return nil, errors.New("empty L1 beacon endpoint")
}

var startingBlockID *big.Int
if c.IsSet(flags.StartingBlockID.Name) {
startingBlockID = new(big.Int).SetUint64(c.Uint64(flags.StartingBlockID.Name))
Expand Down Expand Up @@ -139,6 +144,7 @@ func NewConfigFromCliContext(c *cli.Context) (*Config, error) {
return &Config{
L1WsEndpoint: c.String(flags.L1WSEndpoint.Name),
L1HttpEndpoint: c.String(flags.L1HTTPEndpoint.Name),
L1BeaconEndpoint: c.String(flags.L1BeaconEndpoint.Name),
L2WsEndpoint: c.String(flags.L2WSEndpoint.Name),
L2HttpEndpoint: c.String(flags.L2HTTPEndpoint.Name),
TaikoL1Address: common.HexToAddress(c.String(flags.TaikoL1Address.Name)),
Expand Down
26 changes: 15 additions & 11 deletions prover/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,18 @@ import (
)

var (
l1WsEndpoint = os.Getenv("L1_NODE_WS_ENDPOINT")
l1HttpEndpoint = os.Getenv("L1_NODE_HTTP_ENDPOINT")
l1NodeVersion = "1.0.0"
l2WsEndpoint = os.Getenv("L2_EXECUTION_ENGINE_WS_ENDPOINT")
l2HttpEndpoint = os.Getenv("L2_EXECUTION_ENGINE_HTTP_ENDPOINT")
l2NodeVersion = "0.1.0"
taikoL1 = os.Getenv("TAIKO_L1_ADDRESS")
taikoL2 = os.Getenv("TAIKO_L2_ADDRESS")
allowance = "10000000000000000000000000000000000000000000000000"
rpcTimeout = 5 * time.Second
minTierFee = 1024
l1WsEndpoint = os.Getenv("L1_NODE_WS_ENDPOINT")
l1HttpEndpoint = os.Getenv("L1_NODE_HTTP_ENDPOINT")
l1BeaconEndpoint = os.Getenv("L1_NODE_HTTP_ENDPOINT")
l1NodeVersion = "1.0.0"
l2WsEndpoint = os.Getenv("L2_EXECUTION_ENGINE_WS_ENDPOINT")
l2HttpEndpoint = os.Getenv("L2_EXECUTION_ENGINE_HTTP_ENDPOINT")
l2NodeVersion = "0.1.0"
taikoL1 = os.Getenv("TAIKO_L1_ADDRESS")
taikoL2 = os.Getenv("TAIKO_L2_ADDRESS")
allowance = "10000000000000000000000000000000000000000000000000"
rpcTimeout = 5 * time.Second
minTierFee = 1024
)

func (s *ProverTestSuite) TestNewConfigFromCliContextGuardianProver() {
Expand All @@ -33,6 +34,7 @@ func (s *ProverTestSuite) TestNewConfigFromCliContextGuardianProver() {
s.Nil(err)
s.Equal(l1WsEndpoint, c.L1WsEndpoint)
s.Equal(l1HttpEndpoint, c.L1HttpEndpoint)
s.Equal(l1BeaconEndpoint, c.L1BeaconEndpoint)
s.Equal(l2WsEndpoint, c.L2WsEndpoint)
s.Equal(l2HttpEndpoint, c.L2HttpEndpoint)
s.Equal(taikoL1, c.TaikoL1Address.String())
Expand Down Expand Up @@ -69,6 +71,7 @@ func (s *ProverTestSuite) TestNewConfigFromCliContextGuardianProver() {
"TestNewConfigFromCliContextGuardianProver",
"--" + flags.L1WSEndpoint.Name, l1WsEndpoint,
"--" + flags.L1HTTPEndpoint.Name, l1HttpEndpoint,
"--" + flags.L1BeaconEndpoint.Name, l1BeaconEndpoint,
"--" + flags.L2WSEndpoint.Name, l2WsEndpoint,
"--" + flags.L2HTTPEndpoint.Name, l2HttpEndpoint,
"--" + flags.TaikoL1Address.Name, taikoL1,
Expand Down Expand Up @@ -111,6 +114,7 @@ func (s *ProverTestSuite) SetupApp() *cli.App {
app.Flags = []cli.Flag{
&cli.StringFlag{Name: flags.L1WSEndpoint.Name},
&cli.StringFlag{Name: flags.L1HTTPEndpoint.Name},
&cli.StringFlag{Name: flags.L1BeaconEndpoint.Name},
&cli.StringFlag{Name: flags.L2WSEndpoint.Name},
&cli.StringFlag{Name: flags.L2HTTPEndpoint.Name},
&cli.StringFlag{Name: flags.TaikoL1Address.Name},
Expand Down
16 changes: 10 additions & 6 deletions prover/proof_producer/sgx_producer.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import (
type SGXProofProducer struct {
RaikoHostEndpoint string // a proverd RPC endpoint
L1Endpoint string // a L1 node RPC endpoint
L1BeaconEndpoint string // a L1 beacon node RPC endpoint
L2Endpoint string // a L2 execution engine's RPC endpoint
*DummyProofProducer
}
Expand All @@ -39,12 +40,13 @@ type SGXRequestProofBody struct {

// SGXRequestProofBodyParam represents the JSON body of RequestProofBody's `param` field.
type SGXRequestProofBodyParam struct {
Type string `json:"type"`
Block *big.Int `json:"block"`
L2RPC string `json:"l2Rpc"`
L1RPC string `json:"l1Rpc"`
Prover string `json:"prover"`
Graffiti string `json:"graffiti"`
Type string `json:"type"`
Block *big.Int `json:"block"`
L2RPC string `json:"l2Rpc"`
L1RPC string `json:"l1Rpc"`
L1BeaconRPC string `json:"l1BeaconRpc"`
Prover string `json:"prover"`
Graffiti string `json:"graffiti"`
}

// SGXRequestProofBodyResponse represents the JSON body of the response of the proof requests.
Expand All @@ -68,11 +70,13 @@ type RaikoHostOutput struct {
func NewSGXProducer(
raikoHostEndpoint string,
l1Endpoint string,
l1BeaconEndpoint string,
l2Endpoint string,
) (*SGXProofProducer, error) {
return &SGXProofProducer{
RaikoHostEndpoint: raikoHostEndpoint,
L1Endpoint: l1Endpoint,
L1BeaconEndpoint: l1BeaconEndpoint,
L2Endpoint: l2Endpoint,
}, nil
}
Expand Down
8 changes: 7 additions & 1 deletion prover/prover.go
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,12 @@ func InitFromConfig(ctx context.Context, p *Prover, cfg *Config) (err error) {
case encoding.TierOptimisticID:
producer = &proofProducer.OptimisticProofProducer{DummyProofProducer: new(proofProducer.DummyProofProducer)}
case encoding.TierSgxID:
sgxProducer, err := proofProducer.NewSGXProducer(cfg.RaikoHostEndpoint, cfg.L1HttpEndpoint, cfg.L2HttpEndpoint)
sgxProducer, err := proofProducer.NewSGXProducer(
cfg.RaikoHostEndpoint,
cfg.L1HttpEndpoint,
cfg.L1BeaconEndpoint,
cfg.L2HttpEndpoint,
)
if err != nil {
return err
}
Expand All @@ -186,6 +191,7 @@ func InitFromConfig(ctx context.Context, p *Prover, cfg *Config) (err error) {
sgxProducer, err := proofProducer.NewSGXProducer(
cfg.RaikoHostEndpoint,
cfg.L1HttpEndpoint,
cfg.L1BeaconEndpoint,
cfg.L2HttpEndpoint,
)
if err != nil {
Expand Down
Loading