Update to pallas=0.31.0
This commit is contained in:
parent
c740e4639f
commit
b5047d623a
|
@ -5,6 +5,7 @@
|
||||||
### Changed
|
### Changed
|
||||||
|
|
||||||
- **aiken-lang**: Fix pattern-matching on list wildcard sometimes causing compiler crash following the new _decision trees_ approach. @MicroProofs
|
- **aiken-lang**: Fix pattern-matching on list wildcard sometimes causing compiler crash following the new _decision trees_ approach. @MicroProofs
|
||||||
|
- **uplc**, **aiken**, **aiken-lang**: Update internal dependencies to pallas-0.31.0. @KtorZ
|
||||||
|
|
||||||
## v1.1.6 - 2024-11-13
|
## v1.1.6 - 2024-11-13
|
||||||
|
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
10
Cargo.toml
10
Cargo.toml
|
@ -52,11 +52,11 @@ x86_64-unknown-linux-musl = "ubuntu-22.04"
|
||||||
walkdir = "2.3.2"
|
walkdir = "2.3.2"
|
||||||
insta = { version = "1.30.0", features = ["yaml", "json", "redactions"] }
|
insta = { version = "1.30.0", features = ["yaml", "json", "redactions"] }
|
||||||
miette = { version = "7.2.0" }
|
miette = { version = "7.2.0" }
|
||||||
pallas-addresses = "0.30.1"
|
pallas-addresses = "0.31.0"
|
||||||
pallas-codec = { version = "0.30.1", features = ["num-bigint"] }
|
pallas-codec = { version = "0.31.0", features = ["num-bigint"] }
|
||||||
pallas-crypto = "0.30.1"
|
pallas-crypto = "0.31.0"
|
||||||
pallas-primitives = "0.30.1"
|
pallas-primitives = "0.31.0"
|
||||||
pallas-traverse = "0.30.1"
|
pallas-traverse = "0.31.0"
|
||||||
|
|
||||||
[profile.dev.package.insta]
|
[profile.dev.package.insta]
|
||||||
opt-level = 3
|
opt-level = 3
|
||||||
|
|
|
@ -1007,6 +1007,7 @@ impl UntypedExpr {
|
||||||
PlutusData::Array(elems) => UntypedExpr::List {
|
PlutusData::Array(elems) => UntypedExpr::List {
|
||||||
location: Span::empty(),
|
location: Span::empty(),
|
||||||
elements: elems
|
elements: elems
|
||||||
|
.to_vec()
|
||||||
.into_iter()
|
.into_iter()
|
||||||
.map(UntypedExpr::reify_blind)
|
.map(UntypedExpr::reify_blind)
|
||||||
.collect::<Vec<_>>(),
|
.collect::<Vec<_>>(),
|
||||||
|
@ -1041,6 +1042,7 @@ impl UntypedExpr {
|
||||||
let ix = convert_tag_to_constr(tag).or(any_constructor).unwrap() as usize;
|
let ix = convert_tag_to_constr(tag).or(any_constructor).unwrap() as usize;
|
||||||
|
|
||||||
let fields = fields
|
let fields = fields
|
||||||
|
.to_vec()
|
||||||
.into_iter()
|
.into_iter()
|
||||||
.map(|field| CallArg {
|
.map(|field| CallArg {
|
||||||
location: Span::empty(),
|
location: Span::empty(),
|
||||||
|
@ -1127,6 +1129,7 @@ impl UntypedExpr {
|
||||||
Ok(UntypedExpr::List {
|
Ok(UntypedExpr::List {
|
||||||
location: Span::empty(),
|
location: Span::empty(),
|
||||||
elements: args
|
elements: args
|
||||||
|
.to_vec()
|
||||||
.into_iter()
|
.into_iter()
|
||||||
.map(|arg| {
|
.map(|arg| {
|
||||||
UntypedExpr::do_reify_data(generics, data_types, arg, inner)
|
UntypedExpr::do_reify_data(generics, data_types, arg, inner)
|
||||||
|
@ -1144,6 +1147,7 @@ impl UntypedExpr {
|
||||||
Type::Tuple { elems, .. } => Ok(UntypedExpr::Tuple {
|
Type::Tuple { elems, .. } => Ok(UntypedExpr::Tuple {
|
||||||
location: Span::empty(),
|
location: Span::empty(),
|
||||||
elems: args
|
elems: args
|
||||||
|
.to_vec()
|
||||||
.into_iter()
|
.into_iter()
|
||||||
.zip(elems)
|
.zip(elems)
|
||||||
.map(|(arg, arg_type)| {
|
.map(|(arg, arg_type)| {
|
||||||
|
@ -1153,6 +1157,7 @@ impl UntypedExpr {
|
||||||
}),
|
}),
|
||||||
Type::Pair { fst, snd, .. } => {
|
Type::Pair { fst, snd, .. } => {
|
||||||
let mut elems = args
|
let mut elems = args
|
||||||
|
.to_vec()
|
||||||
.into_iter()
|
.into_iter()
|
||||||
.zip([fst, snd])
|
.zip([fst, snd])
|
||||||
.map(|(arg, arg_type)| {
|
.map(|(arg, arg_type)| {
|
||||||
|
@ -1213,6 +1218,7 @@ impl UntypedExpr {
|
||||||
} else {
|
} else {
|
||||||
let arguments =
|
let arguments =
|
||||||
fields
|
fields
|
||||||
|
.to_vec()
|
||||||
.into_iter()
|
.into_iter()
|
||||||
.zip(constructor.arguments.iter())
|
.zip(constructor.arguments.iter())
|
||||||
.map(
|
.map(
|
||||||
|
@ -1264,9 +1270,9 @@ impl UntypedExpr {
|
||||||
UntypedExpr::do_reify_data(
|
UntypedExpr::do_reify_data(
|
||||||
generics,
|
generics,
|
||||||
data_types,
|
data_types,
|
||||||
PlutusData::Array(
|
Data::list(
|
||||||
kvs.into_iter()
|
kvs.into_iter()
|
||||||
.map(|(k, v)| PlutusData::Array(vec![k, v]))
|
.map(|(k, v)| Data::list(vec![k, v]))
|
||||||
.collect(),
|
.collect(),
|
||||||
),
|
),
|
||||||
tipo,
|
tipo,
|
||||||
|
|
|
@ -18,14 +18,11 @@ use indexmap::IndexMap;
|
||||||
use itertools::{Itertools, Position};
|
use itertools::{Itertools, Position};
|
||||||
use std::{ops::Deref, rc::Rc};
|
use std::{ops::Deref, rc::Rc};
|
||||||
use uplc::{
|
use uplc::{
|
||||||
ast::{Constant as UplcConstant, Name, Term, Type as UplcType},
|
ast::{Constant as UplcConstant, Data, Name, Term, Type as UplcType},
|
||||||
builder::{CONSTR_FIELDS_EXPOSER, CONSTR_INDEX_EXPOSER},
|
builder::{CONSTR_FIELDS_EXPOSER, CONSTR_INDEX_EXPOSER},
|
||||||
builtins::DefaultFunction,
|
builtins::DefaultFunction,
|
||||||
machine::{
|
machine::{runtime::Compressable, value::to_pallas_bigint},
|
||||||
runtime::{convert_constr_to_tag, Compressable, ANY_TAG},
|
KeyValuePairs, PlutusData,
|
||||||
value::to_pallas_bigint,
|
|
||||||
},
|
|
||||||
Constr, KeyValuePairs, PlutusData,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
pub type Variant = String;
|
pub type Variant = String;
|
||||||
|
@ -637,12 +634,7 @@ pub fn convert_constants_to_data(constants: Vec<Rc<UplcConstant>>) -> Vec<UplcCo
|
||||||
UplcConstant::Data(PlutusData::BoundedBytes(s.as_bytes().to_vec().into()))
|
UplcConstant::Data(PlutusData::BoundedBytes(s.as_bytes().to_vec().into()))
|
||||||
}
|
}
|
||||||
|
|
||||||
UplcConstant::Bool(b) => UplcConstant::Data(PlutusData::Constr(Constr {
|
UplcConstant::Bool(b) => UplcConstant::Data(Data::constr((*b).into(), vec![])),
|
||||||
tag: convert_constr_to_tag((*b).into()).unwrap_or(ANY_TAG),
|
|
||||||
any_constructor: convert_constr_to_tag((*b).into())
|
|
||||||
.map_or(Some((*b).into()), |_| None),
|
|
||||||
fields: vec![],
|
|
||||||
})),
|
|
||||||
UplcConstant::ProtoList(list_type, constants) => {
|
UplcConstant::ProtoList(list_type, constants) => {
|
||||||
if matches!(list_type, UplcType::Pair(_, _)) {
|
if matches!(list_type, UplcType::Pair(_, _)) {
|
||||||
let inner_constants = constants
|
let inner_constants = constants
|
||||||
|
@ -675,7 +667,7 @@ pub fn convert_constants_to_data(constants: Vec<Rc<UplcConstant>>) -> Vec<UplcCo
|
||||||
})
|
})
|
||||||
.collect_vec();
|
.collect_vec();
|
||||||
|
|
||||||
UplcConstant::Data(PlutusData::Array(inner_constants))
|
UplcConstant::Data(Data::list(inner_constants))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
UplcConstant::ProtoPair(_, _, left, right) => {
|
UplcConstant::ProtoPair(_, _, left, right) => {
|
||||||
|
@ -688,17 +680,13 @@ pub fn convert_constants_to_data(constants: Vec<Rc<UplcConstant>>) -> Vec<UplcCo
|
||||||
})
|
})
|
||||||
.collect_vec();
|
.collect_vec();
|
||||||
|
|
||||||
UplcConstant::Data(PlutusData::Array(vec![
|
UplcConstant::Data(Data::list(vec![
|
||||||
inner_constants[0].clone(),
|
inner_constants[0].clone(),
|
||||||
inner_constants[1].clone(),
|
inner_constants[1].clone(),
|
||||||
]))
|
]))
|
||||||
}
|
}
|
||||||
d @ UplcConstant::Data(_) => d.clone(),
|
d @ UplcConstant::Data(_) => d.clone(),
|
||||||
UplcConstant::Unit => UplcConstant::Data(PlutusData::Constr(Constr {
|
UplcConstant::Unit => UplcConstant::Data(Data::constr(0, vec![])),
|
||||||
tag: convert_constr_to_tag(0).unwrap(),
|
|
||||||
any_constructor: None,
|
|
||||||
fields: vec![],
|
|
||||||
})),
|
|
||||||
UplcConstant::Bls12_381G1Element(b) => UplcConstant::Data(PlutusData::BoundedBytes(
|
UplcConstant::Bls12_381G1Element(b) => UplcConstant::Data(PlutusData::BoundedBytes(
|
||||||
b.deref().clone().compress().into(),
|
b.deref().clone().compress().into(),
|
||||||
)),
|
)),
|
||||||
|
@ -741,33 +729,12 @@ pub fn convert_type_to_data(term: Term<Name>, field_type: &Rc<Type>) -> Term<Nam
|
||||||
)
|
)
|
||||||
.lambda("__pair")
|
.lambda("__pair")
|
||||||
.apply(term),
|
.apply(term),
|
||||||
Some(UplcType::Unit) => Term::Constant(
|
Some(UplcType::Unit) => Term::Constant(UplcConstant::Data(Data::constr(0, vec![])).into())
|
||||||
UplcConstant::Data(PlutusData::Constr(Constr {
|
.lambda("_")
|
||||||
tag: convert_constr_to_tag(0).unwrap(),
|
.apply(term),
|
||||||
any_constructor: None,
|
|
||||||
fields: vec![],
|
|
||||||
}))
|
|
||||||
.into(),
|
|
||||||
)
|
|
||||||
.lambda("_")
|
|
||||||
.apply(term),
|
|
||||||
Some(UplcType::Bool) => term.if_then_else(
|
Some(UplcType::Bool) => term.if_then_else(
|
||||||
Term::Constant(
|
Term::Constant(UplcConstant::Data(Data::constr(1, vec![])).into()),
|
||||||
UplcConstant::Data(PlutusData::Constr(Constr {
|
Term::Constant(UplcConstant::Data(Data::constr(0, vec![])).into()),
|
||||||
tag: convert_constr_to_tag(1).unwrap(),
|
|
||||||
any_constructor: None,
|
|
||||||
fields: vec![],
|
|
||||||
}))
|
|
||||||
.into(),
|
|
||||||
),
|
|
||||||
Term::Constant(
|
|
||||||
UplcConstant::Data(PlutusData::Constr(Constr {
|
|
||||||
tag: convert_constr_to_tag(0).unwrap(),
|
|
||||||
any_constructor: None,
|
|
||||||
fields: vec![],
|
|
||||||
}))
|
|
||||||
.into(),
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
|
|
||||||
Some(UplcType::Data) | None => term,
|
Some(UplcType::Data) | None => term,
|
||||||
|
|
|
@ -559,16 +559,15 @@ impl Prng {
|
||||||
{
|
{
|
||||||
return Prng::Seeded {
|
return Prng::Seeded {
|
||||||
choices: choices.to_vec(),
|
choices: choices.to_vec(),
|
||||||
uplc: PlutusData::Constr(Constr {
|
uplc: Data::constr(
|
||||||
tag: 121 + Prng::SEEDED,
|
Prng::SEEDED,
|
||||||
fields: vec![
|
vec![
|
||||||
PlutusData::BoundedBytes(bytes.to_owned()),
|
PlutusData::BoundedBytes(bytes.to_owned()),
|
||||||
// Clear choices between seeded runs, to not
|
// Clear choices between seeded runs, to not
|
||||||
// accumulate ALL choices ever made.
|
// accumulate ALL choices ever made.
|
||||||
PlutusData::BoundedBytes(vec![].into()),
|
PlutusData::BoundedBytes(vec![].into()),
|
||||||
],
|
],
|
||||||
any_constructor: None,
|
),
|
||||||
}),
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -149,21 +149,21 @@ impl SerializableProgram {
|
||||||
PlutusV1Program(pgrm) => {
|
PlutusV1Program(pgrm) => {
|
||||||
let cbor = pgrm.to_cbor().unwrap();
|
let cbor = pgrm.to_cbor().unwrap();
|
||||||
let compiled_code = hex::encode(&cbor);
|
let compiled_code = hex::encode(&cbor);
|
||||||
let hash = conway::PlutusV1Script(cbor.into()).compute_hash();
|
let hash = conway::PlutusScript::<1>(cbor.into()).compute_hash();
|
||||||
(compiled_code, hash)
|
(compiled_code, hash)
|
||||||
}
|
}
|
||||||
|
|
||||||
PlutusV2Program(pgrm) => {
|
PlutusV2Program(pgrm) => {
|
||||||
let cbor = pgrm.to_cbor().unwrap();
|
let cbor = pgrm.to_cbor().unwrap();
|
||||||
let compiled_code = hex::encode(&cbor);
|
let compiled_code = hex::encode(&cbor);
|
||||||
let hash = conway::PlutusV2Script(cbor.into()).compute_hash();
|
let hash = conway::PlutusScript::<2>(cbor.into()).compute_hash();
|
||||||
(compiled_code, hash)
|
(compiled_code, hash)
|
||||||
}
|
}
|
||||||
|
|
||||||
PlutusV3Program(pgrm) => {
|
PlutusV3Program(pgrm) => {
|
||||||
let cbor = pgrm.to_cbor().unwrap();
|
let cbor = pgrm.to_cbor().unwrap();
|
||||||
let compiled_code = hex::encode(&cbor);
|
let compiled_code = hex::encode(&cbor);
|
||||||
let hash = conway::PlutusV3Script(cbor.into()).compute_hash();
|
let hash = conway::PlutusScript::<3>(cbor.into()).compute_hash();
|
||||||
(compiled_code, hash)
|
(compiled_code, hash)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -239,15 +239,15 @@ impl<'a> Deserialize<'a> for SerializableProgram {
|
||||||
.and_then(|program| {
|
.and_then(|program| {
|
||||||
let cbor = || program.to_cbor().unwrap().into();
|
let cbor = || program.to_cbor().unwrap().into();
|
||||||
|
|
||||||
if conway::PlutusV3Script(cbor()).compute_hash().to_string() == hash {
|
if conway::PlutusScript::<1>(cbor()).compute_hash().to_string() == hash {
|
||||||
return Ok(SerializableProgram::PlutusV3Program(program));
|
return Ok(SerializableProgram::PlutusV3Program(program));
|
||||||
}
|
}
|
||||||
|
|
||||||
if conway::PlutusV2Script(cbor()).compute_hash().to_string() == hash {
|
if conway::PlutusScript::<2>(cbor()).compute_hash().to_string() == hash {
|
||||||
return Ok(SerializableProgram::PlutusV2Program(program));
|
return Ok(SerializableProgram::PlutusV2Program(program));
|
||||||
}
|
}
|
||||||
|
|
||||||
if conway::PlutusV1Script(cbor()).compute_hash().to_string() == hash {
|
if conway::PlutusScript::<3>(cbor()).compute_hash().to_string() == hash {
|
||||||
return Ok(SerializableProgram::PlutusV1Program(program));
|
return Ok(SerializableProgram::PlutusV1Program(program));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -273,9 +273,9 @@ impl Program<DeBruijn> {
|
||||||
let cbor = self.to_cbor().unwrap();
|
let cbor = self.to_cbor().unwrap();
|
||||||
|
|
||||||
let validator_hash = match plutus_version {
|
let validator_hash = match plutus_version {
|
||||||
Language::PlutusV1 => conway::PlutusV1Script(cbor.into()).compute_hash(),
|
Language::PlutusV1 => conway::PlutusScript::<1>(cbor.into()).compute_hash(),
|
||||||
Language::PlutusV2 => conway::PlutusV2Script(cbor.into()).compute_hash(),
|
Language::PlutusV2 => conway::PlutusScript::<2>(cbor.into()).compute_hash(),
|
||||||
Language::PlutusV3 => conway::PlutusV3Script(cbor.into()).compute_hash(),
|
Language::PlutusV3 => conway::PlutusScript::<3>(cbor.into()).compute_hash(),
|
||||||
};
|
};
|
||||||
|
|
||||||
ShelleyAddress::new(
|
ShelleyAddress::new(
|
||||||
|
@ -420,10 +420,20 @@ impl Data {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn list(xs: Vec<PlutusData>) -> PlutusData {
|
pub fn list(xs: Vec<PlutusData>) -> PlutusData {
|
||||||
PlutusData::Array(xs)
|
PlutusData::Array(if xs.is_empty() {
|
||||||
|
conway::MaybeIndefArray::Def(xs)
|
||||||
|
} else {
|
||||||
|
conway::MaybeIndefArray::Indef(xs)
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn constr(ix: u64, fields: Vec<PlutusData>) -> PlutusData {
|
pub fn constr(ix: u64, fields: Vec<PlutusData>) -> PlutusData {
|
||||||
|
let fields = if fields.is_empty() {
|
||||||
|
conway::MaybeIndefArray::Def(fields)
|
||||||
|
} else {
|
||||||
|
conway::MaybeIndefArray::Indef(fields)
|
||||||
|
};
|
||||||
|
|
||||||
// NOTE: see https://github.com/input-output-hk/plutus/blob/9538fc9829426b2ecb0628d352e2d7af96ec8204/plutus-core/plutus-core/src/PlutusCore/Data.hs#L139-L155
|
// NOTE: see https://github.com/input-output-hk/plutus/blob/9538fc9829426b2ecb0628d352e2d7af96ec8204/plutus-core/plutus-core/src/PlutusCore/Data.hs#L139-L155
|
||||||
if ix < 7 {
|
if ix < 7 {
|
||||||
PlutusData::Constr(Constr {
|
PlutusData::Constr(Constr {
|
||||||
|
|
|
@ -881,7 +881,7 @@ impl DefaultFunction {
|
||||||
})
|
})
|
||||||
.collect();
|
.collect();
|
||||||
|
|
||||||
let value = Value::data(PlutusData::Array(data_list));
|
let value = Value::data(Data::list(data_list));
|
||||||
|
|
||||||
Ok(value)
|
Ok(value)
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
use crate::{
|
use crate::{
|
||||||
ast::{Constant, Name, Program, Term, Type},
|
ast::{Constant, Data, Name, Program, Term, Type},
|
||||||
builtins::DefaultFunction,
|
builtins::DefaultFunction,
|
||||||
machine::{runtime::Compressable, value::to_pallas_bigint},
|
machine::{runtime::Compressable, value::to_pallas_bigint},
|
||||||
};
|
};
|
||||||
|
@ -239,7 +239,7 @@ peg::parser! {
|
||||||
|
|
||||||
rule data() -> PlutusData
|
rule data() -> PlutusData
|
||||||
= _* "Constr" _+ t:decimal() _+ fs:plutus_list() {?
|
= _* "Constr" _+ t:decimal() _+ fs:plutus_list() {?
|
||||||
Ok(crate::ast::Data::constr(
|
Ok(Data::constr(
|
||||||
u64::try_from(t).or(Err("tag"))?,
|
u64::try_from(t).or(Err("tag"))?,
|
||||||
fs,
|
fs,
|
||||||
))
|
))
|
||||||
|
@ -247,7 +247,7 @@ peg::parser! {
|
||||||
/ _* "Map" _+ kvps:plutus_key_value_pairs() {
|
/ _* "Map" _+ kvps:plutus_key_value_pairs() {
|
||||||
PlutusData::Map(pallas_codec::utils::KeyValuePairs::Def(kvps))
|
PlutusData::Map(pallas_codec::utils::KeyValuePairs::Def(kvps))
|
||||||
}
|
}
|
||||||
/ _* "List" _+ ls:plutus_list() { PlutusData::Array(ls) }
|
/ _* "List" _+ ls:plutus_list() { Data::list(ls) }
|
||||||
/ _* "I" _+ n:big_number() { PlutusData::BigInt(to_pallas_bigint(&n)) }
|
/ _* "I" _+ n:big_number() { PlutusData::BigInt(to_pallas_bigint(&n)) }
|
||||||
/ _* "B" _+ "#" i:ident()* {?
|
/ _* "B" _+ "#" i:ident()* {?
|
||||||
Ok(PlutusData::BoundedBytes(
|
Ok(PlutusData::BoundedBytes(
|
||||||
|
|
|
@ -5,7 +5,10 @@ use crate::{
|
||||||
};
|
};
|
||||||
use error::Error;
|
use error::Error;
|
||||||
use pallas_primitives::{
|
use pallas_primitives::{
|
||||||
conway::{CostMdls, MintedTx, Redeemer, TransactionInput, TransactionOutput},
|
conway::{
|
||||||
|
CostModels, ExUnits, MintedTx, Redeemer, Redeemers, RedeemersKey, TransactionInput,
|
||||||
|
TransactionOutput,
|
||||||
|
},
|
||||||
Fragment,
|
Fragment,
|
||||||
};
|
};
|
||||||
use pallas_traverse::{Era, MultiEraTx};
|
use pallas_traverse::{Era, MultiEraTx};
|
||||||
|
@ -28,7 +31,7 @@ pub mod to_plutus_data;
|
||||||
pub fn eval_phase_two(
|
pub fn eval_phase_two(
|
||||||
tx: &MintedTx,
|
tx: &MintedTx,
|
||||||
utxos: &[ResolvedInput],
|
utxos: &[ResolvedInput],
|
||||||
cost_mdls: Option<&CostMdls>,
|
cost_mdls: Option<&CostModels>,
|
||||||
initial_budget: Option<&ExBudget>,
|
initial_budget: Option<&ExBudget>,
|
||||||
slot_config: &SlotConfig,
|
slot_config: &SlotConfig,
|
||||||
run_phase_one: bool,
|
run_phase_one: bool,
|
||||||
|
@ -49,12 +52,12 @@ pub fn eval_phase_two(
|
||||||
|
|
||||||
let mut remaining_budget = *initial_budget.unwrap_or(&ExBudget::default());
|
let mut remaining_budget = *initial_budget.unwrap_or(&ExBudget::default());
|
||||||
|
|
||||||
for (redeemer_key, redeemer_value) in rs.iter() {
|
for (key, data, ex_units) in iter_redeemers(rs) {
|
||||||
let redeemer = Redeemer {
|
let redeemer = Redeemer {
|
||||||
tag: redeemer_key.tag,
|
tag: key.tag,
|
||||||
index: redeemer_key.index,
|
index: key.index,
|
||||||
data: redeemer_value.data.clone(),
|
data: data.clone(),
|
||||||
ex_units: redeemer_value.ex_units,
|
ex_units,
|
||||||
};
|
};
|
||||||
|
|
||||||
with_redeemer(&redeemer);
|
with_redeemer(&redeemer);
|
||||||
|
@ -100,7 +103,9 @@ pub fn eval_phase_two_raw(
|
||||||
.or_else(|_| MultiEraTx::decode_for_era(Era::Babbage, tx_bytes))
|
.or_else(|_| MultiEraTx::decode_for_era(Era::Babbage, tx_bytes))
|
||||||
.or_else(|_| MultiEraTx::decode_for_era(Era::Alonzo, tx_bytes))?;
|
.or_else(|_| MultiEraTx::decode_for_era(Era::Alonzo, tx_bytes))?;
|
||||||
|
|
||||||
let cost_mdls = cost_mdls_bytes.map(CostMdls::decode_fragment).transpose()?;
|
let cost_mdls = cost_mdls_bytes
|
||||||
|
.map(CostModels::decode_fragment)
|
||||||
|
.transpose()?;
|
||||||
|
|
||||||
let budget = ExBudget {
|
let budget = ExBudget {
|
||||||
cpu: initial_budget.0 as i64,
|
cpu: initial_budget.0 as i64,
|
||||||
|
@ -161,7 +166,7 @@ pub fn apply_params_to_script(
|
||||||
let mut buffer = Vec::new();
|
let mut buffer = Vec::new();
|
||||||
let mut program = Program::<DeBruijn>::from_cbor(plutus_script_bytes, &mut buffer)?;
|
let mut program = Program::<DeBruijn>::from_cbor(plutus_script_bytes, &mut buffer)?;
|
||||||
|
|
||||||
for param in params {
|
for param in params.to_vec() {
|
||||||
program = program.apply_data(param);
|
program = program.apply_data(param);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -170,3 +175,31 @@ pub fn apply_params_to_script(
|
||||||
Err(_) => Err(Error::ApplyParamsError),
|
Err(_) => Err(Error::ApplyParamsError),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn iter_redeemers(
|
||||||
|
redeemers: &Redeemers,
|
||||||
|
) -> impl Iterator<Item = (RedeemersKey, &PlutusData, ExUnits)> {
|
||||||
|
match redeemers {
|
||||||
|
Redeemers::List(rs) => Box::new(rs.iter().map(|r| {
|
||||||
|
(
|
||||||
|
RedeemersKey {
|
||||||
|
tag: r.tag,
|
||||||
|
index: r.index,
|
||||||
|
},
|
||||||
|
&r.data,
|
||||||
|
r.ex_units,
|
||||||
|
)
|
||||||
|
})),
|
||||||
|
Redeemers::Map(kv) => Box::new(kv.iter().map(|(k, v)| {
|
||||||
|
(
|
||||||
|
RedeemersKey {
|
||||||
|
tag: k.tag,
|
||||||
|
index: k.index,
|
||||||
|
},
|
||||||
|
&v.data,
|
||||||
|
v.ex_units,
|
||||||
|
)
|
||||||
|
}))
|
||||||
|
as Box<dyn Iterator<Item = (RedeemersKey, &PlutusData, ExUnits)>>,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -13,7 +13,7 @@ use crate::{
|
||||||
PlutusData,
|
PlutusData,
|
||||||
};
|
};
|
||||||
use pallas_codec::utils::Bytes;
|
use pallas_codec::utils::Bytes;
|
||||||
use pallas_primitives::conway::{CostMdls, CostModel, ExUnits, Language, MintedTx, Redeemer};
|
use pallas_primitives::conway::{CostModel, CostModels, ExUnits, Language, MintedTx, Redeemer};
|
||||||
|
|
||||||
pub fn eval_redeemer(
|
pub fn eval_redeemer(
|
||||||
tx: &MintedTx,
|
tx: &MintedTx,
|
||||||
|
@ -21,7 +21,7 @@ pub fn eval_redeemer(
|
||||||
slot_config: &SlotConfig,
|
slot_config: &SlotConfig,
|
||||||
redeemer: &Redeemer,
|
redeemer: &Redeemer,
|
||||||
lookup_table: &DataLookupTable,
|
lookup_table: &DataLookupTable,
|
||||||
cost_mdls_opt: Option<&CostMdls>,
|
cost_mdls_opt: Option<&CostModels>,
|
||||||
initial_budget: &ExBudget,
|
initial_budget: &ExBudget,
|
||||||
) -> Result<Redeemer, Error> {
|
) -> Result<Redeemer, Error> {
|
||||||
fn do_eval_redeemer(
|
fn do_eval_redeemer(
|
||||||
|
|
|
@ -7,8 +7,8 @@ use itertools::Itertools;
|
||||||
use pallas_addresses::{Address, ScriptHash, ShelleyPaymentPart, StakePayload};
|
use pallas_addresses::{Address, ScriptHash, ShelleyPaymentPart, StakePayload};
|
||||||
use pallas_codec::utils::Nullable;
|
use pallas_codec::utils::Nullable;
|
||||||
use pallas_primitives::conway::{
|
use pallas_primitives::conway::{
|
||||||
Certificate, GovAction, MintedTx, PolicyId, RedeemerTag, RedeemersKey, RewardAccount,
|
Certificate, GovAction, MintedTx, PolicyId, RedeemerTag, Redeemers, RedeemersKey,
|
||||||
StakeCredential, TransactionOutput, Voter,
|
RewardAccount, StakeCredential, TransactionOutput, Voter,
|
||||||
};
|
};
|
||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
|
|
||||||
|
@ -92,7 +92,7 @@ pub fn scripts_needed(tx: &MintedTx, utxos: &[ResolvedInput]) -> Result<ScriptsN
|
||||||
|
|
||||||
if let Address::Stake(a) = address {
|
if let Address::Stake(a) = address {
|
||||||
if let StakePayload::Script(h) = a.payload() {
|
if let StakePayload::Script(h) = a.payload() {
|
||||||
let cred = StakeCredential::Scripthash(*h);
|
let cred = StakeCredential::ScriptHash(*h);
|
||||||
return Some((ScriptPurpose::Rewarding(cred), *h));
|
return Some((ScriptPurpose::Rewarding(cred), *h));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -110,19 +110,19 @@ pub fn scripts_needed(tx: &MintedTx, utxos: &[ResolvedInput]) -> Result<ScriptsN
|
||||||
m.iter()
|
m.iter()
|
||||||
.enumerate()
|
.enumerate()
|
||||||
.filter_map(|(ix, cert)| match cert {
|
.filter_map(|(ix, cert)| match cert {
|
||||||
Certificate::StakeDeregistration(StakeCredential::Scripthash(h))
|
Certificate::StakeDeregistration(StakeCredential::ScriptHash(h))
|
||||||
| Certificate::UnReg(StakeCredential::Scripthash(h), _)
|
| Certificate::UnReg(StakeCredential::ScriptHash(h), _)
|
||||||
| Certificate::VoteDeleg(StakeCredential::Scripthash(h), _)
|
| Certificate::VoteDeleg(StakeCredential::ScriptHash(h), _)
|
||||||
| Certificate::VoteRegDeleg(StakeCredential::Scripthash(h), _, _)
|
| Certificate::VoteRegDeleg(StakeCredential::ScriptHash(h), _, _)
|
||||||
| Certificate::StakeVoteDeleg(StakeCredential::Scripthash(h), _, _)
|
| Certificate::StakeVoteDeleg(StakeCredential::ScriptHash(h), _, _)
|
||||||
| Certificate::StakeRegDeleg(StakeCredential::Scripthash(h), _, _)
|
| Certificate::StakeRegDeleg(StakeCredential::ScriptHash(h), _, _)
|
||||||
| Certificate::StakeVoteRegDeleg(StakeCredential::Scripthash(h), _, _, _)
|
| Certificate::StakeVoteRegDeleg(StakeCredential::ScriptHash(h), _, _, _)
|
||||||
| Certificate::RegDRepCert(StakeCredential::Scripthash(h), _, _)
|
| Certificate::RegDRepCert(StakeCredential::ScriptHash(h), _, _)
|
||||||
| Certificate::UnRegDRepCert(StakeCredential::Scripthash(h), _)
|
| Certificate::UnRegDRepCert(StakeCredential::ScriptHash(h), _)
|
||||||
| Certificate::UpdateDRepCert(StakeCredential::Scripthash(h), _)
|
| Certificate::UpdateDRepCert(StakeCredential::ScriptHash(h), _)
|
||||||
| Certificate::AuthCommitteeHot(StakeCredential::Scripthash(h), _)
|
| Certificate::AuthCommitteeHot(StakeCredential::ScriptHash(h), _)
|
||||||
| Certificate::ResignCommitteeCold(StakeCredential::Scripthash(h), _)
|
| Certificate::ResignCommitteeCold(StakeCredential::ScriptHash(h), _)
|
||||||
| Certificate::StakeDelegation(StakeCredential::Scripthash(h), _) => {
|
| Certificate::StakeDelegation(StakeCredential::ScriptHash(h), _) => {
|
||||||
Some((ScriptPurpose::Certifying(ix, cert.clone()), *h))
|
Some((ScriptPurpose::Certifying(ix, cert.clone()), *h))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -222,11 +222,26 @@ pub fn has_exact_set_of_redeemers(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
let wits_redeemer_keys: Vec<&RedeemersKey> = tx
|
let wits_redeemer_keys: Vec<RedeemersKey> = tx
|
||||||
.transaction_witness_set
|
.transaction_witness_set
|
||||||
.redeemer
|
.redeemer
|
||||||
.as_deref()
|
.as_deref()
|
||||||
.map(|m| m.iter().map(|(k, _)| k).collect())
|
.map(|m| match m {
|
||||||
|
Redeemers::List(rs) => rs
|
||||||
|
.iter()
|
||||||
|
.map(|r| RedeemersKey {
|
||||||
|
index: r.index,
|
||||||
|
tag: r.tag,
|
||||||
|
})
|
||||||
|
.collect(),
|
||||||
|
Redeemers::Map(kv) => kv
|
||||||
|
.iter()
|
||||||
|
.map(|(k, _)| RedeemersKey {
|
||||||
|
index: k.index,
|
||||||
|
tag: k.tag,
|
||||||
|
})
|
||||||
|
.collect(),
|
||||||
|
})
|
||||||
.unwrap_or_default();
|
.unwrap_or_default();
|
||||||
|
|
||||||
let needed_redeemer_keys: Vec<RedeemersKey> =
|
let needed_redeemer_keys: Vec<RedeemersKey> =
|
||||||
|
@ -234,7 +249,7 @@ pub fn has_exact_set_of_redeemers(
|
||||||
|
|
||||||
let missing: Vec<_> = redeemers_needed
|
let missing: Vec<_> = redeemers_needed
|
||||||
.into_iter()
|
.into_iter()
|
||||||
.filter(|x| !wits_redeemer_keys.contains(&&x.0))
|
.filter(|x| !wits_redeemer_keys.contains(&x.0))
|
||||||
.map(|x| {
|
.map(|x| {
|
||||||
format!(
|
format!(
|
||||||
"{}[{:?}] -> {}",
|
"{}[{:?}] -> {}",
|
||||||
|
@ -321,7 +336,7 @@ fn build_redeemer_key(
|
||||||
for (idx, x) in reward_accounts.iter().enumerate() {
|
for (idx, x) in reward_accounts.iter().enumerate() {
|
||||||
let cred = match Address::from_bytes(x).unwrap() {
|
let cred = match Address::from_bytes(x).unwrap() {
|
||||||
Address::Stake(a) => match a.payload() {
|
Address::Stake(a) => match a.payload() {
|
||||||
StakePayload::Script(sh) => Some(StakeCredential::Scripthash(*sh)),
|
StakePayload::Script(sh) => Some(StakeCredential::ScriptHash(*sh)),
|
||||||
StakePayload::Stake(_) => None,
|
StakePayload::Stake(_) => None,
|
||||||
},
|
},
|
||||||
_ => return Err(Error::BadWithdrawalAddress),
|
_ => return Err(Error::BadWithdrawalAddress),
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
use super::{to_plutus_data::MintValue, Error};
|
use super::{to_plutus_data::MintValue, Error};
|
||||||
|
use crate::tx::iter_redeemers;
|
||||||
use itertools::Itertools;
|
use itertools::Itertools;
|
||||||
use pallas_addresses::{Address, Network, StakePayload};
|
use pallas_addresses::{Address, Network, StakePayload};
|
||||||
use pallas_codec::utils::{
|
use pallas_codec::utils::{
|
||||||
|
@ -10,10 +11,10 @@ use pallas_primitives::{
|
||||||
conway::{
|
conway::{
|
||||||
AddrKeyhash, Certificate, Coin, DatumHash, DatumOption, GovAction, GovActionId, Mint,
|
AddrKeyhash, Certificate, Coin, DatumHash, DatumOption, GovAction, GovActionId, Mint,
|
||||||
MintedTransactionBody, MintedTransactionOutput, MintedTx, MintedWitnessSet, NativeScript,
|
MintedTransactionBody, MintedTransactionOutput, MintedTx, MintedWitnessSet, NativeScript,
|
||||||
PlutusData, PlutusV1Script, PlutusV2Script, PlutusV3Script, PolicyId,
|
PlutusData, PlutusScript, PolicyId, PostAlonzoTransactionOutput, ProposalProcedure,
|
||||||
PostAlonzoTransactionOutput, ProposalProcedure, PseudoDatumOption, PseudoScript, Redeemer,
|
PseudoDatumOption, PseudoScript, Redeemer, RedeemerTag, RedeemersKey, RequiredSigners,
|
||||||
RedeemerTag, RedeemersKey, RequiredSigners, RewardAccount, ScriptHash, StakeCredential,
|
RewardAccount, ScriptHash, StakeCredential, TransactionInput, TransactionOutput, Value,
|
||||||
TransactionInput, TransactionOutput, Value, Voter, VotingProcedure,
|
Voter, VotingProcedure,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
use pallas_traverse::{ComputeHash, OriginalHash};
|
use pallas_traverse::{ComputeHash, OriginalHash};
|
||||||
|
@ -77,9 +78,9 @@ impl ScriptPurpose {
|
||||||
#[derive(Debug, PartialEq, Clone)]
|
#[derive(Debug, PartialEq, Clone)]
|
||||||
pub enum ScriptVersion {
|
pub enum ScriptVersion {
|
||||||
Native(NativeScript),
|
Native(NativeScript),
|
||||||
V1(PlutusV1Script),
|
V1(PlutusScript<1>),
|
||||||
V2(PlutusV2Script),
|
V2(PlutusScript<2>),
|
||||||
V3(PlutusV3Script),
|
V3(PlutusScript<3>),
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct DataLookupTable {
|
pub struct DataLookupTable {
|
||||||
|
@ -400,7 +401,7 @@ impl TxInfo {
|
||||||
| TxInfo::V2(TxInfoV2 { ref redeemers, .. }) => redeemers
|
| TxInfo::V2(TxInfoV2 { ref redeemers, .. }) => redeemers
|
||||||
.iter()
|
.iter()
|
||||||
.find_map(move |(purpose, some_redeemer)| {
|
.find_map(move |(purpose, some_redeemer)| {
|
||||||
if redeemer == some_redeemer {
|
if redeemer.tag == some_redeemer.tag && redeemer.index == some_redeemer.index {
|
||||||
Some(purpose.clone())
|
Some(purpose.clone())
|
||||||
} else {
|
} else {
|
||||||
None
|
None
|
||||||
|
@ -414,7 +415,7 @@ impl TxInfo {
|
||||||
TxInfo::V3(TxInfoV3 { ref redeemers, .. }) => redeemers
|
TxInfo::V3(TxInfoV3 { ref redeemers, .. }) => redeemers
|
||||||
.iter()
|
.iter()
|
||||||
.find_map(move |(purpose, some_redeemer)| {
|
.find_map(move |(purpose, some_redeemer)| {
|
||||||
if redeemer == some_redeemer {
|
if redeemer.tag == some_redeemer.tag && redeemer.index == some_redeemer.index {
|
||||||
Some(purpose.clone())
|
Some(purpose.clone())
|
||||||
} else {
|
} else {
|
||||||
None
|
None
|
||||||
|
@ -702,24 +703,24 @@ pub fn get_data_info(witness_set: &MintedWitnessSet) -> Vec<(DatumHash, PlutusDa
|
||||||
|
|
||||||
pub fn get_redeemers_info<'a>(
|
pub fn get_redeemers_info<'a>(
|
||||||
witness_set: &'a MintedWitnessSet,
|
witness_set: &'a MintedWitnessSet,
|
||||||
to_script_purpose: impl Fn(&'a RedeemersKey) -> Result<ScriptPurpose, Error>,
|
to_script_purpose: impl Fn(RedeemersKey) -> Result<ScriptPurpose, Error> + 'a,
|
||||||
) -> Result<KeyValuePairs<ScriptPurpose, Redeemer>, Error> {
|
) -> Result<KeyValuePairs<ScriptPurpose, Redeemer>, Error> {
|
||||||
Ok(KeyValuePairs::from(
|
Ok(KeyValuePairs::from(
|
||||||
witness_set
|
witness_set
|
||||||
.redeemer
|
.redeemer
|
||||||
.as_deref()
|
.as_deref()
|
||||||
.map(|m| {
|
.map(|m| {
|
||||||
m.iter()
|
iter_redeemers(m)
|
||||||
.sorted_by(|a, b| sort_redeemers(&a.0, &b.0))
|
.sorted_by(|(a, _, _), (b, _, _)| sort_redeemers(a, b))
|
||||||
.map(|(redeemer_key, redeemer_value)| {
|
.map(|(key, data, ex_units)| {
|
||||||
let redeemer = Redeemer {
|
let redeemer = Redeemer {
|
||||||
tag: redeemer_key.tag,
|
tag: key.tag,
|
||||||
index: redeemer_key.index,
|
index: key.index,
|
||||||
data: redeemer_value.data.clone(),
|
data: data.clone(),
|
||||||
ex_units: redeemer_value.ex_units,
|
ex_units,
|
||||||
};
|
};
|
||||||
|
|
||||||
to_script_purpose(redeemer_key).map(|purpose| (purpose, redeemer))
|
to_script_purpose(key).map(|purpose| (purpose, redeemer))
|
||||||
})
|
})
|
||||||
.collect::<Result<Vec<_>, _>>()
|
.collect::<Result<Vec<_>, _>>()
|
||||||
})
|
})
|
||||||
|
@ -766,8 +767,8 @@ fn script_purpose_builder<'a>(
|
||||||
withdrawals: &'a KeyValuePairs<Address, Coin>,
|
withdrawals: &'a KeyValuePairs<Address, Coin>,
|
||||||
proposal_procedures: &'a [ProposalProcedure],
|
proposal_procedures: &'a [ProposalProcedure],
|
||||||
votes: &'a [&'a Voter],
|
votes: &'a [&'a Voter],
|
||||||
) -> impl Fn(&'a RedeemersKey) -> Result<ScriptPurpose, Error> {
|
) -> impl Fn(RedeemersKey) -> Result<ScriptPurpose, Error> + 'a {
|
||||||
move |redeemer: &'a RedeemersKey| {
|
move |redeemer: RedeemersKey| {
|
||||||
let tag = redeemer.tag;
|
let tag = redeemer.tag;
|
||||||
let index = redeemer.index as usize;
|
let index = redeemer.index as usize;
|
||||||
|
|
||||||
|
@ -793,7 +794,7 @@ fn script_purpose_builder<'a>(
|
||||||
.map(|(address, _)| match address {
|
.map(|(address, _)| match address {
|
||||||
Address::Stake(stake_address) => match stake_address.payload() {
|
Address::Stake(stake_address) => match stake_address.payload() {
|
||||||
StakePayload::Script(script_hash) => Ok(ScriptPurpose::Rewarding(
|
StakePayload::Script(script_hash) => Ok(ScriptPurpose::Rewarding(
|
||||||
StakeCredential::Scripthash(*script_hash),
|
StakeCredential::ScriptHash(*script_hash),
|
||||||
)),
|
)),
|
||||||
StakePayload::Stake(_) => Err(Error::NonScriptWithdrawal),
|
StakePayload::Stake(_) => Err(Error::NonScriptWithdrawal),
|
||||||
},
|
},
|
||||||
|
@ -885,7 +886,7 @@ pub fn find_script(
|
||||||
| Certificate::AuthCommitteeHot(stake_credential, _)
|
| Certificate::AuthCommitteeHot(stake_credential, _)
|
||||||
| Certificate::ResignCommitteeCold(stake_credential, _)
|
| Certificate::ResignCommitteeCold(stake_credential, _)
|
||||||
| Certificate::StakeDelegation(stake_credential, _) => match stake_credential {
|
| Certificate::StakeDelegation(stake_credential, _) => match stake_credential {
|
||||||
StakeCredential::Scripthash(hash) => Ok(hash),
|
StakeCredential::ScriptHash(hash) => Ok(hash),
|
||||||
_ => Err(Error::NonScriptStakeCredential),
|
_ => Err(Error::NonScriptStakeCredential),
|
||||||
},
|
},
|
||||||
Certificate::StakeRegistration { .. }
|
Certificate::StakeRegistration { .. }
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
|
@ -2,7 +2,7 @@ use super::{eval_phase_two, ResolvedInput, SlotConfig};
|
||||||
use crate::machine::cost_model::ExBudget;
|
use crate::machine::cost_model::ExBudget;
|
||||||
use pallas_codec::utils::MaybeIndefArray;
|
use pallas_codec::utils::MaybeIndefArray;
|
||||||
use pallas_primitives::{
|
use pallas_primitives::{
|
||||||
conway::{CostMdls, TransactionInput, TransactionOutput},
|
conway::{CostModels, TransactionInput, TransactionOutput},
|
||||||
Fragment,
|
Fragment,
|
||||||
};
|
};
|
||||||
use pallas_traverse::{Era, MultiEraTx};
|
use pallas_traverse::{Era, MultiEraTx};
|
||||||
|
@ -222,7 +222,7 @@ fn test_eval_0() {
|
||||||
20000000000,
|
20000000000,
|
||||||
];
|
];
|
||||||
|
|
||||||
let cost_mdl = CostMdls {
|
let cost_mdl = CostModels {
|
||||||
plutus_v1: None,
|
plutus_v1: None,
|
||||||
plutus_v2: Some(costs),
|
plutus_v2: Some(costs),
|
||||||
plutus_v3: None,
|
plutus_v3: None,
|
||||||
|
@ -494,7 +494,7 @@ fn test_eval_1() {
|
||||||
20000000000,
|
20000000000,
|
||||||
];
|
];
|
||||||
|
|
||||||
let cost_mdl = CostMdls {
|
let cost_mdl = CostModels {
|
||||||
plutus_v1: None,
|
plutus_v1: None,
|
||||||
plutus_v2: Some(costs),
|
plutus_v2: Some(costs),
|
||||||
plutus_v3: None,
|
plutus_v3: None,
|
||||||
|
@ -606,7 +606,7 @@ fn test_eval_2() {
|
||||||
31220, 32, 32696, 32, 43357, 32, 32247, 32, 38314, 32, 9462713, 1021, 10,
|
31220, 32, 32696, 32, 43357, 32, 32247, 32, 38314, 32, 9462713, 1021, 10,
|
||||||
];
|
];
|
||||||
|
|
||||||
let cost_mdl = CostMdls {
|
let cost_mdl = CostModels {
|
||||||
plutus_v1: Some(costs),
|
plutus_v1: Some(costs),
|
||||||
plutus_v2: None,
|
plutus_v2: None,
|
||||||
plutus_v3: None,
|
plutus_v3: None,
|
||||||
|
@ -876,7 +876,7 @@ fn test_eval_3() {
|
||||||
20000000000,
|
20000000000,
|
||||||
];
|
];
|
||||||
|
|
||||||
let cost_mdl = CostMdls {
|
let cost_mdl = CostModels {
|
||||||
plutus_v1: None,
|
plutus_v1: None,
|
||||||
plutus_v2: Some(costs),
|
plutus_v2: Some(costs),
|
||||||
plutus_v3: None,
|
plutus_v3: None,
|
||||||
|
@ -984,7 +984,7 @@ fn test_eval_4() {
|
||||||
31220, 32, 32696, 32, 43357, 32, 32247, 32, 38314, 32, 9462713, 1021, 10,
|
31220, 32, 32696, 32, 43357, 32, 32247, 32, 38314, 32, 9462713, 1021, 10,
|
||||||
];
|
];
|
||||||
|
|
||||||
let cost_mdl = CostMdls {
|
let cost_mdl = CostModels {
|
||||||
plutus_v1: Some(costs),
|
plutus_v1: Some(costs),
|
||||||
plutus_v2: None,
|
plutus_v2: None,
|
||||||
plutus_v3: None,
|
plutus_v3: None,
|
||||||
|
@ -1069,7 +1069,7 @@ fn test_eval_5() {
|
||||||
31220, 32, 32696, 32, 43357, 32, 32247, 32, 38314, 32, 9462713, 1021, 10,
|
31220, 32, 32696, 32, 43357, 32, 32247, 32, 38314, 32, 9462713, 1021, 10,
|
||||||
];
|
];
|
||||||
|
|
||||||
let cost_mdl = CostMdls {
|
let cost_mdl = CostModels {
|
||||||
plutus_v1: Some(costs),
|
plutus_v1: Some(costs),
|
||||||
plutus_v2: None,
|
plutus_v2: None,
|
||||||
plutus_v3: None,
|
plutus_v3: None,
|
||||||
|
@ -1179,7 +1179,7 @@ fn test_eval_6() {
|
||||||
3345831, 1, 1,
|
3345831, 1, 1,
|
||||||
];
|
];
|
||||||
|
|
||||||
let cost_mdl = CostMdls {
|
let cost_mdl = CostModels {
|
||||||
plutus_v1: Some(costs),
|
plutus_v1: Some(costs),
|
||||||
plutus_v2: None,
|
plutus_v2: None,
|
||||||
plutus_v3: None,
|
plutus_v3: None,
|
||||||
|
@ -1289,7 +1289,7 @@ fn test_eval_7() {
|
||||||
3345831, 1, 1,
|
3345831, 1, 1,
|
||||||
];
|
];
|
||||||
|
|
||||||
let cost_mdl = CostMdls {
|
let cost_mdl = CostModels {
|
||||||
plutus_v1: Some(costs),
|
plutus_v1: Some(costs),
|
||||||
plutus_v2: None,
|
plutus_v2: None,
|
||||||
plutus_v3: None,
|
plutus_v3: None,
|
||||||
|
@ -1550,7 +1550,7 @@ fn test_eval_8() {
|
||||||
20000000000,
|
20000000000,
|
||||||
];
|
];
|
||||||
|
|
||||||
let cost_mdl = CostMdls {
|
let cost_mdl = CostModels {
|
||||||
plutus_v1: None,
|
plutus_v1: None,
|
||||||
plutus_v2: Some(costs),
|
plutus_v2: Some(costs),
|
||||||
plutus_v3: None,
|
plutus_v3: None,
|
||||||
|
@ -1656,7 +1656,7 @@ fn eval_missing_redeemer() {
|
||||||
31220, 32, 32696, 32, 43357, 32, 32247, 32, 38314, 32, 9462713, 1021, 10,
|
31220, 32, 32696, 32, 43357, 32, 32247, 32, 38314, 32, 9462713, 1021, 10,
|
||||||
];
|
];
|
||||||
|
|
||||||
let cost_mdl = CostMdls {
|
let cost_mdl = CostModels {
|
||||||
plutus_v1: Some(costs),
|
plutus_v1: Some(costs),
|
||||||
plutus_v2: None,
|
plutus_v2: None,
|
||||||
plutus_v3: None,
|
plutus_v3: None,
|
||||||
|
@ -1739,7 +1739,7 @@ fn eval_extraneous_redeemer() {
|
||||||
31220, 32, 32696, 32, 43357, 32, 32247, 32, 38314, 32, 9462713, 1021, 10,
|
31220, 32, 32696, 32, 43357, 32, 32247, 32, 38314, 32, 9462713, 1021, 10,
|
||||||
];
|
];
|
||||||
|
|
||||||
let cost_mdl = CostMdls {
|
let cost_mdl = CostModels {
|
||||||
plutus_v1: Some(costs),
|
plutus_v1: Some(costs),
|
||||||
plutus_v2: None,
|
plutus_v2: None,
|
||||||
plutus_v3: None,
|
plutus_v3: None,
|
||||||
|
|
|
@ -11,7 +11,8 @@ use pallas_addresses::{
|
||||||
Address, ShelleyDelegationPart, ShelleyPaymentPart, StakeAddress, StakePayload,
|
Address, ShelleyDelegationPart, ShelleyPaymentPart, StakeAddress, StakePayload,
|
||||||
};
|
};
|
||||||
use pallas_codec::utils::{
|
use pallas_codec::utils::{
|
||||||
AnyUInt, Bytes, Int, KeyValuePairs, NonEmptyKeyValuePairs, Nullable, PositiveCoin,
|
AnyUInt, Bytes, Int, KeyValuePairs, MaybeIndefArray, NonEmptyKeyValuePairs, Nullable,
|
||||||
|
PositiveCoin,
|
||||||
};
|
};
|
||||||
use pallas_crypto::hash::Hash;
|
use pallas_crypto::hash::Hash;
|
||||||
use pallas_primitives::conway::{
|
use pallas_primitives::conway::{
|
||||||
|
@ -28,7 +29,11 @@ fn wrap_multiple_with_constr(index: u64, data: Vec<PlutusData>) -> PlutusData {
|
||||||
PlutusData::Constr(Constr {
|
PlutusData::Constr(Constr {
|
||||||
tag: converted.unwrap_or(ANY_TAG),
|
tag: converted.unwrap_or(ANY_TAG),
|
||||||
any_constructor: converted.map_or(Some(index), |_| None),
|
any_constructor: converted.map_or(Some(index), |_| None),
|
||||||
fields: data,
|
fields: if data.is_empty() {
|
||||||
|
MaybeIndefArray::Def(data)
|
||||||
|
} else {
|
||||||
|
MaybeIndefArray::Indef(data)
|
||||||
|
},
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -104,7 +109,7 @@ impl ToPlutusData for Address {
|
||||||
.to_plutus_data(),
|
.to_plutus_data(),
|
||||||
ShelleyDelegationPart::Script(script_hash) => Some(wrap_with_constr(
|
ShelleyDelegationPart::Script(script_hash) => Some(wrap_with_constr(
|
||||||
0,
|
0,
|
||||||
StakeCredential::Scripthash(*script_hash).to_plutus_data(),
|
StakeCredential::ScriptHash(*script_hash).to_plutus_data(),
|
||||||
))
|
))
|
||||||
.to_plutus_data(),
|
.to_plutus_data(),
|
||||||
ShelleyDelegationPart::Pointer(pointer) => Some(wrap_multiple_with_constr(
|
ShelleyDelegationPart::Pointer(pointer) => Some(wrap_multiple_with_constr(
|
||||||
|
@ -174,7 +179,7 @@ where
|
||||||
A: ToPlutusData,
|
A: ToPlutusData,
|
||||||
{
|
{
|
||||||
fn to_plutus_data(&self) -> PlutusData {
|
fn to_plutus_data(&self) -> PlutusData {
|
||||||
PlutusData::Array(self.iter().map(|p| p.to_plutus_data()).collect())
|
Data::list(self.iter().map(|p| p.to_plutus_data()).collect())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -414,7 +419,7 @@ impl ToPlutusData for ScriptRef {
|
||||||
|
|
||||||
impl<'a> ToPlutusData for WithOptionDatum<'a, WithZeroAdaAsset<'a, Vec<TransactionOutput>>> {
|
impl<'a> ToPlutusData for WithOptionDatum<'a, WithZeroAdaAsset<'a, Vec<TransactionOutput>>> {
|
||||||
fn to_plutus_data(&self) -> PlutusData {
|
fn to_plutus_data(&self) -> PlutusData {
|
||||||
PlutusData::Array(
|
Data::list(
|
||||||
self.0
|
self.0
|
||||||
.0
|
.0
|
||||||
.iter()
|
.iter()
|
||||||
|
@ -426,7 +431,7 @@ impl<'a> ToPlutusData for WithOptionDatum<'a, WithZeroAdaAsset<'a, Vec<Transacti
|
||||||
|
|
||||||
impl<'a> ToPlutusData for WithZeroAdaAsset<'a, Vec<TransactionOutput>> {
|
impl<'a> ToPlutusData for WithZeroAdaAsset<'a, Vec<TransactionOutput>> {
|
||||||
fn to_plutus_data(&self) -> PlutusData {
|
fn to_plutus_data(&self) -> PlutusData {
|
||||||
PlutusData::Array(
|
Data::list(
|
||||||
self.0
|
self.0
|
||||||
.iter()
|
.iter()
|
||||||
.map(|p| WithZeroAdaAsset(p).to_plutus_data())
|
.map(|p| WithZeroAdaAsset(p).to_plutus_data())
|
||||||
|
@ -516,7 +521,7 @@ impl ToPlutusData for StakeCredential {
|
||||||
StakeCredential::AddrKeyhash(addr_keyhas) => {
|
StakeCredential::AddrKeyhash(addr_keyhas) => {
|
||||||
wrap_with_constr(0, addr_keyhas.to_plutus_data())
|
wrap_with_constr(0, addr_keyhas.to_plutus_data())
|
||||||
}
|
}
|
||||||
StakeCredential::Scripthash(script_hash) => {
|
StakeCredential::ScriptHash(script_hash) => {
|
||||||
wrap_with_constr(1, script_hash.to_plutus_data())
|
wrap_with_constr(1, script_hash.to_plutus_data())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -741,7 +746,7 @@ impl ToPlutusData for DRep {
|
||||||
wrap_with_constr(0, StakeCredential::AddrKeyhash(*hash).to_plutus_data())
|
wrap_with_constr(0, StakeCredential::AddrKeyhash(*hash).to_plutus_data())
|
||||||
}
|
}
|
||||||
DRep::Script(hash) => {
|
DRep::Script(hash) => {
|
||||||
wrap_with_constr(0, StakeCredential::Scripthash(*hash).to_plutus_data())
|
wrap_with_constr(0, StakeCredential::ScriptHash(*hash).to_plutus_data())
|
||||||
}
|
}
|
||||||
DRep::Abstain => empty_constr(1),
|
DRep::Abstain => empty_constr(1),
|
||||||
DRep::NoConfidence => empty_constr(2),
|
DRep::NoConfidence => empty_constr(2),
|
||||||
|
@ -798,7 +803,7 @@ impl<'a> ToPlutusData
|
||||||
for WithOptionDatum<'a, WithZeroAdaAsset<'a, WithWrappedTransactionId<'a, Vec<TxInInfo>>>>
|
for WithOptionDatum<'a, WithZeroAdaAsset<'a, WithWrappedTransactionId<'a, Vec<TxInInfo>>>>
|
||||||
{
|
{
|
||||||
fn to_plutus_data(&self) -> PlutusData {
|
fn to_plutus_data(&self) -> PlutusData {
|
||||||
PlutusData::Array(
|
Data::list(
|
||||||
self.0
|
self.0
|
||||||
.0
|
.0
|
||||||
.0
|
.0
|
||||||
|
@ -814,7 +819,7 @@ impl<'a> ToPlutusData
|
||||||
|
|
||||||
impl<'a> ToPlutusData for WithZeroAdaAsset<'a, WithWrappedTransactionId<'a, Vec<TxInInfo>>> {
|
impl<'a> ToPlutusData for WithZeroAdaAsset<'a, WithWrappedTransactionId<'a, Vec<TxInInfo>>> {
|
||||||
fn to_plutus_data(&self) -> PlutusData {
|
fn to_plutus_data(&self) -> PlutusData {
|
||||||
PlutusData::Array(
|
Data::list(
|
||||||
self.0
|
self.0
|
||||||
.0
|
.0
|
||||||
.iter()
|
.iter()
|
||||||
|
@ -1254,13 +1259,13 @@ impl ToPlutusData for Voter {
|
||||||
fn to_plutus_data(&self) -> PlutusData {
|
fn to_plutus_data(&self) -> PlutusData {
|
||||||
match self {
|
match self {
|
||||||
Voter::ConstitutionalCommitteeScript(hash) => {
|
Voter::ConstitutionalCommitteeScript(hash) => {
|
||||||
wrap_with_constr(0, StakeCredential::Scripthash(*hash).to_plutus_data())
|
wrap_with_constr(0, StakeCredential::ScriptHash(*hash).to_plutus_data())
|
||||||
}
|
}
|
||||||
Voter::ConstitutionalCommitteeKey(hash) => {
|
Voter::ConstitutionalCommitteeKey(hash) => {
|
||||||
wrap_with_constr(0, StakeCredential::AddrKeyhash(*hash).to_plutus_data())
|
wrap_with_constr(0, StakeCredential::AddrKeyhash(*hash).to_plutus_data())
|
||||||
}
|
}
|
||||||
Voter::DRepScript(hash) => {
|
Voter::DRepScript(hash) => {
|
||||||
wrap_with_constr(1, StakeCredential::Scripthash(*hash).to_plutus_data())
|
wrap_with_constr(1, StakeCredential::ScriptHash(*hash).to_plutus_data())
|
||||||
}
|
}
|
||||||
Voter::DRepKey(hash) => {
|
Voter::DRepKey(hash) => {
|
||||||
wrap_with_constr(1, StakeCredential::AddrKeyhash(*hash).to_plutus_data())
|
wrap_with_constr(1, StakeCredential::AddrKeyhash(*hash).to_plutus_data())
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
use num_bigint::ToBigInt;
|
use num_bigint::ToBigInt;
|
||||||
|
use pallas_codec::utils::MaybeIndefArray;
|
||||||
use uplc::{
|
use uplc::{
|
||||||
ast::{Constant, Name, Term, Type},
|
ast::{Constant, Name, Term, Type},
|
||||||
parser::term,
|
parser::term,
|
||||||
|
@ -111,9 +112,9 @@ fn constant_data_constr() {
|
||||||
Constant::Data(PlutusData::Constr(Constr::<PlutusData> {
|
Constant::Data(PlutusData::Constr(Constr::<PlutusData> {
|
||||||
tag: 122,
|
tag: 122,
|
||||||
any_constructor: None,
|
any_constructor: None,
|
||||||
fields: vec![PlutusData::BigInt(pallas_primitives::alonzo::BigInt::Int(
|
fields: MaybeIndefArray::Indef(vec![PlutusData::BigInt(
|
||||||
2.into(),
|
pallas_primitives::alonzo::BigInt::Int(2.into()),
|
||||||
))],
|
)]),
|
||||||
}))
|
}))
|
||||||
.into(),
|
.into(),
|
||||||
),
|
),
|
||||||
|
@ -145,10 +146,10 @@ fn constant_data_map() {
|
||||||
fn constant_data_list() {
|
fn constant_data_list() {
|
||||||
round_trip(
|
round_trip(
|
||||||
Term::<Name>::Constant(
|
Term::<Name>::Constant(
|
||||||
Constant::Data(PlutusData::Array(vec![
|
Constant::Data(PlutusData::Array(MaybeIndefArray::Indef(vec![
|
||||||
PlutusData::BigInt(pallas_primitives::alonzo::BigInt::Int(0.into())),
|
PlutusData::BigInt(pallas_primitives::alonzo::BigInt::Int(0.into())),
|
||||||
PlutusData::BigInt(pallas_primitives::alonzo::BigInt::Int(1.into())),
|
PlutusData::BigInt(pallas_primitives::alonzo::BigInt::Int(1.into())),
|
||||||
]))
|
])))
|
||||||
.into(),
|
.into(),
|
||||||
),
|
),
|
||||||
"(con data (List [I 0, I 1]))",
|
"(con data (List [I 0, I 1]))",
|
||||||
|
|
Loading…
Reference in New Issue