From d3dbfd6021f1601cdb4f17ab43785c51548ada4e Mon Sep 17 00:00:00 2001 From: Zahary Karadjov Date: Thu, 18 Aug 2022 19:25:51 +0300 Subject: [PATCH] libnfuzz uses the mainnet RuntimeConfig (the default one might differ in subtle ways) --- nfuzz/libnfuzz.nim | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/nfuzz/libnfuzz.nim b/nfuzz/libnfuzz.nim index 1ba109d8b..15e352106 100644 --- a/nfuzz/libnfuzz.nim +++ b/nfuzz/libnfuzz.nim @@ -3,6 +3,7 @@ import stew/ptrops, stew/ranges/ptr_arith, chronicles, + ../beacon_chain/networking/network_metadata, ../beacon_chain/spec/datatypes/phase0, ../beacon_chain/spec/[ beaconstate, eth2_ssz_serialization, forks, validator, state_transition, @@ -102,7 +103,7 @@ proc nfuzz_attestation(input: openArray[byte], xoutput: ptr byte, proc nfuzz_attester_slashing(input: openArray[byte], xoutput: ptr byte, xoutput_size: ptr uint, disable_bls: bool): bool {.exportc, raises: [FuzzCrashError, Defect].} = decodeAndProcess(AttesterSlashingInput): - process_attester_slashing(defaultRuntimeConfig, data.state, data.attesterSlashing, flags, cache).isOk + process_attester_slashing(mainnetMetadata.cfg, data.state, data.attesterSlashing, flags, cache).isOk proc nfuzz_block(input: openArray[byte], xoutput: ptr byte, xoutput_size: ptr uint, disable_bls: bool): bool {.exportc, raises: [FuzzCrashError, Defect].} = @@ -126,7 +127,7 @@ proc nfuzz_block(input: openArray[byte], xoutput: ptr byte, decodeAndProcess(BlockInput): state_transition( - defaultRuntimeConfig, data, data.beaconBlock, flags, noRollback).isOk + mainnetMetadata.cfg, data, data.beaconBlock, flags, noRollback).isOk proc nfuzz_block_header(input: openArray[byte], xoutput: ptr byte, xoutput_size: ptr uint, disable_bls: bool): bool {.exportc, raises: [FuzzCrashError, Defect].} = @@ -136,17 +137,17 @@ proc nfuzz_block_header(input: openArray[byte], xoutput: ptr byte, proc nfuzz_deposit(input: openArray[byte], xoutput: ptr byte, xoutput_size: ptr uint, disable_bls: bool): bool {.exportc, raises: [FuzzCrashError, Defect].} = decodeAndProcess(DepositInput): - process_deposit(defaultRuntimeConfig, data.state, data.deposit, flags).isOk + process_deposit(mainnetMetadata.cfg, data.state, data.deposit, flags).isOk proc nfuzz_proposer_slashing(input: openArray[byte], xoutput: ptr byte, xoutput_size: ptr uint, disable_bls: bool): bool {.exportc, raises: [FuzzCrashError, Defect].} = decodeAndProcess(ProposerSlashingInput): - process_proposer_slashing(defaultRuntimeConfig, data.state, data.proposerSlashing, flags, cache).isOk + process_proposer_slashing(mainnetMetadata.cfg, data.state, data.proposerSlashing, flags, cache).isOk proc nfuzz_voluntary_exit(input: openArray[byte], xoutput: ptr byte, xoutput_size: ptr uint, disable_bls: bool): bool {.exportc, raises: [FuzzCrashError, Defect].} = decodeAndProcess(VoluntaryExitInput): - process_voluntary_exit(defaultRuntimeConfig, data.state, data.exit, flags, cache).isOk + process_voluntary_exit(mainnetMetadata.cfg, data.state, data.exit, flags, cache).isOk # Note: Could also accept raw input pointer and access list_size + seed here. # However, list_size needs to be known also outside this proc to allocate xoutput.