-
Notifications
You must be signed in to change notification settings - Fork 3.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
op-node: Add sycmode flag and remove old snap sync flag
- Loading branch information
1 parent
99cc9a7
commit e52b320
Showing
9 changed files
with
94 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,54 @@ | ||
package sync | ||
|
||
import ( | ||
"fmt" | ||
"slices" | ||
) | ||
|
||
type Mode string | ||
|
||
// There are three kinds of sync mode that the op-node does: | ||
// 1. In l1-only (L1) sync mode, the op-node only derives data from L1 & does not import unsafe blocks. | ||
// 2. In consensus-layer (CL) sync, the op-node fully drives the execution client and imports unsafe blocks & | ||
// fetches unsafe blocks that it has missed. | ||
// 3. In execution-layer (EL) sync, the op-node tells the execution client to sync towards the tip of the chain. | ||
// It will consolidate the chain as usual. This allows execution clients to snap sync if they are capable of it. | ||
const ( | ||
// L1Sync Mode = "l1-only" // L1 Sync is ignored for now. Will need more modifications to imlement. | ||
CLSync Mode = "consensus-layer" | ||
ELSync Mode = "execution-layer" | ||
) | ||
|
||
var Modes = []Mode{CLSync, ELSync} | ||
|
||
func (m Mode) String() string { | ||
return string(m) | ||
} | ||
|
||
func (m *Mode) Set(value string) error { | ||
if !ValidMode(Mode(value)) { | ||
return fmt.Errorf("unknown sync mode: %q", value) | ||
} | ||
*m = Mode(value) | ||
return nil | ||
} | ||
|
||
func (m *Mode) Clone() any { | ||
cpy := *m | ||
return &cpy | ||
} | ||
|
||
func ValidMode(value Mode) bool { | ||
return slices.Contains(Modes, value) | ||
} | ||
|
||
type Config struct { | ||
// EngineSync is true when the EngineQueue can trigger execution engine P2P sync. | ||
EngineSync bool `json:"engine_sync"` | ||
// SkipSyncStartCheck skip the sanity check of consistency of L1 origins of the unsafe L2 blocks when determining the sync-starting point. This defers the L1-origin verification, and is recommended to use in when utilizing l2.engine-sync | ||
// SyncMode is defined above. | ||
SyncMode Mode `json:"syncmode"` | ||
// SkipSyncStartCheck skip the sanity check of consistency of L1 origins of the unsafe L2 blocks when determining the sync-starting point. | ||
// This defers the L1-origin verification, and is recommended to use in when utilizing --syncmode=EL on op-node and --syncmode=snap on op-geth | ||
// Warning: This will be removed when we implement proper checkpoints. | ||
// Note: We probably need to detect the condition that snap sync has not complete when we do a restart prior to running sync-start if we are doing | ||
// snap sync with a genesis finalization data. | ||
SkipSyncStartCheck bool `json:"skip_sync_start_check"` | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters