Cleanup Comments & Fix get_pow_block_hash_at_ttd() (#2835)
This commit is contained in:
parent
1b56ebf85e
commit
c2f2813385
@ -624,18 +624,6 @@ mod test {
|
||||
.await
|
||||
.with_preloaded_responses(
|
||||
// engine_forkchoiceUpdatedV1 (prepare payload) RESPONSE validation
|
||||
//
|
||||
// NOTE THIS HAD TO BE MODIFIED FROM ORIGINAL RESPONSE
|
||||
// {
|
||||
// "jsonrpc":"2.0",
|
||||
// "id":67,
|
||||
// "result":{
|
||||
// "status":"VALID", // <- This must be SUCCESS
|
||||
// "payloadId":"0xa247243752eb10b4"
|
||||
// }
|
||||
// }
|
||||
// see spec for engine_forkchoiceUpdatedV1 response:
|
||||
// https://github.com/ethereum/execution-apis/blob/v1.0.0-alpha.4/src/engine/specification.md#response-1
|
||||
vec![json!({
|
||||
"id": STATIC_ID,
|
||||
"jsonrpc": JSONRPC_VERSION,
|
||||
@ -779,18 +767,6 @@ mod test {
|
||||
.await
|
||||
.with_preloaded_responses(
|
||||
// engine_executePayloadV1 RESPONSE validation
|
||||
//
|
||||
// NOTE THIS HAD TO BE MODIFIED FROM ORIGINAL RESPONSE
|
||||
// {
|
||||
// "jsonrpc":"2.0",
|
||||
// "id":67,
|
||||
// "result":{
|
||||
// "status":"SUCCESS", // <- This must be VALID
|
||||
// "latestValidHash":"0x3559e851470f6e7bbed1db474980683e8c315bfce99b2a6ef47c057c04de7858"
|
||||
// }
|
||||
// }
|
||||
// see spec for engine_executePayloadV1 response:
|
||||
// https://github.com/ethereum/execution-apis/blob/v1.0.0-alpha.4/src/engine/specification.md#response
|
||||
vec![json!({
|
||||
"jsonrpc": JSONRPC_VERSION,
|
||||
"id": STATIC_ID,
|
||||
@ -852,7 +828,7 @@ mod test {
|
||||
"id": STATIC_ID,
|
||||
"result": {
|
||||
"status":"SUCCESS",
|
||||
"payloadId": serde_json::Value::Null
|
||||
"payloadId": JSON_NULL,
|
||||
}
|
||||
})],
|
||||
|client| async move {
|
||||
|
@ -530,24 +530,23 @@ impl ExecutionLayer {
|
||||
// this implementation becomes canonical.
|
||||
loop {
|
||||
let block_reached_ttd = block.total_difficulty >= spec.terminal_total_difficulty;
|
||||
if block_reached_ttd && block.parent_hash == Hash256::zero() {
|
||||
return Ok(Some(block.block_hash));
|
||||
} else if block.parent_hash == Hash256::zero() {
|
||||
// The end of the chain has been reached without finding the TTD, there is no
|
||||
// terminal block.
|
||||
return Ok(None);
|
||||
}
|
||||
if block_reached_ttd {
|
||||
if block.parent_hash == Hash256::zero() {
|
||||
return Ok(Some(block.block_hash));
|
||||
}
|
||||
let parent = self
|
||||
.get_pow_block(engine, block.parent_hash)
|
||||
.await?
|
||||
.ok_or(ApiError::ExecutionBlockNotFound(block.parent_hash))?;
|
||||
let parent_reached_ttd = parent.total_difficulty >= spec.terminal_total_difficulty;
|
||||
|
||||
let parent = self
|
||||
.get_pow_block(engine, block.parent_hash)
|
||||
.await?
|
||||
.ok_or(ApiError::ExecutionBlockNotFound(block.parent_hash))?;
|
||||
let parent_reached_ttd = parent.total_difficulty >= spec.terminal_total_difficulty;
|
||||
|
||||
if block_reached_ttd && !parent_reached_ttd {
|
||||
return Ok(Some(block.block_hash));
|
||||
if block_reached_ttd && !parent_reached_ttd {
|
||||
return Ok(Some(block.block_hash));
|
||||
} else {
|
||||
block = parent;
|
||||
}
|
||||
} else {
|
||||
block = parent;
|
||||
return Ok(None);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user