mirror of
https://github.com/vacp2p/linea-besu.git
synced 2026-01-08 23:17:54 -05:00
Update reference tests to 12.4 (#5899)
* Update reference tests to 12.4 Update reference tests to 12.4 * Some in-memory storage changed to ConcurrentMap * exclude cancun from all EIP tests, EIP-4788 still in flux * Add new fields to ReferenceTestEnv, and re-order the reflected constructor for clarity and ease of development. Signed-off-by: Danno Ferrin <danno.ferrin@swirldslabs.com> * spotless Signed-off-by: Danno Ferrin <danno.ferrin@swirldslabs.com> --------- Signed-off-by: Danno Ferrin <danno.ferrin@swirldslabs.com> Co-authored-by: Sally MacFarlane <macfarla.github@gmail.com>
This commit is contained in:
@@ -18,9 +18,10 @@ import org.hyperledger.besu.plugin.services.storage.SegmentIdentifier;
|
||||
|
||||
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;
|
||||
@@ -51,9 +52,10 @@ public class InMemoryKeyValueStorage extends SegmentedKeyValueStorageAdapter {
|
||||
}
|
||||
};
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
@@ -25,6 +25,7 @@ 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.Lock;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
@@ -59,7 +60,7 @@ public class LayeredKeyValueStorage extends SegmentedInMemoryKeyValueStorage
|
||||
* @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;
|
||||
|
||||
@@ -30,6 +30,8 @@ import java.util.List;
|
||||
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;
|
||||
@@ -46,14 +48,14 @@ import org.apache.tuweni.bytes.Bytes;
|
||||
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<>());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -62,7 +64,7 @@ public class 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;
|
||||
}
|
||||
|
||||
@@ -76,8 +78,8 @@ public class SegmentedInMemoryKeyValueStorage
|
||||
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
|
||||
@@ -214,7 +216,9 @@ public class SegmentedInMemoryKeyValueStorage
|
||||
// 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
|
||||
|
||||
Reference in New Issue
Block a user