mirror of
https://github.com/vacp2p/linea-besu.git
synced 2026-01-09 23:47:57 -05:00
Bonsai based reference test worldstate (#5686)
* create a bonsai based reference test worldstate -> getOrCreate in BonsaiWorldStateUpdateAccumulator - do not throw if we discover an empty account in a non-null BonsaiValue<Account> -> add curentStateRoot to t8n -> storageEntriesFrom and streamAccounts implemented in BonsaiWorldStateKeyValueStorage -> add endKey version of streamFromKey * bonsai fix for self-destruct and create2 at the same address and same block Signed-off-by: garyschulte <garyschulte@gmail.com> Signed-off-by: Karim TAAM <karim.t2am@gmail.com> Co-authored-by: Karim TAAM <karim.t2am@gmail.com>
This commit is contained in:
@@ -122,8 +122,18 @@ public class LayeredKeyValueStorage extends SegmentedInMemoryKeyValueStorage
|
||||
@Override
|
||||
public Stream<Pair<byte[], byte[]>> streamFromKey(
|
||||
final SegmentIdentifier segmentId, final byte[] startKey) {
|
||||
final Bytes startKeyBytes = Bytes.wrap(startKey);
|
||||
return stream(segmentId).filter(e -> startKeyBytes.compareTo(Bytes.wrap(e.getKey())) <= 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Stream<Pair<byte[], byte[]>> streamFromKey(
|
||||
final SegmentIdentifier segmentId, final byte[] startKey, final byte[] endKey) {
|
||||
final Bytes startKeyBytes = Bytes.wrap(startKey);
|
||||
final Bytes endKeyBytes = Bytes.wrap(endKey);
|
||||
return stream(segmentId)
|
||||
.filter(e -> Bytes.wrap(startKey).compareTo(Bytes.wrap(e.getKey())) <= 0);
|
||||
.filter(e -> startKeyBytes.compareTo(Bytes.wrap(e.getKey())) <= 0)
|
||||
.filter(e -> endKeyBytes.compareTo(Bytes.wrap(e.getKey())) >= 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -118,6 +118,13 @@ public class LimitedInMemoryKeyValueStorage implements KeyValueStorage {
|
||||
return stream().filter(e -> Bytes.wrap(startKey).compareTo(Bytes.wrap(e.getKey())) <= 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Stream<Pair<byte[], byte[]>> streamFromKey(final byte[] startKey, final byte[] endKey) {
|
||||
return stream()
|
||||
.filter(e -> Bytes.wrap(startKey).compareTo(Bytes.wrap(e.getKey())) <= 0)
|
||||
.takeWhile(e -> Bytes.wrap(endKey).compareTo(Bytes.wrap(e.getKey())) >= 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Stream<byte[]> streamKeys() {
|
||||
final Lock lock = rwLock.readLock();
|
||||
|
||||
@@ -149,8 +149,19 @@ public class SegmentedInMemoryKeyValueStorage
|
||||
@Override
|
||||
public Stream<Pair<byte[], byte[]>> streamFromKey(
|
||||
final SegmentIdentifier segmentIdentifier, final byte[] startKey) {
|
||||
final Bytes startKeyBytes = Bytes.wrap(startKey);
|
||||
return stream(segmentIdentifier)
|
||||
.filter(e -> Bytes.wrap(startKey).compareTo(Bytes.wrap(e.getKey())) <= 0);
|
||||
.filter(e -> startKeyBytes.compareTo(Bytes.wrap(e.getKey())) <= 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Stream<Pair<byte[], byte[]>> streamFromKey(
|
||||
final SegmentIdentifier segmentIdentifier, final byte[] startKey, final byte[] endKey) {
|
||||
final Bytes startKeyHash = Bytes.wrap(startKey);
|
||||
final Bytes endKeyHash = Bytes.wrap(endKey);
|
||||
return stream(segmentIdentifier)
|
||||
.filter(e -> startKeyHash.compareTo(Bytes.wrap(e.getKey())) <= 0)
|
||||
.filter(e -> endKeyHash.compareTo(Bytes.wrap(e.getKey())) >= 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -88,8 +88,14 @@ public class SegmentedKeyValueStorageAdapter implements KeyValueStorage {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Stream<Pair<byte[], byte[]>> streamFromKey(final byte[] startKey) throws StorageException {
|
||||
return storage.streamFromKey(segmentIdentifier, startKey);
|
||||
public Stream<Pair<byte[], byte[]>> streamFromKey(final byte[] startKeyHash)
|
||||
throws StorageException {
|
||||
return storage.streamFromKey(segmentIdentifier, startKeyHash);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Stream<Pair<byte[], byte[]>> streamFromKey(final byte[] startKey, final byte[] endKey) {
|
||||
return storage.streamFromKey(segmentIdentifier, startKey, endKey);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user