-
Notifications
You must be signed in to change notification settings - Fork 37.7k
rpc: return block hash & height in getbalances, gettransaction & getwalletinfo JSONs #18570
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
Conversation
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.
Concept ACK. Could:
- Add tests
- Add documentation about this guideline to
doc/developer-notes.md
whereBlockUntilSyncedToCurrentChain
is also documented
Many thanks. Have added a new functional test However, not sure if the docs I added is sufficient enough. |
And again, GitHub closed my pull request. This makes no sense, I just force pushed it. |
@fanquake |
I cannot. You'll likely have to open a new PR. |
Ok, no problem. |
@brakmic see this: |
@promag |
Concept ACK. Very good idea, to add "valid as of ..." stamp to the returned data. What about also adding the height to make it easy/obvious which one is newer, assuming a few requests:
But it's good even without that. Thanks! |
As wallet already has |
Have updated the code, please check. |
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.
Agree with @jonatack.
Code review ACK. Needs git cleanup (squashing). Verified that there are no concurrency issues between getting the balance and the fetching the wallets bestblock. nit: i'm not 100% sure about the term |
Thanks. |
Interesting, on my machine (a macOS Catalina 10.15.4) I am still not getting any errors when executing Will have to dig deeper, it seems. |
@MarcoFalke travis isn't showing any error logs? Only that it wasn't able to fetch them. |
Error is the same on appveyor: https://ci.appveyor.com/project/DrahtBot/bitcoin/builds/32103450#L4902 Make sure to run |
The frozenset |
The |
ACK 0ac3e82 |
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.
Looks good, except the below and appveyor failure, maybe unrelated:
OSError: [WinError 10048] Only one usage of each socket address (protocol/network address/port) is normally permitted
AssertLockHeld(wallet.cs_wallet); | ||
UniValue lastprocessedblock{UniValue::VOBJ}; | ||
lastprocessedblock.pushKV("hash", wallet.GetLastBlockHash().GetHex()); | ||
lastprocessedblock.pushKV("height", wallet.GetLastBlockHeight()); |
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.
GetLastBlockHeight()
returns m_last_block_processed_height
and there is this strange scary comment for it:
Height is a pointer on node's tip and doesn't imply that the wallet has scanned sequentially all blocks up to this one.
Introduced in https://github.com/bitcoin/bitcoin/pull/15931/files#diff-12635a58447c65585f51d32b7e04075bR697-R698
Before that it was
Note that this is not how far we've processed...
from https://github.com/bitcoin/bitcoin/pull/10286/files#diff-12635a58447c65585f51d32b7e04075bR732-R734
Does this contradict with what we are trying to do here?
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.
Does this contradict with what we are trying to do here?
Yes it does. Not sure how we should deal with old wallets that are catching up with the chain after being just loaded.
I'm not sure this is the right approach, interface-wise, especially for calls like Maybe it'd be better to just guarantee atomicity for batch requests? |
Atomicity of batch requests would be good from user point of view, no doubt about it. But it would not fully cover what this PR is trying to do - provide a kind of "stamp" for the returned data - "this is valid as of block XYZ (height 123)". I think this is important given the volatility of the data - it may no longer be accurate when it gets to the client or the client may do something with it at a later time. |
You would batch any call with |
So wallets are unusable by clients that don't have batch support implemented? |
"Unusable" seems a bit strong here. But yes, "I don't want to implement it" isn't an excuse to pick a bad interface... |
🐙 This pull request conflicts with the target branch and needs rebase. |
…alletinfo JSONs Github-Pull: bitcoin#18570 Rebased-From: 1e868bb
This PR expands the JSONs returned from getbalances, gettransaction and getwalletinfo RPCs by adding a new property: lastprocessedblock that contains the hash and height of the block.
Changes:
GetLastBlockHash
to returnm_last_block_processed
AppendLastProcessedBlock
to insert JSON objectsRESULT_LAST_PROCESSED_BLOCK
for JSON reusetests/functional/wallet_balance.py
The motivation for this PR can be found here #18567
The idea to make
lastprocessedblock
an object that contains both hash and height is from vasild. Originally, only the hash was shown.Fixes #18567