1

Is there such a thing in FRAME or otherwise to have a "register" item similar to C referencing a storage item in working runtime memory?

Specifically: I need a storage value in BaseCallFilter that will execute a storage read for every call to the runtime . I want to optimize this if at all possible to only one read & cache for any other BaseCallFilter checks when constructing for a particular block.

I wonder if this is something generic that can be expressed to ensure it happens in other cases runtime engineers need to read the same item very very often.

1 Answer 1

2

No, there is no way to specify values that are read often. However, there is a read-through cache which hopefully already have the data cached from the previous block or cache it on the first read in the current block. This cache improves the read performance by factor ~11 versus reading from the database.

In your pallet you can use the attribute #[pallet::whitelist_storage] above your storage value. This will tell benchmarking to ignore these keys when calculating the weight formula for your call. This should be used for these kind of keys where you know that they are "always cached" as they are accessed in each block multiple times.

2
  • 1
    I think the benchmarking bypasses the call-filter anyway, so in that case it would not need to be whitelisted. The effort will then be accounted for in the ExtrinsicBaseWeight. Dec 15, 2022 at 20:28
  • 2
    Yes that is right. I wanted to give some broader explanation around possible other questions.
    – bkchr
    Dec 15, 2022 at 23:20

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.