decl_storage as a proc_macro (#1176)

* `decl_storage` parsing of the macro (TODO change tool crate structure)

* Start formatting, for now use inner macro.
Still missing optional formating last part (genesis ...).

* Calling extra genesis macro

* decl_storage lines parsing.

* genesis macro as quote (need some cleaning reorg)

* dirty $crate substitute

* proc crate reorg.

* PR impl : skip usage of phantom data, it only applies in test and
council (others required it).

* Remaining macro of decl_storage, warning stringify behave sometime
oddly.

* Formatting code and some cleaning.

* Include line parsing to main struct (cannot use existing macro anymore).

* Remove genesis phantom data when there is already a field with type
parameter.

* Revert wasm files

* Remove old version of `decl_storage`.

* Fix false positive for phantom trait (additional type check on config
build).

* slight changes:
- return token errors instead of panic
- do not use useless intermediate vec

* Update srml/support/procedural/tools/derive/src/lib.rs

remove indent

Co-Authored-By: cheme <emericchevalier.pro@gmail.com>

* Switch iterations to fold, remove unused import.
This commit is contained in:
cheme
2018-12-09 21:09:39 +01:00
committed by Bastian Köcher
parent 3ffb45e3c8
commit ed5b78eaf0
34 changed files with 1681 additions and 1427 deletions
+1 -25
View File
@@ -59,7 +59,6 @@ fn staging_testnet_config_genesis() -> GenesisConfig {
consensus: Some(ConsensusConfig {
code: include_bytes!("../../runtime/wasm/target/wasm32-unknown-unknown/release/node_runtime.compact.wasm").to_vec(), // TODO change
authorities: initial_authorities.clone(),
_genesis_phantom_data: Default::default(),
}),
system: None,
balances: Some(BalancesConfig {
@@ -70,12 +69,10 @@ fn staging_testnet_config_genesis() -> GenesisConfig {
transfer_fee: 1 * CENTS,
creation_fee: 1 * CENTS,
reclaim_rebate: 1 * CENTS,
_genesis_phantom_data: Default::default(),
}),
session: Some(SessionConfig {
validators: initial_authorities.iter().cloned().map(Into::into).collect(),
session_length: 5 * MINUTES,
_genesis_phantom_data: Default::default(),
}),
staking: Some(StakingConfig {
current_era: 0,
@@ -89,13 +86,11 @@ fn staging_testnet_config_genesis() -> GenesisConfig {
bonding_duration: 1 * DAYS,
offline_slash_grace: 4,
minimum_validator_count: 4,
_genesis_phantom_data: Default::default(),
}),
democracy: Some(DemocracyConfig {
launch_period: 5 * MINUTES, // 1 day per public referendum
voting_period: 5 * MINUTES, // 3 days to discuss & vote on an active referendum
minimum_deposit: 50 * DOLLARS, // 12000 as the minimum deposit for a referendum
_genesis_phantom_data: Default::default(),
}),
council_seats: Some(CouncilSeatsConfig {
active_council: vec![],
@@ -108,23 +103,19 @@ fn staging_testnet_config_genesis() -> GenesisConfig {
term_duration: 28 * DAYS,
desired_seats: 0,
inactive_grace_period: 1, // one additional vote should go by before an inactive voter can be reaped.
_genesis_phantom_data: Default::default(),
}),
council_voting: Some(CouncilVotingConfig {
cooloff_period: 4 * DAYS,
voting_period: 1 * DAYS,
_genesis_phantom_data: Default::default(),
}),
timestamp: Some(TimestampConfig {
period: SECS_PER_BLOCK,
_genesis_phantom_data: Default::default(),
}),
treasury: Some(TreasuryConfig {
proposal_bond: Permill::from_percent(5),
proposal_bond_minimum: 1 * DOLLARS,
spend_period: 1 * DAYS,
burn: Permill::from_percent(50),
_genesis_phantom_data: Default::default(),
}),
contract: Some(ContractConfig {
contract_fee: 1 * CENTS,
@@ -134,15 +125,12 @@ fn staging_testnet_config_genesis() -> GenesisConfig {
max_depth: 1024,
block_gas_limit: 10_000_000,
current_schedule: Default::default(),
_genesis_phantom_data: Default::default(),
}),
upgrade_key: Some(UpgradeKeyConfig {
key: endowed_accounts[0].clone(),
_genesis_phantom_data: Default::default(),
}),
grandpa: Some(GrandpaConfig {
authorities: initial_authorities.clone().into_iter().map(|k| (k, 1)).collect(),
_genesis_phantom_data: Default::default(),
})
}
}
@@ -190,7 +178,6 @@ pub fn testnet_genesis(
consensus: Some(ConsensusConfig {
code: include_bytes!("../../runtime/wasm/target/wasm32-unknown-unknown/release/node_runtime.compact.wasm").to_vec(),
authorities: initial_authorities.clone(),
_genesis_phantom_data: Default::default(),
}),
system: None,
balances: Some(BalancesConfig {
@@ -201,12 +188,10 @@ pub fn testnet_genesis(
creation_fee: 0,
reclaim_rebate: 0,
balances: endowed_accounts.iter().map(|&k| (k.into(), (1 << 60))).collect(),
_genesis_phantom_data: Default::default(),
}),
session: Some(SessionConfig {
validators: initial_authorities.iter().cloned().map(Into::into).collect(),
session_length: 10,
_genesis_phantom_data: Default::default(),
}),
staking: Some(StakingConfig {
current_era: 0,
@@ -220,13 +205,11 @@ pub fn testnet_genesis(
current_offline_slash: 0,
current_session_reward: 0,
offline_slash_grace: 0,
_genesis_phantom_data: Default::default(),
}),
democracy: Some(DemocracyConfig {
launch_period: 9,
voting_period: 18,
minimum_deposit: 10,
_genesis_phantom_data: Default::default(),
}),
council_seats: Some(CouncilSeatsConfig {
active_council: endowed_accounts.iter()
@@ -241,23 +224,19 @@ pub fn testnet_genesis(
term_duration: 1000000,
desired_seats: (endowed_accounts.len() - initial_authorities.len()) as u32,
inactive_grace_period: 1,
_genesis_phantom_data: Default::default(),
}),
council_voting: Some(CouncilVotingConfig {
cooloff_period: 75,
voting_period: 20,
_genesis_phantom_data: Default::default(),
}),
timestamp: Some(TimestampConfig {
period: 5, // 5 second block time.
_genesis_phantom_data: Default::default(),
}),
treasury: Some(TreasuryConfig {
proposal_bond: Permill::from_percent(5),
proposal_bond_minimum: 1_000_000,
spend_period: 12 * 60 * 24,
burn: Permill::from_percent(50),
_genesis_phantom_data: Default::default(),
}),
contract: Some(ContractConfig {
contract_fee: 21,
@@ -267,15 +246,12 @@ pub fn testnet_genesis(
max_depth: 1024,
block_gas_limit: 10_000_000,
current_schedule: Default::default(),
_genesis_phantom_data: Default::default(),
}),
upgrade_key: Some(UpgradeKeyConfig {
key: upgrade_key,
_genesis_phantom_data: Default::default(),
}),
grandpa: Some(GrandpaConfig {
authorities: initial_authorities.clone().into_iter().map(|k| (k, 1)).collect(),
_genesis_phantom_data: Default::default(),
})
}
}
@@ -319,7 +295,7 @@ mod tests {
fn local_testnet_genesis_instant() -> GenesisConfig {
let mut genesis = local_testnet_genesis();
genesis.timestamp = Some(TimestampConfig { period: 0, _genesis_phantom_data: Default::default() });
genesis.timestamp = Some(TimestampConfig { period: 0 });
genesis
}