diff --git a/Cargo.lock b/Cargo.lock index 0a44d5d5..fcab061b 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2178,7 +2178,7 @@ dependencies = [ "sp-trie", "sp-version", "staging-xcm", - "trie-db 0.28.0", + "trie-db", ] [[package]] @@ -11482,9 +11482,9 @@ dependencies = [ [[package]] name = "serde_json" -version = "1.0.115" +version = "1.0.116" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "12dc5c46daa8e9fdf4f5e71b6cf9a53f2487da0e86e55808e2d35539666497dd" +checksum = "3e17db7126d17feb94eb3fad46bf1a96b034e8aacbc2e775fe81505f8b0b2813" dependencies = [ "itoa", "ryu", @@ -12135,7 +12135,7 @@ dependencies = [ [[package]] name = "sp-crypto-ec-utils" version = "0.10.0" -source = "git+https://github.com/paritytech/polkadot-sdk#a8f4f4f00f8fc0da512a09e1450bf4cda954d70d" +source = "git+https://github.com/paritytech/polkadot-sdk#753bf2d860e083b5da25fe4171c0e540ddad4888" dependencies = [ "ark-bls12-377", "ark-bls12-377-ext", @@ -12174,7 +12174,7 @@ dependencies = [ [[package]] name = "sp-debug-derive" version = "14.0.0" -source = "git+https://github.com/paritytech/polkadot-sdk#a8f4f4f00f8fc0da512a09e1450bf4cda954d70d" +source = "git+https://github.com/paritytech/polkadot-sdk#753bf2d860e083b5da25fe4171c0e540ddad4888" dependencies = [ "proc-macro2", "quote", @@ -12195,7 +12195,7 @@ dependencies = [ [[package]] name = "sp-externalities" version = "0.25.0" -source = "git+https://github.com/paritytech/polkadot-sdk#a8f4f4f00f8fc0da512a09e1450bf4cda954d70d" +source = "git+https://github.com/paritytech/polkadot-sdk#753bf2d860e083b5da25fe4171c0e540ddad4888" dependencies = [ "environmental", "parity-scale-codec", @@ -12412,7 +12412,7 @@ dependencies = [ [[package]] name = "sp-runtime-interface" version = "24.0.0" -source = "git+https://github.com/paritytech/polkadot-sdk#a8f4f4f00f8fc0da512a09e1450bf4cda954d70d" +source = "git+https://github.com/paritytech/polkadot-sdk#753bf2d860e083b5da25fe4171c0e540ddad4888" dependencies = [ "bytes", "impl-trait-for-tuples", @@ -12444,7 +12444,7 @@ dependencies = [ [[package]] name = "sp-runtime-interface-proc-macro" version = "17.0.0" -source = "git+https://github.com/paritytech/polkadot-sdk#a8f4f4f00f8fc0da512a09e1450bf4cda954d70d" +source = "git+https://github.com/paritytech/polkadot-sdk#753bf2d860e083b5da25fe4171c0e540ddad4888" dependencies = [ "Inflector", "expander 2.1.0", @@ -12501,7 +12501,7 @@ dependencies = [ "sp-trie", "thiserror", "tracing", - "trie-db 0.28.0", + "trie-db", ] [[package]] @@ -12536,7 +12536,7 @@ source = "git+https://github.com/off-narrative-labs/polkadot-sdk?branch=tuxedo-v [[package]] name = "sp-std" version = "14.0.0" -source = "git+https://github.com/paritytech/polkadot-sdk#a8f4f4f00f8fc0da512a09e1450bf4cda954d70d" +source = "git+https://github.com/paritytech/polkadot-sdk#753bf2d860e083b5da25fe4171c0e540ddad4888" [[package]] name = "sp-storage" @@ -12554,7 +12554,7 @@ dependencies = [ [[package]] name = "sp-storage" version = "19.0.0" -source = "git+https://github.com/paritytech/polkadot-sdk#a8f4f4f00f8fc0da512a09e1450bf4cda954d70d" +source = "git+https://github.com/paritytech/polkadot-sdk#753bf2d860e083b5da25fe4171c0e540ddad4888" dependencies = [ "impl-serde", "parity-scale-codec", @@ -12591,7 +12591,7 @@ dependencies = [ [[package]] name = "sp-tracing" version = "16.0.0" -source = "git+https://github.com/paritytech/polkadot-sdk#a8f4f4f00f8fc0da512a09e1450bf4cda954d70d" +source = "git+https://github.com/paritytech/polkadot-sdk#753bf2d860e083b5da25fe4171c0e540ddad4888" dependencies = [ "parity-scale-codec", "tracing", @@ -12643,7 +12643,7 @@ dependencies = [ "sp-std 8.0.0", "thiserror", "tracing", - "trie-db 0.28.0", + "trie-db", "trie-root", ] @@ -12691,7 +12691,7 @@ dependencies = [ [[package]] name = "sp-wasm-interface" version = "20.0.0" -source = "git+https://github.com/paritytech/polkadot-sdk#a8f4f4f00f8fc0da512a09e1450bf4cda954d70d" +source = "git+https://github.com/paritytech/polkadot-sdk#753bf2d860e083b5da25fe4171c0e540ddad4888" dependencies = [ "impl-trait-for-tuples", "log", @@ -13012,7 +13012,7 @@ dependencies = [ "sp-runtime", "sp-state-machine", "sp-trie", - "trie-db 0.28.0", + "trie-db", ] [[package]] @@ -13723,18 +13723,6 @@ dependencies = [ "smallvec", ] -[[package]] -name = "trie-db" -version = "0.29.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "65ed83be775d85ebb0e272914fff6462c39b3ddd6dc67b5c1c41271aad280c69" -dependencies = [ - "hash-db", - "log", - "rustc-hex", - "smallvec", -] - [[package]] name = "trie-root" version = "0.18.0" @@ -13893,7 +13881,7 @@ dependencies = [ "sp-std 8.0.0", "sp-tracing 10.0.0", "sp-trie", - "trie-db 0.29.0", + "trie-db", "tuxedo-core", "tuxedo-parachainify", ] diff --git a/Cargo.toml b/Cargo.toml index 9403ecf8..0318db4f 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -128,7 +128,7 @@ sp-externalities = { branch = "tuxedo-v1.6.0", default_features = false, git = " sp-state-machine = { branch = "tuxedo-v1.6.0", default_features = false, git = "https://github.com/Off-Narrative-Labs/polkadot-sdk" } sp-tracing = { branch = "tuxedo-v1.6.0", default_features = false, git = "https://github.com/Off-Narrative-Labs/polkadot-sdk" } sp-trie = { branch = "tuxedo-v1.6.0", default_features = false, git = "https://github.com/Off-Narrative-Labs/polkadot-sdk" } -trie-db = { version = "0.29.0", default-features = false } +trie-db = { version = "0.28.0", default-features = false } # We need to depend on this explicitly so we can enable the "full-node" feature # See https://github.com/paritytech/polkadot-sdk/issues/2551 for more details diff --git a/tuxedo-core/src/executive.rs b/tuxedo-core/src/executive.rs index 506b56e5..5a79e7d7 100644 --- a/tuxedo-core/src/executive.rs +++ b/tuxedo-core/src/executive.rs @@ -158,7 +158,7 @@ where requires: missing_inputs, provides, priority: 0, - longevity: TransactionLongevity::max_value(), + longevity: TransactionLongevity::MAX, propagate: true, }); } @@ -181,7 +181,7 @@ where requires: Vec::new(), provides, priority: 0, - longevity: TransactionLongevity::max_value(), + longevity: TransactionLongevity::MAX, propagate: true, }) } diff --git a/tuxedo-parachain-core/src/validate_block.rs b/tuxedo-parachain-core/src/validate_block.rs index 197e3ce1..5f21fbc3 100644 --- a/tuxedo-parachain-core/src/validate_block.rs +++ b/tuxedo-parachain-core/src/validate_block.rs @@ -13,7 +13,7 @@ use polkadot_parachain_primitives::primitives::{ }; use tuxedo_core::{ types::{Block, Header, Transaction}, - ConstraintChecker, Executive, Verifier, + Executive, Verifier, }; use parity_scale_codec::Encode; diff --git a/wallet/src/main.rs b/wallet/src/main.rs index 531fbeb6..5615321b 100644 --- a/wallet/src/main.rs +++ b/wallet/src/main.rs @@ -12,7 +12,6 @@ mod amoeba; mod cli; mod keystore; mod money; -mod output_filter; mod parachain; mod rpc; mod sync; @@ -76,7 +75,7 @@ async fn main() -> anyhow::Result<()> { matches![v, OuterVerifier::Sr25519Signature(Sr25519Signature { owner_pubkey }) if crate::keystore::has_key(&keystore, owner_pubkey) - ] || matches![v, OuterVerifier::UpForGrabs(UpForGrabs)] // used for timestamp + ] }; if !sled::Db::was_recovered(&db) { diff --git a/wallet/src/output_filter.rs b/wallet/src/output_filter.rs deleted file mode 100644 index 555fc5a5..00000000 --- a/wallet/src/output_filter.rs +++ /dev/null @@ -1,137 +0,0 @@ -use runtime::{OuterVerifier, Output}; -use sp_core::H256; -use tuxedo_core::types::OutputRef; - -pub type OutputInfo = (Output, OutputRef); - -type TxHash = H256; -/// The Filter type which is the closure signature used by functions to filter UTXOS -pub type Filter = Box Result, ()>>; - -pub trait OutputFilter { - /// The Filter type which is the closure signature used by functions to filter UTXOS - type Filter; - /// Builds a filter to be passed to wallet sync functions to sync the chosen outputs - /// to the users DB. - fn build_filter(verifier: OuterVerifier) -> Self::Filter; -} - -pub struct Sr25519SignatureFilter; -impl OutputFilter for Sr25519SignatureFilter { - // Todo Add filter error - type Filter = Result; - - fn build_filter(verifier: OuterVerifier) -> Self::Filter { - Ok(Box::new(move |outputs, tx_hash| { - let filtered_outputs = outputs - .iter() - .enumerate() - .map(|(i, output)| { - ( - output.clone(), - OutputRef { - tx_hash: *tx_hash, - index: i as u32, - }, - ) - }) - .filter(|(output, _)| output.verifier == verifier) - .collect::>(); - Ok(filtered_outputs) - })) - } -} - -mod tests { - use super::*; - - #[cfg(test)] - use tuxedo_core::{dynamic_typing::DynamicallyTypedData, verifier::*}; - - pub struct TestSr25519SignatureFilter; - impl OutputFilter for TestSr25519SignatureFilter { - type Filter = Result; - - fn build_filter(_verifier: OuterVerifier) -> Self::Filter { - Ok(Box::new(move |_outputs, _tx_hash| { - println!("printed something"); - Ok(vec![]) - })) - } - } - - #[test] - fn filter_prints() { - let verifier = OuterVerifier::Sr25519Signature(Sr25519Signature { - owner_pubkey: H256::zero(), - }); - let output = Output { - verifier: verifier.clone(), - payload: DynamicallyTypedData { - data: vec![], - type_id: *b"1234", - }, - }; - - let my_filter = - TestSr25519SignatureFilter::build_filter(verifier).expect("Can build print filter"); - let _ = my_filter(&[output], &H256::zero()); - } - - #[test] - fn filter_sr25519_signature_works() { - let verifier = OuterVerifier::Sr25519Signature(Sr25519Signature { - owner_pubkey: H256::zero(), - }); - - let outputs_to_filter = vec![ - Output { - verifier: verifier.clone(), - payload: DynamicallyTypedData { - data: vec![], - type_id: *b"1234", - }, - }, - Output { - verifier: OuterVerifier::Sr25519Signature(Sr25519Signature { - owner_pubkey: H256::from_slice(b"asdfasdfasdfasdfasdfasdfasdfasdf"), - }), - payload: DynamicallyTypedData { - data: vec![], - type_id: *b"1234", - }, - }, - Output { - verifier: OuterVerifier::ThresholdMultiSignature(ThresholdMultiSignature { - threshold: 1, - signatories: vec![H256::zero()], - }), - payload: DynamicallyTypedData { - data: vec![], - type_id: *b"1234", - }, - }, - ]; - - let expected_filtered_output_infos = vec![( - Output { - verifier: verifier.clone(), - payload: DynamicallyTypedData { - data: vec![], - type_id: *b"1234", - }, - }, - OutputRef { - tx_hash: H256::zero(), - index: 0, - }, - )]; - - let my_filter = Sr25519SignatureFilter::build_filter(verifier) - .expect("Can build Sr25519Signature filter"); - let filtered_output_infos = my_filter(&outputs_to_filter, &H256::zero()) - .expect("Can filter the outputs by verifier correctly"); - - assert_eq!(filtered_output_infos, expected_filtered_output_infos); - } -} diff --git a/wallet/src/sync.rs b/wallet/src/sync.rs index a0a89945..82c14f96 100644 --- a/wallet/src/sync.rs +++ b/wallet/src/sync.rs @@ -280,16 +280,13 @@ async fn apply_transaction bool, C: ConstraintChecker>( let tx = Transaction::::decode(&mut &encoded_extrinsic[..])?; // Insert all new outputs - for (index, output) in tx - .outputs - .iter() - .filter(|o| filter(&o.verifier)) - .enumerate() - { + for (index, output) in tx.outputs.iter().enumerate() { // For now the wallet only supports simple coins and timestamp match output.payload.type_id { Coin::<0>::TYPE_ID => { - crate::money::apply_transaction(db, tx_hash, index as u32, output)?; + if filter(&output.verifier) { + crate::money::apply_transaction(db, tx_hash, index as u32, output)?; + } } Timestamp::TYPE_ID => { crate::timestamp::apply_transaction(db, output)?; diff --git a/wardrobe/money/src/lib.rs b/wardrobe/money/src/lib.rs index 480ab59a..27efcfdf 100644 --- a/wardrobe/money/src/lib.rs +++ b/wardrobe/money/src/lib.rs @@ -194,10 +194,10 @@ impl SimpleConstraintChecker for MoneyConstraintChecker { // Priority is based on how many token are burned // Type stuff is kinda ugly. Maybe division would be better? let burned = total_input_value - total_output_value; - Ok(if burned < u64::max_value() as u128 { + Ok(if burned < u64::MAX as u128 { burned as u64 } else { - u64::max_value() + u64::MAX }) } Self::Mint => {