Skip to content

Commit 90432e1

Browse files
committed
Update docs
1 parent 0616efc commit 90432e1

File tree

2 files changed

+80
-38
lines changed

2 files changed

+80
-38
lines changed

docs/src/installation.md

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,19 +5,26 @@
55
### Install prerequisites
66

77
Since subcoin is a Substrate-based chain, you must install the necessary development tools to compile the binary from source.
8-
Please refer to https://docs.substrate.io/install/ for the full guide of installing the prerequisites.
8+
Please refer to https://docs.substrate.io/install/ for the full guide on installing the prerequisites.
99

1010
### Compile subcoin node binary
1111

12-
Once the required packages and Rust installed, we can proceed to compile the binary.
12+
Once the required packages and Rust are installed, proceed to compile the binary:
1313

1414
```bash
1515
cargo build --profile production --bin subcoin
1616
```
1717

18-
The Subcoin node executable `subcoin` should be present at `target/production/subcoin`.
18+
The Subcoin node executable `subcoin` should be located at `target/production/subcoin`.
1919

20-
## Docker
20+
### Prebuilt executables
2121

22-
```
22+
You can download the prebuilt executables from GitHub https://github.com/subcoin-project/subcoin/releases/tag/v0.1.0.
23+
24+
## Docker (Linux/amd64)
25+
26+
To use the Docker image for Subcoin, run the following command:
27+
28+
```bash
29+
docker pull ghcr.io/subcoin-project/subcoin:v0.1.0
2330
```

docs/src/usage.md

Lines changed: 68 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -2,51 +2,54 @@
22

33
<!-- clap-markdown-toc -->
44

5-
* [Import bitcoin blocks from `bitcoind` database](#import-bitcoin-blocks-from-`bitcoind`-database)
6-
* [Run `bitcoind`](#run-`bitcoind`)
7-
* [Run `subcoin import-blocks`](#run-`subcoin-import-blocks`)
8-
* [Verify the state of UTXO set](#verify-the-state-of-utxo-set)
5+
* [Import Bitcoin Blocks from `bitcoind` Database](#import-bitcoin-blocks-from-bitcoind-database)
6+
* [Get the `bitcoind` Binary](#get-the-bitcoind-binary)
7+
* [Run `subcoin import-blocks`](#run-subcoin-import-blocks)
8+
* [Verify the UTXO Set State](#verify-the-utxo-set-state)
99

1010
<!-- /clap-markdown-toc -->
1111

12-
This page only describes a subnet of features supported in subcoin with details, check out `subcoin --help` for the full usage.
12+
This page covers some specific features supported in Subcoin. For full usage details, refer to `subcoin --help`.
1313

14-
## Import bitcoin blocks from `bitcoind` database
14+
## Import Bitcoin Blocks from `bitcoind` Database
1515

16-
### Run `bitcoind`
16+
### Get the `bitcoind` Binary
1717

18-
Firstly, we need to install the `bitcoind` binary which can be downloaded directly from [https://bitcoincore.org/en/download](https://bitcoincore.org/en/download/).
19-
And then we need to spin up a `bitcoind` node with `txindex` and `coinstatsindex` enabled. `txindex` is required to import the blocks in subcoin, `coinstatsindex` is required
20-
to query the UTXO set of specific block later.
18+
To have flexible control over `bitcoind` behavior, it’s recommended to compile the `bitcoind` binary from source rather than downloading it directly from [Bitcoin releases](https://github.com/bitcoin/bitcoin/releases) which do not conveniently expose developer-oriented options. You can find the build instructions for your operating system under `build-*.md` in the [Bitcoin repository](https://github.com/bitcoin/bitcoin/tree/master/doc). For Linux, refer to [build-unix.md](https://github.com/bitcoin/bitcoin/blob/master/doc/build-unix.md).
2119

22-
For instance, we use `/tmp/btc-data` as the data dir:
20+
```bash
21+
# Ensure these two commands exist after successfully compiling the Bitcoin Core source code.
22+
./src/bitcoind --help
23+
./src/bitcoin-cli --help
24+
```
2325

24-
<!-- TODO: specify the exact version of bitcoind we are using here. -->
26+
Next, start a `bitcoind` node with `txindex` and `coinstatsindex` enabled. `txindex` is necessary for importing blocks into Subcoin, and `coinstatsindex` is required to query and verify the UTXO set of a specific block later. For example, use `/tmp/btc-data` as the data directory:
2527

2628
```bash
2729
mkdir -p /tmp/btc-data && ./src/bitcoind -datadir=/tmp/btc-data -txindex -coinstatsindex
2830
```
2931

30-
Keep the `bitcoind` process running for a while and ensure it has synced a number of blocks.
32+
Keep the `bitcoind` process running for a while to ensure it has synchronized a number of blocks. Note that `bitcoind` will first synchronize the block headers and only start downloading blocks after the headers are synced. This step might take some time depending on the peer connections (10+ minutes on my machine).
3133

32-
```text
34+
```log
3335
...
34-
8-29T01:17:02Z' progress=0.001342 cache=33.0MiB(304329txo)
3536
2024-07-11T17:23:10Z UpdateTip: new best=00000000000008c273c4c215892eacbafec33c199cfd3d9b539cdb6aafc39f54 height=142979 version=0x00000001 log2_work=66.385350 tx=1392173 date='2011-08-29T01:23:19Z' progress=0.001342 cache=33.0MiB(304442txo)
36-
2024-07-11T17:23:10Z UpdateTip: new best=000000000000000f338e8635c5f78666f0ca2e6b70425fe22aad47d2087a2740 height=142980 version=0x00000001 log2_work=66.385466 tx=1392186 date='2011-08-29T01:29:29Z' progress=0.001342 cache=33.0MiB(304451txo)
37-
2024-07-11T17:23:10Z UpdateTip: new best=000000000000071504dedbc2edd4ae008aca9a6086afb3d4d9cd3cbdd0e67b04 height=142981 version=0x00000001 log2_work=66.385582 tx=1392218 date='2011-08-29T01:35:02Z' progress=0.001342 cache=33.0MiB(304470txo)
38-
2024-07-11T17:23:10Z UpdateTip: new best=00000000000001c59463d1a0b6d70274ed4aea4cf757289363ff99f670f02812 height=142982 version=0x00000001 log2_work=66.385698 tx=1392232 date='2011-08-29T01:37:36Z' progress=0.001342 cache=33.0MiB(304605txo)
37+
...
3938
```
4039

41-
Now stop the `bitcoind` process and proceed to import the blocks in `bitcoind` database into subcoin.
40+
Stop the `bitcoind` process and proceed to import the blocks from the `bitcoind` database into Subcoin.
4241

4342
### Run `subcoin import-blocks`
4443

44+
Ensure you have installed `subcoin`. If not, refer to [installation](./installation.md) to install the `subcoin` binary.
45+
4546
```bash
46-
target/release/subcoin import-blocks /tmp/btc-data
47+
# Specify `subcoin-data` as the data directory for Subcoin and import the blocks from `/tmp/btc-data` which is the `bitcoind` database we set up earlier.
48+
# `--state-pruning archive` is necessary for querying the state of the Subcoin UTXO set later.
49+
subcoin import-blocks /tmp/btc-data -d subcoin-data --state-pruning archive
4750
```
4851

49-
You'll see the output like this:
52+
You should see output similar to this:
5053

5154
```log
5255
2024-07-12 01:28:51 🔨 Initializing Genesis block/state (state: 0x1c68…f3f8, header-hash: 0xbdc8…a76b)
@@ -57,36 +60,68 @@ You'll see the output like this:
5760
2024-07-12 01:28:53 Start loading block_index
5861
2024-07-12 01:28:53 Successfully opened tx_index DB!
5962
2024-07-12 01:28:53 Start to import blocks from #1 to #142984 from bitcoind database: /tmp/btc-data
60-
2024-07-12 01:28:54 Imported 1000 blocks,, best#1001,00000000a2887344f8db859e372e7e4bc26b23b9de340f725afbf2edb265b4c6 (0x3ff4…6eb5)
61-
2024-07-12 01:28:54 Imported 2000 blocks, 3802.2 bps, best#2001,0000000067217a46c49054bad67cda2da943607d326e89896786de10b07cb7c0 (0x296d…6a47)
62-
2024-07-12 01:28:54 Imported 3000 blocks, 3636.3 bps, best#3001,00000000ee1d6b98d28b71c969d4bc8a20ee43a379ce49547bcad30c606d8845 (0xac16…c220)
63-
2024-07-12 01:28:54 Imported 4000 blocks, 3597.1 bps, best#4001,00000000a86f68e8de06c6b46623fdd16b7a11ad9651fa48ecbe8c731658dc06 (0xb5bd…8a28)
64-
2024-07-12 01:28:55 Imported 5000 blocks, 3773.5 bps, best#5001,00000000284bcd658fd7a76f5a88ee526f18592251341a05fd7f3d7abaf0c3ec (0x751f…3375)
65-
2024-07-12 01:28:55 Imported 6000 blocks, 3484.3 bps, best#6001,0000000055fcaf04cb9a82bb86b46a21b15fcaa75ac8c18679b0234f79c4c615 (0xcc4a…3090)
63+
2024-07-12 01:28:54 Imported 1000 blocks, best#1001,00000000a2887344f8db859e372e7e4bc26b23b9de340f725afbf2edb265b4c6 (0x3ff4…6eb5)
6664
...
6765
```
6866

67+
By default, Subcoin will import all blocks up to the latest indexed Bitcoin block in the `bitcoind` database. You can specify the total number of blocks to import or the target number of blocks to import:
68+
69+
```bash
70+
# Import 20000 blocks from the best block of Subcoin.
71+
subcoin import-blocks /tmp/btc-data -d subcoin-data --block-count 20000
72+
73+
# Import blocks up to height 30000.
74+
subcoin import-blocks /tmp/btc-data -d subcoin-data --end-block 30000
75+
```
76+
6977
<div class="warning">
7078

71-
NOTE: _The bitcoind process must be stopped when running the import-blocks command otherwise you will run into the following error_:
79+
NOTE: _The `bitcoind` process must be stopped when running the import-blocks command, otherwise you will encounter the following error_:
7280

7381
```text
7482
Error: Application(OpError { kind: None, message: "LevelDB error: IO error: lock /tmp/btc-data/blocks/index/LOCK: Resource temporarily unavailable" })
7583
```
7684

7785
</div>
7886

79-
### Verify the state of UTXO set
87+
### Verify the UTXO Set State
8088

81-
`bitcoind` offers an interface to inspect the state of UTXO set, we can use it to check the the correctness of subcoin's the UTXO set after the blocks
82-
imported to the subcoin node successfully. For instance, export the UTXO set information at height 10000:
89+
`bitcoind` provides an interface to inspect the UTXO set state. This can be used to check the correctness of Subcoin’s UTXO set after importing blocks. For example, to export the UTXO set of `bitcoind` at height 10000:
8390

8491
```bash
92+
# Note that running this command requires the bitcoind process running in the background.
93+
# If it was stopped, now restart it. You can stop it again after this command finishes.
8594
./src/bitcoin-cli -datadir=/tmp/btc-data gettxoutsetinfo none 10000 true
95+
{
96+
"height": 10000,
97+
"bestblock": "0000000099c744455f58e6c6e98b671e1bf7f37346bfd4cf5d0274ad8ee660cb",
98+
"txouts": 9494,
99+
"bogosize": 1109244,
100+
"total_amount": 500000.00000000,
101+
"total_unspendable_amount": 50.00000000,
102+
"block_info": {
103+
"prevout_spent": 0.00000000,
104+
"coinbase": 50.00000000,
105+
"new_outputs_ex_coinbase": 0.00000000,
106+
"unspendable": 0.00000000,
107+
"unspendables": {
108+
"genesis_block": 0.00000000,
109+
"bip30": 0.00000000,
110+
"scripts": 0.00000000,
111+
"unclaimed_rewards": 0.00000000
112+
}
113+
}
114+
}
86115
```
87116

88-
Check out the state of UTXO set in subcoin at the same height:
117+
Check the state of the UTXO set in Subcoin at the same height:
89118

90119
```bash
91-
./target/release/subcoin blockchain gettxoutsetinfo --height 10000 -d /tmp/subcoin-data
120+
# Note that the existing `gettxoutsetinfo` only displays a subset of the information in `bitcoind`.
121+
subcoin blockchain gettxoutsetinfo --height 10000 -d subcoin-data
122+
block_number: 10000
123+
block_hash: 0000000099c744455f58e6c6e98b671e1bf7f37346bfd4cf5d0274ad8ee660cb
124+
txouts: 9494
125+
bogosize: 1109244
126+
total_amount: 500000.00000000
92127
```

0 commit comments

Comments
 (0)