This repository has been archived by the owner on Aug 28, 2024. It is now read-only.
forked from matter-labs/zksync-era
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(en): file based configs for en (matter-labs#2110)
## What ❔ Allow EN works with file-based config system. Also it brings new functionality based on config system to the main node, because it was lacking before, such as custom api namespaces ## Why ❔ Part of the refactoring to the new config system ## Checklist <!-- Check your PR fulfills the following items. --> <!-- For draft PRs check the boxes as you complete them. --> - [x] PR title corresponds to the body of PR (we generate changelog entries from PRs). - [x] Tests for the changes have been added / updated. - [x] Documentation comments have been added / updated. - [x] Code has been formatted via `zk fmt` and `zk lint`. - [x] Spellcheck has been run via `zk spellcheck`. --------- Signed-off-by: Danil <[email protected]> Co-authored-by: Matías Ignacio González <[email protected]>
- Loading branch information
1 parent
c4f7b92
commit 7940fa3
Showing
42 changed files
with
986 additions
and
16 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
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 |
---|---|---|
@@ -0,0 +1,10 @@ | ||
use std::num::NonZeroU32; | ||
|
||
use serde::Deserialize; | ||
|
||
#[derive(Debug, Deserialize, Clone, PartialEq)] | ||
pub struct CommitmentGeneratorConfig { | ||
/// Maximum degree of parallelism during commitment generation, i.e., the maximum number of L1 batches being processed in parallel. | ||
/// If not specified, commitment generator will use a value roughly equal to the number of CPU cores with some clamping applied. | ||
pub max_parallelism: NonZeroU32, | ||
} |
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 |
---|---|---|
@@ -0,0 +1,19 @@ | ||
use std::num::NonZeroUsize; | ||
|
||
use serde::Deserialize; | ||
use zksync_basic_types::{ | ||
commitment::L1BatchCommitmentMode, url::SensitiveUrl, L1ChainId, L2ChainId, | ||
}; | ||
|
||
/// Temporary config for initializing external node, will be completely replaced by consensus config later | ||
#[derive(Debug, Clone, PartialEq, Deserialize)] | ||
pub struct ENConfig { | ||
// Genesis | ||
pub l2_chain_id: L2ChainId, | ||
pub l1_chain_id: L1ChainId, | ||
pub l1_batch_commit_data_generator_mode: L1BatchCommitmentMode, | ||
|
||
// Main node configuration | ||
pub main_node_url: SensitiveUrl, | ||
pub main_node_rate_limit_rps: Option<NonZeroUsize>, | ||
} |
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 |
---|---|---|
@@ -0,0 +1,19 @@ | ||
use std::num::NonZeroU64; | ||
|
||
use serde::Deserialize; | ||
|
||
#[derive(Debug, Clone, PartialEq, Deserialize)] | ||
pub struct PruningConfig { | ||
pub enabled: bool, | ||
/// Number of L1 batches pruned at a time. | ||
pub chunk_size: Option<u32>, | ||
/// Delta between soft- and hard-removing data from Postgres. Should be reasonably large (order of 60 seconds). | ||
/// The default value is 60 seconds. | ||
pub removal_delay_sec: Option<NonZeroU64>, | ||
/// If set, L1 batches will be pruned after the batch timestamp is this old (in seconds). Note that an L1 batch | ||
/// may be temporarily retained for other reasons; e.g., a batch cannot be pruned until it is executed on L1, | ||
/// which happens roughly 24 hours after its generation on the mainnet. Thus, in practice this value can specify | ||
/// the retention period greater than that implicitly imposed by other criteria (e.g., 7 or 30 days). | ||
/// If set to 0, L1 batches will not be retained based on their timestamp. The default value is 1 hour. | ||
pub data_retention_sec: Option<u64>, | ||
} |
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 |
---|---|---|
@@ -0,0 +1,44 @@ | ||
use std::num::NonZeroUsize; | ||
|
||
use serde::Deserialize; | ||
use zksync_basic_types::L1BatchNumber; | ||
|
||
use crate::ObjectStoreConfig; | ||
|
||
#[derive(Debug, Clone, PartialEq, Deserialize, Default)] | ||
pub struct TreeRecoveryConfig { | ||
/// Approximate chunk size (measured in the number of entries) to recover in a single iteration. | ||
/// Reasonable values are order of 100,000 (meaning an iteration takes several seconds). | ||
/// | ||
/// **Important.** This value cannot be changed in the middle of tree recovery (i.e., if a node is stopped in the middle | ||
/// of recovery and then restarted with a different config). | ||
pub chunk_size: Option<u64>, | ||
/// Buffer capacity for parallel persistence operations. Should be reasonably small since larger buffer means more RAM usage; | ||
/// buffer elements are persisted tree chunks. OTOH, small buffer can lead to persistence parallelization being inefficient. | ||
/// | ||
/// If not set, parallel persistence will be disabled. | ||
pub parallel_persistence_buffer: Option<NonZeroUsize>, | ||
} | ||
|
||
#[derive(Debug, Clone, PartialEq, Deserialize, Default)] | ||
pub struct PostgresRecoveryConfig { | ||
/// Maximum concurrency factor for the concurrent parts of snapshot recovery for Postgres. It may be useful to | ||
/// reduce this factor to about 5 if snapshot recovery overloads I/O capacity of the node. Conversely, | ||
/// if I/O capacity of your infra is high, you may increase concurrency to speed up Postgres recovery. | ||
pub max_concurrency: Option<NonZeroUsize>, | ||
} | ||
|
||
#[derive(Debug, Clone, PartialEq, Deserialize)] | ||
pub struct SnapshotRecoveryConfig { | ||
/// Enables application-level snapshot recovery. Required to start a node that was recovered from a snapshot, | ||
/// or to initialize a node from a snapshot. Has no effect if a node that was initialized from a Postgres dump | ||
/// or was synced from genesis. | ||
/// | ||
/// This is an experimental and incomplete feature; do not use unless you know what you're doing. | ||
pub enabled: bool, | ||
/// L1 batch number of the snapshot to use during recovery. Specifying this parameter is mostly useful for testing. | ||
pub l1_batch: Option<L1BatchNumber>, | ||
pub tree: TreeRecoveryConfig, | ||
pub postgres: PostgresRecoveryConfig, | ||
pub object_store: Option<ObjectStoreConfig>, | ||
} |
Oops, something went wrong.