Skip to content

Commit 05bea90

Browse files
authored
Merge pull request #1051 from opentensor/test-archive-sync-off-v1.1.8
Fix archive sync panic
2 parents e799bc8 + b2c023b commit 05bea90

File tree

6 files changed

+30
-4
lines changed

6 files changed

+30
-4
lines changed

Diff for: Cargo.lock

+1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Diff for: chainspecs/plain_spec_finney.json

+3-1
Large diffs are not rendered by default.

Diff for: chainspecs/raw_spec_finney.json

+3-1
Large diffs are not rendered by default.

Diff for: node/Cargo.toml

+1
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ clap = { workspace = true, features = ["derive"] }
2525
futures = { workspace = true, features = ["thread-pool"] }
2626
scale-codec = { workspace = true }
2727
serde = { workspace = true, features = ["derive"] }
28+
hex = { workspace = true }
2829

2930
# Storage import
3031
memmap2 = { workspace = true }

Diff for: node/src/chain_spec/code_substitute_2585476.txt

+1
Large diffs are not rendered by default.

Diff for: node/src/chain_spec/finney.rs

+21-2
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
#![allow(clippy::unwrap_used)]
33

44
use super::*;
5+
use hex::FromHex;
56

67
pub fn finney_mainnet_config() -> Result<ChainSpec, String> {
78
let path: PathBuf = std::path::PathBuf::from("./snapshot.json");
@@ -69,7 +70,7 @@ pub fn finney_mainnet_config() -> Result<ChainSpec, String> {
6970
properties.insert("tokenDecimals".into(), 9.into());
7071
properties.insert("ss58Format".into(), 42.into());
7172

72-
Ok(ChainSpec::builder(
73+
let chain_spec = ChainSpec::builder(
7374
wasm_binary,
7475
Extensions {
7576
bad_blocks: Some(HashSet::new()),
@@ -181,7 +182,25 @@ pub fn finney_mainnet_config() -> Result<ChainSpec, String> {
181182
balances_issuance,
182183
))
183184
.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)
185204
}
186205

187206
// Configure initial storage state for FRAME modules.

0 commit comments

Comments
 (0)