libnfuzz uses the mainnet RuntimeConfig (the default one might differ in subtle ways)

This commit is contained in:
Zahary Karadjov 2022-08-18 19:25:51 +03:00
parent 7f681af56f
commit d3dbfd6021
No known key found for this signature in database
GPG Key ID: C1F42EAFF38D570F
1 changed files with 6 additions and 5 deletions

View File

@ -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.