Skip to content

Commit

Permalink
Merge pull request #3209 from ethereum/dev
Browse files Browse the repository at this point in the history
release v1.3.0-rc.1
  • Loading branch information
hwwhww authored Jan 13, 2023
2 parents 5f1b88f + 496e1d8 commit 15eb331
Show file tree
Hide file tree
Showing 19 changed files with 345 additions and 173 deletions.
49 changes: 22 additions & 27 deletions .github/workflows/run-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ on:
- cron: '0 0 * * *'

jobs:
precleanup:
preclear:
runs-on: self-hosted
if: always()
steps:
Expand All @@ -40,60 +40,55 @@ jobs:
rm -rf ./* || true
rm -rf ./.??* || true
ls -la ./
setup-env:
runs-on: self-hosted
needs: precleanup
steps:
- name: Checkout this repo
uses: actions/checkout@v3.2.0
with:
ref: ${{ github.event.inputs.commitRef || env.DEFAULT_BRANCH }}
- uses: actions/cache@v3.2.2
id: cache-git
with:
path: ./*
key: ${{ github.sha }}
table_of_contents:
runs-on: self-hosted
needs: setup-env
needs: preclear
steps:
- uses: actions/cache@v3.2.2
id: restore-build
- name: Checkout this repo
uses: actions/checkout@v3.2.0
with:
path: ./*
key: ${{ github.sha }}
ref: ${{ github.event.inputs.commitRef || env.DEFAULT_BRANCH }}
- name: Check table of contents
run: sudo npm install -g doctoc@2 && make check_toc

codespell:
runs-on: self-hosted
needs: setup-env
needs: preclear
steps:
- name: Checkout this repo
uses: actions/checkout@v3.2.0
with:
ref: ${{ github.event.inputs.commitRef || env.DEFAULT_BRANCH }}
- name: Check codespell
run: pip install 'codespell<3.0.0,>=2.0.0' --user && make codespell

lint:
runs-on: self-hosted
needs: setup-env
needs: preclear
steps:
- name: Checkout this repo
uses: actions/checkout@v3.2.0
with:
ref: ${{ github.event.inputs.commitRef || env.DEFAULT_BRANCH }}
- name: Install pyspec requirements
run: make install_test
- name: Run linter for pyspec
run: make lint
- name: Run linter for test generators
run: make lint_generators

pyspec-tests:
runs-on: self-hosted
needs: [setup-env,lint,codespell,table_of_contents]
needs: [preclear,lint,codespell,table_of_contents]
strategy:
matrix:
version: ["phase0", "altair", "bellatrix", "capella", "eip4844"]
steps:
- uses: actions/cache@v3.2.2
id: restore-build
- name: Checkout this repo
uses: actions/checkout@v3.2.0
with:
path: ./*
key: ${{ github.sha }}
ref: ${{ github.event.inputs.commitRef || env.DEFAULT_BRANCH }}
- name: set TEST_PRESET_TYPE
if: github.event.inputs.test_preset_type != ''
run: |
Expand Down Expand Up @@ -122,7 +117,7 @@ jobs:

cleanup:
runs-on: self-hosted
needs: [setup-env,pyspec-tests,codespell,lint,table_of_contents]
needs: [preclear,pyspec-tests,codespell,lint,table_of_contents]
if: always()
steps:
- name: 'Cleanup build folder'
Expand Down
26 changes: 14 additions & 12 deletions specs/altair/light-client/full-node.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,15 @@ def compute_merkle_proof_for_state(state: BeaconState,
### `block_to_light_client_header`

```python
def block_to_light_client_header(block: SignedBeaconBlock) -> BeaconBlockHeader:
return BeaconBlockHeader(
slot=block.message.slot,
proposer_index=block.message.proposer_index,
parent_root=block.message.parent_root,
state_root=block.message.state_root,
body_root=hash_tree_root(block.message.body),
def block_to_light_client_header(block: SignedBeaconBlock) -> LightClientHeader:
return LightClientHeader(
beacon=BeaconBlockHeader(
slot=block.message.slot,
proposer_index=block.message.proposer_index,
parent_root=block.message.parent_root,
state_root=block.message.state_root,
body_root=hash_tree_root(block.message.body),
),
)
```

Expand Down Expand Up @@ -125,7 +127,7 @@ def create_light_client_update(state: BeaconState,
if finalized_block is not None:
if finalized_block.message.slot != GENESIS_SLOT:
update.finalized_header = block_to_light_client_header(finalized_block)
assert hash_tree_root(update.finalized_header) == attested_state.finalized_checkpoint.root
assert hash_tree_root(update.finalized_header.beacon) == attested_state.finalized_checkpoint.root
else:
assert attested_state.finalized_checkpoint.root == Bytes32()
update.finality_branch = compute_merkle_proof_for_state(
Expand All @@ -139,8 +141,8 @@ def create_light_client_update(state: BeaconState,

Full nodes SHOULD provide the best derivable `LightClientUpdate` (according to `is_better_update`) for each sync committee period covering any epochs in range `[max(ALTAIR_FORK_EPOCH, current_epoch - MIN_EPOCHS_FOR_BLOCK_REQUESTS), current_epoch]` where `current_epoch` is defined by the current wall-clock time. Full nodes MAY also provide `LightClientUpdate` for other sync committee periods.

- `LightClientUpdate` are assigned to sync committee periods based on their `attested_header.slot`
- `LightClientUpdate` are only considered if `compute_sync_committee_period_at_slot(update.attested_header.slot) == compute_sync_committee_period_at_slot(update.signature_slot)`
- `LightClientUpdate` are assigned to sync committee periods based on their `attested_header.beacon.slot`
- `LightClientUpdate` are only considered if `compute_sync_committee_period_at_slot(update.attested_header.beacon.slot) == compute_sync_committee_period_at_slot(update.signature_slot)`
- Only `LightClientUpdate` with `next_sync_committee` as selected by fork choice are provided, regardless of ranking by `is_better_update`. To uniquely identify a non-finalized sync committee fork, all of `period`, `current_sync_committee` and `next_sync_committee` need to be incorporated, as sync committees may reappear over time.

### `create_light_client_finality_update`
Expand All @@ -156,7 +158,7 @@ def create_light_client_finality_update(update: LightClientUpdate) -> LightClien
)
```

Full nodes SHOULD provide the `LightClientFinalityUpdate` with the highest `attested_header.slot` (if multiple, highest `signature_slot`) as selected by fork choice, and SHOULD support a push mechanism to deliver new `LightClientFinalityUpdate` whenever `finalized_header` changes.
Full nodes SHOULD provide the `LightClientFinalityUpdate` with the highest `attested_header.beacon.slot` (if multiple, highest `signature_slot`) as selected by fork choice, and SHOULD support a push mechanism to deliver new `LightClientFinalityUpdate` whenever `finalized_header` changes.

### `create_light_client_optimistic_update`

Expand All @@ -169,4 +171,4 @@ def create_light_client_optimistic_update(update: LightClientUpdate) -> LightCli
)
```

Full nodes SHOULD provide the `LightClientOptimisticUpdate` with the highest `attested_header.slot` (if multiple, highest `signature_slot`) as selected by fork choice, and SHOULD support a push mechanism to deliver new `LightClientOptimisticUpdate` whenever `attested_header` changes.
Full nodes SHOULD provide the `LightClientOptimisticUpdate` with the highest `attested_header.beacon.slot` (if multiple, highest `signature_slot`) as selected by fork choice, and SHOULD support a push mechanism to deliver new `LightClientOptimisticUpdate` whenever `attested_header` changes.
2 changes: 1 addition & 1 deletion specs/altair/light-client/light-client.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ This document explains how light clients MAY obtain light client data to sync wi
1. The light client MUST be configured out-of-band with a spec/preset (including fork schedule), with `genesis_state` (including `genesis_time` and `genesis_validators_root`), and with a trusted block root. The trusted block SHOULD be within the weak subjectivity period, and its root SHOULD be from a finalized `Checkpoint`.
2. The local clock is initialized based on the configured `genesis_time`, and the current fork digest is determined to browse for and connect to relevant light client data providers.
3. The light client fetches a [`LightClientBootstrap`](./sync-protocol.md#lightclientbootstrap) object for the configured trusted block root. The `bootstrap` object is passed to [`initialize_light_client_store`](./sync-protocol.md#initialize_light_client_store) to obtain a local [`LightClientStore`](./sync-protocol.md#lightclientstore).
4. The light client tracks the sync committee periods `finalized_period` from `store.finalized_header.slot`, `optimistic_period` from `store.optimistic_header.slot`, and `current_period` from `current_slot` based on the local clock.
4. The light client tracks the sync committee periods `finalized_period` from `store.finalized_header.beacon.slot`, `optimistic_period` from `store.optimistic_header.beacon.slot`, and `current_period` from `current_slot` based on the local clock.
1. When `finalized_period == optimistic_period` and [`is_next_sync_committee_known`](./sync-protocol.md#is_next_sync_committee_known) indicates `False`, the light client fetches a [`LightClientUpdate`](./sync-protocol.md#lightclientupdate) for `finalized_period`. If `finalized_period == current_period`, this fetch SHOULD be scheduled at a random time before `current_period` advances.
2. When `finalized_period + 1 < current_period`, the light client fetches a `LightClientUpdate` for each sync committee period in range `[finalized_period + 1, current_period)` (current period excluded)
3. When `finalized_period + 1 >= current_period`, the light client keeps observing [`LightClientFinalityUpdate`](./sync-protocol.md#lightclientfinalityupdate) and [`LightClientOptimisticUpdate`](./sync-protocol.md#lightclientoptimisticupdate). Received objects are passed to [`process_light_client_finality_update`](./sync-protocol.md#process_light_client_finality_update) and [`process_light_client_optimistic_update`](./sync-protocol.md#process_light_client_optimistic_update). This ensures that `finalized_header` and `optimistic_header` reflect the latest blocks.
Expand Down
Loading

0 comments on commit 15eb331

Please sign in to comment.