While implementing my chain logic I was wondering whether to use events at all since they might cost the node extra storage for the event logs. What is the actual storage cost involved here? Do the logs get purged automatically at some point?
What is the cost of event storage in substrate?
729 Views Asked by vim At
2
Runtime events are handled by the System module. Within your own module, you normally implement the default
deposit_eventfunction:From the in-code documentation:
If you look at the System module code, you will find that ultimately a helper function is called which stores the event:
This function modifies three storage items which you can find in the
decl_storagefor the System module:The final part of the event story can be found in the
initializefunction in the System module, where all three of these items are "cleaned up":This
initializefunction is called in the Executive module at the beginning of every block, beforeon_initializeis called for any module:In conclusion, the cost of adding a single Event in the runtime is:
deposit_event_indexedfunction.