diff --git a/bindings/.githead b/bindings/.githead index 97100565a..9db3a8a14 100644 --- a/bindings/.githead +++ b/bindings/.githead @@ -1 +1 @@ -11af1ccb4ba671543084d1d5b99dfddf4749670f +0496ff40e374354b83d17121e4760391fed90a31 diff --git a/cmd/flags/common.go b/cmd/flags/common.go index 584ad0fba..98daef4ab 100644 --- a/cmd/flags/common.go +++ b/cmd/flags/common.go @@ -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", diff --git a/cmd/flags/driver.go b/cmd/flags/driver.go index 8cfd0a117..dbf24bd4b 100644 --- a/cmd/flags/driver.go +++ b/cmd/flags/driver.go @@ -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", diff --git a/driver/config.go b/driver/config.go index 1a9857d8f..e056321c7 100644 --- a/driver/config.go +++ b/driver/config.go @@ -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{ diff --git a/driver/config_test.go b/driver/config_test.go index b290fc512..8d9e3e56a 100644 --- a/driver/config_test.go +++ b/driver/config_test.go @@ -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") @@ -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()) @@ -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, @@ -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}, diff --git a/prover/config.go b/prover/config.go index cdc4306f1..54e7fdad1 100644 --- a/prover/config.go +++ b/prover/config.go @@ -19,6 +19,7 @@ import ( type Config struct { L1WsEndpoint string L1HttpEndpoint string + L1BeaconEndpoint string L2WsEndpoint string L2HttpEndpoint string TaikoL1Address common.Address @@ -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)) @@ -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)), diff --git a/prover/config_test.go b/prover/config_test.go index d8af0a843..7e6a792f4 100644 --- a/prover/config_test.go +++ b/prover/config_test.go @@ -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() { @@ -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()) @@ -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, @@ -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}, diff --git a/prover/proof_producer/sgx_producer.go b/prover/proof_producer/sgx_producer.go index 6e2a33558..5df3278cf 100644 --- a/prover/proof_producer/sgx_producer.go +++ b/prover/proof_producer/sgx_producer.go @@ -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 } @@ -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. @@ -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 } diff --git a/prover/prover.go b/prover/prover.go index e5ac87e85..2247a5d9d 100644 --- a/prover/prover.go +++ b/prover/prover.go @@ -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 } @@ -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 {