fix safeBlockHash handling in engine_forkchoiceUpdatedV1
This commit is contained in:
parent
1008e87ec2
commit
54724b87dc
|
@ -115,8 +115,6 @@ proc setupEngineAPI*(
|
||||||
var payload: ExecutionPayloadV1
|
var payload: ExecutionPayloadV1
|
||||||
if not api.get(payloadId, payload):
|
if not api.get(payloadId, payload):
|
||||||
raise (ref InvalidRequest)(code: engineApiUnknownPayload, msg: "Unknown payload")
|
raise (ref InvalidRequest)(code: engineApiUnknownPayload, msg: "Unknown payload")
|
||||||
#raise newException(ValueError, "Unknown payload")
|
|
||||||
|
|
||||||
return payload
|
return payload
|
||||||
|
|
||||||
# https://github.com/ethereum/execution-apis/blob/v1.0.0-alpha.7/src/engine/specification.md#engine_exchangeTransitionConfigurationV1
|
# https://github.com/ethereum/execution-apis/blob/v1.0.0-alpha.7/src/engine/specification.md#engine_exchangeTransitionConfigurationV1
|
||||||
|
@ -229,7 +227,9 @@ proc setupEngineAPI*(
|
||||||
error "Refusing beacon update to pre-merge",
|
error "Refusing beacon update to pre-merge",
|
||||||
number = blockNumber,
|
number = blockNumber,
|
||||||
hash = blockHash.data.toHex,
|
hash = blockHash.data.toHex,
|
||||||
diff = header.difficulty
|
diff = header.difficulty,
|
||||||
|
ptd = ptd,
|
||||||
|
ttd = ttd
|
||||||
|
|
||||||
return simpleFCU(PayloadExecutionStatus.invalid_terminal_block)
|
return simpleFCU(PayloadExecutionStatus.invalid_terminal_block)
|
||||||
|
|
||||||
|
@ -257,12 +257,37 @@ proc setupEngineAPI*(
|
||||||
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.data.toHex
|
hash=finalizedBlockHash.data.toHex
|
||||||
return simpleFCU(PayloadExecutionStatus.invalid, "final block not available")
|
raise (ref InvalidRequest)(code: engineApiInvalidParams, msg: "finalized block header not available")
|
||||||
elif not db.getBlockHash(finalBlock.blockNumber, canonHash) or canonHash != finalizedBlockHash:
|
var finalHash: Hash256
|
||||||
|
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.data.toHex
|
hash=finalizedBlockHash.data.toHex
|
||||||
return simpleFCU(PayloadExecutionStatus.invalid, "final block not canonical")
|
raise (ref InvalidRequest)(code: engineApiInvalidParams, msg: "finalized block hash not available")
|
||||||
|
if finalHash != finalizedBlockHash:
|
||||||
|
warn "Final block not in canonical chain",
|
||||||
|
number=finalBlock.blockNumber,
|
||||||
|
finalHash=finalHash.data.toHex,
|
||||||
|
finalizedBlockHash=finalizedBlockHash.data.toHex
|
||||||
|
raise (ref InvalidRequest)(code: engineApiInvalidParams, msg: "finalilized block not canonical")
|
||||||
|
|
||||||
|
let safeBlockHash = update.safeBlockHash.asEthHash
|
||||||
|
if safeBlockHash != Hash256():
|
||||||
|
var safeBlock: EthBlockHeader
|
||||||
|
if not db.getBlockHeader(safeBlockHash, safeBlock):
|
||||||
|
warn "Safe block not available in database",
|
||||||
|
hash = safeBlockHash.data.toHex
|
||||||
|
raise (ref InvalidRequest)(code: engineApiInvalidParams, msg: "safe head not available")
|
||||||
|
var safeHash: Hash256
|
||||||
|
if not db.getBlockHash(safeBlock.blockNumber, safeHash):
|
||||||
|
warn "Safe block hash not available in database",
|
||||||
|
hash = safeHash.data.toHex
|
||||||
|
raise (ref InvalidRequest)(code: engineApiInvalidParams, msg: "safe block hash not available")
|
||||||
|
if safeHash != safeBlockHash:
|
||||||
|
warn "Safe block not in canonical chain",
|
||||||
|
safeHash=safeHash.data.toHex,
|
||||||
|
safeBlockHash=safeBlockHash.data.toHex
|
||||||
|
raise (ref InvalidRequest)(code: engineApiInvalidParams, msg: "safe head not canonical")
|
||||||
|
|
||||||
# If payload generation was requested, create a new block to be potentially
|
# If payload generation was requested, create a new block to be potentially
|
||||||
# sealed by the beacon client. The payload will be requested later, and we
|
# sealed by the beacon client. The payload will be requested later, and we
|
||||||
|
|
Loading…
Reference in New Issue