Skip to content

Commit

Permalink
Update to damson
Browse files Browse the repository at this point in the history
  • Loading branch information
0xOmarA committed Jun 26, 2023
1 parent fdd0ecf commit 069584e
Show file tree
Hide file tree
Showing 10 changed files with 69 additions and 46 deletions.
4 changes: 4 additions & 0 deletions Changelog.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# 0.10.0-damson.1 (26-June-2023)

No interface changes were made with this internal release, just internal changes to the toolkit as a result of bumping the version of the Scrypto Dependency.

# 0.10.0 (26-June-2023)

* All builds of the Radix Engine Toolkit now come with a `test-kit.tar.gz` file containing many test vectors to use when updating the toolkit wrappers to be compatible with the toolkit. More specifically, it includes the following:
Expand Down
14 changes: 7 additions & 7 deletions generator/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@ edition = "2021"

[dependencies]
# radixdlt-scrypto dependencies.
sbor = { git = "https://github.com/radixdlt/radixdlt-scrypto", branch = "feature/fee-locks-in-execution-trace", features = ["serde"] }
scrypto = { git = "https://github.com/radixdlt/radixdlt-scrypto", branch = "feature/fee-locks-in-execution-trace", features = ["serde"] }
scrypto-unit = { git = "https://github.com/radixdlt/radixdlt-scrypto", branch = "feature/fee-locks-in-execution-trace", default-features = false, features = ["lru", "std"] }
transaction = { git = "https://github.com/radixdlt/radixdlt-scrypto", branch = "feature/fee-locks-in-execution-trace" }
radix-engine = { git = "https://github.com/radixdlt/radixdlt-scrypto", branch = "feature/fee-locks-in-execution-trace", default-features= false, features = ["std", "lru"] }
radix-engine-common = { git = "https://github.com/radixdlt/radixdlt-scrypto", branch = "feature/fee-locks-in-execution-trace", features = ["serde"] }
radix-engine-interface = { git = "https://github.com/radixdlt/radixdlt-scrypto", branch = "feature/fee-locks-in-execution-trace" }
sbor = { git = "https://github.com/radixdlt/radixdlt-scrypto", tag = "damson-6b1549985", features = ["serde"] }
scrypto = { git = "https://github.com/radixdlt/radixdlt-scrypto", tag = "damson-6b1549985", features = ["serde"] }
scrypto-unit = { git = "https://github.com/radixdlt/radixdlt-scrypto", tag = "damson-6b1549985", default-features = false, features = ["lru", "std"] }
transaction = { git = "https://github.com/radixdlt/radixdlt-scrypto", tag = "damson-6b1549985" }
radix-engine = { git = "https://github.com/radixdlt/radixdlt-scrypto", tag = "damson-6b1549985", default-features= false, features = ["std", "lru"] }
radix-engine-common = { git = "https://github.com/radixdlt/radixdlt-scrypto", tag = "damson-6b1549985", features = ["serde"] }
radix-engine-interface = { git = "https://github.com/radixdlt/radixdlt-scrypto", tag = "damson-6b1549985" }

# Core Radix Engine Toolkit and Toolkit Native Library
radix-engine-toolkit-core = { path = "../radix-engine-toolkit-core" }
Expand Down
4 changes: 2 additions & 2 deletions generator/src/serializable_models/instruction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -378,7 +378,7 @@ fn example_package() -> (Vec<u8>, PackageDefinition) {
&& blueprint_name == PACKAGE_BLUEPRINT
&& function_name == PACKAGE_PUBLISH_WASM_IDENT =>
{
let PackagePublishWasmManifestInput { code, setup, .. } =
let PackagePublishWasmManifestIndexMapInput { code, setup, .. } =
manifest_decode(&manifest_encode(&args).unwrap()).unwrap();

(code, setup)
Expand All @@ -392,7 +392,7 @@ fn example_package() -> (Vec<u8>, PackageDefinition) {
&& blueprint_name == PACKAGE_BLUEPRINT
&& function_name == PACKAGE_PUBLISH_WASM_ADVANCED_IDENT =>
{
let PackagePublishWasmAdvancedManifestInput { code, setup, .. } =
let PackagePublishWasmAdvancedManifestIndexMapInput { code, setup, .. } =
manifest_decode(&manifest_encode(&args).unwrap()).unwrap();

(code, setup)
Expand Down
20 changes: 10 additions & 10 deletions radix-engine-toolkit-core/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
[package]
name = "radix-engine-toolkit-core"
version = "0.10.0"
version = "0.10.0-damson.1"
edition = "2021"
build = "build.rs"

[dependencies]
# radixdlt-scrypto dependencies.
sbor = { git = "https://github.com/radixdlt/radixdlt-scrypto", branch = "feature/fee-locks-in-execution-trace", features = ["serde"] }
scrypto = { git = "https://github.com/radixdlt/radixdlt-scrypto", branch = "feature/fee-locks-in-execution-trace", features = ["serde"] }
transaction = { git = "https://github.com/radixdlt/radixdlt-scrypto", branch = "feature/fee-locks-in-execution-trace" }
radix-engine = { git = "https://github.com/radixdlt/radixdlt-scrypto", branch = "feature/fee-locks-in-execution-trace", default-features= false, features = ["std", "lru"] }
radix-engine-common = { git = "https://github.com/radixdlt/radixdlt-scrypto", branch = "feature/fee-locks-in-execution-trace", features = ["serde"] }
radix-engine-interface = { git = "https://github.com/radixdlt/radixdlt-scrypto", branch = "feature/fee-locks-in-execution-trace" }
radix-engine-queries = { git = "https://github.com/radixdlt/radixdlt-scrypto", branch = "feature/fee-locks-in-execution-trace", default-features= false, features = ["std", "lru"] }
radix-engine-store-interface = { git = "https://github.com/radixdlt/radixdlt-scrypto", branch = "feature/fee-locks-in-execution-trace" }
sbor = { git = "https://github.com/radixdlt/radixdlt-scrypto", tag = "damson-6b1549985", features = ["serde"] }
scrypto = { git = "https://github.com/radixdlt/radixdlt-scrypto", tag = "damson-6b1549985", features = ["serde"] }
transaction = { git = "https://github.com/radixdlt/radixdlt-scrypto", tag = "damson-6b1549985" }
radix-engine = { git = "https://github.com/radixdlt/radixdlt-scrypto", tag = "damson-6b1549985", default-features= false, features = ["std", "lru"] }
radix-engine-common = { git = "https://github.com/radixdlt/radixdlt-scrypto", tag = "damson-6b1549985", features = ["serde"] }
radix-engine-interface = { git = "https://github.com/radixdlt/radixdlt-scrypto", tag = "damson-6b1549985" }
radix-engine-queries = { git = "https://github.com/radixdlt/radixdlt-scrypto", tag = "damson-6b1549985", default-features= false, features = ["std", "lru"] }
radix-engine-store-interface = { git = "https://github.com/radixdlt/radixdlt-scrypto", tag = "damson-6b1549985" }

# Bech32 encoding and decoding of addresses. Used for the Olympia <-> Babylon address derivations.
bech32 = { version = "0.9.1" }
Expand All @@ -30,7 +30,7 @@ lazy_static = { version = "1.4.0" }
cargo_toml = { version = "0.15.3" }

[dev-dependencies]
scrypto-unit = { git = "https://github.com/radixdlt/radixdlt-scrypto", branch = "feature/fee-locks-in-execution-trace", default-features = false, features = ["lru", "std", "resource_tracker"] }
scrypto-unit = { git = "https://github.com/radixdlt/radixdlt-scrypto", tag = "damson-6b1549985", default-features = false, features = ["lru", "std", "resource_tracker"] }

[lib]
crate-type = ["staticlib", "cdylib", "rlib"]
18 changes: 16 additions & 2 deletions radix-engine-toolkit-core/src/functions/execution.rs
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,15 @@ pub fn analyze(
TransactionType::NonConforming
};

let fee_locks = execution_trace.fee_locks.clone();
let mut fee_locks = FeeLocks::default();
for (_, amount, is_contingent) in fee_summary.locked_fees.iter() {
let amount = amount.amount();
if *is_contingent {
fee_locks.contingent_lock += amount;
} else {
fee_locks.lock += amount;
}
}

let fee_summary = {
// Previews sometimes reports a cost unit price of zero. So, we will:
Expand Down Expand Up @@ -134,12 +142,18 @@ pub struct ExecutionAnalysis {
pub transaction_type: TransactionType,
}

#[derive(Clone, Debug, PartialEq, Eq)]
#[derive(Clone, Debug, PartialEq, Eq, Default)]
pub struct FeeSummary {
pub network_fee: Decimal,
pub royalty_fee: Decimal,
}

#[derive(Clone, Debug, PartialEq, Eq, Default)]
pub struct FeeLocks {
pub lock: Decimal,
pub contingent_lock: Decimal,
}

#[derive(Clone, Debug, PartialEq, Eq)]
pub enum TransactionType {
SimpleTransfer(Box<SimpleTransferTransactionType>),
Expand Down
9 changes: 3 additions & 6 deletions radix-engine-toolkit-core/src/statics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ fn methods_that_require_auth(blueprint_schema: &BlueprintDefinitionInit) -> Vec<
method_auth_template_static_or_panic(&blueprint_schema.auth_config.method_auth)
.iter()
.filter_map(|(key, value)| {
if let MethodAccessibility::Public = value {
if let MethodPermission::Public = value {
None
} else {
Some(key.clone())
Expand All @@ -234,11 +234,8 @@ fn type_ref_static_or_panic<T>(type_ref: &TypeRef<T>) -> &T {

fn method_auth_template_static_or_panic(
method_auth_template: &MethodAuthTemplate,
) -> &BTreeMap<MethodKey, MethodAccessibility> {
) -> &BTreeMap<MethodKey, MethodPermission> {
match method_auth_template {
MethodAuthTemplate::Static(value) => value,
MethodAuthTemplate::AllowAll | MethodAuthTemplate::StaticUseOuterAuth(..) => {
panic!("MethodAuthTemplate is not static")
}
MethodAuthTemplate::Static { auth, .. } => auth,
}
}
14 changes: 11 additions & 3 deletions radix-engine-toolkit-core/src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ use radix_engine::transaction::TransactionReceipt;
use radix_engine_common::prelude::NetworkDefinition;
use radix_engine_queries::typed_substate_layout::{
to_typed_substate_key, to_typed_substate_value, TypedMainModuleSubstateKey,
TypedMainModuleSubstateValue, TypedSubstateKey, TypedSubstateValue,
TypedMainModuleSubstateValue, TypedMetadataModuleSubstateKey, TypedMetadataModuleSubstateValue,
TypedSubstateKey, TypedSubstateValue,
};
use radix_engine_store_interface::interface::DatabaseUpdate;
use sbor::{generate_full_schema_from_single_type, validate_payload_against_schema};
Expand Down Expand Up @@ -211,8 +212,8 @@ pub fn metadata_of_newly_created_entities(
for (substate_key, database_update) in key_update_map.iter() {
if let DatabaseUpdate::Set(data) = database_update {
if let Ok((
TypedSubstateKey::MetadataModuleEntryKey(key),
TypedSubstateValue::MetadataModuleEntryValue(DynSubstate { value, .. }),
TypedSubstateKey::MetadataModule(key),
TypedSubstateValue::MetadataModule(value),
)) = to_typed_substate_key(
global_address.as_node_id().entity_type().unwrap(),
METADATA_KV_STORE_PARTITION,
Expand All @@ -222,6 +223,13 @@ pub fn metadata_of_newly_created_entities(
to_typed_substate_value(&typed_substate_key, data)
.map(|typed_substate_value| (typed_substate_key, typed_substate_value))
}) {
let TypedMetadataModuleSubstateKey::MetadataEntryKey(key) = key;
let value = match value {
TypedMetadataModuleSubstateValue::MetadataEntry(DynSubstate {
value,
..
}) => value,
};
map.entry(global_address)
.or_default()
.insert(key, value.unwrap());
Expand Down
12 changes: 6 additions & 6 deletions radix-engine-toolkit/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
[package]
name = "radix-engine-toolkit"
version = "0.10.0"
version = "0.10.0-damson.1"
edition = "2021"

[dependencies]
# radixdlt-scrypto dependencies.
sbor = { git = "https://github.com/radixdlt/radixdlt-scrypto", branch = "feature/fee-locks-in-execution-trace", features = ["serde"] }
scrypto = { git = "https://github.com/radixdlt/radixdlt-scrypto", branch = "feature/fee-locks-in-execution-trace", features = ["serde"] }
transaction = { git = "https://github.com/radixdlt/radixdlt-scrypto", branch = "feature/fee-locks-in-execution-trace" }
radix-engine = { git = "https://github.com/radixdlt/radixdlt-scrypto", branch = "feature/fee-locks-in-execution-trace", default-features= false, features = ["std", "lru"] }
radix-engine-common = { git = "https://github.com/radixdlt/radixdlt-scrypto", branch = "feature/fee-locks-in-execution-trace", features = ["serde"] }
sbor = { git = "https://github.com/radixdlt/radixdlt-scrypto", tag = "damson-6b1549985", features = ["serde"] }
scrypto = { git = "https://github.com/radixdlt/radixdlt-scrypto", tag = "damson-6b1549985", features = ["serde"] }
transaction = { git = "https://github.com/radixdlt/radixdlt-scrypto", tag = "damson-6b1549985" }
radix-engine = { git = "https://github.com/radixdlt/radixdlt-scrypto", tag = "damson-6b1549985", default-features= false, features = ["std", "lru"] }
radix-engine-common = { git = "https://github.com/radixdlt/radixdlt-scrypto", tag = "damson-6b1549985", features = ["serde"] }

# Core Radix Engine Toolkit
radix-engine-toolkit-core = { path = "../radix-engine-toolkit-core" }
Expand Down
19 changes: 9 additions & 10 deletions radix-engine-toolkit/src/functions/execution.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,15 @@

use crate::prelude::*;

use radix_engine::system::system_modules::execution_trace::ResourceSpecifier;
use radix_engine::transaction::{TransactionReceipt, FeeLocks};
use radix_engine_common::prelude::{scrypto_decode, scrypto_encode};
use radix_engine_toolkit_core::functions::execution::{TransactionType, FeeSummary};
use radix_engine_toolkit_core::instruction_visitor::visitors::transaction_type::transfer_visitor::Resources;
use radix_engine_toolkit_core::instruction_visitor::visitors::transaction_type::general_transaction_visitor::Source;
use sbor::prelude::{HashMap, HashSet};
use schemars::JsonSchema;
use scrypto::api::node_modules::metadata::MetadataValue;
use serde::{Deserialize, Serialize};
use radix_engine::system::system_modules::execution_trace::*;
use radix_engine::transaction::*;
use radix_engine_common::prelude::*;
use radix_engine_toolkit_core::functions::execution::*;
use radix_engine_toolkit_core::instruction_visitor::visitors::transaction_type::transfer_visitor::*;
use radix_engine_toolkit_core::instruction_visitor::visitors::transaction_type::general_transaction_visitor::*;
use schemars::*;
use scrypto::api::node_modules::metadata::*;
use serde::*;

//===================
// Execution Analyze
Expand Down
1 change: 1 addition & 0 deletions radix-engine-toolkit/src/models/manifest_inputs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -183,3 +183,4 @@ pub struct AccessRulesCreateIndexMapInput {
pub struct MetadataCreateWithDataIndexMapInput {
pub data: IndexMap<String, MetadataValue>,
}

0 comments on commit 069584e

Please sign in to comment.