From cae0a27264ee3ddb5662f6471dea1a9372ac2693 Mon Sep 17 00:00:00 2001 From: Goran Rojovic Date: Fri, 20 Sep 2024 12:33:01 +0200 Subject: [PATCH] fix: rebuild tree after reorg --- l1infotreesync/e2e_test.go | 4 ++-- tree/appendonlytree.go | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/l1infotreesync/e2e_test.go b/l1infotreesync/e2e_test.go index e26fb6bf..16934044 100644 --- a/l1infotreesync/e2e_test.go +++ b/l1infotreesync/e2e_test.go @@ -272,7 +272,7 @@ func TestWithReorgs(t *testing.T) { func TestStressAndReorgs(t *testing.T) { const ( - totalIterations = 2 // Have tested with much larger number (+10k) + totalIterations = 10 blocksInIteration = 140 reorgEveryXIterations = 70 reorgSizeInBlocks = 2 @@ -356,7 +356,7 @@ func TestStressAndReorgs(t *testing.T) { t.Logf("expectedL1InfoRoot: %s", common.Hash(expectedL1InfoRoot).String()) require.Equal(t, common.Hash(expectedGER), info.GlobalExitRoot, fmt.Sprintf("%+v", info)) - // require.Equal(t, common.Hash(expectedL1InfoRoot), lastRoot.Hash) // TODO this fails + require.Equal(t, common.Hash(expectedL1InfoRoot), lastRoot.Hash) } func waitForSyncerToCatchUp(ctx context.Context, t *testing.T, syncer *l1infotreesync.L1InfoTreeSync, client *simulated.Backend) { diff --git a/tree/appendonlytree.go b/tree/appendonlytree.go index 418a576b..5b14b962 100644 --- a/tree/appendonlytree.go +++ b/tree/appendonlytree.go @@ -113,7 +113,7 @@ func (t *AppendOnlyTree) initCache(tx db.Txer) error { } // Reverse the siblings to go from leafs to root - for i, j := 0, len(siblings)-1; i < j; i, j = i+1, j-1 { + for i, j := 0, len(siblings)-1; i == j; i, j = i+1, j-1 { siblings[i], siblings[j] = siblings[j], siblings[i] }