refactor: restructures agent config locations (#254)

* feature: restructures configs and from_settings

* fix: settings takes agent name from macro

* fix: replaces toml with json

* fix: removes redundant agent config info

* fix: derives prefix from agent name

* fix: readds kathy config and deletes optics base config

* fix: fixes kebab case rename for base settings and removes extra db_path fields
buddies-main-deployment
Luke Tchang 4 years ago committed by GitHub
parent 740b4013c0
commit 0fa4283a70
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 49
      config/default/base.json
  2. 9
      config/default/kathy-partial.json
  3. 3
      config/default/processor-partial.json
  4. 3
      config/default/relayer-partial.json
  5. 8
      config/default/updater-partial.json
  6. 7
      config/default/watcher-partial.json
  7. 48
      rust/Cargo.lock
  8. 15
      rust/kathy/config/default.toml
  9. 13
      rust/kathy/src/settings.rs
  10. 33
      rust/optics-base/config/default.toml
  11. 12
      rust/optics-base/src/macros.rs
  12. 1
      rust/optics-base/src/settings/mod.rs
  13. 36
      rust/processor/config/default.toml
  14. 11
      rust/processor/src/settings.rs
  15. 35
      rust/relayer/config/default.toml
  16. 10
      rust/relayer/src/settings.rs
  17. 2
      rust/updater/Cargo.toml
  18. 18
      rust/updater/config/default.toml
  19. 15
      rust/updater/src/settings.rs
  20. 36
      rust/watcher/config/default.toml
  21. 13
      rust/watcher/src/settings.rs

@ -0,0 +1,49 @@
{
"replicas": [
{
"address": "0x0000000000000000000000000000000000000000",
"domain": 60,
"name": "ethereum",
"rpc-style": "ethereum",
"config": {
"connection": {
"type": "ws",
"url": "ws://localhost:8545"
},
"signer": {
"key": "380eb0f3d505f087e438eca80bc4df9a7faa24f868e69fc0440261a0fc0567dc",
"type": "hex-key"
}
}
},
{
"address": "0x0000000000000000000000000000000000000000",
"domain": 61,
"name": "eth-classic",
"rpc-style": "ethereum",
"config": {
"connection": {
"type": "ws",
"url": "ws://localhost:8545"
}
}
}
],
"home": {
"address": "0x0000000000000000000000000000000000000000",
"domain": 52752,
"name": "celo",
"rpc-style": "ethereum",
"config": {
"connection": {
"type": "http",
"url": "http://localhost:8545"
}
}
},
"tracing": {
"level": "debug",
"style": "pretty"
},
"db-path": "db_path"
}

@ -0,0 +1,9 @@
{
"message-interval": 100,
"chat-gen-config": {
"destination": 1,
"message": "static message",
"recipient": "recipient",
"type": "static"
}
}

@ -0,0 +1,3 @@
{
"polling-interval": 100
}

@ -0,0 +1,3 @@
{
"polling-interval": 100
}

@ -0,0 +1,8 @@
{
"polling-interval": 100,
"update-pause": 100,
"updater": {
"key": "380eb0f3d505f087e438eca80bc4df9a7faa24f868e69fc0440261a0fc0567dc",
"type": "hex-key"
}
}

@ -0,0 +1,7 @@
{
"polling-interval": 100,
"watcher": {
"key": "380eb0f3d505f087e438eca80bc4df9a7faa24f868e69fc0440261a0fc0567dc",
"type": "hex-key"
}
}

48
rust/Cargo.lock generated

@ -1560,30 +1560,6 @@ dependencies = [
"tokio",
]
[[package]]
name = "optics-updater"
version = "0.1.0"
dependencies = [
"async-trait",
"color-eyre",
"config 0.11.0",
"ethers",
"futures-util",
"log",
"mockall",
"optics-base",
"optics-core",
"optics-test",
"rocksdb",
"serde 1.0.125",
"serde_json",
"thiserror",
"tokio",
"tracing",
"tracing-futures",
"tracing-subscriber",
]
[[package]]
name = "owo-colors"
version = "1.3.0"
@ -2709,6 +2685,30 @@ version = "0.7.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a156c684c91ea7d62626509bce3cb4e1d9ed5c4d978f7b4352658f96a4c26b4a"
[[package]]
name = "updater"
version = "0.1.0"
dependencies = [
"async-trait",
"color-eyre",
"config 0.11.0",
"ethers",
"futures-util",
"log",
"mockall",
"optics-base",
"optics-core",
"optics-test",
"rocksdb",
"serde 1.0.125",
"serde_json",
"thiserror",
"tokio",
"tracing",
"tracing-futures",
"tracing-subscriber",
]
[[package]]
name = "url"
version = "2.2.1"

@ -1,15 +0,0 @@
message-interval = 100
chat-gen-config = { type = "static", destination = 1, recipient = "recipient", message = "static message" }
[home]
name = "celo"
domain = 52752
address = "0x0000000000000000000000000000000000000000"
rpc-style = "Ethereum"
[home.config]
signer = "380eb0f3d505f087e438eca80bc4df9a7faa24f868e69fc0440261a0fc0567dc"
connection = { type = "http", url = "http://localhost:8545" }
[[replicas]]
# empty vector.
# no replicas needed for kathy

@ -52,10 +52,9 @@ impl From<ChatGenConfig> for ChatGenerator {
}
}
decl_settings!(
Settings {
"OPT_KATHY",
message_interval: u64,
#[serde(default)] chat_gen: ChatGenConfig,
}
);
decl_settings!(Settings {
agent: "kathy",
message_interval: u64,
#[serde(default)]
chat_gen: ChatGenConfig,
});

@ -1,33 +0,0 @@
[tracing]
level = "debug"
style = "pretty"
# ChainSetup
[home]
name = "celo"
domain = 52752
address = "0x0000000000000000000000000000000000000000"
rpc-style = "ethereum" # ChainConf (flattened into ChainSetup)
[home.config]
# Missing signer. Will use EthereumSigner::default()
connection = { type = "http", url = "http://localhost:8545" }
# Entry in Vec<ChainSetup>
[[replicas]]
name = "ethereum"
domain = 60
address = "0x0000000000000000000000000000000000000000"
rpc-style = "ethereum"
[replicas.config]
signer = {type = "hex-key", key = "380eb0f3d505f087e438eca80bc4df9a7faa24f868e69fc0440261a0fc0567dc"}
connection = { type = "ws", url = "ws://localhost:8545"}
# Entry in Vec<ChainSetup>
[[replicas]]
name = "eth-classic"
domain = 61
address = "0x0000000000000000000000000000000000000000"
rpc-style = "ethereum"
[replicas.config]
connection = { type = "ws", url = "ws://localhost:8545"}

@ -73,7 +73,7 @@ macro_rules! decl_settings {
(
$(#[$outer:meta])*
Settings {
$prefix:literal,
agent: $name:literal,
$($(#[$tags:meta])* $prop:ident: $type:ty,)*
}
) => {
@ -103,12 +103,14 @@ macro_rules! decl_settings {
pub fn new() -> Result<Self, config::ConfigError> {
let mut s = config::Config::new();
s.merge(config::File::with_name("config/default"))?;
let env = std::env::var("RUN_ENV").unwrap_or_else(|_| "default".into());
let env = std::env::var("RUN_MODE").unwrap_or_else(|_| "development".into());
s.merge(config::File::with_name(&format!("config/{}", env)).required(false))?;
s.merge(config::File::with_name(&format!("../config/{}/base", env)))?;
s.merge(config::File::with_name(&format!("../config/{}/{}-partial", env, $name)).required(false))?;
s.merge(config::Environment::with_prefix($prefix))?;
// Derive Environment prefix from agent name
let prefix = format!("OPT_{}", $name.to_ascii_uppercase());
s.merge(config::Environment::with_prefix(&prefix))?;
s.try_into()
}

@ -85,6 +85,7 @@ impl ChainSetup {
/// }
/// ```
#[derive(Debug, Deserialize)]
#[serde(rename_all = "kebab-case")]
pub struct Settings {
/// The path to use for the DB file
pub db_path: String,

@ -1,36 +0,0 @@
polling_interval = 100
db_path = "db_path"
[tracing]
level = "debug"
style = "pretty"
# ChainSetup
[home]
name = "celo"
domain = 52752
address = "0x0000000000000000000000000000000000000000"
rpc-style = "ethereum" # ChainConf (flattened into ChainSetup)
[home.config]
# Missing signer. Will use EthereumSigner::default()
connection = { type = "http", url = "http://localhost:8545" }
# Entry in Vec<ChainSetup>
[[replicas]]
name = "ethereum"
domain = 60
address = "0x0000000000000000000000000000000000000000"
rpc-style = "ethereum"
[replicas.config]
signer = {type = "hex-key", key = "380eb0f3d505f087e438eca80bc4df9a7faa24f868e69fc0440261a0fc0567dc"}
connection = { type = "ws", url = "ws://localhost:8545"}
# Entry in Vec<ChainSetup>
[[replicas]]
name = "eth-classic"
domain = 61
address = "0x0000000000000000000000000000000000000000"
rpc-style = "ethereum"
[replicas.config]
connection = { type = "ws", url = "ws://localhost:8545"}

@ -1,10 +1,7 @@
//! Configuration
use optics_base::decl_settings;
decl_settings!(
Settings {
"OPT_PROCESSOR",
db_path: String,
polling_interval: u64,
}
);
decl_settings!(Settings {
agent: "processor",
polling_interval: u64,
});

@ -1,35 +0,0 @@
polling_interval = 100
[tracing]
level = "debug"
style = "pretty"
# ChainSetup
[home]
name = "celo"
domain = 52752
address = "0x0000000000000000000000000000000000000000"
rpc-style = "ethereum" # ChainConf (flattened into ChainSetup)
[home.config]
# Missing signer. Will use EthereumSigner::default()
connection = { type = "http", url = "http://localhost:8545" }
# Entry in Vec<ChainSetup>
[[replicas]]
name = "ethereum"
domain = 60
address = "0x0000000000000000000000000000000000000000"
rpc-style = "ethereum"
[replicas.config]
signer = {type = "hex-key", key = "380eb0f3d505f087e438eca80bc4df9a7faa24f868e69fc0440261a0fc0567dc"}
connection = { type = "ws", url = "ws://localhost:8545"}
# Entry in Vec<ChainSetup>
[[replicas]]
name = "eth-classic"
domain = 61
address = "0x0000000000000000000000000000000000000000"
rpc-style = "ethereum"
[replicas.config]
connection = { type = "ws", url = "ws://localhost:8545"}

@ -2,9 +2,7 @@
use optics_base::decl_settings;
decl_settings!(
Settings {
"OPT_UPDATER",
polling_interval: u64,
}
);
decl_settings!(Settings {
agent: "relayer",
polling_interval: u64,
});

@ -1,5 +1,5 @@
[package]
name = "optics-updater"
name = "updater"
version = "0.1.0"
authors = ["James Prestwich <prestwich@clabs.co>"]
edition = "2018"

@ -1,18 +0,0 @@
updater = {type = "hex-key", key = "380eb0f3d505f087e438eca80bc4df9a7faa24f868e69fc0440261a0fc0567dc"}
db_path = "db_path"
polling_interval = 100
update_pause = 100
[home]
name = "ethereum"
domain = 52752
address = "0x0000000000000000000000000000000000000000"
rpc-style = "ethereum"
[home.config]
signer = {type = "hex-key", key = "380eb0f3d505f087e438eca80bc4df9a7faa24f868e69fc0440261a0fc0567dc"}
connection = { type = "http", url = "http://localhost:8545" }
[[replicas]]
# empty table.
# no replicas needed for updater

@ -1,12 +1,9 @@
//! Configuration
use optics_base::{decl_settings, settings::ethereum::EthereumSigner};
decl_settings!(
Settings {
"OPT_UPDATER",
updater: EthereumSigner,
db_path: String,
polling_interval: u64,
update_pause: u64,
}
);
decl_settings!(Settings {
agent: "updater",
updater: EthereumSigner,
polling_interval: u64,
update_pause: u64,
});

@ -1,36 +0,0 @@
watcher = {type = "hex-key", key = "380eb0f3d505f087e438eca80bc4df9a7faa24f868e69fc0440261a0fc0567dc"}
polling_interval = 100
[tracing]
level = "debug"
style = "pretty"
# ChainSetup
[home]
name = "celo"
domain = 52752
address = "0x0000000000000000000000000000000000000000"
rpc-style = "ethereum" # ChainConf (flattened into ChainSetup)
[home.config]
# Missing signer. Will use EthereumSigner::default()
connection = { type = "http", url = "http://localhost:8545" }
# Entry in Vec<ChainSetup>
[[replicas]]
name = "ethereum"
domain = 60
address = "0x0000000000000000000000000000000000000000"
rpc-style = "ethereum"
[replicas.config]
signer = {type = "hex-key", key = "380eb0f3d505f087e438eca80bc4df9a7faa24f868e69fc0440261a0fc0567dc"}
connection = { type = "ws", url = "ws://localhost:8545"}
# Entry in Vec<ChainSetup>
[[replicas]]
name = "eth-classic"
domain = 61
address = "0x0000000000000000000000000000000000000000"
rpc-style = "ethereum"
[replicas.config]
connection = { type = "ws", url = "ws://localhost:8545"}

@ -2,11 +2,8 @@
use optics_base::{decl_settings, settings::ethereum::EthereumSigner};
decl_settings!(
Settings {
"OPT_WATCHER",
watcher: EthereumSigner,
db_path: String,
polling_interval: u64,
}
);
decl_settings!(Settings {
agent: "watcher",
watcher: EthereumSigner,
polling_interval: u64,
});

Loading…
Cancel
Save