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

Change seed from int64 to uint64 #2438

Merged
merged 1 commit into from
Dec 6, 2023
Merged

Change seed from int64 to uint64 #2438

merged 1 commit into from
Dec 6, 2023

Conversation

StephenButtolph
Copy link
Contributor

Why this should be merged

Previously we used int64 for the seed to stay in-line with the standard library... However, internally casting from int64 to uint64 is weird. Additionally, we currently do a number of bitwise operations (uint64) to generate the seed in the proposervm.

How this works

Reduces the number of casts we need to do.

How this was tested

CI

@StephenButtolph StephenButtolph self-assigned this Dec 6, 2023
@StephenButtolph StephenButtolph added the cleanup Code quality improvement label Dec 6, 2023
@StephenButtolph StephenButtolph added this to the v1.10.18 milestone Dec 6, 2023
Comment on lines +40 to +42
func (r *rng) Seed(seed uint64) {
r.lock.Lock()
r.rng.Seed(uint64(seed))
r.rng.Seed(seed)
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 really shouldn't have been casting this before... There wasn't a good reason to take in an int64.

@@ -113,7 +113,7 @@ func (w *windower) Proposers(ctx context.Context, chainHeight, pChainHeight uint
}

seed := chainHeight ^ w.chainSource
w.sampler.Seed(int64(seed))
Copy link
Contributor Author

Choose a reason for hiding this comment

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

🎉

@patrick-ogrady
Copy link
Contributor

(bits used here shouldn't change, so should be a no-op during verification)

@StephenButtolph StephenButtolph added this pull request to the merge queue Dec 6, 2023
Merged via the queue into dev with commit 930879d Dec 6, 2023
16 checks passed
@StephenButtolph StephenButtolph deleted the seed-uint64 branch December 6, 2023 23:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cleanup Code quality improvement
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

3 participants