From a59d86f07a7bffdece360539afeb0537117397e9 Mon Sep 17 00:00:00 2001 From: Joan Esteban <129153821+joanestebanr@users.noreply.github.com> Date: Mon, 27 May 2024 15:14:46 +0200 Subject: [PATCH] Cherry-pick: Feature/3640 synchronizer choose to sync from l2 (#3641) (#3649) * Feature/3640 synchronizer choose to sync from l2 (#3641) * change synchronization config params 'Enable' to 'Enabled' (#3656) --- config/config_test.go | 12 ++++++++ config/default.go | 5 ++-- docs/config-file/node-config-doc.html | 4 +-- docs/config-file/node-config-doc.md | 37 +++++++++++++++++------- docs/config-file/node-config-schema.json | 13 ++++++--- synchronizer/config.go | 10 +++---- synchronizer/l2_sync/config.go | 2 ++ synchronizer/synchronizer.go | 13 +++++---- synchronizer/synchronizer_test.go | 35 ++++++++++++++++++---- 9 files changed, 97 insertions(+), 34 deletions(-) diff --git a/config/config_test.go b/config/config_test.go index 7b35e33b0a..9c297c49f6 100644 --- a/config/config_test.go +++ b/config/config_test.go @@ -64,6 +64,18 @@ func Test_Defaults(t *testing.T) { path: "Synchronizer.L2Synchronization.CheckLastL2BlockHashOnCloseBatch", expectedValue: true, }, + { + path: "Synchronizer.L1BlockCheck.Enabled", + expectedValue: true, + }, + { + path: "Synchronizer.L1BlockCheck.PreCheckEnabled", + expectedValue: true, + }, + { + path: "Synchronizer.L2Synchronization.Enabled", + expectedValue: true, + }, { path: "Sequencer.DeletePoolTxsL1BlockConfirmations", diff --git a/config/default.go b/config/default.go index 6416cb9fab..ac1bf73616 100644 --- a/config/default.go +++ b/config/default.go @@ -107,11 +107,11 @@ L1SynchronizationMode = "sequential" L1SyncCheckL2BlockHash = true L1SyncCheckL2BlockNumberModulus = 600 [Synchronizer.L1BlockCheck] - Enable = true + Enabled = true L1SafeBlockPoint = "finalized" L1SafeBlockOffset = 0 ForceCheckBeforeStart = true - PreCheckEnable = true + PreCheckEnabled = true L1PreSafeBlockPoint = "safe" L1PreSafeBlockOffset = 0 [Synchronizer.L1ParallelSynchronization] @@ -128,6 +128,7 @@ L1SyncCheckL2BlockNumberModulus = 600 AceptableInacctivityTime = "5s" ApplyAfterNumRollupReceived = 10 [Synchronizer.L2Synchronization] + Enabled = true AcceptEmptyClosedBatches = false ReprocessFullBatchOnClose = true CheckLastL2BlockHashOnCloseBatch = true diff --git a/docs/config-file/node-config-doc.html b/docs/config-file/node-config-doc.html index 9b7ed0345e..4fd2d63ea5 100644 --- a/docs/config-file/node-config-doc.html +++ b/docs/config-file/node-config-doc.html @@ -16,7 +16,7 @@
"300ms"
MaxRequestsPerIPAndSecond defines how much requests a single IP can
send within a single second
SequencerNodeURI is used allow Non-Sequencer nodes
to relay transactions to the Sequencer node
MaxCumulativeGasUsed is the max gas allowed per batch
Enabled defines if the WebSocket requests are enabled or disabled
Host defines the network adapter that will be used to serve the WS requests
Port defines the port to serve the endpoints via WS
ReadLimit defines the maximum size of a message read from the client (in bytes)
EnableL2SuggestedGasPricePolling enables polling of the L2 gas price to block tx in the RPC with lower gas price.
BatchRequestsEnabled defines if the Batch requests are enabled or disabled
BatchRequestsLimit defines the limit of requests that can be incorporated into each batch request
L2Coinbase defines which address is going to receive the fees
Must contain a minimum of 20
items
Must contain a maximum of 20
items
MaxLogsCount is a configuration to set the max number of logs that can be returned
in a single call to the state, if zero it means no limit
MaxLogsBlockRange is a configuration to set the max range for block number when querying TXs
logs in a single call to the state, if zero it means no limit
MaxNativeBlockHashBlockRange is a configuration to set the max range for block number when querying
native block hashes in a single call to the state, if zero it means no limit
EnableHttpLog allows the user to enable or disable the logs related to the HTTP
requests to be captured by the server.
SyncInterval is the delay interval between reading new rollup information
"1m"
"300ms"
-
SyncChunkSize is the number of blocks to sync on each chunk
TrustedSequencerURL is the rpc url to connect and sync the trusted state
SyncBlockProtection specify the state to sync (lastest, finalized or safe)
L1SyncCheckL2BlockHash if is true when a batch is closed is force to check L2Block hash against trustedNode (only apply for permissionless)
L1SyncCheckL2BlockNumberModulus is the modulus used to choose the l2block to check
a modules 5, for instance, means check all l2block multiples of 5 (10,15,20,...)
Enable if is true then the check l1 Block Hash is active
L1SafeBlockPoint is the point that a block is considered safe enough to be checked
it can be: finalized, safe,pending or latest
L1SafeBlockOffset is the offset to add to L1SafeBlockPoint as a safe point
it can be positive or negative
Example: L1SafeBlockPoint= finalized, L1SafeBlockOffset= -10, then the safe block ten blocks before the finalized block
ForceCheckBeforeStart if is true then the first time the system is started it will force to check all pending blocks
PreCheckEnable if is true then the pre-check is active, will check blocks between L1SafeBlock and L1PreSafeBlock
L1PreSafeBlockPoint is the point that a block is considered safe enough to be checked
it can be: finalized, safe,pending or latest
L1PreSafeBlockOffset is the offset to add to L1PreSafeBlockPoint as a safe point
it can be positive or negative
Example: L1PreSafeBlockPoint= finalized, L1PreSafeBlockOffset= -10, then the safe block ten blocks before the finalized block
L1SynchronizationMode define how to synchronize with L1:
- parallel: Request data to L1 in parallel, and process sequentially. The advantage is that executor is not blocked waiting for L1 data
- sequential: Request data to L1 and execute
MaxClients Number of clients used to synchronize with L1
MaxPendingNoProcessedBlocks Size of the buffer used to store rollup information from L1, must be >= to NumberOfEthereumClientsToSync
sugested twice of NumberOfParallelOfEthereumClients
RequestLastBlockPeriod is the time to wait to request the
last block to L1 to known if we need to retrieve more data.
This value only apply when the system is synchronized
"1m"
+
SyncChunkSize is the number of blocks to sync on each chunk
TrustedSequencerURL is the rpc url to connect and sync the trusted state
SyncBlockProtection specify the state to sync (lastest, finalized or safe)
L1SyncCheckL2BlockHash if is true when a batch is closed is force to check L2Block hash against trustedNode (only apply for permissionless)
L1SyncCheckL2BlockNumberModulus is the modulus used to choose the l2block to check
a modules 5, for instance, means check all l2block multiples of 5 (10,15,20,...)
If enabled then the check l1 Block Hash is active
L1SafeBlockPoint is the point that a block is considered safe enough to be checked
it can be: finalized, safe,pending or latest
L1SafeBlockOffset is the offset to add to L1SafeBlockPoint as a safe point
it can be positive or negative
Example: L1SafeBlockPoint= finalized, L1SafeBlockOffset= -10, then the safe block ten blocks before the finalized block
ForceCheckBeforeStart if is true then the first time the system is started it will force to check all pending blocks
If enabled then the pre-check is active, will check blocks between L1SafeBlock and L1PreSafeBlock
L1PreSafeBlockPoint is the point that a block is considered safe enough to be checked
it can be: finalized, safe,pending or latest
L1PreSafeBlockOffset is the offset to add to L1PreSafeBlockPoint as a safe point
it can be positive or negative
Example: L1PreSafeBlockPoint= finalized, L1PreSafeBlockOffset= -10, then the safe block ten blocks before the finalized block
L1SynchronizationMode define how to synchronize with L1:
- parallel: Request data to L1 in parallel, and process sequentially. The advantage is that executor is not blocked waiting for L1 data
- sequential: Request data to L1 and execute
MaxClients Number of clients used to synchronize with L1
MaxPendingNoProcessedBlocks Size of the buffer used to store rollup information from L1, must be >= to NumberOfEthereumClientsToSync
sugested twice of NumberOfParallelOfEthereumClients
RequestLastBlockPeriod is the time to wait to request the
last block to L1 to known if we need to retrieve more data.
This value only apply when the system is synchronized
"1m"
"300ms"
AceptableInacctivityTime is the expected maximum time that the consumer
could wait until new data is produced. If the time is greater it emmit a log to warn about
that. The idea is keep working the consumer as much as possible, so if the producer is not
fast enought then you could increse the number of parallel clients to sync with L1
"1m"
"300ms"
@@ -28,7 +28,7 @@
"300ms"
RollupInfoRetriesSpacing is the minimum time between retries to request rollup info (it will sleep for fulfill this time) to avoid spamming L1
"1m"
"300ms"
-
FallbackToSequentialModeOnSynchronized if true switch to sequential mode if the system is synchronized
AcceptEmptyClosedBatches is a flag to enable or disable the acceptance of empty batches.
if true, the synchronizer will accept empty batches and process them.
ReprocessFullBatchOnClose if is true when a batch is closed is force to reprocess again
CheckLastL2BlockHashOnCloseBatch if is true when a batch is closed is force to check the last L2Block hash
DeletePoolTxsL1BlockConfirmations is blocks amount after which txs will be deleted from the pool
DeletePoolTxsCheckInterval is frequency with which txs will be checked for deleting
"1m"
+
FallbackToSequentialModeOnSynchronized if true switch to sequential mode if the system is synchronized
If enabled then the L2 sync process is permitted (only for permissionless)
AcceptEmptyClosedBatches is a flag to enable or disable the acceptance of empty batches.
if true, the synchronizer will accept empty batches and process them.
ReprocessFullBatchOnClose if is true when a batch is closed is force to reprocess again
CheckLastL2BlockHashOnCloseBatch if is true when a batch is closed is force to check the last L2Block hash
DeletePoolTxsL1BlockConfirmations is blocks amount after which txs will be deleted from the pool
DeletePoolTxsCheckInterval is frequency with which txs will be checked for deleting
"1m"
"300ms"
TxLifetimeCheckInterval is the time the sequencer waits to check txs lifetime
"1m"
"300ms"
diff --git a/docs/config-file/node-config-doc.md b/docs/config-file/node-config-doc.md
index 157e6051aa..2e4203b96b 100644
--- a/docs/config-file/node-config-doc.md
+++ b/docs/config-file/node-config-doc.md
@@ -1465,26 +1465,26 @@ L1SyncCheckL2BlockNumberModulus=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
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
it can be positive or negative
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
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
it can be positive or negative
Example: L1PreSafeBlockPoint= finalized, L1PreSafeBlockOffset= -10, then the safe block ten blocks before the finalized block |
-#### 9.7.1. `Synchronizer.L1BlockCheck.Enable`
+#### 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
```
#### 9.7.2. `Synchronizer.L1BlockCheck.L1SafeBlockPoint`
@@ -1537,18 +1537,18 @@ L1SafeBlockOffset=0
ForceCheckBeforeStart=true
```
-#### 9.7.5. `Synchronizer.L1BlockCheck.PreCheckEnable`
+#### 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
```
#### 9.7.6. `Synchronizer.L1BlockCheck.L1PreSafeBlockPoint`
@@ -1875,11 +1875,26 @@ FallbackToSequentialModeOnSynchronized=false
| Property | Pattern | Type | Deprecated | Definition | Title/Description |
| ------------------------------------------------------------------------------------------------------- | ------- | ------- | ---------- | ---------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
+| - [Enabled](#Synchronizer_L2Synchronization_Enabled ) | No | boolean | No | - | If enabled then the L2 sync process is permitted (only for permissionless) |
| - [AcceptEmptyClosedBatches](#Synchronizer_L2Synchronization_AcceptEmptyClosedBatches ) | No | boolean | No | - | AcceptEmptyClosedBatches is a flag to enable or disable the acceptance of empty batches.
if true, the synchronizer will accept empty batches and process them. |
| - [ReprocessFullBatchOnClose](#Synchronizer_L2Synchronization_ReprocessFullBatchOnClose ) | No | boolean | No | - | ReprocessFullBatchOnClose if is true when a batch is closed is force to reprocess again |
| - [CheckLastL2BlockHashOnCloseBatch](#Synchronizer_L2Synchronization_CheckLastL2BlockHashOnCloseBatch ) | No | boolean | No | - | CheckLastL2BlockHashOnCloseBatch if is true when a batch is closed is force to check the last L2Block hash |
-#### 9.10.1. `Synchronizer.L2Synchronization.AcceptEmptyClosedBatches`
+#### 9.10.1. `Synchronizer.L2Synchronization.Enabled`
+
+**Type:** : `boolean`
+
+**Default:** `true`
+
+**Description:** If enabled then the L2 sync process is permitted (only for permissionless)
+
+**Example setting the default value** (true):
+```
+[Synchronizer.L2Synchronization]
+Enabled=true
+```
+
+#### 9.10.2. `Synchronizer.L2Synchronization.AcceptEmptyClosedBatches`
**Type:** : `boolean`
@@ -1894,7 +1909,7 @@ if true, the synchronizer will accept empty batches and process them.
AcceptEmptyClosedBatches=false
```
-#### 9.10.2. `Synchronizer.L2Synchronization.ReprocessFullBatchOnClose`
+#### 9.10.3. `Synchronizer.L2Synchronization.ReprocessFullBatchOnClose`
**Type:** : `boolean`
@@ -1908,7 +1923,7 @@ AcceptEmptyClosedBatches=false
ReprocessFullBatchOnClose=true
```
-#### 9.10.3. `Synchronizer.L2Synchronization.CheckLastL2BlockHashOnCloseBatch`
+#### 9.10.4. `Synchronizer.L2Synchronization.CheckLastL2BlockHashOnCloseBatch`
**Type:** : `boolean`
diff --git a/docs/config-file/node-config-schema.json b/docs/config-file/node-config-schema.json
index 8bd7323c07..032a3bbea6 100644
--- a/docs/config-file/node-config-schema.json
+++ b/docs/config-file/node-config-schema.json
@@ -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": {
@@ -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": {
@@ -698,6 +698,11 @@
},
"L2Synchronization": {
"properties": {
+ "Enabled": {
+ "type": "boolean",
+ "description": "If enabled then the L2 sync process is permitted (only for permissionless)",
+ "default": true
+ },
"AcceptEmptyClosedBatches": {
"type": "boolean",
"description": "AcceptEmptyClosedBatches is a flag to enable or disable the acceptance of empty batches.\nif true, the synchronizer will accept empty batches and process them.",
diff --git a/synchronizer/config.go b/synchronizer/config.go
index 4f35bc232e..b6542222a4 100644
--- a/synchronizer/config.go
+++ b/synchronizer/config.go
@@ -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"`
@@ -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"`
@@ -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')
diff --git a/synchronizer/l2_sync/config.go b/synchronizer/l2_sync/config.go
index 7781c7bd6c..c3cf1faed9 100644
--- a/synchronizer/l2_sync/config.go
+++ b/synchronizer/l2_sync/config.go
@@ -2,6 +2,8 @@ package l2_sync
// Config configuration of L2 sync process
type Config struct {
+ // 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"`
diff --git a/synchronizer/synchronizer.go b/synchronizer/synchronizer.go
index 2d2715bd26..b2649f9ad0 100644
--- a/synchronizer/synchronizer.go
+++ b/synchronizer/synchronizer.go
@@ -127,13 +127,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)
@@ -153,7 +153,7 @@ func NewSynchronizer(
time.Second)
}
- if !isTrustedSequencer {
+ 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
@@ -172,7 +172,10 @@ func NewSynchronizer(
uint64(state.FORKID_ELDERBERRY): syncTrustedStateEtrog,
uint64(state.FORKID_ELDERBERRY_2): syncTrustedStateEtrog,
}, res.state)
+ } else {
+ log.Info("L2 synchronization disabled or running in trusted sequencer mode")
}
+
var l1checkerL2Blocks *actions.CheckL2BlockHash
if cfg.L1SyncCheckL2BlockHash {
if !isTrustedSequencer {
@@ -457,7 +460,7 @@ func (s *ClientSynchronizer) Sync() error {
// latestSequencedBatchNumber -> last batch on SMC
if latestSyncedBatch >= latestSequencedBatchNumber {
startTrusted := time.Now()
- if s.syncTrustedStateExecutor != nil && !s.isTrustedSequencer {
+ if s.syncTrustedStateExecutor != nil {
log.Info("Syncing trusted state (permissionless)")
//Sync Trusted State
log.Debug("Doing reorg check before L2 sync")
@@ -815,7 +818,7 @@ func (s *ClientSynchronizer) ProcessBlockRange(blocks []etherman.Block, order ma
}
func (s *ClientSynchronizer) syncTrustedState(latestSyncedBatch uint64) error {
- if s.syncTrustedStateExecutor == nil || s.isTrustedSequencer {
+ if s.syncTrustedStateExecutor == nil {
return nil
}
diff --git a/synchronizer/synchronizer_test.go b/synchronizer/synchronizer_test.go
index b330d63605..8078737b39 100644
--- a/synchronizer/synchronizer_test.go
+++ b/synchronizer/synchronizer_test.go
@@ -16,6 +16,7 @@ import (
"github.com/0xPolygonHermez/zkevm-node/state/runtime/executor"
"github.com/0xPolygonHermez/zkevm-node/synchronizer/common/syncinterfaces"
mock_syncinterfaces "github.com/0xPolygonHermez/zkevm-node/synchronizer/common/syncinterfaces/mocks"
+ "github.com/0xPolygonHermez/zkevm-node/synchronizer/l2_sync"
syncMocks "github.com/0xPolygonHermez/zkevm-node/synchronizer/mocks"
"github.com/ethereum/go-ethereum/common"
ethTypes "github.com/ethereum/go-ethereum/core/types"
@@ -131,7 +132,10 @@ func TestForcedBatchEtrog(t *testing.T) {
L1SynchronizationMode: SequentialMode,
SyncBlockProtection: "latest",
L1BlockCheck: L1BlockCheckConfig{
- Enable: false,
+ Enabled: false,
+ },
+ L2Synchronization: l2_sync.Config{
+ Enabled: true,
},
}
@@ -677,6 +681,9 @@ func setupGenericTest(t *testing.T) (*state.Genesis, *Config, *mocks) {
RollupInfoRetriesSpacing: cfgTypes.Duration{Duration: 1 * time.Second},
FallbackToSequentialModeOnSynchronized: false,
},
+ L2Synchronization: l2_sync.Config{
+ Enabled: true,
+ },
}
m := mocks{
@@ -933,7 +940,10 @@ func TestReorg(t *testing.T) {
L1SynchronizationMode: SequentialMode,
SyncBlockProtection: "latest",
L1BlockCheck: L1BlockCheckConfig{
- Enable: false,
+ Enabled: false,
+ },
+ L2Synchronization: l2_sync.Config{
+ Enabled: true,
},
}
@@ -1253,7 +1263,10 @@ func TestLatestSyncedBlockEmpty(t *testing.T) {
L1SynchronizationMode: SequentialMode,
SyncBlockProtection: "latest",
L1BlockCheck: L1BlockCheckConfig{
- Enable: false,
+ Enabled: false,
+ },
+ L2Synchronization: l2_sync.Config{
+ Enabled: true,
},
}
@@ -1467,7 +1480,10 @@ func TestRegularReorg(t *testing.T) {
L1SynchronizationMode: SequentialMode,
SyncBlockProtection: "latest",
L1BlockCheck: L1BlockCheckConfig{
- Enable: false,
+ Enabled: false,
+ },
+ L2Synchronization: l2_sync.Config{
+ Enabled: true,
},
}
@@ -1749,7 +1765,10 @@ func TestLatestSyncedBlockEmptyWithExtraReorg(t *testing.T) {
L1SynchronizationMode: SequentialMode,
SyncBlockProtection: "latest",
L1BlockCheck: L1BlockCheckConfig{
- Enable: false,
+ Enabled: false,
+ },
+ L2Synchronization: l2_sync.Config{
+ Enabled: true,
},
}
@@ -2024,6 +2043,12 @@ func TestCallFromEmptyBlockAndReorg(t *testing.T) {
SyncChunkSize: 3,
L1SynchronizationMode: SequentialMode,
SyncBlockProtection: "latest",
+ L1BlockCheck: L1BlockCheckConfig{
+ Enabled: false,
+ },
+ L2Synchronization: l2_sync.Config{
+ Enabled: true,
+ },
}
m := mocks{