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

Expose remaining v17 blockchain APIs for v19+ #79

Merged
merged 10 commits into from
Mar 8, 2025

Conversation

tnull
Copy link
Contributor

@tnull tnull commented Mar 6, 2025

While these API methods were previously exposed for a v17 client, they were not for v19+.

Here, we add the blockchain APIs present in v17 for v19+.

@tnull tnull force-pushed the 2025-03-expose-get-block-count branch from 495d61c to 49c2f5b Compare March 6, 2025 09:42
@tnull tnull changed the title Expose v17 blockchain APIs for v19+ Expose some v17 blockchain APIs for v19+ Mar 6, 2025
@tnull tnull force-pushed the 2025-03-expose-get-block-count branch 8 times, most recently from 3e7146e to cda323a Compare March 6, 2025 12:15
@tnull tnull changed the title Expose some v17 blockchain APIs for v19+ Expose all v17 blockchain APIs for v19+ Mar 6, 2025
@tnull tnull changed the title Expose all v17 blockchain APIs for v19+ Expose remaining v17 blockchain APIs for v19+ Mar 6, 2025
@tnull tnull force-pushed the 2025-03-expose-get-block-count branch 2 times, most recently from 2b11188 to d8c03c1 Compare March 6, 2025 12:23
@tcharding
Copy link
Member

tcharding commented Mar 6, 2025

Bro this is sick!!! Thanks a million for the PR man, super cool. To review it I squashed the whole thing down and then rebase #49 on top of it - and it has green CI. Epic. Let me know how you want to proceed.

A few comments.

  1. The first patch doesn't test because get_tx_out needs feature gating (but if we squash its doesnt' matter)
  2. I realized that I made a vXY feature in integration_test so that feature gating was easier but then I didn't use it.

@tnull
Copy link
Contributor Author

tnull commented Mar 7, 2025

The first patch doesn't test because get_tx_out needs feature gating (but if we squash its doesnt' matter)

Ah, true, although somewhat preexisting as gettxout was exposed but broken for v22+. Now switched the commit order to allow squashing the gettxout fix into the first commit before merging.

I realized that I made a vXY feature in integration_test so that feature gating was easier but then I didn't use it.

Good to know, now added a fixup to switch to that.

> git diff-tree -U2 d8c03c1 54c2ddd
diff --git a/integration_test/tests/blockchain.rs b/integration_test/tests/blockchain.rs
index 4f05c34..1666f06 100644
--- a/integration_test/tests/blockchain.rs
+++ b/integration_test/tests/blockchain.rs
@@ -71,5 +71,5 @@ fn get_block_header_verbose() { // verbose = true
 }

-#[cfg(all(not(feature = "0_18_1"), not(feature = "0_19_1"), not(feature = "0_19_1"), not(feature = "0_20_2"), not(feature = "0_21_2"), not(feature = "22_1"), not(feature = "23_2"), not(feature = "24_2")))]
+#[cfg(not(any(feature = "v18", feature = "v19", feature = "v20", feature = "v21", feature = "v22", feature = "v23", feature = "v24")))]
 // `getblockstats` used to not work on the genesis block as it doesn't have undo data saved to disk
 // (see https://github.com/bitcoin/bitcoin/pull/19888). We therefore only run tests for versions
@@ -81,5 +81,5 @@ fn get_block_stats() {
 }

-#[cfg(all(not(feature = "0_18_1"), not(feature = "0_19_1"), not(feature = "0_19_1"), not(feature = "0_20_2"), not(feature = "0_21_2"), not(feature = "22_1"), not(feature = "23_2"), not(feature = "24_2")))]
+#[cfg(not(any(feature = "v18", feature = "v19", feature = "v20", feature = "v21", feature = "v22", feature = "v23", feature = "v24")))]
 // `getblockstats` used to not work on the genesis block as it doesn't have undo data saved to disk
 // (see https://github.com/bitcoin/bitcoin/pull/19888). We therefore only run tests for versions
@@ -91,5 +91,5 @@ fn get_block_stats_by_height() {
 }

-#[cfg(all(not(feature = "0_18_1"), not(feature = "0_19_1"), not(feature = "0_19_1"), not(feature = "0_20_2"), not(feature = "0_21_2"), not(feature = "22_1"), not(feature = "23_2"), not(feature = "24_2")))]
+#[cfg(not(any(feature = "v18", feature = "v19", feature = "v20", feature = "v21", feature = "v22", feature = "v23", feature = "v24")))]
 // `getblockstats` used to not work on the genesis block as it doesn't have undo data saved to disk
 // (see https://github.com/bitcoin/bitcoin/pull/19888). We therefore only run tests for versions
@@ -102,5 +102,5 @@ fn get_block_stats_by_hash() { // verbose = true
 }

-#[cfg(all(not(feature = "0_18_1"), not(feature = "0_19_1"), not(feature = "0_19_1"), not(feature = "0_20_2"), not(feature = "0_21_2"), not(feature = "22_1"), not(feature = "23_2"), not(feature = "24_2")))]
+#[cfg(not(any(feature = "v18", feature = "v19", feature = "v20", feature = "v21", feature = "v22", feature = "v23", feature = "v24")))]
 // `getblockstats` used to not work on the genesis block as it doesn't have undo data saved to disk
 // (see https://github.com/bitcoin/bitcoin/pull/19888). We therefore only run tests for versions
@@ -113,5 +113,5 @@ fn get_block_stats_by_height_txindex() {
 }

-#[cfg(all(not(feature = "0_18_1"), not(feature = "0_19_1"), not(feature = "0_19_1"), not(feature = "0_20_2"), not(feature = "0_21_2"), not(feature = "22_1"), not(feature = "23_2"), not(feature = "24_2")))]
+#[cfg(not(any(feature = "v18", feature = "v19", feature = "v20", feature = "v21", feature = "v22", feature = "v23", feature = "v24")))]
 // `getblockstats` used to not work on the genesis block as it doesn't have undo data saved to disk
 // (see https://github.com/bitcoin/bitcoin/pull/19888). We therefore only run tests for versions
diff --git a/types/src/v19/blockchain.rs b/types/src/v19/blockchain.rs
index d956ded..fe6f961 100644
--- a/types/src/v19/blockchain.rs
+++ b/types/src/v19/blockchain.rs
@@ -345,5 +345,5 @@ pub struct MempoolEntry {
     /// Hash of serialized transaction, including witness data.
     pub wtxid: String,
-    /// (No docs in Core v17.)
+    /// (No docs in Core v19.)
     pub fees: MempoolEntryFees,
     /// Unconfirmed transactions used as inputs for this transaction (parent transaction id).
@@ -399,5 +399,5 @@ impl MempoolEntry {
 }

-/// (No docs in Core v17.)
+/// (No docs in Core v19.)
 #[derive(Clone, Debug, PartialEq, Deserialize, Serialize)]
 pub struct MempoolEntryFees {

@tnull tnull force-pushed the 2025-03-expose-get-block-count branch from d8c03c1 to 54c2ddd Compare March 7, 2025 08:22
@tnull
Copy link
Contributor Author

tnull commented Mar 7, 2025

Failing nightly formatting CI job seems unrelated as I'm not touching the parts it's failing on in this PR.

@tnull tnull force-pushed the 2025-03-expose-get-block-count branch from 54c2ddd to 394d2e5 Compare March 7, 2025 08:40
@tnull
Copy link
Contributor Author

tnull commented Mar 7, 2025

Pushed another fixup allowing to test the txindex variants of get_block_stats for v18:

> git diff-tree -U2 54c2ddd 394d2e5
diff --git a/integration_test/tests/blockchain.rs b/integration_test/tests/blockchain.rs
index 1666f06..87ce52d 100644
--- a/integration_test/tests/blockchain.rs
+++ b/integration_test/tests/blockchain.rs
@@ -102,5 +102,5 @@ fn get_block_stats_by_hash() { // verbose = true
 }

-#[cfg(not(any(feature = "v18", feature = "v19", feature = "v20", feature = "v21", feature = "v22", feature = "v23", feature = "v24")))]
+#[cfg(not(any(feature = "v19", feature = "v20", feature = "v21", feature = "v22", feature = "v23", feature = "v24")))]
 // `getblockstats` used to not work on the genesis block as it doesn't have undo data saved to disk
 // (see https://github.com/bitcoin/bitcoin/pull/19888). We therefore only run tests for versions
@@ -113,5 +113,5 @@ fn get_block_stats_by_height_txindex() {
 }

-#[cfg(not(any(feature = "v18", feature = "v19", feature = "v20", feature = "v21", feature = "v22", feature = "v23", feature = "v24")))]
+#[cfg(not(any(feature = "v19", feature = "v20", feature = "v21", feature = "v22", feature = "v23", feature = "v24")))]
 // `getblockstats` used to not work on the genesis block as it doesn't have undo data saved to disk
 // (see https://github.com/bitcoin/bitcoin/pull/19888). We therefore only run tests for versions

@tnull
Copy link
Contributor Author

tnull commented Mar 7, 2025

Let me know if I can squash the fixups!

Copy link
Member

@tcharding tcharding left a comment

Choose a reason for hiding this comment

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

ACK 394d2e5

@tcharding
Copy link
Member

All looks good, squash away!

@tcharding
Copy link
Member

tcharding commented Mar 7, 2025

I"ll merge #81 so you can rebase on top and get past the formatting job in CI.

@tnull tnull force-pushed the 2025-03-expose-get-block-count branch from 394d2e5 to f001c7a Compare March 7, 2025 21:51
tnull added 2 commits March 7, 2025 22:52
.. and feature gate the individual test cases, allowing more
fine-grained control going forward.
.. as it was previously only available in `v17` and `v18`.
tnull added 8 commits March 7, 2025 22:52
.. as it was previously only available in `v17` and `v18`.
.. as it was previously only available in `v17` and `v18`.
.. as it was previously only available in `v17` and `v18`.
.. as it was previously only available in `v17` and `v18`.
.. as it was previously only available in `v17` and `v18`.
.. as it was previously only available in `v17` and `v18`.
.. as it was previously only available in `v17` and `v18`.
.. as it was previously only available in `v17` and `v18`.
@tnull tnull force-pushed the 2025-03-expose-get-block-count branch from f001c7a to 2efcb9e Compare March 7, 2025 21:53
@tnull
Copy link
Contributor Author

tnull commented Mar 7, 2025

Rebased on master after #81 landed.

Copy link
Member

@tcharding tcharding left a comment

Choose a reason for hiding this comment

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

ACK 2efcb9e

@tcharding
Copy link
Member

tcharding commented Mar 7, 2025

v18 is excluded from the getblockstats test again but no sweat we can come back. This is a good step forward, thanks man!

@tnull
Copy link
Contributor Author

tnull commented Mar 7, 2025

v18 is excluded from the getblockstats test again but no sweat we can come back. This is a good step forward, thanks man!

Well, yes, it's excluded for the non-txindex variants as those fail complaining that txindex needs to be enabled.

@tcharding
Copy link
Member

tcharding commented Mar 8, 2025

Oh no worries. I had it in mind that we would enable -txindex for all of the getblockstats tests. Its good as is, thanks man. (There is a node constructor that enables it.)

@tcharding tcharding merged commit 9e82412 into rust-bitcoin:master Mar 8, 2025
27 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants