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

fetch new #4

Merged
merged 14 commits into from
Sep 3, 2019
62 changes: 62 additions & 0 deletions CONTRIBUTING.adoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
= Contributing

The `Darwinia` project is an **OPENISH Open Source Project**

== What?

Individuals making significant and valuable contributions are given commit-access to a project to contribute as they see fit. A project is more like an open wiki than a standard guarded open source project.

== Rules

There are a few basic ground-rules for contributors (including the maintainer(s) of the project):

. **No `--force` pushes** or modifying the master branch history in any way. If you need to rebase, ensure you do it in your own repo.
. **Non-master branches**, prefixed with a short name moniker (e.g. `gav-my-feature`) must be used for ongoing work.
. **All modifications** must be made in a **pull-request** to solicit feedback from other contributors.
. A pull-request *must not be merged until CI* has finished successfully.
. Contributors should adhere to the https://wiki.parity.io/Substrate-Style-Guide[house coding style].


== Merge Process

Merging pull requests once CI is successful:

. A PR needs to be reviewed and approved by project maintainers unless:
- it does not alter any logic (e.g. comments, dependencies, docs), then it may be tagged https://github.com/darwinia-network/darwinia/pulls?utf8=%E2%9C%93&q=is%3Apr+is%3Aopen+label%3AA2-insubstantial[`insubstantial`] and merged by its author once CI is complete.
- it is an urgent fix with no large change to logic, then it may be merged after a non-author contributor has approved the review once CI is complete.

. Once a PR is ready for review please add the https://github.com/darwinia-network/darwinia/pulls?q=is%3Apr+is%3Aopen+label%3AA0-pleasereview[`pleasereview`] label. Generally PRs should sit with this label for 48 hours in order to garner feedback. It may be merged before if all relevant parties had a look at it.
. PRs that break the external API must be tagged with https://github.com/darwinia-network/darwinia/labels/B2-breaksapi[`breaksapi`], when it changes the SRML or consensus of running system with https://github.com/darwinia-network/darwinia/labels/B3-breaksconsensus[`breaksconsensus`]
. No PR should be merged until all reviews' comments are addressed.

*Reviewing pull requests*:

When reviewing a pull request, the end-goal is to suggest useful changes to the author. Reviews should finish with approval unless there are issues that would result in:

. Buggy behavior.
. Undue maintenance burden.
. Breaking with house coding style.
. Pessimization (i.e. reduction of speed as measured in the projects benchmarks).
. Feature reduction (i.e. it removes some aspect of functionality that a significant minority of users rely on).
. Uselessness (i.e. it does not strictly add a feature or fix a known issue).

*Reviews may not be used as an effective veto for a PR because*:

. There exists a somewhat cleaner/better/faster way of accomplishing the same feature/fix.
. It does not fit well with some other contributors' longer-term vision for the project.

== Helping out

We use https://github.com/darwinia-network/darwinia/labels[labels] to manage PRs and issues and communicate state of a PR. Please familiarize yourself with them. Furthermore we are organizing issues in https://github.com/darwinia-network/darwinia/milestones[milestones]. Best way to get started is to a pick a ticket from the current milestone tagged https://github.com/darwinia-network/darwinia/issues?q=is%3Aissue+is%3Aopen+label%3AQ2-easy[`easy`] or https://github.com/darwinia-network/darwinia/issues?q=is%3Aissue+is%3Aopen+label%3AQ3-medium[`medium`] and get going or https://github.com/darwinia-network/darwinia/issues?q=is%3Aissue+is%3Aopen+label%3AX1-mentor[`mentor`] and get in contact with the mentor offering their support on that larger task.

== Releases

Declaring formal releases remains the prerogative of the project maintainer(s).

== Changes to this arrangement

This is an experiment and feedback is welcome! This document may also be subject to pull-requests or changes by contributors where you believe you have something valuable to add or change.

== Heritage

These contributing guidelines are modified from the "OPEN Open Source Project" guidelines for the Level project: https://github.com/Level/community/blob/master/CONTRIBUTING.md
332 changes: 330 additions & 2 deletions Cargo.lock

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ path = 'node/src/main.rs'

[workspace]
members = [
# "test-client",
# "darwinia-client",
"node/cli",
"node/executor",
"node/primitives",
Expand All @@ -69,6 +69,6 @@ exclude = ["node/runtime/wasm"]
authors = ['Darwinia Network <hello@darwinia.network>']
build = 'build.rs'
edition = '2018'
name = 'darwinia-crayfish'
version = '0.3.0'
name = 'darwinia'
version = '0.3.1'

87 changes: 87 additions & 0 deletions node/cli/res/crayfish-fir.json

Large diffs are not rendered by default.

26 changes: 17 additions & 9 deletions node/cli/src/chain_spec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,10 @@ pub fn flaming_fir_config() -> Result<ChainSpec, String> {
ChainSpec::from_embedded(include_bytes!("../res/flaming-fir.json"))
}

pub fn crayfish_fir_config() -> Result<ChainSpec, String> {
ChainSpec::from_embedded(include_bytes!("../res/crayfish-fir.json"))
}

fn staging_testnet_config_genesis() -> GenesisConfig {
// stash, controller, session-key
// generated with secret:
Expand Down Expand Up @@ -306,10 +310,7 @@ fn crayfish_config_genesis() -> GenesisConfig {
get_authority_keys_from_seed("Bob"),
],
hex!["5225c14bd888f6f623d4c6fb283b3b6bbb76560151f6dbf3476dc2b60c24c476"].unchecked_into(),
Some(vec![
// tony
hex!["12d5e8af67fc5c08ed231619d9210ecad2c665ff5d72e5948e56e82a0553f86b"].unchecked_into()
]),
None,
false,
)
}
Expand Down Expand Up @@ -352,8 +353,8 @@ pub fn crayfish_testnet_genesis(
}),
balances: Some(BalancesConfig {
balances: endowed_accounts.iter().cloned()
.map(|k| (k, 18 * ENDOWMENT))
.chain(initial_authorities.iter().map(|x| (x.0.clone(), ENDOWMENT)))
.map(|k| (k, 1 * ENDOWMENT))
.chain(initial_authorities.iter().map(|x| (x.0.clone(), 4 * ENDOWMENT)))
.collect(),
vesting: vec![],
}),
Expand All @@ -367,8 +368,7 @@ pub fn crayfish_testnet_genesis(
}),
staking: Some(StakingConfig {
current_era: 0,
// TODO: ready for hacking
current_era_total_reward: 80_000_000 * COIN / 63720,
current_era_total_reward: 80_000_000 * COIN / 105120,
minimum_validator_count: 1,
validator_count: 30,
offline_slash: Perbill::from_parts(1_000_000),
Expand Down Expand Up @@ -431,7 +431,15 @@ pub fn local_testnet_config() -> ChainSpec {

/// c￿rayfish testnet config (multivalidator Alice + Bob)
pub fn crayfish_testnet_config() -> ChainSpec {
ChainSpec::from_genesis("Crayfish Testnet", "crayfish_testnet", crayfish_config_genesis, vec![], None, Some("DAR"), None, token_properties())
ChainSpec::from_genesis(
"Darwinia Crayfish Testnet",
"crayfish_testnet",
crayfish_config_genesis,
vec![],
Some(TelemetryEndpoints::new(vec![(STAGING_TELEMETRY_URL.to_string(), 0)])),
Some("DAR"),
None,
token_properties())
}

#[cfg(test)]
Expand Down
5 changes: 4 additions & 1 deletion node/cli/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ pub enum ChainSpec {
StagingTestnet,
/// Crayfish, darwinia network poc-2
CrayfishTestnet,
CrayfishTestnetFir,
}

/// Custom subcommands.
Expand Down Expand Up @@ -125,14 +126,16 @@ impl ChainSpec {
ChainSpec::LocalTestnet => chain_spec::local_testnet_config(),
ChainSpec::StagingTestnet => chain_spec::staging_testnet_config(),
ChainSpec::CrayfishTestnet => chain_spec::crayfish_testnet_config(),
ChainSpec::CrayfishTestnetFir => chain_spec::crayfish_fir_config()?,
})
}

pub(crate) fn from(s: &str) -> Option<Self> {
match s {
"dev" => Some(ChainSpec::Development),
"" => Some(ChainSpec::CrayfishTestnetFir),
"local" => Some(ChainSpec::LocalTestnet),
"" | "crayfish" => Some(ChainSpec::CrayfishTestnet),
"crayfish" => Some(ChainSpec::CrayfishTestnet),
"flaming-fir" => Some(ChainSpec::FlamingFir),
"staging" => Some(ChainSpec::StagingTestnet),
_ => None,
Expand Down
1 change: 1 addition & 0 deletions node/cli/src/panic_handle.rs
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,7 @@ mod tests {
use super::*;

#[test]
#[ignore]
fn does_not_abort() {
set("test");
let _guard = AbortGuard::force_unwind();
Expand Down
2 changes: 1 addition & 1 deletion node/executor/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ node-primitives = { path = "../primitives" }
node-runtime = { path = "../runtime" }

[dev-dependencies]
#test-client = { package = "substrate-test-client", git = 'https://github.com/paritytech/substrate.git' }
test-client = { package = "substrate-test-client", git = 'https://github.com/paritytech/substrate.git', rev = "5bf5e8f5" }
keyring = { package = "substrate-keyring", git = 'https://github.com/paritytech/substrate.git' }
runtime_primitives = { package = "sr-primitives", git = 'https://github.com/paritytech/substrate.git' }
runtime_support = { package = "srml-support", git = 'https://github.com/paritytech/substrate.git' }
Expand Down
62 changes: 14 additions & 48 deletions node/executor/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ mod tests {
fn xt() -> UncheckedExtrinsic {
sign(CheckedExtrinsic {
signed: Some((alice(), 0)),
function: Call::Balances(balances::Call::transfer::<Runtime>(bob().into(), 69)),
function: Call::Balances(balances::Call::transfer::<Runtime>(bob().into(), 69 * COIN)),
})
}

Expand Down Expand Up @@ -247,8 +247,8 @@ mod tests {
assert!(r.is_ok());

runtime_io::with_externalities(&mut t, || {
assert_eq!(Balances::total_balance(&alice()), 110999999789);
assert_eq!(Balances::total_balance(&bob()), 69);
assert_eq!(Balances::total_balance(&alice()), 41997856000);
assert_eq!(Balances::total_balance(&bob()), 69 * COIN);
});
}

Expand Down Expand Up @@ -283,8 +283,8 @@ mod tests {
assert!(r.is_ok());

runtime_io::with_externalities(&mut t, || {
assert_eq!(Balances::total_balance(&alice()), 110999999789);
assert_eq!(Balances::total_balance(&bob()), 69);
assert_eq!(Balances::total_balance(&alice()), 41997856000);
assert_eq!(Balances::total_balance(&bob()), 69 * COIN);
});
}

Expand Down Expand Up @@ -327,7 +327,6 @@ mod tests {
(ferdie(), 100),
],
vesting: vec![],
sys_acc: ferdie(),
}),
session: Some(SessionConfig {
validators: vec![AccountKeyring::One.into(), AccountKeyring::Two.into(), three],
Expand All @@ -349,7 +348,6 @@ mod tests {
minimum_validator_count: 0,
offline_slash: Perbill::zero(),
session_reward: Perbill::zero(),
current_session_reward: 0,
offline_slash_grace: 0,
invulnerables: vec![alice(), bob(), charlie()],
}),
Expand Down Expand Up @@ -435,7 +433,7 @@ mod tests {
},
CheckedExtrinsic {
signed: Some((alice(), 0)),
function: Call::Balances(balances::Call::transfer(bob().into(), 69)),
function: Call::Balances(balances::Call::transfer(bob().into(), 69 * COIN)),
},
]
)
Expand Down Expand Up @@ -524,7 +522,7 @@ mod tests {
runtime_io::with_externalities(&mut t, || {
// block1 transfers from alice 69 to bob.
// -1 is the default fee
assert_eq!(Balances::total_balance(&alice()), 110999999789);
assert_eq!(Balances::total_balance(&alice()), 110997859931);
assert_eq!(Balances::total_balance(&bob()), 100000000069);
// assert_eq!(System::events(), vec![
// EventRecord {
Expand Down Expand Up @@ -577,9 +575,9 @@ mod tests {
runtime_io::with_externalities(&mut t, || {
// bob sends 5, alice sends 15 | bob += 10, alice -= 10
// 111 - 69 - 1 - 10 - 1 = 30
assert_eq!(Balances::total_balance(&alice()), 110999999638);
assert_eq!(Balances::total_balance(&alice()), 110995720921);
// 100 + 69 + 10 - 1 = 178
assert_eq!(Balances::total_balance(&bob()), 99999999938);
assert_eq!(Balances::total_balance(&bob()), 99997861079);
// assert_eq!(System::events(), vec![
// EventRecord {
// phase: Phase::ApplyExtrinsic(0),
Expand Down Expand Up @@ -635,7 +633,7 @@ mod tests {
runtime_io::with_externalities(&mut t, || {
// block1 transfers from alice 69 to bob.
// -1 is the default fee
assert_eq!(Balances::total_balance(&alice()), 110999999789);
assert_eq!(Balances::total_balance(&alice()), 110997859931);
assert_eq!(Balances::total_balance(&bob()), 100000000069);
});

Expand All @@ -644,9 +642,9 @@ mod tests {
runtime_io::with_externalities(&mut t, || {
// bob sends 5, alice sends 15 | bob += 10, alice -= 10
// 111 - 69 - 1 - 10 - 1 = 30
assert_eq!(Balances::total_balance(&alice()), 110999999638);
assert_eq!(Balances::total_balance(&alice()), 110995720921);
// 100 + 69 + 10 - 1 = 178
assert_eq!(Balances::total_balance(&bob()), 99999999938);
assert_eq!(Balances::total_balance(&bob()), 99997861079);
});
}

Expand Down Expand Up @@ -933,8 +931,8 @@ mod tests {
assert_eq!(r, Ok(ApplyOutcome::Success));

runtime_io::with_externalities(&mut t, || {
assert_eq!(Balances::total_balance(&alice()), 110999999789);
assert_eq!(Balances::total_balance(&bob()), 69);
assert_eq!(Balances::total_balance(&alice()), 41997856000);
assert_eq!(Balances::total_balance(&bob()), 69 * COIN);
});
}

Expand Down Expand Up @@ -966,36 +964,4 @@ mod tests {

assert!(t.storage_changes_root(GENESIS_HASH.into()).unwrap().is_some());
}

#[test]
fn should_import_block_with_test_client() {
use test_client::{ClientExt, TestClientBuilder, consensus::BlockOrigin};

let client = TestClientBuilder::default()
.build_with_native_executor::<Block, node_runtime::RuntimeApi, _>(executor())
.0;

let block1 = changes_trie_block();
let block_data = block1.0;
let block = Block::decode(&mut &block_data[..]).unwrap();

client.import(BlockOrigin::Own, block).unwrap();
}

#[cfg(feature = "benchmarks")]
mod benches {
use super::*;
use test::Bencher;

#[bench]
fn wasm_execute_block(b: &mut Bencher) {
let (block1, block2) = blocks();

b.iter(|| {
let mut t = new_test_ext(COMPACT_CODE, false);
WasmExecutor::new().call(&mut t, "Core_execute_block", &block1.0).unwrap();
WasmExecutor::new().call(&mut t, "Core_execute_block", &block2.0).unwrap();
});
}
}
}
6 changes: 3 additions & 3 deletions node/runtime/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ pub use contracts::Gas;
pub use runtime_primitives::{Permill, Perbill, impl_opaque_keys};
pub use support::StorageValue;
pub use staking::StakerStatus;
pub use staking::ErasNums;
pub use staking::EraIndex;


/// Runtime version.
Expand Down Expand Up @@ -230,8 +230,8 @@ parameter_types! {
pub const SessionsPerEra: session::SessionIndex = 5;
// about 14 days
pub const BondingDuration: staking::EraIndex = 4032;
// 365 days * 24 hours * 60 miutes / 5 minutes
pub const ErasPerEpoch: staking::ErasNums = 63720;
// 365 days * 24 hours * 60 minutes / 5 minutes
pub const ErasPerEpoch: EraIndex = 105120;
}

// customed
Expand Down
2 changes: 1 addition & 1 deletion node/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ impl cli::IntoExit for Exit {

fn main() {
let version = VersionInfo {
name: "Darwinia POC-1 Node",
name: "Darwinia Crayfish Node",
commit: env!("VERGEN_SHA_SHORT"),
version: env!("CARGO_PKG_VERSION"),
executable_name: "darwinia",
Expand Down
Loading