Celestia is a modular data availability network that securely scales with the number of users, making it easy for anyone to launch their own blockchain.
@@ -29,8 +32,24 @@
## What is Optimism?
[Optimism](https://www.optimism.io/) is a project dedicated to scaling Ethereum's technology and expanding its ability to coordinate people from across the world to build effective decentralized economies and governance systems. The [Optimism Collective](https://www.optimism.io/vision) builds open-source software that powers scalable blockchains and aims to address key governance and economic challenges in the wider Ethereum ecosystem. Optimism operates on the principle of **impact=profit**, the idea that individuals who positively impact the Collective should be proportionally rewarded with profit. **Change the incentives and you change the world.**
+If you're looking to run the OP Stack + Celestia setup for this repository, please visit the [Optimism & Celestia guides and tutorials](https://docs.celestia.org/developers/intro-to-op-stack/) to get started.
In this repository you'll find numerous core components of the OP Stack, the decentralized software stack maintained by the Optimism Collective that powers Optimism and forms the backbone of blockchains like [OP Mainnet](https://explorer.optimism.io/) and [Base](https://base.org). The OP Stack is designed to be aggressively open-source — you are welcome to explore, modify, and extend this code.
+The OP Stack powers Optimism, an Ethereum L2 blockchain, and forms the technical foundation for the [the Optimism Collective](https://app.optimism.io/announcement)—a group committed to the **impact=profit** principle. This principle rewards individuals for their positive contributions to the collective.
+
+Optimism addresses critical coordination failures in the crypto ecosystem, such as funding public goods and infrastructure. The OP Stack focuses on creating a shared, open-source system for developing new L2 blockchains within the proposed Superchain ecosystem, promoting collaboration and preventing redundant efforts.
+
+As Optimism evolves, the OP Stack will adapt, encompassing components ranging from blockchain infrastructure to governance systems. This software suite aims to simplify L2 blockchain creation while supporting the growth and development of the Optimism ecosystem.
+
+## What is Celestia?
+
+Celestia is a modular consensus and data network, built to enable anyone to easily deploy their own blockchain with minimal overhead.
+
+Celestia is a minimal blockchain that only orders and publishes transactions and does not execute them. By decoupling the consensus and application execution layers, Celestia modularizes the blockchain technology stack and unlocks new possibilities for decentralized application builders. Lean more at [Celestia.org](https://celestia.org).
+
+## Maintenance
+
+The maintenance guide for this repository can be found in the Wiki tab of the repository or [here](https://github.com/celestiaorg/optimism/wiki).
## Documentation
@@ -40,6 +59,22 @@ In this repository you'll find numerous core components of the OP Stack, the dec
## Specification
Detailed specifications for the OP Stack can be found within the [OP Stack Specs](https://github.com/ethereum-optimism/specs) repository.
+If you're interested in the technical details of how Optimism works, refer to the [Optimism Protocol Specification](https://github.com/ethereum-optimism/specs).
+If you want to build on top of Celestia, take a look at the documentation at [docs.celestia.org](https://docs.celestia.org).
+
+If you want to learn more about the OP Stack, check out the documentation at [stack.optimism.io](https://stack.optimism.io/).
+
+## Community
+
+### Optimism
+
+General discussion happens most frequently on the [Optimism discord](https://discord.gg/optimism).
+Governance discussion can also be found on the [Optimism Governance Forum](https://gov.optimism.io/).
+
+### Celestia
+
+General discussion happens most frequently on the [Celestia discord](https://discord.com/invite/YsnTPcSfWQ).
+Other discussions can be found on the [Celestia forum](https://forum.celestia.org).
## Community
@@ -53,12 +88,52 @@ The OP Stack is a collaborative project. By collaborating on free, open software
[CONTRIBUTING.md](./CONTRIBUTING.md) contains a detailed explanation of the contributing process for this repository. Make sure to use the [Developer Quick Start](./CONTRIBUTING.md#development-quick-start) to properly set up your development environment.
[Good First Issues](https://github.com/ethereum-optimism/optimism/issues?q=is:open+is:issue+label:D-good-first-issue) are a great place to look for tasks to tackle if you're not sure where to start.
+Read through [CONTRIBUTING.md](./CONTRIBUTING.md) for a general overview of our contribution process.
+Use the [Developer Quick Start](./CONTRIBUTING.md#development-quick-start) to get your development environment set up to start working on the Optimism Monorepo.
+Then check out the list of [Good First Issues](https://github.com/ethereum-optimism/optimism/issues?q=is:open+is:issue+label:D-good-first-issue) to find something fun to work on!
+Typo fixes are welcome; however, please create a single commit with all of the typo fixes & batch as many fixes together in a PR as possible. Spammy PRs will be closed.
-## Security Policy and Vulnerability Reporting
+## e2e testing
Please refer to the canonical [Security Policy](https://github.com/ethereum-optimism/.github/blob/master/SECURITY.md) document for detailed information about how to report vulnerabilities in this codebase.
Bounty hunters are encouraged to check out the [Optimism Immunefi bug bounty program](https://immunefi.com/bounty/optimism/).
The Optimism Immunefi program offers up to $2,000,042 for in-scope critical vulnerabilities.
+This repository has updated end-to-end tests in the `op-e2e` package to work with
+Celestia as the data availability (DA) layer.
+
+Currently, the tests assume a working [Celestia devnet](https://github.com/rollkit/local-celestia-devnet) running locally:
+
+```bash
+docker run -p 26650:26650 ghcr.io/rollkit/local-celestia-devnet:v0.12.7
+```
+
+The e2e tests can be triggered with:
+
+```bash
+cd $HOME/optimism
+cd op-e2e
+OP_E2E_DISABLE_PARALLEL=true OP_E2E_CANNON_ENABLED=false OP_NODE_DA_RPC=localhost:26650 OP_BATCHER_DA_RPC=localhost:26650 make test
+```
+
+## Bridging
+
+If you have the OP Stack + Celestia setup running, you can test out bridging from the L1
+to the L2.
+
+To do this, first navigate to the `packages/contracts-bedrock` directory and create a
+`.env` file with the following contents:
+
+```bash
+L1_PROVIDER_URL=http://localhost:8545
+L2_PROVIDER_URL=http://localhost:9545
+PRIVATE_KEY=bf7604d9d3a1c7748642b1b7b05c2bd219c9faa91458b370f85e5a40f3b03af7
+```
+
+Then, run the following from the same directory:
+
+```bash
+npx hardhat deposit --network devnetL1 --l1-provider-url http://localhost:8545 --l2-provider-url http://localhost:9545 --amount-eth --to
+```
## Directory Structure
diff --git a/bedrock-devnet/devnet/__init__.py b/bedrock-devnet/devnet/__init__.py
index 70243dc790c8..0bc614872428 100644
--- a/bedrock-devnet/devnet/__init__.py
+++ b/bedrock-devnet/devnet/__init__.py
@@ -283,6 +283,18 @@ def devnet_deploy(paths):
docker_env['ALTDA_GENERIC_DA'] = 'false'
docker_env['ALTDA_SERVICE'] = 'false'
+ log.info('Bringing up DA')
+ run_command(['docker', 'compose', 'up', '-d', 'da'], cwd=paths.ops_bedrock_dir, env=docker_env)
+ wait_up(26658)
+ time.sleep(15)
+ celestia_node_auth_token = os.getenv("CELESTIA_NODE_AUTH_TOKEN")
+ if not celestia_node_auth_token:
+ celestia_node_auth_token = run_command([
+ 'docker', 'compose', 'exec', '--no-TTY', 'da', 'celestia', 'bridge', 'auth', 'admin', '--node.store', '/home/celestia/bridge'
+ ], cwd=paths.ops_bedrock_dir, env=docker_env, capture_output=True).stdout.decode().strip()
+ docker_env['CELESTIA_NODE_AUTH_TOKEN'] = celestia_node_auth_token
+ print('CELESTIA_NODE_AUTH_TOKEN: ', celestia_node_auth_token)
+
# Bring up the rest of the services.
log.info('Bringing up `op-node`, `op-proposer` and `op-batcher`.')
run_command(['docker', 'compose', 'up', '-d', 'op-node', 'op-proposer', 'op-batcher', 'artifact-server'], cwd=paths.ops_bedrock_dir, env=docker_env)
@@ -363,10 +375,11 @@ def run_command_preset(command: CommandPreset):
return proc.returncode
-def run_command(args, check=True, shell=False, cwd=None, env=None, timeout=None):
+def run_command(args, check=True, shell=False, cwd=None, env=None, timeout=None, capture_output=False):
env = env if env else {}
return subprocess.run(
args,
+ capture_output=capture_output,
check=check,
shell=shell,
env={
diff --git a/docs/op-stack/src/assets/docs/understand/Celestia-logo-color-color.svg b/docs/op-stack/src/assets/docs/understand/Celestia-logo-color-color.svg
new file mode 100644
index 000000000000..6d22cb408925
--- /dev/null
+++ b/docs/op-stack/src/assets/docs/understand/Celestia-logo-color-color.svg
@@ -0,0 +1 @@
+
\ No newline at end of file
diff --git a/go.mod b/go.mod
index 7478f4a18528..2e5529671d9f 100644
--- a/go.mod
+++ b/go.mod
@@ -10,7 +10,7 @@ require (
github.com/btcsuite/btcd v0.24.2
github.com/btcsuite/btcd/chaincfg/chainhash v1.1.0
github.com/cockroachdb/pebble v1.1.2
- github.com/consensys/gnark-crypto v0.12.1
+ github.com/consensys/gnark-crypto v0.14.0
github.com/crate-crypto/go-kzg-4844 v1.0.0
github.com/decred/dcrd/dcrec/secp256k1/v4 v4.3.0
github.com/ethereum-optimism/go-ethereum-hdwallet v0.1.3
@@ -44,6 +44,7 @@ require (
github.com/pkg/profile v1.7.0
github.com/prometheus/client_golang v1.20.5
github.com/protolambda/ctxlock v0.1.0
+ github.com/rollkit/go-da v0.5.0
github.com/stretchr/testify v1.9.0
github.com/urfave/cli/v2 v2.27.5
golang.org/x/crypto v0.28.0
@@ -64,7 +65,7 @@ require (
github.com/armon/go-metrics v0.4.1 // indirect
github.com/benbjohnson/clock v1.3.5 // indirect
github.com/beorn7/perks v1.0.1 // indirect
- github.com/bits-and-blooms/bitset v1.13.0 // indirect
+ github.com/bits-and-blooms/bitset v1.14.2 // indirect
github.com/boltdb/bolt v1.3.1 // indirect
github.com/btcsuite/btcd/btcec/v2 v2.3.4 // indirect
github.com/btcsuite/btcd/btcutil v1.1.5 // indirect
@@ -97,6 +98,7 @@ require (
github.com/fatih/color v1.16.0 // indirect
github.com/felixge/fgprof v0.9.3 // indirect
github.com/ferranbt/fastssz v0.1.2 // indirect
+ github.com/filecoin-project/go-jsonrpc v0.3.1 // indirect
github.com/flynn/noise v1.1.0 // indirect
github.com/francoispqt/gojay v1.2.13 // indirect
github.com/gballet/go-libpcsclite v0.0.0-20191108122812-4678299bea08 // indirect
@@ -112,6 +114,7 @@ require (
github.com/gofrs/flock v0.8.1 // indirect
github.com/gogo/protobuf v1.3.2 // indirect
github.com/golang-jwt/jwt/v4 v4.5.0 // indirect
+ github.com/golang/groupcache v0.0.0-20190702054246-869f871628b6 // indirect
github.com/golang/protobuf v1.5.4 // indirect
github.com/google/gopacket v1.1.19 // indirect
github.com/google/pprof v0.0.0-20240727154555-813a5fbdbec8 // indirect
@@ -229,6 +232,7 @@ require (
github.com/xrash/smetrics v0.0.0-20240521201337-686a1a2994c1 // indirect
github.com/yusufpapurcu/wmi v1.2.3 // indirect
go.etcd.io/bbolt v1.3.5 // indirect
+ go.opencensus.io v0.22.3 // indirect
go.uber.org/dig v1.18.0 // indirect
go.uber.org/fx v1.22.2 // indirect
go.uber.org/mock v0.4.0 // indirect
@@ -239,10 +243,11 @@ require (
golang.org/x/sys v0.26.0 // indirect
golang.org/x/text v0.19.0 // indirect
golang.org/x/tools v0.24.0 // indirect
- google.golang.org/genproto v0.0.0-20230726155614-23370e0ffb3e // indirect
- google.golang.org/genproto/googleapis/api v0.0.0-20230711160842-782d3b101e98 // indirect
- google.golang.org/genproto/googleapis/rpc v0.0.0-20230803162519-f966b187b2e5 // indirect
- google.golang.org/grpc v1.57.1 // indirect
+ golang.org/x/xerrors v0.0.0-20220517211312-f3a8303e98df // indirect
+ google.golang.org/genproto v0.0.0-20231002182017-d307bd883b97 // indirect
+ google.golang.org/genproto/googleapis/api v0.0.0-20231002182017-d307bd883b97 // indirect
+ google.golang.org/genproto/googleapis/rpc v0.0.0-20231002182017-d307bd883b97 // indirect
+ google.golang.org/grpc v1.60.1 // indirect
google.golang.org/protobuf v1.34.2 // indirect
gopkg.in/natefinch/lumberjack.v2 v2.2.1 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
diff --git a/go.sum b/go.sum
index 7b74fd565d0f..be8824fcbc39 100644
--- a/go.sum
+++ b/go.sum
@@ -48,8 +48,8 @@ github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24
github.com/beorn7/perks v1.0.0/go.mod h1:KWe93zE9D1o94FZ5RNwFwVgaQK1VOXiVxmqh+CedLV8=
github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM=
github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw=
-github.com/bits-and-blooms/bitset v1.13.0 h1:bAQ9OPNFYbGHV6Nez0tmNI0RiEu7/hxlYJRUA0wFAVE=
-github.com/bits-and-blooms/bitset v1.13.0/go.mod h1:7hO7Gc7Pp1vODcmWvKMRA9BNmbv6a/7QIWpPxHddWR8=
+github.com/bits-and-blooms/bitset v1.14.2 h1:YXVoyPndbdvcEVcseEovVfp0qjJp7S+i5+xgp/Nfbdc=
+github.com/bits-and-blooms/bitset v1.14.2/go.mod h1:7hO7Gc7Pp1vODcmWvKMRA9BNmbv6a/7QIWpPxHddWR8=
github.com/boltdb/bolt v1.3.1 h1:JQmyP4ZBrce+ZQu0dY660FMfatumYDLun9hBCUVIkF4=
github.com/boltdb/bolt v1.3.1/go.mod h1:clJnj/oiGkjum5o1McbSZDSLxVThjynRyGBgiAx27Ps=
github.com/bradfitz/go-smtpd v0.0.0-20170404230938-deb6d6237625/go.mod h1:HYsPBTaaSFSlLx/70C2HPIMNZpVV8+vt/A+FMnYP11g=
@@ -115,8 +115,8 @@ github.com/cockroachdb/tokenbucket v0.0.0-20230807174530-cc333fc44b06 h1:zuQyyAK
github.com/cockroachdb/tokenbucket v0.0.0-20230807174530-cc333fc44b06/go.mod h1:7nc4anLGjupUW/PeY5qiNYsdNXj7zopG+eqsS7To5IQ=
github.com/consensys/bavard v0.1.13 h1:oLhMLOFGTLdlda/kma4VOJazblc7IM5y5QPd2A/YjhQ=
github.com/consensys/bavard v0.1.13/go.mod h1:9ItSMtA/dXMAiL7BG6bqW2m3NdSEObYWoH223nGHukI=
-github.com/consensys/gnark-crypto v0.12.1 h1:lHH39WuuFgVHONRl3J0LRBtuYdQTumFSDtJF7HpyG8M=
-github.com/consensys/gnark-crypto v0.12.1/go.mod h1:v2Gy7L/4ZRosZ7Ivs+9SfUDr0f5UlG+EM5t7MPHiLuY=
+github.com/consensys/gnark-crypto v0.14.0 h1:DDBdl4HaBtdQsq/wfMwJvZNE80sHidrK3Nfrefatm0E=
+github.com/consensys/gnark-crypto v0.14.0/go.mod h1:CU4UijNPsHawiVGNxe9co07FkzCeWHHrb1li/n1XoU0=
github.com/containerd/cgroups v0.0.0-20201119153540-4cbc285b3327/go.mod h1:ZJeTFisyysqgcCdecO57Dj79RfL0LNeGiFUqLYQRYLE=
github.com/containerd/cgroups v1.1.0 h1:v8rEWFl6EoqHB+swVNjVoCJE8o3jX7e8nqBGPLaDFBM=
github.com/containerd/cgroups v1.1.0/go.mod h1:6ppBcbh/NOOUU+dMKrykgaBnK9lCIBxHqJDGwsa1mIw=
@@ -196,6 +196,8 @@ github.com/felixge/fgprof v0.9.3 h1:VvyZxILNuCiUCSXtPtYmmtGvb65nqXh2QFWc0Wpf2/g=
github.com/felixge/fgprof v0.9.3/go.mod h1:RdbpDgzqYVh/T9fPELJyV7EYJuHB55UTEULNun8eiPw=
github.com/ferranbt/fastssz v0.1.2 h1:Dky6dXlngF6Qjc+EfDipAkE83N5I5DE68bY6O0VLNPk=
github.com/ferranbt/fastssz v0.1.2/go.mod h1:X5UPrE2u1UJjxHA8X54u04SBwdAQjG2sFtWs39YxyWs=
+github.com/filecoin-project/go-jsonrpc v0.3.1 h1:qwvAUc5VwAkooquKJmfz9R2+F8znhiqcNHYjEp/NM10=
+github.com/filecoin-project/go-jsonrpc v0.3.1/go.mod h1:jBSvPTl8V1N7gSTuCR4bis8wnQnIjHbRPpROol6iQKM=
github.com/flynn/go-shlex v0.0.0-20150515145356-3f9db97f8568/go.mod h1:xEzjJPgXI435gkrCt3MPfRiAkVrwSbHsst4LCFVfpJc=
github.com/flynn/noise v1.1.0 h1:KjPQoQCEFdZDiP03phOvGi11+SVVhBG2wOWAorLsstg=
github.com/flynn/noise v1.1.0/go.mod h1:xbMo+0i6+IGbYdJhF31t2eR1BIU0CYc12+BNAKwUTag=
@@ -257,6 +259,8 @@ github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69
github.com/golang-jwt/jwt/v4 v4.5.0 h1:7cYmW1XlMY7h7ii7UhUyChSgS5wUJEnm9uZVTGqOWzg=
github.com/golang-jwt/jwt/v4 v4.5.0/go.mod h1:m21LjoU+eqJr34lmDMbreY2eSTRJ1cv77w39/MY0Ch0=
github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q=
+github.com/golang/groupcache v0.0.0-20190702054246-869f871628b6 h1:ZgQEtGgCBiWRM39fZuwSd1LwSqqSW0hOdXCYYDX0R3I=
+github.com/golang/groupcache v0.0.0-20190702054246-869f871628b6/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc=
github.com/golang/lint v0.0.0-20180702182130-06c8688daad7/go.mod h1:tluoj9z5200jBnyusfRPU2LqT6J+DAorxEvtC7LHB+E=
github.com/golang/mock v1.1.1/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A=
github.com/golang/mock v1.2.0/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A=
@@ -441,8 +445,8 @@ github.com/kylelemons/godebug v1.1.0 h1:RPNrshWIDI6G2gRW9EHilWtl7Z6Sb1BR0xunSBf0
github.com/kylelemons/godebug v1.1.0/go.mod h1:9/0rRGxNHcop5bhtWyNeEfOS8JIWk580+fNqagV/RAw=
github.com/labstack/echo/v4 v4.2.1/go.mod h1:AA49e0DZ8kk5jTOOCKNuPR6oTnBS0dYiM4FW1e6jwpg=
github.com/labstack/gommon v0.3.0/go.mod h1:MULnywXg0yavhxWKc+lOruYdAhDwPK9wf0OL7NoOu+k=
-github.com/leanovate/gopter v0.2.9 h1:fQjYxZaynp97ozCzfOyOuAGOU4aU/z37zf/tOujFk7c=
-github.com/leanovate/gopter v0.2.9/go.mod h1:U2L/78B+KVFIx2VmW6onHJQzXtFb+p5y3y2Sh+Jxxv8=
+github.com/leanovate/gopter v0.2.11 h1:vRjThO1EKPb/1NsDXuDrzldR28RLkBflWYcU9CvzWu4=
+github.com/leanovate/gopter v0.2.11/go.mod h1:aK3tzZP/C+p1m3SPRE4SYZFGP7jjkuSI4f7Xvpt0S9c=
github.com/libp2p/go-buffer-pool v0.1.0 h1:oK4mSFcQz7cTQIfqbe4MIj9gLW+mnanjyFtc6cdF0Y8=
github.com/libp2p/go-buffer-pool v0.1.0/go.mod h1:N+vh8gMqimBzdKkSMVuydVDq+UV5QTWy5HSiZacSbPg=
github.com/libp2p/go-flow-metrics v0.1.0 h1:0iPhMI8PskQwzh57jB9WxIuIOQ0r+15PChFGkx3Q3WM=
@@ -700,6 +704,8 @@ github.com/rogpeppe/go-internal v1.6.1/go.mod h1:xXDCJY+GAPziupqXw64V24skbSoqbTE
github.com/rogpeppe/go-internal v1.9.0/go.mod h1:WtVeX8xhTBvf0smdhujwtBcq4Qrzq/fJaraNFVN+nFs=
github.com/rogpeppe/go-internal v1.11.0 h1:cWPaGQEPrBb5/AsnsZesgZZ9yb1OQ+GOISoDNXVBh4M=
github.com/rogpeppe/go-internal v1.11.0/go.mod h1:ddIwULY96R17DhadqLgMfk9H9tvdUzkipdSkR5nkCZA=
+github.com/rollkit/go-da v0.5.0 h1:sQpZricNS+2TLx3HMjNWhtRfqtvVC/U4pWHpfUz3eN4=
+github.com/rollkit/go-da v0.5.0/go.mod h1:VsUeAoPvKl4Y8wWguu/VibscYiFFePkkrvZWyTjZHww=
github.com/rs/cors v1.11.0 h1:0B9GE/r9Bc2UxRMMtymBkHTenPkHDv0CW4Y98GBY+po=
github.com/rs/cors v1.11.0/go.mod h1:XyqrcTp5zjWr1wsJ8PIRZssZ8b/WMcMf71DJnit4EMU=
github.com/rs/xid v1.6.0 h1:fV591PaemRlL6JfRxGDEPl69wICngIQ3shQtzfy2gxU=
@@ -805,6 +811,8 @@ github.com/yusufpapurcu/wmi v1.2.3/go.mod h1:SBZ9tNy3G9/m5Oi98Zks0QjeHVDvuK0qfxQ
go.etcd.io/bbolt v1.3.5 h1:XAzx9gjCb0Rxj7EoqcClPD1d5ZBxZJk0jbuoPHenBt0=
go.etcd.io/bbolt v1.3.5/go.mod h1:G5EMThwa9y8QZGBClrRx5EY+Yw9kAhnjy3bSjsnlVTQ=
go.opencensus.io v0.18.0/go.mod h1:vKdFvxhtzZ9onBp9VKHK8z/sRpBMnKAsufL7wlDrCOA=
+go.opencensus.io v0.22.3 h1:8sGtKOrtQqkN1bp2AtX+misvLIlOmsEsNd+9NIcPEm8=
+go.opencensus.io v0.22.3/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw=
go.uber.org/atomic v1.6.0/go.mod h1:sABNBOSYdrvTF6hTgEIbc7YasKWGhgEQZyfxyTvoXHQ=
go.uber.org/atomic v1.7.0/go.mod h1:fEN4uk6kAWBTFdckzkM89CLk9XfWZrxpCo0nPH17wJc=
go.uber.org/dig v1.18.0 h1:imUL1UiY0Mg4bqbFfsRQO5G4CGRBec/ZujWTvSVp3pw=
@@ -851,6 +859,7 @@ golang.org/x/exp v0.0.0-20240808152545-0cdaa3abc0fa/go.mod h1:akd2r19cwCdwSwWeId
golang.org/x/lint v0.0.0-20180702182130-06c8688daad7/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE=
golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE=
golang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961/go.mod h1:wehouNa3lNwaWXcvxsM5YxQ5yQlVC4a0KAMCusXpPoU=
+golang.org/x/lint v0.0.0-20190313153728-d0100b6bd8b3/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc=
golang.org/x/lint v0.0.0-20190930215403-16217165b5de/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc=
golang.org/x/lint v0.0.0-20200302205851-738671d3881b/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY=
golang.org/x/mod v0.0.0-20190513183733-4bf6d317e70e/go.mod h1:mXi4GBBbnImb6dmsKGUJ2LatrhH/nqhxcFungHvyanc=
@@ -924,6 +933,7 @@ golang.org/x/sys v0.0.0-20190222072716-a9d3bda3a223/go.mod h1:STP8DvDyc/dI5b8T5h
golang.org/x/sys v0.0.0-20190316082340-a2f829d7f35f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20190422165155-953cdadca894/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
+golang.org/x/sys v0.0.0-20190502145724-3ef323f4f1fd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20190813064441-fde4db37ae7a/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20190904154756-749cb33beabd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20190916202348-b4ddaad3f8a3/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
@@ -1027,6 +1037,7 @@ golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8T
golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
+golang.org/x/xerrors v0.0.0-20220517211312-f3a8303e98df h1:5Pf6pFKu98ODmgnpvkJ3kFUOQGGLIzLIkbzUHp47618=
golang.org/x/xerrors v0.0.0-20220517211312-f3a8303e98df/go.mod h1:K8+ghG5WaK9qNqU5K3HdILfMLy1f3aNYFI/wnl100a8=
google.golang.org/api v0.0.0-20180910000450-7ca32eb868bf/go.mod h1:4mhQ8q/RsB7i+udVvVy5NUi08OU8ZlA0gRVgrF7VFY0=
google.golang.org/api v0.0.0-20181030000543-1d582fd0359e/go.mod h1:4mhQ8q/RsB7i+udVvVy5NUi08OU8ZlA0gRVgrF7VFY0=
@@ -1040,18 +1051,20 @@ google.golang.org/genproto v0.0.0-20180831171423-11092d34479b/go.mod h1:JiN7NxoA
google.golang.org/genproto v0.0.0-20181029155118-b69ba1387ce2/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc=
google.golang.org/genproto v0.0.0-20181202183823-bd91e49a0898/go.mod h1:7Ep/1NZk928CDR8SjdVbjWNpdIf6nzjE3BTgJDr2Atg=
google.golang.org/genproto v0.0.0-20190306203927-b5d61aea6440/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE=
-google.golang.org/genproto v0.0.0-20230726155614-23370e0ffb3e h1:xIXmWJ303kJCuogpj0bHq+dcjcZHU+XFyc1I0Yl9cRg=
-google.golang.org/genproto v0.0.0-20230726155614-23370e0ffb3e/go.mod h1:0ggbjUrZYpy1q+ANUS30SEoGZ53cdfwtbuG7Ptgy108=
-google.golang.org/genproto/googleapis/api v0.0.0-20230711160842-782d3b101e98 h1:FmF5cCW94Ij59cfpoLiwTgodWmm60eEV0CjlsVg2fuw=
-google.golang.org/genproto/googleapis/api v0.0.0-20230711160842-782d3b101e98/go.mod h1:rsr7RhLuwsDKL7RmgDDCUc6yaGr1iqceVb5Wv6f6YvQ=
-google.golang.org/genproto/googleapis/rpc v0.0.0-20230803162519-f966b187b2e5 h1:eSaPbMR4T7WfH9FvABk36NBMacoTUKdWCvV0dx+KfOg=
-google.golang.org/genproto/googleapis/rpc v0.0.0-20230803162519-f966b187b2e5/go.mod h1:zBEcrKX2ZOcEkHWxBPAIvYUWOKKMIhYcmNiUIu2ji3I=
+google.golang.org/genproto v0.0.0-20190425155659-357c62f0e4bb/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE=
+google.golang.org/genproto v0.0.0-20231002182017-d307bd883b97 h1:SeZZZx0cP0fqUyA+oRzP9k7cSwJlvDFiROO72uwD6i0=
+google.golang.org/genproto v0.0.0-20231002182017-d307bd883b97/go.mod h1:t1VqOqqvce95G3hIDCT5FeO3YUc6Q4Oe24L/+rNMxRk=
+google.golang.org/genproto/googleapis/api v0.0.0-20231002182017-d307bd883b97 h1:W18sezcAYs+3tDZX4F80yctqa12jcP1PUS2gQu1zTPU=
+google.golang.org/genproto/googleapis/api v0.0.0-20231002182017-d307bd883b97/go.mod h1:iargEX0SFPm3xcfMI0d1domjg0ZF4Aa0p2awqyxhvF0=
+google.golang.org/genproto/googleapis/rpc v0.0.0-20231002182017-d307bd883b97 h1:6GQBEOdGkX6MMTLT9V+TjtIRZCw9VPD5Z+yHY9wMgS0=
+google.golang.org/genproto/googleapis/rpc v0.0.0-20231002182017-d307bd883b97/go.mod h1:v7nGkzlmW8P3n/bKmWBn2WpBjpOEx8Q6gMueudAmKfY=
google.golang.org/grpc v1.14.0/go.mod h1:yo6s7OP7yaDglbqo1J04qKzAhqBH6lvTonzMVmEdcZw=
google.golang.org/grpc v1.16.0/go.mod h1:0JHn/cJsOMiMfNA9+DeHDlAU7KAAB5GDlYFpa9MZMio=
google.golang.org/grpc v1.17.0/go.mod h1:6QZJwpn2B+Zp71q/5VxRsJ6NXXVCE5NRUHRo+f3cWCs=
google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c=
-google.golang.org/grpc v1.57.1 h1:upNTNqv0ES+2ZOOqACwVtS3Il8M12/+Hz41RCPzAjQg=
-google.golang.org/grpc v1.57.1/go.mod h1:Sd+9RMTACXwmub0zcNY2c4arhtrbBYD1AUHI/dt16Mo=
+google.golang.org/grpc v1.20.1/go.mod h1:10oTOabMzJvdu6/UiuZezV6QK5dSlG84ov/aaiqXj38=
+google.golang.org/grpc v1.60.1 h1:26+wFr+cNqSGFcOXcabYC0lUVJVRa2Sb2ortSK7VrEU=
+google.golang.org/grpc v1.60.1/go.mod h1:OlCHIeLYqSSsLi6i49B5QGdzaMZK9+M7LXN2FKz4eGM=
google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8=
google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0=
google.golang.org/protobuf v0.0.0-20200228230310-ab0ca4ff8a60/go.mod h1:cfTl7dwQJ+fmap5saPgwCLgHXTUD7jkjRqWcaiX5VyM=
diff --git a/op-batcher/batcher/config.go b/op-batcher/batcher/config.go
index ac8bad7791a7..4bf8f5fd4a85 100644
--- a/op-batcher/batcher/config.go
+++ b/op-batcher/batcher/config.go
@@ -11,6 +11,7 @@ import (
altda "github.com/ethereum-optimism/optimism/op-alt-da"
"github.com/ethereum-optimism/optimism/op-batcher/compressor"
"github.com/ethereum-optimism/optimism/op-batcher/flags"
+ celestia "github.com/ethereum-optimism/optimism/op-celestia"
"github.com/ethereum-optimism/optimism/op-node/rollup/derive"
"github.com/ethereum-optimism/optimism/op-service/eth"
oplog "github.com/ethereum-optimism/optimism/op-service/log"
@@ -60,6 +61,12 @@ type CLIConfig struct {
// Maximum number of blocks to add to a span batch. Default is 0 - no maximum.
MaxBlocksPerSpanBatch int
+ // MaxFrameSize is the maximum size of a frame in a batch tx.
+ MaxFrameSize uint64
+
+ // MultiFrameTxs controls whether to put all frames of a channel inside a single tx.
+ MultiFrameTxs bool
+
// The target number of frames to create per channel. Controls number of blobs
// per blob tx, if using Blob DA.
TargetNumFrames int
@@ -106,6 +113,7 @@ type CLIConfig struct {
PprofConfig oppprof.CLIConfig
RPC oprpc.CLIConfig
AltDA altda.CLIConfig
+ DaConfig celestia.CLIConfig
}
func (c *CLIConfig) Check() error {
@@ -161,6 +169,9 @@ func (c *CLIConfig) Check() error {
if err := c.RPC.Check(); err != nil {
return err
}
+ if err := c.DaConfig.Check(); err != nil {
+ return err
+ }
return nil
}
@@ -179,6 +190,8 @@ func NewConfig(ctx *cli.Context) *CLIConfig {
MaxChannelDuration: ctx.Uint64(flags.MaxChannelDurationFlag.Name),
MaxL1TxSize: ctx.Uint64(flags.MaxL1TxSizeBytesFlag.Name),
MaxBlocksPerSpanBatch: ctx.Int(flags.MaxBlocksPerSpanBatch.Name),
+ MaxFrameSize: ctx.Uint64(flags.MaxFrameSizeFlag.Name),
+ MultiFrameTxs: ctx.Bool(flags.MultiFrameTxsFlag.Name),
TargetNumFrames: ctx.Int(flags.TargetNumFramesFlag.Name),
ApproxComprRatio: ctx.Float64(flags.ApproxComprRatioFlag.Name),
Compressor: ctx.String(flags.CompressorFlag.Name),
@@ -195,5 +208,6 @@ func NewConfig(ctx *cli.Context) *CLIConfig {
PprofConfig: oppprof.ReadCLIConfig(ctx),
RPC: oprpc.ReadCLIConfig(ctx),
AltDA: altda.ReadCLIConfig(ctx),
+ DaConfig: celestia.ReadCLIConfig(ctx),
}
}
diff --git a/op-batcher/batcher/driver.go b/op-batcher/batcher/driver.go
index b31dd29e2e05..1dfb699590b9 100644
--- a/op-batcher/batcher/driver.go
+++ b/op-batcher/batcher/driver.go
@@ -2,6 +2,7 @@ package batcher
import (
"context"
+ "encoding/hex"
"errors"
"fmt"
"io"
@@ -12,6 +13,7 @@ import (
altda "github.com/ethereum-optimism/optimism/op-alt-da"
"github.com/ethereum-optimism/optimism/op-batcher/metrics"
+ celestia "github.com/ethereum-optimism/optimism/op-celestia"
"github.com/ethereum-optimism/optimism/op-node/rollup"
"github.com/ethereum-optimism/optimism/op-node/rollup/derive"
"github.com/ethereum-optimism/optimism/op-service/dial"
@@ -86,6 +88,7 @@ type DriverSetup struct {
ChannelConfig ChannelConfigProvider
AltDA *altda.DAClient
ChannelOutFactory ChannelOutFactory
+ DAClient *celestia.DAClient
}
// BatchSubmitter encapsulates a service responsible for submitting L2 tx
@@ -691,6 +694,20 @@ func (l *BatchSubmitter) publishToAltDAAndL1(txdata txData, queue *txmgr.Queue[t
}
}
+// fallbackTxCandidate creates a fallback tx candidate for the given txdata.
+func (l *BatchSubmitter) fallbackTxCandidate(txdata txData) (*txmgr.TxCandidate, error) {
+ switch l.DAClient.FallbackMode {
+ case celestia.FallbackModeBlobData:
+ return l.blobTxCandidate(txdata)
+ case celestia.FallbackModeCallData:
+ return l.calldataTxCandidate(txdata.CallData()), nil
+ case celestia.FallbackModeDisabled:
+ return nil, fmt.Errorf("celestia: fallback disabled")
+ default:
+ return nil, fmt.Errorf("celestia: unknown fallback mode: %s", l.DAClient.FallbackMode)
+ }
+}
+
// sendTransaction creates & queues for sending a transaction to the batch inbox address with the given `txData`.
// This call will block if the txmgr queue is at the max-pending limit.
// The method will block if the queue's MaxPendingTransactions is exceeded.
@@ -704,22 +721,27 @@ func (l *BatchSubmitter) sendTransaction(txdata txData, queue *txmgr.Queue[txRef
return nil
}
- var candidate *txmgr.TxCandidate
- if txdata.asBlob {
- if candidate, err = l.blobTxCandidate(txdata); err != nil {
- // We could potentially fall through and try a calldata tx instead, but this would
- // likely result in the chain spending more in gas fees than it is tuned for, so best
- // to just fail. We do not expect this error to trigger unless there is a serious bug
- // or configuration issue.
- return fmt.Errorf("could not create blob tx candidate: %w", err)
- }
- } else {
- // sanity check
- if nf := len(txdata.frames); nf != 1 {
- l.Log.Crit("Unexpected number of frames in calldata tx", "num_frames", nf)
+ // force celestia tx candidate, multiframe is set by UseBlobs which is not affected
+ txdata.asBlob = false
+ // sanity check
+ if nf := len(txdata.frames); nf > l.ChannelConfig.ChannelConfig().TargetNumFrames {
+ l.Log.Crit("Unexpected number of frames in calldata tx", "num_frames", nf)
+ }
+ candidate, err := l.celestiaTxCandidate(txdata.CallData())
+ if err != nil {
+ l.Log.Error("celestia: blob submission failed", "err", err)
+ candidate, err = l.fallbackTxCandidate(txdata)
+ if err != nil {
+ l.Log.Error("celestia: fallback failed", "err", err)
+ l.recordFailedTx(txdata.ID(), err)
+ return nil
}
- candidate = l.calldataTxCandidate(txdata.CallData())
}
+ // restore asBlob for cancellation in case of blobdata fallback
+ if len(candidate.Blobs) > 0 {
+ txdata.asBlob = true
+ }
+ l.Log.Info("tx candidate", "ID", txdata.ID(), "len(txdata.frames)", len(txdata.frames), "txdata.asBlob", txdata.asBlob)
l.sendTx(txdata, false, candidate, queue, receiptsCh)
return nil
@@ -763,6 +785,22 @@ func (l *BatchSubmitter) calldataTxCandidate(data []byte) *txmgr.TxCandidate {
}
}
+func (l *BatchSubmitter) celestiaTxCandidate(data []byte) (*txmgr.TxCandidate, error) {
+ l.Log.Info("Building Celestia transaction candidate", "size", len(data))
+ ctx, cancel := context.WithTimeout(context.Background(), 30*time.Duration(l.RollupConfig.BlockTime)*time.Second)
+ ids, err := l.DAClient.Client.Submit(ctx, [][]byte{data}, l.DAClient.GasPrice, l.DAClient.Namespace)
+ cancel()
+ if err != nil {
+ return nil, err
+ }
+ if len(ids) != 1 {
+ return nil, fmt.Errorf("celestia: expected 1 id, got %d", len(ids))
+ }
+ l.Log.Info("celestia: blob successfully submitted", "id", hex.EncodeToString(ids[0]))
+ data = append([]byte{celestia.DerivationVersionCelestia}, ids[0]...)
+ return l.calldataTxCandidate(data), nil
+}
+
func (l *BatchSubmitter) handleReceipt(r txmgr.TxReceipt[txRef]) {
// Record TX Status
if r.Err != nil {
diff --git a/op-batcher/batcher/service.go b/op-batcher/batcher/service.go
index 90a85cc4ee48..db1389c44ee7 100644
--- a/op-batcher/batcher/service.go
+++ b/op-batcher/batcher/service.go
@@ -16,6 +16,7 @@ import (
"github.com/ethereum-optimism/optimism/op-batcher/flags"
"github.com/ethereum-optimism/optimism/op-batcher/metrics"
"github.com/ethereum-optimism/optimism/op-batcher/rpc"
+ celestia "github.com/ethereum-optimism/optimism/op-celestia"
"github.com/ethereum-optimism/optimism/op-node/chaincfg"
"github.com/ethereum-optimism/optimism/op-node/params"
"github.com/ethereum-optimism/optimism/op-node/rollup"
@@ -73,6 +74,7 @@ type BatcherService struct {
stopped atomic.Bool
NotSubmittingOnStart bool
+ DAClient *celestia.DAClient
}
type DriverSetupOption func(setup *DriverSetup)
@@ -124,6 +126,13 @@ func (bs *BatcherService) initFromCLIConfig(ctx context.Context, version string,
if err := bs.initPProf(cfg); err != nil {
return fmt.Errorf("failed to init profiling: %w", err)
}
+ // init before driver
+ if err := bs.initAltDA(cfg); err != nil {
+ return fmt.Errorf("failed to init AltDA: %w", err)
+ }
+ if err := bs.initDA(cfg); err != nil {
+ return fmt.Errorf("failed to start da server: %w", err)
+ }
bs.initDriver(opts...)
if err := bs.initRPCServer(cfg); err != nil {
return fmt.Errorf("failed to start RPC server: %w", err)
@@ -208,6 +217,16 @@ func (bs *BatcherService) initChannelConfig(cfg *CLIConfig) error {
BatchType: cfg.BatchType,
}
+ // override max frame size if set
+ if cfg.MaxFrameSize > 0 {
+ cc.MaxFrameSize = cfg.MaxFrameSize
+ }
+
+ // enable multi-frame txs if set
+ if cfg.MultiFrameTxs {
+ cc.UseBlobs = true
+ }
+
switch cfg.DataAvailabilityType {
case flags.BlobsType, flags.AutoType:
if !cfg.TestUseMaxTxSizeForBlobs {
@@ -244,6 +263,7 @@ func (bs *BatcherService) initChannelConfig(cfg *CLIConfig) error {
bs.Log.Info("Initialized channel-config",
"da_type", cfg.DataAvailabilityType,
"use_alt_da", bs.UseAltDA,
+ "use_blobs", cc.UseBlobs,
"max_frame_size", cc.MaxFrameSize,
"target_num_frames", cc.TargetNumFrames,
"compressor", cc.CompressorConfig.Kind,
@@ -328,6 +348,7 @@ func (bs *BatcherService) initDriver(opts ...DriverSetupOption) {
EndpointProvider: bs.EndpointProvider,
ChannelConfig: bs.ChannelConfig,
AltDA: bs.AltDA,
+ DAClient: bs.DAClient,
}
for _, opt := range opts {
opt(&ds)
@@ -366,6 +387,15 @@ func (bs *BatcherService) initAltDA(cfg *CLIConfig) error {
return nil
}
+func (bs *BatcherService) initDA(cfg *CLIConfig) error {
+ client, err := celestia.NewDAClient(cfg.DaConfig.Rpc, cfg.DaConfig.AuthToken, cfg.DaConfig.Namespace, cfg.DaConfig.FallbackMode, cfg.DaConfig.GasPrice)
+ if err != nil {
+ return err
+ }
+ bs.DAClient = client
+ return nil
+}
+
// Start runs once upon start of the batcher lifecycle,
// and starts batch-submission work if the batcher is configured to start submit data on startup.
func (bs *BatcherService) Start(_ context.Context) error {
diff --git a/op-batcher/flags/flags.go b/op-batcher/flags/flags.go
index 3fe66f33981b..10f2278b8759 100644
--- a/op-batcher/flags/flags.go
+++ b/op-batcher/flags/flags.go
@@ -10,6 +10,7 @@ import (
altda "github.com/ethereum-optimism/optimism/op-alt-da"
"github.com/ethereum-optimism/optimism/op-batcher/compressor"
+ celestia "github.com/ethereum-optimism/optimism/op-celestia"
"github.com/ethereum-optimism/optimism/op-node/rollup/derive"
opservice "github.com/ethereum-optimism/optimism/op-service"
openum "github.com/ethereum-optimism/optimism/op-service/enum"
@@ -43,7 +44,6 @@ var (
Usage: "HTTP provider URL for Rollup node. A comma-separated list enables the active L2 endpoint provider. Such a list needs to match the number of l2-eth-rpcs provided.",
EnvVars: prefixEnvVars("ROLLUP_RPC"),
}
- // Optional flags
SubSafetyMarginFlag = &cli.Uint64Flag{
Name: "sub-safety-margin",
Usage: "The batcher tx submission safety margin (in #L1-blocks) to subtract " +
@@ -81,6 +81,18 @@ var (
Usage: "Maximum number of blocks to add to a span batch. Default is 0 - no maximum.",
EnvVars: prefixEnvVars("MAX_BLOCKS_PER_SPAN_BATCH"),
}
+ MaxFrameSizeFlag = &cli.Uint64Flag{
+ Name: "max-frame-size-bytes",
+ Usage: "The maximum size of a frame. 0 to use default value (120k-1)",
+ Value: 0,
+ EnvVars: prefixEnvVars("MAX_FRAME_SIZE_BYTES"),
+ }
+ MultiFrameTxsFlag = &cli.BoolFlag{
+ Name: "multi-frame-txs",
+ Usage: "Whether to put all frames of a channel inside a single tx. Ignored for blobs, where true will be used.",
+ Value: false,
+ EnvVars: prefixEnvVars("MULTI_FRAME_TXS"),
+ }
TargetNumFramesFlag = &cli.IntFlag{
Name: "target-num-frames",
Usage: "The target number of frames to create per channel. Controls number of blobs per blob tx, if using Blob DA.",
@@ -175,6 +187,8 @@ var optionalFlags = []cli.Flag{
MaxChannelDurationFlag,
MaxL1TxSizeBytesFlag,
MaxBlocksPerSpanBatch,
+ MaxFrameSizeFlag,
+ MultiFrameTxsFlag,
TargetNumFramesFlag,
ApproxComprRatioFlag,
CompressorFlag,
@@ -193,6 +207,7 @@ func init() {
optionalFlags = append(optionalFlags, oppprof.CLIFlags(EnvVarPrefix)...)
optionalFlags = append(optionalFlags, txmgr.CLIFlags(EnvVarPrefix)...)
optionalFlags = append(optionalFlags, altda.CLIFlags(EnvVarPrefix, "")...)
+ optionalFlags = append(optionalFlags, celestia.CLIFlags(EnvVarPrefix)...)
Flags = append(requiredFlags, optionalFlags...)
}
diff --git a/op-celestia/cli.go b/op-celestia/cli.go
new file mode 100644
index 000000000000..33b2f1767552
--- /dev/null
+++ b/op-celestia/cli.go
@@ -0,0 +1,120 @@
+package celestia
+
+import (
+ "fmt"
+
+ "github.com/urfave/cli/v2"
+
+ opservice "github.com/ethereum-optimism/optimism/op-service"
+)
+
+const (
+ // FallbackModeDisabled is the fallback mode disabled
+ FallbackModeDisabled = "disabled"
+ // FallbackModeBlobData is the fallback mode blob data
+ FallbackModeBlobData = "blobdata"
+ // FallbackModeCallData is the fallback mode call data
+ FallbackModeCallData = "calldata"
+)
+
+const (
+ // RPCFlagName defines the flag for the rpc url
+ RPCFlagName = "da.rpc"
+ // AuthTokenFlagName defines the flag for the auth token
+ AuthTokenFlagName = "da.auth_token"
+ // NamespaceFlagName defines the flag for the namespace
+ NamespaceFlagName = "da.namespace"
+ // EthFallbackDisabledFlagName defines the flag for disabling eth fallback
+ EthFallbackDisabledFlagName = "da.eth_fallback_disabled"
+ // FallbackModeFlagName defines the flag for fallback mode
+ FallbackModeFlagName = "da.fallback_mode"
+ // GasPriceFlagName defines the flag for gas price
+ GasPriceFlagName = "da.gas_price"
+
+ // NamespaceSize is the size of the hex encoded namespace string
+ NamespaceSize = 58
+
+ // defaultRPC is the default rpc dial address
+ defaultRPC = "grpc://localhost:26650"
+
+ // defaultGasPrice is the default gas price
+ defaultGasPrice = -1
+)
+
+func CLIFlags(envPrefix string) []cli.Flag {
+ return []cli.Flag{
+ &cli.StringFlag{
+ Name: RPCFlagName,
+ Usage: "dial address of the data availability rpc client; supports grpc, http, https",
+ Value: defaultRPC,
+ EnvVars: opservice.PrefixEnvVar(envPrefix, "DA_RPC"),
+ },
+ &cli.StringFlag{
+ Name: AuthTokenFlagName,
+ Usage: "authentication token of the data availability client",
+ EnvVars: opservice.PrefixEnvVar(envPrefix, "DA_AUTH_TOKEN"),
+ },
+ &cli.StringFlag{
+ Name: NamespaceFlagName,
+ Usage: "namespace of the data availability client",
+ EnvVars: opservice.PrefixEnvVar(envPrefix, "DA_NAMESPACE"),
+ },
+ &cli.BoolFlag{
+ Name: EthFallbackDisabledFlagName,
+ Usage: "disable eth fallback (deprecated, use FallbackModeFlag instead)",
+ EnvVars: opservice.PrefixEnvVar(envPrefix, "DA_ETH_FALLBACK_DISABLED"),
+ Action: func(c *cli.Context, e bool) error {
+ if e {
+ return c.Set(FallbackModeFlagName, FallbackModeDisabled)
+ }
+ return nil
+ },
+ },
+ &cli.StringFlag{
+ Name: FallbackModeFlagName,
+ Usage: fmt.Sprintf("fallback mode; must be one of: %s, %s or %s", FallbackModeDisabled, FallbackModeBlobData, FallbackModeCallData),
+ EnvVars: opservice.PrefixEnvVar(envPrefix, "DA_FALLBACK_MODE"),
+ Value: FallbackModeCallData,
+ Action: func(c *cli.Context, s string) error {
+ if s != FallbackModeDisabled && s != FallbackModeBlobData && s != FallbackModeCallData {
+ return fmt.Errorf("invalid fallback mode: %s; must be one of: %s, %s or %s", s, FallbackModeDisabled, FallbackModeBlobData, FallbackModeCallData)
+ }
+ return nil
+ },
+ },
+ &cli.Float64Flag{
+ Name: GasPriceFlagName,
+ Usage: "gas price of the data availability client",
+ Value: defaultGasPrice,
+ EnvVars: opservice.PrefixEnvVar(envPrefix, "DA_GAS_PRICE"),
+ },
+ }
+}
+
+type CLIConfig struct {
+ Rpc string
+ AuthToken string
+ Namespace string
+ FallbackMode string
+ GasPrice float64
+}
+
+func (c CLIConfig) Check() error {
+ return nil
+}
+
+func NewCLIConfig() CLIConfig {
+ return CLIConfig{
+ Rpc: defaultRPC,
+ }
+}
+
+func ReadCLIConfig(ctx *cli.Context) CLIConfig {
+ return CLIConfig{
+ Rpc: ctx.String(RPCFlagName),
+ AuthToken: ctx.String(AuthTokenFlagName),
+ Namespace: ctx.String(NamespaceFlagName),
+ FallbackMode: ctx.String(FallbackModeFlagName),
+ GasPrice: ctx.Float64(GasPriceFlagName),
+ }
+}
diff --git a/op-celestia/da.go b/op-celestia/da.go
new file mode 100644
index 000000000000..feecb3a82fad
--- /dev/null
+++ b/op-celestia/da.go
@@ -0,0 +1,10 @@
+package celestia
+
+// DerivationVersionCelestia is a byte marker for celestia references submitted
+// to the batch inbox address as calldata.
+// Mnemonic 0xce = celestia
+// version 0xce references are encoded as:
+// [8]byte block height ++ [32]byte commitment
+// in little-endian encoding.
+// see: https://github.com/rollkit/celestia-da/blob/1f2df375fd2fcc59e425a50f7eb950daa5382ef0/celestia.go#L141-L160
+const DerivationVersionCelestia = 0xce
diff --git a/op-celestia/da_client.go b/op-celestia/da_client.go
new file mode 100644
index 000000000000..b15940ca335d
--- /dev/null
+++ b/op-celestia/da_client.go
@@ -0,0 +1,39 @@
+package celestia
+
+import (
+ "encoding/hex"
+ "fmt"
+ "time"
+
+ "github.com/rollkit/go-da"
+ "github.com/rollkit/go-da/proxy"
+)
+
+type DAClient struct {
+ Client da.DA
+ GetTimeout time.Duration
+ Namespace da.Namespace
+ FallbackMode string
+ GasPrice float64
+}
+
+func NewDAClient(rpc, token, namespace, fallbackMode string, gasPrice float64) (*DAClient, error) {
+ client, err := proxy.NewClient(rpc, token)
+ if err != nil {
+ return nil, err
+ }
+ ns, err := hex.DecodeString(namespace)
+ if err != nil {
+ return nil, err
+ }
+ if fallbackMode != "disabled" && fallbackMode != "blobdata" && fallbackMode != "calldata" {
+ return nil, fmt.Errorf("celestia: unknown fallback mode: %s", fallbackMode)
+ }
+ return &DAClient{
+ Client: client,
+ GetTimeout: time.Minute,
+ Namespace: ns,
+ FallbackMode: fallbackMode,
+ GasPrice: gasPrice,
+ }, nil
+}
diff --git a/op-e2e/system/e2esys/setup.go b/op-e2e/system/e2esys/setup.go
index fc557aa1a932..cfa0373341c4 100644
--- a/op-e2e/system/e2esys/setup.go
+++ b/op-e2e/system/e2esys/setup.go
@@ -43,6 +43,7 @@ import (
altda "github.com/ethereum-optimism/optimism/op-alt-da"
bss "github.com/ethereum-optimism/optimism/op-batcher/batcher"
batcherFlags "github.com/ethereum-optimism/optimism/op-batcher/flags"
+ celestia "github.com/ethereum-optimism/optimism/op-celestia"
"github.com/ethereum-optimism/optimism/op-chain-ops/genesis"
"github.com/ethereum-optimism/optimism/op-e2e/config"
"github.com/ethereum-optimism/optimism/op-e2e/e2eutils"
@@ -151,6 +152,7 @@ func DefaultSystemConfig(t testing.TB, opts ...SystemConfigOpt) SystemConfig {
RuntimeConfigReloadInterval: time.Minute * 10,
ConfigPersistence: &rollupNode.DisabledConfigPersistence{},
Sync: sync.Config{SyncMode: sync.CLSync},
+ DaConfig: celestia.CLIConfig{Rpc: "grpc://localhost:26650"},
},
RoleVerif: {
Driver: driver.Config{
@@ -167,6 +169,7 @@ func DefaultSystemConfig(t testing.TB, opts ...SystemConfigOpt) SystemConfig {
RuntimeConfigReloadInterval: time.Minute * 10,
ConfigPersistence: &rollupNode.DisabledConfigPersistence{},
Sync: sync.Config{SyncMode: sync.CLSync},
+ DaConfig: celestia.CLIConfig{Rpc: "grpc://localhost:26650"},
},
},
Loggers: map[string]log.Logger{
@@ -904,6 +907,7 @@ func (cfg SystemConfig) Start(t *testing.T, startOpts ...StartOption) (*System,
DataAvailabilityType: sys.Cfg.DataAvailabilityType,
CompressionAlgo: compressionAlgo,
AltDA: batcherAltDACLIConfig,
+ DaConfig: celestia.CLIConfig{Rpc: "localhost:26650"},
}
// Batch Submitter
batcher, err := bss.BatcherServiceFromCLIConfig(context.Background(), "0.0.1", batcherCLIConfig, sys.Cfg.Loggers["batcher"])
diff --git a/op-node/flags/flags.go b/op-node/flags/flags.go
index 54334c150296..8cf85a49c3a1 100644
--- a/op-node/flags/flags.go
+++ b/op-node/flags/flags.go
@@ -7,6 +7,7 @@ import (
"github.com/urfave/cli/v2"
altda "github.com/ethereum-optimism/optimism/op-alt-da"
+ celestia "github.com/ethereum-optimism/optimism/op-celestia"
"github.com/ethereum-optimism/optimism/op-node/rollup/engine"
"github.com/ethereum-optimism/optimism/op-node/rollup/sync"
openum "github.com/ethereum-optimism/optimism/op-service/enum"
@@ -441,6 +442,7 @@ func init() {
optionalFlags = append(optionalFlags, DeprecatedFlags...)
optionalFlags = append(optionalFlags, opflags.CLIFlags(EnvVarPrefix, RollupCategory)...)
optionalFlags = append(optionalFlags, altda.CLIFlags(EnvVarPrefix, AltDACategory)...)
+ optionalFlags = append(optionalFlags, celestia.CLIFlags(EnvVarPrefix)...)
Flags = append(requiredFlags, optionalFlags...)
}
diff --git a/op-node/node/config.go b/op-node/node/config.go
index a78b55853aa2..31770295f21d 100644
--- a/op-node/node/config.go
+++ b/op-node/node/config.go
@@ -8,6 +8,7 @@ import (
"time"
altda "github.com/ethereum-optimism/optimism/op-alt-da"
+ celestia "github.com/ethereum-optimism/optimism/op-celestia"
"github.com/ethereum-optimism/optimism/op-node/flags"
"github.com/ethereum-optimism/optimism/op-node/p2p"
"github.com/ethereum-optimism/optimism/op-node/rollup"
@@ -74,6 +75,8 @@ type Config struct {
// AltDA config
AltDA altda.CLIConfig
+
+ DaConfig celestia.CLIConfig
}
type RPCConfig struct {
@@ -177,6 +180,9 @@ func (cfg *Config) Check() error {
if cfg.AltDA.Enabled {
log.Warn("Alt-DA Mode is a Beta feature of the MIT licensed OP Stack. While it has received initial review from core contributors, it is still undergoing testing, and may have bugs or other issues.")
}
+ if err := cfg.DaConfig.Check(); err != nil {
+ return fmt.Errorf("da config error: %w", err)
+ }
return nil
}
diff --git a/op-node/node/node.go b/op-node/node/node.go
index 298c98aa2b18..7c38df251e9e 100644
--- a/op-node/node/node.go
+++ b/op-node/node/node.go
@@ -139,6 +139,9 @@ func (n *OpNode) init(ctx context.Context, cfg *Config) error {
if err := n.initL2(ctx, cfg); err != nil {
return fmt.Errorf("failed to init L2: %w", err)
}
+ if err := n.initDA(ctx, cfg); err != nil {
+ return fmt.Errorf("failed to init da: %w", err)
+ }
if err := n.initRuntimeConfig(ctx, cfg); err != nil { // depends on L2, to signal initial runtime values to
return fmt.Errorf("failed to init the runtime config: %w", err)
}
@@ -378,6 +381,10 @@ func (n *OpNode) initL1BeaconAPI(ctx context.Context, cfg *Config) error {
}
}
+func (n *OpNode) initDA(ctx context.Context, cfg *Config) error {
+ return driver.SetDAClient(cfg.DaConfig)
+}
+
func (n *OpNode) initL2(ctx context.Context, cfg *Config) error {
rpcClient, rpcCfg, err := cfg.L2.Setup(ctx, n.log, &cfg.Rollup)
if err != nil {
diff --git a/op-node/rollup/derive/blob_data_source.go b/op-node/rollup/derive/blob_data_source.go
index 2c4626941b8b..95e7248464dd 100644
--- a/op-node/rollup/derive/blob_data_source.go
+++ b/op-node/rollup/derive/blob_data_source.go
@@ -86,7 +86,10 @@ func (ds *BlobDataSource) open(ctx context.Context) ([]blobOrCalldata, error) {
return nil, NewTemporaryError(fmt.Errorf("failed to open blob data source: %w", err))
}
- data, hashes := dataAndHashesFromTxs(txs, &ds.dsCfg, ds.batcherAddr, ds.log)
+ data, hashes, err := dataAndHashesFromTxs(txs, &ds.dsCfg, ds.batcherAddr, ds.log)
+ if err != nil {
+ return nil, err
+ }
if len(hashes) == 0 {
// there are no blobs to fetch so we can return immediately
@@ -115,11 +118,12 @@ func (ds *BlobDataSource) open(ctx context.Context) ([]blobOrCalldata, error) {
// dataAndHashesFromTxs extracts calldata and datahashes from the input transactions and returns them. It
// creates a placeholder blobOrCalldata element for each returned blob hash that must be populated
// by fillBlobPointers after blob bodies are retrieved.
-func dataAndHashesFromTxs(txs types.Transactions, config *DataSourceConfig, batcherAddr common.Address, logger log.Logger) ([]blobOrCalldata, []eth.IndexedBlobHash) {
+func dataAndHashesFromTxs(txs types.Transactions, config *DataSourceConfig, batcherAddr common.Address, logger log.Logger) ([]blobOrCalldata, []eth.IndexedBlobHash, error) {
data := []blobOrCalldata{}
var hashes []eth.IndexedBlobHash
blobIndex := 0 // index of each blob in the block's blob sidecar
for _, tx := range txs {
+ logger := log.New("tx", tx.Hash())
// skip any non-batcher transactions
if !isValidBatchTx(tx, config.l1Signer, config.batchInboxAddress, batcherAddr, logger) {
blobIndex += len(tx.BlobHashes())
@@ -127,8 +131,15 @@ func dataAndHashesFromTxs(txs types.Transactions, config *DataSourceConfig, batc
}
// handle non-blob batcher transactions by extracting their calldata
if tx.Type() != types.BlobTxType {
- calldata := eth.Data(tx.Data())
- data = append(data, blobOrCalldata{nil, &calldata})
+ calldata, err := DataFromEVMTransactions(*config, batcherAddr, types.Transactions{tx}, logger)
+ if err != nil {
+ return nil, nil, err
+ }
+ if len(calldata) == 0 {
+ log.Warn("celestia: skipping empty calldata")
+ continue
+ }
+ data = append(data, blobOrCalldata{nil, &calldata[0]})
continue
}
// handle blob batcher transactions by extracting their blob hashes, ignoring any calldata.
@@ -145,7 +156,7 @@ func dataAndHashesFromTxs(txs types.Transactions, config *DataSourceConfig, batc
blobIndex += 1
}
}
- return data, hashes
+ return data, hashes, nil
}
// fillBlobPointers goes back through the data array and fills in the pointers to the fetched blob
diff --git a/op-node/rollup/derive/blob_data_source_test.go b/op-node/rollup/derive/blob_data_source_test.go
index e5e31dc957b9..885fbdf0684d 100644
--- a/op-node/rollup/derive/blob_data_source_test.go
+++ b/op-node/rollup/derive/blob_data_source_test.go
@@ -45,7 +45,8 @@ func TestDataAndHashesFromTxs(t *testing.T) {
}
calldataTx, _ := types.SignNewTx(privateKey, signer, txData)
txs := types.Transactions{calldataTx}
- data, blobHashes := dataAndHashesFromTxs(txs, &config, batcherAddr, logger)
+ data, blobHashes, err := dataAndHashesFromTxs(txs, &config, batcherAddr, logger)
+ require.NoError(t, err)
require.Equal(t, 1, len(data))
require.Equal(t, 0, len(blobHashes))
@@ -60,14 +61,16 @@ func TestDataAndHashesFromTxs(t *testing.T) {
}
blobTx, _ := types.SignNewTx(privateKey, signer, blobTxData)
txs = types.Transactions{blobTx}
- data, blobHashes = dataAndHashesFromTxs(txs, &config, batcherAddr, logger)
+ data, blobHashes, err = dataAndHashesFromTxs(txs, &config, batcherAddr, logger)
+ require.NoError(t, err)
require.Equal(t, 1, len(data))
require.Equal(t, 1, len(blobHashes))
require.Nil(t, data[0].calldata)
// try again with both the blob & calldata transactions and make sure both are picked up
txs = types.Transactions{blobTx, calldataTx}
- data, blobHashes = dataAndHashesFromTxs(txs, &config, batcherAddr, logger)
+ data, blobHashes, err = dataAndHashesFromTxs(txs, &config, batcherAddr, logger)
+ require.NoError(t, err)
require.Equal(t, 2, len(data))
require.Equal(t, 1, len(blobHashes))
require.NotNil(t, data[1].calldata)
@@ -75,7 +78,8 @@ func TestDataAndHashesFromTxs(t *testing.T) {
// make sure blob tx to the batch inbox is ignored if not signed by the batcher
blobTx, _ = types.SignNewTx(testutils.RandomKey(), signer, blobTxData)
txs = types.Transactions{blobTx}
- data, blobHashes = dataAndHashesFromTxs(txs, &config, batcherAddr, logger)
+ data, blobHashes, err = dataAndHashesFromTxs(txs, &config, batcherAddr, logger)
+ require.NoError(t, err)
require.Equal(t, 0, len(data))
require.Equal(t, 0, len(blobHashes))
@@ -84,7 +88,8 @@ func TestDataAndHashesFromTxs(t *testing.T) {
blobTxData.To = testutils.RandomAddress(rng)
blobTx, _ = types.SignNewTx(privateKey, signer, blobTxData)
txs = types.Transactions{blobTx}
- data, blobHashes = dataAndHashesFromTxs(txs, &config, batcherAddr, logger)
+ data, blobHashes, err = dataAndHashesFromTxs(txs, &config, batcherAddr, logger)
+ require.NoError(t, err)
require.Equal(t, 0, len(data))
require.Equal(t, 0, len(blobHashes))
}
diff --git a/op-node/rollup/derive/calldata_source.go b/op-node/rollup/derive/calldata_source.go
index 0e8147261e93..ab95b06d54a8 100644
--- a/op-node/rollup/derive/calldata_source.go
+++ b/op-node/rollup/derive/calldata_source.go
@@ -2,6 +2,7 @@ package derive
import (
"context"
+ "encoding/hex"
"errors"
"fmt"
"io"
@@ -11,9 +12,20 @@ import (
"github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/log"
+ celestia "github.com/ethereum-optimism/optimism/op-celestia"
"github.com/ethereum-optimism/optimism/op-service/eth"
)
+var daClient *celestia.DAClient
+
+func SetDAClient(c *celestia.DAClient) error {
+ if daClient != nil {
+ return errors.New("da client already configured")
+ }
+ daClient = c
+ return nil
+}
+
// CalldataSource is a fault tolerant approach to fetching data.
// The constructor will never fail & it will instead re-attempt the fetcher
// at a later point.
@@ -32,7 +44,7 @@ type CalldataSource struct {
// NewCalldataSource creates a new calldata source. It suppresses errors in fetching the L1 block if they occur.
// If there is an error, it will attempt to fetch the result on the next call to `Next`.
-func NewCalldataSource(ctx context.Context, log log.Logger, dsCfg DataSourceConfig, fetcher L1TransactionFetcher, ref eth.L1BlockRef, batcherAddr common.Address) DataIter {
+func NewCalldataSource(ctx context.Context, log log.Logger, dsCfg DataSourceConfig, fetcher L1TransactionFetcher, ref eth.L1BlockRef, batcherAddr common.Address) (DataIter, error) {
_, txs, err := fetcher.InfoAndTxsByHash(ctx, ref.Hash)
if err != nil {
return &CalldataSource{
@@ -42,12 +54,23 @@ func NewCalldataSource(ctx context.Context, log log.Logger, dsCfg DataSourceConf
fetcher: fetcher,
log: log,
batcherAddr: batcherAddr,
- }
+ }, nil
+ }
+ data, err := DataFromEVMTransactions(dsCfg, batcherAddr, txs, log.New("origin", ref))
+ if err != nil {
+ return &CalldataSource{
+ open: false,
+ ref: ref,
+ dsCfg: dsCfg,
+ fetcher: fetcher,
+ log: log,
+ batcherAddr: batcherAddr,
+ }, err
}
return &CalldataSource{
open: true,
- data: DataFromEVMTransactions(dsCfg, batcherAddr, txs, log.New("origin", ref)),
- }
+ data: data,
+ }, nil
}
// Next returns the next piece of data if it has it. If the constructor failed, this
@@ -57,7 +80,11 @@ func (ds *CalldataSource) Next(ctx context.Context) (eth.Data, error) {
if !ds.open {
if _, txs, err := ds.fetcher.InfoAndTxsByHash(ctx, ds.ref.Hash); err == nil {
ds.open = true
- ds.data = DataFromEVMTransactions(ds.dsCfg, ds.batcherAddr, txs, ds.log)
+ ds.data, err = DataFromEVMTransactions(ds.dsCfg, ds.batcherAddr, txs, ds.log)
+ if err != nil {
+ // already wrapped
+ return nil, err
+ }
} else if errors.Is(err, ethereum.NotFound) {
return nil, NewResetError(fmt.Errorf("failed to open calldata source: %w", err))
} else {
@@ -76,12 +103,38 @@ func (ds *CalldataSource) Next(ctx context.Context) (eth.Data, error) {
// DataFromEVMTransactions filters all of the transactions and returns the calldata from transactions
// that are sent to the batch inbox address from the batch sender address.
// This will return an empty array if no valid transactions are found.
-func DataFromEVMTransactions(dsCfg DataSourceConfig, batcherAddr common.Address, txs types.Transactions, log log.Logger) []eth.Data {
+func DataFromEVMTransactions(dsCfg DataSourceConfig, batcherAddr common.Address, txs types.Transactions, log log.Logger) ([]eth.Data, error) {
out := []eth.Data{}
for _, tx := range txs {
if isValidBatchTx(tx, dsCfg.l1Signer, dsCfg.batchInboxAddress, batcherAddr, log) {
- out = append(out, tx.Data())
+ data := tx.Data()
+ switch len(data) {
+ case 0:
+ out = append(out, data)
+ default:
+ switch data[0] {
+ case celestia.DerivationVersionCelestia:
+ log.Info("celestia: blob request", "id", hex.EncodeToString(tx.Data()))
+ ctx, cancel := context.WithTimeout(context.Background(), daClient.GetTimeout)
+ blobs, err := daClient.Client.Get(ctx, [][]byte{data[1:]}, daClient.Namespace)
+ cancel()
+ if err != nil {
+ return nil, NewResetError(fmt.Errorf("celestia: failed to resolve frame: %w", err))
+ }
+ if len(blobs) != 1 {
+ log.Warn("celestia: unexpected length for blobs", "expected", 1, "got", len(blobs))
+ if len(blobs) == 0 {
+ log.Warn("celestia: skipping empty blobs")
+ continue
+ }
+ }
+ out = append(out, blobs[0])
+ default:
+ out = append(out, data)
+ log.Info("celestia: using eth fallback")
+ }
+ }
}
}
- return out
+ return out, nil
}
diff --git a/op-node/rollup/derive/calldata_source_test.go b/op-node/rollup/derive/calldata_source_test.go
index 01b2616cca3f..7dc17c6aa19f 100644
--- a/op-node/rollup/derive/calldata_source_test.go
+++ b/op-node/rollup/derive/calldata_source_test.go
@@ -121,8 +121,10 @@ func TestDataFromEVMTransactions(t *testing.T) {
}
}
- out := DataFromEVMTransactions(DataSourceConfig{cfg.L1Signer(), cfg.BatchInboxAddress, false}, batcherAddr, txs, testlog.Logger(t, log.LevelCrit))
+ out, err := DataFromEVMTransactions(DataSourceConfig{cfg.L1Signer(), cfg.BatchInboxAddress, false}, batcherAddr, txs, testlog.Logger(t, log.LevelCrit))
+ require.NoError(t, err)
require.ElementsMatch(t, expectedData, out)
+ require.NoError(t, err)
}
}
diff --git a/op-node/rollup/derive/data_source.go b/op-node/rollup/derive/data_source.go
index 8d064a7cdb8c..50f71467f232 100644
--- a/op-node/rollup/derive/data_source.go
+++ b/op-node/rollup/derive/data_source.go
@@ -68,13 +68,17 @@ func (ds *DataSourceFactory) OpenData(ctx context.Context, ref eth.L1BlockRef, b
// Creates a data iterator from blob or calldata source so we can forward it to the altDA source
// if enabled as it still requires an L1 data source for fetching input commmitments.
var src DataIter
+ var err error
if ds.ecotoneTime != nil && ref.Time >= *ds.ecotoneTime {
if ds.blobsFetcher == nil {
return nil, fmt.Errorf("ecotone upgrade active but beacon endpoint not configured")
}
src = NewBlobDataSource(ctx, ds.log, ds.dsCfg, ds.fetcher, ds.blobsFetcher, ref, batcherAddr)
} else {
- src = NewCalldataSource(ctx, ds.log, ds.dsCfg, ds.fetcher, ref, batcherAddr)
+ src, err = NewCalldataSource(ctx, ds.log, ds.dsCfg, ds.fetcher, ref, batcherAddr)
+ if err != nil {
+ return src, err
+ }
}
if ds.dsCfg.altDAEnabled {
// altDA([calldata | blobdata](l1Ref)) -> data
diff --git a/op-node/rollup/driver/da.go b/op-node/rollup/driver/da.go
new file mode 100644
index 000000000000..6fa2cd750456
--- /dev/null
+++ b/op-node/rollup/driver/da.go
@@ -0,0 +1,25 @@
+package driver
+
+import (
+ celestia "github.com/ethereum-optimism/optimism/op-celestia"
+ "github.com/ethereum-optimism/optimism/op-node/rollup/derive"
+)
+
+func SetDAClient(cfg celestia.CLIConfig) error {
+ // NOTE: we always read using blob_data_source.go
+ // If the transaction has calldata, based on the prefix byte.
+ // - If the prefix byte is 0xce
+ // - We interpret the calldata as a celestia reference and fetch
+ // the data from celestia.
+ // - Otherwise, we use the calldata fallback mode.
+ // If the transaction has blobs, we use blobdata fallback mode.
+ // See dataAndHashesFromTxs and DataFromEVMTransactions
+ // The read path always operates in the most permissive mode and is
+ // independent of the fallback mode.
+ // Therefore the configuration value for FallbackMode passed here does not matter.
+ client, err := celestia.NewDAClient(cfg.Rpc, cfg.AuthToken, cfg.Namespace, cfg.FallbackMode, cfg.GasPrice)
+ if err != nil {
+ return err
+ }
+ return derive.SetDAClient(client)
+}
diff --git a/op-node/service.go b/op-node/service.go
index b24e2a638335..a2add986385f 100644
--- a/op-node/service.go
+++ b/op-node/service.go
@@ -18,6 +18,7 @@ import (
"github.com/ethereum/go-ethereum/log"
"github.com/urfave/cli/v2"
+ celestia "github.com/ethereum-optimism/optimism/op-celestia"
"github.com/ethereum-optimism/optimism/op-node/flags"
"github.com/ethereum-optimism/optimism/op-node/node"
p2pcli "github.com/ethereum-optimism/optimism/op-node/p2p/cli"
@@ -112,7 +113,8 @@ func NewConfig(ctx *cli.Context, log log.Logger) (*node.Config, error) {
ConductorRpc: ctx.String(flags.ConductorRpcFlag.Name),
ConductorRpcTimeout: ctx.Duration(flags.ConductorRpcTimeoutFlag.Name),
- AltDA: altda.ReadCLIConfig(ctx),
+ AltDA: altda.ReadCLIConfig(ctx),
+ DaConfig: celestia.ReadCLIConfig(ctx),
}
if err := cfg.LoadPersisted(log); err != nil {
diff --git a/ops-bedrock/docker-compose.yml b/ops-bedrock/docker-compose.yml
index adcaea8f4d1b..c1902e972734 100644
--- a/ops-bedrock/docker-compose.yml
+++ b/ops-bedrock/docker-compose.yml
@@ -14,6 +14,16 @@ volumes:
services:
+ da:
+ image: ghcr.io/rollkit/local-celestia-devnet:v0.13.1
+ ports:
+ - "26658:26658"
+ healthcheck:
+ test: ["CMD", "curl", "-f", "http://localhost:26659/header/1"]
+ interval: 10s
+ timeout: 5s
+ retries: 5
+ start_period: 30s
l1:
build:
@@ -94,6 +104,7 @@ services:
- l1-bn
- l1-vc
- l2
+ - da
build:
context: ../
dockerfile: ops/docker/op-stack-go/Dockerfile
@@ -102,9 +113,7 @@ services:
command: >
op-node
--l1=ws://l1:8546
- --l1.beacon=http://l1-bn:5052
- --l1.epoch-poll-interval=12s
- --l1.http-poll-interval=6s
+ --l1.beacon.ignore
--l2=http://l2:8551
--l2.jwt-secret=/config/jwt-secret.txt
--sequencer.enabled
@@ -129,6 +138,10 @@ services:
--altda.enabled=${ALTDA_ENABLED}
--altda.da-service=${ALTDA_SERVICE}
--altda.da-server=http://da-server:3100
+ environment:
+ OP_NODE_DA_RPC: "http://da:26658"
+ OP_NODE_DA_AUTH_TOKEN: "${CELESTIA_NODE_AUTH_TOKEN}"
+ OP_NODE_DA_NAMESPACE: "00000000000000000000000000000000000000000008e5f679bf7116cb"
ports:
- "7545:8545"
- "9003:9003"
@@ -177,6 +190,7 @@ services:
- l1
- l2
- op-node
+ - da
build:
context: ../
dockerfile: ops/docker/op-stack-go/Dockerfile
@@ -190,7 +204,8 @@ services:
OP_BATCHER_L1_ETH_RPC: http://l1:8545
OP_BATCHER_L2_ETH_RPC: http://l2:8545
OP_BATCHER_ROLLUP_RPC: http://op-node:8545
- OP_BATCHER_MAX_CHANNEL_DURATION: 2
+ OFFLINE_GAS_ESTIMATION: null
+ OP_BATCHER_MAX_CHANNEL_DURATION: 1
OP_BATCHER_SUB_SAFETY_MARGIN: 4 # SWS is 15, ChannelTimeout is 40
OP_BATCHER_POLL_INTERVAL: 1s
OP_BATCHER_NUM_CONFIRMATIONS: 1
@@ -203,7 +218,9 @@ services:
OP_BATCHER_ALTDA_ENABLED: "${ALTDA_ENABLED}"
OP_BATCHER_ALTDA_DA_SERVICE: "${ALTDA_SERVICE}"
OP_BATCHER_ALTDA_DA_SERVER: "http://da-server:3100"
- OP_BATCHER_DATA_AVAILABILITY_TYPE: "${DA_TYPE}"
+ OP_BATCHER_DA_RPC: "http://da:26658"
+ OP_BATCHER_DA_AUTH_TOKEN: "${CELESTIA_NODE_AUTH_TOKEN}"
+ OP_BATCHER_DA_NAMESPACE: "00000000000000000000000000000000000000000008e5f679bf7116cb"
op-challenger:
depends_on:
diff --git a/ops/docker/op-stack-go/Dockerfile.dockerignore b/ops/docker/op-stack-go/Dockerfile.dockerignore
index 1c0841df1f33..c26cffc94db1 100644
--- a/ops/docker/op-stack-go/Dockerfile.dockerignore
+++ b/ops/docker/op-stack-go/Dockerfile.dockerignore
@@ -5,6 +5,7 @@
!/cannon
!/op-batcher
!/op-bootnode
+!/op-celestia
!/op-chain-ops
!/op-challenger
!/packages/contracts-bedrock/snapshots