Replace deprecated INVALID_TERMINAL_BLOCK with INVALID lvh 0x0 (#3882)

Signed-off-by: Fabio Di Fabio <fabio.difabio@consensys.net>
pull/3889/head
Fabio Di Fabio 3 years ago committed by GitHub
parent 20daaf40a9
commit 5cdda94ab1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 3
      CHANGELOG.md
  2. 3
      ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/ExecutionEngineJsonRpcMethod.java
  3. 5
      ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/engine/EngineForkchoiceUpdated.java
  4. 6
      ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/engine/EngineNewPayload.java
  5. 3
      ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/results/EngineUpdateForkchoiceResult.java
  6. 16
      ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/engine/EngineForkchoiceUpdatedTest.java
  7. 7
      ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/engine/EngineNewPayloadTest.java

@ -2,6 +2,9 @@
## 22.4.2
### Additions and Improvements
- Engine API Update: Replace deprecated INVALID_TERMINAL_BLOCK with INVALID last valid hash 0x0 [#3882](https://github.com/hyperledger/besu/pull/3882)
### Bug Fixes
- Stop backward sync if genesis block has been reached [#3869](https://github.com/hyperledger/besu/pull/3869)
- Deprecate experimental merge flag and engine-rpc-enabled flag [#3875](https://github.com/hyperledger/besu/pull/3875)

@ -34,8 +34,7 @@ public abstract class ExecutionEngineJsonRpcMethod implements JsonRpcMethod {
INVALID,
SYNCING,
ACCEPTED,
INVALID_BLOCK_HASH,
INVALID_TERMINAL_BLOCK;
INVALID_BLOCK_HASH;
}
private final Vertx syncVertx;

@ -15,7 +15,6 @@
package org.hyperledger.besu.ethereum.api.jsonrpc.internal.methods.engine;
import static org.hyperledger.besu.ethereum.api.jsonrpc.internal.methods.ExecutionEngineJsonRpcMethod.EngineStatus.INVALID;
import static org.hyperledger.besu.ethereum.api.jsonrpc.internal.methods.ExecutionEngineJsonRpcMethod.EngineStatus.INVALID_TERMINAL_BLOCK;
import static org.hyperledger.besu.ethereum.api.jsonrpc.internal.methods.ExecutionEngineJsonRpcMethod.EngineStatus.SYNCING;
import static org.hyperledger.besu.ethereum.api.jsonrpc.internal.methods.ExecutionEngineJsonRpcMethod.EngineStatus.VALID;
import static org.hyperledger.besu.util.Slf4jLambdaHelper.debugLambda;
@ -107,8 +106,8 @@ public class EngineForkchoiceUpdated extends ExecutionEngineJsonRpcMethod {
return new JsonRpcSuccessResponse(
requestId,
new EngineUpdateForkchoiceResult(
INVALID_TERMINAL_BLOCK,
null,
INVALID,
Hash.ZERO,
null,
Optional.of(newHead.get() + " did not descend from terminal block")));
}

@ -17,7 +17,6 @@ package org.hyperledger.besu.ethereum.api.jsonrpc.internal.methods.engine;
import static org.hyperledger.besu.ethereum.api.jsonrpc.internal.methods.ExecutionEngineJsonRpcMethod.EngineStatus.ACCEPTED;
import static org.hyperledger.besu.ethereum.api.jsonrpc.internal.methods.ExecutionEngineJsonRpcMethod.EngineStatus.INVALID;
import static org.hyperledger.besu.ethereum.api.jsonrpc.internal.methods.ExecutionEngineJsonRpcMethod.EngineStatus.INVALID_BLOCK_HASH;
import static org.hyperledger.besu.ethereum.api.jsonrpc.internal.methods.ExecutionEngineJsonRpcMethod.EngineStatus.INVALID_TERMINAL_BLOCK;
import static org.hyperledger.besu.ethereum.api.jsonrpc.internal.methods.ExecutionEngineJsonRpcMethod.EngineStatus.SYNCING;
import static org.hyperledger.besu.ethereum.api.jsonrpc.internal.methods.ExecutionEngineJsonRpcMethod.EngineStatus.VALID;
import static org.hyperledger.besu.util.Slf4jLambdaHelper.traceLambda;
@ -165,7 +164,10 @@ public class EngineNewPayload extends ExecutionEngineJsonRpcMethod {
// TODO: post-merge cleanup
if (!mergeCoordinator.latestValidAncestorDescendsFromTerminal(newBlockHeader)) {
return respondWith(requestContext.getRequest().getId(), null, INVALID_TERMINAL_BLOCK);
return respondWithInvalid(
requestContext.getRequest().getId(),
Hash.ZERO,
newBlockHeader.getHash() + " did not descend from terminal block");
}
final var latestValidAncestor = mergeCoordinator.getLatestValidAncestor(newBlockHeader);

@ -15,7 +15,6 @@
package org.hyperledger.besu.ethereum.api.jsonrpc.internal.results;
import static org.hyperledger.besu.ethereum.api.jsonrpc.internal.methods.ExecutionEngineJsonRpcMethod.EngineStatus.INVALID;
import static org.hyperledger.besu.ethereum.api.jsonrpc.internal.methods.ExecutionEngineJsonRpcMethod.EngineStatus.INVALID_TERMINAL_BLOCK;
import static org.hyperledger.besu.ethereum.api.jsonrpc.internal.methods.ExecutionEngineJsonRpcMethod.EngineStatus.SYNCING;
import static org.hyperledger.besu.ethereum.api.jsonrpc.internal.methods.ExecutionEngineJsonRpcMethod.EngineStatus.VALID;
@ -34,7 +33,7 @@ public class EngineUpdateForkchoiceResult {
private final EnginePayloadStatusResult payloadStatus;
private final PayloadIdentifier payloadId;
static final EnumSet<EngineStatus> FORK_CHOICE_ENGINE_STATUS =
EnumSet.of(VALID, INVALID, SYNCING, INVALID_TERMINAL_BLOCK);
EnumSet.of(VALID, INVALID, SYNCING);
public EngineUpdateForkchoiceResult(
final EngineStatus status,

@ -16,7 +16,6 @@ package org.hyperledger.besu.ethereum.api.jsonrpc.internal.methods.engine;
import static org.assertj.core.api.Assertions.assertThat;
import static org.hyperledger.besu.ethereum.api.jsonrpc.internal.methods.ExecutionEngineJsonRpcMethod.EngineStatus.INVALID;
import static org.hyperledger.besu.ethereum.api.jsonrpc.internal.methods.ExecutionEngineJsonRpcMethod.EngineStatus.INVALID_TERMINAL_BLOCK;
import static org.hyperledger.besu.ethereum.api.jsonrpc.internal.methods.ExecutionEngineJsonRpcMethod.EngineStatus.SYNCING;
import static org.hyperledger.besu.ethereum.api.jsonrpc.internal.methods.ExecutionEngineJsonRpcMethod.EngineStatus.VALID;
import static org.mockito.ArgumentMatchers.any;
@ -101,14 +100,14 @@ public class EngineForkchoiceUpdatedTest {
}
@Test
public void shouldReturnInvalidTerminalBlock() {
public void shouldReturnInvalidOnBadTerminalBlock() {
BlockHeader mockHeader = new BlockHeaderTestFixture().baseFeePerGas(Wei.ONE).buildHeader();
when(blockchain.getBlockHeader(any())).thenReturn(Optional.of(mockHeader));
when(mergeCoordinator.latestValidAncestorDescendsFromTerminal(mockHeader)).thenReturn(false);
when(mergeCoordinator.isDescendantOf(any(), any())).thenReturn(true);
assertSuccessWithPayloadForForkchoiceResult(
Optional.empty(), mock(ForkchoiceResult.class), INVALID_TERMINAL_BLOCK);
Optional.empty(), mock(ForkchoiceResult.class), INVALID, Optional.of(Hash.ZERO));
}
@Test
@ -341,6 +340,15 @@ public class EngineForkchoiceUpdatedTest {
final Optional<EnginePayloadAttributesParameter> payloadParam,
final ForkchoiceResult forkchoiceResult,
final EngineStatus expectedStatus) {
return assertSuccessWithPayloadForForkchoiceResult(
payloadParam, forkchoiceResult, expectedStatus, Optional.empty());
}
private EngineUpdateForkchoiceResult assertSuccessWithPayloadForForkchoiceResult(
final Optional<EnginePayloadAttributesParameter> payloadParam,
final ForkchoiceResult forkchoiceResult,
final EngineStatus expectedStatus,
final Optional<Hash> maybeLatestValidHash) {
// result from mergeCoordinator has no new finalized, new head:
when(mergeCoordinator.updateForkChoice(
@ -364,7 +372,7 @@ public class EngineForkchoiceUpdatedTest {
}
} else {
// assert null latest valid and payload identifier:
assertThat(res.getPayloadStatus().getLatestValidHash()).isEmpty();
assertThat(res.getPayloadStatus().getLatestValidHash()).isEqualTo(maybeLatestValidHash);
assertThat(res.getPayloadId()).isNull();
}

@ -18,7 +18,6 @@ import static org.assertj.core.api.Assertions.assertThat;
import static org.hyperledger.besu.ethereum.api.jsonrpc.internal.methods.ExecutionEngineJsonRpcMethod.EngineStatus.ACCEPTED;
import static org.hyperledger.besu.ethereum.api.jsonrpc.internal.methods.ExecutionEngineJsonRpcMethod.EngineStatus.INVALID;
import static org.hyperledger.besu.ethereum.api.jsonrpc.internal.methods.ExecutionEngineJsonRpcMethod.EngineStatus.INVALID_BLOCK_HASH;
import static org.hyperledger.besu.ethereum.api.jsonrpc.internal.methods.ExecutionEngineJsonRpcMethod.EngineStatus.INVALID_TERMINAL_BLOCK;
import static org.hyperledger.besu.ethereum.api.jsonrpc.internal.methods.ExecutionEngineJsonRpcMethod.EngineStatus.SYNCING;
import static org.hyperledger.besu.ethereum.api.jsonrpc.internal.methods.ExecutionEngineJsonRpcMethod.EngineStatus.VALID;
import static org.mockito.ArgumentMatchers.any;
@ -164,7 +163,7 @@ public class EngineNewPayloadTest {
}
@Test
public void shouldReturnInvalidTerminalBlock() {
public void shouldReturnInvalidOnBadTerminalBlock() {
BlockHeader mockHeader = new BlockHeaderTestFixture().baseFeePerGas(Wei.ONE).buildHeader();
when(blockchain.getBlockByHash(any())).thenReturn(Optional.empty());
@ -177,8 +176,8 @@ public class EngineNewPayloadTest {
var resp = resp(mockPayload(mockHeader, Collections.emptyList()));
EnginePayloadStatusResult res = fromSuccessResp(resp);
assertThat(res.getLatestValidHash()).isEmpty();
assertThat(res.getStatusAsString()).isEqualTo(INVALID_TERMINAL_BLOCK.name());
assertThat(res.getLatestValidHash()).isEqualTo(Optional.of(Hash.ZERO));
assertThat(res.getStatusAsString()).isEqualTo(INVALID.name());
}
@Test

Loading…
Cancel
Save