From 88c828221fbb156dd989dd08de39d5033eed8acf Mon Sep 17 00:00:00 2001 From: Jordi Date: Tue, 16 Jan 2024 17:06:46 +0100 Subject: [PATCH 1/3] Refactor readme example --- validium_mode_example/README.md | 71 +++++++++++++++++++++++++++++++++ 1 file changed, 71 insertions(+) create mode 100644 validium_mode_example/README.md diff --git a/validium_mode_example/README.md b/validium_mode_example/README.md new file mode 100644 index 00000000000..b6bec52dc0f --- /dev/null +++ b/validium_mode_example/README.md @@ -0,0 +1,71 @@ +## Validium example + +In order to start the node as a validium and run the example follow the next steps. + +### 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 +``` +> [!IMPORTANT] +> Make sure that you are in the `validium_mode_example` directory. + +This test does the following: + - Inits a wallet + - Deposits some funds into the wallet + - Deploys a sample ERC20 contract + - Query the contract for the token name and symbol + - Mint 100000 tokens into the address `CD2a3d9F938E13CD947Ec05AbC7FE734Df8DD826` + - Transfer 1000 tokens from `CD2a3d9F938E13CD947Ec05AbC7FE734Df8DD826` to `bBbBBBBbbBBBbbbBbbBbbbbBBbBbbbbBbBbbBBbB` + +### Logs and prints + +- For each transaction, we use the rpc client to query the transaction details and print them out. The following fields + are printed: + - `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. + +### Example output + +You will have an output similar to this one: + +``` +Deposit transaction hash: 0x77f378f1857ad7ff8c1041d2ce0f7f167587a90a19f9fd923c9ea91fbdf37650 +Deploy +Contract address: 0x4b5df730c2e6b28e17013a1485e5d9bc41efe021 +Transaction hash 0xe08786e302027040056555bdba6e0462fdee56768d982485d80f732043013bb5 +Transaction gas used 161163 +L2 fee: 40290750000000 + +Mint +Transaction hash 0x2f5b565959c8c5ffe320a364df27f4de451ed93ee6344a838f2212397da7fe5f +Transaction gas used 124046 +L2 fee: 31011500000000 +L1 max fee per gas: 1200000011 + +Transfer 1000 +Transaction hash 0x7cfadf74a5fa571ed9e2f1a115edc62f8db913d61d387177b7b07e2cb270af75 +Transaction gas used 125466 +L2 fee: 31366500000000 +L1 max fee per gas: 1000000010 +``` + +> [!NOTE] +> You can observe how the diferent fields evolve depending on the operation. The `transaction hash` is a changing field and the value of the other fields may change depending on the server mode (`rollup` or `validium`). \ No newline at end of file From 122aeada72702be31e78aafa3e3700ba60b428dd Mon Sep 17 00:00:00 2001 From: Jordi Date: Tue, 16 Jan 2024 17:15:44 +0100 Subject: [PATCH 2/3] Fix some comments --- validium_mode_example/README.md | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/validium_mode_example/README.md b/validium_mode_example/README.md index b6bec52dc0f..200c6e44b94 100644 --- a/validium_mode_example/README.md +++ b/validium_mode_example/README.md @@ -23,8 +23,6 @@ Once the server is running, run this command in other terminal: ```sh cargo run --release --bin zksync_full_stack ``` -> [!IMPORTANT] -> Make sure that you are in the `validium_mode_example` directory. This test does the following: - Inits a wallet @@ -68,4 +66,4 @@ L1 max fee per gas: 1000000010 ``` > [!NOTE] -> You can observe how the diferent fields evolve depending on the operation. The `transaction hash` is a changing field and the value of the other fields may change depending on the server mode (`rollup` or `validium`). \ No newline at end of file +> 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 From 65429415e92c21b4d8c3a0e5301d3930ac87db65 Mon Sep 17 00:00:00 2001 From: Jordi Date: Wed, 17 Jan 2024 10:37:05 +0100 Subject: [PATCH 3/3] Remove validium.md --- validium.md | 49 ------------------------------------------------- 1 file changed, 49 deletions(-) delete mode 100644 validium.md diff --git a/validium.md b/validium.md deleted file mode 100644 index d58121029da..00000000000 --- a/validium.md +++ /dev/null @@ -1,49 +0,0 @@ -## Validium - -In order to start the node as a validium: - -- 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: - - Inits a wallet - - Deposits some funds into the wallet - - Deploys a sample ERC20 contract - - Query the contract for the token name and symbol - - Mint 100000 tokens into the address `CD2a3d9F938E13CD947Ec05AbC7FE734Df8DD826` - - Transfer 1000 tokens from `CD2a3d9F938E13CD947Ec05AbC7FE734Df8DD826` to `bBbBBBBbbBBBbbbBbbBbbbbBBbBbbbbBbBbbBBbB` - -### Logs and prints - -- For each transaction, we use the rpc client to query the transaction details and print them out. The following fields - are printed: - - `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. - -### Example output - -``` -Deposit transaction hash: 0x77f378f1857ad7ff8c1041d2ce0f7f167587a90a19f9fd923c9ea91fbdf37650 -Deploy -Contract address: 0x4b5df730c2e6b28e17013a1485e5d9bc41efe021 -Transaction hash 0xe08786e302027040056555bdba6e0462fdee56768d982485d80f732043013bb5 -Transaction gas used 161163 -L2 fee: 40290750000000 - -Mint -Transaction hash 0x2f5b565959c8c5ffe320a364df27f4de451ed93ee6344a838f2212397da7fe5f -Transaction gas used 124046 -L2 fee: 31011500000000 -L1 max fee per gas: 1200000011 - -Transfer 1000 -Transaction hash 0x7cfadf74a5fa571ed9e2f1a115edc62f8db913d61d387177b7b07e2cb270af75 -Transaction gas used 125466 -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`).