-
Notifications
You must be signed in to change notification settings - Fork 84
Adjust get_block RPC to match Bitcoin Core output #682
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
Adjust get_block RPC to match Bitcoin Core output #682
Conversation
|
LGTM, I still need to check that everything is correct but overall it looks good. |
|
@Davidson-Souza can you approve CI ? |
bdd3782 to
2b9b250
Compare
|
@moisesPompilio this needs rebase |
2b9b250 to
3070e5a
Compare
4d46fd1 to
bda4e4d
Compare
0799ba5 to
8b03898
Compare
f4c78d3 to
33d0e5c
Compare
|
I've tested this on block Core: 1763994343 |
33d0e5c to
3f0079b
Compare
I adjusted the calculation based on what Bitcoin Core does, and the tests now produce the correct values. |
Davidson-Souza
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've been thinking about how to expose things like MTP and chainwork in a reusable way, since we'll use it in other places. The best way I thought is an extended trait implemented for Block that takes a BlockchainInterface as argument. So we would have something like:
impl BlockExt {
fn mtp(&self, chain: &impl BlockchainInterface);
fn chain_work(&self, chain: &impl BlockchainInterface);
fn alt_tips(&self, chain: &impl BlockchainInterface);
// what else??
}This way we don't pollute BlockchainInterface too much. What do you guys think? (This is not supposed to be implemented here, just thinking out loud)
3f0079b to
8d0f029
Compare
It makes sense. Using |
8d0f029 to
c4366c0
Compare
Right!
I think we can do it in another PR |
555f2a2 to
bf1a571
Compare
eeff358 to
461b7a3
Compare
461b7a3 to
ed7b7de
Compare
ed7b7de to
1df8140
Compare
Davidson-Souza
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ACK 1df8140
jaoleal
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM but it needs some changes...
sry for the late response
1df8140 to
ed43ad4
Compare
Fix strippedsize to correctly calculate and return the block size excluding witness data
ed43ad4 to
90b3485
Compare
- Use corepc GetBlockVerboseOne instead of local verbose type. - Make get_block RPC field names/types compatible with Bitcoin Core. - Update functional tests to mine blocks (avoid genesis) and compare field-by-field. - update GetBlockRes enum variants to One and Zero
In the Bitcoin Core documentation, the default value of verbosity is 1. So I adjusted the values in `floresta-rpc` and `floresta-node`. Verbosity is no longer required in `floresta-node`
90b3485 to
ce45338
Compare
|
ce45338 I fixed a problem in the |
|
ACK ce45338 |
Davidson-Souza
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ACK ce45338
b37772d chore(rpcserver): Match signature of getblock to its rpc (jaoleal) Pull request description: ### Description and Notes #682 introduced changes that brought getblock rpc method closer to bitcoin core behavior. The changes presented here make the internal method signature to match the specification. ACKs for top commit: moisesPompilio: ACK b37772d Davidson-Souza: ACK b37772d Tree-SHA512: e5c72bf24daf795e853c284b4ef14738ffb6f3779e75a660ab85e86da98a3e48e184853c264054a832f9efc077cb86cf53e886b575e80fafd01b85e6b9a54625
What is the purpose of this pull request?
Which crates are being modified?
Description and Notes
Adjusted the get_block RPC output to match Bitcoin Core’s behavior.
Changes include:
How to verify the changes you have done?
The changes can be verified by comparing the get_block RPC output from Floresta with Bitcoin Core’s reference output and documentation.
For the genesis block (0f9188f13cb7b2c71f2a335e3a4fc328bf5beb436012afca590b1a11466e2206), Bitcoin Core returns:
{ "hash": "0f9188f13cb7b2c71f2a335e3a4fc328bf5beb436012afca590b1a11466e2206", "confirmations": 1, "height": 0, "version": 1, "versionHex": "00000001", "merkleroot": "4a5e1e4baab89f3a32518a88c31bc87f618f76673e2cc77ab2127b7afdeda33b", "time": 1296688602, "mediantime": 1296688602, "nonce": 2, "bits": "207fffff", "target": "7fffff0000000000000000000000000000000000000000000000000000000000", "difficulty": 4.656542373906925e-10, "chainwork": "0000000000000000000000000000000000000000000000000000000000000002", "nTx": 1, "nextblockhash": "5a31f5b914660757c24e62459b8905f64c7b9ee64740da333eaf8372aed81c82", "strippedsize": 285, "size": 285, "weight": 1140, "tx": [ "4a5e1e4baab89f3a32518a88c31bc87f618f76673e2cc77ab2127b7afdeda33b" ] }The reference behavior and expected field serialization can be cross-checked directly in Bitcoin Core’s implementation
src/rpc/blockchain.cpp and its official RPC documentation.