Skip to content

Commit

Permalink
fix(primitives): Handle bytes indef in Plutus data (#143)
Browse files Browse the repository at this point in the history
  • Loading branch information
scarmuega authored Jul 2, 2022
1 parent 98f7128 commit ad5ff36
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 5 deletions.
16 changes: 13 additions & 3 deletions pallas-primitives/src/alonzo/model.rs
Original file line number Diff line number Diff line change
Expand Up @@ -944,7 +944,15 @@ impl<'b, C> minicbor::decode::Decode<'b, C> for PlutusData {
| minicbor::data::Type::I64 => Ok(Self::BigInt(d.decode_with(ctx)?)),
minicbor::data::Type::Map => Ok(Self::Map(d.decode_with(ctx)?)),
minicbor::data::Type::Bytes => Ok(Self::BoundedBytes(d.decode_with(ctx)?)),
minicbor::data::Type::BytesIndef => Ok(Self::BoundedBytes(d.decode_with(ctx)?)),
minicbor::data::Type::BytesIndef => {
let mut full = Vec::new();

for slice in d.bytes_iter()? {
full.extend(slice?);
}

Ok(Self::BoundedBytes(ByteVec::from(full)))
}
minicbor::data::Type::Array => Ok(Self::Array(d.decode_with(ctx)?)),
minicbor::data::Type::ArrayIndef => Ok(Self::ArrayIndef(d.decode_with(ctx)?)),

Expand Down Expand Up @@ -1340,7 +1348,7 @@ pub struct MintedBlock<'b> {
pub transaction_bodies: MaybeIndefArray<KeepRaw<'b, TransactionBody>>,

#[n(2)]
pub transaction_witness_sets: MaybeIndefArray<TransactionWitnessSet>,
pub transaction_witness_sets: MaybeIndefArray<KeepRaw<'b, TransactionWitnessSet>>,

#[n(3)]
pub auxiliary_data_set: KeyValuePairs<TransactionIndex, KeepRaw<'b, AuxiliaryData>>,
Expand Down Expand Up @@ -1370,7 +1378,7 @@ pub struct MintedTx<'b> {
pub transaction_body: KeepRaw<'b, TransactionBody>,

#[n(1)]
pub transaction_witness_set: TransactionWitnessSet,
pub transaction_witness_set: KeepRaw<'b, TransactionWitnessSet>,

#[n(2)]
pub success: bool,
Expand Down Expand Up @@ -1429,6 +1437,8 @@ mod tests {
include_str!("../../../test_data/alonzo21.block"),
// peculiar block with bad tx hash
include_str!("../../../test_data/alonzo22.block"),
// peculiar block with indef byte array in plutus data
include_str!("../../../test_data/alonzo23.block"),
];

for (idx, block_str) in test_blocks.iter().enumerate() {
Expand Down
4 changes: 2 additions & 2 deletions pallas-primitives/src/babbage/model.rs
Original file line number Diff line number Diff line change
Expand Up @@ -536,7 +536,7 @@ pub struct MintedBlock<'b> {
pub transaction_bodies: MaybeIndefArray<KeepRaw<'b, TransactionBody>>,

#[n(2)]
pub transaction_witness_sets: MaybeIndefArray<TransactionWitnessSet>,
pub transaction_witness_sets: MaybeIndefArray<KeepRaw<'b, TransactionWitnessSet>>,

#[n(3)]
pub auxiliary_data_set: KeyValuePairs<TransactionIndex, KeepRaw<'b, AuxiliaryData>>,
Expand Down Expand Up @@ -566,7 +566,7 @@ pub struct MintedTx<'b> {
pub transaction_body: KeepRaw<'b, TransactionBody>,

#[n(1)]
pub transaction_witness_set: TransactionWitnessSet,
pub transaction_witness_set: KeepRaw<'b, TransactionWitnessSet>,

#[n(2)]
pub success: bool,
Expand Down
1 change: 1 addition & 0 deletions test_data/alonzo23.block
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
820585828f1a0036646f1a037e5eda5820e1ef53d961b282f380544071136b17992d63859d1ba92e02f25884161886c1f158209b30232b87e5568f4dd9848a0ea9d91fef54ba11bcd39121cef5e7e6e750f1575820fae4b8f31c676f58a039005d59ea1d2179a83ed2e1f0707b46c2f6c4401d72068258409aff3d1f146c458ad78362c7eda60e09b467ab96e156bc7a33fb22d0e084a57c11b847e5ce662290904068a521d58ed561803f48ca6ccc7ba496e91dcd8ee1065850fa41545a4abbb80d59198c87642f24509e41e86ade3e49e0aad6bd4cfa74fb6c8f3879b6b2fd9095b1b5330c45ed0920d63c3c8a41128d2b48325dbd708f08a5e08fd74918acbfe6d7169822cd21d80782584000216134f32705e1e5d7bf8f81a5d35ea525facc98b0c6c681dce076ff4f3c6a92ff33182c83b576f5e51cf5f969b3e7b016208b84c2e53944e4048289fb62e05850964f51d358a202607fc61999ce3f90538022b6c6c20620649b93d1e094364300eb565bde77b83d7f062ff3bec514a201d357f50bc856edfaaf6e87d604271d4589364b9797606a28d56eb17beecc100e19195c5820c4dcb7f265eb616f165a9a9f383d8c0c1170ee0629f3a64ebc425198886c1b0558209a90d51471fef8bc2d0959c2805886dc198954b8157d00117428a959325ec55e081901b958401ee49bb44464e13dea0e41b6899964940c5a090d74e320cf6382ce66d545bbb75cdf001e58bb53f8663bbffb9a2dd68f1e0cc1f4cc2a4f8d3d5009b408daf20806005901c0aabd2aec389df4c54db2f7139cc8b01f1875c40144c3f17061bcf98a833efbb6d64fb4f2a058ecaaab61a2e48454c9b7bf709360808ce3554c47d4af6e118503ede83764eb9961059e32d76777aec501ba24525afca393787ee1c1ec92efd669304930dd8330c3b3d5559f1bfad00d9506386f9a25d408ae39a8218c91ca00abad0699ab555d91beaf0d71db7b02e71483f9c6572434360b4ea6b7437ff7ab589a0f8507f49cc5570357656c28e3c4c777bd6a8d797623783710ecd592935030b21f7eaa9579b366b113500aadf6619e3307d1f1b26e3ee8f4badb10fd28ada482dca873639082ec192077f8bd552ab9a81f5ad8b2b0bbae8971bf66a614c73052c2184cb6664f9d27921b82d9d13a89f82d62fcc4c96cc2939e1cc3a37f0264341d7850932480c19531294af242cd5d7fdb92c856c73baf672eebcff2d5a3c851bd1eeb3ff675648aa8a3faf2fcaae4abc4a8e9f66594df816ca16e97a76adee94f48fce44ed277f61b5a713ddbc9ad81cf0310daf89127298fdaf99cca7303dcca2f0ea448d0b8f3f59f5fe80468198e0902a3d4686f334786c2f2f5b4d5d6aea0a9010c92c3160cec8b6178252ef9e3419269cffd536a57f3a95af71bd03f87a4008182582032979419239e27b95e1894f69bc978bd8a4a2a885e30447530795a444d9e51a3010182825839001adb6f5ae9610b8407e6181d9d23454591afef28a9bb6dd544661ae80db3289158eacbf45d16d822e2297b7d0da225f1fe6a299334eb19db1a001e8480825839009099de2ede4623f0436aef25b8dbcad88e15dea7b370008a4d2abd41d1f0119ac8c96199b78c7aad426159e5bc031fd32f5d52d8cd8ef21d1b000000015ffe2d97021a00029201031a037e5f12a300828258201124a0737314cf6aa38c4c4edaf5ea561c029618437bd4fd57dcd33ce38b8951018258201124a0737314cf6aa38c4c4edaf5ea561c029618437bd4fd57dcd33ce38b895102018383581d70ccab91fac02ceb62281d66d68e117ace2ab197fc3eb12929b999ca31821a077eb69ea05820ae7ebf3bc5d1f50cf2f12569e088dd53c89917cd71e128e7ea4c6daf59ef02b782583900139f64f546bb2b8ea827ae71423c4d3da389e1e601ad227adfc0512d77c023981d9187f73e5128bf6e23374ff5a8d848d171263a78182ce7821a0014851ea1581cb8aa6f60b48ad4cb0f623edc96eb4dffb652b3a2384287b22c8814aca14547454e53741a01dc914b82583900139f64f546bb2b8ea827ae71423c4d3da389e1e601ad227adfc0512d77c023981d9187f73e5128bf6e23374ff5a8d848d171263a78182ce71a200ba559021a0002aac1a300828258206fe19641cd3041d152d3a5a8e4297585f63bf232db4e176640a2a21db10f3568018258206fe19641cd3041d152d3a5a8e4297585f63bf232db4e176640a2a21db10f356802018383581d70ccab91fac02ceb62281d66d68e117ace2ab197fc3eb12929b999ca31821a16601558a05820ffb3b6509a7b26a10ea88a88700c1b3fb8933b2f98a01cd46a873c45e19aa4d1825839004e8b2a4398afcb339b8557890567d7145cf46f8c19bcf56d6f1c3c919e909fa249ece2c5703eeb2556e0e5551aae238de1943113da576a1e821a001be2daa3581c34250edd1e9836f5378702fbf9416b709bc140e04f668cc355208518a1494154414441636f696e191c8e581c57fca08abbaddee36da742a839f7d83a7e1d2419f1507fcbf3916522a14556414e494c1a0018adac581cd311d3488cc4fef19d05634adce8534977a3bc6fc18136ad65df1d4fa2446c71200a1a009d8e6c446c7120741a0009272c825839004e8b2a4398afcb339b8557890567d7145cf46f8c19bcf56d6f1c3c919e909fa249ece2c5703eeb2556e0e5551aae238de1943113da576a1e1a0b8582dd021a0002bb15a80081825820ad28cb51f1f36bc4f1694e20da46b4e574e77dd16a380a506d655659add859cb000d81825820ad28cb51f1f36bc4f1694e20da46b4e574e77dd16a380a506d655659add859cb00018282583900918449aae85de7248a8e0064d1b2bf9074fafec8af0e0689776af5876649e0f9b73391a3479eee54363cdfff5fbe3514d96cf18caf54ef1c821a0014851ea1581cf6f965943c738b48513277c1baf4770aa3873f2f624bfd2567322d4ba1466d4d415449431a001e84808258390017faa84c3144273ec0ed163a2a4876b6c864dc3b853adec72c7e3246c922acb2313aefd14c318d7944aa37c261d775a2e863f6964a2e7d7b1a2fd3763f021a0007eb6d031a037e7a960e81581c5098e5f901a8b45434b12be1c4700e460551967e1a07a54b0b9d887209a1581cf6f965943c738b48513277c1baf4770aa3873f2f624bfd2567322d4ba1466d4d415449431a001e84800b58202f1e614016e6863bb95bbeec2ffe4379bdead9c593111683fab60dc4d8feb23aa90081825820d3892a2e594455f5e6e0f1b0f901ab28461273c0d42f1cab0cb82ffdd5e7aab7000d80018282581d602cc2167361ba5e1371dca3cdfe119fa4303c7d7d2b35906123dff8961a39e31803825839008e112aee238679eb9c23185c224944687f18d8262f09aabbc64559831de38812b54dc47b9370d39740dc29ba3f834e0acefca7a7e18fdf67821a001e8480a1581cfd8b1cabffe4ac7b7f2c8f63d73a68c51b164f601eeb4e70adf27d51a1575370616365746f6b656e73506c616e657448656c696f7001021a00034805031a037e855a08000e8009a1581cfd8b1cabffe4ac7b7f2c8f63d73a68c51b164f601eeb4e70adf27d51a1575370616365746f6b656e73506c616e657448656c696f7001075820636e1ba4c1ec08f024d6b5d59c09223ce5ea6ba47585596c6b6c037ebaf9fa92a60082825820fa15b96689fbfa41719c13cca93b400451176cfc36c44d7651a07c2b12f3c93c00825820fa15b96689fbfa41719c13cca93b400451176cfc36c44d7651a07c2b12f3c93c01018383581d70081b23f2b3afa39a8750b282848ed9c2bcaf6a63067c517ef048420b821a003d0900a1581c648823ffdad1610b4162f4dbc87bd47f6f9cf45d772ddef661eff198a14577444f47451903e858203769e14cf91066e0b8ca4c07dcbde56d9b5cb6e21106aa19dadc45e40cb01a468258390045aaa2b8a2b997f57dca503579c1f2de11f12f409cdba2ed4e4789b275fa6855be58b262671bffe4b187d9d7b7a58fa66d0b966854c3ef8d1a3af16f2a8258390045aaa2b8a2b997f57dca503579c1f2de11f12f409cdba2ed4e4789b275fa6855be58b262671bffe4b187d9d7b7a58fa66d0b966854c3ef8d821a0017ad4aa1581c648823ffdad1610b4162f4dbc87bd47f6f9cf45d772ddef661eff198a4447742544319271044774554481a0031be604577444f47451a0050db384577555344431a000f4240021a0002f4a9031a037e6a30081a037e5c200b582061c32ff1be070e71013c5b4d4961a61f2cd9cc37918fa6823fbed89ad6aeaad2a4008182582082e9a7a802173bf2f48829fbe1829e91ea22772d904ca36ed40d6f339cdf04fe01018383581d70d3d514ade606266075a7f7efe2f3a71b6e7b1779e958c0c1be131c88821a00989680a2581c00abb5788d115386759a351d6f9d29bc7e23d5484fd67061de60fd05a1495779726d73746f6e651864581cb05fcc8a6e7e2a6e58e932fe8b70a169d975f7b7d99ac78b6c6af135a25054617665726e53717561643030303437015054617665726e537175616430303034380158201b5c3ae5c856701157aef73a8746c84f4e5422eea92346dc7bd21b4f45750043825839004a69950e6cad27ba2f7b3073230bca1885915685667f504d14ad611220168ae068455877c9157c5c31e4be15b1b5b65e3b7703b936465264821a0021ac80a2581c00abb5788d115386759a351d6f9d29bc7e23d5484fd67061de60fd05a1495779726d73746f6e651a00989234581cb05fcc8a6e7e2a6e58e932fe8b70a169d975f7b7d99ac78b6c6af135a65054617665726e53717561643030303431015054617665726e53717561643030303432015054617665726e53717561643030303433015054617665726e53717561643030303434015054617665726e53717561643030303435015054617665726e5371756164303030343601825839004a69950e6cad27ba2f7b3073230bca1885915685667f504d14ad611220168ae068455877c9157c5c31e4be15b1b5b65e3b7703b9364652641a00d68e23021a0002f1e90b5820a63a21d24e92099a849599ba14b69fcd889f10b292ff9f2b577bf2e866a4a12c87a1008182582045f394bee236a754362117fcb5eef36b59e28f86164fac5b32b41d9b6c5e86195840869f9ff5cd75ca265355041503ba43b541d7b68c09337aa9f04ff9d5d5dba7a0e273d431c6fdb41a3f0ee1ea92fec826ece6cc6054109d8046915985d64d8e00a10081825820a978ab7a70f041bab63585a064925be94626322593d061635dcaa6b0d98770a3584097bdc670da5aaf564b766d6242fe4187aeab01a176bd4c5d26c7d72f8081c3cc1b1929ec3842a03bf1187b5883950bbd475afeb0aada4da1452ede7739370607a100818258205a38cee3bf7ee173d604f3b86b17dd1854447fb5dd637c637d39c71984eca5975840ddba74d3f6f8c63686e029f685977f1315becbf394de6fecbcbf0d43e897faa502fdb1506b653cbea14f38ed79514cbdcda7d10a4dcfb61f51dfff17904f9003a30082825820a6af79ecc2c07a82d92b57387de904e7c9a145a64b27611bfaaed8cedb0bc9925840c1da2109e61fdad0e546a805eca96f4c198e3e4181caea15ee6d57e595e81bdacb8b06d790b1d694c15e9e51c44b7f05cdeadec40ad81aa6ec2d88f9edac220e8258204a9381289a9fc11d1d4f39a0f260e6b743aec748f859f47318166e4037af867758403b020349a3ae4676748eefc40d2ef7269bf8ea24e6420356ef6b846b971193aab455c9d2cf1db1e5032b044fa6075f172a87498edb443941e6a1ba735760f20703815907a75907a40100003323232323232323232332232323232332232332232323232322223232325335001101d132635335738921035054350001d01b323500122350022222222222533533355301312001321233001225335002210031001002501b25335333573466e3c04c00408c0884d40740045407000c8408c4084cccd5cd19b8735573aa004900011991091980080180119191919191919191919191999ab9a3370e6aae754029200023333333333222222222212333333333300100b00a009008007006005004003002335014232323333573466e1cd55cea8012400046644246600200600460426ae854008c064d5d09aba2500223263533573805c05a05605426aae7940044dd50009aba1500a33501401535742a012666aa02eeb94058d5d0a804199aa80bbae501635742a00e66a0280466ae854018cd4050cd54098091d69aba150053232323333573466e1cd55cea801240004664424660020060046464646666ae68cdc39aab9d5002480008cc8848cc00400c008cd409dd69aba150023028357426ae8940088c98d4cd5ce01901881781709aab9e5001137540026ae854008c8c8c8cccd5cd19b8735573aa004900011991091980080180119a813bad35742a00460506ae84d5d1280111931a99ab9c03203102f02e135573ca00226ea8004d5d09aba2500223263533573805c05a05605426aae7940044dd50009aba1500433501475c6ae85400ccd4050cd54099d710009aba15002301e357426ae8940088c98d4cd5ce01501481381309aba25001135744a00226ae8940044d5d1280089aba25001135744a00226ae8940044d5d1280089aab9e5001137540026ae854008c8c8c8cccd5cd19b875001480188c848888c010014c06cd5d09aab9e500323333573466e1d40092004232122223002005301d357426aae7940108cccd5cd19b875003480088c848888c004014c05cd5d09aab9e500523333573466e1d40112000232122223003005375c6ae84d55cf280311931a99ab9c02502402202102001f01e135573aa00226ea8004d5d09aba2500223263533573803c03a03603426aae7940044dd5000990009aa80c1108911299a80089a80191000910999a802910011802001199aa9803890008028020008919118011bac001320013550182233335573e0024a012466a01060086ae84008c00cd5d100100c11919191999ab9a3370e6aae75400d20002333222123330010040030023232323333573466e1cd55cea8012400046644246600200600460326ae854008cd4038060d5d09aba2500223263533573803c03a03603426aae7940044dd50009aba150033335500775ca00c6ae854008cd4029d71aba135744a004464c6a66ae7006806405c0584d5d1280089aab9e500113754002266aa002eb9d6889119118011bab00132001355016223233335573e0044a010466a00e66aa02e600c6aae754008c014d55cf280118021aba200301713574200222440042442446600200800624464646666ae68cdc3a800a400046a00e600a6ae84d55cf280191999ab9a3370ea00490011280391931a99ab9c016015013012011135573aa00226ea800448488c00800c44880048c8c8cccd5cd19b8735573aa004900011991091980080180118029aba15002375a6ae84d5d1280111931a99ab9c01101000e00d135573ca00226ea80048c8cccd5cd19b8735573aa002900011bae357426aae7940088c98d4cd5ce00780700600589baa00112232323333573466e1d400520042122200123333573466e1d40092002232122230030043006357426aae7940108cccd5cd19b87500348000848880088c98d4cd5ce00900880780700680609aab9d5001137540024646666ae68cdc3a800a4004400a46666ae68cdc3a80124000400a464c6a66ae7003803402c0280244d55ce9baa001122002122001232323232323333573466e1d4005200c21222222200323333573466e1d4009200a21222222200423333573466e1d400d2008233221222222233001009008375c6ae854014dd69aba135744a00a46666ae68cdc3a8022400c4664424444444660040120106eb8d5d0a8039bae357426ae89401c8cccd5cd19b875005480108cc8848888888cc018024020c030d5d0a8049bae357426ae8940248cccd5cd19b875006480088c848888888c01c020c034d5d09aab9e500b23333573466e1d401d2000232122222223005008300e357426aae7940308c98d4cd5ce00a00980880800780700680600580509aab9d5004135573ca00626aae7940084d55cf280089baa0012323232323333573466e1d400520022333222122333001005004003375a6ae854010dd69aba15003375a6ae84d5d1280191999ab9a3370ea0049000119091180100198041aba135573ca00c464c6a66ae700340300280240204d55cea80189aba25001135573ca00226ea80048c8c8cccd5cd19b875001480088c8488c00400cdd71aba135573ca00646666ae68cdc3a8012400046424460040066eb8d5d09aab9e500423263533573801401200e00c00a26aae7540044dd50008891119191999ab9a3370e6aae754009200023355008300635742a004600a6ae84d5d1280111931a99ab9c00a009007006135573ca00226ea80052611221233001003002120014910350543100112323001001223300330020020014891c5098e5f901a8b45434b12be1c4700e460551967e1a07a54b0b9d887200010581840100d87980821a002625a01a1dcd6500a2008182582013b5f5ed02b2aa700839f43bfe357dd290b5f4e65435e72e4be3ec48c2bf7d315840d1d2e5d52b6873e6448182dc4da7f1848b56410487e6f73c187ac65fbd80bf4a5840d9bdb7a9b6ab368dfe571962d71777aa42d176e311926eb396a8b2fc6606018182018282051a03b614408200581c2cc2167361ba5e1371dca3cdfe119fa4303c7d7d2b35906123dff896a20081825820c46b26712fefaf451327987fe95829f20f0511ace63657b93d7b43e1f5491a2a5840c815409055c588c250495f05ae2a373dc264821210253a9d1f5c01140a5f318104fdeebadfbaff7fff208d6176a12b63d8237eee4a7c64065f55041d55c723030481d8799fd8799fd8799fd8799f581c45aaa2b8a2b997f57dca503579c1f2de11f12f409cdba2ed4e4789b2ffd8799fd8799fd8799f581c75fa6855be58b262671bffe4b187d9d7b7a58fa66d0b966854c3ef8dffffffff581c45aaa2b8a2b997f57dca503579c1f2de11f12f409cdba2ed4e4789b21b00000180de155631d8799fd8799f581c22c3b86a5b88a78b5de52f4aed2831d1483b3b7681f1ee256953813058203395f36673a46e5c1e4d7ff53d96e72b34754fa912e67c0dee427d108f7618b5ffd8799f581c648823ffdad1610b4162f4dbc87bd47f6f9cf45d772ddef661eff1984577444f4745ffffffd8799fd87a801a000a1742ffffa20081825820edb8e8783f02648af956a22f2ddc2334ceab69ba1f7194e1f19d6fec508ae9fd58402fb2f20340cf78a3bda52260842d2128bd52f94ed6ed9e5930d3a8ce2e3428017ac17c673c6fb176593f143e557b5b5d21d1dc93410d4a1cce226b8c6f230803049f9f5f5840616464725f7465737431717039786e396777646a6b6a307733303076633878676374656776677479326b73346e3837357a647a6a6b6b7a7933717a3639777136582c7a3974706d756a39747574736337663073346b78366d7668336d7775706d6a646a7832666a71663071326a32ff1b00000180dd79f9005054617665726e537175616430303034385054617665726e53717561643030303437ffffa104d90103a100a11902d1a178386664386231636162666665346163376237663263386636336437336136386335316231363466363031656562346537306164663237643531a1775370616365746f6b656e73506c616e657448656c696f70a766617574686f726c537061636520546f6b656e736c636f6e74656e745f7479706569696d6167652f706e676b6465736372697074696f6e73537061636520546f6b656e7320506c616e657465696d6167657835697066733a2f2f516d56453153766559616e31707a435944736f66555678755a6471484d344e7a644731735045387376544c504654686c6f636174696f6ea2656874747073783868747470733a2f2f742e7370616365746f6b656e732e696f2f7075622f5370616365746f6b656e73506c616e657448656c696f702e706e6764697066737835697066733a2f2f516d56453153766559616e31707a435944736f66555678755a6471484d344e7a644731735045387376544c504654646e616d656648656c696f70656f74686572a76961737365745f75726c782168747470733a2f2f7777772d732e7370616365746f6b656e732e696f2f642f31316d646973636f76657265645f61747820323032322d30352d31395431373a35303a30302e3334373331312b30303a30306c646973636f766572795f6e6f0b6d65787065646974696f6e5f6e6f0b6c706c616e65745f636c617373036b706c616e65745f73697a656654657272616e6b706c616e65745f74797065654d6574616c80

0 comments on commit ad5ff36

Please sign in to comment.