Engine API: Don't build payload if requested timestamp is invalid
This commit is contained in:
parent
3fe0a49a5e
commit
ddfaf2a4df
|
@ -78,7 +78,7 @@ proc forkchoiceUpdated*(ben: BeaconEngineRef,
|
||||||
# that should be fixed, not papered over.
|
# that should be fixed, not papered over.
|
||||||
if not ben.get(blockHash, header):
|
if not ben.get(blockHash, header):
|
||||||
warn "Forkchoice requested unknown head",
|
warn "Forkchoice requested unknown head",
|
||||||
hash = blockHash
|
hash = blockHash.short
|
||||||
return simpleFCU(PayloadExecutionStatus.syncing)
|
return simpleFCU(PayloadExecutionStatus.syncing)
|
||||||
|
|
||||||
# Header advertised via a past newPayload request. Start syncing to it.
|
# Header advertised via a past newPayload request. Start syncing to it.
|
||||||
|
@ -107,16 +107,16 @@ proc forkchoiceUpdated*(ben: BeaconEngineRef,
|
||||||
if not db.getTd(blockHash, td) or (blockNumber > 0'u64 and not db.getTd(header.parentHash, ptd)):
|
if not db.getTd(blockHash, td) or (blockNumber > 0'u64 and not db.getTd(header.parentHash, ptd)):
|
||||||
error "TDs unavailable for TTD check",
|
error "TDs unavailable for TTD check",
|
||||||
number = blockNumber,
|
number = blockNumber,
|
||||||
hash = blockHash,
|
hash = blockHash.short,
|
||||||
td = td,
|
td = td,
|
||||||
parent = header.parentHash,
|
parent = header.parentHash.short,
|
||||||
ptd = ptd
|
ptd = ptd
|
||||||
return simpleFCU(PayloadExecutionStatus.invalid, "TDs unavailable for TDD check")
|
return simpleFCU(PayloadExecutionStatus.invalid, "TDs unavailable for TDD check")
|
||||||
|
|
||||||
if td < ttd or (blockNumber > 0'u64 and ptd > ttd):
|
if td < ttd or (blockNumber > 0'u64 and ptd > ttd):
|
||||||
error "Refusing beacon update to pre-merge",
|
error "Refusing beacon update to pre-merge",
|
||||||
number = blockNumber,
|
number = blockNumber,
|
||||||
hash = blockHash,
|
hash = blockHash.short,
|
||||||
diff = header.difficulty,
|
diff = header.difficulty,
|
||||||
ptd = ptd,
|
ptd = ptd,
|
||||||
ttd = ttd
|
ttd = ttd
|
||||||
|
@ -146,20 +146,20 @@ proc forkchoiceUpdated*(ben: BeaconEngineRef,
|
||||||
var finalBlock: common.BlockHeader
|
var finalBlock: common.BlockHeader
|
||||||
if not db.getBlockHeader(finalizedBlockHash, finalBlock):
|
if not db.getBlockHeader(finalizedBlockHash, finalBlock):
|
||||||
warn "Final block not available in database",
|
warn "Final block not available in database",
|
||||||
hash=finalizedBlockHash
|
hash=finalizedBlockHash.short
|
||||||
raise invalidParams("finalized block header not available")
|
raise invalidParams("finalized block header not available")
|
||||||
var finalHash: common.Hash256
|
var finalHash: common.Hash256
|
||||||
if not db.getBlockHash(finalBlock.blockNumber, finalHash):
|
if not db.getBlockHash(finalBlock.blockNumber, finalHash):
|
||||||
warn "Final block not in canonical chain",
|
warn "Final block not in canonical chain",
|
||||||
number=finalBlock.blockNumber,
|
number=finalBlock.blockNumber,
|
||||||
hash=finalizedBlockHash
|
hash=finalizedBlockHash.short
|
||||||
raise invalidParams("finalized block hash not available")
|
raise invalidParams("finalized block hash not available")
|
||||||
if finalHash != finalizedBlockHash:
|
if finalHash != finalizedBlockHash:
|
||||||
warn "Final block not in canonical chain",
|
warn "Final block not in canonical chain",
|
||||||
number=finalBlock.blockNumber,
|
number=finalBlock.blockNumber,
|
||||||
expect=finalizedBlockHash,
|
expect=finalizedBlockHash.short,
|
||||||
get=finalHash
|
get=finalHash.short
|
||||||
raise invalidParams("finalilized block not canonical")
|
raise invalidParams("finalized block not canonical")
|
||||||
db.finalizedHeaderHash(finalizedBlockHash)
|
db.finalizedHeaderHash(finalizedBlockHash)
|
||||||
|
|
||||||
let safeBlockHash = ethHash update.safeBlockHash
|
let safeBlockHash = ethHash update.safeBlockHash
|
||||||
|
@ -167,18 +167,18 @@ proc forkchoiceUpdated*(ben: BeaconEngineRef,
|
||||||
var safeBlock: common.BlockHeader
|
var safeBlock: common.BlockHeader
|
||||||
if not db.getBlockHeader(safeBlockHash, safeBlock):
|
if not db.getBlockHeader(safeBlockHash, safeBlock):
|
||||||
warn "Safe block not available in database",
|
warn "Safe block not available in database",
|
||||||
hash = safeBlockHash
|
hash = safeBlockHash.short
|
||||||
raise invalidParams("safe head not available")
|
raise invalidParams("safe head not available")
|
||||||
var safeHash: common.Hash256
|
var safeHash: common.Hash256
|
||||||
if not db.getBlockHash(safeBlock.blockNumber, safeHash):
|
if not db.getBlockHash(safeBlock.blockNumber, safeHash):
|
||||||
warn "Safe block hash not available in database",
|
warn "Safe block hash not available in database",
|
||||||
hash = safeHash
|
hash = safeHash.short
|
||||||
raise invalidParams("safe block hash not available")
|
raise invalidParams("safe block hash not available")
|
||||||
if safeHash != safeBlockHash:
|
if safeHash != safeBlockHash:
|
||||||
warn "Safe block not in canonical chain",
|
warn "Safe block not in canonical chain",
|
||||||
blockNumber=safeBlock.blockNumber,
|
blockNumber=safeBlock.blockNumber,
|
||||||
expect=safeBlockHash,
|
expect=safeBlockHash.short,
|
||||||
get=safeHash
|
get=safeHash.short
|
||||||
raise invalidParams("safe head not canonical")
|
raise invalidParams("safe head not canonical")
|
||||||
db.safeHeaderHash(safeBlockHash)
|
db.safeHeaderHash(safeBlockHash)
|
||||||
|
|
||||||
|
|
|
@ -165,6 +165,9 @@ proc generatePayload*(ben: BeaconEngineRef,
|
||||||
# reorg
|
# reorg
|
||||||
discard xp.smartHead(headBlock)
|
discard xp.smartHead(headBlock)
|
||||||
|
|
||||||
|
if pos.timestamp <= headBlock.timestamp:
|
||||||
|
return err "timestamp must be strictly later than parent"
|
||||||
|
|
||||||
# someBaseFee = true: make sure blk.header
|
# someBaseFee = true: make sure blk.header
|
||||||
# have the same blockHash with generated payload
|
# have the same blockHash with generated payload
|
||||||
let blk = xp.ethBlock(someBaseFee = true)
|
let blk = xp.ethBlock(someBaseFee = true)
|
||||||
|
|
Loading…
Reference in New Issue