Skip to content

Commit

Permalink
Merge pull request #1921 from radixdlt/refactors/further-subintent-fixes
Browse files Browse the repository at this point in the history
Refactors/further subintent fixes
  • Loading branch information
dhedey authored Sep 19, 2024
2 parents a66e830 + 0a39c13 commit 9d47e54
Show file tree
Hide file tree
Showing 42 changed files with 926 additions and 294 deletions.
8 changes: 7 additions & 1 deletion radix-common/src/constants/system_execution.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,18 @@ use crate::data::scrypto::model::NonFungibleLocalId;
use crate::types::*;

/// For definition @see SYSTEM_EXECUTION_RESOURCE
#[derive(Debug, Clone)]
#[derive(Debug, Clone, Copy)]
pub enum SystemExecution {
Protocol = 0,
Validator = 1,
}

impl SystemExecution {
pub fn proof(self) -> NonFungibleGlobalId {
self.into()
}
}

impl Into<NonFungibleGlobalId> for SystemExecution {
fn into(self) -> NonFungibleGlobalId {
NonFungibleGlobalId::new(
Expand Down
4 changes: 2 additions & 2 deletions radix-engine-tests/tests/blueprints/account_locker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3040,7 +3040,7 @@ pub impl DefaultLedgerSimulator {
fn execute_manifest_without_auth(
&mut self,
manifest: TransactionManifestV1,
) -> TransactionReceiptV1 {
) -> TransactionReceipt {
self.execute_manifest_with_enabled_modules(manifest, true, false)
}

Expand All @@ -3049,7 +3049,7 @@ pub impl DefaultLedgerSimulator {
manifest: TransactionManifestV1,
disable_auth: bool,
disable_costing: bool,
) -> TransactionReceiptV1 {
) -> TransactionReceipt {
let mut execution_config =
ExecutionConfig::for_notarized_transaction(NetworkDefinition::mainnet());
execution_config.system_overrides = Some(SystemOverrides {
Expand Down
12 changes: 6 additions & 6 deletions radix-engine-tests/tests/system/crypto_utils.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use radix_common::prelude::*;
use radix_engine::transaction::TransactionReceiptV1;
use radix_engine::transaction::TransactionReceipt;
use radix_engine::vm::NoExtension;
use radix_engine_tests::common::*;
use radix_substate_store_impls::memory_db::InMemorySubstateDatabase;
Expand Down Expand Up @@ -60,7 +60,7 @@ fn crypto_scrypto_bls12381_v1_verify(
msg: Vec<u8>,
pub_key: Bls12381G1PublicKey,
signature: Bls12381G2Signature,
) -> TransactionReceiptV1 {
) -> TransactionReceipt {
runner.execute_manifest(
ManifestBuilder::new()
.lock_fee(runner.faucet_component(), 500u32)
Expand All @@ -81,7 +81,7 @@ fn crypto_scrypto_bls12381_v1_aggregate_verify(
msgs: Vec<Vec<u8>>,
pub_keys: Vec<Bls12381G1PublicKey>,
signature: Bls12381G2Signature,
) -> TransactionReceiptV1 {
) -> TransactionReceipt {
let pub_keys_msgs: Vec<(Bls12381G1PublicKey, Vec<u8>)> = pub_keys
.iter()
.zip(msgs)
Expand All @@ -108,7 +108,7 @@ fn crypto_scrypto_bls12381_v1_fast_aggregate_verify(
msg: Vec<u8>,
pub_keys: Vec<Bls12381G1PublicKey>,
signature: Bls12381G2Signature,
) -> TransactionReceiptV1 {
) -> TransactionReceipt {
runner.execute_manifest(
ManifestBuilder::new()
.lock_fee(runner.faucet_component(), 500u32)
Expand All @@ -127,7 +127,7 @@ fn crypto_scrypto_bls12381_g2_signature_aggregate(
runner: &mut LedgerSimulator<NoExtension, InMemorySubstateDatabase>,
package_address: PackageAddress,
signatures: Vec<Bls12381G2Signature>,
) -> TransactionReceiptV1 {
) -> TransactionReceipt {
runner.execute_manifest(
ManifestBuilder::new()
.lock_fee(runner.faucet_component(), 500u32)
Expand All @@ -146,7 +146,7 @@ fn crypto_scrypto_keccak256_hash(
runner: &mut LedgerSimulator<NoExtension, InMemorySubstateDatabase>,
package_address: PackageAddress,
data: Vec<u8>,
) -> TransactionReceiptV1 {
) -> TransactionReceipt {
runner.execute_manifest(
ManifestBuilder::new()
.lock_fee(runner.faucet_component(), 500u32)
Expand Down
6 changes: 3 additions & 3 deletions radix-engine-tests/tests/system/proxy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ fn get_price_in_oracle_directly(
ledger: &mut DefaultLedgerSimulator,
oracle_address: ComponentAddress,
resources: &IndexMap<String, ResourceAddress>,
) -> TransactionReceiptV1 {
) -> TransactionReceipt {
let manifest = ManifestBuilder::new()
.lock_fee_from_faucet()
.call_method(
Expand All @@ -131,7 +131,7 @@ fn get_price_in_oracle_via_oracle_proxy(
ledger: &mut DefaultLedgerSimulator,
proxy_address: ComponentAddress,
resources: &IndexMap<String, ResourceAddress>,
) -> TransactionReceiptV1 {
) -> TransactionReceipt {
let manifest = ManifestBuilder::new()
.lock_fee_from_faucet()
.call_method(
Expand Down Expand Up @@ -259,7 +259,7 @@ fn get_price_in_oracle_via_generic_proxy(
ledger: &mut DefaultLedgerSimulator,
proxy_address: ComponentAddress,
resources: &IndexMap<String, ResourceAddress>,
) -> TransactionReceiptV1 {
) -> TransactionReceipt {
let manifest = ManifestBuilder::new()
.lock_fee_from_faucet()
.call_method(
Expand Down
2 changes: 1 addition & 1 deletion radix-engine-tests/tests/system/toolkit_receipt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -727,7 +727,7 @@ fn locked_fees_are_mapped_correctly_in_receipt() {
/// * Checks that the runtime receipt obtained from deserialization equals the runtime receipt
/// obtained from direct conversion (roundtrip property)
fn check_and_convert_receipt_to_runtime_receipt(
receipt: TransactionReceiptV1,
receipt: TransactionReceipt,
) -> RuntimeToolkitTransactionReceipt {
// Convert to a runtime receipt.
let runtime_toolkit_receipt = RuntimeToolkitTransactionReceipt::try_from(receipt).unwrap();
Expand Down
24 changes: 7 additions & 17 deletions radix-engine-toolkit-common/src/receipt/receipt/runtime.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,22 +35,12 @@ impl RuntimeToolkitTransactionReceipt {
}
}

impl TryFrom<VersionedTransactionReceipt> for RuntimeToolkitTransactionReceipt {
impl TryFrom<TransactionReceipt> for RuntimeToolkitTransactionReceipt {
type Error = ToolkitReceiptError;

fn try_from(value: VersionedTransactionReceipt) -> Result<Self, Self::Error> {
match TransactionReceiptVersions::from(value) {
TransactionReceiptVersions::V1(receipt) => receipt.try_into(),
}
}
}

impl TryFrom<TransactionReceiptV1> for RuntimeToolkitTransactionReceipt {
type Error = ToolkitReceiptError;

fn try_from(value: TransactionReceiptV1) -> Result<Self, Self::Error> {
fn try_from(value: TransactionReceipt) -> Result<Self, Self::Error> {
match value {
TransactionReceiptV1 {
TransactionReceipt {
result:
TransactionResult::Commit(CommitResult {
outcome: TransactionOutcome::Success(..),
Expand Down Expand Up @@ -224,7 +214,7 @@ impl TryFrom<TransactionReceiptV1> for RuntimeToolkitTransactionReceipt {
non_contingent: execution_trace.fee_locks.lock,
},
}),
TransactionReceiptV1 {
TransactionReceipt {
result:
TransactionResult::Commit(CommitResult {
outcome: TransactionOutcome::Success(..),
Expand All @@ -233,7 +223,7 @@ impl TryFrom<TransactionReceiptV1> for RuntimeToolkitTransactionReceipt {
}),
..
} => Err(ToolkitReceiptError::ReceiptLacksExecutionTrace),
TransactionReceiptV1 {
TransactionReceipt {
result:
TransactionResult::Commit(CommitResult {
outcome: TransactionOutcome::Failure(error),
Expand All @@ -243,13 +233,13 @@ impl TryFrom<TransactionReceiptV1> for RuntimeToolkitTransactionReceipt {
} => Ok(Self::CommitFailure {
reason: format!("{error:?}"),
}),
TransactionReceiptV1 {
TransactionReceipt {
result: TransactionResult::Reject(error),
..
} => Ok(Self::Reject {
reason: format!("{error:?}"),
}),
TransactionReceiptV1 {
TransactionReceipt {
result: TransactionResult::Abort(error),
..
} => Ok(Self::Abort {
Expand Down
2 changes: 1 addition & 1 deletion radix-engine/src/system/bootstrap.rs
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ pub struct ManifestGenesisResource {
// Various helper utilities for constructing and executing genesis
//==========================================================================================

#[derive(Debug, Clone, ScryptoSbor)]
#[derive(Debug, Clone)]
pub struct GenesisReceipts {
pub system_flash_receipt: TransactionReceipt,
pub system_bootstrap_receipt: TransactionReceipt,
Expand Down
22 changes: 9 additions & 13 deletions radix-engine/src/system/system_callback.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1053,7 +1053,7 @@ impl<V: SystemCallbackObject> System<V> {
result: TransactionResult,
print_execution_summary: bool,
costing_module: CostingModule,
) -> TransactionReceiptV1 {
) -> TransactionReceipt {
let (fee_reserve, cost_breakdown, detailed_cost_breakdown) =
costing_module.unpack_for_receipt();
let (finalization_summary, costing_parameters, transaction_costing_parameters) =
Expand All @@ -1074,7 +1074,7 @@ impl<V: SystemCallbackObject> System<V> {
fn create_rejection_receipt(
reason: impl Into<RejectionReason>,
modules: SystemModuleMixer,
) -> TransactionReceiptV1 {
) -> TransactionReceipt {
Self::create_non_commit_receipt(
TransactionResult::Reject(RejectResult {
reason: reason.into(),
Expand All @@ -1087,7 +1087,7 @@ impl<V: SystemCallbackObject> System<V> {
fn create_abort_receipt(
reason: impl Into<AbortReason>,
modules: SystemModuleMixer,
) -> TransactionReceiptV1 {
) -> TransactionReceipt {
Self::create_non_commit_receipt(
TransactionResult::Abort(AbortResult {
reason: reason.into(),
Expand All @@ -1102,7 +1102,7 @@ impl<V: SystemCallbackObject> System<V> {
mut track: Track<S>,
modules: SystemModuleMixer,
system_finalization: SystemFinalization,
) -> TransactionReceiptV1 {
) -> TransactionReceipt {
let print_execution_summary = modules.is_kernel_trace_enabled();
let execution_trace_enabled = modules.is_execution_trace_enabled();
let (costing_module, runtime_module, execution_trace_module) = modules.unpack();
Expand Down Expand Up @@ -1218,13 +1218,9 @@ impl<V: SystemCallbackObject> System<V> {
transaction_costing_parameters: TransactionCostingParameters,
fee_summary: TransactionFeeSummary,
result: TransactionResult,
) -> TransactionReceiptV1 {
// TODO - change to TransactionCostingParametersReceiptV1 when we have a plan regarding how
// to break TransactionReceipt compatibility
let transaction_costing_parameters = TransactionCostingParametersReceiptV1 {
tip_percentage: transaction_costing_parameters
.tip
.truncate_to_percentage_u16(),
) -> TransactionReceipt {
let transaction_costing_parameters = TransactionCostingParametersReceiptV2 {
tip_proportion: transaction_costing_parameters.tip.proportion(),
free_credit_in_xrd: transaction_costing_parameters.free_credit_in_xrd,
};

Expand Down Expand Up @@ -1260,7 +1256,7 @@ impl<V: SystemCallbackObject> System<V> {
store: &mut impl BootStore,
executable: &ExecutableTransaction,
init_input: SystemSelfInit,
) -> Result<(VersionedSystemLogic, SystemModuleMixer), TransactionReceiptV1> {
) -> Result<(VersionedSystemLogic, SystemModuleMixer), TransactionReceipt> {
let system_boot = store
.read_boot_substate(
TRANSACTION_TRACKER.as_node_id(),
Expand Down Expand Up @@ -1381,7 +1377,7 @@ impl<V: SystemCallbackObject> KernelTransactionCallbackObject for System<V> {
type Init = SystemInit<V::Init>;
type Executable = ExecutableTransaction;
type ExecutionOutput = Vec<InstructionOutput>;
type Receipt = TransactionReceiptV1;
type Receipt = TransactionReceipt;

fn init<S: BootStore + CommitableSubstateStore>(
store: &mut S,
Expand Down

This file was deleted.

This file was deleted.

Binary file not shown.
Binary file not shown.
Loading

0 comments on commit 9d47e54

Please sign in to comment.