Closed marekyggdrasil closed 3 years ago
Goal of this issue is to test the compact_chain
API method.
compact_chain
API methodWe would expect would expect the chain to be compacted and take less space. Output should match the example. Include all cURL requests and responses.
Include the exact version of your grin-node and also your environment
uname -a
OS: Debian 10 \
Grin Node: grin 5.0.0-rc.1
\
System Info: Linux debian 4.19.0-13-amd64 #1 SMP Debian 4.19.160-2 (2020-11-28) x86_64 GNU/Linux
For my first test run, running the compact_chain
API method on a brand new node has no observable effect on the disk usage of the chain data. My second test run was more successful when I used the archive node I first ran in issue #5.
$ cd grin-5.0.0-rc.1/target/release/
$ ./grin
chain_data
is, which should be in ~/.grin/main/
, If you ran ./grin server config
after building the node, it should be in ~/grin-5.0.0-rc.1/target/release/
.
$ cd ~/.grin/main/
$ du -c chain_data/
compact_chain
API methodCreate a new bash script to run the cURL request.
compact_chain.sh
#!/bin/bash
# Get the grin node foreign api password
secret=$(cat ~/.grin/main/.api_secret)
# Call the node's foreign api "compact_chain" method
curl -ugrin:$secret localhost:3413/v2/owner -d '{"jsonrpc": "2.0", "method": "compact_chain", "params": [], "id": 1}' -v -w "\n"
$ bash compact_chain.sh
The API response will appear as expected at the end of a long verbose cURL output.
Expected response of running the compact_chain
method:
{
"id": 1,
"jsonrpc": "2.0",
"result": {
"Ok": null
}
}
chain_data
is and run the du
command.
$ du -c chain_data/
chain_data
size before running the compact_chain
API method$ du -c chain_data/
Output:
469580 chain_data/txhashset/kernel
303084 chain_data/txhashset/rangeproof
62996 chain_data/txhashset/output
835664 chain_data/txhashset
1484 chain_data/peer
117232 chain_data/header/sync_head
117260 chain_data/header/header_head
234496 chain_data/header
794268 chain_data/lmdb
1865916 chain_data/
1865916 total
TUI view of the GRIN-Node:
┌──────────────────────────────────────────────────────────────────────────────┐
│Grin Version 5.0.0-rc.1 [Mainnet] │
└──────────────────────────────────────────────────────────────────────────────┘
┌──────────────────┐┌──────────────────────────────────────────────────────────┐
│Basic Status ││ │
│Peers and Sync ││ Current Status: Running │
│Mining ││ Connected Peers: 8 │
│Logs ││ Disk Usage (GB): 1.911 │
│Version Info ││ -------------------------------------------------------- │
│ ││ Header Tip Hash: 00049c208bde... │
│ ││ Header Chain Height: 1026121 │
│ ││ Header Cumulative Difficulty: 1738799139276499 │
│ ││ Header Tip Timestamp: 2020-12-31 11:52:27 UTC │
│ ││ -------------------------------------------------------- │
│ ││ Chain Tip Hash: 00049c208bde... │
│ ││ Chain Height: 1026121 │
│ ││ Chain Cumulative Difficulty: 1738799139276499 │
│ ││ Chain Tip Timestamp: 2020-12-31 11:52:27 UTC │
│------------------││ -------------------------------------------------------- │
│Tab/Arrow : Cycle ││ Transaction Pool Size: 0 (0) │
│Enter : Select││ Stem Pool Size: 0 (0) │
│Esc : Back ││ -------------------------------------------------------- │
│Q : Quit ││ │
└──────────────────┘└──────────────────────────────────────────────────────────┘
compact_chain.sh
bash script$ bash compact_chain.sh
Output:
* Expire in 0 ms for 6 (transfer 0x563fb6e71f90)
* Expire in 1 ms for 1 (transfer 0x563fb6e71f90)
* Expire in 0 ms for 1 (transfer 0x563fb6e71f90)
* Expire in 1 ms for 1 (transfer 0x563fb6e71f90)
* Expire in 0 ms for 1 (transfer 0x563fb6e71f90)
* Expire in 0 ms for 1 (transfer 0x563fb6e71f90)
* Expire in 1 ms for 1 (transfer 0x563fb6e71f90)
* Expire in 0 ms for 1 (transfer 0x563fb6e71f90)
...
...
* Expire in 0 ms for 1 (transfer 0x563fb6e71f90)
* Expire in 0 ms for 1 (transfer 0x563fb6e71f90)
* Expire in 2 ms for 1 (transfer 0x563fb6e71f90)
* Expire in 0 ms for 1 (transfer 0x563fb6e71f90)
* Expire in 0 ms for 1 (transfer 0x563fb6e71f90)
* Expire in 0 ms for 1 (transfer 0x563fb6e71f90)
* Trying ::1...
* TCP_NODELAY set
* Expire in 149999 ms for 3 (transfer 0x563fb6e71f90)
* Expire in 200 ms for 4 (transfer 0x563fb6e71f90)
* connect to ::1 port 3413 failed: Connection refused
* Trying 127.0.0.1...
* TCP_NODELAY set
* Expire in 149999 ms for 3 (transfer 0x563fb6e71f90)
* Connected to localhost (127.0.0.1) port 3413 (#0)
* Server auth using Basic with user 'grin'
> POST /v2/owner HTTP/1.1
> Host: localhost:3413
> Authorization: Basic Z3JpbjpxUEgxT1JzcE1TWTliRk5yZXZvWA==
> User-Agent: curl/7.64.0
> Accept: */*
> Content-Length: 68
> Content-Type: application/x-www-form-urlencoded
>
* upload completely sent off: 68 out of 68 bytes
< HTTP/1.1 200 OK
< access-control-allow-origin: *
< access-control-allow-headers: Content-Type, Authorization
< content-type: application/json
< content-length: 67
< date: Thu, 31 Dec 2020 11:53:43 GMT
<
{
"id": 1,
"jsonrpc": "2.0",
"result": {
"Ok": null
}
* Connection #0 to host localhost left intact
}
The API response at the end of the verbose output matches the expected response.
{
"id": 1,
"jsonrpc": "2.0",
"result": {
"Ok": null
}
}
chain_data
size again after it finished compactingThe disk usage shows the expected results, which is a decrease from the original chain_data
size.
Compared to the initial chain_data
output, the rangeproof
and output
part of the txhashset
data decreased in size.
$ du -c chain_data/
Output:
469580 chain_data/txhashset/kernel
302500 chain_data/txhashset/rangeproof
62920 chain_data/txhashset/output
835004 chain_data/txhashset
1484 chain_data/peer
117232 chain_data/header/sync_head
117260 chain_data/header/header_head
234496 chain_data/header
794268 chain_data/lmdb
1865256 chain_data/
1865256 total
TUI view of the GRIN-Node:
┌──────────────────────────────────────────────────────────────────────────────┐
│Grin Version 5.0.0-rc.1 [Mainnet] │
└──────────────────────────────────────────────────────────────────────────────┘
┌──────────────────┐┌──────────────────────────────────────────────────────────┐
│Basic Status ││ │
│Peers and Sync ││ Current Status: Running │
│Mining ││ Connected Peers: 8 │
│Logs ││ Disk Usage (GB): 1.910 │
│Version Info ││ -------------------------------------------------------- │
│ ││ Header Tip Hash: 000207bfa946... │
│ ││ Header Chain Height: 1026122 │
│ ││ Header Cumulative Difficulty: 1738799310705629 │
│ ││ Header Tip Timestamp: 2020-12-31 11:52:46 UTC │
│ ││ -------------------------------------------------------- │
│ ││ Chain Tip Hash: 000207bfa946... │
│ ││ Chain Height: 1026122 │
│ ││ Chain Cumulative Difficulty: 1738799310705629 │
│ ││ Chain Tip Timestamp: 2020-12-31 11:52:46 UTC │
│------------------││ -------------------------------------------------------- │
│Tab/Arrow : Cycle ││ Transaction Pool Size: 0 (0) │
│Enter : Select││ Stem Pool Size: 0 (0) │
│Esc : Back ││ -------------------------------------------------------- │
│Q : Quit ││ │
└──────────────────┘└──────────────────────────────────────────────────────────┘
chain_data
disk usage1 | 2 | |
---|---|---|
kernel | 469580 | 469580 |
rangeproof | 303084 | 302500 |
output | 62996 | 62920 |
peer | 1484 | 1484 |
sync_head | 117232 | 117232 |
header_head | 117260 | 117260 |
lmdb | 794268 | 794268 |
Testing on an archive node that was already running for several days shows a successful output. The compact_chain
API method seems to work correctly, although it may require a slow buildup of new chain data to be able to successfully compact itself.
Excellent results! And we even have a bash script! Great work @goyle !
Description Goal of this issue is to test the compact_chain API method
Prerequisites
Test procedure
Expected result:
We would expect would expect the chain to be compacted and take less space. Output should match the example. Include all cURL requests and responses.
Include the exact version of your grin-node and also your environment