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

Use fork choice to determine finalized_checkpoint in gossip validation #3543

Merged
merged 1 commit into from
Jan 16, 2024

Conversation

etan-status
Copy link
Contributor

Update gossip validation rules to use the highest finalized_checkpoint across all branches (store.finalized_checkpoint), instead of the one on the currently selected branch (state.finalized_checkpoint) when deciding whether to ignore a block / blob because they are already finalized.

Update gossip validation rules to use the highest `finalized_checkpoint`
across _all_ branches (`store.finalized_checkpoint`), instead of the one
on the currently selected branch (`state.finalized_checkpoint`) when
deciding whether to ignore a block / blob because they are already
finalized.
Comment on lines -694 to +696
- `finalized_root`: `state.finalized_checkpoint.root` for the state corresponding to the head block
- `finalized_root`: `store.finalized_checkpoint.root` according to [fork choice](./fork-choice.md).
(Note this defaults to `Root(b'\x00' * 32)` for the genesis finalized checkpoint).
- `finalized_epoch`: `state.finalized_checkpoint.epoch` for the state corresponding to the head block.
- `finalized_epoch`: `store.finalized_checkpoint.epoch` according to [fork choice](./fork-choice.md).
Copy link
Contributor Author

Choose a reason for hiding this comment

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

These are for the libp2p Status message

i.e. validate that `signed_beacon_block.message.slot > compute_start_slot_at_epoch(state.finalized_checkpoint.epoch)`
i.e. validate that `signed_beacon_block.message.slot > compute_start_slot_at_epoch(store.finalized_checkpoint.epoch)`
Copy link
Contributor Author

Choose a reason for hiding this comment

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

blocks gossip

- _[IGNORE]_ The sidecar is from a slot greater than the latest finalized slot -- i.e. validate that `block_header.slot > compute_start_slot_at_epoch(state.finalized_checkpoint.epoch)`
- _[IGNORE]_ The sidecar is from a slot greater than the latest finalized slot -- i.e. validate that `block_header.slot > compute_start_slot_at_epoch(store.finalized_checkpoint.epoch)`
Copy link
Contributor Author

Choose a reason for hiding this comment

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

blobs gossip

Copy link
Collaborator

@dapplion dapplion left a comment

Choose a reason for hiding this comment

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

Lodestar determines finality for gossip validation from the fork-choice store since genesis

Copy link
Member

@ppopth ppopth left a comment

Choose a reason for hiding this comment

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

I'm not an expert on this, but using the fork-choice store looks cleaner (even though it may not be different assuming that 2/3 of validators are honest). So this LGTM.

@arnetheduck
Copy link
Contributor

even though it may not be different

notably, it doesn't move backwards when you reorg

Copy link
Collaborator

@mkalinin mkalinin left a comment

Choose a reason for hiding this comment

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

Makes sense to me 👍

@hwwhww hwwhww mentioned this pull request Jan 15, 2024
8 tasks
Copy link
Contributor

@djrtwo djrtwo left a comment

Choose a reason for hiding this comment

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

This is certainly the intention of the spec since genesis. With state being poorly defined, definitely see how this was incorrect as is

@@ -691,9 +691,9 @@ The fields are, as seen by the client at the time of sending the message:
- `current_fork_version` is the fork version at the node's current epoch defined by the wall-clock time
(not necessarily the epoch to which the node is sync)
- `genesis_validators_root` is the static `Root` found in `state.genesis_validators_root`
- `finalized_root`: `state.finalized_checkpoint.root` for the state corresponding to the head block
- `finalized_root`: `store.finalized_checkpoint.root` according to [fork choice](./fork-choice.md).
Copy link
Contributor

Choose a reason for hiding this comment

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

This is a no-op, right? The state here is implicitly your head which is going to share the store's finalized checkpoint by definition

Copy link
Contributor Author

Choose a reason for hiding this comment

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

no, there may be a reorg that unrealizes finality in state that was already realized on a different branch - store.finalized_checkpoint tracks the highest finality across all branches, while state just tracks the one from the branch currently selected by fork choice (which may be lower).

@djrtwo djrtwo merged commit a35d783 into ethereum:dev Jan 16, 2024
13 checks passed
@etan-status etan-status deleted the gv-finstore branch January 17, 2024 12:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants