-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Remove without_storage_info
for the node-authorization
pallet
#11621
Conversation
#[derive(Encode, Decode, RuntimeDebug, TypeInfo, MaxEncodedLen)] | ||
#[codec(mel_bound())] | ||
#[scale_info(skip_type_params(T))] | ||
pub struct BoundedPeerId<T: Config>(BoundedVec<u8, T::MaxPeerIdLength>); |
There was a problem hiding this comment.
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?
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. |
not stale |
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. |
not stale |
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. |
not stale |
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. |
not stale |
impl<T: Config> PartialEq for BoundedPeerId<T> { | ||
fn eq(&self, rhs: &Self) -> bool { | ||
self.0.eq(&rhs.0) | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit:
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)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
owners.push((peer_id, account_id)); | |
Owners::<T>::insert(peer_id, account_id); |
and remove the owners
vector?
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. |
not stale |
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. |
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. |
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. |
@koute do you feel like taking this over again? We will review it 😇 |
I think this is pretty much ready. @ggwpez I loop you in as you are more familiar with it to answer koute |
Part of paritytech/polkadot-sdk#323
This PR changes the logic in the following way:
MaxPeerIdLength
andMaxWellKnownNodes
constants. (Previously this wasn't enforced.)reset_well_known_nodes
now enforces that the peer IDs passed in thenodes
are bound byMaxPeerIdLength
. (Previously this wasn't enforced.)reset_well_known_nodes
now enforces that the number of nodes is bound by exactlyMaxWellKnownNodes
. (Previously it enforced a limit ofMaxWellKnownNodes - 1
, which I assume was an off-by-one error?)AdditionalConnections
is now bound by theMaxAdditionalConnections
constant. (Previously it was uncapped.)add_connections
andremove_connections
now enforce that the peer IDs passed in theconnections
are bound byMaxPeerIdLength
. (Previously this wasn't enforced.)offchain_worker
hook now enforces that thestate.peer_id
is now at mostMaxPeerIdLength
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?