Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat/docker bitcoind regest mode #60

Merged
merged 5 commits into from
Dec 17, 2024
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,5 @@ go.work.sum

# binaries
out

contrib/regtest
41 changes: 41 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -63,3 +63,44 @@ endif
cover-html: test-unit-cover
@echo "--> Opening in the browser"
@go tool cover -html=$(TEST_COVERAGE_PROFILE)

###############################################################################
## Infrastructure ##
###############################################################################

BITCOIND_SNAPSHOT=$(shell pwd)/contrib/snapshot
BITCOIND_DATA=$(shell pwd)/contrib/regtest

run-bitcoind:
@docker run -v $(BITCOIND_DATA):/bitcoin/.bitcoin --name=bitcoind-node -d \
-p 18444:8333 \
-p 127.0.0.1:18443:8332 \
-e REGTEST=1 \
-e DISABLEWALLET=0 \
-e PRINTTOCONSOLE=1 \
-e RPCUSER=mysecretrpcuser \
-e RPCPASSWORD=mysecretrpcpassword \
kylemanna/bitcoind
vuvoth marked this conversation as resolved.
Show resolved Hide resolved
@sleep 1
@docker exec -it bitcoind-node bitcoin-cli -regtest -rpcport=8332 loadwallet "nativewallet"

create-bitcoind: snapshot run-bitcoind
vuvoth marked this conversation as resolved.
Show resolved Hide resolved

start-bitcoind:
vuvoth marked this conversation as resolved.
Show resolved Hide resolved
@docker start bitcoind-node

stop-bitcoind:
@docker stop bitcoind-node

delete-bitcoind:
@docker rm -f bitcoind-node

restart-bitcoind: delete-bitcoind create-bitcoind

snapshot:
vuvoth marked this conversation as resolved.
Show resolved Hide resolved
@rm -rf $(BITCOIND_DATA)
@cp -rf $(BITCOIND_SNAPSHOT) $(BITCOIND_DATA)




File renamed without changes.
33 changes: 33 additions & 0 deletions contrib/MockBitcoind.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# Run bitcoind regtest node

## Create bitcoind node

Create a new bitcoind node with snapshot data

```bash
make create-bitcoind
vuvoth marked this conversation as resolved.
Show resolved Hide resolved
```

## Stop bitcoind node

```bash
make stop-bitcoind
```

## Start bitcoind node

You can start bitcoind node again. This command will keep any state you change on bitcoind node.
vuvoth marked this conversation as resolved.
Show resolved Hide resolved

## Restart bitcoind node

Restart bitcoind will create node with snapshot data.
vuvoth marked this conversation as resolved.
Show resolved Hide resolved

```bash
make restart-bitcoind
```

## Interact with bitcoind node

```bash
docker exec -it bitcoind-node bitcoin-cli -regtest -rpcport=8332 <args>
```
5 changes: 5 additions & 0 deletions contrib/snapshot/bitcoin.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
regtest=1
disablewallet=0
printtoconsole=1
rpcuser=mysecretrpcuser
rpcpassword=mysecretrpcpassword
vuvoth marked this conversation as resolved.
Show resolved Hide resolved
Empty file added contrib/snapshot/regtest/.lock
Empty file.
5 changes: 5 additions & 0 deletions contrib/snapshot/regtest/banlist.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"_warning_": "This file is automatically generated and updated by Bitcoin Core. Please do not edit this file while the node is running, as any changes might be ignored or overwritten.",
"banned_nets": [
]
}
1 change: 1 addition & 0 deletions contrib/snapshot/regtest/bitcoind.pid
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
1
Binary file added contrib/snapshot/regtest/blocks/blk00000.dat
Binary file not shown.
Binary file added contrib/snapshot/regtest/blocks/index/000007.ldb
Binary file not shown.
Empty file.
1 change: 1 addition & 0 deletions contrib/snapshot/regtest/blocks/index/CURRENT
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
MANIFEST-000006
Empty file.
Binary file not shown.
Binary file added contrib/snapshot/regtest/blocks/rev00000.dat
Binary file not shown.
1 change: 1 addition & 0 deletions contrib/snapshot/regtest/blocks/xor.dat
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
>ĄOńřÍrz
Binary file added contrib/snapshot/regtest/chainstate/000005.ldb
Binary file not shown.
Binary file added contrib/snapshot/regtest/chainstate/000012.ldb
Binary file not shown.
Empty file.
1 change: 1 addition & 0 deletions contrib/snapshot/regtest/chainstate/CURRENT
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
MANIFEST-000014
Empty file.
Binary file added contrib/snapshot/regtest/chainstate/MANIFEST-000014
Binary file not shown.
1,948 changes: 1,948 additions & 0 deletions contrib/snapshot/regtest/debug.log

Large diffs are not rendered by default.

Binary file added contrib/snapshot/regtest/fee_estimates.dat
Binary file not shown.
Binary file added contrib/snapshot/regtest/mempool.dat
Binary file not shown.
Binary file added contrib/snapshot/regtest/peers.dat
Binary file not shown.
3 changes: 3 additions & 0 deletions contrib/snapshot/regtest/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"_warning_": "This file is automatically generated and updated by Bitcoin Core. Please do not edit this file while the node is running, as any changes might be ignored or overwritten."
}
Binary file not shown.
Binary file not shown.
Loading