-
Notifications
You must be signed in to change notification settings - Fork 106
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
change(rpc): Add getpeerinfo RPC method #5951
Conversation
skips solution check for BlockProposal requests calls CheckBlockValidity instead of Commit block for BlockProposal requests
…ktemplate-rpcs in zebra-state
…w checkpoint height adds feature flags
adds/fixes some comments, adds TODOs general cleanup from a self-review.
Co-authored-by: teor <[email protected]>
Co-authored-by: teor <[email protected]>
Co-authored-by: teor <[email protected]>
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!
Can you please post a zcash-rpc-diff getpeerinfo
with zcashd
, to make sure we have the response format correct?
Do we need to add a test that calls this RPC in CI?
It doesn't need to have a cached state, it can just be one of the acceptance tests. This will also avoid any breaking changes to the RPC.
Yep: ➜ zebra git:(getpeerinfo-rpc) ZCASH_CLI=../zcash/src/zcash-cli ./zebra-utils/zcash-rpc-diff 3000 getpeerinfo
Checking first node release info...
Checking second node release info...
Connected to zebrad (port 3000) and zcashd (../zcash/src/zcash-cli zcash.conf port).
Checking zebrad network and tip height...
Checking zcashd network and tip height...
WARNING: comparing RPC responses from different heights:
zebrad is at: 1951017
zcashd is at: 1951019
Request:
getpeerinfo
Querying zebrad main chain at height >=1951017...
real 0m0.002s
user 0m0.002s
sys 0m0.000s
Querying zcashd main chain at height >=1951019...
real 0m0.002s
user 0m0.002s
sys 0m0.000s
Response diff between zebrad and zcashd:
Response: --- /tmp/tmp.gnxKauLyNF.rpc-diff/zebrad-main-1951017-getpeerinfo.json 2023-01-16 18:11:08.681000866 -0500
+++ /tmp/tmp.gnxKauLyNF.rpc-diff/zcashd-main-1951019-getpeerinfo.json 2023-01-16 18:11:08.681000866 -0500
@@ -1,80 +1,193 @@
[
{
- "addr": "x.x.x.x:8233"
- },
- {
- "addr": "x.x.x.x:8233"
- },
- {
- "addr": "x.x.x.x:8233"
- },
- {
- "addr": "x.x.x.x:8233"
- },
- {
- "addr": "x.x.x.x:8233"
- },
- {
- "addr": "x.x.x.x:8233"
- },
- {
- "addr": "x.x.x.x:8233"
- },
- {
- "addr": "x.x.x.x:8233"
- },
- {
- "addr": "x.x.x.x:8233"
- },
- {
- "addr": "x.x.x.x:8233"
- },
- {
- "addr": "x.x.x.x:8233"
- },
- {
- "addr": "x.x.x.x:8233"
- },
- {
- "addr": "x.x.x.x:8233"
- },
- {
- "addr": "x.x.x.x:8233"
- },
- {
- "addr": "x.x.x.x:8233"
- },
- {
- "addr": "x.x.x.x:8233"
- },
- {
- "addr": "x.x.x.x:8233"
- },
- {
- "addr": "x.x.x.x:8233"
- },
- {
- "addr": "x.x.x.x:8233"
- },
- {
- "addr": "x.x.x.x:8233"
- },
- {
- "addr": "x.x.x.x:8233"
- },
- {
- "addr": "x.x.x.x:8233"
- },
- {
- "addr": "x.x.x.x:8233"
- },
- {
- "addr": "x.x.x.x:8233"
- },
- {
- "addr": "x.x.x.x:8233"
- },
- {
- "addr": "x.x.x.x:8233"
+ "id": 1,
+ "addr": "x.x.x.x:8233",
+ "addrlocal": "x.x.x.x:61556",
+ "services": "0000000000000005",
+ "relaytxes": true,
+ "lastsend": 1673910652,
+ "lastrecv": 1673910652,
+ "bytessent": 598109,
+ "bytesrecv": 118785965,
+ "conntime": 1673895922,
+ "timeoffset": 0,
+ "pingtime": 0.106408,
+ "version": 170100,
+ "subver": "/MagicBean:5.3.0/",
+ "inbound": false,
+ "startingheight": 1950812,
+ "banscore": 0,
+ "synced_headers": 1951019,
+ "synced_blocks": 1951019,
+ "inflight": [
+ ],
+ "whitelisted": false
+ },
+ {
+ "id": 3,
+ "addr": "x.x.x.x:8233",
+ "services": "0000000000000001",
+ "relaytxes": true,
+ "lastsend": 1673910650,
+ "lastrecv": 1673910652,
+ "bytessent": 2853306,
+ "bytesrecv": 43265172,
+ "conntime": 1673895923,
+ "timeoffset": -1,
+ "pingtime": 0.240153,
+ "version": 170100,
+ "subver": "/MagicBean:5.3.2/",
+ "inbound": false,
+ "startingheight": 1950812,
+ "banscore": 0,
+ "synced_headers": 1951019,
+ "synced_blocks": 1951019,
+ "inflight": [
+ ],
+ "whitelisted": false
+ },
+ {
+ "id": 4,
+ "addr": "x.x.x.x:8233",
+ "addrlocal": "x.x.x.x:61596",
+ "services": "0000000000000005",
+ "relaytxes": true,
+ "lastsend": 1673910654,
+ "lastrecv": 1673910657,
+ "bytessent": 7694700,
+ "bytesrecv": 66215784,
+ "conntime": 1673895924,
+ "timeoffset": -4,
+ "pingtime": 0.107663,
+ "version": 170100,
+ "subver": "/MagicBean:5.3.2/",
+ "inbound": false,
+ "startingheight": 1950812,
+ "banscore": 0,
+ "synced_headers": 1951019,
+ "synced_blocks": 1951019,
+ "inflight": [
+ ],
+ "whitelisted": false
+ },
+ {
+ "id": 5,
+ "addr": "x.x.x.x:8233",
+ "addrlocal": "x.x.x.x:61580",
+ "services": "0000000000000005",
+ "relaytxes": true,
+ "lastsend": 1673910652,
+ "lastrecv": 1673910647,
+ "bytessent": 20002261,
+ "bytesrecv": 37563937,
+ "conntime": 1673895927,
+ "timeoffset": -2,
+ "pingtime": 0.08204500000000001,
+ "version": 170100,
+ "subver": "/MagicBean:5.3.2/",
+ "inbound": false,
+ "startingheight": 1950812,
+ "banscore": 0,
+ "synced_headers": 1951019,
+ "synced_blocks": 1951019,
+ "inflight": [
+ ],
+ "whitelisted": false
+ },
+ {
+ "id": 6,
+ "addr": "x.x.x.x:8233",
+ "addrlocal": "x.x.x.x:61628",
+ "services": "0000000000000005",
+ "relaytxes": true,
+ "lastsend": 1673910653,
+ "lastrecv": 1673910653,
+ "bytessent": 1109135,
+ "bytesrecv": 42833285,
+ "conntime": 1673895936,
+ "timeoffset": 0,
+ "pingtime": 0.036377,
+ "version": 170100,
+ "subver": "/MagicBean:5.3.0/",
+ "inbound": false,
+ "startingheight": 1950812,
+ "banscore": 0,
+ "synced_headers": 1951019,
+ "synced_blocks": 1951019,
+ "inflight": [
+ ],
+ "whitelisted": false
+ },
+ {
+ "id": 7,
+ "addr": "x.x.x.x:8233",
+ "addrlocal": "x.x.x.x:61574",
+ "services": "0000000000000005",
+ "relaytxes": true,
+ "lastsend": 1673910653,
+ "lastrecv": 1673910653,
+ "bytessent": 2019806,
+ "bytesrecv": 39574709,
+ "conntime": 1673895938,
+ "timeoffset": -1,
+ "pingtime": 0.119679,
+ "version": 170100,
+ "subver": "/MagicBean:5.3.0/",
+ "inbound": false,
+ "startingheight": 1950812,
+ "banscore": 0,
+ "synced_headers": 1951019,
+ "synced_blocks": 1951019,
+ "inflight": [
+ ],
+ "whitelisted": false
+ },
+ {
+ "id": 8,
+ "addr": "x.x.x.x:8233",
+ "addrlocal": "x.x.x.x:61632",
+ "services": "0000000000000005",
+ "relaytxes": true,
+ "lastsend": 1673910653,
+ "lastrecv": 1673910653,
+ "bytessent": 3618634,
+ "bytesrecv": 45650400,
+ "conntime": 1673895945,
+ "timeoffset": -1,
+ "pingtime": 0.181401,
+ "version": 170100,
+ "subver": "/MagicBean:5.3.2/",
+ "inbound": false,
+ "startingheight": 1950812,
+ "banscore": 0,
+ "synced_headers": 1951019,
+ "synced_blocks": 1951019,
+ "inflight": [
+ ],
+ "whitelisted": false
+ },
+ {
+ "id": 9,
+ "addr": "x.x.x.x:8233",
+ "addrlocal": "x.x.x.x:61558",
+ "services": "0000000000000005",
+ "relaytxes": true,
+ "lastsend": 1673910660,
+ "lastrecv": 1673910663,
+ "bytessent": 204732,
+ "bytesrecv": 57428842,
+ "conntime": 1673896001,
+ "timeoffset": 0,
+ "pingtime": 0.028809,
+ "version": 170100,
+ "subver": "/MagicBean:5.3.0/",
+ "inbound": false,
+ "startingheight": 1950812,
+ "banscore": 0,
+ "synced_headers": 1951019,
+ "synced_blocks": 1951019,
+ "inflight": [
+ ],
+ "whitelisted": false
}
]
Okay, I'll add an acceptance test. |
Co-authored-by: teor <[email protected]>
b0a63b9
to
493412f
Compare
…d uses it from the get_peer_info test
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.
Thanks for the tests!
Motivation
Mining pools use the
getpeerinfo
RPC to make sure the mining pool is still connected to peers.Depends-On: #5884
Closes #5723.
Solution
address_book
toRpcServer::spawn
andGetBlockTemplateRpcImpl
recently_live_peers
and returns a list of peer addressesAddressBookPeers
trait andMockAddressBookPeers
for use in testsrecently_live_peers
method to return aVec
instead of an iteratorReview
Anyone can review.
Reviewer Checklist