fix forkDigest

This commit is contained in:
Jacek Sieka 2021-10-06 18:47:11 +03:00
parent 0fffdaf96d
commit a017e4a817
No known key found for this signature in database
GPG Key ID: A1B09461ABB656B8
2 changed files with 12 additions and 14 deletions

View File

@ -1857,9 +1857,9 @@ proc createEth2Node*(rng: ref BrHmacDrbgContext,
# that are different from the host address (this is relevant when we
# are running behind a NAT).
var switch = newBeaconSwitch(config, netKeys.seckey, hostAddress, rng)
let altairPrefix = $forkDigests.altair
func msgIdProvider(m: messages.Message): seq[byte] =
let topic = getAltairTopic(m, forkDigests.altairTopicPrefix)
let topic = getAltairTopic(m, altairPrefix)
try:
let decoded = snappy.decode(m.data, GOSSIP_MAX_SIZE)
gossipId(decoded, topic, true)

View File

@ -68,11 +68,10 @@ type
of BeaconBlockFork.Merge:
mergeBlock*: merge.TrustedSignedBeaconBlock
ForkDigests* = object
ForkDigests* {.requiresInit.} = object
phase0*: ForkDigest
altair*: ForkDigest
merge*: ForkDigest # TODO where does this get filled
altairTopicPrefix*: string # Used by isAltairTopic
merge*: ForkDigest
ForkDigestsRef* = ref ForkDigests
@ -306,15 +305,14 @@ func get_previous_epoch*(stateData: ForkedHashedBeaconState): Epoch =
func init*(T: type ForkDigests,
cfg: RuntimeConfig,
genesisValidatorsRoot: Eth2Digest): T =
let altairForkDigest = compute_fork_digest(
cfg.ALTAIR_FORK_VERSION,
genesisValidatorsRoot)
T(phase0: compute_fork_digest(
cfg.GENESIS_FORK_VERSION,
genesisValidatorsRoot),
altair: altairForkDigest,
altairTopicPrefix: $altairForkDigest)
T(
phase0:
compute_fork_digest(cfg.GENESIS_FORK_VERSION, genesisValidatorsRoot),
altair:
compute_fork_digest(cfg.ALTAIR_FORK_VERSION, genesisValidatorsRoot),
merge:
compute_fork_digest(cfg.MERGE_FORK_VERSION, genesisValidatorsRoot),
)
template asSigned*(x: phase0.TrustedSignedBeaconBlock or phase0.SigVerifiedBeaconBlock):
phase0.SignedBeaconBlock =