Skip to content

Commit

Permalink
Merge branch 'main' into sam/autopilot-hash-sender-2
Browse files Browse the repository at this point in the history
  • Loading branch information
sampocs committed Jan 10, 2024
2 parents e5559d1 + 2113b4f commit bbb8dfe
Show file tree
Hide file tree
Showing 12 changed files with 188 additions and 147 deletions.
8 changes: 4 additions & 4 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,8 @@ import (
ibcclienttypes "github.com/cosmos/ibc-go/v7/modules/core/02-client/types"
ibchost "github.com/cosmos/ibc-go/v7/modules/core/exported"
ibckeeper "github.com/cosmos/ibc-go/v7/modules/core/keeper"
ibctesting "github.com/cosmos/interchain-security/v3/legacy_ibc_testing/testing"
ccvstaking "github.com/cosmos/interchain-security/v3/x/ccv/democracy/staking"
ibctesting "github.com/cosmos/ibc-go/v7/testing"
ibctestingtypes "github.com/cosmos/ibc-go/v7/testing/types"
"github.com/spf13/cast"

ica "github.com/cosmos/ibc-go/v7/modules/apps/27-interchain-accounts"
Expand Down Expand Up @@ -154,9 +154,9 @@ import (
ccvconsumer "github.com/cosmos/interchain-security/v3/x/ccv/consumer"
ccvconsumerkeeper "github.com/cosmos/interchain-security/v3/x/ccv/consumer/keeper"
ccvconsumertypes "github.com/cosmos/interchain-security/v3/x/ccv/consumer/types"
ccvstaking "github.com/cosmos/interchain-security/v3/x/ccv/democracy/staking"

storetypes "github.com/cosmos/cosmos-sdk/store/types"
"github.com/cosmos/interchain-security/v3/legacy_ibc_testing/core"
)

const (
Expand Down Expand Up @@ -971,7 +971,7 @@ func (app *StrideApp) Name() string { return app.BaseApp.Name() }
func (app *StrideApp) GetBaseApp() *baseapp.BaseApp { return app.BaseApp }

// GetStakingKeeper implements the TestingApp interface.
func (app *StrideApp) GetStakingKeeper() core.StakingKeeper {
func (app *StrideApp) GetStakingKeeper() ibctestingtypes.StakingKeeper {
return app.StakingKeeper
}

Expand Down
104 changes: 56 additions & 48 deletions app/apptesting/test_helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (

abci "github.com/cometbft/cometbft/abci/types"
"github.com/cometbft/cometbft/crypto/ed25519"
tmencoding "github.com/cometbft/cometbft/crypto/encoding"
tmtypesproto "github.com/cometbft/cometbft/proto/tendermint/types"
tmtypes "github.com/cometbft/cometbft/types"
"github.com/cosmos/cosmos-sdk/baseapp"
Expand All @@ -24,12 +25,12 @@ import (
connectiontypes "github.com/cosmos/ibc-go/v7/modules/core/03-connection/types"
channeltypes "github.com/cosmos/ibc-go/v7/modules/core/04-channel/types"
tendermint "github.com/cosmos/ibc-go/v7/modules/light-clients/07-tendermint"
ibctesting "github.com/cosmos/ibc-go/v7/testing"
"github.com/cosmos/ibc-go/v7/testing/simapp"
appProvider "github.com/cosmos/interchain-security/v3/app/provider"
ibctesting "github.com/cosmos/interchain-security/v3/legacy_ibc_testing/testing"
icstestingutils "github.com/cosmos/interchain-security/v3/testutil/ibc_testing"
e2e "github.com/cosmos/interchain-security/v3/testutil/integration"
ccvprovidertypes "github.com/cosmos/interchain-security/v3/x/ccv/provider/types"
testkeeper "github.com/cosmos/interchain-security/v3/testutil/keeper"
ccvtypes "github.com/cosmos/interchain-security/v3/x/ccv/types"
"github.com/stretchr/testify/require"
"github.com/stretchr/testify/suite"
Expand Down Expand Up @@ -139,67 +140,74 @@ func (s *AppTestHelper) SetupIBCChains(hostChainID string) {
s.Coordinator = ibctesting.NewCoordinator(s.T(), 0)

// Initialize a provider testing app
s.ProviderChain = ibctesting.NewTestChain(s.T(), s.Coordinator, icstestingutils.ProviderAppIniter, ProviderChainID)
ibctesting.DefaultTestingAppInit = icstestingutils.ProviderAppIniter
s.ProviderChain = ibctesting.NewTestChain(s.T(), s.Coordinator, ProviderChainID)
s.ProviderApp = s.ProviderChain.App.(*appProvider.App)

// Initialize a stride testing app by casting a StrideApp -> TestingApp
s.StrideChain = ibctesting.NewTestChainWithValSet(s.T(), s.Coordinator, app.InitStrideIBCTestingApp, StrideChainID,
s.ProviderChain.Vals, s.ProviderChain.Signers)

// Initialize a host testing app using SimApp -> TestingApp
s.HostChain = ibctesting.NewTestChain(s.T(), s.Coordinator, ibctesting.SetupTestingApp, hostChainID)

// Update coordinator
s.Coordinator.Chains = map[string]*ibctesting.TestChain{
StrideChainID: s.StrideChain,
hostChainID: s.HostChain,
ProviderChainID: s.ProviderChain,
}
s.IbcEnabled = true

// valsets must match
providerValUpdates := tmtypes.TM2PB.ValidatorUpdates(s.ProviderChain.Vals)
strideValUpdates := tmtypes.TM2PB.ValidatorUpdates(s.StrideChain.Vals)
s.Require().True(len(providerValUpdates) == len(strideValUpdates), "initial valset not matching")

// for i := 0; i < len(providerValUpdates); i++ {
// addr1 := ccvutils.GetChangePubKeyAddress(providerValUpdates[i])
// addr2 := ccvutils.GetChangePubKeyAddress(strideValUpdates[i])
// s.Require().True(bytes.Equal(addr1, addr2), "validator mismatch")
// }

// move chains to the next block
s.ProviderChain.NextBlock()
s.StrideChain.NextBlock()
s.HostChain.NextBlock()

ibctesting.DefaultTestingAppInit = ibctesting.SetupTestingApp
s.HostChain = ibctesting.NewTestChain(s.T(), s.Coordinator, hostChainID)

// create a consumer addition prop
// NOTE: the initial height passed to CreateConsumerClient
// must be the height on the consumer when InitGenesis is called
prop := testkeeper.GetTestConsumerAdditionProp()
prop.ChainId = StrideChainID
prop.UnbondingPeriod = s.ProviderApp.GetTestStakingKeeper().UnbondingTime(s.ProviderChain.GetContext())
prop.InitialHeight = clienttypes.Height{RevisionNumber: 0, RevisionHeight: 3}

// create a consumer client on the provider chain
providerKeeper := s.ProviderApp.GetProviderKeeper()
// create consumer client on provider chain and set as consumer client for consumer chainID in provider keeper.
err := providerKeeper.CreateConsumerClient(
s.ProviderChain.GetContext(),
&ccvprovidertypes.ConsumerAdditionProposal{
ChainId: s.StrideChain.ChainID,
InitialHeight: s.StrideChain.LastHeader.GetHeight().(clienttypes.Height),
BlocksPerDistributionTransmission: 50,
CcvTimeoutPeriod: time.Hour,
TransferTimeoutPeriod: time.Hour,
UnbondingPeriod: time.Hour * 504,
ConsumerRedistributionFraction: "0.75",
HistoricalEntries: 10000,
},
prop,
)
s.Require().NoError(err)

// move provider to next block to commit the state
s.ProviderChain.NextBlock()
// move provider and host chain to next block
s.Coordinator.CommitBlock(s.ProviderChain)
s.Coordinator.CommitBlock(s.HostChain)

// initialize the consumer chain with the genesis state stored on the provider
strideConsumerGenesis, found := providerKeeper.GetConsumerGenesis(
s.ProviderChain.GetContext(),
s.StrideChain.ChainID,
StrideChainID,
)
s.Require().True(found, "consumer genesis not found")

// use the initial validator set from the consumer genesis as the stride chain's initial set
var strideValSet []*tmtypes.Validator
for _, update := range strideConsumerGenesis.InitialValSet {
tmPubKey, err := tmencoding.PubKeyFromProto(update.PubKey)
s.Require().NoError(err)
strideValSet = append(strideValSet, &tmtypes.Validator{
PubKey: tmPubKey,
VotingPower: update.Power,
Address: tmPubKey.Address(),
ProposerPriority: 0,
})
}

// Initialize the stride consumer chain, casted as a TestingApp
ibctesting.DefaultTestingAppInit = app.InitStrideIBCTestingApp(strideConsumerGenesis.InitialValSet)
s.StrideChain = ibctesting.NewTestChainWithValSet(
s.T(),
s.Coordinator,
StrideChainID,
tmtypes.NewValidatorSet(strideValSet),
s.ProviderChain.Signers,
)

// Call InitGenesis on the consumer
s.StrideChain.App.(*app.StrideApp).GetConsumerKeeper().InitGenesis(s.StrideChain.GetContext(), &strideConsumerGenesis)

// Update coordinator
s.Coordinator.Chains = map[string]*ibctesting.TestChain{
StrideChainID: s.StrideChain,
hostChainID: s.HostChain,
ProviderChainID: s.ProviderChain,
}
s.IbcEnabled = true
}

// Creates clients, connections, and a transfer channel between stride and a host chain
Expand All @@ -217,7 +225,7 @@ func (s *AppTestHelper) CreateTransferChannel(hostChainID string) {

// Replace stride and host apps with those from TestingApp
s.App = s.StrideChain.App.(*app.StrideApp)
// s.HostApp = s.HostChain.GetSimApp()
s.HostApp = s.HostChain.GetSimApp()
s.Ctx = s.StrideChain.GetContext()

// Finally confirm the channel was setup properly
Expand Down
26 changes: 20 additions & 6 deletions app/test_setup.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (

sdkmath "cosmossdk.io/math"
cometbftdb "github.com/cometbft/cometbft-db"
"github.com/cometbft/cometbft/abci/types"
abci "github.com/cometbft/cometbft/abci/types"
"github.com/cometbft/cometbft/crypto/secp256k1"
"github.com/cometbft/cometbft/libs/log"
Expand All @@ -18,12 +19,13 @@ import (
authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
banktypes "github.com/cosmos/cosmos-sdk/x/bank/types"
stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types"
ibctesting "github.com/cosmos/interchain-security/v3/legacy_ibc_testing/testing"
ibctesting "github.com/cosmos/ibc-go/v7/testing"
appconsumer "github.com/cosmos/interchain-security/v3/app/consumer"
consumertypes "github.com/cosmos/interchain-security/v3/x/ccv/consumer/types"

testutil "github.com/Stride-Labs/stride/v16/testutil"
ccvtypes "github.com/cosmos/interchain-security/v3/x/ccv/types"

cmdcfg "github.com/Stride-Labs/stride/v16/cmd/strided/config"
testutil "github.com/Stride-Labs/stride/v16/testutil"
)

const Bech32Prefix = "stride"
Expand Down Expand Up @@ -174,7 +176,19 @@ func GenesisStateWithValSet(app *StrideApp) GenesisState {
}

// Initializes a new Stride App casted as a TestingApp for IBC support
func InitStrideIBCTestingApp() (ibctesting.TestingApp, map[string]json.RawMessage) {
app := InitStrideTestApp(false)
return app, NewDefaultGenesisState()
func InitStrideIBCTestingApp(initValPowers []types.ValidatorUpdate) func() (ibctesting.TestingApp, map[string]json.RawMessage) {
return func() (ibctesting.TestingApp, map[string]json.RawMessage) {
encoding := appconsumer.MakeTestEncodingConfig()
app := InitStrideTestApp(false)
genesisState := NewDefaultGenesisState()

// Feed consumer genesis with provider validators
var consumerGenesis ccvtypes.ConsumerGenesisState
encoding.Codec.MustUnmarshalJSON(genesisState[consumertypes.ModuleName], &consumerGenesis)
consumerGenesis.InitialValSet = initValPowers
consumerGenesis.Params.Enabled = true
genesisState[consumertypes.ModuleName] = encoding.Codec.MustMarshalJSON(&consumerGenesis)

return app, genesisState
}
}
3 changes: 2 additions & 1 deletion app/upgrades/v12/upgrades.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import (
ibckeeper "github.com/cosmos/ibc-go/v7/modules/core/keeper"
ccvconsumerkeeper "github.com/cosmos/interchain-security/v3/x/ccv/consumer/keeper"
consumertypes "github.com/cosmos/interchain-security/v3/x/ccv/consumer/types"
ccvtypes "github.com/cosmos/interchain-security/v3/x/ccv/types"
"github.com/spf13/cast"
)

Expand Down Expand Up @@ -49,7 +50,7 @@ func CreateUpgradeHandler(
return fromVM, fmt.Errorf("failed to unmarshal genesis state: %w", err)
}

var consumerGenesis = consumertypes.GenesisState{}
var consumerGenesis = ccvtypes.ConsumerGenesisState{}
cdc.MustUnmarshalJSON(appState[consumertypes.ModuleName], &consumerGenesis)

consumerGenesis.PreCCV = true
Expand Down
5 changes: 3 additions & 2 deletions cmd/consumer.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import (
"github.com/cosmos/cosmos-sdk/x/genutil"
genutiltypes "github.com/cosmos/cosmos-sdk/x/genutil/types"
ccvconsumertypes "github.com/cosmos/interchain-security/v3/x/ccv/consumer/types"
ccvtypes "github.com/cosmos/interchain-security/v3/x/ccv/types"
"github.com/spf13/cobra"

"github.com/Stride-Labs/stride/v16/testutil"
Expand Down Expand Up @@ -150,9 +151,9 @@ type GenesisData struct {
GenesisFile string
GenDoc *tmtypes.GenesisDoc
AppState map[string]json.RawMessage
ConsumerModuleState *ccvconsumertypes.GenesisState
ConsumerModuleState *ccvtypes.ConsumerGenesisState
}

func NewGenesisData(genesisFile string, genDoc *tmtypes.GenesisDoc, appState map[string]json.RawMessage, consumerModuleState *ccvconsumertypes.GenesisState) *GenesisData {
func NewGenesisData(genesisFile string, genDoc *tmtypes.GenesisDoc, appState map[string]json.RawMessage, consumerModuleState *ccvtypes.ConsumerGenesisState) *GenesisData {
return &GenesisData{GenesisFile: genesisFile, GenDoc: genDoc, AppState: appState, ConsumerModuleState: consumerModuleState}
}
54 changes: 28 additions & 26 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@ module github.com/Stride-Labs/stride/v16
go 1.19

require (
cosmossdk.io/math v1.0.1
cosmossdk.io/math v1.1.2
github.com/cometbft/cometbft v0.37.2
github.com/cometbft/cometbft-db v0.8.0
github.com/cosmos/cosmos-proto v1.0.0-beta.2
github.com/cosmos/cosmos-sdk v0.47.4
github.com/cosmos/cosmos-sdk v0.47.5
github.com/cosmos/gogoproto v1.4.10
github.com/cosmos/ibc-go/v7 v7.2.0
github.com/cosmos/ibc-go/v7 v7.3.0
github.com/cosmos/ics23/go v0.10.0
github.com/cosmos/interchain-security/v3 v3.1.0
github.com/cosmos/interchain-security/v3 v3.2.0
github.com/evmos/vesting v0.0.0-20230818101748-9ea561e4529c
github.com/gogo/protobuf v1.3.3
github.com/golang/protobuf v1.5.3
Expand All @@ -21,37 +21,44 @@ require (
github.com/spf13/cobra v1.7.0
github.com/spf13/pflag v1.0.5
github.com/stretchr/testify v1.8.4
google.golang.org/genproto/googleapis/api v0.0.0-20230629202037-9506855d4529
google.golang.org/grpc v1.57.0
google.golang.org/genproto/googleapis/api v0.0.0-20230711160842-782d3b101e98
google.golang.org/grpc v1.58.2
gopkg.in/yaml.v2 v2.4.0

)

require github.com/linxGnu/grocksdb v1.7.16 // indirect

require github.com/coinbase/rosetta-sdk-go/types v1.0.0 // indirect

require (
cosmossdk.io/log v1.1.1-0.20230704160919-88f2c830b0ca // indirect
cosmossdk.io/log v1.2.1 // indirect
github.com/99designs/go-keychain v0.0.0-20191008050251-8e49817e8af4 // indirect
github.com/cockroachdb/errors v1.10.0 // indirect
github.com/cockroachdb/logtags v0.0.0-20230118201751-21c54148d20b // indirect
github.com/cockroachdb/redact v1.1.5 // indirect
github.com/getsentry/sentry-go v0.23.0 // indirect
github.com/google/s2a-go v0.1.4 // indirect
github.com/kr/pretty v0.3.1 // indirect
github.com/kr/text v0.2.0 // indirect
github.com/mattn/go-colorable v0.1.13 // indirect
github.com/oxyno-zeta/gomock-extra-matcher v1.1.0 // indirect
github.com/rs/zerolog v1.29.1 // indirect
golang.org/x/sync v0.2.0 // indirect
google.golang.org/genproto v0.0.0-20230706204954-ccb25ca9f130 // indirect
github.com/oxyno-zeta/gomock-extra-matcher v1.2.0 // indirect
github.com/rogpeppe/go-internal v1.11.0 // indirect
github.com/rs/zerolog v1.30.0 // indirect
go.uber.org/mock v0.2.0 // indirect
golang.org/x/sync v0.3.0 // indirect
google.golang.org/genproto v0.0.0-20230711160842-782d3b101e98 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20230711160842-782d3b101e98 // indirect
)

require (
cloud.google.com/go v0.110.4 // indirect
cloud.google.com/go/compute v1.20.1 // indirect
cloud.google.com/go/compute v1.21.0 // indirect
cloud.google.com/go/compute/metadata v0.2.3 // indirect
cloud.google.com/go/iam v1.1.0 // indirect
cloud.google.com/go/iam v1.1.1 // indirect
cloud.google.com/go/storage v1.30.1 // indirect
cosmossdk.io/api v0.3.1 // indirect
cosmossdk.io/core v0.5.1 // indirect
cosmossdk.io/depinject v1.0.0-alpha.3 // indirect
cosmossdk.io/depinject v1.0.0-alpha.4 // indirect
cosmossdk.io/errors v1.0.0
cosmossdk.io/tools/rosetta v0.2.1 // indirect
filippo.io/edwards25519 v1.0.0 // indirect
Expand Down Expand Up @@ -159,20 +166,20 @@ require (
go.etcd.io/bbolt v1.3.7 // indirect
go.opencensus.io v0.24.0 // indirect
golang.org/x/crypto v0.11.0 // indirect
golang.org/x/exp v0.0.0-20230515195305-f3d0a9c9a5cc // indirect
golang.org/x/exp v0.0.0-20230711153332-06a737ee72cb // indirect
golang.org/x/net v0.12.0 // indirect
golang.org/x/oauth2 v0.8.0 // indirect
golang.org/x/sys v0.10.0 // indirect
golang.org/x/oauth2 v0.10.0 // indirect
golang.org/x/sys v0.11.0 // indirect
golang.org/x/term v0.10.0 // indirect
golang.org/x/text v0.11.0 // indirect
golang.org/x/text v0.12.0 // indirect
golang.org/x/xerrors v0.0.0-20220907171357-04be3eba64a2 // indirect; indirect ustrd
google.golang.org/api v0.126.0 // indirect
google.golang.org/appengine v1.6.7 // indirect
google.golang.org/protobuf v1.31.0 // indirect
gopkg.in/ini.v1 v1.67.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
nhooyr.io/websocket v1.8.6 // indirect
pgregory.net/rapid v0.5.5 // indirect
pgregory.net/rapid v1.1.0 // indirect
sigs.k8s.io/yaml v1.3.0 // indirect

)
Expand All @@ -183,12 +190,7 @@ replace (
github.com/btcsuite/btcd => github.com/btcsuite/btcd v0.22.2 //indirect
// fork SDK to fix SDKv0.47 Distribution Bug
// TODO - Remove this patch and update Tokens in a subsequent upgrade handler
github.com/cosmos/cosmos-sdk => github.com/Stride-Labs/cosmos-sdk v0.47.4-stride-distribution-fix-1

// Two changes
// (1) Testing infra
// (2) Fix bech32 bug
github.com/cosmos/interchain-security/v3 => github.com/Stride-Labs/interchain-security/v3 v3.1.0-remove-validation-bug-7d3d9d
github.com/cosmos/cosmos-sdk => github.com/Stride-Labs/cosmos-sdk v0.47.5-stride-distribution-fix-0

// Add additional verification check to ensure an account is a BaseAccount type before converting
// it to a vesting account: https://github.com/Stride-Labs/vesting/pull/1
Expand Down
Loading

0 comments on commit bbb8dfe

Please sign in to comment.