Skip to content
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

feat: include the node public key in /v2/info #3069

Merged
merged 7 commits into from
Mar 28, 2022
Merged

Conversation

jcnelson
Copy link
Member

Expose the node's network public key and its Hash160 in /v2/info. Fixes #3046.

@jcnelson jcnelson requested review from kantai and wileyj March 10, 2022 19:16
@codecov
Copy link

codecov bot commented Mar 10, 2022

Codecov Report

Merging #3069 (b9fcc8d) into develop (30890c6) will decrease coverage by 0.08%.
The diff coverage is 41.42%.

@@             Coverage Diff             @@
##           develop    #3069      +/-   ##
===========================================
- Coverage    83.83%   83.75%   -0.09%     
===========================================
  Files          248      248              
  Lines       196916   196986      +70     
===========================================
- Hits        165090   164980     -110     
- Misses       31826    32006     +180     
Impacted Files Coverage Δ
src/net/mod.rs 67.68% <ø> (+0.04%) ⬆️
stacks-common/src/types/mod.rs 93.22% <ø> (ø)
src/net/rpc.rs 31.27% <41.42%> (+0.14%) ⬆️
clarity/src/vm/ast/traits_resolver/mod.rs 94.44% <0.00%> (-3.97%) ⬇️
testnet/stacks-node/src/tests/neon_integrations.rs 88.35% <0.00%> (-2.06%) ⬇️
src/burnchains/bitcoin/mod.rs 39.13% <0.00%> (-1.45%) ⬇️
src/burnchains/bitcoin/indexer.rs 84.00% <0.00%> (-0.77%) ⬇️
src/cost_estimates/mod.rs 47.48% <0.00%> (-0.72%) ⬇️
clarity/src/vm/database/key_value_wrapper.rs 96.20% <0.00%> (-0.64%) ⬇️
clarity/src/vm/analysis/errors.rs 69.50% <0.00%> (-0.50%) ⬇️
... and 26 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update a1d45ca...b9fcc8d. Read the comment docs.

@jcnelson
Copy link
Member Author

Add an option to also report the miner address, but make it configurable (and off by default).

src/net/mod.rs Outdated
Comment on lines 1046 to 1051
#[serde(default)]
#[serde(skip_serializing_if = "Option::is_none")]
pub node_public_key: Option<StacksPublicKey>,
#[serde(default)]
#[serde(skip_serializing_if = "Option::is_none")]
pub node_public_key_hash: Option<Hash160>,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is the goal with these fields that this struct should still be able to deserialize the older version of the /v2/info result? If so, can you add a simple unit test that deserializes the old output. A related (but maybe harder to test) question: will old nodes ever try and fail to deserialize the new output?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is the goal with these fields that this struct should still be able to deserialize the older version of the /v2/info result?

Yes

If so, can you add a simple unit test that deserializes the old output.

Sure.

A related (but maybe harder to test) question: will old nodes ever try and fail to deserialize the new output?

Not that I'm aware of. However, I'm of the opinion that if we change the wire format of an RPC response in a backwards-incompatible way, then we need to bump the version prefix (i.e. /v3/info). I'd rather not do that, so I made it so the code will deserialize the older /v2/info.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added compatibility tests for the old /v2/info structure to verify that they decode under the new structure.

Copy link
Contributor

@pavitthrap pavitthrap left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

let mut peer_1_stacks_node = peer_1.stacks_node.take().unwrap();
let _ = peer_1
.network
.refresh_burnchain_view(&peer_1_sortdb, &peer_1_stacks_node.chainstate, false)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why did you add calls to refresh_burnchain_view here?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The absence of this call was causing the .canonical_stacks_tip_height values to not propagate. Adding this in fixes it.

@jcnelson jcnelson requested a review from kantai March 22, 2022 16:54
@jcnelson jcnelson merged commit 0170355 into develop Mar 28, 2022
@blockstack-devops
Copy link
Contributor

This pull request has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@stacks-network stacks-network locked as resolved and limited conversation to collaborators Nov 18, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants