Skip to content

Commit d99bc2f

Browse files
wileyjjcnelson
authored andcommitted
change --config= to --config
1 parent 598d4bf commit d99bc2f

File tree

6 files changed

+39
-16
lines changed

6 files changed

+39
-16
lines changed

Diff for: contrib/init/org.stacks.stacks-blockchain.plist

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
<array>
99
<string>/usr/local/bin/stacks-node</string>
1010
<string>start</string>
11-
<string>--config=/etc/stacks-blockchain/Config.toml</string>
11+
<string>--config /etc/stacks-blockchain/Config.toml</string>
1212
</array>
1313

1414
<key>ProcessType</key>

Diff for: contrib/init/stacks.init

+1-1
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ start() {
6060
return 1
6161
fi
6262
echo -n $"Starting $prog: "
63-
$stacks_bin start --config="$stacks_config" > "$stacks_log" 2>&1 &
63+
$stacks_bin start --config "$stacks_config" > "$stacks_log" 2>&1 &
6464
RETVAL=$?
6565
[ $RETVAL -eq 0 ] && touch "$lockfile"
6666
echo

Diff for: contrib/init/stacks.service

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ ConditionPathExists=/etc/stacks-blockchain/Config.toml
1111
ConditionPathIsDirectory=/stacks-blockchain
1212

1313
[Service]
14-
ExecStart=/usr/local/bin/stacks-node start --config=/etc/stacks-blockchain/Config.toml
14+
ExecStart=/usr/local/bin/stacks-node start --config /etc/stacks-blockchain/Config.toml
1515

1616
# Make sure the config directory is readable by the service user
1717
PermissionsStartOnly=true

Diff for: docs/profiling.md

+31-8
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# Profiling Tools
22

33
This document describes several techniques to profile (i.e. find performance bottlenecks) the stacks-node mining loop, including:
4+
45
- configuring debug logging,
56
- setting up a mock mining node,
67
- recording inbound transactions,
@@ -15,7 +16,7 @@ Note that all bash commands in this document are run from the stacks-blockchain
1516
Validating the config file using `stacks-node check-config`:
1617

1718
```
18-
$ cargo run -r -p stacks-node --bin stacks-node check-config --config=testnet/stacks-node/conf/mainnet-mockminer-conf.toml
19+
$ cargo run -r -p stacks-node --bin stacks-node check-config --config testnet/stacks-node/conf/mainnet-mockminer-conf.toml
1920
INFO [1661276562.220137] [testnet/stacks-node/src/main.rs:82] [main] stacks-node 0.1.0 (tip-mine:c90476aa8a+, release build, macos [aarch64])
2021
INFO [1661276562.220363] [testnet/stacks-node/src/main.rs:115] [main] Loading config at path testnet/stacks-node/conf/mainnet-mockminer-conf.toml
2122
INFO [1661276562.233071] [testnet/stacks-node/src/main.rs:128] [main] Valid config!
@@ -24,7 +25,7 @@ INFO [1661276562.233071] [testnet/stacks-node/src/main.rs:128] [main] Valid conf
2425
Enabling debug logging using environment variable `STACKS_LOG_DEBUG=1`:
2526

2627
```
27-
$ STACKS_LOG_DEBUG=1 cargo run -r -p stacks-node --bin stacks-node check-config --config=testnet/stacks-node/conf/mainnet-mockminer-conf.toml
28+
$ STACKS_LOG_DEBUG=1 cargo run -r -p stacks-node --bin stacks-node check-config --config testnet/stacks-node/conf/mainnet-mockminer-conf.toml
2829
INFO [1661276562.220137] [testnet/stacks-node/src/main.rs:82] [main] stacks-node 0.1.0 (tip-mine:c90476aa8a+, release build, macos [aarch64])
2930
INFO [1661276562.220363] [testnet/stacks-node/src/main.rs:115] [main] Loading config at path testnet/stacks-node/conf/mainnet-mockminer-conf.toml
3031
DEBG [1661276562.222450] [testnet/stacks-node/src/main.rs:118] [main] Loaded config file: ConfigFile { burnchain: Some(BurnchainConfigFile { chain: Some("bitcoin"), burn_fee_cap: Some(1), mode: Some("mainnet"), commit_anchor_block_within: None, peer_host: Some("bitcoind.stacks.co"), peer_port: Some(8333), rpc_port: Some(8332), rpc_ssl: None, username: Some("blockstack"), password: Some("blockstacksystem"), timeout: None, magic_bytes: None, local_mining_public_key: None, process_exit_at_block_height: None, poll_time_secs: None, satoshis_per_byte: None, leader_key_tx_estimated_size: None, block_commit_tx_estimated_size: None, rbf_fee_increment: None, max_rbf: None, epochs: None }), node: Some(NodeConfigFile { name: None, seed: None, deny_nodes: None, working_dir: Some("/Users/igor/w/stacks-work/working_dir"), rpc_bind: Some("0.0.0.0:20443"), p2p_bind: Some("0.0.0.0:20444"), p2p_address: None, data_url: None, bootstrap_node: Some("02196f005965cebe6ddc3901b7b1cc1aa7a88f305bb8c5893456b8f9a605923893@seed.mainnet.hiro.so:20444"), local_peer_seed: None, miner: Some(true), mock_mining: Some(true), mine_microblocks: None, microblock_frequency: None, max_microblocks: None, wait_time_for_microblocks: None, prometheus_bind: None, marf_cache_strategy: None, marf_defer_hashing: None, pox_sync_sample_secs: None, use_test_genesis_chainstate: None }), ustx_balance: None, events_observer: Some([EventObserverConfigFile { endpoint: "localhost:3700", events_keys: ["*"] }]), connection_options: None, fee_estimation: None, miner: None }
@@ -34,7 +35,7 @@ INFO [1661276562.233071] [testnet/stacks-node/src/main.rs:128] [main] Valid conf
3435
Enabling json logging using environment variable `STACKS_LOG_JSON=1` and feature flag `slog_json`:
3536

3637
```
37-
$ STACKS_LOG_JSON=1 cargo run -F slog_json -r -p stacks-node --bin stacks-node check-config --config=testnet/stacks-node/conf/mainnet-mockminer-conf.toml
38+
$ STACKS_LOG_JSON=1 cargo run -F slog_json -r -p stacks-node --bin stacks-node check-config --config testnet/stacks-node/conf/mainnet-mockminer-conf.toml
3839
{"msg":"stacks-node 0.1.0 (tip-mine:c90476aa8a+, release build, macos [aarch64])","level":"INFO","ts":"2022-08-23T12:44:28.072462-05:00","thread":"main","line":82,"file":"testnet/stacks-node/src/main.rs"}
3940
{"msg":"Loading config at path testnet/stacks-node/conf/mainnet-mockminer-conf.toml","level":"INFO","ts":"2022-08-23T12:44:28.074238-05:00","thread":"main","line":115,"file":"testnet/stacks-node/src/main.rs"}
4041
{"msg":"Valid config!","level":"INFO","ts":"2022-08-23T12:44:28.089960-05:00","thread":"main","line":128,"file":"testnet/stacks-node/src/main.rs"}
@@ -53,6 +54,7 @@ $ export STACKS_SNAPSHOT_DIR=$STACKS_DIR/snapshot
5354
## Setting up the mock mining node
5455

5556
Download and extract an archived snapshot of mainnet working directory, provided by Hiro.
57+
5658
```
5759
$ wget -P $STACKS_DIR https://storage.googleapis.com/blockstack-publish/archiver-main/follower/mainnet-follower-latest.tar.gz
5860
$ tar xzvf $STACKS_DIR/mainnet-follower-latest.tar.gz -C $STACKS_DIR
@@ -65,17 +67,19 @@ We'll be using the `stacks-node` config file available at:
6567
Note that, for convenience, the `stacks-node` binary uses the environment variable `$STACKS_WORKING_DIR` to override the working directory location in the config file.
6668

6769
```
68-
$ cargo run -r -p stacks-node --bin stacks-node start --config=testnet/stacks-node/conf/mocknet-miner-conf.toml
70+
$ cargo run -r -p stacks-node --bin stacks-node start --config testnet/stacks-node/conf/mocknet-miner-conf.toml
6971
```
7072

7173
The `stacks-node` process will receive blocks starting from the latest block available in the Hiro archive.
7274

7375
Check the latest tip height of our node.
76+
7477
```
7578
$ curl -s 127.0.0.1:20443/v2/info | jq .stacks_tip_height
7679
```
7780

7881
Compare our node's tip height to a public node's tip height to check when our node is fully synchronized.
82+
7983
```
8084
$ curl -s seed-0.mainnet.stacks.co:20443/v2/info | jq .stacks_tip_height
8185
```
@@ -85,16 +89,19 @@ Once the node is synchronized, terminate the `stacks-node` process so we can set
8589
## Recording blockchain events
8690

8791
Run `stacks-events` to receive and archive events:
92+
8893
```
8994
$ cargo run -r -p stacks-node --bin stacks-events | tee $STACKS_DIR/events.log
9095
```
9196

9297
Run `stacks-node` with an event observer:
98+
9399
```
94-
$ STACKS_EVENT_OBSERVER=localhost:3700 cargo run -r -p stacks-node --bin stacks-node start --config=testnet/stacks-node/conf/mocknet-miner-conf.toml
100+
$ STACKS_EVENT_OBSERVER=localhost:3700 cargo run -r -p stacks-node --bin stacks-node start --config testnet/stacks-node/conf/mocknet-miner-conf.toml
95101
```
96102

97103
You should see output from `stacks-events` in `events.logs` similar to:
104+
98105
```
99106
$ tail -F $STACKS_DIR/events.log
100107
{"path":"drop_mempool_tx","payload":{"dropped_txids":["0x6f78047f15ac3309153fc34be94ed8895111304336aec1ff106b7de051021e17, ..., "ts":"2022-08-12T05:03:08.577Z"}
@@ -103,21 +110,25 @@ $ tail -F $STACKS_DIR/events.log
103110
## Historical Mining
104111

105112
Discover the first recorded block height:
113+
106114
```
107115
$ cat $STACKS_DIR/events.log | egrep new_block | head -1 | jq .payload.block_height
108116
```
109117

110118
Discover a lower bound number of recorded transactions. This is a lower bound because each line in the events file is a list of transactions.
119+
111120
```
112121
$ cat $STACKS_DIR/events.log | egrep new_mempool_tx | wc -l
113122
```
114123

115124
Make a snapshot of the working directory:
125+
116126
```
117127
$ cp -r $STACKS_WORKING_DIR $STACKS_SNAPSHOT_DIR
118128
```
119129

120130
Run the `tip-mine` benchmark:
131+
121132
```
122133
$ export STACKS_TIP_MINE_BLOCK_HEIGHT=71294
123134
$ export STACKS_TIP_MINE_NUM_TXS=100
@@ -137,9 +148,11 @@ INFO [1661274285.417171] [src/chainstate/stacks/miner.rs:1628] [main] Miner: min
137148
Successfully mined block @ height = 71295 off of bd4fa09ece02e7fd53493c96bd69b89155058f7b28d4a659d87d89644208f41e (96cc06519e670eefb674aa2e9cfe0cfae103d4da/f0f0caa2afaae75417f14fe2fad1e3fd52b0169e66cb045b4954b9ab78611f31) in 7310ms.
138149
Block 4a64e0a4012acb6748a08784876c23f6f61aba08b7c826db5b57832935278f33: 3227082 uSTX, 31587 bytes, cost ExecutionCost { write_length: 84090, write_count: 1170, read_length: 20381499, read_count: 7529, runtime: 103717315 }
139150
```
151+
140152
In this run, `tip-mine` mined a block with 87 transactions.
141153

142154
Alternatively, you can run `cargo build` separately from the target binary `stacks-inspect` to avoid re-building and speed up profiling:
155+
143156
```
144157
$ cargo build -F disable-costs -r --bin stacks-inspect
145158
$ ./target/release/stacks-inspect tip-mine $STACKS_SNAPSHOT_DIR $STACKS_DIR/events.log $STACKS_TIP_MINE_BLOCK_HEIGHT $STACKS_TIP_MINE_NUM_TXS
@@ -158,16 +171,19 @@ $ cargo install flamegraph
158171
flamegraph-rs uses [dtrace](https://en.wikipedia.org/wiki/DTrace) for profiling on Mac.
159172

160173
Build `stacks-inspect` using the feature `disable-costs` to disable the block cost limits:
174+
161175
```
162176
$ cargo build -F disable-costs -r --bin stacks-inspect
163177
```
164178

165179
Generate a flame graph:
180+
166181
```
167182
$ flamegraph --root -o perf.svg -e cpu-clock --min-width 1 --deterministic -- ./target/release/stacks-inspect tip-mine $STACKS_SNAPSHOT_DIR $STACKS_DIR/events.log $STACKS_TIP_MINE_BLOCK_HEIGHT $STACKS_TIP_MINE_NUM_TXS
168183
```
169184

170185
You can open the flame graph using a browser:
186+
171187
```
172188
$ open perf.svg
173189
```
@@ -183,40 +199,47 @@ The Linux performance tool `perf` has a performance bug which has been fixed. If
183199
Background on the `perf` performance bug: https://eighty-twenty.org/2021/09/09/perf-addr2line-speed-improvement
184200

185201
Find out your kernel version:
202+
186203
```
187204
$ uname -a
188205
Linux localhost 5.15.0-25-generic #26~16.04.1-Ubuntu SMP Tue Oct 1 16:30:39 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux
189206
```
190207

191208
Install dependencies, clone the linux kernel source, checkout the version tag matching your kernel version and build perf:
209+
192210
```
193-
$ sudo apt install -y git libzstd-dev libunwind-dev libcap-dev libdw-dev libdwarf-dev libbfd-dev libelf-dev systemtap-sdt-dev binutils-dev libnuma-dev libiberty-dev bison flex
211+
$ sudo apt install -y git libzstd-dev libunwind-dev libcap-dev libdw-dev libdwarf-dev libbfd-dev libelf-dev systemtap-sdt-dev binutils-dev libnuma-dev libiberty-dev bison flex
194212
$ git clone https://github.com/torvalds/linux.git
195213
$ git checkout v5.15
196214
$ cd linux/tools/perf && make
197215
```
198216

199217
#### Running perf
218+
200219
Grant kernel permissions to perf:
220+
201221
```
202222
$ sudo sed -i "$ a kernel.perf_event_paranoid = -1" /etc/sysctl.conf
203223
$ sudo sed -i "$ a kernel.kptr_restrict = 0" /etc/sysctl.conf
204224
$ sysctl --system
205225
```
206226

207227
Note that you need to uncomment the following in `.cargo/config` (see [flamegraph-rs](https://github.com/flamegraph-rs/flamegraph) for details)
228+
208229
```
209230
[target.x86_64-unknown-linux-gnu]
210231
linker = "/usr/bin/clang"
211232
rustflags = ["-Clink-arg=-fuse-ld=lld", "-Clink-arg=-Wl,--no-rosegment"]
212233
```
213234

214235
Build `stacks-inspect` using the feature `disable-costs` to disable the block cost limits:
236+
215237
```
216238
$ cargo build -F disable-costs -r --bin stacks-inspect
217239
```
218240

219241
Generate a flame graph using the locally built `perf` binary:
242+
220243
```
221244
$ PERF=~/linux/tools/perf/perf flamegraph --cmd "record -F 97 --call-graph dwarf,65528 -g -e cpu-clock" -o perf.svg --min-width 0.5 --deterministic -- ./target/release/stacks-inspect tip-mine $STACKS_SNAPSHOT_DIR $STACKS_DIR/events.log $STACKS_TIP_MINE_BLOCK_HEIGHT $STACKS_TIP_MINE_NUM_TXS
222245
```
@@ -225,11 +248,11 @@ Output flame graph is in `perf.svg`.
225248

226249
## Profiling SQLite queries
227250

228-
Set the environment variable `STACKS_LOG_DEBUG=1` and use the cargo feature `profile-sqlite`:
251+
Set the environment variable `STACKS_LOG_DEBUG=1` and use the cargo feature `profile-sqlite`:
229252

230253
```
231254
$ STACKS_LOG_DEBUG=1 cargo run -F profile-sqlite,disable-costs -r --bin stacks-inspect try-mine $STACKS_WORKING_DIR
232255
...
233256
DEBG [1661217664.809057] [src/util_lib/db.rs:666] [main] sqlite trace profile {"millis":1,"query":"SELECT value FROM data_table WHERE key = ?"}
234257
...
235-
```
258+
```

Diff for: net-test/bin/start.sh

+3-3
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ start_stacks_master_node() {
145145
logln "ok"
146146

147147
log "[$$] Starting Stacks master node..."
148-
BLOCKSTACK_DEBUG=1 RUST_BACKTRACE=full stacks-node start --config="$STACKS_MASTER_CONF" >"$STACKS_MASTER_LOGFILE" 2>&1 &
148+
BLOCKSTACK_DEBUG=1 RUST_BACKTRACE=full stacks-node start --config "$STACKS_MASTER_CONF" >"$STACKS_MASTER_LOGFILE" 2>&1 &
149149
local STACKS_PID=$!
150150
logln "PID $STACKS_PID"
151151

@@ -233,7 +233,7 @@ start_stacks_miner_node() {
233233
logln "ok"
234234

235235
log "[$$] Starting Stacks miner node..."
236-
BLOCKSTACK_DEBUG=1 RUST_BACKTRACE=full stacks-node start --config="$STACKS_MINER_CONF" >"$STACKS_MINER_LOGFILE" 2>&1 &
236+
BLOCKSTACK_DEBUG=1 RUST_BACKTRACE=full stacks-node start --config "$STACKS_MINER_CONF" >"$STACKS_MINER_LOGFILE" 2>&1 &
237237
local STACKS_PID=$!
238238
logln "PID $STACKS_PID"
239239

@@ -265,7 +265,7 @@ start_stacks_follower_node() {
265265
logln "ok"
266266

267267
log "[$$] Starting Stacks follower node..."
268-
BLOCKSTACK_DEBUG=1 RUST_BACKTRACE=full stacks-node start --config="$STACKS_FOLLOWER_CONF" >"$STACKS_FOLLOWER_LOGFILE" 2>&1 &
268+
BLOCKSTACK_DEBUG=1 RUST_BACKTRACE=full stacks-node start --config "$STACKS_FOLLOWER_CONF" >"$STACKS_FOLLOWER_LOGFILE" 2>&1 &
269269
local STACKS_PID=$!
270270
logln "PID $STACKS_PID"
271271

Diff for: testnet/stacks-node/src/main.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -487,14 +487,14 @@ start\t\tStart a node with a config of your own. Can be used for joining a netwo
487487
\t\tArguments:
488488
\t\t --config: path of the config (such as https://github.com/blockstack/stacks-blockchain/blob/master/testnet/stacks-node/conf/testnet-follower-conf.toml).
489489
\t\tExample:
490-
\t\t stacks-node start --config=/path/to/config.toml
490+
\t\t stacks-node start --config /path/to/config.toml
491491
492492
check-config\t\tValidates the config file without starting up the node. Uses same arguments as start subcommand.
493493
494494
version\t\tDisplay information about the current version and our release cycle.
495495
496496
key-for-seed\tOutput the associated secret key for a burnchain signer created with a given seed.
497-
\t\tCan be passed a config file for the seed via the `--config=<file>` option *or* by supplying the hex seed on
497+
\t\tCan be passed a config file for the seed via the `--config <file>` option *or* by supplying the hex seed on
498498
\t\tthe command line directly.
499499
500500
help\t\tDisplay this help.

0 commit comments

Comments
 (0)