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 Shuffle Function to Swap-or-not #1643

Closed
wants to merge 61 commits into from
Closed

Update Shuffle Function to Swap-or-not #1643

wants to merge 61 commits into from

Conversation

cyberbono3
Copy link
Contributor

[Resolves] #1529


Description

  1. I have implemented shuffle algorithm according to spec

  2. I ran bazel test and majority of tests failed with timeout error.

  3. I think with high probability my implementation is not correct.

I would appreciate your review and feedback.

@prestonvanloon
Copy link
Member

Many tests failing, can you please take a look?

Copy link
Member

@prestonvanloon prestonvanloon left a comment

Choose a reason for hiding this comment

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

Please fix tests

Copy link
Member

@nisdas nisdas left a comment

Choose a reason for hiding this comment

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

@cyberbono3 This doesnt match the spec, its hard to follow what is going on. This is the current one in the spec
https://github.com/ethereum/eth2.0-specs/blob/dev/specs/core/0_beacon-chain.md#get_permuted_index


"github.com/ethereum/go-ethereum/common"
"github.com/prysmaticlabs/prysm/shared/hashutil"
"github.com/prysmaticlabs/prysm/shared/params"
//"github.com/prysmaticlabs/prysm/shared/params"
)

// ShuffleIndices returns a list of pseudorandomly sampled
// indices. This is used to shuffle validators on ETH2.0 beacon chain.
func ShuffleIndices(seed common.Hash, indicesList []uint64) ([]uint64, error) {
Copy link
Member

Choose a reason for hiding this comment

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

This is confusing this doesnt match the spec at all , this is the function in the spec

def get_permuted_index(index: int, list_size: int, seed: Bytes32) -> int:

There also no assertions from the spec

    assert index < list_size
    assert list_size <= 2**40

bs4 := make([]byte, 8)
listSize := len(indicesList)
num := int(math.Floor(float64((listSize + 255) / 256)))
powersOfTwo := []uint64{1, 2, 4, 8, 16, 32, 64, 128}
Copy link
Member

Choose a reason for hiding this comment

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

Please use the PowerOf2function in shared/mathutils for this

t.Errorf("list 2 was incorrectly shuffled")
}

// if !reflect.DeepEqual(list1, []uint64{3,3,0,3,0,3,0,2,0,3}) {
Copy link
Member

Choose a reason for hiding this comment

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

dont comment out code, either check it in or remove it.

@prestonvanloon
Copy link
Member

This implementation might be a helpful reference or library to use: https://github.com/protolambda/eth2-shuffle

@cyberbono3
Copy link
Contributor Author

thanks for your feedback, guys !
@nisdas i am a bit confused, what function should I implement get_shuffling or get_permuted_index ?

@prestonvanloon
Copy link
Member

Please fix tests


"github.com/ethereum/go-ethereum/common"
"github.com/prysmaticlabs/prysm/shared/hashutil"
"github.com/prysmaticlabs/prysm/shared/params"
//"github.com/prysmaticlabs/prysm/shared/params"
Copy link
Member

Choose a reason for hiding this comment

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

Please remove this, if you are not using. dont comment it out

@prestonvanloon
Copy link
Member

Taking a look at this to see what I can do to help

@stale
Copy link

stale bot commented Mar 12, 2019

This pull request has been automatically marked as stale because it has not had recent activity. It will be closed in 7 days if no further activity occurs. Thank you for your contributions.

@stale stale bot added the Stale There hasn't been any activity here in some time... label Mar 12, 2019
@prestonvanloon prestonvanloon added Blocked Blocked by research or external factors and removed Stale There hasn't been any activity here in some time... labels Mar 21, 2019
@prestonvanloon
Copy link
Member

Blocked by testnet feature freeze

@prestonvanloon prestonvanloon added this to the Diamond milestone Mar 21, 2019
@stale
Copy link

stale bot commented Mar 28, 2019

This pull request has been automatically marked as stale because it has not had recent activity. It will be closed in 7 days if no further activity occurs. Thank you for your contributions.

@stale stale bot added the Stale There hasn't been any activity here in some time... label Mar 28, 2019
@stale
Copy link

stale bot commented Apr 4, 2019

This pull request has been closed due to inactivity. Please reopen this pull request if you would like to continue working on it.

@stale stale bot closed this Apr 4, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Blocked Blocked by research or external factors Stale There hasn't been any activity here in some time...
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants