Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor and harden check_core_index #6217

Merged
merged 16 commits into from
Nov 5, 2024
Merged

Conversation

alindima
Copy link
Contributor

@alindima alindima commented Oct 24, 2024

Resolves #6179

@alindima alindima added the T8-polkadot This PR/Issue is related to/affects the Polkadot network. label Oct 24, 2024
polkadot/primitives/src/vstaging/mod.rs Outdated Show resolved Hide resolved
polkadot/primitives/src/vstaging/mod.rs Outdated Show resolved Hide resolved
polkadot/primitives/src/vstaging/mod.rs Outdated Show resolved Hide resolved
polkadot/primitives/src/vstaging/mod.rs Outdated Show resolved Hide resolved
polkadot/primitives/src/vstaging/mod.rs Outdated Show resolved Hide resolved
polkadot/primitives/src/vstaging/mod.rs Outdated Show resolved Hide resolved
polkadot/primitives/src/vstaging/mod.rs Outdated Show resolved Hide resolved
Copy link
Member

@ordian ordian left a comment

Choose a reason for hiding this comment

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

I see that we harden the checks in sanitize_backed_candidate_v2, but remove them in inclusion for upward_messages.

I wonder if it makes sense to introduce some type safety around it, so that we make sure the messages we got in inclusion were already checked. But this could be a part of further refactoring.


if signals_iter.next().is_some() {
let Some(core_selector_message) = signals_iter.next() else { return Ok(None) };
// We should have exactly one signal beyond the separator
Copy link
Member

Choose a reason for hiding this comment

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

unrelated q: right now we have a strict check of at most one signal
IIUC this is being check on both node and runtime sides
if we are to add more signals in the future, how are we going to coordinate the upgrade? via node_features?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I discussed this with @sandreim a while ago. Yes, we'll probably use a new node feature

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes, we'll need a feature anyway if we want to introduce a new signal.

} else {
upward_messages
};
let upward_messages = skip_ump_signals(upward_messages.iter()).collect::<Vec<_>>();
Copy link
Member

Choose a reason for hiding this comment

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

this has a downside of allocation in comparison to the previous version, but it copies only references to the messages, so should not be bad

@alindima
Copy link
Contributor Author

alindima commented Nov 5, 2024

I wonder if it makes sense to introduce some type safety around it, so that we make sure the messages we got in inclusion were already checked. But this could be a part of further refactoring.

This would be a good idea for further refactoring.

@sandreim
Copy link
Contributor

sandreim commented Nov 5, 2024

I see that we harden the checks in sanitize_backed_candidate_v2, but remove them in inclusion for upward_messages.

I wonder if it makes sense to introduce some type safety around it, so that we make sure the messages we got in inclusion were already checked. But this could be a part of further refactoring.

This is a very good idea in general: for any thing we check in the runtime we need to have separate types (checked/unchecked).


// Use first commitment
let message = self.upward_messages.get(separator_pos + 1)?;
/// Utility function for skipping the ump signals.
Copy link
Contributor

Choose a reason for hiding this comment

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

Any good reason not to put it inside CandidateCommitments ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yes, in the runtime we use this function after taking the upward messages from the commitments struct

@alindima alindima added this pull request to the merge queue Nov 5, 2024
Merged via the queue into master with commit 74ec1ee Nov 5, 2024
196 of 200 checks passed
@alindima alindima deleted the alindima/harden-check-core-index branch November 5, 2024 12:55
ordian added a commit that referenced this pull request Nov 5, 2024
* master: (129 commits)
  pallet-revive: Use `RUSTUP_TOOLCHAIN` if set (#6365)
  [eth-rpc] proxy /health (#6360)
  [Release|CI/CD] adjust release pipelines (#6366)
  Bump the known_good_semver group across 1 directory with 3 updates (#6339)
  Run check semver in MQ (#6287)
  [Deprecation] deprecate treasury `spend_local` call and related items (#6169)
  refactor and harden check_core_index (#6217)
  litep2p: Update litep2p to v0.8.0 (#6353)
  [pallet-staking] Additional check for virtual stakers (#5985)
  migrate pallet-remarks to v2 bench syntax (#6291)
  Remove leftover references of Wococo (#6361)
  snowbridge: allow account conversion for Ethereum accounts (#6221)
  authority-discovery: Populate DHT records with public listen addresses (#6298)
  Bounty Pallet: add `approve_bounty_with_curator` call to `bounties` pallet (#5961)
  Silent annoying log (#6351)
  [pallet-revive] rework balance transfers (#6187)
  `statement-distribution`: RFC103 implementation (#5883)
  Disable flaky tests reported in #6343 / #6345 (#6346)
  migrate pallet-recovery to benchmark V2 syntax (#6299)
  inclusion emulator: correctly handle UMP signals (#6178)
  ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
T8-polkadot This PR/Issue is related to/affects the Polkadot network.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Runtime: unify and harden UMP signal checks in check_core_index
3 participants