Fix weight accounting
The problem is slightly different from the previously raised issue due to the deletion of instance pallets. Currently, the problem lies in having two tuple handlers (OnIdtyChange
and Event
). The weight of the function calling these handlers is the sum of each implementation. If these functions are not called in hooks, it will be possible to take the worst possible path as an approximation. However, some are called in on_initialize
, and the worst case is close to 7% of a block, approximately 10 times the average path.
-
Add weight return in OnIdtyChange
andEvent
handlers. -
Account for the weight where these handlers are called. -
Replace all +=
,-=
bysaturating_add
andsaturating_sub
for consistency. -
Closes #163 (closed). -
Closes #203 (closed)
Note: Some handlers are difficult to benchmark using a benchmark function, so the accounting is performed by counting reads and writes, inspired by the staking pallet from Substrate.
Closes #167 (closed)
Edited by Benjamin Gallois