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

refactor: remove consensus messages (backport #21248) #21260

Merged
merged 6 commits into from
Aug 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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 client/v2/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ go 1.22.2

require (
cosmossdk.io/api v0.8.0
cosmossdk.io/core v0.12.1-0.20240812125744-810a542d6bac // main
cosmossdk.io/core v0.12.1-0.20240812141913-3e413243db3c // main
cosmossdk.io/depinject v1.0.0
cosmossdk.io/x/bank v0.0.0-20240226161501-23359a0b6d91
cosmossdk.io/x/gov v0.0.0-20231113122742-912390d5fc4a
Expand Down
4 changes: 2 additions & 2 deletions client/v2/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ cosmossdk.io/api v0.7.3-0.20240802064046-23fac2f1b8ab h1:5S0CQY6mp6iPjgnKu2FnZJ1
cosmossdk.io/api v0.7.3-0.20240802064046-23fac2f1b8ab/go.mod h1:vV3VnJvvK4IWkc1deNEJ1OAL028zw1WPezwKKDAsq60=
cosmossdk.io/collections v0.4.1-0.20240802064046-23fac2f1b8ab h1:E/IWad76v1Nc4Atswaccpt7twJ0VwHkbY94/PhmZfTo=
cosmossdk.io/collections v0.4.1-0.20240802064046-23fac2f1b8ab/go.mod h1:Or+5eVAo1aiS1DnPK90eQykGc59LGBWtqwBoJcxXTmw=
cosmossdk.io/core v0.12.1-0.20240812125744-810a542d6bac h1:OarSQAX1l6NYx67wT3C7NYefir7L79yslaGPGbC0xSQ=
cosmossdk.io/core v0.12.1-0.20240812125744-810a542d6bac/go.mod h1:B8JQN1vmGCPSVFlmRb/22n1T736P4C2qfEsrSKDX1iM=
cosmossdk.io/core v0.12.1-0.20240812141913-3e413243db3c h1:3HChWutRkc2JzI4lK/qMPy3GqdZJvIc0ipSjyZj2YVk=
cosmossdk.io/core v0.12.1-0.20240812141913-3e413243db3c/go.mod h1:B8JQN1vmGCPSVFlmRb/22n1T736P4C2qfEsrSKDX1iM=
cosmossdk.io/core/testing v0.0.0-20240812125744-810a542d6bac h1:yYdIcQunz76r68hO8mMYFdX0OeLYjpDJkDuHHTP17eg=
cosmossdk.io/core/testing v0.0.0-20240812125744-810a542d6bac/go.mod h1:xYAL/SdJh9dZ4pABL9OlLTCdgoEyPyOwTqsEEpLuQcE=
cosmossdk.io/depinject v1.0.0 h1:dQaTu6+O6askNXO06+jyeUAnF2/ssKwrrszP9t5q050=
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ require (
buf.build/gen/go/cometbft/cometbft/protocolbuffers/go v1.34.2-20240701160653-fedbb9acfd2f.2 // indirect
cosmossdk.io/api v0.8.0 // main
cosmossdk.io/collections v0.4.1-0.20240802064046-23fac2f1b8ab // main
cosmossdk.io/core v0.12.1-0.20240812125744-810a542d6bac // main
cosmossdk.io/core v0.12.1-0.20240812141913-3e413243db3c // main
cosmossdk.io/core/testing v0.0.0-20240812125744-810a542d6bac // main
cosmossdk.io/depinject v1.0.0
cosmossdk.io/errors v1.0.1
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ cosmossdk.io/api v0.7.3-0.20240812125744-810a542d6bac h1:TvvAEjryi2iSWuka3b8M+Hy
cosmossdk.io/api v0.7.3-0.20240812125744-810a542d6bac/go.mod h1:z29b2nbMKeQShTpFKtSSKcmcbHb4Jwgr7mxG162fu9U=
cosmossdk.io/collections v0.4.1-0.20240802064046-23fac2f1b8ab h1:E/IWad76v1Nc4Atswaccpt7twJ0VwHkbY94/PhmZfTo=
cosmossdk.io/collections v0.4.1-0.20240802064046-23fac2f1b8ab/go.mod h1:Or+5eVAo1aiS1DnPK90eQykGc59LGBWtqwBoJcxXTmw=
cosmossdk.io/core v0.12.1-0.20240812125744-810a542d6bac h1:OarSQAX1l6NYx67wT3C7NYefir7L79yslaGPGbC0xSQ=
cosmossdk.io/core v0.12.1-0.20240812125744-810a542d6bac/go.mod h1:B8JQN1vmGCPSVFlmRb/22n1T736P4C2qfEsrSKDX1iM=
cosmossdk.io/core v0.12.1-0.20240812141913-3e413243db3c h1:3HChWutRkc2JzI4lK/qMPy3GqdZJvIc0ipSjyZj2YVk=
cosmossdk.io/core v0.12.1-0.20240812141913-3e413243db3c/go.mod h1:B8JQN1vmGCPSVFlmRb/22n1T736P4C2qfEsrSKDX1iM=
cosmossdk.io/core/testing v0.0.0-20240812125744-810a542d6bac h1:yYdIcQunz76r68hO8mMYFdX0OeLYjpDJkDuHHTP17eg=
cosmossdk.io/core/testing v0.0.0-20240812125744-810a542d6bac/go.mod h1:xYAL/SdJh9dZ4pABL9OlLTCdgoEyPyOwTqsEEpLuQcE=
cosmossdk.io/depinject v1.0.0 h1:dQaTu6+O6askNXO06+jyeUAnF2/ssKwrrszP9t5q050=
Expand Down
42 changes: 28 additions & 14 deletions server/v2/cometbft/abci.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import (

coreappmgr "cosmossdk.io/core/app"
"cosmossdk.io/core/comet"
corecontext "cosmossdk.io/core/context"
"cosmossdk.io/core/event"
"cosmossdk.io/core/store"
"cosmossdk.io/core/transaction"
Expand Down Expand Up @@ -152,10 +153,23 @@ func (c *Consensus[T]) Info(ctx context.Context, _ *abciproto.InfoRequest) (*abc
return nil, err
}

// cp, err := c.GetConsensusParams(ctx)
// if err != nil {
// return nil, err
// }
// if height is 0, we dont know the consensus params
var appVersion uint64 = 0
if version > 0 {
cp, err := c.GetConsensusParams(ctx)
// if the consensus params are not found, we set the app version to 0
// in the case that the start version is > 0
if cp == nil || errors.Is(err, errors.New("collections: not found")) {
appVersion = 0
} else if err != nil {
return nil, err
} else {
appVersion = cp.Version.GetApp()
}
if err != nil {
return nil, err
}
}

cid, err := c.store.LastCommitID()
if err != nil {
Expand All @@ -165,7 +179,7 @@ func (c *Consensus[T]) Info(ctx context.Context, _ *abciproto.InfoRequest) (*abc
return &abciproto.InfoResponse{
Data: c.appName,
Version: c.version,
AppVersion: 0, // TODO fetch consensus params?
AppVersion: appVersion,
LastBlockHeight: int64(version),
LastBlockAppHash: cid.Hash,
}, nil
Expand Down Expand Up @@ -234,14 +248,15 @@ func (c *Consensus[T]) InitChain(ctx context.Context, req *abciproto.InitChainRe
c.initialHeight = 1
}

var consMessages []transaction.Msg
if req.ConsensusParams != nil {
consMessages = append(consMessages, &consensustypes.MsgUpdateParams{
ctx = context.WithValue(ctx, corecontext.InitInfoKey, &consensustypes.MsgUpdateParams{
Authority: c.consensusAuthority,
Block: req.ConsensusParams.Block,
Evidence: req.ConsensusParams.Evidence,
Validator: req.ConsensusParams.Validator,
Abci: req.ConsensusParams.Abci,
Synchrony: req.ConsensusParams.Synchrony,
Feature: req.ConsensusParams.Feature,
})
}

Expand All @@ -254,13 +269,12 @@ func (c *Consensus[T]) InitChain(ctx context.Context, req *abciproto.InitChainRe
bz := sha256.Sum256([]byte{})

br := &coreappmgr.BlockRequest[T]{
Height: uint64(req.InitialHeight - 1),
Time: req.Time,
Hash: bz[:],
AppHash: ci.Hash,
ChainId: req.ChainId,
ConsensusMessages: consMessages,
IsGenesis: true,
Height: uint64(req.InitialHeight - 1),
Time: req.Time,
Hash: bz[:],
AppHash: ci.Hash,
ChainId: req.ChainId,
IsGenesis: true,
}

blockresponse, genesisState, err := c.app.InitGenesis(
Expand Down
4 changes: 2 additions & 2 deletions server/v2/cometbft/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,14 +43,14 @@ type CfgOption func(*Config)
// OverwriteDefaultConfigTomlConfig overwrites the default comet config with the new config.
func OverwriteDefaultConfigTomlConfig(newCfg *cmtcfg.Config) CfgOption {
return func(cfg *Config) {
cfg.ConfigTomlConfig = newCfg // nolint:ineffassign,staticcheck // We want to overwrite everything
cfg.ConfigTomlConfig = newCfg
}
}

// OverwriteDefaultAppTomlConfig overwrites the default comet config with the new config.
func OverwriteDefaultAppTomlConfig(newCfg *AppTomlConfig) CfgOption {
return func(cfg *Config) {
cfg.AppTomlConfig = newCfg // nolint:ineffassign,staticcheck // We want to overwrite everything
cfg.AppTomlConfig = newCfg
}
}

Expand Down
2 changes: 1 addition & 1 deletion server/v2/cometbft/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ replace (
require (
buf.build/gen/go/cometbft/cometbft/protocolbuffers/go v1.34.2-20240701160653-fedbb9acfd2f.2
cosmossdk.io/api v0.8.0
cosmossdk.io/core v0.12.1-0.20240812125744-810a542d6bac // main
cosmossdk.io/core v0.12.1-0.20240812141913-3e413243db3c // main
cosmossdk.io/errors v1.0.1
cosmossdk.io/log v1.4.0
cosmossdk.io/server/v2 v2.0.0-20240802142126-a26970e547ab // main
Expand Down
4 changes: 2 additions & 2 deletions server/v2/cometbft/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ cosmossdk.io/api v0.7.3-0.20240802064046-23fac2f1b8ab h1:5S0CQY6mp6iPjgnKu2FnZJ1
cosmossdk.io/api v0.7.3-0.20240802064046-23fac2f1b8ab/go.mod h1:vV3VnJvvK4IWkc1deNEJ1OAL028zw1WPezwKKDAsq60=
cosmossdk.io/collections v0.4.1-0.20240802064046-23fac2f1b8ab h1:E/IWad76v1Nc4Atswaccpt7twJ0VwHkbY94/PhmZfTo=
cosmossdk.io/collections v0.4.1-0.20240802064046-23fac2f1b8ab/go.mod h1:Or+5eVAo1aiS1DnPK90eQykGc59LGBWtqwBoJcxXTmw=
cosmossdk.io/core v0.12.1-0.20240812125744-810a542d6bac h1:OarSQAX1l6NYx67wT3C7NYefir7L79yslaGPGbC0xSQ=
cosmossdk.io/core v0.12.1-0.20240812125744-810a542d6bac/go.mod h1:B8JQN1vmGCPSVFlmRb/22n1T736P4C2qfEsrSKDX1iM=
cosmossdk.io/core v0.12.1-0.20240812141913-3e413243db3c h1:3HChWutRkc2JzI4lK/qMPy3GqdZJvIc0ipSjyZj2YVk=
cosmossdk.io/core v0.12.1-0.20240812141913-3e413243db3c/go.mod h1:B8JQN1vmGCPSVFlmRb/22n1T736P4C2qfEsrSKDX1iM=
cosmossdk.io/core/testing v0.0.0-20240812125744-810a542d6bac h1:yYdIcQunz76r68hO8mMYFdX0OeLYjpDJkDuHHTP17eg=
cosmossdk.io/core/testing v0.0.0-20240812125744-810a542d6bac/go.mod h1:xYAL/SdJh9dZ4pABL9OlLTCdgoEyPyOwTqsEEpLuQcE=
cosmossdk.io/depinject v1.0.0 h1:dQaTu6+O6askNXO06+jyeUAnF2/ssKwrrszP9t5q050=
Expand Down
25 changes: 20 additions & 5 deletions simapp/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -499,11 +499,26 @@ func NewSimApp(
// properly initialized with tokens from genesis accounts.
// NOTE: The genutils module must also occur after auth so that it can access the params from auth.
genesisModuleOrder := []string{
accounts.ModuleName, authtypes.ModuleName, banktypes.ModuleName,
distrtypes.ModuleName, stakingtypes.ModuleName, slashingtypes.ModuleName, govtypes.ModuleName,
minttypes.ModuleName, genutiltypes.ModuleName, evidencetypes.ModuleName, authz.ModuleName,
feegrant.ModuleName, nft.ModuleName, group.ModuleName, upgradetypes.ModuleName,
vestingtypes.ModuleName, consensusparamtypes.ModuleName, circuittypes.ModuleName, pooltypes.ModuleName,
consensusparamtypes.ModuleName,
accounts.ModuleName,
authtypes.ModuleName,
banktypes.ModuleName,
distrtypes.ModuleName,
stakingtypes.ModuleName,
slashingtypes.ModuleName,
govtypes.ModuleName,
minttypes.ModuleName,
genutiltypes.ModuleName,
evidencetypes.ModuleName,
authz.ModuleName,
feegrant.ModuleName,
nft.ModuleName,
group.ModuleName,
upgradetypes.ModuleName,
vestingtypes.ModuleName,
consensusparamtypes.ModuleName,
circuittypes.ModuleName,
pooltypes.ModuleName,
epochstypes.ModuleName,
}
app.ModuleManager.SetOrderInitGenesis(genesisModuleOrder...)
Expand Down
1 change: 1 addition & 0 deletions simapp/app_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,7 @@ var (
// properly initialized with tokens from genesis accounts.
// NOTE: The genutils module must also occur after auth so that it can access the params from auth.
InitGenesis: []string{
consensustypes.ModuleName,
accounts.ModuleName,
authtypes.ModuleName,
banktypes.ModuleName,
Expand Down
2 changes: 1 addition & 1 deletion simapp/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ require (
cosmossdk.io/api v0.8.0 // main
cosmossdk.io/client/v2 v2.0.0-20230630094428-02b760776860
cosmossdk.io/collections v0.4.1-0.20240802064046-23fac2f1b8ab // main
cosmossdk.io/core v0.12.1-0.20240812125744-810a542d6bac // main
cosmossdk.io/core v0.12.1-0.20240812141913-3e413243db3c // main
cosmossdk.io/core/testing v0.0.0-20240812125744-810a542d6bac // indirect; main
cosmossdk.io/depinject v1.0.0
cosmossdk.io/log v1.4.0
Expand Down
4 changes: 2 additions & 2 deletions simapp/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -196,8 +196,8 @@ cosmossdk.io/api v0.7.3-0.20240802064046-23fac2f1b8ab h1:5S0CQY6mp6iPjgnKu2FnZJ1
cosmossdk.io/api v0.7.3-0.20240802064046-23fac2f1b8ab/go.mod h1:vV3VnJvvK4IWkc1deNEJ1OAL028zw1WPezwKKDAsq60=
cosmossdk.io/collections v0.4.1-0.20240802064046-23fac2f1b8ab h1:E/IWad76v1Nc4Atswaccpt7twJ0VwHkbY94/PhmZfTo=
cosmossdk.io/collections v0.4.1-0.20240802064046-23fac2f1b8ab/go.mod h1:Or+5eVAo1aiS1DnPK90eQykGc59LGBWtqwBoJcxXTmw=
cosmossdk.io/core v0.12.1-0.20240812125744-810a542d6bac h1:OarSQAX1l6NYx67wT3C7NYefir7L79yslaGPGbC0xSQ=
cosmossdk.io/core v0.12.1-0.20240812125744-810a542d6bac/go.mod h1:B8JQN1vmGCPSVFlmRb/22n1T736P4C2qfEsrSKDX1iM=
cosmossdk.io/core v0.12.1-0.20240812141913-3e413243db3c h1:3HChWutRkc2JzI4lK/qMPy3GqdZJvIc0ipSjyZj2YVk=
cosmossdk.io/core v0.12.1-0.20240812141913-3e413243db3c/go.mod h1:B8JQN1vmGCPSVFlmRb/22n1T736P4C2qfEsrSKDX1iM=
cosmossdk.io/core/testing v0.0.0-20240812125744-810a542d6bac h1:yYdIcQunz76r68hO8mMYFdX0OeLYjpDJkDuHHTP17eg=
cosmossdk.io/core/testing v0.0.0-20240812125744-810a542d6bac/go.mod h1:xYAL/SdJh9dZ4pABL9OlLTCdgoEyPyOwTqsEEpLuQcE=
cosmossdk.io/depinject v1.0.0 h1:dQaTu6+O6askNXO06+jyeUAnF2/ssKwrrszP9t5q050=
Expand Down
1 change: 1 addition & 0 deletions simapp/v2/app_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,7 @@ var (
// properly initialized with tokens from genesis accounts.
// NOTE: The genutils module must also occur after auth so that it can access the params from auth.
InitGenesis: []string{
consensustypes.ModuleName,
accounts.ModuleName,
authtypes.ModuleName,
banktypes.ModuleName,
Expand Down
20 changes: 10 additions & 10 deletions simapp/v2/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@ go 1.22.2
require (
cosmossdk.io/api v0.8.0 // main
cosmossdk.io/client/v2 v2.0.0-00010101000000-000000000000
cosmossdk.io/core v0.12.1-0.20240812125744-810a542d6bac // main
cosmossdk.io/core/testing v0.0.0-20240812125744-810a542d6bac // indirect; main
cosmossdk.io/core v0.12.1-0.20240812141913-3e413243db3c // main
cosmossdk.io/core/testing v0.0.0-20240812141913-3e413243db3c // indirect; main
cosmossdk.io/depinject v1.0.0
cosmossdk.io/log v1.4.0
cosmossdk.io/math v1.3.0
cosmossdk.io/runtime/v2 v2.0.0-20240812125744-810a542d6bac // main
cosmossdk.io/server/v2 v2.0.0-20240812125744-810a542d6bac // main
cosmossdk.io/runtime/v2 v2.0.0-20240812141913-3e413243db3c // main
cosmossdk.io/server/v2 v2.0.0-20240812141913-3e413243db3c // main
cosmossdk.io/server/v2/cometbft v0.0.0-00010101000000-000000000000
cosmossdk.io/store/v2 v2.0.0-20240812125744-810a542d6bac // indirect; main
cosmossdk.io/store/v2 v2.0.0-20240812141913-3e413243db3c // indirect; main
cosmossdk.io/tools/confix v0.0.0-00010101000000-000000000000
cosmossdk.io/x/accounts v0.0.0-20240226161501-23359a0b6d91
cosmossdk.io/x/auth v0.0.0-00010101000000-000000000000
Expand Down Expand Up @@ -56,13 +56,13 @@ require (
cosmossdk.io/errors v1.0.1 // indirect
cosmossdk.io/errors/v2 v2.0.0-20240731132947-df72853b3ca5 // indirect
cosmossdk.io/schema v0.1.1 // indirect
cosmossdk.io/server/v2/appmanager v0.0.0-20240812125744-810a542d6bac // indirect; main
cosmossdk.io/server/v2/stf v0.0.0-20240812125744-810a542d6bac // indirect; main
cosmossdk.io/server/v2/appmanager v0.0.0-20240812141913-3e413243db3c // indirect; main
cosmossdk.io/server/v2/stf v0.0.0-20240812141913-3e413243db3c // indirect; main
cosmossdk.io/store v1.1.1-0.20240418092142-896cdf1971bc // indirect; main
cosmossdk.io/x/accounts/defaults/lockup v0.0.0-20240417181816-5e7aae0db1f5 // indirect
cosmossdk.io/x/accounts/defaults/multisig v0.0.0-00010101000000-000000000000 // indirect
cosmossdk.io/x/epochs v0.0.0-20240522060652-a1ae4c3e0337 // indirect
cosmossdk.io/x/tx v0.13.4-0.20240812125744-810a542d6bac // indirect; main
cosmossdk.io/x/tx v0.13.4-0.20240812141913-3e413243db3c // indirect; main
filippo.io/edwards25519 v1.1.0 // indirect
github.com/99designs/go-keychain v0.0.0-20191008050251-8e49817e8af4 // indirect
github.com/99designs/keyring v1.2.2 // indirect
Expand Down Expand Up @@ -249,11 +249,11 @@ require (
// SimApp on main always tests the latest extracted SDK modules importing the sdk
replace (
// pseudo version lower than the latest tag
cosmossdk.io/api => cosmossdk.io/api v0.7.3-0.20240812125744-810a542d6bac // main
cosmossdk.io/api => cosmossdk.io/api v0.7.3-0.20240812141913-3e413243db3c // main
cosmossdk.io/client/v2 => ../../client/v2
cosmossdk.io/server/v2/cometbft => ../../server/v2/cometbft
// pseudo version lower than the latest tag
cosmossdk.io/store => cosmossdk.io/store v1.0.0-rc.0.0.20240812125744-810a542d6bac // main
cosmossdk.io/store => cosmossdk.io/store v1.0.0-rc.0.0.20240812141913-3e413243db3c // main
cosmossdk.io/tools/confix => ../../tools/confix
cosmossdk.io/x/accounts => ../../x/accounts
cosmossdk.io/x/accounts/defaults/lockup => ../../x/accounts/defaults/lockup
Expand Down
Loading
Loading