Skip to content
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

Merged
merged 25 commits into from
May 30, 2022
Merged

tests: superfluid delegator voting #1586

merged 25 commits into from
May 30, 2022

Conversation

czarcas7ic
Copy link
Member

What is the purpose of the change

  • Changes genesis creation to be closer to production (uses osmo instead of stake as staking token as well as all other occurrences of using stake as default token)
  • Adds a test to ensure a delegator can override their share of the validator's voting power.

Testing and Verifying

This change is already covered by existing e2e test framework. Was also run locally on arm64 arch.

Documentation and Release Note

  • Does this pull request introduce a new feature or user-facing behavior changes? not
  • Is a relevant changelog entry added to the Unreleased section in CHANGELOG.md? no
  • How is the feature or change documented? not applicable

czarcas7ic and others added 9 commits May 23, 2022 09:38
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-commenter
Copy link

codecov-commenter commented May 25, 2022

Codecov Report

Merging #1586 (ff4935c) into main (0857e87) will not change coverage.
The diff coverage is n/a.

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

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 0857e87...ff4935c. Read the comment docs.

@czarcas7ic czarcas7ic marked this pull request as ready for review May 25, 2022 20:44
@czarcas7ic czarcas7ic requested a review from a team May 25, 2022 20:44
tests/e2e/chain/chain.go Outdated Show resolved Hide resolved
tests/e2e/chain/export.go Outdated Show resolved Hide resolved
tests/e2e/chain/export.go Outdated Show resolved Hide resolved
tests/e2e/e2e_setup_test.go Outdated Show resolved Hide resolved
tests/e2e/e2e_setup_test.go Outdated Show resolved Hide resolved
tests/e2e/e2e_setup_test.go Outdated Show resolved Hide resolved
tests/e2e/chain/chain.go Outdated Show resolved Hide resolved
tests/e2e/chain/config.go Show resolved Hide resolved
tests/e2e/chain/export.go Outdated Show resolved Hide resolved
tests/e2e/chain/export.go Outdated Show resolved Hide resolved
tests/e2e/e2e_setup_test.go Outdated Show resolved Hide resolved
tests/e2e/e2e_test.go Show resolved Hide resolved
tests/e2e/e2e_test.go Outdated Show resolved Hide resolved
tests/e2e/e2e_test.go Outdated Show resolved Hide resolved
tests/e2e/e2e_util_test.go Outdated Show resolved Hide resolved
tests/e2e/chain/export.go Outdated Show resolved Hide resolved
@czarcas7ic czarcas7ic mentioned this pull request May 27, 2022
3 tasks
Comment on lines +183 to +201
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
Copy link
Member

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)

tests/e2e/e2e_test.go Outdated Show resolved Hide resolved
@czarcas7ic czarcas7ic requested a review from a team May 27, 2022 21:17
@czarcas7ic
Copy link
Member Author

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

Copy link
Member

@p0mvn p0mvn left a 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

Dockerfile Outdated Show resolved Hide resolved
tests/e2e/scripts/pool2A.json Show resolved Hide resolved
@@ -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"`
Copy link
Member

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

Copy link
Member Author

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

Copy link
Member

@p0mvn p0mvn May 29, 2022

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:

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

Copy link
Member

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?

Copy link
Member Author

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

tests/e2e/e2e_setup_test.go Outdated Show resolved Hide resolved
tests/e2e/e2e_setup_test.go Outdated Show resolved Hide resolved
tests/e2e/e2e_setup_test.go Outdated Show resolved Hide resolved
tests/localosmosis/Dockerfile Show resolved Hide resolved
tests/e2e/e2e_util_test.go Outdated Show resolved Hide resolved
tests/e2e/e2e_util_test.go Outdated Show resolved Hide resolved
tests/e2e/e2e_util_test.go Outdated Show resolved Hide resolved
@czarcas7ic
Copy link
Member Author

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

@czarcas7ic czarcas7ic requested a review from a team May 29, 2022 01:52
Copy link
Member

@ValarDragon ValarDragon left a 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

@czarcas7ic czarcas7ic merged commit 2fdfeae into main May 30, 2022
@czarcas7ic czarcas7ic deleted the adam/sf-tests-2 branch May 30, 2022 20:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

5 participants