|
| 1 | +# Centralized Sequencer |
| 2 | + |
| 3 | +<!-- markdownlint-disable MD033 --> |
| 4 | +<script setup> |
| 5 | +import constants from '../../.vitepress/constants/constants.js' |
| 6 | +</script> |
| 7 | + |
| 8 | +A centralized sequencer is a sequencing middleware that receives rollup transactions and provides a local sequencing capabilities. Meaning, the transactions are ordered in the order they are received by the sequencer without any censorship. Further, the sequenced batches are made available in the DA network (such as Celestia). Under the hood, the centralized sequencer is a GRPC server that implements `go-sequencing` interface and the server is hosted by the same node that is running the aggregator for the Rollkit rollup. |
| 9 | + |
| 10 | + |
| 11 | + |
| 12 | +## Prerequisites {#prerequisites} |
| 13 | + |
| 14 | +This tutorial serves as a comprehensive guide for using the [centralized-sequencer](https://github.com/rollkit/centralized-sequencer) with your chain. |
| 15 | + |
| 16 | +Before proceeding, ensure that you have completed the [quick start](/tutorials/quick-start) or [build a chain](/tutorials/wordle) tutorial, which covers installing the rollkit CLI, building your chain, and running your chain. |
| 17 | + |
| 18 | +:::tip |
| 19 | +It is important to note that the centralized sequencer expects a DA layer to be running when it starts. This means that you need to launch your DA Layer before starting the centralized sequencer. |
| 20 | +::: |
| 21 | + |
| 22 | +Additionally, you should have completed one of the [DA Layer tutorials](../da/overview) and have your DA layer ready to use with the centralized sequencer. This tutorial will use the [local-da layer](../da/local) as an example. |
| 23 | + |
| 24 | +## Installation the Centralized Sequencer {#installation-centralized-sequencer} |
| 25 | + |
| 26 | +```sh-vue |
| 27 | +git clone --depth 1 --branch {{constants.centralizedSequencerLatestTag}} https://github.com/rollkit/centralized-sequencer.git |
| 28 | +cd centralized-sequencer |
| 29 | +make build |
| 30 | +./build/centralized-sequencer -h |
| 31 | +``` |
| 32 | + |
| 33 | +```sh |
| 34 | +Usage: |
| 35 | + -host string |
| 36 | + centralized sequencer host (default "localhost") |
| 37 | + -port string |
| 38 | + centralized sequencer port (default "50051") |
| 39 | + -listen-all |
| 40 | + listen on all network interfaces (0.0.0.0) instead of just localhost |
| 41 | + -rollup-id string |
| 42 | + rollup id (default "rollupId") |
| 43 | + -batch-time duration |
| 44 | + time in seconds to wait before generating a new batch (default 2s) |
| 45 | + -da_address string |
| 46 | + DA address (default "http://localhost:26658") |
| 47 | + -da_auth_token string |
| 48 | + auth token for the DA |
| 49 | + -da_namespace string |
| 50 | + DA namespace where the sequencer submits transactions |
| 51 | + -db_path string |
| 52 | + path to the database |
| 53 | +``` |
| 54 | + |
| 55 | +As shown by the help command, a centralized sequencer is configured to serve a rollup (via `rollup_id`). The DA network to persist the sequenced batches are specified using `da_address`, `da_auth_token` and `da_namespace`. |
| 56 | + |
| 57 | + |
| 58 | +## Run the centralized sequencer {#run-the-centralized-sequencer} |
| 59 | + |
| 60 | +:::tip |
| 61 | +As mentioned in the prerequisities, you should have your DA layer running. These steps assume the local-da is running on `http://localhost:7980`. |
| 62 | +::: |
| 63 | + |
| 64 | +Start your centralized sequencer with the following command: |
| 65 | + |
| 66 | +::: code-group |
| 67 | + |
| 68 | +```sh [Quick Start] |
| 69 | +./build/centralized-sequencer -rollup-id my-rollup -da_address http://localhost:7980 |
| 70 | +``` |
| 71 | + |
| 72 | +```sh [Build a Chain] |
| 73 | +./build/centralized-sequencer -rollup-id wordle -da_address http://localhost:7980 |
| 74 | +``` |
| 75 | +::: |
| 76 | + |
| 77 | + |
| 78 | +## Run your chain {#run-your-chain} |
| 79 | + |
| 80 | +To connect your chain to the centralized sequencer, you need to pass the `--rollkit.sequencer_address` flag with the local sequencer address and the `--rollkit.sequencer_rollup_id` to ensure your rollup id matches what the sequencer is expecting. |
| 81 | + |
| 82 | +Start your chain with the following command, ensuring to include the sequencer flag: |
| 83 | + |
| 84 | +::: code-group |
| 85 | + |
| 86 | +```sh [Quick Start] |
| 87 | +rollkit start \ |
| 88 | + --rollkit.da_address http://localhost:7980 \ |
| 89 | + --rollkit.sequencer_address localhost:50051 \ |
| 90 | + --rollkit.sequencer_rollup_id my-rollup |
| 91 | +``` |
| 92 | + |
| 93 | +```sh [Wordle Chain] |
| 94 | +rollkit start \ |
| 95 | + --rollkit.aggregator \ |
| 96 | + --rollkit.da_address http://localhost:7980 \ |
| 97 | + --rollkit.sequencer_address localhost:50051 \ |
| 98 | + --rollkit.sequencer_rollup_id wordle |
| 99 | +``` |
| 100 | + |
| 101 | +::: |
| 102 | + |
| 103 | +You should see the following log messages indicating that your chain is connected to the local sequencer: |
| 104 | + |
| 105 | +```sh |
| 106 | +I[2024-11-15|15:22:33.636] sequencer already running module=main address=localhost:50051 |
| 107 | +I[2024-11-15|15:22:33.636] make sure your rollupID matches your sequencer module=main rollupID=my-rollup |
| 108 | +``` |
| 109 | + |
| 110 | +Then after a few blocks you should see this message confirming that your sequencer is successfully submitting batches to the DA layer: |
| 111 | + |
| 112 | +```sh |
| 113 | +I[2024-11-15|16:04:07.698] successfully submitted Rollkit headers to DA layer module=BlockManager gasPrice=-1 daHeight=1 headerCount=14 |
| 114 | +``` |
| 115 | + |
| 116 | +## Summary {#summary} |
| 117 | + |
| 118 | +By following these steps, you will have successfully set up and connected your chain to the centralized sequencer. You can now start submitting transactions to your chain. |
0 commit comments