Skip to content

Commit fba35db

Browse files
committed
undo pretty printing of blockvalidationfailures
Change-Id: I2b978049d02936a4d09b00487311aac985f45b62
1 parent de0b85b commit fba35db

File tree

4 files changed

+4
-10
lines changed

4 files changed

+4
-10
lines changed

chainweb.cabal

-1
Original file line numberDiff line numberDiff line change
@@ -351,7 +351,6 @@ library
351351
build-depends:
352352
, Decimal >= 0.4.2
353353
, aeson >= 2.2
354-
, aeson-pretty >= 0.8
355354
, asn1-encoding >=0.9
356355
, asn1-types >=0.3
357356
, async >= 2.2

src/Chainweb/Pact/PactService.hs

+2-2
Original file line numberDiff line numberDiff line change
@@ -812,7 +812,7 @@ execReadOnlyReplay lowerBound maybeUpperBound = pactLabel "execReadOnlyReplay" $
812812
let
813813
printValidationError (BlockValidationFailure (BlockValidationFailureMsg m)) = do
814814
writeIORef validationFailedRef True
815-
logFunctionText logger Error m
815+
logFunctionText logger Error (J.getJsonText m)
816816
printValidationError e = throwM e
817817
handleMissingBlock NoHistory = throwM $ BlockHeaderLookupFailure $
818818
"execReadOnlyReplay: missing block: " <> sshow bh
@@ -831,7 +831,7 @@ execReadOnlyReplay lowerBound maybeUpperBound = pactLabel "execReadOnlyReplay" $
831831
)
832832
validationFailed <- readIORef validationFailedRef
833833
when validationFailed $
834-
throwM $ BlockValidationFailure $ BlockValidationFailureMsg "Prior block validation errors"
834+
throwM $ BlockValidationFailure $ BlockValidationFailureMsg $ J.encodeJsonText ("Prior block validation errors" :: Text)
835835
return r
836836

837837
heightProgress :: BlockHeight -> BlockHeight -> IORef BlockHeight -> (Text -> IO ()) -> IO ()

src/Chainweb/Pact/PactService/ExecBlock.hs

+1-6
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@ import Control.Monad.Reader
4444
import Control.Monad.State.Strict
4545

4646
import qualified Data.Aeson as A
47-
import qualified Data.Aeson.Encode.Pretty as A
4847
import qualified Data.ByteString.Short as SB
4948
import qualified Data.ByteString.Lazy as BL
5049
import Data.Decimal
@@ -565,16 +564,12 @@ validateHashes bHeader payload miner transactions =
565564
if newHash == prevHash
566565
then Right actualPwo
567566
else Left $ BlockValidationFailure $ BlockValidationFailureMsg $
568-
prettyJson $ J.encodeText $ J.object
567+
J.encodeJsonText $ J.object
569568
[ "header" J..= J.encodeWithAeson (ObjectEncoded bHeader)
570569
, "mismatch" J..= errorMsg "Payload hash" prevHash newHash
571570
, "details" J..= difference
572571
]
573572
where
574-
prettyJson txt = case A.eitherDecodeStrict @A.Value (T.encodeUtf8 txt) of
575-
Right obj -> T.cons '\n' $ T.decodeUtf8 $ BL.toStrict $ A.encodePretty obj
576-
Left err -> error $ "validateHashes: impossible JSON decode failure: " <> show err
577-
578573
actualPwo = toPayloadWithOutputs miner transactions
579574

580575
newHash = _payloadWithOutputsPayloadHash actualPwo

src/Chainweb/Pact/Service/Types.hs

+1-1
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,7 @@ data LocalPreflightSimulation
213213
| LegacySimulation
214214
deriving stock (Eq, Show, Generic)
215215

216-
newtype BlockValidationFailureMsg = BlockValidationFailureMsg Text
216+
newtype BlockValidationFailureMsg = BlockValidationFailureMsg J.JsonText
217217
deriving (Eq, Ord, Generic)
218218
deriving newtype (J.Encode)
219219

0 commit comments

Comments
 (0)