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

module independent #103

Open
wants to merge 79 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
79 commits
Select commit Hold shift + click to select a range
27daa65
split modules
sin3A Jun 20, 2024
c0f6dc2
update proto file
sin3A Jun 20, 2024
28c835c
update simapp
sin3A Jun 21, 2024
c7371ce
update node
sin3A Jun 21, 2024
03e049c
update dependence
sin3A Jun 21, 2024
d6f2277
add junit test
sin3A Jun 26, 2024
ceb7b2c
add slashing junit test
sin3A Jun 27, 2024
054a877
update simapp mod
sin3A Jun 27, 2024
3c640d2
update go mod
sin3A Jun 27, 2024
e6ba840
update simapp mod
sin3A Jun 27, 2024
1002689
update go mod
sin3A Jun 27, 2024
b8ddab1
update node test
sin3A Jul 1, 2024
1f772b8
add file
sin3A Jul 1, 2024
716b8b7
separate modules
sin3A Jul 2, 2024
07b132d
add api
sin3A Jul 2, 2024
9115d13
update cosmos-sdk version
sin3A Jul 2, 2024
fad8db2
update node
sin3A Jul 2, 2024
37e22e1
update idenrity node
sin3A Jul 5, 2024
e6e188b
update go mod
cyilong Jul 5, 2024
2fc74c8
update
sin3A Jul 5, 2024
455266e
Merge branch 'sv/module-independent' of https://github.com/bianjieai/…
sin3A Jul 5, 2024
59438b6
update simapp api
sin3A Jul 8, 2024
0a6305d
update simapp
sin3A Jul 8, 2024
9c7e750
update node upgrade
sin3A Jul 9, 2024
b21710d
update api
sin3A Jul 9, 2024
586a8e9
update simapp
sin3A Jul 9, 2024
bd39030
update node identity
sin3A Jul 9, 2024
a653ae1
update genutil upgrade slashing
sin3A Jul 9, 2024
813edb2
update params
sin3A Jul 9, 2024
ce7bbd0
delete bak file
sin3A Jul 9, 2024
0cce404
add proto script
sin3A Jul 9, 2024
6acdc32
update dependence
sin3A Jun 21, 2024
9cfefe1
add junit test
sin3A Jun 26, 2024
854aaee
add slashing junit test
sin3A Jun 27, 2024
4a29aa8
update go mod
sin3A Jun 27, 2024
e35fdd3
separate modules
sin3A Jul 2, 2024
6b21754
add api
sin3A Jul 2, 2024
bd80eaa
update cosmos-sdk version
sin3A Jul 2, 2024
7c1bd37
update node
sin3A Jul 2, 2024
5dfaba7
update idenrity node
sin3A Jul 5, 2024
cd55497
update go mod
cyilong Jul 5, 2024
6bff400
update simapp api
sin3A Jul 8, 2024
c9a18f9
update node identity upgrade
sin3A Jul 9, 2024
c46ee37
update genutil upgrade slashing
sin3A Jul 9, 2024
b96c053
update params
sin3A Jul 9, 2024
a6290b9
add proto script
sin3A Jul 9, 2024
21c712d
Merge branch 'sv/module-independent' of https://github.com/bianjieai/…
sin3A Jul 15, 2024
c9745cb
update simapp
sin3A Jul 15, 2024
5c05cef
update identity node params upgrade
sin3A Jul 15, 2024
96110b2
update genutil slashing
sin3A Jul 15, 2024
4441ad5
Merge branch 'master' into sv/module-independent
sin3A Jul 16, 2024
ae5f4e4
update upgrade
sin3A Jul 16, 2024
e786a36
clear expired codes
sin3A Jul 16, 2024
936a181
clear expired codes
sin3A Jul 16, 2024
cd8c733
clear codes、update injected
sin3A Jul 16, 2024
100f16a
Merge branch 'sv/module-independent' of https://github.com/bianjieai/…
sin3A Jul 16, 2024
bfc468a
fix HomePath
sin3A Jul 16, 2024
eceb239
update upgrade api
sin3A Jul 16, 2024
9ffd22d
update upgrade test
sin3A Jul 16, 2024
57da399
update genutils
sin3A Jul 22, 2024
08d88a4
update node modules
sin3A Jul 22, 2024
0cfdc43
update slashing node
sin3A Jul 23, 2024
5ee596c
update slashing API
sin3A Jul 23, 2024
5882101
add file update slashing module.proto
sin3A Jul 23, 2024
0822c26
update
sin3A Jul 23, 2024
0aaf460
update
sin3A Jul 24, 2024
cc544d3
update
sin3A Jul 24, 2024
f4802d3
update node module
sin3A Jul 24, 2024
23073a8
update
sin3A Jul 24, 2024
6672f90
update
sin3A Jul 24, 2024
13ed118
update params
sin3A Jul 24, 2024
411c44c
update node
sin3A Jul 24, 2024
9674aa5
update params
sin3A Jul 24, 2024
a42b13b
update upgrade
sin3A Jul 25, 2024
8a6a833
update upgrade init_genesis
sin3A Jul 25, 2024
2fe96dc
refactor code
dreamer-zq Jul 25, 2024
3774a91
fix node_test
sin3A Jul 29, 2024
39af267
fix the issue of not being able to obtain parameters
sin3A Aug 2, 2024
e1cc878
add slashing ConsensusVersion&Migration
sin3A Aug 14, 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
8 changes: 2 additions & 6 deletions modules/upgrade/depinject.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import (
store "github.com/cosmos/cosmos-sdk/store/types"
authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
govtypes "github.com/cosmos/cosmos-sdk/x/gov/types"
upgradekeeper "github.com/cosmos/cosmos-sdk/x/upgrade/keeper"
modulev1 "iritamod.bianjie.ai/api/iritamod/upgrade/module/v1"
"iritamod.bianjie.ai/modules/upgrade/keeper"
)
Expand All @@ -29,7 +28,6 @@ func (am AppModule) IsAppModule() {}

type UpgradeInputs struct {
depinject.In
//upgrade.UpgradeInputs
Key *store.KVStoreKey
Cdc codec.Codec
}
Expand All @@ -43,10 +41,8 @@ type UpgradeOutputs struct {
func ProvideModule(in UpgradeInputs) UpgradeOutputs {
skipUpgradeHeights := make(map[int64]bool)
authority := authtypes.NewModuleAddress(govtypes.ModuleName)
cosmosupgradekeeper := upgradekeeper.NewKeeper(skipUpgradeHeights, in.Key, in.Cdc, "/", nil, authority.String())
keeper := keeper.NewKeeper(
cosmosupgradekeeper,
)
//cosmosupgradekeeper := upgradekeeper.NewKeeper(skipUpgradeHeights, in.Key, in.Cdc, "/", nil, authority.String())
keeper := keeper.NewKeeper(skipUpgradeHeights, in.Key, in.Cdc, "/", nil, authority.String())
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

authority should support to be injected by user

m := NewAppModule(keeper)
return UpgradeOutputs{UpgradeKeeper: keeper, Module: m}
}
25 changes: 14 additions & 11 deletions modules/upgrade/keeper/keeper.go
Original file line number Diff line number Diff line change
@@ -1,27 +1,30 @@
package keeper

import (
"github.com/cosmos/cosmos-sdk/codec"
storetypes "github.com/cosmos/cosmos-sdk/store/types"
sdk "github.com/cosmos/cosmos-sdk/types"
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
xp "github.com/cosmos/cosmos-sdk/x/upgrade/exported"
upgradekeeper "github.com/cosmos/cosmos-sdk/x/upgrade/keeper"
upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types"

"iritamod.bianjie.ai/modules/upgrade/types"
)

type Keeper struct {
uk *upgradekeeper.Keeper
*upgradekeeper.Keeper
}

func NewKeeper(uk *upgradekeeper.Keeper) Keeper {
func NewKeeper(skipUpgradeHeights map[int64]bool, storeKey storetypes.StoreKey, cdc codec.BinaryCodec, homePath string, vs xp.ProtocolVersionSetter, authority string) Keeper {
return Keeper{
uk: uk,
upgradekeeper.NewKeeper(skipUpgradeHeights, storeKey, cdc, homePath, vs, authority),
}
}

// ScheduleUpgrade schedules an upgrade based on the specified plan.
func (k Keeper) ScheduleUpgrade(ctx sdk.Context, msg *types.MsgUpgradeSoftware) error {
p, has := k.uk.GetUpgradePlan(ctx)
p, has := k.GetUpgradePlan(ctx)
if has {
return sdkerrors.Wrapf(
sdkerrors.ErrInvalidRequest,
Expand All @@ -35,40 +38,40 @@ func (k Keeper) ScheduleUpgrade(ctx sdk.Context, msg *types.MsgUpgradeSoftware)
Height: msg.Height,
Info: msg.Info,
}
return k.uk.ScheduleUpgrade(ctx, plan)
return k.Keeper.ScheduleUpgrade(ctx, plan)
}

// ClearUpgradePlan clears currently schedule upgrade
func (k Keeper) ClearUpgradePlan(ctx sdk.Context) error {
_, has := k.uk.GetUpgradePlan(ctx)
_, has := k.GetUpgradePlan(ctx)
if !has {
return sdkerrors.Wrap(sdkerrors.ErrInvalidRequest, "there is currently no upgrade plan")
}

k.uk.ClearUpgradePlan(ctx)
k.Keeper.ClearUpgradePlan(ctx)
return nil
}

func (k Keeper) UpgradeKeeper() *upgradekeeper.Keeper {
return k.uk
return k.Keeper
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove


// SetUpgradeHandler sets an UpgradeHandler for the upgrade specified by name. This handler will be called when the upgrade
// with this name is applied. In order for an upgrade with the given name to proceed, a handler for this upgrade
// must be set even if it is a no-op function.
func (k *Keeper) SetUpgradeHandler(name string, upgradeHandler upgradetypes.UpgradeHandler) {
k.uk.SetUpgradeHandler(name, upgradeHandler)
k.Keeper.SetUpgradeHandler(name, upgradeHandler)
}

// ReadUpgradeInfoFromDisk returns the name and height of the upgrade
// which is written to disk by the old binary when panic'ing
// if there's an error in reading the info,
// it assumes that the upgrade info is not available
func (k Keeper) ReadUpgradeInfoFromDisk() (upgradetypes.Plan, error) {
return k.uk.ReadUpgradeInfoFromDisk()
return k.Keeper.ReadUpgradeInfoFromDisk()
}

// IsSkipHeight checks if the given height is part of skipUpgradeHeights
func (k Keeper) IsSkipHeight(height int64) bool {
return k.uk.IsSkipHeight(height)
return k.Keeper.IsSkipHeight(height)
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove

13 changes: 13 additions & 0 deletions modules/upgrade/test/keeper_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package test
import (
tmproto "github.com/cometbft/cometbft/proto/tendermint/types"
sdk "github.com/cosmos/cosmos-sdk/types"
sdkupgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types"
"github.com/stretchr/testify/suite"
"iritamod.bianjie.ai/modules/upgrade/keeper"
uktype "iritamod.bianjie.ai/modules/upgrade/types"
Expand Down Expand Up @@ -43,6 +44,18 @@ func (suite *KeeperTestSuite) TestUpgrade() {
}
err := suite.keeper.ScheduleUpgrade(suite.ctx, msg)
suite.NoError(err)
plan, has := suite.keeper.GetUpgradePlan(suite.ctx)
suite.True(has)
suite.Equal(msg.Name, plan.Name)
suite.Equal(msg.Height, plan.Height)
plan, err = suite.keeper.ReadUpgradeInfoFromDisk()
suite.NoError(err)
resp, err := suite.keeper.CurrentPlan(suite.ctx, &sdkupgradetypes.QueryCurrentPlanRequest{})
suite.NoError(err)
suite.NotNil(resp)
suite.Equal(msg.Name, resp.Plan.Name)
suite.Equal(msg.Height, resp.Plan.Height)
err = suite.keeper.ClearUpgradePlan(suite.ctx)
suite.NoError(err)

}
Loading