-
Notifications
You must be signed in to change notification settings - Fork 296
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
pindexer: add a nicer error when a checkpoint genesis is used
This adds an informative error explaining that we need the *original* genesis file, before any upgrades, and why. Closes #4880
- Loading branch information
1 parent
7694c38
commit 3f6b5b6
Showing
4 changed files
with
41 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
use anyhow::{anyhow, Context as _}; | ||
use penumbra_app::genesis::{AppState, Content}; | ||
use serde_json::Value; | ||
|
||
const GENESIS_NO_CONTENT_ERROR: &'static str = r#" | ||
Error: using an upgrade genesis file instead of an initial genesis file. | ||
This genesis file only contains a checkpoint hash of the state, | ||
rather than information about how the initial state of the chain was initialized, | ||
at the very first genesis. | ||
Make sure that you're using the very first genesis file, before any upgrades. | ||
"#; | ||
|
||
/// Attempt to parse content from a value. | ||
/// | ||
/// This is useful to get the initial chain state for app views. | ||
/// | ||
/// This has a nice error message, so you should use this. | ||
pub fn parse_content(data: Value) -> anyhow::Result<Content> { | ||
let app_state: AppState = serde_json::from_value(data) | ||
.context("error decoding app_state json: make sure that this is a penumbra genesis file")?; | ||
let content = app_state | ||
.content() | ||
.ok_or(anyhow!(GENESIS_NO_CONTENT_ERROR))?; | ||
Ok(content.clone()) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters