From 716d490e3c246cd49b756229c8e6526fbc70a1ba Mon Sep 17 00:00:00 2001 From: Sam Bukowski Date: Wed, 24 Apr 2024 14:42:17 -0600 Subject: [PATCH] Chore: Update go cli docs (#55) ## Description Update the cli docs to reflect the most recent cli changes and workflows. --- .../tutorials/1-using-astria-go-cli.md | 94 +++++++++++++++---- 1 file changed, 77 insertions(+), 17 deletions(-) diff --git a/docs/developer/tutorials/1-using-astria-go-cli.md b/docs/developer/tutorials/1-using-astria-go-cli.md index 6f30ac85..59d8103e 100644 --- a/docs/developer/tutorials/1-using-astria-go-cli.md +++ b/docs/developer/tutorials/1-using-astria-go-cli.md @@ -1,6 +1,9 @@ # Overview -This guide will walk you through deploying a rollup full node locally against both local and remote sequencer with the Astria stack using the Astria CLI. +This guide will walk you through deploying a rollup full node locally against +both local and remote sequencer with the Astria stack using the Astria CLI. + +See the code [here](https://github.com/astriaorg/astria-cli-go). ## Download the CLI @@ -8,7 +11,7 @@ This guide will walk you through deploying a rollup full node locally against bo ```bash # download the binary for your platform, e.g. macOS silicon -curl -L https://github.com/astriaorg/astria-cli-go/releases/download/v0.4.0/astria-cli-v0.3.0-darwin-arm64.tar.gz \ +curl -L https://github.com/astriaorg/astria-cli-go/releases/download/v0.7.0/astria-go-v0.7.0-darwin-arm64.tar.gz \ --output astria-go.tar.gz # extract the binary tar -xzvf astria-go.tar.gz @@ -40,12 +43,13 @@ mv ./bin/astria-go /usr/local/bin/ astria-go version ``` -## Download and Build Geth +## Setup a Geth Rollup -Requires `Go` and `just`: +Requires `Go`, `just`, and `Foundry`: - Go: https://go.dev/doc/install - just: https://github.com/casey/just +- Foundry: https://book.getfoundry.sh/getting-started/installation ```bash git clone git@github.com:astriaorg/go-ethereum.git @@ -54,6 +58,24 @@ git checkout local-dev just build ``` +Create a new genesis account for your Geth rollup: + +```bash +cast w new +``` + +Open the `geth-genesis-local.json` file in your Geth repo and update the +`"alloc"` account with your new one: + +```json + "alloc": { + "": { "balance": "300000000000000000000" } + } +``` + +You will use the private key for your new account with the [test +transactions](#test-transactions) later on. + @@ -70,9 +92,10 @@ just init just run ``` -If you need to restart the rollup, you can use +If you need to restart the rollup, you can use: ```bash +# in go-etherium dir just clean-restart ``` @@ -87,16 +110,37 @@ astria-go dev run --local ### Initialize and Start Geth -Once you have pulled the Geth repo, you will need to update some genesis information. Open the `geth-gensis-local.json` file and update the chain ID and rollup name to something of your choosing: +Once you have [built Geth](#setup-a-geth-rollup), you will need to update some +additional genesis information to work with the remote sequencer. Run the +following using the Astira cli: + +```bash +astria-go dev init +astria-go sequencer get-blockheight +``` + +Then, open the `geth-genesis-local.json` file and update the chain ID and rollup +name to something of your choosing, as well as updating the starting block +height for your rollup: ```json "config": { + ... "chainId": <6 digit number>, - ... - "astriaRollupName": "" + "astriaRollupName": "", + "astriaSequencerInitialHeight": , + ... }, ``` +:::tip +When starting a new rollup, it is always best to use the most recent height of +the remote Sequencer. The Astria Conductor will always start syncing the rollup +from the `"astriaSequencerInitialHeight"` provided. Using older block heights +will cause your rollup to sync potentially millions of blocks that have no +relevant data for your rollup. +::: + Then initialized and start Geth: ```bash @@ -108,31 +152,35 @@ just run If you need to restart the rollup, you can use ```bash +# in go-etherium dir just clean-restart ``` ## Setup and run the Local Astria components to communicate with the Remote Sequencer +When running against the remote sequencer, you will also need to create a new +sequencer account. + ```bash astria-go dev init -astria-go sequencer get-blockheight # NOTE - this command doesn't exist yet astria-go sequencer create-account ``` Navigate to the `~/.astria` directory. If you have run the commands shown above, you should find a `default` directory. -Open the `/.astria/default/config-remote/.env` file and update the following environment variables. Use the same rollup name you used for setting up Geth above, and the block height and private key from the other two commands. +Open the `/.astria/default/config-remote/.env` file and update the following +environment variables. Use the same rollup name you used for setting up Geth +above, and the private key from the sequencer account you just created. ```bash -ASTRIA_CONDUCTOR_INITIAL_SEQUENCER_BLOCK_HEIGHT= -ASTRIA_CONDUCTOR_CHAIN_ID="" ASTRIA_COMPOSER_ROLLUPS="::ws://127.0.0.1:8546" ASTRIA_COMPOSER_PRIVATE_KEY="" ``` -You can then use the [Sequencer Faucet](https://faucet.sequencer.dusk-3.devnet.astria.org/) to fund the account you just created using the account address. +You can then use the [Sequencer Faucet](https://faucet.sequencer.dusk-4.devnet.astria.org/) to fund the account you just created using the account address. -Then run the local Astria components that will talk to the remote sequencer as follows: +Use the following command to run the local Astria components against the remote +sequencer: ```bash astria-go dev run --remote @@ -151,11 +199,14 @@ forge install cp .env.example .env ``` -Open the .env and update the chain id: +Open the .env and update the chain id and private key. The private key used here +should be the private key for the account you used when [setting up +geth](#setup-a-geth-rollup) previously: -```rust +```bash # this value should be the same as what you used for configuring Geth above CHAIN_ID=<6 digit number> +PRIVATE_KEY= ``` Save the file and then run: @@ -164,4 +215,13 @@ Save the file and then run: just generate-transactions ``` -If everything worked correctly you see the transactions going through in both the `forge` script and in the `conductor` and `composer` windows in the go cli. \ No newline at end of file +If everything worked correctly you see the transactions going through in both +the `forge` script and in the `conductor` and `composer` windows in the go cli. + +:::note +These test transactions should work if you are running everything locally with +`astria-go dev run --local` or if you are running against a remote sequencer +with `astria-go dev run --remote`. If test transactions are not going through +when running remote, the first thing to check would be the sequencer account you +created is funded and configured correctly for use with the Composer. +:::