Skip to content

Commit 49bbf79

Browse files
committed
Gemini 2a chain spec
1 parent 688b260 commit 49bbf79

File tree

5 files changed

+114
-6
lines changed

5 files changed

+114
-6
lines changed

.github/workflows/chain-spec-snapshot-build.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,21 +28,21 @@ jobs:
2828

2929
- name: Generate testnet chain specifications
3030
run: |
31-
docker run --rm -u root ${{ steps.build.outputs.digest }} build-spec --chain gemini-1-compiled --disable-default-bootnode > chain-spec-gemini-1.json
32-
docker run --rm -u root ${{ steps.build.outputs.digest }} build-spec --chain gemini-1-compiled --disable-default-bootnode --raw > chain-spec-raw-gemini-1.json
31+
docker run --rm -u root ${{ steps.build.outputs.digest }} build-spec --chain gemini-2a-compiled --disable-default-bootnode > chain-spec-gemini-2a.json
32+
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
3333
3434
- name: Upload chain specifications to artifacts
3535
uses: actions/upload-artifact@v2
3636
with:
3737
name: chain-specifications
3838
path: |
39-
chain-spec-gemini-1.json
40-
chain-spec-raw-gemini-1.json
39+
chain-spec-gemini-2a.json
40+
chain-spec-raw-gemini-2a.json
4141
if-no-files-found: error
4242

4343
- name: Upload chain specifications to assets
4444
uses: alexellis/[email protected]
4545
env:
4646
GITHUB_TOKEN: ${{ github.token }}
4747
with:
48-
asset_paths: '["chain-spec-gemini-1.json", "chain-spec-raw-gemini-1.json"]'
48+
asset_paths: '["chain-spec-gemini-2a.json", "chain-spec-raw-gemini-2a.json"]'

Cargo.lock

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

crates/subspace-node/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ sc-tracing = { version = "4.0.0-dev", git = "https://github.com/subspace/substra
4141
serde = "1.0.143"
4242
serde_json = "1.0.83"
4343
sp-consensus = { version = "0.10.0-dev", git = "https://github.com/subspace/substrate", rev = "1a7c28721fa77ecce9632ad9ce473f2d3cf1a598" }
44+
sp-consensus-subspace = { version = "0.1.0", path = "../sp-consensus-subspace" }
4445
sp-core = { version = "6.0.0", git = "https://github.com/subspace/substrate", rev = "1a7c28721fa77ecce9632ad9ce473f2d3cf1a598" }
4546
sp-executor = { version = "0.1.0", path = "../sp-executor" }
4647
sp-runtime = { version = "6.0.0", git = "https://github.com/subspace/substrate", rev = "1a7c28721fa77ecce9632ad9ce473f2d3cf1a598" }

crates/subspace-node/src/chain_spec.rs

Lines changed: 105 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,8 @@ use cirrus_runtime::GenesisConfig as ExecutionGenesisConfig;
2424
use sc_service::ChainType;
2525
use sc_subspace_chain_specs::{ChainSpecExtensions, ConsensusChainSpec};
2626
use sc_telemetry::TelemetryEndpoints;
27-
use sp_core::crypto::Ss58Codec;
27+
use sp_consensus_subspace::FarmerPublicKey;
28+
use sp_core::crypto::{Ss58Codec, UncheckedFrom};
2829
use sp_executor::ExecutorId;
2930
use subspace_runtime::{
3031
AllowAuthoringBy, BalancesConfig, ExecutorConfig, GenesisConfig, RuntimeConfigsConfig,
@@ -72,6 +73,109 @@ struct GenesisParams {
7273
max_plot_size: u64,
7374
}
7475

76+
pub fn gemini_2a() -> Result<ConsensusChainSpec<GenesisConfig, ExecutionGenesisConfig>, String> {
77+
unimplemented!()
78+
}
79+
80+
pub fn gemini_2a_compiled(
81+
) -> Result<ConsensusChainSpec<GenesisConfig, ExecutionGenesisConfig>, String> {
82+
Ok(ConsensusChainSpec::from_genesis(
83+
// Name
84+
"Subspace Gemini 2a",
85+
// ID
86+
"subspace_gemini_2a",
87+
ChainType::Custom("Subspace Gemini 2a".to_string()),
88+
|| {
89+
let sudo_account =
90+
AccountId::from_ss58check("5CXTmJEusve5ixyJufqHThmy4qUrrm6FyLCR7QfE4bbyMTNC")
91+
.expect("Wrong root account address");
92+
93+
let mut balances = vec![(sudo_account.clone(), 1_000 * SSC)];
94+
let vesting_schedules = TOKEN_GRANTS
95+
.iter()
96+
.flat_map(|&(account_address, amount)| {
97+
let account_id = AccountId::from_ss58check(account_address)
98+
.expect("Wrong vesting account address");
99+
let amount: Balance = amount * SSC;
100+
101+
// TODO: Adjust start block to real value before mainnet launch
102+
let start_block = 100_000_000;
103+
let one_month_in_blocks =
104+
u32::try_from(3600 * 24 * 30 * MILLISECS_PER_BLOCK / 1000)
105+
.expect("One month of blocks always fits in u32; qed");
106+
107+
// Add balance so it can be locked
108+
balances.push((account_id.clone(), amount));
109+
110+
[
111+
// 1/4 of tokens are released after 1 year.
112+
(
113+
account_id.clone(),
114+
start_block,
115+
one_month_in_blocks * 12,
116+
1,
117+
amount / 4,
118+
),
119+
// 1/48 of tokens are released every month after that for 3 more years.
120+
(
121+
account_id,
122+
start_block + one_month_in_blocks * 12,
123+
one_month_in_blocks,
124+
36,
125+
amount / 48,
126+
),
127+
]
128+
})
129+
.collect::<Vec<_>>();
130+
subspace_genesis_config(
131+
WASM_BINARY.expect("Wasm binary must be built for Gemini"),
132+
sudo_account,
133+
balances,
134+
vesting_schedules,
135+
(
136+
AccountId::from_ss58check("5Df6w8CgYY8kTRwCu8bjBsFu46fy4nFa61xk6dUbL6G4fFjQ")
137+
.expect("Wrong Executor account address"),
138+
ExecutorId::from_ss58check("5FuuXk1TL8DKQMvg7mcqmP8t9FhxUdzTcYC9aFmebiTLmASx")
139+
.expect("Wrong Executor authority address"),
140+
),
141+
GenesisParams {
142+
enable_rewards: false,
143+
enable_storage_access: false,
144+
allow_authoring_by: AllowAuthoringBy::RootFarmer(
145+
FarmerPublicKey::unchecked_from([
146+
0x50, 0x69, 0x60, 0xf3, 0x50, 0x33, 0xee, 0xc1, 0x12, 0xb5, 0xbc, 0xb4,
147+
0xe5, 0x91, 0xfb, 0xbb, 0xf5, 0x88, 0xac, 0x45, 0x26, 0x90, 0xd4, 0x70,
148+
0x32, 0x6c, 0x3f, 0x7b, 0x4e, 0xd9, 0x41, 0x17,
149+
]),
150+
),
151+
enable_executor: false,
152+
// 10GiB
153+
max_plot_size: 10 * 1024 * 1024 * 1024,
154+
},
155+
)
156+
},
157+
// Bootnodes
158+
vec![],
159+
// Telemetry
160+
Some(
161+
TelemetryEndpoints::new(vec![
162+
(POLKADOT_TELEMETRY_URL.into(), 1),
163+
(SUBSPACE_TELEMETRY_URL.into(), 1),
164+
])
165+
.map_err(|error| error.to_string())?,
166+
),
167+
// Protocol ID
168+
Some("subspace-gemini-2a"),
169+
None,
170+
// Properties
171+
Some(chain_spec_properties()),
172+
// Extensions
173+
ChainSpecExtensions {
174+
execution_chain_spec: secondary_chain::chain_spec::development_config(),
175+
},
176+
))
177+
}
178+
75179
pub fn x_net_config() -> Result<ConsensusChainSpec<GenesisConfig, ExecutionGenesisConfig>, String> {
76180
ConsensusChainSpec::from_json_bytes(X_NET_1_CHAIN_SPEC)
77181
}

crates/subspace-node/src/lib.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -223,6 +223,8 @@ impl SubstrateCli for Cli {
223223

224224
fn load_spec(&self, id: &str) -> Result<Box<dyn ChainSpec>, String> {
225225
let mut chain_spec = match id {
226+
"gemini-2a" => chain_spec::gemini_2a()?,
227+
"gemini-2a-compiled" => chain_spec::gemini_2a_compiled()?,
226228
"x-net-1" => chain_spec::x_net_config()?,
227229
"x-net-1-compiled" => chain_spec::x_net_config_compiled()?,
228230
"dev" => chain_spec::dev_config()?,

0 commit comments

Comments
 (0)