From 53d4172f5b8ac75e38b99850aa170878c66d8690 Mon Sep 17 00:00:00 2001 From: Santiago Carmuega Date: Tue, 27 Aug 2024 16:54:54 -0300 Subject: [PATCH] chore: upgrade Pallas to v0.30.1 --- Cargo.lock | 270 ++++++++++++++++++++++++++------- Cargo.toml | 6 +- src/filters/legacy_v1/map.rs | 2 +- src/filters/parse_cbor.rs | 8 +- src/filters/select/eval/mod.rs | 27 +++- src/framework/mod.rs | 4 +- 6 files changed, 244 insertions(+), 73 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 318e3570..0e745f81 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3322,6 +3322,15 @@ dependencies = [ "either", ] +[[package]] +name = "itertools" +version = "0.13.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "413ee7dfc52ee1a4949ceeb7dbc8a33f2d6c088194d9f922fb8318faf1f01186" +dependencies = [ + "either", +] + [[package]] name = "itoa" version = "0.4.8" @@ -3779,12 +3788,12 @@ dependencies = [ "mithril-build-script", "mithril-stm", "nom", - "pallas-addresses", - "pallas-codec", - "pallas-hardano", - "pallas-network", - "pallas-primitives", - "pallas-traverse", + "pallas-addresses 0.27.0", + "pallas-codec 0.27.0", + "pallas-hardano 0.27.0", + "pallas-network 0.27.0", + "pallas-primitives 0.27.0", + "pallas-traverse 0.27.0", "rand_chacha", "rand_core 0.6.4", "rayon", @@ -4139,7 +4148,6 @@ dependencies = [ "tracing", "tracing-subscriber", "unicode-truncate", - "utxorpc-spec", ] [[package]] @@ -4190,18 +4198,18 @@ dependencies = [ [[package]] name = "pallas" -version = "0.27.0" +version = "0.30.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5b1aeedd0e1c254374f10f5b0b59672a81421e1e55feccc41863dc37c1626ba4" +checksum = "1f22ad792399ec4fc6fe8d9c29ce106e25687a887ea65e1f326a68145cff7fcc" dependencies = [ - "pallas-addresses", - "pallas-codec", + "pallas-addresses 0.30.1", + "pallas-codec 0.30.1", "pallas-configs", - "pallas-crypto", - "pallas-hardano", - "pallas-network", - "pallas-primitives", - "pallas-traverse", + "pallas-crypto 0.30.1", + "pallas-hardano 0.30.1", + "pallas-network 0.30.1", + "pallas-primitives 0.30.1", + "pallas-traverse 0.30.1", "pallas-txbuilder", "pallas-utxorpc", ] @@ -4217,11 +4225,42 @@ dependencies = [ "crc", "cryptoxide", "hex", - "pallas-codec", - "pallas-crypto", + "pallas-codec 0.27.0", + "pallas-crypto 0.27.0", + "thiserror", +] + +[[package]] +name = "pallas-addresses" +version = "0.30.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c38fac39e0da3b0fc4c859635c72e97584f01f3a0f4f1508b0851c02d6d52f15" +dependencies = [ + "base58", + "bech32 0.9.1", + "crc", + "cryptoxide", + "hex", + "pallas-codec 0.30.1", + "pallas-crypto 0.30.1", "thiserror", ] +[[package]] +name = "pallas-applying" +version = "0.30.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "36131fe4afa40ec970b1e72c79d22f1321668e96a49c007d59d60932d7267682" +dependencies = [ + "hex", + "pallas-addresses 0.30.1", + "pallas-codec 0.30.1", + "pallas-crypto 0.30.1", + "pallas-primitives 0.30.1", + "pallas-traverse 0.30.1", + "rand", +] + [[package]] name = "pallas-codec" version = "0.27.0" @@ -4234,19 +4273,31 @@ dependencies = [ "thiserror", ] +[[package]] +name = "pallas-codec" +version = "0.30.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ea8a4b87dbc8bcb8aeb865f7cca5e1eb29744330e23b307169fc30537648b264" +dependencies = [ + "hex", + "minicbor", + "serde", + "thiserror", +] + [[package]] name = "pallas-configs" -version = "0.27.0" +version = "0.30.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8c2ae97ad0c054a9c6881085c84ca6620337844473e77dc2620c1b83f29c08d9" +checksum = "4864174e1afde09aa5ca2163510099174b3ecf50d2d9232a7103c165f7b56dc3" dependencies = [ "base64 0.22.0", "hex", "num-rational", - "pallas-addresses", - "pallas-codec", - "pallas-crypto", - "pallas-primitives", + "pallas-addresses 0.30.1", + "pallas-codec 0.30.1", + "pallas-crypto 0.30.1", + "pallas-primitives 0.30.1", "serde", "serde_json", "serde_with 3.8.1", @@ -4260,7 +4311,21 @@ checksum = "5705ee695a2429d8a352af62671cc3470ba5f76fd48968b59bc6c049ef75a7e0" dependencies = [ "cryptoxide", "hex", - "pallas-codec", + "pallas-codec 0.27.0", + "rand_core 0.6.4", + "serde", + "thiserror", +] + +[[package]] +name = "pallas-crypto" +version = "0.30.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7b98c3f204299d47d9b581ab425043789caff1f491c078ee3d3f109d6556f725" +dependencies = [ + "cryptoxide", + "hex", + "pallas-codec 0.30.1", "rand_core 0.6.4", "serde", "thiserror", @@ -4273,8 +4338,22 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "68b2fad14a720b4f1248de270d46a2467ca431e447cc0c09b7b44e96ad88bd5a" dependencies = [ "binary-layout", - "pallas-network", - "pallas-traverse", + "pallas-network 0.27.0", + "pallas-traverse 0.27.0", + "tap", + "thiserror", + "tracing", +] + +[[package]] +name = "pallas-hardano" +version = "0.30.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c8cc9968eecb5832cbf4c36152530ae0fa1d95b3957cf7dd05dbf8766e278a7d" +dependencies = [ + "binary-layout", + "pallas-network 0.30.1", + "pallas-traverse 0.30.1", "tap", "thiserror", "tracing", @@ -4289,8 +4368,26 @@ dependencies = [ "byteorder", "hex", "itertools 0.12.1", - "pallas-codec", - "pallas-crypto", + "pallas-codec 0.27.0", + "pallas-crypto 0.27.0", + "rand", + "socket2 0.5.6", + "thiserror", + "tokio", + "tracing", +] + +[[package]] +name = "pallas-network" +version = "0.30.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "219f4ce6de0cfa8b5ed86dff8cc020be90b7f94e9bbca056b5649d015f15f904" +dependencies = [ + "byteorder", + "hex", + "itertools 0.13.0", + "pallas-codec 0.30.1", + "pallas-crypto 0.30.1", "rand", "socket2 0.5.6", "thiserror", @@ -4308,8 +4405,24 @@ dependencies = [ "bech32 0.9.1", "hex", "log", - "pallas-codec", - "pallas-crypto", + "pallas-codec 0.27.0", + "pallas-crypto 0.27.0", + "serde", + "serde_json", +] + +[[package]] +name = "pallas-primitives" +version = "0.30.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9f64835dd9cbdd75a38961a190b983f02746c872340daf1a921eada8c525a4b6" +dependencies = [ + "base58", + "bech32 0.9.1", + "hex", + "log", + "pallas-codec 0.30.1", + "pallas-crypto 0.30.1", "serde", "serde_json", ] @@ -4321,10 +4434,27 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cb366f1daf4c32fe9875dc14e509112a1a0e1036aa741abe98d1b6d3ba83642a" dependencies = [ "hex", - "pallas-addresses", - "pallas-codec", - "pallas-crypto", - "pallas-primitives", + "pallas-addresses 0.27.0", + "pallas-codec 0.27.0", + "pallas-crypto 0.27.0", + "pallas-primitives 0.27.0", + "paste", + "serde", + "thiserror", +] + +[[package]] +name = "pallas-traverse" +version = "0.30.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ad516b05ba7d838ee84f9998d7b2b4ff7acc178cb052bcfd5fea9edc2ef6023f" +dependencies = [ + "hex", + "itertools 0.13.0", + "pallas-addresses 0.30.1", + "pallas-codec 0.30.1", + "pallas-crypto 0.30.1", + "pallas-primitives 0.30.1", "paste", "serde", "thiserror", @@ -4332,16 +4462,16 @@ dependencies = [ [[package]] name = "pallas-txbuilder" -version = "0.27.0" +version = "0.30.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2d2d5a784a78c1d7d5b335531770250bada239c65b255a509dd5d6a038126da6" +checksum = "2d8e06ff16bfbef54bfcb4169ea53f86ef79bfd64c8c42feed9d9cdc40a5d6ab" dependencies = [ "hex", - "pallas-addresses", - "pallas-codec", - "pallas-crypto", - "pallas-primitives", - "pallas-traverse", + "pallas-addresses 0.30.1", + "pallas-codec 0.30.1", + "pallas-crypto 0.30.1", + "pallas-primitives 0.30.1", + "pallas-traverse 0.30.1", "pallas-wallet", "serde", "serde_json", @@ -4350,28 +4480,30 @@ dependencies = [ [[package]] name = "pallas-utxorpc" -version = "0.27.0" +version = "0.30.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8f66c70dc23aaf018e6b595d4b7a2182fe845e92a4a2dc248a23ee6cb7d771df" +checksum = "1d4d3c0a6de6958902f10de5cb498a86117928c65b3d9bdd169c6e07db5d746a" dependencies = [ - "pallas-codec", - "pallas-crypto", - "pallas-primitives", - "pallas-traverse", + "pallas-applying", + "pallas-codec 0.30.1", + "pallas-crypto 0.30.1", + "pallas-primitives 0.30.1", + "pallas-traverse 0.30.1", + "prost-types 0.13.1", "utxorpc-spec", ] [[package]] name = "pallas-wallet" -version = "0.27.0" +version = "0.30.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b326ca34ee0d4ffff0199375be943b0cc5a78c4eb6c86d2a0bdd15611fd657eb" +checksum = "2b54b78670a8db1d206e0848a2bcc62df498db30934ad36c16a62118f8389714" dependencies = [ "bech32 0.9.1", "bip39", "cryptoxide", "ed25519-bip32", - "pallas-crypto", + "pallas-crypto 0.30.1", "rand", "thiserror", ] @@ -4774,6 +4906,16 @@ dependencies = [ "prost-derive 0.12.3", ] +[[package]] +name = "prost" +version = "0.13.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e13db3d3fde688c61e2446b4d843bc27a7e8af269a69440c0308021dc92333cc" +dependencies = [ + "bytes", + "prost-derive 0.13.1", +] + [[package]] name = "prost-build" version = "0.12.3" @@ -4822,6 +4964,19 @@ dependencies = [ "syn 2.0.52", ] +[[package]] +name = "prost-derive" +version = "0.13.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "18bec9b0adc4eba778b33684b7ba3e7137789434769ee3ce3930463ef904cfca" +dependencies = [ + "anyhow", + "itertools 0.12.1", + "proc-macro2", + "quote", + "syn 2.0.52", +] + [[package]] name = "prost-types" version = "0.11.9" @@ -4840,6 +4995,15 @@ dependencies = [ "prost 0.12.3", ] +[[package]] +name = "prost-types" +version = "0.13.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cee5168b05f49d4b0ca581206eb14a7b22fafd963efe729ac48eb03266e25cc2" +dependencies = [ + "prost 0.13.1", +] + [[package]] name = "psm" version = "0.1.21" @@ -7001,9 +7165,9 @@ checksum = "711b9620af191e0cdc7468a8d14e709c3dcdb115b36f838e601583af800a370a" [[package]] name = "utxorpc-spec" -version = "0.5.1" +version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e6ed1da9027ea2010458a9aa5da7d896518176165d630f0325ad2c994f69772b" +checksum = "66ae3390f4f25d7244d82207573bf7e8ce935f2a13d2c5d708fb27dde9840042" dependencies = [ "bytes", "futures-core", diff --git a/Cargo.toml b/Cargo.toml index 47b75288..25e236fd 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -23,7 +23,7 @@ mithril = ["mithril-client"] # kafka = auto feature flag [dependencies] -pallas = { version = "0.27.0", features = ["hardano"] } +pallas = { version = "0.30.1", features = ["hardano"] } # pallas = { path = "../pallas/pallas" } # pallas = { git = "https://github.com/txpipe/pallas" } @@ -32,8 +32,6 @@ gasket-prometheus = { version = "^0.7" } # gasket = { path = "../../construkts/gasket-rs/gasket", features = ["derive"] } # gasket = { git = "https://github.com/construkts/gasket-rs.git", features = ["derive"] } -utxorpc-spec = { version = "^0.5" } - hex = "0.4.3" net2 = "0.2.37" bech32 = "0.9.1" @@ -80,4 +78,4 @@ aws-sdk-lambda = { version = "^1.1", optional = true } extism = { version = "1.2.0", optional = true } mithril-client = { version = "^0.8", optional = true, features = ["fs"] } miette = { version = "7.2.0", features = ["fancy"] } -itertools = "0.12.1" \ No newline at end of file +itertools = "0.12.1" diff --git a/src/filters/legacy_v1/map.rs b/src/filters/legacy_v1/map.rs index 2ab2ac00..89795d4f 100644 --- a/src/filters/legacy_v1/map.rs +++ b/src/filters/legacy_v1/map.rs @@ -408,7 +408,7 @@ impl EventWriter<'_> { conway::RedeemerTag::Vote => "vote".to_string(), conway::RedeemerTag::Propose => "propose".to_string(), }, - ex_units_mem: redeemer.ex_units().mem, + ex_units_mem: redeemer.ex_units().mem as u32, ex_units_steps: redeemer.ex_units().steps, input_idx: redeemer.index(), plutus_data: redeemer.data().to_json(), diff --git a/src/filters/parse_cbor.rs b/src/filters/parse_cbor.rs index 0cb836ed..d085781d 100644 --- a/src/filters/parse_cbor.rs +++ b/src/filters/parse_cbor.rs @@ -11,12 +11,8 @@ use crate::framework::*; #[derive(Clone, Default)] struct NoOpContext; -impl interop::Context for NoOpContext { - fn get_txo<'a>( - &self, - _tx_hash: pallas::crypto::hash::Hash<32>, - _txo_index: u32, - ) -> Option> { +impl interop::LedgerContext for NoOpContext { + fn get_utxos(&self, _refs: &[interop::TxoRef]) -> Option { None } } diff --git a/src/filters/select/eval/mod.rs b/src/filters/select/eval/mod.rs index 67dbb808..2fc2bea4 100644 --- a/src/filters/select/eval/mod.rs +++ b/src/filters/select/eval/mod.rs @@ -1,10 +1,10 @@ use std::{ops::Deref, str::FromStr}; -use serde::{Deserialize, Serialize}; -use tracing::warn; -use utxorpc_spec::utxorpc::v1alpha::cardano::{ +use pallas::interop::utxorpc::spec::cardano::{ Asset, AuxData, Metadata, Metadatum, Multiasset, TxInput, TxOutput, }; +use serde::{Deserialize, Serialize}; +use tracing::warn; use crate::framework::*; @@ -129,6 +129,10 @@ pub trait PatternOf { let outcomes = iter.map(|x| self.is_match(x)); MatchOutcome::fold_any_of(outcomes) } + + fn is_some_match(&self, subject: Option) -> MatchOutcome { + self.is_any_match(subject.into_iter()) + } } impl PatternOf for Option

@@ -218,7 +222,7 @@ impl PatternOf<&[u8]> for TextPattern { impl PatternOf<&Metadatum> for TextPattern { fn is_match(&self, subject: &Metadatum) -> MatchOutcome { match subject.metadatum.as_ref() { - Some(utxorpc_spec::utxorpc::v1alpha::cardano::metadatum::Metadatum::Text(subject)) => { + Some(pallas::interop::utxorpc::spec::cardano::metadatum::Metadatum::Text(subject)) => { self.is_match(subject.as_str()) } _ => MatchOutcome::Negative, @@ -289,7 +293,9 @@ impl PatternOf<&TxOutput> for OutputPattern { let c = MatchOutcome::fold_all_of(c); - let d = self.datum.is_match(subject.datum_hash.as_ref()); + let d = self + .datum + .is_some_match(subject.datum.as_ref().map(|d| d.hash.as_ref())); MatchOutcome::fold_all_of([a, b, c, d].into_iter()) } @@ -330,7 +336,9 @@ impl PatternOf<&TxInput> for InputPattern { let c = MatchOutcome::fold_all_of(c); - let d = self.datum.is_match(as_output.datum_hash.as_ref()); + let d = self + .datum + .is_some_match(as_output.datum.as_ref().map(|x| x.hash.as_ref())); MatchOutcome::fold_all_of([a, b, c, d].into_iter()) } @@ -499,7 +507,12 @@ fn iter_tx_assets(tx: &ParsedTx) -> impl Iterator { } fn iter_tx_datums(tx: &ParsedTx) -> impl Iterator { - let a = tx.outputs.iter().map(|x| x.datum_hash.as_ref()); + let a = tx + .outputs + .iter() + .map(|x| &x.datum) + .flatten() + .map(|x| x.hash.as_ref()); a } diff --git a/src/framework/mod.rs b/src/framework/mod.rs index 81b76e99..2598e8d8 100644 --- a/src/framework/mod.rs +++ b/src/framework/mod.rs @@ -10,8 +10,8 @@ use std::path::PathBuf; pub use crate::cursor::Config as CursorConfig; // we use UtxoRpc as our canonical representation of a parsed Tx -pub use utxorpc_spec::utxorpc::v1alpha::cardano::Block as ParsedBlock; -pub use utxorpc_spec::utxorpc::v1alpha::cardano::Tx as ParsedTx; +pub use pallas::interop::utxorpc::spec::cardano::Block as ParsedBlock; +pub use pallas::interop::utxorpc::spec::cardano::Tx as ParsedTx; // we use GenesisValues from Pallas as our ChainConfig pub use pallas::ledger::traverse::wellknown::GenesisValues;