-
Notifications
You must be signed in to change notification settings - Fork 996
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
executable light client patch: beacon-chain.md #2141
Conversation
b5374b6
to
6ee73a1
Compare
Changelog
Now trying to fix the new error after rebasing:
I still could not reproduce a similar error case in writing /cc @protolambda do you have any hints of why this error happened? I tried to comment out |
@@ -165,30 +186,59 @@ def process_block(state: BeaconState, block: BeaconBlock) -> None: | |||
```python | |||
def process_sync_committee(state: BeaconState, block: BeaconBlock) -> None: | |||
# Verify sync committee aggregate signature signing over the previous slot block root | |||
previous_slot = Slot(max(state.slot, 1) - 1) | |||
previous_slot = Slot(max(int(state.slot), 1) - 1) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This line was previous_slot = max(state.slot, Slot(1)) - Slot(1)
earlier.
But since max
needs to compare the same type, either we cast to Slot
or cast to int
.
@hwwhww it looks like it was accessing a field in a container, recognized the wrong count of container fields (probably related to new extended types), |
# Reward sync committee participants | ||
participant_rewards = Gwei(0) | ||
proposer_reward = Gwei(0) | ||
active_validator_count = uint64(len(get_active_validator_indices(state, get_current_epoch(state)))) | ||
for participant_index in participant_indices: | ||
base_reward = get_base_reward(state, participant_index) | ||
reward = Gwei(base_reward * active_validator_count // len(committee_indices) // SLOTS_PER_EPOCH) | ||
max_participant_reward = base_reward - base_reward // PROPOSER_REWARD_QUOTIENT | ||
reward = Gwei(max_participant_reward * active_validator_count // len(committee_indices) // SLOTS_PER_EPOCH) | ||
increase_balance(state, participant_index, reward) | ||
participant_rewards += reward | ||
proposer_reward += base_reward // PROPOSER_REWARD_QUOTIENT | ||
|
||
# Reward beacon proposer | ||
increase_balance(state, get_beacon_proposer_index(state), Gwei(participant_rewards // PROPOSER_REWARD_QUOTIENT)) | ||
increase_balance(state, get_beacon_proposer_index(state), proposer_reward) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looked deeper into that navigation error: the state is backed by a tree that does not contain any nodes for TLDR: need to look at state initialization now, see if it properly builds a tree suitable for use in the lighthclient-patch. |
Update: in the |
Attempt to fix it: the test state preparation now runs a new function The Edit: tests run mostly now, but there are some tests that fail for regular reasons, very close to executable spec though, nice work! |
`process_block_header`
Thanks a lot for the help!!! That makes perfect sense. I'm okay with Still have some known issues that our tests didn't find, but finally see the green lights for all CI jobs! 🍏 |
epoch=epoch, | ||
), | ||
# History | ||
latest_block_header=pre.latest_block_header, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since sync_committee_bits
and sync_committee_signature
fields are added to block header instead of block body in 3b7c025, it would be more tricky to handle the SSZ objects at the fork boundary.
- The
latest_block_header
field here should be transformed fromphase0.BeaconBlockBody
tolightclient_patch.BeaconBlockBody
. - However, the next slot (the first slot after the light client patch) will have a problem when caching the
previous_block_root = hash_tree_root(state.latest_block_header)
inprocess_slot
function because the previous root should have been computed with phase 0 form at phase 0.
I think it makes more sense to have sync_committee_bits
and sync_committee_signature
in BeaconBlockBody
although they are not "operations".
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed in 2c86b43
|
||
- [Introduction](#introduction) | ||
- [Configuration](#configuration) | ||
- [Fork to Light-client patch](#fork-to-light-client-patch) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We write "light client" in three different ways 😂
- light client
- lightclient
- light-client
I guess we want to be consistent. (Small preference for "light client" on my side.)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 on "light client".
Once we have a better hard fork name, we can replace the folder name lightclient
with it.
We can scan it again after merging this PR to avoid conflicts.
1) Add a summary note for every function that is changed. 2) Avoid changing `process_block` (instead only change `process_block_header`). 3) Rename `G2_INFINITY_POINT_SIG` to `G2_POINT_AT_INFINITY` to avoid `SIG` contraction. 4) Misc cleanups
Co-authored-by: Marin Petrunić <[email protected]>
@vbuterin @djrtwo @JustinDrake @protolambda
This PR is ready to be merged into upstream #2130. |
Patch for #2130
This PR
optional_fast_aggregate_verify
f0864b8 /cc @JustinDrakeLIGHTCLIENT
fork totest/context.py
TODO in this PR:
LIGHTCLIENT
fork to another code name that is more like a "fork". DoesLIGHTCLIENT_PATCH
work? /cc @djrtwoTODOs in other PRs:
sync-protocol.md
for now. Let's make it executable with other PRs.