diff --git a/Cargo.lock b/Cargo.lock index 2c4e1db5a..a9084dd02 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -5728,20 +5728,6 @@ dependencies = [ "sp-staking", ] -[[package]] -name = "pallet-native-token-management" -version = "1.2.0" -dependencies = [ - "frame-support", - "frame-system", - "log", - "parity-scale-codec", - "scale-info", - "sidechain-domain", - "sp-io", - "sp-native-token-management", -] - [[package]] name = "pallet-partner-chains-session" version = "1.2.0" @@ -6185,7 +6171,6 @@ dependencies = [ "sp-inherents", "sp-io", "sp-keyring", - "sp-native-token-management", "sp-partner-chains-consensus-aura", "sp-runtime", "sp-session-validator-management", @@ -9232,7 +9217,6 @@ dependencies = [ "pallet-balances", "pallet-block-rewards", "pallet-grandpa", - "pallet-native-token-management", "pallet-partner-chains-session", "pallet-session", "pallet-session-runtime-stub", @@ -9262,7 +9246,6 @@ dependencies = [ "sp-inherents", "sp-io", "sp-keyring", - "sp-native-token-management", "sp-offchain", "sp-runtime", "sp-session", @@ -9829,26 +9812,6 @@ dependencies = [ "sp-application-crypto", ] -[[package]] -name = "sp-native-token-management" -version = "1.2.0" -dependencies = [ - "async-trait", - "envy", - "main-chain-follower-api", - "parity-scale-codec", - "scale-info", - "serde", - "sidechain-domain", - "sidechain-mc-hash", - "sp-api", - "sp-blockchain", - "sp-inherents", - "sp-runtime", - "thiserror", - "tokio", -] - [[package]] name = "sp-offchain" version = "34.0.0" diff --git a/Cargo.toml b/Cargo.toml index 1512ce17a..2da8bd76e 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -37,8 +37,6 @@ members = [ "primitives/session-manager", "primitives/sidechain", "partner-chains-cli", - "pallets/native-token-management", - "primitives/native-token-management" ] resolver = "2" @@ -205,8 +203,6 @@ authority-selection-inherents = { path = "primitives/authority-selection-inheren session-manager = { path = "primitives/session-manager", default-features = false } sp-sidechain = { path = "primitives/sidechain", default-features = false } chain-params = { path = "primitives/chain-params", default-features = false } -pallet-native-token-management = { path = "pallets/native-token-management", default-features = false } -sp-native-token-management = { path = "primitives/native-token-management", default-features = false } sc-partner-chains-consensus-aura = { path = "client/consensus/aura", default-features = false } sp-partner-chains-consensus-aura = { path = "primitives/consensus/aura", default-features = false } pallet-partner-chains-session = { path = "pallets/partner-chains-session", default-features = false } diff --git a/node/Cargo.toml b/node/Cargo.toml index 6d2efa3fd..f8ca8a9b8 100644 --- a/node/Cargo.toml +++ b/node/Cargo.toml @@ -91,10 +91,9 @@ frame-benchmarking-cli = { workspace = true } # Local Dependencies sidechain-runtime = { workspace = true } sidechain-mc-hash = { workspace = true, features = ["mock"] } -sp-native-token-management = { workspace = true } main-chain-follower-api = { workspace = true } -db-sync-follower = { workspace = true, features = ["block-source", "candidate-source", "native-token"] } -main-chain-follower-mock = { workspace = true, features = ["block-source", "candidate-source", "native-token"] } +db-sync-follower = { workspace = true, features = ["block-source", "candidate-source"] } +main-chain-follower-mock = { workspace = true, features = ["block-source", "candidate-source"] } tokio = { workspace = true } cli-commands = { workspace = true } diff --git a/node/src/inherent_data.rs b/node/src/inherent_data.rs index eccda60a5..ead8bf0e2 100644 --- a/node/src/inherent_data.rs +++ b/node/src/inherent_data.rs @@ -21,9 +21,6 @@ use sp_consensus_aura::{ }; use sp_core::Pair; use sp_inherents::CreateInherentDataProviders; -use sp_native_token_management::{ - NativeTokenManagementApi, NativeTokenManagementInherentDataProvider as NativeTokenIDP, -}; use sp_partner_chains_consensus_aura::CurrentSlotProvider; use sp_runtime::traits::{Block as BlockT, Header, Zero}; use sp_session_validator_management::SessionValidatorManagementApi; @@ -50,7 +47,6 @@ where AuthoritySelectionInputs, ScEpochNumber, >, - T::Api: NativeTokenManagementApi, { type InherentDataProviders = ( AuraIDP, @@ -58,7 +54,6 @@ where McHashIDP, AriadneIDP, BlockBeneficiaryInherentProvider, - NativeTokenIDP, ); async fn create_inherent_data_providers( @@ -93,22 +88,7 @@ where "SIDECHAIN_BLOCK_BENEFICIARY", )?; - let native_token = NativeTokenIDP::new( - client.clone(), - data_sources.native_token.as_ref(), - mc_hash.mc_hash(), - parent_hash.clone(), - ) - .await?; - - Ok(( - slot, - timestamp, - mc_hash, - ariadne_data_provider, - block_beneficiary_provider, - native_token, - )) + Ok((slot, timestamp, mc_hash, ariadne_data_provider, block_beneficiary_provider)) } } @@ -136,9 +116,8 @@ where AuthoritySelectionInputs, ScEpochNumber, >, - T::Api: NativeTokenManagementApi, { - type InherentDataProviders = (TimestampIDP, AriadneIDP, NativeTokenIDP); + type InherentDataProviders = (TimestampIDP, AriadneIDP); async fn create_inherent_data_providers( &self, @@ -172,15 +151,7 @@ where ) .await?; - let native_token = NativeTokenIDP::new( - client.clone(), - data_sources.native_token.as_ref(), - mc_hash, - parent_hash.clone(), - ) - .await?; - - Ok((timestamp, ariadne_data_provider, native_token)) + Ok((timestamp, ariadne_data_provider)) } } diff --git a/node/src/main_chain_follower.rs b/node/src/main_chain_follower.rs index 3bda0b047..b00822b26 100644 --- a/node/src/main_chain_follower.rs +++ b/node/src/main_chain_follower.rs @@ -1,16 +1,10 @@ -use db_sync_follower::native_token::NativeTokenManagementDataSourceImpl; use db_sync_follower::{ block::{BlockDataSourceImpl, DbSyncBlockDataSourceConfig}, candidates::{cached::CandidateDataSourceCached, CandidatesDataSourceImpl}, metrics::McFollowerMetrics, }; -use main_chain_follower_api::{ - BlockDataSource, CandidateDataSource, NativeTokenManagementDataSource, -}; -use main_chain_follower_mock::{ - block::BlockDataSourceMock, candidate::MockCandidateDataSource, - native_token::NativeTokenDataSourceMock, -}; +use main_chain_follower_api::{BlockDataSource, CandidateDataSource}; +use main_chain_follower_mock::{block::BlockDataSourceMock, candidate::MockCandidateDataSource}; use sc_service::error::Error as ServiceError; use std::error::Error; use std::sync::Arc; @@ -19,7 +13,6 @@ use std::sync::Arc; pub struct DataSources { pub block: Arc, pub candidate: Arc, - pub native_token: Arc, } pub(crate) async fn create_cached_main_chain_follower_data_sources( @@ -58,7 +51,6 @@ pub fn create_mock_data_sources( Ok(DataSources { block: Arc::new(block_data_source_mock), candidate: Arc::new(MockCandidateDataSource::from_env()?), - native_token: Arc::new(NativeTokenDataSourceMock::new()), }) } @@ -80,6 +72,5 @@ pub async fn create_cached_data_sources( CandidatesDataSourceImpl::from_config(pool.clone(), metrics_opt.clone()).await?, CANDIDATES_FOR_EPOCH_CACHE_SIZE, )?), - native_token: Arc::new(NativeTokenManagementDataSourceImpl { pool, metrics_opt }), }) } diff --git a/node/src/staging.rs b/node/src/staging.rs index e3a3143e6..3d5815094 100644 --- a/node/src/staging.rs +++ b/node/src/staging.rs @@ -4,9 +4,8 @@ use chain_params::SidechainParams; use sc_service::ChainType; use sidechain_domain::*; use sidechain_runtime::{ - AccountId, AuraConfig, BalancesConfig, GrandpaConfig, NativeTokenManagementConfig, - RuntimeGenesisConfig, SessionCommitteeManagementConfig, SessionConfig, SidechainConfig, - SudoConfig, SystemConfig, + AccountId, AuraConfig, BalancesConfig, GrandpaConfig, RuntimeGenesisConfig, + SessionCommitteeManagementConfig, SessionConfig, SidechainConfig, SudoConfig, SystemConfig, }; use sp_core::bytes::from_hex; use sp_core::{ed25519, sr25519}; @@ -160,10 +159,6 @@ pub fn staging_genesis( .collect(), main_chain_scripts: sp_session_validator_management::MainChainScripts::read_from_env()?, }, - native_token_management: NativeTokenManagementConfig { - main_chain_scripts: sp_native_token_management::MainChainScripts::read_from_env()?, - ..Default::default() - }, }; Ok(serde_json::to_value(config).expect("Genesis config must be serialized correctly")) diff --git a/node/src/template_chain_spec.rs b/node/src/template_chain_spec.rs index 6440dff10..6ef58b386 100644 --- a/node/src/template_chain_spec.rs +++ b/node/src/template_chain_spec.rs @@ -2,7 +2,7 @@ use crate::chain_spec::*; use chain_params::SidechainParams; use sc_service::ChainType; use sidechain_runtime::{ - AuraConfig, BalancesConfig, GrandpaConfig, NativeTokenManagementConfig, RuntimeGenesisConfig, + AuraConfig, BalancesConfig, GrandpaConfig, RuntimeGenesisConfig, SessionCommitteeManagementConfig, SessionConfig, SidechainConfig, SudoConfig, SystemConfig, }; @@ -38,10 +38,6 @@ pub fn chain_spec() -> Result { initial_authorities: vec![], main_chain_scripts: sp_session_validator_management::MainChainScripts::read_from_env()?, }, - native_token_management: NativeTokenManagementConfig { - main_chain_scripts: sp_native_token_management::MainChainScripts::read_from_env()?, - ..Default::default() - }, }; let genesis_json = serde_json::to_value(runtime_genesis_config) .expect("Genesis config must be serialized correctly"); diff --git a/node/src/testnet.rs b/node/src/testnet.rs index ed4684113..c0c60919f 100644 --- a/node/src/testnet.rs +++ b/node/src/testnet.rs @@ -3,9 +3,8 @@ use chain_params::SidechainParams; use sc_service::ChainType; use sidechain_domain::*; use sidechain_runtime::{ - AccountId, AuraConfig, BalancesConfig, GrandpaConfig, NativeTokenManagementConfig, - RuntimeGenesisConfig, SessionCommitteeManagementConfig, SessionConfig, SidechainConfig, - SudoConfig, SystemConfig, + AccountId, AuraConfig, BalancesConfig, GrandpaConfig, RuntimeGenesisConfig, + SessionCommitteeManagementConfig, SessionConfig, SidechainConfig, SudoConfig, SystemConfig, }; use sidechain_slots::SlotsPerEpoch; use sp_core::bytes::from_hex; @@ -200,10 +199,6 @@ pub fn testnet_genesis( .collect(), main_chain_scripts: sp_session_validator_management::MainChainScripts::read_from_env()?, }, - native_token_management: NativeTokenManagementConfig { - main_chain_scripts: sp_native_token_management::MainChainScripts::read_from_env()?, - ..Default::default() - }, }; Ok(serde_json::to_value(config).expect("Genesis config must be serialized correctly")) diff --git a/node/src/tests/inherent_data_tests.rs b/node/src/tests/inherent_data_tests.rs index 6d6757ef5..668d43026 100644 --- a/node/src/tests/inherent_data_tests.rs +++ b/node/src/tests/inherent_data_tests.rs @@ -3,9 +3,7 @@ use crate::tests::mock::{test_client, test_create_inherent_data_config}; use crate::tests::runtime_api_mock::{mock_header, TestApi}; use authority_selection_inherents::authority_selection_inputs::AuthoritySelectionInputs; use main_chain_follower_api::{block::MainchainBlock, mock_services::*}; -use sidechain_domain::{ - McBlockHash, McBlockNumber, McEpochNumber, McSlotNumber, NativeTokenAmount, ScEpochNumber, -}; +use sidechain_domain::{McBlockHash, McBlockNumber, McEpochNumber, McSlotNumber, ScEpochNumber}; use sp_consensus_aura::Slot; use sp_core::H256; use sp_inherents::CreateInherentDataProviders; @@ -31,15 +29,13 @@ async fn block_proposal_cidp_should_be_created_correctly() { .await .unwrap(); - let (slot, timestamp, mc_hash, ariadne_data, block_beneficiary, native_token) = - inherent_data_providers; + let (slot, timestamp, mc_hash, ariadne_data, block_beneficiary) = inherent_data_providers; let mut inherent_data = InherentData::new(); slot.provide_inherent_data(&mut inherent_data).await.unwrap(); timestamp.provide_inherent_data(&mut inherent_data).await.unwrap(); mc_hash.provide_inherent_data(&mut inherent_data).await.unwrap(); ariadne_data.provide_inherent_data(&mut inherent_data).await.unwrap(); block_beneficiary.provide_inherent_data(&mut inherent_data).await.unwrap(); - native_token.provide_inherent_data(&mut inherent_data).await.unwrap(); assert_eq!( inherent_data .get_data::(&sp_consensus_aura::inherents::INHERENT_IDENTIFIER) @@ -65,10 +61,6 @@ async fn block_proposal_cidp_should_be_created_correctly() { .get_data::(&sp_session_validator_management::INHERENT_IDENTIFIER) .unwrap() .is_some()); - assert!(inherent_data - .get_data::(&sp_native_token_management::INHERENT_IDENTIFIER) - .unwrap() - .is_some()) } #[tokio::test] @@ -94,11 +86,10 @@ async fn block_verification_cidp_should_be_created_correctly() { .create_inherent_data_providers(mock_header().hash(), (30.into(), mc_block_hash)) .await .unwrap(); - let (timestamp, ariadne_data_provider, native_token_provider) = inherent_data_providers; + let (timestamp, ariadne_data_provider) = inherent_data_providers; let mut inherent_data = InherentData::new(); timestamp.provide_inherent_data(&mut inherent_data).await.unwrap(); ariadne_data_provider.provide_inherent_data(&mut inherent_data).await.unwrap(); - native_token_provider.provide_inherent_data(&mut inherent_data).await.unwrap(); assert_eq!( inherent_data.get_data::(&sp_timestamp::INHERENT_IDENTIFIER).unwrap(), @@ -108,8 +99,4 @@ async fn block_verification_cidp_should_be_created_correctly() { .get_data::(&sp_session_validator_management::INHERENT_IDENTIFIER) .unwrap() .is_some()); - assert!(inherent_data - .get_data::(&sp_native_token_management::INHERENT_IDENTIFIER) - .unwrap() - .is_some()) } diff --git a/node/src/tests/mock.rs b/node/src/tests/mock.rs index 43d129668..9716984da 100644 --- a/node/src/tests/mock.rs +++ b/node/src/tests/mock.rs @@ -15,7 +15,7 @@ use std::sync::Arc; impl From for DataSources { fn from(value: TestDataSources) -> Self { - Self { block: value.block, candidate: value.candidate, native_token: value.native_token } + Self { block: value.block, candidate: value.candidate } } } diff --git a/node/src/tests/runtime_api_mock.rs b/node/src/tests/runtime_api_mock.rs index a3fab0f84..93a32f33b 100644 --- a/node/src/tests/runtime_api_mock.rs +++ b/node/src/tests/runtime_api_mock.rs @@ -90,17 +90,6 @@ sp_api::mock_impl_runtime_apis! { } } } - - impl sp_native_token_management::NativeTokenManagementApi for TestApi { - fn get_main_chain_scripts() -> sp_native_token_management::MainChainScripts { - sp_native_token_management::MainChainScripts { - native_token_policy_id: Default::default(), - native_token_asset_name: Default::default(), - illiquid_supply_validator_address: Default::default(), - - } - } - } } impl HeaderBackend for TestApi { diff --git a/runtime/Cargo.toml b/runtime/Cargo.toml index 62a6a29cd..24a38fce4 100644 --- a/runtime/Cargo.toml +++ b/runtime/Cargo.toml @@ -70,8 +70,6 @@ sidechain-domain = { workspace = true, features = ["serde"] } chain-params = { workspace = true, features = ["serde"] } sidechain-slots = { workspace = true } session-manager = { workspace = true } -pallet-native-token-management = { workspace = true } -sp-native-token-management = { workspace = true, features = ["serde"] } pallet-session-runtime-stub = { workspace = true, default-features = false } [dev-dependencies] @@ -142,8 +140,6 @@ std = [ "sidechain-domain/std", "sp-inherents/std", "chain-params/std", - "pallet-native-token-management/std", - "sp-native-token-management/std", "pallet-session-runtime-stub/std", ] diff --git a/runtime/src/lib.rs b/runtime/src/lib.rs index 0699e88bb..b15fc66c9 100644 --- a/runtime/src/lib.rs +++ b/runtime/src/lib.rs @@ -16,8 +16,6 @@ use authority_selection_inherents::filter_invalid_candidates::{ use authority_selection_inherents::select_authorities::select_authorities; use chain_params::SidechainParams; use frame_support::genesis_builder_helper::{build_state, get_preset}; -use frame_support::traits::fungible::Balanced; -use frame_support::traits::tokens::Precision; use frame_support::BoundedVec; pub use frame_support::{ construct_runtime, parameter_types, @@ -32,7 +30,6 @@ pub use frame_support::{ PalletId, StorageValue, }; pub use frame_system::Call as SystemCall; -use hex_literal::hex; use opaque::SessionKeys; pub use pallet_balances::Call as BalancesCall; use pallet_grandpa::AuthorityId as GrandpaId; @@ -41,15 +38,14 @@ pub use pallet_timestamp::Call as TimestampCall; use pallet_transaction_payment::{ConstFeeMultiplier, FungibleAdapter, Multiplier}; use session_manager::ValidatorManagementSessionManager; use sidechain_domain::{ - MainchainPublicKey, NativeTokenAmount, PermissionedCandidateData, RegistrationData, - ScEpochNumber, ScSlotNumber, StakeDelegation, + MainchainPublicKey, PermissionedCandidateData, RegistrationData, ScEpochNumber, ScSlotNumber, + StakeDelegation, }; use sp_api::impl_runtime_apis; use sp_consensus_aura::sr25519::AuthorityId as AuraId; use sp_core::{crypto::KeyTypeId, OpaqueMetadata}; #[cfg(any(feature = "std", test))] pub use sp_runtime::BuildStorage; -use sp_runtime::DispatchResult; use sp_runtime::{ create_runtime_str, generic, impl_opaque_keys, traits::{ @@ -321,29 +317,6 @@ impl frame_system::Config for Runtime { pub struct TokenTransferHandler; -impl pallet_native_token_management::TokenTransferHandler for TokenTransferHandler { - fn handle_token_transfer(token_amount: NativeTokenAmount) -> DispatchResult { - // Mint the "transfered" tokens into a dummy address. - // This is done for visibility in tests only. - // Despite using the `Balances` pallet to do the transfer here, the account balance - // is stored (and can be observed) in the `System` pallet's storage. - let _ = Balances::deposit( - &AccountId::from(hex!( - "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" - )), - token_amount.0.into(), - Precision::Exact, - )?; - log::info!("💸 Registered transfer of {} native tokens", token_amount.0); - Ok(()) - } -} - -impl pallet_native_token_management::Config for Runtime { - type RuntimeEvent = RuntimeEvent; - type TokenTransferHandler = TokenTransferHandler; -} - impl pallet_aura::Config for Runtime { type AuthorityId = AuraId; type DisabledValidators = (); @@ -504,7 +477,6 @@ construct_runtime!( PalletSession: pallet_session, // The order matters!! pallet_partner_chains_session needs to come last for correct initialization order Session: pallet_partner_chains_session, - NativeTokenManagement: pallet_native_token_management, } ); @@ -859,12 +831,6 @@ impl_runtime_apis! { validate_permissioned_candidate_data::(candidate).err() } } - - impl sp_native_token_management::NativeTokenManagementApi for Runtime { - fn get_main_chain_scripts() -> sp_native_token_management::MainChainScripts { - NativeTokenManagement::get_main_chain_scripts() - } - } } #[cfg(test)]