Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(deps): Upgrade Pallas to v0.7.0 #198

Merged
merged 4 commits into from
Mar 16, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 25 additions & 16 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 2 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ authors = ["Santiago Carmuega <[email protected]>"]


[dependencies]
pallas = "0.6.0"
pallas = "0.7.0"
# pallas = { path = "../pallas/pallas" }
hex = "0.4.3"
net2 = "0.2.37"
Expand All @@ -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
Expand Down
6 changes: 3 additions & 3 deletions src/mapper/map.rs
Original file line number Diff line number Diff line change
@@ -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,
Expand Down Expand Up @@ -99,7 +99,7 @@ impl EventWriter {

pub fn to_metadatum_json(&self, source: &Metadatum) -> Result<JsonValue, Error> {
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) => {
Expand Down Expand Up @@ -127,7 +127,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(_) => {
Expand Down
4 changes: 3 additions & 1 deletion src/mapper/shelley.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)?,
_ => (),
};
Expand Down
2 changes: 1 addition & 1 deletion src/model.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ pub enum Era {
pub enum MetadatumRendition {
MapJson(JsonValue),
ArrayJson(JsonValue),
IntScalar(i64),
IntScalar(i128),
TextScalar(String),
BytesHex(String),
}
Expand Down
7 changes: 4 additions & 3 deletions src/sources/n2c/blocks.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
use std::ops::Deref;

use pallas::{
codec::minicbor::decode,
ledger::primitives::{alonzo, byron, probing, Era},
network::miniprotocols::{chainsync::BlockContent, Point},
};
Expand All @@ -22,18 +23,18 @@ impl TryFrom<BlockContent> 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 => {
Expand Down
7 changes: 4 additions & 3 deletions src/sources/n2n/headers.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
use pallas::{
codec::minicbor::decode,
ledger::primitives::{alonzo, byron},
network::miniprotocols::{chainsync::HeaderContent, Point},
};
Expand All @@ -19,16 +20,16 @@ impl TryFrom<HeaderContent> 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))
}
}
Expand Down