Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FRAME] Executive invariant fuzzer #3683

Open
ggwpez opened this issue Mar 13, 2024 · 4 comments
Open

[FRAME] Executive invariant fuzzer #3683

ggwpez opened this issue Mar 13, 2024 · 4 comments
Assignees
Labels
C1-mentor A task where a mentor is available. Please indicate in the issue who the mentor could be. C2-good-first-issue A task for a first time contributor to become familiar with the Polkadot-SDK. D1-medium Can be fixed by a coder with good Rust knowledge but little knowledge of the codebase. T10-tests This PR/Issue is related to tests.

Comments

@ggwpez
Copy link
Member

ggwpez commented Mar 13, 2024

Adding some stuff to Executive in #3666 and there are now so many assumptions of what comes first and stuff being done in the correct order.

Would be nice to have a dedicated fuzzer crate that applies a random number of inherents+transactions and then asserts event records, similar to this test:

for (n_in, n_tx) in (0..15usize).zip(0..15usize) {

@ggwpez ggwpez added C1-mentor A task where a mentor is available. Please indicate in the issue who the mentor could be. D1-medium Can be fixed by a coder with good Rust knowledge but little knowledge of the codebase. C2-good-first-issue A task for a first time contributor to become familiar with the Polkadot-SDK. labels Mar 13, 2024
@gitofdeepanshu
Copy link
Contributor

can I take this?

@ggwpez ggwpez added the T10-tests This PR/Issue is related to tests. label Mar 13, 2024
@ggwpez
Copy link
Member Author

ggwpez commented Mar 17, 2024

Yea sure @gitofdeepanshu!

I think the paged-list fuzzer should give a good example for this: https://github.com/paritytech/polkadot-sdk/blob/daa9ecf77d03bdc80282b9c63e0a1eee136dd2bc/substrate/frame/paged-list/fuzzer/src/paged_list.rs

@gitofdeepanshu
Copy link
Contributor

gitofdeepanshu commented Mar 18, 2024

Hey @ggwpez
I need some advice,
My plan was to create a fuzzer crate that would just do

fn main() {
	loop {
		fuzz!(|data: (usize, usize, bool)| {
			callbacks_in_block_execution_works_inner(data.0, data.1, data.2);
		});
	}
}

and just modify the same function that you linked above.

The problem is I would need the mock runtime's functions and structs that you created in the test folder, but it is behind #[cfg(test)] feature and uses dev-dependencies which mean I can't import the mock runtime and some other required functions. (or can I?)

AFAIK we can either create a new mock runtime in fuzzer crate or (just for the duration of test) manually modify the pallet-executive, remove the dev-dependencies and 'test' feature flag, import all the required code in fuzzer crate, test it and change the code back to normal.

Kindly guide what should be the best step here.

@ggwpez
Copy link
Member Author

ggwpez commented Mar 18, 2024

@gitofdeepanshu yea it looks like we would either need to duplicate the code or import it.
I think it should be fine to guard the mock runtime + pallets behind cfg(feature = "std") instead of cfg(test) to avoid duplicating everything.
It should not be to big of a code change and should remove most dev-dependencies.

Otherwise it would also be possible to use the substrate-test-runtime crate, but it does not have all these nice pallets with assertions deployed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C1-mentor A task where a mentor is available. Please indicate in the issue who the mentor could be. C2-good-first-issue A task for a first time contributor to become familiar with the Polkadot-SDK. D1-medium Can be fixed by a coder with good Rust knowledge but little knowledge of the codebase. T10-tests This PR/Issue is related to tests.
Projects
Status: Backlog
Development

No branches or pull requests

2 participants