Files
consensus-specs/tests/formats/light_client/sync.md
Etan Kissling 2e97af2627 Add ExecutionPayloadHeader to LC data
While the light client sync protocol currently provides access to the
latest `BeaconBlockHeader`, obtaining the matching execution data needs
workarounds such as downloading the full block.

Having ready access to the EL state root simplifies use cases that need
a way to cross-check `eth_getProof` responses against LC data.

Access to `block_hash` unlocks scenarios where a CL light client drives
an EL without `engine_newPayload`. As of Altair, only the CL beacon
block root is available, but the EL block hash is needed for engine API.

Other fields in the `ExecutionPayloadHeader` such as `logs_bloom` may
allow light client applications to monitor blocks for local interest,
e.g. for transfers affecting a certain wallet. This enables to download
only the few relevant blocks instead of every single one.

A new `LightClientStore` is proposed into the Capella spec that may be
used to sync LC data that includes execution data. Existing pre-Capella
LC data will remain as is, but can be locally upgraded before feeding it
into the new `LightClientStore` so that light clients do not need to run
a potentially expensive fork transition at a specific time. This enables
the `LightClientStore` to be upgraded at a use case dependent timing at
any time before Capella hits. Smart contract and embedded deployments
benefit from reduced code size and do not need synchronization with the
beacon chain clock to perform the Capella fork.
2022-12-12 00:48:40 +01:00

3.5 KiB

Light client sync tests

This series of tests provides reference test vectors for validating that a light client implementing the sync protocol can sync to the latest block header.

Test case format

meta.yaml

genesis_validators_root: Bytes32  -- string, hex encoded, with 0x prefix
trusted_block_root: Bytes32       -- string, hex encoded, with 0x prefix
bootstrap_fork_digest: string     -- Encoded `ForkDigest`-context of `bootstrap`
store_fork_digest: string         -- Encoded `ForkDigest`-context of `store` object being tested

bootstrap.ssz_snappy

An SSZ-snappy encoded bootstrap object of type LightClientBootstrap to initialize a local store object of type LightClientStore with store_fork_digest using initialize_light_client_store(trusted_block_rooot, bootstrap). The SSZ type can be determined from bootstrap_fork_digest.

If store_fork_digest differs from bootstrap_fork_digest, the bootstrap object may need upgrading before initializing the store.

steps.yaml

The steps to execute in sequence.

Checks to run after each step

Each step includes checks to verify the expected impact on the store object.

finalized_header: {
    slot: int,                -- Integer value from get_lc_beacon_slot(store.finalized_header)
    beacon_root: string,      -- Encoded 32-byte value from get_lc_beacon_root(store.finalized_header)
    execution_root: string,   -- From Capella onward; get_lc_execution_root(store.finalized_header)
}
optimistic_header: {
    slot: int,                -- Integer value from get_lc_beacon_slot(store.optimistic_header)
    beacon_root: string,      -- Encoded 32-byte value from get_lc_beacon_root(store.optimistic_header)
    execution_root: string,   -- From Capella onward; get_lc_execution_root(store.optimistic_header)
}

force_update execution step

The function process_light_client_store_force_update(store, current_slot) should be executed with the specified parameters:

{
    current_slot: int                  -- integer, decimal
    checks: {<store_attibute>: value}  -- the assertions.
}

After this step, the store object may have been updated.

process_update execution step

The function process_light_client_update(store, update, current_slot, genesis_validators_root) should be executed with the specified parameters:

{
    update_fork_digest: string         -- Encoded `ForkDigest`-context of `update`
    update: string                     -- name of the `*.ssz_snappy` file to load
                                          as a `LightClientUpdate` object
    current_slot: int                  -- integer, decimal
    checks: {<store_attibute>: value}  -- the assertions.
}

If store_fork_digest differs from update_fork_digest, the update object may need upgrading before initializing the store.

After this step, the store object may have been updated.

process_upgrade_store

The store should be upgraded to reflect the new store_fork_digest:

{
    store_fork_digest: string          -- Encoded `ForkDigest`-context of `store`
    checks: {<store_attibute>: value}  -- the assertions.
}

After this step, the store object may have been updated.

Condition

A test-runner should initialize a local LightClientStore using the provided bootstrap object. It should then proceed to execute all the test steps in sequence. After each step, it should verify that the resulting store verifies against the provided checks.