-
Notifications
You must be signed in to change notification settings - Fork 21
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
Fix: Decouple version numbers from run-bitcoind.sh to improve maintainability #112
base: master
Are you sure you want to change the base?
Conversation
Hey @GideonBature, I’d like to test this locally. Could you please guide me on how to do that? Thanks! |
Oh! So here is a guide on how to test it:
v28 28.1.0 281 /opt/bin/bitcoind Used Note: Make sure you put the exact version of the With this you should be able to test the script file. Thank you @AdamuAbba. |
Thanks for the PR, I'll get to reviewing soon as I can. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ACK #7fb7b7d; successfully ran a local test.
Thanks for your work! I'll come back to review this. |
tACK 7fb7b7d Thanks @GideonBature! This PR was tested and reviewed by checking out main at commit (870efdf), then applying the net diff from all four commits in this PR as a single patch. corepc/contrib/run-bitcoind.patch Reproduction process (macOS, bitcoind built from source):# 1) Clone the repo and switch to main/master
git clone https://github.com/rust-bitcoin/corepc.git
cd corepc
git checkout main #or master
# 2) Add a config for the local bitcoind build
cat <<EOF > contrib/bitcoind_versions.conf
v28 28.99.0 289 /path/to/your/bitcoind
EOF
# 3) Attempt to run without the patch
cd contrib
./run-bitcoind.sh start v28 Pre-patch output:./run-bitcoind.sh: line 168: /opt/bitcoin-28.0/bin/bitcoind: No such file or directory
Wrong bitcoind version, expected 28.0
./run-bitcoind.sh: line 172: /opt/bitcoin-28.0/bin/bitcoind: No such file or directory # 4) Apply the patch and try again
git apply run-bitcoind.patch
./run-bitcoind.sh start v28 Post-patch output:Starting bitcoind v28.99.0 (alias: v28)...
Bitcoin Core 28.99.0 nodes running (RPC port: 28949) Suggest squashing commits for a cleaner history. Happy to provide the patch in other formats if that would be useful. |
This is awesome. Thank you! Will squash the commits. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking good, two change requests please.
a3c2301
to
bcb840e
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for sticking with this. Still a few things to, bash is hard to get right.
You mentioned throwing an example config file in someplace. I rekon that is a good idea. This is the one I've been using to test thing # run-bitcoind configuration
#
# This file configures the `run-bitcoind.sh` script found in the `corepc` repository.
v17 0.17.2 172 /opt/bitcoin-0.17.2/bin/bitcoind
v18 0.18.1 181 /opt/bitcoin-0.18.1/bin/bitcoind
v19 0.19.1 191 /opt/bitcoin-0.19.1/bin/bitcoind
v20 0.20.2 202 /opt/bitcoin-0.20.2/bin/bitcoind
v21 0.21.2 212 /opt/bitcoin-0.21.2/bin/bitcoind
v22 22.1 221 /opt/bitcoin-22.1/bin/bitcoind
v23 23.2 232 /opt/bitcoin-23.2/bin/bitcoind
v24 24.2 242 /opt/bitcoin-24.2/bin/bitcoind
v25 25.2 252 /opt/bitcoin-25.2/bin/bitcoind
v26 26.2 262 /opt/bitcoin-26.2/bin/bitcoind
v27 27.1 271 /opt/bitcoin-27.1/bin/bitcoind
v28 28.1 281 /opt/bitcoin-28.0/bin/bitcoind |
:) Thank you! I have implemented the changes... Thank you so much for the reviews. |
bcb840e
to
852b444
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Almost there! Thanks for sticking with this.
|
||
- Examples | ||
|
||
v28 28.1 280 /opt/bitcoin-28.0/bin/bitcoind |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Woops I think this mistake was mine last review, should be 28.0
|
||
v28 28.1 280 /opt/bitcoin-28.0/bin/bitcoind | ||
v24 24.2 242 /opt/bitcoin-24.2/bin/bitcoind | ||
v21 0.21.2 212 /opt/bitcoin-0.21.2/bin/bitcoind | ||
EOF |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since we have another iteration anyways, perhaps a new line before the EOF, makes the output slightly better when an incorrect command is given. Not really important though.
|
||
echo "Two connected bitcoind v${version_number} instances running, one node has JSON-RPC listening on port ${rpc_port}" | ||
sleep 1 # Let nodes connect | ||
echo "Two connected bitcoind v${version_number} instances running, one node has JSON-RPC listening on port ${rpc_port})" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
echo "Two connected bitcoind v${version_number} instances running, one node has JSON-RPC listening on port ${rpc_port})" | |
echo "Two connected bitcoind v${version_number} instances running, one node has JSON-RPC listening on port ${rpc_port}" |
Problem:
The script previously hardcoded version numbers and assumed specific directory structures in
/opt/
, making updates difficult and breaking user environments when new versions were introduced. Developers had to modify the script manually whenever a new version was released or whenbitcoind
was installed in a different location.Solution:
This PR removes the hardcoded version numbers and introduces a configuration-based approach. The script now loads version numbers and
bitcoind
paths from either:BITCOIND_VERSIONS_CONFIG
), allowing users to specify their own config file location.bitcoind_versions.conf
), which developers can set up based on their local environment.If no custom environment variable is provided (BITCOIND_VERSIONS_CONFIG), the script falls back to a default config file in the home directory (
~/.bitcoind_versions.conf
) or the script directory (./bitcoind_versions.conf
).Closes #28