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

Problem: sdk 0.50 is not used #1061

Merged
merged 42 commits into from
Jul 22, 2024
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
92494a6
Problem: sdk 0.50 is not used
mmsqe Jul 18, 2024
18063b9
fix build
yihuang Jul 18, 2024
f37b91d
fix build
yihuang Jul 18, 2024
a9be0f5
fix gomod2nix
yihuang Jul 18, 2024
e103091
fix rocksdb build
yihuang Jul 18, 2024
ed87c00
fix build
yihuang Jul 18, 2024
edacdde
fix module basic manager
yihuang Jul 18, 2024
456b40e
remove ModuleBasics
yihuang Jul 18, 2024
d5bbb72
fix encode
mmsqe Jul 18, 2024
ae7448c
fix keyring
mmsqe Jul 18, 2024
530fb3b
fix staking
mmsqe Jul 18, 2024
dc3b1c4
Problem: latest hermes is not used in integration tests
mmsqe Jul 18, 2024
b2150cf
Merge remote-tracking branch 'origin/master' into bump_hermes
mmsqe Jul 18, 2024
4832a7d
Merge remote-tracking branch 'origin/master' into sdk50
mmsqe Jul 18, 2024
9c92484
wait decimal fix
mmsqe Jul 18, 2024
6229313
fix tests
mmsqe Jul 18, 2024
5cf003e
fix pystarport
mmsqe Jul 18, 2024
a56a4d0
set mempool
mmsqe Jul 19, 2024
19640c1
test ci
mmsqe Jul 19, 2024
7ef4e44
skip priority
mmsqe Jul 19, 2024
c2f48fe
fix ibc
mmsqe Jul 19, 2024
dec8b69
Merge remote-tracking branch 'origin/bump_hermes' into sdk50
mmsqe Jul 19, 2024
ca5f855
fix ibc
mmsqe Jul 19, 2024
cf56991
cleanup
mmsqe Jul 19, 2024
e2df442
Revert "set mempool"
mmsqe Jul 19, 2024
cd73a77
fix hardware
mmsqe Jul 19, 2024
de29a5e
fix test
mmsqe Jul 19, 2024
86a444e
fix upgrade
mmsqe Jul 19, 2024
f48adb1
fix swagger
mmsqe Jul 20, 2024
8a1d7d6
fix sim
mmsqe Jul 20, 2024
f1ca537
subspace
mmsqe Jul 20, 2024
8062337
fix nft test
mmsqe Jul 20, 2024
a0c00b2
fix lint
yihuang Jul 22, 2024
7b0a4dd
ignore .direnv
yihuang Jul 22, 2024
0269a97
ibc-go 8.3
yihuang Jul 22, 2024
26ac3cc
use upstream sdk
yihuang Jul 22, 2024
3cb6395
update deps
yihuang Jul 22, 2024
e4a1e7b
fix build
yihuang Jul 22, 2024
e78e0a7
fix lint
yihuang Jul 22, 2024
5b45dc5
lint
mmsqe Jul 22, 2024
4ecb497
update pystarport
yihuang Jul 22, 2024
ea539c1
update pystarport
mmsqe Jul 22, 2024
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 CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
- [#1023](https://github.com/crypto-org-chain/chain-main/pull/1023) Integrate sdk 0.47
- [#1044](https://github.com/crypto-org-chain/chain-main/pull/1044) Revert the protobuf package name changes introduced in #1023.
- [#1060](https://github.com/crypto-org-chain/chain-main/pull/1060) Upgrade rocksdb to `v9.2.1` and bump versiondb.
- [#1061](https://github.com/crypto-org-chain/chain-main/pull/1061) Integrate sdk 0.50.

*Dec 6, 2023*

Expand Down
4 changes: 2 additions & 2 deletions app/ante.go
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
package app

Check failure on line 1 in app/ante.go

View workflow job for this annotation

GitHub Actions / golangci-lint

: # github.com/crypto-org-chain/chain-main/v4/app [github.com/crypto-org-chain/chain-main/v4/app.test]

import (
newsdkerrors "cosmossdk.io/errors"
sdk "github.com/cosmos/cosmos-sdk/types"
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
"github.com/cosmos/cosmos-sdk/x/auth/ante"
ibcante "github.com/cosmos/ibc-go/v7/modules/core/ante"
"github.com/cosmos/ibc-go/v7/modules/core/keeper"
ibcante "github.com/cosmos/ibc-go/v8/modules/core/ante"
"github.com/cosmos/ibc-go/v8/modules/core/keeper"
nfttypes "github.com/crypto-org-chain/chain-main/v4/x/nft-transfer/types"
)

Expand Down
418 changes: 267 additions & 151 deletions app/app.go

Large diffs are not rendered by default.

2 changes: 0 additions & 2 deletions app/encoding.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,5 @@ func MakeEncodingConfig() params.EncodingConfig {
encodingConfig := params.MakeEncodingConfig()
std.RegisterLegacyAminoCodec(encodingConfig.Amino)
std.RegisterInterfaces(encodingConfig.InterfaceRegistry)
ModuleBasics.RegisterLegacyAminoCodec(encodingConfig.Amino)
ModuleBasics.RegisterInterfaces(encodingConfig.InterfaceRegistry)
return encodingConfig
}
62 changes: 41 additions & 21 deletions app/export.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,11 @@ import (
"fmt"
"log"

storetypes "cosmossdk.io/store/types"
tmproto "github.com/cometbft/cometbft/proto/tendermint/types"

servertypes "github.com/cosmos/cosmos-sdk/server/types"
sdk "github.com/cosmos/cosmos-sdk/types"
slashingtypes "github.com/cosmos/cosmos-sdk/x/slashing/types"

servertypes "github.com/cosmos/cosmos-sdk/server/types"
"github.com/cosmos/cosmos-sdk/x/staking"
stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types"
)
Expand All @@ -21,7 +20,7 @@ func (app *ChainApp) ExportAppStateAndValidators(
forZeroHeight bool, jailAllowedAddrs []string, modulesToExport []string,
) (servertypes.ExportedApp, error) {
// as if they could withdraw from the start of the next block
ctx := app.NewContext(true, tmproto.Header{Height: app.LastBlockHeight()})
ctx := app.NewContext(true).WithBlockHeader(tmproto.Header{Height: app.LastBlockHeight()})

// We export at last height + 1, because that's the height at which
// Tendermint will start InitChain.
Expand All @@ -32,13 +31,16 @@ func (app *ChainApp) ExportAppStateAndValidators(
app.prepForZeroHeightGenesis(ctx, jailAllowedAddrs)
}

genState := app.mm.ExportGenesisForModules(ctx, app.appCodec, modulesToExport)
genState, err := app.mm.ExportGenesisForModules(ctx, app.appCodec, modulesToExport)
if err != nil {
return servertypes.ExportedApp{}, err
}
appState, err := json.MarshalIndent(genState, "", " ")
if err != nil {
return servertypes.ExportedApp{}, err
}

validators, err := staking.WriteValidators(ctx, &app.StakingKeeper)
validators, err := staking.WriteValidators(ctx, app.StakingKeeper)
if err != nil {
return servertypes.ExportedApp{}, err
}
Expand All @@ -54,7 +56,7 @@ func (app *ChainApp) ExportAppStateAndValidators(
// NOTE zero height genesis is a temporary feature which will be deprecated
//
// in favour of export at a block height
func (app *ChainApp) prepForZeroHeightGenesis(ctx sdk.Context, jailAllowedAddrs []string) {
func (app *ChainApp) prepForZeroHeightGenesis(ctx sdk.Context, jailAllowedAddrs []string) error {
applyAllowedAddrs := false

// check if there is a allowed address list
Expand All @@ -76,7 +78,11 @@ func (app *ChainApp) prepForZeroHeightGenesis(ctx sdk.Context, jailAllowedAddrs

// withdraw all validator commission
app.StakingKeeper.IterateValidators(ctx, func(_ int64, val stakingtypes.ValidatorI) (stop bool) {
_, err := app.DistrKeeper.WithdrawValidatorCommission(ctx, val.GetOperator())
valBz, err := app.StakingKeeper.ValidatorAddressCodec().StringToBytes(val.GetOperator())
if err != nil {
panic(err)
}
_, err = app.DistrKeeper.WithdrawValidatorCommission(ctx, valBz)
if err != nil {
log := app.DistrKeeper.Logger(ctx)
log.Error(fmt.Sprintf("Withdraw validator commission: %v", err))
Expand All @@ -85,7 +91,10 @@ func (app *ChainApp) prepForZeroHeightGenesis(ctx sdk.Context, jailAllowedAddrs
})

// withdraw all delegator rewards
dels := app.StakingKeeper.GetAllDelegations(ctx)
dels, err := app.StakingKeeper.GetAllDelegations(ctx)
if err != nil {
return err
}
for _, delegation := range dels {
valAddr, errv := sdk.ValAddressFromBech32(delegation.ValidatorAddress)
if errv != nil {
Expand Down Expand Up @@ -115,13 +124,25 @@ func (app *ChainApp) prepForZeroHeightGenesis(ctx sdk.Context, jailAllowedAddrs

// reinitialize all validators
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 := app.DistrKeeper.GetValidatorOutstandingRewardsCoins(ctx, val.GetOperator())
feePool := app.DistrKeeper.GetFeePool(ctx)
scraps, err := app.DistrKeeper.GetValidatorOutstandingRewardsCoins(ctx, valBz)
if err != nil {
panic(err)
}
feePool, err := app.DistrKeeper.FeePool.Get(ctx)
if err != nil {
panic(err)
}
feePool.CommunityPool = feePool.CommunityPool.Add(scraps...)
app.DistrKeeper.SetFeePool(ctx, feePool)
if err := app.DistrKeeper.FeePool.Set(ctx, feePool); err != nil {
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 Expand Up @@ -172,14 +193,14 @@ func (app *ChainApp) prepForZeroHeightGenesis(ctx sdk.Context, jailAllowedAddrs
// Iterate through validators by power descending, reset bond heights, and
// update bond intra-tx counters.
store := ctx.KVStore(app.keys[stakingtypes.StoreKey])
iter := sdk.KVStoreReversePrefixIterator(store, stakingtypes.ValidatorsKey)
iter := storetypes.KVStoreReversePrefixIterator(store, stakingtypes.ValidatorsKey)
counter := int16(0)

for ; iter.Valid(); iter.Next() {
addr := sdk.ValAddress(stakingtypes.AddressFromValidatorsKey(iter.Key()))
validator, found := app.StakingKeeper.GetValidator(ctx, addr)
if !found {
panic("expected validator, not found")
validator, err := app.StakingKeeper.GetValidator(ctx, addr)
if err != nil {
return fmt.Errorf("expected validator %s not found, %w", addr, err)
}

validator.UnbondingHeight = 0
Expand All @@ -195,15 +216,14 @@ func (app *ChainApp) prepForZeroHeightGenesis(ctx sdk.Context, jailAllowedAddrs
log.Fatal(err)
}

_, err := app.StakingKeeper.ApplyAndReturnValidatorSetUpdates(ctx)
if err != nil {
log.Fatal(err)
if _, err := app.StakingKeeper.ApplyAndReturnValidatorSetUpdates(ctx); err != nil {
return err
}

/* Handle slashing state. */

// reset start height on signing infos
app.SlashingKeeper.IterateValidatorSigningInfos(
return app.SlashingKeeper.IterateValidatorSigningInfos(
ctx,
func(addr sdk.ConsAddress, info slashingtypes.ValidatorSigningInfo) (stop bool) {
info.StartHeight = 0
Expand Down
Loading
Loading