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

feat: Upgrade SDK v0.47 to v0.50 #1069

Merged
merged 58 commits into from
Feb 27, 2024
Merged
Show file tree
Hide file tree
Changes from 28 commits
Commits
Show all changes
58 commits
Select commit Hold shift + click to select a range
bcdf4d2
rebase: rebase done with master branch
deepan95dev Jan 18, 2024
a7ccb91
fix: valset keeper_test blockHeight fixed
deepan95dev Jan 24, 2024
cd2941a
chore: handled errors
vishal-kanna Jan 24, 2024
d180dd0
Merge branch 'fix-build' of https://github.com/palomachain/paloma int…
vishal-kanna Jan 24, 2024
8b1a453
fix: test case fix in valset
deepan95dev Jan 24, 2024
1d4b788
chore: removed unused functions
deepan95dev Jan 24, 2024
6fc62a6
chore:mades changes as per review comments in evm keeper integration …
vishal-kanna Jan 24, 2024
3b10cfc
chore:fixed the failing tests in evm test files
vishal-kanna Jan 24, 2024
15ed5a9
chore: restored the blockheight with context
vishal-kanna Jan 24, 2024
23e0f64
chore: made review changes
vishal-kanna Jan 24, 2024
09f2466
chore: made changes as per review
vishal-kanna Jan 25, 2024
32aca18
fix: use libmeta in ante handler
byte-bandit Jan 25, 2024
481fc23
chore: remove signer option from proto definitions
byte-bandit Jan 25, 2024
28ec83e
fix: keyring issue fix in autocli
deepan95dev Jan 31, 2024
e554d45
Merge branch 'master' into fix-build
deepan95dev Jan 31, 2024
b9b990e
lint: go mod lint fixes
deepan95dev Jan 31, 2024
57cecf0
lint: go mod fixes
deepan95dev Jan 31, 2024
a6e254b
chore: used CustomGetSigners
vishal-kanna Feb 1, 2024
8ea793a
lint: interface registry lint fixes
deepan95dev Feb 1, 2024
7df4ce1
chore: redundant usage removed
deepan95dev Feb 1, 2024
fddf223
chore: fixed invalid coin denomination: got ugrain, expected stake e…
vishal-kanna Feb 2, 2024
ceb6715
chore: retrieved the signer option in the proto files
vishal-kanna Feb 4, 2024
99d6d2c
merge: resolved merge conflicts with master branch
deepan95dev Feb 5, 2024
4823bae
chore: updated metrix module to v0.50
vishal-kanna Feb 13, 2024
320d3f0
chore : resolved merge conflicts
vishal-kanna Feb 13, 2024
e7a3756
chore : fixed the errors in metrix keeper and upgrades.go
vishal-kanna Feb 13, 2024
7970145
fix: fixed linting errors
vishal-kanna Feb 13, 2024
77a6a0b
chore: moved metrix_integration_test to integration tests
vishal-kanna Feb 13, 2024
3af2c36
chore : made review changes
vishal-kanna Feb 14, 2024
847a686
chore: made review changes
vishal-kanna Feb 14, 2024
68e0556
chore: made review changes
vishal-kanna Feb 15, 2024
52dae27
chore : retrieved the creator field and made some review changes
vishal-kanna Feb 15, 2024
0f23e25
chore: fixed error in the consensus_keeper_test.go
vishal-kanna Feb 15, 2024
00371ff
chore: removed the print statement in the test file
vishal-kanna Feb 15, 2024
dad3392
chore: removed authority field in the evm keeper
vishal-kanna Feb 15, 2024
067d4a1
chore: fixed the errors
vishal-kanna Feb 15, 2024
6a4f65c
chore: handled error
vishal-kanna Feb 15, 2024
f0f3992
chore: used liberr and CreatTestEnv
vishal-kanna Feb 20, 2024
317fc20
chore: added helper package
vishal-kanna Feb 20, 2024
f3f10e8
fix: fixed lint issue
vishal-kanna Feb 20, 2024
43c39cd
chore: added test cases
vishal-kanna Feb 20, 2024
14b94a1
chore: used common function which unwraps the goContext to SdkContext
vishal-kanna Feb 21, 2024
9a72c83
'Revert "chore: used common function which unwraps the goContext to S…
vishal-kanna Feb 21, 2024
faea8f2
chore: added SetupPalomaPrefixes function
vishal-kanna Feb 21, 2024
9660a3b
chore: removed the creator field in consensus module
vishal-kanna Feb 21, 2024
fa2d8c2
chore: removed the depreciated creator field from the proto files
vishal-kanna Feb 21, 2024
20eff90
chore: added liblog logger
vishal-kanna Feb 21, 2024
2aadfa7
chore: returned the original error
vishal-kanna Feb 22, 2024
31f5fb5
chore: removed the GetSignBytes method
vishal-kanna Feb 22, 2024
1a998d0
chore: returned the original error
vishal-kanna Feb 22, 2024
1e5b9aa
chore: made review changes
vishal-kanna Feb 22, 2024
18fa8b5
chore: used liblog instead of k.Logger
vishal-kanna Feb 23, 2024
0a03599
chore: made review changes
vishal-kanna Feb 26, 2024
0f7d191
fix: fixed lint error
vishal-kanna Feb 26, 2024
9fbe70d
chore : made review changes
vishal-kanna Feb 26, 2024
3579e3c
chore: bump SDK version to the latest and made changes in upgrade.go
vishal-kanna Feb 26, 2024
03a81d9
fix: fixed lint issue
vishal-kanna Feb 26, 2024
13bbdda
fix: fixed go ethereum version issues
vishal-kanna Feb 27, 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
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ release/
build/
dist/
.scratch/

tests/integration/evm/keeper/testdata
byte-bandit marked this conversation as resolved.
Show resolved Hide resolved
434 changes: 242 additions & 192 deletions app/app.go

Large diffs are not rendered by default.

184 changes: 0 additions & 184 deletions app/app_setup.go

This file was deleted.

3 changes: 0 additions & 3 deletions app/encoding.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,5 @@ func MakeEncodingConfig() params.EncodingConfig {
std.RegisterLegacyAminoCodec(encodingConfig.Amino)
std.RegisterInterfaces(encodingConfig.InterfaceRegistry)

ModuleBasics.RegisterLegacyAminoCodec(encodingConfig.Amino)
ModuleBasics.RegisterInterfaces(encodingConfig.InterfaceRegistry)

return encodingConfig
}
90 changes: 66 additions & 24 deletions app/export.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"encoding/json"
"log"

tmproto "github.com/cometbft/cometbft/proto/tendermint/types"
storetypes "cosmossdk.io/store/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"
Expand All @@ -16,7 +16,7 @@ import (
// file.
func (app *App) ExportAppStateAndValidators(forZeroHeight bool, jailAllowedAddrs, 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)
vishal-kanna marked this conversation as resolved.
Show resolved Hide resolved

// We export at last height + 1, because that's the height at which
// Tendermint will start InitChain.
Expand All @@ -26,7 +26,10 @@ func (app *App) ExportAppStateAndValidators(forZeroHeight bool, jailAllowedAddrs
app.prepForZeroHeightGenesis(ctx, jailAllowedAddrs)
}

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

appState, err := json.MarshalIndent(genState, "", " ")
if err != nil {
Expand Down Expand Up @@ -73,18 +76,24 @@ func (app *App) prepForZeroHeightGenesis(ctx sdk.Context, jailAllowedAddrs []str
/* Handle fee distribution state. */

// withdraw all validator commission
app.StakingKeeper.IterateValidators(ctx, func(_ int64, val stakingtypes.ValidatorI) (stop bool) {
_, err := app.DistrKeeper.WithdrawValidatorCommission(ctx, val.GetOperator())
err := app.StakingKeeper.IterateValidators(ctx, func(_ int64, val stakingtypes.ValidatorI) (stop bool) {
_, err := app.DistrKeeper.WithdrawValidatorCommission(ctx, sdk.ValAddress(val.GetOperator()))
if err != nil {
panic(err)
}
return false
})
if err != nil {
panic(err)
}

// withdraw all delegator rewards
dels := app.StakingKeeper.GetAllDelegations(ctx)
dels, err := app.StakingKeeper.GetAllDelegations(ctx)
if err != nil {
panic(err)
}
for _, delegation := range dels {
_, err := app.DistrKeeper.WithdrawDelegationRewards(ctx, delegation.GetDelegatorAddr(), delegation.GetValidatorAddr())
_, err := app.DistrKeeper.WithdrawDelegationRewards(ctx, sdk.AccAddress(delegation.GetDelegatorAddr()), sdk.ValAddress(delegation.GetValidatorAddr()))
if err != nil {
panic(err)
}
Expand All @@ -101,27 +110,39 @@ func (app *App) prepForZeroHeightGenesis(ctx sdk.Context, jailAllowedAddrs []str
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) {
// 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, sdk.ValAddress(val.GetOperator()))
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)
err = app.DistrKeeper.FeePool.Set(ctx, feePool)
if err != nil {
panic(err)
}

if err := app.DistrKeeper.Hooks().AfterValidatorCreated(ctx, val.GetOperator()); err != nil {
if err := app.DistrKeeper.Hooks().AfterValidatorCreated(ctx, sdk.ValAddress(val.GetOperator())); err != nil {
panic(err)
}

return false
})
if err != nil {
panic(err)
}

// reinitialize all delegations
for _, del := range dels {
if err := app.DistrKeeper.Hooks().BeforeDelegationCreated(ctx, del.GetDelegatorAddr(), del.GetValidatorAddr()); err != nil {
if err := app.DistrKeeper.Hooks().BeforeDelegationCreated(ctx, sdk.AccAddress(del.GetDelegatorAddr()), sdk.ValAddress(del.GetValidatorAddr())); err != nil {
panic(err)
}

if err := app.DistrKeeper.Hooks().AfterDelegationModified(ctx, del.GetDelegatorAddr(), del.GetValidatorAddr()); err != nil {
if err := app.DistrKeeper.Hooks().AfterDelegationModified(ctx, sdk.AccAddress(del.GetDelegatorAddr()), sdk.ValAddress(del.GetValidatorAddr())); err != nil {
panic(err)
}
}
Expand All @@ -132,33 +153,45 @@ func (app *App) prepForZeroHeightGenesis(ctx sdk.Context, jailAllowedAddrs []str
/* Handle staking state. */

// iterate through redelegations, reset creation height
app.StakingKeeper.IterateRedelegations(ctx, func(_ int64, red stakingtypes.Redelegation) (stop bool) {
err = app.StakingKeeper.IterateRedelegations(ctx, func(_ int64, red stakingtypes.Redelegation) (stop bool) {
for i := range red.Entries {
red.Entries[i].CreationHeight = 0
}
app.StakingKeeper.SetRedelegation(ctx, red)
err = app.StakingKeeper.SetRedelegation(ctx, red)
if err != nil {
panic(err)
}
return false
})
if err != nil {
panic(err)
}

// iterate through unbonding delegations, reset creation height
app.StakingKeeper.IterateUnbondingDelegations(ctx, func(_ int64, ubd stakingtypes.UnbondingDelegation) (stop bool) {
err = app.StakingKeeper.IterateUnbondingDelegations(ctx, func(_ int64, ubd stakingtypes.UnbondingDelegation) (stop bool) {
for i := range ubd.Entries {
ubd.Entries[i].CreationHeight = 0
}
app.StakingKeeper.SetUnbondingDelegation(ctx, ubd)
err = app.StakingKeeper.SetUnbondingDelegation(ctx, ubd)
if err != nil {
panic(err)
}
return false
})
if err != nil {
panic(err)
}

// 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(iter.Key()[1:])
validator, found := app.StakingKeeper.GetValidator(ctx, addr)
if !found {
validator, err := app.StakingKeeper.GetValidator(ctx, addr)
if err != nil {
panic("expected validator, not found")
}

Expand All @@ -167,7 +200,10 @@ func (app *App) prepForZeroHeightGenesis(ctx sdk.Context, jailAllowedAddrs []str
validator.Jailed = true
}

app.StakingKeeper.SetValidator(ctx, validator)
err = app.StakingKeeper.SetValidator(ctx, validator)
if err != nil {
panic(err)
}
counter++
}

Expand All @@ -180,12 +216,18 @@ func (app *App) prepForZeroHeightGenesis(ctx sdk.Context, jailAllowedAddrs []str
/* Handle slashing state. */

// reset start height on signing infos
app.SlashingKeeper.IterateValidatorSigningInfos(
err = app.SlashingKeeper.IterateValidatorSigningInfos(
ctx,
func(addr sdk.ConsAddress, info slashingtypes.ValidatorSigningInfo) (stop bool) {
info.StartHeight = 0
app.SlashingKeeper.SetValidatorSigningInfo(ctx, addr, info)
err = app.SlashingKeeper.SetValidatorSigningInfo(ctx, addr, info)
if err != nil {
panic(err)
}
return false
},
)
if err != nil {
panic(err)
}
}
Loading
Loading