Dal_node: Add /synced RPC for querying synchronisation with L1 node
What
Closes #7892 (closed).
Add a /synchronized and a /monitor/synchronized RPC endpoint for the DAL node to monitor the state of the DAL node with respect to the L1 node.
Why
We make use of the L1 crawler status introduced in !18012 (merged).
How
By switching from having a L1 crawler status to having a stream of them, to be used by the RPC endpoint added.
(However, I believe this is not the best approach, it should either be re-thought, or altered, but I have ran out of ideas on how to implement a better version)
Manually testing the MR
- Test when the L1 node is behind the chain
- start a new L1 node (from a snapshot):
$ make
$ ./octez-node config init --data-dir ~/.tezos-node-test --network "ghostnet"
$ ./octez-node snapshot import --data-dir ~/.tezos-node-test ~/Downloads/ghostnet_rolling --no-check
- run the L1 node and in another terminal the DAL node
$ ./octez-node run --data-dir ~/.tezos-node-test --rpc-addr 127.0.0.1:18733 --net-addr 127.0.0.1:19732
$ ./octez-dal-node config init --endpoint http://127.0.0.1:18733
$ ./octez-dal-node run --rpc-addr 127.0.0.1:18999
Then, test the new RPC endpoint:
gabrielmoise at 192 in ~/tezos (gabriel@dal_node_synced_rpc●)
$ curl http://127.0.0.1:18999/monitor/synchronized
{"status":"L1_bootstrapping"}
{"status":"Catching_up","levels_to_process":2}
{"status":"Lagging","levels_to_process":17}
{"status":"Lagging","levels_to_process":16}
{"status":"Lagging","levels_to_process":15}
{"status":"Lagging","levels_to_process":14}
{"status":"Lagging","levels_to_process":13}
{"status":"Lagging","levels_to_process":12}
{"status":"Lagging","levels_to_process":11}
{"status":"Lagging","levels_to_process":10}
{"status":"Lagging","levels_to_process":9}
{"status":"Lagging","levels_to_process":8}
{"status":"Lagging","levels_to_process":7}
{"status":"Lagging","levels_to_process":6}
{"status":"Lagging","levels_to_process":5}
{"status":"Lagging","levels_to_process":4}
{"status":"Lagging","levels_to_process":3}
{"status":"Lagging","levels_to_process":2}
{"status":"Lagging","levels_to_process":1}
{"status":"Synced"}
- DAL node is behind the L1 node
- Stop the DAL node for a bit, to be behind the L1 node.
- Wait for a bit
- Restart the DAL node and query the RPC endpoint
- Query RPC endpoint again:
gabrielmoise at 192 in ~/tezos (gabriel@dal_node_synced_rpc●)
$ curl http://127.0.0.1:18999/monitor/synchronized
{"status":"L1_bootstrapping"}
{"status":"Catching_up","levels_to_process":109}
{"status":"Catching_up","levels_to_process":108}
...
{"status":"Catching_up","levels_to_process":6}
{"status":"Catching_up","levels_to_process":5}
{"status":"Catching_up","levels_to_process":4}
{"status":"Catching_up","levels_to_process":3}
{"status":"Catching_up","levels_to_process":2}
{"status":"Catching_up","levels_to_process":1}
{"status":"Synced"}
and
$ curl http://127.0.0.1:18999/synchronized
{"status":"Synced"}
Checklist
-
Document the interface of any function added or modified (see the coding guidelines) -
Document any change to the user interface, including configuration parameters (see node configuration) -
Provide automatic testing (see the testing guide). -
For new features and bug fixes, add an item in the appropriate changelog ( docs/protocols/alpha.rstfor the protocol and the environment,CHANGES.rstat the root of the repository for everything else). -
Select suitable reviewers using the Reviewersfield below. -
Select as Assigneethe next person who should take action on that MR
Edited by Gabriel Moise