-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Shanghai Engine API Updates #4945
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 8 commits
5f987b5
ba28dd7
b16eb09
d78a9c2
c7af1d5
3cdd6d1
ec23294
5c05882
df5302b
04c1f9a
add7a66
76833fb
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -17,7 +17,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.SYNCING; | ||||||
| import static org.hyperledger.besu.ethereum.api.jsonrpc.internal.methods.ExecutionEngineJsonRpcMethod.EngineStatus.VALID; | ||||||
| import static org.hyperledger.besu.ethereum.api.jsonrpc.internal.parameters.WithdrawalParameterTestFixture.WITHDRAWAL_PARAM_1; | ||||||
|
|
@@ -42,6 +41,7 @@ | |||||
| import org.hyperledger.besu.ethereum.api.jsonrpc.RpcMethod; | ||||||
| import org.hyperledger.besu.ethereum.api.jsonrpc.internal.JsonRpcRequest; | ||||||
| import org.hyperledger.besu.ethereum.api.jsonrpc.internal.JsonRpcRequestContext; | ||||||
| import org.hyperledger.besu.ethereum.api.jsonrpc.internal.methods.ExecutionEngineJsonRpcMethod; | ||||||
| import org.hyperledger.besu.ethereum.api.jsonrpc.internal.parameters.EnginePayloadParameter; | ||||||
| import org.hyperledger.besu.ethereum.api.jsonrpc.internal.parameters.UnsignedLongParameter; | ||||||
| import org.hyperledger.besu.ethereum.api.jsonrpc.internal.parameters.WithdrawalParameter; | ||||||
|
|
@@ -169,8 +169,9 @@ public void shouldReturnAcceptedOnLatestValidAncestorEmpty() { | |||||
| .thenReturn(Optional.of(mock(BlockHeader.class))); | ||||||
| when(mergeCoordinator.getLatestValidAncestor(any(BlockHeader.class))) | ||||||
| .thenReturn(Optional.empty()); | ||||||
| when(mergeCoordinator.latestValidAncestorDescendsFromTerminal(any(BlockHeader.class))) | ||||||
| .thenReturn(true); | ||||||
| if (validateTerminalPoWBlock()) | ||||||
| when(mergeCoordinator.latestValidAncestorDescendsFromTerminal(any(BlockHeader.class))) | ||||||
| .thenReturn(true); | ||||||
|
|
||||||
| var resp = resp(mockPayload(mockHeader, Collections.emptyList())); | ||||||
|
|
||||||
|
|
@@ -198,6 +199,7 @@ public void shouldReturnSuccessOnAlreadyPresent() { | |||||
|
|
||||||
| @Test | ||||||
| public void shouldReturnInvalidOnBadTerminalBlock() { | ||||||
| if (!validateTerminalPoWBlock()) return; | ||||||
|
siladu marked this conversation as resolved.
Outdated
|
||||||
| BlockHeader mockHeader = createBlockHeader(); | ||||||
| when(blockchain.getBlockByHash(mockHeader.getHash())).thenReturn(Optional.empty()); | ||||||
| when(blockchain.getBlockHeader(mockHeader.getParentHash())) | ||||||
|
|
@@ -268,8 +270,9 @@ public void shouldNotReturnInvalidOnThrownMerkleTrieException() { | |||||
| .thenReturn(Optional.of(mock(BlockHeader.class))); | ||||||
| when(mergeCoordinator.getLatestValidAncestor(any(BlockHeader.class))) | ||||||
| .thenReturn(Optional.of(mockHash)); | ||||||
| when(mergeCoordinator.latestValidAncestorDescendsFromTerminal(any(BlockHeader.class))) | ||||||
| .thenReturn(true); | ||||||
| if (validateTerminalPoWBlock()) | ||||||
| when(mergeCoordinator.latestValidAncestorDescendsFromTerminal(any(BlockHeader.class))) | ||||||
| .thenReturn(true); | ||||||
| when(mergeCoordinator.rememberBlock(any())).thenThrow(new MerkleTrieException("missing leaf")); | ||||||
|
|
||||||
| var resp = resp(mockPayload(mockHeader, Collections.emptyList())); | ||||||
|
|
@@ -288,7 +291,7 @@ public void shouldReturnInvalidBlockHashOnBadHashParameter() { | |||||
|
|
||||||
| EnginePayloadStatusResult res = fromSuccessResp(resp); | ||||||
| assertThat(res.getLatestValidHash()).isEmpty(); | ||||||
| assertThat(res.getStatusAsString()).isEqualTo(INVALID_BLOCK_HASH.name()); | ||||||
| assertThat(res.getStatusAsString()).isEqualTo(getCorrectInvalidBlockHashStatus().name()); | ||||||
| verify(engineCallListener, times(1)).executionEngineCalled(); | ||||||
| } | ||||||
|
|
||||||
|
|
@@ -302,7 +305,7 @@ public void shouldCheckBlockValidityBeforeCheckingByHashForExisting() { | |||||
|
|
||||||
| EnginePayloadStatusResult res = fromSuccessResp(resp); | ||||||
| assertThat(res.getLatestValidHash()).isEmpty(); | ||||||
| assertThat(res.getStatusAsString()).isEqualTo(INVALID_BLOCK_HASH.name()); | ||||||
| assertThat(res.getStatusAsString()).isEqualTo(getCorrectInvalidBlockHashStatus().name()); | ||||||
| verify(engineCallListener, times(1)).executionEngineCalled(); | ||||||
| } | ||||||
|
|
||||||
|
|
@@ -526,12 +529,21 @@ private BlockHeader setupValidPayload(final BlockProcessingResult value) { | |||||
| .thenReturn(Optional.of(mock(BlockHeader.class))); | ||||||
| when(mergeCoordinator.getLatestValidAncestor(any(BlockHeader.class))) | ||||||
| .thenReturn(Optional.of(mockHash)); | ||||||
| when(mergeCoordinator.latestValidAncestorDescendsFromTerminal(any(BlockHeader.class))) | ||||||
| .thenReturn(true); | ||||||
| if (validateTerminalPoWBlock()) | ||||||
| when(mergeCoordinator.latestValidAncestorDescendsFromTerminal(any(BlockHeader.class))) | ||||||
| .thenReturn(true); | ||||||
| when(mergeCoordinator.rememberBlock(any())).thenReturn(value); | ||||||
| return mockHeader; | ||||||
| } | ||||||
|
|
||||||
| protected boolean validateTerminalPoWBlock() { | ||||||
| return false; | ||||||
| } | ||||||
|
|
||||||
| protected ExecutionEngineJsonRpcMethod.EngineStatus getCorrectInvalidBlockHashStatus() { | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I prefer 'expected' over 'correct' like your other tests: expectedInvalidBlockHashStatus
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. or just getInvalidBlockHashStatus
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'd prefer expected too - since we expect different status for the same error for V1 and V2. |
||||||
| return INVALID; | ||||||
| } | ||||||
|
|
||||||
| private EnginePayloadStatusResult fromSuccessResp(final JsonRpcResponse resp) { | ||||||
| assertThat(resp.getType()).isEqualTo(JsonRpcResponseType.SUCCESS); | ||||||
| return Optional.of(resp) | ||||||
|
|
||||||
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -15,6 +15,9 @@ | |||||
| 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_BLOCK_HASH; | ||||||
|
|
||||||
| import org.hyperledger.besu.ethereum.api.jsonrpc.internal.methods.ExecutionEngineJsonRpcMethod; | ||||||
|
|
||||||
| import org.junit.Test; | ||||||
| import org.junit.runner.RunWith; | ||||||
|
|
@@ -32,4 +35,14 @@ public EngineNewPayloadV1Test() { | |||||
| public void shouldReturnExpectedMethodName() { | ||||||
| assertThat(method.getName()).isEqualTo("engine_newPayloadV1"); | ||||||
| } | ||||||
|
|
||||||
| @Override | ||||||
| protected boolean validateTerminalPoWBlock() { | ||||||
| return true; | ||||||
| } | ||||||
|
|
||||||
| @Override | ||||||
| protected ExecutionEngineJsonRpcMethod.EngineStatus getCorrectInvalidBlockHashStatus() { | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
| return INVALID_BLOCK_HASH; | ||||||
| } | ||||||
| } | ||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I didn't see this change mentioned in ethereum/execution-apis#338 - is this something different?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yea, bring some changes from ethereum/execution-apis#337 too. Sorry should have updated the description.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
my bad, I got Zhenyang to crowbar that change in too :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok makes sense