rename *_{MERGE => BELLATRIX} constant names (#3296)
This commit is contained in:
parent
9c0c9c98ce
commit
2f635d3337
|
@ -1829,19 +1829,15 @@ proc newBeaconSwitch*(config: BeaconNodeConf, seckey: PrivateKey,
|
||||||
.withTcpTransport({ServerFlags.ReuseAddr})
|
.withTcpTransport({ServerFlags.ReuseAddr})
|
||||||
.build()
|
.build()
|
||||||
|
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.1.8/specs/phase0/p2p-interface.md#configuration
|
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.1.7/specs/merge/p2p-interface.md#configuration
|
|
||||||
func maxGossipMaxSize(): auto {.compileTime.} =
|
func maxGossipMaxSize(): auto {.compileTime.} =
|
||||||
max(GOSSIP_MAX_SIZE, GOSSIP_MAX_SIZE_MERGE)
|
max(GOSSIP_MAX_SIZE, GOSSIP_MAX_SIZE_BELLATRIX)
|
||||||
|
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.1.8/specs/phase0/p2p-interface.md#configuration
|
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.1.7/specs/merge/p2p-interface.md#configuration
|
|
||||||
template gossipMaxSize(T: untyped): uint32 =
|
template gossipMaxSize(T: untyped): uint32 =
|
||||||
const maxSize = static:
|
const maxSize = static:
|
||||||
when isFixedSize(T):
|
when isFixedSize(T):
|
||||||
fixedPortionSize(T)
|
fixedPortionSize(T)
|
||||||
elif T is bellatrix.SignedBeaconBlock:
|
elif T is bellatrix.SignedBeaconBlock:
|
||||||
GOSSIP_MAX_SIZE_MERGE
|
GOSSIP_MAX_SIZE_BELLATRIX
|
||||||
# TODO https://github.com/status-im/nim-ssz-serialization/issues/20 for
|
# TODO https://github.com/status-im/nim-ssz-serialization/issues/20 for
|
||||||
# Attestation, AttesterSlashing, and SignedAggregateAndProof, which all
|
# Attestation, AttesterSlashing, and SignedAggregateAndProof, which all
|
||||||
# have lists bounded at MAX_VALIDATORS_PER_COMMITTEE (2048) items, thus
|
# have lists bounded at MAX_VALIDATORS_PER_COMMITTEE (2048) items, thus
|
||||||
|
|
|
@ -121,7 +121,7 @@ func initiate_validator_exit*(cfg: RuntimeConfig, state: var ForkyBeaconState,
|
||||||
|
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.1.8/specs/phase0/beacon-chain.md#slash_validator
|
# https://github.com/ethereum/consensus-specs/blob/v1.1.8/specs/phase0/beacon-chain.md#slash_validator
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.1.8/specs/altair/beacon-chain.md#modified-slash_validator
|
# https://github.com/ethereum/consensus-specs/blob/v1.1.8/specs/altair/beacon-chain.md#modified-slash_validator
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.1.8/specs/merge/beacon-chain.md#modified-slash_validator
|
# https://github.com/ethereum/consensus-specs/blob/v1.1.8/specs/bellatrix/beacon-chain.md#modified-slash_validator
|
||||||
proc get_slashing_penalty*(state: ForkyBeaconState,
|
proc get_slashing_penalty*(state: ForkyBeaconState,
|
||||||
validator_effective_balance: Gwei): Gwei =
|
validator_effective_balance: Gwei): Gwei =
|
||||||
# TODO Consider whether this is better than splitting the functions apart; in
|
# TODO Consider whether this is better than splitting the functions apart; in
|
||||||
|
@ -131,7 +131,7 @@ proc get_slashing_penalty*(state: ForkyBeaconState,
|
||||||
elif state is altair.BeaconState:
|
elif state is altair.BeaconState:
|
||||||
validator_effective_balance div MIN_SLASHING_PENALTY_QUOTIENT_ALTAIR
|
validator_effective_balance div MIN_SLASHING_PENALTY_QUOTIENT_ALTAIR
|
||||||
elif state is bellatrix.BeaconState:
|
elif state is bellatrix.BeaconState:
|
||||||
validator_effective_balance div MIN_SLASHING_PENALTY_QUOTIENT_MERGE
|
validator_effective_balance div MIN_SLASHING_PENALTY_QUOTIENT_BELLATRIX
|
||||||
else:
|
else:
|
||||||
{.fatal: "invalid BeaconState type".}
|
{.fatal: "invalid BeaconState type".}
|
||||||
|
|
||||||
|
|
|
@ -27,9 +27,9 @@ const
|
||||||
TTFB_TIMEOUT* = 5.seconds
|
TTFB_TIMEOUT* = 5.seconds
|
||||||
RESP_TIMEOUT* = 10.seconds
|
RESP_TIMEOUT* = 10.seconds
|
||||||
|
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.1.7/specs/merge/p2p-interface.md#configuration
|
# https://github.com/ethereum/consensus-specs/blob/v1.1.8/specs/bellatrix/p2p-interface.md#configuration
|
||||||
GOSSIP_MAX_SIZE_MERGE* = 10 * 1024 * 1024 # bytes
|
GOSSIP_MAX_SIZE_BELLATRIX* = 10 * 1024 * 1024 # bytes
|
||||||
MAX_CHUNK_SIZE_MERGE* = 10 * 1024 * 1024 # bytes
|
MAX_CHUNK_SIZE_BELLATRIX* = 10 * 1024 * 1024 # bytes
|
||||||
|
|
||||||
defaultEth2TcpPort* = 9000
|
defaultEth2TcpPort* = 9000
|
||||||
|
|
||||||
|
|
|
@ -1,14 +1,14 @@
|
||||||
# Mainnet preset - Merge
|
# Mainnet preset - Bellatrix
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.1.6/presets/mainnet/merge.yaml
|
# https://github.com/ethereum/consensus-specs/blob/v1.1.8/presets/mainnet/bellatrix.yaml
|
||||||
const
|
const
|
||||||
# Updated penalty values
|
# Updated penalty values
|
||||||
# ---------------------------------------------------------------
|
# ---------------------------------------------------------------
|
||||||
# 2**24 (= 16,777,216)
|
# 2**24 (= 16,777,216)
|
||||||
INACTIVITY_PENALTY_QUOTIENT_MERGE*: uint64 = 16777216
|
INACTIVITY_PENALTY_QUOTIENT_BELLATRIX*: uint64 = 16777216
|
||||||
# 2**5 (= 32)
|
# 2**5 (= 32)
|
||||||
MIN_SLASHING_PENALTY_QUOTIENT_MERGE*: uint64 = 32
|
MIN_SLASHING_PENALTY_QUOTIENT_BELLATRIX*: uint64 = 32
|
||||||
# 3
|
# 3
|
||||||
PROPORTIONAL_SLASHING_MULTIPLIER_MERGE*: uint64 = 3
|
PROPORTIONAL_SLASHING_MULTIPLIER_BELLATRIX*: uint64 = 3
|
||||||
|
|
||||||
|
|
||||||
# Execution
|
# Execution
|
||||||
|
|
|
@ -1,14 +1,14 @@
|
||||||
# Minimal preset - Merge
|
# Minimal preset - Bellatrix
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.1.7/presets/minimal/merge.yaml
|
# https://github.com/ethereum/consensus-specs/blob/v1.1.8/presets/minimal/bellatrix.yaml
|
||||||
const
|
const
|
||||||
# Updated penalty values
|
# Updated penalty values
|
||||||
# ---------------------------------------------------------------
|
# ---------------------------------------------------------------
|
||||||
# 2**24 (= 16,777,216)
|
# 2**24 (= 16,777,216)
|
||||||
INACTIVITY_PENALTY_QUOTIENT_MERGE*: uint64 = 16777216
|
INACTIVITY_PENALTY_QUOTIENT_BELLATRIX*: uint64 = 16777216
|
||||||
# 2**5 (= 32)
|
# 2**5 (= 32)
|
||||||
MIN_SLASHING_PENALTY_QUOTIENT_MERGE*: uint64 = 32
|
MIN_SLASHING_PENALTY_QUOTIENT_BELLATRIX*: uint64 = 32
|
||||||
# 3
|
# 3
|
||||||
PROPORTIONAL_SLASHING_MULTIPLIER_MERGE*: uint64 = 3
|
PROPORTIONAL_SLASHING_MULTIPLIER_BELLATRIX*: uint64 = 3
|
||||||
|
|
||||||
|
|
||||||
# Execution
|
# Execution
|
||||||
|
|
|
@ -721,15 +721,16 @@ iterator get_inactivity_penalty_deltas*(
|
||||||
state.inactivity_scores[index]
|
state.inactivity_scores[index]
|
||||||
yield (vidx, Gwei(penalty_numerator div penalty_denominator))
|
yield (vidx, Gwei(penalty_numerator div penalty_denominator))
|
||||||
|
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.1.4/specs/merge/beacon-chain.md#modified-get_inactivity_penalty_deltas
|
# https://github.com/ethereum/consensus-specs/blob/v1.1.8/specs/bellatrix/beacon-chain.md#modified-get_inactivity_penalty_deltas
|
||||||
iterator get_inactivity_penalty_deltas*(
|
iterator get_inactivity_penalty_deltas*(
|
||||||
cfg: RuntimeConfig, state: bellatrix.BeaconState, info: altair.EpochInfo):
|
cfg: RuntimeConfig, state: bellatrix.BeaconState, info: altair.EpochInfo):
|
||||||
(ValidatorIndex, Gwei) =
|
(ValidatorIndex, Gwei) =
|
||||||
## Return the inactivity penalty deltas by considering timely target
|
## Return the inactivity penalty deltas by considering timely target
|
||||||
## participation flags and inactivity scores.
|
## participation flags and inactivity scores.
|
||||||
let
|
let
|
||||||
|
# [Modified in Bellatrix]
|
||||||
penalty_denominator =
|
penalty_denominator =
|
||||||
cfg.INACTIVITY_SCORE_BIAS * INACTIVITY_PENALTY_QUOTIENT_MERGE
|
cfg.INACTIVITY_SCORE_BIAS * INACTIVITY_PENALTY_QUOTIENT_BELLATRIX
|
||||||
previous_epoch = get_previous_epoch(state)
|
previous_epoch = get_previous_epoch(state)
|
||||||
|
|
||||||
for index in 0 ..< state.validators.len:
|
for index in 0 ..< state.validators.len:
|
||||||
|
@ -853,7 +854,7 @@ func process_registry_updates*(
|
||||||
|
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.1.8/specs/phase0/beacon-chain.md#slashings
|
# https://github.com/ethereum/consensus-specs/blob/v1.1.8/specs/phase0/beacon-chain.md#slashings
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.1.8/specs/altair/beacon-chain.md#slashings
|
# https://github.com/ethereum/consensus-specs/blob/v1.1.8/specs/altair/beacon-chain.md#slashings
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.1.8/specs/merge/beacon-chain.md#slashings
|
# https://github.com/ethereum/consensus-specs/blob/v1.1.8/specs/bellatrix/beacon-chain.md#slashings
|
||||||
func get_adjusted_total_slashing_balance*(
|
func get_adjusted_total_slashing_balance*(
|
||||||
state: ForkyBeaconState, total_balance: Gwei): Gwei =
|
state: ForkyBeaconState, total_balance: Gwei): Gwei =
|
||||||
let multiplier =
|
let multiplier =
|
||||||
|
@ -864,21 +865,21 @@ func get_adjusted_total_slashing_balance*(
|
||||||
elif state is altair.BeaconState:
|
elif state is altair.BeaconState:
|
||||||
PROPORTIONAL_SLASHING_MULTIPLIER_ALTAIR
|
PROPORTIONAL_SLASHING_MULTIPLIER_ALTAIR
|
||||||
elif state is bellatrix.BeaconState:
|
elif state is bellatrix.BeaconState:
|
||||||
PROPORTIONAL_SLASHING_MULTIPLIER_MERGE
|
PROPORTIONAL_SLASHING_MULTIPLIER_BELLATRIX
|
||||||
else:
|
else:
|
||||||
{.fatal: "process_slashings: incorrect BeaconState type".}
|
{.fatal: "process_slashings: incorrect BeaconState type".}
|
||||||
min(sum(state.slashings.data) * multiplier, total_balance)
|
min(sum(state.slashings.data) * multiplier, total_balance)
|
||||||
|
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.1.8/specs/phase0/beacon-chain.md#slashings
|
# https://github.com/ethereum/consensus-specs/blob/v1.1.8/specs/phase0/beacon-chain.md#slashings
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.1.8/specs/altair/beacon-chain.md#slashings
|
# https://github.com/ethereum/consensus-specs/blob/v1.1.8/specs/altair/beacon-chain.md#slashings
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.1.8/specs/merge/beacon-chain.md#slashings
|
# https://github.com/ethereum/consensus-specs/blob/v1.1.8/specs/bellatrix/beacon-chain.md#slashings
|
||||||
func slashing_penalty_applies*(validator: Validator, epoch: Epoch): bool =
|
func slashing_penalty_applies*(validator: Validator, epoch: Epoch): bool =
|
||||||
validator.slashed and
|
validator.slashed and
|
||||||
epoch + EPOCHS_PER_SLASHINGS_VECTOR div 2 == validator.withdrawable_epoch
|
epoch + EPOCHS_PER_SLASHINGS_VECTOR div 2 == validator.withdrawable_epoch
|
||||||
|
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.1.8/specs/phase0/beacon-chain.md#slashings
|
# https://github.com/ethereum/consensus-specs/blob/v1.1.8/specs/phase0/beacon-chain.md#slashings
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.1.8/specs/altair/beacon-chain.md#slashings
|
# https://github.com/ethereum/consensus-specs/blob/v1.1.8/specs/altair/beacon-chain.md#slashings
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.1.8/specs/merge/beacon-chain.md#slashings
|
# https://github.com/ethereum/consensus-specs/blob/v1.1.8/specs/bellatrix/beacon-chain.md#slashings
|
||||||
func get_slashing_penalty*(validator: Validator,
|
func get_slashing_penalty*(validator: Validator,
|
||||||
adjusted_total_slashing_balance,
|
adjusted_total_slashing_balance,
|
||||||
total_balance: Gwei): Gwei =
|
total_balance: Gwei): Gwei =
|
||||||
|
@ -890,7 +891,7 @@ func get_slashing_penalty*(validator: Validator,
|
||||||
|
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.1.8/specs/phase0/beacon-chain.md#slashings
|
# https://github.com/ethereum/consensus-specs/blob/v1.1.8/specs/phase0/beacon-chain.md#slashings
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.1.8/specs/altair/beacon-chain.md#slashings
|
# https://github.com/ethereum/consensus-specs/blob/v1.1.8/specs/altair/beacon-chain.md#slashings
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.1.8/specs/merge/beacon-chain.md#slashings
|
# https://github.com/ethereum/consensus-specs/blob/v1.1.8/specs/bellatrix/beacon-chain.md#slashings
|
||||||
func process_slashings*(state: var ForkyBeaconState, total_balance: Gwei) =
|
func process_slashings*(state: var ForkyBeaconState, total_balance: Gwei) =
|
||||||
let
|
let
|
||||||
epoch = get_current_epoch(state)
|
epoch = get_current_epoch(state)
|
||||||
|
|
|
@ -176,20 +176,20 @@ proc doSSZ(conf: NcliConf) =
|
||||||
of "attestation": printit(Attestation)
|
of "attestation": printit(Attestation)
|
||||||
of "phase0_signed_block": printit(phase0.SignedBeaconBlock)
|
of "phase0_signed_block": printit(phase0.SignedBeaconBlock)
|
||||||
of "altair_signed_block": printit(altair.SignedBeaconBlock)
|
of "altair_signed_block": printit(altair.SignedBeaconBlock)
|
||||||
of "merge_signed_block": printit(bellatrix.SignedBeaconBlock)
|
of "bellatrix_signed_block": printit(bellatrix.SignedBeaconBlock)
|
||||||
of "phase0_block": printit(phase0.BeaconBlock)
|
of "phase0_block": printit(phase0.BeaconBlock)
|
||||||
of "altair_block": printit(altair.BeaconBlock)
|
of "altair_block": printit(altair.BeaconBlock)
|
||||||
of "merge_block": printit(bellatrix.BeaconBlock)
|
of "bellatrix_block": printit(bellatrix.BeaconBlock)
|
||||||
of "phase0_block_body": printit(phase0.BeaconBlockBody)
|
of "phase0_block_body": printit(phase0.BeaconBlockBody)
|
||||||
of "altair_block_body": printit(altair.BeaconBlockBody)
|
of "altair_block_body": printit(altair.BeaconBlockBody)
|
||||||
of "merge_block_body": printit(bellatrix.BeaconBlockBody)
|
of "bellatrix_block_body": printit(bellatrix.BeaconBlockBody)
|
||||||
of "block_header": printit(BeaconBlockHeader)
|
of "block_header": printit(BeaconBlockHeader)
|
||||||
of "deposit": printit(Deposit)
|
of "deposit": printit(Deposit)
|
||||||
of "deposit_data": printit(DepositData)
|
of "deposit_data": printit(DepositData)
|
||||||
of "eth1_data": printit(Eth1Data)
|
of "eth1_data": printit(Eth1Data)
|
||||||
of "phase0_state": printit(phase0.BeaconState)
|
of "phase0_state": printit(phase0.BeaconState)
|
||||||
of "altiar_state": printit(altair.BeaconState)
|
of "altiar_state": printit(altair.BeaconState)
|
||||||
of "merge_state": printit(bellatrix.BeaconState)
|
of "bellatrix_state": printit(bellatrix.BeaconState)
|
||||||
of "proposer_slashing": printit(ProposerSlashing)
|
of "proposer_slashing": printit(ProposerSlashing)
|
||||||
of "voluntary_exit": printit(VoluntaryExit)
|
of "voluntary_exit": printit(VoluntaryExit)
|
||||||
|
|
||||||
|
|
|
@ -305,9 +305,9 @@ proc cmdDumpState(conf: DbConf) =
|
||||||
defer: db.close()
|
defer: db.close()
|
||||||
|
|
||||||
let
|
let
|
||||||
phase0State = (ref phase0.HashedBeaconState)()
|
phase0State = (ref phase0.HashedBeaconState)()
|
||||||
altairState = (ref altair.HashedBeaconState)()
|
altairState = (ref altair.HashedBeaconState)()
|
||||||
mergeState = (ref bellatrix.HashedBeaconState)()
|
bellatrixState = (ref bellatrix.HashedBeaconState)()
|
||||||
|
|
||||||
for stateRoot in conf.stateRoot:
|
for stateRoot in conf.stateRoot:
|
||||||
if shouldShutDown: quit QuitSuccess
|
if shouldShutDown: quit QuitSuccess
|
||||||
|
@ -323,7 +323,7 @@ proc cmdDumpState(conf: DbConf) =
|
||||||
|
|
||||||
doit(phase0State[])
|
doit(phase0State[])
|
||||||
doit(altairState[])
|
doit(altairState[])
|
||||||
doit(mergeState[])
|
doit(bellatrixState[])
|
||||||
|
|
||||||
echo "Couldn't load ", stateRoot
|
echo "Couldn't load ", stateRoot
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue