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

Update deltaStalkEarnedPerSeason to int32 #1092

Merged
merged 6 commits into from
Sep 16, 2024

Conversation

pizzaman1337
Copy link
Contributor

Update deltaStalkEarnedPerSeason to int32 to prevent overflow on sunrise upon reseed.

@@ -316,7 +316,7 @@ struct AssetSettings {
int96 milestoneStem; // │ 12 (30)
bytes1 encodeType; // │ 1 (31)
// one byte is left here. ──┘ 1 (32)
int24 deltaStalkEarnedPerSeason; // ────┐ 3
int32 deltaStalkEarnedPerSeason; // ────┐ 3
Copy link
Contributor

Choose a reason for hiding this comment

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

the comments should be updated based on this (i.e, this is now 4 bytes instead of 3), and the summation is now 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.

@@ -458,19 +459,19 @@ library LibGerminate {
if (s.sys.silo.assetSettings[token].milestoneSeason < s.sys.season.current) {
prevStalkEarnedPerSeason = s.sys.silo.assetSettings[token].stalkEarnedPerSeason;
} else {
int24 deltaStalkEarnedPerSeason = s
int64 deltaStalkEarnedPerSeason = s
Copy link
Contributor

Choose a reason for hiding this comment

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

should this be int32?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yes, a leftover from experimenting with different sizes: 9249efd#diff-d2261445685829aad9421eae03f9644ae9d11be5713ccc0870497a0be1e58d8aR462

.sys
.silo
.assetSettings[token]
.deltaStalkEarnedPerSeason;
if (deltaStalkEarnedPerSeason >= 0) {
prevStalkEarnedPerSeason =
s.sys.silo.assetSettings[token].stalkEarnedPerSeason -
uint32(int32(deltaStalkEarnedPerSeason));
uint32(uint64(deltaStalkEarnedPerSeason));
Copy link
Contributor

Choose a reason for hiding this comment

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

why is this casted to a uint64, then a uint32?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yes, a leftover from experimenting with different sizes: 9249efd#diff-d2261445685829aad9421eae03f9644ae9d11be5713ccc0870497a0be1e58d8aR470

@@ -204,7 +204,7 @@ library LibWhitelist {

// stalkEarnedPerSeason is set to int32 before casting down.
s.sys.silo.assetSettings[token].deltaStalkEarnedPerSeason = (int32(stalkEarnedPerSeason) -
int32(s.sys.silo.assetSettings[token].stalkEarnedPerSeason)).toInt24();
int32(s.sys.silo.assetSettings[token].stalkEarnedPerSeason)).toInt32();
Copy link
Contributor

Choose a reason for hiding this comment

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

surrounding the s.sys.silo.assetSettings[token].stalkEarnedPerSeason with a int32 and casting down to a toInt32 is unnecessary.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Copy link
Contributor

@Brean0 Brean0 left a comment

Choose a reason for hiding this comment

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

Please update the PR with the changes noted in the comments.

Copy link
Contributor

@Brean0 Brean0 left a comment

Choose a reason for hiding this comment

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

Please update the PR with the changes noted in the comments.

@pizzaman1337 pizzaman1337 merged commit cb3196b into reseed-final-fixes Sep 16, 2024
2 checks passed
@pizzaman1337 pizzaman1337 deleted the int32-deltaStalkEarnedPerSeason branch September 16, 2024 20:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants