Skip to content

Add support for Bitcoin Core 31.0#586

Open
xyzconstant wants to merge 5 commits into
rust-bitcoin:masterfrom
xyzconstant:add-support-for-core-31.0
Open

Add support for Bitcoin Core 31.0#586
xyzconstant wants to merge 5 commits into
rust-bitcoin:masterfrom
xyzconstant:add-support-for-core-31.0

Conversation

@xyzconstant
Copy link
Copy Markdown

@xyzconstant xyzconstant commented May 7, 2026

This PR adds support for downloading Bitcoin Core 31 and creates modules for v31 client types (mostly re-exports).

Changes from v30:

  • Drops settxfee types
  • Acknowledge new RPC commands: getmempoolcluster, getmempoolfeeratediagram, abortprivatebroadcast and getprivatebroadcastinfo in docs and verify.

NOTE: Updated and New RPCs in the release can be supported in further work, thus v31 client remains untested until then.

@tcharding
Copy link
Copy Markdown
Member

tcharding commented May 7, 2026

Thanks for the contribution! Can you please explain how you went about this? Specifically exactly which parts did you use an LLM for? And if I do a review are you going to just feed the comments into an LLM or do the suggestions yourself?

Thanks

@xyzconstant
Copy link
Copy Markdown
Author

re: #586 (comment)

I used it for copying the modules from v30 (commit 2 was done mostly by the LLM with some tweaks from my side) and gather historical context about how major releases from Core are supported, #387 was my reference.

And if I do a review are you going to just feed the comments into an LLM or do the suggestions yourself?

Definitely myself :)

@xyzconstant xyzconstant force-pushed the add-support-for-core-31.0 branch from 6db6237 to 6022508 Compare May 7, 2026 14:18
Comment thread bitcoind/src/versions.rs Outdated
Comment on lines +91 to +92
not(feature = "31_0"),
not(feature = "30_2"),
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change confused me. Can you put a patch at the front of this PR that changes this to:

// This makes the build error more succinct if someone tries to build with --no-default-features.
#[cfg(not(feature = "0_17_2"))]
pub const VERSION: &str = "never-used";

And the reason this works is that later version features enable previous ones.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just pushed e6bcc02 to address this

@tcharding
Copy link
Copy Markdown
Member

There is a slight problem here. In types a struct should only appear in the types/src/vX module if it is different from the type already defined. I.e. this PR adds v31::GetMempoolInfo but the v30::GetMempoolInfo is exactly the same.

Said another way, its unusual that there are no re-exports in v31/mod.rs from the v30 module.

Does that make sense? The types crate (and this whole repository) is slightly unusual. All re-exports and definitions are done in very particular places using very particular coding patterns. Holla if there is something you don't understand.

Thanks for the work!

@xyzconstant xyzconstant force-pushed the add-support-for-core-31.0 branch from 6022508 to 882b4e0 Compare May 9, 2026 05:25
@xyzconstant
Copy link
Copy Markdown
Author

re: #586 (comment)

Thanks for the review!

I've moved away from the copying approach and shifted to re-exporting from v30 as per your suggestion. Additionally, I've created f483441 to relax a check in verify that rejected re-exports-only versions.

@xyzconstant xyzconstant force-pushed the add-support-for-core-31.0 branch from 882b4e0 to bdfa22f Compare May 9, 2026 17:09
Copy link
Copy Markdown
Collaborator

@jamillambert jamillambert left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've had a look over and it looks good so far. I'll finish the check tomorrow.

How did you determine which RPCs needed updating and had to be marked as TODO in v31?

@xyzconstant
Copy link
Copy Markdown
Author

re: #586 (review)

Hi, thanks for reviewing the code!

How did you determine which RPCs needed updating and had to be marked as TODO in v31?

Actually there are more RPCs to be updated besides those I originally listed in the description (which I'll update). Initially I just read the release notes looking for removed/new RPCs and noticed a few with changes in the schema, then more surfaced while running integration tests.

@jamillambert
Copy link
Copy Markdown
Collaborator

jamillambert commented May 12, 2026

Actually there are more RPCs to be updated besides those I originally listed in the description ...

Can we then err on the side of caution and mark everything TODO unless the RPC has been checked and confirmed to be the same as in the version that v31 is reexporting.

For this PR it is fine to have a lot of TODOs and then in follow ups address them or remove them.

@xyzconstant
Copy link
Copy Markdown
Author

xyzconstant commented May 13, 2026

re: #586 (comment)

unless the RPC has been checked and confirmed to be the same as in the version that v31 is reexporting.

Hi, sorry, I don't get this at all. I thought integration tests already confirmed the re-exported RPCs are correct.

@jamillambert
Copy link
Copy Markdown
Collaborator

re: #586 (comment)

unless the RPC has been checked and confirmed to be the same as in the version that v31 is reexporting.

Hi, sorry, I don't get this at all. I thought integration tests already confirmed the re-exported RPCs are correct.

No they don't unfortunately. #58 explains it a bit further and what is being done to get closer to testing everything.

They catch a lot of cases with changes in the return shape of an RPC. But if there are new optional fields that are not returned it will not catch it. The docs of the more recent Core versions are fairly reliable and can be cross checked between versions to see if there are any changes.

@tcharding
Copy link
Copy Markdown
Member

tcharding commented May 14, 2026

Please be warned @xyzconstant this is not a great repo for newer devs, I'm not saying you are one, just giving you a heads up. Also, unless you have some reason to want to continue contributing to this repo I would not think its worth your time to work out all the strangeness of the repo. But by all means don't let me stop you. Also please allow me to re-iterate I am extremely allergic to reviewing LLM code. Please make sure you understand the reason for every single line of code you push.

@xyzconstant xyzconstant force-pushed the add-support-for-core-31.0 branch from bdfa22f to 3fb287f Compare May 14, 2026 16:32
@xyzconstant
Copy link
Copy Markdown
Author

re: #586 (comment)

Thanks for this context, I wasn't aware of it. I followed your advice and marked everything as TODOs in the docs table, also reduced change surface by removing integration tests.

re: #586 (comment)

Also, unless you have some reason to want to continue contributing to this repo I would not think its worth your time to work out all the strangeness of the repo.

I have some downstream work that tests v31, that's why I'm pushing this effort. Initially I was just going to add support for downloading the binaries but noticed the client was needed too and expanded the scope more than needed.

Regarding the LLM-generated code: I share your concerns on that and understand reading AI slop can be frustrating. I let the LLM do the work I felt was mechanical and indeed carefully reviewed every single line before pushing since it's never my intention to waste anyone's time.

Just reduced the scope:

bdfa22f -> 3fb287f (compare)

Also, I updated the PR's description to reflect this.

Copy link
Copy Markdown
Collaborator

@jamillambert jamillambert left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ACK 3fb287f

@jamillambert
Copy link
Copy Markdown
Collaborator

Looks good. Let me know if you want to work on implementing the v31 RPC changes. If not I can when I have time, which won't be until the week after next.

Thanks.

@xyzconstant
Copy link
Copy Markdown
Author

Thanks for the review @jamillambert!

Honestly, I don't think I can commit to a follow up

@jamillambert
Copy link
Copy Markdown
Collaborator

Thanks for the review @jamillambert!

Honestly, I don't think I can commit to a follow up

No worries, I just wanted to know so we didn't both work on the same thing at the same time.

Thanks for the contribution.

Copy link
Copy Markdown
Contributor

@satsfy satsfy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the PR! v31 should have come sooner.

Seems like the last 2 commits should be squashed for bisectability, because one introduces the wrong state and the other fixes it.

Off-topic but @jamillambert will you be working on all the follow-ups or just some portion?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All sums verified.

Comment thread bitcoind/src/client_versions.rs Outdated
/// This is meaningless but we need it otherwise we can't get far enough into
/// the build process to trigger the `compile_error!` in `./versions.rs`.
#[cfg(all(
not(feature = "31_0"),
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Below, you introduced a simplification for this case in bitcoind/src/versions.rs, which I think could also be applied here because it is the same pattern.

Comment thread bitcoind/src/versions.rs
not(feature = "0_18_1"),
not(feature = "0_17_2")
))]
// This makes the build error more succinct if someone tries to build with --no-default-features.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here is the simplification I referred to.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

While this simplification is correct its not obvious from the diff why it is correct.

If you were to put a 'why' section in the commit log it would make review easier. It also helps reviewers be sure you understand what is going on because this repo is so odd. I personally always loose context when I haven't touched this repo for a while so it helps freshen reviewers context also. Thanks

@jamillambert
Copy link
Copy Markdown
Collaborator

Off-topic but @jamillambert will you be working on all the follow-ups or just some portion?

If you're asking because you want to work on it, go for it.

@xyzconstant
Copy link
Copy Markdown
Author

re: #586 (review)

Seems like the last 2 commits should be squashed for bisectability, because one introduces the wrong state and the other fixes it.

They're separate for visibility, so the last commit shows what are the new and removed RPCs for v31.

xyzconstant added a commit to xyzconstant/peer-observer that referenced this pull request May 19, 2026
nix-shell CI tests will be skipped because of a `bitcoin-node` version mismatch:
v31.0 (resolved in nix-shell) vs v30.2 (latest version in `corepc`).

Once rust-bitcoin/corepc#586 lands the IN_NIX_SHELL guard should be dropped.
Comment thread verify/src/reexports.rs
Comment on lines -46 to +47
let version_defs = match definitions.get(&version_name) {
Some(defs) => defs,
None => {
let msg = format!("no definitions found for version {}", version_name);
return Err(anyhow::anyhow!(msg));
}
};
let empty = BTreeMap::new();
let version_defs = definitions.get(&version_name).unwrap_or(&empty);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you put a bit more context into your commit logs in general please mate.

verify: handle versions with no inline-defined types

I cannot see why we would want to do this? It looks like the change neuters the check. What is the justification please?

If we look at #387 (excluding patch1), I wouldn't expect to see any changes to verify in this PR other than what is done in that one.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not introducing a single new type definition in types/src/v31/mod.rs (it's only re-exports from there). Without this change running cd verify && cargo run all would fail for v31 if it's only re-exporting types from other modules and not defining one in there. I didn't want to add/implement extra types, just drop SetTxFee at most.

I thought my comment here: #586 (comment) provided enough context about the why of the commit. Sorry for the unclear commit description though, just reworded this commit.

@tcharding
Copy link
Copy Markdown
Member

Sorry mate, I'm not all that keen to keep reviewing this. If @jamillambert or @satsfy wants to do it I won't stop them but otherwise I think we can get support for this in quicker if one of the regular devs tackles this. Appreciate your work its just I've way too many patches to review as it is. Hope you understand.

These fallbacks exist only to let the build reach the version check
compile error. Since each version feature enables the previous one,
the long cfg list collapses to a single clause.
In order to gradually add support for new versions, an implementer
might want to start with zero version-specific types and just re-export
types from older versions (in `types/src/vX/mod.rs`). The previous check
in `check_type_reexports` errored in that case.

Fall back to an empty map when no inline definitions exist.
Based on https://bitcoincore.org/en/releases/31.0/ update docs by:
- Removing `settxfee` RPC command
- Add new RPC commands `getmempoolcluster`,
`getmempoolfeeratediagram`, `abortprivatebroadcast`, and `getprivatebroadcastinfo`.

For types only `settxfee` has been dropped, new/updated RPCs can be supported in
further work.
@xyzconstant xyzconstant force-pushed the add-support-for-core-31.0 branch from 3fb287f to 6ba93bf Compare May 20, 2026 03:44
@xyzconstant
Copy link
Copy Markdown
Author

re: #586 (comment)

No worries mate. If anybody else can tackle this and implement it faster than I can then I'm happy to close this PR and let them move forward.

Either way, just pushed changes addressing the commit description issues + @satsfy's suggestion.

xyzconstant added a commit to xyzconstant/peer-observer that referenced this pull request May 20, 2026
nix-shell CI tests will be skipped because of a `bitcoin-node` version mismatch:
v31.0 (resolved in nix-shell) vs v30.2 (latest version in `corepc`).

Once rust-bitcoin/corepc#586 lands the IN_NIX_SHELL guard should be dropped.
0xB10C pushed a commit to peer-observer/peer-observer that referenced this pull request May 20, 2026
nix-shell CI tests will be skipped because of a `bitcoin-node` version mismatch:
v31.0 (resolved in nix-shell) vs v30.2 (latest version in `corepc`).

Once rust-bitcoin/corepc#586 lands the IN_NIX_SHELL guard should be dropped.
@satsfy
Copy link
Copy Markdown
Contributor

satsfy commented May 20, 2026

This is a good starting point for v31. I could agree with merging this as the scaffold for v31. I'm already working on top of these commits for the v31 RPC changes, and will submit them as a follow-up.

Anyways, it looks like #596 addresses the immediate need in peer-observer, so I'd favor merging that for now and following up fast for full v31 support.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants