-
Notifications
You must be signed in to change notification settings - Fork 698
refactor: bitcoin rpc porting #6329
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
base: develop
Are you sure you want to change the base?
Conversation
…to refactor/bitcoin-rpc
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.
This looks great! I just had a few minor comments.
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.
LGTM!
PR updated with the merge of #6366 (related to BitcoinAddress regtest HRP management). |
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.
LGTM
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.
LGTM!
Description
This PR is the first step in refactoring the
BitcoinRegtestController
to enhance logic correctness, reduce code duplication, increase test coverage. and improve documentation.It primarily introduces a port of the
BitcoinRPCRequest
implementation, with the following key changes:RpcTransport
layer using the reqwest crate (as used inStacksClient
from thestacks-signer
package).BitcoinRpcClient
layer that exposes the relevant RPC APIs.reqwest
version used acrossstacks-node
andstacks-signer
with the version already resolved inCargo.lock
BitcoinCoreController
to make it suitable for the new tests added in this PR.To simplify review, the code introduced here is not yet integrated with the rest of the codebase. Follow-up PRs will handle that integration:
BitcoinRPCRequest
with the newBitcoinRpcClient
inBitcoinRegtestController
.Applicable issues
Additional info (benefits, drawbacks, caveats)
A few design decisions were made with the goal of preserving the current usage of the Bitcoin RPC API. Feedback on the following points would be appreciated:
Limited Rpc API Scope
: This implementation includes only the subset of the Bitcoin RPC API currently used in the codebase, both in terms of available methods and supported input/output parameters. The idea is to keep the implementation minimal for now, with the flexibility to expand it as needed in the future.Nonce Handling in RpcTransport
: The originalBitcoinRegtestController
code uses a fixed nonce value ("stacks") as theid
parameter in RPC requests (see code example below). To stay consistent, this PR allows customizable nonces inRpcTransport
. However, if this behavior is not strictly required, we could simplify the implementation by generating nonces automatically and internally, avoiding the need to expose this as a configurable option. Would removing nonce configurability be acceptable, or is there a use case for keeping it?stacks-core/testnet/stacks-node/src/burnchains/bitcoin_regtest_controller.rs
Lines 2512 to 2519 in a5587d1
Checklist
docs/rpc/openapi.yaml
andrpc-endpoints.md
for v2 endpoints,event-dispatcher.md
for new events)clarity-benchmarking
repobitcoin-tests.yml