Skip to content

Commit

Permalink
fix: improve initialization of epoch config (#12800)
Browse files Browse the repository at this point in the history
The command `neard view-state -t cold view-chain` is failing when
there's a resharding at the epoch boundary.
This change in the way we initialize `epoch_manager` is fixing the
error.
  • Loading branch information
Trisfald authored Jan 27, 2025
1 parent 0e9911d commit c193875
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
6 changes: 3 additions & 3 deletions tools/state-viewer/src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ impl StateViewerSubCommand {
StateViewerSubCommand::StateChanges(cmd) => cmd.run(home_dir, near_config, store),
StateViewerSubCommand::StateParts(cmd) => cmd.run(home_dir, near_config, store),
StateViewerSubCommand::StateStats(cmd) => cmd.run(home_dir, near_config, store),
StateViewerSubCommand::ViewChain(cmd) => cmd.run(near_config, store),
StateViewerSubCommand::ViewChain(cmd) => cmd.run(home_dir, near_config, store),
StateViewerSubCommand::ViewGenesis(cmd) => cmd.run(home_dir, near_config, store),
StateViewerSubCommand::ViewTrie(cmd) => cmd.run(store),
StateViewerSubCommand::TrieIterationBenchmark(cmd) => cmd.run(near_config, store),
Expand Down Expand Up @@ -833,8 +833,8 @@ pub struct ViewChainCmd {
}

impl ViewChainCmd {
pub fn run(self, near_config: NearConfig, store: Store) {
view_chain(self.height, self.block, self.chunk, near_config, store);
pub fn run(self, home_dir: &Path, near_config: NearConfig, store: Store) {
view_chain(self.height, self.block, self.chunk, home_dir, near_config, store);
}
}

Expand Down
5 changes: 3 additions & 2 deletions tools/state-viewer/src/commands.rs
Original file line number Diff line number Diff line change
Expand Up @@ -736,6 +736,7 @@ pub(crate) fn view_chain(
height: Option<BlockHeight>,
view_block: bool,
view_chunks: bool,
home_dir: &Path,
near_config: NearConfig,
store: Store,
) {
Expand All @@ -758,8 +759,8 @@ pub(crate) fn view_chain(
}
}
};
let epoch_manager = EpochManager::new_from_genesis_config(store, &near_config.genesis.config)
.expect("Failed to start Epoch Manager");
let epoch_manager =
EpochManager::new_arc_handle(store, &near_config.genesis.config, Some(home_dir));
let shard_layout = epoch_manager.get_shard_layout(block.header().epoch_id()).unwrap();

let mut chunk_extras = vec![];
Expand Down

0 comments on commit c193875

Please sign in to comment.