Finish off support for Bitcoin Core v31.0#615
Conversation
Converted to enum the type of fields "connection_type" and "transport_protocol_type" to match Bitcoin Core docs.
New fields kernel and privatebroadcast.
RPC getwalletinfo no longer returns paytxfee
Add getmempoolcluster and getmempoolfeeratediagram RPCs. Update getmempoolentry, getrawmempool, getmempoolancestors, getmempooldescendants and getmempoolinfo with new field chunk_weight, chunk_fee and cluster_limit fields. Back-fill optional fields as None for earlier versions.
RPC getdeploymentinfo gets script_flags field. This commit adds an Enum with the possible flags.
RPC gettxspendingprevout adds spending_tx and block_hash fields when return_spending_tx is set.
RPC getblock gets new field coinbase_tx. Commit backfills None for earlier versions.
Deny unknown fields. Use i64 for peer timestamps because time can be emmited as a negative.
getblockfrompeer, disconnectnode, getnetworkinfo, getblocktemplate and waitfornewblock each carried a a note that said the fields since v30, but their modelled return types match v30.
Despite getmempoolfeeratediagram being a new RPC, it is hidden. It is not included in the rustdoc method table. Remove SetTxFee import because the RPC has been deleted but the re-export had been kept.
|
Latest force push uses enums for getpeerinfo types, maintaining full v31 docs in corepc (before, it simply discarded relevant messages from Bitcoin Core documentation). EDIT: below i retriggered CI |
Drop the v30_and_below gates from tests covering RPCs unchanged in v31.
| /// Minimum fee rate in BTC/kB for a transaction to be accepted. | ||
| /// Minimum fee rate in BTC/kvB for a transaction to be accepted. |
There was a problem hiding this comment.
This change shouldn't be in here because we should not be mentioning the rate in model because the FeeRate abstracts this. Can you either just remove this change or throw an additional patch at the front that removes these sorts of docs everywhere in model.
Related: #60
| limit_cluster_count: None, | ||
| limit_cluster_size: None, | ||
| optimal: None, |
There was a problem hiding this comment.
While not technically wrong, I'm a bit anal about code cleanlyness. Can these go down in the correct order pls?
There was a problem hiding this comment.
Same for all the places you add foo: None pls.
| match self { | ||
| Self::Base(e) => write!(f, "conversion of the `base` field failed: {}", e), |
There was a problem hiding this comment.
In this (and rust-bitcoin) repos we use the style of matching on *self and then pattern matching on (ref e). The reason is its just a bit more explicit to what the compiler would otherwise do for us. It was a style choice made a long time ago, to favour explicit over implicit.
| Self::Numeric(e) => write!(f, "numeric: {}", e), | ||
| Self::Wtxid(e) => write!(f, "conversion of the `wtxid` field failed: {}", e), | ||
| Self::Fees(e) => write!(f, "conversion of the `fees` field failed: {}", e), | ||
| Self::Depends(e) => write!(f, "conversion of the `depends` field failed: {}", e), | ||
| Self::SpentBy(e) => write!(f, "conversion of the `spentby` field failed: {}", e), |
There was a problem hiding this comment.
These should be using write_err like we do elsewhere.
|
|
||
| /// Error when converting a `MempoolEntry` type into the model type. | ||
| #[derive(Debug)] | ||
| pub enum MempoolEntryError { |
There was a problem hiding this comment.
All these error types go in a separate file called error.rs.
| /// Transactions in this chunk in mining order (txids). | ||
| /// Transactions in this chunk in mining order. |
There was a problem hiding this comment.
In Bitcoin Core, it looks like this
RPCResult{RPCResult::Type::ARR, "txs", "transactions in this chunk in mining order",
{RPCResult{RPCResult::Type::STR_HEX, "txid", "transaction And in the docs
"txs" : [ (json array) transactions in this chunk in mining order
"hex", (string) transaction id
...
]
There is no (txids). Whenever this kind of conflict happens (knowing that our existing docs have errors sometimes) I took no chances and copied exactly what core said to prevent drift. I thought this would be the way to go because we will have codegen types which effortlessly copy precisely the same docs as core.
|
Looks pretty good man. To create all the new types you just copied the one from the latest version and added the fields, right? I.e for |
|
Reviewed: 1d584d8 |
Yes. Everything that didn't need to change hasn't changed. Diffs only in new/modified fields or the corresponding docs. All "institutional memory" is kept. |
Closes #599
Completes v31 support across the client, types, and integration tests. Makes v31 the default version.
Fixed:
inv_to_sendandlast_inv_sequence, and madestartingheightoptional now that it is only returned under-deprecatedrpc=startingheight.kernelandprivatebroadcastcategories.paytxfee.script_flagsfield.spendingtxandblockhashfields, plus added support for the newmempool_onlyandreturn_spending_txarguments.coinbase_txobject returned at verbosity 1, 2 and 3.Added:
getmempoolclusterandgetmempoolfeeratediagramRPCs, thechunk_weightandchunk_feefields ongetmempoolentry,getrawmempool,getmempoolancestorsandgetmempooldescendants, and thecluster_limitandoptimalfields ongetmempoolinfo.getprivatebroadcastinfoandabortprivatebroadcastRPCs.LLM usage: Claude helped on generating tests for new RPCs, verifying things over and over again, attempting to call every RPC, spotting additional unfixed things, and reviewing every change the PR.
When appropriate, comments have been checked to match v31 documentation exactly.