Skip to content

Fix override encoding, verify spawned forks, carry runtime upgrades - #128

Merged
mordamax merged 5 commits into
mainfrom
fix/overrides-and-fork-verify
Aug 26, 2026
Merged

Fix override encoding, verify spawned forks, carry runtime upgrades#128
mordamax merged 5 commits into
mainfrom
fix/overrides-and-fork-verify

Conversation

@mordamax

@mordamax mordamax commented Aug 21, 2026

Copy link
Copy Markdown
Contributor
  • Fix ValidatorGroups encoding (inner compact lengths), drop no-op ClaimQueue/AvailabilityCores overrides, share validator count between overrides and spawner.
  • Post-spawn verification: finalized-height monitoring, divergence check vs source at bite block + 5, reject chain_spec_path without chain.
  • --rc-upgrade/--para-upgrade seed System::AuthorizedUpgrade instead of installing the runtime; --apply-upgrade submits apply_authorized_upgrade unsigned (no sudo needed) and waits for the spec version bump.

Closes #121
Closes #122
Closes #127

@mordamax
mordamax marked this pull request as ready for review August 21, 2026 20:59
@mordamax
mordamax requested a review from pepoviola August 21, 2026 20:59
Comment thread src/cli.rs Outdated
#[arg(long = "rc-upgrade", verbatim_doc_comment)]
relay_upgrade: Option<String>,
/// Same as --rc-upgrade but for a parachain, format: <para_id>=<wasm_path>
/// (can be repeated)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
/// (can be repeated)
/// Can be set multiple times, onces per para to upgrde.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Applied, thanks.

Comment thread src/config.rs
/// clamped between the two nodes the spawner always starts (alice, bob) and
/// the seven well-known dev accounts. Used by both the state overrides and the
/// spawner so the validator set in state always matches the nodes running.
pub fn num_validators_for_cores(req_cores: u32) -> u32 {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NOTE: At some point we should remove this dev validators constraint.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed — added a TODO. The cap is only there because we reuse the well-known dev accounts; generating keys would let a fork scale past 7.

Comment thread src/doppelganger.rs Outdated
let mut seen_chains: Vec<&str> = vec![];
for para in network_config.parachains() {
let chain = para.chain().map(|c| c.as_str());
if para.chain_spec_path().is_some() && chain.is_none() {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we read the id from the chain-spec and use that, since if we have the chain-spec we will not use the chain.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done. Identity is now chain when set, else the spec's id. Also checked zombienet 0.4.13: with no chain it falls back to unique_id (the para id), so a missing chain isn't fatal there — no reason to reject it.

Comment thread src/doppelganger.rs Outdated
if let Some(chain) = chain {
if seen_chains.contains(&chain) {
bail!(
"parachain {} reuses chain name '{chain}'; each parachain needs a unique 'chain' or they will share one chain spec",

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hm, I don't think we need to ensure that all chains are unique but is a nice to have 👍

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Kept it, now keyed on the resolved identity instead of the raw chain name.

Comment thread src/main.rs Outdated
Comment on lines +188 to +189
error!("--apply-upgrade can only be used with --and-spawn");
std::process::exit(1);

@pepoviola pepoviola Aug 25, 2026

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we can replace it for bail macro here and in the rest.

Suggested change
error!("--apply-upgrade can only be used with --and-spawn");
std::process::exit(1);
bail!("--apply-upgrade can only be used with --and-spawn");

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Switched all three to bail!. Left the "bite dir doesn't exist" block as-is since it prints the colored usage help.

Comment thread src/overrides.rs
/// `authorize_upgrade(hash)` referendum leaves behind. The permissionless
/// `apply_authorized_upgrade(blob)` can then enact the upgrade through the
/// production path, which needs no sudo (usable on Kusama/Polkadot forks).
async fn inject_authorized_upgrade(injects: &mut Value, upgrade_wasm: &str) {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice!

Comment thread src/upgrade.rs

/// Parachain upgrades wait for relay-side PVF pre-checking plus the go-ahead
/// signal before enacting.
const UPGRADE_TIMEOUT_SECS: u64 = 900;

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this mesure for prod environments? I mean, the 900s

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no, not yet, going to test this with custom implementation now on PPN and will adjust if needed

@pepoviola pepoviola left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome job @mordamax, just some nit comments inline.

Comment thread src/doppelganger.rs
if para.chain_spec_path().is_some() && chain.is_none() {
let identity = if let Some(chain) = para.chain() {
chain.as_str().to_string()
} else if let Some(AssetLocation::FilePath(path)) = para.chain_spec_path() {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We have support for file and url as assetLocation, I will rewrite this to support both 👍

@mordamax
mordamax merged commit 2f09d11 into main Aug 26, 2026
4 checks passed
@mordamax
mordamax deleted the fix/overrides-and-fork-verify branch August 26, 2026 14:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

2 participants