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

chore: consensus spinout #20010

Merged
merged 22 commits into from
May 3, 2024
Merged
Show file tree
Hide file tree
Changes from 10 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
31 changes: 31 additions & 0 deletions .github/workflows/test.yml
Expand Up @@ -1253,3 +1253,34 @@ jobs:
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
with:
projectBaseDir: x/epochs/

test-x-consensus:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version: "1.22"
check-latest: true
cache: true
cache-dependency-path: x/consensus/go.sum
- uses: technote-space/get-diff-action@v6.1.2
id: git_diff
with:
PATTERNS: |
x/consensus/**/*.go
x/consensus/go.mod
x/consensus/go.sum
- name: tests
if: env.GIT_DIFF
run: |
cd x/consensus
go test -mod=readonly -timeout 30m -coverprofile=coverage.out -covermode=atomic -tags='norace ledger test_ledger_mock' ./...
- name: sonarcloud
if: ${{ env.GIT_DIFF && !github.event.pull_request.draft && env.SONAR_TOKEN != null }}
uses: SonarSource/sonarcloud-github-action@master
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
with:
projectBaseDir: x/consensus/
7 changes: 4 additions & 3 deletions CHANGELOG.md
Expand Up @@ -62,9 +62,9 @@ Every module contains its own CHANGELOG.md. Please refer to the module you are i
### Improvements

* (telemetry) [#19903](https://github.com/cosmos/cosmos-sdk/pull/19903) Conditionally emit metrics based on enablement.
* **Introduction of `Now` Function**: Added a new function called `Now` to the telemetry package. It returns the current system time if telemetry is enabled, or a zero time if telemetry is not enabled.
* **Atomic Global Variable**: Implemented an atomic global variable to manage the state of telemetry's enablement. This ensures thread safety for the telemetry state.
* **Conditional Telemetry Emission**: All telemetry functions have been updated to emit metrics only when telemetry is enabled. They perform a check with `isTelemetryEnabled()` and return early if telemetry is disabled, minimizing unnecessary operations and overhead.
* **Introduction of `Now` Function**: Added a new function called `Now` to the telemetry package. It returns the current system time if telemetry is enabled, or a zero time if telemetry is not enabled.
* **Atomic Global Variable**: Implemented an atomic global variable to manage the state of telemetry's enablement. This ensures thread safety for the telemetry state.
* **Conditional Telemetry Emission**: All telemetry functions have been updated to emit metrics only when telemetry is enabled. They perform a check with `isTelemetryEnabled()` and return early if telemetry is disabled, minimizing unnecessary operations and overhead.
tac0turtle marked this conversation as resolved.
Show resolved Hide resolved
* (types) [#19869](https://github.com/cosmos/cosmos-sdk/pull/19869) Removed `Any` type from `codec/types` and replaced it with an alias for `cosmos/gogoproto/types/any`.
* (server) [#19854](https://github.com/cosmos/cosmos-sdk/pull/19854) Add customizability to start command.
* Add `StartCmdOptions` in `server.AddCommands` instead of `servertypes.ModuleInitFlags`. To set custom flags set them in the `StartCmdOptions` struct on the `AddFlags` field.
Expand Down Expand Up @@ -179,6 +179,7 @@ Every module contains its own CHANGELOG.md. Please refer to the module you are i
* Additionally, to reflect this change, the module manager does not take a codec either.
* (runtime) [#19747](https://github.com/cosmos/cosmos-sdk/pull/19747) `runtime.ValidatorAddressCodec` and `runtime.ConsensusAddressCodec` have been moved to `core`.
* (baseapp) [#19993](https://github.com/cosmos/cosmos-sdk/pull/19993) Indicate pruning with error code "not found" rather than "invalid request".
* (x/consensus) [#20010](https://github.com/cosmos/cosmos-sdk/pull/20010) Move consensus module to be its own go.mod
tac0turtle marked this conversation as resolved.
Show resolved Hide resolved

### Client Breaking Changes

Expand Down
1 change: 1 addition & 0 deletions Dockerfile
Expand Up @@ -39,6 +39,7 @@ COPY x/auth/go.mod x/auth/go.sum ./x/auth/
COPY x/authz/go.mod x/authz/go.sum ./x/authz/
COPY x/bank/go.mod x/bank/go.sum ./x/bank/
COPY x/mint/go.mod x/mint/go.sum ./x/mint/
COPY x/consensus/go.mod x/consensus/go.sum ./x/consensus/
COPY depinject/go.mod depinject/go.sum ./depinject/
RUN go mod download

Expand Down
3 changes: 2 additions & 1 deletion client/v2/go.mod
@@ -1,6 +1,6 @@
module cosmossdk.io/client/v2

go 1.21
go 1.22.2

require (
cosmossdk.io/api v0.7.3
Expand Down Expand Up @@ -180,6 +180,7 @@ replace (
cosmossdk.io/x/accounts => ./../../x/accounts
cosmossdk.io/x/auth => ./../../x/auth
cosmossdk.io/x/bank => ./../../x/bank
cosmossdk.io/x/consensus => ./../../x/consensus
cosmossdk.io/x/distribution => ./../../x/distribution
cosmossdk.io/x/gov => ./../../x/gov
cosmossdk.io/x/mint => ./../../x/mint
Expand Down
1 change: 1 addition & 0 deletions contrib/images/simd-env/Dockerfile
Expand Up @@ -20,6 +20,7 @@ COPY x/auth/go.mod x/auth/go.sum /work/x/auth/
COPY x/authz/go.mod x/authz/go.sum /work/x/authz/
COPY x/bank/go.mod x/bank/go.sum /work/x/bank/
COPY x/mint/go.mod x/mint/go.sum /work/x/mint/
COPY x/consensus/go.mod x/consensus/go.sum /work/x/consensus/
COPY x/accounts/go.mod x/accounts/go.sum /work/x/accounts/
RUN go mod download

Expand Down
5 changes: 3 additions & 2 deletions go.mod
@@ -1,4 +1,4 @@
go 1.21
go 1.22.2

module github.com/cosmos/cosmos-sdk

Expand All @@ -14,6 +14,7 @@ require (
cosmossdk.io/x/accounts v0.0.0-00010101000000-000000000000
cosmossdk.io/x/auth v0.0.0-00010101000000-000000000000
cosmossdk.io/x/bank v0.0.0-00010101000000-000000000000
cosmossdk.io/x/consensus v0.0.0-00010101000000-000000000000
cosmossdk.io/x/staking v0.0.0-00010101000000-000000000000
cosmossdk.io/x/tx v0.13.1
github.com/99designs/keyring v1.2.2
Expand All @@ -31,7 +32,6 @@ require (
github.com/golang/mock v1.6.0
github.com/golang/protobuf v1.5.4
github.com/google/go-cmp v0.6.0
github.com/google/gofuzz v1.2.0
github.com/gorilla/handlers v1.5.2
github.com/gorilla/mux v1.8.1
github.com/grpc-ecosystem/go-grpc-middleware v1.4.0
Expand Down Expand Up @@ -186,6 +186,7 @@ replace (
cosmossdk.io/x/accounts => ./x/accounts
cosmossdk.io/x/auth => ./x/auth
cosmossdk.io/x/bank => ./x/bank
cosmossdk.io/x/consensus => ./x/consensus
cosmossdk.io/x/staking => ./x/staking
)

Expand Down
2 changes: 1 addition & 1 deletion proto/cosmos/consensus/v1/consensus.proto
Expand Up @@ -4,7 +4,7 @@

import "tendermint/types/params.proto";

option go_package = "github.com/cosmos/cosmos-sdk/x/consensus/types";
option go_package = "cosmossdk.io/x/consensus/types";

Check failure on line 7 in proto/cosmos/consensus/v1/consensus.proto

View workflow job for this annotation

GitHub Actions / break-check

File option "go_package" changed from "github.com/cosmos/cosmos-sdk/x/consensus/types" to "cosmossdk.io/x/consensus/types".

// ConsensusMsgParams is the Msg/Params request type. This is a consensus message that is sent from cometbft.
message ConsensusMsgParams {
Expand Down
6 changes: 3 additions & 3 deletions simapp/app.go
Expand Up @@ -47,6 +47,9 @@ import (
"cosmossdk.io/x/circuit"
circuitkeeper "cosmossdk.io/x/circuit/keeper"
circuittypes "cosmossdk.io/x/circuit/types"
"cosmossdk.io/x/consensus"
consensusparamkeeper "cosmossdk.io/x/consensus/keeper"
consensusparamtypes "cosmossdk.io/x/consensus/types"
distr "cosmossdk.io/x/distribution"
distrkeeper "cosmossdk.io/x/distribution/keeper"
distrtypes "cosmossdk.io/x/distribution/types"
Expand Down Expand Up @@ -107,9 +110,6 @@ import (
"github.com/cosmos/cosmos-sdk/types/msgservice"
sigtypes "github.com/cosmos/cosmos-sdk/types/tx/signing"
"github.com/cosmos/cosmos-sdk/version"
"github.com/cosmos/cosmos-sdk/x/consensus"
consensusparamkeeper "github.com/cosmos/cosmos-sdk/x/consensus/keeper"
consensusparamtypes "github.com/cosmos/cosmos-sdk/x/consensus/types"
"github.com/cosmos/cosmos-sdk/x/genutil"
genutiltypes "github.com/cosmos/cosmos-sdk/x/genutil/types"
)
Expand Down
5 changes: 2 additions & 3 deletions simapp/app_config.go
Expand Up @@ -31,7 +31,6 @@ import (
vestingmodulev1 "cosmossdk.io/api/cosmos/vesting/module/v1"
"cosmossdk.io/depinject/appconfig"
"cosmossdk.io/x/accounts"
_ "cosmossdk.io/x/accounts" // import for side-effects
_ "cosmossdk.io/x/auth/tx/config" // import for side-effects
authtypes "cosmossdk.io/x/auth/types"
_ "cosmossdk.io/x/auth/vesting" // import for side-effects
Expand All @@ -42,6 +41,8 @@ import (
banktypes "cosmossdk.io/x/bank/types"
_ "cosmossdk.io/x/circuit" // import for side-effects
circuittypes "cosmossdk.io/x/circuit/types"
_ "cosmossdk.io/x/consensus" // import for side-effects
consensustypes "cosmossdk.io/x/consensus/types"
_ "cosmossdk.io/x/distribution" // import for side-effects
distrtypes "cosmossdk.io/x/distribution/types"
_ "cosmossdk.io/x/epochs" // import for side-effects
Expand All @@ -68,8 +69,6 @@ import (
upgradetypes "cosmossdk.io/x/upgrade/types"

"github.com/cosmos/cosmos-sdk/runtime"
_ "github.com/cosmos/cosmos-sdk/x/consensus" // import for side-effects
consensustypes "github.com/cosmos/cosmos-sdk/x/consensus/types"
genutiltypes "github.com/cosmos/cosmos-sdk/x/genutil/types"
)

Expand Down
4 changes: 2 additions & 2 deletions simapp/app_di.go
Expand Up @@ -25,6 +25,7 @@ import (
authzkeeper "cosmossdk.io/x/authz/keeper"
bankkeeper "cosmossdk.io/x/bank/keeper"
circuitkeeper "cosmossdk.io/x/circuit/keeper"
consensuskeeper "cosmossdk.io/x/consensus/keeper"
distrkeeper "cosmossdk.io/x/distribution/keeper"
epochskeeper "cosmossdk.io/x/epochs/keeper"
evidencekeeper "cosmossdk.io/x/evidence/keeper"
Expand All @@ -51,7 +52,6 @@ import (
servertypes "github.com/cosmos/cosmos-sdk/server/types"
testdata_pulsar "github.com/cosmos/cosmos-sdk/testutil/testdata/testpb"
"github.com/cosmos/cosmos-sdk/types/module"
consensuskeeper "github.com/cosmos/cosmos-sdk/x/consensus/keeper"
)

// DefaultNodeHome default home directories for the application daemon
Expand Down Expand Up @@ -306,7 +306,7 @@ func NewSimApp(
return app
}

// overwritte default ante handlers with custom ante handlers
// overwrite default ante handlers with custom ante handlers
// set SkipAnteHandler to true in app config and set custom ante handler on baseapp
func (app *SimApp) setCustomAnteHandler() {
anteHandler, err := NewAnteHandler(
Expand Down
5 changes: 4 additions & 1 deletion simapp/go.mod
@@ -1,6 +1,6 @@
module cosmossdk.io/simapp

go 1.22
go 1.22.2

require (
cosmossdk.io/api v0.7.3
Expand Down Expand Up @@ -45,6 +45,8 @@ require (
google.golang.org/protobuf v1.33.0
)

require cosmossdk.io/x/consensus v0.0.0-00010101000000-000000000000

require (
buf.build/gen/go/cosmos/gogo-proto/protocolbuffers/go v1.32.0-20240130113600-88ef6483f90f.1 // indirect
buf.build/gen/go/tendermint/tendermint/protocolbuffers/go v1.32.0-20231117195010-33ed361a9051.1 // indirect
Expand Down Expand Up @@ -246,6 +248,7 @@ replace (
cosmossdk.io/x/authz => ../x/authz
cosmossdk.io/x/bank => ../x/bank
cosmossdk.io/x/circuit => ../x/circuit
cosmossdk.io/x/consensus => ../x/consensus
cosmossdk.io/x/distribution => ../x/distribution
cosmossdk.io/x/epochs => ../x/epochs
cosmossdk.io/x/evidence => ../x/evidence
Expand Down
1 change: 1 addition & 0 deletions simapp/upgrades.go
Expand Up @@ -8,6 +8,7 @@ import (
epochstypes "cosmossdk.io/x/epochs/types"
protocolpooltypes "cosmossdk.io/x/protocolpool/types"
upgradetypes "cosmossdk.io/x/upgrade/types"

"github.com/cosmos/cosmos-sdk/types/module"
crisistypes "github.com/cosmos/cosmos-sdk/x/crisis/types"
)
Expand Down
6 changes: 3 additions & 3 deletions store/db/db.go
Expand Up @@ -10,9 +10,9 @@ type RawDBType string

const (
DBTypeGoLevelDB RawDBType = "goleveldb"
DBTypeRocksDB = "rocksdb"
DBTypePebbleDB = "pebbledb"
DBTypePrefixDB = "prefixdb"
DBTypeRocksDB RawDBType = "rocksdb"
DBTypePebbleDB RawDBType = "pebbledb"
DBTypePrefixDB RawDBType = "prefixdb"

DBFileSuffix string = ".db"
)
Expand Down
4 changes: 0 additions & 4 deletions store/db/rocksdb_noflag.go
Expand Up @@ -82,7 +82,3 @@ func (itr *rocksDBIterator) Error() error {
func (itr *rocksDBIterator) Close() error {
panic("rocksdb must be built with -tags rocksdb")
}

func (itr *rocksDBIterator) assertIsValid() {
panic("rocksdb must be built with -tags rocksdb")
}
2 changes: 1 addition & 1 deletion tests/e2e/baseapp/utils.go
Expand Up @@ -13,6 +13,7 @@ import (
authtypes "cosmossdk.io/x/auth/types"
_ "cosmossdk.io/x/bank"
banktypes "cosmossdk.io/x/bank/types"
_ "cosmossdk.io/x/consensus"
_ "cosmossdk.io/x/staking"

"github.com/cosmos/cosmos-sdk/codec"
Expand All @@ -21,7 +22,6 @@ import (
"github.com/cosmos/cosmos-sdk/testutil/mock"
simtestutil "github.com/cosmos/cosmos-sdk/testutil/sims"
sdk "github.com/cosmos/cosmos-sdk/types"
_ "github.com/cosmos/cosmos-sdk/x/consensus"
)

// GenesisStateWithSingleValidator initializes GenesisState with a single validator and genesis accounts
Expand Down
7 changes: 4 additions & 3 deletions tests/go.mod
@@ -1,8 +1,6 @@
module github.com/cosmos/cosmos-sdk/tests

go 1.22

toolchain go1.22.0
go 1.22.2

require (
cosmossdk.io/api v0.7.3
Expand Down Expand Up @@ -40,13 +38,15 @@ require (
cosmossdk.io/x/auth v0.0.0-20240226161501-23359a0b6d91
cosmossdk.io/x/authz v0.0.0-00010101000000-000000000000
cosmossdk.io/x/bank v0.0.0-20240226161501-23359a0b6d91
cosmossdk.io/x/consensus v0.0.0-00010101000000-000000000000
cosmossdk.io/x/distribution v0.0.0-20240227221813-a248d05f70f4
cosmossdk.io/x/gov v0.0.0-20231113122742-912390d5fc4a
cosmossdk.io/x/group v0.0.0-00010101000000-000000000000
cosmossdk.io/x/mint v0.0.0-00010101000000-000000000000
cosmossdk.io/x/slashing v0.0.0-00010101000000-000000000000
cosmossdk.io/x/staking v0.0.0-20240226161501-23359a0b6d91
github.com/google/go-cmp v0.6.0
github.com/google/gofuzz v1.2.0
github.com/jhump/protoreflect v1.15.6
)

Expand Down Expand Up @@ -242,6 +242,7 @@ replace (
cosmossdk.io/x/authz => ../x/authz
cosmossdk.io/x/bank => ../x/bank
cosmossdk.io/x/circuit => ../x/circuit
cosmossdk.io/x/consensus => ../x/consensus
cosmossdk.io/x/distribution => ../x/distribution
cosmossdk.io/x/epochs => ../x/epochs
cosmossdk.io/x/evidence => ../x/evidence
Expand Down
20 changes: 9 additions & 11 deletions tests/integration/auth/keeper/msg_server_test.go
Expand Up @@ -17,10 +17,8 @@ import (
"cosmossdk.io/x/auth"
authkeeper "cosmossdk.io/x/auth/keeper"
authsims "cosmossdk.io/x/auth/simulation"
"cosmossdk.io/x/auth/types"
authtypes "cosmossdk.io/x/auth/types"
"cosmossdk.io/x/bank"
"cosmossdk.io/x/bank/keeper"
bankkeeper "cosmossdk.io/x/bank/keeper"
"cosmossdk.io/x/bank/testutil"
banktypes "cosmossdk.io/x/bank/types"
Expand Down Expand Up @@ -109,7 +107,7 @@ func initFixture(t *testing.T) *fixture {
blockedAddresses := map[string]bool{
authKeeper.GetAuthority(): false,
}
bankKeeper := keeper.NewBaseKeeper(
bankKeeper := bankkeeper.NewBaseKeeper(
runtime.NewEnvironment(runtime.NewKVStoreService(keys[banktypes.StoreKey]), log.NewNopLogger()),
cdc,
authKeeper,
Expand Down Expand Up @@ -187,13 +185,13 @@ func TestAsyncExec(t *testing.T) {

testCases := []struct {
name string
req *types.MsgNonAtomicExec
req *authtypes.MsgNonAtomicExec
expectErr bool
expErrMsg string
}{
{
name: "empty signer address",
req: &types.MsgNonAtomicExec{
req: &authtypes.MsgNonAtomicExec{
Signer: "",
Msgs: []*codectypes.Any{},
},
Expand All @@ -202,7 +200,7 @@ func TestAsyncExec(t *testing.T) {
},
{
name: "invalid signer address",
req: &types.MsgNonAtomicExec{
req: &authtypes.MsgNonAtomicExec{
Signer: "invalid",
Msgs: []*codectypes.Any{},
},
Expand All @@ -211,7 +209,7 @@ func TestAsyncExec(t *testing.T) {
},
{
name: "empty msgs",
req: &types.MsgNonAtomicExec{
req: &authtypes.MsgNonAtomicExec{
Signer: addrs[0].String(),
Msgs: []*codectypes.Any{},
},
Expand All @@ -220,23 +218,23 @@ func TestAsyncExec(t *testing.T) {
},
{
name: "valid msg",
req: &types.MsgNonAtomicExec{
req: &authtypes.MsgNonAtomicExec{
Signer: addrs[0].String(),
Msgs: []*codectypes.Any{msgAny},
},
expectErr: false,
},
{
name: "multiple messages being executed",
req: &types.MsgNonAtomicExec{
req: &authtypes.MsgNonAtomicExec{
Signer: addrs[0].String(),
Msgs: []*codectypes.Any{msgAny, msgAny},
},
expectErr: false,
},
{
name: "multiple messages with different signers",
req: &types.MsgNonAtomicExec{
req: &authtypes.MsgNonAtomicExec{
Signer: addrs[0].String(),
Msgs: []*codectypes.Any{msgAny, msgAny2},
},
Expand All @@ -245,7 +243,7 @@ func TestAsyncExec(t *testing.T) {
},
{
name: "multi msg with one failing being executed",
req: &types.MsgNonAtomicExec{
req: &authtypes.MsgNonAtomicExec{
Signer: addrs[0].String(),
Msgs: []*codectypes.Any{msgAny, failingMsgAny},
},
Expand Down