Skip to content

Commit

Permalink
change synchronization config params 'Enable' to 'Enabled' (0xPolygon…
Browse files Browse the repository at this point in the history
…Hermez#3656)

* change 'Enable' to 'Enabled' on sync config and changed comments
  • Loading branch information
joanestebanr authored and Stefan-Ethernal committed Jun 26, 2024
1 parent 8e6b6cf commit 8e34cc2
Show file tree
Hide file tree
Showing 9 changed files with 53 additions and 45 deletions.
10 changes: 9 additions & 1 deletion config/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,15 @@ func Test_Defaults(t *testing.T) {
expectedValue: []dataavailability.DataSourcePriority{"local", "trusted", "external"},
},
{
path: "Synchronizer.L2Synchronization.Enable",
path: "Synchronizer.L1BlockCheck.Enabled",
expectedValue: true,
},
{
path: "Synchronizer.L1BlockCheck.PreCheckEnabled",
expectedValue: true,
},
{
path: "Synchronizer.L2Synchronization.Enabled",
expectedValue: true,
},
{
Expand Down
6 changes: 3 additions & 3 deletions config/default.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,11 +108,11 @@ L1SynchronizationMode = "sequential"
L1SyncCheckL2BlockHash = true
L1SyncCheckL2BlockNumberhModulus = 600
[Synchronizer.L1BlockCheck]
Enable = true
Enabled = true
L1SafeBlockPoint = "finalized"
L1SafeBlockOffset = 0
ForceCheckBeforeStart = true
PreCheckEnable = true
PreCheckEnabled = true
L1PreSafeBlockPoint = "safe"
L1PreSafeBlockOffset = 0
[Synchronizer.L1ParallelSynchronization]
Expand All @@ -129,7 +129,7 @@ L1SyncCheckL2BlockNumberhModulus = 600
AceptableInacctivityTime = "5s"
ApplyAfterNumRollupReceived = 10
[Synchronizer.L2Synchronization]
Enable = true
Enabled = true
AcceptEmptyClosedBatches = false
ReprocessFullBatchOnClose = false
CheckLastL2BlockHashOnCloseBatch = true
Expand Down
2 changes: 1 addition & 1 deletion docs/config-file/node-config-doc.html

Large diffs are not rendered by default.

22 changes: 11 additions & 11 deletions docs/config-file/node-config-doc.md
Original file line number Diff line number Diff line change
Expand Up @@ -1466,26 +1466,26 @@ L1SyncCheckL2BlockNumberhModulus=600

| Property | Pattern | Type | Deprecated | Definition | Title/Description |
| ---------------------------------------------------------------------------- | ------- | ---------------- | ---------- | ---------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| - [Enable](#Synchronizer_L1BlockCheck_Enable ) | No | boolean | No | - | Enable if is true then the check l1 Block Hash is active |
| - [Enabled](#Synchronizer_L1BlockCheck_Enabled ) | No | boolean | No | - | If enabled then the check l1 Block Hash is active |
| - [L1SafeBlockPoint](#Synchronizer_L1BlockCheck_L1SafeBlockPoint ) | No | enum (of string) | No | - | L1SafeBlockPoint is the point that a block is considered safe enough to be checked<br />it can be: finalized, safe,pending or latest |
| - [L1SafeBlockOffset](#Synchronizer_L1BlockCheck_L1SafeBlockOffset ) | No | integer | No | - | L1SafeBlockOffset is the offset to add to L1SafeBlockPoint as a safe point<br />it can be positive or negative<br />Example: L1SafeBlockPoint= finalized, L1SafeBlockOffset= -10, then the safe block ten blocks before the finalized block |
| - [ForceCheckBeforeStart](#Synchronizer_L1BlockCheck_ForceCheckBeforeStart ) | No | boolean | No | - | ForceCheckBeforeStart if is true then the first time the system is started it will force to check all pending blocks |
| - [PreCheckEnable](#Synchronizer_L1BlockCheck_PreCheckEnable ) | No | boolean | No | - | PreCheckEnable if is true then the pre-check is active, will check blocks between L1SafeBlock and L1PreSafeBlock |
| - [PreCheckEnabled](#Synchronizer_L1BlockCheck_PreCheckEnabled ) | No | boolean | No | - | If enabled then the pre-check is active, will check blocks between L1SafeBlock and L1PreSafeBlock |
| - [L1PreSafeBlockPoint](#Synchronizer_L1BlockCheck_L1PreSafeBlockPoint ) | No | enum (of string) | No | - | L1PreSafeBlockPoint is the point that a block is considered safe enough to be checked<br />it can be: finalized, safe,pending or latest |
| - [L1PreSafeBlockOffset](#Synchronizer_L1BlockCheck_L1PreSafeBlockOffset ) | No | integer | No | - | L1PreSafeBlockOffset is the offset to add to L1PreSafeBlockPoint as a safe point<br />it can be positive or negative<br />Example: L1PreSafeBlockPoint= finalized, L1PreSafeBlockOffset= -10, then the safe block ten blocks before the finalized block |

#### <a name="Synchronizer_L1BlockCheck_Enable"></a>9.7.1. `Synchronizer.L1BlockCheck.Enable`
#### <a name="Synchronizer_L1BlockCheck_Enabled"></a>9.7.1. `Synchronizer.L1BlockCheck.Enabled`

**Type:** : `boolean`

**Default:** `true`

**Description:** Enable if is true then the check l1 Block Hash is active
**Description:** If enabled then the check l1 Block Hash is active

**Example setting the default value** (true):
```
[Synchronizer.L1BlockCheck]
Enable=true
Enabled=true
```

#### <a name="Synchronizer_L1BlockCheck_L1SafeBlockPoint"></a>9.7.2. `Synchronizer.L1BlockCheck.L1SafeBlockPoint`
Expand Down Expand Up @@ -1538,18 +1538,18 @@ L1SafeBlockOffset=0
ForceCheckBeforeStart=true
```

#### <a name="Synchronizer_L1BlockCheck_PreCheckEnable"></a>9.7.5. `Synchronizer.L1BlockCheck.PreCheckEnable`
#### <a name="Synchronizer_L1BlockCheck_PreCheckEnabled"></a>9.7.5. `Synchronizer.L1BlockCheck.PreCheckEnabled`

**Type:** : `boolean`

**Default:** `true`

**Description:** PreCheckEnable if is true then the pre-check is active, will check blocks between L1SafeBlock and L1PreSafeBlock
**Description:** If enabled then the pre-check is active, will check blocks between L1SafeBlock and L1PreSafeBlock

**Example setting the default value** (true):
```
[Synchronizer.L1BlockCheck]
PreCheckEnable=true
PreCheckEnabled=true
```

#### <a name="Synchronizer_L1BlockCheck_L1PreSafeBlockPoint"></a>9.7.6. `Synchronizer.L1BlockCheck.L1PreSafeBlockPoint`
Expand Down Expand Up @@ -1881,18 +1881,18 @@ FallbackToSequentialModeOnSynchronized=false
| - [CheckLastL2BlockHashOnCloseBatch](#Synchronizer_L2Synchronization_CheckLastL2BlockHashOnCloseBatch ) | No | boolean | No | - | CheckLastL2BlockHashOnCloseBatch if is true when a batch is closed is force to check the last L2Block hash |
| - [DataSourcePriority](#Synchronizer_L2Synchronization_DataSourcePriority ) | No | array of string | No | - | DataSourcePriority defines the order in which L2 batch should be retrieved: local, trusted, external |

#### <a name="Synchronizer_L2Synchronization_Enable"></a>9.10.1. `Synchronizer.L2Synchronization.Enable`
#### <a name="Synchronizer_L2Synchronization_Enabled"></a>9.10.1. `Synchronizer.L2Synchronization.Enabled`

**Type:** : `boolean`

**Default:** `true`

**Description:** Enable if is true then the L2 sync process is permitted (only for permissionless)
**Description:** If enabled then the L2 sync process is permitted (only for permissionless)

**Example setting the default value** (true):
```
[Synchronizer.L2Synchronization]
Enable=true
Enabled=true
```

#### <a name="Synchronizer_L2Synchronization_AcceptEmptyClosedBatches"></a>9.10.2. `Synchronizer.L2Synchronization.AcceptEmptyClosedBatches`
Expand Down
12 changes: 6 additions & 6 deletions docs/config-file/node-config-schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -539,9 +539,9 @@
},
"L1BlockCheck": {
"properties": {
"Enable": {
"Enabled": {
"type": "boolean",
"description": "Enable if is true then the check l1 Block Hash is active",
"description": "If enabled then the check l1 Block Hash is active",
"default": true
},
"L1SafeBlockPoint": {
Expand All @@ -564,9 +564,9 @@
"description": "ForceCheckBeforeStart if is true then the first time the system is started it will force to check all pending blocks",
"default": true
},
"PreCheckEnable": {
"PreCheckEnabled": {
"type": "boolean",
"description": "PreCheckEnable if is true then the pre-check is active, will check blocks between L1SafeBlock and L1PreSafeBlock",
"description": "If enabled then the pre-check is active, will check blocks between L1SafeBlock and L1PreSafeBlock",
"default": true
},
"L1PreSafeBlockPoint": {
Expand Down Expand Up @@ -698,9 +698,9 @@
},
"L2Synchronization": {
"properties": {
"Enable": {
"Enabled": {
"type": "boolean",
"description": "Enable if is true then the L2 sync process is permitted (only for permissionless)",
"description": "If enabled then the L2 sync process is permitted (only for permissionless)",
"default": true
},
"AcceptEmptyClosedBatches": {
Expand Down
10 changes: 5 additions & 5 deletions synchronizer/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ type Config struct {

// L1BlockCheckConfig Configuration for L1 Block Checker
type L1BlockCheckConfig struct {
// Enable if is true then the check l1 Block Hash is active
Enable bool `mapstructure:"Enable"`
// If enabled then the check l1 Block Hash is active
Enabled bool `mapstructure:"Enabled"`
// L1SafeBlockPoint is the point that a block is considered safe enough to be checked
// it can be: finalized, safe,pending or latest
L1SafeBlockPoint string `mapstructure:"L1SafeBlockPoint" jsonschema:"enum=finalized,enum=safe, enum=pending,enum=latest"`
Expand All @@ -49,8 +49,8 @@ type L1BlockCheckConfig struct {
// ForceCheckBeforeStart if is true then the first time the system is started it will force to check all pending blocks
ForceCheckBeforeStart bool `mapstructure:"ForceCheckBeforeStart"`

// PreCheckEnable if is true then the pre-check is active, will check blocks between L1SafeBlock and L1PreSafeBlock
PreCheckEnable bool `mapstructure:"PreCheckEnable"`
// If enabled then the pre-check is active, will check blocks between L1SafeBlock and L1PreSafeBlock
PreCheckEnabled bool `mapstructure:"PreCheckEnabled"`
// L1PreSafeBlockPoint is the point that a block is considered safe enough to be checked
// it can be: finalized, safe,pending or latest
L1PreSafeBlockPoint string `mapstructure:"L1PreSafeBlockPoint" jsonschema:"enum=finalized,enum=safe, enum=pending,enum=latest"`
Expand All @@ -61,7 +61,7 @@ type L1BlockCheckConfig struct {
}

func (c *L1BlockCheckConfig) String() string {
return fmt.Sprintf("Enable: %v, L1SafeBlockPoint: %s, L1SafeBlockOffset: %d, ForceCheckBeforeStart: %v", c.Enable, c.L1SafeBlockPoint, c.L1SafeBlockOffset, c.ForceCheckBeforeStart)
return fmt.Sprintf("Enable: %v, L1SafeBlockPoint: %s, L1SafeBlockOffset: %d, ForceCheckBeforeStart: %v", c.Enabled, c.L1SafeBlockPoint, c.L1SafeBlockOffset, c.ForceCheckBeforeStart)
}

// L1ParallelSynchronizationConfig Configuration for parallel mode (if UL1SynchronizationMode equal to 'parallel')
Expand Down
4 changes: 2 additions & 2 deletions synchronizer/l2_sync/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import "github.com/0xPolygonHermez/zkevm-node/dataavailability"

// Config configuration of L2 sync process
type Config struct {
// Enable if is true then the L2 sync process is permitted (only for permissionless)
Enable bool `mapstructure:"Enable"`
// If enabled then the L2 sync process is permitted (only for permissionless)
Enabled bool `mapstructure:"Enabled"`
// AcceptEmptyClosedBatches is a flag to enable or disable the acceptance of empty batches.
// if true, the synchronizer will accept empty batches and process them.
AcceptEmptyClosedBatches bool `mapstructure:"AcceptEmptyClosedBatches"`
Expand Down
6 changes: 3 additions & 3 deletions synchronizer/synchronizer.go
Original file line number Diff line number Diff line change
Expand Up @@ -125,13 +125,13 @@ func NewSynchronizer(
syncBlockProtection: syncBlockProtection,
halter: syncCommon.NewCriticalErrorHalt(eventLog, 5*time.Second), //nolint:gomnd
}
if cfg.L1BlockCheck.Enable {
if cfg.L1BlockCheck.Enabled {
log.Infof("L1BlockChecker enabled: %s", cfg.L1BlockCheck.String())
l1BlockChecker := l1_check_block.NewCheckL1BlockHash(ethMan, res.state,
l1_check_block.NewSafeL1BlockNumberFetch(l1_check_block.StringToL1BlockPoint(cfg.L1BlockCheck.L1SafeBlockPoint), cfg.L1BlockCheck.L1SafeBlockOffset))

var preCheckAsync syncinterfaces.AsyncL1BlockChecker
if cfg.L1BlockCheck.PreCheckEnable {
if cfg.L1BlockCheck.PreCheckEnabled {
log.Infof("L1BlockChecker enabled precheck from: %s/%d to: %s/%d",
cfg.L1BlockCheck.L1SafeBlockPoint, cfg.L1BlockCheck.L1SafeBlockOffset,
cfg.L1BlockCheck.L1PreSafeBlockPoint, cfg.L1BlockCheck.L1PreSafeBlockOffset)
Expand All @@ -151,7 +151,7 @@ func NewSynchronizer(
time.Second)
}

if !isTrustedSequencer && cfg.L2Synchronization.Enable {
if !isTrustedSequencer && cfg.L2Synchronization.Enabled {
log.Info("Permissionless: creating and Initializing L2 synchronization components")
L1SyncChecker := l2_sync_etrog.NewCheckSyncStatusToProcessBatch(res.zkEVMClient, res.state)
sync := &res
Expand Down
26 changes: 13 additions & 13 deletions synchronizer/synchronizer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -131,10 +131,10 @@ func TestForcedBatchEtrog(t *testing.T) {
L1SynchronizationMode: SequentialMode,
SyncBlockProtection: "latest",
L1BlockCheck: L1BlockCheckConfig{
Enable: false,
Enabled: false,
},
L2Synchronization: l2_sync.Config{
Enable: true,
Enabled: true,
},
}

Expand Down Expand Up @@ -682,7 +682,7 @@ func setupGenericTest(t *testing.T) (*state.Genesis, *Config, *mocks) {
FallbackToSequentialModeOnSynchronized: false,
},
L2Synchronization: l2_sync.Config{
Enable: true,
Enabled: true,
},
}

Expand Down Expand Up @@ -938,10 +938,10 @@ func TestReorg(t *testing.T) {
L1SynchronizationMode: SequentialMode,
SyncBlockProtection: "latest",
L1BlockCheck: L1BlockCheckConfig{
Enable: false,
Enabled: false,
},
L2Synchronization: l2_sync.Config{
Enable: true,
Enabled: true,
},
}

Expand Down Expand Up @@ -1261,10 +1261,10 @@ func TestLatestSyncedBlockEmpty(t *testing.T) {
L1SynchronizationMode: SequentialMode,
SyncBlockProtection: "latest",
L1BlockCheck: L1BlockCheckConfig{
Enable: false,
Enabled: false,
},
L2Synchronization: l2_sync.Config{
Enable: true,
Enabled: true,
},
}

Expand Down Expand Up @@ -1478,10 +1478,10 @@ func TestRegularReorg(t *testing.T) {
L1SynchronizationMode: SequentialMode,
SyncBlockProtection: "latest",
L1BlockCheck: L1BlockCheckConfig{
Enable: false,
Enabled: false,
},
L2Synchronization: l2_sync.Config{
Enable: true,
Enabled: true,
},
}

Expand Down Expand Up @@ -1763,10 +1763,10 @@ func TestLatestSyncedBlockEmptyWithExtraReorg(t *testing.T) {
L1SynchronizationMode: SequentialMode,
SyncBlockProtection: "latest",
L1BlockCheck: L1BlockCheckConfig{
Enable: false,
Enabled: false,
},
L2Synchronization: l2_sync.Config{
Enable: true,
Enabled: true,
},
}

Expand Down Expand Up @@ -2042,10 +2042,10 @@ func TestCallFromEmptyBlockAndReorg(t *testing.T) {
L1SynchronizationMode: SequentialMode,
SyncBlockProtection: "latest",
L1BlockCheck: L1BlockCheckConfig{
Enable: false,
Enabled: false,
},
L2Synchronization: l2_sync.Config{
Enable: true,
Enabled: true,
},
}

Expand Down

0 comments on commit 8e34cc2

Please sign in to comment.