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

Make consumer running without going through ICS changeover #860

Merged
merged 14 commits into from
Aug 3, 2023
Merged
Show file tree
Hide file tree
Changes from 11 commits
Commits
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 app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -570,6 +570,7 @@ func NewStrideApp(
app.StakingKeeper,
app.IcacallbacksKeeper,
app.RatelimitKeeper,
app.ConsumerKeeper,
)
app.StakeibcKeeper = *stakeibcKeeper.SetHooks(
stakeibcmoduletypes.NewMultiStakeIBCHooks(app.ClaimKeeper.Hooks()),
Expand Down
11 changes: 11 additions & 0 deletions app/proposals_whitelisting.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,10 @@ import (

upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types"

ccvconsumertypes "github.com/cosmos/interchain-security/v3/x/ccv/consumer/types"
ccvgov "github.com/cosmos/interchain-security/v3/x/ccv/democracy/governance"

autopilottypes "github.com/Stride-Labs/stride/v12/x/autopilot/types"
minttypes "github.com/Stride-Labs/stride/v12/x/mint/types"
stakeibctypes "github.com/Stride-Labs/stride/v12/x/stakeibc/types"
)
Expand Down Expand Up @@ -86,6 +88,11 @@ var WhitelistedParams = map[ccvgov.ParamChangeKey]struct{}{
{MsgType: stakingtypes.ModuleName, Key: string(stakingtypes.KeyMaxEntries)}: {},
{MsgType: stakingtypes.ModuleName, Key: string(stakingtypes.KeyHistoricalEntries)}: {},
{MsgType: stakingtypes.ModuleName, Key: string(stakingtypes.KeyBondDenom)}: {},
//autopilot
{MsgType: autopilottypes.ModuleName, Key: string(autopilottypes.KeyStakeibcActive)}: {},
{MsgType: autopilottypes.ModuleName, Key: string(autopilottypes.KeyClaimActive)}: {},
//ccv consumer
{MsgType: ccvconsumertypes.ModuleName, Key: string(ccvconsumertypes.KeyRewardDenoms)}: {},
//distribution
{MsgType: distrtypes.ModuleName, Key: string(distrtypes.ParamStoreKeyCommunityTax)}: {},
{MsgType: distrtypes.ModuleName, Key: string(distrtypes.ParamStoreKeyWithdrawAddrEnabled)}: {},
Expand All @@ -96,6 +103,7 @@ var WhitelistedParams = map[ccvgov.ParamChangeKey]struct{}{
{MsgType: minttypes.ModuleName, Key: string(minttypes.KeyReductionPeriodInEpochs)}: {},
{MsgType: minttypes.ModuleName, Key: string(minttypes.KeyReductionFactor)}: {},
{MsgType: minttypes.ModuleName, Key: string(minttypes.KeyPoolAllocationRatio)}: {},
{MsgType: minttypes.ModuleName, Key: string(minttypes.KeyDeveloperRewardsReceiver)}: {},
{MsgType: minttypes.ModuleName, Key: string(minttypes.KeyMintingRewardsDistributionStartEpoch)}: {},
//ibc transfer
{MsgType: ibctransfertypes.ModuleName, Key: string(ibctransfertypes.KeySendEnabled)}: {},
Expand All @@ -116,6 +124,9 @@ var WhitelistedParams = map[ccvgov.ParamChangeKey]struct{}{
{MsgType: stakeibctypes.ModuleName, Key: string(stakeibctypes.KeyDefaultMaxRedemptionRateThreshold)}: {},
{MsgType: stakeibctypes.ModuleName, Key: string(stakeibctypes.KeyIBCTransferTimeoutNanos)}: {},
{MsgType: stakeibctypes.ModuleName, Key: string(stakeibctypes.KeySafetyNumValidators)}: {},
{MsgType: stakeibctypes.ModuleName, Key: string(stakeibctypes.KeySafetyMaxSlashPercent)}: {},
{MsgType: stakeibctypes.ModuleName, Key: string(stakeibctypes.KeyMaxRedemptionRates)}: {},
{MsgType: stakeibctypes.ModuleName, Key: string(stakeibctypes.KeyMinRedemptionRates)}: {},
//ica
{MsgType: icahosttypes.SubModuleName, Key: string(icahosttypes.KeyHostEnabled)}: {},
{MsgType: icahosttypes.SubModuleName, Key: string(icahosttypes.KeyAllowMessages)}: {},
Expand Down
47 changes: 31 additions & 16 deletions cmd/consumer.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package cmd
import (
"encoding/json"
"fmt"
"strconv"

errorsmod "cosmossdk.io/errors"
types1 "github.com/cometbft/cometbft/abci/types"
Expand All @@ -24,31 +25,46 @@ func AddConsumerSectionCmd(defaultNodeHome string) *cobra.Command {
genesisMutator := NewDefaultGenesisIO()

txCmd := &cobra.Command{
Use: "add-consumer-section",
Use: "add-consumer-section [num_nodes]",
Args: cobra.ExactArgs(1),
Short: "ONLY FOR TESTING PURPOSES! Modifies genesis so that chain can be started locally with one node.",
SuggestionsMinimumDistance: 2,
RunE: func(cmd *cobra.Command, args []string) error {
numNodes, err := strconv.Atoi(args[0])
if err != nil {
return errorsmod.Wrap(err, "invalid number of nodes")
} else if numNodes == 0 {
return errorsmod.Wrap(nil, "num_nodes can not be zero")
}

return genesisMutator.AlterConsumerModuleState(cmd, func(state *GenesisData, _ map[string]json.RawMessage) error {
initialValset := []types1.ValidatorUpdate{}
genesisState := testutil.CreateMinimalConsumerTestGenesis()
clientCtx := client.GetClientContextFromCmd(cmd)
serverCtx := server.GetServerContextFromCmd(cmd)
config := serverCtx.Config
config.SetRoot(clientCtx.HomeDir)
privValidator := pvm.LoadFilePV(config.PrivValidatorKeyFile(), config.PrivValidatorStateFile())
pk, err := privValidator.GetPubKey()
if err != nil {
return err
}
sdkPublicKey, err := cryptocodec.FromTmPubKeyInterface(pk)
if err != nil {
return err
}
tmProtoPublicKey, err := cryptocodec.ToTmProtoPublicKey(sdkPublicKey)
if err != nil {
return err
homeDir := clientCtx.HomeDir
for i := 1; i <= numNodes; i++ {
homeDir = fmt.Sprintf("%s%d", homeDir[:len(homeDir)-1], i)
config.SetRoot(homeDir)

privValidator := pvm.LoadFilePV(config.PrivValidatorKeyFile(), config.PrivValidatorStateFile())
pk, err := privValidator.GetPubKey()
if err != nil {
return err
}
sdkPublicKey, err := cryptocodec.FromTmPubKeyInterface(pk)
if err != nil {
return err
}
tmProtoPublicKey, err := cryptocodec.ToTmProtoPublicKey(sdkPublicKey)
if err != nil {
return err
}

initialValset = append(initialValset, types1.ValidatorUpdate{PubKey: tmProtoPublicKey, Power: 100})
}

initialValset := []types1.ValidatorUpdate{{PubKey: tmProtoPublicKey, Power: 100}}
vals, err := tmtypes.PB2TM.ValidatorUpdates(initialValset)
if err != nil {
return errorsmod.Wrap(err, "could not convert val updates to validator set")
Expand All @@ -58,7 +74,6 @@ func AddConsumerSectionCmd(defaultNodeHome string) *cobra.Command {
genesisState.ProviderConsensusState.NextValidatorsHash = tmtypes.NewValidatorSet(vals).Hash()

state.ConsumerModuleState = genesisState

return nil
})
},
Expand Down
1 change: 1 addition & 0 deletions deps/evmos
Submodule evmos added at ec337e
2 changes: 1 addition & 1 deletion deps/juno
Submodule juno updated 192 files
2 changes: 1 addition & 1 deletion deps/relayer
Submodule relayer updated 88 files
+4 −0 CHANGELOG.md
+1 −1 Makefile
+0 −4 buf.work.yaml
+2 −2 cmd/appstate.go
+9 −1 cmd/config.go
+6 −5 cmd/flags.go
+100 −46 cmd/keys.go
+1 −1 cmd/paths.go
+3 −14 cmd/root.go
+2 −28 cmd/start.go
+39 −2 cmd/tx.go
+21 −15 cregistry/chain_info.go
+11 −0 docs/troubleshooting.md
+17 −17 go.mod
+59 −42 go.sum
+6 −0 go.work
+1,668 −0 go.work.sum
+202 −0 interchaintest/fee_middleware_test.go
+8 −8 interchaintest/go.mod
+16 −16 interchaintest/go.sum
+6 −19 interchaintest/relayer.go
+3 −2 internal/relayertest/system.go
+4 −0 proto/buf.gen.gogo.yaml
+13 −0 proto/buf.gen.penumbra.yaml
+31 −0 proto/buf.lock
+7 −0 proto/buf.yaml
+20 −0 proto/cosmos/crypto/sr25519/keys.proto
+3 −1 relayer/chain.go
+2 −0 relayer/chains/cosmos/codec.go
+22 −5 relayer/chains/cosmos/cosmos_chain_processor.go
+20 −10 relayer/chains/cosmos/keys.go
+46 −0 relayer/chains/cosmos/keys/sr25519/algo.go
+320 −0 relayer/chains/cosmos/keys/sr25519/keys.pb.go
+47 −0 relayer/chains/cosmos/keys/sr25519/privkey.go
+38 −0 relayer/chains/cosmos/keys/sr25519/pubkey.go
+104 −0 relayer/chains/cosmos/keys_test.go
+11 −0 relayer/chains/cosmos/message_handlers.go
+2 −1 relayer/chains/cosmos/module/app_module.go
+0 −1 relayer/chains/cosmos/msg.go
+22 −19 relayer/chains/cosmos/provider.go
+0 −3 relayer/chains/cosmos/query.go
+29 −2 relayer/chains/cosmos/tx.go
+61 −0 relayer/chains/cosmos/tx_test.go
+2 −1 relayer/chains/mock/mock_chain_processor.go
+3 −1 relayer/chains/mock/mock_chain_processor_test.go
+100 −0 relayer/chains/penumbra/codec.go
+4,867 −0 relayer/chains/penumbra/core/chain/v1alpha1/chain.pb.go
+9,742 −0 relayer/chains/penumbra/core/crypto/v1alpha1/crypto.pb.go
+9,467 −0 relayer/chains/penumbra/core/dex/v1alpha1/dex.pb.go
+7,233 −0 relayer/chains/penumbra/core/governance/v1alpha1/governance.pb.go
+2,465 −0 relayer/chains/penumbra/core/ibc/v1alpha1/ibc.pb.go
+6,026 −0 relayer/chains/penumbra/core/stake/v1alpha1/stake.pb.go
+16,110 −0 relayer/chains/penumbra/core/transaction/v1alpha1/transaction.pb.go
+589 −0 relayer/chains/penumbra/core/transparent_proofs/v1alpha1/transparent_proofs.pb.go
+1,213 −0 relayer/chains/penumbra/custody/v1alpha1/custody.pb.go
+472 −0 relayer/chains/penumbra/event_parser.go
+215 −0 relayer/chains/penumbra/grpc_query.go
+211 −0 relayer/chains/penumbra/keys.go
+157 −0 relayer/chains/penumbra/log.go
+168 −0 relayer/chains/penumbra/message_handlers.go
+80 −0 relayer/chains/penumbra/msg.go
+420 −0 relayer/chains/penumbra/penumbra_chain_processor.go
+343 −0 relayer/chains/penumbra/provider.go
+985 −0 relayer/chains/penumbra/query.go
+232 −0 relayer/chains/penumbra/relayer_packets.go
+2,240 −0 relayer/chains/penumbra/tx.go
+13,899 −0 relayer/chains/penumbra/view/v1alpha1/view.pb.go
+3 −0 relayer/channel.go
+1 −1 relayer/codecs/ethermint/algorithm.go
+1 −1 relayer/codecs/injective/algorithm.go
+1 −0 relayer/connection.go
+55 −0 relayer/events.go
+9 −1 relayer/packet-tx.go
+3 −0 relayer/processor/message_processor.go
+22 −6 relayer/processor/path_processor.go
+247 −100 relayer/processor/path_processor_internal.go
+30 −0 relayer/processor/types.go
+5 −0 relayer/processor/types_internal.go
+9 −4 relayer/provider/provider.go
+5 −0 relayer/relayMsgs.go
+8 −4 relayer/strategies.go
+6 −1 scripts/protocgen.sh
+0 −80 third_party/proto/amino/amino.proto
+0 −6 third_party/proto/buf.yaml
+0 −23 third_party/proto/cosmos/auth/v1beta1/auth.proto
+0 −97 third_party/proto/cosmos_proto/cosmos.proto
+0 −145 third_party/proto/gogoproto/gogo.proto
+0 −41 third_party/proto/tendermint/crypto/proof.proto
2 changes: 1 addition & 1 deletion deps/stargaze
Submodule stargaze updated 156 files
31 changes: 31 additions & 0 deletions dockernet/src/create_governors.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#!/bin/bash

set -eu
SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
source $SCRIPT_DIR/../config.sh

CHAIN="$1"

CHAIN_ID=$(GET_VAR_VALUE ${CHAIN}_CHAIN_ID)
BINARY=$(GET_VAR_VALUE ${CHAIN}_BINARY)
DENOM=$(GET_VAR_VALUE ${CHAIN}_DENOM)
NUM_NODES=$(GET_VAR_VALUE ${CHAIN}_NUM_NODES)
NODE_PREFIX=$(GET_VAR_VALUE ${CHAIN}_NODE_PREFIX)
VAL_PREFIX=$(GET_VAR_VALUE ${CHAIN}_VAL_PREFIX)

STAKE_TOKENS=${STAKE_TOKENS}000000

echo "Creating $CHAIN_ID governors.."
for (( i=1; i <= $NUM_NODES; i++ )); do
node_name="${NODE_PREFIX}${i}"
cmd="$BINARY --home ${STATE}/$node_name"
val_acct="${VAL_PREFIX}${i}"
pub_key=$($cmd tendermint show-validator)

$cmd tx staking create-validator --amount ${STAKE_TOKENS}${DENOM} --from $val_acct \
--pubkey=$pub_key --commission-rate="0.10" --commission-max-rate="0.20" \
--commission-max-change-rate="0.01" --min-self-delegation="1" -y | TRIM_TX
sleep 2
done

echo "Done"
38 changes: 28 additions & 10 deletions dockernet/src/init_chain.sh
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,8 @@ set_stride_genesis() {
jq '(.app_state.epochs.epochs[] | select(.identifier=="stride_epoch") ).duration = $epochLen' --arg epochLen $STRIDE_EPOCH_EPOCH_DURATION $genesis_config > json.tmp && mv json.tmp $genesis_config
jq '(.app_state.epochs.epochs[] | select(.identifier=="mint") ).duration = $epochLen' --arg epochLen $STRIDE_MINT_EPOCH_DURATION $genesis_config > json.tmp && mv json.tmp $genesis_config
jq '.app_state.staking.params.unbonding_time = $newVal' --arg newVal "$UNBONDING_TIME" $genesis_config > json.tmp && mv json.tmp $genesis_config
jq '.app_state.gov.deposit_params.max_deposit_period = $newVal' --arg newVal "$MAX_DEPOSIT_PERIOD" $genesis_config > json.tmp && mv json.tmp $genesis_config
jq '.app_state.gov.voting_params.voting_period = $newVal' --arg newVal "$VOTING_PERIOD" $genesis_config > json.tmp && mv json.tmp $genesis_config
jq '.app_state.gov.params.max_deposit_period = $newVal' --arg newVal "$MAX_DEPOSIT_PERIOD" $genesis_config > json.tmp && mv json.tmp $genesis_config
jq '.app_state.gov.params.voting_period = $newVal' --arg newVal "$VOTING_PERIOD" $genesis_config > json.tmp && mv json.tmp $genesis_config
jq '.app_state.ccvconsumer.params.unbonding_period = $newVal' --arg newVal "$UNBONDING_TIME" $genesis_config > json.tmp && mv json.tmp $genesis_config

# enable stride as an interchain accounts controller
jq "del(.app_state.interchain_accounts)" $genesis_config > json.tmp && mv json.tmp $genesis_config
Expand Down Expand Up @@ -77,6 +74,14 @@ set_host_genesis() {
sed -i -E 's|"slash_fraction_downtime": "0.010000000000000000"|"slash_fraction_downtime": "0.050000000000000000"|g' $genesis_config
}

set_consumer_genesis() {
genesis_config=$1

# add consumer genesis
$MAIN_CMD add-consumer-section $NUM_NODES
jq '.app_state.ccvconsumer.params.unbonding_period = $newVal' --arg newVal "$UNBONDING_TIME" $genesis_config > json.tmp && mv json.tmp $genesis_config
}

MAIN_ID=1 # Node responsible for genesis and persistent_peers
MAIN_NODE_NAME=""
MAIN_NODE_ID=""
Expand Down Expand Up @@ -136,13 +141,17 @@ for (( i=1; i <= $NUM_NODES; i++ )); do
# Add this account to the current node
$cmd add-genesis-account ${val_addr} ${VAL_TOKENS}${DENOM}

if [[ $CHAIN != "STRIDE" ]]; then
cp $DOCKERNET_HOME/state/${STRIDE_NODE_PREFIX}${i}/config/priv_validator_key.json $DOCKERNET_HOME/state/${NODE_PREFIX}${i}/config/priv_validator_key.json
cp $DOCKERNET_HOME/state/${STRIDE_NODE_PREFIX}${i}/config/node_key.json $DOCKERNET_HOME/state/${NODE_PREFIX}${i}/config/node_key.json
# Copy over the provider stride validator keys to the provider (in the event
# that we are testing ICS)
if [[ $CHAIN == "GAIA" ]]; then
stride_config=$DOCKERNET_HOME/state/${STRIDE_NODE_PREFIX}${i}/config
host_config=$DOCKERNET_HOME/state/${NODE_PREFIX}${i}/config
cp ${stride_config}/priv_validator_key.json ${host_config}/priv_validator_key.json
cp ${stride_config}/node_key.json ${host_config}/node_key.json
fi

if [[ ($CHAIN == "STRIDE" && ($i == 1 || $i == 2)) || $CHAIN != "STRIDE" ]]; then
# actually set this account as a validator on the current node
# Only generate the validator txs for host chains
if [[ "$CHAIN" != "STRIDE" && "$CHAIN" != "HOST" ]]; then
$cmd gentx $val_acct ${STAKE_TOKENS}${DENOM} --chain-id $CHAIN_ID --keyring-backend test &> /dev/null
fi

Expand Down Expand Up @@ -183,6 +192,7 @@ if [ "$CHAIN" == "STRIDE" ]; then
RELAYER_MNEMONIC="${RELAYER_MNEMONICS[i]}"

echo "$RELAYER_MNEMONIC" | $MAIN_CMD keys add $RELAYER_ACCT --recover --keyring-backend=test >> $KEYS_LOGS 2>&1

RELAYER_ADDRESS=$($MAIN_CMD keys show $RELAYER_ACCT --keyring-backend test -a)
$MAIN_CMD add-genesis-account ${RELAYER_ADDRESS} ${VAL_TOKENS}${DENOM}
done
Expand All @@ -207,8 +217,11 @@ else
fi
fi

# now we process gentx txs on the main node
$MAIN_CMD collect-gentxs &> /dev/null
# Only collect the validator genesis txs for host chains
if [[ "$CHAIN" != "STRIDE" && "$CHAIN" != "HOST" ]]; then
# now we process gentx txs on the main node
$MAIN_CMD collect-gentxs &> /dev/null
fi

# wipe out the persistent peers for the main node (these are incorrectly autogenerated for each validator during collect-gentxs)
sed -i -E "s|persistent_peers = .*|persistent_peers = \"\"|g" $MAIN_CONFIG
Expand All @@ -220,6 +233,11 @@ else
set_host_genesis $MAIN_GENESIS
fi

# update consumer genesis for stride binary chains
if [[ "$CHAIN" == "STRIDE" || "$CHAIN" == "HOST" ]]; then
set_consumer_genesis $MAIN_GENESIS
fi

# for all peer nodes....
for (( i=2; i <= $NUM_NODES; i++ )); do
node_name="${NODE_PREFIX}${i}"
Expand Down
34 changes: 2 additions & 32 deletions dockernet/src/start_relayers.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,6 @@ SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )

source ${SCRIPT_DIR}/../config.sh

HERMES_LOGS=${LOGS}/hermes.log
HERMES_CONFIG=$STATE/hermes/config.toml
TMP_MNEMONICS=mnemonic.txt

mkdir -p $STATE/hermes
chmod -R 777 $STATE/hermes
cp ${DOCKERNET_HOME}/config/hermes_config.toml $HERMES_CONFIG

HERMES_CMD="$DOCKERNET_HOME/../build/hermes/release/hermes --config $HERMES_CONFIG"

added_stride_account="false"

for chain in ${HOST_CHAINS[@]}; do
chain_id=$(GET_VAR_VALUE ${chain}_CHAIN_ID)
Expand All @@ -40,25 +29,6 @@ for chain in ${HOST_CHAINS[@]}; do
$relayer_exec rly transact link stride-${chain_name} >> $relayer_logs 2>&1
echo "Done"

printf "STRIDE <> $chain - Adding hermes host key..."
echo "$mnemonic" > $TMP_MNEMONICS
$HERMES_CMD keys add --key-name $account_name --chain $chain_id --mnemonic-file $TMP_MNEMONICS --overwrite
echo "Done"

if [[ "$added_stride_account" == "false" ]]; then
printf "STRIDE <> $chain - Adding hermes Stride key..."
echo "$mnemonic" > $TMP_MNEMONICS
$HERMES_CMD keys add --key-name $RELAYER_STRIDE_ACCT --chain $STRIDE_CHAIN_ID --mnemonic-file $TMP_MNEMONICS --overwrite
echo "Done"

added_stride_account="true"
fi

# $DOCKER_COMPOSE up -d relayer-${chain_name}
# $DOCKER_COMPOSE logs -f relayer-${chain_name} | sed -r -u "s/\x1B\[([0-9]{1,3}(;[0-9]{1,2})?)?[mGK]//g" >> $relayer_logs 2>&1 &
$DOCKER_COMPOSE up -d relayer-${chain_name}
$DOCKER_COMPOSE logs -f relayer-${chain_name} | sed -r -u "s/\x1B\[([0-9]{1,3}(;[0-9]{1,2})?)?[mGK]//g" >> $relayer_logs 2>&1 &
done

$DOCKER_COMPOSE up -d hermes
$DOCKER_COMPOSE logs -f hermes | sed -r -u "s/\x1B\[([0-9]{1,3}(;[0-9]{1,2})?)?[mGK]//g" >> $HERMES_LOGS 2>&1 &

rm $TMP_MNEMONICS
10 changes: 8 additions & 2 deletions dockernet/start_network.sh
Original file line number Diff line number Diff line change
Expand Up @@ -50,17 +50,23 @@ if [[ "${UPGRADE_NAME:-}" != "" ]]; then
echo "Done"
fi


# Initialize the state for each chain
for chain in STRIDE ${HOST_CHAINS[@]}; do
bash $SRC/init_chain.sh $chain
done


# Start the chain and create the transfer channels
# Start each chain, create the transfer channels and start the relayers
bash $SRC/start_chain.sh
bash $SRC/start_relayers.sh

# Create governors for chains running the stride binary
for chain in STRIDE ${HOST_CHAINS[@]}; do
if [[ "$chain" == "STRIDE" || "$chain" == "HOST" ]]; then
bash $SRC/create_governors.sh $chain
fi
done

# Register all host zones
for i in ${!HOST_CHAINS[@]}; do
bash $SRC/register_host.sh ${HOST_CHAINS[$i]} $i
Expand Down
11 changes: 2 additions & 9 deletions dockernet/upgrades/setup_ics.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
source ${SCRIPT_DIR}/../config.sh

#======== 1. ADD CONSUMER ========

PROVIDER_HOME="$DOCKERNET_HOME/state/${GAIA_NODE_PREFIX}1"
CONSUMER_HOME_PREFIX="$DOCKERNET_HOME/state/${STRIDE_NODE_PREFIX}"
CONSUMER_HOME="${CONSUMER_HOME_PREFIX}1"
Expand Down Expand Up @@ -141,14 +140,8 @@ $relayer_exec rly keys restore stride $RELAYER_STRIDE_ICS_ACCT "$mnemonic" >> $r
$relayer_exec rly keys restore $chain_name $account_name "$mnemonic" --coin-type $coin_type >> $relayer_logs 2>&1
echo "Done restoring relayer keys"

printf "STRIDE <> GAIA - Creating new connections..." | tee -a $relayer_logs
$relayer_exec rly transact connection stride-gaia-ics >> $relayer_logs 2>&1
echo "Done."
sleep 10

printf "STRIDE <> GAIA - Creating new channels..." | tee -a $relayer_logs
$relayer_exec rly transact channel stride-gaia-ics --src-port consumer --dst-port provider --order ordered --version 1 >> $relayer_logs 2>&1
echo "Done."
printf "STRIDE <> GAIA - Creating ICS channel..." | tee -a $relayer_logs
$relayer_exec rly transact link stride-gaia-ics --src-port consumer --dst-port provider --order ordered --version 1 >> $relayer_logs 2>&1

$DOCKER_COMPOSE up -d relayer-gaia-ics
$DOCKER_COMPOSE logs -f relayer-gaia-ics | sed -r -u "s/\x1B\[([0-9]{1,3}(;[0-9]{1,2})?)?[mGK]//g" >> $relayer_logs 2>&1 &
Expand Down
39 changes: 39 additions & 0 deletions x/stakeibc/keeper/consumer.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
package keeper

import (
sdk "github.com/cosmos/cosmos-sdk/types"

"github.com/Stride-Labs/stride/v12/x/stakeibc/types"
)

// Register new stTokens to the consumer reward denom whitelist
func (k Keeper) RegisterStTokenDenomsToWhitelist(ctx sdk.Context, denoms []string) error {
hostZones := k.GetAllHostZone(ctx)
allDenomsMap := make(map[string]bool)
registeredDenomsMap := make(map[string]bool)

// get all stToken denoms
for _, zone := range hostZones {
allDenomsMap["st"+zone.HostDenom] = true
}

// get registered denoms in the consumer reward denom whitelist
consumerParams := k.ConsumerKeeper.GetConsumerParams(ctx)
for _, denom := range consumerParams.RewardDenoms {
registeredDenomsMap[denom] = true
}

// register new denoms to the whitelist
for _, denom := range denoms {
if !allDenomsMap[denom] {
return types.ErrStTokenNotFound
} else if registeredDenomsMap[denom] {
continue
} else {
consumerParams.RewardDenoms = append(consumerParams.RewardDenoms, denom)
}
}

k.ConsumerKeeper.SetParams(ctx, consumerParams)
return nil
}
Loading