mirror of
https://github.com/status-im/nimbus-eth2.git
synced 2025-02-26 13:15:16 +00:00
rename _INDEX
generalized index constants to _GINDEX
(#5583)
Rename constants for consistency with upcoming spec adjustment: - https://github.com/ethereum/consensus-specs/pull/3537
This commit is contained in:
parent
4399361bc7
commit
d9031d97dc
@ -222,7 +222,7 @@ proc initLightClientBootstrapForPeriod(
|
|||||||
forkyBlck.toLightClientHeader(lcDataFork))
|
forkyBlck.toLightClientHeader(lcDataFork))
|
||||||
dag.lcDataStore.db.putCurrentSyncCommitteeBranch(
|
dag.lcDataStore.db.putCurrentSyncCommitteeBranch(
|
||||||
bid.slot, forkyState.data.build_proof(
|
bid.slot, forkyState.data.build_proof(
|
||||||
altair.CURRENT_SYNC_COMMITTEE_INDEX).get)
|
altair.CURRENT_SYNC_COMMITTEE_GINDEX).get)
|
||||||
else: raiseAssert "Unreachable"
|
else: raiseAssert "Unreachable"
|
||||||
res
|
res
|
||||||
|
|
||||||
@ -371,10 +371,10 @@ proc initLightClientUpdateForPeriod(
|
|||||||
attested_header: forkyBlck.toLightClientHeader(lcDataFork),
|
attested_header: forkyBlck.toLightClientHeader(lcDataFork),
|
||||||
next_sync_committee: forkyState.data.next_sync_committee,
|
next_sync_committee: forkyState.data.next_sync_committee,
|
||||||
next_sync_committee_branch:
|
next_sync_committee_branch:
|
||||||
forkyState.data.build_proof(altair.NEXT_SYNC_COMMITTEE_INDEX).get,
|
forkyState.data.build_proof(altair.NEXT_SYNC_COMMITTEE_GINDEX).get,
|
||||||
finality_branch:
|
finality_branch:
|
||||||
if finalizedBid.slot != FAR_FUTURE_SLOT:
|
if finalizedBid.slot != FAR_FUTURE_SLOT:
|
||||||
forkyState.data.build_proof(altair.FINALIZED_ROOT_INDEX).get
|
forkyState.data.build_proof(altair.FINALIZED_ROOT_GINDEX).get
|
||||||
else:
|
else:
|
||||||
default(FinalityBranch)))
|
default(FinalityBranch)))
|
||||||
else: raiseAssert "Unreachable"
|
else: raiseAssert "Unreachable"
|
||||||
@ -442,13 +442,13 @@ proc cacheLightClientData(
|
|||||||
## block and state.
|
## block and state.
|
||||||
let cachedData = CachedLightClientData(
|
let cachedData = CachedLightClientData(
|
||||||
current_sync_committee_branch:
|
current_sync_committee_branch:
|
||||||
state.data.build_proof(altair.CURRENT_SYNC_COMMITTEE_INDEX).get,
|
state.data.build_proof(altair.CURRENT_SYNC_COMMITTEE_GINDEX).get,
|
||||||
next_sync_committee_branch:
|
next_sync_committee_branch:
|
||||||
state.data.build_proof(altair.NEXT_SYNC_COMMITTEE_INDEX).get,
|
state.data.build_proof(altair.NEXT_SYNC_COMMITTEE_GINDEX).get,
|
||||||
finalized_slot:
|
finalized_slot:
|
||||||
state.data.finalized_checkpoint.epoch.start_slot,
|
state.data.finalized_checkpoint.epoch.start_slot,
|
||||||
finality_branch:
|
finality_branch:
|
||||||
state.data.build_proof(altair.FINALIZED_ROOT_INDEX).get)
|
state.data.build_proof(altair.FINALIZED_ROOT_GINDEX).get)
|
||||||
if dag.lcDataStore.cache.data.hasKeyOrPut(bid, cachedData):
|
if dag.lcDataStore.cache.data.hasKeyOrPut(bid, cachedData):
|
||||||
doAssert false, "Redundant `cacheLightClientData` call"
|
doAssert false, "Redundant `cacheLightClientData` call"
|
||||||
|
|
||||||
@ -956,7 +956,7 @@ proc getLightClientBootstrap(
|
|||||||
dag.lcDataStore.db.putHeader(header)
|
dag.lcDataStore.db.putHeader(header)
|
||||||
dag.lcDataStore.db.putCurrentSyncCommitteeBranch(
|
dag.lcDataStore.db.putCurrentSyncCommitteeBranch(
|
||||||
slot, forkyState.data.build_proof(
|
slot, forkyState.data.build_proof(
|
||||||
altair.CURRENT_SYNC_COMMITTEE_INDEX).get)
|
altair.CURRENT_SYNC_COMMITTEE_GINDEX).get)
|
||||||
else: raiseAssert "Unreachable"
|
else: raiseAssert "Unreachable"
|
||||||
do: return default(ForkedLightClientBootstrap)
|
do: return default(ForkedLightClientBootstrap)
|
||||||
|
|
||||||
|
@ -59,11 +59,11 @@ const
|
|||||||
# All of these indices are rooted in `BeaconState`.
|
# All of these indices are rooted in `BeaconState`.
|
||||||
# The first member (`genesis_time`) is 32, subsequent members +1 each.
|
# The first member (`genesis_time`) is 32, subsequent members +1 each.
|
||||||
# If there are ever more than 32 members in `BeaconState`, indices change!
|
# If there are ever more than 32 members in `BeaconState`, indices change!
|
||||||
# `FINALIZED_ROOT_INDEX` is one layer deeper, i.e., `52 * 2 + 1`.
|
# `FINALIZED_ROOT_GINDEX` is one layer deeper, i.e., `52 * 2 + 1`.
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.3/ssz/merkle-proofs.md
|
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.3/ssz/merkle-proofs.md
|
||||||
FINALIZED_ROOT_INDEX* = 105.GeneralizedIndex # `finalized_checkpoint` > `root`
|
FINALIZED_ROOT_GINDEX* = 105.GeneralizedIndex # finalized_checkpoint > root
|
||||||
CURRENT_SYNC_COMMITTEE_INDEX* = 54.GeneralizedIndex # `current_sync_committee`
|
CURRENT_SYNC_COMMITTEE_GINDEX* = 54.GeneralizedIndex # current_sync_committee
|
||||||
NEXT_SYNC_COMMITTEE_INDEX* = 55.GeneralizedIndex # `next_sync_committee`
|
NEXT_SYNC_COMMITTEE_GINDEX* = 55.GeneralizedIndex # next_sync_committee
|
||||||
|
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.4/specs/altair/beacon-chain.md#inactivity-penalties
|
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.4/specs/altair/beacon-chain.md#inactivity-penalties
|
||||||
INACTIVITY_SCORE_BIAS* = 4
|
INACTIVITY_SCORE_BIAS* = 4
|
||||||
@ -157,13 +157,13 @@ type
|
|||||||
### Modified/overloaded
|
### Modified/overloaded
|
||||||
|
|
||||||
FinalityBranch* =
|
FinalityBranch* =
|
||||||
array[log2trunc(FINALIZED_ROOT_INDEX), Eth2Digest]
|
array[log2trunc(FINALIZED_ROOT_GINDEX), Eth2Digest]
|
||||||
|
|
||||||
CurrentSyncCommitteeBranch* =
|
CurrentSyncCommitteeBranch* =
|
||||||
array[log2trunc(CURRENT_SYNC_COMMITTEE_INDEX), Eth2Digest]
|
array[log2trunc(CURRENT_SYNC_COMMITTEE_GINDEX), Eth2Digest]
|
||||||
|
|
||||||
NextSyncCommitteeBranch* =
|
NextSyncCommitteeBranch* =
|
||||||
array[log2trunc(NEXT_SYNC_COMMITTEE_INDEX), Eth2Digest]
|
array[log2trunc(NEXT_SYNC_COMMITTEE_GINDEX), Eth2Digest]
|
||||||
|
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.4/specs/altair/light-client/sync-protocol.md#lightclientheader
|
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.4/specs/altair/light-client/sync-protocol.md#lightclientheader
|
||||||
LightClientHeader* = object
|
LightClientHeader* = object
|
||||||
|
@ -32,7 +32,7 @@ const
|
|||||||
# The first member (`randao_reveal`) is 16, subsequent members +1 each.
|
# The first member (`randao_reveal`) is 16, subsequent members +1 each.
|
||||||
# If there are ever more than 16 members in `BeaconBlockBody`, indices change!
|
# If there are ever more than 16 members in `BeaconBlockBody`, indices change!
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.3/ssz/merkle-proofs.md
|
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.3/ssz/merkle-proofs.md
|
||||||
EXECUTION_PAYLOAD_INDEX* = 25.GeneralizedIndex # `execution_payload`
|
EXECUTION_PAYLOAD_GINDEX* = 25.GeneralizedIndex # execution_payload
|
||||||
|
|
||||||
type
|
type
|
||||||
SignedBLSToExecutionChangeList* =
|
SignedBLSToExecutionChangeList* =
|
||||||
@ -120,7 +120,7 @@ type
|
|||||||
execution_payload: ExecutionPayload): bool {.gcsafe, raises: [].}
|
execution_payload: ExecutionPayload): bool {.gcsafe, raises: [].}
|
||||||
|
|
||||||
ExecutionBranch* =
|
ExecutionBranch* =
|
||||||
array[log2trunc(EXECUTION_PAYLOAD_INDEX), Eth2Digest]
|
array[log2trunc(EXECUTION_PAYLOAD_GINDEX), Eth2Digest]
|
||||||
|
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.4/specs/capella/light-client/sync-protocol.md#modified-lightclientheader
|
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.4/specs/capella/light-client/sync-protocol.md#modified-lightclientheader
|
||||||
LightClientHeader* = object
|
LightClientHeader* = object
|
||||||
@ -673,8 +673,8 @@ func is_valid_light_client_header*(
|
|||||||
is_valid_merkle_branch(
|
is_valid_merkle_branch(
|
||||||
get_lc_execution_root(header, cfg),
|
get_lc_execution_root(header, cfg),
|
||||||
header.execution_branch,
|
header.execution_branch,
|
||||||
log2trunc(EXECUTION_PAYLOAD_INDEX),
|
log2trunc(EXECUTION_PAYLOAD_GINDEX),
|
||||||
get_subtree_index(EXECUTION_PAYLOAD_INDEX),
|
get_subtree_index(EXECUTION_PAYLOAD_GINDEX),
|
||||||
header.beacon.body_root)
|
header.beacon.body_root)
|
||||||
|
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.4/specs/capella/light-client/fork.md#upgrading-light-client-data
|
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.4/specs/capella/light-client/fork.md#upgrading-light-client-data
|
||||||
|
@ -574,7 +574,7 @@ func kzg_commitment_inclusion_proof_gindex*(
|
|||||||
# If there are ever more than 16 members in `BeaconBlockBody`, indices change!
|
# If there are ever more than 16 members in `BeaconBlockBody`, indices change!
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.4/ssz/merkle-proofs.md
|
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.4/ssz/merkle-proofs.md
|
||||||
const
|
const
|
||||||
# `blob_kzg_commitments`
|
# blob_kzg_commitments
|
||||||
BLOB_KZG_COMMITMENTS_GINDEX =
|
BLOB_KZG_COMMITMENTS_GINDEX =
|
||||||
27.GeneralizedIndex
|
27.GeneralizedIndex
|
||||||
# List + 0 = items, + 1 = len
|
# List + 0 = items, + 1 = len
|
||||||
@ -639,8 +639,8 @@ func is_valid_light_client_header*(
|
|||||||
is_valid_merkle_branch(
|
is_valid_merkle_branch(
|
||||||
get_lc_execution_root(header, cfg),
|
get_lc_execution_root(header, cfg),
|
||||||
header.execution_branch,
|
header.execution_branch,
|
||||||
log2trunc(EXECUTION_PAYLOAD_INDEX),
|
log2trunc(EXECUTION_PAYLOAD_GINDEX),
|
||||||
get_subtree_index(EXECUTION_PAYLOAD_INDEX),
|
get_subtree_index(EXECUTION_PAYLOAD_GINDEX),
|
||||||
header.beacon.body_root)
|
header.beacon.body_root)
|
||||||
|
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.4/specs/deneb/light-client/fork.md#upgrading-light-client-data
|
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.4/specs/deneb/light-client/fork.md#upgrading-light-client-data
|
||||||
|
@ -878,7 +878,7 @@ func toCapellaLightClientHeader(
|
|||||||
transactions_root: hash_tree_root(payload.transactions),
|
transactions_root: hash_tree_root(payload.transactions),
|
||||||
withdrawals_root: hash_tree_root(payload.withdrawals)),
|
withdrawals_root: hash_tree_root(payload.withdrawals)),
|
||||||
execution_branch: blck.message.body.build_proof(
|
execution_branch: blck.message.body.build_proof(
|
||||||
capella.EXECUTION_PAYLOAD_INDEX).get)
|
capella.EXECUTION_PAYLOAD_GINDEX).get)
|
||||||
|
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-alpha.0/specs/deneb/light-client/full-node.md#modified-block_to_light_client_header
|
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-alpha.0/specs/deneb/light-client/full-node.md#modified-block_to_light_client_header
|
||||||
func toDenebLightClientHeader(
|
func toDenebLightClientHeader(
|
||||||
@ -920,7 +920,7 @@ func toDenebLightClientHeader(
|
|||||||
transactions_root: hash_tree_root(payload.transactions),
|
transactions_root: hash_tree_root(payload.transactions),
|
||||||
withdrawals_root: hash_tree_root(payload.withdrawals)),
|
withdrawals_root: hash_tree_root(payload.withdrawals)),
|
||||||
execution_branch: blck.message.body.build_proof(
|
execution_branch: blck.message.body.build_proof(
|
||||||
capella.EXECUTION_PAYLOAD_INDEX).get)
|
capella.EXECUTION_PAYLOAD_GINDEX).get)
|
||||||
|
|
||||||
func toDenebLightClientHeader(
|
func toDenebLightClientHeader(
|
||||||
blck: # `SomeSignedBeaconBlock` doesn't work here (Nim 1.6)
|
blck: # `SomeSignedBeaconBlock` doesn't work here (Nim 1.6)
|
||||||
@ -947,7 +947,7 @@ func toDenebLightClientHeader(
|
|||||||
withdrawals_root: hash_tree_root(payload.withdrawals),
|
withdrawals_root: hash_tree_root(payload.withdrawals),
|
||||||
excess_blob_gas: payload.excess_blob_gas),
|
excess_blob_gas: payload.excess_blob_gas),
|
||||||
execution_branch: blck.message.body.build_proof(
|
execution_branch: blck.message.body.build_proof(
|
||||||
capella.EXECUTION_PAYLOAD_INDEX).get)
|
capella.EXECUTION_PAYLOAD_GINDEX).get)
|
||||||
|
|
||||||
func toLightClientHeader*(
|
func toLightClientHeader*(
|
||||||
blck: # `SomeSignedBeaconBlock` doesn't work here (Nim 1.6)
|
blck: # `SomeSignedBeaconBlock` doesn't work here (Nim 1.6)
|
||||||
|
@ -32,8 +32,8 @@ func initialize_light_client_store*(
|
|||||||
if not is_valid_merkle_branch(
|
if not is_valid_merkle_branch(
|
||||||
hash_tree_root(bootstrap.current_sync_committee),
|
hash_tree_root(bootstrap.current_sync_committee),
|
||||||
bootstrap.current_sync_committee_branch,
|
bootstrap.current_sync_committee_branch,
|
||||||
log2trunc(altair.CURRENT_SYNC_COMMITTEE_INDEX),
|
log2trunc(altair.CURRENT_SYNC_COMMITTEE_GINDEX),
|
||||||
get_subtree_index(altair.CURRENT_SYNC_COMMITTEE_INDEX),
|
get_subtree_index(altair.CURRENT_SYNC_COMMITTEE_GINDEX),
|
||||||
bootstrap.header.beacon.state_root):
|
bootstrap.header.beacon.state_root):
|
||||||
return ResultType.err(VerifierError.Invalid)
|
return ResultType.err(VerifierError.Invalid)
|
||||||
|
|
||||||
@ -111,8 +111,8 @@ proc validate_light_client_update*(
|
|||||||
if not is_valid_merkle_branch(
|
if not is_valid_merkle_branch(
|
||||||
finalized_root,
|
finalized_root,
|
||||||
update.finality_branch,
|
update.finality_branch,
|
||||||
log2trunc(altair.FINALIZED_ROOT_INDEX),
|
log2trunc(altair.FINALIZED_ROOT_GINDEX),
|
||||||
get_subtree_index(altair.FINALIZED_ROOT_INDEX),
|
get_subtree_index(altair.FINALIZED_ROOT_GINDEX),
|
||||||
update.attested_header.beacon.state_root):
|
update.attested_header.beacon.state_root):
|
||||||
return err(VerifierError.Invalid)
|
return err(VerifierError.Invalid)
|
||||||
|
|
||||||
@ -130,8 +130,8 @@ proc validate_light_client_update*(
|
|||||||
if not is_valid_merkle_branch(
|
if not is_valid_merkle_branch(
|
||||||
hash_tree_root(update.next_sync_committee),
|
hash_tree_root(update.next_sync_committee),
|
||||||
update.next_sync_committee_branch,
|
update.next_sync_committee_branch,
|
||||||
log2trunc(altair.NEXT_SYNC_COMMITTEE_INDEX),
|
log2trunc(altair.NEXT_SYNC_COMMITTEE_GINDEX),
|
||||||
get_subtree_index(altair.NEXT_SYNC_COMMITTEE_INDEX),
|
get_subtree_index(altair.NEXT_SYNC_COMMITTEE_GINDEX),
|
||||||
update.attested_header.beacon.state_root):
|
update.attested_header.beacon.state_root):
|
||||||
return err(VerifierError.Invalid)
|
return err(VerifierError.Invalid)
|
||||||
|
|
||||||
|
@ -288,7 +288,7 @@ proc runTest(storeDataFork: static LightClientDataFork) =
|
|||||||
template next_sync_committee(): auto = state.next_sync_committee
|
template next_sync_committee(): auto = state.next_sync_committee
|
||||||
let
|
let
|
||||||
next_sync_committee_branch =
|
next_sync_committee_branch =
|
||||||
state.build_proof(altair.NEXT_SYNC_COMMITTEE_INDEX).get
|
state.build_proof(altair.NEXT_SYNC_COMMITTEE_GINDEX).get
|
||||||
|
|
||||||
# Finality is unchanged
|
# Finality is unchanged
|
||||||
finality_header = default(storeDataFork.LightClientHeader)
|
finality_header = default(storeDataFork.LightClientHeader)
|
||||||
@ -358,7 +358,7 @@ proc runTest(storeDataFork: static LightClientDataFork) =
|
|||||||
finalized_header.beacon.hash_tree_root() ==
|
finalized_header.beacon.hash_tree_root() ==
|
||||||
state.finalized_checkpoint.root
|
state.finalized_checkpoint.root
|
||||||
let
|
let
|
||||||
finality_branch = state.build_proof(altair.FINALIZED_ROOT_INDEX).get
|
finality_branch = state.build_proof(altair.FINALIZED_ROOT_GINDEX).get
|
||||||
|
|
||||||
update = storeDataFork.LightClientUpdate(
|
update = storeDataFork.LightClientUpdate(
|
||||||
attested_header: attested_header,
|
attested_header: attested_header,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user