diff --git a/benches/benches/decompilation_benchmark.rs b/benches/benches/decompilation_benchmark.rs index fcee66df..6399035f 100644 --- a/benches/benches/decompilation_benchmark.rs +++ b/benches/benches/decompilation_benchmark.rs @@ -1,5 +1,3 @@ -use std::time::Duration; - use benches::{Invoke, RadixEngineToolkit}; use criterion::{black_box, criterion_group, criterion_main, Criterion}; use native_transaction::{ @@ -59,8 +57,6 @@ fn decompile_intent_with_core_toolkit_benchmarks(c: &mut Criterion) { let compiled_transaction = hex::decode(include_str!("./transaction.hex")).unwrap(); let mut group = c.benchmark_group("Decompile Intent with Toolkit Core"); - group.sample_size(10); - group.bench_function("Decompile Unknown Intent to String", |b| { b.iter(|| { black_box({ @@ -169,8 +165,7 @@ fn decompile_intent_with_toolkit_wrapper_benchmarks(c: &mut Criterion) { criterion_group!( name = benches; - config = Criterion::default().measurement_time(Duration::from_secs(10)); - // config = Criterion::default(); + config = Criterion::default(); targets = decompile_intent_natively_benchmarks, decompile_intent_with_toolkit_wrapper_benchmarks, decompile_intent_with_core_toolkit_benchmarks ); criterion_main!(benches); diff --git a/benches/lib/libradix_engine_toolkit.dylib b/benches/lib/libradix_engine_toolkit.dylib index 7d229d7a..3c84f0a7 100755 Binary files a/benches/lib/libradix_engine_toolkit.dylib and b/benches/lib/libradix_engine_toolkit.dylib differ diff --git a/radix-engine-toolkit/src/error.rs b/radix-engine-toolkit/src/error.rs index 3d2e0d38..8282f588 100644 --- a/radix-engine-toolkit/src/error.rs +++ b/radix-engine-toolkit/src/error.rs @@ -201,6 +201,9 @@ pub enum Error { NotAnOlympiaAddress { address: String, }, + + /// Transaction was not committed. + TransactionNotCommitted, } impl Display for Error { diff --git a/radix-engine-toolkit/src/request/analyze_manifest_with_preview_context.rs b/radix-engine-toolkit/src/request/analyze_manifest_with_preview_context.rs index 6927c9ba..b4717aa7 100644 --- a/radix-engine-toolkit/src/request/analyze_manifest_with_preview_context.rs +++ b/radix-engine-toolkit/src/request/analyze_manifest_with_preview_context.rs @@ -17,7 +17,7 @@ use std::collections::BTreeSet; -use crate::error::Result; +use crate::error::{Error, Result}; use crate::model::address::{EntityAddress, NetworkAwarePackageAddress}; use crate::model::address::{NetworkAwareComponentAddress, NetworkAwareResourceAddress}; use crate::model::instruction::Instruction; @@ -27,7 +27,7 @@ use crate::visitor::{ AccountInteractionsInstructionVisitor, AccountProofsInstructionVisitor, AccountWithdraw, AccountWithdrawsInstructionVisitor, AddressAggregatorVisitor, ValueNetworkAggregatorVisitor, }; -use radix_engine::transaction::TransactionReceipt; +use radix_engine::transaction::{TransactionReceipt, TransactionResult}; use radix_engine::types::{scrypto_decode, ComponentAddress}; use toolkit_derive::serializable; @@ -110,6 +110,9 @@ pub struct AnalyzeManifestWithPreviewContextResponse { /// deposits which are guaranteed by the static analysis while the ones referred to as /// "estimate" are deposits which are primarily obtained from the context of the previews pub account_deposits: Vec, + + /// The set of entities which were newly created in this transaction. + pub created_entities: CreatedEntities, } /// The set of addresses encountered in the manifest @@ -130,6 +133,26 @@ pub struct EncounteredAddresses { pub package_addresses: BTreeSet, } +/// The set of newly created entities +#[serializable] +#[derive(PartialEq, PartialOrd, Eq, Ord)] +pub struct CreatedEntities { + /// The set of addresses of newly created components. + #[schemars(with = "BTreeSet")] + #[serde_as(as = "BTreeSet>")] + pub component_addresses: BTreeSet, + + /// The set of addresses of newly created resources. + #[schemars(with = "BTreeSet")] + #[serde_as(as = "BTreeSet>")] + pub resource_addresses: BTreeSet, + + /// The set of addresses of newly created packages. + #[schemars(with = "BTreeSet")] + #[serde_as(as = "BTreeSet>")] + pub package_addresses: BTreeSet, +} + /// The set of addresses encountered in the manifest #[serializable] #[derive(PartialEq, PartialOrd, Eq, Ord)] @@ -273,13 +296,18 @@ impl Handler(&request.transaction_receipt)?; + let commit = match receipt.result { + TransactionResult::Commit(commit) => Ok(commit), + _ => Err(Error::TransactionNotCommitted), + }?; + // Setting up the visitors that will be used on the instructions let mut account_interactions_visitor = AccountInteractionsInstructionVisitor::default(); let mut account_withdraws_visitor = AccountWithdrawsInstructionVisitor::default(); let mut account_proofs_visitor = AccountProofsInstructionVisitor::default(); let mut address_aggregator_visitor = AddressAggregatorVisitor::default(); let mut account_deposits_visitor = { - let receipt = scrypto_decode::(&request.transaction_receipt)?; let resource_changes = receipt .execution_trace .resource_changes @@ -325,6 +353,32 @@ impl Handler