Skip to content

Commit

Permalink
feat: update sequencing section to include local sequencer and steps …
Browse files Browse the repository at this point in the history
…to connect sequencers with rollups
  • Loading branch information
MSevey committed Nov 15, 2024
1 parent 84860e8 commit 8c23cbc
Show file tree
Hide file tree
Showing 11 changed files with 225 additions and 56 deletions.
14 changes: 9 additions & 5 deletions .vitepress/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -239,23 +239,27 @@ function sidebarHome() {
items: [
{
text: "Overview",
link: "/tutorials/sequencing",
link: "/tutorials/sequencing/overview",
},
{
text: "Local",
link: "/tutorials/sequencing/local",
},
{
text: "Centralized",
link: "/tutorials/centralized",
link: "/tutorials/sequencing/centralized",
},
{
text: "Based",
link: "/tutorials/based",
link: "/tutorials/sequencing/based",
},
{
text: "Forced Inclusion",
link: "/tutorials/forced",
link: "/tutorials/sequencing/forced-inclusion",
},
{
text: "Astria",
link: "/tutorials/astria",
link: "/tutorials/sequencing/astria",
},
],
},
Expand Down
1 change: 1 addition & 0 deletions .vitepress/constants/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ const constants = Object.freeze({

localDALatestTag: "v0.3.1",
goSequencingLatestTag: "v0.4.1",
centralizedSequencerLatestTag: "v0.4.0",
igniteVersionTag: "v28.5.3",
});
export default constants;
3 changes: 0 additions & 3 deletions tutorials/astria.md

This file was deleted.

3 changes: 0 additions & 3 deletions tutorials/based.md

This file was deleted.

39 changes: 0 additions & 39 deletions tutorials/centralized.md

This file was deleted.

5 changes: 5 additions & 0 deletions tutorials/sequencing/astria.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Astria Sequencing

Coming soon ...

Track progress on the [GitHub](https://github.com/rollkit/astria-sequencer)
5 changes: 5 additions & 0 deletions tutorials/sequencing/based.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Based Sequencing

Coming soon ...

Track progress on the [GitHub](https://github.com/rollkit/based-sequencer)
118 changes: 118 additions & 0 deletions tutorials/sequencing/centralized.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
# Centralized Sequencer

<!-- markdownlint-disable MD033 -->
<script setup>
import constants from '../../.vitepress/constants/constants.js'
</script>

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.

![Rollkit with Centralized Sequencer](/public/img/sequencing.jpg)

## Prerequisites {#prerequisites}

This tutorial serves as a comprehensive guide for using the [centralized-sequencer](https://github.com/rollkit/centralized-sequencer) with your chain.

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.

:::tip
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.
:::

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.

## Installation the Centralized Sequencer {#installation-centralized-sequencer}

```sh-vue
git clone --depth 1 --branch {{constants.centralizedSequencerLatestTag}} https://github.com/rollkit/centralized-sequencer.git
cd centralized-sequencer
make build
./build/centralized-sequencer -h
```

```sh
Usage:
-host string
centralized sequencer host (default "localhost")
-port string
centralized sequencer port (default "50051")
-listen-all
listen on all network interfaces (0.0.0.0) instead of just localhost
-rollup-id string
rollup id (default "rollupId")
-batch-time duration
time in seconds to wait before generating a new batch (default 2s)
-da_address string
DA address (default "http://localhost:26658")
-da_auth_token string
auth token for the DA
-da_namespace string
DA namespace where the sequencer submits transactions
-db_path string
path to the database
```

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`.


## Run the centralized sequencer {#run-the-centralized-sequencer}

:::tip
As mentioned in the prerequisities, you should have your DA layer running. These steps assume the local-da is running on `http://localhost:7980`.
:::

Start your centralized sequencer with the following command:

::: code-group

```sh [Quick Start]
./build/centralized-sequencer -rollup-id my-rollup -da_address http://localhost:7980
```

```sh [Build a Chain]
./build/centralized-sequencer -rollup-id wordle -da_address http://localhost:7980
```
:::


## Run your chain {#run-your-chain}

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.

Start your chain with the following command, ensuring to include the sequencer flag:

::: code-group

```sh [Quick Start]
rollkit start \
--rollkit.da_address http://localhost:7980 \
--rollkit.sequencer_address localhost:50051 \
--rollkit.sequencer_rollup_id my-rollup
```

```sh [Wordle Chain]
rollkit start \
--rollkit.aggregator \
--rollkit.da_address http://localhost:7980 \
--rollkit.sequencer_address localhost:50051 \
--rollkit.sequencer_rollup_id wordle
```

:::

You should see the following log messages indicating that your chain is connected to the local sequencer:

```sh
I[2024-11-15|15:22:33.636] sequencer already running module=main address=localhost:50051
I[2024-11-15|15:22:33.636] make sure your rollupID matches your sequencer module=main rollupID=my-rollup
```

Then after a few blocks you should see this message confirming that your sequencer is successfully submitting batches to the DA layer:

```sh
I[2024-11-15|16:04:07.698] successfully submitted Rollkit headers to DA layer module=BlockManager gasPrice=-1 daHeight=1 headerCount=14
```

## Summary {#summary}

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.
File renamed without changes.
66 changes: 66 additions & 0 deletions tutorials/sequencing/local.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
# Local Sequencer

<!-- markdownlint-disable MD033 -->
<script setup>
import constants from '../../.vitepress/constants/constants.js'
</script>

## Introduction {#introduction}

This tutorial serves as a comprehensive guide for using the [local-sequencer](https://github.com/rollkit/go-sequencing) with your chain.

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.

## Setting Up a Local Local Sequencer

To set up a local sequencer on your machine, run the following script to install and start the local sequencer:

::: code-group

```bash-vue [Quick Start]
curl -sSL https://rollkit.dev/install-local-sequencer.sh | bash -s {{constants.goSequencingLatestTag}} my-rollup
```

```bash-vue [Build a Chain]
curl -sSL https://rollkit.dev/install-local-sequencer.sh | bash -s {{constants.goSequencingLatestTag}} wordle
```

:::

This script will build and run the sequencer, which will then listen on port `50051` with the `rollup-id` of your chain.

## Configuring your chain to connect to the local sequencer

To connect your chain to the local sequencer, you need to pass the `--rollkit.sequencer_address` flag with the centralized sequencer address and the `--rollkit.sequencer_rollup_id` to ensure your rollup id matches what the sequencer is expecting.

## Run your chain

Start your chain with the following command, ensuring to include the sequencer flag:

::: code-group

```sh [Quick Start]
rollkit start \
--rollkit.sequencer_address localhost:50051 \
--rollkit.sequencer_rollup_id my-rollup
```

```sh [Wordle Chain]
rollkit start \
--rollkit.aggregator \
--rollkit.sequencer_address localhost:50051 \
--rollkit.sequencer_rollup_id wordle
```

:::

You should see the following log messages indicating that your chain is connected to the local sequencer:

```sh
I[2024-11-15|15:22:33.636] sequencer already running module=main address=localhost:50051
I[2024-11-15|15:22:33.636] make sure your rollupID matches your sequencer module=main rollupID=my-rollup
```

## Summary

By following these steps, you will have successfully set up and connected your chain to the local sequencer. You can now start submitting transactions to your chain.
27 changes: 21 additions & 6 deletions tutorials/sequencing.md → tutorials/sequencing/overview.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
# Sequencing

The next step after choosing your DA layer is to choose your sequencing scheme.

## Rollkit prior to Sequencing
Rollkit's aggregator node was responsible for selecting and ordering transactions for including in the rollup blocks. The Rollkit aggregator used to follow a FCFS strategy, where every transaction submitted gets included in the block in order without any censorship. Use of a different sequencing strategy or connecting to a sequencing network (e.g., Astria) was not possible. Rollkit [v0.14.0](https://github.com/rollkit/rollkit/releases/tag/v0.14.0) onwards makes it possible for rollkit to connect to a sequencing network and communicate via grpc.

### Sequencing Interface
## Sequencing Interface {#sequencing-interface}

[go-sequencing](https://github.com/rollkit/go-sequencing) defines a sequencing interface for communicating between any sequencing network and Rollkit. The key functions of the interface are defined as shown below.

Expand All @@ -20,12 +22,25 @@ It mainly consists of:
* `GetNextBatch` returns the next batch of transactions along with a deterministic timestamp
* `VerifyBatch` validates the sequenced batch

### Sequencing Implementations
## Mock Sequencer {#mock-sequencer}

You might have noticed that we did not define a specific sequencer during the [quick start](../quick-start.md) or [build a chain](../wordle.md) tutorials. This is because we used a mock sequencer that is built into Rollkit.

If you revisit the logs from those tutorials, you will see one of the first lines being:

```shell
I[2024-11-15|14:54:19.843] Starting mock sequencer module=main address=localhost:50051 rollupID=test-rollup-a736683c
```

The mock sequencer is a simple in-memory sequencer that is great for testing and development. It is not suitable for production use.

## Sequencing Implementations {#sequencing-implementations}

An implementation of the sequencing interface mainly acts as a middleware that connects Rollkit rollup and the sequencing layer. It implements the sequencing interface functions described above. For example, [centralized-sequencer](https://github.com/rollkit/centralized-sequencer) is the refactored functionality from the Rollkit prior to `v0.14.0`. The centralized sequencer is the middleware run by the aggregator node of the Rollkit rollup. The aggregator node relays rollup transactions to centralized sequencer which then submits them to the DA network (such as Celestia). The header producer node then retrieves (via `GetNextBatch`) the batched transaction from the centralized sequencer to execute the transactions and produce the updated rollup state. Similarly, there are other sequencing middlewares which can be built for various sequencing strategies or even for connecting to different third-party sequencing networks.

The sequencing implementations that are currently work in progress:
* [centralized-sequencer](https://github.com/rollkit/centralized-sequencer)
* [based-sequencer](https://github.com/rollkit/based-sequencer)
* [forced-inclusion-sequencer]()
* [astria-sequencer](https://github.com/rollkit/astria-sequencer)
* [local-sequencer](local)
* [centralized-sequencer](centralized)
* [based-sequencer](based)
* [forced-inclusion-sequencer](forced-inclusion)
* [astria-sequencer](astria)

0 comments on commit 8c23cbc

Please sign in to comment.