Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Build many TXIntents for batch of TX applying Security Shield #349

Open
wants to merge 59 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
59 commits
Select commit Hold shift + click to select a range
d014fee
[no-ci] WIP
CyonAlexRDX Jan 29, 2025
0909f49
Merge branch 'main' into ac/payloads_to_sign_for_applying_shield_abw-…
Sajjon Jan 30, 2025
9a6e841
wip
Sajjon Jan 30, 2025
7b9b5a4
[no ci] WIP
Sajjon Jan 30, 2025
0302a1a
[no ci] wip
CyonAlexRDX Jan 30, 2025
7950810
[no ci] wip
CyonAlexRDX Jan 30, 2025
cd0467b
[no ci] WIP
Sajjon Jan 30, 2025
c85dacd
[no ci] wip
CyonAlexRDX Jan 30, 2025
bc6ef9c
[no ci] WIP
Sajjon Jan 30, 2025
2f0f6c6
[no ci] WIP
Sajjon Jan 30, 2025
0f7fc7f
[no ci] WIP
Sajjon Jan 30, 2025
a4a8a75
[no ci] WIP
Sajjon Jan 30, 2025
652a7db
[no ci] WIP
Sajjon Jan 31, 2025
4bbea33
[no ci] WIP
Sajjon Jan 31, 2025
911cb44
[no ci] wip
CyonAlexRDX Jan 31, 2025
4182575
[no ci] wip
CyonAlexRDX Jan 31, 2025
1119a7d
[no ci] wip
CyonAlexRDX Jan 31, 2025
d5f2d6f
Merge branch 'main' into ac/payloads_to_sign_for_applying_shield_abw-…
Sajjon Jan 31, 2025
6ce4a60
add XRD vault address to SecuredEntityControl
Sajjon Jan 31, 2025
dcfbe8b
Reject Shaku since hard to retrofit with SargonOS. Or at least I fail…
Sajjon Jan 31, 2025
bc1e5d2
Do Reject Shaku since hard to retrofit with SargonOS. Or at least I f…
CyonAlexRDX Jan 31, 2025
acfb3ab
[no ci] wip
CyonAlexRDX Jan 31, 2025
fb7a37b
[no ci] wip
CyonAlexRDX Jan 31, 2025
9ec9850
[no ci] WIP
Sajjon Feb 3, 2025
0af5525
[no ci] WIP
Sajjon Feb 3, 2025
66ddd5e
[no ci] WIP
Sajjon Feb 3, 2025
729a690
[no ci] wip
CyonAlexRDX Feb 3, 2025
2b6213f
[no ci] wip
CyonAlexRDX Feb 3, 2025
359f26f
[no ci] wip
CyonAlexRDX Feb 3, 2025
fe0b2bf
[no ci] WIP
Sajjon Feb 3, 2025
adae814
[no ci] WIP
Sajjon Feb 3, 2025
6dc55a7
[no ci] WIP
Sajjon Feb 3, 2025
7cb25a3
[no ci] WIP
Sajjon Feb 3, 2025
c1a9792
[no ci] WIP
Sajjon Feb 3, 2025
05903de
[no ci] WIP
Sajjon Feb 3, 2025
0376a9e
cleanup
Sajjon Feb 4, 2025
53c2d6d
lock fee against fee payer of unsecurified account if any
Sajjon Feb 4, 2025
c0de34e
merge
CyonAlexRDX Feb 4, 2025
b5fa66b
[no ci] wip
CyonAlexRDX Feb 4, 2025
248aabf
[no ci] wip
CyonAlexRDX Feb 5, 2025
73f94f9
Merge branch 'main' into ac/payloads_to_sign_for_applying_shield_abw-…
CyonAlexRDX Feb 5, 2025
8a9f610
[no ci] wip
CyonAlexRDX Feb 5, 2025
81e7197
[no ci] wip
CyonAlexRDX Feb 6, 2025
8b722bd
[no ci] WIP
Sajjon Feb 6, 2025
ad3bd25
[no ci] WIP
Sajjon Feb 6, 2025
5876363
ci
Sajjon Feb 6, 2025
0635a54
refactor mock driver
Sajjon Feb 6, 2025
9ea8d4f
fix typos
Sajjon Feb 6, 2025
99f3bfc
cleanup
Sajjon Feb 6, 2025
4d98bc2
test securified account
Sajjon Feb 6, 2025
99c7f59
[no ci] WIP
Sajjon Feb 6, 2025
63ae988
[no ci] wip
CyonAlexRDX Feb 6, 2025
9d09f71
doc and cleanup
Sajjon Feb 6, 2025
4601dc5
cleanup and doc more
Sajjon Feb 7, 2025
d72a8d7
[no ci] WIP
Sajjon Feb 7, 2025
04d523b
polish
CyonAlexRDX Feb 7, 2025
99baa0b
Merge branch 'main' into ac/payloads_to_sign_for_applying_shield_abw-…
Sajjon Feb 7, 2025
5b1f232
update links
Sajjon Feb 7, 2025
a5e2e68
more tests
CyonAlexRDX Feb 7, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
[no ci] wip
  • Loading branch information
CyonAlexRDX committed Feb 4, 2025
commit b5fa66bdb8237709b8d2a29f767a863c6eba803a
Original file line number Diff line number Diff line change
Expand Up @@ -152,19 +152,18 @@ impl OsApplySecurityShieldInteraction for SargonOS {
.map(|e| {
let provisional = e.entity.get_provisional().expect("Entity should have a provisional config set since we applied shield above");
let derived = provisional.as_factor_instances_derived().expect("Should have derived factors");
TransactionManifest::apply_security_shield_for_securified_entity(
let manifest = TransactionManifest::apply_security_shield_for_securified_entity(
e.clone(),
derived.clone(),
RolesExercisableInTransactionManifestCombination::manifest_end_user_gets_to_preview()
).inspect(|m| {
manifests_for_entity.insert(
EntityApplyingShieldAddress::AccessController(
e.securified_entity_control.access_controller_address()
),
m.clone()
);
})
.map(UnvalidatedTransactionManifest::from).unwrap()
);
manifests_for_entity.insert(
EntityApplyingShieldAddress::AccessController(
e.securified_entity_control.access_controller_address()
),
manifest.clone()
);
UnvalidatedTransactionManifest::from(manifest)
}).collect_vec();

// TODO: when RET PR https://github.com/radixdlt/radix-engine-toolkit/pull/132
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,17 +55,108 @@ impl ApplySecurityShieldCommitting for SargonOS {
}
}

#[cfg(test)]
mod tests {
use super::*;

#[actix_rt::test]
async fn test() {
let os = SargonOS::fast_boot().await;
os.sign_and_enqueue_batch_of_transactions_applying_security_shield(
NetworkID::Mainnet,
IndexSet::new(),
)
.await;
}
}
// #[cfg(test)]
// mod tests {
// use super::*;

// #[actix_rt::test]
// async fn test() {
// let (os, bdfs) = SargonOS::with_bdfs().await;

// let ledger = FactorSource::sample_at(1);
// let arculus = FactorSource::sample_at(3);
// let password = FactorSource::sample_at(5);
// let off_device_mnemonic = FactorSource::sample_at(7);
// os.add_factor_source(ledger).await;
// os.add_factor_source(arculus).await;
// os.add_factor_source(password).await;
// os.add_factor_source(off_device_mnemonic).await;

// let shield_builder = SecurityShieldBuilder::lenient();

// let shield = shield_builder
// .add_factor_source_to_primary_threshold(bdfs.factor_source_id())
// .add_factor_source_to_primary_threshold(ledger.factor_source_id())
// .add_factor_source_to_recovery_override(password.factor_source_id())
// .add_factor_source_to_recovery_override(
// off_device_mnemonic.factor_source_id(),
// )
// .build()
// .unwrap();

// let shield_id = shield.id();

// os.add_security_structure_of_factor_source_ids(shield)
// .await
// .unwrap();

// let alice = os
// .create_and_save_new_mainnet_account_with_main_bdfs(
// DisplayName::new("Alice").unwrap(),
// )
// .await
// .unwrap()
// .address;

// let bob = os
// .create_and_save_new_mainnet_account_with_main_bdfs(
// DisplayName::new("Bob").unwrap(),
// )
// .await
// .unwrap()
// .address;

// let carol = os
// .create_and_save_new_mainnet_account_with_main_bdfs(
// DisplayName::new("Bob").unwrap(),
// )
// .await
// .unwrap()
// .address;

// let manifests = os
// .make_interaction_for_applying_security_shield(
// shield_id,
// IndexSet::from_iter([alice.clone(), bob.clone()]),
// )
// .await
// .unwrap()
// .transactions
// .iter();

// // ============================================
// // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// // User reviews TXs in Radix Wallet app and
// // selects fee payer (optional) and slides to
// // sign.
// // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// // ============================================
// let manifest_and_payer_tuples =
// IndexSet::from_iter(
// [
// ManifestWithPayerByAddress::new(
// manifests.next().unwrap(),
// None,
// Decimal::five(),
// ),
// ManifestWithPayerByAddress::new(
// manifests.next().unwrap(),
// None,
// Decimal::five(),
// ),
// ]
// );

// // os.sign_and_enqueue_batch_of_transactions_applying_security_shield(
// // NetworkID::Mainnet,
// // IndexSet::new(),
// // )
// // .await;

// let mut committer = ApplyShieldTransactionsCommitterImpl::new(&os)?;

// committer
// .commit(network_id, manifest_and_payer_tuples)
// .await
// }
// }
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,21 @@ use crate::prelude::*;

#[derive(Clone, Debug, PartialEq, Eq)]
pub struct ManifestWithPayerByAddress {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will use Radix Engine toolkit to extract entity_applying_shield: AddressOfAccountOrPersonaOrAccessController from manifest

/// `None` is invalid if `entity_applying_shield` is a Persona.
/// Some(Account) if `entity_applying_shield` is an Account means "use this other account instead"
/// None if `entity_applying_shield` is an Account means "use the account applying the shield"
pub payer: Option<AccountAddress>,
pub manifest: TransactionManifest,
pub estimated_xrd_fee: Decimal,
Copy link
Contributor Author

@CyonAlexRDX CyonAlexRDX Feb 4, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we might re-read estimated_xrd_fee from RET. But we had it host, so might as well pass forward to Sargon

}

impl ManifestWithPayerByAddress {
pub fn new(
manifest: TransactionManifest,
payer: impl Into<Option<AccountAddress>>,
estimated_xrd_fee: Decimal,
) -> Self {
Self {
payer: payer.into(),
manifest,
estimated_xrd_fee,
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ pub trait TransactionManifestSecurifySecurifiedEntity:
security_structure_of_factor_instances:
SecurityStructureOfFactorInstances,
roles_combination: RolesExercisableInTransactionManifestCombination,
) -> Option<TransactionManifest>;
) -> TransactionManifest;
}

impl TransactionManifestSecurifySecurifiedEntity for TransactionManifest {
Expand All @@ -34,7 +34,7 @@ impl TransactionManifestSecurifySecurifiedEntity for TransactionManifest {
security_structure_of_factor_instances:
SecurityStructureOfFactorInstances,
roles_combination: RolesExercisableInTransactionManifestCombination,
) -> Option<Self> {
) -> Self {
let securified_entity = securified_entity.into();
let kind = roles_combination;
let entity_address = securified_entity.entity.address();
Expand Down Expand Up @@ -124,7 +124,7 @@ impl TransactionManifestSecurifySecurifiedEntity for TransactionManifest {
// after user has selected account to pay in wallet GUI. And also call
// `modify_manifest_add_lock_fee_against_xrd_vault_of_access_controller`

Some(manifest)
manifest
}
}

Expand Down Expand Up @@ -154,7 +154,7 @@ mod tests {
entity_applying_shield.clone(),
SecurityStructureOfFactorInstances::sample(),
RolesExercisableInTransactionManifestCombination::InitiateWithPrimaryCompleteWithConfirmation,
).unwrap();
);

let expected_manifest_str =
fixture_rtm!("update_shield_of_account_init_with_P_confirm_with_C");
Expand Down