JoshOrndorff / recipes

A Hands-On Cookbook for Aspiring Blockchain Chefs
GNU General Public License v3.0
376 stars 186 forks source link

fix pallets weight #397

Closed honeywest closed 3 years ago

honeywest commented 3 years ago

It's better to understand Original logic error

danforbes commented 3 years ago

Hello, thank you for all your recent contributions! I will take some time to review them soon :pray: I'd love to learn more about your interest in Substrate, so please feel free to send me a direct message in our Element technical chat if you have joined, or you can email me at dan@parity.io if you'd like to chat :nerd_face:

danforbes commented 3 years ago

@honeywest - can you explain the changes in this PR a bit more? I am not very familiar with this recipe, but it looks like the logic is being changed in a rather fundamental way. Why do you believe there is an error in the original logic? Maybe @JoshOrndorff has thoughts if he has a chance to look? 🙏🏻

JoshOrndorff commented 3 years ago

Since this is a recipe about weights, that bug would have been a security vulnerability. A malicious user could call the extrinsic with the add flag set, consume all the compute to increment the counter repeatedly, and only be charged the fixed rate for set.

It would be good to be able to test this kind of thing. I'm not sure how to do that.