42 Commits

Author SHA1 Message Date
Etan Kissling
35f5010de7
More concise finality ranking
Co-authored-by: Hsiao-Wei Wang <hsiaowei.eth@gmail.com>
2022-07-08 22:01:56 -07:00
Etan Kissling
aa8caee2e3
Add compute_sync_committee_period_at_slot 2022-07-08 21:59:09 -07:00
Etan Kissling
c67ad597f0
Reorder helpers to group ones operating on updates 2022-07-08 21:46:34 -07:00
Etan Kissling
c4dbd241ac
Root next_sync_committee in attested_header
`LightClientUpdate` structures currently use different merkle proof root
depending on the presence of `finalized_header`. By always rooting it in
the same state (the `attested_header.state_root`), logic gets simpler.

Caveats:
- In periods of extended non-finality, `update.finalized_header` may now
  be outdated by several sync committee periods. The old implementation
  rejected such updates as the `next_sync_committee` in them was stale,
  but the new implementation can properly handle this case.
- The `next_sync_committee` can no longer be considered finalized based
  on `is_finality_update`. Instead, waiting until `finalized_header` is
  in the `attested_header`'s sync committee period is now necessary.
- Because `update.finalized_header > store.finalized_header` no longer
  holds (for updates with finality), an `is_better_update` helper is
  added to improve `best_valid_update` tracking (in the past, finalized
  updates with supermajority participation would always directly apply)

This PR builds on prior work from:
- @hwwhww at https://github.com/ethereum/consensus-specs/pull/2829
2022-07-01 14:49:24 -07:00
Etan Kissling
f5f3031c5e
Allow passing redundant next_sync_committee
The producer of `LightClientUpdate` structures usually does not know how
far the `LightClientStore` on the client side has advanced. Updates are
currently rejected when including a redundant `next_sync_committee` not
advancing the `LightClientStore`. Behaviour is changed to allow this.
2022-06-29 13:16:03 +02:00
Etan Kissling
65cfedef22
Update finality update documentation 2022-06-27 22:36:55 +02:00
Etan Kissling
99e30328a8
Switch condition order for readability
Co-authored-by: Hsiao-Wei Wang <hsiaowei.eth@gmail.com>
2022-06-27 22:26:35 +02:00
Etan Kissling
c10daf1709
Allow LightClientUpdate with genesis finality
When `state.finalized_checkpoint` references the genesis slot, it points
to an empty `root`, instead of the actual genesis block hash. This patch
updates the `LightClientUpdate` logic to allow including finality proofs
for genesis `finalized_checkpoint.root`, better supporting non-mainnet.
When including such a finality proof, the proof is for the empty `root`,
but `finalized_header` is kept zeroed out to signify this edge case.
2022-06-27 12:10:40 +02:00
Etan Kissling
0b8ab23bd4
Remove fork_version from LightClientUpdate
The `fork_version` field in `LightClientUpdate` can be derived from the
`update.signature_slot` value by consulting the locally configured fork
schedule. The light client already needs access to the fork schedule to
determine the `GeneralizedIndex` values used for merkle proofs, and the
memory layouts of the structures (including `LightClientUpdate`). The
`fork_version` itself is network dependent and doesn't reveal that info.
2022-06-16 17:17:24 +02:00
Etan Kissling
5653649ca8
Allow light client to verify signatures at period boundary
As the sync committee signs the previous block, the situation arises at
every sync committee period boundary, that the new sync committee signs
a block in the previous sync committee period. The light client cannot
reliably detect this condition (e.g., assume that this is the case when
it is currently on the last slot of a sync committee period), because
the last couple slots of a sync committee period may not have a block.

For example, when receiving a `LightClientUpdate` that is constructed
as in the following illustration, it is unknown whether `sync_aggregate`
was signed by the current or next sync committee at `attested_header`.

```

        slot N           N + 1   |            N + 2   (slot not sent!)
                                 |
  +-----------------+     \ /    |     +----------------+
  | attested_header | <--- X ----|---- | sync_aggregate |
  +-----------------+     / \    |     +----------------+
                        missed   |
                                 |
                          sync committee
                          period boundary
```

This patch addresses this edge case by including the slot at which the
`sync_aggregate` was created into the `LightClientUpdate` object.

Note that the `signature_slot` cannot be trusted beyond the purpose of
signature verification, as it could be manipulated to any other slot
within the same sync committee period and fork version, without making
the `sync_aggregate` invalid.
2022-05-02 13:08:20 +02:00
Aditya Asgaonkar
1e10e7dc1c Fix UPDATE_TIMEOUT unit typo 2022-03-03 20:16:32 -08:00
Hsiao-Wei Wang
6d11d627f8 Refactoring: add is_finality_update helper 2022-02-09 18:13:51 -07:00
Danny Ryan
5a09b5f8a8
Merge pull request #2814 from etan-status/lc-opt-fin
Ensure light client `optimistic_header` to be at head
2022-02-09 10:06:57 -07:00
Etan Kissling
0e9460b8dd
Ensure light client optimistic_header to be at head
When a light client updates its `finalized_header` using a forced update
because of the timeout, and the new header was not signed by enough sync
committee participants to pass `get_safety_threshold(store)`, it may
occur that `store.finalized_header.slot > store.optimistic_header.slot`.
This patch ensures that the `optimistic_header` is updated to the latest
`finalized_header` if that happens, so that it always indicates the
latest known and accepted head.
2022-01-25 10:09:10 +01:00
Etan Kissling
8319d07084
Consistently use compute_sync_committee_period
There were a couple instances where a division was used on an epoch
to derive the corresponding sync committee period instead of calling the
`compute_sync_committee_period` function.
These instances were changed to also use the function.
2022-01-17 17:38:24 +01:00
Hsiao-Wei Wang
16c350ebcd
Merge pull request #2796 from etan-status/lc-aggregate
Rename `sync_committee_aggregate` > `sync_aggregate`
2022-01-13 21:07:50 +08:00
Danny Ryan
7b435bd470
Merge pull request #2797 from etan-status/lc-update-doc
Fix light client docs to match function signature
2022-01-11 06:57:19 -07:00
Etan Kissling
79c456b9f4
Fix light client docs to match function signature
In the light client docs a mentioning of a function trigger is lacking
the `genesis_validators_root` argument. This patch adds that argument
to the documentation to match the real function signature. It also
slightly improves the grammar.
2022-01-11 12:10:30 +01:00
Etan Kissling
212eb00fc1
Document light client constants
This adds documentation about the unit and actual value of light client
specific constants, consistently with the rest of the spec.
2022-01-11 12:10:09 +01:00
Etan Kissling
48e19b15ae
Rename sync_committee_aggregate > sync_aggregate
This renames the `sync_committee_aggregate` field of `LightClientUpdate`
to `sync_aggregate` for consistency with the terminology in the rest of
the spec.
2022-01-11 11:22:39 +01:00
Hsiao-Wei Wang
de892382db
Minor style fixes 2021-12-15 23:44:29 +08:00
Hsiao-Wei Wang
25d88fee24
Fix process_light_client_update 2021-12-14 22:05:09 +08:00
Hsiao-Wei Wang
2f618f7b48
Fix lint and presets 2021-12-14 21:38:58 +08:00
vbuterin
916193bd69
Updates in response to comments 2021-12-10 07:48:14 -06:00
Hsiao-Wei Wang
402c663b51
Fix function name leftover 2021-11-30 21:57:43 +08:00
vbuterin
c30662b696
Consistently use sum instead of count(1) 2021-11-30 06:39:25 -06:00
Hsiao-Wei Wang
7de1495a42
Fix lint (#2750) 2021-11-30 06:38:42 -06:00
vbuterin
6fa19705fb
Clarified next sync committee comment 2021-11-29 07:05:01 -06:00
vbuterin
06af6296c5
Updated in response to comments 2021-11-29 07:04:05 -06:00
vbuterin
c4f70970c4
Update specs/altair/sync-protocol.md
Co-authored-by: terence tsao <terence@prysmaticlabs.com>
2021-11-28 08:31:48 -06:00
vbuterin
77188726de
Fixed ToC and get_active_header positioninf 2021-11-27 07:27:16 -06:00
vbuterin
e104164960
Rework data structures (#2747)
1. Replace `header` and `finality_header` with `attested_header` (always the header signed by the committee) and `finailzed_header` (always the header verified by the Merkle branch)
2. Remove `LightClientSnapshot`, fold its fields into `LightClientStore` for simplicity
2021-11-27 07:25:27 -06:00
vbuterin
013e814d2d
Update sync-protocol.md 2021-11-26 15:32:37 -06:00
vbuterin
25f2efab19
Simplify sync protocol and update to calculate optimistic heads
1. Simplify `valid_updates` to `best_valid_update` so the `LightClientStore` only needs to store O(1) data
2. Track an optimistic head, by looking for the highest-slot header which passes a safety threshold
2021-11-26 15:11:19 -06:00
Danny Ryan
4c1156d504
rename eth1 and eth2 throughout specs and readme where reasonable 2021-08-18 17:13:24 -06:00
protolambda
7689ebb2bd
Altair constant/preset/config separation 2021-05-18 09:28:09 +02:00
Alex Stokes
4c73fec88e
convert LightClientStore to python object instead of SSZ object
this avoids the type overhead of having to define a max size for
the object's data and skips the overhead of serialization/consensus
for a type that does not need it
2021-05-06 10:52:48 -07:00
Alex Stokes
3b80324119
Compute LIGHT_CLIENT_UPDATE_TIMEOUT in lieu of maintaining a constant 2021-05-04 13:47:46 -07:00
Alex Stokes
7a168be862
allow fault tolerance equal to threshold, not just above 2021-05-04 13:25:34 -07:00
Danny Ryan
053179cee9
comments and tests on altair 2021-05-04 07:39:22 -06:00
Hsiao-Wei Wang
c34eae33d0
Merge branch 'dev' into lightclient-sync-exe 2021-03-12 00:49:29 +08:00
Hsiao-Wei Wang
69489d1541
Rename folders and file names to altair 2021-03-11 21:12:46 +08:00