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

Update reference tests to 12.4 #5899

Merged
merged 4 commits into from
Sep 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion ethereum/referencetests/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ tasks.register('validateReferenceTestSubmodule') {
description = "Checks that the reference tests submodule is not accidentally changed"
doLast {
def result = new ByteArrayOutputStream()
def expectedHash = '06e276776bc87817c38f6efb492bf6f4527fa904'
def expectedHash = '661356317ac6df52208d54187e692472a25a01f8'
def submodulePath = java.nio.file.Path.of("${rootProject.projectDir}", "ethereum/referencetests/src/reference-test/external-resources").toAbsolutePath()
try {
exec {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,33 +97,35 @@ Withdrawal asWithdrawal() {
*/
@JsonCreator
public ReferenceTestEnv(
@JsonProperty("beaconRoot") final String beaconRoot,
@JsonProperty("blockHashes") final Map<String, String> blockHashes,
@JsonProperty("ommers") final List<String> _ommers,

Check notice

Code scanning / CodeQL

Useless parameter

The parameter '_ommers' is never used.
@JsonProperty("previousHash") final String previousHash,
@JsonProperty("withdrawals") final List<EnvWithdrawal> withdrawals,
@JsonProperty("currentBaseFee") final String baseFee,
@JsonProperty("currentBeaconRoot") final String currentBeaconRoot,
@JsonProperty("currentBlobGasUsed") final String currentBlobGasUsed,
@JsonProperty("currentCoinbase") final String coinbase,
@JsonProperty("currentDataGasUsed") final String currentDataGasUsed,
@JsonProperty("currentDifficulty") final String difficulty,
@JsonProperty("currentExcessBlobGas") final String currentExcessBlobGas,
@JsonProperty("currentExcessDataGas") final String currentExcessDataGas,
@JsonProperty("currentGasLimit") final String gasLimit,
@JsonProperty("currentNumber") final String number,
@JsonProperty("currentBaseFee") final String baseFee,
@JsonProperty("currentTimestamp") final String timestamp,
@JsonProperty("currentRandom") final String random,
@JsonProperty("currentStateRoot") final String stateRoot,
@JsonProperty("previousHash") final String previousHash,
@JsonProperty("parentDifficulty") final String parentDifficulty,
@JsonProperty("currentTimestamp") final String timestamp,
@JsonProperty("currentWithdrawalsRoot") final String currentWithdrawalsRoot,
@JsonProperty("parentBaseFee") final String parentBaseFee,
@JsonProperty("parentGasUsed") final String parentGasUsed,
@JsonProperty("parentGasLimit") final String parentGasLimit,
@JsonProperty("parentTimestamp") final String parentTimestamp,
@JsonProperty("ommers") final List<String> _ommers,
@JsonProperty("parentUncleHash") final String _parentUncleHash,
@JsonProperty("withdrawals") final List<EnvWithdrawal> withdrawals,
@JsonProperty("blockHashes") final Map<String, String> blockHashes,
@JsonProperty("currentExcessBlobGas") final String currentExcessBlobGas,
@JsonProperty("currentBlobGasUsed") final String currentBlobGasUsed,
@JsonProperty("currentExcessDataGas") final String currentExcessDataGas,
@JsonProperty("currentDataGasUsed") final String currentDataGasUsed,
@JsonProperty("parentExcessBlobGas") final String parentExcessBlobGas,
@JsonProperty("parentBlobGasUsed") final String parentBlobGasUsed,
@JsonProperty("parentExcessDataGas") final String parentExcessDataGas,
@JsonProperty("parentDataGasUsed") final String parentDataGasUsed,
@JsonProperty("beaconRoot") final String beaconRoot) {
@JsonProperty("parentDifficulty") final String parentDifficulty,
@JsonProperty("parentExcessBlobGas") final String parentExcessBlobGas,
@JsonProperty("parentExcessDataGas") final String parentExcessDataGas,
@JsonProperty("parentGasLimit") final String parentGasLimit,
@JsonProperty("parentGasUsed") final String parentGasUsed,
@JsonProperty("parentTimestamp") final String parentTimestamp,
@JsonProperty("parentUncleHash") final String _parentUncleHash) {

Check notice

Code scanning / CodeQL

Useless parameter

The parameter '_parentUncleHash' is never used.
super(
generateTestBlockHash(previousHash, number),
Hash.EMPTY_LIST_HASH, // ommersHash
Expand All @@ -141,7 +143,7 @@ public ReferenceTestEnv(
Optional.ofNullable(baseFee).map(Wei::fromHexString).orElse(null),
Optional.ofNullable(random).map(Difficulty::fromHexString).orElse(Difficulty.ZERO),
0L,
null, // withdrawalsRoot
currentWithdrawalsRoot == null ? null : Hash.fromHexString(currentWithdrawalsRoot),
currentBlobGasUsed == null
? currentDataGasUsed == null ? null : Long.decode(currentDataGasUsed)
: Long.decode(currentBlobGasUsed),
Expand Down Expand Up @@ -172,7 +174,10 @@ public ReferenceTestEnv(
Map.entry(
Long.decode(entry.getKey()), Hash.fromHexString(entry.getValue())))
.collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue));
this.beaconRoot = beaconRoot == null ? null : Hash.fromHexString(beaconRoot);
this.beaconRoot =
beaconRoot == null
? (currentBeaconRoot == null ? null : Hash.fromHexString(currentBeaconRoot))
: Hash.fromHexString(beaconRoot);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,9 @@ public class BlockchainReferenceTestTools {
params.ignore("blobhashListBounds5");
params.ignore("blockWithAllTransactionTypes");

// EIP-4788 is still in flux and the current fill is not against the final address
params.ignore("[Cancun]");

// EOF tests are written against an older version of the spec
params.ignore("/stEOF/");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,10 @@

import java.io.PrintStream;
import java.nio.charset.StandardCharsets;
import java.util.HashMap;
import java.util.Map;
import java.util.Optional;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;
import java.util.concurrent.locks.ReadWriteLock;

import org.apache.tuweni.bytes.Bytes;
Expand Down Expand Up @@ -51,9 +52,10 @@ public boolean containsStaticData() {
}
};

private static Map<SegmentIdentifier, Map<Bytes, Optional<byte[]>>> asSegmentMap(
private static ConcurrentMap<SegmentIdentifier, Map<Bytes, Optional<byte[]>>> asSegmentMap(
final Map<Bytes, Optional<byte[]>> initialMap) {
final Map<SegmentIdentifier, Map<Bytes, Optional<byte[]>>> segmentMap = new HashMap<>();
final ConcurrentMap<SegmentIdentifier, Map<Bytes, Optional<byte[]>>> segmentMap =
new ConcurrentHashMap<>();
segmentMap.put(SEGMENT_IDENTIFIER, initialMap);
return segmentMap;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import java.util.Map;
import java.util.Optional;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;
import java.util.concurrent.locks.Lock;
import java.util.stream.Collectors;
import java.util.stream.Stream;
Expand Down Expand Up @@ -59,7 +60,7 @@ public LayeredKeyValueStorage(final SegmentedKeyValueStorage parent) {
* @param parent the parent key value storage for this layered storage.
*/
public LayeredKeyValueStorage(
final Map<SegmentIdentifier, Map<Bytes, Optional<byte[]>>> map,
final ConcurrentMap<SegmentIdentifier, Map<Bytes, Optional<byte[]>>> map,
final SegmentedKeyValueStorage parent) {
super(map);
this.parent = parent;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@
import java.util.Map;
import java.util.Optional;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;
import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReadWriteLock;
import java.util.concurrent.locks.ReentrantReadWriteLock;
Expand All @@ -46,14 +48,14 @@
public class SegmentedInMemoryKeyValueStorage
implements SnappedKeyValueStorage, SnappableKeyValueStorage, SegmentedKeyValueStorage {
/** protected access for the backing hash map. */
final Map<SegmentIdentifier, Map<Bytes, Optional<byte[]>>> hashValueStore;
final ConcurrentMap<SegmentIdentifier, Map<Bytes, Optional<byte[]>>> hashValueStore;

/** protected access to the rw lock. */
protected final ReadWriteLock rwLock = new ReentrantReadWriteLock();

/** Instantiates a new In memory key value storage. */
public SegmentedInMemoryKeyValueStorage() {
this(new HashMap<>());
this(new ConcurrentHashMap<>());
}

/**
Expand All @@ -62,7 +64,7 @@ public SegmentedInMemoryKeyValueStorage() {
* @param hashValueStore the hash value store
*/
protected SegmentedInMemoryKeyValueStorage(
final Map<SegmentIdentifier, Map<Bytes, Optional<byte[]>>> hashValueStore) {
final ConcurrentMap<SegmentIdentifier, Map<Bytes, Optional<byte[]>>> hashValueStore) {
this.hashValueStore = hashValueStore;
}

Expand All @@ -76,8 +78,8 @@ public SegmentedInMemoryKeyValueStorage(final List<SegmentIdentifier> segments)
segments.stream()
.collect(
Collectors
.<SegmentIdentifier, SegmentIdentifier, Map<Bytes, Optional<byte[]>>>toMap(
s -> s, s -> new HashMap<>())));
.<SegmentIdentifier, SegmentIdentifier, Map<Bytes, Optional<byte[]>>>
toConcurrentMap(s -> s, s -> new ConcurrentHashMap<>())));
}

@Override
Expand Down Expand Up @@ -214,7 +216,9 @@ public SegmentedInMemoryKeyValueStorage takeSnapshot() {
// need to clone the submaps also:
return new SegmentedInMemoryKeyValueStorage(
hashValueStore.entrySet().stream()
.collect(Collectors.toMap(Map.Entry::getKey, e -> new HashMap<>(e.getValue()))));
.collect(
Collectors.toConcurrentMap(
Map.Entry::getKey, e -> new ConcurrentHashMap<>(e.getValue()))));
}

@Override
Expand Down