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

Commit 3fac9ad

Browse files
committed
feat(driver): rename some variables (#782)
1 parent 683e976 commit 3fac9ad

File tree

5 files changed

+35
-35
lines changed

5 files changed

+35
-35
lines changed

cmd/flags/driver.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import (
88

99
// Optional flags used by driver.
1010
var (
11-
P2PSyncVerifiedBlocks = &cli.BoolFlag{
11+
P2PSync = &cli.BoolFlag{
1212
Name: "p2p.sync",
1313
Usage: "Try P2P syncing blocks between L2 execution engines, " +
1414
"will be helpful to bring a new node online quickly",
@@ -54,7 +54,7 @@ var DriverFlags = MergeFlags(CommonFlags, []cli.Flag{
5454
L2WSEndpoint,
5555
L2AuthEndpoint,
5656
JWTSecret,
57-
P2PSyncVerifiedBlocks,
57+
P2PSync,
5858
P2PSyncTimeout,
5959
CheckPointSyncURL,
6060
MaxExponent,

driver/chain_syncer/chain_syncer.go

+14-14
Original file line numberDiff line numberDiff line change
@@ -35,15 +35,15 @@ type L2ChainSyncer struct {
3535

3636
// If this flag is activated, will try P2P beacon sync if current node is behind of the protocol's
3737
// the latest verified block head
38-
p2pSyncVerifiedBlocks bool
38+
p2pSync bool
3939
}
4040

4141
// New creates a new chain syncer instance.
4242
func New(
4343
ctx context.Context,
4444
rpc *rpc.Client,
4545
state *state.State,
46-
p2pSyncVerifiedBlocks bool,
46+
p2pSync bool,
4747
p2pSyncTimeout time.Duration,
4848
maxRetrieveExponent uint64,
4949
blobServerEndpoint *url.URL,
@@ -63,14 +63,14 @@ func New(
6363
}
6464

6565
return &L2ChainSyncer{
66-
ctx: ctx,
67-
rpc: rpc,
68-
state: state,
69-
beaconSyncer: beaconSyncer,
70-
blobSyncer: blobSyncer,
71-
progressTracker: tracker,
72-
syncMode: syncMode,
73-
p2pSyncVerifiedBlocks: p2pSyncVerifiedBlocks,
66+
ctx: ctx,
67+
rpc: rpc,
68+
state: state,
69+
beaconSyncer: beaconSyncer,
70+
blobSyncer: blobSyncer,
71+
progressTracker: tracker,
72+
syncMode: syncMode,
73+
p2pSync: p2pSync,
7474
}, nil
7575
}
7676

@@ -81,7 +81,7 @@ func (s *L2ChainSyncer) Sync() error {
8181
return err
8282
}
8383
// If current L2 execution engine's chain is behind of the protocol's latest verified block head, and the
84-
// `P2PSyncVerifiedBlocks` flag is set, try triggering a beacon sync in L2 execution engine to catch up the
84+
// `P2PSync` flag is set, try triggering a beacon sync in L2 execution engine to catch up the
8585
// latest verified block head.
8686
if needNewBeaconSyncTriggered {
8787
if err := s.beaconSyncer.TriggerBeaconSync(blockID); err != nil {
@@ -96,7 +96,7 @@ func (s *L2ChainSyncer) Sync() error {
9696
if s.progressTracker.Triggered() {
9797
log.Info(
9898
"Switch to insert pending blocks one by one",
99-
"p2pEnabled", s.p2pSyncVerifiedBlocks,
99+
"p2pEnabled", s.p2pSync,
100100
"p2pOutOfSync", s.progressTracker.OutOfSync(),
101101
)
102102

@@ -160,13 +160,13 @@ func (s *L2ChainSyncer) AheadOfProtocolVerifiedHead(verifiedHeightToCompare uint
160160

161161
// needNewBeaconSyncTriggered checks whether the current L2 execution engine needs to trigger
162162
// another new beacon sync, the following conditions should be met:
163-
// 1. The `P2PSyncVerifiedBlocks` flag is set.
163+
// 1. The `P2PSync` flag is set.
164164
// 2. The protocol's latest verified block head is not zero.
165165
// 3. The L2 execution engine's chain is behind of the protocol's latest verified block head.
166166
// 4. The L2 execution engine's chain have met a sync timeout issue.
167167
func (s *L2ChainSyncer) needNewBeaconSyncTriggered() (uint64, bool, error) {
168168
// If the flag is not set or there was a finished beacon sync, we simply return false.
169-
if !s.p2pSyncVerifiedBlocks || s.progressTracker.Finished() {
169+
if !s.p2pSync || s.progressTracker.Finished() {
170170
return 0, false, nil
171171
}
172172

driver/config.go

+13-13
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,11 @@ import (
1717
// Config contains the configurations to initialize a Taiko driver.
1818
type Config struct {
1919
*rpc.ClientConfig
20-
P2PSyncVerifiedBlocks bool
21-
P2PSyncTimeout time.Duration
22-
RetryInterval time.Duration
23-
MaxExponent uint64
24-
BlobServerEndpoint *url.URL
20+
P2PSync bool
21+
P2PSyncTimeout time.Duration
22+
RetryInterval time.Duration
23+
MaxExponent uint64
24+
BlobServerEndpoint *url.URL
2525
}
2626

2727
// NewConfigFromCliContext creates a new config instance from
@@ -33,11 +33,11 @@ func NewConfigFromCliContext(c *cli.Context) (*Config, error) {
3333
}
3434

3535
var (
36-
p2pSyncVerifiedBlocks = c.Bool(flags.P2PSyncVerifiedBlocks.Name)
37-
l2CheckPoint = c.String(flags.CheckPointSyncURL.Name)
36+
p2pSync = c.Bool(flags.P2PSync.Name)
37+
l2CheckPoint = c.String(flags.CheckPointSyncURL.Name)
3838
)
3939

40-
if p2pSyncVerifiedBlocks && len(l2CheckPoint) == 0 {
40+
if p2pSync && len(l2CheckPoint) == 0 {
4141
return nil, errors.New("empty L2 check point URL")
4242
}
4343

@@ -67,10 +67,10 @@ func NewConfigFromCliContext(c *cli.Context) (*Config, error) {
6767
JwtSecret: string(jwtSecret),
6868
Timeout: timeout,
6969
},
70-
RetryInterval: c.Duration(flags.BackOffRetryInterval.Name),
71-
P2PSyncVerifiedBlocks: p2pSyncVerifiedBlocks,
72-
P2PSyncTimeout: c.Duration(flags.P2PSyncTimeout.Name),
73-
MaxExponent: c.Uint64(flags.MaxExponent.Name),
74-
BlobServerEndpoint: blobServerEndpoint,
70+
RetryInterval: c.Duration(flags.BackOffRetryInterval.Name),
71+
P2PSync: p2pSync,
72+
P2PSyncTimeout: c.Duration(flags.P2PSyncTimeout.Name),
73+
MaxExponent: c.Uint64(flags.MaxExponent.Name),
74+
BlobServerEndpoint: blobServerEndpoint,
7575
}, nil
7676
}

driver/config_test.go

+4-4
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ func (s *DriverTestSuite) TestNewConfigFromCliContext() {
3434
s.Equal(taikoL2, c.TaikoL2Address.String())
3535
s.Equal(120*time.Second, c.P2PSyncTimeout)
3636
s.NotEmpty(c.JwtSecret)
37-
s.True(c.P2PSyncVerifiedBlocks)
37+
s.True(c.P2PSync)
3838
s.Equal(l2CheckPoint, c.L2CheckPoint)
3939
s.Nil(new(Driver).InitFromCli(context.Background(), ctx))
4040

@@ -52,7 +52,7 @@ func (s *DriverTestSuite) TestNewConfigFromCliContext() {
5252
"--" + flags.JWTSecret.Name, os.Getenv("JWT_SECRET"),
5353
"--" + flags.P2PSyncTimeout.Name, "120s",
5454
"--" + flags.RPCTimeout.Name, "5s",
55-
"--" + flags.P2PSyncVerifiedBlocks.Name,
55+
"--" + flags.P2PSync.Name,
5656
"--" + flags.CheckPointSyncURL.Name, l2CheckPoint,
5757
}))
5858
}
@@ -70,7 +70,7 @@ func (s *DriverTestSuite) TestNewConfigFromCliContextEmptyL2CheckPoint() {
7070
s.ErrorContains(app.Run([]string{
7171
"TestNewConfigFromCliContext",
7272
"--" + flags.JWTSecret.Name, os.Getenv("JWT_SECRET"),
73-
"--" + flags.P2PSyncVerifiedBlocks.Name,
73+
"--" + flags.P2PSync.Name,
7474
"--" + flags.L2WSEndpoint.Name, "",
7575
}), "empty L2 check point URL")
7676
}
@@ -85,7 +85,7 @@ func (s *DriverTestSuite) SetupApp() *cli.App {
8585
&cli.StringFlag{Name: flags.TaikoL1Address.Name},
8686
&cli.StringFlag{Name: flags.TaikoL2Address.Name},
8787
&cli.StringFlag{Name: flags.JWTSecret.Name},
88-
&cli.BoolFlag{Name: flags.P2PSyncVerifiedBlocks.Name},
88+
&cli.BoolFlag{Name: flags.P2PSync.Name},
8989
&cli.DurationFlag{Name: flags.P2PSyncTimeout.Name},
9090
&cli.DurationFlag{Name: flags.RPCTimeout.Name},
9191
&cli.StringFlag{Name: flags.CheckPointSyncURL.Name},

driver/driver.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -69,15 +69,15 @@ func (d *Driver) InitFromConfig(ctx context.Context, cfg *Config) (err error) {
6969
return err
7070
}
7171

72-
if cfg.P2PSyncVerifiedBlocks && peers == 0 {
72+
if cfg.P2PSync && peers == 0 {
7373
log.Warn("P2P syncing verified blocks enabled, but no connected peer found in L2 execution engine")
7474
}
7575

7676
if d.l2ChainSyncer, err = chainSyncer.New(
7777
d.ctx,
7878
d.rpc,
7979
d.state,
80-
cfg.P2PSyncVerifiedBlocks,
80+
cfg.P2PSync,
8181
cfg.P2PSyncTimeout,
8282
cfg.MaxExponent,
8383
cfg.BlobServerEndpoint,

0 commit comments

Comments
 (0)