Skip to content

Commit

Permalink
Merge pull request #794 from subspace/gemini-2a-preparation
Browse files Browse the repository at this point in the history
Gemini 2a preparation
  • Loading branch information
nazar-pc authored Sep 2, 2022
2 parents 7dc6ffd + 49bbf79 commit 8e5cad3
Show file tree
Hide file tree
Showing 5 changed files with 114 additions and 6 deletions.
10 changes: 5 additions & 5 deletions .github/workflows/chain-spec-snapshot-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,21 +28,21 @@ jobs:

- name: Generate testnet chain specifications
run: |
docker run --rm -u root ${{ steps.build.outputs.digest }} build-spec --chain gemini-1-compiled > chain-spec-gemini-1.json
docker run --rm -u root ${{ steps.build.outputs.digest }} build-spec --chain gemini-1-compiled --raw > chain-spec-raw-gemini-1.json
docker run --rm -u root ${{ steps.build.outputs.digest }} build-spec --chain gemini-2a-compiled --disable-default-bootnode > chain-spec-gemini-2a.json
docker run --rm -u root ${{ steps.build.outputs.digest }} build-spec --chain gemini-2a-compiled --disable-default-bootnode --raw > chain-spec-raw-gemini-2a.json
- name: Upload chain specifications to artifacts
uses: actions/upload-artifact@v2
with:
name: chain-specifications
path: |
chain-spec-gemini-1.json
chain-spec-raw-gemini-1.json
chain-spec-gemini-2a.json
chain-spec-raw-gemini-2a.json
if-no-files-found: error

- name: Upload chain specifications to assets
uses: alexellis/upload-assets@0.3.0
env:
GITHUB_TOKEN: ${{ github.token }}
with:
asset_paths: '["chain-spec-gemini-1.json", "chain-spec-raw-gemini-1.json"]'
asset_paths: '["chain-spec-gemini-2a.json", "chain-spec-raw-gemini-2a.json"]'
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions crates/subspace-node/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ sc-tracing = { version = "4.0.0-dev", git = "https://github.com/subspace/substra
serde = "1.0.143"
serde_json = "1.0.83"
sp-consensus = { version = "0.10.0-dev", git = "https://github.com/subspace/substrate", rev = "1a7c28721fa77ecce9632ad9ce473f2d3cf1a598" }
sp-consensus-subspace = { version = "0.1.0", path = "../sp-consensus-subspace" }
sp-core = { version = "6.0.0", git = "https://github.com/subspace/substrate", rev = "1a7c28721fa77ecce9632ad9ce473f2d3cf1a598" }
sp-executor = { version = "0.1.0", path = "../sp-executor" }
sp-runtime = { version = "6.0.0", git = "https://github.com/subspace/substrate", rev = "1a7c28721fa77ecce9632ad9ce473f2d3cf1a598" }
Expand Down
106 changes: 105 additions & 1 deletion crates/subspace-node/src/chain_spec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ use cirrus_runtime::GenesisConfig as ExecutionGenesisConfig;
use sc_service::ChainType;
use sc_subspace_chain_specs::{ChainSpecExtensions, ConsensusChainSpec};
use sc_telemetry::TelemetryEndpoints;
use sp_core::crypto::Ss58Codec;
use sp_consensus_subspace::FarmerPublicKey;
use sp_core::crypto::{Ss58Codec, UncheckedFrom};
use sp_executor::ExecutorId;
use subspace_runtime::{
AllowAuthoringBy, BalancesConfig, ExecutorConfig, GenesisConfig, RuntimeConfigsConfig,
Expand Down Expand Up @@ -72,6 +73,109 @@ struct GenesisParams {
max_plot_size: u64,
}

pub fn gemini_2a() -> Result<ConsensusChainSpec<GenesisConfig, ExecutionGenesisConfig>, String> {
unimplemented!()
}

pub fn gemini_2a_compiled(
) -> Result<ConsensusChainSpec<GenesisConfig, ExecutionGenesisConfig>, String> {
Ok(ConsensusChainSpec::from_genesis(
// Name
"Subspace Gemini 2a",
// ID
"subspace_gemini_2a",
ChainType::Custom("Subspace Gemini 2a".to_string()),
|| {
let sudo_account =
AccountId::from_ss58check("5CXTmJEusve5ixyJufqHThmy4qUrrm6FyLCR7QfE4bbyMTNC")
.expect("Wrong root account address");

let mut balances = vec![(sudo_account.clone(), 1_000 * SSC)];
let vesting_schedules = TOKEN_GRANTS
.iter()
.flat_map(|&(account_address, amount)| {
let account_id = AccountId::from_ss58check(account_address)
.expect("Wrong vesting account address");
let amount: Balance = amount * SSC;

// TODO: Adjust start block to real value before mainnet launch
let start_block = 100_000_000;
let one_month_in_blocks =
u32::try_from(3600 * 24 * 30 * MILLISECS_PER_BLOCK / 1000)
.expect("One month of blocks always fits in u32; qed");

// Add balance so it can be locked
balances.push((account_id.clone(), amount));

[
// 1/4 of tokens are released after 1 year.
(
account_id.clone(),
start_block,
one_month_in_blocks * 12,
1,
amount / 4,
),
// 1/48 of tokens are released every month after that for 3 more years.
(
account_id,
start_block + one_month_in_blocks * 12,
one_month_in_blocks,
36,
amount / 48,
),
]
})
.collect::<Vec<_>>();
subspace_genesis_config(
WASM_BINARY.expect("Wasm binary must be built for Gemini"),
sudo_account,
balances,
vesting_schedules,
(
AccountId::from_ss58check("5Df6w8CgYY8kTRwCu8bjBsFu46fy4nFa61xk6dUbL6G4fFjQ")
.expect("Wrong Executor account address"),
ExecutorId::from_ss58check("5FuuXk1TL8DKQMvg7mcqmP8t9FhxUdzTcYC9aFmebiTLmASx")
.expect("Wrong Executor authority address"),
),
GenesisParams {
enable_rewards: false,
enable_storage_access: false,
allow_authoring_by: AllowAuthoringBy::RootFarmer(
FarmerPublicKey::unchecked_from([
0x50, 0x69, 0x60, 0xf3, 0x50, 0x33, 0xee, 0xc1, 0x12, 0xb5, 0xbc, 0xb4,
0xe5, 0x91, 0xfb, 0xbb, 0xf5, 0x88, 0xac, 0x45, 0x26, 0x90, 0xd4, 0x70,
0x32, 0x6c, 0x3f, 0x7b, 0x4e, 0xd9, 0x41, 0x17,
]),
),
enable_executor: false,
// 10GiB
max_plot_size: 10 * 1024 * 1024 * 1024,
},
)
},
// Bootnodes
vec![],
// Telemetry
Some(
TelemetryEndpoints::new(vec![
(POLKADOT_TELEMETRY_URL.into(), 1),
(SUBSPACE_TELEMETRY_URL.into(), 1),
])
.map_err(|error| error.to_string())?,
),
// Protocol ID
Some("subspace-gemini-2a"),
None,
// Properties
Some(chain_spec_properties()),
// Extensions
ChainSpecExtensions {
execution_chain_spec: secondary_chain::chain_spec::development_config(),
},
))
}

pub fn x_net_config() -> Result<ConsensusChainSpec<GenesisConfig, ExecutionGenesisConfig>, String> {
ConsensusChainSpec::from_json_bytes(X_NET_1_CHAIN_SPEC)
}
Expand Down
2 changes: 2 additions & 0 deletions crates/subspace-node/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,8 @@ impl SubstrateCli for Cli {

fn load_spec(&self, id: &str) -> Result<Box<dyn ChainSpec>, String> {
let mut chain_spec = match id {
"gemini-2a" => chain_spec::gemini_2a()?,
"gemini-2a-compiled" => chain_spec::gemini_2a_compiled()?,
"x-net-1" => chain_spec::x_net_config()?,
"x-net-1-compiled" => chain_spec::x_net_config_compiled()?,
"dev" => chain_spec::dev_config()?,
Expand Down

0 comments on commit 8e5cad3

Please sign in to comment.