Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Simplify Node config #88

Closed
Tracked by #80
gligneul opened this issue Sep 15, 2023 · 5 comments · Fixed by #155
Closed
Tracked by #80

Simplify Node config #88

gligneul opened this issue Sep 15, 2023 · 5 comments · Fixed by #155
Assignees
Labels
#feat:go-supervisor Feature: Go supervisor
Milestone

Comments

@gligneul
Copy link
Contributor

gligneul commented Sep 15, 2023

📚 Context

The node configuration is confusing because it is spread across multiple services.
It doesn't follow a single naming convention, and we have different variables with the same meaning.

✔️ Solution

We want to provide a set of environment variables in the new rollups-node monolith to help configure it. We will concentrate the documentation for these variables in a single place so it is easy to reason. We will also merge variables with the same meaning but different names. For instance, BH_HTTP_ENDPOINT and TX_PROVIDER_HTTP_ENDPOINT will become CARTESI_PROVIDER_HTTP_ENDPOINT.

We plan to add the CARTESI prefix to all variables to avoid clashing with previous names. If an internal variable is already set, the monolith will not overwrite it. For example, if you set BH_HTTP_ENDPOINT, the monolith won't overwrite it with CARTESI_PROVIDER_HTTP_ENDPOINT. Notice, however, that the monolith will set the TX_PROVIDER_HTTP_ENDPOINT to CARTESI_PROVIDER_HTTP_ENDPOINT if it isn't set.

We should define safe default values as much as possible to start the node defining with minimal configuration. Variables that can be set directly from the monolith won't be exposed. For instance, the address of the state server (SC_GRPC_ENDPOINT) will be hardcoded by the monolith to a local host address. If SC_GRPC_ENDPOINT is already set, the monolith won't overwrite, just like the case above. However, this is not recommended.

Here is the list of variables we will provide and where they are used. (In the final version, we won't document where they are used; this is just for development tracking.)

CARTESI_LOG_LEVEL

Sets RUST_LOG in all node services.
We have to think about the server manager log; currently, it is defined by:

  • SERVER_MANAGER_LOG_LEVEL=warning
  • REMOTE_CARTESI_MACHINE_LOG_LEVEL=info

CARTESI_GRAPHQL_PORT

  • graphql-server: GRAPHQL_PORT

CARTESI_INSPECT_PORT

  • inspect-server: INSPECT_SERVER_ADDRESS

In this case, INSPECT_SERVER_ADDRESS=0.0.0.0:$CARTESI_INSPECT_PORT

CARTESI_POSTGRES_*

  • indexer and graphql-server: POSTGRES_*

CARTESI_REDIS_ENDPOINT

  • dispatcher, advance-runner, indexer: REDIS_ENDPOINT

CARTESI_PROVIDER_HTTP_ENDPOINT

  • dispatcher: TX_PROVIDER_HTTP_ENDPOINT
  • state_server: BH_HTTP_ENDPOINT
  • advance-runner: PROVIDER_HTTP_ENDPOINT

CARTESI_PROVIDER_WS_ENDPOINT

  • state-server: BH_WS_ENDPOINT

CARTESI_DAPP_DEPLOYMENT_FILE

  • dispatcher: RD_DAPP_DEPLOYMENT_FILE
  • advance-runner and indexer: DAPP_CONTRACT_ADDRESS_FILE

CARTESI_ROLLUPS_DEPLOYMENT_FILE

  • dispatcher: RD_ROLLUPS_DEPLOYMENT_FILE

CARTESI_CHAIN_ID

  • dispatcher: TX_CHAIN_ID
  • advance-runner and indexer: CHAIN_ID

CARTESI_CHAIN_IS_LEGACY

  • dispatcher: TX_CHAIN_IS_LEGACY

CARTESI_EPOCH_DURATION

  • dispatcher: RD_EPOCH_DURATION

CARTESI_STATE_FOLD_GENESIS_BLOCK

  • state-server: SF_GENESIS_BLOCK

CARTESI_STATE_FOLD_SAFETY_MARGIN

  • state-server: SF_SAFETY_MARGIN

CARTESI_STATE_FOLD_BLOCK_TIMEOUT

  • state-server: BH_BLOCK_TIMEOUT

CARTESI_STATE_FOLD_DEFAULT_CONFIRMATIONS

  • dispatcher: SC_DEFAULT_CONFIRMATIONS

CARTESI_TRANSACTION_DEFAULT_CONFIRMATIONS

Can we merge this one with CARTESI_STATE_SERVER_DEFAULT_CONFIRMATIONS?

  • dispatcher: TX_DEFAULT_CONFIRMATIONS

CARTESI_AUTH_*

  • dispatcher: AUTH_*

CARTESI_SERVER_MANAGER_SESSION_ID

  • advance_runner and inspect_server: SESSION_ID

CARTESI_SNAPSHOT_DIR

  • advance_runner: SNAPSHOT_DIR

We can set SNAPSHOT_LATEST in advance_runner to $SNAPSHOT_DIR/latest

CARTESI_SNAPSHOT_ENABLED

  • advance_runner: SNAPSHOT_ENABLED
@gligneul gligneul added this to the 1.1.0 milestone Sep 15, 2023
This was referenced Sep 15, 2023
@gligneul
Copy link
Contributor Author

gligneul commented Sep 15, 2023

We should consider #7 (comment).

To handle that, we could add a new variable called CARTESI_LOG_CONFIG that enables printing the config as it is parsed.

@gligneul gligneul moved this to 📋 Backlog in Node Unit Sep 15, 2023
@tuler
Copy link
Member

tuler commented Sep 15, 2023

For the database configuration I'd follow the suggestion at #55

@gligneul
Copy link
Contributor Author

For the database configuration I'd follow the suggestion at #55

I will prioritize it

@gligneul gligneul modified the milestones: 1.1.0, 1.2.0 Sep 15, 2023
@gligneul gligneul self-assigned this Sep 15, 2023
@gligneul gligneul moved this from 📋 Backlog to 🏗 In progress in Node Unit Sep 15, 2023
@gligneul gligneul moved this from 🏗 In progress to 📋 Backlog in Node Unit Sep 18, 2023
@gligneul
Copy link
Contributor Author

I evaluated the Viper package for Go, and I don't think it contributes much to what we need to achieve. Instead, I recommend taking a look at this package: https://github.com/caarlos0/env

@gligneul
Copy link
Contributor Author

We should remove the DApp and Rollups deployment files and receive the necessary parameters as environment variables. The parameters are the DApp address, the deployment block hash, and the addresses of the History, Authority, and InputBox contracts. The History and Authority addresses should be obligatory parameters without default values because the DApp deployer must decide these parameters explicitly. The input box should have a default value because it is the same for every DApp and every chain.

@gligneul gligneul removed their assignment Sep 26, 2023
@renan061 renan061 self-assigned this Oct 4, 2023
@renan061 renan061 moved this from 📋 Backlog to 🏗 In progress in Node Unit Oct 4, 2023
@gligneul gligneul modified the milestones: 1.2.0, 1.3.0 Nov 6, 2023
@renan061 renan061 linked a pull request Nov 16, 2023 that will close this issue
@gligneul gligneul added the #feat:go-supervisor Feature: Go supervisor label Nov 16, 2023
@renan061 renan061 moved this from 🏗 In progress to ✅ Done in Node Unit Nov 29, 2023
@gligneul gligneul closed this as completed Dec 1, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
#feat:go-supervisor Feature: Go supervisor
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

3 participants