-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Conversation
This PR adds a fuzzer for the `SortedListProvider` API exposed by pallet-bags-list.
frame/bags-list/fuzzer/src/main.rs
Outdated
let id = account_id_seed % ID_RANGE; | ||
|
||
match account_id_seed % OPTIONS { | ||
0 => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: you can use an enum here to specify which operation is which number. transmute will work, more options here: https://stackoverflow.com/questions/28028854/how-do-i-match-enum-values-with-an-integer/29530566
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice, lmk what you think about the style of my approach - a bit more verbose than using transmute, but I rather avoid unsafe code if its not neccesary
frame/bags-list/src/mock.rs
Outdated
ids: Vec<(AccountId, VoteWeight)>, | ||
} | ||
|
||
impl ExtBuilder { | ||
/// Add some AccountIds to insert into `List`. | ||
#[cfg(not(feature = "fuzz"))] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hmm, why?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It was an attempt to get the CI not break when it sees unused code .. but seems to be causing other issues in the CI now
frame/bags-list/fuzzer/src/main.rs
Outdated
assert!(BagsList::contains(&id)); | ||
}, | ||
1 => { | ||
if !BagsList::contains(&id) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
arguably we could also let the raw apis be accessed without us helping it such as "insert before update if it is not there". I think on_update
handles non-existing ids, right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It handles non-existing ids by just ignoring them. I changed it to make sure we exercise that codepath. My thinking though was the faster we hit the max number of ids the better.
}, | ||
} | ||
|
||
assert!(BagsList::sanity_check().is_ok()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
might be a good time for you to go and re-read sanity_check
and make sure it is checking everything there is to check.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I found one small check to add 7cca905
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks reasonable. I think our CI team already runs this stuff for a few hours per day or sth. Let's also make sure we give it a solid days/week.
Not sure if there is a better way to share this data, but here is stats from a 22 hour run on commit 7d43123 |
From aa8a523 : |
bot merge |
bot merge |
Waiting for commit status. |
@emostov can you post the updated status from the running process? |
* Fuzzer for Pallet Bags List * Some small updates * Fuzzer for Pallet Bags List This PR adds a fuzzer for the `SortedListProvider` API exposed by pallet-bags-list. * Feature gate code NOT used by fuzz feature * Create Enum for list actions * fix some small mistakes * try and make CI happy * fmt * Do not insert before updating * clean up some misc. comments * marginally improve Node::sanity_check * Change ID_RANGE to 25_000 * comma * try improve correct feature gating so no unused code Co-authored-by: thiolliere <[email protected]>
* Fuzzer for Pallet Bags List * Some small updates * Fuzzer for Pallet Bags List This PR adds a fuzzer for the `SortedListProvider` API exposed by pallet-bags-list. * Feature gate code NOT used by fuzz feature * Create Enum for list actions * fix some small mistakes * try and make CI happy * fmt * Do not insert before updating * clean up some misc. comments * marginally improve Node::sanity_check * Change ID_RANGE to 25_000 * comma * try improve correct feature gating so no unused code Co-authored-by: thiolliere <[email protected]>
This PR adds a fuzzer for the
SortedListProvider
API exposed by pallet-bags-list.