Skip to content

Commit

Permalink
Fix for broken replay files
Browse files Browse the repository at this point in the history
This puts in place a simple fix for replay files which incorrectly
include StorageSnapshots for accounts which are to be created.  Such
snapshots confuse BESU into thinking their storage is not empty which,
in turn, prevents the accounts from being created (and then fails result
checking because the txs in question fail).

In principle, this fix should not be necessary because the BlockCapturer
has already been fixed to resolve this.  However, we still have a number
of older replay files in the repository and this fix resolves all of
time right now (i.e. so we don't have to wait for them to be recaptured,
etc).
  • Loading branch information
DavePearce committed Sep 25, 2024
1 parent ae20d75 commit 0a567b2
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,11 @@ public class Issue1124Tests {

@Test
void issue_1124_range_4323962_4324012() {
replay(LINEA_MAINNET, "4323962-4324012.json.gz", false);
replay(LINEA_MAINNET, "4323962-4324012.json.gz");
}

@Test
void issue_1124_range_4343434_4343473() {
replay(LINEA_MAINNET, "4343434-4343473.json.gz", false);
replay(LINEA_MAINNET, "4343434-4343473.json.gz");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ void test_3175608_3175636() {

@Test
void test_3432730_3432768() {
replay(LINEA_MAINNET, "3432730-3432768.json.gz", false);
replay(LINEA_MAINNET, "3432730-3432768.json.gz");
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ void issue_4065360_4065364() {
// the only test that fails for me ... and only if I set resultChecking to true
@Test
void issue_4065365_4065369() {
replay(LINEA_MAINNET, "4065365-4065369.json.gz", false);
replay(LINEA_MAINNET, "4065365-4065369.json.gz");
}

@Test
Expand Down
Binary file modified arithmetization/src/test/resources/replays/4323985.json.gz
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -232,9 +232,18 @@ private static MutableWorldState initWorld(final ConflationSnapshot conflation)
}
// Initialise storage
for (StorageSnapshot s : conflation.storage()) {
updater
.getAccount(Words.toAddress(Bytes.fromHexString(s.address())))
.setStorageValue(UInt256.fromHexString(s.key()), UInt256.fromHexString(s.value()));
UInt256 key = UInt256.fromHexString(s.key());
UInt256 value = UInt256.fromHexString(s.value());
// The following check is only necessary because of older replay files which captured storage
// for accounts created in the conflation itself (see #1289). Such assignments are always
// zero values, but this confuses BESU into thinking their storage is not empty (leading to a
// creation failure). This fix simply prevents zero values from being assigned at all.
// If/when all older replay files are recaptured, then this check should be redundant.
if (!value.isZero()) {
updater
.getAccount(Words.toAddress(Bytes.fromHexString(s.address())))
.setStorageValue(key, value);
}
}
// Commit changes
updater.commit();
Expand Down Expand Up @@ -269,8 +278,7 @@ private static OperationTracer buildOperationTracer(
}

// Write the captured replay for a given conflation snapshot to a file. This is used to debug the
// BlockCapturer by
// making sure, for example, that captured replays still execute correctly.
// BlockCapturer by making sure, for example, that captured replays still execute correctly.
private static void writeCaptureToFile(ConflationSnapshot conflation, BlockCapturer capturer) {
// Extract capture name
String json = capturer.toJson();
Expand Down

0 comments on commit 0a567b2

Please sign in to comment.