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-7702: devnet-4 changes #7809

Merged
merged 51 commits into from
Dec 3, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
51 commits
Select commit Hold shift + click to select a range
c71d4af
warm up to address at tx start if account is delegated, restrict auth…
daniellehrner Oct 2, 2024
67bab68
Merge branch 'main' into fix/issue-7706/warmup_to_when_delegated
daniellehrner Oct 3, 2024
49a4411
rename requestsRoot to requestsHash
jframe Oct 9, 2024
196bf10
return no code if account has delegated code to precompile, treat pre…
daniellehrner Oct 9, 2024
a2abff2
make accessListWarmAddresses generic again
daniellehrner Oct 9, 2024
dcefdce
Merge branch 'fix/issue-7706/warmup_to_when_delegated' into pectra-de…
daniellehrner Oct 9, 2024
6393399
warm delegatee account if transaction destination has delegated code
daniellehrner Oct 9, 2024
1269cc1
Merge branch 'main' into pectra-devnet4-7702
daniellehrner Oct 10, 2024
d7e5686
* verify auth nonce less than 2**64-1 during auth processing
daniellehrner Oct 10, 2024
cdc9bd5
generalised requests flat encoding and engine api changes
jframe Oct 14, 2024
cee6abc
javadoc
jframe Oct 14, 2024
8f346f4
get tests passing
jframe Oct 15, 2024
4e12780
get tests passing
jframe Oct 15, 2024
42e6865
Merge remote-tracking branch 'upstream/main' into 7685_flat_encoding
jframe Oct 15, 2024
f0d5a24
clean code
jframe Oct 15, 2024
0424317
change requests to single requestData for each requestType
jframe Oct 15, 2024
86f5049
fix PoWBlockCreatorTest after requests data type change
jframe Oct 15, 2024
722823e
don't return request type in getPayload result
jframe Oct 15, 2024
24a33e7
include requests in t8n response
jframe Oct 16, 2024
24de847
update contract addresses for consolidation requests and withdrawal r…
jframe Oct 16, 2024
532cb9d
fix requestHash calculation
jframe Oct 16, 2024
079bcfd
Ensure that execution requests always return a response
jframe Oct 16, 2024
9a98c12
Merge branch 'main' into pectra-devnet4-7702
daniellehrner Oct 16, 2024
c19f93f
Merge remote-tracking branch 'jason/7685_flat_encoding' into pectra-d…
daniellehrner Oct 16, 2024
bdb0cb3
added and fixed bound checks, fixed some compilation errors after the…
daniellehrner Oct 16, 2024
eff46b0
revert changes to evm tool spec tests
jframe Oct 17, 2024
1fdf0db
clean up
jframe Oct 17, 2024
9c2a623
replace AbstractSystemCallRequestProcessor to concrete class and remo…
jframe Oct 17, 2024
afd9023
spotless
jframe Oct 17, 2024
20ca19e
update evmtool tests for 7685 changes
jframe Oct 17, 2024
3ee1b31
use empty requests hash prague fork at genesis
jframe Oct 17, 2024
21b7aae
review suggestions
jframe Oct 17, 2024
6457be5
Merge remote-tracking branch 'jason/7685_flat_encoding' into pectra-d…
daniellehrner Oct 17, 2024
7522a77
temporarily comment out osakaTime from Prague
daniellehrner Oct 17, 2024
89d4950
Merge branch 'main' into pectra-devnet4-7702
daniellehrner Oct 17, 2024
7574c84
engine API validation
jframe Oct 18, 2024
ac812b2
Merge remote-tracking branch 'upstream/main' into 7685_flat_encoding
jframe Oct 18, 2024
95d1606
update plugin API hash
jframe Oct 18, 2024
4c62cae
fix GenesisStateTest
jframe Oct 18, 2024
9a317b1
Merge remote-tracking branch 'jason/7685_flat_encoding' into pectra-d…
daniellehrner Oct 18, 2024
8ab3aac
comment out unused evmWorldUpdater.parentUpdater() check
daniellehrner Oct 21, 2024
9ebc32b
Merge branch 'main' into pectra-devnet-4
daniellehrner Oct 24, 2024
75a3397
added CodeDelegationProcessorTest
daniellehrner Oct 27, 2024
759fab9
Merge branch 'main' into pectra-devnet-4
daniellehrner Nov 8, 2024
97af121
Merge branch 'main' into pectra-devnet-4
daniellehrner Nov 25, 2024
747cf4f
code clean up
daniellehrner Nov 27, 2024
9d5a47b
Merge branch 'main' into pectra-devnet-4
daniellehrner Nov 27, 2024
23b7ca1
Merge branch 'main' into pectra-devnet-4
daniellehrner Nov 29, 2024
2ea76d7
spotless
daniellehrner Nov 29, 2024
a8647e2
Merge branch 'main' into pectra-devnet-4
daniellehrner Dec 2, 2024
734a416
Merge branch 'main' into pectra-devnet-4
daniellehrner Dec 3, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Merge branch 'main' into pectra-devnet-4
Signed-off-by: Daniel Lehrner <daniel.lehrner@consensys.net>
  • Loading branch information
daniellehrner committed Oct 24, 2024
commit 9ebc32bf4184124747a3b257e9bb9a4c10976f71
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
import org.hyperledger.besu.datatypes.Address;
import org.hyperledger.besu.datatypes.Hash;
import org.hyperledger.besu.datatypes.Wei;
import org.hyperledger.besu.ethereum.BlockProcessingOutputs;
import org.hyperledger.besu.ethereum.BlockProcessingResult;
import org.hyperledger.besu.ethereum.ProtocolContext;
import org.hyperledger.besu.ethereum.blockcreation.BlockCreator.BlockCreationResult;
Expand Down Expand Up @@ -305,7 +304,7 @@ public PayloadIdentifier preparePayload(
new PayloadWrapper(
payloadIdentifier,
new BlockWithReceipts(emptyBlock, result.getReceipts()),
result.getYield().flatMap(BlockProcessingOutputs::getRequests)));
result.getRequests()));
LOG.info(
"Start building proposals for block {} identified by {}",
emptyBlock.getHeader().getNumber(),
Expand Down Expand Up @@ -474,7 +473,7 @@ private void evaluateNewBlock(
new PayloadWrapper(
payloadIdentifier,
new BlockWithReceipts(bestBlock, resultBest.getReceipts()),
resultBest.getYield().flatMap(BlockProcessingOutputs::getRequests)));
resultBest.getRequests()));
LOG.atDebug()
.setMessage(
"Successfully built block {} for proposal identified by {}, with {} transactions, in {}ms")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ public JsonRpcResponse syncResponse(final JsonRpcRequestContext requestContext)
} catch (JsonRpcParameterException e) {
throw new InvalidJsonRpcRequestException(
"Invalid execution request parameters (index 3)",
RpcErrorType.INVALID_REQUESTS_PARAMS,
RpcErrorType.INVALID_EXECUTION_REQUESTS_PARAMS,
e);
}

Expand Down Expand Up @@ -202,13 +202,13 @@ public JsonRpcResponse syncResponse(final JsonRpcRequestContext requestContext)
blockParam,
mergeCoordinator.getLatestValidAncestor(blockParam.getParentHash()).orElse(null),
INVALID,
"Invalid requests");
"Invalid execution requests");
}

if (!getRequestsValidator(
protocolSchedule.get(), blockParam.getTimestamp(), blockParam.getBlockNumber())
.validate(maybeRequests)) {
return new JsonRpcErrorResponse(reqId, RpcErrorType.INVALID_REQUESTS_PARAMS);
return new JsonRpcErrorResponse(reqId, RpcErrorType.INVALID_EXECUTION_REQUESTS_PARAMS);
}

if (mergeContext.get().isSyncing()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ protected ValidationResult<RpcErrorType> validateParameters(
"Missing parent beacon block root field");
} else if (maybeRequestsParam.isEmpty()) {
return ValidationResult.invalid(
RpcErrorType.INVALID_REQUESTS_PARAMS, "Missing execution requests field");
RpcErrorType.INVALID_EXECUTION_REQUESTS_PARAMS, "Missing execution requests field");
} else {
return ValidationResult.valid();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -281,12 +281,6 @@ private CreateOn blockCreatorWithBlobGasSupport() {
return createBlockCreator(protocolSpecAdapters);
}

// private CreateOn blockCreatorWithProhibitedDepositRequests() {
// final ProtocolSpecAdapters protocolSpecAdapters =
// ProtocolSpecAdapters.create(0, specBuilder -> specBuilder);
// return createBlockCreator(protocolSpecAdapters);
// }

private CreateOn blockCreatorWithWithdrawalsProcessor() {
final ProtocolSpecAdapters protocolSpecAdapters =
ProtocolSpecAdapters.create(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,13 @@
import org.hyperledger.besu.datatypes.Address;
import org.hyperledger.besu.datatypes.BlobGas;
import org.hyperledger.besu.datatypes.Hash;
import org.hyperledger.besu.datatypes.RequestType;
import org.hyperledger.besu.ethereum.core.Block;
import org.hyperledger.besu.ethereum.core.BlockBody;
import org.hyperledger.besu.ethereum.core.BlockHeader;
import org.hyperledger.besu.ethereum.core.BlockHeaderBuilder;
import org.hyperledger.besu.ethereum.core.Difficulty;
import org.hyperledger.besu.ethereum.core.MutableWorldState;
import org.hyperledger.besu.ethereum.core.Withdrawal;
import org.hyperledger.besu.ethereum.mainnet.BodyValidation;
import org.hyperledger.besu.ethereum.mainnet.ProtocolSchedule;
import org.hyperledger.besu.ethereum.mainnet.ScheduleBasedBlockHeaderFunctions;
import org.hyperledger.besu.ethereum.worldstate.DataStorageConfiguration;
Expand Down Expand Up @@ -219,19 +217,10 @@ private static BlockHeader buildHeader(
.excessBlobGas(isCancunAtGenesis(genesis) ? parseExcessBlobGas(genesis) : null)
.parentBeaconBlockRoot(
(isCancunAtGenesis(genesis) ? parseParentBeaconBlockRoot(genesis) : null))
.requestsHash(isPragueAtGenesis(genesis) ? calcEmptyRequestsHash() : null)
.requestsHash(isPragueAtGenesis(genesis) ? Hash.EMPTY_REQUESTS_HASH : null)
.buildBlockHeader();
}

private static Hash calcEmptyRequestsHash() {
final List<Request> emptyRequests =
List.of(
new Request(RequestType.DEPOSIT, Bytes.EMPTY),
new Request(RequestType.WITHDRAWAL, Bytes.EMPTY),
new Request(RequestType.CONSOLIDATION, Bytes.EMPTY));
return BodyValidation.requestsHash(emptyRequests);
}

private static Address parseCoinbase(final GenesisConfigFile genesis) {
return genesis
.getCoinbase()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,27 +14,26 @@
*/
package org.hyperledger.besu.ethereum.mainnet.requests;

import org.hyperledger.besu.datatypes.RequestType;
import org.hyperledger.besu.ethereum.core.Request;

import java.util.List;
import java.util.Optional;
import java.util.stream.IntStream;

import com.google.common.collect.Ordering;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
* Validates requests within a block against a set of predefined validators. This class delegates
* the validation of requests of specific types to corresponding validators. It ensures that
* requests are properly ordered, have a valid root, and meet the criteria defined by their
* requests are properly ordered, have a valid hash, and meet the criteria defined by their
* validators.
*/
public class MainnetRequestsValidator implements RequestsValidator {
private static final Logger LOG = LoggerFactory.getLogger(MainnetRequestsValidator.class);

/**
* Validates a block's requests by ensuring they are correctly ordered, have a valid root, and
* Validates a block's requests by ensuring they are correctly ordered, have a valid hash, and
* pass their respective type-specific validations.
*
* @param maybeRequests The list of requests to be validated.
Expand All @@ -52,21 +51,10 @@ public boolean validate(final Optional<List<Request>> maybeRequests) {
return false;
}

if (!allRequestTypesAreContained(maybeRequests.get())) {
LOG.warn("Requests must contain all request types");
return false;
}

return true;
}

private static boolean isRequestOrderValid(final List<Request> requests) {
return IntStream.range(0, requests.size() - 1)
.allMatch(i -> requests.get(i).getType().compareTo(requests.get(i + 1).getType()) <= 0);
}

private static boolean allRequestTypesAreContained(final List<Request> requests) {
return requests.stream().map(Request::getType).distinct().count()
== RequestType.values().length;
return Ordering.natural().onResultOf(Request::getType).isOrdered(requests);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -35,16 +35,10 @@ private RequestProcessorCoordinator(
this.processors = processors;
}

public Optional<List<Request>> process(final ProcessRequestContext context) {
List<Request> requests = null;
for (RequestProcessor requestProcessor : processors.values()) {
var r = requestProcessor.process(context);
if (requests == null) {
requests = new ArrayList<>();
}
requests.add(r);
}
return Optional.ofNullable(requests);
public List<Request> process(final ProcessRequestContext context) {
return processors.values().stream()
.map(requestProcessor -> requestProcessor.process(context))
.toList();
}

public static class Builder {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ public Request process(final ProcessRequestContext context) {
context.operationTracer(),
context.blockHashLookup());

Bytes requestData = systemCallOutput == null ? Bytes.EMPTY : systemCallOutput;
return new Request(requestType, requestData);
return new Request(requestType, systemCallOutput);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,6 @@ void validateFalseWhenNoRequests() {
assertFalse(validator.validate(Optional.empty()));
}

@Test
void validateFalseWhenEmptyListOfRequests() {
MainnetRequestsValidator validator = new MainnetRequestsValidator();
assertFalse(validator.validate(Optional.of(List.of())));
}

@Test
void validateFalseWhenRequestsNotInOrder() {
MainnetRequestsValidator validator = new MainnetRequestsValidator();
Expand All @@ -51,16 +45,6 @@ void validateFalseWhenRequestsNotInOrder() {
assertFalse(validator.validate(Optional.of(requests)));
}

@Test
void validateFalseWhenNotAllRequestTypesAreContained() {
MainnetRequestsValidator validator = new MainnetRequestsValidator();
List<Request> requests =
List.of(
new Request(RequestType.DEPOSIT, Bytes.of(1)),
new Request(RequestType.WITHDRAWAL, Bytes.of(2)));
assertFalse(validator.validate(Optional.of(requests)));
}

@Test
void validateTrueForValidRequests() {
MainnetRequestsValidator validator = new MainnetRequestsValidator();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -530,7 +530,7 @@ static T8nResult runTest(
receipts,
new CachingBlockHashLookup(blockHeader, blockchain),
OperationTracer.NO_TRACING);
Optional<List<Request>> maybeRequests = rpc.process(context);
Optional<List<Request>> maybeRequests = Optional.of(rpc.process(context));
Hash requestsHash = BodyValidation.requestsHash(maybeRequests.orElse(List.of()));

resultObject.put("requestsHash", requestsHash.toHexString());
Expand Down
Loading
You are viewing a condensed version of this merge commit. You can view the full changes here.