Skip to content

Commit 31b57d6

Browse files
committed
remove native token pallet from the runtime and node
1 parent 12d2aa3 commit 31b57d6

13 files changed

+18
-174
lines changed

Cargo.lock

Lines changed: 0 additions & 37 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,6 @@ members = [
3737
"primitives/session-manager",
3838
"primitives/sidechain",
3939
"partner-chains-cli",
40-
"pallets/native-token-management",
41-
"primitives/native-token-management"
4240
]
4341
resolver = "2"
4442

@@ -205,8 +203,6 @@ authority-selection-inherents = { path = "primitives/authority-selection-inheren
205203
session-manager = { path = "primitives/session-manager", default-features = false }
206204
sp-sidechain = { path = "primitives/sidechain", default-features = false }
207205
chain-params = { path = "primitives/chain-params", default-features = false }
208-
pallet-native-token-management = { path = "pallets/native-token-management", default-features = false }
209-
sp-native-token-management = { path = "primitives/native-token-management", default-features = false }
210206
sc-partner-chains-consensus-aura = { path = "client/consensus/aura", default-features = false }
211207
sp-partner-chains-consensus-aura = { path = "primitives/consensus/aura", default-features = false }
212208
pallet-partner-chains-session = { path = "pallets/partner-chains-session", default-features = false }

node/Cargo.toml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -91,10 +91,9 @@ frame-benchmarking-cli = { workspace = true }
9191
# Local Dependencies
9292
sidechain-runtime = { workspace = true }
9393
sidechain-mc-hash = { workspace = true, features = ["mock"] }
94-
sp-native-token-management = { workspace = true }
9594
main-chain-follower-api = { workspace = true }
96-
db-sync-follower = { workspace = true, features = ["block-source", "candidate-source", "native-token"] }
97-
main-chain-follower-mock = { workspace = true, features = ["block-source", "candidate-source", "native-token"] }
95+
db-sync-follower = { workspace = true, features = ["block-source", "candidate-source"] }
96+
main-chain-follower-mock = { workspace = true, features = ["block-source", "candidate-source"] }
9897
tokio = { workspace = true }
9998
cli-commands = { workspace = true }
10099

node/src/inherent_data.rs

Lines changed: 3 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,6 @@ use sp_consensus_aura::{
2121
};
2222
use sp_core::Pair;
2323
use sp_inherents::CreateInherentDataProviders;
24-
use sp_native_token_management::{
25-
NativeTokenManagementApi, NativeTokenManagementInherentDataProvider as NativeTokenIDP,
26-
};
2724
use sp_partner_chains_consensus_aura::CurrentSlotProvider;
2825
use sp_runtime::traits::{Block as BlockT, Header, Zero};
2926
use sp_session_validator_management::SessionValidatorManagementApi;
@@ -50,15 +47,13 @@ where
5047
AuthoritySelectionInputs,
5148
ScEpochNumber,
5249
>,
53-
T::Api: NativeTokenManagementApi<Block>,
5450
{
5551
type InherentDataProviders = (
5652
AuraIDP,
5753
TimestampIDP,
5854
McHashIDP,
5955
AriadneIDP,
6056
BlockBeneficiaryInherentProvider<BeneficiaryId>,
61-
NativeTokenIDP,
6257
);
6358

6459
async fn create_inherent_data_providers(
@@ -93,22 +88,7 @@ where
9388
"SIDECHAIN_BLOCK_BENEFICIARY",
9489
)?;
9590

96-
let native_token = NativeTokenIDP::new(
97-
client.clone(),
98-
data_sources.native_token.as_ref(),
99-
mc_hash.mc_hash(),
100-
parent_hash.clone(),
101-
)
102-
.await?;
103-
104-
Ok((
105-
slot,
106-
timestamp,
107-
mc_hash,
108-
ariadne_data_provider,
109-
block_beneficiary_provider,
110-
native_token,
111-
))
91+
Ok((slot, timestamp, mc_hash, ariadne_data_provider, block_beneficiary_provider))
11292
}
11393
}
11494

@@ -136,9 +116,8 @@ where
136116
AuthoritySelectionInputs,
137117
ScEpochNumber,
138118
>,
139-
T::Api: NativeTokenManagementApi<Block>,
140119
{
141-
type InherentDataProviders = (TimestampIDP, AriadneIDP, NativeTokenIDP);
120+
type InherentDataProviders = (TimestampIDP, AriadneIDP);
142121

143122
async fn create_inherent_data_providers(
144123
&self,
@@ -172,15 +151,7 @@ where
172151
)
173152
.await?;
174153

175-
let native_token = NativeTokenIDP::new(
176-
client.clone(),
177-
data_sources.native_token.as_ref(),
178-
mc_hash,
179-
parent_hash.clone(),
180-
)
181-
.await?;
182-
183-
Ok((timestamp, ariadne_data_provider, native_token))
154+
Ok((timestamp, ariadne_data_provider))
184155
}
185156
}
186157

node/src/main_chain_follower.rs

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,10 @@
1-
use db_sync_follower::native_token::NativeTokenManagementDataSourceImpl;
21
use db_sync_follower::{
32
block::{BlockDataSourceImpl, DbSyncBlockDataSourceConfig},
43
candidates::{cached::CandidateDataSourceCached, CandidatesDataSourceImpl},
54
metrics::McFollowerMetrics,
65
};
7-
use main_chain_follower_api::{
8-
BlockDataSource, CandidateDataSource, NativeTokenManagementDataSource,
9-
};
10-
use main_chain_follower_mock::{
11-
block::BlockDataSourceMock, candidate::MockCandidateDataSource,
12-
native_token::NativeTokenDataSourceMock,
13-
};
6+
use main_chain_follower_api::{BlockDataSource, CandidateDataSource};
7+
use main_chain_follower_mock::{block::BlockDataSourceMock, candidate::MockCandidateDataSource};
148
use sc_service::error::Error as ServiceError;
159
use std::error::Error;
1610
use std::sync::Arc;
@@ -19,7 +13,6 @@ use std::sync::Arc;
1913
pub struct DataSources {
2014
pub block: Arc<dyn BlockDataSource + Send + Sync>,
2115
pub candidate: Arc<dyn CandidateDataSource + Send + Sync>,
22-
pub native_token: Arc<dyn NativeTokenManagementDataSource + Send + Sync>,
2316
}
2417

2518
pub(crate) async fn create_cached_main_chain_follower_data_sources(
@@ -58,7 +51,6 @@ pub fn create_mock_data_sources(
5851
Ok(DataSources {
5952
block: Arc::new(block_data_source_mock),
6053
candidate: Arc::new(MockCandidateDataSource::from_env()?),
61-
native_token: Arc::new(NativeTokenDataSourceMock::new()),
6254
})
6355
}
6456

@@ -80,6 +72,5 @@ pub async fn create_cached_data_sources(
8072
CandidatesDataSourceImpl::from_config(pool.clone(), metrics_opt.clone()).await?,
8173
CANDIDATES_FOR_EPOCH_CACHE_SIZE,
8274
)?),
83-
native_token: Arc::new(NativeTokenManagementDataSourceImpl { pool, metrics_opt }),
8475
})
8576
}

node/src/staging.rs

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,8 @@ use chain_params::SidechainParams;
44
use sc_service::ChainType;
55
use sidechain_domain::*;
66
use sidechain_runtime::{
7-
AccountId, AuraConfig, BalancesConfig, GrandpaConfig, NativeTokenManagementConfig,
8-
RuntimeGenesisConfig, SessionCommitteeManagementConfig, SessionConfig, SidechainConfig,
9-
SudoConfig, SystemConfig,
7+
AccountId, AuraConfig, BalancesConfig, GrandpaConfig, RuntimeGenesisConfig,
8+
SessionCommitteeManagementConfig, SessionConfig, SidechainConfig, SudoConfig, SystemConfig,
109
};
1110
use sp_core::bytes::from_hex;
1211
use sp_core::{ed25519, sr25519};
@@ -160,10 +159,6 @@ pub fn staging_genesis(
160159
.collect(),
161160
main_chain_scripts: sp_session_validator_management::MainChainScripts::read_from_env()?,
162161
},
163-
native_token_management: NativeTokenManagementConfig {
164-
main_chain_scripts: sp_native_token_management::MainChainScripts::read_from_env()?,
165-
..Default::default()
166-
},
167162
};
168163

169164
Ok(serde_json::to_value(config).expect("Genesis config must be serialized correctly"))

node/src/template_chain_spec.rs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ use crate::chain_spec::*;
22
use chain_params::SidechainParams;
33
use sc_service::ChainType;
44
use sidechain_runtime::{
5-
AuraConfig, BalancesConfig, GrandpaConfig, NativeTokenManagementConfig, RuntimeGenesisConfig,
5+
AuraConfig, BalancesConfig, GrandpaConfig, RuntimeGenesisConfig,
66
SessionCommitteeManagementConfig, SessionConfig, SidechainConfig, SudoConfig, SystemConfig,
77
};
88

@@ -38,10 +38,6 @@ pub fn chain_spec() -> Result<ChainSpec, envy::Error> {
3838
initial_authorities: vec![],
3939
main_chain_scripts: sp_session_validator_management::MainChainScripts::read_from_env()?,
4040
},
41-
native_token_management: NativeTokenManagementConfig {
42-
main_chain_scripts: sp_native_token_management::MainChainScripts::read_from_env()?,
43-
..Default::default()
44-
},
4541
};
4642
let genesis_json = serde_json::to_value(runtime_genesis_config)
4743
.expect("Genesis config must be serialized correctly");

node/src/testnet.rs

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,8 @@ use chain_params::SidechainParams;
33
use sc_service::ChainType;
44
use sidechain_domain::*;
55
use sidechain_runtime::{
6-
AccountId, AuraConfig, BalancesConfig, GrandpaConfig, NativeTokenManagementConfig,
7-
RuntimeGenesisConfig, SessionCommitteeManagementConfig, SessionConfig, SidechainConfig,
8-
SudoConfig, SystemConfig,
6+
AccountId, AuraConfig, BalancesConfig, GrandpaConfig, RuntimeGenesisConfig,
7+
SessionCommitteeManagementConfig, SessionConfig, SidechainConfig, SudoConfig, SystemConfig,
98
};
109
use sidechain_slots::SlotsPerEpoch;
1110
use sp_core::bytes::from_hex;
@@ -200,10 +199,6 @@ pub fn testnet_genesis(
200199
.collect(),
201200
main_chain_scripts: sp_session_validator_management::MainChainScripts::read_from_env()?,
202201
},
203-
native_token_management: NativeTokenManagementConfig {
204-
main_chain_scripts: sp_native_token_management::MainChainScripts::read_from_env()?,
205-
..Default::default()
206-
},
207202
};
208203

209204
Ok(serde_json::to_value(config).expect("Genesis config must be serialized correctly"))

node/src/tests/inherent_data_tests.rs

Lines changed: 3 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,7 @@ use crate::tests::mock::{test_client, test_create_inherent_data_config};
33
use crate::tests::runtime_api_mock::{mock_header, TestApi};
44
use authority_selection_inherents::authority_selection_inputs::AuthoritySelectionInputs;
55
use main_chain_follower_api::{block::MainchainBlock, mock_services::*};
6-
use sidechain_domain::{
7-
McBlockHash, McBlockNumber, McEpochNumber, McSlotNumber, NativeTokenAmount, ScEpochNumber,
8-
};
6+
use sidechain_domain::{McBlockHash, McBlockNumber, McEpochNumber, McSlotNumber, ScEpochNumber};
97
use sp_consensus_aura::Slot;
108
use sp_core::H256;
119
use sp_inherents::CreateInherentDataProviders;
@@ -31,15 +29,13 @@ async fn block_proposal_cidp_should_be_created_correctly() {
3129
.await
3230
.unwrap();
3331

34-
let (slot, timestamp, mc_hash, ariadne_data, block_beneficiary, native_token) =
35-
inherent_data_providers;
32+
let (slot, timestamp, mc_hash, ariadne_data, block_beneficiary) = inherent_data_providers;
3633
let mut inherent_data = InherentData::new();
3734
slot.provide_inherent_data(&mut inherent_data).await.unwrap();
3835
timestamp.provide_inherent_data(&mut inherent_data).await.unwrap();
3936
mc_hash.provide_inherent_data(&mut inherent_data).await.unwrap();
4037
ariadne_data.provide_inherent_data(&mut inherent_data).await.unwrap();
4138
block_beneficiary.provide_inherent_data(&mut inherent_data).await.unwrap();
42-
native_token.provide_inherent_data(&mut inherent_data).await.unwrap();
4339
assert_eq!(
4440
inherent_data
4541
.get_data::<Slot>(&sp_consensus_aura::inherents::INHERENT_IDENTIFIER)
@@ -65,10 +61,6 @@ async fn block_proposal_cidp_should_be_created_correctly() {
6561
.get_data::<AuthoritySelectionInputs>(&sp_session_validator_management::INHERENT_IDENTIFIER)
6662
.unwrap()
6763
.is_some());
68-
assert!(inherent_data
69-
.get_data::<NativeTokenAmount>(&sp_native_token_management::INHERENT_IDENTIFIER)
70-
.unwrap()
71-
.is_some())
7264
}
7365

7466
#[tokio::test]
@@ -94,11 +86,10 @@ async fn block_verification_cidp_should_be_created_correctly() {
9486
.create_inherent_data_providers(mock_header().hash(), (30.into(), mc_block_hash))
9587
.await
9688
.unwrap();
97-
let (timestamp, ariadne_data_provider, native_token_provider) = inherent_data_providers;
89+
let (timestamp, ariadne_data_provider) = inherent_data_providers;
9890
let mut inherent_data = InherentData::new();
9991
timestamp.provide_inherent_data(&mut inherent_data).await.unwrap();
10092
ariadne_data_provider.provide_inherent_data(&mut inherent_data).await.unwrap();
101-
native_token_provider.provide_inherent_data(&mut inherent_data).await.unwrap();
10293

10394
assert_eq!(
10495
inherent_data.get_data::<Timestamp>(&sp_timestamp::INHERENT_IDENTIFIER).unwrap(),
@@ -108,8 +99,4 @@ async fn block_verification_cidp_should_be_created_correctly() {
10899
.get_data::<AuthoritySelectionInputs>(&sp_session_validator_management::INHERENT_IDENTIFIER)
109100
.unwrap()
110101
.is_some());
111-
assert!(inherent_data
112-
.get_data::<NativeTokenAmount>(&sp_native_token_management::INHERENT_IDENTIFIER)
113-
.unwrap()
114-
.is_some())
115102
}

node/src/tests/mock.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ use std::sync::Arc;
1515

1616
impl From<TestDataSources> for DataSources {
1717
fn from(value: TestDataSources) -> Self {
18-
Self { block: value.block, candidate: value.candidate, native_token: value.native_token }
18+
Self { block: value.block, candidate: value.candidate }
1919
}
2020
}
2121

0 commit comments

Comments
 (0)