Skip to content

Commit 5dc9b1a

Browse files
committed
Completes PR #138, adds additional contemperary features
Removes identification of build directory, as sending file to build directory has been replaced by priting config file to stdout. Also adds support for seeding by generating a seed key if necessary. Update to properly print out config file to std error, and merge conventions such that m_new_config is used to store config file data Signed-off-by: Michael Maurer <[email protected]>
1 parent 3a33f7e commit 5dc9b1a

28 files changed

+1333
-22
lines changed

CMakeLists.txt

+1
Original file line numberDiff line numberDiff line change
@@ -76,5 +76,6 @@ endif()
7676
add_subdirectory(src)
7777
add_subdirectory(tests)
7878
add_subdirectory(benchmarks)
79+
add_subdirectory(tools/config_generator)
7980
add_subdirectory(tools/bench)
8081
add_subdirectory(tools/shard-seeder)

README.md

+11-11
Original file line numberDiff line numberDiff line change
@@ -160,38 +160,38 @@ You can find the images [in the Github Container Registry](https://github.com/mi
160160
## Setup test wallets and test them
161161
162162
The following commands are all performed from within the second container we started in the previous step.
163-
In each of the below commands, you should pass `atomizer-compose.cfg` instead of `2pc-compose.cfg` if you started the atomizer architecture.
163+
In each of the below commands, you should pass `config/general/atomizer-compose.cfg` instead of `config/general/2pc-compose.cfg` if you started the atomizer architecture.
164164
165165
* Mint new coins (e.g., 10 new UTXOs each with a value of 5 atomic units of currency)
166166
```terminal
167-
# ./build/src/uhs/client/client-cli 2pc-compose.cfg mempool0.dat wallet0.dat mint 10 5
167+
# ./build/src/uhs/client/client-cli config/general/2pc-compose.cfg mempool0.dat wallet0.dat mint 10 5
168168
[2021-08-17 15:11:57.686] [WARN ] Existing wallet file not found
169169
[2021-08-17 15:11:57.686] [WARN ] Existing mempool not found
170170
4bc23da407c3a8110145c5b6c38199c8ec3b0e35ea66bbfd78f0ed65304ce6fa
171171
```
172172

173173
If using the atomizer architecture, you'll need to sync the wallet after:
174174
```terminal
175-
# ./build/src/uhs/client/client-cli atomizer-compose.cfg mempool0.dat wallet0.dat sync
175+
# ./build/src/uhs/client/client-cli config/general/atomizer-compose.cfg mempool0.dat wallet0.dat sync
176176
```
177177

178178
* Inspect the balance of a wallet
179179
```terminal
180-
# ./build/src/uhs/client/client-cli 2pc-compose.cfg mempool0.dat wallet0.dat info
180+
# ./build/src/uhs/client/client-cli config/general/2pc-compose.cfg mempool0.dat wallet0.dat info
181181
Balance: $0.50, UTXOs: 10, pending TXs: 0
182182
```
183183

184184
* Make a new wallet
185185
```terminal
186-
# ./build/src/uhs/client/client-cli 2pc-compose.cfg mempool1.dat wallet1.dat newaddress
186+
# ./build/src/uhs/client/client-cli config/general/2pc-compose.cfg mempool1.dat wallet1.dat newaddress
187187
[2021-08-17 15:13:16.148] [WARN ] Existing wallet file not found
188188
[2021-08-17 15:13:16.148] [WARN ] Existing mempool not found
189189
usd1qrw038lx5n4wxx3yvuwdndpr7gnm347d6pn37uywgudzq90w7fsuk52kd5u
190190
```
191191

192192
* Send currency from the first wallet to the second wallet created in the previous step (e.g., 30 atomic units of currency)
193193
```terminal
194-
# ./build/src/uhs/client/client-cli 2pc-compose.cfg mempool0.dat wallet0.dat send 30 usd1qrw038lx5n4wxx3yvuwdndpr7gnm347d6pn37uywgudzq90w7fsuk52kd5u
194+
# ./build/src/uhs/client/client-cli config/general/2pc-compose.cfg mempool0.dat wallet0.dat send 30 usd1qrw038lx5n4wxx3yvuwdndpr7gnm347d6pn37uywgudzq90w7fsuk52kd5u
195195
tx_id:
196196
cc1f7dc708be5b07e23e125cf0674002ff8546a9342928114bc97031d8b96e75
197197
Data for recipient importinput:
@@ -201,20 +201,20 @@ In each of the below commands, you should pass `atomizer-compose.cfg` instead of
201201

202202
If using the atomizer architecture, you'll need to sync the sending wallet after:
203203
```terminal
204-
# ./build/src/uhs/client/client-cli atomizer-compose.cfg mempool0.dat wallet0.dat sync
204+
# ./build/src/uhs/client/client-cli config/general/atomizer-compose.cfg mempool0.dat wallet0.dat sync
205205
```
206206

207207
* Check that the currency is no longer available in the sending wallet
208208
```terminal
209-
# ./build/src/uhs/client/client-cli 2pc-compose.cfg mempool0.dat wallet0.dat info
209+
# ./build/src/uhs/client/client-cli config/general/2pc-compose.cfg mempool0.dat wallet0.dat info
210210
Balance: $0.20, UTXOs: 4, pending TXs: 0
211211
```
212212

213213
* Import coins to the receiving wallet using the string after `importinput` from the currency transfer step above
214214
```terminal
215-
# ./build/src/uhs/client/client-cli 2pc-compose.cfg mempool1.dat wallet1.dat importinput cc1f7dc708be5b07e23e125cf0674002ff8546a9342928114bc97031d8b96e750000000000000000d0e4f689b550f623e9370edae235de50417860be0f2f8e924eca9f402fcefeaa1e00000000000000
216-
# ./build/src/uhs/client/client-cli 2pc-compose.cfg mempool1.dat wallet1.dat sync
217-
# ./build/src/uhs/client/client-cli 2pc-compose.cfg mempool1.dat wallet1.dat info
215+
# ./build/src/uhs/client/client-cli config/general/2pc-compose.cfg mempool1.dat wallet1.dat importinput cc1f7dc708be5b07e23e125cf0674002ff8546a9342928114bc97031d8b96e750000000000000000d0e4f689b550f623e9370edae235de50417860be0f2f8e924eca9f402fcefeaa1e00000000000000
216+
# ./build/src/uhs/client/client-cli config/general/2pc-compose.cfg mempool1.dat wallet1.dat sync
217+
# ./build/src/uhs/client/client-cli config/general/2pc-compose.cfg mempool1.dat wallet1.dat info
218218
Balance: $0.30, UTXOs: 1, pending TXs: 0
219219
```
220220

File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
+44
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
2pc=1
2+
sentinel_count=1
3+
shard_count=1
4+
coordinator_count=1
5+
coordinator_max_threads=1
6+
election_timeout_upper=4000
7+
election_timeout_lower=3000
8+
heartbeat=1000
9+
raft_max_batch=100000
10+
snapshot_distance=1000000000
11+
batch_size=1
12+
wait_for_followers=0
13+
loadgen_invalid_tx_rate=0.00
14+
loadgen_fixed_tx_rate=0.01
15+
loadgen_sendtx_output_count=1
16+
loadgen_sendtx_input_count=1
17+
initial_mint_count=20000
18+
initial_mint_value=100
19+
tmpl_randomize_values=1
20+
tmpl_shard_start=0
21+
tmpl_shard_size=255
22+
tmpl_max_shard_raft_replication_count=1
23+
tmpl_avg_shard_start_end_overlap_percent=0.15
24+
tmpl_max_coordinator_raft_replication_count=1
25+
tmpl_default_log_level="INFO"
26+
tmpl_universal_override_log_level="WARN"
27+
tmpl_sentinel_log_level="WARN"
28+
tmpl_coordinator_log_level="DEBUG"
29+
tmpl_shard_log_level="DEBUG"
30+
num_wallets=10
31+
num_minters=1
32+
num_redeemers=1
33+
total_number_of_transactions=100
34+
avg_mint_value=10
35+
avg_mint_count=10
36+
avg_redemption_value=5
37+
avg_redemption_count=5
38+
transaction_frequency=5
39+
mint_frequency=0.1
40+
redemption_frequency=0.05
41+
sentinel_offline_probability=0.01
42+
shard_offline_probability=0.01
43+
coordinator_offline_probability=0.01
44+
randomize_execution=0
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
2pc=0
2+
archiver_count=1
3+
atomizer_count=1
4+
shard_count=1
5+
sentinel_count=1
6+
watchtower_count=1
7+
target_block_interval=3000
8+
stxo_cache_depth=2
9+
target_block_interval=250
10+
election_timeout_upper=4000
11+
election_timeout_lower=3000
12+
heartbeat=1000
13+
raft_max_batch=100000
14+
snapshot_distance=1000000000
15+
batch_size=1
16+
wait_for_followers=0
17+
loadgen_invalid_tx_rate=0.00
18+
loadgen_fixed_tx_rate=0.01
19+
loadgen_sendtx_output_count=1
20+
loadgen_sendtx_input_count=1
21+
initial_mint_count=20000
22+
initial_mint_value=100
23+
tmpl_randomize_values=1
24+
tmpl_shard_start=0
25+
tmpl_shard_size=255
26+
tmpl_avg_shard_start_end_overlap_percent=0.15
27+
tmpl_default_log_level="INFO"
28+
tmpl_sentinel_log_level="DEBUG"
29+
tmpl_shard_log_level="INFO"
30+
tmpl_watchtower_log_level="DEBUG"
31+
tmpl_archiver_log_level="DEBUG"
32+
tmpl_atomizer_log_level="DEBUG"
File renamed without changes.

docker-compose-2pc.yml

+3-3
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ services:
99
image: opencbdc-tx-twophase
1010
tty: true
1111
restart: always
12-
command: ./build/src/uhs/twophase/sentinel_2pc/sentineld-2pc 2pc-compose.cfg 0
12+
command: ./build/src/uhs/twophase/sentinel_2pc/sentineld-2pc ./config/general/2pc-compose.cfg 0
1313
ports:
1414
- 5555:5555
1515
depends_on:
@@ -29,7 +29,7 @@ services:
2929
target: twophase
3030
image: opencbdc-tx-twophase
3131
tty: true
32-
command: ./build/src/uhs/twophase/coordinator/coordinatord 2pc-compose.cfg 0 0
32+
command: ./build/src/uhs/twophase/coordinator/coordinatord ./config/general/2pc-compose.cfg 0 0
3333
expose:
3434
- "7777"
3535
depends_on:
@@ -49,7 +49,7 @@ services:
4949
target: twophase
5050
image: opencbdc-tx-twophase
5151
tty: true
52-
command: ./build/src/uhs/twophase/locking_shard/locking-shardd 2pc-compose.cfg 0 0
52+
command: ./build/src/uhs/twophase/locking_shard/locking-shardd ./config/general/2pc-compose.cfg 0 0
5353
expose:
5454
- "6666"
5555
ports:

docker-compose-atomizer.yml

+5-5
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ services:
88
target: atomizer
99
image: opencbdc-tx-atomizer
1010
tty: true
11-
command: ./build/src/uhs/atomizer/watchtower/watchtowerd atomizer-compose.cfg 0
11+
command: ./build/src/uhs/atomizer/watchtower/watchtowerd ./config/general/atomizer-compose.cfg 0
1212
ports:
1313
- 8555:8555
1414
expose:
@@ -28,7 +28,7 @@ services:
2828
target: atomizer
2929
image: opencbdc-tx-atomizer
3030
tty: true
31-
command: ./build/src/uhs/atomizer/atomizer/atomizer-raftd atomizer-compose.cfg 0
31+
command: ./build/src/uhs/atomizer/atomizer/atomizer-raftd ./config/general/atomizer-compose.cfg 0
3232
expose:
3333
- "5555"
3434
depends_on:
@@ -48,7 +48,7 @@ services:
4848
target: atomizer
4949
image: opencbdc-tx-atomizer
5050
tty: true
51-
command: ./build/src/uhs/atomizer/archiver/archiverd atomizer-compose.cfg 0
51+
command: ./build/src/uhs/atomizer/archiver/archiverd ./config/general/atomizer-compose.cfg 0
5252
expose:
5353
- "4555"
5454
depends_on:
@@ -69,7 +69,7 @@ services:
6969
target: atomizer
7070
image: opencbdc-tx-atomizer
7171
tty: true
72-
command: ./build/src/uhs/atomizer/shard/shardd atomizer-compose.cfg 0
72+
command: ./build/src/uhs/atomizer/shard/shardd ./config/general/atomizer-compose.cfg 0
7373
expose:
7474
- "6555"
7575
depends_on:
@@ -91,7 +91,7 @@ services:
9191
target: atomizer
9292
image: opencbdc-tx-atomizer
9393
tty: true
94-
command: ./build/src/uhs/atomizer/sentinel/sentineld atomizer-compose.cfg 0
94+
command: ./build/src/uhs/atomizer/sentinel/sentineld ./config/general/atomizer-compose.cfg 0
9595
ports:
9696
- 7555:7555
9797
depends_on:

scripts/test.sh

+3-2
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ run_test_suite () {
164164
if [[ "$RUN_UNIT_TESTS" == "true" ]]
165165
then
166166
echo "Running unit tests..."
167-
find "${REPO_TOP_DIR}"/tests/unit/ -name '*.cfg' \
167+
find "${REPO_TOP_DIR}"/config/unit/ -name '*.cfg' \
168168
-exec rsync \{\} "$BUILD_DIR" \;
169169
run_test_suite "tests/unit/run_unit_tests" "unit_tests_coverage"
170170
else
@@ -175,7 +175,8 @@ echo
175175
if [[ "$RUN_INTEGRATION_TESTS" == "true" ]]
176176
then
177177
echo "Running integration tests..."
178-
cp "${REPO_TOP_DIR}"/tests/integration/*.cfg "$BUILD_DIR"
178+
cp "${REPO_TOP_DIR}"/config/integration/*.cfg "${BUILD_DIR}"
179+
cp "${REPO_TOP_DIR}"/tools/config_generator/*.tmpl "${BUILD_DIR}"/tools/config_generator
179180
run_test_suite "tests/integration/run_integration_tests" \
180181
"integration_tests_coverage"
181182
else

tests/CMakeLists.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
project(tests)
22

3-
include_directories(. ../src ../tools/watchtower ../3rdparty ../3rdparty/secp256k1/include)
3+
include_directories(. ../src ../ ../tools/config_generator ../tools/watchtower ../3rdparty ../3rdparty/secp256k1/include)
44
set(SECP256K1_LIBRARY $<TARGET_FILE:secp256k1>)
55

66
add_library(util util.cpp)

tests/unit/CMakeLists.txt

+2
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ add_executable(run_unit_tests archiver_test.cpp
55
atomizer_test.cpp
66
buffer_test.cpp
77
common/hash_test.cpp
8+
config_gen_test.cpp
89
config_test.cpp
910
coordinator/messages_test.cpp
1011
locking_shard/format_test.cpp
@@ -50,6 +51,7 @@ target_link_libraries(run_unit_tests ${GTEST_LIBRARY}
5051
transaction
5152
network
5253
common
54+
config_generator
5355
serialization
5456
crypto
5557
secp256k1

tests/unit/config_gen_test.cpp

+57
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
// Copyright (c) 2022 MIT Digital Currency Initiative,
2+
// Federal Reserve Bank of Boston
3+
// MITRE Corporation
4+
// Distributed under the MIT software license, see the accompanying
5+
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
6+
7+
#include "tools/config_generator/config_generator.hpp"
8+
#include "util/common/config.hpp"
9+
10+
#include <filesystem>
11+
#include <gtest/gtest.h>
12+
#include <string>
13+
14+
// TODO: Add file parsing tests.
15+
16+
class config_generation_validation_test : public ::testing::Test {
17+
protected:
18+
void SetUp() override {
19+
template_file_atomizer
20+
= "../config/unit/atomizer_template_unit_test.tmpl";
21+
template_file_2pc = "../config/unit/2pc_template_unit_test.tmpl";
22+
port_num = 5555;
23+
}
24+
25+
std::string template_file_atomizer;
26+
std::string template_file_2pc;
27+
size_t port_num;
28+
};
29+
30+
TEST_F(config_generation_validation_test,
31+
generate_configuration_file_atomizer_test) {
32+
// Assumes build dir is "build". Cannot find a way around this since unit
33+
// tests can be run from either root dir or build dir and we don't
34+
// necessarily know which one
35+
cbdc::generate_config::config_generator new_config_gen(
36+
template_file_atomizer,
37+
port_num);
38+
auto cfg_or_err = new_config_gen.generate_configuration_file();
39+
ASSERT_EQ(cfg_or_err, "SUCCESS");
40+
// TODO
41+
// Reload generate file and check values
42+
// Delete generated file
43+
}
44+
45+
TEST_F(config_generation_validation_test,
46+
generate_configuration_file_two_phase_test) {
47+
// Assumes build dir is "build". Cannot find a way around this since unit
48+
// tests can be run from either root dir or build dir and we don't
49+
// necessarily know which one
50+
cbdc::generate_config::config_generator new_config_gen(template_file_2pc,
51+
port_num);
52+
auto cfg_or_err = new_config_gen.generate_configuration_file();
53+
ASSERT_EQ(cfg_or_err, "SUCCESS");
54+
// TODO
55+
// Reload generate file and check values
56+
// Delete generated file
57+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
2pc=1
2+
sentinel_count=1
3+
shard_count=1
4+
coordinator_count=1
5+
coordinator_max_threads=1
6+
election_timeout_upper=4000
7+
election_timeout_lower=3000
8+
heartbeat=1000
9+
raft_max_batch=100000
10+
snapshot_distance=1000000000
11+
batch_size=1
12+
wait_for_followers=0
13+
loadgen_invalid_tx_rate=0.00
14+
loadgen_fixed_tx_rate=0.01
15+
loadgen_sendtx_output_count=1
16+
loadgen_sendtx_input_count=1
17+
initial_mint_count=20000
18+
initial_mint_value=100
19+
tmpl_randomize_values=1
20+
tmpl_shard_start=0
21+
tmpl_shard_size=255
22+
tmpl_max_shard_raft_replication_count=1
23+
tmpl_avg_shard_start_end_overlap_percent=0.15
24+
tmpl_max_coordinator_raft_replication_count=1
25+
tmpl_default_log_level="INFO"
26+
tmpl_universal_override_log_level="WARN"
27+
tmpl_sentinel_log_level="WARN"
28+
tmpl_coordinator_log_level="DEBUG"
29+
tmpl_shard_log_level="DEBUG"
30+
num_wallets=10
31+
num_minters=1
32+
num_redeemers=1
33+
total_number_of_transactions=100
34+
avg_mint_value=10
35+
avg_mint_count=10
36+
avg_redemption_value=5
37+
avg_redemption_count=5
38+
transaction_frequency=5
39+
mint_frequency=0.1
40+
redemption_frequency=0.05
41+
sentinel_offline_probability=0.01
42+
shard_offline_probability=0.01
43+
coordinator_offline_probability=0.01
44+
randomize_execution=0

0 commit comments

Comments
 (0)