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: consensus module #12905

Merged
merged 75 commits into from
Oct 5, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
75 commits
Select commit Hold shift + click to select a range
2528498
add consensus-param module
tac0turtle Aug 8, 2022
75fd065
remove exrtas
tac0turtle Aug 9, 2022
f88a482
comment out tests
tac0turtle Aug 11, 2022
99a1476
setup legacy app
tac0turtle Aug 11, 2022
bd70956
feat: minor improvements to pr (#13031)
JeancarloBarrios Aug 29, 2022
f6cac85
add migrations
JeancarloBarrios Aug 30, 2022
94390b3
empty struct
JeancarloBarrios Aug 31, 2022
fffd4db
commented depinject code
JeancarloBarrios Sep 2, 2022
6f55f8b
change proto to not recieve version and finish migration and migratio…
JeancarloBarrios Sep 3, 2022
97d19f1
add keeper base test
JeancarloBarrios Sep 3, 2022
dada35d
add keeper and update msg test
JeancarloBarrios Sep 4, 2022
fdc9922
add query test
JeancarloBarrios Sep 4, 2022
e58a116
Merge branch 'main' into marko/consensus_param
tac0turtle Sep 5, 2022
95a89e5
Merge branch 'main' into marko/consensus_param
tac0turtle Sep 5, 2022
269f664
lint
tac0turtle Sep 5, 2022
8f2a66a
set param store
tac0turtle Sep 5, 2022
67e9291
Merge branch 'main' into marko/consensus_param
tac0turtle Sep 6, 2022
09e0ab8
fix issues
tac0turtle Sep 6, 2022
09a72c6
fix somethings and get blocked by depinject
tac0turtle Sep 6, 2022
163c7f5
rename module to consensus
tac0turtle Sep 6, 2022
76d7f87
rename module to consensus++
tac0turtle Sep 6, 2022
7969d86
fix imports
tac0turtle Sep 6, 2022
26ee3f8
re-generate protos and update `app.go`
julienrbrt Sep 6, 2022
ccc6cfc
`make lint-fix`
julienrbrt Sep 6, 2022
6ff7c3f
wire x/consensus
julienrbrt Sep 6, 2022
5251ed4
wire consesnsus param
tac0turtle Sep 6, 2022
a51e73c
wire in baseapp
tac0turtle Sep 6, 2022
65b27ec
minor fix
tac0turtle Sep 6, 2022
5870cd7
remove unnecessary uses of reflection in NewAnteHandler
aaronc Sep 6, 2022
ab5b29d
setup tests
tac0turtle Sep 6, 2022
a9e3e2b
fix tests
tac0turtle Sep 6, 2022
9cf54fd
Merge branch 'main' into marko/consensus_param
tac0turtle Sep 6, 2022
3a109bb
fix tests++
tac0turtle Sep 6, 2022
00b2f91
tests+++
tac0turtle Sep 6, 2022
3e0611d
tests+++
tac0turtle Sep 6, 2022
3ee0252
fix migration tests
tac0turtle Sep 6, 2022
547b328
lint++
tac0turtle Sep 6, 2022
5d50a04
Merge branch 'main' into marko/consensus_param
tac0turtle Sep 8, 2022
8817805
fix simapp
tac0turtle Sep 8, 2022
c17cdf6
fix simapp
tac0turtle Sep 8, 2022
2269345
Merge branch 'main' into marko/consensus_param
tac0turtle Sep 12, 2022
a3754b7
fix
tac0turtle Sep 12, 2022
27b3988
Merge branch 'main' into marko/consensus_param
tac0turtle Sep 20, 2022
0c5212b
Merge branch 'main' into marko/consensus_param
tac0turtle Sep 20, 2022
9700322
Merge branch 'main' into marko/consensus_param
tac0turtle Sep 23, 2022
6ef2f75
fix some tests
tac0turtle Sep 23, 2022
e65c714
remove staking and return error
tac0turtle Sep 23, 2022
5a5088e
revert order change
tac0turtle Sep 23, 2022
d378fb0
Update baseapp/baseapp.go
tac0turtle Sep 23, 2022
1d3ccca
Merge branch 'main' into marko/consensus_param
tac0turtle Oct 2, 2022
394ff49
lint
alexanderbez Oct 4, 2022
027eccb
Merge branch 'main' into marko/consensus_param
alexanderbez Oct 4, 2022
abd7a03
lint
alexanderbez Oct 4, 2022
182c56c
Merge branch 'marko/consensus_param' of github.com:cosmos/cosmos-sdk …
alexanderbez Oct 4, 2022
571163f
updates
alexanderbez Oct 4, 2022
664c917
updates
alexanderbez Oct 4, 2022
4fc6898
updates
alexanderbez Oct 4, 2022
dc46fbe
updates
alexanderbez Oct 4, 2022
c56e743
updates
alexanderbez Oct 4, 2022
6dba3fa
updates
alexanderbez Oct 4, 2022
8465b82
updates
alexanderbez Oct 4, 2022
32c9cc1
updates
alexanderbez Oct 4, 2022
9303a65
updates
alexanderbez Oct 4, 2022
6f0d36c
updates
alexanderbez Oct 4, 2022
9a84137
updates
alexanderbez Oct 4, 2022
1fd6d1d
updates
alexanderbez Oct 4, 2022
eb982d6
updates
alexanderbez Oct 4, 2022
49abe6d
updates
alexanderbez Oct 4, 2022
c3ff0bd
fix make rosetta-data + run
facundomedica Oct 4, 2022
1bec6a0
Merge branch 'marko/consensus_param' of https://github.com/cosmos/cos…
facundomedica Oct 4, 2022
0afe8fc
Merge branch 'main' into marko/consensus_param
alexanderbez Oct 5, 2022
cbd7078
Merge branch 'main' into marko/consensus_param
tac0turtle Oct 5, 2022
f236fc2
add upgrade and changelog entry
tac0turtle Oct 5, 2022
ecf490f
updates
alexanderbez Oct 5, 2022
a339f8f
updates
alexanderbez Oct 5, 2022
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
Prev Previous commit
Next Next commit
setup legacy app
  • Loading branch information
tac0turtle committed Aug 11, 2022
commit 99a14764a8d1b93bc38a2eb6c0ce4e704c357582
18 changes: 9 additions & 9 deletions baseapp/baseapp.go
Original file line number Diff line number Diff line change
Expand Up @@ -426,14 +426,7 @@ func (app *BaseApp) GetConsensusParams(ctx sdk.Context) *tmproto.ConsensusParams
panic(err)
}

return &cp
}

// AddRunTxRecoveryHandler adds custom app.runTx method panic handlers.
func (app *BaseApp) AddRunTxRecoveryHandler(handlers ...RecoveryHandler) {
for _, h := range handlers {
app.runTxRecoveryMiddleware = newRecoveryMiddleware(h, app.runTxRecoveryMiddleware)
}
return cp
}

// StoreConsensusParams sets the consensus parameters to the baseapp's param store.
Expand All @@ -446,11 +439,18 @@ func (app *BaseApp) StoreConsensusParams(ctx sdk.Context, cp *tmproto.ConsensusP
return
}

app.paramStore.Set(ctx, *cp)
app.paramStore.Set(ctx, cp)
tac0turtle marked this conversation as resolved.
Show resolved Hide resolved
// We're explicitly not storing the Tendermint app_version in the param store. It's
// stored instead in the x/upgrade store, with its own bump logic.
}

// AddRunTxRecoveryHandler adds custom app.runTx method panic handlers.
func (app *BaseApp) AddRunTxRecoveryHandler(handlers ...RecoveryHandler) {
alexanderbez marked this conversation as resolved.
Show resolved Hide resolved
for _, h := range handlers {
app.runTxRecoveryMiddleware = newRecoveryMiddleware(h, app.runTxRecoveryMiddleware)
}
}

// getMaximumBlockGas gets the maximum gas from the consensus params. It panics
// if maximum block gas is less than negative one and returns zero if negative
// one.
Expand Down
6 changes: 3 additions & 3 deletions baseapp/params.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (
// ParamStore defines the interface the parameter store used by the BaseApp must
// fulfill.
type ParamStore interface {
Get(ctx sdk.Context) (tmproto.ConsensusParams, error)
Has(ctx sdk.Context, key []byte) bool
Set(ctx sdk.Context, cp tmproto.ConsensusParams)
Get(ctx sdk.Context) (*tmproto.ConsensusParams, error)
alexanderbez marked this conversation as resolved.
Show resolved Hide resolved
Has(ctx sdk.Context) bool
Set(ctx sdk.Context, cp *tmproto.ConsensusParams)
}
9 changes: 7 additions & 2 deletions simapp/app_legacy.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@ import (
"github.com/cosmos/cosmos-sdk/x/capability"
capabilitykeeper "github.com/cosmos/cosmos-sdk/x/capability/keeper"
capabilitytypes "github.com/cosmos/cosmos-sdk/x/capability/types"
consensusparamkeeper "github.com/cosmos/cosmos-sdk/x/consensus_param/keeper"
consensusparamtypes "github.com/cosmos/cosmos-sdk/x/consensus_param/types"
"github.com/cosmos/cosmos-sdk/x/crisis"
crisiskeeper "github.com/cosmos/cosmos-sdk/x/crisis/keeper"
crisistypes "github.com/cosmos/cosmos-sdk/x/crisis/types"
Expand Down Expand Up @@ -184,6 +186,7 @@ type SimApp struct {
FeeGrantKeeper feegrantkeeper.Keeper
GroupKeeper groupkeeper.Keeper
NFTKeeper nftkeeper.Keeper
ConsensusParams consensusparamkeeper.Keeper

// the module manager
ModuleManager *module.Manager
Expand Down Expand Up @@ -228,7 +231,7 @@ func NewSimApp(
keys := sdk.NewKVStoreKeys(
authtypes.StoreKey, banktypes.StoreKey, stakingtypes.StoreKey, crisistypes.StoreKey,
minttypes.StoreKey, distrtypes.StoreKey, slashingtypes.StoreKey,
govtypes.StoreKey, paramstypes.StoreKey, upgradetypes.StoreKey, feegrant.StoreKey,
govtypes.StoreKey, paramstypes.StoreKey, consensusparamtypes.StoreKey, upgradetypes.StoreKey, feegrant.StoreKey,
evidencetypes.StoreKey, capabilitytypes.StoreKey,
authzkeeper.StoreKey, nftkeeper.StoreKey, group.StoreKey,
)
Expand Down Expand Up @@ -256,8 +259,10 @@ func NewSimApp(

app.ParamsKeeper = initParamsKeeper(appCodec, legacyAmino, keys[paramstypes.StoreKey], tkeys[paramstypes.TStoreKey])

app.ConsensusParams = consensusparamkeeper.NewKeeper(appCodec, keys[upgradetypes.StoreKey], authtypes.NewModuleAddress(govtypes.ModuleName).String())

// set the BaseApp's parameter store
bApp.SetParamStore(app.ParamsKeeper.Subspace(baseapp.Paramspace).WithKeyTable(paramstypes.ConsensusParamsKeyTable()))
bApp.SetParamStore(&app.ConsensusParams)

app.CapabilityKeeper = capabilitykeeper.NewKeeper(appCodec, keys[capabilitytypes.StoreKey], memKeys[capabilitytypes.MemStoreKey])
// Applications that wish to enforce statically created ScopedKeepers should call `Seal` after creating
Expand Down
6 changes: 3 additions & 3 deletions x/consensus_param/exported/exported.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
// ProtocolVersionSetter defines the interface fulfilled by BaseApp
// which allows setting it's appVersion field.
type ConsensusParamSetter interface {
Get(ctx sdk.Context, key []byte) (tmproto.ConsensusParams, error)
Has(ctx sdk.Context, key []byte) bool
Set(ctx sdk.Context, cp tmproto.ConsensusParams)
Get(ctx sdk.Context) (*tmproto.ConsensusParams, error)
Has(ctx sdk.Context) bool
Set(ctx sdk.Context, cp *tmproto.ConsensusParams)
}
4 changes: 0 additions & 4 deletions x/consensus_param/keeper/grpc_query.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,6 @@ func NewQuerier(keeper Keeper) Querier {

// Balance implements the Query/Balance gRPC method
func (k Querier) Params(ctx context.Context, req *types.QueryParamsRequest) (*types.QueryParamsResponse, error) {
if req == nil {
return nil, status.Error(codes.InvalidArgument, "empty request")
}

sdkCtx := sdk.UnwrapSDKContext(ctx)

params, err := k.Keeper.Get(sdkCtx)
Expand Down
27 changes: 10 additions & 17 deletions x/consensus_param/keeper/keeper.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,30 +10,23 @@ import (
"github.com/cosmos/cosmos-sdk/x/consensus_param/types"
)

var _ exported.ConsensusParamSetter = (*Keeper)(nil)

type Keeper struct {
storeKey storetypes.StoreKey
cdc codec.BinaryCodec
paramSetter exported.ConsensusParamSetter
authority string
storeKey storetypes.StoreKey
cdc codec.BinaryCodec

authority string
}

func NewKeeper(cdc codec.BinaryCodec, storeKey storetypes.StoreKey, paramSetter exported.ConsensusParamSetter, authority string) Keeper {
func NewKeeper(cdc codec.BinaryCodec, storeKey storetypes.StoreKey, authority string) Keeper {
return Keeper{
storeKey: storeKey,
cdc: cdc,
paramSetter: paramSetter,
authority: authority,
storeKey: storeKey,
cdc: cdc,
authority: authority,
}
}

func (k *Keeper) SetParamSetter(paramSetter exported.ConsensusParamSetter) {
k.paramSetter = paramSetter
}

func (k *Keeper) GetParamSetter() exported.ConsensusParamSetter {
return k.paramSetter
}

func (k *Keeper) GetAuthority() string {
return k.authority
}
Expand Down
15 changes: 1 addition & 14 deletions x/consensus_param/types/params.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,7 @@ import (
tmtypes "github.com/tendermint/tendermint/types"
)

// DefaultDefaultSendEnabled is the value that DefaultSendEnabled will have from DefaultParams().
var DefaultDefaultSendEnabled = true

// NewParams creates a new parameter configuration for the bank module
func NewParams(defaultSendEnabled bool) tmtypes.ConsensusParams {
return tmtypes.ConsensusParams{}
}

// DefaultParams is the default parameter configuration for the bank module
func DefaultParams() tmtypes.ConsensusParams {
return tmtypes.ConsensusParams{}
}

// Validate all bank module parameters
// Validate all module parameters
func Validate(p tmtypes.ConsensusParams) error {
return p.ValidateConsensusParams()

Expand Down