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

Commit

Permalink
Merge branch 'main' into fix-tier-fee
Browse files Browse the repository at this point in the history
  • Loading branch information
RogerLamTd committed Apr 5, 2024
2 parents 7995f97 + fd98d4b commit f1eaa67
Show file tree
Hide file tree
Showing 9 changed files with 110 additions and 52 deletions.
2 changes: 1 addition & 1 deletion bindings/.githead
Original file line number Diff line number Diff line change
@@ -1 +1 @@
b853c08eb82cf93bba81b51169c1add8b42f4b09
a05e7b209611404d64579982d6769ebbf70506c1
105 changes: 77 additions & 28 deletions bindings/gen_taiko_l1.go

Large diffs are not rendered by default.

12 changes: 12 additions & 0 deletions cmd/flags/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,18 @@ var (
Required: true,
Category: commonCategory,
}
L2AuthEndpoint = &cli.StringFlag{
Name: "l2.auth",
Usage: "Authenticated HTTP RPC endpoint of a L2 taiko-geth execution engine",
Required: true,
Category: commonCategory,
}
JWTSecret = &cli.StringFlag{
Name: "jwtSecret",
Usage: "Path to a JWT secret to use for authenticated RPC endpoints",
Required: true,
Category: commonCategory,
}
TaikoL1Address = &cli.StringFlag{
Name: "taikoL1",
Usage: "TaikoL1 contract `address`",
Expand Down
16 changes: 0 additions & 16 deletions cmd/flags/driver.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,22 +6,6 @@ import (
"github.com/urfave/cli/v2"
)

// Flags used by driver.
var (
L2AuthEndpoint = &cli.StringFlag{
Name: "l2.auth",
Usage: "Authenticated HTTP RPC endpoint of a L2 taiko-geth execution engine",
Required: true,
Category: driverCategory,
}
JWTSecret = &cli.StringFlag{
Name: "jwtSecret",
Usage: "Path to a JWT secret to use for authenticated RPC endpoints",
Required: true,
Category: driverCategory,
}
)

// Optional flags used by driver.
var (
P2PSyncVerifiedBlocks = &cli.BoolFlag{
Expand Down
2 changes: 2 additions & 0 deletions cmd/flags/proposer.go
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,8 @@ var (
// ProposerFlags All proposer flags.
var ProposerFlags = MergeFlags(CommonFlags, []cli.Flag{
L2HTTPEndpoint,
L2AuthEndpoint,
JWTSecret,
TaikoTokenAddress,
L1ProposerPrivKey,
L2SuggestedFeeRecipient,
Expand Down
4 changes: 2 additions & 2 deletions pkg/rpc/methods.go
Original file line number Diff line number Diff line change
Expand Up @@ -420,14 +420,14 @@ func (c *Client) CheckL1Reorg(ctx context.Context, blockID *big.Int) (*ReorgChec
// If we rollback to the genesis block, then there is no L1Origin information recorded in the L2 execution
// engine for that block, so we will query the protocol to use `GenesisHeight` value to reset the L1 cursor.
if blockID.Cmp(common.Big0) == 0 {
stateVars, err := c.TaikoL1.GetStateVariables(&bind.CallOpts{Context: ctxWithTimeout})
slotA, _, err := c.TaikoL1.GetStateVariables(&bind.CallOpts{Context: ctxWithTimeout})
if err != nil {
return result, err
}

if result.L1CurrentToReset, err = c.L1.HeaderByNumber(
ctxWithTimeout,
new(big.Int).SetUint64(stateVars.A.GenesisHeight),
new(big.Int).SetUint64(slotA.GenesisHeight),
); err != nil {
return nil, err
}
Expand Down
7 changes: 5 additions & 2 deletions pkg/rpc/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,14 @@ func GetProtocolStateVariables(
A bindings.TaikoDataSlotA
B bindings.TaikoDataSlotB
}, error) {
stateVars, err := taikoL1Client.GetStateVariables(opts)
slotA, slotB, err := taikoL1Client.GetStateVariables(opts)
if err != nil {
return nil, err
}
return &stateVars, nil
return &struct {
A bindings.TaikoDataSlotA
B bindings.TaikoDataSlotB
}{slotA, slotB}, nil
}

// CheckProverBalance checks if the prover has the necessary allowance and
Expand Down
8 changes: 8 additions & 0 deletions proposer/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import (

"github.com/taikoxyz/taiko-client/cmd/flags"
pkgFlags "github.com/taikoxyz/taiko-client/pkg/flags"
"github.com/taikoxyz/taiko-client/pkg/jwt"
"github.com/taikoxyz/taiko-client/pkg/rpc"
)

Expand Down Expand Up @@ -48,6 +49,11 @@ type Config struct {
// NewConfigFromCliContext initializes a Config instance from
// command line flags.
func NewConfigFromCliContext(c *cli.Context) (*Config, error) {
jwtSecret, err := jwt.ParseSecretFromFile(c.String(flags.JWTSecret.Name))
if err != nil {
return nil, fmt.Errorf("invalid JWT secret file: %w", err)
}

l1ProposerPrivKey, err := crypto.ToECDSA(
common.Hex2Bytes(c.String(flags.L1ProposerPrivKey.Name)),
)
Expand Down Expand Up @@ -85,6 +91,8 @@ func NewConfigFromCliContext(c *cli.Context) (*Config, error) {
L2Endpoint: c.String(flags.L2HTTPEndpoint.Name),
TaikoL1Address: common.HexToAddress(c.String(flags.TaikoL1Address.Name)),
TaikoL2Address: common.HexToAddress(c.String(flags.TaikoL2Address.Name)),
L2EngineEndpoint: c.String(flags.L2AuthEndpoint.Name),
JwtSecret: string(jwtSecret),
TaikoTokenAddress: common.HexToAddress(c.String(flags.TaikoTokenAddress.Name)),
Timeout: c.Duration(flags.RPCTimeout.Name),
},
Expand Down
6 changes: 3 additions & 3 deletions prover/event_handler/util_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,21 +26,21 @@ func (s *ProverEventHandlerTestSuite) TestGetProvingWindowNotFound() {
}

func (s *ProverEventHandlerTestSuite) TestIsBlockVerified() {
vars, err := s.RPCClient.TaikoL1.GetStateVariables(nil)
_, slotB, err := s.RPCClient.TaikoL1.GetStateVariables(nil)
s.Nil(err)

verified, err := isBlockVerified(
context.Background(),
s.RPCClient,
new(big.Int).SetUint64(vars.B.LastVerifiedBlockId),
new(big.Int).SetUint64(slotB.LastVerifiedBlockId),
)
s.Nil(err)
s.True(verified)

verified, err = isBlockVerified(
context.Background(),
s.RPCClient,
new(big.Int).SetUint64(vars.B.LastVerifiedBlockId+1),
new(big.Int).SetUint64(slotB.LastVerifiedBlockId+1),
)
s.Nil(err)
s.False(verified)
Expand Down

0 comments on commit f1eaa67

Please sign in to comment.