2022-05-03 01:17:46 +02:00
# 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`
```yaml
genesis_validators_root: Bytes32 -- string, hex encoded, with 0x prefix
trusted_block_root: Bytes32 -- string, hex encoded, with 0x prefix
2022-12-12 00:43:07 +01:00
bootstrap_fork_digest: string -- Encoded `ForkDigest` -context of `bootstrap`
store_fork_digest: string -- Encoded `ForkDigest` -context of `store` object being tested
2022-05-03 01:17:46 +02:00
```
### `bootstrap.ssz_snappy`
2022-12-12 00:43:07 +01:00
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` .
2023-01-12 19:01:57 +01:00
If `store_fork_digest` differs from `bootstrap_fork_digest` , the `bootstrap` object may need to be upgraded before initializing the store.
2022-05-03 01:17:46 +02:00
### `steps.yaml`
2022-07-15 13:13:33 +02:00
The steps to execute in sequence.
2022-07-15 13:45:34 +02:00
#### Checks to run after each step
2022-07-15 13:13:33 +02:00
Each step includes checks to verify the expected impact on the `store` object.
```yaml
finalized_header: {
2023-01-05 13:36:04 +01:00
slot: int, -- Integer value from store.finalized_header.beacon.slot
beacon_root: string, -- Encoded 32-byte value from store.finalized_header.beacon.hash_tree_root()
2022-12-12 00:43:07 +01:00
execution_root: string, -- From Capella onward; get_lc_execution_root(store.finalized_header)
2022-07-15 13:13:33 +02:00
}
optimistic_header: {
2023-01-05 13:36:04 +01:00
slot: int, -- Integer value from store.optimistic_header.beacon.slot
beacon_root: string, -- Encoded 32-byte value from store.optimistic_header.beacon.hash_tree_root()
2022-12-12 00:43:07 +01:00
execution_root: string, -- From Capella onward; get_lc_execution_root(store.optimistic_header)
2022-07-15 13:13:33 +02:00
}
```
2022-05-03 01:17:46 +02:00
2022-05-03 12:31:26 +02:00
#### `force_update` execution step
2022-05-03 01:17:46 +02:00
2022-07-22 11:49:07 +02:00
The function `process_light_client_store_force_update(store, current_slot)`
2022-05-03 01:17:46 +02:00
should be executed with the specified parameters:
```yaml
{
2022-07-15 13:13:33 +02:00
current_slot: int -- integer, decimal
checks: {< store_attibute > : value} -- the assertions.
2022-05-03 01:17:46 +02:00
}
```
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:
```yaml
{
2022-12-12 00:43:07 +01:00
update_fork_digest: string -- Encoded `ForkDigest` -context of `update`
2022-07-15 13:13:33 +02:00
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.
2022-05-03 01:17:46 +02:00
}
```
2023-01-12 19:01:57 +01:00
If `store_fork_digest` differs from `update_fork_digest` , the `update` object may need to be upgraded before processing the update.
2022-12-12 00:43:07 +01:00
2022-05-03 01:17:46 +02:00
After this step, the `store` object may have been updated.
2023-01-14 14:51:59 +01:00
#### `upgrade_store`
2022-12-12 00:43:07 +01:00
The `store` should be upgraded to reflect the new `store_fork_digest` :
```yaml
{
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.
2022-05-03 01:17:46 +02:00
## Condition
2022-07-15 13:13:33 +02:00
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` .