Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/main' into add-getblock-engine…
Browse files Browse the repository at this point in the history
…-methods

Signed-off-by: Simon Dudley <simon.dudley@consensys.net>
  • Loading branch information
siladu committed Jan 26, 2023
2 parents 663e11e + 835769d commit 2139828
Show file tree
Hide file tree
Showing 7 changed files with 42 additions and 45 deletions.
4 changes: 3 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@
- Improve get account performance by using the world state updater cache [#4897](https://github.com/hyperledger/besu/pull/4897)
- Add new KZG precompile and option to override the trusted setup being used [#4822](https://github.com/hyperledger/besu/issues/4822)
- Add implementation for eth_createAccessList RPC method [#4942](https://github.com/hyperledger/besu/pull/4942)
- Add implementation for engine_getPayloadBodiesByRangeV1 and engine_getPayloadBodiesByHashV1 [#4980](https://github.com/hyperledger/besu/pull/4980)
- Add implementation for engine_exchangeCapabilities [#4997](https://github.com/hyperledger/besu/pull/4997)
- Add implementation for engine_getPayloadBodiesByRangeV1 and engine_getPayloadBodiesByHashV1 [#4980](https://github.com/hyperledger/besu/pull/4980)
- Updated reference tests to v11.3 [#4996](https://github.com/hyperledger/besu/pull/4996)

### Bug Fixes

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
import org.hyperledger.besu.ethereum.core.MutableWorldState;
import org.hyperledger.besu.ethereum.core.ParsedExtraData;
import org.hyperledger.besu.ethereum.core.Transaction;
import org.hyperledger.besu.ethereum.core.Withdrawal;
import org.hyperledger.besu.ethereum.mainnet.MainnetBlockHeaderFunctions;
import org.hyperledger.besu.ethereum.rlp.BytesValueRLPInput;
import org.hyperledger.besu.ethereum.rlp.RLPInput;
Expand All @@ -40,6 +41,7 @@
import org.hyperledger.besu.evm.worldstate.WorldUpdater;

import java.util.Map;
import java.util.Optional;

import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
Expand Down Expand Up @@ -259,11 +261,10 @@ public Block getBlock() {
final BlockBody body =
new BlockBody(
input.readList(Transaction::readFrom),
input.readList(inputData -> BlockHeader.readFrom(inputData, blockHeaderFunctions)));
// input.readList(inputData -> BlockHeader.readFrom(inputData, blockHeaderFunctions),
// input.isEndOfCurrentList()
// ? Optional.empty()
// : Optional.of(input.readList(Withdrawal::readFrom))));
input.readList(inputData -> BlockHeader.readFrom(inputData, blockHeaderFunctions)),
input.isEndOfCurrentList()
? Optional.empty()
: Optional.of(input.readList(Withdrawal::readFrom)));
return new Block(header, body);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ private static MainnetTransactionValidator transactionValidator(final String nam

public static Stream<Arguments> getTestParametersForConfig() {
return JsonTestParameters.create(TransactionTestCaseSpec.class)
.generator((name, spec, collector) -> collector.add(name, spec, true))
.generator((name, fullPath, spec, collector) -> collector.add(name, fullPath, spec, true))
.generate(TEST_CONFIG_FILE_DIR_PATH).stream().map(params -> Arguments.of(params[0], params[1]));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,20 +56,16 @@ public class BlockchainReferenceTestTools {
private static final JsonTestParameters<?, ?> params =
JsonTestParameters.create(BlockchainReferenceTestCaseSpec.class)
.generator(
(testName, spec, collector) -> {
(testName, fullPath, spec, collector) -> {
final String eip = spec.getNetwork();
collector.add(testName + "[" + eip + "]", spec, NETWORKS_TO_RUN.contains(eip));
collector.add(testName + "[" + eip + "]", fullPath, spec, NETWORKS_TO_RUN.contains(eip));
});

static {
if (NETWORKS_TO_RUN.isEmpty()) {
params.ignoreAll();
}

// Known bad test.
params.ignore(
"RevertPrecompiledTouch(_storage)?_d(0|3)g0v0_(EIP158|Byzantium|Constantinople|ConstantinopleFix)");

// Consumes a huge amount of memory
params.ignore("static_Call1MB1024Calldepth_d1g0v0_\\w+");
params.ignore("ShanghaiLove_.*");
Expand All @@ -85,6 +81,9 @@ public class BlockchainReferenceTestTools {
// chain head.
// Perfectly valid test pre-merge.
params.ignore("UncleFromSideChain_Merge");

// EIP tests are explicitly meant to be works-in-progress with known failing tests
params.ignore("/EIPTests/");
}

private BlockchainReferenceTestTools() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,18 +69,18 @@ private static MainnetTransactionProcessor transactionProcessor(final String nam
private static final JsonTestParameters<?, ?> params =
JsonTestParameters.create(GeneralStateTestCaseSpec.class, GeneralStateTestCaseEipSpec.class)
.generator(
(testName, stateSpec, collector) -> {
(testName, fullPath, stateSpec, collector) -> {
final String prefix = testName + "-";
for (final Map.Entry<String, List<GeneralStateTestCaseEipSpec>> entry :
stateSpec.finalStateSpecs().entrySet()) {
final String eip = entry.getKey();
final boolean runTest = EIPS_TO_RUN.contains(eip);
final List<GeneralStateTestCaseEipSpec> eipSpecs = entry.getValue();
if (eipSpecs.size() == 1) {
collector.add(prefix + eip, eipSpecs.get(0), runTest);
collector.add(prefix + eip, fullPath, eipSpecs.get(0), runTest);
} else {
for (int i = 0; i < eipSpecs.size(); i++) {
collector.add(prefix + eip + '[' + i + ']', eipSpecs.get(i), runTest);
collector.add(prefix + eip + '[' + i + ']', fullPath, eipSpecs.get(i), runTest);
}
}
}
Expand All @@ -91,20 +91,16 @@ private static MainnetTransactionProcessor transactionProcessor(final String nam
params.ignoreAll();
}

// Known incorrect test.
params.ignore(
"RevertPrecompiledTouch(_storage)?-(EIP158|Byzantium|Constantinople|ConstantinopleFix)");

// Gas integer value is too large to construct a valid transaction.
params.ignore("OverflowGasRequire");

// Consumes a huge amount of memory
params.ignore("static_Call1MB1024Calldepth-\\w");
params.ignore("ShanghaiLove_.*");

// Don't do time consuming tests
params.ignore("CALLBlake2f_MaxRounds.*");
params.ignore("loopMul-.*");

// EIP tests are explicitly meant to be works-in-progress with known failing tests
params.ignore("/EIPTests/");
}

private GeneralStateReferenceTestTools() {
Expand Down Expand Up @@ -152,13 +148,17 @@ public static void executeTest(final GeneralStateTestCaseEipSpec spec) {
new BlockHashLookup(blockHeader, blockchain),
false,
TransactionValidationParams.processingBlock());
if (!result.isInvalid()) {
final Account coinbase = worldStateUpdater.getOrCreate(spec.getBlockHeader().getCoinbase());
if (coinbase != null && coinbase.isEmpty() && shouldClearEmptyAccounts(spec.getFork())) {
worldStateUpdater.deleteAccount(coinbase.getAddress());
}
worldStateUpdater.commit();
if (result.isInvalid()) {
assertThat(spec.getExpectException()).isNotNull();
return;
}
assertThat(spec.getExpectException()).withFailMessage("Exception was expected - " + spec.getExpectException()).isNull();

final Account coinbase = worldStateUpdater.getOrCreate(spec.getBlockHeader().getCoinbase());
if (coinbase != null && coinbase.isEmpty() && shouldClearEmptyAccounts(spec.getFork())) {
worldStateUpdater.deleteAccount(coinbase.getAddress());
}
worldStateUpdater.commit();

// Check the world state root hash.
final Hash expectedRootHash = spec.getExpectedRootHash();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,11 +76,14 @@ private Collector(@Nullable final Predicate<String> includes, final Predicate<St
* Add.
*
* @param name the name
* @param fullPath the full path of the test
* @param value the value
* @param runTest the run test
*/
public void add(final String name, final S value, final boolean runTest) {
testParameters.add(new Object[] {name, value, runTest && includes(name)});
public void add(
final String name, final String fullPath, final S value, final boolean runTest) {
testParameters.add(
new Object[] {name, value, runTest && includes(name) && includes(fullPath)});
}

private boolean includes(final String name) {
Expand Down Expand Up @@ -110,10 +113,11 @@ public interface Generator<S, T> {
* Generate.
*
* @param name the name
* @param fullPath the full path of the test
* @param mappedType the mapped type
* @param collector the collector
*/
void generate(String name, S mappedType, Collector<T> collector);
void generate(String name, String fullPath, S mappedType, Collector<T> collector);
}

private static final ObjectMapper objectMapper =
Expand Down Expand Up @@ -152,7 +156,8 @@ private JsonTestParameters(final Class<S> jsonFileMappedType, final Class<T> tes
*/
public static <T> JsonTestParameters<T, T> create(final Class<T> testCaseSpec) {
return new JsonTestParameters<>(testCaseSpec, testCaseSpec)
.generator((name, testCase, collector) -> collector.add(name, testCase, true));
.generator(
(name, fullPath, testCase, collector) -> collector.add(name, fullPath, testCase, true));
}

/**
Expand Down Expand Up @@ -220,16 +225,6 @@ public JsonTestParameters<S, T> generator(final Generator<S, T> generator) {
return this;
}

/**
* Generate collection.
*
* @param path the path
* @return the collection
*/
public Collection<Object[]> generate(final String path) {
return generate(new String[] {path});
}

/**
* Generate collection.
*
Expand All @@ -253,7 +248,7 @@ private Collection<Object[]> generate(final Collection<File> filteredFiles) {
for (final Map.Entry<String, S> entry : testCase.testCaseSpecs.entrySet()) {
final String testName = entry.getKey();
final S mappedType = entry.getValue();
generator.generate(testName, mappedType, collector);
generator.generate(testName, file.getPath(), mappedType, collector);
}
}
return collector.getParameters();
Expand Down

0 comments on commit 2139828

Please sign in to comment.