Update to pallas=0.31.0

This commit is contained in:
KtorZ 2024-11-19 14:53:36 +01:00
parent c740e4639f
commit b5047d623a
No known key found for this signature in database
GPG Key ID: 33173CB6F77F4277
23 changed files with 13033 additions and 11689 deletions

View File

@ -5,6 +5,7 @@
### Changed
- **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

744
Cargo.lock generated vendored

File diff suppressed because it is too large Load Diff

View File

@ -52,11 +52,11 @@ x86_64-unknown-linux-musl = "ubuntu-22.04"
walkdir = "2.3.2"
insta = { version = "1.30.0", features = ["yaml", "json", "redactions"] }
miette = { version = "7.2.0" }
pallas-addresses = "0.30.1"
pallas-codec = { version = "0.30.1", features = ["num-bigint"] }
pallas-crypto = "0.30.1"
pallas-primitives = "0.30.1"
pallas-traverse = "0.30.1"
pallas-addresses = "0.31.0"
pallas-codec = { version = "0.31.0", features = ["num-bigint"] }
pallas-crypto = "0.31.0"
pallas-primitives = "0.31.0"
pallas-traverse = "0.31.0"
[profile.dev.package.insta]
opt-level = 3

View File

@ -1007,6 +1007,7 @@ impl UntypedExpr {
PlutusData::Array(elems) => UntypedExpr::List {
location: Span::empty(),
elements: elems
.to_vec()
.into_iter()
.map(UntypedExpr::reify_blind)
.collect::<Vec<_>>(),
@ -1041,6 +1042,7 @@ impl UntypedExpr {
let ix = convert_tag_to_constr(tag).or(any_constructor).unwrap() as usize;
let fields = fields
.to_vec()
.into_iter()
.map(|field| CallArg {
location: Span::empty(),
@ -1127,6 +1129,7 @@ impl UntypedExpr {
Ok(UntypedExpr::List {
location: Span::empty(),
elements: args
.to_vec()
.into_iter()
.map(|arg| {
UntypedExpr::do_reify_data(generics, data_types, arg, inner)
@ -1144,6 +1147,7 @@ impl UntypedExpr {
Type::Tuple { elems, .. } => Ok(UntypedExpr::Tuple {
location: Span::empty(),
elems: args
.to_vec()
.into_iter()
.zip(elems)
.map(|(arg, arg_type)| {
@ -1153,6 +1157,7 @@ impl UntypedExpr {
}),
Type::Pair { fst, snd, .. } => {
let mut elems = args
.to_vec()
.into_iter()
.zip([fst, snd])
.map(|(arg, arg_type)| {
@ -1213,6 +1218,7 @@ impl UntypedExpr {
} else {
let arguments =
fields
.to_vec()
.into_iter()
.zip(constructor.arguments.iter())
.map(
@ -1264,9 +1270,9 @@ impl UntypedExpr {
UntypedExpr::do_reify_data(
generics,
data_types,
PlutusData::Array(
Data::list(
kvs.into_iter()
.map(|(k, v)| PlutusData::Array(vec![k, v]))
.map(|(k, v)| Data::list(vec![k, v]))
.collect(),
),
tipo,

View File

@ -18,14 +18,11 @@ use indexmap::IndexMap;
use itertools::{Itertools, Position};
use std::{ops::Deref, rc::Rc};
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},
builtins::DefaultFunction,
machine::{
runtime::{convert_constr_to_tag, Compressable, ANY_TAG},
value::to_pallas_bigint,
},
Constr, KeyValuePairs, PlutusData,
machine::{runtime::Compressable, value::to_pallas_bigint},
KeyValuePairs, PlutusData,
};
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::Bool(b) => UplcConstant::Data(PlutusData::Constr(Constr {
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::Bool(b) => UplcConstant::Data(Data::constr((*b).into(), vec![])),
UplcConstant::ProtoList(list_type, constants) => {
if matches!(list_type, UplcType::Pair(_, _)) {
let inner_constants = constants
@ -675,7 +667,7 @@ pub fn convert_constants_to_data(constants: Vec<Rc<UplcConstant>>) -> Vec<UplcCo
})
.collect_vec();
UplcConstant::Data(PlutusData::Array(inner_constants))
UplcConstant::Data(Data::list(inner_constants))
}
}
UplcConstant::ProtoPair(_, _, left, right) => {
@ -688,17 +680,13 @@ pub fn convert_constants_to_data(constants: Vec<Rc<UplcConstant>>) -> Vec<UplcCo
})
.collect_vec();
UplcConstant::Data(PlutusData::Array(vec![
UplcConstant::Data(Data::list(vec![
inner_constants[0].clone(),
inner_constants[1].clone(),
]))
}
d @ UplcConstant::Data(_) => d.clone(),
UplcConstant::Unit => UplcConstant::Data(PlutusData::Constr(Constr {
tag: convert_constr_to_tag(0).unwrap(),
any_constructor: None,
fields: vec![],
})),
UplcConstant::Unit => UplcConstant::Data(Data::constr(0, vec![])),
UplcConstant::Bls12_381G1Element(b) => UplcConstant::Data(PlutusData::BoundedBytes(
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")
.apply(term),
Some(UplcType::Unit) => Term::Constant(
UplcConstant::Data(PlutusData::Constr(Constr {
tag: convert_constr_to_tag(0).unwrap(),
any_constructor: None,
fields: vec![],
}))
.into(),
)
Some(UplcType::Unit) => Term::Constant(UplcConstant::Data(Data::constr(0, vec![])).into())
.lambda("_")
.apply(term),
Some(UplcType::Bool) => term.if_then_else(
Term::Constant(
UplcConstant::Data(PlutusData::Constr(Constr {
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(),
),
Term::Constant(UplcConstant::Data(Data::constr(1, vec![])).into()),
Term::Constant(UplcConstant::Data(Data::constr(0, vec![])).into()),
),
Some(UplcType::Data) | None => term,

View File

@ -559,16 +559,15 @@ impl Prng {
{
return Prng::Seeded {
choices: choices.to_vec(),
uplc: PlutusData::Constr(Constr {
tag: 121 + Prng::SEEDED,
fields: vec![
uplc: Data::constr(
Prng::SEEDED,
vec![
PlutusData::BoundedBytes(bytes.to_owned()),
// Clear choices between seeded runs, to not
// accumulate ALL choices ever made.
PlutusData::BoundedBytes(vec![].into()),
],
any_constructor: None,
}),
),
};
}
}

View File

@ -149,21 +149,21 @@ impl SerializableProgram {
PlutusV1Program(pgrm) => {
let cbor = pgrm.to_cbor().unwrap();
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)
}
PlutusV2Program(pgrm) => {
let cbor = pgrm.to_cbor().unwrap();
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)
}
PlutusV3Program(pgrm) => {
let cbor = pgrm.to_cbor().unwrap();
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)
}
}
@ -239,15 +239,15 @@ impl<'a> Deserialize<'a> for SerializableProgram {
.and_then(|program| {
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));
}
if conway::PlutusV2Script(cbor()).compute_hash().to_string() == hash {
if conway::PlutusScript::<2>(cbor()).compute_hash().to_string() == hash {
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));
}
@ -273,9 +273,9 @@ impl Program<DeBruijn> {
let cbor = self.to_cbor().unwrap();
let validator_hash = match plutus_version {
Language::PlutusV1 => conway::PlutusV1Script(cbor.into()).compute_hash(),
Language::PlutusV2 => conway::PlutusV2Script(cbor.into()).compute_hash(),
Language::PlutusV3 => conway::PlutusV3Script(cbor.into()).compute_hash(),
Language::PlutusV1 => conway::PlutusScript::<1>(cbor.into()).compute_hash(),
Language::PlutusV2 => conway::PlutusScript::<2>(cbor.into()).compute_hash(),
Language::PlutusV3 => conway::PlutusScript::<3>(cbor.into()).compute_hash(),
};
ShelleyAddress::new(
@ -420,10 +420,20 @@ impl Data {
}
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 {
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
if ix < 7 {
PlutusData::Constr(Constr {

View File

@ -881,7 +881,7 @@ impl DefaultFunction {
})
.collect();
let value = Value::data(PlutusData::Array(data_list));
let value = Value::data(Data::list(data_list));
Ok(value)
}

View File

@ -1,5 +1,5 @@
use crate::{
ast::{Constant, Name, Program, Term, Type},
ast::{Constant, Data, Name, Program, Term, Type},
builtins::DefaultFunction,
machine::{runtime::Compressable, value::to_pallas_bigint},
};
@ -239,7 +239,7 @@ peg::parser! {
rule data() -> PlutusData
= _* "Constr" _+ t:decimal() _+ fs:plutus_list() {?
Ok(crate::ast::Data::constr(
Ok(Data::constr(
u64::try_from(t).or(Err("tag"))?,
fs,
))
@ -247,7 +247,7 @@ peg::parser! {
/ _* "Map" _+ kvps:plutus_key_value_pairs() {
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)) }
/ _* "B" _+ "#" i:ident()* {?
Ok(PlutusData::BoundedBytes(

View File

@ -5,7 +5,10 @@ use crate::{
};
use error::Error;
use pallas_primitives::{
conway::{CostMdls, MintedTx, Redeemer, TransactionInput, TransactionOutput},
conway::{
CostModels, ExUnits, MintedTx, Redeemer, Redeemers, RedeemersKey, TransactionInput,
TransactionOutput,
},
Fragment,
};
use pallas_traverse::{Era, MultiEraTx};
@ -28,7 +31,7 @@ pub mod to_plutus_data;
pub fn eval_phase_two(
tx: &MintedTx,
utxos: &[ResolvedInput],
cost_mdls: Option<&CostMdls>,
cost_mdls: Option<&CostModels>,
initial_budget: Option<&ExBudget>,
slot_config: &SlotConfig,
run_phase_one: bool,
@ -49,12 +52,12 @@ pub fn eval_phase_two(
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 {
tag: redeemer_key.tag,
index: redeemer_key.index,
data: redeemer_value.data.clone(),
ex_units: redeemer_value.ex_units,
tag: key.tag,
index: key.index,
data: data.clone(),
ex_units,
};
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::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 {
cpu: initial_budget.0 as i64,
@ -161,7 +166,7 @@ pub fn apply_params_to_script(
let mut buffer = Vec::new();
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);
}
@ -170,3 +175,31 @@ pub fn apply_params_to_script(
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)>>,
}
}

View File

@ -13,7 +13,7 @@ use crate::{
PlutusData,
};
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(
tx: &MintedTx,
@ -21,7 +21,7 @@ pub fn eval_redeemer(
slot_config: &SlotConfig,
redeemer: &Redeemer,
lookup_table: &DataLookupTable,
cost_mdls_opt: Option<&CostMdls>,
cost_mdls_opt: Option<&CostModels>,
initial_budget: &ExBudget,
) -> Result<Redeemer, Error> {
fn do_eval_redeemer(

View File

@ -7,8 +7,8 @@ use itertools::Itertools;
use pallas_addresses::{Address, ScriptHash, ShelleyPaymentPart, StakePayload};
use pallas_codec::utils::Nullable;
use pallas_primitives::conway::{
Certificate, GovAction, MintedTx, PolicyId, RedeemerTag, RedeemersKey, RewardAccount,
StakeCredential, TransactionOutput, Voter,
Certificate, GovAction, MintedTx, PolicyId, RedeemerTag, Redeemers, RedeemersKey,
RewardAccount, StakeCredential, TransactionOutput, Voter,
};
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 StakePayload::Script(h) = a.payload() {
let cred = StakeCredential::Scripthash(*h);
let cred = StakeCredential::ScriptHash(*h);
return Some((ScriptPurpose::Rewarding(cred), *h));
}
}
@ -110,19 +110,19 @@ pub fn scripts_needed(tx: &MintedTx, utxos: &[ResolvedInput]) -> Result<ScriptsN
m.iter()
.enumerate()
.filter_map(|(ix, cert)| match cert {
Certificate::StakeDeregistration(StakeCredential::Scripthash(h))
| Certificate::UnReg(StakeCredential::Scripthash(h), _)
| Certificate::VoteDeleg(StakeCredential::Scripthash(h), _)
| Certificate::VoteRegDeleg(StakeCredential::Scripthash(h), _, _)
| Certificate::StakeVoteDeleg(StakeCredential::Scripthash(h), _, _)
| Certificate::StakeRegDeleg(StakeCredential::Scripthash(h), _, _)
| Certificate::StakeVoteRegDeleg(StakeCredential::Scripthash(h), _, _, _)
| Certificate::RegDRepCert(StakeCredential::Scripthash(h), _, _)
| Certificate::UnRegDRepCert(StakeCredential::Scripthash(h), _)
| Certificate::UpdateDRepCert(StakeCredential::Scripthash(h), _)
| Certificate::AuthCommitteeHot(StakeCredential::Scripthash(h), _)
| Certificate::ResignCommitteeCold(StakeCredential::Scripthash(h), _)
| Certificate::StakeDelegation(StakeCredential::Scripthash(h), _) => {
Certificate::StakeDeregistration(StakeCredential::ScriptHash(h))
| Certificate::UnReg(StakeCredential::ScriptHash(h), _)
| Certificate::VoteDeleg(StakeCredential::ScriptHash(h), _)
| Certificate::VoteRegDeleg(StakeCredential::ScriptHash(h), _, _)
| Certificate::StakeVoteDeleg(StakeCredential::ScriptHash(h), _, _)
| Certificate::StakeRegDeleg(StakeCredential::ScriptHash(h), _, _)
| Certificate::StakeVoteRegDeleg(StakeCredential::ScriptHash(h), _, _, _)
| Certificate::RegDRepCert(StakeCredential::ScriptHash(h), _, _)
| Certificate::UnRegDRepCert(StakeCredential::ScriptHash(h), _)
| Certificate::UpdateDRepCert(StakeCredential::ScriptHash(h), _)
| Certificate::AuthCommitteeHot(StakeCredential::ScriptHash(h), _)
| Certificate::ResignCommitteeCold(StakeCredential::ScriptHash(h), _)
| Certificate::StakeDelegation(StakeCredential::ScriptHash(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
.redeemer
.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();
let needed_redeemer_keys: Vec<RedeemersKey> =
@ -234,7 +249,7 @@ pub fn has_exact_set_of_redeemers(
let missing: Vec<_> = redeemers_needed
.into_iter()
.filter(|x| !wits_redeemer_keys.contains(&&x.0))
.filter(|x| !wits_redeemer_keys.contains(&x.0))
.map(|x| {
format!(
"{}[{:?}] -> {}",
@ -321,7 +336,7 @@ fn build_redeemer_key(
for (idx, x) in reward_accounts.iter().enumerate() {
let cred = match Address::from_bytes(x).unwrap() {
Address::Stake(a) => match a.payload() {
StakePayload::Script(sh) => Some(StakeCredential::Scripthash(*sh)),
StakePayload::Script(sh) => Some(StakeCredential::ScriptHash(*sh)),
StakePayload::Stake(_) => None,
},
_ => return Err(Error::BadWithdrawalAddress),

View File

@ -1,4 +1,5 @@
use super::{to_plutus_data::MintValue, Error};
use crate::tx::iter_redeemers;
use itertools::Itertools;
use pallas_addresses::{Address, Network, StakePayload};
use pallas_codec::utils::{
@ -10,10 +11,10 @@ use pallas_primitives::{
conway::{
AddrKeyhash, Certificate, Coin, DatumHash, DatumOption, GovAction, GovActionId, Mint,
MintedTransactionBody, MintedTransactionOutput, MintedTx, MintedWitnessSet, NativeScript,
PlutusData, PlutusV1Script, PlutusV2Script, PlutusV3Script, PolicyId,
PostAlonzoTransactionOutput, ProposalProcedure, PseudoDatumOption, PseudoScript, Redeemer,
RedeemerTag, RedeemersKey, RequiredSigners, RewardAccount, ScriptHash, StakeCredential,
TransactionInput, TransactionOutput, Value, Voter, VotingProcedure,
PlutusData, PlutusScript, PolicyId, PostAlonzoTransactionOutput, ProposalProcedure,
PseudoDatumOption, PseudoScript, Redeemer, RedeemerTag, RedeemersKey, RequiredSigners,
RewardAccount, ScriptHash, StakeCredential, TransactionInput, TransactionOutput, Value,
Voter, VotingProcedure,
},
};
use pallas_traverse::{ComputeHash, OriginalHash};
@ -77,9 +78,9 @@ impl ScriptPurpose {
#[derive(Debug, PartialEq, Clone)]
pub enum ScriptVersion {
Native(NativeScript),
V1(PlutusV1Script),
V2(PlutusV2Script),
V3(PlutusV3Script),
V1(PlutusScript<1>),
V2(PlutusScript<2>),
V3(PlutusScript<3>),
}
pub struct DataLookupTable {
@ -400,7 +401,7 @@ impl TxInfo {
| TxInfo::V2(TxInfoV2 { ref redeemers, .. }) => redeemers
.iter()
.find_map(move |(purpose, some_redeemer)| {
if redeemer == some_redeemer {
if redeemer.tag == some_redeemer.tag && redeemer.index == some_redeemer.index {
Some(purpose.clone())
} else {
None
@ -414,7 +415,7 @@ impl TxInfo {
TxInfo::V3(TxInfoV3 { ref redeemers, .. }) => redeemers
.iter()
.find_map(move |(purpose, some_redeemer)| {
if redeemer == some_redeemer {
if redeemer.tag == some_redeemer.tag && redeemer.index == some_redeemer.index {
Some(purpose.clone())
} else {
None
@ -702,24 +703,24 @@ pub fn get_data_info(witness_set: &MintedWitnessSet) -> Vec<(DatumHash, PlutusDa
pub fn get_redeemers_info<'a>(
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> {
Ok(KeyValuePairs::from(
witness_set
.redeemer
.as_deref()
.map(|m| {
m.iter()
.sorted_by(|a, b| sort_redeemers(&a.0, &b.0))
.map(|(redeemer_key, redeemer_value)| {
iter_redeemers(m)
.sorted_by(|(a, _, _), (b, _, _)| sort_redeemers(a, b))
.map(|(key, data, ex_units)| {
let redeemer = Redeemer {
tag: redeemer_key.tag,
index: redeemer_key.index,
data: redeemer_value.data.clone(),
ex_units: redeemer_value.ex_units,
tag: key.tag,
index: key.index,
data: data.clone(),
ex_units,
};
to_script_purpose(redeemer_key).map(|purpose| (purpose, redeemer))
to_script_purpose(key).map(|purpose| (purpose, redeemer))
})
.collect::<Result<Vec<_>, _>>()
})
@ -766,8 +767,8 @@ fn script_purpose_builder<'a>(
withdrawals: &'a KeyValuePairs<Address, Coin>,
proposal_procedures: &'a [ProposalProcedure],
votes: &'a [&'a Voter],
) -> impl Fn(&'a RedeemersKey) -> Result<ScriptPurpose, Error> {
move |redeemer: &'a RedeemersKey| {
) -> impl Fn(RedeemersKey) -> Result<ScriptPurpose, Error> + 'a {
move |redeemer: RedeemersKey| {
let tag = redeemer.tag;
let index = redeemer.index as usize;
@ -793,7 +794,7 @@ fn script_purpose_builder<'a>(
.map(|(address, _)| match address {
Address::Stake(stake_address) => match stake_address.payload() {
StakePayload::Script(script_hash) => Ok(ScriptPurpose::Rewarding(
StakeCredential::Scripthash(*script_hash),
StakeCredential::ScriptHash(*script_hash),
)),
StakePayload::Stake(_) => Err(Error::NonScriptWithdrawal),
},
@ -885,7 +886,7 @@ pub fn find_script(
| Certificate::AuthCommitteeHot(stake_credential, _)
| Certificate::ResignCommitteeCold(stake_credential, _)
| Certificate::StakeDelegation(stake_credential, _) => match stake_credential {
StakeCredential::Scripthash(hash) => Ok(hash),
StakeCredential::ScriptHash(hash) => Ok(hash),
_ => Err(Error::NonScriptStakeCredential),
},
Certificate::StakeRegistration { .. }

View File

@ -6,24 +6,29 @@ Constr(
Constr {
tag: 121,
any_constructor: None,
fields: [
Constr(
Constr {
tag: 121,
any_constructor: None,
fields: [
Array(
fields: Indef(
[
Constr(
Constr {
tag: 121,
any_constructor: None,
fields: [
fields: Indef(
[
Array(
Indef(
[
Constr(
Constr {
tag: 121,
any_constructor: None,
fields: [
fields: Indef(
[
Constr(
Constr {
tag: 121,
any_constructor: None,
fields: Indef(
[
BoundedBytes(
BoundedBytes(
[
@ -73,23 +78,27 @@ Constr(
),
),
],
),
},
),
Constr(
Constr {
tag: 121,
any_constructor: None,
fields: [
fields: Indef(
[
Constr(
Constr {
tag: 121,
any_constructor: None,
fields: [
fields: Indef(
[
Constr(
Constr {
tag: 121,
any_constructor: None,
fields: [
fields: Indef(
[
BoundedBytes(
BoundedBytes(
[
@ -125,16 +134,20 @@ Constr(
),
),
],
),
},
),
Constr(
Constr {
tag: 122,
any_constructor: None,
fields: [],
fields: Def(
[],
),
},
),
],
),
},
),
Map(
@ -177,36 +190,46 @@ Constr(
Constr {
tag: 121,
any_constructor: None,
fields: [],
fields: Def(
[],
),
},
),
Constr(
Constr {
tag: 122,
any_constructor: None,
fields: [],
fields: Def(
[],
),
},
),
],
),
},
),
],
),
},
),
],
),
),
Array(
Indef(
[
Constr(
Constr {
tag: 121,
any_constructor: None,
fields: [
fields: Indef(
[
Constr(
Constr {
tag: 121,
any_constructor: None,
fields: [
fields: Indef(
[
BoundedBytes(
BoundedBytes(
[
@ -256,23 +279,27 @@ Constr(
),
),
],
),
},
),
Constr(
Constr {
tag: 121,
any_constructor: None,
fields: [
fields: Indef(
[
Constr(
Constr {
tag: 121,
any_constructor: None,
fields: [
fields: Indef(
[
Constr(
Constr {
tag: 121,
any_constructor: None,
fields: [
fields: Indef(
[
BoundedBytes(
BoundedBytes(
[
@ -308,16 +335,20 @@ Constr(
),
),
],
),
},
),
Constr(
Constr {
tag: 122,
any_constructor: None,
fields: [],
fields: Def(
[],
),
},
),
],
),
},
),
Map(
@ -360,41 +391,52 @@ Constr(
Constr {
tag: 121,
any_constructor: None,
fields: [],
fields: Def(
[],
),
},
),
Constr(
Constr {
tag: 122,
any_constructor: None,
fields: [],
fields: Def(
[],
),
},
),
],
),
},
),
],
),
},
),
],
),
),
Array(
Indef(
[
Constr(
Constr {
tag: 121,
any_constructor: None,
fields: [
fields: Indef(
[
Constr(
Constr {
tag: 121,
any_constructor: None,
fields: [
fields: Indef(
[
Constr(
Constr {
tag: 121,
any_constructor: None,
fields: [
fields: Indef(
[
BoundedBytes(
BoundedBytes(
[
@ -430,16 +472,20 @@ Constr(
),
),
],
),
},
),
Constr(
Constr {
tag: 122,
any_constructor: None,
fields: [],
fields: Def(
[],
),
},
),
],
),
},
),
Map(
@ -482,7 +528,8 @@ Constr(
Constr {
tag: 122,
any_constructor: None,
fields: [
fields: Indef(
[
BoundedBytes(
BoundedBytes(
[
@ -522,33 +569,40 @@ Constr(
),
),
],
),
},
),
Constr(
Constr {
tag: 122,
any_constructor: None,
fields: [],
fields: Def(
[],
),
},
),
],
),
},
),
Constr(
Constr {
tag: 121,
any_constructor: None,
fields: [
fields: Indef(
[
Constr(
Constr {
tag: 121,
any_constructor: None,
fields: [
fields: Indef(
[
Constr(
Constr {
tag: 121,
any_constructor: None,
fields: [
fields: Indef(
[
BoundedBytes(
BoundedBytes(
[
@ -584,23 +638,27 @@ Constr(
),
),
],
),
},
),
Constr(
Constr {
tag: 121,
any_constructor: None,
fields: [
fields: Indef(
[
Constr(
Constr {
tag: 121,
any_constructor: None,
fields: [
fields: Indef(
[
Constr(
Constr {
tag: 121,
any_constructor: None,
fields: [
fields: Indef(
[
BoundedBytes(
BoundedBytes(
[
@ -636,15 +694,19 @@ Constr(
),
),
],
),
},
),
],
),
},
),
],
),
},
),
],
),
},
),
Map(
@ -816,34 +878,42 @@ Constr(
Constr {
tag: 121,
any_constructor: None,
fields: [],
fields: Def(
[],
),
},
),
Constr(
Constr {
tag: 122,
any_constructor: None,
fields: [],
fields: Def(
[],
),
},
),
],
),
},
),
Constr(
Constr {
tag: 121,
any_constructor: None,
fields: [
fields: Indef(
[
Constr(
Constr {
tag: 121,
any_constructor: None,
fields: [
fields: Indef(
[
Constr(
Constr {
tag: 122,
any_constructor: None,
fields: [
fields: Indef(
[
BoundedBytes(
BoundedBytes(
[
@ -879,23 +949,27 @@ Constr(
),
),
],
),
},
),
Constr(
Constr {
tag: 121,
any_constructor: None,
fields: [
fields: Indef(
[
Constr(
Constr {
tag: 121,
any_constructor: None,
fields: [
fields: Indef(
[
Constr(
Constr {
tag: 121,
any_constructor: None,
fields: [
fields: Indef(
[
BoundedBytes(
BoundedBytes(
[
@ -931,15 +1005,19 @@ Constr(
),
),
],
),
},
),
],
),
},
),
],
),
},
),
],
),
},
),
Map(
@ -1049,14 +1127,17 @@ Constr(
Constr {
tag: 121,
any_constructor: None,
fields: [],
fields: Def(
[],
),
},
),
Constr(
Constr {
tag: 121,
any_constructor: None,
fields: [
fields: Indef(
[
BoundedBytes(
BoundedBytes(
[
@ -1092,13 +1173,16 @@ Constr(
),
),
],
),
},
),
],
),
},
),
],
),
),
BigInt(
Int(
Int(
@ -1270,8 +1354,10 @@ Constr(
),
),
Array(
Def(
[],
),
),
Map(
Def(
[],
@ -1281,57 +1367,73 @@ Constr(
Constr {
tag: 121,
any_constructor: None,
fields: [
fields: Indef(
[
Constr(
Constr {
tag: 121,
any_constructor: None,
fields: [
fields: Indef(
[
Constr(
Constr {
tag: 121,
any_constructor: None,
fields: [],
fields: Def(
[],
),
},
),
Constr(
Constr {
tag: 122,
any_constructor: None,
fields: [],
fields: Def(
[],
),
},
),
],
),
},
),
Constr(
Constr {
tag: 121,
any_constructor: None,
fields: [
fields: Indef(
[
Constr(
Constr {
tag: 123,
any_constructor: None,
fields: [],
fields: Def(
[],
),
},
),
Constr(
Constr {
tag: 122,
any_constructor: None,
fields: [],
fields: Def(
[],
),
},
),
],
),
},
),
],
),
},
),
Array(
Def(
[],
),
),
Map(
Def(
[
@ -1340,7 +1442,8 @@ Constr(
Constr {
tag: 121,
any_constructor: None,
fields: [
fields: Indef(
[
BoundedBytes(
BoundedBytes(
[
@ -1376,13 +1479,16 @@ Constr(
),
),
],
),
},
),
Constr(
Constr {
tag: 121,
any_constructor: None,
fields: [],
fields: Def(
[],
),
},
),
),
@ -1391,7 +1497,8 @@ Constr(
Constr {
tag: 121,
any_constructor: None,
fields: [
fields: Indef(
[
BoundedBytes(
BoundedBytes(
[
@ -1427,6 +1534,7 @@ Constr(
),
),
],
),
},
),
BigInt(
@ -1489,7 +1597,9 @@ Constr(
Constr {
tag: 121,
any_constructor: None,
fields: [],
fields: Def(
[],
),
},
),
),
@ -1540,23 +1650,30 @@ Constr(
),
),
Array(
Def(
[],
),
),
Constr(
Constr {
tag: 122,
any_constructor: None,
fields: [],
fields: Def(
[],
),
},
),
Constr(
Constr {
tag: 122,
any_constructor: None,
fields: [],
fields: Def(
[],
),
},
),
],
),
},
),
BigInt(
@ -1573,7 +1690,8 @@ Constr(
Constr {
tag: 121,
any_constructor: None,
fields: [
fields: Indef(
[
BoundedBytes(
BoundedBytes(
[
@ -1609,8 +1727,10 @@ Constr(
),
),
],
),
},
),
],
),
},
)

View File

@ -6,24 +6,29 @@ Constr(
Constr {
tag: 121,
any_constructor: None,
fields: [
Constr(
Constr {
tag: 121,
any_constructor: None,
fields: [
Array(
fields: Indef(
[
Constr(
Constr {
tag: 121,
any_constructor: None,
fields: [
fields: Indef(
[
Array(
Indef(
[
Constr(
Constr {
tag: 121,
any_constructor: None,
fields: [
fields: Indef(
[
Constr(
Constr {
tag: 121,
any_constructor: None,
fields: Indef(
[
BoundedBytes(
BoundedBytes(
[
@ -73,23 +78,27 @@ Constr(
),
),
],
),
},
),
Constr(
Constr {
tag: 121,
any_constructor: None,
fields: [
fields: Indef(
[
Constr(
Constr {
tag: 121,
any_constructor: None,
fields: [
fields: Indef(
[
Constr(
Constr {
tag: 122,
any_constructor: None,
fields: [
fields: Indef(
[
BoundedBytes(
BoundedBytes(
[
@ -125,16 +134,20 @@ Constr(
),
),
],
),
},
),
Constr(
Constr {
tag: 122,
any_constructor: None,
fields: [],
fields: Def(
[],
),
},
),
],
),
},
),
Map(
@ -177,97 +190,116 @@ Constr(
Constr {
tag: 123,
any_constructor: None,
fields: [
fields: Indef(
[
Constr(
Constr {
tag: 121,
any_constructor: None,
fields: [],
},
),
],
},
),
Constr(
Constr {
tag: 122,
any_constructor: None,
fields: [],
},
),
],
},
),
],
},
),
],
),
Array(
fields: Def(
[],
),
Array(
[
Constr(
Constr {
tag: 121,
any_constructor: None,
fields: [
Constr(
Constr {
tag: 121,
any_constructor: None,
fields: [
Constr(
Constr {
tag: 121,
any_constructor: None,
fields: [
BoundedBytes(
BoundedBytes(
[
17,
17,
17,
17,
17,
17,
17,
17,
17,
17,
17,
17,
17,
17,
17,
17,
17,
17,
17,
17,
17,
17,
17,
17,
17,
17,
17,
17,
],
),
},
),
],
),
},
),
Constr(
Constr {
tag: 122,
any_constructor: None,
fields: [],
fields: Def(
[],
),
},
),
],
),
},
),
],
),
},
),
],
),
),
Array(
Def(
[],
),
),
Array(
Indef(
[
Constr(
Constr {
tag: 121,
any_constructor: None,
fields: Indef(
[
Constr(
Constr {
tag: 121,
any_constructor: None,
fields: Indef(
[
Constr(
Constr {
tag: 121,
any_constructor: None,
fields: Indef(
[
BoundedBytes(
BoundedBytes(
[
17,
17,
17,
17,
17,
17,
17,
17,
17,
17,
17,
17,
17,
17,
17,
17,
17,
17,
17,
17,
17,
17,
17,
17,
17,
17,
17,
17,
],
),
),
],
),
},
),
Constr(
Constr {
tag: 122,
any_constructor: None,
fields: Def(
[],
),
},
),
],
),
},
),
Map(
@ -310,21 +342,27 @@ Constr(
Constr {
tag: 121,
any_constructor: None,
fields: [],
fields: Def(
[],
),
},
),
Constr(
Constr {
tag: 122,
any_constructor: None,
fields: [],
fields: Def(
[],
),
},
),
],
),
},
),
],
),
),
BigInt(
Int(
Int(
@ -341,8 +379,10 @@ Constr(
),
),
Array(
Def(
[],
),
),
Map(
Def(
[],
@ -352,57 +392,73 @@ Constr(
Constr {
tag: 121,
any_constructor: None,
fields: [
fields: Indef(
[
Constr(
Constr {
tag: 121,
any_constructor: None,
fields: [
fields: Indef(
[
Constr(
Constr {
tag: 121,
any_constructor: None,
fields: [],
fields: Def(
[],
),
},
),
Constr(
Constr {
tag: 122,
any_constructor: None,
fields: [],
fields: Def(
[],
),
},
),
],
),
},
),
Constr(
Constr {
tag: 121,
any_constructor: None,
fields: [
fields: Indef(
[
Constr(
Constr {
tag: 123,
any_constructor: None,
fields: [],
fields: Def(
[],
),
},
),
Constr(
Constr {
tag: 122,
any_constructor: None,
fields: [],
fields: Def(
[],
),
},
),
],
),
},
),
],
),
},
),
Array(
Def(
[],
),
),
Map(
Def(
[
@ -411,12 +467,14 @@ Constr(
Constr {
tag: 122,
any_constructor: None,
fields: [
fields: Indef(
[
Constr(
Constr {
tag: 121,
any_constructor: None,
fields: [
fields: Indef(
[
BoundedBytes(
BoundedBytes(
[
@ -466,16 +524,20 @@ Constr(
),
),
],
),
},
),
],
),
},
),
Constr(
Constr {
tag: 121,
any_constructor: None,
fields: [],
fields: Def(
[],
),
},
),
),
@ -531,42 +593,53 @@ Constr(
),
),
Array(
Def(
[],
),
),
Constr(
Constr {
tag: 122,
any_constructor: None,
fields: [],
fields: Def(
[],
),
},
),
Constr(
Constr {
tag: 122,
any_constructor: None,
fields: [],
fields: Def(
[],
),
},
),
],
),
},
),
Constr(
Constr {
tag: 121,
any_constructor: None,
fields: [],
fields: Def(
[],
),
},
),
Constr(
Constr {
tag: 122,
any_constructor: None,
fields: [
fields: Indef(
[
Constr(
Constr {
tag: 121,
any_constructor: None,
fields: [
fields: Indef(
[
BoundedBytes(
BoundedBytes(
[
@ -616,26 +689,33 @@ Constr(
),
),
],
),
},
),
Constr(
Constr {
tag: 121,
any_constructor: None,
fields: [
fields: Indef(
[
Constr(
Constr {
tag: 121,
any_constructor: None,
fields: [],
fields: Def(
[],
),
},
),
],
),
},
),
],
),
},
),
],
),
},
)

View File

@ -6,24 +6,29 @@ Constr(
Constr {
tag: 121,
any_constructor: None,
fields: [
Constr(
Constr {
tag: 121,
any_constructor: None,
fields: [
Array(
fields: Indef(
[
Constr(
Constr {
tag: 121,
any_constructor: None,
fields: [
fields: Indef(
[
Array(
Indef(
[
Constr(
Constr {
tag: 121,
any_constructor: None,
fields: [
fields: Indef(
[
Constr(
Constr {
tag: 121,
any_constructor: None,
fields: Indef(
[
BoundedBytes(
BoundedBytes(
[
@ -73,23 +78,27 @@ Constr(
),
),
],
),
},
),
Constr(
Constr {
tag: 121,
any_constructor: None,
fields: [
fields: Indef(
[
Constr(
Constr {
tag: 121,
any_constructor: None,
fields: [
fields: Indef(
[
Constr(
Constr {
tag: 121,
any_constructor: None,
fields: [
fields: Indef(
[
BoundedBytes(
BoundedBytes(
[
@ -125,16 +134,20 @@ Constr(
),
),
],
),
},
),
Constr(
Constr {
tag: 122,
any_constructor: None,
fields: [],
fields: Def(
[],
),
},
),
],
),
},
),
Map(
@ -177,30 +190,41 @@ Constr(
Constr {
tag: 121,
any_constructor: None,
fields: [],
fields: Def(
[],
),
},
),
Constr(
Constr {
tag: 122,
any_constructor: None,
fields: [],
},
),
],
},
),
],
},
),
],
),
Array(
fields: Def(
[],
),
},
),
],
),
},
),
],
),
},
),
],
),
),
Array(
Def(
[],
),
),
Array(
Def(
[],
),
),
BigInt(
Int(
Int(
@ -217,8 +241,10 @@ Constr(
),
),
Array(
Def(
[],
),
),
Map(
Def(
[],
@ -228,57 +254,73 @@ Constr(
Constr {
tag: 121,
any_constructor: None,
fields: [
fields: Indef(
[
Constr(
Constr {
tag: 121,
any_constructor: None,
fields: [
fields: Indef(
[
Constr(
Constr {
tag: 121,
any_constructor: None,
fields: [],
fields: Def(
[],
),
},
),
Constr(
Constr {
tag: 122,
any_constructor: None,
fields: [],
fields: Def(
[],
),
},
),
],
),
},
),
Constr(
Constr {
tag: 121,
any_constructor: None,
fields: [
fields: Indef(
[
Constr(
Constr {
tag: 123,
any_constructor: None,
fields: [],
fields: Def(
[],
),
},
),
Constr(
Constr {
tag: 122,
any_constructor: None,
fields: [],
fields: Def(
[],
),
},
),
],
),
},
),
],
),
},
),
Array(
Def(
[],
),
),
Map(
Def(
[
@ -287,17 +329,20 @@ Constr(
Constr {
tag: 125,
any_constructor: None,
fields: [
fields: Indef(
[
Constr(
Constr {
tag: 121,
any_constructor: None,
fields: [
fields: Indef(
[
Constr(
Constr {
tag: 122,
any_constructor: None,
fields: [
fields: Indef(
[
BoundedBytes(
BoundedBytes(
[
@ -333,19 +378,23 @@ Constr(
),
),
],
),
},
),
],
),
},
),
],
),
},
),
Constr(
Constr {
tag: 121,
any_constructor: None,
fields: [
fields: Def(
[
BigInt(
Int(
Int(
@ -357,6 +406,7 @@ Constr(
),
),
],
),
},
),
),
@ -365,17 +415,20 @@ Constr(
Constr {
tag: 125,
any_constructor: None,
fields: [
fields: Indef(
[
Constr(
Constr {
tag: 122,
any_constructor: None,
fields: [
fields: Indef(
[
Constr(
Constr {
tag: 122,
any_constructor: None,
fields: [
fields: Indef(
[
BoundedBytes(
BoundedBytes(
[
@ -411,19 +464,24 @@ Constr(
),
),
],
),
},
),
],
),
},
),
],
),
},
),
Constr(
Constr {
tag: 121,
any_constructor: None,
fields: [],
fields: Def(
[],
),
},
),
),
@ -481,12 +539,14 @@ Constr(
Constr {
tag: 121,
any_constructor: None,
fields: [
fields: Indef(
[
Constr(
Constr {
tag: 122,
any_constructor: None,
fields: [
fields: Indef(
[
BoundedBytes(
BoundedBytes(
[
@ -522,9 +582,11 @@ Constr(
),
),
],
),
},
),
],
),
},
),
Map(
@ -535,7 +597,8 @@ Constr(
Constr {
tag: 121,
any_constructor: None,
fields: [
fields: Indef(
[
BoundedBytes(
BoundedBytes(
[
@ -585,13 +648,16 @@ Constr(
),
),
],
),
},
),
Constr(
Constr {
tag: 122,
any_constructor: None,
fields: [],
fields: Def(
[],
),
},
),
),
@ -604,12 +670,14 @@ Constr(
Constr {
tag: 121,
any_constructor: None,
fields: [
fields: Indef(
[
Constr(
Constr {
tag: 121,
any_constructor: None,
fields: [
fields: Indef(
[
BoundedBytes(
BoundedBytes(
[
@ -645,9 +713,11 @@ Constr(
),
),
],
),
},
),
],
),
},
),
Map(
@ -658,7 +728,8 @@ Constr(
Constr {
tag: 121,
any_constructor: None,
fields: [
fields: Indef(
[
BoundedBytes(
BoundedBytes(
[
@ -708,13 +779,16 @@ Constr(
),
),
],
),
},
),
Constr(
Constr {
tag: 121,
any_constructor: None,
fields: [],
fields: Def(
[],
),
},
),
),
@ -727,12 +801,14 @@ Constr(
Constr {
tag: 122,
any_constructor: None,
fields: [
fields: Indef(
[
Constr(
Constr {
tag: 122,
any_constructor: None,
fields: [
fields: Indef(
[
BoundedBytes(
BoundedBytes(
[
@ -768,9 +844,11 @@ Constr(
),
),
],
),
},
),
],
),
},
),
Map(
@ -781,7 +859,8 @@ Constr(
Constr {
tag: 121,
any_constructor: None,
fields: [
fields: Indef(
[
BoundedBytes(
BoundedBytes(
[
@ -831,13 +910,16 @@ Constr(
),
),
],
),
},
),
Constr(
Constr {
tag: 121,
any_constructor: None,
fields: [],
fields: Def(
[],
),
},
),
),
@ -850,12 +932,14 @@ Constr(
Constr {
tag: 122,
any_constructor: None,
fields: [
fields: Indef(
[
Constr(
Constr {
tag: 121,
any_constructor: None,
fields: [
fields: Indef(
[
BoundedBytes(
BoundedBytes(
[
@ -891,9 +975,11 @@ Constr(
),
),
],
),
},
),
],
),
},
),
Map(
@ -904,7 +990,8 @@ Constr(
Constr {
tag: 121,
any_constructor: None,
fields: [
fields: Indef(
[
BoundedBytes(
BoundedBytes(
[
@ -954,13 +1041,16 @@ Constr(
),
),
],
),
},
),
Constr(
Constr {
tag: 123,
any_constructor: None,
fields: [],
fields: Def(
[],
),
},
),
),
@ -969,7 +1059,8 @@ Constr(
Constr {
tag: 121,
any_constructor: None,
fields: [
fields: Indef(
[
BoundedBytes(
BoundedBytes(
[
@ -1019,13 +1110,16 @@ Constr(
),
),
],
),
},
),
Constr(
Constr {
tag: 123,
any_constructor: None,
fields: [],
fields: Def(
[],
),
},
),
),
@ -1034,7 +1128,8 @@ Constr(
Constr {
tag: 121,
any_constructor: None,
fields: [
fields: Indef(
[
BoundedBytes(
BoundedBytes(
[
@ -1084,13 +1179,16 @@ Constr(
),
),
],
),
},
),
Constr(
Constr {
tag: 123,
any_constructor: None,
fields: [],
fields: Def(
[],
),
},
),
),
@ -1103,7 +1201,8 @@ Constr(
Constr {
tag: 123,
any_constructor: None,
fields: [
fields: Indef(
[
BoundedBytes(
BoundedBytes(
[
@ -1139,6 +1238,7 @@ Constr(
),
),
],
),
},
),
Map(
@ -1149,7 +1249,8 @@ Constr(
Constr {
tag: 121,
any_constructor: None,
fields: [
fields: Indef(
[
BoundedBytes(
BoundedBytes(
[
@ -1199,13 +1300,16 @@ Constr(
),
),
],
),
},
),
Constr(
Constr {
tag: 122,
any_constructor: None,
fields: [],
fields: Def(
[],
),
},
),
),
@ -1217,30 +1321,38 @@ Constr(
),
),
Array(
Def(
[],
),
),
Constr(
Constr {
tag: 122,
any_constructor: None,
fields: [],
fields: Def(
[],
),
},
),
Constr(
Constr {
tag: 122,
any_constructor: None,
fields: [],
fields: Def(
[],
),
},
),
],
),
},
),
Constr(
Constr {
tag: 121,
any_constructor: None,
fields: [
fields: Indef(
[
BigInt(
Int(
Int(
@ -1252,23 +1364,27 @@ Constr(
),
),
],
),
},
),
Constr(
Constr {
tag: 125,
any_constructor: None,
fields: [
fields: Indef(
[
Constr(
Constr {
tag: 121,
any_constructor: None,
fields: [
fields: Indef(
[
Constr(
Constr {
tag: 122,
any_constructor: None,
fields: [
fields: Indef(
[
BoundedBytes(
BoundedBytes(
[
@ -1304,14 +1420,18 @@ Constr(
),
),
],
),
},
),
],
),
},
),
],
),
},
),
],
),
},
)

View File

@ -6,24 +6,29 @@ Constr(
Constr {
tag: 121,
any_constructor: None,
fields: [
Constr(
Constr {
tag: 121,
any_constructor: None,
fields: [
Array(
fields: Indef(
[
Constr(
Constr {
tag: 121,
any_constructor: None,
fields: [
fields: Indef(
[
Array(
Indef(
[
Constr(
Constr {
tag: 121,
any_constructor: None,
fields: [
fields: Indef(
[
Constr(
Constr {
tag: 121,
any_constructor: None,
fields: Indef(
[
BoundedBytes(
BoundedBytes(
[
@ -73,23 +78,27 @@ Constr(
),
),
],
),
},
),
Constr(
Constr {
tag: 121,
any_constructor: None,
fields: [
fields: Indef(
[
Constr(
Constr {
tag: 121,
any_constructor: None,
fields: [
fields: Indef(
[
Constr(
Constr {
tag: 122,
any_constructor: None,
fields: [
fields: Indef(
[
BoundedBytes(
BoundedBytes(
[
@ -125,23 +134,27 @@ Constr(
),
),
],
),
},
),
Constr(
Constr {
tag: 121,
any_constructor: None,
fields: [
fields: Indef(
[
Constr(
Constr {
tag: 121,
any_constructor: None,
fields: [
fields: Indef(
[
Constr(
Constr {
tag: 122,
any_constructor: None,
fields: [
fields: Indef(
[
BoundedBytes(
BoundedBytes(
[
@ -177,15 +190,19 @@ Constr(
),
),
],
),
},
),
],
),
},
),
],
),
},
),
],
),
},
),
Map(
@ -228,22 +245,27 @@ Constr(
Constr {
tag: 123,
any_constructor: None,
fields: [
fields: Indef(
[
Constr(
Constr {
tag: 121,
any_constructor: None,
fields: [],
fields: Def(
[],
),
},
),
],
),
},
),
Constr(
Constr {
tag: 121,
any_constructor: None,
fields: [
fields: Indef(
[
BoundedBytes(
BoundedBytes(
[
@ -279,36 +301,46 @@ Constr(
),
),
],
),
},
),
],
),
},
),
],
),
},
),
],
),
),
Array(
Def(
[],
),
),
Array(
Indef(
[
Constr(
Constr {
tag: 121,
any_constructor: None,
fields: [
fields: Indef(
[
Constr(
Constr {
tag: 121,
any_constructor: None,
fields: [
fields: Indef(
[
Constr(
Constr {
tag: 121,
any_constructor: None,
fields: [
fields: Indef(
[
BoundedBytes(
BoundedBytes(
[
@ -344,23 +376,27 @@ Constr(
),
),
],
),
},
),
Constr(
Constr {
tag: 121,
any_constructor: None,
fields: [
fields: Indef(
[
Constr(
Constr {
tag: 121,
any_constructor: None,
fields: [
fields: Indef(
[
Constr(
Constr {
tag: 122,
any_constructor: None,
fields: [
fields: Indef(
[
BoundedBytes(
BoundedBytes(
[
@ -396,15 +432,19 @@ Constr(
),
),
],
),
},
),
],
),
},
),
],
),
},
),
],
),
},
),
Map(
@ -447,34 +487,42 @@ Constr(
Constr {
tag: 121,
any_constructor: None,
fields: [],
fields: Def(
[],
),
},
),
Constr(
Constr {
tag: 122,
any_constructor: None,
fields: [],
fields: Def(
[],
),
},
),
],
),
},
),
Constr(
Constr {
tag: 121,
any_constructor: None,
fields: [
fields: Indef(
[
Constr(
Constr {
tag: 121,
any_constructor: None,
fields: [
fields: Indef(
[
Constr(
Constr {
tag: 121,
any_constructor: None,
fields: [
fields: Indef(
[
BoundedBytes(
BoundedBytes(
[
@ -510,18 +558,21 @@ Constr(
),
),
],
),
},
),
Constr(
Constr {
tag: 121,
any_constructor: None,
fields: [
fields: Indef(
[
Constr(
Constr {
tag: 122,
any_constructor: None,
fields: [
fields: Indef(
[
BigInt(
Int(
Int(
@ -553,12 +604,15 @@ Constr(
),
),
],
),
},
),
],
),
},
),
],
),
},
),
Map(
@ -601,34 +655,42 @@ Constr(
Constr {
tag: 121,
any_constructor: None,
fields: [],
fields: Def(
[],
),
},
),
Constr(
Constr {
tag: 122,
any_constructor: None,
fields: [],
fields: Def(
[],
),
},
),
],
),
},
),
Constr(
Constr {
tag: 121,
any_constructor: None,
fields: [
fields: Indef(
[
Constr(
Constr {
tag: 121,
any_constructor: None,
fields: [
fields: Indef(
[
Constr(
Constr {
tag: 122,
any_constructor: None,
fields: [
fields: Indef(
[
BoundedBytes(
BoundedBytes(
[
@ -664,18 +726,21 @@ Constr(
),
),
],
),
},
),
Constr(
Constr {
tag: 121,
any_constructor: None,
fields: [
fields: Indef(
[
Constr(
Constr {
tag: 122,
any_constructor: None,
fields: [
fields: Indef(
[
BigInt(
Int(
Int(
@ -707,12 +772,15 @@ Constr(
),
),
],
),
},
),
],
),
},
),
],
),
},
),
Map(
@ -755,21 +823,27 @@ Constr(
Constr {
tag: 121,
any_constructor: None,
fields: [],
fields: Def(
[],
),
},
),
Constr(
Constr {
tag: 122,
any_constructor: None,
fields: [],
fields: Def(
[],
),
},
),
],
),
},
),
],
),
),
BigInt(
Int(
Int(
@ -786,8 +860,10 @@ Constr(
),
),
Array(
Def(
[],
),
),
Map(
Def(
[
@ -796,7 +872,8 @@ Constr(
Constr {
tag: 122,
any_constructor: None,
fields: [
fields: Indef(
[
BoundedBytes(
BoundedBytes(
[
@ -832,6 +909,7 @@ Constr(
),
),
],
),
},
),
BigInt(
@ -852,39 +930,48 @@ Constr(
Constr {
tag: 121,
any_constructor: None,
fields: [
fields: Indef(
[
Constr(
Constr {
tag: 121,
any_constructor: None,
fields: [
fields: Indef(
[
Constr(
Constr {
tag: 121,
any_constructor: None,
fields: [],
fields: Def(
[],
),
},
),
Constr(
Constr {
tag: 122,
any_constructor: None,
fields: [],
fields: Def(
[],
),
},
),
],
),
},
),
Constr(
Constr {
tag: 121,
any_constructor: None,
fields: [
fields: Indef(
[
Constr(
Constr {
tag: 122,
any_constructor: None,
fields: [
fields: Indef(
[
BigInt(
Int(
Int(
@ -896,22 +983,28 @@ Constr(
),
),
],
),
},
),
Constr(
Constr {
tag: 121,
any_constructor: None,
fields: [],
fields: Def(
[],
),
},
),
],
),
},
),
],
),
},
),
Array(
Indef(
[
BoundedBytes(
BoundedBytes(
@ -949,6 +1042,7 @@ Constr(
),
],
),
),
Map(
Def(
[
@ -957,12 +1051,14 @@ Constr(
Constr {
tag: 122,
any_constructor: None,
fields: [
fields: Indef(
[
Constr(
Constr {
tag: 121,
any_constructor: None,
fields: [
fields: Indef(
[
BoundedBytes(
BoundedBytes(
[
@ -1012,24 +1108,30 @@ Constr(
),
),
],
),
},
),
],
),
},
),
Constr(
Constr {
tag: 122,
any_constructor: None,
fields: [
fields: Def(
[
Constr(
Constr {
tag: 121,
any_constructor: None,
fields: [],
fields: Def(
[],
),
},
),
],
),
},
),
),
@ -1038,12 +1140,14 @@ Constr(
Constr {
tag: 123,
any_constructor: None,
fields: [
fields: Indef(
[
Constr(
Constr {
tag: 122,
any_constructor: None,
fields: [
fields: Indef(
[
BoundedBytes(
BoundedBytes(
[
@ -1079,16 +1183,20 @@ Constr(
),
),
],
),
},
),
],
),
},
),
Constr(
Constr {
tag: 121,
any_constructor: None,
fields: [],
fields: Def(
[],
),
},
),
),
@ -1144,20 +1252,25 @@ Constr(
),
),
Array(
Def(
[],
),
),
Constr(
Constr {
tag: 122,
any_constructor: None,
fields: [],
fields: Def(
[],
),
},
),
Constr(
Constr {
tag: 121,
any_constructor: None,
fields: [
fields: Indef(
[
BigInt(
Int(
Int(
@ -1169,28 +1282,34 @@ Constr(
),
),
],
),
},
),
],
),
},
),
Constr(
Constr {
tag: 121,
any_constructor: None,
fields: [],
fields: Def(
[],
),
},
),
Constr(
Constr {
tag: 123,
any_constructor: None,
fields: [
fields: Indef(
[
Constr(
Constr {
tag: 122,
any_constructor: None,
fields: [
fields: Indef(
[
BoundedBytes(
BoundedBytes(
[
@ -1226,11 +1345,14 @@ Constr(
),
),
],
),
},
),
],
),
},
),
],
),
},
)

View File

@ -2,7 +2,7 @@ use super::{eval_phase_two, ResolvedInput, SlotConfig};
use crate::machine::cost_model::ExBudget;
use pallas_codec::utils::MaybeIndefArray;
use pallas_primitives::{
conway::{CostMdls, TransactionInput, TransactionOutput},
conway::{CostModels, TransactionInput, TransactionOutput},
Fragment,
};
use pallas_traverse::{Era, MultiEraTx};
@ -222,7 +222,7 @@ fn test_eval_0() {
20000000000,
];
let cost_mdl = CostMdls {
let cost_mdl = CostModels {
plutus_v1: None,
plutus_v2: Some(costs),
plutus_v3: None,
@ -494,7 +494,7 @@ fn test_eval_1() {
20000000000,
];
let cost_mdl = CostMdls {
let cost_mdl = CostModels {
plutus_v1: None,
plutus_v2: Some(costs),
plutus_v3: None,
@ -606,7 +606,7 @@ fn test_eval_2() {
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_v2: None,
plutus_v3: None,
@ -876,7 +876,7 @@ fn test_eval_3() {
20000000000,
];
let cost_mdl = CostMdls {
let cost_mdl = CostModels {
plutus_v1: None,
plutus_v2: Some(costs),
plutus_v3: None,
@ -984,7 +984,7 @@ fn test_eval_4() {
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_v2: 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,
];
let cost_mdl = CostMdls {
let cost_mdl = CostModels {
plutus_v1: Some(costs),
plutus_v2: None,
plutus_v3: None,
@ -1179,7 +1179,7 @@ fn test_eval_6() {
3345831, 1, 1,
];
let cost_mdl = CostMdls {
let cost_mdl = CostModels {
plutus_v1: Some(costs),
plutus_v2: None,
plutus_v3: None,
@ -1289,7 +1289,7 @@ fn test_eval_7() {
3345831, 1, 1,
];
let cost_mdl = CostMdls {
let cost_mdl = CostModels {
plutus_v1: Some(costs),
plutus_v2: None,
plutus_v3: None,
@ -1550,7 +1550,7 @@ fn test_eval_8() {
20000000000,
];
let cost_mdl = CostMdls {
let cost_mdl = CostModels {
plutus_v1: None,
plutus_v2: Some(costs),
plutus_v3: None,
@ -1656,7 +1656,7 @@ fn eval_missing_redeemer() {
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_v2: 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,
];
let cost_mdl = CostMdls {
let cost_mdl = CostModels {
plutus_v1: Some(costs),
plutus_v2: None,
plutus_v3: None,

View File

@ -11,7 +11,8 @@ use pallas_addresses::{
Address, ShelleyDelegationPart, ShelleyPaymentPart, StakeAddress, StakePayload,
};
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_primitives::conway::{
@ -28,7 +29,11 @@ fn wrap_multiple_with_constr(index: u64, data: Vec<PlutusData>) -> PlutusData {
PlutusData::Constr(Constr {
tag: converted.unwrap_or(ANY_TAG),
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(),
ShelleyDelegationPart::Script(script_hash) => Some(wrap_with_constr(
0,
StakeCredential::Scripthash(*script_hash).to_plutus_data(),
StakeCredential::ScriptHash(*script_hash).to_plutus_data(),
))
.to_plutus_data(),
ShelleyDelegationPart::Pointer(pointer) => Some(wrap_multiple_with_constr(
@ -174,7 +179,7 @@ where
A: ToPlutusData,
{
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>>> {
fn to_plutus_data(&self) -> PlutusData {
PlutusData::Array(
Data::list(
self.0
.0
.iter()
@ -426,7 +431,7 @@ impl<'a> ToPlutusData for WithOptionDatum<'a, WithZeroAdaAsset<'a, Vec<Transacti
impl<'a> ToPlutusData for WithZeroAdaAsset<'a, Vec<TransactionOutput>> {
fn to_plutus_data(&self) -> PlutusData {
PlutusData::Array(
Data::list(
self.0
.iter()
.map(|p| WithZeroAdaAsset(p).to_plutus_data())
@ -516,7 +521,7 @@ impl ToPlutusData for StakeCredential {
StakeCredential::AddrKeyhash(addr_keyhas) => {
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())
}
}
@ -741,7 +746,7 @@ impl ToPlutusData for DRep {
wrap_with_constr(0, StakeCredential::AddrKeyhash(*hash).to_plutus_data())
}
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::NoConfidence => empty_constr(2),
@ -798,7 +803,7 @@ impl<'a> ToPlutusData
for WithOptionDatum<'a, WithZeroAdaAsset<'a, WithWrappedTransactionId<'a, Vec<TxInInfo>>>>
{
fn to_plutus_data(&self) -> PlutusData {
PlutusData::Array(
Data::list(
self.0
.0
.0
@ -814,7 +819,7 @@ impl<'a> ToPlutusData
impl<'a> ToPlutusData for WithZeroAdaAsset<'a, WithWrappedTransactionId<'a, Vec<TxInInfo>>> {
fn to_plutus_data(&self) -> PlutusData {
PlutusData::Array(
Data::list(
self.0
.0
.iter()
@ -1254,13 +1259,13 @@ impl ToPlutusData for Voter {
fn to_plutus_data(&self) -> PlutusData {
match self {
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) => {
wrap_with_constr(0, StakeCredential::AddrKeyhash(*hash).to_plutus_data())
}
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) => {
wrap_with_constr(1, StakeCredential::AddrKeyhash(*hash).to_plutus_data())

View File

@ -1,4 +1,5 @@
use num_bigint::ToBigInt;
use pallas_codec::utils::MaybeIndefArray;
use uplc::{
ast::{Constant, Name, Term, Type},
parser::term,
@ -111,9 +112,9 @@ fn constant_data_constr() {
Constant::Data(PlutusData::Constr(Constr::<PlutusData> {
tag: 122,
any_constructor: None,
fields: vec![PlutusData::BigInt(pallas_primitives::alonzo::BigInt::Int(
2.into(),
))],
fields: MaybeIndefArray::Indef(vec![PlutusData::BigInt(
pallas_primitives::alonzo::BigInt::Int(2.into()),
)]),
}))
.into(),
),
@ -145,10 +146,10 @@ fn constant_data_map() {
fn constant_data_list() {
round_trip(
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(1.into())),
]))
])))
.into(),
),
"(con data (List [I 0, I 1]))",