-
Notifications
You must be signed in to change notification settings - Fork 805
feat: utilize ${ANTITHESIS_RANDOM_SEED}
to randomize genesis config
#4357
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
base: master
Are you sure you want to change the base?
feat: utilize ${ANTITHESIS_RANDOM_SEED}
to randomize genesis config
#4357
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR adds deterministic randomization to genesis configuration and network parameters for Antithesis testing. When the ANTITHESIS_RANDOM_SEED
environment variable is set, it applies random values to various network parameters including fees, staking amounts, and timing configurations to enable more comprehensive testing scenarios.
- Implements randomized genesis configuration controlled by
ANTITHESIS_RANDOM_SEED
environment variable - Adds randomization of network parameters including gas prices, transaction fees, and staking limits
- Updates CI workflows to automatically set random seeds using GitHub run IDs
Reviewed Changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 5 comments.
Show a summary per file
File | Description |
---|---|
tests/fixture/tmpnet/network.go | Adds logic to apply randomized network flags when environment variable is set |
tests/fixture/tmpnet/genesis.go | Implements randomized genesis creation and parameter generation functions |
tests/fixture/tmpnet/genesis_randomized_test.go | Adds comprehensive test suite for randomization functionality |
.github/workflows/trigger-antithesis-xsvm.yml | Adds optional random seed input parameter for manual workflow triggers |
.github/workflows/trigger-antithesis-avalanchego.yml | Adds optional random seed input parameter for manual workflow triggers |
.github/workflows/publish_antithesis_images.yml | Sets automatic random seed using GitHub run ID |
.github/workflows/ci.yml | Sets automatic random seed for CI antithesis image builds |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
} | ||
|
||
// Create a deterministic random source | ||
rng := rand.New(rand.NewSource(seed)) // #nosec G404 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using math/rand for cryptographic purposes is not secure. Consider using crypto/rand for security-sensitive randomization, especially for network parameters that could affect consensus.
Copilot uses AI. Check for mistakes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we care about this?
return baseParams | ||
} | ||
|
||
rng := rand.New(rand.NewSource(seed)) // #nosec G404 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using math/rand for cryptographic purposes is not secure. Consider using crypto/rand for security-sensitive randomization, especially for network parameters that could affect consensus.
Copilot uses AI. Check for mistakes.
return | ||
} | ||
|
||
// TODO(jonathanoppenheimer): is there a better way to apply these values? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seemed like a bad way to apply the randomizedParams
Is there a more concise way of doing so?
Co-authored-by: Copilot <[email protected]> Signed-off-by: Jonathan Oppenheimer <[email protected]>
Converting to draft to avoid accidental review while this PR is in a research phase. |
Why this should be merged
This PR closes #3934 and adds deterministic randomization to genesis configuration and network parameters for Antithesis testing. The randomization is controlled by the
ANTITHESIS_RANDOM_SEED
environment variable. I assume this makes testing more rigorous or something. I actually have no idea why this feature is desired. 🤷Randomized Parameters
Below are the ranges in which variables are randomized - if different ranges for any of these are desired, let me know.
P-Chain Parameters
Transaction Fees
Validator & Staking Parameters
Genesis Timing
How this works
ANTITHESIS_RANDOM_SEED
environment variable enables randomizationHow this was tested
I created a few unit tests
TestNewRandomizedTestGenesis
TestRandomizedParams
TestRandomizedParamsValidation
TestRandomizedGenesisWithDifferentSeeds
that verify accordingly
Additionally, I ran the antithesis tests locally with a randomized seed that has been set.
I also modified the CI to set
ANTITHESIS_RANDOM_SEED: ${{ github.run_id }}
, which seemed like a reasonable value, and I also made it manually configurable.In these two text files you an see the successful run.
Critically:
You can also check the CI on this PR, to see a similar message, with randomized parameters being set.
Need to be documented in RELEASES.md?
No