From 350841ebf7932bb535858a4cd3c9fe9a80aac807 Mon Sep 17 00:00:00 2001 From: Marcel Moura Date: Fri, 19 Jan 2024 16:28:34 -0300 Subject: [PATCH] fix: generate correct markdown code --- docs/config.md | 100 ++++++++++++++++++--------- internal/config/generate/Config.toml | 11 ++- internal/config/generate/helpers.go | 8 ++- internal/config/generate/main.go | 3 +- 4 files changed, 80 insertions(+), 42 deletions(-) diff --git a/docs/config.md b/docs/config.md index 91b6865d2..33b4d34cd 100644 --- a/docs/config.md +++ b/docs/config.md @@ -1,41 +1,51 @@ -> [!IMPORTANT] -> This file was generated by internal/config/generate. DO NOT EDIT. + + # 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` + +## `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. @@ -43,84 +53,99 @@ 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. @@ -128,7 +153,8 @@ 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. @@ -137,7 +163,8 @@ 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. @@ -145,37 +172,42 @@ 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. @@ -183,7 +215,8 @@ 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. @@ -191,7 +224,8 @@ 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` diff --git a/internal/config/generate/Config.toml b/internal/config/generate/Config.toml index 848544ca9..451089823 100644 --- a/internal/config/generate/Config.toml +++ b/internal/config/generate/Config.toml @@ -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.""" @@ -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 # @@ -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.""" @@ -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.""" diff --git a/internal/config/generate/helpers.go b/internal/config/generate/helpers.go index 708fc33f6..0e476090b 100644 --- a/internal/config/generate/helpers.go +++ b/internal/config/generate/helpers.go @@ -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, "") + addLine(builder, "") 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.)") diff --git a/internal/config/generate/main.go b/internal/config/generate/main.go index 2ceaf9376..ff5346fce 100644 --- a/internal/config/generate/main.go +++ b/internal/config/generate/main.go @@ -33,6 +33,7 @@ func main() { addCodeHeader(&code) addDocHeader(&doc) + addLine(&doc, "") for _, env := range envs { env.validate() addLine(&code, env.toFunction()) @@ -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)