diff --git a/Cargo.lock b/Cargo.lock index c92429d8..1eb25dd7 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -830,11 +830,12 @@ checksum = "2a60c7ce501c71e03a9c9c0d35b861413ae925bd979cc7a4e30d060069aaac8d" [[package]] name = "minicbor" -version = "0.14.1" +version = "0.15.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0d882813266da97748692bd700903a19bd0a179f25d2a144d383df4cddd24a18" +checksum = "2b419e66bd98ccf5824dd4b8f4141f7431d1d07733c3e13c946278204a437d2b" dependencies = [ "half", + "minicbor-derive", ] [[package]] @@ -1084,7 +1085,6 @@ dependencies = [ "kafka", "log 0.4.14", "merge", - "minicbor", "murmur3", "net2", "openssl", @@ -1101,21 +1101,31 @@ dependencies = [ [[package]] name = "pallas" -version = "0.6.0" +version = "0.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "686c2b5d4c4b3f4126888d2e03a9e68aa3c552ffb0831c8866d12870bf034318" +checksum = "346616c6ebff5e12430cdf2e7f9831bad155ce15b947a64f5866e0f51374825f" dependencies = [ + "pallas-codec", "pallas-crypto", "pallas-miniprotocols", "pallas-multiplexer", "pallas-primitives", ] +[[package]] +name = "pallas-codec" +version = "0.7.0-alpha.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "eb97576a7a1beb165c2a1a57890a1d38e4825c0e630bef2013d181d8cbc6f51f" +dependencies = [ + "minicbor", +] + [[package]] name = "pallas-crypto" -version = "0.6.0" +version = "0.7.0-alpha.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "04cdde829997dee2deb4926af3ec742161b737b04525d5a1b52e0613938b026f" +checksum = "e7171ccdc32c0b307bbe10d7283bedb07d91eac6686bcdf8c7669a062aad736d" dependencies = [ "cryptoxide", "hex", @@ -1126,23 +1136,23 @@ dependencies = [ [[package]] name = "pallas-miniprotocols" -version = "0.6.0" +version = "0.7.0-alpha.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7b7e37371b877146b0ad5d6a588a65f37eaf7409ec490487c33b368d6beb01a3" +checksum = "4b4b288f087c5182ce5fe1f4cd27307c568e38470f1b8d215fd39a5ef201c1ce" dependencies = [ "hex", "itertools", "log 0.4.14", - "minicbor", "net2", + "pallas-codec", "pallas-multiplexer", ] [[package]] name = "pallas-multiplexer" -version = "0.6.0" +version = "0.7.0-alpha.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "99ef34b849418628e93d234061200518275ff5a7d7580eb168b618eca2ed579e" +checksum = "fef40d430bf43530e8c2db1c122939cdc9f661511505f7af52e546b914b3e81b" dependencies = [ "byteorder 1.4.3", "hex", @@ -1151,15 +1161,14 @@ dependencies = [ [[package]] name = "pallas-primitives" -version = "0.6.4" +version = "0.7.0-alpha.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a884deec28ab5e0d26b04bb3c4dfa5907fff6bf728185c46ee9d9f4199b68f42" +checksum = "9737eb28b04e8170daef25fa8632867dd40ffa9f83f309c9fe1d1712523a7bbc" dependencies = [ "base58", "hex", "log 0.4.14", - "minicbor", - "minicbor-derive", + "pallas-codec", "pallas-crypto", ] diff --git a/Cargo.toml b/Cargo.toml index e4b56b44..1b0392a1 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -12,7 +12,7 @@ authors = ["Santiago Carmuega "] [dependencies] -pallas = "0.6.0" +pallas = "0.7.0" # pallas = { path = "../pallas/pallas" } hex = "0.4.3" net2 = "0.2.37" @@ -24,10 +24,9 @@ crossterm = "0.23" merge = "0.1.0" config = { version = "0.12.0", default-features = false, features = ["toml"] } serde = { version = "1.0.136", features = ["derive"] } -serde_json = "1.0.79" +serde_json = { version = "1.0.79", features = ["arbitrary_precision"] } strum = "0.24" strum_macros = "0.24" -minicbor = "0.14.1" prometheus_exporter = { version = "0.8.4", default-features = false } # feature logs diff --git a/src/mapper/map.rs b/src/mapper/map.rs index 07e628d6..e1fb6819 100644 --- a/src/mapper/map.rs +++ b/src/mapper/map.rs @@ -1,6 +1,6 @@ use std::collections::HashMap; -use minicbor::bytes::ByteVec; +use pallas::codec::minicbor::bytes::ByteVec; use pallas::crypto::hash::Hash; use pallas::ledger::primitives::alonzo::{ self as alonzo, AuxiliaryData, Block, Certificate, InstantaneousRewardSource, @@ -102,7 +102,7 @@ impl EventWriter { pub fn to_metadatum_json(&self, source: &Metadatum) -> Result { match source { - Metadatum::Int(x) => Ok(json!(x)), + Metadatum::Int(x) => Ok(json!(i128::from(*x))), Metadatum::Bytes(x) => Ok(json!(hex::encode(x.as_slice()))), Metadatum::Text(x) => Ok(json!(x)), Metadatum::Array(x) => { @@ -130,7 +130,7 @@ impl EventWriter { let data = MetadataRecord { label: metadatum_to_string_key(label), content: match value { - Metadatum::Int(x) => MetadatumRendition::IntScalar(*x), + Metadatum::Int(x) => MetadatumRendition::IntScalar(i128::from(*x)), Metadatum::Bytes(x) => MetadatumRendition::BytesHex(hex::encode(x.as_slice())), Metadatum::Text(x) => MetadatumRendition::TextScalar(x.clone()), Metadatum::Array(_) => { diff --git a/src/mapper/shelley.rs b/src/mapper/shelley.rs index 53607f3b..c5ec8c83 100644 --- a/src/mapper/shelley.rs +++ b/src/mapper/shelley.rs @@ -21,7 +21,9 @@ impl EventWriter { self.append_from(record)?; match label { - Metadatum::Int(721) => self.crawl_metadata_label_721(content)?, + Metadatum::Int(i) if i128::from(*i) == 721i128 => { + self.crawl_metadata_label_721(content)? + } Metadatum::Text(x) if x == "721" => self.crawl_metadata_label_721(content)?, _ => (), }; diff --git a/src/model.rs b/src/model.rs index 3b499032..054ac3bd 100644 --- a/src/model.rs +++ b/src/model.rs @@ -27,7 +27,7 @@ pub enum Era { pub enum MetadatumRendition { MapJson(JsonValue), ArrayJson(JsonValue), - IntScalar(i64), + IntScalar(i128), TextScalar(String), BytesHex(String), } diff --git a/src/sources/n2c/blocks.rs b/src/sources/n2c/blocks.rs index 1803e7ed..f573ede3 100644 --- a/src/sources/n2c/blocks.rs +++ b/src/sources/n2c/blocks.rs @@ -1,6 +1,7 @@ use std::ops::Deref; use pallas::{ + codec::minicbor::decode, ledger::primitives::{alonzo, byron, probing, Era}, network::miniprotocols::{chainsync::BlockContent, Point}, }; @@ -22,18 +23,18 @@ impl TryFrom for MultiEraBlock { match probing::probe_block_cbor_era(bytes) { probing::Outcome::Matched(era) => match era { pallas::ledger::primitives::Era::Byron => { - let block = minicbor::decode(bytes)?; + let block = decode(bytes)?; Ok(MultiEraBlock::Byron(Box::new(block))) } _ => { - let alonzo::BlockWrapper(_, block) = minicbor::decode(bytes)?; + let alonzo::BlockWrapper(_, block) = decode(bytes)?; Ok(MultiEraBlock::AlonzoCompatible(Box::new(block), era)) } }, // TODO: we're assuming that the genesis block is Byron-compatible. Is this a safe // assumption? probing::Outcome::GenesisBlock => { - let block = minicbor::decode(bytes)?; + let block = decode(bytes)?; Ok(MultiEraBlock::Byron(Box::new(block))) } probing::Outcome::Inconclusive => { diff --git a/src/sources/n2n/headers.rs b/src/sources/n2n/headers.rs index 64dcd786..1e524a47 100644 --- a/src/sources/n2n/headers.rs +++ b/src/sources/n2n/headers.rs @@ -1,4 +1,5 @@ use pallas::{ + codec::minicbor::decode, ledger::primitives::{alonzo, byron}, network::miniprotocols::{chainsync::HeaderContent, Point}, }; @@ -19,16 +20,16 @@ impl TryFrom for MultiEraHeader { match value.variant { 0 => match value.byron_prefix { Some((0, _)) => { - let header = minicbor::decode(&value.cbor)?; + let header = decode(&value.cbor)?; Ok(MultiEraHeader::ByronBoundary(header)) } _ => { - let header = minicbor::decode(&value.cbor)?; + let header = decode(&value.cbor)?; Ok(MultiEraHeader::Byron(header)) } }, _ => { - let header = minicbor::decode(&value.cbor)?; + let header = decode(&value.cbor)?; Ok(MultiEraHeader::AlonzoCompatible(header)) } }