diff --git a/console/program/src/data/literal/mod.rs b/console/program/src/data/literal/mod.rs index 5b904165ca..62777da9d8 100644 --- a/console/program/src/data/literal/mod.rs +++ b/console/program/src/data/literal/mod.rs @@ -24,6 +24,7 @@ mod parse; mod sample; mod serialize; mod size_in_bits; +mod size_in_bytes; mod to_bits; mod to_type; mod variant; diff --git a/console/program/src/data/literal/size_in_bytes.rs b/console/program/src/data/literal/size_in_bytes.rs new file mode 100644 index 0000000000..cc3a434ec1 --- /dev/null +++ b/console/program/src/data/literal/size_in_bytes.rs @@ -0,0 +1,26 @@ +// Copyright (C) 2019-2023 Aleo Systems Inc. +// This file is part of the snarkVM library. + +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at: +// http://www.apache.org/licenses/LICENSE-2.0 + +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +use super::*; + +impl Literal { + /// Returns the size in bytes of this literal. + #[allow(clippy::cast_possible_truncation)] + pub fn size_in_bytes(&self) -> u16 { + // Note: This upcast to u32 and downcast to u16 is safe because the size of a literal is + // always less than or equal to u16::MAX bits, and we are dividing by 8, so the result will + // always fit in a u16. + (((self.size_in_bits() as u32) + 7) / 8) as u16 + } +} diff --git a/console/program/src/data_types/literal_type/mod.rs b/console/program/src/data_types/literal_type/mod.rs index cb5e4dae49..d6ddf2f5a0 100644 --- a/console/program/src/data_types/literal_type/mod.rs +++ b/console/program/src/data_types/literal_type/mod.rs @@ -15,8 +15,12 @@ mod bytes; mod parse; mod serialize; +mod size_in_bits; +mod size_in_bytes; +use snarkvm_console_account::Signature; use snarkvm_console_network::prelude::*; +use snarkvm_console_types::{prelude::*, Boolean}; use core::fmt::{self, Debug, Display}; use num_derive::FromPrimitive; diff --git a/console/program/src/data_types/literal_type/size_in_bits.rs b/console/program/src/data_types/literal_type/size_in_bits.rs new file mode 100644 index 0000000000..19db4593a7 --- /dev/null +++ b/console/program/src/data_types/literal_type/size_in_bits.rs @@ -0,0 +1,43 @@ +// Copyright (C) 2019-2023 Aleo Systems Inc. +// This file is part of the snarkVM library. + +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at: +// http://www.apache.org/licenses/LICENSE-2.0 + +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +use super::*; + +impl LiteralType { + /// Returns the number of bits of this literal type. + /// + /// For string literals, this method returns the maximum number of bits that can be stored in the string. + pub fn size_in_bits(&self) -> u16 { + let size = match self { + Self::Address => Address::::size_in_bits(), + Self::Boolean => Boolean::::size_in_bits(), + Self::Field => Field::::size_in_bits(), + Self::Group => Group::::size_in_bits(), + Self::I8 => I8::::size_in_bits(), + Self::I16 => I16::::size_in_bits(), + Self::I32 => I32::::size_in_bits(), + Self::I64 => I64::::size_in_bits(), + Self::I128 => I128::::size_in_bits(), + Self::U8 => U8::::size_in_bits(), + Self::U16 => U16::::size_in_bits(), + Self::U32 => U32::::size_in_bits(), + Self::U64 => U64::::size_in_bits(), + Self::U128 => U128::::size_in_bits(), + Self::Scalar => Scalar::::size_in_bits(), + Self::Signature => Signature::::size_in_bits(), + Self::String => N::MAX_STRING_BYTES.saturating_mul(8) as usize, + }; + u16::try_from(size).or_halt_with::("Literal exceeds u16::MAX bits.") + } +} diff --git a/console/program/src/data_types/literal_type/size_in_bytes.rs b/console/program/src/data_types/literal_type/size_in_bytes.rs new file mode 100644 index 0000000000..2862b0f218 --- /dev/null +++ b/console/program/src/data_types/literal_type/size_in_bytes.rs @@ -0,0 +1,28 @@ +// Copyright (C) 2019-2023 Aleo Systems Inc. +// This file is part of the snarkVM library. + +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at: +// http://www.apache.org/licenses/LICENSE-2.0 + +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +use super::*; + +impl LiteralType { + /// Returns the number of bytes of this literal. + /// + /// For string literals, this method returns the maximum number of bytes that can be stored in the string. + #[allow(clippy::cast_possible_truncation)] + pub fn size_in_bytes(&self) -> u16 { + // Note: This upcast to u32 and downcast to u16 is safe because the size of a literal is + // always less than or equal to u16::MAX bits, and we are dividing by 8, so the result will + // always fit in a u16. + (((self.size_in_bits::() as u32) + 7) / 8) as u16 + } +} diff --git a/parameters/src/testnet3/resources/block.genesis b/parameters/src/testnet3/resources/block.genesis index fa73cde84a..c0b70008f2 100644 Binary files a/parameters/src/testnet3/resources/block.genesis and b/parameters/src/testnet3/resources/block.genesis differ diff --git a/synthesizer/program/src/lib.rs b/synthesizer/program/src/lib.rs index 6e32c776f8..556d9ed922 100644 --- a/synthesizer/program/src/lib.rs +++ b/synthesizer/program/src/lib.rs @@ -271,7 +271,7 @@ impl, Command: CommandTrait> Pro /// Returns a reference to the function with the given name. pub fn get_function_ref(&self, name: &Identifier) -> Result<&FunctionCore> { // Attempt to retrieve the function. - let function = self.functions.get(name).ok_or_else(|| anyhow!("Function '{name}' is not defined."))?; + let function = self.functions.get(name).ok_or(anyhow!("Function '{}/{name}' is not defined.", self.id))?; // Ensure the function name matches. ensure!(function.name() == name, "Expected function '{name}', but found function '{}'", function.name()); // Ensure the number of inputs is within the allowed range. diff --git a/synthesizer/src/vm/helpers/cost.rs b/synthesizer/src/vm/helpers/cost.rs index 6f349baa84..e3a962b03a 100644 --- a/synthesizer/src/vm/helpers/cost.rs +++ b/synthesizer/src/vm/helpers/cost.rs @@ -12,16 +12,17 @@ // See the License for the specific language governing permissions and // limitations under the License. -use crate::VM; +use crate::{ + prelude::{Stack, StackProgramTypes}, + VM, +}; use console::{ prelude::*, - program::{LiteralType, PlaintextType}, + program::{FinalizeType, Identifier, LiteralType, PlaintextType}, }; use ledger_block::{Deployment, Execution}; use ledger_store::ConsensusStorage; -use synthesizer_program::{Command, Finalize, Instruction}; - -use std::collections::HashMap; +use synthesizer_program::{CastType, Command, Finalize, Instruction, Operand, StackProgram}; /// Returns the *minimum* cost in microcredits to publish the given deployment (total cost, (storage cost, namespace cost)). pub fn deployment_cost(deployment: &Deployment) -> Result<(u64, (u64, u64))> { @@ -59,34 +60,20 @@ pub fn execution_cost>( // Compute the storage cost in microcredits. let storage_cost = execution.size_in_bytes()?; - // Prepare the program lookup. - let lookup = execution - .transitions() - .map(|transition| { - let program_id = transition.program_id(); - Ok((*program_id, vm.process().read().get_program(program_id)?.clone())) - }) - .collect::>>()?; - // Compute the finalize cost in microcredits. let mut finalize_cost = 0u64; // Iterate over the transitions to accumulate the finalize cost. for transition in execution.transitions() { - // Retrieve the program ID. - let program_id = transition.program_id(); - // Retrieve the function name. - let function_name = transition.function_name(); - // Retrieve the program. - let program = lookup.get(program_id).ok_or(anyhow!("Program '{program_id}' is missing"))?; + // Retrieve the program ID and function name. + let (program_id, function_name) = (transition.program_id(), transition.function_name()); // Retrieve the finalize cost. - let cost = match program.get_function(function_name)?.finalize_logic() { - Some(finalize) => cost_in_microcredits(finalize)?, - None => continue, - }; + let cost = cost_in_microcredits(vm.process().read().get_stack(program_id)?, function_name)?; // Accumulate the finalize cost. - finalize_cost = finalize_cost - .checked_add(cost) - .ok_or(anyhow!("The finalize cost computation overflowed for an execution"))?; + if cost > 0 { + finalize_cost = finalize_cost + .checked_add(cost) + .ok_or(anyhow!("The finalize cost computation overflowed on '{program_id}/{function_name}'"))?; + } } // Compute the total cost in microcredits. @@ -98,107 +85,292 @@ pub fn execution_cost>( } /// Returns the minimum number of microcredits required to run the finalize. -pub fn cost_in_microcredits(finalize: &Finalize) -> Result { - // Defines the cost of each command. +pub fn cost_in_microcredits(stack: &Stack, function_name: &Identifier) -> Result { + /// A helper function to determine the plaintext type in bytes. + fn plaintext_size_in_bytes(stack: &Stack, plaintext_type: &PlaintextType) -> Result { + match plaintext_type { + PlaintextType::Literal(literal_type) => Ok(literal_type.size_in_bytes::() as u64), + PlaintextType::Struct(struct_name) => { + // Retrieve the struct from the stack. + let struct_ = stack.program().get_struct(struct_name)?; + // Retrieve the size of the struct name. + let size_of_name = struct_.name().to_bytes_le()?.len() as u64; + // Retrieve the size of all the members of the struct. + let size_of_members = struct_.members().iter().try_fold(0u64, |acc, (_, member_type)| { + acc.checked_add(plaintext_size_in_bytes(stack, member_type)?).ok_or(anyhow!( + "Overflowed while computing the size of the struct '{}/{struct_name}' - {member_type}", + stack.program_id() + )) + })?; + // Return the size of the struct. + Ok(size_of_name.saturating_add(size_of_members)) + } + PlaintextType::Array(array_type) => { + // Retrieve the number of elements in the array. + let num_elements = **array_type.length() as u64; + // Compute the size of an array element. + let size_of_element = plaintext_size_in_bytes(stack, array_type.next_element_type())?; + // Return the size of the array. + Ok(num_elements.saturating_mul(size_of_element)) + } + } + } + + /// A helper function to compute the following: base_cost + (byte_multiplier * size_of_operands). + fn cost_in_size<'a, N: Network>( + stack: &Stack, + finalize: &Finalize, + operands: impl IntoIterator>, + byte_multiplier: u64, + base_cost: u64, + ) -> Result { + // Retrieve the finalize types. + let finalize_types = stack.get_finalize_types(finalize.name())?; + // Compute the size of the operands. + let size_of_operands = operands.into_iter().try_fold(0u64, |acc, operand| { + // Determine the size of the operand. + let operand_size = match finalize_types.get_type_from_operand(stack, operand)? { + FinalizeType::Plaintext(plaintext_type) => plaintext_size_in_bytes(stack, &plaintext_type)?, + FinalizeType::Future(future) => { + bail!("Future '{future}' is not a valid operand in the finalize scope"); + } + }; + // Safely add the size to the accumulator. + acc.checked_add(operand_size).ok_or(anyhow!( + "Overflowed while computing the size of the operand '{operand}' in '{}/{}' (finalize)", + stack.program_id(), + finalize.name() + )) + })?; + // Return the cost. + Ok(base_cost.saturating_add(byte_multiplier.saturating_mul(size_of_operands))) + } + + // Finalize costs for compute heavy operations, derived as: + // `BASE_COST + (PER_BYTE_COST * SIZE_IN_BYTES)`. + + const CAST_BASE_COST: u64 = 500; + const CAST_PER_BYTE_COST: u64 = 30; + + const HASH_BASE_COST: u64 = 10_000; + const HASH_PER_BYTE_COST: u64 = 30; + + const HASH_BHP_BASE_COST: u64 = 50_000; + const HASH_BHP_PER_BYTE_COST: u64 = 300; + + const HASH_PSD_BASE_COST: u64 = 40_000; + const HASH_PSD_PER_BYTE_COST: u64 = 75; + + const MAPPING_BASE_COST: u64 = 10_000; + const MAPPING_PER_BYTE_COST: u64 = 10; + + const SET_BASE_COST: u64 = 10_000; + const SET_PER_BYTE_COST: u64 = 100; + + // Retrieve the finalize logic. + let Some(finalize) = stack.get_function_ref(function_name)?.finalize_logic() else { + // Return a finalize cost of 0, if the function does not have a finalize scope. + return Ok(0); + }; + + // Measure the cost of each command. let cost = |command: &Command| match command { - Command::Instruction(Instruction::Abs(_)) => Ok(2_000), - Command::Instruction(Instruction::AbsWrapped(_)) => Ok(2_000), - Command::Instruction(Instruction::Add(_)) => Ok(2_000), - Command::Instruction(Instruction::AddWrapped(_)) => Ok(2_000), - Command::Instruction(Instruction::And(_)) => Ok(2_000), - Command::Instruction(Instruction::AssertEq(_)) => Ok(2_000), - Command::Instruction(Instruction::AssertNeq(_)) => Ok(2_000), - Command::Instruction(Instruction::Async(_)) => bail!("`async` is not supported in finalize."), - Command::Instruction(Instruction::Call(_)) => bail!("`call` is not supported in finalize."), - Command::Instruction(Instruction::Cast(_)) => Ok(2_000), - Command::Instruction(Instruction::CastLossy(_)) => Ok(2_000), - Command::Instruction(Instruction::CommitBHP256(_)) => Ok(200_000), - Command::Instruction(Instruction::CommitBHP512(_)) => Ok(200_000), - Command::Instruction(Instruction::CommitBHP768(_)) => Ok(200_000), - Command::Instruction(Instruction::CommitBHP1024(_)) => Ok(200_000), - Command::Instruction(Instruction::CommitPED64(_)) => Ok(100_000), - Command::Instruction(Instruction::CommitPED128(_)) => Ok(100_000), - Command::Instruction(Instruction::Div(_)) => Ok(10_000), - Command::Instruction(Instruction::DivWrapped(_)) => Ok(2_000), - Command::Instruction(Instruction::Double(_)) => Ok(2_000), - Command::Instruction(Instruction::GreaterThan(_)) => Ok(2_000), - Command::Instruction(Instruction::GreaterThanOrEqual(_)) => Ok(2_000), - Command::Instruction(Instruction::HashBHP256(_)) => Ok(100_000), - Command::Instruction(Instruction::HashBHP512(_)) => Ok(100_000), - Command::Instruction(Instruction::HashBHP768(_)) => Ok(100_000), - Command::Instruction(Instruction::HashBHP1024(_)) => Ok(100_000), - Command::Instruction(Instruction::HashKeccak256(_)) => Ok(100_000), - Command::Instruction(Instruction::HashKeccak384(_)) => Ok(100_000), - Command::Instruction(Instruction::HashKeccak512(_)) => Ok(100_000), - Command::Instruction(Instruction::HashPED64(_)) => Ok(20_000), - Command::Instruction(Instruction::HashPED128(_)) => Ok(30_000), - Command::Instruction(Instruction::HashPSD2(hash)) => match hash.destination_type() { - PlaintextType::Literal(LiteralType::Address) | PlaintextType::Literal(LiteralType::Group) => Ok(600_000), - PlaintextType::Literal(..) => Ok(60_000), - plaintext_type => bail!("`hash.psd2` is not supported for plaintext type '{plaintext_type}'"), - }, - Command::Instruction(Instruction::HashPSD4(hash)) => match hash.destination_type() { - PlaintextType::Literal(LiteralType::Address) | PlaintextType::Literal(LiteralType::Group) => Ok(700_000), - PlaintextType::Literal(..) => Ok(100_000), - plaintext_type => bail!("`hash.psd4` is not supported for plaintext type '{plaintext_type}'"), + Command::Instruction(Instruction::Abs(_)) => Ok(500), + Command::Instruction(Instruction::AbsWrapped(_)) => Ok(500), + Command::Instruction(Instruction::Add(_)) => Ok(500), + Command::Instruction(Instruction::AddWrapped(_)) => Ok(500), + Command::Instruction(Instruction::And(_)) => Ok(500), + Command::Instruction(Instruction::AssertEq(_)) => Ok(500), + Command::Instruction(Instruction::AssertNeq(_)) => Ok(500), + Command::Instruction(Instruction::Async(_)) => bail!("'async' is not supported in finalize"), + Command::Instruction(Instruction::Call(_)) => bail!("'call' is not supported in finalize"), + Command::Instruction(Instruction::Cast(cast)) => match cast.cast_type() { + CastType::Plaintext(PlaintextType::Literal(_)) => Ok(500), + CastType::Plaintext(plaintext_type) => Ok(plaintext_size_in_bytes(stack, plaintext_type)? + .saturating_mul(CAST_PER_BYTE_COST) + .saturating_add(CAST_BASE_COST)), + CastType::GroupXCoordinate + | CastType::GroupYCoordinate + | CastType::Record(_) + | CastType::ExternalRecord(_) => Ok(500), }, - Command::Instruction(Instruction::HashPSD8(hash)) => match hash.destination_type() { - PlaintextType::Literal(LiteralType::Address) | PlaintextType::Literal(LiteralType::Group) => Ok(800_000), - PlaintextType::Literal(..) => Ok(200_000), - plaintext_type => bail!("`hash.psd8` is not supported for plaintext type '{plaintext_type}'"), + Command::Instruction(Instruction::CastLossy(cast_lossy)) => match cast_lossy.cast_type() { + CastType::Plaintext(PlaintextType::Literal(_)) => Ok(500), + CastType::Plaintext(plaintext_type) => Ok(plaintext_size_in_bytes(stack, plaintext_type)? + .saturating_mul(CAST_PER_BYTE_COST) + .saturating_add(CAST_BASE_COST)), + CastType::GroupXCoordinate + | CastType::GroupYCoordinate + | CastType::Record(_) + | CastType::ExternalRecord(_) => Ok(500), }, - Command::Instruction(Instruction::HashSha3_256(_)) => Ok(100_000), - Command::Instruction(Instruction::HashSha3_384(_)) => Ok(100_000), - Command::Instruction(Instruction::HashSha3_512(_)) => Ok(100_000), + Command::Instruction(Instruction::CommitBHP256(commit)) => { + cost_in_size(stack, finalize, commit.operands(), HASH_BHP_PER_BYTE_COST, HASH_BHP_BASE_COST) + } + Command::Instruction(Instruction::CommitBHP512(commit)) => { + cost_in_size(stack, finalize, commit.operands(), HASH_BHP_PER_BYTE_COST, HASH_BHP_BASE_COST) + } + Command::Instruction(Instruction::CommitBHP768(commit)) => { + cost_in_size(stack, finalize, commit.operands(), HASH_BHP_PER_BYTE_COST, HASH_BHP_BASE_COST) + } + Command::Instruction(Instruction::CommitBHP1024(commit)) => { + cost_in_size(stack, finalize, commit.operands(), HASH_BHP_PER_BYTE_COST, HASH_BHP_BASE_COST) + } + Command::Instruction(Instruction::CommitPED64(commit)) => { + cost_in_size(stack, finalize, commit.operands(), HASH_PER_BYTE_COST, HASH_BASE_COST) + } + Command::Instruction(Instruction::CommitPED128(commit)) => { + cost_in_size(stack, finalize, commit.operands(), HASH_PER_BYTE_COST, HASH_BASE_COST) + } + Command::Instruction(Instruction::Div(div)) => { + // Ensure `div` has exactly two operands. + ensure!(div.operands().len() == 2, "'div' must contain exactly 2 operands"); + // Retrieve the finalize types. + let finalize_types = stack.get_finalize_types(finalize.name())?; + // Retrieve the price by the operand type. + match finalize_types.get_type_from_operand(stack, &div.operands()[0])? { + FinalizeType::Plaintext(PlaintextType::Literal(LiteralType::Field)) => Ok(1_500), + FinalizeType::Plaintext(PlaintextType::Literal(_)) => Ok(500), + FinalizeType::Plaintext(PlaintextType::Array(_)) => bail!("'div' does not support arrays"), + FinalizeType::Plaintext(PlaintextType::Struct(_)) => bail!("'div' does not support structs"), + FinalizeType::Future(_) => bail!("'div' does not support futures"), + } + } + Command::Instruction(Instruction::DivWrapped(_)) => Ok(500), + Command::Instruction(Instruction::Double(_)) => Ok(500), + Command::Instruction(Instruction::GreaterThan(_)) => Ok(500), + Command::Instruction(Instruction::GreaterThanOrEqual(_)) => Ok(500), + Command::Instruction(Instruction::HashBHP256(hash)) => { + cost_in_size(stack, finalize, hash.operands(), HASH_BHP_PER_BYTE_COST, HASH_BHP_BASE_COST) + } + Command::Instruction(Instruction::HashBHP512(hash)) => { + cost_in_size(stack, finalize, hash.operands(), HASH_BHP_PER_BYTE_COST, HASH_BHP_BASE_COST) + } + Command::Instruction(Instruction::HashBHP768(hash)) => { + cost_in_size(stack, finalize, hash.operands(), HASH_BHP_PER_BYTE_COST, HASH_BHP_BASE_COST) + } + Command::Instruction(Instruction::HashBHP1024(hash)) => { + cost_in_size(stack, finalize, hash.operands(), HASH_BHP_PER_BYTE_COST, HASH_BHP_BASE_COST) + } + Command::Instruction(Instruction::HashKeccak256(hash)) => { + cost_in_size(stack, finalize, hash.operands(), HASH_PER_BYTE_COST, HASH_BASE_COST) + } + Command::Instruction(Instruction::HashKeccak384(hash)) => { + cost_in_size(stack, finalize, hash.operands(), HASH_PER_BYTE_COST, HASH_BASE_COST) + } + Command::Instruction(Instruction::HashKeccak512(hash)) => { + cost_in_size(stack, finalize, hash.operands(), HASH_PER_BYTE_COST, HASH_BASE_COST) + } + Command::Instruction(Instruction::HashPED64(hash)) => { + cost_in_size(stack, finalize, hash.operands(), HASH_PER_BYTE_COST, HASH_BASE_COST) + } + Command::Instruction(Instruction::HashPED128(hash)) => { + cost_in_size(stack, finalize, hash.operands(), HASH_PER_BYTE_COST, HASH_BASE_COST) + } + Command::Instruction(Instruction::HashPSD2(hash)) => { + cost_in_size(stack, finalize, hash.operands(), HASH_PSD_PER_BYTE_COST, HASH_PSD_BASE_COST) + } + Command::Instruction(Instruction::HashPSD4(hash)) => { + cost_in_size(stack, finalize, hash.operands(), HASH_PSD_PER_BYTE_COST, HASH_PSD_BASE_COST) + } + Command::Instruction(Instruction::HashPSD8(hash)) => { + cost_in_size(stack, finalize, hash.operands(), HASH_PSD_PER_BYTE_COST, HASH_PSD_BASE_COST) + } + Command::Instruction(Instruction::HashSha3_256(hash)) => { + cost_in_size(stack, finalize, hash.operands(), HASH_PER_BYTE_COST, HASH_BASE_COST) + } + Command::Instruction(Instruction::HashSha3_384(hash)) => { + cost_in_size(stack, finalize, hash.operands(), HASH_PER_BYTE_COST, HASH_BASE_COST) + } + Command::Instruction(Instruction::HashSha3_512(hash)) => { + cost_in_size(stack, finalize, hash.operands(), HASH_PER_BYTE_COST, HASH_BASE_COST) + } Command::Instruction(Instruction::HashManyPSD2(_)) => { - bail!("`hash_many.psd2` is not supported in finalize.") + bail!("`hash_many.psd2` is not supported in finalize") } Command::Instruction(Instruction::HashManyPSD4(_)) => { - bail!("`hash_many.psd4` is not supported in finalize.") + bail!("`hash_many.psd4` is not supported in finalize") } Command::Instruction(Instruction::HashManyPSD8(_)) => { - bail!("`hash_many.psd8` is not supported in finalize.") - } - Command::Instruction(Instruction::Inv(_)) => Ok(10_000), - Command::Instruction(Instruction::IsEq(_)) => Ok(2_000), - Command::Instruction(Instruction::IsNeq(_)) => Ok(2_000), - Command::Instruction(Instruction::LessThan(_)) => Ok(2_000), - Command::Instruction(Instruction::LessThanOrEqual(_)) => Ok(2_000), - Command::Instruction(Instruction::Modulo(_)) => Ok(2_000), - Command::Instruction(Instruction::Mul(_)) => Ok(150_000), - Command::Instruction(Instruction::MulWrapped(_)) => Ok(2_000), - Command::Instruction(Instruction::Nand(_)) => Ok(2_000), - Command::Instruction(Instruction::Neg(_)) => Ok(2_000), - Command::Instruction(Instruction::Nor(_)) => Ok(2_000), - Command::Instruction(Instruction::Not(_)) => Ok(2_000), - Command::Instruction(Instruction::Or(_)) => Ok(2_000), - Command::Instruction(Instruction::Pow(_)) => Ok(20_000), - Command::Instruction(Instruction::PowWrapped(_)) => Ok(2_000), - Command::Instruction(Instruction::Rem(_)) => Ok(2_000), - Command::Instruction(Instruction::RemWrapped(_)) => Ok(2_000), - Command::Instruction(Instruction::SignVerify(_)) => Ok(250_000), - Command::Instruction(Instruction::Shl(_)) => Ok(2_000), - Command::Instruction(Instruction::ShlWrapped(_)) => Ok(2_000), - Command::Instruction(Instruction::Shr(_)) => Ok(2_000), - Command::Instruction(Instruction::ShrWrapped(_)) => Ok(2_000), - Command::Instruction(Instruction::Square(_)) => Ok(2_000), - Command::Instruction(Instruction::SquareRoot(_)) => Ok(120_000), - Command::Instruction(Instruction::Sub(_)) => Ok(10_000), - Command::Instruction(Instruction::SubWrapped(_)) => Ok(2_000), - Command::Instruction(Instruction::Ternary(_)) => Ok(2_000), - Command::Instruction(Instruction::Xor(_)) => Ok(2_000), - // TODO: The following 'finalize' commands are currently priced higher than expected. - // Expect these numbers to change as their usage is stabilized. - Command::Await(_) => Ok(2_000), - Command::Contains(_) => Ok(12_500), - Command::Get(_) => Ok(25_000), - Command::GetOrUse(_) => Ok(25_000), + bail!("`hash_many.psd8` is not supported in finalize") + } + Command::Instruction(Instruction::Inv(_)) => Ok(2_500), + Command::Instruction(Instruction::IsEq(_)) => Ok(500), + Command::Instruction(Instruction::IsNeq(_)) => Ok(500), + Command::Instruction(Instruction::LessThan(_)) => Ok(500), + Command::Instruction(Instruction::LessThanOrEqual(_)) => Ok(500), + Command::Instruction(Instruction::Modulo(_)) => Ok(500), + Command::Instruction(Instruction::Mul(mul)) => { + // Ensure `mul` has exactly two operands. + ensure!(mul.operands().len() == 2, "'mul' must contain exactly 2 operands"); + // Retrieve the finalize types. + let finalize_types = stack.get_finalize_types(finalize.name())?; + // Retrieve the price by operand type. + match finalize_types.get_type_from_operand(stack, &mul.operands()[0])? { + FinalizeType::Plaintext(PlaintextType::Literal(LiteralType::Group)) => Ok(10_000), + FinalizeType::Plaintext(PlaintextType::Literal(LiteralType::Scalar)) => Ok(10_000), + FinalizeType::Plaintext(PlaintextType::Literal(_)) => Ok(500), + FinalizeType::Plaintext(PlaintextType::Array(_)) => bail!("'mul' does not support arrays"), + FinalizeType::Plaintext(PlaintextType::Struct(_)) => bail!("'mul' does not support structs"), + FinalizeType::Future(_) => bail!("'mul' does not support futures"), + } + } + Command::Instruction(Instruction::MulWrapped(_)) => Ok(500), + Command::Instruction(Instruction::Nand(_)) => Ok(500), + Command::Instruction(Instruction::Neg(_)) => Ok(500), + Command::Instruction(Instruction::Nor(_)) => Ok(500), + Command::Instruction(Instruction::Not(_)) => Ok(500), + Command::Instruction(Instruction::Or(_)) => Ok(500), + Command::Instruction(Instruction::Pow(pow)) => { + // Ensure `pow` has at least one operand. + ensure!(!pow.operands().is_empty(), "'pow' must contain at least 1 operand"); + // Retrieve the finalize types. + let finalize_types = stack.get_finalize_types(finalize.name())?; + // Retrieve the price by operand type. + match finalize_types.get_type_from_operand(stack, &pow.operands()[0])? { + FinalizeType::Plaintext(PlaintextType::Literal(LiteralType::Field)) => Ok(1_500), + FinalizeType::Plaintext(PlaintextType::Literal(_)) => Ok(500), + FinalizeType::Plaintext(PlaintextType::Array(_)) => bail!("'pow' does not support arrays"), + FinalizeType::Plaintext(PlaintextType::Struct(_)) => bail!("'pow' does not support structs"), + FinalizeType::Future(_) => bail!("'pow' does not support futures"), + } + } + Command::Instruction(Instruction::PowWrapped(_)) => Ok(500), + Command::Instruction(Instruction::Rem(_)) => Ok(500), + Command::Instruction(Instruction::RemWrapped(_)) => Ok(500), + Command::Instruction(Instruction::SignVerify(sign)) => { + cost_in_size(stack, finalize, sign.operands(), HASH_PSD_PER_BYTE_COST, HASH_PSD_BASE_COST) + } + Command::Instruction(Instruction::Shl(_)) => Ok(500), + Command::Instruction(Instruction::ShlWrapped(_)) => Ok(500), + Command::Instruction(Instruction::Shr(_)) => Ok(500), + Command::Instruction(Instruction::ShrWrapped(_)) => Ok(500), + Command::Instruction(Instruction::Square(_)) => Ok(500), + Command::Instruction(Instruction::SquareRoot(_)) => Ok(2_500), + Command::Instruction(Instruction::Sub(_)) => Ok(500), + Command::Instruction(Instruction::SubWrapped(_)) => Ok(500), + Command::Instruction(Instruction::Ternary(_)) => Ok(500), + Command::Instruction(Instruction::Xor(_)) => Ok(500), + Command::Await(_) => Ok(500), + Command::Contains(command) => { + cost_in_size(stack, finalize, [command.key()], MAPPING_PER_BYTE_COST, MAPPING_BASE_COST) + } + Command::Get(command) => { + cost_in_size(stack, finalize, [command.key()], MAPPING_PER_BYTE_COST, MAPPING_BASE_COST) + } + Command::GetOrUse(command) => { + cost_in_size(stack, finalize, [command.key()], MAPPING_PER_BYTE_COST, MAPPING_BASE_COST) + } Command::RandChaCha(_) => Ok(25_000), - Command::Remove(_) => Ok(10_000), - Command::Set(_) => Ok(100_000), - Command::BranchEq(_) | Command::BranchNeq(_) => Ok(5_000), - Command::Position(_) => Ok(1_000), + Command::Remove(_) => Ok(MAPPING_BASE_COST), + Command::Set(command) => { + cost_in_size(stack, finalize, [command.key(), command.value()], SET_PER_BYTE_COST, SET_BASE_COST) + } + Command::BranchEq(_) | Command::BranchNeq(_) => Ok(500), + Command::Position(_) => Ok(100), }; + + // Aggregate the cost of all commands in the program. finalize .commands() .iter() diff --git a/synthesizer/tests/expectations/vm/execute_and_finalize/arrays_in_finalize.out b/synthesizer/tests/expectations/vm/execute_and_finalize/arrays_in_finalize.out index 3c8c0a5f79..c824f27366 100644 --- a/synthesizer/tests/expectations/vm/execute_and_finalize/arrays_in_finalize.out +++ b/synthesizer/tests/expectations/vm/execute_and_finalize/arrays_in_finalize.out @@ -15,4 +15,4 @@ additional: - child_outputs: credits.aleo/fee_public: outputs: - - '{"type":"future","id":"4142282429236500615355458184132048110685981096704230785688374794403057659904field","value":"{\n program_id: credits.aleo,\n function_name: fee_public,\n arguments: [\n aleo1y9t0y4lvhm43qdzlfjmfzh8985vfnx9ms368p07x5lsemet5ey8qt0ssjn,\n 21790u64\n ]\n}"}' + - '{"type":"future","id":"4377505400197346320325166594762058980060035444514726670451291598609377642278field","value":"{\n program_id: credits.aleo,\n function_name: fee_public,\n arguments: [\n aleo1y9t0y4lvhm43qdzlfjmfzh8985vfnx9ms368p07x5lsemet5ey8qt0ssjn,\n 7030u64\n ]\n}"}' diff --git a/synthesizer/tests/expectations/vm/execute_and_finalize/complex_finalization.out b/synthesizer/tests/expectations/vm/execute_and_finalize/complex_finalization.out index 3fe0366770..0a3673e69a 100644 --- a/synthesizer/tests/expectations/vm/execute_and_finalize/complex_finalization.out +++ b/synthesizer/tests/expectations/vm/execute_and_finalize/complex_finalization.out @@ -23,4 +23,4 @@ additional: - '{"type":"future","id":"1924141467746445803895332427121150983883397442046587101238781615037989484141field","value":"{\n program_id: three_program.aleo,\n function_name: e,\n arguments: [\n {\n program_id: two_program.aleo,\n function_name: b,\n arguments: [\n {\n program_id: zero_program.aleo,\n function_name: c,\n arguments: [\n aleo1kw4knandael9qcpxs6g36rr6h7dwvjz6q25ueah6zz9v57zjlvxsx5llq8\n ]\n },\n {\n program_id: one_program.aleo,\n function_name: d,\n arguments: [\n aleo1kw4knandael9qcpxs6g36rr6h7dwvjz6q25ueah6zz9v57zjlvxsx5llq8\n ]\n },\n aleo1kw4knandael9qcpxs6g36rr6h7dwvjz6q25ueah6zz9v57zjlvxsx5llq8\n ]\n },\n {\n program_id: one_program.aleo,\n function_name: d,\n arguments: [\n aleo1kw4knandael9qcpxs6g36rr6h7dwvjz6q25ueah6zz9v57zjlvxsx5llq8\n ]\n },\n {\n program_id: zero_program.aleo,\n function_name: c,\n arguments: [\n aleo1kw4knandael9qcpxs6g36rr6h7dwvjz6q25ueah6zz9v57zjlvxsx5llq8\n ]\n },\n aleo1kw4knandael9qcpxs6g36rr6h7dwvjz6q25ueah6zz9v57zjlvxsx5llq8\n ]\n}"}' credits.aleo/fee_public: outputs: - - '{"type":"future","id":"3917070306191507021417247334289380256159485279427720000635170701460828577188field","value":"{\n program_id: credits.aleo,\n function_name: fee_public,\n arguments: [\n aleo1kw4knandael9qcpxs6g36rr6h7dwvjz6q25ueah6zz9v57zjlvxsx5llq8,\n 1313203u64\n ]\n}"}' + - '{"type":"future","id":"7684699263458955489500469434952154401333918354263231036610964274134089849729field","value":"{\n program_id: credits.aleo,\n function_name: fee_public,\n arguments: [\n aleo1kw4knandael9qcpxs6g36rr6h7dwvjz6q25ueah6zz9v57zjlvxsx5llq8,\n 264403u64\n ]\n}"}' diff --git a/synthesizer/tests/expectations/vm/execute_and_finalize/count_usages.out b/synthesizer/tests/expectations/vm/execute_and_finalize/count_usages.out index 462b19bc6e..b24c3cd022 100644 --- a/synthesizer/tests/expectations/vm/execute_and_finalize/count_usages.out +++ b/synthesizer/tests/expectations/vm/execute_and_finalize/count_usages.out @@ -20,4 +20,4 @@ additional: - '{"type":"future","id":"8376420147018709384724335862198143063714524641135069419096866845262064600524field","value":"{\n program_id: basic_math.aleo,\n function_name: sub_and_count,\n arguments: [\n aleo1mrughg5ssadd9fc2uwve7l6u24xn76kyz24zsjtzta03vgkq4vpqggl6fg\n ]\n}"}' credits.aleo/fee_public: outputs: - - '{"type":"future","id":"8324153878106944143887476538634343411354922556646605767561376149695827127954field","value":"{\n program_id: credits.aleo,\n function_name: fee_public,\n arguments: [\n aleo1kw4knandael9qcpxs6g36rr6h7dwvjz6q25ueah6zz9v57zjlvxsx5llq8,\n 263488u64\n ]\n}"}' + - '{"type":"future","id":"1938790837765091012488580924817661279880431670012907855909045111976774319119field","value":"{\n program_id: credits.aleo,\n function_name: fee_public,\n arguments: [\n aleo1kw4knandael9qcpxs6g36rr6h7dwvjz6q25ueah6zz9v57zjlvxsx5llq8,\n 54628u64\n ]\n}"}' diff --git a/synthesizer/tests/expectations/vm/execute_and_finalize/hello.out b/synthesizer/tests/expectations/vm/execute_and_finalize/hello.out index 9d6f611257..ece9240964 100644 --- a/synthesizer/tests/expectations/vm/execute_and_finalize/hello.out +++ b/synthesizer/tests/expectations/vm/execute_and_finalize/hello.out @@ -42,8 +42,8 @@ additional: - child_outputs: credits.aleo/fee_public: outputs: - - '{"type":"future","id":"767846553614807977239719420369516970523795400922031195070118946602953295894field","value":"{\n program_id: credits.aleo,\n function_name: fee_public,\n arguments: [\n aleo10knkelvnd55fsaarm25wch7p9suf2tqlgwy5k4nxwms6d262xyfqm2tccr,\n 5366u64\n ]\n}"}' + - '{"type":"future","id":"693105314299332215857089088059023707332082928469565896605175974356642396813field","value":"{\n program_id: credits.aleo,\n function_name: fee_public,\n arguments: [\n aleo10knkelvnd55fsaarm25wch7p9suf2tqlgwy5k4nxwms6d262xyfqm2tccr,\n 2366u64\n ]\n}"}' - child_outputs: credits.aleo/fee_public: outputs: - - '{"type":"future","id":"3684392356443869477382230822477215940928201767871507287501762026606131450149field","value":"{\n program_id: credits.aleo,\n function_name: fee_public,\n arguments: [\n aleo10knkelvnd55fsaarm25wch7p9suf2tqlgwy5k4nxwms6d262xyfqm2tccr,\n 5366u64\n ]\n}"}' + - '{"type":"future","id":"1441674302389531937522747153756222779025502860728835603548501000282337153942field","value":"{\n program_id: credits.aleo,\n function_name: fee_public,\n arguments: [\n aleo10knkelvnd55fsaarm25wch7p9suf2tqlgwy5k4nxwms6d262xyfqm2tccr,\n 2366u64\n ]\n}"}' diff --git a/synthesizer/tests/expectations/vm/execute_and_finalize/mapping_operations.out b/synthesizer/tests/expectations/vm/execute_and_finalize/mapping_operations.out index 2e7a5fd334..cf0ee56ebb 100644 --- a/synthesizer/tests/expectations/vm/execute_and_finalize/mapping_operations.out +++ b/synthesizer/tests/expectations/vm/execute_and_finalize/mapping_operations.out @@ -36,12 +36,12 @@ additional: - child_outputs: credits.aleo/fee_public: outputs: - - '{"type":"future","id":"2092697046318791120140968816339851333886436511238705667711902517471851427507field","value":"{\n program_id: credits.aleo,\n function_name: fee_public,\n arguments: [\n aleo1eakarna6a70pg9r0l9qal20faejwctgur5xt7lnc2a42wj2yssfqc89rk8,\n 154842u64\n ]\n}"}' + - '{"type":"future","id":"3819478822099171120366229999148101503444113586997605769708785149006145735527field","value":"{\n program_id: credits.aleo,\n function_name: fee_public,\n arguments: [\n aleo1eakarna6a70pg9r0l9qal20faejwctgur5xt7lnc2a42wj2yssfqc89rk8,\n 53072u64\n ]\n}"}' - child_outputs: credits.aleo/fee_public: outputs: - - '{"type":"future","id":"5451185020177869968712311682344650503963494688356610676016967063974610448346field","value":"{\n program_id: credits.aleo,\n function_name: fee_public,\n arguments: [\n aleo1eakarna6a70pg9r0l9qal20faejwctgur5xt7lnc2a42wj2yssfqc89rk8,\n 154842u64\n ]\n}"}' + - '{"type":"future","id":"4954497220272524572712674911495917535980779254032408121375814942204186632211field","value":"{\n program_id: credits.aleo,\n function_name: fee_public,\n arguments: [\n aleo1eakarna6a70pg9r0l9qal20faejwctgur5xt7lnc2a42wj2yssfqc89rk8,\n 53072u64\n ]\n}"}' - child_outputs: credits.aleo/fee_public: outputs: - - '{"type":"future","id":"2284917219703505613501488644232038072426366368973461661148269133200617380349field","value":"{\n program_id: credits.aleo,\n function_name: fee_public,\n arguments: [\n aleo1eakarna6a70pg9r0l9qal20faejwctgur5xt7lnc2a42wj2yssfqc89rk8,\n 154842u64\n ]\n}"}' + - '{"type":"future","id":"4374767356370294298106071783882769062590961601732098604265421591312847844881field","value":"{\n program_id: credits.aleo,\n function_name: fee_public,\n arguments: [\n aleo1eakarna6a70pg9r0l9qal20faejwctgur5xt7lnc2a42wj2yssfqc89rk8,\n 53072u64\n ]\n}"}' diff --git a/synthesizer/tests/expectations/vm/execute_and_finalize/public_wallet.out b/synthesizer/tests/expectations/vm/execute_and_finalize/public_wallet.out index 8c14c6e65f..97dfd95336 100644 --- a/synthesizer/tests/expectations/vm/execute_and_finalize/public_wallet.out +++ b/synthesizer/tests/expectations/vm/execute_and_finalize/public_wallet.out @@ -14,4 +14,4 @@ additional: - '{"type":"future","id":"6870476253411913047431672168259118946802015453568356666196082705096404310887field","value":"{\n program_id: token.aleo,\n function_name: mint_public,\n arguments: [\n aleo1sry3pke49ykrf0aeshf889tr98r4c86p5f4ms766795ssdwfdyqq9jdg0j,\n 10u64\n ]\n}"}' credits.aleo/fee_public: outputs: - - '{"type":"future","id":"5525308133544540763757385329943115018858161100889529786580724367369238892field","value":"{\n program_id: credits.aleo,\n function_name: fee_public,\n arguments: [\n aleo1d3e2je2m2hsxwdsvntvf4jnnlj459ywfry6ch2qwrpy6l6r6yvpq8e88h5,\n 131265u64\n ]\n}"}' + - '{"type":"future","id":"8242741303045788366029769877408013430285170870359415275077024518285491239453field","value":"{\n program_id: credits.aleo,\n function_name: fee_public,\n arguments: [\n aleo1d3e2je2m2hsxwdsvntvf4jnnlj459ywfry6ch2qwrpy6l6r6yvpq8e88h5,\n 27585u64\n ]\n}"}' diff --git a/synthesizer/tests/expectations/vm/execute_and_finalize/read_external_mapping.out b/synthesizer/tests/expectations/vm/execute_and_finalize/read_external_mapping.out index 981eab75c7..51f9402e04 100644 --- a/synthesizer/tests/expectations/vm/execute_and_finalize/read_external_mapping.out +++ b/synthesizer/tests/expectations/vm/execute_and_finalize/read_external_mapping.out @@ -50,24 +50,24 @@ additional: - child_outputs: credits.aleo/fee_public: outputs: - - '{"type":"future","id":"1980579904176887149609836662057476775778939283569912608145754425251637674937field","value":"{\n program_id: credits.aleo,\n function_name: fee_public,\n arguments: [\n aleo1xe2fps8f9xpdas2q0fqy22uraenk84tvvzetrsyxgnwy6445h59s6wv78x,\n 28511u64\n ]\n}"}' + - '{"type":"future","id":"2460846645005462366786666390638662805054402091600049454074156831399214194828field","value":"{\n program_id: credits.aleo,\n function_name: fee_public,\n arguments: [\n aleo1xe2fps8f9xpdas2q0fqy22uraenk84tvvzetrsyxgnwy6445h59s6wv78x,\n 12331u64\n ]\n}"}' - child_outputs: credits.aleo/fee_public: outputs: - - '{"type":"future","id":"5447803391825137175441907904975044117223783214516201758332272734273947792008field","value":"{\n program_id: credits.aleo,\n function_name: fee_public,\n arguments: [\n aleo1xe2fps8f9xpdas2q0fqy22uraenk84tvvzetrsyxgnwy6445h59s6wv78x,\n 28539u64\n ]\n}"}' + - '{"type":"future","id":"6275256556950672117831015896650227423786495892079094886222239210235424203607field","value":"{\n program_id: credits.aleo,\n function_name: fee_public,\n arguments: [\n aleo1xe2fps8f9xpdas2q0fqy22uraenk84tvvzetrsyxgnwy6445h59s6wv78x,\n 12359u64\n ]\n}"}' - child_outputs: credits.aleo/fee_public: outputs: - - '{"type":"future","id":"3860882066519028066548084960516274925487614453365218041993564070381791439271field","value":"{\n program_id: credits.aleo,\n function_name: fee_public,\n arguments: [\n aleo1f6eg623knp66cwx0926w3plgdgzcmfpgyrzgnjz90mucgs3z7s9qls4upm,\n 101242u64\n ]\n}"}' + - '{"type":"future","id":"8372199321635126203021619457748641319234355407813689190122379673577134950885field","value":"{\n program_id: credits.aleo,\n function_name: fee_public,\n arguments: [\n aleo1f6eg623knp66cwx0926w3plgdgzcmfpgyrzgnjz90mucgs3z7s9qls4upm,\n 14542u64\n ]\n}"}' - child_outputs: credits.aleo/fee_public: outputs: - - '{"type":"future","id":"6950398885728475979865392048432051837738192098568760171018607474283886122052field","value":"{\n program_id: credits.aleo,\n function_name: fee_public,\n arguments: [\n aleo1xe2fps8f9xpdas2q0fqy22uraenk84tvvzetrsyxgnwy6445h59s6wv78x,\n 28511u64\n ]\n}"}' + - '{"type":"future","id":"610670209921538255900619170127761975836076634836989613464070279109494487943field","value":"{\n program_id: credits.aleo,\n function_name: fee_public,\n arguments: [\n aleo1xe2fps8f9xpdas2q0fqy22uraenk84tvvzetrsyxgnwy6445h59s6wv78x,\n 12331u64\n ]\n}"}' - child_outputs: credits.aleo/fee_public: outputs: - - '{"type":"future","id":"1611419113948590934439813710994891232204055145464765197156009306482292108171field","value":"{\n program_id: credits.aleo,\n function_name: fee_public,\n arguments: [\n aleo1f6eg623knp66cwx0926w3plgdgzcmfpgyrzgnjz90mucgs3z7s9qls4upm,\n 101246u64\n ]\n}"}' + - '{"type":"future","id":"7567328850021607310717103237149585492311011209064307935458393135932696315699field","value":"{\n program_id: credits.aleo,\n function_name: fee_public,\n arguments: [\n aleo1f6eg623knp66cwx0926w3plgdgzcmfpgyrzgnjz90mucgs3z7s9qls4upm,\n 14546u64\n ]\n}"}' - child_outputs: credits.aleo/fee_public: outputs: - - '{"type":"future","id":"4567702067011150795800469439274536831772194733575217584709850797127644395715field","value":"{\n program_id: credits.aleo,\n function_name: fee_public,\n arguments: [\n aleo1xe2fps8f9xpdas2q0fqy22uraenk84tvvzetrsyxgnwy6445h59s6wv78x,\n 28511u64\n ]\n}"}' + - '{"type":"future","id":"1006453709257039404896819728350834886286831571018854714236513706501168842517field","value":"{\n program_id: credits.aleo,\n function_name: fee_public,\n arguments: [\n aleo1xe2fps8f9xpdas2q0fqy22uraenk84tvvzetrsyxgnwy6445h59s6wv78x,\n 12331u64\n ]\n}"}' diff --git a/synthesizer/tests/expectations/vm/execute_and_finalize/test_branch.out b/synthesizer/tests/expectations/vm/execute_and_finalize/test_branch.out index 7a740e7321..a92ddf6b41 100644 --- a/synthesizer/tests/expectations/vm/execute_and_finalize/test_branch.out +++ b/synthesizer/tests/expectations/vm/execute_and_finalize/test_branch.out @@ -25,12 +25,12 @@ additional: - child_outputs: credits.aleo/fee_public: outputs: - - '{"type":"future","id":"1171608727776431644975750070732912123034332726467525754602888924054094288537field","value":"{\n program_id: credits.aleo,\n function_name: fee_public,\n arguments: [\n aleo1x3r205zqql5ywy0cqqt74k0r0htuusn0d037ycxe8ftt9ep8hyzsmqz4dh,\n 17300u64\n ]\n}"}' + - '{"type":"future","id":"7173480694908809256108540320075206508452674100243861581665566642817871381991field","value":"{\n program_id: credits.aleo,\n function_name: fee_public,\n arguments: [\n aleo1x3r205zqql5ywy0cqqt74k0r0htuusn0d037ycxe8ftt9ep8hyzsmqz4dh,\n 3500u64\n ]\n}"}' - child_outputs: credits.aleo/fee_public: outputs: - - '{"type":"future","id":"7463420514229578917100663094481004916008770860159447604880946437006571567641field","value":"{\n program_id: credits.aleo,\n function_name: fee_public,\n arguments: [\n aleo1x3r205zqql5ywy0cqqt74k0r0htuusn0d037ycxe8ftt9ep8hyzsmqz4dh,\n 17300u64\n ]\n}"}' + - '{"type":"future","id":"8282914561152876827019335440647738942468939906336223802339463037044326143146field","value":"{\n program_id: credits.aleo,\n function_name: fee_public,\n arguments: [\n aleo1x3r205zqql5ywy0cqqt74k0r0htuusn0d037ycxe8ftt9ep8hyzsmqz4dh,\n 3500u64\n ]\n}"}' - child_outputs: credits.aleo/fee_public: outputs: - - '{"type":"future","id":"6487859374829903867805258250383686562413912996473658489745407025850659518586field","value":"{\n program_id: credits.aleo,\n function_name: fee_public,\n arguments: [\n aleo1x3r205zqql5ywy0cqqt74k0r0htuusn0d037ycxe8ftt9ep8hyzsmqz4dh,\n 17300u64\n ]\n}"}' + - '{"type":"future","id":"5334579863811891704545979925237596250682151556306514860044024145517585546947field","value":"{\n program_id: credits.aleo,\n function_name: fee_public,\n arguments: [\n aleo1x3r205zqql5ywy0cqqt74k0r0htuusn0d037ycxe8ftt9ep8hyzsmqz4dh,\n 3500u64\n ]\n}"}' diff --git a/synthesizer/tests/expectations/vm/execute_and_finalize/test_rand.out b/synthesizer/tests/expectations/vm/execute_and_finalize/test_rand.out index 532aef5b20..57dd18584c 100644 --- a/synthesizer/tests/expectations/vm/execute_and_finalize/test_rand.out +++ b/synthesizer/tests/expectations/vm/execute_and_finalize/test_rand.out @@ -19,14 +19,14 @@ outputs: test_rand.aleo/rand_chacha_check: outputs: - '{"type":"future","id":"488590592441422127997725386233571306457829570948543232762424611162021835080field","value":"{\n program_id: test_rand.aleo,\n function_name: rand_chacha_check,\n arguments: [\n 0field,\n false\n ]\n}"}' - speculate: the execution was accepted + speculate: the execution was rejected add_next_block: succeeded. - verified: true execute: test_rand.aleo/rand_chacha_check: outputs: - '{"type":"future","id":"884323248557348741020456011434839803868309861690594536593949575748229817915field","value":"{\n program_id: test_rand.aleo,\n function_name: rand_chacha_check,\n arguments: [\n 1field,\n true\n ]\n}"}' - speculate: the execution was accepted + speculate: the execution was rejected add_next_block: succeeded. additional: - child_outputs: @@ -40,8 +40,8 @@ additional: - child_outputs: credits.aleo/fee_public: outputs: - - '{"type":"future","id":"4462067028953176194433456128612215180254915580822913622860423763786957990093field","value":"{\n program_id: credits.aleo,\n function_name: fee_public,\n arguments: [\n aleo1uchf7kruskpp8thlnfeya9qeklcjss27j6rtu74zz7ch559neqystgslsp,\n 28376u64\n ]\n}"}' + - '{"type":"future","id":"1282129350700700594940680024596897867110148414308708700842921386046440366011field","value":"{\n program_id: credits.aleo,\n function_name: fee_public,\n arguments: [\n aleo1uchf7kruskpp8thlnfeya9qeklcjss27j6rtu74zz7ch559neqystgslsp,\n 26876u64\n ]\n}"}' - child_outputs: credits.aleo/fee_public: outputs: - - '{"type":"future","id":"7019143888326425189688317194740968171760456342747217065687761270408913083348field","value":"{\n program_id: credits.aleo,\n function_name: fee_public,\n arguments: [\n aleo1uchf7kruskpp8thlnfeya9qeklcjss27j6rtu74zz7ch559neqystgslsp,\n 28376u64\n ]\n}"}' + - '{"type":"future","id":"2838401481340464124610411329302176081664394080829994051209644145406827373864field","value":"{\n program_id: credits.aleo,\n function_name: fee_public,\n arguments: [\n aleo1uchf7kruskpp8thlnfeya9qeklcjss27j6rtu74zz7ch559neqystgslsp,\n 26876u64\n ]\n}"}' diff --git a/synthesizer/tests/expectations/vm/execute_and_finalize/timelock.out b/synthesizer/tests/expectations/vm/execute_and_finalize/timelock.out index fb8c6b56dc..bddb3741aa 100644 --- a/synthesizer/tests/expectations/vm/execute_and_finalize/timelock.out +++ b/synthesizer/tests/expectations/vm/execute_and_finalize/timelock.out @@ -18,8 +18,8 @@ additional: - child_outputs: credits.aleo/fee_public: outputs: - - '{"type":"future","id":"6311501351515915084600267933817246658800627224158118036734300141828790673821field","value":"{\n program_id: credits.aleo,\n function_name: fee_public,\n arguments: [\n aleo12tksdptp7hvxly8tkm3um08fvf53qpehsgdgqfvy9pe3sewcq5ysjg5myy,\n 5196u64\n ]\n}"}' + - '{"type":"future","id":"945360682200179475934660913543316288826823363735980525242738043528572749037field","value":"{\n program_id: credits.aleo,\n function_name: fee_public,\n arguments: [\n aleo12tksdptp7hvxly8tkm3um08fvf53qpehsgdgqfvy9pe3sewcq5ysjg5myy,\n 2196u64\n ]\n}"}' - child_outputs: credits.aleo/fee_public: outputs: - - '{"type":"future","id":"3727428454041721032579660663546168001221206494621052639644496834224868473189field","value":"{\n program_id: credits.aleo,\n function_name: fee_public,\n arguments: [\n aleo12tksdptp7hvxly8tkm3um08fvf53qpehsgdgqfvy9pe3sewcq5ysjg5myy,\n 5196u64\n ]\n}"}' + - '{"type":"future","id":"4407865525570721713881622682558869732652022922248324986891224724282763545029field","value":"{\n program_id: credits.aleo,\n function_name: fee_public,\n arguments: [\n aleo12tksdptp7hvxly8tkm3um08fvf53qpehsgdgqfvy9pe3sewcq5ysjg5myy,\n 2196u64\n ]\n}"}' diff --git a/synthesizer/tests/expectations/vm/execute_and_finalize/unused_position.out b/synthesizer/tests/expectations/vm/execute_and_finalize/unused_position.out index 71a183aa9c..3c78b6e8a7 100644 --- a/synthesizer/tests/expectations/vm/execute_and_finalize/unused_position.out +++ b/synthesizer/tests/expectations/vm/execute_and_finalize/unused_position.out @@ -11,4 +11,4 @@ additional: - child_outputs: credits.aleo/fee_public: outputs: - - '{"type":"future","id":"2621696734847465496099117263198227992906624839872816115893439464172566198419field","value":"{\n program_id: credits.aleo,\n function_name: fee_public,\n arguments: [\n aleo12tksdptp7hvxly8tkm3um08fvf53qpehsgdgqfvy9pe3sewcq5ysjg5myy,\n 2208u64\n ]\n}"}' + - '{"type":"future","id":"4500648057971642536326023581723419344508470174070904810378001320229962188845field","value":"{\n program_id: credits.aleo,\n function_name: fee_public,\n arguments: [\n aleo12tksdptp7hvxly8tkm3um08fvf53qpehsgdgqfvy9pe3sewcq5ysjg5myy,\n 1308u64\n ]\n}"}'