Skip to content

Commit

Permalink
Document rlp decode subcommand (#1593)
Browse files Browse the repository at this point in the history
* Document rlp decode subcommand

Signed-off-by: Alexandra Tran <alexandra.tran@consensys.net>

* minor edit

Signed-off-by: Alexandra Tran <alexandra.tran@consensys.net>

* added std in/out defaults

Signed-off-by: Alexandra Tran <alexandra.tran@consensys.net>

---------

Signed-off-by: Alexandra Tran <alexandra.tran@consensys.net>
Co-authored-by: Alexandra Tran <alexandra.tran@consensys.net>
Co-authored-by: Joan E <153745173+joaniefromtheblock@users.noreply.github.com>
  • Loading branch information
3 people committed May 17, 2024
1 parent 1c0c593 commit 3c087fe
Show file tree
Hide file tree
Showing 3 changed files with 61 additions and 11 deletions.
2 changes: 1 addition & 1 deletion docs/private-networks/how-to/configure/consensus/ibft.md
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ RLP encoding is a space-efficient object serialization scheme used in Ethereum.

#### Generate extra data

To generate the `extraData` RLP string for inclusion in the genesis file, use the [`rlp encode`](../../../../public-networks/reference/cli/subcommands.md#rlp) Besu subcommand.
To generate the `extraData` RLP string for inclusion in the genesis file, use the [`rlp encode`](../../../reference/cli/subcommands.md#encode) Besu subcommand.

```bash title="Example"
besu rlp encode --from=toEncode.json
Expand Down
2 changes: 1 addition & 1 deletion docs/private-networks/how-to/configure/consensus/qbft.md
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ RLP encoding is a space-efficient object serialization scheme used in Ethereum.

#### Generate extra data

To generate the `extraData` RLP string for inclusion in the genesis file, use the [`rlp encode`](../../../reference/cli/subcommands.md#rlp) Besu subcommand.
To generate the `extraData` RLP string for inclusion in the genesis file, use the [`rlp encode`](../../../reference/cli/subcommands.md#encode) Besu subcommand.

```bash title="Example"
besu rlp encode --from=toEncode.json --type=QBFT_EXTRA_DATA
Expand Down
68 changes: 59 additions & 9 deletions docs/private-networks/reference/cli/subcommands.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,23 +65,67 @@ The configuration file has two nested JSON nodes. The first is the `genesis` pro

Provides RLP related actions.

### `decode`

<Tabs>

<TabItem value="Syntax" label="Syntax" default>

```bash
besu rlp decode [--from=<FILE>] [--to=<FILE>] [--type=<TYPE>]
```

</TabItem>

<TabItem value="File example" label="File example">

```bash
besu rlp decode --from=ibft_extra_data.txt --to=decoded_ibft_extra_data.txt --type=IBFT_EXTRA_DATA
```

</TabItem>

<TabItem value="Standard input/output example" label="Standard input/output example">

```bash
cat ibft_extra_data.txt | besu rlp decode > decoded_ibft_extra_data.txt
```

</TabItem>

</Tabs>

Decodes the RLP hexadecimal string used as `extraData` in an
[IBFT 2.0](../../how-to/configure/consensus/ibft.md#extra-data) or
[QBFT](../../how-to/configure/consensus/qbft.md#extra-data) genesis file into a validator list.

This subcommand takes the following options:

- `from` - The file containing the RLP hexadecimal string to decode.
The default is standard input.
- `to` - The file to write the decoded validator list to.
The default is standard output.
- `type` - `IBFT_EXTRA_DATA` for an IBFT 2.0 `extraData` string, or `QBFT_EXTRA_DATA` for a QBFT
`extraData` string.
The default is `IBFT_EXTRA_DATA`.

### `encode`

<Tabs>

<TabItem value="Syntax" label="Syntax" default>

```bash
besu rlp encode [--from=<FILE>] [--to=<FILE>] [--type=<type>]
besu rlp encode [--from=<FILE>] [--to=<FILE>] [--type=<TYPE>]
```

</TabItem>

<TabItem value="File example" label="File example">

```bash
besu rlp encode --from=ibft_extra_data.json --to=extra_data_for_ibft_genesis.txt --type=IBFT_EXTRA_DATA
```
```bash
besu rlp encode --from=ibft_extra_data.json --to=extra_data_for_ibft_genesis.txt --type=IBFT_EXTRA_DATA
```

</TabItem>

Expand All @@ -95,13 +139,19 @@ cat extra_data.json | besu rlp encode > rlp.txt

</Tabs>

Encodes the RLP hexadecimal string for use in an [IBFT 2.0](../../how-to/configure/consensus/ibft.md#genesis-file) or [QBFT](../../how-to/configure/consensus/qbft.md#genesis-file) genesis file. The default type is `IBFT_EXTRA_DATA`.

Supported types are:
Encodes a validator list into an RLP hexadecimal string to use as `extraData` in an
[IBFT 2.0](../../how-to/configure/consensus/ibft.md#extra-data) or
[QBFT](../../how-to/configure/consensus/qbft.md#extra-data) genesis file.

- `IBFT_EXTRA_DATA` - The IBFT 2.0 genesis file includes the `IBFT_EXTRA_DATA` type in the [`extraData`](../../how-to/configure/consensus/ibft.md#extra-data) property.
This subcommand takes the following options:

- `QBFT_EXTRA_DATA` - The QBFT genesis file includes the `QBFT_EXTRA_DATA` type in the [`extraData`](../../how-to/configure/consensus/qbft.md#extra-data) property.
- `from` - The file containing the validator list to encode.
The default is standard input.
- `to` - The file to write the RLP-encoded hexadecimal string to.
The default is standard output.
- `type` - `IBFT_EXTRA_DATA` for an IBFT 2.0 `extraData` string, or `QBFT_EXTRA_DATA` for a QBFT
`extraData` string.
The default is `IBFT_EXTRA_DATA`.

## IBFT 2.0 extra data

Expand Down

0 comments on commit 3c087fe

Please sign in to comment.