-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add a tutorial to run the DAL as a baker on Weeklynet
- Loading branch information
Raphaël Cauderlier
committed
Jan 13, 2024
1 parent
4d9ee45
commit 0725d33
Showing
9 changed files
with
172 additions
and
0 deletions.
There are no files selected for viewing
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
20 changes: 20 additions & 0 deletions
20
docs/tutorials/running-the-dal-as-a-weeklynet-baker-in-5-steps.md
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,20 @@ | ||
# Running the DAL as a Weeklynet baker, in 5 steps | ||
|
||
Tezos' Data-Availability Layer (DAL for short), which we presented [in a previous article](https://research-development.nomadic-labs.com/data-availability-layer-tezos.html), is a key component of our scalability roadmap for Tezos. In a nutshell, the DAL is about increasing the bandwidth available for Tezos smart rollups thanks to a new parallel P2P network on which rollup could connect to fetch inputs but without compromising their security and in particular the possibility for any participant to detect fraud attempts from rollup operators and refute them in the Tezos protocol. | ||
|
||
In order for the DAL to be as secured as the Tezos Layer 1 itself, bakers would play a very important role in it. Currently, bakers on the L1 network are not only responsible for producing blocks but also for attesting that blocks are published on the L1 network; they are rewarded for this through protocol incentives and they also monitor the behaviour of other bakers to denounce cheating attempts. Similarly, the role of bakers for the DAL would be to attest the publication of data on the DAL P2P network, they would be rewarded for this through protocol incentives, and denounce cheating attempts from other bakers. | ||
|
||
Since a new P2P network with hundreds of participants may take some time to setup, we will propose a smooth transition toward the DAL by not including any protocol incentives for DAL attestations in the first mainnet version of the DAL, this will let plenty of time for bakers to join the DAL network without risking any reward loss. This incentive-free version of the DAL is already available on the weeklynet test network and we consider it to be stable enough to be put in the hands of bakers willing to test it and report any issue they may find. Feedback from bakers is very important for us now because modifying DAL may become much harder once it is part of a protocol amendment proposal. | ||
|
||
This article is a tutorial for bakers willing to test the DAL on the weeklynet network so that they can play with the feature and prepare well in advance for a possible future activation of the DAL on mainnet. | ||
|
||
/!\ Warning: This tutorial uses a very simple setup running all required daemons on the same machine. In a production environment, we advise against running a DAL attester node under the same IP address than a baker's node because the DAL node may leak the IP address and ease DOS attacks on the baker. See also [the DAL documentation page on baking](https://tezos.gitlab.io/shell/dal_bakers.html). | ||
|
||
/!\ Warning: This article was written in January 2024 to help bakers experiment with the DAL. If you are reading this article in the future, the UX of the DAL components will probably have changed with the feedback we got, in particular from the testers following this tutorial. | ||
|
||
- [Step 1: get a Weeklynet-compatible Octez](./running-the-dal-as-a-weeklynet-baker-in-5-steps/get-octez) | ||
- [Step 2: run an Octez node on Weeklynet](./running-the-dal-as-a-weeklynet-baker-in-5-steps/run-node) | ||
- [Step 3: prepare an account for baking on Weeklynet](./running-the-dal-as-a-weeklynet-baker-in-5-steps/prepare-account) | ||
- [Step 4: run an Octez DAL node on Weeklynet](./running-the-dal-as-a-weeklynet-baker-in-5-steps/run-dal-node) | ||
- [Step 5: run an Octez baking deamon on Weeklynet](./running-the-dal-as-a-weeklynet-baker-in-5-steps/run-baker) | ||
- [Conclusion](./running-the-dal-as-a-weeklynet-baker-in-5-steps/conclusion) |
3 changes: 3 additions & 0 deletions
3
docs/tutorials/running-the-dal-as-a-weeklynet-baker-in-5-steps/conclusion.md
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,3 @@ | ||
# Conclusion | ||
|
||
In this tutorial we have gone through all the steps needed to participate in the Weeklynet test network as a baker and DAL attester. We could further improve the setup by defining system services so that the daemons are automatically launched when the machine starts or when the network restarts on Wednesday. We could also plug a monitoring solution such as the Prometheus + Grafana combo; a Grafana dashboard template for DAL nodes is available in Grafazos. The interactions between our baker and the Weeklynet chain can be observed on the Explorus block explorer which is aware of the DAL and can in particular display which DAL slots are being used at each level. |
6 changes: 6 additions & 0 deletions
6
docs/tutorials/running-the-dal-as-a-weeklynet-baker-in-5-steps/get-octez.md
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,6 @@ | ||
## Step 1: get a Weeklynet-compatible Octez | ||
|
||
The Weeklynet test network is restarted once every Wednesday and for most of its lifetime (from level 512) it runs a development version of the Tezos protocol which is not part of any released version of Octez. For this reason, baking on Weeklynet requires to run Octez either with Docker using a specific Docker image, or by building it from source using a specific git commit. | ||
|
||
To get this specific docker image or the hash of this specific commit, see https://teztnets.xyz/weeklynet-about. This page also contains the proper `octez-node config init` incantation to configure the Octez node with the current network parameters of Weeklynet, the URL of a public RPC endpoint, and a link to a faucet distributing testnet tez for free. | ||
|
57 changes: 57 additions & 0 deletions
57
docs/tutorials/running-the-dal-as-a-weeklynet-baker-in-5-steps/prepare-account.md
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,57 @@ | ||
## Step 3: prepare an account for baking on Weeklynet | ||
|
||
Our baker needs an implicit account consisting of a pair of keys and an address. The simplest to get them is to ask the Octez client to randomly generate them and associate them to the `my_baker` alias: | ||
|
||
``` | ||
octez-client gen keys my_baker | ||
``` | ||
|
||
The address of the generated account can be obtained with the following command: | ||
|
||
``` | ||
octez-client show address my_baker | ||
``` | ||
|
||
Let's record this address in a shell variable, this will be useful for the some commands which cannot get addresses by their octez-client aliases. | ||
|
||
``` | ||
MY_BAKER="$(octez-client show address my_baker | head -n 1 | cut -d ' ' -f 2)" | ||
``` | ||
|
||
At this point, the balance of the `my_baker` account is still empty as can be seen with the following command: | ||
|
||
``` | ||
octez-client --endpoint "$TEZTNETS_RPC_ENDPOINT" get balance for my_baker | ||
``` | ||
|
||
In order to get some consensus and DAL rights, we need to put some tez on the account. Fortunately, getting free testnet tez is easy thanks to the testnet faucet. To use it, we need to enter the generated address in the Weeklynet faucet linked from https://teztnets.xyz/weeklynet-about. We need at least 6k tez for running a baker but the more tez we have the more rights we will get and the shorter we will have to wait to produce blocks and attestations; that being said, baking with too much stake would prevent us from leaving the network without disturbing or even halting it so to avoid breaking the network for all other testers let's not be too greedy. 50k tez should be enough to get enough rights to easily check if our baker behaves as expected while not much disturbing the network when our baker will stop operating. | ||
|
||
Once the tez are obtained from the faucet, we can check with the same `get balance` command that they have been received: | ||
|
||
``` | ||
octez-client --endpoint "$TEZTNETS_RPC_ENDPOINT" get balance for my_baker | ||
``` | ||
|
||
At this point, the `my_baker` account owns enough stake to bake but has still no consensus nor DAL rights because we haven't declared to the Tezos protocol our intention to become a baker. This can be achieved with the following command: | ||
|
||
``` | ||
octez-client --endpoint "$TEZTNETS_RPC_ENDPOINT" register key my_baker as delegate | ||
``` | ||
|
||
A few cycles later, our baker will start receiving rights. To see for instance its consensus attestation rights in the current cycle, we can use the following RPC: | ||
|
||
``` | ||
octez-client --endpoint "$TEZTNETS_RPC_ENDPOINT" rpc get /chains/main/blocks/head/helpers/attestation_rights\?delegate="$MY_BAKER" | ||
``` | ||
|
||
To see its DAL attestation rights, we can use the following RPC: | ||
|
||
``` | ||
octez-client --endpoint "$TEZTNETS_RPC_ENDPOINT" rpc get /chains/main/blocks/head/context/dal/shards | ||
``` | ||
|
||
This returns an array of DAL attestation rights indicating for each active baker the slice of shard indices it is expected to attest in the head block where a slice is given by a pair consisting of the first index and the length of the slice. So to check if some rights were assigned to us we can look for the address of our baker in the result of this RPC: | ||
|
||
``` | ||
octez-client --endpoint "$TEZTNETS_RPC_ENDPOINT" rpc get /chains/main/blocks/head/context/dal/shards | grep "$MY_BAKER" | ||
``` |
26 changes: 26 additions & 0 deletions
26
docs/tutorials/running-the-dal-as-a-weeklynet-baker-in-5-steps/run-baker.md
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,26 @@ | ||
### Step 5: run an Octez baking deamon on Weeklynet | ||
|
||
The baking daemon is launched almost as usual, the only difference is that we use the `--dal-node http://127.0.0.1` option to tell it to connect to the DAL node that we just launched in the previous step. | ||
|
||
``` | ||
octez-baker-alpha run with local node "$HOME/.tezos-node" my_baker --liquidity-baking-toggle-vote on --adaptive-issuance-vote on --dal-node http://127.0.0.1 &>> "$HOME/octez-baker.log" | ||
``` | ||
|
||
We can check that the DAL is now subscribed to the relevant topics by retrying the following RPC, which should now return all the topics of the form `{"slot_index":<index>,"pkh":"<ADDRESS OF OUR BAKER>"}` where `index` varies between `0` included and the number of slot indexes (`32` on Weeklynet) exluded: | ||
|
||
``` | ||
curl http://localhost:10732/p2p/gossipsub/topics | ||
``` | ||
|
||
We can also look at the baker logs to see if it manages to inject the expected operations. At each level, the baker is expected to: | ||
- receive a block proposal (log message: "received new proposal ... at level ..., round ...") | ||
- inject a preattestation for it (log message: "injected preattestation ... for my_baker (<address>) for level ..., round ...") | ||
- receive a block (log message: "received new head ... at level ..., round ...") | ||
- inject an attestation for it (log message: "injected attestation ... for my_baker (<address>) for level ..., round ...") | ||
- inject a DAL attestation indicating which of the shards assigned to the baker have been seen on the DAL network (log message: "injected DAL attestation ... for level ..., round ..., with bitset ... for my_baker (<address>) to attest slots published at level ..."); if no shard was seen (either because they did not reach the DAL node for some reason or simply because nothing was published on the DAL at the targetted level), the operation is skipped (log message: "Skipping the injection of the DAL attestation for attestation level ..., round ..., as currently no slot published at level ... is attestable.") | ||
|
||
Optionally, we can also launch an accuser which will monitor the behaviour of the other Weeklynet bakers and denounce them to the Tezos protocol if they are caught double-signing any block or consensus operation. | ||
|
||
``` | ||
octez-accuser-alpha run &>> "$HOME/octez-accuser.log" | ||
``` |
22 changes: 22 additions & 0 deletions
22
docs/tutorials/running-the-dal-as-a-weeklynet-baker-in-5-steps/run-dal-node.md
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,22 @@ | ||
|
||
## Step 4: run an Octez DAL node on Weeklynet | ||
|
||
``` | ||
octez-dal-node run &>> "$HOME/octez-dal-node.log" | ||
``` | ||
|
||
This, too, may take some time to launch the first time because it needs to generate a new identity file, this time for the DAL network. | ||
|
||
When running normally, the logs of the dal node should contain one line per block applied by the layer 1 node looking like: | ||
|
||
``` | ||
<timestamp>: layer 1 node's block at level <level>, round <round> is final | ||
``` | ||
|
||
The DAL node we have launched connects to the DAL network but it is not yet subscribed to any Gossipsub topic. We can observe this by requesting the topics it registered to using the following RPC: | ||
|
||
``` | ||
curl http://localhost:10732/p2p/gossipsub/topics | ||
``` | ||
|
||
In particular, it won't collect the shards assigned to our baker until it is subscribed to the corresponding topics. We could explicitly instruct the DAL node to subscribe to them by launching it in attester profile (by adding the `--attester-profiles="$MY_BAKER"` option) but this is not required because the baker daemon will automatically ask the DAL to subscribe to the relevent topics anyway. |
14 changes: 14 additions & 0 deletions
14
docs/tutorials/running-the-dal-as-a-weeklynet-baker-in-5-steps/run-node.md
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,14 @@ | ||
## Step 2: run an Octez node on Weeklynet | ||
|
||
Once the Octez node has been configured to join Weeklynet, it's possible to launch it. | ||
|
||
``` | ||
octez-node run --rpc-addr localhost --log-output="$HOME/octez-node.log" | ||
``` | ||
|
||
At first launch, the node will generate a fresh identity file used to identify itself on the Weeklynet L1 network, it then bootstraps the chain which means that it downloads and applies all the blocks. This takes a variable amount of time depending on when during the week these instructions are followed but at worse, on a tuesday evening, it takes a few hours. Fortunately, we can continue to set up our Weeklynet baking infrastructure while the node is bootstrapping, all we have to do for this is to use another, already bootstrapped, node as RPC endpoint for `octez-client` when we want to interact with the chain. | ||
|
||
A public RPC endpoint URL for Weeklynet is linked from the https://teztnets.xyz/weeklynet-about page, let's record it in a shell variable: | ||
``` | ||
TEZTNETS_RPC_ENDPOINT="<URL of the RPC endpoint linked from https://teztnets.xyz/weeklynet-about>" | ||
``` |
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