Skip to content

Commit

Permalink
Try to reproduce the aux data conflict as reported by mlabs
Browse files Browse the repository at this point in the history
  • Loading branch information
ch1bo committed May 3, 2024
1 parent 12e8f7f commit d55e074
Showing 1 changed file with 52 additions and 44 deletions.
96 changes: 52 additions & 44 deletions hydra-node/test/Hydra/Chain/Direct/TxSpec.hs
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,11 @@ import Cardano.Ledger.Api (
)
import Cardano.Ledger.Core (EraTx (getMinFeeTx))
import Cardano.Ledger.Credential (Credential (..))
import Control.Lens ((^.))
import Control.Lens ((^.), (^?!))
import Data.Aeson.Lens (key, _JSON)
import Data.Aeson.Types (parseMaybe)
import Data.Map qualified as Map
import Data.Maybe (fromJust)
import Data.Maybe.Strict (StrictMaybe (..))
import Data.Set qualified as Set
import Data.Text qualified as T
Expand Down Expand Up @@ -209,49 +212,54 @@ spec =
forAllBlind arbitrary $ \chainContext -> do
let ChainContext{networkId, ownVerificationKey, ownParty, scriptRegistry} =
chainContext{ownVerificationKey = getVerificationKey commitSigningKey, networkId = testNetworkId}
forAllBlind genBlueprintTxWithUTxO $ \(lookupUTxO, blueprintTx) ->
counterexample ("Blueprint tx: " <> renderTxWithUTxO lookupUTxO blueprintTx) $ do
let createdTx =
commitTx
networkId
scriptRegistry
(mkHeadId Fixture.testPolicyId)
ownParty
CommitBlueprintTx{lookupUTxO, blueprintTx}
(healthyInitialTxIn, toUTxOContext healthyInitialTxOut, verificationKeyHash ownVerificationKey)
counterexample ("\n\n\nCommit tx: " <> renderTxWithUTxO lookupUTxO createdTx) $ do
let blueprintBody = toLedgerTx blueprintTx ^. bodyTxL
let commitTxBody = toLedgerTx createdTx ^. bodyTxL
let spendableUTxO =
UTxO.singleton (healthyInitialTxIn, toUTxOContext healthyInitialTxOut)
<> lookupUTxO
<> registryUTxO scriptRegistry

conjoin
[ propTransactionEvaluates (blueprintTx, lookupUTxO)
& counterexample "Blueprint transaction failed to evaluate"
, propTransactionEvaluates (createdTx, spendableUTxO)
& counterexample "Commit transaction failed to evaluate"
, conjoin
[ getAuxMetadata blueprintTx `propIsSubmapOf` getAuxMetadata createdTx
& counterexample "Blueprint metadata incomplete"
, propHasValidAuxData blueprintTx
& counterexample "Blueprint tx has invalid aux data"
, propHasValidAuxData createdTx
& counterexample "Commit tx has invalid aux data"
]
, blueprintBody ^. vldtTxBodyL === commitTxBody ^. vldtTxBodyL
& counterexample "Validity range mismatch"
, (blueprintBody ^. inputsTxBodyL) `propIsSubsetOf` (commitTxBody ^. inputsTxBodyL)
& counterexample "Blueprint inputs missing"
, property
((`all` (blueprintBody ^. outputsTxBodyL)) (`notElem` (commitTxBody ^. outputsTxBodyL)))
& counterexample "Blueprint outputs not discarded"
, (blueprintBody ^. reqSignerHashesTxBodyL) `propIsSubsetOf` (commitTxBody ^. reqSignerHashesTxBodyL)
& counterexample "Blueprint required signatures missing"
, (blueprintBody ^. referenceInputsTxBodyL) `propIsSubsetOf` (commitTxBody ^. referenceInputsTxBodyL)
& counterexample "Blueprint reference inputs missing"
]
-- forAllBlind genBlueprintTxWithUTxO $ \(lookupUTxO, blueprintTx) ->
let lookupUTxO = reproJSON ^?! key "utxo" . _JSON
blueprintTx = reproJSON ^?! key "blueprintTx" . _JSON
counterexample ("Blueprint tx: " <> renderTxWithUTxO lookupUTxO blueprintTx) $ do
let createdTx =
commitTx
networkId
scriptRegistry
(mkHeadId Fixture.testPolicyId)
ownParty
CommitBlueprintTx{lookupUTxO, blueprintTx}
(healthyInitialTxIn, toUTxOContext healthyInitialTxOut, verificationKeyHash ownVerificationKey)
counterexample ("\n\n\nCommit tx: " <> renderTxWithUTxO lookupUTxO createdTx) $ do
let blueprintBody = toLedgerTx blueprintTx ^. bodyTxL
let commitTxBody = toLedgerTx createdTx ^. bodyTxL
let spendableUTxO =
UTxO.singleton (healthyInitialTxIn, toUTxOContext healthyInitialTxOut)
<> lookupUTxO
<> registryUTxO scriptRegistry

conjoin
-- [ propTransactionEvaluates (blueprintTx, lookupUTxO)
-- & counterexample "Blueprint transaction failed to evaluate"
[ propTransactionEvaluates (createdTx, spendableUTxO)
& counterexample "Commit transaction failed to evaluate"
, conjoin
[ getAuxMetadata blueprintTx `propIsSubmapOf` getAuxMetadata createdTx
& counterexample "Blueprint metadata incomplete"
, propHasValidAuxData blueprintTx
& counterexample "Blueprint tx has invalid aux data"
, propHasValidAuxData createdTx
& counterexample "Commit tx has invalid aux data"
]
, blueprintBody ^. vldtTxBodyL === commitTxBody ^. vldtTxBodyL
& counterexample "Validity range mismatch"
, (blueprintBody ^. inputsTxBodyL) `propIsSubsetOf` (commitTxBody ^. inputsTxBodyL)
& counterexample "Blueprint inputs missing"
, property
((`all` (blueprintBody ^. outputsTxBodyL)) (`notElem` (commitTxBody ^. outputsTxBodyL)))
& counterexample "Blueprint outputs not discarded"
, (blueprintBody ^. reqSignerHashesTxBodyL) `propIsSubsetOf` (commitTxBody ^. reqSignerHashesTxBodyL)
& counterexample "Blueprint required signatures missing"
, (blueprintBody ^. referenceInputsTxBodyL) `propIsSubsetOf` (commitTxBody ^. referenceInputsTxBodyL)
& counterexample "Blueprint reference inputs missing"
]

reproJSON :: Text
reproJSON = "{\"blueprintTx\": {\"cborHex\": \"84a6008282582040950f0b632cf619661bc6a219ad149a5ff100559ee5c36fa4eb9fbd133d4d0700825820a509f07d4d0ce981dd8b09c2c29b1fa8c4669e4c846e6ac077dd26e34e42494d0001800200031a02ddff65081a02ddf9890e82581cac55de689702d745e77050ce83b77ff9619383bb802e40fb90aa3be4581ce17e5b8c19c89d663c66b3e4943972d7b6dd70a711fade4cf1a6a95aa30380068159114c591149010000333232323232323232323232323232323232323232323232323232323232323232323232323232323232323232323232323232323232323232323232323232323232323232323232323232323232323232323222222333332222232325333058332232323370e6660b4444a6660bc002200426600666e00009200230620014800000520023304e23303132306130620013060305f3061001004001375860bc60be002605c0020042a6660b06602000e60b860b660ba002264a6660b2664466064460066eacc188004004c88cc0c88c00cdd69831000800919b8700148000cc88ccc8c04488dd3198019bab002375600244666024446ea0cdc09bad002375a0020040020040026eac0052f5bded8c02646464a6660b866e1d2000002132533305d3301500c001132533305e3330304a04a660726464646464646464a66082666660446eb8c1acc1a801400c0200092201014000133333022375c60d600a6eb8c1acc1a8010c1ac0100052210145003322332232533306b3371200290000801099b8a333069222533306d00110021330033371400460e400260e20020746660d2444a6660dc66e24009200014bd620998318009980199b81002480080040040ec008cdc08011b8d0014822804cdc5181c80b99b8a303900137666ea0008dd6983500299191919299983519b874800800854cc19d24013470616464725061796d656e744b657948617368556e736166653a206661696c656420746f20676574207061796d656e7420706b6800161375c60dc00260de00460d40026ea8c1acc1b0004c1a800cc8cdc5181b80a981b8009bae30693068002375c60d060be60d202460d060ce00660ca00260c800260ca00460c660c460c801a2666062646466e24008004dd69832183198328011bad30633049306400d23232323371266e0000c004008dd69833191833182680098338081bad306530643066003375a60c860c660ca002018002264a6660be6606e608601a0022930a9982e248105535442443800163062304a3063008153305b4901055354424437001633059491055354424436003232323253330613370e9002001098299919191919002a99983299b87480000084c8c8c8c8c8c8c926533306a001149854cc1a014c58c1b40194ccc1a4cdc3a400000426464646464646464646464646464646493299983b8008a4c2a660ea0c02c60f40066eb8004c1e4004c1dc00cdd7000983b000983a0019bad00130730013071006533306d3370e900000109919191919191919191924ca6660ea0022930a9983982f0b183c0019bae0013077001307500653330713370e900000109919191919191919191919191924ca6660f80022930a9983d0328b183f803299983d99b87480000084c8c8c8c8c8c8c926533308001001149854cc1f81a458c20c040194ccc1fccdc3a4000004264646464646464932999842008008a4c2a66104020da2c610e0200ca6661060266e1d2000002132325333085013370e6e340052038132324994ccc2140400452615330830106e1630880100315330820105816375c002610e020022a6661060266e1d2002002132325333085013370e6e340052038132324994ccc2140400452615330830106e1630880100315330820105916375c002610e020022a66100020d82c6110020046106020026ea8004c20c0400454ccc1fccdc3a4004004264646464646464646464932999843808008a4c2a6610a020e02c6114020066eb4004c22404004c21c0400cdd68009843008009842008019bad001308301001153307c06816308401002307f001375400260fe0022a6660f666e1d20020021324994ccc1e8004526153307806316153307806416308001002307b001375400260f600260f200ca6660ea66e1d20000021323253330773370e6e340052038132324994ccc1dc004526153307506016307a003153307404a16375c00260f20022a6660ea66e1d20020021323253330773370e6e340052038132324994ccc1dc004526153307506016307a003153307404b16375c00260f20022a660e40bc2c60f400460ea0026ea8004c1d400454cc1b816858c1d8008c1c4004dd500098388008a9983502b0b183900118368009baa001306d001153306605216306e0023069001375400260d20022a6660ca66e1d20020021324994ccc190004526153306204d16153306204e16306a0023065001375400260ca00220c460cc00460c20026ea8004c184c160c18800454cc16924010553544244350016330584910553544244340033223304d23303430633064001003375860c460b260c6002606400a00c2a6660b866e1d200200213232533305e33035233223305f22533306200114a02a6660c666ebcc19c00400c5288980118330008011bac306330620030010011533305e33036304200c3062002149854cc16d241065354424431300016153305b4910553544244390016375860c260ae60c4016609060c200c264a6660ba66644464646464666444660024600600220069408c020004004cc88cc0048c888c00800cc00c00448940048c8c8c8c80154ccc19ccdc3a40000042649329998330008a4c2a660c809e2c2a6660ce66e1d20020021324994ccc198004526153306404f16153330673370e900200109924ca6660cc0022930a998320278b0a99983399b87480180084c9265333066001149854cc19013c5854cc19014058c1b0008c19c004dd50009999111983211299983380089128008a99983419baf306a306c00100413005306c00113002306b001001232223002003306a0010010033374a90011982b80082b183298330011bab3064304a3065002232323253330613370e90000010a50153330613370e90030010a5014a260cc00460c20026ea800401c004526153305a490106535442443132001633058491065354424431310033223304d23370e6660aa646eacc190c18cc194004c18cc188c19000403800d2002375860c460c600291010741554354494f4e000063061002305c001375400a2a660ac9210553544244330016305c3051305d002153305549010553544244320016153305549105535442443100163305349105535442443000323232533305a3370e90010010991919982d111299982f00089128008a99982f9801183180089911180100198318008998018011831000919baf3061306200100300137586460c060c200260be60c000c60bc00220b660be00460b40026ea8c16cc168c170008c168c16c004dd700280200180100091119998020019100100100091824980100091191911980080180111129998270008998220018010991919299982919baf002001133047337600046601260b000c60b00066660104400400a60aa0082a6660a466e40dd70011bae0011330470063333008220010033055004005133047003333300822001006005305500430530023052004305300122533304c0021001133330032200130510023050002001223330030020040012223370e6660806eacc138c134c13c00400c00920024890c5354414e44494e475f42494400222223253302930014a0260029448cccccc01c00401000c0088ccdca8030008038a5022223333005004003232303c3371402c66e28dd71827182680099b8a017337146eb8c138004cdc500c19b8a00333714008032609c00220924466600600246600a0024464607666e9520003303e37520026607c6ea40080f4cdc500619b8a002337146601a00a00666e28c04c00c05c41188c8c8c8c94ccc11ccdc3a400400420902646464a66609466e1d20000021323232533304d3370e900100108270991919299982819b87480080084c108c8c8888cc008014010dd7182a8011bae305400a13042323222233003005004375c60aa0046eb8c150028c154008c140004dd51828800982900118268009baa304e0011303c322223001004375c609c008609e00460940026ea8c12cc128010c130008c11c004dd518240009824000919980091119800802803111198008028031119800803003a44101390048810146004881011d004881012a0048810158002233300122533303f0041005100f22533303f004100610072533303e0031007100848901010048810121004881012000488101610048810160002333001714e2880052210d846a5369676e617475726531580048810ba201276761646472657373004881024058004881004881010000237666ea4004888c8c8c94ccc0d0cdc3a4004004200c2600a6070002607200460680026ea80052412c7074727946726f6d28505075624b657948617368293a206d757374206265203238206279746573206c6f6e670049012c7074727946726f6d285053637269707448617368293a206d757374206265203238206279746573206c6f6e6700223375e6e9cc0c8008dd3981900091918181818800981798171818000918141129998158008a5115330063003303000113002302f00122323253300633005300f3030002300f3030001133005300f3030302f001300f3030302f0023030002302f0022232323232533302d53300b5330070021001153300730090021300900113300a00400313300e004003300e3030302f004300d302f302e004302e002302d0022233302800200100314a0466604a0029412891299801998030010008998028010009198118008010a512232323253330253370e90000010991919299981419b87480000085288a50302d002302800137540082a66604a66e1d2002002132323253330283370e900100109919b87375a605a00a0026eb4c0b0004528181680118140009baa004132323253330283370e90020010a5114a0605a00460500026ea8010c0a8008c094004dd500111191919299981219b87480000085288a99981219b87480080084c8c8c94ccc09ccdc3a4000004294054ccc09ccdc3a400800429444cdc41bad302b004375a60560026058004604e0026ea80104c8c8c94ccc09ccdc3a40080042944528181600118138009baa004302900230240013754004466e1cc084dd5000a4004044464660066eb4c088004dd698111810800980b18110009119ba548000cc048cdd2a40006602466e952002330123750004022660240060226602466e952000330123374a9001198091ba8001011330120040110114c0103d87a80004c0103d87980004901317074727946726f6d2850446174615265636f72645b5d293a206c697374206973206c6f6e676572207468616e207a65726f0049013f7265616368656420656e64206f662073756d207768696c65207374696c6c206e6f7420686176696e6720666f756e642074686520636f6e7374727563746f72002301a300200123019300200123018300200123017300200123016300c00122300333006002001300e225333011001101315333012300330150011300430160011013574644460040064601844a66601e0022008264a666022600800226600c00260066028004260066028004602800297ae05740444666600800490001199980280124000eb4dd5800801918011ba900122223300a22533300d00110051533300e3375e6020602400200c2600860286024002260046022002002460166004002460146004002460126012002446600240022a660060042cae708c8c0088cc0080080048c0088cc00800800555cfab9a2250015573aae895d0918011baa0015573c98011e581c526d32281e1b7c1d9d971f43ca447b518afa82e3753871cd61276b3d004c01ffd8799fa1581cc0f8644a01a6bf5db02f4afe30d604975e63dd274f1098a1738e561da1484d6f6e614c69736101d8799fd8799f581c5adb3931b04f04b3cec724bffa6ddfbde4581b88ad3cd036f8739915ffd8799fd8799fd8799f581c74616edff426d4fd7027af0453b6eda6812e6ca8ec7ca182b1f588edffffffff58206b65411ab5550ba69734c59628fcddd906d3062bfa330e9452211d3f1d87883f9f581cac55de689702d745e77050ce83b77ff9619383bb802e40fb90aa3be4581ce17e5b8c19c89d663c66b3e4943972d7b6dd70a711fade4cf1a6a95aff1b0000018f3f5de5c21b0000018f3f9dfc021b0000018f3fd4ea821b0000018f3fd517d4e21a002dc6c01a007a12001a000f42401a002dc6c0ff00010581840001d87a80820000f5f6\", \"description\": \"\", \"txId\": \"ab704d9199e6d5bb664952dd3baf2697587d21da311a758ac3eafbb34efc7761\", \"type\": \"Tx BabbageEra\"}, \"utxo\": {\"40950f0b632cf619661bc6a219ad149a5ff100559ee5c36fa4eb9fbd133d4d07#0\": {\"address\": \"addr_test1vzxkgg32lujr89lkud56q0kz6pfv7rmr0p8w6etn87gr3tq2uvdeg\", \"inlineDatum\": null, \"value\": {\"lovelace\": 10000000}}, \"a509f07d4d0ce981dd8b09c2c29b1fa8c4669e4c846e6ac077dd26e34e42494d#0\": {\"address\": \"addr_test1wrpg4jyq2u4e5tg3e2v4fp63jc9pg4mc3246ka4wwp7swxqtutv2g\", \"inlineDatum\": {\"fields\": [], \"constructor\": 1}, \"inlineDatumhash\": \"8392f0c940435c06888f9bdb8c74a95dc69f156367d6a089cf008ae05caae01e\", \"value\": {\"lovelace\": 1099050, \"526d32281e1b7c1d9d971f43ca447b518afa82e3753871cd61276b3d\": {\"5354414e44494e475f424944\": 1}}}}}"

-- | Check auxiliary data of a transaction against 'pparams' and whether the aux
-- data hash is consistent.
Expand Down

0 comments on commit d55e074

Please sign in to comment.