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

goal: Added consensus upgrade fields to node status api & goal output #4800

Merged
merged 28 commits into from
Jan 4, 2023

Conversation

mciccarello
Copy link
Contributor

Summary

Test Plan

@CLAassistant
Copy link

CLAassistant commented Nov 16, 2022

CLA assistant check
All committers have signed the CLA.

@mciccarello mciccarello marked this pull request as draft November 16, 2022 07:05
@mciccarello
Copy link
Contributor Author

Eric (or someone) can you let me know what else is expected? I'm unsure what's required for testing in particular. I can't really test for correct values if there's not an upgrade going on, for example.

@mciccarello mciccarello marked this pull request as ready for review November 16, 2022 07:06
@mciccarello mciccarello marked this pull request as draft November 16, 2022 07:07
Copy link
Contributor

@Eric-Warehime Eric-Warehime left a comment

Choose a reason for hiding this comment

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

LGTM. For testing you can probably extend the existing NodeStatus test here by just adding the proper data--probably injecting a custom Consensus Protocol here

It looks like the tests are already complaining about some of the new fields being added that aren't expected.

@Eric-Warehime
Copy link
Contributor

Also, the go-algorand repo requires you to tag your PR with one of New Feature, Enhancement, Bug-Fix, Not-Yet-Enabled, Skip-Release-Notes.

And I think the title has to be something like <string describing PR category>: <PR TITLE> so like algod: Added consensus upgrade fields to node status api & goal output

@winder winder changed the title Added consensus upgrade fields to node status api & goal output goal: Added consensus upgrade fields to node status api & goal output Nov 16, 2022
@codecov
Copy link

codecov bot commented Nov 17, 2022

Codecov Report

Merging #4800 (ab22d88) into master (4f1ac12) will decrease coverage by 0.07%.
The diff coverage is 14.51%.

@@            Coverage Diff             @@
##           master    #4800      +/-   ##
==========================================
- Coverage   53.70%   53.62%   -0.08%     
==========================================
  Files         433      433              
  Lines       54050    54106      +56     
==========================================
- Hits        29028    29017      -11     
- Misses      22776    22840      +64     
- Partials     2246     2249       +3     
Impacted Files Coverage Δ
cmd/goal/node.go 11.90% <0.00%> (-0.78%) ⬇️
daemon/algod/api/server/v2/handlers.go 0.82% <0.00%> (-0.03%) ⬇️
node/node.go 4.22% <0.00%> (-0.04%) ⬇️
daemon/algod/api/server/v2/test/helpers.go 74.83% <90.00%> (+<0.01%) ⬆️
ledger/blockqueue.go 85.63% <0.00%> (-2.88%) ⬇️
catchup/peerSelector.go 98.95% <0.00%> (-1.05%) ⬇️
cmd/tealdbg/debugger.go 72.69% <0.00%> (-0.81%) ⬇️
catchup/service.go 69.80% <0.00%> (-0.73%) ⬇️
network/wsNetwork.go 64.74% <0.00%> (-0.18%) ⬇️

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

@mciccarello mciccarello marked this pull request as ready for review November 17, 2022 23:01
@mciccarello mciccarello requested a review from winder November 17, 2022 23:02
@mciccarello
Copy link
Contributor Author

Please approve

Copy link
Contributor

@winder winder left a comment

Choose a reason for hiding this comment

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

I left a couple suggestions. Did you have a chance to review Eric's suggestion? There may be an existing tests you can hook into.

@@ -781,6 +798,14 @@ func (v2 *Handlers) GetStatus(ctx echo.Context) error {
CatchpointAcquiredBlocks: &stat.CatchpointCatchupAcquiredBlocks,
}

if upgradePropose != "" {
Copy link
Contributor

Choose a reason for hiding this comment

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

This also needs to check that the vote has not finished:

Suggested change
if upgradePropose != "" {
if upgradePropose != "" && latestBlkHdr.NextProtocolVoteBefore > stat.LastRound {

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

cmd/goal/node.go Outdated
@@ -458,6 +459,34 @@ func makeStatusString(stat model.NodeStatusResponse) string {
if stat.StoppedAtUnsupportedRound {
statusString = statusString + "\n" + fmt.Sprintf(catchupStoppedOnUnsupported, stat.LastRound)
}

if stat.UpgradePropose != nil {
Copy link
Contributor

Choose a reason for hiding this comment

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

Same as below, no need to display this once the vote is complete.

Suggested change
if stat.UpgradePropose != nil {
if stat.UpgradePropose != nil && stat.LastVersion != stat.NextVersion {

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

Comment on lines 790 to 806
upgradePropose := string(latestBlkHdr.UpgradeVote.UpgradePropose)
if upgradePropose != "" && latestBlkHdr.NextProtocolVoteBefore > stat.LastRound {
votesToGo := uint64(latestBlkHdr.NextProtocolVoteBefore) - uint64(stat.LastRound)
consensus := config.Consensus[protocol.ConsensusCurrentVersion]
upgradeVoteRounds := consensus.UpgradeVoteRounds
upgradeThreshold := consensus.UpgradeThreshold
votes := uint64(upgradeVoteRounds) - votesToGo
votesYes := latestBlkHdr.UpgradeState.NextProtocolApprovals
votesNo := votes - votesYes
upgradeDelay := uint64(latestBlkHdr.UpgradeVote.UpgradeDelay)

response.UpgradePropose = &upgradePropose
response.UpgradeThreshold = &upgradeThreshold
response.UpgradeApprove = &latestBlkHdr.UpgradeApprove
response.UpgradeDelay = &upgradeDelay
response.UpgradeNo = &votesNo
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Discussed offline, but I think it's useful to write down here for posterity...

I think it's important to put this logic in the node.Status function.
Reason being is that the Status call uses the ledger.BlockHdr call used above internally to fill in the output. So the following sequence of events becomes problematic.

  1. Node.Status is called returning status info for the latest round, round X.
  2. Either agreement or catchup advances the latest round in the ledger to X+1.
  3. Ledger.BlockHdr is called for the latest round, X+1.

Now the data in latestBlkHdr potentially conflicts the data in stat.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

@mciccarello
Copy link
Contributor Author

mciccarello commented Dec 3, 2022

@winder The values don't look right to me either. But the field names and their sources come directly from the ticket as far as I can tell:

Fields from the UpgradeVote blockheader struct:

UpgradePropose
UpgradeDelay
UpgradeApprove

Consensus value:

UpgradeThreshold

The no votes is a computed value, as per the ticket based on a formula in node-ui.

votes - votes yes where
votes = upgrade rounds - votes to go where
votes to go = Header.NextProtocolVoteBefore - Status.LastRound
and
votes yes = Header.ProtocolApprovals

...and it looks to me like that's what my code does, though perhaps I'm getting one or more of these fields from the wrong data structure?

What I'm really not sure of is how "Upgrade proposal" could be empty. Investigating further

@winder
Copy link
Contributor

winder commented Dec 5, 2022

@winder The values don't look right to me either. But the field names and their sources come directly from the ticket as far as I can tell:

Fields from the UpgradeVote blockheader struct:
UpgradePropose
UpgradeDelay
UpgradeApprove
Consensus value:
UpgradeThreshold

The no votes is a computed value, as per the ticket based on a formula in node-ui.

votes - votes yes where votes = upgrade rounds - votes to go where votes to go = Header.NextProtocolVoteBefore - Status.LastRound and votes yes = Header.ProtocolApprovals

...and it looks to me like that's what my code does, though perhaps I'm getting one or more of these fields from the wrong data structure?

What I'm really not sure of is how "Upgrade proposal" could be empty. Investigating further

It looks like you have the correct values, but we should just figure out how to label them for the user to make sure what they represent is clear.

I made a diagram to help refresh my memory about how these formulas relate to each other.

It looks like your formula is slightly wrong, you need to get the proposal round first:
Votes = Header.NextProtocolVoteBefore - (Header.NextProtocolVoteBefore - Consensus.UpgradeThreshold)

image

For reference, I think this is pretty clear. But the goal command / API have more constraints.
image

What do you think about the following:

Consensus Upgrade State: Voting
Next Protocol: xxxxx
Votes: 1500
Yes Votes: 750
Votes Remaining: 8500
Yes Votes Required: 9000
Vote Window Close: xxxxx

Once scheduled

Consensus Upgrade State: Scheduled
...
The existing upgrade scheduled information here
...

@mciccarello
Copy link
Contributor Author

It looks like your formula is slightly wrong, you need to get the proposal round first: Votes = Header.NextProtocolVoteBefore - (Header.NextProtocolVoteBefore - Consensus.UpgradeThreshold)

I don't see how that's possible. That's just ConsensusUpgradeThreshold!

@algoanne
Copy link
Contributor

@mciccarello and I chatted a bit about this. Here is what I propose:

Consensus Upgrade State: Voting
Next Protocol: 44fa607d6051730f5264526bf3c108d51f0eadb6

Yes Votes: 750
No Votes: 218
Votes Remaining: 8389

Yes Votes Required: 8422
Vote Window Close round: 25229176

And I like what @winder suggests for the "once scheduled" note.

@mciccarello mciccarello requested a review from winder January 3, 2023 18:22
Copy link
Contributor

@winder winder left a comment

Choose a reason for hiding this comment

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

Looks good!

Tested with mainnet:

During vote:

Time since last block: 0.0s
Sync Time: 35.3s
Last consensus protocol: https://github.com/algorandfoundation/specs/tree/433d8e9a7274b6fca703d91213e05c7e6a589e69
Next consensus protocol: https://github.com/algorandfoundation/specs/tree/433d8e9a7274b6fca703d91213e05c7e6a589e69
Round for next consensus protocol: 25231779
Next consensus protocol supported: true
Last Catchpoint: 
Consensus upgrate state: Voting
Yes votes: 2427
No votes: 174
Votes remaining: 7399
Yes votes required: 9000
Vote window close round: 25239177
Genesis ID: mainnet-v1.0
Genesis hash: wGHE2Pwdvd7S12BL5FaOP20EGYesN73ktiC1qzkkit8=

After vote:

Time since last block: 0.1s
Sync Time: 596.7s
Last consensus protocol: https://github.com/algorandfoundation/specs/tree/433d8e9a7274b6fca703d91213e05c7e6a589e69
Next consensus protocol: https://github.com/algorandfoundation/specs/tree/44fa607d6051730f5264526bf3c108d51f0eadb6
Round for next consensus protocol: 25379177
Next consensus protocol supported: true
Last Catchpoint: 
Consensus upgrade state: Scheduled
Genesis ID: mainnet-v1.0
Genesis hash: wGHE2Pwdvd7S12BL5FaOP20EGYesN73ktiC1qzkkit8=

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants