-
Notifications
You must be signed in to change notification settings - Fork 2.6k
pallet macro: allow to declare individual unbounded storage for those who cannot go into PoV #9670
Conversation
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.
LGTM, why is the system::event not already tagged?
Co-authored-by: Kian Paimani <5588131+kianenigma@users.noreply.github.com>
for now event goes into PoV, and frame_system doesn't declare the storage info bounds, so no storage are bounded. |
for attr in attrs { | ||
match attr { | ||
PalletStorageAttr::Getter(ident, ..) if getter.is_none() => getter = Some(ident), | ||
PalletStorageAttr::StorageName(name, ..) if rename_as.is_none() => |
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.
This seems like a change in api: before we errored if there was more than 1 getter
or name
. Now we simply skip anything after the first one.
for example we had
if names.len() > 1 {
let msg = "Invalid pallet::storage, multiple argument pallet::storage_prefix found";
return Err(syn::Error::new(names[1].attr_span(), msg))
}
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.
looking at the UI tests though it seems like it still complains about a duplicate attribute, is this just now an error we can rely on the compiler for?
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.
the duplicate attribute is not from the compiler it is from the last matching arm below, in case rename_as is already some, then the last matching are is branched and the error is raised
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.
My understanding of the proc-macro libs is really not great, but from my level of understanding it looks ok.
bot merge |
Waiting for commit status. |
This PR introduce a new attribute in the pallet macro for storage:
pallet::unbounded
.This attribute allow to declare that a storage doesn't have bounds on its keys and value types and thus only generate partial storage information.
For storage who cannot go into PoV this is useful. Like system event for instance.
Limitation: Maybe the some storage might want to express the bounds on the key types but not the bound on the value. Currently the storage info doesn't support this. I think we can implement more fine grained description when the need comes.