Skip to content

Commit

Permalink
rename EIP4844 > Deneb for light client (#4713)
Browse files Browse the repository at this point in the history
* rename `EIP4844` > `Deneb` for light client

* regenerate test logs
  • Loading branch information
etan-status authored Mar 10, 2023
1 parent 8fd3723 commit 57b2151
Show file tree
Hide file tree
Showing 10 changed files with 126 additions and 128 deletions.
2 changes: 1 addition & 1 deletion ConsensusSpecPreset-mainnet.md
Original file line number Diff line number Diff line change
Expand Up @@ -2034,7 +2034,7 @@ OK: 1/1 Fail: 0/1 Skip: 0/1
+ Testing Withdrawal OK
```
OK: 49/49 Fail: 0/49 Skip: 0/49
## EF - EIP4844 - Unittests - Light client - Sync protocol [Preset: mainnet]
## EF - Deneb - Unittests - Light client - Sync protocol [Preset: mainnet]
```diff
+ process_light_client_update_finality_updated OK
+ process_light_client_update_timeout OK
Expand Down
2 changes: 1 addition & 1 deletion ConsensusSpecPreset-minimal.md
Original file line number Diff line number Diff line change
Expand Up @@ -2210,7 +2210,7 @@ OK: 5/5 Fail: 0/5 Skip: 0/5
+ Testing Withdrawal OK
```
OK: 49/49 Fail: 0/49 Skip: 0/49
## EF - EIP4844 - Unittests - Light client - Sync protocol [Preset: minimal]
## EF - Deneb - Unittests - Light client - Sync protocol [Preset: minimal]
```diff
+ process_light_client_update_finality_updated OK
+ process_light_client_update_timeout OK
Expand Down
7 changes: 3 additions & 4 deletions beacon_chain/beacon_chain_db.nim
Original file line number Diff line number Diff line change
Expand Up @@ -531,18 +531,17 @@ proc new*(T: type BeaconChainDB,
"lc_capella_headers"
else:
"",
eip4844Headers:
denebHeaders:
if cfg.DENEB_FORK_EPOCH != FAR_FUTURE_EPOCH:
# TODO: We should probably rename this to match the official fork name
"lc_eip4844_headers"
"lc_deneb_headers"
else:
"",
altairCurrentBranches: "lc_altair_current_branches",
altairSyncCommittees: "lc_altair_sync_committees",
legacyAltairBestUpdates: "lc_altair_best_updates",
bestUpdates: "lc_best_updates",
sealedPeriods: "lc_sealed_periods")).expectDb()
static: doAssert LightClientDataFork.high == LightClientDataFork.EIP4844
static: doAssert LightClientDataFork.high == LightClientDataFork.Deneb

var blobs : KvStoreRef
if cfg.DENEB_FORK_EPOCH != FAR_FUTURE_EPOCH:
Expand Down
16 changes: 8 additions & 8 deletions beacon_chain/beacon_chain_db_light_client.nim
Original file line number Diff line number Diff line change
Expand Up @@ -27,22 +27,22 @@ logScope: topics = "lcdata"
# Mainnet data size (all columns):
# - Altair: ~38 KB per `SyncCommitteePeriod` (~1.0 MB per month)
# - Capella: ~222 KB per `SyncCommitteePeriod` (~6.1 MB per month)
# - EIP4844: ~230 KB per `SyncCommitteePeriod` (~6.3 MB per month)
# - Deneb: ~230 KB per `SyncCommitteePeriod` (~6.3 MB per month)
#
# `lc_altair_current_branches` holds merkle proofs needed to
# construct `LightClientBootstrap` objects.
# SSZ because this data does not compress well, and because this data
# needs to be bundled together with other data to fulfill requests.
# Mainnet data size (all columns):
# - Altair ... EIP4844: ~42 KB per `SyncCommitteePeriod` (~1.1 MB per month)
# - Altair ... Deneb: ~42 KB per `SyncCommitteePeriod` (~1.1 MB per month)
#
# `lc_altair_sync_committees` contains a copy of finalized sync committees.
# They are initially populated from the main DAG (usually a fast state access).
# Caching is necessary to support longer retention for LC data than state data.
# SSZ because this data does not compress well, and because this data
# needs to be bundled together with other data to fulfill requests.
# Mainnet data size (all columns):
# - Altair ... EIP4844: ~32 KB per `SyncCommitteePeriod` (~0.9 MB per month)
# - Altair ... Deneb: ~32 KB per `SyncCommitteePeriod` (~0.9 MB per month)
#
# `lc_best_updates` holds full `LightClientUpdate` objects in SSZ form.
# These objects are frequently queried in bulk, but there is only one per
Expand All @@ -58,7 +58,7 @@ logScope: topics = "lcdata"
# Mainnet data size (all columns):
# - Altair: ~33 KB per `SyncCommitteePeriod` (~0.9 MB per month)
# - Capella: ~34 KB per `SyncCommitteePeriod` (~0.9 MB per month)
# - EIP4844: ~34 KB per `SyncCommitteePeriod` (~0.9 MB per month)
# - Deneb: ~34 KB per `SyncCommitteePeriod` (~0.9 MB per month)
#
# `lc_sealed_periods` contains the sync committee periods for which
# full light client data was imported. Data for these periods may no longer
Expand Down Expand Up @@ -675,7 +675,7 @@ func keepPeriodsFrom*(
type LightClientDataDBNames* = object
altairHeaders*: string
capellaHeaders*: string
eip4844Headers*: string
denebHeaders*: string
altairCurrentBranches*: string
altairSyncCommittees*: string
legacyAltairBestUpdates*: string
Expand All @@ -685,7 +685,7 @@ type LightClientDataDBNames* = object
proc initLightClientDataDB*(
backend: SqStoreRef,
names: LightClientDataDBNames): KvResult[LightClientDataDB] =
static: doAssert LightClientDataFork.high == LightClientDataFork.EIP4844
static: doAssert LightClientDataFork.high == LightClientDataFork.Deneb
let
headers = [
# LightClientDataFork.None
Expand All @@ -696,9 +696,9 @@ proc initLightClientDataDB*(
# LightClientDataFork.Capella
? backend.initHeadersStore(
names.capellaHeaders, "capella.LightClientHeader"),
# LightClientDataFork.EIP4844
# LightClientDataFork.Deneb
? backend.initHeadersStore(
names.eip4844Headers, "eip4844.LightClientHeader")
names.denebHeaders, "deneb.LightClientHeader")
]
currentBranches =
? backend.initCurrentBranchesStore(names.altairCurrentBranches)
Expand Down
2 changes: 1 addition & 1 deletion beacon_chain/light_client.nim
Original file line number Diff line number Diff line change
Expand Up @@ -347,7 +347,7 @@ proc installMessageValidators*(
withLcDataFork(lcDataForkAtStateFork(stateFork)):
when lcDataFork > LightClientDataFork.None:
let
contextFork = stateFork # Copy to avoid capturing `EIP4844` (Nim 1.6)
contextFork = stateFork # Copy to avoid capturing `Deneb` (Nim 1.6)
digest = forkDigests[].atStateFork(contextFork)

lightClient.network.addValidator(
Expand Down
47 changes: 23 additions & 24 deletions beacon_chain/spec/datatypes/deneb.nim
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,6 @@ type
kzgs*: KZGCommitments
blobs*: Blobs

# https://github.com/ethereum/consensus-specs/blob/v1.3.0-rc.2/specs/eip4844/beacon-chain.md#executionpayloadheader
# https://github.com/ethereum/consensus-specs/blob/v1.3.0-rc.3/specs/deneb/beacon-chain.md#executionpayloadheader
ExecutionPayloadHeader* = object
parent_hash*: Eth2Digest
Expand Down Expand Up @@ -552,7 +551,7 @@ func shortLog*(v: ExecutionPayload): auto =
num_withdrawals: len(v.withdrawals)
)

# https://github.com/ethereum/consensus-specs/blob/v1.3.0-rc.1/specs/eip4844/light-client/sync-protocol.md#get_lc_execution_root
# https://github.com/ethereum/consensus-specs/blob/v1.3.0-rc.3/specs/deneb/light-client/sync-protocol.md#modified-get_lc_execution_root
func get_lc_execution_root*(
header: LightClientHeader, cfg: RuntimeConfig): Eth2Digest =
let epoch = header.beacon.slot.epoch
Expand Down Expand Up @@ -581,7 +580,7 @@ func get_lc_execution_root*(

ZERO_HASH

# https://github.com/ethereum/consensus-specs/blob/v1.3.0-rc.1/specs/eip4844/light-client/sync-protocol.md#is_valid_light_client_header
# https://github.com/ethereum/consensus-specs/blob/v1.3.0-rc.3/specs/deneb/light-client/sync-protocol.md#modified-is_valid_light_client_header
func is_valid_light_client_header*(
header: LightClientHeader, cfg: RuntimeConfig): bool =
let epoch = header.beacon.slot.epoch
Expand All @@ -602,8 +601,8 @@ func is_valid_light_client_header*(
get_subtree_index(EXECUTION_PAYLOAD_INDEX),
header.beacon.body_root)

# https://github.com/ethereum/consensus-specs/blob/v1.3.0-rc.1/specs/eip4844/light-client/fork.md#upgrade_lc_header_to_eip4844
func upgrade_lc_header_to_eip4844*(
# https://github.com/ethereum/consensus-specs/blob/v1.3.0-rc.3/specs/deneb/light-client/fork.md#upgrading-light-client-data
func upgrade_lc_header_to_deneb*(
pre: capella.LightClientHeader): LightClientHeader =
LightClientHeader(
beacon: pre.beacon,
Expand All @@ -625,41 +624,41 @@ func upgrade_lc_header_to_eip4844*(
withdrawals_root: pre.execution.withdrawals_root),
execution_branch: pre.execution_branch)

# https://github.com/ethereum/consensus-specs/blob/v1.3.0-rc.1/specs/eip4844/light-client/fork.md#upgrade_lc_bootstrap_to_eip4844
func upgrade_lc_bootstrap_to_eip4844*(
# https://github.com/ethereum/consensus-specs/blob/v1.3.0-rc.3/specs/deneb/light-client/fork.md#upgrading-light-client-data
func upgrade_lc_bootstrap_to_deneb*(
pre: capella.LightClientBootstrap): LightClientBootstrap =
LightClientBootstrap(
header: upgrade_lc_header_to_eip4844(pre.header),
header: upgrade_lc_header_to_deneb(pre.header),
current_sync_committee: pre.current_sync_committee,
current_sync_committee_branch: pre.current_sync_committee_branch)

# https://github.com/ethereum/consensus-specs/blob/v1.3.0-rc.1/specs/eip4844/light-client/fork.md#upgrade_lc_update_to_eip4844
func upgrade_lc_update_to_eip4844*(
# https://github.com/ethereum/consensus-specs/blob/v1.3.0-rc.3/specs/deneb/light-client/fork.md#upgrading-light-client-data
func upgrade_lc_update_to_deneb*(
pre: capella.LightClientUpdate): LightClientUpdate =
LightClientUpdate(
attested_header: upgrade_lc_header_to_eip4844(pre.attested_header),
attested_header: upgrade_lc_header_to_deneb(pre.attested_header),
next_sync_committee: pre.next_sync_committee,
next_sync_committee_branch: pre.next_sync_committee_branch,
finalized_header: upgrade_lc_header_to_eip4844(pre.finalized_header),
finalized_header: upgrade_lc_header_to_deneb(pre.finalized_header),
finality_branch: pre.finality_branch,
sync_aggregate: pre.sync_aggregate,
signature_slot: pre.signature_slot)

# https://github.com/ethereum/consensus-specs/blob/v1.3.0-rc.1/specs/eip4844/light-client/fork.md#upgrade_lc_finality_update_to_eip4844
func upgrade_lc_finality_update_to_eip4844*(
# https://github.com/ethereum/consensus-specs/blob/v1.3.0-rc.3/specs/deneb/light-client/fork.md#upgrading-light-client-data
func upgrade_lc_finality_update_to_deneb*(
pre: capella.LightClientFinalityUpdate): LightClientFinalityUpdate =
LightClientFinalityUpdate(
attested_header: upgrade_lc_header_to_eip4844(pre.attested_header),
finalized_header: upgrade_lc_header_to_eip4844(pre.finalized_header),
attested_header: upgrade_lc_header_to_deneb(pre.attested_header),
finalized_header: upgrade_lc_header_to_deneb(pre.finalized_header),
finality_branch: pre.finality_branch,
sync_aggregate: pre.sync_aggregate,
signature_slot: pre.signature_slot)

# https://github.com/ethereum/consensus-specs/blob/v1.3.0-rc.1/specs/eip4844/light-client/fork.md#upgrade_lc_optimistic_update_to_eip4844
func upgrade_lc_optimistic_update_to_eip4844*(
# https://github.com/ethereum/consensus-specs/blob/v1.3.0-rc.3/specs/deneb/light-client/fork.md#upgrading-light-client-data
func upgrade_lc_optimistic_update_to_deneb*(
pre: capella.LightClientOptimisticUpdate): LightClientOptimisticUpdate =
LightClientOptimisticUpdate(
attested_header: upgrade_lc_header_to_eip4844(pre.attested_header),
attested_header: upgrade_lc_header_to_deneb(pre.attested_header),
sync_aggregate: pre.sync_aggregate,
signature_slot: pre.signature_slot)

Expand Down Expand Up @@ -706,20 +705,20 @@ chronicles.formatIt LightClientUpdate: shortLog(it)
chronicles.formatIt LightClientFinalityUpdate: shortLog(it)
chronicles.formatIt LightClientOptimisticUpdate: shortLog(it)

# https://github.com/ethereum/consensus-specs/blob/v1.3.0-rc.1/specs/eip4844/light-client/fork.md#upgrade_lc_store_to_eip4844
func upgrade_lc_store_to_eip4844*(
# https://github.com/ethereum/consensus-specs/blob/v1.3.0-rc.3/specs/deneb/light-client/fork.md#upgrading-the-store
func upgrade_lc_store_to_deneb*(
pre: capella.LightClientStore): LightClientStore =
let best_valid_update =
if pre.best_valid_update.isNone:
Opt.none(LightClientUpdate)
else:
Opt.some upgrade_lc_update_to_eip4844(pre.best_valid_update.get)
Opt.some upgrade_lc_update_to_deneb(pre.best_valid_update.get)
LightClientStore(
finalized_header: upgrade_lc_header_to_eip4844(pre.finalized_header),
finalized_header: upgrade_lc_header_to_deneb(pre.finalized_header),
current_sync_committee: pre.current_sync_committee,
next_sync_committee: pre.next_sync_committee,
best_valid_update: best_valid_update,
optimistic_header: upgrade_lc_header_to_eip4844(pre.optimistic_header),
optimistic_header: upgrade_lc_header_to_deneb(pre.optimistic_header),
previous_max_active_participants: pre.previous_max_active_participants,
current_max_active_participants: pre.current_max_active_participants)

Expand Down
4 changes: 2 additions & 2 deletions beacon_chain/spec/forks.nim
Original file line number Diff line number Diff line change
Expand Up @@ -904,9 +904,9 @@ func forkVersion*(cfg: RuntimeConfig, consensusFork: ConsensusFork): Version =
of ConsensusFork.Deneb: cfg.DENEB_FORK_VERSION

func lcDataForkAtStateFork*(stateFork: ConsensusFork): LightClientDataFork =
static: doAssert LightClientDataFork.high == LightClientDataFork.EIP4844
static: doAssert LightClientDataFork.high == LightClientDataFork.Deneb
if stateFork >= ConsensusFork.Deneb:
LightClientDataFork.EIP4844
LightClientDataFork.Deneb
elif stateFork >= ConsensusFork.Capella:
LightClientDataFork.Capella
elif stateFork >= ConsensusFork.Altair:
Expand Down
Loading

0 comments on commit 57b2151

Please sign in to comment.