Skip to content

Commit

Permalink
fix: generate correct markdown code
Browse files Browse the repository at this point in the history
  • Loading branch information
marcelstanley authored and gligneul committed Jan 19, 2024
1 parent 6b43910 commit 350841e
Show file tree
Hide file tree
Showing 4 changed files with 80 additions and 42 deletions.
100 changes: 67 additions & 33 deletions docs/config.md
Original file line number Diff line number Diff line change
@@ -1,134 +1,160 @@
> [!IMPORTANT]
> This file was generated by internal/config/generate. DO NOT EDIT.
<!--
File generated by internal/config/generate.
DO NOT EDIT.
-->

<!-- markdownlint-disable line_length -->
# Node Configuration

The node is configurable through environment variables.
(There is no other way to configure it.)

This file documents the configuration options.

### `CARTESI_AUTH_AWS_KMS_KEY_ID`
<!-- markdownlint-disable MD012 -->
## `CARTESI_AUTH_AWS_KMS_KEY_ID`

If set, the node will use the AWS KMS service with this key ID to sign transactions.

Must be set alongside `CARTESI_AUTH_AWS_KMS_REGION`.

* **Type:** `string`

### `CARTESI_AUTH_AWS_KMS_REGION`
## `CARTESI_AUTH_AWS_KMS_REGION`

An AWS KMS Region.

Must be set alongside `CARTESI_AUTH_AWS_KMS_KEY_ID`.

* **Type:** `string`

### `CARTESI_AUTH_MNEMONIC`
## `CARTESI_AUTH_MNEMONIC`

The node will use the private key generated from this mnemonic to sign transactions.

Overrides `CARTESI_AUTH_MNEMONIC_FILE` and `CARTESI_AUTH_AWS_KMS_*`.

* **Type:** `string`

### `CARTESI_AUTH_MNEMONIC_ACCOUNT_INDEX`
## `CARTESI_AUTH_MNEMONIC_ACCOUNT_INDEX`

When using mnemonics to sign transactions,
the node will use this account index to generate the private key.

* **Type:** `int`
* **Default:** `"0"`

### `CARTESI_AUTH_MNEMONIC_FILE`
## `CARTESI_AUTH_MNEMONIC_FILE`

The node will use the private key generated from the mnemonic contained in this file
to sign transactions.

Overrides `CARTESI_AUTH_AWS_KMS_*`.

* **Type:** `string`

### `CARTESI_BLOCKCHAIN_BLOCK_TIMEOUT`
## `CARTESI_BLOCKCHAIN_BLOCK_TIMEOUT`

Block subscription timeout in seconds.

* **Type:** `int`
* **Default:** `"60"`

### `CARTESI_BLOCKCHAIN_FINALITY_OFFSET`
## `CARTESI_BLOCKCHAIN_FINALITY_OFFSET`

The node assumes that blocks offseted by N from the current block have reached finality
(N is the read depth).

* **Type:** `int`
* **Default:** `"10"`

### `CARTESI_BLOCKCHAIN_HTTP_ENDPOINT`
## `CARTESI_BLOCKCHAIN_HTTP_ENDPOINT`

HTTP endpoint for the blockchain RPC provider.

* **Type:** `string`

### `CARTESI_BLOCKCHAIN_ID`
## `CARTESI_BLOCKCHAIN_ID`

An unique identifier representing a blockchain network.

* **Type:** `int`

### `CARTESI_BLOCKCHAIN_IS_LEGACY`
## `CARTESI_BLOCKCHAIN_IS_LEGACY`

If set to true the node will send transactions using the legacy gas fee model
(instead of EIP-1559).

* **Type:** `bool`
* **Default:** `"false"`

### `CARTESI_BLOCKCHAIN_WS_ENDPOINT`
## `CARTESI_BLOCKCHAIN_WS_ENDPOINT`

WebSocket endpoint for the blockchain RPC provider.

* **Type:** `string`

### `CARTESI_CONTRACTS_INPUT_BOX_DEPLOYMENT_BLOCK_NUMBER`
## `CARTESI_CONTRACTS_INPUT_BOX_DEPLOYMENT_BLOCK_NUMBER`

The deployment block for the input box contract.
The node will begin to read blockchain events from this block.

* **Type:** `int64`

### `CARTESI_CONTRACTS_AUTHORITY_ADDRESS`
## `CARTESI_CONTRACTS_AUTHORITY_ADDRESS`

Address of the Authority contract.

* **Type:** `string`

### `CARTESI_CONTRACTS_DAPP_ADDRESS`
## `CARTESI_CONTRACTS_DAPP_ADDRESS`

Address of the DApp's contract.

* **Type:** `string`

### `CARTESI_CONTRACTS_DAPP_DEPLOYMENT_BLOCK_NUMBER`
## `CARTESI_CONTRACTS_DAPP_DEPLOYMENT_BLOCK_NUMBER`

Block in which the DApp's contract was deployed.

* **Type:** `string`

### `CARTESI_CONTRACTS_HISTORY_ADDRESS`
## `CARTESI_CONTRACTS_HISTORY_ADDRESS`

Address of the History contract.

* **Type:** `string`

### `CARTESI_CONTRACTS_INPUT_BOX_ADDRESS`
## `CARTESI_CONTRACTS_INPUT_BOX_ADDRESS`

Address of the InputBox contract.

* **Type:** `string`

### `CARTESI_EXPERIMENTAL_SUNODO_VALIDATOR_ENABLED`
## `CARTESI_EXPERIMENTAL_SUNODO_VALIDATOR_ENABLED`

When enabled, the node does not start the authority-claimer service and the Redis server.

* **Type:** `bool`
* **Default:** `"false"`

### `CARTESI_EXPERIMENTAL_SUNODO_VALIDATOR_REDIS_ENDPOINT`
## `CARTESI_EXPERIMENTAL_SUNODO_VALIDATOR_REDIS_ENDPOINT`

External Redis endpoint for the node when running in the experimental sunodo validator mode.

* **Type:** `string`

### `CARTESI_FEATURE_DISABLE_MACHINE_HASH_CHECK`
## `CARTESI_FEATURE_DISABLE_MACHINE_HASH_CHECK`

If set to true, the node will *not* check whether the Cartesi machine hash from
the snapshot matches the hash in the Application contract.


* **Type:** `bool`
* **Default:** `"false"`

### `CARTESI_FEATURE_HOST_MODE`
## `CARTESI_FEATURE_HOST_MODE`

If set to true, the node will run in host mode.

In host mode, computations will not be performed by the cartesi machine.
Expand All @@ -137,61 +163,69 @@ You should only use host mode for development and debugging!
* **Type:** `bool`
* **Default:** `"false"`

### `CARTESI_FEATURE_READER_MODE`
## `CARTESI_FEATURE_READER_MODE`

If set to true, the node will run in reader mode.

In reader mode, the node does not make claims.

* **Type:** `bool`
* **Default:** `"false"`

### `CARTESI_HTTP_ADDRESS`
## `CARTESI_HTTP_ADDRESS`

HTTP address for the node.

* **Type:** `string`
* **Default:** `"127.0.0.1"`

### `CARTESI_HTTP_PORT`
## `CARTESI_HTTP_PORT`

HTTP port for the node.
The node will also use the 20 ports after this one for internal services.

* **Type:** `int`
* **Default:** `"10000"`

### `CARTESI_LOG_LEVEL`
## `CARTESI_LOG_LEVEL`

One of "debug", "info", "warning", "error".

* **Type:** `LogLevel`
* **Default:** `"info"`

### `CARTESI_LOG_TIMESTAMP`
## `CARTESI_LOG_TIMESTAMP`

If set to true, the node will print the timestamp when logging.

* **Type:** `bool`
* **Default:** `"false"`

### `CARTESI_POSTGRES_ENDPOINT`
## `CARTESI_POSTGRES_ENDPOINT`

Postgres endpoint in the 'postgres://user:password@hostname:port/database' format.

If not set, or set to empty string, will defer the behaviour to the PG driver.
See [this](https://www.postgresql.org/docs/current/libpq-envars.html) for more information.

It is also possible to set the endpoint without a password and load it from Postgres' passfile.
See [this](https://www.postgresql.org/docs/current/libpq-connect.html#LIBPQ-CONNECT-PASSFILE)
for more information.

* **Type:** `string`
* **Default:** `""`

### `CARTESI_EPOCH_DURATION`
## `CARTESI_EPOCH_DURATION`

Duration of a rollups epoch in seconds.

At the end of each epoch, the node will send claims to the blockchain.

* **Type:** `Duration`
* **Default:** `"86400"`

### `CARTESI_SNAPSHOT_DIR`
## `CARTESI_SNAPSHOT_DIR`

Path to the directory of the cartesi-machine snapshots.

* **Type:** `string`
Expand Down
11 changes: 5 additions & 6 deletions internal/config/generate/Config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@
#

[logging.CARTESI_LOG_LEVEL]
default = "info"
default = "info"
go-type = "LogLevel"
description = """
One of "debug", "info", "warning", "error"."""

[logging.CARTESI_LOG_TIMESTAMP]
default = "false"
default = "false"
go-type = "bool"
description = """
If set to true, the node will print the timestamp when logging."""
Expand Down Expand Up @@ -132,7 +132,6 @@ description = """
The deployment block for the input box contract.
The node will begin to read blockchain events from this block."""


#
# Snapshot
#
Expand Down Expand Up @@ -202,10 +201,10 @@ go-type = "string"
redact = true
description = """
Postgres endpoint in the 'postgres://user:password@hostname:port/database' format.
If not set, or set to empty string, will defer the behaviour to the PG driver.
See [this](https://www.postgresql.org/docs/current/libpq-envars.html) for more information.
It is also possible to set the endpoint without a password and load it from Postgres' passfile.
See [this](https://www.postgresql.org/docs/current/libpq-connect.html#LIBPQ-CONNECT-PASSFILE)
for more information."""
Expand All @@ -232,7 +231,7 @@ The node will also use the 20 ports after this one for internal services."""
#

[experimental.CARTESI_EXPERIMENTAL_SUNODO_VALIDATOR_ENABLED]
default = "false"
default = "false"
go-type = "bool"
description = """
When enabled, the node does not start the authority-claimer service and the Redis server."""
Expand Down
8 changes: 6 additions & 2 deletions internal/config/generate/helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,11 +89,15 @@ func addCodeHeader(builder *strings.Builder) {
}

func addDocHeader(builder *strings.Builder) {
addLine(builder, "> [!IMPORTANT]")
addLine(builder, "> This file was generated by internal/config/generate. DO NOT EDIT.")
addLine(builder, "<!--")
addLine(builder, "File generated by internal/config/generate.")
addLine(builder, "DO NOT EDIT.")
addLine(builder, "-->")
addLine(builder, "")
addLine(builder, "<!-- markdownlint-disable line_length -->")

addLine(builder, "# Node Configuration")
addLine(builder, "")

addLine(builder, "The node is configurable through environment variables.")
addLine(builder, "(There is no other way to configure it.)")
Expand Down
3 changes: 2 additions & 1 deletion internal/config/generate/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ func main() {
addCodeHeader(&code)
addDocHeader(&doc)

addLine(&doc, "<!-- markdownlint-disable MD012 -->")
for _, env := range envs {
env.validate()
addLine(&code, env.toFunction())
Expand Down Expand Up @@ -124,7 +125,7 @@ func (e Env) toFunction() string {

// Generates the documentation entry for the environment variable.
func (e Env) toDoc() string {
s := fmt.Sprintf("### `%s`\n%s\n\n", e.Name, e.Description)
s := fmt.Sprintf("## `%s`\n\n%s\n\n", e.Name, e.Description)
s = fmt.Sprintf("%s* **Type:** `%s`\n", s, e.GoType)
if e.Default != nil {
s = fmt.Sprintf("%s* **Default:** `\"%s\"`\n", s, *e.Default)
Expand Down

0 comments on commit 350841e

Please sign in to comment.