Skip to content

bug(corepc-types): type of prune_target_size field in model::GetBlockchainInfo should be i64 instead of u32 #544

@RazorBest

Description

@RazorBest

You can configure a bitcoin-core node with prune=5000 or greater (which is in MB). As a consequence, the RPC call getblockchaininfo will return "prune_target_size": 5242880000 , or greater, which is the value in bytes of the prune limit that was set for the node. This value is outside of u32.

Demo:

use std::error::Error;

use corepc_client::client_sync::Auth;
use corepc_client::client_sync::v29::Client;

fn main() -> Result<(), Box<dyn Error>> {
    let rpc_host = "http://127.0.0.1:8332";
    let cookie_path = "/home/btc/.bitcoin/.cookie";
    let auth = Auth::CookieFile(cookie_path.into());
    let client = Client::new_with_auth(rpc_host, auth)?;

    let rpc_result = client.get_blockchain_info()?;
    println!("RPC response: {rpc_result:?}");

    let generic_result = rpc_result.into_model()?;
    println!("Generic response: {generic_result:?}");

    Ok(())
}

Cargo.toml:

[dependencies]
corepc-client = { version = "0.10.0", features = ["client-sync"] }

Configure a node with prune=5000 or higher. Change rpc_host and cookie_path accordingly.

Output:

RPC response: GetBlockchainInfo ...
Error: Numeric(Overflow { field: "prune_target_size", value: 5242880000 })

Expected behaviour: no error.


v17::GetBlockchainInfo and v29::GetBlockchainInfo both define the field prune_target_size as Option<i64>. So, only model::GetBlockchainInfo::prune_target_size seems to be the outlier.

I don't know if it was a deliberate decision to represent all the version non-specific type fields integers as 32-bit ints. But unless proven wrongly, I'll just categorize this as a bug.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions