allora-network / allora-chain

Node software to run the Allora Network
https://www.allora.network/
Apache License 2.0
78 stars 72 forks source link

Fuzzer Bugfixes, Allow User to Set Fuzzer Transition Probability Distribution #653

Closed relyt29 closed 1 week ago

relyt29 commented 2 weeks ago

Purpose of Changes and their Description

This PR does three things:

  1. Squashes bugs in the fuzzer that was causing it to crash (in several cases where the fuzzer thought that it had the wrong state as compared to the chain).
  2. Changes the fuzzer to (in addition to environment variables) takes its configuration from a config.json file in the fuzz directory
  3. Allows the user to specify a probability distribution to follow for the state transitions the fuzzer will attempt. By setting the transitionWeights configuration parameter, the fuzzer will now choose state transitions following the percentage likelihood for each transition. E.g. if you set the weight of createTopic to 20%, then the fuzzer will, on every iteration, have a 20% likelihood of picking a createTopic as the next state transition it will attempt. This allows the user to guide fuzzing to an extent to try to probe specific parts of the codebase more thoroughly.

Link(s) to Ticket(s) or Issue(s) resolved by this PR

PROTO-2289

Are these changes tested and documented?

These changes have been tested manually by running the fuzzer on my local computer. Updates to the fuzzer documentation have been put in the README.md in the fuzzer folder. The changelog has been updated.

relyt29 commented 1 week ago

using this you can do cool things like force testing of unstake and cancel operations over everything else:

   fuzz_test.go:197: State Transitions Summary: {                                                                     
        createTopic: 2,                                                                                                
        fundTopic: 2,                                                                                                  
        registerWorker: 10,                                                                                            
        registerReputer: 8,                                                                                            
        unregisterWorker: 2,                                                                                           
        unregisterReputer: 1,                                                                                          
        stakeAsReputer: 541                                                                                            
        delegateStake: 559                                                                                             
        unstakeAsReputer: 492 
        undelegateStake: 523
        cancelStakeRemoval: 256
        cancelDelegateStakeRemoval: 239
        collectDelegatorRewards: 4
        doInferenceAndReputation: 2
        }
github-actions[bot] commented 1 week ago

The latest Buf updates on your PR. Results from workflow Buf Linter / buf (pull_request).

BuildFormatLintBreakingUpdated (UTC)
✅ passed✅ passed✅ passed⏩ skippedOct 31, 2024, 4:47 PM