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

refactor!: config structs are directly mapped onto toml config #4006

Merged

Conversation

sdbondi
Copy link
Member

@sdbondi sdbondi commented Apr 6, 2022

Description

This PR builds from work done on #3777 by @philipr-za @mikethetike @CjS77

  • refactors configuration to map directly to config structs on all apps
  • refactor and simplify p2p configs
  • split out various transport configs
  • split out peer seeds from other p2p config so that it is common to all apps and overridable per network

FFI Breaking changes:

  • network added to params for wallet_create
  • transport_type_destroy renamed to transport_config_destroy. transport_type_destroy is still available but deprecated.
  • uses TransportConfig instead of TransportType struct
  • network argument removed from comms_config_create

Motivation and Context

Previous config was brittle and could easily break app configs when they are changed. This PR greatly reduces config maintenance by removing any mapping and default setting when changing configs.

TODOs:

  • update launchpad
  • integration tests (in progress)

How Has This Been Tested?

Manually, testing each app
Existing tests
Code compiles

philipr-za and others added 30 commits January 28, 2022 14:41
Some fixes to the launchpad docker files to get them working under dibbler
* Add Dibbler to possible networks, and remove Weatherwax
* Make `config.toml` minimla to ease maintenance
* Migrate some netwrok-specific config variables to environment
  variables
* Update front-end to default to dibbler
* Remove torrc (It's 100% configured in the code)
* Fix `tauri.conf.json` so that `cargo tauri dev` works
* Copy assets over in dev mode (tauri.conf.json)
* Bump version

Note: I sometimes get random file access permissions in MacOs, but have
not been able to identify the precise reason. So watch out for this and
report back any issues.
Most apps need tor configuration, so pull this out into a helper method
and re-use where applicable.
These changes let you specify mining node parameters in the
`[mining_node]` configuration section.

Before this, settings would be overwritten from the `global` config
struct. This is not what we want, because it prevents general Tari app
configuration. A classic example is that the base node GRPC address is
overwritten from the `base_node.grpc_base_node_address` config variable.

This typically is fine on a local machine setup, but what if the base
node and miner are on different networks (or in different docker
containers)?

`grpc_base_node_address` will be `0.0.0.0:18149` to let the node listen
for GRPC connections from other networks. But the mining_node
`base_node_addr` must be `/dns4/base_node_url/tcp/18149`, and NOT
`0.0.0.0:18149` as it is currently forced into.

The overwriting also undoes the work of the `DefaultConfigLoader` trait
which elegantly handles sub-configs and negates the need to carry
everything in a `GlobalConfiguration` struct.
This commit migrates config settings for mining node 100% to the
DefaultConfigLoader. This makes the global variables unnessecary, and
they are removed.
This commit removes the global config variables in favour of the "magic"
config traits that Maxim wrote.

See the new test in applications/tari_merge_mining_proxy/src/config.rs
to see how this is awesome.
* Maybe controversial: Allow any string to be specified as "network" in
  config files, and not just official network names. This would let you
set up say "base_node.monday" and "base_node.tuesday" configuration
settings and select them at run time. Probably better is to change the
name of the key from netowrk to say, "config" though; because the
root-level network field MUST select a valid network.

* Rearrange the order of docker file steps so that the dependency
  compiled objects are more likely to be cached.
# Conflicts:
#	applications/launchpad/backend/assets/config.toml
#	applications/launchpad/backend/src/docker/settings.rs
#	applications/launchpad/docker_rig/base_node.Dockerfile
#	applications/launchpad/docker_rig/console_wallet.Dockerfile
#	applications/launchpad/docker_rig/mm_proxy.Dockerfile
#	applications/launchpad/docker_rig/sha3_miner.Dockerfile
#	applications/launchpad/versions.txt
#	common/src/configuration/global.rs
#	common/src/configuration/mod.rs
@aviator-app aviator-app bot merged commit fcbdb0a into tari-project:development Apr 11, 2022
@sdbondi sdbondi deleted the refactor-structs-as-config branch April 11, 2022 09:59
stringhandler added a commit that referenced this pull request May 10, 2022
BREAKING CHANGES
---

* major config rework. Config files should be recreated  (#4006)

Features
---

* allow network to be set by TARI_NETWORK env var ([#4073](#4073)) ([c27be5c](c27be5c))
* **collectibles:** add list assets command ([#3908](#3908)) ([5b726a6](5b726a6))
* **merge mining proxy:** check achieved Monero difficulty before submitting to Tari basenode ([#4019](#4019)) ([b09fa76](b09fa76))
* **p2p:** adds tor.forward_address setting ([#4070](#4070)) ([8c78717](8c78717))
* **tari_explorer:** add total hashrate chart ([#4054](#4054)) ([9e0ec36](9e0ec36))

Bug Fixes
---

* add Environment cfg source and remove --create-id ([#4018](#4018)) ([e59e657](e59e657))
* **base-node:** assign correct base dir to tor identity ([#4081](#4081)) ([1464f8b](1464f8b))
* **dht:** saf storage uses constructs correct msg hash ([#4003](#4003)) ([e1e7669](e1e7669))
* **dht:** sets file default for DHT db ([#4030](#4030)) ([5b125e7](5b125e7))
* **dns-seeds:** use correct cloudflare resolver default ([#4029](#4029)) ([c95e589](c95e589))
* fix github integration tests ([#4008](#4008)) ([aa143c6](aa143c6))
* github actions ([#4014](#4014)) ([a03392e](a03392e))
* ignore test that timeout in github action ([#4010](#4010)) ([6c5471e](6c5471e))
* **key-manager:** remove floating point math from mnemonic code ([#4064](#4064)) ([c2d60b3](c2d60b3))
* launchpad build docker images ([#4042](#4042)) ([50e2812](50e2812))
* **launchpad:** fix config presets ([#4028](#4028)) ([1b8b274](1b8b274))
* long running and non critical github action ([#4009](#4009)) ([3b8cb8b](3b8cb8b))
* makes header consensus encoding infallible ([#4045](#4045)) ([5ebf129](5ebf129))
* only count base nodes in peers count in base node status ([#4039](#4039)) ([190d75a](190d75a))
* prevent seed peer address from being overwritten unless newer ([#4085](#4085)) ([59b76c3](59b76c3))
* support safe non-interactive mode ([#4072](#4072)) ([b34f79d](b34f79d))
* test_output_manager_sqlite_db(_encrypted) ([#4025](#4025)) ([7a6f980](7a6f980))
* update daily test configuration ([#4049](#4049)) ([b15d682](b15d682))
* **wallet:** do not prompt for password if given in config ([#4040](#4040)) ([fc1aa65](fc1aa65))
* **wallet:** ensure block hash exists ([#4083](#4083)) ([a258984](a258984))
* weird behaviour of dates in base node banned peers ([#4037](#4037)) ([7097185](7097185))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants