From 241204cc802ea497c09da72caa263926905b9854 Mon Sep 17 00:00:00 2001 From: Pavel Kalinnikov Date: Fri, 29 Apr 2022 16:36:05 +0100 Subject: [PATCH] cache: Set a fixed tile height of 8 (#2726) --- CHANGELOG.md | 1 + storage/cache/log_tile.go | 9 ++++----- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ea518ef255..e96e81bdd1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -15,6 +15,7 @@ ### Misc improvements * #2712: Fix MySQL world-writable config warning. + * #2726: Check the tile height invariant stricter. No changes required. ## v1.4.0 diff --git a/storage/cache/log_tile.go b/storage/cache/log_tile.go index f5689fec18..26c406ba05 100644 --- a/storage/cache/log_tile.go +++ b/storage/cache/log_tile.go @@ -39,12 +39,11 @@ const ( // // TODO(pavelkalinnikov): Unexport it after the refactoring. func PopulateLogTile(st *storagepb.SubtreeProto, hasher merkle.LogHasher) error { - if st.Depth < 1 { - return fmt.Errorf("populate log subtree with invalid depth: %d", st.Depth) + if got, want := st.Depth, int32(logStrataDepth); got != want { + return fmt.Errorf("invalid log tile depth %d, want %d", got, want) } - // maxLeaves is the number of leaves that fully populates a subtree of the depth we are - // working with. - maxLeaves := 1 << uint(st.Depth) + // maxLeaves is the number of leaves in a fully populated tile. + const maxLeaves = 1 << logStrataDepth // If the subtree is fully populated then the internal node map is expected to be nil but in // case it isn't we recreate it as we're about to rebuild the contents. We'll check