Skip to content
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

EIP-7685 #7068

Merged
Merged

Conversation

Gabriel-Trintinalia
Copy link
Contributor

@Gabriel-Trintinalia Gabriel-Trintinalia commented May 7, 2024

Description

General purpose execution layer requests eip-7685

This PR implements the generic execution layer requests.

Fixes #6985, #6986 and the last item of #6800

Main changes:

  • Removal of depositsRoot and withdrawalRequestRoot from the blockheader
  • Removal of deposit and withdrawal requests from the block body
  • Introduction of requestsRoot in the blockHeader
  • Introduction of requests in the block body
  • Introduction of Generic Request Type
  • Removed depoistValidator and withdrawalRequestValidator
  • Added a generic Request decoder/encoder
  • Introduction of RequestValidatorCoordinator and RequestProcessorCoordinator
  • Extract the processing logic of deposits and withdrawalRequests from block creation and block processing to new DepositProcessor and WithdrawalRequestProcessor
  • Replaced of depositValidatorProvider and withdrawalRequestValidatorProvider by RequestValidadorProvider
  • Change logic in the engine methods to use the correct validator to validate requests
  • Adapts deposit existing tests and withdrawal existing tests to use the new classess
  • Adds generic validation to the request list (Request root, request ordering, etc)

This PR does not ensure the logic of Deposits and withdrawalRequests but encapsulates them into a generic request list that is used to calculate the new requestRoot. The engine API has not changed and the requests are still split into deposits and withdrawalRequests.

To do:

  • Add more unit tests

lucassaldanha and others added 25 commits April 18, 2024 11:37
Signed-off-by: Lucas Saldanha <lucascrsaldanha@gmail.com>
Signed-off-by: Lucas Saldanha <lucascrsaldanha@gmail.com>
Signed-off-by: Lucas Saldanha <lucascrsaldanha@gmail.com>
Signed-off-by: Lucas Saldanha <lucascrsaldanha@gmail.com>
Signed-off-by: Lucas Saldanha <lucascrsaldanha@gmail.com>
Signed-off-by: Gabriel-Trintinalia <gabriel.trintinalia@consensys.net>
Signed-off-by: Gabriel-Trintinalia <gabriel.trintinalia@consensys.net>
Signed-off-by: Gabriel-Trintinalia <gabriel.trintinalia@consensys.net>
Signed-off-by: Gabriel-Trintinalia <gabriel.trintinalia@consensys.net>
Signed-off-by: Gabriel-Trintinalia <gabriel.trintinalia@consensys.net>
Signed-off-by: Gabriel-Trintinalia <gabriel.trintinalia@consensys.net>
Signed-off-by: Gabriel-Trintinalia <gabriel.trintinalia@consensys.net>
Signed-off-by: Gabriel-Trintinalia <gabriel.trintinalia@consensys.net>
Signed-off-by: Gabriel-Trintinalia <gabriel.trintinalia@consensys.net>
Signed-off-by: Gabriel-Trintinalia <gabriel.trintinalia@consensys.net>
Signed-off-by: Gabriel-Trintinalia <gabriel.trintinalia@consensys.net>
Signed-off-by: Gabriel-Trintinalia <gabriel.trintinalia@consensys.net>
Signed-off-by: Gabriel-Trintinalia <gabriel.trintinalia@consensys.net>
Signed-off-by: Gabriel-Trintinalia <gabriel.trintinalia@consensys.net>
Signed-off-by: Gabriel-Trintinalia <gabriel.trintinalia@consensys.net>
Signed-off-by: Gabriel-Trintinalia <gabriel.trintinalia@consensys.net>
Signed-off-by: Gabriel-Trintinalia <gabriel.trintinalia@consensys.net>
Signed-off-by: Gabriel-Trintinalia <gabriel.trintinalia@consensys.net>
Signed-off-by: Gabriel-Trintinalia <gabriel.trintinalia@consensys.net>
Signed-off-by: Gabriel-Trintinalia <gabriel.trintinalia@consensys.net>
@Gabriel-Trintinalia
Copy link
Contributor Author

@ensi321 @lucassaldanha

@Gabriel-Trintinalia Gabriel-Trintinalia self-assigned this May 9, 2024
Signed-off-by: Gabriel-Trintinalia <gabriel.trintinalia@consensys.net>
Gabriel-Trintinalia and others added 8 commits May 12, 2024 10:20
Signed-off-by: Gabriel-Trintinalia <gabriel.trintinalia@consensys.net>
Signed-off-by: Gabriel-Trintinalia <gabriel.trintinalia@consensys.net>
Signed-off-by: Gabriel-Trintinalia <gabriel.trintinalia@consensys.net>
Signed-off-by: Gabriel-Trintinalia <gabriel.trintinalia@consensys.net>
Signed-off-by: Gabriel-Trintinalia <gabriel.trintinalia@consensys.net>
Signed-off-by: Justin Florentine <justin+github@florentine.us>
Signed-off-by: Gabriel-Trintinalia <gabriel.trintinalia@consensys.net>
import org.hyperledger.besu.ethereum.rlp.RLP;
import org.hyperledger.besu.ethereum.rlp.RLPOutput;

import org.apache.tuweni.bytes.Bytes;

public class DepositEncoder {

public static void encode(final Deposit deposit, final RLPOutput rlpOutput) {
public static void encode(final Request request, final RLPOutput rlpOutput) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like that we are using composition over inheritance with these codecs.

* @throws IllegalArgumentException if the serialized type value does not correspond to any {@link
* RequestType}.
*/
public static RequestType of(final int serializedTypeValue) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would rather just treat the request type as bytes and just pass the requestType byte in from the RequestDecoder

if (requests == null) {
return Collections.emptyList();
}
return requests.stream().filter(requestType::isInstance).map(requestType::cast).toList();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we use the enum RequestType to filter on instead of filtering by the class?

return validateRequests(block, maybeRequests.get(), receipts);
}

public boolean validateRoot(final Block block, final Optional<List<Request>> requests) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This method isn't being used anywhere

@@ -170,16 +166,12 @@ public Optional<Hash> getWithdrawalsRoot() {
}

/**
* Returns the block deposits root hash.
* Returns the block request root hash.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: should be requests root hash

* @throws IllegalArgumentException if the provided request is not a WithdrawalRequest.
*/
public static void encode(final Request request, final RLPOutput rlpOutput) {
if (!(request instanceof WithdrawalRequest withdrawalRequest)) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rather use the Request.getType() and check it is a deposit rather than doing an instanceof

@@ -91,36 +89,15 @@ public static Hash withdrawalsRoot(final List<Withdrawal> withdrawals) {
}

/**
* Generates the deposits root for a list of deposits
* Generates the request root for a list of requests
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: request root

* RequestType}.
*/
public static RequestType of(final int serializedTypeValue) {
return Arrays.stream(RequestType.values())
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would a switch statement be easier/more performant?

return RequestDecoder.decode(rlpInput);
}

public void writeTo(final RLPOutput out) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we do not need an implementation here!

@Gabriel-Trintinalia Gabriel-Trintinalia marked this pull request as ready for review May 13, 2024 08:31
return Optional.empty();
}
List<Deposit> deposits = findDepositsFromReceipts(transactionReceipts);
return Optional.of(deposits.stream().map(r -> (Request) r).toList());
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If RequestProcessor.process arg type was List<? extends Request> instead of List<Request> could avoid the additional iteration to cast to the right type.

Signed-off-by: Gabriel-Trintinalia <gabriel.trintinalia@consensys.net>
Signed-off-by: Gabriel-Trintinalia <gabriel.trintinalia@consensys.net>
Signed-off-by: Gabriel-Trintinalia <gabriel.trintinalia@consensys.net>
Signed-off-by: Gabriel-Trintinalia <gabriel.trintinalia@consensys.net>
Signed-off-by: Gabriel-Trintinalia <gabriel.trintinalia@consensys.net>
@Gabriel-Trintinalia Gabriel-Trintinalia changed the title WIP EIP-7685 EIP-7685 May 13, 2024
Signed-off-by: Gabriel-Trintinalia <gabriel.trintinalia@consensys.net>
@Gabriel-Trintinalia Gabriel-Trintinalia marked this pull request as draft May 14, 2024 09:02
Signed-off-by: Gabriel-Trintinalia <gabriel.trintinalia@consensys.net>
@Gabriel-Trintinalia Gabriel-Trintinalia marked this pull request as ready for review May 15, 2024 07:15
@Gabriel-Trintinalia Gabriel-Trintinalia merged commit f9a61a0 into hyperledger:main May 15, 2024
42 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

EIP-6110: Update implementation to use EIP-7685
5 participants