From a544113e16649da49711dd59791e7d4211e70dda Mon Sep 17 00:00:00 2001 From: Tyera Eulberg Date: Thu, 8 Feb 2024 19:51:50 -0700 Subject: [PATCH] Add warn log if capitalization changes during create-snapshot --- ledger-tool/src/main.rs | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/ledger-tool/src/main.rs b/ledger-tool/src/main.rs index d4a5a3eb18ea69..272c6ec3ddc7c6 100644 --- a/ledger-tool/src/main.rs +++ b/ledger-tool/src/main.rs @@ -2024,8 +2024,20 @@ fn main() { } } + let pre_capitalization = bank.capitalization(); + bank.set_capitalization(); + let post_capitalization = bank.capitalization(); + if pre_capitalization != post_capitalization { + let amount = if pre_capitalization > post_capitalization { + format!("-{}", pre_capitalization - post_capitalization) + } else { + (post_capitalization - pre_capitalization).to_string() + }; + warn!("Capitalization change: {amount} lamports"); + } + let bank = if let Some(warp_slot) = warp_slot { // need to flush the write cache in order to use Storages to calculate // the accounts hash, and need to root `bank` before flushing the cache