Skip to content

Commit

Permalink
Remove Authz in v5 (#574)
Browse files Browse the repository at this point in the history
Co-authored-by: sampocs <sam.pochyly@gmail.com>
  • Loading branch information
shellvish and sampocs authored Jan 13, 2023
1 parent f3f607a commit cd96f99
Show file tree
Hide file tree
Showing 8 changed files with 61 additions and 29 deletions.
19 changes: 1 addition & 18 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,6 @@ import (
authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
"github.com/cosmos/cosmos-sdk/x/auth/vesting"
vestingtypes "github.com/cosmos/cosmos-sdk/x/auth/vesting/types"
"github.com/cosmos/cosmos-sdk/x/authz"
authzkeeper "github.com/cosmos/cosmos-sdk/x/authz/keeper"
authzmodule "github.com/cosmos/cosmos-sdk/x/authz/module"
"github.com/cosmos/cosmos-sdk/x/bank"
bankkeeper "github.com/cosmos/cosmos-sdk/x/bank/keeper"
banktypes "github.com/cosmos/cosmos-sdk/x/bank/types"
Expand Down Expand Up @@ -141,7 +138,7 @@ import (
const (
AccountAddressPrefix = "stride"
Name = "stride"
Version = "4.0.3"
Version = "5.0.0"
)

// this line is used by starport scaffolding # stargate/wasm/app/enabledProposals
Expand Down Expand Up @@ -173,7 +170,6 @@ var (
// and genesis verification.
ModuleBasics = module.NewBasicManager(
auth.AppModuleBasic{},
authzmodule.AppModuleBasic{},
genutil.AppModuleBasic{},
bank.AppModuleBasic{},
capability.AppModuleBasic{},
Expand Down Expand Up @@ -253,7 +249,6 @@ type StrideApp struct {

// keepers
AccountKeeper authkeeper.AccountKeeper
AuthzKeeper authzkeeper.Keeper
BankKeeper bankkeeper.Keeper
CapabilityKeeper *capabilitykeeper.Keeper
StakingKeeper stakingkeeper.Keeper
Expand Down Expand Up @@ -330,7 +325,6 @@ func NewStrideApp(
icacontrollertypes.StoreKey, icahosttypes.StoreKey,
recordsmoduletypes.StoreKey,
icacallbacksmoduletypes.StoreKey,
authzkeeper.StoreKey,
claimtypes.StoreKey,
// this line is used by starport scaffolding # stargate/app/storeKey
)
Expand Down Expand Up @@ -368,13 +362,6 @@ func NewStrideApp(
appCodec, keys[authtypes.StoreKey], app.GetSubspace(authtypes.ModuleName), authtypes.ProtoBaseAccount, maccPerms, AccountAddressPrefix,
)

app.AuthzKeeper = authzkeeper.NewKeeper(
keys[authzkeeper.StoreKey],
appCodec,
app.BaseApp.MsgServiceRouter(),
app.AccountKeeper,
)

app.BankKeeper = bankkeeper.NewBaseKeeper(
appCodec, keys[banktypes.StoreKey], app.AccountKeeper, app.GetSubspace(banktypes.ModuleName), app.BlacklistedModuleAccountAddrs(),
)
Expand Down Expand Up @@ -644,7 +631,6 @@ func NewStrideApp(
icaModule,
recordsModule,
icacallbacksModule,
authzmodule.NewAppModule(appCodec, app.AuthzKeeper, app.AccountKeeper, app.BankKeeper, app.interfaceRegistry),
// this line is used by starport scaffolding # stargate/app/appModule
)

Expand Down Expand Up @@ -679,7 +665,6 @@ func NewStrideApp(
recordsmoduletypes.ModuleName,
icacallbacksmoduletypes.ModuleName,
claimtypes.ModuleName,
authz.ModuleName,
// this line is used by starport scaffolding # stargate/app/beginBlockers
)

Expand Down Expand Up @@ -710,7 +695,6 @@ func NewStrideApp(
recordsmoduletypes.ModuleName,
icacallbacksmoduletypes.ModuleName,
claimtypes.ModuleName,
authz.ModuleName,
// this line is used by starport scaffolding # stargate/app/endBlockers
)

Expand Down Expand Up @@ -746,7 +730,6 @@ func NewStrideApp(
recordsmoduletypes.ModuleName,
icacallbacksmoduletypes.ModuleName,
claimtypes.ModuleName,
authz.ModuleName,
// this line is used by starport scaffolding # stargate/app/initGenesis
)

Expand Down
13 changes: 13 additions & 0 deletions app/upgrades.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,12 @@ import (
storetypes "github.com/cosmos/cosmos-sdk/store/types"
upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types"

authz "github.com/cosmos/cosmos-sdk/x/authz"

v2 "github.com/Stride-Labs/stride/v4/app/upgrades/v2"
v3 "github.com/Stride-Labs/stride/v4/app/upgrades/v3"
v4 "github.com/Stride-Labs/stride/v4/app/upgrades/v4"
v5 "github.com/Stride-Labs/stride/v4/app/upgrades/v5"
claimtypes "github.com/Stride-Labs/stride/v4/x/claim/types"
)

Expand All @@ -31,6 +34,12 @@ func (app *StrideApp) setupUpgradeHandlers() {
v4.CreateUpgradeHandler(app.mm, app.configurator),
)

// v5 upgrade handler
app.UpgradeKeeper.SetUpgradeHandler(
v5.UpgradeName,
v5.CreateUpgradeHandler(app.mm, app.configurator, app.InterchainqueryKeeper),
)

upgradeInfo, err := app.UpgradeKeeper.ReadUpgradeInfoFromDisk()
if err != nil {
panic(fmt.Errorf("Failed to read upgrade info from disk: %w", err))
Expand All @@ -47,6 +56,10 @@ func (app *StrideApp) setupUpgradeHandlers() {
storeUpgrades = &storetypes.StoreUpgrades{
Added: []string{claimtypes.StoreKey},
}
case "v5":
storeUpgrades = &storetypes.StoreUpgrades{
Deleted: []string{authz.ModuleName},
}
}

if storeUpgrades != nil {
Expand Down
34 changes: 34 additions & 0 deletions app/upgrades/v5/upgrades.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
package v4

import (
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/types/module"
authz "github.com/cosmos/cosmos-sdk/x/authz"
upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types"

interchainquerykeeper "github.com/Stride-Labs/stride/v4/x/interchainquery/keeper"
)

// Note: ensure these values are properly set before running upgrade
var (
UpgradeName = "v5"
)

// CreateUpgradeHandler creates an SDK upgrade handler for v5
func CreateUpgradeHandler(
mm *module.Manager,
configurator module.Configurator,
interchainqueryKeeper interchainquerykeeper.Keeper,
) upgradetypes.UpgradeHandler {
return func(ctx sdk.Context, _ upgradetypes.Plan, vm module.VersionMap) (module.VersionMap, error) {
// Remove authz from store as it causes an issue with state sync
delete(vm, authz.ModuleName)

// Remove a stale query from the interchainquery store
// This query used an old query ID format and got stuck after the format was updated
staleQueryId := "60b8e09dc7a65938cd6e6e5728b8aa0ca3726ffbe5511946a4f08ced316174ab"
interchainqueryKeeper.DeleteQuery(ctx, staleQueryId)

return mm.RunMigrations(ctx, configurator, vm)
}
}
2 changes: 1 addition & 1 deletion cmd/strided/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ func SetupConfig() {

version.AppName = "stride"
version.Name = "strided"
version.Version = "v4.0.3"
version.Version = "v5.0.0"
}

// SetBech32Prefixes sets the global prefixes to be used when serializing addresses and public keys to Bech32 strings.
Expand Down
2 changes: 1 addition & 1 deletion dockernet/src/init_chain.sh
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ for (( i=1; i <= $NUM_NODES; i++ )); do
sed -i -E "s|minimum-gas-prices = \".*\"|minimum-gas-prices = \"0${DENOM}\"|g" $app_toml
sed -i -E '/\[api\]/,/^enable = .*$/ s/^enable = .*$/enable = true/' $app_toml
sed -i -E 's|unsafe-cors = .*|unsafe-cors = true|g' $app_toml
sed -i -E "s|snapshot-interval = 0|snapshot-interval = 100|g" $app_toml
sed -i -E "s|snapshot-interval = 0|snapshot-interval = 300|g" $app_toml

sed -i -E "s|chain-id = \"\"|chain-id = \"${CHAIN_ID}\"|g" $client_toml
sed -i -E "s|keyring-backend = \"os\"|keyring-backend = \"test\"|g" $client_toml
Expand Down
1 change: 1 addition & 0 deletions dockernet/upgrades/Dockerfile.cosmovisor
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ RUN git clone https://github.com/Stride-Labs/stride.git \
&& sed -i -E "s|stride1k8c2m5cn322akk5wy8lpt87dd2f4yh9azg7jlh|$stride_admin_address|g" utils/admins.go \
&& env GOOS=linux GOARCH=amd64 go build -mod=readonly -trimpath -o /opt/build/ ./... \
&& mv /opt/build/strided /opt/build/strided1

RUN --mount=type=cache,target=/root/.cache/go-build cd /opt/stride && make build


16 changes: 9 additions & 7 deletions dockernet/upgrades/submit_upgrade.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ source ${SCRIPT_DIR}/../config.sh

UPGRADE_HEIGHT=250

PROPOSAL_ID=1

printf "PROPOSAL\n"
$STRIDE_MAIN_CMD tx gov submit-proposal software-upgrade $UPGRADE_NAME \
--title $UPGRADE_NAME --description "version 2 description" \
Expand All @@ -17,25 +19,25 @@ $STRIDE_MAIN_CMD query gov proposals

sleep 5
printf "\nDEPOSIT\n"
$STRIDE_MAIN_CMD tx gov deposit 1 10000001ustrd --from val1 -y | TRIM_TX
$STRIDE_MAIN_CMD tx gov deposit $PROPOSAL_ID 10000001ustrd --from val1 -y | TRIM_TX

sleep 5
printf "\nDEPOSIT CONFIRMATION\n"
$STRIDE_MAIN_CMD query gov deposits 1
$STRIDE_MAIN_CMD query gov deposits $PROPOSAL_ID

sleep 5
printf "\nVOTING\n"
$STRIDE_MAIN_CMD tx gov vote 1 yes --from val1 -y | TRIM_TX
$STRIDE_MAIN_CMD tx gov vote 1 yes --from val2 -y | TRIM_TX
$STRIDE_MAIN_CMD tx gov vote 1 yes --from val3 -y | TRIM_TX
$STRIDE_MAIN_CMD tx gov vote $PROPOSAL_ID yes --from val1 -y | TRIM_TX
$STRIDE_MAIN_CMD tx gov vote $PROPOSAL_ID yes --from val2 -y | TRIM_TX
$STRIDE_MAIN_CMD tx gov vote $PROPOSAL_ID yes --from val3 -y | TRIM_TX

sleep 5
printf "\nVOTE CONFIRMATION\n"
$STRIDE_MAIN_CMD query gov tally 1
$STRIDE_MAIN_CMD query gov tally $PROPOSAL_ID

printf "\nPROPOSAL STATUS\n"
while true; do
status=$($STRIDE_MAIN_CMD query gov proposal 1 | grep "status" | awk '{printf $2}')
status=$($STRIDE_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
Expand Down
3 changes: 1 addition & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -162,8 +162,7 @@ replace (

// dragonberry replkace line per: https://github.com/cosmos/cosmos-sdk/releases/tag/v0.45.9
github.com/confio/ics23/go => github.com/cosmos/cosmos-sdk/ics23/go v0.8.0
// apply ICA patch
// github.com/cosmos/cosmos-sdk => github.com/Stride-Labs/cosmos-sdk v0.45.9-dragonberry

// use cosmos-flavored protobufs
github.com/gogo/protobuf => github.com/regen-network/protobuf v1.3.3-alpha.regen.1

Expand Down

0 comments on commit cd96f99

Please sign in to comment.