Skip to content

Commit

Permalink
Merge branch 'main' into cleanup_v15
Browse files Browse the repository at this point in the history
  • Loading branch information
sampocs committed Dec 13, 2023
2 parents e981184 + ca43a34 commit 3599e14
Show file tree
Hide file tree
Showing 103 changed files with 13,146 additions and 1,636 deletions.
2 changes: 1 addition & 1 deletion .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
path = deps/juno
url = https://github.com/CosmosContracts/juno.git
[submodule "deps/osmosis"]
# Commit: v16.1.1-no-fees
# Commit: v20.5.0-no-fees
path = deps/osmosis
url = https://github.com/Stride-Labs/osmosis.git
[submodule "deps/stargaze"]
Expand Down
6 changes: 6 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,12 @@ upgrade-integration-tests-part-1: start-docker-all start-upgrade-integration-tes
setup-ics:
UPGRADE_HEIGHT=150 bash $(DOCKERNET_HOME)/upgrades/setup_ics.sh

###############################################################################
### LocalNet ###
###############################################################################
start-local-node:
@bash scripts/start_local_node.sh

###############################################################################
### Local to Mainnet ###
###############################################################################
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ close soup mirror crew erode defy knock trigger gather eyebrow tent farm gym glo
This mnemonic will have tokens on every chain running locally.

#### Running integration tests
Ensure submoules are updated
Ensure submodules are updated
```
git submodule update --init --recursive
```
Expand Down
1 change: 1 addition & 0 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -590,6 +590,7 @@ func NewStrideApp(
keys[stakeibcmoduletypes.StoreKey],
keys[stakeibcmoduletypes.MemStoreKey],
app.GetSubspace(stakeibcmoduletypes.ModuleName),
authtypes.NewModuleAddress(govtypes.ModuleName).String(),
app.AccountKeeper,
app.BankKeeper,
app.ICAControllerKeeper,
Expand Down
99 changes: 98 additions & 1 deletion app/apptesting/test_helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ import (
"github.com/cosmos/cosmos-sdk/baseapp"
codectypes "github.com/cosmos/cosmos-sdk/codec/types"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/types/bech32"
banktypes "github.com/cosmos/cosmos-sdk/x/bank/types"
minttypes "github.com/cosmos/cosmos-sdk/x/mint/types"
upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types"
"github.com/cosmos/gogoproto/proto"
Expand Down Expand Up @@ -231,7 +233,10 @@ func (s *AppTestHelper) CreateICAChannel(owner string) (channelID, portID string
_, transferChannelExists := s.App.IBCKeeper.ChannelKeeper.GetChannel(s.Ctx, ibctesting.TransferPort, ibctesting.FirstChannelID)
if !transferChannelExists {
ownerSplit := strings.Split(owner, ".")
s.Require().Equal(2, len(ownerSplit), "owner should be of the form: {HostZone}.{AccountName}")
isHostZoneICA := len(ownerSplit) == 2
isTradeRouteICA := len(ownerSplit) == 3
s.Require().True(isHostZoneICA || isTradeRouteICA,
"owner should be either of the form: {chainId}.{AccountName} or {chainId}.{rewarDenom}-{hostDenom}.{accountName}")

hostChainID := ownerSplit[0]
s.CreateTransferChannel(hostChainID)
Expand Down Expand Up @@ -352,6 +357,34 @@ func (s *AppTestHelper) UpdateChannelState(portId, channelId string, channelStat
s.App.IBCKeeper.ChannelKeeper.SetChannel(s.Ctx, portId, channelId, channel)
}

// Helper function to check if an ICA was submitted by seeing if the sequence number incremented
func (s *AppTestHelper) CheckICATxSubmitted(portId, channelId string, icaFunction func() error) {
// Get the sequence before the tested funciton is run
startSequence := s.MustGetNextSequenceNumber(portId, channelId)

// Run the test function and confirm there's no error
err := icaFunction()
s.Require().NoError(err, "no error expected executing tested function")

// Check that the sequence number incremented
endSequence := s.MustGetNextSequenceNumber(portId, channelId)
s.Require().Equal(startSequence+1, endSequence, "sequence number should have incremented from tested function")
}

// Helper function to check if an ICA was NOT submitted by seeing if the sequence number did not increment
func (s *AppTestHelper) CheckICATxNotSubmitted(portId, channelId string, icaFunction func() error) {
// Get the sequence before the tested funciton is run
startSequence := s.MustGetNextSequenceNumber(portId, channelId)

// Run the test function and confirm there's no error
err := icaFunction()
s.Require().NoError(err, "no error expected executing tested function")

// Check that the sequence number did not change
endSequence := s.MustGetNextSequenceNumber(portId, channelId)
s.Require().Equal(startSequence, endSequence, "sequence number should NOT have incremented from tested function")
}

// Constructs an ICA Packet Acknowledgement compatible with ibc-go v5+
func ICAPacketAcknowledgement(t *testing.T, msgType string, msgResponses []proto.Message) channeltypes.Acknowledgement {
txMsgData := &sdk.TxMsgData{
Expand Down Expand Up @@ -409,6 +442,13 @@ func (s *AppTestHelper) GetIBCDenomTrace(denom string) transfertypes.DenomTrace
return transfertypes.ParseDenomTrace(prefixedDenom)
}

// Helper function to get the next sequence number for testing when an ICA was submitted
func (s *AppTestHelper) MustGetNextSequenceNumber(portId, channelId string) uint64 {
sequence, found := s.App.StakeibcKeeper.IBCKeeper.ChannelKeeper.GetNextSequenceSend(s.Ctx, portId, channelId)
s.Require().True(found, "sequence number for port %s and channel %s was not found", portId, channelId)
return sequence
}

// Creates and stores an IBC denom from a base denom on transfer channel-0
// This is only required for tests that use the transfer keeper and require that the IBC
// denom is present in the store
Expand Down Expand Up @@ -437,6 +477,46 @@ func (s *AppTestHelper) MockClientLatestHeight(height uint64) {
s.App.IBCKeeper.ClientKeeper.SetClientState(s.Ctx, FirstClientId, &clientState)
}

// Helper function to mock out a client and connection to test
// mapping from connection ID back to chain ID
// This also mocks out the consensus state to enable testing registering interchain accounts
func (s *AppTestHelper) MockClientAndConnection(chainId, clientId, connectionId string) {
clientHeight := clienttypes.Height{
RevisionHeight: uint64(s.Ctx.BlockHeight()),
}
clientState := tendermint.ClientState{
ChainId: chainId,
LatestHeight: clientHeight,
TrustingPeriod: time.Minute * 10,
}
s.App.IBCKeeper.ClientKeeper.SetClientState(s.Ctx, clientId, &clientState)

consensusState := tendermint.ConsensusState{
Timestamp: s.Ctx.BlockTime(),
}
s.App.IBCKeeper.ClientKeeper.SetClientConsensusState(s.Ctx, clientId, clientHeight, &consensusState)

connection := connectiontypes.ConnectionEnd{
ClientId: clientId,
Versions: []*connectiontypes.Version{connectiontypes.DefaultIBCVersion},
}
s.App.IBCKeeper.ConnectionKeeper.SetConnection(s.Ctx, connectionId, connection)
}

// Helper function to mock out an ICA address
func (s *AppTestHelper) MockICAChannel(connectionId, channelId, owner, address string) {
// Create an open channel with the ICA port
portId, _ := icatypes.NewControllerPortID(owner)
channel := channeltypes.Channel{
State: channeltypes.OPEN,
}
s.App.IBCKeeper.ChannelKeeper.SetChannel(s.Ctx, portId, channelId, channel)

// Then set the address and make the channel active
s.App.ICAControllerKeeper.SetInterchainAccountAddress(s.Ctx, connectionId, portId, address)
s.App.ICAControllerKeeper.SetActiveChannelID(s.Ctx, connectionId, portId, channelId)
}

func (s *AppTestHelper) ConfirmUpgradeSucceededs(upgradeName string, upgradeHeight int64) {
s.Ctx = s.Ctx.WithBlockHeight(upgradeHeight - 1)
plan := upgradetypes.Plan{Name: upgradeName, Height: upgradeHeight}
Expand All @@ -452,6 +532,23 @@ func (s *AppTestHelper) ConfirmUpgradeSucceededs(upgradeName string, upgradeHeig
})
}

// Returns the bank store key prefix for an address and denom
// Useful for testing balance ICQs
func (s *AppTestHelper) GetBankStoreKeyPrefix(address, denom string) []byte {
_, addressBz, err := bech32.DecodeAndConvert(address)
s.Require().NoError(err, "no error expected when bech decoding address")
return append(banktypes.CreateAccountBalancesPrefix(addressBz), []byte(denom)...)
}

// Extracts the address and denom from a bank store prefix
// Useful for testing balance ICQs as it can confirm that the serialized query request
// data has the proper address and denom
func (s *AppTestHelper) ExtractAddressAndDenomFromBankPrefix(data []byte) (address, denom string) {
addressBz, denom, err := banktypes.AddressAndDenomFromBalancesStore(data[1:]) // Remove BalancePrefix byte
s.Require().NoError(err, "no error expected when getting address and denom from balance store")
return addressBz.String(), denom
}

// Generates a valid and invalid test address (used for non-keeper tests)
func GenerateTestAddrs() (string, string) {
pk1 := ed25519.GenPrivKey().PubKey()
Expand Down
3 changes: 3 additions & 0 deletions app/proposals_whitelisting.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@ var WhiteListModule = map[string]struct{}{
"/cosmos.upgrade.v1beta1.MsgCancelUpgrade": {},
"/stride.icaoracle.MsgToggleOracle": {},
"/stride.icaoracle.MsgRemoveOracle": {},
"/stride.stakeibc.MsgCreateTradeRoute": {},
"/stride.stakeibc.MsgUpdateTradeRoute": {},
"/stride.stakeibc.MsgDeleteTradeRoute": {},
}

func IsModuleWhiteList(typeUrl string) bool {
Expand Down
2 changes: 1 addition & 1 deletion deps/osmosis
Submodule osmosis updated 1238 files
6 changes: 2 additions & 4 deletions dockernet/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,10 @@ make build-docker build={z}
volumes:
- ./dockernet/state/{new-host-zone}2:/home/{new-host-zone}/.{new-host-zone}d
...
{new-host-zone}5:
{new-host-zone}3:
image: stridezone:{new-host-zone}
volumes:
- ./dockernet/state/{new-host-zone}5:/home/{new-host-zone}/.{new-host-zone}d
- ./dockernet/state/{new-host-zone}3:/home/{new-host-zone}/.{new-host-zone}d
...
relayer-{chain}:
image: stridezone:relayer
Expand Down
55 changes: 50 additions & 5 deletions dockernet/config.sh
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ if [[ "${ALL_HOST_CHAINS:-false}" == "true" ]]; then
elif [[ "${#HOST_CHAINS[@]}" == "0" ]]; then
HOST_CHAINS=(GAIA)
fi
REWARD_CONVERTER_HOST_ZONE=${HOST_CHAINS[0]}

# DENOMS
STRD_DENOM="ustrd"
Expand Down Expand Up @@ -108,7 +109,7 @@ IBC_STARS_DENOM=$IBC_STARS_CHANNEL_3_DENOM

# CHAIN PARAMS
BLOCK_TIME='1s'
STRIDE_HOUR_EPOCH_DURATION="90s"
STRIDE_HOUR_EPOCH_DURATION="60s"
STRIDE_DAY_EPOCH_DURATION="140s"
STRIDE_EPOCH_EPOCH_DURATION="35s"
STRIDE_MINT_EPOCH_DURATION="20s"
Expand Down Expand Up @@ -336,15 +337,24 @@ STRIDE_RELAYER_MNEMONICS=(
"$RELAYER_GAIA_ICS_MNEMONIC"
"$RELAYER_DYDX_MNEMONIC"
)
# Mnemonics for connections between two non-stride chains
RELAYER_NOBLE_DYDX_MNEMONIC="sentence fruit crumble sail bar knife exact flame apart prosper hint myth clean among tiny burden depart purity select envelope identify cross physical emerge"
RELAYER_DYDX_NOBLE_MNEMONIC="aerobic breeze claw climb bounce morning tank victory eight funny employ bracket hire reduce fine flee lava domain warfare loop theme fly tattoo must"
# Mnemonics for connections between accessory chains
RELAYER_STRIDE_OSMO_MNEMONIC="father october lonely ticket leave regret pudding buffalo return asthma plastic piano beef orient ill clip right phone ready pottery helmet hip solid galaxy"
RELAYER_OSMO_STRIDE_MNEMONIC="narrow assist come feel canyon anxiety three reason satoshi inspire region little attend impulse what student dog armor economy faculty dutch distance upon calm"
RELAYER_STRIDE_NOBLE_MNEMONIC="absent confirm lumber hobby glide alter remain yard mixed fiscal series kitchen effort protect pistol hire bless police year struggle near hour wisdom jewel"
RELAYER_NOBLE_STRIDE_MNEMONIC="jar point equal question fatigue frog disorder wasp labor obtain head print orbit entire frown high sadness dash retire idea coffee rubber rough until"
RELAYER_NOBLE_OSMO_MNEMONIC="actual field visual wage orbit add human unit happy rich evil chair entire person february cactus deputy impact gasp elbow sunset brand possible fly"
RELAYER_OSMO_NOBLE_MNEMONIC="obey clinic miss grunt inflict laugh sell moral kitchen tumble gold song flavor rather horn exhaust state amazing poverty differ approve spike village device"
# Mnemonics between host zone and accessory chains when running with GAIA as the host
RELAYER_GAIA_NOBLE_MNEMONIC="aerobic breeze claw climb bounce morning tank victory eight funny employ bracket hire reduce fine flee lava domain warfare loop theme fly tattoo must"
RELAYER_NOBLE_GAIA_MNEMONIC="sentence fruit crumble sail bar knife exact flame apart prosper hint myth clean among tiny burden depart purity select envelope identify cross physical emerge"
RELAYER_GAIA_OSMO_MNEMONIC="small fire step promote fox reward book seek arctic session illegal loyal because brass spoil minute wonder jazz shoe price muffin churn evil monitor"
RELAYER_OSMO_GAIA_MNEMONIC="risk wool reason sweet current strategy female miracle squeeze that wire develop ocean rapid domain lift blame monkey sick round museum item maze trumpet"
# Mnemonics between host zone and accessory chains when running with DYDX as the host
RELAYER_NOBLE_DYDX_MNEMONIC="sentence fruit crumble sail bar knife exact flame apart prosper hint myth clean among tiny burden depart purity select envelope identify cross physical emerge"
RELAYER_DYDX_NOBLE_MNEMONIC="aerobic breeze claw climb bounce morning tank victory eight funny employ bracket hire reduce fine flee lava domain warfare loop theme fly tattoo must"
RELAYER_DYDX_OSMO_MNEMONIC="small fire step promote fox reward book seek arctic session illegal loyal because brass spoil minute wonder jazz shoe price muffin churn evil monitor"
RELAYER_OSMO_DYDX_MNEMONIC="risk wool reason sweet current strategy female miracle squeeze that wire develop ocean rapid domain lift blame monkey sick round museum item maze trumpet"


STRIDE_ADDRESS() {
# After an upgrade, the keys query can sometimes print migration info,
# so we need to filter by valid addresses using the prefix
Expand Down Expand Up @@ -512,6 +522,41 @@ GET_COUNTERPARTY_TRANSFER_CHANNEL_ID() {
$main_cmd q ibc channel end transfer $channel_id | grep -A 2 counterparty | grep channel_id | awk '{print $2}'
}

GET_LATEST_PROPOSAL_ID() {
chain="$1"

main_cmd=$(GET_VAR_VALUE ${chain}_MAIN_CMD)
$main_cmd q gov proposals | grep ' id:' | tail -1 | awk '{printf $2}' | tr -d '"'
}

WATCH_PROPOSAL_STATUS() {
chain="$1"
proposal_id="$2"

main_cmd=$(GET_VAR_VALUE ${chain}_MAIN_CMD)

# Continually polls the proposal status until it passes or fails
while true; do
status=$($main_cmd query gov proposal $proposal_id | grep "status" | awk '{printf $2}')
if [[ "$status" == "PROPOSAL_STATUS_VOTING_PERIOD" ]]; then
echo " Proposal still in progress..."
sleep 5
elif [[ "$status" == "PROPOSAL_STATUS_PASSED" ]]; then
echo " Proposal passed!"
exit 0
elif [[ "$status" == "PROPOSAL_STATUS_REJECTED" ]]; then
echo " Proposal rejected!"
exit 1
elif [[ "$status" == "PROPOSAL_STATUS_FAILED" ]]; then
echo " Proposal failed!"
exit 1
else
echo "ERROR: Unknown proposal status: $status"
exit 1
fi
done
}

TRIM_TX() {
grep -E "code:|txhash:" | sed 's/^/ /'
}
Expand Down
3 changes: 2 additions & 1 deletion dockernet/config/ica_host.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@
"/cosmos.distribution.v1beta1.MsgFundCommunityPool",
"/ibc.applications.transfer.v1.MsgTransfer",
"/cosmwasm.wasm.v1.MsgExecuteContract",
"/cosmwasm.wasm.v1.MsgInstantiateContract"
"/cosmwasm.wasm.v1.MsgInstantiateContract",
"/osmosis.gamm.v1beta1.MsgSwapExactAmountIn"
]
}
}
Expand Down
Loading

0 comments on commit 3599e14

Please sign in to comment.