From 055688dbb3133eb3ad11ebf4aa5bba1fc7af89be Mon Sep 17 00:00:00 2001 From: Pavel Zbitskiy Date: Mon, 22 Aug 2022 16:10:19 -0400 Subject: [PATCH 1/5] Fix logged panics in reproducible labels test --- ledger/acctupdates_test.go | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/ledger/acctupdates_test.go b/ledger/acctupdates_test.go index da9edd0acc..3a02da5718 100644 --- a/ledger/acctupdates_test.go +++ b/ledger/acctupdates_test.go @@ -120,12 +120,14 @@ func (ml *mockLedgerForTracker) fork(t testing.TB) *mockLedgerForTracker { dblogger := logging.TestingLog(t) dblogger.SetLevel(logging.Info) newLedgerTracker := &mockLedgerForTracker{ - inMemory: false, - log: dblogger, - blocks: make([]blockEntry, len(ml.blocks)), - deltas: make([]ledgercore.StateDelta, len(ml.deltas)), - accts: make(map[basics.Address]basics.AccountData), - filename: fn, + inMemory: false, + log: dblogger, + blocks: make([]blockEntry, len(ml.blocks)), + deltas: make([]ledgercore.StateDelta, len(ml.deltas)), + accts: make(map[basics.Address]basics.AccountData), + filename: fn, + consensusParams: ml.consensusParams, + consensusVersion: ml.consensusVersion, } for k, v := range ml.accts { newLedgerTracker.accts[k] = v From 68b7ec9d6b6252b46ef1b36a1bd0e5a62c746e7c Mon Sep 17 00:00:00 2001 From: Pavel Zbitskiy Date: Mon, 22 Aug 2022 16:14:58 -0400 Subject: [PATCH 2/5] Do not log AddBlock --- ledger/archival_test.go | 1 + ledger/ledger_test.go | 1 + 2 files changed, 2 insertions(+) diff --git a/ledger/archival_test.go b/ledger/archival_test.go index cb6dc4ae51..242f013a6e 100644 --- a/ledger/archival_test.go +++ b/ledger/archival_test.go @@ -143,6 +143,7 @@ func TestArchival(t *testing.T) { cfg := config.GetDefaultLocal() cfg.Archival = true log := logging.TestingLog(t) + log.SetLevel(logging.Info) l, err := OpenLedger(log, dbName, inMem, genesisInitState, cfg) require.NoError(t, err) defer l.Close() diff --git a/ledger/ledger_test.go b/ledger/ledger_test.go index 114057f503..8308945a53 100644 --- a/ledger/ledger_test.go +++ b/ledger/ledger_test.go @@ -2665,6 +2665,7 @@ func TestVotersReloadFromDisk(t *testing.T) { cfg.Archival = false cfg.MaxAcctLookback = proto.StateProofInterval - proto.StateProofVotersLookback - 10 log := logging.TestingLog(t) + log.SetLevel(logging.Info) l, err := OpenLedger(log, dbName, inMem, genesisInitState, cfg) require.NoError(t, err) defer l.Close() From faab51641de39fea7480df8434153fd4eaf66500 Mon Sep 17 00:00:00 2001 From: Pavel Zbitskiy Date: Mon, 22 Aug 2022 16:37:44 -0400 Subject: [PATCH 3/5] Do not log AddBlock more --- ledger/archival_test.go | 1 + ledger/ledger_test.go | 5 +++++ 2 files changed, 6 insertions(+) diff --git a/ledger/archival_test.go b/ledger/archival_test.go index 242f013a6e..6e61ee0abf 100644 --- a/ledger/archival_test.go +++ b/ledger/archival_test.go @@ -721,6 +721,7 @@ func TestArchivalFromNonArchival(t *testing.T) { cfg.Archival = false log := logging.TestingLog(t) + log.SetLevel(logging.Info) l, err := OpenLedger(log, dbPrefix, inMem, genesisInitState, cfg) require.NoError(t, err) blk := genesisInitState.Block diff --git a/ledger/ledger_test.go b/ledger/ledger_test.go index 8308945a53..095a2e5f8f 100644 --- a/ledger/ledger_test.go +++ b/ledger/ledger_test.go @@ -1388,6 +1388,7 @@ func TestLedgerBlockHdrCaching(t *testing.T) { cfg := config.GetDefaultLocal() cfg.Archival = true log := logging.TestingLog(t) + log.SetLevel(logging.Info) l, err := OpenLedger(log, dbName, inMem, genesisInitState, cfg) a.NoError(err) defer l.Close() @@ -1484,6 +1485,7 @@ func TestLedgerReload(t *testing.T) { cfg := config.GetDefaultLocal() cfg.Archival = true log := logging.TestingLog(t) + log.SetLevel(logging.Info) l, err := OpenLedger(log, dbName, inMem, genesisInitState, cfg) require.NoError(t, err) defer l.Close() @@ -1682,11 +1684,13 @@ func TestLedgerKeepsOldBlocksForStateProof(t *testing.T) { cfg := config.GetDefaultLocal() cfg.Archival = false log := logging.TestingLog(t) + log.SetLevel(logging.Info) l, err := OpenLedger(log, dbName, inMem, genesisInitState, cfg) require.NoError(t, err) defer l.Close() lastBlock, err := l.Block(l.Latest()) + require.NoError(t, err) proto := config.Consensus[lastBlock.CurrentProtocol] accounts := make(map[basics.Address]basics.AccountData, len(genesisInitState.Accounts)+maxBlocks) keys := make(map[basics.Address]*crypto.SignatureSecrets, len(initKeys)+maxBlocks) @@ -2713,6 +2717,7 @@ func TestVotersReloadFromDiskAfterOneStateProofCommitted(t *testing.T) { cfg.Archival = false cfg.MaxAcctLookback = proto.StateProofInterval - proto.StateProofVotersLookback - 10 log := logging.TestingLog(t) + log.SetLevel(logging.Info) l, err := OpenLedger(log, dbName, inMem, genesisInitState, cfg) require.NoError(t, err) defer l.Close() From f0a2bac8feac080622b8d4e88c5f25a08cf345c7 Mon Sep 17 00:00:00 2001 From: Pavel Zbitskiy Date: Mon, 22 Aug 2022 17:12:22 -0400 Subject: [PATCH 4/5] more not logging --- ledger/ledger_test.go | 1 + 1 file changed, 1 insertion(+) diff --git a/ledger/ledger_test.go b/ledger/ledger_test.go index 095a2e5f8f..58c89ecae0 100644 --- a/ledger/ledger_test.go +++ b/ledger/ledger_test.go @@ -2777,6 +2777,7 @@ func TestVotersReloadFromDiskPassRecoveryPeriod(t *testing.T) { cfg.Archival = false cfg.MaxAcctLookback = proto.StateProofInterval - proto.StateProofVotersLookback - 10 log := logging.TestingLog(t) + log.SetLevel(logging.Info) l, err := OpenLedger(log, dbName, inMem, genesisInitState, cfg) require.NoError(t, err) defer l.Close() From 706ba58b068a7fa50787d88b478a76b257d2ea46 Mon Sep 17 00:00:00 2001 From: Pavel Zbitskiy Date: Tue, 23 Aug 2022 10:28:27 -0400 Subject: [PATCH 5/5] checkAcctUpdates: check totals only when it makes sense --- ledger/acctupdates_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ledger/acctupdates_test.go b/ledger/acctupdates_test.go index 3a02da5718..edd44549ed 100644 --- a/ledger/acctupdates_test.go +++ b/ledger/acctupdates_test.go @@ -291,7 +291,7 @@ func checkAcctUpdates(t *testing.T, au *accountUpdates, ao *onlineAccounts, base require.Error(t, err) require.Equal(t, basics.Round(0), validThrough) - if base > 0 { + if base > 0 && base >= basics.Round(ao.maxBalLookback()) { _, err := ao.onlineTotals(base - basics.Round(ao.maxBalLookback())) require.Error(t, err)