celestia

package module
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 5, 2024 License: Apache-2.0 Imports: 15 Imported by: 0

README

Plasma x Celestia:

Overview:

This repo implements a celestia da-server for plasma mode using generic commitments.

The da-server connects to a celestia-node running as a sidecar process.

celestia da-server accepts the following flags for celestia storage using celestia-openrpc

    --celestia.auth-token value                                            ($OP_PLASMA_DA_SERVER_CELESTIA_AUTH_TOKEN)
          celestia auth token

    --celestia.namespace value                                             ($OP_PLASMA_DA_SERVER_CELESTIA_NAMESPACE)
          celestia namespace

    --celestia.server value             (default: "http://localhost:26658") ($OP_PLASMA_DA_SERVER_CELESTIA_SERVER)
          celestia server endpoint

The celestia server endpoint should be set to the celestia-node rpc server, usually http://127.0.0.1:26658.

A random valid namespace can be generated by running the following command:

export NAMESPACE=00000000000000000000000000000000000000$(openssl rand -hex 10)

The auth token is auto generated and is required to submit blob transactions to the celestia-node.

Testing:

Follow the usual instructions for setting up devnet.

There are two ways to test the celestia da-server in devnet and testnet modes.

Using rollop:

The first way uses a fork of rollop to automate deployment. This method is recommended for beginners.

Clone the rollop repository, checkout the plasma branch and follow the instructions in the README to setup the rollop stack.

git clone https://github.com/tuxcanfly/roll-op.git
cd roll-op
git checkout plasma
./rollop setup --yes

rollop is configured to use mocha-4 celestia network by default in both devnet and testnet modes.

Devnet

Once the rollop stack is setup, you can start the devnet with the following command:

./rollop --clean devnet

This will start the devnet in plasma mode with celestia-node running in testnet mode.

You can verify that the devnet is running by checking da-server logs:

tail -f deployments/rollup/logs/da_server.log

Upon successful operation, the logs should contain the following message:

t=2024-05-30T19:08:30+0000 lvl=info msg="Using celestia storage" url=http://da:26658
t=2024-05-30T19:08:32+0000 lvl=info msg="celestia: blob successfully submitted" id=0900000000000000b25a32154ab00902cfc0269b3239b612ebfe7f7263545119ee7251cc72728142
t=2024-05-30T19:08:34+0000 lvl=info msg="celestia: blob successfully submitted" id=0a00000000000000cb559bc3c6a01b0819460ce86c13165fdc58ac9c81c1e52404f8c4b36097db87
t=2024-05-30T19:08:34+0000 lvl=info msg="celestia: blob request" id=010c0900000000000000b25a32154ab00902cfc0269b3239b612ebfe7f7263545119ee7251cc72728142
Testnet

Copy example config config.toml.example to config.toml and update any fields as required.

Next start the testnet with the following command:

./rollop --name=celopstia-11177111 --preset=prod --config=config.toml l2

You can verify that the testnet is running by checking da-server logs:

tail -f deployments/celopstia-11177111/logs/da_server.log

Upon successful operation, the logs should contain the following message:

t=2024-06-03T21:36:32+0000 lvl=info msg="Using celestia storage" url=http://127.0.0.1:26658
t=2024-06-03T21:36:32+0000 lvl=info msg="Started DA Server"
t=2024-06-03T21:37:16+0000 lvl=debug msg=PUT url=/put/
t=2024-06-03T21:37:19+0000 lvl=info msg="celestia: blob successfully submitted" id=430f1e0000000000f34842f2c61d3b1fc1fad749ed442320fdce7023669f3116ea8df024ce792b7f
t=2024-06-03T21:38:23+0000 lvl=debug msg=PUT url=/put/
t=2024-06-03T21:38:28+0000 lvl=debug msg=GET url=/get/0x010c430f1e0000000000f34842f2c61d3b1fc1fad749ed442320fdce7023669f3116ea8df024ce792b7f
t=2024-06-03T21:38:28+0000 lvl=info msg="celestia: blob request" id=010c430f1e0000000000f34842f2c61d3b1fc1fad749ed442320fdce7023669f3116ea8df024ce792b7f

To configure the da-server to use a different namespace, update the da_namespace field in config.toml.

To configure the da-server to use a different celestia network, you'll need to update the --p2p.network flag in l2_batcher.py, l2_node.py and celestia_light_node.py for now. This will be configurable in the future.

Troubleshooting:

Check the logs for the da-server to see if it is running successfully:

tail -f deployments/rollup/logs/da_server.log

Additionally verify that the batcher is able to submit transactions to the celestia-node:

tail -f deployments/rollup/logs/l2_batcher.log
Using docker-compose:

The second way to test the celestia da-server uses docker-compose to deploy the rollup stack. This method reuses the bedrock devnet docker-compose setup and is recommended for developers.

Devnet:

For testing devnet, we'll use the local-celestia-devnet docker image which simulates the whole celestia network including a local celestia-node and does not require a peer-to-peer connection.

To run a local devnet with local-celestia-devnet:

DEVNET_PLASMA="true" GENERIC_PLASMA="true"  make devnet-up

This will start the devnet in plasma mode with local-celestia-devnet.

You can verify that the devnet is running by checking da-server logs:

docker logs -f ops-da-server-1 | grep celestia

Upon successful operation, the logs should contain the following message:

t=2024-05-30T19:08:30+0000 lvl=info msg="Using celestia storage" url=http://da:26658
t=2024-05-30T19:08:32+0000 lvl=info msg="celestia: blob successfully submitted" id=0900000000000000b25a32154ab00902cfc0269b3239b612ebfe7f7263545119ee7251cc72728142
t=2024-05-30T19:08:34+0000 lvl=info msg="celestia: blob successfully submitted" id=0a00000000000000cb559bc3c6a01b0819460ce86c13165fdc58ac9c81c1e52404f8c4b36097db87
t=2024-05-30T19:08:34+0000 lvl=info msg="celestia: blob request" id=010c0900000000000000b25a32154ab00902cfc0269b3239b612ebfe7f7263545119ee7251cc72728142
Testnet:

Usually, it's better to deploy both OP stack and celestia-node in the same network, but for ease of testing, we will modify the devnet docker-compose file to submit to celestia testnet instead.

For running plasma in celestia testnet mode, we'll use the celestia-node docker image which requires a celestia testnet network like mocha or arabica.

To run a celestia-node in testnet mode, follow the instructions for setting up a light node and changes required to the docker-compose file

Note that in this case, the auth token needs to be configured using the CELESTIA_NODE_AUTH_TOKEN environment variable.

To obtain the auth token for celestia-node, check the documentation for the node type you are using

Once the docker compose file is modified, you can run the devnet with the following command:

DEVNET_PLASMA="true" GENERIC_PLASMA="true"  make devnet-up

This will start the devnet in plasma mode with celestia-node running in testnet mode.

You can verify that the devnet is running by checking da-server logs:

docker logs -f ops-bedrock-da-server-1 | grep celestia

Once again, upon successful operation, the logs should contain the following message:

t=2024-05-30T19:08:30+0000 lvl=info msg="Using celestia storage" url=http://da:26658
t=2024-05-30T19:08:32+0000 lvl=info msg="celestia: blob successfully submitted" id=0900000000000000b25a32154ab00902cfc0269b3239b612ebfe7f7263545119ee7251cc72728142
t=2024-05-30T19:08:34+0000 lvl=info msg="celestia: blob successfully submitted" id=0a00000000000000cb559bc3c6a01b0819460ce86c13165fdc58ac9c81c1e52404f8c4b36097db87
t=2024-05-30T19:08:34+0000 lvl=info msg="celestia: blob request" id=010c0900000000000000b25a32154ab00902cfc0269b3239b612ebfe7f7263545119ee7251cc72728142

As an alternative, you may wish to deploy OP stack and celestia-node both to testnets e.g. sepolia and mocha.

In this case, run a celestia light node and da-server, then follow the instructions for creating your own L2 rollup testnet including the following flags:

op-node
      --plasma.enabled=true
      --plasma.da-service=true
op-batcher
      --plasma.enabled=true
      --plasma.da-service=true
da-server
      --generic-commitment=true
      --celestia.server=http://localhost:26658
      --celestia.auth-token=$CELESTIA_NODE_AUTH_TOKEN
      --celestia.namespace=$NAMESPACE

where $CELESTIA_NODE_AUTH_TOKEN is the auth token for the celestia-node and $NAMESPACE is a random valid namespace.

Troubleshooting:

Check the logs for the da-server to see if it is running successfully:

docker logs -f ops-bedrock-da-server-1

Additionally verify that the batcher is able to submit transactions to the celestia-node:

docker logs -f ops-bedrock-op-batcher-1

Documentation

Index

Constants

View Source
const VersionByte = 0x0c

Variables

This section is empty.

Functions

This section is empty.

Types

type CelestiaConfig

type CelestiaConfig struct {
	URL       string
	AuthToken string
	Namespace []byte
}

type CelestiaServer

type CelestiaServer struct {
	// contains filtered or unexported fields
}

func NewCelestiaServer

func NewCelestiaServer(host string, port int, store *CelestiaStore, log log.Logger) *CelestiaServer

func (*CelestiaServer) Endpoint

func (b *CelestiaServer) Endpoint() string

func (*CelestiaServer) HandleGet

func (d *CelestiaServer) HandleGet(w http.ResponseWriter, r *http.Request)

func (*CelestiaServer) HandlePut

func (d *CelestiaServer) HandlePut(w http.ResponseWriter, r *http.Request)

func (*CelestiaServer) Start

func (d *CelestiaServer) Start() error

func (*CelestiaServer) Stop

func (b *CelestiaServer) Stop() error

type CelestiaStore

type CelestiaStore struct {
	Log        log.Logger
	GetTimeout time.Duration
	Namespace  []byte
	Client     *client.Client
}

CelestiaStore implements DAStorage with celestia backend

func NewCelestiaStore

func NewCelestiaStore(cfg CelestiaConfig) *CelestiaStore

NewCelestiaStore returns a celestia store.

func (*CelestiaStore) Get

func (d *CelestiaStore) Get(ctx context.Context, key []byte) ([]byte, error)

func (*CelestiaStore) Put

func (d *CelestiaStore) Put(ctx context.Context, data []byte) ([]byte, error)

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL