Skip to content

Commit 0fdd6eb

Browse files
author
Eason
committed
refactor: change config files
1 parent 138de93 commit 0fdd6eb

7 files changed

Lines changed: 22 additions & 183 deletions

File tree

common/config-parser/src/lib.rs

Lines changed: 1 addition & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -84,39 +84,11 @@ impl From<reqwest::Error> for ParseError {
8484

8585
#[cfg(test)]
8686
mod tests {
87-
use super::{parse_file, parse_reader};
88-
use serde::Deserialize;
89-
use stringreader::StringReader;
90-
91-
#[derive(Debug, Deserialize)]
92-
struct Config {
93-
global_string: Option<String>,
94-
global_int: Option<u64>,
95-
}
87+
use super::{parse_file, types::Config};
9688

9789
#[test]
9890
fn test_parse_config() {
9991
let file_path = "../../devtools/chain/config.toml";
10092
let _config: Config = parse_file(file_path, false).unwrap();
10193
}
102-
103-
#[test]
104-
fn test_parse_reader() {
105-
let toml_str = r#"
106-
global_string = "Best Food"
107-
global_int = 42
108-
"#;
109-
let mut toml_r = StringReader::new(toml_str);
110-
let config: Config = parse_reader(&mut toml_r).unwrap();
111-
assert_eq!(config.global_string, Some(String::from("Best Food")));
112-
assert_eq!(config.global_int, Some(42));
113-
}
114-
115-
#[ignore]
116-
#[test]
117-
fn test_parse_file() {
118-
let config: Config = parse_file("/tmp/config.toml", false).unwrap();
119-
assert_eq!(config.global_string, Some(String::from("Best Food")));
120-
assert_eq!(config.global_int, Some(42));
121-
}
12294
}

common/config-parser/src/types.rs

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -22,17 +22,20 @@ pub struct Config {
2222

2323
pub accounts: Vec<InitialAccount>,
2424

25-
pub rpc: ConfigApi,
26-
pub network: ConfigNetwork,
27-
pub mempool: ConfigMempool,
28-
pub executor: ConfigExecutor,
29-
pub consensus: ConfigConsensus,
25+
pub rpc: ConfigApi,
26+
pub network: ConfigNetwork,
27+
pub mempool: ConfigMempool,
28+
pub executor: ConfigExecutor,
29+
pub consensus: ConfigConsensus,
3030
#[serde(default)]
31-
pub logger: ConfigLogger,
31+
pub logger: ConfigLogger,
3232
#[serde(default)]
33-
pub rocksdb: ConfigRocksDB,
34-
pub jaeger: Option<ConfigJaeger>,
35-
pub prometheus: Option<ConfigPrometheus>,
33+
pub rocksdb: ConfigRocksDB,
34+
pub jaeger: Option<ConfigJaeger>,
35+
pub prometheus: Option<ConfigPrometheus>,
36+
37+
#[serde(default)]
38+
pub ibc_contract_address: H160,
3639
pub wckb_contract_address: H160,
3740
}
3841

@@ -78,7 +81,6 @@ impl Config {
7881
}
7982
}
8083

81-
8284
#[derive(Clone, Debug, Deserialize)]
8385
pub struct ConfigApi {
8486
pub http_listening_address: Option<SocketAddr>,

devtools/chain/config.toml

Lines changed: 1 addition & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,11 @@ privkey = "0x37aa0f893d05914a4def0460c0a984d3611546cfb26924d7a7ca6e0db9950a2d"
44
# db config
55
data_path = "./devtools/chain/data"
66

7-
epoch_len = 100_000_000
8-
9-
metadata_contract_address = "0xffffffffffffffffffffffffffffffffffffff01"
107
crosschain_contract_address = "0xb9dc8bde1db42410d304b5e78c2ff843134e15e0"
118
wckb_contract_address = "0xa13763691970d9373d4fab7cc323d7ba06fa9986"
129

1310
[[accounts]]
14-
address = "0x"
11+
address = "0xa0ee7a142d267c1f36714e4a8f75612f20a79720"
1512
balance = "04ee2d6d415b85acef8100000000"
1613

1714
[rpc]
@@ -67,27 +64,3 @@ tracing_batch_size = 50
6764

6865
[prometheus]
6966
listening_address = "0.0.0.0:8100"
70-
71-
[cross_client]
72-
axon_udt_hash = "0xf32ec1e3274c27ac4cc018c92efec443847e9b78ba8cbedca36f0fa8c35d1c9e"
73-
ckb_uri = "https://mercury-testnet.ckbapp.dev/rpc"
74-
mercury_uri = "http://127.0.0.1:8116"
75-
indexer_uri = "http://127.0.0.1:8117"
76-
start_block_number = 5899094
77-
checkpoint_interval = 1000
78-
pk = "0x37aa0f893d05914a4def0460c0a984d3611546cfb26924d7a7ca6e0db9950a2d"
79-
enable = false
80-
admin_address = "0x0000000000000000000000000000000000000000"
81-
node_address = "0x0000000000000000000000000000000000000000"
82-
selection_lock_hash = "0xf32ec1e3274c27ac4cc018c92efec443847e9b78ba8cbedca36f0fa8c35d1c9e"
83-
checkpoint_type_hash = "0xf32ec1e3274c27ac4cc018c92efec443847e9b78ba8cbedca36f0fa8c35d1c9e"
84-
acs_lock_code_hash = "0x97e6179be134d47ca10322a1534d8dcb65052de7e099b5556bea924137839bab"
85-
request_type_code_hash = "0xd8f9afaad8eb3e26a1ef2538bac91d68635502508358ae901941513bfe2edb1d"
86-
87-
[ibc]
88-
uri = "127.0.0.1:8118"
89-
90-
[interoperability_extension]
91-
blockchain_extension_transaction_hashes = [
92-
{name = "cardano", id = 2, tx_hash = "0xb1af175009413bf9670dffb7b120f0eca52896a9798bda123df9b25ff7d8f721"}
93-
]

devtools/chain/nodes/node_1.toml

Lines changed: 2 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,11 @@ privkey = "0x37aa0f893d05914a4def0460c0a984d3611546cfb26924d7a7ca6e0db9950a2d"
44
# db config
55
data_path = "./devtools/chain/data/node_1"
66

7-
epoch_len = 100_000_000
8-
9-
metadata_contract_address = "0xffffffffffffffffffffffffffffffffffffff01"
107
crosschain_contract_address = "0xb9dc8bde1db42410d304b5e78c2ff843134e15e0"
118
wckb_contract_address = "0xa13763691970d9373d4fab7cc323d7ba06fa9986"
129

13-
[accounts]
14-
mnemonic = "test test test test test test test test test test test junk"
15-
# initial_index = 0
16-
# path = "m/44'/60'/0'/0"
17-
count = 10
10+
[[accounts]]
11+
address = "0xa0ee7a142d267c1f36714e4a8f75612f20a79720"
1812
balance = "56bc75e2d63100000"
1913

2014
[rpc]
@@ -70,24 +64,3 @@ cache_size = 134217728
7064
# Provide an options file to tune RocksDB for your workload and your system configuration.
7165
# More details can be found in [the official tuning guide](https://github.com/facebook/rocksdb/wiki/RocksDB-Tuning-Guide).
7266
options_file = "default.db-options"
73-
74-
[cross_client]
75-
axon_udt_hash = "0xf32ec1e3274c27ac4cc018c92efec443847e9b78ba8cbedca36f0fa8c35d1c9e"
76-
ckb_uri = "https://mercury-testnet.ckbapp.dev/rpc"
77-
mercury_uri = "http://127.0.0.1:8116"
78-
indexer_uri = "http://127.0.0.1:8117"
79-
start_block_number = 5899094
80-
checkpoint_interval = 1000
81-
pk = "0x37aa0f893d05914a4def0460c0a984d3611546cfb26924d7a7ca6e0db9950a2d"
82-
enable = false
83-
admin_address = "0x0000000000000000000000000000000000000000"
84-
node_address = "0x0000000000000000000000000000000000000000"
85-
selection_lock_hash = "0xf32ec1e3274c27ac4cc018c92efec443847e9b78ba8cbedca36f0fa8c35d1c9e"
86-
checkpoint_type_hash = "0xf32ec1e3274c27ac4cc018c92efec443847e9b78ba8cbedca36f0fa8c35d1c9e"
87-
acs_lock_code_hash = "0x97e6179be134d47ca10322a1534d8dcb65052de7e099b5556bea924137839bab"
88-
request_type_code_hash = "0xd8f9afaad8eb3e26a1ef2538bac91d68635502508358ae901941513bfe2edb1d"
89-
90-
[interoperability_extension]
91-
blockchain_extension_transaction_hashes = [
92-
{name = "cardano", id = 2, tx_hash = "0xb1af175009413bf9670dffb7b120f0eca52896a9798bda123df9b25ff7d8f721"}
93-
]

devtools/chain/nodes/node_2.toml

Lines changed: 2 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,11 @@ privkey = "0x383fcff8683b8115e31613949be24254b4204ffbe43c227408a76334a2e3fb32"
44
# db config
55
data_path = "./devtools/chain/data/node_2"
66

7-
epoch_len = 100_000_000
8-
9-
metadata_contract_address = "0xffffffffffffffffffffffffffffffffffffff01"
107
crosschain_contract_address = "0xb9dc8bde1db42410d304b5e78c2ff843134e15e0"
118
wckb_contract_address = "0xa13763691970d9373d4fab7cc323d7ba06fa9986"
129

13-
[accounts]
14-
mnemonic = "test test test test test test test test test test test junk"
15-
# initial_index = 0
16-
# path = "m/44'/60'/0'/0"
17-
count = 10
10+
[[accounts]]
11+
address = "0xa0ee7a142d267c1f36714e4a8f75612f20a79720"
1812
balance = "56bc75e2d63100000"
1913

2014
[rpc]
@@ -70,24 +64,3 @@ cache_size = 134217728
7064
# Provide an options file to tune RocksDB for your workload and your system configuration.
7165
# More details can be found in [the official tuning guide](https://github.com/facebook/rocksdb/wiki/RocksDB-Tuning-Guide).
7266
options_file = "default.db-options"
73-
74-
[cross_client]
75-
axon_udt_hash = "0xf32ec1e3274c27ac4cc018c92efec443847e9b78ba8cbedca36f0fa8c35d1c9e"
76-
ckb_uri = "https://mercury-testnet.ckbapp.dev/rpc"
77-
mercury_uri = "http://127.0.0.1:8116"
78-
indexer_uri = "http://127.0.0.1:8117"
79-
start_block_number = 5899094
80-
checkpoint_interval = 1000
81-
pk = "0x37aa0f893d05914a4def0460c0a984d3611546cfb26924d7a7ca6e0db9950a2d"
82-
enable = false
83-
admin_address = "0x0000000000000000000000000000000000000000"
84-
node_address = "0x0000000000000000000000000000000000000000"
85-
selection_lock_hash = "0xf32ec1e3274c27ac4cc018c92efec443847e9b78ba8cbedca36f0fa8c35d1c9e"
86-
checkpoint_type_hash = "0xf32ec1e3274c27ac4cc018c92efec443847e9b78ba8cbedca36f0fa8c35d1c9e"
87-
acs_lock_code_hash = "0x97e6179be134d47ca10322a1534d8dcb65052de7e099b5556bea924137839bab"
88-
request_type_code_hash = "0xd8f9afaad8eb3e26a1ef2538bac91d68635502508358ae901941513bfe2edb1d"
89-
90-
[interoperability_extension]
91-
blockchain_extension_transaction_hashes = [
92-
{name = "cardano", id = 2, tx_hash = "0xb1af175009413bf9670dffb7b120f0eca52896a9798bda123df9b25ff7d8f721"}
93-
]

devtools/chain/nodes/node_3.toml

Lines changed: 2 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,11 @@ privkey = "0x51ce21643b911347c5d5c85c323d9d5421810dc89f46b688720b2715f5e8e936"
44
# db config
55
data_path = "./devtools/chain/data/node_3"
66

7-
epoch_len = 100_000_000
8-
9-
metadata_contract_address = "0xffffffffffffffffffffffffffffffffffffff01"
107
crosschain_contract_address = "0xb9dc8bde1db42410d304b5e78c2ff843134e15e0"
118
wckb_contract_address = "0xa13763691970d9373d4fab7cc323d7ba06fa9986"
129

13-
[accounts]
14-
mnemonic = "test test test test test test test test test test test junk"
15-
# initial_index = 0
16-
# path = "m/44'/60'/0'/0"
17-
count = 10
10+
[[accounts]]
11+
address = "0xa0ee7a142d267c1f36714e4a8f75612f20a79720"
1812
balance = "56bc75e2d63100000"
1913

2014
[rpc]
@@ -70,24 +64,3 @@ cache_size = 134217728
7064
# Provide an options file to tune RocksDB for your workload and your system configuration.
7165
# More details can be found in [the official tuning guide](https://github.com/facebook/rocksdb/wiki/RocksDB-Tuning-Guide).
7266
options_file = "default.db-options"
73-
74-
[cross_client]
75-
axon_udt_hash = "0xf32ec1e3274c27ac4cc018c92efec443847e9b78ba8cbedca36f0fa8c35d1c9e"
76-
ckb_uri = "https://mercury-testnet.ckbapp.dev/rpc"
77-
mercury_uri = "http://127.0.0.1:8116"
78-
indexer_uri = "http://127.0.0.1:8117"
79-
start_block_number = 5899094
80-
checkpoint_interval = 1000
81-
pk = "0x37aa0f893d05914a4def0460c0a984d3611546cfb26924d7a7ca6e0db9950a2d"
82-
enable = false
83-
admin_address = "0x0000000000000000000000000000000000000000"
84-
node_address = "0x0000000000000000000000000000000000000000"
85-
selection_lock_hash = "0xf32ec1e3274c27ac4cc018c92efec443847e9b78ba8cbedca36f0fa8c35d1c9e"
86-
checkpoint_type_hash = "0xf32ec1e3274c27ac4cc018c92efec443847e9b78ba8cbedca36f0fa8c35d1c9e"
87-
acs_lock_code_hash = "0x97e6179be134d47ca10322a1534d8dcb65052de7e099b5556bea924137839bab"
88-
request_type_code_hash = "0xd8f9afaad8eb3e26a1ef2538bac91d68635502508358ae901941513bfe2edb1d"
89-
90-
[interoperability_extension]
91-
blockchain_extension_transaction_hashes = [
92-
{name = "cardano", id = 2, tx_hash = "0xb1af175009413bf9670dffb7b120f0eca52896a9798bda123df9b25ff7d8f721"}
93-
]

devtools/chain/nodes/node_4.toml

Lines changed: 2 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,11 @@ privkey = "0x69ff51f4c22f30615f68b88efa740f8f1b9169e88842b83d189748d06f1a948e"
44
# db config
55
data_path = "./devtools/chain/data/node_4"
66

7-
epoch_len = 100_000_000
8-
9-
metadata_contract_address = "0xffffffffffffffffffffffffffffffffffffff01"
107
crosschain_contract_address = "0xb9dc8bde1db42410d304b5e78c2ff843134e15e0"
118
wckb_contract_address = "0xa13763691970d9373d4fab7cc323d7ba06fa9986"
129

13-
[accounts]
14-
mnemonic = "test test test test test test test test test test test junk"
15-
# initial_index = 0
16-
# path = "m/44'/60'/0'/0"
17-
count = 10
10+
[[accounts]]
11+
address = "0xa0ee7a142d267c1f36714e4a8f75612f20a79720"
1812
balance = "56bc75e2d63100000"
1913

2014
[rpc]
@@ -70,24 +64,3 @@ cache_size = 134217728
7064
# Provide an options file to tune RocksDB for your workload and your system configuration.
7165
# More details can be found in [the official tuning guide](https://github.com/facebook/rocksdb/wiki/RocksDB-Tuning-Guide).
7266
options_file = "default.db-options"
73-
74-
[cross_client]
75-
axon_udt_hash = "0xf32ec1e3274c27ac4cc018c92efec443847e9b78ba8cbedca36f0fa8c35d1c9e"
76-
ckb_uri = "https://mercury-testnet.ckbapp.dev/rpc"
77-
mercury_uri = "http://127.0.0.1:8116"
78-
indexer_uri = "http://127.0.0.1:8117"
79-
start_block_number = 5899094
80-
checkpoint_interval = 1000
81-
pk = "0x37aa0f893d05914a4def0460c0a984d3611546cfb26924d7a7ca6e0db9950a2d"
82-
enable = false
83-
admin_address = "0x0000000000000000000000000000000000000000"
84-
node_address = "0x0000000000000000000000000000000000000000"
85-
selection_lock_hash = "0xf32ec1e3274c27ac4cc018c92efec443847e9b78ba8cbedca36f0fa8c35d1c9e"
86-
checkpoint_type_hash = "0xf32ec1e3274c27ac4cc018c92efec443847e9b78ba8cbedca36f0fa8c35d1c9e"
87-
acs_lock_code_hash = "0x97e6179be134d47ca10322a1534d8dcb65052de7e099b5556bea924137839bab"
88-
request_type_code_hash = "0xd8f9afaad8eb3e26a1ef2538bac91d68635502508358ae901941513bfe2edb1d"
89-
90-
[interoperability_extension]
91-
blockchain_extension_transaction_hashes = [
92-
{name = "cardano", id = 2, tx_hash = "0xb1af175009413bf9670dffb7b120f0eca52896a9798bda123df9b25ff7d8f721"}
93-
]

0 commit comments

Comments
 (0)