Skip to content

Starting on phase 1 misc beacon changes#1323

Merged
djrtwo merged 47 commits into
devfrom
vbuterin-patch-13
Sep 2, 2019
Merged

Starting on phase 1 misc beacon changes#1323
djrtwo merged 47 commits into
devfrom
vbuterin-patch-13

Conversation

@vbuterin

Copy link
Copy Markdown
Contributor

No description provided.

Comment thread specs/core/1_beacon_chain_misc.md Outdated
@hwwhww hwwhww added the phase 1 label Jul 30, 2019
Comment thread specs/core/1_beacon-chain-misc.md Outdated
Comment thread specs/core/1_beacon-chain-misc.md Outdated

@CarlBeek CarlBeek left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@djrtwo, All @inserts look good to me. (I also tested it with the spec builder and it works as expected too.)

Other comments are minor changes mostly related to whitespace.

Comment thread specs/core/1_beacon-chain-misc.md Outdated
Comment thread specs/core/1_beacon-chain-misc.md Outdated
Comment thread specs/core/1_beacon-chain-misc.md Outdated
Comment thread specs/core/1_beacon-chain-misc.md Outdated
Comment thread specs/core/1_beacon-chain-misc.md Outdated
Comment thread specs/core/1_beacon-chain-misc.md Outdated
Comment thread specs/core/1_beacon-chain-misc.md Outdated
@hwwhww hwwhww force-pushed the vbuterin-patch-13 branch from 2329171 to c5acddc Compare August 11, 2019 15:20

@hwwhww hwwhww left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Changelogs

  • Sorry for that I accidentally pushed the rebased branch. 🙈
  • Enabled it in the CI and then the errors reveal...!
  • Should merge #1326 before this one.

Comment thread specs/core/1_beacon-chain-misc.md Outdated
Comment thread specs/core/1_beacon-chain-misc.md Outdated
Comment thread specs/core/1_beacon-chain-misc.md
Comment thread specs/core/1_beacon-chain-misc.md
hwwhww and others added 4 commits August 12, 2019 00:40
Comment thread specs/core/1_beacon-chain-misc.md Outdated
Comment thread specs/core/1_beacon-chain-misc.md Outdated
Comment thread specs/core/1_beacon-chain-misc.md Outdated
Comment thread specs/core/0_beacon-chain.md Outdated
Comment thread specs/core/0_beacon-chain.md Outdated
Comment thread specs/core/1_beacon-chain-misc.md Outdated
Comment thread specs/core/1_beacon-chain-misc.md Outdated
Comment thread specs/core/1_beacon-chain-misc.md Outdated
Comment thread specs/core/1_beacon-chain-misc.md Outdated
"""
Given a state and a list of validator indices, outputs the CompactCommittee representing them.
"""
validators = [state.validators[i] for i in committee]

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
validators = [state.validators[i] for i in committee]
assert len(committee) <= MAX_VALIDATORS_PER_COMMITTEE
validators = [state.validators[i] for i in committee]

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Is this needed? This function could theoretically be used for different kinds of committees; doesn't seem wise to put a maximum designed around a specific type of committee.

@hwwhww hwwhww Aug 27, 2019

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

It's a safety check since the size of CompactCommittee elements are set to maximum MAX_VALIDATORS_PER_COMMITTEE:

class CompactCommittee(Container):
    pubkeys: List[BLSPubkey, MAX_VALIDATORS_PER_COMMITTEE]
    compact_validators: List[uint64, MAX_VALIDATORS_PER_COMMITTEE]

It leads to one more implicit config validity condition of that MAX_VALIDATORS_PER_COMMITTEE >= TARGET_PERSISTENT_COMMITTEE_SIZE. (p.s. #407)

If we want to make this function could be used for different kinds of committees, how about refactoring this function into:

def pack_committee(state: BeaconState, committee: Sequence[ValidatorIndex]) -> Tuple[Sequence[BLSPubkey], Sequence[int]]:
    validators = [state.validators[i] for i in committee]
    compact_validators = [
        pack_compact_validator(i, v.slashed, v.effective_balance // EFFECTIVE_BALANCE_INCREMENT)
        for i, v in zip(committee, validators)
    ]
    pubkeys = [v.pubkey for v in validators]
    return pubkeys, compact_validators


def committee_to_compact_committee(state: BeaconState, committee: Sequence[ValidatorIndex]) -> CompactCommittee:
    assert len(committee) <= MAX_VALIDATORS_PER_COMMITTEE
    pubkeys, compact_validators = pack_committee(state, committee)
    return CompactCommittee(pubkeys=pubkeys, compact_validators=compact_validators)

```python
class CompactCommittee(Container):
pubkeys: List[BLSPubkey, MAX_VALIDATORS_PER_COMMITTEE]
compact_validators: List[uint64, MAX_VALIDATORS_PER_COMMITTEE]

@hwwhww hwwhww Aug 25, 2019

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

What do you think about adding a custom type CompactValidator: uint64?

Edit: just realized that CompactValidator and unpack_compact_validator are defined in sync_protocol.md. I'd say:

  1. Remove unpack_compact_validator from 1_beacon-chain-misc.md since it's not used here.
  2. Move CompactValidator definition to 1_beacon-chain-misc.md.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Remove unpack_compact_validator from 1_beacon-chain-misc.md since it's not used here.

Where would it be put though? In the light client file that actually uses it? I can see how that's theoretically better in one way, but it has a big disadvantage, which is that pack and unpack are no longer beside each other. So I'd still favor putting both in the same file, to make it easier for readers to see that they are inverses.

Comment thread specs/core/1_beacon-chain-misc.md
vbuterin and others added 8 commits August 26, 2019 10:09
Co-Authored-By: John Adler <adlerjohn@users.noreply.github.com>
Co-Authored-By: John Adler <adlerjohn@users.noreply.github.com>
Co-Authored-By: John Adler <adlerjohn@users.noreply.github.com>
Co-Authored-By: Hsiao-Wei Wang <hwwang156@gmail.com>
@djrtwo

djrtwo commented Aug 28, 2019

Copy link
Copy Markdown
Contributor

@vbuterin Is this ready for merge?

@vbuterin

vbuterin commented Sep 1, 2019

Copy link
Copy Markdown
Contributor Author

@vbuterin Is this ready for merge?

I'd say so. My preference is generally to merge earlier for specs that are still in-progress; it makes it easier to propose further changes.

Justin's upcoming PR may force a change to the internals of receipt processing but it won't be large.

@JustinDrake

Copy link
Copy Markdown
Contributor

Justin's upcoming PR

The PR is ready for review :) #1383

@hwwhww hwwhww left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Giving a green light in case it's blocking #1383 review. (receipts)

class ShardReceiptProof(Container):
shard: Shard
proof: List[Hash, PLACEHOLDER]
receipt: List[ShardReceiptDelta, PLACEHOLDER]

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Looks like ShardReceiptDelta is going away in #1383. Should we define the ShardReceiptDelta container here?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Going to merge this and handle the conflict after reviewing #1383. Thanks for pointing this out :)

@djrtwo djrtwo merged commit 1449697 into dev Sep 2, 2019
@djrtwo djrtwo deleted the vbuterin-patch-13 branch September 2, 2019 16:02
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.

8 participants