-
Notifications
You must be signed in to change notification settings - Fork 828
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
Change requests to use flat encoding #7771
Conversation
Signed-off-by: Jason Frame <jason.frame@consensys.net>
Signed-off-by: Jason Frame <jason.frame@consensys.net>
Signed-off-by: Jason Frame <jason.frame@consensys.net>
Signed-off-by: Jason Frame <jason.frame@consensys.net>
Signed-off-by: Jason Frame <jason.frame@consensys.net>
Signed-off-by: Jason Frame <jason.frame@consensys.net>
Signed-off-by: Jason Frame <jason.frame@consensys.net>
Signed-off-by: Jason Frame <jason.frame@consensys.net> don't return request type in getPayload result Signed-off-by: Jason Frame <jason.frame@consensys.net>
ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/BodyValidation.java
Show resolved
Hide resolved
ethereum/core/src/main/java/org/hyperledger/besu/ethereum/chain/GenesisState.java
Outdated
Show resolved
Hide resolved
.../src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/response/RpcErrorType.java
Outdated
Show resolved
Hide resolved
...rc/main/java/org/hyperledger/besu/ethereum/mainnet/requests/ProhibitedRequestsValidator.java
Outdated
Show resolved
Hide resolved
...eum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/requests/RequestsValidator.java
Outdated
Show resolved
Hide resolved
...eum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/requests/RequestsValidator.java
Outdated
Show resolved
Hide resolved
I would love to have |
Signed-off-by: Jason Frame <jason.frame@consensys.net>
…equests Signed-off-by: Jason Frame <jason.frame@consensys.net>
Signed-off-by: Jason Frame <jason.frame@consensys.net>
Signed-off-by: Jason Frame <jason.frame@consensys.net>
Signed-off-by: Jason Frame <jason.frame@consensys.net>
…ve specific processors Signed-off-by: Jason Frame <jason.frame@consensys.net>
Signed-off-by: Jason Frame <jason.frame@consensys.net>
Signed-off-by: Jason Frame <jason.frame@consensys.net>
Signed-off-by: Jason Frame <jason.frame@consensys.net>
Signed-off-by: Jason Frame <jason.frame@consensys.net>
Signed-off-by: Jason Frame <jason.frame@consensys.net>
Signed-off-by: Jason Frame <jason.frame@consensys.net>
Signed-off-by: Jason Frame <jason.frame@consensys.net>
…quests in new structure and contract code Signed-off-by: Jason Frame <jason.frame@consensys.net>
…rt of the comparison Signed-off-by: Jason Frame <jason.frame@consensys.net>
...src/test/java/org/hyperledger/besu/tests/acceptance/ethereum/PragueAcceptanceTestHelper.java
Outdated
Show resolved
Hide resolved
...src/test/java/org/hyperledger/besu/tests/acceptance/ethereum/PragueAcceptanceTestHelper.java
Outdated
Show resolved
Hide resolved
...merge/src/main/java/org/hyperledger/besu/consensus/merge/blockcreation/MergeCoordinator.java
Outdated
Show resolved
Hide resolved
...merge/src/main/java/org/hyperledger/besu/consensus/merge/blockcreation/MergeCoordinator.java
Outdated
Show resolved
Hide resolved
/** | ||
* Hash of empty requests or "0x6036c41849da9c076ed79654d434017387a88fb833c2856b32e18218b3341c5f" | ||
*/ | ||
public static final Hash EMPTY_REQUESTS_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.
Assuming this will change for devnet5?
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.
Yep this will change for devnet5. Will create another PR for that change though
if (!allRequestTypesAreContained(maybeRequests.get())) { | ||
LOG.warn("Requests must contain all request types"); | ||
return false; | ||
} |
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.
Will this work if we add a new request type for an futere fork?
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.
No it won't work as the list of request types will be different for each fork. This will also need to change for upcoming execution request changes, as there could be empty requests.
Maybe we don't even need this check? Think only the first two validations are actually necessary
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.
Removed this size check since we won't be able do this soon with the upcoming changes anyway
if (requests == null) { | ||
requests = new ArrayList<>(); | ||
} | ||
requests.add(r); |
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.
With this change, the only way to return Optional.Empty
is a processor coordinator with no processors. We can throw an exception in the builder if trying to build with empty processors and simplify this method to return List
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.
nice suggestion. I've done that and also simplified the process method to use a stream because doesn't need to consider nulls now
...src/main/java/org/hyperledger/besu/ethereum/mainnet/requests/SystemCallRequestProcessor.java
Outdated
Show resolved
Hide resolved
...e/src/main/java/org/hyperledger/besu/ethereum/mainnet/requests/MainnetRequestsValidator.java
Outdated
Show resolved
Hide resolved
...e/src/main/java/org/hyperledger/besu/ethereum/mainnet/requests/MainnetRequestsValidator.java
Outdated
Show resolved
Hide resolved
Signed-off-by: Jason Frame <jason.frame@consensys.net>
Signed-off-by: Jason Frame <jason.frame@consensys.net>
Signed-off-by: Jason Frame <jason.frame@consensys.net>
@jframe fyi, I am in the middle of reviewing |
Maybe even EngineExecutionRequest to further refine the scope? ExecutionRequest still pretty generic, unless understood within the context of the Engine API. If we need to cross a boundary from engine API to core domain, then does something like SystemCallRequest make sense? |
We have the deposit request that is not a a system call |
ContractRequest?? 😅 |
CLRequest? ConsensusRequest? EngineRequest? |
My preference is for ExecutionRequest and it also matches with what it's called in the engine API spec. In EIP 7685 it's just called Requests but easy enough to know it means ExecutionRequests. Also rather do that change in a separate PR once we agree on a name. |
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.
Sooo much deleted code, love it! +1,099 −5,067
Kudos to the spec authors too🏅
A few nits and questions - happy to approve if you think there's nothing further to change based on my comments.
consensus/merge/src/main/java/org/hyperledger/besu/consensus/merge/PayloadWrapper.java
Show resolved
Hide resolved
@@ -106,6 +106,7 @@ public JsonRpcResponse process( | |||
case INVALID_PROPOSAL_PARAMS: | |||
case INVALID_REMOTE_CAPABILITIES_PARAMS: | |||
case INVALID_REWARD_PERCENTILES_PARAMS: | |||
case INVALID_REQUESTS_PARAMS: |
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.
nit: a little close to INVALID_REQUEST
, maybe we could namespace with something, e.g. INVALID_EXECUTION_REQUESTS_PARAMS
or
INVALID_ENGINE_NEW_PAYLOAD_REQUESTS_PARAMS
(others already use this prefix)
General point: "requests" is a very overloaded name
Saw Gabriel mentioned changing to executionRequests.
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.
good idea, changed it to INVALID_EXECUTION_REQUESTS_PARAMS
return IntStream.range(0, requests.size() - 1) | ||
.allMatch(i -> requests.get(i).getType().compareTo(requests.get(i + 1).getType()) <= 0); |
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.
nit: guava has quite a neat way of doing this
return IntStream.range(0, requests.size() - 1) | |
.allMatch(i -> requests.get(i).getType().compareTo(requests.get(i + 1).getType()) <= 0); | |
return Ordering.natural().onResultOf(Request::getType).isOrdered(requests); |
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.
nice! much less code
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.
Enjoying the removal of lots of code, esp in this class :)
if (yield.isEmpty()) { | ||
return Optional.empty(); | ||
} else { | ||
return yield.get().getRequests(); | ||
} |
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.
if (yield.isEmpty()) { | |
return Optional.empty(); | |
} else { | |
return yield.get().getRequests(); | |
} | |
return yield.flatMap(BlockProcessingOutputs::getRequests); |
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.
done
ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/SystemCallProcessor.java
Show resolved
Hide resolved
.flatMap(receipt -> receipt.getLogsList().stream()) | ||
.filter(log -> address.equals(log.getLogger())) | ||
.map(DepositLogDecoder::decodeFromLog) | ||
.reduce(Bytes::concatenate)); |
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.
a nice fix for java stream junkies here ;)
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 remaining unresolved comments are only nits, nice to haves or namings
Signed-off-by: Jason Frame <jason.frame@consensys.net>
PR description
Update generalised request encoding for changes introduced in devnet4
EIP-7251: change request to flat encoding ethereum/EIPs#8857
EIP-6110: change request to flat encoding ethereum/EIPs#8856
EIP-7002: change request to flat encoding ethereum/EIPs#8855
EIP-7685: change requests hash to flat hash ethereum/EIPs#8854
EIP-7685: group requests into request-data ethereum/EIPs#8924
Make execution requests a sidecar, take 2 ethereum/execution-apis#591
Fixed Issue(s)
#7744
Thanks for sending a pull request! Have you done the following?
doc-change-required
label to this PR if updates are required.Locally, you can run these tests to catch failures early:
./gradlew build
./gradlew acceptanceTest
./gradlew integrationTest
./gradlew ethereum:referenceTests:referenceTests