From 479061d8879603a63694fd1c44bb9c161c588d8f Mon Sep 17 00:00:00 2001 From: Jordi <146965181+jordibonet-lambdaclass@users.noreply.github.com> Date: Tue, 16 Jan 2024 15:38:55 +0100 Subject: [PATCH 1/3] fix: update output readme (#39) * Update output readme * Add a note for transactions * Fix note --- validium.md | 22 ++++++++-------------- validium_mode_example/src/main.rs | 5 ----- 2 files changed, 8 insertions(+), 19 deletions(-) diff --git a/validium.md b/validium.md index 5bc22e0c98b0..d58121029da0 100644 --- a/validium.md +++ b/validium.md @@ -22,34 +22,28 @@ In order to start the node as a validium: - `Transaction hash`: The hash of the transaction - `Transaction gas used`: The gas used to perform this transaction. - `L2 fee`: The total cost of this transaction. - - `L1 Gas`: The gas borrowed in order to run the transaction. Unused gas will be returned. - - `L1 Gas price`: The gas price used to run the transaction. ### Example output ``` -Deposit transaction hash: 0xc01cf32c699943f8d751047514393a5e98d8cbeaa128fa50c32a3d7804b876a5 +Deposit transaction hash: 0x77f378f1857ad7ff8c1041d2ce0f7f167587a90a19f9fd923c9ea91fbdf37650 Deploy -Contract address: 0xf2fcc18ed5072b48c0a076693eca72fe840b3981 -Transaction hash 0x9e817fcc8eeeda001793c9142161a11e3fd3ef3c64523be1f5c11b6cbff7b64f +Contract address: 0x4b5df730c2e6b28e17013a1485e5d9bc41efe021 +Transaction hash 0xe08786e302027040056555bdba6e0462fdee56768d982485d80f732043013bb5 Transaction gas used 161163 L2 fee: 40290750000000 -L1 Gas: 4000000 -L1 Gas price: 1000000007 Mint -Transaction hash 0x0e9bcc26addf1edfe0993767cc2d6ec959a135dc3087b63b5fc9d54d7ed854ef +Transaction hash 0x2f5b565959c8c5ffe320a364df27f4de451ed93ee6344a838f2212397da7fe5f Transaction gas used 124046 L2 fee: 31011500000000 -L1 max fee per gas: 1000000010 -L1 Gas: 4000000 -L1 Gas price: 1000000007 +L1 max fee per gas: 1200000011 Transfer 1000 -Transaction hash 0x5a1f7130024b73c2d3de5256a72bddbc703983d69d3ad0f3f64d8e6122e0e85a +Transaction hash 0x7cfadf74a5fa571ed9e2f1a115edc62f8db913d61d387177b7b07e2cb270af75 Transaction gas used 125466 L2 fee: 31366500000000 L1 max fee per gas: 1000000010 -L1 Gas: 4000000 -L1 Gas price: 1000000007 ``` + +> [!NOTE] The `transaction hash` is a changing field and the value of the other fields may change depending on the server mode (`rollup` or `validium`). diff --git a/validium_mode_example/src/main.rs b/validium_mode_example/src/main.rs index 9d1337b4d1d7..7c82fbf28206 100644 --- a/validium_mode_example/src/main.rs +++ b/validium_mode_example/src/main.rs @@ -129,11 +129,6 @@ async fn main() { let l2_tx_fee_formatted_deploy = format!("{:#?}", l2_transaction_deploy.fee); println!("L2 fee: {}", l2_tx_fee_formatted_deploy.green()); - let l1_transaction = l1_rpc_client - .get_transaction_by_hash(l2_transaction_deploy.eth_commit_tx_hash.unwrap()) - .await - .unwrap() - .unwrap(); address }; From ef48b514d15c60c37c53f7ec875e7ba5a0f7c14d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Antonio=20Calv=C3=ADn=20Garc=C3=ADa?= Date: Tue, 16 Jan 2024 20:55:29 +0100 Subject: [PATCH 2/3] feat: remove logs pubdata (#42) * remove logs from pubdata * update comment --- core/lib/types/src/commitment.rs | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/core/lib/types/src/commitment.rs b/core/lib/types/src/commitment.rs index 3c4ec610d280..c75043aacf55 100644 --- a/core/lib/types/src/commitment.rs +++ b/core/lib/types/src/commitment.rs @@ -224,14 +224,14 @@ impl L1BatchWithMetadata { pub fn construct_pubdata(&self, validium_mode: bool) -> Vec { let mut res: Vec = vec![]; - // Process and Pack Logs - res.extend((self.header.l2_to_l1_logs.len() as u32).to_be_bytes()); - for l2_to_l1_log in &self.header.l2_to_l1_logs { - res.extend(l2_to_l1_log.0.to_bytes()); - } - - // We do not want to publish L2->L1 msgs, bytecodes, and state diffs in validium mode. + // We do not want to publish L2-L1 logs, L2->L1 msgs, bytecodes, and state diffs in validium mode. if !validium_mode { + // Process and Pack Logs + res.extend((self.header.l2_to_l1_logs.len() as u32).to_be_bytes()); + for l2_to_l1_log in &self.header.l2_to_l1_logs { + res.extend(l2_to_l1_log.0.to_bytes()); + } + // Process and Pack Msgs res.extend((self.header.l2_to_l1_messages.len() as u32).to_be_bytes()); for msg in &self.header.l2_to_l1_messages { From 5c3dfc54681c3d819e6c221403fb2339f10afe5b Mon Sep 17 00:00:00 2001 From: Jordi <146965181+jordibonet-lambdaclass@users.noreply.github.com> Date: Wed, 17 Jan 2024 15:31:57 +0100 Subject: [PATCH 3/3] feat: refactor readme example (#44) * Refactor readme example * Fix some comments * Remove validium.md --- .../README.md | 38 ++++++++++++++----- 1 file changed, 29 insertions(+), 9 deletions(-) rename validium.md => validium_mode_example/README.md (57%) diff --git a/validium.md b/validium_mode_example/README.md similarity index 57% rename from validium.md rename to validium_mode_example/README.md index d58121029da0..200c6e44b944 100644 --- a/validium.md +++ b/validium_mode_example/README.md @@ -1,13 +1,30 @@ -## Validium +## Validium example -In order to start the node as a validium: +In order to start the node as a validium and run the example follow the next steps. -- Make sure `zk` has been built and then run `zk && zk clean --all && zk init --validium-mode` This will set up the - Ethereum node with the validium contracts, and also define an env var which the server will pick up in order to run as - a validium node. -- Start the server (`zk server`) -- Execute transactions. For testing, run `cargo run --release --bin validium_mode_example`, this test does the - following: +### Run the server + +To run this example we need to run the server in validium mode. In the `zksync-era` directory, you can run the following command: + +```sh +zk && zk clean --all && zk init --validium-mode && zk server +``` + +> [!IMPORTANT] +> Make sure that the flag `--validium-mode` is present when initilizing the server. + +This will set up the Ethereum node with the validium contracts, and also define an `env` var which the server will pick up in order to run as a validium node. + +### Run the example + +In this example we're going to run some transactions. + +Once the server is running, run this command in other terminal: +```sh +cargo run --release --bin zksync_full_stack +``` + +This test does the following: - Inits a wallet - Deposits some funds into the wallet - Deploys a sample ERC20 contract @@ -25,6 +42,8 @@ In order to start the node as a validium: ### Example output +You will have an output similar to this one: + ``` Deposit transaction hash: 0x77f378f1857ad7ff8c1041d2ce0f7f167587a90a19f9fd923c9ea91fbdf37650 Deploy @@ -46,4 +65,5 @@ L2 fee: 31366500000000 L1 max fee per gas: 1000000010 ``` -> [!NOTE] The `transaction hash` is a changing field and the value of the other fields may change depending on the server mode (`rollup` or `validium`). +> [!NOTE] +> You can observe how the diferent fields evolve depending on the operation. The `transaction hash` is a changing field. \ No newline at end of file