Skip to content

Commit

Permalink
Update access node indexing setup with checkpoint details (#881)
Browse files Browse the repository at this point in the history
* Update access node indexing setup with checkpoint details

* Apply suggestions from code review

Co-authored-by: Vishal <[email protected]>

---------

Co-authored-by: Vishal <[email protected]>
  • Loading branch information
peterargue and vishalchangrani authored Sep 3, 2024
1 parent 48dfa1f commit a0d741a
Showing 1 changed file with 42 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ Store the **`root-protocol-state-snapshot.json`** into the **`/bootstrap/public-

### Download the root checkpoint

The root checkpoint for the network is by Execution nodes (and now Access nodes), to bootstrap their local execution state database with a known trusted snapshot. The checkpoint contains 18 files that make up the merkle trie used to store the blockchain’s state.
The root checkpoint for the network is used by Execution nodes and Access nodes to bootstrap their local execution state database with a known trusted snapshot. The checkpoint contains 18 files that make up the merkle trie used to store the blockchain’s state.

The root checkpoint for each spork is hosted in GCP. You can find the link for the specific network in the [`sporks.json`](https://github.com/onflow/flow/blob/master/sporks.json) file. Here’s the URL for `mainnet24`:

Expand All @@ -78,21 +78,57 @@ The URL in that file will point to a file named `root.checkpoint`. This is the b
gsutil -m cp "gs://flow-genesis-bootstrap/[network]-execution/public-root-information/root.checkpoint*" .
```

Where `[network]` is the network you are downloading for. For example, `mainnet-24` or `testnet-49`.

Once the files are downloaded, you can either move them to `/bootstrap/execution-state/` within the node’s bootstrap directory or put them in any mounted directory and reference the location with this cli flag: `--execution-state-checkpoint=/path/to/root.checkpoint`. The naming of files should be `root.checkpoint.*`.

## **Option 2: Enabling Indexing Mid-Spork**

### Download the root protocol state snapshot
### Identify the root checkpoint

You can download  `root-protocol-state-snapshot.json` file by using the `GetProtocolStateSnapshotByHeight` call with the corresponding height. You will get a `base64` encoded snapshot which you will need to decode.
The root checkpoint for the network is used by Execution and Access nodes to bootstrap their local execution state database with a known trusted snapshot. The checkpoint contains 18 files that make up the merkle trie used to store the blockchain’s state.

Store the **`root-protocol-state-snapshot.json`** into the **`/bootstrap/public-root-information/`** folder.
Root checkpoints are periodically generated on Flow Foundation execution nodes and uploaded to a GCP bucket. You can see
a list of available checkpoints [here](https://console.cloud.google.com/storage/browser/flow-genesis-bootstrap/checkpoints),
or list them using the [gsutil](https://cloud.google.com/storage/docs/gsutil) command

```bash
gsutil ls "gs://flow-genesis-bootstrap/checkpoints/"
```

The checkpoint paths are in the format `flow-genesis-bootstrap/checkpoints/[network]/[epoch number]-[block height]/`.
Where
* `[network]` is the network the checkpoint is from. For example, `mainnet` or `testnet`.
* `[epoch number]` is the epoch number when the checkpoint was taken. You can find the current epoch number on the [flowdiver](https://www.flowdiver.io/) home page.
* `[block height]` is the block height at which the checkpoint was taken.
Make sure that the checkpoint you select is from an epoch when your node was part of the network.

### Download the root checkpoint

You will need to download checkpoint files for the corresponding height which is the same as was for downloading the root protocol state snapshot. This is important cause in other cases you will get the error described in the Troubleshooting section.
Once you have selected the checkpoint to download, you can download the files. If you have `gsutil` installed, you can download them all easily with the following command.

```bash
gsutil -m cp "gs://flow-genesis-bootstrap/checkpoints/[network]/[epoch number]-[block height]/root.checkpoint*" .
```

Once the files are downloaded, you can either move them to `/bootstrap/execution-state/` within the node’s bootstrap directory or put them in any mounted directory and reference the location with this cli flag: `--execution-state-checkpoint=/path/to/root.checkpoint`. The naming of files should be `root.checkpoint*`.

### Download the root protocol state snapshot

Access nodes require that the data in the root checkpoint corresponds to the root block in the `root-protocol-state-snapshot.json` file.
It's important to download the snapshot for the correct height, otherwise bootstrapping will fail with an error described in the Troubleshooting section.

You can download the `root-protocol-state-snapshot.json` file generated by the Execution from the same GCP bucket.

```bash
gsutil cp "gs://flow-genesis-bootstrap/checkpoints/[network]/[epoch number]-[block height]/root-protocol-state-snapshot.json" .
```

Alternatively, you can download it directly from a trusted Access node using the `GetProtocolStateSnapshotByHeight` gRPC endpoint
with the corresponding height. You will get a `base64` encoded snapshot which decodes into a json object. At this time, this endpoint is only support using the grpc API.

Store the **`root-protocol-state-snapshot.json`** into the **`/bootstrap/public-root-information/`** folder.

Once the files are downloaded, you can either move them to `/bootstrap/execution-state/` within the node’s bootstrap directory or put them in any mounted directory and reference the location with this cli flag: `--execution-state-checkpoint=/path/to/root.checkpoint`. The naming of files should be `root.checkpoint.*`.

# Configure the node to run the indexer

Expand Down

0 comments on commit a0d741a

Please sign in to comment.