-
Notifications
You must be signed in to change notification settings - Fork 729
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
ensure #[pallet::constant] is actually constant #1139
Comments
We actually (ab)use the fact that it isn't actually a constant (at least in a sense that we can have different values without updating runtime) for implementing dynamic cost of storage (our Otherwise we'll need to refactor and make |
In that case it should not be annotated with |
Well, Bastian suggested that it is fine as long as value stays the same for the duration of a particular block, so we went with that. |
Unstable metadata wouldn't cause any onchain issue, but I am sure @Slesarew will reach out to you one day complaining it breaks parity signer. And it will cause more trouble with #291 paritytech/substrate#10057 |
Did I? :D I can not remember :P To the issue, I'm with you @xlc, but it will maybe also be hard to solve.Using the example of @nazar-pc, we may would need to introduce A trick to check if constants are really constant could be to |
I guess the short term solution will be have |
But in our protocol it does for |
It is not a constant so you should be fine |
Indeed 🤦♂️ It must have been something else then, but I can't recall it right now. But this would be a significant change either way. Ideally we'd use |
I can totally see this breaks a lot of chains, so it could be an opt-in feature to start with. |
|
Metadata should be constant within a version. Otherwise, it won't play nicely with features like #291 |
Yeah, I think to ensure this I would introduce some kind of "no state access" runtime api calls. Then we could move the |
I am pretty sure that the fact that metadata is not a static blob is a mistake, in the same way as it was mistake to make the version a function. Thus I think #2745 is the right way to solve it long term. |
For dynamic parameters, we can have a different attribute, and metadata will return a default value and it's location (storage key) in the storage. I have an issue for it, if sounds good I will work on it - #3238 |
It is possible to annotate a field with
#[pallet::constant]
which is actually not a constant and causing unexpected behaviour.We should have a way to assert the pallet constant are actually constant at compile time. Not exactly sure how it can be implemented but there must be some way.
Related: #934 AcalaNetwork/Acala#2184
The text was updated successfully, but these errors were encountered: