Skip to content

[stable2503] Backport #7936#8201

Closed
paritytech-release-backport-bot[bot] wants to merge 1 commit intostable2503from
backport-7936-to-stable2503
Closed

[stable2503] Backport #7936#8201
paritytech-release-backport-bot[bot] wants to merge 1 commit intostable2503from
backport-7936-to-stable2503

Conversation

@paritytech-release-backport-bot
Copy link
Copy Markdown

Backport #7936 into stable2503 from Ank4n.

See the documentation on how to use this bot.

…nce` (#7936)

closes #6344.
related paritytech/substrate#14048.

---

## Overview
Post-AHM, RC will no longer have validator exposure information, as all
of it will move to AH alongside `pallet-staking`. Currently, we use
`Exposure` to identify a validator when an offence report is received.
After this change, we’ll only need to check whether the validator exists
in the session.

Also, the storage map `pallet-offences::Reports` depends on the
`Exposure` type and is heavily bloated (and never cleared). There was
[some work](paritytech/substrate#14048) to clean
it up, but it was never completed. Replacing `Exposure` with `Existence`
would make the old storage undecodable, and migrating it would be a
pain. The `pallet-offences` storage layout needs to be redesigned, and I
didn’t want to make any rushed decisions there that could lead to
long-term issues.

Instead, this PR introduces a new type, `ExistenceOrLegacyExposure`,
with a custom encoder/decoder that can handle both the legacy `Exposure`
and the new `Existence` type.

It also introduces `ExistenceOf` and `ExistenceOrLegacyExposureOf`,
which replaces `ExposureOf`. With this change, runtimes can be
configured to identify a validator based solely on their presence,
without needing full exposure data.

This is useful when configuring historical sessions. For example:
```
impl pallet_session::historical::Config for Runtime {
	type FullIdentification = pallet_staking::Existence;
	type FullIdentificationOf = pallet_staking::ExistenceOf<Runtime>;
}
```

## Backward Compatibility

For existing runtimes that still depend on the Exposure type in
pallet-offences — typically configured like this:

```
impl pallet_offences::Config for Runtime {
        ...
	type IdentificationTuple = pallet_session::historical::IdentificationTuple<Self>;
}
```

Where `IdentificationTuple` is defined as:
```
pub type IdentificationTuple<T> =
	(<T as pallet_session::Config>::ValidatorId, <T as Config>::FullIdentification);

```

You should now use `ExistenceOrLegacyExposureOf`. This type includes a
custom encoder/decoder that supports both the legacy `Exposure` and the
new `Existence` types.

This compatibility layer is essential to ensure the `Offences::Reports`
storage map can still decode older entries.

## TODO
- [x] TryStateCheck to see existing offence report decodes correctly.

---------

Co-authored-by: cmd[bot] <41898282+github-actions[bot]@users.noreply.github.com>
(cherry picked from commit 68aa033)
@github-actions github-actions bot added the A3-backport Pull request is already reviewed well in another branch. label Apr 9, 2025
@github-actions github-actions bot requested a review from Ank4n April 9, 2025 12:57
@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Apr 9, 2025

This pull request is amending an existing release. Please proceed with extreme caution,
as to not impact downstream teams that rely on the stability of it. Some things to consider:

  • Backports are only for 'patch' or 'minor' changes. No 'major' or other breaking change.
  • Should be a legit fix for some bug, not adding tons of new features.
  • Must either be already audited or not need an audit.
Emergency Bypass

If you really need to bypass this check: add validate: false to each crate
in the Prdoc where a breaking change is introduced. This will release a new major
version of that crate and all its reverse dependencies and basically break the release.

@Ank4n
Copy link
Copy Markdown
Contributor

Ank4n commented Apr 9, 2025

This does not need to be backported.

@Ank4n Ank4n closed this Apr 9, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A3-backport Pull request is already reviewed well in another branch.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant