-
Notifications
You must be signed in to change notification settings - Fork 607
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
tests: superfluid delegator voting #1586
Conversation
Closes: #XXX This PR refactors e2e test setup to have an abstraction `chainConfig` that has information about which validators should not be run during initialization. This is a first step toward testing state-sync as we want to postpone running some nodes so that we can test nodes "catching up". Additionally, this PR extracts a separate package `docker` for managing and storing all information related to docker images. - create a `chainConfig` struct to encapsulate all configurations related to chains in a single abstraction * remove global variables `propHeightA`, `propHeightB`, `votingPeriodA`, `votingPeriodB`. Instead, these are part of the `chainConfig` struct * `skipRunValidatorIndexes` - this is needed to skip certain validators from being run during setup so that we can test state-sync post-initialization and upgrade - remove code duplication for every chain. Instead, always loop over `chainConfig`s so that if we add more chains later, the setup would work out of the box - tested running both with and without upgrade - Does this pull request introduce a new feature or user-facing behavior changes? no - Is a relevant changelog entry added to the `Unreleased` section in `CHANGELOG.md`? no - How is the feature or change documented? not applicable
Codecov Report
@@ Coverage Diff @@
## main #1586 +/- ##
=======================================
Coverage 19.60% 19.60%
=======================================
Files 242 242
Lines 32279 32279
=======================================
Hits 6329 6329
Misses 24792 24792
Partials 1158 1158 Continue to review full report at Codecov.
|
var stakeGenState staketypes.GenesisState | ||
if err := util.Cdc.UnmarshalJSON(appGenState[staketypes.ModuleName], &stakeGenState); err != nil { | ||
return err | ||
} | ||
|
||
stakeGenState.Params = staketypes.Params{ | ||
BondDenom: OsmoDenom, | ||
MaxValidators: 100, | ||
MaxEntries: 7, | ||
HistoricalEntries: 10000, | ||
UnbondingTime: 240000000000, | ||
MinCommissionRate: sdk.ZeroDec(), | ||
} | ||
|
||
sz, err := util.Cdc.MarshalJSON(&stakeGenState) | ||
if err != nil { | ||
return err | ||
} | ||
appGenState[staketypes.ModuleName] = sz |
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.
(For a future PR) I think we should move these to be independent functions, and think of ways to lower the boilerplate involved with them. (e.g. Go Generics)
This should be good to go now, unsure of why linter is failing though, looks like its having trouble pulling the linter docker image suddenly |
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.
Really great job on minimizing code duplication and extracting these reusable methods!
A few minor questions and comments from me
tests/e2e/chain/export.go
Outdated
@@ -13,6 +13,8 @@ type Validator struct { | |||
Index int `json:"index"` | |||
Mnemonic string `json:"mnemonic"` | |||
PublicAddress string `json:"publicAddress"` | |||
PublicKey string `json:"publicKey"` | |||
OperAddress string `json:"operAddress"` |
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 can be removed as it is not used
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.
We still need to store this value for each validator so we are able to SFS to their operator address
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.
I was hoping to keep these Validator
and Chain
structs only used for transferring state between the "chain-initialization" part (that happens inside a Docker container) and the test runner part (in e2e
package). The goal of this is to decouple the chain initialization and test runner components as much as possible.
I know there is still some coupling present right now but the goal is to eventually get to completely independent components with incremental refactoring.
So this OperAddress
is never used during chain initialization. I think if we want to keep adding more state to Validator
or Chain
structs, we should wrap them into structs that are local to the e2e
package:
type validatorConfig struct {
validator chain.Validator
operatorAddress string
}
We already do something similar with chain.Chain
:
osmosis/tests/e2e/e2e_setup_test.go
Lines 40 to 52 in 360abcf
type chainConfig struct { | |
// voting period is number of blocks it takes to deposit, 1.2 seconds per validator to vote on the prop, and a buffer. | |
votingPeriod float32 | |
// upgrade proposal height for chain. | |
propHeight int | |
// Indexes of the validators to skip from running during initialization. | |
// This is needed for testing functionality like state-sync where we would | |
// like to start a node during tests post-initialization. | |
skipRunValidatorIndexes map[int]struct{} | |
latestProposalNumber int | |
latestLockNumber int | |
chain *chain.Chain | |
} |
Here, instead of adding the fields directly to chain.Chain
we wrap it into the chainConfig
struct
Please let me know what you think
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.
Should we move this to an issue?
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.
I can get to it now, if it proves to be a difficult change (it shouldn't be) then I will make an issue instead and merge
Co-authored-by: Roman <[email protected]>
Changes made, let me know if we anything further done here. Once we merge this, CI will be ~10 minute for this until I merge in Roman's changes which should make non PRs to main much faster |
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.
LGTM! We should chat about some more steps to help eliminate boilerplate / overhead further in a followup issue/PR
What is the purpose of the change
osmo
instead ofstake
as staking token as well as all other occurrences of using stake as default token)Testing and Verifying
This change is already covered by existing e2e test framework. Was also run locally on arm64 arch.
Documentation and Release Note
Unreleased
section inCHANGELOG.md
? no