Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merge from poc1-final to develop for devnet setup #50

Merged
merged 35 commits into from
Jul 29, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
1e2f55a
Add some kton tests
wuminzhe Jul 2, 2019
643658e
Merge pull request #24 from wuminzhe/poc1-final
hackfisher Jul 3, 2019
b9311a7
rebase on #5bf5e8f5
sekisamu Jul 3, 2019
37b7b46
Merge pull request #30 from hammeWang/poc1-final
sekisamu Jul 3, 2019
e815522
delete Cargo.lock.bak
sekisamu Jul 3, 2019
f72d419
Merge pull request #31 from hammeWang/poc1-final
sekisamu Jul 3, 2019
ce48c03
update node/runtime/wasm/Cargo.lock
sekisamu Jul 5, 2019
2fb68f3
update kton tests
sekisamu Jul 5, 2019
d1d6bef
update Storage identifier to be compatible to frontend
sekisamu Jul 5, 2019
60b7239
Merge pull request #39 from darwinia-network/master
sekisamu Jul 8, 2019
9bedd8a
Merge remote-tracking branch 'upstream/poc1-final' into poc1-final
sekisamu Jul 8, 2019
c703987
update cargo.lock
sekisamu Jul 8, 2019
b2df080
mark bugs in `_IMPL_DECODE_FOR_RewardDestination::_parity_codec::Deco…
sekisamu Jul 8, 2019
9786e5a
add aura and evo-staking
sekisamu Jul 9, 2019
7391c5d
remove unnecessary module for now
sekisamu Jul 11, 2019
50aa83f
add kton tests
sekisamu Jul 12, 2019
c605290
fix bug in kton::make_free_balance_be
sekisamu Jul 13, 2019
8346a3a
add kton tests
sekisamu Jul 13, 2019
c1a2a0e
fix bug in chain_spec
sekisamu Jul 13, 2019
cbea038
add basic tests about staking
sekisamu Jul 13, 2019
0fd5973
remove unnecessary code
sekisamu Jul 16, 2019
c38a722
update runtime version
sekisamu Jul 17, 2019
0085336
mark:update for frontend event decoding
sekisamu Jul 18, 2019
4d5304d
update for test all, temporarily
sekisamu Jul 22, 2019
7c4e258
add kton storage initialization
sekisamu Jul 24, 2019
47c627c
handle errs in staking
sekisamu Jul 24, 2019
d9e464d
add staking tests and fix bugs in wasm buidling
sekisamu Jul 26, 2019
aea03eb
close https://github.com/darwinia-network/darwinia/issues/48
sekisamu Jul 26, 2019
86f8120
fix errs in test after removing depositing in genesis config
sekisamu Jul 26, 2019
b4efa77
modify staking
sekisamu Jul 29, 2019
4be19ec
extract reward module
wuminzhe Jul 26, 2019
2413187
split reward module to two modules: reward and gringotts
wuminzhe Jul 29, 2019
8f54dd4
Merge pull request #49 from wuminzhe/poc1-final
hackfisher Jul 29, 2019
a2451a7
fix typo and compile issue
hackfisher Jul 29, 2019
a9e4230
merge from master and resolve conflict
hackfisher Jul 29, 2019
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
999 changes: 550 additions & 449 deletions Cargo.lock

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -56,11 +56,11 @@ members = [
"node/runtime",
"node/rpc-client",
"srml/staking",
"srml/token/ring",
"srml/token/kton",
"srml/kton",
"srml/support",
"srml/aura",
"srml/try",
"srml/reward",
]

exclude = ["node/runtime/wasm"]
Expand Down
3 changes: 2 additions & 1 deletion node/cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ tokio = "0.1.7"
futures = "0.1"
exit-future = "0.1"
cli = { package = "substrate-cli", git = 'https://github.com/paritytech/substrate.git' }
parity-codec = { version = "3.3" }
parity-codec = { version = "4.1.1" }
sr-io = { git = 'https://github.com/paritytech/substrate.git' }
client = { package = "substrate-client", git = 'https://github.com/paritytech/substrate.git' }
primitives = { package = "substrate-primitives", git = 'https://github.com/paritytech/substrate.git' }
Expand All @@ -39,6 +39,7 @@ timestamp = { package = "srml-timestamp", git = 'https://github.com/paritytech/s
rand = "0.6"
finality_tracker = { package = "srml-finality-tracker", git = 'https://github.com/paritytech/substrate.git', default-features = false }
srml-support = { git = 'https://github.com/paritytech/substrate.git', default-features = false }
contracts = { package = "srml-contracts", git = 'https://github.com/paritytech/substrate.git', default-features = false }

[dev-dependencies]
consensus-common = { package = "substrate-consensus-common", git = 'https://github.com/paritytech/substrate.git' }
Expand Down
817 changes: 305 additions & 512 deletions node/cli/src/chain_spec.rs

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions node/cli/src/factory_impl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -193,11 +193,11 @@ impl RuntimeAdapter for FactoryState<Number> {
} else {
match self.round() {
0 =>
// if round is 0 all transactions will be done with master as a sender
// if round is 0 all transactions will be done with master as a sender
self.block_no(),
_ =>
// if round is e.g. 1 every sender account will be new and not yet have
// any transactions done
// if round is e.g. 1 every sender account will be new and not yet have
// any transactions done
0
}
}
Expand Down
35 changes: 10 additions & 25 deletions node/cli/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,21 +46,15 @@ pub enum ChainSpec {
FlamingFir,
/// Whatever the current runtime is with the "global testnet" defaults.
StagingTestnet,
/// darwinia poc-1 testnet, same with local testnet
Trilobita,
/// darwinia poc-1 testnet
Darwinia,
/// darwinia poc-1 testnet fir
DarwiniaFir
}

/// Custom subcommands.
#[derive(Clone, Debug, StructOpt)]
pub enum CustomSubcommands {
/// The custom factory subcommmand for manufacturing transactions.
#[structopt(
name = "factory",
about = "Manufactures num transactions from Alice to random accounts. \
name = "factory",
about = "Manufactures num transactions from Alice to random accounts. \
Only supported for development or local testnet."
)]
Factory(FactoryCmd),
Expand Down Expand Up @@ -124,21 +118,14 @@ impl ChainSpec {
ChainSpec::Development => chain_spec::development_config(),
ChainSpec::LocalTestnet => chain_spec::local_testnet_config(),
ChainSpec::StagingTestnet => chain_spec::staging_testnet_config(),
ChainSpec::Trilobita => chain_spec::trilobita_testnet_config(),
// latest
ChainSpec::Darwinia => chain_spec::trilobita_config(),
ChainSpec::DarwiniaFir => chain_spec::darwinia_fir_config()?,
})
}

pub(crate) fn from(s: &str) -> Option<Self> {
match s {
"dev" => Some(ChainSpec::Development),
"local" => Some(ChainSpec::LocalTestnet),
"darwinia" => Some(ChainSpec::Darwinia),
"" => Some(ChainSpec::DarwiniaFir),
"trilobita" => Some(ChainSpec::Trilobita),
"fir" | "flaming-fir" => Some(ChainSpec::FlamingFir),
"" | "fir" | "flaming-fir" => Some(ChainSpec::FlamingFir),
"staging" => Some(ChainSpec::StagingTestnet),
_ => None,
}
Expand All @@ -163,22 +150,21 @@ pub fn run<I, T, E>(args: I, exit: E, version: cli::VersionInfo) -> error::Resul
|exit, _cli_args, _custom_args, config| {
info!("{}", version.name);
info!(" version {}", config.full_version());
info!(" by Darwinia Network, 2017-2019");
info!(" by Parity Technologies, 2017-2019");
info!("Chain specification: {}", config.chain_spec.name());
info!("Node name: {}", config.name);
info!("Roles: {:?}", config.roles);
let runtime = RuntimeBuilder::new().name_prefix("main-tokio-").build()
.map_err(|e| format!("{:?}", e))?;
let executor = runtime.executor();
match config.roles {
ServiceRoles::LIGHT => run_until_exit(
runtime,
service::Factory::new_light(config, executor).map_err(|e| format!("{:?}", e))?,
service::Factory::new_light(config).map_err(|e| format!("{:?}", e))?,
exit
),
_ => run_until_exit(
runtime,
service::Factory::new_full(config, executor).map_err(|e| format!("{:?}", e))?,
service::Factory::new_full(config).map_err(|e| format!("{:?}", e))?,
exit
),
}.map_err(|e| format!("{:?}", e))
Expand Down Expand Up @@ -220,7 +206,7 @@ fn run_until_exit<T, C, E>(
e: E,
) -> error::Result<()>
where
T: Deref<Target=substrate_service::Service<C>>,
T: Deref<Target=substrate_service::Service<C>> + Future<Item = (), Error = ()> + Send + 'static,
C: substrate_service::Components,
E: IntoExit,
{
Expand All @@ -229,13 +215,12 @@ fn run_until_exit<T, C, E>(
let informant = cli::informant::build(&service);
runtime.executor().spawn(exit.until(informant).map(|_| ()));

let _ = runtime.block_on(e.into_exit());
exit_send.fire();

// we eagerly drop the service so that the internal exit future is fired,
// but we need to keep holding a reference to the global telemetry guard
let _telemetry = service.telemetry();
drop(service);

let _ = runtime.block_on(service.select(e.into_exit()));
exit_send.fire();

// TODO [andre]: timeout this future #1318
let _ = runtime.shutdown_on_idle().wait();
Expand Down
58 changes: 36 additions & 22 deletions node/cli/src/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ use node_primitives::Block;
use node_runtime::{GenesisConfig, RuntimeApi};
use substrate_service::{
FactoryFullConfiguration, LightComponents, FullComponents, FullBackend,
FullClient, LightClient, LightBackend, FullExecutor, LightExecutor, TaskExecutor,
FullClient, LightClient, LightBackend, FullExecutor, LightExecutor,
error::{Error as ServiceError},
};
use transaction_pool::{self, txpool::{Pool as TransactionPool}};
Expand Down Expand Up @@ -76,10 +76,10 @@ construct_service_factory! {
Genesis = GenesisConfig,
Configuration = NodeConfig<Self>,
FullService = FullComponents<Self>
{ |config: FactoryFullConfiguration<Self>, executor: TaskExecutor|
FullComponents::<Factory>::new(config, executor) },
{ |config: FactoryFullConfiguration<Self>|
FullComponents::<Factory>::new(config) },
AuthoritySetup = {
|mut service: Self::FullService, executor: TaskExecutor, local_key: Option<Arc<ed25519::Pair>>| {
|mut service: Self::FullService, local_key: Option<Arc<ed25519::Pair>>| {
let (block_import, link_half) = service.config.custom.grandpa_import_setup.take()
.expect("Link Half and Block Import are present for Full Services or setup failed before. qed");

Expand All @@ -104,7 +104,7 @@ construct_service_factory! {
service.config.custom.inherent_data_providers.clone(),
service.config.force_authoring,
)?;
executor.spawn(aura.select(service.on_exit()).then(|_| Ok(())));
service.spawn_task(Box::new(aura.select(service.on_exit()).then(|_| Ok(()))));

info!("Running Grandpa session as Authority {}", key.public());
}
Expand All @@ -125,18 +125,16 @@ construct_service_factory! {

match config.local_key {
None => {
executor.spawn(grandpa::run_grandpa_observer(
service.spawn_task(Box::new(grandpa::run_grandpa_observer(
config,
link_half,
service.network(),
service.on_exit(),
)?);
)?));
},
Some(_) => {
let telemetry_on_connect = TelemetryOnConnect {
on_exit: Box::new(service.on_exit()),
telemetry_connection_sinks: service.telemetry_on_connect_stream(),
executor: &executor,
};
let grandpa_config = grandpa::GrandpaParams {
config: config,
Expand All @@ -146,15 +144,15 @@ construct_service_factory! {
on_exit: service.on_exit(),
telemetry_on_connect: Some(telemetry_on_connect),
};
executor.spawn(grandpa::run_grandpa_voter(grandpa_config)?);
service.spawn_task(Box::new(grandpa::run_grandpa_voter(grandpa_config)?));
},
}

Ok(service)
}
},
LightService = LightComponents<Self>
{ |config, executor| <LightComponents<Factory>>::new(config, executor) },
{ |config| <LightComponents<Factory>>::new(config) },
FullImportQueue = AuraImportQueue<Self::Block>
{ |config: &mut FactoryFullConfiguration<Self> , client: Arc<FullClient<Self>>, select_chain: Self::SelectChain| {
let slot_duration = SlotDuration::get_or_compute(&*client)?;
Expand Down Expand Up @@ -220,7 +218,7 @@ mod tests {
use consensus::CompatibleDigestItem;
use consensus_common::{Environment, Proposer, ImportBlock, BlockOrigin, ForkChoiceStrategy};
use node_primitives::DigestItem;
use node_runtime::{Call, BalancesCall, UncheckedExtrinsic};
use node_runtime::{BalancesCall, Call, COIN, UncheckedExtrinsic};
use parity_codec::{Compact, Encode, Decode};
use primitives::{
crypto::Pair as CryptoPair, ed25519::Pair, blake2_256,
Expand All @@ -231,6 +229,7 @@ mod tests {
use finality_tracker;
use keyring::{ed25519::Keyring as AuthorityKeyring, sr25519::Keyring as AccountKeyring};
use substrate_service::ServiceFactory;
use service_test::SyncService;
use crate::service::Factory;

#[cfg(feature = "rhd")]
Expand Down Expand Up @@ -266,8 +265,13 @@ mod tests {
auxiliary: Vec::new(),
}
};
let extrinsic_factory = |service: &<Factory as service::ServiceFactory>::FullService| {
let payload = (0, Call::Balances(BalancesCall::transfer(RawAddress::Id(bob.public().0.into()), 69.into())), Era::immortal(), service.client().genesis_hash());
let extrinsic_factory = |service: &SyncService<<Factory as service::ServiceFactory>::FullService>| {
let payload = (
0,
Call::Balances(BalancesCall::transfer(RawAddress::Id(bob.public().0.into()), 69.into())),
Era::immortal(),
service.client().genesis_hash()
);
let signature = alice.sign(&payload.encode()).into();
let id = alice.public().0.into();
let xt = UncheckedExtrinsic {
Expand All @@ -277,7 +281,11 @@ mod tests {
let v: Vec<u8> = Decode::decode(&mut xt.as_slice()).unwrap();
OpaqueExtrinsic(v)
};
service_test::sync::<Factory, _, _>(chain_spec::integration_test_config(), block_factory, extrinsic_factory);
service_test::sync::<Factory, _, _>(
chain_spec::integration_test_config(),
block_factory,
extrinsic_factory,
);
}

#[test]
Expand All @@ -287,9 +295,14 @@ mod tests {

let alice = Arc::new(AuthorityKeyring::Alice.pair());
let mut slot_num = 1u64;
let block_factory = |service: &<Factory as ServiceFactory>::FullService| {
let mut inherent_data = service.config.custom.inherent_data_providers
.create_inherent_data().unwrap();
let block_factory = |service: &SyncService<<Factory as ServiceFactory>::FullService>| {
let service = service.get();
let mut inherent_data = service
.config
.custom
.inherent_data_providers
.create_inherent_data()
.expect("Creates inherent data.");
inherent_data.replace_data(finality_tracker::INHERENT_IDENTIFIER, &1u64);
inherent_data.replace_data(timestamp::INHERENT_IDENTIFIER, &(slot_num * 10));

Expand All @@ -299,13 +312,14 @@ mod tests {
client: service.client(),
transaction_pool: service.transaction_pool(),
});

let mut digest = Digest::<H256>::default();
digest.push(<DigestItem as CompatibleDigestItem<Pair>>::aura_pre_digest(slot_num * 10 / 2));
let proposer = proposer_factory.init(&parent_header).unwrap();
let new_block = proposer.propose(
inherent_data,
digest,
::std::time::Duration::from_secs(1),
std::time::Duration::from_secs(1),
).expect("Error making test block");

let (new_header, new_body) = new_block.deconstruct();
Expand Down Expand Up @@ -335,11 +349,11 @@ mod tests {
let charlie = Arc::new(AccountKeyring::Charlie.pair());

let mut index = 0;
let extrinsic_factory = |service: &<Factory as ServiceFactory>::FullService| {
let amount = 1000;
let extrinsic_factory = |service: &SyncService<<Factory as ServiceFactory>::FullService>| {
let amount = 5 * COIN;
let to = AddressPublic::from_raw(bob.public().0);
let from = AddressPublic::from_raw(charlie.public().0);
let genesis_hash = service.client().block_hash(0).unwrap().unwrap();
let genesis_hash = service.get().client().block_hash(0).unwrap().unwrap();
let signer = charlie.clone();

let function = Call::Balances(BalancesCall::transfer(to.into(), amount));
Expand Down
2 changes: 1 addition & 1 deletion node/executor/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ edition = "2018"

[dependencies]
trie-root = "0.12"
parity-codec = "3.3"
parity-codec = "4.1.1"
runtime_io = { package = "sr-io", git = 'https://github.com/paritytech/substrate.git' }
state_machine = { package = "substrate-state-machine", git = 'https://github.com/paritytech/substrate.git' }
substrate-executor = { git = 'https://github.com/paritytech/substrate.git' }
Expand Down
Loading