Skip to content
This repository has been archived by the owner on Nov 15, 2023. It is now read-only.

Remove without_storage_info for the node-authorization pallet #11621

Closed

Conversation

koute
Copy link
Contributor

@koute koute commented Jun 8, 2022

Part of paritytech/polkadot-sdk#323

This PR changes the logic in the following way:

  • The well known nodes inserted during genesis are now bound by the MaxPeerIdLength and MaxWellKnownNodes constants. (Previously this wasn't enforced.)
  • The reset_well_known_nodes now enforces that the peer IDs passed in the nodes are bound by MaxPeerIdLength. (Previously this wasn't enforced.)
  • The reset_well_known_nodes now enforces that the number of nodes is bound by exactly MaxWellKnownNodes. (Previously it enforced a limit of MaxWellKnownNodes - 1, which I assume was an off-by-one error?)
  • The set inside of the AdditionalConnections is now bound by the MaxAdditionalConnections constant. (Previously it was uncapped.)
  • The add_connections and remove_connections now enforce that the peer IDs passed in the connections are bound by MaxPeerIdLength. (Previously this wasn't enforced.)
  • The offchain_worker hook now enforces that the state.peer_id is now at most MaxPeerIdLength long. (Previously this wasn't enforced.)

Marking as D5-nicetohaveaudit since this does change the logic.

Since this enforces extra bounds which weren't previously enforced do we need to do anything extra here?

@koute koute added A0-please_review Pull request needs code review. B0-silent Changes should not be mentioned in any release notes C1-low PR touches the given topic and has a low impact on builders. D5-nicetohaveaudit ⚠️ PR contains trivial changes to logic that should be properly reviewed. labels Jun 8, 2022
@koute koute requested review from shawntabrizi, KiChjang and ggwpez June 8, 2022 07:41
#[derive(Encode, Decode, RuntimeDebug, TypeInfo, MaxEncodedLen)]
#[codec(mel_bound())]
#[scale_info(skip_type_params(T))]
pub struct BoundedPeerId<T: Config>(BoundedVec<u8, T::MaxPeerIdLength>);
Copy link
Contributor

Choose a reason for hiding this comment

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

I think we should really try to give an upper bound on PeerId itself, rather than creating a container type around it to sidestep the issue. @shawntabrizi How exactly should we make primitive types bounded?

@stale
Copy link

stale bot commented Jul 16, 2022

Hey, is anyone still working on this? Due to the inactivity this issue has been automatically marked as stale. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the A5-stale Pull request did not receive any updates in a long time. No review needed at this stage. Close it. label Jul 16, 2022
@koute
Copy link
Contributor Author

koute commented Jul 16, 2022

not stale

@stale stale bot removed the A5-stale Pull request did not receive any updates in a long time. No review needed at this stage. Close it. label Jul 16, 2022
@stale
Copy link

stale bot commented Aug 15, 2022

Hey, is anyone still working on this? Due to the inactivity this issue has been automatically marked as stale. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the A5-stale Pull request did not receive any updates in a long time. No review needed at this stage. Close it. label Aug 15, 2022
@koute
Copy link
Contributor Author

koute commented Aug 15, 2022

not stale

@stale stale bot removed the A5-stale Pull request did not receive any updates in a long time. No review needed at this stage. Close it. label Aug 15, 2022
@stale
Copy link

stale bot commented Sep 14, 2022

Hey, is anyone still working on this? Due to the inactivity this issue has been automatically marked as stale. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the A5-stale Pull request did not receive any updates in a long time. No review needed at this stage. Close it. label Sep 14, 2022
@koute
Copy link
Contributor Author

koute commented Sep 14, 2022

not stale

@stale stale bot removed the A5-stale Pull request did not receive any updates in a long time. No review needed at this stage. Close it. label Sep 14, 2022
@stale
Copy link

stale bot commented Oct 14, 2022

Hey, is anyone still working on this? Due to the inactivity this issue has been automatically marked as stale. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the A5-stale Pull request did not receive any updates in a long time. No review needed at this stage. Close it. label Oct 14, 2022
@koute
Copy link
Contributor Author

koute commented Oct 15, 2022

not stale

@stale stale bot removed the A5-stale Pull request did not receive any updates in a long time. No review needed at this stage. Close it. label Oct 15, 2022
Comment on lines +106 to +110
impl<T: Config> PartialEq for BoundedPeerId<T> {
fn eq(&self, rhs: &Self) -> bool {
self.0.eq(&rhs.0)
}
}
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
impl<T: Config> PartialEq for BoundedPeerId<T> {
fn eq(&self, rhs: &Self) -> bool {
self.0.eq(&rhs.0)
}
}

There are PartialEqNoBound, CloneNoBound and a few others.

let owner = Owners::<T>::get(&node).ok_or(Error::<T>::NotClaimed)?;
ensure!(owner == sender, Error::<T>::NotOwner);

let mut nodes = AdditionalConnections::<T>::get(&node);

let mut nodes: BTreeSet<_> = AdditionalConnections::<T>::get(&node).into();
Copy link
Member

Choose a reason for hiding this comment

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

Nit:

Suggested change
let mut nodes: BTreeSet<_> = AdditionalConnections::<T>::get(&node).into();
let mut nodes = AdditionalConnections::<T>::get(&node);

then you can try_insert below and dont have to bound it again.

for (peer_id, account_id) in nodes {
let peer_id = BoundedPeerId::<T>::try_from(peer_id.clone())?;
peer_ids.try_insert(peer_id.clone()).map_err(|_| Error::<T>::TooManyNodes)?;
owners.push((peer_id, account_id));
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
owners.push((peer_id, account_id));
Owners::<T>::insert(peer_id, account_id);

and remove the owners vector?

@stale
Copy link

stale bot commented Nov 17, 2022

Hey, is anyone still working on this? Due to the inactivity this issue has been automatically marked as stale. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the A5-stale Pull request did not receive any updates in a long time. No review needed at this stage. Close it. label Nov 17, 2022
@koute
Copy link
Contributor Author

koute commented Nov 17, 2022

not stale

@stale stale bot removed the A5-stale Pull request did not receive any updates in a long time. No review needed at this stage. Close it. label Nov 17, 2022
@stale
Copy link

stale bot commented Dec 17, 2022

Hey, is anyone still working on this? Due to the inactivity this issue has been automatically marked as stale. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the A5-stale Pull request did not receive any updates in a long time. No review needed at this stage. Close it. label Dec 17, 2022
@stale stale bot closed this Dec 31, 2022
@koute koute reopened this Jan 10, 2023
@stale stale bot removed A5-stale Pull request did not receive any updates in a long time. No review needed at this stage. Close it. labels Jan 10, 2023
@stale
Copy link

stale bot commented Feb 9, 2023

Hey, is anyone still working on this? Due to the inactivity this issue has been automatically marked as stale. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the A5-stale Pull request did not receive any updates in a long time. No review needed at this stage. Close it. label Feb 9, 2023
@koute koute removed the A5-stale Pull request did not receive any updates in a long time. No review needed at this stage. Close it. label Feb 10, 2023
@stale
Copy link

stale bot commented Mar 12, 2023

Hey, is anyone still working on this? Due to the inactivity this issue has been automatically marked as stale. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the A3-stale label Mar 12, 2023
@stale stale bot closed this Mar 26, 2023
@juangirini
Copy link
Contributor

@koute do you feel like taking this over again? We will review it 😇

@koute
Copy link
Contributor Author

koute commented Jun 9, 2023

@koute do you feel like taking this over again? We will review it

Sure I can. Could I get some feedback as to how this should be done? Is the way I did it okay, or does anything else has to change? (Besides @ggwpez 's comments which I'll address.)

@juangirini
Copy link
Contributor

I think this is pretty much ready. @ggwpez I loop you in as you are more familiar with it to answer koute

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
A0-please_review Pull request needs code review. A3-stale B0-silent Changes should not be mentioned in any release notes C1-low PR touches the given topic and has a low impact on builders. D5-nicetohaveaudit ⚠️ PR contains trivial changes to logic that should be properly reviewed.
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

4 participants