Skip to content

Commit ad0d300

Browse files
authored
state/forkyState cleanup; spec URL updates; rm unused imports (#4052)
1 parent 9ae796d commit ad0d300

File tree

15 files changed

+32
-31
lines changed

15 files changed

+32
-31
lines changed

beacon_chain/conf.nim

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -538,11 +538,11 @@ type
538538
defaultValue: false
539539
name: "validator-monitor-totals" .}: bool
540540

541-
# https://github.com/ethereum/consensus-specs/blob/v1.2.0-rc.1/sync/optimistic.md#fork-choice-poisoning
541+
# https://github.com/ethereum/consensus-specs/blob/v1.2.0-rc.3/sync/optimistic.md#fork-choice-poisoning
542542
safeSlotsToImportOptimistically* {.
543543
hidden
544544
desc: "Modify SAFE_SLOTS_TO_IMPORT_OPTIMISTICALLY"
545-
# https://github.com/ethereum/consensus-specs/blob/v1.2.0-rc.1/sync/optimistic.md#constants
545+
# https://github.com/ethereum/consensus-specs/blob/v1.2.0-rc.3/sync/optimistic.md#constants
546546
defaultValue: 128
547547
name: "safe-slots-to-import-optimistically" .}: uint16
548548

beacon_chain/consensus_object_pools/README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@ to specs:
77
- blocks: https://github.com/ethereum/consensus-specs/blob/v1.1.10/specs/phase0/p2p-interface.md#beacon_block
88
- aggregate attestations: https://github.com/ethereum/consensus-specs/blob/v1.1.10/specs/phase0/p2p-interface.md#beacon_aggregate_and_proof
99
- unaggregated attestation: https://github.com/ethereum/consensus-specs/blob/v1.2.0-rc.2/specs/phase0/p2p-interface.md#beacon_attestation_subnet_id
10-
- voluntary exits: https://github.com/ethereum/consensus-specs/blob/v1.2.0-rc.2/specs/phase0/p2p-interface.md#voluntary_exit
11-
- Attester slashings: https://github.com/ethereum/consensus-specs/blob/v1.2.0-rc.2/specs/phase0/p2p-interface.md#attester_slashing
12-
- Proposer slashings: https://github.com/ethereum/consensus-specs/blob/v1.2.0-rc.2/specs/phase0/p2p-interface.md#proposer_slashing
10+
- voluntary exits: https://github.com/ethereum/consensus-specs/blob/v1.2.0-rc.3/specs/phase0/p2p-interface.md#voluntary_exit
11+
- Attester slashings: https://github.com/ethereum/consensus-specs/blob/v1.2.0-rc.3/specs/phase0/p2p-interface.md#attester_slashing
12+
- Proposer slashings: https://github.com/ethereum/consensus-specs/blob/v1.2.0-rc.3/specs/phase0/p2p-interface.md#proposer_slashing
1313

1414
After "gossip validation" the consensus objects can be rebroadcasted as they are optimistically good, however for internal processing further verification is needed.
1515
For blocks, this means verifying state transition and all contained cryptographic signatures (instead of just the proposer signature).

beacon_chain/consensus_object_pools/blockchain_dag.nim

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1954,21 +1954,22 @@ proc preInit*(
19541954
let genesisBlockRoot = withState(genesisState):
19551955
if forkyState.root != getStateRoot(tailState):
19561956
# Different tail and genesis
1957-
if state.data.slot >= getStateField(tailState, slot):
1957+
if forkyState.data.slot >= getStateField(tailState, slot):
19581958
fatal "Tail state must be newer or the same as genesis state"
19591959
quit 1
19601960

19611961
let tail_genesis_validators_root =
19621962
getStateField(tailState, genesis_validators_root)
1963-
if state.data.genesis_validators_root != tail_genesis_validators_root:
1963+
if forkyState.data.genesis_validators_root !=
1964+
tail_genesis_validators_root:
19641965
fatal "Tail state doesn't match genesis validators root, it is likely from a different network!",
1965-
genesis_validators_root = shortLog(state.data.genesis_validators_root),
1966+
genesis_validators_root = shortLog(forkyState.data.genesis_validators_root),
19661967
tail_genesis_validators_root = shortLog(tail_genesis_validators_root)
19671968
quit 1
19681969

1969-
let blck = get_initial_beacon_block(state)
1970+
let blck = get_initial_beacon_block(forkyState)
19701971
db.putBlock(blck)
1971-
db.putState(state)
1972+
db.putState(forkyState)
19721973

19731974
db.putGenesisBlock(blck.root)
19741975

@@ -1984,14 +1985,14 @@ proc preInit*(
19841985
# BlockSlot->state_root map, so the only way the init code can find the
19851986
# state is through the state root in the block - this could be relaxed
19861987
# down the line
1987-
if blck.message.state_root != state.root:
1988+
if blck.message.state_root != forkyState.root:
19881989
fatal "State must match the given block",
19891990
tailBlck = shortLog(blck)
19901991

19911992
quit 1
19921993

19931994
db.putBlock(blck)
1994-
db.putState(state)
1995+
db.putState(forkyState)
19951996

19961997
db.putTailBlock(blck.root)
19971998
db.putHeadBlock(blck.root)
@@ -2001,8 +2002,8 @@ proc preInit*(
20012002
genesisStateRoot = shortLog(getStateRoot(genesisState)),
20022003
tailBlockRoot = shortLog(blck.root),
20032004
tailStateRoot = shortLog(state.root),
2004-
fork = state.data.fork,
2005-
validators = state.data.validators.len()
2005+
fork = forkyState.data.fork,
2006+
validators = forkyState.data.validators.len()
20062007

20072008
proc getProposer*(
20082009
dag: ChainDAGRef, head: BlockRef, slot: Slot): Option[ValidatorIndex] =

beacon_chain/fork_choice/fork_choice_types.nim

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ else:
1212

1313
import
1414
# Standard library
15-
std/[options, tables],
15+
std/tables,
1616
# Status
1717
stew/results,
1818
chronicles,

beacon_chain/fork_choice/proto_array.nim

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ else:
1212

1313
import
1414
# Standard library
15-
std/[options, tables, typetraits],
15+
std/[tables, typetraits],
1616
# Status libraries
1717
chronicles,
1818
stew/results,

beacon_chain/gossip_processing/README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@ Gossip validation is different from consensus verification in particular for blo
1212
- Blocks: https://github.com/ethereum/consensus-specs/blob/v1.1.10/specs/phase0/p2p-interface.md#beacon_block
1313
- Attestations (aggregated): https://github.com/ethereum/consensus-specs/blob/v1.1.10/specs/phase0/p2p-interface.md#beacon_aggregate_and_proof
1414
- Attestations (unaggregated): https://github.com/ethereum/consensus-specs/blob/v1.2.0-rc.2/specs/phase0/p2p-interface.md#attestation-subnets
15-
- Voluntary exits: https://github.com/ethereum/consensus-specs/blob/v1.2.0-rc.2/specs/phase0/p2p-interface.md#voluntary_exit
16-
- Proposer slashings: https://github.com/ethereum/consensus-specs/blob/v1.2.0-rc.2/specs/phase0/p2p-interface.md#proposer_slashing
17-
- Attester slashing: https://github.com/ethereum/consensus-specs/blob/v1.2.0-rc.2/specs/phase0/p2p-interface.md#attester_slashing
15+
- Voluntary exits: https://github.com/ethereum/consensus-specs/blob/v1.2.0-rc.3/specs/phase0/p2p-interface.md#voluntary_exit
16+
- Proposer slashings: https://github.com/ethereum/consensus-specs/blob/v1.2.0-rc.3/specs/phase0/p2p-interface.md#proposer_slashing
17+
- Attester slashing: https://github.com/ethereum/consensus-specs/blob/v1.2.0-rc.3/specs/phase0/p2p-interface.md#attester_slashing
1818

1919
There are multiple consumers of validated consensus objects:
2020
- a `ValidationResult.Accept` output triggers rebroadcasting in libp2p

beacon_chain/spec/beaconstate.nim

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ func get_proposer_reward(state: ForkyBeaconState, whistleblower_reward: Gwei): G
165165

166166
# https://github.com/ethereum/consensus-specs/blob/v1.2.0-rc.3/specs/phase0/beacon-chain.md#slash_validator
167167
# https://github.com/ethereum/consensus-specs/blob/v1.2.0-rc.3/specs/altair/beacon-chain.md#modified-slash_validator
168-
# https://github.com/ethereum/consensus-specs/blob/v1.2.0-rc.1/specs/bellatrix/beacon-chain.md#modified-slash_validator
168+
# https://github.com/ethereum/consensus-specs/blob/v1.2.0-rc.3/specs/bellatrix/beacon-chain.md#modified-slash_validator
169169
proc slash_validator*(
170170
cfg: RuntimeConfig, state: var ForkyBeaconState,
171171
slashed_index: ValidatorIndex, cache: var StateCache):

beacon_chain/spec/datatypes/base.nim

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ const
8585
ZERO_HASH* = Eth2Digest()
8686
MAX_GRAFFITI_SIZE* = 32
8787

88-
# https://github.com/ethereum/consensus-specs/blob/v1.2.0-rc.2/specs/phase0/p2p-interface.md#configuration
88+
# https://github.com/ethereum/consensus-specs/blob/v1.2.0-rc.3/specs/phase0/p2p-interface.md#configuration
8989
MAXIMUM_GOSSIP_CLOCK_DISPARITY* = 500.millis
9090

9191
SLOTS_PER_ETH1_VOTING_PERIOD* =
@@ -94,7 +94,7 @@ const
9494
DEPOSIT_CONTRACT_TREE_DEPTH* = 32
9595
BASE_REWARDS_PER_EPOCH* = 4
9696

97-
# https://github.com/ethereum/consensus-specs/blob/v1.2.0-rc.1/specs/phase0/validator.md#misc
97+
# https://github.com/ethereum/consensus-specs/blob/v1.2.0-rc.3/specs/phase0/validator.md#misc
9898
ATTESTATION_SUBNET_COUNT* = 64
9999

100100
DEPOSIT_CONTRACT_LIMIT* = Limit(1'u64 shl DEPOSIT_CONTRACT_TREE_DEPTH)

beacon_chain/spec/signatures.nim

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ func compute_epoch_signing_root*(
7070
let domain = get_domain(fork, DOMAIN_RANDAO, epoch, genesis_validators_root)
7171
compute_signing_root(epoch, domain)
7272

73-
# https://github.com/ethereum/consensus-specs/blob/v1.2.0-rc.1/specs/phase0/validator.md#randao-reveal
73+
# https://github.com/ethereum/consensus-specs/blob/v1.2.0-rc.3/specs/phase0/validator.md#randao-reveal
7474
func get_epoch_signature*(
7575
fork: Fork, genesis_validators_root: Eth2Digest, epoch: Epoch,
7676
privkey: ValidatorPrivKey): CookedSig =

beacon_chain/spec/state_transition_block.nim

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -368,7 +368,7 @@ proc check_voluntary_exit*(
368368
signed_voluntary_exit: SomeSignedVoluntaryExit;
369369
flags: UpdateFlags): Result[ValidatorIndex, cstring] =
370370
withState(state):
371-
check_voluntary_exit(cfg, state.data, signed_voluntary_exit, flags)
371+
check_voluntary_exit(cfg, forkyState.data, signed_voluntary_exit, flags)
372372

373373
# https://github.com/ethereum/consensus-specs/blob/v1.2.0-rc.3/specs/phase0/beacon-chain.md#voluntary-exits
374374
proc process_voluntary_exit*(

0 commit comments

Comments
 (0)