Skip to content

Commit

Permalink
Merge pull request #1678 from radixdlt/feature/pool-improvements
Browse files Browse the repository at this point in the history
Pools v1.1 + update logic
  • Loading branch information
talekhinezh committed Jan 19, 2024
2 parents 6809816 + 36dffee commit c69e16d
Show file tree
Hide file tree
Showing 67 changed files with 6,224 additions and 1,516 deletions.
3 changes: 1 addition & 2 deletions monkey-tests/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,7 @@ use crate::resource::{
use crate::two_pool::TwoPoolFuzzAction;
use crate::validator::ValidatorFuzzAction;
use radix_engine::blueprints::consensus_manager::EpochChangeEvent;
use radix_engine::blueprints::pool::multi_resource_pool::MULTI_RESOURCE_POOL_BLUEPRINT_IDENT;
use radix_engine::blueprints::pool::two_resource_pool::TWO_RESOURCE_POOL_BLUEPRINT_IDENT;
use radix_engine::blueprints::pool::v1::constants::*;
use radix_engine::errors::{NativeRuntimeError, RuntimeError, VmError};
use radix_engine::prelude::node_modules::ModuleConfig;
use radix_engine::transaction::{TransactionOutcome, TransactionResult};
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion radix-engine-interface/src/blueprints/package/substates.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,11 @@ pub const TRANSACTION_PROCESSOR_CODE_ID: u64 = 7u64;
pub const METADATA_CODE_ID: u64 = 10u64;
pub const ROYALTY_CODE_ID: u64 = 11u64;
pub const ROLE_ASSIGNMENT_CODE_ID: u64 = 12u64;
pub const POOL_CODE_ID: u64 = 13u64;
pub const POOL_V1_0_CODE_ID: u64 = 13u64;
pub const TRANSACTION_TRACKER_CODE_ID: u64 = 14u64;
pub const TEST_UTILS_CODE_ID: u64 = 15u64;
pub const CONSENSUS_MANAGER_SECONDS_PRECISION_CODE_ID: u64 = 16u64;
pub const POOL_V1_1_CODE_ID: u64 = 17u64;

pub const PACKAGE_FIELDS_PARTITION_OFFSET: PartitionOffset = PartitionOffset(0u8);
pub const PACKAGE_BLUEPRINTS_PARTITION_OFFSET: PartitionOffset = PartitionOffset(1u8);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ define_invocation! {
},
output: type (Bucket, Vec<Bucket>),
manifest_input: struct {
buckets: (ManifestBucket, ManifestBucket)
buckets: Vec<ManifestBucket>
}
}

Expand Down
4 changes: 2 additions & 2 deletions radix-engine-interface/src/blueprints/resource/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ macro_rules! resource_roles {
pub $updater_field: T,
}

impl $roles_struct<RoleDefinition> {
impl $roles_struct<$crate::api::node_modules::auth::RoleDefinition> {
pub fn to_role_init(self) -> $crate::blueprints::resource::RoleAssignmentInit {
let mut roles = $crate::blueprints::resource::RoleAssignmentInit::new();
roles.define_role($actor_field_name, self.$actor_field);
Expand All @@ -71,7 +71,7 @@ macro_rules! resource_roles {
}
}

impl Default for $roles_struct<RoleDefinition> {
impl Default for $roles_struct<$crate::api::node_modules::auth::RoleDefinition> {
fn default() -> Self {
Self {
$actor_field: Some($default_rule),
Expand Down
31 changes: 16 additions & 15 deletions radix-engine-queries/src/typed_native_events.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
use crate::typed_substate_layout::*;
use radix_engine::blueprints::account;
use radix_engine::blueprints::native_schema::*;
use radix_engine::blueprints::pool::v1::events as pool_events;
use radix_engine::types::*;

/// Given an [`EventTypeIdentifier`] and the raw event data, this function attempts to convert the
Expand Down Expand Up @@ -74,7 +75,7 @@ fn resolve_typed_event_key_from_event_type_identifier(
)
.map(TypedNativeEventKey::from),
POOL_PACKAGE => TypedPoolPackageEventKey::new(
&POOL_PACKAGE_DEFINITION,
&POOL_PACKAGE_DEFINITION_V1_0,
&blueprint_id.blueprint_name,
&event_name,
)
Expand Down Expand Up @@ -301,20 +302,20 @@ define_structure! {
}

// Type aliases for events with the same name in order not to cause use collision issues.
type OneResourcePoolContributionEvent = one_resource_pool::ContributionEvent;
type OneResourcePoolRedemptionEvent = one_resource_pool::RedemptionEvent;
type OneResourcePoolWithdrawEvent = one_resource_pool::WithdrawEvent;
type OneResourcePoolDepositEvent = one_resource_pool::DepositEvent;

type TwoResourcePoolContributionEvent = two_resource_pool::ContributionEvent;
type TwoResourcePoolRedemptionEvent = two_resource_pool::RedemptionEvent;
type TwoResourcePoolWithdrawEvent = two_resource_pool::WithdrawEvent;
type TwoResourcePoolDepositEvent = two_resource_pool::DepositEvent;

type MultiResourcePoolContributionEvent = multi_resource_pool::ContributionEvent;
type MultiResourcePoolRedemptionEvent = multi_resource_pool::RedemptionEvent;
type MultiResourcePoolWithdrawEvent = multi_resource_pool::WithdrawEvent;
type MultiResourcePoolDepositEvent = multi_resource_pool::DepositEvent;
type OneResourcePoolContributionEvent = pool_events::one_resource_pool::ContributionEvent;
type OneResourcePoolRedemptionEvent = pool_events::one_resource_pool::RedemptionEvent;
type OneResourcePoolWithdrawEvent = pool_events::one_resource_pool::WithdrawEvent;
type OneResourcePoolDepositEvent = pool_events::one_resource_pool::DepositEvent;

type TwoResourcePoolContributionEvent = pool_events::two_resource_pool::ContributionEvent;
type TwoResourcePoolRedemptionEvent = pool_events::two_resource_pool::RedemptionEvent;
type TwoResourcePoolWithdrawEvent = pool_events::two_resource_pool::WithdrawEvent;
type TwoResourcePoolDepositEvent = pool_events::two_resource_pool::DepositEvent;

type MultiResourcePoolContributionEvent = pool_events::multi_resource_pool::ContributionEvent;
type MultiResourcePoolRedemptionEvent = pool_events::multi_resource_pool::RedemptionEvent;
type MultiResourcePoolWithdrawEvent = pool_events::multi_resource_pool::WithdrawEvent;
type MultiResourcePoolDepositEvent = pool_events::multi_resource_pool::DepositEvent;

type FungibleVaultLockFeeEvent = fungible_vault::LockFeeEvent;
type FungibleVaultPayFeeEvent = fungible_vault::PayFeeEvent;
Expand Down
12 changes: 6 additions & 6 deletions radix-engine-queries/src/typed_substate_layout.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,16 @@ pub use radix_engine::blueprints::account::{AccountBlueprint, AccountError, Acco
use radix_engine::blueprints::account::{AccountTypedSubstateKey, AccountTypedSubstateValue};
pub use radix_engine::blueprints::consensus_manager::*;
pub use radix_engine::blueprints::package::*;
pub use radix_engine::blueprints::pool::multi_resource_pool;
use radix_engine::blueprints::pool::multi_resource_pool::{
pub use radix_engine::blueprints::pool::v1::substates::multi_resource_pool;
use radix_engine::blueprints::pool::v1::substates::multi_resource_pool::{
MultiResourcePoolTypedSubstateKey, MultiResourcePoolTypedSubstateValue,
};
pub use radix_engine::blueprints::pool::one_resource_pool;
use radix_engine::blueprints::pool::one_resource_pool::{
pub use radix_engine::blueprints::pool::v1::substates::one_resource_pool;
use radix_engine::blueprints::pool::v1::substates::one_resource_pool::{
OneResourcePoolTypedSubstateKey, OneResourcePoolTypedSubstateValue,
};
pub use radix_engine::blueprints::pool::two_resource_pool;
use radix_engine::blueprints::pool::two_resource_pool::{
pub use radix_engine::blueprints::pool::v1::substates::two_resource_pool;
use radix_engine::blueprints::pool::v1::substates::two_resource_pool::{
TwoResourcePoolTypedSubstateKey, TwoResourcePoolTypedSubstateValue,
};
pub use radix_engine::blueprints::resource::*;
Expand Down
55 changes: 55 additions & 0 deletions radix-engine-tests/assets/metering/cost_radiswap_pools_v1_1.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
Total Cost (XRD) , 0.57356037273, 100.0%
- Execution Cost (XRD) , 0.3676254, 64.1%
- Finalization Cost (XRD) , 0.0427613, 7.5%
- Tipping Cost (XRD) , 0, 0.0%
- Storage Cost (XRD) , 0.16317367273, 28.4%
- Tipping Cost (XRD) , 0, 0.0%
- Royalty Cost (XRD) , 0, 0.0%
Execution Cost Breakdown , 7352508, 100.0%
- AfterInvoke , 1444, 0.0%
- AllocateNodeId , 3395, 0.0%
- BeforeInvoke , 3714, 0.1%
- CloseSubstate , 75852, 1.0%
- CreateNode , 31054, 0.4%
- DropNode , 53650, 0.7%
- EmitEvent , 6566, 0.1%
- LockFee , 500, 0.0%
- MarkSubstateAsTransient , 165, 0.0%
- OpenSubstate::GlobalAccount , 656205, 8.9%
- OpenSubstate::GlobalFungibleResourceManager , 425889, 5.8%
- OpenSubstate::GlobalGenericComponent , 44192, 0.6%
- OpenSubstate::GlobalPackage , 2671378, 36.3%
- OpenSubstate::GlobalTwoResourcePool , 657608, 8.9%
- OpenSubstate::InternalFungibleVault , 355473, 4.8%
- OpenSubstate::InternalGenericComponent , 125641, 1.7%
- PinNode , 408, 0.0%
- PrepareWasmCode , 504358, 6.9%
- QueryActor , 4500, 0.1%
- ReadSubstate , 743734, 10.1%
- RunNativeCode::Worktop_drain , 11224, 0.2%
- RunNativeCode::Worktop_drop , 17918, 0.2%
- RunNativeCode::Worktop_put , 58066, 0.8%
- RunNativeCode::Worktop_take_all , 14602, 0.2%
- RunNativeCode::create_empty_vault_FungibleResourceManager , 35570, 0.5%
- RunNativeCode::get_amount_FungibleBucket , 88128, 1.2%
- RunNativeCode::get_amount_FungibleVault , 28902, 0.4%
- RunNativeCode::get_resource_address_FungibleBucket , 17768, 0.2%
- RunNativeCode::get_vault_amounts_two_resource_pool , 47047, 0.6%
- RunNativeCode::lock_fee , 116047, 1.6%
- RunNativeCode::protected_deposit_two_resource_pool , 55718, 0.8%
- RunNativeCode::protected_withdraw_two_resource_pool , 38847, 0.5%
- RunNativeCode::put_FungibleVault , 49108, 0.7%
- RunNativeCode::take_FungibleVault , 42457, 0.6%
- RunNativeCode::take_advanced_FungibleVault , 44567, 0.6%
- RunNativeCode::try_deposit_batch_or_abort , 121257, 1.6%
- RunNativeCode::withdraw , 57851, 0.8%
- RunWasmCode::Radiswap_swap , 95299, 1.3%
- ValidateTxPayload , 13120, 0.2%
- VerifyTxSignatures , 14000, 0.2%
- WriteSubstate , 19286, 0.3%
Finalization Cost Breakdown , 855226, 100.0%
- CommitEvents , 55131, 6.4%
- CommitLogs , 0, 0.0%
- CommitStateUpdates::GlobalAccount , 100011, 11.7%
- CommitStateUpdates::GlobalGenericComponent , 100010, 11.7%
- CommitStateUpdates::InternalFungibleVault , 600074, 70.2%
1 change: 1 addition & 0 deletions radix-engine-tests/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
// Provides assets paths to benchmarks.
pub mod common;
pub mod pool_stubs;
Loading

0 comments on commit c69e16d

Please sign in to comment.