Skip to content

Commit

Permalink
back port fix
Browse files Browse the repository at this point in the history
  • Loading branch information
davidterpay committed Sep 11, 2023
1 parent b569328 commit 499e96c
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 17 deletions.
16 changes: 12 additions & 4 deletions tests/app/export.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,11 @@ func (app *TestApp) prepForZeroHeightGenesis(ctx sdk.Context, jailAllowedAddrs [

// withdraw all validator commission
err := app.StakingKeeper.IterateValidators(ctx, func(_ int64, val stakingtypes.ValidatorI) (stop bool) {
_, _ = app.DistrKeeper.WithdrawValidatorCommission(ctx, val.GetOperator())
valBz, err := app.StakingKeeper.ValidatorAddressCodec().StringToBytes(val.GetOperator())
if err != nil {
panic(err)
}
_, _ = app.DistrKeeper.WithdrawValidatorCommission(ctx, valBz)
return false
})
if err != nil {
Expand Down Expand Up @@ -113,9 +117,13 @@ func (app *TestApp) prepForZeroHeightGenesis(ctx sdk.Context, jailAllowedAddrs [
ctx = ctx.WithBlockHeight(0)

// reinitialize all validators
app.StakingKeeper.IterateValidators(ctx, func(_ int64, val stakingtypes.ValidatorI) (stop bool) {
err = app.StakingKeeper.IterateValidators(ctx, func(_ int64, val stakingtypes.ValidatorI) (stop bool) {
valBz, err := app.StakingKeeper.ValidatorAddressCodec().StringToBytes(val.GetOperator())
if err != nil {
panic(err)
}
// donate any unwithdrawn outstanding reward fraction tokens to the community pool
scraps, err := app.DistrKeeper.GetValidatorOutstandingRewardsCoins(ctx, val.GetOperator())
scraps, err := app.DistrKeeper.GetValidatorOutstandingRewardsCoins(ctx, valBz)
if err != nil {
panic(err)
}
Expand All @@ -128,7 +136,7 @@ func (app *TestApp) prepForZeroHeightGenesis(ctx sdk.Context, jailAllowedAddrs [
panic(err)
}

if err := app.DistrKeeper.Hooks().AfterValidatorCreated(ctx, val.GetOperator()); err != nil {
if err := app.DistrKeeper.Hooks().AfterValidatorCreated(ctx, valBz); err != nil {
panic(err)
}
return false
Expand Down
9 changes: 4 additions & 5 deletions tests/app/testappd/cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import (
"cosmossdk.io/depinject"
"cosmossdk.io/log"
confixcmd "cosmossdk.io/tools/confix/cmd"

"github.com/skip-mev/block-sdk/tests/app"

"github.com/cosmos/cosmos-sdk/client"
Expand Down Expand Up @@ -199,8 +198,8 @@ lru_size = 0`
func initRootCmd(
rootCmd *cobra.Command,
txConfig client.TxConfig,
_ codectypes.InterfaceRegistry,
_ codec.Codec,
interfaceRegistry codectypes.InterfaceRegistry,

Check warning on line 201 in tests/app/testappd/cmd/root.go

View workflow job for this annotation

GitHub Actions / golangci-lint

unused-parameter: parameter 'interfaceRegistry' seems to be unused, consider removing or renaming it as _ (revive)
appCodec codec.Codec,

Check warning on line 202 in tests/app/testappd/cmd/root.go

View workflow job for this annotation

GitHub Actions / golangci-lint

unused-parameter: parameter 'appCodec' seems to be unused, consider removing or renaming it as _ (revive)
basicManager module.BasicManager,
) {
cfg := sdk.GetConfig()
Expand All @@ -219,11 +218,11 @@ func initRootCmd(

// add keybase, auxiliary RPC, query, genesis, and tx child commands
rootCmd.AddCommand(
rpc.StatusCommand(),
server.StatusCommand(),
genesisCommand(txConfig, basicManager),
queryCommand(),
txCommand(),
keys.Commands(app.DefaultNodeHome),
keys.Commands(),
)
}

Expand Down
17 changes: 12 additions & 5 deletions tests/app/testappd/cmd/testnet.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import (
"github.com/cosmos/cosmos-sdk/crypto/hd"
"github.com/cosmos/cosmos-sdk/crypto/keyring"
cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types"
"github.com/cosmos/cosmos-sdk/runtime"
"github.com/cosmos/cosmos-sdk/server"
srvconfig "github.com/cosmos/cosmos-sdk/server/config"
"github.com/cosmos/cosmos-sdk/testutil"
Expand Down Expand Up @@ -145,7 +146,7 @@ Example:
args.numValidators, _ = cmd.Flags().GetInt(flagNumValidators)
args.algo, _ = cmd.Flags().GetString(flags.FlagKeyType)

return initTestnetFiles(clientCtx, cmd, config, mbm, genBalIterator, args)
return initTestnetFiles(clientCtx, cmd, config, mbm, genBalIterator, clientCtx.TxConfig.SigningContext().ValidatorAddressCodec(), args)
},
}

Expand Down Expand Up @@ -205,6 +206,7 @@ func initTestnetFiles(
nodeConfig *cmtconfig.Config,
mbm module.BasicManager,
genBalIterator banktypes.GenesisBalancesIterator,
valAddrCodec runtime.ValidatorAddressCodec,
args initArgs,
) error {
if args.chainID == "" {
Expand Down Expand Up @@ -297,9 +299,13 @@ func initTestnetFiles(
genBalances = append(genBalances, banktypes.Balance{Address: addr.String(), Coins: coins.Sort()})
genAccounts = append(genAccounts, authtypes.NewBaseAccount(addr, nil, 0, 0))

valStr, err := valAddrCodec.BytesToString(sdk.ValAddress(addr))
if err != nil {
return err
}
valTokens := sdk.TokensFromConsensusPower(100, sdk.DefaultPowerReduction)
createValMsg, err := stakingtypes.NewMsgCreateValidator(
sdk.ValAddress(addr),
valStr,
valPubKeys[i],
sdk.NewCoin(sdk.DefaultBondDenom, valTokens),
stakingtypes.NewDescription(nodeDirName, "", "", "", ""),
Expand Down Expand Up @@ -346,7 +352,7 @@ func initTestnetFiles(

err := collectGenFiles(
clientCtx, nodeConfig, args.chainID, nodeIDs, valPubKeys, args.numValidators,
args.outputDir, args.nodeDirPrefix, args.nodeDaemonHome, genBalIterator,
args.outputDir, args.nodeDirPrefix, args.nodeDaemonHome, genBalIterator, valAddrCodec,
)
if err != nil {
return err
Expand Down Expand Up @@ -403,7 +409,7 @@ func initGenFiles(
func collectGenFiles(
clientCtx client.Context, nodeConfig *cmtconfig.Config, chainID string,
nodeIDs []string, valPubKeys []cryptotypes.PubKey, numValidators int,
outputDir, nodeDirPrefix, nodeDaemonHome string, genBalIterator banktypes.GenesisBalancesIterator,
outputDir, nodeDirPrefix, nodeDaemonHome string, genBalIterator banktypes.GenesisBalancesIterator, valAddrCodec runtime.ValidatorAddressCodec,
) error {
var appState json.RawMessage
genTime := cmttime.Now()
Expand All @@ -424,7 +430,8 @@ func collectGenFiles(
return err
}

nodeAppState, err := genutil.GenAppStateFromConfig(clientCtx.Codec, clientCtx.TxConfig, nodeConfig, initCfg, appGenesis, genBalIterator, genutiltypes.DefaultMessageValidator)
nodeAppState, err := genutil.GenAppStateFromConfig(clientCtx.Codec, clientCtx.TxConfig, nodeConfig, initCfg, appGenesis, genBalIterator, genutiltypes.DefaultMessageValidator,
valAddrCodec)
if err != nil {
return err
}
Expand Down
4 changes: 2 additions & 2 deletions x/builder/keeper/msg_server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,11 +101,11 @@ func (suite *KeeperTestSuite) TestMsgAuctionBid() {

suite.bankKeeper.EXPECT().
SendCoins(suite.ctx, bidder.Address, proposerOperator.Address, sdk.NewCoins(sdk.NewInt64Coin("stake", 1024))).
Return(nil)
Return(nil).AnyTimes()

suite.bankKeeper.EXPECT().
SendCoins(suite.ctx, bidder.Address, escrow.Address, sdk.NewCoins(sdk.NewInt64Coin("stake", 2392))).
Return(nil)
Return(nil).AnyTimes()
},
expectErr: false,
},
Expand Down
2 changes: 1 addition & 1 deletion x/builder/rewards/proposer_provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,5 +37,5 @@ func (p *ProposerRewardsAddressProvider) GetRewardsAddress(ctx sdk.Context) (sdk
return nil, err
}

return sdk.AccAddress(prevProposer.GetOperator()), nil
return sdk.AccAddressFromBech32(prevProposer.GetOperator())
}

0 comments on commit 499e96c

Please sign in to comment.