tfchain icon indicating copy to clipboard operation
tfchain copied to clipboard

Pallet KV: Decrease storage and computational overhead

Open sameh-farouk opened this issue 1 year ago • 0 comments

Emitting too much information in events can be wasteful and inefficient, as it may consume unnecessary on-chain storage space. Currently, we emit the value alongside the account id and user key for each event (when creating and deleted key-pair). However, this is redundant since the value can be retrieved from the kv storage by using the account id and the user key. given the value can be up to 2048 bytes, we are paying unnecessary storage costs. from substrate docs:

In general, events inform users or applications such as a block explorer that a change occurred. Events aren't intended to describe differences in state or to contain detailed information. You should use caution in adding more information to an event than is needed because additional information increases storage and computational overhead involved in producing events. If additional information about a change is needed, users can query the chain state.

sameh-farouk avatar Jul 25 '23 11:07 sameh-farouk