diff --git a/persist/sqlite/consensus.go b/persist/sqlite/consensus.go index 6ba5a1c2..1dfc3656 100644 --- a/persist/sqlite/consensus.go +++ b/persist/sqlite/consensus.go @@ -6,7 +6,6 @@ import ( "encoding/json" "errors" "fmt" - "log" "go.sia.tech/core/consensus" "go.sia.tech/core/types" @@ -790,7 +789,6 @@ func addFileContractElements(tx *txn, revert bool, b types.Block, fces []explore if err != nil { return fmt.Errorf("failed to execute file_contract_elements statement: %w", err) } - log.Printf("(%v) %v: (valid: %v, resolved: %v, rev: %d, lastRevision: %v)", b.ID(), fcID, valid, resolved, fc.RevisionNumber, lastRevision) // only update if it's the most recent revision which will come from // running ForEachFileContractElement on the update @@ -1011,7 +1009,6 @@ func (ut *updateTx) ApplyIndex(state explorer.UpdateState) error { } func (ut *updateTx) RevertIndex(state explorer.UpdateState) error { - log.Println("Revert:", state.Index) if err := updateMaturedBalances(ut.tx, true, state.Index.Height); err != nil { return fmt.Errorf("RevertIndex: failed to update matured balances: %w", err) } else if _, err := addSiacoinElements( diff --git a/persist/sqlite/consensus_test.go b/persist/sqlite/consensus_test.go index 1c5c50e4..514268d5 100644 --- a/persist/sqlite/consensus_test.go +++ b/persist/sqlite/consensus_test.go @@ -2578,4 +2578,33 @@ func TestMultipleReorgFileContract(t *testing.T) { checkFC(false, false, revFC, dbFCs[0]) } } + + extra = cm.Tip().Height - genesisState.Index.Height + 1 + for reorg := uint64(0); reorg < 2; reorg++ { + { + var blocks []types.Block + state := genesisState + for i := uint64(0); i < reorg+extra; i++ { + pk := types.GeneratePrivateKey() + addr := types.StandardUnlockHash(pk.PublicKey()) + + blocks = append(blocks, mineBlock(state, nil, addr)) + state.Index.ID = blocks[len(blocks)-1].ID() + state.Index.Height++ + } + if err := cm.AddBlocks(blocks); err != nil { + t.Fatal(err) + } + syncDB(t, db, cm) + } + + // contract should no longer exist + { + dbFCs, err := db.Contracts([]types.FileContractID{fcID}) + if err != nil { + t.Fatal(err) + } + check(t, "fcs", 0, len(dbFCs)) + } + } }