Skip to content

Fix: SubstrateConfigBuilder::set_genesis_hash is a no-op#2236

Open
RomarQ wants to merge 2 commits into
paritytech:masterfrom
RomarQ:fix/substrate-config-genesis-hash
Open

Fix: SubstrateConfigBuilder::set_genesis_hash is a no-op#2236
RomarQ wants to merge 2 commits into
paritytech:masterfrom
RomarQ:fix/substrate-config-genesis-hash

Conversation

@RomarQ
Copy link
Copy Markdown

@RomarQ RomarQ commented May 18, 2026

SubstrateConfigBuilder::set_genesis_hash is a no-op: the value is stored on the builder but build() never copies it into SubstrateConfigInner, and impl Config for SubstrateConfig never overrides genesis_hash(), so it falls back to the trait default of None.

Offline workflows that rely on the configured genesis hash fail with ExtrinsicError::GenesisHashNotProvided:

let config = SubstrateConfig::builder()
    .set_genesis_hash(genesis_hash)
    .set_metadata_for_spec_versions(...)
    .set_spec_version_for_block_ranges(...)
    .build();
let client = OfflineClient::<SubstrateConfig>::new_with_config(config);
let at_block = client.at_block(0u64)?;
at_block.tx().create_signable_offline(&call, params)?; // GenesisHashNotProvided

The OnlineClient path is unaffected, since the hash is fetched from the network when genesis_hash is None.

This adds the missing genesis_hash field on SubstrateConfigInner, propagates it through build(), and overrides Config::genesis_hash for SubstrateConfig.

@RomarQ RomarQ marked this pull request as ready for review May 18, 2026 20:47
…sis_hash

`SubstrateConfigBuilder::set_genesis_hash` stored the value on the
builder, but `build()` did not propagate it to `SubstrateConfigInner`,
and `impl Config for SubstrateConfig` never overrode `genesis_hash()`,
falling back to the trait default of `None`.

As a result, offline workflows that rely on the configured genesis hash
(e.g. `OfflineClient::new_with_config(...).at_block(...).tx().create_signable_offline(...)`)
fail with `ExtrinsicError::GenesisHashNotProvided` even when the user
calls `set_genesis_hash`. The online path is unaffected because the
genesis hash comes from the network and is stored on `OnlineClient`.

`PolkadotConfig` inherits the same behaviour since its
`genesis_hash()` delegates to the wrapped `SubstrateConfig`.

Add the missing wiring (one field, one impl method) and a couple of
tests covering the two paths.
@RomarQ RomarQ force-pushed the fix/substrate-config-genesis-hash branch from 3010037 to 9ea70a5 Compare May 18, 2026 21:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants