Ensure no in-memory execution when --experimental.overlay=false (#4708)

* Ensure no in-memory execution when --experimental.overlay=false

* bump log level

* canExtendInMemory -> canExtendFork

* forgot to FeedHeaderPoS

* small simplification
This commit is contained in:
Andrew Ashikhmin 2022-07-13 18:54:43 +01:00 committed by GitHub
parent 8c27879a6b
commit af58e427f1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -587,9 +587,9 @@ func verifyAndSaveNewPoSHeader(
currentHeadHash := rawdb.ReadHeadHeaderHash(tx)
canExtendCanonical := header.ParentHash == currentHeadHash
canExtendInMemory := cfg.memoryOverlay && (cfg.forkValidator.ExtendingForkHeadHash() == (common.Hash{}) || header.ParentHash == cfg.forkValidator.ExtendingForkHeadHash())
canExtendFork := cfg.forkValidator.ExtendingForkHeadHash() == (common.Hash{}) || header.ParentHash == cfg.forkValidator.ExtendingForkHeadHash()
if canExtendInMemory || !canExtendCanonical {
if cfg.memoryOverlay && (canExtendFork || !canExtendCanonical) {
status, latestValidHash, validationError, criticalError := cfg.forkValidator.ValidatePayload(tx, header, body, canExtendCanonical)
if criticalError != nil {
return &privateapi.PayloadStatus{CriticalError: criticalError}, false, criticalError
@ -608,11 +608,16 @@ func verifyAndSaveNewPoSHeader(
}, success, nil
}
// OK, we're on the canonical chain
if err := headerInserter.FeedHeaderPoS(tx, header, headerHash); err != nil {
return nil, false, err
}
if !canExtendCanonical {
log.Info("Side chain or something weird", "parentHash", header.ParentHash, "currentHead", currentHeadHash)
return &privateapi.PayloadStatus{Status: remote.EngineStatus_ACCEPTED}, true, nil
}
// OK, we're on the canonical chain
if requestStatus == engineapi.New {
cfg.hd.SetPendingPayloadHash(headerHash)
}