Skip to content

Commit bc2e58f

Browse files
ana-pantilielehins
andcommitted
Ledger changes; fix parsing errors
Co-authored-by: Alexey Kuleshevich <lehins@yandex.ru>
1 parent 5f5739d commit bc2e58f

File tree

2 files changed

+72
-21
lines changed

2 files changed

+72
-21
lines changed

cardano-node/src/Cardano/Node/Tracing/Era/Shelley.hs

Lines changed: 36 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -183,9 +183,18 @@ instance LogFormatting (Conway.ConwayDelegPredFailure era) where
183183
, "credential" .= String (textShow credential)
184184
, "error" .= String "Delegated rep is not registered for provided stake key"
185185
]
186-
-- TODO: fix
187-
Conway.DepositIncorrectDELEG _ -> undefined
188-
Conway.RefundIncorrectDELEG _ -> undefined
186+
Conway.DepositIncorrectDELEG Mismatch {mismatchSupplied, mismatchExpected} ->
187+
[ "kind" .= String "DepositIncorrectDELEG"
188+
, "givenRefund" .= mismatchSupplied
189+
, "expectedRefund" .= mismatchExpected
190+
, "error" .= String "Deposit mismatch"
191+
]
192+
Conway.RefundIncorrectDELEG Mismatch {mismatchSupplied, mismatchExpected} ->
193+
[ "kind" .= String "RefundIncorrectDELEG"
194+
, "givenRefund" .= mismatchSupplied
195+
, "expectedRefund" .= mismatchExpected
196+
, "error" .= String "Refund mismatch"
197+
]
189198

190199
instance
191200
( ShelleyCompatible protocol era
@@ -380,8 +389,12 @@ instance
380389
]
381390
)
382391
(Api.shelleyBasedEra :: Api.ShelleyBasedEra era)
383-
-- TODO: fix
384-
forMachine _ (ScriptIntegrityHashMismatch _ _) = undefined
392+
forMachine _ (ScriptIntegrityHashMismatch Mismatch {mismatchSupplied, mismatchExpected} mBytes) =
393+
mconcat [ "kind" .= String "ScriptIntegrityHashMismatch"
394+
, "supplied" .= renderScriptIntegrityHash (strictMaybeToMaybe mismatchSupplied)
395+
, "expected" .= renderScriptIntegrityHash (strictMaybeToMaybe mismatchExpected)
396+
, "hashHexPreimage" .= formatAsHex mBytes
397+
]
385398

386399
instance
387400
( Consensus.ShelleyBasedEra era
@@ -718,8 +731,12 @@ instance LogFormatting (ShelleyPoolPredFailure era) where
718731
, "poolId" .= String (textShow poolId)
719732
, "error" .= String "Wrong network ID in pool registration certificate"
720733
]
721-
-- TODO: fix
722-
forMachine _dtal (VRFKeyHashAlreadyRegistered _ _) = undefined
734+
forMachine _dtal (VRFKeyHashAlreadyRegistered poolId vrfKeyHash) =
735+
mconcat [ "kind" .= String "VRFKeyHashAlreadyRegistered"
736+
, "poolId" .= String (textShow poolId)
737+
, "vrfKeyHash" .= String (textShow vrfKeyHash)
738+
, "error" .= String "Pool with the same VRF Key Hash is already registered"
739+
]
723740

724741

725742
instance LogFormatting TicknPredicateFailure where
@@ -1025,7 +1042,12 @@ instance
10251042
, "scripts" .= s
10261043
]
10271044
-- TODO: fix
1028-
Babbage.ScriptIntegrityHashMismatch _ _ -> undefined
1045+
Babbage.ScriptIntegrityHashMismatch Mismatch {mismatchSupplied, mismatchExpected} mBytes ->
1046+
mconcat [ "kind" .= String "ScriptIntegrityHashMismatch"
1047+
, "supplied" .= renderScriptIntegrityHash (strictMaybeToMaybe mismatchSupplied)
1048+
, "expected" .= renderScriptIntegrityHash (strictMaybeToMaybe mismatchExpected)
1049+
, "hashHexPreimage" .= formatAsHex (mBytes)
1050+
]
10291051
--------------------------------------------------------------------------------
10301052
-- Conway related
10311053
--------------------------------------------------------------------------------
@@ -1475,8 +1497,12 @@ instance
14751497
mconcat [ "kind" .= String "MalformedReferenceScripts"
14761498
, "scripts" .= scripts
14771499
]
1478-
-- TODO: fix
1479-
Conway.ScriptIntegrityHashMismatch _ _ -> undefined
1500+
Conway.ScriptIntegrityHashMismatch Mismatch {mismatchSupplied, mismatchExpected} mBytes ->
1501+
mconcat [ "kind" .= String "ScriptIntegrityHashMismatch"
1502+
, "supplied" .= renderScriptIntegrityHash (strictMaybeToMaybe mismatchSupplied)
1503+
, "expected" .= renderScriptIntegrityHash (strictMaybeToMaybe mismatchExpected)
1504+
, "hashHexPreimage" .= formatAsHex (mBytes)
1505+
]
14801506

14811507
instance LogFormatting (Praos.PraosTiebreakerView crypto) where
14821508
forMachine _dtal (Praos.PraosTiebreakerView sl issuer issueNo vrf) =

cardano-node/src/Cardano/Tracing/OrphanInstances/Shelley.hs

Lines changed: 36 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -221,9 +221,18 @@ instance ToObject (Conway.ConwayDelegPredFailure era) where
221221
, "credential" .= String (textShow credential)
222222
, "error" .= String "Delegated rep is not registered for provided stake key"
223223
]
224-
-- TODO: fix
225-
Conway.DepositIncorrectDELEG _ -> undefined
226-
Conway.RefundIncorrectDELEG _ -> undefined
224+
Conway.DepositIncorrectDELEG Mismatch {mismatchSupplied, mismatchExpected} ->
225+
[ "kind" .= String "DepositIncorrectDELEG"
226+
, "givenRefund" .= mismatchSupplied
227+
, "expectedRefund" .= mismatchExpected
228+
, "error" .= String "Deposit mismatch"
229+
]
230+
Conway.RefundIncorrectDELEG Mismatch {mismatchSupplied, mismatchExpected} ->
231+
[ "kind" .= String "RefundIncorrectDELEG"
232+
, "givenRefund" .= mismatchSupplied
233+
, "expectedRefund" .= mismatchExpected
234+
, "error" .= String "Refund mismatch"
235+
]
227236

228237
instance ToObject (Set (Credential 'Staking)) where
229238
toObject _verb creds =
@@ -485,8 +494,12 @@ instance
485494
]
486495
)
487496
(Api.shelleyBasedEra :: Api.ShelleyBasedEra era)
488-
-- TODO: fix
489-
toObject _ _ = undefined
497+
toObject _ (VRFKeyHashAlreadyRegistered poolId vrfKeyHash) =
498+
mconcat [ "kind" .= String "VRFKeyHashAlreadyRegistered"
499+
, "poolId" .= String (textShow poolId)
500+
, "vrfKeyHash" .= String (textShow vrfKeyHash)
501+
, "error" .= String "Pool with the same VRF Key Hash is already registered"
502+
]
490503

491504
instance
492505
( ToObject (PredicateFailure (Core.EraRule "UTXO" ledgerera))
@@ -815,8 +828,12 @@ instance ToObject (ShelleyPoolPredFailure era) where
815828
, "hashSize" .= String (textShow hashSize)
816829
, "error" .= String "The stake pool metadata hash is too large"
817830
]
818-
-- TODO: fix
819-
toObject _verb (VRFKeyHashAlreadyRegistered _ _) = undefined
831+
toObject _ (VRFKeyHashAlreadyRegistered poolId vrfKeyHash) =
832+
mconcat [ "kind" .= String "VRFKeyHashAlreadyRegistered"
833+
, "poolId" .= String (textShow poolId)
834+
, "vrfKeyHash" .= String (textShow vrfKeyHash)
835+
, "error" .= String "Pool with the same VRF Key Hash is already registered"
836+
]
820837

821838
-- Apparently this should never happen according to the Shelley exec spec
822839
-- toObject _verb (WrongCertificateTypePOOL index) =
@@ -1183,8 +1200,12 @@ instance
11831200
mconcat [ "kind" .= String "MalformedReferenceScripts"
11841201
, "scripts" .= s
11851202
]
1186-
-- TODO: fix
1187-
Babbage.ScriptIntegrityHashMismatch _ _ -> undefined
1203+
Babbage.ScriptIntegrityHashMismatch Mismatch {mismatchSupplied, mismatchExpected} mBytes ->
1204+
mconcat [ "kind" .= String "ScriptIntegrityHashMismatch"
1205+
, "supplied" .= renderScriptIntegrityHash (strictMaybeToMaybe mismatchSupplied)
1206+
, "expected" .= renderScriptIntegrityHash (strictMaybeToMaybe mismatchExpected)
1207+
, "hashHexPreimage" .= formatAsHex (mBytes)
1208+
]
11881209

11891210
instance Core.Crypto crypto => ToObject (Praos.PraosValidationErr crypto) where
11901211
toObject _ err' =
@@ -1525,8 +1546,12 @@ instance
15251546
mconcat [ "kind" .= String "MalformedReferenceScripts"
15261547
, "scripts" .= scripts
15271548
]
1528-
-- TODO: fix
1529-
Conway.ScriptIntegrityHashMismatch _ _ -> undefined
1549+
Conway.ScriptIntegrityHashMismatch Mismatch {mismatchSupplied, mismatchExpected} mBytes ->
1550+
mconcat [ "kind" .= String "ScriptIntegrityHashMismatch"
1551+
, "supplied" .= renderScriptIntegrityHash (strictMaybeToMaybe mismatchSupplied)
1552+
, "expected" .= renderScriptIntegrityHash (strictMaybeToMaybe mismatchExpected)
1553+
, "hashHexPreimage" .= formatAsHex (mBytes)
1554+
]
15301555

15311556
instance ToObject (Praos.PraosTiebreakerView crypto) where
15321557
toObject v (Praos.PraosTiebreakerView sl issuer issueNo vrf) =

0 commit comments

Comments
 (0)