core: remove unnecessary check that storedcfg matches newcfg before writing to disk

This commit is contained in:
Aaron Buchwald 2023-08-26 19:27:18 -04:00
parent f174ddba7a
commit 0cd0ef29d9
No known key found for this signature in database
GPG key ID: 3433467056CC7B55

View file

@ -367,7 +367,6 @@ func SetupGenesisBlockWithOverride(db ethdb.Database, triedb *trie.Database, gen
rawdb.WriteChainConfig(db, stored, newcfg) rawdb.WriteChainConfig(db, stored, newcfg)
return newcfg, stored, nil return newcfg, stored, nil
} }
storedData, _ := json.Marshal(storedcfg)
// Special case: if a private network is being used (no genesis and also no // Special case: if a private network is being used (no genesis and also no
// mainnet hash in the database), we must not apply the `configOrDefault` // mainnet hash in the database), we must not apply the `configOrDefault`
// chain config as that would be AllProtocolChanges (applying any new fork // chain config as that would be AllProtocolChanges (applying any new fork
@ -387,10 +386,7 @@ func SetupGenesisBlockWithOverride(db ethdb.Database, triedb *trie.Database, gen
if compatErr != nil && ((head.Number.Uint64() != 0 && compatErr.RewindToBlock != 0) || (head.Time != 0 && compatErr.RewindToTime != 0)) { if compatErr != nil && ((head.Number.Uint64() != 0 && compatErr.RewindToBlock != 0) || (head.Time != 0 && compatErr.RewindToTime != 0)) {
return newcfg, stored, compatErr return newcfg, stored, compatErr
} }
// Don't overwrite if the old is identical to the new
if newData, _ := json.Marshal(newcfg); !bytes.Equal(storedData, newData) {
rawdb.WriteChainConfig(db, stored, newcfg) rawdb.WriteChainConfig(db, stored, newcfg)
}
return newcfg, stored, nil return newcfg, stored, nil
} }