From f1c996ef62758c2ef50c00b2295a23ba72544613 Mon Sep 17 00:00:00 2001 From: Nisheeth Barthwal Date: Mon, 16 Oct 2023 18:06:32 +0200 Subject: [PATCH 1/3] support builtInWithoutSecurity option --- README.md | 8 ++++++++ src/main.rs | 22 +++++++++++++++------- 2 files changed, 23 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index b8936dc7..6a0f61fe 100644 --- a/README.md +++ b/README.md @@ -66,6 +66,14 @@ Please note that `era-test-node` is still in its **alpha** stage. Some features make run ``` +## 📄 System Contracts + +The system contract within the node can be specified via the `--dev-system-contracts` option. +It can take one of the following options: + * `built-in`: Use the compiled built-in contracts + * `built-in-no-verify`: Use the compiled built-in contracts, but without signature verification + * `local`: Load contracts from `ZKSYNC_HOME` + ## 📃 Logging The node may be started in either of `debug`, `info`, `warn` or `error` logging levels via the `--log` option: diff --git a/src/main.rs b/src/main.rs index 0a4071c4..aeda66af 100644 --- a/src/main.rs +++ b/src/main.rs @@ -181,6 +181,14 @@ enum CacheType { Disk, } +/// System contract options. +#[derive(ValueEnum, Debug, Clone)] +enum DevSystemContracts { + BuiltIn, + BuiltInNoVerify, + Local, +} + #[derive(Debug, Parser)] #[command(author = "Matter Labs", version, about = "Test Node", long_about = None)] struct Cli { @@ -208,9 +216,9 @@ struct Cli { /// It will make debug log more readable, but will decrease the performance. resolve_hashes: bool, + /// Specifies the option for the system contracts (load locally or use compiled built-in with or without signature verification). #[arg(long)] - /// If true, will load the locally compiled system contracts (useful when doing changes to system contracts or bootloader) - dev_use_local_contracts: bool, + dev_system_contracts: DevSystemContracts, /// Log filter level - default: info #[arg(long, default_value = "info")] @@ -296,7 +304,7 @@ async fn main() -> anyhow::Result<()> { ]) .expect("failed instantiating logger"); - if opt.dev_use_local_contracts { + if matches!(opt.dev_system_contracts, DevSystemContracts::Local) { if let Some(path) = env::var_os("ZKSYNC_HOME") { log::info!("+++++ Reading local contracts from {:?} +++++", path); } @@ -340,10 +348,10 @@ async fn main() -> anyhow::Result<()> { } else { vec![] }; - let system_contracts_options = if opt.dev_use_local_contracts { - system_contracts::Options::Local - } else { - system_contracts::Options::BuiltIn + let system_contracts_options = match opt.dev_system_contracts { + DevSystemContracts::BuiltIn => system_contracts::Options::BuiltIn, + DevSystemContracts::BuiltInNoVerify => system_contracts::Options::BuiltInWithoutSecurity, + DevSystemContracts::Local => system_contracts::Options::BuiltIn, }; let node = InMemoryNode::new( From a965777f5d492ea30f30fda42ff7f073c9932d88 Mon Sep 17 00:00:00 2001 From: Nisheeth Barthwal Date: Mon, 16 Oct 2023 18:49:14 +0200 Subject: [PATCH 2/3] fix typo --- src/main.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main.rs b/src/main.rs index aeda66af..70ce9c53 100644 --- a/src/main.rs +++ b/src/main.rs @@ -351,7 +351,7 @@ async fn main() -> anyhow::Result<()> { let system_contracts_options = match opt.dev_system_contracts { DevSystemContracts::BuiltIn => system_contracts::Options::BuiltIn, DevSystemContracts::BuiltInNoVerify => system_contracts::Options::BuiltInWithoutSecurity, - DevSystemContracts::Local => system_contracts::Options::BuiltIn, + DevSystemContracts::Local => system_contracts::Options::Local, }; let node = InMemoryNode::new( From e2fac13a2773b47f585b6425d6c425f23c9a41d7 Mon Sep 17 00:00:00 2001 From: Nisheeth Barthwal Date: Tue, 17 Oct 2023 10:19:08 +0200 Subject: [PATCH 3/3] set default value --- src/main.rs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/main.rs b/src/main.rs index 70ce9c53..96b1defe 100644 --- a/src/main.rs +++ b/src/main.rs @@ -216,8 +216,9 @@ struct Cli { /// It will make debug log more readable, but will decrease the performance. resolve_hashes: bool, - /// Specifies the option for the system contracts (load locally or use compiled built-in with or without signature verification). - #[arg(long)] + /// Specifies the option for the system contracts (use compiled built-in with or without signature verification, or load locally). + /// Default: built-in + #[arg(long, default_value = "built-in")] dev_system_contracts: DevSystemContracts, /// Log filter level - default: info