Skip to content

Commit

Permalink
docs: node.store usage updates for celestia-node (#1532)
Browse files Browse the repository at this point in the history
* docs: node.store note on celestia-node-key

* docs: edit troubleshooting

* docs: edit trouble again

* docs: update node tutorial

* docs: final updates

* docs: last edit

* Apply suggestions from code review

* Apply suggestions from code review

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>

---------

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
  • Loading branch information
jcstein and coderabbitai[bot] authored Jul 19, 2024
1 parent 26c54fc commit 1551ac5
Show file tree
Hide file tree
Showing 2 changed files with 119 additions and 44 deletions.
85 changes: 41 additions & 44 deletions developers/node-tutorial.md
Original file line number Diff line number Diff line change
Expand Up @@ -245,8 +245,14 @@ Where:
For example, to submit a blob to Celestia, you can use this command
once your node store is set:

:::note
Previously, the `node.store` flag had to be specified manually for each
request. This has changed in v0.14.0+ and you can
[read more about the implementation in celestia-node troubleshooting](../nodes/celestia-node-troubleshooting.md#changing-the-location-of-your-node-store).
:::

```bash
celestia blob submit 0x42690c204d39600fddd3 'gm' --node.store $NODE_STORE
celestia blob submit 0x42690c204d39600fddd3 'gm'
```

Alternatively, you could use the `--token` flag to set your auth token:
Expand All @@ -262,7 +268,8 @@ and how to use the node store to set it.
### Basic flags

All RPC CLI commands have basic flags that can be used to
interact with the API.
interact with the API; however, none are necessary using
default configurations.

These include:

Expand Down Expand Up @@ -311,12 +318,13 @@ In order to interact with the API using RPC CLI,
you can also use your node store to set your auth token. This will
allow you to interact with the API without
setting an authentication token directly.
This is only required if you are using a non-default node store path.

To set your node store for a light node on {{constants.mochaChainId}},
To set a custom node store for a light node on {{constants.mochaChainId}},
you can use the following command:

```bash-vue
export NODE_STORE=$HOME/.celestia-light-{{constants.mochaChainId}}
export NODE_STORE=$HOME/your-custom-path/celestia-light-{{constants.mochaChainId}}
```

Then, set the `--node.store` flag to the `$NODE_STORE` variable
Expand All @@ -331,12 +339,12 @@ celestia <module> <method> [args...] --node.store $NODE_STORE
This section is for users who are using a `CELESTIA_CUSTOM` or private network.

:::tip
If you are using a private and custom network, you will **need to set
the location of the node store in your auth command.**
If you are using a private and custom network with a custom node store path,
you will **need to set the location of the node store in your auth command.**
:::

```bash
--node.store $HOME/.celestia-light-private)
--node.store $HOME/your-custom-path/.celestia-light-private
```

The above is an example from the following custom network set up with:
Expand All @@ -359,7 +367,7 @@ CELESTIA_CUSTOM=robusta-22 celestia light init

# Set auth token
export AUTH_TOKEN=$(celestia light auth admin --p2p.network private \
--node.store $HOME/.celestia-light-robusta-22)
--node.store $HOME/your-custom-path/.celestia-light-robusta-22)
```

### Submitting data
Expand All @@ -385,14 +393,13 @@ Here is an example of the format of the `blob.Submit` transaction:

```bash
celestia blob submit <hex-encoded namespace> <hex-encoded data> \
[optional: fee] [optional: gasLimit] [node store | auth token]
[optional: fee] [optional: gasLimit] [optional: node store | auth token]
```

We run the following to submit a blob to the network in hexadecimal format:

```bash
celestia blob submit 0x42690c204d39600fddd3 0x676d \
--node.store $NODE_STORE
```

We get the following output:
Expand All @@ -417,7 +424,7 @@ celestia blob submit <hex-encoded namespace> <'data'> \
And an example to submit "gm" as the plain-text data:

```bash
celestia blob submit 0x42690c204d39600fddd3 'gm' --node.store $HOME/.celestia-light-mocha-4/
celestia blob submit 0x42690c204d39600fddd3 'gm'
```

Output:
Expand Down Expand Up @@ -463,8 +470,7 @@ Here is an example command to retrieve the data from above, on `{{constants.arab
<!-- markdownlint-disable MD013 -->

```bash
celestia blob get 252614 0x42690c204d39600fddd3 IXg+08HV5RsPF3Lle8PH+B2TUGsGUsBiseflxh6wB5E= \
--node.store $NODE_STORE
celestia blob get 252614 0x42690c204d39600fddd3 IXg+08HV5RsPF3Lle8PH+B2TUGsGUsBiseflxh6wB5E=
```

Will generate the following output:
Expand All @@ -487,7 +493,7 @@ To see the base64 response, use the `--base64` flag set to `TRUE`

```bash
celestia blob get 252614 0x42690c204d39600fddd3 IXg+08HV5RsPF3Lle8PH+B2TUGsGUsBiseflxh6wB5E= \
--base64=TRUE --node.store $NODE_STORE
--base64=TRUE
```

<!-- markdownlint-enable MD013 -->
Expand All @@ -509,8 +515,7 @@ To get all blobs in the namespace at the block height, use `get-all` instead
of `get`:

```bash
celestia blob get-all 252614 0x42690c204d39600fddd3 \
--node.store $NODE_STORE
celestia blob get-all 252614 0x42690c204d39600fddd3
```

This will return the following:
Expand All @@ -532,7 +537,7 @@ To display the response in base64, use:

```bash
celestia blob get-all 252614 0x42690c204d39600fddd3 \
--base64=TRUE --node.store $NODE_STORE
--base64=TRUE
```

Which will return:
Expand Down Expand Up @@ -566,8 +571,7 @@ Learn [more about gas fees and limits](../developers/submit-data.md).
To set a higher gas price of 0.004 utia, use the `--gas.price 0.004` flag:

```bash
celestia blob submit 0x42690c204d39600fddd3 'gm' --gas.price 0.004 \
--node.store $NODE_STORE
celestia blob submit 0x42690c204d39600fddd3 'gm' --gas.price 0.004
```

You will receive the height and commitment of the block in which the
Expand All @@ -591,7 +595,7 @@ Let's query our node for the balance of its default account
key we generated above):

```bash
celestia state balance --node.store $NODE_STORE
celestia state balance
```

The response will look similar to:
Expand All @@ -612,17 +616,15 @@ The response will look similar to:
Here is an example of the format of the `balance-for-address` command:

```bash
celestia state balance-for-address <address> \
--node.store $NODE_STORE
celestia state balance-for-address <address>
```

Let's query our node for the balance of another address:

<!-- markdownlint-disable MD013 -->

```bash
celestia state balance-for-address celestia10rtd9lhel2cuh6c659l25yncl6atcyt37umard \
--node.store $NODE_STORE
celestia state balance-for-address celestia10rtd9lhel2cuh6c659l25yncl6atcyt37umard
```

The response will be the balance of the address you queried:
Expand All @@ -643,7 +645,7 @@ The response will be the balance of the address you queried:
This is an RPC call in order to get your node's peerId information:

```bash
celestia p2p info --node.store $NODE_STORE
celestia p2p info
```

The node ID is in the `ID` value from the response:
Expand Down Expand Up @@ -671,7 +673,7 @@ The node ID is in the `ID` value from the response:
This is an RPC call in order to get your node's account address:

```bash
celestia state account-address --node.store $NODE_STORE
celestia state account-address
```

Response:
Expand All @@ -689,17 +691,16 @@ Response:
Here is an example of the format of the `GetByHeight` command:

```bash
celestia header get-by-height <height> \
--node.store $NODE_STORE
celestia header get-by-height <height>
```

Now, let's get the block header information.

Here we will get the header from Block 1:

````bash
celestia header get-by-height 1 \
--node.store $NODE_STORE```
celestia header get-by-height 1
```

It will output something like this:

Expand Down Expand Up @@ -793,15 +794,13 @@ It will output something like this:
#### Combined commands
```bash
celestia share get-by-namespace "$(celestia header get-by-height 147105 \
--node.store $NODE_STORE | jq '.result.dah' -r)" 0x42690c204d39600fddd3 \
--node.store $NODE_STORE
celestia share get-by-namespace "$(celestia header get-by-height 147105 | jq '.result.dah' -r)" 0x42690c204d39600fddd3
```

#### Get data availability sampler stats

```bash
celestia das sampling-stats --node.store $NODE_STORE
celestia das sampling-stats
```

#### Transfer balance of utia to another account
Expand All @@ -817,29 +816,27 @@ recipient's address, gas fee, and gasLimit. This is what the format will
look like:
```bash
celestia state transfer $ADDRESS <amount in utia> <gas fee in utia> <gas fee in utia> \
--node.store $NODE_STORE
celestia state transfer $ADDRESS <amount in utia> <gas fee in utia> <gas fee in utia>
```
Here is an example, sending 0.1 TIA, with a gas fee of 0.008 TIA, and a gas limit of 0.08:
```bash
celestia state transfer $ADDRESS 100000 8000 80000 \
--node.store $NODE_STORE
celestia state transfer $ADDRESS 100000 8000 80000
```
If you'd just like to return the transaction hash, you can use jq:

```bash
celestia state transfer $ADDRESS 100000 8000 80000 --node.store $NODE_STORE | jq .result.txhash
celestia state transfer $ADDRESS 100000 8000 80000 | jq .result.txhash
```

#### API version

To query your node's API version, you can use the following command:
```bash
celestia node info --node.store $NODE_STORE
celestia node info
```
#### Help
Expand All @@ -850,10 +847,10 @@ To get help and view the CLI menu, use the following command:
celestia --help
```
To view help menu for a specific method, use the following command:
To view the help menu for a specific method, use the following command:
```bash
celestia <module> <method> --node.store $NODE_STORE --help
celestia <module> <method> --help
```
### Advanced example
Expand All @@ -864,8 +861,8 @@ used in `celestia share get-by-namespace`:
```bash
celestia share get-by-namespace \
"$(celestia header get-by-height 252614 --node.store $NODE_STORE | jq '.result.dah' -r)" \
0x42690c204d39600fddd3 --node.store $NODE_STORE
"$(celestia header get-by-height 252614 | jq '.result.dah' -r)" \
0x42690c204d39600fddd3
```
## Additional resources
Expand Down
78 changes: 78 additions & 0 deletions nodes/celestia-node-troubleshooting.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,33 @@ If you would like to use them anyway, you can

## Changing the location of your node store

### Background

An [enhancement has been made in v0.14.0+](https://github.com/celestiaorg/celestia-node/pull/3246)
to automate the detection of the running node, eliminating the need to
manually specify the `--node.store` flag for each RPC request.

**Assumptions:**

- The presence of a lock signifies a running node.
- Networks are ordered as Mainnet, Mocha, Arabica, private, custom.
- Node types are ordered as bridge, full, and light.
- Each network has only one running node type.
- Multiple nodes of the same network and type are prohibited
(resulting in an `Error: node: store is in use`).

**Key Points:**

- Authentication token and other flags maintain their previous behavior
and take precedence.
- Address and port details are fetched from the configuration.
- `skipAuth` allows bypassing authentication for trusted setups and follows
Unix daemon conventions.
- Non-default node store and cel-key configurations still require specific
flags in the configuration settings.

### Demonstration

In this section, we'll guide you through starting your node using a
node store in a different location than you originally started with.

Expand Down Expand Up @@ -113,6 +140,57 @@ To show the keys you should add `--keyring-dir` like this example:
--keyring-dir /home/user/celestia-<node-type>-location/keys/
```

### Examples

#### Mainnet Beta full and Mocha light

This example uses a Mainnet Beta full node and a Mocha light node. When
making the request:

```bash
❯ celestia blob get 1318129 0x42690c204d39600fddd3 0MFhYKQUi2BU+U1jxPzG7QY2BVV1lb3kiU+zAK7nUiY=
{
"result": "RPC client error: sendRequest failed: http status 401 Unauthorized unmarshaling response: EOF"
}
```

The request will go to the Mainnet Beta node, and a 401 will show in
this node's logs. Note that a 401 is expected because this blob was
posted to Mocha and neither the namespace nor the blob exist on Mainnet.

#### Mocha full and Arabica light

This example uses a Mocha full node and an Arabica light node. When
making the request:

```bash
❯ celestia blob get 1318129 0x42690c204d39600fddd3 0MFhYKQUi2BU+U1jxPzG7QY2BVV1lb3kiU+zAK7nUiY=
{
"result": {
"namespace": "AAAAAAAAAAAAAAAAAAAAAAAAAEJpDCBNOWAP3dM=",
"data": "0x676d",
"share_version": 0,
"commitment": "0MFhYKQUi2BU+U1jxPzG7QY2BVV1lb3kiU+zAK7nUiY=",
"index": 23
}
}
```

The request will go to the Mocha full node, and result shown as expected.

#### Using a custom rpc.config address

When using a custom RPC config address `0.0.0.1` and port `25231`,
the CLI accurately routes to the custom address and port, where no
node is running. It fails as expected:

```bash
❯ celestia blob get 1318129 0x42690c204d39600fddd3 0MFhYKQUi2BU+U1jxPzG7QY2BVV1lb3kiU+zAK7nUiY=
{
"result": "RPC client error: sendRequest failed: Post \"http://0.0.0.1:25231\": dial tcp 0.0.0.1:25231: connect: no route to host"
}
```

## Resetting your config

If you an encounter an error, it is likely that an old config file is present:
Expand Down

0 comments on commit 1551ac5

Please sign in to comment.