From 8e0791966b74b0fbfcc06840e09375a3d8ff65ae Mon Sep 17 00:00:00 2001 From: Jose Storopoli Date: Fri, 11 Oct 2024 15:47:01 -0300 Subject: [PATCH 1/2] ci: update to bitcoin 28.0 --- .github/workflows/functional.yml | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/.github/workflows/functional.yml b/.github/workflows/functional.yml index c6d9eb6a6..ff868a8d6 100644 --- a/.github/workflows/functional.yml +++ b/.github/workflows/functional.yml @@ -8,7 +8,6 @@ on: env: CARGO_TERM_COLOR: always - jobs: lint: name: Lint test files @@ -55,11 +54,11 @@ jobs: - name: Install bitcoind env: - BITCOIND_VERSION: "27.0" + BITCOIND_VERSION: "28.0" BITCOIND_ARCH: "x86_64-linux-gnu" - SHASUM: "2a6974c5486f528793c79d42694b5987401e4a43c97f62b1383abf35bcee44a8" + SHASUM: "7fe294b02b25b51acb8e8e0a0eb5af6bbafa7cd0c5b0e5fcbb61263104a82fbc" run: | - wget -q "https://bitcoin.org/bin/bitcoin-core-${{ env.BITCOIND_VERSION }}/bitcoin-${{ env.BITCOIND_VERSION }}-${{ env.BITCOIND_ARCH }}.tar.gz" + curl -fsSLO --proto "=https" --tlsv1.2 "https://bitcoincore.org/bin/bitcoin-core-${{ env.BITCOIND_VERSION }}/bitcoin-${{ env.BITCOIND_VERSION }}-${{ env.BITCOIND_ARCH }}.tar.gz" sha256sum -c <<< "$SHASUM bitcoin-${{ env.BITCOIND_VERSION }}-${{ env.BITCOIND_ARCH }}.tar.gz" tar xzf "bitcoin-${{ env.BITCOIND_VERSION }}-${{ env.BITCOIND_ARCH }}.tar.gz" sudo install -m 0755 -t /usr/local/bin bitcoin-${{ env.BITCOIND_VERSION }}/bin/* From d89c9e611822f72feeda923f8e129fb34fb3af18 Mon Sep 17 00:00:00 2001 From: Jose Storopoli Date: Wed, 16 Oct 2024 16:44:12 -0300 Subject: [PATCH 2/2] fix(btcio): non-breaking changes in GetBlockChainInfo Shouldn't be a breaking change for us, since we are not using any of the changed stuff. See: https://github.com/bitcoin/bitcoin/blob/master/doc/release-notes/release-notes-28.0.md#updated-rpcs --- crates/btcio/src/rpc/client.rs | 6 ++--- crates/btcio/src/rpc/traits.rs | 5 ++-- crates/btcio/src/rpc/types.rs | 43 ++++++++++++++++++++++++++++++++++ crates/btcio/src/test_utils.rs | 9 ++----- 4 files changed, 50 insertions(+), 13 deletions(-) diff --git a/crates/btcio/src/rpc/client.rs b/crates/btcio/src/rpc/client.rs index a271747d4..6f8f7ff55 100644 --- a/crates/btcio/src/rpc/client.rs +++ b/crates/btcio/src/rpc/client.rs @@ -11,7 +11,7 @@ use bitcoin::{ bip32::Xpriv, consensus::encode::serialize_hex, Address, Block, BlockHash, Network, Transaction, Txid, }; -use bitcoind_json_rpc_types::v26::{GetBlockVerbosityZero, GetBlockchainInfo, GetNewAddress}; +use bitcoind_json_rpc_types::v26::{GetBlockVerbosityZero, GetNewAddress}; use reqwest::{ header::{HeaderMap, AUTHORIZATION, CONTENT_TYPE}, Client, @@ -28,8 +28,8 @@ use crate::rpc::{ error::{BitcoinRpcError, ClientError}, traits::{Broadcaster, Reader, Signer, Wallet}, types::{ - CreateWallet, GetTransaction, ImportDescriptor, ImportDescriptorResult, ListDescriptors, - ListTransactions, ListUnspent, SignRawTransactionWithWallet, + CreateWallet, GetBlockchainInfo, GetTransaction, ImportDescriptor, ImportDescriptorResult, + ListDescriptors, ListTransactions, ListUnspent, SignRawTransactionWithWallet, }, }; diff --git a/crates/btcio/src/rpc/traits.rs b/crates/btcio/src/rpc/traits.rs index 4468e0f9c..5a05222a9 100644 --- a/crates/btcio/src/rpc/traits.rs +++ b/crates/btcio/src/rpc/traits.rs @@ -1,12 +1,11 @@ use async_trait::async_trait; use bitcoin::{bip32::Xpriv, Address, Block, BlockHash, Network, Transaction, Txid}; -use bitcoind_json_rpc_types::v26::GetBlockchainInfo; use crate::rpc::{ client::ClientResult, types::{ - GetTransaction, ImportDescriptor, ImportDescriptorResult, ListTransactions, ListUnspent, - SignRawTransactionWithWallet, + GetBlockchainInfo, GetTransaction, ImportDescriptor, ImportDescriptorResult, + ListTransactions, ListUnspent, SignRawTransactionWithWallet, }, }; diff --git a/crates/btcio/src/rpc/types.rs b/crates/btcio/src/rpc/types.rs index 317e99cdf..59d4e8692 100644 --- a/crates/btcio/src/rpc/types.rs +++ b/crates/btcio/src/rpc/types.rs @@ -35,6 +35,49 @@ pub enum TransactionCategory { Orphan, } +/// Result of JSON-RPC method `getblockchaininfo`. +/// +/// Method call: `getblockchaininfo` +/// +/// > Returns an object containing various state info regarding blockchain processing. +#[derive(Clone, Debug, PartialEq, Deserialize, Serialize)] +pub struct GetBlockchainInfo { + /// Current network name as defined in BIP70 (main, test, signet, regtest). + pub chain: String, + /// The current number of blocks processed in the server. + pub blocks: u64, + /// The current number of headers we have validated. + pub headers: u64, + /// The hash of the currently best block. + #[serde(rename = "bestblockhash")] + pub best_block_hash: String, + /// The current difficulty. + pub difficulty: f64, + /// Median time for the current best block. + #[serde(rename = "mediantime")] + pub median_time: u64, + /// Estimate of verification progress (between 0 and 1). + #[serde(rename = "verificationprogress")] + pub verification_progress: f64, + /// Estimate of whether this node is in Initial Block Download (IBD) mode. + #[serde(rename = "initialblockdownload")] + pub initial_block_download: bool, + /// Total amount of work in active chain, in hexadecimal. + #[serde(rename = "chainwork")] + pub chain_work: String, + /// The estimated size of the block and undo files on disk. + pub size_on_disk: u64, + /// If the blocks are subject to pruning. + pub pruned: bool, + /// Lowest-height complete block stored (only present if pruning is enabled). + #[serde(rename = "pruneheight")] + pub prune_height: Option, + /// Whether automatic pruning is enabled (only present if pruning is enabled). + pub automatic_pruning: Option, + /// The target size used by pruning (only present if automatic pruning is enabled). + pub prune_target_size: Option, +} + /// Models the result of JSON-RPC method `listunspent`. /// /// # Note diff --git a/crates/btcio/src/test_utils.rs b/crates/btcio/src/test_utils.rs index e157f51a3..4b091b7a1 100644 --- a/crates/btcio/src/test_utils.rs +++ b/crates/btcio/src/test_utils.rs @@ -1,5 +1,3 @@ -use std::collections::BTreeMap; - use async_trait::async_trait; use bitcoin::{ bip32::Xpriv, @@ -8,15 +6,14 @@ use bitcoin::{ taproot::ControlBlock, Address, Amount, Block, BlockHash, Network, ScriptBuf, SignedAmount, Transaction, Txid, Work, }; -use bitcoind_json_rpc_types::v26::GetBlockchainInfo; use strata_state::tx::InscriptionData; use crate::{ rpc::{ traits::{Broadcaster, Reader, Signer, Wallet}, types::{ - GetTransaction, ImportDescriptor, ImportDescriptorResult, ListTransactions, - ListUnspent, SignRawTransactionWithWallet, + GetBlockchainInfo, GetTransaction, ImportDescriptor, ImportDescriptorResult, + ListTransactions, ListUnspent, SignRawTransactionWithWallet, }, ClientResult, }, @@ -94,8 +91,6 @@ impl Reader for TestBitcoinClient { prune_height: None, automatic_pruning: None, prune_target_size: None, - softforks: BTreeMap::new(), - warnings: "".to_string(), }) }