|
2 | 2 | #![allow(clippy::unwrap_used)]
|
3 | 3 |
|
4 | 4 | use super::*;
|
| 5 | +use hex::FromHex; |
5 | 6 |
|
6 | 7 | pub fn finney_mainnet_config() -> Result<ChainSpec, String> {
|
7 | 8 | let path: PathBuf = std::path::PathBuf::from("./snapshot.json");
|
@@ -69,7 +70,7 @@ pub fn finney_mainnet_config() -> Result<ChainSpec, String> {
|
69 | 70 | properties.insert("tokenDecimals".into(), 9.into());
|
70 | 71 | properties.insert("ss58Format".into(), 42.into());
|
71 | 72 |
|
72 |
| - Ok(ChainSpec::builder( |
| 73 | + let chain_spec = ChainSpec::builder( |
73 | 74 | wasm_binary,
|
74 | 75 | Extensions {
|
75 | 76 | bad_blocks: Some(HashSet::new()),
|
@@ -181,7 +182,25 @@ pub fn finney_mainnet_config() -> Result<ChainSpec, String> {
|
181 | 182 | balances_issuance,
|
182 | 183 | ))
|
183 | 184 | .with_properties(properties)
|
184 |
| - .build()) |
| 185 | + .build(); |
| 186 | + |
| 187 | + // Load and set the code substitute to avoid archive node sync panic |
| 188 | + // See <https://github.com/opentensor/subtensor/pull/1051> |
| 189 | + // |
| 190 | + // Need to do it in this hacky way because the ChainSpec builder doesn't support setting it |
| 191 | + let code_substitute_2585476_hex = include_bytes!("code_substitute_2585476.txt"); |
| 192 | + let chain_spec_json = chain_spec.as_json(false).unwrap(); |
| 193 | + let mut chain_spec_json = serde_json::from_str(&chain_spec_json).unwrap(); |
| 194 | + sc_chain_spec::set_code_substitute_in_json_chain_spec( |
| 195 | + &mut chain_spec_json, |
| 196 | + Vec::from_hex(code_substitute_2585476_hex) |
| 197 | + .unwrap() |
| 198 | + .as_slice(), |
| 199 | + 2585476, |
| 200 | + ); |
| 201 | + let chain_spec_bytes = chain_spec_json.to_string().into_bytes(); |
| 202 | + let chain_spec = ChainSpec::from_json_bytes(chain_spec_bytes).unwrap(); |
| 203 | + Ok(chain_spec) |
185 | 204 | }
|
186 | 205 |
|
187 | 206 | // Configure initial storage state for FRAME modules.
|
|
0 commit comments