Upgrade to soon-to-be-released bitcoin#528
Upgrade to soon-to-be-released bitcoin#528tcharding wants to merge 2 commits intorust-bitcoin:masterfrom
bitcoin#528Conversation
bitcoin-0.33.0-beta++ dependency
bitcoin-0.33.0-beta++ dependencybitcoin
jamillambert
left a comment
There was a problem hiding this comment.
I assume the first patch ignoring the .claude folder is for your local dev only and you didn't want to use a global ignore.
I couldn't find the branch on your rust-bitcoin fork that you were using. I used instead the current master with the PRs you listed added. But then I had to change HeaderDecoderError and TransactionDecoderError to be wrapped in DecodeError.
After I did that it builds and the tests all pass. Besides the points below it all looks good.
| pub average_fee: Amount, | ||
| /// Average feerate. | ||
| pub average_fee_rate: Option<FeeRate>, | ||
| pub average_fee_rate: FeeRate, |
There was a problem hiding this comment.
This field and some of the others changed are optional in v25. Why the removal of Option?
Edit: I realised it was removed due to the change in the return type in rust-bitcoin. But it highlights an existing error that it, in fact all fields in the v25 GetBlockStats are optional. Opened #530
| /// Models the result of JSON-RPC method `getblockstats`. | ||
| #[derive(Clone, Debug, PartialEq, Deserialize, Serialize)] | ||
| // #[derive(Clone, Debug, PartialEq, Deserialize, Serialize)] | ||
| // FIMXE: How do we serde a `Vec<FeeRate>`? |
There was a problem hiding this comment.
AI says you can use a helper and gave the below, it is possible to use the existing bitcoin::fee_rate::serde::as_sat_per_vb_floor but still needs a helper for the vec.
mod fee_rate_vec_serde {
use bitcoin::FeeRate;
use serde::{Deserialize, Deserializer, Serialize, Serializer};
pub fn serialize<S>(rates: &Vec<FeeRate>, serializer: S) -> Result<S::Ok, S::Error>
where
S: Serializer,
{
let sats: Vec<u64> = rates.iter().map(|rate| rate.to_sat_per_vb_floor()).collect();
sats.serialize(serializer)
}
pub fn deserialize<'de, D>(deserializer: D) -> Result<Vec<FeeRate>, D::Error>
where
D: Deserializer<'de>,
{
let sats = Vec::<u32>::deserialize(deserializer)?;
Ok(sats.into_iter().map(FeeRate::from_sat_per_vb).collect())
}
}There was a problem hiding this comment.
Oh yes, I didn't know that at the time I wrote the comment. I actually added this sort of thing in rust-bitcoin/rust-bitcoin#5704
I'm not sure if we should push Vec support upstream for all the types that currently have serde support as modules (ie Amount). Or just hack it in here?
There was a problem hiding this comment.
I think it makes more sense to have them upstream, I don't see the downside and it then enables it for everyone.
Opened: rust-bitcoin/rust-bitcoin#5786
| let bytes = bitcoin::hex::decode_to_vec(sig).map_err(E::Hex)?; | ||
| let (sighash_byte, signature) = bytes.split_last().ok_or(E::EmptySignature)?; | ||
| Ok(Signature { | ||
| signature: secp256k1::schnorr::Signature::from_slice(signature) |
There was a problem hiding this comment.
Lint warning:
warning: use of deprecated associated function `bitcoin::secp256k1::schnorr::Signature::from_slice`: Use `from_byte_array` instead
There was a problem hiding this comment.
Yeah this is non-trivial to remove so I just left it in for now.
| let bytes = bitcoin::hex::decode_to_vec(sig).map_err(E::Hex)?; | ||
| let (sighash_byte, signature) = bytes.split_last().ok_or(E::EmptySignature)?; | ||
| Ok(Signature { | ||
| signature: secp256k1::schnorr::Signature::from_slice(signature) |
There was a problem hiding this comment.
Lint warning:
warning: use of deprecated associated function `bitcoin::secp256k1::schnorr::Signature::from_slice`: Use `from_byte_array` instead
| average_fee: Amount::from_sat(self.average_fee), | ||
| average_fee_rate, | ||
| average_fee: Amount::from_sat(self.average_fee).expect("TODO: Handle this error"), | ||
| average_fee_rate: average_fee_rate, |
There was a problem hiding this comment.
| average_fee_rate: average_fee_rate, | |
| average_fee_rate, |
Was this change left over from a previous revision? there is no need for it.
There was a problem hiding this comment.
Not sure, thanks man. I wasn't expecting such a thorough review. Appreciate it!
| @@ -0,0 +1,72 @@ | |||
| // SPDX-License-Identifier: CC0-1.0 | |||
There was a problem hiding this comment.
This file was removed intentionally on master.
Oh that is sloppy of me, will remove.
My bad, I never pushed the branch. I only added the three PRs and didn't have to touch the decoder errors from memory. I"ll investigate. Thanks for going to the trouble of building this, I did not expect that. Pleasant surprise. |
Upgrade to the upcoming bitcoin beta release. This is a local branch with a few PRs merged as described in rust-bitcoin/rust-bitcoin#5742
7b66711 to
89590da
Compare
Upgrade to the upcoming bitcoin beta release (
masterbranch ofbitcoinwith a few PRs merged in: #5704, #5657, and #5710).Expect all red in CI. Locally, with the
bitcoinbranch available, I can run the integration tests (withtest17andtest29).