Improve Fuzzing runs (#402)

* Update Fuzzing:
* add coverage generation
* fix block numeration error
* fix AFL build error
* add an EVM run

* toml sort

* fix unexistent call
This commit is contained in:
Nikita Khateev
2025-01-14 13:42:29 +04:00
committed by GitHub
parent 3e625f319b
commit 67c2f2b4e8
9 changed files with 117 additions and 24 deletions
@@ -15,6 +15,7 @@ workspace = true
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
quinn-proto = { version = "0.9.6", features = [ "arbitrary" ] }
ziggy = { workspace = true }
generic-runtime-template = { path = "../runtime" }
+4 -11
View File
@@ -103,7 +103,8 @@ fn process_input(accounts: &[AccountId], genesis: &Storage, data: &[u8]) {
}
if lapse > 0 {
finalize_block(elapsed);
println!("\n time spent: {elapsed:?}");
assert!(elapsed.as_secs() <= 2, "block execution took too much time");
block += u32::from(lapse) * 393; // 393 * 256 = 100608 which nearly corresponds to a week
weight = 0.into();
@@ -131,7 +132,7 @@ fn process_input(accounts: &[AccountId], genesis: &Storage, data: &[u8]) {
println!(" result: {res:?}");
}
finalize_block(elapsed);
Executive::finalize_block();
check_invariants(block, initial_total_issuance);
});
@@ -140,7 +141,7 @@ fn process_input(accounts: &[AccountId], genesis: &Storage, data: &[u8]) {
fn initialize_block(block: u32) {
println!("\ninitializing block {}", block);
let current_timestamp = u64::from(block) * SLOT_DURATION;
let current_timestamp = u64::from(block) * SLOT_DURATION * 2;
let prev_header = match block {
1 => None,
@@ -207,14 +208,6 @@ fn initialize_block(block: u32) {
// Calls that need to be called before each block starts (init_calls) go here
}
fn finalize_block(elapsed: Duration) {
println!("\n time spent: {elapsed:?}");
assert!(elapsed.as_secs() <= 2, "block execution took too much time");
println!(" finalizing block");
Executive::finalize_block();
}
fn check_invariants(block: u32, initial_total_issuance: Balance) {
let mut counted_free = 0;
let mut counted_reserved = 0;