From b20be790bf2e44a6f084abe8a4a7f427959a6470 Mon Sep 17 00:00:00 2001 From: Radu Ometita Date: Tue, 12 Oct 2021 13:54:14 +0300 Subject: [PATCH] Fix duplicate block error --- plutus-chain-index/src/Plutus/ChainIndex/Types.hs | 2 +- plutus-chain-index/src/Plutus/ChainIndex/UtxoState.hs | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/plutus-chain-index/src/Plutus/ChainIndex/Types.hs b/plutus-chain-index/src/Plutus/ChainIndex/Types.hs index e61519e90ce..37dbf7c7fc8 100644 --- a/plutus-chain-index/src/Plutus/ChainIndex/Types.hs +++ b/plutus-chain-index/src/Plutus/ChainIndex/Types.hs @@ -127,7 +127,7 @@ instance Monoid Tip where instance Ord Tip where TipAtGenesis <= _ = True _ <= TipAtGenesis = False - (Tip ls _ _) <= (Tip rs _ _) = ls <= rs + (Tip _ _ lb) <= (Tip _ _ rb) = lb <= rb instance Pretty Tip where pretty TipAtGenesis = "TipAtGenesis" diff --git a/plutus-chain-index/src/Plutus/ChainIndex/UtxoState.hs b/plutus-chain-index/src/Plutus/ChainIndex/UtxoState.hs index aa949f95ad7..a27e30e2f53 100644 --- a/plutus-chain-index/src/Plutus/ChainIndex/UtxoState.hs +++ b/plutus-chain-index/src/Plutus/ChainIndex/UtxoState.hs @@ -49,6 +49,8 @@ import Plutus.ChainIndex.ChainIndexLog (InsertUtxoPosition (..)) import Plutus.ChainIndex.Types (Point (..), Tip (..), pointsToTip) import Prettyprinter (Pretty (..)) +import qualified Debug.Trace as Debug + -- | UTXO / ledger state, kept in memory. We are only interested in the UTXO set, everything else is stored -- on disk. This is OK because we don't need to validate transactions when they come in. data UtxoState a = @@ -107,7 +109,7 @@ insert s@UtxoState{_usTip=thisTip} ix = in case tip (utxoState after) of TipAtGenesis -> Right $ InsertUtxoSuccess{newIndex = before FT.|> s, insertPosition = InsertAtEnd} t | t > thisTip -> Right $ InsertUtxoSuccess{newIndex = (before FT.|> s) <> after, insertPosition = InsertBeforeEnd} - | otherwise -> Left $ DuplicateBlock t + | otherwise -> Debug.trace ("Our tip: " <> show thisTip <> " Ix tip: " <> show t) $ Left $ DuplicateBlock t data RollbackResult a = RollbackResult