parent
4ca73c4cdf
commit
3bc3792aa3
|
@ -29,6 +29,7 @@ use crate::{
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
line_numbers::LineNumbers,
|
line_numbers::LineNumbers,
|
||||||
|
plutus_version::PlutusVersion,
|
||||||
tipo::{
|
tipo::{
|
||||||
check_replaceable_opaque_type, convert_opaque_type, find_and_replace_generics,
|
check_replaceable_opaque_type, convert_opaque_type, find_and_replace_generics,
|
||||||
get_arg_type_name, get_generic_id_and_type, lookup_data_type_by_tipo,
|
get_arg_type_name, get_generic_id_and_type, lookup_data_type_by_tipo,
|
||||||
|
@ -51,6 +52,8 @@ use uplc::{
|
||||||
|
|
||||||
#[derive(Clone)]
|
#[derive(Clone)]
|
||||||
pub struct CodeGenerator<'a> {
|
pub struct CodeGenerator<'a> {
|
||||||
|
#[allow(dead_code)]
|
||||||
|
plutus_version: PlutusVersion,
|
||||||
/// immutable index maps
|
/// immutable index maps
|
||||||
functions: IndexMap<&'a FunctionAccessKey, &'a TypedFunction>,
|
functions: IndexMap<&'a FunctionAccessKey, &'a TypedFunction>,
|
||||||
data_types: IndexMap<&'a DataTypeKey, &'a TypedDataType>,
|
data_types: IndexMap<&'a DataTypeKey, &'a TypedDataType>,
|
||||||
|
@ -75,6 +78,7 @@ impl<'a> CodeGenerator<'a> {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn new(
|
pub fn new(
|
||||||
|
plutus_version: PlutusVersion,
|
||||||
functions: IndexMap<&'a FunctionAccessKey, &'a TypedFunction>,
|
functions: IndexMap<&'a FunctionAccessKey, &'a TypedFunction>,
|
||||||
data_types: IndexMap<&'a DataTypeKey, &'a TypedDataType>,
|
data_types: IndexMap<&'a DataTypeKey, &'a TypedDataType>,
|
||||||
module_types: IndexMap<&'a str, &'a TypeInfo>,
|
module_types: IndexMap<&'a str, &'a TypeInfo>,
|
||||||
|
@ -82,6 +86,7 @@ impl<'a> CodeGenerator<'a> {
|
||||||
tracing: Tracing,
|
tracing: Tracing,
|
||||||
) -> Self {
|
) -> Self {
|
||||||
CodeGenerator {
|
CodeGenerator {
|
||||||
|
plutus_version,
|
||||||
functions,
|
functions,
|
||||||
data_types,
|
data_types,
|
||||||
module_types,
|
module_types,
|
||||||
|
|
|
@ -12,6 +12,7 @@ pub mod gen_uplc;
|
||||||
pub mod levenshtein;
|
pub mod levenshtein;
|
||||||
pub mod line_numbers;
|
pub mod line_numbers;
|
||||||
pub mod parser;
|
pub mod parser;
|
||||||
|
pub mod plutus_version;
|
||||||
pub mod pretty;
|
pub mod pretty;
|
||||||
pub mod tipo;
|
pub mod tipo;
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,51 @@
|
||||||
|
use pallas::ledger::primitives::conway::Language;
|
||||||
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
|
#[derive(Debug, Default, Deserialize, Serialize, Clone, Copy, PartialEq)]
|
||||||
|
#[serde(rename_all = "camelCase")]
|
||||||
|
pub enum PlutusVersion {
|
||||||
|
V1,
|
||||||
|
#[default]
|
||||||
|
V2,
|
||||||
|
V3,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl From<PlutusVersion> for Language {
|
||||||
|
fn from(value: PlutusVersion) -> Self {
|
||||||
|
match value {
|
||||||
|
PlutusVersion::V1 => Language::PlutusV1,
|
||||||
|
PlutusVersion::V2 => Language::PlutusV2,
|
||||||
|
PlutusVersion::V3 => Language::PlutusV3,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl From<&PlutusVersion> for Language {
|
||||||
|
fn from(value: &PlutusVersion) -> Self {
|
||||||
|
match value {
|
||||||
|
PlutusVersion::V1 => Language::PlutusV1,
|
||||||
|
PlutusVersion::V2 => Language::PlutusV2,
|
||||||
|
PlutusVersion::V3 => Language::PlutusV3,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl From<Language> for PlutusVersion {
|
||||||
|
fn from(value: Language) -> Self {
|
||||||
|
match value {
|
||||||
|
Language::PlutusV1 => PlutusVersion::V2,
|
||||||
|
Language::PlutusV2 => PlutusVersion::V2,
|
||||||
|
Language::PlutusV3 => PlutusVersion::V3,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl PlutusVersion {
|
||||||
|
pub fn cardano_cli_type(&self) -> String {
|
||||||
|
match self {
|
||||||
|
PlutusVersion::V1 => "PlutusScriptV1".to_string(),
|
||||||
|
PlutusVersion::V2 => "PlutusScriptV2".to_string(),
|
||||||
|
PlutusVersion::V3 => "PlutusScriptV3".to_string(),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -8,7 +8,7 @@ pub mod validator;
|
||||||
pub use error::Error;
|
pub use error::Error;
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
config::{self, Config},
|
config::{self, Config, PlutusVersion},
|
||||||
module::CheckedModules,
|
module::CheckedModules,
|
||||||
};
|
};
|
||||||
use aiken_lang::gen_uplc::CodeGenerator;
|
use aiken_lang::gen_uplc::CodeGenerator;
|
||||||
|
@ -44,13 +44,6 @@ pub struct Preamble {
|
||||||
pub license: Option<String>,
|
pub license: Option<String>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, PartialEq, Clone, serde::Serialize, serde::Deserialize)]
|
|
||||||
#[serde(rename_all = "camelCase")]
|
|
||||||
pub enum PlutusVersion {
|
|
||||||
V1,
|
|
||||||
V2,
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Debug, PartialEq, Clone, serde::Serialize, serde::Deserialize)]
|
#[derive(Debug, PartialEq, Clone, serde::Serialize, serde::Deserialize)]
|
||||||
#[serde(rename_all = "camelCase")]
|
#[serde(rename_all = "camelCase")]
|
||||||
pub struct Compiler {
|
pub struct Compiler {
|
||||||
|
@ -151,7 +144,7 @@ impl From<&Config> for Preamble {
|
||||||
name: "Aiken".to_string(),
|
name: "Aiken".to_string(),
|
||||||
version: config::compiler_version(true),
|
version: config::compiler_version(true),
|
||||||
}),
|
}),
|
||||||
plutus_version: PlutusVersion::V2,
|
plutus_version: config.plutus_version,
|
||||||
version: config.version.clone(),
|
version: config.version.clone(),
|
||||||
license: config.license.clone(),
|
license: config.license.clone(),
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,13 +1,18 @@
|
||||||
|
use std::{fmt::Display, fs, io, path::Path};
|
||||||
|
|
||||||
use crate::{github::repo::LatestRelease, package_name::PackageName, paths, Error};
|
use crate::{github::repo::LatestRelease, package_name::PackageName, paths, Error};
|
||||||
use aiken_lang::ast::Span;
|
use aiken_lang::ast::Span;
|
||||||
|
|
||||||
use miette::NamedSource;
|
use miette::NamedSource;
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
use std::{fmt::Display, fs, io, path::Path};
|
|
||||||
|
pub use aiken_lang::plutus_version::PlutusVersion;
|
||||||
|
|
||||||
#[derive(Deserialize, Serialize, Clone)]
|
#[derive(Deserialize, Serialize, Clone)]
|
||||||
pub struct Config {
|
pub struct Config {
|
||||||
pub name: PackageName,
|
pub name: PackageName,
|
||||||
pub version: String,
|
pub version: String,
|
||||||
|
pub plutus_version: PlutusVersion,
|
||||||
pub license: Option<String>,
|
pub license: Option<String>,
|
||||||
#[serde(default)]
|
#[serde(default)]
|
||||||
pub description: String,
|
pub description: String,
|
||||||
|
@ -53,6 +58,7 @@ impl Config {
|
||||||
Config {
|
Config {
|
||||||
name: name.clone(),
|
name: name.clone(),
|
||||||
version: "0.0.0".to_string(),
|
version: "0.0.0".to_string(),
|
||||||
|
plutus_version: PlutusVersion::default(),
|
||||||
license: Some("Apache-2.0".to_string()),
|
license: Some("Apache-2.0".to_string()),
|
||||||
description: format!("Aiken contracts for project '{name}'"),
|
description: format!("Aiken contracts for project '{name}'"),
|
||||||
repository: Some(Repository {
|
repository: Some(Repository {
|
||||||
|
|
|
@ -35,10 +35,11 @@ use aiken_lang::{
|
||||||
DataTypeKey, Definition, FunctionAccessKey, ModuleKind, Tracing, TypedDataType,
|
DataTypeKey, Definition, FunctionAccessKey, ModuleKind, Tracing, TypedDataType,
|
||||||
TypedFunction,
|
TypedFunction,
|
||||||
},
|
},
|
||||||
builtins::{self},
|
builtins,
|
||||||
expr::UntypedExpr,
|
expr::UntypedExpr,
|
||||||
gen_uplc::CodeGenerator,
|
gen_uplc::CodeGenerator,
|
||||||
line_numbers::LineNumbers,
|
line_numbers::LineNumbers,
|
||||||
|
plutus_version::PlutusVersion,
|
||||||
tipo::{Type, TypeInfo},
|
tipo::{Type, TypeInfo},
|
||||||
IdGenerator,
|
IdGenerator,
|
||||||
};
|
};
|
||||||
|
@ -49,7 +50,7 @@ use options::{CodeGenMode, Options};
|
||||||
use package_name::PackageName;
|
use package_name::PackageName;
|
||||||
use pallas::ledger::{
|
use pallas::ledger::{
|
||||||
addresses::{Address, Network, ShelleyAddress, ShelleyDelegationPart, StakePayload},
|
addresses::{Address, Network, ShelleyAddress, ShelleyDelegationPart, StakePayload},
|
||||||
primitives::babbage::{self as cardano, PolicyId},
|
primitives::conway::{self as cardano, PolicyId},
|
||||||
traverse::ComputeHash,
|
traverse::ComputeHash,
|
||||||
};
|
};
|
||||||
use std::{
|
use std::{
|
||||||
|
@ -141,6 +142,7 @@ where
|
||||||
|
|
||||||
pub fn new_generator(&'_ self, tracing: Tracing) -> CodeGenerator<'_> {
|
pub fn new_generator(&'_ self, tracing: Tracing) -> CodeGenerator<'_> {
|
||||||
CodeGenerator::new(
|
CodeGenerator::new(
|
||||||
|
self.config.plutus_version,
|
||||||
utils::indexmap::as_ref_values(&self.functions),
|
utils::indexmap::as_ref_values(&self.functions),
|
||||||
utils::indexmap::as_ref_values(&self.data_types),
|
utils::indexmap::as_ref_values(&self.data_types),
|
||||||
utils::indexmap::as_str_ref_values(&self.module_types),
|
utils::indexmap::as_str_ref_values(&self.module_types),
|
||||||
|
@ -422,6 +424,7 @@ where
|
||||||
}
|
}
|
||||||
|
|
||||||
let n = validator.parameters.len();
|
let n = validator.parameters.len();
|
||||||
|
|
||||||
if n > 0 {
|
if n > 0 {
|
||||||
Err(blueprint::error::Error::ParameterizedValidator { n }.into())
|
Err(blueprint::error::Error::ParameterizedValidator { n }.into())
|
||||||
} else {
|
} else {
|
||||||
|
@ -460,7 +463,13 @@ where
|
||||||
Err(blueprint::error::Error::ParameterizedValidator { n }.into())
|
Err(blueprint::error::Error::ParameterizedValidator { n }.into())
|
||||||
} else {
|
} else {
|
||||||
let cbor = validator.program.to_cbor().unwrap();
|
let cbor = validator.program.to_cbor().unwrap();
|
||||||
let validator_hash = cardano::PlutusV2Script(cbor.into()).compute_hash();
|
|
||||||
|
let validator_hash = match self.config.plutus_version {
|
||||||
|
PlutusVersion::V1 => cardano::PlutusV1Script(cbor.into()).compute_hash(),
|
||||||
|
PlutusVersion::V2 => cardano::PlutusV2Script(cbor.into()).compute_hash(),
|
||||||
|
PlutusVersion::V3 => cardano::PlutusV3Script(cbor.into()).compute_hash(),
|
||||||
|
};
|
||||||
|
|
||||||
Ok(validator_hash)
|
Ok(validator_hash)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
@ -842,11 +851,15 @@ where
|
||||||
|
|
||||||
let data_types = utils::indexmap::as_ref_values(&self.data_types);
|
let data_types = utils::indexmap::as_ref_values(&self.data_types);
|
||||||
|
|
||||||
|
let plutus_version = &self.config.plutus_version;
|
||||||
|
|
||||||
tests
|
tests
|
||||||
.into_par_iter()
|
.into_par_iter()
|
||||||
.map(|test| match test {
|
.map(|test| match test {
|
||||||
Test::UnitTest(unit_test) => unit_test.run(),
|
Test::UnitTest(unit_test) => unit_test.run(plutus_version),
|
||||||
Test::PropertyTest(property_test) => property_test.run(seed, property_max_success),
|
Test::PropertyTest(property_test) => {
|
||||||
|
property_test.run(seed, property_max_success, plutus_version)
|
||||||
|
}
|
||||||
})
|
})
|
||||||
.collect::<Vec<TestResult<(Constant, Rc<Type>), PlutusData>>>()
|
.collect::<Vec<TestResult<(Constant, Rc<Type>), PlutusData>>>()
|
||||||
.into_iter()
|
.into_iter()
|
||||||
|
|
|
@ -4,6 +4,7 @@ use aiken_lang::{
|
||||||
expr::{TypedExpr, UntypedExpr},
|
expr::{TypedExpr, UntypedExpr},
|
||||||
format::Formatter,
|
format::Formatter,
|
||||||
gen_uplc::CodeGenerator,
|
gen_uplc::CodeGenerator,
|
||||||
|
plutus_version::PlutusVersion,
|
||||||
tipo::{convert_opaque_type, Type},
|
tipo::{convert_opaque_type, Type},
|
||||||
};
|
};
|
||||||
use cryptoxide::{blake2b::Blake2b, digest::Digest};
|
use cryptoxide::{blake2b::Blake2b, digest::Digest};
|
||||||
|
@ -171,10 +172,10 @@ pub struct UnitTest {
|
||||||
unsafe impl Send for UnitTest {}
|
unsafe impl Send for UnitTest {}
|
||||||
|
|
||||||
impl UnitTest {
|
impl UnitTest {
|
||||||
pub fn run<T>(self) -> TestResult<(Constant, Rc<Type>), T> {
|
pub fn run<T>(self, plutus_version: &PlutusVersion) -> TestResult<(Constant, Rc<Type>), T> {
|
||||||
let mut eval_result = Program::<NamedDeBruijn>::try_from(self.program.clone())
|
let mut eval_result = Program::<NamedDeBruijn>::try_from(self.program.clone())
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.eval(ExBudget::max());
|
.eval_version(ExBudget::max(), &plutus_version.into());
|
||||||
|
|
||||||
let success = !eval_result.failed(self.can_error);
|
let success = !eval_result.failed(self.can_error);
|
||||||
|
|
||||||
|
@ -226,15 +227,24 @@ impl PropertyTest {
|
||||||
|
|
||||||
/// Run a property test from a given seed. The property is run at most DEFAULT_MAX_SUCCESS times. It
|
/// Run a property test from a given seed. The property is run at most DEFAULT_MAX_SUCCESS times. It
|
||||||
/// may stops earlier on failure; in which case a 'counterexample' is returned.
|
/// may stops earlier on failure; in which case a 'counterexample' is returned.
|
||||||
pub fn run<U>(self, seed: u32, n: usize) -> TestResult<U, PlutusData> {
|
pub fn run<U>(
|
||||||
|
self,
|
||||||
|
seed: u32,
|
||||||
|
n: usize,
|
||||||
|
plutus_version: &PlutusVersion,
|
||||||
|
) -> TestResult<U, PlutusData> {
|
||||||
let mut labels = BTreeMap::new();
|
let mut labels = BTreeMap::new();
|
||||||
let mut remaining = n;
|
let mut remaining = n;
|
||||||
|
|
||||||
let (traces, counterexample, iterations) =
|
let (traces, counterexample, iterations) = match self.run_n_times(
|
||||||
match self.run_n_times(&mut remaining, Prng::from_seed(seed), &mut labels) {
|
&mut remaining,
|
||||||
|
Prng::from_seed(seed),
|
||||||
|
&mut labels,
|
||||||
|
plutus_version,
|
||||||
|
) {
|
||||||
Ok(None) => (Vec::new(), Ok(None), n),
|
Ok(None) => (Vec::new(), Ok(None), n),
|
||||||
Ok(Some(counterexample)) => (
|
Ok(Some(counterexample)) => (
|
||||||
self.eval(&counterexample.value)
|
self.eval(&counterexample.value, plutus_version)
|
||||||
.logs()
|
.logs()
|
||||||
.into_iter()
|
.into_iter()
|
||||||
.filter(|s| PropertyTest::extract_label(s).is_none())
|
.filter(|s| PropertyTest::extract_label(s).is_none())
|
||||||
|
@ -266,28 +276,30 @@ impl PropertyTest {
|
||||||
remaining: &mut usize,
|
remaining: &mut usize,
|
||||||
initial_prng: Prng,
|
initial_prng: Prng,
|
||||||
labels: &mut BTreeMap<String, usize>,
|
labels: &mut BTreeMap<String, usize>,
|
||||||
|
plutus_version: &'a PlutusVersion,
|
||||||
) -> Result<Option<Counterexample<'a>>, FuzzerError> {
|
) -> Result<Option<Counterexample<'a>>, FuzzerError> {
|
||||||
let mut prng = initial_prng;
|
let mut prng = initial_prng;
|
||||||
let mut counterexample = None;
|
let mut counterexample = None;
|
||||||
|
|
||||||
while *remaining > 0 && counterexample.is_none() {
|
while *remaining > 0 && counterexample.is_none() {
|
||||||
(prng, counterexample) = self.run_once(prng, labels)?;
|
(prng, counterexample) = self.run_once(prng, labels, plutus_version)?;
|
||||||
*remaining -= 1;
|
*remaining -= 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
Ok(counterexample)
|
Ok(counterexample)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn run_once(
|
fn run_once<'a>(
|
||||||
&self,
|
&'a self,
|
||||||
prng: Prng,
|
prng: Prng,
|
||||||
labels: &mut BTreeMap<String, usize>,
|
labels: &mut BTreeMap<String, usize>,
|
||||||
) -> Result<(Prng, Option<Counterexample<'_>>), FuzzerError> {
|
plutus_version: &'a PlutusVersion,
|
||||||
|
) -> Result<(Prng, Option<Counterexample<'a>>), FuzzerError> {
|
||||||
let (next_prng, value) = prng
|
let (next_prng, value) = prng
|
||||||
.sample(&self.fuzzer.program)?
|
.sample(&self.fuzzer.program)?
|
||||||
.expect("A seeded PRNG returned 'None' which indicates a fuzzer is ill-formed and implemented wrongly; please contact library's authors.");
|
.expect("A seeded PRNG returned 'None' which indicates a fuzzer is ill-formed and implemented wrongly; please contact library's authors.");
|
||||||
|
|
||||||
let mut result = self.eval(&value);
|
let mut result = self.eval(&value, plutus_version);
|
||||||
|
|
||||||
for s in result.logs() {
|
for s in result.logs() {
|
||||||
// NOTE: There may be other log outputs that interefere with labels. So *by
|
// NOTE: There may be other log outputs that interefere with labels. So *by
|
||||||
|
@ -313,7 +325,7 @@ impl PropertyTest {
|
||||||
Err(..) => Status::Invalid,
|
Err(..) => Status::Invalid,
|
||||||
Ok(None) => Status::Invalid,
|
Ok(None) => Status::Invalid,
|
||||||
Ok(Some((_, value))) => {
|
Ok(Some((_, value))) => {
|
||||||
let result = self.eval(&value);
|
let result = self.eval(&value, plutus_version);
|
||||||
|
|
||||||
let is_failure = result.failed(self.can_error);
|
let is_failure = result.failed(self.can_error);
|
||||||
|
|
||||||
|
@ -341,12 +353,12 @@ impl PropertyTest {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn eval(&self, value: &PlutusData) -> EvalResult {
|
pub fn eval(&self, value: &PlutusData, plutus_version: &PlutusVersion) -> EvalResult {
|
||||||
let program = self.program.apply_data(value.clone());
|
let program = self.program.apply_data(value.clone());
|
||||||
|
|
||||||
Program::<NamedDeBruijn>::try_from(program)
|
Program::<NamedDeBruijn>::try_from(program)
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.eval(ExBudget::max())
|
.eval_version(ExBudget::max(), &plutus_version.into())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn extract_label(s: &str) -> Option<String> {
|
fn extract_label(s: &str) -> Option<String> {
|
||||||
|
@ -1255,8 +1267,8 @@ mod test {
|
||||||
builtins,
|
builtins,
|
||||||
format::Formatter,
|
format::Formatter,
|
||||||
line_numbers::LineNumbers,
|
line_numbers::LineNumbers,
|
||||||
parser,
|
parser::{self, extra::ModuleExtra},
|
||||||
parser::extra::ModuleExtra,
|
plutus_version::PlutusVersion,
|
||||||
IdGenerator,
|
IdGenerator,
|
||||||
};
|
};
|
||||||
use indoc::indoc;
|
use indoc::indoc;
|
||||||
|
@ -1323,6 +1335,7 @@ mod test {
|
||||||
);
|
);
|
||||||
|
|
||||||
let mut generator = CodeGenerator::new(
|
let mut generator = CodeGenerator::new(
|
||||||
|
PlutusVersion::default(),
|
||||||
utils::indexmap::as_ref_values(&functions),
|
utils::indexmap::as_ref_values(&functions),
|
||||||
utils::indexmap::as_ref_values(&data_types),
|
utils::indexmap::as_ref_values(&data_types),
|
||||||
utils::indexmap::as_str_ref_values(&module_types),
|
utils::indexmap::as_str_ref_values(&module_types),
|
||||||
|
@ -1454,10 +1467,15 @@ mod test {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl PropertyTest {
|
impl PropertyTest {
|
||||||
fn expect_failure(&self) -> Counterexample {
|
fn expect_failure<'a>(&'a self, plutus_version: &'a PlutusVersion) -> Counterexample<'a> {
|
||||||
let mut labels = BTreeMap::new();
|
let mut labels = BTreeMap::new();
|
||||||
let mut remaining = PropertyTest::DEFAULT_MAX_SUCCESS;
|
let mut remaining = PropertyTest::DEFAULT_MAX_SUCCESS;
|
||||||
match self.run_n_times(&mut remaining, Prng::from_seed(42), &mut labels) {
|
match self.run_n_times(
|
||||||
|
&mut remaining,
|
||||||
|
Prng::from_seed(42),
|
||||||
|
&mut labels,
|
||||||
|
plutus_version,
|
||||||
|
) {
|
||||||
Ok(Some(counterexample)) => counterexample,
|
Ok(Some(counterexample)) => counterexample,
|
||||||
_ => panic!("expected property to fail but it didn't."),
|
_ => panic!("expected property to fail but it didn't."),
|
||||||
}
|
}
|
||||||
|
@ -1473,7 +1491,11 @@ mod test {
|
||||||
"#});
|
"#});
|
||||||
|
|
||||||
assert!(prop
|
assert!(prop
|
||||||
.run::<()>(42, PropertyTest::DEFAULT_MAX_SUCCESS)
|
.run::<()>(
|
||||||
|
42,
|
||||||
|
PropertyTest::DEFAULT_MAX_SUCCESS,
|
||||||
|
&PlutusVersion::default()
|
||||||
|
)
|
||||||
.is_success());
|
.is_success());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1496,7 +1518,11 @@ mod test {
|
||||||
}
|
}
|
||||||
"#});
|
"#});
|
||||||
|
|
||||||
match prop.run::<()>(42, PropertyTest::DEFAULT_MAX_SUCCESS) {
|
match prop.run::<()>(
|
||||||
|
42,
|
||||||
|
PropertyTest::DEFAULT_MAX_SUCCESS,
|
||||||
|
&PlutusVersion::default(),
|
||||||
|
) {
|
||||||
TestResult::UnitTestResult(..) => unreachable!("property returned unit-test result ?!"),
|
TestResult::UnitTestResult(..) => unreachable!("property returned unit-test result ?!"),
|
||||||
TestResult::PropertyTestResult(result) => {
|
TestResult::PropertyTestResult(result) => {
|
||||||
assert!(
|
assert!(
|
||||||
|
@ -1519,7 +1545,8 @@ mod test {
|
||||||
}
|
}
|
||||||
"#});
|
"#});
|
||||||
|
|
||||||
let mut counterexample = prop.expect_failure();
|
let plutus_version = PlutusVersion::default();
|
||||||
|
let mut counterexample = prop.expect_failure(&plutus_version);
|
||||||
|
|
||||||
counterexample.simplify();
|
counterexample.simplify();
|
||||||
|
|
||||||
|
@ -1546,7 +1573,8 @@ mod test {
|
||||||
}
|
}
|
||||||
"#});
|
"#});
|
||||||
|
|
||||||
let mut counterexample = prop.expect_failure();
|
let plutus_version = PlutusVersion::default();
|
||||||
|
let mut counterexample = prop.expect_failure(&plutus_version);
|
||||||
|
|
||||||
counterexample.simplify();
|
counterexample.simplify();
|
||||||
|
|
||||||
|
@ -1562,7 +1590,8 @@ mod test {
|
||||||
}
|
}
|
||||||
"#});
|
"#});
|
||||||
|
|
||||||
let mut counterexample = prop.expect_failure();
|
let plutus_version = PlutusVersion::default();
|
||||||
|
let mut counterexample = prop.expect_failure(&plutus_version);
|
||||||
|
|
||||||
counterexample.simplify();
|
counterexample.simplify();
|
||||||
|
|
||||||
|
@ -1589,7 +1618,8 @@ mod test {
|
||||||
}
|
}
|
||||||
"#});
|
"#});
|
||||||
|
|
||||||
let mut counterexample = prop.expect_failure();
|
let plutus_version = PlutusVersion::default();
|
||||||
|
let mut counterexample = prop.expect_failure(&plutus_version);
|
||||||
|
|
||||||
counterexample.simplify();
|
counterexample.simplify();
|
||||||
|
|
||||||
|
@ -1616,7 +1646,8 @@ mod test {
|
||||||
}
|
}
|
||||||
"#});
|
"#});
|
||||||
|
|
||||||
let mut counterexample = prop.expect_failure();
|
let plutus_version = PlutusVersion::default();
|
||||||
|
let mut counterexample = prop.expect_failure(&plutus_version);
|
||||||
|
|
||||||
counterexample.simplify();
|
counterexample.simplify();
|
||||||
|
|
||||||
|
@ -1646,7 +1677,8 @@ mod test {
|
||||||
}
|
}
|
||||||
"#});
|
"#});
|
||||||
|
|
||||||
let mut counterexample = prop.expect_failure();
|
let plutus_version = PlutusVersion::default();
|
||||||
|
let mut counterexample = prop.expect_failure(&plutus_version);
|
||||||
|
|
||||||
counterexample.simplify();
|
counterexample.simplify();
|
||||||
|
|
||||||
|
@ -1680,7 +1712,9 @@ mod test {
|
||||||
}
|
}
|
||||||
"#});
|
"#});
|
||||||
|
|
||||||
let mut counterexample = prop.expect_failure();
|
let plutus_version = PlutusVersion::default();
|
||||||
|
|
||||||
|
let mut counterexample = prop.expect_failure(&plutus_version);
|
||||||
|
|
||||||
counterexample.simplify();
|
counterexample.simplify();
|
||||||
|
|
||||||
|
@ -1714,7 +1748,8 @@ mod test {
|
||||||
}
|
}
|
||||||
"#});
|
"#});
|
||||||
|
|
||||||
let mut counterexample = prop.expect_failure();
|
let plutus_version = PlutusVersion::default();
|
||||||
|
let mut counterexample = prop.expect_failure(&plutus_version);
|
||||||
|
|
||||||
counterexample.simplify();
|
counterexample.simplify();
|
||||||
|
|
||||||
|
@ -1748,7 +1783,8 @@ mod test {
|
||||||
}
|
}
|
||||||
"#});
|
"#});
|
||||||
|
|
||||||
let mut counterexample = prop.expect_failure();
|
let plutus_version = PlutusVersion::default();
|
||||||
|
let mut counterexample = prop.expect_failure(&plutus_version);
|
||||||
|
|
||||||
counterexample.simplify();
|
counterexample.simplify();
|
||||||
|
|
||||||
|
|
|
@ -12,6 +12,7 @@ use aiken_lang::{
|
||||||
gen_uplc::CodeGenerator,
|
gen_uplc::CodeGenerator,
|
||||||
line_numbers::LineNumbers,
|
line_numbers::LineNumbers,
|
||||||
parser,
|
parser,
|
||||||
|
plutus_version::PlutusVersion,
|
||||||
tipo::TypeInfo,
|
tipo::TypeInfo,
|
||||||
IdGenerator,
|
IdGenerator,
|
||||||
};
|
};
|
||||||
|
@ -60,6 +61,7 @@ impl TestProject {
|
||||||
|
|
||||||
pub fn new_generator(&'_ self, tracing: Tracing) -> CodeGenerator<'_> {
|
pub fn new_generator(&'_ self, tracing: Tracing) -> CodeGenerator<'_> {
|
||||||
CodeGenerator::new(
|
CodeGenerator::new(
|
||||||
|
PlutusVersion::default(),
|
||||||
utils::indexmap::as_ref_values(&self.functions),
|
utils::indexmap::as_ref_values(&self.functions),
|
||||||
utils::indexmap::as_ref_values(&self.data_types),
|
utils::indexmap::as_ref_values(&self.data_types),
|
||||||
utils::indexmap::as_str_ref_values(&self.module_types),
|
utils::indexmap::as_str_ref_values(&self.module_types),
|
||||||
|
|
|
@ -5,6 +5,7 @@ use std::{env, fs::File, io::BufReader, path::PathBuf, process};
|
||||||
|
|
||||||
use aiken_project::{
|
use aiken_project::{
|
||||||
blueprint::{error::Error as BlueprintError, Blueprint},
|
blueprint::{error::Error as BlueprintError, Blueprint},
|
||||||
|
config::Config,
|
||||||
error::Error as ProjectError,
|
error::Error as ProjectError,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -15,7 +15,7 @@ use pallas::ledger::{
|
||||||
addresses::{Network, ShelleyAddress, ShelleyDelegationPart, ShelleyPaymentPart},
|
addresses::{Network, ShelleyAddress, ShelleyDelegationPart, ShelleyPaymentPart},
|
||||||
primitives::{
|
primitives::{
|
||||||
alonzo::{self, Constr, PlutusData},
|
alonzo::{self, Constr, PlutusData},
|
||||||
babbage::{self, Language},
|
conway::{self, Language},
|
||||||
},
|
},
|
||||||
traverse::ComputeHash,
|
traverse::ComputeHash,
|
||||||
};
|
};
|
||||||
|
@ -118,7 +118,7 @@ impl Serialize for Program<DeBruijn> {
|
||||||
let cbor = self.to_cbor().unwrap();
|
let cbor = self.to_cbor().unwrap();
|
||||||
let mut s = serializer.serialize_struct("Program<DeBruijn>", 2)?;
|
let mut s = serializer.serialize_struct("Program<DeBruijn>", 2)?;
|
||||||
s.serialize_field("compiledCode", &hex::encode(&cbor))?;
|
s.serialize_field("compiledCode", &hex::encode(&cbor))?;
|
||||||
s.serialize_field("hash", &babbage::PlutusV2Script(cbor.into()).compute_hash())?;
|
s.serialize_field("hash", &conway::PlutusV2Script(cbor.into()).compute_hash())?;
|
||||||
s.end()
|
s.end()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -749,14 +749,9 @@ impl Program<NamedDeBruijn> {
|
||||||
EvalResult::new(term, machine.ex_budget, initial_budget, machine.logs)
|
EvalResult::new(term, machine.ex_budget, initial_budget, machine.logs)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Evaluate a Program as PlutusV1
|
/// Evaluate a Program as a specific PlutusVersion
|
||||||
pub fn eval_version(self, version: &Language) -> EvalResult {
|
pub fn eval_version(self, initial_budget: ExBudget, version: &Language) -> EvalResult {
|
||||||
let mut machine = Machine::new(
|
let mut machine = Machine::new(version.clone(), CostModel::default(), initial_budget, 200);
|
||||||
version.clone(),
|
|
||||||
CostModel::default(),
|
|
||||||
ExBudget::default(),
|
|
||||||
200,
|
|
||||||
);
|
|
||||||
|
|
||||||
let term = machine.run(self.term);
|
let term = machine.run(self.term);
|
||||||
|
|
||||||
|
|
|
@ -11,7 +11,7 @@ pub mod value;
|
||||||
|
|
||||||
use cost_model::{ExBudget, StepKind};
|
use cost_model::{ExBudget, StepKind};
|
||||||
pub use error::Error;
|
pub use error::Error;
|
||||||
use pallas::ledger::primitives::babbage::Language;
|
use pallas::ledger::primitives::conway::Language;
|
||||||
|
|
||||||
use self::{
|
use self::{
|
||||||
cost_model::CostModel,
|
cost_model::CostModel,
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
|
|
||||||
use pallas::ledger::primitives::babbage::Language;
|
use pallas::ledger::primitives::conway::Language;
|
||||||
|
|
||||||
use crate::builtins::DefaultFunction;
|
use crate::builtins::DefaultFunction;
|
||||||
|
|
||||||
|
@ -2188,7 +2188,187 @@ pub fn initialize_cost_model(version: &Language, costs: &[i64]) -> CostModel {
|
||||||
"verify_schnorr_secp256k1_signature-mem-arguments"=> costs[174]
|
"verify_schnorr_secp256k1_signature-mem-arguments"=> costs[174]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Language::PlutusV3 => {
|
||||||
|
hashmap! {
|
||||||
|
"add_integer-cpu-arguments-intercept"=> costs[0],
|
||||||
|
"add_integer-cpu-arguments-slope"=> costs[1],
|
||||||
|
"add_integer-mem-arguments-intercept"=> costs[2],
|
||||||
|
"add_integer-mem-arguments-slope"=> costs[3],
|
||||||
|
"append_byte_string-cpu-arguments-intercept"=> costs[4],
|
||||||
|
"append_byte_string-cpu-arguments-slope"=> costs[5],
|
||||||
|
"append_byte_string-mem-arguments-intercept"=> costs[6],
|
||||||
|
"append_byte_string-mem-arguments-slope"=> costs[7],
|
||||||
|
"append_string-cpu-arguments-intercept"=> costs[8],
|
||||||
|
"append_string-cpu-arguments-slope"=> costs[9],
|
||||||
|
"append_string-mem-arguments-intercept"=> costs[10],
|
||||||
|
"append_string-mem-arguments-slope"=> costs[11],
|
||||||
|
"b_data-cpu-arguments"=> costs[12],
|
||||||
|
"b_data-mem-arguments"=> costs[13],
|
||||||
|
"blake2b_256-cpu-arguments-intercept"=> costs[14],
|
||||||
|
"blake2b_256-cpu-arguments-slope"=> costs[15],
|
||||||
|
"blake2b_256-mem-arguments"=> costs[16],
|
||||||
|
"cek_apply_cost-exBudgetCPU"=> costs[17],
|
||||||
|
"cek_apply_cost-exBudgetmem"=> costs[18],
|
||||||
|
"cek_builtin_cost-exBudgetCPU"=> costs[19],
|
||||||
|
"cek_builtin_cost-exBudgetmem"=> costs[20],
|
||||||
|
"cek_const_cost-exBudgetCPU"=> costs[21],
|
||||||
|
"cek_const_cost-exBudgetmem"=> costs[22],
|
||||||
|
"cek_delay_cost-exBudgetCPU"=> costs[23],
|
||||||
|
"cek_delay_cost-exBudgetmem"=> costs[24],
|
||||||
|
"cek_force_cost-exBudgetCPU"=> costs[25],
|
||||||
|
"cek_force_cost-exBudgetmem"=> costs[26],
|
||||||
|
"cek_lam_cost-exBudgetCPU"=> costs[27],
|
||||||
|
"cek_lam_cost-exBudgetmem"=> costs[28],
|
||||||
|
"cek_startup_cost-exBudgetCPU"=> costs[29],
|
||||||
|
"cek_startup_cost-exBudgetmem"=> costs[30],
|
||||||
|
"cek_var_cost-exBudgetCPU"=> costs[31],
|
||||||
|
"cek_var_cost-exBudgetmem"=> costs[32],
|
||||||
|
"choose_data-cpu-arguments"=> costs[33],
|
||||||
|
"choose_data-mem-arguments"=> costs[34],
|
||||||
|
"choose_list-cpu-arguments"=> costs[35],
|
||||||
|
"choose_list-mem-arguments"=> costs[36],
|
||||||
|
"choose_unit-cpu-arguments"=> costs[37],
|
||||||
|
"choose_unit-mem-arguments"=> costs[38],
|
||||||
|
"cons_byte_string-cpu-arguments-intercept"=> costs[39],
|
||||||
|
"cons_byte_string-cpu-arguments-slope"=> costs[40],
|
||||||
|
"cons_byte_string-mem-arguments-intercept"=> costs[41],
|
||||||
|
"cons_byte_string-mem-arguments-slope"=> costs[42],
|
||||||
|
"constr_data-cpu-arguments"=> costs[43],
|
||||||
|
"constr_data-mem-arguments"=> costs[44],
|
||||||
|
"decode_utf8-cpu-arguments-intercept"=> costs[45],
|
||||||
|
"decode_utf8-cpu-arguments-slope"=> costs[46],
|
||||||
|
"decode_utf8-mem-arguments-intercept"=> costs[47],
|
||||||
|
"decode_utf8-mem-arguments-slope"=> costs[48],
|
||||||
|
"divide_integer-cpu-arguments-constant"=> costs[49],
|
||||||
|
"divide_integer-cpu-arguments-model-arguments-intercept"=> costs[50],
|
||||||
|
"divide_integer-cpu-arguments-model-arguments-slope"=> costs[51],
|
||||||
|
"divide_integer-mem-arguments-intercept"=> costs[52],
|
||||||
|
"divide_integer-mem-arguments-minimum"=> costs[53],
|
||||||
|
"divide_integer-mem-arguments-slope"=> costs[54],
|
||||||
|
"encode_utf8-cpu-arguments-intercept"=> costs[55],
|
||||||
|
"encode_utf8-cpu-arguments-slope"=> costs[56],
|
||||||
|
"encode_utf8-mem-arguments-intercept"=> costs[57],
|
||||||
|
"encode_utf8-mem-arguments-slope"=> costs[58],
|
||||||
|
"equals_byte_string-cpu-arguments-constant"=> costs[59],
|
||||||
|
"equals_byte_string-cpu-arguments-intercept"=> costs[60],
|
||||||
|
"equals_byte_string-cpu-arguments-slope"=> costs[61],
|
||||||
|
"equals_byte_string-mem-arguments"=> costs[62],
|
||||||
|
"equals_data-cpu-arguments-intercept"=> costs[63],
|
||||||
|
"equals_data-cpu-arguments-slope"=> costs[64],
|
||||||
|
"equals_data-mem-arguments"=> costs[65],
|
||||||
|
"equals_integer-cpu-arguments-intercept"=> costs[66],
|
||||||
|
"equals_integer-cpu-arguments-slope"=> costs[67],
|
||||||
|
"equals_integer-mem-arguments"=> costs[68],
|
||||||
|
"equals_string-cpu-arguments-constant"=> costs[69],
|
||||||
|
"equals_string-cpu-arguments-intercept"=> costs[70],
|
||||||
|
"equals_string-cpu-arguments-slope"=> costs[71],
|
||||||
|
"equals_string-mem-arguments"=> costs[72],
|
||||||
|
"fst_pair-cpu-arguments"=> costs[73],
|
||||||
|
"fst_pair-mem-arguments"=> costs[74],
|
||||||
|
"head_list-cpu-arguments"=> costs[75],
|
||||||
|
"head_list-mem-arguments"=> costs[76],
|
||||||
|
"i_data-cpu-arguments"=> costs[77],
|
||||||
|
"i_data-mem-arguments"=> costs[78],
|
||||||
|
"if_then_else-cpu-arguments"=> costs[79],
|
||||||
|
"if_then_else-mem-arguments"=> costs[80],
|
||||||
|
"index_byte_string-cpu-arguments"=> costs[81],
|
||||||
|
"index_byte_string-mem-arguments"=> costs[82],
|
||||||
|
"length_of_byte_string-cpu-arguments"=> costs[83],
|
||||||
|
"length_of_byte_string-mem-arguments"=> costs[84],
|
||||||
|
"less_than_byte_string-cpu-arguments-intercept"=> costs[85],
|
||||||
|
"less_than_byte_string-cpu-arguments-slope"=> costs[86],
|
||||||
|
"less_than_byte_string-mem-arguments"=> costs[87],
|
||||||
|
"less_than_equals_byte_string-cpu-arguments-intercept"=> costs[88],
|
||||||
|
"less_than_equals_byte_string-cpu-arguments-slope"=> costs[89],
|
||||||
|
"less_than_equals_byte_string-mem-arguments"=> costs[90],
|
||||||
|
"less_than_equals_integer-cpu-arguments-intercept"=> costs[91],
|
||||||
|
"less_than_equals_integer-cpu-arguments-slope"=> costs[92],
|
||||||
|
"less_than_equals_integer-mem-arguments"=> costs[93],
|
||||||
|
"less_than_integer-cpu-arguments-intercept"=> costs[94],
|
||||||
|
"less_than_integer-cpu-arguments-slope"=> costs[95],
|
||||||
|
"less_than_integer-mem-arguments"=> costs[96],
|
||||||
|
"list_data-cpu-arguments"=> costs[97],
|
||||||
|
"list_data-mem-arguments"=> costs[98],
|
||||||
|
"map_data-cpu-arguments"=> costs[99],
|
||||||
|
"map_data-mem-arguments"=> costs[100],
|
||||||
|
"mk_cons-cpu-arguments"=> costs[101],
|
||||||
|
"mk_cons-mem-arguments"=> costs[102],
|
||||||
|
"mk_nil_data-cpu-arguments"=> costs[103],
|
||||||
|
"mk_nil_data-mem-arguments"=> costs[104],
|
||||||
|
"mk_nil_pair_data-cpu-arguments"=> costs[105],
|
||||||
|
"mk_nil_pair_data-mem-arguments"=> costs[106],
|
||||||
|
"mk_pair_data-cpu-arguments"=> costs[107],
|
||||||
|
"mk_pair_data-mem-arguments"=> costs[108],
|
||||||
|
"mod_integer-cpu-arguments-constant"=> costs[109],
|
||||||
|
"mod_integer-cpu-arguments-model-arguments-intercept"=> costs[110],
|
||||||
|
"mod_integer-cpu-arguments-model-arguments-slope"=> costs[111],
|
||||||
|
"mod_integer-mem-arguments-intercept"=> costs[112],
|
||||||
|
"mod_integer-mem-arguments-minimum"=> costs[113],
|
||||||
|
"mod_integer-mem-arguments-slope"=> costs[114],
|
||||||
|
"multiply_integer-cpu-arguments-intercept"=> costs[115],
|
||||||
|
"multiply_integer-cpu-arguments-slope"=> costs[116],
|
||||||
|
"multiply_integer-mem-arguments-intercept"=> costs[117],
|
||||||
|
"multiply_integer-mem-arguments-slope"=> costs[118],
|
||||||
|
"null_list-cpu-arguments"=> costs[119],
|
||||||
|
"null_list-mem-arguments"=> costs[120],
|
||||||
|
"quotient_integer-cpu-arguments-constant"=> costs[121],
|
||||||
|
"quotient_integer-cpu-arguments-model-arguments-intercept"=> costs[122],
|
||||||
|
"quotient_integer-cpu-arguments-model-arguments-slope"=> costs[123],
|
||||||
|
"quotient_integer-mem-arguments-intercept"=> costs[124],
|
||||||
|
"quotient_integer-mem-arguments-minimum"=> costs[125],
|
||||||
|
"quotient_integer-mem-arguments-slope"=> costs[126],
|
||||||
|
"remainder_integer-cpu-arguments-constant"=> costs[127],
|
||||||
|
"remainder_integer-cpu-arguments-model-arguments-intercept"=> costs[128],
|
||||||
|
"remainder_integer-cpu-arguments-model-arguments-slope"=> costs[129],
|
||||||
|
"remainder_integer-mem-arguments-intercept"=> costs[130],
|
||||||
|
"remainder_integer-mem-arguments-minimum"=> costs[131],
|
||||||
|
"remainder_integer-mem-arguments-slope"=> costs[132],
|
||||||
|
"serialise_data-cpu-arguments-intercept"=> costs[133],
|
||||||
|
"serialise_data-cpu-arguments-slope"=> costs[134],
|
||||||
|
"serialise_data-mem-arguments-intercept"=> costs[135],
|
||||||
|
"serialise_data-mem-arguments-slope"=> costs[136],
|
||||||
|
"sha2_256-cpu-arguments-intercept"=> costs[137],
|
||||||
|
"sha2_256-cpu-arguments-slope"=> costs[138],
|
||||||
|
"sha2_256-mem-arguments"=> costs[139],
|
||||||
|
"sha3_256-cpu-arguments-intercept"=> costs[140],
|
||||||
|
"sha3_256-cpu-arguments-slope"=> costs[141],
|
||||||
|
"sha3_256-mem-arguments"=> costs[142],
|
||||||
|
"slice_byte_string-cpu-arguments-intercept"=> costs[143],
|
||||||
|
"slice_byte_string-cpu-arguments-slope"=> costs[144],
|
||||||
|
"slice_byte_string-mem-arguments-intercept"=> costs[145],
|
||||||
|
"slice_byte_string-mem-arguments-slope"=> costs[146],
|
||||||
|
"snd_pair-cpu-arguments"=> costs[147],
|
||||||
|
"snd_pair-mem-arguments"=> costs[148],
|
||||||
|
"subtract_integer-cpu-arguments-intercept"=> costs[149],
|
||||||
|
"subtract_integer-cpu-arguments-slope"=> costs[150],
|
||||||
|
"subtract_integer-mem-arguments-intercept"=> costs[151],
|
||||||
|
"subtract_integer-mem-arguments-slope"=> costs[152],
|
||||||
|
"tail_list-cpu-arguments"=> costs[153],
|
||||||
|
"tail_list-mem-arguments"=> costs[154],
|
||||||
|
"trace-cpu-arguments"=> costs[155],
|
||||||
|
"trace-mem-arguments"=> costs[156],
|
||||||
|
"un_b_data-cpu-arguments"=> costs[157],
|
||||||
|
"un_b_data-mem-arguments"=> costs[158],
|
||||||
|
"un_constr_data-cpu-arguments"=> costs[159],
|
||||||
|
"un_constr_data-mem-arguments"=> costs[160],
|
||||||
|
"un_i_data-cpu-arguments"=> costs[161],
|
||||||
|
"un_i_data-mem-arguments"=> costs[162],
|
||||||
|
"un_list_data-cpu-arguments"=> costs[163],
|
||||||
|
"un_list_data-mem-arguments"=> costs[164],
|
||||||
|
"un_map_data-cpu-arguments"=> costs[165],
|
||||||
|
"un_map_data-mem-arguments"=> costs[166],
|
||||||
|
"verify_ecdsa_secp256k1_signature-cpu-arguments"=> costs[167],
|
||||||
|
"verify_ecdsa_secp256k1_signature-mem-arguments"=> costs[168],
|
||||||
|
"verify_ed25519_signature-cpu-arguments-intercept"=> costs[169],
|
||||||
|
"verify_ed25519_signature-cpu-arguments-slope"=> costs[170],
|
||||||
|
"verify_ed25519_signature-mem-arguments"=> costs[171],
|
||||||
|
"verify_schnorr_secp256k1_signature-cpu-arguments-intercept"=> costs[172],
|
||||||
|
"verify_schnorr_secp256k1_signature-cpu-arguments-slope"=> costs[173],
|
||||||
|
"verify_schnorr_secp256k1_signature-mem-arguments"=> costs[174]
|
||||||
|
}
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
CostModel {
|
CostModel {
|
||||||
machine_costs: MachineCosts {
|
machine_costs: MachineCosts {
|
||||||
startup: ExBudget {
|
startup: ExBudget {
|
||||||
|
|
|
@ -4,7 +4,7 @@ use num_bigint::BigInt;
|
||||||
use num_integer::Integer;
|
use num_integer::Integer;
|
||||||
use num_traits::{Signed, Zero};
|
use num_traits::{Signed, Zero};
|
||||||
use once_cell::sync::Lazy;
|
use once_cell::sync::Lazy;
|
||||||
use pallas::ledger::primitives::babbage::{Language, PlutusData};
|
use pallas::ledger::primitives::conway::{Language, PlutusData};
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
ast::{Constant, Data, Type},
|
ast::{Constant, Data, Type},
|
||||||
|
|
|
@ -9,15 +9,17 @@ use pallas::{
|
||||||
ledger::{
|
ledger::{
|
||||||
addresses::{Address, ScriptHash, StakePayload},
|
addresses::{Address, ScriptHash, StakePayload},
|
||||||
primitives::babbage::{
|
primitives::babbage::{
|
||||||
Certificate, CostMdls, DatumHash, DatumOption, ExUnits, Language, Mint, MintedTx,
|
Certificate, CostMdls, DatumHash, DatumOption, ExUnits, Mint, MintedTx, NativeScript,
|
||||||
NativeScript, PlutusV1Script, PlutusV2Script, PolicyId, PseudoScript, Redeemer,
|
PlutusV1Script, PlutusV2Script, PolicyId, PseudoScript, Redeemer, RedeemerTag,
|
||||||
RedeemerTag, RewardAccount, StakeCredential, TransactionInput, TransactionOutput,
|
RewardAccount, StakeCredential, TransactionInput, TransactionOutput, Value,
|
||||||
Value, Withdrawals,
|
Withdrawals,
|
||||||
},
|
},
|
||||||
traverse::{ComputeHash, OriginalHash},
|
traverse::{ComputeHash, OriginalHash},
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
use pallas::ledger::primitives::conway::Language;
|
||||||
|
|
||||||
use std::{cmp::Ordering, collections::HashMap, convert::TryInto, ops::Deref, vec};
|
use std::{cmp::Ordering, collections::HashMap, convert::TryInto, ops::Deref, vec};
|
||||||
|
|
||||||
use super::{
|
use super::{
|
||||||
|
@ -761,7 +763,7 @@ pub fn eval_redeemer(
|
||||||
|
|
||||||
program.eval_as(&Language::PlutusV1, costs, Some(initial_budget))
|
program.eval_as(&Language::PlutusV1, costs, Some(initial_budget))
|
||||||
} else {
|
} else {
|
||||||
program.eval_version(&Language::PlutusV1)
|
program.eval_version(ExBudget::default(), &Language::PlutusV1)
|
||||||
};
|
};
|
||||||
|
|
||||||
let cost = eval_result.cost();
|
let cost = eval_result.cost();
|
||||||
|
@ -861,7 +863,7 @@ pub fn eval_redeemer(
|
||||||
|
|
||||||
program.eval_as(&Language::PlutusV1, costs, Some(initial_budget))
|
program.eval_as(&Language::PlutusV1, costs, Some(initial_budget))
|
||||||
} else {
|
} else {
|
||||||
program.eval_version(&Language::PlutusV1)
|
program.eval_version(ExBudget::default(), &Language::PlutusV1)
|
||||||
};
|
};
|
||||||
|
|
||||||
let cost = eval_result.cost();
|
let cost = eval_result.cost();
|
||||||
|
|
Loading…
Reference in New Issue