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

Chunk group assignment #697

Open
wants to merge 25 commits into
base: master
Choose a base branch
from

Conversation

cody-littley
Copy link
Contributor

@cody-littley cody-littley commented Aug 12, 2024

Why are these changes needed?

This is the code for mapping light nodes into chunk groups.

Checks

  • I've made sure the lint is passing in this PR.
  • I've made sure the tests are passing. Note that there might be a few flaky tests, in that case, please comment that they are not relevant.
  • Testing Strategy
    • Unit tests
    • Integration tests
    • This PR is not tested :(

Signed-off-by: Cody Littley <[email protected]>
Signed-off-by: Cody Littley <[email protected]>
Signed-off-by: Cody Littley <[email protected]>
Signed-off-by: Cody Littley <[email protected]>
Signed-off-by: Cody Littley <[email protected]>
Signed-off-by: Cody Littley <[email protected]>
Signed-off-by: Cody Littley <[email protected]>
@cody-littley cody-littley self-assigned this Aug 12, 2024
Signed-off-by: Cody Littley <[email protected]>
Signed-off-by: Cody Littley <[email protected]>
// hash hashes a seed using the Keccak-256 algorithm. The returned value is an integer formed from the
// first 8 bytes of the hash.
func randomInt(seed uint64) uint64 {
hasher := sha3.NewLegacyKeccak256()
Copy link
Contributor Author

@cody-littley cody-littley Aug 13, 2024

Choose a reason for hiding this comment

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

@mooselumph Is this the correct function to call for a standard keccak hash, or should I instead be calling sha3.New256()?

@cody-littley cody-littley marked this pull request as ready for review August 13, 2024 18:27
Signed-off-by: Cody Littley <[email protected]>
Signed-off-by: Cody Littley <[email protected]>
Signed-off-by: Cody Littley <[email protected]>
Signed-off-by: Cody Littley <[email protected]>
Signed-off-by: Cody Littley <[email protected]>
Signed-off-by: Cody Littley <[email protected]>
function:

```
chunkGroup := randomInt(rotateLeft(nodeSeed, assignmentIndex) ^ shuffleEpoch) % numberOfChunks
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm unclear on which operation is meant by ^ here. If this is bitwise XOR, then it might be constraining the entropy undesirably.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Correct, ^ should be interpreted to mean bitwise XOR.

An alternate strategy might be to just feed the nodeSeed, assignmentIndex, and shuffleEpoch directly into the keccak digest as a byte array.

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 went ahead and implemented the new strategy that appends the values into a byte array and then feeds the entire byte array into the digest.

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