diff --git a/.vitepress/config.ts b/.vitepress/config.ts index 3e2c1c49352..6b01ead2cbd 100644 --- a/.vitepress/config.ts +++ b/.vitepress/config.ts @@ -585,11 +585,7 @@ function sidebarHome() { link: "/developers/gm-portal-bubs", }, { - text: "Deploy an OP Stack devnet", - link: "/developers/optimism-devnet", - }, - { - text: "Deploy an OP Stack devnet on Celestia", + text: "Run an OP Stack devnet posting Celestia", link: "/developers/optimism", }, { @@ -601,7 +597,7 @@ function sidebarHome() { link: "https://thirdweb.com/bubs-testnet", }, { - text: "Rollups-as-a-Service", + text: "Rollups as a Service", collapsed: true, items: [ { diff --git a/developers/blobstream-proof-queries.md b/developers/blobstream-proof-queries.md index d54c50c9845..1cc0819f7a2 100644 --- a/developers/blobstream-proof-queries.md +++ b/developers/blobstream-proof-queries.md @@ -1,5 +1,8 @@ --- description: Learn how to query the inclusion proofs used in Blobstream +next: + text: "Requesting data commitment ranges" + link: "/developers/requesting-data-commitment-ranges" --- # Blobstream proofs queries diff --git a/developers/blobstream-rollups.md b/developers/blobstream-rollups.md index 8f61ecc791a..c790b6c7351 100644 --- a/developers/blobstream-rollups.md +++ b/developers/blobstream-rollups.md @@ -1,5 +1,11 @@ --- description: Learn how to build rollups that use Blobstream. +prev: + text: "Ethereum fallback mechanism" + link: "/developers/ethereum-fallback" +next: + text: "Submitting data blobs to Celestia" + link: "/developers/submit-data" --- # Introduction to Blobstream rollups diff --git a/developers/blobstream-x-deploy.md b/developers/blobstream-x-deploy.md index fdc964fd655..68b8225d8ef 100644 --- a/developers/blobstream-x-deploy.md +++ b/developers/blobstream-x-deploy.md @@ -1,3 +1,9 @@ +--- +next: + text: "Celestia-node key" + link: "/developers/celestia-node-key" +--- + # New Blobstream X deployments If you want to deploy Blobstream X to a new chain, where a Gateway diff --git a/developers/blobstream-x-requesting-data-commitment-ranges.md b/developers/blobstream-x-requesting-data-commitment-ranges.md index b14d1ec3f7b..6981dae3a08 100644 --- a/developers/blobstream-x-requesting-data-commitment-ranges.md +++ b/developers/blobstream-x-requesting-data-commitment-ranges.md @@ -1,3 +1,9 @@ +--- +prev: + text: "Querying the Blobstream proofs" + link: "/developers/blobstream-proof-queries" +--- + # Requesting data commitment ranges By default, the Blobstream X deployments on Ethereum will be diff --git a/developers/bubs-testnet.md b/developers/bubs-testnet.md index 6a9c330b1fe..7634d3e5de4 100644 --- a/developers/bubs-testnet.md +++ b/developers/bubs-testnet.md @@ -1,14 +1,17 @@ --- description: The first testnet built with OP Stack and Celestia. +next: + text: "Deploy a smart contract on Bubs testnet" + link: "/developers/deploy-on-bubs" --- # Bubs testnet ![Bubs testnet](/img/Celestia_Bubs_Testnet.jpg) -[Bubs Testnet](https://bubs-sepolia.hub.caldera.xyz/) is a fresh offering from -[Caldera](https://caldera.xyz) with support from Celestia Labs, -built with OP Stack and Celestia, and is dedicated to providing developers with +[Bubs Testnet](https://bubs-sepolia.hub.caldera.xyz/) is a the first +OP Stack testnet with Celestia underneath hosted by +[Caldera](https://caldera.xyz) with support from Celestia Labs. Bubs is dedicated to providing developers with an EVM-compatible execution layer to deploy their EVM applications on. ## Built with the OP Stack and Celestia @@ -19,27 +22,12 @@ layer. This integration can be found in the [@celestiaorg/optimism repository](https://github.com/celestiaorg/optimism). The testnet is hosted by [Caldera](https://caldera.xyz), who makes it easy to launch rollups with no code required. - -In this setup, data handling is accomplished in two ways. Firstly, data is -written to the DA layer, in this case, Celestia -(on the [Mocha testnet](../nodes/mocha-testnet.md)). Then, the data -commitment is written to the `op-batcher`. When reading, the `op-node` -retrieves the data back from the DA layer by first reading the data commitment -from the `op-batcher`, then reading the data from the DA layer using the data -commitment. Hence, while previously `op-node` was reading from `calldata` on -Ethereum, it now reads data from Celestia. +Bubs' data is posted to Celestia +on the [Mocha testnet](../nodes/mocha-testnet.md). [View the namespace for Bubs on Celestia's Mocha testnet](https://mocha-4.celenium.io/namespace/000000000000000000000000000000000000ca1de12ad45362e77e87). -The tools involved in the data handling process include `op-batcher`, -which batches up rollup blocks and posts them to Ethereum, `op-geth` -that handles execution, and `op-proposer` responsible for state commitment -submission. - -By using Celestia as a DA layer, existing L2s can switch from posting their -data as `calldata` on Ethereum to posting to Celestia. The commitment to the -block is posted on Celestia, which is purpose-built for data availability. -This is more scalable than the traditional method of posting this data as -`calldata` on monolithic chains. +[Learn more about the setup of the integration in +the introduction](./intro-to-op-stack.md#about-the-integration). ## Building on Bubs @@ -102,8 +90,4 @@ To see the status and uptime information for Bubs, Now that you have a better understanding of the Bubs Testnet and its integration of OP Stack and Celestia, you can start exploring its -capabilities: - -- [Deploy a smart contract on Bubs testnet](./deploy-on-bubs.md) -- [Deploy a GM Portal dapp on Bubs testnet](./gm-portal-bubs.md) - +capabilities. \ No newline at end of file diff --git a/developers/build-whatever.md b/developers/build-whatever.md index 4dff4e7cec1..72649c3794f 100644 --- a/developers/build-whatever.md +++ b/developers/build-whatever.md @@ -32,7 +32,7 @@ Here are a few options that are currently available for developers. -### Rollups-as-a-Service +### Rollups as a Service Deploy your rollup with a RaaS provider. diff --git a/developers/celestia-node-key.md b/developers/celestia-node-key.md index f6b2fc9e890..027e8f5429a 100644 --- a/developers/celestia-node-key.md +++ b/developers/celestia-node-key.md @@ -1,8 +1,8 @@ --- description: Use the cel-key utility to generate a wallet on celestia-node. prev: - text: "Rollkit" - link: "/developers/rollkit" + text: "New Blobstream X deployments" + link: "/developers/blobstream-x-deploy" --- # Create a wallet with celestia-node diff --git a/developers/deploy-on-bubs.md b/developers/deploy-on-bubs.md index 7e5af4f47ce..e275eb6dbca 100644 --- a/developers/deploy-on-bubs.md +++ b/developers/deploy-on-bubs.md @@ -1,3 +1,9 @@ +--- +prev: + text: "Bubs testnet" + link: "/developers/bubs-testnet" +--- + # Deploy a smart contract on Bubs testnet In this tutorial, we will deploy a smart contract to the diff --git a/developers/ethereum-fallback.md b/developers/ethereum-fallback.md index 853e787722a..3dd443ca2a2 100644 --- a/developers/ethereum-fallback.md +++ b/developers/ethereum-fallback.md @@ -1,5 +1,11 @@ --- description: The DA fallback mechanism to Ethereum for rollups. +next: + text: "Blobstream rollups" + link: "/developers/blobstream-rollups" +prev: + text: "Run an OP Stack devnet posting Celestia" + link: "/developers/optimism" --- # Ethereum fallback diff --git a/developers/intro-to-op-stack.md b/developers/intro-to-op-stack.md index 88ac9274477..3c2a6630d07 100644 --- a/developers/intro-to-op-stack.md +++ b/developers/intro-to-op-stack.md @@ -7,43 +7,69 @@ description: Learn about the integration of OP Stack with Celestia. [Optimism](https://optimism.io) is a low-cost and lightning-fast Ethereum L2 blockchain, built with [the OP Stack](https://stack.optimism.io/). -[Celestia](https://celestia.org) is a modular consensus and data network, +[Celestia](https://celestia.org) is a modular consensus and data availability (DA) network, built to enable anyone to easily deploy their own blockchain with minimal overhead. -## About the integration - -_Discover how to integrate existing blockchain frameworks -like the OP Stack with Celestia in this category._ - -:::tip -Tested on a machine with 8GB RAM, 160 GB SSD, -Ubuntu 22.10, and a 4 core AMD CPU. -::: +Together, they allow developers to create rollups that +post data to Celestia and settle on Ethereum. -This is a **beta integration** and we are working on resolving -[open issues](https://github.com/celestiaorg/optimism/issues). +## About the integration [Optimism](https://www.optimism.io/) uses Ethereum as -a data availability (DA) layer. Currently, settlement and DA for +a DA layer. Currently, settlement and DA for Optimism are on Ethereum, both onchain. `op-batcher` batches up rollup blocks and posts to Ethereum. -### Table of contents of the category +The integration of OP Stack with Celestia underneath for DA +allows rollup operators to reduce overhead that is associated with posting +data as `calldata` on Ethereum. Instead, `op-batcher` batches up +rollup blocks and posts them to Celestia's DA network. -- [Bubs testnet](./bubs-testnet.md) -- [Deploy a smart contract on Bubs testnet](./deploy-on-bubs.md) -- [Deploy a GM Portal dapp on Bubs testnet](./gm-portal-bubs.md) -- [Deploy an OP Stack devnet](./optimism-devnet.md) -- [Deploy an OP Stack devnet on Celestia](./optimism.md) +Data is managed in two ways. First, data is written +to the data availability (DA) layer i.e. in this case Celestia, then the +data commitment is written to the `op-batcher`. When reading `op-node` +simply reads the data back from the DA layer by reading the +data commitment from the `op-batcher` first, then reading the +data from the DA layer using the data commitment. While +previously `op-node` was reading from `calldata` on Ethereum, it now reads data from Celestia. + +There are a few tools involved in the data handling process. `op-batcher` +batches up rollup blocks and posts them to Ethereum. `op-geth` handles +execution, while `op-proposer` is responsible for state commitment +submission. -## Celestia and OP Stack repository +By using Celestia as a DA layer, existing L2s can switch from posting +their data as `calldata` on Ethereum, to posting to Celestia. +The commitment to the block is posted on Celestia, which is +purpose-built for data availability. This is a more scalable than +the traditional method of posting this data as `calldata` on monolithic chains. + +### GitHub repository Find the [repository for this integration](https://github.com/celestiaorg/optimism/) at `https://github.com/celestiaorg/optimism`. -### What are Optimism and the OP Stack? +:::warning +This is a **beta integration** and we are working on resolving +[open issues](https://github.com/celestiaorg/optimism/issues). +::: + +## Category contents + +This category will guide you through interacting with existing OP Stack rollups +with Celestia underneath, then how to start your own devnet +with a modified version of `optimism-bedrock` that uses Celestia as a +DA layer. + +- [Bubs testnet](./bubs-testnet.md): learn about +the first testnet made with OP Stack with Celestia underneath +- [Deploy a smart contract on Bubs testnet](./deploy-on-bubs.md) +- [Deploy a GM Portal dapp on Bubs testnet](./gm-portal-bubs.md) +- [Run an OP Stack devnet posting Celestia](./optimism.md) + + ## Next steps diff --git a/developers/optimism-devnet.md b/developers/optimism-devnet.md index 66541f1776e..1baa0ffeaaf 100644 --- a/developers/optimism-devnet.md +++ b/developers/optimism-devnet.md @@ -1,351 +1,3 @@ ---- -description: Start your own devnet with a modified version of optimism-bedrock. ---- +# Optimism devnet -# Deploy an OP Stack devnet - -This guide will show you how to run your own OP Stack devnet. - -## Dependency setup - -### Environment setup and Golang installation - -First, [install dependencies for Celestia software](../nodes/environment.md) -and for [OP Stack](https://community.optimism.io/docs/developers/build/dev-node/). - -### Clone repository - -Next, clone the repo: - -```bash -cd $HOME -git clone https://github.com/celestiaorg/optimism -cd optimism -``` - -Check out to the version for either the stable version or upstream version: - -::: code-group - -```bash-vue [v1.2.0-OP_v1.7.0-CN_v0.12.4] -git checkout tags/v1.2.0-OP_v1.7.0-CN_v0.12.4 -git submodule update --init --recursive -``` - -```bash-vue [celestia-develop] -git checkout celestia-develop -git submodule update --init --recursive -``` - -::: - -## Build devnet - -Build TypeScript definitions for TS dependencies: - -```bash -cd $HOME -cd optimism -make -``` - -Set environment variables to start network: - -```bash -export SEQUENCER_BATCH_INBOX_ADDRESS=0xff00000000000000000000000000000000000000 -export L2OO_ADDRESS=0x70997970C51812dc3A010C7d01b50e0d17dc79C8 -``` - -### Start devnet - -Start the network by running: - -```bash -make devnet-up -``` - -This starts up the layer 1 (ETH), layer 2 (`op-geth`), data availability -layer (Celestia), the sequencer (`op-node`), batch submitter (`op-batcher`), -state commitment service (`op-proposer`). - -### View the logs of the devnet - -If you'd like to view the logs of the devnet, run the following command -from the root of the Optimism directory: - -```bash -make devnet-logs -``` - -::: details Optional: Docker tips - -### Stop devnet - -If you'd like to start the network over, use the following command -to safely shut down all of the containers: - -```bash -make devnet-down -``` - -Then clean out the old config: - -```bash -make devnet-clean -``` - -### Viewing containers - -To view the containers running, send: - -```bash -docker ps -``` - -Find the container ID of the `ops-bedrock_op-batcher_1` -and run the following to follow the logs: - -```bash -docker logs -f -``` - -In a new terminal, find the container ID of the -`ghcr.io/celestiaorg/local-celestia-devnet:main` -and run the following to follow the logs: - -```bash -docker logs -f -``` - -You can do the same for other containers as you -explore the stack. - -::: - -## Find a transaction - -Now, we'll check for a recent transaction on the L1 with: - -```bash -cast block latest --rpc-url localhost:8545 -``` - -Output of a block that contains a transaction will look like this: - -```console -baseFeePerGas 7 -difficulty 2 -extraData 0xd883010d04846765746888676f312e32312e33856c696e7578000000000000006b3afa42dce1f87f1f07a1ef569c4d43e41738ef93c865098bfa1458645f384e2e4498bcfe4ad9353ff1913a2e16162f496fafe5b0939a6c78fb5b503248d6da01 -gasLimit 30000000 -gasUsed 21568 -hash 0x1cb54d2369752ef73511c202ff9cdfd0eadf3a77b7aef0092bea63f2b5d57659 -logsBloom 0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 -miner 0x0000000000000000000000000000000000000000 -mixHash 0x0000000000000000000000000000000000000000000000000000000000000000 -nonce 0x0000000000000000 -number 1141 -parentHash 0x664bf4bb4a57dd5768a0a98991d77c58fb7a4e164c2581c79fb33ce9c3d4c250 -receiptsRoot 0xaf8ff6af1180c8be9e4e8f3a5f882b3b227233f4abbefa479836d3721682a389 -sealFields [] -sha3Uncles 0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347 -size 767 -stateRoot 0xd4b998a35d20d98ed3488221f0c161a0a9572d3de66399482553c8e3d2fae751 -timestamp 1699638350 -withdrawalsRoot -totalDifficulty 2283 -transactions: [ - 0x79a0a7a1b4936aafe7a37dbfb07a6a9e55c145a4ed6fd54f962649b4b7db8de7 -] -``` - -Copy the transaction hash from `transactions: ` and -set it as a variable: - -```bash -export TX_HASH=0x79a0a7a1b4936aafe7a37dbfb07a6a9e55c145a4ed6fd54f962649b4b7db8de7 -``` - -## Read the transaction call data - -Now read the transaction call data on the L1: - -```bash -cast tx $TX_HASH --rpc-url localhost:8545 -``` - -The output will look similar to below: - -```console -blockHash 0x9f4dfae061b5ddd86f95a81be5daa0d7fe32e7f7f770f86dc375e0007d249bd2 -blockNumber 24 -from 0x3C44CdDdB6a900fa2b585dd299e03d12FA4293BC -gas 21572 -gasPrice 1040676758 -hash 0xadd3a5dc0b8c605aeac891098e87cbaff43bb642896ebbf74f964c0690e46df2 -input 0xce3500000000000000769074a923011bdda721eacc34c8a77c69c10f2b6c8e659f987e82f217a5340f -nonce 4 -r 0xaf5c1505c7dfcebca94d9a6a8c0caf99b6c87a8ed6d6c0b3161c9026f270a84f -s 0x383ed2debf9f9055920cd7340418dda7e2bca6b989eb6992d83d123d4e322f2a -to 0xFf00000000000000000000000000000000000901 -transactionIndex 0 -v 0 -value 0 -yParity 0 -``` - -::: tip -You are looking for a batcher transaction to the address -`0xFf00000000000000000000000000000000000901`. -::: - -First, remove the prefix `0xce`. -Now, set the `input` as the `INPUT` variable and encode it as -base64: - -```bash -export INPUT=ce3500000000000000769074a923011bdda721eacc34c8a77c69c10f2b6c8e659f987e82f217a5340f -export ENCODED_INPUT=$(echo "$INPUT" | xxd -r -p | base64) -``` - -:::tip -Remember to remove the `0xce` prefix! -::: - -## Find the data on Celestia - -Clone the `go-da` repository: - -```bash -cd $HOME -git clone https://github.com/rollkit/go-da.git -cd go-da/proto/da -``` - -Now, from `go-da/proto/da` run: - - - -```bash -grpcurl -proto da.proto -plaintext -d "{\"ids\": [{\"value\": \"$ENCODED_INPUT\"}]}" 127.0.0.1:26650 da.DAService.Get -``` - -Your result will look similar to the below! - -```console -{ - "blobs": [ - { - "value": "AKUumhJ8FnuyVrBs38FDKEIAAAAAAZB42trhw/DDc4GFAlv4klkv5Zh4E16mmO5fpNOS1f5wzpds8YK3S0Rvs4ULLJj13euw+Ovdv6Q23zuV1ShROEvk5aptIT7bGmZunvc1OiKwJTXVbN0BiGm6k2zNWq78cNsT2ez3+nzQq84Ds28or/aKz/o1w4NpV7w4caZtgJomX71w96m63+xzYnarXLu7WWvRrwbeb6cW8R93YHXt1r4+TXCBGVe76obzf5JLTNu22gksD2cL+83D8DGjX0FKcwZD0VofkGmboKY1uTddu8704s2MwgNNe09s1bzw+n9Fq6fKFw7pvwJL200eCS0oFJ3HfPAEywnlgyyGQc89dh+98GD5TrdU4aNql9afmW+sDzJtC9S0fzLWYROOS0bvK3W7EvNpmWXe5qrdzKlBmv1LZi4ofrrxLHGmbYOaJhHsEn+B81lGUh33HDet8K9nVKKSF2+W3Xul6uPSxydPBwsv2GHskR+yfUlDbvyl1ROTvtS1zXlpEPz0M1e/RIIt57fVj0Gm7TgACAAA//+Qdel2AQ==" - } - ] -} -``` - -## Ethereum fallback mechanism in OP Stack - -The [Ethereum fallback mechanism](ethereum-fallback.md) allows rollups to -"fall back" to Ethereum or another EVM chain in the case of downtime or -errors submitting data to Celestia. - -### Implementation of fallback - -The Ethereum fallback mechanism is implemented in the -[celestiaorg/optimism](https://github.com/celestiaorg/optimism/tree/release-v1.1.0) -v1.1.0 release. - -The `op-batcher/batcher/driver.go` and -`op-node/rollup/derive/calldata_source.go` files are part of the Ethereum -fallback mechanism in the `op-batcher` and `op-node` respectively. - -In [`driver.go`, the `calldataTxCandidate` function is responsible for the write path](https://github.com/celestiaorg/optimism/blob/release-v1.1.0/op-batcher/batcher/driver.go#L405-L419) -of the Ethereum fallback. This function creates and submits a transaction to the -batch inbox address with the given data. It uses the underlying `txmgr` to -handle transaction sending and gas price management. - -If the transaction data can be published as a blob to Celestia, -it replaces the calldata with a blob identifier and sends the -transaction with this data. If it cannot be published to Celestia, -it falls back to Ethereum without any change to the transaction. - -The blob identifier starts with the special prefix `0xce`, which was chosen as a -mnemonic for Celestia, and indicates that the remaining data has to -interpreted as a little-endian encoded Block Height (8 bytes) and -Blob Commitment (32 bytes). The combination of these can later be used to -retrieve the original calldata from Celestia. - - - -| Prefix | 8 bytes | 32 bytes | -| ------ | ------------ | --------------- | -| 0xce | Block Height | Blob Commitment | - - - -```go -func (l *BatchSubmitter) sendTransaction( - txdata txData, - queue *txmgr.Queue[txData], - receiptsCh chan txmgr.TxReceipt[txData], -) { - // ... -} -``` - -In `calldata_source.go`, -[the `DataFromEVMTransactions` function defines the read path](https://github.com/celestiaorg/optimism/blob/release-v1.1.0/op-node/rollup/derive/calldata_source.go#L102-L139) -of the Ethereum fallback. This function filters all of the transactions -and returns the calldata from transactions that are sent to the batch -inbox address from the batch sender address. - -If the calldata matches the version prefix `0xce`, it is decoded as a -blob identifier, the original calldata is retrieved from Celestia -and returned for derivation. If the calldata does not match the prefix, -the entire calldata is returned for derivation. - -```go -func DataFromEVMTransactions( - config *rollup.Config, - batcherAddr common.Address, - txs types.Transactions, - log log.Logger -) ([]eth.Data, error) { - // ... -} -``` - -These two functions work together to ensure that the Ethereum -fallback mechanism operates correctly, allowing the rollup -to continue functioning even during periods of downtime on -Celestia. - -### Testing the fallback - -Testing out the Ethereum fallback mechanism can be done -with the `go-da` tool. Triggering a simultaneous blob transaction will -cause the `op-batcher` blob transaction to fail, with an `incorrect account -sequence` error, which triggers a fallback to Ethereum. - -To trigger the transaction, send this command from the same `go/proto/da` directory: - - - -```bash -grpcurl -proto da.proto -plaintext -d '{"blobs": [{"value": "SGVsbG8gd28ybGQh"}]}' 127.0.0.1:26650 da.DAService.Submit -``` - - - -Alternatively, you can shut off the `local-celestia-devnet` and see that -the OP Stack devnet logs show that the rollup has fallen back to the L1, -in this case Ethereum, for posting data. - -## Span batches - -Span batches can be enabled by setting `OP_BATCHER_BATCH_TYPE: 1` -in your `docker-compose.yml` file. - -Note that this requires the Delta activation time to be configured. -For your devnet, you should set `"l2GenesisDeltaTimeOffset": "0x0",` -in `devnetL1-template.json`. This will enable span batches and can be tested -by grepping `docker compose logs -f | grep batch_type` which should include -`batch_type=SpanBatch` and `batch_type=1`. +This page has moved to [developers/optimism](./optimism.md). diff --git a/developers/optimism.md b/developers/optimism.md index 84f588df203..b736fe3d9b3 100644 --- a/developers/optimism.md +++ b/developers/optimism.md @@ -1,40 +1,72 @@ --- description: Start your own devnet with a modified version of optimism-bedrock. next: - text: "Rollkit" - link: "/developers/rollkit" + text: "Ethereum fallback mechanism" + link: "/developers/ethereum-fallback" --- -# Deploy an OP Stack devnet to Celestia +# Run an OP Stack devnet posting Celestia -In order to deploy a devnet to Celestia, you will need to have a modified -version of `optimism-bedrock`. -Refer to the -[steps to install dependencies and the modified version of OP Stack](./optimism-devnet.md) -for your environment setup. +This guide will show you how to run your own OP Stack devnet locally that posts to a Celestia network. + +If you'd like to use a Rollups as a Service (RaaS) provider, you can visit the RaaS category in the menu. + +## Dependency setup + +### Environment setup + +First, [install dependencies for Celestia software](../nodes/environment.md) +and for [OP Stack](https://community.optimism.io/docs/developers/build/dev-node/). + +### Clone repository + +Next, clone the repo: + +```bash +cd $HOME +git clone https://github.com/celestiaorg/optimism +cd optimism +``` + +Check out to the version for either the +[stable version](https://github.com/celestiaorg/optimism/releases) or +[upstream version](https://github.com/celestiaorg/optimism/tree/celestia-develop): -## Pick your deployment type +::: code-group -Using Celestia and OP stack, you have the option to either -run a light node of your own or a `local-celestia-devnet`, -both of which will give you a local devnet to test things out with. +```bash-vue [v1.3.0-OP_op-node/v1.7.5-CN_v0.13.2] +git checkout tags/v1.3.0-OP_op-node/v1.7.5-CN_v0.13.2 +git submodule update --init --recursive +``` -### Using a local devnet +```bash-vue [celestia-develop] +git checkout celestia-develop +git submodule update --init --recursive +``` -If you'd like to use the `local-celestia-devnet`, you're in luck! -This is the default for the OP Stack + Celestia repository. Head -to the [previous page](./optimism-devnet.md) to get started. +::: -### Using a light node +## Build devnet -This is a **beta integration** and we are working on resolving -[open issues](https://github.com/celestiaorg/optimism/issues/). +Build TypeScript definitions for TS dependencies: + +```bash +make +``` + +Set environment variables to start network: + +```bash +export SEQUENCER_BATCH_INBOX_ADDRESS=0xff00000000000000000000000000000000000000 +export L2OO_ADDRESS=0x70997970C51812dc3A010C7d01b50e0d17dc79C8 +``` + +## Setting up your light node In order to allow your light node to post and retrieve data without errors, you will need to change `UseShareExchange` @@ -59,16 +91,13 @@ $HOME/.celestia-light-{{constants.arabicaChainId}}/config.toml If you choose to use your own node store, the light node must be **fully synced** and **funded** for you to be able to submit and retrieve `PayForBlobs` to a Celestia network. - -If it is not synced, you will run into -[errors similar to this](https://github.com/celestiaorg/celestia-node/issues/2151/). - Visit the [Arabica](../nodes/arabica-devnet.md) or [Mocha](../nodes/mocha-testnet.md) pages to -visit their faucets. +visit their faucets. If it is not synced, you will run into +[errors similar to this](https://github.com/celestiaorg/celestia-node/issues/2151/). In order to mount existing data, you must have a node store that is -in this directory: +in the default directory: ::: code-group @@ -86,76 +115,62 @@ $HOME/.celestia-light-{{constants.arabicaChainId}} ::: -This is the default location of the node store -when you initialize and run a new Celestia node. - By default, the node will run with the account named `my_celes_key`. - If you have your own setup you'd like to try, you can always edit `optimism/ops-bedrock/docker-compose.yml` to work with your setup. -### Using a RaaS provider - -If you'd like to use a Rollups as a Service (RaaS) provider, you can do so -by going to the RaaS category in the menu. - -## Build the devnet - -Build TypeScript definitions for TS dependencies: - -```bash -cd $HOME -cd optimism -make -``` - -Set environment variables to start network: - -```bash -export SEQUENCER_BATCH_INBOX_ADDRESS=0xff00000000000000000000000000000000000000 -export L2OO_ADDRESS=0x70997970C51812dc3A010C7d01b50e0d17dc79C8 -``` - -## Start the devnet +### Docker changes -First, make sure your light node is synced and funded. It must -not be running for this example to work. - -This example is for Mainnet Beta. -You can modify the `da:` section of your `$HOME/optimism/ops-bedrock/docker-compose.yml` -for your specific use, similarly to the example below: - -This setup will use `celestia-da`, which is `celestia-node` with -a DA server on port 26650. +You will need to modify the `da:` section of your `$HOME/optimism/ops-bedrock/docker-compose.yml` +for your specific use, similarly to the example below. +This setup will use `celestia-node` with +a DA server on port 26658. For the `P2P_NETWORK` variable, you'll need to supply the network of choice, either `celestia`, `mocha`, or `arabica`. Using `celestia`, the volume path will be just `.celestia-light` instead of `.celestia-light-`. You will also need -to provide a core.ip RPC URL for the network you are using. +to provide a `--core.ip ` for the network you are using. -```yaml +::: code-group + +```yaml-vue [Mainnet Beta] da: - image: ghcr.io/rollkit/local-celestia-devnet:v0.12.1 // [!code --] - image: ghcr.io/rollkit/celestia-da:v0.12.9 // [!code ++] - command: > // [!code ++] - celestia-da light start // [!code ++] - --p2p.network= // [!code ++] - --da.grpc.namespace=000008e5f679bf7116cb // [!code ++] - --da.grpc.listen=0.0.0.0:26650 // [!code ++] - --core.ip // [!code ++] - --gateway // [!code ++] + image: ghcr.io/rollkit/local-celestia-devnet:v0.13.1 // [!code --] + image: ghcr.io/celestiaorg/celestia-node:v0.13.2 // [!code ++] + command: celestia light start --p2p.network celestia --core.ip rpc.celestia.pops.one --gateway// [!code ++] + ports: + - "26658:26658" + - "26659:26659" // [!code ++] + volumes: // [!code ++] + - $HOME/.celestia-light/:/home/celestia/.celestia-light/ // [!code ++] environment: // [!code ++] - - NODE_TYPE=light // [!code ++] - - P2P_NETWORK= // [!code ++] + NODE_TYPE: "light" // [!code ++] + P2P_NETWORK: "celestia" // [!code ++] + user: root // [!code ++] + healthcheck: + test: ["CMD", "curl", "-f", "http://localhost:26659/header/1"] + interval: 10s + timeout: 5s + retries: 5 + start_period: 30s +``` + +```yaml-vue [Mocha testnet] +da: + image: ghcr.io/celestiaorg/celestia-node:v0.13.2 // [!code ++] + command: celestia light start --p2p.network mocha --core.ip consensus-full-mocha-4.celestia-mocha.com --gateway// [!code ++] ports: - - "26650:26650" - "26658:26658" - - "26659:26659" + - "26659:26659" // [!code ++] volumes: // [!code ++] - - $HOME/.celestia-light-/:/home/celestia/.celestia-light-/ // [!code ++] + - $HOME/.celestia-light-{{constants.mochaChainId}}/:/home/celestia/.celestia-light-{{constants.mochaChainId}}/ // [!code ++] + environment: // [!code ++] + NODE_TYPE: "light" // [!code ++] + P2P_NETWORK: "mocha" // [!code ++] + user: root // [!code ++] healthcheck: test: ["CMD", "curl", "-f", "http://localhost:26659/header/1"] interval: 10s @@ -164,13 +179,63 @@ da: start_period: 30s ``` -Now start the devnet: +```yaml-vue [Arabica devnet] +da: + image: ghcr.io/rollkit/local-celestia-devnet:v0.13.1 // [!code --] + image: ghcr.io/celestiaorg/celestia-node:v0.13.2 // [!code ++] + command: celestia light start --p2p.network arabica --core.ip validator-1.celestia-arabica-11.com --gateway// [!code ++] + ports: + - "26658:26658" + - "26659:26659" // [!code ++] + volumes: // [!code ++] + - $HOME/.celestia-light-{{constants.arabicaChainId}}/:/home/celestia/.celestia-light-{{constants.arabicaChainId}}/ // [!code ++] + environment: // [!code ++] + NODE_TYPE: "light" // [!code ++] + P2P_NETWORK: "arabica" // [!code ++] + user: root // [!code ++] + healthcheck: + test: ["CMD", "curl", "-f", "http://localhost:26659/header/1"] + interval: 10s + timeout: 5s + retries: 5 + start_period: 30s +``` + +::: + +### Set your Celestia node auth token + +::: code-group + +```bash-vue [Mainnet Beta] +export CELESTIA_NODE_AUTH_TOKEN=$(celestia light auth admin) +``` + +```bash-vue [Mocha testnet] +export CELESTIA_NODE_AUTH_TOKEN=$(celestia light auth admin --p2p.network mocha) +``` + +```bash-vue [Arabica devnet] +export CELESTIA_NODE_AUTH_TOKEN=$(celestia light auth admin --p2p.network arabica) +``` + +::: + +Now you're ready to start your devnet. + +## Start devnet + +Start the network by running: ```bash make devnet-up ``` -## View the logs of the devnet +This starts up the layer 1 (ETH), layer 2 (`op-geth`), data availability +layer (Celestia), the sequencer (`op-node`), batch submitter (`op-batcher`), +state commitment service (`op-proposer`). + +### View the logs of the devnet If you'd like to view the logs of the devnet, run the following command from the root of the Optimism directory: @@ -179,17 +244,16 @@ from the root of the Optimism directory: make devnet-logs ``` -## Stop the devnet +### Optional: Stop devnet -To safely stop the devnet, run the following command: +If you'd like to start the network over, use the following command +to safely shut down all of the containers: ```bash make devnet-down ``` -## Clean the devnet - -To remove all data from the devnet, run the following command: +Then clean out the old config: ```bash make devnet-clean @@ -199,3 +263,221 @@ make devnet-clean If you'd like to deploy to an EVM L1 or L2, reference the [OP stack deployment guide](https://community.optimism.io/docs/developers/bedrock/node-operator-guide/). + +## Find a transaction + +Now, we'll check for a recent transaction on the L1 with: + +```bash +cast block latest --rpc-url localhost:8545 +``` + +Output of a block that contains a transaction will look like this: + +```console +baseFeePerGas 7 +difficulty 2 +extraData 0xd883010d04846765746888676f312e32312e33856c696e7578000000000000006b3afa42dce1f87f1f07a1ef569c4d43e41738ef93c865098bfa1458645f384e2e4498bcfe4ad9353ff1913a2e16162f496fafe5b0939a6c78fb5b503248d6da01 +gasLimit 30000000 +gasUsed 21568 +hash 0x1cb54d2369752ef73511c202ff9cdfd0eadf3a77b7aef0092bea63f2b5d57659 +logsBloom 0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 +miner 0x0000000000000000000000000000000000000000 +mixHash 0x0000000000000000000000000000000000000000000000000000000000000000 +nonce 0x0000000000000000 +number 1141 +parentHash 0x664bf4bb4a57dd5768a0a98991d77c58fb7a4e164c2581c79fb33ce9c3d4c250 +receiptsRoot 0xaf8ff6af1180c8be9e4e8f3a5f882b3b227233f4abbefa479836d3721682a389 +sealFields [] +sha3Uncles 0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347 +size 767 +stateRoot 0xd4b998a35d20d98ed3488221f0c161a0a9572d3de66399482553c8e3d2fae751 +timestamp 1699638350 +withdrawalsRoot +totalDifficulty 2283 +transactions: [ + 0x79a0a7a1b4936aafe7a37dbfb07a6a9e55c145a4ed6fd54f962649b4b7db8de7 +] +``` + +Copy the transaction hash from `transactions: ` and +set it as a variable: + +```bash +export TX_HASH=0x79a0a7a1b4936aafe7a37dbfb07a6a9e55c145a4ed6fd54f962649b4b7db8de7 +``` + +## Read the transaction call data + +Now read the transaction call data on the L1: + +```bash +cast tx $TX_HASH --rpc-url localhost:8545 +``` + +The output will look similar to below: + +```console +blockHash 0x9f4dfae061b5ddd86f95a81be5daa0d7fe32e7f7f770f86dc375e0007d249bd2 +blockNumber 24 +from 0x3C44CdDdB6a900fa2b585dd299e03d12FA4293BC +gas 21572 +gasPrice 1040676758 +hash 0xadd3a5dc0b8c605aeac891098e87cbaff43bb642896ebbf74f964c0690e46df2 +input 0xce3500000000000000769074a923011bdda721eacc34c8a77c69c10f2b6c8e659f987e82f217a5340f +nonce 4 +r 0xaf5c1505c7dfcebca94d9a6a8c0caf99b6c87a8ed6d6c0b3161c9026f270a84f +s 0x383ed2debf9f9055920cd7340418dda7e2bca6b989eb6992d83d123d4e322f2a +to 0xFf00000000000000000000000000000000000901 +transactionIndex 0 +v 0 +value 0 +yParity 0 +``` + +::: tip +You are looking for a batcher transaction to the address +`0xFf00000000000000000000000000000000000901`. +::: + +First, remove the prefix `0xce`. +Now, set the `input` as the `INPUT` variable and encode it as +base64: + +```bash +export INPUT=3500000000000000769074a923011bdda721eacc34c8a77c69c10f2b6c8e659f987e82f217a5340f +export ENCODED_INPUT=$(echo "$INPUT" | xxd -r -p | base64) +``` + +:::tip +Remember to remove the `0xce` prefix! +::: + +## Find the data on Celestia + + + +```bash +curl -s -X POST -H "Content-Type: application/json" -H "Authorization: Bearer $CELESTIA_NODE_AUTH_TOKEN" -d '{ "id": 1, "jsonrpc": "2.0", "method": "da.Get", "params": [["$ENCODED_INPUT"], "AAAAAAAAAAAAAAAAAAAAAAAAAAECAwQFBgcICRA="]}' http://127.0.0.1:26658 +``` + +The params are `[]blobs, namespace`, base64-encoded. + +Your result will look similar to the below! + +```console +{"jsonrpc":"2.0","result":["SGVsbG8gd28ybGQh"],"id":1} +``` + +## Ethereum fallback mechanism in OP Stack + +The [Ethereum fallback mechanism](ethereum-fallback.md) allows rollups to +"fall back" to Ethereum or another EVM chain in the case of downtime or +errors submitting data to Celestia. + +### Implementation of fallback + +The Ethereum fallback mechanism is implemented in the +[celestiaorg/optimism](https://github.com/celestiaorg/optimism/tree/release-v1.1.0) +v1.1.0 release. + +The `op-batcher/batcher/driver.go` and +`op-node/rollup/derive/calldata_source.go` files are part of the Ethereum +fallback mechanism in the `op-batcher` and `op-node` respectively. + +In [`driver.go`, the `calldataTxCandidate` function is responsible for the write path](https://github.com/celestiaorg/optimism/blob/release-v1.1.0/op-batcher/batcher/driver.go#L405-L419) +of the Ethereum fallback. This function creates and submits a transaction to the +batch inbox address with the given data. It uses the underlying `txmgr` to +handle transaction sending and gas price management. + +If the transaction data can be published as a blob to Celestia, +it replaces the calldata with a blob identifier and sends the +transaction with this data. If it cannot be published to Celestia, +it falls back to Ethereum without any change to the transaction. + +The blob identifier starts with the special prefix `0xce`, which was chosen as a +mnemonic for Celestia, and indicates that the remaining data has to +interpreted as a little-endian encoded Block Height (8 bytes) and +Blob Commitment (32 bytes). The combination of these can later be used to +retrieve the original calldata from Celestia. + + + +| Prefix | 8 bytes | 32 bytes | +| ------ | ------------ | --------------- | +| 0xce | Block Height | Blob Commitment | + + + +```go +func (l *BatchSubmitter) sendTransaction( + txdata txData, + queue *txmgr.Queue[txData], + receiptsCh chan txmgr.TxReceipt[txData], +) { + // ... +} +``` + +In `calldata_source.go`, +[the `DataFromEVMTransactions` function defines the read path](https://github.com/celestiaorg/optimism/blob/release-v1.1.0/op-node/rollup/derive/calldata_source.go#L102-L139) +of the Ethereum fallback. This function filters all of the transactions +and returns the calldata from transactions that are sent to the batch +inbox address from the batch sender address. + +If the calldata matches the version prefix `0xce`, it is decoded as a +blob identifier, the original calldata is retrieved from Celestia +and returned for derivation. If the calldata does not match the prefix, +the entire calldata is returned for derivation. + +```go +func DataFromEVMTransactions( + config *rollup.Config, + batcherAddr common.Address, + txs types.Transactions, + log log.Logger +) ([]eth.Data, error) { + // ... +} +``` + +These two functions work together to ensure that the Ethereum +fallback mechanism operates correctly, allowing the rollup +to continue functioning even during periods of downtime on +Celestia. + +### Testing the fallback + +Testing out the Ethereum fallback mechanism can be done +with a curl command. Triggering a simultaneous blob transaction will +cause the `op-batcher` blob transaction to fail, with an `incorrect account +sequence` error, which triggers a fallback to Ethereum. + + + +```bash +curl -s -X POST -H "Content-Type: application/json" -H "Authorization: Bearer $CELESTIA_NODE_AUTH_TOKEN" -d '{ "id": 1, "jsonrpc": "2.0", "method": "da.Submit", "params": [["SGVsbG8gd28ybGQh"], -1, "AAAAAAAAAAAAAAAAAAAAAAAAAAECAwQFBgcICRA="]}' http://127.0.0.1:26658 +``` + +Which should return: + +```bash +{"jsonrpc":"2.0","result":["9QEAAAAAAABmGvJUORYLqY8wVdjgp6/0oSh6brQqG3ZGr/cfUMuElg=="],"id":1} +``` + + + +Alternatively, you can shut off the light node and see that +the OP Stack devnet logs show that the rollup has fallen back to the L1, +in this case Ethereum, for posting data. + +## Span batches + +Span batches can be enabled by setting `OP_BATCHER_BATCH_TYPE: 1` +in your `docker-compose.yml` file. + +Note that this requires the Delta activation time to be configured. +For your devnet, you should set `"l2GenesisDeltaTimeOffset": "0x0",` +in `devnetL1-template.json`. This will enable span batches and can be tested +by grepping `docker compose logs -f | grep batch_type` which should include +`batch_type=SpanBatch` and `batch_type=1`. diff --git a/developers/rollkit.md b/developers/rollkit.md index 28d7c106132..e551f26fe2c 100644 --- a/developers/rollkit.md +++ b/developers/rollkit.md @@ -1,7 +1,7 @@ --- description: Learn how to build Cosmos-SDK applications that connect to Celestia's Data Availability Layer via Rollkit. prev: - text: "Deploy an OP Stack devnet to Celestia" + text: "Run an OP Stack devnet posting Celestia" link: "/developers/optimism" next: text: "Create a wallet with celestia-node" diff --git a/developers/submit-data.md b/developers/submit-data.md index f13eee7af7f..e58dbba8cde 100644 --- a/developers/submit-data.md +++ b/developers/submit-data.md @@ -1,3 +1,9 @@ +--- +prev: + text: "Blobstream rollups" + link: "/developers/blobstream-rollups" +--- + # Submitting data blobs to Celestia diff --git a/nodes/full-consensus-node.md b/nodes/full-consensus-node.md index 7ee31772224..a40f63dba3e 100644 --- a/nodes/full-consensus-node.md +++ b/nodes/full-consensus-node.md @@ -408,7 +408,7 @@ configuration to load the new settings. If you encounter an error like: -```error +```bash 2024-04-25 14:48:24 6:48PM ERR CONSENSUS FAILURE!!! err="+2/3 committed an invalid block: wrong Block.Header.Version. Expected {11 1}, got {11 2}" module=consensus stack="goroutine 214 [running]:\nruntime/debug.Stack()\n\t/usr/local/go/src/runtime/debug/stack.go:24 +0x64\ngithub.com/tendermint/tendermint/consensus.(*State).receiveRoutine.func2()\n\t/go/pkg/mod/github.com/celestiaorg/celestia-core@v1.35.0-tm-v0.34.29/consensus/state.go:746 +0x44\npanic({0x1b91180?, 0x400153b240?})\n\t/usr/local/go/src/runtime/panic.go:770 +0x124\ngithub.com/tendermint/tendermint/consensus.(*State).finalizeCommit(0x400065ea88, 0x3)\n\t/go/pkg/mod/github.com/celestiaorg/celestia-core@v1.35.0-tm-v0.34.29/consensus/state.go:1637 +0xd30\ngithub.com/tendermint/tendermint/consensus.(*State).tryFinalizeCommit(0x400065ea88, 0x3)\n\t/go/pkg/mod/github.com/celestiaorg/celestia-core@v1.35.0-tm-v0.34.29/consensus/state.go:1606 +0x26c\ngithub.com/tendermint/tendermint/consensus.(*State).handleCompleteProposal(0x400065ea88, 0x3)\n\t/go/pkg/mod/github.com/celestiaorg/celestia-core@v1.35.0-tm-v0.34.29/consensus/state.go:2001 +0x2d8\ngithub.com/tendermint/tendermint/consensus.(*State).handleMsg(0x400065ea88, {{0x2b30a00, 0x400143e048}, {0x40002a61b0, 0x28}})\n\t/go/pkg/mod/github.com/celestiaorg/celestia-core@v1.35.0-tm-v0.34.29/consensus/state.go:856 +0x1c8\ngithub.com/tendermint/tendermint/consensus.(*State).receiveRoutine(0x400065ea88, 0x0)\n\t/go/pkg/mod/github.com/celestiaorg/celestia-core@v1.35.0-tm-v0.34.29/consensus/state.go:782 +0x2c4\ncreated by github.com/tendermint/tendermint/consensus.(*State).OnStart in goroutine 169\n\t/go/pkg/mod/github.com/celestiaorg/celestia-core@v1.35.0-tm-v0.34.29/consensus/state.go:391 +0x110\n" ``` diff --git a/nodes/validator-node.md b/nodes/validator-node.md index 01dc548727f..e79b6977b51 100644 --- a/nodes/validator-node.md +++ b/nodes/validator-node.md @@ -232,7 +232,7 @@ For additional resources, refer to If you encounter an error like: -```error +```bash 2024-04-25 14:48:24 6:48PM ERR CONSENSUS FAILURE!!! err="+2/3 committed an invalid block: wrong Block.Header.Version. Expected {11 1}, got {11 2}" module=consensus stack="goroutine 214 [running]:\nruntime/debug.Stack()\n\t/usr/local/go/src/runtime/debug/stack.go:24 +0x64\ngithub.com/tendermint/tendermint/consensus.(*State).receiveRoutine.func2()\n\t/go/pkg/mod/github.com/celestiaorg/celestia-core@v1.35.0-tm-v0.34.29/consensus/state.go:746 +0x44\npanic({0x1b91180?, 0x400153b240?})\n\t/usr/local/go/src/runtime/panic.go:770 +0x124\ngithub.com/tendermint/tendermint/consensus.(*State).finalizeCommit(0x400065ea88, 0x3)\n\t/go/pkg/mod/github.com/celestiaorg/celestia-core@v1.35.0-tm-v0.34.29/consensus/state.go:1637 +0xd30\ngithub.com/tendermint/tendermint/consensus.(*State).tryFinalizeCommit(0x400065ea88, 0x3)\n\t/go/pkg/mod/github.com/celestiaorg/celestia-core@v1.35.0-tm-v0.34.29/consensus/state.go:1606 +0x26c\ngithub.com/tendermint/tendermint/consensus.(*State).handleCompleteProposal(0x400065ea88, 0x3)\n\t/go/pkg/mod/github.com/celestiaorg/celestia-core@v1.35.0-tm-v0.34.29/consensus/state.go:2001 +0x2d8\ngithub.com/tendermint/tendermint/consensus.(*State).handleMsg(0x400065ea88, {{0x2b30a00, 0x400143e048}, {0x40002a61b0, 0x28}})\n\t/go/pkg/mod/github.com/celestiaorg/celestia-core@v1.35.0-tm-v0.34.29/consensus/state.go:856 +0x1c8\ngithub.com/tendermint/tendermint/consensus.(*State).receiveRoutine(0x400065ea88, 0x0)\n\t/go/pkg/mod/github.com/celestiaorg/celestia-core@v1.35.0-tm-v0.34.29/consensus/state.go:782 +0x2c4\ncreated by github.com/tendermint/tendermint/consensus.(*State).OnStart in goroutine 169\n\t/go/pkg/mod/github.com/celestiaorg/celestia-core@v1.35.0-tm-v0.34.29/consensus/state.go:391 +0x110\n" ```