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

chore: Rename ModStateProofNextRound to StateProofNext. #5265

Merged
merged 7 commits into from
Apr 14, 2023

Conversation

winder
Copy link
Contributor

@winder winder commented Apr 6, 2023

Summary

Remove Mod prefix because ModStateProofNextRound is an absolute round rather than some sort of mod/delta/offset.

Test Plan

Non functional change, existing regression tests.

@winder winder self-assigned this Apr 6, 2023
Copy link
Contributor

@algorandskiy algorandskiy left a comment

Choose a reason for hiding this comment

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

This change was made on purpose in order to not confuse with the value in block header since they have different semantics.

@winder
Copy link
Contributor Author

winder commented Apr 6, 2023

This change was made on purpose in order to not confuse with the value in block header since they have different semantics.

@algorandskiy What are the semantics?

@algorandskiy
Copy link
Contributor

ModStateProofNextRound is only set when block has a stateproof txn, and zero otherwise. Block's StateProofNextRound is always not zero and set to last seen ModStateProofNextRound.

@winder winder added the Bug-Fix label Apr 6, 2023
@winder winder marked this pull request as ready for review April 6, 2023 15:45
@winder
Copy link
Contributor Author

winder commented Apr 7, 2023

@algorandskiy changed this to be a codec tag. That should be sufficient to fix backwards compatibility with the SDK.

@winder winder requested a review from algorandskiy April 7, 2023 12:10
algorandskiy
algorandskiy previously approved these changes Apr 7, 2023
@winder
Copy link
Contributor Author

winder commented Apr 7, 2023

I needed to add msgp:ignore StateDelta for the CI to pass.

@winder winder requested review from Eric-Warehime and removed request for jannotti and id-ms April 7, 2023 16:28
@@ -113,7 +115,7 @@ type StateDelta struct {
// ModStateProofNextRound represents modification on StateProofNextRound field in the block header. If the block contains
// a valid state proof transaction, this field will contain the next round for state proof.
// otherwise it will be set to 0.
ModStateProofNextRound basics.Round
ModStateProofNextRound basics.Round `codec:"StateProofNextRound,omitempty"`
Copy link
Contributor

Choose a reason for hiding this comment

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

I think it is better to add a comment that explains why ModStateProofNextRound is the only field that has codec tag and why the codec id is different.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We're working on some CI automation that would warn when these types diverge from the ones in the sdk.

Hopefully that will serve better than comments like this.

Copy link
Contributor

Choose a reason for hiding this comment

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

are we renaming this field in the sdk, too? it's currently StateProofNext.
https://github.com/algorand/go-algorand-sdk/blob/develop/types/statedelta.go#L317

Copy link
Contributor Author

@winder winder Apr 13, 2023

Choose a reason for hiding this comment

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

I think that's why it was renamed here -- easy to mistake the block header field and the ledgercore state delta field. This codec change matches the current SDK.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@shiqizng thanks, you're right:

Suggested change
ModStateProofNextRound basics.Round `codec:"StateProofNextRound,omitempty"`
ModStateProofNextRound basics.Round `codec:"StateProofNext,omitempty"`

@@ -88,6 +88,8 @@ type KvValueDelta struct {
// If adding a new field not explicitly allocated by PopulateStateDelta, make sure to reset
// it in .ReuseStateDelta to avoid dirty memory errors.
// If adding fields make sure to add them to the .Reset() method to avoid dirty state
//
//msgp:ignore StateDelta
Copy link
Contributor

Choose a reason for hiding this comment

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

This will prevent us from ever msgp-encoding this data structure right? Not necessarily a bad thing, just want to be clear.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I believe this is only for the pre-generated Marshal/Unmarshal functions. We're still able to use the reflection based msgp encoding functions.

Copy link
Contributor

Choose a reason for hiding this comment

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

Right, the codegen which might be used when sending these messages over the network for example.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I added this in because adding the codec tag caused that codegen to start triggering for this struct. There were a bunch of errors with it because we don't set allocbounds in any of the slices.

Eric-Warehime
Eric-Warehime previously approved these changes Apr 13, 2023
shiqizng
shiqizng previously approved these changes Apr 13, 2023
@@ -113,7 +115,7 @@ type StateDelta struct {
// ModStateProofNextRound represents modification on StateProofNextRound field in the block header. If the block contains
// a valid state proof transaction, this field will contain the next round for state proof.
// otherwise it will be set to 0.
ModStateProofNextRound basics.Round
ModStateProofNextRound basics.Round `codec:"StateProofNext,omitempty"`
Copy link
Contributor

Choose a reason for hiding this comment

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

since the consensus name is StateProofNext for API, maybe we rename the field to StateProofNext as well?
It will be different from StateProofNextRound that is used in block headers (matching name here and there was a confusion point and the trigger for the original renaming)

algorandskiy
algorandskiy previously approved these changes Apr 14, 2023
Copy link
Contributor

@algorandskiy algorandskiy left a comment

Choose a reason for hiding this comment

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

Thank you. Few more usages left...

@winder winder changed the title chore: Rename ModStateProofNextRound to StateProofNextRound. chore: Rename ModStateProofNextRound to StateProofNext. Apr 14, 2023
@winder winder merged commit 1d80ccb into algorand:master Apr 14, 2023
@winder winder deleted the will/mod-state-delta-rename branch April 14, 2023 19:53
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