Skip to content

Commit

Permalink
Chore: Update go cli docs (#55)
Browse files Browse the repository at this point in the history
## Description
Update the cli docs to reflect the most recent cli changes and
workflows.
  • Loading branch information
sambukowski authored Apr 24, 2024
1 parent 09618b9 commit 716d490
Showing 1 changed file with 77 additions and 17 deletions.
94 changes: 77 additions & 17 deletions docs/developer/tutorials/1-using-astria-go-cli.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
# 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

### Using curl

```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
Expand Down Expand Up @@ -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
Expand All @@ -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": {
"<you new address>": { "balance": "300000000000000000000" }
}
```

You will use the private key for your new account with the [test
transactions](#test-transactions) later on.

<!-- ## Download and Build the Messenger Rollup
tbd -->
Expand All @@ -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
```

Expand All @@ -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": "<rollup name>"
"astriaRollupName": "<your rollup name>",
"astriaSequencerInitialHeight": <sequencer block height>,
...
},
```

:::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
Expand All @@ -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=<the value found above>
ASTRIA_CONDUCTOR_CHAIN_ID="<your rollup name>"
ASTRIA_COMPOSER_ROLLUPS="<your rollup name>::ws://127.0.0.1:8546"
ASTRIA_COMPOSER_PRIVATE_KEY="<sequencer account 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
Expand All @@ -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=<your account private key>
```

Save the file and then run:
Expand All @@ -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.
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.
:::

0 comments on commit 716d490

Please sign in to comment.