From d2066eff093eb67b508d572d1217297f6c834b63 Mon Sep 17 00:00:00 2001 From: gop Date: Mon, 18 Sep 2023 15:05:42 -0500 Subject: [PATCH] Using the Location and Genesis hash together to calculate the ForkID checksum --- core/forkid/forkid.go | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/core/forkid/forkid.go b/core/forkid/forkid.go index 5f1622da6d..5da491e25c 100644 --- a/core/forkid/forkid.go +++ b/core/forkid/forkid.go @@ -66,8 +66,11 @@ type Filter func(id ID) error // NewID calculates the Quai fork ID from the chain config, genesis hash, and head. func NewID(config *params.ChainConfig, genesis common.Hash, head uint64) ID { - // Calculate the starting checksum from the genesis hash - hash := crc32.ChecksumIEEE(genesis[:]) + // CheckSum now has to be hash of Genesis and Location because in order to + // use the Disco crawler and use the same enr tree for all chains location + // serves as a unique identifier for filtering enodes + checkSumBytes := append(genesis[:], config.Location...) + hash := crc32.ChecksumIEEE(checkSumBytes[:]) // Calculate the current fork checksum and the next fork block var next uint64 @@ -119,7 +122,11 @@ func newFilter(config *params.ChainConfig, genesis common.Hash, headfn func() ui forks = gatherForks(config) sums = make([][4]byte, len(forks)+1) // 0th is the genesis ) - hash := crc32.ChecksumIEEE(genesis[:]) + // CheckSum now has to be hash of Genesis and Location because in order to + // use the Disco crawler and use the same enr tree for all chains location + // serves as a unique identifier for filtering enodes + checkSumBytes := append(genesis[:], config.Location...) + hash := crc32.ChecksumIEEE(checkSumBytes[:]) sums[0] = checksumToBytes(hash) for i, fork := range forks { hash = checksumUpdate(hash, fork)