Skip to content

Commit

Permalink
Add validium example guide
Browse files Browse the repository at this point in the history
  • Loading branch information
ilitteri committed Jan 3, 2024
1 parent fb659bf commit 3de9457
Showing 1 changed file with 100 additions and 0 deletions.
100 changes: 100 additions & 0 deletions validium.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
## Validium

In order to start the node as a validium:

- Make sure `zk` has been built and then run `zk init --validium`. 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, `cargo run --release --bin zksync_full_stack` inits a wallet, deploys a contract
and executes a tx
- Query the node for the tx hash (output of the zksync_full_stack binary):

```
curl -X POST -H 'content-type: application/json' 127.0.0.1:3050 -d '{"jsonrpc": "2.0", "id": 1, "method": "zks_getTransactionDetails", "params": ["0xa1ae38705aa3f3e65ec9f2ce2692aaff6e531d56031998d33ac3e015bf676680"]}' | jq
{
"jsonrpc": "2.0",
"result": {
"isL1Originated": false,
"status": "verified",
"fee": "0x1c72f149e000",
"gasPerPubdata": "0xc350",
"initiatorAddress": "0x36615cf349d7f6344891b1e7ca7c72883f5dc049",
"receivedAt": "2023-11-02T18:00:02.808Z",
"ethCommitTxHash": "0xf2daa7aeba7ded2c4dcb1ceb7892c6fa34ef57fec3a175f8593d313bf2c5d314",
"ethProveTxHash": "0x7b9385ac38937207ea54403e0dbefdd9000a33b01b61d777c134057863272b6c",
"ethExecuteTxHash": null
},
"id": 1
}
```

Not all the eth-related transaction hashes might be displayed depending on how much time passes between sending the tx
and querying the node, since the transactions are bundled into batches which get entered into the batch pipeline

- query the geth node with the `ethCommitTxHash` (remember to use your hash and not the one in the example below)

```
curl -X POST -H 'content-type: application/json' 127.0.0.1:8545 -d '{"jsonrpc": "2.0", "id": 1, "method": "eth_getTransactionByHash", "params": ["0xf2daa7aeba7ded2c4dcb1ceb7892c6fa34ef57fec3a175f8593d313bf2c5d314"]}' | jq
{
"jsonrpc": "2.0",
"id": 1,
"result": {
"blockHash": "0x67cf02bcb7752d71df784c5c1e21b860e78a8a2963c18833d5c6240eb141b4e3",
"blockNumber": "0x1d3b6",
"from": "0xde03a0b5963f75f1c8485b355ff6d30f3093bde7",
"gas": "0x3d0900",
"gasPrice": "0x3b9aca07",
"maxFeePerGas": "0x3b9aca0a",
"maxPriorityFeePerGas": "0x3b9aca00",
"hash": "0xf2daa7aeba7ded2c4dcb1ceb7892c6fa34ef57fec3a175f8593d313bf2c5d314",
"input": "0x701f58c500000000000000000000000000000000000000000000000000000000000000035a75c9fdb0ef4c97c74e433ac053b9afec3ad23563063b23890091324539c126000000000000000000000000000000000000000000000000000000000000005f0000000000000000000000000000000000000000000000000000000000000000c5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a4706c86889f42762dc2a4d547d5daab9982825dba1944ea75d19c5b72a6f8816c0a000000000000000000000000000000000000000000000000000000006543e10ec341dfc85d9f9402a6d16d2b863e1c30ac8cc8853ac2c024feb960c7c121d51b0000000000000000000000000000000000000000000000000000000000000120000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000006543e12600000000000000000000000000000000000000000000000000000000000000621cd68c6b5e0da5ab1354bd7523bb510155acf5ed85c2aa199b28695f90f7633a0000000000000000000000000000000000000000000000000000000000000000c5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a4707fb8d37f4ce4c9fdd84f5965ec76dd3ccb89e049f92cf155bc2ddc71bfad8c5b470af434b6d50228459d0ed2e371f237933c9f3f4c3e1c1417e4b3d3fcd2b4b6000000000000000000000000000000000000000000000000000000000000014000000000000000000000000000000000000000000000000000000000000003e0000000000000000000000000000000000000000000000000000000000000026800000000000000000000000000000000000000000000800b00000000000000000000000000000000000000000000000000000000000000045a75c9fdb0ef4c97c74e433ac053b9afec3ad23563063b23890091324539c12600000001000000000000000000000000000000000000800b00000000000000000000000000000000000000000000000000000000000000030000000000000000000000006543e1260000000000000000000000006543e1270001000100000000000000000000000000000000000080010000000000000000000000000000000000000000000000000000000000000005c5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470000100010000000000000000000000000000000000008001000000000000000000000000000000000000000000000000000000000000000600000000000000000000000000000000000000000000000000000000000000000001000100000000000000000000000000000000000080080000000000000000000000000000000000000000000000000000000000000000fef7bd9f889811e59e4076a0174087135f080177302763019adaf531257e3a8700010001000000000000000000000000000000000000800800000000000000000000000000000000000000000000000000000000000000011c204342a59bae89d48807f747a363671740f0615de30530e12e8bbfc450ece000010001000000000000000000000000000000000000800800000000000000000000000000000000000000000000000000000000000000022b4fd9c63abc805a3c11cbc1264eb6c9bcdec326c3f8b41eb92d4b2ffef611c2000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000c0000000000000000010203090000000000000000000000000000000000000000",
"nonce": "0x38",
"to": "0x06b7877ba1a9bb15e5ae1aaac8c651969106a57a",
"transactionIndex": "0x0",
"value": "0x0",
"type": "0x2",
"accessList": [],
"chainId": "0x9",
"v": "0x0",
"r": "0x9f038380597cdc035e60916dd9bbd20d0b1a02f32eac7def479cf1f24633b100",
"s": "0x79c004b4b18d7132f980c501bc14804e6bd78cccc76a8e5fff6631b1403c832c"
}
}
```

if the same process is followed for a non-validium node, there is more data in the input field (see after the `01020309`
sub-array which was put in place for detecting these changes):

```
curl -X POST -H 'content-type: application/json' 127.0.0.1:8545 -d '{"jsonrpc": "2.0", "id": 1, "method": "eth_getTransactionByHash", "params": ["0xf2daa7aeba7ded2c4dcb1ceb7892c6fa34ef57fec3a175f8593d313bf2c5d314"]}' | jq
{
"jsonrpc": "2.0",
"id": 1,
"result": {
"blockHash": "0x2dc87056f8c8b7eba3f122da43bc8db0672492aa5915f944b4842b4ab57f21f8",
"blockNumber": "0x1d628",
"from": "0xde03a0b5963f75f1c8485b355ff6d30f3093bde7",
"gas": "0x3d0900",
"gasPrice": "0x3b9aca07",
"maxFeePerGas": "0x3b9aca0a",
"maxPriorityFeePerGas": "0x3b9aca00",
"hash": "0xf2daa7aeba7ded2c4dcb1ceb7892c6fa34ef57fec3a175f8593d313bf2c5d314",
"input": "0x701f58c50000000000000000000000000000000000000000000000000000000000000003abcc4c7388651eb753807814b2c5fce3c85d7501cf89dad6e5669df9c5ede5c8000000000000000000000000000000000000000000000000000000000000005e0000000000000000000000000000000000000000000000000000000000000000c5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a4706c86889f42762dc2a4d547d5daab9982825dba1944ea75d19c5b72a6f8816c0a000000000000000000000000000000000000000000000000000000006543e38b2da007083449852aa93d1b2e48cf237dafe6d11eeee14dca1a2abb3525526b100000000000000000000000000000000000000000000000000000000000000120000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000006543e3a3000000000000000000000000000000000000000000000000000000000000006122173cd9a05bc38fb465363fd6aed57d93141f8bfdbc75d19ea48f2af3beb52d0000000000000000000000000000000000000000000000000000000000000000c5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a4706294138c217f7427db7f8e19c4d6bc144331827e856e379016e8b66cf9fc05e6470af434b6d50228459d0ed2e371f237933c9f3f4c3e1c1417e4b3d3fcd2b4b6000000000000000000000000000000000000000000000000000000000000014000000000000000000000000000000000000000000000000000000000000003e0000000000000000000000000000000000000000000000000000000000000026800000000000000000000000000000000000000000000800b0000000000000000000000000000000000000000000000000000000000000004abcc4c7388651eb753807814b2c5fce3c85d7501cf89dad6e5669df9c5ede5c800000001000000000000000000000000000000000000800b00000000000000000000000000000000000000000000000000000000000000030000000000000000000000006543e3a30000000000000000000000006543e3a40001000100000000000000000000000000000000000080010000000000000000000000000000000000000000000000000000000000000005c5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470000100010000000000000000000000000000000000008001000000000000000000000000000000000000000000000000000000000000000600000000000000000000000000000000000000000000000000000000000000000001000100000000000000000000000000000000000080080000000000000000000000000000000000000000000000000000000000000000fef7bd9f889811e59e4076a0174087135f080177302763019adaf531257e3a870001000100000000000000000000000000000000000080080000000000000000000000000000000000000000000000000000000000000001dc5fdb827f4535cf6d6552a98d75494dae47466825a5f2a2c8b28b15bc0fcf7a0001000100000000000000000000000000000000000080080000000000000000000000000000000000000000000000000000000000000002e7748039ceb32bda1670b1a1520470e929f74b5ce1bf29df23258c0a5301e225000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000015b00000000000000000102030900000000010001460400032c1818e4770f08c05b28829d7d5f9d401d492c7432c166dfecf4af04238ea3230058d1d0f8a5baff47f324e7d9b05e62deb67355dd311d0e6a6bf9e7c41ecec108ca1bbc31cc849a8092a36f9a321e17412dee200b956038af1c2dc83430a0e8b00058203175654ae01a169ff0277c30e5d00fb332f32855bf6204abe9a7168d00f3cf368ce957aed709b985423cd3ba11615de01ecafa15eb9a11bc6cdef4f6327900abcc4c7388651eb753807814b2c5fce3c85d7501cf89dad6e5669df9c5ede5c800000058090100000030311c72f149e00000000053321c72f149e0000000003389010000000000000000000000000000001800000034890200000000000000000000000000000018000000378902000000000000000000000000000000180000005df20c9390fffffffffffffffffffffffffffffffffffffffffffffffffffffc0000000000",
"nonce": "0x49",
"to": "0x540c25479dd1f0250e336b3abb21485afa7d8aba",
"transactionIndex": "0x0",
"value": "0x0",
"type": "0x2",
"accessList": [],
"chainId": "0x9",
"v": "0x0",
"r": "0x69874fbaab6e00210cbdc03b15aab565eeb0c706e1845601d194e243e71bd618",
"s": "0xdab5e41a8cfbe73295f57e1bd1ac409170ba251eefc822b8e2c6936aaf3ed"
}
}
```

0 comments on commit 3de9457

Please sign in to comment.