diff --git a/Cargo.lock b/Cargo.lock index 05ef979dc0..513a18f56c 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -441,6 +441,9 @@ name = "bitflags" version = "2.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b4682ae6287fcf752ecaabbfcc7b6f9b72aa33933dc23a554d853aea8eea8635" +dependencies = [ + "serde", +] [[package]] name = "bitstring" @@ -3084,7 +3087,7 @@ dependencies = [ name = "minotari_console_wallet" version = "0.52.0-pre.1" dependencies = [ - "bitflags 1.3.2", + "bitflags 2.4.0", "blake2", "chrono", "clap 3.2.25", @@ -5508,7 +5511,7 @@ version = "0.52.0-pre.1" dependencies = [ "anyhow", "async-trait", - "bitflags 1.3.2", + "bitflags 2.4.0", "blake2", "bytes 1.4.0", "chrono", @@ -5557,7 +5560,7 @@ name = "tari_comms_dht" version = "0.52.0-pre.1" dependencies = [ "anyhow", - "bitflags 1.3.2", + "bitflags 2.4.0", "chacha20 0.7.3", "chacha20poly1305 0.10.1", "chrono", @@ -5650,7 +5653,7 @@ version = "0.52.0-pre.1" dependencies = [ "async-trait", "bincode", - "bitflags 1.3.2", + "bitflags 2.4.0", "blake2", "borsh", "bytes 0.5.6", diff --git a/applications/minotari_console_wallet/Cargo.toml b/applications/minotari_console_wallet/Cargo.toml index c657a98338..d995faad4f 100644 --- a/applications/minotari_console_wallet/Cargo.toml +++ b/applications/minotari_console_wallet/Cargo.toml @@ -28,7 +28,7 @@ console-subscriber = "0.1.8" # Uncomment for normal use (non tokio-console tracing) tokio = { version = "1.23", features = ["signal"] } -bitflags = "1.3.2" +bitflags = { version = "2.4", features = ["serde"] } chrono = { version = "0.4.19", default-features = false } clap = { version = "3.2", features = ["derive", "env"] } config = "0.13.0" diff --git a/applications/minotari_console_wallet/src/ui/state/app_state.rs b/applications/minotari_console_wallet/src/ui/state/app_state.rs index 55eec71c64..823b0f25de 100644 --- a/applications/minotari_console_wallet/src/ui/state/app_state.rs +++ b/applications/minotari_console_wallet/src/ui/state/app_state.rs @@ -1345,6 +1345,7 @@ pub enum UiTransactionBurnStatus { } bitflags! { + #[derive(Clone)] pub struct TransactionFilter: u8 { const NONE = 0b0000_0000; const ABANDONED_COINBASES = 0b0000_0001; diff --git a/base_layer/core/Cargo.toml b/base_layer/core/Cargo.toml index dfa0e43730..b9d212d1e8 100644 --- a/base_layer/core/Cargo.toml +++ b/base_layer/core/Cargo.toml @@ -38,7 +38,7 @@ tari_common_sqlite = { path = "../../common_sqlite" } async-trait = {version = "0.1.50"} bincode = "1.1.4" -bitflags = "1" +bitflags = { version = "2.4", features = ["serde"] } blake2 = "0.10" borsh = { version = "0.10", features = ["const-generics"] } bytes = "0.5" diff --git a/base_layer/core/src/blocks/faucets/esmeralda_faucet.json b/base_layer/core/src/blocks/faucets/esmeralda_faucet.json index 812e54348e..cf73781e62 100644 --- a/base_layer/core/src/blocks/faucets/esmeralda_faucet.json +++ b/base_layer/core/src/blocks/faucets/esmeralda_faucet.json @@ -453,4 +453,4 @@ {"version":"V0","features":{"version":"V0","output_type":0,"maturity":3558240,"coinbase_extra":[],"sidechain_feature":null,"range_proof_type":"RevealedValue"},"commitment":"2c3dcafffc9a79dc10f6384d83519ba6b573acd4b03bad7dbb186166737fe851","proof":null,"script":"73","sender_offset_public_key":"ecc5a231ca6f0f14212d35cf91ca6ff5209396fa21f704ad9e2a127c33a04504","metadata_signature":{"ephemeral_commitment":"064193cf5831b2c35ba47230a3e3193e8878fc941b7d5cc48ef7b666d246ac6d","ephemeral_pubkey":"64779a975a3c07260a2d9cf8720852001e24de02f2dfea8b3de070e7b815e445","u_a":"082cddc87ad4086903383abad7cfb78b92a4b98b78c53bc4749ed122d431e50d","u_x":"329491fc8451e899b13d3eac400e304270b9712761d166603bea517ac6114100","u_y":"bd97658e77dcb35b0af01473abc0fa02ceb077083e4407b78645589b28f7d80e"},"covenant":"","encrypted_data":{"data":"0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"},"minimum_value_promise":1067769369090} {"version":"V0","features":{"version":"V0","output_type":0,"maturity":3568320,"coinbase_extra":[],"sidechain_feature":null,"range_proof_type":"RevealedValue"},"commitment":"8cfc7c799721948ebbafbe8a7c386b43a72c02437191101090f16b2b98abc12c","proof":null,"script":"73","sender_offset_public_key":"d4f0710d42a72f5137b37d249bd9332fac41d0feef921a2646ffc1b318fcfc55","metadata_signature":{"ephemeral_commitment":"8acf637ed7bfbd8f6485a8fd1fc5deb67057aee73334b18b0fb9697162b0fb62","ephemeral_pubkey":"a81f809b36076379c61e5b75452854ae953ce56bf9649dc511e7cd15adc7262a","u_a":"6831907ab5355a0574451af3fbcab837477abaa97284a27bee6c034cee2aa909","u_x":"b2d7250e3ca94807dafab8fb0df35294fe3d25d0371b214733d2b6833aa76d03","u_y":"e0b4c7a236ad800f29de5a2dc7b6715c71eb41111e18be2eebe5a9999a296a09"},"covenant":"","encrypted_data":{"data":"0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"},"minimum_value_promise":1058372253648} {"version":"V0","features":{"version":"V0","output_type":0,"maturity":3574176,"coinbase_extra":[],"sidechain_feature":null,"range_proof_type":"RevealedValue"},"commitment":"885306808c95dc65708bb406f3124f5a374d00a3f6111f6c5a26147be285d806","proof":null,"script":"73","sender_offset_public_key":"cc8cb1c24250ec490c577374bd1c7651aab9454ff982bed90c3ccfb426411f2d","metadata_signature":{"ephemeral_commitment":"faa2adb0cb7b50dcb67a0d870b628654969c4964365122dc585e1f0995b35810","ephemeral_pubkey":"629a1b26f1d5692da25868cd2d6eeb2f057e3dadd01ff7510475f1aecf048f07","u_a":"dc36aa0ae126630423b3096bb97efd42d9c9f951fac43ee8618965072dd22c07","u_x":"c9920aed9752b28fd344a8e3508de575e14722d655d3bb059667b4d11c86e204","u_y":"20d175e6da0fbccdb338cae156908abe055637aa01375fb22cedcde4d75e6703"},"covenant":"","encrypted_data":{"data":"0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"},"minimum_value_promise":610482446047} -{"version":"V0","features":{"bits":0},"fee":0,"lock_height":0,"excess":"ea6d44e2e369bec0c41bc23ebb3b7a9e1b06ad33b3a288e461a2fd229eb60122","excess_sig":{"public_nonce":"ea7f16718149ca831535b9109d0014c4f14ec6af59a5ebb7fed0c943c2cc1853","signature":"493edf49b9c1de9ebd6e1fa03c076260682c7767c9c9b5934f97ec8ff6513100"},"burn_commitment":null} +{"version":"V0","features":0,"fee":0,"lock_height":0,"excess":"ea6d44e2e369bec0c41bc23ebb3b7a9e1b06ad33b3a288e461a2fd229eb60122","excess_sig":{"public_nonce":"ea7f16718149ca831535b9109d0014c4f14ec6af59a5ebb7fed0c943c2cc1853","signature":"493edf49b9c1de9ebd6e1fa03c076260682c7767c9c9b5934f97ec8ff6513100"},"burn_commitment":null} diff --git a/base_layer/core/src/blocks/faucets/igor_faucet.json b/base_layer/core/src/blocks/faucets/igor_faucet.json index 25e6b97ed1..a5dcdd0eae 100644 --- a/base_layer/core/src/blocks/faucets/igor_faucet.json +++ b/base_layer/core/src/blocks/faucets/igor_faucet.json @@ -5524,4 +5524,4 @@ {"version":"V0","features":{"version":"V0","output_type":0,"maturity":11081144,"coinbase_extra":[],"sidechain_feature":null,"range_proof_type":"RevealedValue"},"commitment":"36ce6daabb0c724a25a448a28259d88ded75414a033ce0137c99acab5f033773","proof":null,"script":"73","sender_offset_public_key":"e0ee3b5f210fe858b5b5c088938b9c4b67bd265e3019836e1155abc133c3ff20","metadata_signature":{"ephemeral_commitment":"24e12529821d207d5aefe0b78e5d26e058555f07cef39be82b669b9ec8151d21","ephemeral_pubkey":"4c862f60bd8d92b72426784ed35666ac14a288d4b3a9a020fe6316399a7af14f","u_a":"5e37d07ac483f3beaf8259bcce1367c48d4ee5f905446a7fe364419984d2c301","u_x":"ae5918a416392930323764c67a08f223b2c85dca1609a8269e76e21cdfce3a0a","u_y":"dbd906f08bc6ef50d15eac666d841015d611955330821416ef0711b1040f170d"},"covenant":"","encrypted_data":{"data":"0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"},"minimum_value_promise":1054066742} {"version":"V0","features":{"version":"V0","output_type":0,"maturity":11083150,"coinbase_extra":[],"sidechain_feature":null,"range_proof_type":"RevealedValue"},"commitment":"a254a0a59d30f8b1abde585a95103fda75a606e91bef66297528a5d6d1b0d301","proof":null,"script":"73","sender_offset_public_key":"b83923e9d6a0a4279232e4c2177baa99c2af1a0e3015b6559a950040ba296124","metadata_signature":{"ephemeral_commitment":"0c8d3c501de829d1e5a91c8e801ddb31344fc23b3611e657b0ffee4256996c55","ephemeral_pubkey":"963aec71faf233eed8db74bfb2196f0ba18899a0f59f2abba8bc38a08ab0fe2b","u_a":"aba654b0b8a6246847c1f45f79d45339697caea32f8780e6a80c953e5a45db05","u_x":"f750ccbdeaf4a5efc69b81048c23bb3586c33b317a30231405327a4f047bc40e","u_y":"691fbb99393d30a4c7271501dd3edce5a2304a5ff93221f7827efd745f22da04"},"covenant":"","encrypted_data":{"data":"0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"},"minimum_value_promise":1053060734} {"version":"V0","features":{"version":"V0","output_type":0,"maturity":11084819,"coinbase_extra":[],"sidechain_feature":null,"range_proof_type":"RevealedValue"},"commitment":"b2467bab3f68c868c086cda08657bf74f959b53dc850b1ddfa902149ee01a857","proof":null,"script":"73","sender_offset_public_key":"1a5699ea448bdec8ab14df106892c8b59e23bcb08a0de35ab933f9cc04a66260","metadata_signature":{"ephemeral_commitment":"5ae908c58cef55c9b9c5e146e8c79dfcb2a7d1932d2d55af87cee1ca65954174","ephemeral_pubkey":"78438373e9cd7f5630e5475cc300a73a000e00fbf68b67072821b474a0af1d60","u_a":"03492fb6286f5ca19f8a496002883407ec880b191a33c90a2fb6a74c21784209","u_x":"60b8b6f13b5924b9b296b4fc903fe62ca1df4fcb5d7fbc2b8f62d94e0832df0b","u_y":"fe55c8a399ee5633abf84dda04c63ecd0cb37ed3ae3d4a5963f991870d426205"},"covenant":"","encrypted_data":{"data":"0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"},"minimum_value_promise":874859744} -{"version":"V0","features":{"bits":0},"fee":0,"lock_height":0,"excess":"32a0bb0088f6d8d454a1863ccdef0be227c58f4102d97107797cfba8e4ace978","excess_sig":{"public_nonce":"ecf229e5e4422e32def4ba8fcbab6c42c0d9a526707af5b0d6ec316e7b1c4a18","signature":"957a5fa257d56c58d053d7c6cb5d2704e5b5f4b80e196d359ed6f93f8183050c"},"burn_commitment":null} +{"version":"V0","features":0,"fee":0,"lock_height":0,"excess":"32a0bb0088f6d8d454a1863ccdef0be227c58f4102d97107797cfba8e4ace978","excess_sig":{"public_nonce":"ecf229e5e4422e32def4ba8fcbab6c42c0d9a526707af5b0d6ec316e7b1c4a18","signature":"957a5fa257d56c58d053d7c6cb5d2704e5b5f4b80e196d359ed6f93f8183050c"},"burn_commitment":null} diff --git a/base_layer/core/src/blocks/genesis_block.rs b/base_layer/core/src/blocks/genesis_block.rs index 5d320a6ac6..95d9e516f5 100644 --- a/base_layer/core/src/blocks/genesis_block.rs +++ b/base_layer/core/src/blocks/genesis_block.rs @@ -479,7 +479,7 @@ mod test { let utxo_sum = block.block().body.outputs().iter().map(|o| &o.commitment).sum(); let kernel_sum = block.block().body.kernels().iter().map(|k| &k.excess).sum(); - let db = create_new_blockchain_with_network(Network::Igor); + let db = create_new_blockchain_with_network(network); let lock = db.db_read_access().unwrap(); ChainBalanceValidator::new(ConsensusManager::builder(network).build().unwrap(), Default::default()) diff --git a/base_layer/core/src/transactions/transaction_components/kernel_features.rs b/base_layer/core/src/transactions/transaction_components/kernel_features.rs index 80916f907b..099a07a056 100644 --- a/base_layer/core/src/transactions/transaction_components/kernel_features.rs +++ b/base_layer/core/src/transactions/transaction_components/kernel_features.rs @@ -23,10 +23,12 @@ use borsh::{BorshDeserialize, BorshSerialize}; use serde::{Deserialize, Serialize}; +/// Options for a kernel's structure or use. +#[derive(Serialize, Deserialize, BorshSerialize, BorshDeserialize, Clone, Copy, Debug, Eq, PartialEq)] +pub struct KernelFeatures(u8); + bitflags! { - /// Options for a kernel's structure or use. - #[derive(Deserialize, Serialize, BorshSerialize, BorshDeserialize)] - pub struct KernelFeatures: u8 { + impl KernelFeatures: u8 { /// Coinbase transaction const COINBASE_KERNEL = 1u8; /// Burned output transaction diff --git a/comms/core/Cargo.toml b/comms/core/Cargo.toml index 969aa04ee8..709ba3c021 100644 --- a/comms/core/Cargo.toml +++ b/comms/core/Cargo.toml @@ -18,7 +18,7 @@ tari_utilities = { version = "0.5" } anyhow = "1.0.53" async-trait = "0.1.36" -bitflags = "1" +bitflags = { version = "2.4", features = ["serde"] } blake2 = "0.10" bytes = { version = "1", features = ["serde"] } chrono = { version = "0.4.19", default-features = false, features = ["serde", "clock"] } diff --git a/comms/core/src/peer_manager/peer.rs b/comms/core/src/peer_manager/peer.rs index a7ab165a42..3ec13afe13 100644 --- a/comms/core/src/peer_manager/peer.rs +++ b/comms/core/src/peer_manager/peer.rs @@ -49,7 +49,7 @@ use crate::{ bitflags! { /// Miscellaneous Peer flags - #[derive(Default, Deserialize, Serialize)] + #[derive(Default, Deserialize, Serialize, Eq, PartialEq, Debug, Clone, Copy)] pub struct PeerFlags: u8 { const NONE = 0x00; const SEED = 0x01; diff --git a/comms/core/src/peer_manager/peer_features.rs b/comms/core/src/peer_manager/peer_features.rs index 70bff86df4..7be09dca02 100644 --- a/comms/core/src/peer_manager/peer_features.rs +++ b/comms/core/src/peer_manager/peer_features.rs @@ -27,7 +27,7 @@ use serde::{Deserialize, Serialize}; bitflags! { /// Peer feature flags. These advertised the capabilities of peer nodes. - #[derive(Serialize, Deserialize)] + #[derive(Serialize, Deserialize, Clone, Copy, Debug, Eq, PartialEq)] pub struct PeerFeatures: u32 { /// No capabilities const NONE = 0b0000_0000; @@ -37,9 +37,9 @@ bitflags! { const DHT_STORE_FORWARD = 0b0000_0010; /// Node is a communication node (typically a base layer node) - const COMMUNICATION_NODE = Self::MESSAGE_PROPAGATION.bits | Self::DHT_STORE_FORWARD.bits; + const COMMUNICATION_NODE = Self::MESSAGE_PROPAGATION.bits() | Self::DHT_STORE_FORWARD.bits(); /// Node is a network client - const COMMUNICATION_CLIENT = Self::NONE.bits; + const COMMUNICATION_CLIENT = Self::NONE.bits(); } } diff --git a/comms/core/src/protocol/negotiation.rs b/comms/core/src/protocol/negotiation.rs index a5a85294b2..141002487f 100644 --- a/comms/core/src/protocol/negotiation.rs +++ b/comms/core/src/protocol/negotiation.rs @@ -63,6 +63,7 @@ pub struct ProtocolNegotiation<'a, TSocket> { } bitflags! { + #[derive(Debug)] struct Flags: u8 { const NONE = 0x00; const OPTIMISTIC = 0x01; diff --git a/comms/core/src/protocol/rpc/message.rs b/comms/core/src/protocol/rpc/message.rs index b701c89d1a..4722b1e065 100644 --- a/comms/core/src/protocol/rpc/message.rs +++ b/comms/core/src/protocol/rpc/message.rs @@ -196,6 +196,7 @@ impl Into for RpcMethod { } bitflags! { + #[derive(Debug, Clone, Copy)] pub struct RpcMessageFlags: u8 { /// Message stream has completed const FIN = 0x01; diff --git a/comms/dht/Cargo.toml b/comms/dht/Cargo.toml index e7f0fae427..6d0be4e336 100644 --- a/comms/dht/Cargo.toml +++ b/comms/dht/Cargo.toml @@ -20,7 +20,7 @@ tari_storage = { path = "../../infrastructure/storage" } tari_common_sqlite = { path = "../../common_sqlite" } anyhow = "1.0.53" -bitflags = "1" +bitflags = { version = "2.4", features = ["serde"] } chacha20 = "0.7.1" chacha20poly1305 = "0.10.1" chrono = { version = "0.4.19", default-features = false } diff --git a/comms/dht/src/envelope.rs b/comms/dht/src/envelope.rs index 28c87e5be1..e14162b245 100644 --- a/comms/dht/src/envelope.rs +++ b/comms/dht/src/envelope.rs @@ -100,7 +100,7 @@ impl fmt::Display for DhtMessageType { bitflags! { /// Used to indicate characteristics of the incoming or outgoing message, such /// as whether the message is encrypted. - #[derive(Deserialize, Serialize, Default)] + #[derive(Deserialize, Serialize, Default, Copy, Clone, Debug, Eq, PartialEq)] pub struct DhtMessageFlags: u32 { const NONE = 0x00; /// Set if the message is encrypted