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
Show file tree
Hide file tree
Changes from 11 commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
2c87381
change to osmo no stake
czarcas7ic May 23, 2022
f416f6f
currently working
czarcas7ic May 23, 2022
6d7c5d4
superfluid vote overwrite test
czarcas7ic May 25, 2022
9f0ff0a
change docker file
czarcas7ic May 25, 2022
9d33f0d
refactor: e2e setup to be more extensible for state sync (#1565)
p0mvn May 24, 2022
12d4a57
add extract oper address
czarcas7ic May 25, 2022
cac90ee
extract val addr
czarcas7ic May 25, 2022
6904461
new line
czarcas7ic May 25, 2022
ee095d0
delete no longer needed script
czarcas7ic May 25, 2022
e4ec2fb
Merge branch 'main' into adam/sf-tests-2
czarcas7ic May 25, 2022
6a84b6a
Delete .bash_history
czarcas7ic May 25, 2022
966d361
add helper functions to declutter
czarcas7ic May 26, 2022
02bbe8c
remove majority boilerplate
czarcas7ic May 27, 2022
9767416
move docker file back to distroless
czarcas7ic May 27, 2022
eb16e72
Merge branch 'main' into adam/sf-tests-2
czarcas7ic May 27, 2022
a4cabdd
no longer use bash to add account
czarcas7ic May 27, 2022
1e7ee23
Merge branch 'main' into adam/sf-tests-2
czarcas7ic May 27, 2022
c3ea676
remove debugging print statements
czarcas7ic May 27, 2022
0a8d28d
Merge branch 'adam/sf-tests-2' of https://github.com/osmosis-labs/osm…
czarcas7ic May 27, 2022
6c0e355
Delete .bash_history
czarcas7ic May 27, 2022
4c4358f
remove extra line in docker file
czarcas7ic May 27, 2022
e209efb
Apply suggestions from code review
czarcas7ic May 29, 2022
360abcf
code review suggestions
czarcas7ic May 29, 2022
b9b14ef
further validator abstractions
czarcas7ic May 30, 2022
ff4935c
Merge branch 'main' into adam/sf-tests-2
czarcas7ic May 30, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@

czarcas7ic marked this conversation as resolved.
Show resolved Hide resolved
# syntax=docker/dockerfile:1

ARG BASE_IMG_TAG=nonroot
Expand Down
3 changes: 3 additions & 0 deletions tests/e2e/chain/chain.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@ func (c *internalChain) createAndInitValidators(count int) error {
if err := node.createKey("val"); err != nil {
return err
}
if err := node.createKey("val2"); err != nil {
czarcas7ic marked this conversation as resolved.
Show resolved Hide resolved
return err
}
if err := node.createNodeKey(); err != nil {
return err
}
Expand Down
166 changes: 164 additions & 2 deletions tests/e2e/chain/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,22 @@ import (
sdk "github.com/cosmos/cosmos-sdk/types"
authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
banktypes "github.com/cosmos/cosmos-sdk/x/bank/types"
crisistypes "github.com/cosmos/cosmos-sdk/x/crisis/types"
"github.com/cosmos/cosmos-sdk/x/genutil"
genutiltypes "github.com/cosmos/cosmos-sdk/x/genutil/types"
govtypes "github.com/cosmos/cosmos-sdk/x/gov/types"
staketypes "github.com/cosmos/cosmos-sdk/x/staking/types"
"github.com/spf13/viper"
tmconfig "github.com/tendermint/tendermint/config"
tmjson "github.com/tendermint/tendermint/libs/json"

epochtypes "github.com/osmosis-labs/osmosis/v7/x/epochs/types"
gammtypes "github.com/osmosis-labs/osmosis/v7/x/gamm/types"
incentivestypes "github.com/osmosis-labs/osmosis/v7/x/incentives/types"
minttypes "github.com/osmosis-labs/osmosis/v7/x/mint/types"
poolitypes "github.com/osmosis-labs/osmosis/v7/x/pool-incentives/types"
txfeestypes "github.com/osmosis-labs/osmosis/v7/x/txfees/types"

"github.com/osmosis-labs/osmosis/v7/tests/e2e/util"
)

Expand Down Expand Up @@ -52,9 +61,9 @@ const (

var (
StakeAmountIntA = sdk.NewInt(StakeAmountA)
StakeAmountCoinA = sdk.NewCoin(StakeDenom, StakeAmountIntA)
StakeAmountCoinA = sdk.NewCoin(OsmoDenom, StakeAmountIntA)
StakeAmountIntB = sdk.NewInt(StakeAmountB)
StakeAmountCoinB = sdk.NewCoin(StakeDenom, StakeAmountIntB)
StakeAmountCoinB = sdk.NewCoin(OsmoDenom, StakeAmountIntB)

InitBalanceStrA = fmt.Sprintf("%d%s,%d%s", OsmoBalanceA, OsmoDenom, StakeBalanceA, StakeDenom)
InitBalanceStrB = fmt.Sprintf("%d%s,%d%s", OsmoBalanceB, OsmoDenom, StakeBalanceB, StakeDenom)
Expand Down Expand Up @@ -171,6 +180,157 @@ func initGenesis(c *internalChain, votingPeriod time.Duration) error {
}
appGenState[banktypes.ModuleName] = bz

var stakeGenState staketypes.GenesisState
czarcas7ic marked this conversation as resolved.
Show resolved Hide resolved
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
Comment on lines +184 to +202
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)


var pooliGenState poolitypes.GenesisState
if err := util.Cdc.UnmarshalJSON(appGenState[poolitypes.ModuleName], &pooliGenState); err != nil {
return err
}

pooliGenState.LockableDurations =
[]time.Duration{
time.Second * 120,
time.Second * 180,
time.Second * 240,
}

pooliGenState.Params = poolitypes.Params{
MintedDenom: OsmoDenom,
}

pz, err := util.Cdc.MarshalJSON(&pooliGenState)
if err != nil {
return err
}
appGenState[poolitypes.ModuleName] = pz

var incentivesGenState incentivestypes.GenesisState
if err := util.Cdc.UnmarshalJSON(appGenState[incentivestypes.ModuleName], &incentivesGenState); err != nil {
return err
}

incentivesGenState.LockableDurations =
[]time.Duration{
time.Second,
time.Second * 120,
time.Second * 180,
time.Second * 240,
}

incentivesGenState.Params = incentivestypes.Params{
DistrEpochIdentifier: "day",
}

iz, err := util.Cdc.MarshalJSON(&incentivesGenState)
if err != nil {
return err
}
appGenState[incentivestypes.ModuleName] = iz

var mintGenState minttypes.GenesisState
if err := util.Cdc.UnmarshalJSON(appGenState[minttypes.ModuleName], &mintGenState); err != nil {
return err
}

mintGenState.Params.MintDenom = OsmoDenom
mintGenState.Params.EpochIdentifier = "day"

mz, err := util.Cdc.MarshalJSON(&mintGenState)
if err != nil {
return err
}
appGenState[minttypes.ModuleName] = mz

var txfeesGenState txfeestypes.GenesisState
if err := util.Cdc.UnmarshalJSON(appGenState[txfeestypes.ModuleName], &txfeesGenState); err != nil {
return err
}

txfeesGenState.Basedenom = OsmoDenom

tz, err := util.Cdc.MarshalJSON(&txfeesGenState)
if err != nil {
return err
}
appGenState[txfeestypes.ModuleName] = tz

var gammGenState gammtypes.GenesisState
if err := util.Cdc.UnmarshalJSON(appGenState[gammtypes.ModuleName], &gammGenState); err != nil {
return err
}

gammGenState.Params.PoolCreationFee = sdk.Coins{sdk.NewInt64Coin(OsmoDenom, 10000000)}

gaz, err := util.Cdc.MarshalJSON(&gammGenState)
if err != nil {
return err
}
appGenState[gammtypes.ModuleName] = gaz

var epochGenState epochtypes.GenesisState
if err := util.Cdc.UnmarshalJSON(appGenState[epochtypes.ModuleName], &epochGenState); err != nil {
return err
}

epochGenState.Epochs =
[]epochtypes.EpochInfo{
{
Identifier: "week",
StartTime: time.Time{},
Duration: time.Hour * 24 * 7,
CurrentEpoch: 0,
CurrentEpochStartHeight: 0,
CurrentEpochStartTime: time.Time{},
EpochCountingStarted: false,
},
{
Identifier: "day",
StartTime: time.Time{},
Duration: time.Second * 60,
CurrentEpoch: 0,
CurrentEpochStartHeight: 0,
CurrentEpochStartTime: time.Time{},
EpochCountingStarted: false,
},
}

ez, err := util.Cdc.MarshalJSON(&epochGenState)
if err != nil {
return err
}
appGenState[epochtypes.ModuleName] = ez

var crisisGenState crisistypes.GenesisState
if err := util.Cdc.UnmarshalJSON(appGenState[crisistypes.ModuleName], &crisisGenState); err != nil {
return err
}

crisisGenState.ConstantFee.Denom = OsmoDenom

cz, err := util.Cdc.MarshalJSON(&crisisGenState)
if err != nil {
return err
}
appGenState[crisistypes.ModuleName] = cz

var govGenState govtypes.GenesisState
if err := util.Cdc.UnmarshalJSON(appGenState[govtypes.ModuleName], &govGenState); err != nil {
return err
Expand All @@ -180,6 +340,8 @@ func initGenesis(c *internalChain, votingPeriod time.Duration) error {
VotingPeriod: votingPeriod,
}

govGenState.DepositParams.MinDeposit = sdk.Coins{sdk.NewInt64Coin(OsmoDenom, 10000000)}

gz, err := util.Cdc.MarshalJSON(&govGenState)
if err != nil {
return err
Expand Down
15 changes: 10 additions & 5 deletions tests/e2e/chain/export.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,21 @@ type ChainMeta struct {
}

type Validator struct {
Name string `json:"name"`
ConfigDir string `json:"configDir"`
Index int `json:"index"`
Mnemonic string `json:"mnemonic"`
PublicAddress string `json:"publicAddress"`
Name string `json:"name"`
ConfigDir string `json:"configDir"`
Index int `json:"index"`
Mnemonic string `json:"mnemonic"`
PublicAddress string `json:"publicAddress"`
PublicAddress2 string `json:"publicAddress2"`
czarcas7ic marked this conversation as resolved.
Show resolved Hide resolved
PublicKey string `json:"publicKey"`
OperAddress string `json:"operAddress"`
czarcas7ic marked this conversation as resolved.
Show resolved Hide resolved
}

type Chain struct {
ChainMeta ChainMeta `json:"chainMeta"`
Validators []*Validator `json:"validators"`
PropNumber int `json:"propNumber"`
czarcas7ic marked this conversation as resolved.
Show resolved Hide resolved
LockNumber int `json:"lockNumber"`
czarcas7ic marked this conversation as resolved.
Show resolved Hide resolved
}

func (c *ChainMeta) configDir() string {
Expand Down
1 change: 1 addition & 0 deletions tests/e2e/chain/validator.go
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,7 @@ func (v *internalValidator) export() *Validator {
Index: v.index,
Mnemonic: v.mnemonic,
PublicAddress: v.keyInfo.GetAddress().String(),
PublicKey: v.keyInfo.GetPubKey().Address().String(),
}
}

Expand Down
14 changes: 10 additions & 4 deletions tests/e2e/chain_init/chain-init.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,20 @@ RUN apk add linux-headers
WORKDIR /osmosis
COPY . /osmosis

# From https://github.com/CosmWasm/wasmd/blob/master/Dockerfile
# For more details see https://github.com/CosmWasm/wasmvm#builds-of-libwasmvm
ADD https://github.com/CosmWasm/wasmvm/releases/download/v1.0.0/libwasmvm_muslc.x86_64.a /lib/libwasmvm_muslc.a
RUN sha256sum /lib/libwasmvm_muslc.a | grep f6282df732a13dec836cda1f399dd874b1e3163504dbd9607c6af915b2740479
# CosmWasm: see https://github.com/CosmWasm/wasmvm/releases
ADD https://github.com/CosmWasm/wasmvm/releases/download/v1.0.0/libwasmvm_muslc.aarch64.a /lib/libwasmvm_muslc.aarch64.a
ADD https://github.com/CosmWasm/wasmvm/releases/download/v1.0.0/libwasmvm_muslc.x86_64.a /lib/libwasmvm_muslc.x86_64.a
RUN sha256sum /lib/libwasmvm_muslc.aarch64.a | grep 7d2239e9f25e96d0d4daba982ce92367aacf0cbd95d2facb8442268f2b1cc1fc
RUN sha256sum /lib/libwasmvm_muslc.x86_64.a | grep f6282df732a13dec836cda1f399dd874b1e3163504dbd9607c6af915b2740479

# CosmWasm: copy the right library according to architecture. The final location will be found by the linker flag `-lwasmvm_muslc`
RUN cp /lib/libwasmvm_muslc.$(uname -m).a /lib/libwasmvm_muslc.a

RUN BUILD_TAGS=muslc LINK_STATICALLY=true make build-e2e-chain-init

## Deploy image
FROM ubuntu
RUN apt-get update && apt-get install -y jq moreutils
czarcas7ic marked this conversation as resolved.
Show resolved Hide resolved

COPY --from=build /osmosis/build/chain_init /bin/chain_init

Expand Down
4 changes: 2 additions & 2 deletions tests/e2e/docker/image_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,10 @@ const (
// It should be uploaded to Docker Hub. OSMOSIS_E2E_SKIP_UPGRADE should be unset
// for this functionality to be used.
previousVersionOsmoRepository = "osmolabs/osmosis-dev"
previousVersionOsmoTag = "v8.0.0-debug"
previousVersionOsmoTag = "v8.0.0-2-debug"
// Pre-upgrade repo/tag for osmosis initialization (this should be one version below upgradeVersion)
previousVersionInitRepository = "osmolabs/osmosis-init"
previousVersionInitTag = "v8.0.0"
previousVersionInitTag = "v8.0.0-2-osmo"
// Hermes repo/version for relayer
relayerRepository = "osmolabs/hermes"
relayerTag = "0.13.0"
Expand Down
11 changes: 10 additions & 1 deletion tests/e2e/e2e_setup_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,14 @@ type syncInfo struct {
SyncInfo status `json:"SyncInfo"`
}

type valinfo struct {
p0mvn marked this conversation as resolved.
Show resolved Hide resolved
VotingPower string `json:"VotingPower"`
alexanderbez marked this conversation as resolved.
Show resolved Hide resolved
}

type operInfo struct {
czarcas7ic marked this conversation as resolved.
Show resolved Hide resolved
Bech32Val string `json:"Bech32 Val"`
czarcas7ic marked this conversation as resolved.
Show resolved Hide resolved
}

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
Expand Down Expand Up @@ -167,6 +175,7 @@ func (s *IntegrationTestSuite) SetupSuite() {

for i, chainConfig := range s.chainConfigs {
s.runValidators(chainConfig, s.dockerImages.OsmosisRepository, s.dockerImages.OsmosisTag, i*10)
s.extractOperAddress(chainConfig)
czarcas7ic marked this conversation as resolved.
Show resolved Hide resolved
}

// Run a relayer between every possible pair of chains.
Expand Down Expand Up @@ -476,7 +485,7 @@ func (s *IntegrationTestSuite) upgrade() {
for _, chainConfig := range s.chainConfigs {
currentHeight := s.getCurrentChainHeight(s.valResources[chainConfig.chain.ChainMeta.Id][0].Container.ID)
chainConfig.propHeight = currentHeight + int(chainConfig.votingPeriod) + int(propSubmitBlocks) + int(propBufferBlocks)
s.submitProposal(chainConfig.chain, chainConfig.propHeight)
s.submitUpgradeProposal(chainConfig.chain, chainConfig.propHeight)
s.depositProposal(chainConfig.chain)
s.voteProposal(chainConfig)
}
Expand Down
65 changes: 59 additions & 6 deletions tests/e2e/e2e_test.go
Original file line number Diff line number Diff line change
@@ -1,14 +1,67 @@
package e2e

import (
"github.com/osmosis-labs/osmosis/v7/tests/e2e/chain"
"fmt"
"strconv"
"time"
)

func (s *IntegrationTestSuite) TestIBCTokenTransfer() {
czarcas7ic marked this conversation as resolved.
Show resolved Hide resolved
func (s *IntegrationTestSuite) TestSuperfluidVoting() {
chainA := s.chainConfigs[0].chain
chainB := s.chainConfigs[1].chain
s.Run("superfluid_vote_chainA", func() {
czarcas7ic marked this conversation as resolved.
Show resolved Hide resolved
s.submitSuperfluidProposal(chainA, "gamm/pool/1")
s.depositProposal(chainA)
s.voteProposal(s.chainConfigs[0])
// send gamm tokens to validator's other wallet (non self-delegation wallet)
s.sendTx(chainA, 0, "100000000000000000000gamm/pool/1", chainA.Validators[0].PublicAddress, chainA.Validators[0].PublicAddress2)
// lock tokens from validator 0 on chain A
s.lockTokens(chainA, 0, "100000000000000000000gamm/pool/1", "240s", "val2")
// superfluid delegate from validator 0 non self-delegation wallet to validator 1 on chain A
s.superfluidDelegate(chainA, s.chainConfigs[0].chain.Validators[1].OperAddress, "val2")
// create a text prop, deposit and vote yes
s.submitTextProposal(chainA, "superfluid vote overwrite test")
s.depositProposal(chainA)
s.voteProposal(s.chainConfigs[0])
// set delegator vote to no
s.voteNoProposal(chainA, 0, "val2")

// compare coins of reciever pre and post IBC send
// diff should only be the amount sent
s.sendIBC(chainA, chainB, chainB.Validators[0].PublicAddress, chain.OsmoToken)
chainAAPIEndpoint := fmt.Sprintf("http://%s", s.valResources[chainA.ChainMeta.Id][0].GetHostPort("1317/tcp"))
sfProposalNumber := strconv.Itoa(chainA.PropNumber)
czarcas7ic marked this conversation as resolved.
Show resolved Hide resolved
s.Require().Eventually(
func() bool {
noTotal, yesTotal, noWithVetoTotal, abstainTotal, err := s.queryPropTally(chainAAPIEndpoint, sfProposalNumber)
if err != nil {
return false
}
if abstainTotal.Int64()+noTotal.Int64()+noWithVetoTotal.Int64()+yesTotal.Int64() <= 0 {
return false
}
return true
},
1*time.Minute,
time.Second,
"Osmosis node failed to retrieve prop tally",
)
noTotal, _, _, _, _ := s.queryPropTally(chainAAPIEndpoint, sfProposalNumber)
noTotalFinal, err := strconv.Atoi(noTotal.String())
s.Require().NoError(err)

s.Require().Eventually(
func() bool {
intAccountBalance, err := s.queryIntermediaryAccount(chainA, chainAAPIEndpoint, "gamm/pool/1", chainA.Validators[1].OperAddress)
s.Require().NoError(err)
if err != nil {
return false
}
if noTotalFinal != intAccountBalance {
fmt.Printf("noTotalFinal %v does not match intAccountBalance %v", noTotalFinal, intAccountBalance)
return false
}
return true
},
1*time.Minute,
time.Second,
"superfluid delegation vote overwrite not working as expected",
)
})
}
Loading