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

[Sharding] Fix unspecified SHARD_COUNT and DOMAIN_SHARD_HEADER constants #2367

Merged
merged 4 commits into from
May 4, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions specs/sharding/beacon-chain.md
Original file line number Diff line number Diff line change
Expand Up @@ -563,7 +563,7 @@ def process_shard_header(state: BeaconState,
# Verify proposer
assert header.proposer_index == get_shard_proposer_index(state, header.slot, header.shard)
# Verify signature
signing_root = compute_signing_root(header, get_domain(state, DOMAIN_SHARD_HEADER))
signing_root = compute_signing_root(header, get_domain(state, DOMAIN_SHARD_PROPOSER))
assert bls.Verify(state.validators[header.proposer_index].pubkey, signing_root, signed_header.signature)

# Verify the length by verifying the degree.
Expand Down Expand Up @@ -704,7 +704,7 @@ def process_pending_headers(state: BeaconState) -> None:
winning_index = [c.root for c in candidates].index(Root())
candidates[winning_index].confirmed = True
for slot_index in range(SLOTS_PER_EPOCH):
for shard in range(SHARD_COUNT):
for shard in range(MAX_SHARDS):
state.grandparent_epoch_confirmed_commitments[shard][slot_index] = DataCommitment()
confirmed_headers = [candidate for candidate in state.previous_epoch_pending_shard_headers if candidate.confirmed]
for header in confirmed_headers:
Expand All @@ -718,9 +718,10 @@ def charge_confirmed_header_fees(state: BeaconState) -> None:
get_active_shard_count(state, get_current_epoch(state))
* SLOTS_PER_EPOCH * GASPRICE_ADJUSTMENT_COEFFICIENT
)
previous_epoch_start_slot = compute_start_slot_at_epoch(get_previous_epoch(state))
previous_epoch = get_previous_epoch(state)
previous_epoch_start_slot = compute_start_slot_at_epoch(previous_epoch)
Copy link
Contributor

Choose a reason for hiding this comment

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

Good fix, but this reminds me we should limit some of these methods to epoch 1+, epoch 0 doesn't work quite as expected. The previous epoch var would be clipped to 0, and then it tries to confirm current-epoch shard headers.

for slot in range(previous_epoch_start_slot, previous_epoch_start_slot + SLOTS_PER_EPOCH):
for shard_index in range(SHARD_COUNT):
for shard_index in range(get_active_shard_count(state, previous_epoch)):
shard = Shard(shard_index)
confirmed_candidates = [
c for c in state.previous_epoch_pending_shard_headers
Expand Down