diff --git a/.github/.codespellignore b/.github/.codespellignore index e1e8758d0c30..4ac943d563d4 100644 --- a/.github/.codespellignore +++ b/.github/.codespellignore @@ -4,4 +4,5 @@ keypair pastTime hasTables Nam -EyT \ No newline at end of file +EyT +upTo \ No newline at end of file diff --git a/.github/dependabot.yml b/.github/dependabot.yml index 7af739bbcf30..98ae0c266d5c 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -356,3 +356,23 @@ updates: # cometbft 0.38 is not semver, but we want to only update "patch" versions for 0.38.x update-types: ["version-update:semver-major", "version-update:semver-minor"] + + - package-ecosystem: gomod + directory: "/" + target-branch: "release/v0.52.x" + schedule: + interval: daily + time: "03:00" + labels: + - "A:automerge" + - dependencies + - "testing-required" + allow: + - dependency-name: "github.com/cosmos/cosmos-sdk/*" + dependency-type: "all" + - dependency-name: "github.com/cosmos/*" + dependency-type: "all" + - dependency-name: "cosmossdk.io/*" + dependency-type: "all" + - dependency-name: "github.com/cometbft/*" + dependency-type: "all" diff --git a/.github/workflows/misspell.yml b/.github/workflows/misspell.yml index f524e88b2cb8..e4cff28364c1 100644 --- a/.github/workflows/misspell.yml +++ b/.github/workflows/misspell.yml @@ -15,7 +15,7 @@ jobs: continue-on-error: true run: | sudo apt-get install codespell -y - codespell -w --skip="*.pulsar.go,*.pb.go,*.pb.gw.go,*.cosmos_orm.go,*.json,*.git,*.js,crypto/keys,fuzz,*.h,proto/tendermint,*.bin" --ignore-words=.github/.codespellignore + codespell -w --skip="*.pulsar.go,*.pb.go,*.pb.gw.go,*.cosmos_orm.go,*.json,*.git,*.js,crypto/keys,fuzz,*.h,proto/tendermint,*.bin,go.sum,go.mod" --ignore-words=.github/.codespellignore - uses: peter-evans/create-pull-request@v6 if: github.event_name != 'pull_request' with: diff --git a/.github/workflows/proto.yml b/.github/workflows/proto.yml index 998b9ac993b1..d11a355bc546 100644 --- a/.github/workflows/proto.yml +++ b/.github/workflows/proto.yml @@ -15,7 +15,7 @@ jobs: timeout-minutes: 5 steps: - uses: actions/checkout@v4 - - uses: bufbuild/buf-setup-action@v1.34.0 + - uses: bufbuild/buf-setup-action@v1.35.1 - uses: bufbuild/buf-lint-action@v1 with: input: "proto" @@ -24,7 +24,7 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - - uses: bufbuild/buf-setup-action@v1.34.0 + - uses: bufbuild/buf-setup-action@v1.35.1 - uses: bufbuild/buf-breaking-action@v1 with: input: "proto" diff --git a/.github/workflows/sims-052.yml b/.github/workflows/sims-052.yml new file mode 100644 index 000000000000..b64d6332b76f --- /dev/null +++ b/.github/workflows/sims-052.yml @@ -0,0 +1,136 @@ +name: Sims release/0.52.x +# Sims workflow runs multiple types of simulations (nondeterminism, import-export, after-import, multi-seed-short) +# This workflow will run on all Pull Requests, if a .go, .mod or .sum file have been changed +on: + schedule: + - cron: "0 0,12 * * *" + release: + types: [published] + +concurrency: + group: ci-${{ github.ref }}-sims-052 + cancel-in-progress: true + +jobs: + build: + permissions: + contents: read # for actions/checkout to fetch code + runs-on: large-sdk-runner + if: "!contains(github.event.head_commit.message, 'skip-sims')" + steps: + - uses: actions/checkout@v4 + with: + ref: "release/v0.52.x" + - uses: actions/setup-go@v5 + with: + go-version: "1.22" + check-latest: true + - run: make build + + test-sim-import-export: + runs-on: large-sdk-runner + needs: [build] + timeout-minutes: 60 + steps: + - uses: actions/checkout@v4 + with: + ref: "release/v0.52.x" + - uses: actions/setup-go@v5 + with: + go-version: "1.22" + check-latest: true + - name: test-sim-import-export + run: | + make test-sim-import-export + + test-sim-after-import: + runs-on: large-sdk-runner + needs: [build] + timeout-minutes: 60 + steps: + - uses: actions/checkout@v4 + with: + ref: "release/v0.52.x" + - uses: actions/setup-go@v5 + with: + go-version: "1.22" + check-latest: true + - name: test-sim-after-import + run: | + make test-sim-after-import + + test-sim-deterministic: + runs-on: large-sdk-runner + needs: [build] + timeout-minutes: 60 + steps: + - uses: actions/checkout@v4 + with: + ref: "release/v0.52.x" + - uses: actions/setup-go@v5 + with: + go-version: "1.22" + check-latest: true + - name: test-sim-nondeterminism-streaming + run: | + make test-sim-nondeterminism-streaming + + test-sim-multi-seed-short: + runs-on: large-sdk-runner + needs: [build] + timeout-minutes: 60 + steps: + - uses: actions/checkout@v4 + with: + ref: "release/v0.52.x" + - uses: actions/setup-go@v5 + with: + go-version: "1.22" + check-latest: true + - name: test-sim-multi-seed-short + run: | + make test-sim-multi-seed-short + + sims-notify-success: + needs: + [test-sim-multi-seed-short, test-sim-after-import, test-sim-import-export] + runs-on: large-sdk-runner + if: ${{ success() }} + steps: + - uses: actions/checkout@v4 + - name: Get previous workflow status + uses: ./.github/actions/last-workflow-status + id: last_status + with: + github_token: ${{ secrets.GITHUB_TOKEN }} + + - name: Notify Slack on success + if: ${{ steps.last_status.outputs.last_status == 'failure' }} + uses: rtCamp/action-slack-notify@v2.3.0 + env: + SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }} + SLACK_CHANNEL: sdk-sims + SLACK_USERNAME: Sim Tests release/0.52.x + SLACK_ICON_EMOJI: ":white_check_mark:" + SLACK_COLOR: good + SLACK_MESSAGE: 0.52.x Sims are passing + SLACK_FOOTER: "" + + sims-notify-failure: + permissions: + contents: none + needs: + [test-sim-multi-seed-short, test-sim-after-import, test-sim-import-export] + runs-on: large-sdk-runner + if: ${{ failure() }} + steps: + - name: Notify Slack on failure + uses: rtCamp/action-slack-notify@v2.3.0 + env: + SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }} + SLACK_CHANNEL: sdk-sims + SLACK_USERNAME: Sim Tests release/0.52.x + SLACK_ICON_EMOJI: ":skull:" + SLACK_COLOR: danger + SLACK_MESSAGE: 0.52.x Sims are failing + SLACK_FOOTER: "" diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 6eea986e27b7..92c9914c14dc 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -357,14 +357,6 @@ jobs: run: | cd core/testing 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: core/testing/ test-depinject: runs-on: ubuntu-latest @@ -487,6 +479,36 @@ jobs: with: projectBaseDir: schema/ + test-schema-testing: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-go@v5 + with: + go-version: "1.22" + cache: true + cache-dependency-path: schema/testing/go.sum + - uses: technote-space/get-diff-action@v6.1.2 + id: git_diff + with: + PATTERNS: | + schema/testing/**/*.go + schema/testing/go.mod + schema/testing/go.sum + - name: tests + if: env.GIT_DIFF + run: | + cd schema + go test -mod=readonly -timeout 30m -coverprofile=coverage.out -covermode=atomic ./... + - 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: schema/testing/ + test-indexer-postgres: runs-on: ubuntu-latest steps: @@ -544,7 +566,7 @@ jobs: if: env.GIT_DIFF run: | cd simapp - go test -mod=readonly -timeout 30m -coverprofile=coverage.out -covermode=atomic -tags='norace ledger test_ledger_mock' ./... + go test -mod=readonly -timeout 30m -tags='norace ledger test_ledger_mock' ./... - name: tests simapp v1 if: env.GIT_DIFF run: | @@ -570,10 +592,28 @@ jobs: go.sum **/go.mod **/go.sum + - name: tests simapp + if: env.GIT_DIFF + run: | + cd simapp/v2 + go test -mod=readonly -timeout 30m -tags='norace ledger test_ledger_mock' ./... - name: simapp-v2-smoke-test if: env.GIT_DIFF run: | - ./scripts/simapp-v2-init.sh + COSMOS_BUILD_OPTIONS=v2 make install + ./scripts/init-simapp-v2.sh + simdv2 start & + SIMD_PID=$! + cnt=0 + while ! simdv2 query block --type=height 5; do + cnt=$((cnt + 1)) + if [ $cnt -gt 30 ]; then + kill -9 "$SIMD_PID" + exit 1 + fi + sleep 1 + done + kill -9 "$SIMD_PID" test-collections: runs-on: ubuntu-latest diff --git a/.github/workflows/v2-test.yml b/.github/workflows/v2-test.yml index 7433a47a133e..9bde9c3f39d1 100644 --- a/.github/workflows/v2-test.yml +++ b/.github/workflows/v2-test.yml @@ -1,4 +1,4 @@ -name: v2 core Tests +name: v2 core Tests on: pull_request: merge_group: @@ -37,7 +37,7 @@ jobs: - name: test & coverage report creation if: env.GIT_DIFF run: | - cd server/v2 && go test -mod=readonly -race -timeout 30m -covermode=atomic -tags='ledger test_ledger_mock' + cd server/v2 && go test -mod=readonly -race -timeout 30m -tags='ledger test_ledger_mock' stf: runs-on: ubuntu-latest strategy: @@ -60,9 +60,9 @@ jobs: - name: test & coverage report creation if: env.GIT_DIFF run: | - cd server/v2/stf && go test -mod=readonly -race -timeout 30m -covermode=atomic -tags='ledger test_ledger_mock' - - appamanger: + cd server/v2/stf && go test -mod=readonly -race -timeout 30m -tags='ledger test_ledger_mock' + + appmanager: runs-on: ubuntu-latest strategy: fail-fast: false @@ -84,4 +84,28 @@ jobs: - name: test & coverage report creation if: env.GIT_DIFF run: | - cd server/v2/appmanager && go test -mod=readonly -race -timeout 30m -covermode=atomic -tags='ledger test_ledger_mock' \ No newline at end of file + cd server/v2/appmanager && go test -mod=readonly -race -timeout 30m -tags='ledger test_ledger_mock' + + cometbft: + runs-on: ubuntu-latest + strategy: + fail-fast: false + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-go@v5 + with: + go-version: "1.22" + check-latest: true + cache: true + cache-dependency-path: go.sum + - uses: technote-space/get-diff-action@v6.1.2 + id: git_diff + with: + PATTERNS: | + server/v2/cometbft/**/*.go + server/v2/cometbft/go.mod + server/v2/cometbft/go.sum + - name: test & coverage report creation + if: env.GIT_DIFF + run: | + cd server/v2/cometbft && go test -mod=readonly -race -timeout 30m -tags='ledger test_ledger_mock' diff --git a/.gitignore b/.gitignore index 0fc9f902957a..bc2377793355 100644 --- a/.gitignore +++ b/.gitignore @@ -63,3 +63,4 @@ debug_container.log *.synctex.gz /x/genutil/config/priv_validator_key.json /x/genutil/data/priv_validator_state.json +simapp/simapp.test \ No newline at end of file diff --git a/.mergify.yml b/.mergify.yml index 23eb45476a4b..810131c70c95 100644 --- a/.mergify.yml +++ b/.mergify.yml @@ -16,6 +16,14 @@ pull_request_rules: commit_message_template: | {{ title }} (#{{ number }}) {{ body }} + - name: backport patches to v0.52.x branch + conditions: + - base=main + - label=backport/v0.52.x + actions: + backport: + branches: + - release/v0.52.x - name: backport patches to v0.50.x branch conditions: - base=main diff --git a/.vscode/launch.json b/.vscode/launch.json index d188c4ae2a5f..a5e7a729457b 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -20,6 +20,15 @@ "program": "${workspaceFolder}/simapp/v2/simdv2", "args": ["start"], "buildFlags": "" + }, + { + "name": "Start: simapp/v1", + "type": "go", + "request": "launch", + "mode": "debug", + "program": "${workspaceFolder}/simapp/simd", + "args": ["start"], + "buildFlags": "" } ] } diff --git a/CHANGELOG.md b/CHANGELOG.md index 48ad43d5e0f3..c65b03c49252 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -42,6 +42,7 @@ Every module contains its own CHANGELOG.md. Please refer to the module you are i ### Features +* (baseapp) [#20291](https://github.com/cosmos/cosmos-sdk/pull/20291) Simulate nested messages. * (tests) [#20013](https://github.com/cosmos/cosmos-sdk/pull/20013) Introduce system tests to run multi node local testnet in CI * (runtime) [#19953](https://github.com/cosmos/cosmos-sdk/pull/19953) Implement `core/transaction.Service` in runtime. * (client) [#19905](https://github.com/cosmos/cosmos-sdk/pull/19905) Add grpc client config to `client.toml`. @@ -61,6 +62,7 @@ Every module contains its own CHANGELOG.md. Please refer to the module you are i * (client) [#19870](https://github.com/cosmos/cosmos-sdk/pull/19870) Add new query command `wait-tx`. Alias `event-query-tx-for` to `wait-tx` for backward compatibility. * (crypto/keyring) [#20212](https://github.com/cosmos/cosmos-sdk/pull/20212) Expose the db keyring used in the keystore. * (genutil) [#19971](https://github.com/cosmos/cosmos-sdk/pull/19971) Allow manually setting the consensus key type in genesis +* (client/tx) [#20870](https://github.com/cosmos/cosmos-sdk/pull/20870) Add `timeout-timestamp` field for tx body defines time based timeout.Add `WithTimeoutTimestamp` to tx factory. Increased gas cost for processing newly added timeout timestamp field in tx body. ### Improvements @@ -121,7 +123,7 @@ Every module contains its own CHANGELOG.md. Please refer to the module you are i * (testutil/integration) [#21006](https://github.com/cosmos/cosmos-sdk/pull/21006) Fix `NewIntegrationApp` method not writing default genesis to state ### API Breaking Changes - +* (sims) [#21039](https://github.com/cosmos/cosmos-sdk/pull/21039): Remove Baseapp from sims by a new interface `simtypes.AppEntrypoint` * (client) [#20976](https://github.com/cosmos/cosmos-sdk/pull/20976) Simplified command initialization by removing unnecessary parameters such as `txConfig` and `addressCodec`. * Remove parameter `txConfig` from `genutilcli.Commands`,`genutilcli.CommandsWithCustomMigrationMap`,`genutilcli.GenTxCmd`. * Remove parameter `addressCodec` from `genutilcli.GenTxCmd`,`genutilcli.AddGenesisAccountCmd`,`stakingcli.BuildCreateValidatorMsg`. @@ -200,12 +202,13 @@ Every module contains its own CHANGELOG.md. Please refer to the module you are i ### Client Breaking Changes -* (runtime) [#19040](https://github.com/cosmos/cosmos-sdk/pull/19040) Simplify app config implementation and deprecate `/cosmos/app/v1alpha1/config` query. +* (runtime) [#19040](https://github.com/cosmos/cosmos-sdk/pull/19040) Simplify app config implementation and deprecate `/cosmos/app/v1alpha1/config` query. ### CLI Breaking Changes * (perf)[#20490](https://github.com/cosmos/cosmos-sdk/pull/20490) Sims: Replace runsim command with Go stdlib testing. CLI: `Commit` default true, `Lean`, `SimulateEveryOperation`, `PrintAllInvariants`, `DBBackend` params removed * (server) [#18303](https://github.com/cosmos/cosmos-sdk/pull/18303) `appd export` has moved with other genesis commands, use `appd genesis export` instead. +* (client/tx) [#20870](https://github.com/cosmos/cosmos-sdk/pull/20870) Removed `timeout-height` flag replace with `timeout-timestamp` flag for a time based timeout. ### Deprecated diff --git a/Makefile b/Makefile index bf814eb5f5c7..2e760653bfc9 100644 --- a/Makefile +++ b/Makefile @@ -8,6 +8,8 @@ include scripts/build/testing.mk include scripts/build/documentation.mk include scripts/build/build.mk +.DEFAULT_GOAL := help + ############################################################################### ### Tools & Dependencies ### ############################################################################### diff --git a/UPGRADING.md b/UPGRADING.md index 887fb2a1e454..15d23e784482 100644 --- a/UPGRADING.md +++ b/UPGRADING.md @@ -5,6 +5,39 @@ Note, always read the **SimApp** section for more information on application wir ## [Unreleased] +### BaseApp + +#### Nested Messages Simulation + +Now it is possible to simulate the nested messages of a message, providing developers with a powerful tool for +testing and predicting the behavior of complex transactions. This feature allows for a more comprehensive +evaluation of gas consumption, state changes, and potential errors that may occur when executing nested +messages. However, it's important to note that while the simulation can provide valuable insights, it does not +guarantee the correct execution of the nested messages in the future. Factors such as changes in the +blockchain state or updates to the protocol could potentially affect the actual execution of these nested +messages when the transaction is finally processed on the network. + +For example, consider a governance proposal that includes nested messages to update multiple protocol +parameters. At the time of simulation, the blockchain state may be suitable for executing all these nested +messages successfully. However, by the time the actual governance proposal is executed (which could be days or +weeks later), the blockchain state might have changed significantly. As a result, while the simulation showed +a successful execution, the actual governance proposal might fail when it's finally processed. + +By default, when simulating transactions, the gas cost of nested messages is not calculated. This means that +only the gas cost of the top-level message is considered. However, this behavior can be customized using the +`SetIncludeNestedMsgsGas` option when building the BaseApp. By providing a list of message types to this option, +you can specify which messages should have their nested message gas costs included in the simulation. This +allows for more accurate gas estimation for transactions involving specific message types that contain nested +messages, while maintaining the default behavior for other message types. + +Here is an example on how `SetIncludeNestedMsgsGas` option could be set to calculate the gas of a gov proposal +nested messages: +```go +baseAppOptions = append(baseAppOptions, baseapp.SetIncludeNestedMsgsGas([]sdk.Message{&gov.MsgSubmitProposal{}})) +// ... +app.App = appBuilder.Build(db, traceStore, baseAppOptions...) +``` + ### SimApp In this section we describe the changes made in Cosmos SDK' SimApp. @@ -103,7 +136,7 @@ transactions in your application: anteDecorators := []sdk.AnteDecorator{ ante.NewSetUpContextDecorator(), // ... - ante.NewUnorderedTxDecorator(unorderedtx.DefaultMaxUnOrderedTTL, app.UnorderedTxManager), + ante.NewUnorderedTxDecorator(unorderedtx.DefaultMaxTimeoutDuration, options.TxManager, options.Environment), // ... } @@ -170,7 +203,9 @@ There is no longer a need for the Cosmos SDK to host these protos for itself and That package containing proto v2 generated code, but the SDK now uses [buf generated go SDK instead](https://buf.build/docs/bsr/generated-sdks/go). If you were depending on `cosmossdk.io/api/tendermint`, please use the buf generated go SDK instead, or ask CometBFT host the generated proto v2 code. -The `codectypes.Any` has moved to `github.com/cosmos/gogoproto/types/any`. Module developers can update the `buf.gen.gogo.yaml` configuration files by adjusting the corresponding `opt` option to `Mgoogle/protobuf/any.proto=github.com/cosmos/gogoproto/types/any` for directly mapping the`Any` type to its new location. This change is optional as `codectypes.Any` is aliased to `gogoproto.Any` in the SDK. +The `codectypes.Any` has moved to `github.com/cosmos/gogoproto/types/any`. Module developers need to update the `buf.gen.gogo.yaml` configuration files by adjusting the corresponding `opt` option to `Mgoogle/protobuf/any.proto=github.com/cosmos/gogoproto/types/any` for directly mapping the`Any` type to its new location. This change is optional, but recommended, as `codectypes.Any` is aliased to `gogoproto.Any` in the SDK. + +Also, any usages of the interfaces `AnyUnpacker` and `UnpackInterfacesMessage` must be replaced with the interfaces of the same name in the `github.com/cosmos/gogoproto/types/any` package. ### Modules @@ -1260,4 +1295,4 @@ message MsgSetWithdrawAddress { } ``` -When clients interact with a node they are required to set a codec in in the grpc.Dial. More information can be found in this [doc](https://docs.cosmos.network/v0.46/run-node/interact-node.html#programmatically-via-go). +When clients interact with a node they are required to set a codec in the grpc.Dial. More information can be found in this [doc](https://docs.cosmos.network/v0.46/run-node/interact-node.html#programmatically-via-go). diff --git a/api/cosmos/base/node/v1beta1/query.pulsar.go b/api/cosmos/base/node/v1beta1/query.pulsar.go index dcec17ddc233..ae4e61914747 100644 --- a/api/cosmos/base/node/v1beta1/query.pulsar.go +++ b/api/cosmos/base/node/v1beta1/query.pulsar.go @@ -2113,7 +2113,7 @@ func (*StatusRequest) Descriptor() ([]byte, []int) { return file_cosmos_base_node_v1beta1_query_proto_rawDescGZIP(), []int{2} } -// StateResponse defines the response structure for the status of a node. +// StatusResponse defines the response structure for the status of a node. type StatusResponse struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache diff --git a/api/cosmos/consensus/v1/query.pulsar.go b/api/cosmos/consensus/v1/query.pulsar.go index ca4bad59679e..734ec7f7023e 100644 --- a/api/cosmos/consensus/v1/query.pulsar.go +++ b/api/cosmos/consensus/v1/query.pulsar.go @@ -14,797 +14,6 @@ import ( sync "sync" ) -var ( - md_QueryGetCometInfoRequest protoreflect.MessageDescriptor -) - -func init() { - file_cosmos_consensus_v1_query_proto_init() - md_QueryGetCometInfoRequest = File_cosmos_consensus_v1_query_proto.Messages().ByName("QueryGetCometInfoRequest") -} - -var _ protoreflect.Message = (*fastReflection_QueryGetCometInfoRequest)(nil) - -type fastReflection_QueryGetCometInfoRequest QueryGetCometInfoRequest - -func (x *QueryGetCometInfoRequest) ProtoReflect() protoreflect.Message { - return (*fastReflection_QueryGetCometInfoRequest)(x) -} - -func (x *QueryGetCometInfoRequest) slowProtoReflect() protoreflect.Message { - mi := &file_cosmos_consensus_v1_query_proto_msgTypes[0] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -var _fastReflection_QueryGetCometInfoRequest_messageType fastReflection_QueryGetCometInfoRequest_messageType -var _ protoreflect.MessageType = fastReflection_QueryGetCometInfoRequest_messageType{} - -type fastReflection_QueryGetCometInfoRequest_messageType struct{} - -func (x fastReflection_QueryGetCometInfoRequest_messageType) Zero() protoreflect.Message { - return (*fastReflection_QueryGetCometInfoRequest)(nil) -} -func (x fastReflection_QueryGetCometInfoRequest_messageType) New() protoreflect.Message { - return new(fastReflection_QueryGetCometInfoRequest) -} -func (x fastReflection_QueryGetCometInfoRequest_messageType) Descriptor() protoreflect.MessageDescriptor { - return md_QueryGetCometInfoRequest -} - -// Descriptor returns message descriptor, which contains only the protobuf -// type information for the message. -func (x *fastReflection_QueryGetCometInfoRequest) Descriptor() protoreflect.MessageDescriptor { - return md_QueryGetCometInfoRequest -} - -// Type returns the message type, which encapsulates both Go and protobuf -// type information. If the Go type information is not needed, -// it is recommended that the message descriptor be used instead. -func (x *fastReflection_QueryGetCometInfoRequest) Type() protoreflect.MessageType { - return _fastReflection_QueryGetCometInfoRequest_messageType -} - -// New returns a newly allocated and mutable empty message. -func (x *fastReflection_QueryGetCometInfoRequest) New() protoreflect.Message { - return new(fastReflection_QueryGetCometInfoRequest) -} - -// Interface unwraps the message reflection interface and -// returns the underlying ProtoMessage interface. -func (x *fastReflection_QueryGetCometInfoRequest) Interface() protoreflect.ProtoMessage { - return (*QueryGetCometInfoRequest)(x) -} - -// Range iterates over every populated field in an undefined order, -// calling f for each field descriptor and value encountered. -// Range returns immediately if f returns false. -// While iterating, mutating operations may only be performed -// on the current field descriptor. -func (x *fastReflection_QueryGetCometInfoRequest) Range(f func(protoreflect.FieldDescriptor, protoreflect.Value) bool) { -} - -// Has reports whether a field is populated. -// -// Some fields have the property of nullability where it is possible to -// distinguish between the default value of a field and whether the field -// was explicitly populated with the default value. Singular message fields, -// member fields of a oneof, and proto2 scalar fields are nullable. Such -// fields are populated only if explicitly set. -// -// In other cases (aside from the nullable cases above), -// a proto3 scalar field is populated if it contains a non-zero value, and -// a repeated field is populated if it is non-empty. -func (x *fastReflection_QueryGetCometInfoRequest) Has(fd protoreflect.FieldDescriptor) bool { - switch fd.FullName() { - default: - if fd.IsExtension() { - panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.consensus.v1.QueryGetCometInfoRequest")) - } - panic(fmt.Errorf("message cosmos.consensus.v1.QueryGetCometInfoRequest does not contain field %s", fd.FullName())) - } -} - -// Clear clears the field such that a subsequent Has call reports false. -// -// Clearing an extension field clears both the extension type and value -// associated with the given field number. -// -// Clear is a mutating operation and unsafe for concurrent use. -func (x *fastReflection_QueryGetCometInfoRequest) Clear(fd protoreflect.FieldDescriptor) { - switch fd.FullName() { - default: - if fd.IsExtension() { - panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.consensus.v1.QueryGetCometInfoRequest")) - } - panic(fmt.Errorf("message cosmos.consensus.v1.QueryGetCometInfoRequest does not contain field %s", fd.FullName())) - } -} - -// Get retrieves the value for a field. -// -// For unpopulated scalars, it returns the default value, where -// the default value of a bytes scalar is guaranteed to be a copy. -// For unpopulated composite types, it returns an empty, read-only view -// of the value; to obtain a mutable reference, use Mutable. -func (x *fastReflection_QueryGetCometInfoRequest) Get(descriptor protoreflect.FieldDescriptor) protoreflect.Value { - switch descriptor.FullName() { - default: - if descriptor.IsExtension() { - panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.consensus.v1.QueryGetCometInfoRequest")) - } - panic(fmt.Errorf("message cosmos.consensus.v1.QueryGetCometInfoRequest does not contain field %s", descriptor.FullName())) - } -} - -// Set stores the value for a field. -// -// For a field belonging to a oneof, it implicitly clears any other field -// that may be currently set within the same oneof. -// For extension fields, it implicitly stores the provided ExtensionType. -// When setting a composite type, it is unspecified whether the stored value -// aliases the source's memory in any way. If the composite value is an -// empty, read-only value, then it panics. -// -// Set is a mutating operation and unsafe for concurrent use. -func (x *fastReflection_QueryGetCometInfoRequest) Set(fd protoreflect.FieldDescriptor, value protoreflect.Value) { - switch fd.FullName() { - default: - if fd.IsExtension() { - panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.consensus.v1.QueryGetCometInfoRequest")) - } - panic(fmt.Errorf("message cosmos.consensus.v1.QueryGetCometInfoRequest does not contain field %s", fd.FullName())) - } -} - -// Mutable returns a mutable reference to a composite type. -// -// If the field is unpopulated, it may allocate a composite value. -// For a field belonging to a oneof, it implicitly clears any other field -// that may be currently set within the same oneof. -// For extension fields, it implicitly stores the provided ExtensionType -// if not already stored. -// It panics if the field does not contain a composite type. -// -// Mutable is a mutating operation and unsafe for concurrent use. -func (x *fastReflection_QueryGetCometInfoRequest) Mutable(fd protoreflect.FieldDescriptor) protoreflect.Value { - switch fd.FullName() { - default: - if fd.IsExtension() { - panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.consensus.v1.QueryGetCometInfoRequest")) - } - panic(fmt.Errorf("message cosmos.consensus.v1.QueryGetCometInfoRequest does not contain field %s", fd.FullName())) - } -} - -// NewField returns a new value that is assignable to the field -// for the given descriptor. For scalars, this returns the default value. -// For lists, maps, and messages, this returns a new, empty, mutable value. -func (x *fastReflection_QueryGetCometInfoRequest) NewField(fd protoreflect.FieldDescriptor) protoreflect.Value { - switch fd.FullName() { - default: - if fd.IsExtension() { - panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.consensus.v1.QueryGetCometInfoRequest")) - } - panic(fmt.Errorf("message cosmos.consensus.v1.QueryGetCometInfoRequest does not contain field %s", fd.FullName())) - } -} - -// WhichOneof reports which field within the oneof is populated, -// returning nil if none are populated. -// It panics if the oneof descriptor does not belong to this message. -func (x *fastReflection_QueryGetCometInfoRequest) WhichOneof(d protoreflect.OneofDescriptor) protoreflect.FieldDescriptor { - switch d.FullName() { - default: - panic(fmt.Errorf("%s is not a oneof field in cosmos.consensus.v1.QueryGetCometInfoRequest", d.FullName())) - } - panic("unreachable") -} - -// GetUnknown retrieves the entire list of unknown fields. -// The caller may only mutate the contents of the RawFields -// if the mutated bytes are stored back into the message with SetUnknown. -func (x *fastReflection_QueryGetCometInfoRequest) GetUnknown() protoreflect.RawFields { - return x.unknownFields -} - -// SetUnknown stores an entire list of unknown fields. -// The raw fields must be syntactically valid according to the wire format. -// An implementation may panic if this is not the case. -// Once stored, the caller must not mutate the content of the RawFields. -// An empty RawFields may be passed to clear the fields. -// -// SetUnknown is a mutating operation and unsafe for concurrent use. -func (x *fastReflection_QueryGetCometInfoRequest) SetUnknown(fields protoreflect.RawFields) { - x.unknownFields = fields -} - -// IsValid reports whether the message is valid. -// -// An invalid message is an empty, read-only value. -// -// An invalid message often corresponds to a nil pointer of the concrete -// message type, but the details are implementation dependent. -// Validity is not part of the protobuf data model, and may not -// be preserved in marshaling or other operations. -func (x *fastReflection_QueryGetCometInfoRequest) IsValid() bool { - return x != nil -} - -// ProtoMethods returns optional fastReflectionFeature-path implementations of various operations. -// This method may return nil. -// -// The returned methods type is identical to -// "google.golang.org/protobuf/runtime/protoiface".Methods. -// Consult the protoiface package documentation for details. -func (x *fastReflection_QueryGetCometInfoRequest) ProtoMethods() *protoiface.Methods { - size := func(input protoiface.SizeInput) protoiface.SizeOutput { - x := input.Message.Interface().(*QueryGetCometInfoRequest) - if x == nil { - return protoiface.SizeOutput{ - NoUnkeyedLiterals: input.NoUnkeyedLiterals, - Size: 0, - } - } - options := runtime.SizeInputToOptions(input) - _ = options - var n int - var l int - _ = l - if x.unknownFields != nil { - n += len(x.unknownFields) - } - return protoiface.SizeOutput{ - NoUnkeyedLiterals: input.NoUnkeyedLiterals, - Size: n, - } - } - - marshal := func(input protoiface.MarshalInput) (protoiface.MarshalOutput, error) { - x := input.Message.Interface().(*QueryGetCometInfoRequest) - if x == nil { - return protoiface.MarshalOutput{ - NoUnkeyedLiterals: input.NoUnkeyedLiterals, - Buf: input.Buf, - }, nil - } - options := runtime.MarshalInputToOptions(input) - _ = options - size := options.Size(x) - dAtA := make([]byte, size) - i := len(dAtA) - _ = i - var l int - _ = l - if x.unknownFields != nil { - i -= len(x.unknownFields) - copy(dAtA[i:], x.unknownFields) - } - if input.Buf != nil { - input.Buf = append(input.Buf, dAtA...) - } else { - input.Buf = dAtA - } - return protoiface.MarshalOutput{ - NoUnkeyedLiterals: input.NoUnkeyedLiterals, - Buf: input.Buf, - }, nil - } - unmarshal := func(input protoiface.UnmarshalInput) (protoiface.UnmarshalOutput, error) { - x := input.Message.Interface().(*QueryGetCometInfoRequest) - if x == nil { - return protoiface.UnmarshalOutput{ - NoUnkeyedLiterals: input.NoUnkeyedLiterals, - Flags: input.Flags, - }, nil - } - options := runtime.UnmarshalInputToOptions(input) - _ = options - dAtA := input.Buf - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrIntOverflow - } - if iNdEx >= l { - return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: QueryGetCometInfoRequest: wiretype end group for non-group") - } - if fieldNum <= 0 { - return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: QueryGetCometInfoRequest: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - default: - iNdEx = preIndex - skippy, err := runtime.Skip(dAtA[iNdEx:]) - if err != nil { - return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength - } - if (iNdEx + skippy) > l { - return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF - } - if !options.DiscardUnknown { - x.unknownFields = append(x.unknownFields, dAtA[iNdEx:iNdEx+skippy]...) - } - iNdEx += skippy - } - } - - if iNdEx > l { - return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF - } - return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, nil - } - return &protoiface.Methods{ - NoUnkeyedLiterals: struct{}{}, - Flags: protoiface.SupportMarshalDeterministic | protoiface.SupportUnmarshalDiscardUnknown, - Size: size, - Marshal: marshal, - Unmarshal: unmarshal, - Merge: nil, - CheckInitialized: nil, - } -} - -var ( - md_QueryGetCometInfoResponse protoreflect.MessageDescriptor - fd_QueryGetCometInfoResponse_comet_info protoreflect.FieldDescriptor -) - -func init() { - file_cosmos_consensus_v1_query_proto_init() - md_QueryGetCometInfoResponse = File_cosmos_consensus_v1_query_proto.Messages().ByName("QueryGetCometInfoResponse") - fd_QueryGetCometInfoResponse_comet_info = md_QueryGetCometInfoResponse.Fields().ByName("comet_info") -} - -var _ protoreflect.Message = (*fastReflection_QueryGetCometInfoResponse)(nil) - -type fastReflection_QueryGetCometInfoResponse QueryGetCometInfoResponse - -func (x *QueryGetCometInfoResponse) ProtoReflect() protoreflect.Message { - return (*fastReflection_QueryGetCometInfoResponse)(x) -} - -func (x *QueryGetCometInfoResponse) slowProtoReflect() protoreflect.Message { - mi := &file_cosmos_consensus_v1_query_proto_msgTypes[1] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -var _fastReflection_QueryGetCometInfoResponse_messageType fastReflection_QueryGetCometInfoResponse_messageType -var _ protoreflect.MessageType = fastReflection_QueryGetCometInfoResponse_messageType{} - -type fastReflection_QueryGetCometInfoResponse_messageType struct{} - -func (x fastReflection_QueryGetCometInfoResponse_messageType) Zero() protoreflect.Message { - return (*fastReflection_QueryGetCometInfoResponse)(nil) -} -func (x fastReflection_QueryGetCometInfoResponse_messageType) New() protoreflect.Message { - return new(fastReflection_QueryGetCometInfoResponse) -} -func (x fastReflection_QueryGetCometInfoResponse_messageType) Descriptor() protoreflect.MessageDescriptor { - return md_QueryGetCometInfoResponse -} - -// Descriptor returns message descriptor, which contains only the protobuf -// type information for the message. -func (x *fastReflection_QueryGetCometInfoResponse) Descriptor() protoreflect.MessageDescriptor { - return md_QueryGetCometInfoResponse -} - -// Type returns the message type, which encapsulates both Go and protobuf -// type information. If the Go type information is not needed, -// it is recommended that the message descriptor be used instead. -func (x *fastReflection_QueryGetCometInfoResponse) Type() protoreflect.MessageType { - return _fastReflection_QueryGetCometInfoResponse_messageType -} - -// New returns a newly allocated and mutable empty message. -func (x *fastReflection_QueryGetCometInfoResponse) New() protoreflect.Message { - return new(fastReflection_QueryGetCometInfoResponse) -} - -// Interface unwraps the message reflection interface and -// returns the underlying ProtoMessage interface. -func (x *fastReflection_QueryGetCometInfoResponse) Interface() protoreflect.ProtoMessage { - return (*QueryGetCometInfoResponse)(x) -} - -// Range iterates over every populated field in an undefined order, -// calling f for each field descriptor and value encountered. -// Range returns immediately if f returns false. -// While iterating, mutating operations may only be performed -// on the current field descriptor. -func (x *fastReflection_QueryGetCometInfoResponse) Range(f func(protoreflect.FieldDescriptor, protoreflect.Value) bool) { - if x.CometInfo != nil { - value := protoreflect.ValueOfMessage(x.CometInfo.ProtoReflect()) - if !f(fd_QueryGetCometInfoResponse_comet_info, value) { - return - } - } -} - -// Has reports whether a field is populated. -// -// Some fields have the property of nullability where it is possible to -// distinguish between the default value of a field and whether the field -// was explicitly populated with the default value. Singular message fields, -// member fields of a oneof, and proto2 scalar fields are nullable. Such -// fields are populated only if explicitly set. -// -// In other cases (aside from the nullable cases above), -// a proto3 scalar field is populated if it contains a non-zero value, and -// a repeated field is populated if it is non-empty. -func (x *fastReflection_QueryGetCometInfoResponse) Has(fd protoreflect.FieldDescriptor) bool { - switch fd.FullName() { - case "cosmos.consensus.v1.QueryGetCometInfoResponse.comet_info": - return x.CometInfo != nil - default: - if fd.IsExtension() { - panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.consensus.v1.QueryGetCometInfoResponse")) - } - panic(fmt.Errorf("message cosmos.consensus.v1.QueryGetCometInfoResponse does not contain field %s", fd.FullName())) - } -} - -// Clear clears the field such that a subsequent Has call reports false. -// -// Clearing an extension field clears both the extension type and value -// associated with the given field number. -// -// Clear is a mutating operation and unsafe for concurrent use. -func (x *fastReflection_QueryGetCometInfoResponse) Clear(fd protoreflect.FieldDescriptor) { - switch fd.FullName() { - case "cosmos.consensus.v1.QueryGetCometInfoResponse.comet_info": - x.CometInfo = nil - default: - if fd.IsExtension() { - panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.consensus.v1.QueryGetCometInfoResponse")) - } - panic(fmt.Errorf("message cosmos.consensus.v1.QueryGetCometInfoResponse does not contain field %s", fd.FullName())) - } -} - -// Get retrieves the value for a field. -// -// For unpopulated scalars, it returns the default value, where -// the default value of a bytes scalar is guaranteed to be a copy. -// For unpopulated composite types, it returns an empty, read-only view -// of the value; to obtain a mutable reference, use Mutable. -func (x *fastReflection_QueryGetCometInfoResponse) Get(descriptor protoreflect.FieldDescriptor) protoreflect.Value { - switch descriptor.FullName() { - case "cosmos.consensus.v1.QueryGetCometInfoResponse.comet_info": - value := x.CometInfo - return protoreflect.ValueOfMessage(value.ProtoReflect()) - default: - if descriptor.IsExtension() { - panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.consensus.v1.QueryGetCometInfoResponse")) - } - panic(fmt.Errorf("message cosmos.consensus.v1.QueryGetCometInfoResponse does not contain field %s", descriptor.FullName())) - } -} - -// Set stores the value for a field. -// -// For a field belonging to a oneof, it implicitly clears any other field -// that may be currently set within the same oneof. -// For extension fields, it implicitly stores the provided ExtensionType. -// When setting a composite type, it is unspecified whether the stored value -// aliases the source's memory in any way. If the composite value is an -// empty, read-only value, then it panics. -// -// Set is a mutating operation and unsafe for concurrent use. -func (x *fastReflection_QueryGetCometInfoResponse) Set(fd protoreflect.FieldDescriptor, value protoreflect.Value) { - switch fd.FullName() { - case "cosmos.consensus.v1.QueryGetCometInfoResponse.comet_info": - x.CometInfo = value.Message().Interface().(*CometInfo) - default: - if fd.IsExtension() { - panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.consensus.v1.QueryGetCometInfoResponse")) - } - panic(fmt.Errorf("message cosmos.consensus.v1.QueryGetCometInfoResponse does not contain field %s", fd.FullName())) - } -} - -// Mutable returns a mutable reference to a composite type. -// -// If the field is unpopulated, it may allocate a composite value. -// For a field belonging to a oneof, it implicitly clears any other field -// that may be currently set within the same oneof. -// For extension fields, it implicitly stores the provided ExtensionType -// if not already stored. -// It panics if the field does not contain a composite type. -// -// Mutable is a mutating operation and unsafe for concurrent use. -func (x *fastReflection_QueryGetCometInfoResponse) Mutable(fd protoreflect.FieldDescriptor) protoreflect.Value { - switch fd.FullName() { - case "cosmos.consensus.v1.QueryGetCometInfoResponse.comet_info": - if x.CometInfo == nil { - x.CometInfo = new(CometInfo) - } - return protoreflect.ValueOfMessage(x.CometInfo.ProtoReflect()) - default: - if fd.IsExtension() { - panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.consensus.v1.QueryGetCometInfoResponse")) - } - panic(fmt.Errorf("message cosmos.consensus.v1.QueryGetCometInfoResponse does not contain field %s", fd.FullName())) - } -} - -// NewField returns a new value that is assignable to the field -// for the given descriptor. For scalars, this returns the default value. -// For lists, maps, and messages, this returns a new, empty, mutable value. -func (x *fastReflection_QueryGetCometInfoResponse) NewField(fd protoreflect.FieldDescriptor) protoreflect.Value { - switch fd.FullName() { - case "cosmos.consensus.v1.QueryGetCometInfoResponse.comet_info": - m := new(CometInfo) - return protoreflect.ValueOfMessage(m.ProtoReflect()) - default: - if fd.IsExtension() { - panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.consensus.v1.QueryGetCometInfoResponse")) - } - panic(fmt.Errorf("message cosmos.consensus.v1.QueryGetCometInfoResponse does not contain field %s", fd.FullName())) - } -} - -// WhichOneof reports which field within the oneof is populated, -// returning nil if none are populated. -// It panics if the oneof descriptor does not belong to this message. -func (x *fastReflection_QueryGetCometInfoResponse) WhichOneof(d protoreflect.OneofDescriptor) protoreflect.FieldDescriptor { - switch d.FullName() { - default: - panic(fmt.Errorf("%s is not a oneof field in cosmos.consensus.v1.QueryGetCometInfoResponse", d.FullName())) - } - panic("unreachable") -} - -// GetUnknown retrieves the entire list of unknown fields. -// The caller may only mutate the contents of the RawFields -// if the mutated bytes are stored back into the message with SetUnknown. -func (x *fastReflection_QueryGetCometInfoResponse) GetUnknown() protoreflect.RawFields { - return x.unknownFields -} - -// SetUnknown stores an entire list of unknown fields. -// The raw fields must be syntactically valid according to the wire format. -// An implementation may panic if this is not the case. -// Once stored, the caller must not mutate the content of the RawFields. -// An empty RawFields may be passed to clear the fields. -// -// SetUnknown is a mutating operation and unsafe for concurrent use. -func (x *fastReflection_QueryGetCometInfoResponse) SetUnknown(fields protoreflect.RawFields) { - x.unknownFields = fields -} - -// IsValid reports whether the message is valid. -// -// An invalid message is an empty, read-only value. -// -// An invalid message often corresponds to a nil pointer of the concrete -// message type, but the details are implementation dependent. -// Validity is not part of the protobuf data model, and may not -// be preserved in marshaling or other operations. -func (x *fastReflection_QueryGetCometInfoResponse) IsValid() bool { - return x != nil -} - -// ProtoMethods returns optional fastReflectionFeature-path implementations of various operations. -// This method may return nil. -// -// The returned methods type is identical to -// "google.golang.org/protobuf/runtime/protoiface".Methods. -// Consult the protoiface package documentation for details. -func (x *fastReflection_QueryGetCometInfoResponse) ProtoMethods() *protoiface.Methods { - size := func(input protoiface.SizeInput) protoiface.SizeOutput { - x := input.Message.Interface().(*QueryGetCometInfoResponse) - if x == nil { - return protoiface.SizeOutput{ - NoUnkeyedLiterals: input.NoUnkeyedLiterals, - Size: 0, - } - } - options := runtime.SizeInputToOptions(input) - _ = options - var n int - var l int - _ = l - if x.CometInfo != nil { - l = options.Size(x.CometInfo) - n += 1 + l + runtime.Sov(uint64(l)) - } - if x.unknownFields != nil { - n += len(x.unknownFields) - } - return protoiface.SizeOutput{ - NoUnkeyedLiterals: input.NoUnkeyedLiterals, - Size: n, - } - } - - marshal := func(input protoiface.MarshalInput) (protoiface.MarshalOutput, error) { - x := input.Message.Interface().(*QueryGetCometInfoResponse) - if x == nil { - return protoiface.MarshalOutput{ - NoUnkeyedLiterals: input.NoUnkeyedLiterals, - Buf: input.Buf, - }, nil - } - options := runtime.MarshalInputToOptions(input) - _ = options - size := options.Size(x) - dAtA := make([]byte, size) - i := len(dAtA) - _ = i - var l int - _ = l - if x.unknownFields != nil { - i -= len(x.unknownFields) - copy(dAtA[i:], x.unknownFields) - } - if x.CometInfo != nil { - encoded, err := options.Marshal(x.CometInfo) - if err != nil { - return protoiface.MarshalOutput{ - NoUnkeyedLiterals: input.NoUnkeyedLiterals, - Buf: input.Buf, - }, err - } - i -= len(encoded) - copy(dAtA[i:], encoded) - i = runtime.EncodeVarint(dAtA, i, uint64(len(encoded))) - i-- - dAtA[i] = 0xa - } - if input.Buf != nil { - input.Buf = append(input.Buf, dAtA...) - } else { - input.Buf = dAtA - } - return protoiface.MarshalOutput{ - NoUnkeyedLiterals: input.NoUnkeyedLiterals, - Buf: input.Buf, - }, nil - } - unmarshal := func(input protoiface.UnmarshalInput) (protoiface.UnmarshalOutput, error) { - x := input.Message.Interface().(*QueryGetCometInfoResponse) - if x == nil { - return protoiface.UnmarshalOutput{ - NoUnkeyedLiterals: input.NoUnkeyedLiterals, - Flags: input.Flags, - }, nil - } - options := runtime.UnmarshalInputToOptions(input) - _ = options - dAtA := input.Buf - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrIntOverflow - } - if iNdEx >= l { - return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: QueryGetCometInfoResponse: wiretype end group for non-group") - } - if fieldNum <= 0 { - return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: QueryGetCometInfoResponse: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: wrong wireType = %d for field CometInfo", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrIntOverflow - } - if iNdEx >= l { - return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength - } - if postIndex > l { - return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF - } - if x.CometInfo == nil { - x.CometInfo = &CometInfo{} - } - if err := options.Unmarshal(dAtA[iNdEx:postIndex], x.CometInfo); err != nil { - return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, err - } - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := runtime.Skip(dAtA[iNdEx:]) - if err != nil { - return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength - } - if (iNdEx + skippy) > l { - return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF - } - if !options.DiscardUnknown { - x.unknownFields = append(x.unknownFields, dAtA[iNdEx:iNdEx+skippy]...) - } - iNdEx += skippy - } - } - - if iNdEx > l { - return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF - } - return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, nil - } - return &protoiface.Methods{ - NoUnkeyedLiterals: struct{}{}, - Flags: protoiface.SupportMarshalDeterministic | protoiface.SupportUnmarshalDiscardUnknown, - Size: size, - Marshal: marshal, - Unmarshal: unmarshal, - Merge: nil, - CheckInitialized: nil, - } -} - var ( md_QueryParamsRequest protoreflect.MessageDescriptor ) @@ -823,7 +32,7 @@ func (x *QueryParamsRequest) ProtoReflect() protoreflect.Message { } func (x *QueryParamsRequest) slowProtoReflect() protoreflect.Message { - mi := &file_cosmos_consensus_v1_query_proto_msgTypes[2] + mi := &file_cosmos_consensus_v1_query_proto_msgTypes[0] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -1181,7 +390,7 @@ func (x *QueryParamsResponse) ProtoReflect() protoreflect.Message { } func (x *QueryParamsResponse) slowProtoReflect() protoreflect.Message { - mi := &file_cosmos_consensus_v1_query_proto_msgTypes[3] + mi := &file_cosmos_consensus_v1_query_proto_msgTypes[1] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -1611,70 +820,6 @@ const ( _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) ) -// QueryCometInfoRequest defines the request type for querying x/consensus comet info. -type QueryGetCometInfoRequest struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields -} - -func (x *QueryGetCometInfoRequest) Reset() { - *x = QueryGetCometInfoRequest{} - if protoimpl.UnsafeEnabled { - mi := &file_cosmos_consensus_v1_query_proto_msgTypes[0] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *QueryGetCometInfoRequest) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*QueryGetCometInfoRequest) ProtoMessage() {} - -// Deprecated: Use QueryGetCometInfoRequest.ProtoReflect.Descriptor instead. -func (*QueryGetCometInfoRequest) Descriptor() ([]byte, []int) { - return file_cosmos_consensus_v1_query_proto_rawDescGZIP(), []int{0} -} - -// QueryCometInfoResponse defines the response type for querying x/consensus comet info. -type QueryGetCometInfoResponse struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - // comet_info is the comet info of the x/consensus module. - CometInfo *CometInfo `protobuf:"bytes,1,opt,name=comet_info,json=cometInfo,proto3" json:"comet_info,omitempty"` -} - -func (x *QueryGetCometInfoResponse) Reset() { - *x = QueryGetCometInfoResponse{} - if protoimpl.UnsafeEnabled { - mi := &file_cosmos_consensus_v1_query_proto_msgTypes[1] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *QueryGetCometInfoResponse) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*QueryGetCometInfoResponse) ProtoMessage() {} - -// Deprecated: Use QueryGetCometInfoResponse.ProtoReflect.Descriptor instead. -func (*QueryGetCometInfoResponse) Descriptor() ([]byte, []int) { - return file_cosmos_consensus_v1_query_proto_rawDescGZIP(), []int{1} -} - -func (x *QueryGetCometInfoResponse) GetCometInfo() *CometInfo { - if x != nil { - return x.CometInfo - } - return nil -} - // QueryParamsRequest defines the request type for querying x/consensus parameters. type QueryParamsRequest struct { state protoimpl.MessageState @@ -1685,7 +830,7 @@ type QueryParamsRequest struct { func (x *QueryParamsRequest) Reset() { *x = QueryParamsRequest{} if protoimpl.UnsafeEnabled { - mi := &file_cosmos_consensus_v1_query_proto_msgTypes[2] + mi := &file_cosmos_consensus_v1_query_proto_msgTypes[0] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -1699,7 +844,7 @@ func (*QueryParamsRequest) ProtoMessage() {} // Deprecated: Use QueryParamsRequest.ProtoReflect.Descriptor instead. func (*QueryParamsRequest) Descriptor() ([]byte, []int) { - return file_cosmos_consensus_v1_query_proto_rawDescGZIP(), []int{2} + return file_cosmos_consensus_v1_query_proto_rawDescGZIP(), []int{0} } // QueryParamsResponse defines the response type for querying x/consensus parameters. @@ -1717,7 +862,7 @@ type QueryParamsResponse struct { func (x *QueryParamsResponse) Reset() { *x = QueryParamsResponse{} if protoimpl.UnsafeEnabled { - mi := &file_cosmos_consensus_v1_query_proto_msgTypes[3] + mi := &file_cosmos_consensus_v1_query_proto_msgTypes[1] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -1731,7 +876,7 @@ func (*QueryParamsResponse) ProtoMessage() {} // Deprecated: Use QueryParamsResponse.ProtoReflect.Descriptor instead. func (*QueryParamsResponse) Descriptor() ([]byte, []int) { - return file_cosmos_consensus_v1_query_proto_rawDescGZIP(), []int{3} + return file_cosmos_consensus_v1_query_proto_rawDescGZIP(), []int{1} } func (x *QueryParamsResponse) GetParams() *v1.ConsensusParams { @@ -1753,50 +898,35 @@ var file_cosmos_consensus_v1_query_proto_rawDesc = []byte{ 0x79, 0x70, 0x65, 0x73, 0x2f, 0x76, 0x31, 0x2f, 0x70, 0x61, 0x72, 0x61, 0x6d, 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x23, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2f, 0x63, 0x6f, 0x6e, 0x73, 0x65, 0x6e, 0x73, 0x75, 0x73, 0x2f, 0x76, 0x31, 0x2f, 0x63, 0x6f, 0x6e, 0x73, 0x65, 0x6e, - 0x73, 0x75, 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x1a, 0x0a, 0x18, 0x51, 0x75, 0x65, - 0x72, 0x79, 0x47, 0x65, 0x74, 0x43, 0x6f, 0x6d, 0x65, 0x74, 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x65, - 0x71, 0x75, 0x65, 0x73, 0x74, 0x22, 0x5a, 0x0a, 0x19, 0x51, 0x75, 0x65, 0x72, 0x79, 0x47, 0x65, - 0x74, 0x43, 0x6f, 0x6d, 0x65, 0x74, 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, - 0x73, 0x65, 0x12, 0x3d, 0x0a, 0x0a, 0x63, 0x6f, 0x6d, 0x65, 0x74, 0x5f, 0x69, 0x6e, 0x66, 0x6f, - 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1e, 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, - 0x63, 0x6f, 0x6e, 0x73, 0x65, 0x6e, 0x73, 0x75, 0x73, 0x2e, 0x76, 0x31, 0x2e, 0x43, 0x6f, 0x6d, - 0x65, 0x74, 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x09, 0x63, 0x6f, 0x6d, 0x65, 0x74, 0x49, 0x6e, 0x66, - 0x6f, 0x22, 0x14, 0x0a, 0x12, 0x51, 0x75, 0x65, 0x72, 0x79, 0x50, 0x61, 0x72, 0x61, 0x6d, 0x73, - 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x22, 0x51, 0x0a, 0x13, 0x51, 0x75, 0x65, 0x72, 0x79, - 0x50, 0x61, 0x72, 0x61, 0x6d, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x3a, - 0x0a, 0x06, 0x70, 0x61, 0x72, 0x61, 0x6d, 0x73, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x22, - 0x2e, 0x63, 0x6f, 0x6d, 0x65, 0x74, 0x62, 0x66, 0x74, 0x2e, 0x74, 0x79, 0x70, 0x65, 0x73, 0x2e, - 0x76, 0x31, 0x2e, 0x43, 0x6f, 0x6e, 0x73, 0x65, 0x6e, 0x73, 0x75, 0x73, 0x50, 0x61, 0x72, 0x61, - 0x6d, 0x73, 0x52, 0x06, 0x70, 0x61, 0x72, 0x61, 0x6d, 0x73, 0x32, 0xf9, 0x01, 0x0a, 0x05, 0x51, - 0x75, 0x65, 0x72, 0x79, 0x12, 0x80, 0x01, 0x0a, 0x06, 0x50, 0x61, 0x72, 0x61, 0x6d, 0x73, 0x12, - 0x27, 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x63, 0x6f, 0x6e, 0x73, 0x65, 0x6e, 0x73, - 0x75, 0x73, 0x2e, 0x76, 0x31, 0x2e, 0x51, 0x75, 0x65, 0x72, 0x79, 0x50, 0x61, 0x72, 0x61, 0x6d, - 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x28, 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, - 0x73, 0x2e, 0x63, 0x6f, 0x6e, 0x73, 0x65, 0x6e, 0x73, 0x75, 0x73, 0x2e, 0x76, 0x31, 0x2e, 0x51, - 0x75, 0x65, 0x72, 0x79, 0x50, 0x61, 0x72, 0x61, 0x6d, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, - 0x73, 0x65, 0x22, 0x23, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x1d, 0x12, 0x1b, 0x2f, 0x63, 0x6f, 0x73, - 0x6d, 0x6f, 0x73, 0x2f, 0x63, 0x6f, 0x6e, 0x73, 0x65, 0x6e, 0x73, 0x75, 0x73, 0x2f, 0x76, 0x31, - 0x2f, 0x70, 0x61, 0x72, 0x61, 0x6d, 0x73, 0x12, 0x6d, 0x0a, 0x0c, 0x47, 0x65, 0x74, 0x43, 0x6f, - 0x6d, 0x65, 0x74, 0x49, 0x6e, 0x66, 0x6f, 0x12, 0x2d, 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, + 0x73, 0x75, 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x14, 0x0a, 0x12, 0x51, 0x75, 0x65, + 0x72, 0x79, 0x50, 0x61, 0x72, 0x61, 0x6d, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x22, + 0x51, 0x0a, 0x13, 0x51, 0x75, 0x65, 0x72, 0x79, 0x50, 0x61, 0x72, 0x61, 0x6d, 0x73, 0x52, 0x65, + 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x3a, 0x0a, 0x06, 0x70, 0x61, 0x72, 0x61, 0x6d, 0x73, + 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x22, 0x2e, 0x63, 0x6f, 0x6d, 0x65, 0x74, 0x62, 0x66, + 0x74, 0x2e, 0x74, 0x79, 0x70, 0x65, 0x73, 0x2e, 0x76, 0x31, 0x2e, 0x43, 0x6f, 0x6e, 0x73, 0x65, + 0x6e, 0x73, 0x75, 0x73, 0x50, 0x61, 0x72, 0x61, 0x6d, 0x73, 0x52, 0x06, 0x70, 0x61, 0x72, 0x61, + 0x6d, 0x73, 0x32, 0x8a, 0x01, 0x0a, 0x05, 0x51, 0x75, 0x65, 0x72, 0x79, 0x12, 0x80, 0x01, 0x0a, + 0x06, 0x50, 0x61, 0x72, 0x61, 0x6d, 0x73, 0x12, 0x27, 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x63, 0x6f, 0x6e, 0x73, 0x65, 0x6e, 0x73, 0x75, 0x73, 0x2e, 0x76, 0x31, 0x2e, 0x51, 0x75, - 0x65, 0x72, 0x79, 0x47, 0x65, 0x74, 0x43, 0x6f, 0x6d, 0x65, 0x74, 0x49, 0x6e, 0x66, 0x6f, 0x52, - 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x2e, 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, - 0x63, 0x6f, 0x6e, 0x73, 0x65, 0x6e, 0x73, 0x75, 0x73, 0x2e, 0x76, 0x31, 0x2e, 0x51, 0x75, 0x65, - 0x72, 0x79, 0x47, 0x65, 0x74, 0x43, 0x6f, 0x6d, 0x65, 0x74, 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x65, - 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x42, 0xc5, 0x01, 0x0a, 0x17, 0x63, 0x6f, 0x6d, 0x2e, 0x63, - 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x63, 0x6f, 0x6e, 0x73, 0x65, 0x6e, 0x73, 0x75, 0x73, 0x2e, - 0x76, 0x31, 0x42, 0x0a, 0x51, 0x75, 0x65, 0x72, 0x79, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, - 0x5a, 0x30, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x73, 0x64, 0x6b, 0x2e, 0x69, 0x6f, 0x2f, 0x61, - 0x70, 0x69, 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2f, 0x63, 0x6f, 0x6e, 0x73, 0x65, 0x6e, - 0x73, 0x75, 0x73, 0x2f, 0x76, 0x31, 0x3b, 0x63, 0x6f, 0x6e, 0x73, 0x65, 0x6e, 0x73, 0x75, 0x73, - 0x76, 0x31, 0xa2, 0x02, 0x03, 0x43, 0x43, 0x58, 0xaa, 0x02, 0x13, 0x43, 0x6f, 0x73, 0x6d, 0x6f, - 0x73, 0x2e, 0x43, 0x6f, 0x6e, 0x73, 0x65, 0x6e, 0x73, 0x75, 0x73, 0x2e, 0x56, 0x31, 0xca, 0x02, - 0x13, 0x43, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x5c, 0x43, 0x6f, 0x6e, 0x73, 0x65, 0x6e, 0x73, 0x75, - 0x73, 0x5c, 0x56, 0x31, 0xe2, 0x02, 0x1f, 0x43, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x5c, 0x43, 0x6f, - 0x6e, 0x73, 0x65, 0x6e, 0x73, 0x75, 0x73, 0x5c, 0x56, 0x31, 0x5c, 0x47, 0x50, 0x42, 0x4d, 0x65, - 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0xea, 0x02, 0x15, 0x43, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x3a, - 0x3a, 0x43, 0x6f, 0x6e, 0x73, 0x65, 0x6e, 0x73, 0x75, 0x73, 0x3a, 0x3a, 0x56, 0x31, 0x62, 0x06, - 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x65, 0x72, 0x79, 0x50, 0x61, 0x72, 0x61, 0x6d, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, + 0x1a, 0x28, 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x63, 0x6f, 0x6e, 0x73, 0x65, 0x6e, + 0x73, 0x75, 0x73, 0x2e, 0x76, 0x31, 0x2e, 0x51, 0x75, 0x65, 0x72, 0x79, 0x50, 0x61, 0x72, 0x61, + 0x6d, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x23, 0x82, 0xd3, 0xe4, 0x93, + 0x02, 0x1d, 0x12, 0x1b, 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2f, 0x63, 0x6f, 0x6e, 0x73, + 0x65, 0x6e, 0x73, 0x75, 0x73, 0x2f, 0x76, 0x31, 0x2f, 0x70, 0x61, 0x72, 0x61, 0x6d, 0x73, 0x42, + 0xc5, 0x01, 0x0a, 0x17, 0x63, 0x6f, 0x6d, 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x63, + 0x6f, 0x6e, 0x73, 0x65, 0x6e, 0x73, 0x75, 0x73, 0x2e, 0x76, 0x31, 0x42, 0x0a, 0x51, 0x75, 0x65, + 0x72, 0x79, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x30, 0x63, 0x6f, 0x73, 0x6d, 0x6f, + 0x73, 0x73, 0x64, 0x6b, 0x2e, 0x69, 0x6f, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x63, 0x6f, 0x73, 0x6d, + 0x6f, 0x73, 0x2f, 0x63, 0x6f, 0x6e, 0x73, 0x65, 0x6e, 0x73, 0x75, 0x73, 0x2f, 0x76, 0x31, 0x3b, + 0x63, 0x6f, 0x6e, 0x73, 0x65, 0x6e, 0x73, 0x75, 0x73, 0x76, 0x31, 0xa2, 0x02, 0x03, 0x43, 0x43, + 0x58, 0xaa, 0x02, 0x13, 0x43, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x43, 0x6f, 0x6e, 0x73, 0x65, + 0x6e, 0x73, 0x75, 0x73, 0x2e, 0x56, 0x31, 0xca, 0x02, 0x13, 0x43, 0x6f, 0x73, 0x6d, 0x6f, 0x73, + 0x5c, 0x43, 0x6f, 0x6e, 0x73, 0x65, 0x6e, 0x73, 0x75, 0x73, 0x5c, 0x56, 0x31, 0xe2, 0x02, 0x1f, + 0x43, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x5c, 0x43, 0x6f, 0x6e, 0x73, 0x65, 0x6e, 0x73, 0x75, 0x73, + 0x5c, 0x56, 0x31, 0x5c, 0x47, 0x50, 0x42, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0xea, + 0x02, 0x15, 0x43, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x3a, 0x3a, 0x43, 0x6f, 0x6e, 0x73, 0x65, 0x6e, + 0x73, 0x75, 0x73, 0x3a, 0x3a, 0x56, 0x31, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( @@ -1811,27 +941,21 @@ func file_cosmos_consensus_v1_query_proto_rawDescGZIP() []byte { return file_cosmos_consensus_v1_query_proto_rawDescData } -var file_cosmos_consensus_v1_query_proto_msgTypes = make([]protoimpl.MessageInfo, 4) +var file_cosmos_consensus_v1_query_proto_msgTypes = make([]protoimpl.MessageInfo, 2) var file_cosmos_consensus_v1_query_proto_goTypes = []interface{}{ - (*QueryGetCometInfoRequest)(nil), // 0: cosmos.consensus.v1.QueryGetCometInfoRequest - (*QueryGetCometInfoResponse)(nil), // 1: cosmos.consensus.v1.QueryGetCometInfoResponse - (*QueryParamsRequest)(nil), // 2: cosmos.consensus.v1.QueryParamsRequest - (*QueryParamsResponse)(nil), // 3: cosmos.consensus.v1.QueryParamsResponse - (*CometInfo)(nil), // 4: cosmos.consensus.v1.CometInfo - (*v1.ConsensusParams)(nil), // 5: cometbft.types.v1.ConsensusParams + (*QueryParamsRequest)(nil), // 0: cosmos.consensus.v1.QueryParamsRequest + (*QueryParamsResponse)(nil), // 1: cosmos.consensus.v1.QueryParamsResponse + (*v1.ConsensusParams)(nil), // 2: cometbft.types.v1.ConsensusParams } var file_cosmos_consensus_v1_query_proto_depIdxs = []int32{ - 4, // 0: cosmos.consensus.v1.QueryGetCometInfoResponse.comet_info:type_name -> cosmos.consensus.v1.CometInfo - 5, // 1: cosmos.consensus.v1.QueryParamsResponse.params:type_name -> cometbft.types.v1.ConsensusParams - 2, // 2: cosmos.consensus.v1.Query.Params:input_type -> cosmos.consensus.v1.QueryParamsRequest - 0, // 3: cosmos.consensus.v1.Query.GetCometInfo:input_type -> cosmos.consensus.v1.QueryGetCometInfoRequest - 3, // 4: cosmos.consensus.v1.Query.Params:output_type -> cosmos.consensus.v1.QueryParamsResponse - 1, // 5: cosmos.consensus.v1.Query.GetCometInfo:output_type -> cosmos.consensus.v1.QueryGetCometInfoResponse - 4, // [4:6] is the sub-list for method output_type - 2, // [2:4] is the sub-list for method input_type - 2, // [2:2] is the sub-list for extension type_name - 2, // [2:2] is the sub-list for extension extendee - 0, // [0:2] is the sub-list for field type_name + 2, // 0: cosmos.consensus.v1.QueryParamsResponse.params:type_name -> cometbft.types.v1.ConsensusParams + 0, // 1: cosmos.consensus.v1.Query.Params:input_type -> cosmos.consensus.v1.QueryParamsRequest + 1, // 2: cosmos.consensus.v1.Query.Params:output_type -> cosmos.consensus.v1.QueryParamsResponse + 2, // [2:3] is the sub-list for method output_type + 1, // [1:2] is the sub-list for method input_type + 1, // [1:1] is the sub-list for extension type_name + 1, // [1:1] is the sub-list for extension extendee + 0, // [0:1] is the sub-list for field type_name } func init() { file_cosmos_consensus_v1_query_proto_init() } @@ -1842,30 +966,6 @@ func file_cosmos_consensus_v1_query_proto_init() { file_cosmos_consensus_v1_consensus_proto_init() if !protoimpl.UnsafeEnabled { file_cosmos_consensus_v1_query_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*QueryGetCometInfoRequest); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_cosmos_consensus_v1_query_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*QueryGetCometInfoResponse); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_cosmos_consensus_v1_query_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*QueryParamsRequest); i { case 0: return &v.state @@ -1877,7 +977,7 @@ func file_cosmos_consensus_v1_query_proto_init() { return nil } } - file_cosmos_consensus_v1_query_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} { + file_cosmos_consensus_v1_query_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*QueryParamsResponse); i { case 0: return &v.state @@ -1896,7 +996,7 @@ func file_cosmos_consensus_v1_query_proto_init() { GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: file_cosmos_consensus_v1_query_proto_rawDesc, NumEnums: 0, - NumMessages: 4, + NumMessages: 2, NumExtensions: 0, NumServices: 1, }, diff --git a/api/cosmos/consensus/v1/query_grpc.pb.go b/api/cosmos/consensus/v1/query_grpc.pb.go index ce898bd95251..03694d673fe9 100644 --- a/api/cosmos/consensus/v1/query_grpc.pb.go +++ b/api/cosmos/consensus/v1/query_grpc.pb.go @@ -21,8 +21,7 @@ import ( const _ = grpc.SupportPackageIsVersion7 const ( - Query_Params_FullMethodName = "/cosmos.consensus.v1.Query/Params" - Query_GetCometInfo_FullMethodName = "/cosmos.consensus.v1.Query/GetCometInfo" + Query_Params_FullMethodName = "/cosmos.consensus.v1.Query/Params" ) // QueryClient is the client API for Query service. @@ -31,8 +30,6 @@ const ( type QueryClient interface { // Params queries the parameters of x/consensus module. Params(ctx context.Context, in *QueryParamsRequest, opts ...grpc.CallOption) (*QueryParamsResponse, error) - // CometInfo queries the comet info of x/consensus module. - GetCometInfo(ctx context.Context, in *QueryGetCometInfoRequest, opts ...grpc.CallOption) (*QueryGetCometInfoResponse, error) } type queryClient struct { @@ -52,23 +49,12 @@ func (c *queryClient) Params(ctx context.Context, in *QueryParamsRequest, opts . return out, nil } -func (c *queryClient) GetCometInfo(ctx context.Context, in *QueryGetCometInfoRequest, opts ...grpc.CallOption) (*QueryGetCometInfoResponse, error) { - out := new(QueryGetCometInfoResponse) - err := c.cc.Invoke(ctx, Query_GetCometInfo_FullMethodName, in, out, opts...) - if err != nil { - return nil, err - } - return out, nil -} - // QueryServer is the server API for Query service. // All implementations must embed UnimplementedQueryServer // for forward compatibility type QueryServer interface { // Params queries the parameters of x/consensus module. Params(context.Context, *QueryParamsRequest) (*QueryParamsResponse, error) - // CometInfo queries the comet info of x/consensus module. - GetCometInfo(context.Context, *QueryGetCometInfoRequest) (*QueryGetCometInfoResponse, error) mustEmbedUnimplementedQueryServer() } @@ -79,9 +65,6 @@ type UnimplementedQueryServer struct { func (UnimplementedQueryServer) Params(context.Context, *QueryParamsRequest) (*QueryParamsResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method Params not implemented") } -func (UnimplementedQueryServer) GetCometInfo(context.Context, *QueryGetCometInfoRequest) (*QueryGetCometInfoResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method GetCometInfo not implemented") -} func (UnimplementedQueryServer) mustEmbedUnimplementedQueryServer() {} // UnsafeQueryServer may be embedded to opt out of forward compatibility for this service. @@ -113,24 +96,6 @@ func _Query_Params_Handler(srv interface{}, ctx context.Context, dec func(interf return interceptor(ctx, in, info, handler) } -func _Query_GetCometInfo_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(QueryGetCometInfoRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(QueryServer).GetCometInfo(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: Query_GetCometInfo_FullMethodName, - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(QueryServer).GetCometInfo(ctx, req.(*QueryGetCometInfoRequest)) - } - return interceptor(ctx, in, info, handler) -} - // Query_ServiceDesc is the grpc.ServiceDesc for Query service. // It's only intended for direct use with grpc.RegisterService, // and not to be introspected or modified (even as a copy) @@ -142,10 +107,6 @@ var Query_ServiceDesc = grpc.ServiceDesc{ MethodName: "Params", Handler: _Query_Params_Handler, }, - { - MethodName: "GetCometInfo", - Handler: _Query_GetCometInfo_Handler, - }, }, Streams: []grpc.StreamDesc{}, Metadata: "cosmos/consensus/v1/query.proto", diff --git a/api/cosmos/consensus/v1/tx.pulsar.go b/api/cosmos/consensus/v1/tx.pulsar.go index def6529fc167..12e85d0769b4 100644 --- a/api/cosmos/consensus/v1/tx.pulsar.go +++ b/api/cosmos/consensus/v1/tx.pulsar.go @@ -2,7 +2,7 @@ package consensusv1 import ( - v11 "buf.build/gen/go/cometbft/cometbft/protocolbuffers/go/cometbft/abci/v1" + _ "buf.build/gen/go/cometbft/cometbft/protocolbuffers/go/cometbft/abci/v1" v1 "buf.build/gen/go/cometbft/cometbft/protocolbuffers/go/cometbft/types/v1" _ "cosmossdk.io/api/amino" _ "cosmossdk.io/api/cosmos/msg/v1" @@ -1267,1131 +1267,6 @@ func (x *fastReflection_MsgUpdateParamsResponse) ProtoMethods() *protoiface.Meth } } -var _ protoreflect.List = (*_MsgSetCometInfo_2_list)(nil) - -type _MsgSetCometInfo_2_list struct { - list *[]*v11.Misbehavior -} - -func (x *_MsgSetCometInfo_2_list) Len() int { - if x.list == nil { - return 0 - } - return len(*x.list) -} - -func (x *_MsgSetCometInfo_2_list) Get(i int) protoreflect.Value { - return protoreflect.ValueOfMessage((*x.list)[i].ProtoReflect()) -} - -func (x *_MsgSetCometInfo_2_list) Set(i int, value protoreflect.Value) { - valueUnwrapped := value.Message() - concreteValue := valueUnwrapped.Interface().(*v11.Misbehavior) - (*x.list)[i] = concreteValue -} - -func (x *_MsgSetCometInfo_2_list) Append(value protoreflect.Value) { - valueUnwrapped := value.Message() - concreteValue := valueUnwrapped.Interface().(*v11.Misbehavior) - *x.list = append(*x.list, concreteValue) -} - -func (x *_MsgSetCometInfo_2_list) AppendMutable() protoreflect.Value { - v := new(v11.Misbehavior) - *x.list = append(*x.list, v) - return protoreflect.ValueOfMessage(v.ProtoReflect()) -} - -func (x *_MsgSetCometInfo_2_list) Truncate(n int) { - for i := n; i < len(*x.list); i++ { - (*x.list)[i] = nil - } - *x.list = (*x.list)[:n] -} - -func (x *_MsgSetCometInfo_2_list) NewElement() protoreflect.Value { - v := new(v11.Misbehavior) - return protoreflect.ValueOfMessage(v.ProtoReflect()) -} - -func (x *_MsgSetCometInfo_2_list) IsValid() bool { - return x.list != nil -} - -var ( - md_MsgSetCometInfo protoreflect.MessageDescriptor - fd_MsgSetCometInfo_authority protoreflect.FieldDescriptor - fd_MsgSetCometInfo_evidence protoreflect.FieldDescriptor - fd_MsgSetCometInfo_validators_hash protoreflect.FieldDescriptor - fd_MsgSetCometInfo_proposer_address protoreflect.FieldDescriptor - fd_MsgSetCometInfo_last_commit protoreflect.FieldDescriptor -) - -func init() { - file_cosmos_consensus_v1_tx_proto_init() - md_MsgSetCometInfo = File_cosmos_consensus_v1_tx_proto.Messages().ByName("MsgSetCometInfo") - fd_MsgSetCometInfo_authority = md_MsgSetCometInfo.Fields().ByName("authority") - fd_MsgSetCometInfo_evidence = md_MsgSetCometInfo.Fields().ByName("evidence") - fd_MsgSetCometInfo_validators_hash = md_MsgSetCometInfo.Fields().ByName("validators_hash") - fd_MsgSetCometInfo_proposer_address = md_MsgSetCometInfo.Fields().ByName("proposer_address") - fd_MsgSetCometInfo_last_commit = md_MsgSetCometInfo.Fields().ByName("last_commit") -} - -var _ protoreflect.Message = (*fastReflection_MsgSetCometInfo)(nil) - -type fastReflection_MsgSetCometInfo MsgSetCometInfo - -func (x *MsgSetCometInfo) ProtoReflect() protoreflect.Message { - return (*fastReflection_MsgSetCometInfo)(x) -} - -func (x *MsgSetCometInfo) slowProtoReflect() protoreflect.Message { - mi := &file_cosmos_consensus_v1_tx_proto_msgTypes[2] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -var _fastReflection_MsgSetCometInfo_messageType fastReflection_MsgSetCometInfo_messageType -var _ protoreflect.MessageType = fastReflection_MsgSetCometInfo_messageType{} - -type fastReflection_MsgSetCometInfo_messageType struct{} - -func (x fastReflection_MsgSetCometInfo_messageType) Zero() protoreflect.Message { - return (*fastReflection_MsgSetCometInfo)(nil) -} -func (x fastReflection_MsgSetCometInfo_messageType) New() protoreflect.Message { - return new(fastReflection_MsgSetCometInfo) -} -func (x fastReflection_MsgSetCometInfo_messageType) Descriptor() protoreflect.MessageDescriptor { - return md_MsgSetCometInfo -} - -// Descriptor returns message descriptor, which contains only the protobuf -// type information for the message. -func (x *fastReflection_MsgSetCometInfo) Descriptor() protoreflect.MessageDescriptor { - return md_MsgSetCometInfo -} - -// Type returns the message type, which encapsulates both Go and protobuf -// type information. If the Go type information is not needed, -// it is recommended that the message descriptor be used instead. -func (x *fastReflection_MsgSetCometInfo) Type() protoreflect.MessageType { - return _fastReflection_MsgSetCometInfo_messageType -} - -// New returns a newly allocated and mutable empty message. -func (x *fastReflection_MsgSetCometInfo) New() protoreflect.Message { - return new(fastReflection_MsgSetCometInfo) -} - -// Interface unwraps the message reflection interface and -// returns the underlying ProtoMessage interface. -func (x *fastReflection_MsgSetCometInfo) Interface() protoreflect.ProtoMessage { - return (*MsgSetCometInfo)(x) -} - -// Range iterates over every populated field in an undefined order, -// calling f for each field descriptor and value encountered. -// Range returns immediately if f returns false. -// While iterating, mutating operations may only be performed -// on the current field descriptor. -func (x *fastReflection_MsgSetCometInfo) Range(f func(protoreflect.FieldDescriptor, protoreflect.Value) bool) { - if x.Authority != "" { - value := protoreflect.ValueOfString(x.Authority) - if !f(fd_MsgSetCometInfo_authority, value) { - return - } - } - if len(x.Evidence) != 0 { - value := protoreflect.ValueOfList(&_MsgSetCometInfo_2_list{list: &x.Evidence}) - if !f(fd_MsgSetCometInfo_evidence, value) { - return - } - } - if len(x.ValidatorsHash) != 0 { - value := protoreflect.ValueOfBytes(x.ValidatorsHash) - if !f(fd_MsgSetCometInfo_validators_hash, value) { - return - } - } - if len(x.ProposerAddress) != 0 { - value := protoreflect.ValueOfBytes(x.ProposerAddress) - if !f(fd_MsgSetCometInfo_proposer_address, value) { - return - } - } - if x.LastCommit != nil { - value := protoreflect.ValueOfMessage(x.LastCommit.ProtoReflect()) - if !f(fd_MsgSetCometInfo_last_commit, value) { - return - } - } -} - -// Has reports whether a field is populated. -// -// Some fields have the property of nullability where it is possible to -// distinguish between the default value of a field and whether the field -// was explicitly populated with the default value. Singular message fields, -// member fields of a oneof, and proto2 scalar fields are nullable. Such -// fields are populated only if explicitly set. -// -// In other cases (aside from the nullable cases above), -// a proto3 scalar field is populated if it contains a non-zero value, and -// a repeated field is populated if it is non-empty. -func (x *fastReflection_MsgSetCometInfo) Has(fd protoreflect.FieldDescriptor) bool { - switch fd.FullName() { - case "cosmos.consensus.v1.MsgSetCometInfo.authority": - return x.Authority != "" - case "cosmos.consensus.v1.MsgSetCometInfo.evidence": - return len(x.Evidence) != 0 - case "cosmos.consensus.v1.MsgSetCometInfo.validators_hash": - return len(x.ValidatorsHash) != 0 - case "cosmos.consensus.v1.MsgSetCometInfo.proposer_address": - return len(x.ProposerAddress) != 0 - case "cosmos.consensus.v1.MsgSetCometInfo.last_commit": - return x.LastCommit != nil - default: - if fd.IsExtension() { - panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.consensus.v1.MsgSetCometInfo")) - } - panic(fmt.Errorf("message cosmos.consensus.v1.MsgSetCometInfo does not contain field %s", fd.FullName())) - } -} - -// Clear clears the field such that a subsequent Has call reports false. -// -// Clearing an extension field clears both the extension type and value -// associated with the given field number. -// -// Clear is a mutating operation and unsafe for concurrent use. -func (x *fastReflection_MsgSetCometInfo) Clear(fd protoreflect.FieldDescriptor) { - switch fd.FullName() { - case "cosmos.consensus.v1.MsgSetCometInfo.authority": - x.Authority = "" - case "cosmos.consensus.v1.MsgSetCometInfo.evidence": - x.Evidence = nil - case "cosmos.consensus.v1.MsgSetCometInfo.validators_hash": - x.ValidatorsHash = nil - case "cosmos.consensus.v1.MsgSetCometInfo.proposer_address": - x.ProposerAddress = nil - case "cosmos.consensus.v1.MsgSetCometInfo.last_commit": - x.LastCommit = nil - default: - if fd.IsExtension() { - panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.consensus.v1.MsgSetCometInfo")) - } - panic(fmt.Errorf("message cosmos.consensus.v1.MsgSetCometInfo does not contain field %s", fd.FullName())) - } -} - -// Get retrieves the value for a field. -// -// For unpopulated scalars, it returns the default value, where -// the default value of a bytes scalar is guaranteed to be a copy. -// For unpopulated composite types, it returns an empty, read-only view -// of the value; to obtain a mutable reference, use Mutable. -func (x *fastReflection_MsgSetCometInfo) Get(descriptor protoreflect.FieldDescriptor) protoreflect.Value { - switch descriptor.FullName() { - case "cosmos.consensus.v1.MsgSetCometInfo.authority": - value := x.Authority - return protoreflect.ValueOfString(value) - case "cosmos.consensus.v1.MsgSetCometInfo.evidence": - if len(x.Evidence) == 0 { - return protoreflect.ValueOfList(&_MsgSetCometInfo_2_list{}) - } - listValue := &_MsgSetCometInfo_2_list{list: &x.Evidence} - return protoreflect.ValueOfList(listValue) - case "cosmos.consensus.v1.MsgSetCometInfo.validators_hash": - value := x.ValidatorsHash - return protoreflect.ValueOfBytes(value) - case "cosmos.consensus.v1.MsgSetCometInfo.proposer_address": - value := x.ProposerAddress - return protoreflect.ValueOfBytes(value) - case "cosmos.consensus.v1.MsgSetCometInfo.last_commit": - value := x.LastCommit - return protoreflect.ValueOfMessage(value.ProtoReflect()) - default: - if descriptor.IsExtension() { - panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.consensus.v1.MsgSetCometInfo")) - } - panic(fmt.Errorf("message cosmos.consensus.v1.MsgSetCometInfo does not contain field %s", descriptor.FullName())) - } -} - -// Set stores the value for a field. -// -// For a field belonging to a oneof, it implicitly clears any other field -// that may be currently set within the same oneof. -// For extension fields, it implicitly stores the provided ExtensionType. -// When setting a composite type, it is unspecified whether the stored value -// aliases the source's memory in any way. If the composite value is an -// empty, read-only value, then it panics. -// -// Set is a mutating operation and unsafe for concurrent use. -func (x *fastReflection_MsgSetCometInfo) Set(fd protoreflect.FieldDescriptor, value protoreflect.Value) { - switch fd.FullName() { - case "cosmos.consensus.v1.MsgSetCometInfo.authority": - x.Authority = value.Interface().(string) - case "cosmos.consensus.v1.MsgSetCometInfo.evidence": - lv := value.List() - clv := lv.(*_MsgSetCometInfo_2_list) - x.Evidence = *clv.list - case "cosmos.consensus.v1.MsgSetCometInfo.validators_hash": - x.ValidatorsHash = value.Bytes() - case "cosmos.consensus.v1.MsgSetCometInfo.proposer_address": - x.ProposerAddress = value.Bytes() - case "cosmos.consensus.v1.MsgSetCometInfo.last_commit": - x.LastCommit = value.Message().Interface().(*v11.CommitInfo) - default: - if fd.IsExtension() { - panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.consensus.v1.MsgSetCometInfo")) - } - panic(fmt.Errorf("message cosmos.consensus.v1.MsgSetCometInfo does not contain field %s", fd.FullName())) - } -} - -// Mutable returns a mutable reference to a composite type. -// -// If the field is unpopulated, it may allocate a composite value. -// For a field belonging to a oneof, it implicitly clears any other field -// that may be currently set within the same oneof. -// For extension fields, it implicitly stores the provided ExtensionType -// if not already stored. -// It panics if the field does not contain a composite type. -// -// Mutable is a mutating operation and unsafe for concurrent use. -func (x *fastReflection_MsgSetCometInfo) Mutable(fd protoreflect.FieldDescriptor) protoreflect.Value { - switch fd.FullName() { - case "cosmos.consensus.v1.MsgSetCometInfo.evidence": - if x.Evidence == nil { - x.Evidence = []*v11.Misbehavior{} - } - value := &_MsgSetCometInfo_2_list{list: &x.Evidence} - return protoreflect.ValueOfList(value) - case "cosmos.consensus.v1.MsgSetCometInfo.last_commit": - if x.LastCommit == nil { - x.LastCommit = new(v11.CommitInfo) - } - return protoreflect.ValueOfMessage(x.LastCommit.ProtoReflect()) - case "cosmos.consensus.v1.MsgSetCometInfo.authority": - panic(fmt.Errorf("field authority of message cosmos.consensus.v1.MsgSetCometInfo is not mutable")) - case "cosmos.consensus.v1.MsgSetCometInfo.validators_hash": - panic(fmt.Errorf("field validators_hash of message cosmos.consensus.v1.MsgSetCometInfo is not mutable")) - case "cosmos.consensus.v1.MsgSetCometInfo.proposer_address": - panic(fmt.Errorf("field proposer_address of message cosmos.consensus.v1.MsgSetCometInfo is not mutable")) - default: - if fd.IsExtension() { - panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.consensus.v1.MsgSetCometInfo")) - } - panic(fmt.Errorf("message cosmos.consensus.v1.MsgSetCometInfo does not contain field %s", fd.FullName())) - } -} - -// NewField returns a new value that is assignable to the field -// for the given descriptor. For scalars, this returns the default value. -// For lists, maps, and messages, this returns a new, empty, mutable value. -func (x *fastReflection_MsgSetCometInfo) NewField(fd protoreflect.FieldDescriptor) protoreflect.Value { - switch fd.FullName() { - case "cosmos.consensus.v1.MsgSetCometInfo.authority": - return protoreflect.ValueOfString("") - case "cosmos.consensus.v1.MsgSetCometInfo.evidence": - list := []*v11.Misbehavior{} - return protoreflect.ValueOfList(&_MsgSetCometInfo_2_list{list: &list}) - case "cosmos.consensus.v1.MsgSetCometInfo.validators_hash": - return protoreflect.ValueOfBytes(nil) - case "cosmos.consensus.v1.MsgSetCometInfo.proposer_address": - return protoreflect.ValueOfBytes(nil) - case "cosmos.consensus.v1.MsgSetCometInfo.last_commit": - m := new(v11.CommitInfo) - return protoreflect.ValueOfMessage(m.ProtoReflect()) - default: - if fd.IsExtension() { - panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.consensus.v1.MsgSetCometInfo")) - } - panic(fmt.Errorf("message cosmos.consensus.v1.MsgSetCometInfo does not contain field %s", fd.FullName())) - } -} - -// WhichOneof reports which field within the oneof is populated, -// returning nil if none are populated. -// It panics if the oneof descriptor does not belong to this message. -func (x *fastReflection_MsgSetCometInfo) WhichOneof(d protoreflect.OneofDescriptor) protoreflect.FieldDescriptor { - switch d.FullName() { - default: - panic(fmt.Errorf("%s is not a oneof field in cosmos.consensus.v1.MsgSetCometInfo", d.FullName())) - } - panic("unreachable") -} - -// GetUnknown retrieves the entire list of unknown fields. -// The caller may only mutate the contents of the RawFields -// if the mutated bytes are stored back into the message with SetUnknown. -func (x *fastReflection_MsgSetCometInfo) GetUnknown() protoreflect.RawFields { - return x.unknownFields -} - -// SetUnknown stores an entire list of unknown fields. -// The raw fields must be syntactically valid according to the wire format. -// An implementation may panic if this is not the case. -// Once stored, the caller must not mutate the content of the RawFields. -// An empty RawFields may be passed to clear the fields. -// -// SetUnknown is a mutating operation and unsafe for concurrent use. -func (x *fastReflection_MsgSetCometInfo) SetUnknown(fields protoreflect.RawFields) { - x.unknownFields = fields -} - -// IsValid reports whether the message is valid. -// -// An invalid message is an empty, read-only value. -// -// An invalid message often corresponds to a nil pointer of the concrete -// message type, but the details are implementation dependent. -// Validity is not part of the protobuf data model, and may not -// be preserved in marshaling or other operations. -func (x *fastReflection_MsgSetCometInfo) IsValid() bool { - return x != nil -} - -// ProtoMethods returns optional fastReflectionFeature-path implementations of various operations. -// This method may return nil. -// -// The returned methods type is identical to -// "google.golang.org/protobuf/runtime/protoiface".Methods. -// Consult the protoiface package documentation for details. -func (x *fastReflection_MsgSetCometInfo) ProtoMethods() *protoiface.Methods { - size := func(input protoiface.SizeInput) protoiface.SizeOutput { - x := input.Message.Interface().(*MsgSetCometInfo) - if x == nil { - return protoiface.SizeOutput{ - NoUnkeyedLiterals: input.NoUnkeyedLiterals, - Size: 0, - } - } - options := runtime.SizeInputToOptions(input) - _ = options - var n int - var l int - _ = l - l = len(x.Authority) - if l > 0 { - n += 1 + l + runtime.Sov(uint64(l)) - } - if len(x.Evidence) > 0 { - for _, e := range x.Evidence { - l = options.Size(e) - n += 1 + l + runtime.Sov(uint64(l)) - } - } - l = len(x.ValidatorsHash) - if l > 0 { - n += 1 + l + runtime.Sov(uint64(l)) - } - l = len(x.ProposerAddress) - if l > 0 { - n += 1 + l + runtime.Sov(uint64(l)) - } - if x.LastCommit != nil { - l = options.Size(x.LastCommit) - n += 1 + l + runtime.Sov(uint64(l)) - } - if x.unknownFields != nil { - n += len(x.unknownFields) - } - return protoiface.SizeOutput{ - NoUnkeyedLiterals: input.NoUnkeyedLiterals, - Size: n, - } - } - - marshal := func(input protoiface.MarshalInput) (protoiface.MarshalOutput, error) { - x := input.Message.Interface().(*MsgSetCometInfo) - if x == nil { - return protoiface.MarshalOutput{ - NoUnkeyedLiterals: input.NoUnkeyedLiterals, - Buf: input.Buf, - }, nil - } - options := runtime.MarshalInputToOptions(input) - _ = options - size := options.Size(x) - dAtA := make([]byte, size) - i := len(dAtA) - _ = i - var l int - _ = l - if x.unknownFields != nil { - i -= len(x.unknownFields) - copy(dAtA[i:], x.unknownFields) - } - if x.LastCommit != nil { - encoded, err := options.Marshal(x.LastCommit) - if err != nil { - return protoiface.MarshalOutput{ - NoUnkeyedLiterals: input.NoUnkeyedLiterals, - Buf: input.Buf, - }, err - } - i -= len(encoded) - copy(dAtA[i:], encoded) - i = runtime.EncodeVarint(dAtA, i, uint64(len(encoded))) - i-- - dAtA[i] = 0x2a - } - if len(x.ProposerAddress) > 0 { - i -= len(x.ProposerAddress) - copy(dAtA[i:], x.ProposerAddress) - i = runtime.EncodeVarint(dAtA, i, uint64(len(x.ProposerAddress))) - i-- - dAtA[i] = 0x22 - } - if len(x.ValidatorsHash) > 0 { - i -= len(x.ValidatorsHash) - copy(dAtA[i:], x.ValidatorsHash) - i = runtime.EncodeVarint(dAtA, i, uint64(len(x.ValidatorsHash))) - i-- - dAtA[i] = 0x1a - } - if len(x.Evidence) > 0 { - for iNdEx := len(x.Evidence) - 1; iNdEx >= 0; iNdEx-- { - encoded, err := options.Marshal(x.Evidence[iNdEx]) - if err != nil { - return protoiface.MarshalOutput{ - NoUnkeyedLiterals: input.NoUnkeyedLiterals, - Buf: input.Buf, - }, err - } - i -= len(encoded) - copy(dAtA[i:], encoded) - i = runtime.EncodeVarint(dAtA, i, uint64(len(encoded))) - i-- - dAtA[i] = 0x12 - } - } - if len(x.Authority) > 0 { - i -= len(x.Authority) - copy(dAtA[i:], x.Authority) - i = runtime.EncodeVarint(dAtA, i, uint64(len(x.Authority))) - i-- - dAtA[i] = 0xa - } - if input.Buf != nil { - input.Buf = append(input.Buf, dAtA...) - } else { - input.Buf = dAtA - } - return protoiface.MarshalOutput{ - NoUnkeyedLiterals: input.NoUnkeyedLiterals, - Buf: input.Buf, - }, nil - } - unmarshal := func(input protoiface.UnmarshalInput) (protoiface.UnmarshalOutput, error) { - x := input.Message.Interface().(*MsgSetCometInfo) - if x == nil { - return protoiface.UnmarshalOutput{ - NoUnkeyedLiterals: input.NoUnkeyedLiterals, - Flags: input.Flags, - }, nil - } - options := runtime.UnmarshalInputToOptions(input) - _ = options - dAtA := input.Buf - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrIntOverflow - } - if iNdEx >= l { - return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: MsgSetCometInfo: wiretype end group for non-group") - } - if fieldNum <= 0 { - return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: MsgSetCometInfo: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: wrong wireType = %d for field Authority", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrIntOverflow - } - if iNdEx >= l { - return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength - } - if postIndex > l { - return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF - } - x.Authority = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 2: - if wireType != 2 { - return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: wrong wireType = %d for field Evidence", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrIntOverflow - } - if iNdEx >= l { - return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength - } - if postIndex > l { - return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF - } - x.Evidence = append(x.Evidence, &v11.Misbehavior{}) - if err := options.Unmarshal(dAtA[iNdEx:postIndex], x.Evidence[len(x.Evidence)-1]); err != nil { - return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, err - } - iNdEx = postIndex - case 3: - if wireType != 2 { - return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: wrong wireType = %d for field ValidatorsHash", wireType) - } - var byteLen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrIntOverflow - } - if iNdEx >= l { - return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - byteLen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if byteLen < 0 { - return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength - } - postIndex := iNdEx + byteLen - if postIndex < 0 { - return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength - } - if postIndex > l { - return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF - } - x.ValidatorsHash = append(x.ValidatorsHash[:0], dAtA[iNdEx:postIndex]...) - if x.ValidatorsHash == nil { - x.ValidatorsHash = []byte{} - } - iNdEx = postIndex - case 4: - if wireType != 2 { - return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: wrong wireType = %d for field ProposerAddress", wireType) - } - var byteLen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrIntOverflow - } - if iNdEx >= l { - return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - byteLen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if byteLen < 0 { - return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength - } - postIndex := iNdEx + byteLen - if postIndex < 0 { - return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength - } - if postIndex > l { - return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF - } - x.ProposerAddress = append(x.ProposerAddress[:0], dAtA[iNdEx:postIndex]...) - if x.ProposerAddress == nil { - x.ProposerAddress = []byte{} - } - iNdEx = postIndex - case 5: - if wireType != 2 { - return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: wrong wireType = %d for field LastCommit", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrIntOverflow - } - if iNdEx >= l { - return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength - } - if postIndex > l { - return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF - } - if x.LastCommit == nil { - x.LastCommit = &v11.CommitInfo{} - } - if err := options.Unmarshal(dAtA[iNdEx:postIndex], x.LastCommit); err != nil { - return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, err - } - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := runtime.Skip(dAtA[iNdEx:]) - if err != nil { - return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength - } - if (iNdEx + skippy) > l { - return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF - } - if !options.DiscardUnknown { - x.unknownFields = append(x.unknownFields, dAtA[iNdEx:iNdEx+skippy]...) - } - iNdEx += skippy - } - } - - if iNdEx > l { - return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF - } - return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, nil - } - return &protoiface.Methods{ - NoUnkeyedLiterals: struct{}{}, - Flags: protoiface.SupportMarshalDeterministic | protoiface.SupportUnmarshalDiscardUnknown, - Size: size, - Marshal: marshal, - Unmarshal: unmarshal, - Merge: nil, - CheckInitialized: nil, - } -} - -var ( - md_MsgSetCometInfoResponse protoreflect.MessageDescriptor -) - -func init() { - file_cosmos_consensus_v1_tx_proto_init() - md_MsgSetCometInfoResponse = File_cosmos_consensus_v1_tx_proto.Messages().ByName("MsgSetCometInfoResponse") -} - -var _ protoreflect.Message = (*fastReflection_MsgSetCometInfoResponse)(nil) - -type fastReflection_MsgSetCometInfoResponse MsgSetCometInfoResponse - -func (x *MsgSetCometInfoResponse) ProtoReflect() protoreflect.Message { - return (*fastReflection_MsgSetCometInfoResponse)(x) -} - -func (x *MsgSetCometInfoResponse) slowProtoReflect() protoreflect.Message { - mi := &file_cosmos_consensus_v1_tx_proto_msgTypes[3] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -var _fastReflection_MsgSetCometInfoResponse_messageType fastReflection_MsgSetCometInfoResponse_messageType -var _ protoreflect.MessageType = fastReflection_MsgSetCometInfoResponse_messageType{} - -type fastReflection_MsgSetCometInfoResponse_messageType struct{} - -func (x fastReflection_MsgSetCometInfoResponse_messageType) Zero() protoreflect.Message { - return (*fastReflection_MsgSetCometInfoResponse)(nil) -} -func (x fastReflection_MsgSetCometInfoResponse_messageType) New() protoreflect.Message { - return new(fastReflection_MsgSetCometInfoResponse) -} -func (x fastReflection_MsgSetCometInfoResponse_messageType) Descriptor() protoreflect.MessageDescriptor { - return md_MsgSetCometInfoResponse -} - -// Descriptor returns message descriptor, which contains only the protobuf -// type information for the message. -func (x *fastReflection_MsgSetCometInfoResponse) Descriptor() protoreflect.MessageDescriptor { - return md_MsgSetCometInfoResponse -} - -// Type returns the message type, which encapsulates both Go and protobuf -// type information. If the Go type information is not needed, -// it is recommended that the message descriptor be used instead. -func (x *fastReflection_MsgSetCometInfoResponse) Type() protoreflect.MessageType { - return _fastReflection_MsgSetCometInfoResponse_messageType -} - -// New returns a newly allocated and mutable empty message. -func (x *fastReflection_MsgSetCometInfoResponse) New() protoreflect.Message { - return new(fastReflection_MsgSetCometInfoResponse) -} - -// Interface unwraps the message reflection interface and -// returns the underlying ProtoMessage interface. -func (x *fastReflection_MsgSetCometInfoResponse) Interface() protoreflect.ProtoMessage { - return (*MsgSetCometInfoResponse)(x) -} - -// Range iterates over every populated field in an undefined order, -// calling f for each field descriptor and value encountered. -// Range returns immediately if f returns false. -// While iterating, mutating operations may only be performed -// on the current field descriptor. -func (x *fastReflection_MsgSetCometInfoResponse) Range(f func(protoreflect.FieldDescriptor, protoreflect.Value) bool) { -} - -// Has reports whether a field is populated. -// -// Some fields have the property of nullability where it is possible to -// distinguish between the default value of a field and whether the field -// was explicitly populated with the default value. Singular message fields, -// member fields of a oneof, and proto2 scalar fields are nullable. Such -// fields are populated only if explicitly set. -// -// In other cases (aside from the nullable cases above), -// a proto3 scalar field is populated if it contains a non-zero value, and -// a repeated field is populated if it is non-empty. -func (x *fastReflection_MsgSetCometInfoResponse) Has(fd protoreflect.FieldDescriptor) bool { - switch fd.FullName() { - default: - if fd.IsExtension() { - panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.consensus.v1.MsgSetCometInfoResponse")) - } - panic(fmt.Errorf("message cosmos.consensus.v1.MsgSetCometInfoResponse does not contain field %s", fd.FullName())) - } -} - -// Clear clears the field such that a subsequent Has call reports false. -// -// Clearing an extension field clears both the extension type and value -// associated with the given field number. -// -// Clear is a mutating operation and unsafe for concurrent use. -func (x *fastReflection_MsgSetCometInfoResponse) Clear(fd protoreflect.FieldDescriptor) { - switch fd.FullName() { - default: - if fd.IsExtension() { - panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.consensus.v1.MsgSetCometInfoResponse")) - } - panic(fmt.Errorf("message cosmos.consensus.v1.MsgSetCometInfoResponse does not contain field %s", fd.FullName())) - } -} - -// Get retrieves the value for a field. -// -// For unpopulated scalars, it returns the default value, where -// the default value of a bytes scalar is guaranteed to be a copy. -// For unpopulated composite types, it returns an empty, read-only view -// of the value; to obtain a mutable reference, use Mutable. -func (x *fastReflection_MsgSetCometInfoResponse) Get(descriptor protoreflect.FieldDescriptor) protoreflect.Value { - switch descriptor.FullName() { - default: - if descriptor.IsExtension() { - panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.consensus.v1.MsgSetCometInfoResponse")) - } - panic(fmt.Errorf("message cosmos.consensus.v1.MsgSetCometInfoResponse does not contain field %s", descriptor.FullName())) - } -} - -// Set stores the value for a field. -// -// For a field belonging to a oneof, it implicitly clears any other field -// that may be currently set within the same oneof. -// For extension fields, it implicitly stores the provided ExtensionType. -// When setting a composite type, it is unspecified whether the stored value -// aliases the source's memory in any way. If the composite value is an -// empty, read-only value, then it panics. -// -// Set is a mutating operation and unsafe for concurrent use. -func (x *fastReflection_MsgSetCometInfoResponse) Set(fd protoreflect.FieldDescriptor, value protoreflect.Value) { - switch fd.FullName() { - default: - if fd.IsExtension() { - panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.consensus.v1.MsgSetCometInfoResponse")) - } - panic(fmt.Errorf("message cosmos.consensus.v1.MsgSetCometInfoResponse does not contain field %s", fd.FullName())) - } -} - -// Mutable returns a mutable reference to a composite type. -// -// If the field is unpopulated, it may allocate a composite value. -// For a field belonging to a oneof, it implicitly clears any other field -// that may be currently set within the same oneof. -// For extension fields, it implicitly stores the provided ExtensionType -// if not already stored. -// It panics if the field does not contain a composite type. -// -// Mutable is a mutating operation and unsafe for concurrent use. -func (x *fastReflection_MsgSetCometInfoResponse) Mutable(fd protoreflect.FieldDescriptor) protoreflect.Value { - switch fd.FullName() { - default: - if fd.IsExtension() { - panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.consensus.v1.MsgSetCometInfoResponse")) - } - panic(fmt.Errorf("message cosmos.consensus.v1.MsgSetCometInfoResponse does not contain field %s", fd.FullName())) - } -} - -// NewField returns a new value that is assignable to the field -// for the given descriptor. For scalars, this returns the default value. -// For lists, maps, and messages, this returns a new, empty, mutable value. -func (x *fastReflection_MsgSetCometInfoResponse) NewField(fd protoreflect.FieldDescriptor) protoreflect.Value { - switch fd.FullName() { - default: - if fd.IsExtension() { - panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.consensus.v1.MsgSetCometInfoResponse")) - } - panic(fmt.Errorf("message cosmos.consensus.v1.MsgSetCometInfoResponse does not contain field %s", fd.FullName())) - } -} - -// WhichOneof reports which field within the oneof is populated, -// returning nil if none are populated. -// It panics if the oneof descriptor does not belong to this message. -func (x *fastReflection_MsgSetCometInfoResponse) WhichOneof(d protoreflect.OneofDescriptor) protoreflect.FieldDescriptor { - switch d.FullName() { - default: - panic(fmt.Errorf("%s is not a oneof field in cosmos.consensus.v1.MsgSetCometInfoResponse", d.FullName())) - } - panic("unreachable") -} - -// GetUnknown retrieves the entire list of unknown fields. -// The caller may only mutate the contents of the RawFields -// if the mutated bytes are stored back into the message with SetUnknown. -func (x *fastReflection_MsgSetCometInfoResponse) GetUnknown() protoreflect.RawFields { - return x.unknownFields -} - -// SetUnknown stores an entire list of unknown fields. -// The raw fields must be syntactically valid according to the wire format. -// An implementation may panic if this is not the case. -// Once stored, the caller must not mutate the content of the RawFields. -// An empty RawFields may be passed to clear the fields. -// -// SetUnknown is a mutating operation and unsafe for concurrent use. -func (x *fastReflection_MsgSetCometInfoResponse) SetUnknown(fields protoreflect.RawFields) { - x.unknownFields = fields -} - -// IsValid reports whether the message is valid. -// -// An invalid message is an empty, read-only value. -// -// An invalid message often corresponds to a nil pointer of the concrete -// message type, but the details are implementation dependent. -// Validity is not part of the protobuf data model, and may not -// be preserved in marshaling or other operations. -func (x *fastReflection_MsgSetCometInfoResponse) IsValid() bool { - return x != nil -} - -// ProtoMethods returns optional fastReflectionFeature-path implementations of various operations. -// This method may return nil. -// -// The returned methods type is identical to -// "google.golang.org/protobuf/runtime/protoiface".Methods. -// Consult the protoiface package documentation for details. -func (x *fastReflection_MsgSetCometInfoResponse) ProtoMethods() *protoiface.Methods { - size := func(input protoiface.SizeInput) protoiface.SizeOutput { - x := input.Message.Interface().(*MsgSetCometInfoResponse) - if x == nil { - return protoiface.SizeOutput{ - NoUnkeyedLiterals: input.NoUnkeyedLiterals, - Size: 0, - } - } - options := runtime.SizeInputToOptions(input) - _ = options - var n int - var l int - _ = l - if x.unknownFields != nil { - n += len(x.unknownFields) - } - return protoiface.SizeOutput{ - NoUnkeyedLiterals: input.NoUnkeyedLiterals, - Size: n, - } - } - - marshal := func(input protoiface.MarshalInput) (protoiface.MarshalOutput, error) { - x := input.Message.Interface().(*MsgSetCometInfoResponse) - if x == nil { - return protoiface.MarshalOutput{ - NoUnkeyedLiterals: input.NoUnkeyedLiterals, - Buf: input.Buf, - }, nil - } - options := runtime.MarshalInputToOptions(input) - _ = options - size := options.Size(x) - dAtA := make([]byte, size) - i := len(dAtA) - _ = i - var l int - _ = l - if x.unknownFields != nil { - i -= len(x.unknownFields) - copy(dAtA[i:], x.unknownFields) - } - if input.Buf != nil { - input.Buf = append(input.Buf, dAtA...) - } else { - input.Buf = dAtA - } - return protoiface.MarshalOutput{ - NoUnkeyedLiterals: input.NoUnkeyedLiterals, - Buf: input.Buf, - }, nil - } - unmarshal := func(input protoiface.UnmarshalInput) (protoiface.UnmarshalOutput, error) { - x := input.Message.Interface().(*MsgSetCometInfoResponse) - if x == nil { - return protoiface.UnmarshalOutput{ - NoUnkeyedLiterals: input.NoUnkeyedLiterals, - Flags: input.Flags, - }, nil - } - options := runtime.UnmarshalInputToOptions(input) - _ = options - dAtA := input.Buf - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrIntOverflow - } - if iNdEx >= l { - return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: MsgSetCometInfoResponse: wiretype end group for non-group") - } - if fieldNum <= 0 { - return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: MsgSetCometInfoResponse: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - default: - iNdEx = preIndex - skippy, err := runtime.Skip(dAtA[iNdEx:]) - if err != nil { - return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength - } - if (iNdEx + skippy) > l { - return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF - } - if !options.DiscardUnknown { - x.unknownFields = append(x.unknownFields, dAtA[iNdEx:iNdEx+skippy]...) - } - iNdEx += skippy - } - } - - if iNdEx > l { - return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF - } - return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, nil - } - return &protoiface.Methods{ - NoUnkeyedLiterals: struct{}{}, - Flags: protoiface.SupportMarshalDeterministic | protoiface.SupportUnmarshalDiscardUnknown, - Size: size, - Marshal: marshal, - Unmarshal: unmarshal, - Merge: nil, - CheckInitialized: nil, - } -} - // Since: cosmos-sdk 0.47 // Code generated by protoc-gen-go. DO NOT EDIT. @@ -2529,106 +1404,6 @@ func (*MsgUpdateParamsResponse) Descriptor() ([]byte, []int) { return file_cosmos_consensus_v1_tx_proto_rawDescGZIP(), []int{1} } -// MsgCometInfo is the Msg/CometInfo request type. -type MsgSetCometInfo struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - // authority is the address that controls the module (defaults to x/gov unless overwritten). - Authority string `protobuf:"bytes,1,opt,name=authority,proto3" json:"authority,omitempty"` - // evidence is the misbehaviour evidence to submit. - Evidence []*v11.Misbehavior `protobuf:"bytes,2,rep,name=evidence,proto3" json:"evidence,omitempty"` - // validators_hash is the hash of the current validator set. - ValidatorsHash []byte `protobuf:"bytes,3,opt,name=validators_hash,json=validatorsHash,proto3" json:"validators_hash,omitempty"` - // proposer_address is the address of the current proposer. - ProposerAddress []byte `protobuf:"bytes,4,opt,name=proposer_address,json=proposerAddress,proto3" json:"proposer_address,omitempty"` - // last_commit is the last commit info. - LastCommit *v11.CommitInfo `protobuf:"bytes,5,opt,name=last_commit,json=lastCommit,proto3" json:"last_commit,omitempty"` -} - -func (x *MsgSetCometInfo) Reset() { - *x = MsgSetCometInfo{} - if protoimpl.UnsafeEnabled { - mi := &file_cosmos_consensus_v1_tx_proto_msgTypes[2] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *MsgSetCometInfo) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*MsgSetCometInfo) ProtoMessage() {} - -// Deprecated: Use MsgSetCometInfo.ProtoReflect.Descriptor instead. -func (*MsgSetCometInfo) Descriptor() ([]byte, []int) { - return file_cosmos_consensus_v1_tx_proto_rawDescGZIP(), []int{2} -} - -func (x *MsgSetCometInfo) GetAuthority() string { - if x != nil { - return x.Authority - } - return "" -} - -func (x *MsgSetCometInfo) GetEvidence() []*v11.Misbehavior { - if x != nil { - return x.Evidence - } - return nil -} - -func (x *MsgSetCometInfo) GetValidatorsHash() []byte { - if x != nil { - return x.ValidatorsHash - } - return nil -} - -func (x *MsgSetCometInfo) GetProposerAddress() []byte { - if x != nil { - return x.ProposerAddress - } - return nil -} - -func (x *MsgSetCometInfo) GetLastCommit() *v11.CommitInfo { - if x != nil { - return x.LastCommit - } - return nil -} - -// MsgCometInfoResponse defines the response -type MsgSetCometInfoResponse struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields -} - -func (x *MsgSetCometInfoResponse) Reset() { - *x = MsgSetCometInfoResponse{} - if protoimpl.UnsafeEnabled { - mi := &file_cosmos_consensus_v1_tx_proto_msgTypes[3] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *MsgSetCometInfoResponse) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*MsgSetCometInfoResponse) ProtoMessage() {} - -// Deprecated: Use MsgSetCometInfoResponse.ProtoReflect.Descriptor instead. -func (*MsgSetCometInfoResponse) Descriptor() ([]byte, []int) { - return file_cosmos_consensus_v1_tx_proto_rawDescGZIP(), []int{3} -} - var File_cosmos_consensus_v1_tx_proto protoreflect.FileDescriptor var file_cosmos_consensus_v1_tx_proto_rawDesc = []byte{ @@ -2680,57 +1455,28 @@ var file_cosmos_consensus_v1_tx_proto_rawDesc = []byte{ 0x6f, 0x6e, 0x73, 0x65, 0x6e, 0x73, 0x75, 0x73, 0x2f, 0x4d, 0x73, 0x67, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x50, 0x61, 0x72, 0x61, 0x6d, 0x73, 0x22, 0x19, 0x0a, 0x17, 0x4d, 0x73, 0x67, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x50, 0x61, 0x72, 0x61, 0x6d, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, - 0x6e, 0x73, 0x65, 0x22, 0xcf, 0x02, 0x0a, 0x0f, 0x4d, 0x73, 0x67, 0x53, 0x65, 0x74, 0x43, 0x6f, - 0x6d, 0x65, 0x74, 0x49, 0x6e, 0x66, 0x6f, 0x12, 0x36, 0x0a, 0x09, 0x61, 0x75, 0x74, 0x68, 0x6f, - 0x72, 0x69, 0x74, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x42, 0x18, 0xd2, 0xb4, 0x2d, 0x14, - 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x41, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x53, 0x74, - 0x72, 0x69, 0x6e, 0x67, 0x52, 0x09, 0x61, 0x75, 0x74, 0x68, 0x6f, 0x72, 0x69, 0x74, 0x79, 0x12, - 0x39, 0x0a, 0x08, 0x65, 0x76, 0x69, 0x64, 0x65, 0x6e, 0x63, 0x65, 0x18, 0x02, 0x20, 0x03, 0x28, - 0x0b, 0x32, 0x1d, 0x2e, 0x63, 0x6f, 0x6d, 0x65, 0x74, 0x62, 0x66, 0x74, 0x2e, 0x61, 0x62, 0x63, - 0x69, 0x2e, 0x76, 0x31, 0x2e, 0x4d, 0x69, 0x73, 0x62, 0x65, 0x68, 0x61, 0x76, 0x69, 0x6f, 0x72, - 0x52, 0x08, 0x65, 0x76, 0x69, 0x64, 0x65, 0x6e, 0x63, 0x65, 0x12, 0x27, 0x0a, 0x0f, 0x76, 0x61, - 0x6c, 0x69, 0x64, 0x61, 0x74, 0x6f, 0x72, 0x73, 0x5f, 0x68, 0x61, 0x73, 0x68, 0x18, 0x03, 0x20, - 0x01, 0x28, 0x0c, 0x52, 0x0e, 0x76, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x6f, 0x72, 0x73, 0x48, - 0x61, 0x73, 0x68, 0x12, 0x29, 0x0a, 0x10, 0x70, 0x72, 0x6f, 0x70, 0x6f, 0x73, 0x65, 0x72, 0x5f, - 0x61, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x0f, 0x70, - 0x72, 0x6f, 0x70, 0x6f, 0x73, 0x65, 0x72, 0x41, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x12, 0x3d, - 0x0a, 0x0b, 0x6c, 0x61, 0x73, 0x74, 0x5f, 0x63, 0x6f, 0x6d, 0x6d, 0x69, 0x74, 0x18, 0x05, 0x20, - 0x01, 0x28, 0x0b, 0x32, 0x1c, 0x2e, 0x63, 0x6f, 0x6d, 0x65, 0x74, 0x62, 0x66, 0x74, 0x2e, 0x61, - 0x62, 0x63, 0x69, 0x2e, 0x76, 0x31, 0x2e, 0x43, 0x6f, 0x6d, 0x6d, 0x69, 0x74, 0x49, 0x6e, 0x66, - 0x6f, 0x52, 0x0a, 0x6c, 0x61, 0x73, 0x74, 0x43, 0x6f, 0x6d, 0x6d, 0x69, 0x74, 0x3a, 0x36, 0x82, - 0xe7, 0xb0, 0x2a, 0x09, 0x61, 0x75, 0x74, 0x68, 0x6f, 0x72, 0x69, 0x74, 0x79, 0x8a, 0xe7, 0xb0, - 0x2a, 0x23, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2d, 0x73, 0x64, 0x6b, 0x2f, 0x78, 0x2f, 0x63, - 0x6f, 0x6e, 0x73, 0x65, 0x6e, 0x73, 0x75, 0x73, 0x2f, 0x4d, 0x73, 0x67, 0x43, 0x6f, 0x6d, 0x65, - 0x74, 0x49, 0x6e, 0x66, 0x6f, 0x22, 0x19, 0x0a, 0x17, 0x4d, 0x73, 0x67, 0x53, 0x65, 0x74, 0x43, - 0x6f, 0x6d, 0x65, 0x74, 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, - 0x32, 0xe9, 0x01, 0x0a, 0x03, 0x4d, 0x73, 0x67, 0x12, 0x77, 0x0a, 0x0c, 0x55, 0x70, 0x64, 0x61, - 0x74, 0x65, 0x50, 0x61, 0x72, 0x61, 0x6d, 0x73, 0x12, 0x24, 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, - 0x73, 0x2e, 0x63, 0x6f, 0x6e, 0x73, 0x65, 0x6e, 0x73, 0x75, 0x73, 0x2e, 0x76, 0x31, 0x2e, 0x4d, - 0x73, 0x67, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x50, 0x61, 0x72, 0x61, 0x6d, 0x73, 0x1a, 0x2c, - 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x63, 0x6f, 0x6e, 0x73, 0x65, 0x6e, 0x73, 0x75, - 0x73, 0x2e, 0x76, 0x31, 0x2e, 0x4d, 0x73, 0x67, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x50, 0x61, - 0x72, 0x61, 0x6d, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x13, 0xca, 0xb4, - 0x2d, 0x0f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2d, 0x73, 0x64, 0x6b, 0x20, 0x30, 0x2e, 0x34, - 0x37, 0x12, 0x62, 0x0a, 0x0c, 0x53, 0x65, 0x74, 0x43, 0x6f, 0x6d, 0x65, 0x74, 0x49, 0x6e, 0x66, - 0x6f, 0x12, 0x24, 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x63, 0x6f, 0x6e, 0x73, 0x65, - 0x6e, 0x73, 0x75, 0x73, 0x2e, 0x76, 0x31, 0x2e, 0x4d, 0x73, 0x67, 0x53, 0x65, 0x74, 0x43, 0x6f, - 0x6d, 0x65, 0x74, 0x49, 0x6e, 0x66, 0x6f, 0x1a, 0x2c, 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, - 0x2e, 0x63, 0x6f, 0x6e, 0x73, 0x65, 0x6e, 0x73, 0x75, 0x73, 0x2e, 0x76, 0x31, 0x2e, 0x4d, 0x73, - 0x67, 0x53, 0x65, 0x74, 0x43, 0x6f, 0x6d, 0x65, 0x74, 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x65, 0x73, - 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x1a, 0x05, 0x80, 0xe7, 0xb0, 0x2a, 0x01, 0x42, 0xc2, 0x01, 0x0a, - 0x17, 0x63, 0x6f, 0x6d, 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x63, 0x6f, 0x6e, 0x73, - 0x65, 0x6e, 0x73, 0x75, 0x73, 0x2e, 0x76, 0x31, 0x42, 0x07, 0x54, 0x78, 0x50, 0x72, 0x6f, 0x74, - 0x6f, 0x50, 0x01, 0x5a, 0x30, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x73, 0x64, 0x6b, 0x2e, 0x69, - 0x6f, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2f, 0x63, 0x6f, 0x6e, - 0x73, 0x65, 0x6e, 0x73, 0x75, 0x73, 0x2f, 0x76, 0x31, 0x3b, 0x63, 0x6f, 0x6e, 0x73, 0x65, 0x6e, - 0x73, 0x75, 0x73, 0x76, 0x31, 0xa2, 0x02, 0x03, 0x43, 0x43, 0x58, 0xaa, 0x02, 0x13, 0x43, 0x6f, - 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x43, 0x6f, 0x6e, 0x73, 0x65, 0x6e, 0x73, 0x75, 0x73, 0x2e, 0x56, - 0x31, 0xca, 0x02, 0x13, 0x43, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x5c, 0x43, 0x6f, 0x6e, 0x73, 0x65, - 0x6e, 0x73, 0x75, 0x73, 0x5c, 0x56, 0x31, 0xe2, 0x02, 0x1f, 0x43, 0x6f, 0x73, 0x6d, 0x6f, 0x73, - 0x5c, 0x43, 0x6f, 0x6e, 0x73, 0x65, 0x6e, 0x73, 0x75, 0x73, 0x5c, 0x56, 0x31, 0x5c, 0x47, 0x50, - 0x42, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0xea, 0x02, 0x15, 0x43, 0x6f, 0x73, 0x6d, - 0x6f, 0x73, 0x3a, 0x3a, 0x43, 0x6f, 0x6e, 0x73, 0x65, 0x6e, 0x73, 0x75, 0x73, 0x3a, 0x3a, 0x56, - 0x31, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x6e, 0x73, 0x65, 0x32, 0x85, 0x01, 0x0a, 0x03, 0x4d, 0x73, 0x67, 0x12, 0x77, 0x0a, 0x0c, 0x55, + 0x70, 0x64, 0x61, 0x74, 0x65, 0x50, 0x61, 0x72, 0x61, 0x6d, 0x73, 0x12, 0x24, 0x2e, 0x63, 0x6f, + 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x63, 0x6f, 0x6e, 0x73, 0x65, 0x6e, 0x73, 0x75, 0x73, 0x2e, 0x76, + 0x31, 0x2e, 0x4d, 0x73, 0x67, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x50, 0x61, 0x72, 0x61, 0x6d, + 0x73, 0x1a, 0x2c, 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x63, 0x6f, 0x6e, 0x73, 0x65, + 0x6e, 0x73, 0x75, 0x73, 0x2e, 0x76, 0x31, 0x2e, 0x4d, 0x73, 0x67, 0x55, 0x70, 0x64, 0x61, 0x74, + 0x65, 0x50, 0x61, 0x72, 0x61, 0x6d, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, + 0x13, 0xca, 0xb4, 0x2d, 0x0f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2d, 0x73, 0x64, 0x6b, 0x20, + 0x30, 0x2e, 0x34, 0x37, 0x1a, 0x05, 0x80, 0xe7, 0xb0, 0x2a, 0x01, 0x42, 0xc2, 0x01, 0x0a, 0x17, + 0x63, 0x6f, 0x6d, 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x63, 0x6f, 0x6e, 0x73, 0x65, + 0x6e, 0x73, 0x75, 0x73, 0x2e, 0x76, 0x31, 0x42, 0x07, 0x54, 0x78, 0x50, 0x72, 0x6f, 0x74, 0x6f, + 0x50, 0x01, 0x5a, 0x30, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x73, 0x64, 0x6b, 0x2e, 0x69, 0x6f, + 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2f, 0x63, 0x6f, 0x6e, 0x73, + 0x65, 0x6e, 0x73, 0x75, 0x73, 0x2f, 0x76, 0x31, 0x3b, 0x63, 0x6f, 0x6e, 0x73, 0x65, 0x6e, 0x73, + 0x75, 0x73, 0x76, 0x31, 0xa2, 0x02, 0x03, 0x43, 0x43, 0x58, 0xaa, 0x02, 0x13, 0x43, 0x6f, 0x73, + 0x6d, 0x6f, 0x73, 0x2e, 0x43, 0x6f, 0x6e, 0x73, 0x65, 0x6e, 0x73, 0x75, 0x73, 0x2e, 0x56, 0x31, + 0xca, 0x02, 0x13, 0x43, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x5c, 0x43, 0x6f, 0x6e, 0x73, 0x65, 0x6e, + 0x73, 0x75, 0x73, 0x5c, 0x56, 0x31, 0xe2, 0x02, 0x1f, 0x43, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x5c, + 0x43, 0x6f, 0x6e, 0x73, 0x65, 0x6e, 0x73, 0x75, 0x73, 0x5c, 0x56, 0x31, 0x5c, 0x47, 0x50, 0x42, + 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0xea, 0x02, 0x15, 0x43, 0x6f, 0x73, 0x6d, 0x6f, + 0x73, 0x3a, 0x3a, 0x43, 0x6f, 0x6e, 0x73, 0x65, 0x6e, 0x73, 0x75, 0x73, 0x3a, 0x3a, 0x56, 0x31, + 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( @@ -2745,39 +1491,31 @@ func file_cosmos_consensus_v1_tx_proto_rawDescGZIP() []byte { return file_cosmos_consensus_v1_tx_proto_rawDescData } -var file_cosmos_consensus_v1_tx_proto_msgTypes = make([]protoimpl.MessageInfo, 4) +var file_cosmos_consensus_v1_tx_proto_msgTypes = make([]protoimpl.MessageInfo, 2) var file_cosmos_consensus_v1_tx_proto_goTypes = []interface{}{ (*MsgUpdateParams)(nil), // 0: cosmos.consensus.v1.MsgUpdateParams (*MsgUpdateParamsResponse)(nil), // 1: cosmos.consensus.v1.MsgUpdateParamsResponse - (*MsgSetCometInfo)(nil), // 2: cosmos.consensus.v1.MsgSetCometInfo - (*MsgSetCometInfoResponse)(nil), // 3: cosmos.consensus.v1.MsgSetCometInfoResponse - (*v1.BlockParams)(nil), // 4: cometbft.types.v1.BlockParams - (*v1.EvidenceParams)(nil), // 5: cometbft.types.v1.EvidenceParams - (*v1.ValidatorParams)(nil), // 6: cometbft.types.v1.ValidatorParams - (*v1.ABCIParams)(nil), // 7: cometbft.types.v1.ABCIParams - (*v1.SynchronyParams)(nil), // 8: cometbft.types.v1.SynchronyParams - (*v1.FeatureParams)(nil), // 9: cometbft.types.v1.FeatureParams - (*v11.Misbehavior)(nil), // 10: cometbft.abci.v1.Misbehavior - (*v11.CommitInfo)(nil), // 11: cometbft.abci.v1.CommitInfo + (*v1.BlockParams)(nil), // 2: cometbft.types.v1.BlockParams + (*v1.EvidenceParams)(nil), // 3: cometbft.types.v1.EvidenceParams + (*v1.ValidatorParams)(nil), // 4: cometbft.types.v1.ValidatorParams + (*v1.ABCIParams)(nil), // 5: cometbft.types.v1.ABCIParams + (*v1.SynchronyParams)(nil), // 6: cometbft.types.v1.SynchronyParams + (*v1.FeatureParams)(nil), // 7: cometbft.types.v1.FeatureParams } var file_cosmos_consensus_v1_tx_proto_depIdxs = []int32{ - 4, // 0: cosmos.consensus.v1.MsgUpdateParams.block:type_name -> cometbft.types.v1.BlockParams - 5, // 1: cosmos.consensus.v1.MsgUpdateParams.evidence:type_name -> cometbft.types.v1.EvidenceParams - 6, // 2: cosmos.consensus.v1.MsgUpdateParams.validator:type_name -> cometbft.types.v1.ValidatorParams - 7, // 3: cosmos.consensus.v1.MsgUpdateParams.abci:type_name -> cometbft.types.v1.ABCIParams - 8, // 4: cosmos.consensus.v1.MsgUpdateParams.synchrony:type_name -> cometbft.types.v1.SynchronyParams - 9, // 5: cosmos.consensus.v1.MsgUpdateParams.feature:type_name -> cometbft.types.v1.FeatureParams - 10, // 6: cosmos.consensus.v1.MsgSetCometInfo.evidence:type_name -> cometbft.abci.v1.Misbehavior - 11, // 7: cosmos.consensus.v1.MsgSetCometInfo.last_commit:type_name -> cometbft.abci.v1.CommitInfo - 0, // 8: cosmos.consensus.v1.Msg.UpdateParams:input_type -> cosmos.consensus.v1.MsgUpdateParams - 2, // 9: cosmos.consensus.v1.Msg.SetCometInfo:input_type -> cosmos.consensus.v1.MsgSetCometInfo - 1, // 10: cosmos.consensus.v1.Msg.UpdateParams:output_type -> cosmos.consensus.v1.MsgUpdateParamsResponse - 3, // 11: cosmos.consensus.v1.Msg.SetCometInfo:output_type -> cosmos.consensus.v1.MsgSetCometInfoResponse - 10, // [10:12] is the sub-list for method output_type - 8, // [8:10] is the sub-list for method input_type - 8, // [8:8] is the sub-list for extension type_name - 8, // [8:8] is the sub-list for extension extendee - 0, // [0:8] is the sub-list for field type_name + 2, // 0: cosmos.consensus.v1.MsgUpdateParams.block:type_name -> cometbft.types.v1.BlockParams + 3, // 1: cosmos.consensus.v1.MsgUpdateParams.evidence:type_name -> cometbft.types.v1.EvidenceParams + 4, // 2: cosmos.consensus.v1.MsgUpdateParams.validator:type_name -> cometbft.types.v1.ValidatorParams + 5, // 3: cosmos.consensus.v1.MsgUpdateParams.abci:type_name -> cometbft.types.v1.ABCIParams + 6, // 4: cosmos.consensus.v1.MsgUpdateParams.synchrony:type_name -> cometbft.types.v1.SynchronyParams + 7, // 5: cosmos.consensus.v1.MsgUpdateParams.feature:type_name -> cometbft.types.v1.FeatureParams + 0, // 6: cosmos.consensus.v1.Msg.UpdateParams:input_type -> cosmos.consensus.v1.MsgUpdateParams + 1, // 7: cosmos.consensus.v1.Msg.UpdateParams:output_type -> cosmos.consensus.v1.MsgUpdateParamsResponse + 7, // [7:8] is the sub-list for method output_type + 6, // [6:7] is the sub-list for method input_type + 6, // [6:6] is the sub-list for extension type_name + 6, // [6:6] is the sub-list for extension extendee + 0, // [0:6] is the sub-list for field type_name } func init() { file_cosmos_consensus_v1_tx_proto_init() } @@ -2810,30 +1548,6 @@ func file_cosmos_consensus_v1_tx_proto_init() { return nil } } - file_cosmos_consensus_v1_tx_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*MsgSetCometInfo); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_cosmos_consensus_v1_tx_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*MsgSetCometInfoResponse); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } } type x struct{} out := protoimpl.TypeBuilder{ @@ -2841,7 +1555,7 @@ func file_cosmos_consensus_v1_tx_proto_init() { GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: file_cosmos_consensus_v1_tx_proto_rawDesc, NumEnums: 0, - NumMessages: 4, + NumMessages: 2, NumExtensions: 0, NumServices: 1, }, diff --git a/api/cosmos/consensus/v1/tx_grpc.pb.go b/api/cosmos/consensus/v1/tx_grpc.pb.go index 50dfbe9de169..14f2e80d209e 100644 --- a/api/cosmos/consensus/v1/tx_grpc.pb.go +++ b/api/cosmos/consensus/v1/tx_grpc.pb.go @@ -22,7 +22,6 @@ const _ = grpc.SupportPackageIsVersion7 const ( Msg_UpdateParams_FullMethodName = "/cosmos.consensus.v1.Msg/UpdateParams" - Msg_SetCometInfo_FullMethodName = "/cosmos.consensus.v1.Msg/SetCometInfo" ) // MsgClient is the client API for Msg service. @@ -32,8 +31,6 @@ type MsgClient interface { // UpdateParams defines a governance operation for updating the x/consensus module parameters. // The authority is defined in the keeper. UpdateParams(ctx context.Context, in *MsgUpdateParams, opts ...grpc.CallOption) (*MsgUpdateParamsResponse, error) - // SetCometInfo defines how to set the comet info for the x/consensus module. - SetCometInfo(ctx context.Context, in *MsgSetCometInfo, opts ...grpc.CallOption) (*MsgSetCometInfoResponse, error) } type msgClient struct { @@ -53,15 +50,6 @@ func (c *msgClient) UpdateParams(ctx context.Context, in *MsgUpdateParams, opts return out, nil } -func (c *msgClient) SetCometInfo(ctx context.Context, in *MsgSetCometInfo, opts ...grpc.CallOption) (*MsgSetCometInfoResponse, error) { - out := new(MsgSetCometInfoResponse) - err := c.cc.Invoke(ctx, Msg_SetCometInfo_FullMethodName, in, out, opts...) - if err != nil { - return nil, err - } - return out, nil -} - // MsgServer is the server API for Msg service. // All implementations must embed UnimplementedMsgServer // for forward compatibility @@ -69,8 +57,6 @@ type MsgServer interface { // UpdateParams defines a governance operation for updating the x/consensus module parameters. // The authority is defined in the keeper. UpdateParams(context.Context, *MsgUpdateParams) (*MsgUpdateParamsResponse, error) - // SetCometInfo defines how to set the comet info for the x/consensus module. - SetCometInfo(context.Context, *MsgSetCometInfo) (*MsgSetCometInfoResponse, error) mustEmbedUnimplementedMsgServer() } @@ -81,9 +67,6 @@ type UnimplementedMsgServer struct { func (UnimplementedMsgServer) UpdateParams(context.Context, *MsgUpdateParams) (*MsgUpdateParamsResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method UpdateParams not implemented") } -func (UnimplementedMsgServer) SetCometInfo(context.Context, *MsgSetCometInfo) (*MsgSetCometInfoResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method SetCometInfo not implemented") -} func (UnimplementedMsgServer) mustEmbedUnimplementedMsgServer() {} // UnsafeMsgServer may be embedded to opt out of forward compatibility for this service. @@ -115,24 +98,6 @@ func _Msg_UpdateParams_Handler(srv interface{}, ctx context.Context, dec func(in return interceptor(ctx, in, info, handler) } -func _Msg_SetCometInfo_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(MsgSetCometInfo) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(MsgServer).SetCometInfo(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: Msg_SetCometInfo_FullMethodName, - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(MsgServer).SetCometInfo(ctx, req.(*MsgSetCometInfo)) - } - return interceptor(ctx, in, info, handler) -} - // Msg_ServiceDesc is the grpc.ServiceDesc for Msg service. // It's only intended for direct use with grpc.RegisterService, // and not to be introspected or modified (even as a copy) @@ -144,10 +109,6 @@ var Msg_ServiceDesc = grpc.ServiceDesc{ MethodName: "UpdateParams", Handler: _Msg_UpdateParams_Handler, }, - { - MethodName: "SetCometInfo", - Handler: _Msg_SetCometInfo_Handler, - }, }, Streams: []grpc.StreamDesc{}, Metadata: "cosmos/consensus/v1/tx.proto", diff --git a/api/cosmos/epochs/module/v1/module.pulsar.go b/api/cosmos/epochs/module/v1/module.pulsar.go index b169d8466fc7..9adaff215156 100644 --- a/api/cosmos/epochs/module/v1/module.pulsar.go +++ b/api/cosmos/epochs/module/v1/module.pulsar.go @@ -382,7 +382,7 @@ const ( _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) ) -// Module is the config object of the authz module. +// Module is the config object of the epochs module. type Module struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache diff --git a/api/cosmos/nft/v1beta1/query_grpc.pb.go b/api/cosmos/nft/v1beta1/query_grpc.pb.go index d25acc384af2..1f69c3c9643e 100644 --- a/api/cosmos/nft/v1beta1/query_grpc.pb.go +++ b/api/cosmos/nft/v1beta1/query_grpc.pb.go @@ -39,7 +39,7 @@ const ( type QueryClient interface { // Balance queries the number of NFTs of a given class owned by the owner, same as balanceOf in ERC721 Balance(ctx context.Context, in *QueryBalanceRequest, opts ...grpc.CallOption) (*QueryBalanceResponse, error) - // BalancebyQueryString queries the number of NFTs of a given class owned by the owner, same as balanceOf in ERC721 + // BalanceByQueryString queries the number of NFTs of a given class owned by the owner, same as balanceOf in ERC721 BalanceByQueryString(ctx context.Context, in *QueryBalanceByQueryStringRequest, opts ...grpc.CallOption) (*QueryBalanceByQueryStringResponse, error) // Owner queries the owner of the NFT based on its class and id, same as ownerOf in ERC721 Owner(ctx context.Context, in *QueryOwnerRequest, opts ...grpc.CallOption) (*QueryOwnerResponse, error) @@ -186,7 +186,7 @@ func (c *queryClient) Classes(ctx context.Context, in *QueryClassesRequest, opts type QueryServer interface { // Balance queries the number of NFTs of a given class owned by the owner, same as balanceOf in ERC721 Balance(context.Context, *QueryBalanceRequest) (*QueryBalanceResponse, error) - // BalancebyQueryString queries the number of NFTs of a given class owned by the owner, same as balanceOf in ERC721 + // BalanceByQueryString queries the number of NFTs of a given class owned by the owner, same as balanceOf in ERC721 BalanceByQueryString(context.Context, *QueryBalanceByQueryStringRequest) (*QueryBalanceByQueryStringResponse, error) // Owner queries the owner of the NFT based on its class and id, same as ownerOf in ERC721 Owner(context.Context, *QueryOwnerRequest) (*QueryOwnerResponse, error) diff --git a/api/cosmos/protocolpool/v1/genesis.pulsar.go b/api/cosmos/protocolpool/v1/genesis.pulsar.go index 98fc6c281211..3a7ff075f2a2 100644 --- a/api/cosmos/protocolpool/v1/genesis.pulsar.go +++ b/api/cosmos/protocolpool/v1/genesis.pulsar.go @@ -9,6 +9,7 @@ import ( protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoiface "google.golang.org/protobuf/runtime/protoiface" protoimpl "google.golang.org/protobuf/runtime/protoimpl" + timestamppb "google.golang.org/protobuf/types/known/timestamppb" io "io" reflect "reflect" sync "sync" @@ -116,11 +117,63 @@ func (x *_GenesisState_2_list) IsValid() bool { return x.list != nil } +var _ protoreflect.List = (*_GenesisState_4_list)(nil) + +type _GenesisState_4_list struct { + list *[]*Distribution +} + +func (x *_GenesisState_4_list) Len() int { + if x.list == nil { + return 0 + } + return len(*x.list) +} + +func (x *_GenesisState_4_list) Get(i int) protoreflect.Value { + return protoreflect.ValueOfMessage((*x.list)[i].ProtoReflect()) +} + +func (x *_GenesisState_4_list) Set(i int, value protoreflect.Value) { + valueUnwrapped := value.Message() + concreteValue := valueUnwrapped.Interface().(*Distribution) + (*x.list)[i] = concreteValue +} + +func (x *_GenesisState_4_list) Append(value protoreflect.Value) { + valueUnwrapped := value.Message() + concreteValue := valueUnwrapped.Interface().(*Distribution) + *x.list = append(*x.list, concreteValue) +} + +func (x *_GenesisState_4_list) AppendMutable() protoreflect.Value { + v := new(Distribution) + *x.list = append(*x.list, v) + return protoreflect.ValueOfMessage(v.ProtoReflect()) +} + +func (x *_GenesisState_4_list) Truncate(n int) { + for i := n; i < len(*x.list); i++ { + (*x.list)[i] = nil + } + *x.list = (*x.list)[:n] +} + +func (x *_GenesisState_4_list) NewElement() protoreflect.Value { + v := new(Distribution) + return protoreflect.ValueOfMessage(v.ProtoReflect()) +} + +func (x *_GenesisState_4_list) IsValid() bool { + return x.list != nil +} + var ( md_GenesisState protoreflect.MessageDescriptor fd_GenesisState_continuous_fund protoreflect.FieldDescriptor fd_GenesisState_budget protoreflect.FieldDescriptor - fd_GenesisState_to_distribute protoreflect.FieldDescriptor + fd_GenesisState_last_balance protoreflect.FieldDescriptor + fd_GenesisState_distributions protoreflect.FieldDescriptor ) func init() { @@ -128,7 +181,8 @@ func init() { md_GenesisState = File_cosmos_protocolpool_v1_genesis_proto.Messages().ByName("GenesisState") fd_GenesisState_continuous_fund = md_GenesisState.Fields().ByName("continuous_fund") fd_GenesisState_budget = md_GenesisState.Fields().ByName("budget") - fd_GenesisState_to_distribute = md_GenesisState.Fields().ByName("to_distribute") + fd_GenesisState_last_balance = md_GenesisState.Fields().ByName("last_balance") + fd_GenesisState_distributions = md_GenesisState.Fields().ByName("distributions") } var _ protoreflect.Message = (*fastReflection_GenesisState)(nil) @@ -208,9 +262,15 @@ func (x *fastReflection_GenesisState) Range(f func(protoreflect.FieldDescriptor, return } } - if x.ToDistribute != "" { - value := protoreflect.ValueOfString(x.ToDistribute) - if !f(fd_GenesisState_to_distribute, value) { + if x.LastBalance != "" { + value := protoreflect.ValueOfString(x.LastBalance) + if !f(fd_GenesisState_last_balance, value) { + return + } + } + if len(x.Distributions) != 0 { + value := protoreflect.ValueOfList(&_GenesisState_4_list{list: &x.Distributions}) + if !f(fd_GenesisState_distributions, value) { return } } @@ -233,8 +293,10 @@ func (x *fastReflection_GenesisState) Has(fd protoreflect.FieldDescriptor) bool return len(x.ContinuousFund) != 0 case "cosmos.protocolpool.v1.GenesisState.budget": return len(x.Budget) != 0 - case "cosmos.protocolpool.v1.GenesisState.to_distribute": - return x.ToDistribute != "" + case "cosmos.protocolpool.v1.GenesisState.last_balance": + return x.LastBalance != "" + case "cosmos.protocolpool.v1.GenesisState.distributions": + return len(x.Distributions) != 0 default: if fd.IsExtension() { panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.protocolpool.v1.GenesisState")) @@ -255,8 +317,10 @@ func (x *fastReflection_GenesisState) Clear(fd protoreflect.FieldDescriptor) { x.ContinuousFund = nil case "cosmos.protocolpool.v1.GenesisState.budget": x.Budget = nil - case "cosmos.protocolpool.v1.GenesisState.to_distribute": - x.ToDistribute = "" + case "cosmos.protocolpool.v1.GenesisState.last_balance": + x.LastBalance = "" + case "cosmos.protocolpool.v1.GenesisState.distributions": + x.Distributions = nil default: if fd.IsExtension() { panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.protocolpool.v1.GenesisState")) @@ -285,9 +349,15 @@ func (x *fastReflection_GenesisState) Get(descriptor protoreflect.FieldDescripto } listValue := &_GenesisState_2_list{list: &x.Budget} return protoreflect.ValueOfList(listValue) - case "cosmos.protocolpool.v1.GenesisState.to_distribute": - value := x.ToDistribute + case "cosmos.protocolpool.v1.GenesisState.last_balance": + value := x.LastBalance return protoreflect.ValueOfString(value) + case "cosmos.protocolpool.v1.GenesisState.distributions": + if len(x.Distributions) == 0 { + return protoreflect.ValueOfList(&_GenesisState_4_list{}) + } + listValue := &_GenesisState_4_list{list: &x.Distributions} + return protoreflect.ValueOfList(listValue) default: if descriptor.IsExtension() { panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.protocolpool.v1.GenesisState")) @@ -316,8 +386,12 @@ func (x *fastReflection_GenesisState) Set(fd protoreflect.FieldDescriptor, value lv := value.List() clv := lv.(*_GenesisState_2_list) x.Budget = *clv.list - case "cosmos.protocolpool.v1.GenesisState.to_distribute": - x.ToDistribute = value.Interface().(string) + case "cosmos.protocolpool.v1.GenesisState.last_balance": + x.LastBalance = value.Interface().(string) + case "cosmos.protocolpool.v1.GenesisState.distributions": + lv := value.List() + clv := lv.(*_GenesisState_4_list) + x.Distributions = *clv.list default: if fd.IsExtension() { panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.protocolpool.v1.GenesisState")) @@ -350,8 +424,14 @@ func (x *fastReflection_GenesisState) Mutable(fd protoreflect.FieldDescriptor) p } value := &_GenesisState_2_list{list: &x.Budget} return protoreflect.ValueOfList(value) - case "cosmos.protocolpool.v1.GenesisState.to_distribute": - panic(fmt.Errorf("field to_distribute of message cosmos.protocolpool.v1.GenesisState is not mutable")) + case "cosmos.protocolpool.v1.GenesisState.distributions": + if x.Distributions == nil { + x.Distributions = []*Distribution{} + } + value := &_GenesisState_4_list{list: &x.Distributions} + return protoreflect.ValueOfList(value) + case "cosmos.protocolpool.v1.GenesisState.last_balance": + panic(fmt.Errorf("field last_balance of message cosmos.protocolpool.v1.GenesisState is not mutable")) default: if fd.IsExtension() { panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.protocolpool.v1.GenesisState")) @@ -371,8 +451,11 @@ func (x *fastReflection_GenesisState) NewField(fd protoreflect.FieldDescriptor) case "cosmos.protocolpool.v1.GenesisState.budget": list := []*Budget{} return protoreflect.ValueOfList(&_GenesisState_2_list{list: &list}) - case "cosmos.protocolpool.v1.GenesisState.to_distribute": + case "cosmos.protocolpool.v1.GenesisState.last_balance": return protoreflect.ValueOfString("") + case "cosmos.protocolpool.v1.GenesisState.distributions": + list := []*Distribution{} + return protoreflect.ValueOfList(&_GenesisState_4_list{list: &list}) default: if fd.IsExtension() { panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.protocolpool.v1.GenesisState")) @@ -454,10 +537,16 @@ func (x *fastReflection_GenesisState) ProtoMethods() *protoiface.Methods { n += 1 + l + runtime.Sov(uint64(l)) } } - l = len(x.ToDistribute) + l = len(x.LastBalance) if l > 0 { n += 1 + l + runtime.Sov(uint64(l)) } + if len(x.Distributions) > 0 { + for _, e := range x.Distributions { + l = options.Size(e) + n += 1 + l + runtime.Sov(uint64(l)) + } + } if x.unknownFields != nil { n += len(x.unknownFields) } @@ -487,10 +576,26 @@ func (x *fastReflection_GenesisState) ProtoMethods() *protoiface.Methods { i -= len(x.unknownFields) copy(dAtA[i:], x.unknownFields) } - if len(x.ToDistribute) > 0 { - i -= len(x.ToDistribute) - copy(dAtA[i:], x.ToDistribute) - i = runtime.EncodeVarint(dAtA, i, uint64(len(x.ToDistribute))) + if len(x.Distributions) > 0 { + for iNdEx := len(x.Distributions) - 1; iNdEx >= 0; iNdEx-- { + encoded, err := options.Marshal(x.Distributions[iNdEx]) + if err != nil { + return protoiface.MarshalOutput{ + NoUnkeyedLiterals: input.NoUnkeyedLiterals, + Buf: input.Buf, + }, err + } + i -= len(encoded) + copy(dAtA[i:], encoded) + i = runtime.EncodeVarint(dAtA, i, uint64(len(encoded))) + i-- + dAtA[i] = 0x22 + } + } + if len(x.LastBalance) > 0 { + i -= len(x.LastBalance) + copy(dAtA[i:], x.LastBalance) + i = runtime.EncodeVarint(dAtA, i, uint64(len(x.LastBalance))) i-- dAtA[i] = 0x1a } @@ -645,7 +750,7 @@ func (x *fastReflection_GenesisState) ProtoMethods() *protoiface.Methods { iNdEx = postIndex case 3: if wireType != 2 { - return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: wrong wireType = %d for field ToDistribute", wireType) + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: wrong wireType = %d for field LastBalance", wireType) } var stringLen uint64 for shift := uint(0); ; shift += 7 { @@ -673,7 +778,41 @@ func (x *fastReflection_GenesisState) ProtoMethods() *protoiface.Methods { if postIndex > l { return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF } - x.ToDistribute = string(dAtA[iNdEx:postIndex]) + x.LastBalance = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 4: + if wireType != 2 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: wrong wireType = %d for field Distributions", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrIntOverflow + } + if iNdEx >= l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength + } + if postIndex > l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + x.Distributions = append(x.Distributions, &Distribution{}) + if err := options.Unmarshal(dAtA[iNdEx:postIndex], x.Distributions[len(x.Distributions)-1]); err != nil { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, err + } iNdEx = postIndex default: iNdEx = preIndex @@ -710,154 +849,740 @@ func (x *fastReflection_GenesisState) ProtoMethods() *protoiface.Methods { } } -// Code generated by protoc-gen-go. DO NOT EDIT. -// versions: -// protoc-gen-go v1.27.0 -// protoc (unknown) -// source: cosmos/protocolpool/v1/genesis.proto - -const ( - // Verify that this generated code is sufficiently up-to-date. - _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) - // Verify that runtime/protoimpl is sufficiently up-to-date. - _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) +var ( + md_Distribution protoreflect.MessageDescriptor + fd_Distribution_amount protoreflect.FieldDescriptor + fd_Distribution_time protoreflect.FieldDescriptor ) -// GenesisState defines the protocolpool module's genesis state. -type GenesisState struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields +func init() { + file_cosmos_protocolpool_v1_genesis_proto_init() + md_Distribution = File_cosmos_protocolpool_v1_genesis_proto.Messages().ByName("Distribution") + fd_Distribution_amount = md_Distribution.Fields().ByName("amount") + fd_Distribution_time = md_Distribution.Fields().ByName("time") +} - // ContinuousFund defines the continuous funds at genesis. - ContinuousFund []*ContinuousFund `protobuf:"bytes,1,rep,name=continuous_fund,json=continuousFund,proto3" json:"continuous_fund,omitempty"` - // Budget defines the budget proposals at genesis. - Budget []*Budget `protobuf:"bytes,2,rep,name=budget,proto3" json:"budget,omitempty"` - ToDistribute string `protobuf:"bytes,3,opt,name=to_distribute,json=toDistribute,proto3" json:"to_distribute,omitempty"` +var _ protoreflect.Message = (*fastReflection_Distribution)(nil) + +type fastReflection_Distribution Distribution + +func (x *Distribution) ProtoReflect() protoreflect.Message { + return (*fastReflection_Distribution)(x) } -func (x *GenesisState) Reset() { - *x = GenesisState{} - if protoimpl.UnsafeEnabled { - mi := &file_cosmos_protocolpool_v1_genesis_proto_msgTypes[0] +func (x *Distribution) slowProtoReflect() protoreflect.Message { + mi := &file_cosmos_protocolpool_v1_genesis_proto_msgTypes[1] + if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms } + return mi.MessageOf(x) } -func (x *GenesisState) String() string { - return protoimpl.X.MessageStringOf(x) -} +var _fastReflection_Distribution_messageType fastReflection_Distribution_messageType +var _ protoreflect.MessageType = fastReflection_Distribution_messageType{} -func (*GenesisState) ProtoMessage() {} +type fastReflection_Distribution_messageType struct{} -// Deprecated: Use GenesisState.ProtoReflect.Descriptor instead. -func (*GenesisState) Descriptor() ([]byte, []int) { - return file_cosmos_protocolpool_v1_genesis_proto_rawDescGZIP(), []int{0} +func (x fastReflection_Distribution_messageType) Zero() protoreflect.Message { + return (*fastReflection_Distribution)(nil) } - -func (x *GenesisState) GetContinuousFund() []*ContinuousFund { - if x != nil { - return x.ContinuousFund - } - return nil +func (x fastReflection_Distribution_messageType) New() protoreflect.Message { + return new(fastReflection_Distribution) +} +func (x fastReflection_Distribution_messageType) Descriptor() protoreflect.MessageDescriptor { + return md_Distribution } -func (x *GenesisState) GetBudget() []*Budget { - if x != nil { - return x.Budget - } - return nil +// Descriptor returns message descriptor, which contains only the protobuf +// type information for the message. +func (x *fastReflection_Distribution) Descriptor() protoreflect.MessageDescriptor { + return md_Distribution } -func (x *GenesisState) GetToDistribute() string { - if x != nil { - return x.ToDistribute - } - return "" +// Type returns the message type, which encapsulates both Go and protobuf +// type information. If the Go type information is not needed, +// it is recommended that the message descriptor be used instead. +func (x *fastReflection_Distribution) Type() protoreflect.MessageType { + return _fastReflection_Distribution_messageType } -var File_cosmos_protocolpool_v1_genesis_proto protoreflect.FileDescriptor +// New returns a newly allocated and mutable empty message. +func (x *fastReflection_Distribution) New() protoreflect.Message { + return new(fastReflection_Distribution) +} -var file_cosmos_protocolpool_v1_genesis_proto_rawDesc = []byte{ - 0x0a, 0x24, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x6f, - 0x6c, 0x70, 0x6f, 0x6f, 0x6c, 0x2f, 0x76, 0x31, 0x2f, 0x67, 0x65, 0x6e, 0x65, 0x73, 0x69, 0x73, - 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x16, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x70, - 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x6f, 0x6c, 0x70, 0x6f, 0x6f, 0x6c, 0x2e, 0x76, 0x31, 0x1a, 0x22, - 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x6f, 0x6c, 0x70, - 0x6f, 0x6f, 0x6c, 0x2f, 0x76, 0x31, 0x2f, 0x74, 0x79, 0x70, 0x65, 0x73, 0x2e, 0x70, 0x72, 0x6f, - 0x74, 0x6f, 0x1a, 0x14, 0x67, 0x6f, 0x67, 0x6f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x67, 0x6f, - 0x67, 0x6f, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x19, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, - 0x5f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x70, 0x72, - 0x6f, 0x74, 0x6f, 0x22, 0xe9, 0x01, 0x0a, 0x0c, 0x47, 0x65, 0x6e, 0x65, 0x73, 0x69, 0x73, 0x53, - 0x74, 0x61, 0x74, 0x65, 0x12, 0x4f, 0x0a, 0x0f, 0x63, 0x6f, 0x6e, 0x74, 0x69, 0x6e, 0x75, 0x6f, - 0x75, 0x73, 0x5f, 0x66, 0x75, 0x6e, 0x64, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x26, 0x2e, - 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x6f, 0x6c, 0x70, - 0x6f, 0x6f, 0x6c, 0x2e, 0x76, 0x31, 0x2e, 0x43, 0x6f, 0x6e, 0x74, 0x69, 0x6e, 0x75, 0x6f, 0x75, - 0x73, 0x46, 0x75, 0x6e, 0x64, 0x52, 0x0e, 0x63, 0x6f, 0x6e, 0x74, 0x69, 0x6e, 0x75, 0x6f, 0x75, - 0x73, 0x46, 0x75, 0x6e, 0x64, 0x12, 0x36, 0x0a, 0x06, 0x62, 0x75, 0x64, 0x67, 0x65, 0x74, 0x18, - 0x02, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x1e, 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x70, - 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x6f, 0x6c, 0x70, 0x6f, 0x6f, 0x6c, 0x2e, 0x76, 0x31, 0x2e, 0x42, - 0x75, 0x64, 0x67, 0x65, 0x74, 0x52, 0x06, 0x62, 0x75, 0x64, 0x67, 0x65, 0x74, 0x12, 0x50, 0x0a, - 0x0d, 0x74, 0x6f, 0x5f, 0x64, 0x69, 0x73, 0x74, 0x72, 0x69, 0x62, 0x75, 0x74, 0x65, 0x18, 0x03, - 0x20, 0x01, 0x28, 0x09, 0x42, 0x2b, 0xc8, 0xde, 0x1f, 0x00, 0xda, 0xde, 0x1f, 0x15, 0x63, 0x6f, - 0x73, 0x6d, 0x6f, 0x73, 0x73, 0x64, 0x6b, 0x2e, 0x69, 0x6f, 0x2f, 0x6d, 0x61, 0x74, 0x68, 0x2e, - 0x49, 0x6e, 0x74, 0xd2, 0xb4, 0x2d, 0x0a, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x49, 0x6e, - 0x74, 0x52, 0x0c, 0x74, 0x6f, 0x44, 0x69, 0x73, 0x74, 0x72, 0x69, 0x62, 0x75, 0x74, 0x65, 0x42, - 0xdc, 0x01, 0x0a, 0x1a, 0x63, 0x6f, 0x6d, 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x70, - 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x6f, 0x6c, 0x70, 0x6f, 0x6f, 0x6c, 0x2e, 0x76, 0x31, 0x42, 0x0c, - 0x47, 0x65, 0x6e, 0x65, 0x73, 0x69, 0x73, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x36, - 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x73, 0x64, 0x6b, 0x2e, 0x69, 0x6f, 0x2f, 0x61, 0x70, 0x69, - 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x6f, 0x6c, - 0x70, 0x6f, 0x6f, 0x6c, 0x2f, 0x76, 0x31, 0x3b, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x6f, 0x6c, - 0x70, 0x6f, 0x6f, 0x6c, 0x76, 0x31, 0xa2, 0x02, 0x03, 0x43, 0x50, 0x58, 0xaa, 0x02, 0x16, 0x43, - 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x6f, 0x6c, 0x70, 0x6f, - 0x6f, 0x6c, 0x2e, 0x56, 0x31, 0xca, 0x02, 0x16, 0x43, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x5c, 0x50, - 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x6f, 0x6c, 0x70, 0x6f, 0x6f, 0x6c, 0x5c, 0x56, 0x31, 0xe2, 0x02, - 0x22, 0x43, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x5c, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x6f, 0x6c, - 0x70, 0x6f, 0x6f, 0x6c, 0x5c, 0x56, 0x31, 0x5c, 0x47, 0x50, 0x42, 0x4d, 0x65, 0x74, 0x61, 0x64, - 0x61, 0x74, 0x61, 0xea, 0x02, 0x18, 0x43, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x3a, 0x3a, 0x50, 0x72, - 0x6f, 0x74, 0x6f, 0x63, 0x6f, 0x6c, 0x70, 0x6f, 0x6f, 0x6c, 0x3a, 0x3a, 0x56, 0x31, 0x62, 0x06, - 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, +// Interface unwraps the message reflection interface and +// returns the underlying ProtoMessage interface. +func (x *fastReflection_Distribution) Interface() protoreflect.ProtoMessage { + return (*Distribution)(x) } -var ( - file_cosmos_protocolpool_v1_genesis_proto_rawDescOnce sync.Once - file_cosmos_protocolpool_v1_genesis_proto_rawDescData = file_cosmos_protocolpool_v1_genesis_proto_rawDesc -) +// Range iterates over every populated field in an undefined order, +// calling f for each field descriptor and value encountered. +// Range returns immediately if f returns false. +// While iterating, mutating operations may only be performed +// on the current field descriptor. +func (x *fastReflection_Distribution) Range(f func(protoreflect.FieldDescriptor, protoreflect.Value) bool) { + if x.Amount != "" { + value := protoreflect.ValueOfString(x.Amount) + if !f(fd_Distribution_amount, value) { + return + } + } + if x.Time != nil { + value := protoreflect.ValueOfMessage(x.Time.ProtoReflect()) + if !f(fd_Distribution_time, value) { + return + } + } +} -func file_cosmos_protocolpool_v1_genesis_proto_rawDescGZIP() []byte { - file_cosmos_protocolpool_v1_genesis_proto_rawDescOnce.Do(func() { - file_cosmos_protocolpool_v1_genesis_proto_rawDescData = protoimpl.X.CompressGZIP(file_cosmos_protocolpool_v1_genesis_proto_rawDescData) - }) - return file_cosmos_protocolpool_v1_genesis_proto_rawDescData +// Has reports whether a field is populated. +// +// Some fields have the property of nullability where it is possible to +// distinguish between the default value of a field and whether the field +// was explicitly populated with the default value. Singular message fields, +// member fields of a oneof, and proto2 scalar fields are nullable. Such +// fields are populated only if explicitly set. +// +// In other cases (aside from the nullable cases above), +// a proto3 scalar field is populated if it contains a non-zero value, and +// a repeated field is populated if it is non-empty. +func (x *fastReflection_Distribution) Has(fd protoreflect.FieldDescriptor) bool { + switch fd.FullName() { + case "cosmos.protocolpool.v1.Distribution.amount": + return x.Amount != "" + case "cosmos.protocolpool.v1.Distribution.time": + return x.Time != nil + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.protocolpool.v1.Distribution")) + } + panic(fmt.Errorf("message cosmos.protocolpool.v1.Distribution does not contain field %s", fd.FullName())) + } } -var file_cosmos_protocolpool_v1_genesis_proto_msgTypes = make([]protoimpl.MessageInfo, 1) -var file_cosmos_protocolpool_v1_genesis_proto_goTypes = []interface{}{ - (*GenesisState)(nil), // 0: cosmos.protocolpool.v1.GenesisState - (*ContinuousFund)(nil), // 1: cosmos.protocolpool.v1.ContinuousFund - (*Budget)(nil), // 2: cosmos.protocolpool.v1.Budget +// Clear clears the field such that a subsequent Has call reports false. +// +// Clearing an extension field clears both the extension type and value +// associated with the given field number. +// +// Clear is a mutating operation and unsafe for concurrent use. +func (x *fastReflection_Distribution) Clear(fd protoreflect.FieldDescriptor) { + switch fd.FullName() { + case "cosmos.protocolpool.v1.Distribution.amount": + x.Amount = "" + case "cosmos.protocolpool.v1.Distribution.time": + x.Time = nil + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.protocolpool.v1.Distribution")) + } + panic(fmt.Errorf("message cosmos.protocolpool.v1.Distribution does not contain field %s", fd.FullName())) + } } -var file_cosmos_protocolpool_v1_genesis_proto_depIdxs = []int32{ - 1, // 0: cosmos.protocolpool.v1.GenesisState.continuous_fund:type_name -> cosmos.protocolpool.v1.ContinuousFund - 2, // 1: cosmos.protocolpool.v1.GenesisState.budget:type_name -> cosmos.protocolpool.v1.Budget - 2, // [2:2] is the sub-list for method output_type - 2, // [2:2] is the sub-list for method input_type - 2, // [2:2] is the sub-list for extension type_name - 2, // [2:2] is the sub-list for extension extendee - 0, // [0:2] is the sub-list for field type_name + +// Get retrieves the value for a field. +// +// For unpopulated scalars, it returns the default value, where +// the default value of a bytes scalar is guaranteed to be a copy. +// For unpopulated composite types, it returns an empty, read-only view +// of the value; to obtain a mutable reference, use Mutable. +func (x *fastReflection_Distribution) Get(descriptor protoreflect.FieldDescriptor) protoreflect.Value { + switch descriptor.FullName() { + case "cosmos.protocolpool.v1.Distribution.amount": + value := x.Amount + return protoreflect.ValueOfString(value) + case "cosmos.protocolpool.v1.Distribution.time": + value := x.Time + return protoreflect.ValueOfMessage(value.ProtoReflect()) + default: + if descriptor.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.protocolpool.v1.Distribution")) + } + panic(fmt.Errorf("message cosmos.protocolpool.v1.Distribution does not contain field %s", descriptor.FullName())) + } } -func init() { file_cosmos_protocolpool_v1_genesis_proto_init() } -func file_cosmos_protocolpool_v1_genesis_proto_init() { - if File_cosmos_protocolpool_v1_genesis_proto != nil { - return +// Set stores the value for a field. +// +// For a field belonging to a oneof, it implicitly clears any other field +// that may be currently set within the same oneof. +// For extension fields, it implicitly stores the provided ExtensionType. +// When setting a composite type, it is unspecified whether the stored value +// aliases the source's memory in any way. If the composite value is an +// empty, read-only value, then it panics. +// +// Set is a mutating operation and unsafe for concurrent use. +func (x *fastReflection_Distribution) Set(fd protoreflect.FieldDescriptor, value protoreflect.Value) { + switch fd.FullName() { + case "cosmos.protocolpool.v1.Distribution.amount": + x.Amount = value.Interface().(string) + case "cosmos.protocolpool.v1.Distribution.time": + x.Time = value.Message().Interface().(*timestamppb.Timestamp) + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.protocolpool.v1.Distribution")) + } + panic(fmt.Errorf("message cosmos.protocolpool.v1.Distribution does not contain field %s", fd.FullName())) } - file_cosmos_protocolpool_v1_types_proto_init() - if !protoimpl.UnsafeEnabled { - file_cosmos_protocolpool_v1_genesis_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*GenesisState); i { +} + +// Mutable returns a mutable reference to a composite type. +// +// If the field is unpopulated, it may allocate a composite value. +// For a field belonging to a oneof, it implicitly clears any other field +// that may be currently set within the same oneof. +// For extension fields, it implicitly stores the provided ExtensionType +// if not already stored. +// It panics if the field does not contain a composite type. +// +// Mutable is a mutating operation and unsafe for concurrent use. +func (x *fastReflection_Distribution) Mutable(fd protoreflect.FieldDescriptor) protoreflect.Value { + switch fd.FullName() { + case "cosmos.protocolpool.v1.Distribution.time": + if x.Time == nil { + x.Time = new(timestamppb.Timestamp) + } + return protoreflect.ValueOfMessage(x.Time.ProtoReflect()) + case "cosmos.protocolpool.v1.Distribution.amount": + panic(fmt.Errorf("field amount of message cosmos.protocolpool.v1.Distribution is not mutable")) + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.protocolpool.v1.Distribution")) + } + panic(fmt.Errorf("message cosmos.protocolpool.v1.Distribution does not contain field %s", fd.FullName())) + } +} + +// NewField returns a new value that is assignable to the field +// for the given descriptor. For scalars, this returns the default value. +// For lists, maps, and messages, this returns a new, empty, mutable value. +func (x *fastReflection_Distribution) NewField(fd protoreflect.FieldDescriptor) protoreflect.Value { + switch fd.FullName() { + case "cosmos.protocolpool.v1.Distribution.amount": + return protoreflect.ValueOfString("") + case "cosmos.protocolpool.v1.Distribution.time": + m := new(timestamppb.Timestamp) + return protoreflect.ValueOfMessage(m.ProtoReflect()) + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.protocolpool.v1.Distribution")) + } + panic(fmt.Errorf("message cosmos.protocolpool.v1.Distribution does not contain field %s", fd.FullName())) + } +} + +// WhichOneof reports which field within the oneof is populated, +// returning nil if none are populated. +// It panics if the oneof descriptor does not belong to this message. +func (x *fastReflection_Distribution) WhichOneof(d protoreflect.OneofDescriptor) protoreflect.FieldDescriptor { + switch d.FullName() { + default: + panic(fmt.Errorf("%s is not a oneof field in cosmos.protocolpool.v1.Distribution", d.FullName())) + } + panic("unreachable") +} + +// GetUnknown retrieves the entire list of unknown fields. +// The caller may only mutate the contents of the RawFields +// if the mutated bytes are stored back into the message with SetUnknown. +func (x *fastReflection_Distribution) GetUnknown() protoreflect.RawFields { + return x.unknownFields +} + +// SetUnknown stores an entire list of unknown fields. +// The raw fields must be syntactically valid according to the wire format. +// An implementation may panic if this is not the case. +// Once stored, the caller must not mutate the content of the RawFields. +// An empty RawFields may be passed to clear the fields. +// +// SetUnknown is a mutating operation and unsafe for concurrent use. +func (x *fastReflection_Distribution) SetUnknown(fields protoreflect.RawFields) { + x.unknownFields = fields +} + +// IsValid reports whether the message is valid. +// +// An invalid message is an empty, read-only value. +// +// An invalid message often corresponds to a nil pointer of the concrete +// message type, but the details are implementation dependent. +// Validity is not part of the protobuf data model, and may not +// be preserved in marshaling or other operations. +func (x *fastReflection_Distribution) IsValid() bool { + return x != nil +} + +// ProtoMethods returns optional fastReflectionFeature-path implementations of various operations. +// This method may return nil. +// +// The returned methods type is identical to +// "google.golang.org/protobuf/runtime/protoiface".Methods. +// Consult the protoiface package documentation for details. +func (x *fastReflection_Distribution) ProtoMethods() *protoiface.Methods { + size := func(input protoiface.SizeInput) protoiface.SizeOutput { + x := input.Message.Interface().(*Distribution) + if x == nil { + return protoiface.SizeOutput{ + NoUnkeyedLiterals: input.NoUnkeyedLiterals, + Size: 0, + } + } + options := runtime.SizeInputToOptions(input) + _ = options + var n int + var l int + _ = l + l = len(x.Amount) + if l > 0 { + n += 1 + l + runtime.Sov(uint64(l)) + } + if x.Time != nil { + l = options.Size(x.Time) + n += 1 + l + runtime.Sov(uint64(l)) + } + if x.unknownFields != nil { + n += len(x.unknownFields) + } + return protoiface.SizeOutput{ + NoUnkeyedLiterals: input.NoUnkeyedLiterals, + Size: n, + } + } + + marshal := func(input protoiface.MarshalInput) (protoiface.MarshalOutput, error) { + x := input.Message.Interface().(*Distribution) + if x == nil { + return protoiface.MarshalOutput{ + NoUnkeyedLiterals: input.NoUnkeyedLiterals, + Buf: input.Buf, + }, nil + } + options := runtime.MarshalInputToOptions(input) + _ = options + size := options.Size(x) + dAtA := make([]byte, size) + i := len(dAtA) + _ = i + var l int + _ = l + if x.unknownFields != nil { + i -= len(x.unknownFields) + copy(dAtA[i:], x.unknownFields) + } + if x.Time != nil { + encoded, err := options.Marshal(x.Time) + if err != nil { + return protoiface.MarshalOutput{ + NoUnkeyedLiterals: input.NoUnkeyedLiterals, + Buf: input.Buf, + }, err + } + i -= len(encoded) + copy(dAtA[i:], encoded) + i = runtime.EncodeVarint(dAtA, i, uint64(len(encoded))) + i-- + dAtA[i] = 0x32 + } + if len(x.Amount) > 0 { + i -= len(x.Amount) + copy(dAtA[i:], x.Amount) + i = runtime.EncodeVarint(dAtA, i, uint64(len(x.Amount))) + i-- + dAtA[i] = 0x1a + } + if input.Buf != nil { + input.Buf = append(input.Buf, dAtA...) + } else { + input.Buf = dAtA + } + return protoiface.MarshalOutput{ + NoUnkeyedLiterals: input.NoUnkeyedLiterals, + Buf: input.Buf, + }, nil + } + unmarshal := func(input protoiface.UnmarshalInput) (protoiface.UnmarshalOutput, error) { + x := input.Message.Interface().(*Distribution) + if x == nil { + return protoiface.UnmarshalOutput{ + NoUnkeyedLiterals: input.NoUnkeyedLiterals, + Flags: input.Flags, + }, nil + } + options := runtime.UnmarshalInputToOptions(input) + _ = options + dAtA := input.Buf + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrIntOverflow + } + if iNdEx >= l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: Distribution: wiretype end group for non-group") + } + if fieldNum <= 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: Distribution: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 3: + if wireType != 2 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: wrong wireType = %d for field Amount", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrIntOverflow + } + if iNdEx >= l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength + } + if postIndex > l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + x.Amount = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 6: + if wireType != 2 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: wrong wireType = %d for field Time", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrIntOverflow + } + if iNdEx >= l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength + } + if postIndex > l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + if x.Time == nil { + x.Time = ×tamppb.Timestamp{} + } + if err := options.Unmarshal(dAtA[iNdEx:postIndex], x.Time); err != nil { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := runtime.Skip(dAtA[iNdEx:]) + if err != nil { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength + } + if (iNdEx + skippy) > l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + if !options.DiscardUnknown { + x.unknownFields = append(x.unknownFields, dAtA[iNdEx:iNdEx+skippy]...) + } + iNdEx += skippy + } + } + + if iNdEx > l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, nil + } + return &protoiface.Methods{ + NoUnkeyedLiterals: struct{}{}, + Flags: protoiface.SupportMarshalDeterministic | protoiface.SupportUnmarshalDiscardUnknown, + Size: size, + Marshal: marshal, + Unmarshal: unmarshal, + Merge: nil, + CheckInitialized: nil, + } +} + +// Code generated by protoc-gen-go. DO NOT EDIT. +// versions: +// protoc-gen-go v1.27.0 +// protoc (unknown) +// source: cosmos/protocolpool/v1/genesis.proto + +const ( + // Verify that this generated code is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) + // Verify that runtime/protoimpl is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) +) + +// GenesisState defines the protocolpool module's genesis state. +type GenesisState struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + // ContinuousFund defines the continuous funds at genesis. + ContinuousFund []*ContinuousFund `protobuf:"bytes,1,rep,name=continuous_fund,json=continuousFund,proto3" json:"continuous_fund,omitempty"` + // Budget defines the budget proposals at genesis. + Budget []*Budget `protobuf:"bytes,2,rep,name=budget,proto3" json:"budget,omitempty"` + // last_balance contains the amount of tokens yet to be distributed, will be zero if + // there are no funds to distribute. + LastBalance string `protobuf:"bytes,3,opt,name=last_balance,json=lastBalance,proto3" json:"last_balance,omitempty"` + // distributions contains the list of distributions to be made to continuous + // funds and budgets. It contains time in order to distribute to non-expired + // funds only. + Distributions []*Distribution `protobuf:"bytes,4,rep,name=distributions,proto3" json:"distributions,omitempty"` +} + +func (x *GenesisState) Reset() { + *x = GenesisState{} + if protoimpl.UnsafeEnabled { + mi := &file_cosmos_protocolpool_v1_genesis_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *GenesisState) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*GenesisState) ProtoMessage() {} + +// Deprecated: Use GenesisState.ProtoReflect.Descriptor instead. +func (*GenesisState) Descriptor() ([]byte, []int) { + return file_cosmos_protocolpool_v1_genesis_proto_rawDescGZIP(), []int{0} +} + +func (x *GenesisState) GetContinuousFund() []*ContinuousFund { + if x != nil { + return x.ContinuousFund + } + return nil +} + +func (x *GenesisState) GetBudget() []*Budget { + if x != nil { + return x.Budget + } + return nil +} + +func (x *GenesisState) GetLastBalance() string { + if x != nil { + return x.LastBalance + } + return "" +} + +func (x *GenesisState) GetDistributions() []*Distribution { + if x != nil { + return x.Distributions + } + return nil +} + +type Distribution struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Amount string `protobuf:"bytes,3,opt,name=amount,proto3" json:"amount,omitempty"` + Time *timestamppb.Timestamp `protobuf:"bytes,6,opt,name=time,proto3" json:"time,omitempty"` +} + +func (x *Distribution) Reset() { + *x = Distribution{} + if protoimpl.UnsafeEnabled { + mi := &file_cosmos_protocolpool_v1_genesis_proto_msgTypes[1] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *Distribution) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*Distribution) ProtoMessage() {} + +// Deprecated: Use Distribution.ProtoReflect.Descriptor instead. +func (*Distribution) Descriptor() ([]byte, []int) { + return file_cosmos_protocolpool_v1_genesis_proto_rawDescGZIP(), []int{1} +} + +func (x *Distribution) GetAmount() string { + if x != nil { + return x.Amount + } + return "" +} + +func (x *Distribution) GetTime() *timestamppb.Timestamp { + if x != nil { + return x.Time + } + return nil +} + +var File_cosmos_protocolpool_v1_genesis_proto protoreflect.FileDescriptor + +var file_cosmos_protocolpool_v1_genesis_proto_rawDesc = []byte{ + 0x0a, 0x24, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x6f, + 0x6c, 0x70, 0x6f, 0x6f, 0x6c, 0x2f, 0x76, 0x31, 0x2f, 0x67, 0x65, 0x6e, 0x65, 0x73, 0x69, 0x73, + 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x16, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x70, + 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x6f, 0x6c, 0x70, 0x6f, 0x6f, 0x6c, 0x2e, 0x76, 0x31, 0x1a, 0x22, + 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x6f, 0x6c, 0x70, + 0x6f, 0x6f, 0x6c, 0x2f, 0x76, 0x31, 0x2f, 0x74, 0x79, 0x70, 0x65, 0x73, 0x2e, 0x70, 0x72, 0x6f, + 0x74, 0x6f, 0x1a, 0x14, 0x67, 0x6f, 0x67, 0x6f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x67, 0x6f, + 0x67, 0x6f, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x19, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, + 0x5f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x70, 0x72, + 0x6f, 0x74, 0x6f, 0x1a, 0x1f, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x70, 0x72, 0x6f, 0x74, + 0x6f, 0x62, 0x75, 0x66, 0x2f, 0x74, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x2e, 0x70, + 0x72, 0x6f, 0x74, 0x6f, 0x22, 0xb3, 0x02, 0x0a, 0x0c, 0x47, 0x65, 0x6e, 0x65, 0x73, 0x69, 0x73, + 0x53, 0x74, 0x61, 0x74, 0x65, 0x12, 0x4f, 0x0a, 0x0f, 0x63, 0x6f, 0x6e, 0x74, 0x69, 0x6e, 0x75, + 0x6f, 0x75, 0x73, 0x5f, 0x66, 0x75, 0x6e, 0x64, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x26, + 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x6f, 0x6c, + 0x70, 0x6f, 0x6f, 0x6c, 0x2e, 0x76, 0x31, 0x2e, 0x43, 0x6f, 0x6e, 0x74, 0x69, 0x6e, 0x75, 0x6f, + 0x75, 0x73, 0x46, 0x75, 0x6e, 0x64, 0x52, 0x0e, 0x63, 0x6f, 0x6e, 0x74, 0x69, 0x6e, 0x75, 0x6f, + 0x75, 0x73, 0x46, 0x75, 0x6e, 0x64, 0x12, 0x36, 0x0a, 0x06, 0x62, 0x75, 0x64, 0x67, 0x65, 0x74, + 0x18, 0x02, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x1e, 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, + 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x6f, 0x6c, 0x70, 0x6f, 0x6f, 0x6c, 0x2e, 0x76, 0x31, 0x2e, + 0x42, 0x75, 0x64, 0x67, 0x65, 0x74, 0x52, 0x06, 0x62, 0x75, 0x64, 0x67, 0x65, 0x74, 0x12, 0x4e, + 0x0a, 0x0c, 0x6c, 0x61, 0x73, 0x74, 0x5f, 0x62, 0x61, 0x6c, 0x61, 0x6e, 0x63, 0x65, 0x18, 0x03, + 0x20, 0x01, 0x28, 0x09, 0x42, 0x2b, 0xc8, 0xde, 0x1f, 0x00, 0xda, 0xde, 0x1f, 0x15, 0x63, 0x6f, + 0x73, 0x6d, 0x6f, 0x73, 0x73, 0x64, 0x6b, 0x2e, 0x69, 0x6f, 0x2f, 0x6d, 0x61, 0x74, 0x68, 0x2e, + 0x49, 0x6e, 0x74, 0xd2, 0xb4, 0x2d, 0x0a, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x49, 0x6e, + 0x74, 0x52, 0x0b, 0x6c, 0x61, 0x73, 0x74, 0x42, 0x61, 0x6c, 0x61, 0x6e, 0x63, 0x65, 0x12, 0x4a, + 0x0a, 0x0d, 0x64, 0x69, 0x73, 0x74, 0x72, 0x69, 0x62, 0x75, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x18, + 0x04, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x24, 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x70, + 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x6f, 0x6c, 0x70, 0x6f, 0x6f, 0x6c, 0x2e, 0x76, 0x31, 0x2e, 0x44, + 0x69, 0x73, 0x74, 0x72, 0x69, 0x62, 0x75, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x0d, 0x64, 0x69, 0x73, + 0x74, 0x72, 0x69, 0x62, 0x75, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x22, 0x89, 0x01, 0x0a, 0x0c, 0x44, + 0x69, 0x73, 0x74, 0x72, 0x69, 0x62, 0x75, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x43, 0x0a, 0x06, 0x61, + 0x6d, 0x6f, 0x75, 0x6e, 0x74, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x42, 0x2b, 0xc8, 0xde, 0x1f, + 0x00, 0xda, 0xde, 0x1f, 0x15, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x73, 0x64, 0x6b, 0x2e, 0x69, + 0x6f, 0x2f, 0x6d, 0x61, 0x74, 0x68, 0x2e, 0x49, 0x6e, 0x74, 0xd2, 0xb4, 0x2d, 0x0a, 0x63, 0x6f, + 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x49, 0x6e, 0x74, 0x52, 0x06, 0x61, 0x6d, 0x6f, 0x75, 0x6e, 0x74, + 0x12, 0x34, 0x0a, 0x04, 0x74, 0x69, 0x6d, 0x65, 0x18, 0x06, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1a, + 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, + 0x2e, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x42, 0x04, 0x90, 0xdf, 0x1f, 0x01, + 0x52, 0x04, 0x74, 0x69, 0x6d, 0x65, 0x42, 0xdc, 0x01, 0x0a, 0x1a, 0x63, 0x6f, 0x6d, 0x2e, 0x63, + 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x6f, 0x6c, 0x70, 0x6f, + 0x6f, 0x6c, 0x2e, 0x76, 0x31, 0x42, 0x0c, 0x47, 0x65, 0x6e, 0x65, 0x73, 0x69, 0x73, 0x50, 0x72, + 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x36, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x73, 0x64, 0x6b, + 0x2e, 0x69, 0x6f, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2f, 0x70, + 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x6f, 0x6c, 0x70, 0x6f, 0x6f, 0x6c, 0x2f, 0x76, 0x31, 0x3b, 0x70, + 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x6f, 0x6c, 0x70, 0x6f, 0x6f, 0x6c, 0x76, 0x31, 0xa2, 0x02, 0x03, + 0x43, 0x50, 0x58, 0xaa, 0x02, 0x16, 0x43, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x50, 0x72, 0x6f, + 0x74, 0x6f, 0x63, 0x6f, 0x6c, 0x70, 0x6f, 0x6f, 0x6c, 0x2e, 0x56, 0x31, 0xca, 0x02, 0x16, 0x43, + 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x5c, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x6f, 0x6c, 0x70, 0x6f, + 0x6f, 0x6c, 0x5c, 0x56, 0x31, 0xe2, 0x02, 0x22, 0x43, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x5c, 0x50, + 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x6f, 0x6c, 0x70, 0x6f, 0x6f, 0x6c, 0x5c, 0x56, 0x31, 0x5c, 0x47, + 0x50, 0x42, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0xea, 0x02, 0x18, 0x43, 0x6f, 0x73, + 0x6d, 0x6f, 0x73, 0x3a, 0x3a, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x6f, 0x6c, 0x70, 0x6f, 0x6f, + 0x6c, 0x3a, 0x3a, 0x56, 0x31, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, +} + +var ( + file_cosmos_protocolpool_v1_genesis_proto_rawDescOnce sync.Once + file_cosmos_protocolpool_v1_genesis_proto_rawDescData = file_cosmos_protocolpool_v1_genesis_proto_rawDesc +) + +func file_cosmos_protocolpool_v1_genesis_proto_rawDescGZIP() []byte { + file_cosmos_protocolpool_v1_genesis_proto_rawDescOnce.Do(func() { + file_cosmos_protocolpool_v1_genesis_proto_rawDescData = protoimpl.X.CompressGZIP(file_cosmos_protocolpool_v1_genesis_proto_rawDescData) + }) + return file_cosmos_protocolpool_v1_genesis_proto_rawDescData +} + +var file_cosmos_protocolpool_v1_genesis_proto_msgTypes = make([]protoimpl.MessageInfo, 2) +var file_cosmos_protocolpool_v1_genesis_proto_goTypes = []interface{}{ + (*GenesisState)(nil), // 0: cosmos.protocolpool.v1.GenesisState + (*Distribution)(nil), // 1: cosmos.protocolpool.v1.Distribution + (*ContinuousFund)(nil), // 2: cosmos.protocolpool.v1.ContinuousFund + (*Budget)(nil), // 3: cosmos.protocolpool.v1.Budget + (*timestamppb.Timestamp)(nil), // 4: google.protobuf.Timestamp +} +var file_cosmos_protocolpool_v1_genesis_proto_depIdxs = []int32{ + 2, // 0: cosmos.protocolpool.v1.GenesisState.continuous_fund:type_name -> cosmos.protocolpool.v1.ContinuousFund + 3, // 1: cosmos.protocolpool.v1.GenesisState.budget:type_name -> cosmos.protocolpool.v1.Budget + 1, // 2: cosmos.protocolpool.v1.GenesisState.distributions:type_name -> cosmos.protocolpool.v1.Distribution + 4, // 3: cosmos.protocolpool.v1.Distribution.time:type_name -> google.protobuf.Timestamp + 4, // [4:4] is the sub-list for method output_type + 4, // [4:4] is the sub-list for method input_type + 4, // [4:4] is the sub-list for extension type_name + 4, // [4:4] is the sub-list for extension extendee + 0, // [0:4] is the sub-list for field type_name +} + +func init() { file_cosmos_protocolpool_v1_genesis_proto_init() } +func file_cosmos_protocolpool_v1_genesis_proto_init() { + if File_cosmos_protocolpool_v1_genesis_proto != nil { + return + } + file_cosmos_protocolpool_v1_types_proto_init() + if !protoimpl.UnsafeEnabled { + file_cosmos_protocolpool_v1_genesis_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*GenesisState); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_cosmos_protocolpool_v1_genesis_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*Distribution); i { case 0: return &v.state case 1: @@ -875,7 +1600,7 @@ func file_cosmos_protocolpool_v1_genesis_proto_init() { GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: file_cosmos_protocolpool_v1_genesis_proto_rawDesc, NumEnums: 0, - NumMessages: 1, + NumMessages: 2, NumExtensions: 0, NumServices: 0, }, diff --git a/api/cosmos/store/snapshots/v2/snapshot.pulsar.go b/api/cosmos/store/snapshots/v2/snapshot.pulsar.go new file mode 100644 index 000000000000..a993d16abf82 --- /dev/null +++ b/api/cosmos/store/snapshots/v2/snapshot.pulsar.go @@ -0,0 +1,4455 @@ +// Code generated by protoc-gen-go-pulsar. DO NOT EDIT. +package snapshotsv2 + +import ( + fmt "fmt" + _ "github.com/cosmos/cosmos-proto" + runtime "github.com/cosmos/cosmos-proto/runtime" + _ "github.com/cosmos/gogoproto/gogoproto" + protoreflect "google.golang.org/protobuf/reflect/protoreflect" + protoiface "google.golang.org/protobuf/runtime/protoiface" + protoimpl "google.golang.org/protobuf/runtime/protoimpl" + io "io" + reflect "reflect" + sync "sync" +) + +var ( + md_Snapshot protoreflect.MessageDescriptor + fd_Snapshot_height protoreflect.FieldDescriptor + fd_Snapshot_format protoreflect.FieldDescriptor + fd_Snapshot_chunks protoreflect.FieldDescriptor + fd_Snapshot_hash protoreflect.FieldDescriptor + fd_Snapshot_metadata protoreflect.FieldDescriptor +) + +func init() { + file_cosmos_store_snapshots_v2_snapshot_proto_init() + md_Snapshot = File_cosmos_store_snapshots_v2_snapshot_proto.Messages().ByName("Snapshot") + fd_Snapshot_height = md_Snapshot.Fields().ByName("height") + fd_Snapshot_format = md_Snapshot.Fields().ByName("format") + fd_Snapshot_chunks = md_Snapshot.Fields().ByName("chunks") + fd_Snapshot_hash = md_Snapshot.Fields().ByName("hash") + fd_Snapshot_metadata = md_Snapshot.Fields().ByName("metadata") +} + +var _ protoreflect.Message = (*fastReflection_Snapshot)(nil) + +type fastReflection_Snapshot Snapshot + +func (x *Snapshot) ProtoReflect() protoreflect.Message { + return (*fastReflection_Snapshot)(x) +} + +func (x *Snapshot) slowProtoReflect() protoreflect.Message { + mi := &file_cosmos_store_snapshots_v2_snapshot_proto_msgTypes[0] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +var _fastReflection_Snapshot_messageType fastReflection_Snapshot_messageType +var _ protoreflect.MessageType = fastReflection_Snapshot_messageType{} + +type fastReflection_Snapshot_messageType struct{} + +func (x fastReflection_Snapshot_messageType) Zero() protoreflect.Message { + return (*fastReflection_Snapshot)(nil) +} +func (x fastReflection_Snapshot_messageType) New() protoreflect.Message { + return new(fastReflection_Snapshot) +} +func (x fastReflection_Snapshot_messageType) Descriptor() protoreflect.MessageDescriptor { + return md_Snapshot +} + +// Descriptor returns message descriptor, which contains only the protobuf +// type information for the message. +func (x *fastReflection_Snapshot) Descriptor() protoreflect.MessageDescriptor { + return md_Snapshot +} + +// Type returns the message type, which encapsulates both Go and protobuf +// type information. If the Go type information is not needed, +// it is recommended that the message descriptor be used instead. +func (x *fastReflection_Snapshot) Type() protoreflect.MessageType { + return _fastReflection_Snapshot_messageType +} + +// New returns a newly allocated and mutable empty message. +func (x *fastReflection_Snapshot) New() protoreflect.Message { + return new(fastReflection_Snapshot) +} + +// Interface unwraps the message reflection interface and +// returns the underlying ProtoMessage interface. +func (x *fastReflection_Snapshot) Interface() protoreflect.ProtoMessage { + return (*Snapshot)(x) +} + +// Range iterates over every populated field in an undefined order, +// calling f for each field descriptor and value encountered. +// Range returns immediately if f returns false. +// While iterating, mutating operations may only be performed +// on the current field descriptor. +func (x *fastReflection_Snapshot) Range(f func(protoreflect.FieldDescriptor, protoreflect.Value) bool) { + if x.Height != uint64(0) { + value := protoreflect.ValueOfUint64(x.Height) + if !f(fd_Snapshot_height, value) { + return + } + } + if x.Format != uint32(0) { + value := protoreflect.ValueOfUint32(x.Format) + if !f(fd_Snapshot_format, value) { + return + } + } + if x.Chunks != uint32(0) { + value := protoreflect.ValueOfUint32(x.Chunks) + if !f(fd_Snapshot_chunks, value) { + return + } + } + if len(x.Hash) != 0 { + value := protoreflect.ValueOfBytes(x.Hash) + if !f(fd_Snapshot_hash, value) { + return + } + } + if x.Metadata != nil { + value := protoreflect.ValueOfMessage(x.Metadata.ProtoReflect()) + if !f(fd_Snapshot_metadata, value) { + return + } + } +} + +// Has reports whether a field is populated. +// +// Some fields have the property of nullability where it is possible to +// distinguish between the default value of a field and whether the field +// was explicitly populated with the default value. Singular message fields, +// member fields of a oneof, and proto2 scalar fields are nullable. Such +// fields are populated only if explicitly set. +// +// In other cases (aside from the nullable cases above), +// a proto3 scalar field is populated if it contains a non-zero value, and +// a repeated field is populated if it is non-empty. +func (x *fastReflection_Snapshot) Has(fd protoreflect.FieldDescriptor) bool { + switch fd.FullName() { + case "cosmos.store.snapshots.v2.Snapshot.height": + return x.Height != uint64(0) + case "cosmos.store.snapshots.v2.Snapshot.format": + return x.Format != uint32(0) + case "cosmos.store.snapshots.v2.Snapshot.chunks": + return x.Chunks != uint32(0) + case "cosmos.store.snapshots.v2.Snapshot.hash": + return len(x.Hash) != 0 + case "cosmos.store.snapshots.v2.Snapshot.metadata": + return x.Metadata != nil + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.store.snapshots.v2.Snapshot")) + } + panic(fmt.Errorf("message cosmos.store.snapshots.v2.Snapshot does not contain field %s", fd.FullName())) + } +} + +// Clear clears the field such that a subsequent Has call reports false. +// +// Clearing an extension field clears both the extension type and value +// associated with the given field number. +// +// Clear is a mutating operation and unsafe for concurrent use. +func (x *fastReflection_Snapshot) Clear(fd protoreflect.FieldDescriptor) { + switch fd.FullName() { + case "cosmos.store.snapshots.v2.Snapshot.height": + x.Height = uint64(0) + case "cosmos.store.snapshots.v2.Snapshot.format": + x.Format = uint32(0) + case "cosmos.store.snapshots.v2.Snapshot.chunks": + x.Chunks = uint32(0) + case "cosmos.store.snapshots.v2.Snapshot.hash": + x.Hash = nil + case "cosmos.store.snapshots.v2.Snapshot.metadata": + x.Metadata = nil + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.store.snapshots.v2.Snapshot")) + } + panic(fmt.Errorf("message cosmos.store.snapshots.v2.Snapshot does not contain field %s", fd.FullName())) + } +} + +// Get retrieves the value for a field. +// +// For unpopulated scalars, it returns the default value, where +// the default value of a bytes scalar is guaranteed to be a copy. +// For unpopulated composite types, it returns an empty, read-only view +// of the value; to obtain a mutable reference, use Mutable. +func (x *fastReflection_Snapshot) Get(descriptor protoreflect.FieldDescriptor) protoreflect.Value { + switch descriptor.FullName() { + case "cosmos.store.snapshots.v2.Snapshot.height": + value := x.Height + return protoreflect.ValueOfUint64(value) + case "cosmos.store.snapshots.v2.Snapshot.format": + value := x.Format + return protoreflect.ValueOfUint32(value) + case "cosmos.store.snapshots.v2.Snapshot.chunks": + value := x.Chunks + return protoreflect.ValueOfUint32(value) + case "cosmos.store.snapshots.v2.Snapshot.hash": + value := x.Hash + return protoreflect.ValueOfBytes(value) + case "cosmos.store.snapshots.v2.Snapshot.metadata": + value := x.Metadata + return protoreflect.ValueOfMessage(value.ProtoReflect()) + default: + if descriptor.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.store.snapshots.v2.Snapshot")) + } + panic(fmt.Errorf("message cosmos.store.snapshots.v2.Snapshot does not contain field %s", descriptor.FullName())) + } +} + +// Set stores the value for a field. +// +// For a field belonging to a oneof, it implicitly clears any other field +// that may be currently set within the same oneof. +// For extension fields, it implicitly stores the provided ExtensionType. +// When setting a composite type, it is unspecified whether the stored value +// aliases the source's memory in any way. If the composite value is an +// empty, read-only value, then it panics. +// +// Set is a mutating operation and unsafe for concurrent use. +func (x *fastReflection_Snapshot) Set(fd protoreflect.FieldDescriptor, value protoreflect.Value) { + switch fd.FullName() { + case "cosmos.store.snapshots.v2.Snapshot.height": + x.Height = value.Uint() + case "cosmos.store.snapshots.v2.Snapshot.format": + x.Format = uint32(value.Uint()) + case "cosmos.store.snapshots.v2.Snapshot.chunks": + x.Chunks = uint32(value.Uint()) + case "cosmos.store.snapshots.v2.Snapshot.hash": + x.Hash = value.Bytes() + case "cosmos.store.snapshots.v2.Snapshot.metadata": + x.Metadata = value.Message().Interface().(*Metadata) + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.store.snapshots.v2.Snapshot")) + } + panic(fmt.Errorf("message cosmos.store.snapshots.v2.Snapshot does not contain field %s", fd.FullName())) + } +} + +// Mutable returns a mutable reference to a composite type. +// +// If the field is unpopulated, it may allocate a composite value. +// For a field belonging to a oneof, it implicitly clears any other field +// that may be currently set within the same oneof. +// For extension fields, it implicitly stores the provided ExtensionType +// if not already stored. +// It panics if the field does not contain a composite type. +// +// Mutable is a mutating operation and unsafe for concurrent use. +func (x *fastReflection_Snapshot) Mutable(fd protoreflect.FieldDescriptor) protoreflect.Value { + switch fd.FullName() { + case "cosmos.store.snapshots.v2.Snapshot.metadata": + if x.Metadata == nil { + x.Metadata = new(Metadata) + } + return protoreflect.ValueOfMessage(x.Metadata.ProtoReflect()) + case "cosmos.store.snapshots.v2.Snapshot.height": + panic(fmt.Errorf("field height of message cosmos.store.snapshots.v2.Snapshot is not mutable")) + case "cosmos.store.snapshots.v2.Snapshot.format": + panic(fmt.Errorf("field format of message cosmos.store.snapshots.v2.Snapshot is not mutable")) + case "cosmos.store.snapshots.v2.Snapshot.chunks": + panic(fmt.Errorf("field chunks of message cosmos.store.snapshots.v2.Snapshot is not mutable")) + case "cosmos.store.snapshots.v2.Snapshot.hash": + panic(fmt.Errorf("field hash of message cosmos.store.snapshots.v2.Snapshot is not mutable")) + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.store.snapshots.v2.Snapshot")) + } + panic(fmt.Errorf("message cosmos.store.snapshots.v2.Snapshot does not contain field %s", fd.FullName())) + } +} + +// NewField returns a new value that is assignable to the field +// for the given descriptor. For scalars, this returns the default value. +// For lists, maps, and messages, this returns a new, empty, mutable value. +func (x *fastReflection_Snapshot) NewField(fd protoreflect.FieldDescriptor) protoreflect.Value { + switch fd.FullName() { + case "cosmos.store.snapshots.v2.Snapshot.height": + return protoreflect.ValueOfUint64(uint64(0)) + case "cosmos.store.snapshots.v2.Snapshot.format": + return protoreflect.ValueOfUint32(uint32(0)) + case "cosmos.store.snapshots.v2.Snapshot.chunks": + return protoreflect.ValueOfUint32(uint32(0)) + case "cosmos.store.snapshots.v2.Snapshot.hash": + return protoreflect.ValueOfBytes(nil) + case "cosmos.store.snapshots.v2.Snapshot.metadata": + m := new(Metadata) + return protoreflect.ValueOfMessage(m.ProtoReflect()) + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.store.snapshots.v2.Snapshot")) + } + panic(fmt.Errorf("message cosmos.store.snapshots.v2.Snapshot does not contain field %s", fd.FullName())) + } +} + +// WhichOneof reports which field within the oneof is populated, +// returning nil if none are populated. +// It panics if the oneof descriptor does not belong to this message. +func (x *fastReflection_Snapshot) WhichOneof(d protoreflect.OneofDescriptor) protoreflect.FieldDescriptor { + switch d.FullName() { + default: + panic(fmt.Errorf("%s is not a oneof field in cosmos.store.snapshots.v2.Snapshot", d.FullName())) + } + panic("unreachable") +} + +// GetUnknown retrieves the entire list of unknown fields. +// The caller may only mutate the contents of the RawFields +// if the mutated bytes are stored back into the message with SetUnknown. +func (x *fastReflection_Snapshot) GetUnknown() protoreflect.RawFields { + return x.unknownFields +} + +// SetUnknown stores an entire list of unknown fields. +// The raw fields must be syntactically valid according to the wire format. +// An implementation may panic if this is not the case. +// Once stored, the caller must not mutate the content of the RawFields. +// An empty RawFields may be passed to clear the fields. +// +// SetUnknown is a mutating operation and unsafe for concurrent use. +func (x *fastReflection_Snapshot) SetUnknown(fields protoreflect.RawFields) { + x.unknownFields = fields +} + +// IsValid reports whether the message is valid. +// +// An invalid message is an empty, read-only value. +// +// An invalid message often corresponds to a nil pointer of the concrete +// message type, but the details are implementation dependent. +// Validity is not part of the protobuf data model, and may not +// be preserved in marshaling or other operations. +func (x *fastReflection_Snapshot) IsValid() bool { + return x != nil +} + +// ProtoMethods returns optional fastReflectionFeature-path implementations of various operations. +// This method may return nil. +// +// The returned methods type is identical to +// "google.golang.org/protobuf/runtime/protoiface".Methods. +// Consult the protoiface package documentation for details. +func (x *fastReflection_Snapshot) ProtoMethods() *protoiface.Methods { + size := func(input protoiface.SizeInput) protoiface.SizeOutput { + x := input.Message.Interface().(*Snapshot) + if x == nil { + return protoiface.SizeOutput{ + NoUnkeyedLiterals: input.NoUnkeyedLiterals, + Size: 0, + } + } + options := runtime.SizeInputToOptions(input) + _ = options + var n int + var l int + _ = l + if x.Height != 0 { + n += 1 + runtime.Sov(uint64(x.Height)) + } + if x.Format != 0 { + n += 1 + runtime.Sov(uint64(x.Format)) + } + if x.Chunks != 0 { + n += 1 + runtime.Sov(uint64(x.Chunks)) + } + l = len(x.Hash) + if l > 0 { + n += 1 + l + runtime.Sov(uint64(l)) + } + if x.Metadata != nil { + l = options.Size(x.Metadata) + n += 1 + l + runtime.Sov(uint64(l)) + } + if x.unknownFields != nil { + n += len(x.unknownFields) + } + return protoiface.SizeOutput{ + NoUnkeyedLiterals: input.NoUnkeyedLiterals, + Size: n, + } + } + + marshal := func(input protoiface.MarshalInput) (protoiface.MarshalOutput, error) { + x := input.Message.Interface().(*Snapshot) + if x == nil { + return protoiface.MarshalOutput{ + NoUnkeyedLiterals: input.NoUnkeyedLiterals, + Buf: input.Buf, + }, nil + } + options := runtime.MarshalInputToOptions(input) + _ = options + size := options.Size(x) + dAtA := make([]byte, size) + i := len(dAtA) + _ = i + var l int + _ = l + if x.unknownFields != nil { + i -= len(x.unknownFields) + copy(dAtA[i:], x.unknownFields) + } + if x.Metadata != nil { + encoded, err := options.Marshal(x.Metadata) + if err != nil { + return protoiface.MarshalOutput{ + NoUnkeyedLiterals: input.NoUnkeyedLiterals, + Buf: input.Buf, + }, err + } + i -= len(encoded) + copy(dAtA[i:], encoded) + i = runtime.EncodeVarint(dAtA, i, uint64(len(encoded))) + i-- + dAtA[i] = 0x2a + } + if len(x.Hash) > 0 { + i -= len(x.Hash) + copy(dAtA[i:], x.Hash) + i = runtime.EncodeVarint(dAtA, i, uint64(len(x.Hash))) + i-- + dAtA[i] = 0x22 + } + if x.Chunks != 0 { + i = runtime.EncodeVarint(dAtA, i, uint64(x.Chunks)) + i-- + dAtA[i] = 0x18 + } + if x.Format != 0 { + i = runtime.EncodeVarint(dAtA, i, uint64(x.Format)) + i-- + dAtA[i] = 0x10 + } + if x.Height != 0 { + i = runtime.EncodeVarint(dAtA, i, uint64(x.Height)) + i-- + dAtA[i] = 0x8 + } + if input.Buf != nil { + input.Buf = append(input.Buf, dAtA...) + } else { + input.Buf = dAtA + } + return protoiface.MarshalOutput{ + NoUnkeyedLiterals: input.NoUnkeyedLiterals, + Buf: input.Buf, + }, nil + } + unmarshal := func(input protoiface.UnmarshalInput) (protoiface.UnmarshalOutput, error) { + x := input.Message.Interface().(*Snapshot) + if x == nil { + return protoiface.UnmarshalOutput{ + NoUnkeyedLiterals: input.NoUnkeyedLiterals, + Flags: input.Flags, + }, nil + } + options := runtime.UnmarshalInputToOptions(input) + _ = options + dAtA := input.Buf + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrIntOverflow + } + if iNdEx >= l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: Snapshot: wiretype end group for non-group") + } + if fieldNum <= 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: Snapshot: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: wrong wireType = %d for field Height", wireType) + } + x.Height = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrIntOverflow + } + if iNdEx >= l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + x.Height |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 2: + if wireType != 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: wrong wireType = %d for field Format", wireType) + } + x.Format = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrIntOverflow + } + if iNdEx >= l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + x.Format |= uint32(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 3: + if wireType != 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: wrong wireType = %d for field Chunks", wireType) + } + x.Chunks = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrIntOverflow + } + if iNdEx >= l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + x.Chunks |= uint32(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 4: + if wireType != 2 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: wrong wireType = %d for field Hash", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrIntOverflow + } + if iNdEx >= l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength + } + if postIndex > l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + x.Hash = append(x.Hash[:0], dAtA[iNdEx:postIndex]...) + if x.Hash == nil { + x.Hash = []byte{} + } + iNdEx = postIndex + case 5: + if wireType != 2 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: wrong wireType = %d for field Metadata", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrIntOverflow + } + if iNdEx >= l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength + } + if postIndex > l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + if x.Metadata == nil { + x.Metadata = &Metadata{} + } + if err := options.Unmarshal(dAtA[iNdEx:postIndex], x.Metadata); err != nil { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := runtime.Skip(dAtA[iNdEx:]) + if err != nil { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength + } + if (iNdEx + skippy) > l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + if !options.DiscardUnknown { + x.unknownFields = append(x.unknownFields, dAtA[iNdEx:iNdEx+skippy]...) + } + iNdEx += skippy + } + } + + if iNdEx > l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, nil + } + return &protoiface.Methods{ + NoUnkeyedLiterals: struct{}{}, + Flags: protoiface.SupportMarshalDeterministic | protoiface.SupportUnmarshalDiscardUnknown, + Size: size, + Marshal: marshal, + Unmarshal: unmarshal, + Merge: nil, + CheckInitialized: nil, + } +} + +var _ protoreflect.List = (*_Metadata_1_list)(nil) + +type _Metadata_1_list struct { + list *[][]byte +} + +func (x *_Metadata_1_list) Len() int { + if x.list == nil { + return 0 + } + return len(*x.list) +} + +func (x *_Metadata_1_list) Get(i int) protoreflect.Value { + return protoreflect.ValueOfBytes((*x.list)[i]) +} + +func (x *_Metadata_1_list) Set(i int, value protoreflect.Value) { + valueUnwrapped := value.Bytes() + concreteValue := valueUnwrapped + (*x.list)[i] = concreteValue +} + +func (x *_Metadata_1_list) Append(value protoreflect.Value) { + valueUnwrapped := value.Bytes() + concreteValue := valueUnwrapped + *x.list = append(*x.list, concreteValue) +} + +func (x *_Metadata_1_list) AppendMutable() protoreflect.Value { + panic(fmt.Errorf("AppendMutable can not be called on message Metadata at list field ChunkHashes as it is not of Message kind")) +} + +func (x *_Metadata_1_list) Truncate(n int) { + *x.list = (*x.list)[:n] +} + +func (x *_Metadata_1_list) NewElement() protoreflect.Value { + var v []byte + return protoreflect.ValueOfBytes(v) +} + +func (x *_Metadata_1_list) IsValid() bool { + return x.list != nil +} + +var ( + md_Metadata protoreflect.MessageDescriptor + fd_Metadata_chunk_hashes protoreflect.FieldDescriptor +) + +func init() { + file_cosmos_store_snapshots_v2_snapshot_proto_init() + md_Metadata = File_cosmos_store_snapshots_v2_snapshot_proto.Messages().ByName("Metadata") + fd_Metadata_chunk_hashes = md_Metadata.Fields().ByName("chunk_hashes") +} + +var _ protoreflect.Message = (*fastReflection_Metadata)(nil) + +type fastReflection_Metadata Metadata + +func (x *Metadata) ProtoReflect() protoreflect.Message { + return (*fastReflection_Metadata)(x) +} + +func (x *Metadata) slowProtoReflect() protoreflect.Message { + mi := &file_cosmos_store_snapshots_v2_snapshot_proto_msgTypes[1] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +var _fastReflection_Metadata_messageType fastReflection_Metadata_messageType +var _ protoreflect.MessageType = fastReflection_Metadata_messageType{} + +type fastReflection_Metadata_messageType struct{} + +func (x fastReflection_Metadata_messageType) Zero() protoreflect.Message { + return (*fastReflection_Metadata)(nil) +} +func (x fastReflection_Metadata_messageType) New() protoreflect.Message { + return new(fastReflection_Metadata) +} +func (x fastReflection_Metadata_messageType) Descriptor() protoreflect.MessageDescriptor { + return md_Metadata +} + +// Descriptor returns message descriptor, which contains only the protobuf +// type information for the message. +func (x *fastReflection_Metadata) Descriptor() protoreflect.MessageDescriptor { + return md_Metadata +} + +// Type returns the message type, which encapsulates both Go and protobuf +// type information. If the Go type information is not needed, +// it is recommended that the message descriptor be used instead. +func (x *fastReflection_Metadata) Type() protoreflect.MessageType { + return _fastReflection_Metadata_messageType +} + +// New returns a newly allocated and mutable empty message. +func (x *fastReflection_Metadata) New() protoreflect.Message { + return new(fastReflection_Metadata) +} + +// Interface unwraps the message reflection interface and +// returns the underlying ProtoMessage interface. +func (x *fastReflection_Metadata) Interface() protoreflect.ProtoMessage { + return (*Metadata)(x) +} + +// Range iterates over every populated field in an undefined order, +// calling f for each field descriptor and value encountered. +// Range returns immediately if f returns false. +// While iterating, mutating operations may only be performed +// on the current field descriptor. +func (x *fastReflection_Metadata) Range(f func(protoreflect.FieldDescriptor, protoreflect.Value) bool) { + if len(x.ChunkHashes) != 0 { + value := protoreflect.ValueOfList(&_Metadata_1_list{list: &x.ChunkHashes}) + if !f(fd_Metadata_chunk_hashes, value) { + return + } + } +} + +// Has reports whether a field is populated. +// +// Some fields have the property of nullability where it is possible to +// distinguish between the default value of a field and whether the field +// was explicitly populated with the default value. Singular message fields, +// member fields of a oneof, and proto2 scalar fields are nullable. Such +// fields are populated only if explicitly set. +// +// In other cases (aside from the nullable cases above), +// a proto3 scalar field is populated if it contains a non-zero value, and +// a repeated field is populated if it is non-empty. +func (x *fastReflection_Metadata) Has(fd protoreflect.FieldDescriptor) bool { + switch fd.FullName() { + case "cosmos.store.snapshots.v2.Metadata.chunk_hashes": + return len(x.ChunkHashes) != 0 + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.store.snapshots.v2.Metadata")) + } + panic(fmt.Errorf("message cosmos.store.snapshots.v2.Metadata does not contain field %s", fd.FullName())) + } +} + +// Clear clears the field such that a subsequent Has call reports false. +// +// Clearing an extension field clears both the extension type and value +// associated with the given field number. +// +// Clear is a mutating operation and unsafe for concurrent use. +func (x *fastReflection_Metadata) Clear(fd protoreflect.FieldDescriptor) { + switch fd.FullName() { + case "cosmos.store.snapshots.v2.Metadata.chunk_hashes": + x.ChunkHashes = nil + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.store.snapshots.v2.Metadata")) + } + panic(fmt.Errorf("message cosmos.store.snapshots.v2.Metadata does not contain field %s", fd.FullName())) + } +} + +// Get retrieves the value for a field. +// +// For unpopulated scalars, it returns the default value, where +// the default value of a bytes scalar is guaranteed to be a copy. +// For unpopulated composite types, it returns an empty, read-only view +// of the value; to obtain a mutable reference, use Mutable. +func (x *fastReflection_Metadata) Get(descriptor protoreflect.FieldDescriptor) protoreflect.Value { + switch descriptor.FullName() { + case "cosmos.store.snapshots.v2.Metadata.chunk_hashes": + if len(x.ChunkHashes) == 0 { + return protoreflect.ValueOfList(&_Metadata_1_list{}) + } + listValue := &_Metadata_1_list{list: &x.ChunkHashes} + return protoreflect.ValueOfList(listValue) + default: + if descriptor.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.store.snapshots.v2.Metadata")) + } + panic(fmt.Errorf("message cosmos.store.snapshots.v2.Metadata does not contain field %s", descriptor.FullName())) + } +} + +// Set stores the value for a field. +// +// For a field belonging to a oneof, it implicitly clears any other field +// that may be currently set within the same oneof. +// For extension fields, it implicitly stores the provided ExtensionType. +// When setting a composite type, it is unspecified whether the stored value +// aliases the source's memory in any way. If the composite value is an +// empty, read-only value, then it panics. +// +// Set is a mutating operation and unsafe for concurrent use. +func (x *fastReflection_Metadata) Set(fd protoreflect.FieldDescriptor, value protoreflect.Value) { + switch fd.FullName() { + case "cosmos.store.snapshots.v2.Metadata.chunk_hashes": + lv := value.List() + clv := lv.(*_Metadata_1_list) + x.ChunkHashes = *clv.list + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.store.snapshots.v2.Metadata")) + } + panic(fmt.Errorf("message cosmos.store.snapshots.v2.Metadata does not contain field %s", fd.FullName())) + } +} + +// Mutable returns a mutable reference to a composite type. +// +// If the field is unpopulated, it may allocate a composite value. +// For a field belonging to a oneof, it implicitly clears any other field +// that may be currently set within the same oneof. +// For extension fields, it implicitly stores the provided ExtensionType +// if not already stored. +// It panics if the field does not contain a composite type. +// +// Mutable is a mutating operation and unsafe for concurrent use. +func (x *fastReflection_Metadata) Mutable(fd protoreflect.FieldDescriptor) protoreflect.Value { + switch fd.FullName() { + case "cosmos.store.snapshots.v2.Metadata.chunk_hashes": + if x.ChunkHashes == nil { + x.ChunkHashes = [][]byte{} + } + value := &_Metadata_1_list{list: &x.ChunkHashes} + return protoreflect.ValueOfList(value) + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.store.snapshots.v2.Metadata")) + } + panic(fmt.Errorf("message cosmos.store.snapshots.v2.Metadata does not contain field %s", fd.FullName())) + } +} + +// NewField returns a new value that is assignable to the field +// for the given descriptor. For scalars, this returns the default value. +// For lists, maps, and messages, this returns a new, empty, mutable value. +func (x *fastReflection_Metadata) NewField(fd protoreflect.FieldDescriptor) protoreflect.Value { + switch fd.FullName() { + case "cosmos.store.snapshots.v2.Metadata.chunk_hashes": + list := [][]byte{} + return protoreflect.ValueOfList(&_Metadata_1_list{list: &list}) + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.store.snapshots.v2.Metadata")) + } + panic(fmt.Errorf("message cosmos.store.snapshots.v2.Metadata does not contain field %s", fd.FullName())) + } +} + +// WhichOneof reports which field within the oneof is populated, +// returning nil if none are populated. +// It panics if the oneof descriptor does not belong to this message. +func (x *fastReflection_Metadata) WhichOneof(d protoreflect.OneofDescriptor) protoreflect.FieldDescriptor { + switch d.FullName() { + default: + panic(fmt.Errorf("%s is not a oneof field in cosmos.store.snapshots.v2.Metadata", d.FullName())) + } + panic("unreachable") +} + +// GetUnknown retrieves the entire list of unknown fields. +// The caller may only mutate the contents of the RawFields +// if the mutated bytes are stored back into the message with SetUnknown. +func (x *fastReflection_Metadata) GetUnknown() protoreflect.RawFields { + return x.unknownFields +} + +// SetUnknown stores an entire list of unknown fields. +// The raw fields must be syntactically valid according to the wire format. +// An implementation may panic if this is not the case. +// Once stored, the caller must not mutate the content of the RawFields. +// An empty RawFields may be passed to clear the fields. +// +// SetUnknown is a mutating operation and unsafe for concurrent use. +func (x *fastReflection_Metadata) SetUnknown(fields protoreflect.RawFields) { + x.unknownFields = fields +} + +// IsValid reports whether the message is valid. +// +// An invalid message is an empty, read-only value. +// +// An invalid message often corresponds to a nil pointer of the concrete +// message type, but the details are implementation dependent. +// Validity is not part of the protobuf data model, and may not +// be preserved in marshaling or other operations. +func (x *fastReflection_Metadata) IsValid() bool { + return x != nil +} + +// ProtoMethods returns optional fastReflectionFeature-path implementations of various operations. +// This method may return nil. +// +// The returned methods type is identical to +// "google.golang.org/protobuf/runtime/protoiface".Methods. +// Consult the protoiface package documentation for details. +func (x *fastReflection_Metadata) ProtoMethods() *protoiface.Methods { + size := func(input protoiface.SizeInput) protoiface.SizeOutput { + x := input.Message.Interface().(*Metadata) + if x == nil { + return protoiface.SizeOutput{ + NoUnkeyedLiterals: input.NoUnkeyedLiterals, + Size: 0, + } + } + options := runtime.SizeInputToOptions(input) + _ = options + var n int + var l int + _ = l + if len(x.ChunkHashes) > 0 { + for _, b := range x.ChunkHashes { + l = len(b) + n += 1 + l + runtime.Sov(uint64(l)) + } + } + if x.unknownFields != nil { + n += len(x.unknownFields) + } + return protoiface.SizeOutput{ + NoUnkeyedLiterals: input.NoUnkeyedLiterals, + Size: n, + } + } + + marshal := func(input protoiface.MarshalInput) (protoiface.MarshalOutput, error) { + x := input.Message.Interface().(*Metadata) + if x == nil { + return protoiface.MarshalOutput{ + NoUnkeyedLiterals: input.NoUnkeyedLiterals, + Buf: input.Buf, + }, nil + } + options := runtime.MarshalInputToOptions(input) + _ = options + size := options.Size(x) + dAtA := make([]byte, size) + i := len(dAtA) + _ = i + var l int + _ = l + if x.unknownFields != nil { + i -= len(x.unknownFields) + copy(dAtA[i:], x.unknownFields) + } + if len(x.ChunkHashes) > 0 { + for iNdEx := len(x.ChunkHashes) - 1; iNdEx >= 0; iNdEx-- { + i -= len(x.ChunkHashes[iNdEx]) + copy(dAtA[i:], x.ChunkHashes[iNdEx]) + i = runtime.EncodeVarint(dAtA, i, uint64(len(x.ChunkHashes[iNdEx]))) + i-- + dAtA[i] = 0xa + } + } + if input.Buf != nil { + input.Buf = append(input.Buf, dAtA...) + } else { + input.Buf = dAtA + } + return protoiface.MarshalOutput{ + NoUnkeyedLiterals: input.NoUnkeyedLiterals, + Buf: input.Buf, + }, nil + } + unmarshal := func(input protoiface.UnmarshalInput) (protoiface.UnmarshalOutput, error) { + x := input.Message.Interface().(*Metadata) + if x == nil { + return protoiface.UnmarshalOutput{ + NoUnkeyedLiterals: input.NoUnkeyedLiterals, + Flags: input.Flags, + }, nil + } + options := runtime.UnmarshalInputToOptions(input) + _ = options + dAtA := input.Buf + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrIntOverflow + } + if iNdEx >= l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: Metadata: wiretype end group for non-group") + } + if fieldNum <= 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: Metadata: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: wrong wireType = %d for field ChunkHashes", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrIntOverflow + } + if iNdEx >= l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength + } + if postIndex > l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + x.ChunkHashes = append(x.ChunkHashes, make([]byte, postIndex-iNdEx)) + copy(x.ChunkHashes[len(x.ChunkHashes)-1], dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := runtime.Skip(dAtA[iNdEx:]) + if err != nil { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength + } + if (iNdEx + skippy) > l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + if !options.DiscardUnknown { + x.unknownFields = append(x.unknownFields, dAtA[iNdEx:iNdEx+skippy]...) + } + iNdEx += skippy + } + } + + if iNdEx > l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, nil + } + return &protoiface.Methods{ + NoUnkeyedLiterals: struct{}{}, + Flags: protoiface.SupportMarshalDeterministic | protoiface.SupportUnmarshalDiscardUnknown, + Size: size, + Marshal: marshal, + Unmarshal: unmarshal, + Merge: nil, + CheckInitialized: nil, + } +} + +var ( + md_SnapshotItem protoreflect.MessageDescriptor + fd_SnapshotItem_store protoreflect.FieldDescriptor + fd_SnapshotItem_iavl protoreflect.FieldDescriptor + fd_SnapshotItem_extension protoreflect.FieldDescriptor + fd_SnapshotItem_extension_payload protoreflect.FieldDescriptor +) + +func init() { + file_cosmos_store_snapshots_v2_snapshot_proto_init() + md_SnapshotItem = File_cosmos_store_snapshots_v2_snapshot_proto.Messages().ByName("SnapshotItem") + fd_SnapshotItem_store = md_SnapshotItem.Fields().ByName("store") + fd_SnapshotItem_iavl = md_SnapshotItem.Fields().ByName("iavl") + fd_SnapshotItem_extension = md_SnapshotItem.Fields().ByName("extension") + fd_SnapshotItem_extension_payload = md_SnapshotItem.Fields().ByName("extension_payload") +} + +var _ protoreflect.Message = (*fastReflection_SnapshotItem)(nil) + +type fastReflection_SnapshotItem SnapshotItem + +func (x *SnapshotItem) ProtoReflect() protoreflect.Message { + return (*fastReflection_SnapshotItem)(x) +} + +func (x *SnapshotItem) slowProtoReflect() protoreflect.Message { + mi := &file_cosmos_store_snapshots_v2_snapshot_proto_msgTypes[2] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +var _fastReflection_SnapshotItem_messageType fastReflection_SnapshotItem_messageType +var _ protoreflect.MessageType = fastReflection_SnapshotItem_messageType{} + +type fastReflection_SnapshotItem_messageType struct{} + +func (x fastReflection_SnapshotItem_messageType) Zero() protoreflect.Message { + return (*fastReflection_SnapshotItem)(nil) +} +func (x fastReflection_SnapshotItem_messageType) New() protoreflect.Message { + return new(fastReflection_SnapshotItem) +} +func (x fastReflection_SnapshotItem_messageType) Descriptor() protoreflect.MessageDescriptor { + return md_SnapshotItem +} + +// Descriptor returns message descriptor, which contains only the protobuf +// type information for the message. +func (x *fastReflection_SnapshotItem) Descriptor() protoreflect.MessageDescriptor { + return md_SnapshotItem +} + +// Type returns the message type, which encapsulates both Go and protobuf +// type information. If the Go type information is not needed, +// it is recommended that the message descriptor be used instead. +func (x *fastReflection_SnapshotItem) Type() protoreflect.MessageType { + return _fastReflection_SnapshotItem_messageType +} + +// New returns a newly allocated and mutable empty message. +func (x *fastReflection_SnapshotItem) New() protoreflect.Message { + return new(fastReflection_SnapshotItem) +} + +// Interface unwraps the message reflection interface and +// returns the underlying ProtoMessage interface. +func (x *fastReflection_SnapshotItem) Interface() protoreflect.ProtoMessage { + return (*SnapshotItem)(x) +} + +// Range iterates over every populated field in an undefined order, +// calling f for each field descriptor and value encountered. +// Range returns immediately if f returns false. +// While iterating, mutating operations may only be performed +// on the current field descriptor. +func (x *fastReflection_SnapshotItem) Range(f func(protoreflect.FieldDescriptor, protoreflect.Value) bool) { + if x.Item != nil { + switch o := x.Item.(type) { + case *SnapshotItem_Store: + v := o.Store + value := protoreflect.ValueOfMessage(v.ProtoReflect()) + if !f(fd_SnapshotItem_store, value) { + return + } + case *SnapshotItem_Iavl: + v := o.Iavl + value := protoreflect.ValueOfMessage(v.ProtoReflect()) + if !f(fd_SnapshotItem_iavl, value) { + return + } + case *SnapshotItem_Extension: + v := o.Extension + value := protoreflect.ValueOfMessage(v.ProtoReflect()) + if !f(fd_SnapshotItem_extension, value) { + return + } + case *SnapshotItem_ExtensionPayload: + v := o.ExtensionPayload + value := protoreflect.ValueOfMessage(v.ProtoReflect()) + if !f(fd_SnapshotItem_extension_payload, value) { + return + } + } + } +} + +// Has reports whether a field is populated. +// +// Some fields have the property of nullability where it is possible to +// distinguish between the default value of a field and whether the field +// was explicitly populated with the default value. Singular message fields, +// member fields of a oneof, and proto2 scalar fields are nullable. Such +// fields are populated only if explicitly set. +// +// In other cases (aside from the nullable cases above), +// a proto3 scalar field is populated if it contains a non-zero value, and +// a repeated field is populated if it is non-empty. +func (x *fastReflection_SnapshotItem) Has(fd protoreflect.FieldDescriptor) bool { + switch fd.FullName() { + case "cosmos.store.snapshots.v2.SnapshotItem.store": + if x.Item == nil { + return false + } else if _, ok := x.Item.(*SnapshotItem_Store); ok { + return true + } else { + return false + } + case "cosmos.store.snapshots.v2.SnapshotItem.iavl": + if x.Item == nil { + return false + } else if _, ok := x.Item.(*SnapshotItem_Iavl); ok { + return true + } else { + return false + } + case "cosmos.store.snapshots.v2.SnapshotItem.extension": + if x.Item == nil { + return false + } else if _, ok := x.Item.(*SnapshotItem_Extension); ok { + return true + } else { + return false + } + case "cosmos.store.snapshots.v2.SnapshotItem.extension_payload": + if x.Item == nil { + return false + } else if _, ok := x.Item.(*SnapshotItem_ExtensionPayload); ok { + return true + } else { + return false + } + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.store.snapshots.v2.SnapshotItem")) + } + panic(fmt.Errorf("message cosmos.store.snapshots.v2.SnapshotItem does not contain field %s", fd.FullName())) + } +} + +// Clear clears the field such that a subsequent Has call reports false. +// +// Clearing an extension field clears both the extension type and value +// associated with the given field number. +// +// Clear is a mutating operation and unsafe for concurrent use. +func (x *fastReflection_SnapshotItem) Clear(fd protoreflect.FieldDescriptor) { + switch fd.FullName() { + case "cosmos.store.snapshots.v2.SnapshotItem.store": + x.Item = nil + case "cosmos.store.snapshots.v2.SnapshotItem.iavl": + x.Item = nil + case "cosmos.store.snapshots.v2.SnapshotItem.extension": + x.Item = nil + case "cosmos.store.snapshots.v2.SnapshotItem.extension_payload": + x.Item = nil + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.store.snapshots.v2.SnapshotItem")) + } + panic(fmt.Errorf("message cosmos.store.snapshots.v2.SnapshotItem does not contain field %s", fd.FullName())) + } +} + +// Get retrieves the value for a field. +// +// For unpopulated scalars, it returns the default value, where +// the default value of a bytes scalar is guaranteed to be a copy. +// For unpopulated composite types, it returns an empty, read-only view +// of the value; to obtain a mutable reference, use Mutable. +func (x *fastReflection_SnapshotItem) Get(descriptor protoreflect.FieldDescriptor) protoreflect.Value { + switch descriptor.FullName() { + case "cosmos.store.snapshots.v2.SnapshotItem.store": + if x.Item == nil { + return protoreflect.ValueOfMessage((*SnapshotStoreItem)(nil).ProtoReflect()) + } else if v, ok := x.Item.(*SnapshotItem_Store); ok { + return protoreflect.ValueOfMessage(v.Store.ProtoReflect()) + } else { + return protoreflect.ValueOfMessage((*SnapshotStoreItem)(nil).ProtoReflect()) + } + case "cosmos.store.snapshots.v2.SnapshotItem.iavl": + if x.Item == nil { + return protoreflect.ValueOfMessage((*SnapshotIAVLItem)(nil).ProtoReflect()) + } else if v, ok := x.Item.(*SnapshotItem_Iavl); ok { + return protoreflect.ValueOfMessage(v.Iavl.ProtoReflect()) + } else { + return protoreflect.ValueOfMessage((*SnapshotIAVLItem)(nil).ProtoReflect()) + } + case "cosmos.store.snapshots.v2.SnapshotItem.extension": + if x.Item == nil { + return protoreflect.ValueOfMessage((*SnapshotExtensionMeta)(nil).ProtoReflect()) + } else if v, ok := x.Item.(*SnapshotItem_Extension); ok { + return protoreflect.ValueOfMessage(v.Extension.ProtoReflect()) + } else { + return protoreflect.ValueOfMessage((*SnapshotExtensionMeta)(nil).ProtoReflect()) + } + case "cosmos.store.snapshots.v2.SnapshotItem.extension_payload": + if x.Item == nil { + return protoreflect.ValueOfMessage((*SnapshotExtensionPayload)(nil).ProtoReflect()) + } else if v, ok := x.Item.(*SnapshotItem_ExtensionPayload); ok { + return protoreflect.ValueOfMessage(v.ExtensionPayload.ProtoReflect()) + } else { + return protoreflect.ValueOfMessage((*SnapshotExtensionPayload)(nil).ProtoReflect()) + } + default: + if descriptor.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.store.snapshots.v2.SnapshotItem")) + } + panic(fmt.Errorf("message cosmos.store.snapshots.v2.SnapshotItem does not contain field %s", descriptor.FullName())) + } +} + +// Set stores the value for a field. +// +// For a field belonging to a oneof, it implicitly clears any other field +// that may be currently set within the same oneof. +// For extension fields, it implicitly stores the provided ExtensionType. +// When setting a composite type, it is unspecified whether the stored value +// aliases the source's memory in any way. If the composite value is an +// empty, read-only value, then it panics. +// +// Set is a mutating operation and unsafe for concurrent use. +func (x *fastReflection_SnapshotItem) Set(fd protoreflect.FieldDescriptor, value protoreflect.Value) { + switch fd.FullName() { + case "cosmos.store.snapshots.v2.SnapshotItem.store": + cv := value.Message().Interface().(*SnapshotStoreItem) + x.Item = &SnapshotItem_Store{Store: cv} + case "cosmos.store.snapshots.v2.SnapshotItem.iavl": + cv := value.Message().Interface().(*SnapshotIAVLItem) + x.Item = &SnapshotItem_Iavl{Iavl: cv} + case "cosmos.store.snapshots.v2.SnapshotItem.extension": + cv := value.Message().Interface().(*SnapshotExtensionMeta) + x.Item = &SnapshotItem_Extension{Extension: cv} + case "cosmos.store.snapshots.v2.SnapshotItem.extension_payload": + cv := value.Message().Interface().(*SnapshotExtensionPayload) + x.Item = &SnapshotItem_ExtensionPayload{ExtensionPayload: cv} + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.store.snapshots.v2.SnapshotItem")) + } + panic(fmt.Errorf("message cosmos.store.snapshots.v2.SnapshotItem does not contain field %s", fd.FullName())) + } +} + +// Mutable returns a mutable reference to a composite type. +// +// If the field is unpopulated, it may allocate a composite value. +// For a field belonging to a oneof, it implicitly clears any other field +// that may be currently set within the same oneof. +// For extension fields, it implicitly stores the provided ExtensionType +// if not already stored. +// It panics if the field does not contain a composite type. +// +// Mutable is a mutating operation and unsafe for concurrent use. +func (x *fastReflection_SnapshotItem) Mutable(fd protoreflect.FieldDescriptor) protoreflect.Value { + switch fd.FullName() { + case "cosmos.store.snapshots.v2.SnapshotItem.store": + if x.Item == nil { + value := &SnapshotStoreItem{} + oneofValue := &SnapshotItem_Store{Store: value} + x.Item = oneofValue + return protoreflect.ValueOfMessage(value.ProtoReflect()) + } + switch m := x.Item.(type) { + case *SnapshotItem_Store: + return protoreflect.ValueOfMessage(m.Store.ProtoReflect()) + default: + value := &SnapshotStoreItem{} + oneofValue := &SnapshotItem_Store{Store: value} + x.Item = oneofValue + return protoreflect.ValueOfMessage(value.ProtoReflect()) + } + case "cosmos.store.snapshots.v2.SnapshotItem.iavl": + if x.Item == nil { + value := &SnapshotIAVLItem{} + oneofValue := &SnapshotItem_Iavl{Iavl: value} + x.Item = oneofValue + return protoreflect.ValueOfMessage(value.ProtoReflect()) + } + switch m := x.Item.(type) { + case *SnapshotItem_Iavl: + return protoreflect.ValueOfMessage(m.Iavl.ProtoReflect()) + default: + value := &SnapshotIAVLItem{} + oneofValue := &SnapshotItem_Iavl{Iavl: value} + x.Item = oneofValue + return protoreflect.ValueOfMessage(value.ProtoReflect()) + } + case "cosmos.store.snapshots.v2.SnapshotItem.extension": + if x.Item == nil { + value := &SnapshotExtensionMeta{} + oneofValue := &SnapshotItem_Extension{Extension: value} + x.Item = oneofValue + return protoreflect.ValueOfMessage(value.ProtoReflect()) + } + switch m := x.Item.(type) { + case *SnapshotItem_Extension: + return protoreflect.ValueOfMessage(m.Extension.ProtoReflect()) + default: + value := &SnapshotExtensionMeta{} + oneofValue := &SnapshotItem_Extension{Extension: value} + x.Item = oneofValue + return protoreflect.ValueOfMessage(value.ProtoReflect()) + } + case "cosmos.store.snapshots.v2.SnapshotItem.extension_payload": + if x.Item == nil { + value := &SnapshotExtensionPayload{} + oneofValue := &SnapshotItem_ExtensionPayload{ExtensionPayload: value} + x.Item = oneofValue + return protoreflect.ValueOfMessage(value.ProtoReflect()) + } + switch m := x.Item.(type) { + case *SnapshotItem_ExtensionPayload: + return protoreflect.ValueOfMessage(m.ExtensionPayload.ProtoReflect()) + default: + value := &SnapshotExtensionPayload{} + oneofValue := &SnapshotItem_ExtensionPayload{ExtensionPayload: value} + x.Item = oneofValue + return protoreflect.ValueOfMessage(value.ProtoReflect()) + } + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.store.snapshots.v2.SnapshotItem")) + } + panic(fmt.Errorf("message cosmos.store.snapshots.v2.SnapshotItem does not contain field %s", fd.FullName())) + } +} + +// NewField returns a new value that is assignable to the field +// for the given descriptor. For scalars, this returns the default value. +// For lists, maps, and messages, this returns a new, empty, mutable value. +func (x *fastReflection_SnapshotItem) NewField(fd protoreflect.FieldDescriptor) protoreflect.Value { + switch fd.FullName() { + case "cosmos.store.snapshots.v2.SnapshotItem.store": + value := &SnapshotStoreItem{} + return protoreflect.ValueOfMessage(value.ProtoReflect()) + case "cosmos.store.snapshots.v2.SnapshotItem.iavl": + value := &SnapshotIAVLItem{} + return protoreflect.ValueOfMessage(value.ProtoReflect()) + case "cosmos.store.snapshots.v2.SnapshotItem.extension": + value := &SnapshotExtensionMeta{} + return protoreflect.ValueOfMessage(value.ProtoReflect()) + case "cosmos.store.snapshots.v2.SnapshotItem.extension_payload": + value := &SnapshotExtensionPayload{} + return protoreflect.ValueOfMessage(value.ProtoReflect()) + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.store.snapshots.v2.SnapshotItem")) + } + panic(fmt.Errorf("message cosmos.store.snapshots.v2.SnapshotItem does not contain field %s", fd.FullName())) + } +} + +// WhichOneof reports which field within the oneof is populated, +// returning nil if none are populated. +// It panics if the oneof descriptor does not belong to this message. +func (x *fastReflection_SnapshotItem) WhichOneof(d protoreflect.OneofDescriptor) protoreflect.FieldDescriptor { + switch d.FullName() { + case "cosmos.store.snapshots.v2.SnapshotItem.item": + if x.Item == nil { + return nil + } + switch x.Item.(type) { + case *SnapshotItem_Store: + return x.Descriptor().Fields().ByName("store") + case *SnapshotItem_Iavl: + return x.Descriptor().Fields().ByName("iavl") + case *SnapshotItem_Extension: + return x.Descriptor().Fields().ByName("extension") + case *SnapshotItem_ExtensionPayload: + return x.Descriptor().Fields().ByName("extension_payload") + } + default: + panic(fmt.Errorf("%s is not a oneof field in cosmos.store.snapshots.v2.SnapshotItem", d.FullName())) + } + panic("unreachable") +} + +// GetUnknown retrieves the entire list of unknown fields. +// The caller may only mutate the contents of the RawFields +// if the mutated bytes are stored back into the message with SetUnknown. +func (x *fastReflection_SnapshotItem) GetUnknown() protoreflect.RawFields { + return x.unknownFields +} + +// SetUnknown stores an entire list of unknown fields. +// The raw fields must be syntactically valid according to the wire format. +// An implementation may panic if this is not the case. +// Once stored, the caller must not mutate the content of the RawFields. +// An empty RawFields may be passed to clear the fields. +// +// SetUnknown is a mutating operation and unsafe for concurrent use. +func (x *fastReflection_SnapshotItem) SetUnknown(fields protoreflect.RawFields) { + x.unknownFields = fields +} + +// IsValid reports whether the message is valid. +// +// An invalid message is an empty, read-only value. +// +// An invalid message often corresponds to a nil pointer of the concrete +// message type, but the details are implementation dependent. +// Validity is not part of the protobuf data model, and may not +// be preserved in marshaling or other operations. +func (x *fastReflection_SnapshotItem) IsValid() bool { + return x != nil +} + +// ProtoMethods returns optional fastReflectionFeature-path implementations of various operations. +// This method may return nil. +// +// The returned methods type is identical to +// "google.golang.org/protobuf/runtime/protoiface".Methods. +// Consult the protoiface package documentation for details. +func (x *fastReflection_SnapshotItem) ProtoMethods() *protoiface.Methods { + size := func(input protoiface.SizeInput) protoiface.SizeOutput { + x := input.Message.Interface().(*SnapshotItem) + if x == nil { + return protoiface.SizeOutput{ + NoUnkeyedLiterals: input.NoUnkeyedLiterals, + Size: 0, + } + } + options := runtime.SizeInputToOptions(input) + _ = options + var n int + var l int + _ = l + switch x := x.Item.(type) { + case *SnapshotItem_Store: + if x == nil { + break + } + l = options.Size(x.Store) + n += 1 + l + runtime.Sov(uint64(l)) + case *SnapshotItem_Iavl: + if x == nil { + break + } + l = options.Size(x.Iavl) + n += 1 + l + runtime.Sov(uint64(l)) + case *SnapshotItem_Extension: + if x == nil { + break + } + l = options.Size(x.Extension) + n += 1 + l + runtime.Sov(uint64(l)) + case *SnapshotItem_ExtensionPayload: + if x == nil { + break + } + l = options.Size(x.ExtensionPayload) + n += 1 + l + runtime.Sov(uint64(l)) + } + if x.unknownFields != nil { + n += len(x.unknownFields) + } + return protoiface.SizeOutput{ + NoUnkeyedLiterals: input.NoUnkeyedLiterals, + Size: n, + } + } + + marshal := func(input protoiface.MarshalInput) (protoiface.MarshalOutput, error) { + x := input.Message.Interface().(*SnapshotItem) + if x == nil { + return protoiface.MarshalOutput{ + NoUnkeyedLiterals: input.NoUnkeyedLiterals, + Buf: input.Buf, + }, nil + } + options := runtime.MarshalInputToOptions(input) + _ = options + size := options.Size(x) + dAtA := make([]byte, size) + i := len(dAtA) + _ = i + var l int + _ = l + if x.unknownFields != nil { + i -= len(x.unknownFields) + copy(dAtA[i:], x.unknownFields) + } + switch x := x.Item.(type) { + case *SnapshotItem_Store: + encoded, err := options.Marshal(x.Store) + if err != nil { + return protoiface.MarshalOutput{ + NoUnkeyedLiterals: input.NoUnkeyedLiterals, + Buf: input.Buf, + }, err + } + i -= len(encoded) + copy(dAtA[i:], encoded) + i = runtime.EncodeVarint(dAtA, i, uint64(len(encoded))) + i-- + dAtA[i] = 0xa + case *SnapshotItem_Iavl: + encoded, err := options.Marshal(x.Iavl) + if err != nil { + return protoiface.MarshalOutput{ + NoUnkeyedLiterals: input.NoUnkeyedLiterals, + Buf: input.Buf, + }, err + } + i -= len(encoded) + copy(dAtA[i:], encoded) + i = runtime.EncodeVarint(dAtA, i, uint64(len(encoded))) + i-- + dAtA[i] = 0x12 + case *SnapshotItem_Extension: + encoded, err := options.Marshal(x.Extension) + if err != nil { + return protoiface.MarshalOutput{ + NoUnkeyedLiterals: input.NoUnkeyedLiterals, + Buf: input.Buf, + }, err + } + i -= len(encoded) + copy(dAtA[i:], encoded) + i = runtime.EncodeVarint(dAtA, i, uint64(len(encoded))) + i-- + dAtA[i] = 0x1a + case *SnapshotItem_ExtensionPayload: + encoded, err := options.Marshal(x.ExtensionPayload) + if err != nil { + return protoiface.MarshalOutput{ + NoUnkeyedLiterals: input.NoUnkeyedLiterals, + Buf: input.Buf, + }, err + } + i -= len(encoded) + copy(dAtA[i:], encoded) + i = runtime.EncodeVarint(dAtA, i, uint64(len(encoded))) + i-- + dAtA[i] = 0x22 + } + if input.Buf != nil { + input.Buf = append(input.Buf, dAtA...) + } else { + input.Buf = dAtA + } + return protoiface.MarshalOutput{ + NoUnkeyedLiterals: input.NoUnkeyedLiterals, + Buf: input.Buf, + }, nil + } + unmarshal := func(input protoiface.UnmarshalInput) (protoiface.UnmarshalOutput, error) { + x := input.Message.Interface().(*SnapshotItem) + if x == nil { + return protoiface.UnmarshalOutput{ + NoUnkeyedLiterals: input.NoUnkeyedLiterals, + Flags: input.Flags, + }, nil + } + options := runtime.UnmarshalInputToOptions(input) + _ = options + dAtA := input.Buf + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrIntOverflow + } + if iNdEx >= l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: SnapshotItem: wiretype end group for non-group") + } + if fieldNum <= 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: SnapshotItem: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: wrong wireType = %d for field Store", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrIntOverflow + } + if iNdEx >= l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength + } + if postIndex > l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + v := &SnapshotStoreItem{} + if err := options.Unmarshal(dAtA[iNdEx:postIndex], v); err != nil { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, err + } + x.Item = &SnapshotItem_Store{v} + iNdEx = postIndex + case 2: + if wireType != 2 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: wrong wireType = %d for field Iavl", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrIntOverflow + } + if iNdEx >= l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength + } + if postIndex > l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + v := &SnapshotIAVLItem{} + if err := options.Unmarshal(dAtA[iNdEx:postIndex], v); err != nil { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, err + } + x.Item = &SnapshotItem_Iavl{v} + iNdEx = postIndex + case 3: + if wireType != 2 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: wrong wireType = %d for field Extension", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrIntOverflow + } + if iNdEx >= l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength + } + if postIndex > l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + v := &SnapshotExtensionMeta{} + if err := options.Unmarshal(dAtA[iNdEx:postIndex], v); err != nil { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, err + } + x.Item = &SnapshotItem_Extension{v} + iNdEx = postIndex + case 4: + if wireType != 2 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: wrong wireType = %d for field ExtensionPayload", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrIntOverflow + } + if iNdEx >= l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength + } + if postIndex > l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + v := &SnapshotExtensionPayload{} + if err := options.Unmarshal(dAtA[iNdEx:postIndex], v); err != nil { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, err + } + x.Item = &SnapshotItem_ExtensionPayload{v} + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := runtime.Skip(dAtA[iNdEx:]) + if err != nil { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength + } + if (iNdEx + skippy) > l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + if !options.DiscardUnknown { + x.unknownFields = append(x.unknownFields, dAtA[iNdEx:iNdEx+skippy]...) + } + iNdEx += skippy + } + } + + if iNdEx > l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, nil + } + return &protoiface.Methods{ + NoUnkeyedLiterals: struct{}{}, + Flags: protoiface.SupportMarshalDeterministic | protoiface.SupportUnmarshalDiscardUnknown, + Size: size, + Marshal: marshal, + Unmarshal: unmarshal, + Merge: nil, + CheckInitialized: nil, + } +} + +var ( + md_SnapshotStoreItem protoreflect.MessageDescriptor + fd_SnapshotStoreItem_name protoreflect.FieldDescriptor +) + +func init() { + file_cosmos_store_snapshots_v2_snapshot_proto_init() + md_SnapshotStoreItem = File_cosmos_store_snapshots_v2_snapshot_proto.Messages().ByName("SnapshotStoreItem") + fd_SnapshotStoreItem_name = md_SnapshotStoreItem.Fields().ByName("name") +} + +var _ protoreflect.Message = (*fastReflection_SnapshotStoreItem)(nil) + +type fastReflection_SnapshotStoreItem SnapshotStoreItem + +func (x *SnapshotStoreItem) ProtoReflect() protoreflect.Message { + return (*fastReflection_SnapshotStoreItem)(x) +} + +func (x *SnapshotStoreItem) slowProtoReflect() protoreflect.Message { + mi := &file_cosmos_store_snapshots_v2_snapshot_proto_msgTypes[3] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +var _fastReflection_SnapshotStoreItem_messageType fastReflection_SnapshotStoreItem_messageType +var _ protoreflect.MessageType = fastReflection_SnapshotStoreItem_messageType{} + +type fastReflection_SnapshotStoreItem_messageType struct{} + +func (x fastReflection_SnapshotStoreItem_messageType) Zero() protoreflect.Message { + return (*fastReflection_SnapshotStoreItem)(nil) +} +func (x fastReflection_SnapshotStoreItem_messageType) New() protoreflect.Message { + return new(fastReflection_SnapshotStoreItem) +} +func (x fastReflection_SnapshotStoreItem_messageType) Descriptor() protoreflect.MessageDescriptor { + return md_SnapshotStoreItem +} + +// Descriptor returns message descriptor, which contains only the protobuf +// type information for the message. +func (x *fastReflection_SnapshotStoreItem) Descriptor() protoreflect.MessageDescriptor { + return md_SnapshotStoreItem +} + +// Type returns the message type, which encapsulates both Go and protobuf +// type information. If the Go type information is not needed, +// it is recommended that the message descriptor be used instead. +func (x *fastReflection_SnapshotStoreItem) Type() protoreflect.MessageType { + return _fastReflection_SnapshotStoreItem_messageType +} + +// New returns a newly allocated and mutable empty message. +func (x *fastReflection_SnapshotStoreItem) New() protoreflect.Message { + return new(fastReflection_SnapshotStoreItem) +} + +// Interface unwraps the message reflection interface and +// returns the underlying ProtoMessage interface. +func (x *fastReflection_SnapshotStoreItem) Interface() protoreflect.ProtoMessage { + return (*SnapshotStoreItem)(x) +} + +// Range iterates over every populated field in an undefined order, +// calling f for each field descriptor and value encountered. +// Range returns immediately if f returns false. +// While iterating, mutating operations may only be performed +// on the current field descriptor. +func (x *fastReflection_SnapshotStoreItem) Range(f func(protoreflect.FieldDescriptor, protoreflect.Value) bool) { + if x.Name != "" { + value := protoreflect.ValueOfString(x.Name) + if !f(fd_SnapshotStoreItem_name, value) { + return + } + } +} + +// Has reports whether a field is populated. +// +// Some fields have the property of nullability where it is possible to +// distinguish between the default value of a field and whether the field +// was explicitly populated with the default value. Singular message fields, +// member fields of a oneof, and proto2 scalar fields are nullable. Such +// fields are populated only if explicitly set. +// +// In other cases (aside from the nullable cases above), +// a proto3 scalar field is populated if it contains a non-zero value, and +// a repeated field is populated if it is non-empty. +func (x *fastReflection_SnapshotStoreItem) Has(fd protoreflect.FieldDescriptor) bool { + switch fd.FullName() { + case "cosmos.store.snapshots.v2.SnapshotStoreItem.name": + return x.Name != "" + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.store.snapshots.v2.SnapshotStoreItem")) + } + panic(fmt.Errorf("message cosmos.store.snapshots.v2.SnapshotStoreItem does not contain field %s", fd.FullName())) + } +} + +// Clear clears the field such that a subsequent Has call reports false. +// +// Clearing an extension field clears both the extension type and value +// associated with the given field number. +// +// Clear is a mutating operation and unsafe for concurrent use. +func (x *fastReflection_SnapshotStoreItem) Clear(fd protoreflect.FieldDescriptor) { + switch fd.FullName() { + case "cosmos.store.snapshots.v2.SnapshotStoreItem.name": + x.Name = "" + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.store.snapshots.v2.SnapshotStoreItem")) + } + panic(fmt.Errorf("message cosmos.store.snapshots.v2.SnapshotStoreItem does not contain field %s", fd.FullName())) + } +} + +// Get retrieves the value for a field. +// +// For unpopulated scalars, it returns the default value, where +// the default value of a bytes scalar is guaranteed to be a copy. +// For unpopulated composite types, it returns an empty, read-only view +// of the value; to obtain a mutable reference, use Mutable. +func (x *fastReflection_SnapshotStoreItem) Get(descriptor protoreflect.FieldDescriptor) protoreflect.Value { + switch descriptor.FullName() { + case "cosmos.store.snapshots.v2.SnapshotStoreItem.name": + value := x.Name + return protoreflect.ValueOfString(value) + default: + if descriptor.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.store.snapshots.v2.SnapshotStoreItem")) + } + panic(fmt.Errorf("message cosmos.store.snapshots.v2.SnapshotStoreItem does not contain field %s", descriptor.FullName())) + } +} + +// Set stores the value for a field. +// +// For a field belonging to a oneof, it implicitly clears any other field +// that may be currently set within the same oneof. +// For extension fields, it implicitly stores the provided ExtensionType. +// When setting a composite type, it is unspecified whether the stored value +// aliases the source's memory in any way. If the composite value is an +// empty, read-only value, then it panics. +// +// Set is a mutating operation and unsafe for concurrent use. +func (x *fastReflection_SnapshotStoreItem) Set(fd protoreflect.FieldDescriptor, value protoreflect.Value) { + switch fd.FullName() { + case "cosmos.store.snapshots.v2.SnapshotStoreItem.name": + x.Name = value.Interface().(string) + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.store.snapshots.v2.SnapshotStoreItem")) + } + panic(fmt.Errorf("message cosmos.store.snapshots.v2.SnapshotStoreItem does not contain field %s", fd.FullName())) + } +} + +// Mutable returns a mutable reference to a composite type. +// +// If the field is unpopulated, it may allocate a composite value. +// For a field belonging to a oneof, it implicitly clears any other field +// that may be currently set within the same oneof. +// For extension fields, it implicitly stores the provided ExtensionType +// if not already stored. +// It panics if the field does not contain a composite type. +// +// Mutable is a mutating operation and unsafe for concurrent use. +func (x *fastReflection_SnapshotStoreItem) Mutable(fd protoreflect.FieldDescriptor) protoreflect.Value { + switch fd.FullName() { + case "cosmos.store.snapshots.v2.SnapshotStoreItem.name": + panic(fmt.Errorf("field name of message cosmos.store.snapshots.v2.SnapshotStoreItem is not mutable")) + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.store.snapshots.v2.SnapshotStoreItem")) + } + panic(fmt.Errorf("message cosmos.store.snapshots.v2.SnapshotStoreItem does not contain field %s", fd.FullName())) + } +} + +// NewField returns a new value that is assignable to the field +// for the given descriptor. For scalars, this returns the default value. +// For lists, maps, and messages, this returns a new, empty, mutable value. +func (x *fastReflection_SnapshotStoreItem) NewField(fd protoreflect.FieldDescriptor) protoreflect.Value { + switch fd.FullName() { + case "cosmos.store.snapshots.v2.SnapshotStoreItem.name": + return protoreflect.ValueOfString("") + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.store.snapshots.v2.SnapshotStoreItem")) + } + panic(fmt.Errorf("message cosmos.store.snapshots.v2.SnapshotStoreItem does not contain field %s", fd.FullName())) + } +} + +// WhichOneof reports which field within the oneof is populated, +// returning nil if none are populated. +// It panics if the oneof descriptor does not belong to this message. +func (x *fastReflection_SnapshotStoreItem) WhichOneof(d protoreflect.OneofDescriptor) protoreflect.FieldDescriptor { + switch d.FullName() { + default: + panic(fmt.Errorf("%s is not a oneof field in cosmos.store.snapshots.v2.SnapshotStoreItem", d.FullName())) + } + panic("unreachable") +} + +// GetUnknown retrieves the entire list of unknown fields. +// The caller may only mutate the contents of the RawFields +// if the mutated bytes are stored back into the message with SetUnknown. +func (x *fastReflection_SnapshotStoreItem) GetUnknown() protoreflect.RawFields { + return x.unknownFields +} + +// SetUnknown stores an entire list of unknown fields. +// The raw fields must be syntactically valid according to the wire format. +// An implementation may panic if this is not the case. +// Once stored, the caller must not mutate the content of the RawFields. +// An empty RawFields may be passed to clear the fields. +// +// SetUnknown is a mutating operation and unsafe for concurrent use. +func (x *fastReflection_SnapshotStoreItem) SetUnknown(fields protoreflect.RawFields) { + x.unknownFields = fields +} + +// IsValid reports whether the message is valid. +// +// An invalid message is an empty, read-only value. +// +// An invalid message often corresponds to a nil pointer of the concrete +// message type, but the details are implementation dependent. +// Validity is not part of the protobuf data model, and may not +// be preserved in marshaling or other operations. +func (x *fastReflection_SnapshotStoreItem) IsValid() bool { + return x != nil +} + +// ProtoMethods returns optional fastReflectionFeature-path implementations of various operations. +// This method may return nil. +// +// The returned methods type is identical to +// "google.golang.org/protobuf/runtime/protoiface".Methods. +// Consult the protoiface package documentation for details. +func (x *fastReflection_SnapshotStoreItem) ProtoMethods() *protoiface.Methods { + size := func(input protoiface.SizeInput) protoiface.SizeOutput { + x := input.Message.Interface().(*SnapshotStoreItem) + if x == nil { + return protoiface.SizeOutput{ + NoUnkeyedLiterals: input.NoUnkeyedLiterals, + Size: 0, + } + } + options := runtime.SizeInputToOptions(input) + _ = options + var n int + var l int + _ = l + l = len(x.Name) + if l > 0 { + n += 1 + l + runtime.Sov(uint64(l)) + } + if x.unknownFields != nil { + n += len(x.unknownFields) + } + return protoiface.SizeOutput{ + NoUnkeyedLiterals: input.NoUnkeyedLiterals, + Size: n, + } + } + + marshal := func(input protoiface.MarshalInput) (protoiface.MarshalOutput, error) { + x := input.Message.Interface().(*SnapshotStoreItem) + if x == nil { + return protoiface.MarshalOutput{ + NoUnkeyedLiterals: input.NoUnkeyedLiterals, + Buf: input.Buf, + }, nil + } + options := runtime.MarshalInputToOptions(input) + _ = options + size := options.Size(x) + dAtA := make([]byte, size) + i := len(dAtA) + _ = i + var l int + _ = l + if x.unknownFields != nil { + i -= len(x.unknownFields) + copy(dAtA[i:], x.unknownFields) + } + if len(x.Name) > 0 { + i -= len(x.Name) + copy(dAtA[i:], x.Name) + i = runtime.EncodeVarint(dAtA, i, uint64(len(x.Name))) + i-- + dAtA[i] = 0xa + } + if input.Buf != nil { + input.Buf = append(input.Buf, dAtA...) + } else { + input.Buf = dAtA + } + return protoiface.MarshalOutput{ + NoUnkeyedLiterals: input.NoUnkeyedLiterals, + Buf: input.Buf, + }, nil + } + unmarshal := func(input protoiface.UnmarshalInput) (protoiface.UnmarshalOutput, error) { + x := input.Message.Interface().(*SnapshotStoreItem) + if x == nil { + return protoiface.UnmarshalOutput{ + NoUnkeyedLiterals: input.NoUnkeyedLiterals, + Flags: input.Flags, + }, nil + } + options := runtime.UnmarshalInputToOptions(input) + _ = options + dAtA := input.Buf + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrIntOverflow + } + if iNdEx >= l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: SnapshotStoreItem: wiretype end group for non-group") + } + if fieldNum <= 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: SnapshotStoreItem: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: wrong wireType = %d for field Name", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrIntOverflow + } + if iNdEx >= l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength + } + if postIndex > l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + x.Name = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := runtime.Skip(dAtA[iNdEx:]) + if err != nil { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength + } + if (iNdEx + skippy) > l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + if !options.DiscardUnknown { + x.unknownFields = append(x.unknownFields, dAtA[iNdEx:iNdEx+skippy]...) + } + iNdEx += skippy + } + } + + if iNdEx > l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, nil + } + return &protoiface.Methods{ + NoUnkeyedLiterals: struct{}{}, + Flags: protoiface.SupportMarshalDeterministic | protoiface.SupportUnmarshalDiscardUnknown, + Size: size, + Marshal: marshal, + Unmarshal: unmarshal, + Merge: nil, + CheckInitialized: nil, + } +} + +var ( + md_SnapshotIAVLItem protoreflect.MessageDescriptor + fd_SnapshotIAVLItem_key protoreflect.FieldDescriptor + fd_SnapshotIAVLItem_value protoreflect.FieldDescriptor + fd_SnapshotIAVLItem_version protoreflect.FieldDescriptor + fd_SnapshotIAVLItem_height protoreflect.FieldDescriptor +) + +func init() { + file_cosmos_store_snapshots_v2_snapshot_proto_init() + md_SnapshotIAVLItem = File_cosmos_store_snapshots_v2_snapshot_proto.Messages().ByName("SnapshotIAVLItem") + fd_SnapshotIAVLItem_key = md_SnapshotIAVLItem.Fields().ByName("key") + fd_SnapshotIAVLItem_value = md_SnapshotIAVLItem.Fields().ByName("value") + fd_SnapshotIAVLItem_version = md_SnapshotIAVLItem.Fields().ByName("version") + fd_SnapshotIAVLItem_height = md_SnapshotIAVLItem.Fields().ByName("height") +} + +var _ protoreflect.Message = (*fastReflection_SnapshotIAVLItem)(nil) + +type fastReflection_SnapshotIAVLItem SnapshotIAVLItem + +func (x *SnapshotIAVLItem) ProtoReflect() protoreflect.Message { + return (*fastReflection_SnapshotIAVLItem)(x) +} + +func (x *SnapshotIAVLItem) slowProtoReflect() protoreflect.Message { + mi := &file_cosmos_store_snapshots_v2_snapshot_proto_msgTypes[4] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +var _fastReflection_SnapshotIAVLItem_messageType fastReflection_SnapshotIAVLItem_messageType +var _ protoreflect.MessageType = fastReflection_SnapshotIAVLItem_messageType{} + +type fastReflection_SnapshotIAVLItem_messageType struct{} + +func (x fastReflection_SnapshotIAVLItem_messageType) Zero() protoreflect.Message { + return (*fastReflection_SnapshotIAVLItem)(nil) +} +func (x fastReflection_SnapshotIAVLItem_messageType) New() protoreflect.Message { + return new(fastReflection_SnapshotIAVLItem) +} +func (x fastReflection_SnapshotIAVLItem_messageType) Descriptor() protoreflect.MessageDescriptor { + return md_SnapshotIAVLItem +} + +// Descriptor returns message descriptor, which contains only the protobuf +// type information for the message. +func (x *fastReflection_SnapshotIAVLItem) Descriptor() protoreflect.MessageDescriptor { + return md_SnapshotIAVLItem +} + +// Type returns the message type, which encapsulates both Go and protobuf +// type information. If the Go type information is not needed, +// it is recommended that the message descriptor be used instead. +func (x *fastReflection_SnapshotIAVLItem) Type() protoreflect.MessageType { + return _fastReflection_SnapshotIAVLItem_messageType +} + +// New returns a newly allocated and mutable empty message. +func (x *fastReflection_SnapshotIAVLItem) New() protoreflect.Message { + return new(fastReflection_SnapshotIAVLItem) +} + +// Interface unwraps the message reflection interface and +// returns the underlying ProtoMessage interface. +func (x *fastReflection_SnapshotIAVLItem) Interface() protoreflect.ProtoMessage { + return (*SnapshotIAVLItem)(x) +} + +// Range iterates over every populated field in an undefined order, +// calling f for each field descriptor and value encountered. +// Range returns immediately if f returns false. +// While iterating, mutating operations may only be performed +// on the current field descriptor. +func (x *fastReflection_SnapshotIAVLItem) Range(f func(protoreflect.FieldDescriptor, protoreflect.Value) bool) { + if len(x.Key) != 0 { + value := protoreflect.ValueOfBytes(x.Key) + if !f(fd_SnapshotIAVLItem_key, value) { + return + } + } + if len(x.Value) != 0 { + value := protoreflect.ValueOfBytes(x.Value) + if !f(fd_SnapshotIAVLItem_value, value) { + return + } + } + if x.Version != int64(0) { + value := protoreflect.ValueOfInt64(x.Version) + if !f(fd_SnapshotIAVLItem_version, value) { + return + } + } + if x.Height != int32(0) { + value := protoreflect.ValueOfInt32(x.Height) + if !f(fd_SnapshotIAVLItem_height, value) { + return + } + } +} + +// Has reports whether a field is populated. +// +// Some fields have the property of nullability where it is possible to +// distinguish between the default value of a field and whether the field +// was explicitly populated with the default value. Singular message fields, +// member fields of a oneof, and proto2 scalar fields are nullable. Such +// fields are populated only if explicitly set. +// +// In other cases (aside from the nullable cases above), +// a proto3 scalar field is populated if it contains a non-zero value, and +// a repeated field is populated if it is non-empty. +func (x *fastReflection_SnapshotIAVLItem) Has(fd protoreflect.FieldDescriptor) bool { + switch fd.FullName() { + case "cosmos.store.snapshots.v2.SnapshotIAVLItem.key": + return len(x.Key) != 0 + case "cosmos.store.snapshots.v2.SnapshotIAVLItem.value": + return len(x.Value) != 0 + case "cosmos.store.snapshots.v2.SnapshotIAVLItem.version": + return x.Version != int64(0) + case "cosmos.store.snapshots.v2.SnapshotIAVLItem.height": + return x.Height != int32(0) + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.store.snapshots.v2.SnapshotIAVLItem")) + } + panic(fmt.Errorf("message cosmos.store.snapshots.v2.SnapshotIAVLItem does not contain field %s", fd.FullName())) + } +} + +// Clear clears the field such that a subsequent Has call reports false. +// +// Clearing an extension field clears both the extension type and value +// associated with the given field number. +// +// Clear is a mutating operation and unsafe for concurrent use. +func (x *fastReflection_SnapshotIAVLItem) Clear(fd protoreflect.FieldDescriptor) { + switch fd.FullName() { + case "cosmos.store.snapshots.v2.SnapshotIAVLItem.key": + x.Key = nil + case "cosmos.store.snapshots.v2.SnapshotIAVLItem.value": + x.Value = nil + case "cosmos.store.snapshots.v2.SnapshotIAVLItem.version": + x.Version = int64(0) + case "cosmos.store.snapshots.v2.SnapshotIAVLItem.height": + x.Height = int32(0) + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.store.snapshots.v2.SnapshotIAVLItem")) + } + panic(fmt.Errorf("message cosmos.store.snapshots.v2.SnapshotIAVLItem does not contain field %s", fd.FullName())) + } +} + +// Get retrieves the value for a field. +// +// For unpopulated scalars, it returns the default value, where +// the default value of a bytes scalar is guaranteed to be a copy. +// For unpopulated composite types, it returns an empty, read-only view +// of the value; to obtain a mutable reference, use Mutable. +func (x *fastReflection_SnapshotIAVLItem) Get(descriptor protoreflect.FieldDescriptor) protoreflect.Value { + switch descriptor.FullName() { + case "cosmos.store.snapshots.v2.SnapshotIAVLItem.key": + value := x.Key + return protoreflect.ValueOfBytes(value) + case "cosmos.store.snapshots.v2.SnapshotIAVLItem.value": + value := x.Value + return protoreflect.ValueOfBytes(value) + case "cosmos.store.snapshots.v2.SnapshotIAVLItem.version": + value := x.Version + return protoreflect.ValueOfInt64(value) + case "cosmos.store.snapshots.v2.SnapshotIAVLItem.height": + value := x.Height + return protoreflect.ValueOfInt32(value) + default: + if descriptor.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.store.snapshots.v2.SnapshotIAVLItem")) + } + panic(fmt.Errorf("message cosmos.store.snapshots.v2.SnapshotIAVLItem does not contain field %s", descriptor.FullName())) + } +} + +// Set stores the value for a field. +// +// For a field belonging to a oneof, it implicitly clears any other field +// that may be currently set within the same oneof. +// For extension fields, it implicitly stores the provided ExtensionType. +// When setting a composite type, it is unspecified whether the stored value +// aliases the source's memory in any way. If the composite value is an +// empty, read-only value, then it panics. +// +// Set is a mutating operation and unsafe for concurrent use. +func (x *fastReflection_SnapshotIAVLItem) Set(fd protoreflect.FieldDescriptor, value protoreflect.Value) { + switch fd.FullName() { + case "cosmos.store.snapshots.v2.SnapshotIAVLItem.key": + x.Key = value.Bytes() + case "cosmos.store.snapshots.v2.SnapshotIAVLItem.value": + x.Value = value.Bytes() + case "cosmos.store.snapshots.v2.SnapshotIAVLItem.version": + x.Version = value.Int() + case "cosmos.store.snapshots.v2.SnapshotIAVLItem.height": + x.Height = int32(value.Int()) + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.store.snapshots.v2.SnapshotIAVLItem")) + } + panic(fmt.Errorf("message cosmos.store.snapshots.v2.SnapshotIAVLItem does not contain field %s", fd.FullName())) + } +} + +// Mutable returns a mutable reference to a composite type. +// +// If the field is unpopulated, it may allocate a composite value. +// For a field belonging to a oneof, it implicitly clears any other field +// that may be currently set within the same oneof. +// For extension fields, it implicitly stores the provided ExtensionType +// if not already stored. +// It panics if the field does not contain a composite type. +// +// Mutable is a mutating operation and unsafe for concurrent use. +func (x *fastReflection_SnapshotIAVLItem) Mutable(fd protoreflect.FieldDescriptor) protoreflect.Value { + switch fd.FullName() { + case "cosmos.store.snapshots.v2.SnapshotIAVLItem.key": + panic(fmt.Errorf("field key of message cosmos.store.snapshots.v2.SnapshotIAVLItem is not mutable")) + case "cosmos.store.snapshots.v2.SnapshotIAVLItem.value": + panic(fmt.Errorf("field value of message cosmos.store.snapshots.v2.SnapshotIAVLItem is not mutable")) + case "cosmos.store.snapshots.v2.SnapshotIAVLItem.version": + panic(fmt.Errorf("field version of message cosmos.store.snapshots.v2.SnapshotIAVLItem is not mutable")) + case "cosmos.store.snapshots.v2.SnapshotIAVLItem.height": + panic(fmt.Errorf("field height of message cosmos.store.snapshots.v2.SnapshotIAVLItem is not mutable")) + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.store.snapshots.v2.SnapshotIAVLItem")) + } + panic(fmt.Errorf("message cosmos.store.snapshots.v2.SnapshotIAVLItem does not contain field %s", fd.FullName())) + } +} + +// NewField returns a new value that is assignable to the field +// for the given descriptor. For scalars, this returns the default value. +// For lists, maps, and messages, this returns a new, empty, mutable value. +func (x *fastReflection_SnapshotIAVLItem) NewField(fd protoreflect.FieldDescriptor) protoreflect.Value { + switch fd.FullName() { + case "cosmos.store.snapshots.v2.SnapshotIAVLItem.key": + return protoreflect.ValueOfBytes(nil) + case "cosmos.store.snapshots.v2.SnapshotIAVLItem.value": + return protoreflect.ValueOfBytes(nil) + case "cosmos.store.snapshots.v2.SnapshotIAVLItem.version": + return protoreflect.ValueOfInt64(int64(0)) + case "cosmos.store.snapshots.v2.SnapshotIAVLItem.height": + return protoreflect.ValueOfInt32(int32(0)) + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.store.snapshots.v2.SnapshotIAVLItem")) + } + panic(fmt.Errorf("message cosmos.store.snapshots.v2.SnapshotIAVLItem does not contain field %s", fd.FullName())) + } +} + +// WhichOneof reports which field within the oneof is populated, +// returning nil if none are populated. +// It panics if the oneof descriptor does not belong to this message. +func (x *fastReflection_SnapshotIAVLItem) WhichOneof(d protoreflect.OneofDescriptor) protoreflect.FieldDescriptor { + switch d.FullName() { + default: + panic(fmt.Errorf("%s is not a oneof field in cosmos.store.snapshots.v2.SnapshotIAVLItem", d.FullName())) + } + panic("unreachable") +} + +// GetUnknown retrieves the entire list of unknown fields. +// The caller may only mutate the contents of the RawFields +// if the mutated bytes are stored back into the message with SetUnknown. +func (x *fastReflection_SnapshotIAVLItem) GetUnknown() protoreflect.RawFields { + return x.unknownFields +} + +// SetUnknown stores an entire list of unknown fields. +// The raw fields must be syntactically valid according to the wire format. +// An implementation may panic if this is not the case. +// Once stored, the caller must not mutate the content of the RawFields. +// An empty RawFields may be passed to clear the fields. +// +// SetUnknown is a mutating operation and unsafe for concurrent use. +func (x *fastReflection_SnapshotIAVLItem) SetUnknown(fields protoreflect.RawFields) { + x.unknownFields = fields +} + +// IsValid reports whether the message is valid. +// +// An invalid message is an empty, read-only value. +// +// An invalid message often corresponds to a nil pointer of the concrete +// message type, but the details are implementation dependent. +// Validity is not part of the protobuf data model, and may not +// be preserved in marshaling or other operations. +func (x *fastReflection_SnapshotIAVLItem) IsValid() bool { + return x != nil +} + +// ProtoMethods returns optional fastReflectionFeature-path implementations of various operations. +// This method may return nil. +// +// The returned methods type is identical to +// "google.golang.org/protobuf/runtime/protoiface".Methods. +// Consult the protoiface package documentation for details. +func (x *fastReflection_SnapshotIAVLItem) ProtoMethods() *protoiface.Methods { + size := func(input protoiface.SizeInput) protoiface.SizeOutput { + x := input.Message.Interface().(*SnapshotIAVLItem) + if x == nil { + return protoiface.SizeOutput{ + NoUnkeyedLiterals: input.NoUnkeyedLiterals, + Size: 0, + } + } + options := runtime.SizeInputToOptions(input) + _ = options + var n int + var l int + _ = l + l = len(x.Key) + if l > 0 { + n += 1 + l + runtime.Sov(uint64(l)) + } + l = len(x.Value) + if l > 0 { + n += 1 + l + runtime.Sov(uint64(l)) + } + if x.Version != 0 { + n += 1 + runtime.Sov(uint64(x.Version)) + } + if x.Height != 0 { + n += 1 + runtime.Sov(uint64(x.Height)) + } + if x.unknownFields != nil { + n += len(x.unknownFields) + } + return protoiface.SizeOutput{ + NoUnkeyedLiterals: input.NoUnkeyedLiterals, + Size: n, + } + } + + marshal := func(input protoiface.MarshalInput) (protoiface.MarshalOutput, error) { + x := input.Message.Interface().(*SnapshotIAVLItem) + if x == nil { + return protoiface.MarshalOutput{ + NoUnkeyedLiterals: input.NoUnkeyedLiterals, + Buf: input.Buf, + }, nil + } + options := runtime.MarshalInputToOptions(input) + _ = options + size := options.Size(x) + dAtA := make([]byte, size) + i := len(dAtA) + _ = i + var l int + _ = l + if x.unknownFields != nil { + i -= len(x.unknownFields) + copy(dAtA[i:], x.unknownFields) + } + if x.Height != 0 { + i = runtime.EncodeVarint(dAtA, i, uint64(x.Height)) + i-- + dAtA[i] = 0x20 + } + if x.Version != 0 { + i = runtime.EncodeVarint(dAtA, i, uint64(x.Version)) + i-- + dAtA[i] = 0x18 + } + if len(x.Value) > 0 { + i -= len(x.Value) + copy(dAtA[i:], x.Value) + i = runtime.EncodeVarint(dAtA, i, uint64(len(x.Value))) + i-- + dAtA[i] = 0x12 + } + if len(x.Key) > 0 { + i -= len(x.Key) + copy(dAtA[i:], x.Key) + i = runtime.EncodeVarint(dAtA, i, uint64(len(x.Key))) + i-- + dAtA[i] = 0xa + } + if input.Buf != nil { + input.Buf = append(input.Buf, dAtA...) + } else { + input.Buf = dAtA + } + return protoiface.MarshalOutput{ + NoUnkeyedLiterals: input.NoUnkeyedLiterals, + Buf: input.Buf, + }, nil + } + unmarshal := func(input protoiface.UnmarshalInput) (protoiface.UnmarshalOutput, error) { + x := input.Message.Interface().(*SnapshotIAVLItem) + if x == nil { + return protoiface.UnmarshalOutput{ + NoUnkeyedLiterals: input.NoUnkeyedLiterals, + Flags: input.Flags, + }, nil + } + options := runtime.UnmarshalInputToOptions(input) + _ = options + dAtA := input.Buf + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrIntOverflow + } + if iNdEx >= l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: SnapshotIAVLItem: wiretype end group for non-group") + } + if fieldNum <= 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: SnapshotIAVLItem: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: wrong wireType = %d for field Key", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrIntOverflow + } + if iNdEx >= l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength + } + if postIndex > l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + x.Key = append(x.Key[:0], dAtA[iNdEx:postIndex]...) + if x.Key == nil { + x.Key = []byte{} + } + iNdEx = postIndex + case 2: + if wireType != 2 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: wrong wireType = %d for field Value", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrIntOverflow + } + if iNdEx >= l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength + } + if postIndex > l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + x.Value = append(x.Value[:0], dAtA[iNdEx:postIndex]...) + if x.Value == nil { + x.Value = []byte{} + } + iNdEx = postIndex + case 3: + if wireType != 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: wrong wireType = %d for field Version", wireType) + } + x.Version = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrIntOverflow + } + if iNdEx >= l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + x.Version |= int64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 4: + if wireType != 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: wrong wireType = %d for field Height", wireType) + } + x.Height = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrIntOverflow + } + if iNdEx >= l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + x.Height |= int32(b&0x7F) << shift + if b < 0x80 { + break + } + } + default: + iNdEx = preIndex + skippy, err := runtime.Skip(dAtA[iNdEx:]) + if err != nil { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength + } + if (iNdEx + skippy) > l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + if !options.DiscardUnknown { + x.unknownFields = append(x.unknownFields, dAtA[iNdEx:iNdEx+skippy]...) + } + iNdEx += skippy + } + } + + if iNdEx > l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, nil + } + return &protoiface.Methods{ + NoUnkeyedLiterals: struct{}{}, + Flags: protoiface.SupportMarshalDeterministic | protoiface.SupportUnmarshalDiscardUnknown, + Size: size, + Marshal: marshal, + Unmarshal: unmarshal, + Merge: nil, + CheckInitialized: nil, + } +} + +var ( + md_SnapshotExtensionMeta protoreflect.MessageDescriptor + fd_SnapshotExtensionMeta_name protoreflect.FieldDescriptor + fd_SnapshotExtensionMeta_format protoreflect.FieldDescriptor +) + +func init() { + file_cosmos_store_snapshots_v2_snapshot_proto_init() + md_SnapshotExtensionMeta = File_cosmos_store_snapshots_v2_snapshot_proto.Messages().ByName("SnapshotExtensionMeta") + fd_SnapshotExtensionMeta_name = md_SnapshotExtensionMeta.Fields().ByName("name") + fd_SnapshotExtensionMeta_format = md_SnapshotExtensionMeta.Fields().ByName("format") +} + +var _ protoreflect.Message = (*fastReflection_SnapshotExtensionMeta)(nil) + +type fastReflection_SnapshotExtensionMeta SnapshotExtensionMeta + +func (x *SnapshotExtensionMeta) ProtoReflect() protoreflect.Message { + return (*fastReflection_SnapshotExtensionMeta)(x) +} + +func (x *SnapshotExtensionMeta) slowProtoReflect() protoreflect.Message { + mi := &file_cosmos_store_snapshots_v2_snapshot_proto_msgTypes[5] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +var _fastReflection_SnapshotExtensionMeta_messageType fastReflection_SnapshotExtensionMeta_messageType +var _ protoreflect.MessageType = fastReflection_SnapshotExtensionMeta_messageType{} + +type fastReflection_SnapshotExtensionMeta_messageType struct{} + +func (x fastReflection_SnapshotExtensionMeta_messageType) Zero() protoreflect.Message { + return (*fastReflection_SnapshotExtensionMeta)(nil) +} +func (x fastReflection_SnapshotExtensionMeta_messageType) New() protoreflect.Message { + return new(fastReflection_SnapshotExtensionMeta) +} +func (x fastReflection_SnapshotExtensionMeta_messageType) Descriptor() protoreflect.MessageDescriptor { + return md_SnapshotExtensionMeta +} + +// Descriptor returns message descriptor, which contains only the protobuf +// type information for the message. +func (x *fastReflection_SnapshotExtensionMeta) Descriptor() protoreflect.MessageDescriptor { + return md_SnapshotExtensionMeta +} + +// Type returns the message type, which encapsulates both Go and protobuf +// type information. If the Go type information is not needed, +// it is recommended that the message descriptor be used instead. +func (x *fastReflection_SnapshotExtensionMeta) Type() protoreflect.MessageType { + return _fastReflection_SnapshotExtensionMeta_messageType +} + +// New returns a newly allocated and mutable empty message. +func (x *fastReflection_SnapshotExtensionMeta) New() protoreflect.Message { + return new(fastReflection_SnapshotExtensionMeta) +} + +// Interface unwraps the message reflection interface and +// returns the underlying ProtoMessage interface. +func (x *fastReflection_SnapshotExtensionMeta) Interface() protoreflect.ProtoMessage { + return (*SnapshotExtensionMeta)(x) +} + +// Range iterates over every populated field in an undefined order, +// calling f for each field descriptor and value encountered. +// Range returns immediately if f returns false. +// While iterating, mutating operations may only be performed +// on the current field descriptor. +func (x *fastReflection_SnapshotExtensionMeta) Range(f func(protoreflect.FieldDescriptor, protoreflect.Value) bool) { + if x.Name != "" { + value := protoreflect.ValueOfString(x.Name) + if !f(fd_SnapshotExtensionMeta_name, value) { + return + } + } + if x.Format != uint32(0) { + value := protoreflect.ValueOfUint32(x.Format) + if !f(fd_SnapshotExtensionMeta_format, value) { + return + } + } +} + +// Has reports whether a field is populated. +// +// Some fields have the property of nullability where it is possible to +// distinguish between the default value of a field and whether the field +// was explicitly populated with the default value. Singular message fields, +// member fields of a oneof, and proto2 scalar fields are nullable. Such +// fields are populated only if explicitly set. +// +// In other cases (aside from the nullable cases above), +// a proto3 scalar field is populated if it contains a non-zero value, and +// a repeated field is populated if it is non-empty. +func (x *fastReflection_SnapshotExtensionMeta) Has(fd protoreflect.FieldDescriptor) bool { + switch fd.FullName() { + case "cosmos.store.snapshots.v2.SnapshotExtensionMeta.name": + return x.Name != "" + case "cosmos.store.snapshots.v2.SnapshotExtensionMeta.format": + return x.Format != uint32(0) + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.store.snapshots.v2.SnapshotExtensionMeta")) + } + panic(fmt.Errorf("message cosmos.store.snapshots.v2.SnapshotExtensionMeta does not contain field %s", fd.FullName())) + } +} + +// Clear clears the field such that a subsequent Has call reports false. +// +// Clearing an extension field clears both the extension type and value +// associated with the given field number. +// +// Clear is a mutating operation and unsafe for concurrent use. +func (x *fastReflection_SnapshotExtensionMeta) Clear(fd protoreflect.FieldDescriptor) { + switch fd.FullName() { + case "cosmos.store.snapshots.v2.SnapshotExtensionMeta.name": + x.Name = "" + case "cosmos.store.snapshots.v2.SnapshotExtensionMeta.format": + x.Format = uint32(0) + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.store.snapshots.v2.SnapshotExtensionMeta")) + } + panic(fmt.Errorf("message cosmos.store.snapshots.v2.SnapshotExtensionMeta does not contain field %s", fd.FullName())) + } +} + +// Get retrieves the value for a field. +// +// For unpopulated scalars, it returns the default value, where +// the default value of a bytes scalar is guaranteed to be a copy. +// For unpopulated composite types, it returns an empty, read-only view +// of the value; to obtain a mutable reference, use Mutable. +func (x *fastReflection_SnapshotExtensionMeta) Get(descriptor protoreflect.FieldDescriptor) protoreflect.Value { + switch descriptor.FullName() { + case "cosmos.store.snapshots.v2.SnapshotExtensionMeta.name": + value := x.Name + return protoreflect.ValueOfString(value) + case "cosmos.store.snapshots.v2.SnapshotExtensionMeta.format": + value := x.Format + return protoreflect.ValueOfUint32(value) + default: + if descriptor.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.store.snapshots.v2.SnapshotExtensionMeta")) + } + panic(fmt.Errorf("message cosmos.store.snapshots.v2.SnapshotExtensionMeta does not contain field %s", descriptor.FullName())) + } +} + +// Set stores the value for a field. +// +// For a field belonging to a oneof, it implicitly clears any other field +// that may be currently set within the same oneof. +// For extension fields, it implicitly stores the provided ExtensionType. +// When setting a composite type, it is unspecified whether the stored value +// aliases the source's memory in any way. If the composite value is an +// empty, read-only value, then it panics. +// +// Set is a mutating operation and unsafe for concurrent use. +func (x *fastReflection_SnapshotExtensionMeta) Set(fd protoreflect.FieldDescriptor, value protoreflect.Value) { + switch fd.FullName() { + case "cosmos.store.snapshots.v2.SnapshotExtensionMeta.name": + x.Name = value.Interface().(string) + case "cosmos.store.snapshots.v2.SnapshotExtensionMeta.format": + x.Format = uint32(value.Uint()) + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.store.snapshots.v2.SnapshotExtensionMeta")) + } + panic(fmt.Errorf("message cosmos.store.snapshots.v2.SnapshotExtensionMeta does not contain field %s", fd.FullName())) + } +} + +// Mutable returns a mutable reference to a composite type. +// +// If the field is unpopulated, it may allocate a composite value. +// For a field belonging to a oneof, it implicitly clears any other field +// that may be currently set within the same oneof. +// For extension fields, it implicitly stores the provided ExtensionType +// if not already stored. +// It panics if the field does not contain a composite type. +// +// Mutable is a mutating operation and unsafe for concurrent use. +func (x *fastReflection_SnapshotExtensionMeta) Mutable(fd protoreflect.FieldDescriptor) protoreflect.Value { + switch fd.FullName() { + case "cosmos.store.snapshots.v2.SnapshotExtensionMeta.name": + panic(fmt.Errorf("field name of message cosmos.store.snapshots.v2.SnapshotExtensionMeta is not mutable")) + case "cosmos.store.snapshots.v2.SnapshotExtensionMeta.format": + panic(fmt.Errorf("field format of message cosmos.store.snapshots.v2.SnapshotExtensionMeta is not mutable")) + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.store.snapshots.v2.SnapshotExtensionMeta")) + } + panic(fmt.Errorf("message cosmos.store.snapshots.v2.SnapshotExtensionMeta does not contain field %s", fd.FullName())) + } +} + +// NewField returns a new value that is assignable to the field +// for the given descriptor. For scalars, this returns the default value. +// For lists, maps, and messages, this returns a new, empty, mutable value. +func (x *fastReflection_SnapshotExtensionMeta) NewField(fd protoreflect.FieldDescriptor) protoreflect.Value { + switch fd.FullName() { + case "cosmos.store.snapshots.v2.SnapshotExtensionMeta.name": + return protoreflect.ValueOfString("") + case "cosmos.store.snapshots.v2.SnapshotExtensionMeta.format": + return protoreflect.ValueOfUint32(uint32(0)) + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.store.snapshots.v2.SnapshotExtensionMeta")) + } + panic(fmt.Errorf("message cosmos.store.snapshots.v2.SnapshotExtensionMeta does not contain field %s", fd.FullName())) + } +} + +// WhichOneof reports which field within the oneof is populated, +// returning nil if none are populated. +// It panics if the oneof descriptor does not belong to this message. +func (x *fastReflection_SnapshotExtensionMeta) WhichOneof(d protoreflect.OneofDescriptor) protoreflect.FieldDescriptor { + switch d.FullName() { + default: + panic(fmt.Errorf("%s is not a oneof field in cosmos.store.snapshots.v2.SnapshotExtensionMeta", d.FullName())) + } + panic("unreachable") +} + +// GetUnknown retrieves the entire list of unknown fields. +// The caller may only mutate the contents of the RawFields +// if the mutated bytes are stored back into the message with SetUnknown. +func (x *fastReflection_SnapshotExtensionMeta) GetUnknown() protoreflect.RawFields { + return x.unknownFields +} + +// SetUnknown stores an entire list of unknown fields. +// The raw fields must be syntactically valid according to the wire format. +// An implementation may panic if this is not the case. +// Once stored, the caller must not mutate the content of the RawFields. +// An empty RawFields may be passed to clear the fields. +// +// SetUnknown is a mutating operation and unsafe for concurrent use. +func (x *fastReflection_SnapshotExtensionMeta) SetUnknown(fields protoreflect.RawFields) { + x.unknownFields = fields +} + +// IsValid reports whether the message is valid. +// +// An invalid message is an empty, read-only value. +// +// An invalid message often corresponds to a nil pointer of the concrete +// message type, but the details are implementation dependent. +// Validity is not part of the protobuf data model, and may not +// be preserved in marshaling or other operations. +func (x *fastReflection_SnapshotExtensionMeta) IsValid() bool { + return x != nil +} + +// ProtoMethods returns optional fastReflectionFeature-path implementations of various operations. +// This method may return nil. +// +// The returned methods type is identical to +// "google.golang.org/protobuf/runtime/protoiface".Methods. +// Consult the protoiface package documentation for details. +func (x *fastReflection_SnapshotExtensionMeta) ProtoMethods() *protoiface.Methods { + size := func(input protoiface.SizeInput) protoiface.SizeOutput { + x := input.Message.Interface().(*SnapshotExtensionMeta) + if x == nil { + return protoiface.SizeOutput{ + NoUnkeyedLiterals: input.NoUnkeyedLiterals, + Size: 0, + } + } + options := runtime.SizeInputToOptions(input) + _ = options + var n int + var l int + _ = l + l = len(x.Name) + if l > 0 { + n += 1 + l + runtime.Sov(uint64(l)) + } + if x.Format != 0 { + n += 1 + runtime.Sov(uint64(x.Format)) + } + if x.unknownFields != nil { + n += len(x.unknownFields) + } + return protoiface.SizeOutput{ + NoUnkeyedLiterals: input.NoUnkeyedLiterals, + Size: n, + } + } + + marshal := func(input protoiface.MarshalInput) (protoiface.MarshalOutput, error) { + x := input.Message.Interface().(*SnapshotExtensionMeta) + if x == nil { + return protoiface.MarshalOutput{ + NoUnkeyedLiterals: input.NoUnkeyedLiterals, + Buf: input.Buf, + }, nil + } + options := runtime.MarshalInputToOptions(input) + _ = options + size := options.Size(x) + dAtA := make([]byte, size) + i := len(dAtA) + _ = i + var l int + _ = l + if x.unknownFields != nil { + i -= len(x.unknownFields) + copy(dAtA[i:], x.unknownFields) + } + if x.Format != 0 { + i = runtime.EncodeVarint(dAtA, i, uint64(x.Format)) + i-- + dAtA[i] = 0x10 + } + if len(x.Name) > 0 { + i -= len(x.Name) + copy(dAtA[i:], x.Name) + i = runtime.EncodeVarint(dAtA, i, uint64(len(x.Name))) + i-- + dAtA[i] = 0xa + } + if input.Buf != nil { + input.Buf = append(input.Buf, dAtA...) + } else { + input.Buf = dAtA + } + return protoiface.MarshalOutput{ + NoUnkeyedLiterals: input.NoUnkeyedLiterals, + Buf: input.Buf, + }, nil + } + unmarshal := func(input protoiface.UnmarshalInput) (protoiface.UnmarshalOutput, error) { + x := input.Message.Interface().(*SnapshotExtensionMeta) + if x == nil { + return protoiface.UnmarshalOutput{ + NoUnkeyedLiterals: input.NoUnkeyedLiterals, + Flags: input.Flags, + }, nil + } + options := runtime.UnmarshalInputToOptions(input) + _ = options + dAtA := input.Buf + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrIntOverflow + } + if iNdEx >= l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: SnapshotExtensionMeta: wiretype end group for non-group") + } + if fieldNum <= 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: SnapshotExtensionMeta: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: wrong wireType = %d for field Name", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrIntOverflow + } + if iNdEx >= l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength + } + if postIndex > l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + x.Name = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: wrong wireType = %d for field Format", wireType) + } + x.Format = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrIntOverflow + } + if iNdEx >= l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + x.Format |= uint32(b&0x7F) << shift + if b < 0x80 { + break + } + } + default: + iNdEx = preIndex + skippy, err := runtime.Skip(dAtA[iNdEx:]) + if err != nil { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength + } + if (iNdEx + skippy) > l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + if !options.DiscardUnknown { + x.unknownFields = append(x.unknownFields, dAtA[iNdEx:iNdEx+skippy]...) + } + iNdEx += skippy + } + } + + if iNdEx > l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, nil + } + return &protoiface.Methods{ + NoUnkeyedLiterals: struct{}{}, + Flags: protoiface.SupportMarshalDeterministic | protoiface.SupportUnmarshalDiscardUnknown, + Size: size, + Marshal: marshal, + Unmarshal: unmarshal, + Merge: nil, + CheckInitialized: nil, + } +} + +var ( + md_SnapshotExtensionPayload protoreflect.MessageDescriptor + fd_SnapshotExtensionPayload_payload protoreflect.FieldDescriptor +) + +func init() { + file_cosmos_store_snapshots_v2_snapshot_proto_init() + md_SnapshotExtensionPayload = File_cosmos_store_snapshots_v2_snapshot_proto.Messages().ByName("SnapshotExtensionPayload") + fd_SnapshotExtensionPayload_payload = md_SnapshotExtensionPayload.Fields().ByName("payload") +} + +var _ protoreflect.Message = (*fastReflection_SnapshotExtensionPayload)(nil) + +type fastReflection_SnapshotExtensionPayload SnapshotExtensionPayload + +func (x *SnapshotExtensionPayload) ProtoReflect() protoreflect.Message { + return (*fastReflection_SnapshotExtensionPayload)(x) +} + +func (x *SnapshotExtensionPayload) slowProtoReflect() protoreflect.Message { + mi := &file_cosmos_store_snapshots_v2_snapshot_proto_msgTypes[6] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +var _fastReflection_SnapshotExtensionPayload_messageType fastReflection_SnapshotExtensionPayload_messageType +var _ protoreflect.MessageType = fastReflection_SnapshotExtensionPayload_messageType{} + +type fastReflection_SnapshotExtensionPayload_messageType struct{} + +func (x fastReflection_SnapshotExtensionPayload_messageType) Zero() protoreflect.Message { + return (*fastReflection_SnapshotExtensionPayload)(nil) +} +func (x fastReflection_SnapshotExtensionPayload_messageType) New() protoreflect.Message { + return new(fastReflection_SnapshotExtensionPayload) +} +func (x fastReflection_SnapshotExtensionPayload_messageType) Descriptor() protoreflect.MessageDescriptor { + return md_SnapshotExtensionPayload +} + +// Descriptor returns message descriptor, which contains only the protobuf +// type information for the message. +func (x *fastReflection_SnapshotExtensionPayload) Descriptor() protoreflect.MessageDescriptor { + return md_SnapshotExtensionPayload +} + +// Type returns the message type, which encapsulates both Go and protobuf +// type information. If the Go type information is not needed, +// it is recommended that the message descriptor be used instead. +func (x *fastReflection_SnapshotExtensionPayload) Type() protoreflect.MessageType { + return _fastReflection_SnapshotExtensionPayload_messageType +} + +// New returns a newly allocated and mutable empty message. +func (x *fastReflection_SnapshotExtensionPayload) New() protoreflect.Message { + return new(fastReflection_SnapshotExtensionPayload) +} + +// Interface unwraps the message reflection interface and +// returns the underlying ProtoMessage interface. +func (x *fastReflection_SnapshotExtensionPayload) Interface() protoreflect.ProtoMessage { + return (*SnapshotExtensionPayload)(x) +} + +// Range iterates over every populated field in an undefined order, +// calling f for each field descriptor and value encountered. +// Range returns immediately if f returns false. +// While iterating, mutating operations may only be performed +// on the current field descriptor. +func (x *fastReflection_SnapshotExtensionPayload) Range(f func(protoreflect.FieldDescriptor, protoreflect.Value) bool) { + if len(x.Payload) != 0 { + value := protoreflect.ValueOfBytes(x.Payload) + if !f(fd_SnapshotExtensionPayload_payload, value) { + return + } + } +} + +// Has reports whether a field is populated. +// +// Some fields have the property of nullability where it is possible to +// distinguish between the default value of a field and whether the field +// was explicitly populated with the default value. Singular message fields, +// member fields of a oneof, and proto2 scalar fields are nullable. Such +// fields are populated only if explicitly set. +// +// In other cases (aside from the nullable cases above), +// a proto3 scalar field is populated if it contains a non-zero value, and +// a repeated field is populated if it is non-empty. +func (x *fastReflection_SnapshotExtensionPayload) Has(fd protoreflect.FieldDescriptor) bool { + switch fd.FullName() { + case "cosmos.store.snapshots.v2.SnapshotExtensionPayload.payload": + return len(x.Payload) != 0 + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.store.snapshots.v2.SnapshotExtensionPayload")) + } + panic(fmt.Errorf("message cosmos.store.snapshots.v2.SnapshotExtensionPayload does not contain field %s", fd.FullName())) + } +} + +// Clear clears the field such that a subsequent Has call reports false. +// +// Clearing an extension field clears both the extension type and value +// associated with the given field number. +// +// Clear is a mutating operation and unsafe for concurrent use. +func (x *fastReflection_SnapshotExtensionPayload) Clear(fd protoreflect.FieldDescriptor) { + switch fd.FullName() { + case "cosmos.store.snapshots.v2.SnapshotExtensionPayload.payload": + x.Payload = nil + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.store.snapshots.v2.SnapshotExtensionPayload")) + } + panic(fmt.Errorf("message cosmos.store.snapshots.v2.SnapshotExtensionPayload does not contain field %s", fd.FullName())) + } +} + +// Get retrieves the value for a field. +// +// For unpopulated scalars, it returns the default value, where +// the default value of a bytes scalar is guaranteed to be a copy. +// For unpopulated composite types, it returns an empty, read-only view +// of the value; to obtain a mutable reference, use Mutable. +func (x *fastReflection_SnapshotExtensionPayload) Get(descriptor protoreflect.FieldDescriptor) protoreflect.Value { + switch descriptor.FullName() { + case "cosmos.store.snapshots.v2.SnapshotExtensionPayload.payload": + value := x.Payload + return protoreflect.ValueOfBytes(value) + default: + if descriptor.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.store.snapshots.v2.SnapshotExtensionPayload")) + } + panic(fmt.Errorf("message cosmos.store.snapshots.v2.SnapshotExtensionPayload does not contain field %s", descriptor.FullName())) + } +} + +// Set stores the value for a field. +// +// For a field belonging to a oneof, it implicitly clears any other field +// that may be currently set within the same oneof. +// For extension fields, it implicitly stores the provided ExtensionType. +// When setting a composite type, it is unspecified whether the stored value +// aliases the source's memory in any way. If the composite value is an +// empty, read-only value, then it panics. +// +// Set is a mutating operation and unsafe for concurrent use. +func (x *fastReflection_SnapshotExtensionPayload) Set(fd protoreflect.FieldDescriptor, value protoreflect.Value) { + switch fd.FullName() { + case "cosmos.store.snapshots.v2.SnapshotExtensionPayload.payload": + x.Payload = value.Bytes() + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.store.snapshots.v2.SnapshotExtensionPayload")) + } + panic(fmt.Errorf("message cosmos.store.snapshots.v2.SnapshotExtensionPayload does not contain field %s", fd.FullName())) + } +} + +// Mutable returns a mutable reference to a composite type. +// +// If the field is unpopulated, it may allocate a composite value. +// For a field belonging to a oneof, it implicitly clears any other field +// that may be currently set within the same oneof. +// For extension fields, it implicitly stores the provided ExtensionType +// if not already stored. +// It panics if the field does not contain a composite type. +// +// Mutable is a mutating operation and unsafe for concurrent use. +func (x *fastReflection_SnapshotExtensionPayload) Mutable(fd protoreflect.FieldDescriptor) protoreflect.Value { + switch fd.FullName() { + case "cosmos.store.snapshots.v2.SnapshotExtensionPayload.payload": + panic(fmt.Errorf("field payload of message cosmos.store.snapshots.v2.SnapshotExtensionPayload is not mutable")) + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.store.snapshots.v2.SnapshotExtensionPayload")) + } + panic(fmt.Errorf("message cosmos.store.snapshots.v2.SnapshotExtensionPayload does not contain field %s", fd.FullName())) + } +} + +// NewField returns a new value that is assignable to the field +// for the given descriptor. For scalars, this returns the default value. +// For lists, maps, and messages, this returns a new, empty, mutable value. +func (x *fastReflection_SnapshotExtensionPayload) NewField(fd protoreflect.FieldDescriptor) protoreflect.Value { + switch fd.FullName() { + case "cosmos.store.snapshots.v2.SnapshotExtensionPayload.payload": + return protoreflect.ValueOfBytes(nil) + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.store.snapshots.v2.SnapshotExtensionPayload")) + } + panic(fmt.Errorf("message cosmos.store.snapshots.v2.SnapshotExtensionPayload does not contain field %s", fd.FullName())) + } +} + +// WhichOneof reports which field within the oneof is populated, +// returning nil if none are populated. +// It panics if the oneof descriptor does not belong to this message. +func (x *fastReflection_SnapshotExtensionPayload) WhichOneof(d protoreflect.OneofDescriptor) protoreflect.FieldDescriptor { + switch d.FullName() { + default: + panic(fmt.Errorf("%s is not a oneof field in cosmos.store.snapshots.v2.SnapshotExtensionPayload", d.FullName())) + } + panic("unreachable") +} + +// GetUnknown retrieves the entire list of unknown fields. +// The caller may only mutate the contents of the RawFields +// if the mutated bytes are stored back into the message with SetUnknown. +func (x *fastReflection_SnapshotExtensionPayload) GetUnknown() protoreflect.RawFields { + return x.unknownFields +} + +// SetUnknown stores an entire list of unknown fields. +// The raw fields must be syntactically valid according to the wire format. +// An implementation may panic if this is not the case. +// Once stored, the caller must not mutate the content of the RawFields. +// An empty RawFields may be passed to clear the fields. +// +// SetUnknown is a mutating operation and unsafe for concurrent use. +func (x *fastReflection_SnapshotExtensionPayload) SetUnknown(fields protoreflect.RawFields) { + x.unknownFields = fields +} + +// IsValid reports whether the message is valid. +// +// An invalid message is an empty, read-only value. +// +// An invalid message often corresponds to a nil pointer of the concrete +// message type, but the details are implementation dependent. +// Validity is not part of the protobuf data model, and may not +// be preserved in marshaling or other operations. +func (x *fastReflection_SnapshotExtensionPayload) IsValid() bool { + return x != nil +} + +// ProtoMethods returns optional fastReflectionFeature-path implementations of various operations. +// This method may return nil. +// +// The returned methods type is identical to +// "google.golang.org/protobuf/runtime/protoiface".Methods. +// Consult the protoiface package documentation for details. +func (x *fastReflection_SnapshotExtensionPayload) ProtoMethods() *protoiface.Methods { + size := func(input protoiface.SizeInput) protoiface.SizeOutput { + x := input.Message.Interface().(*SnapshotExtensionPayload) + if x == nil { + return protoiface.SizeOutput{ + NoUnkeyedLiterals: input.NoUnkeyedLiterals, + Size: 0, + } + } + options := runtime.SizeInputToOptions(input) + _ = options + var n int + var l int + _ = l + l = len(x.Payload) + if l > 0 { + n += 1 + l + runtime.Sov(uint64(l)) + } + if x.unknownFields != nil { + n += len(x.unknownFields) + } + return protoiface.SizeOutput{ + NoUnkeyedLiterals: input.NoUnkeyedLiterals, + Size: n, + } + } + + marshal := func(input protoiface.MarshalInput) (protoiface.MarshalOutput, error) { + x := input.Message.Interface().(*SnapshotExtensionPayload) + if x == nil { + return protoiface.MarshalOutput{ + NoUnkeyedLiterals: input.NoUnkeyedLiterals, + Buf: input.Buf, + }, nil + } + options := runtime.MarshalInputToOptions(input) + _ = options + size := options.Size(x) + dAtA := make([]byte, size) + i := len(dAtA) + _ = i + var l int + _ = l + if x.unknownFields != nil { + i -= len(x.unknownFields) + copy(dAtA[i:], x.unknownFields) + } + if len(x.Payload) > 0 { + i -= len(x.Payload) + copy(dAtA[i:], x.Payload) + i = runtime.EncodeVarint(dAtA, i, uint64(len(x.Payload))) + i-- + dAtA[i] = 0xa + } + if input.Buf != nil { + input.Buf = append(input.Buf, dAtA...) + } else { + input.Buf = dAtA + } + return protoiface.MarshalOutput{ + NoUnkeyedLiterals: input.NoUnkeyedLiterals, + Buf: input.Buf, + }, nil + } + unmarshal := func(input protoiface.UnmarshalInput) (protoiface.UnmarshalOutput, error) { + x := input.Message.Interface().(*SnapshotExtensionPayload) + if x == nil { + return protoiface.UnmarshalOutput{ + NoUnkeyedLiterals: input.NoUnkeyedLiterals, + Flags: input.Flags, + }, nil + } + options := runtime.UnmarshalInputToOptions(input) + _ = options + dAtA := input.Buf + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrIntOverflow + } + if iNdEx >= l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: SnapshotExtensionPayload: wiretype end group for non-group") + } + if fieldNum <= 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: SnapshotExtensionPayload: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: wrong wireType = %d for field Payload", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrIntOverflow + } + if iNdEx >= l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength + } + if postIndex > l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + x.Payload = append(x.Payload[:0], dAtA[iNdEx:postIndex]...) + if x.Payload == nil { + x.Payload = []byte{} + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := runtime.Skip(dAtA[iNdEx:]) + if err != nil { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength + } + if (iNdEx + skippy) > l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + if !options.DiscardUnknown { + x.unknownFields = append(x.unknownFields, dAtA[iNdEx:iNdEx+skippy]...) + } + iNdEx += skippy + } + } + + if iNdEx > l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, nil + } + return &protoiface.Methods{ + NoUnkeyedLiterals: struct{}{}, + Flags: protoiface.SupportMarshalDeterministic | protoiface.SupportUnmarshalDiscardUnknown, + Size: size, + Marshal: marshal, + Unmarshal: unmarshal, + Merge: nil, + CheckInitialized: nil, + } +} + +// Code generated by protoc-gen-go. DO NOT EDIT. +// versions: +// protoc-gen-go v1.27.0 +// protoc (unknown) +// source: cosmos/store/snapshots/v2/snapshot.proto + +const ( + // Verify that this generated code is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) + // Verify that runtime/protoimpl is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) +) + +// Snapshot contains Tendermint state sync snapshot info. +type Snapshot struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Height uint64 `protobuf:"varint,1,opt,name=height,proto3" json:"height,omitempty"` + Format uint32 `protobuf:"varint,2,opt,name=format,proto3" json:"format,omitempty"` + Chunks uint32 `protobuf:"varint,3,opt,name=chunks,proto3" json:"chunks,omitempty"` + Hash []byte `protobuf:"bytes,4,opt,name=hash,proto3" json:"hash,omitempty"` + Metadata *Metadata `protobuf:"bytes,5,opt,name=metadata,proto3" json:"metadata,omitempty"` +} + +func (x *Snapshot) Reset() { + *x = Snapshot{} + if protoimpl.UnsafeEnabled { + mi := &file_cosmos_store_snapshots_v2_snapshot_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *Snapshot) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*Snapshot) ProtoMessage() {} + +// Deprecated: Use Snapshot.ProtoReflect.Descriptor instead. +func (*Snapshot) Descriptor() ([]byte, []int) { + return file_cosmos_store_snapshots_v2_snapshot_proto_rawDescGZIP(), []int{0} +} + +func (x *Snapshot) GetHeight() uint64 { + if x != nil { + return x.Height + } + return 0 +} + +func (x *Snapshot) GetFormat() uint32 { + if x != nil { + return x.Format + } + return 0 +} + +func (x *Snapshot) GetChunks() uint32 { + if x != nil { + return x.Chunks + } + return 0 +} + +func (x *Snapshot) GetHash() []byte { + if x != nil { + return x.Hash + } + return nil +} + +func (x *Snapshot) GetMetadata() *Metadata { + if x != nil { + return x.Metadata + } + return nil +} + +// Metadata contains SDK-specific snapshot metadata. +type Metadata struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + ChunkHashes [][]byte `protobuf:"bytes,1,rep,name=chunk_hashes,json=chunkHashes,proto3" json:"chunk_hashes,omitempty"` // SHA-256 chunk hashes +} + +func (x *Metadata) Reset() { + *x = Metadata{} + if protoimpl.UnsafeEnabled { + mi := &file_cosmos_store_snapshots_v2_snapshot_proto_msgTypes[1] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *Metadata) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*Metadata) ProtoMessage() {} + +// Deprecated: Use Metadata.ProtoReflect.Descriptor instead. +func (*Metadata) Descriptor() ([]byte, []int) { + return file_cosmos_store_snapshots_v2_snapshot_proto_rawDescGZIP(), []int{1} +} + +func (x *Metadata) GetChunkHashes() [][]byte { + if x != nil { + return x.ChunkHashes + } + return nil +} + +// SnapshotItem is an item contained in a rootmulti.Store snapshot. +type SnapshotItem struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + // item is the specific type of snapshot item. + // + // Types that are assignable to Item: + // + // *SnapshotItem_Store + // *SnapshotItem_Iavl + // *SnapshotItem_Extension + // *SnapshotItem_ExtensionPayload + Item isSnapshotItem_Item `protobuf_oneof:"item"` +} + +func (x *SnapshotItem) Reset() { + *x = SnapshotItem{} + if protoimpl.UnsafeEnabled { + mi := &file_cosmos_store_snapshots_v2_snapshot_proto_msgTypes[2] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *SnapshotItem) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*SnapshotItem) ProtoMessage() {} + +// Deprecated: Use SnapshotItem.ProtoReflect.Descriptor instead. +func (*SnapshotItem) Descriptor() ([]byte, []int) { + return file_cosmos_store_snapshots_v2_snapshot_proto_rawDescGZIP(), []int{2} +} + +func (x *SnapshotItem) GetItem() isSnapshotItem_Item { + if x != nil { + return x.Item + } + return nil +} + +func (x *SnapshotItem) GetStore() *SnapshotStoreItem { + if x, ok := x.GetItem().(*SnapshotItem_Store); ok { + return x.Store + } + return nil +} + +func (x *SnapshotItem) GetIavl() *SnapshotIAVLItem { + if x, ok := x.GetItem().(*SnapshotItem_Iavl); ok { + return x.Iavl + } + return nil +} + +func (x *SnapshotItem) GetExtension() *SnapshotExtensionMeta { + if x, ok := x.GetItem().(*SnapshotItem_Extension); ok { + return x.Extension + } + return nil +} + +func (x *SnapshotItem) GetExtensionPayload() *SnapshotExtensionPayload { + if x, ok := x.GetItem().(*SnapshotItem_ExtensionPayload); ok { + return x.ExtensionPayload + } + return nil +} + +type isSnapshotItem_Item interface { + isSnapshotItem_Item() +} + +type SnapshotItem_Store struct { + Store *SnapshotStoreItem `protobuf:"bytes,1,opt,name=store,proto3,oneof"` +} + +type SnapshotItem_Iavl struct { + Iavl *SnapshotIAVLItem `protobuf:"bytes,2,opt,name=iavl,proto3,oneof"` +} + +type SnapshotItem_Extension struct { + Extension *SnapshotExtensionMeta `protobuf:"bytes,3,opt,name=extension,proto3,oneof"` +} + +type SnapshotItem_ExtensionPayload struct { + ExtensionPayload *SnapshotExtensionPayload `protobuf:"bytes,4,opt,name=extension_payload,json=extensionPayload,proto3,oneof"` +} + +func (*SnapshotItem_Store) isSnapshotItem_Item() {} + +func (*SnapshotItem_Iavl) isSnapshotItem_Item() {} + +func (*SnapshotItem_Extension) isSnapshotItem_Item() {} + +func (*SnapshotItem_ExtensionPayload) isSnapshotItem_Item() {} + +// SnapshotStoreItem contains metadata about a snapshotted store. +type SnapshotStoreItem struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"` +} + +func (x *SnapshotStoreItem) Reset() { + *x = SnapshotStoreItem{} + if protoimpl.UnsafeEnabled { + mi := &file_cosmos_store_snapshots_v2_snapshot_proto_msgTypes[3] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *SnapshotStoreItem) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*SnapshotStoreItem) ProtoMessage() {} + +// Deprecated: Use SnapshotStoreItem.ProtoReflect.Descriptor instead. +func (*SnapshotStoreItem) Descriptor() ([]byte, []int) { + return file_cosmos_store_snapshots_v2_snapshot_proto_rawDescGZIP(), []int{3} +} + +func (x *SnapshotStoreItem) GetName() string { + if x != nil { + return x.Name + } + return "" +} + +// SnapshotIAVLItem is an exported IAVL node. +type SnapshotIAVLItem struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Key []byte `protobuf:"bytes,1,opt,name=key,proto3" json:"key,omitempty"` + Value []byte `protobuf:"bytes,2,opt,name=value,proto3" json:"value,omitempty"` + // version is block height + Version int64 `protobuf:"varint,3,opt,name=version,proto3" json:"version,omitempty"` + // height is depth of the tree. + Height int32 `protobuf:"varint,4,opt,name=height,proto3" json:"height,omitempty"` +} + +func (x *SnapshotIAVLItem) Reset() { + *x = SnapshotIAVLItem{} + if protoimpl.UnsafeEnabled { + mi := &file_cosmos_store_snapshots_v2_snapshot_proto_msgTypes[4] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *SnapshotIAVLItem) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*SnapshotIAVLItem) ProtoMessage() {} + +// Deprecated: Use SnapshotIAVLItem.ProtoReflect.Descriptor instead. +func (*SnapshotIAVLItem) Descriptor() ([]byte, []int) { + return file_cosmos_store_snapshots_v2_snapshot_proto_rawDescGZIP(), []int{4} +} + +func (x *SnapshotIAVLItem) GetKey() []byte { + if x != nil { + return x.Key + } + return nil +} + +func (x *SnapshotIAVLItem) GetValue() []byte { + if x != nil { + return x.Value + } + return nil +} + +func (x *SnapshotIAVLItem) GetVersion() int64 { + if x != nil { + return x.Version + } + return 0 +} + +func (x *SnapshotIAVLItem) GetHeight() int32 { + if x != nil { + return x.Height + } + return 0 +} + +// SnapshotExtensionMeta contains metadata about an external snapshotter. +type SnapshotExtensionMeta struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"` + Format uint32 `protobuf:"varint,2,opt,name=format,proto3" json:"format,omitempty"` +} + +func (x *SnapshotExtensionMeta) Reset() { + *x = SnapshotExtensionMeta{} + if protoimpl.UnsafeEnabled { + mi := &file_cosmos_store_snapshots_v2_snapshot_proto_msgTypes[5] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *SnapshotExtensionMeta) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*SnapshotExtensionMeta) ProtoMessage() {} + +// Deprecated: Use SnapshotExtensionMeta.ProtoReflect.Descriptor instead. +func (*SnapshotExtensionMeta) Descriptor() ([]byte, []int) { + return file_cosmos_store_snapshots_v2_snapshot_proto_rawDescGZIP(), []int{5} +} + +func (x *SnapshotExtensionMeta) GetName() string { + if x != nil { + return x.Name + } + return "" +} + +func (x *SnapshotExtensionMeta) GetFormat() uint32 { + if x != nil { + return x.Format + } + return 0 +} + +// SnapshotExtensionPayload contains payloads of an external snapshotter. +type SnapshotExtensionPayload struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Payload []byte `protobuf:"bytes,1,opt,name=payload,proto3" json:"payload,omitempty"` +} + +func (x *SnapshotExtensionPayload) Reset() { + *x = SnapshotExtensionPayload{} + if protoimpl.UnsafeEnabled { + mi := &file_cosmos_store_snapshots_v2_snapshot_proto_msgTypes[6] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *SnapshotExtensionPayload) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*SnapshotExtensionPayload) ProtoMessage() {} + +// Deprecated: Use SnapshotExtensionPayload.ProtoReflect.Descriptor instead. +func (*SnapshotExtensionPayload) Descriptor() ([]byte, []int) { + return file_cosmos_store_snapshots_v2_snapshot_proto_rawDescGZIP(), []int{6} +} + +func (x *SnapshotExtensionPayload) GetPayload() []byte { + if x != nil { + return x.Payload + } + return nil +} + +var File_cosmos_store_snapshots_v2_snapshot_proto protoreflect.FileDescriptor + +var file_cosmos_store_snapshots_v2_snapshot_proto_rawDesc = []byte{ + 0x0a, 0x28, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2f, 0x73, 0x74, 0x6f, 0x72, 0x65, 0x2f, 0x73, + 0x6e, 0x61, 0x70, 0x73, 0x68, 0x6f, 0x74, 0x73, 0x2f, 0x76, 0x32, 0x2f, 0x73, 0x6e, 0x61, 0x70, + 0x73, 0x68, 0x6f, 0x74, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x19, 0x63, 0x6f, 0x73, 0x6d, + 0x6f, 0x73, 0x2e, 0x73, 0x74, 0x6f, 0x72, 0x65, 0x2e, 0x73, 0x6e, 0x61, 0x70, 0x73, 0x68, 0x6f, + 0x74, 0x73, 0x2e, 0x76, 0x32, 0x1a, 0x14, 0x67, 0x6f, 0x67, 0x6f, 0x70, 0x72, 0x6f, 0x74, 0x6f, + 0x2f, 0x67, 0x6f, 0x67, 0x6f, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x19, 0x63, 0x6f, 0x73, + 0x6d, 0x6f, 0x73, 0x5f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, + 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0xad, 0x01, 0x0a, 0x08, 0x53, 0x6e, 0x61, 0x70, 0x73, + 0x68, 0x6f, 0x74, 0x12, 0x16, 0x0a, 0x06, 0x68, 0x65, 0x69, 0x67, 0x68, 0x74, 0x18, 0x01, 0x20, + 0x01, 0x28, 0x04, 0x52, 0x06, 0x68, 0x65, 0x69, 0x67, 0x68, 0x74, 0x12, 0x16, 0x0a, 0x06, 0x66, + 0x6f, 0x72, 0x6d, 0x61, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x06, 0x66, 0x6f, 0x72, + 0x6d, 0x61, 0x74, 0x12, 0x16, 0x0a, 0x06, 0x63, 0x68, 0x75, 0x6e, 0x6b, 0x73, 0x18, 0x03, 0x20, + 0x01, 0x28, 0x0d, 0x52, 0x06, 0x63, 0x68, 0x75, 0x6e, 0x6b, 0x73, 0x12, 0x12, 0x0a, 0x04, 0x68, + 0x61, 0x73, 0x68, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x04, 0x68, 0x61, 0x73, 0x68, 0x12, + 0x45, 0x0a, 0x08, 0x6d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0x18, 0x05, 0x20, 0x01, 0x28, + 0x0b, 0x32, 0x23, 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x73, 0x74, 0x6f, 0x72, 0x65, + 0x2e, 0x73, 0x6e, 0x61, 0x70, 0x73, 0x68, 0x6f, 0x74, 0x73, 0x2e, 0x76, 0x32, 0x2e, 0x4d, 0x65, + 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0x42, 0x04, 0xc8, 0xde, 0x1f, 0x00, 0x52, 0x08, 0x6d, 0x65, + 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0x22, 0x2d, 0x0a, 0x08, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, + 0x74, 0x61, 0x12, 0x21, 0x0a, 0x0c, 0x63, 0x68, 0x75, 0x6e, 0x6b, 0x5f, 0x68, 0x61, 0x73, 0x68, + 0x65, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0c, 0x52, 0x0b, 0x63, 0x68, 0x75, 0x6e, 0x6b, 0x48, + 0x61, 0x73, 0x68, 0x65, 0x73, 0x22, 0xf4, 0x02, 0x0a, 0x0c, 0x53, 0x6e, 0x61, 0x70, 0x73, 0x68, + 0x6f, 0x74, 0x49, 0x74, 0x65, 0x6d, 0x12, 0x44, 0x0a, 0x05, 0x73, 0x74, 0x6f, 0x72, 0x65, 0x18, + 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x2c, 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x73, + 0x74, 0x6f, 0x72, 0x65, 0x2e, 0x73, 0x6e, 0x61, 0x70, 0x73, 0x68, 0x6f, 0x74, 0x73, 0x2e, 0x76, + 0x32, 0x2e, 0x53, 0x6e, 0x61, 0x70, 0x73, 0x68, 0x6f, 0x74, 0x53, 0x74, 0x6f, 0x72, 0x65, 0x49, + 0x74, 0x65, 0x6d, 0x48, 0x00, 0x52, 0x05, 0x73, 0x74, 0x6f, 0x72, 0x65, 0x12, 0x4b, 0x0a, 0x04, + 0x69, 0x61, 0x76, 0x6c, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x2b, 0x2e, 0x63, 0x6f, 0x73, + 0x6d, 0x6f, 0x73, 0x2e, 0x73, 0x74, 0x6f, 0x72, 0x65, 0x2e, 0x73, 0x6e, 0x61, 0x70, 0x73, 0x68, + 0x6f, 0x74, 0x73, 0x2e, 0x76, 0x32, 0x2e, 0x53, 0x6e, 0x61, 0x70, 0x73, 0x68, 0x6f, 0x74, 0x49, + 0x41, 0x56, 0x4c, 0x49, 0x74, 0x65, 0x6d, 0x42, 0x08, 0xe2, 0xde, 0x1f, 0x04, 0x49, 0x41, 0x56, + 0x4c, 0x48, 0x00, 0x52, 0x04, 0x69, 0x61, 0x76, 0x6c, 0x12, 0x50, 0x0a, 0x09, 0x65, 0x78, 0x74, + 0x65, 0x6e, 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x30, 0x2e, 0x63, + 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x73, 0x74, 0x6f, 0x72, 0x65, 0x2e, 0x73, 0x6e, 0x61, 0x70, + 0x73, 0x68, 0x6f, 0x74, 0x73, 0x2e, 0x76, 0x32, 0x2e, 0x53, 0x6e, 0x61, 0x70, 0x73, 0x68, 0x6f, + 0x74, 0x45, 0x78, 0x74, 0x65, 0x6e, 0x73, 0x69, 0x6f, 0x6e, 0x4d, 0x65, 0x74, 0x61, 0x48, 0x00, + 0x52, 0x09, 0x65, 0x78, 0x74, 0x65, 0x6e, 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x62, 0x0a, 0x11, 0x65, + 0x78, 0x74, 0x65, 0x6e, 0x73, 0x69, 0x6f, 0x6e, 0x5f, 0x70, 0x61, 0x79, 0x6c, 0x6f, 0x61, 0x64, + 0x18, 0x04, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x33, 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, + 0x73, 0x74, 0x6f, 0x72, 0x65, 0x2e, 0x73, 0x6e, 0x61, 0x70, 0x73, 0x68, 0x6f, 0x74, 0x73, 0x2e, + 0x76, 0x32, 0x2e, 0x53, 0x6e, 0x61, 0x70, 0x73, 0x68, 0x6f, 0x74, 0x45, 0x78, 0x74, 0x65, 0x6e, + 0x73, 0x69, 0x6f, 0x6e, 0x50, 0x61, 0x79, 0x6c, 0x6f, 0x61, 0x64, 0x48, 0x00, 0x52, 0x10, 0x65, + 0x78, 0x74, 0x65, 0x6e, 0x73, 0x69, 0x6f, 0x6e, 0x50, 0x61, 0x79, 0x6c, 0x6f, 0x61, 0x64, 0x3a, + 0x13, 0xd2, 0xb4, 0x2d, 0x0f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2d, 0x73, 0x64, 0x6b, 0x20, + 0x30, 0x2e, 0x34, 0x36, 0x42, 0x06, 0x0a, 0x04, 0x69, 0x74, 0x65, 0x6d, 0x22, 0x3c, 0x0a, 0x11, + 0x53, 0x6e, 0x61, 0x70, 0x73, 0x68, 0x6f, 0x74, 0x53, 0x74, 0x6f, 0x72, 0x65, 0x49, 0x74, 0x65, + 0x6d, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, + 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x3a, 0x13, 0xd2, 0xb4, 0x2d, 0x0f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, + 0x73, 0x2d, 0x73, 0x64, 0x6b, 0x20, 0x30, 0x2e, 0x34, 0x36, 0x22, 0x81, 0x01, 0x0a, 0x10, 0x53, + 0x6e, 0x61, 0x70, 0x73, 0x68, 0x6f, 0x74, 0x49, 0x41, 0x56, 0x4c, 0x49, 0x74, 0x65, 0x6d, 0x12, + 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x03, 0x6b, 0x65, + 0x79, 0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0c, + 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x12, 0x18, 0x0a, 0x07, 0x76, 0x65, 0x72, 0x73, 0x69, + 0x6f, 0x6e, 0x18, 0x03, 0x20, 0x01, 0x28, 0x03, 0x52, 0x07, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, + 0x6e, 0x12, 0x16, 0x0a, 0x06, 0x68, 0x65, 0x69, 0x67, 0x68, 0x74, 0x18, 0x04, 0x20, 0x01, 0x28, + 0x05, 0x52, 0x06, 0x68, 0x65, 0x69, 0x67, 0x68, 0x74, 0x3a, 0x13, 0xd2, 0xb4, 0x2d, 0x0f, 0x63, + 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2d, 0x73, 0x64, 0x6b, 0x20, 0x30, 0x2e, 0x34, 0x36, 0x22, 0x58, + 0x0a, 0x15, 0x53, 0x6e, 0x61, 0x70, 0x73, 0x68, 0x6f, 0x74, 0x45, 0x78, 0x74, 0x65, 0x6e, 0x73, + 0x69, 0x6f, 0x6e, 0x4d, 0x65, 0x74, 0x61, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, + 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x16, 0x0a, 0x06, 0x66, + 0x6f, 0x72, 0x6d, 0x61, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x06, 0x66, 0x6f, 0x72, + 0x6d, 0x61, 0x74, 0x3a, 0x13, 0xd2, 0xb4, 0x2d, 0x0f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2d, + 0x73, 0x64, 0x6b, 0x20, 0x30, 0x2e, 0x34, 0x36, 0x22, 0x49, 0x0a, 0x18, 0x53, 0x6e, 0x61, 0x70, + 0x73, 0x68, 0x6f, 0x74, 0x45, 0x78, 0x74, 0x65, 0x6e, 0x73, 0x69, 0x6f, 0x6e, 0x50, 0x61, 0x79, + 0x6c, 0x6f, 0x61, 0x64, 0x12, 0x18, 0x0a, 0x07, 0x70, 0x61, 0x79, 0x6c, 0x6f, 0x61, 0x64, 0x18, + 0x01, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x07, 0x70, 0x61, 0x79, 0x6c, 0x6f, 0x61, 0x64, 0x3a, 0x13, + 0xd2, 0xb4, 0x2d, 0x0f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2d, 0x73, 0x64, 0x6b, 0x20, 0x30, + 0x2e, 0x34, 0x36, 0x42, 0xed, 0x01, 0x0a, 0x1d, 0x63, 0x6f, 0x6d, 0x2e, 0x63, 0x6f, 0x73, 0x6d, + 0x6f, 0x73, 0x2e, 0x73, 0x74, 0x6f, 0x72, 0x65, 0x2e, 0x73, 0x6e, 0x61, 0x70, 0x73, 0x68, 0x6f, + 0x74, 0x73, 0x2e, 0x76, 0x32, 0x42, 0x0d, 0x53, 0x6e, 0x61, 0x70, 0x73, 0x68, 0x6f, 0x74, 0x50, + 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x36, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x73, 0x64, + 0x6b, 0x2e, 0x69, 0x6f, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2f, + 0x73, 0x74, 0x6f, 0x72, 0x65, 0x2f, 0x73, 0x6e, 0x61, 0x70, 0x73, 0x68, 0x6f, 0x74, 0x73, 0x2f, + 0x76, 0x32, 0x3b, 0x73, 0x6e, 0x61, 0x70, 0x73, 0x68, 0x6f, 0x74, 0x73, 0x76, 0x32, 0xa2, 0x02, + 0x03, 0x43, 0x53, 0x53, 0xaa, 0x02, 0x19, 0x43, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x53, 0x74, + 0x6f, 0x72, 0x65, 0x2e, 0x53, 0x6e, 0x61, 0x70, 0x73, 0x68, 0x6f, 0x74, 0x73, 0x2e, 0x56, 0x32, + 0xca, 0x02, 0x19, 0x43, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x5c, 0x53, 0x74, 0x6f, 0x72, 0x65, 0x5c, + 0x53, 0x6e, 0x61, 0x70, 0x73, 0x68, 0x6f, 0x74, 0x73, 0x5c, 0x56, 0x32, 0xe2, 0x02, 0x25, 0x43, + 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x5c, 0x53, 0x74, 0x6f, 0x72, 0x65, 0x5c, 0x53, 0x6e, 0x61, 0x70, + 0x73, 0x68, 0x6f, 0x74, 0x73, 0x5c, 0x56, 0x32, 0x5c, 0x47, 0x50, 0x42, 0x4d, 0x65, 0x74, 0x61, + 0x64, 0x61, 0x74, 0x61, 0xea, 0x02, 0x1c, 0x43, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x3a, 0x3a, 0x53, + 0x74, 0x6f, 0x72, 0x65, 0x3a, 0x3a, 0x53, 0x6e, 0x61, 0x70, 0x73, 0x68, 0x6f, 0x74, 0x73, 0x3a, + 0x3a, 0x56, 0x32, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, +} + +var ( + file_cosmos_store_snapshots_v2_snapshot_proto_rawDescOnce sync.Once + file_cosmos_store_snapshots_v2_snapshot_proto_rawDescData = file_cosmos_store_snapshots_v2_snapshot_proto_rawDesc +) + +func file_cosmos_store_snapshots_v2_snapshot_proto_rawDescGZIP() []byte { + file_cosmos_store_snapshots_v2_snapshot_proto_rawDescOnce.Do(func() { + file_cosmos_store_snapshots_v2_snapshot_proto_rawDescData = protoimpl.X.CompressGZIP(file_cosmos_store_snapshots_v2_snapshot_proto_rawDescData) + }) + return file_cosmos_store_snapshots_v2_snapshot_proto_rawDescData +} + +var file_cosmos_store_snapshots_v2_snapshot_proto_msgTypes = make([]protoimpl.MessageInfo, 7) +var file_cosmos_store_snapshots_v2_snapshot_proto_goTypes = []interface{}{ + (*Snapshot)(nil), // 0: cosmos.store.snapshots.v2.Snapshot + (*Metadata)(nil), // 1: cosmos.store.snapshots.v2.Metadata + (*SnapshotItem)(nil), // 2: cosmos.store.snapshots.v2.SnapshotItem + (*SnapshotStoreItem)(nil), // 3: cosmos.store.snapshots.v2.SnapshotStoreItem + (*SnapshotIAVLItem)(nil), // 4: cosmos.store.snapshots.v2.SnapshotIAVLItem + (*SnapshotExtensionMeta)(nil), // 5: cosmos.store.snapshots.v2.SnapshotExtensionMeta + (*SnapshotExtensionPayload)(nil), // 6: cosmos.store.snapshots.v2.SnapshotExtensionPayload +} +var file_cosmos_store_snapshots_v2_snapshot_proto_depIdxs = []int32{ + 1, // 0: cosmos.store.snapshots.v2.Snapshot.metadata:type_name -> cosmos.store.snapshots.v2.Metadata + 3, // 1: cosmos.store.snapshots.v2.SnapshotItem.store:type_name -> cosmos.store.snapshots.v2.SnapshotStoreItem + 4, // 2: cosmos.store.snapshots.v2.SnapshotItem.iavl:type_name -> cosmos.store.snapshots.v2.SnapshotIAVLItem + 5, // 3: cosmos.store.snapshots.v2.SnapshotItem.extension:type_name -> cosmos.store.snapshots.v2.SnapshotExtensionMeta + 6, // 4: cosmos.store.snapshots.v2.SnapshotItem.extension_payload:type_name -> cosmos.store.snapshots.v2.SnapshotExtensionPayload + 5, // [5:5] is the sub-list for method output_type + 5, // [5:5] is the sub-list for method input_type + 5, // [5:5] is the sub-list for extension type_name + 5, // [5:5] is the sub-list for extension extendee + 0, // [0:5] is the sub-list for field type_name +} + +func init() { file_cosmos_store_snapshots_v2_snapshot_proto_init() } +func file_cosmos_store_snapshots_v2_snapshot_proto_init() { + if File_cosmos_store_snapshots_v2_snapshot_proto != nil { + return + } + if !protoimpl.UnsafeEnabled { + file_cosmos_store_snapshots_v2_snapshot_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*Snapshot); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_cosmos_store_snapshots_v2_snapshot_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*Metadata); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_cosmos_store_snapshots_v2_snapshot_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*SnapshotItem); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_cosmos_store_snapshots_v2_snapshot_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*SnapshotStoreItem); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_cosmos_store_snapshots_v2_snapshot_proto_msgTypes[4].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*SnapshotIAVLItem); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_cosmos_store_snapshots_v2_snapshot_proto_msgTypes[5].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*SnapshotExtensionMeta); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_cosmos_store_snapshots_v2_snapshot_proto_msgTypes[6].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*SnapshotExtensionPayload); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + } + file_cosmos_store_snapshots_v2_snapshot_proto_msgTypes[2].OneofWrappers = []interface{}{ + (*SnapshotItem_Store)(nil), + (*SnapshotItem_Iavl)(nil), + (*SnapshotItem_Extension)(nil), + (*SnapshotItem_ExtensionPayload)(nil), + } + type x struct{} + out := protoimpl.TypeBuilder{ + File: protoimpl.DescBuilder{ + GoPackagePath: reflect.TypeOf(x{}).PkgPath(), + RawDescriptor: file_cosmos_store_snapshots_v2_snapshot_proto_rawDesc, + NumEnums: 0, + NumMessages: 7, + NumExtensions: 0, + NumServices: 0, + }, + GoTypes: file_cosmos_store_snapshots_v2_snapshot_proto_goTypes, + DependencyIndexes: file_cosmos_store_snapshots_v2_snapshot_proto_depIdxs, + MessageInfos: file_cosmos_store_snapshots_v2_snapshot_proto_msgTypes, + }.Build() + File_cosmos_store_snapshots_v2_snapshot_proto = out.File + file_cosmos_store_snapshots_v2_snapshot_proto_rawDesc = nil + file_cosmos_store_snapshots_v2_snapshot_proto_goTypes = nil + file_cosmos_store_snapshots_v2_snapshot_proto_depIdxs = nil +} diff --git a/api/cosmos/tx/v1beta1/tx.pulsar.go b/api/cosmos/tx/v1beta1/tx.pulsar.go index 56ea5057518a..b2feef2fb80f 100644 --- a/api/cosmos/tx/v1beta1/tx.pulsar.go +++ b/api/cosmos/tx/v1beta1/tx.pulsar.go @@ -14,6 +14,7 @@ import ( protoiface "google.golang.org/protobuf/runtime/protoiface" protoimpl "google.golang.org/protobuf/runtime/protoimpl" anypb "google.golang.org/protobuf/types/known/anypb" + timestamppb "google.golang.org/protobuf/types/known/timestamppb" io "io" reflect "reflect" sync "sync" @@ -2768,6 +2769,7 @@ var ( fd_TxBody_memo protoreflect.FieldDescriptor fd_TxBody_timeout_height protoreflect.FieldDescriptor fd_TxBody_unordered protoreflect.FieldDescriptor + fd_TxBody_timeout_timestamp protoreflect.FieldDescriptor fd_TxBody_extension_options protoreflect.FieldDescriptor fd_TxBody_non_critical_extension_options protoreflect.FieldDescriptor ) @@ -2779,6 +2781,7 @@ func init() { fd_TxBody_memo = md_TxBody.Fields().ByName("memo") fd_TxBody_timeout_height = md_TxBody.Fields().ByName("timeout_height") fd_TxBody_unordered = md_TxBody.Fields().ByName("unordered") + fd_TxBody_timeout_timestamp = md_TxBody.Fields().ByName("timeout_timestamp") fd_TxBody_extension_options = md_TxBody.Fields().ByName("extension_options") fd_TxBody_non_critical_extension_options = md_TxBody.Fields().ByName("non_critical_extension_options") } @@ -2872,6 +2875,12 @@ func (x *fastReflection_TxBody) Range(f func(protoreflect.FieldDescriptor, proto return } } + if x.TimeoutTimestamp != nil { + value := protoreflect.ValueOfMessage(x.TimeoutTimestamp.ProtoReflect()) + if !f(fd_TxBody_timeout_timestamp, value) { + return + } + } if len(x.ExtensionOptions) != 0 { value := protoreflect.ValueOfList(&_TxBody_1023_list{list: &x.ExtensionOptions}) if !f(fd_TxBody_extension_options, value) { @@ -2907,6 +2916,8 @@ func (x *fastReflection_TxBody) Has(fd protoreflect.FieldDescriptor) bool { return x.TimeoutHeight != uint64(0) case "cosmos.tx.v1beta1.TxBody.unordered": return x.Unordered != false + case "cosmos.tx.v1beta1.TxBody.timeout_timestamp": + return x.TimeoutTimestamp != nil case "cosmos.tx.v1beta1.TxBody.extension_options": return len(x.ExtensionOptions) != 0 case "cosmos.tx.v1beta1.TxBody.non_critical_extension_options": @@ -2935,6 +2946,8 @@ func (x *fastReflection_TxBody) Clear(fd protoreflect.FieldDescriptor) { x.TimeoutHeight = uint64(0) case "cosmos.tx.v1beta1.TxBody.unordered": x.Unordered = false + case "cosmos.tx.v1beta1.TxBody.timeout_timestamp": + x.TimeoutTimestamp = nil case "cosmos.tx.v1beta1.TxBody.extension_options": x.ExtensionOptions = nil case "cosmos.tx.v1beta1.TxBody.non_critical_extension_options": @@ -2970,6 +2983,9 @@ func (x *fastReflection_TxBody) Get(descriptor protoreflect.FieldDescriptor) pro case "cosmos.tx.v1beta1.TxBody.unordered": value := x.Unordered return protoreflect.ValueOfBool(value) + case "cosmos.tx.v1beta1.TxBody.timeout_timestamp": + value := x.TimeoutTimestamp + return protoreflect.ValueOfMessage(value.ProtoReflect()) case "cosmos.tx.v1beta1.TxBody.extension_options": if len(x.ExtensionOptions) == 0 { return protoreflect.ValueOfList(&_TxBody_1023_list{}) @@ -3012,6 +3028,8 @@ func (x *fastReflection_TxBody) Set(fd protoreflect.FieldDescriptor, value proto x.TimeoutHeight = value.Uint() case "cosmos.tx.v1beta1.TxBody.unordered": x.Unordered = value.Bool() + case "cosmos.tx.v1beta1.TxBody.timeout_timestamp": + x.TimeoutTimestamp = value.Message().Interface().(*timestamppb.Timestamp) case "cosmos.tx.v1beta1.TxBody.extension_options": lv := value.List() clv := lv.(*_TxBody_1023_list) @@ -3046,6 +3064,11 @@ func (x *fastReflection_TxBody) Mutable(fd protoreflect.FieldDescriptor) protore } value := &_TxBody_1_list{list: &x.Messages} return protoreflect.ValueOfList(value) + case "cosmos.tx.v1beta1.TxBody.timeout_timestamp": + if x.TimeoutTimestamp == nil { + x.TimeoutTimestamp = new(timestamppb.Timestamp) + } + return protoreflect.ValueOfMessage(x.TimeoutTimestamp.ProtoReflect()) case "cosmos.tx.v1beta1.TxBody.extension_options": if x.ExtensionOptions == nil { x.ExtensionOptions = []*anypb.Any{} @@ -3086,6 +3109,9 @@ func (x *fastReflection_TxBody) NewField(fd protoreflect.FieldDescriptor) protor return protoreflect.ValueOfUint64(uint64(0)) case "cosmos.tx.v1beta1.TxBody.unordered": return protoreflect.ValueOfBool(false) + case "cosmos.tx.v1beta1.TxBody.timeout_timestamp": + m := new(timestamppb.Timestamp) + return protoreflect.ValueOfMessage(m.ProtoReflect()) case "cosmos.tx.v1beta1.TxBody.extension_options": list := []*anypb.Any{} return protoreflect.ValueOfList(&_TxBody_1023_list{list: &list}) @@ -3177,6 +3203,10 @@ func (x *fastReflection_TxBody) ProtoMethods() *protoiface.Methods { if x.Unordered { n += 2 } + if x.TimeoutTimestamp != nil { + l = options.Size(x.TimeoutTimestamp) + n += 1 + l + runtime.Sov(uint64(l)) + } if len(x.ExtensionOptions) > 0 { for _, e := range x.ExtensionOptions { l = options.Size(e) @@ -3254,6 +3284,20 @@ func (x *fastReflection_TxBody) ProtoMethods() *protoiface.Methods { dAtA[i] = 0xfa } } + if x.TimeoutTimestamp != nil { + encoded, err := options.Marshal(x.TimeoutTimestamp) + if err != nil { + return protoiface.MarshalOutput{ + NoUnkeyedLiterals: input.NoUnkeyedLiterals, + Buf: input.Buf, + }, err + } + i -= len(encoded) + copy(dAtA[i:], encoded) + i = runtime.EncodeVarint(dAtA, i, uint64(len(encoded))) + i-- + dAtA[i] = 0x2a + } if x.Unordered { i-- if x.Unordered { @@ -3446,6 +3490,42 @@ func (x *fastReflection_TxBody) ProtoMethods() *protoiface.Methods { } } x.Unordered = bool(v != 0) + case 5: + if wireType != 2 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: wrong wireType = %d for field TimeoutTimestamp", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrIntOverflow + } + if iNdEx >= l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength + } + if postIndex > l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + if x.TimeoutTimestamp == nil { + x.TimeoutTimestamp = ×tamppb.Timestamp{} + } + if err := options.Unmarshal(dAtA[iNdEx:postIndex], x.TimeoutTimestamp); err != nil { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, err + } + iNdEx = postIndex case 1023: if wireType != 2 { return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: wrong wireType = %d for field ExtensionOptions", wireType) @@ -8471,10 +8551,6 @@ type TxBody struct { Memo string `protobuf:"bytes,2,opt,name=memo,proto3" json:"memo,omitempty"` // timeout_height is the block height after which this transaction will not // be processed by the chain. - // - // Note, if unordered=true this value MUST be set - // and will act as a short-lived TTL in which the transaction is deemed valid - // and kept in memory to prevent duplicates. TimeoutHeight uint64 `protobuf:"varint,3,opt,name=timeout_height,json=timeoutHeight,proto3" json:"timeout_height,omitempty"` // unordered, when set to true, indicates that the transaction signer(s) // intend for the transaction to be evaluated and executed in an un-ordered @@ -8482,10 +8558,17 @@ type TxBody struct { // incremented, which allows for fire-and-forget as well as concurrent // transaction execution. // - // Note, when set to true, the existing 'timeout_height' value must be set and - // will be used to correspond to a height in which the transaction is deemed + // Note, when set to true, the existing 'timeout_height' value must + // be set and will be used to correspond to a time_stamp in which the transaction is deemed // valid. Unordered bool `protobuf:"varint,4,opt,name=unordered,proto3" json:"unordered,omitempty"` + // timeout_timestamp is the block time after which this transaction will not + // be processed by the chain. + // + // Note, if unordered=true this value MUST be set + // and will act as a short-lived TTL in which the transaction is deemed valid + // and kept in memory to prevent duplicates. + TimeoutTimestamp *timestamppb.Timestamp `protobuf:"bytes,5,opt,name=timeout_timestamp,json=timeoutTimestamp,proto3" json:"timeout_timestamp,omitempty"` // extension_options are arbitrary options that can be added by chains // when the default options are not sufficient. If any of these are present // and can't be handled, the transaction will be rejected @@ -8544,6 +8627,13 @@ func (x *TxBody) GetUnordered() bool { return false } +func (x *TxBody) GetTimeoutTimestamp() *timestamppb.Timestamp { + if x != nil { + return x.TimeoutTimestamp + } + return nil +} + func (x *TxBody) GetExtensionOptions() []*anypb.Any { if x != nil { return x.ExtensionOptions @@ -9059,128 +9149,119 @@ var file_cosmos_tx_v1beta1_tx_proto_rawDesc = []byte{ 0x67, 0x6e, 0x69, 0x6e, 0x67, 0x2f, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x2f, 0x73, 0x69, 0x67, 0x6e, 0x69, 0x6e, 0x67, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x19, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2f, 0x61, 0x6e, 0x79, - 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x8d, 0x01, 0x0a, 0x02, 0x54, 0x78, 0x12, 0x2d, 0x0a, - 0x04, 0x62, 0x6f, 0x64, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x19, 0x2e, 0x63, 0x6f, - 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x74, 0x78, 0x2e, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x2e, - 0x54, 0x78, 0x42, 0x6f, 0x64, 0x79, 0x52, 0x04, 0x62, 0x6f, 0x64, 0x79, 0x12, 0x38, 0x0a, 0x09, - 0x61, 0x75, 0x74, 0x68, 0x5f, 0x69, 0x6e, 0x66, 0x6f, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, - 0x1b, 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x74, 0x78, 0x2e, 0x76, 0x31, 0x62, 0x65, - 0x74, 0x61, 0x31, 0x2e, 0x41, 0x75, 0x74, 0x68, 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x08, 0x61, 0x75, - 0x74, 0x68, 0x49, 0x6e, 0x66, 0x6f, 0x12, 0x1e, 0x0a, 0x0a, 0x73, 0x69, 0x67, 0x6e, 0x61, 0x74, - 0x75, 0x72, 0x65, 0x73, 0x18, 0x03, 0x20, 0x03, 0x28, 0x0c, 0x52, 0x0a, 0x73, 0x69, 0x67, 0x6e, - 0x61, 0x74, 0x75, 0x72, 0x65, 0x73, 0x22, 0x6e, 0x0a, 0x05, 0x54, 0x78, 0x52, 0x61, 0x77, 0x12, - 0x1d, 0x0a, 0x0a, 0x62, 0x6f, 0x64, 0x79, 0x5f, 0x62, 0x79, 0x74, 0x65, 0x73, 0x18, 0x01, 0x20, - 0x01, 0x28, 0x0c, 0x52, 0x09, 0x62, 0x6f, 0x64, 0x79, 0x42, 0x79, 0x74, 0x65, 0x73, 0x12, 0x26, - 0x0a, 0x0f, 0x61, 0x75, 0x74, 0x68, 0x5f, 0x69, 0x6e, 0x66, 0x6f, 0x5f, 0x62, 0x79, 0x74, 0x65, - 0x73, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x0d, 0x61, 0x75, 0x74, 0x68, 0x49, 0x6e, 0x66, - 0x6f, 0x42, 0x79, 0x74, 0x65, 0x73, 0x12, 0x1e, 0x0a, 0x0a, 0x73, 0x69, 0x67, 0x6e, 0x61, 0x74, - 0x75, 0x72, 0x65, 0x73, 0x18, 0x03, 0x20, 0x03, 0x28, 0x0c, 0x52, 0x0a, 0x73, 0x69, 0x67, 0x6e, - 0x61, 0x74, 0x75, 0x72, 0x65, 0x73, 0x22, 0x92, 0x01, 0x0a, 0x07, 0x53, 0x69, 0x67, 0x6e, 0x44, - 0x6f, 0x63, 0x12, 0x1d, 0x0a, 0x0a, 0x62, 0x6f, 0x64, 0x79, 0x5f, 0x62, 0x79, 0x74, 0x65, 0x73, - 0x18, 0x01, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x09, 0x62, 0x6f, 0x64, 0x79, 0x42, 0x79, 0x74, 0x65, - 0x73, 0x12, 0x26, 0x0a, 0x0f, 0x61, 0x75, 0x74, 0x68, 0x5f, 0x69, 0x6e, 0x66, 0x6f, 0x5f, 0x62, - 0x79, 0x74, 0x65, 0x73, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x0d, 0x61, 0x75, 0x74, 0x68, - 0x49, 0x6e, 0x66, 0x6f, 0x42, 0x79, 0x74, 0x65, 0x73, 0x12, 0x19, 0x0a, 0x08, 0x63, 0x68, 0x61, - 0x69, 0x6e, 0x5f, 0x69, 0x64, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x63, 0x68, 0x61, - 0x69, 0x6e, 0x49, 0x64, 0x12, 0x25, 0x0a, 0x0e, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x5f, - 0x6e, 0x75, 0x6d, 0x62, 0x65, 0x72, 0x18, 0x04, 0x20, 0x01, 0x28, 0x04, 0x52, 0x0d, 0x61, 0x63, - 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x4e, 0x75, 0x6d, 0x62, 0x65, 0x72, 0x22, 0x87, 0x02, 0x0a, 0x10, - 0x53, 0x69, 0x67, 0x6e, 0x44, 0x6f, 0x63, 0x44, 0x69, 0x72, 0x65, 0x63, 0x74, 0x41, 0x75, 0x78, + 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x1f, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x70, + 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2f, 0x74, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, + 0x70, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x8d, 0x01, 0x0a, 0x02, 0x54, 0x78, 0x12, 0x2d, + 0x0a, 0x04, 0x62, 0x6f, 0x64, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x19, 0x2e, 0x63, + 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x74, 0x78, 0x2e, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, + 0x2e, 0x54, 0x78, 0x42, 0x6f, 0x64, 0x79, 0x52, 0x04, 0x62, 0x6f, 0x64, 0x79, 0x12, 0x38, 0x0a, + 0x09, 0x61, 0x75, 0x74, 0x68, 0x5f, 0x69, 0x6e, 0x66, 0x6f, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, + 0x32, 0x1b, 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x74, 0x78, 0x2e, 0x76, 0x31, 0x62, + 0x65, 0x74, 0x61, 0x31, 0x2e, 0x41, 0x75, 0x74, 0x68, 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x08, 0x61, + 0x75, 0x74, 0x68, 0x49, 0x6e, 0x66, 0x6f, 0x12, 0x1e, 0x0a, 0x0a, 0x73, 0x69, 0x67, 0x6e, 0x61, + 0x74, 0x75, 0x72, 0x65, 0x73, 0x18, 0x03, 0x20, 0x03, 0x28, 0x0c, 0x52, 0x0a, 0x73, 0x69, 0x67, + 0x6e, 0x61, 0x74, 0x75, 0x72, 0x65, 0x73, 0x22, 0x6e, 0x0a, 0x05, 0x54, 0x78, 0x52, 0x61, 0x77, 0x12, 0x1d, 0x0a, 0x0a, 0x62, 0x6f, 0x64, 0x79, 0x5f, 0x62, 0x79, 0x74, 0x65, 0x73, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x09, 0x62, 0x6f, 0x64, 0x79, 0x42, 0x79, 0x74, 0x65, 0x73, 0x12, - 0x33, 0x0a, 0x0a, 0x70, 0x75, 0x62, 0x6c, 0x69, 0x63, 0x5f, 0x6b, 0x65, 0x79, 0x18, 0x02, 0x20, - 0x01, 0x28, 0x0b, 0x32, 0x14, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, - 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x41, 0x6e, 0x79, 0x52, 0x09, 0x70, 0x75, 0x62, 0x6c, 0x69, - 0x63, 0x4b, 0x65, 0x79, 0x12, 0x19, 0x0a, 0x08, 0x63, 0x68, 0x61, 0x69, 0x6e, 0x5f, 0x69, 0x64, - 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x63, 0x68, 0x61, 0x69, 0x6e, 0x49, 0x64, 0x12, - 0x25, 0x0a, 0x0e, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x5f, 0x6e, 0x75, 0x6d, 0x62, 0x65, - 0x72, 0x18, 0x04, 0x20, 0x01, 0x28, 0x04, 0x52, 0x0d, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, - 0x4e, 0x75, 0x6d, 0x62, 0x65, 0x72, 0x12, 0x1a, 0x0a, 0x08, 0x73, 0x65, 0x71, 0x75, 0x65, 0x6e, - 0x63, 0x65, 0x18, 0x05, 0x20, 0x01, 0x28, 0x04, 0x52, 0x08, 0x73, 0x65, 0x71, 0x75, 0x65, 0x6e, - 0x63, 0x65, 0x12, 0x2c, 0x0a, 0x03, 0x74, 0x69, 0x70, 0x18, 0x06, 0x20, 0x01, 0x28, 0x0b, 0x32, - 0x16, 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x74, 0x78, 0x2e, 0x76, 0x31, 0x62, 0x65, - 0x74, 0x61, 0x31, 0x2e, 0x54, 0x69, 0x70, 0x42, 0x02, 0x18, 0x01, 0x52, 0x03, 0x74, 0x69, 0x70, - 0x3a, 0x13, 0xd2, 0xb4, 0x2d, 0x0f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2d, 0x73, 0x64, 0x6b, - 0x20, 0x30, 0x2e, 0x34, 0x36, 0x22, 0xb3, 0x02, 0x0a, 0x06, 0x54, 0x78, 0x42, 0x6f, 0x64, 0x79, - 0x12, 0x30, 0x0a, 0x08, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x73, 0x18, 0x01, 0x20, 0x03, - 0x28, 0x0b, 0x32, 0x14, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, - 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x41, 0x6e, 0x79, 0x52, 0x08, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, - 0x65, 0x73, 0x12, 0x12, 0x0a, 0x04, 0x6d, 0x65, 0x6d, 0x6f, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, - 0x52, 0x04, 0x6d, 0x65, 0x6d, 0x6f, 0x12, 0x25, 0x0a, 0x0e, 0x74, 0x69, 0x6d, 0x65, 0x6f, 0x75, - 0x74, 0x5f, 0x68, 0x65, 0x69, 0x67, 0x68, 0x74, 0x18, 0x03, 0x20, 0x01, 0x28, 0x04, 0x52, 0x0d, - 0x74, 0x69, 0x6d, 0x65, 0x6f, 0x75, 0x74, 0x48, 0x65, 0x69, 0x67, 0x68, 0x74, 0x12, 0x1c, 0x0a, - 0x09, 0x75, 0x6e, 0x6f, 0x72, 0x64, 0x65, 0x72, 0x65, 0x64, 0x18, 0x04, 0x20, 0x01, 0x28, 0x08, - 0x52, 0x09, 0x75, 0x6e, 0x6f, 0x72, 0x64, 0x65, 0x72, 0x65, 0x64, 0x12, 0x42, 0x0a, 0x11, 0x65, - 0x78, 0x74, 0x65, 0x6e, 0x73, 0x69, 0x6f, 0x6e, 0x5f, 0x6f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, - 0x18, 0xff, 0x07, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x14, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, - 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x41, 0x6e, 0x79, 0x52, 0x10, 0x65, - 0x78, 0x74, 0x65, 0x6e, 0x73, 0x69, 0x6f, 0x6e, 0x4f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x12, - 0x5a, 0x0a, 0x1e, 0x6e, 0x6f, 0x6e, 0x5f, 0x63, 0x72, 0x69, 0x74, 0x69, 0x63, 0x61, 0x6c, 0x5f, - 0x65, 0x78, 0x74, 0x65, 0x6e, 0x73, 0x69, 0x6f, 0x6e, 0x5f, 0x6f, 0x70, 0x74, 0x69, 0x6f, 0x6e, - 0x73, 0x18, 0xff, 0x0f, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x14, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, - 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x41, 0x6e, 0x79, 0x52, 0x1b, - 0x6e, 0x6f, 0x6e, 0x43, 0x72, 0x69, 0x74, 0x69, 0x63, 0x61, 0x6c, 0x45, 0x78, 0x74, 0x65, 0x6e, - 0x73, 0x69, 0x6f, 0x6e, 0x4f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x22, 0xb7, 0x01, 0x0a, 0x08, - 0x41, 0x75, 0x74, 0x68, 0x49, 0x6e, 0x66, 0x6f, 0x12, 0x40, 0x0a, 0x0c, 0x73, 0x69, 0x67, 0x6e, - 0x65, 0x72, 0x5f, 0x69, 0x6e, 0x66, 0x6f, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x1d, - 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x74, 0x78, 0x2e, 0x76, 0x31, 0x62, 0x65, 0x74, - 0x61, 0x31, 0x2e, 0x53, 0x69, 0x67, 0x6e, 0x65, 0x72, 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x0b, 0x73, - 0x69, 0x67, 0x6e, 0x65, 0x72, 0x49, 0x6e, 0x66, 0x6f, 0x73, 0x12, 0x28, 0x0a, 0x03, 0x66, 0x65, - 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x16, 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, - 0x2e, 0x74, 0x78, 0x2e, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x2e, 0x46, 0x65, 0x65, 0x52, - 0x03, 0x66, 0x65, 0x65, 0x12, 0x3f, 0x0a, 0x03, 0x74, 0x69, 0x70, 0x18, 0x03, 0x20, 0x01, 0x28, - 0x0b, 0x32, 0x16, 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x74, 0x78, 0x2e, 0x76, 0x31, - 0x62, 0x65, 0x74, 0x61, 0x31, 0x2e, 0x54, 0x69, 0x70, 0x42, 0x15, 0x18, 0x01, 0xda, 0xb4, 0x2d, - 0x0f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2d, 0x73, 0x64, 0x6b, 0x20, 0x30, 0x2e, 0x34, 0x36, - 0x52, 0x03, 0x74, 0x69, 0x70, 0x22, 0x97, 0x01, 0x0a, 0x0a, 0x53, 0x69, 0x67, 0x6e, 0x65, 0x72, - 0x49, 0x6e, 0x66, 0x6f, 0x12, 0x33, 0x0a, 0x0a, 0x70, 0x75, 0x62, 0x6c, 0x69, 0x63, 0x5f, 0x6b, - 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x14, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, - 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x41, 0x6e, 0x79, 0x52, 0x09, - 0x70, 0x75, 0x62, 0x6c, 0x69, 0x63, 0x4b, 0x65, 0x79, 0x12, 0x38, 0x0a, 0x09, 0x6d, 0x6f, 0x64, - 0x65, 0x5f, 0x69, 0x6e, 0x66, 0x6f, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1b, 0x2e, 0x63, - 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x74, 0x78, 0x2e, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, - 0x2e, 0x4d, 0x6f, 0x64, 0x65, 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x08, 0x6d, 0x6f, 0x64, 0x65, 0x49, - 0x6e, 0x66, 0x6f, 0x12, 0x1a, 0x0a, 0x08, 0x73, 0x65, 0x71, 0x75, 0x65, 0x6e, 0x63, 0x65, 0x18, - 0x03, 0x20, 0x01, 0x28, 0x04, 0x52, 0x08, 0x73, 0x65, 0x71, 0x75, 0x65, 0x6e, 0x63, 0x65, 0x22, - 0xe0, 0x02, 0x0a, 0x08, 0x4d, 0x6f, 0x64, 0x65, 0x49, 0x6e, 0x66, 0x6f, 0x12, 0x3c, 0x0a, 0x06, - 0x73, 0x69, 0x6e, 0x67, 0x6c, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x22, 0x2e, 0x63, - 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x74, 0x78, 0x2e, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, - 0x2e, 0x4d, 0x6f, 0x64, 0x65, 0x49, 0x6e, 0x66, 0x6f, 0x2e, 0x53, 0x69, 0x6e, 0x67, 0x6c, 0x65, - 0x48, 0x00, 0x52, 0x06, 0x73, 0x69, 0x6e, 0x67, 0x6c, 0x65, 0x12, 0x39, 0x0a, 0x05, 0x6d, 0x75, - 0x6c, 0x74, 0x69, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x21, 0x2e, 0x63, 0x6f, 0x73, 0x6d, - 0x6f, 0x73, 0x2e, 0x74, 0x78, 0x2e, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x2e, 0x4d, 0x6f, - 0x64, 0x65, 0x49, 0x6e, 0x66, 0x6f, 0x2e, 0x4d, 0x75, 0x6c, 0x74, 0x69, 0x48, 0x00, 0x52, 0x05, - 0x6d, 0x75, 0x6c, 0x74, 0x69, 0x1a, 0x41, 0x0a, 0x06, 0x53, 0x69, 0x6e, 0x67, 0x6c, 0x65, 0x12, - 0x37, 0x0a, 0x04, 0x6d, 0x6f, 0x64, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x23, 0x2e, - 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x74, 0x78, 0x2e, 0x73, 0x69, 0x67, 0x6e, 0x69, 0x6e, - 0x67, 0x2e, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x2e, 0x53, 0x69, 0x67, 0x6e, 0x4d, 0x6f, - 0x64, 0x65, 0x52, 0x04, 0x6d, 0x6f, 0x64, 0x65, 0x1a, 0x90, 0x01, 0x0a, 0x05, 0x4d, 0x75, 0x6c, - 0x74, 0x69, 0x12, 0x4b, 0x0a, 0x08, 0x62, 0x69, 0x74, 0x61, 0x72, 0x72, 0x61, 0x79, 0x18, 0x01, - 0x20, 0x01, 0x28, 0x0b, 0x32, 0x2f, 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x63, 0x72, - 0x79, 0x70, 0x74, 0x6f, 0x2e, 0x6d, 0x75, 0x6c, 0x74, 0x69, 0x73, 0x69, 0x67, 0x2e, 0x76, 0x31, - 0x62, 0x65, 0x74, 0x61, 0x31, 0x2e, 0x43, 0x6f, 0x6d, 0x70, 0x61, 0x63, 0x74, 0x42, 0x69, 0x74, - 0x41, 0x72, 0x72, 0x61, 0x79, 0x52, 0x08, 0x62, 0x69, 0x74, 0x61, 0x72, 0x72, 0x61, 0x79, 0x12, - 0x3a, 0x0a, 0x0a, 0x6d, 0x6f, 0x64, 0x65, 0x5f, 0x69, 0x6e, 0x66, 0x6f, 0x73, 0x18, 0x02, 0x20, - 0x03, 0x28, 0x0b, 0x32, 0x1b, 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x74, 0x78, 0x2e, - 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x2e, 0x4d, 0x6f, 0x64, 0x65, 0x49, 0x6e, 0x66, 0x6f, - 0x52, 0x09, 0x6d, 0x6f, 0x64, 0x65, 0x49, 0x6e, 0x66, 0x6f, 0x73, 0x42, 0x05, 0x0a, 0x03, 0x73, - 0x75, 0x6d, 0x22, 0x81, 0x02, 0x0a, 0x03, 0x46, 0x65, 0x65, 0x12, 0x79, 0x0a, 0x06, 0x61, 0x6d, - 0x6f, 0x75, 0x6e, 0x74, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x19, 0x2e, 0x63, 0x6f, 0x73, - 0x6d, 0x6f, 0x73, 0x2e, 0x62, 0x61, 0x73, 0x65, 0x2e, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, - 0x2e, 0x43, 0x6f, 0x69, 0x6e, 0x42, 0x46, 0xc8, 0xde, 0x1f, 0x00, 0xaa, 0xdf, 0x1f, 0x28, 0x67, - 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, - 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2d, 0x73, 0x64, 0x6b, 0x2f, 0x74, 0x79, 0x70, 0x65, - 0x73, 0x2e, 0x43, 0x6f, 0x69, 0x6e, 0x73, 0x9a, 0xe7, 0xb0, 0x2a, 0x0c, 0x6c, 0x65, 0x67, 0x61, - 0x63, 0x79, 0x5f, 0x63, 0x6f, 0x69, 0x6e, 0x73, 0xa8, 0xe7, 0xb0, 0x2a, 0x01, 0x52, 0x06, 0x61, - 0x6d, 0x6f, 0x75, 0x6e, 0x74, 0x12, 0x1b, 0x0a, 0x09, 0x67, 0x61, 0x73, 0x5f, 0x6c, 0x69, 0x6d, - 0x69, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x04, 0x52, 0x08, 0x67, 0x61, 0x73, 0x4c, 0x69, 0x6d, - 0x69, 0x74, 0x12, 0x2e, 0x0a, 0x05, 0x70, 0x61, 0x79, 0x65, 0x72, 0x18, 0x03, 0x20, 0x01, 0x28, - 0x09, 0x42, 0x18, 0xd2, 0xb4, 0x2d, 0x14, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x41, 0x64, - 0x64, 0x72, 0x65, 0x73, 0x73, 0x53, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x52, 0x05, 0x70, 0x61, 0x79, - 0x65, 0x72, 0x12, 0x32, 0x0a, 0x07, 0x67, 0x72, 0x61, 0x6e, 0x74, 0x65, 0x72, 0x18, 0x04, 0x20, - 0x01, 0x28, 0x09, 0x42, 0x18, 0xd2, 0xb4, 0x2d, 0x14, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, - 0x41, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x53, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x52, 0x07, 0x67, - 0x72, 0x61, 0x6e, 0x74, 0x65, 0x72, 0x22, 0xc9, 0x01, 0x0a, 0x03, 0x54, 0x69, 0x70, 0x12, 0x79, + 0x26, 0x0a, 0x0f, 0x61, 0x75, 0x74, 0x68, 0x5f, 0x69, 0x6e, 0x66, 0x6f, 0x5f, 0x62, 0x79, 0x74, + 0x65, 0x73, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x0d, 0x61, 0x75, 0x74, 0x68, 0x49, 0x6e, + 0x66, 0x6f, 0x42, 0x79, 0x74, 0x65, 0x73, 0x12, 0x1e, 0x0a, 0x0a, 0x73, 0x69, 0x67, 0x6e, 0x61, + 0x74, 0x75, 0x72, 0x65, 0x73, 0x18, 0x03, 0x20, 0x03, 0x28, 0x0c, 0x52, 0x0a, 0x73, 0x69, 0x67, + 0x6e, 0x61, 0x74, 0x75, 0x72, 0x65, 0x73, 0x22, 0x92, 0x01, 0x0a, 0x07, 0x53, 0x69, 0x67, 0x6e, + 0x44, 0x6f, 0x63, 0x12, 0x1d, 0x0a, 0x0a, 0x62, 0x6f, 0x64, 0x79, 0x5f, 0x62, 0x79, 0x74, 0x65, + 0x73, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x09, 0x62, 0x6f, 0x64, 0x79, 0x42, 0x79, 0x74, + 0x65, 0x73, 0x12, 0x26, 0x0a, 0x0f, 0x61, 0x75, 0x74, 0x68, 0x5f, 0x69, 0x6e, 0x66, 0x6f, 0x5f, + 0x62, 0x79, 0x74, 0x65, 0x73, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x0d, 0x61, 0x75, 0x74, + 0x68, 0x49, 0x6e, 0x66, 0x6f, 0x42, 0x79, 0x74, 0x65, 0x73, 0x12, 0x19, 0x0a, 0x08, 0x63, 0x68, + 0x61, 0x69, 0x6e, 0x5f, 0x69, 0x64, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x63, 0x68, + 0x61, 0x69, 0x6e, 0x49, 0x64, 0x12, 0x25, 0x0a, 0x0e, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, + 0x5f, 0x6e, 0x75, 0x6d, 0x62, 0x65, 0x72, 0x18, 0x04, 0x20, 0x01, 0x28, 0x04, 0x52, 0x0d, 0x61, + 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x4e, 0x75, 0x6d, 0x62, 0x65, 0x72, 0x22, 0x87, 0x02, 0x0a, + 0x10, 0x53, 0x69, 0x67, 0x6e, 0x44, 0x6f, 0x63, 0x44, 0x69, 0x72, 0x65, 0x63, 0x74, 0x41, 0x75, + 0x78, 0x12, 0x1d, 0x0a, 0x0a, 0x62, 0x6f, 0x64, 0x79, 0x5f, 0x62, 0x79, 0x74, 0x65, 0x73, 0x18, + 0x01, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x09, 0x62, 0x6f, 0x64, 0x79, 0x42, 0x79, 0x74, 0x65, 0x73, + 0x12, 0x33, 0x0a, 0x0a, 0x70, 0x75, 0x62, 0x6c, 0x69, 0x63, 0x5f, 0x6b, 0x65, 0x79, 0x18, 0x02, + 0x20, 0x01, 0x28, 0x0b, 0x32, 0x14, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, + 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x41, 0x6e, 0x79, 0x52, 0x09, 0x70, 0x75, 0x62, 0x6c, + 0x69, 0x63, 0x4b, 0x65, 0x79, 0x12, 0x19, 0x0a, 0x08, 0x63, 0x68, 0x61, 0x69, 0x6e, 0x5f, 0x69, + 0x64, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x63, 0x68, 0x61, 0x69, 0x6e, 0x49, 0x64, + 0x12, 0x25, 0x0a, 0x0e, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x5f, 0x6e, 0x75, 0x6d, 0x62, + 0x65, 0x72, 0x18, 0x04, 0x20, 0x01, 0x28, 0x04, 0x52, 0x0d, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, + 0x74, 0x4e, 0x75, 0x6d, 0x62, 0x65, 0x72, 0x12, 0x1a, 0x0a, 0x08, 0x73, 0x65, 0x71, 0x75, 0x65, + 0x6e, 0x63, 0x65, 0x18, 0x05, 0x20, 0x01, 0x28, 0x04, 0x52, 0x08, 0x73, 0x65, 0x71, 0x75, 0x65, + 0x6e, 0x63, 0x65, 0x12, 0x2c, 0x0a, 0x03, 0x74, 0x69, 0x70, 0x18, 0x06, 0x20, 0x01, 0x28, 0x0b, + 0x32, 0x16, 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x74, 0x78, 0x2e, 0x76, 0x31, 0x62, + 0x65, 0x74, 0x61, 0x31, 0x2e, 0x54, 0x69, 0x70, 0x42, 0x02, 0x18, 0x01, 0x52, 0x03, 0x74, 0x69, + 0x70, 0x3a, 0x13, 0xd2, 0xb4, 0x2d, 0x0f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2d, 0x73, 0x64, + 0x6b, 0x20, 0x30, 0x2e, 0x34, 0x36, 0x22, 0x86, 0x03, 0x0a, 0x06, 0x54, 0x78, 0x42, 0x6f, 0x64, + 0x79, 0x12, 0x30, 0x0a, 0x08, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x73, 0x18, 0x01, 0x20, + 0x03, 0x28, 0x0b, 0x32, 0x14, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, + 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x41, 0x6e, 0x79, 0x52, 0x08, 0x6d, 0x65, 0x73, 0x73, 0x61, + 0x67, 0x65, 0x73, 0x12, 0x12, 0x0a, 0x04, 0x6d, 0x65, 0x6d, 0x6f, 0x18, 0x02, 0x20, 0x01, 0x28, + 0x09, 0x52, 0x04, 0x6d, 0x65, 0x6d, 0x6f, 0x12, 0x25, 0x0a, 0x0e, 0x74, 0x69, 0x6d, 0x65, 0x6f, + 0x75, 0x74, 0x5f, 0x68, 0x65, 0x69, 0x67, 0x68, 0x74, 0x18, 0x03, 0x20, 0x01, 0x28, 0x04, 0x52, + 0x0d, 0x74, 0x69, 0x6d, 0x65, 0x6f, 0x75, 0x74, 0x48, 0x65, 0x69, 0x67, 0x68, 0x74, 0x12, 0x1c, + 0x0a, 0x09, 0x75, 0x6e, 0x6f, 0x72, 0x64, 0x65, 0x72, 0x65, 0x64, 0x18, 0x04, 0x20, 0x01, 0x28, + 0x08, 0x52, 0x09, 0x75, 0x6e, 0x6f, 0x72, 0x64, 0x65, 0x72, 0x65, 0x64, 0x12, 0x51, 0x0a, 0x11, + 0x74, 0x69, 0x6d, 0x65, 0x6f, 0x75, 0x74, 0x5f, 0x74, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, + 0x70, 0x18, 0x05, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, + 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74, + 0x61, 0x6d, 0x70, 0x42, 0x08, 0xc8, 0xde, 0x1f, 0x01, 0x90, 0xdf, 0x1f, 0x01, 0x52, 0x10, 0x74, + 0x69, 0x6d, 0x65, 0x6f, 0x75, 0x74, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x12, + 0x42, 0x0a, 0x11, 0x65, 0x78, 0x74, 0x65, 0x6e, 0x73, 0x69, 0x6f, 0x6e, 0x5f, 0x6f, 0x70, 0x74, + 0x69, 0x6f, 0x6e, 0x73, 0x18, 0xff, 0x07, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x14, 0x2e, 0x67, 0x6f, + 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x41, 0x6e, + 0x79, 0x52, 0x10, 0x65, 0x78, 0x74, 0x65, 0x6e, 0x73, 0x69, 0x6f, 0x6e, 0x4f, 0x70, 0x74, 0x69, + 0x6f, 0x6e, 0x73, 0x12, 0x5a, 0x0a, 0x1e, 0x6e, 0x6f, 0x6e, 0x5f, 0x63, 0x72, 0x69, 0x74, 0x69, + 0x63, 0x61, 0x6c, 0x5f, 0x65, 0x78, 0x74, 0x65, 0x6e, 0x73, 0x69, 0x6f, 0x6e, 0x5f, 0x6f, 0x70, + 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x18, 0xff, 0x0f, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x14, 0x2e, 0x67, + 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x41, + 0x6e, 0x79, 0x52, 0x1b, 0x6e, 0x6f, 0x6e, 0x43, 0x72, 0x69, 0x74, 0x69, 0x63, 0x61, 0x6c, 0x45, + 0x78, 0x74, 0x65, 0x6e, 0x73, 0x69, 0x6f, 0x6e, 0x4f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x22, + 0xb7, 0x01, 0x0a, 0x08, 0x41, 0x75, 0x74, 0x68, 0x49, 0x6e, 0x66, 0x6f, 0x12, 0x40, 0x0a, 0x0c, + 0x73, 0x69, 0x67, 0x6e, 0x65, 0x72, 0x5f, 0x69, 0x6e, 0x66, 0x6f, 0x73, 0x18, 0x01, 0x20, 0x03, + 0x28, 0x0b, 0x32, 0x1d, 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x74, 0x78, 0x2e, 0x76, + 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x2e, 0x53, 0x69, 0x67, 0x6e, 0x65, 0x72, 0x49, 0x6e, 0x66, + 0x6f, 0x52, 0x0b, 0x73, 0x69, 0x67, 0x6e, 0x65, 0x72, 0x49, 0x6e, 0x66, 0x6f, 0x73, 0x12, 0x28, + 0x0a, 0x03, 0x66, 0x65, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x16, 0x2e, 0x63, 0x6f, + 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x74, 0x78, 0x2e, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x2e, + 0x46, 0x65, 0x65, 0x52, 0x03, 0x66, 0x65, 0x65, 0x12, 0x3f, 0x0a, 0x03, 0x74, 0x69, 0x70, 0x18, + 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x16, 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x74, + 0x78, 0x2e, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x2e, 0x54, 0x69, 0x70, 0x42, 0x15, 0x18, + 0x01, 0xda, 0xb4, 0x2d, 0x0f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2d, 0x73, 0x64, 0x6b, 0x20, + 0x30, 0x2e, 0x34, 0x36, 0x52, 0x03, 0x74, 0x69, 0x70, 0x22, 0x97, 0x01, 0x0a, 0x0a, 0x53, 0x69, + 0x67, 0x6e, 0x65, 0x72, 0x49, 0x6e, 0x66, 0x6f, 0x12, 0x33, 0x0a, 0x0a, 0x70, 0x75, 0x62, 0x6c, + 0x69, 0x63, 0x5f, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x14, 0x2e, 0x67, + 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x41, + 0x6e, 0x79, 0x52, 0x09, 0x70, 0x75, 0x62, 0x6c, 0x69, 0x63, 0x4b, 0x65, 0x79, 0x12, 0x38, 0x0a, + 0x09, 0x6d, 0x6f, 0x64, 0x65, 0x5f, 0x69, 0x6e, 0x66, 0x6f, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, + 0x32, 0x1b, 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x74, 0x78, 0x2e, 0x76, 0x31, 0x62, + 0x65, 0x74, 0x61, 0x31, 0x2e, 0x4d, 0x6f, 0x64, 0x65, 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x08, 0x6d, + 0x6f, 0x64, 0x65, 0x49, 0x6e, 0x66, 0x6f, 0x12, 0x1a, 0x0a, 0x08, 0x73, 0x65, 0x71, 0x75, 0x65, + 0x6e, 0x63, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x04, 0x52, 0x08, 0x73, 0x65, 0x71, 0x75, 0x65, + 0x6e, 0x63, 0x65, 0x22, 0xe0, 0x02, 0x0a, 0x08, 0x4d, 0x6f, 0x64, 0x65, 0x49, 0x6e, 0x66, 0x6f, + 0x12, 0x3c, 0x0a, 0x06, 0x73, 0x69, 0x6e, 0x67, 0x6c, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, + 0x32, 0x22, 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x74, 0x78, 0x2e, 0x76, 0x31, 0x62, + 0x65, 0x74, 0x61, 0x31, 0x2e, 0x4d, 0x6f, 0x64, 0x65, 0x49, 0x6e, 0x66, 0x6f, 0x2e, 0x53, 0x69, + 0x6e, 0x67, 0x6c, 0x65, 0x48, 0x00, 0x52, 0x06, 0x73, 0x69, 0x6e, 0x67, 0x6c, 0x65, 0x12, 0x39, + 0x0a, 0x05, 0x6d, 0x75, 0x6c, 0x74, 0x69, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x21, 0x2e, + 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x74, 0x78, 0x2e, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, + 0x31, 0x2e, 0x4d, 0x6f, 0x64, 0x65, 0x49, 0x6e, 0x66, 0x6f, 0x2e, 0x4d, 0x75, 0x6c, 0x74, 0x69, + 0x48, 0x00, 0x52, 0x05, 0x6d, 0x75, 0x6c, 0x74, 0x69, 0x1a, 0x41, 0x0a, 0x06, 0x53, 0x69, 0x6e, + 0x67, 0x6c, 0x65, 0x12, 0x37, 0x0a, 0x04, 0x6d, 0x6f, 0x64, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, + 0x0e, 0x32, 0x23, 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x74, 0x78, 0x2e, 0x73, 0x69, + 0x67, 0x6e, 0x69, 0x6e, 0x67, 0x2e, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x2e, 0x53, 0x69, + 0x67, 0x6e, 0x4d, 0x6f, 0x64, 0x65, 0x52, 0x04, 0x6d, 0x6f, 0x64, 0x65, 0x1a, 0x90, 0x01, 0x0a, + 0x05, 0x4d, 0x75, 0x6c, 0x74, 0x69, 0x12, 0x4b, 0x0a, 0x08, 0x62, 0x69, 0x74, 0x61, 0x72, 0x72, + 0x61, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x2f, 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, + 0x73, 0x2e, 0x63, 0x72, 0x79, 0x70, 0x74, 0x6f, 0x2e, 0x6d, 0x75, 0x6c, 0x74, 0x69, 0x73, 0x69, + 0x67, 0x2e, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x2e, 0x43, 0x6f, 0x6d, 0x70, 0x61, 0x63, + 0x74, 0x42, 0x69, 0x74, 0x41, 0x72, 0x72, 0x61, 0x79, 0x52, 0x08, 0x62, 0x69, 0x74, 0x61, 0x72, + 0x72, 0x61, 0x79, 0x12, 0x3a, 0x0a, 0x0a, 0x6d, 0x6f, 0x64, 0x65, 0x5f, 0x69, 0x6e, 0x66, 0x6f, + 0x73, 0x18, 0x02, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x1b, 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, + 0x2e, 0x74, 0x78, 0x2e, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x2e, 0x4d, 0x6f, 0x64, 0x65, + 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x09, 0x6d, 0x6f, 0x64, 0x65, 0x49, 0x6e, 0x66, 0x6f, 0x73, 0x42, + 0x05, 0x0a, 0x03, 0x73, 0x75, 0x6d, 0x22, 0x81, 0x02, 0x0a, 0x03, 0x46, 0x65, 0x65, 0x12, 0x79, 0x0a, 0x06, 0x61, 0x6d, 0x6f, 0x75, 0x6e, 0x74, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x19, 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x62, 0x61, 0x73, 0x65, 0x2e, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x2e, 0x43, 0x6f, 0x69, 0x6e, 0x42, 0x46, 0xc8, 0xde, 0x1f, 0x00, 0xaa, @@ -9188,38 +9269,54 @@ var file_cosmos_tx_v1beta1_tx_proto_rawDesc = []byte{ 0x73, 0x6d, 0x6f, 0x73, 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2d, 0x73, 0x64, 0x6b, 0x2f, 0x74, 0x79, 0x70, 0x65, 0x73, 0x2e, 0x43, 0x6f, 0x69, 0x6e, 0x73, 0x9a, 0xe7, 0xb0, 0x2a, 0x0c, 0x6c, 0x65, 0x67, 0x61, 0x63, 0x79, 0x5f, 0x63, 0x6f, 0x69, 0x6e, 0x73, 0xa8, 0xe7, 0xb0, 0x2a, - 0x01, 0x52, 0x06, 0x61, 0x6d, 0x6f, 0x75, 0x6e, 0x74, 0x12, 0x30, 0x0a, 0x06, 0x74, 0x69, 0x70, - 0x70, 0x65, 0x72, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x42, 0x18, 0xd2, 0xb4, 0x2d, 0x14, 0x63, - 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x41, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x53, 0x74, 0x72, - 0x69, 0x6e, 0x67, 0x52, 0x06, 0x74, 0x69, 0x70, 0x70, 0x65, 0x72, 0x3a, 0x15, 0x18, 0x01, 0xd2, - 0xb4, 0x2d, 0x0f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2d, 0x73, 0x64, 0x6b, 0x20, 0x30, 0x2e, - 0x34, 0x36, 0x22, 0xe3, 0x01, 0x0a, 0x0d, 0x41, 0x75, 0x78, 0x53, 0x69, 0x67, 0x6e, 0x65, 0x72, - 0x44, 0x61, 0x74, 0x61, 0x12, 0x32, 0x0a, 0x07, 0x61, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x18, - 0x01, 0x20, 0x01, 0x28, 0x09, 0x42, 0x18, 0xd2, 0xb4, 0x2d, 0x14, 0x63, 0x6f, 0x73, 0x6d, 0x6f, + 0x01, 0x52, 0x06, 0x61, 0x6d, 0x6f, 0x75, 0x6e, 0x74, 0x12, 0x1b, 0x0a, 0x09, 0x67, 0x61, 0x73, + 0x5f, 0x6c, 0x69, 0x6d, 0x69, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x04, 0x52, 0x08, 0x67, 0x61, + 0x73, 0x4c, 0x69, 0x6d, 0x69, 0x74, 0x12, 0x2e, 0x0a, 0x05, 0x70, 0x61, 0x79, 0x65, 0x72, 0x18, + 0x03, 0x20, 0x01, 0x28, 0x09, 0x42, 0x18, 0xd2, 0xb4, 0x2d, 0x14, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x41, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x53, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x52, - 0x07, 0x61, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x12, 0x3e, 0x0a, 0x08, 0x73, 0x69, 0x67, 0x6e, - 0x5f, 0x64, 0x6f, 0x63, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x23, 0x2e, 0x63, 0x6f, 0x73, - 0x6d, 0x6f, 0x73, 0x2e, 0x74, 0x78, 0x2e, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x2e, 0x53, - 0x69, 0x67, 0x6e, 0x44, 0x6f, 0x63, 0x44, 0x69, 0x72, 0x65, 0x63, 0x74, 0x41, 0x75, 0x78, 0x52, - 0x07, 0x73, 0x69, 0x67, 0x6e, 0x44, 0x6f, 0x63, 0x12, 0x37, 0x0a, 0x04, 0x6d, 0x6f, 0x64, 0x65, - 0x18, 0x03, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x23, 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, - 0x74, 0x78, 0x2e, 0x73, 0x69, 0x67, 0x6e, 0x69, 0x6e, 0x67, 0x2e, 0x76, 0x31, 0x62, 0x65, 0x74, - 0x61, 0x31, 0x2e, 0x53, 0x69, 0x67, 0x6e, 0x4d, 0x6f, 0x64, 0x65, 0x52, 0x04, 0x6d, 0x6f, 0x64, - 0x65, 0x12, 0x10, 0x0a, 0x03, 0x73, 0x69, 0x67, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x03, - 0x73, 0x69, 0x67, 0x3a, 0x13, 0xd2, 0xb4, 0x2d, 0x0f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2d, - 0x73, 0x64, 0x6b, 0x20, 0x30, 0x2e, 0x34, 0x36, 0x42, 0xb4, 0x01, 0x0a, 0x15, 0x63, 0x6f, 0x6d, + 0x05, 0x70, 0x61, 0x79, 0x65, 0x72, 0x12, 0x32, 0x0a, 0x07, 0x67, 0x72, 0x61, 0x6e, 0x74, 0x65, + 0x72, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x42, 0x18, 0xd2, 0xb4, 0x2d, 0x14, 0x63, 0x6f, 0x73, + 0x6d, 0x6f, 0x73, 0x2e, 0x41, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x53, 0x74, 0x72, 0x69, 0x6e, + 0x67, 0x52, 0x07, 0x67, 0x72, 0x61, 0x6e, 0x74, 0x65, 0x72, 0x22, 0xc9, 0x01, 0x0a, 0x03, 0x54, + 0x69, 0x70, 0x12, 0x79, 0x0a, 0x06, 0x61, 0x6d, 0x6f, 0x75, 0x6e, 0x74, 0x18, 0x01, 0x20, 0x03, + 0x28, 0x0b, 0x32, 0x19, 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x62, 0x61, 0x73, 0x65, + 0x2e, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x2e, 0x43, 0x6f, 0x69, 0x6e, 0x42, 0x46, 0xc8, + 0xde, 0x1f, 0x00, 0xaa, 0xdf, 0x1f, 0x28, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, + 0x6d, 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2d, + 0x73, 0x64, 0x6b, 0x2f, 0x74, 0x79, 0x70, 0x65, 0x73, 0x2e, 0x43, 0x6f, 0x69, 0x6e, 0x73, 0x9a, + 0xe7, 0xb0, 0x2a, 0x0c, 0x6c, 0x65, 0x67, 0x61, 0x63, 0x79, 0x5f, 0x63, 0x6f, 0x69, 0x6e, 0x73, + 0xa8, 0xe7, 0xb0, 0x2a, 0x01, 0x52, 0x06, 0x61, 0x6d, 0x6f, 0x75, 0x6e, 0x74, 0x12, 0x30, 0x0a, + 0x06, 0x74, 0x69, 0x70, 0x70, 0x65, 0x72, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x42, 0x18, 0xd2, + 0xb4, 0x2d, 0x14, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x41, 0x64, 0x64, 0x72, 0x65, 0x73, + 0x73, 0x53, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x52, 0x06, 0x74, 0x69, 0x70, 0x70, 0x65, 0x72, 0x3a, + 0x15, 0x18, 0x01, 0xd2, 0xb4, 0x2d, 0x0f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2d, 0x73, 0x64, + 0x6b, 0x20, 0x30, 0x2e, 0x34, 0x36, 0x22, 0xe3, 0x01, 0x0a, 0x0d, 0x41, 0x75, 0x78, 0x53, 0x69, + 0x67, 0x6e, 0x65, 0x72, 0x44, 0x61, 0x74, 0x61, 0x12, 0x32, 0x0a, 0x07, 0x61, 0x64, 0x64, 0x72, + 0x65, 0x73, 0x73, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x42, 0x18, 0xd2, 0xb4, 0x2d, 0x14, 0x63, + 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x41, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x53, 0x74, 0x72, + 0x69, 0x6e, 0x67, 0x52, 0x07, 0x61, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x12, 0x3e, 0x0a, 0x08, + 0x73, 0x69, 0x67, 0x6e, 0x5f, 0x64, 0x6f, 0x63, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x23, 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x74, 0x78, 0x2e, 0x76, 0x31, 0x62, 0x65, 0x74, - 0x61, 0x31, 0x42, 0x07, 0x54, 0x78, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x2c, 0x63, - 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x73, 0x64, 0x6b, 0x2e, 0x69, 0x6f, 0x2f, 0x61, 0x70, 0x69, 0x2f, - 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2f, 0x74, 0x78, 0x2f, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, - 0x31, 0x3b, 0x74, 0x78, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0xa2, 0x02, 0x03, 0x43, 0x54, - 0x58, 0xaa, 0x02, 0x11, 0x43, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x54, 0x78, 0x2e, 0x56, 0x31, - 0x62, 0x65, 0x74, 0x61, 0x31, 0xca, 0x02, 0x11, 0x43, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x5c, 0x54, - 0x78, 0x5c, 0x56, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0xe2, 0x02, 0x1d, 0x43, 0x6f, 0x73, 0x6d, - 0x6f, 0x73, 0x5c, 0x54, 0x78, 0x5c, 0x56, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x5c, 0x47, 0x50, - 0x42, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0xea, 0x02, 0x13, 0x43, 0x6f, 0x73, 0x6d, - 0x6f, 0x73, 0x3a, 0x3a, 0x54, 0x78, 0x3a, 0x3a, 0x56, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x62, - 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x61, 0x31, 0x2e, 0x53, 0x69, 0x67, 0x6e, 0x44, 0x6f, 0x63, 0x44, 0x69, 0x72, 0x65, 0x63, 0x74, + 0x41, 0x75, 0x78, 0x52, 0x07, 0x73, 0x69, 0x67, 0x6e, 0x44, 0x6f, 0x63, 0x12, 0x37, 0x0a, 0x04, + 0x6d, 0x6f, 0x64, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x23, 0x2e, 0x63, 0x6f, 0x73, + 0x6d, 0x6f, 0x73, 0x2e, 0x74, 0x78, 0x2e, 0x73, 0x69, 0x67, 0x6e, 0x69, 0x6e, 0x67, 0x2e, 0x76, + 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x2e, 0x53, 0x69, 0x67, 0x6e, 0x4d, 0x6f, 0x64, 0x65, 0x52, + 0x04, 0x6d, 0x6f, 0x64, 0x65, 0x12, 0x10, 0x0a, 0x03, 0x73, 0x69, 0x67, 0x18, 0x04, 0x20, 0x01, + 0x28, 0x0c, 0x52, 0x03, 0x73, 0x69, 0x67, 0x3a, 0x13, 0xd2, 0xb4, 0x2d, 0x0f, 0x63, 0x6f, 0x73, + 0x6d, 0x6f, 0x73, 0x2d, 0x73, 0x64, 0x6b, 0x20, 0x30, 0x2e, 0x34, 0x36, 0x42, 0xb4, 0x01, 0x0a, + 0x15, 0x63, 0x6f, 0x6d, 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x74, 0x78, 0x2e, 0x76, + 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x42, 0x07, 0x54, 0x78, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, + 0x01, 0x5a, 0x2c, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x73, 0x64, 0x6b, 0x2e, 0x69, 0x6f, 0x2f, + 0x61, 0x70, 0x69, 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2f, 0x74, 0x78, 0x2f, 0x76, 0x31, + 0x62, 0x65, 0x74, 0x61, 0x31, 0x3b, 0x74, 0x78, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0xa2, + 0x02, 0x03, 0x43, 0x54, 0x58, 0xaa, 0x02, 0x11, 0x43, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x54, + 0x78, 0x2e, 0x56, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0xca, 0x02, 0x11, 0x43, 0x6f, 0x73, 0x6d, + 0x6f, 0x73, 0x5c, 0x54, 0x78, 0x5c, 0x56, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0xe2, 0x02, 0x1d, + 0x43, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x5c, 0x54, 0x78, 0x5c, 0x56, 0x31, 0x62, 0x65, 0x74, 0x61, + 0x31, 0x5c, 0x47, 0x50, 0x42, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0xea, 0x02, 0x13, + 0x43, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x3a, 0x3a, 0x54, 0x78, 0x3a, 0x3a, 0x56, 0x31, 0x62, 0x65, + 0x74, 0x61, 0x31, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( @@ -9250,9 +9347,10 @@ var file_cosmos_tx_v1beta1_tx_proto_goTypes = []interface{}{ (*ModeInfo_Single)(nil), // 11: cosmos.tx.v1beta1.ModeInfo.Single (*ModeInfo_Multi)(nil), // 12: cosmos.tx.v1beta1.ModeInfo.Multi (*anypb.Any)(nil), // 13: google.protobuf.Any - (*v1beta12.Coin)(nil), // 14: cosmos.base.v1beta1.Coin - (v1beta1.SignMode)(0), // 15: cosmos.tx.signing.v1beta1.SignMode - (*v1beta11.CompactBitArray)(nil), // 16: cosmos.crypto.multisig.v1beta1.CompactBitArray + (*timestamppb.Timestamp)(nil), // 14: google.protobuf.Timestamp + (*v1beta12.Coin)(nil), // 15: cosmos.base.v1beta1.Coin + (v1beta1.SignMode)(0), // 16: cosmos.tx.signing.v1beta1.SignMode + (*v1beta11.CompactBitArray)(nil), // 17: cosmos.crypto.multisig.v1beta1.CompactBitArray } var file_cosmos_tx_v1beta1_tx_proto_depIdxs = []int32{ 4, // 0: cosmos.tx.v1beta1.Tx.body:type_name -> cosmos.tx.v1beta1.TxBody @@ -9260,27 +9358,28 @@ var file_cosmos_tx_v1beta1_tx_proto_depIdxs = []int32{ 13, // 2: cosmos.tx.v1beta1.SignDocDirectAux.public_key:type_name -> google.protobuf.Any 9, // 3: cosmos.tx.v1beta1.SignDocDirectAux.tip:type_name -> cosmos.tx.v1beta1.Tip 13, // 4: cosmos.tx.v1beta1.TxBody.messages:type_name -> google.protobuf.Any - 13, // 5: cosmos.tx.v1beta1.TxBody.extension_options:type_name -> google.protobuf.Any - 13, // 6: cosmos.tx.v1beta1.TxBody.non_critical_extension_options:type_name -> google.protobuf.Any - 6, // 7: cosmos.tx.v1beta1.AuthInfo.signer_infos:type_name -> cosmos.tx.v1beta1.SignerInfo - 8, // 8: cosmos.tx.v1beta1.AuthInfo.fee:type_name -> cosmos.tx.v1beta1.Fee - 9, // 9: cosmos.tx.v1beta1.AuthInfo.tip:type_name -> cosmos.tx.v1beta1.Tip - 13, // 10: cosmos.tx.v1beta1.SignerInfo.public_key:type_name -> google.protobuf.Any - 7, // 11: cosmos.tx.v1beta1.SignerInfo.mode_info:type_name -> cosmos.tx.v1beta1.ModeInfo - 11, // 12: cosmos.tx.v1beta1.ModeInfo.single:type_name -> cosmos.tx.v1beta1.ModeInfo.Single - 12, // 13: cosmos.tx.v1beta1.ModeInfo.multi:type_name -> cosmos.tx.v1beta1.ModeInfo.Multi - 14, // 14: cosmos.tx.v1beta1.Fee.amount:type_name -> cosmos.base.v1beta1.Coin - 14, // 15: cosmos.tx.v1beta1.Tip.amount:type_name -> cosmos.base.v1beta1.Coin - 3, // 16: cosmos.tx.v1beta1.AuxSignerData.sign_doc:type_name -> cosmos.tx.v1beta1.SignDocDirectAux - 15, // 17: cosmos.tx.v1beta1.AuxSignerData.mode:type_name -> cosmos.tx.signing.v1beta1.SignMode - 15, // 18: cosmos.tx.v1beta1.ModeInfo.Single.mode:type_name -> cosmos.tx.signing.v1beta1.SignMode - 16, // 19: cosmos.tx.v1beta1.ModeInfo.Multi.bitarray:type_name -> cosmos.crypto.multisig.v1beta1.CompactBitArray - 7, // 20: cosmos.tx.v1beta1.ModeInfo.Multi.mode_infos:type_name -> cosmos.tx.v1beta1.ModeInfo - 21, // [21:21] is the sub-list for method output_type - 21, // [21:21] is the sub-list for method input_type - 21, // [21:21] is the sub-list for extension type_name - 21, // [21:21] is the sub-list for extension extendee - 0, // [0:21] is the sub-list for field type_name + 14, // 5: cosmos.tx.v1beta1.TxBody.timeout_timestamp:type_name -> google.protobuf.Timestamp + 13, // 6: cosmos.tx.v1beta1.TxBody.extension_options:type_name -> google.protobuf.Any + 13, // 7: cosmos.tx.v1beta1.TxBody.non_critical_extension_options:type_name -> google.protobuf.Any + 6, // 8: cosmos.tx.v1beta1.AuthInfo.signer_infos:type_name -> cosmos.tx.v1beta1.SignerInfo + 8, // 9: cosmos.tx.v1beta1.AuthInfo.fee:type_name -> cosmos.tx.v1beta1.Fee + 9, // 10: cosmos.tx.v1beta1.AuthInfo.tip:type_name -> cosmos.tx.v1beta1.Tip + 13, // 11: cosmos.tx.v1beta1.SignerInfo.public_key:type_name -> google.protobuf.Any + 7, // 12: cosmos.tx.v1beta1.SignerInfo.mode_info:type_name -> cosmos.tx.v1beta1.ModeInfo + 11, // 13: cosmos.tx.v1beta1.ModeInfo.single:type_name -> cosmos.tx.v1beta1.ModeInfo.Single + 12, // 14: cosmos.tx.v1beta1.ModeInfo.multi:type_name -> cosmos.tx.v1beta1.ModeInfo.Multi + 15, // 15: cosmos.tx.v1beta1.Fee.amount:type_name -> cosmos.base.v1beta1.Coin + 15, // 16: cosmos.tx.v1beta1.Tip.amount:type_name -> cosmos.base.v1beta1.Coin + 3, // 17: cosmos.tx.v1beta1.AuxSignerData.sign_doc:type_name -> cosmos.tx.v1beta1.SignDocDirectAux + 16, // 18: cosmos.tx.v1beta1.AuxSignerData.mode:type_name -> cosmos.tx.signing.v1beta1.SignMode + 16, // 19: cosmos.tx.v1beta1.ModeInfo.Single.mode:type_name -> cosmos.tx.signing.v1beta1.SignMode + 17, // 20: cosmos.tx.v1beta1.ModeInfo.Multi.bitarray:type_name -> cosmos.crypto.multisig.v1beta1.CompactBitArray + 7, // 21: cosmos.tx.v1beta1.ModeInfo.Multi.mode_infos:type_name -> cosmos.tx.v1beta1.ModeInfo + 22, // [22:22] is the sub-list for method output_type + 22, // [22:22] is the sub-list for method input_type + 22, // [22:22] is the sub-list for extension type_name + 22, // [22:22] is the sub-list for extension extendee + 0, // [0:22] is the sub-list for field type_name } func init() { file_cosmos_tx_v1beta1_tx_proto_init() } diff --git a/baseapp/abci_test.go b/baseapp/abci_test.go index 7e08aabfba05..f455fd5692a0 100644 --- a/baseapp/abci_test.go +++ b/baseapp/abci_test.go @@ -24,6 +24,7 @@ import ( "github.com/cosmos/gogoproto/jsonpb" "github.com/cosmos/gogoproto/proto" gogotypes "github.com/cosmos/gogoproto/types" + any "github.com/cosmos/gogoproto/types/any" "github.com/golang/mock/gomock" "github.com/stretchr/testify/require" @@ -38,6 +39,7 @@ import ( "github.com/cosmos/cosmos-sdk/baseapp" baseapptestutil "github.com/cosmos/cosmos-sdk/baseapp/testutil" "github.com/cosmos/cosmos-sdk/baseapp/testutil/mock" + "github.com/cosmos/cosmos-sdk/codec" cryptocodec "github.com/cosmos/cosmos-sdk/crypto/codec" "github.com/cosmos/cosmos-sdk/testutil" "github.com/cosmos/cosmos-sdk/testutil/testdata" @@ -760,6 +762,240 @@ func TestABCI_FinalizeBlock_MultiMsg(t *testing.T) { require.Equal(t, int64(2), msgCounter2) } +func anyMessage(t *testing.T, cdc codec.Codec, msg *baseapptestutil.MsgSend) *any.Any { + t.Helper() + b, err := cdc.Marshal(msg) + require.NoError(t, err) + return &any.Any{ + TypeUrl: sdk.MsgTypeURL(msg), + Value: b, + } +} + +func TestABCI_Query_SimulateNestedMessagesTx(t *testing.T) { + anteOpt := func(bapp *baseapp.BaseApp) { + bapp.SetAnteHandler(func(ctx sdk.Context, tx sdk.Tx, simulate bool) (newCtx sdk.Context, err error) { + newCtx = ctx.WithGasMeter(storetypes.NewGasMeter(uint64(15))) + return + }) + } + suite := NewBaseAppSuite(t, anteOpt) + + _, err := suite.baseApp.InitChain(&abci.InitChainRequest{ + ConsensusParams: &cmtproto.ConsensusParams{}, + }) + require.NoError(t, err) + + baseapptestutil.RegisterNestedMessagesServer(suite.baseApp.MsgServiceRouter(), NestedMessgesServerImpl{}) + baseapptestutil.RegisterSendServer(suite.baseApp.MsgServiceRouter(), SendServerImpl{}) + + _, _, addr := testdata.KeyTestPubAddr() + _, _, toAddr := testdata.KeyTestPubAddr() + tests := []struct { + name string + message sdk.Msg + wantErr bool + }{ + { + name: "ok nested message", + message: &baseapptestutil.MsgSend{ + From: addr.String(), + To: toAddr.String(), + Amount: "10000stake", + }, + }, + { + name: "different signers", + message: &baseapptestutil.MsgSend{ + From: toAddr.String(), + To: addr.String(), + Amount: "10000stake", + }, + wantErr: true, + }, + { + name: "empty from", + message: &baseapptestutil.MsgSend{ + From: "", + To: toAddr.String(), + Amount: "10000stake", + }, + wantErr: true, + }, + { + name: "empty to", + message: &baseapptestutil.MsgSend{ + From: addr.String(), + To: "", + Amount: "10000stake", + }, + wantErr: true, + }, + { + name: "negative amount", + message: &baseapptestutil.MsgSend{ + From: addr.String(), + To: toAddr.String(), + Amount: "-10000stake", + }, + wantErr: true, + }, + { + name: "with nested messages", + message: &baseapptestutil.MsgNestedMessages{ + Signer: addr.String(), + Messages: []*any.Any{ + anyMessage(t, suite.cdc, &baseapptestutil.MsgSend{ + From: addr.String(), + To: toAddr.String(), + Amount: "10000stake", + }), + }, + }, + }, + { + name: "with invalid nested messages", + message: &baseapptestutil.MsgNestedMessages{ + Signer: addr.String(), + Messages: []*any.Any{ + anyMessage(t, suite.cdc, &baseapptestutil.MsgSend{ + From: "", + To: toAddr.String(), + Amount: "10000stake", + }), + }, + }, + wantErr: true, + }, + { + name: "with different signer ", + message: &baseapptestutil.MsgNestedMessages{ + Signer: addr.String(), + Messages: []*any.Any{ + anyMessage(t, suite.cdc, &baseapptestutil.MsgSend{ + From: toAddr.String(), + To: addr.String(), + Amount: "10000stake", + }), + }, + }, + wantErr: true, + }, + } + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + nestedMessages := make([]*any.Any, 1) + b, err := suite.cdc.Marshal(tt.message) + require.NoError(t, err) + nestedMessages[0] = &any.Any{ + TypeUrl: sdk.MsgTypeURL(tt.message), + Value: b, + } + + msg := &baseapptestutil.MsgNestedMessages{ + Messages: nestedMessages, + Signer: addr.String(), + } + + builder := suite.txConfig.NewTxBuilder() + err = builder.SetMsgs(msg) + require.NoError(t, err) + setTxSignature(t, builder, 0) + tx := builder.GetTx() + + txBytes, err := suite.txConfig.TxEncoder()(tx) + require.Nil(t, err) + + _, result, err := suite.baseApp.Simulate(txBytes) + if tt.wantErr { + require.Error(t, err) + require.Nil(t, result) + } else { + require.NoError(t, err) + require.NotNil(t, result) + } + }) + } +} + +func TestABCI_Query_SimulateNestedMessagesGas(t *testing.T) { + anteOpt := func(bapp *baseapp.BaseApp) { + bapp.SetAnteHandler(func(ctx sdk.Context, tx sdk.Tx, simulate bool) (newCtx sdk.Context, err error) { + newCtx = ctx.WithGasMeter(storetypes.NewGasMeter(uint64(10))) + return + }) + } + + _, _, addr := testdata.KeyTestPubAddr() + _, _, toAddr := testdata.KeyTestPubAddr() + + tests := []struct { + name string + suite *BaseAppSuite + message sdk.Msg + consumedGas uint64 + }{ + { + name: "don't add gas", + suite: NewBaseAppSuite(t, anteOpt), + message: &baseapptestutil.MsgSend{ + From: addr.String(), + To: toAddr.String(), + Amount: "10000stake", + }, + consumedGas: 5, + }, + { + name: "add gas", + suite: NewBaseAppSuite(t, anteOpt, baseapp.SetIncludeNestedMsgsGas([]sdk.Msg{&baseapptestutil.MsgNestedMessages{}})), + message: &baseapptestutil.MsgSend{ + From: addr.String(), + To: toAddr.String(), + Amount: "10000stake", + }, + consumedGas: 10, + }, + } + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + _, err := tt.suite.baseApp.InitChain(&abci.InitChainRequest{ + ConsensusParams: &cmtproto.ConsensusParams{}, + }) + require.NoError(t, err) + + baseapptestutil.RegisterNestedMessagesServer(tt.suite.baseApp.MsgServiceRouter(), NestedMessgesServerImpl{}) + baseapptestutil.RegisterSendServer(tt.suite.baseApp.MsgServiceRouter(), SendServerImpl{}) + + nestedMessages := make([]*any.Any, 1) + b, err := tt.suite.cdc.Marshal(tt.message) + require.NoError(t, err) + nestedMessages[0] = &any.Any{ + TypeUrl: sdk.MsgTypeURL(tt.message), + Value: b, + } + + msg := &baseapptestutil.MsgNestedMessages{ + Messages: nestedMessages, + Signer: addr.String(), + } + + builder := tt.suite.txConfig.NewTxBuilder() + err = builder.SetMsgs(msg) + require.NoError(t, err) + setTxSignature(t, builder, 0) + tx := builder.GetTx() + + txBytes, err := tt.suite.txConfig.TxEncoder()(tx) + require.Nil(t, err) + + gas, result, err := tt.suite.baseApp.Simulate(txBytes) + require.NoError(t, err) + require.NotNil(t, result) + require.True(t, gas.GasUsed == tt.consumedGas) + }) + } +} + func TestABCI_Query_SimulateTx(t *testing.T) { gasConsumed := uint64(5) anteOpt := func(bapp *baseapp.BaseApp) { @@ -1597,19 +1833,29 @@ func TestABCI_PrepareProposal_ReachedMaxBytes(t *testing.T) { }) require.NoError(t, err) + expectedTxs := 8 + var expectedTxBytes int64 + for i := 0; i < 100; i++ { tx2 := newTxCounter(t, suite.txConfig, int64(i), int64(i)) err := pool.Insert(sdk.Context{}, tx2) require.NoError(t, err) + + txBz, err := suite.txConfig.TxEncoder()(tx2) + require.NoError(t, err) + txDataSize := int(cmttypes.ComputeProtoSizeForTxs([]cmttypes.Tx{txBz})) + if i < expectedTxs { + expectedTxBytes += int64(txDataSize) + } } reqPrepareProposal := abci.PrepareProposalRequest{ - MaxTxBytes: 1500, + MaxTxBytes: expectedTxBytes, Height: 1, } resPrepareProposal, err := suite.baseApp.PrepareProposal(&reqPrepareProposal) require.NoError(t, err) - require.Equal(t, 8, len(resPrepareProposal.Txs)) + require.Equal(t, expectedTxs, len(resPrepareProposal.Txs)) } func TestABCI_PrepareProposal_BadEncoding(t *testing.T) { diff --git a/baseapp/abci_utils_test.go b/baseapp/abci_utils_test.go index 25d4c4073c89..7e1c566faf94 100644 --- a/baseapp/abci_utils_test.go +++ b/baseapp/abci_utils_test.go @@ -496,10 +496,10 @@ func (s *ABCIUtilsTestSuite) TestDefaultProposalHandler_NoOpMempoolTxSelection() tx := builder.GetTx() txBz, err := txConfig.TxEncoder()(tx) s.Require().NoError(err) - s.Require().Len(txBz, 152) + s.Require().Len(txBz, 165) txDataSize := int(cmttypes.ComputeProtoSizeForTxs([]cmttypes.Tx{txBz})) - s.Require().Equal(txDataSize, 155) + s.Require().Equal(txDataSize, 168) testCases := map[string]struct { ctx sdk.Context @@ -532,15 +532,15 @@ func (s *ABCIUtilsTestSuite) TestDefaultProposalHandler_NoOpMempoolTxSelection() Txs: [][]byte{txBz, txBz, txBz, txBz, txBz}, MaxTxBytes: 465, }, - expectedTxs: 3, + expectedTxs: 2, }, "large max tx bytes len calculation": { ctx: s.ctx, req: &abci.PrepareProposalRequest{ Txs: [][]byte{txBz, txBz, txBz, txBz, txBz}, - MaxTxBytes: 456, + MaxTxBytes: 504, }, - expectedTxs: 2, + expectedTxs: 3, }, "max gas and tx bytes": { ctx: s.ctx.WithConsensusParams(cmtproto.ConsensusParams{ @@ -619,15 +619,15 @@ func (s *ABCIUtilsTestSuite) TestDefaultProposalHandler_PriorityNonceMempoolTxSe testTxs[i].size = int(cmttypes.ComputeProtoSizeForTxs([]cmttypes.Tx{bz})) } - s.Require().Equal(180, testTxs[0].size) - s.Require().Equal(190, testTxs[1].size) - s.Require().Equal(181, testTxs[2].size) - s.Require().Equal(181, testTxs[3].size) - s.Require().Equal(263, testTxs[4].size) - s.Require().Equal(273, testTxs[5].size) - s.Require().Equal(264, testTxs[6].size) - s.Require().Equal(264, testTxs[7].size) - s.Require().Equal(264, testTxs[8].size) + s.Require().Equal(193, testTxs[0].size) + s.Require().Equal(203, testTxs[1].size) + s.Require().Equal(194, testTxs[2].size) + s.Require().Equal(194, testTxs[3].size) + s.Require().Equal(276, testTxs[4].size) + s.Require().Equal(286, testTxs[5].size) + s.Require().Equal(277, testTxs[6].size) + s.Require().Equal(277, testTxs[7].size) + s.Require().Equal(277, testTxs[8].size) testCases := map[string]struct { ctx sdk.Context @@ -640,7 +640,7 @@ func (s *ABCIUtilsTestSuite) TestDefaultProposalHandler_PriorityNonceMempoolTxSe ctx: s.ctx, txInputs: []testTx{testTxs[0], testTxs[1], testTxs[2], testTxs[3]}, req: &abci.PrepareProposalRequest{ - MaxTxBytes: 180 + 181, + MaxTxBytes: 193 + 194, }, expectedTxs: []int{0, 3}, }, @@ -648,7 +648,7 @@ func (s *ABCIUtilsTestSuite) TestDefaultProposalHandler_PriorityNonceMempoolTxSe ctx: s.ctx, txInputs: []testTx{testTxs[4], testTxs[5], testTxs[6], testTxs[7], testTxs[8]}, req: &abci.PrepareProposalRequest{ - MaxTxBytes: 263 + 264, + MaxTxBytes: 276 + 277, }, expectedTxs: []int{4, 8}, }, @@ -657,7 +657,7 @@ func (s *ABCIUtilsTestSuite) TestDefaultProposalHandler_PriorityNonceMempoolTxSe ctx: s.ctx, txInputs: []testTx{testTxs[9], testTxs[10], testTxs[11]}, req: &abci.PrepareProposalRequest{ - MaxTxBytes: 263 + 264, + MaxTxBytes: 276 + 277, }, expectedTxs: []int{9}, }, diff --git a/baseapp/baseapp.go b/baseapp/baseapp.go index d23207c667c2..e193bd86d310 100644 --- a/baseapp/baseapp.go +++ b/baseapp/baseapp.go @@ -18,9 +18,8 @@ import ( "google.golang.org/protobuf/reflect/protoreflect" "cosmossdk.io/core/header" - "cosmossdk.io/core/log" errorsmod "cosmossdk.io/errors" - sdklog "cosmossdk.io/log" + "cosmossdk.io/log" "cosmossdk.io/store" storemetrics "cosmossdk.io/store/metrics" "cosmossdk.io/store/snapshots" @@ -186,6 +185,9 @@ type BaseApp struct { // including the goroutine handling.This is experimental and must be enabled // by developers. optimisticExec *oe.OptimisticExecution + + // includeNestedMsgsGas holds a set of message types for which gas costs for its nested messages are calculated. + includeNestedMsgsGas map[string]struct{} } // NewBaseApp returns a reference to an initialized BaseApp. It accepts a @@ -198,7 +200,7 @@ func NewBaseApp( logger: logger.With(log.ModuleKey, "baseapp"), name: name, db: db, - cms: store.NewCommitMultiStore(db, sdklog.LogWrapper{Logger: logger}, storemetrics.NewNoOpMetrics()), // by default we use a no-op metric gather in store + cms: store.NewCommitMultiStore(db, logger, storemetrics.NewNoOpMetrics()), // by default we use a no-op metric gather in store storeLoader: DefaultStoreLoader, grpcQueryRouter: NewGRPCQueryRouter(), msgServiceRouter: NewMsgServiceRouter(), @@ -233,7 +235,9 @@ func NewBaseApp( if app.interBlockCache != nil { app.cms.SetInterBlockCache(app.interBlockCache) } - + if app.includeNestedMsgsGas == nil { + app.includeNestedMsgsGas = make(map[string]struct{}) + } app.runTxRecoveryMiddleware = newDefaultRecoveryMiddleware() // Initialize with an empty interface registry to avoid nil pointer dereference. @@ -811,6 +815,10 @@ func (app *BaseApp) endBlock(_ context.Context) (sdk.EndBlock, error) { return endblock, nil } +type HasNestedMsgs interface { + GetMsgs() ([]sdk.Msg, error) +} + // runTx processes a transaction within a given execution mode, encoded transaction // bytes, and the decoded transaction itself. All state transitions occur through // a cached Context depending on the mode provided. State only gets persisted @@ -955,6 +963,15 @@ func (app *BaseApp) runTx(mode execMode, txBytes []byte) (gInfo sdk.GasInfo, res result, err = app.runMsgs(runMsgCtx, msgs, reflectMsgs, mode) } + if mode == execModeSimulate { + for _, msg := range msgs { + nestedErr := app.simulateNestedMessages(ctx, msg) + if nestedErr != nil { + return gInfo, nil, anteEvents, nestedErr + } + } + } + // Run optional postHandlers (should run regardless of the execution result). // // Note: If the postHandler fails, we also revert the runMsgs state. @@ -1061,6 +1078,49 @@ func (app *BaseApp) runMsgs(ctx sdk.Context, msgs []sdk.Msg, reflectMsgs []proto }, nil } +// simulateNestedMessages simulates a message nested messages. +func (app *BaseApp) simulateNestedMessages(ctx sdk.Context, msg sdk.Msg) error { + nestedMsgs, ok := msg.(HasNestedMsgs) + if !ok { + return nil + } + + msgs, err := nestedMsgs.GetMsgs() + if err != nil { + return err + } + + if err := validateBasicTxMsgs(app.msgServiceRouter, msgs); err != nil { + return err + } + + for _, msg := range msgs { + err = app.simulateNestedMessages(ctx, msg) + if err != nil { + return err + } + } + + protoMessages := make([]protoreflect.Message, len(msgs)) + for i, msg := range msgs { + _, protoMsg, err := app.cdc.GetMsgSigners(msg) + if err != nil { + return err + } + protoMessages[i] = protoMsg + } + + initialGas := ctx.GasMeter().GasConsumed() + _, err = app.runMsgs(ctx, msgs, protoMessages, execModeSimulate) + if err == nil { + if _, includeGas := app.includeNestedMsgsGas[sdk.MsgTypeURL(msg)]; !includeGas { + consumedGas := ctx.GasMeter().GasConsumed() - initialGas + ctx.GasMeter().RefundGas(consumedGas, "simulation of nested messages") + } + } + return err +} + // makeABCIData generates the Data field to be sent to ABCI Check/DeliverTx. func makeABCIData(msgResponses []*codectypes.Any) ([]byte, error) { return proto.Marshal(&sdk.TxMsgData{MsgResponses: msgResponses}) diff --git a/baseapp/grpcrouter_helpers.go b/baseapp/grpcrouter_helpers.go index e629be06cb63..907cef764a86 100644 --- a/baseapp/grpcrouter_helpers.go +++ b/baseapp/grpcrouter_helpers.go @@ -2,6 +2,7 @@ package baseapp import ( gocontext "context" + "errors" "fmt" abci "github.com/cometbft/cometbft/api/cometbft/abci/v1" @@ -60,5 +61,5 @@ func (q *QueryServiceTestHelper) Invoke(_ gocontext.Context, method string, args // NewStream implements the grpc ClientConn.NewStream method func (q *QueryServiceTestHelper) NewStream(gocontext.Context, *grpc.StreamDesc, string, ...grpc.CallOption) (grpc.ClientStream, error) { - return nil, fmt.Errorf("not supported") + return nil, errors.New("not supported") } diff --git a/baseapp/oe/optimistic_execution.go b/baseapp/oe/optimistic_execution.go index e5820aa0022e..1c4a83825f3c 100644 --- a/baseapp/oe/optimistic_execution.go +++ b/baseapp/oe/optimistic_execution.go @@ -10,7 +10,7 @@ import ( abci "github.com/cometbft/cometbft/api/cometbft/abci/v1" - "cosmossdk.io/core/log" + "cosmossdk.io/log" ) // FinalizeBlockFunc is the function that is called by the OE to finalize the diff --git a/baseapp/oe/optimistic_execution_test.go b/baseapp/oe/optimistic_execution_test.go index 4afb16aaa795..29643f4ee102 100644 --- a/baseapp/oe/optimistic_execution_test.go +++ b/baseapp/oe/optimistic_execution_test.go @@ -8,7 +8,7 @@ import ( abci "github.com/cometbft/cometbft/api/cometbft/abci/v1" "github.com/stretchr/testify/assert" - coretesting "cosmossdk.io/core/testing" + "cosmossdk.io/log" ) func testFinalizeBlock(_ context.Context, _ *abci.FinalizeBlockRequest) (*abci.FinalizeBlockResponse, error) { @@ -16,7 +16,7 @@ func testFinalizeBlock(_ context.Context, _ *abci.FinalizeBlockRequest) (*abci.F } func TestOptimisticExecution(t *testing.T) { - oe := NewOptimisticExecution(coretesting.NewNopLogger(), testFinalizeBlock) + oe := NewOptimisticExecution(log.NewNopLogger(), testFinalizeBlock) assert.True(t, oe.Enabled()) oe.Execute(&abci.ProcessProposalRequest{ Hash: []byte("test"), diff --git a/baseapp/options.go b/baseapp/options.go index 372c2411cf82..bcff418fb8b0 100644 --- a/baseapp/options.go +++ b/baseapp/options.go @@ -119,6 +119,19 @@ func SetOptimisticExecution(opts ...func(*oe.OptimisticExecution)) func(*BaseApp } } +// SetIncludeNestedMsgsGas sets the message types for which gas costs for its nested messages are calculated when simulating. +func SetIncludeNestedMsgsGas(msgs []sdk.Msg) func(*BaseApp) { + return func(app *BaseApp) { + app.includeNestedMsgsGas = make(map[string]struct{}) + for _, msg := range msgs { + if _, ok := msg.(HasNestedMsgs); !ok { + continue + } + app.includeNestedMsgsGas[sdk.MsgTypeURL(msg)] = struct{}{} + } + } +} + func (app *BaseApp) SetName(name string) { if app.sealed { panic("SetName() on sealed BaseApp") diff --git a/baseapp/testutil/messages.go b/baseapp/testutil/messages.go index a4b1cd9abbcb..1bc8a8bd920f 100644 --- a/baseapp/testutil/messages.go +++ b/baseapp/testutil/messages.go @@ -3,6 +3,7 @@ package testutil import ( errorsmod "cosmossdk.io/errors" + codectestutil "github.com/cosmos/cosmos-sdk/codec/testutil" "github.com/cosmos/cosmos-sdk/codec/types" "github.com/cosmos/cosmos-sdk/crypto/codec" sdk "github.com/cosmos/cosmos-sdk/types" @@ -16,10 +17,15 @@ func RegisterInterfaces(registry types.InterfaceRegistry) { &MsgCounter{}, &MsgCounter2{}, &MsgKeyValue{}, + &MsgNestedMessages{}, + &MsgSend{}, ) + msgservice.RegisterMsgServiceDesc(registry, &_Counter_serviceDesc) msgservice.RegisterMsgServiceDesc(registry, &_Counter2_serviceDesc) msgservice.RegisterMsgServiceDesc(registry, &_KeyValue_serviceDesc) + msgservice.RegisterMsgServiceDesc(registry, &_NestedMessages_serviceDesc) + msgservice.RegisterMsgServiceDesc(registry, &_Send_serviceDesc) codec.RegisterInterfaces(registry) } @@ -63,3 +69,21 @@ func (msg *MsgKeyValue) ValidateBasic() error { } return nil } + +func (msg *MsgNestedMessages) GetMsgs() ([]sdk.Msg, error) { + cdc := codectestutil.CodecOptions{}.NewCodec() + RegisterInterfaces(cdc.InterfaceRegistry()) + msgs := make([]sdk.Msg, len(msg.GetMessages())) + for i, m := range msg.GetMessages() { + mm, err := cdc.InterfaceRegistry().Resolve(m.TypeUrl) + if err != nil { + return nil, err + } + err = cdc.UnpackAny(m, &mm) + if err != nil { + return nil, err + } + msgs[i] = mm + } + return msgs, nil +} diff --git a/baseapp/testutil/messages.pb.go b/baseapp/testutil/messages.pb.go index 2884ff0f649a..da3421a020f9 100644 --- a/baseapp/testutil/messages.pb.go +++ b/baseapp/testutil/messages.pb.go @@ -6,11 +6,11 @@ package testutil import ( context "context" fmt "fmt" - _ "github.com/cosmos/cosmos-sdk/codec/types" _ "github.com/cosmos/cosmos-sdk/types/msgservice" _ "github.com/cosmos/gogoproto/gogoproto" grpc1 "github.com/cosmos/gogoproto/grpc" proto "github.com/cosmos/gogoproto/proto" + any "github.com/cosmos/gogoproto/types/any" grpc "google.golang.org/grpc" codes "google.golang.org/grpc/codes" status "google.golang.org/grpc/status" @@ -282,43 +282,240 @@ func (m *MsgCreateKeyValueResponse) XXX_DiscardUnknown() { var xxx_messageInfo_MsgCreateKeyValueResponse proto.InternalMessageInfo +type MsgSend struct { + From string `protobuf:"bytes,1,opt,name=from,proto3" json:"from,omitempty"` + To string `protobuf:"bytes,2,opt,name=to,proto3" json:"to,omitempty"` + Amount string `protobuf:"bytes,3,opt,name=amount,proto3" json:"amount,omitempty"` +} + +func (m *MsgSend) Reset() { *m = MsgSend{} } +func (m *MsgSend) String() string { return proto.CompactTextString(m) } +func (*MsgSend) ProtoMessage() {} +func (*MsgSend) Descriptor() ([]byte, []int) { + return fileDescriptor_4dc296cbfe5ffcd5, []int{5} +} +func (m *MsgSend) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgSend) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgSend.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *MsgSend) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgSend.Merge(m, src) +} +func (m *MsgSend) XXX_Size() int { + return m.Size() +} +func (m *MsgSend) XXX_DiscardUnknown() { + xxx_messageInfo_MsgSend.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgSend proto.InternalMessageInfo + +func (m *MsgSend) GetFrom() string { + if m != nil { + return m.From + } + return "" +} + +func (m *MsgSend) GetTo() string { + if m != nil { + return m.To + } + return "" +} + +func (m *MsgSend) GetAmount() string { + if m != nil { + return m.Amount + } + return "" +} + +type MsgSendResponse struct { +} + +func (m *MsgSendResponse) Reset() { *m = MsgSendResponse{} } +func (m *MsgSendResponse) String() string { return proto.CompactTextString(m) } +func (*MsgSendResponse) ProtoMessage() {} +func (*MsgSendResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_4dc296cbfe5ffcd5, []int{6} +} +func (m *MsgSendResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgSendResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgSendResponse.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *MsgSendResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgSendResponse.Merge(m, src) +} +func (m *MsgSendResponse) XXX_Size() int { + return m.Size() +} +func (m *MsgSendResponse) XXX_DiscardUnknown() { + xxx_messageInfo_MsgSendResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgSendResponse proto.InternalMessageInfo + +type MsgNestedMessages struct { + Messages []*any.Any `protobuf:"bytes,1,rep,name=messages,proto3" json:"messages,omitempty"` + Signer string `protobuf:"bytes,2,opt,name=signer,proto3" json:"signer,omitempty"` +} + +func (m *MsgNestedMessages) Reset() { *m = MsgNestedMessages{} } +func (m *MsgNestedMessages) String() string { return proto.CompactTextString(m) } +func (*MsgNestedMessages) ProtoMessage() {} +func (*MsgNestedMessages) Descriptor() ([]byte, []int) { + return fileDescriptor_4dc296cbfe5ffcd5, []int{7} +} +func (m *MsgNestedMessages) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgNestedMessages) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgNestedMessages.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *MsgNestedMessages) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgNestedMessages.Merge(m, src) +} +func (m *MsgNestedMessages) XXX_Size() int { + return m.Size() +} +func (m *MsgNestedMessages) XXX_DiscardUnknown() { + xxx_messageInfo_MsgNestedMessages.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgNestedMessages proto.InternalMessageInfo + +func (m *MsgNestedMessages) GetMessages() []*any.Any { + if m != nil { + return m.Messages + } + return nil +} + +func (m *MsgNestedMessages) GetSigner() string { + if m != nil { + return m.Signer + } + return "" +} + +type MsgCreateNestedMessagesResponse struct { +} + +func (m *MsgCreateNestedMessagesResponse) Reset() { *m = MsgCreateNestedMessagesResponse{} } +func (m *MsgCreateNestedMessagesResponse) String() string { return proto.CompactTextString(m) } +func (*MsgCreateNestedMessagesResponse) ProtoMessage() {} +func (*MsgCreateNestedMessagesResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_4dc296cbfe5ffcd5, []int{8} +} +func (m *MsgCreateNestedMessagesResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgCreateNestedMessagesResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgCreateNestedMessagesResponse.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *MsgCreateNestedMessagesResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgCreateNestedMessagesResponse.Merge(m, src) +} +func (m *MsgCreateNestedMessagesResponse) XXX_Size() int { + return m.Size() +} +func (m *MsgCreateNestedMessagesResponse) XXX_DiscardUnknown() { + xxx_messageInfo_MsgCreateNestedMessagesResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgCreateNestedMessagesResponse proto.InternalMessageInfo + func init() { proto.RegisterType((*MsgCounter)(nil), "MsgCounter") proto.RegisterType((*MsgCounter2)(nil), "MsgCounter2") proto.RegisterType((*MsgCreateCounterResponse)(nil), "MsgCreateCounterResponse") proto.RegisterType((*MsgKeyValue)(nil), "MsgKeyValue") proto.RegisterType((*MsgCreateKeyValueResponse)(nil), "MsgCreateKeyValueResponse") + proto.RegisterType((*MsgSend)(nil), "MsgSend") + proto.RegisterType((*MsgSendResponse)(nil), "MsgSendResponse") + proto.RegisterType((*MsgNestedMessages)(nil), "MsgNestedMessages") + proto.RegisterType((*MsgCreateNestedMessagesResponse)(nil), "MsgCreateNestedMessagesResponse") } func init() { proto.RegisterFile("messages.proto", fileDescriptor_4dc296cbfe5ffcd5) } var fileDescriptor_4dc296cbfe5ffcd5 = []byte{ - // 390 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xbc, 0x92, 0xcf, 0xaa, 0xd3, 0x40, - 0x14, 0xc6, 0x1b, 0x83, 0x6d, 0x3d, 0xad, 0x5a, 0x42, 0xd1, 0x34, 0x42, 0x28, 0x5d, 0x48, 0x11, - 0x9a, 0xc1, 0xb8, 0x6b, 0x77, 0x8a, 0x54, 0x11, 0x11, 0x22, 0xb8, 0xe8, 0xa6, 0x4c, 0xd2, 0xd3, - 0x69, 0x68, 0x32, 0x13, 0x32, 0x93, 0x42, 0xb7, 0x3e, 0x81, 0x8f, 0xe2, 0x63, 0xb8, 0xec, 0xd2, - 0xa5, 0xb4, 0x0b, 0x5f, 0x43, 0xf2, 0xaf, 0x75, 0x71, 0x7b, 0xb9, 0xab, 0xbb, 0x9a, 0xf3, 0x7d, - 0x87, 0x9c, 0xdf, 0xc9, 0xc7, 0x81, 0x27, 0x31, 0x4a, 0x49, 0x19, 0x4a, 0x27, 0x49, 0x85, 0x12, - 0x56, 0x9f, 0x09, 0x26, 0x8a, 0x92, 0xe4, 0x55, 0xe5, 0x0e, 0x98, 0x10, 0x2c, 0x42, 0x52, 0x28, - 0x3f, 0x5b, 0x13, 0xca, 0xf7, 0x55, 0xeb, 0x79, 0x20, 0x64, 0x2c, 0x24, 0x89, 0x25, 0x23, 0xbb, - 0xd7, 0xf9, 0x53, 0x36, 0x46, 0x12, 0xe0, 0xb3, 0x64, 0xef, 0x44, 0xc6, 0x15, 0xa6, 0x86, 0x09, - 0xad, 0xa0, 0x2c, 0x4d, 0x6d, 0xa8, 0x8d, 0x75, 0xaf, 0x96, 0xc6, 0x4b, 0x78, 0xba, 0xa6, 0x61, - 0xb4, 0x14, 0x7c, 0xb9, 0xa1, 0x7c, 0x15, 0x61, 0x6a, 0x3e, 0x18, 0x6a, 0xe3, 0xb6, 0xf7, 0x38, - 0xb7, 0xbf, 0xf0, 0x0f, 0xa5, 0x69, 0x3c, 0x83, 0xa6, 0x0c, 0x19, 0xc7, 0xd4, 0xd4, 0x87, 0xda, - 0xf8, 0x91, 0x57, 0xa9, 0x69, 0xe7, 0xfb, 0xdf, 0x9f, 0xaf, 0x2a, 0x31, 0x52, 0xd0, 0xb9, 0x40, - 0xdd, 0xfb, 0xa2, 0x5a, 0x60, 0xe6, 0xd4, 0x14, 0xa9, 0xc2, 0x8a, 0xed, 0xa1, 0x4c, 0x04, 0x97, - 0x38, 0x5a, 0x14, 0x1b, 0x7d, 0xc2, 0xfd, 0x37, 0x1a, 0x65, 0x68, 0xf4, 0x40, 0xdf, 0xe2, 0xbe, - 0xd8, 0xa6, 0xeb, 0xe5, 0xa5, 0xd1, 0x87, 0x87, 0xbb, 0xbc, 0x55, 0xf0, 0xbb, 0x5e, 0x29, 0xee, - 0xc6, 0x7d, 0x01, 0x83, 0x33, 0xb7, 0x26, 0xd4, 0x60, 0xf7, 0x3d, 0xb4, 0xea, 0xf0, 0xa7, 0xd0, - 0xfb, 0xc8, 0x83, 0x14, 0x63, 0xe4, 0xaa, 0xf6, 0x3a, 0xce, 0x25, 0x28, 0x6b, 0xe0, 0x5c, 0xdb, - 0xdf, 0x9d, 0x43, 0xfb, 0x1c, 0xe7, 0xec, 0x86, 0x39, 0xdd, 0xff, 0xe6, 0xb8, 0xb7, 0x0d, 0x9a, - 0x41, 0xfb, 0x9c, 0x02, 0x01, 0xfd, 0x2b, 0xaa, 0xf2, 0xdb, 0xda, 0xb4, 0x2c, 0xe7, 0xea, 0xcf, - 0xbc, 0x9d, 0xff, 0x3a, 0xda, 0xda, 0xe1, 0x68, 0x6b, 0x7f, 0x8e, 0xb6, 0xf6, 0xe3, 0x64, 0x37, - 0x0e, 0x27, 0xbb, 0xf1, 0xfb, 0x64, 0x37, 0x16, 0x13, 0x16, 0xaa, 0x4d, 0xe6, 0x3b, 0x81, 0x88, - 0x49, 0x75, 0x8a, 0xe5, 0x33, 0x91, 0xab, 0x2d, 0xf1, 0xa9, 0x44, 0x9a, 0x24, 0x44, 0xa1, 0x54, - 0x99, 0x0a, 0x23, 0xbf, 0x59, 0x1c, 0xe7, 0x9b, 0x7f, 0x01, 0x00, 0x00, 0xff, 0xff, 0x44, 0x91, - 0x2d, 0xb3, 0xf8, 0x02, 0x00, 0x00, + // 535 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xbc, 0x93, 0xcf, 0x6e, 0xd3, 0x40, + 0x10, 0xc6, 0xeb, 0xa4, 0x6d, 0x92, 0x49, 0x48, 0xd3, 0x55, 0x04, 0x8e, 0x91, 0x4c, 0xc8, 0x01, + 0x45, 0x95, 0xba, 0x06, 0x73, 0x4b, 0xc5, 0x01, 0x2a, 0x54, 0x10, 0x0a, 0x45, 0xae, 0xc4, 0xa1, + 0x97, 0xca, 0x49, 0x26, 0x9b, 0x90, 0x78, 0x37, 0xf2, 0xae, 0x2b, 0xe5, 0xca, 0x13, 0xf0, 0x28, + 0x3c, 0x06, 0xc7, 0x1e, 0x39, 0xa2, 0xe4, 0xc0, 0x6b, 0x20, 0xaf, 0xff, 0xb4, 0x14, 0x02, 0x9c, + 0x38, 0xed, 0xcc, 0xac, 0x77, 0x7e, 0xb3, 0xfb, 0x7d, 0x86, 0x7a, 0x80, 0x52, 0xfa, 0x0c, 0x25, + 0x5d, 0x84, 0x42, 0x09, 0xab, 0xc9, 0x04, 0x13, 0x3a, 0x74, 0xe2, 0x28, 0xad, 0xb6, 0x98, 0x10, + 0x6c, 0x8e, 0x8e, 0xce, 0x06, 0xd1, 0xd8, 0xf1, 0xf9, 0x32, 0xdd, 0xba, 0x37, 0x14, 0x32, 0x10, + 0xd2, 0x09, 0x24, 0x73, 0x2e, 0x9f, 0xc4, 0x4b, 0xb2, 0xd1, 0x91, 0x00, 0x7d, 0xc9, 0x8e, 0x45, + 0xc4, 0x15, 0x86, 0xc4, 0x84, 0xd2, 0x30, 0x09, 0x4d, 0xa3, 0x6d, 0x74, 0x8b, 0x5e, 0x96, 0x92, + 0x47, 0xb0, 0x37, 0xf6, 0xa7, 0xf3, 0x0b, 0xc1, 0x2f, 0x26, 0x3e, 0x1f, 0xcd, 0x31, 0x34, 0x0b, + 0x6d, 0xa3, 0x5b, 0xf6, 0xee, 0xc4, 0xe5, 0x53, 0xfe, 0x2a, 0x29, 0x92, 0xbb, 0xb0, 0x2b, 0xa7, + 0x8c, 0x63, 0x68, 0x16, 0xdb, 0x46, 0xb7, 0xe2, 0xa5, 0x59, 0xaf, 0xfa, 0xf1, 0xfb, 0xe7, 0x83, + 0x34, 0xe9, 0x28, 0xa8, 0x5e, 0x43, 0xdd, 0xff, 0x45, 0xb5, 0xc0, 0x8c, 0xa9, 0x21, 0xfa, 0x0a, + 0x53, 0xb6, 0x87, 0x72, 0x21, 0xb8, 0xc4, 0xce, 0xb9, 0x9e, 0xe8, 0x0d, 0x2e, 0xdf, 0xfb, 0xf3, + 0x08, 0x49, 0x03, 0x8a, 0x33, 0x5c, 0xea, 0x69, 0x6a, 0x5e, 0x1c, 0x92, 0x26, 0xec, 0x5c, 0xc6, + 0x5b, 0x9a, 0x5f, 0xf3, 0x92, 0xe4, 0xdf, 0xb8, 0xf7, 0xa1, 0x95, 0x73, 0x33, 0x42, 0x0e, 0x7e, + 0x07, 0xa5, 0xbe, 0x64, 0x67, 0xc8, 0x47, 0x84, 0xc0, 0xf6, 0x38, 0x14, 0x81, 0xa6, 0x56, 0x3c, + 0x1d, 0x93, 0x3a, 0x14, 0x94, 0xd0, 0xcc, 0x8a, 0x57, 0x50, 0x22, 0x06, 0xfa, 0x41, 0x3c, 0x7b, + 0x06, 0x4c, 0xb2, 0x5e, 0x25, 0x06, 0xea, 0x23, 0x9d, 0x7d, 0xd8, 0x4b, 0x3b, 0xe6, 0x90, 0x0f, + 0xb0, 0xdf, 0x97, 0xec, 0x2d, 0x4a, 0x85, 0xa3, 0x7e, 0xea, 0x24, 0xf2, 0x18, 0xca, 0x99, 0xab, + 0x4c, 0xa3, 0x5d, 0xec, 0x56, 0xdd, 0x26, 0x4d, 0x0c, 0x44, 0x33, 0x03, 0xd1, 0xe7, 0x7c, 0xe9, + 0xe5, 0x5f, 0xdd, 0xb8, 0x6d, 0x61, 0xf3, 0x6d, 0x1f, 0xc2, 0x83, 0xfc, 0xb6, 0x3f, 0x13, 0xb3, + 0x71, 0xdc, 0x97, 0x50, 0xca, 0x0c, 0xd7, 0x83, 0xc6, 0x6b, 0x3e, 0x0c, 0x31, 0x40, 0xae, 0xb2, + 0x5a, 0x95, 0x5e, 0x9b, 0xc3, 0x6a, 0xd1, 0x4d, 0x9a, 0xb9, 0x27, 0x50, 0xce, 0x2d, 0x74, 0xf4, + 0x9b, 0x3e, 0xb5, 0x1b, 0x7d, 0xdc, 0x3f, 0x35, 0x3a, 0x82, 0x72, 0xae, 0xbc, 0x03, 0xc5, 0x33, + 0x54, 0xc9, 0xd9, 0xac, 0x68, 0x59, 0x74, 0xa3, 0x80, 0xee, 0x01, 0x6c, 0x6b, 0xf5, 0x3a, 0xe9, + 0x5a, 0xa6, 0xe9, 0xeb, 0x5b, 0x0d, 0x7a, 0x4b, 0x07, 0xf7, 0x14, 0xea, 0xb7, 0x44, 0x78, 0x06, + 0x3b, 0xc7, 0x13, 0x1c, 0xce, 0x08, 0xa1, 0xbf, 0x28, 0x64, 0xb5, 0xe9, 0x5f, 0x5e, 0xf2, 0xc5, + 0xc9, 0x97, 0x95, 0x6d, 0x5c, 0xad, 0x6c, 0xe3, 0xdb, 0xca, 0x36, 0x3e, 0xad, 0xed, 0xad, 0xab, + 0xb5, 0xbd, 0xf5, 0x75, 0x6d, 0x6f, 0x9d, 0x1f, 0xb2, 0xa9, 0x9a, 0x44, 0x03, 0x3a, 0x14, 0x81, + 0x93, 0xfe, 0xfb, 0xc9, 0x72, 0x28, 0x47, 0x33, 0x67, 0xe0, 0x4b, 0xf4, 0x17, 0x0b, 0x47, 0xa1, + 0x54, 0x91, 0x9a, 0xce, 0x07, 0xbb, 0x5a, 0xf2, 0xa7, 0x3f, 0x02, 0x00, 0x00, 0xff, 0xff, 0x12, + 0x9a, 0xa4, 0x74, 0x69, 0x04, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -545,6 +742,150 @@ var _KeyValue_serviceDesc = grpc.ServiceDesc{ Metadata: "messages.proto", } +// SendClient is the client API for Send service. +// +// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream. +type SendClient interface { + Send(ctx context.Context, in *MsgSend, opts ...grpc.CallOption) (*MsgSendResponse, error) +} + +type sendClient struct { + cc grpc1.ClientConn +} + +func NewSendClient(cc grpc1.ClientConn) SendClient { + return &sendClient{cc} +} + +func (c *sendClient) Send(ctx context.Context, in *MsgSend, opts ...grpc.CallOption) (*MsgSendResponse, error) { + out := new(MsgSendResponse) + err := c.cc.Invoke(ctx, "/Send/Send", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +// SendServer is the server API for Send service. +type SendServer interface { + Send(context.Context, *MsgSend) (*MsgSendResponse, error) +} + +// UnimplementedSendServer can be embedded to have forward compatible implementations. +type UnimplementedSendServer struct { +} + +func (*UnimplementedSendServer) Send(ctx context.Context, req *MsgSend) (*MsgSendResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method Send not implemented") +} + +func RegisterSendServer(s grpc1.Server, srv SendServer) { + s.RegisterService(&_Send_serviceDesc, srv) +} + +func _Send_Send_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(MsgSend) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(SendServer).Send(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/Send/Send", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(SendServer).Send(ctx, req.(*MsgSend)) + } + return interceptor(ctx, in, info, handler) +} + +var _Send_serviceDesc = grpc.ServiceDesc{ + ServiceName: "Send", + HandlerType: (*SendServer)(nil), + Methods: []grpc.MethodDesc{ + { + MethodName: "Send", + Handler: _Send_Send_Handler, + }, + }, + Streams: []grpc.StreamDesc{}, + Metadata: "messages.proto", +} + +// NestedMessagesClient is the client API for NestedMessages service. +// +// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream. +type NestedMessagesClient interface { + Check(ctx context.Context, in *MsgNestedMessages, opts ...grpc.CallOption) (*MsgCreateNestedMessagesResponse, error) +} + +type nestedMessagesClient struct { + cc grpc1.ClientConn +} + +func NewNestedMessagesClient(cc grpc1.ClientConn) NestedMessagesClient { + return &nestedMessagesClient{cc} +} + +func (c *nestedMessagesClient) Check(ctx context.Context, in *MsgNestedMessages, opts ...grpc.CallOption) (*MsgCreateNestedMessagesResponse, error) { + out := new(MsgCreateNestedMessagesResponse) + err := c.cc.Invoke(ctx, "/NestedMessages/Check", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +// NestedMessagesServer is the server API for NestedMessages service. +type NestedMessagesServer interface { + Check(context.Context, *MsgNestedMessages) (*MsgCreateNestedMessagesResponse, error) +} + +// UnimplementedNestedMessagesServer can be embedded to have forward compatible implementations. +type UnimplementedNestedMessagesServer struct { +} + +func (*UnimplementedNestedMessagesServer) Check(ctx context.Context, req *MsgNestedMessages) (*MsgCreateNestedMessagesResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method Check not implemented") +} + +func RegisterNestedMessagesServer(s grpc1.Server, srv NestedMessagesServer) { + s.RegisterService(&_NestedMessages_serviceDesc, srv) +} + +func _NestedMessages_Check_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(MsgNestedMessages) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(NestedMessagesServer).Check(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/NestedMessages/Check", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(NestedMessagesServer).Check(ctx, req.(*MsgNestedMessages)) + } + return interceptor(ctx, in, info, handler) +} + +var _NestedMessages_serviceDesc = grpc.ServiceDesc{ + ServiceName: "NestedMessages", + HandlerType: (*NestedMessagesServer)(nil), + Methods: []grpc.MethodDesc{ + { + MethodName: "Check", + Handler: _NestedMessages_Check_Handler, + }, + }, + Streams: []grpc.StreamDesc{}, + Metadata: "messages.proto", +} + func (m *MsgCounter) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) @@ -725,39 +1066,173 @@ func (m *MsgCreateKeyValueResponse) MarshalToSizedBuffer(dAtA []byte) (int, erro return len(dAtA) - i, nil } -func encodeVarintMessages(dAtA []byte, offset int, v uint64) int { - offset -= sovMessages(v) - base := offset - for v >= 1<<7 { - dAtA[offset] = uint8(v&0x7f | 0x80) - v >>= 7 - offset++ +func (m *MsgSend) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err } - dAtA[offset] = uint8(v) - return base + return dAtA[:n], nil } -func (m *MsgCounter) Size() (n int) { - if m == nil { - return 0 - } + +func (m *MsgSend) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgSend) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i var l int _ = l - if m.Counter != 0 { - n += 1 + sovMessages(uint64(m.Counter)) + if len(m.Amount) > 0 { + i -= len(m.Amount) + copy(dAtA[i:], m.Amount) + i = encodeVarintMessages(dAtA, i, uint64(len(m.Amount))) + i-- + dAtA[i] = 0x1a } - if m.FailOnHandler { - n += 2 + if len(m.To) > 0 { + i -= len(m.To) + copy(dAtA[i:], m.To) + i = encodeVarintMessages(dAtA, i, uint64(len(m.To))) + i-- + dAtA[i] = 0x12 } - l = len(m.Signer) - if l > 0 { - n += 1 + l + sovMessages(uint64(l)) + if len(m.From) > 0 { + i -= len(m.From) + copy(dAtA[i:], m.From) + i = encodeVarintMessages(dAtA, i, uint64(len(m.From))) + i-- + dAtA[i] = 0xa } - return n + return len(dAtA) - i, nil } -func (m *MsgCounter2) Size() (n int) { - if m == nil { - return 0 +func (m *MsgSendResponse) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *MsgSendResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgSendResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + return len(dAtA) - i, nil +} + +func (m *MsgNestedMessages) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *MsgNestedMessages) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgNestedMessages) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Signer) > 0 { + i -= len(m.Signer) + copy(dAtA[i:], m.Signer) + i = encodeVarintMessages(dAtA, i, uint64(len(m.Signer))) + i-- + dAtA[i] = 0x12 + } + if len(m.Messages) > 0 { + for iNdEx := len(m.Messages) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.Messages[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintMessages(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + } + } + return len(dAtA) - i, nil +} + +func (m *MsgCreateNestedMessagesResponse) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *MsgCreateNestedMessagesResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgCreateNestedMessagesResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + return len(dAtA) - i, nil +} + +func encodeVarintMessages(dAtA []byte, offset int, v uint64) int { + offset -= sovMessages(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *MsgCounter) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.Counter != 0 { + n += 1 + sovMessages(uint64(m.Counter)) + } + if m.FailOnHandler { + n += 2 + } + l = len(m.Signer) + if l > 0 { + n += 1 + l + sovMessages(uint64(l)) + } + return n +} + +func (m *MsgCounter2) Size() (n int) { + if m == nil { + return 0 } var l int _ = l @@ -813,6 +1288,64 @@ func (m *MsgCreateKeyValueResponse) Size() (n int) { return n } +func (m *MsgSend) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.From) + if l > 0 { + n += 1 + l + sovMessages(uint64(l)) + } + l = len(m.To) + if l > 0 { + n += 1 + l + sovMessages(uint64(l)) + } + l = len(m.Amount) + if l > 0 { + n += 1 + l + sovMessages(uint64(l)) + } + return n +} + +func (m *MsgSendResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + return n +} + +func (m *MsgNestedMessages) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if len(m.Messages) > 0 { + for _, e := range m.Messages { + l = e.Size() + n += 1 + l + sovMessages(uint64(l)) + } + } + l = len(m.Signer) + if l > 0 { + n += 1 + l + sovMessages(uint64(l)) + } + return n +} + +func (m *MsgCreateNestedMessagesResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + return n +} + func sovMessages(x uint64) (n int) { return (math_bits.Len64(x|1) + 6) / 7 } @@ -1311,6 +1844,368 @@ func (m *MsgCreateKeyValueResponse) Unmarshal(dAtA []byte) error { } return nil } +func (m *MsgSend) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowMessages + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: MsgSend: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgSend: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field From", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowMessages + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthMessages + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthMessages + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.From = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field To", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowMessages + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthMessages + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthMessages + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.To = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Amount", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowMessages + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthMessages + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthMessages + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Amount = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipMessages(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthMessages + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *MsgSendResponse) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowMessages + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: MsgSendResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgSendResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + default: + iNdEx = preIndex + skippy, err := skipMessages(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthMessages + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *MsgNestedMessages) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowMessages + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: MsgNestedMessages: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgNestedMessages: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Messages", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowMessages + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthMessages + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthMessages + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Messages = append(m.Messages, &any.Any{}) + if err := m.Messages[len(m.Messages)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Signer", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowMessages + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthMessages + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthMessages + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Signer = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipMessages(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthMessages + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *MsgCreateNestedMessagesResponse) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowMessages + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: MsgCreateNestedMessagesResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgCreateNestedMessagesResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + default: + iNdEx = preIndex + skippy, err := skipMessages(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthMessages + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} func skipMessages(dAtA []byte) (n int, err error) { l := len(dAtA) iNdEx := 0 diff --git a/baseapp/testutil/messages.proto b/baseapp/testutil/messages.proto index d2b25d24c117..2e0cfd15195f 100644 --- a/baseapp/testutil/messages.proto +++ b/baseapp/testutil/messages.proto @@ -34,6 +34,25 @@ message MsgKeyValue { message MsgCreateKeyValueResponse {} +message MsgSend { + option (cosmos.msg.v1.signer) = "from"; + + string from = 1; + string to = 2; + string amount = 3; +} + +message MsgSendResponse {} + +message MsgNestedMessages { + option (cosmos.msg.v1.signer) = "signer"; + + repeated google.protobuf.Any messages = 1; + string signer = 2; +} + +message MsgCreateNestedMessagesResponse {} + service Counter { rpc IncrementCounter(MsgCounter) returns (MsgCreateCounterResponse); } @@ -44,4 +63,12 @@ service Counter2 { service KeyValue { rpc Set(MsgKeyValue) returns (MsgCreateKeyValueResponse); -} \ No newline at end of file +} + +service Send { + rpc Send(MsgSend) returns (MsgSendResponse); +} + +service NestedMessages { + rpc Check(MsgNestedMessages) returns (MsgCreateNestedMessagesResponse); +} diff --git a/baseapp/utils_test.go b/baseapp/utils_test.go index f95ac16c9f78..27668ce590c5 100644 --- a/baseapp/utils_test.go +++ b/baseapp/utils_test.go @@ -32,6 +32,7 @@ import ( baseapptestutil "github.com/cosmos/cosmos-sdk/baseapp/testutil" "github.com/cosmos/cosmos-sdk/client" addresscodec "github.com/cosmos/cosmos-sdk/codec/address" + codectestutil "github.com/cosmos/cosmos-sdk/codec/testutil" "github.com/cosmos/cosmos-sdk/crypto/keys/secp256k1" "github.com/cosmos/cosmos-sdk/testutil/testdata" sdk "github.com/cosmos/cosmos-sdk/types" @@ -375,3 +376,72 @@ func wonkyMsg(t *testing.T, cfg client.TxConfig, tx signing.Tx) signing.Tx { require.NoError(t, err) return builder.GetTx() } + +type SendServerImpl struct { + gas uint64 +} + +func (s SendServerImpl) Send(ctx context.Context, send *baseapptestutil.MsgSend) (*baseapptestutil.MsgSendResponse, error) { + sdkCtx := sdk.UnwrapSDKContext(ctx) + if send.From == "" { + return nil, errors.New("from address cannot be empty") + } + if send.To == "" { + return nil, errors.New("to address cannot be empty") + } + + _, err := sdk.ParseCoinNormalized(send.Amount) + if err != nil { + return nil, err + } + gas := s.gas + if gas == 0 { + gas = 5 + } + sdkCtx.GasMeter().ConsumeGas(gas, "send test") + return &baseapptestutil.MsgSendResponse{}, nil +} + +type NestedMessgesServerImpl struct { + gas uint64 +} + +func (n NestedMessgesServerImpl) Check(ctx context.Context, message *baseapptestutil.MsgNestedMessages) (*baseapptestutil.MsgCreateNestedMessagesResponse, error) { + sdkCtx := sdk.UnwrapSDKContext(ctx) + cdc := codectestutil.CodecOptions{}.NewCodec() + baseapptestutil.RegisterInterfaces(cdc.InterfaceRegistry()) + + signer, _, err := cdc.GetMsgSigners(message) + if err != nil { + return nil, err + } + if len(signer) != 1 { + return nil, fmt.Errorf("expected 1 signer, got %d", len(signer)) + } + + msgs, err := message.GetMsgs() + if err != nil { + return nil, err + } + + for _, msg := range msgs { + s, _, err := cdc.GetMsgSigners(msg) + if err != nil { + return nil, err + } + if len(s) != 1 { + return nil, fmt.Errorf("expected 1 signer, got %d", len(s)) + } + if !bytes.Equal(signer[0], s[0]) { + return nil, errors.New("signer does not match") + } + + } + + gas := n.gas + if gas == 0 { + gas = 5 + } + sdkCtx.GasMeter().ConsumeGas(gas, "nested messages test") + return nil, nil +} diff --git a/client/cmd.go b/client/cmd.go index c5b40774d9e4..7ea1f49e0942 100644 --- a/client/cmd.go +++ b/client/cmd.go @@ -290,7 +290,7 @@ func readTxCommandFlags(clientCtx Context, flagSet *pflag.FlagSet) (Context, err if keyType == keyring.TypeLedger && clientCtx.SignModeStr == flags.SignModeTextual { if !slices.Contains(clientCtx.TxConfig.SignModeHandler().SupportedModes(), signingv1beta1.SignMode_SIGN_MODE_TEXTUAL) { - return clientCtx, fmt.Errorf("SIGN_MODE_TEXTUAL is not available") + return clientCtx, errors.New("SIGN_MODE_TEXTUAL is not available") } } diff --git a/client/docs/swagger-ui/swagger.yaml b/client/docs/swagger-ui/swagger.yaml index f949019cfdd8..c4352f47aec5 100644 --- a/client/docs/swagger-ui/swagger.yaml +++ b/client/docs/swagger-ui/swagger.yaml @@ -29831,7 +29831,7 @@ paths: /cosmos/nft/v1beta1/balance: get: summary: >- - BalancebyQueryString queries the number of NFTs of a given class owned + BalanceByQueryString queries the number of NFTs of a given class owned by the owner, same as balanceOf in ERC721 operationId: BalanceByQueryString responses: diff --git a/client/flags/flags.go b/client/flags/flags.go index ea8d5794d57f..d44ed316792d 100644 --- a/client/flags/flags.go +++ b/client/flags/flags.go @@ -73,7 +73,7 @@ const ( FlagPageKey = "page-key" FlagOffset = "offset" FlagCountTotal = "count-total" - FlagTimeoutHeight = "timeout-height" + FlagTimeoutTimestamp = "timeout-timestamp" FlagUnordered = "unordered" FlagKeyAlgorithm = "algo" FlagKeyType = "key-type" @@ -136,8 +136,8 @@ func AddTxFlagsToCmd(cmd *cobra.Command) { f.Bool(FlagOffline, false, "Offline mode (does not allow any online functionality)") f.BoolP(FlagSkipConfirmation, "y", false, "Skip tx broadcasting prompt confirmation") f.String(FlagSignMode, "", "Choose sign mode (direct|amino-json|direct-aux|textual), this is an advanced feature") - f.Uint64(FlagTimeoutHeight, 0, "Set a block timeout height to prevent the tx from being committed past a certain height") - f.Bool(FlagUnordered, false, "Enable unordered transaction delivery; must be used in conjunction with --timeout-height") + f.Int64(FlagTimeoutTimestamp, 0, "Set a block timeout timestamp to prevent the tx from being committed past a certain time") + f.Bool(FlagUnordered, false, "Enable unordered transaction delivery; must be used in conjunction with --timeout-timestamp") f.String(FlagFeePayer, "", "Fee payer pays fees for the transaction instead of deducting from the signer") f.String(FlagFeeGranter, "", "Fee granter grants fees for the transaction") f.String(FlagTip, "", "Tip is the amount that is going to be transferred to the fee payer on the target chain. This flag is only valid when used with --aux, and is ignored if the target chain didn't enable the TipDecorator") diff --git a/client/grpc/cmtservice/service.go b/client/grpc/cmtservice/service.go index ad307984c0e5..05eeeb6ecc43 100644 --- a/client/grpc/cmtservice/service.go +++ b/client/grpc/cmtservice/service.go @@ -5,6 +5,7 @@ import ( abci "github.com/cometbft/cometbft/api/cometbft/abci/v1" gogogrpc "github.com/cosmos/gogoproto/grpc" + gogoprotoany "github.com/cosmos/gogoproto/types/any" "github.com/grpc-ecosystem/grpc-gateway/runtime" "google.golang.org/grpc/codes" "google.golang.org/grpc/status" @@ -20,8 +21,8 @@ import ( ) var ( - _ ServiceServer = queryServer{} - _ codectypes.UnpackInterfacesMessage = &GetLatestValidatorSetResponse{} + _ ServiceServer = queryServer{} + _ gogoprotoany.UnpackInterfacesMessage = &GetLatestValidatorSetResponse{} ) type ( @@ -112,7 +113,7 @@ func (s queryServer) GetLatestValidatorSet(ctx context.Context, req *GetLatestVa return ValidatorsOutput(ctx, s.clientCtx, nil, page, limit) } -func (m *GetLatestValidatorSetResponse) UnpackInterfaces(unpacker codectypes.AnyUnpacker) error { +func (m *GetLatestValidatorSetResponse) UnpackInterfaces(unpacker gogoprotoany.AnyUnpacker) error { var pubKey cryptotypes.PubKey for _, val := range m.Validators { err := unpacker.UnpackAny(val.PubKey, &pubKey) diff --git a/client/grpc/node/query.pb.go b/client/grpc/node/query.pb.go index e35556035670..4fa49a40070e 100644 --- a/client/grpc/node/query.pb.go +++ b/client/grpc/node/query.pb.go @@ -176,7 +176,7 @@ func (m *StatusRequest) XXX_DiscardUnknown() { var xxx_messageInfo_StatusRequest proto.InternalMessageInfo -// StateResponse defines the response structure for the status of a node. +// StatusResponse defines the response structure for the status of a node. type StatusResponse struct { EarliestStoreHeight uint64 `protobuf:"varint,1,opt,name=earliest_store_height,json=earliestStoreHeight,proto3" json:"earliest_store_height,omitempty"` Height uint64 `protobuf:"varint,2,opt,name=height,proto3" json:"height,omitempty"` diff --git a/client/grpc_query.go b/client/grpc_query.go index 45f60e48d2de..df6ac284f434 100644 --- a/client/grpc_query.go +++ b/client/grpc_query.go @@ -2,7 +2,7 @@ package client import ( gocontext "context" - "fmt" + "errors" "reflect" "strconv" @@ -123,7 +123,7 @@ func (ctx Context) Invoke(grpcCtx gocontext.Context, method string, req, reply i // NewStream implements the grpc ClientConn.NewStream method func (Context) NewStream(gocontext.Context, *grpc.StreamDesc, string, ...grpc.CallOption) (grpc.ClientStream, error) { - return nil, fmt.Errorf("streaming rpc not supported") + return nil, errors.New("streaming rpc not supported") } // gRPCCodec checks if Context's Codec is codec.GRPCCodecProvider diff --git a/client/keys/output_test.go b/client/keys/output_test.go index c88f93b8752a..b56a30c7a083 100644 --- a/client/keys/output_test.go +++ b/client/keys/output_test.go @@ -8,6 +8,7 @@ import ( "github.com/cosmos/cosmos-sdk/codec" addresscodec "github.com/cosmos/cosmos-sdk/codec/address" + codectestutil "github.com/cosmos/cosmos-sdk/codec/testutil" codectypes "github.com/cosmos/cosmos-sdk/codec/types" cryptocodec "github.com/cosmos/cosmos-sdk/crypto/codec" "github.com/cosmos/cosmos-sdk/crypto/keyring" @@ -15,6 +16,7 @@ import ( "github.com/cosmos/cosmos-sdk/crypto/keys/secp256k1" "github.com/cosmos/cosmos-sdk/crypto/types" sdk "github.com/cosmos/cosmos-sdk/types" + moduletestutil "github.com/cosmos/cosmos-sdk/types/module/testutil" ) func generatePubKeys(n int) []types.PubKey { @@ -100,3 +102,24 @@ func TestProtoMarshalJSON(t *testing.T) { require.Equal(ko.Address, expectedOutput) require.Equal(ko.PubKey, string(bz)) } + +func TestNestedMultisigOutput(t *testing.T) { + cdc := moduletestutil.MakeTestEncodingConfig(codectestutil.CodecOptions{}).Codec + + sk := secp256k1.PrivKey{Key: []byte{154, 49, 3, 117, 55, 232, 249, 20, 205, 216, 102, 7, 136, 72, 177, 2, 131, 202, 234, 81, 31, 208, 46, 244, 179, 192, 167, 163, 142, 117, 246, 13}} + tmpKey := sk.PubKey() + multisigPk := kmultisig.NewLegacyAminoPubKey(1, []types.PubKey{tmpKey}) + multisigPk2 := kmultisig.NewLegacyAminoPubKey(1, []types.PubKey{tmpKey, multisigPk}) + + kb, err := keyring.New(t.Name(), keyring.BackendTest, t.TempDir(), nil, cdc) + require.NoError(t, err) + + _, err = kb.SaveMultisig("multisig", multisigPk2) + require.NoError(t, err) + + k, err := kb.Key("multisig") + require.NoError(t, err) + + _, err = MkAccKeyOutput(k, addresscodec.NewBech32Codec("cosmos")) + require.NoError(t, err) +} diff --git a/client/snapshot/load.go b/client/snapshot/load.go index b64f2eac860d..657929b44104 100644 --- a/client/snapshot/load.go +++ b/client/snapshot/load.go @@ -102,12 +102,12 @@ func LoadArchiveCmd() *cobra.Command { savedSnapshot := <-quitChan if savedSnapshot == nil { - return fmt.Errorf("failed to save snapshot") + return errors.New("failed to save snapshot") } if !reflect.DeepEqual(&snapshot, savedSnapshot) { _ = snapshotStore.Delete(snapshot.Height, snapshot.Format) - return fmt.Errorf("invalid archive, the saved snapshot is not equal to the original one") + return errors.New("invalid archive, the saved snapshot is not equal to the original one") } return nil diff --git a/client/tx/aux_builder.go b/client/tx/aux_builder.go index ade6622f87a0..d7888770ddb1 100644 --- a/client/tx/aux_builder.go +++ b/client/tx/aux_builder.go @@ -2,9 +2,11 @@ package tx import ( "context" + "time" "github.com/cosmos/gogoproto/proto" "google.golang.org/protobuf/types/known/anypb" + "google.golang.org/protobuf/types/known/timestamppb" txv1beta1 "cosmossdk.io/api/cosmos/tx/v1beta1" txsigning "cosmossdk.io/x/tx/signing" @@ -58,6 +60,14 @@ func (b *AuxTxBuilder) SetTimeoutHeight(height uint64) { b.auxSignerData.SignDoc.BodyBytes = nil } +// SetTimeoutTimestamp sets a timeout timestamp in the tx. +func (b *AuxTxBuilder) SetTimeoutTimestamp(timestamp time.Time) { + b.checkEmptyFields() + + b.body.TimeoutTimestamp = timestamppb.New(timestamp) + b.auxSignerData.SignDoc.BodyBytes = nil +} + // SetMsgs sets an array of Msgs in the tx. func (b *AuxTxBuilder) SetMsgs(msgs ...sdk.Msg) error { anys := make([]*anypb.Any, len(msgs)) @@ -209,9 +219,10 @@ func (b *AuxTxBuilder) GetSignBytes() ([]byte, error) { }) auxBody := &txv1beta1.TxBody{ - Messages: body.Messages, - Memo: body.Memo, - TimeoutHeight: body.TimeoutHeight, + Messages: body.Messages, + Memo: body.Memo, + TimeoutHeight: body.TimeoutHeight, + TimeoutTimestamp: body.TimeoutTimestamp, // AuxTxBuilder has no concern with extension options, so we set them to nil. // This preserves pre-PR#16025 behavior where extension options were ignored, this code path: // https://github.com/cosmos/cosmos-sdk/blob/ac3c209326a26b46f65a6cc6f5b5ebf6beb79b38/client/tx/aux_builder.go#L193 diff --git a/client/tx/factory.go b/client/tx/factory.go index 598d389d5f40..4864cacaa877 100644 --- a/client/tx/factory.go +++ b/client/tx/factory.go @@ -6,6 +6,7 @@ import ( "math/big" "os" "strings" + "time" "github.com/cosmos/go-bip39" "github.com/spf13/pflag" @@ -33,6 +34,7 @@ type Factory struct { sequence uint64 gas uint64 timeoutHeight uint64 + timeoutTimestamp time.Time gasAdjustment float64 chainID string fromName string @@ -86,7 +88,8 @@ func NewFactoryCLI(clientCtx client.Context, flagSet *pflag.FlagSet) (Factory, e gasAdj := clientCtx.Viper.GetFloat64(flags.FlagGasAdjustment) memo := clientCtx.Viper.GetString(flags.FlagNote) - timeoutHeight := clientCtx.Viper.GetUint64(flags.FlagTimeoutHeight) + timestampUnix := clientCtx.Viper.GetInt64(flags.FlagTimeoutTimestamp) + timeoutTimestamp := time.Unix(timestampUnix, 0) unordered := clientCtx.Viper.GetBool(flags.FlagUnordered) gasStr := clientCtx.Viper.GetString(flags.FlagGas) @@ -104,7 +107,7 @@ func NewFactoryCLI(clientCtx client.Context, flagSet *pflag.FlagSet) (Factory, e simulateAndExecute: gasSetting.Simulate, accountNumber: accNum, sequence: accSeq, - timeoutHeight: timeoutHeight, + timeoutTimestamp: timeoutTimestamp, unordered: unordered, gasAdjustment: gasAdj, memo: memo, @@ -135,6 +138,7 @@ func (f Factory) Fees() sdk.Coins { return f.fees } func (f Factory) GasPrices() sdk.DecCoins { return f.gasPrices } func (f Factory) AccountRetriever() client.AccountRetriever { return f.accountRetriever } func (f Factory) TimeoutHeight() uint64 { return f.timeoutHeight } +func (f Factory) TimeoutTimestamp() time.Time { return f.timeoutTimestamp } func (f Factory) Unordered() bool { return f.unordered } func (f Factory) FromName() string { return f.fromName } @@ -249,6 +253,12 @@ func (f Factory) WithTimeoutHeight(height uint64) Factory { return f } +// WithTimeoutTimestamp returns a copy of the Factory with an updated timeout timestamp. +func (f Factory) WithTimeoutTimestamp(timestamp time.Time) Factory { + f.timeoutTimestamp = timestamp + return f +} + // WithUnordered returns a copy of the Factory with an updated unordered field. func (f Factory) WithUnordered(v bool) Factory { f.unordered = v @@ -361,6 +371,7 @@ func (f Factory) BuildUnsignedTx(msgs ...sdk.Msg) (client.TxBuilder, error) { tx.SetFeeGranter(f.feeGranter) tx.SetFeePayer(f.feePayer) tx.SetTimeoutHeight(f.TimeoutHeight()) + tx.SetTimeoutTimestamp(f.TimeoutTimestamp()) tx.SetUnordered(f.Unordered()) if etx, ok := tx.(client.ExtendedTxBuilder); ok { @@ -441,7 +452,7 @@ func (f Factory) BuildSimTx(msgs ...sdk.Msg) ([]byte, error) { encoder := f.txConfig.TxEncoder() if encoder == nil { - return nil, fmt.Errorf("cannot simulate tx: tx encoder is nil") + return nil, errors.New("cannot simulate tx: tx encoder is nil") } return encoder(txb.GetTx()) diff --git a/client/tx/tx_test.go b/client/tx/tx_test.go index 77cd0401e520..fd81ee79e26d 100644 --- a/client/tx/tx_test.go +++ b/client/tx/tx_test.go @@ -2,6 +2,7 @@ package tx import ( "context" + "errors" "fmt" "strings" "testing" @@ -44,7 +45,7 @@ type mockContext struct { func (m mockContext) Invoke(_ context.Context, _ string, _, reply interface{}, _ ...grpc.CallOption) (err error) { if m.wantErr { - return fmt.Errorf("mock err") + return errors.New("mock err") } *(reply.(*txtypes.SimulateResponse)) = txtypes.SimulateResponse{ diff --git a/client/tx_config.go b/client/tx_config.go index fe60fe4625c1..c41d3de6389a 100644 --- a/client/tx_config.go +++ b/client/tx_config.go @@ -1,6 +1,8 @@ package client import ( + "time" + "cosmossdk.io/x/auth/signing" txsigning "cosmossdk.io/x/tx/signing" @@ -48,6 +50,7 @@ type ( SetFeePayer(feePayer sdk.AccAddress) SetGasLimit(limit uint64) SetTimeoutHeight(height uint64) + SetTimeoutTimestamp(timestamp time.Time) SetUnordered(v bool) SetFeeGranter(feeGranter sdk.AccAddress) AddAuxSignerData(tx.AuxSignerData) error diff --git a/client/v2/autocli/flag/coin.go b/client/v2/autocli/flag/coin.go index 6ed842a34a93..f317d8585776 100644 --- a/client/v2/autocli/flag/coin.go +++ b/client/v2/autocli/flag/coin.go @@ -2,7 +2,7 @@ package flag import ( "context" - "fmt" + "errors" "strings" "google.golang.org/protobuf/reflect/protoreflect" @@ -38,7 +38,7 @@ func (c *coinValue) String() string { func (c *coinValue) Set(stringValue string) error { if strings.Contains(stringValue, ",") { - return fmt.Errorf("coin flag must be a single coin, specific multiple coins with multiple flags or spaces") + return errors.New("coin flag must be a single coin, specific multiple coins with multiple flags or spaces") } coin, err := coins.ParseCoin(stringValue) diff --git a/client/v2/autocli/testdata/help-echo-msg.golden b/client/v2/autocli/testdata/help-echo-msg.golden index fc981ffd4611..91c5e678c43e 100644 --- a/client/v2/autocli/testdata/help-echo-msg.golden +++ b/client/v2/autocli/testdata/help-echo-msg.golden @@ -27,7 +27,7 @@ Flags: -o, --output string Output format (text|json) (default "json") -s, --sequence uint The sequence number of the signing account (offline mode only) --sign-mode string Choose sign mode (direct|amino-json|direct-aux|textual), this is an advanced feature - --timeout-height uint Set a block timeout height to prevent the tx from being committed past a certain height + --timeout-timestamp int Set a block timeout timestamp to prevent the tx from being committed past a certain time --tip string Tip is the amount that is going to be transferred to the fee payer on the target chain. This flag is only valid when used with --aux, and is ignored if the target chain didn't enable the TipDecorator - --unordered Enable unordered transaction delivery; must be used in conjunction with --timeout-height + --unordered Enable unordered transaction delivery; must be used in conjunction with --timeout-timestamp -y, --yes Skip tx broadcasting prompt confirmation diff --git a/client/v2/autocli/testdata/msg-output.golden b/client/v2/autocli/testdata/msg-output.golden index 924f3eeee5d5..8e075ccb1470 100644 --- a/client/v2/autocli/testdata/msg-output.golden +++ b/client/v2/autocli/testdata/msg-output.golden @@ -1 +1 @@ -{"body":{"messages":[{"@type":"/cosmos.bank.v1beta1.MsgSend","from_address":"cosmos1y74p8wyy4enfhfn342njve6cjmj5c8dtl6emdk","to_address":"cosmos1y74p8wyy4enfhfn342njve6cjmj5c8dtl6emdk","amount":[{"denom":"foo","amount":"1"}]}]},"auth_info":{"fee":{"gas_limit":"200000"}}} +{"body":{"messages":[{"@type":"/cosmos.bank.v1beta1.MsgSend","from_address":"cosmos1y74p8wyy4enfhfn342njve6cjmj5c8dtl6emdk","to_address":"cosmos1y74p8wyy4enfhfn342njve6cjmj5c8dtl6emdk","amount":[{"denom":"foo","amount":"1"}]}],"timeout_timestamp":"1970-01-01T00:00:00Z"},"auth_info":{"fee":{"gas_limit":"200000"}}} \ No newline at end of file diff --git a/client/v2/go.mod b/client/v2/go.mod index a9bb7f4a8e15..f68895543ab3 100644 --- a/client/v2/go.mod +++ b/client/v2/go.mod @@ -5,12 +5,12 @@ go 1.22.2 require ( cosmossdk.io/api v0.7.5 cosmossdk.io/core v0.12.1-0.20231114100755-569e3ff6a0d7 - cosmossdk.io/depinject v1.0.0-alpha.4 + cosmossdk.io/depinject v1.0.0 cosmossdk.io/x/bank v0.0.0-20240226161501-23359a0b6d91 cosmossdk.io/x/gov v0.0.0-20231113122742-912390d5fc4a cosmossdk.io/x/tx v0.13.3 github.com/cosmos/cosmos-proto v1.0.0-beta.5 - github.com/cosmos/cosmos-sdk v0.51.0 + github.com/cosmos/cosmos-sdk v0.53.0 github.com/spf13/cobra v1.8.1 github.com/spf13/pflag v1.0.5 google.golang.org/grpc v1.64.1 @@ -55,7 +55,7 @@ require ( github.com/cosmos/go-bip39 v1.0.0 // indirect github.com/cosmos/gogogateway v1.2.0 // indirect github.com/cosmos/gogoproto v1.5.0 - github.com/cosmos/iavl v1.2.0 // indirect + github.com/cosmos/iavl v1.2.1-0.20240725141113-7adc688cf179 // indirect github.com/cosmos/ics23/go v0.10.0 // indirect github.com/cosmos/ledger-cosmos-go v0.13.3 // indirect github.com/danieljoos/wincred v1.2.1 // indirect @@ -171,7 +171,6 @@ require ( ) require ( - cosmossdk.io/core/testing v0.0.0-00010101000000-000000000000 // indirect cosmossdk.io/schema v0.1.1 // indirect github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect ) @@ -183,8 +182,6 @@ replace ( cosmossdk.io/api => ./../../api cosmossdk.io/core => ./../../core cosmossdk.io/core/testing => ../../core/testing - cosmossdk.io/depinject => ./../../depinject - cosmossdk.io/log => ./../../log cosmossdk.io/store => ./../../store cosmossdk.io/x/accounts => ./../../x/accounts cosmossdk.io/x/auth => ./../../x/auth diff --git a/client/v2/go.sum b/client/v2/go.sum index 0b4d456bb56c..dc867c180288 100644 --- a/client/v2/go.sum +++ b/client/v2/go.sum @@ -6,8 +6,12 @@ cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMT cloud.google.com/go v0.34.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= cosmossdk.io/collections v0.4.0 h1:PFmwj2W8szgpD5nOd8GWH6AbYNi1f2J6akWXJ7P5t9s= cosmossdk.io/collections v0.4.0/go.mod h1:oa5lUING2dP+gdDquow+QjlF45eL1t4TJDypgGd+tv0= +cosmossdk.io/depinject v1.0.0 h1:dQaTu6+O6askNXO06+jyeUAnF2/ssKwrrszP9t5q050= +cosmossdk.io/depinject v1.0.0/go.mod h1:zxK/h3HgHoA/eJVtiSsoaRaRA2D5U4cJ5thIG4ssbB8= cosmossdk.io/errors v1.0.1 h1:bzu+Kcr0kS/1DuPBtUFdWjzLqyUuCiyHjyJB6srBV/0= cosmossdk.io/errors v1.0.1/go.mod h1:MeelVSZThMi4bEakzhhhE/CKqVv3nOJDA25bIqRDu/U= +cosmossdk.io/log v1.3.1 h1:UZx8nWIkfbbNEWusZqzAx3ZGvu54TZacWib3EzUYmGI= +cosmossdk.io/log v1.3.1/go.mod h1:2/dIomt8mKdk6vl3OWJcPk2be3pGOS8OQaLUM/3/tCM= cosmossdk.io/math v1.3.0 h1:RC+jryuKeytIiictDslBP9i1fhkVm6ZDmZEoNP316zE= cosmossdk.io/math v1.3.0/go.mod h1:vnRTxewy+M7BtXBNFybkuhSH4WfedVAAnERHgVFhp3k= cosmossdk.io/schema v0.1.1 h1:I0M6pgI7R10nq+/HCQfbO6BsGBZA8sQy+duR1Y3aKcA= @@ -115,8 +119,8 @@ github.com/cosmos/gogogateway v1.2.0/go.mod h1:iQpLkGWxYcnCdz5iAdLcRBSw3h7NXeOkZ github.com/cosmos/gogoproto v1.4.2/go.mod h1:cLxOsn1ljAHSV527CHOtaIP91kK6cCrZETRBrkzItWU= github.com/cosmos/gogoproto v1.5.0 h1:SDVwzEqZDDBoslaeZg+dGE55hdzHfgUA40pEanMh52o= github.com/cosmos/gogoproto v1.5.0/go.mod h1:iUM31aofn3ymidYG6bUR5ZFrk+Om8p5s754eMUcyp8I= -github.com/cosmos/iavl v1.2.0 h1:kVxTmjTh4k0Dh1VNL046v6BXqKziqMDzxo93oh3kOfM= -github.com/cosmos/iavl v1.2.0/go.mod h1:HidWWLVAtODJqFD6Hbne2Y0q3SdxByJepHUOeoH4LiI= +github.com/cosmos/iavl v1.2.1-0.20240725141113-7adc688cf179 h1:wmwDn7V3RodN9auB3FooSQxs46nHVE3u0mb87TJkZFE= +github.com/cosmos/iavl v1.2.1-0.20240725141113-7adc688cf179/go.mod h1:GiM43q0pB+uG53mLxLDzimxM9l/5N9UuSY3/D0huuVw= github.com/cosmos/ics23/go v0.10.0 h1:iXqLLgp2Lp+EdpIuwXTYIQU+AiHj9mOC2X9ab++bZDM= github.com/cosmos/ics23/go v0.10.0/go.mod h1:ZfJSmng/TBNTBkFemHHHj5YY7VAU/MBU980F4VU1NG0= github.com/cosmos/ledger-cosmos-go v0.13.3 h1:7ehuBGuyIytsXbd4MP43mLeoN2LTOEnk5nvue4rK+yM= diff --git a/client/v2/internal/coins/format.go b/client/v2/internal/coins/format.go index 1c84fe9beab9..c447040c2456 100644 --- a/client/v2/internal/coins/format.go +++ b/client/v2/internal/coins/format.go @@ -1,7 +1,7 @@ package coins import ( - "fmt" + "errors" "regexp" "strings" @@ -19,13 +19,13 @@ func ParseCoin(input string) (*basev1beta1.Coin, error) { input = strings.TrimSpace(input) if input == "" { - return nil, fmt.Errorf("empty input when parsing coin") + return nil, errors.New("empty input when parsing coin") } matches := coinRegex.FindStringSubmatch(input) if len(matches) == 0 { - return nil, fmt.Errorf("invalid input format") + return nil, errors.New("invalid input format") } return &basev1beta1.Coin{ diff --git a/client/v2/internal/prompt/validation.go b/client/v2/internal/prompt/validation.go index 8a6e5a2d334f..d914999f214d 100644 --- a/client/v2/internal/prompt/validation.go +++ b/client/v2/internal/prompt/validation.go @@ -1,6 +1,7 @@ package prompt import ( + "errors" "fmt" "net/url" @@ -10,7 +11,7 @@ import ( // ValidatePromptNotEmpty validates that the input is not empty. func ValidatePromptNotEmpty(input string) error { if input == "" { - return fmt.Errorf("input cannot be empty") + return errors.New("input cannot be empty") } return nil diff --git a/client/v2/internal/testpb/msg.proto b/client/v2/internal/testpb/msg.proto index a1360175d0a1..52096ebd58e7 100644 --- a/client/v2/internal/testpb/msg.proto +++ b/client/v2/internal/testpb/msg.proto @@ -16,7 +16,7 @@ service Msg { }; rpc Clawback(MsgClawbackRequest) returns (MsgClawbackResponse) { - option (cosmos_proto.method_added_in) = "cosmos-sdk v0.51.0"; + option (cosmos_proto.method_added_in) = "cosmos-sdk v0.53.0 "; } } @@ -59,4 +59,4 @@ message MsgResponse { message MsgClawbackRequest {} -message MsgClawbackResponse {} \ No newline at end of file +message MsgClawbackResponse {} diff --git a/client/v2/offchain/builder.go b/client/v2/offchain/builder.go index c3a8f924ed01..55c5678cd15c 100644 --- a/client/v2/offchain/builder.go +++ b/client/v2/offchain/builder.go @@ -113,6 +113,7 @@ func (b *builder) GetSigningTxData() (txsigning.TxData, error) { Messages: msgs, Memo: body.Memo, TimeoutHeight: body.TimeoutHeight, + TimeoutTimestamp: body.TimeoutTimestamp, ExtensionOptions: extOptions, NonCriticalExtensionOptions: nonCriticalExtOptions, } diff --git a/client/v2/offchain/verify.go b/client/v2/offchain/verify.go index 303a086022a7..8b9580d63235 100644 --- a/client/v2/offchain/verify.go +++ b/client/v2/offchain/verify.go @@ -123,7 +123,7 @@ func verifySignature( return err } if !pubKey.VerifySignature(signBytes, data.Signature) { - return fmt.Errorf("unable to verify single signer signature") + return errors.New("unable to verify single signer signature") } return nil default: diff --git a/codec/codec.go b/codec/codec.go index c8c5844ac04b..3d9cfd771bc0 100644 --- a/codec/codec.go +++ b/codec/codec.go @@ -2,6 +2,7 @@ package codec import ( "github.com/cosmos/gogoproto/proto" + gogoprotoany "github.com/cosmos/gogoproto/types/any" "google.golang.org/grpc/encoding" "google.golang.org/protobuf/reflect/protoreflect" @@ -76,7 +77,7 @@ type ( // is not registered in codec, or is not compatible with the serialized data UnmarshalInterface(bz []byte, ptr interface{}) error - types.AnyUnpacker + gogoprotoany.AnyUnpacker } JSONCodec interface { diff --git a/codec/types/interface_registry.go b/codec/types/interface_registry.go index 63bcc8094b43..04c94c4394a9 100644 --- a/codec/types/interface_registry.go +++ b/codec/types/interface_registry.go @@ -7,6 +7,7 @@ import ( "github.com/cosmos/gogoproto/jsonpb" "github.com/cosmos/gogoproto/proto" + gogoprotoany "github.com/cosmos/gogoproto/types/any" "google.golang.org/protobuf/reflect/protodesc" "google.golang.org/protobuf/reflect/protoreflect" @@ -14,47 +15,10 @@ import ( "cosmossdk.io/x/tx/signing" ) -// AnyUnpacker is an interface which allows safely unpacking types packed -// in Any's against a whitelist of registered types -type AnyUnpacker interface { - // UnpackAny unpacks the value in any to the interface pointer passed in as - // iface. Note that the type in any must have been registered in the - // underlying whitelist registry as a concrete type for that interface - // Ex: - // var msg sdk.Msg - // err := cdc.UnpackAny(any, &msg) - // ... - UnpackAny(any *Any, iface interface{}) error -} - -// UnpackInterfacesMessage is meant to extend protobuf types (which implement -// proto.Message) to support a post-deserialization phase which unpacks -// types packed within Any's using the whitelist provided by AnyUnpacker -type UnpackInterfacesMessage interface { - // UnpackInterfaces is implemented in order to unpack values packed within - // Any's using the AnyUnpacker. It should generally be implemented as - // follows: - // func (s *MyStruct) UnpackInterfaces(unpacker AnyUnpacker) error { - // var x AnyInterface - // // where X is an Any field on MyStruct - // err := unpacker.UnpackAny(s.X, &x) - // if err != nil { - // return nil - // } - // // where Y is a field on MyStruct that implements UnpackInterfacesMessage itself - // err = s.Y.UnpackInterfaces(unpacker) - // if err != nil { - // return nil - // } - // return nil - // } - UnpackInterfaces(unpacker AnyUnpacker) error -} - // UnpackInterfaces is a convenience function that calls UnpackInterfaces // on x if x implements UnpackInterfacesMessage -func UnpackInterfaces(x interface{}, unpacker AnyUnpacker) error { - if msg, ok := x.(UnpackInterfacesMessage); ok { +func UnpackInterfaces(x interface{}, unpacker gogoprotoany.AnyUnpacker) error { + if msg, ok := x.(gogoprotoany.UnpackInterfacesMessage); ok { return msg.UnpackInterfaces(unpacker) } return nil @@ -65,7 +29,7 @@ var protoMessageType = reflect.TypeOf((*proto.Message)(nil)).Elem() // InterfaceRegistry provides a mechanism for registering interfaces and // implementations that can be safely unpacked from Any type InterfaceRegistry interface { - AnyUnpacker + gogoprotoany.AnyUnpacker jsonpb.AnyResolver registry.InterfaceRegistrar diff --git a/collections/iter_test.go b/collections/iter_test.go index e18bad20a864..872156196900 100644 --- a/collections/iter_test.go +++ b/collections/iter_test.go @@ -1,6 +1,7 @@ package collections import ( + "errors" "fmt" "testing" @@ -188,7 +189,7 @@ func TestWalk(t *testing.T) { }) require.NoError(t, err) - sentinelErr := fmt.Errorf("sentinel error") + sentinelErr := errors.New("sentinel error") err = m.Walk(ctx, nil, func(key, value uint64) (stop bool, err error) { require.LessOrEqual(t, key, uint64(3)) // asserts that after the number three we stop if key == 3 { diff --git a/collections/map_test.go b/collections/map_test.go index f95935c5720e..5f1ae176df07 100644 --- a/collections/map_test.go +++ b/collections/map_test.go @@ -2,7 +2,7 @@ package collections import ( "context" - "fmt" + "errors" "testing" "github.com/stretchr/testify/require" @@ -53,7 +53,7 @@ func TestMap_Clear(t *testing.T) { err := m.Clear(ctx, nil) require.NoError(t, err) err = m.Walk(ctx, nil, func(key, value uint64) (bool, error) { - return false, fmt.Errorf("should never be called") + return false, errors.New("should never be called") }) require.NoError(t, err) }) diff --git a/core/CHANGELOG.md b/core/CHANGELOG.md index 7be6d889bf8a..bd95f6aabc02 100644 --- a/core/CHANGELOG.md +++ b/core/CHANGELOG.md @@ -62,19 +62,15 @@ Ref: https://keepachangelog.com/en/1.0.0/ * [#18861](https://github.com/cosmos/cosmos-sdk/pull/18861) Moved `coin.ParseCoin` to `client/v2/internal`. * [#18866](https://github.com/cosmos/cosmos-sdk/pull/18866) All items related to depinject have been moved to `cosmossdk.io/depinject` (`Provide`, `Invoke`, `Register`) * [#19041](https://github.com/cosmos/cosmos-sdk/pull/19041) `HasEventListeners` was removed from appmodule due to the fact that it was not used anywhere in the SDK nor implemented - -## [v0.12.0](https://github.com/cosmos/cosmos-sdk/releases/tag/core%2Fv0.12.0) - -:::note -This release contains breaking changes and should not be used with 0.50.x or earlier versions of the Cosmos SDK. -::: - * [#17689](https://github.com/cosmos/cosmos-sdk/pull/17689) Move Comet service to return structs instead of interfaces. * `BlockInfo` was renamed to `Info` and `BlockInfoService` was renamed to `CometInfoService` * [#17693](https://github.com/cosmos/cosmos-sdk/pull/17693) Remove `appmodule.UpgradeModule` interface in favor of preblock -## [v0.11.0](https://github.com/cosmos/cosmos-sdk/releases/tag/core%2Fv0.11.0) +## [v0.11.1](https://github.com/cosmos/cosmos-sdk/releases/tag/core%2Fv0.11.1) + +* [#21022](https://github.com/cosmos/cosmos-sdk/pull/21022) Upgrade depinject to v1.0.0. +## [v0.11.0](https://github.com/cosmos/cosmos-sdk/releases/tag/core%2Fv0.11.0) * [#17468](https://github.com/cosmos/cosmos-sdk/pull/17468) Add `appmodule.HasPreBlocker` interface. diff --git a/core/go.mod b/core/go.mod index 640023bbfb5d..d6dc5f94cd27 100644 --- a/core/go.mod +++ b/core/go.mod @@ -16,3 +16,6 @@ require ( google.golang.org/genproto/googleapis/rpc v0.0.0-20240709173604-40e1e62336c5 // indirect google.golang.org/protobuf v1.34.2 // indirect ) + +// Version tagged too early and incompatible with v0.50 (latest at the time of tagging) +retract v0.12.0 diff --git a/core/log/logger.go b/core/log/logger.go index e56c462b22b7..6065e81732ad 100644 --- a/core/log/logger.go +++ b/core/log/logger.go @@ -2,10 +2,9 @@ package log const ModuleKey = "module" -// Logger is the Cosmos SDK logger interface. -// It maintains as much backward compatibility with the CometBFT logger as possible. -// cosmossdk.io/log is the implementation provided by the Cosmos SDK -// All functionalities of the logger are available through the Impl() method. +// Logger defines basic logger functionality that all previous versions of the Logger interface should +// support. Library users should prefer to use this interface when possible, then type case to Logger +// to see if WithContext is supported. type Logger interface { // Info takes a message and a set of key/value pairs and logs with level INFO. // The key of the tuple must be a string. @@ -23,9 +22,6 @@ type Logger interface { // The key of the tuple must be a string. Debug(msg string, keyVals ...any) - // With returns a new wrapped logger with additional context provided by a set. - With(keyVals ...any) Logger - // Impl returns the underlying logger implementation. // It is used to access the full functionalities of the underlying logger. // Advanced users can type cast the returned value to the actual logger. diff --git a/core/testing/noop.go b/core/testing/noop.go index 94ea011b431b..e723280b8329 100644 --- a/core/testing/noop.go +++ b/core/testing/noop.go @@ -17,5 +17,5 @@ func (nopLogger) Info(string, ...any) {} func (nopLogger) Warn(string, ...any) {} func (nopLogger) Error(string, ...any) {} func (nopLogger) Debug(string, ...any) {} -func (nopLogger) With(...any) log.Logger { return nopLogger{} } +func (nopLogger) WithContext(...any) any { return nopLogger{} } func (nopLogger) Impl() any { return nopLogger{} } diff --git a/crypto/keyring/legacy_info.go b/crypto/keyring/legacy_info.go index 47cbe3e9a920..48e5d664f11f 100644 --- a/crypto/keyring/legacy_info.go +++ b/crypto/keyring/legacy_info.go @@ -4,6 +4,8 @@ import ( "errors" "fmt" + gogoprotoany "github.com/cosmos/gogoproto/types/any" + "github.com/cosmos/cosmos-sdk/codec/legacy" codectypes "github.com/cosmos/cosmos-sdk/codec/types" "github.com/cosmos/cosmos-sdk/crypto/hd" @@ -218,7 +220,7 @@ func (i LegacyMultiInfo) GetPath() (*hd.BIP44Params, error) { } // UnpackInterfaces implements UnpackInterfacesMessage.UnpackInterfaces -func (i LegacyMultiInfo) UnpackInterfaces(unpacker codectypes.AnyUnpacker) error { +func (i LegacyMultiInfo) UnpackInterfaces(unpacker gogoprotoany.AnyUnpacker) error { multiPK := i.PubKey.(*multisig.LegacyAminoPubKey) return codectypes.UnpackInterfaces(multiPK, unpacker) diff --git a/crypto/keyring/record.go b/crypto/keyring/record.go index 96141e4c906e..2e19c5b91576 100644 --- a/crypto/keyring/record.go +++ b/crypto/keyring/record.go @@ -3,6 +3,8 @@ package keyring import ( "errors" + gogoprotoany "github.com/cosmos/gogoproto/types/any" + errorsmod "cosmossdk.io/errors" codectypes "github.com/cosmos/cosmos-sdk/codec/types" @@ -103,7 +105,7 @@ func (k Record) GetType() KeyType { } // UnpackInterfaces implements UnpackInterfacesMessage.UnpackInterfaces -func (k *Record) UnpackInterfaces(unpacker codectypes.AnyUnpacker) error { +func (k *Record) UnpackInterfaces(unpacker gogoprotoany.AnyUnpacker) error { var pk cryptotypes.PubKey if err := unpacker.UnpackAny(k.PubKey, &pk); err != nil { return err diff --git a/crypto/keys/multisig/multisig.go b/crypto/keys/multisig/multisig.go index 623f25516164..1fc3f8e28098 100644 --- a/crypto/keys/multisig/multisig.go +++ b/crypto/keys/multisig/multisig.go @@ -4,6 +4,7 @@ import ( "fmt" cmtcrypto "github.com/cometbft/cometbft/crypto" + gogoprotoany "github.com/cosmos/gogoproto/types/any" "github.com/cosmos/cosmos-sdk/codec/types" cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types" @@ -12,8 +13,8 @@ import ( ) var ( - _ multisigtypes.PubKey = &LegacyAminoPubKey{} - _ types.UnpackInterfacesMessage = &LegacyAminoPubKey{} + _ multisigtypes.PubKey = &LegacyAminoPubKey{} + _ gogoprotoany.UnpackInterfacesMessage = &LegacyAminoPubKey{} ) // NewLegacyAminoPubKey returns a new LegacyAminoPubKey. @@ -149,7 +150,7 @@ func (m *LegacyAminoPubKey) Type() string { } // UnpackInterfaces implements UnpackInterfacesMessage.UnpackInterfaces -func (m *LegacyAminoPubKey) UnpackInterfaces(unpacker types.AnyUnpacker) error { +func (m *LegacyAminoPubKey) UnpackInterfaces(unpacker gogoprotoany.AnyUnpacker) error { for _, any := range m.PubKeys { var pk cryptotypes.PubKey err := unpacker.UnpackAny(any, &pk) @@ -169,11 +170,6 @@ func packPubKeys(pubKeys []cryptotypes.PubKey) ([]*types.Any, error) { return nil, err } anyPubKeys[i] = any - - // sets the compat.aminoBz value - if err := anyPubKeys[i].UnmarshalAmino(pubKeys[i].Bytes()); err != nil { - return nil, err - } } return anyPubKeys, nil } diff --git a/depinject/appconfig/config.go b/depinject/appconfig/config.go index 10e1d037386d..9bffeae41c50 100644 --- a/depinject/appconfig/config.go +++ b/depinject/appconfig/config.go @@ -1,6 +1,7 @@ package appconfig import ( + "errors" "fmt" "reflect" "strings" @@ -95,7 +96,7 @@ func Compose(appConfig gogoproto.Message) depinject.Config { for _, module := range appConfigConcrete.Modules { if module.Name == "" { - return depinject.Error(fmt.Errorf("module is missing name")) + return depinject.Error(errors.New("module is missing name")) } if module.Config == nil { diff --git a/depinject/container_test.go b/depinject/container_test.go index 43010004cc35..dc4a9291e370 100644 --- a/depinject/container_test.go +++ b/depinject/container_test.go @@ -1,6 +1,7 @@ package depinject_test import ( + "errors" "fmt" "os" "testing" @@ -300,7 +301,7 @@ func TestCyclic(t *testing.T) { } func TestErrorOption(t *testing.T) { - err := depinject.Inject(depinject.Error(fmt.Errorf("an error"))) + err := depinject.Inject(depinject.Error(errors.New("an error"))) require.Error(t, err) } @@ -606,7 +607,7 @@ func ProvideTestOutput() (TestOutput, error) { } func ProvideTestOutputErr() (TestOutput, error) { - return TestOutput{}, fmt.Errorf("error") + return TestOutput{}, errors.New("error") } func TestStructArgs(t *testing.T) { diff --git a/depinject/internal/codegen/file.go b/depinject/internal/codegen/file.go index dba77becb13e..09a1a6109637 100644 --- a/depinject/internal/codegen/file.go +++ b/depinject/internal/codegen/file.go @@ -1,7 +1,7 @@ package codegen import ( - "fmt" + "errors" "go/ast" "go/token" "strconv" @@ -61,7 +61,7 @@ func NewFileGen(file *ast.File, codegenPkgPath string) (*FileGen, error) { if spec.Name != nil { name := spec.Name.Name if name == "." { - return nil, fmt.Errorf(". package imports are not allowed") + return nil, errors.New(". package imports are not allowed") } info = &importInfo{importPrefix: name, ImportSpec: spec} diff --git a/docs/architecture/adr-054-semver-compatible-modules.md b/docs/architecture/adr-054-semver-compatible-modules.md index 8173b9a20c69..5dc0a666f69b 100644 --- a/docs/architecture/adr-054-semver-compatible-modules.md +++ b/docs/architecture/adr-054-semver-compatible-modules.md @@ -3,6 +3,7 @@ ## Changelog * 2022-04-27: First draft +* 2024-07-21: Second draft ## Status @@ -286,7 +287,29 @@ the [protoreflect API](https://pkg.go.dev/google.golang.org/protobuf/reflect/pro to ensure that no fields unknown to the receiving module are set. This could result in an undesirable performance hit depending on how complex this logic is. -### Approach B) Changes to Generated Code +#### No New Fields in Existing Protobuf Messages + +An alternative to addressing minor version incompatibilities as described above is disallowing new fields in existing protobuf messages. While this is more restrictive, it simplifies versioning and eliminates the need for runtime unknown field checking. In addition, this approach would simplify cross language communication with the proposed [RFC 002: Zero Copy Encoding](../rfc/rfc-002-zero-copy-encoding.md). So, while it is rather restrictive, it has gained a fair amount of support. + +Although disallowing new fields may seem overly restrictive, there is a straightforward way to work around it using protobuf `oneof`s. Because `oneof` and `enum` cases must get processed through a `switch` statement, adding new cases is not problematic because any unknown cases can be handled by a `default` clause. The router layer wouldn't need to do unknown field filtering for these because the `switch` statement is a native way to do this. If we needed to add new fields to `MsgDoSomething` from above and retain the possibility of adding more new fields in the future, we could do something like this: + +```protobuf +message MsgDoSomethingWithOptions { + string sender = 1; + uint64 amount = 2; + repeated MsgDoSomethingOption options = 3; +} + +message MsgDoSomethingOption { + oneof option { + Condition condition = 1; + } +} +``` + +New `oneof` cases can be added to `MsgDoSomethingOption` and this has a similar effect as adding new fields to `MsgDoSomethingWithOptions` but no new fields are needed. A similar strategy is recommended for adding variadic options to golang functions in https://go.dev/blog/module-compatibility and expanded upon in https://commandcenter.blogspot.com/2014/01/self-referential-functions-and-design.html. + +### Approach B) Changes to Generated Code to a Getter/Setter API An alternate approach to solving the versioning problem is to change how protobuf code is generated and move modules mostly or completely in the direction of inter-module communication as described @@ -429,297 +452,70 @@ Other downsides to this approach are: * doesn't get us any closer to proper object capability security (one of the goals of ADR 033) * ADR 033 needs to be done properly anyway for the set of use cases which do need it -## Decision - -The latest **DRAFT** proposal is: - -1. we are alignment on adopting [ADR 033](./adr-033-protobuf-inter-module-comm.md) not just as an addition to the - framework, but as a core replacement to the keeper paradigm entirely. -2. the ADR 033 inter-module router will accommodate any variation of approach (A) or (B) given the following rules: - a. if the client type is the same as the server type then pass it directly through, - b. if both client and server use the zero-copy generated code wrappers (which still need to be defined), then pass - the memory buffers from one wrapper to the other, or - c. marshal/unmarshal types between client and server. - -This approach will allow for both maximal correctness and enable a clear path to enabling modules within in other -languages, possibly executed within a WASM VM. - -### Minor API Revisions - -To declare minor API revisions of proto files, we propose the following guidelines (which were already documented -in [cosmos.app.v1alpha module options](https://github.com/cosmos/cosmos-sdk/blob/main/proto/cosmos/app/v1alpha1/module.proto): - -* proto packages which are revised from their initial version (considered revision `0`) should include a `package` -* comment in some .proto file containing the test `Revision N` at the start of a comment line where `N` is the current -revision number. -* all fields, messages, etc. added in a version beyond the initial revision should add a comment at the start of a -comment line of the form `Since: Revision N` where `N` is the non-zero revision it was added. +### Approach E) Use Structural Typing in Inter-module APIs, Avoid New Fields on Messages -It is advised that there is a 1:1 correspondence between a state machine module and versioned set of proto files -which are versioned either as a buf module a go API module or both. If the buf schema registry is used, the version of -this buf module should always be `1.N` where `N` corresponds to the package revision. Patch releases should be used when -only documentation comments are updated. It is okay to include proto packages named `v2`, `v3`, etc. in this same -`1.N` versioned buf module (ex. `cosmos.bank.v2`) as long as all these proto packages consist of a single API intended -to be served by a single SDK module. +The current non-router based approach for inter-module communication is for a module to define a `Keeper` interface and for a consumer module to define an expected keeper interface with a subset of the keeper's methods. Such an interface can allow one module to avoid a direct dependency on another module if no concrete types need to be imported from the other module. For instance, if we had a method `DoSomething(context.Context, string, uint64)` as in `foo.v1`, then a module calling `DoSomething` would not need to import `foo` directly. If, however, we had a struct parameter such as `Condition` and the new method were `DoSomethingV2(context.Context, string, uint64, foo.Condition)` then a calling module would generally need to import foo just to get a reference to the `foo.Condition` struct. -### Introspecting Minor API Revisions +Golang, however, supports both structural and nominal typing. Nominal typing means that two types equivalent if and only if they have the same name. Structural typing in golang means that two types are equivalent if they have the same structure and are unnamed. So if we defined `Condition` nominally it might look like `type Condition struct { Field1 string }` and if we defined it structurally it would look like `type Condition = struct { Field1 string }`. If `Condition` were defined structurally we could use the expected keeper approach and a calling module _would not_ need to import `foo` at all to define the `DoSomethingV2` method in its expected keeper interface. Structural typing avoids the dependency problems described above. -In order for modules to introspect the minor API revision of peer modules, we propose adding the following method -to `cosmossdk.io/core/intermodule.Client`: +We could actually extend this structural typing paradigm to protobuf generated code _if_ we disallow adding new fields to existing protobuf messages. This would be required because two struct types are only identical if their fields are identical. If even the order of fields in a struct or the struct tags change, then golang considers the structs as different types. While this is fairly restrictive, it is under consideration for approach A) and [RFC 002](../rfc/rfc-002-zero-copy-encoding.md) as well and has gained a fair amount of support. -```go -ServiceRevision(ctx context.Context, serviceName string) uint64 -``` - -Modules could all this using the service name statically generated by the go grpc code generator: - -```go -intermoduleClient.ServiceRevision(ctx, bankv1beta1.Msg_ServiceDesc.ServiceName) -``` - -In the future, we may decide to extend the code generator used for protobuf services to add a field -to client types which does this check more concisely, ex: +Small modifications to the existing pulsar code generator could potentially generate code that uses structural typing and moves the implementation of protobuf interfaces to wrapper types because unnamed structs can't define methods. Here's an example of what this might look like: ```go -package bankv1beta1 - -type MsgClient interface { - Send(context.Context, MsgSend) (MsgSendResponse, error) - ServiceRevision(context.Context) uint64 +type MsgDoSomething = struct { + Sender string + Amount uint64 } -``` - -### Unknown Field Filtering -To correctly perform [unknown field filtering](./adr-020-protobuf-transaction-encoding.md#unknown-field-filtering), -the inter-module router can do one of the following: +type MsgDoSomething_Message(*MsgDoSomething) -* use the `protoreflect` API for messages which support that -* for gogo proto messages, marshal and use the existing `codec/unknownproto` code -* for zero-copy messages, do a simple check on the highest set field number (assuming we can require that fields are - adding consecutively in increasing order) - -### `FileDescriptor` Registration - -Because a single go binary may contain different versions of the same generated protobuf code, we cannot rely on the -global protobuf registry to contain the correct `FileDescriptor`s. Because `appconfig` module configuration is itself -written in protobuf, we would like to load the `FileDescriptor`s for a module before loading a module itself. So we -will provide ways to register `FileDescriptor`s at module registration time before instantiation. We propose the -following `cosmossdk.io/core/appmodule.Option` constructors for the various cases of how `FileDescriptor`s may be -packaged: - -```go -package appmodule - -// this can be used when we are using google.golang.org/protobuf compatible generated code -// Ex: -// ProtoFiles(bankv1beta1.File_cosmos_bank_v1beta1_module_proto) -func ProtoFiles(file []protoreflect.FileDescriptor) Option {} - -// this can be used when we are using gogo proto generated code. -func GzippedProtoFiles(file [][]byte) Option {} - -// this can be used when we are using buf build to generated a pinned file descriptor -func ProtoImage(protoImage []byte) Option {} +// MsgDoSomething_Message would actually implement protobuf methods +var _ proto.Message = (*MsgDoSomething_Message)(nil) ``` -This approach allows us to support several ways protobuf files might be generated: - -* proto files generated internally to a module (use `ProtoFiles`) -* the API module approach with pinned file descriptors (use `ProtoImage`) -* gogo proto (use `GzippedProtoFiles`) - -### Module Dependency Declaration +At least at the message layer, such an API wouldn't pose a problem because the transaction decoder does message decoding and modules wouldn't need to interact with the `proto.Message` interface directly. -One risk of ADR 033 is that dependencies are called at runtime which are not present in the loaded set of SDK modules. -Also we want modules to have a way to define a minimum dependency API revision that they require. Therefore, all -modules should declare their set of dependencies upfront. These dependencies could be defined when a module is -instantiated, but ideally we know what the dependencies are before instantiation and can statically look at an app -config and determine whether the set of modules. For example, if `bar` requires `foo` revision `>= 1`, then we -should be able to know this when creating an app config with two versions of `bar` and `foo`. +In order to avoid problems with the global protobuf registry, the structural typing generated code would only register message descriptors with the global registry but not register message types. This would allow two modules to generate the same protobuf types in different packages without causing a conflict. Because the types are defined structurally, they would actually be the _same_ types but no direct import would be required. In order to ensure compatibility, when message descriptors are registered at startup, a check would be required to ensure that messages are identical (i.e. no new fields). -We propose defining these dependencies in the proto options of the module config object itself. +With this approach, a module `bar` calling module `foo` could either import `foo` directly to get its types or generate its own set of compatible types for `foo`s API. The dependency problem is essentially solved with this approach without needing any sort of special discipline around a separate API module. The main discipline would be around versioning protobuf APIs correctly and not adding new fields. -### Interface Registration - -We will also need to define how interface methods are defined on types that are serialized as `google.protobuf.Any`'s. -In light of the desire to support modules in other languages, we may want to think of solutions that will accommodate -other languages such as plugins described briefly in [ADR 033](./adr-033-protobuf-inter-module-comm.md#internal-methods). - -### Testing - -In order to ensure that modules are indeed with multiple versions of their dependencies, we plan to provide specialized -unit and integration testing infrastructure that automatically tests multiple versions of dependencies. - -#### Unit Testing - -Unit tests should be conducted inside SDK modules by mocking their dependencies. In a full ADR 033 scenario, -this means that all interaction with other modules is done via the inter-module router, so mocking of dependencies -means mocking their msg and query server implementations. We will provide both a test runner and fixture to make this -streamlined. The key thing that the test runner should do to test compatibility is to test all combinations of -dependency API revisions. This can be done by taking the file descriptors for the dependencies, parsing their comments -to determine the revisions various elements were added, and then created synthetic file descriptors for each revision -by subtracting elements that were added later. - -Here is a proposed API for the unit test runner and fixture: +Taking this approach one step further, we could potentially even define APIs that unwrap the request and response types, i.e. `DoSomething(context.Context, string, uint64) error` vs `DoSomething(context.Context, MsgDoSomething) (MsgDoSomethingResponse, error)`. Or, APIs could even be defined directly in golang and the `.proto` files plus marshaling code could be generated via `go generate`. Ex: ```go -package moduletesting - -import ( - "context" - "testing" - - "cosmossdk.io/core/intermodule" - "cosmossdk.io/depinject" - "google.golang.org/grpc" - "google.golang.org/protobuf/proto" - "google.golang.org/protobuf/reflect/protodesc" -) - -type TestFixture interface { - context.Context - intermodule.Client // for making calls to the module we're testing - BeginBlock() - EndBlock() -} +package foo -type UnitTestFixture interface { - TestFixture - grpc.ServiceRegistrar // for registering mock service implementations -} +import "context" -type UnitTestConfig struct { - ModuleConfig proto.Message // the module's config object - DepinjectConfig depinject.Config // optional additional depinject config options - DependencyFileDescriptors []protodesc.FileDescriptorProto // optional dependency file descriptors to use instead of the global registry -} +//go:generate go run github.com/cosmos/cosmos-proto/cmd/structproto -// Run runs the test function for all combinations of dependency API revisions. -func (cfg UnitTestConfig) Run(t *testing.T, f func(t *testing.T, f UnitTestFixture)) { - // ... +type Msg interface { + DoSomething(context.Context, string, uint64) error } ``` -Here is an example for testing bar calling foo which takes advantage of conditional service revisions in the expected -mock arguments: +While having the limitation of not allowing new fields to be added to existing structs, approach E) has the following benefits: +* unlike approach A), api types can be generated in the same go module, but direct imports can always be avoided +* generated client/server code could look more like regular go interfaces (without needing a set of intermediate structs) +* keeper interface defined in `.go` files could be turned into protobuf APIs (rather than needing to write `.proto` files) +* SDK modules could adopt go semantic versioning without any of the issues described above, achieving the initially stated goals of this ADR -```go -func TestBar(t *testing.T) { - UnitTestConfig{ModuleConfig: &foomodulev1.Module{}}.Run(t, func (t *testing.T, f moduletesting.UnitTestFixture) { - ctrl := gomock.NewController(t) - mockFooMsgServer := footestutil.NewMockMsgServer() - foov1.RegisterMsgServer(f, mockFooMsgServer) - barMsgClient := barv1.NewMsgClient(f) - if f.ServiceRevision(foov1.Msg_ServiceDesc.ServiceName) >= 1 { - mockFooMsgServer.EXPECT().DoSomething(gomock.Any(), &foov1.MsgDoSomething{ - ..., - Condition: ..., // condition is expected in revision >= 1 - }).Return(&foov1.MsgDoSomethingResponse{}, nil) - } else { - mockFooMsgServer.EXPECT().DoSomething(gomock.Any(), &foov1.MsgDoSomething{...}).Return(&foov1.MsgDoSomethingResponse{}, nil) - } - res, err := barMsgClient.CallFoo(f, &MsgCallFoo{}) - ... - }) -} -``` - -The unit test runner would make sure that no dependency mocks return arguments which are invalid for the service -revision being tested to ensure that modules don't incorrectly depend on functionality not present in a given revision. - -#### Integration Testing - -An integration test runner and fixture would also be provided which instead of using mocks would test actual module -dependencies in various combinations. Here is the proposed API: - -```go -type IntegrationTestFixture interface { - TestFixture -} - -type IntegrationTestConfig struct { - ModuleConfig proto.Message // the module's config object - DependencyMatrix map[string][]proto.Message // all the dependent module configs -} - -// Run runs the test function for all combinations of dependency modules. -func (cfg IntegationTestConfig) Run(t *testing.T, f func (t *testing.T, f IntegrationTestFixture)) { - // ... -} -``` - -And here is an example with foo and bar: - -```go -func TestBarIntegration(t *testing.T) { - IntegrationTestConfig{ - ModuleConfig: &barmodulev1.Module{}, - DependencyMatrix: map[string][]proto.Message{ - "runtime": []proto.Message{ // test against two versions of runtime - &runtimev1.Module{}, - &runtimev2.Module{}, - }, - "foo": []proto.Message{ // test against three versions of foo - &foomodulev1.Module{}, - &foomodulev2.Module{}, - &foomodulev3.Module{}, - } - } - }.Run(t, func (t *testing.T, f moduletesting.IntegrationTestFixture) { - barMsgClient := barv1.NewMsgClient(f) - res, err := barMsgClient.CallFoo(f, &MsgCallFoo{}) - ... - }) -} -``` +## Decision -Unlike unit tests, integration tests actually pull in other module dependencies. So that modules can be written -without direct dependencies on other modules and because golang has no concept of development dependencies, integration -tests should be written in separate go modules, ex. `example.com/bar/v2/test`. Because this paradigm uses go semantic -versioning, it is possible to build a single go module which imports 3 versions of bar and 2 versions of runtime and -can test these all together in the six various combinations of dependencies. +There has been no decision yet, and the SDK has more or less been following approach C) and official adoption of [0ver](https://0ver.org) as a policy has been discussed. The issue of decoupling modules, properly versioning protobuf types, avoiding breakage, and adopting semver continue to arise from time to time. The most serious alternatives under consideration currently are approaches A) and E). The remainder of this ADR has been left blank and will be filled in when and if there is further convergence on a solution. ## Consequences ### Backwards Compatibility -Modules which migrate fully to ADR 033 will not be compatible with existing modules which use the keeper paradigm. -As a temporary workaround we may create some wrapper types that emulate the current keeper interface to minimize -the migration overhead. - ### Positive -* we will be able to deliver interoperable semantically versioned modules which should dramatically increase the - ability of the Cosmos SDK ecosystem to iterate on new features -* it will be possible to write Cosmos SDK modules in other languages in the near future - ### Negative -* all modules will need to be refactored somewhat dramatically - ### Neutral -* the `cosmossdk.io/core/appconfig` framework will play a more central role in terms of how modules are defined, this - is likely generally a good thing but does mean additional changes for users wanting to stick to the pre-depinject way - of wiring up modules -* `depinject` is somewhat less needed or maybe even obviated because of the full ADR 033 approach. If we adopt the - core API proposed in https://github.com/cosmos/cosmos-sdk/pull/12239, then a module would probably always instantiate - itself with a method `ProvideModule(appmodule.Service) (appmodule.AppModule, error)`. There is no complex wiring of - keeper dependencies in this scenario and dependency injection may not have as much of (or any) use case. - ## Further Discussions -The decision described above is considered in draft mode and is pending final buy-in from the team and key stakeholders. -Key outstanding discussions if we do adopt that direction are: - -* how do module clients introspect dependency module API revisions -* how do modules determine a minor dependency module API revision requirement -* how do modules appropriately test compatibility with different dependency versions -* how to register and resolve interface implementations -* how do modules register their protobuf file descriptors depending on the approach they take to generated code (the - API module approach may still be viable as a supported strategy and would need pinned file descriptors) - ## References * https://github.com/cosmos/cosmos-sdk/discussions/10162 diff --git a/docs/architecture/adr-070-unordered-transactions.md b/docs/architecture/adr-070-unordered-transactions.md index b3547b1075ec..abcf63e76dd6 100644 --- a/docs/architecture/adr-070-unordered-transactions.md +++ b/docs/architecture/adr-070-unordered-transactions.md @@ -35,13 +35,13 @@ this proposal, they'll follow the nonce rules the same as before. When an un-ordered transaction is included into a block, the transaction hash is recorded in a dictionary. New transactions are checked against this dictionary for duplicates, and to prevent the dictionary grow indefinitely, the transaction must -specify `timeout_height` for expiration, so it's safe to removed it from the +specify `timeout_timestamp` for expiration, so it's safe to removed it from the dictionary after it's expired. The dictionary can be simply implemented as an in-memory golang map, a preliminary analysis shows that the memory consumption won't be too big, for example `32M = 32 * 1024 * 1024` can support 1024 blocks where each block contains 1024 unordered transactions. For -safety, we should limit the range of `timeout_height` to prevent very long expiration, +safety, we should limit the range of `timeout_timestamp` to prevent very long expiration, and limit the size of the dictionary. ### Transaction Format @@ -58,12 +58,12 @@ message TxBody { In order to provide replay protection, a user should ensure that the transaction's TTL value is relatively short-lived but long enough to provide enough time to be -included in a block, e.g. ~H+50. +included in a block, e.g. ~10 minutes. We facilitate this by storing the transaction's hash in a durable map, `UnorderedTxManager`, to prevent duplicates, i.e. replay attacks. Upon transaction ingress during `CheckTx`, we check if the transaction's hash exists in this map or if the TTL value is stale, -i.e. before the current block. If so, we reject it. Upon inclusion in a block +i.e. before the current block time. If so, we reject it. Upon inclusion in a block during `DeliverTx`, the transaction's hash is set in the map along with it's TTL value. @@ -93,20 +93,20 @@ const PurgeLoopSleepMS = 500 // UnorderedTxManager contains the tx hash dictionary for duplicates checking, // and expire them when block production progresses. type UnorderedTxManager struct { - // blockCh defines a channel to receive newly committed block heights - blockCh chan uint64 + // blockCh defines a channel to receive newly committed block time + blockCh chan time.Time mu sync.RWMutex // txHashes defines a map from tx hash -> TTL value, which is used for duplicate // checking and replay protection, as well as purging the map when the TTL is // expired. - txHashes map[TxHash]uint64 + txHashes map[TxHash]time.Time } func NewUnorderedTxManager() *UnorderedTxManager { m := &UnorderedTxManager{ - blockCh: make(chan uint64, 16), - txHashes: make(map[TxHash]uint64), + blockCh: make(chan time.Time, 16), + txHashes: make(map[TxHash]time.Time), } return m @@ -137,27 +137,27 @@ func (m *UnorderedTxManager) Size() int { return len(m.txHashes) } -func (m *UnorderedTxManager) Add(hash TxHash, expire uint64) { +func (m *UnorderedTxManager) Add(hash TxHash, expire time.Time) { m.mu.Lock() defer m.mu.Unlock() m.txHashes[hash] = expire } -// OnNewBlock send the latest block number to the background purge loop, which +// OnNewBlock send the latest block time to the background purge loop, which // should be called in ABCI Commit event. -func (m *UnorderedTxManager) OnNewBlock(blockHeight uint64) { - m.blockCh <- blockHeight +func (m *UnorderedTxManager) OnNewBlock(blockTime time.Time) { + m.blockCh <- blockTime } -// expiredTxs returns expired tx hashes based on the provided block height. -func (m *UnorderedTxManager) expiredTxs(blockHeight uint64) []TxHash { +// expiredTxs returns expired tx hashes based on the provided block time. +func (m *UnorderedTxManager) expiredTxs(blockTime time.Time) []TxHash { m.mu.RLock() defer m.mu.RUnlock() var result []TxHash for txHash, expire := range m.txHashes { - if blockHeight > expire { + if blockTime.After(expire) { result = append(result, txHash) } } @@ -178,21 +178,17 @@ func (m *UnorderedTxManager) purge(txHashes []TxHash) { // purgeLoop removes expired tx hashes in the background func (m *UnorderedTxManager) purgeLoop() error { for { - blocks := channelBatchRecv(m.blockCh) - if len(blocks) == 0 { - // channel closed - break - } - - latest := *blocks[len(blocks)-1] - hashes := m.expired(latest) - if len(hashes) > 0 { - m.purge(hashes) - } + latestTime, ok := m.batchReceive() + if !ok { + // channel closed + return + } - // avoid burning cpu in catching up phase - time.Sleep(PurgeLoopSleepMS * time.Millisecond) - } + hashes := m.expiredTxs(latestTime) + if len(hashes) > 0 { + m.purge(hashes) + } + } } @@ -237,14 +233,14 @@ verification and map lookup. ```golang const ( - // DefaultMaxUnOrderedTTL defines the default maximum TTL an un-ordered transaction + // DefaultMaxTimeoutDuration defines the default maximum duration an un-ordered transaction // can set. - DefaultMaxUnOrderedTTL = 1024 + DefaultMaxTimeoutDuration = time.Minute * 40 ) type DedupTxDecorator struct { m *UnorderedTxManager - maxUnOrderedTTL uint64 + maxTimeoutDuration time.Time } func (d *DedupTxDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, simulate bool, next sdk.AnteHandler) (sdk.Context, error) { @@ -253,13 +249,17 @@ func (d *DedupTxDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, simulate bool, return next(ctx, tx, simulate) } - if tx.TimeoutHeight() == 0 { - return nil, errorsmod.Wrap(sdkerrors.ErrLogic, "unordered tx must set timeout-height") - } - - if tx.TimeoutHeight() > ctx.BlockHeight() + d.maxUnOrderedTTL { - return nil, errorsmod.Wrapf(sdkerrors.ErrLogic, "unordered tx ttl exceeds %d", d.maxUnOrderedTTL) - } + headerInfo := d.env.HeaderService.HeaderInfo(ctx) + timeoutTimestamp := unorderedTx.GetTimeoutTimeStamp() + if timeoutTimestamp.IsZero() || timeoutTimestamp.Unix() == 0 { + return ctx, errorsmod.Wrap(sdkerrors.ErrInvalidRequest, "unordered transaction must have timeout_timestamp set") + } + if timeoutTimestamp.Before(headerInfo.Time) { + return ctx, errorsmod.Wrap(sdkerrors.ErrInvalidRequest, "unordered transaction has a timeout_timestamp that has already passed") + } + if timeoutTimestamp.After(headerInfo.Time.Add(d.maxTimeoutDuration)) { + return ctx, errorsmod.Wrapf(sdkerrors.ErrInvalidRequest, "unordered tx ttl exceeds %s", d.maxTimeoutDuration.String()) + } // in order to create a deterministic hash based on the tx, we need to hash the contents of the tx with signature // Get a Buffer from the pool @@ -302,7 +302,7 @@ encoding is not malleable. If a given transaction, which is otherwise valid, can be encoded to produce different hashes, which reflect the same valid transaction, then a duplicate unordered transaction can be submitted and included in a block. -In order to prevent this, the decoded transaction contents is taken. Starting with the content of the transaction we marshal the transaction in order to prevent a client reordering the transaction. Next we include the gas and timeout height as part of the identifier. All these fields are signed over in the transaction payload. If one of them changes the signature will not match the transaction. +In order to prevent this, the decoded transaction contents is taken. Starting with the content of the transaction we marshal the transaction in order to prevent a client reordering the transaction. Next we include the gas and timeout timestamp as part of the identifier. All these fields are signed over in the transaction payload. If one of them changes the signature will not match the transaction. ### State Management diff --git a/docs/architecture/adr-071-bank-v2.md b/docs/architecture/adr-071-bank-v2.md new file mode 100644 index 000000000000..5067a6f14f93 --- /dev/null +++ b/docs/architecture/adr-071-bank-v2.md @@ -0,0 +1,109 @@ +# ADR-71 Bank V2 + +## Status + +DRAFT + +## Changelog + +* 2024-05-08: Initial Draft (@samricotta, @julienrbrt) + +## Abstract + +The primary objective of refactoring the bank module is to simplify and enhance the functionality of the Cosmos SDK. Over time the bank module has been burdened with numerous responsibilities including transaction handling, account restrictions, delegation counting, and the minting and burning of coins. + +In addition to the above, the bank module is currently too rigid and handles too many tasks, so this proposal aims to streamline the module by focusing on core functions `Send`, `Mint`, and `Burn`. + +Currently, the module is split across different keepers with scattered and duplicates functionalities (with 4 send functions for instance). + +Additionally, the integration of the token factory into the bank module allows for standardization, and better integration within the core modules. + +This rewrite will reduce complexity and enhance the efficiency and UX of the bank module. + +## Context + +The current implementation of the bank module is characterised by its handling of a broad array of functions, leading to significant complexity in using and extending the bank module. + +These issues have underscored the need for a refactoring strategy that simplifies the module’s architecture and focuses on its most essential operations. + +Additionally, there is an overlap in functionality with a Token Factory module, which could be integrated to streamline oper. + +## Decision + +**Permission Tightening**: Access to the module can be restricted to selected denominations only, ensuring that it operates within designated boundaries and does not exceed its intended scope. Currently, the permissions allow all denoms, so this should be changed. Send restrictions functionality will be maintained. + +**Simplification of Logic**: The bank module will focus on core functionalities `Send`, `Mint`, and `Burn`. This refinement aims to streamline the architecture, enhancing both maintainability and performance. + +**Integration of Token Factory**: The Token Factory will be merged into the bank module. This consolidation of related functionalities aims to reduce redundancy and enhance coherence within the system. Migrations functions will be provided for migrating from Osmosis' Token Factory module to bank/v2. + +**Legacy Support**: A legacy wrapper will be implemented to ensure compatibility with about 90% of existing functions. This measure will facilitate a smooth transition while keeping older systems functional. + +**Denom Implementation**: A asset interface will be added to standardise interactions such as transfers, balance inquiries, minting, and burning across different tokens. This will allow the bank module to support arbitrary asset types, enabling developers to implement custom, ERC20-like denominations. + +For example, currently if a team would like to extend the transfer method the changes would apply universally, affecting all denom’s. With the proposed Asset Interface, it allows teams to customise or extend the transfer method specifically for their own tokens without impacting others. + +These improvements are expected to enhance the flexibility of the bank module, allowing for the creation of custom tokens similar to ERC20 standards and assets backed by CosmWasm (CW) contracts. The integration efforts will also aim to unify CW20 with bank coins across the Cosmos chains. + +Example of denom interface: + +```go +type AssetInterface interface { + Transfer(ctx sdk.Context, from sdk.AccAddress, to sdk.AccAddress, amount sdk.Coin) error + Mint(ctx sdk.Context, to sdk.AccAddress, amount sdk.Coin) error + Burn(ctx sdk.Context, from sdk.AccAddress, amount sdk.Coin) error + QueryBalance(ctx sdk.Context, account sdk.AccAddress) (sdk.Coin, error) +} +``` + +Overview of flow: + +1. Alice initiates a transfer by entering Bob's address and the amount (100 ATOM) +2. The Bank module verifies that the ATOM token implements the `AssetInterface` by querying the `ATOM_Denom_Account`, which is an `x/account` denom account. +3. The Bank module executes the transfer by subtracting 100 ATOM from Alice’s balance and adding 100 ATOM to Bob’s balance. +4. The Bank module calls the Transfer method on the `ATOM_Denom_Account`. The Transfer method, defined in the `AssetInterface`, handles the logic to subtract 100 ATOM from Alice’s balance and add 100 ATOM to Bob’s balance. +5. The Bank module updates the chain and returns the new balances. +6. Both Alice and Bob successfully receive the updated balances. + + + + + + + + + + +## Migration Plans + +Bank is a widely used module, so getting a v2 needs to be thought thoroughly. In order to not force all dependencies to immediately migrate to bank/v2, the same _upgrading_ path will be taken as for the `gov` module. + +This means `cosmossdk.io/bank` will stay one module and there won't be a new `cosmossdk.io/bank/v2` go module. Instead the bank protos will be versioned from `v1beta1` (current bank) to `v2`. + +Bank `v1beta1` endpoints will use the new bank v2 implementation for maximum backward compatibility. + +The bank `v1beta1` keepers will be deprecated and potentially eventually removed, but its proto and messages definitions will remain. + +Additionally, as bank plans to integrate token factory, migrations functions will be provided to migrate from Osmosis token factory implementation (most widely used implementation) to the new bank/v2 token factory. + +## Consequences + +### Positive + +* Simplified interaction with bank APIs +* Backward compatible changes (no contracts or apis broken) +* Optional migration (note: bank `v1beta1` won't get any new feature after bank `v2` release) + +### Neutral + +* Asset implementation not available cross-chain (IBC-ed custom asset should possibly fallback to the default implementation) +* Many assets may slow down bank balances requests + +### Negative + +* Temporarily duplicate functionalities as bank `v1beta1` are `v2` are living alongside +* Difficultity to ever completely remove bank `v1beta1` + +### References + +* Current bank module implementation: https://github.com/cosmos/cosmos-sdk/blob/v0.50.6/x/bank/keeper/keeper.go#L22-L53 +* Osmosis token factory: https://github.com/osmosis-labs/osmosis/tree/v25.0.0/x/tokenfactory/keeper diff --git a/docs/architecture/bankv2.png b/docs/architecture/bankv2.png new file mode 100644 index 000000000000..4123dbf5ed5d Binary files /dev/null and b/docs/architecture/bankv2.png differ diff --git a/docs/learn/advanced/00-baseapp.md b/docs/learn/advanced/00-baseapp.md index 8a4fa12b3a15..61e71f28d779 100644 --- a/docs/learn/advanced/00-baseapp.md +++ b/docs/learn/advanced/00-baseapp.md @@ -480,7 +480,7 @@ https://github.com/cosmos/cosmos-sdk/blob/v0.50.0-alpha.0/baseapp/abci.go#L623 When the underlying consensus engine receives a block proposal, each transaction in the block needs to be processed by the application. To that end, the underlying consensus engine sends the transactions in FinalizeBlock message to the application for each transaction in a sequential order. -Since `FinalizeBlock` is an ABCI call, `Tx` is received in the encoded `[]byte` form. Nodes first unmarshal the transaction, using the [`TxConfig`](./00-app-anatomy.md#register-codec) defined in the app, then call `runTx` in `execModeFinalize`, which is very similar to `CheckTx` but also executes and writes state changes. +Since `FinalizeBlock` is an ABCI call, `Tx` is received in the encoded `[]byte` form. Nodes first unmarshal the transaction, using the [`TxConfig`](../beginner/00-app-anatomy.md#register-codec) defined in the app, then call `runTx` in `execModeFinalize`, which is very similar to `CheckTx` but also executes and writes state changes. ![blockprocessing](./blockprocessing-1.png) diff --git a/go.mod b/go.mod index b575c28b25bd..217ad6e2ee99 100644 --- a/go.mod +++ b/go.mod @@ -7,7 +7,7 @@ require ( cosmossdk.io/collections v0.4.0 cosmossdk.io/core v0.12.1-0.20231114100755-569e3ff6a0d7 cosmossdk.io/core/testing v0.0.0-00010101000000-000000000000 - cosmossdk.io/depinject v1.0.0-alpha.4 + cosmossdk.io/depinject v1.0.0 cosmossdk.io/errors v1.0.1 cosmossdk.io/log v1.3.1 cosmossdk.io/math v1.3.0 @@ -85,7 +85,7 @@ require ( github.com/cockroachdb/redact v1.1.5 // indirect github.com/cockroachdb/tokenbucket v0.0.0-20230807174530-cc333fc44b06 // indirect github.com/cometbft/cometbft-db v0.12.0 // indirect - github.com/cosmos/iavl v1.2.0 // indirect + github.com/cosmos/iavl v1.2.1-0.20240725141113-7adc688cf179 // indirect github.com/cosmos/ics23/go v0.10.0 // indirect github.com/danieljoos/wincred v1.2.1 // indirect github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect @@ -188,8 +188,6 @@ replace ( cosmossdk.io/collections => ./collections cosmossdk.io/core => ./core cosmossdk.io/core/testing => ./core/testing - cosmossdk.io/depinject => ./depinject - cosmossdk.io/log => ./log cosmossdk.io/store => ./store cosmossdk.io/x/accounts => ./x/accounts cosmossdk.io/x/auth => ./x/auth diff --git a/go.sum b/go.sum index 1cb148b54b7d..c63d7cbaf794 100644 --- a/go.sum +++ b/go.sum @@ -4,8 +4,12 @@ buf.build/gen/go/cosmos/gogo-proto/protocolbuffers/go v1.34.2-20240130113600-88e buf.build/gen/go/cosmos/gogo-proto/protocolbuffers/go v1.34.2-20240130113600-88ef6483f90f.2/go.mod h1:HqcXMSa5qnNuakaMUo+hWhF51mKbcrZxGl9Vp5EeJXc= cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= cloud.google.com/go v0.34.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= +cosmossdk.io/depinject v1.0.0 h1:dQaTu6+O6askNXO06+jyeUAnF2/ssKwrrszP9t5q050= +cosmossdk.io/depinject v1.0.0/go.mod h1:zxK/h3HgHoA/eJVtiSsoaRaRA2D5U4cJ5thIG4ssbB8= cosmossdk.io/errors v1.0.1 h1:bzu+Kcr0kS/1DuPBtUFdWjzLqyUuCiyHjyJB6srBV/0= cosmossdk.io/errors v1.0.1/go.mod h1:MeelVSZThMi4bEakzhhhE/CKqVv3nOJDA25bIqRDu/U= +cosmossdk.io/log v1.3.1 h1:UZx8nWIkfbbNEWusZqzAx3ZGvu54TZacWib3EzUYmGI= +cosmossdk.io/log v1.3.1/go.mod h1:2/dIomt8mKdk6vl3OWJcPk2be3pGOS8OQaLUM/3/tCM= cosmossdk.io/math v1.3.0 h1:RC+jryuKeytIiictDslBP9i1fhkVm6ZDmZEoNP316zE= cosmossdk.io/math v1.3.0/go.mod h1:vnRTxewy+M7BtXBNFybkuhSH4WfedVAAnERHgVFhp3k= cosmossdk.io/schema v0.1.1 h1:I0M6pgI7R10nq+/HCQfbO6BsGBZA8sQy+duR1Y3aKcA= @@ -104,8 +108,8 @@ github.com/cosmos/gogogateway v1.2.0/go.mod h1:iQpLkGWxYcnCdz5iAdLcRBSw3h7NXeOkZ github.com/cosmos/gogoproto v1.4.2/go.mod h1:cLxOsn1ljAHSV527CHOtaIP91kK6cCrZETRBrkzItWU= github.com/cosmos/gogoproto v1.5.0 h1:SDVwzEqZDDBoslaeZg+dGE55hdzHfgUA40pEanMh52o= github.com/cosmos/gogoproto v1.5.0/go.mod h1:iUM31aofn3ymidYG6bUR5ZFrk+Om8p5s754eMUcyp8I= -github.com/cosmos/iavl v1.2.0 h1:kVxTmjTh4k0Dh1VNL046v6BXqKziqMDzxo93oh3kOfM= -github.com/cosmos/iavl v1.2.0/go.mod h1:HidWWLVAtODJqFD6Hbne2Y0q3SdxByJepHUOeoH4LiI= +github.com/cosmos/iavl v1.2.1-0.20240725141113-7adc688cf179 h1:wmwDn7V3RodN9auB3FooSQxs46nHVE3u0mb87TJkZFE= +github.com/cosmos/iavl v1.2.1-0.20240725141113-7adc688cf179/go.mod h1:GiM43q0pB+uG53mLxLDzimxM9l/5N9UuSY3/D0huuVw= github.com/cosmos/ics23/go v0.10.0 h1:iXqLLgp2Lp+EdpIuwXTYIQU+AiHj9mOC2X9ab++bZDM= github.com/cosmos/ics23/go v0.10.0/go.mod h1:ZfJSmng/TBNTBkFemHHHj5YY7VAU/MBU980F4VU1NG0= github.com/cosmos/keyring v1.2.0 h1:8C1lBP9xhImmIabyXW4c3vFjjLiBdGCmfLUfeZlV1Yo= diff --git a/indexer/postgres/base_sql.go b/indexer/postgres/base_sql.go index 81e1ac704242..32eb38f364c0 100644 --- a/indexer/postgres/base_sql.go +++ b/indexer/postgres/base_sql.go @@ -5,4 +5,29 @@ const BaseSQL = ` CREATE OR REPLACE FUNCTION nanos_to_timestamptz(nanos bigint) RETURNS timestamptz AS $$ SELECT to_timestamp(nanos / 1000000000) + (nanos / 1000000000) * INTERVAL '1 microsecond' $$ LANGUAGE SQL IMMUTABLE; + +CREATE TABLE IF NOT EXISTS block +( + number BIGINT NOT NULL PRIMARY KEY, + header JSONB NULL +); + +CREATE TABLE IF NOT EXISTS tx +( + id BIGSERIAL PRIMARY KEY, + block_number BIGINT NOT NULL REFERENCES block (number), + index_in_block BIGINT NOT NULL, + data JSONB NOT NULL +); + +CREATE TABLE IF NOT EXISTS event +( + id BIGSERIAL PRIMARY KEY, + block_number BIGINT NOT NULL REFERENCES block (number), + tx_id BIGINT NULL REFERENCES tx (id), + msg_index BIGINT NULL, + event_index BIGINT NULL, + type TEXT NOT NULL, + data JSONB NOT NULL +); ` diff --git a/indexer/postgres/column.go b/indexer/postgres/column.go index f9692af13711..188e9d8da651 100644 --- a/indexer/postgres/column.go +++ b/indexer/postgres/column.go @@ -25,7 +25,7 @@ func (tm *ObjectIndexer) createColumnDefinition(writer io.Writer, field schema.F } else { switch field.Kind { case schema.EnumKind: - _, err = fmt.Fprintf(writer, "%q", enumTypeName(tm.moduleName, field.EnumDefinition)) + _, err = fmt.Fprintf(writer, "%q", enumTypeName(tm.moduleName, field.EnumType)) if err != nil { return err } @@ -100,7 +100,7 @@ func simpleColumnType(kind schema.Kind) string { return "JSONB" case schema.DurationKind: return "BIGINT" - case schema.Bech32AddressKind: + case schema.AddressKind: return "TEXT" default: return "" diff --git a/indexer/postgres/enum.go b/indexer/postgres/enum.go index c438257d2020..709fc9039562 100644 --- a/indexer/postgres/enum.go +++ b/indexer/postgres/enum.go @@ -11,7 +11,7 @@ import ( ) // CreateEnumType creates an enum type in the database. -func (m *ModuleIndexer) CreateEnumType(ctx context.Context, conn DBConn, enum schema.EnumDefinition) error { +func (m *ModuleIndexer) CreateEnumType(ctx context.Context, conn DBConn, enum schema.EnumType) error { typeName := enumTypeName(m.moduleName, enum) row := conn.QueryRowContext(ctx, "SELECT 1 FROM pg_type WHERE typname = $1", typeName) var res interface{} @@ -39,7 +39,7 @@ func (m *ModuleIndexer) CreateEnumType(ctx context.Context, conn DBConn, enum sc } // CreateEnumTypeSql generates a CREATE TYPE statement for the enum definition. -func CreateEnumTypeSql(writer io.Writer, moduleName string, enum schema.EnumDefinition) error { +func CreateEnumTypeSql(writer io.Writer, moduleName string, enum schema.EnumType) error { _, err := fmt.Fprintf(writer, "CREATE TYPE %q AS ENUM (", enumTypeName(moduleName, enum)) if err != nil { return err @@ -63,30 +63,6 @@ func CreateEnumTypeSql(writer io.Writer, moduleName string, enum schema.EnumDefi } // enumTypeName returns the name of the enum type scoped to the module. -func enumTypeName(moduleName string, enum schema.EnumDefinition) string { +func enumTypeName(moduleName string, enum schema.EnumType) string { return fmt.Sprintf("%s_%s", moduleName, enum.Name) } - -// createEnumTypesForFields creates enum types for all the fields that have enum kind in the module schema. -func (m *ModuleIndexer) createEnumTypesForFields(ctx context.Context, conn DBConn, fields []schema.Field) error { - for _, field := range fields { - if field.Kind != schema.EnumKind { - continue - } - - if _, ok := m.definedEnums[field.EnumDefinition.Name]; ok { - // if the enum type is already defined, skip - // we assume validation already happened - continue - } - - err := m.CreateEnumType(ctx, conn, field.EnumDefinition) - if err != nil { - return err - } - - m.definedEnums[field.EnumDefinition.Name] = field.EnumDefinition - } - - return nil -} diff --git a/indexer/postgres/go.mod b/indexer/postgres/go.mod index d85dbc46718e..b0423dde0744 100644 --- a/indexer/postgres/go.mod +++ b/indexer/postgres/go.mod @@ -9,3 +9,5 @@ go 1.12 // This module should only use the golang standard library (database/sql) // and cosmossdk.io/indexer/base. require cosmossdk.io/schema v0.1.1 + +replace cosmossdk.io/schema => ../../schema diff --git a/indexer/postgres/go.sum b/indexer/postgres/go.sum index 6a92c3d3ec66..e69de29bb2d1 100644 --- a/indexer/postgres/go.sum +++ b/indexer/postgres/go.sum @@ -1,2 +0,0 @@ -cosmossdk.io/schema v0.1.1 h1:I0M6pgI7R10nq+/HCQfbO6BsGBZA8sQy+duR1Y3aKcA= -cosmossdk.io/schema v0.1.1/go.mod h1:RDAhxIeNB4bYqAlF4NBJwRrgtnciMcyyg0DOKnhNZQQ= diff --git a/indexer/postgres/indexer.go b/indexer/postgres/indexer.go index afcd8e0d8dbf..a69eefff1cd0 100644 --- a/indexer/postgres/indexer.go +++ b/indexer/postgres/indexer.go @@ -3,6 +3,7 @@ package postgres import ( "context" "database/sql" + "errors" "fmt" "cosmossdk.io/schema/appdata" @@ -23,7 +24,7 @@ type SqlLogger = func(msg, sql string, params ...interface{}) func StartIndexer(ctx context.Context, logger SqlLogger, config Config) (appdata.Listener, error) { if config.DatabaseURL == "" { - return appdata.Listener{}, fmt.Errorf("missing database URL") + return appdata.Listener{}, errors.New("missing database URL") } driver := config.DatabaseDriver diff --git a/indexer/postgres/internal/testdata/example_schema.go b/indexer/postgres/internal/testdata/example_schema.go index ccdd39d96c35..ff2d4f2ed1b4 100644 --- a/indexer/postgres/internal/testdata/example_schema.go +++ b/indexer/postgres/internal/testdata/example_schema.go @@ -29,22 +29,26 @@ func init() { switch i { case schema.EnumKind: - field.EnumDefinition = MyEnum - case schema.Bech32AddressKind: - field.AddressPrefix = "foo" + field.EnumType = MyEnum default: } AllKindsObject.ValueFields = append(AllKindsObject.ValueFields, field) } - ExampleSchema = schema.ModuleSchema{ - ObjectTypes: []schema.ObjectType{ - AllKindsObject, - SingletonObject, - VoteObject, - }, + ExampleSchema = mustModuleSchema([]schema.ObjectType{ + AllKindsObject, + SingletonObject, + VoteObject, + }) +} + +func mustModuleSchema(objectTypes []schema.ObjectType) schema.ModuleSchema { + s, err := schema.NewModuleSchema(objectTypes) + if err != nil { + panic(err) } + return s } var SingletonObject = schema.ObjectType{ @@ -60,9 +64,9 @@ var SingletonObject = schema.ObjectType{ Nullable: true, }, { - Name: "an_enum", - Kind: schema.EnumKind, - EnumDefinition: MyEnum, + Name: "an_enum", + Kind: schema.EnumKind, + EnumType: MyEnum, }, }, } @@ -76,14 +80,14 @@ var VoteObject = schema.ObjectType{ }, { Name: "address", - Kind: schema.Bech32AddressKind, + Kind: schema.AddressKind, }, }, ValueFields: []schema.Field{ { Name: "vote", Kind: schema.EnumKind, - EnumDefinition: schema.EnumDefinition{ + EnumType: schema.EnumType{ Name: "vote_type", Values: []string{"yes", "no", "abstain"}, }, @@ -92,7 +96,7 @@ var VoteObject = schema.ObjectType{ RetainDeletions: true, } -var MyEnum = schema.EnumDefinition{ +var MyEnum = schema.EnumType{ Name: "my_enum", Values: []string{"a", "b", "c"}, } diff --git a/indexer/postgres/module.go b/indexer/postgres/module.go index 57564700b78a..0d6a28e2ef72 100644 --- a/indexer/postgres/module.go +++ b/indexer/postgres/module.go @@ -12,7 +12,7 @@ type ModuleIndexer struct { moduleName string schema schema.ModuleSchema tables map[string]*ObjectIndexer - definedEnums map[string]schema.EnumDefinition + definedEnums map[string]schema.EnumType options Options } @@ -22,7 +22,7 @@ func NewModuleIndexer(moduleName string, modSchema schema.ModuleSchema, options moduleName: moduleName, schema: modSchema, tables: map[string]*ObjectIndexer{}, - definedEnums: map[string]schema.EnumDefinition{}, + definedEnums: map[string]schema.EnumType{}, options: options, } } @@ -30,29 +30,27 @@ func NewModuleIndexer(moduleName string, modSchema schema.ModuleSchema, options // InitializeSchema creates tables for all object types in the module schema and creates enum types. func (m *ModuleIndexer) InitializeSchema(ctx context.Context, conn DBConn) error { // create enum types - for _, typ := range m.schema.ObjectTypes { - err := m.createEnumTypesForFields(ctx, conn, typ.KeyFields) - if err != nil { - return err - } - - err = m.createEnumTypesForFields(ctx, conn, typ.ValueFields) - if err != nil { - return err - } + var err error + m.schema.EnumTypes(func(enumType schema.EnumType) bool { + err = m.CreateEnumType(ctx, conn, enumType) + return err == nil + }) + if err != nil { + return err } // create tables for all object types - for _, typ := range m.schema.ObjectTypes { + m.schema.ObjectTypes(func(typ schema.ObjectType) bool { tm := NewObjectIndexer(m.moduleName, typ, m.options) m.tables[typ.Name] = tm - err := tm.CreateTable(ctx, conn) + err = tm.CreateTable(ctx, conn) if err != nil { - return fmt.Errorf("failed to create table for %s in module %s: %v", typ.Name, m.moduleName, err) //nolint:errorlint // using %v for go 1.12 compat + err = fmt.Errorf("failed to create table for %s in module %s: %v", typ.Name, m.moduleName, err) //nolint:errorlint // using %v for go 1.12 compat } - } + return err == nil + }) - return nil + return err } // ObjectIndexers returns the object indexers for the module. diff --git a/indexer/postgres/tests/go.mod b/indexer/postgres/tests/go.mod index d5a29304251f..0353ba6091b5 100644 --- a/indexer/postgres/tests/go.mod +++ b/indexer/postgres/tests/go.mod @@ -30,4 +30,6 @@ require ( replace cosmossdk.io/indexer/postgres => ../. +replace cosmossdk.io/schema => ../../../schema + go 1.22 diff --git a/indexer/postgres/tests/go.sum b/indexer/postgres/tests/go.sum index a4ba87b486c2..de3d49d74702 100644 --- a/indexer/postgres/tests/go.sum +++ b/indexer/postgres/tests/go.sum @@ -1,5 +1,3 @@ -cosmossdk.io/schema v0.1.1 h1:I0M6pgI7R10nq+/HCQfbO6BsGBZA8sQy+duR1Y3aKcA= -cosmossdk.io/schema v0.1.1/go.mod h1:RDAhxIeNB4bYqAlF4NBJwRrgtnciMcyyg0DOKnhNZQQ= github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc h1:U9qPSI2PIWSS1VwoXQT9A3Wy9MM3WgvqSxFWenqJduM= diff --git a/indexer/postgres/tests/init_schema_test.go b/indexer/postgres/tests/init_schema_test.go index 1afa6caea9b4..8c4288ba344f 100644 --- a/indexer/postgres/tests/init_schema_test.go +++ b/indexer/postgres/tests/init_schema_test.go @@ -9,9 +9,7 @@ import ( embeddedpostgres "github.com/fergusstrange/embedded-postgres" "github.com/hashicorp/consul/sdk/freeport" - - // this is where we get our pgx database driver from - _ "github.com/jackc/pgx/v5/stdlib" + _ "github.com/jackc/pgx/v5/stdlib" // this is where we get our pgx database driver from "github.com/stretchr/testify/require" "gotest.tools/v3/golden" diff --git a/internal/testutil/cmd_test.go b/internal/testutil/cmd_test.go index 2544b2467c44..4151360b9a0d 100644 --- a/internal/testutil/cmd_test.go +++ b/internal/testutil/cmd_test.go @@ -1,6 +1,7 @@ package testutil_test import ( + "errors" "fmt" "testing" @@ -21,7 +22,7 @@ func TestSetArgsWithOriginalMethod(t *testing.T) { c, _ := cmd.Flags().GetBool("c") switch { case a && b, a && c, b && c: - return fmt.Errorf("a,b,c only one could be true") + return errors.New("a,b,c only one could be true") } return nil }, diff --git a/log/CHANGELOG.md b/log/CHANGELOG.md index ae04009a9918..ca750f3ff9f8 100644 --- a/log/CHANGELOG.md +++ b/log/CHANGELOG.md @@ -22,6 +22,8 @@ Each entry must include the Github issue reference in the following format: ## [Unreleased] +* [#21045](https://github.com/cosmos/cosmos-sdk/pull/21045) Add `WithContext` method implementations to make all returned loggers compatible with `cosmossdk.io/core/log.Logger` without a direct dependency. + ## [v1.3.1](https://github.com/cosmos/cosmos-sdk/releases/tag/log/v1.3.0) - 2024-02-05 * [#19346](https://github.com/cosmos/cosmos-sdk/pull/19346) Upgrade zerolog to v1.32.0. diff --git a/log/go.mod b/log/go.mod index da7c3d4d64a3..8ad68695218b 100644 --- a/log/go.mod +++ b/log/go.mod @@ -3,24 +3,14 @@ module cosmossdk.io/log go 1.20 require ( - cosmossdk.io/core v0.12.0 - cosmossdk.io/core/testing v0.0.0-00010101000000-000000000000 github.com/pkg/errors v0.9.1 github.com/rs/zerolog v1.33.0 gotest.tools/v3 v3.5.1 ) require ( - github.com/cosmos/gogoproto v1.5.0 // indirect github.com/google/go-cmp v0.6.0 // indirect github.com/mattn/go-colorable v0.1.13 // indirect github.com/mattn/go-isatty v0.0.20 // indirect - github.com/tidwall/btree v1.7.0 // indirect - golang.org/x/exp v0.0.0-20231006140011-7918f672742d // indirect golang.org/x/sys v0.22.0 // indirect - google.golang.org/protobuf v1.34.2 // indirect ) - -replace cosmossdk.io/core => ../core - -replace cosmossdk.io/core/testing => ../core/testing diff --git a/log/go.sum b/log/go.sum index c8715b25f591..12553f8dc11e 100644 --- a/log/go.sum +++ b/log/go.sum @@ -1,8 +1,5 @@ github.com/coreos/go-systemd/v22 v22.5.0/go.mod h1:Y58oyj3AT4RCenI/lSvhwexgC+NSVTIJ3seZv2GcEnc= -github.com/cosmos/gogoproto v1.5.0 h1:SDVwzEqZDDBoslaeZg+dGE55hdzHfgUA40pEanMh52o= -github.com/cosmos/gogoproto v1.5.0/go.mod h1:iUM31aofn3ymidYG6bUR5ZFrk+Om8p5s754eMUcyp8I= github.com/godbus/dbus/v5 v5.0.4/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA= -github.com/golang/protobuf v1.5.3 h1:KhyjKVUg7Usr/dYsdSqoFveMYd5ko72D+zANwlG1mmg= github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI= github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= github.com/mattn/go-colorable v0.1.13 h1:fFA4WZxdEF4tXPZVKMLwD8oUnCTTo08duU7wxecdEvA= @@ -16,16 +13,10 @@ github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINE github.com/rs/xid v1.5.0/go.mod h1:trrq9SKmegXys3aeAKXMUTdJsYXVwGY3RLcfgqegfbg= github.com/rs/zerolog v1.33.0 h1:1cU2KZkvPxNyfgEmhHAz/1A9Bz+llsdYzklWFzgp0r8= github.com/rs/zerolog v1.33.0/go.mod h1:/7mN4D5sKwJLZQ2b/znpjC3/GQWY/xaDXUM0kKWRHss= -github.com/tidwall/btree v1.7.0 h1:L1fkJH/AuEh5zBnnBbmTwQ5Lt+bRJ5A8EWecslvo9iI= -github.com/tidwall/btree v1.7.0/go.mod h1:twD9XRA5jj9VUQGELzDO4HPQTNJsoWWfYEL+EUQ2cKY= -golang.org/x/exp v0.0.0-20231006140011-7918f672742d h1:jtJma62tbqLibJ5sFQz8bKtEM8rJBtfilJ2qTU199MI= -golang.org/x/exp v0.0.0-20231006140011-7918f672742d/go.mod h1:ldy0pHrwJyGW56pPQzzkH36rKxoZW1tw7ZJpeKx+hdo= golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.12.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.22.0 h1:RI27ohtqKCnwULzJLqkv897zojh5/DwS/ENaMzUOaWI= golang.org/x/sys v0.22.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= -google.golang.org/protobuf v1.34.2 h1:6xV6lTsCfpGD21XK49h7MhtcApnLqkfYgPcdHftf6hg= -google.golang.org/protobuf v1.34.2/go.mod h1:qYOHts0dSfpeUzUFpOMr/WGzszTmLH+DiWniOlNbLDw= gotest.tools/v3 v3.5.1 h1:EENdUnS3pdur5nybKYIh2Vfgc8IUNBjxDPSjtiJcOzU= gotest.tools/v3 v3.5.1/go.mod h1:isy3WKz7GK6uNw/sbHzfKBLvlvXwUyV06n6brMxxopU= diff --git a/log/logger.go b/log/logger.go index f57c7690b414..38802ed88e73 100644 --- a/log/logger.go +++ b/log/logger.go @@ -9,9 +9,6 @@ import ( "github.com/pkg/errors" "github.com/rs/zerolog" "github.com/rs/zerolog/pkgerrors" - - corelog "cosmossdk.io/core/log" - coretesting "cosmossdk.io/core/testing" ) func init() { @@ -30,15 +27,39 @@ func init() { } // ModuleKey defines a module logging key. -const ModuleKey = corelog.ModuleKey +const ModuleKey = "module" // ContextKey is used to store the logger in the context. var ContextKey struct{} // Logger is the Cosmos SDK logger interface. -// It maintains as much backward compatibility with the CometBFT logger as possible. -// All functionalities of the logger are available through the Impl() method. -type Logger = corelog.Logger +// It extends cosmossdk.io/core/log.Logger to return a child logger. +// Use cosmossdk.io/core/log.Logger instead in modules. +type Logger interface { + // Info takes a message and a set of key/value pairs and logs with level INFO. + // The key of the tuple must be a string. + Info(msg string, keyVals ...any) + + // Warn takes a message and a set of key/value pairs and logs with level WARN. + // The key of the tuple must be a string. + Warn(msg string, keyVals ...any) + + // Error takes a message and a set of key/value pairs and logs with level ERR. + // The key of the tuple must be a string. + Error(msg string, keyVals ...any) + + // Debug takes a message and a set of key/value pairs and logs with level DEBUG. + // The key of the tuple must be a string. + Debug(msg string, keyVals ...any) + + // With returns a new wrapped logger with additional context provided by a set. + With(keyVals ...any) Logger + + // Impl returns the underlying logger implementation. + // It is used to access the full functionalities of the underlying logger. + // Advanced users can type cast the returned value to the actual logger. + Impl() any +} // WithJSONMarshal configures zerolog global json encoding. func WithJSONMarshal(marshaler func(v any) ([]byte, error)) { @@ -68,6 +89,7 @@ type zeroLogWrapper struct { // // Stderr is the typical destination for logs, // so that any output from your application can still be piped to other processes. +// The returned value can be safely cast to cosmossdk.io/core/log.Logger. func NewLogger(dst io.Writer, options ...Option) Logger { logCfg := defaultConfig for _, opt := range options { @@ -144,6 +166,12 @@ func (l zeroLogWrapper) With(keyVals ...interface{}) Logger { return zeroLogWrapper{&logger} } +// WithContext returns a new wrapped logger with additional context provided by a set. +func (l zeroLogWrapper) WithContext(keyVals ...interface{}) any { + logger := l.Logger.With().Fields(keyVals).Logger() + return zeroLogWrapper{&logger} +} + // Impl returns the underlying zerolog logger. // It can be used to used zerolog structured API directly instead of the wrapper. func (l zeroLogWrapper) Impl() interface{} { @@ -151,38 +179,20 @@ func (l zeroLogWrapper) Impl() interface{} { } // NewNopLogger returns a new logger that does nothing. -var NewNopLogger = coretesting.NewNopLogger - -// LogWrapper wraps a Logger and implements the Logger interface. -// it is only meant to avoid breakage of legacy versions of the Logger interface. -type LogWrapper struct { - corelog.Logger -} - -func NewLogWrapper(logger corelog.Logger) Logger { - return LogWrapper{logger} -} - -func (l LogWrapper) Impl() interface{} { - return l.Logger -} - -func (l LogWrapper) With(keyVals ...interface{}) Logger { - return NewLogWrapper(l.Logger.With(keyVals...)) -} - -func (l LogWrapper) Info(msg string, keyVals ...interface{}) { - l.Logger.Info(msg, keyVals...) -} - -func (l LogWrapper) Warn(msg string, keyVals ...interface{}) { - l.Logger.Warn(msg, keyVals...) -} - -func (l LogWrapper) Error(msg string, keyVals ...interface{}) { - l.Logger.Error(msg, keyVals...) -} - -func (l LogWrapper) Debug(msg string, keyVals ...interface{}) { - l.Logger.Debug(msg, keyVals...) -} +func NewNopLogger() Logger { + // The custom nopLogger is about 3x faster than a zeroLogWrapper with zerolog.Nop(). + return nopLogger{} +} + +// nopLogger is a Logger that does nothing when called. +// See the "specialized nop logger" benchmark and compare with the "zerolog nop logger" benchmark. +// The custom implementation is about 3x faster. +type nopLogger struct{} + +func (nopLogger) Info(string, ...any) {} +func (nopLogger) Warn(string, ...any) {} +func (nopLogger) Error(string, ...any) {} +func (nopLogger) Debug(string, ...any) {} +func (nopLogger) With(...any) Logger { return nopLogger{} } +func (nopLogger) WithContext(...any) any { return nopLogger{} } +func (nopLogger) Impl() any { return nopLogger{} } diff --git a/math/dec.go b/math/dec.go index 49daf378ea75..3ed930d5c484 100644 --- a/math/dec.go +++ b/math/dec.go @@ -499,7 +499,7 @@ func (d LegacyDec) ApproxRoot(root uint64) (guess LegacyDec, err error) { return guess, nil } -// Power returns a the result of raising to a positive integer power +// Power returns the result of raising to a positive integer power func (d LegacyDec) Power(power uint64) LegacyDec { res := LegacyDec{new(big.Int).Set(d.i)} return res.PowerMut(power) diff --git a/orm/encoding/ormfield/uint32.go b/orm/encoding/ormfield/uint32.go index 0e770ad6b482..0da31691d9f6 100644 --- a/orm/encoding/ormfield/uint32.go +++ b/orm/encoding/ormfield/uint32.go @@ -2,7 +2,7 @@ package ormfield import ( "encoding/binary" - "fmt" + "errors" "io" "google.golang.org/protobuf/reflect/protoreflect" @@ -183,6 +183,6 @@ func DecodeCompactUint32(reader io.Reader) (uint32, error) { x |= uint32(buf[4]) return x, nil default: - return 0, fmt.Errorf("unexpected case") + return 0, errors.New("unexpected case") } } diff --git a/orm/encoding/ormfield/uint64.go b/orm/encoding/ormfield/uint64.go index 8623e516b155..43f08b0302c4 100644 --- a/orm/encoding/ormfield/uint64.go +++ b/orm/encoding/ormfield/uint64.go @@ -2,7 +2,7 @@ package ormfield import ( "encoding/binary" - "fmt" + "errors" "io" "google.golang.org/protobuf/reflect/protoreflect" @@ -213,6 +213,6 @@ func DecodeCompactUint64(reader io.Reader) (uint64, error) { x |= uint64(buf[8]) return x, nil default: - return 0, fmt.Errorf("unexpected case") + return 0, errors.New("unexpected case") } } diff --git a/orm/go.mod b/orm/go.mod index 86c7619af94c..7a290f798bff 100644 --- a/orm/go.mod +++ b/orm/go.mod @@ -5,7 +5,7 @@ go 1.21 require ( cosmossdk.io/api v0.7.5 cosmossdk.io/core v0.12.1-0.20231114100755-569e3ff6a0d7 - cosmossdk.io/depinject v1.0.0-alpha.4 + cosmossdk.io/depinject v1.0.0 cosmossdk.io/errors v1.0.1 github.com/cosmos/cosmos-db v1.0.2 github.com/cosmos/cosmos-proto v1.0.0-beta.5 @@ -68,7 +68,4 @@ require ( sigs.k8s.io/yaml v1.4.0 // indirect ) -replace ( - cosmossdk.io/core => ../core - cosmossdk.io/depinject => ../depinject -) +replace cosmossdk.io/core => ../core diff --git a/orm/go.sum b/orm/go.sum index ace3ac645255..4382ea973b42 100644 --- a/orm/go.sum +++ b/orm/go.sum @@ -1,5 +1,7 @@ cosmossdk.io/api v0.7.5 h1:eMPTReoNmGUm8DeiQL9DyM8sYDjEhWzL1+nLbI9DqtQ= cosmossdk.io/api v0.7.5/go.mod h1:IcxpYS5fMemZGqyYtErK7OqvdM0C8kdW3dq8Q/XIG38= +cosmossdk.io/depinject v1.0.0 h1:dQaTu6+O6askNXO06+jyeUAnF2/ssKwrrszP9t5q050= +cosmossdk.io/depinject v1.0.0/go.mod h1:zxK/h3HgHoA/eJVtiSsoaRaRA2D5U4cJ5thIG4ssbB8= cosmossdk.io/errors v1.0.1 h1:bzu+Kcr0kS/1DuPBtUFdWjzLqyUuCiyHjyJB6srBV/0= cosmossdk.io/errors v1.0.1/go.mod h1:MeelVSZThMi4bEakzhhhE/CKqVv3nOJDA25bIqRDu/U= github.com/DataDog/zstd v1.5.5 h1:oWf5W7GtOLgp6bciQYDmhHHjdhYkALu6S/5Ni9ZgSvQ= diff --git a/orm/internal/listinternal/options.go b/orm/internal/listinternal/options.go index fb5c254dc88d..45571b24af1d 100644 --- a/orm/internal/listinternal/options.go +++ b/orm/internal/listinternal/options.go @@ -1,7 +1,7 @@ package listinternal import ( - "fmt" + "errors" "google.golang.org/protobuf/proto" ) @@ -17,7 +17,7 @@ type Options struct { func (o Options) Validate() error { if len(o.Cursor) != 0 { if o.Offset > 0 { - return fmt.Errorf("can only specify one of cursor or offset") + return errors.New("can only specify one of cursor or offset") } } return nil diff --git a/orm/model/ormdb/module.go b/orm/model/ormdb/module.go index 35d264196a3e..5aebb7a02339 100644 --- a/orm/model/ormdb/module.go +++ b/orm/model/ormdb/module.go @@ -4,6 +4,7 @@ import ( "bytes" "context" "encoding/binary" + "errors" "fmt" "math" @@ -111,7 +112,7 @@ func NewModuleDB(schema *ormv1alpha1.ModuleSchemaDescriptor, options ModuleDBOpt case ormv1alpha1.StorageType_STORAGE_TYPE_MEMORY: service := options.MemoryStoreService if service == nil { - return nil, fmt.Errorf("missing MemoryStoreService") + return nil, errors.New("missing MemoryStoreService") } backendResolver = func(ctx context.Context) (ormtable.ReadBackend, error) { @@ -124,7 +125,7 @@ func NewModuleDB(schema *ormv1alpha1.ModuleSchemaDescriptor, options ModuleDBOpt case ormv1alpha1.StorageType_STORAGE_TYPE_TRANSIENT: service := options.TransientStoreService if service == nil { - return nil, fmt.Errorf("missing TransientStoreService") + return nil, errors.New("missing TransientStoreService") } backendResolver = func(ctx context.Context) (ormtable.ReadBackend, error) { diff --git a/orm/model/ormdb/module_test.go b/orm/model/ormdb/module_test.go index 2557cd857c96..4127a0b88bfe 100644 --- a/orm/model/ormdb/module_test.go +++ b/orm/model/ormdb/module_test.go @@ -4,7 +4,7 @@ import ( "bytes" "context" "encoding/json" - "fmt" + "errors" "strings" "testing" @@ -103,7 +103,7 @@ func (k keeper) Burn(ctx context.Context, acct, denom string, amount uint64) err } if amount > supply.Amount { - return fmt.Errorf("insufficient supply") + return errors.New("insufficient supply") } supply.Amount -= amount @@ -171,7 +171,7 @@ func (k keeper) safeSubBalance(ctx context.Context, acct, denom string, amount u } if amount > balance.Amount { - return fmt.Errorf("insufficient funds") + return errors.New("insufficient funds") } balance.Amount -= amount diff --git a/orm/model/ormtable/backend.go b/orm/model/ormtable/backend.go index 2c1f234187ff..adeccc87188c 100644 --- a/orm/model/ormtable/backend.go +++ b/orm/model/ormtable/backend.go @@ -2,6 +2,7 @@ package ormtable import ( "context" + "errors" "fmt" "cosmossdk.io/core/store" @@ -182,7 +183,7 @@ var defaultContextKey = contextKeyType("backend") func getBackendDefault(ctx context.Context) (ReadBackend, error) { value := ctx.Value(defaultContextKey) if value == nil { - return nil, fmt.Errorf("can't resolve backend") + return nil, errors.New("can't resolve backend") } backend, ok := value.(ReadBackend) diff --git a/orm/model/ormtable/bench_test.go b/orm/model/ormtable/bench_test.go index 337e049fb26a..450d54e2af92 100644 --- a/orm/model/ormtable/bench_test.go +++ b/orm/model/ormtable/bench_test.go @@ -2,6 +2,7 @@ package ormtable_test import ( "context" + "errors" "fmt" "testing" @@ -143,7 +144,7 @@ func insertBalance(store kv.Store, balance *testpb.Balance) error { } if has { - return fmt.Errorf("already exists") + return errors.New("already exists") } bz, err := proto.Marshal(balance) @@ -223,7 +224,7 @@ func getBalance(store kv.Store, address, denom string) (*testpb.Balance, error) } if bz == nil { - return nil, fmt.Errorf("not found") + return nil, errors.New("not found") } balance := testpb.Balance{} diff --git a/proto/cosmos/base/node/v1beta1/query.proto b/proto/cosmos/base/node/v1beta1/query.proto index 999eddc9c03d..268c85b79d5e 100644 --- a/proto/cosmos/base/node/v1beta1/query.proto +++ b/proto/cosmos/base/node/v1beta1/query.proto @@ -33,7 +33,7 @@ message ConfigResponse { // StatusRequest defines the request structure for the status of a node. message StatusRequest {} -// StateResponse defines the response structure for the status of a node. +// StatusResponse defines the response structure for the status of a node. message StatusResponse { uint64 earliest_store_height = 1; // earliest block height available in the store uint64 height = 2; // current block height diff --git a/proto/cosmos/store/snapshots/v2/snapshot.proto b/proto/cosmos/store/snapshots/v2/snapshot.proto new file mode 100644 index 000000000000..675a22c1cd6d --- /dev/null +++ b/proto/cosmos/store/snapshots/v2/snapshot.proto @@ -0,0 +1,63 @@ +syntax = "proto3"; +package cosmos.store.snapshots.v2; + +import "gogoproto/gogo.proto"; +import "cosmos_proto/cosmos.proto"; +option go_package = "cosmossdk.io/store/snapshots/types"; + +// Snapshot contains Tendermint state sync snapshot info. +message Snapshot { + uint64 height = 1; + uint32 format = 2; + uint32 chunks = 3; + bytes hash = 4; + Metadata metadata = 5 [(gogoproto.nullable) = false]; +} + +// Metadata contains SDK-specific snapshot metadata. +message Metadata { + repeated bytes chunk_hashes = 1; // SHA-256 chunk hashes +} + +// SnapshotItem is an item contained in a rootmulti.Store snapshot. +// +message SnapshotItem { + // item is the specific type of snapshot item. + oneof item { + SnapshotStoreItem store = 1; + SnapshotIAVLItem iavl = 2 [(gogoproto.customname) = "IAVL"]; + SnapshotExtensionMeta extension = 3; + SnapshotExtensionPayload extension_payload = 4; + } + option (cosmos_proto.message_added_in) = "cosmos-sdk 0.46"; +} + +// SnapshotStoreItem contains metadata about a snapshotted store. +message SnapshotStoreItem { + string name = 1; + option (cosmos_proto.message_added_in) = "cosmos-sdk 0.46"; +} + +// SnapshotIAVLItem is an exported IAVL node. +message SnapshotIAVLItem { + bytes key = 1; + bytes value = 2; + // version is block height + int64 version = 3; + // height is depth of the tree. + int32 height = 4; + option (cosmos_proto.message_added_in) = "cosmos-sdk 0.46"; +} + +// SnapshotExtensionMeta contains metadata about an external snapshotter. +message SnapshotExtensionMeta { + string name = 1; + uint32 format = 2; + option (cosmos_proto.message_added_in) = "cosmos-sdk 0.46"; +} + +// SnapshotExtensionPayload contains payloads of an external snapshotter. +message SnapshotExtensionPayload { + bytes payload = 1; + option (cosmos_proto.message_added_in) = "cosmos-sdk 0.46"; +} diff --git a/proto/cosmos/tx/v1beta1/tx.proto b/proto/cosmos/tx/v1beta1/tx.proto index b1c45f8063bc..7b78cd6d07e4 100644 --- a/proto/cosmos/tx/v1beta1/tx.proto +++ b/proto/cosmos/tx/v1beta1/tx.proto @@ -8,6 +8,7 @@ import "cosmos/crypto/multisig/v1beta1/multisig.proto"; import "cosmos/base/v1beta1/coin.proto"; import "cosmos/tx/signing/v1beta1/signing.proto"; import "google/protobuf/any.proto"; +import "google/protobuf/timestamp.proto"; option go_package = "github.com/cosmos/cosmos-sdk/types/tx"; @@ -110,10 +111,6 @@ message TxBody { // timeout_height is the block height after which this transaction will not // be processed by the chain. - // - // Note, if unordered=true this value MUST be set - // and will act as a short-lived TTL in which the transaction is deemed valid - // and kept in memory to prevent duplicates. uint64 timeout_height = 3; // unordered, when set to true, indicates that the transaction signer(s) @@ -122,11 +119,19 @@ message TxBody { // incremented, which allows for fire-and-forget as well as concurrent // transaction execution. // - // Note, when set to true, the existing 'timeout_height' value must be set and - // will be used to correspond to a height in which the transaction is deemed + // Note, when set to true, the existing 'timeout_height' value must + // be set and will be used to correspond to a time_stamp in which the transaction is deemed // valid. bool unordered = 4; + // timeout_timestamp is the block time after which this transaction will not + // be processed by the chain. + // + // Note, if unordered=true this value MUST be set + // and will act as a short-lived TTL in which the transaction is deemed valid + // and kept in memory to prevent duplicates. + google.protobuf.Timestamp timeout_timestamp = 5 [(gogoproto.nullable) = true, (gogoproto.stdtime) = true]; + // extension_options are arbitrary options that can be added by chains // when the default options are not sufficient. If any of these are present // and can't be handled, the transaction will be rejected diff --git a/runtime/app.go b/runtime/app.go index 80bc28340898..185278511e00 100644 --- a/runtime/app.go +++ b/runtime/app.go @@ -8,10 +8,9 @@ import ( abci "github.com/cometbft/cometbft/api/cometbft/abci/v1" runtimev1alpha1 "cosmossdk.io/api/cosmos/app/runtime/v1alpha1" - appv1alpha1 "cosmossdk.io/api/cosmos/app/v1alpha1" "cosmossdk.io/core/appmodule" "cosmossdk.io/core/legacy" - "cosmossdk.io/core/log" + "cosmossdk.io/log" storetypes "cosmossdk.io/store/types" authtx "cosmossdk.io/x/auth/tx" @@ -51,7 +50,6 @@ type App struct { baseAppOptions []BaseAppOption msgServiceRouter *baseapp.MsgServiceRouter grpcQueryRouter *baseapp.GRPCQueryRouter - appConfig *appv1alpha1.Config logger log.Logger // initChainer is the init chainer function defined by the app config. // this is only required if the chain wants to add special InitChainer logic. diff --git a/runtime/branch_test.go b/runtime/branch_test.go index 29a6c9703e0b..bd0dc1154a15 100644 --- a/runtime/branch_test.go +++ b/runtime/branch_test.go @@ -2,7 +2,7 @@ package runtime import ( "context" - "fmt" + "errors" "testing" "github.com/stretchr/testify/require" @@ -52,7 +52,7 @@ func TestBranchService(t *testing.T) { ctx := testutil.DefaultContext(sk, tsk) err := bs.Execute(ctx, func(ctx context.Context) error { doStateChange(ctx) - return fmt.Errorf("failure") + return errors.New("failure") }) require.Error(t, err) assertRollback(ctx, true) @@ -76,7 +76,7 @@ func TestBranchService(t *testing.T) { ctx := testutil.DefaultContext(sk, tsk) gasUsed, err := bs.ExecuteWithGasLimit(ctx, 4_000, func(ctx context.Context) error { doStateChange(ctx) - return fmt.Errorf("failure") + return errors.New("failure") }) require.Error(t, err) // assert gas used diff --git a/runtime/module.go b/runtime/module.go index 501b9c1ff04c..e806e2156761 100644 --- a/runtime/module.go +++ b/runtime/module.go @@ -10,7 +10,6 @@ import ( "google.golang.org/protobuf/reflect/protoregistry" runtimev1alpha1 "cosmossdk.io/api/cosmos/app/runtime/v1alpha1" - appv1alpha1 "cosmossdk.io/api/cosmos/app/v1alpha1" autocliv1 "cosmossdk.io/api/cosmos/autocli/v1" reflectionv1 "cosmossdk.io/api/cosmos/reflection/v1" "cosmossdk.io/core/app" @@ -18,10 +17,10 @@ import ( "cosmossdk.io/core/comet" "cosmossdk.io/core/genesis" "cosmossdk.io/core/legacy" - "cosmossdk.io/core/log" "cosmossdk.io/core/store" "cosmossdk.io/depinject" "cosmossdk.io/depinject/appconfig" + "cosmossdk.io/log" storetypes "cosmossdk.io/store/types" "github.com/cosmos/cosmos-sdk/baseapp" @@ -155,7 +154,6 @@ type AppInputs struct { depinject.In Logger log.Logger - AppConfig *appv1alpha1.Config Config *runtimev1alpha1.Module AppBuilder *AppBuilder ModuleManager *module.Manager @@ -168,7 +166,6 @@ func SetupAppBuilder(inputs AppInputs) { app := inputs.AppBuilder.app app.baseAppOptions = inputs.BaseAppOptions app.config = inputs.Config - app.appConfig = inputs.AppConfig app.logger = inputs.Logger app.ModuleManager = inputs.ModuleManager app.ModuleManager.RegisterInterfaces(inputs.InterfaceRegistry) diff --git a/runtime/v2/app.go b/runtime/v2/app.go index 014849c497b0..0e28d8e3b5a5 100644 --- a/runtime/v2/app.go +++ b/runtime/v2/app.go @@ -8,11 +8,10 @@ import ( "golang.org/x/exp/slices" runtimev2 "cosmossdk.io/api/cosmos/app/runtime/v2" - appv1alpha1 "cosmossdk.io/api/cosmos/app/v1alpha1" "cosmossdk.io/core/legacy" - "cosmossdk.io/core/log" "cosmossdk.io/core/registry" "cosmossdk.io/core/transaction" + "cosmossdk.io/log" "cosmossdk.io/server/v2/appmanager" "cosmossdk.io/server/v2/stf" ) @@ -36,9 +35,8 @@ type App[T transaction.Tx] struct { db Store // app configuration - logger log.Logger - config *runtimev2.Module - appConfig *appv1alpha1.Config + logger log.Logger + config *runtimev2.Module // modules configuration storeKeys []string @@ -46,9 +44,14 @@ type App[T transaction.Tx] struct { amino legacy.Amino moduleManager *MM[T] - // GRPCQueryDecoders maps gRPC method name to a function that decodes the request + // GRPCMethodsToMessageMap maps gRPC method name to a function that decodes the request // bytes into a gogoproto.Message, which then can be passed to appmanager. - GRPCQueryDecoders map[string]func(requestBytes []byte) (gogoproto.Message, error) + GRPCMethodsToMessageMap map[string]func() gogoproto.Message +} + +// Name returns the app name. +func (a *App[T]) Name() string { + return a.config.AppName } // Logger returns the app logger. @@ -115,6 +118,6 @@ func (a *App[T]) GetAppManager() *appmanager.AppManager[T] { return a.AppManager } -func (a *App[T]) GetGRPCQueryDecoders() map[string]func(requestBytes []byte) (gogoproto.Message, error) { - return a.GRPCQueryDecoders +func (a *App[T]) GetGPRCMethodsToMessageMap() map[string]func() gogoproto.Message { + return a.GRPCMethodsToMessageMap } diff --git a/runtime/v2/builder.go b/runtime/v2/builder.go index 2618b0f0be5d..b7869fa3f0a7 100644 --- a/runtime/v2/builder.go +++ b/runtime/v2/builder.go @@ -5,6 +5,9 @@ import ( "encoding/json" "fmt" "io" + "path/filepath" + + "github.com/spf13/viper" "cosmossdk.io/core/appmodule" appmodulev2 "cosmossdk.io/core/appmodule/v2" @@ -13,6 +16,7 @@ import ( "cosmossdk.io/server/v2/appmanager" "cosmossdk.io/server/v2/stf" "cosmossdk.io/server/v2/stf/branch" + "cosmossdk.io/store/v2/db" rootstore "cosmossdk.io/store/v2/root" ) @@ -22,6 +26,7 @@ import ( type AppBuilder[T transaction.Tx] struct { app *App[T] storeOptions *rootstore.FactoryOptions + viper *viper.Viper // the following fields are used to overwrite the default branch func(state store.ReaderMap) store.WriterMap @@ -117,9 +122,32 @@ func (a *AppBuilder[T]) Build(opts ...AppBuilderOption[T]) (*App[T], error) { if err != nil { return nil, fmt.Errorf("failed to create STF: %w", err) } - a.app.stf = stf + v := a.viper + home := v.GetString(FlagHome) + + storeOpts := rootstore.DefaultStoreOptions() + if s := v.Sub("store.options"); s != nil { + if err := s.Unmarshal(&storeOpts); err != nil { + return nil, fmt.Errorf("failed to store options: %w", err) + } + } + + scRawDb, err := db.NewDB(db.DBType(v.GetString("store.app-db-backend")), "application", filepath.Join(home, "data"), nil) + if err != nil { + panic(err) + } + + storeOptions := &rootstore.FactoryOptions{ + Logger: a.app.logger, + RootDir: home, + Options: storeOpts, + StoreKeys: append(a.app.storeKeys, "stf"), + SCRawDB: scRawDb, + } + a.storeOptions = storeOptions + rs, err := rootstore.CreateRootStore(a.storeOptions) if err != nil { return nil, fmt.Errorf("failed to create root store: %w", err) diff --git a/runtime/v2/go.mod b/runtime/v2/go.mod index 3873280d2b38..c7dd259104e7 100644 --- a/runtime/v2/go.mod +++ b/runtime/v2/go.mod @@ -7,31 +7,24 @@ replace ( cosmossdk.io/api => ../../api cosmossdk.io/core => ../../core cosmossdk.io/core/testing => ../../core/testing - cosmossdk.io/depinject => ../../depinject - cosmossdk.io/log => ../../log cosmossdk.io/server/v2/appmanager => ../../server/v2/appmanager cosmossdk.io/server/v2/stf => ../../server/v2/stf cosmossdk.io/store/v2 => ../../store/v2 - 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/staking => ../../x/staking cosmossdk.io/x/tx => ../../x/tx - github.com/cosmos/cosmos-sdk => ../.. ) require ( cosmossdk.io/api v0.7.5 cosmossdk.io/core v0.12.1-0.20231114100755-569e3ff6a0d7 - cosmossdk.io/depinject v1.0.0-alpha.4 + cosmossdk.io/depinject v1.0.0 + cosmossdk.io/log v1.3.1 cosmossdk.io/server/v2/appmanager v0.0.0-00010101000000-000000000000 cosmossdk.io/server/v2/stf v0.0.0-00010101000000-000000000000 cosmossdk.io/store/v2 v2.0.0-00010101000000-000000000000 cosmossdk.io/x/tx v0.13.3 github.com/cosmos/gogoproto v1.5.0 - golang.org/x/exp v0.0.0-20240506185415-9bf2ced13842 + github.com/spf13/viper v1.19.0 + golang.org/x/exp v0.0.0-20240531132922-fd00a4e0eefc google.golang.org/grpc v1.64.1 google.golang.org/protobuf v1.34.2 ) @@ -40,8 +33,7 @@ require ( buf.build/gen/go/cometbft/cometbft/protocolbuffers/go v1.34.2-20240701160653-fedbb9acfd2f.2 // indirect buf.build/gen/go/cosmos/gogo-proto/protocolbuffers/go v1.34.2-20240130113600-88ef6483f90f.2 // indirect cosmossdk.io/core/testing v0.0.0-00010101000000-000000000000 // indirect - cosmossdk.io/errors v1.0.1 // indirect - cosmossdk.io/log v1.3.1 // indirect + cosmossdk.io/errors/v2 v2.0.0-20240731132947-df72853b3ca5 // indirect github.com/DataDog/zstd v1.5.5 // indirect github.com/beorn7/perks v1.0.1 // indirect github.com/cespare/xxhash/v2 v2.3.0 // indirect @@ -52,10 +44,11 @@ require ( github.com/cockroachdb/tokenbucket v0.0.0-20230807174530-cc333fc44b06 // indirect github.com/cosmos/cosmos-db v1.0.2 // indirect github.com/cosmos/cosmos-proto v1.0.0-beta.5 // indirect - github.com/cosmos/iavl v1.2.0 // indirect + github.com/cosmos/iavl v1.2.1-0.20240725141113-7adc688cf179 // indirect github.com/cosmos/ics23/go v0.10.0 // indirect github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect github.com/emicklei/dot v1.6.2 // indirect + github.com/fsnotify/fsnotify v1.7.0 // indirect github.com/getsentry/sentry-go v0.27.0 // indirect github.com/gogo/protobuf v1.3.2 // indirect github.com/golang/snappy v0.0.4 // indirect @@ -64,15 +57,19 @@ require ( github.com/hashicorp/go-immutable-radix v1.3.1 // indirect github.com/hashicorp/go-metrics v0.5.3 // indirect github.com/hashicorp/golang-lru v1.0.2 // indirect + github.com/hashicorp/hcl v1.0.0 // indirect github.com/klauspost/compress v1.17.8 // indirect github.com/kr/pretty v0.3.1 // indirect github.com/kr/text v0.2.0 // indirect github.com/linxGnu/grocksdb v1.8.14 // indirect + github.com/magiconair/properties v1.8.7 // indirect github.com/mattn/go-colorable v0.1.13 // indirect github.com/mattn/go-isatty v0.0.20 // indirect github.com/mattn/go-sqlite3 v1.14.22 // indirect + github.com/mitchellh/mapstructure v1.5.0 // indirect github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect github.com/onsi/gomega v1.28.1 // indirect + github.com/pelletier/go-toml/v2 v2.2.2 // indirect github.com/pkg/errors v0.9.1 // indirect github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect github.com/prometheus/client_golang v1.19.1 // indirect @@ -81,11 +78,18 @@ require ( github.com/prometheus/procfs v0.15.1 // indirect github.com/rogpeppe/go-internal v1.12.0 // indirect github.com/rs/zerolog v1.33.0 // indirect + github.com/sagikazarmark/locafero v0.4.0 // indirect + github.com/sagikazarmark/slog-shim v0.1.0 // indirect + github.com/sourcegraph/conc v0.3.0 // indirect + github.com/spf13/afero v1.11.0 // indirect github.com/spf13/cast v1.6.0 // indirect + github.com/spf13/pflag v1.0.5 // indirect github.com/stretchr/testify v1.9.0 // indirect + github.com/subosito/gotenv v1.6.0 // indirect github.com/syndtr/goleveldb v1.0.1-0.20220721030215-126854af5e6d // indirect github.com/tendermint/go-amino v0.16.0 // indirect github.com/tidwall/btree v1.7.0 // indirect + go.uber.org/multierr v1.11.0 // indirect golang.org/x/crypto v0.25.0 // indirect golang.org/x/net v0.27.0 // indirect golang.org/x/sync v0.7.0 // indirect @@ -93,6 +97,7 @@ require ( golang.org/x/text v0.16.0 // indirect google.golang.org/genproto/googleapis/api v0.0.0-20240318140521-94a12d6c2237 // indirect google.golang.org/genproto/googleapis/rpc v0.0.0-20240709173604-40e1e62336c5 // indirect + gopkg.in/ini.v1 v1.67.0 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect sigs.k8s.io/yaml v1.4.0 // indirect ) diff --git a/runtime/v2/go.sum b/runtime/v2/go.sum index 069bd8c96bf4..b6c5110af8e1 100644 --- a/runtime/v2/go.sum +++ b/runtime/v2/go.sum @@ -2,8 +2,12 @@ buf.build/gen/go/cometbft/cometbft/protocolbuffers/go v1.34.2-20240701160653-fed buf.build/gen/go/cometbft/cometbft/protocolbuffers/go v1.34.2-20240701160653-fedbb9acfd2f.2/go.mod h1:1+3gJj2NvZ1mTLAtHu+lMhOjGgQPiCKCeo+9MBww0Eo= buf.build/gen/go/cosmos/gogo-proto/protocolbuffers/go v1.34.2-20240130113600-88ef6483f90f.2 h1:b7EEYTUHmWSBEyISHlHvXbJPqtKiHRuUignL1tsHnNQ= buf.build/gen/go/cosmos/gogo-proto/protocolbuffers/go v1.34.2-20240130113600-88ef6483f90f.2/go.mod h1:HqcXMSa5qnNuakaMUo+hWhF51mKbcrZxGl9Vp5EeJXc= -cosmossdk.io/errors v1.0.1 h1:bzu+Kcr0kS/1DuPBtUFdWjzLqyUuCiyHjyJB6srBV/0= -cosmossdk.io/errors v1.0.1/go.mod h1:MeelVSZThMi4bEakzhhhE/CKqVv3nOJDA25bIqRDu/U= +cosmossdk.io/depinject v1.0.0 h1:dQaTu6+O6askNXO06+jyeUAnF2/ssKwrrszP9t5q050= +cosmossdk.io/depinject v1.0.0/go.mod h1:zxK/h3HgHoA/eJVtiSsoaRaRA2D5U4cJ5thIG4ssbB8= +cosmossdk.io/errors/v2 v2.0.0-20240731132947-df72853b3ca5 h1:IQNdY2kB+k+1OM2DvqFG1+UgeU1JzZrWtwuWzI3ZfwA= +cosmossdk.io/errors/v2 v2.0.0-20240731132947-df72853b3ca5/go.mod h1:0CuYKkFHxc1vw2JC+t21THBCALJVROrWVR/3PQ1urpc= +cosmossdk.io/log v1.3.1 h1:UZx8nWIkfbbNEWusZqzAx3ZGvu54TZacWib3EzUYmGI= +cosmossdk.io/log v1.3.1/go.mod h1:2/dIomt8mKdk6vl3OWJcPk2be3pGOS8OQaLUM/3/tCM= github.com/DataDog/datadog-go v3.2.0+incompatible/go.mod h1:LButxg5PwREeZtORoXG3tL4fMGNddJ+vMq1mwgfaqoQ= github.com/DataDog/zstd v1.5.5 h1:oWf5W7GtOLgp6bciQYDmhHHjdhYkALu6S/5Ni9ZgSvQ= github.com/DataDog/zstd v1.5.5/go.mod h1:g4AWEaM3yOg3HYfnJ3YIawPnVdXJh9QME85blwSAmyw= @@ -42,8 +46,8 @@ github.com/cosmos/cosmos-proto v1.0.0-beta.5 h1:eNcayDLpip+zVLRLYafhzLvQlSmyab+R github.com/cosmos/cosmos-proto v1.0.0-beta.5/go.mod h1:hQGLpiIUloJBMdQMMWb/4wRApmI9hjHH05nefC0Ojec= github.com/cosmos/gogoproto v1.5.0 h1:SDVwzEqZDDBoslaeZg+dGE55hdzHfgUA40pEanMh52o= github.com/cosmos/gogoproto v1.5.0/go.mod h1:iUM31aofn3ymidYG6bUR5ZFrk+Om8p5s754eMUcyp8I= -github.com/cosmos/iavl v1.2.0 h1:kVxTmjTh4k0Dh1VNL046v6BXqKziqMDzxo93oh3kOfM= -github.com/cosmos/iavl v1.2.0/go.mod h1:HidWWLVAtODJqFD6Hbne2Y0q3SdxByJepHUOeoH4LiI= +github.com/cosmos/iavl v1.2.1-0.20240725141113-7adc688cf179 h1:wmwDn7V3RodN9auB3FooSQxs46nHVE3u0mb87TJkZFE= +github.com/cosmos/iavl v1.2.1-0.20240725141113-7adc688cf179/go.mod h1:GiM43q0pB+uG53mLxLDzimxM9l/5N9UuSY3/D0huuVw= github.com/cosmos/ics23/go v0.10.0 h1:iXqLLgp2Lp+EdpIuwXTYIQU+AiHj9mOC2X9ab++bZDM= github.com/cosmos/ics23/go v0.10.0/go.mod h1:ZfJSmng/TBNTBkFemHHHj5YY7VAU/MBU980F4VU1NG0= github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E= @@ -119,6 +123,8 @@ github.com/hashicorp/go-uuid v1.0.1/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/b github.com/hashicorp/golang-lru v0.5.0/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8= github.com/hashicorp/golang-lru v1.0.2 h1:dV3g9Z/unq5DpblPpw+Oqcv4dU/1omnb4Ok8iPY6p1c= github.com/hashicorp/golang-lru v1.0.2/go.mod h1:iADmTwqILo4mZ8BN3D2Q6+9jd8WM5uGBxy+E8yxSoD4= +github.com/hashicorp/hcl v1.0.0 h1:0Anlzjpi4vEasTeNFn2mLJgTSwt0+6sfsiTG8qcWGx4= +github.com/hashicorp/hcl v1.0.0/go.mod h1:E5yfLk+7swimpb2L/Alb/PJmXilQ/rhwaUYs4T20WEQ= github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU= github.com/ianlancetaylor/demangle v0.0.0-20200824232613-28f6c0f3b639/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc= github.com/json-iterator/go v1.1.6/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCVDaaPEHmU= @@ -139,6 +145,8 @@ github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= github.com/linxGnu/grocksdb v1.8.14 h1:HTgyYalNwBSG/1qCQUIott44wU5b2Y9Kr3z7SK5OfGQ= github.com/linxGnu/grocksdb v1.8.14/go.mod h1:QYiYypR2d4v63Wj1adOOfzglnoII0gLj3PNh4fZkcFA= +github.com/magiconair/properties v1.8.7 h1:IeQXZAiQcpL9mgcAe1Nu6cX9LLw6ExEHKjN0VQdvPDY= +github.com/magiconair/properties v1.8.7/go.mod h1:Dhd985XPs7jluiymwWYZ0G4Z61jb3vdS329zhj2hYo0= github.com/mattn/go-colorable v0.1.13 h1:fFA4WZxdEF4tXPZVKMLwD8oUnCTTo08duU7wxecdEvA= github.com/mattn/go-colorable v0.1.13/go.mod h1:7S9/ev0klgBDR4GtXTXX8a3vIGJpMovkB8vQcUbaXHg= github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM= @@ -148,6 +156,8 @@ github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D github.com/mattn/go-sqlite3 v1.14.22 h1:2gZY6PC6kBnID23Tichd1K+Z0oS6nE/XwU+Vz/5o4kU= github.com/mattn/go-sqlite3 v1.14.22/go.mod h1:Uh1q+B4BYcTPb+yiD3kU8Ct7aC0hY9fxUwlHK0RXw+Y= github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0= +github.com/mitchellh/mapstructure v1.5.0 h1:jeMsZIYE/09sWLaz43PL7Gy6RuMjD2eJVyuac5Z2hdY= +github.com/mitchellh/mapstructure v1.5.0/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo= github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= github.com/modern-go/reflect2 v0.0.0-20180701023420-4b7aa43c6742/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0= @@ -172,6 +182,8 @@ github.com/onsi/gomega v1.28.1 h1:MijcGUbfYuznzK/5R4CPNoUP/9Xvuo20sXfEm6XxoTA= github.com/onsi/gomega v1.28.1/go.mod h1:9sxs+SwGrKI0+PWe4Fxa9tFQQBG5xSsSbMXOI8PPpoQ= github.com/pascaldekloe/goe v0.1.0 h1:cBOtyMzM9HTpWjXfbbunk26uA6nG3a8n06Wieeh0MwY= github.com/pascaldekloe/goe v0.1.0/go.mod h1:lzWF7FIEvWOWxwDKqyGYQf6ZUaNfKdP144TG7ZOy1lc= +github.com/pelletier/go-toml/v2 v2.2.2 h1:aYUidT7k73Pcl9nb2gScu7NSrKCSHIDE89b3+6Wq+LM= +github.com/pelletier/go-toml/v2 v2.2.2/go.mod h1:1t835xjRzz80PqgE6HHgN2JOsmgYu/h4qDAS4n929Rs= github.com/pingcap/errors v0.11.4 h1:lFuQV/oaUMGcD2tqt+01ROSmJs75VG1ToEOkZIZ4nE4= github.com/pingcap/errors v0.11.4/go.mod h1:Oi8TUi2kEtXXLMJk9l1cGmz20kV3TaQ0usTwv5KuLY8= github.com/pkg/diff v0.0.0-20210226163009-20ebb0f2a09e/go.mod h1:pJLUxLENpZxwdsKMEsNbx1VGcRFpLqf3715MtcvvzbA= @@ -207,19 +219,39 @@ github.com/rogpeppe/go-internal v1.12.0/go.mod h1:E+RYuTGaKKdloAfM02xzb0FW3Paa99 github.com/rs/xid v1.5.0/go.mod h1:trrq9SKmegXys3aeAKXMUTdJsYXVwGY3RLcfgqegfbg= github.com/rs/zerolog v1.33.0 h1:1cU2KZkvPxNyfgEmhHAz/1A9Bz+llsdYzklWFzgp0r8= github.com/rs/zerolog v1.33.0/go.mod h1:/7mN4D5sKwJLZQ2b/znpjC3/GQWY/xaDXUM0kKWRHss= +github.com/sagikazarmark/locafero v0.4.0 h1:HApY1R9zGo4DBgr7dqsTH/JJxLTTsOt7u6keLGt6kNQ= +github.com/sagikazarmark/locafero v0.4.0/go.mod h1:Pe1W6UlPYUk/+wc/6KFhbORCfqzgYEpgQ3O5fPuL3H4= +github.com/sagikazarmark/slog-shim v0.1.0 h1:diDBnUNK9N/354PgrxMywXnAwEr1QZcOr6gto+ugjYE= +github.com/sagikazarmark/slog-shim v0.1.0/go.mod h1:SrcSrq8aKtyuqEI1uvTDTK1arOWRIczQRv+GVI1AkeQ= github.com/sirupsen/logrus v1.2.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo= github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6MwdIuYE2rE= +github.com/sourcegraph/conc v0.3.0 h1:OQTbbt6P72L20UqAkXXuLOj79LfEanQ+YQFNpLA9ySo= +github.com/sourcegraph/conc v0.3.0/go.mod h1:Sdozi7LEKbFPqYX2/J+iBAM6HpqSLTASQIKqDmF7Mt0= +github.com/spf13/afero v1.11.0 h1:WJQKhtpdm3v2IzqG8VMqrr6Rf3UYpEF239Jy9wNepM8= +github.com/spf13/afero v1.11.0/go.mod h1:GH9Y3pIexgf1MTIWtNGyogA5MwRIDXGUr+hbWNoBjkY= github.com/spf13/cast v1.6.0 h1:GEiTHELF+vaR5dhz3VqZfFSzZjYbgeKDpBxQVS4GYJ0= github.com/spf13/cast v1.6.0/go.mod h1:ancEpBxwJDODSW/UG4rDrAqiKolqNNh2DX3mk86cAdo= +github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA= +github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg= +github.com/spf13/viper v1.19.0 h1:RWq5SEjt8o25SROyN3z2OrDB9l7RPd3lwTWU8EcEdcI= +github.com/spf13/viper v1.19.0/go.mod h1:GQUN9bilAbhU/jgc1bKs99f/suXKeUMct8Adx5+Ntkg= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= +github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw= +github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo= +github.com/stretchr/objx v0.5.2/go.mod h1:FRsXN1f5AsAjCGJKqEizvkpNtU+EGNCLh3NxZ/8L+MA= github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA= +github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.7.2/go.mod h1:R6va5+xMeoiuVRoj+gSkQ7d3FALtqAAGI1FQKckRals= +github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= +github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg= github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= +github.com/subosito/gotenv v1.6.0 h1:9NlTDc1FTs4qu0DDq7AEtTPNw6SVm7uBMsUCUjABIf8= +github.com/subosito/gotenv v1.6.0/go.mod h1:Dk4QP5c2W3ibzajGcXpNraDfq2IrhjMIvMSWPKKo0FU= github.com/syndtr/goleveldb v1.0.1-0.20220721030215-126854af5e6d h1:vfofYNRScrDdvS342BElfbETmL1Aiz3i2t0zfRj16Hs= github.com/syndtr/goleveldb v1.0.1-0.20220721030215-126854af5e6d/go.mod h1:RRCYJbIwD5jmqPI9XoAFR0OcDxqUctll6zUj/+B4S48= github.com/tendermint/go-amino v0.16.0 h1:GyhmgQKvqF82e2oZeuMSp9JTN0N09emoSZlb2lyGa2E= @@ -229,14 +261,16 @@ github.com/tidwall/btree v1.7.0/go.mod h1:twD9XRA5jj9VUQGELzDO4HPQTNJsoWWfYEL+EU github.com/tv42/httpunix v0.0.0-20150427012821-b75d8614f926/go.mod h1:9ESjWnEqriFuLhtthL60Sar/7RFoluCcXsuvEwTV5KM= github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= +go.uber.org/multierr v1.11.0 h1:blXXJkSxSSfBVBlC76pxqeO+LN3aDfLQo+309xJstO0= +go.uber.org/multierr v1.11.0/go.mod h1:20+QtiLqy0Nd6FdQB9TLXag12DsQkrbs3htMFfDN80Y= golang.org/x/crypto v0.0.0-20180904163835-0709b304e793/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.25.0 h1:ypSNr+bnYL2YhwoMt2zPxHFmbAN1KZs/njMG3hxUp30= golang.org/x/crypto v0.25.0/go.mod h1:T+wALwcMOSE0kXgUAnPAHqTLW+XHgcELELW8VaDgm/M= -golang.org/x/exp v0.0.0-20240506185415-9bf2ced13842 h1:vr/HnozRka3pE4EsMEg1lgkXJkTFJCVUX+S/ZT6wYzM= -golang.org/x/exp v0.0.0-20240506185415-9bf2ced13842/go.mod h1:XtvwrStGgqGPLc4cjQfWqZHG1YFdYs6swckp8vpsjnc= +golang.org/x/exp v0.0.0-20240531132922-fd00a4e0eefc h1:O9NuF4s+E/PvMIy+9IUZB9znFwUIXEWSstNjek6VpVg= +golang.org/x/exp v0.0.0-20240531132922-fd00a4e0eefc/go.mod h1:XtvwrStGgqGPLc4cjQfWqZHG1YFdYs6swckp8vpsjnc= golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= @@ -327,6 +361,8 @@ gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8 gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk= gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q= gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys= +gopkg.in/ini.v1 v1.67.0 h1:Dgnx+6+nfE+IfzjUEISNeydPJh9AXNNsWbGP9KzCsOA= +gopkg.in/ini.v1 v1.67.0/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k= gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 h1:uRGJdciOHaEIrze2W8Q3AKkepLTh2hOroT7a+7czfdQ= gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWDmTeBkI65Dw0HsyUHuEVlX15mw= gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= @@ -335,6 +371,7 @@ gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.2.5/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.3.0/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ= +gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gotest.tools/v3 v3.5.1 h1:EENdUnS3pdur5nybKYIh2Vfgc8IUNBjxDPSjtiJcOzU= diff --git a/runtime/v2/manager.go b/runtime/v2/manager.go index c947e0b96581..244353674c5a 100644 --- a/runtime/v2/manager.go +++ b/runtime/v2/manager.go @@ -20,9 +20,9 @@ import ( "cosmossdk.io/core/appmodule" appmodulev2 "cosmossdk.io/core/appmodule/v2" "cosmossdk.io/core/legacy" - "cosmossdk.io/core/log" "cosmossdk.io/core/registry" "cosmossdk.io/core/transaction" + "cosmossdk.io/log" "cosmossdk.io/server/v2/stf" ) @@ -166,7 +166,7 @@ func (m *MM[T]) InitGenesisJSON( case appmodulev2.HasGenesis: m.logger.Debug("running initialization for module", "module", moduleName) if err := module.InitGenesis(ctx, genesisData[moduleName]); err != nil { - return err + return fmt.Errorf("init module %s: %w", moduleName, err) } case appmodulev2.HasABCIGenesis: m.logger.Debug("running initialization for module", "module", moduleName) @@ -410,7 +410,7 @@ func (m *MM[T]) RunMigrations(ctx context.Context, fromVM appmodulev2.VersionMap // The module manager assumes only one module will update the validator set, and it can't be a new module. if len(moduleValUpdates) > 0 { - return nil, fmt.Errorf("validator InitGenesis update is already set by another module") + return nil, errors.New("validator InitGenesis update is already set by another module") } } } @@ -556,7 +556,7 @@ func (m *MM[T]) assertNoForgottenModules( func registerServices[T transaction.Tx](s appmodule.HasServices, app *App[T], registry *protoregistry.Files) error { c := &configurator{ - grpcQueryDecoders: map[string]func([]byte) (gogoproto.Message, error){}, + grpcQueryDecoders: map[string]func() gogoproto.Message{}, stfQueryRouter: app.queryRouterBuilder, stfMsgRouter: app.msgRouterBuilder, registry: registry, @@ -567,7 +567,10 @@ func registerServices[T transaction.Tx](s appmodule.HasServices, app *App[T], re if err != nil { return fmt.Errorf("unable to register services: %w", err) } - app.GRPCQueryDecoders = c.grpcQueryDecoders + // merge maps + for path, decoder := range c.grpcQueryDecoders { + app.GRPCMethodsToMessageMap[path] = decoder + } return nil } @@ -576,7 +579,7 @@ var _ grpc.ServiceRegistrar = (*configurator)(nil) type configurator struct { // grpcQueryDecoders is required because module expose queries through gRPC // this provides a way to route to modules using gRPC. - grpcQueryDecoders map[string]func([]byte) (gogoproto.Message, error) + grpcQueryDecoders map[string]func() gogoproto.Message stfQueryRouter *stf.MsgRouterBuilder stfMsgRouter *stf.MsgRouterBuilder @@ -618,11 +621,11 @@ func (c *configurator) registerQueryHandlers(sd *grpc.ServiceDesc, ss interface{ if typ == nil { return fmt.Errorf("unable to find message in gogotype registry: %w", err) } - decoderFunc := func(bytes []byte) (gogoproto.Message, error) { - msg := reflect.New(typ.Elem()).Interface().(gogoproto.Message) - return msg, gogoproto.Unmarshal(bytes, msg) + decoderFunc := func() gogoproto.Message { + return reflect.New(typ.Elem()).Interface().(gogoproto.Message) } - c.grpcQueryDecoders[md.MethodName] = decoderFunc + methodName := fmt.Sprintf("/%s/%s", sd.ServiceName, md.MethodName) + c.grpcQueryDecoders[methodName] = decoderFunc } return nil } diff --git a/runtime/v2/module.go b/runtime/v2/module.go index ffc5632f9403..fbcf391b1f68 100644 --- a/runtime/v2/module.go +++ b/runtime/v2/module.go @@ -6,6 +6,7 @@ import ( "slices" "github.com/cosmos/gogoproto/proto" + "github.com/spf13/viper" "google.golang.org/grpc" "google.golang.org/protobuf/reflect/protodesc" "google.golang.org/protobuf/reflect/protoregistry" @@ -20,15 +21,14 @@ import ( "cosmossdk.io/core/comet" "cosmossdk.io/core/genesis" "cosmossdk.io/core/legacy" - "cosmossdk.io/core/log" "cosmossdk.io/core/registry" "cosmossdk.io/core/store" "cosmossdk.io/core/transaction" "cosmossdk.io/depinject" "cosmossdk.io/depinject/appconfig" + "cosmossdk.io/log" "cosmossdk.io/runtime/v2/services" "cosmossdk.io/server/v2/stf" - rootstorev2 "cosmossdk.io/store/v2/root" ) var ( @@ -130,11 +130,12 @@ func ProvideAppBuilder[T transaction.Tx]( msgRouterBuilder := stf.NewMsgRouterBuilder() app := &App[T]{ - storeKeys: nil, - interfaceRegistrar: interfaceRegistrar, - amino: amino, - msgRouterBuilder: msgRouterBuilder, - queryRouterBuilder: stf.NewMsgRouterBuilder(), // TODO dedicated query router + storeKeys: nil, + interfaceRegistrar: interfaceRegistrar, + amino: amino, + msgRouterBuilder: msgRouterBuilder, + queryRouterBuilder: stf.NewMsgRouterBuilder(), // TODO dedicated query router + GRPCMethodsToMessageMap: map[string]func() proto.Message{}, } appBuilder := &AppBuilder[T]{app: app} @@ -144,29 +145,25 @@ func ProvideAppBuilder[T transaction.Tx]( type AppInputs struct { depinject.In - AppConfig *appv1alpha1.Config Config *runtimev2.Module AppBuilder *AppBuilder[transaction.Tx] ModuleManager *MM[transaction.Tx] InterfaceRegistrar registry.InterfaceRegistrar LegacyAmino legacy.Amino Logger log.Logger - StoreOptions *rootstorev2.FactoryOptions `optional:"true"` + Viper *viper.Viper `optional:"true"` } func SetupAppBuilder(inputs AppInputs) { app := inputs.AppBuilder.app app.config = inputs.Config - app.appConfig = inputs.AppConfig app.logger = inputs.Logger app.moduleManager = inputs.ModuleManager app.moduleManager.RegisterInterfaces(inputs.InterfaceRegistrar) app.moduleManager.RegisterLegacyAminoCodec(inputs.LegacyAmino) - if inputs.StoreOptions != nil { - inputs.AppBuilder.storeOptions = inputs.StoreOptions - inputs.AppBuilder.storeOptions.StoreKeys = inputs.AppBuilder.app.storeKeys - inputs.AppBuilder.storeOptions.StoreKeys = append(inputs.AppBuilder.storeOptions.StoreKeys, "stf") + if inputs.Viper != nil { + inputs.AppBuilder.viper = inputs.Viper } } diff --git a/runtime/v2/types.go b/runtime/v2/types.go index ac606cbd5457..0138dd802c82 100644 --- a/runtime/v2/types.go +++ b/runtime/v2/types.go @@ -12,7 +12,10 @@ import ( "cosmossdk.io/x/tx/signing" ) -const ModuleName = "runtime" +const ( + ModuleName = "runtime" + FlagHome = "home" +) // ValidateProtoAnnotations validates that the proto annotations are correct. // More specifically, it verifies: diff --git a/schema/appdata/async.go b/schema/appdata/async.go new file mode 100644 index 000000000000..4112ae839fe9 --- /dev/null +++ b/schema/appdata/async.go @@ -0,0 +1,162 @@ +package appdata + +import ( + "context" + "sync" +) + +// AsyncListenerOptions are options for async listeners and listener mux's. +type AsyncListenerOptions struct { + // Context is the context whose Done() channel listeners use will use to listen for completion to close their + // goroutine. If it is nil, then context.Background() will be used and goroutines may be leaked. + Context context.Context + + // BufferSize is the buffer size of the channels to use. It defaults to 0. + BufferSize int + + // DoneWaitGroup is an optional wait-group that listener goroutines will notify via Add(1) when they are started + // and Done() after they are canceled and completed. + DoneWaitGroup *sync.WaitGroup +} + +// AsyncListenerMux returns a listener that forwards received events to all the provided listeners asynchronously +// with each listener processing in a separate go routine. All callbacks in the returned listener will return nil +// except for Commit which will return an error or nil once all listeners have processed the commit. The context +// is used to signal that the listeners should stop listening and return. bufferSize is the size of the buffer for the +// channels used to send events to the listeners. +func AsyncListenerMux(opts AsyncListenerOptions, listeners ...Listener) Listener { + asyncListeners := make([]Listener, len(listeners)) + commitChans := make([]chan error, len(listeners)) + for i, l := range listeners { + commitChan := make(chan error) + commitChans[i] = commitChan + asyncListeners[i] = AsyncListener(opts, commitChan, l) + } + mux := ListenerMux(asyncListeners...) + muxCommit := mux.Commit + mux.Commit = func(data CommitData) error { + if muxCommit != nil { + err := muxCommit(data) + if err != nil { + return err + } + } + + for _, commitChan := range commitChans { + err := <-commitChan + if err != nil { + return err + } + } + return nil + } + + return mux +} + +// AsyncListener returns a listener that forwards received events to the provided listener listening in asynchronously +// in a separate go routine. The listener that is returned will return nil for all methods including Commit and +// an error or nil will only be returned in commitChan once the sender has sent commit and the receiving listener has +// processed it. Thus commitChan can be used as a synchronization and error checking mechanism. The go routine +// that is being used for listening will exit when context.Done() returns and no more events will be received by the listener. +// bufferSize is the size of the buffer for the channel that is used to send events to the listener. +// Instead of using AsyncListener directly, it is recommended to use AsyncListenerMux which does coordination directly +// via its Commit callback. +func AsyncListener(opts AsyncListenerOptions, commitChan chan<- error, listener Listener) Listener { + packetChan := make(chan Packet, opts.BufferSize) + res := Listener{} + ctx := opts.Context + if ctx == nil { + ctx = context.Background() + } + done := ctx.Done() + + go func() { + if opts.DoneWaitGroup != nil { + opts.DoneWaitGroup.Add(1) + } + + var err error + for { + select { + case packet := <-packetChan: + if err != nil { + // if we have an error, don't process any more packets + // and return the error and finish when it's time to commit + if _, ok := packet.(CommitData); ok { + commitChan <- err + return + } + } else { + // process the packet + err = listener.SendPacket(packet) + // if it's a commit + if _, ok := packet.(CommitData); ok { + commitChan <- err + if err != nil { + return + } + } + } + + case <-done: + close(packetChan) + if opts.DoneWaitGroup != nil { + opts.DoneWaitGroup.Done() + } + return + } + } + }() + + if listener.InitializeModuleData != nil { + res.InitializeModuleData = func(data ModuleInitializationData) error { + packetChan <- data + return nil + } + } + + if listener.StartBlock != nil { + res.StartBlock = func(data StartBlockData) error { + packetChan <- data + return nil + } + } + + if listener.OnTx != nil { + res.OnTx = func(data TxData) error { + packetChan <- data + return nil + } + } + + if listener.OnEvent != nil { + res.OnEvent = func(data EventData) error { + packetChan <- data + return nil + } + } + + if listener.OnKVPair != nil { + res.OnKVPair = func(data KVPairData) error { + packetChan <- data + return nil + } + } + + if listener.OnObjectUpdate != nil { + res.OnObjectUpdate = func(data ObjectUpdateData) error { + packetChan <- data + return nil + } + } + + if listener.Commit != nil { + res.Commit = func(data CommitData) error { + packetChan <- data + return nil + } + } + + return res +} diff --git a/schema/appdata/async_test.go b/schema/appdata/async_test.go new file mode 100644 index 000000000000..c1df2d4ca6c0 --- /dev/null +++ b/schema/appdata/async_test.go @@ -0,0 +1,148 @@ +package appdata + +import ( + "context" + "fmt" + "sync" + "testing" +) + +func TestAsyncListenerMux(t *testing.T) { + t.Run("empty", func(t *testing.T) { + listener := AsyncListenerMux(AsyncListenerOptions{}, Listener{}, Listener{}) + + if listener.InitializeModuleData != nil { + t.Error("expected nil") + } + if listener.StartBlock != nil { + t.Error("expected nil") + } + if listener.OnTx != nil { + t.Error("expected nil") + } + if listener.OnEvent != nil { + t.Error("expected nil") + } + if listener.OnKVPair != nil { + t.Error("expected nil") + } + if listener.OnObjectUpdate != nil { + t.Error("expected nil") + } + + // commit is not expected to be nil + }) + + t.Run("call cancel", func(t *testing.T) { + ctx, cancel := context.WithCancel(context.Background()) + wg := &sync.WaitGroup{} + var calls1, calls2 []string + listener1 := callCollector(1, func(name string, _ int, _ Packet) { + calls1 = append(calls1, name) + }) + listener2 := callCollector(2, func(name string, _ int, _ Packet) { + calls2 = append(calls2, name) + }) + res := AsyncListenerMux(AsyncListenerOptions{ + BufferSize: 16, Context: ctx, DoneWaitGroup: wg, + }, listener1, listener2) + + callAllCallbacksOnces(t, res) + + expectedCalls := []string{ + "InitializeModuleData", + "StartBlock", + "OnTx", + "OnEvent", + "OnKVPair", + "OnObjectUpdate", + "Commit", + } + + checkExpectedCallOrder(t, calls1, expectedCalls) + checkExpectedCallOrder(t, calls2, expectedCalls) + + // cancel and expect the test to finish - if all goroutines aren't canceled the test will hang + cancel() + wg.Wait() + }) + + t.Run("error on commit", func(t *testing.T) { + var calls1, calls2 []string + listener1 := callCollector(1, func(name string, _ int, _ Packet) { + calls1 = append(calls1, name) + }) + listener1.Commit = func(data CommitData) error { + return fmt.Errorf("error") + } + listener2 := callCollector(2, func(name string, _ int, _ Packet) { + calls2 = append(calls2, name) + }) + res := AsyncListenerMux(AsyncListenerOptions{}, listener1, listener2) + + err := res.Commit(CommitData{}) + if err == nil || err.Error() != "error" { + t.Fatalf("expected error, got %v", err) + } + }) +} + +func TestAsyncListener(t *testing.T) { + t.Run("call cancel", func(t *testing.T) { + commitChan := make(chan error) + ctx, cancel := context.WithCancel(context.Background()) + wg := &sync.WaitGroup{} + var calls []string + listener := callCollector(1, func(name string, _ int, _ Packet) { + calls = append(calls, name) + }) + res := AsyncListener(AsyncListenerOptions{BufferSize: 16, Context: ctx, DoneWaitGroup: wg}, + commitChan, listener) + + callAllCallbacksOnces(t, res) + + err := <-commitChan + if err != nil { + t.Fatalf("expected nil, got %v", err) + } + + checkExpectedCallOrder(t, calls, []string{ + "InitializeModuleData", + "StartBlock", + "OnTx", + "OnEvent", + "OnKVPair", + "OnObjectUpdate", + "Commit", + }) + + calls = nil + + // expect wait group to return after cancel is called + cancel() + wg.Wait() + }) + + t.Run("error", func(t *testing.T) { + commitChan := make(chan error) + var calls []string + listener := callCollector(1, func(name string, _ int, _ Packet) { + calls = append(calls, name) + }) + + listener.OnKVPair = func(updates KVPairData) error { + return fmt.Errorf("error") + } + + res := AsyncListener(AsyncListenerOptions{BufferSize: 16}, commitChan, listener) + + callAllCallbacksOnces(t, res) + + err := <-commitChan + if err == nil || err.Error() != "error" { + t.Fatalf("expected error, got %v", err) + } + + checkExpectedCallOrder(t, calls, []string{"InitializeModuleData", "StartBlock", "OnTx", "OnEvent"}) + }) +} diff --git a/schema/appdata/forwarder.go b/schema/appdata/forwarder.go new file mode 100644 index 000000000000..2fb4113c8564 --- /dev/null +++ b/schema/appdata/forwarder.go @@ -0,0 +1,15 @@ +package appdata + +// PacketForwarder creates a listener which listens to all callbacks and forwards all packets to the provided +// function. This is intended to be used primarily for tests and debugging. +func PacketForwarder(f func(Packet) error) Listener { + return Listener{ + InitializeModuleData: func(data ModuleInitializationData) error { return f(data) }, + OnTx: func(data TxData) error { return f(data) }, + OnEvent: func(data EventData) error { return f(data) }, + OnKVPair: func(data KVPairData) error { return f(data) }, + OnObjectUpdate: func(data ObjectUpdateData) error { return f(data) }, + StartBlock: func(data StartBlockData) error { return f(data) }, + Commit: func(data CommitData) error { return f(data) }, + } +} diff --git a/schema/appdata/forwarder_test.go b/schema/appdata/forwarder_test.go new file mode 100644 index 000000000000..aaf792f7170b --- /dev/null +++ b/schema/appdata/forwarder_test.go @@ -0,0 +1,39 @@ +package appdata + +import ( + "reflect" + "testing" +) + +func TestPacketForwarder(t *testing.T) { + var received []Packet + listener := PacketForwarder(func(packet Packet) error { + received = append(received, packet) + return nil + }) + + expected := []Packet{ + ModuleInitializationData{}, + StartBlockData{}, + TxData{}, + EventData{}, + KVPairData{}, + ObjectUpdateData{}, + CommitData{}, + } + + for i, packet := range expected { + err := listener.SendPacket(packet) + if err != nil { + t.Fatal(err) + } + + if len(received) != i+1 { + t.Fatalf("didn't receive packet %v", packet) + } + + if !reflect.DeepEqual(received[i], packet) { + t.Fatalf("received packet %v, expected %v", received[i], packet) + } + } +} diff --git a/schema/appdata/mux.go b/schema/appdata/mux.go new file mode 100644 index 000000000000..8e6b886577d2 --- /dev/null +++ b/schema/appdata/mux.go @@ -0,0 +1,128 @@ +package appdata + +// ListenerMux returns a listener that forwards received events to all the provided listeners in order. +// A callback is only registered if a non-nil callback is present in at least one of the listeners. +func ListenerMux(listeners ...Listener) Listener { + mux := Listener{} + + initModDataCbs := make([]func(ModuleInitializationData) error, 0, len(listeners)) + for _, l := range listeners { + if l.InitializeModuleData != nil { + initModDataCbs = append(initModDataCbs, l.InitializeModuleData) + } + } + if len(initModDataCbs) > 0 { + mux.InitializeModuleData = func(data ModuleInitializationData) error { + for _, cb := range initModDataCbs { + if err := cb(data); err != nil { + return err + } + } + return nil + } + } + + startBlockCbs := make([]func(StartBlockData) error, 0, len(listeners)) + for _, l := range listeners { + if l.StartBlock != nil { + startBlockCbs = append(startBlockCbs, l.StartBlock) + } + } + if len(startBlockCbs) > 0 { + mux.StartBlock = func(data StartBlockData) error { + for _, cb := range startBlockCbs { + if err := cb(data); err != nil { + return err + } + } + return nil + } + } + + onTxCbs := make([]func(TxData) error, 0, len(listeners)) + for _, l := range listeners { + if l.OnTx != nil { + onTxCbs = append(onTxCbs, l.OnTx) + } + } + if len(onTxCbs) > 0 { + mux.OnTx = func(data TxData) error { + for _, cb := range onTxCbs { + if err := cb(data); err != nil { + return err + } + } + return nil + } + } + + onEventCbs := make([]func(EventData) error, 0, len(listeners)) + for _, l := range listeners { + if l.OnEvent != nil { + onEventCbs = append(onEventCbs, l.OnEvent) + } + } + if len(onEventCbs) > 0 { + mux.OnEvent = func(data EventData) error { + for _, cb := range onEventCbs { + if err := cb(data); err != nil { + return err + } + } + return nil + } + } + + onKvPairCbs := make([]func(KVPairData) error, 0, len(listeners)) + for _, l := range listeners { + if l.OnKVPair != nil { + onKvPairCbs = append(onKvPairCbs, l.OnKVPair) + } + } + if len(onKvPairCbs) > 0 { + mux.OnKVPair = func(data KVPairData) error { + for _, cb := range onKvPairCbs { + if err := cb(data); err != nil { + return err + } + } + return nil + } + } + + onObjectUpdateCbs := make([]func(ObjectUpdateData) error, 0, len(listeners)) + for _, l := range listeners { + if l.OnObjectUpdate != nil { + onObjectUpdateCbs = append(onObjectUpdateCbs, l.OnObjectUpdate) + } + } + if len(onObjectUpdateCbs) > 0 { + mux.OnObjectUpdate = func(data ObjectUpdateData) error { + for _, cb := range onObjectUpdateCbs { + if err := cb(data); err != nil { + return err + } + } + return nil + } + } + + commitCbs := make([]func(CommitData) error, 0, len(listeners)) + for _, l := range listeners { + if l.Commit != nil { + commitCbs = append(commitCbs, l.Commit) + } + } + if len(commitCbs) > 0 { + mux.Commit = func(data CommitData) error { + for _, cb := range commitCbs { + if err := cb(data); err != nil { + return err + } + } + return nil + } + } + + return mux +} diff --git a/schema/appdata/mux_test.go b/schema/appdata/mux_test.go new file mode 100644 index 000000000000..70787fada8a5 --- /dev/null +++ b/schema/appdata/mux_test.go @@ -0,0 +1,133 @@ +package appdata + +import ( + "fmt" + "testing" +) + +func TestListenerMux(t *testing.T) { + t.Run("empty", func(t *testing.T) { + listener := ListenerMux(Listener{}, Listener{}) + + if listener.InitializeModuleData != nil { + t.Error("expected nil") + } + if listener.StartBlock != nil { + t.Error("expected nil") + } + if listener.OnTx != nil { + t.Error("expected nil") + } + if listener.OnEvent != nil { + t.Error("expected nil") + } + if listener.OnKVPair != nil { + t.Error("expected nil") + } + if listener.OnObjectUpdate != nil { + t.Error("expected nil") + } + if listener.Commit != nil { + t.Error("expected nil") + } + }) + + t.Run("all called once", func(t *testing.T) { + var calls []string + onCall := func(name string, i int, _ Packet) { + calls = append(calls, fmt.Sprintf("%s %d", name, i)) + } + + res := ListenerMux(callCollector(1, onCall), callCollector(2, onCall)) + + callAllCallbacksOnces(t, res) + + checkExpectedCallOrder(t, calls, []string{ + "InitializeModuleData 1", + "InitializeModuleData 2", + "StartBlock 1", + "StartBlock 2", + "OnTx 1", + "OnTx 2", + "OnEvent 1", + "OnEvent 2", + "OnKVPair 1", + "OnKVPair 2", + "OnObjectUpdate 1", + "OnObjectUpdate 2", + "Commit 1", + "Commit 2", + }) + }) +} + +func callAllCallbacksOnces(t *testing.T, listener Listener) { + t.Helper() + if err := listener.InitializeModuleData(ModuleInitializationData{}); err != nil { + t.Error(err) + } + if err := listener.StartBlock(StartBlockData{}); err != nil { + t.Error(err) + } + if err := listener.OnTx(TxData{}); err != nil { + t.Error(err) + } + if err := listener.OnEvent(EventData{}); err != nil { + t.Error(err) + } + if err := listener.OnKVPair(KVPairData{}); err != nil { + t.Error(err) + } + if err := listener.OnObjectUpdate(ObjectUpdateData{}); err != nil { + t.Error(err) + } + if err := listener.Commit(CommitData{}); err != nil { + t.Error(err) + } +} + +func callCollector(i int, onCall func(string, int, Packet)) Listener { + return Listener{ + InitializeModuleData: func(ModuleInitializationData) error { + onCall("InitializeModuleData", i, nil) + return nil + }, + StartBlock: func(StartBlockData) error { + onCall("StartBlock", i, nil) + return nil + }, + OnTx: func(TxData) error { + onCall("OnTx", i, nil) + return nil + }, + OnEvent: func(EventData) error { + onCall("OnEvent", i, nil) + return nil + }, + OnKVPair: func(KVPairData) error { + onCall("OnKVPair", i, nil) + return nil + }, + OnObjectUpdate: func(ObjectUpdateData) error { + onCall("OnObjectUpdate", i, nil) + return nil + }, + Commit: func(CommitData) error { + onCall("Commit", i, nil) + return nil + }, + } +} + +func checkExpectedCallOrder(t *testing.T, actual, expected []string) { + t.Helper() + if len(actual) != len(expected) { + t.Fatalf("expected %d calls, got %d", len(expected), len(actual)) + } + + for i := range actual { + if actual[i] != expected[i] { + t.Errorf("expected %q, got %q", expected[i], actual[i]) + } + } +} diff --git a/schema/decoding/decoding_test.go b/schema/decoding/decoding_test.go index 988c1b5ea2e4..a671d2f4c35b 100644 --- a/schema/decoding/decoding_test.go +++ b/schema/decoding/decoding_test.go @@ -1,6 +1,7 @@ package decoding import ( + "errors" "fmt" "reflect" "sort" @@ -68,7 +69,7 @@ func TestMiddleware_filtered(t *testing.T) { tl := newTestFixture(t) listener, err := Middleware(tl.Listener, tl.resolver, MiddlewareOptions{ ModuleFilter: func(moduleName string) bool { - return moduleName == "one" + return moduleName == "one" //nolint:goconst // adding constants for this would impede readability }, }) if err != nil { @@ -176,6 +177,7 @@ type testFixture struct { } func newTestFixture(t *testing.T) *testFixture { + t.Helper() res := &testFixture{} res.Listener = appdata.Listener{ InitializeModuleData: func(data appdata.ModuleInitializationData) error { @@ -246,7 +248,7 @@ func newTestMultiStore() *testMultiStore { var _ SyncSource = &testMultiStore{} -func (ms *testMultiStore) IterateAllKVPairs(moduleName string, fn func(key []byte, value []byte) error) error { +func (ms *testMultiStore) IterateAllKVPairs(moduleName string, fn func(key, value []byte) error) error { s, ok := ms.stores[moduleName] if !ok { return fmt.Errorf("don't have state for module %s", moduleName) @@ -267,6 +269,7 @@ func (ms *testMultiStore) IterateAllKVPairs(moduleName string, fn func(key []byt } func (ms *testMultiStore) newTestStore(t *testing.T, modName string) *testStore { + t.Helper() s := &testStore{ t: t, modName: modName, @@ -358,14 +361,15 @@ func (e exampleBankModule) subBalance(acct, denom string, amount uint64) error { key := balanceKey(acct, denom) cur := e.store.GetUInt64(key) if cur < amount { - return fmt.Errorf("insufficient balance") + return errors.New("insufficient balance") } e.store.SetUInt64(key, cur-amount) return nil } -var exampleBankSchema = schema.ModuleSchema{ - ObjectTypes: []schema.ObjectType{ +func init() { + var err error + exampleBankSchema, err = schema.NewModuleSchema([]schema.ObjectType{ { Name: "balances", KeyFields: []schema.Field{ @@ -385,9 +389,14 @@ var exampleBankSchema = schema.ModuleSchema{ }, }, }, - }, + }) + if err != nil { + panic(err) + } } +var exampleBankSchema schema.ModuleSchema + func (e exampleBankModule) ModuleCodec() (schema.ModuleCodec, error) { return schema.ModuleCodec{ Schema: exampleBankSchema, @@ -424,17 +433,25 @@ type oneValueModule struct { store *testStore } -var oneValueModSchema = schema.ModuleSchema{ - ObjectTypes: []schema.ObjectType{ - { - Name: "item", - ValueFields: []schema.Field{ - {Name: "value", Kind: schema.StringKind}, +func init() { + var err error + oneValueModSchema, err = schema.NewModuleSchema( + []schema.ObjectType{ + { + Name: "item", + ValueFields: []schema.Field{ + {Name: "value", Kind: schema.StringKind}, + }, }, }, - }, + ) + if err != nil { + panic(err) + } } +var oneValueModSchema schema.ModuleSchema + func (i oneValueModule) ModuleCodec() (schema.ModuleCodec, error) { return schema.ModuleCodec{ Schema: oneValueModSchema, diff --git a/schema/decoding/resolver_test.go b/schema/decoding/resolver_test.go index d91197ac2675..a5e9fa33c947 100644 --- a/schema/decoding/resolver_test.go +++ b/schema/decoding/resolver_test.go @@ -10,16 +10,24 @@ import ( type modA struct{} func (m modA) ModuleCodec() (schema.ModuleCodec, error) { + modSchema, err := schema.NewModuleSchema([]schema.ObjectType{{Name: "A", KeyFields: []schema.Field{{Name: "field1", Kind: schema.StringKind}}}}) + if err != nil { + return schema.ModuleCodec{}, err + } return schema.ModuleCodec{ - Schema: schema.ModuleSchema{ObjectTypes: []schema.ObjectType{{Name: "A"}}}, + Schema: modSchema, }, nil } type modB struct{} func (m modB) ModuleCodec() (schema.ModuleCodec, error) { + modSchema, err := schema.NewModuleSchema([]schema.ObjectType{{Name: "B", KeyFields: []schema.Field{{Name: "field2", Kind: schema.StringKind}}}}) + if err != nil { + return schema.ModuleCodec{}, err + } return schema.ModuleCodec{ - Schema: schema.ModuleSchema{ObjectTypes: []schema.ObjectType{{Name: "B"}}}, + Schema: modSchema, }, nil } @@ -36,10 +44,15 @@ var testResolver = ModuleSetDecoderResolver(moduleSet) func TestModuleSetDecoderResolver_IterateAll(t *testing.T) { objectTypes := map[string]bool{} err := testResolver.IterateAll(func(moduleName string, cdc schema.ModuleCodec) error { - objectTypes[cdc.Schema.ObjectTypes[0].Name] = true + cdc.Schema.Types(func(t schema.Type) bool { + objTyp, ok := t.(schema.ObjectType) + if ok { + objectTypes[objTyp.Name] = true + } + return true + }) return nil }) - if err != nil { t.Fatalf("unexpected error: %v", err) } @@ -67,8 +80,9 @@ func TestModuleSetDecoderResolver_LookupDecoder(t *testing.T) { t.Fatalf("expected to find decoder for modA") } - if decoder.Schema.ObjectTypes[0].Name != "A" { - t.Fatalf("expected object type A, got %s", decoder.Schema.ObjectTypes[0].Name) + _, ok := decoder.Schema.LookupType("A") + if !ok { + t.Fatalf("expected object type A") } decoder, found, err = testResolver.LookupDecoder("modB") @@ -80,8 +94,9 @@ func TestModuleSetDecoderResolver_LookupDecoder(t *testing.T) { t.Fatalf("expected to find decoder for modB") } - if decoder.Schema.ObjectTypes[0].Name != "B" { - t.Fatalf("expected object type B, got %s", decoder.Schema.ObjectTypes[0].Name) + _, ok = decoder.Schema.LookupType("B") + if !ok { + t.Fatalf("expected object type B") } decoder, found, err = testResolver.LookupDecoder("modC") diff --git a/schema/decoding/sync.go b/schema/decoding/sync.go index 19582cfa37ad..d8aee9884c6a 100644 --- a/schema/decoding/sync.go +++ b/schema/decoding/sync.go @@ -8,7 +8,6 @@ import ( // SyncSource is an interface that allows indexers to start indexing modules with pre-existing state. // It should generally be a wrapper around the key-value store. type SyncSource interface { - // IterateAllKVPairs iterates over all key-value pairs for a given module. IterateAllKVPairs(moduleName string, fn func(key, value []byte) error) error } diff --git a/schema/enum.go b/schema/enum.go index 927cc827cb3e..5ceb435313d1 100644 --- a/schema/enum.go +++ b/schema/enum.go @@ -5,8 +5,8 @@ import ( "fmt" ) -// EnumDefinition represents the definition of an enum type. -type EnumDefinition struct { +// EnumType represents the definition of an enum type. +type EnumType struct { // Name is the name of the enum type. It must conform to the NameFormat regular expression. // Its name must be unique between all enum types and object types in the module. // The same enum, however, can be used in multiple object types and fields as long as the @@ -18,8 +18,15 @@ type EnumDefinition struct { Values []string } +// TypeName implements the Type interface. +func (e EnumType) TypeName() string { + return e.Name +} + +func (EnumType) isType() {} + // Validate validates the enum definition. -func (e EnumDefinition) Validate() error { +func (e EnumType) Validate() error { if !ValidateName(e.Name) { return fmt.Errorf("invalid enum definition name %q", e.Name) } @@ -42,7 +49,7 @@ func (e EnumDefinition) Validate() error { } // ValidateValue validates that the value is a valid enum value. -func (e EnumDefinition) ValidateValue(value string) error { +func (e EnumType) ValidateValue(value string) error { for _, v := range e.Values { if v == value { return nil @@ -50,31 +57,3 @@ func (e EnumDefinition) ValidateValue(value string) error { } return fmt.Errorf("value %q is not a valid enum value for %s", value, e.Name) } - -// checkEnumCompatibility checks that the enum values are consistent across object types and fields. -func checkEnumCompatibility(enumValueMap map[string]map[string]bool, field Field) error { - if field.Kind != EnumKind { - return nil - } - - enum := field.EnumDefinition - - if existing, ok := enumValueMap[enum.Name]; ok { - if len(existing) != len(enum.Values) { - return fmt.Errorf("enum %q has different number of values in different object types", enum.Name) - } - - for _, value := range enum.Values { - if !existing[value] { - return fmt.Errorf("enum %q has different values in different object types", enum.Name) - } - } - } else { - valueMap := map[string]bool{} - for _, value := range enum.Values { - valueMap[value] = true - } - enumValueMap[enum.Name] = valueMap - } - return nil -} diff --git a/schema/enum_test.go b/schema/enum_test.go index 435449d0c564..51881f29ff09 100644 --- a/schema/enum_test.go +++ b/schema/enum_test.go @@ -8,12 +8,12 @@ import ( func TestEnumDefinition_Validate(t *testing.T) { tests := []struct { name string - enum EnumDefinition + enum EnumType errContains string }{ { name: "valid enum", - enum: EnumDefinition{ + enum: EnumType{ Name: "test", Values: []string{"a", "b", "c"}, }, @@ -21,7 +21,7 @@ func TestEnumDefinition_Validate(t *testing.T) { }, { name: "empty name", - enum: EnumDefinition{ + enum: EnumType{ Name: "", Values: []string{"a", "b", "c"}, }, @@ -29,7 +29,7 @@ func TestEnumDefinition_Validate(t *testing.T) { }, { name: "empty values", - enum: EnumDefinition{ + enum: EnumType{ Name: "test", Values: []string{}, }, @@ -37,7 +37,7 @@ func TestEnumDefinition_Validate(t *testing.T) { }, { name: "empty value", - enum: EnumDefinition{ + enum: EnumType{ Name: "test", Values: []string{"a", "", "c"}, }, @@ -45,7 +45,7 @@ func TestEnumDefinition_Validate(t *testing.T) { }, { name: "duplicate value", - enum: EnumDefinition{ + enum: EnumType{ Name: "test", Values: []string{"a", "b", "a"}, }, @@ -72,7 +72,7 @@ func TestEnumDefinition_Validate(t *testing.T) { } func TestEnumDefinition_ValidateValue(t *testing.T) { - enum := EnumDefinition{ + enum := EnumType{ Name: "test", Values: []string{"a", "b", "c"}, } diff --git a/schema/field.go b/schema/field.go index 19a1b4085dd6..bd3e3997e1ed 100644 --- a/schema/field.go +++ b/schema/field.go @@ -13,15 +13,11 @@ type Field struct { // Nullable indicates whether null values are accepted for the field. Key fields CANNOT be nullable. Nullable bool - // AddressPrefix is the address prefix of the field's kind, currently only used for Bech32AddressKind. - // TODO: in a future update, stricter criteria and validation for address prefixes should be added. - AddressPrefix string - - // EnumDefinition is the definition of the enum type and is only valid when Kind is EnumKind. + // EnumType is the definition of the enum type and is only valid when Kind is EnumKind. // The same enum types can be reused in the same module schema, but they always must contain // the same values for the same enum name. This possibly introduces some duplication of // definitions but makes it easier to reason about correctness and validation in isolation. - EnumDefinition EnumDefinition + EnumType EnumType } // Validate validates the field. @@ -36,19 +32,12 @@ func (c Field) Validate() error { return fmt.Errorf("invalid field kind for %q: %v", c.Name, err) //nolint:errorlint // false positive due to using go1.12 } - // address prefix only valid with Bech32AddressKind - if c.Kind == Bech32AddressKind && c.AddressPrefix == "" { - return fmt.Errorf("missing address prefix for field %q", c.Name) - } else if c.Kind != Bech32AddressKind && c.AddressPrefix != "" { - return fmt.Errorf("address prefix is only valid for field %q with type Bech32AddressKind", c.Name) - } - // enum definition only valid with EnumKind if c.Kind == EnumKind { - if err := c.EnumDefinition.Validate(); err != nil { + if err := c.EnumType.Validate(); err != nil { return fmt.Errorf("invalid enum definition for field %q: %v", c.Name, err) //nolint:errorlint // false positive due to using go1.12 } - } else if c.Kind != EnumKind && (c.EnumDefinition.Name != "" || c.EnumDefinition.Values != nil) { + } else if c.Kind != EnumKind && (c.EnumType.Name != "" || c.EnumType.Values != nil) { return fmt.Errorf("enum definition is only valid for field %q with type EnumKind", c.Name) } @@ -56,7 +45,7 @@ func (c Field) Validate() error { } // ValidateValue validates that the value conforms to the field's kind and nullability. -// Unlike Kind.ValidateValue, it also checks that the value conforms to the EnumDefinition +// Unlike Kind.ValidateValue, it also checks that the value conforms to the EnumType // if the field is an EnumKind. func (c Field) ValidateValue(value interface{}) error { if value == nil { @@ -71,7 +60,7 @@ func (c Field) ValidateValue(value interface{}) error { } if c.Kind == EnumKind { - return c.EnumDefinition.ValidateValue(value.(string)) + return c.EnumType.ValidateValue(value.(string)) } return nil diff --git a/schema/field_test.go b/schema/field_test.go index a1f8087fff6a..5fd7d8015c73 100644 --- a/schema/field_test.go +++ b/schema/field_test.go @@ -35,23 +35,6 @@ func TestField_Validate(t *testing.T) { }, errContains: "invalid field kind", }, - { - name: "missing address prefix", - field: Field{ - Name: "field1", - Kind: Bech32AddressKind, - }, - errContains: "missing address prefix", - }, - { - name: "address prefix with non-Bech32AddressKind", - field: Field{ - Name: "field1", - Kind: StringKind, - AddressPrefix: "prefix", - }, - errContains: "address prefix is only valid for field \"field1\" with type Bech32AddressKind", - }, { name: "invalid enum definition", field: Field{ @@ -63,18 +46,18 @@ func TestField_Validate(t *testing.T) { { name: "enum definition with non-EnumKind", field: Field{ - Name: "field1", - Kind: StringKind, - EnumDefinition: EnumDefinition{Name: "enum"}, + Name: "field1", + Kind: StringKind, + EnumType: EnumType{Name: "enum"}, }, errContains: "enum definition is only valid for field \"field1\" with type EnumKind", }, { name: "valid enum", field: Field{ - Name: "field1", - Kind: EnumKind, - EnumDefinition: EnumDefinition{Name: "enum", Values: []string{"a", "b"}}, + Name: "field1", + Kind: EnumKind, + EnumType: EnumType{Name: "enum", Values: []string{"a", "b"}}, }, }, } @@ -145,9 +128,9 @@ func TestField_ValidateValue(t *testing.T) { { name: "valid enum", field: Field{ - Name: "field1", - Kind: EnumKind, - EnumDefinition: EnumDefinition{Name: "enum", Values: []string{"a", "b"}}, + Name: "field1", + Kind: EnumKind, + EnumType: EnumType{Name: "enum", Values: []string{"a", "b"}}, }, value: "a", errContains: "", @@ -155,9 +138,9 @@ func TestField_ValidateValue(t *testing.T) { { name: "invalid enum", field: Field{ - Name: "field1", - Kind: EnumKind, - EnumDefinition: EnumDefinition{Name: "enum", Values: []string{"a", "b"}}, + Name: "field1", + Kind: EnumKind, + EnumType: EnumType{Name: "enum", Values: []string{"a", "b"}}, }, value: "c", errContains: "not a valid enum value", diff --git a/schema/kind.go b/schema/kind.go index c3fefad52c8a..44d18e100ffd 100644 --- a/schema/kind.go +++ b/schema/kind.go @@ -72,13 +72,13 @@ const ( // Float64Kind is a float64 type and values of this type must be of the go type float64. Float64Kind - // Bech32AddressKind is a bech32 address type and values of this type must be of the go type []byte. - // Fields of this type are expected to set the AddressPrefix field in the field definition to the - // bech32 address prefix so that indexers can properly convert them to strings. - Bech32AddressKind + // AddressKind represents an account address and must be of type []byte. Addresses usually have a + // human-readable rendering, such as bech32, and tooling should provide a way for apps to define a + // string encoder for friendly user-facing display. + AddressKind // EnumKind is an enum type and values of this type must be of the go type string. - // Fields of this type are expected to set the EnumDefinition field in the field definition to the enum + // Fields of this type are expected to set the EnumType field in the field definition to the enum // definition. EnumKind @@ -150,8 +150,8 @@ func (t Kind) String() string { return "float32" case Float64Kind: return "float64" - case Bech32AddressKind: - return "bech32address" + case AddressKind: + return "address" case EnumKind: return "enum" case JSONKind: @@ -254,7 +254,7 @@ func (t Kind) ValidateValueType(value interface{}) error { if !ok { return fmt.Errorf("expected float64, got %T", value) } - case Bech32AddressKind: + case AddressKind: _, ok := value.([]byte) if !ok { return fmt.Errorf("expected []byte, got %T", value) @@ -321,7 +321,7 @@ var ( ) // KindForGoValue finds the simplest kind that can represent the given go value. It will not, however, -// return kinds such as IntegerStringKind, DecimalStringKind, Bech32AddressKind, or EnumKind which all can be +// return kinds such as IntegerStringKind, DecimalStringKind, AddressKind, or EnumKind which all can be // represented as strings. func KindForGoValue(value interface{}) Kind { switch value.(type) { diff --git a/schema/kind_test.go b/schema/kind_test.go index 49799fe4956c..a337ba278331 100644 --- a/schema/kind_test.go +++ b/schema/kind_test.go @@ -59,8 +59,8 @@ func TestKind_ValidateValueType(t *testing.T) { {kind: DecimalStringKind, value: "1", valid: true}, {kind: DecimalStringKind, value: "1.1e4", valid: true}, {kind: DecimalStringKind, value: int32(1), valid: false}, - {kind: Bech32AddressKind, value: []byte("hello"), valid: true}, - {kind: Bech32AddressKind, value: 1, valid: false}, + {kind: AddressKind, value: []byte("hello"), valid: true}, + {kind: AddressKind, value: 1, valid: false}, {kind: BoolKind, value: true, valid: true}, {kind: BoolKind, value: false, valid: true}, {kind: BoolKind, value: 1, valid: false}, @@ -213,7 +213,7 @@ func TestKind_String(t *testing.T) { {Float64Kind, "float64"}, {JSONKind, "json"}, {EnumKind, "enum"}, - {Bech32AddressKind, "bech32address"}, + {AddressKind, "address"}, {InvalidKind, "invalid(0)"}, } for i, tt := range tests { diff --git a/schema/module_schema.go b/schema/module_schema.go index 9412c4456cbe..f90a44c192b1 100644 --- a/schema/module_schema.go +++ b/schema/module_schema.go @@ -1,18 +1,82 @@ package schema -import "fmt" +import ( + "fmt" + "sort" +) // ModuleSchema represents the logical schema of a module for purposes of indexing and querying. type ModuleSchema struct { - // ObjectTypes describe the types of objects that are part of the module's schema. - ObjectTypes []ObjectType + types map[string]Type +} + +// NewModuleSchema constructs a new ModuleSchema and validates it. Any module schema returned without an error +// is guaranteed to be valid. +func NewModuleSchema(objectTypes []ObjectType) (ModuleSchema, error) { + types := map[string]Type{} + + for _, objectType := range objectTypes { + types[objectType.Name] = objectType + } + + res := ModuleSchema{types: types} + + // validate adds all enum types to the type map + err := res.Validate() + if err != nil { + return ModuleSchema{}, err + } + + return res, nil +} + +func addEnumType(types map[string]Type, field Field) error { + enumDef := field.EnumType + if enumDef.Name == "" { + return nil + } + + existing, ok := types[enumDef.Name] + if !ok { + types[enumDef.Name] = enumDef + return nil + } + + existingEnum, ok := existing.(EnumType) + if !ok { + return fmt.Errorf("enum %q already exists as a different non-enum type", enumDef.Name) + } + + if len(existingEnum.Values) != len(enumDef.Values) { + return fmt.Errorf("enum %q has different number of values in different fields", enumDef.Name) + } + + existingValues := map[string]bool{} + for _, value := range existingEnum.Values { + existingValues[value] = true + } + + for _, value := range enumDef.Values { + _, ok := existingValues[value] + if !ok { + return fmt.Errorf("enum %q has different values in different fields", enumDef.Name) + } + } + + return nil } // Validate validates the module schema. func (s ModuleSchema) Validate() error { - enumValueMap := map[string]map[string]bool{} - for _, objType := range s.ObjectTypes { - if err := objType.validate(enumValueMap); err != nil { + for _, typ := range s.types { + objTyp, ok := typ.(ObjectType) + if !ok { + continue + } + + // all enum types get added to the type map when we call ObjectType.validate + err := objTyp.validate(s.types) + if err != nil { return err } } @@ -22,10 +86,58 @@ func (s ModuleSchema) Validate() error { // ValidateObjectUpdate validates that the update conforms to the module schema. func (s ModuleSchema) ValidateObjectUpdate(update ObjectUpdate) error { - for _, objType := range s.ObjectTypes { - if objType.Name == update.TypeName { - return objType.ValidateObjectUpdate(update) + typ, ok := s.types[update.TypeName] + if !ok { + return fmt.Errorf("object type %q not found in module schema", update.TypeName) + } + + objTyp, ok := typ.(ObjectType) + if !ok { + return fmt.Errorf("type %q is not an object type", update.TypeName) + } + + return objTyp.ValidateObjectUpdate(update) +} + +// LookupType looks up a type by name in the module schema. +func (s ModuleSchema) LookupType(name string) (Type, bool) { + typ, ok := s.types[name] + return typ, ok +} + +// Types calls the provided function for each type in the module schema and stops if the function returns false. +// The types are iterated over in sorted order by name. This function is compatible with go 1.23 iterators. +func (s ModuleSchema) Types(f func(Type) bool) { + keys := make([]string, 0, len(s.types)) + for k := range s.types { + keys = append(keys, k) + } + sort.Strings(keys) + for _, k := range keys { + if !f(s.types[k]) { + break } } - return fmt.Errorf("object type %q not found in module schema", update.TypeName) +} + +// ObjectTypes iterators over all the object types in the schema in alphabetical order. +func (s ModuleSchema) ObjectTypes(f func(ObjectType) bool) { + s.Types(func(t Type) bool { + objTyp, ok := t.(ObjectType) + if ok { + return f(objTyp) + } + return true + }) +} + +// EnumTypes iterators over all the enum types in the schema in alphabetical order. +func (s ModuleSchema) EnumTypes(f func(EnumType) bool) { + s.Types(func(t Type) bool { + enumType, ok := t.(EnumType) + if ok { + return f(enumType) + } + return true + }) } diff --git a/schema/module_schema_test.go b/schema/module_schema_test.go index d04327811be6..2e4a927acc5d 100644 --- a/schema/module_schema_test.go +++ b/schema/module_schema_test.go @@ -1,27 +1,26 @@ package schema import ( + "reflect" "strings" "testing" ) func TestModuleSchema_Validate(t *testing.T) { tests := []struct { - name string - moduleSchema ModuleSchema - errContains string + name string + objectTypes []ObjectType + errContains string }{ { name: "valid module schema", - moduleSchema: ModuleSchema{ - ObjectTypes: []ObjectType{ - { - Name: "object1", - KeyFields: []Field{ - { - Name: "field1", - Kind: StringKind, - }, + objectTypes: []ObjectType{ + { + Name: "object1", + KeyFields: []Field{ + { + Name: "field1", + Kind: StringKind, }, }, }, @@ -30,15 +29,13 @@ func TestModuleSchema_Validate(t *testing.T) { }, { name: "invalid object type", - moduleSchema: ModuleSchema{ - ObjectTypes: []ObjectType{ - { - Name: "", - KeyFields: []Field{ - { - Name: "field1", - Kind: StringKind, - }, + objectTypes: []ObjectType{ + { + Name: "", + KeyFields: []Field{ + { + Name: "field1", + Kind: StringKind, }, }, }, @@ -47,28 +44,26 @@ func TestModuleSchema_Validate(t *testing.T) { }, { name: "same enum with missing values", - moduleSchema: ModuleSchema{ - ObjectTypes: []ObjectType{ - { - Name: "object1", - KeyFields: []Field{ - { - Name: "k", - Kind: EnumKind, - EnumDefinition: EnumDefinition{ - Name: "enum1", - Values: []string{"a", "b"}, - }, + objectTypes: []ObjectType{ + { + Name: "object1", + KeyFields: []Field{ + { + Name: "k", + Kind: EnumKind, + EnumType: EnumType{ + Name: "enum1", + Values: []string{"a", "b"}, }, }, - ValueFields: []Field{ - { - Name: "v", - Kind: EnumKind, - EnumDefinition: EnumDefinition{ - Name: "enum1", - Values: []string{"a", "b", "c"}, - }, + }, + ValueFields: []Field{ + { + Name: "v", + Kind: EnumKind, + EnumType: EnumType{ + Name: "enum1", + Values: []string{"a", "b", "c"}, }, }, }, @@ -78,31 +73,29 @@ func TestModuleSchema_Validate(t *testing.T) { }, { name: "same enum with different values", - moduleSchema: ModuleSchema{ - ObjectTypes: []ObjectType{ - { - Name: "object1", - KeyFields: []Field{ - { - Name: "k", - Kind: EnumKind, - EnumDefinition: EnumDefinition{ - Name: "enum1", - Values: []string{"a", "b"}, - }, + objectTypes: []ObjectType{ + { + Name: "object1", + KeyFields: []Field{ + { + Name: "k", + Kind: EnumKind, + EnumType: EnumType{ + Name: "enum1", + Values: []string{"a", "b"}, }, }, }, - { - Name: "object2", - KeyFields: []Field{ - { - Name: "k", - Kind: EnumKind, - EnumDefinition: EnumDefinition{ - Name: "enum1", - Values: []string{"a", "c"}, - }, + }, + { + Name: "object2", + KeyFields: []Field{ + { + Name: "k", + Kind: EnumKind, + EnumType: EnumType{ + Name: "enum1", + Values: []string{"a", "c"}, }, }, }, @@ -112,42 +105,59 @@ func TestModuleSchema_Validate(t *testing.T) { }, { name: "same enum", - moduleSchema: ModuleSchema{ - ObjectTypes: []ObjectType{ - { - Name: "object1", - KeyFields: []Field{ - { - Name: "k", - Kind: EnumKind, - EnumDefinition: EnumDefinition{ - Name: "enum1", - Values: []string{"a", "b"}, - }, + objectTypes: []ObjectType{ + { + Name: "object1", + KeyFields: []Field{ + { + Name: "k", + Kind: EnumKind, + EnumType: EnumType{ + Name: "enum1", + Values: []string{"a", "b"}, }, }, }, - { - Name: "object2", - KeyFields: []Field{ - { - Name: "k", - Kind: EnumKind, - EnumDefinition: EnumDefinition{ - Name: "enum1", - Values: []string{"a", "b"}, - }, + }, + { + Name: "object2", + KeyFields: []Field{ + { + Name: "k", + Kind: EnumKind, + EnumType: EnumType{ + Name: "enum1", + Values: []string{"a", "b"}, }, }, }, }, }, }, + { + objectTypes: []ObjectType{ + { + Name: "type1", + ValueFields: []Field{ + { + Name: "field1", + Kind: EnumKind, + EnumType: EnumType{ + Name: "type1", + Values: []string{"a", "b"}, + }, + }, + }, + }, + }, + errContains: "enum \"type1\" already exists as a different non-enum type", + }, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { - err := tt.moduleSchema.Validate() + // because validate is called when calling NewModuleSchema, we just call NewModuleSchema + _, err := NewModuleSchema(tt.objectTypes) if tt.errContains == "" { if err != nil { t.Fatalf("unexpected error: %v", err) @@ -170,19 +180,18 @@ func TestModuleSchema_ValidateObjectUpdate(t *testing.T) { }{ { name: "valid object update", - moduleSchema: ModuleSchema{ - ObjectTypes: []ObjectType{ - { - Name: "object1", - KeyFields: []Field{ - { - Name: "field1", - Kind: StringKind, - }, + moduleSchema: requireModuleSchema(t, []ObjectType{ + { + Name: "object1", + KeyFields: []Field{ + { + Name: "field1", + Kind: StringKind, }, }, }, }, + ), objectUpdate: ObjectUpdate{ TypeName: "object1", Key: "abc", @@ -191,25 +200,47 @@ func TestModuleSchema_ValidateObjectUpdate(t *testing.T) { }, { name: "object type not found", - moduleSchema: ModuleSchema{ - ObjectTypes: []ObjectType{ - { - Name: "object1", - KeyFields: []Field{ - { - Name: "field1", - Kind: StringKind, - }, + moduleSchema: requireModuleSchema(t, []ObjectType{ + { + Name: "object1", + KeyFields: []Field{ + { + Name: "field1", + Kind: StringKind, }, }, }, }, + ), objectUpdate: ObjectUpdate{ TypeName: "object2", Key: "abc", }, errContains: "object type \"object2\" not found in module schema", }, + { + name: "type name refers to an enum", + moduleSchema: requireModuleSchema(t, []ObjectType{ + { + Name: "obj1", + KeyFields: []Field{ + { + Name: "field1", + Kind: EnumKind, + EnumType: EnumType{ + Name: "enum1", + Values: []string{"a", "b"}, + }, + }, + }, + }, + }), + objectUpdate: ObjectUpdate{ + TypeName: "enum1", + Key: "a", + }, + errContains: "type \"enum1\" is not an object type", + }, } for _, tt := range tests { @@ -227,3 +258,153 @@ func TestModuleSchema_ValidateObjectUpdate(t *testing.T) { }) } } + +func requireModuleSchema(t *testing.T, objectTypes []ObjectType) ModuleSchema { + t.Helper() + moduleSchema, err := NewModuleSchema(objectTypes) + if err != nil { + t.Fatalf("unexpected error: %v", err) + } + return moduleSchema +} + +func TestModuleSchema_LookupType(t *testing.T) { + moduleSchema := requireModuleSchema(t, []ObjectType{ + { + Name: "object1", + KeyFields: []Field{ + { + Name: "field1", + Kind: StringKind, + }, + }, + }, + }) + + typ, ok := moduleSchema.LookupType("object1") + if !ok { + t.Fatalf("expected to find object type \"object1\"") + } + + objectType, ok := typ.(ObjectType) + if !ok { + t.Fatalf("expected object type, got %T", typ) + } + + if objectType.Name != "object1" { + t.Fatalf("expected object type name \"object1\", got %q", objectType.Name) + } +} + +func exampleSchema(t *testing.T) ModuleSchema { + t.Helper() + return requireModuleSchema(t, []ObjectType{ + { + Name: "object1", + KeyFields: []Field{ + { + Name: "field1", + Kind: EnumKind, + EnumType: EnumType{ + Name: "enum2", + Values: []string{"d", "e", "f"}, + }, + }, + }, + }, + { + Name: "object2", + KeyFields: []Field{ + { + Name: "field1", + Kind: EnumKind, + EnumType: EnumType{ + Name: "enum1", + Values: []string{"a", "b", "c"}, + }, + }, + }, + }, + }) +} + +func TestModuleSchema_Types(t *testing.T) { + moduleSchema := exampleSchema(t) + + var typeNames []string + moduleSchema.Types(func(typ Type) bool { + typeNames = append(typeNames, typ.TypeName()) + return true + }) + + expected := []string{"enum1", "enum2", "object1", "object2"} + if !reflect.DeepEqual(typeNames, expected) { + t.Fatalf("expected %v, got %v", expected, typeNames) + } + + typeNames = nil + // scan just the first type and return false + moduleSchema.Types(func(typ Type) bool { + typeNames = append(typeNames, typ.TypeName()) + return false + }) + + expected = []string{"enum1"} + if !reflect.DeepEqual(typeNames, expected) { + t.Fatalf("expected %v, got %v", expected, typeNames) + } +} + +func TestModuleSchema_ObjectTypes(t *testing.T) { + moduleSchema := exampleSchema(t) + + var typeNames []string + moduleSchema.ObjectTypes(func(typ ObjectType) bool { + typeNames = append(typeNames, typ.Name) + return true + }) + + expected := []string{"object1", "object2"} + if !reflect.DeepEqual(typeNames, expected) { + t.Fatalf("expected %v, got %v", expected, typeNames) + } + + typeNames = nil + // scan just the first type and return false + moduleSchema.ObjectTypes(func(typ ObjectType) bool { + typeNames = append(typeNames, typ.Name) + return false + }) + + expected = []string{"object1"} + if !reflect.DeepEqual(typeNames, expected) { + t.Fatalf("expected %v, got %v", expected, typeNames) + } +} + +func TestModuleSchema_EnumTypes(t *testing.T) { + moduleSchema := exampleSchema(t) + + var typeNames []string + moduleSchema.EnumTypes(func(typ EnumType) bool { + typeNames = append(typeNames, typ.Name) + return true + }) + + expected := []string{"enum1", "enum2"} + if !reflect.DeepEqual(typeNames, expected) { + t.Fatalf("expected %v, got %v", expected, typeNames) + } + + typeNames = nil + // scan just the first type and return false + moduleSchema.EnumTypes(func(typ EnumType) bool { + typeNames = append(typeNames, typ.Name) + return false + }) + + expected = []string{"enum1"} + if !reflect.DeepEqual(typeNames, expected) { + t.Fatalf("expected %v, got %v", expected, typeNames) + } +} diff --git a/schema/object_type.go b/schema/object_type.go index a8fa432d8032..379d7d4a8382 100644 --- a/schema/object_type.go +++ b/schema/object_type.go @@ -4,8 +4,8 @@ import "fmt" // ObjectType describes an object type a module schema. type ObjectType struct { - // Name is the name of the object type. It must be unique within the module schema - // and conform to the NameFormat regular expression. + // Name is the name of the object type. It must be unique within the module schema amongst all object and enum + // types and conform to the NameFormat regular expression. Name string // KeyFields is a list of fields that make up the primary key of the object. @@ -27,14 +27,21 @@ type ObjectType struct { RetainDeletions bool } +// TypeName implements the Type interface. +func (o ObjectType) TypeName() string { + return o.Name +} + +func (ObjectType) isType() {} + // Validate validates the object type. func (o ObjectType) Validate() error { - return o.validate(map[string]map[string]bool{}) + return o.validate(map[string]Type{}) } // validate validates the object type with an enumValueMap that can be // shared across a whole module schema. -func (o ObjectType) validate(enumValueMap map[string]map[string]bool) error { +func (o ObjectType) validate(types map[string]Type) error { if !ValidateName(o.Name) { return fmt.Errorf("invalid object type name %q", o.Name) } @@ -55,7 +62,8 @@ func (o ObjectType) validate(enumValueMap map[string]map[string]bool) error { } fieldNames[field.Name] = true - if err := checkEnumCompatibility(enumValueMap, field); err != nil { + err := addEnumType(types, field) + if err != nil { return err } } @@ -70,7 +78,8 @@ func (o ObjectType) validate(enumValueMap map[string]map[string]bool) error { } fieldNames[field.Name] = true - if err := checkEnumCompatibility(enumValueMap, field); err != nil { + err := addEnumType(types, field) + if err != nil { return err } } diff --git a/schema/object_type_test.go b/schema/object_type_test.go index 0a78a371aa96..68a85111b7b6 100644 --- a/schema/object_type_test.go +++ b/schema/object_type_test.go @@ -170,7 +170,7 @@ func TestObjectType_Validate(t *testing.T) { { Name: "key", Kind: EnumKind, - EnumDefinition: EnumDefinition{ + EnumType: EnumType{ Name: "enum1", Values: []string{"a", "b"}, }, @@ -180,7 +180,7 @@ func TestObjectType_Validate(t *testing.T) { { Name: "value", Kind: EnumKind, - EnumDefinition: EnumDefinition{ + EnumType: EnumType{ Name: "enum1", Values: []string{"c", "b"}, }, diff --git a/schema/testing/CHANGELOG.md b/schema/testing/CHANGELOG.md new file mode 100644 index 000000000000..0c3c9d03857f --- /dev/null +++ b/schema/testing/CHANGELOG.md @@ -0,0 +1,37 @@ + + +# Changelog + +## [Unreleased] diff --git a/schema/testing/README.md b/schema/testing/README.md new file mode 100644 index 000000000000..4a9ac319882e --- /dev/null +++ b/schema/testing/README.md @@ -0,0 +1,50 @@ +# Schema & Indexer Testing + +This module contains core test utilities and fixtures for testing `cosmossdk.io/schema` and `cosmossdk.io/schema/indexer` functionality. It is managed as a separate go module to manage versions better and allow for dependencies on useful testing libraries without imposing those elsewhere. + +The two primary intended uses of this library are: +- testing that indexers can handle all valid app data that they might be asked to index +- testing that state management frameworks properly map their data to and from schema types + +## Testing Indexers + +Indexers are expected to process all valid `schema` and `appdata` types, yet it may be hard to find a data set in the wild that comprehensively represents the full valid range of these types. This library provides utilities for simulating such data. The simplest way for an indexer to leverage this test framework is to implement the `appdatasim.HasAppData` type against their data store. Then the `appdatasim.Simulator` can be used to generate deterministically random valid data that can be sent to the indexer and also stored in the simulator. After each generated block is applied, `appdatasim.DiffAppData` can be used to compare the expected state in the simulator to the actual state in the indexer. + +This example code shows how this might look in a test: + +```go +func TestMyIndexer(t *testing.T) { + var myIndexerListener appdata.Listener + var myIndexerAppData appdatasim.HasAppData + // do the setup for your indexer and return an appdata.Listener to consume updates and the appdatasim.HasAppData instance to check the actual vs expected data + myIndexerListener, myIndexerAppData := myIndexer.Setup() + + simulator, err := appdatasim.NewSimulator(appdatatest.SimulatorOptions{ + AppSchema: indexertesting.ExampleAppSchema, + StateSimOptions: statesim.Options{ + CanRetainDeletions: true, + }, + Listener: myIndexerListener, + }) + require.NoError(t, err) + + blockDataGen := simulator.BlockDataGen() + for i := 0; i < 1000; i++ { + // using Example generates a deterministic data set based + // on a seed so that regression tests can be created OR rapid.Check can + // be used for fully random property-based testing + blockData := blockDataGen.Example(i) + + // process the generated block data with the simulator which will also + // send it to the indexer + require.NoError(t, simulator.ProcessBlockData(blockData)) + + // compare the expected state in the simulator to the actual state in the indexer and expect the diff to be empty + require.Empty(t, appdatasim.DiffAppData(simulator, myIndexerAppData)) + } +} +``` + +## Testing State Management Frameworks + +The compliance of frameworks like `cosmossdk.io/collections` and `cosmossdk.io/orm` with `cosmossdk.io/schema` can be tested with this framework. One example of how this might be done is if there is a `KeyCodec` that represents an array of `schema.Field`s then `schematesting.ObjectKeyGen` might be used to generate a random object key which encoded and then decoded and then `schematesting.DiffObjectKeys` is used to compare the expected key with the decoded key. If such state management frameworks require that users that schema compliance when implementing things like `KeyCodec`s then those state management frameworks should specify best practices for users. \ No newline at end of file diff --git a/schema/testing/app.go b/schema/testing/app.go new file mode 100644 index 000000000000..feda6d036346 --- /dev/null +++ b/schema/testing/app.go @@ -0,0 +1,21 @@ +package schematesting + +import ( + "fmt" + + "pgregory.net/rapid" + + "cosmossdk.io/schema" +) + +// AppSchemaGen generates random valid app schemas, essentially a map of module names to module schemas. +var AppSchemaGen = rapid.Custom(func(t *rapid.T) map[string]schema.ModuleSchema { + schema := make(map[string]schema.ModuleSchema) + numModules := rapid.IntRange(1, 10).Draw(t, "numModules") + for i := 0; i < numModules; i++ { + moduleName := NameGen.Draw(t, "moduleName") + moduleSchema := ModuleSchemaGen.Draw(t, fmt.Sprintf("moduleSchema[%s]", moduleName)) + schema[moduleName] = moduleSchema + } + return schema +}) diff --git a/schema/testing/app_test.go b/schema/testing/app_test.go new file mode 100644 index 000000000000..ac2600e238f2 --- /dev/null +++ b/schema/testing/app_test.go @@ -0,0 +1,18 @@ +package schematesting + +import ( + "testing" + + "github.com/stretchr/testify/require" + "pgregory.net/rapid" +) + +func TestAppSchema(t *testing.T) { + rapid.Check(t, func(t *rapid.T) { + schema := AppSchemaGen.Draw(t, "schema") + for moduleName, moduleSchema := range schema { + require.NotEmpty(t, moduleName) + require.NoError(t, moduleSchema.Validate()) + } + }) +} diff --git a/schema/testing/appdatasim/app_data.go b/schema/testing/appdatasim/app_data.go new file mode 100644 index 000000000000..db82d285de5a --- /dev/null +++ b/schema/testing/appdatasim/app_data.go @@ -0,0 +1,161 @@ +package appdatasim + +import ( + "fmt" + "sort" + + "pgregory.net/rapid" + + "cosmossdk.io/schema" + "cosmossdk.io/schema/appdata" + "cosmossdk.io/schema/testing/statesim" +) + +// Options are the options for creating an app data simulator. +type Options struct { + // AppSchema is the schema to use. If it is nil, then schematesting.ExampleAppSchema + // will be used. + AppSchema map[string]schema.ModuleSchema + + // Listener is the listener to output appdata updates to. + Listener appdata.Listener + + // StateSimOptions are the options to pass to the statesim.App instance used under + // the hood. + StateSimOptions statesim.Options +} + +// Simulator simulates a stream of app data. Currently, it only simulates InitializeModuleData, OnObjectUpdate, +// StartBlock and Commit callbacks but others will be added in the future. +type Simulator struct { + state *statesim.App + options Options + blockNum uint64 +} + +// BlockData represents the app data packets in a block. +type BlockData = []appdata.Packet + +// NewSimulator creates a new app data simulator with the given options and runs its +// initialization methods. +func NewSimulator(options Options) (*Simulator, error) { + sim := &Simulator{ + // we initialize the state simulator with no app schema because we'll do + // that in the first block + state: statesim.NewApp(nil, options.StateSimOptions), + options: options, + } + + err := sim.initialize() + if err != nil { + return nil, err + } + + return sim, nil +} + +func (a *Simulator) initialize() error { + // in block "0" we only pass module initialization data and don't + // even generate any real block data + var keys []string + for key := range a.options.AppSchema { + keys = append(keys, key) + } + sort.Strings(keys) + for _, moduleName := range keys { + err := a.ProcessPacket(appdata.ModuleInitializationData{ + ModuleName: moduleName, + Schema: a.options.AppSchema[moduleName], + }) + if err != nil { + return err + } + } + return nil +} + +// BlockDataGen generates random block data. It is expected that generated data is passed to ProcessBlockData +// to simulate the app data stream and advance app state based on the object updates in the block. The first +// packet in the block data will be a StartBlockData packet with the height set to the next block height. +func (a *Simulator) BlockDataGen() *rapid.Generator[BlockData] { + return a.BlockDataGenN(0, 100) +} + +// BlockDataGenN creates a block data generator which allows specifying the maximum number of updates per block. +func (a *Simulator) BlockDataGenN(minUpdatesPerBlock, maxUpdatesPerBlock int) *rapid.Generator[BlockData] { + numUpdatesGen := rapid.IntRange(minUpdatesPerBlock, maxUpdatesPerBlock) + + return rapid.Custom(func(t *rapid.T) BlockData { + var packets BlockData + + packets = append(packets, appdata.StartBlockData{Height: a.blockNum + 1}) + + updateSet := map[string]bool{} + // filter out any updates to the same key from this block, otherwise we can end up with weird errors + updateGen := a.state.UpdateGen().Filter(func(data appdata.ObjectUpdateData) bool { + for _, update := range data.Updates { + _, existing := updateSet[fmt.Sprintf("%s:%v", data.ModuleName, update.Key)] + if existing { + return false + } + } + return true + }) + numUpdates := numUpdatesGen.Draw(t, "numUpdates") + for i := 0; i < numUpdates; i++ { + data := updateGen.Draw(t, fmt.Sprintf("update[%d]", i)) + for _, update := range data.Updates { + updateSet[fmt.Sprintf("%s:%v", data.ModuleName, update.Key)] = true + } + packets = append(packets, data) + } + + packets = append(packets, appdata.CommitData{}) + + return packets + }) +} + +// ProcessBlockData processes the given block data, advancing the app state based on the object updates in the block +// and forwarding all packets to the attached listener. It is expected that the data passed came from BlockDataGen, +// however, other data can be passed as long as any StartBlockData packet has the height set to the current height + 1. +func (a *Simulator) ProcessBlockData(data BlockData) error { + for _, packet := range data { + err := a.ProcessPacket(packet) + if err != nil { + return err + } + } + return nil +} + +// ProcessPacket processes a single packet, advancing the app state based on the data in the packet, +// and forwarding the packet to any listener. +func (a *Simulator) ProcessPacket(packet appdata.Packet) error { + err := a.options.Listener.SendPacket(packet) + if err != nil { + return err + } + switch packet := packet.(type) { + case appdata.StartBlockData: + if packet.Height != a.blockNum+1 { + return fmt.Errorf("invalid StartBlockData packet: %v", packet) + } + a.blockNum++ + case appdata.ModuleInitializationData: + return a.state.InitializeModule(packet) + case appdata.ObjectUpdateData: + return a.state.ApplyUpdate(packet) + } + return nil +} + +// AppState returns the current app state backing the simulator. +func (a *Simulator) AppState() statesim.AppState { + return a.state +} + +// BlockNum returns the current block number of the simulator. +func (a *Simulator) BlockNum() uint64 { + return a.blockNum +} diff --git a/schema/testing/appdatasim/app_data_test.go b/schema/testing/appdatasim/app_data_test.go new file mode 100644 index 000000000000..29701c4411e7 --- /dev/null +++ b/schema/testing/appdatasim/app_data_test.go @@ -0,0 +1,108 @@ +package appdatasim + +import ( + "bytes" + "encoding/json" + "fmt" + "io" + "testing" + + "github.com/stretchr/testify/require" + "gotest.tools/v3/golden" + + "cosmossdk.io/schema/appdata" + schematesting "cosmossdk.io/schema/testing" + "cosmossdk.io/schema/testing/statesim" +) + +func TestAppSimulator_mirror(t *testing.T) { + t.Run("default", func(t *testing.T) { + testAppSimulatorMirror(t, false) + }) + t.Run("retain deletes", func(t *testing.T) { + testAppSimulatorMirror(t, true) + }) +} + +func testAppSimulatorMirror(t *testing.T, retainDeletes bool) { // nolint: thelper // this isn't a test helper function + stateSimOpts := statesim.Options{CanRetainDeletions: retainDeletes} + mirror, err := NewSimulator(Options{ + StateSimOptions: stateSimOpts, + }) + require.NoError(t, err) + + appSim, err := NewSimulator(Options{ + AppSchema: schematesting.ExampleAppSchema, + Listener: appdata.PacketForwarder(func(packet appdata.Packet) error { + return mirror.ProcessPacket(packet) + }), + StateSimOptions: stateSimOpts, + }) + require.NoError(t, err) + + blockDataGen := appSim.BlockDataGenN(50, 100) + + for i := 0; i < 10; i++ { + data := blockDataGen.Example(i + 1) + require.NoError(t, appSim.ProcessBlockData(data)) + require.Empty(t, DiffAppData(appSim, mirror)) + } +} + +func TestAppSimulator_exampleSchema(t *testing.T) { + out := &bytes.Buffer{} + appSim, err := NewSimulator(Options{ + AppSchema: schematesting.ExampleAppSchema, + Listener: writerListener(out), + StateSimOptions: statesim.Options{}, + }) + require.NoError(t, err) + + blockDataGen := appSim.BlockDataGenN(10, 20) + + for i := 0; i < 10; i++ { + data := blockDataGen.Example(i + 1) + require.NoError(t, appSim.ProcessBlockData(data)) + } + + // we do a golden test so that we can have some human-readable proof that + // the simulator is emitting updates that look like what we expect + // make sure you check the golden tests when the simulator is changed + // this can be updated by running "go test . -update" + golden.Assert(t, out.String(), "app_sim_example_schema.txt") +} + +// writerListener returns a listener that writes to the provided writer. It currently +// only covers callbacks which are called by the simulator, but others will be added +// as the simulator covers other cases. +func writerListener(w io.Writer) appdata.Listener { + return appdata.Listener{ + StartBlock: func(data appdata.StartBlockData) error { + _, err := fmt.Fprintf(w, "StartBlock: %v\n", data) + return err + }, + OnTx: nil, + OnEvent: nil, + OnKVPair: nil, + Commit: func(data appdata.CommitData) error { + _, err := fmt.Fprintf(w, "Commit: %v\n", data) + return err + }, + InitializeModuleData: func(data appdata.ModuleInitializationData) error { + bz, err := json.Marshal(data) + if err != nil { + return err + } + _, err = fmt.Fprintf(w, "InitializeModuleData: %s\n", bz) + return err + }, + OnObjectUpdate: func(data appdata.ObjectUpdateData) error { + bz, err := json.Marshal(data) + if err != nil { + return err + } + _, err = fmt.Fprintf(w, "OnObjectUpdate: %s\n", bz) + return err + }, + } +} diff --git a/schema/testing/appdatasim/diff.go b/schema/testing/appdatasim/diff.go new file mode 100644 index 000000000000..5896331d542a --- /dev/null +++ b/schema/testing/appdatasim/diff.go @@ -0,0 +1,38 @@ +package appdatasim + +import ( + "fmt" + + "cosmossdk.io/schema/testing/statesim" +) + +// HasAppData defines an interface for things that hold app data include app state. +// If an indexer implements this then DiffAppData can be used to compare it with +// the Simulator state which also implements this. +type HasAppData interface { + // AppState returns the app state. + AppState() statesim.AppState + + // BlockNum returns the latest block number. + BlockNum() uint64 +} + +// DiffAppData compares the app data of two objects that implement HasAppData. +// This can be used by indexer to compare their state with the Simulator state +// if the indexer implements HasAppData. +// It returns a human-readable diff if the app data differs and the empty string +// if they are the same. +func DiffAppData(expected, actual HasAppData) string { + res := "" + + if stateDiff := statesim.DiffAppStates(expected.AppState(), actual.AppState()); stateDiff != "" { + res += "App State Diff:\n" + res += stateDiff + } + + if expected.BlockNum() != actual.BlockNum() { + res += fmt.Sprintf("BlockNum: expected %d, got %d\n", expected.BlockNum(), actual.BlockNum()) + } + + return res +} diff --git a/schema/testing/appdatasim/diff_test.go b/schema/testing/appdatasim/diff_test.go new file mode 100644 index 000000000000..cb9ecee9eb95 --- /dev/null +++ b/schema/testing/appdatasim/diff_test.go @@ -0,0 +1,39 @@ +package appdatasim + +import ( + "testing" + + "github.com/stretchr/testify/require" + "gotest.tools/v3/golden" + + "cosmossdk.io/schema" + schematesting "cosmossdk.io/schema/testing" +) + +// this test checks that diffs in app data are deterministic and can be used for regression testing +func TestDiffAppData(t *testing.T) { + appSim, err := NewSimulator(Options{ + AppSchema: schematesting.ExampleAppSchema, + }) + require.NoError(t, err) + + mirror, err := NewSimulator(Options{ + // add just one module to the mirror + AppSchema: map[string]schema.ModuleSchema{ + "all_kinds": schematesting.ExampleAppSchema["all_kinds"], + }, + }) + require.NoError(t, err) + + // mirror one block + blockGen := appSim.BlockDataGenN(50, 100) + blockData := blockGen.Example(1) + require.NoError(t, appSim.ProcessBlockData(blockData)) + require.NoError(t, mirror.ProcessBlockData(blockData)) + + // produce another block, but don't mirror it so that they're out of sync + blockData = blockGen.Example(2) + require.NoError(t, appSim.ProcessBlockData(blockData)) + + golden.Assert(t, DiffAppData(appSim, mirror), "diff_example.txt") +} diff --git a/schema/testing/appdatasim/doc.go b/schema/testing/appdatasim/doc.go new file mode 100644 index 000000000000..7f3493e2524b --- /dev/null +++ b/schema/testing/appdatasim/doc.go @@ -0,0 +1,2 @@ +// Package appdatasim contains utilities for simulating valid streams of app data for testing indexer implementations. +package appdatasim diff --git a/schema/testing/appdatasim/testdata/app_sim_example_schema.txt b/schema/testing/appdatasim/testdata/app_sim_example_schema.txt new file mode 100644 index 000000000000..32aa613514a2 --- /dev/null +++ b/schema/testing/appdatasim/testdata/app_sim_example_schema.txt @@ -0,0 +1,161 @@ +InitializeModuleData: {"ModuleName":"all_kinds","Schema":{}} +InitializeModuleData: {"ModuleName":"test_cases","Schema":{}} +StartBlock: {1 } +OnObjectUpdate: {"ModuleName":"test_cases","Updates":[{"TypeName":"RetainDeletions","Key":"","Value":[4602,"NwsAtcME5moByAKKwXU="],"Delete":false},{"TypeName":"Simple","Key":"","Value":[-89,"fgY="],"Delete":false}]} +OnObjectUpdate: {"ModuleName":"test_cases","Updates":[{"TypeName":"Singleton","Key":null,"Value":["֑Ⱥ|@!`",""],"Delete":false}]} +OnObjectUpdate: {"ModuleName":"test_cases","Updates":[{"TypeName":"TwoKeys","Key":["a\u003c",-84],"Value":null,"Delete":false}]} +OnObjectUpdate: {"ModuleName":"all_kinds","Updates":[{"TypeName":"test_integer","Key":"11598611","Value":["016807","-016339012"],"Delete":false},{"TypeName":"test_uint16","Key":9407,"Value":{"valNotNull":0,"valNullable":null},"Delete":false}]} +OnObjectUpdate: {"ModuleName":"all_kinds","Updates":[{"TypeName":"test_int16","Key":-4371,"Value":{"valNotNull":-3532,"valNullable":-15},"Delete":false}]} +OnObjectUpdate: {"ModuleName":"test_cases","Updates":[{"TypeName":"Simple","Key":"\u000b𝜛࣢Ⱥ +\u001c","Value":{"Value1":-28,"Value2":"AAE5AAAAATgB"},"Delete":false},{"TypeName":"RetainDeletions","Key":".(","Value":[116120837,"/wwIyAAUciAC"],"Delete":false}]} +OnObjectUpdate: {"ModuleName":"all_kinds","Updates":[{"TypeName":"test_bool","Key":false,"Value":[false,false],"Delete":false},{"TypeName":"test_float64","Key":0,"Value":[-0.819610595703125,0.08682777894820155],"Delete":false}]} +OnObjectUpdate: {"ModuleName":"test_cases","Updates":[{"TypeName":"ManyValues","Key":"+!𐅫a⍦","Value":[36,"fi07",0.000005021243239880513,2],"Delete":false}]} +OnObjectUpdate: {"ModuleName":"test_cases","Updates":[{"TypeName":"ThreeKeys","Key":["˖|󺪆𝅲=鄖_.;ǀ⃣%; #~",16,512578],"Value":686,"Delete":false}]} +OnObjectUpdate: {"ModuleName":"all_kinds","Updates":[{"TypeName":"test_int16","Key":-988,"Value":[6,null],"Delete":false}]} +OnObjectUpdate: {"ModuleName":"test_cases","Updates":[{"TypeName":"Simple","Key":"?൙ဴ𑇑\".+AB","Value":{"Value1":-75,"Value2":"FdQcnKoeAAIB"},"Delete":false}]} +OnObjectUpdate: {"ModuleName":"all_kinds","Updates":[{"TypeName":"test_int8","Key":6,"Value":[6,null],"Delete":false},{"TypeName":"test_int32","Key":-7573,"Value":[-57,null],"Delete":false}]} +OnObjectUpdate: {"ModuleName":"test_cases","Updates":[{"TypeName":"ThreeKeys","Key":["\tA𐞙?\t",-5317218,1],"Value":6450,"Delete":false}]} +OnObjectUpdate: {"ModuleName":"all_kinds","Updates":[{"TypeName":"test_bytes","Key":"AwMbGS8=","Value":["AwQA3EBwHgCEABQBAw==",null],"Delete":false},{"TypeName":"test_bool","Key":true,"Value":{"valNotNull":true,"valNullable":null},"Delete":false}]} +Commit: {} +StartBlock: {2 } +OnObjectUpdate: {"ModuleName":"test_cases","Updates":[{"TypeName":"RetainDeletions","Key":"ᾢ","Value":[3,"AQQF3LYA"],"Delete":false}]} +OnObjectUpdate: {"ModuleName":"test_cases","Updates":[{"TypeName":"ManyValues","Key":"_; ᾚ DzA{˭҄\nA ^$?ᾦ,:\u003c\"?_\u0014;|","Value":{"Value1":-15,"Value2":"PED/","Value3":7.997156312768529e-26,"Value4":33975920899014},"Delete":false},{"TypeName":"Simple","Key":"","Value":[-2,"FwY="],"Delete":false}]} +OnObjectUpdate: {"ModuleName":"all_kinds","Updates":[{"TypeName":"test_address","Key":"AgDYbdMBAZ31DGsBs7UGnAp/BgX/BkQFAQ3Si9sd6x8Hrw==","Value":{"valNotNull":"/2ADvYQC/wATggAAAwYBLjQCAv8=","valNullable":null},"Delete":false}]} +OnObjectUpdate: {"ModuleName":"all_kinds","Updates":[{"TypeName":"test_address","Key":"GJQSAs0BGAILARUXAwIrnf8pBgIrRQOrSQNOEgfvA8ATAAEMVw8s/w==","Value":["GwADWP8AMB6z0AZCDgEDMv8DfQEQ","DAHaBAOt3g16AQAfNQEBeQYBAlv/AfgKUi0YAgg="],"Delete":false},{"TypeName":"test_duration","Key":468,"Value":[-52600,null],"Delete":false}]} +OnObjectUpdate: {"ModuleName":"test_cases","Updates":[{"TypeName":"Simple","Key":": Ⱥ","Value":[-14,"fmoD3wY="],"Delete":false},{"TypeName":"TwoKeys","Key":["Ⱥ꙱Lj",12],"Value":null,"Delete":false}]} +OnObjectUpdate: {"ModuleName":"test_cases","Updates":[{"TypeName":"Simple","Key":"$","Value":[13,"Uf8VAgYltOwK"],"Delete":false}]} +OnObjectUpdate: {"ModuleName":"test_cases","Updates":[{"TypeName":"TwoKeys","Key":["",-4],"Value":null,"Delete":false}]} +OnObjectUpdate: {"ModuleName":"all_kinds","Updates":[{"TypeName":"test_bool","Key":true,"Value":{"valNotNull":false,"valNullable":null},"Delete":false}]} +OnObjectUpdate: {"ModuleName":"test_cases","Updates":[{"TypeName":"Simple","Key":"\t;𞄱𑨁௺ⅦA×~ႂᛯaA","Value":{"Value1":2147483647,"Value2":"AAMBAgADGA4="},"Delete":false},{"TypeName":"RetainDeletions","Key":"\nȺ*|𑀾","Value":{"Value1":0,"Value2":"ChoCY0w="},"Delete":false}]} +OnObjectUpdate: {"ModuleName":"test_cases","Updates":[{"TypeName":"Singleton","Key":null,"Value":["\u000b!","OQ=="],"Delete":false},{"TypeName":"Singleton","Key":null,"Value":["a",""],"Delete":false}]} +Commit: {} +StartBlock: {3 } +OnObjectUpdate: {"ModuleName":"all_kinds","Updates":[{"TypeName":"test_int32","Key":-103,"Value":{"valNotNull":-1887959808,"valNullable":2096073436},"Delete":false}]} +OnObjectUpdate: {"ModuleName":"all_kinds","Updates":[{"TypeName":"test_bool","Key":true,"Value":null,"Delete":true}]} +OnObjectUpdate: {"ModuleName":"test_cases","Updates":[{"TypeName":"ManyValues","Key":"","Value":{"Value1":-4,"Value2":"","Value3":5.199354003997906e-290,"Value4":2703222758},"Delete":false},{"TypeName":"ThreeKeys","Key":["˖|󺪆𝅲=鄖_.;ǀ⃣%; #~",16,512578],"Value":11281,"Delete":false}]} +OnObjectUpdate: {"ModuleName":"all_kinds","Updates":[{"TypeName":"test_uint8","Key":7,"Value":{"valNotNull":1,"valNullable":150},"Delete":false}]} +OnObjectUpdate: {"ModuleName":"test_cases","Updates":[{"TypeName":"Simple","Key":"?൙ဴ𑇑\".+AB","Value":[-1,"LP8="],"Delete":false}]} +OnObjectUpdate: {"ModuleName":"all_kinds","Updates":[{"TypeName":"test_integer","Key":"72961530924372552","Value":["080207094","-598415299"],"Delete":false}]} +OnObjectUpdate: {"ModuleName":"all_kinds","Updates":[{"TypeName":"test_float64","Key":-1.7392669057403718e+166,"Value":[1.556643269146063e-16,-1.1920928955078125e-7],"Delete":false}]} +OnObjectUpdate: {"ModuleName":"test_cases","Updates":[{"TypeName":"TwoKeys","Key":["ऻॉ~$𒐈+Xʱ:²-~?ʳ~$ₜ\\",-787],"Value":null,"Delete":false},{"TypeName":"Singleton","Key":null,"Value":null,"Delete":true}]} +OnObjectUpdate: {"ModuleName":"test_cases","Updates":[{"TypeName":"Simple","Key":"\u000b𝜛࣢Ⱥ +\u001c","Value":null,"Delete":true}]} +OnObjectUpdate: {"ModuleName":"all_kinds","Updates":[{"TypeName":"test_uint8","Key":14,"Value":[4,1],"Delete":false},{"TypeName":"test_address","Key":"AgDYbdMBAZ31DGsBs7UGnAp/BgX/BkQFAQ3Si9sd6x8Hrw==","Value":["BQEBAemXEjNqrx2kATMdGuUCESLnES4KAfAC//v/A9gJIaQNAQH/kcYdDw==","lMhHJAXnpQG+wgIzzAoNWjoAGTIABQ=="],"Delete":false}]} +OnObjectUpdate: {"ModuleName":"test_cases","Updates":[{"TypeName":"TwoKeys","Key":["Ⱥ꙱Lj",12],"Value":null,"Delete":true}]} +Commit: {} +StartBlock: {4 } +OnObjectUpdate: {"ModuleName":"all_kinds","Updates":[{"TypeName":"test_duration","Key":-152,"Value":{"valNotNull":1476419818092,"valNullable":-163469},"Delete":false}]} +OnObjectUpdate: {"ModuleName":"test_cases","Updates":[{"TypeName":"Simple","Key":"‮","Value":[-1,"GwE="],"Delete":false},{"TypeName":"ManyValues","Key":"","Value":[1,"",4.1017235364794545e-228,25],"Delete":false}]} +OnObjectUpdate: {"ModuleName":"test_cases","Updates":[{"TypeName":"RetainDeletions","Key":".(","Value":null,"Delete":true},{"TypeName":"Singleton","Key":null,"Value":{"Value":"ᾫ+=[฿́\u001b\u003cʰ+`𑱐@\u001b*Dž‮#₻\u0001῎ !a܏ῼ","Value2":"AgI="},"Delete":false}]} +OnObjectUpdate: {"ModuleName":"test_cases","Updates":[{"TypeName":"Simple","Key":"?൙ဴ𑇑\".+AB","Value":null,"Delete":true}]} +OnObjectUpdate: {"ModuleName":"test_cases","Updates":[{"TypeName":"RetainDeletions","Key":" ","Value":[-1,""],"Delete":false}]} +OnObjectUpdate: {"ModuleName":"test_cases","Updates":[{"TypeName":"ThreeKeys","Key":["",11,107],"Value":{"Value1":-31402597},"Delete":false},{"TypeName":"Simple","Key":"\t;𞄱𑨁௺ⅦA×~ႂᛯaA","Value":null,"Delete":true}]} +OnObjectUpdate: {"ModuleName":"all_kinds","Updates":[{"TypeName":"test_uint16","Key":0,"Value":{"valNotNull":68,"valNullable":null},"Delete":false}]} +OnObjectUpdate: {"ModuleName":"all_kinds","Updates":[{"TypeName":"test_address","Key":"PQYReIgDAAG/6fs+AVcXxgEGDXLQ30f0/w==","Value":["b+QAdJmb/0hGGAMzEoat/wYeAQcB/wO7Ae0BlgQFAP+i7A0rGA8ESIv+Oi+eFwIDHAMAygDjBogABwADAAC5Aw==",null],"Delete":false}]} +OnObjectUpdate: {"ModuleName":"test_cases","Updates":[{"TypeName":"ThreeKeys","Key":["\tA𐞙?\t",-5317218,1],"Value":{"Value1":-220},"Delete":false}]} +OnObjectUpdate: {"ModuleName":"all_kinds","Updates":[{"TypeName":"test_integer","Key":"617","Value":{"valNotNull":"688647620","valNullable":null},"Delete":false},{"TypeName":"test_bool","Key":false,"Value":null,"Delete":true}]} +Commit: {} +StartBlock: {5 } +OnObjectUpdate: {"ModuleName":"all_kinds","Updates":[{"TypeName":"test_bool","Key":true,"Value":{"valNotNull":true,"valNullable":null},"Delete":false},{"TypeName":"test_uint64","Key":21,"Value":{"valNotNull":73,"valNullable":2},"Delete":false}]} +OnObjectUpdate: {"ModuleName":"all_kinds","Updates":[{"TypeName":"test_address","Key":"AgDYbdMBAZ31DGsBs7UGnAp/BgX/BkQFAQ3Si9sd6x8Hrw==","Value":["BQBsCf9MAgQAGfzKAAu1AYAClAADAhlDAP+oChQBYQA5AA0LT19MujQyf/8FbQMDawAM",null],"Delete":false},{"TypeName":"test_enum","Key":"foo","Value":{"valNotNull":"foo","valNullable":"foo"},"Delete":false}]} +OnObjectUpdate: {"ModuleName":"test_cases","Updates":[{"TypeName":"Singleton","Key":null,"Value":["𝔏؃\"ᵚ¡ $A\r",""],"Delete":false}]} +OnObjectUpdate: {"ModuleName":"test_cases","Updates":[{"TypeName":"ThreeKeys","Key":["𒑏𑿞=A?¯ \t~",-6,53],"Value":-2,"Delete":false},{"TypeName":"Simple","Key":"?","Value":{"Value1":12,"Value2":"HAIBmK0D"},"Delete":false}]} +OnObjectUpdate: {"ModuleName":"test_cases","Updates":[{"TypeName":"RetainDeletions","Key":"⍦","Value":[-202,"EQTRAwAELg=="],"Delete":false},{"TypeName":"ManyValues","Key":"`ⅤaAះA~~⹗=\u000b","Value":[-17,"okMB1d0=",-3.643491752614398e+288,1382771530458],"Delete":false}]} +OnObjectUpdate: {"ModuleName":"all_kinds","Updates":[{"TypeName":"test_float64","Key":0,"Value":[-1014342049.3947449,null],"Delete":false}]} +OnObjectUpdate: {"ModuleName":"test_cases","Updates":[{"TypeName":"TwoKeys","Key":["a\u003c",-84],"Value":null,"Delete":true},{"TypeName":"Simple","Key":"d⹘:","Value":[3016,"AQ=="],"Delete":false}]} +OnObjectUpdate: {"ModuleName":"all_kinds","Updates":[{"TypeName":"test_bytes","Key":"AwMbGS8=","Value":null,"Delete":true},{"TypeName":"test_decimal","Key":"-02","Value":["1219101",null],"Delete":false}]} +OnObjectUpdate: {"ModuleName":"all_kinds","Updates":[{"TypeName":"test_decimal","Key":"9.5E+8","Value":{"valNotNull":"13333140202.01031939e81","valNullable":"7210210.1e+1"},"Delete":false}]} +OnObjectUpdate: {"ModuleName":"all_kinds","Updates":[{"TypeName":"test_uint16","Key":11,"Value":[6,14912],"Delete":false},{"TypeName":"test_duration","Key":-152,"Value":null,"Delete":true}]} +OnObjectUpdate: {"ModuleName":"test_cases","Updates":[{"TypeName":"RetainDeletions","Key":"`³Njॊ\u003c ?ᾩ‮₦~$","Value":{"Value1":2,"Value2":"lAAD4AAABQQbAwABAwHP"},"Delete":false},{"TypeName":"RetainDeletions","Key":"൴~𝔶ٞ蹯a_ ᛮ!؋aض©-?","Value":{"Value1":-6813,"Value2":"AhRPdlAC"},"Delete":false}]} +OnObjectUpdate: {"ModuleName":"all_kinds","Updates":[{"TypeName":"test_address","Key":"BkiVAAcAAJ6xA/dutlmcBe8DAA1UZAsB","Value":["AA57GQP/oifkJ8aYJENTAwLxPhPSAwEI1AA9xQMWAwEoBA==",null],"Delete":false},{"TypeName":"test_address","Key":"7QTt/24APN4FBA/TAG8B/wMBWOoCqP+HNg0FBQIdAw8F5AI=","Value":["BQNcFhh01gEBAm4BAfAlGwMKkCo=","aQQTfSUg2RkZARH/EP8IGAxENIBOGwbPFAA="],"Delete":false}]} +OnObjectUpdate: {"ModuleName":"all_kinds","Updates":[{"TypeName":"test_int8","Key":6,"Value":[-8,null],"Delete":false},{"TypeName":"test_address","Key":"AACHBAjyAgFHOQAABo+PGAK3Bj7TwwBb/wAB3gE=","Value":["ASwojxUABA8BAf/9AgUBIs4WAq9lqAEKAP8FAAgCGwEMDQKHZwEABA82AVZZAHO/ngS7AA==",null],"Delete":false}]} +OnObjectUpdate: {"ModuleName":"all_kinds","Updates":[{"TypeName":"test_address","Key":"AWvYAbSo5gQCAz8XAQYGjwCaRx0DSAUpAWQV","Value":["/z/eNBkL5QAgCwXergJOUCEC/+ICAp4BTgBsVw==","HhoELBAPigABQwIDAxsB7KEAGlIOEAAEYQL/GQA37QAJWg0A"],"Delete":false}]} +OnObjectUpdate: {"ModuleName":"test_cases","Updates":[{"TypeName":"RetainDeletions","Key":" ","Value":null,"Delete":true}]} +OnObjectUpdate: {"ModuleName":"all_kinds","Updates":[{"TypeName":"test_decimal","Key":"79","Value":["-7872","53"],"Delete":false}]} +OnObjectUpdate: {"ModuleName":"all_kinds","Updates":[{"TypeName":"test_uint32","Key":1322158439,"Value":{"valNotNull":2415,"valNullable":null},"Delete":false}]} +OnObjectUpdate: {"ModuleName":"test_cases","Updates":[{"TypeName":"ManyValues","Key":"_; ᾚ DzA{˭҄\nA ^$?ᾦ,:\u003c\"?_\u0014;|","Value":null,"Delete":true}]} +OnObjectUpdate: {"ModuleName":"test_cases","Updates":[{"TypeName":"ThreeKeys","Key":["\tA𐞙?\t",-5317218,1],"Value":-2147483648,"Delete":false},{"TypeName":"ManyValues","Key":"‮۽𝅸\u003c#󠁋","Value":[-3,"",-5.385845077524242e-269,2468],"Delete":false}]} +Commit: {} +StartBlock: {6 } +OnObjectUpdate: {"ModuleName":"test_cases","Updates":[{"TypeName":"TwoKeys","Key":["A𞥟",981],"Value":null,"Delete":false},{"TypeName":"ManyValues","Key":"ᵕ؏­􏿽A","Value":{"Value1":-317,"Value2":"AA==","Value3":-37.62890625,"Value4":232},"Delete":false}]} +OnObjectUpdate: {"ModuleName":"all_kinds","Updates":[{"TypeName":"test_address","Key":"AACHBAjyAgFHOQAABo+PGAK3Bj7TwwBb/wAB3gE=","Value":{"valNotNull":"HBwBHAY6AAKO+UwDKRICAT0lgRRvCRvHFFoNAigBAUEDHoQUfB2qApRB/z41AAubARsBATQg3gCppQMAAQwHAQ=="},"Delete":false}]} +OnObjectUpdate: {"ModuleName":"all_kinds","Updates":[{"TypeName":"test_decimal","Key":"9.5E+8","Value":["-2","88111430.0122412446"],"Delete":false}]} +OnObjectUpdate: {"ModuleName":"all_kinds","Updates":[{"TypeName":"test_uint8","Key":7,"Value":null,"Delete":true},{"TypeName":"test_time","Key":"1970-01-01T00:59:59.999999999+01:00","Value":["1970-01-01T01:00:00.000000001+01:00",null],"Delete":false}]} +OnObjectUpdate: {"ModuleName":"test_cases","Updates":[{"TypeName":"RetainDeletions","Key":"൴~𝔶ٞ蹯a_ ᛮ!؋aض©-?","Value":{"Value2":""},"Delete":false}]} +OnObjectUpdate: {"ModuleName":"all_kinds","Updates":[{"TypeName":"test_uint8","Key":14,"Value":{"valNotNull":116},"Delete":false},{"TypeName":"test_duration","Key":100403021838,"Value":[1547,null],"Delete":false}]} +OnObjectUpdate: {"ModuleName":"all_kinds","Updates":[{"TypeName":"test_int64","Key":-34196421,"Value":[56,224549431],"Delete":false},{"TypeName":"test_bool","Key":true,"Value":{"valNotNull":true,"valNullable":null},"Delete":false}]} +OnObjectUpdate: {"ModuleName":"test_cases","Updates":[{"TypeName":"ThreeKeys","Key":["ⅷ_ŕ,A",-467,98],"Value":{"Value1":145},"Delete":false},{"TypeName":"RetainDeletions","Key":"?aa₽A\u001b=⇂́ᯫ𖽦ᩣ","Value":{"Value1":0,"Value2":""},"Delete":false}]} +OnObjectUpdate: {"ModuleName":"test_cases","Updates":[{"TypeName":"TwoKeys","Key":["",-4],"Value":null,"Delete":true}]} +OnObjectUpdate: {"ModuleName":"test_cases","Updates":[{"TypeName":"Simple","Key":"","Value":{"Value1":1174095848,"Value2":"AR//A0kBNVwGGGsHANYAAAAtJQ=="},"Delete":false}]} +OnObjectUpdate: {"ModuleName":"all_kinds","Updates":[{"TypeName":"test_uint64","Key":3,"Value":[14481555953,496],"Delete":false}]} +OnObjectUpdate: {"ModuleName":"test_cases","Updates":[{"TypeName":"Simple","Key":"ǃ^@❽\u2028!𑿞a‮a`","Value":{"Value1":-33730,"Value2":"qKQ="},"Delete":false},{"TypeName":"Singleton","Key":null,"Value":["𞤎𞤡","BAconQGXHRuHXQN/GTUCSQACEg=="],"Delete":false}]} +OnObjectUpdate: {"ModuleName":"test_cases","Updates":[{"TypeName":"ManyValues","Key":"ൌ{ ༿","Value":[1110340689,"AQ==",0.00018342199999210607,1],"Delete":false}]} +OnObjectUpdate: {"ModuleName":"all_kinds","Updates":[{"TypeName":"test_bytes","Key":"AwcJA//C","Value":{"valNotNull":"DQ==","valNullable":null},"Delete":false},{"TypeName":"test_duration","Key":210213542904,"Value":[-207349773999415086,null],"Delete":false}]} +OnObjectUpdate: {"ModuleName":"all_kinds","Updates":[{"TypeName":"test_float64","Key":-3.0664227080502325e-103,"Value":[2.125936378595003e-239,null],"Delete":false}]} +Commit: {} +StartBlock: {7 } +OnObjectUpdate: {"ModuleName":"all_kinds","Updates":[{"TypeName":"test_bool","Key":true,"Value":{"valNotNull":true,"valNullable":true},"Delete":false}]} +OnObjectUpdate: {"ModuleName":"test_cases","Updates":[{"TypeName":"Simple","Key":"d⹘:","Value":{"Value2":""},"Delete":false}]} +OnObjectUpdate: {"ModuleName":"test_cases","Updates":[{"TypeName":"TwoKeys","Key":["ऻॉ~$𒐈+Xʱ:²-~?ʳ~$ₜ\\",-787],"Value":null,"Delete":true}]} +OnObjectUpdate: {"ModuleName":"test_cases","Updates":[{"TypeName":"TwoKeys","Key":["ः𒑨Dz؅",-2],"Value":null,"Delete":false}]} +OnObjectUpdate: {"ModuleName":"test_cases","Updates":[{"TypeName":"ThreeKeys","Key":["@(\u0001\u0001\tᛰᾚ𐺭a'ᵆᾭaa",16,817744173394],"Value":{"Value1":-2},"Delete":false}]} +OnObjectUpdate: {"ModuleName":"all_kinds","Updates":[{"TypeName":"test_bytes","Key":"AwcJA//C","Value":{"valNotNull":"AWNXAw=="},"Delete":false}]} +OnObjectUpdate: {"ModuleName":"all_kinds","Updates":[{"TypeName":"test_decimal","Key":"-85","Value":["-2511998","-077.01427082957E-7"],"Delete":false}]} +OnObjectUpdate: {"ModuleName":"all_kinds","Updates":[{"TypeName":"test_int16","Key":-988,"Value":null,"Delete":true}]} +OnObjectUpdate: {"ModuleName":"all_kinds","Updates":[{"TypeName":"test_enum","Key":"foo","Value":null,"Delete":true},{"TypeName":"test_decimal","Key":"-02","Value":["-40892500970.58239","11e0"],"Delete":false}]} +OnObjectUpdate: {"ModuleName":"all_kinds","Updates":[{"TypeName":"test_string","Key":"","Value":{"valNotNull":"実.*𑁤!؋A\u000b.{;?󠀮_? ‍*🄑󠇯","valNullable":"(Ⱥ#/\u003c_"},"Delete":false},{"TypeName":"test_integer","Key":"-1391361","Value":{"valNotNull":"-0105","valNullable":null},"Delete":false}]} +OnObjectUpdate: {"ModuleName":"all_kinds","Updates":[{"TypeName":"test_address","Key":"AWvYAbSo5gQCAz8XAQYGjwCaRx0DSAUpAWQV","Value":null,"Delete":true}]} +OnObjectUpdate: {"ModuleName":"all_kinds","Updates":[{"TypeName":"test_int8","Key":98,"Value":[-40,null],"Delete":false}]} +Commit: {} +StartBlock: {8 } +OnObjectUpdate: {"ModuleName":"test_cases","Updates":[{"TypeName":"Simple","Key":"$","Value":[0,""],"Delete":false}]} +OnObjectUpdate: {"ModuleName":"all_kinds","Updates":[{"TypeName":"test_decimal","Key":"8E4","Value":{"valNotNull":"4043421E29","valNullable":null},"Delete":false}]} +OnObjectUpdate: {"ModuleName":"all_kinds","Updates":[{"TypeName":"test_address","Key":"AACHBAjyAgFHOQAABo+PGAK3Bj7TwwBb/wAB3gE=","Value":null,"Delete":true}]} +OnObjectUpdate: {"ModuleName":"test_cases","Updates":[{"TypeName":"TwoKeys","Key":["A𞥟",981],"Value":null,"Delete":true}]} +OnObjectUpdate: {"ModuleName":"test_cases","Updates":[{"TypeName":"TwoKeys","Key":["",55175],"Value":null,"Delete":false},{"TypeName":"RetainDeletions","Key":"`³Njॊ\u003c ?ᾩ‮₦~$","Value":{"Value1":3},"Delete":false}]} +OnObjectUpdate: {"ModuleName":"all_kinds","Updates":[{"TypeName":"test_duration","Key":468,"Value":[-4,-805402038367],"Delete":false}]} +OnObjectUpdate: {"ModuleName":"all_kinds","Updates":[{"TypeName":"test_bool","Key":true,"Value":null,"Delete":true},{"TypeName":"test_int32","Key":-24,"Value":[1,null],"Delete":false}]} +OnObjectUpdate: {"ModuleName":"test_cases","Updates":[{"TypeName":"RetainDeletions","Key":"҉߃ ","Value":[-526,""],"Delete":false},{"TypeName":"Simple","Key":": Ⱥ","Value":[59,"Kw=="],"Delete":false}]} +OnObjectUpdate: {"ModuleName":"all_kinds","Updates":[{"TypeName":"test_enum","Key":"bar","Value":{"valNotNull":"foo","valNullable":null},"Delete":false},{"TypeName":"test_int64","Key":2481611475,"Value":[136,6],"Delete":false}]} +OnObjectUpdate: {"ModuleName":"all_kinds","Updates":[{"TypeName":"test_float64","Key":-3.0664227080502325e-103,"Value":[-0.34326171875,-1.9202818317669984e-13],"Delete":false}]} +OnObjectUpdate: {"ModuleName":"test_cases","Updates":[{"TypeName":"Singleton","Key":null,"Value":null,"Delete":true},{"TypeName":"Singleton","Key":null,"Value":{"Value":"","Value2":"ClAs"},"Delete":false}]} +OnObjectUpdate: {"ModuleName":"test_cases","Updates":[{"TypeName":"ManyValues","Key":"?b⁠\r##﹍/$ͥ","Value":[10,"",5.231528162956238,42],"Delete":false}]} +OnObjectUpdate: {"ModuleName":"test_cases","Updates":[{"TypeName":"Simple","Key":"ݙaس\u003cй?{E","Value":{"Value1":-15,"Value2":"o+MQ"},"Delete":false},{"TypeName":"RetainDeletions","Key":"൴~𝔶ٞ蹯a_ ᛮ!؋aض©-?","Value":null,"Delete":true}]} +OnObjectUpdate: {"ModuleName":"all_kinds","Updates":[{"TypeName":"test_bytes","Key":"AwcJA//C","Value":{"valNullable":""},"Delete":false},{"TypeName":"test_uint32","Key":1322158439,"Value":null,"Delete":true}]} +OnObjectUpdate: {"ModuleName":"test_cases","Updates":[{"TypeName":"TwoKeys","Key":["ꬵ[Ⰶ\u2029\u0026𒐗🕳c҉\u0026฿a\u0026",-79424],"Value":null,"Delete":false}]} +OnObjectUpdate: {"ModuleName":"all_kinds","Updates":[{"TypeName":"test_int8","Key":-128,"Value":[7,null],"Delete":false},{"TypeName":"test_int32","Key":-103,"Value":null,"Delete":true}]} +OnObjectUpdate: {"ModuleName":"test_cases","Updates":[{"TypeName":"RetainDeletions","Key":"ᾢ","Value":[-2356,"DA=="],"Delete":false},{"TypeName":"ManyValues","Key":"","Value":{"Value1":28,"Value2":"","Value3":-1.6098999622118156e+67,"Value4":14},"Delete":false}]} +OnObjectUpdate: {"ModuleName":"test_cases","Updates":[{"TypeName":"ManyValues","Key":"?≚a'","Value":{"Value1":-611,"Value2":"AgqTAG4=","Value3":-2.0360732649240822e+100,"Value4":0},"Delete":false}]} +OnObjectUpdate: {"ModuleName":"all_kinds","Updates":[{"TypeName":"test_float64","Key":0,"Value":[2.5625,null],"Delete":false}]} +OnObjectUpdate: {"ModuleName":"all_kinds","Updates":[{"TypeName":"test_uint64","Key":3,"Value":{"valNotNull":59,"valNullable":null},"Delete":false}]} +Commit: {} +StartBlock: {9 } +OnObjectUpdate: {"ModuleName":"test_cases","Updates":[{"TypeName":"TwoKeys","Key":["ः𒑨Dz؅",-2],"Value":null,"Delete":true}]} +OnObjectUpdate: {"ModuleName":"test_cases","Updates":[{"TypeName":"Simple","Key":"_�é","Value":{"Value1":9,"Value2":"Ywc="},"Delete":false},{"TypeName":"Singleton","Key":null,"Value":null,"Delete":true}]} +OnObjectUpdate: {"ModuleName":"test_cases","Updates":[{"TypeName":"RetainDeletions","Key":"A%aa ¹­ ᾏaĵ¨","Value":[9,"A/faBuYCCecZ3ATQAQcC3gAsizI="],"Delete":false},{"TypeName":"ThreeKeys","Key":[" {a",2790155,310794],"Value":{"Value1":312},"Delete":false}]} +OnObjectUpdate: {"ModuleName":"all_kinds","Updates":[{"TypeName":"test_int32","Key":892,"Value":[-3,null],"Delete":false},{"TypeName":"test_duration","Key":210213542904,"Value":[-722503,113854019],"Delete":false}]} +OnObjectUpdate: {"ModuleName":"all_kinds","Updates":[{"TypeName":"test_duration","Key":468,"Value":[12,null],"Delete":false},{"TypeName":"test_int16","Key":0,"Value":[3089,null],"Delete":false}]} +OnObjectUpdate: {"ModuleName":"all_kinds","Updates":[{"TypeName":"test_decimal","Key":"79","Value":null,"Delete":true}]} +OnObjectUpdate: {"ModuleName":"test_cases","Updates":[{"TypeName":"ThreeKeys","Key":["",11,107],"Value":null,"Delete":true}]} +OnObjectUpdate: {"ModuleName":"all_kinds","Updates":[{"TypeName":"test_bool","Key":false,"Value":[true,true],"Delete":false}]} +OnObjectUpdate: {"ModuleName":"test_cases","Updates":[{"TypeName":"Simple","Key":": Ⱥ","Value":{"Value1":-2147483648},"Delete":false}]} +OnObjectUpdate: {"ModuleName":"all_kinds","Updates":[{"TypeName":"test_uint8","Key":14,"Value":null,"Delete":true},{"TypeName":"test_integer","Key":"-1391361","Value":null,"Delete":true}]} +OnObjectUpdate: {"ModuleName":"test_cases","Updates":[{"TypeName":"RetainDeletions","Key":"","Value":[-242379,"BngOEOsA"],"Delete":false}]} +OnObjectUpdate: {"ModuleName":"all_kinds","Updates":[{"TypeName":"test_int8","Key":6,"Value":null,"Delete":true},{"TypeName":"test_address","Key":"BkiVAAcAAJ6xA/dutlmcBe8DAA1UZAsB","Value":null,"Delete":true}]} +OnObjectUpdate: {"ModuleName":"test_cases","Updates":[{"TypeName":"Simple","Key":" 😖₱ ̄؀ा󠁿","Value":[7541152,""],"Delete":false},{"TypeName":"ThreeKeys","Key":["ⅷ_ŕ,A",-467,98],"Value":2,"Delete":false}]} +Commit: {} +StartBlock: {10 } +OnObjectUpdate: {"ModuleName":"all_kinds","Updates":[{"TypeName":"test_duration","Key":87208838869,"Value":[-9725,4968373],"Delete":false},{"TypeName":"test_duration","Key":468,"Value":null,"Delete":true}]} +OnObjectUpdate: {"ModuleName":"test_cases","Updates":[{"TypeName":"RetainDeletions","Key":"","Value":[-1,"FQIK"],"Delete":false},{"TypeName":"Singleton","Key":null,"Value":{"Value":"œLj$࿇ ᾙ☇؄ೲȺ","Value2":"ADei6AACZTMDDss="},"Delete":false}]} +OnObjectUpdate: {"ModuleName":"all_kinds","Updates":[{"TypeName":"test_bool","Key":false,"Value":[true,null],"Delete":false},{"TypeName":"test_enum","Key":"bar","Value":{"valNotNull":"baz","valNullable":"baz"},"Delete":false}]} +OnObjectUpdate: {"ModuleName":"test_cases","Updates":[{"TypeName":"ThreeKeys","Key":["\tA𐞙?\t",-5317218,1],"Value":{"Value1":1},"Delete":false},{"TypeName":"RetainDeletions","Key":"\u0026 ٱȺ+҉@","Value":[63,"AAE="],"Delete":false}]} +OnObjectUpdate: {"ModuleName":"all_kinds","Updates":[{"TypeName":"test_float64","Key":-1.7392669057403718e+166,"Value":[-1.0781831287525041e+139,111.37014762980289],"Delete":false}]} +OnObjectUpdate: {"ModuleName":"all_kinds","Updates":[{"TypeName":"test_address","Key":"GJQSAs0BGAILARUXAwIrnf8pBgIrRQOrSQNOEgfvA8ATAAEMVw8s/w==","Value":{"valNotNull":"em2zQwR2O7EAAAYLk23QBADE/wA="},"Delete":false},{"TypeName":"test_address","Key":"PQYReIgDAAG/6fs+AVcXxgEGDXLQ30f0/w==","Value":null,"Delete":true}]} +OnObjectUpdate: {"ModuleName":"test_cases","Updates":[{"TypeName":"ManyValues","Key":"","Value":[-188,"",-2632691.375,17],"Delete":false}]} +OnObjectUpdate: {"ModuleName":"test_cases","Updates":[{"TypeName":"ThreeKeys","Key":["A]$",-125,43],"Value":12654289,"Delete":false},{"TypeName":"RetainDeletions","Key":"?aa₽A\u001b=⇂́ᯫ𖽦ᩣ","Value":{"Value2":"ARM="},"Delete":false}]} +OnObjectUpdate: {"ModuleName":"all_kinds","Updates":[{"TypeName":"test_uint8","Key":0,"Value":{"valNotNull":0,"valNullable":null},"Delete":false},{"TypeName":"test_float32","Key":1.7852577e+32,"Value":[1.6582896,null],"Delete":false}]} +OnObjectUpdate: {"ModuleName":"test_cases","Updates":[{"TypeName":"ManyValues","Key":"?b⁠\r##﹍/$ͥ","Value":null,"Delete":true}]} +OnObjectUpdate: {"ModuleName":"test_cases","Updates":[{"TypeName":"TwoKeys","Key":["",55175],"Value":null,"Delete":true},{"TypeName":"ThreeKeys","Key":["˖|󺪆𝅲=鄖_.;ǀ⃣%; #~",16,512578],"Value":null,"Delete":true}]} +OnObjectUpdate: {"ModuleName":"test_cases","Updates":[{"TypeName":"RetainDeletions","Key":"A%aa ¹­ ᾏaĵ¨","Value":null,"Delete":true}]} +OnObjectUpdate: {"ModuleName":"test_cases","Updates":[{"TypeName":"Simple","Key":"‮","Value":{"Value2":"DAcBeTgAFAED"},"Delete":false},{"TypeName":"RetainDeletions","Key":"ʵ² *ᾍA@҂b⭗@‮൞","Value":{"Value1":547,"Value2":""},"Delete":false}]} +OnObjectUpdate: {"ModuleName":"all_kinds","Updates":[{"TypeName":"test_uint8","Key":4,"Value":[17,null],"Delete":false},{"TypeName":"test_uint8","Key":8,"Value":[2,12],"Delete":false}]} +OnObjectUpdate: {"ModuleName":"test_cases","Updates":[{"TypeName":"ManyValues","Key":"҉♰ᾜȺ൜堯Ⱥ៵\"","Value":{"Value1":-10,"Value2":"jg==","Value3":-0.11867497289509932,"Value4":24065},"Delete":false}]} +Commit: {} diff --git a/schema/testing/appdatasim/testdata/diff_example.txt b/schema/testing/appdatasim/testdata/diff_example.txt new file mode 100644 index 000000000000..636e388937ee --- /dev/null +++ b/schema/testing/appdatasim/testdata/diff_example.txt @@ -0,0 +1,79 @@ +App State Diff: +MODULE COUNT ERROR: expected 2, got 1 +Module all_kinds + Object Collection test_address + OBJECT COUNT ERROR: expected 16, got 14 + Object key=0x0c6ff6530300000704ff285714816e0d0b03010d0102010302ff7400d60103c2110e3700c30105679f0910570048aa48f6b4680128821c98011d00240c2c00ff + valNotNull: expected [43 29 85 255 6 1 176 1 241 222 0 0 14 116 190 1 11 30 2 8 1 144 12 2 12 1 16 15 1 1 27 8 0 255 57 2 6 195 255 60 0 201 255 1 1 13 9 112 1 2 0 121 12 172 254 22 11 1 5 37 54 212 121 0], got [220 0 1 2 13 4 24 1 12 24 58 0 1 224 0 148 104 51 116 27 56 39 14 32 35 84 126 2 18 1 5 6] + valNullable: expected [189 125 119 246 192 0 3 170 24 6 10 123 0 7 34 118 1 212 187 7 1 249 110 146 10 14 0 3 223 134 65 0 15 248 153], got [29 201 1 2 1 63 13 0 191 75 1 2 240 10 209 58 15 137 184 141 148] + Object key=0x18f0037d00012c006d9c72096b011e01f600035108fe0303000100031f1f020f08002203000502010120060f1b0201180203006a00e0: NOT FOUND + Object key=0xa10f005de9c1010692980d213250ef13020697430007000bdc01010305054f4001b7ba39003a01d2ae0e59007eef4e19e9020e006974016d00001c00037b7028: NOT FOUND + Object key=0xff2619001c04b3031aa10d9d167f1f0046d6760216009c: NOT FOUND + Object Collection test_bytes + OBJECT COUNT ERROR: expected 5, got 4 + Object key=0x000a4f0f6e9b67f6: NOT FOUND + Object key=0x0e0827 + valNotNull: expected [159 2], got [41 6 2 75] + valNullable: expected [0 11 54 47 28], got [6] + Object key=0xff661b1c00 + valNullable: expected [15 20 0 1 132 7 37 3 28 2], got [0 8 1 170 90 0 1 201 97 138 53 2] + Object Collection test_decimal + OBJECT COUNT ERROR: expected 5, got 3 + Object key=-04360.6e32: NOT FOUND + Object key=-21918e-3: NOT FOUND + Object key=-37.02e01: NOT FOUND + Object key=41090120E-3 + valNotNull: expected 04.13921382165470301184220430, got 0255559.705E-4 + valNullable: expected -2e5, got nil + Object Collection test_duration + OBJECT COUNT ERROR: expected 1, got 2 + Object Collection test_enum + OBJECT COUNT ERROR: expected 1, got 2 + Object Collection test_float32 + OBJECT COUNT ERROR: expected 3, got 4 + Object Collection test_int16 + OBJECT COUNT ERROR: expected 9, got 8 + Object key=-44: NOT FOUND + Object Collection test_int32 + OBJECT COUNT ERROR: expected 2, got 1 + Object key=-453: NOT FOUND + Object key=205: NOT FOUND + Object Collection test_int64 + OBJECT COUNT ERROR: expected 3, got 5 + Object key=-41 + valNotNull: expected 244, got -5717 + valNullable: expected nil, got 0 + Object Collection test_int8 + OBJECT COUNT ERROR: expected 4, got 3 + Object key=-2: NOT FOUND + Object key=53 + valNotNull: expected 27, got 58 + valNullable: expected nil, got -10 + Object Collection test_integer + OBJECT COUNT ERROR: expected 7, got 6 + Object key=-31083911818: NOT FOUND + Object key=191 + valNotNull: expected 62, got -47110784 + valNullable: expected 9297555, got nil + Object Collection test_string + OBJECT COUNT ERROR: expected 2, got 1 + Object key=š℠¼々¢~;-Ⱥ!˃a[ʰᾌ?{ᪧ৵%ᾯ¦〈: NOT FOUND + Object Collection test_time + OBJECT COUNT ERROR: expected 4, got 3 + Object key=1970-01-01 01:00:00.000000005 +0100 CET: NOT FOUND + Object key=1970-01-01 01:00:00.001598687 +0100 CET + valNotNull: expected 1970-01-01 01:00:00.007727197 +0100 CET, got 1970-01-01 01:00:00.034531678 +0100 CET + valNullable: expected 1970-01-01 01:00:00.000000484 +0100 CET, got 1970-01-01 01:00:00.000000033 +0100 CET + Object Collection test_uint16 + OBJECT COUNT ERROR: expected 4, got 3 + Object key=23712: NOT FOUND + Object Collection test_uint32 + OBJECT COUNT ERROR: expected 3, got 2 + Object key=0: NOT FOUND + Object Collection test_uint64 + OBJECT COUNT ERROR: expected 1, got 2 + Object Collection test_uint8 + OBJECT COUNT ERROR: expected 3, got 2 + Object key=1: NOT FOUND + Module test_cases: NOT FOUND +BlockNum: expected 2, got 1 diff --git a/schema/testing/diff.go b/schema/testing/diff.go new file mode 100644 index 000000000000..413a9384eec3 --- /dev/null +++ b/schema/testing/diff.go @@ -0,0 +1,100 @@ +package schematesting + +import ( + "bytes" + "fmt" + + "cosmossdk.io/schema" +) + +// DiffObjectKeys compares the values as object keys for the provided field and returns a diff if they +// differ or an empty string if they are equal. +func DiffObjectKeys(fields []schema.Field, expected, actual any) string { + n := len(fields) + switch n { + case 0: + return "" + case 1: + return DiffFieldValues(fields[0], expected, actual) + default: + actualValues, ok := actual.([]interface{}) + if !ok { + return fmt.Sprintf("ERROR: expected array of values for actual, got %v\n", actual) + } + expectedValues, ok := expected.([]interface{}) + if !ok { + return fmt.Sprintf("ERROR: expected array of values for expected, got %v\n", actual) + } + res := "" + for i := 0; i < n; i++ { + res += DiffFieldValues(fields[i], expectedValues[i], actualValues[i]) + } + return res + } +} + +// DiffObjectValues compares the values as object values for the provided field and returns a diff if they +// differ or an empty string if they are equal. Object values cannot be ValueUpdates for this comparison. +func DiffObjectValues(fields []schema.Field, expected, actual any) string { + if len(fields) == 0 { + return "" + } + + _, ok := expected.(schema.ValueUpdates) + _, ok2 := expected.(schema.ValueUpdates) + + if ok || ok2 { + return "ValueUpdates is not expected when comparing state" + } + + return DiffObjectKeys(fields, expected, actual) +} + +// DiffFieldValues compares the values for the provided field and returns a diff if they differ or an empty +// string if they are equal. +func DiffFieldValues(field schema.Field, expected, actual any) string { + if field.Nullable { + if expected == nil { + if actual == nil { + return "" + } else { + return fmt.Sprintf("%s: expected nil, got %v\n", field.Name, actual) + } + } else if actual == nil { + return fmt.Sprintf("%s: expected %v, got nil\n", field.Name, expected) + } + } + + eq, err := CompareKindValues(field.Kind, actual, expected) + if err != nil { + return fmt.Sprintf("%s: ERROR: %v\n", field.Name, err) + } + if !eq { + return fmt.Sprintf("%s: expected %v, got %v\n", field.Name, expected, actual) + } + return "" +} + +// CompareKindValues compares the expected and actual values for the provided kind and returns true if they are equal, +// false if they are not, and an error if the types are not valid for the kind. +func CompareKindValues(kind schema.Kind, expected, actual any) (bool, error) { + if kind.ValidateValueType(expected) != nil { + return false, fmt.Errorf("unexpected type %T for kind %s", expected, kind) + } + + if kind.ValidateValueType(actual) != nil { + return false, fmt.Errorf("unexpected type %T for kind %s", actual, kind) + } + + switch kind { + case schema.BytesKind, schema.JSONKind, schema.AddressKind: + if !bytes.Equal(expected.([]byte), actual.([]byte)) { + return false, nil + } + default: + if expected != actual { + return false, nil + } + } + return true, nil +} diff --git a/schema/testing/doc.go b/schema/testing/doc.go new file mode 100644 index 000000000000..05f3dcb1b496 --- /dev/null +++ b/schema/testing/doc.go @@ -0,0 +1,3 @@ +// Package schematesting includes property-based testing generators for creating random valid data +// for testing schemas and state representing those schemas. +package schematesting diff --git a/schema/testing/enum.go b/schema/testing/enum.go new file mode 100644 index 000000000000..40d3f6b35fbc --- /dev/null +++ b/schema/testing/enum.go @@ -0,0 +1,19 @@ +package schematesting + +import ( + "pgregory.net/rapid" + + "cosmossdk.io/schema" +) + +var enumValuesGen = rapid.SliceOfNDistinct(NameGen, 1, 10, func(x string) string { return x }) + +// EnumType generates random valid EnumTypes. +var EnumType = rapid.Custom(func(t *rapid.T) schema.EnumType { + enum := schema.EnumType{ + Name: NameGen.Draw(t, "name"), + Values: enumValuesGen.Draw(t, "values"), + } + + return enum +}) diff --git a/schema/testing/enum_test.go b/schema/testing/enum_test.go new file mode 100644 index 000000000000..4b84559cc520 --- /dev/null +++ b/schema/testing/enum_test.go @@ -0,0 +1,15 @@ +package schematesting + +import ( + "testing" + + "github.com/stretchr/testify/require" + "pgregory.net/rapid" +) + +func TestEnumType(t *testing.T) { + rapid.Check(t, func(t *rapid.T) { + enumType := EnumType.Draw(t, "enum") + require.NoError(t, enumType.Validate()) + }) +} diff --git a/schema/testing/example_schema.go b/schema/testing/example_schema.go new file mode 100644 index 000000000000..60ae8bba548e --- /dev/null +++ b/schema/testing/example_schema.go @@ -0,0 +1,171 @@ +package schematesting + +import ( + "fmt" + + "cosmossdk.io/schema" +) + +// ExampleAppSchema is an example app schema that intends to cover all schema cases that indexers should handle +// that can be used in reproducible unit testing and property based testing. +var ExampleAppSchema = map[string]schema.ModuleSchema{ + "all_kinds": mkAllKindsModule(), + "test_cases": MustNewModuleSchema([]schema.ObjectType{ + { + Name: "Singleton", + KeyFields: []schema.Field{}, + ValueFields: []schema.Field{ + { + Name: "Value", + Kind: schema.StringKind, + }, + { + Name: "Value2", + Kind: schema.BytesKind, + }, + }, + }, + { + Name: "Simple", + KeyFields: []schema.Field{ + { + Name: "Key", + Kind: schema.StringKind, + }, + }, + ValueFields: []schema.Field{ + { + Name: "Value1", + Kind: schema.Int32Kind, + }, + { + Name: "Value2", + Kind: schema.BytesKind, + }, + }, + }, + { + Name: "TwoKeys", + KeyFields: []schema.Field{ + { + Name: "Key1", + Kind: schema.StringKind, + }, + { + Name: "Key2", + Kind: schema.Int32Kind, + }, + }, + }, + { + Name: "ThreeKeys", + KeyFields: []schema.Field{ + { + Name: "Key1", + Kind: schema.StringKind, + }, + { + Name: "Key2", + Kind: schema.Int32Kind, + }, + { + Name: "Key3", + Kind: schema.Uint64Kind, + }, + }, + ValueFields: []schema.Field{ + { + Name: "Value1", + Kind: schema.Int32Kind, + }, + }, + }, + { + Name: "ManyValues", + KeyFields: []schema.Field{ + { + Name: "Key", + Kind: schema.StringKind, + }, + }, + ValueFields: []schema.Field{ + { + Name: "Value1", + Kind: schema.Int32Kind, + }, + { + Name: "Value2", + Kind: schema.BytesKind, + }, + { + Name: "Value3", + Kind: schema.Float64Kind, + }, + { + Name: "Value4", + Kind: schema.Uint64Kind, + }, + }, + }, + { + Name: "RetainDeletions", + KeyFields: []schema.Field{ + { + Name: "Key", + Kind: schema.StringKind, + }, + }, + ValueFields: []schema.Field{ + { + Name: "Value1", + Kind: schema.Int32Kind, + }, + { + Name: "Value2", + Kind: schema.BytesKind, + }, + }, + RetainDeletions: true, + }, + }), +} + +func mkAllKindsModule() schema.ModuleSchema { + var objTypes []schema.ObjectType + for i := 1; i < int(schema.MAX_VALID_KIND); i++ { + kind := schema.Kind(i) + typ := mkTestObjectType(kind) + objTypes = append(objTypes, typ) + } + + return MustNewModuleSchema(objTypes) +} + +func mkTestObjectType(kind schema.Kind) schema.ObjectType { + field := schema.Field{ + Kind: kind, + } + + if kind == schema.EnumKind { + field.EnumType = testEnum + } + + keyField := field + keyField.Name = "key" + val1Field := field + val1Field.Name = "valNotNull" + val2Field := field + val2Field.Name = "valNullable" + val2Field.Nullable = true + + return schema.ObjectType{ + Name: fmt.Sprintf("test_%v", kind), + KeyFields: []schema.Field{keyField}, + ValueFields: []schema.Field{val1Field, val2Field}, + } +} + +var testEnum = schema.EnumType{ + Name: "test_enum_type", + Values: []string{"foo", "bar", "baz"}, +} diff --git a/schema/testing/field.go b/schema/testing/field.go new file mode 100644 index 000000000000..670f9356a681 --- /dev/null +++ b/schema/testing/field.go @@ -0,0 +1,175 @@ +package schematesting + +import ( + "fmt" + "time" + + "pgregory.net/rapid" + + "cosmossdk.io/schema" +) + +var ( + kindGen = rapid.Map(rapid.IntRange(int(schema.InvalidKind+1), int(schema.MAX_VALID_KIND-1)), + func(i int) schema.Kind { + return schema.Kind(i) + }) + boolGen = rapid.Bool() +) + +// FieldGen generates random Field's based on the validity criteria of fields. +var FieldGen = rapid.Custom(func(t *rapid.T) schema.Field { + kind := kindGen.Draw(t, "kind") + field := schema.Field{ + Name: NameGen.Draw(t, "name"), + Kind: kind, + Nullable: boolGen.Draw(t, "nullable"), + } + + switch kind { + case schema.EnumKind: + field.EnumType = EnumType.Draw(t, "enumDefinition") + default: + } + + return field +}) + +// FieldValueGen generates random valid values for the field, aiming to exercise the full range of possible +// values for the field. +func FieldValueGen(field schema.Field) *rapid.Generator[any] { + gen := baseFieldValue(field) + + if field.Nullable { + return rapid.OneOf(gen, rapid.Just[any](nil)).AsAny() + } + + return gen +} + +func baseFieldValue(field schema.Field) *rapid.Generator[any] { + switch field.Kind { + case schema.StringKind: + return rapid.StringOf(rapid.Rune().Filter(func(r rune) bool { + return r != 0 // filter out NULL characters + })).AsAny() + case schema.BytesKind: + return rapid.SliceOf(rapid.Byte()).AsAny() + case schema.Int8Kind: + return rapid.Int8().AsAny() + case schema.Int16Kind: + return rapid.Int16().AsAny() + case schema.Uint8Kind: + return rapid.Uint8().AsAny() + case schema.Uint16Kind: + return rapid.Uint16().AsAny() + case schema.Int32Kind: + return rapid.Int32().AsAny() + case schema.Uint32Kind: + return rapid.Uint32().AsAny() + case schema.Int64Kind: + return rapid.Int64().AsAny() + case schema.Uint64Kind: + return rapid.Uint64().AsAny() + case schema.Float32Kind: + return rapid.Float32().AsAny() + case schema.Float64Kind: + return rapid.Float64().AsAny() + case schema.IntegerStringKind: + return rapid.StringMatching(schema.IntegerFormat).AsAny() + case schema.DecimalStringKind: + return rapid.StringMatching(schema.DecimalFormat).AsAny() + case schema.BoolKind: + return rapid.Bool().AsAny() + case schema.TimeKind: + return rapid.Map(rapid.Int64(), func(i int64) time.Time { + return time.Unix(0, i) + }).AsAny() + case schema.DurationKind: + return rapid.Map(rapid.Int64(), func(i int64) time.Duration { + return time.Duration(i) + }).AsAny() + case schema.AddressKind: + return rapid.SliceOfN(rapid.Byte(), 20, 64).AsAny() + case schema.EnumKind: + return rapid.SampledFrom(field.EnumType.Values).AsAny() + default: + panic(fmt.Errorf("unexpected kind: %v", field.Kind)) + } +} + +// ObjectKeyGen generates a value that is valid for the provided object key fields. +func ObjectKeyGen(keyFields []schema.Field) *rapid.Generator[any] { + if len(keyFields) == 0 { + return rapid.Just[any](nil) + } + + if len(keyFields) == 1 { + return FieldValueGen(keyFields[0]) + } + + gens := make([]*rapid.Generator[any], len(keyFields)) + for i, field := range keyFields { + gens[i] = FieldValueGen(field) + } + + return rapid.Custom(func(t *rapid.T) any { + values := make([]any, len(keyFields)) + for i, gen := range gens { + values[i] = gen.Draw(t, keyFields[i].Name) + } + return values + }) +} + +// ObjectValueGen generates a value that is valid for the provided object value fields. The +// forUpdate parameter indicates whether the generator should generate value that +// are valid for insertion (in the case forUpdate is false) or for update (in the case forUpdate is true). +// Values that are for update may skip some fields in a ValueUpdates instance whereas values for insertion +// will always contain all values. +func ObjectValueGen(valueFields []schema.Field, forUpdate bool) *rapid.Generator[any] { + // special case where there are no value fields + // we shouldn't end up here, but just in case + if len(valueFields) == 0 { + return rapid.Just[any](nil) + } + + gens := make([]*rapid.Generator[any], len(valueFields)) + for i, field := range valueFields { + gens[i] = FieldValueGen(field) + } + return rapid.Custom(func(t *rapid.T) any { + // return ValueUpdates 50% of the time + if boolGen.Draw(t, "valueUpdates") { + updates := map[string]any{} + + n := len(valueFields) + for i, gen := range gens { + lastField := i == n-1 + haveUpdates := len(updates) > 0 + // skip 50% of the time if this is an update + // but check if we have updates by the time we reach the last field + // so we don't have an empty update + if forUpdate && + (!lastField || haveUpdates) && + boolGen.Draw(t, fmt.Sprintf("skip_%s", valueFields[i].Name)) { + continue + } + updates[valueFields[i].Name] = gen.Draw(t, valueFields[i].Name) + } + + return schema.MapValueUpdates(updates) + } else { + if len(valueFields) == 1 { + return gens[0].Draw(t, valueFields[0].Name) + } + + values := make([]any, len(valueFields)) + for i, gen := range gens { + values[i] = gen.Draw(t, valueFields[i].Name) + } + + return values + } + }) +} diff --git a/schema/testing/field_test.go b/schema/testing/field_test.go new file mode 100644 index 000000000000..7e264fcebcad --- /dev/null +++ b/schema/testing/field_test.go @@ -0,0 +1,26 @@ +package schematesting + +import ( + "testing" + + "github.com/stretchr/testify/require" + "pgregory.net/rapid" +) + +func TestField(t *testing.T) { + rapid.Check(t, func(t *rapid.T) { + field := FieldGen.Draw(t, "field") + require.NoError(t, field.Validate()) + }) +} + +func TestFieldValue(t *testing.T) { + rapid.Check(t, checkFieldValue) +} + +var checkFieldValue = func(t *rapid.T) { + field := FieldGen.Draw(t, "field") + require.NoError(t, field.Validate()) + fieldValue := FieldValueGen(field).Draw(t, "fieldValue") + require.NoError(t, field.ValidateValue(fieldValue)) +} diff --git a/schema/testing/go.mod b/schema/testing/go.mod new file mode 100644 index 000000000000..e1cfc343bcdf --- /dev/null +++ b/schema/testing/go.mod @@ -0,0 +1,20 @@ +module cosmossdk.io/schema/testing + +require ( + cosmossdk.io/schema v0.0.0 + github.com/stretchr/testify v1.9.0 + github.com/tidwall/btree v1.7.0 + gotest.tools/v3 v3.5.1 + pgregory.net/rapid v1.1.0 +) + +require ( + github.com/davecgh/go-spew v1.1.1 // indirect + github.com/google/go-cmp v0.5.9 // indirect + github.com/pmezard/go-difflib v1.0.0 // indirect + gopkg.in/yaml.v3 v3.0.1 // indirect +) + +replace cosmossdk.io/schema => ./.. + +go 1.22 diff --git a/schema/testing/go.sum b/schema/testing/go.sum new file mode 100644 index 000000000000..393b537c2d4a --- /dev/null +++ b/schema/testing/go.sum @@ -0,0 +1,18 @@ +github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= +github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38= +github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= +github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= +github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= +github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg= +github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= +github.com/tidwall/btree v1.7.0 h1:L1fkJH/AuEh5zBnnBbmTwQ5Lt+bRJ5A8EWecslvo9iI= +github.com/tidwall/btree v1.7.0/go.mod h1:twD9XRA5jj9VUQGELzDO4HPQTNJsoWWfYEL+EUQ2cKY= +gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= +gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= +gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= +gotest.tools/v3 v3.5.1 h1:EENdUnS3pdur5nybKYIh2Vfgc8IUNBjxDPSjtiJcOzU= +gotest.tools/v3 v3.5.1/go.mod h1:isy3WKz7GK6uNw/sbHzfKBLvlvXwUyV06n6brMxxopU= +pgregory.net/rapid v1.1.0 h1:CMa0sjHSru3puNx+J0MIAuiiEV4N0qj8/cMWGBBCsjw= +pgregory.net/rapid v1.1.0/go.mod h1:PY5XlDGj0+V1FCq0o192FdRhpKHGTRIWBgqjDBTrq04= diff --git a/schema/testing/module_schema.go b/schema/testing/module_schema.go new file mode 100644 index 000000000000..9f62bfd2d281 --- /dev/null +++ b/schema/testing/module_schema.go @@ -0,0 +1,51 @@ +package schematesting + +import ( + "fmt" + + "pgregory.net/rapid" + + "cosmossdk.io/schema" +) + +// ModuleSchemaGen generates random ModuleSchema's based on the validity criteria of module schemas. +var ModuleSchemaGen = rapid.Custom(func(t *rapid.T) schema.ModuleSchema { + objectTypes := objectTypesGen.Draw(t, "objectTypes") + modSchema, err := schema.NewModuleSchema(objectTypes) + if err != nil { + t.Fatal(err) + } + return modSchema +}) + +var objectTypesGen = rapid.Custom(func(t *rapid.T) []schema.ObjectType { + var objectTypes []schema.ObjectType + numObjectTypes := rapid.IntRange(1, 10).Draw(t, "numObjectTypes") + for i := 0; i < numObjectTypes; i++ { + objectType := ObjectTypeGen.Draw(t, fmt.Sprintf("objectType[%d]", i)) + objectTypes = append(objectTypes, objectType) + } + return objectTypes +}).Filter(func(objectTypes []schema.ObjectType) bool { + typeNames := map[string]bool{} + for _, objectType := range objectTypes { + if hasDuplicateNames(typeNames, objectType.KeyFields) || hasDuplicateNames(typeNames, objectType.ValueFields) { + return false + } + if typeNames[objectType.Name] { + return false + } + typeNames[objectType.Name] = true + } + return true +}) + +// MustNewModuleSchema calls NewModuleSchema and panics if there's an error. This should generally be used +// only in tests or initialization code. +func MustNewModuleSchema(objectTypes []schema.ObjectType) schema.ModuleSchema { + schema, err := schema.NewModuleSchema(objectTypes) + if err != nil { + panic(err) + } + return schema +} diff --git a/schema/testing/module_schema_test.go b/schema/testing/module_schema_test.go new file mode 100644 index 000000000000..91196d59aa18 --- /dev/null +++ b/schema/testing/module_schema_test.go @@ -0,0 +1,15 @@ +package schematesting + +import ( + "testing" + + "github.com/stretchr/testify/require" + "pgregory.net/rapid" +) + +func TestModuleSchema(t *testing.T) { + rapid.Check(t, func(t *rapid.T) { + schema := ModuleSchemaGen.Draw(t, "schema") + require.NoError(t, schema.Validate()) + }) +} diff --git a/schema/testing/name.go b/schema/testing/name.go new file mode 100644 index 000000000000..144347e5db46 --- /dev/null +++ b/schema/testing/name.go @@ -0,0 +1,10 @@ +package schematesting + +import ( + "pgregory.net/rapid" + + "cosmossdk.io/schema" +) + +// NameGen validates valid names that match the NameFormat regex. +var NameGen = rapid.StringMatching(schema.NameFormat) diff --git a/schema/testing/name_test.go b/schema/testing/name_test.go new file mode 100644 index 000000000000..b4d9a44ea612 --- /dev/null +++ b/schema/testing/name_test.go @@ -0,0 +1,17 @@ +package schematesting + +import ( + "testing" + + "github.com/stretchr/testify/require" + "pgregory.net/rapid" + + "cosmossdk.io/schema" +) + +func TestName(t *testing.T) { + rapid.Check(t, func(t *rapid.T) { + name := NameGen.Draw(t, "name") + require.True(t, schema.ValidateName(name)) + }) +} diff --git a/schema/testing/object.go b/schema/testing/object.go new file mode 100644 index 000000000000..8d7bd37a2a05 --- /dev/null +++ b/schema/testing/object.go @@ -0,0 +1,127 @@ +package schematesting + +import ( + "github.com/tidwall/btree" + "pgregory.net/rapid" + + "cosmossdk.io/schema" +) + +var fieldsGen = rapid.SliceOfNDistinct(FieldGen, 1, 12, func(f schema.Field) string { + return f.Name +}) + +// ObjectTypeGen generates random ObjectType's based on the validity criteria of object types. +var ObjectTypeGen = rapid.Custom(func(t *rapid.T) schema.ObjectType { + typ := schema.ObjectType{ + Name: NameGen.Draw(t, "name"), + } + + fields := fieldsGen.Draw(t, "fields") + numKeyFields := rapid.IntRange(0, len(fields)).Draw(t, "numKeyFields") + + typ.KeyFields = fields[:numKeyFields] + + for i := range typ.KeyFields { + // key fields can't be nullable + typ.KeyFields[i].Nullable = false + } + + typ.ValueFields = fields[numKeyFields:] + + typ.RetainDeletions = boolGen.Draw(t, "retainDeletions") + + return typ +}).Filter(func(typ schema.ObjectType) bool { + // filter out duplicate enum names + typeNames := map[string]bool{typ.Name: true} + if hasDuplicateNames(typeNames, typ.KeyFields) { + return false + } + if hasDuplicateNames(typeNames, typ.ValueFields) { + return false + } + return true +}) + +// hasDuplicateNames checks if there is type name in the fields +func hasDuplicateNames(typeNames map[string]bool, fields []schema.Field) bool { + for _, field := range fields { + if field.Kind != schema.EnumKind { + continue + } + + if _, ok := typeNames[field.EnumType.Name]; ok { + return true + } + + typeNames[field.EnumType.Name] = true + } + return false +} + +// ObjectInsertGen generates object updates that are valid for insertion. +func ObjectInsertGen(objectType schema.ObjectType) *rapid.Generator[schema.ObjectUpdate] { + return ObjectUpdateGen(objectType, nil) +} + +// ObjectUpdateGen generates object updates that are valid for updates using the provided state map as a source +// of valid existing keys. +func ObjectUpdateGen(objectType schema.ObjectType, state *btree.Map[string, schema.ObjectUpdate]) *rapid.Generator[schema.ObjectUpdate] { + keyGen := ObjectKeyGen(objectType.KeyFields) + + if len(objectType.ValueFields) == 0 { + // special case where there are no value fields, + // so we just insert or delete, no updates + return rapid.Custom(func(t *rapid.T) schema.ObjectUpdate { + update := schema.ObjectUpdate{ + TypeName: objectType.Name, + } + + // 50% of the time delete existing key (when there are keys) + n := 0 + if state != nil { + n = state.Len() + } + if n > 0 && boolGen.Draw(t, "delete") { + i := rapid.IntRange(0, n-1).Draw(t, "index") + update.Key = state.Values()[i].Key + update.Delete = true + } else { + update.Key = keyGen.Draw(t, "key") + } + + return update + }) + } else { + insertValueGen := ObjectValueGen(objectType.ValueFields, false) + updateValueGen := ObjectValueGen(objectType.ValueFields, true) + return rapid.Custom(func(t *rapid.T) schema.ObjectUpdate { + update := schema.ObjectUpdate{ + TypeName: objectType.Name, + } + + // 50% of the time use existing key (when there are keys) + n := 0 + if state != nil { + n = state.Len() + } + if n > 0 && boolGen.Draw(t, "existingKey") { + i := rapid.IntRange(0, n-1).Draw(t, "index") + update.Key = state.Values()[i].Key + + // delete 50% of the time + if boolGen.Draw(t, "delete") { + update.Delete = true + } else { + update.Value = updateValueGen.Draw(t, "value") + } + } else { + update.Key = keyGen.Draw(t, "key") + update.Value = insertValueGen.Draw(t, "value") + } + + return update + }) + } +} diff --git a/schema/testing/object_test.go b/schema/testing/object_test.go new file mode 100644 index 000000000000..9106878a7fed --- /dev/null +++ b/schema/testing/object_test.go @@ -0,0 +1,24 @@ +package schematesting + +import ( + "testing" + + "github.com/stretchr/testify/require" + "pgregory.net/rapid" +) + +func TestObject(t *testing.T) { + rapid.Check(t, func(t *rapid.T) { + objectType := ObjectTypeGen.Draw(t, "object") + require.NoError(t, objectType.Validate()) + }) +} + +func TestObjectUpdate(t *testing.T) { + rapid.Check(t, func(t *rapid.T) { + objectType := ObjectTypeGen.Draw(t, "object") + require.NoError(t, objectType.Validate()) + update := ObjectInsertGen(objectType).Draw(t, "update") + require.NoError(t, objectType.ValidateObjectUpdate(update)) + }) +} diff --git a/schema/testing/sonar-project.properties b/schema/testing/sonar-project.properties new file mode 100644 index 000000000000..6d4dd005040e --- /dev/null +++ b/schema/testing/sonar-project.properties @@ -0,0 +1,16 @@ +sonar.projectKey=cosmos-sdk-schema-testing +sonar.organization=cosmos + +sonar.projectName=Cosmos SDK - Schema Testing +sonar.project.monorepo.enabled=true + +sonar.sources=. +sonar.exclusions=**/*_test.go,**/*.pb.go,**/*.pulsar.go,**/*.pb.gw.go +sonar.coverage.exclusions=**/*_test.go,**/testutil/**,**/*.pb.go,**/*.pb.gw.go,**/*.pulsar.go,test_helpers.go,docs/** +sonar.tests=. +sonar.test.inclusions=**/*_test.go +sonar.go.coverage.reportPaths=coverage.out + +sonar.sourceEncoding=UTF-8 +sonar.scm.provider=git +sonar.scm.forceReloadAll=true diff --git a/schema/testing/statesim/app.go b/schema/testing/statesim/app.go new file mode 100644 index 000000000000..127af5431b9d --- /dev/null +++ b/schema/testing/statesim/app.go @@ -0,0 +1,108 @@ +package statesim + +import ( + "fmt" + + "github.com/stretchr/testify/require" + "github.com/tidwall/btree" + "pgregory.net/rapid" + + "cosmossdk.io/schema" + "cosmossdk.io/schema/appdata" +) + +// App is a collection of simulated module states corresponding to an app's schema for testing purposes. +type App struct { + options Options + moduleStates *btree.Map[string, *Module] + updateGen *rapid.Generator[appdata.ObjectUpdateData] +} + +// NewApp creates a new simulation App for the given app schema. The app schema can be nil +// if the user desires initializing modules with InitializeModule instead. +func NewApp(appSchema map[string]schema.ModuleSchema, options Options) *App { + app := &App{ + options: options, + moduleStates: &btree.Map[string, *Module]{}, + } + + for moduleName, moduleSchema := range appSchema { + moduleState := NewModule(moduleSchema, options) + app.moduleStates.Set(moduleName, moduleState) + } + + moduleNameSelector := rapid.Custom(func(t *rapid.T) string { + return rapid.SampledFrom(app.moduleStates.Keys()).Draw(t, "moduleName") + }) + + numUpdatesGen := rapid.IntRange(1, 2) + app.updateGen = rapid.Custom(func(t *rapid.T) appdata.ObjectUpdateData { + moduleName := moduleNameSelector.Draw(t, "moduleName") + moduleState, ok := app.moduleStates.Get(moduleName) + require.True(t, ok) + numUpdates := numUpdatesGen.Draw(t, "numUpdates") + updates := make([]schema.ObjectUpdate, numUpdates) + for i := 0; i < numUpdates; i++ { + update := moduleState.UpdateGen().Draw(t, fmt.Sprintf("update[%d]", i)) + updates[i] = update + } + return appdata.ObjectUpdateData{ + ModuleName: moduleName, + Updates: updates, + } + }) + + return app +} + +// InitializeModule initializes the module with the provided schema. This returns an error if the +// module is already initialized in state. +func (a *App) InitializeModule(data appdata.ModuleInitializationData) error { + if _, ok := a.moduleStates.Get(data.ModuleName); ok { + return fmt.Errorf("module %s already initialized", data.ModuleName) + } + + a.moduleStates.Set(data.ModuleName, NewModule(data.Schema, a.options)) + return nil +} + +// ApplyUpdate applies the given object update to the module. +func (a *App) ApplyUpdate(data appdata.ObjectUpdateData) error { + moduleState, ok := a.moduleStates.Get(data.ModuleName) + if !ok { + // we don't have this module so skip the update + return nil + } + + for _, update := range data.Updates { + err := moduleState.ApplyUpdate(update) + if err != nil { + return err + } + } + + return nil +} + +// UpdateGen is a generator for object update data against the app. It is stateful and includes a certain number of +// updates and deletions to existing objects. +func (a *App) UpdateGen() *rapid.Generator[appdata.ObjectUpdateData] { + return a.updateGen +} + +// GetModule returns the module state for the given module name. +func (a *App) GetModule(moduleName string) (ModuleState, bool) { + return a.moduleStates.Get(moduleName) +} + +// Modules iterates over all the module state instances in the app. +func (a *App) Modules(f func(moduleName string, modState ModuleState) bool) { + a.moduleStates.Scan(func(key string, value *Module) bool { + return f(key, value) + }) +} + +// NumModules returns the number of modules in the app. +func (a *App) NumModules() int { + return a.moduleStates.Len() +} diff --git a/schema/testing/statesim/app_diff.go b/schema/testing/statesim/app_diff.go new file mode 100644 index 000000000000..6dfa222d066a --- /dev/null +++ b/schema/testing/statesim/app_diff.go @@ -0,0 +1,43 @@ +package statesim + +import "fmt" + +// AppState defines an interface for things that represent application state in schema format. +type AppState interface { + // GetModule returns the module state for the given module name. + GetModule(moduleName string) (ModuleState, bool) + + // Modules iterates over all the module state instances in the app. + Modules(f func(moduleName string, modState ModuleState) bool) + + // NumModules returns the number of modules in the app. + NumModules() int +} + +// DiffAppStates compares the app state of two objects that implement AppState and returns a string with a diff if they +// are different or the empty string if they are the same. +func DiffAppStates(expected, actual AppState) string { + res := "" + + if expected.NumModules() != actual.NumModules() { + res += fmt.Sprintf("MODULE COUNT ERROR: expected %d, got %d\n", expected.NumModules(), actual.NumModules()) + } + + expected.Modules(func(moduleName string, expectedMod ModuleState) bool { + actualMod, found := actual.GetModule(moduleName) + if !found { + res += fmt.Sprintf("Module %s: NOT FOUND\n", moduleName) + return true + } + + diff := DiffModuleStates(expectedMod, actualMod) + if diff != "" { + res += "Module " + moduleName + "\n" + res += indentAllLines(diff) + } + + return true + }) + + return res +} diff --git a/schema/testing/statesim/doc.go b/schema/testing/statesim/doc.go new file mode 100644 index 000000000000..9f06ff8eb71c --- /dev/null +++ b/schema/testing/statesim/doc.go @@ -0,0 +1,3 @@ +// Package statesim contains utilities for simulating state based on ObjectType's and ModuleSchema's for testing +// the conformance of state management libraries and indexers to schema rules. +package statesim diff --git a/schema/testing/statesim/module.go b/schema/testing/statesim/module.go new file mode 100644 index 000000000000..6a33f19d5817 --- /dev/null +++ b/schema/testing/statesim/module.go @@ -0,0 +1,84 @@ +package statesim + +import ( + "fmt" + + "github.com/stretchr/testify/require" + "github.com/tidwall/btree" + "pgregory.net/rapid" + + "cosmossdk.io/schema" +) + +// Module is a collection of object collections corresponding to a module's schema for testing purposes. +type Module struct { + moduleSchema schema.ModuleSchema + objectCollections *btree.Map[string, *ObjectCollection] + updateGen *rapid.Generator[schema.ObjectUpdate] +} + +// NewModule creates a new Module for the given module schema. +func NewModule(moduleSchema schema.ModuleSchema, options Options) *Module { + objectCollections := &btree.Map[string, *ObjectCollection]{} + var objectTypeNames []string + + moduleSchema.ObjectTypes(func(objectType schema.ObjectType) bool { + objectCollection := NewObjectCollection(objectType, options) + objectCollections.Set(objectType.Name, objectCollection) + objectTypeNames = append(objectTypeNames, objectType.Name) + return true + }) + + objectTypeSelector := rapid.SampledFrom(objectTypeNames) + + updateGen := rapid.Custom(func(t *rapid.T) schema.ObjectUpdate { + objectType := objectTypeSelector.Draw(t, "objectType") + objectColl, ok := objectCollections.Get(objectType) + require.True(t, ok) + return objectColl.UpdateGen().Draw(t, "update") + }) + + return &Module{ + moduleSchema: moduleSchema, + updateGen: updateGen, + objectCollections: objectCollections, + } +} + +// ApplyUpdate applies the given object update to the module. +func (o *Module) ApplyUpdate(update schema.ObjectUpdate) error { + objState, ok := o.objectCollections.Get(update.TypeName) + if !ok { + return fmt.Errorf("object type %s not found in module", update.TypeName) + } + + return objState.ApplyUpdate(update) +} + +// UpdateGen returns a generator for object updates. The generator is stateful and returns +// a certain number of updates and deletes of existing objects in the module. +func (o *Module) UpdateGen() *rapid.Generator[schema.ObjectUpdate] { + return o.updateGen +} + +// ModuleSchema returns the module schema for the module. +func (o *Module) ModuleSchema() schema.ModuleSchema { + return o.moduleSchema +} + +// GetObjectCollection returns the object collection for the given object type. +func (o *Module) GetObjectCollection(objectType string) (ObjectCollectionState, bool) { + return o.objectCollections.Get(objectType) +} + +// ObjectCollections iterates over all object collections in the module. +func (o *Module) ObjectCollections(f func(value ObjectCollectionState) bool) { + o.objectCollections.Scan(func(key string, value *ObjectCollection) bool { + return f(value) + }) +} + +// NumObjectCollections returns the number of object collections in the module. +func (o *Module) NumObjectCollections() int { + return o.objectCollections.Len() +} diff --git a/schema/testing/statesim/module_diff.go b/schema/testing/statesim/module_diff.go new file mode 100644 index 000000000000..0907f974dfd8 --- /dev/null +++ b/schema/testing/statesim/module_diff.go @@ -0,0 +1,51 @@ +package statesim + +import ( + "fmt" + + "cosmossdk.io/schema" +) + +// ModuleState defines an interface for things that represent module state in schema format. +type ModuleState interface { + // ModuleSchema returns the schema for the module. + ModuleSchema() schema.ModuleSchema + + // GetObjectCollection returns the object collection state for the given object type. + GetObjectCollection(objectType string) (ObjectCollectionState, bool) + + // ObjectCollections iterates over all the object collection states in the module. + ObjectCollections(f func(value ObjectCollectionState) bool) + + // NumObjectCollections returns the number of object collections in the module. + NumObjectCollections() int +} + +// DiffModuleStates compares the module state of two objects that implement ModuleState and returns a string with a diff if they +// are different or the empty string if they are the same. +func DiffModuleStates(expected, actual ModuleState) string { + res := "" + + if expected.NumObjectCollections() != actual.NumObjectCollections() { + res += fmt.Sprintf("OBJECT COLLECTION COUNT ERROR: expected %d, got %d\n", expected.NumObjectCollections(), actual.NumObjectCollections()) + } + + expected.ObjectCollections(func(expectedColl ObjectCollectionState) bool { + objTypeName := expectedColl.ObjectType().Name + actualColl, found := actual.GetObjectCollection(objTypeName) + if !found { + res += fmt.Sprintf("Object Collection %s: NOT FOUND\n", objTypeName) + return true + } + + diff := DiffObjectCollections(expectedColl, actualColl) + if diff != "" { + res += "Object Collection " + objTypeName + "\n" + res += indentAllLines(diff) + } + + return true + }) + + return res +} diff --git a/schema/testing/statesim/object_coll.go b/schema/testing/statesim/object_coll.go new file mode 100644 index 000000000000..56b09fe758b5 --- /dev/null +++ b/schema/testing/statesim/object_coll.go @@ -0,0 +1,167 @@ +package statesim + +import ( + "fmt" + + "github.com/tidwall/btree" + "pgregory.net/rapid" + + "cosmossdk.io/schema" + schematesting "cosmossdk.io/schema/testing" +) + +// ObjectCollection is a collection of objects of a specific type for testing purposes. +type ObjectCollection struct { + options Options + objectType schema.ObjectType + objects *btree.Map[string, schema.ObjectUpdate] + updateGen *rapid.Generator[schema.ObjectUpdate] + valueFieldIndices map[string]int +} + +// NewObjectCollection creates a new ObjectCollection for the given object type. +func NewObjectCollection(objectType schema.ObjectType, options Options) *ObjectCollection { + objects := &btree.Map[string, schema.ObjectUpdate]{} + updateGen := schematesting.ObjectUpdateGen(objectType, objects) + valueFieldIndices := make(map[string]int, len(objectType.ValueFields)) + for i, field := range objectType.ValueFields { + valueFieldIndices[field.Name] = i + } + + return &ObjectCollection{ + options: options, + objectType: objectType, + objects: objects, + updateGen: updateGen, + valueFieldIndices: valueFieldIndices, + } +} + +// ApplyUpdate applies the given object update to the collection. +func (o *ObjectCollection) ApplyUpdate(update schema.ObjectUpdate) error { + if update.TypeName != o.objectType.Name { + return fmt.Errorf("update type name %q does not match object type name %q", update.TypeName, o.objectType.Name) + } + + err := o.objectType.ValidateObjectUpdate(update) + if err != nil { + return err + } + + keyStr := fmtObjectKey(o.objectType, update.Key) + cur, exists := o.objects.Get(keyStr) + if update.Delete { + if o.objectType.RetainDeletions && o.options.CanRetainDeletions { + if !exists { + return fmt.Errorf("object not found for deletion: %v", update.Key) + } + + cur.Delete = true + o.objects.Set(keyStr, cur) + } else { + o.objects.Delete(keyStr) + } + } else { + // convert value updates to array + if valueUpdates, ok := update.Value.(schema.ValueUpdates); ok { + var values []interface{} + n := len(o.objectType.ValueFields) + if exists { + if n == 1 { + values = []interface{}{cur.Value} + } else { + values = cur.Value.([]interface{}) + } + } else { + values = make([]interface{}, len(o.objectType.ValueFields)) + } + + err = valueUpdates.Iterate(func(fieldName string, value interface{}) bool { + fieldIndex, ok := o.valueFieldIndices[fieldName] + if !ok { + panic(fmt.Sprintf("field %q not found in object type %q", fieldName, o.objectType.Name)) + } + + values[fieldIndex] = value + return true + }) + if err != nil { + return err + } + + if n == 1 { + update.Value = values[0] + } else { + update.Value = values + } + } + + o.objects.Set(keyStr, update) + } + + return nil +} + +// UpdateGen returns a generator for random object updates against the collection. This generator +// is stateful and returns a certain number of updates and deletes to existing objects. +func (o *ObjectCollection) UpdateGen() *rapid.Generator[schema.ObjectUpdate] { + return o.updateGen +} + +// AllState iterates over the state of the collection by calling the given function with each item in +// state represented as an object update. +func (o *ObjectCollection) AllState(f func(schema.ObjectUpdate) bool) { + o.objects.Scan(func(_ string, v schema.ObjectUpdate) bool { + return f(v) + }) +} + +// GetObject returns the object with the given key from the collection represented as an ObjectUpdate +// itself. Deletions that are retained are returned as ObjectUpdate's with delete set to true. +func (o *ObjectCollection) GetObject(key any) (update schema.ObjectUpdate, found bool) { + return o.objects.Get(fmtObjectKey(o.objectType, key)) +} + +// ObjectType returns the object type of the collection. +func (o *ObjectCollection) ObjectType() schema.ObjectType { + return o.objectType +} + +// Len returns the number of objects in the collection. +func (o *ObjectCollection) Len() int { + return o.objects.Len() +} + +func fmtObjectKey(objectType schema.ObjectType, key any) string { + keyFields := objectType.KeyFields + n := len(keyFields) + switch n { + case 0: + return "" + case 1: + valStr := fmtValue(keyFields[0].Kind, key) + return fmt.Sprintf("%s=%v", keyFields[0].Name, valStr) + default: + ks := key.([]interface{}) + res := "" + for i := 0; i < n; i++ { + if i != 0 { + res += ", " + } + valStr := fmtValue(keyFields[i].Kind, ks[i]) + res += fmt.Sprintf("%s=%v", keyFields[i].Name, valStr) + } + return res + } +} + +func fmtValue(kind schema.Kind, value any) string { + switch kind { + case schema.BytesKind, schema.AddressKind: + return fmt.Sprintf("0x%x", value) + case schema.JSONKind: + return fmt.Sprintf("%s", value) + default: + return fmt.Sprintf("%v", value) + } +} diff --git a/schema/testing/statesim/object_coll_diff.go b/schema/testing/statesim/object_coll_diff.go new file mode 100644 index 000000000000..0a9be9f222d6 --- /dev/null +++ b/schema/testing/statesim/object_coll_diff.go @@ -0,0 +1,75 @@ +package statesim + +import ( + "fmt" + "strings" + + "cosmossdk.io/schema" + schematesting "cosmossdk.io/schema/testing" +) + +// ObjectCollectionState is the interface for the state of an object collection +// represented by ObjectUpdate's for an ObjectType. ObjectUpdates must not include +// ValueUpdates in the Value field. When ValueUpdates are applied they must be +// converted to individual value or array format depending on the number of fields in +// the value. For collections which retain deletions, ObjectUpdate's with the Delete +// field set to true should be returned with the latest Value still intact. +type ObjectCollectionState interface { + // ObjectType returns the object type for the collection. + ObjectType() schema.ObjectType + + // GetObject returns the object update for the given key if it exists. + GetObject(key any) (update schema.ObjectUpdate, found bool) + + // AllState iterates over the state of the collection by calling the given function with each item in + // state represented as an object update. + AllState(f func(schema.ObjectUpdate) bool) + + // Len returns the number of objects in the collection. + Len() int +} + +// DiffObjectCollections compares the object collection state of two objects that implement ObjectCollectionState and returns a string with a diff if they +// are different or the empty string if they are the same. +func DiffObjectCollections(expected, actual ObjectCollectionState) string { + res := "" + if expected.Len() != actual.Len() { + res += fmt.Sprintf("OBJECT COUNT ERROR: expected %d, got %d\n", expected.Len(), actual.Len()) + } + + expected.AllState(func(expectedUpdate schema.ObjectUpdate) bool { + actualUpdate, found := actual.GetObject(expectedUpdate.Key) + if !found { + res += fmt.Sprintf("Object %s: NOT FOUND\n", fmtObjectKey(expected.ObjectType(), expectedUpdate.Key)) + return true + } + + if expectedUpdate.Delete != actualUpdate.Delete { + res += fmt.Sprintf("Object %s: Deleted mismatch, expected %v, got %v\n", fmtObjectKey(expected.ObjectType(), expectedUpdate.Key), expectedUpdate.Delete, actualUpdate.Delete) + } + + if expectedUpdate.Delete { + return true + } + + valueDiff := schematesting.DiffObjectValues(expected.ObjectType().ValueFields, expectedUpdate.Value, actualUpdate.Value) + if valueDiff != "" { + res += "Object " + res += fmtObjectKey(expected.ObjectType(), expectedUpdate.Key) + res += "\n" + res += indentAllLines(valueDiff) + } + + return true + }) + + return res +} + +func indentAllLines(s string) string { + lines := strings.Split(s, "\n") + for i, line := range lines { + lines[i] = " " + line + } + return strings.Join(lines, "\n") +} diff --git a/schema/testing/statesim/options.go b/schema/testing/statesim/options.go new file mode 100644 index 000000000000..c19ad565399f --- /dev/null +++ b/schema/testing/statesim/options.go @@ -0,0 +1,9 @@ +package statesim + +// Options are options for object, module and app state simulators. +type Options struct { + // CanRetainDeletions indicates that the simulator can retain deletions when that flag is enabled + // on object types. This should be set to match the indexers ability to retain deletions or not + // for accurately testing the expected state in the simulator with the indexer's actual state. + CanRetainDeletions bool +} diff --git a/schema/type.go b/schema/type.go new file mode 100644 index 000000000000..75155de8688f --- /dev/null +++ b/schema/type.go @@ -0,0 +1,10 @@ +package schema + +// Type is an interface that all types in the schema implement. +// Currently these are ObjectType and EnumType. +type Type interface { + // TypeName returns the type's name. + TypeName() string + + isType() +} diff --git a/scripts/build/localnet.mk b/scripts/build/localnet.mk index 2bc94a7351d8..931e8b421285 100644 --- a/scripts/build/localnet.mk +++ b/scripts/build/localnet.mk @@ -27,7 +27,7 @@ localnet-debug: localnet-stop localnet-build-dlv localnet-build-nodes .PHONY: localnet-start localnet-stop localnet-debug localnet-build-env localnet-build-dlv localnet-build-nodes #? help: Get more info on make commands. -help: Makefile +help: @echo " Choose a command run in "$(PROJECT_NAME)":" - @sed -n 's/^#?//p' $< | column -t -s ':' | sort | sed -e 's/^/ /' + @cat $(MAKEFILE_LIST) | sed -n 's/^#?//p' | column -t -s ':' | sort | sed -e 's/^/ /' .PHONY: help diff --git a/scripts/build/simulations.mk b/scripts/build/simulations.mk index 6d0f077e6d87..ea7510db4cb8 100644 --- a/scripts/build/simulations.mk +++ b/scripts/build/simulations.mk @@ -45,7 +45,7 @@ test-sim-custom-genesis-multi-seed: test-sim-multi-seed-long: @echo "Running long multi-seed application simulation. This may take awhile!" @cd ${CURRENT_DIR}/simapp && go test -mod=readonly -timeout=1h -tags='sims' -run TestFullAppSimulation \ - -NumBlocks=500 -Period=50 + -NumBlocks=150 -Period=50 test-sim-multi-seed-short: @echo "Running short multi-seed application simulation. This may take awhile!" diff --git a/scripts/build/testing.mk b/scripts/build/testing.mk index 8289d538ac6b..98f1afe2a634 100644 --- a/scripts/build/testing.mk +++ b/scripts/build/testing.mk @@ -6,6 +6,8 @@ #? init-simapp: Initializes a single local node network init-simapp: ./scripts/init-simapp.sh +init-simapp-v2: + ./scripts/init-simapp-v2.sh #? test: Run `make test-unit` test: test-unit diff --git a/scripts/init-simapp-v2.sh b/scripts/init-simapp-v2.sh new file mode 100755 index 000000000000..a4788dfee838 --- /dev/null +++ b/scripts/init-simapp-v2.sh @@ -0,0 +1,23 @@ +#!/usr/bin/env bash + +SIMD_BIN=${SIMD_BIN:=$(which simdv2 2>/dev/null)} + +if [ -z "$SIMD_BIN" ]; then echo "SIMD_BIN is not set. Make sure to run 'COSMOS_BUILD_OPTIONS=v2 make install' before"; exit 1; fi +echo "using $SIMD_BIN" +SIMD_HOME=$($SIMD_BIN config home) +if [ -d "$SIMD_HOME" ]; then rm -rv $SIMD_HOME; fi +$SIMD_BIN config set client chain-id simapp-v2-chain +$SIMD_BIN config set client keyring-backend test +$SIMD_BIN config set client keyring-default-keyname alice +$SIMD_BIN config set app api.enable true +$SIMD_BIN keys add alice --indiscreet +$SIMD_BIN keys add bob --indiscreet +$SIMD_BIN init simapp-v2-node --chain-id simapp-v2-chain +# to change the voting_period +jq '.app_state.gov.params.voting_period = "600s"' $SIMD_HOME/config/genesis.json > temp.json && mv temp.json $SIMD_HOME/config/genesis.json +jq '.app_state.gov.params.expedited_voting_period = "300s"' $SIMD_HOME/config/genesis.json > temp.json && mv temp.json $SIMD_HOME/config/genesis.json +jq '.app_state.mint.minter.inflation = "0.300000000000000000"' $SIMD_HOME/config/genesis.json > temp.json && mv temp.json $SIMD_HOME/config/genesis.json # to change the inflation +$SIMD_BIN genesis add-genesis-account alice 5000000000stake --keyring-backend test +$SIMD_BIN genesis add-genesis-account bob 5000000000stake --keyring-backend test +$SIMD_BIN genesis gentx alice 1000000stake --chain-id demo +$SIMD_BIN genesis collect-gentxs \ No newline at end of file diff --git a/scripts/init-simapp.sh b/scripts/init-simapp.sh index b7f08949564b..d3995197fdeb 100755 --- a/scripts/init-simapp.sh +++ b/scripts/init-simapp.sh @@ -2,9 +2,9 @@ SIMD_BIN=${SIMD_BIN:=$(which simd 2>/dev/null)} -if [ -z "$SIMD_BIN" ]; then echo "SIMD_BIN is not set. Make sure to run make install before"; exit 1; fi -echo "using $SIMD_BIN" -if [ -d "$($SIMD_BIN config home)" ]; then rm -rv $($SIMD_BIN config home); fi +if [ -z "$SIMD_BIN" ]; then echo "SIMD_BIN is not set. Make sure to run 'make install' before"; exit 1; fi +SIMD_HOME=$($SIMD_BIN config home) +if [ -d "$SIMD_HOME" ]; then rm -rv $SIMD_HOME; fi $SIMD_BIN config set client chain-id demo $SIMD_BIN config set client keyring-backend test $SIMD_BIN config set client keyring-default-keyname alice @@ -12,6 +12,10 @@ $SIMD_BIN config set app api.enable true $SIMD_BIN keys add alice --indiscreet $SIMD_BIN keys add bob --indiscreet $SIMD_BIN init test --chain-id demo +# to change the voting_period +jq '.app_state.gov.params.voting_period = "600s"' $SIMD_HOME/config/genesis.json > temp.json && mv temp.json $SIMD_HOME/config/genesis.json +jq '.app_state.gov.params.expedited_voting_period = "300s"' $SIMD_HOME/config/genesis.json > temp.json && mv temp.json $SIMD_HOME/config/genesis.json +jq '.app_state.mint.minter.inflation = "0.300000000000000000"' $SIMD_HOME/config/genesis.json > temp.json && mv temp.json $SIMD_HOME/config/genesis.json # to change the inflation $SIMD_BIN genesis add-genesis-account alice 5000000000stake --keyring-backend test $SIMD_BIN genesis add-genesis-account bob 5000000000stake --keyring-backend test $SIMD_BIN genesis gentx alice 1000000stake --chain-id demo diff --git a/scripts/simapp-v2-init.sh b/scripts/simapp-v2-init.sh deleted file mode 100755 index 7d22970e4605..000000000000 --- a/scripts/simapp-v2-init.sh +++ /dev/null @@ -1,47 +0,0 @@ -#!/usr/bin/env bash - -set -o errexit -set -o nounset -set -x - -ROOT=$PWD - -SIMD="$ROOT/build/simdv2" -CONFIG="${CONFIG:-$HOME/.simappv2/config}" - -COSMOS_BUILD_OPTIONS=v2 make build - -if [ -d "$($SIMD config home)" ]; then rm -rv $($SIMD config home); fi - -$SIMD init simapp-v2-node --chain-id simapp-v2-chain - -cd "$CONFIG" - -# to change the voting_period -jq '.app_state.gov.voting_params.voting_period = "600s"' genesis.json > temp.json && mv temp.json genesis.json - -# to change the inflation -jq '.app_state.mint.minter.inflation = "0.300000000000000000"' genesis.json > temp.json && mv temp.json genesis.json - -$SIMD config set client chain-id simapp-v2-chain -$SIMD keys add test_validator --indiscreet -VALIDATOR_ADDRESS=$($SIMD keys show test_validator -a --keyring-backend test) - -$SIMD genesis add-genesis-account "$VALIDATOR_ADDRESS" 1000000000stake -$SIMD genesis gentx test_validator 1000000000stake --keyring-backend test -$SIMD genesis collect-gentxs - -$SIMD start & -SIMD_PID=$! - -cnt=0 -while ! $SIMD query block --type=height 5; do - cnt=$((cnt + 1)) - if [ $cnt -gt 30 ]; then - kill -9 "$SIMD_PID" - exit 1 - fi - sleep 1 -done - -kill -9 "$SIMD_PID" diff --git a/server/cmt_cmds.go b/server/cmt_cmds.go index e4fdf1ed814c..abbc4a9f5da3 100644 --- a/server/cmt_cmds.go +++ b/server/cmt_cmds.go @@ -3,6 +3,7 @@ package server import ( "context" "encoding/json" + "errors" "fmt" "strconv" "strings" @@ -226,7 +227,7 @@ $ %s query block --%s=%s `, version.AppName, auth.FlagType, auth.TypeHeight, version.AppName, auth.FlagType, auth.TypeHash)), - Args: cobra.ExactArgs(1), + Args: cobra.MaximumNArgs(1), RunE: func(cmd *cobra.Command, args []string) error { clientCtx, err := client.GetClientQueryContext(cmd) if err != nil { @@ -234,24 +235,37 @@ $ %s query block --%s=%s } typ, _ := cmd.Flags().GetString(auth.FlagType) + if len(args) == 0 { + // do not break default v0.50 behavior of block hash + // if no args are provided, set the type to height + typ = auth.TypeHeight + } switch typ { case auth.TypeHeight: - - if args[0] == "" { - return fmt.Errorf("argument should be a block height") + var ( + err error + height int64 + ) + heightStr := "" + if len(args) > 0 { + heightStr = args[0] } - // optional height - var height *int64 - if len(args) > 0 { - height, err = parseOptionalHeight(args[0]) + if heightStr == "" { + cmd.Println("Falling back to latest block height:") + height, err = rpc.GetChainHeight(clientCtx) + if err != nil { + return fmt.Errorf("failed to get chain height: %w", err) + } + } else { + height, err = strconv.ParseInt(heightStr, 10, 64) if err != nil { - return err + return fmt.Errorf("failed to parse block height: %w", err) } } - output, err := rpc.GetBlockByHeight(clientCtx, height) + output, err := rpc.GetBlockByHeight(clientCtx, &height) if err != nil { return err } @@ -265,7 +279,7 @@ $ %s query block --%s=%s case auth.TypeHash: if args[0] == "" { - return fmt.Errorf("argument should be a tx hash") + return errors.New("argument should be a tx hash") } // If hash is given, then query the tx by hash. @@ -311,15 +325,21 @@ func QueryBlockResultsCmd() *cobra.Command { } // optional height - var height *int64 + var height int64 if len(args) > 0 { - height, err = parseOptionalHeight(args[0]) + height, err = strconv.ParseInt(args[0], 10, 64) if err != nil { return err } + } else { + cmd.Println("Falling back to latest block height:") + height, err = rpc.GetChainHeight(clientCtx) + if err != nil { + return fmt.Errorf("failed to get chain height: %w", err) + } } - blockRes, err := node.BlockResults(context.Background(), height) + blockRes, err := node.BlockResults(context.Background(), &height) if err != nil { return err } @@ -341,21 +361,6 @@ func QueryBlockResultsCmd() *cobra.Command { return cmd } -func parseOptionalHeight(heightStr string) (*int64, error) { - h, err := strconv.Atoi(heightStr) - if err != nil { - return nil, err - } - - if h == 0 { - return nil, nil - } - - tmp := int64(h) - - return &tmp, nil -} - func BootstrapStateCmd[T types.Application](appCreator types.AppCreator[T]) *cobra.Command { cmd := &cobra.Command{ Use: "bootstrap-state", diff --git a/server/grpc/reflection/v2alpha1/reflection.go b/server/grpc/reflection/v2alpha1/reflection.go index 2e2fd1a45e6a..fd1ffe4293f7 100644 --- a/server/grpc/reflection/v2alpha1/reflection.go +++ b/server/grpc/reflection/v2alpha1/reflection.go @@ -162,7 +162,7 @@ func newTxDescriptor(ir codectypes.InterfaceRegistry) (*TxDescriptor, error) { // get base tx type name txPbName := proto.MessageName(&tx.Tx{}) if txPbName == "" { - return nil, fmt.Errorf("unable to get *tx.Tx protobuf name") + return nil, errors.New("unable to get *tx.Tx protobuf name") } // get msgs sdkMsgImplementers := ir.ListImplementations(sdk.MsgInterfaceProtoName) diff --git a/server/util.go b/server/util.go index d84847ef2759..c23668341d43 100644 --- a/server/util.go +++ b/server/util.go @@ -25,7 +25,6 @@ import ( "golang.org/x/sync/errgroup" corectx "cosmossdk.io/core/context" - corelog "cosmossdk.io/core/log" "cosmossdk.io/log" "cosmossdk.io/store" "cosmossdk.io/store/snapshots" @@ -51,7 +50,7 @@ const ServerContextKey = sdk.ContextKey("server.context") type Context struct { Viper *viper.Viper Config *cmtcfg.Config - Logger corelog.Logger + Logger log.Logger } func NewDefaultContext() *Context { @@ -169,7 +168,7 @@ func InterceptConfigsAndCreateContext(cmd *cobra.Command, customAppConfigTemplat return serverCtx, nil } -// CreateSDKLogger creates a the default SDK logger. +// CreateSDKLogger creates the default SDK logger. // It reads the log level and format from the server context. func CreateSDKLogger(ctx *Context, out io.Writer) (log.Logger, error) { var opts []log.Option diff --git a/server/v2/api/grpc/flags.go b/server/v2/api/grpc/flags.go new file mode 100644 index 000000000000..be2f49cccd34 --- /dev/null +++ b/server/v2/api/grpc/flags.go @@ -0,0 +1,12 @@ +package grpc + +import "fmt" + +// start flags are prefixed with the server name +// as the config in prefixed with the server name +// this allows viper to properly bind the flags +func prefix(f string) string { + return fmt.Sprintf("%s.%s", ServerName, f) +} + +var FlagAddress = prefix("address") diff --git a/server/v2/api/grpc/gogoreflection/serverreflection.go b/server/v2/api/grpc/gogoreflection/serverreflection.go index 077c15c3321a..79f520545a87 100644 --- a/server/v2/api/grpc/gogoreflection/serverreflection.go +++ b/server/v2/api/grpc/gogoreflection/serverreflection.go @@ -42,33 +42,41 @@ import ( "errors" "fmt" "io" - "log" "reflect" "sort" + "strings" "sync" - //nolint: staticcheck // keep this import for backward compatibility - "github.com/golang/protobuf/proto" + gogoproto "github.com/cosmos/gogoproto/proto" dpb "github.com/golang/protobuf/protoc-gen-go/descriptor" "google.golang.org/grpc" "google.golang.org/grpc/codes" rpb "google.golang.org/grpc/reflection/grpc_reflection_v1alpha" "google.golang.org/grpc/status" + "google.golang.org/protobuf/reflect/protodesc" + "google.golang.org/protobuf/reflect/protoreflect" + + "cosmossdk.io/core/log" ) type serverReflectionServer struct { rpb.UnimplementedServerReflectionServer s *grpc.Server + methods []string + initSymbols sync.Once serviceNames []string symbols map[string]*dpb.FileDescriptorProto // map of fully-qualified names to files + log log.Logger } // Register registers the server reflection service on the given gRPC server. -func Register(s *grpc.Server) { +func Register(s *grpc.Server, methods []string, logger log.Logger) { rpb.RegisterServerReflectionServer(s, &serverReflectionServer{ - s: s, + s: s, + methods: methods, + log: logger, }) } @@ -82,21 +90,12 @@ type protoMessage interface { func (s *serverReflectionServer) getSymbols() (svcNames []string, symbolIndex map[string]*dpb.FileDescriptorProto) { s.initSymbols.Do(func() { - serviceInfo := s.s.GetServiceInfo() - s.symbols = map[string]*dpb.FileDescriptorProto{} - s.serviceNames = make([]string, 0, len(serviceInfo)) + services, fds := s.getServices(s.methods) + s.serviceNames = services + processed := map[string]struct{}{} - for svc, info := range serviceInfo { - s.serviceNames = append(s.serviceNames, svc) - fdenc, ok := parseMetadata(info.Metadata) - if !ok { - continue - } - fd, err := decodeFileDesc(fdenc) - if err != nil { - continue - } + for _, fd := range fds { s.processFile(fd, processed) } sort.Strings(s.serviceNames) @@ -207,7 +206,7 @@ func decodeFileDesc(enc []byte) (*dpb.FileDescriptorProto, error) { } fd := new(dpb.FileDescriptorProto) - if err := proto.Unmarshal(raw, fd); err != nil { + if err := gogoproto.Unmarshal(raw, fd); err != nil { return nil, fmt.Errorf("bad descriptor: %w", err) } return fd, nil @@ -237,7 +236,7 @@ func typeForName(name string) (reflect.Type, error) { } func fileDescContainingExtension(st reflect.Type, ext int32) (*dpb.FileDescriptorProto, error) { - m, ok := reflect.Zero(reflect.PtrTo(st)).Interface().(proto.Message) + m, ok := reflect.Zero(reflect.PtrTo(st)).Interface().(gogoproto.Message) if !ok { return nil, fmt.Errorf("failed to create message from type: %v", st) } @@ -252,7 +251,7 @@ func fileDescContainingExtension(st reflect.Type, ext int32) (*dpb.FileDescripto } func (s *serverReflectionServer) allExtensionNumbersForType(st reflect.Type) ([]int32, error) { - m, ok := reflect.Zero(reflect.PtrTo(st)).Interface().(proto.Message) + m, ok := reflect.Zero(reflect.PtrTo(st)).Interface().(gogoproto.Message) if !ok { return nil, fmt.Errorf("failed to create message from type: %v", st) } @@ -272,7 +271,7 @@ func fileDescWithDependencies(fd *dpb.FileDescriptorProto, sentFileDescriptors m queue = queue[1:] if sent := sentFileDescriptors[currentfd.GetName()]; len(r) == 0 || !sent { sentFileDescriptors[currentfd.GetName()] = true - currentfdEncoded, err := proto.Marshal(currentfd) + currentfdEncoded, err := gogoproto.Marshal(currentfd) if err != nil { return nil, err } @@ -305,24 +304,6 @@ func (s *serverReflectionServer) fileDescEncodingByFilename(name string, sentFil return fileDescWithDependencies(fd, sentFileDescriptors) } -// parseMetadata finds the file descriptor bytes specified meta. -// For SupportPackageIsVersion4, m is the name of the proto file, we -// call proto.FileDescriptor to get the byte slice. -// For SupportPackageIsVersion3, m is a byte slice itself. -func parseMetadata(meta interface{}) ([]byte, bool) { - // Check if meta is the file name. - if fileNameForMeta, ok := meta.(string); ok { - return getFileDescriptor(fileNameForMeta), true - } - - // Check if meta is the byte slice. - if enc, ok := meta.([]byte); ok { - return enc, true - } - - return nil, false -} - // fileDescEncodingContainingSymbol finds the file descriptor containing the // given symbol, finds all of its previously unsent transitive dependencies, // does marshaling on them, and returns the marshaled result. The given symbol @@ -446,7 +427,6 @@ func (s *serverReflectionServer) ServerReflectionInfo(stream rpb.ServerReflectio ErrorMessage: err.Error(), }, } - log.Printf("OH NO: %s", err) } else { out.MessageResponse = &rpb.ServerReflectionResponse_AllExtensionNumbersResponse{ AllExtensionNumbersResponse: &rpb.ExtensionNumberResponse{ //nolint:staticcheck // SA1019: we want to keep using v1alpha @@ -476,3 +456,28 @@ func (s *serverReflectionServer) ServerReflectionInfo(stream rpb.ServerReflectio } } } + +// getServices gets the unique list of services given a list of methods. +func (s *serverReflectionServer) getServices(methods []string) (svcs []string, fds []*dpb.FileDescriptorProto) { + registry, err := gogoproto.MergedRegistry() + if err != nil { + s.log.Error("unable to load merged registry", "err", err) + return nil, nil + } + seenSvc := map[protoreflect.FullName]struct{}{} + for _, methodName := range methods { + methodName = strings.Join(strings.Split(methodName[1:], "/"), ".") + md, err := registry.FindDescriptorByName(protoreflect.FullName(methodName)) + if err != nil { + s.log.Error("unable to load method descriptor", "method", methodName, "err", err) + continue + } + svc := md.(protoreflect.MethodDescriptor).Parent() + if _, seen := seenSvc[svc.FullName()]; !seen { + svcs = append(svcs, string(svc.FullName())) + file := svc.ParentFile() + fds = append(fds, protodesc.ToFileDescriptorProto(file)) + } + } + return +} diff --git a/server/v2/api/grpc/server.go b/server/v2/api/grpc/server.go index 7f73472a330f..5bce26508b02 100644 --- a/server/v2/api/grpc/server.go +++ b/server/v2/api/grpc/server.go @@ -2,11 +2,20 @@ package grpc import ( "context" + "errors" "fmt" + "io" "net" + "strconv" + "github.com/cosmos/gogoproto/proto" + "github.com/spf13/pflag" "github.com/spf13/viper" + "golang.org/x/exp/maps" "google.golang.org/grpc" + "google.golang.org/grpc/codes" + "google.golang.org/grpc/metadata" + "google.golang.org/grpc/status" "cosmossdk.io/core/transaction" "cosmossdk.io/log" @@ -14,7 +23,13 @@ import ( "cosmossdk.io/server/v2/api/grpc/gogoreflection" ) -type GRPCServer[T transaction.Tx] struct { +const ( + ServerName = "grpc" + + BlockHeightHeader = "x-cosmos-block-height" +) + +type Server[T transaction.Tx] struct { logger log.Logger config *Config cfgOptions []CfgOption @@ -23,32 +38,34 @@ type GRPCServer[T transaction.Tx] struct { } // New creates a new grpc server. -func New[T transaction.Tx](cfgOptions ...CfgOption) *GRPCServer[T] { - return &GRPCServer[T]{ +func New[T transaction.Tx](cfgOptions ...CfgOption) *Server[T] { + return &Server[T]{ cfgOptions: cfgOptions, } } // Init returns a correctly configured and initialized gRPC server. // Note, the caller is responsible for starting the server. -func (s *GRPCServer[T]) Init(appI serverv2.AppI[T], v *viper.Viper, logger log.Logger) error { +func (s *Server[T]) Init(appI serverv2.AppI[T], v *viper.Viper, logger log.Logger) error { cfg := s.Config().(*Config) if v != nil { - if err := v.Sub(s.Name()).Unmarshal(&cfg); err != nil { + if err := serverv2.UnmarshalSubConfig(v, s.Name(), &cfg); err != nil { return fmt.Errorf("failed to unmarshal config: %w", err) } } + methodsMap := appI.GetGPRCMethodsToMessageMap() grpcSrv := grpc.NewServer( grpc.ForceServerCodec(newProtoCodec(appI.InterfaceRegistry()).GRPCCodec()), grpc.MaxSendMsgSize(cfg.MaxSendMsgSize), grpc.MaxRecvMsgSize(cfg.MaxRecvMsgSize), + grpc.UnknownServiceHandler( + makeUnknownServiceHandler(methodsMap, appI.GetAppManager()), + ), ) - // appI.RegisterGRPCServer(grpcSrv) - // Reflection allows external clients to see what services and methods the gRPC server exposes. - gogoreflection.Register(grpcSrv) + gogoreflection.Register(grpcSrv, maps.Keys(methodsMap), logger.With("sub-module", "grpc-reflection")) s.grpcSrv = grpcSrv s.config = cfg @@ -57,11 +74,80 @@ func (s *GRPCServer[T]) Init(appI serverv2.AppI[T], v *viper.Viper, logger log.L return nil } -func (s *GRPCServer[T]) Name() string { - return "grpc" +func (s *Server[T]) StartCmdFlags() *pflag.FlagSet { + flags := pflag.NewFlagSet(s.Name(), pflag.ExitOnError) + flags.String(FlagAddress, "localhost:9090", "Listen address") + return flags +} + +func makeUnknownServiceHandler(messageMap map[string]func() proto.Message, querier interface { + Query(ctx context.Context, version uint64, msg proto.Message) (proto.Message, error) +}, +) grpc.StreamHandler { + return func(srv any, stream grpc.ServerStream) error { + method, ok := grpc.MethodFromServerStream(stream) + if !ok { + return status.Error(codes.InvalidArgument, "unable to get method") + } + makeMsg, exists := messageMap[method] + if !exists { + return status.Errorf(codes.Unimplemented, "gRPC method %s is not handled", method) + } + for { + req := makeMsg() + err := stream.RecvMsg(req) + if err != nil { + if errors.Is(err, io.EOF) { + return nil + } + return err + } + + // extract height header + ctx := stream.Context() + height, err := getHeightFromCtx(ctx) + if err != nil { + return status.Errorf(codes.InvalidArgument, "invalid get height from context: %v", err) + } + resp, err := querier.Query(ctx, height, req) + if err != nil { + return err + } + err = stream.SendMsg(resp) + if err != nil { + return err + } + } + } +} + +func getHeightFromCtx(ctx context.Context) (uint64, error) { + md, ok := metadata.FromIncomingContext(ctx) + if !ok { + return 0, nil + } + values := md.Get(BlockHeightHeader) + if len(values) == 0 { + return 0, nil + } + if len(values) != 1 { + return 0, fmt.Errorf("gRPC height metadata must be of length 1, got: %d", len(values)) + } + + heightStr := values[0] + height, err := strconv.ParseUint(heightStr, 10, 64) + if err != nil { + return 0, fmt.Errorf("unable to parse height string from gRPC metadata %s: %w", heightStr, err) + } + + return height, nil +} + +func (s *Server[T]) Name() string { + return ServerName } -func (s *GRPCServer[T]) Config() any { +func (s *Server[T]) Config() any { if s.config == nil || s.config == (&Config{}) { cfg := DefaultConfig() // overwrite the default config with the provided options @@ -75,7 +161,7 @@ func (s *GRPCServer[T]) Config() any { return s.config } -func (s *GRPCServer[T]) Start(ctx context.Context) error { +func (s *Server[T]) Start(ctx context.Context) error { if !s.config.Enable { return nil } @@ -102,7 +188,7 @@ func (s *GRPCServer[T]) Start(ctx context.Context) error { return err } -func (s *GRPCServer[T]) Stop(ctx context.Context) error { +func (s *Server[T]) Stop(ctx context.Context) error { if !s.config.Enable { return nil } diff --git a/server/v2/api/grpcgateway/server.go b/server/v2/api/grpcgateway/server.go index 7a5693f8c5be..028027a83a07 100644 --- a/server/v2/api/grpcgateway/server.go +++ b/server/v2/api/grpcgateway/server.go @@ -21,6 +21,8 @@ import ( var _ serverv2.ServerComponent[transaction.Tx] = (*GRPCGatewayServer[transaction.Tx])(nil) const ( + ServerName = "grpc-gateway" + // GRPCBlockHeightHeader is the gRPC header for block height. GRPCBlockHeightHeader = "x-cosmos-block-height" ) @@ -64,7 +66,7 @@ func New[T transaction.Tx](grpcSrv *grpc.Server, ir jsonpb.AnyResolver, cfgOptio } func (g *GRPCGatewayServer[T]) Name() string { - return "grpc-gateway" + return ServerName } func (s *GRPCGatewayServer[T]) Config() any { @@ -84,7 +86,7 @@ func (s *GRPCGatewayServer[T]) Config() any { func (s *GRPCGatewayServer[T]) Init(appI serverv2.AppI[transaction.Tx], v *viper.Viper, logger log.Logger) error { cfg := s.Config().(*Config) if v != nil { - if err := v.Sub(s.Name()).Unmarshal(&cfg); err != nil { + if err := serverv2.UnmarshalSubConfig(v, s.Name(), &cfg); err != nil { return fmt.Errorf("failed to unmarshal config: %w", err) } } diff --git a/server/v2/api/telemetry/metrics.go b/server/v2/api/telemetry/metrics.go index 78fe6388ca68..39055af6739b 100644 --- a/server/v2/api/telemetry/metrics.go +++ b/server/v2/api/telemetry/metrics.go @@ -3,6 +3,7 @@ package telemetry import ( "bytes" "encoding/json" + "errors" "fmt" "net/http" "time" @@ -145,7 +146,7 @@ func (m *Metrics) Gather(format string) (GatherResponse, error) { // If Prometheus metrics are not enabled, it returns an error. func (m *Metrics) gatherPrometheus() (GatherResponse, error) { if !m.prometheusEnabled { - return GatherResponse{}, fmt.Errorf("prometheus metrics are not enabled") + return GatherResponse{}, errors.New("prometheus metrics are not enabled") } metricsFamilies, err := prometheus.DefaultGatherer.Gather() @@ -171,7 +172,7 @@ func (m *Metrics) gatherPrometheus() (GatherResponse, error) { func (m *Metrics) gatherGeneric() (GatherResponse, error) { gm, ok := m.sink.(DisplayableSink) if !ok { - return GatherResponse{}, fmt.Errorf("non in-memory metrics sink does not support generic format") + return GatherResponse{}, errors.New("non in-memory metrics sink does not support generic format") } summary, err := gm.DisplayMetrics(nil, nil) diff --git a/server/v2/appmanager/appmanager.go b/server/v2/appmanager/appmanager.go index d9c84c5035d7..cef0fc57cce7 100644 --- a/server/v2/appmanager/appmanager.go +++ b/server/v2/appmanager/appmanager.go @@ -4,6 +4,7 @@ import ( "bytes" "context" "encoding/json" + "errors" "fmt" appmanager "cosmossdk.io/core/app" @@ -46,7 +47,7 @@ func (a AppManager[T]) InitGenesis( return nil, nil, fmt.Errorf("unable to get latest state: %w", err) } if v != 0 { // TODO: genesis state may be > 0, we need to set version on store - return nil, nil, fmt.Errorf("cannot init genesis on non-zero state") + return nil, nil, errors.New("cannot init genesis on non-zero state") } var genTxs []T diff --git a/server/v2/cometbft/abci.go b/server/v2/cometbft/abci.go index f63953b0c8d3..372886792ee7 100644 --- a/server/v2/cometbft/abci.go +++ b/server/v2/cometbft/abci.go @@ -14,10 +14,10 @@ import ( coreappmgr "cosmossdk.io/core/app" "cosmossdk.io/core/comet" "cosmossdk.io/core/event" - "cosmossdk.io/core/log" "cosmossdk.io/core/store" "cosmossdk.io/core/transaction" errorsmod "cosmossdk.io/errors" + "cosmossdk.io/log" "cosmossdk.io/server/v2/appmanager" "cosmossdk.io/server/v2/cometbft/client/grpc/cmtservice" "cosmossdk.io/server/v2/cometbft/handlers" @@ -32,18 +32,21 @@ import ( var _ abci.Application = (*Consensus[transaction.Tx])(nil) type Consensus[T transaction.Tx] struct { - // legacy support for gRPC - grpcQueryDecoders map[string]func(requestBytes []byte) (gogoproto.Message, error) - - app *appmanager.AppManager[T] - cfg Config - store types.Store - logger log.Logger - txCodec transaction.Codec[T] - streaming streaming.Manager - snapshotManager *snapshots.Manager - mempool mempool.Mempool[T] - + logger log.Logger + appName, version string + consensusAuthority string // Set by the application to grant authority to the consensus engine to send messages to the consensus module + app *appmanager.AppManager[T] + txCodec transaction.Codec[T] + store types.Store + streaming streaming.Manager + snapshotManager *snapshots.Manager + mempool mempool.Mempool[T] + + cfg Config + indexedEvents map[string]struct{} + chainID string + + initialHeight uint64 // this is only available after this node has committed a block (in FinalizeBlock), // otherwise it will be empty and we will need to query the app for the last // committed block. @@ -54,20 +57,29 @@ type Consensus[T transaction.Tx] struct { verifyVoteExt handlers.VerifyVoteExtensionhandler extendVote handlers.ExtendVoteHandler - chainID string + addrPeerFilter types.PeerFilter // filter peers by address and port + idPeerFilter types.PeerFilter // filter peers by node ID + + grpcMethodsMap map[string]func() gogoproto.Message // maps gRPC method to message creator func } func NewConsensus[T transaction.Tx]( + logger log.Logger, + appName string, + consensusAuthority string, app *appmanager.AppManager[T], mp mempool.Mempool[T], - grpcQueryDecoders map[string]func(requestBytes []byte) (gogoproto.Message, error), + indexedEvents map[string]struct{}, + gRPCMethodsMap map[string]func() gogoproto.Message, store types.Store, cfg Config, txCodec transaction.Codec[T], - logger log.Logger, ) *Consensus[T] { return &Consensus[T]{ - grpcQueryDecoders: grpcQueryDecoders, + appName: appName, + version: getCometBFTServerVersion(), + consensusAuthority: consensusAuthority, + grpcMethodsMap: gRPCMethodsMap, app: app, cfg: cfg, store: store, @@ -82,27 +94,24 @@ func NewConsensus[T transaction.Tx]( verifyVoteExt: nil, extendVote: nil, chainID: "", + indexedEvents: indexedEvents, + initialHeight: 0, } } +// SetStreamingManager sets the streaming manager for the consensus module. func (c *Consensus[T]) SetStreamingManager(sm streaming.Manager) { c.streaming = sm } -// SetSnapshotManager sets the snapshot manager for the Consensus. -// The snapshot manager is responsible for managing snapshots of the Consensus state. -// It allows for creating, storing, and restoring snapshots of the Consensus state. -// The provided snapshot manager will be used by the Consensus to handle snapshots. -func (c *Consensus[T]) SetSnapshotManager(sm *snapshots.Manager) { - c.snapshotManager = sm -} - -// RegisterExtensions registers the given extensions with the consensus module's snapshot manager. +// RegisterSnapshotExtensions registers the given extensions with the consensus module's snapshot manager. // It allows additional snapshotter implementations to be used for creating and restoring snapshots. -func (c *Consensus[T]) RegisterExtensions(extensions ...snapshots.ExtensionSnapshotter) { +func (c *Consensus[T]) RegisterSnapshotExtensions(extensions ...snapshots.ExtensionSnapshotter) error { if err := c.snapshotManager.RegisterExtensions(extensions...); err != nil { - panic(fmt.Errorf("failed to register snapshot extensions: %w", err)) + return fmt.Errorf("failed to register snapshot extensions: %w", err) } + + return nil } // CheckTx implements types.Application. @@ -122,7 +131,7 @@ func (c *Consensus[T]) CheckTx(ctx context.Context, req *abciproto.CheckTxReques Code: resp.Code, GasWanted: uint64ToInt64(resp.GasWanted), GasUsed: uint64ToInt64(resp.GasUsed), - Events: intoABCIEvents(resp.Events, c.cfg.IndexEvents), + Events: intoABCIEvents(resp.Events, c.indexedEvents), Info: resp.Info, Data: resp.Data, Log: resp.Log, @@ -144,7 +153,7 @@ func (c *Consensus[T]) Info(ctx context.Context, _ *abciproto.InfoRequest) (*abc // cp, err := c.GetConsensusParams(ctx) // if err != nil { - // return nil, err + // return nil, err // } cid, err := c.store.LastCommitID() @@ -153,10 +162,9 @@ func (c *Consensus[T]) Info(ctx context.Context, _ *abciproto.InfoRequest) (*abc } return &abciproto.InfoResponse{ - Data: c.cfg.Name, - Version: c.cfg.Version, - // AppVersion: cp.GetVersion().App, - AppVersion: 0, // TODO fetch from store? + Data: c.appName, + Version: c.version, + AppVersion: 0, // TODO fetch consensus params? LastBlockHeight: int64(version), LastBlockAppHash: cid.Hash, }, nil @@ -166,14 +174,14 @@ func (c *Consensus[T]) Info(ctx context.Context, _ *abciproto.InfoRequest) (*abc // It is called by cometbft to query application state. func (c *Consensus[T]) Query(ctx context.Context, req *abciproto.QueryRequest) (resp *abciproto.QueryResponse, err error) { // check if it's a gRPC method - grpcQueryDecoder, isGRPC := c.grpcQueryDecoders[req.Path] + makeGRPCRequest, isGRPC := c.grpcMethodsMap[req.Path] if isGRPC { - protoRequest, err := grpcQueryDecoder(req.Data) + protoRequest := makeGRPCRequest() + err = gogoproto.Unmarshal(req.Data, protoRequest) // TODO: use codec if err != nil { return nil, fmt.Errorf("unable to decode gRPC request with path %s from ABCI.Query: %w", req.Path, err) } res, err := c.app.Query(ctx, uint64(req.Height), protoRequest) - if err != nil { resp := queryResult(err) resp.Height = req.Height @@ -188,7 +196,7 @@ func (c *Consensus[T]) Query(ctx context.Context, req *abciproto.QueryRequest) ( // it must be an app/p2p/store query path := splitABCIQueryPath(req.Path) if len(path) == 0 { - return QueryResult(errorsmod.Wrap(cometerrors.ErrUnknownRequest, "no query path provided"), c.cfg.Trace), nil + return QueryResult(errorsmod.Wrap(cometerrors.ErrUnknownRequest, "no query path provided"), c.cfg.AppTomlConfig.Trace), nil } switch path[0] { @@ -202,11 +210,11 @@ func (c *Consensus[T]) Query(ctx context.Context, req *abciproto.QueryRequest) ( resp, err = c.handleQueryP2P(path) default: - resp = QueryResult(errorsmod.Wrap(cometerrors.ErrUnknownRequest, "unknown query path"), c.cfg.Trace) + resp = QueryResult(errorsmod.Wrap(cometerrors.ErrUnknownRequest, "unknown query path"), c.cfg.AppTomlConfig.Trace) } if err != nil { - return QueryResult(err, c.cfg.Trace), nil + return QueryResult(err, c.cfg.AppTomlConfig.Trace), nil } return resp, nil @@ -218,17 +226,17 @@ func (c *Consensus[T]) InitChain(ctx context.Context, req *abciproto.InitChainRe // store chainID to be used later on in execution c.chainID = req.ChainId - // TODO: check if we need to load the config from genesis.json or config.toml - c.cfg.InitialHeight = uint64(req.InitialHeight) - // On a new chain, we consider the init chain block height as 0, even though - // req.InitialHeight is 1 by default. - // TODO + // TODO: check if we need to load the config from genesis.json or config.toml + c.initialHeight = uint64(req.InitialHeight) + if c.initialHeight == 0 { // If initial height is 0, set it to 1 + c.initialHeight = 1 + } var consMessages []transaction.Msg if req.ConsensusParams != nil { consMessages = append(consMessages, &consensustypes.MsgUpdateParams{ - Authority: c.cfg.ConsensusAuthority, + Authority: c.consensusAuthority, Block: req.ConsensusParams.Block, Evidence: req.ConsensusParams.Evidence, Validator: req.ConsensusParams.Validator, @@ -307,7 +315,7 @@ func (c *Consensus[T]) PrepareProposal( } decodedTxs := make([]T, len(req.Txs)) - for _, tx := range req.Txs { + for i, tx := range req.Txs { decTx, err := c.txCodec.Decode(tx) if err != nil { // TODO: vote extension meta data as a custom type to avoid possibly accepting invalid txs @@ -315,7 +323,8 @@ func (c *Consensus[T]) PrepareProposal( c.logger.Error("failed to decode tx", "err", err) continue } - decodedTxs = append(decodedTxs, decTx) + + decodedTxs[i] = decTx } ciCtx := contextWithCometInfo(ctx, comet.Info{ @@ -392,26 +401,8 @@ func (c *Consensus[T]) FinalizeBlock( return nil, err } - // TODO evaluate this approach vs. service using context. - // cometInfo := &consensustypes.MsgUpdateCometInfo{ - // Authority: c.cfg.ConsensusAuthority, - // CometInfo: &consensustypes.CometInfo{ - // Evidence: req.Misbehavior, - // ValidatorsHash: req.NextValidatorsHash, - // ProposerAddress: req.ProposerAddress, - // LastCommit: req.DecidedLastCommit, - // }, - // } - // - // ctx = context.WithValue(ctx, corecontext.CometInfoKey, &comet.Info{ - // Evidence: sdktypes.ToSDKEvidence(req.Misbehavior), - // ValidatorsHash: req.NextValidatorsHash, - // ProposerAddress: req.ProposerAddress, - // LastCommit: sdktypes.ToSDKCommitInfo(req.DecidedLastCommit), - // }) - // we don't need to deliver the block in the genesis block - if req.Height == int64(c.cfg.InitialHeight) { + if req.Height == int64(c.initialHeight) { appHash, err := c.store.Commit(store.NewChangeset()) if err != nil { return nil, fmt.Errorf("unable to commit the changeset: %w", err) @@ -442,7 +433,6 @@ func (c *Consensus[T]) FinalizeBlock( AppHash: cid.Hash, ChainId: c.chainID, Txs: decodedTxs, - // ConsensusMessages: []transaction.Msg{cometInfo}, } ciCtx := contextWithCometInfo(ctx, comet.Info{ @@ -495,7 +485,7 @@ func (c *Consensus[T]) FinalizeBlock( return nil, err } - return finalizeBlockResponse(resp, cp, appHash, c.cfg.IndexEvents) + return finalizeBlockResponse(resp, cp, appHash, c.indexedEvents) } // Commit implements types.Application. @@ -537,7 +527,7 @@ func (c *Consensus[T]) VerifyVoteExtension( } if c.verifyVoteExt == nil { - return nil, fmt.Errorf("vote extensions are enabled but no verify function was set") + return nil, errors.New("vote extensions are enabled but no verify function was set") } _, latestStore, err := c.store.StateLatest() @@ -573,7 +563,7 @@ func (c *Consensus[T]) ExtendVote(ctx context.Context, req *abciproto.ExtendVote } if c.verifyVoteExt == nil { - return nil, fmt.Errorf("vote extensions are enabled but no verify function was set") + return nil, errors.New("vote extensions are enabled but no verify function was set") } _, latestStore, err := c.store.StateLatest() diff --git a/server/v2/cometbft/client/grpc/cmtservice/service.go b/server/v2/cometbft/client/grpc/cmtservice/service.go index 426b32aa45d4..2e1638eaa7a1 100644 --- a/server/v2/cometbft/client/grpc/cmtservice/service.go +++ b/server/v2/cometbft/client/grpc/cmtservice/service.go @@ -7,6 +7,7 @@ import ( abci "github.com/cometbft/cometbft/api/cometbft/abci/v1" coretypes "github.com/cometbft/cometbft/rpc/core/types" gogogrpc "github.com/cosmos/gogoproto/grpc" + gogoprotoany "github.com/cosmos/gogoproto/types/any" "github.com/grpc-ecosystem/grpc-gateway/runtime" "google.golang.org/grpc/codes" "google.golang.org/grpc/status" @@ -22,8 +23,8 @@ import ( ) var ( - _ ServiceServer = queryServer{} - _ codectypes.UnpackInterfacesMessage = &GetLatestValidatorSetResponse{} + _ ServiceServer = queryServer{} + _ gogoprotoany.UnpackInterfacesMessage = &GetLatestValidatorSetResponse{} ) const ( @@ -136,7 +137,7 @@ func (s queryServer) GetLatestValidatorSet( return ValidatorsOutput(ctx, s.client, nil, page, limit) } -func (m *GetLatestValidatorSetResponse) UnpackInterfaces(unpacker codectypes.AnyUnpacker) error { +func (m *GetLatestValidatorSetResponse) UnpackInterfaces(unpacker gogoprotoany.AnyUnpacker) error { var pubKey cryptotypes.PubKey for _, val := range m.Validators { err := unpacker.UnpackAny(val.PubKey, &pubKey) diff --git a/server/v2/cometbft/commands.go b/server/v2/cometbft/commands.go index 7c72cfe56ecc..26d13058952a 100644 --- a/server/v2/cometbft/commands.go +++ b/server/v2/cometbft/commands.go @@ -2,6 +2,7 @@ package cometbft import ( "encoding/json" + "errors" "fmt" "strconv" "strings" @@ -19,7 +20,6 @@ import ( "sigs.k8s.io/yaml" "cosmossdk.io/server/v2/cometbft/client/rpc" - auth "cosmossdk.io/x/auth/client/cli" "github.com/cosmos/cosmos-sdk/client" cryptocodec "github.com/cosmos/cosmos-sdk/crypto/codec" @@ -29,7 +29,7 @@ import ( ) func (s *CometBFTServer[T]) rpcClient(cmd *cobra.Command) (rpc.CometRPC, error) { - if s.config.Standalone { + if s.config.AppTomlConfig.Standalone { client, err := rpchttp.New(client.GetConfigFromCmd(cmd).RPC.ListenAddress) if err != nil { return nil, err @@ -201,10 +201,10 @@ for. Each module documents its respective events under 'xx_events.md'. return err } - query, _ := cmd.Flags().GetString(auth.FlagQuery) + query, _ := cmd.Flags().GetString(FlagQuery) page, _ := cmd.Flags().GetInt(FlagPage) limit, _ := cmd.Flags().GetInt(FlagLimit) - orderBy, _ := cmd.Flags().GetString(auth.FlagOrderBy) + orderBy, _ := cmd.Flags().GetString(FlagOrderBy) blocks, err := rpc.QueryBlocks(cmd.Context(), rpcclient, page, limit, query, orderBy) if err != nil { @@ -223,9 +223,9 @@ for. Each module documents its respective events under 'xx_events.md'. AddQueryFlagsToCmd(cmd) cmd.Flags().Int(FlagPage, query.DefaultPage, "Query a specific page of paginated results") cmd.Flags().Int(FlagLimit, query.DefaultLimit, "Query number of transactions results per page returned") - cmd.Flags().String(auth.FlagQuery, "", "The blocks events query per CometBFT's query semantics") - cmd.Flags().String(auth.FlagOrderBy, "", "The ordering semantics (asc|dsc)") - _ = cmd.MarkFlagRequired(auth.FlagQuery) + cmd.Flags().String(FlagQuery, "", "The blocks events query per CometBFT's query semantics") + cmd.Flags().String(FlagOrderBy, "", "The ordering semantics (asc|dsc)") + _ = cmd.MarkFlagRequired(FlagQuery) return cmd } @@ -240,11 +240,11 @@ func (s *CometBFTServer[T]) QueryBlockCmd() *cobra.Command { $ %s query block --%s=%s $ %s query block --%s=%s `, - version.AppName, auth.FlagType, auth.TypeHeight, - version.AppName, auth.FlagType, auth.TypeHash)), + version.AppName, FlagType, TypeHeight, + version.AppName, FlagType, TypeHash)), Args: cobra.ExactArgs(1), RunE: func(cmd *cobra.Command, args []string) error { - typ, _ := cmd.Flags().GetString(auth.FlagType) + typ, _ := cmd.Flags().GetString(FlagType) rpcclient, err := s.rpcClient(cmd) if err != nil { @@ -252,9 +252,9 @@ $ %s query block --%s=%s } switch typ { - case auth.TypeHeight: + case TypeHeight: if args[0] == "" { - return fmt.Errorf("argument should be a block height") + return errors.New("argument should be a block height") } // optional height @@ -282,10 +282,10 @@ $ %s query block --%s=%s return printOutput(cmd, bz) - case auth.TypeHash: + case TypeHash: if args[0] == "" { - return fmt.Errorf("argument should be a tx hash") + return errors.New("argument should be a tx hash") } // If hash is given, then query the tx by hash. @@ -306,13 +306,13 @@ $ %s query block --%s=%s return printOutput(cmd, bz) default: - return fmt.Errorf("unknown --%s value %s", auth.FlagType, typ) + return fmt.Errorf("unknown --%s value %s", FlagType, typ) } }, } AddQueryFlagsToCmd(cmd) - cmd.Flags().String(auth.FlagType, auth.TypeHash, fmt.Sprintf("The type to be used when querying tx, can be one of \"%s\", \"%s\"", auth.TypeHeight, auth.TypeHash)) + cmd.Flags().String(FlagType, TypeHash, fmt.Sprintf("The type to be used when querying tx, can be one of \"%s\", \"%s\"", TypeHeight, TypeHash)) return cmd } diff --git a/server/v2/cometbft/config.go b/server/v2/cometbft/config.go index e349cf6dc563..3f03e383c601 100644 --- a/server/v2/cometbft/config.go +++ b/server/v2/cometbft/config.go @@ -5,54 +5,62 @@ import ( "github.com/spf13/viper" serverv2 "cosmossdk.io/server/v2" - "cosmossdk.io/server/v2/cometbft/types" ) -// TODO REDO/VERIFY THIS +// Config is the configuration for the CometBFT application +type Config struct { + AppTomlConfig *AppTomlConfig + ConfigTomlConfig *cmtcfg.Config +} -func GetConfigFromViper(v *viper.Viper) *cmtcfg.Config { - conf := cmtcfg.DefaultConfig() - err := v.Unmarshal(conf) - rootDir := v.GetString(serverv2.FlagHome) - if err != nil { - return cmtcfg.DefaultConfig().SetRoot(rootDir) +func DefaultAppTomlConfig() *AppTomlConfig { + return &AppTomlConfig{ + MinRetainBlocks: 0, + IndexEvents: make([]string, 0), + HaltHeight: 0, + HaltTime: 0, + Address: "tcp://127.0.0.1:26658", + Transport: "socket", + Trace: false, + Standalone: false, } +} - return conf.SetRoot(rootDir) +type AppTomlConfig struct { + MinRetainBlocks uint64 `mapstructure:"min-retain-blocks" toml:"min-retain-blocks" comment:"min-retain-blocks defines the minimum block height offset from the current block being committed, such that all blocks past this offset are pruned from CometBFT. A value of 0 indicates that no blocks should be pruned."` + IndexEvents []string `mapstructure:"index-events" toml:"index-events" comment:"index-events defines the set of events in the form {eventType}.{attributeKey}, which informs CometBFT what to index. If empty, all events will be indexed."` + HaltHeight uint64 `mapstructure:"halt-height" toml:"halt-height" comment:"halt-height contains a non-zero block height at which a node will gracefully halt and shutdown that can be used to assist upgrades and testing."` + HaltTime uint64 `mapstructure:"halt-time" toml:"halt-time" comment:"halt-time contains a non-zero minimum block time (in Unix seconds) at which a node will gracefully halt and shutdown that can be used to assist upgrades and testing."` + Address string `mapstructure:"address" toml:"address" comment:"address defines the CometBFT RPC server address to bind to."` + Transport string `mapstructure:"transport" toml:"transport" comment:"transport defines the CometBFT RPC server transport protocol: socket, grpc"` + Trace bool `mapstructure:"trace" toml:"trace" comment:"trace enables the CometBFT RPC server to output trace information about its internal operations."` + Standalone bool `mapstructure:"standalone" toml:"standalone" comment:"standalone starts the application without the CometBFT node. The node should be started separately."` } -// Config is the configuration for the CometBFT application -type Config struct { - // app.toml config options - Name string `mapstructure:"name" toml:"name"` - Version string `mapstructure:"version" toml:"version"` - InitialHeight uint64 `mapstructure:"initial_height" toml:"initial_height"` - MinRetainBlocks uint64 `mapstructure:"min_retain_blocks" toml:"min_retain_blocks"` - IndexEvents map[string]struct{} `mapstructure:"index_events" toml:"index_events"` - HaltHeight uint64 `mapstructure:"halt_height" toml:"halt_height"` - HaltTime uint64 `mapstructure:"halt_time" toml:"halt_time"` - // end of app.toml config options - - AddrPeerFilter types.PeerFilter // filter peers by address and port - IdPeerFilter types.PeerFilter // filter peers by node ID - - Transport string `mapstructure:"transport" toml:"transport"` - Addr string `mapstructure:"addr" toml:"addr"` - Standalone bool `mapstructure:"standalone" toml:"standalone"` - Trace bool `mapstructure:"trace" toml:"trace"` - // Must be set by the application to grant authority to the consensus engine to send messages to the consensus module - ConsensusAuthority string - - // config.toml - CmtConfig *cmtcfg.Config +// CfgOption is a function that allows to overwrite the default server configuration. +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 + } +} + +// 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 + } } -// CmtCfgOption is a function that allows to overwrite the default server configuration. -type CmtCfgOption func(*cmtcfg.Config) +func getConfigTomlFromViper(v *viper.Viper) *cmtcfg.Config { + rootDir := v.GetString(serverv2.FlagHome) -// OverwriteDefaultCometConfig overwrites the default comet config with the new config. -func OverwriteDefaultCometConfig(newCfg *cmtcfg.Config) CmtCfgOption { - return func(cfg *cmtcfg.Config) { // nolint:staticcheck // We want to overwrite everything - cfg = newCfg // nolint:ineffassign,staticcheck // We want to overwrite everything + conf := cmtcfg.DefaultConfig() + if err := v.Unmarshal(conf); err != nil { + return cmtcfg.DefaultConfig().SetRoot(rootDir) } + + return conf.SetRoot(rootDir) } diff --git a/server/v2/cometbft/flags.go b/server/v2/cometbft/flags.go index fe1442edf6c5..55fa0a14e771 100644 --- a/server/v2/cometbft/flags.go +++ b/server/v2/cometbft/flags.go @@ -1,27 +1,16 @@ package cometbft -import "github.com/spf13/cobra" +import ( + "fmt" -const ( - FlagQuery = "query" - FlagType = "type" - FlagOrderBy = "order_by" -) - -const ( - FlagWithComet = "with-comet" - FlagAddress = "address" - FlagTransport = "transport" - FlagTraceStore = "trace-store" - FlagCPUProfile = "cpu-profile" - FlagMinGasPrices = "minimum-gas-prices" - FlagQueryGasLimit = "query-gas-limit" - FlagHaltHeight = "halt-height" - FlagHaltTime = "halt-time" - FlagTrace = "trace" + "github.com/spf13/cobra" ) +// Query flags const ( + FlagQuery = "query" + FlagType = "type" + FlagOrderBy = "order_by" FlagChainID = "chain-id" FlagNode = "node" FlagGRPC = "grpc-addr" @@ -30,6 +19,8 @@ const ( FlagPage = "page" FlagLimit = "limit" FlagOutput = "output" + TypeHash = "hash" + TypeHeight = "height" ) // List of supported output formats @@ -50,3 +41,20 @@ func AddQueryFlagsToCmd(cmd *cobra.Command) { // hence the flag should not be required for those commands _ = cmd.MarkFlagRequired(FlagChainID) } + +// start flags are prefixed with the server name +// as the config in prefixed with the server name +// this allows viper to properly bind the flags +func prefix(f string) string { + return fmt.Sprintf("%s.%s", ServerName, f) +} + +// Server flags +var ( + Standalone = prefix("standalone") + FlagAddress = prefix("address") + FlagTransport = prefix("transport") + FlagHaltHeight = prefix("halt-height") + FlagHaltTime = prefix("halt-time") + FlagTrace = prefix("trace") +) diff --git a/server/v2/cometbft/go.mod b/server/v2/cometbft/go.mod index 78e8545dcd26..ef9c06a6c679 100644 --- a/server/v2/cometbft/go.mod +++ b/server/v2/cometbft/go.mod @@ -6,8 +6,6 @@ replace ( cosmossdk.io/api => ../../../api cosmossdk.io/core => ../../../core cosmossdk.io/core/testing => ../../../core/testing - cosmossdk.io/depinject => ../../../depinject - cosmossdk.io/log => ../../../log cosmossdk.io/server/v2 => ../ cosmossdk.io/server/v2/appmanager => ../appmanager cosmossdk.io/store => ../../../store @@ -26,15 +24,15 @@ require ( cosmossdk.io/api v0.7.5 cosmossdk.io/core v0.12.1-0.20231114100755-569e3ff6a0d7 cosmossdk.io/errors v1.0.1 + cosmossdk.io/log v1.3.1 cosmossdk.io/server/v2 v2.0.0-00010101000000-000000000000 cosmossdk.io/server/v2/appmanager v0.0.0-00010101000000-000000000000 cosmossdk.io/store/v2 v2.0.0-00010101000000-000000000000 - cosmossdk.io/x/auth v0.0.0-00010101000000-000000000000 cosmossdk.io/x/consensus v0.0.0-00010101000000-000000000000 github.com/cometbft/cometbft v1.0.0-rc1 github.com/cometbft/cometbft/api v1.0.0-rc.1 github.com/cosmos/cosmos-proto v1.0.0-beta.5 - github.com/cosmos/cosmos-sdk v0.51.0 + github.com/cosmos/cosmos-sdk v0.53.0 github.com/cosmos/gogoproto v1.5.0 github.com/golang/protobuf v1.5.4 github.com/grpc-ecosystem/grpc-gateway v1.16.0 @@ -50,21 +48,18 @@ require ( require ( buf.build/gen/go/cosmos/gogo-proto/protocolbuffers/go v1.34.2-20240130113600-88ef6483f90f.2 // indirect cosmossdk.io/collections v0.4.0 // indirect - cosmossdk.io/core/testing v0.0.0-00010101000000-000000000000 // indirect - cosmossdk.io/depinject v1.0.0-alpha.4 // indirect - cosmossdk.io/log v1.3.1 // indirect + cosmossdk.io/depinject v1.0.0 // indirect + cosmossdk.io/errors/v2 v2.0.0-20240731132947-df72853b3ca5 // indirect cosmossdk.io/math v1.3.0 // indirect - cosmossdk.io/schema v0.1.1 // indirect cosmossdk.io/store v1.1.1-0.20240418092142-896cdf1971bc // indirect + cosmossdk.io/x/auth v0.0.0-00010101000000-000000000000 // indirect cosmossdk.io/x/bank v0.0.0-20240226161501-23359a0b6d91 // indirect cosmossdk.io/x/staking v0.0.0-00010101000000-000000000000 // indirect cosmossdk.io/x/tx v0.13.3 // indirect 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 - github.com/DataDog/datadog-go v4.8.3+incompatible // indirect github.com/DataDog/zstd v1.5.5 // indirect - github.com/Microsoft/go-winio v0.6.1 // indirect github.com/beorn7/perks v1.0.1 // indirect github.com/bgentry/speakeasy v0.2.0 // indirect github.com/btcsuite/btcd/btcec/v2 v2.3.3 // indirect @@ -79,8 +74,7 @@ require ( github.com/cosmos/cosmos-db v1.0.2 // indirect github.com/cosmos/crypto v0.1.2 // indirect github.com/cosmos/go-bip39 v1.0.0 // indirect - github.com/cosmos/gogogateway v1.2.0 // indirect - github.com/cosmos/iavl v1.2.0 // indirect + github.com/cosmos/iavl v1.2.1-0.20240725141113-7adc688cf179 // indirect github.com/cosmos/ics23/go v0.10.0 // indirect github.com/cosmos/ledger-cosmos-go v0.13.3 // indirect github.com/danieljoos/wincred v1.2.1 // indirect @@ -92,7 +86,6 @@ require ( github.com/dvsekhvalnov/jose2go v1.6.0 // indirect github.com/emicklei/dot v1.6.2 // indirect github.com/fatih/color v1.17.0 // indirect - github.com/felixge/httpsnoop v1.0.4 // indirect github.com/fsnotify/fsnotify v1.7.0 // indirect github.com/getsentry/sentry-go v0.27.0 // indirect github.com/go-kit/kit v0.13.0 // indirect @@ -100,7 +93,6 @@ require ( github.com/go-logfmt/logfmt v0.6.0 // indirect github.com/godbus/dbus v0.0.0-20190726142602-4481cbc300e2 // indirect github.com/gofrs/uuid v4.4.0+incompatible // indirect - github.com/gogo/googleapis v1.4.1 // indirect github.com/gogo/protobuf v1.3.2 // indirect github.com/golang/glog v1.2.0 // indirect github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect @@ -109,10 +101,7 @@ require ( github.com/google/flatbuffers v2.0.8+incompatible // indirect github.com/google/go-cmp v0.6.0 // indirect github.com/google/orderedcode v0.0.1 // indirect - github.com/gorilla/handlers v1.5.2 // indirect - github.com/gorilla/mux v1.8.1 // indirect github.com/gorilla/websocket v1.5.3 // indirect - github.com/grpc-ecosystem/go-grpc-middleware v1.4.0 // indirect github.com/gsterjov/go-libsecret v0.0.0-20161001094733-a6f4afe4910c // indirect github.com/hashicorp/go-hclog v1.6.3 // indirect github.com/hashicorp/go-immutable-radix v1.3.1 // indirect @@ -123,7 +112,6 @@ require ( github.com/hashicorp/hcl v1.0.0 // indirect github.com/hashicorp/yamux v0.1.1 // indirect github.com/hdevalence/ed25519consensus v0.2.0 // indirect - github.com/huandu/skiplist v1.2.0 // indirect github.com/iancoleman/strcase v0.3.0 // indirect github.com/inconshreveable/mousetrap v1.1.0 // indirect github.com/jmhodges/levigo v1.0.0 // indirect @@ -176,13 +164,11 @@ require ( go.uber.org/multierr v1.11.0 // indirect golang.org/x/crypto v0.25.0 // indirect golang.org/x/exp v0.0.0-20240531132922-fd00a4e0eefc // indirect - golang.org/x/mod v0.17.0 // indirect golang.org/x/net v0.27.0 // indirect golang.org/x/sync v0.7.0 // indirect golang.org/x/sys v0.22.0 // indirect golang.org/x/term v0.22.0 // indirect golang.org/x/text v0.16.0 // indirect - golang.org/x/tools v0.21.1-0.20240508182429-e35e4ccd0d2d // indirect google.golang.org/genproto v0.0.0-20240227224415-6ceb2ff114de // indirect google.golang.org/genproto/googleapis/rpc v0.0.0-20240709173604-40e1e62336c5 // indirect gopkg.in/ini.v1 v1.67.0 // indirect diff --git a/server/v2/cometbft/go.sum b/server/v2/cometbft/go.sum index c749a4e9d0d6..99756515738a 100644 --- a/server/v2/cometbft/go.sum +++ b/server/v2/cometbft/go.sum @@ -6,8 +6,14 @@ cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMT cloud.google.com/go v0.34.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= cosmossdk.io/collections v0.4.0 h1:PFmwj2W8szgpD5nOd8GWH6AbYNi1f2J6akWXJ7P5t9s= cosmossdk.io/collections v0.4.0/go.mod h1:oa5lUING2dP+gdDquow+QjlF45eL1t4TJDypgGd+tv0= +cosmossdk.io/depinject v1.0.0 h1:dQaTu6+O6askNXO06+jyeUAnF2/ssKwrrszP9t5q050= +cosmossdk.io/depinject v1.0.0/go.mod h1:zxK/h3HgHoA/eJVtiSsoaRaRA2D5U4cJ5thIG4ssbB8= cosmossdk.io/errors v1.0.1 h1:bzu+Kcr0kS/1DuPBtUFdWjzLqyUuCiyHjyJB6srBV/0= cosmossdk.io/errors v1.0.1/go.mod h1:MeelVSZThMi4bEakzhhhE/CKqVv3nOJDA25bIqRDu/U= +cosmossdk.io/errors/v2 v2.0.0-20240731132947-df72853b3ca5 h1:IQNdY2kB+k+1OM2DvqFG1+UgeU1JzZrWtwuWzI3ZfwA= +cosmossdk.io/errors/v2 v2.0.0-20240731132947-df72853b3ca5/go.mod h1:0CuYKkFHxc1vw2JC+t21THBCALJVROrWVR/3PQ1urpc= +cosmossdk.io/log v1.3.1 h1:UZx8nWIkfbbNEWusZqzAx3ZGvu54TZacWib3EzUYmGI= +cosmossdk.io/log v1.3.1/go.mod h1:2/dIomt8mKdk6vl3OWJcPk2be3pGOS8OQaLUM/3/tCM= cosmossdk.io/math v1.3.0 h1:RC+jryuKeytIiictDslBP9i1fhkVm6ZDmZEoNP316zE= cosmossdk.io/math v1.3.0/go.mod h1:vnRTxewy+M7BtXBNFybkuhSH4WfedVAAnERHgVFhp3k= cosmossdk.io/schema v0.1.1 h1:I0M6pgI7R10nq+/HCQfbO6BsGBZA8sQy+duR1Y3aKcA= @@ -39,7 +45,6 @@ github.com/alecthomas/template v0.0.0-20190718012654-fb15b899a751/go.mod h1:LOuy github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0= github.com/alecthomas/units v0.0.0-20190717042225-c3de453c63f4/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0= github.com/antihax/optional v1.0.0/go.mod h1:uupD/76wgC+ih3iEmQUL+0Ugr19nfwCT1kdvxnR2qWY= -github.com/benbjohnson/clock v1.1.0/go.mod h1:J11/hYXuz8f4ySSvYwY0FKfm+ezbsZBKZxNJlLklBHA= github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q= github.com/beorn7/perks v1.0.0/go.mod h1:KWe93zE9D1o94FZ5RNwFwVgaQK1VOXiVxmqh+CedLV8= github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM= @@ -67,12 +72,6 @@ github.com/circonus-labs/circonus-gometrics v2.3.1+incompatible/go.mod h1:nmEj6D github.com/circonus-labs/circonusllhist v0.1.3/go.mod h1:kMXHVDlOchFAehlya5ePtbp5jckzBHf4XRpQvBOLI+I= github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw= github.com/cncf/udpa/go v0.0.0-20191209042840-269d4d468f6f/go.mod h1:M8M6+tZqaGXZJjfX53e64911xZQV5JYwmTeXPW+k8Sc= -github.com/cncf/udpa/go v0.0.0-20201120205902-5459f2c99403/go.mod h1:WmhPx2Nbnhtbo57+VJT5O0JRkEi1Wbu0z5j0R8u5Hbk= -github.com/cncf/udpa/go v0.0.0-20210930031921-04548b0d99d4/go.mod h1:6pvJx4me5XPnfI9Z40ddWsdw2W/uZgQLFXToKeRcDiI= -github.com/cncf/xds/go v0.0.0-20210805033703-aa0b78936158/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs= -github.com/cncf/xds/go v0.0.0-20210922020428-25de7278fc84/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs= -github.com/cncf/xds/go v0.0.0-20211001041855-01bcc9b48dfe/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs= -github.com/cncf/xds/go v0.0.0-20211011173535-cb28da3451f1/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs= github.com/cockroachdb/datadriven v1.0.3-0.20230413201302-be42291fc80f h1:otljaYPt5hWxV3MUfO5dFPFiOXg9CyG5/kCfayTqsJ4= github.com/cockroachdb/datadriven v1.0.3-0.20230413201302-be42291fc80f/go.mod h1:a9RdTaap04u637JoCzcUoIcDmvwSUtcUFtT/C3kJlTU= github.com/cockroachdb/errors v1.11.1 h1:xSEW75zKaKCWzR3OfxXUxgrk/NtT4G1MiOv5lWZazG8= @@ -106,11 +105,10 @@ github.com/cosmos/go-bip39 v1.0.0 h1:pcomnQdrdH22njcAatO0yWojsUnCO3y2tNoV1cb6hHY github.com/cosmos/go-bip39 v1.0.0/go.mod h1:RNJv0H/pOIVgxw6KS7QeX2a0Uo0aKUlfhZ4xuwvCdJw= github.com/cosmos/gogogateway v1.2.0 h1:Ae/OivNhp8DqBi/sh2A8a1D0y638GpL3tkmLQAiKxTE= github.com/cosmos/gogogateway v1.2.0/go.mod h1:iQpLkGWxYcnCdz5iAdLcRBSw3h7NXeOkZ4GUkT+tbFI= -github.com/cosmos/gogoproto v1.4.2/go.mod h1:cLxOsn1ljAHSV527CHOtaIP91kK6cCrZETRBrkzItWU= github.com/cosmos/gogoproto v1.5.0 h1:SDVwzEqZDDBoslaeZg+dGE55hdzHfgUA40pEanMh52o= github.com/cosmos/gogoproto v1.5.0/go.mod h1:iUM31aofn3ymidYG6bUR5ZFrk+Om8p5s754eMUcyp8I= -github.com/cosmos/iavl v1.2.0 h1:kVxTmjTh4k0Dh1VNL046v6BXqKziqMDzxo93oh3kOfM= -github.com/cosmos/iavl v1.2.0/go.mod h1:HidWWLVAtODJqFD6Hbne2Y0q3SdxByJepHUOeoH4LiI= +github.com/cosmos/iavl v1.2.1-0.20240725141113-7adc688cf179 h1:wmwDn7V3RodN9auB3FooSQxs46nHVE3u0mb87TJkZFE= +github.com/cosmos/iavl v1.2.1-0.20240725141113-7adc688cf179/go.mod h1:GiM43q0pB+uG53mLxLDzimxM9l/5N9UuSY3/D0huuVw= github.com/cosmos/ics23/go v0.10.0 h1:iXqLLgp2Lp+EdpIuwXTYIQU+AiHj9mOC2X9ab++bZDM= github.com/cosmos/ics23/go v0.10.0/go.mod h1:ZfJSmng/TBNTBkFemHHHj5YY7VAU/MBU980F4VU1NG0= github.com/cosmos/ledger-cosmos-go v0.13.3 h1:7ehuBGuyIytsXbd4MP43mLeoN2LTOEnk5nvue4rK+yM= @@ -148,9 +146,6 @@ github.com/emicklei/dot v1.6.2/go.mod h1:DeV7GvQtIw4h2u73RKBkkFdvVAz0D9fzeJrgPW6 github.com/envoyproxy/go-control-plane v0.9.0/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= github.com/envoyproxy/go-control-plane v0.9.4/go.mod h1:6rpuAdCZL397s3pYoYcLgu1mIlRU8Am5FuJP05cCM98= -github.com/envoyproxy/go-control-plane v0.9.9-0.20201210154907-fd9021fe5dad/go.mod h1:cXg6YxExXjJnVBQHBLXeUAgxn2UodCpnH306RInaBQk= -github.com/envoyproxy/go-control-plane v0.9.10-0.20210907150352-cf90f659a021/go.mod h1:AFq3mo9L8Lqqiid3OhADV3RfLJnjiw63cSpi+fDTRC0= -github.com/envoyproxy/go-control-plane v0.10.2-0.20220325020618-49ff273808a1/go.mod h1:KJwIaB5Mv44NWtYuAOFCVOjcI94vtpEz2JU/D2v6IjE= github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c= github.com/fatih/color v1.13.0/go.mod h1:kLAiJbzzSOZDVNGyDpeOxJ47H46qBXwg5ILebYFFOfk= github.com/fatih/color v1.17.0 h1:GlRw1BRJxkpqUCBKzKOw098ed57fEsKeNjpTe3cSjK4= @@ -175,12 +170,10 @@ github.com/go-kit/kit v0.8.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2 github.com/go-kit/kit v0.9.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as= github.com/go-kit/kit v0.13.0 h1:OoneCcHKHQ03LfBpoQCUfCluwd2Vt3ohz+kvbJneZAU= github.com/go-kit/kit v0.13.0/go.mod h1:phqEHMMUbyrCFCTgH48JueqrM3md2HcAZ8N3XE4FKDg= -github.com/go-kit/log v0.1.0/go.mod h1:zbhenjAZHb184qTLMA9ZjW7ThYL0H2mk7Q6pNt4vbaY= github.com/go-kit/log v0.2.1 h1:MRVx0/zhvdseW+Gza6N9rVzU/IVzaeE1SFI4raAhmBU= github.com/go-kit/log v0.2.1/go.mod h1:NwTd00d/i8cPZ3xOwwiv2PO5MOcx78fFErGNcVmBjv0= github.com/go-logfmt/logfmt v0.3.0/go.mod h1:Qt1PoO58o5twSAckw1HlFXLmHsOX5/0LbT9GBnD5lWE= github.com/go-logfmt/logfmt v0.4.0/go.mod h1:3RMwSq7FuexP4Kalkev3ejPJsZTpXXBr9+V4qmtdjCk= -github.com/go-logfmt/logfmt v0.5.0/go.mod h1:wCYkCAKZfumFQihp8CzCvQ3paCTfi41vtzG1KdI/P7A= github.com/go-logfmt/logfmt v0.6.0 h1:wGYYu3uicYdqXVgoYbvnkrPVXkuLM1p1ifugDMEdRi4= github.com/go-logfmt/logfmt v0.6.0/go.mod h1:WYhtIu8zTZfxdn5+rREduYbwxfcBr/Vr6KEVveWlfTs= github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY= @@ -190,11 +183,9 @@ github.com/godbus/dbus v0.0.0-20190726142602-4481cbc300e2/go.mod h1:bBOAhwG1umN6 github.com/godbus/dbus/v5 v5.0.4/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA= github.com/gofrs/uuid v4.4.0+incompatible h1:3qXRTX8/NbyulANqlc0lchS1gqAVxRgsuW1YrTJupqA= github.com/gofrs/uuid v4.4.0+incompatible/go.mod h1:b2aQJv3Z4Fp6yNu3cdSllBxTCLRxnplIgP/c0N/04lM= -github.com/gogo/googleapis v1.4.1-0.20201022092350-68b0159b7869/go.mod h1:5YRNX2z1oM5gXdAkurHa942MDgEJyk02w4OecKY87+c= github.com/gogo/googleapis v1.4.1 h1:1Yx4Myt7BxzvUr5ldGSbwYiZG6t9wGBZ+8/fX3Wvtq0= github.com/gogo/googleapis v1.4.1/go.mod h1:2lpHqI5OcWCtVElxXnPt+s8oJvMpySlOyM6xDCrzib4= github.com/gogo/protobuf v1.1.1/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ= -github.com/gogo/protobuf v1.3.1/go.mod h1:SlYgWuQ5SjCEi6WLHjHCa1yvBfUnHcTbrrZtXPKa29o= github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q= github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q= github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q= @@ -236,7 +227,6 @@ github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/ github.com/google/go-cmp v0.5.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.3/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= -github.com/google/go-cmp v0.5.6/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI= github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= @@ -286,8 +276,6 @@ github.com/hashicorp/yamux v0.1.1/go.mod h1:CtWFDAQgb7dxtzFs4tWbplKIe2jSi3+5vKbg github.com/hdevalence/ed25519consensus v0.2.0 h1:37ICyZqdyj0lAZ8P4D1d1id3HqbbG1N3iBb1Tb4rdcU= github.com/hdevalence/ed25519consensus v0.2.0/go.mod h1:w3BHWjwJbFU29IRHL1Iqkw3sus+7FctEyM4RqDxYNzo= github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU= -github.com/huandu/go-assert v1.1.5 h1:fjemmA7sSfYHJD7CUqs9qTwwfdNAx7/j2/ZlHXzNB3c= -github.com/huandu/go-assert v1.1.5/go.mod h1:yOLvuqZwmcHIC5rIzrBhT7D3Q9c3GFnd0JrPVhn/06U= github.com/huandu/skiplist v1.2.0 h1:gox56QD77HzSC0w+Ws3MH3iie755GBJU1OER3h5VsYw= github.com/huandu/skiplist v1.2.0/go.mod h1:7v3iFjLcSAzO4fN5B8dvebvo/qsfumiLiDXMrPiHF9w= github.com/iancoleman/strcase v0.3.0 h1:nTXanmYxhfFAMjZL34Ov6gkzEsSJZ5DbhxWjvSASxEI= @@ -302,7 +290,6 @@ github.com/jmhodges/levigo v1.0.0/go.mod h1:Q6Qx+uH3RAqyK4rFQroq9RL7mdkABMcfhEI+ github.com/json-iterator/go v1.1.6/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCVDaaPEHmU= github.com/json-iterator/go v1.1.9/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4= github.com/julienschmidt/httprouter v1.2.0/go.mod h1:SYymIcj16QtmaHHD7aYtjjsJG7VTCxuUUipMqKk8s4w= -github.com/kisielk/errcheck v1.2.0/go.mod h1:/BMXB+zMLi60iA8Vv6Ksmxu/1UDYcXs4uQLJ+jE2L00= github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8= github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= github.com/klauspost/compress v1.17.8 h1:YcnTYrq7MikUT7k0Yb5eceMmALQPYBW/Xltxn0NAMnU= @@ -376,7 +363,6 @@ github.com/opencontainers/image-spec v1.1.0-rc5 h1:Ygwkfw9bpDvs+c9E34SdgGOj41dX/ github.com/opencontainers/image-spec v1.1.0-rc5/go.mod h1:X4pATf0uXsnn3g5aiGIsVnJBR4mxhKzfwmvK/B2NTm8= github.com/opencontainers/runc v1.1.12 h1:BOIssBaW1La0/qbNZHXOOa71dZfZEQOzW7dqQf3phss= github.com/opencontainers/runc v1.1.12/go.mod h1:S+lQwSfncpBha7XTy/5lBwWgm5+y5Ma/O44Ekby9FK8= -github.com/opentracing/opentracing-go v1.1.0/go.mod h1:UkNAQd3GIcIGf0SeVgPpRdFStlNbqXla1AfSYxPUl2o= github.com/ory/dockertest v3.3.5+incompatible h1:iLLK6SQwIhcbrG783Dghaaa3WPzGc+4Emza6EbVUUGA= github.com/ory/dockertest v3.3.5+incompatible/go.mod h1:1vX4m9wsvi00u5bseYwXaSnhNrne+V0E6LAcBILJdPs= github.com/pascaldekloe/goe v0.1.0 h1:cBOtyMzM9HTpWjXfbbunk26uA6nG3a8n06Wieeh0MwY= @@ -461,7 +447,6 @@ github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UV github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA= github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= -github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.7.2/go.mod h1:R6va5+xMeoiuVRoj+gSkQ7d3FALtqAAGI1FQKckRals= github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= @@ -494,13 +479,8 @@ go.etcd.io/bbolt v1.4.0-alpha.0.0.20240404170359-43604f3112c5 h1:qxen9oVGzDdIRP6 go.etcd.io/bbolt v1.4.0-alpha.0.0.20240404170359-43604f3112c5/go.mod h1:eW0HG9/oHQhvRCvb1/pIXW4cOvtDqeQK+XSi3TnwaXY= go.opencensus.io v0.24.0 h1:y73uSU6J157QMP2kn2r30vwW1A2W2WFwSCGnAVxeaD0= go.opencensus.io v0.24.0/go.mod h1:vNK8G9p7aAivkbmorf4v+7Hgx+Zs0yY+0fOtgBfjQKo= -go.opentelemetry.io/proto/otlp v0.7.0/go.mod h1:PqfVotwruBrMGOCsRd/89rSnXhoiJIqeYNgFYFoEGnI= -go.uber.org/atomic v1.7.0/go.mod h1:fEN4uk6kAWBTFdckzkM89CLk9XfWZrxpCo0nPH17wJc= -go.uber.org/goleak v1.1.10/go.mod h1:8a7PlsEVH3e/a/GLqe5IIrQx6GzcnRmZEufDUTk4A7A= -go.uber.org/multierr v1.6.0/go.mod h1:cdWPpRnG4AhwMwsgIHip0KRBQjJy5kYEpYjJxpXp9iU= go.uber.org/multierr v1.11.0 h1:blXXJkSxSSfBVBlC76pxqeO+LN3aDfLQo+309xJstO0= go.uber.org/multierr v1.11.0/go.mod h1:20+QtiLqy0Nd6FdQB9TLXag12DsQkrbs3htMFfDN80Y= -go.uber.org/zap v1.18.1/go.mod h1:xg/QME4nWcxGxrpdeYfq7UvYrLh66cuVKdrbD1XF/NI= golang.org/x/crypto v0.0.0-20180904163835-0709b304e793/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= @@ -514,7 +494,6 @@ golang.org/x/exp v0.0.0-20240531132922-fd00a4e0eefc/go.mod h1:XtvwrStGgqGPLc4cjQ golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= golang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961/go.mod h1:wehouNa3lNwaWXcvxsM5YxQ5yQlVC4a0KAMCusXpPoU= golang.org/x/lint v0.0.0-20190313153728-d0100b6bd8b3/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= -golang.org/x/lint v0.0.0-20190930215403-16217165b5de/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.17.0 h1:zY54UmvipHiNd+pm+m0x9KhZ9hl1/7QNMyxXbc6ICqA= @@ -534,7 +513,6 @@ golang.org/x/net v0.0.0-20200520004742-59133d7f0dd7/go.mod h1:qpuaurCH72eLCgpAm/ golang.org/x/net v0.0.0-20200822124328-c89045814202/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= golang.org/x/net v0.0.0-20201110031124-69a78807bb2b/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= -golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4/go.mod h1:p54w0d4576C0XHj96bSt6lcn1PtDYWL6XObtHCRCNQM= golang.org/x/net v0.0.0-20210428140749-89ef3d95e781/go.mod h1:OJAsFXCWl8Ukc7SiCT/9KSuxbyM7479/AVlXFRxuMCk= golang.org/x/net v0.0.0-20220225172249-27dd8689420f/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk= golang.org/x/net v0.0.0-20220607020251-c690dde0001d/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c= @@ -570,16 +548,11 @@ golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210112080510-489259a85091/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20210119212857-b64e53b001e4/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20210330210617-4fbd30eecc44/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20210510120138-977fb7262007/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210927094055-39ccf1dd6fa6/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20211025201205-69cdffdb9359/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20220315194320-039c03cc5b86/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220412211240-33da011f77ad/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220503163025-988cb79eb6c6/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= @@ -595,18 +568,15 @@ golang.org/x/term v0.22.0 h1:BbsgPEJULsl2fV/AT3v15Mjva5yXKQDyKf+TbDz7QJk= golang.org/x/term v0.22.0/go.mod h1:F3qCibpT5AMpCRfhfT53vVJwhLtIVHhB9XDjfFvnMI4= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= -golang.org/x/text v0.3.5/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= golang.org/x/text v0.16.0 h1:a94ExnEXNtEwYLGJSIUxnWoxoRz/ZcCsV63ROupILh4= golang.org/x/text v0.16.0/go.mod h1:GhwF1Be+LQoKShO3cGOHzqOgRrGaYc9AvblQOmPVHnI= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= -golang.org/x/tools v0.0.0-20181030221726-6c7e314b6563/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20190226205152-f727befe758c/go.mod h1:9Yl7xja0Znq3iFh3HoIrodX9oNMXvdceNzlUR8zjMvY= golang.org/x/tools v0.0.0-20190311212946-11955173bddd/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= golang.org/x/tools v0.0.0-20190524140312-2c0ae7006135/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q= -golang.org/x/tools v0.0.0-20191108193012-7d206e10da11/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.0.0-20200619180055-7c47624df98f/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= golang.org/x/tools v0.0.0-20201224043029-2b0845dc783e/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= @@ -623,10 +593,8 @@ google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7 google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc= google.golang.org/genproto v0.0.0-20180831171423-11092d34479b/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc= google.golang.org/genproto v0.0.0-20190819201941-24fa4b261c55/go.mod h1:DMBHOl98Agz4BDEuKkezgsaosCRResVns1a3J2ZsMNc= -google.golang.org/genproto v0.0.0-20200423170343-7949de9c1215/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= google.golang.org/genproto v0.0.0-20200513103714-09dca8ec2884/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= google.golang.org/genproto v0.0.0-20200526211855-cb27e3aa2013/go.mod h1:NbSheEEYHJ7i3ixzK3sjbqSGDJWnxyFXZblF3eUsNvo= -google.golang.org/genproto v0.0.0-20220314164441-57ef72a4c106/go.mod h1:hAL49I2IFola2sVEjAn7MEwsja0xp51I0tlGAf9hz4E= google.golang.org/genproto v0.0.0-20240227224415-6ceb2ff114de h1:F6qOa9AZTYJXOUEr4jDysRDLrm4PHePlge4v4TGAlxY= google.golang.org/genproto v0.0.0-20240227224415-6ceb2ff114de/go.mod h1:VUhTRKeHn9wwcdrk73nvdC9gF178Tzhmt/qyaFcPLSo= google.golang.org/genproto/googleapis/api v0.0.0-20240318140521-94a12d6c2237 h1:RFiFrvy37/mpSpdySBDrUdipW/dHwsRwh3J3+A9VgT4= @@ -637,12 +605,8 @@ google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZi google.golang.org/grpc v1.23.0/go.mod h1:Y5yQAOtifL1yxbo5wqy6BxZv8vAUGQwXBOALyacEbxg= google.golang.org/grpc v1.25.1/go.mod h1:c3i+UQWmh7LiEpx4sFZnkU36qjEYZ0imhYfXVyQciAY= google.golang.org/grpc v1.27.0/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk= -google.golang.org/grpc v1.29.1/go.mod h1:itym6AZVZYACWQqET3MqgPpjcuV5QH3BxFS3IjizoKk= google.golang.org/grpc v1.33.1/go.mod h1:fr5YgcSWrqhRRxogOsw7RzIpsmvOZ6IcH4kBYTpR3n0= google.golang.org/grpc v1.33.2/go.mod h1:JMHMWHQWaTccqQQlmk3MJZS+GWXOdAesneDmEnv2fbc= -google.golang.org/grpc v1.36.0/go.mod h1:qjiiYl8FncCW8feJPdyg3v6XW24KsRHe+dy9BAGRRjU= -google.golang.org/grpc v1.45.0/go.mod h1:lN7owxKUQEqMfSyQikvvk5tf/6zMPsrK+ONuO11+0rQ= -google.golang.org/grpc v1.49.0/go.mod h1:ZgQEeidpAuNRZ8iRrlBKXZQP1ghovWIVhdJRyCDK+GI= google.golang.org/grpc v1.64.1 h1:LKtvyfbX3UGVPFcGqJ9ItpVWW6oN/2XqTxfAnwRRXiA= google.golang.org/grpc v1.64.1/go.mod h1:hiQF4LFZelK2WKaP6W0L92zGHtiQdZxk8CrSdvyjeP0= google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8= @@ -656,13 +620,10 @@ google.golang.org/protobuf v1.23.1-0.20200526195155-81db48ad09cc/go.mod h1:EGpAD google.golang.org/protobuf v1.25.0/go.mod h1:9JNX74DMeImyA3h4bdi1ymwjUzf21/xIlbajtzgsN7c= google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw= google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= -google.golang.org/protobuf v1.27.1/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= -google.golang.org/protobuf v1.28.1/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= google.golang.org/protobuf v1.34.2 h1:6xV6lTsCfpGD21XK49h7MhtcApnLqkfYgPcdHftf6hg= google.golang.org/protobuf v1.34.2/go.mod h1:qYOHts0dSfpeUzUFpOMr/WGzszTmLH+DiWniOlNbLDw= gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= -gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20200902074654-038fdea0a05b/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk= @@ -677,11 +638,9 @@ gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.2.3/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.2.5/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= -gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.3.0/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ= gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= -gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gotest.tools/v3 v3.5.1 h1:EENdUnS3pdur5nybKYIh2Vfgc8IUNBjxDPSjtiJcOzU= diff --git a/server/v2/cometbft/handlers/defaults.go b/server/v2/cometbft/handlers/defaults.go index f7e32f64fa45..c16064974b1f 100644 --- a/server/v2/cometbft/handlers/defaults.go +++ b/server/v2/cometbft/handlers/defaults.go @@ -140,7 +140,7 @@ func (h *DefaultProposalHandler[T]) ProcessHandler() ProcessHandler[T] { if maxBlockGas > 0 { gaslimit, err := tx.GetGasLimit() if err != nil { - return fmt.Errorf("failed to get gas limit") + return errors.New("failed to get gas limit") } totalTxGas += gaslimit if totalTxGas > maxBlockGas { diff --git a/server/v2/cometbft/log/logger.go b/server/v2/cometbft/log/logger.go index 94f5d944e3ad..6ad7fdd8883e 100644 --- a/server/v2/cometbft/log/logger.go +++ b/server/v2/cometbft/log/logger.go @@ -3,7 +3,7 @@ package log import ( cmtlog "github.com/cometbft/cometbft/libs/log" - "cosmossdk.io/core/log" + "cosmossdk.io/log" ) var _ cmtlog.Logger = (*CometLoggerWrapper)(nil) diff --git a/server/v2/cometbft/options.go b/server/v2/cometbft/options.go index 0950609f7da9..1e0a389882e0 100644 --- a/server/v2/cometbft/options.go +++ b/server/v2/cometbft/options.go @@ -4,6 +4,7 @@ import ( "cosmossdk.io/core/transaction" "cosmossdk.io/server/v2/cometbft/handlers" "cosmossdk.io/server/v2/cometbft/mempool" + "cosmossdk.io/server/v2/cometbft/types" "cosmossdk.io/store/v2/snapshots" ) @@ -16,6 +17,9 @@ type ServerOptions[T transaction.Tx] struct { ExtendVoteHandler handlers.ExtendVoteHandler SnapshotOptions snapshots.SnapshotOptions + + AddrPeerFilter types.PeerFilter // filter peers by address and port + IdPeerFilter types.PeerFilter // filter peers by node ID } // DefaultServerOptions returns the default server options. @@ -28,5 +32,7 @@ func DefaultServerOptions[T transaction.Tx]() ServerOptions[T] { VerifyVoteExtensionHandler: handlers.NoOpVerifyVoteExtensionHandler(), ExtendVoteHandler: handlers.NoOpExtendVote(), SnapshotOptions: snapshots.NewSnapshotOptions(0, 0), + AddrPeerFilter: nil, + IdPeerFilter: nil, } } diff --git a/server/v2/cometbft/query.go b/server/v2/cometbft/query.go index d45c97cd078b..912338ff79f3 100644 --- a/server/v2/cometbft/query.go +++ b/server/v2/cometbft/query.go @@ -20,13 +20,14 @@ func (c *Consensus[T]) handleQueryP2P(path []string) (*abci.QueryResponse, error cmd, typ, arg := path[1], path[2], path[3] if cmd == "filter" { - if typ == "addr" { - if c.cfg.AddrPeerFilter != nil { - return c.cfg.AddrPeerFilter(arg) + switch typ { + case "addr": + if c.addrPeerFilter != nil { + return c.addrPeerFilter(arg) } - } else if typ == "id" { - if c.cfg.IdPeerFilter != nil { - return c.cfg.IdPeerFilter(arg) + case "id": + if c.idPeerFilter != nil { + return c.idPeerFilter(arg) } } } @@ -61,7 +62,7 @@ func (c *Consensus[T]) handlerQueryApp(ctx context.Context, path []string, req * return nil, errorsmod.Wrap(err, "failed to simulate tx") } - bz, err := intoABCISimulationResponse(txResult, c.cfg.IndexEvents) + bz, err := intoABCISimulationResponse(txResult, c.indexedEvents) if err != nil { return nil, errorsmod.Wrap(err, "failed to marshal txResult") } @@ -75,7 +76,7 @@ func (c *Consensus[T]) handlerQueryApp(ctx context.Context, path []string, req * case "version": return &abci.QueryResponse{ Codespace: cometerrors.RootCodespace, - Value: []byte(c.cfg.Version), + Value: []byte(c.version), Height: req.Height, }, nil } diff --git a/server/v2/cometbft/server.go b/server/v2/cometbft/server.go index 9b84a776400c..c85a241566e2 100644 --- a/server/v2/cometbft/server.go +++ b/server/v2/cometbft/server.go @@ -18,9 +18,8 @@ import ( "github.com/spf13/pflag" "github.com/spf13/viper" - corectx "cosmossdk.io/core/context" - "cosmossdk.io/core/log" "cosmossdk.io/core/transaction" + "cosmossdk.io/log" serverv2 "cosmossdk.io/server/v2" cometlog "cosmossdk.io/server/v2/cometbft/log" "cosmossdk.io/server/v2/cometbft/types" @@ -29,6 +28,8 @@ import ( genutiltypes "github.com/cosmos/cosmos-sdk/x/genutil/types" ) +const ServerName = "comet" + var ( _ serverv2.ServerComponent[transaction.Tx] = (*CometBFTServer[transaction.Tx])(nil) _ serverv2.HasCLICommands = (*CometBFTServer[transaction.Tx])(nil) @@ -39,61 +40,82 @@ type CometBFTServer[T transaction.Tx] struct { Node *node.Node Consensus *Consensus[T] - initTxCodec transaction.Codec[T] - logger log.Logger - config Config - options ServerOptions[T] - cmtConfigOptions []CmtCfgOption + initTxCodec transaction.Codec[T] + logger log.Logger + serverOptions ServerOptions[T] + config Config + cfgOptions []CfgOption } -func New[T transaction.Tx](txCodec transaction.Codec[T], options ServerOptions[T], cfgOptions ...CmtCfgOption) *CometBFTServer[T] { +func New[T transaction.Tx](txCodec transaction.Codec[T], serverOptions ServerOptions[T], cfgOptions ...CfgOption) *CometBFTServer[T] { return &CometBFTServer[T]{ - initTxCodec: txCodec, - options: options, - cmtConfigOptions: cfgOptions, + initTxCodec: txCodec, + serverOptions: serverOptions, + cfgOptions: cfgOptions, } } func (s *CometBFTServer[T]) Init(appI serverv2.AppI[T], v *viper.Viper, logger log.Logger) error { - s.config = Config{CmtConfig: GetConfigFromViper(v), ConsensusAuthority: appI.GetConsensusAuthority()} - s.logger = logger.With(log.ModuleKey, s.Name()) + // get configs (app.toml + config.toml) from viper + appTomlConfig := s.Config().(*AppTomlConfig) + if v != nil { + if err := serverv2.UnmarshalSubConfig(v, s.Name(), &appTomlConfig); err != nil { + return fmt.Errorf("failed to unmarshal config: %w", err) + } + } + s.config = Config{ + ConfigTomlConfig: getConfigTomlFromViper(v), + AppTomlConfig: appTomlConfig, + } - // create consensus - store := appI.GetStore().(types.Store) - consensus := NewConsensus[T](appI.GetAppManager(), s.options.Mempool, appI.GetGRPCQueryDecoders(), store, s.config, s.initTxCodec, s.logger) + indexEvents := make(map[string]struct{}, len(s.config.AppTomlConfig.IndexEvents)) + for _, e := range s.config.AppTomlConfig.IndexEvents { + indexEvents[e] = struct{}{} + } - consensus.prepareProposalHandler = s.options.PrepareProposalHandler - consensus.processProposalHandler = s.options.ProcessProposalHandler - consensus.verifyVoteExt = s.options.VerifyVoteExtensionHandler - consensus.extendVote = s.options.ExtendVoteHandler + s.logger = logger.With(log.ModuleKey, s.Name()) + store := appI.GetStore().(types.Store) + consensus := NewConsensus( + s.logger, + appI.Name(), + appI.GetConsensusAuthority(), + appI.GetAppManager(), + s.serverOptions.Mempool, + indexEvents, + appI.GetGPRCMethodsToMessageMap(), + store, + s.config, + s.initTxCodec, + ) + consensus.prepareProposalHandler = s.serverOptions.PrepareProposalHandler + consensus.processProposalHandler = s.serverOptions.ProcessProposalHandler + consensus.verifyVoteExt = s.serverOptions.VerifyVoteExtensionHandler + consensus.extendVote = s.serverOptions.ExtendVoteHandler + consensus.addrPeerFilter = s.serverOptions.AddrPeerFilter + consensus.idPeerFilter = s.serverOptions.IdPeerFilter - // TODO: set these; what is the appropriate presence of the Store interface here? - var ss snapshots.StorageSnapshotter - var sc snapshots.CommitSnapshotter + ss := store.GetStateStorage().(snapshots.StorageSnapshotter) + sc := store.GetStateCommitment().(snapshots.CommitSnapshotter) - snapshotStore, err := GetSnapshotStore(s.config.CmtConfig.RootDir) + snapshotStore, err := GetSnapshotStore(s.config.ConfigTomlConfig.RootDir) if err != nil { return err } - - sm := snapshots.NewManager(snapshotStore, s.options.SnapshotOptions, sc, ss, nil, s.logger) - consensus.SetSnapshotManager(sm) + consensus.snapshotManager = snapshots.NewManager(snapshotStore, s.serverOptions.SnapshotOptions, sc, ss, nil, s.logger) s.Consensus = consensus + return nil } func (s *CometBFTServer[T]) Name() string { - return "comet" + return ServerName } func (s *CometBFTServer[T]) Start(ctx context.Context) error { - viper := ctx.Value(corectx.ViperContextKey).(*viper.Viper) - cometConfig := GetConfigFromViper(viper) - wrappedLogger := cometlog.CometLoggerWrapper{Logger: s.logger} - if s.config.Standalone { - svr, err := abciserver.NewServer(s.config.Addr, s.config.Transport, s.Consensus) + if s.config.AppTomlConfig.Standalone { + svr, err := abciserver.NewServer(s.config.AppTomlConfig.Address, s.config.AppTomlConfig.Transport, s.Consensus) if err != nil { return fmt.Errorf("error creating listener: %w", err) } @@ -103,20 +125,20 @@ func (s *CometBFTServer[T]) Start(ctx context.Context) error { return svr.Start() } - nodeKey, err := p2p.LoadOrGenNodeKey(cometConfig.NodeKeyFile()) + nodeKey, err := p2p.LoadOrGenNodeKey(s.config.ConfigTomlConfig.NodeKeyFile()) if err != nil { return err } s.Node, err = node.NewNode( ctx, - cometConfig, - pvm.LoadOrGenFilePV(cometConfig.PrivValidatorKeyFile(), cometConfig.PrivValidatorStateFile()), + s.config.ConfigTomlConfig, + pvm.LoadOrGenFilePV(s.config.ConfigTomlConfig.PrivValidatorKeyFile(), s.config.ConfigTomlConfig.PrivValidatorStateFile()), nodeKey, proxy.NewConsensusSyncLocalClientCreator(s.Consensus), - getGenDocProvider(cometConfig), + getGenDocProvider(s.config.ConfigTomlConfig), cmtcfg.DefaultDBProvider, - node.DefaultMetricsProvider(cometConfig.Instrumentation), + node.DefaultMetricsProvider(s.config.ConfigTomlConfig.Instrumentation), wrappedLogger, ) if err != nil { @@ -173,17 +195,21 @@ func getGenDocProvider(cfg *cmtcfg.Config) func() (node.ChecksummedGenesisDoc, e } func (s *CometBFTServer[T]) StartCmdFlags() *pflag.FlagSet { - flags := pflag.NewFlagSet("cometbft", pflag.ExitOnError) - flags.Bool(FlagWithComet, true, "Run abci app embedded in-process with CometBFT") + flags := pflag.NewFlagSet(s.Name(), pflag.ExitOnError) + flags.String(FlagAddress, "tcp://127.0.0.1:26658", "Listen address") flags.String(FlagTransport, "socket", "Transport protocol: socket, grpc") - flags.String(FlagTraceStore, "", "Enable KVStore tracing to an output file") - flags.String(FlagMinGasPrices, "", "Minimum gas prices to accept for transactions; Any fee in a tx must meet this minimum (e.g. 0.01photino;0.0001stake)") - flags.Uint64(FlagQueryGasLimit, 0, "Maximum gas a Rest/Grpc query can consume. Blank and 0 imply unbounded.") flags.Uint64(FlagHaltHeight, 0, "Block height at which to gracefully halt the chain and shutdown the node") flags.Uint64(FlagHaltTime, 0, "Minimum block time (in Unix seconds) at which to gracefully halt the chain and shutdown the node") - flags.String(FlagCPUProfile, "", "Enable CPU profiling and write to the provided file") flags.Bool(FlagTrace, false, "Provide full stack traces for errors in ABCI Log") + flags.Bool(Standalone, false, "Run app without CometBFT") + + // add comet flags, we use an empty command to avoid duplicating CometBFT's AddNodeFlags. + // we can then merge the flag sets. + emptyCmd := &cobra.Command{} + cmtcmd.AddNodeFlags(emptyCmd) + flags.AddFlagSet(emptyCmd.Flags()) + return flags } @@ -206,12 +232,30 @@ func (s *CometBFTServer[T]) CLICommands() serverv2.CLIConfig { } } -func (s *CometBFTServer[T]) WriteDefaultConfigAt(configPath string) error { - cometConfig := cmtcfg.DefaultConfig() - for _, opt := range s.cmtConfigOptions { - opt(cometConfig) +// CometBFT is a special server, it has config in config.toml and app.toml + +// Config returns the (app.toml) server configuration. +func (s *CometBFTServer[T]) Config() any { + if s.config.AppTomlConfig == nil || s.config.AppTomlConfig == (&AppTomlConfig{}) { + cfg := &Config{AppTomlConfig: DefaultAppTomlConfig()} + // overwrite the default config with the provided options + for _, opt := range s.cfgOptions { + opt(cfg) + } + + return cfg.AppTomlConfig + } + + return s.config.AppTomlConfig +} + +// WriteCustomConfigAt writes the default cometbft config.toml +func (s *CometBFTServer[T]) WriteCustomConfigAt(configPath string) error { + cfg := &Config{ConfigTomlConfig: cmtcfg.DefaultConfig()} + for _, opt := range s.cfgOptions { + opt(cfg) } - cmtcfg.WriteConfigFile(filepath.Join(configPath, "config.toml"), cometConfig) + cmtcfg.WriteConfigFile(filepath.Join(configPath, "config.toml"), cfg.ConfigTomlConfig) return nil } diff --git a/server/v2/cometbft/utils.go b/server/v2/cometbft/utils.go index b302e90c78c3..e97f09716d86 100644 --- a/server/v2/cometbft/utils.go +++ b/server/v2/cometbft/utils.go @@ -2,6 +2,7 @@ package cometbft import ( "context" + "errors" "fmt" "math" "strings" @@ -262,10 +263,10 @@ func (c *Consensus[T]) validateFinalizeBlockHeight(req *abci.FinalizeBlockReques // expectedHeight holds the expected height to validate var expectedHeight uint64 - if lastBlockHeight == 0 && c.cfg.InitialHeight > 1 { + if lastBlockHeight == 0 && c.initialHeight > 1 { // In this case, we're validating the first block of the chain, i.e no // previous commit. The height we're expecting is the initial height. - expectedHeight = c.cfg.InitialHeight + expectedHeight = c.initialHeight } else { // This case can mean two things: // @@ -296,38 +297,16 @@ func (c *Consensus[T]) GetConsensusParams(ctx context.Context) (*cmtproto.Consen } if r, ok := res.(*consensus.QueryParamsResponse); !ok { - return nil, fmt.Errorf("failed to query consensus params") + return nil, errors.New("failed to query consensus params") } else { // convert our params to cometbft params - evidenceMaxDuration := r.Params.Evidence.MaxAgeDuration - cs := &cmtproto.ConsensusParams{ - Block: &cmtproto.BlockParams{ - MaxBytes: r.Params.Block.MaxBytes, - MaxGas: r.Params.Block.MaxGas, - }, - Evidence: &cmtproto.EvidenceParams{ - MaxAgeNumBlocks: r.Params.Evidence.MaxAgeNumBlocks, - MaxAgeDuration: evidenceMaxDuration, - }, - Validator: &cmtproto.ValidatorParams{ - PubKeyTypes: r.Params.Validator.PubKeyTypes, - }, - Version: &cmtproto.VersionParams{ - App: r.Params.Version.App, - }, - } - if r.Params.Abci != nil { - cs.Abci = &cmtproto.ABCIParams{ // nolint:staticcheck // deprecated type still supported for now - VoteExtensionsEnableHeight: r.Params.Abci.VoteExtensionsEnableHeight, - } - } - return cs, nil + return r.Params, nil } } func (c *Consensus[T]) GetBlockRetentionHeight(cp *cmtproto.ConsensusParams, commitHeight int64) int64 { // pruning is disabled if minRetainBlocks is zero - if c.cfg.MinRetainBlocks == 0 { + if c.cfg.AppTomlConfig.MinRetainBlocks == 0 { return 0 } @@ -368,7 +347,7 @@ func (c *Consensus[T]) GetBlockRetentionHeight(cp *cmtproto.ConsensusParams, com } } - v := commitHeight - int64(c.cfg.MinRetainBlocks) + v := commitHeight - int64(c.cfg.AppTomlConfig.MinRetainBlocks) retentionHeight = minNonZero(retentionHeight, v) if retentionHeight <= 0 { @@ -383,15 +362,15 @@ func (c *Consensus[T]) GetBlockRetentionHeight(cp *cmtproto.ConsensusParams, com func (c *Consensus[T]) checkHalt(height int64, time time.Time) error { var halt bool switch { - case c.cfg.HaltHeight > 0 && uint64(height) > c.cfg.HaltHeight: + case c.cfg.AppTomlConfig.HaltHeight > 0 && uint64(height) > c.cfg.AppTomlConfig.HaltHeight: halt = true - case c.cfg.HaltTime > 0 && time.Unix() > int64(c.cfg.HaltTime): + case c.cfg.AppTomlConfig.HaltTime > 0 && time.Unix() > int64(c.cfg.AppTomlConfig.HaltTime): halt = true } if halt { - return fmt.Errorf("halt per configuration height %d time %d", c.cfg.HaltHeight, c.cfg.HaltTime) + return fmt.Errorf("halt per configuration height %d time %d", c.cfg.AppTomlConfig.HaltHeight, c.cfg.AppTomlConfig.HaltTime) } return nil diff --git a/server/v2/cometbft/version.go b/server/v2/cometbft/version.go new file mode 100644 index 000000000000..1151f819ac39 --- /dev/null +++ b/server/v2/cometbft/version.go @@ -0,0 +1,26 @@ +package cometbft + +import "runtime/debug" + +var Version = "" + +func getCometBFTServerVersion() string { + deps, ok := debug.ReadBuildInfo() + if !ok { + return Version + } + + var serverVersion string + for _, dep := range deps.Deps { + if dep.Path == "cosmossdk.io/server/v2/cometbft" { + if dep.Replace != nil && dep.Replace.Version != "(devel)" { + serverVersion = dep.Replace.Version + } else { + serverVersion = dep.Version + } + } + } + + Version = serverVersion + return serverVersion +} diff --git a/server/v2/commands.go b/server/v2/commands.go index dd62c1518ac6..a0b2b05ae902 100644 --- a/server/v2/commands.go +++ b/server/v2/commands.go @@ -3,7 +3,6 @@ package serverv2 import ( "context" "errors" - "fmt" "os" "os/signal" "path/filepath" @@ -102,19 +101,12 @@ func createStartCommand[T transaction.Tx]( ) *cobra.Command { flags := server.StartFlags() - return &cobra.Command{ + cmd := &cobra.Command{ Use: "start", Short: "Run the application", RunE: func(cmd *cobra.Command, args []string) error { v := GetViperFromCmd(cmd) l := GetLoggerFromCmd(cmd) - - for _, startFlags := range flags { - if err := v.BindPFlags(startFlags); err != nil { - return err - } - } - if err := v.BindPFlags(cmd.Flags()); err != nil { return err } @@ -137,12 +129,19 @@ func createStartCommand[T transaction.Tx]( }() if err := server.Start(ctx); err != nil { - return fmt.Errorf("failed to start servers: %w", err) + return err } return nil }, } + + // add the start flags to the command + for _, startFlags := range flags { + cmd.Flags().AddFlagSet(startFlags) + } + + return cmd } // configHandle writes the default config to the home directory if it does not exist and sets the server context diff --git a/server/v2/config.go b/server/v2/config.go index cb5fbeae7cb5..57cce302bd74 100644 --- a/server/v2/config.go +++ b/server/v2/config.go @@ -1,15 +1,61 @@ package serverv2 -import "github.com/spf13/cobra" - -// CLIConfig defines the CLI configuration for a module server. -type CLIConfig struct { - // Commands defines the main command of a module server. - Commands []*cobra.Command - // Queries defines the query commands of a module server. - // Those commands are meant to be added in the root query command. - Queries []*cobra.Command - // Txs defines the tx commands of a module server. - // Those commands are meant to be added in the root tx command. - Txs []*cobra.Command +import ( + "fmt" + "strings" + + "github.com/mitchellh/mapstructure" + "github.com/spf13/viper" +) + +// ReadConfig returns a viper instance of the config file +func ReadConfig(configPath string) (*viper.Viper, error) { + v := viper.New() + v.SetConfigType("toml") + v.SetConfigName("config") + v.AddConfigPath(configPath) + if err := v.ReadInConfig(); err != nil { + return nil, fmt.Errorf("failed to read config: %s: %w", configPath, err) + } + + v.SetConfigName("app") + if err := v.MergeInConfig(); err != nil { + return nil, fmt.Errorf("failed to merge configuration: %w", err) + } + + v.WatchConfig() + + return v, nil +} + +// UnmarshalSubConfig unmarshals the given subconfig from the viper instance. +// It unmarshals the config, env, flags into the target struct. +// Use this instead of viper.Sub because viper does not unmarshal flags. +func UnmarshalSubConfig(v *viper.Viper, subName string, target any) error { + var sub any + for k, val := range v.AllSettings() { + if strings.HasPrefix(k, subName) { + sub = val + } + } + + // Create a new decoder with custom decoding options + decoder, err := mapstructure.NewDecoder(&mapstructure.DecoderConfig{ + DecodeHook: mapstructure.ComposeDecodeHookFunc( + mapstructure.StringToTimeDurationHookFunc(), + mapstructure.StringToSliceHookFunc(","), + ), + Result: target, + WeaklyTypedInput: true, + }) + if err != nil { + return fmt.Errorf("failed to create decoder: %w", err) + } + + // Decode the sub-configuration + if err := decoder.Decode(sub); err != nil { + return fmt.Errorf("failed to decode sub-configuration: %w", err) + } + + return nil } diff --git a/server/v2/config_test.go b/server/v2/config_test.go new file mode 100644 index 000000000000..24eb28bb7522 --- /dev/null +++ b/server/v2/config_test.go @@ -0,0 +1,39 @@ +package serverv2_test + +import ( + "os" + "path/filepath" + "testing" + + "github.com/stretchr/testify/require" + + serverv2 "cosmossdk.io/server/v2" + grpc "cosmossdk.io/server/v2/api/grpc" +) + +func TestReadConfig(t *testing.T) { + currentDir, err := os.Getwd() + require.NoError(t, err) + configPath := filepath.Join(currentDir, "testdata") + + v, err := serverv2.ReadConfig(configPath) + require.NoError(t, err) + + require.Equal(t, v.GetString("grpc.address"), grpc.DefaultConfig().Address) +} + +func TestUnmarshalSubConfig(t *testing.T) { + currentDir, err := os.Getwd() + require.NoError(t, err) + configPath := filepath.Join(currentDir, "testdata") + + v, err := serverv2.ReadConfig(configPath) + require.NoError(t, err) + + grpcConfig := grpc.DefaultConfig() + err = serverv2.UnmarshalSubConfig(v, "grpc", &grpcConfig) + require.NoError(t, err) + + require.True(t, grpc.DefaultConfig().Enable) + require.False(t, grpcConfig.Enable) +} diff --git a/server/v2/go.mod b/server/v2/go.mod index c82827815f93..97fd086bf82f 100644 --- a/server/v2/go.mod +++ b/server/v2/go.mod @@ -6,10 +6,10 @@ replace ( cosmossdk.io/api => ../../api cosmossdk.io/core => ../../core cosmossdk.io/core/testing => ../../core/testing - cosmossdk.io/depinject => ../../depinject - cosmossdk.io/log => ../../log cosmossdk.io/server/v2/appmanager => ./appmanager cosmossdk.io/server/v2/stf => ./stf + cosmossdk.io/store/v2 => ../../store/v2 + cosmossdk.io/store/v2/db => ../../store/v2/db cosmossdk.io/x/tx => ../../x/tx ) @@ -19,6 +19,7 @@ require ( cosmossdk.io/core/testing v0.0.0-00010101000000-000000000000 cosmossdk.io/log v1.3.1 cosmossdk.io/server/v2/appmanager v0.0.0-00010101000000-000000000000 + cosmossdk.io/store/v2 v2.0.0-00010101000000-000000000000 github.com/cosmos/cosmos-proto v1.0.0-beta.5 github.com/cosmos/gogogateway v1.2.0 github.com/cosmos/gogoproto v1.5.0 @@ -28,6 +29,7 @@ require ( github.com/hashicorp/go-hclog v1.6.2 github.com/hashicorp/go-metrics v0.5.3 github.com/hashicorp/go-plugin v1.6.0 + github.com/mitchellh/mapstructure v1.5.0 github.com/pelletier/go-toml/v2 v2.2.2 github.com/prometheus/client_golang v1.19.1 github.com/prometheus/common v0.55.0 @@ -36,33 +38,51 @@ require ( github.com/spf13/pflag v1.0.5 github.com/spf13/viper v1.19.0 github.com/stretchr/testify v1.9.0 + golang.org/x/exp v0.0.0-20240531132922-fd00a4e0eefc golang.org/x/sync v0.7.0 google.golang.org/grpc v1.64.1 google.golang.org/protobuf v1.34.2 ) require ( + cosmossdk.io/errors/v2 v2.0.0-20240731132947-df72853b3ca5 // indirect github.com/DataDog/datadog-go v3.2.0+incompatible // indirect + github.com/DataDog/zstd v1.5.5 // indirect github.com/beorn7/perks v1.0.1 // indirect github.com/cespare/xxhash/v2 v2.3.0 // indirect + github.com/cockroachdb/errors v1.11.1 // indirect + github.com/cockroachdb/logtags v0.0.0-20230118201751-21c54148d20b // indirect + github.com/cockroachdb/pebble v1.1.0 // indirect + github.com/cockroachdb/redact v1.1.5 // indirect + github.com/cockroachdb/tokenbucket v0.0.0-20230807174530-cc333fc44b06 // indirect + github.com/cosmos/cosmos-db v1.0.2 // indirect + github.com/cosmos/iavl v1.2.1-0.20240725141113-7adc688cf179 // indirect + github.com/cosmos/ics23/go v0.10.0 // indirect github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect + github.com/emicklei/dot v1.6.1 // indirect github.com/fatih/color v1.15.0 // indirect github.com/fsnotify/fsnotify v1.7.0 // indirect + github.com/getsentry/sentry-go v0.27.0 // indirect github.com/gogo/googleapis v1.4.1 // indirect github.com/gogo/protobuf v1.3.2 // indirect + github.com/golang/snappy v0.0.4 // indirect + github.com/google/btree v1.1.2 // indirect github.com/google/go-cmp v0.6.0 // indirect github.com/hashicorp/go-immutable-radix v1.3.1 // indirect - github.com/hashicorp/go-uuid v1.0.1 // indirect github.com/hashicorp/golang-lru v1.0.2 // indirect github.com/hashicorp/hcl v1.0.0 // indirect github.com/hashicorp/yamux v0.1.1 // indirect github.com/inconshreveable/mousetrap v1.1.0 // indirect github.com/jhump/protoreflect v1.15.3 // indirect + github.com/klauspost/compress v1.17.7 // indirect + github.com/kr/pretty v0.3.1 // indirect + github.com/kr/text v0.2.0 // indirect + github.com/linxGnu/grocksdb v1.8.14 // indirect github.com/magiconair/properties v1.8.7 // indirect github.com/mattn/go-colorable v0.1.13 // indirect github.com/mattn/go-isatty v0.0.20 // indirect + github.com/mattn/go-sqlite3 v1.14.22 // indirect github.com/mitchellh/go-testing-interface v1.14.1 // indirect - github.com/mitchellh/mapstructure v1.5.0 // indirect github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect github.com/oklog/run v1.1.0 // indirect github.com/pkg/errors v0.9.1 // indirect @@ -76,9 +96,10 @@ require ( github.com/spf13/afero v1.11.0 // indirect github.com/spf13/cast v1.6.0 // indirect github.com/subosito/gotenv v1.6.0 // indirect + github.com/syndtr/goleveldb v1.0.1-0.20220721030215-126854af5e6d // indirect github.com/tidwall/btree v1.7.0 // indirect go.uber.org/multierr v1.11.0 // indirect - golang.org/x/exp v0.0.0-20240531132922-fd00a4e0eefc // indirect + golang.org/x/crypto v0.25.0 // indirect golang.org/x/net v0.27.0 // indirect golang.org/x/sys v0.22.0 // indirect golang.org/x/text v0.16.0 // indirect diff --git a/server/v2/go.sum b/server/v2/go.sum index 247c43d719ec..466845865b15 100644 --- a/server/v2/go.sum +++ b/server/v2/go.sum @@ -1,8 +1,14 @@ cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= cloud.google.com/go v0.34.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= +cosmossdk.io/errors/v2 v2.0.0-20240731132947-df72853b3ca5 h1:IQNdY2kB+k+1OM2DvqFG1+UgeU1JzZrWtwuWzI3ZfwA= +cosmossdk.io/errors/v2 v2.0.0-20240731132947-df72853b3ca5/go.mod h1:0CuYKkFHxc1vw2JC+t21THBCALJVROrWVR/3PQ1urpc= +cosmossdk.io/log v1.3.1 h1:UZx8nWIkfbbNEWusZqzAx3ZGvu54TZacWib3EzUYmGI= +cosmossdk.io/log v1.3.1/go.mod h1:2/dIomt8mKdk6vl3OWJcPk2be3pGOS8OQaLUM/3/tCM= github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= github.com/DataDog/datadog-go v3.2.0+incompatible h1:qSG2N4FghB1He/r2mFrWKCaL7dXCilEuNEeAn20fdD4= github.com/DataDog/datadog-go v3.2.0+incompatible/go.mod h1:LButxg5PwREeZtORoXG3tL4fMGNddJ+vMq1mwgfaqoQ= +github.com/DataDog/zstd v1.5.5 h1:oWf5W7GtOLgp6bciQYDmhHHjdhYkALu6S/5Ni9ZgSvQ= +github.com/DataDog/zstd v1.5.5/go.mod h1:g4AWEaM3yOg3HYfnJ3YIawPnVdXJh9QME85blwSAmyw= github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc= github.com/alecthomas/template v0.0.0-20190718012654-fb15b899a751/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc= github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0= @@ -18,6 +24,9 @@ github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA github.com/cespare/xxhash/v2 v2.1.1/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= github.com/cespare/xxhash/v2 v2.3.0 h1:UL815xU9SqsFlibzuggzjXhog7bL6oX9BbNZnL2UFvs= github.com/cespare/xxhash/v2 v2.3.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= +github.com/chzyer/logex v1.1.10/go.mod h1:+Ywpsq7O8HXn0nuIou7OrIPyXbp3wmkHB+jjWRnGsAI= +github.com/chzyer/readline v0.0.0-20180603132655-2972be24d48e/go.mod h1:nSuG5e5PlCu98SY8svDHJxuZscDgtXS6KTTbou5AhLI= +github.com/chzyer/test v0.0.0-20180213035817-a1ea475d72b1/go.mod h1:Q3SI9o4m/ZMnBNeIyt5eFwwo7qiLfzFZmjNmxjkiQlU= github.com/circonus-labs/circonus-gometrics v2.3.1+incompatible/go.mod h1:nmEj6Dob7S7YxXgwXpfOuvO54S+tGdZdw9fuRZt25Ag= github.com/circonus-labs/circonusllhist v0.1.3/go.mod h1:kMXHVDlOchFAehlya5ePtbp5jckzBHf4XRpQvBOLI+I= github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw= @@ -28,7 +37,21 @@ github.com/cncf/xds/go v0.0.0-20210805033703-aa0b78936158/go.mod h1:eXthEFrGJvWH github.com/cncf/xds/go v0.0.0-20210922020428-25de7278fc84/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs= github.com/cncf/xds/go v0.0.0-20211001041855-01bcc9b48dfe/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs= github.com/cncf/xds/go v0.0.0-20211011173535-cb28da3451f1/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs= +github.com/cockroachdb/datadriven v1.0.3-0.20230413201302-be42291fc80f h1:otljaYPt5hWxV3MUfO5dFPFiOXg9CyG5/kCfayTqsJ4= +github.com/cockroachdb/datadriven v1.0.3-0.20230413201302-be42291fc80f/go.mod h1:a9RdTaap04u637JoCzcUoIcDmvwSUtcUFtT/C3kJlTU= +github.com/cockroachdb/errors v1.11.1 h1:xSEW75zKaKCWzR3OfxXUxgrk/NtT4G1MiOv5lWZazG8= +github.com/cockroachdb/errors v1.11.1/go.mod h1:8MUxA3Gi6b25tYlFEBGLf+D8aISL+M4MIpiWMSNRfxw= +github.com/cockroachdb/logtags v0.0.0-20230118201751-21c54148d20b h1:r6VH0faHjZeQy818SGhaone5OnYfxFR/+AzdY3sf5aE= +github.com/cockroachdb/logtags v0.0.0-20230118201751-21c54148d20b/go.mod h1:Vz9DsVWQQhf3vs21MhPMZpMGSht7O/2vFW2xusFUVOs= +github.com/cockroachdb/pebble v1.1.0 h1:pcFh8CdCIt2kmEpK0OIatq67Ln9uGDYY3d5XnE0LJG4= +github.com/cockroachdb/pebble v1.1.0/go.mod h1:sEHm5NOXxyiAoKWhoFxT8xMgd/f3RA6qUqQ1BXKrh2E= +github.com/cockroachdb/redact v1.1.5 h1:u1PMllDkdFfPWaNGMyLD1+so+aq3uUItthCFqzwPJ30= +github.com/cockroachdb/redact v1.1.5/go.mod h1:BVNblN9mBWFyMyqK1k3AAiSxhvhfK2oOZZ2lK+dpvRg= +github.com/cockroachdb/tokenbucket v0.0.0-20230807174530-cc333fc44b06 h1:zuQyyAKVxetITBuuhv3BI9cMrmStnpT18zmgmTxunpo= +github.com/cockroachdb/tokenbucket v0.0.0-20230807174530-cc333fc44b06/go.mod h1:7nc4anLGjupUW/PeY5qiNYsdNXj7zopG+eqsS7To5IQ= github.com/coreos/go-systemd/v22 v22.5.0/go.mod h1:Y58oyj3AT4RCenI/lSvhwexgC+NSVTIJ3seZv2GcEnc= +github.com/cosmos/cosmos-db v1.0.2 h1:hwMjozuY1OlJs/uh6vddqnk9j7VamLv+0DBlbEXbAKs= +github.com/cosmos/cosmos-db v1.0.2/go.mod h1:Z8IXcFJ9PqKK6BIsVOB3QXtkKoqUOp1vRvPT39kOXEA= github.com/cosmos/cosmos-proto v1.0.0-beta.5 h1:eNcayDLpip+zVLRLYafhzLvQlSmyab+RC5W7ZfmxJLA= github.com/cosmos/cosmos-proto v1.0.0-beta.5/go.mod h1:hQGLpiIUloJBMdQMMWb/4wRApmI9hjHH05nefC0Ojec= github.com/cosmos/gogogateway v1.2.0 h1:Ae/OivNhp8DqBi/sh2A8a1D0y638GpL3tkmLQAiKxTE= @@ -36,11 +59,18 @@ github.com/cosmos/gogogateway v1.2.0/go.mod h1:iQpLkGWxYcnCdz5iAdLcRBSw3h7NXeOkZ github.com/cosmos/gogoproto v1.4.2/go.mod h1:cLxOsn1ljAHSV527CHOtaIP91kK6cCrZETRBrkzItWU= github.com/cosmos/gogoproto v1.5.0 h1:SDVwzEqZDDBoslaeZg+dGE55hdzHfgUA40pEanMh52o= github.com/cosmos/gogoproto v1.5.0/go.mod h1:iUM31aofn3ymidYG6bUR5ZFrk+Om8p5s754eMUcyp8I= +github.com/cosmos/iavl v1.2.1-0.20240725141113-7adc688cf179 h1:wmwDn7V3RodN9auB3FooSQxs46nHVE3u0mb87TJkZFE= +github.com/cosmos/iavl v1.2.1-0.20240725141113-7adc688cf179/go.mod h1:GiM43q0pB+uG53mLxLDzimxM9l/5N9UuSY3/D0huuVw= +github.com/cosmos/ics23/go v0.10.0 h1:iXqLLgp2Lp+EdpIuwXTYIQU+AiHj9mOC2X9ab++bZDM= +github.com/cosmos/ics23/go v0.10.0/go.mod h1:ZfJSmng/TBNTBkFemHHHj5YY7VAU/MBU980F4VU1NG0= github.com/cpuguy83/go-md2man/v2 v2.0.4/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o= +github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc h1:U9qPSI2PIWSS1VwoXQT9A3Wy9MM3WgvqSxFWenqJduM= github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/emicklei/dot v1.6.1 h1:ujpDlBkkwgWUY+qPId5IwapRW/xEoligRSYjioR6DFI= +github.com/emicklei/dot v1.6.1/go.mod h1:DeV7GvQtIw4h2u73RKBkkFdvVAz0D9fzeJrgPW6gy/s= github.com/envoyproxy/go-control-plane v0.9.0/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= github.com/envoyproxy/go-control-plane v0.9.4/go.mod h1:6rpuAdCZL397s3pYoYcLgu1mIlRU8Am5FuJP05cCM98= @@ -53,14 +83,22 @@ github.com/fatih/color v1.15.0 h1:kOqh6YHBtK8aywxGerMG2Eq3H6Qgoqeo13Bk2Mv/nBs= github.com/fatih/color v1.15.0/go.mod h1:0h5ZqXfHYED7Bhv2ZJamyIOUej9KtShiJESRwBDUSsw= github.com/frankban/quicktest v1.14.6 h1:7Xjx+VpznH+oBnejlPUj8oUpdxnVs4f8XU8WnHkI4W8= github.com/frankban/quicktest v1.14.6/go.mod h1:4ptaffx2x8+WTWXmUCuVU6aPUX1/Mz7zb5vbUoiM6w0= +github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo= +github.com/fsnotify/fsnotify v1.4.9/go.mod h1:znqG4EE+3YCdAaPaxE2ZRY/06pZUdp0tY4IgpuI1SZQ= +github.com/fsnotify/fsnotify v1.5.4/go.mod h1:OVB6XrOHzAwXMpEM7uPOzcehqUV2UqJxmVXmkdnm1bU= github.com/fsnotify/fsnotify v1.7.0 h1:8JEhPFa5W2WU7YfeZzPNqzMP6Lwt7L2715Ggo0nosvA= github.com/fsnotify/fsnotify v1.7.0/go.mod h1:40Bi/Hjc2AVfZrqy+aj+yEI+/bRxZnMJyTJwOpGvigM= +github.com/getsentry/sentry-go v0.27.0 h1:Pv98CIbtB3LkMWmXi4Joa5OOcwbmnX88sF5qbK3r3Ps= +github.com/getsentry/sentry-go v0.27.0/go.mod h1:lc76E2QywIyW8WuBnwl8Lc4bkmQH4+w1gwTf25trprY= github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04= +github.com/go-errors/errors v1.4.2 h1:J6MZopCL4uSllY1OfXM374weqZFFItUbrImctkmUxIA= +github.com/go-errors/errors v1.4.2/go.mod h1:sIVyrIiJhuEF+Pj9Ebtd6P/rEYROXFi3BopGUQ5a5Og= github.com/go-kit/kit v0.8.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as= github.com/go-kit/kit v0.9.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as= github.com/go-logfmt/logfmt v0.3.0/go.mod h1:Qt1PoO58o5twSAckw1HlFXLmHsOX5/0LbT9GBnD5lWE= github.com/go-logfmt/logfmt v0.4.0/go.mod h1:3RMwSq7FuexP4Kalkev3ejPJsZTpXXBr9+V4qmtdjCk= github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY= +github.com/go-task/slim-sprig v0.0.0-20210107165309-348f09dbbbc0/go.mod h1:fyg7847qk6SyHyPtNmDHnmrv/HOrqktSC+C9fM+CJOE= github.com/godbus/dbus/v5 v5.0.4/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA= github.com/gogo/googleapis v1.4.1-0.20201022092350-68b0159b7869/go.mod h1:5YRNX2z1oM5gXdAkurHa942MDgEJyk02w4OecKY87+c= github.com/gogo/googleapis v1.4.1 h1:1Yx4Myt7BxzvUr5ldGSbwYiZG6t9wGBZ+8/fX3Wvtq0= @@ -71,6 +109,8 @@ github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q= github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q= github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q= github.com/golang/mock v1.1.1/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A= +github.com/golang/mock v1.6.0 h1:ErTB+efbowRARo13NNdxyJji2egdxLGQhRaY+DUumQc= +github.com/golang/mock v1.6.0/go.mod h1:p6yTPP+5HYm5mzsMV8JkE6ZKdX+/wYM6Hr+LicevLPs= github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= github.com/golang/protobuf v1.3.2/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= @@ -87,6 +127,10 @@ github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaS github.com/golang/protobuf v1.5.2/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY= github.com/golang/protobuf v1.5.4 h1:i7eJL8qZTpSEXOPTxNKhASYpMn+8e5Q6AdndVa1dWek= github.com/golang/protobuf v1.5.4/go.mod h1:lnTiLA8Wa4RWRcIUkrtSVa5nRhsEGBg48fD6rSs7xps= +github.com/golang/snappy v0.0.4 h1:yAGX7huGHXlcLOEtBnF4w7FQwA26wojNCwOYAEhLjQM= +github.com/golang/snappy v0.0.4/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= +github.com/google/btree v1.1.2 h1:xf4v41cLI2Z6FxbKm+8Bu+m8ifhj15JuZ9sa0jZCMUU= +github.com/google/btree v1.1.2/go.mod h1:qOPhT0dTNdNzV6Z/lhRX0YXUafgPLFUh+gZMl761Gm4= github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M= github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= @@ -97,6 +141,7 @@ github.com/google/go-cmp v0.5.6/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/ github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI= github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= +github.com/google/pprof v0.0.0-20210407192527-94a9f03dee38/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE= github.com/google/uuid v1.1.2/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/gorilla/mux v1.8.1 h1:TuBL49tXwgrFYWhqrNgrUNEY92u81SPhu7sTdzQEiWY= github.com/gorilla/mux v1.8.1/go.mod h1:AKf9I4AEqPTmMytcMc0KkNouC66V3BtZ4qD5fmWSiMQ= @@ -123,6 +168,8 @@ github.com/hashicorp/hcl v1.0.0 h1:0Anlzjpi4vEasTeNFn2mLJgTSwt0+6sfsiTG8qcWGx4= github.com/hashicorp/hcl v1.0.0/go.mod h1:E5yfLk+7swimpb2L/Alb/PJmXilQ/rhwaUYs4T20WEQ= github.com/hashicorp/yamux v0.1.1 h1:yrQxtgseBDrq9Y652vSRDvsKCJKOUD+GzTS4Y0Y8pvE= github.com/hashicorp/yamux v0.1.1/go.mod h1:CtWFDAQgb7dxtzFs4tWbplKIe2jSi3+5vKbgIO0SLnQ= +github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU= +github.com/ianlancetaylor/demangle v0.0.0-20200824232613-28f6c0f3b639/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc= github.com/inconshreveable/mousetrap v1.1.0 h1:wN+x4NVGpMsO7ErUn/mUI3vEoE6Jt13X2s0bqwp9tc8= github.com/inconshreveable/mousetrap v1.1.0/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw= github.com/jhump/protoreflect v1.15.3 h1:6SFRuqU45u9hIZPJAoZ8c28T3nK64BNdp9w6jFonzls= @@ -133,6 +180,8 @@ github.com/julienschmidt/httprouter v1.2.0/go.mod h1:SYymIcj16QtmaHHD7aYtjjsJG7V github.com/kisielk/errcheck v1.2.0/go.mod h1:/BMXB+zMLi60iA8Vv6Ksmxu/1UDYcXs4uQLJ+jE2L00= github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8= github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= +github.com/klauspost/compress v1.17.7 h1:ehO88t2UGzQK66LMdE8tibEd1ErmzZjNEqWkjLAKQQg= +github.com/klauspost/compress v1.17.7/go.mod h1:Di0epgTjJY877eYKx5yC51cX2A2Vl2ibi7bDH9ttBbw= github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= github.com/kr/logfmt v0.0.0-20140226030751-b84e30acd515/go.mod h1:+0opPa2QZZtGFBFZlji/RkVcI2GknAs/DXo4wKdlNEc= github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= @@ -142,6 +191,8 @@ github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= +github.com/linxGnu/grocksdb v1.8.14 h1:HTgyYalNwBSG/1qCQUIott44wU5b2Y9Kr3z7SK5OfGQ= +github.com/linxGnu/grocksdb v1.8.14/go.mod h1:QYiYypR2d4v63Wj1adOOfzglnoII0gLj3PNh4fZkcFA= github.com/magiconair/properties v1.8.7 h1:IeQXZAiQcpL9mgcAe1Nu6cX9LLw6ExEHKjN0VQdvPDY= github.com/magiconair/properties v1.8.7/go.mod h1:Dhd985XPs7jluiymwWYZ0G4Z61jb3vdS329zhj2hYo0= github.com/mattn/go-colorable v0.1.9/go.mod h1:u6P/XSegPjTcexA+o6vUJrdnUu04hMope9wVRipJSqc= @@ -154,6 +205,8 @@ github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/ github.com/mattn/go-isatty v0.0.19/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y= github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY= github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y= +github.com/mattn/go-sqlite3 v1.14.22 h1:2gZY6PC6kBnID23Tichd1K+Z0oS6nE/XwU+Vz/5o4kU= +github.com/mattn/go-sqlite3 v1.14.22/go.mod h1:Uh1q+B4BYcTPb+yiD3kU8Ct7aC0hY9fxUwlHK0RXw+Y= github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0= github.com/mitchellh/go-testing-interface v1.14.1 h1:jrgshOhYAUVNMAJiKbEu7EqAwgJJ2JqpQmpLJOu07cU= github.com/mitchellh/go-testing-interface v1.14.1/go.mod h1:gfgS7OtZj6MA4U1UrDRp04twqAjfvlZyCfX3sDjEym8= @@ -166,12 +219,30 @@ github.com/modern-go/reflect2 v1.0.1/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3Rllmb github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 h1:C3w9PqII01/Oq1c1nUAm88MOHcQC9l5mIlSMApZMrHA= github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822/go.mod h1:+n7T8mK8HuQTcFwEeznm/DIxMOiR9yIdICNftLE1DvQ= github.com/mwitkow/go-conntrack v0.0.0-20161129095857-cc309e4a2223/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U= +github.com/nxadm/tail v1.4.4/go.mod h1:kenIhsEOeOJmVchQTgglprH7qJGnHDVpk1VPCcaMI8A= +github.com/nxadm/tail v1.4.8 h1:nPr65rt6Y5JFSKQO7qToXr7pePgD6Gwiw05lkbyAQTE= +github.com/nxadm/tail v1.4.8/go.mod h1:+ncqLTQzXmGhMZNUePPaPqPvBxHAIsmXswZKocGu+AU= github.com/oklog/run v1.1.0 h1:GEenZ1cK0+q0+wsJew9qUg/DyD8k3JzYsZAi5gYi2mA= github.com/oklog/run v1.1.0/go.mod h1:sVPdnTZT1zYwAJeCMu2Th4T21pA3FPOQRfWjQlk7DVU= +github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= +github.com/onsi/ginkgo v1.12.1/go.mod h1:zj2OWP4+oCPe1qIXoGWkgMRwljMUYCdkwsT2108oapk= +github.com/onsi/ginkgo v1.16.4/go.mod h1:dX+/inL/fNMqNlz0e9LfyB9TswhZpCVdJM/Z6Vvnwo0= +github.com/onsi/ginkgo v1.16.5 h1:8xi0RTUf59SOSfEtZMvwTvXYMzG4gV23XVHOZiXNtnE= +github.com/onsi/ginkgo v1.16.5/go.mod h1:+E8gABHa3K6zRBolWtd+ROzc/U5bkGt0FwiG042wbpU= +github.com/onsi/ginkgo/v2 v2.1.3/go.mod h1:vw5CSIxN1JObi/U8gcbwft7ZxR2dgaR70JSE3/PpL4c= +github.com/onsi/gomega v1.7.1/go.mod h1:XdKZgCCFLUoM/7CFJVPcG8C1xQ1AJ0vpAezJrB7JYyY= +github.com/onsi/gomega v1.10.1/go.mod h1:iN09h71vgCQne3DLsj+A5owkum+a2tYe+TOCB1ybHNo= +github.com/onsi/gomega v1.17.0/go.mod h1:HnhC7FXeEQY45zxNK3PPoIUhzk/80Xly9PcubAlGdZY= +github.com/onsi/gomega v1.19.0/go.mod h1:LY+I3pBVzYsTBU1AnDwOSxaYi9WoWiqgwooUqq9yPro= +github.com/onsi/gomega v1.26.0 h1:03cDLK28U6hWvCAns6NeydX3zIm4SF3ci69ulidS32Q= +github.com/onsi/gomega v1.26.0/go.mod h1:r+zV744Re+DiYCIPRlYOTxn0YkOLcAnW8k1xXdMPGhM= github.com/pascaldekloe/goe v0.1.0 h1:cBOtyMzM9HTpWjXfbbunk26uA6nG3a8n06Wieeh0MwY= github.com/pascaldekloe/goe v0.1.0/go.mod h1:lzWF7FIEvWOWxwDKqyGYQf6ZUaNfKdP144TG7ZOy1lc= github.com/pelletier/go-toml/v2 v2.2.2 h1:aYUidT7k73Pcl9nb2gScu7NSrKCSHIDE89b3+6Wq+LM= github.com/pelletier/go-toml/v2 v2.2.2/go.mod h1:1t835xjRzz80PqgE6HHgN2JOsmgYu/h4qDAS4n929Rs= +github.com/pingcap/errors v0.11.4 h1:lFuQV/oaUMGcD2tqt+01ROSmJs75VG1ToEOkZIZ4nE4= +github.com/pingcap/errors v0.11.4/go.mod h1:Oi8TUi2kEtXXLMJk9l1cGmz20kV3TaQ0usTwv5KuLY8= +github.com/pkg/diff v0.0.0-20210226163009-20ebb0f2a09e/go.mod h1:pJLUxLENpZxwdsKMEsNbx1VGcRFpLqf3715MtcvvzbA= github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= @@ -200,6 +271,7 @@ github.com/prometheus/procfs v0.0.8/go.mod h1:7Qr8sr6344vo1JqZ6HhLceV9o3AJ1Ff+Gx github.com/prometheus/procfs v0.15.1 h1:YagwOFzUgYfKKHX6Dr+sHT7km/hxC76UB0learggepc= github.com/prometheus/procfs v0.15.1/go.mod h1:fB45yRUv8NstnjriLhBQLuOUt+WW4BsoGhij/e3PBqk= github.com/rogpeppe/fastuuid v1.2.0/go.mod h1:jVj6XXZzXRy/MSR5jhDC/2q6DgLz+nrA6LYCDYWNEvQ= +github.com/rogpeppe/go-internal v1.9.0/go.mod h1:WtVeX8xhTBvf0smdhujwtBcq4Qrzq/fJaraNFVN+nFs= github.com/rogpeppe/go-internal v1.12.0 h1:exVL4IDcn6na9z1rAb56Vxr+CgyK3nn3O+epU5NdKM8= github.com/rogpeppe/go-internal v1.12.0/go.mod h1:E+RYuTGaKKdloAfM02xzb0FW3Paa99yedzYV+kq4uf4= github.com/rs/xid v1.5.0/go.mod h1:trrq9SKmegXys3aeAKXMUTdJsYXVwGY3RLcfgqegfbg= @@ -243,6 +315,8 @@ github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsT github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= github.com/subosito/gotenv v1.6.0 h1:9NlTDc1FTs4qu0DDq7AEtTPNw6SVm7uBMsUCUjABIf8= github.com/subosito/gotenv v1.6.0/go.mod h1:Dk4QP5c2W3ibzajGcXpNraDfq2IrhjMIvMSWPKKo0FU= +github.com/syndtr/goleveldb v1.0.1-0.20220721030215-126854af5e6d h1:vfofYNRScrDdvS342BElfbETmL1Aiz3i2t0zfRj16Hs= +github.com/syndtr/goleveldb v1.0.1-0.20220721030215-126854af5e6d/go.mod h1:RRCYJbIwD5jmqPI9XoAFR0OcDxqUctll6zUj/+B4S48= github.com/tidwall/btree v1.7.0 h1:L1fkJH/AuEh5zBnnBbmTwQ5Lt+bRJ5A8EWecslvo9iI= github.com/tidwall/btree v1.7.0/go.mod h1:twD9XRA5jj9VUQGELzDO4HPQTNJsoWWfYEL+EUQ2cKY= github.com/tv42/httpunix v0.0.0-20150427012821-b75d8614f926/go.mod h1:9ESjWnEqriFuLhtthL60Sar/7RFoluCcXsuvEwTV5KM= @@ -255,6 +329,8 @@ golang.org/x/crypto v0.0.0-20180904163835-0709b304e793/go.mod h1:6SG95UA2DQfeDnf golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= +golang.org/x/crypto v0.25.0 h1:ypSNr+bnYL2YhwoMt2zPxHFmbAN1KZs/njMG3hxUp30= +golang.org/x/crypto v0.25.0/go.mod h1:T+wALwcMOSE0kXgUAnPAHqTLW+XHgcELELW8VaDgm/M= golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20240531132922-fd00a4e0eefc h1:O9NuF4s+E/PvMIy+9IUZB9znFwUIXEWSstNjek6VpVg= golang.org/x/exp v0.0.0-20240531132922-fd00a4e0eefc/go.mod h1:XtvwrStGgqGPLc4cjQfWqZHG1YFdYs6swckp8vpsjnc= @@ -265,6 +341,7 @@ golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20181114220301-adae6a3d119a/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20190108225652-1e06a53dbb7e/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20190213061140-3a22650c66bd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= @@ -273,10 +350,13 @@ golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn golang.org/x/net v0.0.0-20190613194153-d28f0bde5980/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20200520004742-59133d7f0dd7/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= golang.org/x/net v0.0.0-20200822124328-c89045814202/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4/go.mod h1:p54w0d4576C0XHj96bSt6lcn1PtDYWL6XObtHCRCNQM= +golang.org/x/net v0.0.0-20210428140749-89ef3d95e781/go.mod h1:OJAsFXCWl8Ukc7SiCT/9KSuxbyM7479/AVlXFRxuMCk= golang.org/x/net v0.0.0-20220225172249-27dd8689420f/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk= +golang.org/x/net v0.0.0-20220607020251-c690dde0001d/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c= golang.org/x/net v0.27.0 h1:5K3Njcw06/l2y9vpGCSdcxWOYHOUk3dVNGDXN+FvAys= golang.org/x/net v0.27.0/go.mod h1:dDi0PyhWNoiUOrAS8uXv/vnScO4wnHQO4mj9fn/RytE= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= @@ -291,25 +371,34 @@ golang.org/x/sync v0.7.0 h1:YsImfSBoP9QPYL0xyKJPq0gcaJdG3rInoqxTWbfQu9M= golang.org/x/sync v0.7.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20181116152217-5ac8a444bdc5/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190422165155-953cdadca894/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20190904154756-749cb33beabd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20191005200804-aed5e4c7ecf9/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20191120155948-bd437916bb0e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20191204072324-ce4227a45e2e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200116001909-b77594299b42/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200122134326-e047566fdf82/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200223170610-d5e6a3e2c0ae/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210112080510-489259a85091/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210119212857-b64e53b001e4/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210330210617-4fbd30eecc44/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210510120138-977fb7262007/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210927094055-39ccf1dd6fa6/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220315194320-039c03cc5b86/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20220412211240-33da011f77ad/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220503163025-988cb79eb6c6/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.12.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= @@ -320,6 +409,7 @@ golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuX golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.5/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= +golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= golang.org/x/text v0.16.0 h1:a94ExnEXNtEwYLGJSIUxnWoxoRz/ZcCsV63ROupILh4= golang.org/x/text v0.16.0/go.mod h1:GhwF1Be+LQoKShO3cGOHzqOgRrGaYc9AvblQOmPVHnI= @@ -331,11 +421,13 @@ golang.org/x/tools v0.0.0-20190311212946-11955173bddd/go.mod h1:LCzVGOaR6xXOjkQ3 golang.org/x/tools v0.0.0-20190524140312-2c0ae7006135/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q= golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.0.0-20200619180055-7c47624df98f/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= +golang.org/x/tools v0.0.0-20201224043029-2b0845dc783e/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= golang.org/x/tools v0.0.0-20210106214847-113979e3529a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +golang.org/x/xerrors v0.0.0-20220517211312-f3a8303e98df/go.mod h1:K8+ghG5WaK9qNqU5K3HdILfMLy1f3aNYFI/wnl100a8= google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM= google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc= @@ -379,13 +471,18 @@ gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8 gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk= gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q= +gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys= gopkg.in/ini.v1 v1.67.0 h1:Dgnx+6+nfE+IfzjUEISNeydPJh9AXNNsWbGP9KzCsOA= gopkg.in/ini.v1 v1.67.0/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k= +gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 h1:uRGJdciOHaEIrze2W8Q3AKkepLTh2hOroT7a+7czfdQ= +gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWDmTeBkI65Dw0HsyUHuEVlX15mw= gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.2.3/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.2.5/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +gopkg.in/yaml.v2 v2.3.0/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ= gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= diff --git a/server/v2/logger.go b/server/v2/logger.go index 5b89486c2771..8ca80e4cce45 100644 --- a/server/v2/logger.go +++ b/server/v2/logger.go @@ -6,13 +6,12 @@ import ( "github.com/rs/zerolog" "github.com/spf13/viper" - corelog "cosmossdk.io/core/log" "cosmossdk.io/log" ) -// NewLogger creates a the default SDK logger. +// NewLogger creates the default SDK logger. // It reads the log level and format from the server context. -func NewLogger(v *viper.Viper, out io.Writer) (corelog.Logger, error) { +func NewLogger(v *viper.Viper, out io.Writer) (log.Logger, error) { var opts []log.Option if v.GetString(FlagLogFormat) == OutputFormatJSON { opts = append(opts, log.OutputJSONOption()) diff --git a/server/v2/server.go b/server/v2/server.go index 7dd4438097ca..6e1a4e7114db 100644 --- a/server/v2/server.go +++ b/server/v2/server.go @@ -26,9 +26,12 @@ type ServerComponent[T transaction.Tx] interface { Init(AppI[T], *viper.Viper, log.Logger) error } -// HasCLICommands is a server module that has CLI commands. -type HasCLICommands interface { - CLICommands() CLIConfig +// HasStartFlags is a server module that has start flags. +type HasStartFlags interface { + // StartCmdFlags returns server start flags. + // Those flags should be prefixed with the server name. + // They are then merged with the server config in one viper instance. + StartCmdFlags() *pflag.FlagSet } // HasConfig is a server module that has a config. @@ -36,33 +39,25 @@ type HasConfig interface { Config() any } -// HasStartFlags is a server module that has start flags. -type HasStartFlags interface { - StartCmdFlags() *pflag.FlagSet +// HasCLICommands is a server module that has CLI commands. +type HasCLICommands interface { + CLICommands() CLIConfig } -var _ ServerComponent[transaction.Tx] = (*Server[transaction.Tx])(nil) - -// ReadConfig returns a viper instance of the config file -func ReadConfig(configPath string) (*viper.Viper, error) { - v := viper.New() - v.SetConfigType("toml") - v.SetConfigName("config") - v.AddConfigPath(configPath) - if err := v.ReadInConfig(); err != nil { - return nil, fmt.Errorf("failed to read config: %s: %w", configPath, err) - } - - v.SetConfigName("app") - if err := v.MergeInConfig(); err != nil { - return nil, fmt.Errorf("failed to merge configuration: %w", err) - } - - v.WatchConfig() - - return v, nil +// CLIConfig defines the CLI configuration for a module server. +type CLIConfig struct { + // Commands defines the main command of a module server. + Commands []*cobra.Command + // Queries defines the query commands of a module server. + // Those commands are meant to be added in the root query command. + Queries []*cobra.Command + // Txs defines the tx commands of a module server. + // Those commands are meant to be added in the root tx command. + Txs []*cobra.Command } +var _ ServerComponent[transaction.Tx] = (*Server[transaction.Tx])(nil) + type Server[T transaction.Tx] struct { logger log.Logger components []ServerComponent[T] @@ -209,8 +204,8 @@ func (s *Server[T]) WriteConfig(configPath string) error { // undocumented interface to write the component default config in another file than app.toml // it is used by cometbft for backward compatibility // it should not be used by other components - if mod, ok := component.(interface{ WriteDefaultConfigAt(string) error }); ok { - if err := mod.WriteDefaultConfigAt(configPath); err != nil { + if mod, ok := component.(interface{ WriteCustomConfigAt(string) error }); ok { + if err := mod.WriteCustomConfigAt(configPath); err != nil { return err } } diff --git a/server/v2/server_test.go b/server/v2/server_test.go index 76102942006e..e757e7ecd5ca 100644 --- a/server/v2/server_test.go +++ b/server/v2/server_test.go @@ -16,6 +16,7 @@ import ( "cosmossdk.io/log" serverv2 "cosmossdk.io/server/v2" grpc "cosmossdk.io/server/v2/api/grpc" + "cosmossdk.io/server/v2/appmanager" ) type mockInterfaceRegistry struct{} @@ -33,23 +34,21 @@ type mockApp[T transaction.Tx] struct { serverv2.AppI[T] } +func (*mockApp[T]) GetGPRCMethodsToMessageMap() map[string]func() gogoproto.Message { + return map[string]func() gogoproto.Message{} +} + +func (*mockApp[T]) GetAppManager() *appmanager.AppManager[T] { + return nil +} + func (*mockApp[T]) InterfaceRegistry() coreapp.InterfaceRegistry { return &mockInterfaceRegistry{} } -// TODO split this test into multiple tests -// test read config -// test write config -// test server configs -// test start empty -// test start config exists -// test stop func TestServer(t *testing.T) { currentDir, err := os.Getwd() - if err != nil { - t.Log(err) - t.Fail() - } + require.NoError(t, err) configPath := filepath.Join(currentDir, "testdata") v, err := serverv2.ReadConfig(configPath) @@ -59,10 +58,8 @@ func TestServer(t *testing.T) { logger := log.NewLogger(os.Stdout) grpcServer := grpc.New[transaction.Tx]() - if err := grpcServer.Init(&mockApp[transaction.Tx]{}, v, logger); err != nil { - t.Log(err) - t.Fail() - } + err = grpcServer.Init(&mockApp[transaction.Tx]{}, v, logger) + require.NoError(t, err) mockServer := &mockServer{name: "mock-server-1", ch: make(chan string, 100)} @@ -73,30 +70,17 @@ func TestServer(t *testing.T) { ) serverCfgs := server.Configs() - if serverCfgs[grpcServer.Name()].(*grpc.Config).Address != grpc.DefaultConfig().Address { - t.Logf("config is not equal: %v", serverCfgs[grpcServer.Name()]) - t.Fail() - } - if serverCfgs[mockServer.Name()].(*mockServerConfig).MockFieldOne != MockServerDefaultConfig().MockFieldOne { - t.Logf("config is not equal: %v", serverCfgs[mockServer.Name()]) - t.Fail() - } + require.Equal(t, serverCfgs[grpcServer.Name()].(*grpc.Config).Address, grpc.DefaultConfig().Address) + require.Equal(t, serverCfgs[mockServer.Name()].(*mockServerConfig).MockFieldOne, MockServerDefaultConfig().MockFieldOne) // write config - if err := server.WriteConfig(configPath); err != nil { - t.Log(err) - t.Fail() - } + err = server.WriteConfig(configPath) + require.NoError(t, err) v, err = serverv2.ReadConfig(configPath) - if err != nil { - t.Log(err) // config should be created by WriteConfig - t.FailNow() - } - if v.GetString(grpcServer.Name()+".address") != grpc.DefaultConfig().Address { - t.Logf("config is not equal: %v", v) - t.Fail() - } + require.NoError(t, err) + + require.Equal(t, v.GetString(grpcServer.Name()+".address"), grpc.DefaultConfig().Address) // start empty ctx, cancelFn := context.WithCancel(context.TODO()) @@ -105,30 +89,10 @@ func TestServer(t *testing.T) { <-time.After(5 * time.Second) cancelFn() - if err := server.Stop(ctx); err != nil { - t.Logf("failed to stop servers: %s", err) - t.Fail() - } + err = server.Stop(ctx) + require.NoError(t, err) }() - if err := server.Start(ctx); err != nil { - t.Log(err) - t.Fail() - } -} - -func TestReadConfig(t *testing.T) { - currentDir, err := os.Getwd() - if err != nil { - t.Log(err) - t.Fail() - } - configPath := filepath.Join(currentDir, "testdata") - - v, err := serverv2.ReadConfig(configPath) - require.NoError(t, err) - - grpcConfig := grpc.DefaultConfig() - err = v.Sub("grpc").Unmarshal(&grpcConfig) + err = server.Start(ctx) require.NoError(t, err) } diff --git a/server/v2/stf/core_branch_service_test.go b/server/v2/stf/core_branch_service_test.go index 960563faba0d..21854001ba56 100644 --- a/server/v2/stf/core_branch_service_test.go +++ b/server/v2/stf/core_branch_service_test.go @@ -2,7 +2,7 @@ package stf import ( "context" - "fmt" + "errors" "testing" gogotypes "github.com/cosmos/gogoproto/types" @@ -70,7 +70,7 @@ func TestBranchService(t *testing.T) { stfCtx := makeContext() gasUsed, err := branchService.ExecuteWithGasLimit(stfCtx, 10000, func(ctx context.Context) error { kvSet(t, ctx, "cookies") - return fmt.Errorf("fail") + return errors.New("fail") }) require.Error(t, err) require.NotZero(t, gasUsed) diff --git a/server/v2/stf/core_event_service.go b/server/v2/stf/core_event_service.go index 5bd94c6ea746..137f654ec78f 100644 --- a/server/v2/stf/core_event_service.go +++ b/server/v2/stf/core_event_service.go @@ -1,10 +1,12 @@ package stf import ( + "bytes" "context" "encoding/json" "slices" + "github.com/cosmos/gogoproto/jsonpb" gogoproto "github.com/cosmos/gogoproto/proto" "golang.org/x/exp/maps" @@ -55,14 +57,14 @@ func (em *eventManager) EmitNonConsensus(event gogoproto.Message) error { // TypedEventToEvent takes typed event and converts to Event object func TypedEventToEvent(tev gogoproto.Message) (event.Event, error) { evtType := gogoproto.MessageName(tev) - evtJSON, err := gogoproto.Marshal(tev) - if err != nil { + buf := new(bytes.Buffer) + jm := &jsonpb.Marshaler{OrigName: true, EmitDefaults: true, AnyResolver: nil} + if err := jm.Marshal(buf, tev); err != nil { return event.Event{}, err } var attrMap map[string]json.RawMessage - err = json.Unmarshal(evtJSON, &attrMap) - if err != nil { + if err := json.Unmarshal(buf.Bytes(), &attrMap); err != nil { return event.Event{}, err } diff --git a/server/v2/stf/stf.go b/server/v2/stf/stf.go index 633a356c36d1..d6cf27115d38 100644 --- a/server/v2/stf/stf.go +++ b/server/v2/stf/stf.go @@ -149,7 +149,7 @@ func (s STF[T]) DeliverBlock( if err = isCtxCancelled(ctx); err != nil { return nil, nil, err } - txResults[i] = s.deliverTx(ctx, newState, txBytes, transaction.ExecModeFinalize, hi) + txResults[i] = s.deliverTx(exCtx, newState, txBytes, transaction.ExecModeFinalize, hi) } // reset events exCtx.events = make([]event.Event, 0) @@ -564,10 +564,10 @@ func (s STF[T]) makeContext( ) *executionContext { valuedCtx := context.WithValue(ctx, corecontext.ExecModeKey, execMode) return newExecutionContext( + valuedCtx, s.makeGasMeter, s.makeGasMeteredState, s.branchFn, - valuedCtx, sender, store, execMode, @@ -577,10 +577,10 @@ func (s STF[T]) makeContext( } func newExecutionContext( + ctx context.Context, makeGasMeterFn makeGasMeterFn, makeGasMeteredStoreFn makeGasMeteredStateFn, branchFn branchFn, - ctx context.Context, sender transaction.Identity, state store.WriterMap, execMode transaction.ExecMode, diff --git a/server/v2/stf/stf_test.go b/server/v2/stf/stf_test.go index a77c126087ee..6d6fc692a30b 100644 --- a/server/v2/stf/stf_test.go +++ b/server/v2/stf/stf_test.go @@ -3,7 +3,7 @@ package stf import ( "context" "crypto/sha256" - "fmt" + "errors" "testing" "time" @@ -158,7 +158,7 @@ func TestSTF(t *testing.T) { // update the stf to fail on the handler s := s.clone() addMsgHandlerToSTF(t, &s, func(ctx context.Context, msg *gogotypes.BoolValue) (*gogotypes.BoolValue, error) { - return nil, fmt.Errorf("failure") + return nil, errors.New("failure") }) blockResult, newState, err := s.DeliverBlock(context.Background(), &appmanager.BlockRequest[mock.Tx]{ @@ -180,7 +180,7 @@ func TestSTF(t *testing.T) { t.Run("tx is success but post tx failed", func(t *testing.T) { s := s.clone() s.postTxExec = func(ctx context.Context, tx mock.Tx, success bool) error { - return fmt.Errorf("post tx failure") + return errors.New("post tx failure") } blockResult, newState, err := s.DeliverBlock(context.Background(), &appmanager.BlockRequest[mock.Tx]{ Height: uint64(1), @@ -201,9 +201,9 @@ func TestSTF(t *testing.T) { t.Run("tx failed and post tx failed", func(t *testing.T) { s := s.clone() addMsgHandlerToSTF(t, &s, func(ctx context.Context, msg *gogotypes.BoolValue) (*gogotypes.BoolValue, error) { - return nil, fmt.Errorf("exec failure") + return nil, errors.New("exec failure") }) - s.postTxExec = func(ctx context.Context, tx mock.Tx, success bool) error { return fmt.Errorf("post tx failure") } + s.postTxExec = func(ctx context.Context, tx mock.Tx, success bool) error { return errors.New("post tx failure") } blockResult, newState, err := s.DeliverBlock(context.Background(), &appmanager.BlockRequest[mock.Tx]{ Height: uint64(1), Time: time.Date(2024, 2, 3, 18, 23, 0, 0, time.UTC), @@ -223,7 +223,7 @@ func TestSTF(t *testing.T) { t.Run("fail validate tx", func(t *testing.T) { // update stf to fail on the validation step s := s.clone() - s.doTxValidation = func(ctx context.Context, tx mock.Tx) error { return fmt.Errorf("failure") } + s.doTxValidation = func(ctx context.Context, tx mock.Tx) error { return errors.New("failure") } blockResult, newState, err := s.DeliverBlock(context.Background(), &appmanager.BlockRequest[mock.Tx]{ Height: uint64(1), Time: time.Date(2024, 2, 3, 18, 23, 0, 0, time.UTC), diff --git a/server/v2/store/commands.go b/server/v2/store/commands.go new file mode 100644 index 000000000000..dc44892f3b89 --- /dev/null +++ b/server/v2/store/commands.go @@ -0,0 +1,163 @@ +package store + +import ( + "fmt" + "os" + "path/filepath" + "strings" + + "github.com/spf13/cobra" + "github.com/spf13/viper" + + "cosmossdk.io/log" + serverv2 "cosmossdk.io/server/v2" + storev2 "cosmossdk.io/store/v2" + "cosmossdk.io/store/v2/db" + "cosmossdk.io/store/v2/root" +) + +// QueryBlockResultsCmd implements the default command for a BlockResults query. +func (s *StoreComponent[T]) PrunesCmd() *cobra.Command { + cmd := &cobra.Command{ + Use: "prune [pruning-method]", + Short: "Prune app history states by keeping the recent heights and deleting old heights", + Long: `Prune app history states by keeping the recent heights and deleting old heights. +The pruning option is provided via the 'pruning' argument or alternatively with '--pruning-keep-recent' + +- default: the last 362880 states are kept +- nothing: all historic states will be saved, nothing will be deleted (i.e. archiving node) +- everything: 2 latest states will be kept +- custom: allow pruning options to be manually specified through 'pruning-keep-recent' + +Note: When the --app-db-backend flag is not specified, the default backend type is 'goleveldb'. +Supported app-db-backend types include 'goleveldb', 'rocksdb', 'pebbledb'.`, + Example: fmt.Sprintf("%s prune custom --pruning-keep-recent 100 --app-db-backend 'goleveldb'", ""), + Args: cobra.RangeArgs(0, 1), + RunE: func(cmd *cobra.Command, args []string) error { + // bind flags to the Context's Viper so we can get pruning options. + vp := serverv2.GetViperFromCmd(cmd) + if err := vp.BindPFlags(cmd.Flags()); err != nil { + return err + } + if err := vp.BindPFlags(cmd.PersistentFlags()); err != nil { + return err + } + + logger := log.NewLogger(cmd.OutOrStdout()) + home, err := cmd.Flags().GetString(serverv2.FlagHome) + if err != nil { + return err + } + + rootStore, keepRecent, err := createRootStore(cmd, home, vp, logger) + if err != nil { + return fmt.Errorf("can not create root store %w", err) + } + + latestHeight, err := rootStore.GetLatestVersion() + if err != nil { + return err + } + + // valid heights should be greater than 0. + if latestHeight <= 0 { + return fmt.Errorf("the database has no valid heights to prune, the latest height: %v", latestHeight) + } + + diff := latestHeight - keepRecent + cmd.Printf("pruning heights up to %v\n", diff) + + err = rootStore.Prune(latestHeight) + if err != nil { + return err + } + + cmd.Println("successfully pruned the application root multi stores") + return nil + }, + } + + cmd.Flags().String(FlagAppDBBackend, "", "The type of database for application and snapshots databases") + cmd.Flags().Uint64(FlagPruningKeepRecent, 0, "Number of recent heights to keep on disk (ignored if pruning is not 'custom')") + + return cmd +} + +func createRootStore(cmd *cobra.Command, rootDir string, v *viper.Viper, logger log.Logger) (storev2.RootStore, uint64, error) { + tempViper := v + + // handle FlagAppDBBackend + var dbType db.DBType + if cmd.Flags().Changed(FlagAppDBBackend) { + dbStr, err := cmd.Flags().GetString(FlagAppDBBackend) + if err != nil { + return nil, 0, err + } + dbType = db.DBType(dbStr) + } else { + dbType = db.DBType(v.GetString("store.app-db-backend")) + } + scRawDb, err := db.NewDB(dbType, "application", filepath.Join(rootDir, "data"), nil) + if err != nil { + panic(err) + } + + // handle KeepRecent & Interval flags + if cmd.Flags().Changed(FlagPruningKeepRecent) { + keepRecent, err := cmd.Flags().GetUint64(FlagPruningKeepRecent) + if err != nil { + return nil, 0, err + } + + // viper has an issue that we could not override subitem then Unmarshal key + // so we can not do viper.Set() as comment below + // https://github.com/spf13/viper/issues/1106 + // Do it by a hacky: overwrite app.toml file then read config again. + + // v.Set("store.options.sc-pruning-option.keep-recent", keepRecent) // entry that read from app.toml + // v.Set("store.options.ss-pruning-option.keep-recent", keepRecent) + + err = overrideKeepRecent(filepath.Join(rootDir, "config"), keepRecent) + if err != nil { + return nil, 0, err + } + + tempViper, err = serverv2.ReadConfig(filepath.Join(rootDir, "config")) + if err != nil { + return nil, 0, err + } + } + + storeOpts := root.DefaultStoreOptions() + if v != nil && v.Sub("store.options") != nil { + if err := v.Sub("store.options").Unmarshal(&storeOpts); err != nil { + return nil, 0, fmt.Errorf("failed to store options: %w", err) + } + } + + store, err := root.CreateRootStore(&root.FactoryOptions{ + Logger: logger, + RootDir: rootDir, + Options: storeOpts, + SCRawDB: scRawDb, + }) + + return store, tempViper.GetUint64("store.options.sc-pruning-option.keep-recent"), err +} + +func overrideKeepRecent(configPath string, keepRecent uint64) error { + bz, err := os.ReadFile(filepath.Join(configPath, "app.toml")) + if err != nil { + return err + } + lines := strings.Split(string(bz), "\n") + + for i, line := range lines { + if strings.Contains(line, "keep-recent") { + lines[i] = fmt.Sprintf("keep-recent = %d", keepRecent) + } + } + output := strings.Join(lines, "\n") + + return os.WriteFile(filepath.Join(configPath, "app.toml"), []byte(output), 0o600) +} diff --git a/server/v2/store/config.go b/server/v2/store/config.go new file mode 100644 index 000000000000..457bfa9383cb --- /dev/null +++ b/server/v2/store/config.go @@ -0,0 +1,17 @@ +package store + +import ( + "cosmossdk.io/store/v2/root" +) + +func DefaultConfig() *Config { + return &Config{ + AppDBBackend: "goleveldb", + Options: root.DefaultStoreOptions(), + } +} + +type Config struct { + AppDBBackend string `mapstructure:"app-db-backend" toml:"app-db-backend" comment:"The type of database for application and snapshots databases."` + Options root.Options `mapstructure:"options" toml:"options"` +} diff --git a/server/v2/store/flags.go b/server/v2/store/flags.go new file mode 100644 index 000000000000..9bf1af5282f4 --- /dev/null +++ b/server/v2/store/flags.go @@ -0,0 +1,6 @@ +package store + +const ( + FlagAppDBBackend = "app-db-backend" + FlagPruningKeepRecent = "keep-recent" +) diff --git a/server/v2/store/server.go b/server/v2/store/server.go new file mode 100644 index 000000000000..c7a1f9035d10 --- /dev/null +++ b/server/v2/store/server.go @@ -0,0 +1,76 @@ +package store + +import ( + "context" + "fmt" + + "github.com/spf13/cobra" + "github.com/spf13/viper" + + "cosmossdk.io/core/transaction" + "cosmossdk.io/log" + serverv2 "cosmossdk.io/server/v2" +) + +// StoreComponent manages store config +// and contains prune & snapshot commands +type StoreComponent[T transaction.Tx] struct { + config *Config +} + +func New[T transaction.Tx]() *StoreComponent[T] { + return &StoreComponent[T]{} +} + +func (s *StoreComponent[T]) Init(appI serverv2.AppI[T], v *viper.Viper, logger log.Logger) error { + cfg := DefaultConfig() + if v != nil { + if err := v.Sub(s.Name()).Unmarshal(&cfg); err != nil { + return fmt.Errorf("failed to unmarshal config: %w", err) + } + } + s.config = cfg + return nil +} + +func (s *StoreComponent[T]) Name() string { + return "store" +} + +func (s *StoreComponent[T]) Start(ctx context.Context) error { + return nil +} + +func (s *StoreComponent[T]) Stop(ctx context.Context) error { + return nil +} + +func (s *StoreComponent[T]) GetCommands() []*cobra.Command { + return []*cobra.Command{ + s.PrunesCmd(), + } +} + +func (s *StoreComponent[T]) GetTxs() []*cobra.Command { + return nil +} + +func (s *StoreComponent[T]) GetQueries() []*cobra.Command { + return nil +} + +func (s *StoreComponent[T]) CLICommands() serverv2.CLIConfig { + return serverv2.CLIConfig{ + Commands: []*cobra.Command{ + s.PrunesCmd(), + }, + } +} + +func (g *StoreComponent[T]) Config() any { + if g.config == nil || g.config == (&Config{}) { + return DefaultConfig() + } + + return g.config +} diff --git a/server/v2/testdata/app.toml b/server/v2/testdata/app.toml index 34fb5b0b0239..20482ac44282 100644 --- a/server/v2/testdata/app.toml +++ b/server/v2/testdata/app.toml @@ -1,6 +1,6 @@ [grpc] # Enable defines if the gRPC server should be enabled. -enable = true +enable = false # Address defines the gRPC server address to bind to. address = 'localhost:9090' # MaxRecvMsgSize defines the max message size in bytes the server can receive. diff --git a/server/v2/types.go b/server/v2/types.go index 3382d1b27b6b..978b46b78810 100644 --- a/server/v2/types.go +++ b/server/v2/types.go @@ -13,9 +13,10 @@ import ( type AppCreator[T transaction.Tx] func(log.Logger, *viper.Viper) AppI[T] type AppI[T transaction.Tx] interface { + Name() string + InterfaceRegistry() coreapp.InterfaceRegistry GetAppManager() *appmanager.AppManager[T] GetConsensusAuthority() string - InterfaceRegistry() coreapp.InterfaceRegistry - GetGRPCQueryDecoders() map[string]func(requestBytes []byte) (gogoproto.Message, error) + GetGPRCMethodsToMessageMap() map[string]func() gogoproto.Message GetStore() any } diff --git a/server/v2/util.go b/server/v2/util.go index dfec4cd5f18d..72335621b44b 100644 --- a/server/v2/util.go +++ b/server/v2/util.go @@ -10,7 +10,6 @@ import ( "github.com/spf13/viper" corectx "cosmossdk.io/core/context" - corelog "cosmossdk.io/core/log" "cosmossdk.io/log" ) @@ -40,9 +39,9 @@ func GetViperFromCmd(cmd *cobra.Command) *viper.Viper { return v } -func GetLoggerFromCmd(cmd *cobra.Command) corelog.Logger { +func GetLoggerFromCmd(cmd *cobra.Command) log.Logger { v := cmd.Context().Value(corectx.LoggerContextKey) - logger, ok := v.(corelog.Logger) + logger, ok := v.(log.Logger) if !ok { panic(fmt.Sprintf("incorrect logger type %T: expected log.Logger. Have you forgot to set the logger in the command context?", v)) } diff --git a/simapp/ante.go b/simapp/ante.go index f39b8369ba00..6a12eabecfd5 100644 --- a/simapp/ante.go +++ b/simapp/ante.go @@ -39,7 +39,7 @@ func NewAnteHandler(options HandlerOptions) (sdk.AnteHandler, error) { ante.NewExtensionOptionsDecorator(options.ExtensionOptionChecker), ante.NewValidateBasicDecorator(options.Environment), ante.NewTxTimeoutHeightDecorator(options.Environment), - ante.NewUnorderedTxDecorator(unorderedtx.DefaultMaxUnOrderedTTL, options.TxManager, options.Environment, ante.DefaultSha256Cost), + ante.NewUnorderedTxDecorator(unorderedtx.DefaultMaxTimeoutDuration, options.TxManager, options.Environment, ante.DefaultSha256Cost), ante.NewValidateMemoDecorator(options.AccountKeeper), ante.NewConsumeGasForTxSizeDecorator(options.AccountKeeper), ante.NewDeductFeeDecorator(options.AccountKeeper, options.BankKeeper, options.FeegrantKeeper, options.TxFeeChecker), diff --git a/simapp/app.go b/simapp/app.go index 64232666e565..6c2424e29c60 100644 --- a/simapp/app.go +++ b/simapp/app.go @@ -19,8 +19,7 @@ import ( reflectionv1 "cosmossdk.io/api/cosmos/reflection/v1" "cosmossdk.io/client/v2/autocli" clienthelpers "cosmossdk.io/client/v2/helpers" - "cosmossdk.io/core/appmodule" - "cosmossdk.io/core/log" + "cosmossdk.io/log" storetypes "cosmossdk.io/store/types" "cosmossdk.io/x/accounts" "cosmossdk.io/x/accounts/accountstd" @@ -52,7 +51,6 @@ import ( "cosmossdk.io/x/consensus" consensusparamkeeper "cosmossdk.io/x/consensus/keeper" consensusparamtypes "cosmossdk.io/x/consensus/types" - consensustypes "cosmossdk.io/x/consensus/types" distr "cosmossdk.io/x/distribution" distrkeeper "cosmossdk.io/x/distribution/keeper" distrtypes "cosmossdk.io/x/distribution/types" @@ -68,6 +66,7 @@ import ( "cosmossdk.io/x/gov" govkeeper "cosmossdk.io/x/gov/keeper" govtypes "cosmossdk.io/x/gov/types" + govv1 "cosmossdk.io/x/gov/types/v1" govv1beta1 "cosmossdk.io/x/gov/types/v1beta1" "cosmossdk.io/x/group" groupkeeper "cosmossdk.io/x/group/keeper" @@ -81,7 +80,6 @@ import ( "cosmossdk.io/x/protocolpool" poolkeeper "cosmossdk.io/x/protocolpool/keeper" pooltypes "cosmossdk.io/x/protocolpool/types" - protocolpooltypes "cosmossdk.io/x/protocolpool/types" "cosmossdk.io/x/slashing" slashingkeeper "cosmossdk.io/x/slashing/keeper" slashingtypes "cosmossdk.io/x/slashing/types" @@ -126,15 +124,16 @@ var ( // module account permissions maccPerms = map[string][]string{ - authtypes.FeeCollectorName: nil, - distrtypes.ModuleName: nil, - pooltypes.ModuleName: nil, - pooltypes.StreamAccount: nil, - minttypes.ModuleName: {authtypes.Minter}, - stakingtypes.BondedPoolName: {authtypes.Burner, authtypes.Staking}, - stakingtypes.NotBondedPoolName: {authtypes.Burner, authtypes.Staking}, - govtypes.ModuleName: {authtypes.Burner}, - nft.ModuleName: nil, + authtypes.FeeCollectorName: nil, + distrtypes.ModuleName: nil, + pooltypes.ModuleName: nil, + pooltypes.StreamAccount: nil, + pooltypes.ProtocolPoolDistrAccount: nil, + minttypes.ModuleName: {authtypes.Minter}, + stakingtypes.BondedPoolName: {authtypes.Burner, authtypes.Staking}, + stakingtypes.NotBondedPoolName: {authtypes.Burner, authtypes.Staking}, + govtypes.ModuleName: {authtypes.Burner}, + nft.ModuleName: nil, } ) @@ -215,6 +214,10 @@ func NewSimApp( signingCtx := interfaceRegistry.SigningContext() txConfig := authtx.NewTxConfig(appCodec, signingCtx.AddressCodec(), signingCtx.ValidatorAddressCodec(), authtx.DefaultSignModes) + if err := signingCtx.Validate(); err != nil { + panic(err) + } + std.RegisterLegacyAminoCodec(legacyAmino) std.RegisterInterfaces(interfaceRegistry) @@ -249,7 +252,8 @@ func NewSimApp( voteExtHandler := NewVoteExtensionHandler() voteExtHandler.SetHandlers(bApp) } - baseAppOptions = append(baseAppOptions, voteExtOp, baseapp.SetOptimisticExecution()) + baseAppOptions = append(baseAppOptions, voteExtOp, baseapp.SetOptimisticExecution(), + baseapp.SetIncludeNestedMsgsGas([]sdk.Msg{&govv1.MsgSubmitProposal{}})) bApp := baseapp.NewBaseApp(appName, logger, db, txConfig.TxDecoder(), baseAppOptions...) bApp.SetCommitMultiStoreTracer(traceStore) @@ -356,7 +360,7 @@ func NewSimApp( app.PoolKeeper = poolkeeper.NewKeeper(appCodec, runtime.NewEnvironment(runtime.NewKVStoreService(keys[pooltypes.StoreKey]), logger.With(log.ModuleKey, "x/protocolpool")), app.AuthKeeper, app.BankKeeper, app.StakingKeeper, authtypes.NewModuleAddress(govtypes.ModuleName).String()) - app.DistrKeeper = distrkeeper.NewKeeper(appCodec, runtime.NewEnvironment(runtime.NewKVStoreService(keys[distrtypes.StoreKey]), logger.With(log.ModuleKey, "x/distribution")), app.AuthKeeper, app.BankKeeper, app.StakingKeeper, app.PoolKeeper, cometService, authtypes.FeeCollectorName, authtypes.NewModuleAddress(govtypes.ModuleName).String()) + app.DistrKeeper = distrkeeper.NewKeeper(appCodec, runtime.NewEnvironment(runtime.NewKVStoreService(keys[distrtypes.StoreKey]), logger.With(log.ModuleKey, "x/distribution")), app.AuthKeeper, app.BankKeeper, app.StakingKeeper, cometService, authtypes.FeeCollectorName, authtypes.NewModuleAddress(govtypes.ModuleName).String()) app.SlashingKeeper = slashingkeeper.NewKeeper(runtime.NewEnvironment(runtime.NewKVStoreService(keys[slashingtypes.StoreKey]), logger.With(log.ModuleKey, "x/slashing")), appCodec, legacyAmino, app.StakingKeeper, authtypes.NewModuleAddress(govtypes.ModuleName).String(), @@ -439,28 +443,28 @@ func NewSimApp( // NOTE: Any module instantiated in the module manager that is later modified // must be passed by reference here. - app.ModuleManager = module.NewManagerFromMap(map[string]appmodule.AppModule{ - genutiltypes.ModuleName: genutil.NewAppModule(appCodec, app.AuthKeeper, app.StakingKeeper, app, txConfig, genutiltypes.DefaultMessageValidator), - accounts.ModuleName: accounts.NewAppModule(appCodec, app.AccountsKeeper), - authtypes.ModuleName: auth.NewAppModule(appCodec, app.AuthKeeper, app.AccountsKeeper, authsims.RandomGenesisAccounts), - vestingtypes.ModuleName: vesting.NewAppModule(app.AuthKeeper, app.BankKeeper), - banktypes.ModuleName: bank.NewAppModule(appCodec, app.BankKeeper, app.AuthKeeper), - feegrant.ModuleName: feegrantmodule.NewAppModule(appCodec, app.AuthKeeper, app.BankKeeper, app.FeeGrantKeeper, app.interfaceRegistry), - govtypes.ModuleName: gov.NewAppModule(appCodec, &app.GovKeeper, app.AuthKeeper, app.BankKeeper, app.PoolKeeper), - minttypes.ModuleName: mint.NewAppModule(appCodec, app.MintKeeper, app.AuthKeeper, nil), - slashingtypes.ModuleName: slashing.NewAppModule(appCodec, app.SlashingKeeper, app.AuthKeeper, app.BankKeeper, app.StakingKeeper, app.interfaceRegistry, cometService), - distrtypes.ModuleName: distr.NewAppModule(appCodec, app.DistrKeeper, app.AuthKeeper, app.BankKeeper, app.StakingKeeper, app.PoolKeeper), - stakingtypes.ModuleName: staking.NewAppModule(appCodec, app.StakingKeeper, app.AuthKeeper, app.BankKeeper), - upgradetypes.ModuleName: upgrade.NewAppModule(app.UpgradeKeeper), - evidencetypes.ModuleName: evidence.NewAppModule(appCodec, app.EvidenceKeeper, cometService), - authz.ModuleName: authzmodule.NewAppModule(appCodec, app.AuthzKeeper, app.AuthKeeper, app.BankKeeper, app.interfaceRegistry), - group.ModuleName: groupmodule.NewAppModule(appCodec, app.GroupKeeper, app.AuthKeeper, app.BankKeeper, app.interfaceRegistry), - nft.ModuleName: nftmodule.NewAppModule(appCodec, app.NFTKeeper, app.AuthKeeper, app.BankKeeper, app.interfaceRegistry), - consensustypes.ModuleName: consensus.NewAppModule(appCodec, app.ConsensusParamsKeeper), - circuittypes.ModuleName: circuit.NewAppModule(appCodec, app.CircuitKeeper), - protocolpooltypes.ModuleName: protocolpool.NewAppModule(appCodec, app.PoolKeeper, app.AuthKeeper, app.BankKeeper), - epochstypes.ModuleName: epochs.NewAppModule(appCodec, app.EpochsKeeper), - }) + app.ModuleManager = module.NewManager( + genutil.NewAppModule(appCodec, app.AuthKeeper, app.StakingKeeper, app, txConfig, genutiltypes.DefaultMessageValidator), + accounts.NewAppModule(appCodec, app.AccountsKeeper), + auth.NewAppModule(appCodec, app.AuthKeeper, app.AccountsKeeper, authsims.RandomGenesisAccounts), + vesting.NewAppModule(app.AuthKeeper, app.BankKeeper), + bank.NewAppModule(appCodec, app.BankKeeper, app.AuthKeeper), + feegrantmodule.NewAppModule(appCodec, app.AuthKeeper, app.BankKeeper, app.FeeGrantKeeper, app.interfaceRegistry), + gov.NewAppModule(appCodec, &app.GovKeeper, app.AuthKeeper, app.BankKeeper, app.PoolKeeper), + mint.NewAppModule(appCodec, app.MintKeeper, app.AuthKeeper, nil), + slashing.NewAppModule(appCodec, app.SlashingKeeper, app.AuthKeeper, app.BankKeeper, app.StakingKeeper, app.interfaceRegistry, cometService), + distr.NewAppModule(appCodec, app.DistrKeeper, app.AuthKeeper, app.BankKeeper, app.StakingKeeper), + staking.NewAppModule(appCodec, app.StakingKeeper, app.AuthKeeper, app.BankKeeper), + upgrade.NewAppModule(app.UpgradeKeeper), + evidence.NewAppModule(appCodec, app.EvidenceKeeper, cometService), + authzmodule.NewAppModule(appCodec, app.AuthzKeeper, app.AuthKeeper, app.BankKeeper, app.interfaceRegistry), + groupmodule.NewAppModule(appCodec, app.GroupKeeper, app.AuthKeeper, app.BankKeeper, app.interfaceRegistry), + nftmodule.NewAppModule(appCodec, app.NFTKeeper, app.AuthKeeper, app.BankKeeper, app.interfaceRegistry), + consensus.NewAppModule(appCodec, app.ConsensusParamsKeeper), + circuit.NewAppModule(appCodec, app.CircuitKeeper), + protocolpool.NewAppModule(appCodec, app.PoolKeeper, app.AuthKeeper, app.BankKeeper), + epochs.NewAppModule(appCodec, app.EpochsKeeper), + ) app.ModuleManager.RegisterLegacyAminoCodec(legacyAmino) app.ModuleManager.RegisterInterfaces(interfaceRegistry) @@ -476,6 +480,7 @@ func NewSimApp( app.ModuleManager.SetOrderBeginBlockers( minttypes.ModuleName, distrtypes.ModuleName, + pooltypes.ModuleName, slashingtypes.ModuleName, evidencetypes.ModuleName, stakingtypes.ModuleName, diff --git a/simapp/app_config.go b/simapp/app_config.go index 4eb39f1766c7..e92ac2ce03fe 100644 --- a/simapp/app_config.go +++ b/simapp/app_config.go @@ -81,6 +81,7 @@ var ( {Account: distrtypes.ModuleName}, {Account: pooltypes.ModuleName}, {Account: pooltypes.StreamAccount}, + {Account: pooltypes.ProtocolPoolDistrAccount}, {Account: minttypes.ModuleName, Permissions: []string{authtypes.Minter}}, {Account: stakingtypes.BondedPoolName, Permissions: []string{authtypes.Burner, stakingtypes.ModuleName}}, {Account: stakingtypes.NotBondedPoolName, Permissions: []string{authtypes.Burner, stakingtypes.ModuleName}}, @@ -119,6 +120,7 @@ var ( BeginBlockers: []string{ minttypes.ModuleName, distrtypes.ModuleName, + pooltypes.ModuleName, slashingtypes.ModuleName, evidencetypes.ModuleName, stakingtypes.ModuleName, diff --git a/simapp/app_di.go b/simapp/app_di.go index 52c9917fd186..63beee09ab7e 100644 --- a/simapp/app_di.go +++ b/simapp/app_di.go @@ -137,7 +137,6 @@ func NewSimApp( appOpts, // supply the logger logger, - // ADVANCED CONFIGURATION // diff --git a/simapp/go.mod b/simapp/go.mod index c5238167f215..1545f860cec2 100644 --- a/simapp/go.mod +++ b/simapp/go.mod @@ -7,8 +7,8 @@ require ( cosmossdk.io/client/v2 v2.0.0-20230630094428-02b760776860 cosmossdk.io/collections v0.4.0 cosmossdk.io/core v0.12.1-0.20231114100755-569e3ff6a0d7 - cosmossdk.io/core/testing v0.0.0-00010101000000-000000000000 - cosmossdk.io/depinject v1.0.0-alpha.4 + cosmossdk.io/core/testing v0.0.0-00010101000000-000000000000 // indirect + cosmossdk.io/depinject v1.0.0 cosmossdk.io/log v1.3.1 cosmossdk.io/math v1.3.0 cosmossdk.io/store v1.1.1-0.20240418092142-896cdf1971bc @@ -37,7 +37,7 @@ require ( github.com/cometbft/cometbft/api v1.0.0-rc.1 github.com/cosmos/cosmos-db v1.0.2 // this version is not used as it is always replaced by the latest Cosmos SDK version - github.com/cosmos/cosmos-sdk v0.51.0 + github.com/cosmos/cosmos-sdk v0.53.0 github.com/cosmos/gogoproto v1.5.0 github.com/golang/mock v1.6.0 github.com/spf13/cast v1.6.0 @@ -87,7 +87,7 @@ require ( github.com/cosmos/crypto v0.1.2 // indirect github.com/cosmos/go-bip39 v1.0.0 // indirect github.com/cosmos/gogogateway v1.2.0 // indirect - github.com/cosmos/iavl v1.2.0 // indirect + github.com/cosmos/iavl v1.2.1-0.20240725141113-7adc688cf179 // indirect github.com/cosmos/ics23/go v0.10.0 // indirect github.com/cosmos/ledger-cosmos-go v0.13.3 // indirect github.com/creachadair/atomicfile v0.3.4 // indirect @@ -244,8 +244,6 @@ replace ( cosmossdk.io/collections => ../collections cosmossdk.io/core => ../core cosmossdk.io/core/testing => ../core/testing - cosmossdk.io/depinject => ../depinject - cosmossdk.io/log => ../log cosmossdk.io/store => ../store cosmossdk.io/tools/confix => ../tools/confix cosmossdk.io/x/accounts => ../x/accounts diff --git a/simapp/go.sum b/simapp/go.sum index 11ad33d741a0..53269104f8f7 100644 --- a/simapp/go.sum +++ b/simapp/go.sum @@ -192,8 +192,12 @@ cloud.google.com/go/webrisk v1.4.0/go.mod h1:Hn8X6Zr+ziE2aNd8SliSDWpEnSS1u4R9+xX cloud.google.com/go/webrisk v1.5.0/go.mod h1:iPG6fr52Tv7sGk0H6qUFzmL3HHZev1htXuWDEEsqMTg= cloud.google.com/go/workflows v1.6.0/go.mod h1:6t9F5h/unJz41YqfBmqSASJSXccBLtD1Vwf+KmJENM0= cloud.google.com/go/workflows v1.7.0/go.mod h1:JhSrZuVZWuiDfKEFxU0/F1PQjmpnpcoISEXH2bcHC3M= +cosmossdk.io/depinject v1.0.0 h1:dQaTu6+O6askNXO06+jyeUAnF2/ssKwrrszP9t5q050= +cosmossdk.io/depinject v1.0.0/go.mod h1:zxK/h3HgHoA/eJVtiSsoaRaRA2D5U4cJ5thIG4ssbB8= cosmossdk.io/errors v1.0.1 h1:bzu+Kcr0kS/1DuPBtUFdWjzLqyUuCiyHjyJB6srBV/0= cosmossdk.io/errors v1.0.1/go.mod h1:MeelVSZThMi4bEakzhhhE/CKqVv3nOJDA25bIqRDu/U= +cosmossdk.io/log v1.3.1 h1:UZx8nWIkfbbNEWusZqzAx3ZGvu54TZacWib3EzUYmGI= +cosmossdk.io/log v1.3.1/go.mod h1:2/dIomt8mKdk6vl3OWJcPk2be3pGOS8OQaLUM/3/tCM= cosmossdk.io/math v1.3.0 h1:RC+jryuKeytIiictDslBP9i1fhkVm6ZDmZEoNP316zE= cosmossdk.io/math v1.3.0/go.mod h1:vnRTxewy+M7BtXBNFybkuhSH4WfedVAAnERHgVFhp3k= cosmossdk.io/schema v0.1.1 h1:I0M6pgI7R10nq+/HCQfbO6BsGBZA8sQy+duR1Y3aKcA= @@ -317,8 +321,8 @@ github.com/cosmos/gogogateway v1.2.0/go.mod h1:iQpLkGWxYcnCdz5iAdLcRBSw3h7NXeOkZ github.com/cosmos/gogoproto v1.4.2/go.mod h1:cLxOsn1ljAHSV527CHOtaIP91kK6cCrZETRBrkzItWU= github.com/cosmos/gogoproto v1.5.0 h1:SDVwzEqZDDBoslaeZg+dGE55hdzHfgUA40pEanMh52o= github.com/cosmos/gogoproto v1.5.0/go.mod h1:iUM31aofn3ymidYG6bUR5ZFrk+Om8p5s754eMUcyp8I= -github.com/cosmos/iavl v1.2.0 h1:kVxTmjTh4k0Dh1VNL046v6BXqKziqMDzxo93oh3kOfM= -github.com/cosmos/iavl v1.2.0/go.mod h1:HidWWLVAtODJqFD6Hbne2Y0q3SdxByJepHUOeoH4LiI= +github.com/cosmos/iavl v1.2.1-0.20240725141113-7adc688cf179 h1:wmwDn7V3RodN9auB3FooSQxs46nHVE3u0mb87TJkZFE= +github.com/cosmos/iavl v1.2.1-0.20240725141113-7adc688cf179/go.mod h1:GiM43q0pB+uG53mLxLDzimxM9l/5N9UuSY3/D0huuVw= github.com/cosmos/ics23/go v0.10.0 h1:iXqLLgp2Lp+EdpIuwXTYIQU+AiHj9mOC2X9ab++bZDM= github.com/cosmos/ics23/go v0.10.0/go.mod h1:ZfJSmng/TBNTBkFemHHHj5YY7VAU/MBU980F4VU1NG0= github.com/cosmos/keyring v1.2.0 h1:8C1lBP9xhImmIabyXW4c3vFjjLiBdGCmfLUfeZlV1Yo= diff --git a/simapp/sim_bench_test.go b/simapp/sim_bench_test.go index 914e7a40c5ce..4a7832c8ec14 100644 --- a/simapp/sim_bench_test.go +++ b/simapp/sim_bench_test.go @@ -6,7 +6,7 @@ import ( "os" "testing" - coretesting "cosmossdk.io/core/testing" + "cosmossdk.io/log" "github.com/cosmos/cosmos-sdk/testutils/sims" flag "github.com/spf13/pflag" @@ -60,7 +60,7 @@ func BenchmarkFullAppSimulation(b *testing.B) { // run randomized simulation simParams, simErr := simulation.SimulateFromSeedX( b, - coretesting.NewNopLogger(), + log.NewNopLogger(), os.Stdout, app.BaseApp, simtestutil.AppStateFn(app.AppCodec(), app.AuthKeeper.AddressCodec(), app.StakingKeeper.ValidatorAddressCodec(), app.SimulationManager(), app.DefaultGenesis()), diff --git a/simapp/test_helpers.go b/simapp/test_helpers.go index bce25b283242..dc74a4e47e16 100644 --- a/simapp/test_helpers.go +++ b/simapp/test_helpers.go @@ -12,8 +12,7 @@ import ( dbm "github.com/cosmos/cosmos-db" "github.com/stretchr/testify/require" - "cosmossdk.io/core/log" - coretesting "cosmossdk.io/core/testing" + "cosmossdk.io/log" sdkmath "cosmossdk.io/math" pruningtypes "cosmossdk.io/store/pruning/types" authtypes "cosmossdk.io/x/auth/types" @@ -47,7 +46,7 @@ func setup(withGenesis bool, invCheckPeriod uint) (*SimApp, GenesisState) { appOptions[flags.FlagHome] = DefaultNodeHome appOptions[server.FlagInvCheckPeriod] = invCheckPeriod - app := NewSimApp(coretesting.NewNopLogger(), db, nil, true, appOptions) + app := NewSimApp(log.NewNopLogger(), db, nil, true, appOptions) if withGenesis { return app, app.DefaultGenesis() } @@ -226,7 +225,7 @@ func NewTestNetworkFixture() network.TestFixture { } defer os.RemoveAll(dir) - app := NewSimApp(coretesting.NewNopLogger(), dbm.NewMemDB(), nil, true, simtestutil.NewAppOptionsWithFlagHome(dir)) + app := NewSimApp(log.NewNopLogger(), dbm.NewMemDB(), nil, true, simtestutil.NewAppOptionsWithFlagHome(dir)) appCtr := func(val network.ValidatorI) servertypes.Application { return NewSimApp( diff --git a/simapp/v2/app_config.go b/simapp/v2/app_config.go index aff5f923093c..c3e5e0492935 100644 --- a/simapp/v2/app_config.go +++ b/simapp/v2/app_config.go @@ -77,6 +77,7 @@ var ( {Account: distrtypes.ModuleName}, {Account: pooltypes.ModuleName}, {Account: pooltypes.StreamAccount}, + {Account: pooltypes.ProtocolPoolDistrAccount}, {Account: minttypes.ModuleName, Permissions: []string{authtypes.Minter}}, {Account: stakingtypes.BondedPoolName, Permissions: []string{authtypes.Burner, stakingtypes.ModuleName}}, {Account: stakingtypes.NotBondedPoolName, Permissions: []string{authtypes.Burner, stakingtypes.ModuleName}}, @@ -115,6 +116,7 @@ var ( BeginBlockers: []string{ minttypes.ModuleName, distrtypes.ModuleName, + pooltypes.ModuleName, slashingtypes.ModuleName, evidencetypes.ModuleName, stakingtypes.ModuleName, diff --git a/simapp/v2/app_di.go b/simapp/v2/app_di.go index 5f4b2455bc8d..7cde4042f3c8 100644 --- a/simapp/v2/app_di.go +++ b/simapp/v2/app_di.go @@ -2,22 +2,17 @@ package simapp import ( _ "embed" - "path/filepath" "github.com/spf13/viper" clienthelpers "cosmossdk.io/client/v2/helpers" coreapp "cosmossdk.io/core/app" "cosmossdk.io/core/legacy" - "cosmossdk.io/core/log" "cosmossdk.io/core/transaction" "cosmossdk.io/depinject" + "cosmossdk.io/log" "cosmossdk.io/runtime/v2" serverv2 "cosmossdk.io/server/v2" - "cosmossdk.io/store/v2" - "cosmossdk.io/store/v2/commitment/iavl" - "cosmossdk.io/store/v2/db" - "cosmossdk.io/store/v2/root" "cosmossdk.io/x/accounts" authkeeper "cosmossdk.io/x/auth/keeper" authzkeeper "cosmossdk.io/x/authz/keeper" @@ -41,6 +36,7 @@ import ( "github.com/cosmos/cosmos-sdk/codec" codectypes "github.com/cosmos/cosmos-sdk/codec/types" "github.com/cosmos/cosmos-sdk/std" + _ "github.com/cosmos/cosmos-sdk/x/genutil" ) // DefaultNodeHome default home directories for the application daemon @@ -97,10 +93,6 @@ func NewSimApp[T transaction.Tx]( viper *viper.Viper, ) *SimApp[T] { viper.Set(serverv2.FlagHome, DefaultNodeHome) // TODO possibly set earlier when viper is created - scRawDb, err := db.NewGoLevelDB("application", filepath.Join(DefaultNodeHome, "data"), nil) - if err != nil { - panic(err) - } var ( app = &SimApp[T]{} appBuilder *runtime.AppBuilder[T] @@ -110,21 +102,6 @@ func NewSimApp[T transaction.Tx]( AppConfig(), depinject.Supply( logger, - &root.FactoryOptions{ - Logger: logger, - RootDir: DefaultNodeHome, - SSType: 0, - SCType: 0, - SCPruningOption: &store.PruningOption{ - KeepRecent: 0, - Interval: 0, - }, - IavlConfig: &iavl.Config{ - CacheSize: 100_000, - SkipFastStorageUpgrade: true, - }, - SCRawDB: scRawDb, - }, viper, // ADVANCED CONFIGURATION @@ -206,6 +183,7 @@ func NewSimApp[T transaction.Tx]( panic(err) } + var err error app.App, err = appBuilder.Build() if err != nil { panic(err) diff --git a/simapp/v2/go.mod b/simapp/v2/go.mod index a275758c69fc..82f48388a049 100644 --- a/simapp/v2/go.mod +++ b/simapp/v2/go.mod @@ -6,13 +6,13 @@ require ( cosmossdk.io/api v0.7.5 cosmossdk.io/client/v2 v2.0.0-00010101000000-000000000000 cosmossdk.io/core v0.12.1-0.20231114100755-569e3ff6a0d7 - cosmossdk.io/depinject v1.0.0-alpha.4 + cosmossdk.io/depinject v1.0.0 cosmossdk.io/log v1.3.1 cosmossdk.io/math v1.3.0 cosmossdk.io/runtime/v2 v2.0.0-00010101000000-000000000000 - cosmossdk.io/server/v2 v2.0.0-00010101000000-000000000000 + cosmossdk.io/server/v2 v2.0.0-20240718121635-a877e3e8048a cosmossdk.io/server/v2/cometbft v0.0.0-00010101000000-000000000000 - cosmossdk.io/store/v2 v2.0.0 + cosmossdk.io/store/v2 v2.0.0 // indirect 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 @@ -34,7 +34,7 @@ require ( github.com/cometbft/cometbft v1.0.0-rc1 github.com/cosmos/cosmos-db v1.0.2 // this version is not used as it is always replaced by the latest Cosmos SDK version - github.com/cosmos/cosmos-sdk v0.51.0 + github.com/cosmos/cosmos-sdk v0.53.0 github.com/spf13/cobra v1.8.1 github.com/spf13/pflag v1.0.5 github.com/spf13/viper v1.19.0 @@ -42,7 +42,7 @@ require ( google.golang.org/protobuf v1.34.2 ) -require cosmossdk.io/core/testing v0.0.0-00010101000000-000000000000 +require cosmossdk.io/core/testing v0.0.0-00010101000000-000000000000 // indirect require ( buf.build/gen/go/cometbft/cometbft/protocolbuffers/go v1.34.2-20240701160653-fedbb9acfd2f.2 // indirect @@ -55,6 +55,7 @@ require ( cloud.google.com/go/storage v1.42.0 // indirect cosmossdk.io/collections v0.4.0 // indirect 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-00010101000000-000000000000 // indirect cosmossdk.io/server/v2/stf v0.0.0-00010101000000-000000000000 // indirect @@ -92,7 +93,7 @@ require ( github.com/cosmos/go-bip39 v1.0.0 // indirect github.com/cosmos/gogogateway v1.2.0 // indirect github.com/cosmos/gogoproto v1.5.0 // indirect - github.com/cosmos/iavl v1.2.0 // indirect + github.com/cosmos/iavl v1.2.1-0.20240725141113-7adc688cf179 // indirect github.com/cosmos/ics23/go v0.10.0 // indirect github.com/cosmos/ledger-cosmos-go v0.13.3 // indirect github.com/creachadair/atomicfile v0.3.4 // indirect @@ -250,7 +251,6 @@ replace ( cosmossdk.io/client/v2 => ../../client/v2 cosmossdk.io/collections => ../../collections cosmossdk.io/core => ../../core - cosmossdk.io/depinject => ../../depinject cosmossdk.io/tools/confix => ../../tools/confix cosmossdk.io/x/accounts => ../../x/accounts cosmossdk.io/x/accounts/defaults/lockup => ../../x/accounts/defaults/lockup @@ -292,7 +292,6 @@ replace ( replace ( cosmossdk.io/api => ../../api cosmossdk.io/core/testing => ../../core/testing - cosmossdk.io/log => ../../log cosmossdk.io/runtime/v2 => ../../runtime/v2 cosmossdk.io/server/v2 => ../../server/v2 cosmossdk.io/server/v2/appmanager => ../../server/v2/appmanager diff --git a/simapp/v2/go.sum b/simapp/v2/go.sum index 3e3ba62fee8d..6e9aa3b16e96 100644 --- a/simapp/v2/go.sum +++ b/simapp/v2/go.sum @@ -192,8 +192,14 @@ cloud.google.com/go/webrisk v1.4.0/go.mod h1:Hn8X6Zr+ziE2aNd8SliSDWpEnSS1u4R9+xX cloud.google.com/go/webrisk v1.5.0/go.mod h1:iPG6fr52Tv7sGk0H6qUFzmL3HHZev1htXuWDEEsqMTg= cloud.google.com/go/workflows v1.6.0/go.mod h1:6t9F5h/unJz41YqfBmqSASJSXccBLtD1Vwf+KmJENM0= cloud.google.com/go/workflows v1.7.0/go.mod h1:JhSrZuVZWuiDfKEFxU0/F1PQjmpnpcoISEXH2bcHC3M= +cosmossdk.io/depinject v1.0.0 h1:dQaTu6+O6askNXO06+jyeUAnF2/ssKwrrszP9t5q050= +cosmossdk.io/depinject v1.0.0/go.mod h1:zxK/h3HgHoA/eJVtiSsoaRaRA2D5U4cJ5thIG4ssbB8= cosmossdk.io/errors v1.0.1 h1:bzu+Kcr0kS/1DuPBtUFdWjzLqyUuCiyHjyJB6srBV/0= cosmossdk.io/errors v1.0.1/go.mod h1:MeelVSZThMi4bEakzhhhE/CKqVv3nOJDA25bIqRDu/U= +cosmossdk.io/errors/v2 v2.0.0-20240731132947-df72853b3ca5 h1:IQNdY2kB+k+1OM2DvqFG1+UgeU1JzZrWtwuWzI3ZfwA= +cosmossdk.io/errors/v2 v2.0.0-20240731132947-df72853b3ca5/go.mod h1:0CuYKkFHxc1vw2JC+t21THBCALJVROrWVR/3PQ1urpc= +cosmossdk.io/log v1.3.1 h1:UZx8nWIkfbbNEWusZqzAx3ZGvu54TZacWib3EzUYmGI= +cosmossdk.io/log v1.3.1/go.mod h1:2/dIomt8mKdk6vl3OWJcPk2be3pGOS8OQaLUM/3/tCM= cosmossdk.io/math v1.3.0 h1:RC+jryuKeytIiictDslBP9i1fhkVm6ZDmZEoNP316zE= cosmossdk.io/math v1.3.0/go.mod h1:vnRTxewy+M7BtXBNFybkuhSH4WfedVAAnERHgVFhp3k= cosmossdk.io/schema v0.1.1 h1:I0M6pgI7R10nq+/HCQfbO6BsGBZA8sQy+duR1Y3aKcA= @@ -319,8 +325,8 @@ github.com/cosmos/gogogateway v1.2.0/go.mod h1:iQpLkGWxYcnCdz5iAdLcRBSw3h7NXeOkZ github.com/cosmos/gogoproto v1.4.2/go.mod h1:cLxOsn1ljAHSV527CHOtaIP91kK6cCrZETRBrkzItWU= github.com/cosmos/gogoproto v1.5.0 h1:SDVwzEqZDDBoslaeZg+dGE55hdzHfgUA40pEanMh52o= github.com/cosmos/gogoproto v1.5.0/go.mod h1:iUM31aofn3ymidYG6bUR5ZFrk+Om8p5s754eMUcyp8I= -github.com/cosmos/iavl v1.2.0 h1:kVxTmjTh4k0Dh1VNL046v6BXqKziqMDzxo93oh3kOfM= -github.com/cosmos/iavl v1.2.0/go.mod h1:HidWWLVAtODJqFD6Hbne2Y0q3SdxByJepHUOeoH4LiI= +github.com/cosmos/iavl v1.2.1-0.20240725141113-7adc688cf179 h1:wmwDn7V3RodN9auB3FooSQxs46nHVE3u0mb87TJkZFE= +github.com/cosmos/iavl v1.2.1-0.20240725141113-7adc688cf179/go.mod h1:GiM43q0pB+uG53mLxLDzimxM9l/5N9UuSY3/D0huuVw= github.com/cosmos/ics23/go v0.10.0 h1:iXqLLgp2Lp+EdpIuwXTYIQU+AiHj9mOC2X9ab++bZDM= github.com/cosmos/ics23/go v0.10.0/go.mod h1:ZfJSmng/TBNTBkFemHHHj5YY7VAU/MBU980F4VU1NG0= github.com/cosmos/keyring v1.2.0 h1:8C1lBP9xhImmIabyXW4c3vFjjLiBdGCmfLUfeZlV1Yo= diff --git a/simapp/v2/simdv2/cmd/commands.go b/simapp/v2/simdv2/cmd/commands.go index 0a677a80fa2e..8d1e8bd40a63 100644 --- a/simapp/v2/simdv2/cmd/commands.go +++ b/simapp/v2/simdv2/cmd/commands.go @@ -10,12 +10,13 @@ import ( "github.com/spf13/viper" "cosmossdk.io/client/v2/offchain" - "cosmossdk.io/core/log" "cosmossdk.io/core/transaction" + "cosmossdk.io/log" runtimev2 "cosmossdk.io/runtime/v2" serverv2 "cosmossdk.io/server/v2" "cosmossdk.io/server/v2/api/grpc" "cosmossdk.io/server/v2/cometbft" + "cosmossdk.io/server/v2/store" "cosmossdk.io/simapp/v2" confixcmd "cosmossdk.io/tools/confix/cmd" authcmd "cosmossdk.io/x/auth/client/cli" @@ -32,46 +33,6 @@ import ( genutiltypes "github.com/cosmos/cosmos-sdk/x/genutil/types" ) -var _ transaction.Codec[transaction.Tx] = &temporaryTxDecoder[transaction.Tx]{} - -type temporaryTxDecoder[T transaction.Tx] struct { - txConfig client.TxConfig -} - -// Decode implements transaction.Codec. -func (t *temporaryTxDecoder[T]) Decode(bz []byte) (T, error) { - var out T - tx, err := t.txConfig.TxDecoder()(bz) - if err != nil { - return out, err - } - - var ok bool - out, ok = tx.(T) - if !ok { - return out, errors.New("unexpected Tx type") - } - - return out, nil -} - -// DecodeJSON implements transaction.Codec. -func (t *temporaryTxDecoder[T]) DecodeJSON(bz []byte) (T, error) { - var out T - tx, err := t.txConfig.TxJSONDecoder()(bz) - if err != nil { - return out, err - } - - var ok bool - out, ok = tx.(T) - if !ok { - return out, errors.New("unexpected Tx type") - } - - return out, nil -} - func newApp[T transaction.Tx]( logger log.Logger, viper *viper.Viper, ) serverv2.AppI[T] { @@ -102,20 +63,21 @@ func initRootCmd[T transaction.Tx]( // add keybase, auxiliary RPC, query, genesis, and tx child commands rootCmd.AddCommand( - genesisCommand[T](moduleManager, appExport[T]), + genesisCommand(moduleManager, appExport[T]), queryCommand(), txCommand(), keys.Commands(), offchain.OffChain(), ) - // Add empty server struct here for writing default config + // wire server commands if err = serverv2.AddCommands( rootCmd, newApp, logger, - cometbft.New[T](&temporaryTxDecoder[T]{txConfig}, cometbft.DefaultServerOptions[T]()), + cometbft.New(&genericTxDecoder[T]{txConfig}, cometbft.DefaultServerOptions[T]()), grpc.New[T](), + store.New[T](), ); err != nil { panic(err) } @@ -220,3 +182,43 @@ func appExport[T transaction.Tx]( return simApp.ExportAppStateAndValidators(forZeroHeight, jailAllowedAddrs, modulesToExport) } + +var _ transaction.Codec[transaction.Tx] = &genericTxDecoder[transaction.Tx]{} + +type genericTxDecoder[T transaction.Tx] struct { + txConfig client.TxConfig +} + +// Decode implements transaction.Codec. +func (t *genericTxDecoder[T]) Decode(bz []byte) (T, error) { + var out T + tx, err := t.txConfig.TxDecoder()(bz) + if err != nil { + return out, err + } + + var ok bool + out, ok = tx.(T) + if !ok { + return out, errors.New("unexpected Tx type") + } + + return out, nil +} + +// DecodeJSON implements transaction.Codec. +func (t *genericTxDecoder[T]) DecodeJSON(bz []byte) (T, error) { + var out T + tx, err := t.txConfig.TxJSONDecoder()(bz) + if err != nil { + return out, err + } + + var ok bool + out, ok = tx.(T) + if !ok { + return out, errors.New("unexpected Tx type") + } + + return out, nil +} diff --git a/simapp/v2/simdv2/cmd/root_test.go b/simapp/v2/simdv2/cmd/root_test.go index a945a9ee8c85..7c51b1b21170 100644 --- a/simapp/v2/simdv2/cmd/root_test.go +++ b/simapp/v2/simdv2/cmd/root_test.go @@ -7,11 +7,11 @@ import ( "github.com/stretchr/testify/require" "cosmossdk.io/core/transaction" + svrcmd "cosmossdk.io/server/v2" "cosmossdk.io/simapp/v2" "cosmossdk.io/simapp/v2/simdv2/cmd" "github.com/cosmos/cosmos-sdk/client/flags" - svrcmd "github.com/cosmos/cosmos-sdk/server/cmd" "github.com/cosmos/cosmos-sdk/x/genutil/client/cli" ) diff --git a/simapp/v2/simdv2/cmd/testnet.go b/simapp/v2/simdv2/cmd/testnet.go index d1a15cfcbc93..2d4c3b348db5 100644 --- a/simapp/v2/simdv2/cmd/testnet.go +++ b/simapp/v2/simdv2/cmd/testnet.go @@ -14,14 +14,15 @@ import ( "github.com/spf13/cobra" "github.com/spf13/pflag" - coretesting "cosmossdk.io/core/testing" "cosmossdk.io/core/transaction" + "cosmossdk.io/log" "cosmossdk.io/math" "cosmossdk.io/math/unsafe" runtimev2 "cosmossdk.io/runtime/v2" serverv2 "cosmossdk.io/server/v2" "cosmossdk.io/server/v2/api/grpc" "cosmossdk.io/server/v2/cometbft" + "cosmossdk.io/server/v2/store" authtypes "cosmossdk.io/x/auth/types" banktypes "cosmossdk.io/x/bank/types" stakingtypes "cosmossdk.io/x/staking/types" @@ -40,6 +41,7 @@ import ( ) var ( + flagMinGasPrices = "minimum-gas-prices" flagNodeDirPrefix = "node-dir-prefix" flagNumValidators = "validator-count" flagOutputDir = "output-dir" @@ -70,7 +72,7 @@ func addTestnetFlagsToCmd(cmd *cobra.Command) { cmd.Flags().IntP(flagNumValidators, "n", 4, "Number of validators to initialize the testnet with") cmd.Flags().StringP(flagOutputDir, "o", "./.testnets", "Directory to store initialization data for the testnet") cmd.Flags().String(flags.FlagChainID, "", "genesis file chain-id, if left blank will be randomly created") - cmd.Flags().String(cometbft.FlagMinGasPrices, fmt.Sprintf("0.000006%s", sdk.DefaultBondDenom), "Minimum gas prices to accept for transactions; All fees in a tx must meet this minimum (e.g. 0.01photino,0.001stake)") + cmd.Flags().String(flagMinGasPrices, fmt.Sprintf("0.000006%s", sdk.DefaultBondDenom), "Minimum gas prices to accept for transactions; All fees in a tx must meet this minimum (e.g. 0.01photino,0.001stake)") cmd.Flags().String(flags.FlagKeyType, string(hd.Secp256k1Type), "Key signing algorithm to generate keys for") // support old flags name for backwards compatibility @@ -127,7 +129,7 @@ Example: args.outputDir, _ = cmd.Flags().GetString(flagOutputDir) args.keyringBackend, _ = cmd.Flags().GetString(flags.FlagKeyringBackend) args.chainID, _ = cmd.Flags().GetString(flags.FlagChainID) - args.minGasPrices, _ = cmd.Flags().GetString(cometbft.FlagMinGasPrices) + args.minGasPrices, _ = cmd.Flags().GetString(flagMinGasPrices) args.nodeDirPrefix, _ = cmd.Flags().GetString(flagNodeDirPrefix) args.nodeDaemonHome, _ = cmd.Flags().GetString(flagNodeDaemonHome) args.startingIPAddress, _ = cmd.Flags().GetString(flagStartingIPAddress) @@ -198,7 +200,7 @@ func initTestnetFiles[T transaction.Tx]( // generate private keys, node IDs, and initial transactions for i := 0; i < args.numValidators; i++ { var portOffset int - var grpcConfig *grpc.Config + grpcConfig := grpc.DefaultConfig() if args.singleMachine { portOffset = i p2pPortStart = 16656 // use different start point to not conflict with rpc port @@ -336,9 +338,14 @@ func initTestnetFiles[T transaction.Tx]( } // Write server config - cometServer := cometbft.New[T](&temporaryTxDecoder[T]{clientCtx.TxConfig}, cometbft.ServerOptions[T]{}, cometbft.OverwriteDefaultCometConfig(nodeConfig)) + cometServer := cometbft.New[T]( + &genericTxDecoder[T]{clientCtx.TxConfig}, + cometbft.ServerOptions[T]{}, + cometbft.OverwriteDefaultConfigTomlConfig(nodeConfig), + ) grpcServer := grpc.New[T](grpc.OverwriteDefaultConfig(grpcConfig)) - server := serverv2.NewServer(coretesting.NewNopLogger(), cometServer, grpcServer) + storeServer := store.New[T]() + server := serverv2.NewServer(log.NewNopLogger(), cometServer, grpcServer, storeServer) err = server.WriteConfig(filepath.Join(nodeDir, "config")) if err != nil { return err diff --git a/simapp/v2/simdv2/cmd/testnet_test.go b/simapp/v2/simdv2/cmd/testnet_test.go new file mode 100644 index 000000000000..145a32608e60 --- /dev/null +++ b/simapp/v2/simdv2/cmd/testnet_test.go @@ -0,0 +1,27 @@ +package cmd_test + +import ( + "fmt" + "testing" + + "github.com/stretchr/testify/require" + + "cosmossdk.io/core/transaction" + svrcmd "cosmossdk.io/server/v2" + "cosmossdk.io/simapp/v2" + "cosmossdk.io/simapp/v2/simdv2/cmd" + + "github.com/cosmos/cosmos-sdk/client/flags" + "github.com/cosmos/cosmos-sdk/crypto/keyring" +) + +func TestInitTestFilesCmd(t *testing.T) { + rootCmd := cmd.NewRootCmd[transaction.Tx]() + rootCmd.SetArgs([]string{ + "testnet", // Test the testnet init-files command + "init-files", + fmt.Sprintf("--%s=%s", flags.FlagKeyringBackend, keyring.BackendTest), // Set keyring-backend to test + }) + + require.NoError(t, svrcmd.Execute(rootCmd, "", simapp.DefaultNodeHome)) +} diff --git a/store/go.mod b/store/go.mod index 4b18cd027a01..a5c21ccbc977 100644 --- a/store/go.mod +++ b/store/go.mod @@ -3,8 +3,6 @@ module cosmossdk.io/store go 1.22.2 require ( - cosmossdk.io/core v0.12.0 - cosmossdk.io/core/testing v0.0.0-00010101000000-000000000000 cosmossdk.io/errors v1.0.1 cosmossdk.io/log v1.3.1 cosmossdk.io/math v1.3.0 @@ -13,7 +11,7 @@ require ( github.com/cosmos/cosmos-db v1.0.2 github.com/cosmos/cosmos-proto v1.0.0-beta.5 github.com/cosmos/gogoproto v1.5.0 - github.com/cosmos/iavl v1.2.0 + github.com/cosmos/iavl v1.2.1-0.20240725141113-7adc688cf179 github.com/cosmos/ics23/go v0.10.0 github.com/golang/mock v1.6.0 github.com/hashicorp/go-hclog v1.6.3 @@ -28,12 +26,6 @@ require ( gotest.tools/v3 v3.5.1 ) -replace cosmossdk.io/core => ../core - -replace cosmossdk.io/core/testing => ../core/testing - -replace cosmossdk.io/log => ../log - require ( github.com/DataDog/zstd v1.5.5 // indirect github.com/beorn7/perks v1.0.1 // indirect diff --git a/store/go.sum b/store/go.sum index 6809e46163d0..8f0c16d05b7b 100644 --- a/store/go.sum +++ b/store/go.sum @@ -1,5 +1,7 @@ cosmossdk.io/errors v1.0.1 h1:bzu+Kcr0kS/1DuPBtUFdWjzLqyUuCiyHjyJB6srBV/0= cosmossdk.io/errors v1.0.1/go.mod h1:MeelVSZThMi4bEakzhhhE/CKqVv3nOJDA25bIqRDu/U= +cosmossdk.io/log v1.3.1 h1:UZx8nWIkfbbNEWusZqzAx3ZGvu54TZacWib3EzUYmGI= +cosmossdk.io/log v1.3.1/go.mod h1:2/dIomt8mKdk6vl3OWJcPk2be3pGOS8OQaLUM/3/tCM= cosmossdk.io/math v1.3.0 h1:RC+jryuKeytIiictDslBP9i1fhkVm6ZDmZEoNP316zE= cosmossdk.io/math v1.3.0/go.mod h1:vnRTxewy+M7BtXBNFybkuhSH4WfedVAAnERHgVFhp3k= github.com/DataDog/datadog-go v3.2.0+incompatible/go.mod h1:LButxg5PwREeZtORoXG3tL4fMGNddJ+vMq1mwgfaqoQ= @@ -43,8 +45,8 @@ github.com/cosmos/cosmos-proto v1.0.0-beta.5 h1:eNcayDLpip+zVLRLYafhzLvQlSmyab+R github.com/cosmos/cosmos-proto v1.0.0-beta.5/go.mod h1:hQGLpiIUloJBMdQMMWb/4wRApmI9hjHH05nefC0Ojec= github.com/cosmos/gogoproto v1.5.0 h1:SDVwzEqZDDBoslaeZg+dGE55hdzHfgUA40pEanMh52o= github.com/cosmos/gogoproto v1.5.0/go.mod h1:iUM31aofn3ymidYG6bUR5ZFrk+Om8p5s754eMUcyp8I= -github.com/cosmos/iavl v1.2.0 h1:kVxTmjTh4k0Dh1VNL046v6BXqKziqMDzxo93oh3kOfM= -github.com/cosmos/iavl v1.2.0/go.mod h1:HidWWLVAtODJqFD6Hbne2Y0q3SdxByJepHUOeoH4LiI= +github.com/cosmos/iavl v1.2.1-0.20240725141113-7adc688cf179 h1:wmwDn7V3RodN9auB3FooSQxs46nHVE3u0mb87TJkZFE= +github.com/cosmos/iavl v1.2.1-0.20240725141113-7adc688cf179/go.mod h1:GiM43q0pB+uG53mLxLDzimxM9l/5N9UuSY3/D0huuVw= github.com/cosmos/ics23/go v0.10.0 h1:iXqLLgp2Lp+EdpIuwXTYIQU+AiHj9mOC2X9ab++bZDM= github.com/cosmos/ics23/go v0.10.0/go.mod h1:ZfJSmng/TBNTBkFemHHHj5YY7VAU/MBU980F4VU1NG0= github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E= diff --git a/store/iavl/store.go b/store/iavl/store.go index 8e1905b7a38b..198948b30091 100644 --- a/store/iavl/store.go +++ b/store/iavl/store.go @@ -10,7 +10,6 @@ import ( "github.com/cosmos/iavl" ics23 "github.com/cosmos/ics23/go" - "cosmossdk.io/core/log" errorsmod "cosmossdk.io/errors" "cosmossdk.io/store/cachekv" "cosmossdk.io/store/internal/kv" @@ -37,14 +36,14 @@ var ( // Store Implements types.KVStore and CommitKVStore. type Store struct { tree Tree - logger log.Logger + logger types.Logger metrics metrics.StoreMetrics } // LoadStore returns an IAVL Store as a CommitKVStore. Internally, it will load the // store's version (id) from the provided DB. An error is returned if the version // fails to load, or if called with a positive version on an empty tree. -func LoadStore(db dbm.DB, logger log.Logger, key types.StoreKey, id types.CommitID, cacheSize int, disableFastNode bool, metrics metrics.StoreMetrics) (types.CommitKVStore, error) { +func LoadStore(db dbm.DB, logger types.Logger, key types.StoreKey, id types.CommitID, cacheSize int, disableFastNode bool, metrics metrics.StoreMetrics) (types.CommitKVStore, error) { return LoadStoreWithInitialVersion(db, logger, key, id, 0, cacheSize, disableFastNode, metrics) } @@ -52,7 +51,7 @@ func LoadStore(db dbm.DB, logger log.Logger, key types.StoreKey, id types.Commit // to the one given. Internally, it will load the store's version (id) from the // provided DB. An error is returned if the version fails to load, or if called with a positive // version on an empty tree. -func LoadStoreWithInitialVersion(db dbm.DB, logger log.Logger, key types.StoreKey, id types.CommitID, initialVersion uint64, cacheSize int, disableFastNode bool, metrics metrics.StoreMetrics) (types.CommitKVStore, error) { +func LoadStoreWithInitialVersion(db dbm.DB, logger types.Logger, key types.StoreKey, id types.CommitID, initialVersion uint64, cacheSize int, disableFastNode bool, metrics metrics.StoreMetrics) (types.CommitKVStore, error) { tree := iavl.NewMutableTree(wrapper.NewDBWrapper(db), cacheSize, disableFastNode, logger, iavl.InitialVersionOption(initialVersion), iavl.AsyncPruningOption(true)) isUpgradeable, err := tree.IsUpgradeable() diff --git a/store/pruning/manager.go b/store/pruning/manager.go index 3656d07ed36d..ddc9569ffe64 100644 --- a/store/pruning/manager.go +++ b/store/pruning/manager.go @@ -8,8 +8,8 @@ import ( dbm "github.com/cosmos/cosmos-db" - "cosmossdk.io/core/log" "cosmossdk.io/store/pruning/types" + storetypes "cosmossdk.io/store/types" ) // Manager is an abstraction to handle the logic needed for @@ -17,7 +17,7 @@ import ( // based on the strategy described by the pruning options. type Manager struct { db dbm.DB - logger log.Logger + logger storetypes.Logger opts types.PruningOptions snapshotInterval uint64 // Snapshots are taken in a separate goroutine from the regular execution @@ -46,7 +46,7 @@ var pruneSnapshotHeightsKey = []byte("s/prunesnapshotheights") // The returned manager uses a pruning strategy of "nothing" which // keeps all heights. Users of the Manager may change the strategy // by calling SetOptions. -func NewManager(db dbm.DB, logger log.Logger) *Manager { +func NewManager(db dbm.DB, logger storetypes.Logger) *Manager { return &Manager{ db: db, logger: logger, diff --git a/store/pruning/manager_test.go b/store/pruning/manager_test.go index fe4aae74cc46..006891de8570 100644 --- a/store/pruning/manager_test.go +++ b/store/pruning/manager_test.go @@ -9,7 +9,7 @@ import ( "github.com/golang/mock/gomock" "github.com/stretchr/testify/require" - coretesting "cosmossdk.io/core/testing" + "cosmossdk.io/log" "cosmossdk.io/store/mock" "cosmossdk.io/store/pruning" "cosmossdk.io/store/pruning/types" @@ -18,7 +18,7 @@ import ( const dbErr = "db error" func TestNewManager(t *testing.T) { - manager := pruning.NewManager(db.NewMemDB(), coretesting.NewNopLogger()) + manager := pruning.NewManager(db.NewMemDB(), log.NewNopLogger()) require.NotNil(t, manager) require.Equal(t, types.PruningNothing, manager.GetOptions().GetPruningStrategy()) } @@ -79,7 +79,7 @@ func TestStrategies(t *testing.T) { t.Run(name, func(t *testing.T) { t.Parallel() - manager := pruning.NewManager(db.NewMemDB(), coretesting.NewNopLogger()) + manager := pruning.NewManager(db.NewMemDB(), log.NewNopLogger()) require.NotNil(t, manager) curStrategy := tc.strategy @@ -186,7 +186,7 @@ func TestPruningHeight_Inputs(t *testing.T) { for name, tc := range testcases { t.Run(name, func(t *testing.T) { - manager := pruning.NewManager(db.NewMemDB(), coretesting.NewNopLogger()) + manager := pruning.NewManager(db.NewMemDB(), log.NewNopLogger()) require.NotNil(t, manager) manager.SetOptions(types.NewPruningOptions(tc.strategy)) @@ -204,7 +204,7 @@ func TestHandleSnapshotHeight_DbErr_Panic(t *testing.T) { dbMock.EXPECT().SetSync(gomock.Any(), gomock.Any()).Return(errors.New(dbErr)).Times(1) - manager := pruning.NewManager(dbMock, coretesting.NewNopLogger()) + manager := pruning.NewManager(dbMock, log.NewNopLogger()) manager.SetOptions(types.NewPruningOptions(types.PruningEverything)) require.NotNil(t, manager) @@ -222,7 +222,7 @@ func TestHandleSnapshotHeight_LoadFromDisk(t *testing.T) { // Setup db := db.NewMemDB() - manager := pruning.NewManager(db, coretesting.NewNopLogger()) + manager := pruning.NewManager(db, log.NewNopLogger()) require.NotNil(t, manager) manager.SetOptions(types.NewPruningOptions(types.PruningEverything)) @@ -253,7 +253,7 @@ func TestHandleSnapshotHeight_LoadFromDisk(t *testing.T) { func TestLoadPruningSnapshotHeights(t *testing.T) { var ( - manager = pruning.NewManager(db.NewMemDB(), coretesting.NewNopLogger()) + manager = pruning.NewManager(db.NewMemDB(), log.NewNopLogger()) err error ) require.NotNil(t, manager) @@ -294,7 +294,7 @@ func TestLoadPruningSnapshotHeights(t *testing.T) { } func TestLoadSnapshotHeights_PruneNothing(t *testing.T) { - manager := pruning.NewManager(db.NewMemDB(), coretesting.NewNopLogger()) + manager := pruning.NewManager(db.NewMemDB(), log.NewNopLogger()) require.NotNil(t, manager) manager.SetOptions(types.NewPruningOptions(types.PruningNothing)) diff --git a/store/rootmulti/proof_test.go b/store/rootmulti/proof_test.go index 2019f3eb4671..d573937c3d08 100644 --- a/store/rootmulti/proof_test.go +++ b/store/rootmulti/proof_test.go @@ -6,7 +6,7 @@ import ( dbm "github.com/cosmos/cosmos-db" "github.com/stretchr/testify/require" - coretesting "cosmossdk.io/core/testing" + "cosmossdk.io/log" "cosmossdk.io/store/iavl" "cosmossdk.io/store/metrics" "cosmossdk.io/store/types" @@ -15,7 +15,7 @@ import ( func TestVerifyIAVLStoreQueryProof(t *testing.T) { // Create main tree for testing. db := dbm.NewMemDB() - iStore, err := iavl.LoadStore(db, coretesting.NewNopLogger(), types.NewKVStoreKey("test"), types.CommitID{}, iavl.DefaultIAVLCacheSize, false, metrics.NewNoOpMetrics()) + iStore, err := iavl.LoadStore(db, log.NewNopLogger(), types.NewKVStoreKey("test"), types.CommitID{}, iavl.DefaultIAVLCacheSize, false, metrics.NewNoOpMetrics()) store := iStore.(*iavl.Store) require.Nil(t, err) store.Set([]byte("MYKEY"), []byte("MYVALUE")) @@ -59,7 +59,7 @@ func TestVerifyIAVLStoreQueryProof(t *testing.T) { func TestVerifyMultiStoreQueryProof(t *testing.T) { // Create main tree for testing. db := dbm.NewMemDB() - store := NewStore(db, coretesting.NewNopLogger(), metrics.NewNoOpMetrics()) + store := NewStore(db, log.NewNopLogger(), metrics.NewNoOpMetrics()) iavlStoreKey := types.NewKVStoreKey("iavlStoreKey") store.MountStoreWithDB(iavlStoreKey, types.StoreTypeIAVL, nil) @@ -115,7 +115,7 @@ func TestVerifyMultiStoreQueryProof(t *testing.T) { func TestVerifyMultiStoreQueryProofAbsence(t *testing.T) { // Create main tree for testing. db := dbm.NewMemDB() - store := NewStore(db, coretesting.NewNopLogger(), metrics.NewNoOpMetrics()) + store := NewStore(db, log.NewNopLogger(), metrics.NewNoOpMetrics()) iavlStoreKey := types.NewKVStoreKey("iavlStoreKey") store.MountStoreWithDB(iavlStoreKey, types.StoreTypeIAVL, nil) diff --git a/store/rootmulti/snapshot_test.go b/store/rootmulti/snapshot_test.go index 9fded8482a64..635be92970a3 100644 --- a/store/rootmulti/snapshot_test.go +++ b/store/rootmulti/snapshot_test.go @@ -14,7 +14,7 @@ import ( "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - coretesting "cosmossdk.io/core/testing" + "cosmossdk.io/log" "cosmossdk.io/store/iavl" "cosmossdk.io/store/metrics" "cosmossdk.io/store/rootmulti" @@ -24,7 +24,7 @@ import ( ) func newMultiStoreWithGeneratedData(db dbm.DB, stores uint8, storeKeys uint64) *rootmulti.Store { - multiStore := rootmulti.NewStore(db, coretesting.NewNopLogger(), metrics.NewNoOpMetrics()) + multiStore := rootmulti.NewStore(db, log.NewNopLogger(), metrics.NewNoOpMetrics()) r := rand.New(rand.NewSource(49872768940)) // Fixed seed for deterministic tests keys := []*types.KVStoreKey{} @@ -62,7 +62,7 @@ func newMultiStoreWithGeneratedData(db dbm.DB, stores uint8, storeKeys uint64) * } func newMultiStoreWithMixedMounts(db dbm.DB) *rootmulti.Store { - store := rootmulti.NewStore(db, coretesting.NewNopLogger(), metrics.NewNoOpMetrics()) + store := rootmulti.NewStore(db, log.NewNopLogger(), metrics.NewNoOpMetrics()) store.MountStoreWithDB(types.NewKVStoreKey("iavl1"), types.StoreTypeIAVL, nil) store.MountStoreWithDB(types.NewKVStoreKey("iavl2"), types.StoreTypeIAVL, nil) store.MountStoreWithDB(types.NewKVStoreKey("iavl3"), types.StoreTypeIAVL, nil) @@ -245,7 +245,7 @@ func benchmarkMultistoreSnapshot(b *testing.B, stores uint8, storeKeys uint64) { b.StartTimer() for i := 0; i < b.N; i++ { - target := rootmulti.NewStore(dbm.NewMemDB(), coretesting.NewNopLogger(), metrics.NewNoOpMetrics()) + target := rootmulti.NewStore(dbm.NewMemDB(), log.NewNopLogger(), metrics.NewNoOpMetrics()) for _, key := range source.StoreKeysByName() { target.MountStoreWithDB(key, types.StoreTypeIAVL, nil) } @@ -281,7 +281,7 @@ func benchmarkMultistoreSnapshotRestore(b *testing.B, stores uint8, storeKeys ui b.StartTimer() for i := 0; i < b.N; i++ { - target := rootmulti.NewStore(dbm.NewMemDB(), coretesting.NewNopLogger(), metrics.NewNoOpMetrics()) + target := rootmulti.NewStore(dbm.NewMemDB(), log.NewNopLogger(), metrics.NewNoOpMetrics()) for _, key := range source.StoreKeysByName() { target.MountStoreWithDB(key, types.StoreTypeIAVL, nil) } diff --git a/store/rootmulti/store.go b/store/rootmulti/store.go index ab6402447f71..1226f63d1ac3 100644 --- a/store/rootmulti/store.go +++ b/store/rootmulti/store.go @@ -16,7 +16,6 @@ import ( gogotypes "github.com/cosmos/gogoproto/types" iavltree "github.com/cosmos/iavl" - "cosmossdk.io/core/log" errorsmod "cosmossdk.io/errors" "cosmossdk.io/store/cachemulti" "cosmossdk.io/store/dbadapter" @@ -57,7 +56,7 @@ func keysFromStoreKeyMap[V any](m map[types.StoreKey]V) []types.StoreKey { // the CommitMultiStore interface. type Store struct { db dbm.DB - logger log.Logger + logger iavltree.Logger lastCommitInfo *types.CommitInfo pruningManager *pruning.Manager iavlCacheSize int @@ -85,7 +84,7 @@ var ( // store will be created with a PruneNothing pruning strategy by default. After // a store is created, KVStores must be mounted and finally LoadLatestVersion or // LoadVersion must be called. -func NewStore(db dbm.DB, logger log.Logger, metricGatherer metrics.StoreMetrics) *Store { +func NewStore(db dbm.DB, logger iavltree.Logger, metricGatherer metrics.StoreMetrics) *Store { return &Store{ db: db, logger: logger, diff --git a/store/rootmulti/store_test.go b/store/rootmulti/store_test.go index 39cbfaf801dd..be23d3deda9c 100644 --- a/store/rootmulti/store_test.go +++ b/store/rootmulti/store_test.go @@ -10,8 +10,8 @@ import ( dbm "github.com/cosmos/cosmos-db" "github.com/stretchr/testify/require" - coretesting "cosmossdk.io/core/testing" "cosmossdk.io/errors" + "cosmossdk.io/log" "cosmossdk.io/store/cachemulti" "cosmossdk.io/store/iavl" sdkmaps "cosmossdk.io/store/internal/maps" @@ -22,7 +22,7 @@ import ( func TestStoreType(t *testing.T) { db := dbm.NewMemDB() - store := NewStore(db, coretesting.NewNopLogger(), metrics.NewNoOpMetrics()) + store := NewStore(db, log.NewNopLogger(), metrics.NewNoOpMetrics()) store.MountStoreWithDB(types.NewKVStoreKey("store1"), types.StoreTypeIAVL, db) } @@ -45,7 +45,7 @@ func TestGetCommitKVStore(t *testing.T) { func TestStoreMount(t *testing.T) { db := dbm.NewMemDB() - store := NewStore(db, coretesting.NewNopLogger(), metrics.NewNoOpMetrics()) + store := NewStore(db, log.NewNopLogger(), metrics.NewNoOpMetrics()) key1 := types.NewKVStoreKey("store1") key2 := types.NewKVStoreKey("store2") @@ -652,7 +652,7 @@ func (p *pauseableCommitKVStoreStub) PausePruning(b bool) { } func TestPausePruningOnCommit(t *testing.T) { - store := NewStore(dbm.NewMemDB(), coretesting.NewNopLogger(), metrics.NewNoOpMetrics()) + store := NewStore(dbm.NewMemDB(), log.NewNopLogger(), metrics.NewNoOpMetrics()) store.SetPruning(pruningtypes.NewCustomPruningOptions(2, 11)) store.MountStoreWithDB(testStoreKey1, types.StoreTypeIAVL, nil) require.NoError(t, store.LoadLatestVersion()) @@ -833,7 +833,7 @@ var ( ) func newMultiStoreWithMounts(db dbm.DB, pruningOpts pruningtypes.PruningOptions) *Store { - store := NewStore(db, coretesting.NewNopLogger(), metrics.NewNoOpMetrics()) + store := NewStore(db, log.NewNopLogger(), metrics.NewNoOpMetrics()) store.SetPruning(pruningOpts) store.MountStoreWithDB(testStoreKey1, types.StoreTypeIAVL, nil) @@ -844,7 +844,7 @@ func newMultiStoreWithMounts(db dbm.DB, pruningOpts pruningtypes.PruningOptions) } func newMultiStoreWithModifiedMounts(db dbm.DB, pruningOpts pruningtypes.PruningOptions) (*Store, *types.StoreUpgrades) { - store := NewStore(db, coretesting.NewNopLogger(), metrics.NewNoOpMetrics()) + store := NewStore(db, log.NewNopLogger(), metrics.NewNoOpMetrics()) store.SetPruning(pruningOpts) store.MountStoreWithDB(types.NewKVStoreKey("store1"), types.StoreTypeIAVL, nil) @@ -970,7 +970,7 @@ func (stub *commitKVStoreStub) Commit() types.CommitID { func prepareStoreMap() (map[types.StoreKey]types.CommitKVStore, error) { var db dbm.DB = dbm.NewMemDB() - store := NewStore(db, coretesting.NewNopLogger(), metrics.NewNoOpMetrics()) + store := NewStore(db, log.NewNopLogger(), metrics.NewNoOpMetrics()) store.MountStoreWithDB(types.NewKVStoreKey("iavl1"), types.StoreTypeIAVL, nil) store.MountStoreWithDB(types.NewKVStoreKey("iavl2"), types.StoreTypeIAVL, nil) store.MountStoreWithDB(types.NewTransientStoreKey("trans1"), types.StoreTypeTransient, nil) diff --git a/store/snapshots/helpers_test.go b/store/snapshots/helpers_test.go index d45d068f5c75..af623b0256a1 100644 --- a/store/snapshots/helpers_test.go +++ b/store/snapshots/helpers_test.go @@ -15,8 +15,8 @@ import ( protoio "github.com/cosmos/gogoproto/io" "github.com/stretchr/testify/require" - coretesting "cosmossdk.io/core/testing" errorsmod "cosmossdk.io/errors" + "cosmossdk.io/log" "cosmossdk.io/store/snapshots" snapshottypes "cosmossdk.io/store/snapshots/types" "cosmossdk.io/store/types" @@ -211,7 +211,7 @@ func setupBusyManager(t *testing.T) *snapshots.Manager { require.NoError(t, err) hung := newHungSnapshotter() hung.SetSnapshotInterval(opts.Interval) - mgr := snapshots.NewManager(store, opts, hung, nil, coretesting.NewNopLogger()) + mgr := snapshots.NewManager(store, opts, hung, nil, log.NewNopLogger()) require.Equal(t, opts.Interval, hung.snapshotInterval) // Channel to ensure the test doesn't finish until the goroutine is done. diff --git a/store/snapshots/manager.go b/store/snapshots/manager.go index 6c7816705b8c..4d75690c396e 100644 --- a/store/snapshots/manager.go +++ b/store/snapshots/manager.go @@ -11,7 +11,6 @@ import ( "sort" "sync" - "cosmossdk.io/core/log" errorsmod "cosmossdk.io/errors" "cosmossdk.io/store/snapshots/types" storetypes "cosmossdk.io/store/types" @@ -37,7 +36,7 @@ type Manager struct { opts types.SnapshotOptions // multistore is the store from which snapshots are taken. multistore types.Snapshotter - logger log.Logger + logger storetypes.Logger mtx sync.Mutex operation operation @@ -71,7 +70,7 @@ const ( var ErrOptsZeroSnapshotInterval = errors.New("snaphot-interval must not be 0") // NewManager creates a new manager. -func NewManager(store *Store, opts types.SnapshotOptions, multistore types.Snapshotter, extensions map[string]types.ExtensionSnapshotter, logger log.Logger) *Manager { +func NewManager(store *Store, opts types.SnapshotOptions, multistore types.Snapshotter, extensions map[string]types.ExtensionSnapshotter, logger storetypes.Logger) *Manager { if extensions == nil { extensions = map[string]types.ExtensionSnapshotter{} } diff --git a/store/snapshots/manager_test.go b/store/snapshots/manager_test.go index b6ecdc261175..49f31e86272b 100644 --- a/store/snapshots/manager_test.go +++ b/store/snapshots/manager_test.go @@ -8,7 +8,7 @@ import ( "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - coretesting "cosmossdk.io/core/testing" + "cosmossdk.io/log" "cosmossdk.io/store/snapshots" "cosmossdk.io/store/snapshots/types" ) @@ -19,7 +19,7 @@ func TestManager_List(t *testing.T) { store := setupStore(t) snapshotter := &mockSnapshotter{} snapshotter.SetSnapshotInterval(opts.Interval) - manager := snapshots.NewManager(store, opts, snapshotter, nil, coretesting.NewNopLogger()) + manager := snapshots.NewManager(store, opts, snapshotter, nil, log.NewNopLogger()) require.Equal(t, opts.Interval, snapshotter.GetSnapshotInterval()) mgrList, err := manager.List() @@ -41,7 +41,7 @@ func TestManager_List(t *testing.T) { func TestManager_LoadChunk(t *testing.T) { store := setupStore(t) - manager := snapshots.NewManager(store, opts, &mockSnapshotter{}, nil, coretesting.NewNopLogger()) + manager := snapshots.NewManager(store, opts, &mockSnapshotter{}, nil, log.NewNopLogger()) // Existing chunk should return body chunk, err := manager.LoadChunk(2, 1, 1) @@ -74,7 +74,7 @@ func TestManager_Take(t *testing.T) { extSnapshotter := newExtSnapshotter(10) expectChunks := snapshotItems(items, extSnapshotter) - manager := snapshots.NewManager(store, opts, snapshotter, nil, coretesting.NewNopLogger()) + manager := snapshots.NewManager(store, opts, snapshotter, nil, log.NewNopLogger()) err := manager.RegisterExtensions(extSnapshotter) require.NoError(t, err) @@ -119,7 +119,7 @@ func TestManager_Prune(t *testing.T) { store := setupStore(t) snapshotter := &mockSnapshotter{} snapshotter.SetSnapshotInterval(opts.Interval) - manager := snapshots.NewManager(store, opts, snapshotter, nil, coretesting.NewNopLogger()) + manager := snapshots.NewManager(store, opts, snapshotter, nil, log.NewNopLogger()) pruned, err := manager.Prune(2) require.NoError(t, err) @@ -141,7 +141,7 @@ func TestManager_Restore(t *testing.T) { prunedHeights: make(map[int64]struct{}), } extSnapshotter := newExtSnapshotter(0) - manager := snapshots.NewManager(store, opts, target, nil, coretesting.NewNopLogger()) + manager := snapshots.NewManager(store, opts, target, nil, log.NewNopLogger()) err := manager.RegisterExtensions(extSnapshotter) require.NoError(t, err) @@ -251,7 +251,7 @@ func TestManager_TakeError(t *testing.T) { snapshotter := &mockErrorSnapshotter{} store, err := snapshots.NewStore(db.NewMemDB(), GetTempDir(t)) require.NoError(t, err) - manager := snapshots.NewManager(store, opts, snapshotter, nil, coretesting.NewNopLogger()) + manager := snapshots.NewManager(store, opts, snapshotter, nil, log.NewNopLogger()) _, err = manager.Create(1) require.Error(t, err) diff --git a/store/store.go b/store/store.go index 12297b8bfe89..e02ea24a66e8 100644 --- a/store/store.go +++ b/store/store.go @@ -3,14 +3,13 @@ package store import ( dbm "github.com/cosmos/cosmos-db" - "cosmossdk.io/core/log" "cosmossdk.io/store/cache" "cosmossdk.io/store/metrics" "cosmossdk.io/store/rootmulti" "cosmossdk.io/store/types" ) -func NewCommitMultiStore(db dbm.DB, logger log.Logger, metricGatherer metrics.StoreMetrics) types.CommitMultiStore { +func NewCommitMultiStore(db dbm.DB, logger types.Logger, metricGatherer metrics.StoreMetrics) types.CommitMultiStore { return rootmulti.NewStore(db, logger, metricGatherer) } diff --git a/store/streaming/streaming_test.go b/store/streaming/streaming_test.go index 3cc55c28d059..75fcec937b51 100644 --- a/store/streaming/streaming_test.go +++ b/store/streaming/streaming_test.go @@ -15,8 +15,7 @@ import ( "github.com/stretchr/testify/require" "github.com/stretchr/testify/suite" - "cosmossdk.io/core/log" - coretesting "cosmossdk.io/core/testing" + "cosmossdk.io/log" storetypes "cosmossdk.io/store/types" ) @@ -59,7 +58,7 @@ func (s *PluginTestSuite) SetupTest() { require.True(s.T(), ok, "should pass type check") header := cmtproto.Header{Height: 1, Time: time.Now()} - logger := coretesting.NewNopLogger() + logger := log.NewNopLogger() streamingService := storetypes.StreamingManager{ ABCIListeners: []storetypes.ABCIListener{abciListener}, StopNodeOnErr: true, diff --git a/store/types/context.go b/store/types/context.go index 26c49126765a..999539e16cb2 100644 --- a/store/types/context.go +++ b/store/types/context.go @@ -1,8 +1,6 @@ package types -import ( - "cosmossdk.io/core/log" -) +import "cosmossdk.io/log" // Context is an interface used by an App to pass context information // needed to process store streaming requests. diff --git a/store/types/iterator_test.go b/store/types/iterator_test.go index 46d5484e4816..a804b092c8ea 100644 --- a/store/types/iterator_test.go +++ b/store/types/iterator_test.go @@ -6,7 +6,7 @@ import ( dbm "github.com/cosmos/cosmos-db" "github.com/stretchr/testify/require" - coretesting "cosmossdk.io/core/testing" + "cosmossdk.io/log" "cosmossdk.io/store/iavl" "cosmossdk.io/store/metrics" "cosmossdk.io/store/types" @@ -15,7 +15,7 @@ import ( func newMemTestKVStore(t *testing.T) types.KVStore { t.Helper() db := dbm.NewMemDB() - store, err := iavl.LoadStore(db, coretesting.NewNopLogger(), types.NewKVStoreKey("test"), types.CommitID{}, iavl.DefaultIAVLCacheSize, false, metrics.NewNoOpMetrics()) + store, err := iavl.LoadStore(db, log.NewNopLogger(), types.NewKVStoreKey("test"), types.CommitID{}, iavl.DefaultIAVLCacheSize, false, metrics.NewNoOpMetrics()) require.NoError(t, err) return store } diff --git a/store/types/logger.go b/store/types/logger.go new file mode 100644 index 000000000000..abce36c86ad1 --- /dev/null +++ b/store/types/logger.go @@ -0,0 +1,21 @@ +package types + +// Logger defines basic logger that store expects. +// It is a subset of the cosmossdk.io/log.Logger interface. +type Logger interface { + // Info takes a message and a set of key/value pairs and logs with level INFO. + // The key of the tuple must be a string. + Info(msg string, keyVals ...any) + + // Warn takes a message and a set of key/value pairs and logs with level WARN. + // The key of the tuple must be a string. + Warn(msg string, keyVals ...any) + + // Error takes a message and a set of key/value pairs and logs with level ERR. + // The key of the tuple must be a string. + Error(msg string, keyVals ...any) + + // Debug takes a message and a set of key/value pairs and logs with level DEBUG. + // The key of the tuple must be a string. + Debug(msg string, keyVals ...any) +} diff --git a/store/v2/commitment/iavl/config.go b/store/v2/commitment/iavl/config.go index 7e386b3a46c4..027f8f2788bc 100644 --- a/store/v2/commitment/iavl/config.go +++ b/store/v2/commitment/iavl/config.go @@ -2,8 +2,8 @@ package iavl // Config is the configuration for the IAVL tree. type Config struct { - CacheSize int `mapstructure:"cache_size"` - SkipFastStorageUpgrade bool `mapstructure:"skip_fast_storage_upgrade"` + CacheSize int `mapstructure:"cache-size" toml:"cache-size" comment:"CacheSize set the size of the iavl tree cache."` + SkipFastStorageUpgrade bool `mapstructure:"skip-fast-storage-upgrade" toml:"skip-fast-storage-upgrade" comment:"If true, the tree will work like no fast storage and always not upgrade fast storage."` } // DefaultConfig returns the default configuration for the IAVL tree. diff --git a/store/v2/commitment/iavl/tree_test.go b/store/v2/commitment/iavl/tree_test.go index 279a185d11db..7435b4e58dd2 100644 --- a/store/v2/commitment/iavl/tree_test.go +++ b/store/v2/commitment/iavl/tree_test.go @@ -7,7 +7,7 @@ import ( "github.com/stretchr/testify/require" "github.com/stretchr/testify/suite" - "cosmossdk.io/core/log" + corelog "cosmossdk.io/core/log" corestore "cosmossdk.io/core/store" coretesting "cosmossdk.io/core/testing" "cosmossdk.io/store/v2/commitment" @@ -16,7 +16,7 @@ import ( func TestCommitterSuite(t *testing.T) { s := &commitment.CommitStoreTestSuite{ - NewStore: func(db corestore.KVStoreWithBatch, storeKeys []string, logger log.Logger) (*commitment.CommitStore, error) { + NewStore: func(db corestore.KVStoreWithBatch, storeKeys []string, logger corelog.Logger) (*commitment.CommitStore, error) { multiTrees := make(map[string]commitment.Tree) cfg := DefaultConfig() for _, storeKey := range storeKeys { diff --git a/store/v2/commitment/store.go b/store/v2/commitment/store.go index 0dda7f282903..c814dec70be1 100644 --- a/store/v2/commitment/store.go +++ b/store/v2/commitment/store.go @@ -8,7 +8,7 @@ import ( protoio "github.com/cosmos/gogoproto/io" - "cosmossdk.io/core/log" + corelog "cosmossdk.io/core/log" corestore "cosmossdk.io/core/store" "cosmossdk.io/store/v2" "cosmossdk.io/store/v2/internal" @@ -30,13 +30,13 @@ var ( // RootStore use a CommitStore as an abstraction to handle multiple store keys // and trees. type CommitStore struct { - logger log.Logger + logger corelog.Logger metadata *MetadataStore multiTrees map[string]Tree } // NewCommitStore creates a new CommitStore instance. -func NewCommitStore(trees map[string]Tree, db corestore.KVStoreWithBatch, logger log.Logger) (*CommitStore, error) { +func NewCommitStore(trees map[string]Tree, db corestore.KVStoreWithBatch, logger corelog.Logger) (*CommitStore, error) { return &CommitStore{ logger: logger, multiTrees: trees, @@ -244,7 +244,7 @@ func (c *CommitStore) PausePruning(pause bool) { // Snapshot implements snapshotstypes.CommitSnapshotter. func (c *CommitStore) Snapshot(version uint64, protoWriter protoio.Writer) error { if version == 0 { - return fmt.Errorf("the snapshot version must be greater than 0") + return errors.New("the snapshot version must be greater than 0") } latestVersion, err := c.GetLatestVersion() @@ -348,7 +348,7 @@ loop: case *snapshotstypes.SnapshotItem_IAVL: if importer == nil { - return snapshotstypes.SnapshotItem{}, fmt.Errorf("received IAVL node item before store item") + return snapshotstypes.SnapshotItem{}, errors.New("received IAVL node item before store item") } node := item.IAVL if node.Height > int32(math.MaxInt8) { diff --git a/store/v2/commitment/store_test_suite.go b/store/v2/commitment/store_test_suite.go index 5c5c2d378a89..7e8c3587d34e 100644 --- a/store/v2/commitment/store_test_suite.go +++ b/store/v2/commitment/store_test_suite.go @@ -8,7 +8,7 @@ import ( "github.com/stretchr/testify/suite" - "cosmossdk.io/core/log" + corelog "cosmossdk.io/core/log" corestore "cosmossdk.io/core/store" coretesting "cosmossdk.io/core/testing" "cosmossdk.io/store/v2" @@ -26,7 +26,7 @@ const ( type CommitStoreTestSuite struct { suite.Suite - NewStore func(db corestore.KVStoreWithBatch, storeKeys []string, logger log.Logger) (*CommitStore, error) + NewStore func(db corestore.KVStoreWithBatch, storeKeys []string, logger corelog.Logger) (*CommitStore, error) } func (s *CommitStoreTestSuite) TestStore_Snapshotter() { diff --git a/store/v2/go.mod b/store/v2/go.mod index aea6c0d464f7..8c8ec3843456 100644 --- a/store/v2/go.mod +++ b/store/v2/go.mod @@ -5,11 +5,11 @@ go 1.21 require ( cosmossdk.io/core v0.12.0 cosmossdk.io/core/testing v0.0.0-00010101000000-000000000000 - cosmossdk.io/errors v1.0.1 + cosmossdk.io/errors/v2 v2.0.0-20240731132947-df72853b3ca5 cosmossdk.io/log v1.3.1 github.com/cockroachdb/pebble v1.1.0 github.com/cosmos/gogoproto v1.5.0 - github.com/cosmos/iavl v1.2.0 + github.com/cosmos/iavl v1.2.1-0.20240725141113-7adc688cf179 github.com/cosmos/ics23/go v0.10.0 github.com/google/btree v1.1.2 github.com/hashicorp/go-metrics v0.5.3 @@ -35,9 +35,10 @@ require ( github.com/fsnotify/fsnotify v1.7.0 // indirect github.com/getsentry/sentry-go v0.27.0 // indirect github.com/gogo/protobuf v1.3.2 // indirect + github.com/golang/protobuf v1.5.4 // indirect github.com/golang/snappy v0.0.4 // indirect github.com/google/go-cmp v0.6.0 // indirect - github.com/hashicorp/go-immutable-radix v1.0.0 // indirect + github.com/hashicorp/go-immutable-radix v1.3.1 // indirect github.com/hashicorp/go-uuid v1.0.1 // indirect github.com/hashicorp/golang-lru v1.0.2 // indirect github.com/klauspost/compress v1.17.7 // indirect @@ -55,12 +56,10 @@ require ( github.com/rogpeppe/go-internal v1.12.0 // indirect github.com/rs/zerolog v1.33.0 // indirect github.com/tidwall/btree v1.7.0 // indirect - golang.org/x/crypto v0.24.0 // indirect + golang.org/x/crypto v0.25.0 // indirect golang.org/x/exp v0.0.0-20240314144324-c7f7c6466f7f // indirect golang.org/x/sys v0.22.0 // indirect golang.org/x/text v0.16.0 // indirect - google.golang.org/genproto/googleapis/rpc v0.0.0-20240709173604-40e1e62336c5 // indirect - google.golang.org/grpc v1.64.1 // indirect google.golang.org/protobuf v1.34.2 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect ) @@ -68,5 +67,3 @@ require ( replace cosmossdk.io/core => ../../core replace cosmossdk.io/core/testing => ../../core/testing - -replace cosmossdk.io/log => ../../log diff --git a/store/v2/go.sum b/store/v2/go.sum index 66d125306c7a..425eb1d56e9e 100644 --- a/store/v2/go.sum +++ b/store/v2/go.sum @@ -1,5 +1,7 @@ -cosmossdk.io/errors v1.0.1 h1:bzu+Kcr0kS/1DuPBtUFdWjzLqyUuCiyHjyJB6srBV/0= -cosmossdk.io/errors v1.0.1/go.mod h1:MeelVSZThMi4bEakzhhhE/CKqVv3nOJDA25bIqRDu/U= +cosmossdk.io/errors/v2 v2.0.0-20240731132947-df72853b3ca5 h1:IQNdY2kB+k+1OM2DvqFG1+UgeU1JzZrWtwuWzI3ZfwA= +cosmossdk.io/errors/v2 v2.0.0-20240731132947-df72853b3ca5/go.mod h1:0CuYKkFHxc1vw2JC+t21THBCALJVROrWVR/3PQ1urpc= +cosmossdk.io/log v1.3.1 h1:UZx8nWIkfbbNEWusZqzAx3ZGvu54TZacWib3EzUYmGI= +cosmossdk.io/log v1.3.1/go.mod h1:2/dIomt8mKdk6vl3OWJcPk2be3pGOS8OQaLUM/3/tCM= github.com/DataDog/datadog-go v3.2.0+incompatible/go.mod h1:LButxg5PwREeZtORoXG3tL4fMGNddJ+vMq1mwgfaqoQ= github.com/DataDog/zstd v1.5.5 h1:oWf5W7GtOLgp6bciQYDmhHHjdhYkALu6S/5Ni9ZgSvQ= github.com/DataDog/zstd v1.5.5/go.mod h1:g4AWEaM3yOg3HYfnJ3YIawPnVdXJh9QME85blwSAmyw= @@ -36,8 +38,8 @@ github.com/cosmos/cosmos-db v1.0.2 h1:hwMjozuY1OlJs/uh6vddqnk9j7VamLv+0DBlbEXbAK github.com/cosmos/cosmos-db v1.0.2/go.mod h1:Z8IXcFJ9PqKK6BIsVOB3QXtkKoqUOp1vRvPT39kOXEA= github.com/cosmos/gogoproto v1.5.0 h1:SDVwzEqZDDBoslaeZg+dGE55hdzHfgUA40pEanMh52o= github.com/cosmos/gogoproto v1.5.0/go.mod h1:iUM31aofn3ymidYG6bUR5ZFrk+Om8p5s754eMUcyp8I= -github.com/cosmos/iavl v1.2.0 h1:kVxTmjTh4k0Dh1VNL046v6BXqKziqMDzxo93oh3kOfM= -github.com/cosmos/iavl v1.2.0/go.mod h1:HidWWLVAtODJqFD6Hbne2Y0q3SdxByJepHUOeoH4LiI= +github.com/cosmos/iavl v1.2.1-0.20240725141113-7adc688cf179 h1:wmwDn7V3RodN9auB3FooSQxs46nHVE3u0mb87TJkZFE= +github.com/cosmos/iavl v1.2.1-0.20240725141113-7adc688cf179/go.mod h1:GiM43q0pB+uG53mLxLDzimxM9l/5N9UuSY3/D0huuVw= github.com/cosmos/ics23/go v0.10.0 h1:iXqLLgp2Lp+EdpIuwXTYIQU+AiHj9mOC2X9ab++bZDM= github.com/cosmos/ics23/go v0.10.0/go.mod h1:ZfJSmng/TBNTBkFemHHHj5YY7VAU/MBU980F4VU1NG0= github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E= @@ -96,8 +98,9 @@ github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeN github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= github.com/google/pprof v0.0.0-20210407192527-94a9f03dee38/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE= github.com/hashicorp/go-cleanhttp v0.5.0/go.mod h1:JpRdi6/HCYpAwUzNwuwqhbovhLtngrth3wmdIIUrZ80= -github.com/hashicorp/go-immutable-radix v1.0.0 h1:AKDB1HM5PWEA7i4nhcpwOrO2byshxBjXVn/J/3+z5/0= github.com/hashicorp/go-immutable-radix v1.0.0/go.mod h1:0y9vanUI8NX6FsYoO3zeMjhV/C5i9g4Q3DwcSNZ4P60= +github.com/hashicorp/go-immutable-radix v1.3.1 h1:DKHmCUm2hRBK510BaiZlwvpD40f8bJFeZnpfm2KLowc= +github.com/hashicorp/go-immutable-radix v1.3.1/go.mod h1:0y9vanUI8NX6FsYoO3zeMjhV/C5i9g4Q3DwcSNZ4P60= github.com/hashicorp/go-metrics v0.5.3 h1:M5uADWMOGCTUNU1YuC4hfknOeHNaX54LDm4oYSucoNE= github.com/hashicorp/go-metrics v0.5.3/go.mod h1:KEjodfebIOuBYSAe/bHTm+HChmKSxAOXPBieMLYozDE= github.com/hashicorp/go-retryablehttp v0.5.3/go.mod h1:9B5zBasrRhHXnJnui7y6sL7es7NDiJgTc6Er0maI1Xs= @@ -219,8 +222,8 @@ golang.org/x/crypto v0.0.0-20180904163835-0709b304e793/go.mod h1:6SG95UA2DQfeDnf golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= -golang.org/x/crypto v0.24.0 h1:mnl8DM0o513X8fdIkmyFE/5hTYxbwYOjDS/+rK6qpRI= -golang.org/x/crypto v0.24.0/go.mod h1:Z1PMYSOR5nyMcyAVAIQSKCDwalqy85Aqn1x3Ws4L5DM= +golang.org/x/crypto v0.25.0 h1:ypSNr+bnYL2YhwoMt2zPxHFmbAN1KZs/njMG3hxUp30= +golang.org/x/crypto v0.25.0/go.mod h1:T+wALwcMOSE0kXgUAnPAHqTLW+XHgcELELW8VaDgm/M= golang.org/x/exp v0.0.0-20240314144324-c7f7c6466f7f h1:3CW0unweImhOzd5FmYuRsD4Y4oQFKZIjAnKbjV4WIrw= golang.org/x/exp v0.0.0-20240314144324-c7f7c6466f7f/go.mod h1:CxmFvTBINI24O/j8iY7H1xHzx2i4OsyguNBmN/uPtqc= golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= @@ -289,10 +292,6 @@ golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8T golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20220517211312-f3a8303e98df/go.mod h1:K8+ghG5WaK9qNqU5K3HdILfMLy1f3aNYFI/wnl100a8= -google.golang.org/genproto/googleapis/rpc v0.0.0-20240709173604-40e1e62336c5 h1:SbSDUWW1PAO24TNpLdeheoYPd7kllICcLU52x6eD4kQ= -google.golang.org/genproto/googleapis/rpc v0.0.0-20240709173604-40e1e62336c5/go.mod h1:Ue6ibwXGpU+dqIcODieyLOcgj7z8+IcskoNIgZxtrFY= -google.golang.org/grpc v1.64.1 h1:LKtvyfbX3UGVPFcGqJ9ItpVWW6oN/2XqTxfAnwRRXiA= -google.golang.org/grpc v1.64.1/go.mod h1:hiQF4LFZelK2WKaP6W0L92zGHtiQdZxk8CrSdvyjeP0= google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8= google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0= google.golang.org/protobuf v0.0.0-20200228230310-ab0ca4ff8a60/go.mod h1:cfTl7dwQJ+fmap5saPgwCLgHXTUD7jkjRqWcaiX5VyM= diff --git a/store/v2/migration/manager.go b/store/v2/migration/manager.go index bd636dc3c600..a7ce8204a4b3 100644 --- a/store/v2/migration/manager.go +++ b/store/v2/migration/manager.go @@ -183,8 +183,13 @@ func (m *Manager) writeChangeset() error { batch := m.db.NewBatch() // Invoking this code in a closure so that defer is called immediately on return // yet not in the for-loop which can leave resource lingering. - err = func() error { - defer batch.Close() + err = func() (err error) { + defer func() { + cErr := batch.Close() + if err == nil { + err = cErr + } + }() if err := batch.Set(csKey, csBytes); err != nil { return fmt.Errorf("failed to write changeset to db.Batch: %w", err) @@ -215,7 +220,7 @@ func (m *Manager) GetMigratedVersion() uint64 { func (m *Manager) Sync() error { version := m.GetMigratedVersion() if version == 0 { - return fmt.Errorf("migration is not done yet") + return errors.New("migration is not done yet") } version += 1 diff --git a/store/v2/migration/manager_test.go b/store/v2/migration/manager_test.go index d57c4a67c22a..d8365ce07579 100644 --- a/store/v2/migration/manager_test.go +++ b/store/v2/migration/manager_test.go @@ -79,6 +79,11 @@ func TestMigrateState(t *testing.T) { err := m.Migrate(toVersion - 1) require.NoError(t, err) + // expecting error for conflicting process, since Migrate trigger snapshotter create migration, + // which start a snapshot process already. + _, err = m.snapshotsManager.Create(toVersion - 1) + require.Error(t, err) + if m.stateCommitment != nil { // check the migrated state for version := uint64(1); version < toVersion; version++ { diff --git a/store/v2/options.go b/store/v2/options.go index 9c20d8494230..f87475e4a6d2 100644 --- a/store/v2/options.go +++ b/store/v2/options.go @@ -18,13 +18,14 @@ const ( ) // PruningOption defines the pruning configuration. +// app.toml config options type PruningOption struct { // KeepRecent sets the number of recent versions to keep. - KeepRecent uint64 + KeepRecent uint64 `mapstructure:"keep-recent" toml:"keep-recent" comment:"Number of recent heights to keep on disk."` // Interval sets the number of how often to prune. // If set to 0, no pruning will be done. - Interval uint64 + Interval uint64 `mapstructure:"interval" toml:"interval" comment:"Height interval at which pruned heights are removed from disk."` } // NewPruningOption returns a new PruningOption instance based on the given pruning strategy. diff --git a/store/v2/proof/proof.go b/store/v2/proof/proof.go index 120cf3d2a13b..01a31227b7b5 100644 --- a/store/v2/proof/proof.go +++ b/store/v2/proof/proof.go @@ -5,7 +5,7 @@ import ( ics23 "github.com/cosmos/ics23/go" - "cosmossdk.io/errors" + errors "cosmossdk.io/errors/v2" storeerrors "cosmossdk.io/store/v2/errors" ) diff --git a/store/v2/pruning/manager_test.go b/store/v2/pruning/manager_test.go index d75aea8e5156..607af22bc722 100644 --- a/store/v2/pruning/manager_test.go +++ b/store/v2/pruning/manager_test.go @@ -9,7 +9,7 @@ import ( "github.com/stretchr/testify/suite" corestore "cosmossdk.io/core/store" - "cosmossdk.io/log" + coretesting "cosmossdk.io/core/testing" "cosmossdk.io/store/v2" "cosmossdk.io/store/v2/commitment" "cosmossdk.io/store/v2/commitment/iavl" @@ -33,7 +33,7 @@ func TestPruningManagerTestSuite(t *testing.T) { } func (s *PruningManagerTestSuite) SetupTest() { - nopLog := log.NewNopLogger() + nopLog := coretesting.NewNopLogger() var err error mdb := dbm.NewMemDB() diff --git a/store/v2/root/factory.go b/store/v2/root/factory.go index 7139f48abf87..563e439815bc 100644 --- a/store/v2/root/factory.go +++ b/store/v2/root/factory.go @@ -32,16 +32,40 @@ const ( SCTypeIavlV2 SCType = 1 ) +// app.toml config options +type Options struct { + SSType SSType `mapstructure:"ss-type" toml:"ss-type" comment:"State storage database type. Currently we support: 0 for SQLite, 1 for Pebble"` + SCType SCType `mapstructure:"sc-type" toml:"sc-type" comment:"State commitment database type. Currently we support:0 for iavl, 1 for iavl v2"` + SSPruningOption *store.PruningOption `mapstructure:"ss-pruning-option" toml:"ss-pruning-option" comment:"Pruning options for state storage"` + SCPruningOption *store.PruningOption `mapstructure:"sc-pruning-option" toml:"sc-pruning-option" comment:"Pruning options for state commitment"` + IavlConfig *iavl.Config `mapstructure:"iavl-config" toml:"iavl-config"` +} + type FactoryOptions struct { - Logger log.Logger - RootDir string - SSType SSType - SCType SCType - SSPruningOption *store.PruningOption - SCPruningOption *store.PruningOption - IavlConfig *iavl.Config - StoreKeys []string - SCRawDB corestore.KVStoreWithBatch + Logger log.Logger + RootDir string + Options Options + StoreKeys []string + SCRawDB corestore.KVStoreWithBatch +} + +func DefaultStoreOptions() Options { + return Options{ + SSType: 0, + SCType: 0, + SCPruningOption: &store.PruningOption{ + KeepRecent: 2, + Interval: 1, + }, + SSPruningOption: &store.PruningOption{ + KeepRecent: 2, + Interval: 1, + }, + IavlConfig: &iavl.Config{ + CacheSize: 100_000, + SkipFastStorageUpgrade: true, + }, + } } // CreateRootStore is a convenience function to create a root store based on the @@ -62,7 +86,8 @@ func CreateRootStore(opts *FactoryOptions) (store.RootStore, error) { } ) - switch opts.SSType { + storeOpts := opts.Options + switch storeOpts.SSType { case SSTypeSQLite: dir := fmt.Sprintf("%s/data/ss/sqlite", opts.RootDir) if err = ensureDir(dir); err != nil { @@ -107,9 +132,9 @@ func CreateRootStore(opts *FactoryOptions) (store.RootStore, error) { if internal.IsMemoryStoreKey(key) { trees[key] = mem.New() } else { - switch opts.SCType { + switch storeOpts.SCType { case SCTypeIavl: - trees[key] = iavl.NewIavlTree(db.NewPrefixDB(opts.SCRawDB, []byte(key)), opts.Logger, opts.IavlConfig) + trees[key] = iavl.NewIavlTree(db.NewPrefixDB(opts.SCRawDB, []byte(key)), opts.Logger, storeOpts.IavlConfig) case SCTypeIavlV2: return nil, errors.New("iavl v2 not supported") } @@ -120,7 +145,7 @@ func CreateRootStore(opts *FactoryOptions) (store.RootStore, error) { return nil, err } - pm := pruning.NewManager(sc, ss, opts.SCPruningOption, opts.SSPruningOption) + pm := pruning.NewManager(sc, ss, storeOpts.SCPruningOption, storeOpts.SSPruningOption) return New(opts.Logger, ss, sc, pm, nil, nil) } diff --git a/store/v2/root/store.go b/store/v2/root/store.go index 997f9d0f485e..56f722282f45 100644 --- a/store/v2/root/store.go +++ b/store/v2/root/store.go @@ -11,7 +11,7 @@ import ( "golang.org/x/sync/errgroup" coreheader "cosmossdk.io/core/header" - "cosmossdk.io/core/log" + corelog "cosmossdk.io/core/log" corestore "cosmossdk.io/core/store" "cosmossdk.io/store/v2" "cosmossdk.io/store/v2/metrics" @@ -27,7 +27,7 @@ var _ store.RootStore = (*Store)(nil) // backend may or may not support multiple store keys and is implementation // dependent. type Store struct { - logger log.Logger + logger corelog.Logger initialVersion uint64 // stateStorage reflects the state storage backend @@ -65,7 +65,7 @@ type Store struct { // // NOTE: The migration manager is optional and can be nil if no migration is required. func New( - logger log.Logger, + logger corelog.Logger, ss store.VersionedDatabase, sc store.Committer, pm *pruning.Manager, @@ -73,7 +73,7 @@ func New( m metrics.StoreMetrics, ) (store.RootStore, error) { return &Store{ - logger: logger.With("module", "root_store"), + logger: logger, initialVersion: 1, stateStorage: ss, stateCommitment: sc, @@ -467,3 +467,7 @@ func (s *Store) commitSC() error { return nil } + +func (s *Store) Prune(version uint64) error { + return s.pruningManager.Prune(version) +} diff --git a/store/v2/root/store_test.go b/store/v2/root/store_test.go index dd22fcaf4131..b2b640feb974 100644 --- a/store/v2/root/store_test.go +++ b/store/v2/root/store_test.go @@ -630,7 +630,7 @@ func (s *RootStoreTestSuite) TestMultiStore_PruningRestart() { return false } // wait for async pruning process to finish - s.Require().Eventually(checkErr, 2*time.Second, 100*time.Millisecond, "expected error when loading height: %d", v) + s.Require().Eventually(checkErr, 5*time.Second, 100*time.Millisecond, "expected error when loading height: %d", v) } } diff --git a/store/v2/snapshots/chunk.go b/store/v2/snapshots/chunk.go index 9049460a1874..1bacf58c1089 100644 --- a/store/v2/snapshots/chunk.go +++ b/store/v2/snapshots/chunk.go @@ -2,10 +2,10 @@ package snapshots import ( stderrors "errors" + "fmt" "io" "math" - "cosmossdk.io/errors" storeerrors "cosmossdk.io/store/v2/errors" snapshotstypes "cosmossdk.io/store/v2/snapshots/types" ) @@ -73,7 +73,7 @@ func (w *ChunkWriter) CloseWithError(err error) { // Write implements io.Writer. func (w *ChunkWriter) Write(data []byte) (int, error) { if w.closed { - return 0, errors.Wrap(storeerrors.ErrLogic, "cannot write to closed ChunkWriter") + return 0, fmt.Errorf("cannot write to closed ChunkWriter: %w", storeerrors.ErrLogic) } nTotal := 0 for len(data) > 0 { @@ -171,15 +171,15 @@ func DrainChunks(chunks <-chan io.ReadCloser) { // ValidRestoreHeight will check height is valid for snapshot restore or not func ValidRestoreHeight(format uint32, height uint64) error { if format != snapshotstypes.CurrentFormat { - return errors.Wrapf(snapshotstypes.ErrUnknownFormat, "format %v", format) + return fmt.Errorf("format %v: %w", format, snapshotstypes.ErrUnknownFormat) } if height == 0 { - return errors.Wrap(storeerrors.ErrLogic, "cannot restore snapshot at height 0") + return fmt.Errorf("cannot restore snapshot at height 0: %w", storeerrors.ErrLogic) } if height > uint64(math.MaxInt64) { - return errors.Wrapf(snapshotstypes.ErrInvalidMetadata, - "snapshot height %v cannot exceed %v", height, int64(math.MaxInt64)) + return fmt.Errorf( + "snapshot height %v cannot exceed %v: %w", height, int64(math.MaxInt64), snapshotstypes.ErrInvalidMetadata) } return nil diff --git a/store/v2/snapshots/helpers_test.go b/store/v2/snapshots/helpers_test.go index 3157f3531608..129704325c6a 100644 --- a/store/v2/snapshots/helpers_test.go +++ b/store/v2/snapshots/helpers_test.go @@ -6,6 +6,7 @@ import ( "compress/zlib" "crypto/sha256" "errors" + "fmt" "io" "testing" "time" @@ -15,7 +16,6 @@ import ( corestore "cosmossdk.io/core/store" coretesting "cosmossdk.io/core/testing" - errorsmod "cosmossdk.io/errors" "cosmossdk.io/store/v2/snapshots" snapshotstypes "cosmossdk.io/store/v2/snapshots/types" ) @@ -126,7 +126,7 @@ func (m *mockCommitSnapshotter) Restore( if errors.Is(err, io.EOF) { break } else if err != nil { - return snapshotstypes.SnapshotItem{}, errorsmod.Wrap(err, "invalid protobuf message") + return snapshotstypes.SnapshotItem{}, fmt.Errorf("invalid protobuf message: %w", err) } payload := item.GetExtensionPayload() if payload == nil { diff --git a/store/v2/snapshots/manager.go b/store/v2/snapshots/manager.go index 75e6e4ad616c..9380b3021b4d 100644 --- a/store/v2/snapshots/manager.go +++ b/store/v2/snapshots/manager.go @@ -11,9 +11,9 @@ import ( "sort" "sync" - "cosmossdk.io/core/log" + corelog "cosmossdk.io/core/log" corestore "cosmossdk.io/core/store" - errorsmod "cosmossdk.io/errors" + errorsmod "cosmossdk.io/errors/v2" storeerrors "cosmossdk.io/store/v2/errors" "cosmossdk.io/store/v2/snapshots/types" ) @@ -41,7 +41,7 @@ type Manager struct { // storageSnapshotter is the snapshotter for the storage state. storageSnapshotter StorageSnapshotter - logger log.Logger + logger corelog.Logger mtx sync.Mutex operation operation @@ -76,7 +76,7 @@ const ( var ErrOptsZeroSnapshotInterval = errors.New("snapshot-interval must not be 0") // NewManager creates a new manager. -func NewManager(store *Store, opts SnapshotOptions, commitSnapshotter CommitSnapshotter, storageSnapshotter StorageSnapshotter, extensions map[string]ExtensionSnapshotter, logger log.Logger) *Manager { +func NewManager(store *Store, opts SnapshotOptions, commitSnapshotter CommitSnapshotter, storageSnapshotter StorageSnapshotter, extensions map[string]ExtensionSnapshotter, logger corelog.Logger) *Manager { if extensions == nil { extensions = map[string]ExtensionSnapshotter{} } @@ -86,7 +86,7 @@ func NewManager(store *Store, opts SnapshotOptions, commitSnapshotter CommitSnap commitSnapshotter: commitSnapshotter, storageSnapshotter: storageSnapshotter, extensions: extensions, - logger: logger.With("module", "snapshot_manager"), + logger: logger, } } diff --git a/store/v2/snapshots/manager_test.go b/store/v2/snapshots/manager_test.go index f7ec801d7be2..4fd33e1b36fa 100644 --- a/store/v2/snapshots/manager_test.go +++ b/store/v2/snapshots/manager_test.go @@ -254,3 +254,167 @@ func TestManager_TakeError(t *testing.T) { _, err = manager.Create(1) require.Error(t, err) } + +func TestSnapshot_Take_Restore(t *testing.T) { + store := setupStore(t) + items := [][]byte{ + {1, 2, 3}, + {4, 5, 6}, + {7, 8, 9}, + } + commitSnapshotter := &mockCommitSnapshotter{ + items: items, + } + extSnapshotter := newExtSnapshotter(10) + + expectChunks := snapshotItems(items, extSnapshotter) + manager := snapshots.NewManager(store, opts, commitSnapshotter, &mockStorageSnapshotter{}, nil, coretesting.NewNopLogger()) + err := manager.RegisterExtensions(extSnapshotter) + require.NoError(t, err) + + // creating a snapshot at a higher height should be fine, and should return it + snapshot, err := manager.Create(5) + require.NoError(t, err) + + assert.Equal(t, &types.Snapshot{ + Height: 5, + Format: commitSnapshotter.SnapshotFormat(), + Chunks: 1, + Hash: []uint8{0xc5, 0xf7, 0xfe, 0xea, 0xd3, 0x4d, 0x3e, 0x87, 0xff, 0x41, 0xa2, 0x27, 0xfa, 0xcb, 0x38, 0x17, 0xa, 0x5, 0xeb, 0x27, 0x4e, 0x16, 0x5e, 0xf3, 0xb2, 0x8b, 0x47, 0xd1, 0xe6, 0x94, 0x7e, 0x8b}, + Metadata: types.Metadata{ + ChunkHashes: checksums(expectChunks), + }, + }, snapshot) + + storeSnapshot, chunks, err := store.Load(snapshot.Height, snapshot.Format) + require.NoError(t, err) + assert.Equal(t, snapshot, storeSnapshot) + assert.Equal(t, expectChunks, readChunks(chunks)) + + err = manager.Restore(*snapshot) + require.NoError(t, err) + + // Feeding the chunks should work + for i, chunk := range readChunks(chunks) { + done, err := manager.RestoreChunk(chunk) + require.NoError(t, err) + if i == len(chunks)-1 { + assert.True(t, done) + } else { + assert.False(t, done) + } + } + + // The snapshot is saved in local snapshot store + snapshots, err := store.List() + require.NoError(t, err) + require.Equal(t, uint64(5), snapshots[0].Height) + require.Equal(t, types.CurrentFormat, snapshots[0].Format) + + // Starting a new restore should fail now, because the target already has contents. + err = manager.Restore(*snapshot) + require.Error(t, err) + + storeSnapshot, chunks, err = store.Load(snapshot.Height, snapshot.Format) + require.NoError(t, err) + assert.Equal(t, snapshot, storeSnapshot) + assert.Equal(t, expectChunks, readChunks(chunks)) + + // Feeding the chunks should work + for i, chunk := range readChunks(chunks) { + done, err := manager.RestoreChunk(chunk) + require.NoError(t, err) + if i == len(chunks)-1 { + assert.True(t, done) + } else { + assert.False(t, done) + } + } + + assert.Equal(t, items, commitSnapshotter.items) + assert.Equal(t, 10, len(extSnapshotter.state)) + + snapshots, err = store.List() + require.NoError(t, err) + require.Equal(t, uint64(5), snapshots[0].Height) + require.Equal(t, types.CurrentFormat, snapshots[0].Format) +} + +func TestSnapshot_Take_Prune(t *testing.T) { + store := setupStore(t) + + items := [][]byte{ + {1, 2, 3}, + {4, 5, 6}, + {7, 8, 9}, + } + commitSnapshotter := &mockCommitSnapshotter{ + items: items, + } + extSnapshotter := newExtSnapshotter(10) + + expectChunks := snapshotItems(items, extSnapshotter) + manager := snapshots.NewManager(store, opts, commitSnapshotter, &mockStorageSnapshotter{}, nil, coretesting.NewNopLogger()) + err := manager.RegisterExtensions(extSnapshotter) + require.NoError(t, err) + + // creating a snapshot at height 4 + snapshot, err := manager.Create(4) + require.NoError(t, err) + + assert.Equal(t, &types.Snapshot{ + Height: 4, + Format: commitSnapshotter.SnapshotFormat(), + Chunks: 1, + Hash: []uint8{0xc5, 0xf7, 0xfe, 0xea, 0xd3, 0x4d, 0x3e, 0x87, 0xff, 0x41, 0xa2, 0x27, 0xfa, 0xcb, 0x38, 0x17, 0xa, 0x5, 0xeb, 0x27, 0x4e, 0x16, 0x5e, 0xf3, 0xb2, 0x8b, 0x47, 0xd1, 0xe6, 0x94, 0x7e, 0x8b}, + Metadata: types.Metadata{ + ChunkHashes: checksums(expectChunks), + }, + }, snapshot) + + pruned, err := manager.Prune(1) + require.NoError(t, err) + assert.EqualValues(t, 4, pruned) + + // creating a snapshot at a same height 4, should be error + // since we prune all the previous snapshot except the latest at height 4 + _, err = manager.Create(4) + require.Error(t, err) + + // prune all + pruned, err = manager.Prune(0) + require.NoError(t, err) + assert.EqualValues(t, 1, pruned) + + // creating a snapshot at a same height 4, should be true since we prune all the previous snapshot + snapshot, err = manager.Create(4) + require.NoError(t, err) + + assert.Equal(t, &types.Snapshot{ + Height: 4, + Format: commitSnapshotter.SnapshotFormat(), + Chunks: 1, + Hash: []uint8{0xc5, 0xf7, 0xfe, 0xea, 0xd3, 0x4d, 0x3e, 0x87, 0xff, 0x41, 0xa2, 0x27, 0xfa, 0xcb, 0x38, 0x17, 0xa, 0x5, 0xeb, 0x27, 0x4e, 0x16, 0x5e, 0xf3, 0xb2, 0x8b, 0x47, 0xd1, 0xe6, 0x94, 0x7e, 0x8b}, + Metadata: types.Metadata{ + ChunkHashes: checksums(expectChunks), + }, + }, snapshot) + + storeSnapshot, chunks, err := store.Load(snapshot.Height, snapshot.Format) + require.NoError(t, err) + assert.Equal(t, snapshot, storeSnapshot) + assert.Equal(t, expectChunks, readChunks(chunks)) + + pruned, err = manager.Prune(2) + require.NoError(t, err) + assert.EqualValues(t, 0, pruned) + + list, err := manager.List() + require.NoError(t, err) + assert.Len(t, list, 1) + + // Prune should error while a snapshot is being taken + manager = setupBusyManager(t) + _, err = manager.Prune(2) + require.Error(t, err) +} diff --git a/store/v2/snapshots/store.go b/store/v2/snapshots/store.go index 50c8e1dbd6ac..f74461e8ecf2 100644 --- a/store/v2/snapshots/store.go +++ b/store/v2/snapshots/store.go @@ -17,7 +17,7 @@ import ( "github.com/cosmos/gogoproto/proto" corestore "cosmossdk.io/core/store" - "cosmossdk.io/errors" + "cosmossdk.io/errors/v2" storeerrors "cosmossdk.io/store/v2/errors" "cosmossdk.io/store/v2/snapshots/types" ) @@ -38,15 +38,15 @@ type Store struct { // NewStore creates a new snapshot store. func NewStore(dir string) (*Store, error) { if dir == "" { - return nil, errors.Wrap(storeerrors.ErrLogic, "snapshot directory not given") + return nil, fmt.Errorf("snapshot directory not given: %w", storeerrors.ErrLogic) } err := os.MkdirAll(dir, 0o755) if err != nil { - return nil, errors.Wrapf(err, "failed to create snapshot directory %q", dir) + return nil, fmt.Errorf("failed to create snapshot directory %q: %w", dir, err) } err = os.MkdirAll(filepath.Join(dir, "metadata"), 0o750) if err != nil { - return nil, errors.Wrapf(err, "failed to create snapshot metadata directory %q", dir) + return nil, fmt.Errorf("failed to create snapshot metadata directory %q: %w", dir, err) } return &Store{ diff --git a/store/v2/snapshots/stream.go b/store/v2/snapshots/stream.go index 4662d138b233..5f990983a78f 100644 --- a/store/v2/snapshots/stream.go +++ b/store/v2/snapshots/stream.go @@ -8,7 +8,7 @@ import ( protoio "github.com/cosmos/gogoproto/io" "github.com/cosmos/gogoproto/proto" - "cosmossdk.io/errors" + "cosmossdk.io/errors/v2" ) const ( diff --git a/store/v2/snapshots/types/snapshot.pb.go b/store/v2/snapshots/types/snapshot.pb.go index 686e11905a4a..224c826846e9 100644 --- a/store/v2/snapshots/types/snapshot.pb.go +++ b/store/v2/snapshots/types/snapshot.pb.go @@ -1,5 +1,5 @@ // Code generated by protoc-gen-gogo. DO NOT EDIT. -// source: cosmos/store/snapshots/v1/snapshot.proto +// source: cosmos/store/snapshots/v2/snapshot.proto package types @@ -36,7 +36,7 @@ func (m *Snapshot) Reset() { *m = Snapshot{} } func (m *Snapshot) String() string { return proto.CompactTextString(m) } func (*Snapshot) ProtoMessage() {} func (*Snapshot) Descriptor() ([]byte, []int) { - return fileDescriptor_3d5cca1aa5b69183, []int{0} + return fileDescriptor_6851f1463fcbb80c, []int{0} } func (m *Snapshot) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -109,7 +109,7 @@ func (m *Metadata) Reset() { *m = Metadata{} } func (m *Metadata) String() string { return proto.CompactTextString(m) } func (*Metadata) ProtoMessage() {} func (*Metadata) Descriptor() ([]byte, []int) { - return fileDescriptor_3d5cca1aa5b69183, []int{1} + return fileDescriptor_6851f1463fcbb80c, []int{1} } func (m *Metadata) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -146,8 +146,6 @@ func (m *Metadata) GetChunkHashes() [][]byte { } // SnapshotItem is an item contained in a rootmulti.Store snapshot. -// -// Since: cosmos-sdk 0.46 type SnapshotItem struct { // item is the specific type of snapshot item. // @@ -164,7 +162,7 @@ func (m *SnapshotItem) Reset() { *m = SnapshotItem{} } func (m *SnapshotItem) String() string { return proto.CompactTextString(m) } func (*SnapshotItem) ProtoMessage() {} func (*SnapshotItem) Descriptor() ([]byte, []int) { - return fileDescriptor_3d5cca1aa5b69183, []int{2} + return fileDescriptor_6851f1463fcbb80c, []int{2} } func (m *SnapshotItem) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -263,8 +261,6 @@ func (*SnapshotItem) XXX_OneofWrappers() []interface{} { } // SnapshotStoreItem contains metadata about a snapshotted store. -// -// Since: cosmos-sdk 0.46 type SnapshotStoreItem struct { Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"` } @@ -273,7 +269,7 @@ func (m *SnapshotStoreItem) Reset() { *m = SnapshotStoreItem{} } func (m *SnapshotStoreItem) String() string { return proto.CompactTextString(m) } func (*SnapshotStoreItem) ProtoMessage() {} func (*SnapshotStoreItem) Descriptor() ([]byte, []int) { - return fileDescriptor_3d5cca1aa5b69183, []int{3} + return fileDescriptor_6851f1463fcbb80c, []int{3} } func (m *SnapshotStoreItem) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -310,8 +306,6 @@ func (m *SnapshotStoreItem) GetName() string { } // SnapshotIAVLItem is an exported IAVL node. -// -// Since: cosmos-sdk 0.46 type SnapshotIAVLItem struct { Key []byte `protobuf:"bytes,1,opt,name=key,proto3" json:"key,omitempty"` Value []byte `protobuf:"bytes,2,opt,name=value,proto3" json:"value,omitempty"` @@ -325,7 +319,7 @@ func (m *SnapshotIAVLItem) Reset() { *m = SnapshotIAVLItem{} } func (m *SnapshotIAVLItem) String() string { return proto.CompactTextString(m) } func (*SnapshotIAVLItem) ProtoMessage() {} func (*SnapshotIAVLItem) Descriptor() ([]byte, []int) { - return fileDescriptor_3d5cca1aa5b69183, []int{4} + return fileDescriptor_6851f1463fcbb80c, []int{4} } func (m *SnapshotIAVLItem) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -383,8 +377,6 @@ func (m *SnapshotIAVLItem) GetHeight() int32 { } // SnapshotExtensionMeta contains metadata about an external snapshotter. -// -// Since: cosmos-sdk 0.46 type SnapshotExtensionMeta struct { Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"` Format uint32 `protobuf:"varint,2,opt,name=format,proto3" json:"format,omitempty"` @@ -394,7 +386,7 @@ func (m *SnapshotExtensionMeta) Reset() { *m = SnapshotExtensionMeta{} } func (m *SnapshotExtensionMeta) String() string { return proto.CompactTextString(m) } func (*SnapshotExtensionMeta) ProtoMessage() {} func (*SnapshotExtensionMeta) Descriptor() ([]byte, []int) { - return fileDescriptor_3d5cca1aa5b69183, []int{5} + return fileDescriptor_6851f1463fcbb80c, []int{5} } func (m *SnapshotExtensionMeta) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -438,8 +430,6 @@ func (m *SnapshotExtensionMeta) GetFormat() uint32 { } // SnapshotExtensionPayload contains payloads of an external snapshotter. -// -// Since: cosmos-sdk 0.46 type SnapshotExtensionPayload struct { Payload []byte `protobuf:"bytes,1,opt,name=payload,proto3" json:"payload,omitempty"` } @@ -448,7 +438,7 @@ func (m *SnapshotExtensionPayload) Reset() { *m = SnapshotExtensionPaylo func (m *SnapshotExtensionPayload) String() string { return proto.CompactTextString(m) } func (*SnapshotExtensionPayload) ProtoMessage() {} func (*SnapshotExtensionPayload) Descriptor() ([]byte, []int) { - return fileDescriptor_3d5cca1aa5b69183, []int{6} + return fileDescriptor_6851f1463fcbb80c, []int{6} } func (m *SnapshotExtensionPayload) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -485,52 +475,55 @@ func (m *SnapshotExtensionPayload) GetPayload() []byte { } func init() { - proto.RegisterType((*Snapshot)(nil), "cosmos.store.snapshots.v1.Snapshot") - proto.RegisterType((*Metadata)(nil), "cosmos.store.snapshots.v1.Metadata") - proto.RegisterType((*SnapshotItem)(nil), "cosmos.store.snapshots.v1.SnapshotItem") - proto.RegisterType((*SnapshotStoreItem)(nil), "cosmos.store.snapshots.v1.SnapshotStoreItem") - proto.RegisterType((*SnapshotIAVLItem)(nil), "cosmos.store.snapshots.v1.SnapshotIAVLItem") - proto.RegisterType((*SnapshotExtensionMeta)(nil), "cosmos.store.snapshots.v1.SnapshotExtensionMeta") - proto.RegisterType((*SnapshotExtensionPayload)(nil), "cosmos.store.snapshots.v1.SnapshotExtensionPayload") + proto.RegisterType((*Snapshot)(nil), "cosmos.store.snapshots.v2.Snapshot") + proto.RegisterType((*Metadata)(nil), "cosmos.store.snapshots.v2.Metadata") + proto.RegisterType((*SnapshotItem)(nil), "cosmos.store.snapshots.v2.SnapshotItem") + proto.RegisterType((*SnapshotStoreItem)(nil), "cosmos.store.snapshots.v2.SnapshotStoreItem") + proto.RegisterType((*SnapshotIAVLItem)(nil), "cosmos.store.snapshots.v2.SnapshotIAVLItem") + proto.RegisterType((*SnapshotExtensionMeta)(nil), "cosmos.store.snapshots.v2.SnapshotExtensionMeta") + proto.RegisterType((*SnapshotExtensionPayload)(nil), "cosmos.store.snapshots.v2.SnapshotExtensionPayload") } func init() { - proto.RegisterFile("cosmos/store/snapshots/v1/snapshot.proto", fileDescriptor_3d5cca1aa5b69183) -} - -var fileDescriptor_3d5cca1aa5b69183 = []byte{ - // 496 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94, 0x53, 0x41, 0x6f, 0xd3, 0x30, - 0x14, 0x8e, 0xd7, 0xb4, 0x74, 0x2f, 0x41, 0xea, 0xac, 0x81, 0x02, 0x87, 0x2c, 0x84, 0x03, 0x91, - 0x80, 0x94, 0x65, 0x1c, 0xb9, 0x50, 0x98, 0x94, 0x09, 0x90, 0x26, 0x4f, 0xe2, 0xc0, 0x65, 0xf2, - 0x56, 0xd3, 0x44, 0x6d, 0xe2, 0xaa, 0xf6, 0x22, 0xfa, 0x2f, 0xf8, 0x23, 0xfc, 0x8f, 0x1d, 0x77, - 0xe4, 0x34, 0x50, 0xfb, 0x47, 0x90, 0xed, 0x26, 0xa0, 0x6d, 0x45, 0xdb, 0xed, 0x7d, 0x2f, 0xdf, - 0xf7, 0xf9, 0xf9, 0xcb, 0x33, 0x44, 0xa7, 0x5c, 0x14, 0x5c, 0xf4, 0x85, 0xe4, 0x33, 0xd6, 0x17, - 0x25, 0x9d, 0x8a, 0x8c, 0x4b, 0xd1, 0xaf, 0x76, 0x1b, 0x10, 0x4f, 0x67, 0x5c, 0x72, 0xfc, 0xc8, - 0x30, 0x63, 0xcd, 0x8c, 0x1b, 0x66, 0x5c, 0xed, 0x3e, 0xde, 0x1e, 0xf1, 0x11, 0xd7, 0xac, 0xbe, - 0xaa, 0x8c, 0x20, 0xfc, 0x81, 0xa0, 0x7b, 0xb4, 0xa2, 0xe1, 0x87, 0xd0, 0xc9, 0x58, 0x3e, 0xca, - 0xa4, 0x87, 0x02, 0x14, 0xd9, 0x64, 0x85, 0x54, 0xff, 0x2b, 0x9f, 0x15, 0x54, 0x7a, 0x1b, 0x01, - 0x8a, 0xee, 0x93, 0x15, 0x52, 0xfd, 0xd3, 0xec, 0xac, 0x1c, 0x0b, 0xaf, 0x65, 0xfa, 0x06, 0x61, - 0x0c, 0x76, 0x46, 0x45, 0xe6, 0xd9, 0x01, 0x8a, 0x5c, 0xa2, 0x6b, 0xbc, 0x0f, 0xdd, 0x82, 0x49, - 0x3a, 0xa4, 0x92, 0x7a, 0xed, 0x00, 0x45, 0x4e, 0xf2, 0x34, 0x5e, 0x3b, 0x6c, 0xfc, 0x69, 0x45, - 0x1d, 0xd8, 0xe7, 0x97, 0x3b, 0x16, 0x69, 0xa4, 0xe1, 0x4b, 0xe8, 0xd6, 0xdf, 0xf0, 0x13, 0x70, - 0xf5, 0x81, 0xc7, 0xea, 0x00, 0x26, 0x3c, 0x14, 0xb4, 0x22, 0x97, 0x38, 0xba, 0x97, 0xea, 0x56, - 0xf8, 0x6b, 0x03, 0xdc, 0xfa, 0x7a, 0x07, 0x92, 0x15, 0xf8, 0x3d, 0xb4, 0xf5, 0x71, 0xfa, 0x86, - 0x4e, 0xf2, 0xe2, 0x3f, 0x33, 0xd4, 0xba, 0x23, 0xf5, 0x49, 0x89, 0x53, 0x8b, 0x18, 0x31, 0xfe, - 0x00, 0x76, 0x4e, 0xab, 0x89, 0x8e, 0xc3, 0x49, 0x9e, 0xdf, 0xc2, 0xe4, 0xe0, 0xed, 0xe7, 0x8f, - 0xca, 0x63, 0xd0, 0x5d, 0x5c, 0xee, 0xd8, 0x0a, 0xa5, 0x16, 0xd1, 0x26, 0xf8, 0x10, 0x36, 0xd9, - 0x37, 0xc9, 0x4a, 0x91, 0xf3, 0x52, 0x07, 0xe9, 0x24, 0xaf, 0x6e, 0xe1, 0xb8, 0x5f, 0x6b, 0x54, - 0x1e, 0xa9, 0x45, 0xfe, 0x9a, 0xe0, 0x13, 0xd8, 0x6a, 0xc0, 0xf1, 0x94, 0xce, 0x27, 0x9c, 0x0e, - 0xf5, 0xcf, 0x70, 0x92, 0xbd, 0xbb, 0x38, 0x1f, 0x1a, 0x69, 0x6a, 0x91, 0x1e, 0xbb, 0xd2, 0x1b, - 0x74, 0xc0, 0xce, 0x25, 0x2b, 0xc2, 0x67, 0xb0, 0x75, 0x2d, 0x28, 0xb5, 0x00, 0x25, 0x2d, 0x4c, - 0xc8, 0x9b, 0x44, 0xd7, 0xe1, 0x04, 0x7a, 0x57, 0xc3, 0xc0, 0x3d, 0x68, 0x8d, 0xd9, 0x5c, 0xd3, - 0x5c, 0xa2, 0x4a, 0xbc, 0x0d, 0xed, 0x8a, 0x4e, 0xce, 0x98, 0x8e, 0xd6, 0x25, 0x06, 0x60, 0x0f, - 0xee, 0x55, 0x6c, 0xd6, 0x04, 0xd4, 0x22, 0x35, 0xfc, 0x67, 0x65, 0xd5, 0xfd, 0xda, 0xf5, 0xca, - 0x86, 0xef, 0xe0, 0xc1, 0x8d, 0x41, 0xdd, 0x34, 0xda, 0xba, 0xfd, 0x0e, 0x5f, 0x83, 0xb7, 0x2e, - 0x13, 0x35, 0x52, 0x9d, 0xac, 0x19, 0xbf, 0x86, 0x83, 0x37, 0xe7, 0x0b, 0x1f, 0x5d, 0x2c, 0x7c, - 0xf4, 0x7b, 0xe1, 0xa3, 0xef, 0x4b, 0xdf, 0xba, 0x58, 0xfa, 0xd6, 0xcf, 0xa5, 0x6f, 0x7d, 0x09, - 0x4d, 0xf6, 0x62, 0x38, 0x8e, 0x73, 0x7e, 0xed, 0x35, 0xcb, 0xf9, 0x94, 0x89, 0x93, 0x8e, 0x7e, - 0x97, 0x7b, 0x7f, 0x02, 0x00, 0x00, 0xff, 0xff, 0xef, 0xe9, 0x8e, 0x10, 0xf4, 0x03, 0x00, 0x00, + proto.RegisterFile("cosmos/store/snapshots/v2/snapshot.proto", fileDescriptor_6851f1463fcbb80c) +} + +var fileDescriptor_6851f1463fcbb80c = []byte{ + // 535 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94, 0x54, 0xc1, 0x6e, 0xd3, 0x30, + 0x18, 0x8e, 0xd7, 0xb4, 0x74, 0x4e, 0x10, 0x9d, 0x19, 0x28, 0xec, 0x90, 0x85, 0x70, 0x89, 0x04, + 0x4d, 0xa7, 0x0c, 0x71, 0x40, 0xbb, 0x50, 0x31, 0xa9, 0x15, 0x20, 0x4d, 0x9e, 0x84, 0x10, 0x97, + 0xca, 0x5b, 0x4d, 0x53, 0xb5, 0x89, 0xab, 0xda, 0x8b, 0xe8, 0x91, 0x37, 0xe0, 0x45, 0xb8, 0xf1, + 0x10, 0x3b, 0x4e, 0x9c, 0x38, 0x4d, 0xa8, 0x7d, 0x05, 0x1e, 0x00, 0xd9, 0x4e, 0x02, 0xda, 0x52, + 0xb4, 0xdd, 0xfe, 0xef, 0xf7, 0xf7, 0x7d, 0xf6, 0xff, 0xd9, 0x09, 0x0c, 0x4e, 0x19, 0x4f, 0x18, + 0xef, 0x70, 0xc1, 0xe6, 0xb4, 0xc3, 0x53, 0x32, 0xe3, 0x31, 0x13, 0xbc, 0x93, 0x45, 0x25, 0x08, + 0x67, 0x73, 0x26, 0x18, 0x7a, 0xa4, 0x99, 0xa1, 0x62, 0x86, 0x25, 0x33, 0xcc, 0xa2, 0x9d, 0xed, + 0x11, 0x1b, 0x31, 0xc5, 0xea, 0xc8, 0x4a, 0x0b, 0x76, 0x72, 0xc1, 0x40, 0x2f, 0xe4, 0x6a, 0x05, + 0xfc, 0x6f, 0x00, 0x36, 0x8f, 0x73, 0x07, 0xf4, 0x10, 0x36, 0x62, 0x3a, 0x1e, 0xc5, 0xc2, 0x01, + 0x1e, 0x08, 0x4c, 0x9c, 0x23, 0xd9, 0xff, 0xc4, 0xe6, 0x09, 0x11, 0xce, 0x86, 0x07, 0x82, 0xbb, + 0x38, 0x47, 0xb2, 0x7f, 0x1a, 0x9f, 0xa5, 0x13, 0xee, 0xd4, 0x74, 0x5f, 0x23, 0x84, 0xa0, 0x19, + 0x13, 0x1e, 0x3b, 0xa6, 0x07, 0x02, 0x1b, 0xab, 0x1a, 0x1d, 0xc2, 0x66, 0x42, 0x05, 0x19, 0x12, + 0x41, 0x9c, 0xba, 0x07, 0x02, 0x2b, 0x7a, 0x12, 0xae, 0x9d, 0x23, 0x7c, 0x97, 0x53, 0xbb, 0xe6, + 0xf9, 0xe5, 0xae, 0x81, 0x4b, 0xa9, 0xdf, 0x86, 0xcd, 0x62, 0x0d, 0x3d, 0x86, 0xb6, 0xda, 0x70, + 0x20, 0x37, 0xa0, 0xdc, 0x01, 0x5e, 0x2d, 0xb0, 0xb1, 0xa5, 0x7a, 0x3d, 0xd5, 0xf2, 0x7f, 0x6f, + 0x40, 0xbb, 0x18, 0xaf, 0x2f, 0x68, 0x82, 0x5e, 0xc3, 0xba, 0xda, 0x4e, 0x4d, 0x68, 0x45, 0xcf, + 0xfe, 0x73, 0x86, 0x42, 0x77, 0x2c, 0x97, 0xa4, 0xb8, 0x67, 0x60, 0x2d, 0x46, 0x6f, 0xa0, 0x39, + 0x26, 0xd9, 0x54, 0xc5, 0x61, 0x45, 0x4f, 0x6f, 0x60, 0xd2, 0x7f, 0xf5, 0xfe, 0xad, 0xf4, 0xe8, + 0x36, 0x97, 0x97, 0xbb, 0xa6, 0x44, 0x3d, 0x03, 0x2b, 0x13, 0x74, 0x04, 0x37, 0xe9, 0x67, 0x41, + 0x53, 0x3e, 0x66, 0xa9, 0x0a, 0xd2, 0x8a, 0xf6, 0x6e, 0xe0, 0x78, 0x58, 0x68, 0x64, 0x1e, 0x3d, + 0x03, 0xff, 0x35, 0x41, 0x27, 0x70, 0xab, 0x04, 0x83, 0x19, 0x59, 0x4c, 0x19, 0x19, 0xaa, 0xcb, + 0xb0, 0xa2, 0xfd, 0xdb, 0x38, 0x1f, 0x69, 0x69, 0xcf, 0xc0, 0x2d, 0x7a, 0xa5, 0xf7, 0xf2, 0xfe, + 0x8f, 0xef, 0xed, 0x7b, 0xda, 0xab, 0xcd, 0x87, 0x13, 0x6f, 0x2f, 0x7c, 0xfe, 0xa2, 0xdb, 0x80, + 0xe6, 0x58, 0xd0, 0xc4, 0x3f, 0x80, 0x5b, 0xd7, 0xd2, 0x93, 0xaf, 0x22, 0x25, 0x89, 0x4e, 0x7e, + 0x13, 0xab, 0xba, 0xd2, 0xc5, 0xff, 0x02, 0x60, 0xeb, 0x6a, 0x6e, 0xa8, 0x05, 0x6b, 0x13, 0xba, + 0x50, 0x62, 0x1b, 0xcb, 0x12, 0x6d, 0xc3, 0x7a, 0x46, 0xa6, 0x67, 0x54, 0xdd, 0x82, 0x8d, 0x35, + 0x40, 0x0e, 0xbc, 0x93, 0xd1, 0x79, 0x99, 0x65, 0x0d, 0x17, 0xf0, 0x9f, 0xd7, 0x2d, 0xa3, 0xa8, + 0x17, 0xaf, 0xbb, 0xfa, 0x0c, 0x1f, 0xe0, 0x83, 0xca, 0xa0, 0xab, 0xa6, 0x58, 0xf7, 0x7d, 0x54, + 0x3b, 0xf7, 0xa1, 0xb3, 0x2e, 0x68, 0x79, 0xf8, 0xe2, 0xba, 0xf4, 0xa0, 0x05, 0xac, 0x8e, 0xfb, + 0xe0, 0x7c, 0xe9, 0x82, 0x8b, 0xa5, 0x0b, 0x7e, 0x2d, 0x5d, 0xf0, 0x75, 0xe5, 0x1a, 0x17, 0x2b, + 0xd7, 0xf8, 0xb9, 0x72, 0x8d, 0x8f, 0xbe, 0xa6, 0xf2, 0xe1, 0x24, 0x1c, 0xb3, 0x6b, 0xbf, 0x14, + 0xb1, 0x98, 0x51, 0x7e, 0xd2, 0x50, 0x7f, 0x80, 0xfd, 0x3f, 0x01, 0x00, 0x00, 0xff, 0xff, 0xa0, + 0xee, 0x29, 0xf5, 0x79, 0x04, 0x00, 0x00, } func (m *Snapshot) Marshal() (dAtA []byte, err error) { diff --git a/store/v2/store.go b/store/v2/store.go index f6af274220d1..71a3cc48bcad 100644 --- a/store/v2/store.go +++ b/store/v2/store.go @@ -67,6 +67,8 @@ type RootStore interface { // SetMetrics sets the telemetry handler on the RootStore. SetMetrics(m metrics.Metrics) + Prune(version uint64) error + io.Closer } diff --git a/tests/e2e/baseapp/block_gas_test.go b/tests/e2e/baseapp/block_gas_test.go index df5423fb86ce..c8f9148b5bc7 100644 --- a/tests/e2e/baseapp/block_gas_test.go +++ b/tests/e2e/baseapp/block_gas_test.go @@ -174,7 +174,7 @@ func TestBaseApp_BlockGas(t *testing.T) { require.Equal(t, []byte("ok"), okValue) } // check block gas is always consumed - baseGas := uint64(38012) // baseGas is the gas consumed before tx msg + baseGas := uint64(38142) // baseGas is the gas consumed before tx msg expGasConsumed := addUint64Saturating(tc.gasToConsume, baseGas) if expGasConsumed > uint64(simtestutil.DefaultConsensusParams.Block.MaxGas) { // capped by gasLimit diff --git a/tests/go.mod b/tests/go.mod index da3bc3b45cb2..1dd30f25688f 100644 --- a/tests/go.mod +++ b/tests/go.mod @@ -6,7 +6,7 @@ require ( cosmossdk.io/api v0.7.5 cosmossdk.io/collections v0.4.0 cosmossdk.io/core v0.12.1-0.20231114100755-569e3ff6a0d7 - cosmossdk.io/depinject v1.0.0-alpha.4 + cosmossdk.io/depinject v1.0.0 cosmossdk.io/errors v1.0.1 // indirect cosmossdk.io/log v1.3.1 cosmossdk.io/math v1.3.0 @@ -22,7 +22,7 @@ require ( github.com/cosmos/cosmos-db v1.0.2 github.com/cosmos/cosmos-proto v1.0.0-beta.5 // this version is not used as it is always replaced by the latest Cosmos SDK version - github.com/cosmos/cosmos-sdk v0.51.0 + github.com/cosmos/cosmos-sdk v0.53.0 github.com/cosmos/gogoproto v1.5.0 github.com/golang/mock v1.6.0 github.com/spf13/cobra v1.8.1 @@ -94,7 +94,7 @@ require ( github.com/cosmos/crypto v0.1.2 // indirect github.com/cosmos/go-bip39 v1.0.0 // indirect github.com/cosmos/gogogateway v1.2.0 // indirect - github.com/cosmos/iavl v1.2.0 // indirect + github.com/cosmos/iavl v1.2.1-0.20240725141113-7adc688cf179 // indirect github.com/cosmos/ics23/go v0.10.0 // indirect github.com/cosmos/ledger-cosmos-go v0.13.3 // indirect github.com/danieljoos/wincred v1.2.1 // indirect @@ -241,8 +241,6 @@ replace ( cosmossdk.io/collections => ../collections cosmossdk.io/core => ../core cosmossdk.io/core/testing => ../core/testing - cosmossdk.io/depinject => ../depinject - cosmossdk.io/log => ../log cosmossdk.io/store => ../store cosmossdk.io/x/accounts => ../x/accounts cosmossdk.io/x/accounts/defaults/lockup => ../x/accounts/defaults/lockup diff --git a/tests/go.sum b/tests/go.sum index 934a3017d47a..581fde544509 100644 --- a/tests/go.sum +++ b/tests/go.sum @@ -192,8 +192,12 @@ cloud.google.com/go/webrisk v1.4.0/go.mod h1:Hn8X6Zr+ziE2aNd8SliSDWpEnSS1u4R9+xX cloud.google.com/go/webrisk v1.5.0/go.mod h1:iPG6fr52Tv7sGk0H6qUFzmL3HHZev1htXuWDEEsqMTg= cloud.google.com/go/workflows v1.6.0/go.mod h1:6t9F5h/unJz41YqfBmqSASJSXccBLtD1Vwf+KmJENM0= cloud.google.com/go/workflows v1.7.0/go.mod h1:JhSrZuVZWuiDfKEFxU0/F1PQjmpnpcoISEXH2bcHC3M= +cosmossdk.io/depinject v1.0.0 h1:dQaTu6+O6askNXO06+jyeUAnF2/ssKwrrszP9t5q050= +cosmossdk.io/depinject v1.0.0/go.mod h1:zxK/h3HgHoA/eJVtiSsoaRaRA2D5U4cJ5thIG4ssbB8= cosmossdk.io/errors v1.0.1 h1:bzu+Kcr0kS/1DuPBtUFdWjzLqyUuCiyHjyJB6srBV/0= cosmossdk.io/errors v1.0.1/go.mod h1:MeelVSZThMi4bEakzhhhE/CKqVv3nOJDA25bIqRDu/U= +cosmossdk.io/log v1.3.1 h1:UZx8nWIkfbbNEWusZqzAx3ZGvu54TZacWib3EzUYmGI= +cosmossdk.io/log v1.3.1/go.mod h1:2/dIomt8mKdk6vl3OWJcPk2be3pGOS8OQaLUM/3/tCM= cosmossdk.io/math v1.3.0 h1:RC+jryuKeytIiictDslBP9i1fhkVm6ZDmZEoNP316zE= cosmossdk.io/math v1.3.0/go.mod h1:vnRTxewy+M7BtXBNFybkuhSH4WfedVAAnERHgVFhp3k= cosmossdk.io/schema v0.1.1 h1:I0M6pgI7R10nq+/HCQfbO6BsGBZA8sQy+duR1Y3aKcA= @@ -315,8 +319,8 @@ github.com/cosmos/gogogateway v1.2.0/go.mod h1:iQpLkGWxYcnCdz5iAdLcRBSw3h7NXeOkZ github.com/cosmos/gogoproto v1.4.2/go.mod h1:cLxOsn1ljAHSV527CHOtaIP91kK6cCrZETRBrkzItWU= github.com/cosmos/gogoproto v1.5.0 h1:SDVwzEqZDDBoslaeZg+dGE55hdzHfgUA40pEanMh52o= github.com/cosmos/gogoproto v1.5.0/go.mod h1:iUM31aofn3ymidYG6bUR5ZFrk+Om8p5s754eMUcyp8I= -github.com/cosmos/iavl v1.2.0 h1:kVxTmjTh4k0Dh1VNL046v6BXqKziqMDzxo93oh3kOfM= -github.com/cosmos/iavl v1.2.0/go.mod h1:HidWWLVAtODJqFD6Hbne2Y0q3SdxByJepHUOeoH4LiI= +github.com/cosmos/iavl v1.2.1-0.20240725141113-7adc688cf179 h1:wmwDn7V3RodN9auB3FooSQxs46nHVE3u0mb87TJkZFE= +github.com/cosmos/iavl v1.2.1-0.20240725141113-7adc688cf179/go.mod h1:GiM43q0pB+uG53mLxLDzimxM9l/5N9UuSY3/D0huuVw= github.com/cosmos/ics23/go v0.10.0 h1:iXqLLgp2Lp+EdpIuwXTYIQU+AiHj9mOC2X9ab++bZDM= github.com/cosmos/ics23/go v0.10.0/go.mod h1:ZfJSmng/TBNTBkFemHHHj5YY7VAU/MBU980F4VU1NG0= github.com/cosmos/keyring v1.2.0 h1:8C1lBP9xhImmIabyXW4c3vFjjLiBdGCmfLUfeZlV1Yo= diff --git a/tests/integration/distribution/keeper/msg_server_test.go b/tests/integration/distribution/keeper/msg_server_test.go index f8dc17862403..9a85cac995e0 100644 --- a/tests/integration/distribution/keeper/msg_server_test.go +++ b/tests/integration/distribution/keeper/msg_server_test.go @@ -86,11 +86,12 @@ func initFixture(t *testing.T) *fixture { authority := authtypes.NewModuleAddress("gov") maccPerms := map[string][]string{ - pooltypes.ModuleName: {}, - pooltypes.StreamAccount: {}, - distrtypes.ModuleName: {authtypes.Minter}, - stakingtypes.BondedPoolName: {authtypes.Burner, authtypes.Staking}, - stakingtypes.NotBondedPoolName: {authtypes.Burner, authtypes.Staking}, + pooltypes.ModuleName: {}, + pooltypes.StreamAccount: {}, + pooltypes.ProtocolPoolDistrAccount: {}, + distrtypes.ModuleName: {authtypes.Minter}, + stakingtypes.BondedPoolName: {authtypes.Burner, authtypes.Staking}, + stakingtypes.NotBondedPoolName: {authtypes.Burner, authtypes.Staking}, } // gomock initializations @@ -137,13 +138,13 @@ func initFixture(t *testing.T) *fixture { poolKeeper := poolkeeper.NewKeeper(cdc, runtime.NewEnvironment(runtime.NewKVStoreService(keys[pooltypes.StoreKey]), log.NewNopLogger()), accountKeeper, bankKeeper, stakingKeeper, authority.String()) distrKeeper := distrkeeper.NewKeeper( - cdc, runtime.NewEnvironment(runtime.NewKVStoreService(keys[distrtypes.StoreKey]), logger), accountKeeper, bankKeeper, stakingKeeper, poolKeeper, cometService, distrtypes.ModuleName, authority.String(), + cdc, runtime.NewEnvironment(runtime.NewKVStoreService(keys[distrtypes.StoreKey]), logger), accountKeeper, bankKeeper, stakingKeeper, cometService, distrtypes.ModuleName, authority.String(), ) authModule := auth.NewAppModule(cdc, accountKeeper, acctsModKeeper, authsims.RandomGenesisAccounts) bankModule := bank.NewAppModule(cdc, bankKeeper, accountKeeper) stakingModule := staking.NewAppModule(cdc, stakingKeeper, accountKeeper, bankKeeper) - distrModule := distribution.NewAppModule(cdc, distrKeeper, accountKeeper, bankKeeper, stakingKeeper, poolKeeper) + distrModule := distribution.NewAppModule(cdc, distrKeeper, accountKeeper, bankKeeper, stakingKeeper) poolModule := protocolpool.NewAppModule(cdc, poolKeeper, accountKeeper, bankKeeper) addr := sdk.AccAddress(PKS[0].Address()) diff --git a/tests/integration/example/example_test.go b/tests/integration/example/example_test.go index 92fdbbeebb07..b8bac7848849 100644 --- a/tests/integration/example/example_test.go +++ b/tests/integration/example/example_test.go @@ -2,6 +2,7 @@ package integration_test import ( "context" + "errors" "fmt" "io" "testing" @@ -112,7 +113,7 @@ func Example() { // in this example the result is an empty response, a nil check is enough // in other cases, it is recommended to check the result value. if result == nil { - panic(fmt.Errorf("unexpected nil result")) + panic(errors.New("unexpected nil result")) } // we now check the result @@ -137,7 +138,7 @@ func Example() { // Output: 10000 } -// ExampleOneModule shows how to use the integration test framework to test the integration of a single module. +// Example_oneModule shows how to use the integration test framework to test the integration of a single module. // That module has no dependency on other modules. func Example_oneModule() { // in this example we are testing the integration of the auth module: @@ -220,7 +221,7 @@ func Example_oneModule() { // in this example the result is an empty response, a nil check is enough // in other cases, it is recommended to check the result value. if result == nil { - panic(fmt.Errorf("unexpected nil result")) + panic(errors.New("unexpected nil result")) } // we now check the result diff --git a/tests/integration/gov/keeper/keeper_test.go b/tests/integration/gov/keeper/keeper_test.go index d98e86c06dd0..bb2f58979edf 100644 --- a/tests/integration/gov/keeper/keeper_test.go +++ b/tests/integration/gov/keeper/keeper_test.go @@ -67,12 +67,13 @@ func initFixture(tb testing.TB) *fixture { authority := authtypes.NewModuleAddress(types.ModuleName) maccPerms := map[string][]string{ - pooltypes.ModuleName: {}, - pooltypes.StreamAccount: {}, - minttypes.ModuleName: {authtypes.Minter}, - stakingtypes.BondedPoolName: {authtypes.Burner, authtypes.Staking}, - stakingtypes.NotBondedPoolName: {authtypes.Burner, authtypes.Staking}, - types.ModuleName: {authtypes.Burner}, + pooltypes.ModuleName: {}, + pooltypes.StreamAccount: {}, + pooltypes.ProtocolPoolDistrAccount: {}, + minttypes.ModuleName: {authtypes.Minter}, + stakingtypes.BondedPoolName: {authtypes.Burner, authtypes.Staking}, + stakingtypes.NotBondedPoolName: {authtypes.Burner, authtypes.Staking}, + types.ModuleName: {authtypes.Burner}, } // gomock initializations diff --git a/tests/integration/protocolpool/module_test.go b/tests/integration/protocolpool/module_test.go index 2c527dd0d52d..b8148be37106 100644 --- a/tests/integration/protocolpool/module_test.go +++ b/tests/integration/protocolpool/module_test.go @@ -87,7 +87,6 @@ func TestWithdrawAnytime(t *testing.T) { // TestExpireInTheMiddle tests if a continuous fund that expires without anyone // calling the withdraw function, the funds are still distributed correctly. func TestExpireInTheMiddle(t *testing.T) { - t.Skip("This is a bug @facu found, will fix in another PR") var accountKeeper authkeeper.AccountKeeper var protocolpoolKeeper protocolpoolkeeper.Keeper var bankKeeper bankkeeper.Keeper @@ -131,8 +130,8 @@ func TestExpireInTheMiddle(t *testing.T) { _, err = msgServer.WithdrawContinuousFund(ctx, &protocolpooltypes.MsgWithdrawContinuousFund{ RecipientAddress: testAddr0Str, }) - require.Error(t, err) + require.NoError(t, err) endBalance := bankKeeper.GetBalance(ctx, testAddrs[0], sdk.DefaultBondDenom) - require.Equal(t, "158441stake", endBalance.String()) + require.Equal(t, "237661stake", endBalance.String()) } diff --git a/tests/integration/server/grpc/out_of_gas_test.go b/tests/integration/server/grpc/out_of_gas_test.go index f662d2a25ff8..4a91d3e05201 100644 --- a/tests/integration/server/grpc/out_of_gas_test.go +++ b/tests/integration/server/grpc/out_of_gas_test.go @@ -17,6 +17,7 @@ import ( _ "cosmossdk.io/x/consensus" _ "cosmossdk.io/x/staking" + "github.com/cosmos/cosmos-sdk/baseapp" "github.com/cosmos/cosmos-sdk/codec" "github.com/cosmos/cosmos-sdk/testutil/configurator" "github.com/cosmos/cosmos-sdk/testutil/network" @@ -36,7 +37,7 @@ func (s *IntegrationTestOutOfGasSuite) SetupSuite() { var err error s.T().Log("setting up integration test suite") - s.cfg, err = network.DefaultConfigWithAppConfigWithQueryGasLimit(configurator.NewAppConfig( + s.cfg, err = network.DefaultConfigWithAppConfig(configurator.NewAppConfig( configurator.AccountsModule(), configurator.AuthModule(), configurator.BankModule(), @@ -44,7 +45,7 @@ func (s *IntegrationTestOutOfGasSuite) SetupSuite() { configurator.StakingModule(), configurator.ConsensusModule(), configurator.TxModule(), - ), 10) + ), baseapp.SetQueryGasLimit(10)) s.NoError(err) s.cfg.NumValidators = 1 diff --git a/tests/integration/slashing/keeper/slash_redelegation_test.go b/tests/integration/slashing/keeper/slash_redelegation_test.go index ad6dd9abd57a..96f6a50db081 100644 --- a/tests/integration/slashing/keeper/slash_redelegation_test.go +++ b/tests/integration/slashing/keeper/slash_redelegation_test.go @@ -365,3 +365,138 @@ func TestOverSlashing(t *testing.T) { require.Equal(t, "550000stake", balance2AfterSlashing.String()) require.Equal(t, "550000stake", balance3AfterSlashing.String()) } + +func TestSlashRedelegation_ValidatorLeftWithNoTokens(t *testing.T) { + // setting up + var ( + authKeeper authkeeper.AccountKeeper + stakingKeeper *stakingkeeper.Keeper + bankKeeper bankkeeper.Keeper + slashKeeper slashingkeeper.Keeper + distrKeeper distributionkeeper.Keeper + ) + + app, err := simtestutil.Setup( + depinject.Configs( + depinject.Supply(log.NewNopLogger()), + slashing.AppConfig, + ), + &stakingKeeper, + &bankKeeper, + &slashKeeper, + &distrKeeper, + &authKeeper, + ) + require.NoError(t, err) + + // get sdk context, staking msg server and bond denom + ctx := app.BaseApp.NewContext(false).WithBlockHeight(1).WithHeaderInfo(header.Info{Height: 1}) + stakingMsgServer := stakingkeeper.NewMsgServerImpl(stakingKeeper) + bondDenom, err := stakingKeeper.BondDenom(ctx) + require.NoError(t, err) + + // create validators DST and SRC + dstPubKey := secp256k1.GenPrivKey().PubKey() + srcPubKey := secp256k1.GenPrivKey().PubKey() + + dstAddr := sdk.ValAddress(dstPubKey.Address()) + srcAddr := sdk.ValAddress(srcPubKey.Address()) + + testCoin := sdk.NewCoin(bondDenom, stakingKeeper.TokensFromConsensusPower(ctx, 1000)) + fundAccount(t, ctx, bankKeeper, authKeeper, sdk.AccAddress(dstAddr), testCoin) + fundAccount(t, ctx, bankKeeper, authKeeper, sdk.AccAddress(srcAddr), testCoin) + + createValMsgDST, _ := stakingtypes.NewMsgCreateValidator( + dstAddr.String(), dstPubKey, testCoin, stakingtypes.Description{Details: "Validator DST"}, stakingtypes.NewCommissionRates(math.LegacyNewDecWithPrec(5, 1), math.LegacyNewDecWithPrec(5, 1), math.LegacyNewDec(0)), math.OneInt()) + _, err = stakingMsgServer.CreateValidator(ctx, createValMsgDST) + require.NoError(t, err) + + createValMsgSRC, _ := stakingtypes.NewMsgCreateValidator( + srcAddr.String(), srcPubKey, testCoin, stakingtypes.Description{Details: "Validator SRC"}, stakingtypes.NewCommissionRates(math.LegacyNewDecWithPrec(5, 1), math.LegacyNewDecWithPrec(5, 1), math.LegacyNewDec(0)), math.OneInt()) + _, err = stakingMsgServer.CreateValidator(ctx, createValMsgSRC) + require.NoError(t, err) + + // create a user accounts and delegate to SRC and DST + userAcc := sdk.AccAddress([]byte("user1_______________")) + fundAccount(t, ctx, bankKeeper, authKeeper, userAcc, testCoin) + + userAcc2 := sdk.AccAddress([]byte("user2_______________")) + fundAccount(t, ctx, bankKeeper, authKeeper, userAcc2, testCoin) + + delMsg := stakingtypes.NewMsgDelegate(userAcc.String(), srcAddr.String(), testCoin) + _, err = stakingMsgServer.Delegate(ctx, delMsg) + require.NoError(t, err) + + delMsg = stakingtypes.NewMsgDelegate(userAcc2.String(), dstAddr.String(), testCoin) + _, err = stakingMsgServer.Delegate(ctx, delMsg) + require.NoError(t, err) + + ctx, err = simtestutil.NextBlock(app, ctx, time.Duration(1)) + require.NoError(t, err) + + // commit an infraction with DST and store the power at this height + dstVal, err := stakingKeeper.GetValidator(ctx, dstAddr) + require.NoError(t, err) + dstPower := stakingKeeper.TokensToConsensusPower(ctx, dstVal.Tokens) + dstConsAddr, err := dstVal.GetConsAddr() + require.NoError(t, err) + dstInfractionHeight := ctx.BlockHeight() + + ctx, err = simtestutil.NextBlock(app, ctx, time.Duration(1)) + require.NoError(t, err) + + // undelegate all the user tokens from DST + undelMsg := stakingtypes.NewMsgUndelegate(userAcc2.String(), dstAddr.String(), testCoin) + _, err = stakingMsgServer.Undelegate(ctx, undelMsg) + require.NoError(t, err) + + // commit an infraction with SRC and store the power at this height + srcVal, err := stakingKeeper.GetValidator(ctx, srcAddr) + require.NoError(t, err) + srcPower := stakingKeeper.TokensToConsensusPower(ctx, srcVal.Tokens) + srcConsAddr, err := srcVal.GetConsAddr() + require.NoError(t, err) + srcInfractionHeight := ctx.BlockHeight() + + ctx, err = simtestutil.NextBlock(app, ctx, time.Duration(1)) + require.NoError(t, err) + + // redelegate all the user tokens from SRC to DST + redelMsg := stakingtypes.NewMsgBeginRedelegate(userAcc.String(), srcAddr.String(), dstAddr.String(), testCoin) + _, err = stakingMsgServer.BeginRedelegate(ctx, redelMsg) + require.NoError(t, err) + + // undelegate the self delegation from DST + undelMsg = stakingtypes.NewMsgUndelegate(sdk.AccAddress(dstAddr).String(), dstAddr.String(), testCoin) + _, err = stakingMsgServer.Undelegate(ctx, undelMsg) + require.NoError(t, err) + + ctx, err = simtestutil.NextBlock(app, ctx, time.Duration(1)) + require.NoError(t, err) + + undelMsg = stakingtypes.NewMsgUndelegate(userAcc.String(), dstAddr.String(), testCoin) + _, err = stakingMsgServer.Undelegate(ctx, undelMsg) + require.NoError(t, err) + + // check that dst now has zero tokens + valDst, err := stakingKeeper.GetValidator(ctx, dstAddr) + require.NoError(t, err) + require.Equal(t, math.ZeroInt().String(), valDst.Tokens.String()) + + // slash the infractions + err = slashKeeper.Slash(ctx, dstConsAddr, math.LegacyMustNewDecFromStr("0.8"), dstPower, dstInfractionHeight) + require.NoError(t, err) + + err = slashKeeper.Slash(ctx, srcConsAddr, math.LegacyMustNewDecFromStr("0.5"), srcPower, srcInfractionHeight) + require.NoError(t, err) + + // assert invariants to ensure correctness + _, stop := stakingkeeper.AllInvariants(stakingKeeper)(ctx) + require.False(t, stop) + + _, stop = bankkeeper.AllInvariants(bankKeeper)(ctx) + require.False(t, stop) + + _, stop = distributionkeeper.AllInvariants(distrKeeper)(ctx) + require.False(t, stop) +} diff --git a/tests/integration/store/rootmulti/rollback_test.go b/tests/integration/store/rootmulti/rollback_test.go index c06dadcf82f7..22a6dce56847 100644 --- a/tests/integration/store/rootmulti/rollback_test.go +++ b/tests/integration/store/rootmulti/rollback_test.go @@ -9,7 +9,7 @@ import ( dbm "github.com/cosmos/cosmos-db" "gotest.tools/v3/assert" - coretesting "cosmossdk.io/core/testing" + "cosmossdk.io/log" "cosmossdk.io/simapp" simtestutil "github.com/cosmos/cosmos-sdk/testutil/sims" @@ -18,7 +18,7 @@ import ( func TestRollback(t *testing.T) { db := dbm.NewMemDB() options := simapp.SetupOptions{ - Logger: coretesting.NewNopLogger(), + Logger: log.NewNopLogger(), DB: db, AppOpts: simtestutil.NewAppOptionsWithFlagHome(t.TempDir()), } diff --git a/tests/sims/gov/operations_test.go b/tests/sims/gov/operations_test.go index 7e4b6a27ea69..93159e6f5206 100644 --- a/tests/sims/gov/operations_test.go +++ b/tests/sims/gov/operations_test.go @@ -1,6 +1,7 @@ package simulation_test import ( + "context" "fmt" "math/rand" "testing" @@ -56,8 +57,8 @@ func (m MockWeightedProposals) DefaultWeight() int { return m.n } -func (m MockWeightedProposals) MsgSimulatorFn() simtypes.MsgSimulatorFn { - return func(r *rand.Rand, _ []simtypes.Account, _ address.Codec) (sdk.Msg, error) { +func (m MockWeightedProposals) MsgSimulatorFn() simtypes.MsgSimulatorFnX { + return func(_ context.Context, r *rand.Rand, _ []simtypes.Account, _ address.Codec) (sdk.Msg, error) { return nil, nil } } diff --git a/tests/systemtests/README.md b/tests/systemtests/README.md index ab20d155f08f..61eaf89d0223 100644 --- a/tests/systemtests/README.md +++ b/tests/systemtests/README.md @@ -3,19 +3,23 @@ Test framework for system tests. Starts and interacts with a (multi node) blockchain in Go. Supports + * CLI * Servers * Events * RPC Uses: + * testify * gjson * sjson Server and client side are executed on the host machine ## Developer + ### Test strategy + System tests cover the full stack via cli and a running (multi node) network. They are more expensive (in terms of time/ cpu) to run compared to unit or integration tests. Therefore, we focus on the **critical path** and do not cover every condition. @@ -33,7 +37,9 @@ Test cli parameters * `-nodes-count` int - number of nodes in the cluster (default 4) # Port ranges + With *n* nodes: + * `26657` - `26657+n` - RPC * `1317` - `1317+n` - API * `9090` - `9090+n` - GRPC @@ -47,4 +53,4 @@ For example Node *3* listens on `26660` for RPC calls ## Disclaimer -This is based on the system test framework in [wasmd](https://github.com/CosmWasm/wasmd) built by Confio. \ No newline at end of file +This is based on the system test framework in [wasmd](https://github.com/CosmWasm/wasmd) built by Confio. diff --git a/tests/systemtests/account_test.go b/tests/systemtests/account_test.go new file mode 100644 index 000000000000..c3940579e2c3 --- /dev/null +++ b/tests/systemtests/account_test.go @@ -0,0 +1,50 @@ +package systemtests + +import ( + "strings" + "testing" + + "github.com/stretchr/testify/assert" + "github.com/tidwall/gjson" +) + +func TestAccountCreation(t *testing.T) { + // scenario: test account creation + // given a running chain + // when accountA is sending funds to accountB, + // AccountB should not be created + // when accountB is sending funds to accountA, + // AccountB should be created + + sut.ResetChain(t) + cli := NewCLIWrapper(t, sut, verbose) + // add genesis account with some tokens + account1Addr := cli.AddKey("account1") + account2Addr := cli.AddKey("account2") + sut.ModifyGenesisCLI(t, + []string{"genesis", "add-genesis-account", account1Addr, "10000000stake"}, + ) + + sut.StartChain(t) + + // query account1 + rsp := cli.CustomQuery("q", "auth", "account", account1Addr) + assert.Equal(t, account1Addr, gjson.Get(rsp, "account.value.address").String(), rsp) + + rsp1 := cli.Run("tx", "bank", "send", account1Addr, account2Addr, "5000stake", "--from="+account1Addr, "--fees=1stake") + RequireTxSuccess(t, rsp1) + + // query account2 + + rsp2 := cli.WithRunErrorsIgnored().CustomQuery("q", "auth", "account", account2Addr) + assert.True(t, strings.Contains(rsp2, "not found: key not found")) + + rsp3 := cli.Run("tx", "bank", "send", account2Addr, account1Addr, "1000stake", "--from="+account1Addr, "--fees=1stake") + RequireTxSuccess(t, rsp3) + + // query account2 to make sure its created + rsp4 := cli.CustomQuery("q", "auth", "account", account2Addr) + assert.Equal(t, "1", gjson.Get(rsp4, "account.value.sequence").String(), rsp4) + rsp5 := cli.CustomQuery("q", "auth", "account", account1Addr) + assert.Equal(t, "1", gjson.Get(rsp5, "account.value.sequence").String(), rsp5) +} diff --git a/tests/systemtests/cli.go b/tests/systemtests/cli.go index 486e1c203a52..ae0ee0e9ac8d 100644 --- a/tests/systemtests/cli.go +++ b/tests/systemtests/cli.go @@ -15,11 +15,6 @@ import ( "github.com/tidwall/gjson" "golang.org/x/exp/slices" - "github.com/cosmos/cosmos-sdk/client/grpc/cmtservice" - "github.com/cosmos/cosmos-sdk/codec" - codectypes "github.com/cosmos/cosmos-sdk/codec/types" - cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types" - "github.com/cosmos/cosmos-sdk/std" sdk "github.com/cosmos/cosmos-sdk/types" ) @@ -287,7 +282,7 @@ func (c CLIWrapper) AddKeyFromSeed(name, mnemoic string) string { return addr } -// GetKeyAddr returns address +// GetKeyAddr returns Acc address func (c CLIWrapper) GetKeyAddr(name string) string { cmd := c.withKeyringFlags("keys", "show", name, "-a") out, _ := c.run(cmd) @@ -296,6 +291,15 @@ func (c CLIWrapper) GetKeyAddr(name string) string { return addr } +// GetKeyAddrPrefix returns key address with Beach32 prefix encoding for a key (acc|val|cons) +func (c CLIWrapper) GetKeyAddrPrefix(name, prefix string) string { + cmd := c.withKeyringFlags("keys", "show", name, "-a", "--bech="+prefix) + out, _ := c.run(cmd) + addr := strings.Trim(out, "\n") + require.NotEmpty(c.t, addr, "got %q", out) + return addr +} + const defaultSrcAddr = "node0" // FundAddress sends the token amount to the destination address @@ -330,33 +334,6 @@ func (c CLIWrapper) QueryTotalSupply(denom string) int64 { return gjson.Get(raw, fmt.Sprintf("supply.#(denom==%q).amount", denom)).Int() } -func (c CLIWrapper) GetCometBFTValidatorSet() cmtservice.GetLatestValidatorSetResponse { - args := []string{"q", "comet-validator-set"} - got := c.CustomQuery(args...) - - // still using amino here as the SDK - amino := codec.NewLegacyAmino() - std.RegisterLegacyAminoCodec(amino) - std.RegisterInterfaces(codectypes.NewInterfaceRegistry()) - - var res cmtservice.GetLatestValidatorSetResponse - require.NoError(c.t, amino.UnmarshalJSON([]byte(got), &res), got) - return res -} - -// IsInCometBftValset returns true when the given pub key is in the current active tendermint validator set -func (c CLIWrapper) IsInCometBftValset(valPubKey cryptotypes.PubKey) (cmtservice.GetLatestValidatorSetResponse, bool) { - valResult := c.GetCometBFTValidatorSet() - var found bool - for _, v := range valResult.Validators { - if v.PubKey.Equal(valPubKey) { - found = true - break - } - } - return valResult, found -} - // SubmitGovProposal submit a gov v1 proposal func (c CLIWrapper) SubmitGovProposal(proposalJson string, args ...string) string { if len(args) == 0 { diff --git a/tests/systemtests/fraud_test.go b/tests/systemtests/fraud_test.go new file mode 100644 index 000000000000..675f3969e40c --- /dev/null +++ b/tests/systemtests/fraud_test.go @@ -0,0 +1,62 @@ +//go:build system_test + +package systemtests + +import ( + "fmt" + "os" + "path/filepath" + "testing" + + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" + "github.com/tidwall/gjson" + + cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types" +) + +func TestValidatorDoubleSign(t *testing.T) { + // Scenario: + // given: a running chain + // when: a second instance with the same val key signs a block + // then: the validator is removed from the active set and jailed forever + sut.ResetChain(t) + cli := NewCLIWrapper(t, sut, verbose) + sut.StartChain(t) + + // Check the validator is in the active set + rsp := cli.CustomQuery("q", "staking", "validators") + t.Log(rsp) + nodePowerBefore := QueryCometValidatorPowerForNode(t, sut, 0) + require.NotEmpty(t, nodePowerBefore) + + var validatorPubKey cryptotypes.PubKey + newNode := sut.AddFullnode(t, "0.001stake", func(nodeNumber int, nodePath string) { + valKeyFile := filepath.Join(WorkDir, nodePath, "config", "priv_validator_key.json") + _ = os.Remove(valKeyFile) + _, err := copyFile(filepath.Join(WorkDir, sut.nodePath(0), "config", "priv_validator_key.json"), valKeyFile) + require.NoError(t, err) + validatorPubKey = LoadValidatorPubKeyForNode(t, sut, nodeNumber) + }) + sut.AwaitNodeUp(t, fmt.Sprintf("http://%s:%d", newNode.IP, newNode.RPCPort)) + + // let's wait some blocks to have evidence and update persisted + rpc := sut.RPCClient(t) + pkBz := validatorPubKey.Bytes() + for i := 0; i < 20; i++ { + sut.AwaitNextBlock(t) + if QueryCometValidatorPower(rpc, pkBz) == 0 { + break + } + } + sut.AwaitNextBlock(t) + + // then comet status updated + nodePowerAfter := QueryCometValidatorPowerForNode(t, sut, 0) + require.Empty(t, nodePowerAfter) + + // and sdk status updated + byzantineOperatorAddr := cli.GetKeyAddrPrefix("node0", "val") + rsp = cli.CustomQuery("q", "staking", "validator", byzantineOperatorAddr) + assert.True(t, gjson.Get(rsp, "validator.jailed").Bool(), rsp) +} diff --git a/tests/systemtests/go.mod b/tests/systemtests/go.mod index 7ff21661a355..e7c9ac0f2c4e 100644 --- a/tests/systemtests/go.mod +++ b/tests/systemtests/go.mod @@ -36,7 +36,7 @@ require ( cosmossdk.io/api v0.7.5 // indirect cosmossdk.io/collections v0.4.0 // indirect cosmossdk.io/core v0.11.0 // indirect - cosmossdk.io/depinject v1.0.0-alpha.4 // indirect + cosmossdk.io/depinject v1.0.0 // indirect cosmossdk.io/errors v1.0.1 // indirect cosmossdk.io/log v1.3.1 // indirect cosmossdk.io/store v1.1.0 // indirect diff --git a/tests/systemtests/go.sum b/tests/systemtests/go.sum index bed8c0c8f9c8..a0aa43940f9e 100644 --- a/tests/systemtests/go.sum +++ b/tests/systemtests/go.sum @@ -6,8 +6,8 @@ cosmossdk.io/collections v0.4.0 h1:PFmwj2W8szgpD5nOd8GWH6AbYNi1f2J6akWXJ7P5t9s= cosmossdk.io/collections v0.4.0/go.mod h1:oa5lUING2dP+gdDquow+QjlF45eL1t4TJDypgGd+tv0= cosmossdk.io/core v0.11.0 h1:vtIafqUi+1ZNAE/oxLOQQ7Oek2n4S48SWLG8h/+wdbo= cosmossdk.io/core v0.11.0/go.mod h1:LaTtayWBSoacF5xNzoF8tmLhehqlA9z1SWiPuNC6X1w= -cosmossdk.io/depinject v1.0.0-alpha.4 h1:PLNp8ZYAMPTUKyG9IK2hsbciDWqna2z1Wsl98okJopc= -cosmossdk.io/depinject v1.0.0-alpha.4/go.mod h1:HeDk7IkR5ckZ3lMGs/o91AVUc7E596vMaOmslGFM3yU= +cosmossdk.io/depinject v1.0.0 h1:dQaTu6+O6askNXO06+jyeUAnF2/ssKwrrszP9t5q050= +cosmossdk.io/depinject v1.0.0/go.mod h1:zxK/h3HgHoA/eJVtiSsoaRaRA2D5U4cJ5thIG4ssbB8= cosmossdk.io/errors v1.0.1 h1:bzu+Kcr0kS/1DuPBtUFdWjzLqyUuCiyHjyJB6srBV/0= cosmossdk.io/errors v1.0.1/go.mod h1:MeelVSZThMi4bEakzhhhE/CKqVv3nOJDA25bIqRDu/U= cosmossdk.io/log v1.3.1 h1:UZx8nWIkfbbNEWusZqzAx3ZGvu54TZacWib3EzUYmGI= diff --git a/tests/systemtests/node_utils.go b/tests/systemtests/node_utils.go new file mode 100644 index 000000000000..f503a0f390ad --- /dev/null +++ b/tests/systemtests/node_utils.go @@ -0,0 +1,46 @@ +package systemtests + +import ( + "bytes" + "path/filepath" + "testing" + + "github.com/cometbft/cometbft/privval" + "github.com/stretchr/testify/require" + + cryptocodec "github.com/cosmos/cosmos-sdk/crypto/codec" + cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types" +) + +// LoadValidatorPubKeyForNode load validator nodes consensus pub key for given node number +func LoadValidatorPubKeyForNode(t *testing.T, sut *SystemUnderTest, nodeNumber int) cryptotypes.PubKey { + t.Helper() + return LoadValidatorPubKey(t, filepath.Join(WorkDir, sut.nodePath(nodeNumber), "config", "priv_validator_key.json")) +} + +// LoadValidatorPubKey load validator nodes consensus pub key from disk +func LoadValidatorPubKey(t *testing.T, keyFile string) cryptotypes.PubKey { + t.Helper() + filePV := privval.LoadFilePVEmptyState(keyFile, "") + pubKey, err := filePV.GetPubKey() + require.NoError(t, err) + valPubKey, err := cryptocodec.FromCmtPubKeyInterface(pubKey) + require.NoError(t, err) + return valPubKey +} + +// QueryCometValidatorPowerForNode returns the validator's power from tendermint RPC endpoint. 0 when not found +func QueryCometValidatorPowerForNode(t *testing.T, sut *SystemUnderTest, nodeNumber int) int64 { + t.Helper() + pubKebBz := LoadValidatorPubKeyForNode(t, sut, nodeNumber).Bytes() + return QueryCometValidatorPower(sut.RPCClient(t), pubKebBz) +} + +func QueryCometValidatorPower(c RPCClient, pubKebBz []byte) int64 { + for _, v := range c.Validators() { + if bytes.Equal(v.PubKey.Bytes(), pubKebBz) { + return v.VotingPower + } + } + return 0 +} diff --git a/tests/systemtests/system.go b/tests/systemtests/system.go index a9aec879a729..355854cfddc1 100644 --- a/tests/systemtests/system.go +++ b/tests/systemtests/system.go @@ -154,7 +154,7 @@ func (s *SystemUnderTest) StartChain(t *testing.T, xargs ...string) { t.Helper() s.Log("Start chain\n") s.ChainStarted = true - s.startNodesAsync(t, append([]string{"start", "--trace", "--log_level=info"}, xargs...)...) + s.startNodesAsync(t, append([]string{"start", "--trace", "--log_level=info", "--log_no_color"}, xargs...)...) s.AwaitNodeUp(t, s.rpcAddr) @@ -635,9 +635,12 @@ func AllNodes(t *testing.T, s *SystemUnderTest) []Node { t.Helper() result := make([]Node, s.nodesCount) outs := s.ForEachNodeExecAndWait(t, []string{"comet", "show-node-id"}) - ip, err := server.ExternalIP() - require.NoError(t, err) - + ip := "127.0.0.1" + if false { // is there still a use case for external ip? + var err error + ip, err = server.ExternalIP() + require.NoError(t, err) + } for i, out := range outs { result[i] = Node{ ID: strings.TrimSpace(out[0]), @@ -655,7 +658,7 @@ func (s *SystemUnderTest) resetBuffers() { } // AddFullnode starts a new fullnode that connects to the existing chain but is not a validator. -func (s *SystemUnderTest) AddFullnode(t *testing.T, beforeStart ...func(nodeNumber int, nodePath string)) Node { +func (s *SystemUnderTest) AddFullnode(t *testing.T, minGasPrices string, beforeStart ...func(nodeNumber int, nodePath string)) Node { t.Helper() s.MarkDirty() s.nodesCount++ @@ -698,9 +701,11 @@ func (s *SystemUnderTest) AddFullnode(t *testing.T, beforeStart ...func(nodeNumb fmt.Sprintf("--p2p.laddr=tcp://localhost:%d", node.P2PPort), fmt.Sprintf("--rpc.laddr=tcp://localhost:%d", node.RPCPort), fmt.Sprintf("--grpc.address=localhost:%d", 9090+nodeNumber), - fmt.Sprintf("--grpc-web.address=localhost:%d", 8090+nodeNumber), + fmt.Sprintf("--minimum-gas-prices=%s", minGasPrices), + "--p2p.pex=false", "--moniker=" + moniker, "--log_level=info", + "--log_no_color", "--home", nodePath, } s.Logf("Execute `%s %s`\n", s.execBinary, strings.Join(args, " ")) diff --git a/tests/systemtests/unordered_tx_test.go b/tests/systemtests/unordered_tx_test.go index 4d74cbec2ece..4b22df92b0a5 100644 --- a/tests/systemtests/unordered_tx_test.go +++ b/tests/systemtests/unordered_tx_test.go @@ -3,8 +3,9 @@ package systemtests import ( - "strconv" + "fmt" "testing" + "time" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" @@ -27,11 +28,9 @@ func TestUnorderedTXDuplicate(t *testing.T) { sut.StartChain(t) - height := sut.CurrentHeight() - timeoutHeight := height + 15 - timeoutHeightStr := strconv.Itoa(int(timeoutHeight)) + timeoutTimestamp := time.Now().Add(time.Minute) // send tokens - rsp1 := cli.Run("tx", "bank", "send", account1Addr, account2Addr, "5000stake", "--from="+account1Addr, "--fees=1stake", "--timeout-height="+timeoutHeightStr, "--unordered", "--sequence=1", "--note=1") + rsp1 := cli.Run("tx", "bank", "send", account1Addr, account2Addr, "5000stake", "--from="+account1Addr, "--fees=1stake", fmt.Sprintf("--timeout-timestamp=%v", timeoutTimestamp.Unix()), "--unordered", "--sequence=1", "--note=1") RequireTxSuccess(t, rsp1) assertDuplicateErr := func(xt assert.TestingT, gotErr error, gotOutputs ...interface{}) bool { @@ -39,14 +38,10 @@ func TestUnorderedTXDuplicate(t *testing.T) { assert.Contains(t, gotOutputs[0], "is duplicated: invalid request") return false // always abort } - rsp2 := cli.WithRunErrorMatcher(assertDuplicateErr).Run("tx", "bank", "send", account1Addr, account2Addr, "5000stake", "--from="+account1Addr, "--fees=1stake", "--timeout-height="+timeoutHeightStr, "--unordered", "--sequence=1") + rsp2 := cli.WithRunErrorMatcher(assertDuplicateErr).Run("tx", "bank", "send", account1Addr, account2Addr, "5000stake", "--from="+account1Addr, "--fees=1stake", fmt.Sprintf("--timeout-timestamp=%v", timeoutTimestamp.Unix()), "--unordered", "--sequence=1") RequireTxFailure(t, rsp2) - // assert TX executed before timeout - for cli.QueryBalance(account2Addr, "stake") != 5000 { - t.Log("query balance") - if current := sut.AwaitNextBlock(t); current > timeoutHeight { - t.Fatal("TX was not executed before timeout") - } - } + require.Eventually(t, func() bool { + return cli.QueryBalance(account2Addr, "stake") == 5000 + }, time.Minute, time.Microsecond*500, "TX was not executed before timeout") } diff --git a/testutil/configurator/configurator.go b/testutil/configurator/configurator.go index 84e1fc986c45..91c93ba2d5b0 100644 --- a/testutil/configurator/configurator.go +++ b/testutil/configurator/configurator.go @@ -50,6 +50,7 @@ func defaultConfig() *Config { BeginBlockersOrder: []string{ testutil.MintModuleName, testutil.DistributionModuleName, + testutil.ProtocolPoolModuleName, testutil.SlashingModuleName, testutil.EvidenceModuleName, testutil.StakingModuleName, @@ -164,6 +165,7 @@ func AuthModule() ModuleOption { {Account: testutil.NFTModuleName}, {Account: testutil.ProtocolPoolModuleName}, {Account: "stream_acc"}, + {Account: "protocolpool_distr"}, }, }), } diff --git a/testutil/context.go b/testutil/context.go index 105638ab191d..12c36f11307c 100644 --- a/testutil/context.go +++ b/testutil/context.go @@ -8,7 +8,7 @@ import ( "github.com/stretchr/testify/assert" "cosmossdk.io/core/header" - coretesting "cosmossdk.io/core/testing" + "cosmossdk.io/log" "cosmossdk.io/store" "cosmossdk.io/store/metrics" storetypes "cosmossdk.io/store/types" @@ -19,14 +19,14 @@ import ( // DefaultContext creates a sdk.Context with a fresh MemDB that can be used in tests. func DefaultContext(key, tkey storetypes.StoreKey) sdk.Context { db := dbm.NewMemDB() - cms := store.NewCommitMultiStore(db, coretesting.NewNopLogger(), metrics.NewNoOpMetrics()) + cms := store.NewCommitMultiStore(db, log.NewNopLogger(), metrics.NewNoOpMetrics()) cms.MountStoreWithDB(key, storetypes.StoreTypeIAVL, db) cms.MountStoreWithDB(tkey, storetypes.StoreTypeTransient, db) err := cms.LoadLatestVersion() if err != nil { panic(err) } - ctx := sdk.NewContext(cms, false, coretesting.NewNopLogger()) + ctx := sdk.NewContext(cms, false, log.NewNopLogger()) return ctx } @@ -39,7 +39,7 @@ func DefaultContextWithKeys( memKeys map[string]*storetypes.MemoryStoreKey, ) sdk.Context { db := dbm.NewMemDB() - cms := store.NewCommitMultiStore(db, coretesting.NewNopLogger(), metrics.NewNoOpMetrics()) + cms := store.NewCommitMultiStore(db, log.NewNopLogger(), metrics.NewNoOpMetrics()) for _, key := range keys { cms.MountStoreWithDB(key, storetypes.StoreTypeIAVL, db) @@ -58,7 +58,7 @@ func DefaultContextWithKeys( panic(err) } - return sdk.NewContext(cms, false, coretesting.NewNopLogger()) + return sdk.NewContext(cms, false, log.NewNopLogger()) } type TestContext struct { @@ -70,13 +70,13 @@ type TestContext struct { func DefaultContextWithDB(tb testing.TB, key, tkey storetypes.StoreKey) TestContext { tb.Helper() db := dbm.NewMemDB() - cms := store.NewCommitMultiStore(db, coretesting.NewNopLogger(), metrics.NewNoOpMetrics()) + cms := store.NewCommitMultiStore(db, log.NewNopLogger(), metrics.NewNoOpMetrics()) cms.MountStoreWithDB(key, storetypes.StoreTypeIAVL, db) cms.MountStoreWithDB(tkey, storetypes.StoreTypeTransient, db) err := cms.LoadLatestVersion() assert.NoError(tb, err) - ctx := sdk.NewContext(cms, false, coretesting.NewNopLogger()).WithHeaderInfo(header.Info{Time: time.Now()}) + ctx := sdk.NewContext(cms, false, log.NewNopLogger()).WithHeaderInfo(header.Info{Time: time.Now()}) return TestContext{ctx, db, cms} } diff --git a/testutil/mock/logger.go b/testutil/mock/logger.go index 1a8080da357b..800210aa241e 100644 --- a/testutil/mock/logger.go +++ b/testutil/mock/logger.go @@ -7,7 +7,7 @@ package mock import ( reflect "reflect" - log "cosmossdk.io/core/log" + log "cosmossdk.io/log" gomock "github.com/golang/mock/gomock" ) diff --git a/testutil/network/network.go b/testutil/network/network.go index fb2bbd54ae69..cd59d0b08502 100644 --- a/testutil/network/network.go +++ b/testutil/network/network.go @@ -163,11 +163,7 @@ func DefaultConfig(factory TestFixtureFactory) Config { } } -func DefaultConfigWithAppConfig(appConfig depinject.Config) (Config, error) { - return DefaultConfigWithAppConfigWithQueryGasLimit(appConfig, 0) -} - -func DefaultConfigWithAppConfigWithQueryGasLimit(appConfig depinject.Config, queryGasLimit uint64) (Config, error) { +func DefaultConfigWithAppConfig(appConfig depinject.Config, baseappOpts ...func(*baseapp.BaseApp)) (Config, error) { var ( appBuilder *runtime.AppBuilder txConfig client.TxConfig @@ -222,10 +218,11 @@ func DefaultConfigWithAppConfigWithQueryGasLimit(appConfig depinject.Config, que app := appBuilder.Build( dbm.NewMemDB(), nil, - baseapp.SetPruning(pruningtypes.NewPruningOptionsFromString(val.GetAppConfig().Pruning)), - baseapp.SetMinGasPrices(val.GetAppConfig().MinGasPrices), - baseapp.SetChainID(cfg.ChainID), - baseapp.SetQueryGasLimit(queryGasLimit), + append(baseappOpts, + baseapp.SetPruning(pruningtypes.NewPruningOptionsFromString(val.GetAppConfig().Pruning)), + baseapp.SetMinGasPrices(val.GetAppConfig().MinGasPrices), + baseapp.SetChainID(cfg.ChainID), + )..., ) testdata.RegisterQueryServer(app.GRPCQueryRouter(), testdata.QueryImpl{}) @@ -350,7 +347,7 @@ func New(l Logger, baseDir string, cfg Config) (NetworkI, error) { apiListenAddr = cfg.APIAddress } else { if len(portPool) == 0 { - return nil, fmt.Errorf("failed to get port for API server") + return nil, errors.New("failed to get port for API server") } port := <-portPool apiListenAddr = fmt.Sprintf("tcp://127.0.0.1:%s", port) @@ -367,7 +364,7 @@ func New(l Logger, baseDir string, cfg Config) (NetworkI, error) { cmtCfg.RPC.ListenAddress = cfg.RPCAddress } else { if len(portPool) == 0 { - return nil, fmt.Errorf("failed to get port for RPC server") + return nil, errors.New("failed to get port for RPC server") } port := <-portPool cmtCfg.RPC.ListenAddress = fmt.Sprintf("tcp://127.0.0.1:%s", port) @@ -377,7 +374,7 @@ func New(l Logger, baseDir string, cfg Config) (NetworkI, error) { appCfg.GRPC.Address = cfg.GRPCAddress } else { if len(portPool) == 0 { - return nil, fmt.Errorf("failed to get port for GRPC server") + return nil, errors.New("failed to get port for GRPC server") } port := <-portPool appCfg.GRPC.Address = fmt.Sprintf("127.0.0.1:%s", port) @@ -410,14 +407,14 @@ func New(l Logger, baseDir string, cfg Config) (NetworkI, error) { monikers[i] = nodeDirName if len(portPool) == 0 { - return nil, fmt.Errorf("failed to get port for Proxy server") + return nil, errors.New("failed to get port for Proxy server") } port := <-portPool proxyAddr := fmt.Sprintf("tcp://127.0.0.1:%s", port) cmtCfg.ProxyApp = proxyAddr if len(portPool) == 0 { - return nil, fmt.Errorf("failed to get port for Proxy server") + return nil, errors.New("failed to get port for Proxy server") } port = <-portPool p2pAddr := fmt.Sprintf("tcp://127.0.0.1:%s", port) diff --git a/testutil/sims/address_helpers.go b/testutil/sims/address_helpers.go index 0f6d85e275cc..d0b8bb8ce7fc 100644 --- a/testutil/sims/address_helpers.go +++ b/testutil/sims/address_helpers.go @@ -3,7 +3,7 @@ package sims import ( "bytes" "encoding/hex" - "fmt" + "errors" "strconv" errorsmod "cosmossdk.io/errors" @@ -108,7 +108,7 @@ func TestAddr(addr, bech string) (sdk.AccAddress, error) { } bechexpected := res.String() if bech != bechexpected { - return nil, fmt.Errorf("bech encoding doesn't match reference") + return nil, errors.New("bech encoding doesn't match reference") } bechres, err := sdk.AccAddressFromBech32(bech) diff --git a/testutil/sims/app_helpers.go b/testutil/sims/app_helpers.go index 720713ca56ac..1a1762d78437 100644 --- a/testutil/sims/app_helpers.go +++ b/testutil/sims/app_helpers.go @@ -2,6 +2,7 @@ package sims import ( "encoding/json" + "errors" "fmt" "time" @@ -164,7 +165,7 @@ func SetupWithConfiguration(appConfig depinject.Config, startupConfig StartupCon // create validator set valSet, err := startupConfig.ValidatorSet() if err != nil { - return nil, fmt.Errorf("failed to create validator set") + return nil, errors.New("failed to create validator set") } var ( diff --git a/testutil/sims/state_helpers.go b/testutil/sims/state_helpers.go index 8a3ce8a488a3..631ec379b81f 100644 --- a/testutil/sims/state_helpers.go +++ b/testutil/sims/state_helpers.go @@ -3,7 +3,7 @@ package sims import ( "bufio" "encoding/json" - "fmt" + "errors" "io" "math/rand" "os" @@ -289,7 +289,7 @@ func AppStateFromGenesisFileFn(r io.Reader, cdc codec.JSONCodec, genesisFile str a, ok := acc.GetCachedValue().(sdk.AccountI) if !ok { - return *genesis, nil, fmt.Errorf("expected account") + return *genesis, nil, errors.New("expected account") } // create simulator accounts diff --git a/testutil/testdata/animal.go b/testutil/testdata/animal.go index 7d5afa615280..327b8851e1ea 100644 --- a/testutil/testdata/animal.go +++ b/testutil/testdata/animal.go @@ -4,8 +4,7 @@ import ( "fmt" "github.com/cosmos/gogoproto/proto" - - "github.com/cosmos/cosmos-sdk/codec/types" + gogoprotoany "github.com/cosmos/gogoproto/types/any" ) type Animal interface { @@ -32,9 +31,9 @@ func (d Dog) Greet() string { return fmt.Sprintf("Roof, my name is %s", d.Name) } -var _ types.UnpackInterfacesMessage = HasAnimal{} +var _ gogoprotoany.UnpackInterfacesMessage = HasAnimal{} -func (m HasAnimal) UnpackInterfaces(unpacker types.AnyUnpacker) error { +func (m HasAnimal) UnpackInterfaces(unpacker gogoprotoany.AnyUnpacker) error { var animal Animal return unpacker.UnpackAny(m.Animal, &animal) } @@ -59,9 +58,9 @@ func (m HasHasAnimal) TheHasAnimal() HasAnimalI { return m.HasAnimal.GetCachedValue().(HasAnimalI) } -var _ types.UnpackInterfacesMessage = HasHasAnimal{} +var _ gogoprotoany.UnpackInterfacesMessage = HasHasAnimal{} -func (m HasHasAnimal) UnpackInterfaces(unpacker types.AnyUnpacker) error { +func (m HasHasAnimal) UnpackInterfaces(unpacker gogoprotoany.AnyUnpacker) error { var animal HasAnimalI return unpacker.UnpackAny(m.HasAnimal, &animal) } @@ -76,9 +75,9 @@ func (m HasHasHasAnimal) TheHasHasAnimal() HasHasAnimalI { return m.HasHasAnimal.GetCachedValue().(HasHasAnimalI) } -var _ types.UnpackInterfacesMessage = HasHasHasAnimal{} +var _ gogoprotoany.UnpackInterfacesMessage = HasHasHasAnimal{} -func (m HasHasHasAnimal) UnpackInterfaces(unpacker types.AnyUnpacker) error { +func (m HasHasHasAnimal) UnpackInterfaces(unpacker gogoprotoany.AnyUnpacker) error { var animal HasHasAnimalI return unpacker.UnpackAny(m.HasHasAnimal, &animal) } diff --git a/testutil/testdata/grpc_query.go b/testutil/testdata/grpc_query.go index 1078f60b8b81..a8b4d75b0621 100644 --- a/testutil/testdata/grpc_query.go +++ b/testutil/testdata/grpc_query.go @@ -2,9 +2,11 @@ package testdata import ( "context" + "errors" "fmt" "testing" + gogoprotoany "github.com/cosmos/gogoproto/types/any" "github.com/cosmos/gogoproto/types/any/test" "github.com/cosmos/gogoproto/proto" @@ -26,7 +28,7 @@ var _ QueryServer = QueryImpl{} func (e QueryImpl) TestAny(_ context.Context, request *TestAnyRequest) (*TestAnyResponse, error) { animal, ok := request.AnyAnimal.GetCachedValue().(test.Animal) if !ok { - return nil, fmt.Errorf("expected Animal") + return nil, errors.New("expected Animal") } any, err := types.NewAnyWithValue(animal.(proto.Message)) @@ -49,16 +51,16 @@ func (e QueryImpl) SayHello(_ context.Context, request *SayHelloRequest) (*SayHe return &SayHelloResponse{Greeting: greeting}, nil } -var _ types.UnpackInterfacesMessage = &TestAnyRequest{} +var _ gogoprotoany.UnpackInterfacesMessage = &TestAnyRequest{} -func (m *TestAnyRequest) UnpackInterfaces(unpacker types.AnyUnpacker) error { +func (m *TestAnyRequest) UnpackInterfaces(unpacker gogoprotoany.AnyUnpacker) error { var animal test.Animal return unpacker.UnpackAny(m.AnyAnimal, &animal) } -var _ types.UnpackInterfacesMessage = &TestAnyResponse{} +var _ gogoprotoany.UnpackInterfacesMessage = &TestAnyResponse{} -func (m *TestAnyResponse) UnpackInterfaces(unpacker types.AnyUnpacker) error { +func (m *TestAnyResponse) UnpackInterfaces(unpacker gogoprotoany.AnyUnpacker) error { return m.HasAnimal.UnpackInterfaces(unpacker) } diff --git a/testutil/testdata/testpb/tx.proto b/testutil/testdata/testpb/tx.proto index d3b97193acf7..f49900205e3a 100644 --- a/testutil/testdata/testpb/tx.proto +++ b/testutil/testdata/testpb/tx.proto @@ -5,6 +5,7 @@ import "amino/amino.proto"; import "gogoproto/gogo.proto"; import "testpb/testdata.proto"; import "cosmos/msg/v1/msg.proto"; +import "cosmos_proto/cosmos.proto"; option go_package = "github.com/cosmos/cosmos-sdk/testutil/testdata"; @@ -35,4 +36,11 @@ message TestMsg { option (amino.name) = "testpb/TestMsg"; repeated string signers = 1; + + string decField = 2 [ + (cosmos_proto.scalar) = "cosmos.Dec", + (gogoproto.customtype) = "cosmossdk.io/math.LegacyDec", + (amino.dont_omitempty) = true, + (gogoproto.nullable) = false + ]; } diff --git a/testutil/testdata/testpb/tx.pulsar.go b/testutil/testdata/testpb/tx.pulsar.go index 5e4213c4802a..14b44049e00d 100644 --- a/testutil/testdata/testpb/tx.pulsar.go +++ b/testutil/testdata/testpb/tx.pulsar.go @@ -5,6 +5,7 @@ import ( _ "cosmossdk.io/api/amino" _ "cosmossdk.io/api/cosmos/msg/v1" fmt "fmt" + _ "github.com/cosmos/cosmos-proto" runtime "github.com/cosmos/cosmos-proto/runtime" _ "github.com/cosmos/gogoproto/gogoproto" protoreflect "google.golang.org/protobuf/reflect/protoreflect" @@ -981,14 +982,16 @@ func (x *_TestMsg_1_list) IsValid() bool { } var ( - md_TestMsg protoreflect.MessageDescriptor - fd_TestMsg_signers protoreflect.FieldDescriptor + md_TestMsg protoreflect.MessageDescriptor + fd_TestMsg_signers protoreflect.FieldDescriptor + fd_TestMsg_decField protoreflect.FieldDescriptor ) func init() { file_testpb_tx_proto_init() md_TestMsg = File_testpb_tx_proto.Messages().ByName("TestMsg") fd_TestMsg_signers = md_TestMsg.Fields().ByName("signers") + fd_TestMsg_decField = md_TestMsg.Fields().ByName("decField") } var _ protoreflect.Message = (*fastReflection_TestMsg)(nil) @@ -1062,6 +1065,12 @@ func (x *fastReflection_TestMsg) Range(f func(protoreflect.FieldDescriptor, prot return } } + if x.DecField != "" { + value := protoreflect.ValueOfString(x.DecField) + if !f(fd_TestMsg_decField, value) { + return + } + } } // Has reports whether a field is populated. @@ -1079,6 +1088,8 @@ func (x *fastReflection_TestMsg) Has(fd protoreflect.FieldDescriptor) bool { switch fd.FullName() { case "testpb.TestMsg.signers": return len(x.Signers) != 0 + case "testpb.TestMsg.decField": + return x.DecField != "" default: if fd.IsExtension() { panic(fmt.Errorf("proto3 declared messages do not support extensions: testpb.TestMsg")) @@ -1097,6 +1108,8 @@ func (x *fastReflection_TestMsg) Clear(fd protoreflect.FieldDescriptor) { switch fd.FullName() { case "testpb.TestMsg.signers": x.Signers = nil + case "testpb.TestMsg.decField": + x.DecField = "" default: if fd.IsExtension() { panic(fmt.Errorf("proto3 declared messages do not support extensions: testpb.TestMsg")) @@ -1119,6 +1132,9 @@ func (x *fastReflection_TestMsg) Get(descriptor protoreflect.FieldDescriptor) pr } listValue := &_TestMsg_1_list{list: &x.Signers} return protoreflect.ValueOfList(listValue) + case "testpb.TestMsg.decField": + value := x.DecField + return protoreflect.ValueOfString(value) default: if descriptor.IsExtension() { panic(fmt.Errorf("proto3 declared messages do not support extensions: testpb.TestMsg")) @@ -1143,6 +1159,8 @@ func (x *fastReflection_TestMsg) Set(fd protoreflect.FieldDescriptor, value prot lv := value.List() clv := lv.(*_TestMsg_1_list) x.Signers = *clv.list + case "testpb.TestMsg.decField": + x.DecField = value.Interface().(string) default: if fd.IsExtension() { panic(fmt.Errorf("proto3 declared messages do not support extensions: testpb.TestMsg")) @@ -1169,6 +1187,8 @@ func (x *fastReflection_TestMsg) Mutable(fd protoreflect.FieldDescriptor) protor } value := &_TestMsg_1_list{list: &x.Signers} return protoreflect.ValueOfList(value) + case "testpb.TestMsg.decField": + panic(fmt.Errorf("field decField of message testpb.TestMsg is not mutable")) default: if fd.IsExtension() { panic(fmt.Errorf("proto3 declared messages do not support extensions: testpb.TestMsg")) @@ -1185,6 +1205,8 @@ func (x *fastReflection_TestMsg) NewField(fd protoreflect.FieldDescriptor) proto case "testpb.TestMsg.signers": list := []string{} return protoreflect.ValueOfList(&_TestMsg_1_list{list: &list}) + case "testpb.TestMsg.decField": + return protoreflect.ValueOfString("") default: if fd.IsExtension() { panic(fmt.Errorf("proto3 declared messages do not support extensions: testpb.TestMsg")) @@ -1260,6 +1282,10 @@ func (x *fastReflection_TestMsg) ProtoMethods() *protoiface.Methods { n += 1 + l + runtime.Sov(uint64(l)) } } + l = len(x.DecField) + if l > 0 { + n += 1 + l + runtime.Sov(uint64(l)) + } if x.unknownFields != nil { n += len(x.unknownFields) } @@ -1289,6 +1315,13 @@ func (x *fastReflection_TestMsg) ProtoMethods() *protoiface.Methods { i -= len(x.unknownFields) copy(dAtA[i:], x.unknownFields) } + if len(x.DecField) > 0 { + i -= len(x.DecField) + copy(dAtA[i:], x.DecField) + i = runtime.EncodeVarint(dAtA, i, uint64(len(x.DecField))) + i-- + dAtA[i] = 0x12 + } if len(x.Signers) > 0 { for iNdEx := len(x.Signers) - 1; iNdEx >= 0; iNdEx-- { i -= len(x.Signers[iNdEx]) @@ -1379,6 +1412,38 @@ func (x *fastReflection_TestMsg) ProtoMethods() *protoiface.Methods { } x.Signers = append(x.Signers, string(dAtA[iNdEx:postIndex])) iNdEx = postIndex + case 2: + if wireType != 2 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: wrong wireType = %d for field DecField", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrIntOverflow + } + if iNdEx >= l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength + } + if postIndex > l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + x.DecField = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex default: iNdEx = preIndex skippy, err := runtime.Skip(dAtA[iNdEx:]) @@ -1512,7 +1577,8 @@ type TestMsg struct { sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - Signers []string `protobuf:"bytes,1,rep,name=signers,proto3" json:"signers,omitempty"` + Signers []string `protobuf:"bytes,1,rep,name=signers,proto3" json:"signers,omitempty"` + DecField string `protobuf:"bytes,2,opt,name=decField,proto3" json:"decField,omitempty"` } func (x *TestMsg) Reset() { @@ -1542,6 +1608,13 @@ func (x *TestMsg) GetSigners() []string { return nil } +func (x *TestMsg) GetDecField() string { + if x != nil { + return x.DecField + } + return "" +} + var File_testpb_tx_proto protoreflect.FileDescriptor var file_testpb_tx_proto_rawDesc = []byte{ @@ -1552,17 +1625,24 @@ var file_testpb_tx_proto_rawDesc = []byte{ 0x74, 0x6f, 0x1a, 0x15, 0x74, 0x65, 0x73, 0x74, 0x70, 0x62, 0x2f, 0x74, 0x65, 0x73, 0x74, 0x64, 0x61, 0x74, 0x61, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x17, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2f, 0x6d, 0x73, 0x67, 0x2f, 0x76, 0x31, 0x2f, 0x6d, 0x73, 0x67, 0x2e, 0x70, 0x72, 0x6f, - 0x74, 0x6f, 0x22, 0x4f, 0x0a, 0x0c, 0x4d, 0x73, 0x67, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x44, - 0x6f, 0x67, 0x12, 0x1d, 0x0a, 0x03, 0x64, 0x6f, 0x67, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, - 0x0b, 0x2e, 0x74, 0x65, 0x73, 0x74, 0x70, 0x62, 0x2e, 0x44, 0x6f, 0x67, 0x52, 0x03, 0x64, 0x6f, - 0x67, 0x12, 0x14, 0x0a, 0x05, 0x6f, 0x77, 0x6e, 0x65, 0x72, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, - 0x52, 0x05, 0x6f, 0x77, 0x6e, 0x65, 0x72, 0x3a, 0x0a, 0x82, 0xe7, 0xb0, 0x2a, 0x05, 0x6f, 0x77, - 0x6e, 0x65, 0x72, 0x22, 0x2a, 0x0a, 0x14, 0x4d, 0x73, 0x67, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, - 0x44, 0x6f, 0x67, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x6e, - 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x22, - 0x48, 0x0a, 0x07, 0x54, 0x65, 0x73, 0x74, 0x4d, 0x73, 0x67, 0x12, 0x18, 0x0a, 0x07, 0x73, 0x69, - 0x67, 0x6e, 0x65, 0x72, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x09, 0x52, 0x07, 0x73, 0x69, 0x67, - 0x6e, 0x65, 0x72, 0x73, 0x3a, 0x23, 0x88, 0xa0, 0x1f, 0x00, 0x82, 0xe7, 0xb0, 0x2a, 0x07, 0x73, + 0x74, 0x6f, 0x1a, 0x19, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x5f, 0x70, 0x72, 0x6f, 0x74, 0x6f, + 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x4f, 0x0a, + 0x0c, 0x4d, 0x73, 0x67, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x44, 0x6f, 0x67, 0x12, 0x1d, 0x0a, + 0x03, 0x64, 0x6f, 0x67, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0b, 0x2e, 0x74, 0x65, 0x73, + 0x74, 0x70, 0x62, 0x2e, 0x44, 0x6f, 0x67, 0x52, 0x03, 0x64, 0x6f, 0x67, 0x12, 0x14, 0x0a, 0x05, + 0x6f, 0x77, 0x6e, 0x65, 0x72, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x6f, 0x77, 0x6e, + 0x65, 0x72, 0x3a, 0x0a, 0x82, 0xe7, 0xb0, 0x2a, 0x05, 0x6f, 0x77, 0x6e, 0x65, 0x72, 0x22, 0x2a, + 0x0a, 0x14, 0x4d, 0x73, 0x67, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x44, 0x6f, 0x67, 0x52, 0x65, + 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, + 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x22, 0x9c, 0x01, 0x0a, 0x07, 0x54, + 0x65, 0x73, 0x74, 0x4d, 0x73, 0x67, 0x12, 0x18, 0x0a, 0x07, 0x73, 0x69, 0x67, 0x6e, 0x65, 0x72, + 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x09, 0x52, 0x07, 0x73, 0x69, 0x67, 0x6e, 0x65, 0x72, 0x73, + 0x12, 0x52, 0x0a, 0x08, 0x64, 0x65, 0x63, 0x46, 0x69, 0x65, 0x6c, 0x64, 0x18, 0x02, 0x20, 0x01, + 0x28, 0x09, 0x42, 0x36, 0xc8, 0xde, 0x1f, 0x00, 0xda, 0xde, 0x1f, 0x1b, 0x63, 0x6f, 0x73, 0x6d, + 0x6f, 0x73, 0x73, 0x64, 0x6b, 0x2e, 0x69, 0x6f, 0x2f, 0x6d, 0x61, 0x74, 0x68, 0x2e, 0x4c, 0x65, + 0x67, 0x61, 0x63, 0x79, 0x44, 0x65, 0x63, 0xd2, 0xb4, 0x2d, 0x0a, 0x63, 0x6f, 0x73, 0x6d, 0x6f, + 0x73, 0x2e, 0x44, 0x65, 0x63, 0xa8, 0xe7, 0xb0, 0x2a, 0x01, 0x52, 0x08, 0x64, 0x65, 0x63, 0x46, + 0x69, 0x65, 0x6c, 0x64, 0x3a, 0x23, 0x88, 0xa0, 0x1f, 0x00, 0x82, 0xe7, 0xb0, 0x2a, 0x07, 0x73, 0x69, 0x67, 0x6e, 0x65, 0x72, 0x73, 0x8a, 0xe7, 0xb0, 0x2a, 0x0e, 0x74, 0x65, 0x73, 0x74, 0x70, 0x62, 0x2f, 0x54, 0x65, 0x73, 0x74, 0x4d, 0x73, 0x67, 0x32, 0x4d, 0x0a, 0x03, 0x4d, 0x73, 0x67, 0x12, 0x3f, 0x0a, 0x09, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x44, 0x6f, 0x67, 0x12, 0x14, 0x2e, diff --git a/testutil/testdata/tx.go b/testutil/testdata/tx.go index 3abc02d61c6a..6de23c818b42 100644 --- a/testutil/testdata/tx.go +++ b/testutil/testdata/tx.go @@ -1,6 +1,7 @@ package testdata import ( + "cosmossdk.io/math" "testing" "gotest.tools/v3/assert" @@ -81,7 +82,8 @@ func NewTestMsg(addrs ...sdk.AccAddress) *TestMsg { } return &TestMsg{ - Signers: accAddresses, + Signers: accAddresses, + DecField: math.LegacyZeroDec(), } } diff --git a/testutil/testdata/tx.pb.go b/testutil/testdata/tx.pb.go index e2d416faa41e..17cefcb39269 100644 --- a/testutil/testdata/tx.pb.go +++ b/testutil/testdata/tx.pb.go @@ -5,7 +5,9 @@ package testdata import ( context "context" + cosmossdk_io_math "cosmossdk.io/math" fmt "fmt" + _ "github.com/cosmos/cosmos-proto" _ "github.com/cosmos/cosmos-sdk/types/msgservice" _ "github.com/cosmos/cosmos-sdk/types/tx/amino" _ "github.com/cosmos/gogoproto/gogoproto" @@ -129,7 +131,8 @@ func (m *MsgCreateDogResponse) GetName() string { // TestMsg is msg type for testing protobuf message using any, as defined in // https://github.com/cosmos/cosmos-sdk/issues/6213. type TestMsg struct { - Signers []string `protobuf:"bytes,1,rep,name=signers,proto3" json:"signers,omitempty"` + Signers []string `protobuf:"bytes,1,rep,name=signers,proto3" json:"signers,omitempty"` + DecField cosmossdk_io_math.LegacyDec `protobuf:"bytes,2,opt,name=decField,proto3,customtype=cosmossdk.io/math.LegacyDec" json:"decField"` } func (m *TestMsg) Reset() { *m = TestMsg{} } @@ -174,29 +177,33 @@ func init() { func init() { proto.RegisterFile("testpb/tx.proto", fileDescriptor_1c54006dba274b2e) } var fileDescriptor_1c54006dba274b2e = []byte{ - // 337 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x6c, 0x90, 0x31, 0x4b, 0xc3, 0x40, - 0x14, 0xc7, 0x73, 0xd6, 0xb6, 0xe4, 0x2a, 0x8a, 0x21, 0x62, 0x08, 0x1a, 0x4b, 0x5d, 0x4a, 0xc0, - 0x1c, 0xd6, 0xad, 0x8b, 0xa0, 0x1d, 0xba, 0x14, 0x21, 0x38, 0xb9, 0xa5, 0xed, 0x71, 0x06, 0x4d, - 0x5e, 0xc9, 0xbb, 0xaa, 0xa3, 0x38, 0x89, 0x93, 0x1f, 0xc1, 0x8f, 0xd0, 0x8f, 0xe1, 0xd8, 0xd1, - 0x51, 0xda, 0xa1, 0x5f, 0x43, 0x72, 0x97, 0x68, 0x07, 0x97, 0xbc, 0xff, 0xfb, 0x3d, 0xf2, 0xbf, - 0xf7, 0xfe, 0x74, 0x47, 0x72, 0x94, 0x93, 0x21, 0x93, 0x4f, 0xc1, 0x24, 0x03, 0x09, 0x56, 0x4d, - 0x03, 0x77, 0x37, 0x4a, 0xe2, 0x14, 0x98, 0xfa, 0xea, 0x91, 0x6b, 0x0b, 0x10, 0xa0, 0x24, 0xcb, - 0x55, 0x41, 0xf7, 0x4a, 0x07, 0x8e, 0x72, 0x1c, 0xc9, 0xa8, 0xc0, 0xfb, 0x23, 0xc0, 0x04, 0x90, - 0x25, 0x28, 0xd8, 0xc3, 0x69, 0x5e, 0xf4, 0xa0, 0x75, 0x45, 0xb7, 0x06, 0x28, 0x2e, 0x33, 0x1e, - 0x49, 0xde, 0x03, 0x61, 0x1d, 0xd2, 0xca, 0x18, 0x84, 0x43, 0x9a, 0xa4, 0xdd, 0xe8, 0x34, 0x02, - 0xed, 0x16, 0xf4, 0x40, 0x84, 0x39, 0xb7, 0x6c, 0x5a, 0x85, 0xc7, 0x94, 0x67, 0xce, 0x46, 0x93, - 0xb4, 0xcd, 0x50, 0x37, 0x5d, 0xfa, 0xb2, 0x9a, 0xf9, 0x5a, 0xb7, 0x7c, 0x6a, 0xaf, 0x1b, 0x86, - 0x1c, 0x27, 0x90, 0x22, 0xb7, 0x2c, 0xba, 0x99, 0x46, 0x09, 0x57, 0xce, 0x66, 0xa8, 0x74, 0xab, - 0x4f, 0xeb, 0xd7, 0x1c, 0xe5, 0x00, 0x85, 0xe5, 0xd0, 0x3a, 0xc6, 0x22, 0xe5, 0x19, 0x3a, 0xa4, - 0x59, 0x69, 0x9b, 0x61, 0xd9, 0x76, 0x8f, 0x5f, 0x3f, 0x8e, 0x8c, 0xfc, 0x81, 0x92, 0xbc, 0xad, - 0x66, 0xfe, 0x76, 0x71, 0x66, 0xf1, 0x7b, 0x67, 0x40, 0x2b, 0xb9, 0xcb, 0x39, 0x35, 0xff, 0x4e, - 0xb1, 0xcb, 0xed, 0xd7, 0xf7, 0x71, 0x0f, 0xfe, 0xa3, 0xe5, 0x96, 0x6e, 0xf5, 0x79, 0x35, 0xf3, - 0xc9, 0x45, 0xff, 0x73, 0xe1, 0x91, 0xf9, 0xc2, 0x23, 0xdf, 0x0b, 0x8f, 0xbc, 0x2f, 0x3d, 0x63, - 0xbe, 0xf4, 0x8c, 0xaf, 0xa5, 0x67, 0xdc, 0x04, 0x22, 0x96, 0xb7, 0xd3, 0x61, 0x30, 0x82, 0x84, - 0x15, 0x99, 0xea, 0x72, 0x82, 0xe3, 0x3b, 0x95, 0xfa, 0x54, 0xc6, 0xf7, 0xbf, 0xf1, 0x0f, 0x6b, - 0x2a, 0xe6, 0xb3, 0x9f, 0x00, 0x00, 0x00, 0xff, 0xff, 0x89, 0xf1, 0xc8, 0x3c, 0xda, 0x01, 0x00, - 0x00, + // 411 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0xe2, 0x2f, 0x49, 0x2d, 0x2e, + 0x29, 0x48, 0xd2, 0x2f, 0xa9, 0xd0, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0x62, 0x83, 0x08, 0x48, + 0x09, 0x26, 0xe6, 0x66, 0xe6, 0xe5, 0xeb, 0x83, 0x49, 0x88, 0x94, 0x94, 0x48, 0x7a, 0x7e, 0x7a, + 0x3e, 0x98, 0xa9, 0x0f, 0x62, 0x41, 0x45, 0x45, 0x61, 0x26, 0xa4, 0x16, 0x97, 0xa4, 0x24, 0x96, + 0x24, 0x42, 0x85, 0xc5, 0x93, 0xf3, 0x8b, 0x73, 0xf3, 0x8b, 0xf5, 0x73, 0x8b, 0xd3, 0xf5, 0xcb, + 0x0c, 0x41, 0x14, 0x54, 0x42, 0x12, 0x22, 0x11, 0x0f, 0x31, 0x08, 0xc2, 0x81, 0x48, 0x29, 0xf9, + 0x73, 0xf1, 0xf8, 0x16, 0xa7, 0x3b, 0x17, 0xa5, 0x26, 0x96, 0xa4, 0xba, 0xe4, 0xa7, 0x0b, 0xc9, + 0x72, 0x31, 0xa7, 0xe4, 0xa7, 0x4b, 0x30, 0x2a, 0x30, 0x6a, 0x70, 0x1b, 0x71, 0xeb, 0x41, 0x2c, + 0xd2, 0x73, 0xc9, 0x4f, 0x0f, 0x02, 0x89, 0x0b, 0x89, 0x70, 0xb1, 0xe6, 0x97, 0xe7, 0xa5, 0x16, + 0x49, 0x30, 0x29, 0x30, 0x6a, 0x70, 0x06, 0x41, 0x38, 0x56, 0x5c, 0x4d, 0xcf, 0x37, 0x68, 0x41, + 0xd8, 0x4a, 0x5a, 0x5c, 0x22, 0xc8, 0x06, 0x06, 0xa5, 0x16, 0x17, 0xe4, 0xe7, 0x15, 0xa7, 0x0a, + 0x09, 0x71, 0xb1, 0xe4, 0x25, 0xe6, 0xa6, 0x82, 0x4d, 0xe6, 0x0c, 0x02, 0xb3, 0x95, 0xe6, 0x30, + 0x72, 0xb1, 0x87, 0xa4, 0x16, 0x97, 0xf8, 0x16, 0xa7, 0x0b, 0x49, 0x70, 0xb1, 0x17, 0x67, 0xa6, + 0xe7, 0xa5, 0x16, 0x15, 0x4b, 0x30, 0x2a, 0x30, 0x6b, 0x70, 0x06, 0xc1, 0xb8, 0x42, 0x41, 0x5c, + 0x1c, 0x29, 0xa9, 0xc9, 0x6e, 0x99, 0xa9, 0x39, 0x29, 0x10, 0x6b, 0x9d, 0xcc, 0x4e, 0xdc, 0x93, + 0x67, 0xb8, 0x75, 0x4f, 0x5e, 0x1a, 0xe2, 0x95, 0xe2, 0x94, 0x6c, 0xbd, 0xcc, 0x7c, 0xfd, 0xdc, + 0xc4, 0x92, 0x0c, 0x3d, 0x9f, 0xd4, 0xf4, 0xc4, 0xe4, 0x4a, 0x97, 0xd4, 0xe4, 0x4b, 0x5b, 0x74, + 0xb9, 0xa0, 0x3e, 0x75, 0x49, 0x4d, 0x5e, 0xf1, 0x7c, 0x83, 0x16, 0x63, 0x10, 0xdc, 0x1c, 0x2b, + 0xe5, 0x8e, 0x05, 0xf2, 0x0c, 0x20, 0x57, 0xc3, 0x6c, 0xe9, 0x7a, 0xbe, 0x41, 0x8b, 0x0f, 0x1a, + 0xac, 0x50, 0x27, 0x19, 0xf9, 0x72, 0x31, 0x83, 0x5c, 0x66, 0xcf, 0xc5, 0x89, 0x08, 0x1f, 0x11, + 0x58, 0x90, 0x20, 0x7b, 0x52, 0x4a, 0x06, 0x9b, 0x28, 0xcc, 0xeb, 0x52, 0xac, 0x0d, 0x20, 0xdb, + 0x9d, 0x3c, 0x4e, 0x3c, 0x92, 0x63, 0xbc, 0xf0, 0x48, 0x8e, 0xf1, 0xc1, 0x23, 0x39, 0xc6, 0x09, + 0x8f, 0xe5, 0x18, 0x2e, 0x3c, 0x96, 0x63, 0xb8, 0xf1, 0x58, 0x8e, 0x21, 0x4a, 0x2f, 0x3d, 0xb3, + 0x24, 0xa3, 0x34, 0x49, 0x2f, 0x39, 0x3f, 0x17, 0x1a, 0x3b, 0x50, 0x4a, 0xb7, 0x38, 0x25, 0x1b, + 0x1c, 0xcb, 0xa5, 0x25, 0x99, 0x39, 0xf0, 0xe8, 0x4e, 0x62, 0x03, 0xc7, 0x9d, 0x31, 0x20, 0x00, + 0x00, 0xff, 0xff, 0x82, 0x43, 0x1a, 0xed, 0x4a, 0x02, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -371,6 +378,16 @@ func (m *TestMsg) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l + { + size := m.DecField.Size() + i -= size + if _, err := m.DecField.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintTx(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 if len(m.Signers) > 0 { for iNdEx := len(m.Signers) - 1; iNdEx >= 0; iNdEx-- { i -= len(m.Signers[iNdEx]) @@ -436,6 +453,8 @@ func (m *TestMsg) Size() (n int) { n += 1 + l + sovTx(uint64(l)) } } + l = m.DecField.Size() + n += 1 + l + sovTx(uint64(l)) return n } @@ -706,6 +725,40 @@ func (m *TestMsg) Unmarshal(dAtA []byte) error { } m.Signers = append(m.Signers, string(dAtA[iNdEx:postIndex])) iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field DecField", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.DecField.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex default: iNdEx = preIndex skippy, err := skipTx(dAtA[iNdEx:]) diff --git a/testutils/sims/runner.go b/testutils/sims/runner.go index 0518b1b34a8d..34acc544bdc0 100644 --- a/testutils/sims/runner.go +++ b/testutils/sims/runner.go @@ -9,8 +9,7 @@ import ( dbm "github.com/cosmos/cosmos-db" "github.com/stretchr/testify/require" - "cosmossdk.io/core/log" - tlog "cosmossdk.io/log" + "cosmossdk.io/log" "github.com/cosmos/cosmos-sdk/baseapp" "github.com/cosmos/cosmos-sdk/client" @@ -109,9 +108,9 @@ func RunWithSeeds[T SimulationApp]( testInstance := NewSimulationAppInstance(t, tCfg, appFactory) var runLogger log.Logger if cli.FlagVerboseValue { - runLogger = tlog.NewTestLogger(t) + runLogger = log.NewTestLogger(t) } else { - runLogger = tlog.NewTestLoggerInfo(t) + runLogger = log.NewTestLoggerInfo(t) } runLogger = runLogger.With("seed", tCfg.Seed) @@ -176,9 +175,9 @@ func NewSimulationAppInstance[T SimulationApp]( dbDir := filepath.Join(workDir, "leveldb-app-sim") var logger log.Logger if cli.FlagVerboseValue { - logger = tlog.NewTestLogger(t) + logger = log.NewTestLogger(t) } else { - logger = tlog.NewTestLoggerError(t) + logger = log.NewTestLoggerError(t) } logger = logger.With("seed", tCfg.Seed) diff --git a/tools/confix/cmd/migrate.go b/tools/confix/cmd/migrate.go index ccab1f4e2173..a7122161d14e 100644 --- a/tools/confix/cmd/migrate.go +++ b/tools/confix/cmd/migrate.go @@ -32,15 +32,31 @@ In case of any error in updating the file, no output is written.`, RunE: func(cmd *cobra.Command, args []string) error { var configPath string clientCtx := client.GetClientContextFromCmd(cmd) + + configType := confix.AppConfigType + isClient, _ := cmd.Flags().GetBool(confix.ClientConfigType) + + if isClient { + configType = confix.ClientConfigType + } + switch { case len(args) > 1: configPath = args[1] case clientCtx.HomeDir != "": - configPath = filepath.Join(clientCtx.HomeDir, "config", "app.toml") + suffix := "app.toml" + if isClient { + suffix = "client.toml" + } + configPath = filepath.Join(clientCtx.HomeDir, "config", suffix) default: return errors.New("must provide a path to the app.toml or client.toml") } + if strings.HasSuffix(configPath, "client.toml") && !isClient { + return errors.New("app.toml file expected, got client.toml, use --client flag to migrate client.toml") + } + targetVersion := args[0] plan, ok := confix.Migrations[targetVersion] if !ok { @@ -62,15 +78,10 @@ In case of any error in updating the file, no output is written.`, outputPath = "" } - configType := confix.AppConfigType - if ok, _ := cmd.Flags().GetBool(confix.ClientConfigType); ok { - configPath = strings.ReplaceAll(configPath, "app.toml", "client.toml") // for the case we are using the home dir of client ctx - configType = confix.ClientConfigType - } else if strings.HasSuffix(configPath, "client.toml") { - return errors.New("app.toml file expected, got client.toml, use --client flag to migrate client.toml") - } + // get transformation steps and formatDoc in which plan need to be applied + steps, formatDoc := plan(rawFile, targetVersion, configType) - if err := confix.Upgrade(ctx, plan(rawFile, targetVersion, configType), configPath, outputPath, FlagSkipValidate); err != nil { + if err := confix.Upgrade(ctx, steps, formatDoc, configPath, outputPath, FlagSkipValidate); err != nil { return fmt.Errorf("failed to migrate config: %w", err) } diff --git a/tools/confix/cmd/mutate.go b/tools/confix/cmd/mutate.go index 73ae7c3d1e7c..772f38e7a86e 100644 --- a/tools/confix/cmd/mutate.go +++ b/tools/confix/cmd/mutate.go @@ -73,7 +73,12 @@ func SetCommand() *cobra.Command { ctx = confix.WithLogWriter(ctx, cmd.ErrOrStderr()) } - return confix.Upgrade(ctx, plan, filename, outputPath, FlagSkipValidate) + doc, err := confix.LoadConfig(filename) + if err != nil { + return err + } + + return confix.Upgrade(ctx, plan, doc, filename, outputPath, FlagSkipValidate) }, } diff --git a/tools/confix/data/v2-app.toml b/tools/confix/data/v2-app.toml new file mode 100644 index 000000000000..6a93006eccfb --- /dev/null +++ b/tools/confix/data/v2-app.toml @@ -0,0 +1,59 @@ +[comet] +# min-retain-blocks defines the minimum block height offset from the current block being committed, such that all blocks past this offset are pruned from CometBFT. A value of 0 indicates that no blocks should be pruned. +min-retain-blocks = 0 +# index-events defines the set of events in the form {eventType}.{attributeKey}, which informs CometBFT what to index. If empty, all events will be indexed. +index-events = [] +# halt-height contains a non-zero block height at which a node will gracefully halt and shutdown that can be used to assist upgrades and testing. +halt-height = 0 +# halt-time contains a non-zero minimum block time (in Unix seconds) at which a node will gracefully halt and shutdown that can be used to assist upgrades and testing. +halt-time = 0 +# address defines the CometBFT RPC server address to bind to. +address = 'tcp://127.0.0.1:26658' +# transport defines the CometBFT RPC server transport protocol: socket, grpc +transport = 'socket' +# trace enables the CometBFT RPC server to output trace information about its internal operations. +trace = false +# standalone starts the application without the CometBFT node. The node should be started separately. +standalone = false + +[grpc] +# Enable defines if the gRPC server should be enabled. +enable = true +# Address defines the gRPC server address to bind to. +address = 'localhost:9090' +# MaxRecvMsgSize defines the max message size in bytes the server can receive. +# The default value is 10MB. +max-recv-msg-size = 10485760 +# MaxSendMsgSize defines the max message size in bytes the server can send. +# The default value is math.MaxInt32. +max-send-msg-size = 2147483647 + +[store] +# The type of database for application and snapshots databases. +app-db-backend = 'goleveldb' + +[store.options] +# State storage database type. Currently we support: 0 for SQLite, 1 for Pebble +ss-type = 0 +# State commitment database type. Currently we support:0 for iavl, 1 for iavl v2 +sc-type = 0 + +# Pruning options for state storage +[store.options.ss-pruning-option] +# Number of recent heights to keep on disk. +keep-recent = 2 +# Height interval at which pruned heights are removed from disk. +interval = 1 + +# Pruning options for state commitment +[store.options.sc-pruning-option] +# Number of recent heights to keep on disk. +keep-recent = 2 +# Height interval at which pruned heights are removed from disk. +interval = 1 + +[store.options.iavl-config] +# CacheSize set the size of the iavl tree cache. +cache-size = 100000 +# If true, the tree will work like no fast storage and always not upgrade fast storage. +skip-fast-storage-upgrade = true diff --git a/tools/confix/data/v2-client.toml b/tools/confix/data/v2-client.toml new file mode 100644 index 000000000000..04fa4067a280 --- /dev/null +++ b/tools/confix/data/v2-client.toml @@ -0,0 +1,27 @@ +# This is a TOML config file. +# For more information, see https://github.com/toml-lang/toml + +############################################################################### +### Client Configuration ### +############################################################################### + +# The network chain ID +chain-id = "" +# The keyring's backend, where the keys are stored (os|file|kwallet|pass|test|memory) +keyring-backend = "test" +# Default key name, if set, defines the default key to use for signing transaction when the --from flag is not specified +keyring-default-keyname = "" +# CLI output format (text|json) +output = "text" +# : to CometBFT RPC interface for this chain +node = "tcp://localhost:26657" +# Transaction broadcasting mode (sync|async) +broadcast-mode = "sync" + +# gRPC server endpoint to which the client will connect. +# It can be overwritten by the --grpc-addr flag in each command. +grpc-address = "" + +# Allow the gRPC client to connect over insecure channels. +# It can be overwritten by the --grpc-insecure flag in each command. +grpc-insecure = false diff --git a/tools/confix/go.mod b/tools/confix/go.mod index fc186fed6c14..d7c74d44b60b 100644 --- a/tools/confix/go.mod +++ b/tools/confix/go.mod @@ -17,7 +17,7 @@ require ( cosmossdk.io/api v0.7.5 // indirect cosmossdk.io/collections v0.4.0 // indirect cosmossdk.io/core v0.11.0 // indirect - cosmossdk.io/depinject v1.0.0-alpha.4 // indirect + cosmossdk.io/depinject v1.0.0 // indirect cosmossdk.io/errors v1.0.1 // indirect cosmossdk.io/log v1.3.1 // indirect cosmossdk.io/math v1.3.0 // indirect diff --git a/tools/confix/go.sum b/tools/confix/go.sum index 5737494ce2ce..bdb33226732d 100644 --- a/tools/confix/go.sum +++ b/tools/confix/go.sum @@ -6,8 +6,8 @@ cosmossdk.io/collections v0.4.0 h1:PFmwj2W8szgpD5nOd8GWH6AbYNi1f2J6akWXJ7P5t9s= cosmossdk.io/collections v0.4.0/go.mod h1:oa5lUING2dP+gdDquow+QjlF45eL1t4TJDypgGd+tv0= cosmossdk.io/core v0.11.0 h1:vtIafqUi+1ZNAE/oxLOQQ7Oek2n4S48SWLG8h/+wdbo= cosmossdk.io/core v0.11.0/go.mod h1:LaTtayWBSoacF5xNzoF8tmLhehqlA9z1SWiPuNC6X1w= -cosmossdk.io/depinject v1.0.0-alpha.4 h1:PLNp8ZYAMPTUKyG9IK2hsbciDWqna2z1Wsl98okJopc= -cosmossdk.io/depinject v1.0.0-alpha.4/go.mod h1:HeDk7IkR5ckZ3lMGs/o91AVUc7E596vMaOmslGFM3yU= +cosmossdk.io/depinject v1.0.0 h1:dQaTu6+O6askNXO06+jyeUAnF2/ssKwrrszP9t5q050= +cosmossdk.io/depinject v1.0.0/go.mod h1:zxK/h3HgHoA/eJVtiSsoaRaRA2D5U4cJ5thIG4ssbB8= cosmossdk.io/errors v1.0.1 h1:bzu+Kcr0kS/1DuPBtUFdWjzLqyUuCiyHjyJB6srBV/0= cosmossdk.io/errors v1.0.1/go.mod h1:MeelVSZThMi4bEakzhhhE/CKqVv3nOJDA25bIqRDu/U= cosmossdk.io/log v1.3.1 h1:UZx8nWIkfbbNEWusZqzAx3ZGvu54TZacWib3EzUYmGI= diff --git a/tools/confix/match.go b/tools/confix/match.go new file mode 100644 index 000000000000..9e05d5f02192 --- /dev/null +++ b/tools/confix/match.go @@ -0,0 +1,63 @@ +package confix + +import ( + "sort" + + "github.com/creachadair/tomledit" + "github.com/creachadair/tomledit/transform" +) + +// MatchKeys diffs the keyspaces of the TOML documents in files lhs and rhs. +// Comments, order, and values are ignored for comparison purposes. +// It will return in the format of map[oldKey]newKey +func MatchKeys(lhs, rhs *tomledit.Document) map[string]string { + matches := matchDocs(map[string]string{}, allKVs(lhs.Global), allKVs(rhs.Global)) + + lsec, rsec := lhs.Sections, rhs.Sections + transform.SortSectionsByName(lsec) + transform.SortSectionsByName(rsec) + + i, j := 0, 0 + for i < len(lsec) && j < len(rsec) { + switch { + case lsec[i].Name.Before(rsec[j].Name): + i++ + case rsec[j].Name.Before(lsec[i].Name): + j++ + default: + matches = matchDocs(matches, allKVs(lsec[i]), allKVs(rsec[j])) + i++ + j++ + } + } + + return matches +} + +// matchDocs get all the keys matching in lhs and rhs. +// value of keys are ignored +func matchDocs(matchesMap map[string]string, lhs, rhs []KV) map[string]string { + sort.Slice(lhs, func(i, j int) bool { + return lhs[i].Key < lhs[j].Key + }) + sort.Slice(rhs, func(i, j int) bool { + return rhs[i].Key < rhs[j].Key + }) + + i, j := 0, 0 + for i < len(lhs) && j < len(rhs) { + switch { + case lhs[i].Key < rhs[j].Key: + i++ + case lhs[i].Key > rhs[j].Key: + j++ + default: + // key exists in both lhs and rhs + matchesMap[lhs[i].Key] = rhs[j].Key + i++ + j++ + } + } + + return matchesMap +} diff --git a/tools/confix/migrations.go b/tools/confix/migrations.go index 2eece120fe5a..737ed6b822cb 100644 --- a/tools/confix/migrations.go +++ b/tools/confix/migrations.go @@ -19,7 +19,7 @@ const ( ) // MigrationMap defines a mapping from a version to a transformation plan. -type MigrationMap map[string]func(from *tomledit.Document, to, planType string) transform.Plan +type MigrationMap map[string]func(from *tomledit.Document, to, planType string) (transform.Plan, *tomledit.Document) var Migrations = MigrationMap{ "v0.45": NoPlan, // Confix supports only the current supported SDK version. So we do not support v0.44 -> v0.45. @@ -27,11 +27,34 @@ var Migrations = MigrationMap{ "v0.47": PlanBuilder, "v0.50": PlanBuilder, "v0.52": PlanBuilder, + "v2": V2PlanBuilder, // "v0.xx.x": PlanBuilder, // add specific migration in case of configuration changes in minor versions } +type v2KeyChangesMap map[string][]string + +// list all the keys which are need to be modified in v2 +var v2KeyChanges = v2KeyChangesMap{ + "min-retain-blocks": []string{"comet.min-retain-blocks"}, + "index-events": []string{"comet.index-events"}, + "halt-height": []string{"comet.halt-height"}, + "halt-time": []string{"comet.halt-time"}, + "app-db-backend": []string{"store.app-db-backend"}, + "pruning-keep-recent": []string{ + "store.options.ss-pruning-option.keep-recent", + "store.options.sc-pruning-option.keep-recent", + }, + "pruning-interval": []string{ + "store.options.ss-pruning-option.interval", + "store.options.sc-pruning-option.interval", + }, + "iavl-cache-size": []string{"store.options.iavl-config.cache-size"}, + "iavl-disable-fastnode": []string{"store.options.iavl-config.skip-fast-storage-upgrade"}, + // Add other key mappings as needed +} + // PlanBuilder is a function that returns a transformation plan for a given diff between two files. -func PlanBuilder(from *tomledit.Document, to, planType string) transform.Plan { +func PlanBuilder(from *tomledit.Document, to, planType string) (transform.Plan, *tomledit.Document) { plan := transform.Plan{} deletedSections := map[string]bool{} @@ -114,11 +137,105 @@ func PlanBuilder(from *tomledit.Document, to, planType string) transform.Plan { plan = append(plan, step) } - return plan + return plan, from } // NoPlan returns a no-op plan. -func NoPlan(_ *tomledit.Document, to, planType string) transform.Plan { +func NoPlan(from *tomledit.Document, to, planType string) (transform.Plan, *tomledit.Document) { fmt.Printf("no migration needed to %s\n", to) - return transform.Plan{} + return transform.Plan{}, from +} + +// V2PlanBuilder is a function that returns a transformation plan to convert to v2 config +func V2PlanBuilder(from *tomledit.Document, to, planType string) (transform.Plan, *tomledit.Document) { + target, err := LoadLocalConfig(to, planType) + if err != nil { + panic(fmt.Errorf("failed to parse file: %w. This file should have been valid", err)) + } + + plan := transform.Plan{} + plan = updateMatchedKeysPlan(from, target, plan) + plan = applyKeyChangesPlan(from, plan) + + return plan, target +} + +// updateMatchedKeysPlan updates all matched keys with old key values +func updateMatchedKeysPlan(from, target *tomledit.Document, plan transform.Plan) transform.Plan { + matches := MatchKeys(from, target) + for oldKey, newKey := range matches { + oldEntry := getEntry(from, oldKey) + if oldEntry == nil { + continue + } + + // check if the key "app-db-backend" exists and if its value is empty in the existing config + // If the value is empty, update the key value with the default value + // of v2 i.e., goleveldb to prevent network failures. + if isAppDBBackend(newKey, oldEntry) { + continue // lets keep app-db-backend with v2 default value + } + + // update newKey value with old entry value + step := createUpdateStep(oldKey, newKey, oldEntry) + plan = append(plan, step) + } + return plan +} + +// applyKeyChangesPlan checks if key changes are needed with the "to" version and applies them +func applyKeyChangesPlan(from *tomledit.Document, plan transform.Plan) transform.Plan { + changes := v2KeyChanges + for oldKey, newKeys := range changes { + oldEntry := getEntry(from, oldKey) + if oldEntry == nil { + continue + } + + for _, newKey := range newKeys { + // check if the key "app-db-backend" exists and if its value is empty in the existing config + // If the value is empty, update the key value with the default value + // of v2 i.e., goleveldb to prevent network failures. + if isAppDBBackend(newKey, oldEntry) { + continue // lets keep app-db-backend with v2 default value + } + + // update newKey value with old entry value + step := createUpdateStep(oldKey, newKey, oldEntry) + plan = append(plan, step) + } + } + return plan +} + +// getEntry retrieves the first entry for the given key from the document +func getEntry(doc *tomledit.Document, key string) *parser.KeyValue { + splitKeys := strings.Split(key, ".") + entry := doc.First(splitKeys...) + if entry == nil || entry.KeyValue == nil { + return nil + } + return entry.KeyValue +} + +// isAppDBBackend checks if the key is "store.app-db-backend" and the value is empty +func isAppDBBackend(key string, entry *parser.KeyValue) bool { + return key == "store.app-db-backend" && entry.Value.String() == `""` +} + +// createUpdateStep creates a transformation step to update a key with a new key value +func createUpdateStep(oldKey, newKey string, oldEntry *parser.KeyValue) transform.Step { + return transform.Step{ + Desc: fmt.Sprintf("updating %s key with %s key", oldKey, newKey), + T: transform.Func(func(_ context.Context, doc *tomledit.Document) error { + splitNewKeys := strings.Split(newKey, ".") + newEntry := doc.First(splitNewKeys...) + if newEntry == nil || newEntry.KeyValue == nil { + return nil + } + + newEntry.KeyValue.Value = oldEntry.Value + return nil + }), + } } diff --git a/tools/confix/upgrade.go b/tools/confix/upgrade.go index d6b4ff7f71ac..d212bbfb7927 100644 --- a/tools/confix/upgrade.go +++ b/tools/confix/upgrade.go @@ -28,16 +28,11 @@ import ( // Upgrade is a convenience wrapper for calls to LoadConfig, ApplyFixes, and // CheckValid. If the caller requires more control over the behavior of the // Upgrade, call those functions directly. -func Upgrade(ctx context.Context, plan transform.Plan, configPath, outputPath string, skipValidate bool) error { +func Upgrade(ctx context.Context, plan transform.Plan, doc *tomledit.Document, configPath, outputPath string, skipValidate bool) error { if configPath == "" { return errors.New("empty input configuration path") } - doc, err := LoadConfig(configPath) - if err != nil { - return fmt.Errorf("loading config: %w", err) - } - // transforms doc and reports whether it succeeded. if err := plan.Apply(ctx, doc); err != nil { return fmt.Errorf("updating %q: %w", configPath, err) @@ -48,14 +43,18 @@ func Upgrade(ctx context.Context, plan transform.Plan, configPath, outputPath st return fmt.Errorf("formatting config: %w", err) } + // ignore validation for serverv2 by checking any default field found in doc + isServerV2 := doc.First(strings.Split("store.options.ss-pruning-option", ".")...) != nil + // allow to skip validation - if !skipValidate { + if !skipValidate && !isServerV2 { // verify that file is valid after applying fixes if err := CheckValid(configPath, buf.Bytes()); err != nil { return fmt.Errorf("updated config is invalid: %w", err) } } + var err error if outputPath == "" { _, err = os.Stdout.Write(buf.Bytes()) } else { diff --git a/tools/cosmovisor/args.go b/tools/cosmovisor/args.go index e89112749b30..40e2553631b3 100644 --- a/tools/cosmovisor/args.go +++ b/tools/cosmovisor/args.go @@ -310,7 +310,7 @@ func parseEnvDuration(input string) (time.Duration, error) { } if duration <= 0 { - return 0, fmt.Errorf("must be greater than 0") + return 0, errors.New("must be greater than 0") } return duration, nil diff --git a/tools/cosmovisor/go.mod b/tools/cosmovisor/go.mod index aacd169fd638..21a5fea45e52 100644 --- a/tools/cosmovisor/go.mod +++ b/tools/cosmovisor/go.mod @@ -24,7 +24,7 @@ require ( cosmossdk.io/api v0.7.5 // indirect cosmossdk.io/collections v0.4.0 // indirect cosmossdk.io/core v0.11.0 // indirect - cosmossdk.io/depinject v1.0.0-alpha.4 // indirect + cosmossdk.io/depinject v1.0.0 // indirect cosmossdk.io/errors v1.0.1 // indirect cosmossdk.io/math v1.3.0 // indirect cosmossdk.io/store v1.1.0 // indirect diff --git a/tools/cosmovisor/go.sum b/tools/cosmovisor/go.sum index 713b07d3ae27..a36072f7b7b1 100644 --- a/tools/cosmovisor/go.sum +++ b/tools/cosmovisor/go.sum @@ -194,8 +194,8 @@ cosmossdk.io/collections v0.4.0 h1:PFmwj2W8szgpD5nOd8GWH6AbYNi1f2J6akWXJ7P5t9s= cosmossdk.io/collections v0.4.0/go.mod h1:oa5lUING2dP+gdDquow+QjlF45eL1t4TJDypgGd+tv0= cosmossdk.io/core v0.11.0 h1:vtIafqUi+1ZNAE/oxLOQQ7Oek2n4S48SWLG8h/+wdbo= cosmossdk.io/core v0.11.0/go.mod h1:LaTtayWBSoacF5xNzoF8tmLhehqlA9z1SWiPuNC6X1w= -cosmossdk.io/depinject v1.0.0-alpha.4 h1:PLNp8ZYAMPTUKyG9IK2hsbciDWqna2z1Wsl98okJopc= -cosmossdk.io/depinject v1.0.0-alpha.4/go.mod h1:HeDk7IkR5ckZ3lMGs/o91AVUc7E596vMaOmslGFM3yU= +cosmossdk.io/depinject v1.0.0 h1:dQaTu6+O6askNXO06+jyeUAnF2/ssKwrrszP9t5q050= +cosmossdk.io/depinject v1.0.0/go.mod h1:zxK/h3HgHoA/eJVtiSsoaRaRA2D5U4cJ5thIG4ssbB8= cosmossdk.io/errors v1.0.1 h1:bzu+Kcr0kS/1DuPBtUFdWjzLqyUuCiyHjyJB6srBV/0= cosmossdk.io/errors v1.0.1/go.mod h1:MeelVSZThMi4bEakzhhhE/CKqVv3nOJDA25bIqRDu/U= cosmossdk.io/log v1.3.1 h1:UZx8nWIkfbbNEWusZqzAx3ZGvu54TZacWib3EzUYmGI= diff --git a/tools/hubl/go.mod b/tools/hubl/go.mod index 92f960fb61b4..ac8fa90b1dc1 100644 --- a/tools/hubl/go.mod +++ b/tools/hubl/go.mod @@ -17,7 +17,7 @@ require ( require ( cosmossdk.io/collections v0.4.0 // indirect - cosmossdk.io/depinject v1.0.0-alpha.4 // indirect + cosmossdk.io/depinject v1.0.0 // indirect cosmossdk.io/log v1.3.1 // indirect cosmossdk.io/math v1.3.0 // indirect cosmossdk.io/store v1.1.0 // indirect diff --git a/tools/hubl/go.sum b/tools/hubl/go.sum index 0cc13874c939..954afa4073f5 100644 --- a/tools/hubl/go.sum +++ b/tools/hubl/go.sum @@ -8,8 +8,8 @@ cosmossdk.io/collections v0.4.0 h1:PFmwj2W8szgpD5nOd8GWH6AbYNi1f2J6akWXJ7P5t9s= cosmossdk.io/collections v0.4.0/go.mod h1:oa5lUING2dP+gdDquow+QjlF45eL1t4TJDypgGd+tv0= cosmossdk.io/core v0.11.0 h1:vtIafqUi+1ZNAE/oxLOQQ7Oek2n4S48SWLG8h/+wdbo= cosmossdk.io/core v0.11.0/go.mod h1:LaTtayWBSoacF5xNzoF8tmLhehqlA9z1SWiPuNC6X1w= -cosmossdk.io/depinject v1.0.0-alpha.4 h1:PLNp8ZYAMPTUKyG9IK2hsbciDWqna2z1Wsl98okJopc= -cosmossdk.io/depinject v1.0.0-alpha.4/go.mod h1:HeDk7IkR5ckZ3lMGs/o91AVUc7E596vMaOmslGFM3yU= +cosmossdk.io/depinject v1.0.0 h1:dQaTu6+O6askNXO06+jyeUAnF2/ssKwrrszP9t5q050= +cosmossdk.io/depinject v1.0.0/go.mod h1:zxK/h3HgHoA/eJVtiSsoaRaRA2D5U4cJ5thIG4ssbB8= cosmossdk.io/errors v1.0.1 h1:bzu+Kcr0kS/1DuPBtUFdWjzLqyUuCiyHjyJB6srBV/0= cosmossdk.io/errors v1.0.1/go.mod h1:MeelVSZThMi4bEakzhhhE/CKqVv3nOJDA25bIqRDu/U= cosmossdk.io/log v1.3.1 h1:UZx8nWIkfbbNEWusZqzAx3ZGvu54TZacWib3EzUYmGI= diff --git a/tools/hubl/internal/version.go b/tools/hubl/internal/version.go index 87a0d57c1d1b..d4dbff188a37 100644 --- a/tools/hubl/internal/version.go +++ b/tools/hubl/internal/version.go @@ -1,7 +1,7 @@ package internal import ( - "fmt" + "errors" "runtime/debug" "strings" @@ -19,7 +19,7 @@ func VersionCmd() *cobra.Command { RunE: func(cmd *cobra.Command, args []string) error { version, ok := debug.ReadBuildInfo() if !ok { - return fmt.Errorf("failed to get hubl version") + return errors.New("failed to get hubl version") } cmd.Printf("hubl version: %s\n", strings.TrimSpace(version.Main.Version)) diff --git a/types/collections.go b/types/collections.go index cf7ad0cb2257..79d9b4fca55a 100644 --- a/types/collections.go +++ b/types/collections.go @@ -2,6 +2,7 @@ package types import ( "encoding/binary" + "errors" "fmt" "time" @@ -255,7 +256,7 @@ var timeSize = len(FormatTimeBytes(time.Time{})) func (timeKeyCodec) Decode(buffer []byte) (int, time.Time, error) { if len(buffer) != timeSize { - return 0, time.Time{}, fmt.Errorf("invalid time buffer size") + return 0, time.Time{}, errors.New("invalid time buffer size") } t, err := ParseTimeBytes(buffer) if err != nil { diff --git a/types/context.go b/types/context.go index 72a944847432..04b74c19d8ce 100644 --- a/types/context.go +++ b/types/context.go @@ -9,7 +9,7 @@ import ( "cosmossdk.io/core/comet" "cosmossdk.io/core/header" - "cosmossdk.io/core/log" + "cosmossdk.io/log" "cosmossdk.io/store/gaskv" storetypes "cosmossdk.io/store/types" ) diff --git a/types/errors/errors.go b/types/errors/errors.go index 5e17f2df481a..36bb82ffd957 100644 --- a/types/errors/errors.go +++ b/types/errors/errors.go @@ -142,4 +142,8 @@ var ( // ErrPanic should only be set when we recovering from a panic ErrPanic = errorsmod.ErrPanic + + // ErrTxTimeout defines an error for when a tx is rejected out due to an + // explicitly set timeout timestamp. + ErrTxTimeout = errorsmod.Register(RootCodespace, 42, "tx timeout") ) diff --git a/types/mempool/mempool_test.go b/types/mempool/mempool_test.go index 8cfb1d0252f1..5c3215857c6d 100644 --- a/types/mempool/mempool_test.go +++ b/types/mempool/mempool_test.go @@ -1,6 +1,7 @@ package mempool_test import ( + "errors" "fmt" "math/rand" "testing" @@ -11,8 +12,8 @@ import ( _ "cosmossdk.io/api/cosmos/counter/v1" _ "cosmossdk.io/api/cosmos/crypto/secp256k1" - coretesting "cosmossdk.io/core/testing" "cosmossdk.io/core/transaction" + "cosmossdk.io/log" "cosmossdk.io/x/auth/signing" codectestutil "github.com/cosmos/cosmos-sdk/codec/testutil" @@ -174,7 +175,7 @@ func fetchTxs(iterator mempool.Iterator, maxBytes int64) []sdk.Tx { func (s *MempoolTestSuite) TestDefaultMempool() { t := s.T() - ctx := sdk.NewContext(nil, false, coretesting.NewNopLogger()) + ctx := sdk.NewContext(nil, false, log.NewNopLogger()) accounts := simtypes.RandomAccounts(rand.New(rand.NewSource(0)), 10) txCount := 1000 var txs []testTx @@ -217,7 +218,7 @@ func (s *MempoolTestSuite) TestDefaultMempool() { // a tx which does not implement SigVerifiableTx should not be inserted tx := &sigErrTx{getSigs: func() ([]txsigning.SignatureV2, error) { - return nil, fmt.Errorf("error") + return nil, errors.New("error") }} require.Error(t, s.mempool.Insert(ctx, tx)) require.Error(t, s.mempool.Remove(tx)) @@ -266,7 +267,7 @@ func TestMempoolTestSuite(t *testing.T) { } func (s *MempoolTestSuite) TestSampleTxs() { - ctxt := sdk.NewContext(nil, false, coretesting.NewNopLogger()) + ctxt := sdk.NewContext(nil, false, log.NewNopLogger()) t := s.T() s.resetMempool() mp := s.mempool diff --git a/types/mempool/priority_nonce.go b/types/mempool/priority_nonce.go index f0df79e70882..a927693410ef 100644 --- a/types/mempool/priority_nonce.go +++ b/types/mempool/priority_nonce.go @@ -2,6 +2,7 @@ package mempool import ( "context" + "errors" "fmt" "math" "sync" @@ -215,7 +216,7 @@ func (mp *PriorityNonceMempool[C]) Insert(ctx context.Context, tx sdk.Tx) error return err } if len(sigs) == 0 { - return fmt.Errorf("tx must have at least one signer") + return errors.New("tx must have at least one signer") } sig := sigs[0] @@ -436,7 +437,7 @@ func (mp *PriorityNonceMempool[C]) Remove(tx sdk.Tx) error { return err } if len(sigs) == 0 { - return fmt.Errorf("attempted to remove a tx with no signatures") + return errors.New("attempted to remove a tx with no signatures") } sig := sigs[0] @@ -466,7 +467,7 @@ func (mp *PriorityNonceMempool[C]) Remove(tx sdk.Tx) error { func IsEmpty[C comparable](mempool Mempool) error { mp := mempool.(*PriorityNonceMempool[C]) if mp.priorityIndex.Len() != 0 { - return fmt.Errorf("priorityIndex not empty") + return errors.New("priorityIndex not empty") } countKeys := make([]C, 0, len(mp.priorityCounts)) diff --git a/types/mempool/priority_nonce_test.go b/types/mempool/priority_nonce_test.go index 3357c2684fdb..0a2f40355fbd 100644 --- a/types/mempool/priority_nonce_test.go +++ b/types/mempool/priority_nonce_test.go @@ -9,7 +9,7 @@ import ( "github.com/stretchr/testify/require" - coretesting "cosmossdk.io/core/testing" + "cosmossdk.io/log" "cosmossdk.io/x/auth/signing" sdk "github.com/cosmos/cosmos-sdk/types" @@ -83,7 +83,7 @@ func (a signerExtractionAdapter) GetSigners(tx sdk.Tx) ([]mempool.SignerData, er func (s *MempoolTestSuite) TestPriorityNonceTxOrderWithAdapter() { t := s.T() - ctx := sdk.NewContext(nil, false, coretesting.NewNopLogger()) + ctx := sdk.NewContext(nil, false, log.NewNopLogger()) accounts := simtypes.RandomAccounts(rand.New(rand.NewSource(0)), 5) sa := accounts[0].Address sb := accounts[1].Address @@ -142,7 +142,7 @@ func (s *MempoolTestSuite) TestPriorityNonceTxOrderWithAdapter() { func (s *MempoolTestSuite) TestPriorityNonceTxOrder() { t := s.T() - ctx := sdk.NewContext(nil, false, coretesting.NewNopLogger()) + ctx := sdk.NewContext(nil, false, log.NewNopLogger()) accounts := simtypes.RandomAccounts(rand.New(rand.NewSource(0)), 5) sa := accounts[0].Address sb := accounts[1].Address @@ -341,7 +341,7 @@ func (s *MempoolTestSuite) TestPriorityNonceTxOrder() { func (s *MempoolTestSuite) TestIterator() { t := s.T() - ctx := sdk.NewContext(nil, false, coretesting.NewNopLogger()) + ctx := sdk.NewContext(nil, false, log.NewNopLogger()) accounts := simtypes.RandomAccounts(rand.New(rand.NewSource(0)), 2) sa := accounts[0].Address sb := accounts[1].Address @@ -396,7 +396,7 @@ func (s *MempoolTestSuite) TestIterator() { } func (s *MempoolTestSuite) TestPriorityTies() { - ctx := sdk.NewContext(nil, false, coretesting.NewNopLogger()) + ctx := sdk.NewContext(nil, false, log.NewNopLogger()) accounts := simtypes.RandomAccounts(rand.New(rand.NewSource(0)), 3) sa := accounts[0].Address sb := accounts[1].Address @@ -520,7 +520,7 @@ func (s *MempoolTestSuite) TestRandomGeneratedTxs() { ) t := s.T() - ctx := sdk.NewContext(nil, false, coretesting.NewNopLogger()) + ctx := sdk.NewContext(nil, false, log.NewNopLogger()) seed := time.Now().UnixNano() t.Logf("running with seed: %d", seed) @@ -556,7 +556,7 @@ func (s *MempoolTestSuite) TestRandomWalkTxs() { s.mempool = mempool.DefaultPriorityMempool() t := s.T() - ctx := sdk.NewContext(nil, false, coretesting.NewNopLogger()) + ctx := sdk.NewContext(nil, false, log.NewNopLogger()) seed := time.Now().UnixNano() // interesting failing seeds: @@ -729,7 +729,7 @@ func TestTxOrderN(t *testing.T) { func TestPriorityNonceMempool_NextSenderTx(t *testing.T) { accounts := simtypes.RandomAccounts(rand.New(rand.NewSource(0)), 2) - ctx := sdk.NewContext(nil, false, coretesting.NewNopLogger()) + ctx := sdk.NewContext(nil, false, log.NewNopLogger()) accA := accounts[0].Address accB := accounts[1].Address @@ -759,7 +759,7 @@ func TestPriorityNonceMempool_NextSenderTx(t *testing.T) { func TestNextSenderTx_TxLimit(t *testing.T) { accounts := simtypes.RandomAccounts(rand.New(rand.NewSource(0)), 2) - ctx := sdk.NewContext(nil, false, coretesting.NewNopLogger()) + ctx := sdk.NewContext(nil, false, log.NewNopLogger()) sa := accounts[0].Address sb := accounts[1].Address @@ -835,7 +835,7 @@ func TestNextSenderTx_TxLimit(t *testing.T) { func TestNextSenderTx_TxReplacement(t *testing.T) { accounts := simtypes.RandomAccounts(rand.New(rand.NewSource(0)), 1) - ctx := sdk.NewContext(nil, false, coretesting.NewNopLogger()) + ctx := sdk.NewContext(nil, false, log.NewNopLogger()) sa := accounts[0].Address txs := []testTx{ diff --git a/types/mempool/sender_nonce.go b/types/mempool/sender_nonce.go index 9e2b25e4e47d..fc4902f64792 100644 --- a/types/mempool/sender_nonce.go +++ b/types/mempool/sender_nonce.go @@ -4,7 +4,7 @@ import ( "context" crand "crypto/rand" // #nosec // crypto/rand is used for seed generation "encoding/binary" - "fmt" + "errors" "math/rand" // #nosec // math/rand is used for random selection and seeded from crypto/rand "sync" @@ -133,7 +133,7 @@ func (snm *SenderNonceMempool) Insert(_ context.Context, tx sdk.Tx) error { return err } if len(sigs) == 0 { - return fmt.Errorf("tx must have at least one signer") + return errors.New("tx must have at least one signer") } sig := sigs[0] @@ -206,7 +206,7 @@ func (snm *SenderNonceMempool) Remove(tx sdk.Tx) error { return err } if len(sigs) == 0 { - return fmt.Errorf("tx must have at least one signer") + return errors.New("tx must have at least one signer") } sig := sigs[0] diff --git a/types/mempool/sender_nonce_property_test.go b/types/mempool/sender_nonce_property_test.go index b4eb36f75815..5ebda7d6f93d 100644 --- a/types/mempool/sender_nonce_property_test.go +++ b/types/mempool/sender_nonce_property_test.go @@ -6,7 +6,7 @@ import ( "github.com/stretchr/testify/require" "pgregory.net/rapid" - coretesting "cosmossdk.io/core/testing" + "cosmossdk.io/log" "cosmossdk.io/x/auth/signing" cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types" @@ -33,7 +33,7 @@ func AddressGenerator(t *rapid.T) *rapid.Generator[sdk.AccAddress] { } func testMempoolProperties(t *rapid.T) { - ctx := sdk.NewContext(nil, false, coretesting.NewNopLogger()) + ctx := sdk.NewContext(nil, false, log.NewNopLogger()) mp := mempool.NewSenderNonceMempool() genMultipleAddress := rapid.SliceOfNDistinct(AddressGenerator(t), 1, 10, func(acc sdk.AccAddress) string { diff --git a/types/mempool/sender_nonce_test.go b/types/mempool/sender_nonce_test.go index 8b56a8a0299c..d4e4fe565ee3 100644 --- a/types/mempool/sender_nonce_test.go +++ b/types/mempool/sender_nonce_test.go @@ -7,7 +7,7 @@ import ( "github.com/stretchr/testify/require" - coretesting "cosmossdk.io/core/testing" + "cosmossdk.io/log" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/mempool" @@ -16,7 +16,7 @@ import ( func (s *MempoolTestSuite) TestTxOrder() { t := s.T() - ctx := sdk.NewContext(nil, false, coretesting.NewNopLogger()) + ctx := sdk.NewContext(nil, false, log.NewNopLogger()) accounts := simtypes.RandomAccounts(rand.New(rand.NewSource(0)), 5) sa := accounts[0].Address sb := accounts[1].Address @@ -140,7 +140,7 @@ func (s *MempoolTestSuite) TestTxOrder() { func (s *MempoolTestSuite) TestMaxTx() { t := s.T() - ctx := sdk.NewContext(nil, false, coretesting.NewNopLogger()) + ctx := sdk.NewContext(nil, false, log.NewNopLogger()) accounts := simtypes.RandomAccounts(rand.New(rand.NewSource(0)), 1) mp := mempool.NewSenderNonceMempool(mempool.SenderNonceMaxTxOpt(1)) @@ -170,7 +170,7 @@ func (s *MempoolTestSuite) TestMaxTx() { func (s *MempoolTestSuite) TestTxNotFoundOnSender() { t := s.T() - ctx := sdk.NewContext(nil, false, coretesting.NewNopLogger()) + ctx := sdk.NewContext(nil, false, log.NewNopLogger()) accounts := simtypes.RandomAccounts(rand.New(rand.NewSource(0)), 1) mp := mempool.NewSenderNonceMempool(mempool.SenderNonceMaxTxOpt(5000)) diff --git a/types/mempool/signer_extraction_adapater_test.go b/types/mempool/signer_extraction_adapater_test.go index 77531956a08d..6bc88a87d59b 100644 --- a/types/mempool/signer_extraction_adapater_test.go +++ b/types/mempool/signer_extraction_adapater_test.go @@ -1,6 +1,7 @@ package mempool_test import ( + "errors" "fmt" "math/rand" "testing" @@ -52,7 +53,7 @@ func TestDefaultSignerExtractor(t *testing.T) { ext := mempool.NewDefaultSignerExtractionAdapter() goodTx := testTx{id: 0, priority: 0, nonce: 0, address: sa} badTx := &sigErrTx{getSigs: func() ([]txsigning.SignatureV2, error) { - return nil, fmt.Errorf("error") + return nil, errors.New("error") }} nonSigVerify := nonVerifiableTx{} @@ -63,7 +64,7 @@ func TestDefaultSignerExtractor(t *testing.T) { err error }{ {name: "valid tx extracts sigs", tx: goodTx, sea: ext, err: nil}, - {name: "invalid tx fails on sig", tx: badTx, sea: ext, err: fmt.Errorf("err")}, + {name: "invalid tx fails on sig", tx: badTx, sea: ext, err: errors.New("err")}, {name: "non-verifiable tx fails on conversion", tx: nonSigVerify, sea: ext, err: fmt.Errorf("tx of type %T does not implement SigVerifiableTx", nonSigVerify)}, } for _, test := range tests { diff --git a/types/module/module_test.go b/types/module/module_test.go index 7d1ecfee0bad..ad8ff8178464 100644 --- a/types/module/module_test.go +++ b/types/module/module_test.go @@ -14,7 +14,7 @@ import ( "google.golang.org/grpc" "cosmossdk.io/core/appmodule" - coretesting "cosmossdk.io/core/testing" + "cosmossdk.io/log" authtypes "cosmossdk.io/x/auth/types" "github.com/cosmos/cosmos-sdk/codec" @@ -171,7 +171,7 @@ func TestManager_InitGenesis(t *testing.T) { require.NotNil(t, mm) require.Equal(t, 3, len(mm.Modules)) - ctx := sdk.NewContext(nil, false, coretesting.NewNopLogger()) + ctx := sdk.NewContext(nil, false, log.NewNopLogger()) genesisData := map[string]json.RawMessage{"module1": json.RawMessage(`{"key": "value"}`)} // this should error since the validator set is empty even after init genesis @@ -220,7 +220,7 @@ func TestManager_ExportGenesis(t *testing.T) { require.NotNil(t, mm) require.Equal(t, 3, len(mm.Modules)) - ctx := sdk.NewContext(nil, false, coretesting.NewNopLogger()) + ctx := sdk.NewContext(nil, false, log.NewNopLogger()) mockAppModule1.EXPECT().ExportGenesis(gomock.Eq(ctx)).AnyTimes().Return(json.RawMessage(`{"key1": "value1"}`), nil) mockAppModule2.EXPECT().ExportGenesis(gomock.Eq(ctx)).AnyTimes().Return(json.RawMessage(`{"key2": "value2"}`), nil) @@ -304,7 +304,7 @@ func TestCoreAPIManager_InitGenesis(t *testing.T) { require.NotNil(t, mm) require.Equal(t, 1, len(mm.Modules)) - ctx := sdk.NewContext(nil, false, coretesting.NewNopLogger()) + ctx := sdk.NewContext(nil, false, log.NewNopLogger()) genesisData := map[string]json.RawMessage{"module1": json.RawMessage(`{"key": "value"}`)} // this should panic since the validator set is empty even after init genesis @@ -326,7 +326,7 @@ func TestCoreAPIManager_ExportGenesis(t *testing.T) { require.NotNil(t, mm) require.Equal(t, 2, len(mm.Modules)) - ctx := sdk.NewContext(nil, false, coretesting.NewNopLogger()) + ctx := sdk.NewContext(nil, false, log.NewNopLogger()) want := map[string]json.RawMessage{ "module1": json.RawMessage(`{ "someField": "someKey" diff --git a/types/query/collections_pagination.go b/types/query/collections_pagination.go index fb17fd8c56e4..2877df26396c 100644 --- a/types/query/collections_pagination.go +++ b/types/query/collections_pagination.go @@ -3,7 +3,6 @@ package query import ( "context" "errors" - "fmt" "cosmossdk.io/collections" collcodec "cosmossdk.io/collections/codec" @@ -87,7 +86,7 @@ func CollectionFilteredPaginate[K, V any, C Collection[K, V], T any]( reverse := pageReq.Reverse if offset > 0 && key != nil { - return nil, nil, fmt.Errorf("invalid request, either offset or key is expected, got both") + return nil, nil, errors.New("invalid request, either offset or key is expected, got both") } opt := new(CollectionsPaginateOptions[K]) diff --git a/types/query/filtered_pagination.go b/types/query/filtered_pagination.go index 7d57aa8f534f..1eafe6321b33 100644 --- a/types/query/filtered_pagination.go +++ b/types/query/filtered_pagination.go @@ -1,7 +1,7 @@ package query import ( - "fmt" + "errors" "github.com/cosmos/gogoproto/proto" @@ -26,7 +26,7 @@ func FilteredPaginate( pageRequest = initPageRequestDefaults(pageRequest) if pageRequest.Offset > 0 && pageRequest.Key != nil { - return nil, fmt.Errorf("invalid request, either offset or key is expected, got both") + return nil, errors.New("invalid request, either offset or key is expected, got both") } var ( @@ -151,7 +151,7 @@ func GenericFilteredPaginate[T, F proto.Message]( results := []F{} if pageRequest.Offset > 0 && pageRequest.Key != nil { - return results, nil, fmt.Errorf("invalid request, either offset or key is expected, got both") + return results, nil, errors.New("invalid request, either offset or key is expected, got both") } var ( diff --git a/types/query/pagination.go b/types/query/pagination.go index 110dc57fa2e7..c26ca38ff73b 100644 --- a/types/query/pagination.go +++ b/types/query/pagination.go @@ -1,7 +1,7 @@ package query import ( - "fmt" + "errors" "math" db "github.com/cosmos/cosmos-db" @@ -62,7 +62,7 @@ func Paginate( pageRequest = initPageRequestDefaults(pageRequest) if pageRequest.Offset > 0 && pageRequest.Key != nil { - return nil, fmt.Errorf("invalid request, either offset or key is expected, got both") + return nil, errors.New("invalid request, either offset or key is expected, got both") } iterator := getIterator(prefixStore, pageRequest.Key, pageRequest.Reverse) diff --git a/types/result.go b/types/result.go index 148847eecf2b..b4724151e9da 100644 --- a/types/result.go +++ b/types/result.go @@ -7,6 +7,7 @@ import ( cmtproto "github.com/cometbft/cometbft/api/cometbft/types/v1" coretypes "github.com/cometbft/cometbft/rpc/core/types" + gogoprotoany "github.com/cosmos/gogoproto/types/any" "github.com/cosmos/cosmos-sdk/codec" codectypes "github.com/cosmos/cosmos-sdk/codec/types" @@ -159,13 +160,13 @@ func ParseABCILogs(logs string) (res ABCIMessageLogs, err error) { return res, err } -var _, _ codectypes.UnpackInterfacesMessage = SearchTxsResult{}, TxResponse{} +var _, _ gogoprotoany.UnpackInterfacesMessage = SearchTxsResult{}, TxResponse{} // UnpackInterfaces implements UnpackInterfacesMessage.UnpackInterfaces // // types.UnpackInterfaces needs to be called for each nested Tx because // there are generally interfaces to unpack in Tx's -func (s SearchTxsResult) UnpackInterfaces(unpacker codectypes.AnyUnpacker) error { +func (s SearchTxsResult) UnpackInterfaces(unpacker gogoprotoany.AnyUnpacker) error { for _, tx := range s.Txs { err := codectypes.UnpackInterfaces(tx, unpacker) if err != nil { @@ -176,7 +177,7 @@ func (s SearchTxsResult) UnpackInterfaces(unpacker codectypes.AnyUnpacker) error } // UnpackInterfaces implements UnpackInterfacesMessage.UnpackInterfaces -func (r TxResponse) UnpackInterfaces(unpacker codectypes.AnyUnpacker) error { +func (r TxResponse) UnpackInterfaces(unpacker gogoprotoany.AnyUnpacker) error { if r.Tx != nil { var tx HasMsgs return unpacker.UnpackAny(r.Tx, &tx) diff --git a/types/simulation/account.go b/types/simulation/account.go index 0c3f786b5f36..d046ea23e284 100644 --- a/types/simulation/account.go +++ b/types/simulation/account.go @@ -1,7 +1,7 @@ package simulation import ( - "fmt" + "errors" "math/rand" "github.com/cosmos/cosmos-sdk/crypto/keys/ed25519" @@ -90,7 +90,7 @@ func RandomFees(r *rand.Rand, spendableCoins sdk.Coins) (sdk.Coins, error) { } if randCoin.Amount.IsZero() { - return nil, fmt.Errorf("no coins found for random fees") + return nil, errors.New("no coins found for random fees") } amt, err := RandPositiveInt(r, randCoin.Amount) diff --git a/types/simulation/types.go b/types/simulation/types.go index da9c67332f6c..c576b2885d06 100644 --- a/types/simulation/types.go +++ b/types/simulation/types.go @@ -1,6 +1,7 @@ package simulation import ( + "context" "encoding/json" "fmt" "math/rand" @@ -10,11 +11,15 @@ import ( "cosmossdk.io/core/address" - "github.com/cosmos/cosmos-sdk/baseapp" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/kv" ) +// AppEntrypoint defines the method for delivering simulation TX to the app. This is implemented by *Baseapp +type AppEntrypoint interface { + SimDeliver(_txEncoder sdk.TxEncoder, tx sdk.Tx) (sdk.GasInfo, *sdk.Result, error) +} + // Deprecated: Use WeightedProposalMsg instead. type WeightedProposalContent interface { AppParamsKey() string // key used to retrieve the value of the weight from the simulation application params @@ -36,12 +41,16 @@ type Content interface { } type WeightedProposalMsg interface { - AppParamsKey() string // key used to retrieve the value of the weight from the simulation application params - DefaultWeight() int // default weight - MsgSimulatorFn() MsgSimulatorFn // msg simulator function + AppParamsKey() string // key used to retrieve the value of the weight from the simulation application params + DefaultWeight() int // default weight + MsgSimulatorFn() MsgSimulatorFnX // msg simulator function } -type MsgSimulatorFn func(r *rand.Rand, accs []Account, cdc address.Codec) (sdk.Msg, error) +type ( + // Deprecated: use MsgSimulatorFnX + MsgSimulatorFn func(r *rand.Rand, accs []Account, cdc address.Codec) (sdk.Msg, error) + MsgSimulatorFnX func(ctx context.Context, r *rand.Rand, accs []Account, cdc address.Codec) (sdk.Msg, error) +) type SimValFn func(r *rand.Rand) string @@ -66,7 +75,7 @@ type WeightedOperation interface { // // Operations can optionally provide a list of "FutureOperations" to run later // These will be ran at the beginning of the corresponding block. -type Operation func(r *rand.Rand, app *baseapp.BaseApp, +type Operation func(r *rand.Rand, app AppEntrypoint, ctx sdk.Context, accounts []Account, chainID string) ( OperationMsg OperationMsg, futureOps []FutureOperation, err error) diff --git a/types/tx/direct_aux.go b/types/tx/direct_aux.go index 52c9fc214a8e..d685a837ad29 100644 --- a/types/tx/direct_aux.go +++ b/types/tx/direct_aux.go @@ -1,7 +1,8 @@ package tx import ( - codectypes "github.com/cosmos/cosmos-sdk/codec/types" + gogoprotoany "github.com/cosmos/gogoproto/types/any" + cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" "github.com/cosmos/cosmos-sdk/types/tx/signing" @@ -21,7 +22,7 @@ func (s *SignDocDirectAux) ValidateBasic() error { } // UnpackInterfaces implements the UnpackInterfaceMessages.UnpackInterfaces method -func (s *SignDocDirectAux) UnpackInterfaces(unpacker codectypes.AnyUnpacker) error { +func (s *SignDocDirectAux) UnpackInterfaces(unpacker gogoprotoany.AnyUnpacker) error { return unpacker.UnpackAny(s.PublicKey, new(cryptotypes.PubKey)) } @@ -60,6 +61,6 @@ func (a *AuxSignerData) GetSignatureV2() (signing.SignatureV2, error) { } // UnpackInterfaces implements the UnpackInterfaceMessages.UnpackInterfaces method -func (a *AuxSignerData) UnpackInterfaces(unpacker codectypes.AnyUnpacker) error { +func (a *AuxSignerData) UnpackInterfaces(unpacker gogoprotoany.AnyUnpacker) error { return a.GetSignDoc().UnpackInterfaces(unpacker) } diff --git a/types/tx/ext.go b/types/tx/ext.go index fb2e1ed448bc..e51be337d5b1 100644 --- a/types/tx/ext.go +++ b/types/tx/ext.go @@ -1,6 +1,8 @@ package tx import ( + gogoprotoany "github.com/cosmos/gogoproto/types/any" + "github.com/cosmos/cosmos-sdk/codec/types" ) @@ -8,7 +10,7 @@ import ( type TxExtensionOptionI interface{} // unpackTxExtensionOptionsI unpacks Any's to TxExtensionOptionI's. -func unpackTxExtensionOptionsI(unpacker types.AnyUnpacker, anys []*types.Any) error { +func unpackTxExtensionOptionsI(unpacker gogoprotoany.AnyUnpacker, anys []*types.Any) error { for _, any := range anys { var opt TxExtensionOptionI err := unpacker.UnpackAny(any, &opt) diff --git a/types/tx/msgs.go b/types/tx/msgs.go index 2f2f9a80f912..036f9a2414c8 100644 --- a/types/tx/msgs.go +++ b/types/tx/msgs.go @@ -3,6 +3,8 @@ package tx import ( "fmt" + gogoprotoany "github.com/cosmos/gogoproto/types/any" + "github.com/cosmos/cosmos-sdk/codec/types" sdk "github.com/cosmos/cosmos-sdk/types" ) @@ -53,7 +55,7 @@ func GetMsgs(anys []*types.Any, name string) ([]sdk.Msg, error) { } // UnpackInterfaces unpacks Any's to sdk.Msg's. -func UnpackInterfaces(unpacker types.AnyUnpacker, anys []*types.Any) error { +func UnpackInterfaces(unpacker gogoprotoany.AnyUnpacker, anys []*types.Any) error { for _, any := range anys { var msg sdk.Msg err := unpacker.UnpackAny(any, &msg) diff --git a/types/tx/signing/signature.go b/types/tx/signing/signature.go index a9549bab9a12..a27ea27b86eb 100644 --- a/types/tx/signing/signature.go +++ b/types/tx/signing/signature.go @@ -3,7 +3,8 @@ package signing import ( "fmt" - codectypes "github.com/cosmos/cosmos-sdk/codec/types" + gogoprotoany "github.com/cosmos/gogoproto/types/any" + cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types" ) @@ -86,10 +87,10 @@ func SignatureDataFromProto(descData *SignatureDescriptor_Data) SignatureData { } } -var _, _ codectypes.UnpackInterfacesMessage = &SignatureDescriptors{}, &SignatureDescriptor{} +var _, _ gogoprotoany.UnpackInterfacesMessage = &SignatureDescriptors{}, &SignatureDescriptor{} // UnpackInterfaces implements the UnpackInterfaceMessages.UnpackInterfaces method -func (sds *SignatureDescriptors) UnpackInterfaces(unpacker codectypes.AnyUnpacker) error { +func (sds *SignatureDescriptors) UnpackInterfaces(unpacker gogoprotoany.AnyUnpacker) error { for _, sig := range sds.Signatures { err := sig.UnpackInterfaces(unpacker) if err != nil { @@ -101,6 +102,6 @@ func (sds *SignatureDescriptors) UnpackInterfaces(unpacker codectypes.AnyUnpacke } // UnpackInterfaces implements the UnpackInterfaceMessages.UnpackInterfaces method -func (sd *SignatureDescriptor) UnpackInterfaces(unpacker codectypes.AnyUnpacker) error { +func (sd *SignatureDescriptor) UnpackInterfaces(unpacker gogoprotoany.AnyUnpacker) error { return unpacker.UnpackAny(sd.PublicKey, new(cryptotypes.PubKey)) } diff --git a/types/tx/tx.pb.go b/types/tx/tx.pb.go index f0230d462abb..5037f2c605d6 100644 --- a/types/tx/tx.pb.go +++ b/types/tx/tx.pb.go @@ -13,16 +13,20 @@ import ( signing "github.com/cosmos/cosmos-sdk/types/tx/signing" _ "github.com/cosmos/gogoproto/gogoproto" proto "github.com/cosmos/gogoproto/proto" + github_com_cosmos_gogoproto_types "github.com/cosmos/gogoproto/types" any "github.com/cosmos/gogoproto/types/any" + _ "google.golang.org/protobuf/types/known/timestamppb" io "io" math "math" math_bits "math/bits" + time "time" ) // Reference imports to suppress errors if they are not otherwise used. var _ = proto.Marshal var _ = fmt.Errorf var _ = math.Inf +var _ = time.Kitchen // This is a compile-time assertion to ensure that this generated file // is compatible with the proto package it is being compiled against. @@ -359,10 +363,6 @@ type TxBody struct { Memo string `protobuf:"bytes,2,opt,name=memo,proto3" json:"memo,omitempty"` // timeout_height is the block height after which this transaction will not // be processed by the chain. - // - // Note, if unordered=true this value MUST be set - // and will act as a short-lived TTL in which the transaction is deemed valid - // and kept in memory to prevent duplicates. TimeoutHeight uint64 `protobuf:"varint,3,opt,name=timeout_height,json=timeoutHeight,proto3" json:"timeout_height,omitempty"` // unordered, when set to true, indicates that the transaction signer(s) // intend for the transaction to be evaluated and executed in an un-ordered @@ -370,10 +370,17 @@ type TxBody struct { // incremented, which allows for fire-and-forget as well as concurrent // transaction execution. // - // Note, when set to true, the existing 'timeout_height' value must be set and - // will be used to correspond to a height in which the transaction is deemed + // Note, when set to true, the existing 'timeout_height' value must + // be set and will be used to correspond to a time_stamp in which the transaction is deemed // valid. Unordered bool `protobuf:"varint,4,opt,name=unordered,proto3" json:"unordered,omitempty"` + // timeout_timestamp is the block time after which this transaction will not + // be processed by the chain. + // + // Note, if unordered=true this value MUST be set + // and will act as a short-lived TTL in which the transaction is deemed valid + // and kept in memory to prevent duplicates. + TimeoutTimestamp *time.Time `protobuf:"bytes,5,opt,name=timeout_timestamp,json=timeoutTimestamp,proto3,stdtime" json:"timeout_timestamp,omitempty"` // extension_options are arbitrary options that can be added by chains // when the default options are not sufficient. If any of these are present // and can't be handled, the transaction will be rejected @@ -445,6 +452,13 @@ func (m *TxBody) GetUnordered() bool { return false } +func (m *TxBody) GetTimeoutTimestamp() *time.Time { + if m != nil { + return m.TimeoutTimestamp + } + return nil +} + func (m *TxBody) GetExtensionOptions() []*any.Any { if m != nil { return m.ExtensionOptions @@ -1036,77 +1050,79 @@ func init() { func init() { proto.RegisterFile("cosmos/tx/v1beta1/tx.proto", fileDescriptor_96d1575ffde80842) } var fileDescriptor_96d1575ffde80842 = []byte{ - // 1106 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xc4, 0x55, 0xcf, 0x6f, 0x1b, 0xc5, - 0x17, 0xf7, 0x7a, 0x6d, 0xc7, 0x7e, 0x4d, 0xfa, 0x63, 0xbe, 0xed, 0x57, 0x8e, 0x4b, 0xdd, 0xe0, - 0xaa, 0x60, 0x55, 0x64, 0xb7, 0x4d, 0x11, 0x94, 0x08, 0x51, 0xec, 0x86, 0x28, 0x55, 0x29, 0x48, - 0x9b, 0x9c, 0x7a, 0x59, 0x8d, 0x77, 0x27, 0xeb, 0x51, 0xbd, 0x33, 0xcb, 0xce, 0x2c, 0x78, 0x8f, - 0x9c, 0x38, 0x21, 0x55, 0x5c, 0x90, 0xf8, 0x0b, 0x10, 0xa7, 0x4a, 0x54, 0xe2, 0x5f, 0x28, 0xb7, - 0x2a, 0x27, 0xc4, 0x01, 0xaa, 0xe4, 0xd0, 0x3f, 0x03, 0xb4, 0xb3, 0xb3, 0x9b, 0xb4, 0x75, 0x1d, - 0x10, 0x48, 0x5c, 0x56, 0x33, 0x6f, 0x3f, 0xef, 0xcd, 0x67, 0xde, 0xfb, 0xcc, 0x7b, 0xd0, 0xf1, - 0xb8, 0x08, 0xb9, 0xb0, 0xe5, 0xd4, 0xfe, 0xfc, 0xda, 0x88, 0x48, 0x7c, 0xcd, 0x96, 0x53, 0x2b, - 0x8a, 0xb9, 0xe4, 0xe8, 0x4c, 0xfe, 0xcf, 0x92, 0x53, 0x4b, 0xff, 0xeb, 0x2c, 0xe7, 0x26, 0x57, - 0x01, 0x6c, 0xfd, 0x5f, 0x6d, 0x3a, 0x67, 0x70, 0x48, 0x19, 0xb7, 0xd5, 0x57, 0x9b, 0xce, 0x06, - 0x3c, 0xe0, 0x39, 0x34, 0x5b, 0x69, 0xeb, 0xaa, 0x3e, 0xd2, 0x8b, 0xd3, 0x48, 0x72, 0x3b, 0x4c, - 0x26, 0x92, 0x0a, 0x1a, 0x94, 0xe7, 0x17, 0x06, 0x0d, 0xef, 0x6a, 0xf8, 0x08, 0x0b, 0x52, 0x62, - 0x3c, 0x4e, 0x99, 0xfe, 0xff, 0xe6, 0xe1, 0x0d, 0x04, 0x0d, 0x18, 0x65, 0x87, 0x91, 0xf4, 0x5e, - 0x03, 0x97, 0x03, 0xce, 0x83, 0x09, 0xb1, 0xd5, 0x6e, 0x94, 0xec, 0xda, 0x98, 0xa5, 0xf9, 0xaf, - 0xde, 0xd7, 0x06, 0x54, 0x77, 0xa6, 0x68, 0x15, 0x6a, 0x23, 0xee, 0xa7, 0x6d, 0x63, 0xc5, 0xe8, - 0x9f, 0x58, 0x5b, 0xb6, 0x5e, 0xba, 0xbf, 0xb5, 0x33, 0x1d, 0x72, 0x3f, 0x75, 0x14, 0x0c, 0xdd, - 0x80, 0x16, 0x4e, 0xe4, 0xd8, 0xa5, 0x6c, 0x97, 0xb7, 0xab, 0xca, 0xe7, 0xfc, 0x0c, 0x9f, 0x41, - 0x22, 0xc7, 0xb7, 0xd9, 0x2e, 0x77, 0x9a, 0x58, 0xaf, 0x50, 0x17, 0x20, 0xe3, 0x86, 0x65, 0x12, - 0x13, 0xd1, 0x36, 0x57, 0xcc, 0xfe, 0xa2, 0x73, 0xc4, 0xd2, 0x63, 0x50, 0xdf, 0x99, 0x3a, 0xf8, - 0x0b, 0x74, 0x01, 0x20, 0x3b, 0xca, 0x1d, 0xa5, 0x92, 0x08, 0xc5, 0x6b, 0xd1, 0x69, 0x65, 0x96, - 0x61, 0x66, 0x40, 0x6f, 0xc0, 0xa9, 0x92, 0x81, 0xc6, 0x54, 0x15, 0x66, 0xa9, 0x38, 0x2a, 0xc7, - 0x1d, 0x77, 0xde, 0x37, 0x06, 0x2c, 0x6c, 0xd3, 0x80, 0x6d, 0x70, 0xef, 0xdf, 0x3a, 0x72, 0x19, - 0x9a, 0xde, 0x18, 0x53, 0xe6, 0x52, 0xbf, 0x6d, 0xae, 0x18, 0xfd, 0x96, 0xb3, 0xa0, 0xf6, 0xb7, - 0x7d, 0x74, 0x19, 0x4e, 0x62, 0xcf, 0xe3, 0x09, 0x93, 0x2e, 0x4b, 0xc2, 0x11, 0x89, 0xdb, 0xb5, - 0x15, 0xa3, 0x5f, 0x73, 0x96, 0xb4, 0xf5, 0x13, 0x65, 0xec, 0x7d, 0x55, 0x85, 0xd3, 0x9a, 0xd4, - 0x06, 0x8d, 0x89, 0x27, 0x07, 0xc9, 0xf4, 0x38, 0x76, 0xd7, 0x01, 0xa2, 0x64, 0x34, 0xa1, 0x9e, - 0x7b, 0x9f, 0xa4, 0xba, 0x26, 0x67, 0xad, 0xbc, 0xf0, 0x56, 0x51, 0x78, 0x6b, 0xc0, 0x52, 0xa7, - 0x95, 0xe3, 0xee, 0x90, 0xf4, 0x9f, 0x53, 0x45, 0x1d, 0x68, 0x0a, 0xf2, 0x59, 0x42, 0x98, 0x47, - 0xda, 0x75, 0x05, 0x28, 0xf7, 0xe8, 0x2d, 0x30, 0x25, 0x8d, 0xda, 0x0d, 0xc5, 0xe5, 0xff, 0xb3, - 0x34, 0x45, 0xa3, 0x61, 0xb5, 0x6d, 0x38, 0x19, 0x6c, 0xfd, 0x7f, 0x7b, 0x8f, 0x56, 0x4f, 0xe5, - 0x98, 0x55, 0xe1, 0xdf, 0x5f, 0xb9, 0x6a, 0xbd, 0xfd, 0x4e, 0xef, 0xc7, 0x2a, 0x34, 0x72, 0xe5, - 0xa1, 0xab, 0xd0, 0x0c, 0x89, 0x10, 0x38, 0x50, 0xb7, 0x37, 0x5f, 0x79, 0xbd, 0x12, 0x85, 0x10, - 0xd4, 0x42, 0x12, 0xe6, 0x02, 0x6d, 0x39, 0x6a, 0x9d, 0x5d, 0x4b, 0xd2, 0x90, 0xf0, 0x44, 0xba, - 0x63, 0x42, 0x83, 0xb1, 0x54, 0xf7, 0xae, 0x39, 0x4b, 0xda, 0xba, 0xa5, 0x8c, 0xe8, 0x35, 0x68, - 0x25, 0x8c, 0xc7, 0x3e, 0x89, 0x89, 0xaf, 0x2e, 0xde, 0x74, 0x0e, 0x0d, 0x68, 0x08, 0x67, 0xc8, - 0x54, 0x12, 0x26, 0x28, 0x67, 0x2e, 0x8f, 0x24, 0xe5, 0x4c, 0xb4, 0xff, 0x58, 0x98, 0x43, 0xea, - 0x74, 0x89, 0xff, 0x34, 0x87, 0xa3, 0x7b, 0xd0, 0x65, 0x9c, 0xb9, 0x5e, 0x4c, 0x25, 0xf5, 0xf0, - 0xc4, 0x9d, 0x11, 0xf0, 0xd4, 0x9c, 0x80, 0xe7, 0x19, 0x67, 0xb7, 0xb4, 0xef, 0x47, 0x2f, 0xc4, - 0xee, 0xfd, 0x64, 0x40, 0xb3, 0x78, 0x7b, 0xe8, 0x43, 0x58, 0xcc, 0xf4, 0x4e, 0x62, 0x25, 0xdc, - 0x22, 0x77, 0x17, 0x66, 0x94, 0x63, 0x5b, 0xc1, 0xd4, 0x83, 0x3d, 0x21, 0xca, 0xb5, 0x40, 0x7d, - 0x30, 0x77, 0x09, 0xd1, 0x9a, 0x9a, 0x55, 0xc7, 0x4d, 0x42, 0x9c, 0x0c, 0x82, 0x6e, 0xe6, 0x15, - 0x37, 0xe7, 0x56, 0xfc, 0xdc, 0xaf, 0x2f, 0x17, 0x5a, 0x8b, 0xa0, 0xf7, 0xad, 0x01, 0x70, 0x48, - 0xe3, 0x05, 0x51, 0x1b, 0x7f, 0x4d, 0xd4, 0x37, 0xa0, 0x15, 0x72, 0x9f, 0x1c, 0xd7, 0x9c, 0xee, - 0x72, 0x9f, 0xe4, 0xcd, 0x29, 0xd4, 0xab, 0xe7, 0xc4, 0x6c, 0x3e, 0x2f, 0xe6, 0xde, 0xd3, 0x2a, - 0x34, 0x0b, 0x17, 0xf4, 0x3e, 0x34, 0x04, 0x65, 0xc1, 0x84, 0x68, 0x4e, 0xbd, 0x39, 0xf1, 0xad, - 0x6d, 0x85, 0xdc, 0xaa, 0x38, 0xda, 0x07, 0xbd, 0x07, 0x75, 0xd5, 0xe9, 0x35, 0xb9, 0xd7, 0xe7, - 0x39, 0xdf, 0xcd, 0x80, 0x5b, 0x15, 0x27, 0xf7, 0xe8, 0x0c, 0xa0, 0x91, 0x87, 0x43, 0xef, 0x42, - 0x2d, 0xe3, 0xad, 0x08, 0x9c, 0x5c, 0xbb, 0x74, 0x24, 0x46, 0xd1, 0xfb, 0x8f, 0x96, 0x35, 0x8b, - 0xe7, 0x28, 0x87, 0xce, 0x03, 0x03, 0xea, 0x2a, 0x2a, 0xba, 0x03, 0xcd, 0x11, 0x95, 0x38, 0x8e, - 0x71, 0x91, 0x5b, 0xbb, 0x08, 0x93, 0x4f, 0x28, 0xab, 0x1c, 0x48, 0x45, 0xac, 0x5b, 0x3c, 0x8c, - 0xb0, 0x27, 0x87, 0x54, 0x0e, 0x32, 0x37, 0xa7, 0x0c, 0x80, 0xd6, 0x01, 0xca, 0xac, 0x67, 0x8d, - 0xd1, 0x3c, 0x2e, 0xed, 0xad, 0x22, 0xed, 0x62, 0x58, 0x07, 0x53, 0x24, 0x61, 0xef, 0xcb, 0x2a, - 0x98, 0x9b, 0x84, 0xa0, 0x14, 0x1a, 0x38, 0xcc, 0x7a, 0x8c, 0xd6, 0x6a, 0x39, 0x8e, 0xb2, 0x41, - 0x78, 0x84, 0x0a, 0x65, 0xc3, 0xcd, 0xc7, 0xbf, 0x5d, 0xac, 0xfc, 0xf0, 0xfb, 0xc5, 0x7e, 0x40, - 0xe5, 0x38, 0x19, 0x59, 0x1e, 0x0f, 0xed, 0x62, 0xc8, 0x96, 0x0a, 0xb3, 0x65, 0x1a, 0x11, 0xa1, - 0x1c, 0xc4, 0x77, 0xcf, 0x1e, 0x5e, 0x59, 0x9c, 0x90, 0x00, 0x7b, 0xa9, 0x9b, 0x8d, 0x52, 0xf1, - 0xfd, 0xb3, 0x87, 0x57, 0x0c, 0x47, 0x1f, 0x88, 0xce, 0x43, 0x2b, 0xc0, 0xc2, 0x9d, 0xd0, 0x90, - 0x4a, 0x55, 0x9e, 0x9a, 0xd3, 0x0c, 0xb0, 0xf8, 0x38, 0xdb, 0x23, 0x0b, 0xea, 0x11, 0x4e, 0x49, - 0x9c, 0xb7, 0xca, 0x61, 0x7b, 0xef, 0xd1, 0xea, 0x59, 0xcd, 0x6c, 0xe0, 0xfb, 0x31, 0x11, 0x62, - 0x5b, 0xc6, 0x94, 0x05, 0x4e, 0x0e, 0x43, 0x6b, 0xb0, 0x10, 0xc4, 0x98, 0x49, 0xdd, 0x3b, 0xe7, - 0x79, 0x14, 0xc0, 0xde, 0xcf, 0x06, 0x98, 0x3b, 0x34, 0xfa, 0x2f, 0x73, 0x70, 0x15, 0x1a, 0x92, - 0x46, 0x11, 0x89, 0xf3, 0xc6, 0x39, 0x87, 0xb5, 0xc6, 0xad, 0x9f, 0xdb, 0x9b, 0xf5, 0xa2, 0x7b, - 0x07, 0x06, 0x2c, 0x0d, 0x92, 0x69, 0xfe, 0x9e, 0x37, 0xb0, 0xc4, 0x59, 0x46, 0x70, 0x1e, 0x41, - 0x09, 0x6e, 0x6e, 0x46, 0x34, 0x10, 0x7d, 0x00, 0xcd, 0x4c, 0xd1, 0xae, 0xcf, 0x3d, 0xfd, 0x60, - 0x2e, 0xbd, 0xa2, 0x77, 0x1d, 0x1d, 0x97, 0xce, 0x82, 0xd0, 0x53, 0xbd, 0x78, 0x28, 0xe6, 0xdf, - 0x7c, 0x28, 0xe8, 0x34, 0x98, 0x82, 0x06, 0xaa, 0x74, 0x8b, 0x4e, 0xb6, 0x9c, 0x39, 0xa2, 0x86, - 0x37, 0x1f, 0xef, 0x77, 0x8d, 0x27, 0xfb, 0x5d, 0xe3, 0xe9, 0x7e, 0xd7, 0x78, 0x70, 0xd0, 0xad, - 0x3c, 0x39, 0xe8, 0x56, 0x7e, 0x39, 0xe8, 0x56, 0xee, 0x5d, 0x3e, 0xbe, 0x20, 0xb6, 0x9c, 0x8e, - 0x1a, 0xaa, 0x91, 0x5d, 0xff, 0x33, 0x00, 0x00, 0xff, 0xff, 0x6d, 0xc2, 0x59, 0x2a, 0x91, 0x0a, - 0x00, 0x00, + // 1147 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xc4, 0x56, 0x4f, 0x8f, 0xdb, 0x44, + 0x14, 0x8f, 0xe3, 0x24, 0x9b, 0xbc, 0xee, 0xb6, 0xbb, 0x43, 0x8b, 0xb2, 0x29, 0xcd, 0x2e, 0xa9, + 0x0a, 0x51, 0xc5, 0xda, 0xed, 0x16, 0x41, 0xa9, 0x10, 0x25, 0x69, 0xa9, 0x5a, 0x95, 0x82, 0xf0, + 0xee, 0xa9, 0x17, 0x6b, 0x62, 0xcf, 0x3a, 0xa3, 0xc6, 0x33, 0xc6, 0x33, 0x86, 0xf8, 0xc8, 0x05, + 0x4e, 0x48, 0x15, 0x17, 0x24, 0x3e, 0x01, 0xe2, 0xd4, 0x43, 0x25, 0xbe, 0x42, 0xb9, 0x55, 0x3d, + 0x21, 0x0e, 0x6d, 0xd5, 0x3d, 0xf4, 0x63, 0x80, 0x3c, 0x1e, 0x7b, 0xb7, 0xdd, 0x34, 0x0b, 0x02, + 0x89, 0x4b, 0xe4, 0x79, 0xf3, 0x7b, 0x6f, 0x7e, 0xef, 0x7f, 0xa0, 0xe3, 0x71, 0x11, 0x72, 0x61, + 0xcb, 0xa9, 0xfd, 0xd5, 0xf9, 0x11, 0x91, 0xf8, 0xbc, 0x2d, 0xa7, 0x56, 0x14, 0x73, 0xc9, 0xd1, + 0x4a, 0x7e, 0x67, 0xc9, 0xa9, 0xa5, 0xef, 0x3a, 0xab, 0xb9, 0xc8, 0x55, 0x00, 0x5b, 0xdf, 0xab, + 0x43, 0x67, 0x05, 0x87, 0x94, 0x71, 0x5b, 0xfd, 0x6a, 0xd1, 0xf1, 0x80, 0x07, 0x3c, 0x87, 0x66, + 0x5f, 0x5a, 0xba, 0xa1, 0x9f, 0xf4, 0xe2, 0x34, 0x92, 0xdc, 0x0e, 0x93, 0x89, 0xa4, 0x82, 0x06, + 0xe5, 0xfb, 0x85, 0x40, 0xc3, 0xbb, 0x1a, 0x3e, 0xc2, 0x82, 0x94, 0x18, 0x8f, 0x53, 0xa6, 0xef, + 0xdf, 0xde, 0xf3, 0x40, 0xd0, 0x80, 0x51, 0xb6, 0x67, 0x49, 0x9f, 0x35, 0x70, 0x35, 0xe0, 0x3c, + 0x98, 0x10, 0x5b, 0x9d, 0x46, 0xc9, 0x8e, 0x8d, 0x59, 0xaa, 0xaf, 0xd6, 0x5e, 0xbe, 0x92, 0x34, + 0x24, 0x42, 0xe2, 0x30, 0xca, 0x01, 0xbd, 0xef, 0x0d, 0xa8, 0x6e, 0x4f, 0xd1, 0x06, 0xd4, 0x46, + 0xdc, 0x4f, 0xdb, 0xc6, 0xba, 0xd1, 0x3f, 0xb2, 0xb9, 0x6a, 0x1d, 0x08, 0x90, 0xb5, 0x3d, 0x1d, + 0x72, 0x3f, 0x75, 0x14, 0x0c, 0x5d, 0x84, 0x16, 0x4e, 0xe4, 0xd8, 0xa5, 0x6c, 0x87, 0xb7, 0xab, + 0x4a, 0xe7, 0xe4, 0x0c, 0x9d, 0x41, 0x22, 0xc7, 0x37, 0xd8, 0x0e, 0x77, 0x9a, 0x58, 0x7f, 0xa1, + 0x2e, 0x40, 0x46, 0x1e, 0xcb, 0x24, 0x26, 0xa2, 0x6d, 0xae, 0x9b, 0xfd, 0x45, 0x67, 0x9f, 0xa4, + 0xc7, 0xa0, 0xbe, 0x3d, 0x75, 0xf0, 0xd7, 0xe8, 0x14, 0x40, 0xf6, 0x94, 0x3b, 0x4a, 0x25, 0x11, + 0x8a, 0xd7, 0xa2, 0xd3, 0xca, 0x24, 0xc3, 0x4c, 0x80, 0xde, 0x82, 0x63, 0x25, 0x03, 0x8d, 0xa9, + 0x2a, 0xcc, 0x52, 0xf1, 0x54, 0x8e, 0x3b, 0xec, 0xbd, 0x1f, 0x0c, 0x58, 0xd8, 0xa2, 0x01, 0xbb, + 0xca, 0xbd, 0xff, 0xea, 0xc9, 0x55, 0x68, 0x7a, 0x63, 0x4c, 0x99, 0x4b, 0xfd, 0xb6, 0xb9, 0x6e, + 0xf4, 0x5b, 0xce, 0x82, 0x3a, 0xdf, 0xf0, 0xd1, 0x19, 0x38, 0x8a, 0x3d, 0x8f, 0x27, 0x4c, 0xba, + 0x2c, 0x09, 0x47, 0x24, 0x6e, 0xd7, 0xd6, 0x8d, 0x7e, 0xcd, 0x59, 0xd2, 0xd2, 0xcf, 0x94, 0xb0, + 0xf7, 0x5d, 0x15, 0x96, 0x35, 0xa9, 0xab, 0x34, 0x26, 0x9e, 0x1c, 0x24, 0xd3, 0xc3, 0xd8, 0x5d, + 0x00, 0x88, 0x92, 0xd1, 0x84, 0x7a, 0xee, 0x1d, 0x92, 0xea, 0x9c, 0x1c, 0xb7, 0xf2, 0xf4, 0x5b, + 0x45, 0xfa, 0xad, 0x01, 0x4b, 0x9d, 0x56, 0x8e, 0xbb, 0x49, 0xd2, 0x7f, 0x4f, 0x15, 0x75, 0xa0, + 0x29, 0xc8, 0x97, 0x09, 0x61, 0x1e, 0x69, 0xd7, 0x15, 0xa0, 0x3c, 0xa3, 0x77, 0xc0, 0x94, 0x34, + 0x6a, 0x37, 0x14, 0x97, 0xd7, 0x67, 0xd5, 0x14, 0x8d, 0x86, 0xd5, 0xb6, 0xe1, 0x64, 0xb0, 0x4b, + 0xaf, 0x3d, 0xba, 0xbf, 0x71, 0x2c, 0xc7, 0x6c, 0x08, 0xff, 0xce, 0xfa, 0x39, 0xeb, 0xdd, 0xf7, + 0x7a, 0xdf, 0x9a, 0xd0, 0xc8, 0x2b, 0x0f, 0x9d, 0x83, 0x66, 0x48, 0x84, 0xc0, 0x81, 0xf2, 0xde, + 0x7c, 0xa5, 0x7b, 0x25, 0x0a, 0x21, 0xa8, 0x85, 0x24, 0xcc, 0x0b, 0xb4, 0xe5, 0xa8, 0xef, 0xcc, + 0xad, 0xac, 0x05, 0x78, 0x22, 0xdd, 0x31, 0xa1, 0xc1, 0x58, 0x2a, 0xbf, 0x6b, 0xce, 0x92, 0x96, + 0x5e, 0x57, 0x42, 0xf4, 0x06, 0xb4, 0x12, 0xc6, 0x63, 0x9f, 0xc4, 0xc4, 0x57, 0x8e, 0x37, 0x9d, + 0x3d, 0x01, 0xfa, 0x02, 0x56, 0x0a, 0x23, 0x65, 0x3f, 0x29, 0xef, 0x8f, 0x6c, 0x76, 0x0e, 0x70, + 0xda, 0x2e, 0x10, 0xc3, 0xe6, 0x83, 0xc7, 0x6b, 0xc6, 0xdd, 0x27, 0x6b, 0x86, 0xb3, 0xac, 0xd5, + 0xcb, 0x3b, 0x34, 0x84, 0x15, 0x32, 0x95, 0x84, 0x09, 0xca, 0x99, 0xcb, 0x23, 0x49, 0x39, 0x13, + 0xed, 0x3f, 0x17, 0xe6, 0xf8, 0xb9, 0x5c, 0xe2, 0x3f, 0xcf, 0xe1, 0xe8, 0x36, 0x74, 0x19, 0x67, + 0xae, 0x17, 0x53, 0x49, 0x3d, 0x3c, 0x71, 0x67, 0x18, 0x3c, 0x36, 0xc7, 0xe0, 0x49, 0xc6, 0xd9, + 0x15, 0xad, 0xfb, 0xc9, 0x4b, 0xb6, 0x7b, 0xbf, 0x1a, 0xd0, 0x2c, 0xda, 0x19, 0x7d, 0x0c, 0x8b, + 0x59, 0x0b, 0x91, 0x58, 0xf5, 0x42, 0x91, 0x8e, 0x53, 0x33, 0x32, 0xbc, 0xa5, 0x60, 0x6a, 0x06, + 0x1c, 0x11, 0xe5, 0xb7, 0x40, 0x7d, 0x30, 0x77, 0x08, 0xd1, 0x65, 0x3a, 0xab, 0x34, 0xae, 0x11, + 0xe2, 0x64, 0x10, 0x74, 0x39, 0x2f, 0x22, 0x73, 0x6e, 0x11, 0x9d, 0xf8, 0xe3, 0x60, 0xed, 0xe8, + 0xba, 0xea, 0xfd, 0x68, 0x00, 0xec, 0xd1, 0x78, 0xa9, 0x4f, 0x8c, 0xbf, 0xd7, 0x27, 0x17, 0xa1, + 0x15, 0x72, 0x9f, 0x1c, 0x36, 0xef, 0x6e, 0x71, 0x9f, 0xe4, 0xf3, 0x2e, 0xd4, 0x5f, 0x2f, 0xf4, + 0x87, 0xf9, 0x62, 0x7f, 0xf4, 0x9e, 0x56, 0xa1, 0x59, 0xa8, 0xa0, 0x0f, 0xa1, 0x21, 0x28, 0x0b, + 0x26, 0x44, 0x73, 0xea, 0xcd, 0xb1, 0x6f, 0x6d, 0x29, 0xe4, 0xf5, 0x8a, 0xa3, 0x75, 0xd0, 0x07, + 0x50, 0x57, 0xdb, 0x45, 0x93, 0x7b, 0x73, 0x9e, 0xf2, 0xad, 0x0c, 0x78, 0xbd, 0xe2, 0xe4, 0x1a, + 0x9d, 0x01, 0x34, 0x72, 0x73, 0xe8, 0x7d, 0xa8, 0x65, 0xbc, 0x15, 0x81, 0xa3, 0x9b, 0xa7, 0xf7, + 0xd9, 0x28, 0xf6, 0xcd, 0xfe, 0xb4, 0x66, 0xf6, 0x1c, 0xa5, 0xd0, 0xb9, 0x6b, 0x40, 0x5d, 0x59, + 0x45, 0x37, 0xa1, 0x39, 0xa2, 0x12, 0xc7, 0x31, 0x2e, 0x62, 0x6b, 0x17, 0x66, 0xf2, 0xad, 0x68, + 0x95, 0x4b, 0xb0, 0xb0, 0x75, 0x85, 0x87, 0x11, 0xf6, 0xe4, 0x90, 0xca, 0x41, 0xa6, 0xe6, 0x94, + 0x06, 0xd0, 0x25, 0x80, 0x32, 0xea, 0xd9, 0xac, 0x35, 0x0f, 0x0b, 0x7b, 0xab, 0x08, 0xbb, 0x18, + 0xd6, 0xc1, 0x14, 0x49, 0xd8, 0xfb, 0xa6, 0x0a, 0xe6, 0x35, 0x42, 0x50, 0x0a, 0x0d, 0x1c, 0x66, + 0x63, 0x4b, 0xd7, 0x6a, 0xb9, 0xe1, 0xb2, 0xe5, 0xbb, 0x8f, 0x0a, 0x65, 0xc3, 0x6b, 0x0f, 0x1e, + 0xaf, 0x55, 0x7e, 0x79, 0xb2, 0xd6, 0x0f, 0xa8, 0x1c, 0x27, 0x23, 0xcb, 0xe3, 0xa1, 0x5d, 0x2c, + 0xf6, 0xb2, 0xc2, 0x6c, 0x99, 0x46, 0x44, 0x28, 0x05, 0xf1, 0xd3, 0xf3, 0x7b, 0x67, 0x17, 0x27, + 0x24, 0xc0, 0x5e, 0xea, 0x66, 0xeb, 0x5b, 0xfc, 0xfc, 0xfc, 0xde, 0x59, 0xc3, 0xd1, 0x0f, 0xa2, + 0x93, 0xd0, 0x0a, 0xb0, 0x70, 0x27, 0x34, 0xa4, 0x52, 0xa5, 0xa7, 0xe6, 0x34, 0x03, 0x2c, 0x3e, + 0xcd, 0xce, 0xc8, 0x82, 0x7a, 0x84, 0x53, 0x12, 0xe7, 0xd3, 0x77, 0xd8, 0x7e, 0x74, 0x7f, 0xe3, + 0xb8, 0x66, 0x36, 0xf0, 0xfd, 0x98, 0x08, 0xb1, 0x25, 0x63, 0xca, 0x02, 0x27, 0x87, 0xa1, 0x4d, + 0x58, 0x08, 0x62, 0xcc, 0xa4, 0x1e, 0xc7, 0xf3, 0x34, 0x0a, 0x60, 0xef, 0x37, 0x03, 0xcc, 0x6d, + 0x1a, 0xfd, 0x9f, 0x31, 0x38, 0x07, 0x0d, 0x49, 0xa3, 0x88, 0xc4, 0xf9, 0x2c, 0x9e, 0xc3, 0x5a, + 0xe3, 0x2e, 0x9d, 0x78, 0x34, 0xab, 0xa3, 0x7b, 0xbb, 0x06, 0x2c, 0x0d, 0x92, 0x69, 0xde, 0xcf, + 0x57, 0xb1, 0xc4, 0x59, 0x44, 0x70, 0x6e, 0x41, 0x15, 0xdc, 0xdc, 0x88, 0x68, 0x20, 0xfa, 0x08, + 0x9a, 0x59, 0x45, 0xbb, 0x3e, 0xf7, 0x74, 0xc3, 0x9c, 0x7e, 0xc5, 0xec, 0xda, 0xbf, 0x81, 0x9d, + 0x05, 0xa1, 0xff, 0x28, 0x14, 0x8d, 0x62, 0xfe, 0xc3, 0x46, 0x41, 0xcb, 0x60, 0x0a, 0x1a, 0xa8, + 0xd4, 0x2d, 0x3a, 0xd9, 0xe7, 0xcc, 0xad, 0x37, 0xbc, 0xfc, 0xe0, 0x59, 0xd7, 0x78, 0xf8, 0xac, + 0x6b, 0x3c, 0x7d, 0xd6, 0x35, 0xee, 0xee, 0x76, 0x2b, 0x0f, 0x77, 0xbb, 0x95, 0xdf, 0x77, 0xbb, + 0x95, 0xdb, 0x67, 0x0e, 0x4f, 0x88, 0x2d, 0xa7, 0xa3, 0x86, 0x1a, 0x64, 0x17, 0xfe, 0x0a, 0x00, + 0x00, 0xff, 0xff, 0x72, 0x63, 0x4f, 0x0e, 0x05, 0x0b, 0x00, 0x00, } func (m *Tx) Marshal() (dAtA []byte, err error) { @@ -1383,6 +1399,16 @@ func (m *TxBody) MarshalToSizedBuffer(dAtA []byte) (int, error) { dAtA[i] = 0xfa } } + if m.TimeoutTimestamp != nil { + n5, err5 := github_com_cosmos_gogoproto_types.StdTimeMarshalTo(*m.TimeoutTimestamp, dAtA[i-github_com_cosmos_gogoproto_types.SizeOfStdTime(*m.TimeoutTimestamp):]) + if err5 != nil { + return 0, err5 + } + i -= n5 + i = encodeVarintTx(dAtA, i, uint64(n5)) + i-- + dAtA[i] = 0x2a + } if m.Unordered { i-- if m.Unordered { @@ -1974,6 +2000,10 @@ func (m *TxBody) Size() (n int) { if m.Unordered { n += 2 } + if m.TimeoutTimestamp != nil { + l = github_com_cosmos_gogoproto_types.SizeOfStdTime(*m.TimeoutTimestamp) + n += 1 + l + sovTx(uint64(l)) + } if len(m.ExtensionOptions) > 0 { for _, e := range m.ExtensionOptions { l = e.Size() @@ -3007,6 +3037,42 @@ func (m *TxBody) Unmarshal(dAtA []byte) error { } } m.Unordered = bool(v != 0) + case 5: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field TimeoutTimestamp", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.TimeoutTimestamp == nil { + m.TimeoutTimestamp = new(time.Time) + } + if err := github_com_cosmos_gogoproto_types.StdTimeUnmarshal(m.TimeoutTimestamp, dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex case 1023: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field ExtensionOptions", wireType) diff --git a/types/tx/types.go b/types/tx/types.go index b2726c60abf2..b8a61946538c 100644 --- a/types/tx/types.go +++ b/types/tx/types.go @@ -3,13 +3,13 @@ package tx import ( "errors" + gogoprotoany "github.com/cosmos/gogoproto/types/any" "google.golang.org/protobuf/reflect/protoreflect" "cosmossdk.io/core/registry" errorsmod "cosmossdk.io/errors" "github.com/cosmos/cosmos-sdk/codec" - codectypes "github.com/cosmos/cosmos-sdk/codec/types" cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types" sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" @@ -20,7 +20,7 @@ const MaxGasWanted = uint64((1 << 63) - 1) // Interface implementation checks. var ( - _, _, _, _ codectypes.UnpackInterfacesMessage = &Tx{}, &TxBody{}, &AuthInfo{}, &SignerInfo{} + _, _, _, _ gogoprotoany.UnpackInterfacesMessage = &Tx{}, &TxBody{}, &AuthInfo{}, &SignerInfo{} ) // GetMsgs implements the GetMsgs method on sdk.Tx. @@ -177,7 +177,7 @@ func (t *Tx) FeeGranter(cdc codec.Codec) []byte { } // UnpackInterfaces implements the UnpackInterfaceMessages.UnpackInterfaces method -func (t *Tx) UnpackInterfaces(unpacker codectypes.AnyUnpacker) error { +func (t *Tx) UnpackInterfaces(unpacker gogoprotoany.AnyUnpacker) error { if t.Body != nil { if err := t.Body.UnpackInterfaces(unpacker); err != nil { return err @@ -192,7 +192,7 @@ func (t *Tx) UnpackInterfaces(unpacker codectypes.AnyUnpacker) error { } // UnpackInterfaces implements the UnpackInterfaceMessages.UnpackInterfaces method -func (m *TxBody) UnpackInterfaces(unpacker codectypes.AnyUnpacker) error { +func (m *TxBody) UnpackInterfaces(unpacker gogoprotoany.AnyUnpacker) error { if err := UnpackInterfaces(unpacker, m.Messages); err != nil { return err } @@ -209,7 +209,7 @@ func (m *TxBody) UnpackInterfaces(unpacker codectypes.AnyUnpacker) error { } // UnpackInterfaces implements the UnpackInterfaceMessages.UnpackInterfaces method -func (m *AuthInfo) UnpackInterfaces(unpacker codectypes.AnyUnpacker) error { +func (m *AuthInfo) UnpackInterfaces(unpacker gogoprotoany.AnyUnpacker) error { for _, signerInfo := range m.SignerInfos { err := signerInfo.UnpackInterfaces(unpacker) if err != nil { @@ -220,7 +220,7 @@ func (m *AuthInfo) UnpackInterfaces(unpacker codectypes.AnyUnpacker) error { } // UnpackInterfaces implements the UnpackInterfaceMessages.UnpackInterfaces method -func (m *SignerInfo) UnpackInterfaces(unpacker codectypes.AnyUnpacker) error { +func (m *SignerInfo) UnpackInterfaces(unpacker gogoprotoany.AnyUnpacker) error { return unpacker.UnpackAny(m.PublicKey, new(cryptotypes.PubKey)) } diff --git a/types/tx_msg.go b/types/tx_msg.go index 4c0c4042f598..22e785e898e1 100644 --- a/types/tx_msg.go +++ b/types/tx_msg.go @@ -4,6 +4,7 @@ import ( "encoding/json" "fmt" "strings" + "time" "google.golang.org/protobuf/reflect/protoreflect" @@ -79,6 +80,14 @@ type ( GetMemo() string } + // TxWithTimeoutTimeStamp extends the Tx interface by allowing a transaction to + // set a timeout timestamp. + TxWithTimeoutTimeStamp interface { + Tx + + GetTimeoutTimeStamp() time.Time + } + // TxWithTimeoutHeight extends the Tx interface by allowing a transaction to // set a height timeout. TxWithTimeoutHeight interface { @@ -88,9 +97,9 @@ type ( } // TxWithUnordered extends the Tx interface by allowing a transaction to set - // the unordered field, which implicitly relies on TxWithTimeoutHeight. + // the unordered field, which implicitly relies on TxWithTimeoutTimeStamp. TxWithUnordered interface { - TxWithTimeoutHeight + TxWithTimeoutTimeStamp GetUnordered() bool } diff --git a/types/tx_msg_test.go b/types/tx_msg_test.go index 31ca01f5df6e..13c795c7ba9a 100644 --- a/types/tx_msg_test.go +++ b/types/tx_msg_test.go @@ -6,6 +6,8 @@ import ( "github.com/stretchr/testify/suite" "google.golang.org/protobuf/types/known/anypb" + "cosmossdk.io/math" + "github.com/cosmos/cosmos-sdk/codec" "github.com/cosmos/cosmos-sdk/testutil/testdata" sdk "github.com/cosmos/cosmos-sdk/types" @@ -35,7 +37,8 @@ func (s *testMsgSuite) TestMsgTypeURL() { } func (s *testMsgSuite) TestGetMsgFromTypeURL() { - msg := new(testdata.TestMsg) + msg := testdata.NewTestMsg() + msg.DecField = math.LegacyZeroDec() cdc := codec.NewProtoCodec(testdata.NewTestInterfaceRegistry()) result, err := sdk.GetMsgFromTypeURL(cdc, "/testpb.TestMsg") diff --git a/x/accounts/defaults/lockup/continuous_locking_account_test.go b/x/accounts/defaults/lockup/continuous_locking_account_test.go index dd208b26be74..cbccbb224ec5 100644 --- a/x/accounts/defaults/lockup/continuous_locking_account_test.go +++ b/x/accounts/defaults/lockup/continuous_locking_account_test.go @@ -19,7 +19,7 @@ import ( func setupContinousAccount(t *testing.T, ctx context.Context, ss store.KVStoreService) *ContinuousLockingAccount { t.Helper() deps := makeMockDependencies(ss) - owner := "owner" + owner := "owner" //nolint:goconst // adding constants for this would impede readability acc, err := NewContinuousLockingAccount(deps) require.NoError(t, err) diff --git a/x/accounts/defaults/lockup/go.mod b/x/accounts/defaults/lockup/go.mod index d778d3689424..35267bb203ef 100644 --- a/x/accounts/defaults/lockup/go.mod +++ b/x/accounts/defaults/lockup/go.mod @@ -9,7 +9,7 @@ require ( cosmossdk.io/x/bank v0.0.0-20240226161501-23359a0b6d91 cosmossdk.io/x/distribution v0.0.0-00010101000000-000000000000 cosmossdk.io/x/staking v0.0.0-00010101000000-000000000000 - github.com/cosmos/cosmos-sdk v0.51.0 + github.com/cosmos/cosmos-sdk v0.53.0 github.com/cosmos/gogoproto v1.5.0 ) @@ -18,8 +18,7 @@ require cosmossdk.io/x/consensus v0.0.0-00010101000000-000000000000 // indirect require ( buf.build/gen/go/cometbft/cometbft/protocolbuffers/go v1.34.2-20240701160653-fedbb9acfd2f.2 // indirect cosmossdk.io/core/testing v0.0.0-00010101000000-000000000000 // indirect - cosmossdk.io/depinject v1.0.0-alpha.4 // indirect - cosmossdk.io/schema v0.1.1 // indirect + cosmossdk.io/depinject v1.0.0 // indirect github.com/cometbft/cometbft/api v1.0.0-rc.1 // indirect github.com/cosmos/crypto v0.1.2 // indirect github.com/dgraph-io/badger/v4 v4.2.0 // indirect @@ -42,9 +41,7 @@ require ( 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 - github.com/DataDog/datadog-go v4.8.3+incompatible // indirect github.com/DataDog/zstd v1.5.5 // indirect - github.com/Microsoft/go-winio v0.6.1 // indirect github.com/beorn7/perks v1.0.1 // indirect github.com/bgentry/speakeasy v0.2.0 // indirect github.com/btcsuite/btcd/btcec/v2 v2.3.3 // indirect @@ -60,8 +57,7 @@ require ( github.com/cosmos/cosmos-db v1.0.2 // indirect github.com/cosmos/cosmos-proto v1.0.0-beta.5 github.com/cosmos/go-bip39 v1.0.0 // indirect - github.com/cosmos/gogogateway v1.2.0 // indirect - github.com/cosmos/iavl v1.2.0 // indirect + github.com/cosmos/iavl v1.2.1-0.20240725141113-7adc688cf179 // indirect github.com/cosmos/ics23/go v0.10.0 // indirect github.com/cosmos/ledger-cosmos-go v0.13.3 // indirect github.com/danieljoos/wincred v1.2.1 // indirect @@ -71,36 +67,26 @@ require ( github.com/dustin/go-humanize v1.0.1 // indirect github.com/dvsekhvalnov/jose2go v1.6.0 // indirect github.com/emicklei/dot v1.6.2 // indirect - github.com/fatih/color v1.17.0 // indirect - github.com/felixge/httpsnoop v1.0.4 // indirect github.com/fsnotify/fsnotify v1.7.0 // indirect github.com/getsentry/sentry-go v0.27.0 // indirect github.com/go-kit/kit v0.13.0 // indirect github.com/go-kit/log v0.2.1 // indirect github.com/go-logfmt/logfmt v0.6.0 // indirect github.com/godbus/dbus v0.0.0-20190726142602-4481cbc300e2 // indirect - github.com/gogo/googleapis v1.4.1 // indirect github.com/gogo/protobuf v1.3.2 // indirect github.com/golang/glog v1.2.0 // indirect github.com/golang/protobuf v1.5.4 github.com/golang/snappy v0.0.4 // indirect github.com/google/btree v1.1.2 // indirect github.com/google/go-cmp v0.6.0 // indirect - github.com/gorilla/handlers v1.5.2 // indirect - github.com/gorilla/mux v1.8.1 // indirect github.com/gorilla/websocket v1.5.3 // indirect - github.com/grpc-ecosystem/go-grpc-middleware v1.4.0 // indirect github.com/grpc-ecosystem/grpc-gateway v1.16.0 // indirect github.com/gsterjov/go-libsecret v0.0.0-20161001094733-a6f4afe4910c // indirect - github.com/hashicorp/go-hclog v1.6.3 // indirect github.com/hashicorp/go-immutable-radix v1.3.1 // indirect github.com/hashicorp/go-metrics v0.5.3 // indirect - github.com/hashicorp/go-plugin v1.6.1 // indirect github.com/hashicorp/golang-lru v1.0.2 // indirect github.com/hashicorp/hcl v1.0.0 // indirect - github.com/hashicorp/yamux v0.1.1 // indirect github.com/hdevalence/ed25519consensus v0.2.0 // indirect - github.com/huandu/skiplist v1.2.0 // indirect github.com/iancoleman/strcase v0.3.0 // indirect github.com/inconshreveable/mousetrap v1.1.0 // indirect github.com/jmhodges/levigo v1.0.0 // indirect @@ -112,11 +98,9 @@ require ( github.com/magiconair/properties v1.8.7 // indirect github.com/mattn/go-colorable v0.1.13 // indirect github.com/mattn/go-isatty v0.0.20 // indirect - github.com/mitchellh/go-testing-interface v1.14.1 // indirect github.com/mitchellh/mapstructure v1.5.0 // indirect github.com/mtibben/percent v0.2.1 // indirect github.com/oasisprotocol/curve25519-voi v0.0.0-20230904125328-1f23a7beb09a // indirect - github.com/oklog/run v1.1.0 // indirect github.com/pelletier/go-toml/v2 v2.2.2 // indirect github.com/petermattis/goid v0.0.0-20240327183114-c42a807a84ba // indirect github.com/pkg/errors v0.9.1 // indirect @@ -150,13 +134,11 @@ require ( go.uber.org/multierr v1.11.0 // indirect golang.org/x/crypto v0.25.0 // indirect golang.org/x/exp v0.0.0-20240531132922-fd00a4e0eefc // indirect - golang.org/x/mod v0.17.0 // indirect golang.org/x/net v0.27.0 // indirect golang.org/x/sync v0.7.0 // indirect golang.org/x/sys v0.22.0 // indirect golang.org/x/term v0.22.0 // indirect golang.org/x/text v0.16.0 // indirect - golang.org/x/tools v0.21.1-0.20240508182429-e35e4ccd0d2d // indirect google.golang.org/genproto v0.0.0-20240227224415-6ceb2ff114de // indirect google.golang.org/genproto/googleapis/api v0.0.0-20240318140521-94a12d6c2237 // indirect google.golang.org/genproto/googleapis/rpc v0.0.0-20240709173604-40e1e62336c5 // indirect @@ -176,8 +158,6 @@ replace ( cosmossdk.io/collections => ../../../../collections // TODO tag new collections ASAP cosmossdk.io/core => ../../../../core cosmossdk.io/core/testing => ../../../../core/testing - cosmossdk.io/depinject => ../../../../depinject - cosmossdk.io/log => ../../../../log cosmossdk.io/x/accounts => ../../. cosmossdk.io/x/auth => ../../../auth cosmossdk.io/x/bank => ../../../bank diff --git a/x/accounts/defaults/lockup/go.sum b/x/accounts/defaults/lockup/go.sum index 6a551cec1660..50f921c26d80 100644 --- a/x/accounts/defaults/lockup/go.sum +++ b/x/accounts/defaults/lockup/go.sum @@ -4,8 +4,12 @@ buf.build/gen/go/cosmos/gogo-proto/protocolbuffers/go v1.34.2-20240130113600-88e buf.build/gen/go/cosmos/gogo-proto/protocolbuffers/go v1.34.2-20240130113600-88ef6483f90f.2/go.mod h1:HqcXMSa5qnNuakaMUo+hWhF51mKbcrZxGl9Vp5EeJXc= cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= cloud.google.com/go v0.34.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= +cosmossdk.io/depinject v1.0.0 h1:dQaTu6+O6askNXO06+jyeUAnF2/ssKwrrszP9t5q050= +cosmossdk.io/depinject v1.0.0/go.mod h1:zxK/h3HgHoA/eJVtiSsoaRaRA2D5U4cJ5thIG4ssbB8= cosmossdk.io/errors v1.0.1 h1:bzu+Kcr0kS/1DuPBtUFdWjzLqyUuCiyHjyJB6srBV/0= cosmossdk.io/errors v1.0.1/go.mod h1:MeelVSZThMi4bEakzhhhE/CKqVv3nOJDA25bIqRDu/U= +cosmossdk.io/log v1.3.1 h1:UZx8nWIkfbbNEWusZqzAx3ZGvu54TZacWib3EzUYmGI= +cosmossdk.io/log v1.3.1/go.mod h1:2/dIomt8mKdk6vl3OWJcPk2be3pGOS8OQaLUM/3/tCM= cosmossdk.io/math v1.3.0 h1:RC+jryuKeytIiictDslBP9i1fhkVm6ZDmZEoNP316zE= cosmossdk.io/math v1.3.0/go.mod h1:vnRTxewy+M7BtXBNFybkuhSH4WfedVAAnERHgVFhp3k= cosmossdk.io/schema v0.1.1 h1:I0M6pgI7R10nq+/HCQfbO6BsGBZA8sQy+duR1Y3aKcA= @@ -35,7 +39,6 @@ github.com/alecthomas/template v0.0.0-20190718012654-fb15b899a751/go.mod h1:LOuy github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0= github.com/alecthomas/units v0.0.0-20190717042225-c3de453c63f4/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0= github.com/antihax/optional v1.0.0/go.mod h1:uupD/76wgC+ih3iEmQUL+0Ugr19nfwCT1kdvxnR2qWY= -github.com/benbjohnson/clock v1.1.0/go.mod h1:J11/hYXuz8f4ySSvYwY0FKfm+ezbsZBKZxNJlLklBHA= github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q= github.com/beorn7/perks v1.0.0/go.mod h1:KWe93zE9D1o94FZ5RNwFwVgaQK1VOXiVxmqh+CedLV8= github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM= @@ -48,8 +51,6 @@ github.com/btcsuite/btcd/btcutil v1.1.5 h1:+wER79R5670vs/ZusMTF1yTcRYE5GUsFbdjdi github.com/btcsuite/btcd/btcutil v1.1.5/go.mod h1:PSZZ4UitpLBWzxGd5VGOrLnmOjtPP/a6HaFo12zMs00= github.com/btcsuite/btcd/chaincfg/chainhash v1.0.1 h1:q0rUy8C/TYNBQS1+CGKw68tLOFYSNEs0TFnxxnS9+4U= github.com/btcsuite/btcd/chaincfg/chainhash v1.0.1/go.mod h1:7SFka0XMvUgj3hfZtydOrQY2mwhPclbT2snogU7SQQc= -github.com/bufbuild/protocompile v0.4.0 h1:LbFKd2XowZvQ/kajzguUp2DC9UEIQhIq77fZZlaQsNA= -github.com/bufbuild/protocompile v0.4.0/go.mod h1:3v93+mbWn/v3xzN+31nwkJfrEpAUwp+BagBSZWx+TP8= github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU= github.com/cespare/xxhash/v2 v2.1.1/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= github.com/cespare/xxhash/v2 v2.3.0 h1:UL815xU9SqsFlibzuggzjXhog7bL6oX9BbNZnL2UFvs= @@ -61,12 +62,6 @@ github.com/circonus-labs/circonus-gometrics v2.3.1+incompatible/go.mod h1:nmEj6D github.com/circonus-labs/circonusllhist v0.1.3/go.mod h1:kMXHVDlOchFAehlya5ePtbp5jckzBHf4XRpQvBOLI+I= github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw= github.com/cncf/udpa/go v0.0.0-20191209042840-269d4d468f6f/go.mod h1:M8M6+tZqaGXZJjfX53e64911xZQV5JYwmTeXPW+k8Sc= -github.com/cncf/udpa/go v0.0.0-20201120205902-5459f2c99403/go.mod h1:WmhPx2Nbnhtbo57+VJT5O0JRkEi1Wbu0z5j0R8u5Hbk= -github.com/cncf/udpa/go v0.0.0-20210930031921-04548b0d99d4/go.mod h1:6pvJx4me5XPnfI9Z40ddWsdw2W/uZgQLFXToKeRcDiI= -github.com/cncf/xds/go v0.0.0-20210805033703-aa0b78936158/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs= -github.com/cncf/xds/go v0.0.0-20210922020428-25de7278fc84/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs= -github.com/cncf/xds/go v0.0.0-20211001041855-01bcc9b48dfe/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs= -github.com/cncf/xds/go v0.0.0-20211011173535-cb28da3451f1/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs= github.com/cockroachdb/datadriven v1.0.3-0.20230413201302-be42291fc80f h1:otljaYPt5hWxV3MUfO5dFPFiOXg9CyG5/kCfayTqsJ4= github.com/cockroachdb/datadriven v1.0.3-0.20230413201302-be42291fc80f/go.mod h1:a9RdTaap04u637JoCzcUoIcDmvwSUtcUFtT/C3kJlTU= github.com/cockroachdb/errors v1.11.1 h1:xSEW75zKaKCWzR3OfxXUxgrk/NtT4G1MiOv5lWZazG8= @@ -98,11 +93,10 @@ github.com/cosmos/go-bip39 v1.0.0 h1:pcomnQdrdH22njcAatO0yWojsUnCO3y2tNoV1cb6hHY github.com/cosmos/go-bip39 v1.0.0/go.mod h1:RNJv0H/pOIVgxw6KS7QeX2a0Uo0aKUlfhZ4xuwvCdJw= github.com/cosmos/gogogateway v1.2.0 h1:Ae/OivNhp8DqBi/sh2A8a1D0y638GpL3tkmLQAiKxTE= github.com/cosmos/gogogateway v1.2.0/go.mod h1:iQpLkGWxYcnCdz5iAdLcRBSw3h7NXeOkZ4GUkT+tbFI= -github.com/cosmos/gogoproto v1.4.2/go.mod h1:cLxOsn1ljAHSV527CHOtaIP91kK6cCrZETRBrkzItWU= github.com/cosmos/gogoproto v1.5.0 h1:SDVwzEqZDDBoslaeZg+dGE55hdzHfgUA40pEanMh52o= github.com/cosmos/gogoproto v1.5.0/go.mod h1:iUM31aofn3ymidYG6bUR5ZFrk+Om8p5s754eMUcyp8I= -github.com/cosmos/iavl v1.2.0 h1:kVxTmjTh4k0Dh1VNL046v6BXqKziqMDzxo93oh3kOfM= -github.com/cosmos/iavl v1.2.0/go.mod h1:HidWWLVAtODJqFD6Hbne2Y0q3SdxByJepHUOeoH4LiI= +github.com/cosmos/iavl v1.2.1-0.20240725141113-7adc688cf179 h1:wmwDn7V3RodN9auB3FooSQxs46nHVE3u0mb87TJkZFE= +github.com/cosmos/iavl v1.2.1-0.20240725141113-7adc688cf179/go.mod h1:GiM43q0pB+uG53mLxLDzimxM9l/5N9UuSY3/D0huuVw= github.com/cosmos/ics23/go v0.10.0 h1:iXqLLgp2Lp+EdpIuwXTYIQU+AiHj9mOC2X9ab++bZDM= github.com/cosmos/ics23/go v0.10.0/go.mod h1:ZfJSmng/TBNTBkFemHHHj5YY7VAU/MBU980F4VU1NG0= github.com/cosmos/ledger-cosmos-go v0.13.3 h1:7ehuBGuyIytsXbd4MP43mLeoN2LTOEnk5nvue4rK+yM= @@ -136,11 +130,7 @@ github.com/emicklei/dot v1.6.2/go.mod h1:DeV7GvQtIw4h2u73RKBkkFdvVAz0D9fzeJrgPW6 github.com/envoyproxy/go-control-plane v0.9.0/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= github.com/envoyproxy/go-control-plane v0.9.4/go.mod h1:6rpuAdCZL397s3pYoYcLgu1mIlRU8Am5FuJP05cCM98= -github.com/envoyproxy/go-control-plane v0.9.9-0.20201210154907-fd9021fe5dad/go.mod h1:cXg6YxExXjJnVBQHBLXeUAgxn2UodCpnH306RInaBQk= -github.com/envoyproxy/go-control-plane v0.9.10-0.20210907150352-cf90f659a021/go.mod h1:AFq3mo9L8Lqqiid3OhADV3RfLJnjiw63cSpi+fDTRC0= -github.com/envoyproxy/go-control-plane v0.10.2-0.20220325020618-49ff273808a1/go.mod h1:KJwIaB5Mv44NWtYuAOFCVOjcI94vtpEz2JU/D2v6IjE= github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c= -github.com/fatih/color v1.13.0/go.mod h1:kLAiJbzzSOZDVNGyDpeOxJ47H46qBXwg5ILebYFFOfk= github.com/fatih/color v1.17.0 h1:GlRw1BRJxkpqUCBKzKOw098ed57fEsKeNjpTe3cSjK4= github.com/fatih/color v1.17.0/go.mod h1:YZ7TlrGPkiz6ku9fK3TLD/pl3CpsiFyu8N92HLgmosI= github.com/felixge/httpsnoop v1.0.4 h1:NFTV2Zj1bL4mc9sqWACXbQFVBBg2W3GPvqp8/ESS2Wg= @@ -163,12 +153,10 @@ github.com/go-kit/kit v0.8.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2 github.com/go-kit/kit v0.9.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as= github.com/go-kit/kit v0.13.0 h1:OoneCcHKHQ03LfBpoQCUfCluwd2Vt3ohz+kvbJneZAU= github.com/go-kit/kit v0.13.0/go.mod h1:phqEHMMUbyrCFCTgH48JueqrM3md2HcAZ8N3XE4FKDg= -github.com/go-kit/log v0.1.0/go.mod h1:zbhenjAZHb184qTLMA9ZjW7ThYL0H2mk7Q6pNt4vbaY= github.com/go-kit/log v0.2.1 h1:MRVx0/zhvdseW+Gza6N9rVzU/IVzaeE1SFI4raAhmBU= github.com/go-kit/log v0.2.1/go.mod h1:NwTd00d/i8cPZ3xOwwiv2PO5MOcx78fFErGNcVmBjv0= github.com/go-logfmt/logfmt v0.3.0/go.mod h1:Qt1PoO58o5twSAckw1HlFXLmHsOX5/0LbT9GBnD5lWE= github.com/go-logfmt/logfmt v0.4.0/go.mod h1:3RMwSq7FuexP4Kalkev3ejPJsZTpXXBr9+V4qmtdjCk= -github.com/go-logfmt/logfmt v0.5.0/go.mod h1:wCYkCAKZfumFQihp8CzCvQ3paCTfi41vtzG1KdI/P7A= github.com/go-logfmt/logfmt v0.6.0 h1:wGYYu3uicYdqXVgoYbvnkrPVXkuLM1p1ifugDMEdRi4= github.com/go-logfmt/logfmt v0.6.0/go.mod h1:WYhtIu8zTZfxdn5+rREduYbwxfcBr/Vr6KEVveWlfTs= github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY= @@ -178,11 +166,9 @@ github.com/godbus/dbus v0.0.0-20190726142602-4481cbc300e2/go.mod h1:bBOAhwG1umN6 github.com/godbus/dbus/v5 v5.0.4/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA= github.com/gofrs/uuid v4.4.0+incompatible h1:3qXRTX8/NbyulANqlc0lchS1gqAVxRgsuW1YrTJupqA= github.com/gofrs/uuid v4.4.0+incompatible/go.mod h1:b2aQJv3Z4Fp6yNu3cdSllBxTCLRxnplIgP/c0N/04lM= -github.com/gogo/googleapis v1.4.1-0.20201022092350-68b0159b7869/go.mod h1:5YRNX2z1oM5gXdAkurHa942MDgEJyk02w4OecKY87+c= github.com/gogo/googleapis v1.4.1 h1:1Yx4Myt7BxzvUr5ldGSbwYiZG6t9wGBZ+8/fX3Wvtq0= github.com/gogo/googleapis v1.4.1/go.mod h1:2lpHqI5OcWCtVElxXnPt+s8oJvMpySlOyM6xDCrzib4= github.com/gogo/protobuf v1.1.1/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ= -github.com/gogo/protobuf v1.3.1/go.mod h1:SlYgWuQ5SjCEi6WLHjHCa1yvBfUnHcTbrrZtXPKa29o= github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q= github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q= github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q= @@ -224,7 +210,6 @@ github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/ github.com/google/go-cmp v0.5.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.3/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= -github.com/google/go-cmp v0.5.6/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI= github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= @@ -274,8 +259,6 @@ github.com/hashicorp/yamux v0.1.1/go.mod h1:CtWFDAQgb7dxtzFs4tWbplKIe2jSi3+5vKbg github.com/hdevalence/ed25519consensus v0.2.0 h1:37ICyZqdyj0lAZ8P4D1d1id3HqbbG1N3iBb1Tb4rdcU= github.com/hdevalence/ed25519consensus v0.2.0/go.mod h1:w3BHWjwJbFU29IRHL1Iqkw3sus+7FctEyM4RqDxYNzo= github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU= -github.com/huandu/go-assert v1.1.5 h1:fjemmA7sSfYHJD7CUqs9qTwwfdNAx7/j2/ZlHXzNB3c= -github.com/huandu/go-assert v1.1.5/go.mod h1:yOLvuqZwmcHIC5rIzrBhT7D3Q9c3GFnd0JrPVhn/06U= github.com/huandu/skiplist v1.2.0 h1:gox56QD77HzSC0w+Ws3MH3iie755GBJU1OER3h5VsYw= github.com/huandu/skiplist v1.2.0/go.mod h1:7v3iFjLcSAzO4fN5B8dvebvo/qsfumiLiDXMrPiHF9w= github.com/iancoleman/strcase v0.3.0 h1:nTXanmYxhfFAMjZL34Ov6gkzEsSJZ5DbhxWjvSASxEI= @@ -283,14 +266,11 @@ github.com/iancoleman/strcase v0.3.0/go.mod h1:iwCmte+B7n89clKwxIoIXy/HfoL7AsD47 github.com/ianlancetaylor/demangle v0.0.0-20200824232613-28f6c0f3b639/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc= github.com/inconshreveable/mousetrap v1.1.0 h1:wN+x4NVGpMsO7ErUn/mUI3vEoE6Jt13X2s0bqwp9tc8= github.com/inconshreveable/mousetrap v1.1.0/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw= -github.com/jhump/protoreflect v1.15.3 h1:6SFRuqU45u9hIZPJAoZ8c28T3nK64BNdp9w6jFonzls= -github.com/jhump/protoreflect v1.15.3/go.mod h1:4ORHmSBmlCW8fh3xHmJMGyul1zNqZK4Elxc8qKP+p1k= github.com/jmhodges/levigo v1.0.0 h1:q5EC36kV79HWeTBWsod3mG11EgStG3qArTKcvlksN1U= github.com/jmhodges/levigo v1.0.0/go.mod h1:Q6Qx+uH3RAqyK4rFQroq9RL7mdkABMcfhEI+nNuzMJQ= github.com/json-iterator/go v1.1.6/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCVDaaPEHmU= github.com/json-iterator/go v1.1.9/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4= github.com/julienschmidt/httprouter v1.2.0/go.mod h1:SYymIcj16QtmaHHD7aYtjjsJG7VTCxuUUipMqKk8s4w= -github.com/kisielk/errcheck v1.2.0/go.mod h1:/BMXB+zMLi60iA8Vv6Ksmxu/1UDYcXs4uQLJ+jE2L00= github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8= github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= github.com/klauspost/compress v1.17.8 h1:YcnTYrq7MikUT7k0Yb5eceMmALQPYBW/Xltxn0NAMnU= @@ -312,12 +292,8 @@ github.com/linxGnu/grocksdb v1.8.14 h1:HTgyYalNwBSG/1qCQUIott44wU5b2Y9Kr3z7SK5Of github.com/linxGnu/grocksdb v1.8.14/go.mod h1:QYiYypR2d4v63Wj1adOOfzglnoII0gLj3PNh4fZkcFA= github.com/magiconair/properties v1.8.7 h1:IeQXZAiQcpL9mgcAe1Nu6cX9LLw6ExEHKjN0VQdvPDY= github.com/magiconair/properties v1.8.7/go.mod h1:Dhd985XPs7jluiymwWYZ0G4Z61jb3vdS329zhj2hYo0= -github.com/mattn/go-colorable v0.1.9/go.mod h1:u6P/XSegPjTcexA+o6vUJrdnUu04hMope9wVRipJSqc= -github.com/mattn/go-colorable v0.1.12/go.mod h1:u5H1YNBxpqRaxsYJYSkiCWKzEfiAb1Gb520KVy5xxl4= github.com/mattn/go-colorable v0.1.13 h1:fFA4WZxdEF4tXPZVKMLwD8oUnCTTo08duU7wxecdEvA= github.com/mattn/go-colorable v0.1.13/go.mod h1:7S9/ev0klgBDR4GtXTXX8a3vIGJpMovkB8vQcUbaXHg= -github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU= -github.com/mattn/go-isatty v0.0.14/go.mod h1:7GGIvUiUoEMVVmxf/4nioHXj79iQHKdU27kJ6hsGG94= github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM= github.com/mattn/go-isatty v0.0.19/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y= github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY= @@ -358,7 +334,6 @@ github.com/onsi/gomega v1.17.0/go.mod h1:HnhC7FXeEQY45zxNK3PPoIUhzk/80Xly9PcubAl github.com/onsi/gomega v1.19.0/go.mod h1:LY+I3pBVzYsTBU1AnDwOSxaYi9WoWiqgwooUqq9yPro= github.com/onsi/gomega v1.28.1 h1:MijcGUbfYuznzK/5R4CPNoUP/9Xvuo20sXfEm6XxoTA= github.com/onsi/gomega v1.28.1/go.mod h1:9sxs+SwGrKI0+PWe4Fxa9tFQQBG5xSsSbMXOI8PPpoQ= -github.com/opentracing/opentracing-go v1.1.0/go.mod h1:UkNAQd3GIcIGf0SeVgPpRdFStlNbqXla1AfSYxPUl2o= github.com/pascaldekloe/goe v0.1.0 h1:cBOtyMzM9HTpWjXfbbunk26uA6nG3a8n06Wieeh0MwY= github.com/pascaldekloe/goe v0.1.0/go.mod h1:lzWF7FIEvWOWxwDKqyGYQf6ZUaNfKdP144TG7ZOy1lc= github.com/pelletier/go-toml/v2 v2.2.2 h1:aYUidT7k73Pcl9nb2gScu7NSrKCSHIDE89b3+6Wq+LM= @@ -439,7 +414,6 @@ github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UV github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA= github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= -github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.7.2/go.mod h1:R6va5+xMeoiuVRoj+gSkQ7d3FALtqAAGI1FQKckRals= github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= @@ -472,13 +446,8 @@ go.etcd.io/bbolt v1.4.0-alpha.0.0.20240404170359-43604f3112c5 h1:qxen9oVGzDdIRP6 go.etcd.io/bbolt v1.4.0-alpha.0.0.20240404170359-43604f3112c5/go.mod h1:eW0HG9/oHQhvRCvb1/pIXW4cOvtDqeQK+XSi3TnwaXY= go.opencensus.io v0.24.0 h1:y73uSU6J157QMP2kn2r30vwW1A2W2WFwSCGnAVxeaD0= go.opencensus.io v0.24.0/go.mod h1:vNK8G9p7aAivkbmorf4v+7Hgx+Zs0yY+0fOtgBfjQKo= -go.opentelemetry.io/proto/otlp v0.7.0/go.mod h1:PqfVotwruBrMGOCsRd/89rSnXhoiJIqeYNgFYFoEGnI= -go.uber.org/atomic v1.7.0/go.mod h1:fEN4uk6kAWBTFdckzkM89CLk9XfWZrxpCo0nPH17wJc= -go.uber.org/goleak v1.1.10/go.mod h1:8a7PlsEVH3e/a/GLqe5IIrQx6GzcnRmZEufDUTk4A7A= -go.uber.org/multierr v1.6.0/go.mod h1:cdWPpRnG4AhwMwsgIHip0KRBQjJy5kYEpYjJxpXp9iU= go.uber.org/multierr v1.11.0 h1:blXXJkSxSSfBVBlC76pxqeO+LN3aDfLQo+309xJstO0= go.uber.org/multierr v1.11.0/go.mod h1:20+QtiLqy0Nd6FdQB9TLXag12DsQkrbs3htMFfDN80Y= -go.uber.org/zap v1.18.1/go.mod h1:xg/QME4nWcxGxrpdeYfq7UvYrLh66cuVKdrbD1XF/NI= golang.org/x/crypto v0.0.0-20180904163835-0709b304e793/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= @@ -492,7 +461,6 @@ golang.org/x/exp v0.0.0-20240531132922-fd00a4e0eefc/go.mod h1:XtvwrStGgqGPLc4cjQ golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= golang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961/go.mod h1:wehouNa3lNwaWXcvxsM5YxQ5yQlVC4a0KAMCusXpPoU= golang.org/x/lint v0.0.0-20190313153728-d0100b6bd8b3/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= -golang.org/x/lint v0.0.0-20190930215403-16217165b5de/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.17.0 h1:zY54UmvipHiNd+pm+m0x9KhZ9hl1/7QNMyxXbc6ICqA= @@ -512,7 +480,6 @@ golang.org/x/net v0.0.0-20200520004742-59133d7f0dd7/go.mod h1:qpuaurCH72eLCgpAm/ golang.org/x/net v0.0.0-20200822124328-c89045814202/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= golang.org/x/net v0.0.0-20201110031124-69a78807bb2b/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= -golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4/go.mod h1:p54w0d4576C0XHj96bSt6lcn1PtDYWL6XObtHCRCNQM= golang.org/x/net v0.0.0-20210428140749-89ef3d95e781/go.mod h1:OJAsFXCWl8Ukc7SiCT/9KSuxbyM7479/AVlXFRxuMCk= golang.org/x/net v0.0.0-20220225172249-27dd8689420f/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk= golang.org/x/net v0.0.0-20220607020251-c690dde0001d/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c= @@ -540,25 +507,15 @@ golang.org/x/sys v0.0.0-20190904154756-749cb33beabd/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20191005200804-aed5e4c7ecf9/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20191120155948-bd437916bb0e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20191204072324-ce4227a45e2e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200116001909-b77594299b42/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200122134326-e047566fdf82/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200223170610-d5e6a3e2c0ae/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210112080510-489259a85091/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20210119212857-b64e53b001e4/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20210330210617-4fbd30eecc44/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20210510120138-977fb7262007/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20210927094055-39ccf1dd6fa6/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20211025201205-69cdffdb9359/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20220315194320-039c03cc5b86/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220412211240-33da011f77ad/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20220503163025-988cb79eb6c6/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20221010170243-090e33056c14/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= @@ -572,18 +529,15 @@ golang.org/x/term v0.22.0 h1:BbsgPEJULsl2fV/AT3v15Mjva5yXKQDyKf+TbDz7QJk= golang.org/x/term v0.22.0/go.mod h1:F3qCibpT5AMpCRfhfT53vVJwhLtIVHhB9XDjfFvnMI4= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= -golang.org/x/text v0.3.5/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= golang.org/x/text v0.16.0 h1:a94ExnEXNtEwYLGJSIUxnWoxoRz/ZcCsV63ROupILh4= golang.org/x/text v0.16.0/go.mod h1:GhwF1Be+LQoKShO3cGOHzqOgRrGaYc9AvblQOmPVHnI= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= -golang.org/x/tools v0.0.0-20181030221726-6c7e314b6563/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20190226205152-f727befe758c/go.mod h1:9Yl7xja0Znq3iFh3HoIrodX9oNMXvdceNzlUR8zjMvY= golang.org/x/tools v0.0.0-20190311212946-11955173bddd/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= golang.org/x/tools v0.0.0-20190524140312-2c0ae7006135/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q= -golang.org/x/tools v0.0.0-20191108193012-7d206e10da11/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.0.0-20200619180055-7c47624df98f/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= golang.org/x/tools v0.0.0-20201224043029-2b0845dc783e/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= @@ -600,10 +554,8 @@ google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7 google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc= google.golang.org/genproto v0.0.0-20180831171423-11092d34479b/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc= google.golang.org/genproto v0.0.0-20190819201941-24fa4b261c55/go.mod h1:DMBHOl98Agz4BDEuKkezgsaosCRResVns1a3J2ZsMNc= -google.golang.org/genproto v0.0.0-20200423170343-7949de9c1215/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= google.golang.org/genproto v0.0.0-20200513103714-09dca8ec2884/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= google.golang.org/genproto v0.0.0-20200526211855-cb27e3aa2013/go.mod h1:NbSheEEYHJ7i3ixzK3sjbqSGDJWnxyFXZblF3eUsNvo= -google.golang.org/genproto v0.0.0-20220314164441-57ef72a4c106/go.mod h1:hAL49I2IFola2sVEjAn7MEwsja0xp51I0tlGAf9hz4E= google.golang.org/genproto v0.0.0-20240227224415-6ceb2ff114de h1:F6qOa9AZTYJXOUEr4jDysRDLrm4PHePlge4v4TGAlxY= google.golang.org/genproto v0.0.0-20240227224415-6ceb2ff114de/go.mod h1:VUhTRKeHn9wwcdrk73nvdC9gF178Tzhmt/qyaFcPLSo= google.golang.org/genproto/googleapis/api v0.0.0-20240318140521-94a12d6c2237 h1:RFiFrvy37/mpSpdySBDrUdipW/dHwsRwh3J3+A9VgT4= @@ -614,12 +566,8 @@ google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZi google.golang.org/grpc v1.23.0/go.mod h1:Y5yQAOtifL1yxbo5wqy6BxZv8vAUGQwXBOALyacEbxg= google.golang.org/grpc v1.25.1/go.mod h1:c3i+UQWmh7LiEpx4sFZnkU36qjEYZ0imhYfXVyQciAY= google.golang.org/grpc v1.27.0/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk= -google.golang.org/grpc v1.29.1/go.mod h1:itym6AZVZYACWQqET3MqgPpjcuV5QH3BxFS3IjizoKk= google.golang.org/grpc v1.33.1/go.mod h1:fr5YgcSWrqhRRxogOsw7RzIpsmvOZ6IcH4kBYTpR3n0= google.golang.org/grpc v1.33.2/go.mod h1:JMHMWHQWaTccqQQlmk3MJZS+GWXOdAesneDmEnv2fbc= -google.golang.org/grpc v1.36.0/go.mod h1:qjiiYl8FncCW8feJPdyg3v6XW24KsRHe+dy9BAGRRjU= -google.golang.org/grpc v1.45.0/go.mod h1:lN7owxKUQEqMfSyQikvvk5tf/6zMPsrK+ONuO11+0rQ= -google.golang.org/grpc v1.49.0/go.mod h1:ZgQEeidpAuNRZ8iRrlBKXZQP1ghovWIVhdJRyCDK+GI= google.golang.org/grpc v1.64.1 h1:LKtvyfbX3UGVPFcGqJ9ItpVWW6oN/2XqTxfAnwRRXiA= google.golang.org/grpc v1.64.1/go.mod h1:hiQF4LFZelK2WKaP6W0L92zGHtiQdZxk8CrSdvyjeP0= google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8= @@ -633,13 +581,10 @@ google.golang.org/protobuf v1.23.1-0.20200526195155-81db48ad09cc/go.mod h1:EGpAD google.golang.org/protobuf v1.25.0/go.mod h1:9JNX74DMeImyA3h4bdi1ymwjUzf21/xIlbajtzgsN7c= google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw= google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= -google.golang.org/protobuf v1.27.1/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= -google.golang.org/protobuf v1.28.1/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= google.golang.org/protobuf v1.34.2 h1:6xV6lTsCfpGD21XK49h7MhtcApnLqkfYgPcdHftf6hg= google.golang.org/protobuf v1.34.2/go.mod h1:qYOHts0dSfpeUzUFpOMr/WGzszTmLH+DiWniOlNbLDw= gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= -gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20200902074654-038fdea0a05b/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk= @@ -654,11 +599,9 @@ gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.2.3/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.2.5/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= -gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.3.0/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ= gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= -gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gotest.tools/v3 v3.5.1 h1:EENdUnS3pdur5nybKYIh2Vfgc8IUNBjxDPSjtiJcOzU= diff --git a/x/accounts/defaults/multisig/go.mod b/x/accounts/defaults/multisig/go.mod index e916c454b755..482921159b70 100644 --- a/x/accounts/defaults/multisig/go.mod +++ b/x/accounts/defaults/multisig/go.mod @@ -9,7 +9,7 @@ require ( cosmossdk.io/x/accounts v0.0.0-00010101000000-000000000000 cosmossdk.io/x/bank v0.0.0-20240226161501-23359a0b6d91 github.com/cosmos/cosmos-proto v1.0.0-beta.5 - github.com/cosmos/cosmos-sdk v0.51.0 + github.com/cosmos/cosmos-sdk v0.53.0 github.com/cosmos/gogoproto v1.5.0 github.com/stretchr/testify v1.9.0 google.golang.org/protobuf v1.34.2 @@ -20,7 +20,7 @@ require ( buf.build/gen/go/cosmos/gogo-proto/protocolbuffers/go v1.34.2-20240130113600-88ef6483f90f.2 // indirect cosmossdk.io/api v0.7.5 // indirect cosmossdk.io/core/testing v0.0.0-00010101000000-000000000000 // indirect - cosmossdk.io/depinject v1.0.0-alpha.4 // indirect + cosmossdk.io/depinject v1.0.0 // indirect cosmossdk.io/errors v1.0.1 // indirect cosmossdk.io/log v1.3.1 // indirect cosmossdk.io/schema v0.1.1 // indirect @@ -52,7 +52,7 @@ require ( github.com/cosmos/crypto v0.1.2 // indirect github.com/cosmos/go-bip39 v1.0.0 // indirect github.com/cosmos/gogogateway v1.2.0 // indirect - github.com/cosmos/iavl v1.2.0 // indirect + github.com/cosmos/iavl v1.2.1-0.20240725141113-7adc688cf179 // indirect github.com/cosmos/ics23/go v0.10.0 // indirect github.com/cosmos/ledger-cosmos-go v0.13.3 // indirect github.com/danieljoos/wincred v1.2.1 // indirect @@ -177,8 +177,6 @@ replace ( cosmossdk.io/collections => ../../../../collections // TODO tag new collections ASAP cosmossdk.io/core => ../../../../core cosmossdk.io/core/testing => ../../../../core/testing - cosmossdk.io/depinject => ../../../../depinject - cosmossdk.io/log => ../../../../log cosmossdk.io/x/accounts => ../../. cosmossdk.io/x/auth => ../../../auth cosmossdk.io/x/bank => ../../../bank @@ -188,4 +186,5 @@ replace ( cosmossdk.io/x/protocolpool => ../../../protocolpool cosmossdk.io/x/slashing => ../../../slashing cosmossdk.io/x/staking => ../../../staking + cosmossdk.io/x/tx => ../../../tx ) diff --git a/x/accounts/defaults/multisig/go.sum b/x/accounts/defaults/multisig/go.sum index db6a096219de..b56674a06af2 100644 --- a/x/accounts/defaults/multisig/go.sum +++ b/x/accounts/defaults/multisig/go.sum @@ -4,16 +4,18 @@ buf.build/gen/go/cosmos/gogo-proto/protocolbuffers/go v1.34.2-20240130113600-88e buf.build/gen/go/cosmos/gogo-proto/protocolbuffers/go v1.34.2-20240130113600-88ef6483f90f.2/go.mod h1:HqcXMSa5qnNuakaMUo+hWhF51mKbcrZxGl9Vp5EeJXc= cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= cloud.google.com/go v0.34.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= +cosmossdk.io/depinject v1.0.0 h1:dQaTu6+O6askNXO06+jyeUAnF2/ssKwrrszP9t5q050= +cosmossdk.io/depinject v1.0.0/go.mod h1:zxK/h3HgHoA/eJVtiSsoaRaRA2D5U4cJ5thIG4ssbB8= cosmossdk.io/errors v1.0.1 h1:bzu+Kcr0kS/1DuPBtUFdWjzLqyUuCiyHjyJB6srBV/0= cosmossdk.io/errors v1.0.1/go.mod h1:MeelVSZThMi4bEakzhhhE/CKqVv3nOJDA25bIqRDu/U= +cosmossdk.io/log v1.3.1 h1:UZx8nWIkfbbNEWusZqzAx3ZGvu54TZacWib3EzUYmGI= +cosmossdk.io/log v1.3.1/go.mod h1:2/dIomt8mKdk6vl3OWJcPk2be3pGOS8OQaLUM/3/tCM= cosmossdk.io/math v1.3.0 h1:RC+jryuKeytIiictDslBP9i1fhkVm6ZDmZEoNP316zE= cosmossdk.io/math v1.3.0/go.mod h1:vnRTxewy+M7BtXBNFybkuhSH4WfedVAAnERHgVFhp3k= cosmossdk.io/schema v0.1.1 h1:I0M6pgI7R10nq+/HCQfbO6BsGBZA8sQy+duR1Y3aKcA= cosmossdk.io/schema v0.1.1/go.mod h1:RDAhxIeNB4bYqAlF4NBJwRrgtnciMcyyg0DOKnhNZQQ= cosmossdk.io/store v1.1.1-0.20240418092142-896cdf1971bc h1:R9O9d75e0qZYUsVV0zzi+D7cNLnX2JrUOQNoIPaF0Bg= cosmossdk.io/store v1.1.1-0.20240418092142-896cdf1971bc/go.mod h1:amTTatOUV3u1PsKmNb87z6/galCxrRbz9kRdJkL0DyU= -cosmossdk.io/x/tx v0.13.3 h1:Ha4mNaHmxBc6RMun9aKuqul8yHiL78EKJQ8g23Zf73g= -cosmossdk.io/x/tx v0.13.3/go.mod h1:I8xaHv0rhUdIvIdptKIqzYy27+n2+zBVaxO6fscFhys= filippo.io/edwards25519 v1.1.0 h1:FNf4tywRC1HmFuKW5xopWpigGjJKiJSV0Cqo0cJWDaA= filippo.io/edwards25519 v1.1.0/go.mod h1:BxyFTGdWcka3PhytdK4V28tE5sGfRvvvRV7EaN4VDT4= github.com/99designs/go-keychain v0.0.0-20191008050251-8e49817e8af4 h1:/vQbFIOMbk2FiG/kXiLl8BRyzTWDw7gX/Hz7Dd5eDMs= @@ -111,8 +113,8 @@ github.com/cosmos/gogogateway v1.2.0/go.mod h1:iQpLkGWxYcnCdz5iAdLcRBSw3h7NXeOkZ github.com/cosmos/gogoproto v1.4.2/go.mod h1:cLxOsn1ljAHSV527CHOtaIP91kK6cCrZETRBrkzItWU= github.com/cosmos/gogoproto v1.5.0 h1:SDVwzEqZDDBoslaeZg+dGE55hdzHfgUA40pEanMh52o= github.com/cosmos/gogoproto v1.5.0/go.mod h1:iUM31aofn3ymidYG6bUR5ZFrk+Om8p5s754eMUcyp8I= -github.com/cosmos/iavl v1.2.0 h1:kVxTmjTh4k0Dh1VNL046v6BXqKziqMDzxo93oh3kOfM= -github.com/cosmos/iavl v1.2.0/go.mod h1:HidWWLVAtODJqFD6Hbne2Y0q3SdxByJepHUOeoH4LiI= +github.com/cosmos/iavl v1.2.1-0.20240725141113-7adc688cf179 h1:wmwDn7V3RodN9auB3FooSQxs46nHVE3u0mb87TJkZFE= +github.com/cosmos/iavl v1.2.1-0.20240725141113-7adc688cf179/go.mod h1:GiM43q0pB+uG53mLxLDzimxM9l/5N9UuSY3/D0huuVw= github.com/cosmos/ics23/go v0.10.0 h1:iXqLLgp2Lp+EdpIuwXTYIQU+AiHj9mOC2X9ab++bZDM= github.com/cosmos/ics23/go v0.10.0/go.mod h1:ZfJSmng/TBNTBkFemHHHj5YY7VAU/MBU980F4VU1NG0= github.com/cosmos/ledger-cosmos-go v0.13.3 h1:7ehuBGuyIytsXbd4MP43mLeoN2LTOEnk5nvue4rK+yM= diff --git a/x/accounts/go.mod b/x/accounts/go.mod index 0a2b6d9a7666..a91192d1984d 100644 --- a/x/accounts/go.mod +++ b/x/accounts/go.mod @@ -7,11 +7,11 @@ require ( cosmossdk.io/collections v0.4.0 cosmossdk.io/core v0.12.1-0.20231114100755-569e3ff6a0d7 cosmossdk.io/core/testing v0.0.0-00010101000000-000000000000 - cosmossdk.io/depinject v1.0.0-alpha.4 + cosmossdk.io/depinject v1.0.0 cosmossdk.io/x/accounts/defaults/multisig v0.0.0-00010101000000-000000000000 cosmossdk.io/x/bank v0.0.0-20240226161501-23359a0b6d91 cosmossdk.io/x/tx v0.13.3 - github.com/cosmos/cosmos-sdk v0.51.0 + github.com/cosmos/cosmos-sdk v0.53.0 github.com/cosmos/gogoproto v1.5.0 github.com/decred/dcrd/dcrec/secp256k1/v4 v4.3.0 github.com/spf13/cobra v1.8.1 @@ -62,7 +62,7 @@ require ( github.com/cosmos/crypto v0.1.2 // indirect github.com/cosmos/go-bip39 v1.0.0 // indirect github.com/cosmos/gogogateway v1.2.0 // indirect - github.com/cosmos/iavl v1.2.0 // indirect + github.com/cosmos/iavl v1.2.1-0.20240725141113-7adc688cf179 // indirect github.com/cosmos/ics23/go v0.10.0 // indirect github.com/cosmos/ledger-cosmos-go v0.13.3 // indirect github.com/danieljoos/wincred v1.2.1 // indirect @@ -184,8 +184,6 @@ replace ( cosmossdk.io/collections => ../../collections cosmossdk.io/core => ../../core cosmossdk.io/core/testing => ../../core/testing - cosmossdk.io/depinject => ../../depinject - cosmossdk.io/log => ../../log cosmossdk.io/x/accounts/defaults/multisig => ./defaults/multisig cosmossdk.io/x/auth => ../auth cosmossdk.io/x/bank => ../bank diff --git a/x/accounts/go.sum b/x/accounts/go.sum index 99a16b5789f2..e4d12d7e10b9 100644 --- a/x/accounts/go.sum +++ b/x/accounts/go.sum @@ -4,8 +4,12 @@ buf.build/gen/go/cosmos/gogo-proto/protocolbuffers/go v1.34.2-20240130113600-88e buf.build/gen/go/cosmos/gogo-proto/protocolbuffers/go v1.34.2-20240130113600-88ef6483f90f.2/go.mod h1:HqcXMSa5qnNuakaMUo+hWhF51mKbcrZxGl9Vp5EeJXc= cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= cloud.google.com/go v0.34.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= +cosmossdk.io/depinject v1.0.0 h1:dQaTu6+O6askNXO06+jyeUAnF2/ssKwrrszP9t5q050= +cosmossdk.io/depinject v1.0.0/go.mod h1:zxK/h3HgHoA/eJVtiSsoaRaRA2D5U4cJ5thIG4ssbB8= cosmossdk.io/errors v1.0.1 h1:bzu+Kcr0kS/1DuPBtUFdWjzLqyUuCiyHjyJB6srBV/0= cosmossdk.io/errors v1.0.1/go.mod h1:MeelVSZThMi4bEakzhhhE/CKqVv3nOJDA25bIqRDu/U= +cosmossdk.io/log v1.3.1 h1:UZx8nWIkfbbNEWusZqzAx3ZGvu54TZacWib3EzUYmGI= +cosmossdk.io/log v1.3.1/go.mod h1:2/dIomt8mKdk6vl3OWJcPk2be3pGOS8OQaLUM/3/tCM= cosmossdk.io/math v1.3.0 h1:RC+jryuKeytIiictDslBP9i1fhkVm6ZDmZEoNP316zE= cosmossdk.io/math v1.3.0/go.mod h1:vnRTxewy+M7BtXBNFybkuhSH4WfedVAAnERHgVFhp3k= cosmossdk.io/schema v0.1.1 h1:I0M6pgI7R10nq+/HCQfbO6BsGBZA8sQy+duR1Y3aKcA= @@ -111,8 +115,8 @@ github.com/cosmos/gogogateway v1.2.0/go.mod h1:iQpLkGWxYcnCdz5iAdLcRBSw3h7NXeOkZ github.com/cosmos/gogoproto v1.4.2/go.mod h1:cLxOsn1ljAHSV527CHOtaIP91kK6cCrZETRBrkzItWU= github.com/cosmos/gogoproto v1.5.0 h1:SDVwzEqZDDBoslaeZg+dGE55hdzHfgUA40pEanMh52o= github.com/cosmos/gogoproto v1.5.0/go.mod h1:iUM31aofn3ymidYG6bUR5ZFrk+Om8p5s754eMUcyp8I= -github.com/cosmos/iavl v1.2.0 h1:kVxTmjTh4k0Dh1VNL046v6BXqKziqMDzxo93oh3kOfM= -github.com/cosmos/iavl v1.2.0/go.mod h1:HidWWLVAtODJqFD6Hbne2Y0q3SdxByJepHUOeoH4LiI= +github.com/cosmos/iavl v1.2.1-0.20240725141113-7adc688cf179 h1:wmwDn7V3RodN9auB3FooSQxs46nHVE3u0mb87TJkZFE= +github.com/cosmos/iavl v1.2.1-0.20240725141113-7adc688cf179/go.mod h1:GiM43q0pB+uG53mLxLDzimxM9l/5N9UuSY3/D0huuVw= github.com/cosmos/ics23/go v0.10.0 h1:iXqLLgp2Lp+EdpIuwXTYIQU+AiHj9mOC2X9ab++bZDM= github.com/cosmos/ics23/go v0.10.0/go.mod h1:ZfJSmng/TBNTBkFemHHHj5YY7VAU/MBU980F4VU1NG0= github.com/cosmos/ledger-cosmos-go v0.13.3 h1:7ehuBGuyIytsXbd4MP43mLeoN2LTOEnk5nvue4rK+yM= diff --git a/x/accounts/testing/account_abstraction/minimal.go b/x/accounts/testing/account_abstraction/minimal.go index 30775e984261..b450f0016cc8 100644 --- a/x/accounts/testing/account_abstraction/minimal.go +++ b/x/accounts/testing/account_abstraction/minimal.go @@ -46,7 +46,7 @@ func (a MinimalAbstractedAccount) RotatePubKey(ctx context.Context, msg *rotatio return nil, errors.New("not implemented") } -// Authenticate authenticates the account, auth always passess. +// Authenticate authenticates the account, auth always passes. func (a MinimalAbstractedAccount) Authenticate(ctx context.Context, msg *account_abstractionv1.MsgAuthenticate) (*account_abstractionv1.MsgAuthenticateResponse, error) { _, err := a.Sequence.Next(ctx) if err != nil { diff --git a/x/auth/ante/basic.go b/x/auth/ante/basic.go index ff9852698961..642230a6de3e 100644 --- a/x/auth/ante/basic.go +++ b/x/auth/ante/basic.go @@ -2,6 +2,7 @@ package ante import ( "context" + "time" "cosmossdk.io/core/appmodule/v2" "cosmossdk.io/core/transaction" @@ -227,6 +228,7 @@ type ( sdk.Tx GetTimeoutHeight() uint64 + GetTimeoutTimeStamp() time.Time } ) @@ -266,5 +268,12 @@ func (txh TxTimeoutHeightDecorator) ValidateTx(ctx context.Context, tx sdk.Tx) e ) } + timeoutTimestamp := timeoutTx.GetTimeoutTimeStamp() + if !timeoutTimestamp.IsZero() && timeoutTimestamp.Unix() != 0 && timeoutTimestamp.Before(headerInfo.Time) { + return errorsmod.Wrapf( + sdkerrors.ErrTxTimeout, "block time: %s, timeout timestamp: %s", headerInfo.Time.String(), timeoutTimestamp.String(), + ) + } + return nil } diff --git a/x/auth/ante/basic_test.go b/x/auth/ante/basic_test.go index 836fd63e1fb6..599fc653913c 100644 --- a/x/auth/ante/basic_test.go +++ b/x/auth/ante/basic_test.go @@ -4,6 +4,7 @@ import ( "context" "strings" "testing" + "time" "github.com/stretchr/testify/require" @@ -193,21 +194,30 @@ func TestTxHeightTimeoutDecorator(t *testing.T) { // keys and addresses priv1, _, addr1 := testdata.KeyTestPubAddr() + currentTime := time.Now() + // msg and signatures msg := testdata.NewTestMsg(addr1) feeAmount := testdata.NewTestFeeAmount() gasLimit := testdata.NewTestGasLimit() testCases := []struct { - name string - timeout uint64 - height int64 - expectedErr error + name string + timeout uint64 + height int64 + timeoutTimestamp time.Time + timestamp time.Time + expectedErr error }{ - {"default value", 0, 10, nil}, - {"no timeout (greater height)", 15, 10, nil}, - {"no timeout (same height)", 10, 10, nil}, - {"timeout (smaller height)", 9, 10, sdkerrors.ErrTxTimeoutHeight}, + {"default value", 0, 10, time.Time{}, time.Time{}, nil}, + {"no timeout (greater height)", 15, 10, time.Time{}, time.Time{}, nil}, + {"no timeout (same height)", 10, 10, time.Time{}, time.Time{}, nil}, + {"timeout (smaller height)", 9, 10, time.Time{}, time.Time{}, sdkerrors.ErrTxTimeoutHeight}, + {"no timeout (timeout after timestamp)", 0, 20, currentTime.Add(time.Minute), currentTime, nil}, + {"no timeout (current time)", 0, 20, currentTime, currentTime, nil}, + {"timeout before timestamp", 0, 20, currentTime, currentTime.Add(time.Minute), sdkerrors.ErrTxTimeout}, + {"tx contain both timeouts, timeout (timeout before timestamp)", 15, 10, currentTime, currentTime.Add(time.Minute), sdkerrors.ErrTxTimeout}, + {"tx contain both timeout, no timeout", 15, 10, currentTime.Add(time.Minute), currentTime, nil}, } for _, tc := range testCases { @@ -222,12 +232,14 @@ func TestTxHeightTimeoutDecorator(t *testing.T) { suite.txBuilder.SetGasLimit(gasLimit) suite.txBuilder.SetMemo(strings.Repeat("01234567890", 10)) suite.txBuilder.SetTimeoutHeight(tc.timeout) + suite.txBuilder.SetTimeoutTimestamp(tc.timeoutTimestamp) privs, accNums, accSeqs := []cryptotypes.PrivKey{priv1}, []uint64{0}, []uint64{0} tx, err := suite.CreateTestTx(suite.ctx, privs, accNums, accSeqs, suite.ctx.ChainID(), signing.SignMode_SIGN_MODE_DIRECT) require.NoError(t, err) mockHeaderService.WithBlockHeight(tc.height) + mockHeaderService.WithBlockTime(tc.timestamp) _, err = antehandler(suite.ctx, tx, true) require.ErrorIs(t, err, tc.expectedErr) }) @@ -247,3 +259,7 @@ func (m *mockHeaderService) HeaderInfo(_ context.Context) header.Info { func (m *mockHeaderService) WithBlockHeight(height int64) { m.exp.Height = height } + +func (m *mockHeaderService) WithBlockTime(blocktime time.Time) { + m.exp.Time = blocktime +} diff --git a/x/auth/ante/expected_keepers.go b/x/auth/ante/expected_keepers.go index f0f2db6bccb6..82fc9846a3af 100644 --- a/x/auth/ante/expected_keepers.go +++ b/x/auth/ante/expected_keepers.go @@ -30,5 +30,4 @@ type FeegrantKeeper interface { type ConsensusKeeper interface { Params(context.Context, *consensustypes.QueryParamsRequest) (*consensustypes.QueryParamsResponse, error) - GetCometInfo(ctx context.Context, request *consensustypes.QueryGetCometInfoRequest) (*consensustypes.QueryGetCometInfoResponse, error) } diff --git a/x/auth/ante/sigverify.go b/x/auth/ante/sigverify.go index 1856f2c311f6..a435ba03bdfa 100644 --- a/x/auth/ante/sigverify.go +++ b/x/auth/ante/sigverify.go @@ -464,7 +464,7 @@ func NewValidateSigCountDecorator(ak AccountKeeper) ValidateSigCountDecorator { } } -// AnteHandler implements an ante decorator for ValidateSigCountDecorator +// AnteHandle implements an ante decorator for ValidateSigCountDecorator func (vscd ValidateSigCountDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, _ bool, next sdk.AnteHandler) (newCtx sdk.Context, err error) { if err := vscd.ValidateTx(ctx, tx); err != nil { return ctx, err diff --git a/x/auth/ante/testutil/expected_keepers_mocks.go b/x/auth/ante/testutil/expected_keepers_mocks.go index 35952cd58087..e848a52342cf 100644 --- a/x/auth/ante/testutil/expected_keepers_mocks.go +++ b/x/auth/ante/testutil/expected_keepers_mocks.go @@ -195,21 +195,6 @@ func (m *MockConsensusKeeper) EXPECT() *MockConsensusKeeperMockRecorder { return m.recorder } -// GetCometInfo mocks base method. -func (m *MockConsensusKeeper) GetCometInfo(ctx context.Context, request *types0.QueryGetCometInfoRequest) (*types0.QueryGetCometInfoResponse, error) { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "GetCometInfo", ctx, request) - ret0, _ := ret[0].(*types0.QueryGetCometInfoResponse) - ret1, _ := ret[1].(error) - return ret0, ret1 -} - -// GetCometInfo indicates an expected call of GetCometInfo. -func (mr *MockConsensusKeeperMockRecorder) GetCometInfo(ctx, request interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetCometInfo", reflect.TypeOf((*MockConsensusKeeper)(nil).GetCometInfo), ctx, request) -} - // Params mocks base method. func (m *MockConsensusKeeper) Params(arg0 context.Context, arg1 *types0.QueryParamsRequest) (*types0.QueryParamsResponse, error) { m.ctrl.T.Helper() diff --git a/x/auth/ante/unordered.go b/x/auth/ante/unordered.go index 16b2837c4360..b97774ef6118 100644 --- a/x/auth/ante/unordered.go +++ b/x/auth/ante/unordered.go @@ -5,8 +5,9 @@ import ( "crypto/sha256" "encoding/binary" "sync" + "time" - "github.com/golang/protobuf/proto" // nolint: staticcheck // for proto.Message + "github.com/cosmos/gogoproto/proto" "cosmossdk.io/core/appmodule/v2" "cosmossdk.io/core/transaction" @@ -42,22 +43,32 @@ var _ sdk.AnteDecorator = (*UnorderedTxDecorator)(nil) // chain to ensure that during DeliverTx, the transaction is added to the UnorderedTxManager. type UnorderedTxDecorator struct { // maxUnOrderedTTL defines the maximum TTL a transaction can define. - maxUnOrderedTTL uint64 - txManager *unorderedtx.Manager - env appmodule.Environment - sha256Cost uint64 + maxTimeoutDuration time.Duration + txManager *unorderedtx.Manager + env appmodule.Environment + sha256Cost uint64 } -func NewUnorderedTxDecorator(maxTTL uint64, m *unorderedtx.Manager, env appmodule.Environment, gasCost uint64) *UnorderedTxDecorator { +func NewUnorderedTxDecorator( + maxDuration time.Duration, + m *unorderedtx.Manager, + env appmodule.Environment, + gasCost uint64, +) *UnorderedTxDecorator { return &UnorderedTxDecorator{ - maxUnOrderedTTL: maxTTL, - txManager: m, - env: env, - sha256Cost: gasCost, + maxTimeoutDuration: maxDuration, + txManager: m, + env: env, + sha256Cost: gasCost, } } -func (d *UnorderedTxDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, _ bool, next sdk.AnteHandler) (sdk.Context, error) { +func (d *UnorderedTxDecorator) AnteHandle( + ctx sdk.Context, + tx sdk.Tx, + _ bool, + next sdk.AnteHandler, +) (sdk.Context, error) { unorderedTx, ok := tx.(sdk.TxWithUnordered) if !ok || !unorderedTx.GetUnordered() { // If the transaction does not implement unordered capabilities or has the @@ -65,17 +76,26 @@ func (d *UnorderedTxDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, _ bool, ne return next(ctx, tx, false) } - // TTL is defined as a specific block height at which this tx is no longer valid - ttl := unorderedTx.GetTimeoutHeight() - - if ttl == 0 { - return ctx, errorsmod.Wrap(sdkerrors.ErrInvalidRequest, "unordered transaction must have timeout_height set") + headerInfo := d.env.HeaderService.HeaderInfo(ctx) + timeoutTimestamp := unorderedTx.GetTimeoutTimeStamp() + if timeoutTimestamp.IsZero() || timeoutTimestamp.Unix() == 0 { + return ctx, errorsmod.Wrap( + sdkerrors.ErrInvalidRequest, + "unordered transaction must have timeout_timestamp set", + ) } - if ttl < uint64(ctx.BlockHeight()) { - return ctx, errorsmod.Wrap(sdkerrors.ErrInvalidRequest, "unordered transaction has a timeout_height that has already passed") + if timeoutTimestamp.Before(headerInfo.Time) { + return ctx, errorsmod.Wrap( + sdkerrors.ErrInvalidRequest, + "unordered transaction has a timeout_timestamp that has already passed", + ) } - if ttl > uint64(ctx.BlockHeight())+d.maxUnOrderedTTL { - return ctx, errorsmod.Wrapf(sdkerrors.ErrInvalidRequest, "unordered tx ttl exceeds %d", d.maxUnOrderedTTL) + if timeoutTimestamp.After(headerInfo.Time.Add(d.maxTimeoutDuration)) { + return ctx, errorsmod.Wrapf( + sdkerrors.ErrInvalidRequest, + "unordered tx ttl exceeds %s", + d.maxTimeoutDuration.String(), + ) } // consume gas in all exec modes to avoid gas estimation discrepancies @@ -90,18 +110,21 @@ func (d *UnorderedTxDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, _ bool, ne } // calculate the tx hash - txHash, err := TxIdentifier(ttl, tx) + txHash, err := TxIdentifier(uint64(timeoutTimestamp.Unix()), tx) if err != nil { return ctx, err } // check for duplicates if d.txManager.Contains(txHash) { - return ctx, errorsmod.Wrap(sdkerrors.ErrInvalidRequest, "tx %X is duplicated") + return ctx, errorsmod.Wrap( + sdkerrors.ErrInvalidRequest, + "tx %X is duplicated", + ) } if d.env.TransactionService.ExecMode(ctx) == transaction.ExecModeFinalize { // a new tx included in the block, add the hash to the unordered tx manager - d.txManager.Add(txHash, ttl) + d.txManager.Add(txHash, timeoutTimestamp) } return next(ctx, tx, false) @@ -111,7 +134,10 @@ func (d *UnorderedTxDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, _ bool, ne func TxIdentifier(timeout uint64, tx sdk.Tx) ([32]byte, error) { feetx := tx.(sdk.FeeTx) if feetx.GetFee().IsZero() { - return [32]byte{}, errorsmod.Wrap(sdkerrors.ErrInvalidRequest, "unordered transaction must have a fee") + return [32]byte{}, errorsmod.Wrap( + sdkerrors.ErrInvalidRequest, + "unordered transaction must have a fee", + ) } buf := bufPool.Get().(*bytes.Buffer) @@ -126,22 +152,34 @@ func TxIdentifier(timeout uint64, tx sdk.Tx) ([32]byte, error) { // Malleability is not a concern here because the state machine will encode the transaction deterministically. bz, err := proto.Marshal(msg) if err != nil { - return [32]byte{}, errorsmod.Wrap(sdkerrors.ErrInvalidRequest, "failed to marshal message") + return [32]byte{}, errorsmod.Wrap( + sdkerrors.ErrInvalidRequest, + "failed to marshal message", + ) } if _, err := buf.Write(bz); err != nil { - return [32]byte{}, errorsmod.Wrap(sdkerrors.ErrInvalidRequest, "failed to write message to buffer") + return [32]byte{}, errorsmod.Wrap( + sdkerrors.ErrInvalidRequest, + "failed to write message to buffer", + ) } } // write the timeout height to the buffer if err := binary.Write(buf, binary.LittleEndian, timeout); err != nil { - return [32]byte{}, errorsmod.Wrap(sdkerrors.ErrInvalidRequest, "failed to write timeout_height to buffer") + return [32]byte{}, errorsmod.Wrap( + sdkerrors.ErrInvalidRequest, + "failed to write timeout_height to buffer", + ) } // write gas to the buffer if err := binary.Write(buf, binary.LittleEndian, feetx.GetGas()); err != nil { - return [32]byte{}, errorsmod.Wrap(sdkerrors.ErrInvalidRequest, "failed to write unordered to buffer") + return [32]byte{}, errorsmod.Wrap( + sdkerrors.ErrInvalidRequest, + "failed to write unordered to buffer", + ) } txHash := sha256.Sum256(buf.Bytes()) diff --git a/x/auth/ante/unordered_test.go b/x/auth/ante/unordered_test.go index 7a1db02f2768..b02fcc28c471 100644 --- a/x/auth/ante/unordered_test.go +++ b/x/auth/ante/unordered_test.go @@ -2,9 +2,11 @@ package ante_test import ( "testing" + "time" "github.com/stretchr/testify/require" + "cosmossdk.io/core/header" storetypes "cosmossdk.io/store/types" "cosmossdk.io/x/auth/ante" "cosmossdk.io/x/auth/ante/unorderedtx" @@ -27,10 +29,10 @@ func TestUnorderedTxDecorator_OrderedTx(t *testing.T) { suite := SetupTestSuite(t, false) - chain := sdk.ChainAnteDecorators(ante.NewUnorderedTxDecorator(unorderedtx.DefaultMaxUnOrderedTTL, txm, suite.accountKeeper.GetEnvironment(), ante.DefaultSha256Cost)) + chain := sdk.ChainAnteDecorators(ante.NewUnorderedTxDecorator(unorderedtx.DefaultMaxTimeoutDuration, txm, suite.accountKeeper.GetEnvironment(), ante.DefaultSha256Cost)) - tx, txBz := genUnorderedTx(t, false, 0) - ctx := sdk.Context{}.WithTxBytes(txBz).WithBlockHeight(100) + tx, txBz := genUnorderedTx(t, false, time.Time{}) + ctx := sdk.Context{}.WithTxBytes(txBz) _, err := chain(ctx, tx, false) require.NoError(t, err) @@ -46,10 +48,10 @@ func TestUnorderedTxDecorator_UnorderedTx_NoTTL(t *testing.T) { suite := SetupTestSuite(t, false) - chain := sdk.ChainAnteDecorators(ante.NewUnorderedTxDecorator(unorderedtx.DefaultMaxUnOrderedTTL, txm, suite.accountKeeper.GetEnvironment(), ante.DefaultSha256Cost)) + chain := sdk.ChainAnteDecorators(ante.NewUnorderedTxDecorator(unorderedtx.DefaultMaxTimeoutDuration, txm, suite.accountKeeper.GetEnvironment(), ante.DefaultSha256Cost)) - tx, txBz := genUnorderedTx(t, true, 0) - ctx := sdk.Context{}.WithTxBytes(txBz).WithBlockHeight(100) + tx, txBz := genUnorderedTx(t, true, time.Time{}) + ctx := sdk.Context{}.WithTxBytes(txBz) _, err := chain(ctx, tx, false) require.Error(t, err) @@ -65,11 +67,10 @@ func TestUnorderedTxDecorator_UnorderedTx_InvalidTTL(t *testing.T) { suite := SetupTestSuite(t, false) - chain := sdk.ChainAnteDecorators(ante.NewUnorderedTxDecorator(unorderedtx.DefaultMaxUnOrderedTTL, txm, suite.accountKeeper.GetEnvironment(), ante.DefaultSha256Cost)) - - tx, txBz := genUnorderedTx(t, true, 100+unorderedtx.DefaultMaxUnOrderedTTL+1) - ctx := sdk.Context{}.WithTxBytes(txBz).WithBlockHeight(100) + chain := sdk.ChainAnteDecorators(ante.NewUnorderedTxDecorator(unorderedtx.DefaultMaxTimeoutDuration, txm, suite.accountKeeper.GetEnvironment(), ante.DefaultSha256Cost)) + tx, txBz := genUnorderedTx(t, true, time.Now().Add(unorderedtx.DefaultMaxTimeoutDuration+time.Second)) + ctx := sdk.Context{}.WithTxBytes(txBz).WithHeaderInfo(header.Info{Time: time.Now()}) _, err := chain(ctx, tx, false) require.Error(t, err) } @@ -84,14 +85,14 @@ func TestUnorderedTxDecorator_UnorderedTx_AlreadyExists(t *testing.T) { suite := SetupTestSuite(t, false) - chain := sdk.ChainAnteDecorators(ante.NewUnorderedTxDecorator(unorderedtx.DefaultMaxUnOrderedTTL, txm, suite.accountKeeper.GetEnvironment(), ante.DefaultSha256Cost)) + chain := sdk.ChainAnteDecorators(ante.NewUnorderedTxDecorator(unorderedtx.DefaultMaxTimeoutDuration, txm, suite.accountKeeper.GetEnvironment(), ante.DefaultSha256Cost)) - tx, txBz := genUnorderedTx(t, true, 150) - ctx := sdk.Context{}.WithTxBytes(txBz).WithBlockHeight(100).WithGasMeter(storetypes.NewGasMeter(gasConsumed)) + tx, txBz := genUnorderedTx(t, true, time.Now().Add(time.Minute)) + ctx := sdk.Context{}.WithTxBytes(txBz).WithHeaderInfo(header.Info{Time: time.Now()}).WithGasMeter(storetypes.NewGasMeter(gasConsumed)) bz := [32]byte{} copy(bz[:], txBz[:32]) - txm.Add(bz, 150) + txm.Add(bz, time.Now().Add(time.Minute)) _, err := chain(ctx, tx, false) require.Error(t, err) @@ -107,10 +108,10 @@ func TestUnorderedTxDecorator_UnorderedTx_ValidCheckTx(t *testing.T) { suite := SetupTestSuite(t, false) - chain := sdk.ChainAnteDecorators(ante.NewUnorderedTxDecorator(unorderedtx.DefaultMaxUnOrderedTTL, txm, suite.accountKeeper.GetEnvironment(), ante.DefaultSha256Cost)) + chain := sdk.ChainAnteDecorators(ante.NewUnorderedTxDecorator(unorderedtx.DefaultMaxTimeoutDuration, txm, suite.accountKeeper.GetEnvironment(), ante.DefaultSha256Cost)) - tx, txBz := genUnorderedTx(t, true, 150) - ctx := sdk.Context{}.WithTxBytes(txBz).WithBlockHeight(100).WithExecMode(sdk.ExecModeCheck).WithGasMeter(storetypes.NewGasMeter(gasConsumed)) + tx, txBz := genUnorderedTx(t, true, time.Now().Add(time.Minute)) + ctx := sdk.Context{}.WithTxBytes(txBz).WithHeaderInfo(header.Info{Time: time.Now()}).WithExecMode(sdk.ExecModeCheck).WithGasMeter(storetypes.NewGasMeter(gasConsumed)) _, err := chain(ctx, tx, false) require.NoError(t, err) @@ -126,10 +127,10 @@ func TestUnorderedTxDecorator_UnorderedTx_ValidDeliverTx(t *testing.T) { suite := SetupTestSuite(t, false) - chain := sdk.ChainAnteDecorators(ante.NewUnorderedTxDecorator(unorderedtx.DefaultMaxUnOrderedTTL, txm, suite.accountKeeper.GetEnvironment(), ante.DefaultSha256Cost)) + chain := sdk.ChainAnteDecorators(ante.NewUnorderedTxDecorator(unorderedtx.DefaultMaxTimeoutDuration, txm, suite.accountKeeper.GetEnvironment(), ante.DefaultSha256Cost)) - tx, txBz := genUnorderedTx(t, true, 150) - ctx := sdk.Context{}.WithTxBytes(txBz).WithBlockHeight(100).WithExecMode(sdk.ExecModeFinalize).WithGasMeter(storetypes.NewGasMeter(gasConsumed)) + tx, txBz := genUnorderedTx(t, true, time.Now().Add(time.Minute)) + ctx := sdk.Context{}.WithTxBytes(txBz).WithHeaderInfo(header.Info{Time: time.Now()}).WithExecMode(sdk.ExecModeFinalize).WithGasMeter(storetypes.NewGasMeter(gasConsumed)) _, err := chain(ctx, tx, false) require.NoError(t, err) @@ -140,7 +141,7 @@ func TestUnorderedTxDecorator_UnorderedTx_ValidDeliverTx(t *testing.T) { require.True(t, txm.Contains(bz)) } -func genUnorderedTx(t *testing.T, unordered bool, ttl uint64) (sdk.Tx, []byte) { +func genUnorderedTx(t *testing.T, unordered bool, timestamp time.Time) (sdk.Tx, []byte) { t.Helper() s := SetupTestSuite(t, true) @@ -158,13 +159,13 @@ func genUnorderedTx(t *testing.T, unordered bool, ttl uint64) (sdk.Tx, []byte) { s.txBuilder.SetFeeAmount(feeAmount) s.txBuilder.SetGasLimit(gasLimit) s.txBuilder.SetUnordered(unordered) - s.txBuilder.SetTimeoutHeight(ttl) + s.txBuilder.SetTimeoutTimestamp(timestamp) privKeys, accNums, accSeqs := []cryptotypes.PrivKey{priv1}, []uint64{0}, []uint64{0} tx, err := s.CreateTestTx(s.ctx, privKeys, accNums, accSeqs, s.ctx.ChainID(), signing.SignMode_SIGN_MODE_DIRECT) require.NoError(t, err) - txBz, err := ante.TxIdentifier(ttl, tx) + txBz, err := ante.TxIdentifier(uint64(timestamp.Unix()), tx) require.NoError(t, err) diff --git a/x/auth/ante/unorderedtx/manager.go b/x/auth/ante/unorderedtx/manager.go index 14fbe018b83b..00e6ae624d5c 100644 --- a/x/auth/ante/unorderedtx/manager.go +++ b/x/auth/ante/unorderedtx/manager.go @@ -18,9 +18,9 @@ import ( ) const ( - // DefaultMaxUnOrderedTTL defines the default maximum TTL an un-ordered transaction + // DefaultmaxTimeoutDuration defines the default maximum duration an un-ordered transaction // can set. - DefaultMaxUnOrderedTTL = 1024 + DefaultMaxTimeoutDuration = time.Minute * 40 dirName = "unordered_txs" fileName = "data" @@ -33,7 +33,7 @@ type TxHash [32]byte // them when block production progresses. type Manager struct { // blockCh defines a channel to receive newly committed block heights - blockCh chan uint64 + blockCh chan time.Time // doneCh allows us to ensure the purgeLoop has gracefully terminated prior to closing doneCh chan struct{} @@ -48,10 +48,11 @@ type Manager struct { dataDir string mu sync.RWMutex - // txHashes defines a map from tx hash -> TTL value, which is used for duplicate + + // txHashes defines a map from tx hash -> TTL value defined as block time, which is used for duplicate // checking and replay protection, as well as purging the map when the TTL is // expired. - txHashes map[TxHash]uint64 + txHashes map[TxHash]time.Time } func NewManager(dataDir string) *Manager { @@ -62,9 +63,9 @@ func NewManager(dataDir string) *Manager { m := &Manager{ dataDir: dataDir, - blockCh: make(chan uint64, 16), + blockCh: make(chan time.Time, 16), doneCh: make(chan struct{}), - txHashes: make(map[TxHash]uint64), + txHashes: make(map[TxHash]time.Time), } return m @@ -91,7 +92,6 @@ func (m *Manager) Close() error { func (m *Manager) Contains(hash TxHash) bool { m.mu.RLock() defer m.mu.RUnlock() - _, ok := m.txHashes[hash] return ok } @@ -103,11 +103,11 @@ func (m *Manager) Size() int { return len(m.txHashes) } -func (m *Manager) Add(txHash TxHash, ttl uint64) { +func (m *Manager) Add(txHash TxHash, timestamp time.Time) { m.mu.Lock() defer m.mu.Unlock() - m.txHashes[txHash] = ttl + m.txHashes[txHash] = timestamp } // OnInit must be called when a node starts up. Typically, this should be called @@ -145,7 +145,8 @@ func (m *Manager) OnInit() error { var txHash TxHash copy(txHash[:], buf[:txHashSize]) - m.Add(txHash, binary.BigEndian.Uint64(buf[txHashSize:])) + timeStamp := binary.BigEndian.Uint64(buf[txHashSize:]) + m.Add(txHash, time.Unix(int64(timeStamp), 0)) } return nil @@ -153,8 +154,8 @@ func (m *Manager) OnInit() error { // OnNewBlock sends the latest block number to the background purge loop, which // should be called in ABCI Commit event. -func (m *Manager) OnNewBlock(blockHeight uint64) { - m.blockCh <- blockHeight +func (m *Manager) OnNewBlock(blockTime time.Time) { + m.blockCh <- blockTime } func (m *Manager) exportSnapshot(height uint64, snapshotWriter func([]byte) error) error { @@ -164,14 +165,16 @@ func (m *Manager) exportSnapshot(height uint64, snapshotWriter func([]byte) erro keys := maps.Keys(m.txHashes) sort.Slice(keys, func(i, j int) bool { return bytes.Compare(keys[i][:], keys[j][:]) < 0 }) + timestamp := time.Unix(int64(height), 0) for _, txHash := range keys { - ttl := m.txHashes[txHash] - if height > ttl { + timeoutTime := m.txHashes[txHash] + if timestamp.After(timeoutTime) { // skip expired txs that have yet to be purged continue } - - chunk := unorderedTxToBytes(txHash, ttl) + // right now we dont have access block time at this flow, so we would just include the expired txs + // and let it be purge during purge loop + chunk := unorderedTxToBytes(txHash, uint64(timeoutTime.Unix())) if _, err := w.Write(chunk); err != nil { return fmt.Errorf("failed to write unordered tx to buffer: %w", err) @@ -195,8 +198,8 @@ func (m *Manager) flushToFile() error { defer f.Close() w := bufio.NewWriter(f) - for txHash, ttl := range m.txHashes { - chunk := unorderedTxToBytes(txHash, ttl) + for txHash, timestamp := range m.txHashes { + chunk := unorderedTxToBytes(txHash, uint64(timestamp.Unix())) if _, err = w.Write(chunk); err != nil { return fmt.Errorf("failed to write unordered tx to buffer: %w", err) @@ -211,13 +214,13 @@ func (m *Manager) flushToFile() error { } // expiredTxs returns expired tx hashes based on the provided block height. -func (m *Manager) expiredTxs(blockHeight uint64) []TxHash { +func (m *Manager) expiredTxs(blockTime time.Time) []TxHash { m.mu.RLock() defer m.mu.RUnlock() var result []TxHash - for txHash, ttl := range m.txHashes { - if blockHeight > ttl { + for txHash, timestamp := range m.txHashes { + if blockTime.After(timestamp) { result = append(result, txHash) } } @@ -237,37 +240,38 @@ func (m *Manager) purge(txHashes []TxHash) { // purgeLoop removes expired tx hashes in the background func (m *Manager) purgeLoop() { for { - latestHeight, ok := m.batchReceive() + latestTime, ok := m.batchReceive() if !ok { // channel closed m.doneCh <- struct{}{} return } - hashes := m.expiredTxs(latestHeight) + hashes := m.expiredTxs(latestTime) if len(hashes) > 0 { m.purge(hashes) } } } -func (m *Manager) batchReceive() (uint64, bool) { +func (m *Manager) batchReceive() (time.Time, bool) { ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second) defer cancel() - var latestHeight uint64 + var latestTime time.Time for { select { case <-ctx.Done(): - return latestHeight, true + return latestTime, true - case blockHeight, ok := <-m.blockCh: + case blockTime, ok := <-m.blockCh: if !ok { // channel is closed - return 0, false + return time.Time{}, false } - if blockHeight > latestHeight { - latestHeight = blockHeight + + if blockTime.After(latestTime) { + latestTime = blockTime } } } @@ -277,7 +281,7 @@ func unorderedTxToBytes(txHash TxHash, ttl uint64) []byte { chunk := make([]byte, chunkSize) copy(chunk[:txHashSize], txHash[:]) - ttlBz := make([]byte, ttlSize) + ttlBz := make([]byte, timeoutSize) binary.BigEndian.PutUint64(ttlBz, ttl) copy(chunk[txHashSize:], ttlBz) diff --git a/x/auth/ante/unorderedtx/manager_test.go b/x/auth/ante/unorderedtx/manager_test.go index 04138e344657..40e48c72be27 100644 --- a/x/auth/ante/unorderedtx/manager_test.go +++ b/x/auth/ante/unorderedtx/manager_test.go @@ -25,9 +25,9 @@ func TestUnorderedTxManager_SimpleSize(t *testing.T) { txm.Start() - txm.Add([32]byte{0xFF}, 100) - txm.Add([32]byte{0xAA}, 100) - txm.Add([32]byte{0xCC}, 100) + txm.Add([32]byte{0xFF}, time.Now()) + txm.Add([32]byte{0xAA}, time.Now()) + txm.Add([32]byte{0xCC}, time.Now()) require.Equal(t, 3, txm.Size()) } @@ -42,7 +42,7 @@ func TestUnorderedTxManager_SimpleContains(t *testing.T) { for i := 0; i < 10; i++ { txHash := [32]byte{byte(i)} - txm.Add(txHash, 100) + txm.Add(txHash, time.Now()) require.True(t, txm.Contains(txHash)) } @@ -70,7 +70,7 @@ func TestUnorderedTxManager_CloseInit(t *testing.T) { // add a handful of unordered txs for i := 0; i < 100; i++ { - txm.Add([32]byte{byte(i)}, 100) + txm.Add([32]byte{byte(i)}, time.Now()) } // close the manager, which should flush all unexpired txs to file @@ -100,15 +100,17 @@ func TestUnorderedTxManager_Flow(t *testing.T) { txm.Start() + currentTime := time.Now() + // Seed the manager with a txs, some of which should eventually be purged and // the others will remain. Txs with TTL less than or equal to 50 should be purged. for i := 1; i <= 100; i++ { txHash := [32]byte{byte(i)} if i <= 50 { - txm.Add(txHash, uint64(i)) + txm.Add(txHash, currentTime.Add(time.Millisecond*500*time.Duration(i))) } else { - txm.Add(txHash, 100) + txm.Add(txHash, currentTime.Add(time.Hour)) } } @@ -118,19 +120,12 @@ func TestUnorderedTxManager_Flow(t *testing.T) { ticker := time.NewTicker(time.Millisecond * 500) defer ticker.Stop() - var ( - height uint64 = 1 - i = 101 - ) - for range ticker.C { - txm.OnNewBlock(height) - height++ + for t := range ticker.C { + txm.OnNewBlock(t) - if height > 51 { + if t.After(currentTime.Add(time.Millisecond * 500 * time.Duration(50))) { doneBlockCh <- true return - } else { - txm.Add([32]byte{byte(i)}, 50) } } }() diff --git a/x/auth/ante/unorderedtx/snapshotter.go b/x/auth/ante/unorderedtx/snapshotter.go index 5941a11a6888..690c45445493 100644 --- a/x/auth/ante/unorderedtx/snapshotter.go +++ b/x/auth/ante/unorderedtx/snapshotter.go @@ -4,14 +4,15 @@ import ( "encoding/binary" "errors" "io" + "time" snapshot "cosmossdk.io/store/snapshots/types" ) const ( - txHashSize = 32 - ttlSize = 8 - chunkSize = txHashSize + ttlSize + txHashSize = 32 + timeoutSize = 8 + chunkSize = txHashSize + timeoutSize ) var _ snapshot.ExtensionSnapshotter = &Snapshotter{} @@ -78,11 +79,13 @@ func (s *Snapshotter) restore(height uint64, payloadReader snapshot.ExtensionPay var txHash TxHash copy(txHash[:], payload[i:i+txHashSize]) - ttl := binary.BigEndian.Uint64(payload[i+txHashSize : i+chunkSize]) - - if height < ttl { - // only add unordered transactions that are still valid, i.e. unexpired - s.m.Add(txHash, ttl) + timestamp := binary.BigEndian.Uint64(payload[i+txHashSize : i+chunkSize]) + // need to come up with a way to fetch blocktime to filter out expired txs + // + // right now we dont have access block time at this flow, so we would just include the expired txs + // and let it be purge during purge loop + if timestamp != 0 && timestamp > height { + s.m.Add(txHash, time.Unix(int64(timestamp), 0)) } i += chunkSize diff --git a/x/auth/ante/unorderedtx/snapshotter_test.go b/x/auth/ante/unorderedtx/snapshotter_test.go index c073cf73f054..dcf7c05a0cd5 100644 --- a/x/auth/ante/unorderedtx/snapshotter_test.go +++ b/x/auth/ante/unorderedtx/snapshotter_test.go @@ -2,6 +2,7 @@ package unorderedtx_test import ( "testing" + "time" "github.com/stretchr/testify/require" @@ -12,9 +13,11 @@ func TestSnapshotter(t *testing.T) { dataDir := t.TempDir() txm := unorderedtx.NewManager(dataDir) + currentTime := time.Now() + // add a handful of unordered txs for i := 0; i < 100; i++ { - txm.Add([32]byte{byte(i)}, 100) + txm.Add([32]byte{byte(i)}, currentTime.Add(time.Second*100)) } var unorderedTxBz []byte @@ -36,17 +39,17 @@ func TestSnapshotter(t *testing.T) { err = s.RestoreExtension(50, 2, pr) require.Error(t, err) - // restore with height > ttl which should result in no unordered txs synced + // restore with timestamp > timeout time which should result in no unordered txs synced txm2 := unorderedtx.NewManager(dataDir) s2 := unorderedtx.NewSnapshotter(txm2) - err = s2.RestoreExtension(200, unorderedtx.SnapshotFormat, pr) + err = s2.RestoreExtension(uint64(currentTime.Add(time.Second*200).Unix()), unorderedtx.SnapshotFormat, pr) require.NoError(t, err) require.Empty(t, txm2.Size()) - // restore with height < ttl which should result in all unordered txs synced + // restore with timestamp < timeout time which should result in all unordered txs synced txm3 := unorderedtx.NewManager(dataDir) s3 := unorderedtx.NewSnapshotter(txm3) - err = s3.RestoreExtension(50, unorderedtx.SnapshotFormat, pr) + err = s3.RestoreExtension(uint64(currentTime.Add(time.Second*50).Unix()), unorderedtx.SnapshotFormat, pr) require.NoError(t, err) require.Equal(t, 100, txm3.Size()) diff --git a/x/auth/go.mod b/x/auth/go.mod index 36809cc0c27e..bcfb743e0ec1 100644 --- a/x/auth/go.mod +++ b/x/auth/go.mod @@ -7,7 +7,7 @@ require ( cosmossdk.io/collections v0.4.0 cosmossdk.io/core v0.12.1-0.20231114100755-569e3ff6a0d7 cosmossdk.io/core/testing v0.0.0-00010101000000-000000000000 - cosmossdk.io/depinject v1.0.0-alpha.4 + cosmossdk.io/depinject v1.0.0 cosmossdk.io/errors v1.0.1 cosmossdk.io/math v1.3.0 cosmossdk.io/store v1.1.1-0.20240418092142-896cdf1971bc @@ -16,7 +16,7 @@ require ( github.com/cometbft/cometbft v1.0.0-rc1 github.com/cometbft/cometbft/api v1.0.0-rc.1 github.com/cosmos/cosmos-proto v1.0.0-beta.5 - github.com/cosmos/cosmos-sdk v0.51.0 + github.com/cosmos/cosmos-sdk v0.53.0 github.com/cosmos/gogoproto v1.5.0 github.com/decred/dcrd/dcrec/secp256k1/v4 v4.3.0 github.com/golang/mock v1.6.0 @@ -62,7 +62,7 @@ require ( github.com/cosmos/crypto v0.1.2 // indirect github.com/cosmos/go-bip39 v1.0.0 // indirect github.com/cosmos/gogogateway v1.2.0 // indirect - github.com/cosmos/iavl v1.2.0 // indirect + github.com/cosmos/iavl v1.2.1-0.20240725141113-7adc688cf179 // indirect github.com/cosmos/ics23/go v0.10.0 // indirect github.com/cosmos/ledger-cosmos-go v0.13.3 // indirect github.com/danieljoos/wincred v1.2.1 // indirect @@ -177,8 +177,6 @@ replace ( cosmossdk.io/collections => ../../collections cosmossdk.io/core => ../../core cosmossdk.io/core/testing => ../../core/testing - cosmossdk.io/depinject => ../../depinject - cosmossdk.io/log => ../../log cosmossdk.io/x/accounts => ../accounts cosmossdk.io/x/bank => ../bank cosmossdk.io/x/consensus => ../consensus diff --git a/x/auth/go.sum b/x/auth/go.sum index 7c6b086874ef..4e269960625f 100644 --- a/x/auth/go.sum +++ b/x/auth/go.sum @@ -4,8 +4,12 @@ buf.build/gen/go/cosmos/gogo-proto/protocolbuffers/go v1.34.2-20240130113600-88e buf.build/gen/go/cosmos/gogo-proto/protocolbuffers/go v1.34.2-20240130113600-88ef6483f90f.2/go.mod h1:HqcXMSa5qnNuakaMUo+hWhF51mKbcrZxGl9Vp5EeJXc= cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= cloud.google.com/go v0.34.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= +cosmossdk.io/depinject v1.0.0 h1:dQaTu6+O6askNXO06+jyeUAnF2/ssKwrrszP9t5q050= +cosmossdk.io/depinject v1.0.0/go.mod h1:zxK/h3HgHoA/eJVtiSsoaRaRA2D5U4cJ5thIG4ssbB8= cosmossdk.io/errors v1.0.1 h1:bzu+Kcr0kS/1DuPBtUFdWjzLqyUuCiyHjyJB6srBV/0= cosmossdk.io/errors v1.0.1/go.mod h1:MeelVSZThMi4bEakzhhhE/CKqVv3nOJDA25bIqRDu/U= +cosmossdk.io/log v1.3.1 h1:UZx8nWIkfbbNEWusZqzAx3ZGvu54TZacWib3EzUYmGI= +cosmossdk.io/log v1.3.1/go.mod h1:2/dIomt8mKdk6vl3OWJcPk2be3pGOS8OQaLUM/3/tCM= cosmossdk.io/math v1.3.0 h1:RC+jryuKeytIiictDslBP9i1fhkVm6ZDmZEoNP316zE= cosmossdk.io/math v1.3.0/go.mod h1:vnRTxewy+M7BtXBNFybkuhSH4WfedVAAnERHgVFhp3k= cosmossdk.io/schema v0.1.1 h1:I0M6pgI7R10nq+/HCQfbO6BsGBZA8sQy+duR1Y3aKcA= @@ -109,8 +113,8 @@ github.com/cosmos/gogogateway v1.2.0/go.mod h1:iQpLkGWxYcnCdz5iAdLcRBSw3h7NXeOkZ github.com/cosmos/gogoproto v1.4.2/go.mod h1:cLxOsn1ljAHSV527CHOtaIP91kK6cCrZETRBrkzItWU= github.com/cosmos/gogoproto v1.5.0 h1:SDVwzEqZDDBoslaeZg+dGE55hdzHfgUA40pEanMh52o= github.com/cosmos/gogoproto v1.5.0/go.mod h1:iUM31aofn3ymidYG6bUR5ZFrk+Om8p5s754eMUcyp8I= -github.com/cosmos/iavl v1.2.0 h1:kVxTmjTh4k0Dh1VNL046v6BXqKziqMDzxo93oh3kOfM= -github.com/cosmos/iavl v1.2.0/go.mod h1:HidWWLVAtODJqFD6Hbne2Y0q3SdxByJepHUOeoH4LiI= +github.com/cosmos/iavl v1.2.1-0.20240725141113-7adc688cf179 h1:wmwDn7V3RodN9auB3FooSQxs46nHVE3u0mb87TJkZFE= +github.com/cosmos/iavl v1.2.1-0.20240725141113-7adc688cf179/go.mod h1:GiM43q0pB+uG53mLxLDzimxM9l/5N9UuSY3/D0huuVw= github.com/cosmos/ics23/go v0.10.0 h1:iXqLLgp2Lp+EdpIuwXTYIQU+AiHj9mOC2X9ab++bZDM= github.com/cosmos/ics23/go v0.10.0/go.mod h1:ZfJSmng/TBNTBkFemHHHj5YY7VAU/MBU980F4VU1NG0= github.com/cosmos/ledger-cosmos-go v0.13.3 h1:7ehuBGuyIytsXbd4MP43mLeoN2LTOEnk5nvue4rK+yM= diff --git a/x/auth/migrations/legacytx/stdsign.go b/x/auth/migrations/legacytx/stdsign.go index 71887fb26c99..6ef08f4c8a02 100644 --- a/x/auth/migrations/legacytx/stdsign.go +++ b/x/auth/migrations/legacytx/stdsign.go @@ -5,6 +5,7 @@ import ( "errors" "fmt" + gogoprotoany "github.com/cosmos/gogoproto/types/any" "sigs.k8s.io/yaml" errorsmod "cosmossdk.io/errors" @@ -130,7 +131,7 @@ func (ss StdSignature) MarshalYAML() (interface{}, error) { return string(bz), err } -func (ss StdSignature) UnpackInterfaces(unpacker codectypes.AnyUnpacker) error { +func (ss StdSignature) UnpackInterfaces(unpacker gogoprotoany.AnyUnpacker) error { return codectypes.UnpackInterfaces(ss.PubKey, unpacker) } diff --git a/x/auth/migrations/legacytx/stdsignmsg.go b/x/auth/migrations/legacytx/stdsignmsg.go index 561a64463f50..1fd8c585015f 100644 --- a/x/auth/migrations/legacytx/stdsignmsg.go +++ b/x/auth/migrations/legacytx/stdsignmsg.go @@ -1,11 +1,13 @@ package legacytx import ( + gogoprotoany "github.com/cosmos/gogoproto/types/any" + "github.com/cosmos/cosmos-sdk/codec/types" sdk "github.com/cosmos/cosmos-sdk/types" ) -var _ types.UnpackInterfacesMessage = StdSignMsg{} +var _ gogoprotoany.UnpackInterfacesMessage = StdSignMsg{} // StdSignMsg is a convenience structure for passing along a Msg with the other // requirements for a StdSignDoc before it is signed. For use in the CLI. @@ -19,7 +21,7 @@ type StdSignMsg struct { Memo string `json:"memo" yaml:"memo"` } -func (msg StdSignMsg) UnpackInterfaces(unpacker types.AnyUnpacker) error { +func (msg StdSignMsg) UnpackInterfaces(unpacker gogoprotoany.AnyUnpacker) error { for _, m := range msg.Msgs { err := types.UnpackInterfaces(m, unpacker) if err != nil { diff --git a/x/auth/migrations/legacytx/stdtx.go b/x/auth/migrations/legacytx/stdtx.go index dc5dba098860..5e67518716d5 100644 --- a/x/auth/migrations/legacytx/stdtx.go +++ b/x/auth/migrations/legacytx/stdtx.go @@ -1,6 +1,8 @@ package legacytx import ( + gogoprotoany "github.com/cosmos/gogoproto/types/any" + errorsmod "cosmossdk.io/errors" "cosmossdk.io/math" @@ -13,9 +15,9 @@ import ( // Interface implementation checks var ( - _ codectypes.UnpackInterfacesMessage = (*StdTx)(nil) + _ gogoprotoany.UnpackInterfacesMessage = (*StdTx)(nil) - _ codectypes.UnpackInterfacesMessage = (*StdSignature)(nil) + _ gogoprotoany.UnpackInterfacesMessage = (*StdSignature)(nil) ) // StdFee includes the amount of coins paid in fees and the maximum @@ -169,7 +171,7 @@ func (tx StdTx) FeeGranter() sdk.AccAddress { return nil } -func (tx StdTx) UnpackInterfaces(unpacker codectypes.AnyUnpacker) error { +func (tx StdTx) UnpackInterfaces(unpacker gogoprotoany.AnyUnpacker) error { for _, m := range tx.Msgs { err := codectypes.UnpackInterfaces(m, unpacker) if err != nil { diff --git a/x/auth/migrations/legacytx/stdtx_test.go b/x/auth/migrations/legacytx/stdtx_test.go index f49357ca6398..cdb28e978b2b 100644 --- a/x/auth/migrations/legacytx/stdtx_test.go +++ b/x/auth/migrations/legacytx/stdtx_test.go @@ -44,7 +44,7 @@ func TestStdSignBytes(t *testing.T) { Amount: []*basev1beta1.Coin{{Denom: "atom", Amount: "150"}}, GasLimit: 100000, } - msgStr := fmt.Sprintf(`{"type":"testpb/TestMsg","value":{"signers":["%s"]}}`, addr) + msgStr := fmt.Sprintf(`{"type":"testpb/TestMsg","value":{"decField":"0","signers":["%s"]}}`, addr) tests := []struct { name string args args diff --git a/x/auth/simulation/proposals.go b/x/auth/simulation/proposals.go index 244acb1975e1..78a5c09e2f86 100644 --- a/x/auth/simulation/proposals.go +++ b/x/auth/simulation/proposals.go @@ -1,6 +1,7 @@ package simulation import ( + "context" "math/rand" coreaddress "cosmossdk.io/core/address" @@ -22,7 +23,7 @@ const ( // ProposalMsgs defines the module weighted proposals' contents func ProposalMsgs() []simtypes.WeightedProposalMsg { return []simtypes.WeightedProposalMsg{ - simulation.NewWeightedProposalMsg( + simulation.NewWeightedProposalMsgX( OpWeightMsgUpdateParams, DefaultWeightMsgUpdateParams, SimulateMsgUpdateParams, @@ -31,7 +32,7 @@ func ProposalMsgs() []simtypes.WeightedProposalMsg { } // SimulateMsgUpdateParams returns a random MsgUpdateParams -func SimulateMsgUpdateParams(r *rand.Rand, _ []simtypes.Account, _ coreaddress.Codec) (sdk.Msg, error) { +func SimulateMsgUpdateParams(_ context.Context, r *rand.Rand, _ []simtypes.Account, _ coreaddress.Codec) (sdk.Msg, error) { // use the default gov module account address as authority var authority sdk.AccAddress = address.Module("gov") diff --git a/x/auth/simulation/proposals_test.go b/x/auth/simulation/proposals_test.go index bbe53b58ef48..b5fc4cf8aa5d 100644 --- a/x/auth/simulation/proposals_test.go +++ b/x/auth/simulation/proposals_test.go @@ -32,7 +32,7 @@ func TestProposalMsgs(t *testing.T) { assert.Equal(t, simulation.OpWeightMsgUpdateParams, w0.AppParamsKey()) assert.Equal(t, simulation.DefaultWeightMsgUpdateParams, w0.DefaultWeight()) - msg, err := w0.MsgSimulatorFn()(r, accounts, codectestutil.CodecOptions{}.GetAddressCodec()) + msg, err := w0.MsgSimulatorFn()(sdk.Context{}, r, accounts, codectestutil.CodecOptions{}.GetAddressCodec()) assert.NilError(t, err) msgUpdateParams, ok := msg.(*types.MsgUpdateParams) assert.Assert(t, ok) diff --git a/x/auth/tx/builder.go b/x/auth/tx/builder.go index 84dd54bb3002..af97b2e3c02a 100644 --- a/x/auth/tx/builder.go +++ b/x/auth/tx/builder.go @@ -3,9 +3,11 @@ package tx import ( "errors" "fmt" + "time" "google.golang.org/protobuf/proto" "google.golang.org/protobuf/types/known/anypb" + "google.golang.org/protobuf/types/known/timestamppb" basev1beta1 "cosmossdk.io/api/cosmos/base/v1beta1" multisigv1beta1 "cosmossdk.io/api/cosmos/crypto/multisig/v1beta1" @@ -79,16 +81,17 @@ type builder struct { decoder *decode.Decoder codec codec.BinaryCodec - msgs []sdk.Msg - timeoutHeight uint64 - granter []byte - payer []byte - unordered bool - memo string - gasLimit uint64 - fees sdk.Coins - signerInfos []*tx.SignerInfo - signatures [][]byte + msgs []sdk.Msg + timeoutHeight uint64 + timeoutTimestamp time.Time + granter []byte + payer []byte + unordered bool + memo string + gasLimit uint64 + fees sdk.Coins + signerInfos []*tx.SignerInfo + signatures [][]byte extensionOptions []*codectypes.Any nonCriticalExtensionOptions []*codectypes.Any @@ -115,6 +118,7 @@ func (w *builder) getTx() (*gogoTxWrapper, error) { Messages: anyMsgs, Memo: w.memo, TimeoutHeight: w.timeoutHeight, + TimeoutTimestamp: timestamppb.New(w.timeoutTimestamp), Unordered: w.unordered, ExtensionOptions: intoAnyV2(w.extensionOptions), NonCriticalExtensionOptions: intoAnyV2(w.nonCriticalExtensionOptions), @@ -189,6 +193,8 @@ func (w *builder) SetMsgs(msgs ...sdk.Msg) error { // SetTimeoutHeight sets the transaction's height timeout. func (w *builder) SetTimeoutHeight(height uint64) { w.timeoutHeight = height } +func (w *builder) SetTimeoutTimestamp(timestamp time.Time) { w.timeoutTimestamp = timestamp } + func (w *builder) SetUnordered(v bool) { w.unordered = v } func (w *builder) SetMemo(memo string) { w.memo = memo } diff --git a/x/auth/tx/decoder.go b/x/auth/tx/decoder.go index ed576ddf68c2..74b20621690b 100644 --- a/x/auth/tx/decoder.go +++ b/x/auth/tx/decoder.go @@ -1,36 +1,35 @@ package tx import ( - "google.golang.org/protobuf/encoding/protojson" + gogoproto "github.com/cosmos/gogoproto/proto" txv1beta1 "cosmossdk.io/api/cosmos/tx/v1beta1" "cosmossdk.io/core/address" + errorsmod "cosmossdk.io/errors" "cosmossdk.io/x/tx/decode" "github.com/cosmos/cosmos-sdk/codec" sdk "github.com/cosmos/cosmos-sdk/types" + sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" + "github.com/cosmos/cosmos-sdk/types/tx" ) // DefaultJSONTxDecoder returns a default protobuf JSON TxDecoder using the provided Marshaler. -func DefaultJSONTxDecoder(addrCodec address.Codec, cdc codec.BinaryCodec, decoder *decode.Decoder) sdk.TxDecoder { - jsonUnmarshaller := protojson.UnmarshalOptions{ - AllowPartial: false, - DiscardUnknown: false, - } +func DefaultJSONTxDecoder(addrCodec address.Codec, cdc codec.Codec, decoder *decode.Decoder) sdk.TxDecoder { return func(txBytes []byte) (sdk.Tx, error) { - jsonTx := new(txv1beta1.Tx) - err := jsonUnmarshaller.Unmarshal(txBytes, jsonTx) + var jsonTx tx.Tx + err := cdc.UnmarshalJSON(txBytes, &jsonTx) if err != nil { - return nil, err + return nil, errorsmod.Wrap(sdkerrors.ErrTxDecode, err.Error()) } // need to convert jsonTx into raw tx. - bodyBytes, err := marshalOption.Marshal(jsonTx.Body) + bodyBytes, err := gogoproto.Marshal(jsonTx.Body) if err != nil { return nil, err } - authInfoBytes, err := marshalOption.Marshal(jsonTx.AuthInfo) + authInfoBytes, err := gogoproto.Marshal(jsonTx.AuthInfo) if err != nil { return nil, err } diff --git a/x/auth/tx/encoder.go b/x/auth/tx/encoder.go index df15da9fca8e..f40e75962686 100644 --- a/x/auth/tx/encoder.go +++ b/x/auth/tx/encoder.go @@ -3,10 +3,12 @@ package tx import ( "fmt" - "google.golang.org/protobuf/encoding/protojson" + gogoproto "github.com/cosmos/gogoproto/proto" + "google.golang.org/protobuf/proto" "github.com/cosmos/cosmos-sdk/codec" sdk "github.com/cosmos/cosmos-sdk/types" + sdktx "github.com/cosmos/cosmos-sdk/types/tx" ) // DefaultTxEncoder returns a default protobuf TxEncoder using the provided Marshaler @@ -22,16 +24,28 @@ func DefaultTxEncoder() sdk.TxEncoder { // DefaultJSONTxEncoder returns a default protobuf JSON TxEncoder using the provided Marshaler. func DefaultJSONTxEncoder(cdc codec.Codec) sdk.TxEncoder { - jsonMarshaler := protojson.MarshalOptions{ - Indent: "", - UseProtoNames: true, - UseEnumNumbers: false, - } return func(tx sdk.Tx) ([]byte, error) { + // 1) Unwrap the tx gogoWrapper, ok := tx.(*gogoTxWrapper) if !ok { return nil, fmt.Errorf("unexpected tx type: %T", tx) } - return jsonMarshaler.Marshal(gogoWrapper.Tx) + // The unwrapped tx is a pulsar message, but SDK spec for marshaling JSON is AminoJSON. + // AminoJSON only operates on gogoproto structures, so we need to convert the pulsar message to a "v1" (gogoproto) Tx. + // see: https://github.com/cosmos/cosmos-sdk/issues/20431 and associated PRs for an eventual fix. + // + // 2) Marshal the pulsar message to bytes + bz, err := proto.Marshal(gogoWrapper.Tx) + if err != nil { + return nil, err + } + // 3) Umarshal the bytes to a "v1" (gogoproto) Tx + v1Tx := &sdktx.Tx{} + err = gogoproto.Unmarshal(bz, v1Tx) + if err != nil { + return nil, err + } + // 4) Marshal the "v1" (gogoproto) to Amino ProtoJSON + return cdc.MarshalJSON(v1Tx) } } diff --git a/x/auth/tx/gogotx.go b/x/auth/tx/gogotx.go index da129af50461..36d124206b03 100644 --- a/x/auth/tx/gogotx.go +++ b/x/auth/tx/gogotx.go @@ -4,6 +4,7 @@ import ( "fmt" "reflect" "strings" + "time" "github.com/cosmos/gogoproto/proto" "google.golang.org/protobuf/reflect/protoreflect" @@ -177,6 +178,11 @@ func (w *gogoTxWrapper) GetMemo() string { return w.Tx.Body.Memo } // GetTimeoutHeight returns the transaction's timeout height (if set). func (w *gogoTxWrapper) GetTimeoutHeight() uint64 { return w.Tx.Body.TimeoutHeight } +// GetTimeoutTimeStamp returns the transaction's timeout timestamp (if set). +func (w *gogoTxWrapper) GetTimeoutTimeStamp() time.Time { + return w.Tx.Body.TimeoutTimestamp.AsTime() +} + // GetUnordered returns the transaction's unordered field (if set). func (w *gogoTxWrapper) GetUnordered() bool { return w.Tx.Body.Unordered } diff --git a/x/auth/tx/testutil/suite.go b/x/auth/tx/testutil/suite.go index 1689fca40161..6ac4b25608c6 100644 --- a/x/auth/tx/testutil/suite.go +++ b/x/auth/tx/testutil/suite.go @@ -3,10 +3,12 @@ package testutil import ( "bytes" "context" + "strings" "github.com/stretchr/testify/suite" signingv1beta1 "cosmossdk.io/api/cosmos/tx/signing/v1beta1" + "cosmossdk.io/math" "cosmossdk.io/x/auth/signing" "github.com/cosmos/cosmos-sdk/client" @@ -74,7 +76,8 @@ func (s *TxConfigTestSuite) TestTxBuilderSetMsgs() { err := txBuilder.SetMsgs(msgs...) s.Require().NoError(err) tx := txBuilder.GetTx() - s.Require().Equal(msgs, tx.GetMsgs()) + unbuiltMsgs := tx.GetMsgs() + s.Require().Equal(msgs, unbuiltMsgs) signers, err := tx.GetSigners() s.Require().NoError(err) s.Require().Equal([][]byte{addr1, addr2}, signers) @@ -242,6 +245,8 @@ func (s *TxConfigTestSuite) TestTxEncodeDecode() { gasLimit := uint64(50000) memo := "foomemo" msg := testdata.NewTestMsg(addr) + pi := "3.141590000000000000" + msg.DecField = math.LegacyMustNewDecFromStr(pi) dummySig := []byte("dummySig") sig := signingtypes.SignatureV2{ PubKey: pubkey, @@ -286,6 +291,9 @@ func (s *TxConfigTestSuite) TestTxEncodeDecode() { jsonTxBytes, err := s.TxConfig.TxJSONEncoder()(tx) s.Require().NoError(err) s.Require().NotNil(jsonTxBytes) + // ensure the JSON representation contains the human read-able decimal value + s.Require().True(strings.Contains(string(jsonTxBytes), pi), + "expected %s to contain %s", string(jsonTxBytes), pi) log("JSON decode transaction") tx2, err = s.TxConfig.TxJSONDecoder()(jsonTxBytes) @@ -302,6 +310,8 @@ func (s *TxConfigTestSuite) TestTxEncodeDecode() { pks, err = tx3.GetPubKeys() s.Require().NoError(err) s.Require().Equal([]cryptotypes.PubKey{pubkey}, pks) + msg2 := tx2.GetMsgs()[0].(*testdata.TestMsg) + s.Require().Equal(pi, msg2.DecField.String()) } func (s *TxConfigTestSuite) TestWrapTxBuilder() { diff --git a/x/auth/types/account.go b/x/auth/types/account.go index 263c5ee41ee1..ccdff269125f 100644 --- a/x/auth/types/account.go +++ b/x/auth/types/account.go @@ -7,6 +7,8 @@ import ( "fmt" "strings" + gogoprotoany "github.com/cosmos/gogoproto/types/any" + codectypes "github.com/cosmos/cosmos-sdk/codec/types" cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types" sdk "github.com/cosmos/cosmos-sdk/types" @@ -14,11 +16,11 @@ import ( ) var ( - _ sdk.AccountI = (*BaseAccount)(nil) - _ GenesisAccount = (*BaseAccount)(nil) - _ codectypes.UnpackInterfacesMessage = (*BaseAccount)(nil) - _ GenesisAccount = (*ModuleAccount)(nil) - _ sdk.ModuleAccountI = (*ModuleAccount)(nil) + _ sdk.AccountI = (*BaseAccount)(nil) + _ GenesisAccount = (*BaseAccount)(nil) + _ gogoprotoany.UnpackInterfacesMessage = (*BaseAccount)(nil) + _ GenesisAccount = (*ModuleAccount)(nil) + _ sdk.ModuleAccountI = (*ModuleAccount)(nil) ) // NewBaseAccount creates a new BaseAccount object. @@ -132,7 +134,7 @@ func (acc BaseAccount) Validate() error { } // UnpackInterfaces implements UnpackInterfacesMessage.UnpackInterfaces -func (acc BaseAccount) UnpackInterfaces(unpacker codectypes.AnyUnpacker) error { +func (acc BaseAccount) UnpackInterfaces(unpacker gogoprotoany.AnyUnpacker) error { if acc.PubKey == nil { return nil } diff --git a/x/auth/types/genesis.go b/x/auth/types/genesis.go index b31c686bc43f..d0b6db9dbefd 100644 --- a/x/auth/types/genesis.go +++ b/x/auth/types/genesis.go @@ -7,6 +7,7 @@ import ( "sort" "github.com/cosmos/gogoproto/proto" + gogoprotoany "github.com/cosmos/gogoproto/types/any" "github.com/cosmos/cosmos-sdk/codec" "github.com/cosmos/cosmos-sdk/codec/types" @@ -14,7 +15,7 @@ import ( "github.com/cosmos/cosmos-sdk/types/module" ) -var _ types.UnpackInterfacesMessage = GenesisState{} +var _ gogoprotoany.UnpackInterfacesMessage = GenesisState{} // RandomGenesisAccountsFn defines the function required to generate custom account types type RandomGenesisAccountsFn func(simState *module.SimulationState) GenesisAccounts @@ -32,7 +33,7 @@ func NewGenesisState(params Params, accounts GenesisAccounts) *GenesisState { } // UnpackInterfaces implements UnpackInterfacesMessage.UnpackInterfaces -func (g GenesisState) UnpackInterfaces(unpacker types.AnyUnpacker) error { +func (g GenesisState) UnpackInterfaces(unpacker gogoprotoany.AnyUnpacker) error { for _, any := range g.Accounts { var account GenesisAccount err := unpacker.UnpackAny(any, &account) diff --git a/x/auth/types/query.go b/x/auth/types/query.go index 8ab9df38f9f0..96b089e18a74 100644 --- a/x/auth/types/query.go +++ b/x/auth/types/query.go @@ -1,13 +1,14 @@ package types import ( - codectypes "github.com/cosmos/cosmos-sdk/codec/types" + gogoprotoany "github.com/cosmos/gogoproto/types/any" + sdk "github.com/cosmos/cosmos-sdk/types" ) -func (m *QueryAccountResponse) UnpackInterfaces(unpacker codectypes.AnyUnpacker) error { +func (m *QueryAccountResponse) UnpackInterfaces(unpacker gogoprotoany.AnyUnpacker) error { var account sdk.AccountI return unpacker.UnpackAny(m.Account, &account) } -var _ codectypes.UnpackInterfacesMessage = &QueryAccountResponse{} +var _ gogoprotoany.UnpackInterfacesMessage = &QueryAccountResponse{} diff --git a/x/authz/authorization_grant.go b/x/authz/authorization_grant.go index 9dd8aced3791..c054eb081403 100644 --- a/x/authz/authorization_grant.go +++ b/x/authz/authorization_grant.go @@ -4,10 +4,10 @@ import ( "time" "github.com/cosmos/gogoproto/proto" + gogoprotoany "github.com/cosmos/gogoproto/types/any" errorsmod "cosmossdk.io/errors" - cdctypes "github.com/cosmos/cosmos-sdk/codec/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" ) @@ -22,7 +22,7 @@ func NewGrant(blockTime time.Time, a Authorization, expiration *time.Time) (Gran if !ok { return Grant{}, sdkerrors.ErrPackAny.Wrapf("cannot proto marshal %T", a) } - any, err := cdctypes.NewAnyWithValue(msg) + any, err := gogoprotoany.NewAnyWithCacheWithValue(msg) if err != nil { return Grant{}, err } @@ -32,10 +32,10 @@ func NewGrant(blockTime time.Time, a Authorization, expiration *time.Time) (Gran }, nil } -var _ cdctypes.UnpackInterfacesMessage = &Grant{} +var _ gogoprotoany.UnpackInterfacesMessage = &Grant{} // UnpackInterfaces implements UnpackInterfacesMessage.UnpackInterfaces -func (g Grant) UnpackInterfaces(unpacker cdctypes.AnyUnpacker) error { +func (g Grant) UnpackInterfaces(unpacker gogoprotoany.AnyUnpacker) error { var authorization Authorization return unpacker.UnpackAny(g.Authorization, &authorization) } diff --git a/x/authz/genesis.go b/x/authz/genesis.go index 2e7dde1b7260..f2afc47cad91 100644 --- a/x/authz/genesis.go +++ b/x/authz/genesis.go @@ -3,7 +3,7 @@ package authz import ( "fmt" - cdctypes "github.com/cosmos/cosmos-sdk/codec/types" + gogoprotoany "github.com/cosmos/gogoproto/types/any" ) // NewGenesisState creates new GenesisState object @@ -32,10 +32,10 @@ func DefaultGenesisState() *GenesisState { return &GenesisState{} } -var _ cdctypes.UnpackInterfacesMessage = GenesisState{} +var _ gogoprotoany.UnpackInterfacesMessage = GenesisState{} // UnpackInterfaces implements UnpackInterfacesMessage.UnpackInterfaces -func (data GenesisState) UnpackInterfaces(unpacker cdctypes.AnyUnpacker) error { +func (data GenesisState) UnpackInterfaces(unpacker gogoprotoany.AnyUnpacker) error { for _, a := range data.Authorization { err := a.UnpackInterfaces(unpacker) if err != nil { @@ -46,7 +46,7 @@ func (data GenesisState) UnpackInterfaces(unpacker cdctypes.AnyUnpacker) error { } // UnpackInterfaces implements UnpackInterfacesMessage.UnpackInterfaces -func (msg GrantAuthorization) UnpackInterfaces(unpacker cdctypes.AnyUnpacker) error { +func (msg GrantAuthorization) UnpackInterfaces(unpacker gogoprotoany.AnyUnpacker) error { var a Authorization return unpacker.UnpackAny(msg.Authorization, &a) } diff --git a/x/authz/go.mod b/x/authz/go.mod index 8b97249bdc4d..648be6a3102c 100644 --- a/x/authz/go.mod +++ b/x/authz/go.mod @@ -5,7 +5,7 @@ go 1.22.2 require ( cosmossdk.io/api v0.7.5 cosmossdk.io/core v0.12.1-0.20231114100755-569e3ff6a0d7 - cosmossdk.io/depinject v1.0.0-alpha.4 + cosmossdk.io/depinject v1.0.0 cosmossdk.io/errors v1.0.1 cosmossdk.io/math v1.3.0 cosmossdk.io/store v1.1.1-0.20240418092142-896cdf1971bc @@ -15,7 +15,7 @@ require ( github.com/cockroachdb/tokenbucket v0.0.0-20230807174530-cc333fc44b06 // indirect github.com/cometbft/cometbft v1.0.0-rc1 github.com/cosmos/cosmos-proto v1.0.0-beta.5 - github.com/cosmos/cosmos-sdk v0.51.0 + github.com/cosmos/cosmos-sdk v0.53.0 github.com/cosmos/gogoproto v1.5.0 github.com/golang/mock v1.6.0 github.com/golang/protobuf v1.5.4 @@ -30,6 +30,7 @@ require ( require ( buf.build/gen/go/cometbft/cometbft/protocolbuffers/go v1.34.2-20240701160653-fedbb9acfd2f.2 // indirect cosmossdk.io/collections v0.4.0 // indirect + cosmossdk.io/core/testing v0.0.0-00010101000000-000000000000 cosmossdk.io/x/auth v0.0.0-00010101000000-000000000000 cosmossdk.io/x/consensus v0.0.0-00010101000000-000000000000 // indirect filippo.io/edwards25519 v1.1.0 // indirect @@ -53,7 +54,7 @@ require ( github.com/cosmos/crypto v0.1.2 // indirect github.com/cosmos/go-bip39 v1.0.0 // indirect github.com/cosmos/gogogateway v1.2.0 // indirect - github.com/cosmos/iavl v1.2.0 // indirect + github.com/cosmos/iavl v1.2.1-0.20240725141113-7adc688cf179 // indirect github.com/cosmos/ics23/go v0.10.0 // indirect github.com/cosmos/ledger-cosmos-go v0.13.3 // indirect github.com/danieljoos/wincred v1.2.1 // indirect @@ -165,11 +166,10 @@ require ( sigs.k8s.io/yaml v1.4.0 // indirect ) -require cosmossdk.io/core/testing v0.0.0-00010101000000-000000000000 +require cosmossdk.io/log v1.3.1 require ( buf.build/gen/go/cosmos/gogo-proto/protocolbuffers/go v1.34.2-20240130113600-88ef6483f90f.2 // indirect - cosmossdk.io/log v1.3.1 // indirect cosmossdk.io/schema v0.1.1 // indirect github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect ) @@ -182,9 +182,6 @@ replace ( cosmossdk.io/collections => ../../collections cosmossdk.io/core => ../../core cosmossdk.io/core/testing => ../../core/testing - cosmossdk.io/depinject => ../../depinject - cosmossdk.io/log => ../../log - cosmossdk.io/logger => ../../logger cosmossdk.io/store => ../../store cosmossdk.io/x/accounts => ../accounts cosmossdk.io/x/auth => ../auth diff --git a/x/authz/go.sum b/x/authz/go.sum index 70ef03925e0a..8d4b41eff915 100644 --- a/x/authz/go.sum +++ b/x/authz/go.sum @@ -4,8 +4,12 @@ buf.build/gen/go/cosmos/gogo-proto/protocolbuffers/go v1.34.2-20240130113600-88e buf.build/gen/go/cosmos/gogo-proto/protocolbuffers/go v1.34.2-20240130113600-88ef6483f90f.2/go.mod h1:HqcXMSa5qnNuakaMUo+hWhF51mKbcrZxGl9Vp5EeJXc= cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= cloud.google.com/go v0.34.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= +cosmossdk.io/depinject v1.0.0 h1:dQaTu6+O6askNXO06+jyeUAnF2/ssKwrrszP9t5q050= +cosmossdk.io/depinject v1.0.0/go.mod h1:zxK/h3HgHoA/eJVtiSsoaRaRA2D5U4cJ5thIG4ssbB8= cosmossdk.io/errors v1.0.1 h1:bzu+Kcr0kS/1DuPBtUFdWjzLqyUuCiyHjyJB6srBV/0= cosmossdk.io/errors v1.0.1/go.mod h1:MeelVSZThMi4bEakzhhhE/CKqVv3nOJDA25bIqRDu/U= +cosmossdk.io/log v1.3.1 h1:UZx8nWIkfbbNEWusZqzAx3ZGvu54TZacWib3EzUYmGI= +cosmossdk.io/log v1.3.1/go.mod h1:2/dIomt8mKdk6vl3OWJcPk2be3pGOS8OQaLUM/3/tCM= cosmossdk.io/math v1.3.0 h1:RC+jryuKeytIiictDslBP9i1fhkVm6ZDmZEoNP316zE= cosmossdk.io/math v1.3.0/go.mod h1:vnRTxewy+M7BtXBNFybkuhSH4WfedVAAnERHgVFhp3k= cosmossdk.io/schema v0.1.1 h1:I0M6pgI7R10nq+/HCQfbO6BsGBZA8sQy+duR1Y3aKcA= @@ -107,8 +111,8 @@ github.com/cosmos/gogogateway v1.2.0/go.mod h1:iQpLkGWxYcnCdz5iAdLcRBSw3h7NXeOkZ github.com/cosmos/gogoproto v1.4.2/go.mod h1:cLxOsn1ljAHSV527CHOtaIP91kK6cCrZETRBrkzItWU= github.com/cosmos/gogoproto v1.5.0 h1:SDVwzEqZDDBoslaeZg+dGE55hdzHfgUA40pEanMh52o= github.com/cosmos/gogoproto v1.5.0/go.mod h1:iUM31aofn3ymidYG6bUR5ZFrk+Om8p5s754eMUcyp8I= -github.com/cosmos/iavl v1.2.0 h1:kVxTmjTh4k0Dh1VNL046v6BXqKziqMDzxo93oh3kOfM= -github.com/cosmos/iavl v1.2.0/go.mod h1:HidWWLVAtODJqFD6Hbne2Y0q3SdxByJepHUOeoH4LiI= +github.com/cosmos/iavl v1.2.1-0.20240725141113-7adc688cf179 h1:wmwDn7V3RodN9auB3FooSQxs46nHVE3u0mb87TJkZFE= +github.com/cosmos/iavl v1.2.1-0.20240725141113-7adc688cf179/go.mod h1:GiM43q0pB+uG53mLxLDzimxM9l/5N9UuSY3/D0huuVw= github.com/cosmos/ics23/go v0.10.0 h1:iXqLLgp2Lp+EdpIuwXTYIQU+AiHj9mOC2X9ab++bZDM= github.com/cosmos/ics23/go v0.10.0/go.mod h1:ZfJSmng/TBNTBkFemHHHj5YY7VAU/MBU980F4VU1NG0= github.com/cosmos/ledger-cosmos-go v0.13.3 h1:7ehuBGuyIytsXbd4MP43mLeoN2LTOEnk5nvue4rK+yM= diff --git a/x/authz/keeper/genesis_test.go b/x/authz/keeper/genesis_test.go index 20a4c0acb168..6cc9db972025 100644 --- a/x/authz/keeper/genesis_test.go +++ b/x/authz/keeper/genesis_test.go @@ -9,6 +9,7 @@ import ( "cosmossdk.io/core/header" coretesting "cosmossdk.io/core/testing" + "cosmossdk.io/log" sdkmath "cosmossdk.io/math" storetypes "cosmossdk.io/store/types" "cosmossdk.io/x/authz/keeper" @@ -58,7 +59,7 @@ func (suite *GenesisTestSuite) SetupTest() { suite.baseApp = baseapp.NewBaseApp( "authz", - coretesting.NewNopLogger(), + log.NewNopLogger(), testCtx.DB, suite.encCfg.TxConfig.TxDecoder(), ) diff --git a/x/authz/keeper/keeper_test.go b/x/authz/keeper/keeper_test.go index ac8cda6adb65..72bd049b1c79 100644 --- a/x/authz/keeper/keeper_test.go +++ b/x/authz/keeper/keeper_test.go @@ -9,6 +9,7 @@ import ( "cosmossdk.io/core/header" coretesting "cosmossdk.io/core/testing" + "cosmossdk.io/log" storetypes "cosmossdk.io/store/types" "cosmossdk.io/x/authz" authzkeeper "cosmossdk.io/x/authz/keeper" @@ -56,7 +57,7 @@ func (s *TestSuite) SetupTest() { s.baseApp = baseapp.NewBaseApp( "authz", - coretesting.NewNopLogger(), + log.NewNopLogger(), testCtx.DB, s.encCfg.TxConfig.TxDecoder(), ) diff --git a/x/authz/module/abci_test.go b/x/authz/module/abci_test.go index b2c8dbb9f5aa..00fda78e2a53 100644 --- a/x/authz/module/abci_test.go +++ b/x/authz/module/abci_test.go @@ -9,6 +9,7 @@ import ( "cosmossdk.io/core/header" coretesting "cosmossdk.io/core/testing" + "cosmossdk.io/log" storetypes "cosmossdk.io/store/types" authtypes "cosmossdk.io/x/auth/types" "cosmossdk.io/x/authz" @@ -36,7 +37,7 @@ func TestExpiredGrantsQueue(t *testing.T) { baseApp := baseapp.NewBaseApp( "authz", - coretesting.NewNopLogger(), + log.NewNopLogger(), testCtx.DB, encCfg.TxConfig.TxDecoder(), ) diff --git a/x/authz/msgs.go b/x/authz/msgs.go index 0964f45cb34b..b7c7c6c9cd30 100644 --- a/x/authz/msgs.go +++ b/x/authz/msgs.go @@ -4,6 +4,7 @@ import ( "time" "github.com/cosmos/gogoproto/proto" + gogoprotoany "github.com/cosmos/gogoproto/types/any" cdctypes "github.com/cosmos/cosmos-sdk/codec/types" sdk "github.com/cosmos/cosmos-sdk/types" @@ -15,8 +16,8 @@ var ( _ sdk.Msg = &MsgRevoke{} _ sdk.Msg = &MsgExec{} - _ cdctypes.UnpackInterfacesMessage = &MsgGrant{} - _ cdctypes.UnpackInterfacesMessage = &MsgExec{} + _ gogoprotoany.UnpackInterfacesMessage = &MsgGrant{} + _ gogoprotoany.UnpackInterfacesMessage = &MsgExec{} ) // NewMsgGrant creates a new MsgGrant @@ -44,7 +45,7 @@ func (msg *MsgGrant) SetAuthorization(a Authorization) error { if !ok { return sdkerrors.ErrPackAny.Wrapf("can't proto marshal %T", m) } - any, err := cdctypes.NewAnyWithValue(m) + any, err := gogoprotoany.NewAnyWithCacheWithValue(m) if err != nil { return err } @@ -53,7 +54,7 @@ func (msg *MsgGrant) SetAuthorization(a Authorization) error { } // UnpackInterfaces implements UnpackInterfacesMessage.UnpackInterfaces -func (msg MsgExec) UnpackInterfaces(unpacker cdctypes.AnyUnpacker) error { +func (msg MsgExec) UnpackInterfaces(unpacker gogoprotoany.AnyUnpacker) error { for _, x := range msg.Msgs { var msgExecAuthorized sdk.Msg err := unpacker.UnpackAny(x, &msgExecAuthorized) @@ -66,7 +67,7 @@ func (msg MsgExec) UnpackInterfaces(unpacker cdctypes.AnyUnpacker) error { } // UnpackInterfaces implements UnpackInterfacesMessage.UnpackInterfaces -func (msg MsgGrant) UnpackInterfaces(unpacker cdctypes.AnyUnpacker) error { +func (msg MsgGrant) UnpackInterfaces(unpacker gogoprotoany.AnyUnpacker) error { return msg.Grant.UnpackInterfaces(unpacker) } diff --git a/x/authz/simulation/operations.go b/x/authz/simulation/operations.go index ec62f5196b2f..4c7c085d3b70 100644 --- a/x/authz/simulation/operations.go +++ b/x/authz/simulation/operations.go @@ -5,6 +5,8 @@ import ( "math/rand" "time" + gogoprotoany "github.com/cosmos/gogoproto/types/any" + "cosmossdk.io/core/address" "cosmossdk.io/core/appmodule" corecontext "cosmossdk.io/core/context" @@ -14,7 +16,6 @@ import ( "cosmossdk.io/x/authz/keeper" banktype "cosmossdk.io/x/bank/types" - "github.com/cosmos/cosmos-sdk/baseapp" "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/codec" cdctypes "github.com/cosmos/cosmos-sdk/codec/types" @@ -101,7 +102,7 @@ func SimulateMsgGrant( _ keeper.Keeper, ) simtypes.Operation { return func( - r *rand.Rand, app *baseapp.BaseApp, ctx sdk.Context, accs []simtypes.Account, chainID string, + r *rand.Rand, app simtypes.AppEntrypoint, ctx sdk.Context, accs []simtypes.Account, chainID string, ) (simtypes.OperationMsg, []simtypes.FutureOperation, error) { granter, _ := simtypes.RandomAcc(r, accs) grantee, _ := simtypes.RandomAcc(r, accs) @@ -182,7 +183,7 @@ func SimulateMsgRevoke( k keeper.Keeper, ) simtypes.Operation { return func( - r *rand.Rand, app *baseapp.BaseApp, ctx sdk.Context, accs []simtypes.Account, chainID string, + r *rand.Rand, app simtypes.AppEntrypoint, ctx sdk.Context, accs []simtypes.Account, chainID string, ) (simtypes.OperationMsg, []simtypes.FutureOperation, error) { var granterAddr, granteeAddr sdk.AccAddress var grant authz.Grant @@ -260,10 +261,10 @@ func SimulateMsgExec( ak authz.AccountKeeper, bk authz.BankKeeper, k keeper.Keeper, - unpacker cdctypes.AnyUnpacker, + unpacker gogoprotoany.AnyUnpacker, ) simtypes.Operation { return func( - r *rand.Rand, app *baseapp.BaseApp, ctx sdk.Context, accs []simtypes.Account, chainID string, + r *rand.Rand, app simtypes.AppEntrypoint, ctx sdk.Context, accs []simtypes.Account, chainID string, ) (simtypes.OperationMsg, []simtypes.FutureOperation, error) { var granterAddr sdk.AccAddress var granteeAddr sdk.AccAddress diff --git a/x/bank/client/cli/tx.go b/x/bank/client/cli/tx.go index a480d3b1a2cc..1e86b92f7564 100644 --- a/x/bank/client/cli/tx.go +++ b/x/bank/client/cli/tx.go @@ -1,6 +1,7 @@ package cli import ( + "errors" "fmt" "github.com/spf13/cobra" @@ -64,7 +65,7 @@ When using '--dry-run' a key name cannot be used, only a bech32 address.`, } if coins.IsZero() { - return fmt.Errorf("must send positive amount") + return errors.New("must send positive amount") } split, err := cmd.Flags().GetBool(FlagSplit) diff --git a/x/bank/go.mod b/x/bank/go.mod index a55c27bf07a7..ff9bb6ebbcb0 100644 --- a/x/bank/go.mod +++ b/x/bank/go.mod @@ -6,7 +6,7 @@ require ( cosmossdk.io/api v0.7.5 cosmossdk.io/collections v0.4.0 cosmossdk.io/core v0.12.1-0.20231114100755-569e3ff6a0d7 - cosmossdk.io/depinject v1.0.0-alpha.4 + cosmossdk.io/depinject v1.0.0 cosmossdk.io/errors v1.0.1 cosmossdk.io/log v1.3.1 // indirect cosmossdk.io/math v1.3.0 @@ -14,7 +14,7 @@ require ( github.com/cockroachdb/tokenbucket v0.0.0-20230807174530-cc333fc44b06 // indirect github.com/cometbft/cometbft v1.0.0-rc1 github.com/cosmos/cosmos-proto v1.0.0-beta.5 - github.com/cosmos/cosmos-sdk v0.51.0 + github.com/cosmos/cosmos-sdk v0.53.0 github.com/cosmos/gogoproto v1.5.0 github.com/golang/mock v1.6.0 github.com/golang/protobuf v1.5.4 @@ -55,7 +55,7 @@ require ( github.com/cosmos/crypto v0.1.2 // indirect github.com/cosmos/go-bip39 v1.0.0 // indirect github.com/cosmos/gogogateway v1.2.0 // indirect - github.com/cosmos/iavl v1.2.0 // indirect + github.com/cosmos/iavl v1.2.1-0.20240725141113-7adc688cf179 // indirect github.com/cosmos/ics23/go v0.10.0 // indirect github.com/cosmos/ledger-cosmos-go v0.13.3 // indirect github.com/danieljoos/wincred v1.2.1 // indirect @@ -181,8 +181,6 @@ replace ( cosmossdk.io/collections => ../../collections cosmossdk.io/core => ../../core cosmossdk.io/core/testing => ../../core/testing - cosmossdk.io/depinject => ../../depinject - cosmossdk.io/log => ../../log cosmossdk.io/x/accounts => ../accounts cosmossdk.io/x/auth => ../auth cosmossdk.io/x/consensus => ../consensus diff --git a/x/bank/go.sum b/x/bank/go.sum index 7c6b086874ef..4e269960625f 100644 --- a/x/bank/go.sum +++ b/x/bank/go.sum @@ -4,8 +4,12 @@ buf.build/gen/go/cosmos/gogo-proto/protocolbuffers/go v1.34.2-20240130113600-88e buf.build/gen/go/cosmos/gogo-proto/protocolbuffers/go v1.34.2-20240130113600-88ef6483f90f.2/go.mod h1:HqcXMSa5qnNuakaMUo+hWhF51mKbcrZxGl9Vp5EeJXc= cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= cloud.google.com/go v0.34.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= +cosmossdk.io/depinject v1.0.0 h1:dQaTu6+O6askNXO06+jyeUAnF2/ssKwrrszP9t5q050= +cosmossdk.io/depinject v1.0.0/go.mod h1:zxK/h3HgHoA/eJVtiSsoaRaRA2D5U4cJ5thIG4ssbB8= cosmossdk.io/errors v1.0.1 h1:bzu+Kcr0kS/1DuPBtUFdWjzLqyUuCiyHjyJB6srBV/0= cosmossdk.io/errors v1.0.1/go.mod h1:MeelVSZThMi4bEakzhhhE/CKqVv3nOJDA25bIqRDu/U= +cosmossdk.io/log v1.3.1 h1:UZx8nWIkfbbNEWusZqzAx3ZGvu54TZacWib3EzUYmGI= +cosmossdk.io/log v1.3.1/go.mod h1:2/dIomt8mKdk6vl3OWJcPk2be3pGOS8OQaLUM/3/tCM= cosmossdk.io/math v1.3.0 h1:RC+jryuKeytIiictDslBP9i1fhkVm6ZDmZEoNP316zE= cosmossdk.io/math v1.3.0/go.mod h1:vnRTxewy+M7BtXBNFybkuhSH4WfedVAAnERHgVFhp3k= cosmossdk.io/schema v0.1.1 h1:I0M6pgI7R10nq+/HCQfbO6BsGBZA8sQy+duR1Y3aKcA= @@ -109,8 +113,8 @@ github.com/cosmos/gogogateway v1.2.0/go.mod h1:iQpLkGWxYcnCdz5iAdLcRBSw3h7NXeOkZ github.com/cosmos/gogoproto v1.4.2/go.mod h1:cLxOsn1ljAHSV527CHOtaIP91kK6cCrZETRBrkzItWU= github.com/cosmos/gogoproto v1.5.0 h1:SDVwzEqZDDBoslaeZg+dGE55hdzHfgUA40pEanMh52o= github.com/cosmos/gogoproto v1.5.0/go.mod h1:iUM31aofn3ymidYG6bUR5ZFrk+Om8p5s754eMUcyp8I= -github.com/cosmos/iavl v1.2.0 h1:kVxTmjTh4k0Dh1VNL046v6BXqKziqMDzxo93oh3kOfM= -github.com/cosmos/iavl v1.2.0/go.mod h1:HidWWLVAtODJqFD6Hbne2Y0q3SdxByJepHUOeoH4LiI= +github.com/cosmos/iavl v1.2.1-0.20240725141113-7adc688cf179 h1:wmwDn7V3RodN9auB3FooSQxs46nHVE3u0mb87TJkZFE= +github.com/cosmos/iavl v1.2.1-0.20240725141113-7adc688cf179/go.mod h1:GiM43q0pB+uG53mLxLDzimxM9l/5N9UuSY3/D0huuVw= github.com/cosmos/ics23/go v0.10.0 h1:iXqLLgp2Lp+EdpIuwXTYIQU+AiHj9mOC2X9ab++bZDM= github.com/cosmos/ics23/go v0.10.0/go.mod h1:ZfJSmng/TBNTBkFemHHHj5YY7VAU/MBU980F4VU1NG0= github.com/cosmos/ledger-cosmos-go v0.13.3 h1:7ehuBGuyIytsXbd4MP43mLeoN2LTOEnk5nvue4rK+yM= diff --git a/x/bank/keeper/keeper.go b/x/bank/keeper/keeper.go index 31e4720bbd4d..03f01765c673 100644 --- a/x/bank/keeper/keeper.go +++ b/x/bank/keeper/keeper.go @@ -6,7 +6,6 @@ import ( "cosmossdk.io/core/appmodule" "cosmossdk.io/core/event" - "cosmossdk.io/core/log" errorsmod "cosmossdk.io/errors" "cosmossdk.io/math" authtypes "cosmossdk.io/x/auth/types" @@ -92,9 +91,6 @@ func NewBaseKeeper( panic(fmt.Errorf("invalid bank authority address: %w", err)) } - // add the module name to the logger - env.Logger = env.Logger.With(log.ModuleKey, "x/"+types.ModuleName) - return BaseKeeper{ Environment: env, BaseSendKeeper: NewBaseSendKeeper(env, cdc, ak, blockedAddrs, authority), diff --git a/x/bank/simulation/operations.go b/x/bank/simulation/operations.go index b3933b6d01e1..d662687cfe07 100644 --- a/x/bank/simulation/operations.go +++ b/x/bank/simulation/operations.go @@ -6,7 +6,6 @@ import ( "cosmossdk.io/x/bank/keeper" "cosmossdk.io/x/bank/types" - "github.com/cosmos/cosmos-sdk/baseapp" "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/codec" cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types" @@ -63,7 +62,7 @@ func SimulateMsgSend( bk keeper.Keeper, ) simtypes.Operation { return func( - r *rand.Rand, app *baseapp.BaseApp, ctx sdk.Context, + r *rand.Rand, app simtypes.AppEntrypoint, ctx sdk.Context, accs []simtypes.Account, chainID string, ) (simtypes.OperationMsg, []simtypes.FutureOperation, error) { msgType := sdk.MsgTypeURL(&types.MsgSend{}) @@ -110,7 +109,7 @@ func SimulateMsgSendToModuleAccount( moduleAccount int, ) simtypes.Operation { return func( - r *rand.Rand, app *baseapp.BaseApp, ctx sdk.Context, + r *rand.Rand, app simtypes.AppEntrypoint, ctx sdk.Context, accs []simtypes.Account, chainID string, ) (simtypes.OperationMsg, []simtypes.FutureOperation, error) { msgType := sdk.MsgTypeURL(&types.MsgSend{}) @@ -146,7 +145,7 @@ func SimulateMsgSendToModuleAccount( // sendMsgSend sends a transaction with a MsgSend from a provided random account. func sendMsgSend( - r *rand.Rand, app *baseapp.BaseApp, + r *rand.Rand, app simtypes.AppEntrypoint, txGen client.TxConfig, bk keeper.Keeper, ak types.AccountKeeper, msg *types.MsgSend, ctx sdk.Context, chainID string, privkeys []cryptotypes.PrivKey, @@ -198,7 +197,7 @@ func sendMsgSend( // all accounts in msg fields exist in state func SimulateMsgMultiSend(txGen client.TxConfig, ak types.AccountKeeper, bk keeper.Keeper) simtypes.Operation { return func( - r *rand.Rand, app *baseapp.BaseApp, ctx sdk.Context, + r *rand.Rand, app simtypes.AppEntrypoint, ctx sdk.Context, accs []simtypes.Account, chainID string, ) (simtypes.OperationMsg, []simtypes.FutureOperation, error) { msgType := sdk.MsgTypeURL(&types.MsgMultiSend{}) @@ -302,7 +301,7 @@ func SimulateMsgMultiSendToModuleAccount( moduleAccount int, ) simtypes.Operation { return func( - r *rand.Rand, app *baseapp.BaseApp, ctx sdk.Context, + r *rand.Rand, app simtypes.AppEntrypoint, ctx sdk.Context, accs []simtypes.Account, chainID string, ) (simtypes.OperationMsg, []simtypes.FutureOperation, error) { msgType := sdk.MsgTypeURL(&types.MsgMultiSend{}) @@ -370,7 +369,7 @@ func SimulateMsgMultiSendToModuleAccount( // sendMsgMultiSend sends a transaction with a MsgMultiSend from a provided random // account. func sendMsgMultiSend( - r *rand.Rand, app *baseapp.BaseApp, + r *rand.Rand, app simtypes.AppEntrypoint, txGen client.TxConfig, bk keeper.Keeper, ak types.AccountKeeper, msg *types.MsgMultiSend, ctx sdk.Context, chainID string, privkeys []cryptotypes.PrivKey, diff --git a/x/bank/simulation/proposals.go b/x/bank/simulation/proposals.go index 7e2683fed6cb..ec9f637240d9 100644 --- a/x/bank/simulation/proposals.go +++ b/x/bank/simulation/proposals.go @@ -1,6 +1,7 @@ package simulation import ( + "context" "math/rand" coreaddress "cosmossdk.io/core/address" @@ -22,7 +23,7 @@ const ( // ProposalMsgs defines the module weighted proposals' contents func ProposalMsgs() []simtypes.WeightedProposalMsg { return []simtypes.WeightedProposalMsg{ - simulation.NewWeightedProposalMsg( + simulation.NewWeightedProposalMsgX( OpWeightMsgUpdateParams, DefaultWeightMsgUpdateParams, SimulateMsgUpdateParams, @@ -31,7 +32,7 @@ func ProposalMsgs() []simtypes.WeightedProposalMsg { } // SimulateMsgUpdateParams returns a random MsgUpdateParams -func SimulateMsgUpdateParams(r *rand.Rand, _ []simtypes.Account, ac coreaddress.Codec) (sdk.Msg, error) { +func SimulateMsgUpdateParams(_ context.Context, r *rand.Rand, _ []simtypes.Account, ac coreaddress.Codec) (sdk.Msg, error) { // use the default gov module account address as authority authority, err := ac.BytesToString(address.Module("gov")) if err != nil { diff --git a/x/bank/simulation/proposals_test.go b/x/bank/simulation/proposals_test.go index 3d60a17bbb91..50d7fc0ad5d3 100644 --- a/x/bank/simulation/proposals_test.go +++ b/x/bank/simulation/proposals_test.go @@ -1,6 +1,7 @@ package simulation_test import ( + "context" "math/rand" "testing" @@ -33,7 +34,7 @@ func TestProposalMsgs(t *testing.T) { assert.Equal(t, simulation.OpWeightMsgUpdateParams, w0.AppParamsKey()) assert.Equal(t, simulation.DefaultWeightMsgUpdateParams, w0.DefaultWeight()) - msg, err := w0.MsgSimulatorFn()(r, accounts, ac) + msg, err := w0.MsgSimulatorFn()(context.Background(), r, accounts, ac) assert.NilError(t, err) msgUpdateParams, ok := msg.(*types.MsgUpdateParams) assert.Assert(t, ok) diff --git a/x/circuit/go.mod b/x/circuit/go.mod index 2d8a15a32a9b..17b772ed428e 100644 --- a/x/circuit/go.mod +++ b/x/circuit/go.mod @@ -7,11 +7,11 @@ require ( cosmossdk.io/collections v0.4.0 cosmossdk.io/core v0.12.1-0.20231114100755-569e3ff6a0d7 cosmossdk.io/core/testing v0.0.0-00010101000000-000000000000 - cosmossdk.io/depinject v1.0.0-alpha.4 + cosmossdk.io/depinject v1.0.0 cosmossdk.io/errors v1.0.1 cosmossdk.io/store v1.1.1-0.20240418092142-896cdf1971bc cosmossdk.io/x/auth v0.0.0-00010101000000-000000000000 - github.com/cosmos/cosmos-sdk v0.51.0 + github.com/cosmos/cosmos-sdk v0.53.0 github.com/cosmos/gogoproto v1.5.0 github.com/golang/protobuf v1.5.4 github.com/grpc-ecosystem/grpc-gateway v1.16.0 @@ -54,7 +54,7 @@ require ( github.com/cosmos/crypto v0.1.2 // indirect github.com/cosmos/go-bip39 v1.0.0 // indirect github.com/cosmos/gogogateway v1.2.0 // indirect - github.com/cosmos/iavl v1.2.0 // indirect + github.com/cosmos/iavl v1.2.1-0.20240725141113-7adc688cf179 // indirect github.com/cosmos/ics23/go v0.10.0 // indirect github.com/cosmos/ledger-cosmos-go v0.13.3 // indirect github.com/danieljoos/wincred v1.2.1 // indirect @@ -177,8 +177,6 @@ replace ( cosmossdk.io/api => ../../api cosmossdk.io/core => ../../core cosmossdk.io/core/testing => ../../core/testing - cosmossdk.io/depinject => ../../depinject - cosmossdk.io/log => ../../log cosmossdk.io/x/accounts => ../accounts cosmossdk.io/x/auth => ../auth cosmossdk.io/x/bank => ../bank diff --git a/x/circuit/go.sum b/x/circuit/go.sum index c2479081cac7..81d16c68890c 100644 --- a/x/circuit/go.sum +++ b/x/circuit/go.sum @@ -6,8 +6,12 @@ cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMT cloud.google.com/go v0.34.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= cosmossdk.io/collections v0.4.0 h1:PFmwj2W8szgpD5nOd8GWH6AbYNi1f2J6akWXJ7P5t9s= cosmossdk.io/collections v0.4.0/go.mod h1:oa5lUING2dP+gdDquow+QjlF45eL1t4TJDypgGd+tv0= +cosmossdk.io/depinject v1.0.0 h1:dQaTu6+O6askNXO06+jyeUAnF2/ssKwrrszP9t5q050= +cosmossdk.io/depinject v1.0.0/go.mod h1:zxK/h3HgHoA/eJVtiSsoaRaRA2D5U4cJ5thIG4ssbB8= cosmossdk.io/errors v1.0.1 h1:bzu+Kcr0kS/1DuPBtUFdWjzLqyUuCiyHjyJB6srBV/0= cosmossdk.io/errors v1.0.1/go.mod h1:MeelVSZThMi4bEakzhhhE/CKqVv3nOJDA25bIqRDu/U= +cosmossdk.io/log v1.3.1 h1:UZx8nWIkfbbNEWusZqzAx3ZGvu54TZacWib3EzUYmGI= +cosmossdk.io/log v1.3.1/go.mod h1:2/dIomt8mKdk6vl3OWJcPk2be3pGOS8OQaLUM/3/tCM= cosmossdk.io/math v1.3.0 h1:RC+jryuKeytIiictDslBP9i1fhkVm6ZDmZEoNP316zE= cosmossdk.io/math v1.3.0/go.mod h1:vnRTxewy+M7BtXBNFybkuhSH4WfedVAAnERHgVFhp3k= cosmossdk.io/schema v0.1.1 h1:I0M6pgI7R10nq+/HCQfbO6BsGBZA8sQy+duR1Y3aKcA= @@ -111,8 +115,8 @@ github.com/cosmos/gogogateway v1.2.0/go.mod h1:iQpLkGWxYcnCdz5iAdLcRBSw3h7NXeOkZ github.com/cosmos/gogoproto v1.4.2/go.mod h1:cLxOsn1ljAHSV527CHOtaIP91kK6cCrZETRBrkzItWU= github.com/cosmos/gogoproto v1.5.0 h1:SDVwzEqZDDBoslaeZg+dGE55hdzHfgUA40pEanMh52o= github.com/cosmos/gogoproto v1.5.0/go.mod h1:iUM31aofn3ymidYG6bUR5ZFrk+Om8p5s754eMUcyp8I= -github.com/cosmos/iavl v1.2.0 h1:kVxTmjTh4k0Dh1VNL046v6BXqKziqMDzxo93oh3kOfM= -github.com/cosmos/iavl v1.2.0/go.mod h1:HidWWLVAtODJqFD6Hbne2Y0q3SdxByJepHUOeoH4LiI= +github.com/cosmos/iavl v1.2.1-0.20240725141113-7adc688cf179 h1:wmwDn7V3RodN9auB3FooSQxs46nHVE3u0mb87TJkZFE= +github.com/cosmos/iavl v1.2.1-0.20240725141113-7adc688cf179/go.mod h1:GiM43q0pB+uG53mLxLDzimxM9l/5N9UuSY3/D0huuVw= github.com/cosmos/ics23/go v0.10.0 h1:iXqLLgp2Lp+EdpIuwXTYIQU+AiHj9mOC2X9ab++bZDM= github.com/cosmos/ics23/go v0.10.0/go.mod h1:ZfJSmng/TBNTBkFemHHHj5YY7VAU/MBU980F4VU1NG0= github.com/cosmos/ledger-cosmos-go v0.13.3 h1:7ehuBGuyIytsXbd4MP43mLeoN2LTOEnk5nvue4rK+yM= diff --git a/x/consensus/go.mod b/x/consensus/go.mod index cc73bce6d289..b638d69e19aa 100644 --- a/x/consensus/go.mod +++ b/x/consensus/go.mod @@ -7,12 +7,12 @@ require ( cosmossdk.io/collections v0.4.0 cosmossdk.io/core v0.12.1-0.20231114100755-569e3ff6a0d7 cosmossdk.io/core/testing v0.0.0-00010101000000-000000000000 - cosmossdk.io/depinject v1.0.0-alpha.4 + cosmossdk.io/depinject v1.0.0 cosmossdk.io/store v1.1.1-0.20240418092142-896cdf1971bc github.com/cometbft/cometbft v1.0.0-rc1 github.com/cometbft/cometbft/api v1.0.0-rc.1 github.com/cosmos/cosmos-proto v1.0.0-beta.5 - github.com/cosmos/cosmos-sdk v0.51.0 + github.com/cosmos/cosmos-sdk v0.53.0 github.com/cosmos/gogoproto v1.5.0 github.com/golang/protobuf v1.5.4 github.com/grpc-ecosystem/grpc-gateway v1.16.0 @@ -53,7 +53,7 @@ require ( github.com/cosmos/crypto v0.1.2 // indirect github.com/cosmos/go-bip39 v1.0.0 // indirect github.com/cosmos/gogogateway v1.2.0 // indirect - github.com/cosmos/iavl v1.2.0 // indirect + github.com/cosmos/iavl v1.2.1-0.20240725141113-7adc688cf179 // indirect github.com/cosmos/ics23/go v0.10.0 // indirect github.com/cosmos/ledger-cosmos-go v0.13.3 // indirect github.com/danieljoos/wincred v1.2.1 // indirect @@ -174,8 +174,6 @@ replace ( cosmossdk.io/api => ../../api cosmossdk.io/core => ../../core cosmossdk.io/core/testing => ../../core/testing - cosmossdk.io/depinject => ../../depinject - cosmossdk.io/log => ../../log cosmossdk.io/x/accounts => ../accounts cosmossdk.io/x/auth => ../auth cosmossdk.io/x/bank => ../bank diff --git a/x/consensus/go.sum b/x/consensus/go.sum index 2aa9efc32a9b..d2a9b023b854 100644 --- a/x/consensus/go.sum +++ b/x/consensus/go.sum @@ -6,8 +6,12 @@ cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMT cloud.google.com/go v0.34.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= cosmossdk.io/collections v0.4.0 h1:PFmwj2W8szgpD5nOd8GWH6AbYNi1f2J6akWXJ7P5t9s= cosmossdk.io/collections v0.4.0/go.mod h1:oa5lUING2dP+gdDquow+QjlF45eL1t4TJDypgGd+tv0= +cosmossdk.io/depinject v1.0.0 h1:dQaTu6+O6askNXO06+jyeUAnF2/ssKwrrszP9t5q050= +cosmossdk.io/depinject v1.0.0/go.mod h1:zxK/h3HgHoA/eJVtiSsoaRaRA2D5U4cJ5thIG4ssbB8= cosmossdk.io/errors v1.0.1 h1:bzu+Kcr0kS/1DuPBtUFdWjzLqyUuCiyHjyJB6srBV/0= cosmossdk.io/errors v1.0.1/go.mod h1:MeelVSZThMi4bEakzhhhE/CKqVv3nOJDA25bIqRDu/U= +cosmossdk.io/log v1.3.1 h1:UZx8nWIkfbbNEWusZqzAx3ZGvu54TZacWib3EzUYmGI= +cosmossdk.io/log v1.3.1/go.mod h1:2/dIomt8mKdk6vl3OWJcPk2be3pGOS8OQaLUM/3/tCM= cosmossdk.io/math v1.3.0 h1:RC+jryuKeytIiictDslBP9i1fhkVm6ZDmZEoNP316zE= cosmossdk.io/math v1.3.0/go.mod h1:vnRTxewy+M7BtXBNFybkuhSH4WfedVAAnERHgVFhp3k= cosmossdk.io/schema v0.1.1 h1:I0M6pgI7R10nq+/HCQfbO6BsGBZA8sQy+duR1Y3aKcA= @@ -111,8 +115,8 @@ github.com/cosmos/gogogateway v1.2.0/go.mod h1:iQpLkGWxYcnCdz5iAdLcRBSw3h7NXeOkZ github.com/cosmos/gogoproto v1.4.2/go.mod h1:cLxOsn1ljAHSV527CHOtaIP91kK6cCrZETRBrkzItWU= github.com/cosmos/gogoproto v1.5.0 h1:SDVwzEqZDDBoslaeZg+dGE55hdzHfgUA40pEanMh52o= github.com/cosmos/gogoproto v1.5.0/go.mod h1:iUM31aofn3ymidYG6bUR5ZFrk+Om8p5s754eMUcyp8I= -github.com/cosmos/iavl v1.2.0 h1:kVxTmjTh4k0Dh1VNL046v6BXqKziqMDzxo93oh3kOfM= -github.com/cosmos/iavl v1.2.0/go.mod h1:HidWWLVAtODJqFD6Hbne2Y0q3SdxByJepHUOeoH4LiI= +github.com/cosmos/iavl v1.2.1-0.20240725141113-7adc688cf179 h1:wmwDn7V3RodN9auB3FooSQxs46nHVE3u0mb87TJkZFE= +github.com/cosmos/iavl v1.2.1-0.20240725141113-7adc688cf179/go.mod h1:GiM43q0pB+uG53mLxLDzimxM9l/5N9UuSY3/D0huuVw= github.com/cosmos/ics23/go v0.10.0 h1:iXqLLgp2Lp+EdpIuwXTYIQU+AiHj9mOC2X9ab++bZDM= github.com/cosmos/ics23/go v0.10.0/go.mod h1:ZfJSmng/TBNTBkFemHHHj5YY7VAU/MBU980F4VU1NG0= github.com/cosmos/ledger-cosmos-go v0.13.3 h1:7ehuBGuyIytsXbd4MP43mLeoN2LTOEnk5nvue4rK+yM= diff --git a/x/consensus/keeper/keeper.go b/x/consensus/keeper/keeper.go index 1bda1861fe6a..fbf7fcc41012 100644 --- a/x/consensus/keeper/keeper.go +++ b/x/consensus/keeper/keeper.go @@ -1,7 +1,6 @@ package keeper import ( - "bytes" "context" "errors" "fmt" @@ -12,7 +11,6 @@ import ( "google.golang.org/grpc/status" "cosmossdk.io/collections" - coreapp "cosmossdk.io/core/app" "cosmossdk.io/core/appmodule" "cosmossdk.io/core/event" "cosmossdk.io/x/consensus/exported" @@ -28,8 +26,6 @@ type Keeper struct { authority string ParamsStore collections.Item[cmtproto.ConsensusParams] - // storage of the last comet info - cometInfo collections.Item[types.CometInfo] } var _ exported.ConsensusParamSetter = Keeper{}.ParamsStore @@ -40,7 +36,6 @@ func NewKeeper(cdc codec.BinaryCodec, env appmodule.Environment, authority strin Environment: env, authority: authority, ParamsStore: collections.NewItem(sb, collections.NewPrefix("Consensus"), "params", codec.CollValue[cmtproto.ConsensusParams](cdc)), - cometInfo: collections.NewItem(sb, collections.NewPrefix("CometInfo"), "comet_info", codec.CollValue[types.CometInfo](cdc)), } } @@ -112,31 +107,3 @@ func (k Keeper) UpdateParams(ctx context.Context, msg *types.MsgUpdateParams) (* return &types.MsgUpdateParamsResponse{}, nil } - -func (k Keeper) SetCometInfo(ctx context.Context, msg *types.MsgSetCometInfo) (*types.MsgSetCometInfoResponse, error) { - if !bytes.Equal(coreapp.ConsensusIdentity, []byte(msg.Authority)) { - return nil, fmt.Errorf("invalid authority; expected %s, got %s", coreapp.ConsensusIdentity, msg.Authority) - } - - cometInfo := types.CometInfo{ - Evidence: msg.Evidence, - ValidatorsHash: msg.ValidatorsHash, - ProposerAddress: msg.ProposerAddress, - LastCommit: msg.LastCommit, - } - - if err := k.cometInfo.Set(ctx, cometInfo); err != nil { - return nil, err - } - - return &types.MsgSetCometInfoResponse{}, nil -} - -func (k Keeper) GetCometInfo(ctx context.Context, _ *types.QueryGetCometInfoRequest) (*types.QueryGetCometInfoResponse, error) { - cometInfo, err := k.cometInfo.Get(ctx) - if err != nil { - return nil, status.Error(codes.Internal, err.Error()) - } - - return &types.QueryGetCometInfoResponse{CometInfo: &cometInfo}, nil -} diff --git a/x/consensus/keeper/keeper_test.go b/x/consensus/keeper/keeper_test.go index d1961fbfa7a9..48188411b591 100644 --- a/x/consensus/keeper/keeper_test.go +++ b/x/consensus/keeper/keeper_test.go @@ -4,7 +4,6 @@ import ( "testing" "time" - v1 "github.com/cometbft/cometbft/api/cometbft/abci/v1" cmtproto "github.com/cometbft/cometbft/api/cometbft/types/v1" cmttypes "github.com/cometbft/cometbft/types" gogotypes "github.com/cosmos/gogoproto/types" @@ -604,53 +603,3 @@ func (s *KeeperTestSuite) TestUpdateParams() { }) } } - -func (s *KeeperTestSuite) TestSetCometInfo() { - consensusIdentiy := "consensus" - testCases := []struct { - name string - enabledFeatures bool - input *types.MsgSetCometInfo - expErr bool - expErrMsg string - }{ - { - name: "valid comet info", - input: &types.MsgSetCometInfo{ - Authority: consensusIdentiy, - Evidence: []*v1.Misbehavior{}, - ValidatorsHash: []byte("validatorhash"), - ProposerAddress: []byte("proposeraddress"), - LastCommit: &v1.CommitInfo{}, - }, - expErr: false, - expErrMsg: "", - }, - { - name: "invalid authority", - input: &types.MsgSetCometInfo{ - Authority: "invalid", - Evidence: []*v1.Misbehavior{}, - ValidatorsHash: []byte("validatorhash"), - ProposerAddress: []byte("proposeraddress"), - LastCommit: &v1.CommitInfo{}, - }, - expErr: true, - expErrMsg: "invalid authority", - }, - } - - for _, tc := range testCases { - tc := tc - s.Run(tc.name, func() { - s.SetupTest(tc.enabledFeatures) - _, err := s.consensusParamsKeeper.SetCometInfo(s.ctx, tc.input) - if tc.expErr { - s.Require().Error(err) - s.Require().Contains(err.Error(), tc.expErrMsg) - } else { - s.Require().NoError(err) - } - }) - } -} diff --git a/x/consensus/proto/cosmos/consensus/v1/query.proto b/x/consensus/proto/cosmos/consensus/v1/query.proto index d458c32c55d2..4841c5aed367 100644 --- a/x/consensus/proto/cosmos/consensus/v1/query.proto +++ b/x/consensus/proto/cosmos/consensus/v1/query.proto @@ -14,18 +14,6 @@ service Query { rpc Params(QueryParamsRequest) returns (QueryParamsResponse) { option (google.api.http).get = "/cosmos/consensus/v1/params"; } - - // CometInfo queries the comet info of x/consensus module. - rpc GetCometInfo(QueryGetCometInfoRequest) returns (QueryGetCometInfoResponse); -} - -// QueryCometInfoRequest defines the request type for querying x/consensus comet info. -message QueryGetCometInfoRequest {} - -// QueryCometInfoResponse defines the response type for querying x/consensus comet info. -message QueryGetCometInfoResponse { - // comet_info is the comet info of the x/consensus module. - CometInfo comet_info = 1; } // QueryParamsRequest defines the request type for querying x/consensus parameters. diff --git a/x/consensus/proto/cosmos/consensus/v1/tx.proto b/x/consensus/proto/cosmos/consensus/v1/tx.proto index 74480b72a50c..d6b21625c41b 100644 --- a/x/consensus/proto/cosmos/consensus/v1/tx.proto +++ b/x/consensus/proto/cosmos/consensus/v1/tx.proto @@ -19,9 +19,6 @@ service Msg { rpc UpdateParams(MsgUpdateParams) returns (MsgUpdateParamsResponse) { option (cosmos_proto.method_added_in) = "cosmos-sdk 0.47"; } - - // SetCometInfo defines how to set the comet info for the x/consensus module. - rpc SetCometInfo(MsgSetCometInfo) returns (MsgSetCometInfoResponse); } // MsgUpdateParams is the Msg/UpdateParams request type. @@ -50,27 +47,3 @@ message MsgUpdateParams { // MsgUpdateParamsResponse defines the response structure for executing a // MsgUpdateParams message. message MsgUpdateParamsResponse {} - -// MsgCometInfo is the Msg/CometInfo request type. -message MsgSetCometInfo { - option (cosmos.msg.v1.signer) = "authority"; - option (amino.name) = "cosmos-sdk/x/consensus/MsgCometInfo"; - - // authority is the address that controls the module (defaults to x/gov unless overwritten). - string authority = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"]; - - // evidence is the misbehaviour evidence to submit. - repeated cometbft.abci.v1.Misbehavior evidence = 2; - - // validators_hash is the hash of the current validator set. - bytes validators_hash = 3; - - // proposer_address is the address of the current proposer. - bytes proposer_address = 4; - - // last_commit is the last commit info. - cometbft.abci.v1.CommitInfo last_commit = 5; -} - -// MsgCometInfoResponse defines the response -message MsgSetCometInfoResponse {} diff --git a/x/consensus/types/query.pb.go b/x/consensus/types/query.pb.go index 1ba4d07047af..51273849e407 100644 --- a/x/consensus/types/query.pb.go +++ b/x/consensus/types/query.pb.go @@ -29,89 +29,6 @@ var _ = math.Inf // proto package needs to be updated. const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package -// QueryCometInfoRequest defines the request type for querying x/consensus comet info. -type QueryGetCometInfoRequest struct { -} - -func (m *QueryGetCometInfoRequest) Reset() { *m = QueryGetCometInfoRequest{} } -func (m *QueryGetCometInfoRequest) String() string { return proto.CompactTextString(m) } -func (*QueryGetCometInfoRequest) ProtoMessage() {} -func (*QueryGetCometInfoRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_bf54d1e5df04cee9, []int{0} -} -func (m *QueryGetCometInfoRequest) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *QueryGetCometInfoRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_QueryGetCometInfoRequest.Marshal(b, m, deterministic) - } else { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil - } -} -func (m *QueryGetCometInfoRequest) XXX_Merge(src proto.Message) { - xxx_messageInfo_QueryGetCometInfoRequest.Merge(m, src) -} -func (m *QueryGetCometInfoRequest) XXX_Size() int { - return m.Size() -} -func (m *QueryGetCometInfoRequest) XXX_DiscardUnknown() { - xxx_messageInfo_QueryGetCometInfoRequest.DiscardUnknown(m) -} - -var xxx_messageInfo_QueryGetCometInfoRequest proto.InternalMessageInfo - -// QueryCometInfoResponse defines the response type for querying x/consensus comet info. -type QueryGetCometInfoResponse struct { - // comet_info is the comet info of the x/consensus module. - CometInfo *CometInfo `protobuf:"bytes,1,opt,name=comet_info,json=cometInfo,proto3" json:"comet_info,omitempty"` -} - -func (m *QueryGetCometInfoResponse) Reset() { *m = QueryGetCometInfoResponse{} } -func (m *QueryGetCometInfoResponse) String() string { return proto.CompactTextString(m) } -func (*QueryGetCometInfoResponse) ProtoMessage() {} -func (*QueryGetCometInfoResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_bf54d1e5df04cee9, []int{1} -} -func (m *QueryGetCometInfoResponse) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *QueryGetCometInfoResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_QueryGetCometInfoResponse.Marshal(b, m, deterministic) - } else { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil - } -} -func (m *QueryGetCometInfoResponse) XXX_Merge(src proto.Message) { - xxx_messageInfo_QueryGetCometInfoResponse.Merge(m, src) -} -func (m *QueryGetCometInfoResponse) XXX_Size() int { - return m.Size() -} -func (m *QueryGetCometInfoResponse) XXX_DiscardUnknown() { - xxx_messageInfo_QueryGetCometInfoResponse.DiscardUnknown(m) -} - -var xxx_messageInfo_QueryGetCometInfoResponse proto.InternalMessageInfo - -func (m *QueryGetCometInfoResponse) GetCometInfo() *CometInfo { - if m != nil { - return m.CometInfo - } - return nil -} - // QueryParamsRequest defines the request type for querying x/consensus parameters. type QueryParamsRequest struct { } @@ -120,7 +37,7 @@ func (m *QueryParamsRequest) Reset() { *m = QueryParamsRequest{} } func (m *QueryParamsRequest) String() string { return proto.CompactTextString(m) } func (*QueryParamsRequest) ProtoMessage() {} func (*QueryParamsRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_bf54d1e5df04cee9, []int{2} + return fileDescriptor_bf54d1e5df04cee9, []int{0} } func (m *QueryParamsRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -161,7 +78,7 @@ func (m *QueryParamsResponse) Reset() { *m = QueryParamsResponse{} } func (m *QueryParamsResponse) String() string { return proto.CompactTextString(m) } func (*QueryParamsResponse) ProtoMessage() {} func (*QueryParamsResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_bf54d1e5df04cee9, []int{3} + return fileDescriptor_bf54d1e5df04cee9, []int{1} } func (m *QueryParamsResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -198,8 +115,6 @@ func (m *QueryParamsResponse) GetParams() *v1.ConsensusParams { } func init() { - proto.RegisterType((*QueryGetCometInfoRequest)(nil), "cosmos.consensus.v1.QueryGetCometInfoRequest") - proto.RegisterType((*QueryGetCometInfoResponse)(nil), "cosmos.consensus.v1.QueryGetCometInfoResponse") proto.RegisterType((*QueryParamsRequest)(nil), "cosmos.consensus.v1.QueryParamsRequest") proto.RegisterType((*QueryParamsResponse)(nil), "cosmos.consensus.v1.QueryParamsResponse") } @@ -207,29 +122,25 @@ func init() { func init() { proto.RegisterFile("cosmos/consensus/v1/query.proto", fileDescriptor_bf54d1e5df04cee9) } var fileDescriptor_bf54d1e5df04cee9 = []byte{ - // 342 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x8c, 0x92, 0x31, 0x4f, 0xc3, 0x30, - 0x10, 0x85, 0x6b, 0x24, 0x2a, 0x61, 0x98, 0x5c, 0x86, 0x12, 0xc0, 0xa0, 0x74, 0xa0, 0x0b, 0xb6, - 0x5a, 0x16, 0x84, 0xc4, 0x02, 0x03, 0x62, 0xa3, 0x8c, 0x5d, 0x50, 0x1a, 0xdc, 0x2a, 0x82, 0xf8, - 0xd2, 0xda, 0xad, 0xe8, 0x86, 0xf8, 0x05, 0x48, 0xfc, 0x29, 0xc6, 0x4a, 0x2c, 0x8c, 0x28, 0xe1, - 0x4f, 0xb0, 0xa1, 0xd8, 0x09, 0x2d, 0xc2, 0x08, 0xb6, 0x28, 0xf7, 0xee, 0xbd, 0xef, 0x5d, 0x82, - 0x77, 0x42, 0x50, 0x31, 0x28, 0x1e, 0x82, 0x54, 0x42, 0xaa, 0xb1, 0xe2, 0x93, 0x16, 0x1f, 0x8e, - 0xc5, 0x68, 0xca, 0x92, 0x11, 0x68, 0x20, 0x35, 0x2b, 0x60, 0x5f, 0x02, 0x36, 0x69, 0x79, 0x5b, - 0x03, 0x80, 0xc1, 0xad, 0xe0, 0x41, 0x12, 0xf1, 0x40, 0x4a, 0xd0, 0x81, 0x8e, 0x40, 0x2a, 0xbb, - 0xe2, 0xd1, 0x10, 0x62, 0xa1, 0x7b, 0x7d, 0xcd, 0xf5, 0x34, 0x11, 0xc6, 0x31, 0x09, 0x46, 0x41, - 0x5c, 0xce, 0x1b, 0xae, 0xcc, 0xb9, 0xbf, 0x11, 0xf9, 0x1e, 0xae, 0x77, 0x72, 0x8c, 0x33, 0xa1, - 0x4f, 0x73, 0xbb, 0x73, 0xd9, 0x87, 0x4b, 0x31, 0x1c, 0x0b, 0xa5, 0xfd, 0x2e, 0xde, 0x70, 0xcc, - 0x54, 0x92, 0x5b, 0x90, 0x63, 0x8c, 0x4d, 0xfe, 0x55, 0x24, 0xfb, 0x50, 0x47, 0xbb, 0xa8, 0xb9, - 0xda, 0xa6, 0xcc, 0xd1, 0x82, 0xcd, 0x77, 0x57, 0xc2, 0xf2, 0xd1, 0x5f, 0xc7, 0xc4, 0x78, 0x5f, - 0x18, 0xe2, 0x32, 0xb1, 0x83, 0x6b, 0xdf, 0xde, 0x16, 0x59, 0x47, 0xb8, 0x6a, 0x9b, 0x15, 0x39, - 0x3e, 0x2b, 0xab, 0x33, 0x53, 0xdd, 0xa6, 0x14, 0x91, 0xc5, 0x6e, 0xb1, 0xd1, 0xfe, 0x40, 0x78, - 0xd9, 0x78, 0x92, 0x7b, 0x84, 0xab, 0x76, 0x48, 0xf6, 0x9c, 0xa0, 0x3f, 0x81, 0xbc, 0xe6, 0xdf, - 0x42, 0xcb, 0xe8, 0x37, 0x1e, 0x5e, 0xde, 0x9f, 0x96, 0xb6, 0xc9, 0x26, 0x77, 0x9d, 0xdd, 0xc2, - 0x90, 0x18, 0xaf, 0x2d, 0x1e, 0x93, 0xec, 0xff, 0x6e, 0xef, 0xf8, 0x20, 0x1e, 0xfb, 0xaf, 0xdc, - 0x32, 0x9d, 0x1c, 0x3e, 0xa7, 0x14, 0xcd, 0x52, 0x8a, 0xde, 0x52, 0x8a, 0x1e, 0x33, 0x5a, 0x99, - 0x65, 0xb4, 0xf2, 0x9a, 0xd1, 0x4a, 0x97, 0x5a, 0x23, 0x75, 0x7d, 0xc3, 0x22, 0xe0, 0x77, 0x0b, - 0xb0, 0xe6, 0xa0, 0xbd, 0xaa, 0xf9, 0x3b, 0x0e, 0x3e, 0x03, 0x00, 0x00, 0xff, 0xff, 0xd0, 0xd8, - 0xe1, 0x00, 0xb8, 0x02, 0x00, 0x00, + // 278 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x92, 0x4f, 0xce, 0x2f, 0xce, + 0xcd, 0x2f, 0xd6, 0x4f, 0xce, 0xcf, 0x2b, 0x4e, 0xcd, 0x2b, 0x2e, 0x2d, 0xd6, 0x2f, 0x33, 0xd4, + 0x2f, 0x2c, 0x4d, 0x2d, 0xaa, 0xd4, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0x12, 0x86, 0x28, 0xd0, + 0x83, 0x2b, 0xd0, 0x2b, 0x33, 0x94, 0x92, 0x49, 0xcf, 0xcf, 0x4f, 0xcf, 0x49, 0xd5, 0x4f, 0x2c, + 0xc8, 0xd4, 0x4f, 0xcc, 0xcb, 0xcb, 0x2f, 0x49, 0x2c, 0xc9, 0xcc, 0xcf, 0x2b, 0x86, 0x68, 0x91, + 0x92, 0x4b, 0xce, 0xcf, 0x4d, 0x2d, 0x49, 0x4a, 0x2b, 0xd1, 0x2f, 0xa9, 0x2c, 0x48, 0x05, 0x9b, + 0x58, 0x90, 0x58, 0x94, 0x98, 0x0b, 0x93, 0x57, 0xc6, 0x66, 0x27, 0xc2, 0x7c, 0xb0, 0x22, 0x25, + 0x11, 0x2e, 0xa1, 0x40, 0x90, 0x33, 0x02, 0xc0, 0x3a, 0x83, 0x52, 0x0b, 0x4b, 0x53, 0x8b, 0x4b, + 0x94, 0x02, 0xb9, 0x84, 0x51, 0x44, 0x8b, 0x0b, 0x40, 0xda, 0x84, 0xac, 0xb8, 0xd8, 0x20, 0x36, + 0x48, 0x30, 0x2a, 0x30, 0x6a, 0x70, 0x1b, 0x29, 0xe9, 0xc1, 0x9c, 0xa0, 0x07, 0x76, 0x82, 0x5e, + 0x99, 0xa1, 0x9e, 0x33, 0xcc, 0x02, 0xa8, 0x5e, 0xa8, 0x0e, 0xa3, 0x2e, 0x46, 0x2e, 0x56, 0xb0, + 0x99, 0x42, 0x0d, 0x8c, 0x5c, 0x6c, 0x10, 0x49, 0x21, 0x75, 0x3d, 0x2c, 0xde, 0xd6, 0xc3, 0x74, + 0x90, 0x94, 0x06, 0x61, 0x85, 0x10, 0x37, 0x2a, 0x29, 0x37, 0x5d, 0x7e, 0x32, 0x99, 0x49, 0x56, + 0x48, 0x5a, 0x1f, 0x9b, 0xf7, 0x21, 0x8e, 0x71, 0xb2, 0x38, 0xf1, 0x48, 0x8e, 0xf1, 0xc2, 0x23, + 0x39, 0xc6, 0x07, 0x8f, 0xe4, 0x18, 0x27, 0x3c, 0x96, 0x63, 0xb8, 0xf0, 0x58, 0x8e, 0xe1, 0xc6, + 0x63, 0x39, 0x86, 0x28, 0x39, 0x88, 0xae, 0xe2, 0x94, 0x6c, 0xbd, 0xcc, 0x7c, 0xfd, 0x0a, 0x24, + 0xdd, 0x60, 0x1f, 0x26, 0xb1, 0x81, 0x83, 0xcd, 0x18, 0x10, 0x00, 0x00, 0xff, 0xff, 0xc3, 0xb9, + 0xf1, 0x10, 0xd1, 0x01, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -246,8 +157,6 @@ const _ = grpc.SupportPackageIsVersion4 type QueryClient interface { // Params queries the parameters of x/consensus module. Params(ctx context.Context, in *QueryParamsRequest, opts ...grpc.CallOption) (*QueryParamsResponse, error) - // CometInfo queries the comet info of x/consensus module. - GetCometInfo(ctx context.Context, in *QueryGetCometInfoRequest, opts ...grpc.CallOption) (*QueryGetCometInfoResponse, error) } type queryClient struct { @@ -267,21 +176,10 @@ func (c *queryClient) Params(ctx context.Context, in *QueryParamsRequest, opts . return out, nil } -func (c *queryClient) GetCometInfo(ctx context.Context, in *QueryGetCometInfoRequest, opts ...grpc.CallOption) (*QueryGetCometInfoResponse, error) { - out := new(QueryGetCometInfoResponse) - err := c.cc.Invoke(ctx, "/cosmos.consensus.v1.Query/GetCometInfo", in, out, opts...) - if err != nil { - return nil, err - } - return out, nil -} - // QueryServer is the server API for Query service. type QueryServer interface { // Params queries the parameters of x/consensus module. Params(context.Context, *QueryParamsRequest) (*QueryParamsResponse, error) - // CometInfo queries the comet info of x/consensus module. - GetCometInfo(context.Context, *QueryGetCometInfoRequest) (*QueryGetCometInfoResponse, error) } // UnimplementedQueryServer can be embedded to have forward compatible implementations. @@ -291,9 +189,6 @@ type UnimplementedQueryServer struct { func (*UnimplementedQueryServer) Params(ctx context.Context, req *QueryParamsRequest) (*QueryParamsResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method Params not implemented") } -func (*UnimplementedQueryServer) GetCometInfo(ctx context.Context, req *QueryGetCometInfoRequest) (*QueryGetCometInfoResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method GetCometInfo not implemented") -} func RegisterQueryServer(s grpc1.Server, srv QueryServer) { s.RegisterService(&_Query_serviceDesc, srv) @@ -317,24 +212,6 @@ func _Query_Params_Handler(srv interface{}, ctx context.Context, dec func(interf return interceptor(ctx, in, info, handler) } -func _Query_GetCometInfo_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(QueryGetCometInfoRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(QueryServer).GetCometInfo(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/cosmos.consensus.v1.Query/GetCometInfo", - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(QueryServer).GetCometInfo(ctx, req.(*QueryGetCometInfoRequest)) - } - return interceptor(ctx, in, info, handler) -} - var _Query_serviceDesc = grpc.ServiceDesc{ ServiceName: "cosmos.consensus.v1.Query", HandlerType: (*QueryServer)(nil), @@ -343,73 +220,11 @@ var _Query_serviceDesc = grpc.ServiceDesc{ MethodName: "Params", Handler: _Query_Params_Handler, }, - { - MethodName: "GetCometInfo", - Handler: _Query_GetCometInfo_Handler, - }, }, Streams: []grpc.StreamDesc{}, Metadata: "cosmos/consensus/v1/query.proto", } -func (m *QueryGetCometInfoRequest) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *QueryGetCometInfoRequest) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *QueryGetCometInfoRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - return len(dAtA) - i, nil -} - -func (m *QueryGetCometInfoResponse) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *QueryGetCometInfoResponse) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *QueryGetCometInfoResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if m.CometInfo != nil { - { - size, err := m.CometInfo.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintQuery(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0xa - } - return len(dAtA) - i, nil -} - func (m *QueryParamsRequest) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) @@ -479,28 +294,6 @@ func encodeVarintQuery(dAtA []byte, offset int, v uint64) int { dAtA[offset] = uint8(v) return base } -func (m *QueryGetCometInfoRequest) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - return n -} - -func (m *QueryGetCometInfoResponse) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if m.CometInfo != nil { - l = m.CometInfo.Size() - n += 1 + l + sovQuery(uint64(l)) - } - return n -} - func (m *QueryParamsRequest) Size() (n int) { if m == nil { return 0 @@ -529,142 +322,6 @@ func sovQuery(x uint64) (n int) { func sozQuery(x uint64) (n int) { return sovQuery(uint64((x << 1) ^ uint64((int64(x) >> 63)))) } -func (m *QueryGetCometInfoRequest) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowQuery - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: QueryGetCometInfoRequest: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: QueryGetCometInfoRequest: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - default: - iNdEx = preIndex - skippy, err := skipQuery(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthQuery - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *QueryGetCometInfoResponse) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowQuery - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: QueryGetCometInfoResponse: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: QueryGetCometInfoResponse: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field CometInfo", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowQuery - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthQuery - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthQuery - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if m.CometInfo == nil { - m.CometInfo = &CometInfo{} - } - if err := m.CometInfo.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipQuery(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthQuery - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} func (m *QueryParamsRequest) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 diff --git a/x/consensus/types/tx.pb.go b/x/consensus/types/tx.pb.go index ecf75a0e78ea..1ce22a421407 100644 --- a/x/consensus/types/tx.pb.go +++ b/x/consensus/types/tx.pb.go @@ -6,7 +6,7 @@ package types import ( context "context" fmt "fmt" - v11 "github.com/cometbft/cometbft/api/cometbft/abci/v1" + _ "github.com/cometbft/cometbft/api/cometbft/abci/v1" v1 "github.com/cometbft/cometbft/api/cometbft/types/v1" _ "github.com/cosmos/cosmos-proto" _ "github.com/cosmos/cosmos-sdk/types/msgservice" @@ -171,177 +171,47 @@ func (m *MsgUpdateParamsResponse) XXX_DiscardUnknown() { var xxx_messageInfo_MsgUpdateParamsResponse proto.InternalMessageInfo -// MsgCometInfo is the Msg/CometInfo request type. -type MsgSetCometInfo struct { - // authority is the address that controls the module (defaults to x/gov unless overwritten). - Authority string `protobuf:"bytes,1,opt,name=authority,proto3" json:"authority,omitempty"` - // evidence is the misbehaviour evidence to submit. - Evidence []*v11.Misbehavior `protobuf:"bytes,2,rep,name=evidence,proto3" json:"evidence,omitempty"` - // validators_hash is the hash of the current validator set. - ValidatorsHash []byte `protobuf:"bytes,3,opt,name=validators_hash,json=validatorsHash,proto3" json:"validators_hash,omitempty"` - // proposer_address is the address of the current proposer. - ProposerAddress []byte `protobuf:"bytes,4,opt,name=proposer_address,json=proposerAddress,proto3" json:"proposer_address,omitempty"` - // last_commit is the last commit info. - LastCommit *v11.CommitInfo `protobuf:"bytes,5,opt,name=last_commit,json=lastCommit,proto3" json:"last_commit,omitempty"` -} - -func (m *MsgSetCometInfo) Reset() { *m = MsgSetCometInfo{} } -func (m *MsgSetCometInfo) String() string { return proto.CompactTextString(m) } -func (*MsgSetCometInfo) ProtoMessage() {} -func (*MsgSetCometInfo) Descriptor() ([]byte, []int) { - return fileDescriptor_2135c60575ab504d, []int{2} -} -func (m *MsgSetCometInfo) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *MsgSetCometInfo) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_MsgSetCometInfo.Marshal(b, m, deterministic) - } else { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil - } -} -func (m *MsgSetCometInfo) XXX_Merge(src proto.Message) { - xxx_messageInfo_MsgSetCometInfo.Merge(m, src) -} -func (m *MsgSetCometInfo) XXX_Size() int { - return m.Size() -} -func (m *MsgSetCometInfo) XXX_DiscardUnknown() { - xxx_messageInfo_MsgSetCometInfo.DiscardUnknown(m) -} - -var xxx_messageInfo_MsgSetCometInfo proto.InternalMessageInfo - -func (m *MsgSetCometInfo) GetAuthority() string { - if m != nil { - return m.Authority - } - return "" -} - -func (m *MsgSetCometInfo) GetEvidence() []*v11.Misbehavior { - if m != nil { - return m.Evidence - } - return nil -} - -func (m *MsgSetCometInfo) GetValidatorsHash() []byte { - if m != nil { - return m.ValidatorsHash - } - return nil -} - -func (m *MsgSetCometInfo) GetProposerAddress() []byte { - if m != nil { - return m.ProposerAddress - } - return nil -} - -func (m *MsgSetCometInfo) GetLastCommit() *v11.CommitInfo { - if m != nil { - return m.LastCommit - } - return nil -} - -// MsgCometInfoResponse defines the response -type MsgSetCometInfoResponse struct { -} - -func (m *MsgSetCometInfoResponse) Reset() { *m = MsgSetCometInfoResponse{} } -func (m *MsgSetCometInfoResponse) String() string { return proto.CompactTextString(m) } -func (*MsgSetCometInfoResponse) ProtoMessage() {} -func (*MsgSetCometInfoResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_2135c60575ab504d, []int{3} -} -func (m *MsgSetCometInfoResponse) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *MsgSetCometInfoResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_MsgSetCometInfoResponse.Marshal(b, m, deterministic) - } else { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil - } -} -func (m *MsgSetCometInfoResponse) XXX_Merge(src proto.Message) { - xxx_messageInfo_MsgSetCometInfoResponse.Merge(m, src) -} -func (m *MsgSetCometInfoResponse) XXX_Size() int { - return m.Size() -} -func (m *MsgSetCometInfoResponse) XXX_DiscardUnknown() { - xxx_messageInfo_MsgSetCometInfoResponse.DiscardUnknown(m) -} - -var xxx_messageInfo_MsgSetCometInfoResponse proto.InternalMessageInfo - func init() { proto.RegisterType((*MsgUpdateParams)(nil), "cosmos.consensus.v1.MsgUpdateParams") proto.RegisterType((*MsgUpdateParamsResponse)(nil), "cosmos.consensus.v1.MsgUpdateParamsResponse") - proto.RegisterType((*MsgSetCometInfo)(nil), "cosmos.consensus.v1.MsgSetCometInfo") - proto.RegisterType((*MsgSetCometInfoResponse)(nil), "cosmos.consensus.v1.MsgSetCometInfoResponse") } func init() { proto.RegisterFile("cosmos/consensus/v1/tx.proto", fileDescriptor_2135c60575ab504d) } var fileDescriptor_2135c60575ab504d = []byte{ - // 649 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x9c, 0x54, 0x4d, 0x4f, 0xd4, 0x40, - 0x18, 0xa6, 0x7c, 0xba, 0xc3, 0xc6, 0xd5, 0x41, 0x43, 0xd9, 0x60, 0xb3, 0xae, 0x46, 0x91, 0x48, - 0xcb, 0x22, 0xa2, 0x90, 0x90, 0xc8, 0x12, 0x0d, 0x1c, 0x88, 0xa6, 0x04, 0x0f, 0x5e, 0x36, 0xd3, - 0x76, 0xd8, 0x36, 0xd0, 0x4e, 0xd3, 0x19, 0x2a, 0x7b, 0x33, 0x1e, 0x3d, 0xf9, 0x47, 0x4c, 0x38, - 0xf0, 0x23, 0x8c, 0x17, 0x89, 0x27, 0xe3, 0xc9, 0xec, 0x1e, 0x36, 0xfe, 0x0b, 0xd3, 0x99, 0x7e, - 0xec, 0x47, 0x37, 0x31, 0x5e, 0x9a, 0x74, 0xde, 0xe7, 0x79, 0xde, 0x77, 0x9e, 0xf7, 0x69, 0xc1, - 0xa2, 0x49, 0xa8, 0x4b, 0xa8, 0x66, 0x12, 0x8f, 0x62, 0x8f, 0x9e, 0x51, 0x2d, 0xac, 0x69, 0xec, - 0x5c, 0xf5, 0x03, 0xc2, 0x08, 0x9c, 0x13, 0x55, 0x35, 0xad, 0xaa, 0x61, 0xad, 0x7c, 0x13, 0xb9, - 0x8e, 0x47, 0x34, 0xfe, 0x14, 0xb8, 0xf2, 0x82, 0xc0, 0x35, 0xf8, 0x9b, 0x16, 0x93, 0x44, 0x69, - 0x3e, 0x6e, 0xe0, 0xd2, 0x66, 0x24, 0xed, 0xd2, 0x66, 0x5c, 0x50, 0x4c, 0xe2, 0x62, 0x66, 0x1c, - 0x33, 0x8d, 0xb5, 0x7c, 0xcc, 0xfb, 0xfa, 0x28, 0x40, 0x6e, 0x42, 0x5c, 0x4c, 0xeb, 0xc8, 0x30, - 0x1d, 0x3e, 0x56, 0x84, 0x13, 0xd5, 0xea, 0x97, 0x49, 0x50, 0x3a, 0xa0, 0xcd, 0x23, 0xdf, 0x42, - 0x0c, 0xbf, 0xe1, 0x3c, 0xb8, 0x01, 0x0a, 0xe8, 0x8c, 0xd9, 0x24, 0x70, 0x58, 0x4b, 0x96, 0x2a, - 0xd2, 0x52, 0xa1, 0x2e, 0xff, 0xb8, 0x5c, 0xb9, 0x15, 0xcf, 0xb3, 0x63, 0x59, 0x01, 0xa6, 0xf4, - 0x90, 0x05, 0x8e, 0xd7, 0xd4, 0x33, 0x28, 0x5c, 0x07, 0x53, 0xc6, 0x29, 0x31, 0x4f, 0xe4, 0xf1, - 0x8a, 0xb4, 0x34, 0xbb, 0xa6, 0xa8, 0x49, 0x67, 0x55, 0x74, 0x0c, 0x6b, 0x6a, 0x3d, 0xaa, 0x8b, - 0x36, 0xba, 0x00, 0xc3, 0x6d, 0x70, 0x0d, 0x87, 0x8e, 0x85, 0x3d, 0x13, 0xcb, 0x13, 0x9c, 0x78, - 0x37, 0x87, 0xf8, 0x32, 0x86, 0xc4, 0xdc, 0x94, 0x02, 0x5f, 0x80, 0x42, 0x88, 0x4e, 0x1d, 0x0b, - 0x31, 0x12, 0xc8, 0x93, 0x9c, 0x5f, 0xcd, 0xe1, 0xbf, 0x4d, 0x30, 0xb1, 0x40, 0x46, 0x82, 0x7b, - 0x60, 0x32, 0x72, 0x46, 0x9e, 0xe2, 0xe4, 0x3b, 0x39, 0xe4, 0x9d, 0xfa, 0xee, 0xbe, 0xe0, 0xd5, - 0x6f, 0xff, 0xba, 0x5c, 0x29, 0x09, 0x23, 0x56, 0xa8, 0x75, 0x52, 0x59, 0x55, 0x9f, 0xae, 0xca, - 0x92, 0xce, 0x15, 0xe0, 0x11, 0x28, 0xd0, 0x96, 0x67, 0xda, 0x01, 0xf1, 0x5a, 0xf2, 0xf4, 0xc8, - 0x59, 0x0e, 0x13, 0x4c, 0xac, 0x39, 0x37, 0xac, 0x59, 0xd3, 0x33, 0x25, 0xf8, 0x1a, 0xcc, 0x1c, - 0x63, 0xc4, 0xce, 0x02, 0x2c, 0xcf, 0x70, 0xd1, 0x4a, 0x8e, 0xe8, 0x2b, 0x81, 0x18, 0x2d, 0xb9, - 0xa6, 0x27, 0x2a, 0x5b, 0x9b, 0x1f, 0xbb, 0x17, 0xcb, 0xd9, 0xe2, 0x3e, 0x75, 0x2f, 0x96, 0x1f, - 0x64, 0x60, 0xed, 0xbc, 0x27, 0xc5, 0x03, 0xd9, 0xa8, 0x2e, 0x80, 0xf9, 0x81, 0x23, 0x1d, 0x53, - 0x3f, 0x82, 0x57, 0xbf, 0x8f, 0xf3, 0x28, 0x1d, 0x62, 0xb6, 0x1b, 0x4d, 0xb7, 0xef, 0x1d, 0x93, - 0xff, 0x8e, 0xd2, 0x66, 0x4f, 0x28, 0xc6, 0x2b, 0x13, 0xfd, 0x7b, 0x89, 0xbc, 0x8e, 0xae, 0x7c, - 0xe0, 0x50, 0x03, 0xdb, 0x28, 0x74, 0x48, 0xd0, 0x13, 0x88, 0x87, 0xa0, 0x94, 0xee, 0x96, 0x36, - 0x6c, 0x44, 0x6d, 0x1e, 0xab, 0xa2, 0x7e, 0x3d, 0x3b, 0xde, 0x43, 0xd4, 0x86, 0x8f, 0xc0, 0x0d, - 0x3f, 0x20, 0x3e, 0xa1, 0x38, 0x68, 0x20, 0x31, 0x08, 0x0f, 0x50, 0x51, 0x2f, 0x25, 0xe7, 0xf1, - 0x7c, 0x70, 0x1b, 0xcc, 0x9e, 0x22, 0xca, 0x1a, 0x26, 0x71, 0x5d, 0x87, 0xc5, 0x49, 0x59, 0x1c, - 0x9e, 0x68, 0x97, 0xd7, 0xa3, 0x9b, 0xeb, 0x20, 0x22, 0x88, 0xf7, 0xad, 0x8d, 0x61, 0xbf, 0xef, - 0x8d, 0xf6, 0x3b, 0x75, 0x2f, 0x36, 0xbb, 0xd7, 0xd0, 0xc4, 0xec, 0xb5, 0x3f, 0x12, 0x98, 0x38, - 0xa0, 0x4d, 0xf8, 0x1e, 0x14, 0xfb, 0xbe, 0xdd, 0xfb, 0x6a, 0xce, 0xaf, 0x46, 0x1d, 0x58, 0x59, - 0xf9, 0xf1, 0xbf, 0xa0, 0xd2, 0xc5, 0xce, 0x7d, 0x1b, 0x0c, 0xd3, 0xfa, 0x33, 0x68, 0x80, 0x62, - 0xdf, 0xa6, 0x47, 0x36, 0xee, 0x45, 0x8d, 0x6e, 0x9c, 0x77, 0xc9, 0xf2, 0xd4, 0x87, 0xee, 0xc5, - 0xb2, 0x54, 0x7f, 0xfe, 0xb5, 0xad, 0x48, 0x57, 0x6d, 0x45, 0xfa, 0xdd, 0x56, 0xa4, 0xcf, 0x1d, - 0x65, 0xec, 0xaa, 0xa3, 0x8c, 0xfd, 0xec, 0x28, 0x63, 0xef, 0x14, 0xa1, 0x46, 0xad, 0x13, 0xd5, - 0x21, 0x7d, 0x3e, 0xf2, 0xef, 0xc2, 0x98, 0xe6, 0x3f, 0xb9, 0x27, 0x7f, 0x03, 0x00, 0x00, 0xff, - 0xff, 0x65, 0xd1, 0xd8, 0x21, 0x9e, 0x05, 0x00, 0x00, + // 507 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x8c, 0x93, 0x4f, 0x6b, 0x13, 0x41, + 0x18, 0xc6, 0xb3, 0x36, 0x69, 0xcd, 0x28, 0x14, 0x27, 0x4a, 0xa7, 0xa1, 0x0e, 0x31, 0x88, 0x94, + 0x60, 0x66, 0x9b, 0x58, 0xff, 0x82, 0x60, 0x23, 0x8a, 0x1e, 0x8a, 0xb2, 0xa5, 0x1e, 0xbc, 0xc8, + 0x64, 0x77, 0xba, 0x5d, 0xd2, 0xdd, 0x59, 0x76, 0x26, 0x6b, 0x73, 0x13, 0xc1, 0x8b, 0x27, 0xbf, + 0x88, 0x90, 0x43, 0x3f, 0x84, 0x78, 0x2a, 0x9e, 0xc4, 0x93, 0x24, 0x87, 0x7c, 0x0d, 0xd9, 0x99, + 0xdd, 0xac, 0x8d, 0x5b, 0xf0, 0x12, 0xc8, 0x3e, 0xcf, 0xef, 0x79, 0x66, 0xde, 0x7d, 0x17, 0x6c, + 0xd8, 0x5c, 0xf8, 0x5c, 0x98, 0x36, 0x0f, 0x04, 0x0b, 0xc4, 0x50, 0x98, 0x71, 0xc7, 0x94, 0xc7, + 0x24, 0x8c, 0xb8, 0xe4, 0xb0, 0xa6, 0x55, 0x32, 0x57, 0x49, 0xdc, 0xa9, 0x5f, 0xa1, 0xbe, 0x17, + 0x70, 0x53, 0xfd, 0x6a, 0x5f, 0x7d, 0x5d, 0xfb, 0xde, 0xa9, 0x7f, 0x66, 0x0a, 0x69, 0x69, 0x2d, + 0x2d, 0xf0, 0x85, 0x9b, 0x44, 0xfb, 0xc2, 0x4d, 0x05, 0x6c, 0x73, 0x9f, 0xc9, 0xfe, 0x81, 0x34, + 0xe5, 0x28, 0x64, 0xaa, 0x37, 0xa4, 0x11, 0xf5, 0x33, 0x70, 0x63, 0xae, 0xd3, 0xbe, 0xed, 0xa9, + 0x63, 0x25, 0x3e, 0xad, 0x36, 0xbf, 0x96, 0xc1, 0xea, 0xae, 0x70, 0xf7, 0x43, 0x87, 0x4a, 0xf6, + 0x5a, 0x71, 0xf0, 0x1e, 0xa8, 0xd2, 0xa1, 0x3c, 0xe4, 0x91, 0x27, 0x47, 0xc8, 0x68, 0x18, 0x9b, + 0xd5, 0x1e, 0xfa, 0x71, 0xd2, 0xbe, 0x9a, 0x9e, 0x67, 0xc7, 0x71, 0x22, 0x26, 0xc4, 0x9e, 0x8c, + 0xbc, 0xc0, 0xb5, 0x72, 0x2b, 0xdc, 0x06, 0x95, 0xfe, 0x11, 0xb7, 0x07, 0xe8, 0x42, 0xc3, 0xd8, + 0xbc, 0xd4, 0xc5, 0x24, 0x6b, 0x26, 0xba, 0x31, 0xee, 0x90, 0x5e, 0xa2, 0xeb, 0x1a, 0x4b, 0x9b, + 0xe1, 0x63, 0x70, 0x91, 0xc5, 0x9e, 0xc3, 0x02, 0x9b, 0xa1, 0x25, 0x05, 0xde, 0x28, 0x00, 0x9f, + 0xa5, 0x96, 0x94, 0x9d, 0x23, 0xf0, 0x09, 0xa8, 0xc6, 0xf4, 0xc8, 0x73, 0xa8, 0xe4, 0x11, 0x2a, + 0x2b, 0xbe, 0x59, 0xc0, 0xbf, 0xc9, 0x3c, 0x69, 0x40, 0x0e, 0xc1, 0x17, 0xa0, 0x9c, 0x4c, 0x06, + 0x55, 0x14, 0x7c, 0xbd, 0x00, 0xde, 0xe9, 0x3d, 0x7d, 0xa9, 0xb9, 0xde, 0xb5, 0x5f, 0x27, 0xed, + 0x55, 0x3d, 0x88, 0xb6, 0x70, 0x06, 0x8d, 0x2d, 0x72, 0x77, 0x0b, 0x19, 0x96, 0x4a, 0x80, 0xfb, + 0xa0, 0x2a, 0x46, 0x81, 0x7d, 0x18, 0xf1, 0x60, 0x84, 0x96, 0xcf, 0x3d, 0xcb, 0x5e, 0xe6, 0x49, + 0x33, 0x6b, 0xff, 0x66, 0x76, 0xac, 0x3c, 0x09, 0xbe, 0x02, 0x2b, 0x07, 0x8c, 0xca, 0x61, 0xc4, + 0xd0, 0x8a, 0x0a, 0x6d, 0x14, 0x84, 0x3e, 0xd7, 0x8e, 0xf3, 0x23, 0xbb, 0x56, 0x96, 0xf2, 0xe8, + 0xe1, 0xc7, 0xd9, 0xb8, 0x95, 0xbf, 0xb8, 0xcf, 0xb3, 0x71, 0xeb, 0x56, 0x6e, 0x36, 0x8f, 0xff, + 0xda, 0xe2, 0x85, 0xdd, 0x68, 0xae, 0x83, 0xb5, 0x85, 0x47, 0x16, 0x13, 0x61, 0x62, 0xef, 0x7e, + 0x32, 0xc0, 0xd2, 0xae, 0x70, 0xe1, 0x7b, 0x70, 0xf9, 0xcc, 0x3a, 0xdd, 0x24, 0x05, 0xdb, 0x4f, + 0x16, 0x52, 0xea, 0xb7, 0xff, 0xc7, 0x95, 0x75, 0x35, 0x6b, 0xdf, 0x17, 0xef, 0xb7, 0x7d, 0xbf, + 0x5e, 0xf9, 0x30, 0x1b, 0xb7, 0x8c, 0xde, 0x83, 0x6f, 0x13, 0x6c, 0x9c, 0x4e, 0xb0, 0xf1, 0x7b, + 0x82, 0x8d, 0x2f, 0x53, 0x5c, 0x3a, 0x9d, 0xe2, 0xd2, 0xcf, 0x29, 0x2e, 0xbd, 0xc5, 0x9a, 0x10, + 0xce, 0x80, 0x78, 0xfc, 0xcc, 0x35, 0xd5, 0x18, 0xfb, 0xcb, 0xea, 0x9b, 0xb8, 0xf3, 0x27, 0x00, + 0x00, 0xff, 0xff, 0x6c, 0x14, 0x46, 0x20, 0xcd, 0x03, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -359,8 +229,6 @@ type MsgClient interface { // UpdateParams defines a governance operation for updating the x/consensus module parameters. // The authority is defined in the keeper. UpdateParams(ctx context.Context, in *MsgUpdateParams, opts ...grpc.CallOption) (*MsgUpdateParamsResponse, error) - // SetCometInfo defines how to set the comet info for the x/consensus module. - SetCometInfo(ctx context.Context, in *MsgSetCometInfo, opts ...grpc.CallOption) (*MsgSetCometInfoResponse, error) } type msgClient struct { @@ -380,22 +248,11 @@ func (c *msgClient) UpdateParams(ctx context.Context, in *MsgUpdateParams, opts return out, nil } -func (c *msgClient) SetCometInfo(ctx context.Context, in *MsgSetCometInfo, opts ...grpc.CallOption) (*MsgSetCometInfoResponse, error) { - out := new(MsgSetCometInfoResponse) - err := c.cc.Invoke(ctx, "/cosmos.consensus.v1.Msg/SetCometInfo", in, out, opts...) - if err != nil { - return nil, err - } - return out, nil -} - // MsgServer is the server API for Msg service. type MsgServer interface { // UpdateParams defines a governance operation for updating the x/consensus module parameters. // The authority is defined in the keeper. UpdateParams(context.Context, *MsgUpdateParams) (*MsgUpdateParamsResponse, error) - // SetCometInfo defines how to set the comet info for the x/consensus module. - SetCometInfo(context.Context, *MsgSetCometInfo) (*MsgSetCometInfoResponse, error) } // UnimplementedMsgServer can be embedded to have forward compatible implementations. @@ -405,9 +262,6 @@ type UnimplementedMsgServer struct { func (*UnimplementedMsgServer) UpdateParams(ctx context.Context, req *MsgUpdateParams) (*MsgUpdateParamsResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method UpdateParams not implemented") } -func (*UnimplementedMsgServer) SetCometInfo(ctx context.Context, req *MsgSetCometInfo) (*MsgSetCometInfoResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method SetCometInfo not implemented") -} func RegisterMsgServer(s grpc1.Server, srv MsgServer) { s.RegisterService(&_Msg_serviceDesc, srv) @@ -431,24 +285,6 @@ func _Msg_UpdateParams_Handler(srv interface{}, ctx context.Context, dec func(in return interceptor(ctx, in, info, handler) } -func _Msg_SetCometInfo_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(MsgSetCometInfo) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(MsgServer).SetCometInfo(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/cosmos.consensus.v1.Msg/SetCometInfo", - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(MsgServer).SetCometInfo(ctx, req.(*MsgSetCometInfo)) - } - return interceptor(ctx, in, info, handler) -} - var _Msg_serviceDesc = grpc.ServiceDesc{ ServiceName: "cosmos.consensus.v1.Msg", HandlerType: (*MsgServer)(nil), @@ -457,10 +293,6 @@ var _Msg_serviceDesc = grpc.ServiceDesc{ MethodName: "UpdateParams", Handler: _Msg_UpdateParams_Handler, }, - { - MethodName: "SetCometInfo", - Handler: _Msg_SetCometInfo_Handler, - }, }, Streams: []grpc.StreamDesc{}, Metadata: "cosmos/consensus/v1/tx.proto", @@ -591,99 +423,6 @@ func (m *MsgUpdateParamsResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) return len(dAtA) - i, nil } -func (m *MsgSetCometInfo) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *MsgSetCometInfo) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *MsgSetCometInfo) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if m.LastCommit != nil { - { - size, err := m.LastCommit.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintTx(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x2a - } - if len(m.ProposerAddress) > 0 { - i -= len(m.ProposerAddress) - copy(dAtA[i:], m.ProposerAddress) - i = encodeVarintTx(dAtA, i, uint64(len(m.ProposerAddress))) - i-- - dAtA[i] = 0x22 - } - if len(m.ValidatorsHash) > 0 { - i -= len(m.ValidatorsHash) - copy(dAtA[i:], m.ValidatorsHash) - i = encodeVarintTx(dAtA, i, uint64(len(m.ValidatorsHash))) - i-- - dAtA[i] = 0x1a - } - if len(m.Evidence) > 0 { - for iNdEx := len(m.Evidence) - 1; iNdEx >= 0; iNdEx-- { - { - size, err := m.Evidence[iNdEx].MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintTx(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x12 - } - } - if len(m.Authority) > 0 { - i -= len(m.Authority) - copy(dAtA[i:], m.Authority) - i = encodeVarintTx(dAtA, i, uint64(len(m.Authority))) - i-- - dAtA[i] = 0xa - } - return len(dAtA) - i, nil -} - -func (m *MsgSetCometInfoResponse) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *MsgSetCometInfoResponse) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *MsgSetCometInfoResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - return len(dAtA) - i, nil -} - func encodeVarintTx(dAtA []byte, offset int, v uint64) int { offset -= sovTx(v) base := offset @@ -741,46 +480,6 @@ func (m *MsgUpdateParamsResponse) Size() (n int) { return n } -func (m *MsgSetCometInfo) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = len(m.Authority) - if l > 0 { - n += 1 + l + sovTx(uint64(l)) - } - if len(m.Evidence) > 0 { - for _, e := range m.Evidence { - l = e.Size() - n += 1 + l + sovTx(uint64(l)) - } - } - l = len(m.ValidatorsHash) - if l > 0 { - n += 1 + l + sovTx(uint64(l)) - } - l = len(m.ProposerAddress) - if l > 0 { - n += 1 + l + sovTx(uint64(l)) - } - if m.LastCommit != nil { - l = m.LastCommit.Size() - n += 1 + l + sovTx(uint64(l)) - } - return n -} - -func (m *MsgSetCometInfoResponse) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - return n -} - func sovTx(x uint64) (n int) { return (math_bits.Len64(x|1) + 6) / 7 } @@ -1135,276 +834,6 @@ func (m *MsgUpdateParamsResponse) Unmarshal(dAtA []byte) error { } return nil } -func (m *MsgSetCometInfo) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTx - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: MsgSetCometInfo: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: MsgSetCometInfo: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Authority", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTx - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthTx - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthTx - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Authority = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Evidence", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTx - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthTx - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthTx - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Evidence = append(m.Evidence, &v11.Misbehavior{}) - if err := m.Evidence[len(m.Evidence)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 3: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field ValidatorsHash", wireType) - } - var byteLen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTx - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - byteLen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if byteLen < 0 { - return ErrInvalidLengthTx - } - postIndex := iNdEx + byteLen - if postIndex < 0 { - return ErrInvalidLengthTx - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.ValidatorsHash = append(m.ValidatorsHash[:0], dAtA[iNdEx:postIndex]...) - if m.ValidatorsHash == nil { - m.ValidatorsHash = []byte{} - } - iNdEx = postIndex - case 4: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field ProposerAddress", wireType) - } - var byteLen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTx - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - byteLen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if byteLen < 0 { - return ErrInvalidLengthTx - } - postIndex := iNdEx + byteLen - if postIndex < 0 { - return ErrInvalidLengthTx - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.ProposerAddress = append(m.ProposerAddress[:0], dAtA[iNdEx:postIndex]...) - if m.ProposerAddress == nil { - m.ProposerAddress = []byte{} - } - iNdEx = postIndex - case 5: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field LastCommit", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTx - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthTx - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthTx - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if m.LastCommit == nil { - m.LastCommit = &v11.CommitInfo{} - } - if err := m.LastCommit.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipTx(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthTx - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *MsgSetCometInfoResponse) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTx - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: MsgSetCometInfoResponse: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: MsgSetCometInfoResponse: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - default: - iNdEx = preIndex - skippy, err := skipTx(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthTx - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} func skipTx(dAtA []byte) (n int, err error) { l := len(dAtA) iNdEx := 0 diff --git a/x/distribution/CHANGELOG.md b/x/distribution/CHANGELOG.md index 86940a5e2d81..0a341876bc94 100644 --- a/x/distribution/CHANGELOG.md +++ b/x/distribution/CHANGELOG.md @@ -29,9 +29,13 @@ Ref: https://keepachangelog.com/en/1.0.0/ * -### API Breaking Changes +### Improvements +* [#20790](https://github.com/cosmos/cosmos-sdk/pull/20790) `x/distribution` does not depend on `x/protocolpool` anymore, now `x/distribution` only does token transfers and `x/protocolpool` does the rest. + +### API Breaking Changes +* [#20790](https://github.com/cosmos/cosmos-sdk/pull/20790) `x/distribution` does not depend on `x/protocolpool` anymore, meaning NewAppModule and NewKeeper do not take it as an argument. * [#20588](https://github.com/cosmos/cosmos-sdk/pull/20588) `x/distribution` now takes cometService in order to get consensus related information. * [#19868](https://github.com/cosmos/cosmos-sdk/pull/19868) Removes Accounts String method * `NewMsgSetWithdrawAddress` now takes strings as argument instead of `sdk.AccAddress`. @@ -52,7 +56,7 @@ Ref: https://keepachangelog.com/en/1.0.0/ * remove `Keeper`: `SetDelegatorWithdrawAddr`, `DeleteDelegatorWithdrawAddr`, `IterateDelegatorWithdrawAddrs`. * [#16459](https://github.com/cosmos/cosmos-sdk/pull/16459) use collections for `ValidatorCurrentRewards` state management: * remove `Keeper`: `IterateValidatorCurrentRewards`, `GetValidatorCurrentRewards`, `SetValidatorCurrentRewards`, `DeleteValidatorCurrentRewards` -* [#17657](https://github.com/cosmos/cosmos-sdk/pull/17657) The distribution module keeper now takes a new argument `PoolKeeper` in addition. +* [#17657](https://github.com/cosmos/cosmos-sdk/pull/17657) ~The distribution module keeper now takes a new argument `PoolKeeper` in addition.~ Reverted on #20790 * [#17670](https://github.com/cosmos/cosmos-sdk/pull/17670) `AllocateTokens` takes `comet.VoteInfos` instead of `[]abci.VoteInfo` * [#19740](https://github.com/cosmos/cosmos-sdk/pull/19740) `InitGenesis` and `ExportGenesis` module code and keeper code do not panic but return errors. diff --git a/x/distribution/depinject.go b/x/distribution/depinject.go index ddd6c64b33b3..07e63548efac 100644 --- a/x/distribution/depinject.go +++ b/x/distribution/depinject.go @@ -36,7 +36,6 @@ type ModuleInputs struct { AccountKeeper types.AccountKeeper BankKeeper types.BankKeeper StakingKeeper types.StakingKeeper - PoolKeeper types.PoolKeeper } type ModuleOutputs struct { @@ -70,13 +69,12 @@ func ProvideModule(in ModuleInputs) ModuleOutputs { in.AccountKeeper, in.BankKeeper, in.StakingKeeper, - in.PoolKeeper, in.CometService, feeCollectorName, authorityAddr, ) - m := NewAppModule(in.Cdc, k, in.AccountKeeper, in.BankKeeper, in.StakingKeeper, in.PoolKeeper) + m := NewAppModule(in.Cdc, k, in.AccountKeeper, in.BankKeeper, in.StakingKeeper) return ModuleOutputs{ DistrKeeper: k, diff --git a/x/distribution/go.mod b/x/distribution/go.mod index b812981659ac..bc58aea63171 100644 --- a/x/distribution/go.mod +++ b/x/distribution/go.mod @@ -7,7 +7,7 @@ require ( cosmossdk.io/collections v0.4.0 cosmossdk.io/core v0.12.1-0.20231114100755-569e3ff6a0d7 cosmossdk.io/core/testing v0.0.0-00010101000000-000000000000 - cosmossdk.io/depinject v1.0.0-alpha.4 + cosmossdk.io/depinject v1.0.0 cosmossdk.io/errors v1.0.1 cosmossdk.io/log v1.3.1 cosmossdk.io/math v1.3.0 @@ -16,7 +16,7 @@ require ( cosmossdk.io/x/protocolpool v0.0.0-20230925135524-a1bc045b3190 cosmossdk.io/x/staking v0.0.0-00010101000000-000000000000 github.com/cosmos/cosmos-proto v1.0.0-beta.5 - github.com/cosmos/cosmos-sdk v0.51.0 + github.com/cosmos/cosmos-sdk v0.53.0 github.com/cosmos/gogoproto v1.5.0 github.com/golang/mock v1.6.0 github.com/golang/protobuf v1.5.4 @@ -65,7 +65,7 @@ require ( github.com/cosmos/crypto v0.1.2 // indirect github.com/cosmos/go-bip39 v1.0.0 // indirect github.com/cosmos/gogogateway v1.2.0 // indirect - github.com/cosmos/iavl v1.2.0 // indirect + github.com/cosmos/iavl v1.2.1-0.20240725141113-7adc688cf179 // indirect github.com/cosmos/ics23/go v0.10.0 // indirect github.com/cosmos/ledger-cosmos-go v0.13.3 // indirect github.com/danieljoos/wincred v1.2.1 // indirect @@ -182,12 +182,11 @@ replace ( cosmossdk.io/collections => ../../collections cosmossdk.io/core => ../../core cosmossdk.io/core/testing => ../../core/testing - cosmossdk.io/depinject => ../../depinject - cosmossdk.io/log => ../../log cosmossdk.io/x/accounts => ../accounts cosmossdk.io/x/auth => ../auth cosmossdk.io/x/bank => ../bank cosmossdk.io/x/consensus => ../consensus + cosmossdk.io/x/protocolpool => ../protocolpool cosmossdk.io/x/staking => ../staking cosmossdk.io/x/tx => ../tx ) diff --git a/x/distribution/go.sum b/x/distribution/go.sum index 4aa0abf8728a..4e269960625f 100644 --- a/x/distribution/go.sum +++ b/x/distribution/go.sum @@ -4,16 +4,18 @@ buf.build/gen/go/cosmos/gogo-proto/protocolbuffers/go v1.34.2-20240130113600-88e buf.build/gen/go/cosmos/gogo-proto/protocolbuffers/go v1.34.2-20240130113600-88ef6483f90f.2/go.mod h1:HqcXMSa5qnNuakaMUo+hWhF51mKbcrZxGl9Vp5EeJXc= cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= cloud.google.com/go v0.34.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= +cosmossdk.io/depinject v1.0.0 h1:dQaTu6+O6askNXO06+jyeUAnF2/ssKwrrszP9t5q050= +cosmossdk.io/depinject v1.0.0/go.mod h1:zxK/h3HgHoA/eJVtiSsoaRaRA2D5U4cJ5thIG4ssbB8= cosmossdk.io/errors v1.0.1 h1:bzu+Kcr0kS/1DuPBtUFdWjzLqyUuCiyHjyJB6srBV/0= cosmossdk.io/errors v1.0.1/go.mod h1:MeelVSZThMi4bEakzhhhE/CKqVv3nOJDA25bIqRDu/U= +cosmossdk.io/log v1.3.1 h1:UZx8nWIkfbbNEWusZqzAx3ZGvu54TZacWib3EzUYmGI= +cosmossdk.io/log v1.3.1/go.mod h1:2/dIomt8mKdk6vl3OWJcPk2be3pGOS8OQaLUM/3/tCM= cosmossdk.io/math v1.3.0 h1:RC+jryuKeytIiictDslBP9i1fhkVm6ZDmZEoNP316zE= cosmossdk.io/math v1.3.0/go.mod h1:vnRTxewy+M7BtXBNFybkuhSH4WfedVAAnERHgVFhp3k= cosmossdk.io/schema v0.1.1 h1:I0M6pgI7R10nq+/HCQfbO6BsGBZA8sQy+duR1Y3aKcA= cosmossdk.io/schema v0.1.1/go.mod h1:RDAhxIeNB4bYqAlF4NBJwRrgtnciMcyyg0DOKnhNZQQ= cosmossdk.io/store v1.1.1-0.20240418092142-896cdf1971bc h1:R9O9d75e0qZYUsVV0zzi+D7cNLnX2JrUOQNoIPaF0Bg= cosmossdk.io/store v1.1.1-0.20240418092142-896cdf1971bc/go.mod h1:amTTatOUV3u1PsKmNb87z6/galCxrRbz9kRdJkL0DyU= -cosmossdk.io/x/protocolpool v0.0.0-20230925135524-a1bc045b3190 h1:XQJj9Dv9Gtze0l2TF79BU5lkP6MkUveTUuKICmxoz+o= -cosmossdk.io/x/protocolpool v0.0.0-20230925135524-a1bc045b3190/go.mod h1:7WUGupOvmlHJoIMBz1JbObQxeo6/TDiuDBxmtod8HRg= filippo.io/edwards25519 v1.1.0 h1:FNf4tywRC1HmFuKW5xopWpigGjJKiJSV0Cqo0cJWDaA= filippo.io/edwards25519 v1.1.0/go.mod h1:BxyFTGdWcka3PhytdK4V28tE5sGfRvvvRV7EaN4VDT4= github.com/99designs/go-keychain v0.0.0-20191008050251-8e49817e8af4 h1:/vQbFIOMbk2FiG/kXiLl8BRyzTWDw7gX/Hz7Dd5eDMs= @@ -111,8 +113,8 @@ github.com/cosmos/gogogateway v1.2.0/go.mod h1:iQpLkGWxYcnCdz5iAdLcRBSw3h7NXeOkZ github.com/cosmos/gogoproto v1.4.2/go.mod h1:cLxOsn1ljAHSV527CHOtaIP91kK6cCrZETRBrkzItWU= github.com/cosmos/gogoproto v1.5.0 h1:SDVwzEqZDDBoslaeZg+dGE55hdzHfgUA40pEanMh52o= github.com/cosmos/gogoproto v1.5.0/go.mod h1:iUM31aofn3ymidYG6bUR5ZFrk+Om8p5s754eMUcyp8I= -github.com/cosmos/iavl v1.2.0 h1:kVxTmjTh4k0Dh1VNL046v6BXqKziqMDzxo93oh3kOfM= -github.com/cosmos/iavl v1.2.0/go.mod h1:HidWWLVAtODJqFD6Hbne2Y0q3SdxByJepHUOeoH4LiI= +github.com/cosmos/iavl v1.2.1-0.20240725141113-7adc688cf179 h1:wmwDn7V3RodN9auB3FooSQxs46nHVE3u0mb87TJkZFE= +github.com/cosmos/iavl v1.2.1-0.20240725141113-7adc688cf179/go.mod h1:GiM43q0pB+uG53mLxLDzimxM9l/5N9UuSY3/D0huuVw= github.com/cosmos/ics23/go v0.10.0 h1:iXqLLgp2Lp+EdpIuwXTYIQU+AiHj9mOC2X9ab++bZDM= github.com/cosmos/ics23/go v0.10.0/go.mod h1:ZfJSmng/TBNTBkFemHHHj5YY7VAU/MBU980F4VU1NG0= github.com/cosmos/ledger-cosmos-go v0.13.3 h1:7ehuBGuyIytsXbd4MP43mLeoN2LTOEnk5nvue4rK+yM= diff --git a/x/distribution/keeper/allocation.go b/x/distribution/keeper/allocation.go index 992c487ddb46..123b161c0b58 100644 --- a/x/distribution/keeper/allocation.go +++ b/x/distribution/keeper/allocation.go @@ -79,12 +79,7 @@ func (k Keeper) AllocateTokens(ctx context.Context, totalPreviousPower int64, bo } // send to community pool and set remainder in fee pool amt, re := remaining.TruncateDecimal() - if err := k.bankKeeper.SendCoinsFromModuleToModule(ctx, types.ModuleName, types.ProtocolPoolModuleName, amt); err != nil { - return err - } - - // set ToDistribute in protocolpool to keep track of continuous funds distribution - if err := k.poolKeeper.SetToDistribute(ctx, amt, k.GetAuthority()); err != nil { // TODO: this should be distribution module account + if err := k.bankKeeper.SendCoinsFromModuleToModule(ctx, types.ModuleName, types.ProtocolPoolDistrAccount, amt); err != nil { return err } @@ -170,7 +165,7 @@ func (k Keeper) sendDecimalPoolToCommunityPool(ctx context.Context) error { } amt, re := feePool.DecimalPool.TruncateDecimal() - if err := k.bankKeeper.SendCoinsFromModuleToModule(ctx, types.ModuleName, types.ProtocolPoolModuleName, amt); err != nil { + if err := k.bankKeeper.SendCoinsFromModuleToModule(ctx, types.ModuleName, types.ProtocolPoolDistrAccount, amt); err != nil { return err } diff --git a/x/distribution/keeper/allocation_test.go b/x/distribution/keeper/allocation_test.go index b76b3409fbc9..f319ad456cbe 100644 --- a/x/distribution/keeper/allocation_test.go +++ b/x/distribution/keeper/allocation_test.go @@ -51,7 +51,6 @@ func TestAllocateTokensToValidatorWithCommission(t *testing.T) { bankKeeper := distrtestutil.NewMockBankKeeper(ctrl) stakingKeeper := distrtestutil.NewMockStakingKeeper(ctrl) accountKeeper := distrtestutil.NewMockAccountKeeper(ctrl) - poolKeeper := distrtestutil.NewMockPoolKeeper(ctrl) env := runtime.NewEnvironment(runtime.NewKVStoreService(key), coretesting.NewNopLogger()) @@ -69,7 +68,6 @@ func TestAllocateTokensToValidatorWithCommission(t *testing.T) { accountKeeper, bankKeeper, stakingKeeper, - poolKeeper, testCometService, "fee_collector", authorityAddr, @@ -118,7 +116,6 @@ func TestAllocateTokensToManyValidators(t *testing.T) { bankKeeper := distrtestutil.NewMockBankKeeper(ctrl) stakingKeeper := distrtestutil.NewMockStakingKeeper(ctrl) accountKeeper := distrtestutil.NewMockAccountKeeper(ctrl) - poolKeeper := distrtestutil.NewMockPoolKeeper(ctrl) feeCollectorAcc := authtypes.NewEmptyModuleAccount("fee_collector") accountKeeper.EXPECT().GetModuleAddress("distribution").Return(distrAcc.GetAddress()) @@ -136,7 +133,6 @@ func TestAllocateTokensToManyValidators(t *testing.T) { accountKeeper, bankKeeper, stakingKeeper, - poolKeeper, testCometService, "fee_collector", authorityAddr, @@ -200,8 +196,7 @@ func TestAllocateTokensToManyValidators(t *testing.T) { fees := sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, math.NewInt(100))) bankKeeper.EXPECT().GetAllBalances(gomock.Any(), feeCollectorAcc.GetAddress()).Return(fees) bankKeeper.EXPECT().SendCoinsFromModuleToModule(gomock.Any(), "fee_collector", disttypes.ModuleName, fees) - bankKeeper.EXPECT().SendCoinsFromModuleToModule(gomock.Any(), disttypes.ModuleName, disttypes.ProtocolPoolModuleName, sdk.Coins{{Denom: sdk.DefaultBondDenom, Amount: math.NewInt(2)}}) // 2 community pool coins - poolKeeper.EXPECT().SetToDistribute(ctx, gomock.Any(), gomock.Any()) + bankKeeper.EXPECT().SendCoinsFromModuleToModule(gomock.Any(), disttypes.ModuleName, disttypes.ProtocolPoolDistrAccount, sdk.Coins{{Denom: sdk.DefaultBondDenom, Amount: math.NewInt(2)}}) // 2 community pool coins votes := []comet.VoteInfo{ { @@ -259,7 +254,6 @@ func TestAllocateTokensTruncation(t *testing.T) { bankKeeper := distrtestutil.NewMockBankKeeper(ctrl) stakingKeeper := distrtestutil.NewMockStakingKeeper(ctrl) accountKeeper := distrtestutil.NewMockAccountKeeper(ctrl) - poolKeeper := distrtestutil.NewMockPoolKeeper(ctrl) feeCollectorAcc := authtypes.NewEmptyModuleAccount("fee_collector") accountKeeper.EXPECT().GetModuleAddress("distribution").Return(distrAcc.GetAddress()) @@ -277,7 +271,6 @@ func TestAllocateTokensTruncation(t *testing.T) { accountKeeper, bankKeeper, stakingKeeper, - poolKeeper, testCometService, "fee_collector", authorityAddr, @@ -354,8 +347,7 @@ func TestAllocateTokensTruncation(t *testing.T) { fees := sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, math.NewInt(634195840))) bankKeeper.EXPECT().GetAllBalances(gomock.Any(), feeCollectorAcc.GetAddress()).Return(fees) bankKeeper.EXPECT().SendCoinsFromModuleToModule(gomock.Any(), "fee_collector", disttypes.ModuleName, fees) - bankKeeper.EXPECT().SendCoinsFromModuleToModule(gomock.Any(), disttypes.ModuleName, disttypes.ProtocolPoolModuleName, gomock.Any()) // something is sent to community pool - poolKeeper.EXPECT().SetToDistribute(ctx, gomock.Any(), gomock.Any()) + bankKeeper.EXPECT().SendCoinsFromModuleToModule(gomock.Any(), disttypes.ModuleName, disttypes.ProtocolPoolDistrAccount, gomock.Any()) // something is sent to community pool votes := []comet.VoteInfo{ { diff --git a/x/distribution/keeper/delegation.go b/x/distribution/keeper/delegation.go index e175d48795b6..7bf2091edb89 100644 --- a/x/distribution/keeper/delegation.go +++ b/x/distribution/keeper/delegation.go @@ -52,12 +52,12 @@ func (k Keeper) calculateDelegationRewardsBetween(ctx context.Context, val sdk.V ) (sdk.DecCoins, error) { // sanity check if startingPeriod > endingPeriod { - return sdk.DecCoins{}, fmt.Errorf("startingPeriod cannot be greater than endingPeriod") + return sdk.DecCoins{}, errors.New("startingPeriod cannot be greater than endingPeriod") } // sanity check if stake.IsNegative() { - return sdk.DecCoins{}, fmt.Errorf("stake should not be negative") + return sdk.DecCoins{}, errors.New("stake should not be negative") } valBz, err := k.stakingKeeper.ValidatorAddressCodec().StringToBytes(val.GetOperator()) @@ -78,7 +78,7 @@ func (k Keeper) calculateDelegationRewardsBetween(ctx context.Context, val sdk.V difference := ending.CumulativeRewardRatio.Sub(starting.CumulativeRewardRatio) if difference.IsAnyNegative() { - return sdk.DecCoins{}, fmt.Errorf("negative rewards should not be possible") + return sdk.DecCoins{}, errors.New("negative rewards should not be possible") } // note: necessary to truncate so we don't allow withdrawing more rewards than owed rewards := difference.MulDecTruncate(stake) diff --git a/x/distribution/keeper/delegation_test.go b/x/distribution/keeper/delegation_test.go index 76bcfb628787..31419b10e082 100644 --- a/x/distribution/keeper/delegation_test.go +++ b/x/distribution/keeper/delegation_test.go @@ -36,7 +36,6 @@ func TestCalculateRewardsBasic(t *testing.T) { bankKeeper := distrtestutil.NewMockBankKeeper(ctrl) stakingKeeper := distrtestutil.NewMockStakingKeeper(ctrl) accountKeeper := distrtestutil.NewMockAccountKeeper(ctrl) - poolKeeper := distrtestutil.NewMockPoolKeeper(ctrl) accountKeeper.EXPECT().GetModuleAddress("distribution").Return(distrAcc.GetAddress()) stakingKeeper.EXPECT().ValidatorAddressCodec().Return(address.NewBech32Codec(sdk.Bech32PrefixValAddr)).AnyTimes() @@ -53,7 +52,6 @@ func TestCalculateRewardsBasic(t *testing.T) { accountKeeper, bankKeeper, stakingKeeper, - poolKeeper, testCometService, "fee_collector", authorityAddr, @@ -150,7 +148,6 @@ func TestCalculateRewardsAfterSlash(t *testing.T) { bankKeeper := distrtestutil.NewMockBankKeeper(ctrl) stakingKeeper := distrtestutil.NewMockStakingKeeper(ctrl) accountKeeper := distrtestutil.NewMockAccountKeeper(ctrl) - poolKeeper := distrtestutil.NewMockPoolKeeper(ctrl) accountKeeper.EXPECT().GetModuleAddress("distribution").Return(distrAcc.GetAddress()) stakingKeeper.EXPECT().ValidatorAddressCodec().Return(address.NewBech32Codec(sdk.Bech32PrefixValAddr)).AnyTimes() @@ -167,7 +164,6 @@ func TestCalculateRewardsAfterSlash(t *testing.T) { accountKeeper, bankKeeper, stakingKeeper, - poolKeeper, testCometService, "fee_collector", authorityAddr, @@ -267,7 +263,6 @@ func TestCalculateRewardsAfterManySlashes(t *testing.T) { bankKeeper := distrtestutil.NewMockBankKeeper(ctrl) stakingKeeper := distrtestutil.NewMockStakingKeeper(ctrl) accountKeeper := distrtestutil.NewMockAccountKeeper(ctrl) - poolKeeper := distrtestutil.NewMockPoolKeeper(ctrl) accountKeeper.EXPECT().GetModuleAddress("distribution").Return(distrAcc.GetAddress()) stakingKeeper.EXPECT().ValidatorAddressCodec().Return(address.NewBech32Codec(sdk.Bech32PrefixValAddr)).AnyTimes() @@ -284,7 +279,6 @@ func TestCalculateRewardsAfterManySlashes(t *testing.T) { accountKeeper, bankKeeper, stakingKeeper, - poolKeeper, testCometService, "fee_collector", authorityAddr, @@ -405,7 +399,6 @@ func TestCalculateRewardsMultiDelegator(t *testing.T) { bankKeeper := distrtestutil.NewMockBankKeeper(ctrl) stakingKeeper := distrtestutil.NewMockStakingKeeper(ctrl) accountKeeper := distrtestutil.NewMockAccountKeeper(ctrl) - poolKeeper := distrtestutil.NewMockPoolKeeper(ctrl) accountKeeper.EXPECT().GetModuleAddress("distribution").Return(distrAcc.GetAddress()) stakingKeeper.EXPECT().ValidatorAddressCodec().Return(address.NewBech32Codec(sdk.Bech32PrefixValAddr)).AnyTimes() @@ -422,7 +415,6 @@ func TestCalculateRewardsMultiDelegator(t *testing.T) { accountKeeper, bankKeeper, stakingKeeper, - poolKeeper, testCometService, "fee_collector", authorityAddr, @@ -516,7 +508,6 @@ func TestWithdrawDelegationRewardsBasic(t *testing.T) { bankKeeper := distrtestutil.NewMockBankKeeper(ctrl) stakingKeeper := distrtestutil.NewMockStakingKeeper(ctrl) accountKeeper := distrtestutil.NewMockAccountKeeper(ctrl) - poolKeeper := distrtestutil.NewMockPoolKeeper(ctrl) accountKeeper.EXPECT().GetModuleAddress("distribution").Return(distrAcc.GetAddress()) stakingKeeper.EXPECT().ValidatorAddressCodec().Return(address.NewBech32Codec(sdk.Bech32PrefixValAddr)).AnyTimes() @@ -533,7 +524,6 @@ func TestWithdrawDelegationRewardsBasic(t *testing.T) { accountKeeper, bankKeeper, stakingKeeper, - poolKeeper, testCometService, "fee_collector", authorityAddr, @@ -605,7 +595,6 @@ func TestCalculateRewardsAfterManySlashesInSameBlock(t *testing.T) { bankKeeper := distrtestutil.NewMockBankKeeper(ctrl) stakingKeeper := distrtestutil.NewMockStakingKeeper(ctrl) accountKeeper := distrtestutil.NewMockAccountKeeper(ctrl) - poolKeeper := distrtestutil.NewMockPoolKeeper(ctrl) accountKeeper.EXPECT().GetModuleAddress("distribution").Return(distrAcc.GetAddress()) stakingKeeper.EXPECT().ValidatorAddressCodec().Return(address.NewBech32Codec(sdk.Bech32PrefixValAddr)).AnyTimes() @@ -622,7 +611,6 @@ func TestCalculateRewardsAfterManySlashesInSameBlock(t *testing.T) { accountKeeper, bankKeeper, stakingKeeper, - poolKeeper, testCometService, "fee_collector", authorityAddr, @@ -735,7 +723,6 @@ func TestCalculateRewardsMultiDelegatorMultiSlash(t *testing.T) { bankKeeper := distrtestutil.NewMockBankKeeper(ctrl) stakingKeeper := distrtestutil.NewMockStakingKeeper(ctrl) accountKeeper := distrtestutil.NewMockAccountKeeper(ctrl) - poolKeeper := distrtestutil.NewMockPoolKeeper(ctrl) accountKeeper.EXPECT().GetModuleAddress("distribution").Return(distrAcc.GetAddress()) stakingKeeper.EXPECT().ValidatorAddressCodec().Return(address.NewBech32Codec(sdk.Bech32PrefixValAddr)).AnyTimes() @@ -752,7 +739,6 @@ func TestCalculateRewardsMultiDelegatorMultiSlash(t *testing.T) { accountKeeper, bankKeeper, stakingKeeper, - poolKeeper, testCometService, "fee_collector", authorityAddr, @@ -889,7 +875,6 @@ func TestCalculateRewardsMultiDelegatorMultWithdraw(t *testing.T) { bankKeeper := distrtestutil.NewMockBankKeeper(ctrl) stakingKeeper := distrtestutil.NewMockStakingKeeper(ctrl) accountKeeper := distrtestutil.NewMockAccountKeeper(ctrl) - poolKeeper := distrtestutil.NewMockPoolKeeper(ctrl) accountKeeper.EXPECT().GetModuleAddress("distribution").Return(distrAcc.GetAddress()) stakingKeeper.EXPECT().ValidatorAddressCodec().Return(address.NewBech32Codec(sdk.Bech32PrefixValAddr)).AnyTimes() @@ -906,7 +891,6 @@ func TestCalculateRewardsMultiDelegatorMultWithdraw(t *testing.T) { accountKeeper, bankKeeper, stakingKeeper, - poolKeeper, testCometService, "fee_collector", authorityAddr, @@ -1103,7 +1087,6 @@ func Test100PercentCommissionReward(t *testing.T) { bankKeeper := distrtestutil.NewMockBankKeeper(ctrl) stakingKeeper := distrtestutil.NewMockStakingKeeper(ctrl) accountKeeper := distrtestutil.NewMockAccountKeeper(ctrl) - poolKeeper := distrtestutil.NewMockPoolKeeper(ctrl) accountKeeper.EXPECT().GetModuleAddress("distribution").Return(distrAcc.GetAddress()) stakingKeeper.EXPECT().ValidatorAddressCodec().Return(address.NewBech32Codec(sdk.Bech32PrefixValAddr)).AnyTimes() @@ -1121,7 +1104,6 @@ func Test100PercentCommissionReward(t *testing.T) { accountKeeper, bankKeeper, stakingKeeper, - poolKeeper, testCometService, "fee_collector", authorityAddr, diff --git a/x/distribution/keeper/grpc_query.go b/x/distribution/keeper/grpc_query.go index 62b602c8a805..de8657276fbe 100644 --- a/x/distribution/keeper/grpc_query.go +++ b/x/distribution/keeper/grpc_query.go @@ -373,9 +373,12 @@ func (k Querier) DelegatorWithdrawAddress(ctx context.Context, req *types.QueryD // This method uses deprecated query request. Use CommunityPool from x/protocolpool module instead. // CommunityPool queries the community pool coins func (k Querier) CommunityPool(ctx context.Context, req *types.QueryCommunityPoolRequest) (*types.QueryCommunityPoolResponse, error) { - pool, err := k.poolKeeper.GetCommunityPool(ctx) - if err != nil { - return nil, err + moduleAccount := k.authKeeper.GetModuleAccount(ctx, types.ProtocolPoolModuleName) + if moduleAccount == nil { + return nil, status.Error(codes.Internal, "protocolpool module account does not exist") } - return &types.QueryCommunityPoolResponse{Pool: sdk.NewDecCoinsFromCoins(pool...)}, nil + + balances := k.bankKeeper.GetAllBalances(ctx, moduleAccount.GetAddress()) + + return &types.QueryCommunityPoolResponse{Pool: sdk.NewDecCoinsFromCoins(balances...)}, nil } diff --git a/x/distribution/keeper/grpc_query_test.go b/x/distribution/keeper/grpc_query_test.go index 14bbbd66902f..affc16b392b1 100644 --- a/x/distribution/keeper/grpc_query_test.go +++ b/x/distribution/keeper/grpc_query_test.go @@ -7,6 +7,7 @@ import ( "github.com/stretchr/testify/require" "cosmossdk.io/math" + authtypes "cosmossdk.io/x/auth/types" "cosmossdk.io/x/distribution/keeper" distrtestutil "cosmossdk.io/x/distribution/testutil" "cosmossdk.io/x/distribution/types" @@ -147,9 +148,13 @@ func TestQueryCommunityPool(t *testing.T) { ctx, _, distrKeeper, dep := initFixture(t) queryServer := keeper.NewQuerier(distrKeeper) + poolAcc := authtypes.NewEmptyModuleAccount(types.ProtocolPoolModuleName) + dep.accountKeeper.EXPECT().GetModuleAccount(gomock.Any(), types.ProtocolPoolModuleName).Return(poolAcc).AnyTimes() + + dep.bankKeeper.EXPECT().GetAllBalances(gomock.Any(), poolAcc.GetAddress()).Return(sdk.NewCoins(sdk.NewCoin("stake", math.NewInt(100)))) + coins := sdk.NewCoins(sdk.NewCoin("stake", math.NewInt(100))) decCoins := sdk.NewDecCoinsFromCoins(coins...) - dep.poolKeeper.EXPECT().GetCommunityPool(gomock.Any()).Return(coins, nil).AnyTimes() cases := []struct { name string diff --git a/x/distribution/keeper/keeper.go b/x/distribution/keeper/keeper.go index bc5096c4c506..0c3238353eba 100644 --- a/x/distribution/keeper/keeper.go +++ b/x/distribution/keeper/keeper.go @@ -28,7 +28,6 @@ type Keeper struct { authKeeper types.AccountKeeper bankKeeper types.BankKeeper stakingKeeper types.StakingKeeper - poolKeeper types.PoolKeeper // the address capable of executing a MsgUpdateParams message. Typically, this // should be the x/gov module account. @@ -64,7 +63,6 @@ func NewKeeper( ak types.AccountKeeper, bk types.BankKeeper, sk types.StakingKeeper, - pk types.PoolKeeper, cometService comet.Service, feeCollectorName, authority string, ) Keeper { @@ -81,7 +79,6 @@ func NewKeeper( authKeeper: ak, bankKeeper: bk, stakingKeeper: sk, - poolKeeper: pk, feeCollectorName: feeCollectorName, authority: authority, Params: collections.NewItem(sb, types.ParamsKey, "params", codec.CollValue[types.Params](cdc)), diff --git a/x/distribution/keeper/keeper_test.go b/x/distribution/keeper/keeper_test.go index 8b6afcebd9ce..a3fdb44d797c 100644 --- a/x/distribution/keeper/keeper_test.go +++ b/x/distribution/keeper/keeper_test.go @@ -30,7 +30,6 @@ type dep struct { bankKeeper *distrtestutil.MockBankKeeper stakingKeeper *distrtestutil.MockStakingKeeper accountKeeper *distrtestutil.MockAccountKeeper - poolKeeper *distrtestutil.MockPoolKeeper } func initFixture(t *testing.T) (sdk.Context, []sdk.AccAddress, keeper.Keeper, dep) { @@ -47,7 +46,6 @@ func initFixture(t *testing.T) (sdk.Context, []sdk.AccAddress, keeper.Keeper, de bankKeeper := distrtestutil.NewMockBankKeeper(ctrl) stakingKeeper := distrtestutil.NewMockStakingKeeper(ctrl) accountKeeper := distrtestutil.NewMockAccountKeeper(ctrl) - poolKeeper := distrtestutil.NewMockPoolKeeper(ctrl) accountKeeper.EXPECT().GetModuleAddress("distribution").Return(distrAcc.GetAddress()) accountKeeper.EXPECT().AddressCodec().Return(address.NewBech32Codec("cosmos")).AnyTimes() @@ -69,7 +67,6 @@ func initFixture(t *testing.T) (sdk.Context, []sdk.AccAddress, keeper.Keeper, de accountKeeper, bankKeeper, stakingKeeper, - poolKeeper, testCometService, "fee_collector", authorityAddr, @@ -78,7 +75,7 @@ func initFixture(t *testing.T) (sdk.Context, []sdk.AccAddress, keeper.Keeper, de params := types.DefaultParams() require.NoError(t, distrKeeper.Params.Set(ctx, params)) - return ctx, addrs, distrKeeper, dep{bankKeeper, stakingKeeper, accountKeeper, poolKeeper} + return ctx, addrs, distrKeeper, dep{bankKeeper, stakingKeeper, accountKeeper} } func TestSetWithdrawAddr(t *testing.T) { diff --git a/x/distribution/keeper/migrations.go b/x/distribution/keeper/migrations.go index cb6be65cb6b2..7a35fa76f893 100644 --- a/x/distribution/keeper/migrations.go +++ b/x/distribution/keeper/migrations.go @@ -42,7 +42,7 @@ func (m Migrator) Migrate3to4(ctx context.Context) error { func (m Migrator) migrateFunds(ctx context.Context) error { macc := m.keeper.GetDistributionAccount(ctx) - poolMacc := m.keeper.authKeeper.GetModuleAccount(ctx, types.ProtocolPoolModuleName) + poolMacc := m.keeper.authKeeper.GetModuleAccount(ctx, types.ProtocolPoolDistrAccount) feePool, err := m.keeper.FeePool.Get(ctx) if err != nil { diff --git a/x/distribution/keeper/msg_server.go b/x/distribution/keeper/msg_server.go index 6f8b622f52b3..2b405f9b053a 100644 --- a/x/distribution/keeper/msg_server.go +++ b/x/distribution/keeper/msg_server.go @@ -114,7 +114,7 @@ func (k msgServer) FundCommunityPool(ctx context.Context, msg *types.MsgFundComm return nil, err } - if err := k.poolKeeper.FundCommunityPool(ctx, msg.Amount, depositor); err != nil { + if err := k.bankKeeper.SendCoinsFromAccountToModule(ctx, depositor, types.ProtocolPoolModuleName, msg.Amount); err != nil { return nil, err } @@ -158,7 +158,7 @@ func (k msgServer) CommunityPoolSpend(ctx context.Context, msg *types.MsgCommuni return nil, fmt.Errorf("invalid recipient address: %w", err) } - if err := k.poolKeeper.DistributeFromCommunityPool(ctx, msg.Amount, recipient); err != nil { + if err := k.bankKeeper.SendCoinsFromModuleToAccount(ctx, types.ProtocolPoolModuleName, recipient, msg.Amount); err != nil { return nil, err } diff --git a/x/distribution/keeper/msg_server_test.go b/x/distribution/keeper/msg_server_test.go index 8c5cad6d39ac..59a21395de4c 100644 --- a/x/distribution/keeper/msg_server_test.go +++ b/x/distribution/keeper/msg_server_test.go @@ -176,12 +176,13 @@ func TestMsgWithdrawValidatorCommission(t *testing.T) { func TestMsgFundCommunityPool(t *testing.T) { ctx, addrs, distrKeeper, dep := initFixture(t) - dep.poolKeeper.EXPECT().FundCommunityPool(gomock.Any(), gomock.Any(), gomock.Any()).Return(nil).AnyTimes() msgServer := keeper.NewMsgServerImpl(distrKeeper) addr0Str, err := codectestutil.CodecOptions{}.GetAddressCodec().BytesToString(addrs[0]) require.NoError(t, err) + dep.bankKeeper.EXPECT().SendCoinsFromAccountToModule(gomock.Any(), addrs[0], types.ProtocolPoolModuleName, sdk.NewCoins(sdk.NewCoin("stake", math.NewInt(1000)))).Return(nil) + cases := []struct { name string msg *types.MsgFundCommunityPool //nolint:staticcheck // Testing deprecated method @@ -281,7 +282,6 @@ func TestMsgUpdateParams(t *testing.T) { func TestMsgCommunityPoolSpend(t *testing.T) { ctx, addrs, distrKeeper, dep := initFixture(t) - dep.poolKeeper.EXPECT().DistributeFromCommunityPool(gomock.Any(), gomock.Any(), gomock.Any()).Return(nil).AnyTimes() msgServer := keeper.NewMsgServerImpl(distrKeeper) authorityAddr, err := codectestutil.CodecOptions{}.GetAddressCodec().BytesToString(authtypes.NewModuleAddress("gov")) @@ -289,6 +289,8 @@ func TestMsgCommunityPoolSpend(t *testing.T) { addr0Str, err := codectestutil.CodecOptions{}.GetAddressCodec().BytesToString(addrs[0]) require.NoError(t, err) + dep.bankKeeper.EXPECT().SendCoinsFromModuleToAccount(gomock.Any(), types.ProtocolPoolModuleName, addrs[0], sdk.NewCoins(sdk.NewCoin("stake", math.NewInt(1000)))).Return(nil) + cases := []struct { name string msg *types.MsgCommunityPoolSpend //nolint:staticcheck // Testing deprecated method diff --git a/x/distribution/migrations/v4/migrate_funds_test.go b/x/distribution/migrations/v4/migrate_funds_test.go index e801040009a2..90f557e130c3 100644 --- a/x/distribution/migrations/v4/migrate_funds_test.go +++ b/x/distribution/migrations/v4/migrate_funds_test.go @@ -60,7 +60,6 @@ func TestFundsMigration(t *testing.T) { ctrl := gomock.NewController(t) acctsModKeeper := authtestutil.NewMockAccountsModKeeper(ctrl) stakingKeeper := distrtestutil.NewMockStakingKeeper(ctrl) - poolKeeper := distrtestutil.NewMockPoolKeeper(ctrl) accNum := uint64(0) acctsModKeeper.EXPECT().NextAccountNumber(gomock.Any()).AnyTimes().DoAndReturn(func(ctx context.Context) (uint64, error) { @@ -97,7 +96,6 @@ func TestFundsMigration(t *testing.T) { accountKeeper, bankKeeper, stakingKeeper, - poolKeeper, &emptyCometService{}, disttypes.ModuleName, authority, diff --git a/x/distribution/module.go b/x/distribution/module.go index bd0d3c6d3c89..82e991069335 100644 --- a/x/distribution/module.go +++ b/x/distribution/module.go @@ -48,13 +48,12 @@ type AppModule struct { accountKeeper types.AccountKeeper bankKeeper types.BankKeeper stakingKeeper types.StakingKeeper - poolKeeper types.PoolKeeper } // NewAppModule creates a new AppModule object func NewAppModule( cdc codec.Codec, keeper keeper.Keeper, accountKeeper types.AccountKeeper, - bankKeeper types.BankKeeper, stakingKeeper types.StakingKeeper, poolKeeper types.PoolKeeper, + bankKeeper types.BankKeeper, stakingKeeper types.StakingKeeper, ) AppModule { return AppModule{ cdc: cdc, @@ -62,7 +61,6 @@ func NewAppModule( accountKeeper: accountKeeper, bankKeeper: bankKeeper, stakingKeeper: stakingKeeper, - poolKeeper: poolKeeper, } } diff --git a/x/distribution/simulation/operations.go b/x/distribution/simulation/operations.go index 7b210bdf95ee..4b067cbe7174 100644 --- a/x/distribution/simulation/operations.go +++ b/x/distribution/simulation/operations.go @@ -10,7 +10,6 @@ import ( "cosmossdk.io/x/distribution/keeper" "cosmossdk.io/x/distribution/types" - "github.com/cosmos/cosmos-sdk/baseapp" "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/codec" "github.com/cosmos/cosmos-sdk/testutil" @@ -74,7 +73,7 @@ func WeightedOperations( // SimulateMsgSetWithdrawAddress generates a MsgSetWithdrawAddress with random values. func SimulateMsgSetWithdrawAddress(txConfig client.TxConfig, ak types.AccountKeeper, bk types.BankKeeper, k keeper.Keeper) simtypes.Operation { return func( - r *rand.Rand, app *baseapp.BaseApp, ctx sdk.Context, accs []simtypes.Account, chainID string, + r *rand.Rand, app simtypes.AppEntrypoint, ctx sdk.Context, accs []simtypes.Account, chainID string, ) (simtypes.OperationMsg, []simtypes.FutureOperation, error) { isWithdrawAddrEnabled, err := k.GetWithdrawAddrEnabled(ctx) if err != nil { @@ -123,7 +122,7 @@ func SimulateMsgSetWithdrawAddress(txConfig client.TxConfig, ak types.AccountKee // SimulateMsgWithdrawDelegatorReward generates a MsgWithdrawDelegatorReward with random values. func SimulateMsgWithdrawDelegatorReward(txConfig client.TxConfig, ak types.AccountKeeper, bk types.BankKeeper, k keeper.Keeper, sk types.StakingKeeper) simtypes.Operation { return func( - r *rand.Rand, app *baseapp.BaseApp, ctx sdk.Context, accs []simtypes.Account, chainID string, + r *rand.Rand, app simtypes.AppEntrypoint, ctx sdk.Context, accs []simtypes.Account, chainID string, ) (simtypes.OperationMsg, []simtypes.FutureOperation, error) { simAccount, _ := simtypes.RandomAcc(r, accs) delegations, err := sk.GetAllDelegatorDelegations(ctx, simAccount.Address) @@ -191,7 +190,7 @@ func SimulateMsgWithdrawDelegatorReward(txConfig client.TxConfig, ak types.Accou // SimulateMsgWithdrawValidatorCommission generates a MsgWithdrawValidatorCommission with random values. func SimulateMsgWithdrawValidatorCommission(txConfig client.TxConfig, ak types.AccountKeeper, bk types.BankKeeper, k keeper.Keeper, sk types.StakingKeeper) simtypes.Operation { return func( - r *rand.Rand, app *baseapp.BaseApp, ctx sdk.Context, accs []simtypes.Account, chainID string, + r *rand.Rand, app simtypes.AppEntrypoint, ctx sdk.Context, accs []simtypes.Account, chainID string, ) (simtypes.OperationMsg, []simtypes.FutureOperation, error) { msgType := sdk.MsgTypeURL(&types.MsgWithdrawValidatorCommission{}) diff --git a/x/distribution/simulation/proposals.go b/x/distribution/simulation/proposals.go index 98592d1f8e5f..3d9dfe6bd900 100644 --- a/x/distribution/simulation/proposals.go +++ b/x/distribution/simulation/proposals.go @@ -1,6 +1,7 @@ package simulation import ( + "context" "math/rand" coreaddress "cosmossdk.io/core/address" @@ -23,7 +24,7 @@ const ( // ProposalMsgs defines the module weighted proposals' contents func ProposalMsgs() []simtypes.WeightedProposalMsg { return []simtypes.WeightedProposalMsg{ - simulation.NewWeightedProposalMsg( + simulation.NewWeightedProposalMsgX( OpWeightMsgUpdateParams, DefaultWeightMsgUpdateParams, SimulateMsgUpdateParams, @@ -32,7 +33,7 @@ func ProposalMsgs() []simtypes.WeightedProposalMsg { } // SimulateMsgUpdateParams returns a random MsgUpdateParams -func SimulateMsgUpdateParams(r *rand.Rand, _ []simtypes.Account, cdc coreaddress.Codec) (sdk.Msg, error) { +func SimulateMsgUpdateParams(_ context.Context, r *rand.Rand, _ []simtypes.Account, cdc coreaddress.Codec) (sdk.Msg, error) { // use the default gov module account address as authority var authority sdk.AccAddress = address.Module("gov") diff --git a/x/distribution/simulation/proposals_test.go b/x/distribution/simulation/proposals_test.go index 7903be80eb62..ce792ea856e4 100644 --- a/x/distribution/simulation/proposals_test.go +++ b/x/distribution/simulation/proposals_test.go @@ -1,6 +1,7 @@ package simulation_test import ( + "context" "math/rand" "testing" @@ -33,7 +34,7 @@ func TestProposalMsgs(t *testing.T) { assert.Equal(t, simulation.OpWeightMsgUpdateParams, w0.AppParamsKey()) assert.Equal(t, simulation.DefaultWeightMsgUpdateParams, w0.DefaultWeight()) - msg, err := w0.MsgSimulatorFn()(r, accounts, addressCodec) + msg, err := w0.MsgSimulatorFn()(context.Background(), r, accounts, addressCodec) assert.NilError(t, err) msgUpdateParams, ok := msg.(*types.MsgUpdateParams) assert.Assert(t, ok) diff --git a/x/distribution/testutil/expected_keepers_mocks.go b/x/distribution/testutil/expected_keepers_mocks.go index a2a2d669f861..e30590d865e9 100644 --- a/x/distribution/testutil/expected_keepers_mocks.go +++ b/x/distribution/testutil/expected_keepers_mocks.go @@ -240,86 +240,6 @@ func (mr *MockBankKeeperMockRecorder) SpendableCoins(ctx, addr interface{}) *gom return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SpendableCoins", reflect.TypeOf((*MockBankKeeper)(nil).SpendableCoins), ctx, addr) } -// MockPoolKeeper is a mock of PoolKeeper interface. -type MockPoolKeeper struct { - ctrl *gomock.Controller - recorder *MockPoolKeeperMockRecorder -} - -// MockPoolKeeperMockRecorder is the mock recorder for MockPoolKeeper. -type MockPoolKeeperMockRecorder struct { - mock *MockPoolKeeper -} - -// NewMockPoolKeeper creates a new mock instance. -func NewMockPoolKeeper(ctrl *gomock.Controller) *MockPoolKeeper { - mock := &MockPoolKeeper{ctrl: ctrl} - mock.recorder = &MockPoolKeeperMockRecorder{mock} - return mock -} - -// EXPECT returns an object that allows the caller to indicate expected use. -func (m *MockPoolKeeper) EXPECT() *MockPoolKeeperMockRecorder { - return m.recorder -} - -// DistributeFromCommunityPool mocks base method. -func (m *MockPoolKeeper) DistributeFromCommunityPool(ctx context.Context, amount types0.Coins, receiveAddr types0.AccAddress) error { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "DistributeFromCommunityPool", ctx, amount, receiveAddr) - ret0, _ := ret[0].(error) - return ret0 -} - -// DistributeFromCommunityPool indicates an expected call of DistributeFromCommunityPool. -func (mr *MockPoolKeeperMockRecorder) DistributeFromCommunityPool(ctx, amount, receiveAddr interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "DistributeFromCommunityPool", reflect.TypeOf((*MockPoolKeeper)(nil).DistributeFromCommunityPool), ctx, amount, receiveAddr) -} - -// FundCommunityPool mocks base method. -func (m *MockPoolKeeper) FundCommunityPool(ctx context.Context, amount types0.Coins, sender types0.AccAddress) error { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "FundCommunityPool", ctx, amount, sender) - ret0, _ := ret[0].(error) - return ret0 -} - -// FundCommunityPool indicates an expected call of FundCommunityPool. -func (mr *MockPoolKeeperMockRecorder) FundCommunityPool(ctx, amount, sender interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "FundCommunityPool", reflect.TypeOf((*MockPoolKeeper)(nil).FundCommunityPool), ctx, amount, sender) -} - -// GetCommunityPool mocks base method. -func (m *MockPoolKeeper) GetCommunityPool(ctx context.Context) (types0.Coins, error) { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "GetCommunityPool", ctx) - ret0, _ := ret[0].(types0.Coins) - ret1, _ := ret[1].(error) - return ret0, ret1 -} - -// GetCommunityPool indicates an expected call of GetCommunityPool. -func (mr *MockPoolKeeperMockRecorder) GetCommunityPool(ctx interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetCommunityPool", reflect.TypeOf((*MockPoolKeeper)(nil).GetCommunityPool), ctx) -} - -// SetToDistribute mocks base method. -func (m *MockPoolKeeper) SetToDistribute(ctx context.Context, amount types0.Coins, addr string) error { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "SetToDistribute", ctx, amount, addr) - ret0, _ := ret[0].(error) - return ret0 -} - -// SetToDistribute indicates an expected call of SetToDistribute. -func (mr *MockPoolKeeperMockRecorder) SetToDistribute(ctx, amount, addr interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SetToDistribute", reflect.TypeOf((*MockPoolKeeper)(nil).SetToDistribute), ctx, amount, addr) -} - // MockStakingKeeper is a mock of StakingKeeper interface. type MockStakingKeeper struct { ctrl *gomock.Controller diff --git a/x/distribution/types/expected_keepers.go b/x/distribution/types/expected_keepers.go index e0fa03dbb1e5..8288f2206280 100644 --- a/x/distribution/types/expected_keepers.go +++ b/x/distribution/types/expected_keepers.go @@ -34,14 +34,6 @@ type BankKeeper interface { IsSendEnabledDenom(ctx context.Context, denom string) bool } -// PoolKeeper defines the expected interface needed to fund & distribute pool balances. -type PoolKeeper interface { - FundCommunityPool(ctx context.Context, amount sdk.Coins, sender sdk.AccAddress) error - DistributeFromCommunityPool(ctx context.Context, amount sdk.Coins, receiveAddr sdk.AccAddress) error - GetCommunityPool(ctx context.Context) (sdk.Coins, error) - SetToDistribute(ctx context.Context, amount sdk.Coins, addr string) error -} - // StakingKeeper expected staking keeper (noalias) type StakingKeeper interface { ValidatorAddressCodec() address.Codec diff --git a/x/distribution/types/keys.go b/x/distribution/types/keys.go index e4409d9d5959..cee527708b85 100644 --- a/x/distribution/types/keys.go +++ b/x/distribution/types/keys.go @@ -24,7 +24,12 @@ const ( // It should be synced with the gov module's name if it is ever changed. // See: https://github.com/cosmos/cosmos-sdk/blob/b62a28aac041829da5ded4aeacfcd7a42873d1c8/x/gov/types/keys.go#L9 GovModuleName = "gov" - // ProtocolPoolModuleName duplicates the protocolpool module's name to avoid a cyclic dependency with x/protocolpool. + // ProtocolPoolDistrAccount duplicates the protocolpool_distr accounts's name to avoid a cyclic dependency with x/protocolpool. + // This account is an intermediary account that holds the funds to be distributed to the protocolpool accounts. + ProtocolPoolDistrAccount = "protocolpool_distr" + + // ProtocolPoolModuleName duplicates the protocolpool accounts's name to avoid a cyclic dependency with x/protocolpool. + // DO NOT USE: This is only used in deprecated methods CommunityPoolSpend, FundCommunityPool and query CommunityPool. ProtocolPoolModuleName = "protocolpool" ) diff --git a/x/distribution/types/params.go b/x/distribution/types/params.go index b8438ca73812..b37cd8844fe1 100644 --- a/x/distribution/types/params.go +++ b/x/distribution/types/params.go @@ -1,6 +1,7 @@ package types import ( + "errors" "fmt" "cosmossdk.io/math" @@ -28,7 +29,7 @@ func validateCommunityTax(i interface{}) error { } if v.IsNil() { - return fmt.Errorf("community tax must be not nil") + return errors.New("community tax must be not nil") } if v.IsNegative() { return fmt.Errorf("community tax must be positive: %s", v) diff --git a/x/epochs/go.mod b/x/epochs/go.mod index 6842a566fd9a..9ff57f6eff80 100644 --- a/x/epochs/go.mod +++ b/x/epochs/go.mod @@ -7,11 +7,11 @@ require ( cosmossdk.io/collections v0.4.0 cosmossdk.io/core v0.12.1-0.20231114100755-569e3ff6a0d7 cosmossdk.io/core/testing v0.0.0-00010101000000-000000000000 - cosmossdk.io/depinject v1.0.0-alpha.4 + cosmossdk.io/depinject v1.0.0 cosmossdk.io/errors v1.0.1 cosmossdk.io/store v1.1.1-0.20240418092142-896cdf1971bc github.com/cosmos/cosmos-proto v1.0.0-beta.5 - github.com/cosmos/cosmos-sdk v0.51.0 + github.com/cosmos/cosmos-sdk v0.53.0 github.com/cosmos/gogoproto v1.5.0 github.com/golang/protobuf v1.5.4 github.com/grpc-ecosystem/grpc-gateway v1.16.0 @@ -51,7 +51,7 @@ require ( github.com/cosmos/crypto v0.1.2 // indirect github.com/cosmos/go-bip39 v1.0.0 // indirect github.com/cosmos/gogogateway v1.2.0 // indirect - github.com/cosmos/iavl v1.2.0 // indirect + github.com/cosmos/iavl v1.2.1-0.20240725141113-7adc688cf179 // indirect github.com/cosmos/ics23/go v0.10.0 // indirect github.com/cosmos/ledger-cosmos-go v0.13.3 // indirect github.com/danieljoos/wincred v1.2.1 // indirect @@ -179,8 +179,6 @@ replace ( cosmossdk.io/api => ../../api cosmossdk.io/core => ../../core cosmossdk.io/core/testing => ../../core/testing - cosmossdk.io/depinject => ../../depinject - cosmossdk.io/log => ../../log cosmossdk.io/x/accounts => ../accounts cosmossdk.io/x/auth => ../auth cosmossdk.io/x/bank => ../bank diff --git a/x/epochs/go.sum b/x/epochs/go.sum index 2aa9efc32a9b..d2a9b023b854 100644 --- a/x/epochs/go.sum +++ b/x/epochs/go.sum @@ -6,8 +6,12 @@ cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMT cloud.google.com/go v0.34.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= cosmossdk.io/collections v0.4.0 h1:PFmwj2W8szgpD5nOd8GWH6AbYNi1f2J6akWXJ7P5t9s= cosmossdk.io/collections v0.4.0/go.mod h1:oa5lUING2dP+gdDquow+QjlF45eL1t4TJDypgGd+tv0= +cosmossdk.io/depinject v1.0.0 h1:dQaTu6+O6askNXO06+jyeUAnF2/ssKwrrszP9t5q050= +cosmossdk.io/depinject v1.0.0/go.mod h1:zxK/h3HgHoA/eJVtiSsoaRaRA2D5U4cJ5thIG4ssbB8= cosmossdk.io/errors v1.0.1 h1:bzu+Kcr0kS/1DuPBtUFdWjzLqyUuCiyHjyJB6srBV/0= cosmossdk.io/errors v1.0.1/go.mod h1:MeelVSZThMi4bEakzhhhE/CKqVv3nOJDA25bIqRDu/U= +cosmossdk.io/log v1.3.1 h1:UZx8nWIkfbbNEWusZqzAx3ZGvu54TZacWib3EzUYmGI= +cosmossdk.io/log v1.3.1/go.mod h1:2/dIomt8mKdk6vl3OWJcPk2be3pGOS8OQaLUM/3/tCM= cosmossdk.io/math v1.3.0 h1:RC+jryuKeytIiictDslBP9i1fhkVm6ZDmZEoNP316zE= cosmossdk.io/math v1.3.0/go.mod h1:vnRTxewy+M7BtXBNFybkuhSH4WfedVAAnERHgVFhp3k= cosmossdk.io/schema v0.1.1 h1:I0M6pgI7R10nq+/HCQfbO6BsGBZA8sQy+duR1Y3aKcA= @@ -111,8 +115,8 @@ github.com/cosmos/gogogateway v1.2.0/go.mod h1:iQpLkGWxYcnCdz5iAdLcRBSw3h7NXeOkZ github.com/cosmos/gogoproto v1.4.2/go.mod h1:cLxOsn1ljAHSV527CHOtaIP91kK6cCrZETRBrkzItWU= github.com/cosmos/gogoproto v1.5.0 h1:SDVwzEqZDDBoslaeZg+dGE55hdzHfgUA40pEanMh52o= github.com/cosmos/gogoproto v1.5.0/go.mod h1:iUM31aofn3ymidYG6bUR5ZFrk+Om8p5s754eMUcyp8I= -github.com/cosmos/iavl v1.2.0 h1:kVxTmjTh4k0Dh1VNL046v6BXqKziqMDzxo93oh3kOfM= -github.com/cosmos/iavl v1.2.0/go.mod h1:HidWWLVAtODJqFD6Hbne2Y0q3SdxByJepHUOeoH4LiI= +github.com/cosmos/iavl v1.2.1-0.20240725141113-7adc688cf179 h1:wmwDn7V3RodN9auB3FooSQxs46nHVE3u0mb87TJkZFE= +github.com/cosmos/iavl v1.2.1-0.20240725141113-7adc688cf179/go.mod h1:GiM43q0pB+uG53mLxLDzimxM9l/5N9UuSY3/D0huuVw= github.com/cosmos/ics23/go v0.10.0 h1:iXqLLgp2Lp+EdpIuwXTYIQU+AiHj9mOC2X9ab++bZDM= github.com/cosmos/ics23/go v0.10.0/go.mod h1:ZfJSmng/TBNTBkFemHHHj5YY7VAU/MBU980F4VU1NG0= github.com/cosmos/ledger-cosmos-go v0.13.3 h1:7ehuBGuyIytsXbd4MP43mLeoN2LTOEnk5nvue4rK+yM= diff --git a/x/epochs/proto/cosmos/epochs/module/v1/module.proto b/x/epochs/proto/cosmos/epochs/module/v1/module.proto index 1b860b3e504b..786f99100c32 100644 --- a/x/epochs/proto/cosmos/epochs/module/v1/module.proto +++ b/x/epochs/proto/cosmos/epochs/module/v1/module.proto @@ -4,7 +4,7 @@ package cosmos.epochs.module.v1; import "cosmos/app/v1alpha1/module.proto"; -// Module is the config object of the authz module. +// Module is the config object of the epochs module. message Module { option (cosmos.app.v1alpha1.module) = { go_import: "cosmossdk.io/x/epochs" diff --git a/x/evidence/go.mod b/x/evidence/go.mod index 4c20a6686878..6e69b3e184cb 100644 --- a/x/evidence/go.mod +++ b/x/evidence/go.mod @@ -7,13 +7,13 @@ require ( cosmossdk.io/collections v0.4.0 cosmossdk.io/core v0.12.1-0.20231114100755-569e3ff6a0d7 cosmossdk.io/core/testing v0.0.0-00010101000000-000000000000 - cosmossdk.io/depinject v1.0.0-alpha.4 + cosmossdk.io/depinject v1.0.0 cosmossdk.io/errors v1.0.1 cosmossdk.io/math v1.3.0 cosmossdk.io/store v1.1.1-0.20240418092142-896cdf1971bc cosmossdk.io/x/consensus v0.0.0-00010101000000-000000000000 github.com/cosmos/cosmos-proto v1.0.0-beta.5 - github.com/cosmos/cosmos-sdk v0.51.0 + github.com/cosmos/cosmos-sdk v0.53.0 github.com/cosmos/gogoproto v1.5.0 github.com/golang/mock v1.6.0 github.com/golang/protobuf v1.5.4 @@ -57,7 +57,7 @@ require ( github.com/cosmos/crypto v0.1.2 // indirect github.com/cosmos/go-bip39 v1.0.0 // indirect github.com/cosmos/gogogateway v1.2.0 // indirect - github.com/cosmos/iavl v1.2.0 // indirect + github.com/cosmos/iavl v1.2.1-0.20240725141113-7adc688cf179 // indirect github.com/cosmos/ics23/go v0.10.0 // indirect github.com/cosmos/ledger-cosmos-go v0.13.3 // indirect github.com/danieljoos/wincred v1.2.1 // indirect @@ -177,8 +177,6 @@ replace ( cosmossdk.io/api => ../../api cosmossdk.io/core => ../../core cosmossdk.io/core/testing => ../../core/testing - cosmossdk.io/depinject => ../../depinject - cosmossdk.io/log => ../../log cosmossdk.io/x/accounts => ../accounts cosmossdk.io/x/auth => ../auth cosmossdk.io/x/bank => ../bank diff --git a/x/evidence/go.sum b/x/evidence/go.sum index c2479081cac7..81d16c68890c 100644 --- a/x/evidence/go.sum +++ b/x/evidence/go.sum @@ -6,8 +6,12 @@ cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMT cloud.google.com/go v0.34.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= cosmossdk.io/collections v0.4.0 h1:PFmwj2W8szgpD5nOd8GWH6AbYNi1f2J6akWXJ7P5t9s= cosmossdk.io/collections v0.4.0/go.mod h1:oa5lUING2dP+gdDquow+QjlF45eL1t4TJDypgGd+tv0= +cosmossdk.io/depinject v1.0.0 h1:dQaTu6+O6askNXO06+jyeUAnF2/ssKwrrszP9t5q050= +cosmossdk.io/depinject v1.0.0/go.mod h1:zxK/h3HgHoA/eJVtiSsoaRaRA2D5U4cJ5thIG4ssbB8= cosmossdk.io/errors v1.0.1 h1:bzu+Kcr0kS/1DuPBtUFdWjzLqyUuCiyHjyJB6srBV/0= cosmossdk.io/errors v1.0.1/go.mod h1:MeelVSZThMi4bEakzhhhE/CKqVv3nOJDA25bIqRDu/U= +cosmossdk.io/log v1.3.1 h1:UZx8nWIkfbbNEWusZqzAx3ZGvu54TZacWib3EzUYmGI= +cosmossdk.io/log v1.3.1/go.mod h1:2/dIomt8mKdk6vl3OWJcPk2be3pGOS8OQaLUM/3/tCM= cosmossdk.io/math v1.3.0 h1:RC+jryuKeytIiictDslBP9i1fhkVm6ZDmZEoNP316zE= cosmossdk.io/math v1.3.0/go.mod h1:vnRTxewy+M7BtXBNFybkuhSH4WfedVAAnERHgVFhp3k= cosmossdk.io/schema v0.1.1 h1:I0M6pgI7R10nq+/HCQfbO6BsGBZA8sQy+duR1Y3aKcA= @@ -111,8 +115,8 @@ github.com/cosmos/gogogateway v1.2.0/go.mod h1:iQpLkGWxYcnCdz5iAdLcRBSw3h7NXeOkZ github.com/cosmos/gogoproto v1.4.2/go.mod h1:cLxOsn1ljAHSV527CHOtaIP91kK6cCrZETRBrkzItWU= github.com/cosmos/gogoproto v1.5.0 h1:SDVwzEqZDDBoslaeZg+dGE55hdzHfgUA40pEanMh52o= github.com/cosmos/gogoproto v1.5.0/go.mod h1:iUM31aofn3ymidYG6bUR5ZFrk+Om8p5s754eMUcyp8I= -github.com/cosmos/iavl v1.2.0 h1:kVxTmjTh4k0Dh1VNL046v6BXqKziqMDzxo93oh3kOfM= -github.com/cosmos/iavl v1.2.0/go.mod h1:HidWWLVAtODJqFD6Hbne2Y0q3SdxByJepHUOeoH4LiI= +github.com/cosmos/iavl v1.2.1-0.20240725141113-7adc688cf179 h1:wmwDn7V3RodN9auB3FooSQxs46nHVE3u0mb87TJkZFE= +github.com/cosmos/iavl v1.2.1-0.20240725141113-7adc688cf179/go.mod h1:GiM43q0pB+uG53mLxLDzimxM9l/5N9UuSY3/D0huuVw= github.com/cosmos/ics23/go v0.10.0 h1:iXqLLgp2Lp+EdpIuwXTYIQU+AiHj9mOC2X9ab++bZDM= github.com/cosmos/ics23/go v0.10.0/go.mod h1:ZfJSmng/TBNTBkFemHHHj5YY7VAU/MBU980F4VU1NG0= github.com/cosmos/ledger-cosmos-go v0.13.3 h1:7ehuBGuyIytsXbd4MP43mLeoN2LTOEnk5nvue4rK+yM= diff --git a/x/evidence/keeper/keeper_test.go b/x/evidence/keeper/keeper_test.go index cb5b54bc9b4b..3ec2a425e607 100644 --- a/x/evidence/keeper/keeper_test.go +++ b/x/evidence/keeper/keeper_test.go @@ -127,10 +127,6 @@ func (suite *KeeperTestSuite) SetupTest() { types.RegisterQueryServer(queryHelper, keeper.NewQuerier(evidenceKeeper)) suite.queryClient = types.NewQueryClient(queryHelper) suite.evidenceKeeper = *evidenceKeeper - - suite.Require().Equal(testCtx.Ctx.Logger().With("module", "x/"+types.ModuleName), - suite.evidenceKeeper.Logger) - suite.msgServer = keeper.NewMsgServerImpl(suite.evidenceKeeper) } diff --git a/x/evidence/types/genesis.go b/x/evidence/types/genesis.go index d9ccaefbe729..ce9363f58025 100644 --- a/x/evidence/types/genesis.go +++ b/x/evidence/types/genesis.go @@ -1,16 +1,18 @@ package types import ( + "errors" "fmt" "github.com/cosmos/gogoproto/proto" + gogoprotoany "github.com/cosmos/gogoproto/types/any" "cosmossdk.io/x/evidence/exported" "github.com/cosmos/cosmos-sdk/codec/types" ) -var _ types.UnpackInterfacesMessage = GenesisState{} +var _ gogoprotoany.UnpackInterfacesMessage = GenesisState{} // NewGenesisState creates a new genesis state for the evidence module. func NewGenesisState(e []exported.Evidence) *GenesisState { @@ -44,7 +46,7 @@ func (gs GenesisState) Validate() error { for _, e := range gs.Evidence { evi, ok := e.GetCachedValue().(exported.Evidence) if !ok { - return fmt.Errorf("expected evidence") + return errors.New("expected evidence") } if err := evi.ValidateBasic(); err != nil { return err @@ -55,7 +57,7 @@ func (gs GenesisState) Validate() error { } // UnpackInterfaces implements UnpackInterfacesMessage.UnpackInterfaces -func (gs GenesisState) UnpackInterfaces(unpacker types.AnyUnpacker) error { +func (gs GenesisState) UnpackInterfaces(unpacker gogoprotoany.AnyUnpacker) error { for _, any := range gs.Evidence { var evi exported.Evidence err := unpacker.UnpackAny(any, &evi) diff --git a/x/evidence/types/genesis_test.go b/x/evidence/types/genesis_test.go index 20b5967ac2eb..786b2103f762 100644 --- a/x/evidence/types/genesis_test.go +++ b/x/evidence/types/genesis_test.go @@ -5,6 +5,7 @@ import ( "testing" "time" + gogoprotoany "github.com/cosmos/gogoproto/types/any" "github.com/stretchr/testify/require" "cosmossdk.io/x/evidence/exported" @@ -130,7 +131,7 @@ func TestUnpackInterfaces(t *testing.T) { testCases := []struct { msg string - unpacker codectypes.AnyUnpacker + unpacker gogoprotoany.AnyUnpacker expPass bool }{ { diff --git a/x/evidence/types/msgs.go b/x/evidence/types/msgs.go index 92df414692a5..03e70b5ab7df 100644 --- a/x/evidence/types/msgs.go +++ b/x/evidence/types/msgs.go @@ -4,6 +4,7 @@ import ( "fmt" "github.com/cosmos/gogoproto/proto" + gogoprotoany "github.com/cosmos/gogoproto/types/any" "cosmossdk.io/x/evidence/exported" @@ -12,9 +13,9 @@ import ( ) var ( - _ sdk.Msg = &MsgSubmitEvidence{} - _ types.UnpackInterfacesMessage = MsgSubmitEvidence{} - _ exported.MsgSubmitEvidenceI = &MsgSubmitEvidence{} + _ sdk.Msg = &MsgSubmitEvidence{} + _ gogoprotoany.UnpackInterfacesMessage = MsgSubmitEvidence{} + _ exported.MsgSubmitEvidenceI = &MsgSubmitEvidence{} ) // NewMsgSubmitEvidence returns a new MsgSubmitEvidence with a signer/submitter. @@ -51,7 +52,7 @@ func (m MsgSubmitEvidence) GetSubmitter() sdk.AccAddress { return accAddr } -func (m MsgSubmitEvidence) UnpackInterfaces(ctx types.AnyUnpacker) error { +func (m MsgSubmitEvidence) UnpackInterfaces(ctx gogoprotoany.AnyUnpacker) error { var evi exported.Evidence return ctx.UnpackAny(m.Evidence, &evi) } diff --git a/x/feegrant/basic_fee.go b/x/feegrant/basic_fee.go index 1bace70b02ed..2100cd5be3b1 100644 --- a/x/feegrant/basic_fee.go +++ b/x/feegrant/basic_fee.go @@ -2,7 +2,7 @@ package feegrant import ( "context" - "fmt" + "errors" "time" "cosmossdk.io/core/appmodule" @@ -28,7 +28,7 @@ var _ FeeAllowanceI = (*BasicAllowance)(nil) func (a *BasicAllowance) Accept(ctx context.Context, fee sdk.Coins, _ []sdk.Msg) (bool, error) { environment, ok := ctx.Value(corecontext.EnvironmentContextKey).(appmodule.Environment) if !ok { - return false, fmt.Errorf("environment not set") + return false, errors.New("environment not set") } headerInfo := environment.HeaderService.HeaderInfo(ctx) if a.Expiration != nil && a.Expiration.Before(headerInfo.Time) { diff --git a/x/feegrant/filtered_fee.go b/x/feegrant/filtered_fee.go index 6e001ef947e9..68e2fa681cfd 100644 --- a/x/feegrant/filtered_fee.go +++ b/x/feegrant/filtered_fee.go @@ -2,10 +2,11 @@ package feegrant import ( "context" - "fmt" + "errors" "time" "github.com/cosmos/gogoproto/proto" + gogoprotoany "github.com/cosmos/gogoproto/types/any" "cosmossdk.io/core/appmodule" corecontext "cosmossdk.io/core/context" @@ -23,12 +24,12 @@ const ( ) var ( - _ FeeAllowanceI = (*AllowedMsgAllowance)(nil) - _ types.UnpackInterfacesMessage = (*AllowedMsgAllowance)(nil) + _ FeeAllowanceI = (*AllowedMsgAllowance)(nil) + _ gogoprotoany.UnpackInterfacesMessage = (*AllowedMsgAllowance)(nil) ) // UnpackInterfaces implements UnpackInterfacesMessage.UnpackInterfaces -func (a *AllowedMsgAllowance) UnpackInterfaces(unpacker types.AnyUnpacker) error { +func (a *AllowedMsgAllowance) UnpackInterfaces(unpacker gogoprotoany.AnyUnpacker) error { var allowance FeeAllowanceI return unpacker.UnpackAny(a.Allowance, &allowance) } @@ -99,7 +100,7 @@ func (a *AllowedMsgAllowance) allowedMsgsToMap(ctx context.Context) (map[string] msgsMap := make(map[string]bool, len(a.AllowedMessages)) environment, ok := ctx.Value(corecontext.EnvironmentContextKey).(appmodule.Environment) if !ok { - return nil, fmt.Errorf("environment not set") + return nil, errors.New("environment not set") } gasMeter := environment.GasService.GasMeter(ctx) for _, msg := range a.AllowedMessages { @@ -119,7 +120,7 @@ func (a *AllowedMsgAllowance) allMsgTypesAllowed(ctx context.Context, msgs []sdk } environment, ok := ctx.Value(corecontext.EnvironmentContextKey).(appmodule.Environment) if !ok { - return false, fmt.Errorf("environment not set") + return false, errors.New("environment not set") } gasMeter := environment.GasService.GasMeter(ctx) for _, msg := range msgs { diff --git a/x/feegrant/genesis.go b/x/feegrant/genesis.go index 83b29baeb85d..71ddf943a3e3 100644 --- a/x/feegrant/genesis.go +++ b/x/feegrant/genesis.go @@ -1,10 +1,10 @@ package feegrant import ( - "github.com/cosmos/cosmos-sdk/codec/types" + gogoprotoany "github.com/cosmos/gogoproto/types/any" ) -var _ types.UnpackInterfacesMessage = GenesisState{} +var _ gogoprotoany.UnpackInterfacesMessage = GenesisState{} // NewGenesisState creates new GenesisState object func NewGenesisState(entries []Grant) *GenesisState { @@ -34,7 +34,7 @@ func DefaultGenesisState() *GenesisState { } // UnpackInterfaces implements UnpackInterfacesMessage.UnpackInterfaces -func (data GenesisState) UnpackInterfaces(unpacker types.AnyUnpacker) error { +func (data GenesisState) UnpackInterfaces(unpacker gogoprotoany.AnyUnpacker) error { for _, f := range data.Allowances { err := f.UnpackInterfaces(unpacker) if err != nil { diff --git a/x/feegrant/go.mod b/x/feegrant/go.mod index a1ab606ae9f1..48f76e69f4b3 100644 --- a/x/feegrant/go.mod +++ b/x/feegrant/go.mod @@ -7,7 +7,7 @@ require ( cosmossdk.io/collections v0.4.0 cosmossdk.io/core v0.12.1-0.20231114100755-569e3ff6a0d7 cosmossdk.io/core/testing v0.0.0-00010101000000-000000000000 - cosmossdk.io/depinject v1.0.0-alpha.4 + cosmossdk.io/depinject v1.0.0 cosmossdk.io/errors v1.0.1 cosmossdk.io/math v1.3.0 cosmossdk.io/store v1.1.1-0.20240418092142-896cdf1971bc @@ -15,7 +15,7 @@ require ( cosmossdk.io/x/gov v0.0.0-20230925135524-a1bc045b3190 github.com/cometbft/cometbft v1.0.0-rc1 github.com/cosmos/cosmos-proto v1.0.0-beta.5 - github.com/cosmos/cosmos-sdk v0.51.0 + github.com/cosmos/cosmos-sdk v0.53.0 github.com/cosmos/gogoproto v1.5.0 github.com/golang/mock v1.6.0 github.com/golang/protobuf v1.5.4 @@ -32,6 +32,7 @@ require ( buf.build/gen/go/cometbft/cometbft/protocolbuffers/go v1.34.2-20240701160653-fedbb9acfd2f.2 // indirect buf.build/gen/go/cosmos/gogo-proto/protocolbuffers/go v1.34.2-20240130113600-88ef6483f90f.2 // indirect cosmossdk.io/log v1.3.1 // indirect + cosmossdk.io/schema v0.1.1 // indirect cosmossdk.io/x/auth v0.0.0-00010101000000-000000000000 cosmossdk.io/x/consensus v0.0.0-00010101000000-000000000000 // indirect cosmossdk.io/x/protocolpool v0.0.0-20230925135524-a1bc045b3190 // indirect @@ -60,7 +61,7 @@ require ( github.com/cosmos/crypto v0.1.2 // indirect github.com/cosmos/go-bip39 v1.0.0 // indirect github.com/cosmos/gogogateway v1.2.0 // indirect - github.com/cosmos/iavl v1.2.0 // indirect + github.com/cosmos/iavl v1.2.1-0.20240725141113-7adc688cf179 // indirect github.com/cosmos/ics23/go v0.10.0 // indirect github.com/cosmos/ledger-cosmos-go v0.13.3 // indirect github.com/danieljoos/wincred v1.2.1 // indirect @@ -121,6 +122,7 @@ require ( github.com/mitchellh/go-testing-interface v1.14.1 // indirect github.com/mitchellh/mapstructure v1.5.0 // indirect github.com/mtibben/percent v0.2.1 // indirect + github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect github.com/oasisprotocol/curve25519-voi v0.0.0-20230904125328-1f23a7beb09a // indirect github.com/oklog/run v1.1.0 // indirect github.com/pelletier/go-toml/v2 v2.2.2 // indirect @@ -172,11 +174,6 @@ require ( sigs.k8s.io/yaml v1.4.0 // indirect ) -require ( - cosmossdk.io/schema v0.1.1 // indirect - github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect -) - replace github.com/cosmos/cosmos-sdk => ../../. // TODO remove post spinning out all modules @@ -185,8 +182,6 @@ replace ( cosmossdk.io/collections => ../../collections cosmossdk.io/core => ../../core cosmossdk.io/core/testing => ../../core/testing - cosmossdk.io/depinject => ../../depinject - cosmossdk.io/log => ../../log cosmossdk.io/x/accounts => ../accounts cosmossdk.io/x/auth => ../auth cosmossdk.io/x/bank => ../bank diff --git a/x/feegrant/go.sum b/x/feegrant/go.sum index c0d696396264..8413c200c45e 100644 --- a/x/feegrant/go.sum +++ b/x/feegrant/go.sum @@ -4,8 +4,12 @@ buf.build/gen/go/cosmos/gogo-proto/protocolbuffers/go v1.34.2-20240130113600-88e buf.build/gen/go/cosmos/gogo-proto/protocolbuffers/go v1.34.2-20240130113600-88ef6483f90f.2/go.mod h1:HqcXMSa5qnNuakaMUo+hWhF51mKbcrZxGl9Vp5EeJXc= cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= cloud.google.com/go v0.34.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= +cosmossdk.io/depinject v1.0.0 h1:dQaTu6+O6askNXO06+jyeUAnF2/ssKwrrszP9t5q050= +cosmossdk.io/depinject v1.0.0/go.mod h1:zxK/h3HgHoA/eJVtiSsoaRaRA2D5U4cJ5thIG4ssbB8= cosmossdk.io/errors v1.0.1 h1:bzu+Kcr0kS/1DuPBtUFdWjzLqyUuCiyHjyJB6srBV/0= cosmossdk.io/errors v1.0.1/go.mod h1:MeelVSZThMi4bEakzhhhE/CKqVv3nOJDA25bIqRDu/U= +cosmossdk.io/log v1.3.1 h1:UZx8nWIkfbbNEWusZqzAx3ZGvu54TZacWib3EzUYmGI= +cosmossdk.io/log v1.3.1/go.mod h1:2/dIomt8mKdk6vl3OWJcPk2be3pGOS8OQaLUM/3/tCM= cosmossdk.io/math v1.3.0 h1:RC+jryuKeytIiictDslBP9i1fhkVm6ZDmZEoNP316zE= cosmossdk.io/math v1.3.0/go.mod h1:vnRTxewy+M7BtXBNFybkuhSH4WfedVAAnERHgVFhp3k= cosmossdk.io/schema v0.1.1 h1:I0M6pgI7R10nq+/HCQfbO6BsGBZA8sQy+duR1Y3aKcA= @@ -117,8 +121,8 @@ github.com/cosmos/gogogateway v1.2.0/go.mod h1:iQpLkGWxYcnCdz5iAdLcRBSw3h7NXeOkZ github.com/cosmos/gogoproto v1.4.2/go.mod h1:cLxOsn1ljAHSV527CHOtaIP91kK6cCrZETRBrkzItWU= github.com/cosmos/gogoproto v1.5.0 h1:SDVwzEqZDDBoslaeZg+dGE55hdzHfgUA40pEanMh52o= github.com/cosmos/gogoproto v1.5.0/go.mod h1:iUM31aofn3ymidYG6bUR5ZFrk+Om8p5s754eMUcyp8I= -github.com/cosmos/iavl v1.2.0 h1:kVxTmjTh4k0Dh1VNL046v6BXqKziqMDzxo93oh3kOfM= -github.com/cosmos/iavl v1.2.0/go.mod h1:HidWWLVAtODJqFD6Hbne2Y0q3SdxByJepHUOeoH4LiI= +github.com/cosmos/iavl v1.2.1-0.20240725141113-7adc688cf179 h1:wmwDn7V3RodN9auB3FooSQxs46nHVE3u0mb87TJkZFE= +github.com/cosmos/iavl v1.2.1-0.20240725141113-7adc688cf179/go.mod h1:GiM43q0pB+uG53mLxLDzimxM9l/5N9UuSY3/D0huuVw= github.com/cosmos/ics23/go v0.10.0 h1:iXqLLgp2Lp+EdpIuwXTYIQU+AiHj9mOC2X9ab++bZDM= github.com/cosmos/ics23/go v0.10.0/go.mod h1:ZfJSmng/TBNTBkFemHHHj5YY7VAU/MBU980F4VU1NG0= github.com/cosmos/ledger-cosmos-go v0.13.3 h1:7ehuBGuyIytsXbd4MP43mLeoN2LTOEnk5nvue4rK+yM= diff --git a/x/feegrant/grant.go b/x/feegrant/grant.go index 0fb85dd5a226..a483475c6b41 100644 --- a/x/feegrant/grant.go +++ b/x/feegrant/grant.go @@ -2,6 +2,7 @@ package feegrant import ( "github.com/cosmos/gogoproto/proto" + gogoprotoany "github.com/cosmos/gogoproto/types/any" errorsmod "cosmossdk.io/errors" @@ -9,7 +10,7 @@ import ( sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" ) -var _ types.UnpackInterfacesMessage = &Grant{} +var _ gogoprotoany.UnpackInterfacesMessage = &Grant{} // NewGrant creates a new FeeAllowanceGrant. func NewGrant(granter, grantee string, feeAllowance FeeAllowanceI) (Grant, error) { @@ -62,7 +63,7 @@ func (a Grant) GetGrant() (FeeAllowanceI, error) { } // UnpackInterfaces implements UnpackInterfacesMessage.UnpackInterfaces -func (a Grant) UnpackInterfaces(unpacker types.AnyUnpacker) error { +func (a Grant) UnpackInterfaces(unpacker gogoprotoany.AnyUnpacker) error { var allowance FeeAllowanceI return unpacker.UnpackAny(a.Allowance, &allowance) } diff --git a/x/feegrant/keeper/keeper.go b/x/feegrant/keeper/keeper.go index c68f992878b3..ad3f5d59c656 100644 --- a/x/feegrant/keeper/keeper.go +++ b/x/feegrant/keeper/keeper.go @@ -2,14 +2,12 @@ package keeper import ( "context" - "fmt" "time" "cosmossdk.io/collections" "cosmossdk.io/core/appmodule" corecontext "cosmossdk.io/core/context" "cosmossdk.io/core/event" - "cosmossdk.io/core/log" errorsmod "cosmossdk.io/errors" "cosmossdk.io/x/auth/ante" "cosmossdk.io/x/feegrant" @@ -60,11 +58,6 @@ func NewKeeper(env appmodule.Environment, cdc codec.BinaryCodec, ak feegrant.Acc } } -// Logger returns a module-specific logger. -func (k Keeper) Logger(ctx sdk.Context) log.Logger { - return ctx.Logger().With("module", fmt.Sprintf("x/%s", feegrant.ModuleName)) -} - // GrantAllowance creates a new grant func (k Keeper) GrantAllowance(ctx context.Context, granter, grantee sdk.AccAddress, feeAllowance feegrant.FeeAllowanceI) error { // Checking for duplicate entry diff --git a/x/feegrant/msgs.go b/x/feegrant/msgs.go index c049c73d4f3f..e79c5ce39ab9 100644 --- a/x/feegrant/msgs.go +++ b/x/feegrant/msgs.go @@ -2,6 +2,7 @@ package feegrant import ( "github.com/cosmos/gogoproto/proto" + gogoprotoany "github.com/cosmos/gogoproto/types/any" errorsmod "cosmossdk.io/errors" @@ -11,8 +12,8 @@ import ( ) var ( - _, _ sdk.Msg = &MsgGrantAllowance{}, &MsgRevokeAllowance{} - _ types.UnpackInterfacesMessage = &MsgGrantAllowance{} + _, _ sdk.Msg = &MsgGrantAllowance{}, &MsgRevokeAllowance{} + _ gogoprotoany.UnpackInterfacesMessage = &MsgGrantAllowance{} ) // NewMsgGrantAllowance creates a new MsgGrantAllowance. @@ -44,7 +45,7 @@ func (msg MsgGrantAllowance) GetFeeAllowanceI() (FeeAllowanceI, error) { } // UnpackInterfaces implements UnpackInterfacesMessage.UnpackInterfaces -func (msg MsgGrantAllowance) UnpackInterfaces(unpacker types.AnyUnpacker) error { +func (msg MsgGrantAllowance) UnpackInterfaces(unpacker gogoprotoany.AnyUnpacker) error { var allowance FeeAllowanceI return unpacker.UnpackAny(msg.Allowance, &allowance) } diff --git a/x/feegrant/simulation/operations.go b/x/feegrant/simulation/operations.go index c82677d4fa09..59c3d0d7df69 100644 --- a/x/feegrant/simulation/operations.go +++ b/x/feegrant/simulation/operations.go @@ -7,7 +7,6 @@ import ( "cosmossdk.io/x/feegrant" "cosmossdk.io/x/feegrant/keeper" - "github.com/cosmos/cosmos-sdk/baseapp" "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/codec" codectypes "github.com/cosmos/cosmos-sdk/codec/types" @@ -79,7 +78,7 @@ func SimulateMsgGrantAllowance( k keeper.Keeper, ) simtypes.Operation { return func( - r *rand.Rand, app *baseapp.BaseApp, ctx sdk.Context, accs []simtypes.Account, chainID string, + r *rand.Rand, app simtypes.AppEntrypoint, ctx sdk.Context, accs []simtypes.Account, chainID string, ) (simtypes.OperationMsg, []simtypes.FutureOperation, error) { granter, _ := simtypes.RandomAcc(r, accs) grantee, _ := simtypes.RandomAcc(r, accs) @@ -143,7 +142,7 @@ func SimulateMsgRevokeAllowance( k keeper.Keeper, ) simtypes.Operation { return func( - r *rand.Rand, app *baseapp.BaseApp, ctx sdk.Context, accs []simtypes.Account, chainID string, + r *rand.Rand, app simtypes.AppEntrypoint, ctx sdk.Context, accs []simtypes.Account, chainID string, ) (simtypes.OperationMsg, []simtypes.FutureOperation, error) { hasGrant := false diff --git a/x/genutil/client/cli/export_test.go b/x/genutil/client/cli/export_test.go index e492e100b11f..f5f8c570d334 100644 --- a/x/genutil/client/cli/export_test.go +++ b/x/genutil/client/cli/export_test.go @@ -3,7 +3,7 @@ package cli_test import ( "context" "encoding/json" - "fmt" + "errors" "io" "os" "path/filepath" @@ -164,7 +164,7 @@ func (e *mockExporter) Export( modulesToExport []string, ) (types.ExportedApp, error) { if e.Err == nil && isZeroExportedApp(e.ExportApp) { - panic(fmt.Errorf("(*mockExporter).Export called without setting e.ExportApp or e.Err")) + panic(errors.New("(*mockExporter).Export called without setting e.ExportApp or e.Err")) } e.WasCalled = true @@ -311,7 +311,7 @@ func TestExportCLI(t *testing.T) { t.Parallel() e := new(mockExporter) - e.Err = fmt.Errorf("whoopsie") + e.Err = errors.New("whoopsie") sys := NewExportSystem(t, e.Export) _ = sys.MustRun(t, "init", "some_moniker") diff --git a/x/genutil/utils.go b/x/genutil/utils.go index e06e440d9a20..b20b7bfa6ec8 100644 --- a/x/genutil/utils.go +++ b/x/genutil/utils.go @@ -2,6 +2,7 @@ package genutil import ( "encoding/json" + "errors" "fmt" "os" "path/filepath" @@ -60,7 +61,7 @@ func InitializeNodeValidatorFilesFromMnemonic(config *cfg.Config, mnemonic, keyT nodeID string, valPubKey cryptotypes.PubKey, err error, ) { if len(mnemonic) > 0 && !bip39.IsMnemonicValid(mnemonic) { - return "", nil, fmt.Errorf("invalid mnemonic") + return "", nil, errors.New("invalid mnemonic") } nodeKey, err := p2p.LoadOrGenNodeKey(config.NodeKeyFile()) if err != nil { @@ -103,7 +104,7 @@ func InitializeNodeValidatorFilesFromMnemonic(config *cfg.Config, mnemonic, keyT privKey = tmed25519.GenPrivKeyFromSecret([]byte(mnemonic)) case "bls12_381": // TODO: need to add support for getting from mnemonic in Comet. - return "", nil, fmt.Errorf("BLS key type does not support mnemonic") + return "", nil, errors.New("BLS key type does not support mnemonic") default: privKey = tmed25519.GenPrivKeyFromSecret([]byte(mnemonic)) } diff --git a/x/gov/client/cli/util.go b/x/gov/client/cli/util.go index 166a4c7077da..f8628f9cffed 100644 --- a/x/gov/client/cli/util.go +++ b/x/gov/client/cli/util.go @@ -2,6 +2,7 @@ package cli import ( "encoding/json" + "errors" "fmt" "os" "strings" @@ -28,15 +29,15 @@ type legacyProposal struct { // validate the legacyProposal func (p legacyProposal) validate() error { if p.Type == "" { - return fmt.Errorf("proposal type is required") + return errors.New("proposal type is required") } if p.Title == "" { - return fmt.Errorf("proposal title is required") + return errors.New("proposal title is required") } if p.Description == "" { - return fmt.Errorf("proposal description is required") + return errors.New("proposal description is required") } return nil } diff --git a/x/gov/go.mod b/x/gov/go.mod index 52ce9816d89e..18ca83213bd5 100644 --- a/x/gov/go.mod +++ b/x/gov/go.mod @@ -7,9 +7,9 @@ require ( cosmossdk.io/collections v0.4.0 cosmossdk.io/core v0.12.1-0.20231114100755-569e3ff6a0d7 cosmossdk.io/core/testing v0.0.0-00010101000000-000000000000 - cosmossdk.io/depinject v1.0.0-alpha.4 + cosmossdk.io/depinject v1.0.0 cosmossdk.io/errors v1.0.1 - cosmossdk.io/log v1.3.1 // indirect + cosmossdk.io/log v1.3.1 cosmossdk.io/math v1.3.0 cosmossdk.io/store v1.1.1-0.20240418092142-896cdf1971bc cosmossdk.io/x/auth v0.0.0-00010101000000-000000000000 @@ -19,7 +19,7 @@ require ( github.com/chzyer/readline v1.5.1 github.com/cometbft/cometbft v1.0.0-rc1 github.com/cosmos/cosmos-proto v1.0.0-beta.5 - github.com/cosmos/cosmos-sdk v0.51.0 + github.com/cosmos/cosmos-sdk v0.53.0 github.com/cosmos/gogoproto v1.5.0 github.com/golang/mock v1.6.0 github.com/golang/protobuf v1.5.4 @@ -38,6 +38,7 @@ require ( require ( buf.build/gen/go/cometbft/cometbft/protocolbuffers/go v1.34.2-20240701160653-fedbb9acfd2f.2 // indirect buf.build/gen/go/cosmos/gogo-proto/protocolbuffers/go v1.34.2-20240130113600-88ef6483f90f.2 // indirect + cosmossdk.io/schema v0.1.1 // indirect cosmossdk.io/x/consensus v0.0.0-00010101000000-000000000000 // indirect cosmossdk.io/x/tx v0.13.3 // indirect filippo.io/edwards25519 v1.1.0 // indirect @@ -62,7 +63,7 @@ require ( github.com/cosmos/crypto v0.1.2 // indirect github.com/cosmos/go-bip39 v1.0.0 // indirect github.com/cosmos/gogogateway v1.2.0 // indirect - github.com/cosmos/iavl v1.2.0 // indirect + github.com/cosmos/iavl v1.2.1-0.20240725141113-7adc688cf179 // indirect github.com/cosmos/ics23/go v0.10.0 // indirect github.com/cosmos/ledger-cosmos-go v0.13.3 // indirect github.com/danieljoos/wincred v1.2.1 // indirect @@ -172,8 +173,6 @@ require ( sigs.k8s.io/yaml v1.4.0 // indirect ) -require cosmossdk.io/schema v0.1.1 // indirect - replace github.com/cosmos/cosmos-sdk => ../../. // TODO remove post spinning out all modules @@ -182,8 +181,6 @@ replace ( cosmossdk.io/collections => ../../collections cosmossdk.io/core => ../../core cosmossdk.io/core/testing => ../../core/testing - cosmossdk.io/depinject => ../../depinject - cosmossdk.io/log => ../../log cosmossdk.io/x/accounts => ../accounts cosmossdk.io/x/auth => ../auth cosmossdk.io/x/bank => ../bank diff --git a/x/gov/go.sum b/x/gov/go.sum index 8b0e673b096e..e1b34dbc8d81 100644 --- a/x/gov/go.sum +++ b/x/gov/go.sum @@ -4,8 +4,12 @@ buf.build/gen/go/cosmos/gogo-proto/protocolbuffers/go v1.34.2-20240130113600-88e buf.build/gen/go/cosmos/gogo-proto/protocolbuffers/go v1.34.2-20240130113600-88ef6483f90f.2/go.mod h1:HqcXMSa5qnNuakaMUo+hWhF51mKbcrZxGl9Vp5EeJXc= cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= cloud.google.com/go v0.34.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= +cosmossdk.io/depinject v1.0.0 h1:dQaTu6+O6askNXO06+jyeUAnF2/ssKwrrszP9t5q050= +cosmossdk.io/depinject v1.0.0/go.mod h1:zxK/h3HgHoA/eJVtiSsoaRaRA2D5U4cJ5thIG4ssbB8= cosmossdk.io/errors v1.0.1 h1:bzu+Kcr0kS/1DuPBtUFdWjzLqyUuCiyHjyJB6srBV/0= cosmossdk.io/errors v1.0.1/go.mod h1:MeelVSZThMi4bEakzhhhE/CKqVv3nOJDA25bIqRDu/U= +cosmossdk.io/log v1.3.1 h1:UZx8nWIkfbbNEWusZqzAx3ZGvu54TZacWib3EzUYmGI= +cosmossdk.io/log v1.3.1/go.mod h1:2/dIomt8mKdk6vl3OWJcPk2be3pGOS8OQaLUM/3/tCM= cosmossdk.io/math v1.3.0 h1:RC+jryuKeytIiictDslBP9i1fhkVm6ZDmZEoNP316zE= cosmossdk.io/math v1.3.0/go.mod h1:vnRTxewy+M7BtXBNFybkuhSH4WfedVAAnERHgVFhp3k= cosmossdk.io/schema v0.1.1 h1:I0M6pgI7R10nq+/HCQfbO6BsGBZA8sQy+duR1Y3aKcA= @@ -115,8 +119,8 @@ github.com/cosmos/gogogateway v1.2.0/go.mod h1:iQpLkGWxYcnCdz5iAdLcRBSw3h7NXeOkZ github.com/cosmos/gogoproto v1.4.2/go.mod h1:cLxOsn1ljAHSV527CHOtaIP91kK6cCrZETRBrkzItWU= github.com/cosmos/gogoproto v1.5.0 h1:SDVwzEqZDDBoslaeZg+dGE55hdzHfgUA40pEanMh52o= github.com/cosmos/gogoproto v1.5.0/go.mod h1:iUM31aofn3ymidYG6bUR5ZFrk+Om8p5s754eMUcyp8I= -github.com/cosmos/iavl v1.2.0 h1:kVxTmjTh4k0Dh1VNL046v6BXqKziqMDzxo93oh3kOfM= -github.com/cosmos/iavl v1.2.0/go.mod h1:HidWWLVAtODJqFD6Hbne2Y0q3SdxByJepHUOeoH4LiI= +github.com/cosmos/iavl v1.2.1-0.20240725141113-7adc688cf179 h1:wmwDn7V3RodN9auB3FooSQxs46nHVE3u0mb87TJkZFE= +github.com/cosmos/iavl v1.2.1-0.20240725141113-7adc688cf179/go.mod h1:GiM43q0pB+uG53mLxLDzimxM9l/5N9UuSY3/D0huuVw= github.com/cosmos/ics23/go v0.10.0 h1:iXqLLgp2Lp+EdpIuwXTYIQU+AiHj9mOC2X9ab++bZDM= github.com/cosmos/ics23/go v0.10.0/go.mod h1:ZfJSmng/TBNTBkFemHHHj5YY7VAU/MBU980F4VU1NG0= github.com/cosmos/ledger-cosmos-go v0.13.3 h1:7ehuBGuyIytsXbd4MP43mLeoN2LTOEnk5nvue4rK+yM= diff --git a/x/gov/keeper/common_test.go b/x/gov/keeper/common_test.go index 595312521ed8..5b18aaaf3da4 100644 --- a/x/gov/keeper/common_test.go +++ b/x/gov/keeper/common_test.go @@ -1,6 +1,7 @@ package keeper_test import ( + "errors" "fmt" "testing" "time" @@ -10,6 +11,7 @@ import ( "cosmossdk.io/core/header" coretesting "cosmossdk.io/core/testing" + "cosmossdk.io/log" "cosmossdk.io/math" storetypes "cosmossdk.io/store/types" authtypes "cosmossdk.io/x/auth/types" @@ -126,7 +128,7 @@ func setupGovKeeper(t *testing.T, expectations ...func(sdk.Context, mocks)) ( baseApp := baseapp.NewBaseApp( "authz", - coretesting.NewNopLogger(), + log.NewNopLogger(), testCtx.DB, encCfg.TxConfig.TxDecoder(), ) @@ -192,7 +194,7 @@ func setupGovKeeperWithMaxVoteOptionsLen(t *testing.T, maxVoteOptionsLen uint64, baseApp := baseapp.NewBaseApp( "authz", - coretesting.NewNopLogger(), + log.NewNopLogger(), testCtx.DB, encCfg.TxConfig.TxDecoder(), ) @@ -266,7 +268,7 @@ func trackMockBalances(bankKeeper *govtestutil.MockBankKeeper) error { } newBalance, negative := balances[senderAddr].SafeSub(coins...) if negative { - return fmt.Errorf("not enough balance") + return errors.New("not enough balance") } balances[senderAddr] = newBalance return nil diff --git a/x/gov/simulation/operations.go b/x/gov/simulation/operations.go index a8e47b279443..a2749acb8cb3 100644 --- a/x/gov/simulation/operations.go +++ b/x/gov/simulation/operations.go @@ -11,7 +11,6 @@ import ( "cosmossdk.io/x/gov/types" v1 "cosmossdk.io/x/gov/types/v1" - "github.com/cosmos/cosmos-sdk/baseapp" "github.com/cosmos/cosmos-sdk/client" simtestutil "github.com/cosmos/cosmos-sdk/testutil/sims" sdk "github.com/cosmos/cosmos-sdk/types" @@ -171,12 +170,12 @@ func SimulateMsgSubmitProposal( ak types.AccountKeeper, bk types.BankKeeper, k *keeper.Keeper, - msgSim simtypes.MsgSimulatorFn, + msgSim simtypes.MsgSimulatorFnX, ) simtypes.Operation { - return func(r *rand.Rand, app *baseapp.BaseApp, ctx sdk.Context, accs []simtypes.Account, chainID string, + return func(r *rand.Rand, app simtypes.AppEntrypoint, ctx sdk.Context, accs []simtypes.Account, chainID string, ) (simtypes.OperationMsg, []simtypes.FutureOperation, error) { msgs := []sdk.Msg{} - proposalMsg, err := msgSim(r, accs, ak.AddressCodec()) + proposalMsg, err := msgSim(ctx, r, accs, ak.AddressCodec()) if err != nil { return simtypes.OperationMsg{}, nil, err } @@ -198,7 +197,7 @@ func SimulateMsgSubmitLegacyProposal( k *keeper.Keeper, contentSim simtypes.ContentSimulatorFn, //nolint:staticcheck // used for legacy testing ) simtypes.Operation { - return func(r *rand.Rand, app *baseapp.BaseApp, ctx sdk.Context, accs []simtypes.Account, chainID string, + return func(r *rand.Rand, app simtypes.AppEntrypoint, ctx sdk.Context, accs []simtypes.Account, chainID string, ) (simtypes.OperationMsg, []simtypes.FutureOperation, error) { // 1) submit proposal now content := contentSim(r, ctx, accs) @@ -249,7 +248,7 @@ func simulateMsgSubmitProposal( return func( r *rand.Rand, - app *baseapp.BaseApp, + app simtypes.AppEntrypoint, ctx sdk.Context, accs []simtypes.Account, chainID string, @@ -327,16 +326,19 @@ func simulateMsgSubmitProposal( whoVotes = whoVotes[:numVotes] params, _ := k.Params.Get(ctx) votingPeriod := params.VotingPeriod - - fops := make([]simtypes.FutureOperation, numVotes+1) - for i := 0; i < numVotes; i++ { - whenVote := ctx.HeaderInfo().Time.Add(time.Duration(r.Int63n(int64(votingPeriod.Seconds()))) * time.Second) - fops[i] = simtypes.FutureOperation{ - BlockTime: whenVote, - Op: operationSimulateMsgVote(txGen, ak, bk, k, accs[whoVotes[i]], int64(proposalID), nil), + var fops []simtypes.FutureOperation + if false { // future ops deactivated because they were not implemented correct in the framework before and flood the system now + fops = make([]simtypes.FutureOperation, numVotes+1) + for i := 0; i < numVotes; i++ { + whenVote := ctx.HeaderInfo().Time.Add(time.Duration(r.Int63n(int64(votingPeriod.Seconds()))) * time.Second) + fops[i] = simtypes.FutureOperation{ + BlockTime: whenVote, + Op: func(r *rand.Rand, app simtypes.AppEntrypoint, ctx sdk.Context, accounts []simtypes.Account, chainID string) (OperationMsg simtypes.OperationMsg, futureOps []simtypes.FutureOperation, err error) { + return operationSimulateMsgVote(txGen, ak, bk, k, accs[whoVotes[i]], int64(proposalID), nil)(r, app, ctx, accounts, chainID) + }, + } } } - return opMsg, fops, nil } } @@ -350,7 +352,7 @@ func SimulateMsgDeposit( s *SharedState, ) simtypes.Operation { return func( - r *rand.Rand, app *baseapp.BaseApp, ctx sdk.Context, + r *rand.Rand, app simtypes.AppEntrypoint, ctx sdk.Context, accs []simtypes.Account, chainID string, ) (simtypes.OperationMsg, []simtypes.FutureOperation, error) { simAccount, _ := simtypes.RandomAcc(r, accs) @@ -429,7 +431,7 @@ func operationSimulateMsgVote( s *SharedState, ) simtypes.Operation { return func( - r *rand.Rand, app *baseapp.BaseApp, ctx sdk.Context, + r *rand.Rand, app simtypes.AppEntrypoint, ctx sdk.Context, accs []simtypes.Account, chainID string, ) (simtypes.OperationMsg, []simtypes.FutureOperation, error) { if simAccount.Equals(simtypes.Account{}) { @@ -498,7 +500,7 @@ func operationSimulateMsgVoteWeighted( s *SharedState, ) simtypes.Operation { return func( - r *rand.Rand, app *baseapp.BaseApp, ctx sdk.Context, + r *rand.Rand, app simtypes.AppEntrypoint, ctx sdk.Context, accs []simtypes.Account, chainID string, ) (simtypes.OperationMsg, []simtypes.FutureOperation, error) { if simAccount.Equals(simtypes.Account{}) { @@ -549,7 +551,7 @@ func operationSimulateMsgVoteWeighted( // SimulateMsgCancelProposal generates a MsgCancelProposal. func SimulateMsgCancelProposal(txGen client.TxConfig, ak types.AccountKeeper, bk types.BankKeeper, k *keeper.Keeper) simtypes.Operation { return func( - r *rand.Rand, app *baseapp.BaseApp, ctx sdk.Context, + r *rand.Rand, app simtypes.AppEntrypoint, ctx sdk.Context, accs []simtypes.Account, chainID string, ) (simtypes.OperationMsg, []simtypes.FutureOperation, error) { simAccount := accs[0] diff --git a/x/gov/simulation/proposals.go b/x/gov/simulation/proposals.go index bc508cce4ebb..c53d024b13a5 100644 --- a/x/gov/simulation/proposals.go +++ b/x/gov/simulation/proposals.go @@ -1,6 +1,7 @@ package simulation import ( + "context" "math/rand" coreaddress "cosmossdk.io/core/address" @@ -17,7 +18,7 @@ const OpWeightSubmitTextProposal = "op_weight_submit_text_proposal" // ProposalMsgs defines the module weighted proposals' contents func ProposalMsgs() []simtypes.WeightedProposalMsg { return []simtypes.WeightedProposalMsg{ - simulation.NewWeightedProposalMsg( + simulation.NewWeightedProposalMsgX( OpWeightSubmitTextProposal, DefaultWeightTextProposal, SimulateTextProposal, @@ -27,7 +28,7 @@ func ProposalMsgs() []simtypes.WeightedProposalMsg { // SimulateTextProposal returns a random text proposal content. // A text proposal is a proposal that contains no msgs. -func SimulateTextProposal(r *rand.Rand, _ []simtypes.Account, _ coreaddress.Codec) (sdk.Msg, error) { +func SimulateTextProposal(_ context.Context, r *rand.Rand, _ []simtypes.Account, _ coreaddress.Codec) (sdk.Msg, error) { return nil, nil } diff --git a/x/gov/simulation/proposals_test.go b/x/gov/simulation/proposals_test.go index 41a4068e7bb3..939103c75ea9 100644 --- a/x/gov/simulation/proposals_test.go +++ b/x/gov/simulation/proposals_test.go @@ -1,6 +1,7 @@ package simulation_test import ( + "context" "math/rand" "testing" @@ -30,7 +31,7 @@ func TestProposalMsgs(t *testing.T) { assert.Equal(t, simulation.OpWeightSubmitTextProposal, w0.AppParamsKey()) assert.Equal(t, simulation.DefaultWeightTextProposal, w0.DefaultWeight()) - msg, err := w0.MsgSimulatorFn()(r, accounts, codectestutil.CodecOptions{}.GetAddressCodec()) + msg, err := w0.MsgSimulatorFn()(context.Background(), r, accounts, codectestutil.CodecOptions{}.GetAddressCodec()) assert.NilError(t, err) assert.Assert(t, msg == nil) } diff --git a/x/gov/testutil/expected_keepers.go b/x/gov/testutil/expected_keepers.go index 987a7a895eb5..9da4b7156638 100644 --- a/x/gov/testutil/expected_keepers.go +++ b/x/gov/testutil/expected_keepers.go @@ -43,7 +43,7 @@ type BankKeeper interface { // PoolKeeper extends the gov's actual expected PoolKeeper. type PoolKeeper interface { - FundCommunityPool(ctx context.Context, amount sdk.Coins, sender sdk.AccAddress) error + FundCommunityPool(ctx context.Context, amount sdk.Coins, sender []byte) error } // StakingKeeper extends gov's actual expected StakingKeeper with additional diff --git a/x/gov/testutil/expected_keepers_mocks.go b/x/gov/testutil/expected_keepers_mocks.go index ea9e9e535bcb..4636f53df68e 100644 --- a/x/gov/testutil/expected_keepers_mocks.go +++ b/x/gov/testutil/expected_keepers_mocks.go @@ -290,7 +290,7 @@ func (m *MockPoolKeeper) EXPECT() *MockPoolKeeperMockRecorder { } // FundCommunityPool mocks base method. -func (m *MockPoolKeeper) FundCommunityPool(ctx context.Context, amount types.Coins, sender types.AccAddress) error { +func (m *MockPoolKeeper) FundCommunityPool(ctx context.Context, amount types.Coins, sender []byte) error { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "FundCommunityPool", ctx, amount, sender) ret0, _ := ret[0].(error) diff --git a/x/gov/types/expected_keepers.go b/x/gov/types/expected_keepers.go index 31d19af74d64..7a14d90dbe6d 100644 --- a/x/gov/types/expected_keepers.go +++ b/x/gov/types/expected_keepers.go @@ -51,7 +51,7 @@ type BankKeeper interface { // PoolKeeper defines the expected interface needed to fund & distribute pool balances. type PoolKeeper interface { - FundCommunityPool(ctx context.Context, amount sdk.Coins, sender sdk.AccAddress) error + FundCommunityPool(ctx context.Context, amount sdk.Coins, sender []byte) error } // Event Hooks diff --git a/x/gov/types/v1/genesis.go b/x/gov/types/v1/genesis.go index 21721e4b024e..e4a8ae280509 100644 --- a/x/gov/types/v1/genesis.go +++ b/x/gov/types/v1/genesis.go @@ -4,11 +4,10 @@ import ( "errors" "fmt" + gogoprotoany "github.com/cosmos/gogoproto/types/any" "golang.org/x/sync/errgroup" "cosmossdk.io/core/address" - - "github.com/cosmos/cosmos-sdk/codec/types" ) // NewGenesisState creates a new genesis state for the governance module @@ -107,10 +106,10 @@ func ValidateGenesis(ac address.Codec, data *GenesisState) error { return errGroup.Wait() } -var _ types.UnpackInterfacesMessage = GenesisState{} +var _ gogoprotoany.UnpackInterfacesMessage = GenesisState{} // UnpackInterfaces implements UnpackInterfacesMessage.UnpackInterfaces -func (data GenesisState) UnpackInterfaces(unpacker types.AnyUnpacker) error { +func (data GenesisState) UnpackInterfaces(unpacker gogoprotoany.AnyUnpacker) error { for _, p := range data.Proposals { err := p.UnpackInterfaces(unpacker) if err != nil { diff --git a/x/gov/types/v1/msgs.go b/x/gov/types/v1/msgs.go index d25a9ed33aad..70b4b90c5c73 100644 --- a/x/gov/types/v1/msgs.go +++ b/x/gov/types/v1/msgs.go @@ -4,6 +4,8 @@ import ( "errors" "fmt" + gogoprotoany "github.com/cosmos/gogoproto/types/any" + "cosmossdk.io/x/gov/types/v1beta1" codectypes "github.com/cosmos/cosmos-sdk/codec/types" @@ -12,8 +14,8 @@ import ( ) var ( - _, _, _, _, _, _, _, _ sdk.Msg = &MsgSubmitProposal{}, &MsgDeposit{}, &MsgVote{}, &MsgVoteWeighted{}, &MsgExecLegacyContent{}, &MsgUpdateParams{}, &MsgCancelProposal{}, &MsgSubmitMultipleChoiceProposal{} - _, _ codectypes.UnpackInterfacesMessage = &MsgSubmitProposal{}, &MsgExecLegacyContent{} + _, _, _, _, _, _, _, _ sdk.Msg = &MsgSubmitProposal{}, &MsgDeposit{}, &MsgVote{}, &MsgVoteWeighted{}, &MsgExecLegacyContent{}, &MsgUpdateParams{}, &MsgCancelProposal{}, &MsgSubmitMultipleChoiceProposal{} + _, _ gogoprotoany.UnpackInterfacesMessage = &MsgSubmitProposal{}, &MsgExecLegacyContent{} ) // NewMsgSubmitProposal creates a new MsgSubmitProposal. @@ -60,7 +62,7 @@ func (m *MsgSubmitProposal) SetMsgs(msgs []sdk.Msg) error { } // UnpackInterfaces implements UnpackInterfacesMessage.UnpackInterfaces -func (m MsgSubmitProposal) UnpackInterfaces(unpacker codectypes.AnyUnpacker) error { +func (m MsgSubmitProposal) UnpackInterfaces(unpacker gogoprotoany.AnyUnpacker) error { return sdktx.UnpackInterfaces(unpacker, m.Messages) } @@ -120,7 +122,7 @@ func (c MsgExecLegacyContent) ValidateBasic() error { } // UnpackInterfaces implements UnpackInterfacesMessage.UnpackInterfaces -func (c MsgExecLegacyContent) UnpackInterfaces(unpacker codectypes.AnyUnpacker) error { +func (c MsgExecLegacyContent) UnpackInterfaces(unpacker gogoprotoany.AnyUnpacker) error { var content v1beta1.Content return unpacker.UnpackAny(c.Content, &content) } diff --git a/x/gov/types/v1/proposal.go b/x/gov/types/v1/proposal.go index be5931c217ae..e9a901934c58 100644 --- a/x/gov/types/v1/proposal.go +++ b/x/gov/types/v1/proposal.go @@ -5,7 +5,8 @@ import ( "strings" "time" - codectypes "github.com/cosmos/cosmos-sdk/codec/types" + gogoprotoany "github.com/cosmos/gogoproto/types/any" + sdk "github.com/cosmos/cosmos-sdk/types" sdktx "github.com/cosmos/cosmos-sdk/types/tx" ) @@ -74,14 +75,14 @@ func (p Proposal) GetMinDepositFromParams(params Params) sdk.Coins { } // UnpackInterfaces implements UnpackInterfacesMessage.UnpackInterfaces -func (p Proposal) UnpackInterfaces(unpacker codectypes.AnyUnpacker) error { +func (p Proposal) UnpackInterfaces(unpacker gogoprotoany.AnyUnpacker) error { return sdktx.UnpackInterfaces(unpacker, p.Messages) } // Proposals is an array of proposal type Proposals []*Proposal -var _ codectypes.UnpackInterfacesMessage = Proposals{} +var _ gogoprotoany.UnpackInterfacesMessage = Proposals{} // String implements stringer interface func (p Proposals) String() string { @@ -94,7 +95,7 @@ func (p Proposals) String() string { } // UnpackInterfaces implements UnpackInterfacesMessage.UnpackInterfaces -func (p Proposals) UnpackInterfaces(unpacker codectypes.AnyUnpacker) error { +func (p Proposals) UnpackInterfaces(unpacker gogoprotoany.AnyUnpacker) error { for _, x := range p { err := x.UnpackInterfaces(unpacker) if err != nil { diff --git a/x/gov/types/v1beta1/genesis.go b/x/gov/types/v1beta1/genesis.go index d71c008d8860..d2c288574db6 100644 --- a/x/gov/types/v1beta1/genesis.go +++ b/x/gov/types/v1beta1/genesis.go @@ -3,9 +3,9 @@ package v1beta1 import ( "fmt" - "cosmossdk.io/math" + gogoprotoany "github.com/cosmos/gogoproto/types/any" - "github.com/cosmos/cosmos-sdk/codec/types" + "cosmossdk.io/math" ) // NewGenesisState creates a new genesis state for the governance module @@ -66,10 +66,10 @@ func ValidateGenesis(data *GenesisState) error { return nil } -var _ types.UnpackInterfacesMessage = GenesisState{} +var _ gogoprotoany.UnpackInterfacesMessage = GenesisState{} // UnpackInterfaces implements UnpackInterfacesMessage.UnpackInterfaces -func (data GenesisState) UnpackInterfaces(unpacker types.AnyUnpacker) error { +func (data GenesisState) UnpackInterfaces(unpacker gogoprotoany.AnyUnpacker) error { for _, p := range data.Proposals { err := p.UnpackInterfaces(unpacker) if err != nil { diff --git a/x/gov/types/v1beta1/msgs.go b/x/gov/types/v1beta1/msgs.go index 298f26c592eb..984bed150093 100644 --- a/x/gov/types/v1beta1/msgs.go +++ b/x/gov/types/v1beta1/msgs.go @@ -4,6 +4,7 @@ import ( "fmt" "github.com/cosmos/gogoproto/proto" + gogoprotoany "github.com/cosmos/gogoproto/types/any" codectypes "github.com/cosmos/cosmos-sdk/codec/types" sdk "github.com/cosmos/cosmos-sdk/types" @@ -20,7 +21,7 @@ const ( var ( _, _, _, _ sdk.Msg = &MsgSubmitProposal{}, &MsgDeposit{}, &MsgVote{}, &MsgVoteWeighted{} - _ codectypes.UnpackInterfacesMessage = &MsgSubmitProposal{} + _ gogoprotoany.UnpackInterfacesMessage = &MsgSubmitProposal{} ) // NewMsgSubmitProposal creates a new MsgSubmitProposal. @@ -73,7 +74,7 @@ func (m *MsgSubmitProposal) SetContent(content Content) error { } // UnpackInterfaces implements UnpackInterfacesMessage.UnpackInterfaces -func (m MsgSubmitProposal) UnpackInterfaces(unpacker codectypes.AnyUnpacker) error { +func (m MsgSubmitProposal) UnpackInterfaces(unpacker gogoprotoany.AnyUnpacker) error { var content Content return unpacker.UnpackAny(m.Content, &content) } diff --git a/x/gov/types/v1beta1/proposal.go b/x/gov/types/v1beta1/proposal.go index b29753edb33b..814301406861 100644 --- a/x/gov/types/v1beta1/proposal.go +++ b/x/gov/types/v1beta1/proposal.go @@ -7,6 +7,7 @@ import ( "time" "github.com/cosmos/gogoproto/proto" + gogoprotoany "github.com/cosmos/gogoproto/types/any" errorsmod "cosmossdk.io/errors" "cosmossdk.io/x/gov/types" @@ -81,7 +82,7 @@ func (p Proposal) GetTitle() string { } // UnpackInterfaces implements UnpackInterfacesMessage.UnpackInterfaces -func (p Proposal) UnpackInterfaces(unpacker codectypes.AnyUnpacker) error { +func (p Proposal) UnpackInterfaces(unpacker gogoprotoany.AnyUnpacker) error { var content Content return unpacker.UnpackAny(p.Content, &content) } @@ -89,7 +90,7 @@ func (p Proposal) UnpackInterfaces(unpacker codectypes.AnyUnpacker) error { // Proposals is an array of proposal type Proposals []Proposal -var _ codectypes.UnpackInterfacesMessage = Proposals{} +var _ gogoprotoany.UnpackInterfacesMessage = Proposals{} // Equal returns true if two slices (order-dependant) of proposals are equal. func (p Proposals) Equal(other Proposals) bool { @@ -118,7 +119,7 @@ func (p Proposals) String() string { } // UnpackInterfaces implements UnpackInterfacesMessage.UnpackInterfaces -func (p Proposals) UnpackInterfaces(unpacker codectypes.AnyUnpacker) error { +func (p Proposals) UnpackInterfaces(unpacker gogoprotoany.AnyUnpacker) error { for _, x := range p { err := x.UnpackInterfaces(unpacker) if err != nil { diff --git a/x/group/client/cli/util.go b/x/group/client/cli/util.go index 7b5cc7359155..162a7addd310 100644 --- a/x/group/client/cli/util.go +++ b/x/group/client/cli/util.go @@ -2,6 +2,7 @@ package cli import ( "encoding/json" + "errors" "fmt" "os" @@ -14,7 +15,7 @@ import ( // parseDecisionPolicy reads and parses the decision policy. func parseDecisionPolicy(cdc codec.Codec, decisionPolicyFile string) (group.DecisionPolicy, error) { if decisionPolicyFile == "" { - return nil, fmt.Errorf("decision policy is required") + return nil, errors.New("decision policy is required") } contents, err := os.ReadFile(decisionPolicyFile) diff --git a/x/group/genesis.go b/x/group/genesis.go index eccf1f941e05..2a7e073890ba 100644 --- a/x/group/genesis.go +++ b/x/group/genesis.go @@ -3,9 +3,10 @@ package group import ( "fmt" + gogoprotoany "github.com/cosmos/gogoproto/types/any" + errorsmod "cosmossdk.io/errors" - "github.com/cosmos/cosmos-sdk/codec/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" ) @@ -83,7 +84,7 @@ func (s GenesisState) Validate() error { } // UnpackInterfaces implements UnpackInterfacesMessage.UnpackInterfaces -func (s GenesisState) UnpackInterfaces(unpacker types.AnyUnpacker) error { +func (s GenesisState) UnpackInterfaces(unpacker gogoprotoany.AnyUnpacker) error { for _, g := range s.GroupPolicies { err := g.UnpackInterfaces(unpacker) if err != nil { diff --git a/x/group/go.mod b/x/group/go.mod index 80c70d3d79c5..8f229dfbbc9f 100644 --- a/x/group/go.mod +++ b/x/group/go.mod @@ -5,7 +5,7 @@ go 1.22.2 require ( cosmossdk.io/api v0.7.5 cosmossdk.io/core v0.12.1-0.20231114100755-569e3ff6a0d7 - cosmossdk.io/depinject v1.0.0-alpha.4 + cosmossdk.io/depinject v1.0.0 cosmossdk.io/errors v1.0.1 cosmossdk.io/log v1.3.1 cosmossdk.io/math v1.3.0 @@ -23,7 +23,7 @@ require ( github.com/cometbft/cometbft/api v1.0.0-rc.1 github.com/cosmos/cosmos-db v1.0.2 github.com/cosmos/cosmos-proto v1.0.0-beta.5 - github.com/cosmos/cosmos-sdk v0.51.0 + github.com/cosmos/cosmos-sdk v0.53.0 github.com/cosmos/gogoproto v1.5.0 github.com/golang/mock v1.6.0 github.com/golang/protobuf v1.5.4 @@ -69,7 +69,7 @@ require ( github.com/cosmos/crypto v0.1.2 // indirect github.com/cosmos/go-bip39 v1.0.0 // indirect github.com/cosmos/gogogateway v1.2.0 // indirect - github.com/cosmos/iavl v1.2.0 // indirect + github.com/cosmos/iavl v1.2.1-0.20240725141113-7adc688cf179 // indirect github.com/cosmos/ics23/go v0.10.0 // indirect github.com/cosmos/ledger-cosmos-go v0.13.3 // indirect github.com/danieljoos/wincred v1.2.1 // indirect @@ -188,8 +188,6 @@ replace ( cosmossdk.io/collections => ../../collections cosmossdk.io/core => ../../core cosmossdk.io/core/testing => ../../core/testing - cosmossdk.io/depinject => ../../depinject - cosmossdk.io/log => ../../log cosmossdk.io/x/accounts => ../accounts cosmossdk.io/x/accounts/defaults/multisig => ../accounts/defaults/multisig cosmossdk.io/x/auth => ../auth diff --git a/x/group/go.sum b/x/group/go.sum index e3dc6325d997..34b225a6d09e 100644 --- a/x/group/go.sum +++ b/x/group/go.sum @@ -4,8 +4,12 @@ buf.build/gen/go/cosmos/gogo-proto/protocolbuffers/go v1.34.2-20240130113600-88e buf.build/gen/go/cosmos/gogo-proto/protocolbuffers/go v1.34.2-20240130113600-88ef6483f90f.2/go.mod h1:HqcXMSa5qnNuakaMUo+hWhF51mKbcrZxGl9Vp5EeJXc= cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= cloud.google.com/go v0.34.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= +cosmossdk.io/depinject v1.0.0 h1:dQaTu6+O6askNXO06+jyeUAnF2/ssKwrrszP9t5q050= +cosmossdk.io/depinject v1.0.0/go.mod h1:zxK/h3HgHoA/eJVtiSsoaRaRA2D5U4cJ5thIG4ssbB8= cosmossdk.io/errors v1.0.1 h1:bzu+Kcr0kS/1DuPBtUFdWjzLqyUuCiyHjyJB6srBV/0= cosmossdk.io/errors v1.0.1/go.mod h1:MeelVSZThMi4bEakzhhhE/CKqVv3nOJDA25bIqRDu/U= +cosmossdk.io/log v1.3.1 h1:UZx8nWIkfbbNEWusZqzAx3ZGvu54TZacWib3EzUYmGI= +cosmossdk.io/log v1.3.1/go.mod h1:2/dIomt8mKdk6vl3OWJcPk2be3pGOS8OQaLUM/3/tCM= cosmossdk.io/math v1.3.0 h1:RC+jryuKeytIiictDslBP9i1fhkVm6ZDmZEoNP316zE= cosmossdk.io/math v1.3.0/go.mod h1:vnRTxewy+M7BtXBNFybkuhSH4WfedVAAnERHgVFhp3k= cosmossdk.io/schema v0.1.1 h1:I0M6pgI7R10nq+/HCQfbO6BsGBZA8sQy+duR1Y3aKcA= @@ -121,8 +125,8 @@ github.com/cosmos/gogogateway v1.2.0/go.mod h1:iQpLkGWxYcnCdz5iAdLcRBSw3h7NXeOkZ github.com/cosmos/gogoproto v1.4.2/go.mod h1:cLxOsn1ljAHSV527CHOtaIP91kK6cCrZETRBrkzItWU= github.com/cosmos/gogoproto v1.5.0 h1:SDVwzEqZDDBoslaeZg+dGE55hdzHfgUA40pEanMh52o= github.com/cosmos/gogoproto v1.5.0/go.mod h1:iUM31aofn3ymidYG6bUR5ZFrk+Om8p5s754eMUcyp8I= -github.com/cosmos/iavl v1.2.0 h1:kVxTmjTh4k0Dh1VNL046v6BXqKziqMDzxo93oh3kOfM= -github.com/cosmos/iavl v1.2.0/go.mod h1:HidWWLVAtODJqFD6Hbne2Y0q3SdxByJepHUOeoH4LiI= +github.com/cosmos/iavl v1.2.1-0.20240725141113-7adc688cf179 h1:wmwDn7V3RodN9auB3FooSQxs46nHVE3u0mb87TJkZFE= +github.com/cosmos/iavl v1.2.1-0.20240725141113-7adc688cf179/go.mod h1:GiM43q0pB+uG53mLxLDzimxM9l/5N9UuSY3/D0huuVw= github.com/cosmos/ics23/go v0.10.0 h1:iXqLLgp2Lp+EdpIuwXTYIQU+AiHj9mOC2X9ab++bZDM= github.com/cosmos/ics23/go v0.10.0/go.mod h1:ZfJSmng/TBNTBkFemHHHj5YY7VAU/MBU980F4VU1NG0= github.com/cosmos/ledger-cosmos-go v0.13.3 h1:7ehuBGuyIytsXbd4MP43mLeoN2LTOEnk5nvue4rK+yM= diff --git a/x/group/internal/math/dec.go b/x/group/internal/math/dec.go index 02a0ca847678..973aa7024a40 100644 --- a/x/group/internal/math/dec.go +++ b/x/group/internal/math/dec.go @@ -2,12 +2,12 @@ package math import ( - "fmt" + "errors" "github.com/cockroachdb/apd/v2" errorsmod "cosmossdk.io/errors" - "cosmossdk.io/x/group/errors" + grouperrors "cosmossdk.io/x/group/errors" ) // Dec is a wrapper struct around apd.Decimal that does no mutation of apd.Decimal's when performing @@ -23,10 +23,10 @@ type Dec struct { func NewPositiveDecFromString(s string) (Dec, error) { d, err := NewDecFromString(s) if err != nil { - return Dec{}, errors.ErrInvalidDecString.Wrap(err.Error()) + return Dec{}, grouperrors.ErrInvalidDecString.Wrap(err.Error()) } if !d.IsPositive() { - return Dec{}, errors.ErrInvalidDecString.Wrapf("expected a positive decimal, got %s", s) + return Dec{}, grouperrors.ErrInvalidDecString.Wrapf("expected a positive decimal, got %s", s) } return d, nil } @@ -34,10 +34,10 @@ func NewPositiveDecFromString(s string) (Dec, error) { func NewNonNegativeDecFromString(s string) (Dec, error) { d, err := NewDecFromString(s) if err != nil { - return Dec{}, errors.ErrInvalidDecString.Wrap(err.Error()) + return Dec{}, grouperrors.ErrInvalidDecString.Wrap(err.Error()) } if d.IsNegative() { - return Dec{}, errors.ErrInvalidDecString.Wrapf("expected a non-negative decimal, got %s", s) + return Dec{}, grouperrors.ErrInvalidDecString.Wrapf("expected a non-negative decimal, got %s", s) } return d, nil } @@ -51,11 +51,11 @@ func (x Dec) IsPositive() bool { func NewDecFromString(s string) (Dec, error) { d, _, err := apd.NewFromString(s) if err != nil { - return Dec{}, errors.ErrInvalidDecString.Wrap(err.Error()) + return Dec{}, grouperrors.ErrInvalidDecString.Wrap(err.Error()) } if d.Form != apd.Finite { - return Dec{}, errors.ErrInvalidDecString.Wrapf("expected a finite decimal, got %s", s) + return Dec{}, grouperrors.ErrInvalidDecString.Wrapf("expected a finite decimal, got %s", s) } return Dec{*d}, nil @@ -136,7 +136,7 @@ func SubNonNegative(x, y Dec) (Dec, error) { } if z.IsNegative() { - return z, fmt.Errorf("result negative during non-negative subtraction") + return z, errors.New("result negative during non-negative subtraction") } return z, nil diff --git a/x/group/internal/orm/iterator.go b/x/group/internal/orm/iterator.go index a19d238e906d..c2612a4954fc 100644 --- a/x/group/internal/orm/iterator.go +++ b/x/group/internal/orm/iterator.go @@ -1,13 +1,13 @@ package orm import ( - "fmt" + "errors" "reflect" "github.com/cosmos/gogoproto/proto" errorsmod "cosmossdk.io/errors" - "cosmossdk.io/x/group/errors" + grouperrors "cosmossdk.io/x/group/errors" "github.com/cosmos/cosmos-sdk/types/query" ) @@ -20,7 +20,7 @@ const defaultPageLimit = 100 type IteratorFunc func(dest proto.Message) (RowID, error) // LoadNext loads the next value in the sequence into the pointer passed as dest and returns the key. If there -// are no more items the errors.ErrORMIteratorDone error is returned +// are no more items the grouperrors.ErrORMIteratorDone error is returned // The key is the rowID and not any MultiKeyIndex key. func (i IteratorFunc) LoadNext(dest proto.Message) (RowID, error) { return i(dest) @@ -35,10 +35,10 @@ func NewSingleValueIterator(rowID RowID, val []byte) Iterator { var closed bool return IteratorFunc(func(dest proto.Message) (RowID, error) { if dest == nil { - return nil, errorsmod.Wrap(errors.ErrORMInvalidArgument, "destination object must not be nil") + return nil, errorsmod.Wrap(grouperrors.ErrORMInvalidArgument, "destination object must not be nil") } if closed || val == nil { - return nil, errors.ErrORMIteratorDone + return nil, grouperrors.ErrORMIteratorDone } closed = true return rowID, proto.Unmarshal(val, dest) @@ -48,7 +48,7 @@ func NewSingleValueIterator(rowID RowID, val []byte) Iterator { // Iterator that return ErrORMInvalidIterator only. func NewInvalidIterator() Iterator { return IteratorFunc(func(dest proto.Message) (RowID, error) { - return nil, errors.ErrORMInvalidIterator + return nil, grouperrors.ErrORMInvalidIterator }) } @@ -63,20 +63,20 @@ type LimitedIterator struct { // max can be 0 or any positive number func LimitIterator(parent Iterator, max int) (*LimitedIterator, error) { if max < 0 { - return nil, errors.ErrORMInvalidArgument.Wrap("quantity must not be negative") + return nil, grouperrors.ErrORMInvalidArgument.Wrap("quantity must not be negative") } if parent == nil { - return nil, errors.ErrORMInvalidArgument.Wrap("parent iterator must not be nil") + return nil, grouperrors.ErrORMInvalidArgument.Wrap("parent iterator must not be nil") } return &LimitedIterator{remainingCount: max, parentIterator: parent}, nil } // LoadNext loads the next value in the sequence into the pointer passed as dest and returns the key. If there -// are no more items or the defined max number of elements was returned the `errors.ErrORMIteratorDone` error is returned +// are no more items or the defined max number of elements was returned the `grouperrors.ErrORMIteratorDone` error is returned // The key is the rowID and not any MultiKeyIndex key. func (i *LimitedIterator) LoadNext(dest proto.Message) (RowID, error) { if i.remainingCount == 0 { - return nil, errors.ErrORMIteratorDone + return nil, grouperrors.ErrORMIteratorDone } i.remainingCount-- return i.parentIterator.LoadNext(dest) @@ -91,7 +91,7 @@ func (i LimitedIterator) Close() error { // When the iterator is closed or has no elements the according error is passed as return value. func First(it Iterator, dest proto.Message) (RowID, error) { if it == nil { - return nil, errorsmod.Wrap(errors.ErrORMInvalidArgument, "iterator must not be nil") + return nil, errorsmod.Wrap(grouperrors.ErrORMInvalidArgument, "iterator must not be nil") } defer it.Close() binKey, err := it.LoadNext(dest) @@ -136,7 +136,7 @@ func Paginate( countTotal := pageRequest.CountTotal if offset > 0 && key != nil { - return nil, fmt.Errorf("invalid request, either offset or key is expected, got both") + return nil, errors.New("invalid request, either offset or key is expected, got both") } if limit == 0 { @@ -147,7 +147,7 @@ func Paginate( } if it == nil { - return nil, errorsmod.Wrap(errors.ErrORMInvalidArgument, "iterator must not be nil") + return nil, errorsmod.Wrap(grouperrors.ErrORMInvalidArgument, "iterator must not be nil") } defer it.Close() @@ -177,11 +177,11 @@ func Paginate( modelProto, ok := model.Interface().(proto.Message) if !ok { - return nil, errorsmod.Wrapf(errors.ErrORMInvalidArgument, "%s should implement codec.ProtoMarshaler", elemType) + return nil, errorsmod.Wrapf(grouperrors.ErrORMInvalidArgument, "%s should implement codec.ProtoMarshaler", elemType) } binKey, err := it.LoadNext(modelProto) if err != nil { - if errors.ErrORMIteratorDone.Is(err) { + if grouperrors.ErrORMIteratorDone.Is(err) { break } return nil, err @@ -237,7 +237,7 @@ type ModelSlicePtr interface{} // require.NoError(t, err) func ReadAll(it Iterator, dest ModelSlicePtr) ([]RowID, error) { if it == nil { - return nil, errorsmod.Wrap(errors.ErrORMInvalidArgument, "iterator must not be nil") + return nil, errorsmod.Wrap(grouperrors.ErrORMInvalidArgument, "iterator must not be nil") } defer it.Close() @@ -261,7 +261,7 @@ func ReadAll(it Iterator, dest ModelSlicePtr) ([]RowID, error) { switch { case err == nil: tmpSlice = reflect.Append(tmpSlice, val) - case errors.ErrORMIteratorDone.Is(err): + case grouperrors.ErrORMIteratorDone.Is(err): destRef.Set(tmpSlice) return rowIDs, nil default: @@ -276,14 +276,14 @@ func ReadAll(it Iterator, dest ModelSlicePtr) ([]RowID, error) { // It overwrites destRef and tmpSlice using reflection. func assertDest(dest ModelSlicePtr, destRef, tmpSlice *reflect.Value) (reflect.Type, error) { if dest == nil { - return nil, errorsmod.Wrap(errors.ErrORMInvalidArgument, "destination must not be nil") + return nil, errorsmod.Wrap(grouperrors.ErrORMInvalidArgument, "destination must not be nil") } tp := reflect.ValueOf(dest) if tp.Kind() != reflect.Ptr { - return nil, errorsmod.Wrap(errors.ErrORMInvalidArgument, "destination must be a pointer to a slice") + return nil, errorsmod.Wrap(grouperrors.ErrORMInvalidArgument, "destination must be a pointer to a slice") } if tp.Elem().Kind() != reflect.Slice { - return nil, errorsmod.Wrap(errors.ErrORMInvalidArgument, "destination must point to a slice") + return nil, errorsmod.Wrap(grouperrors.ErrORMInvalidArgument, "destination must point to a slice") } // Since dest is just an interface{}, we overwrite destRef using reflection @@ -291,7 +291,7 @@ func assertDest(dest ModelSlicePtr, destRef, tmpSlice *reflect.Value) (reflect.T *destRef = tp.Elem() // We need to verify that we can call Set() on destRef. if !destRef.CanSet() { - return nil, errorsmod.Wrap(errors.ErrORMInvalidArgument, "destination not assignable") + return nil, errorsmod.Wrap(grouperrors.ErrORMInvalidArgument, "destination not assignable") } elemType := reflect.TypeOf(dest).Elem().Elem() @@ -299,7 +299,7 @@ func assertDest(dest ModelSlicePtr, destRef, tmpSlice *reflect.Value) (reflect.T protoMarshaler := reflect.TypeOf((*proto.Message)(nil)).Elem() if !elemType.Implements(protoMarshaler) && !reflect.PtrTo(elemType).Implements(protoMarshaler) { - return nil, errorsmod.Wrapf(errors.ErrORMInvalidArgument, "unsupported type :%s", elemType) + return nil, errorsmod.Wrapf(grouperrors.ErrORMInvalidArgument, "unsupported type :%s", elemType) } // tmpSlice is a slice value for the specified type diff --git a/x/group/keeper/msg_server_test.go b/x/group/keeper/msg_server_test.go index 20eb8a7b184b..b3100a50287f 100644 --- a/x/group/keeper/msg_server_test.go +++ b/x/group/keeper/msg_server_test.go @@ -3,7 +3,7 @@ package keeper_test import ( "bytes" "context" - "fmt" + "errors" "sort" "strings" "time" @@ -2706,7 +2706,7 @@ func (s *TestSuite) TestExecProposal() { setupProposal: func(ctx context.Context) uint64 { msgs := []sdk.Msg{msgSend1, msgSend2} s.bankKeeper.EXPECT().Send(gomock.Any(), msgSend1).Return(nil, nil) - s.bankKeeper.EXPECT().Send(gomock.Any(), msgSend2).Return(nil, fmt.Errorf("error")) + s.bankKeeper.EXPECT().Send(gomock.Any(), msgSend2).Return(nil, errors.New("error")) return submitProposalAndVote(ctx, s, msgs, proposers, group.VOTE_OPTION_YES) }, @@ -2723,7 +2723,7 @@ func (s *TestSuite) TestExecProposal() { // Wait after min execution period end before Exec sdkCtx := sdk.UnwrapSDKContext(ctx) sdkCtx = sdkCtx.WithHeaderInfo(header.Info{Time: sdkCtx.HeaderInfo().Time.Add(minExecutionPeriod)}) // MinExecutionPeriod is 5s - s.bankKeeper.EXPECT().Send(gomock.Any(), msgSend2).Return(nil, fmt.Errorf("error")) + s.bankKeeper.EXPECT().Send(gomock.Any(), msgSend2).Return(nil, errors.New("error")) _, err := s.groupKeeper.Exec(sdkCtx, &group.MsgExec{Executor: s.addrsStr[0], ProposalId: myProposalID}) s.bankKeeper.EXPECT().Send(gomock.Any(), msgSend2).Return(nil, nil) @@ -2902,7 +2902,7 @@ func (s *TestSuite) TestExecPrunedProposalsAndVotes() { } msgs := []sdk.Msg{msgSend1, msgSend2} - s.bankKeeper.EXPECT().Send(gomock.Any(), msgSend1).Return(nil, fmt.Errorf("error")) + s.bankKeeper.EXPECT().Send(gomock.Any(), msgSend1).Return(nil, errors.New("error")) return submitProposalAndVote(ctx, s, msgs, proposers, group.VOTE_OPTION_YES) }, @@ -2920,7 +2920,7 @@ func (s *TestSuite) TestExecPrunedProposalsAndVotes() { myProposalID := submitProposalAndVote(ctx, s, msgs, proposers, group.VOTE_OPTION_YES) - s.bankKeeper.EXPECT().Send(gomock.Any(), msgSend2).Return(nil, fmt.Errorf("error")) + s.bankKeeper.EXPECT().Send(gomock.Any(), msgSend2).Return(nil, errors.New("error")) // Wait for min execution period end sdkCtx := sdk.UnwrapSDKContext(ctx) diff --git a/x/group/msgs.go b/x/group/msgs.go index d9aad25d63b3..a9e36c207f48 100644 --- a/x/group/msgs.go +++ b/x/group/msgs.go @@ -2,6 +2,7 @@ package group import ( "github.com/cosmos/gogoproto/proto" + gogoprotoany "github.com/cosmos/gogoproto/types/any" "github.com/cosmos/cosmos-sdk/codec/types" sdk "github.com/cosmos/cosmos-sdk/types" @@ -27,9 +28,9 @@ var ( _ sdk.Msg = &MsgSubmitProposal{} _ sdk.Msg = &MsgCreateGroupPolicy{} - _ types.UnpackInterfacesMessage = MsgCreateGroupPolicy{} - _ types.UnpackInterfacesMessage = MsgUpdateGroupPolicyDecisionPolicy{} - _ types.UnpackInterfacesMessage = MsgCreateGroupWithPolicy{} + _ gogoprotoany.UnpackInterfacesMessage = MsgCreateGroupPolicy{} + _ gogoprotoany.UnpackInterfacesMessage = MsgUpdateGroupPolicyDecisionPolicy{} + _ gogoprotoany.UnpackInterfacesMessage = MsgCreateGroupWithPolicy{} ) // GetGroupID gets the group id of the MsgUpdateGroupMetadata. @@ -83,7 +84,7 @@ func (m *MsgCreateGroupWithPolicy) SetDecisionPolicy(decisionPolicy DecisionPoli } // UnpackInterfaces implements UnpackInterfacesMessage.UnpackInterfaces -func (m MsgCreateGroupWithPolicy) UnpackInterfaces(unpacker types.AnyUnpacker) error { +func (m MsgCreateGroupWithPolicy) UnpackInterfaces(unpacker gogoprotoany.AnyUnpacker) error { var decisionPolicy DecisionPolicy return unpacker.UnpackAny(m.DecisionPolicy, &decisionPolicy) } @@ -126,7 +127,7 @@ func (m *MsgUpdateGroupPolicyDecisionPolicy) GetDecisionPolicy() (DecisionPolicy } // UnpackInterfaces implements UnpackInterfacesMessage.UnpackInterfaces -func (m MsgUpdateGroupPolicyDecisionPolicy) UnpackInterfaces(unpacker types.AnyUnpacker) error { +func (m MsgUpdateGroupPolicyDecisionPolicy) UnpackInterfaces(unpacker gogoprotoany.AnyUnpacker) error { var decisionPolicy DecisionPolicy return unpacker.UnpackAny(m.DecisionPolicy, &decisionPolicy) } @@ -180,7 +181,7 @@ func (m *MsgCreateGroupPolicy) SetDecisionPolicy(decisionPolicy DecisionPolicy) } // UnpackInterfaces implements UnpackInterfacesMessage.UnpackInterfaces -func (m MsgCreateGroupPolicy) UnpackInterfaces(unpacker types.AnyUnpacker) error { +func (m MsgCreateGroupPolicy) UnpackInterfaces(unpacker gogoprotoany.AnyUnpacker) error { var decisionPolicy DecisionPolicy return unpacker.UnpackAny(m.DecisionPolicy, &decisionPolicy) } @@ -218,6 +219,6 @@ func (m MsgSubmitProposal) GetMsgs() ([]sdk.Msg, error) { } // UnpackInterfaces implements UnpackInterfacesMessage.UnpackInterfaces -func (m MsgSubmitProposal) UnpackInterfaces(unpacker types.AnyUnpacker) error { +func (m MsgSubmitProposal) UnpackInterfaces(unpacker gogoprotoany.AnyUnpacker) error { return tx.UnpackInterfaces(unpacker, m.Messages) } diff --git a/x/group/proposal.go b/x/group/proposal.go index a47ee5115c3b..642e8981a487 100644 --- a/x/group/proposal.go +++ b/x/group/proposal.go @@ -1,7 +1,8 @@ package group import ( - "github.com/cosmos/cosmos-sdk/codec/types" + gogoprotoany "github.com/cosmos/gogoproto/types/any" + sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/tx" ) @@ -22,6 +23,6 @@ func (p *Proposal) SetMsgs(msgs []sdk.Msg) error { } // UnpackInterfaces implements UnpackInterfacesMessage.UnpackInterfaces -func (p Proposal) UnpackInterfaces(unpacker types.AnyUnpacker) error { +func (p Proposal) UnpackInterfaces(unpacker gogoprotoany.AnyUnpacker) error { return tx.UnpackInterfaces(unpacker, p.Messages) } diff --git a/x/group/simulation/operations.go b/x/group/simulation/operations.go index 2a90842681dc..bab0939fddaf 100644 --- a/x/group/simulation/operations.go +++ b/x/group/simulation/operations.go @@ -8,11 +8,12 @@ import ( "sync/atomic" "time" + gogoprotoany "github.com/cosmos/gogoproto/types/any" + "cosmossdk.io/core/address" "cosmossdk.io/x/group" "cosmossdk.io/x/group/keeper" - "github.com/cosmos/cosmos-sdk/baseapp" "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/codec" cdctypes "github.com/cosmos/cosmos-sdk/codec/types" @@ -104,7 +105,7 @@ func WeightedOperations( registry cdctypes.InterfaceRegistry, appParams simtypes.AppParams, cdc codec.JSONCodec, txGen client.TxConfig, ak group.AccountKeeper, bk group.BankKeeper, k keeper.Keeper, - appCdc cdctypes.AnyUnpacker, + appCdc gogoprotoany.AnyUnpacker, ) simulation.WeightedOperations { var ( weightMsgCreateGroup int @@ -248,7 +249,7 @@ func SimulateMsgCreateGroup( bk group.BankKeeper, ) simtypes.Operation { return func( - r *rand.Rand, app *baseapp.BaseApp, ctx sdk.Context, accounts []simtypes.Account, chainID string, + r *rand.Rand, app simtypes.AppEntrypoint, ctx sdk.Context, accounts []simtypes.Account, chainID string, ) (simtypes.OperationMsg, []simtypes.FutureOperation, error) { acc, _ := simtypes.RandomAcc(r, accounts) account := ak.GetAccount(ctx, acc.Address) @@ -301,7 +302,7 @@ func SimulateMsgCreateGroupWithPolicy( bk group.BankKeeper, ) simtypes.Operation { return func( - r *rand.Rand, app *baseapp.BaseApp, ctx sdk.Context, accounts []simtypes.Account, chainID string, + r *rand.Rand, app simtypes.AppEntrypoint, ctx sdk.Context, accounts []simtypes.Account, chainID string, ) (simtypes.OperationMsg, []simtypes.FutureOperation, error) { acc, _ := simtypes.RandomAcc(r, accounts) account := ak.GetAccount(ctx, acc.Address) @@ -373,7 +374,7 @@ func SimulateMsgCreateGroupPolicy( s *SharedState, ) simtypes.Operation { return func( - r *rand.Rand, app *baseapp.BaseApp, sdkCtx sdk.Context, accounts []simtypes.Account, chainID string, + r *rand.Rand, app simtypes.AppEntrypoint, sdkCtx sdk.Context, accounts []simtypes.Account, chainID string, ) (simtypes.OperationMsg, []simtypes.FutureOperation, error) { groupInfo, acc, account, err := randomGroup(r, k, ak, sdkCtx, accounts, s) if err != nil { @@ -445,7 +446,7 @@ func SimulateMsgSubmitProposal( s *SharedState, ) simtypes.Operation { return func( - r *rand.Rand, app *baseapp.BaseApp, sdkCtx sdk.Context, accounts []simtypes.Account, chainID string, + r *rand.Rand, app simtypes.AppEntrypoint, sdkCtx sdk.Context, accounts []simtypes.Account, chainID string, ) (simtypes.OperationMsg, []simtypes.FutureOperation, error) { g, groupPolicy, _, _, err := randomGroupPolicy(r, k, ak, sdkCtx, accounts, s) if err != nil { @@ -532,7 +533,7 @@ func SimulateMsgUpdateGroupAdmin( s *SharedState, ) simtypes.Operation { return func( - r *rand.Rand, app *baseapp.BaseApp, sdkCtx sdk.Context, accounts []simtypes.Account, chainID string, + r *rand.Rand, app simtypes.AppEntrypoint, sdkCtx sdk.Context, accounts []simtypes.Account, chainID string, ) (simtypes.OperationMsg, []simtypes.FutureOperation, error) { groupInfo, acc, account, err := randomGroup(r, k, ak, sdkCtx, accounts, s) if err != nil { @@ -606,7 +607,7 @@ func SimulateMsgUpdateGroupMetadata( s *SharedState, ) simtypes.Operation { return func( - r *rand.Rand, app *baseapp.BaseApp, sdkCtx sdk.Context, accounts []simtypes.Account, chainID string, + r *rand.Rand, app simtypes.AppEntrypoint, sdkCtx sdk.Context, accounts []simtypes.Account, chainID string, ) (simtypes.OperationMsg, []simtypes.FutureOperation, error) { groupInfo, acc, account, err := randomGroup(r, k, ak, sdkCtx, accounts, s) if err != nil { @@ -667,7 +668,7 @@ func SimulateMsgUpdateGroupMembers( s *SharedState, ) simtypes.Operation { return func( - r *rand.Rand, app *baseapp.BaseApp, sdkCtx sdk.Context, accounts []simtypes.Account, chainID string, + r *rand.Rand, app simtypes.AppEntrypoint, sdkCtx sdk.Context, accounts []simtypes.Account, chainID string, ) (simtypes.OperationMsg, []simtypes.FutureOperation, error) { groupInfo, acc, account, err := randomGroup(r, k, ak, sdkCtx, accounts, s) if err != nil { @@ -758,7 +759,7 @@ func SimulateMsgUpdateGroupPolicyAdmin( s *SharedState, ) simtypes.Operation { return func( - r *rand.Rand, app *baseapp.BaseApp, sdkCtx sdk.Context, accounts []simtypes.Account, chainID string, + r *rand.Rand, app simtypes.AppEntrypoint, sdkCtx sdk.Context, accounts []simtypes.Account, chainID string, ) (simtypes.OperationMsg, []simtypes.FutureOperation, error) { _, groupPolicy, acc, account, err := randomGroupPolicy(r, k, ak, sdkCtx, accounts, s) if err != nil { @@ -832,7 +833,7 @@ func SimulateMsgUpdateGroupPolicyDecisionPolicy( s *SharedState, ) simtypes.Operation { return func( - r *rand.Rand, app *baseapp.BaseApp, sdkCtx sdk.Context, accounts []simtypes.Account, chainID string, + r *rand.Rand, app simtypes.AppEntrypoint, sdkCtx sdk.Context, accounts []simtypes.Account, chainID string, ) (simtypes.OperationMsg, []simtypes.FutureOperation, error) { _, groupPolicy, acc, account, err := randomGroupPolicy(r, k, ak, sdkCtx, accounts, s) if err != nil { @@ -906,7 +907,7 @@ func SimulateMsgUpdateGroupPolicyMetadata( s *SharedState, ) simtypes.Operation { return func( - r *rand.Rand, app *baseapp.BaseApp, sdkCtx sdk.Context, accounts []simtypes.Account, chainID string, + r *rand.Rand, app simtypes.AppEntrypoint, sdkCtx sdk.Context, accounts []simtypes.Account, chainID string, ) (simtypes.OperationMsg, []simtypes.FutureOperation, error) { _, groupPolicy, acc, account, err := randomGroupPolicy(r, k, ak, sdkCtx, accounts, s) if err != nil { @@ -967,7 +968,7 @@ func SimulateMsgWithdrawProposal( s *SharedState, ) simtypes.Operation { return func( - r *rand.Rand, app *baseapp.BaseApp, sdkCtx sdk.Context, accounts []simtypes.Account, chainID string, + r *rand.Rand, app simtypes.AppEntrypoint, sdkCtx sdk.Context, accounts []simtypes.Account, chainID string, ) (simtypes.OperationMsg, []simtypes.FutureOperation, error) { g, groupPolicy, _, _, err := randomGroupPolicy(r, k, ak, sdkCtx, accounts, s) if err != nil { @@ -1083,7 +1084,7 @@ func SimulateMsgVote( s *SharedState, ) simtypes.Operation { return func( - r *rand.Rand, app *baseapp.BaseApp, sdkCtx sdk.Context, accounts []simtypes.Account, chainID string, + r *rand.Rand, app simtypes.AppEntrypoint, sdkCtx sdk.Context, accounts []simtypes.Account, chainID string, ) (simtypes.OperationMsg, []simtypes.FutureOperation, error) { g, groupPolicy, _, _, err := randomGroupPolicy(r, k, ak, sdkCtx, accounts, s) if err != nil { @@ -1196,7 +1197,7 @@ func SimulateMsgExec( s *SharedState, ) simtypes.Operation { return func( - r *rand.Rand, app *baseapp.BaseApp, sdkCtx sdk.Context, accounts []simtypes.Account, chainID string, + r *rand.Rand, app simtypes.AppEntrypoint, sdkCtx sdk.Context, accounts []simtypes.Account, chainID string, ) (simtypes.OperationMsg, []simtypes.FutureOperation, error) { _, groupPolicy, acc, account, err := randomGroupPolicy(r, k, ak, sdkCtx, accounts, s) if err != nil { @@ -1281,7 +1282,7 @@ func SimulateMsgLeaveGroup( s *SharedState, ) simtypes.Operation { return func( - r *rand.Rand, app *baseapp.BaseApp, sdkCtx sdk.Context, accounts []simtypes.Account, chainID string, + r *rand.Rand, app simtypes.AppEntrypoint, sdkCtx sdk.Context, accounts []simtypes.Account, chainID string, ) (simtypes.OperationMsg, []simtypes.FutureOperation, error) { groupInfo, policyInfo, _, _, err := randomGroupPolicy(r, k, ak, sdkCtx, accounts, s) if err != nil { diff --git a/x/group/types.go b/x/group/types.go index 4a8b2cd7d564..d91d4fd89704 100644 --- a/x/group/types.go +++ b/x/group/types.go @@ -5,6 +5,7 @@ import ( "time" "github.com/cosmos/gogoproto/proto" + gogoprotoany "github.com/cosmos/gogoproto/types/any" "cosmossdk.io/core/address" errorsmod "cosmossdk.io/errors" @@ -286,7 +287,7 @@ func (g GroupPolicyInfo) GetDecisionPolicy() (DecisionPolicy, error) { } // UnpackInterfaces implements UnpackInterfacesMessage.UnpackInterfaces -func (g GroupPolicyInfo) UnpackInterfaces(unpacker codectypes.AnyUnpacker) error { +func (g GroupPolicyInfo) UnpackInterfaces(unpacker gogoprotoany.AnyUnpacker) error { var decisionPolicy DecisionPolicy return unpacker.UnpackAny(g.DecisionPolicy, &decisionPolicy) } @@ -458,16 +459,16 @@ func (v Vote) ValidateBasic() error { } // UnpackInterfaces implements UnpackInterfacesMessage.UnpackInterfaces -func (q QueryGroupPoliciesByGroupResponse) UnpackInterfaces(unpacker codectypes.AnyUnpacker) error { +func (q QueryGroupPoliciesByGroupResponse) UnpackInterfaces(unpacker gogoprotoany.AnyUnpacker) error { return unpackGroupPolicies(unpacker, q.GroupPolicies) } // UnpackInterfaces implements UnpackInterfacesMessage.UnpackInterfaces -func (q QueryGroupPoliciesByAdminResponse) UnpackInterfaces(unpacker codectypes.AnyUnpacker) error { +func (q QueryGroupPoliciesByAdminResponse) UnpackInterfaces(unpacker gogoprotoany.AnyUnpacker) error { return unpackGroupPolicies(unpacker, q.GroupPolicies) } -func unpackGroupPolicies(unpacker codectypes.AnyUnpacker, accs []*GroupPolicyInfo) error { +func unpackGroupPolicies(unpacker gogoprotoany.AnyUnpacker, accs []*GroupPolicyInfo) error { for _, g := range accs { err := g.UnpackInterfaces(unpacker) if err != nil { diff --git a/x/mint/README.md b/x/mint/README.md index aac6d52ff686..849164f04131 100644 --- a/x/mint/README.md +++ b/x/mint/README.md @@ -8,6 +8,10 @@ sidebar_position: 1 * [Concepts](#concepts) * [The Minting Mechanism](#the-minting-mechanism) + * [Provisions](#provisions) + * [Relation to Inflation](#relation-to-inflation) + * [Usage per Block](#usage-per-block) + * [Example](#example) * [State](#state) * [Minter](#minter) * [Params](#params) @@ -51,6 +55,49 @@ It can be broken down in the following way: * If the actual percentage of bonded tokens is above the goal %-bonded the inflation rate will decrease until a minimum value is reached +### Provisions + +Provisions are the number of tokens generated and distributed in each block. They are directly related to the inflation rate and the current total supply of tokens. The amount of provisions generated per block is calculated based on the annual provisions, which are determined by the inflation rate and the total supply of tokens. + +#### Relation to Inflation + +The inflation rate determines the percentage of the total supply of tokens that will be added as provisions over a year. These annual provisions are divided by the number of blocks in a year to obtain the provisions per block. + +#### Usage per Block + +Each block uses a fraction of the annual provisions, calculated as: + +```plaintext +Provisions per block = Annual provisions / Number of blocks per year +``` + +These provisions are distributed to validators and delegators as rewards for their participation in the network. + + +#### Example + +For example, if the total supply of tokens is 1,000,000 and the inflation rate is 10%, the annual provisions would be: + +Annual provisions = 1,000,000 * 0.10 = 100,000 tokens + +If there are 3,153,600 blocks per year (one block every 10 seconds), the provisions per block would be: +Provisions per block = 100,000 / 3,153,600 ≈ 0.0317 tokens per block. + +These provisions are then distributed to validators and delegators as rewards. + +```mermaid +flowchart TD + A[Start] --> B[Get Total Supply] + B --> C[Get Inflation Rate] + C --> D[Calculate Annual Provisions] + D --> E[Calculate Provisions per Block] + E --> F[Distribute Provisions to Validators and Delegators] + + subgraph Calculation + D --> |Annual Provisions = Total Supply * Inflation Rate| D + E --> |Provisions per Block = Annual Provisions / Number of Blocks per Year| E + end +``` ## State diff --git a/x/mint/go.mod b/x/mint/go.mod index b881ce826f23..f97f79aa0727 100644 --- a/x/mint/go.mod +++ b/x/mint/go.mod @@ -6,7 +6,8 @@ require ( cosmossdk.io/api v0.7.5 cosmossdk.io/collections v0.4.0 cosmossdk.io/core v0.12.1-0.20231114100755-569e3ff6a0d7 - cosmossdk.io/depinject v1.0.0-alpha.4 + cosmossdk.io/core/testing v0.0.0-00010101000000-000000000000 + cosmossdk.io/depinject v1.0.0 cosmossdk.io/errors v1.0.1 cosmossdk.io/log v1.3.1 cosmossdk.io/math v1.3.0 @@ -14,7 +15,7 @@ require ( cosmossdk.io/x/epochs v0.0.0-20240522060652-a1ae4c3e0337 github.com/cockroachdb/tokenbucket v0.0.0-20230807174530-cc333fc44b06 // indirect github.com/cosmos/cosmos-proto v1.0.0-beta.5 - github.com/cosmos/cosmos-sdk v0.51.0 + github.com/cosmos/cosmos-sdk v0.53.0 github.com/cosmos/gogoproto v1.5.0 github.com/golang/mock v1.6.0 github.com/golang/protobuf v1.5.4 @@ -51,7 +52,7 @@ require ( github.com/cosmos/cosmos-db v1.0.2 // indirect github.com/cosmos/go-bip39 v1.0.0 // indirect github.com/cosmos/gogogateway v1.2.0 // indirect - github.com/cosmos/iavl v1.2.0 // indirect + github.com/cosmos/iavl v1.2.1-0.20240725141113-7adc688cf179 // indirect github.com/cosmos/ics23/go v0.10.0 // indirect github.com/cosmos/ledger-cosmos-go v0.13.3 // indirect github.com/danieljoos/wincred v1.2.1 // indirect @@ -159,7 +160,6 @@ require ( require ( buf.build/gen/go/cometbft/cometbft/protocolbuffers/go v1.34.2-20240701160653-fedbb9acfd2f.2 // indirect - cosmossdk.io/core/testing v0.0.0-00010101000000-000000000000 // indirect cosmossdk.io/schema v0.1.1 // indirect cosmossdk.io/x/consensus v0.0.0-00010101000000-000000000000 // indirect github.com/cometbft/cometbft/api v1.0.0-rc.1 // indirect @@ -181,8 +181,6 @@ replace ( cosmossdk.io/api => ../../api cosmossdk.io/core => ../../core cosmossdk.io/core/testing => ../../core/testing - cosmossdk.io/depinject => ../../depinject - cosmossdk.io/log => ../../log cosmossdk.io/x/accounts => ../accounts cosmossdk.io/x/auth => ../auth cosmossdk.io/x/bank => ../bank diff --git a/x/mint/go.sum b/x/mint/go.sum index e79db92d532d..079d8d65f322 100644 --- a/x/mint/go.sum +++ b/x/mint/go.sum @@ -6,8 +6,12 @@ cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMT cloud.google.com/go v0.34.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= cosmossdk.io/collections v0.4.0 h1:PFmwj2W8szgpD5nOd8GWH6AbYNi1f2J6akWXJ7P5t9s= cosmossdk.io/collections v0.4.0/go.mod h1:oa5lUING2dP+gdDquow+QjlF45eL1t4TJDypgGd+tv0= +cosmossdk.io/depinject v1.0.0 h1:dQaTu6+O6askNXO06+jyeUAnF2/ssKwrrszP9t5q050= +cosmossdk.io/depinject v1.0.0/go.mod h1:zxK/h3HgHoA/eJVtiSsoaRaRA2D5U4cJ5thIG4ssbB8= cosmossdk.io/errors v1.0.1 h1:bzu+Kcr0kS/1DuPBtUFdWjzLqyUuCiyHjyJB6srBV/0= cosmossdk.io/errors v1.0.1/go.mod h1:MeelVSZThMi4bEakzhhhE/CKqVv3nOJDA25bIqRDu/U= +cosmossdk.io/log v1.3.1 h1:UZx8nWIkfbbNEWusZqzAx3ZGvu54TZacWib3EzUYmGI= +cosmossdk.io/log v1.3.1/go.mod h1:2/dIomt8mKdk6vl3OWJcPk2be3pGOS8OQaLUM/3/tCM= cosmossdk.io/math v1.3.0 h1:RC+jryuKeytIiictDslBP9i1fhkVm6ZDmZEoNP316zE= cosmossdk.io/math v1.3.0/go.mod h1:vnRTxewy+M7BtXBNFybkuhSH4WfedVAAnERHgVFhp3k= cosmossdk.io/schema v0.1.1 h1:I0M6pgI7R10nq+/HCQfbO6BsGBZA8sQy+duR1Y3aKcA= @@ -113,8 +117,8 @@ github.com/cosmos/gogogateway v1.2.0/go.mod h1:iQpLkGWxYcnCdz5iAdLcRBSw3h7NXeOkZ github.com/cosmos/gogoproto v1.4.2/go.mod h1:cLxOsn1ljAHSV527CHOtaIP91kK6cCrZETRBrkzItWU= github.com/cosmos/gogoproto v1.5.0 h1:SDVwzEqZDDBoslaeZg+dGE55hdzHfgUA40pEanMh52o= github.com/cosmos/gogoproto v1.5.0/go.mod h1:iUM31aofn3ymidYG6bUR5ZFrk+Om8p5s754eMUcyp8I= -github.com/cosmos/iavl v1.2.0 h1:kVxTmjTh4k0Dh1VNL046v6BXqKziqMDzxo93oh3kOfM= -github.com/cosmos/iavl v1.2.0/go.mod h1:HidWWLVAtODJqFD6Hbne2Y0q3SdxByJepHUOeoH4LiI= +github.com/cosmos/iavl v1.2.1-0.20240725141113-7adc688cf179 h1:wmwDn7V3RodN9auB3FooSQxs46nHVE3u0mb87TJkZFE= +github.com/cosmos/iavl v1.2.1-0.20240725141113-7adc688cf179/go.mod h1:GiM43q0pB+uG53mLxLDzimxM9l/5N9UuSY3/D0huuVw= github.com/cosmos/ics23/go v0.10.0 h1:iXqLLgp2Lp+EdpIuwXTYIQU+AiHj9mOC2X9ab++bZDM= github.com/cosmos/ics23/go v0.10.0/go.mod h1:ZfJSmng/TBNTBkFemHHHj5YY7VAU/MBU980F4VU1NG0= github.com/cosmos/ledger-cosmos-go v0.13.3 h1:7ehuBGuyIytsXbd4MP43mLeoN2LTOEnk5nvue4rK+yM= diff --git a/x/mint/keeper/keeper.go b/x/mint/keeper/keeper.go index 3f31a3ff3252..14ee19cde865 100644 --- a/x/mint/keeper/keeper.go +++ b/x/mint/keeper/keeper.go @@ -7,7 +7,6 @@ import ( "cosmossdk.io/collections" "cosmossdk.io/core/appmodule" "cosmossdk.io/core/event" - "cosmossdk.io/log" "cosmossdk.io/math" "cosmossdk.io/x/mint/types" @@ -23,7 +22,6 @@ type Keeper struct { cdc codec.BinaryCodec stakingKeeper types.StakingKeeper bankKeeper types.BankKeeper - logger log.Logger feeCollectorName string // the address capable of executing a MsgUpdateParams message. Typically, this // should be the x/gov module account. @@ -55,7 +53,6 @@ func NewKeeper( cdc: cdc, stakingKeeper: sk, bankKeeper: bk, - logger: env.Logger, feeCollectorName: feeCollectorName, authority: authority, Params: collections.NewItem(sb, types.ParamsKey, "params", codec.CollValue[types.Params](cdc)), @@ -141,7 +138,7 @@ func (k Keeper) DefaultMintFn(ic types.InflationCalculationFn) types.MintFn { // calculate the difference between maxSupply and totalSupply diff := maxSupply.Sub(totalSupply) if diff.LTE(math.ZeroInt()) { - k.logger.Info("max supply reached, no new tokens will be minted") + k.Environment.Logger.Info("max supply reached, no new tokens will be minted") return nil } diff --git a/x/mint/keeper/keeper_test.go b/x/mint/keeper/keeper_test.go index d3d0281c7563..012917777901 100644 --- a/x/mint/keeper/keeper_test.go +++ b/x/mint/keeper/keeper_test.go @@ -8,7 +8,7 @@ import ( "github.com/stretchr/testify/suite" "cosmossdk.io/core/appmodule" - "cosmossdk.io/log" + coretesting "cosmossdk.io/core/testing" "cosmossdk.io/math" storetypes "cosmossdk.io/store/types" authtypes "cosmossdk.io/x/auth/types" @@ -44,7 +44,7 @@ func (s *KeeperTestSuite) SetupTest() { encCfg := moduletestutil.MakeTestEncodingConfig(codectestutil.CodecOptions{}, mint.AppModule{}) key := storetypes.NewKVStoreKey(types.StoreKey) storeService := runtime.NewKVStoreService(key) - env := runtime.NewEnvironment(storeService, log.NewNopLogger()) + env := runtime.NewEnvironment(storeService, coretesting.NewNopLogger()) testCtx := testutil.DefaultContextWithDB(s.T(), key, storetypes.NewTransientStoreKey("transient_test")) s.ctx = testCtx.Ctx diff --git a/x/mint/simulation/proposals.go b/x/mint/simulation/proposals.go index be6320ac8326..570bf203efcc 100644 --- a/x/mint/simulation/proposals.go +++ b/x/mint/simulation/proposals.go @@ -1,6 +1,7 @@ package simulation import ( + "context" "math/rand" coreaddress "cosmossdk.io/core/address" @@ -23,7 +24,7 @@ const ( // ProposalMsgs defines the module weighted proposals' contents func ProposalMsgs() []simtypes.WeightedProposalMsg { return []simtypes.WeightedProposalMsg{ - simulation.NewWeightedProposalMsg( + simulation.NewWeightedProposalMsgX( OpWeightMsgUpdateParams, DefaultWeightMsgUpdateParams, SimulateMsgUpdateParams, @@ -32,7 +33,7 @@ func ProposalMsgs() []simtypes.WeightedProposalMsg { } // SimulateMsgUpdateParams returns a random MsgUpdateParams -func SimulateMsgUpdateParams(r *rand.Rand, _ []simtypes.Account, ac coreaddress.Codec) (sdk.Msg, error) { +func SimulateMsgUpdateParams(_ context.Context, r *rand.Rand, _ []simtypes.Account, ac coreaddress.Codec) (sdk.Msg, error) { // use the default gov module account address as authority var authority sdk.AccAddress = address.Module("gov") diff --git a/x/mint/simulation/proposals_test.go b/x/mint/simulation/proposals_test.go index 767bbfad1508..abc470a76d81 100644 --- a/x/mint/simulation/proposals_test.go +++ b/x/mint/simulation/proposals_test.go @@ -1,6 +1,7 @@ package simulation_test import ( + "context" "math/rand" "testing" @@ -33,7 +34,7 @@ func TestProposalMsgs(t *testing.T) { assert.Equal(t, simulation.OpWeightMsgUpdateParams, w0.AppParamsKey()) assert.Equal(t, simulation.DefaultWeightMsgUpdateParams, w0.DefaultWeight()) - msg, err := w0.MsgSimulatorFn()(r, accounts, ac) + msg, err := w0.MsgSimulatorFn()(context.Background(), r, accounts, ac) assert.NilError(t, err) msgUpdateParams, ok := msg.(*types.MsgUpdateParams) assert.Assert(t, ok) diff --git a/x/nft/go.mod b/x/nft/go.mod index 7d7d4bde2bad..e4884dbfa329 100644 --- a/x/nft/go.mod +++ b/x/nft/go.mod @@ -5,13 +5,13 @@ go 1.22.2 require ( cosmossdk.io/api v0.7.5 cosmossdk.io/core v0.12.1-0.20231114100755-569e3ff6a0d7 - cosmossdk.io/depinject v1.0.0-alpha.4 + cosmossdk.io/depinject v1.0.0 cosmossdk.io/errors v1.0.1 cosmossdk.io/log v1.3.1 cosmossdk.io/math v1.3.0 cosmossdk.io/store v1.1.1-0.20240418092142-896cdf1971bc github.com/cosmos/cosmos-proto v1.0.0-beta.5 - github.com/cosmos/cosmos-sdk v0.51.0 + github.com/cosmos/cosmos-sdk v0.53.0 github.com/cosmos/gogoproto v1.5.0 github.com/golang/mock v1.6.0 github.com/golang/protobuf v1.5.4 @@ -25,7 +25,6 @@ require ( buf.build/gen/go/cometbft/cometbft/protocolbuffers/go v1.34.2-20240701160653-fedbb9acfd2f.2 // indirect buf.build/gen/go/cosmos/gogo-proto/protocolbuffers/go v1.34.2-20240130113600-88ef6483f90f.2 // indirect cosmossdk.io/collections v0.4.0 // indirect - cosmossdk.io/core/testing v0.0.0-00010101000000-000000000000 // indirect cosmossdk.io/schema v0.1.1 // indirect cosmossdk.io/x/auth v0.0.0-00010101000000-000000000000 // indirect cosmossdk.io/x/bank v0.0.0-20240226161501-23359a0b6d91 // indirect @@ -55,7 +54,7 @@ require ( github.com/cosmos/crypto v0.1.2 // indirect github.com/cosmos/go-bip39 v1.0.0 // indirect github.com/cosmos/gogogateway v1.2.0 // indirect - github.com/cosmos/iavl v1.2.0 // indirect + github.com/cosmos/iavl v1.2.1-0.20240725141113-7adc688cf179 // indirect github.com/cosmos/ics23/go v0.10.0 // indirect github.com/cosmos/ledger-cosmos-go v0.13.3 // indirect github.com/danieljoos/wincred v1.2.1 // indirect @@ -177,8 +176,6 @@ replace ( cosmossdk.io/api => ../../api cosmossdk.io/core => ../../core cosmossdk.io/core/testing => ../../core/testing - cosmossdk.io/depinject => ../../depinject - cosmossdk.io/log => ../../log cosmossdk.io/x/accounts => ../accounts cosmossdk.io/x/auth => ../auth cosmossdk.io/x/bank => ../bank diff --git a/x/nft/go.sum b/x/nft/go.sum index c2479081cac7..81d16c68890c 100644 --- a/x/nft/go.sum +++ b/x/nft/go.sum @@ -6,8 +6,12 @@ cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMT cloud.google.com/go v0.34.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= cosmossdk.io/collections v0.4.0 h1:PFmwj2W8szgpD5nOd8GWH6AbYNi1f2J6akWXJ7P5t9s= cosmossdk.io/collections v0.4.0/go.mod h1:oa5lUING2dP+gdDquow+QjlF45eL1t4TJDypgGd+tv0= +cosmossdk.io/depinject v1.0.0 h1:dQaTu6+O6askNXO06+jyeUAnF2/ssKwrrszP9t5q050= +cosmossdk.io/depinject v1.0.0/go.mod h1:zxK/h3HgHoA/eJVtiSsoaRaRA2D5U4cJ5thIG4ssbB8= cosmossdk.io/errors v1.0.1 h1:bzu+Kcr0kS/1DuPBtUFdWjzLqyUuCiyHjyJB6srBV/0= cosmossdk.io/errors v1.0.1/go.mod h1:MeelVSZThMi4bEakzhhhE/CKqVv3nOJDA25bIqRDu/U= +cosmossdk.io/log v1.3.1 h1:UZx8nWIkfbbNEWusZqzAx3ZGvu54TZacWib3EzUYmGI= +cosmossdk.io/log v1.3.1/go.mod h1:2/dIomt8mKdk6vl3OWJcPk2be3pGOS8OQaLUM/3/tCM= cosmossdk.io/math v1.3.0 h1:RC+jryuKeytIiictDslBP9i1fhkVm6ZDmZEoNP316zE= cosmossdk.io/math v1.3.0/go.mod h1:vnRTxewy+M7BtXBNFybkuhSH4WfedVAAnERHgVFhp3k= cosmossdk.io/schema v0.1.1 h1:I0M6pgI7R10nq+/HCQfbO6BsGBZA8sQy+duR1Y3aKcA= @@ -111,8 +115,8 @@ github.com/cosmos/gogogateway v1.2.0/go.mod h1:iQpLkGWxYcnCdz5iAdLcRBSw3h7NXeOkZ github.com/cosmos/gogoproto v1.4.2/go.mod h1:cLxOsn1ljAHSV527CHOtaIP91kK6cCrZETRBrkzItWU= github.com/cosmos/gogoproto v1.5.0 h1:SDVwzEqZDDBoslaeZg+dGE55hdzHfgUA40pEanMh52o= github.com/cosmos/gogoproto v1.5.0/go.mod h1:iUM31aofn3ymidYG6bUR5ZFrk+Om8p5s754eMUcyp8I= -github.com/cosmos/iavl v1.2.0 h1:kVxTmjTh4k0Dh1VNL046v6BXqKziqMDzxo93oh3kOfM= -github.com/cosmos/iavl v1.2.0/go.mod h1:HidWWLVAtODJqFD6Hbne2Y0q3SdxByJepHUOeoH4LiI= +github.com/cosmos/iavl v1.2.1-0.20240725141113-7adc688cf179 h1:wmwDn7V3RodN9auB3FooSQxs46nHVE3u0mb87TJkZFE= +github.com/cosmos/iavl v1.2.1-0.20240725141113-7adc688cf179/go.mod h1:GiM43q0pB+uG53mLxLDzimxM9l/5N9UuSY3/D0huuVw= github.com/cosmos/ics23/go v0.10.0 h1:iXqLLgp2Lp+EdpIuwXTYIQU+AiHj9mOC2X9ab++bZDM= github.com/cosmos/ics23/go v0.10.0/go.mod h1:ZfJSmng/TBNTBkFemHHHj5YY7VAU/MBU980F4VU1NG0= github.com/cosmos/ledger-cosmos-go v0.13.3 h1:7ehuBGuyIytsXbd4MP43mLeoN2LTOEnk5nvue4rK+yM= diff --git a/x/nft/proto/cosmos/nft/v1beta1/query.proto b/x/nft/proto/cosmos/nft/v1beta1/query.proto index e0646c61fe38..92df51459e41 100644 --- a/x/nft/proto/cosmos/nft/v1beta1/query.proto +++ b/x/nft/proto/cosmos/nft/v1beta1/query.proto @@ -15,7 +15,7 @@ service Query { option (google.api.http).get = "/cosmos/nft/v1beta1/balance/{owner}/{class_id}"; } - // BalancebyQueryString queries the number of NFTs of a given class owned by the owner, same as balanceOf in ERC721 + // BalanceByQueryString queries the number of NFTs of a given class owned by the owner, same as balanceOf in ERC721 rpc BalanceByQueryString(QueryBalanceByQueryStringRequest) returns (QueryBalanceByQueryStringResponse) { option (google.api.http).get = "/cosmos/nft/v1beta1/balance"; option (cosmos_proto.method_added_in) = "nft v0.1.1"; diff --git a/x/nft/query.pb.go b/x/nft/query.pb.go index c815738d61ae..7b9138320b12 100644 --- a/x/nft/query.pb.go +++ b/x/nft/query.pb.go @@ -1333,7 +1333,7 @@ const _ = grpc.SupportPackageIsVersion4 type QueryClient interface { // Balance queries the number of NFTs of a given class owned by the owner, same as balanceOf in ERC721 Balance(ctx context.Context, in *QueryBalanceRequest, opts ...grpc.CallOption) (*QueryBalanceResponse, error) - // BalancebyQueryString queries the number of NFTs of a given class owned by the owner, same as balanceOf in ERC721 + // BalanceByQueryString queries the number of NFTs of a given class owned by the owner, same as balanceOf in ERC721 BalanceByQueryString(ctx context.Context, in *QueryBalanceByQueryStringRequest, opts ...grpc.CallOption) (*QueryBalanceByQueryStringResponse, error) // Owner queries the owner of the NFT based on its class and id, same as ownerOf in ERC721 Owner(ctx context.Context, in *QueryOwnerRequest, opts ...grpc.CallOption) (*QueryOwnerResponse, error) @@ -1478,7 +1478,7 @@ func (c *queryClient) Classes(ctx context.Context, in *QueryClassesRequest, opts type QueryServer interface { // Balance queries the number of NFTs of a given class owned by the owner, same as balanceOf in ERC721 Balance(context.Context, *QueryBalanceRequest) (*QueryBalanceResponse, error) - // BalancebyQueryString queries the number of NFTs of a given class owned by the owner, same as balanceOf in ERC721 + // BalanceByQueryString queries the number of NFTs of a given class owned by the owner, same as balanceOf in ERC721 BalanceByQueryString(context.Context, *QueryBalanceByQueryStringRequest) (*QueryBalanceByQueryStringResponse, error) // Owner queries the owner of the NFT based on its class and id, same as ownerOf in ERC721 Owner(context.Context, *QueryOwnerRequest) (*QueryOwnerResponse, error) diff --git a/x/nft/simulation/operations.go b/x/nft/simulation/operations.go index 5128d8147749..f13a47c49e84 100644 --- a/x/nft/simulation/operations.go +++ b/x/nft/simulation/operations.go @@ -6,7 +6,6 @@ import ( "cosmossdk.io/x/nft" "cosmossdk.io/x/nft/keeper" - "github.com/cosmos/cosmos-sdk/baseapp" "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/codec" cdctypes "github.com/cosmos/cosmos-sdk/codec/types" @@ -61,7 +60,7 @@ func SimulateMsgSend( k keeper.Keeper, ) simtypes.Operation { return func( - r *rand.Rand, app *baseapp.BaseApp, ctx sdk.Context, accs []simtypes.Account, chainID string, + r *rand.Rand, app simtypes.AppEntrypoint, ctx sdk.Context, accs []simtypes.Account, chainID string, ) (simtypes.OperationMsg, []simtypes.FutureOperation, error) { sender, _ := simtypes.RandomAcc(r, accs) receiver, _ := simtypes.RandomAcc(r, accs) diff --git a/x/params/go.mod b/x/params/go.mod index 489b27d3870f..05f1c5dd0cdd 100644 --- a/x/params/go.mod +++ b/x/params/go.mod @@ -5,7 +5,7 @@ go 1.22.2 require ( cosmossdk.io/api v0.7.5 cosmossdk.io/core v0.12.1-0.20231114100755-569e3ff6a0d7 - cosmossdk.io/depinject v1.0.0-alpha.4 + cosmossdk.io/depinject v1.0.0 cosmossdk.io/errors v1.0.1 cosmossdk.io/log v1.3.1 cosmossdk.io/math v1.3.0 @@ -14,7 +14,7 @@ require ( github.com/cometbft/cometbft/api v1.0.0-rc.1 github.com/cosmos/cosmos-db v1.0.2 github.com/cosmos/cosmos-proto v1.0.0-beta.5 - github.com/cosmos/cosmos-sdk v0.51.0 + github.com/cosmos/cosmos-sdk v0.53.0 github.com/cosmos/gogoproto v1.5.0 github.com/golang/mock v1.6.0 github.com/golang/protobuf v1.5.4 @@ -29,7 +29,6 @@ require ( buf.build/gen/go/cometbft/cometbft/protocolbuffers/go v1.34.2-20240701160653-fedbb9acfd2f.2 // indirect buf.build/gen/go/cosmos/gogo-proto/protocolbuffers/go v1.34.2-20240130113600-88ef6483f90f.2 // indirect cosmossdk.io/collections v0.4.0 // indirect - cosmossdk.io/core/testing v0.0.0-00010101000000-000000000000 // indirect cosmossdk.io/schema v0.1.1 // indirect cosmossdk.io/x/auth v0.0.0-00010101000000-000000000000 // indirect cosmossdk.io/x/bank v0.0.0-20240226161501-23359a0b6d91 // indirect @@ -57,7 +56,7 @@ require ( github.com/cosmos/crypto v0.1.2 // indirect github.com/cosmos/go-bip39 v1.0.0 // indirect github.com/cosmos/gogogateway v1.2.0 // indirect - github.com/cosmos/iavl v1.2.0 // indirect + github.com/cosmos/iavl v1.2.1-0.20240725141113-7adc688cf179 // indirect github.com/cosmos/ics23/go v0.10.0 // indirect github.com/cosmos/ledger-cosmos-go v0.13.3 // indirect github.com/danieljoos/wincred v1.2.1 // indirect @@ -178,8 +177,6 @@ replace ( cosmossdk.io/api => ../../api cosmossdk.io/core => ../../core cosmossdk.io/core/testing => ../../core/testing - cosmossdk.io/depinject => ../../depinject - cosmossdk.io/log => ../../log cosmossdk.io/x/accounts => ../accounts cosmossdk.io/x/auth => ../auth cosmossdk.io/x/bank => ../bank diff --git a/x/params/go.sum b/x/params/go.sum index c2479081cac7..81d16c68890c 100644 --- a/x/params/go.sum +++ b/x/params/go.sum @@ -6,8 +6,12 @@ cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMT cloud.google.com/go v0.34.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= cosmossdk.io/collections v0.4.0 h1:PFmwj2W8szgpD5nOd8GWH6AbYNi1f2J6akWXJ7P5t9s= cosmossdk.io/collections v0.4.0/go.mod h1:oa5lUING2dP+gdDquow+QjlF45eL1t4TJDypgGd+tv0= +cosmossdk.io/depinject v1.0.0 h1:dQaTu6+O6askNXO06+jyeUAnF2/ssKwrrszP9t5q050= +cosmossdk.io/depinject v1.0.0/go.mod h1:zxK/h3HgHoA/eJVtiSsoaRaRA2D5U4cJ5thIG4ssbB8= cosmossdk.io/errors v1.0.1 h1:bzu+Kcr0kS/1DuPBtUFdWjzLqyUuCiyHjyJB6srBV/0= cosmossdk.io/errors v1.0.1/go.mod h1:MeelVSZThMi4bEakzhhhE/CKqVv3nOJDA25bIqRDu/U= +cosmossdk.io/log v1.3.1 h1:UZx8nWIkfbbNEWusZqzAx3ZGvu54TZacWib3EzUYmGI= +cosmossdk.io/log v1.3.1/go.mod h1:2/dIomt8mKdk6vl3OWJcPk2be3pGOS8OQaLUM/3/tCM= cosmossdk.io/math v1.3.0 h1:RC+jryuKeytIiictDslBP9i1fhkVm6ZDmZEoNP316zE= cosmossdk.io/math v1.3.0/go.mod h1:vnRTxewy+M7BtXBNFybkuhSH4WfedVAAnERHgVFhp3k= cosmossdk.io/schema v0.1.1 h1:I0M6pgI7R10nq+/HCQfbO6BsGBZA8sQy+duR1Y3aKcA= @@ -111,8 +115,8 @@ github.com/cosmos/gogogateway v1.2.0/go.mod h1:iQpLkGWxYcnCdz5iAdLcRBSw3h7NXeOkZ github.com/cosmos/gogoproto v1.4.2/go.mod h1:cLxOsn1ljAHSV527CHOtaIP91kK6cCrZETRBrkzItWU= github.com/cosmos/gogoproto v1.5.0 h1:SDVwzEqZDDBoslaeZg+dGE55hdzHfgUA40pEanMh52o= github.com/cosmos/gogoproto v1.5.0/go.mod h1:iUM31aofn3ymidYG6bUR5ZFrk+Om8p5s754eMUcyp8I= -github.com/cosmos/iavl v1.2.0 h1:kVxTmjTh4k0Dh1VNL046v6BXqKziqMDzxo93oh3kOfM= -github.com/cosmos/iavl v1.2.0/go.mod h1:HidWWLVAtODJqFD6Hbne2Y0q3SdxByJepHUOeoH4LiI= +github.com/cosmos/iavl v1.2.1-0.20240725141113-7adc688cf179 h1:wmwDn7V3RodN9auB3FooSQxs46nHVE3u0mb87TJkZFE= +github.com/cosmos/iavl v1.2.1-0.20240725141113-7adc688cf179/go.mod h1:GiM43q0pB+uG53mLxLDzimxM9l/5N9UuSY3/D0huuVw= github.com/cosmos/ics23/go v0.10.0 h1:iXqLLgp2Lp+EdpIuwXTYIQU+AiHj9mOC2X9ab++bZDM= github.com/cosmos/ics23/go v0.10.0/go.mod h1:ZfJSmng/TBNTBkFemHHHj5YY7VAU/MBU980F4VU1NG0= github.com/cosmos/ledger-cosmos-go v0.13.3 h1:7ehuBGuyIytsXbd4MP43mLeoN2LTOEnk5nvue4rK+yM= diff --git a/x/protocolpool/CHANGELOG.md b/x/protocolpool/CHANGELOG.md new file mode 100644 index 000000000000..71b686118198 --- /dev/null +++ b/x/protocolpool/CHANGELOG.md @@ -0,0 +1,30 @@ + + +# Changelog + +## [Unreleased] + +### Improvements + +* [#20790](https://github.com/cosmos/cosmos-sdk/pull/20790) `x/protocolpool` now has its own BeginBlock. diff --git a/x/protocolpool/go.mod b/x/protocolpool/go.mod index a0cc4853d437..a02f7312608a 100644 --- a/x/protocolpool/go.mod +++ b/x/protocolpool/go.mod @@ -6,14 +6,14 @@ require ( cosmossdk.io/api v0.7.5 cosmossdk.io/collections v0.4.0 cosmossdk.io/core v0.12.1-0.20231114100755-569e3ff6a0d7 - cosmossdk.io/depinject v1.0.0-alpha.4 + cosmossdk.io/core/testing v0.0.0-00010101000000-000000000000 + cosmossdk.io/depinject v1.0.0 cosmossdk.io/errors v1.0.1 - cosmossdk.io/log v1.3.1 cosmossdk.io/math v1.3.0 cosmossdk.io/store v1.1.1-0.20240418092142-896cdf1971bc cosmossdk.io/x/auth v0.0.0-00010101000000-000000000000 github.com/cosmos/cosmos-proto v1.0.0-beta.5 - github.com/cosmos/cosmos-sdk v0.51.0 + github.com/cosmos/cosmos-sdk v0.53.0 github.com/cosmos/gogoproto v1.5.0 github.com/golang/mock v1.6.0 github.com/golang/protobuf v1.5.4 @@ -28,7 +28,7 @@ require ( require ( buf.build/gen/go/cometbft/cometbft/protocolbuffers/go v1.34.2-20240701160653-fedbb9acfd2f.2 // indirect buf.build/gen/go/cosmos/gogo-proto/protocolbuffers/go v1.34.2-20240130113600-88ef6483f90f.2 // indirect - cosmossdk.io/core/testing v0.0.0-00010101000000-000000000000 // indirect + cosmossdk.io/log v1.3.1 // indirect cosmossdk.io/schema v0.1.1 // indirect cosmossdk.io/x/bank v0.0.0-20240226161501-23359a0b6d91 // indirect cosmossdk.io/x/consensus v0.0.0-00010101000000-000000000000 // indirect @@ -57,7 +57,7 @@ require ( github.com/cosmos/crypto v0.1.2 // indirect github.com/cosmos/go-bip39 v1.0.0 // indirect github.com/cosmos/gogogateway v1.2.0 // indirect - github.com/cosmos/iavl v1.2.0 // indirect + github.com/cosmos/iavl v1.2.1-0.20240725141113-7adc688cf179 // indirect github.com/cosmos/ics23/go v0.10.0 // indirect github.com/cosmos/ledger-cosmos-go v0.13.3 // indirect github.com/danieljoos/wincred v1.2.1 // indirect @@ -177,8 +177,6 @@ replace ( cosmossdk.io/api => ../../api cosmossdk.io/core => ../../core cosmossdk.io/core/testing => ../../core/testing - cosmossdk.io/depinject => ../../depinject - cosmossdk.io/log => ../../log cosmossdk.io/x/accounts => ../accounts cosmossdk.io/x/auth => ../auth cosmossdk.io/x/bank => ../bank diff --git a/x/protocolpool/go.sum b/x/protocolpool/go.sum index c2479081cac7..81d16c68890c 100644 --- a/x/protocolpool/go.sum +++ b/x/protocolpool/go.sum @@ -6,8 +6,12 @@ cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMT cloud.google.com/go v0.34.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= cosmossdk.io/collections v0.4.0 h1:PFmwj2W8szgpD5nOd8GWH6AbYNi1f2J6akWXJ7P5t9s= cosmossdk.io/collections v0.4.0/go.mod h1:oa5lUING2dP+gdDquow+QjlF45eL1t4TJDypgGd+tv0= +cosmossdk.io/depinject v1.0.0 h1:dQaTu6+O6askNXO06+jyeUAnF2/ssKwrrszP9t5q050= +cosmossdk.io/depinject v1.0.0/go.mod h1:zxK/h3HgHoA/eJVtiSsoaRaRA2D5U4cJ5thIG4ssbB8= cosmossdk.io/errors v1.0.1 h1:bzu+Kcr0kS/1DuPBtUFdWjzLqyUuCiyHjyJB6srBV/0= cosmossdk.io/errors v1.0.1/go.mod h1:MeelVSZThMi4bEakzhhhE/CKqVv3nOJDA25bIqRDu/U= +cosmossdk.io/log v1.3.1 h1:UZx8nWIkfbbNEWusZqzAx3ZGvu54TZacWib3EzUYmGI= +cosmossdk.io/log v1.3.1/go.mod h1:2/dIomt8mKdk6vl3OWJcPk2be3pGOS8OQaLUM/3/tCM= cosmossdk.io/math v1.3.0 h1:RC+jryuKeytIiictDslBP9i1fhkVm6ZDmZEoNP316zE= cosmossdk.io/math v1.3.0/go.mod h1:vnRTxewy+M7BtXBNFybkuhSH4WfedVAAnERHgVFhp3k= cosmossdk.io/schema v0.1.1 h1:I0M6pgI7R10nq+/HCQfbO6BsGBZA8sQy+duR1Y3aKcA= @@ -111,8 +115,8 @@ github.com/cosmos/gogogateway v1.2.0/go.mod h1:iQpLkGWxYcnCdz5iAdLcRBSw3h7NXeOkZ github.com/cosmos/gogoproto v1.4.2/go.mod h1:cLxOsn1ljAHSV527CHOtaIP91kK6cCrZETRBrkzItWU= github.com/cosmos/gogoproto v1.5.0 h1:SDVwzEqZDDBoslaeZg+dGE55hdzHfgUA40pEanMh52o= github.com/cosmos/gogoproto v1.5.0/go.mod h1:iUM31aofn3ymidYG6bUR5ZFrk+Om8p5s754eMUcyp8I= -github.com/cosmos/iavl v1.2.0 h1:kVxTmjTh4k0Dh1VNL046v6BXqKziqMDzxo93oh3kOfM= -github.com/cosmos/iavl v1.2.0/go.mod h1:HidWWLVAtODJqFD6Hbne2Y0q3SdxByJepHUOeoH4LiI= +github.com/cosmos/iavl v1.2.1-0.20240725141113-7adc688cf179 h1:wmwDn7V3RodN9auB3FooSQxs46nHVE3u0mb87TJkZFE= +github.com/cosmos/iavl v1.2.1-0.20240725141113-7adc688cf179/go.mod h1:GiM43q0pB+uG53mLxLDzimxM9l/5N9UuSY3/D0huuVw= github.com/cosmos/ics23/go v0.10.0 h1:iXqLLgp2Lp+EdpIuwXTYIQU+AiHj9mOC2X9ab++bZDM= github.com/cosmos/ics23/go v0.10.0/go.mod h1:ZfJSmng/TBNTBkFemHHHj5YY7VAU/MBU980F4VU1NG0= github.com/cosmos/ledger-cosmos-go v0.13.3 h1:7ehuBGuyIytsXbd4MP43mLeoN2LTOEnk5nvue4rK+yM= diff --git a/x/protocolpool/keeper/genesis.go b/x/protocolpool/keeper/genesis.go index b7da5a204bc6..0a371f453103 100644 --- a/x/protocolpool/keeper/genesis.go +++ b/x/protocolpool/keeper/genesis.go @@ -2,8 +2,11 @@ package keeper import ( "context" + "errors" "fmt" + "time" + "cosmossdk.io/math" "cosmossdk.io/x/protocolpool/types" sdk "github.com/cosmos/cosmos-sdk/types" @@ -49,8 +52,21 @@ func (k Keeper) InitGenesis(ctx context.Context, data *types.GenesisState) error } } - if err := k.ToDistribute.Set(ctx, data.ToDistribute); err != nil { - return fmt.Errorf("failed to set to distribute: %w", err) + if err := k.LastBalance.Set(ctx, data.LastBalance); err != nil { + return fmt.Errorf("failed to set last balance: %w", err) + } + + totalToBeDistributed := math.ZeroInt() + for _, distribution := range data.Distributions { + totalToBeDistributed = totalToBeDistributed.Add(distribution.Amount) + if err := k.Distributions.Set(ctx, *distribution.Time, distribution.Amount); err != nil { + return fmt.Errorf("failed to set distribution: %w", err) + } + } + + // sanity check to avoid trying to distribute more than what is available + if data.LastBalance.LT(totalToBeDistributed) { + return errors.New("total to be distributed is greater than the last balance") } return nil @@ -96,7 +112,19 @@ func (k Keeper) ExportGenesis(ctx context.Context) (*types.GenesisState, error) genState := types.NewGenesisState(cf, budget) - genState.ToDistribute, err = k.ToDistribute.Get(ctx) + genState.LastBalance, err = k.LastBalance.Get(ctx) + if err != nil { + return nil, err + } + + err = k.Distributions.Walk(ctx, nil, func(key time.Time, value math.Int) (stop bool, err error) { + genState.Distributions = append(genState.Distributions, &types.Distribution{ + Time: &key, + Amount: value, + }) + + return false, nil + }) if err != nil { return nil, err } diff --git a/x/protocolpool/keeper/genesis_test.go b/x/protocolpool/keeper/genesis_test.go index 4653ff616305..f0149f662787 100644 --- a/x/protocolpool/keeper/genesis_test.go +++ b/x/protocolpool/keeper/genesis_test.go @@ -31,7 +31,17 @@ func (suite *KeeperTestSuite) TestInitGenesis() { }, ) + gs.Distributions = append(gs.Distributions, &types.Distribution{ + Amount: math.OneInt(), + Time: &time.Time{}, + }) + err := suite.poolKeeper.InitGenesis(suite.ctx, gs) + suite.Require().ErrorContains(err, "total to be distributed is greater than the last balance") + + // Set last balance + gs.LastBalance = math.NewInt(1) + err = suite.poolKeeper.InitGenesis(suite.ctx, gs) suite.Require().NoError(err) // Export @@ -39,4 +49,5 @@ func (suite *KeeperTestSuite) TestInitGenesis() { suite.Require().NoError(err) suite.Require().Equal(gs.ContinuousFund, exportedGenState.ContinuousFund) suite.Require().Equal(gs.Budget, exportedGenState.Budget) + suite.Require().Equal(math.OneInt(), exportedGenState.LastBalance) } diff --git a/x/protocolpool/keeper/keeper.go b/x/protocolpool/keeper/keeper.go index 038fd3260d88..f74b10af9862 100644 --- a/x/protocolpool/keeper/keeper.go +++ b/x/protocolpool/keeper/keeper.go @@ -1,10 +1,10 @@ package keeper import ( - "bytes" "context" "errors" "fmt" + "sort" "time" "cosmossdk.io/collections" @@ -35,8 +35,8 @@ type Keeper struct { ContinuousFund collections.Map[sdk.AccAddress, types.ContinuousFund] // RecipientFundDistribution key: RecipientAddr | value: Claimable amount RecipientFundDistribution collections.Map[sdk.AccAddress, math.Int] - // ToDistribute is to keep track of funds to be distributed. It gets zeroed out in iterateAndUpdateFundsDistribution. - ToDistribute collections.Item[math.Int] + Distributions collections.Map[time.Time, math.Int] // key: time.Time | value: amount + LastBalance collections.Item[math.Int] } func NewKeeper(cdc codec.BinaryCodec, env appmodule.Environment, ak types.AccountKeeper, bk types.BankKeeper, sk types.StakingKeeper, authority string, @@ -49,6 +49,10 @@ func NewKeeper(cdc codec.BinaryCodec, env appmodule.Environment, ak types.Accoun if addr := ak.GetModuleAddress(types.StreamAccount); addr == nil { panic(fmt.Sprintf("%s module account has not been set", types.StreamAccount)) } + // ensure protocol pool distribution account is set + if addr := ak.GetModuleAddress(types.ProtocolPoolDistrAccount); addr == nil { + panic(fmt.Sprintf("%s module account has not been set", types.ProtocolPoolDistrAccount)) + } sb := collections.NewSchemaBuilder(env.KVStoreService) @@ -62,7 +66,8 @@ func NewKeeper(cdc codec.BinaryCodec, env appmodule.Environment, ak types.Accoun BudgetProposal: collections.NewMap(sb, types.BudgetKey, "budget", sdk.AccAddressKey, codec.CollValue[types.Budget](cdc)), ContinuousFund: collections.NewMap(sb, types.ContinuousFundKey, "continuous_fund", sdk.AccAddressKey, codec.CollValue[types.ContinuousFund](cdc)), RecipientFundDistribution: collections.NewMap(sb, types.RecipientFundDistributionKey, "recipient_fund_distribution", sdk.AccAddressKey, sdk.IntValue), - ToDistribute: collections.NewItem(sb, types.ToDistributeKey, "to_distribute", sdk.IntValue), + Distributions: collections.NewMap(sb, types.DistributionsKey, "distributions", sdk.TimeKey, sdk.IntValue), + LastBalance: collections.NewItem(sb, types.LastBalanceKey, "last_balance", sdk.IntValue), } schema, err := sb.Build() @@ -80,19 +85,19 @@ func (k Keeper) GetAuthority() string { } // FundCommunityPool allows an account to directly fund the community fund pool. -func (k Keeper) FundCommunityPool(ctx context.Context, amount sdk.Coins, sender sdk.AccAddress) error { +func (k Keeper) FundCommunityPool(ctx context.Context, amount sdk.Coins, sender []byte) error { return k.bankKeeper.SendCoinsFromAccountToModule(ctx, sender, types.ModuleName, amount) } // DistributeFromCommunityPool distributes funds from the protocolpool module account to // a receiver address. -func (k Keeper) DistributeFromCommunityPool(ctx context.Context, amount sdk.Coins, receiveAddr sdk.AccAddress) error { +func (k Keeper) DistributeFromCommunityPool(ctx context.Context, amount sdk.Coins, receiveAddr []byte) error { return k.bankKeeper.SendCoinsFromModuleToAccount(ctx, types.ModuleName, receiveAddr, amount) } // DistributeFromStreamFunds distributes funds from the protocolpool's stream module account to // a receiver address. -func (k Keeper) DistributeFromStreamFunds(ctx context.Context, amount sdk.Coins, receiveAddr sdk.AccAddress) error { +func (k Keeper) DistributeFromStreamFunds(ctx context.Context, amount sdk.Coins, receiveAddr []byte) error { return k.bankKeeper.SendCoinsFromModuleToAccount(ctx, types.StreamAccount, receiveAddr, amount) } @@ -100,48 +105,17 @@ func (k Keeper) DistributeFromStreamFunds(ctx context.Context, amount sdk.Coins, func (k Keeper) GetCommunityPool(ctx context.Context) (sdk.Coins, error) { moduleAccount := k.authKeeper.GetModuleAccount(ctx, types.ModuleName) if moduleAccount == nil { - return nil, errorsmod.Wrapf(sdkerrors.ErrUnknownAddress, "module account %s does not exist", moduleAccount) + return nil, errorsmod.Wrapf(sdkerrors.ErrUnknownAddress, "module account %s does not exist", types.ModuleName) } return k.bankKeeper.GetAllBalances(ctx, moduleAccount.GetAddress()), nil } -func (k Keeper) withdrawContinuousFund(ctx context.Context, recipientAddr string) (sdk.Coin, error) { - recipient, err := k.authKeeper.AddressCodec().StringToBytes(recipientAddr) - if err != nil { - return sdk.Coin{}, sdkerrors.ErrInvalidAddress.Wrapf("invalid recipient address: %s", err) - } - - cf, err := k.ContinuousFund.Get(ctx, recipient) - if err != nil { - if errors.Is(err, collections.ErrNotFound) { - return sdk.Coin{}, fmt.Errorf("no continuous fund found for recipient: %s", recipientAddr) - } - return sdk.Coin{}, fmt.Errorf("get continuous fund failed for recipient: %s", recipientAddr) - } - if cf.Expiry != nil && cf.Expiry.Before(k.HeaderService.HeaderInfo(ctx).Time) { - return sdk.Coin{}, fmt.Errorf("cannot withdraw continuous funds: continuous fund expired for recipient: %s", recipientAddr) - } - - err = k.IterateAndUpdateFundsDistribution(ctx) - if err != nil { - return sdk.Coin{}, fmt.Errorf("error while iterating all the continuous funds: %w", err) - } - - // withdraw continuous fund - withdrawnAmount, err := k.withdrawRecipientFunds(ctx, recipient) - if err != nil { - return sdk.Coin{}, fmt.Errorf("error while withdrawing recipient funds for recipient: %s", recipientAddr) - } - - return withdrawnAmount, nil -} - func (k Keeper) withdrawRecipientFunds(ctx context.Context, recipient []byte) (sdk.Coin, error) { // get allocated continuous fund fundsAllocated, err := k.RecipientFundDistribution.Get(ctx, recipient) if err != nil { if errors.Is(err, collections.ErrNotFound) { - return sdk.Coin{}, types.ErrNoRecipientFund + return sdk.Coin{}, types.ErrNoRecipientFound } return sdk.Coin{}, err } @@ -166,20 +140,12 @@ func (k Keeper) withdrawRecipientFunds(ctx context.Context, recipient []byte) (s return withdrawnAmount, nil } -// SetToDistribute sets the amount to be distributed among recipients, usually called by x/distribution while allocating -// reward and fee distribution. -// This could be only set by the authority address. -func (k Keeper) SetToDistribute(ctx context.Context, amount sdk.Coins, addr string) error { - authAddr, err := k.authKeeper.AddressCodec().StringToBytes(addr) - if err != nil { - return err - } - hasPermission, err := k.hasPermission(authAddr) - if err != nil { - return err - } - if !hasPermission { - return sdkerrors.ErrUnauthorized +// SetToDistribute sets the amount to be distributed among recipients. +func (k Keeper) SetToDistribute(ctx context.Context) error { + // Get current balance of the intermediary module account + moduleAccount := k.authKeeper.GetModuleAccount(ctx, types.ProtocolPoolDistrAccount) + if moduleAccount == nil { + return errorsmod.Wrapf(sdkerrors.ErrUnknownAddress, "module account %s does not exist", types.ProtocolPoolDistrAccount) } denom, err := k.stakingKeeper.BondDenom(ctx) @@ -187,116 +153,154 @@ func (k Keeper) SetToDistribute(ctx context.Context, amount sdk.Coins, addr stri return err } - totalStreamFundsPercentage := math.LegacyZeroDec() - err = k.ContinuousFund.Walk(ctx, nil, func(key sdk.AccAddress, cf types.ContinuousFund) (stop bool, err error) { - // Check if the continuous fund has expired - if cf.Expiry != nil && cf.Expiry.Before(k.HeaderService.HeaderInfo(ctx).Time) { - return false, nil - } - - totalStreamFundsPercentage = totalStreamFundsPercentage.Add(cf.Percentage) - if totalStreamFundsPercentage.GT(math.LegacyOneDec()) { - return true, errors.New("total funds percentage cannot exceed 100") - } - - return false, nil - }) - if err != nil { - return err - } + currentBalance := k.bankKeeper.GetAllBalances(ctx, moduleAccount.GetAddress()) + distributionBalance := currentBalance.AmountOf(denom) - // if percentage is 0 then return early - if totalStreamFundsPercentage.IsZero() { + // if the balance is zero, return early + if distributionBalance.IsZero() { return nil } - // send streaming funds to the stream module account - toDistributeAmt := math.LegacyNewDecFromInt(amount.AmountOf(denom)).Mul(totalStreamFundsPercentage).TruncateInt() - streamAmt := sdk.NewCoins(sdk.NewCoin(denom, toDistributeAmt)) - if err := k.bankKeeper.SendCoinsFromModuleToModule(ctx, types.ModuleName, types.StreamAccount, streamAmt); err != nil { - return err - } - - amountToDistribute, err := k.ToDistribute.Get(ctx) + lastBalance, err := k.LastBalance.Get(ctx) if err != nil { if errors.Is(err, collections.ErrNotFound) { - amountToDistribute = math.ZeroInt() + lastBalance = math.ZeroInt() } else { return err } } - err = k.ToDistribute.Set(ctx, amountToDistribute.Add(amount.AmountOf(denom))) - if err != nil { - return fmt.Errorf("error while setting ToDistribute: %w", err) - } - return nil -} + // Calculate the amount to be distributed + amountToDistribute := distributionBalance.Sub(lastBalance) -func (k Keeper) hasPermission(addr []byte) (bool, error) { - authority := k.GetAuthority() - authAcc, err := k.authKeeper.AddressCodec().StringToBytes(authority) - if err != nil { - return false, err + if err = k.Distributions.Set(ctx, k.HeaderService.HeaderInfo(ctx).Time, amountToDistribute); err != nil { + return fmt.Errorf("error while setting Distributions: %w", err) } - return bytes.Equal(authAcc, addr), nil + // Update the last balance + return k.LastBalance.Set(ctx, distributionBalance) } func (k Keeper) IterateAndUpdateFundsDistribution(ctx context.Context) error { - toDistributeAmount, err := k.ToDistribute.Get(ctx) + // first we get all the continuous funds, and keep a list of the ones that expired so we can delete later + funds := []types.ContinuousFund{} + toDelete := [][]byte{} + err := k.ContinuousFund.Walk(ctx, nil, func(key sdk.AccAddress, cf types.ContinuousFund) (stop bool, err error) { + funds = append(funds, cf) + + // check if the continuous fund has expired, and add it to the list of funds to delete + if cf.Expiry != nil && cf.Expiry.Before(k.HeaderService.HeaderInfo(ctx).Time) { + toDelete = append(toDelete, key) + } + + return false, nil + }) if err != nil { return err } - // if there are no funds to distribute, return - if toDistributeAmount.IsZero() { - return nil + // next we iterate over the distributions, calculate each recipient's share and the remaining pool funds + toDistribute := map[string]math.Int{} + poolFunds := math.ZeroInt() + fullAmountToDistribute := math.ZeroInt() + + if err = k.Distributions.Walk(ctx, nil, func(key time.Time, amount math.Int) (stop bool, err error) { + percentageToDistribute := math.LegacyZeroDec() + for _, f := range funds { + if f.Expiry != nil && f.Expiry.Before(key) { + continue + } + + percentageToDistribute = percentageToDistribute.Add(f.Percentage) + + _, ok := toDistribute[f.Recipient] + if !ok { + toDistribute[f.Recipient] = math.ZeroInt() + } + amountToDistribute := f.Percentage.MulInt(amount).TruncateInt() + toDistribute[f.Recipient] = toDistribute[f.Recipient].Add(amountToDistribute) + fullAmountToDistribute = fullAmountToDistribute.Add(amountToDistribute) + } + + // sanity check for max percentage + if percentageToDistribute.GT(math.LegacyOneDec()) { + return true, errors.New("total funds percentage cannot exceed 100") + } + + remaining := math.LegacyOneDec().Sub(percentageToDistribute).MulInt(amount).RoundInt() + poolFunds = poolFunds.Add(remaining) + + return false, nil + }); err != nil { + return err } - totalPercentageToBeDistributed := math.LegacyZeroDec() + // clear the distributions and reset the last balance + if err = k.Distributions.Clear(ctx, nil); err != nil { + return err + } - denom, err := k.stakingKeeper.BondDenom(ctx) + if err = k.LastBalance.Set(ctx, math.ZeroInt()); err != nil { + return err + } + + // send the funds to the stream account to be distributed later, and the remaining to the community pool + bondDenom, err := k.stakingKeeper.BondDenom(ctx) if err != nil { return err } - toDistributeDec := sdk.NewDecCoin(denom, toDistributeAmount) - // Calculate totalPercentageToBeDistributed and store values - err = k.ContinuousFund.Walk(ctx, nil, func(key sdk.AccAddress, cf types.ContinuousFund) (stop bool, err error) { - // Check if the continuous fund has expired - if cf.Expiry != nil && cf.Expiry.Before(k.HeaderService.HeaderInfo(ctx).Time) { - return false, nil + streamAmt := sdk.NewCoins(sdk.NewCoin(bondDenom, fullAmountToDistribute)) + if !streamAmt.IsZero() { + if err := k.bankKeeper.SendCoinsFromModuleToModule(ctx, types.ProtocolPoolDistrAccount, types.StreamAccount, streamAmt); err != nil { + return err } + } - // sanity check for max percentage - totalPercentageToBeDistributed = totalPercentageToBeDistributed.Add(cf.Percentage) - if totalPercentageToBeDistributed.GT(math.LegacyOneDec()) { - return true, errors.New("total funds percentage cannot exceed 100") + if !poolFunds.IsZero() { + poolCoins := sdk.NewCoins(sdk.NewCoin(bondDenom, poolFunds)) + if err := k.bankKeeper.SendCoinsFromModuleToModule(ctx, types.ProtocolPoolDistrAccount, types.ModuleName, poolCoins); err != nil { + return err } + } - // Calculate the funds to be distributed based on the percentage - recipientAmount := toDistributeDec.Amount.Mul(cf.Percentage).TruncateInt() + // update the recipient fund distribution, first get the keys and sort them + recipients := make([]string, 0, len(toDistribute)) + for k2 := range toDistribute { + recipients = append(recipients, k2) + } + sort.Strings(recipients) + for _, recipient := range recipients { // Set funds to be claimed - toClaim, err := k.RecipientFundDistribution.Get(ctx, key) + bzAddr, err := k.authKeeper.AddressCodec().StringToBytes(recipient) if err != nil { - return true, err + return err } - amount := toClaim.Add(recipientAmount) - err = k.RecipientFundDistribution.Set(ctx, key, amount) + + toClaim, err := k.RecipientFundDistribution.Get(ctx, bzAddr) if err != nil { - return true, err + if errors.Is(err, collections.ErrNotFound) { + toClaim = math.ZeroInt() + } else { + return err + } } - return false, nil - }) - if err != nil { - return err + amount := toClaim.Add(toDistribute[recipient]) + if err = k.RecipientFundDistribution.Set(ctx, bzAddr, amount); err != nil { + return err + } + } + + // delete expired continuous funds + for _, recipient := range toDelete { + if err = k.ContinuousFund.Remove(ctx, recipient); err != nil { + return err + } } - // Set the coins to be distributed from toDistribute to 0 - return k.ToDistribute.Set(ctx, math.ZeroInt()) + return nil } func (k Keeper) claimFunds(ctx context.Context, recipientAddr string) (amount sdk.Coin, err error) { @@ -472,3 +476,7 @@ func (k Keeper) validateContinuousFund(ctx context.Context, msg types.MsgCreateC return nil } + +func (k Keeper) BeginBlocker(ctx context.Context) error { + return k.SetToDistribute(ctx) +} diff --git a/x/protocolpool/keeper/keeper_test.go b/x/protocolpool/keeper/keeper_test.go index ddfcd6d82415..7100d2dec5cf 100644 --- a/x/protocolpool/keeper/keeper_test.go +++ b/x/protocolpool/keeper/keeper_test.go @@ -9,7 +9,7 @@ import ( "cosmossdk.io/core/appmodule" "cosmossdk.io/core/header" - "cosmossdk.io/log" + coretesting "cosmossdk.io/core/testing" "cosmossdk.io/math" storetypes "cosmossdk.io/store/types" authtypes "cosmossdk.io/x/auth/types" @@ -27,8 +27,9 @@ import ( ) var ( - poolAcc = authtypes.NewEmptyModuleAccount(types.ModuleName) - streamAcc = authtypes.NewEmptyModuleAccount(types.StreamAccount) + poolAcc = authtypes.NewEmptyModuleAccount(types.ModuleName) + streamAcc = authtypes.NewEmptyModuleAccount(types.StreamAccount) + poolDistrAcc = authtypes.NewEmptyModuleAccount(types.ProtocolPoolDistrAccount) ) type KeeperTestSuite struct { @@ -48,7 +49,7 @@ type KeeperTestSuite struct { func (s *KeeperTestSuite) SetupTest() { key := storetypes.NewKVStoreKey(types.StoreKey) storeService := runtime.NewKVStoreService(key) - environment := runtime.NewEnvironment(storeService, log.NewNopLogger()) + environment := runtime.NewEnvironment(storeService, coretesting.NewNopLogger()) testCtx := testutil.DefaultContextWithDB(s.T(), key, storetypes.NewTransientStoreKey("transient_test")) ctx := testCtx.Ctx.WithHeaderInfo(header.Info{Time: time.Now()}) encCfg := moduletestutil.MakeTestEncodingConfig(codectestutil.CodecOptions{}) @@ -57,6 +58,7 @@ func (s *KeeperTestSuite) SetupTest() { ctrl := gomock.NewController(s.T()) accountKeeper := pooltestutil.NewMockAccountKeeper(ctrl) accountKeeper.EXPECT().GetModuleAddress(types.ModuleName).Return(poolAcc.GetAddress()) + accountKeeper.EXPECT().GetModuleAddress(types.ProtocolPoolDistrAccount).Return(poolDistrAcc.GetAddress()) accountKeeper.EXPECT().AddressCodec().Return(address.NewBech32Codec("cosmos")).AnyTimes() accountKeeper.EXPECT().GetModuleAddress(types.StreamAccount).Return(streamAcc.GetAddress()) s.authKeeper = accountKeeper @@ -102,12 +104,14 @@ func (s *KeeperTestSuite) mockWithdrawContinuousFund() { s.stakingKeeper.EXPECT().BondDenom(gomock.Any()).Return("stake", nil).AnyTimes() } -func (s *KeeperTestSuite) mockStreamFunds() { +func (s *KeeperTestSuite) mockStreamFunds(distributed math.Int) { s.authKeeper.EXPECT().GetModuleAccount(s.ctx, types.ModuleName).Return(poolAcc).AnyTimes() + s.authKeeper.EXPECT().GetModuleAccount(s.ctx, types.ProtocolPoolDistrAccount).Return(poolDistrAcc).AnyTimes() s.authKeeper.EXPECT().GetModuleAddress(types.StreamAccount).Return(streamAcc.GetAddress()).AnyTimes() - distrBal := sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, math.NewInt(100000))) - s.bankKeeper.EXPECT().GetAllBalances(s.ctx, poolAcc.GetAddress()).Return(distrBal).AnyTimes() - s.bankKeeper.EXPECT().SendCoinsFromModuleToModule(s.ctx, poolAcc.GetName(), streamAcc.GetName(), gomock.Any()).AnyTimes() + distrBal := sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, distributed)) + s.bankKeeper.EXPECT().GetAllBalances(s.ctx, poolDistrAcc.GetAddress()).Return(distrBal).AnyTimes() + s.bankKeeper.EXPECT().SendCoinsFromModuleToModule(s.ctx, poolDistrAcc.GetName(), streamAcc.GetName(), gomock.Any()).AnyTimes() + s.bankKeeper.EXPECT().SendCoinsFromModuleToModule(s.ctx, poolDistrAcc.GetName(), poolAcc.GetName(), gomock.Any()).AnyTimes() } func TestKeeperTestSuite(t *testing.T) { @@ -118,10 +122,11 @@ func (s *KeeperTestSuite) TestIterateAndUpdateFundsDistribution() { // We'll create 2 continuous funds of 30% each, and the total pool is 1000000, meaning each fund should get 300000 s.SetupTest() - s.authKeeper.EXPECT().GetModuleAccount(s.ctx, types.ModuleName).Return(poolAcc).AnyTimes() + s.authKeeper.EXPECT().GetModuleAccount(s.ctx, types.ProtocolPoolDistrAccount).Return(poolAcc).AnyTimes() distrBal := sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, math.NewInt(1000000))) s.bankKeeper.EXPECT().GetAllBalances(s.ctx, poolAcc.GetAddress()).Return(distrBal).AnyTimes() - s.bankKeeper.EXPECT().SendCoinsFromModuleToModule(s.ctx, poolAcc.GetName(), streamAcc.GetName(), sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, math.NewInt(600000)))).AnyTimes() + s.bankKeeper.EXPECT().SendCoinsFromModuleToModule(s.ctx, poolDistrAcc.GetName(), streamAcc.GetName(), sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, math.NewInt(600000)))) + s.bankKeeper.EXPECT().SendCoinsFromModuleToModule(s.ctx, poolDistrAcc.GetName(), poolAcc.GetName(), sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, math.NewInt(400000)))) _, err := s.msgServer.CreateContinuousFund(s.ctx, &types.MsgCreateContinuousFund{ Authority: s.poolKeeper.GetAuthority(), @@ -137,7 +142,7 @@ func (s *KeeperTestSuite) TestIterateAndUpdateFundsDistribution() { }) s.Require().NoError(err) - _ = s.poolKeeper.SetToDistribute(s.ctx, sdk.NewCoins(sdk.NewCoin("stake", math.NewInt(1000000))), s.poolKeeper.GetAuthority()) + _ = s.poolKeeper.SetToDistribute(s.ctx) err = s.poolKeeper.IterateAndUpdateFundsDistribution(s.ctx) s.Require().NoError(err) diff --git a/x/protocolpool/keeper/msg_server.go b/x/protocolpool/keeper/msg_server.go index 775826cda755..43caff3e42a2 100644 --- a/x/protocolpool/keeper/msg_server.go +++ b/x/protocolpool/keeper/msg_server.go @@ -139,6 +139,11 @@ func (k MsgServer) CreateContinuousFund(ctx context.Context, msg *types.MsgCreat return nil, fmt.Errorf("cannot set continuous fund proposal\ntotal funds percentage exceeds 100\ncurrent total percentage: %s", totalStreamFundsPercentage.Sub(msg.Percentage).MulInt64(100).TruncateInt().String()) } + // Distribute funds to avoid giving this new fund more than it should get + if err := k.IterateAndUpdateFundsDistribution(ctx); err != nil { + return nil, err + } + // Create continuous fund proposal cf := types.ContinuousFund{ Recipient: msg.Recipient, @@ -161,12 +166,23 @@ func (k MsgServer) CreateContinuousFund(ctx context.Context, msg *types.MsgCreat } func (k MsgServer) WithdrawContinuousFund(ctx context.Context, msg *types.MsgWithdrawContinuousFund) (*types.MsgWithdrawContinuousFundResponse, error) { - amount, err := k.withdrawContinuousFund(ctx, msg.RecipientAddress) + recipient, err := k.authKeeper.AddressCodec().StringToBytes(msg.RecipientAddress) if err != nil { - return nil, err + return nil, sdkerrors.ErrInvalidAddress.Wrapf("invalid recipient address: %s", err) + } + + err = k.IterateAndUpdateFundsDistribution(ctx) + if err != nil { + return nil, fmt.Errorf("error while iterating all the continuous funds: %w", err) + } + + // withdraw continuous fund + withdrawnAmount, err := k.withdrawRecipientFunds(ctx, recipient) + if err != nil { + return nil, fmt.Errorf("error while withdrawing recipient funds for recipient: %w", err) } - return &types.MsgWithdrawContinuousFundResponse{Amount: amount}, nil + return &types.MsgWithdrawContinuousFundResponse{Amount: withdrawnAmount}, nil } func (k MsgServer) CancelContinuousFund(ctx context.Context, msg *types.MsgCancelContinuousFund) (*types.MsgCancelContinuousFundResponse, error) { @@ -182,17 +198,14 @@ func (k MsgServer) CancelContinuousFund(ctx context.Context, msg *types.MsgCance canceledHeight := k.HeaderService.HeaderInfo(ctx).Height canceledTime := k.HeaderService.HeaderInfo(ctx).Time - found, err := k.ContinuousFund.Has(ctx, recipient) - if !found { - return nil, fmt.Errorf("no recipient found to cancel continuous fund: %s", msg.RecipientAddress) - } - if err != nil { + // distribute funds before withdrawing + if err = k.IterateAndUpdateFundsDistribution(ctx); err != nil { return nil, err } // withdraw funds if any are allocated withdrawnFunds, err := k.withdrawRecipientFunds(ctx, recipient) - if err != nil && !errorspkg.Is(err, types.ErrNoRecipientFund) { + if err != nil && !errorspkg.Is(err, types.ErrNoRecipientFound) { return nil, fmt.Errorf("error while withdrawing already allocated funds for recipient %s: %w", msg.RecipientAddress, err) } diff --git a/x/protocolpool/keeper/msg_server_test.go b/x/protocolpool/keeper/msg_server_test.go index 37b122170d71..b053ef9ff681 100644 --- a/x/protocolpool/keeper/msg_server_test.go +++ b/x/protocolpool/keeper/msg_server_test.go @@ -3,6 +3,8 @@ package keeper_test import ( "time" + "github.com/golang/mock/gomock" + "cosmossdk.io/collections" "cosmossdk.io/core/header" "cosmossdk.io/math" @@ -403,7 +405,7 @@ func (suite *KeeperTestSuite) TestWithdrawContinuousFund() { "recipient with no continuous fund": { recipientAddress: []sdk.AccAddress{recipient}, expErr: true, - expErrMsg: "no continuous fund found for recipient", + expErrMsg: "error while withdrawing recipient funds for recipient: no recipient found", }, "funds percentage > 100": { preRun: func() { @@ -441,14 +443,14 @@ func (suite *KeeperTestSuite) TestWithdrawContinuousFund() { suite.Require().NoError(err) // Set ToDistribute - err = suite.poolKeeper.ToDistribute.Set(suite.ctx, math.NewInt(100000)) + err = suite.poolKeeper.Distributions.Set(suite.ctx, suite.ctx.HeaderInfo().Time, math.NewInt(100000)) suite.Require().NoError(err) }, recipientAddress: []sdk.AccAddress{recipient}, expErr: true, expErrMsg: "error while iterating all the continuous funds: total funds percentage cannot exceed 100", }, - "expired case": { + "expired case with no funds left to withdraw": { preRun: func() { percentage, err := math.LegacyNewDecFromStr("0.2") suite.Require().NoError(err) @@ -464,7 +466,7 @@ func (suite *KeeperTestSuite) TestWithdrawContinuousFund() { }, recipientAddress: []sdk.AccAddress{recipient}, expErr: true, - expErrMsg: "cannot withdraw continuous funds: continuous fund expired for recipient", + expErrMsg: "error while withdrawing recipient funds for recipient: no recipient found", }, "valid case with ToDistribute amount zero": { preRun: func() { @@ -483,8 +485,9 @@ func (suite *KeeperTestSuite) TestWithdrawContinuousFund() { // Set recipient fund percentage and recipient fund distribution err = suite.poolKeeper.RecipientFundDistribution.Set(suite.ctx, recipient, math.ZeroInt()) suite.Require().NoError(err) - err = suite.poolKeeper.ToDistribute.Set(suite.ctx, math.ZeroInt()) + err = suite.poolKeeper.Distributions.Set(suite.ctx, suite.ctx.HeaderInfo().Time, math.ZeroInt()) suite.Require().NoError(err) + suite.mockStreamFunds(math.NewInt(0)) }, recipientAddress: []sdk.AccAddress{recipient}, expErr: false, @@ -504,9 +507,8 @@ func (suite *KeeperTestSuite) TestWithdrawContinuousFund() { // Set recipient fund percentage and recipient fund distribution err = suite.poolKeeper.RecipientFundDistribution.Set(suite.ctx, recipient, math.ZeroInt()) suite.Require().NoError(err) - toDistribute := sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, math.NewInt(100000))) - suite.mockStreamFunds() - err = suite.poolKeeper.SetToDistribute(suite.ctx, toDistribute, suite.poolKeeper.GetAuthority()) + suite.mockStreamFunds(math.NewInt(100000)) + err = suite.poolKeeper.SetToDistribute(suite.ctx) suite.Require().NoError(err) }, recipientAddress: []sdk.AccAddress{recipient}, @@ -530,9 +532,8 @@ func (suite *KeeperTestSuite) TestWithdrawContinuousFund() { // Set recipient fund percentage and recipient fund distribution err = suite.poolKeeper.RecipientFundDistribution.Set(suite.ctx, recipient, math.ZeroInt()) suite.Require().NoError(err) - toDistribute := sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, math.NewInt(100000))) - suite.mockStreamFunds() - err = suite.poolKeeper.SetToDistribute(suite.ctx, toDistribute, suite.poolKeeper.GetAuthority()) + suite.mockStreamFunds(math.NewInt(100000)) + err = suite.poolKeeper.SetToDistribute(suite.ctx) suite.Require().NoError(err) }, recipientAddress: []sdk.AccAddress{recipient}, @@ -588,9 +589,8 @@ func (suite *KeeperTestSuite) TestWithdrawContinuousFund() { err = suite.poolKeeper.RecipientFundDistribution.Set(suite.ctx, recipient3, math.ZeroInt()) suite.Require().NoError(err) - toDistribute := sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, math.NewInt(100000))) - suite.mockStreamFunds() - err = suite.poolKeeper.SetToDistribute(suite.ctx, toDistribute, suite.poolKeeper.GetAuthority()) + suite.mockStreamFunds(math.NewInt(100000)) + err = suite.poolKeeper.SetToDistribute(suite.ctx) suite.Require().NoError(err) }, recipientAddress: []sdk.AccAddress{recipient, recipient2, recipient3}, @@ -813,11 +813,6 @@ func (suite *KeeperTestSuite) TestCancelContinuousFund() { expErr: true, expErrMsg: "empty address string is not allowed", }, - "no recipient found": { - recipientAddr: recipientAddr, - expErr: true, - expErrMsg: "no recipient found to cancel continuous fund", - }, "all good with unclaimed funds for recipient": { preRun: func() { // Set fund 1 @@ -853,9 +848,8 @@ func (suite *KeeperTestSuite) TestCancelContinuousFund() { suite.Require().NoError(err) // Set ToDistribute - toDistribute := sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, math.NewInt(100000))) - suite.mockStreamFunds() - err = suite.poolKeeper.SetToDistribute(suite.ctx, toDistribute, suite.poolKeeper.GetAuthority()) + suite.mockStreamFunds(math.NewInt(100000)) + err = suite.poolKeeper.SetToDistribute(suite.ctx) suite.Require().NoError(err) // withdraw funds for fund request 2 @@ -960,9 +954,8 @@ func (suite *KeeperTestSuite) TestWithdrawExpiredFunds() { }) suite.Require().NoError(err) - toDistribute := sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, math.NewInt(100000))) - suite.mockStreamFunds() - err = suite.poolKeeper.SetToDistribute(suite.ctx, toDistribute, suite.poolKeeper.GetAuthority()) + suite.mockStreamFunds(math.NewInt(100000)) + err = suite.poolKeeper.SetToDistribute(suite.ctx) suite.Require().NoError(err) suite.mockWithdrawContinuousFund() @@ -973,11 +966,17 @@ func (suite *KeeperTestSuite) TestWithdrawExpiredFunds() { header.Time = expiration.Add(1 * time.Second) suite.ctx = suite.ctx.WithHeaderInfo(header) - _, err = suite.msgServer.WithdrawContinuousFund(suite.ctx, &types.MsgWithdrawContinuousFund{RecipientAddress: recipientStrAddr}) - suite.Require().ErrorContains(err, "continuous fund expired for recipient") + // If we keep calling WithdrawContinuousFund, it should not error and return always an amount of 0 + withdrawRes, err := suite.msgServer.WithdrawContinuousFund(suite.ctx, &types.MsgWithdrawContinuousFund{RecipientAddress: recipientStrAddr}) + suite.Require().True(withdrawRes.Amount.IsZero()) + suite.Require().NoError(err) + + withdrawRes, err = suite.msgServer.WithdrawContinuousFund(suite.ctx, &types.MsgWithdrawContinuousFund{RecipientAddress: recipientStrAddr}) + suite.Require().True(withdrawRes.Amount.IsZero()) + suite.Require().NoError(err) - suite.mockStreamFunds() - err = suite.poolKeeper.SetToDistribute(suite.ctx, toDistribute, suite.poolKeeper.GetAuthority()) + suite.mockStreamFunds(math.NewInt(100000)) + err = suite.poolKeeper.SetToDistribute(suite.ctx) suite.Require().NoError(err) suite.mockWithdrawContinuousFund() @@ -985,9 +984,58 @@ func (suite *KeeperTestSuite) TestWithdrawExpiredFunds() { suite.Require().NoError(err) res, err := suite.msgServer.CancelContinuousFund(suite.ctx, &types.MsgCancelContinuousFund{ + Authority: suite.poolKeeper.GetAuthority(), + RecipientAddress: recipient2StrAddr, + }) + suite.Require().NoError(err) + suite.Require().Equal(sdk.NewCoin(sdk.DefaultBondDenom, math.NewInt(0)), res.WithdrawnAllocatedFund) + + // canceling an expired continuous fund, won't error + res, err = suite.msgServer.CancelContinuousFund(suite.ctx, &types.MsgCancelContinuousFund{ Authority: suite.poolKeeper.GetAuthority(), RecipientAddress: recipientStrAddr, }) suite.Require().NoError(err) suite.Require().Equal(sdk.NewCoin(sdk.DefaultBondDenom, math.NewInt(0)), res.WithdrawnAllocatedFund) + + // if we try to cancel again the same continuout fund, it won't error, it will still distribute funds if needed. + res, err = suite.msgServer.CancelContinuousFund(suite.ctx, &types.MsgCancelContinuousFund{ + Authority: suite.poolKeeper.GetAuthority(), + RecipientAddress: recipientStrAddr, + }) + suite.Require().NoError(err) + suite.Require().True(res.WithdrawnAllocatedFund.IsNil()) +} + +func (suite *KeeperTestSuite) TestFundCommunityPool() { + sender := []byte("fundingAddr1____________________") + addrCodec := codectestutil.CodecOptions{}.GetAddressCodec() + senderAddr, err := addrCodec.BytesToString(sender) + suite.Require().NoError(err) + + amount := sdk.NewCoins(sdk.NewInt64Coin(sdk.DefaultBondDenom, 1000000)) + suite.bankKeeper.EXPECT().SendCoinsFromAccountToModule(gomock.Any(), sender, types.ModuleName, amount).Return(nil).Times(1) + + _, err = suite.msgServer.FundCommunityPool(suite.ctx, &types.MsgFundCommunityPool{ + Amount: amount, + Depositor: senderAddr, + }) + suite.Require().NoError(err) +} + +func (suite *KeeperTestSuite) TestCommunityPoolSpend() { + recipient := []byte("fundingAddr1____________________") + addrCodec := codectestutil.CodecOptions{}.GetAddressCodec() + recipientAddr, err := addrCodec.BytesToString(recipient) + suite.Require().NoError(err) + + amount := sdk.NewCoins(sdk.NewInt64Coin(sdk.DefaultBondDenom, 1000000)) + suite.bankKeeper.EXPECT().SendCoinsFromModuleToAccount(gomock.Any(), types.ModuleName, recipient, amount).Return(nil).Times(1) + + _, err = suite.msgServer.CommunityPoolSpend(suite.ctx, &types.MsgCommunityPoolSpend{ + Authority: suite.poolKeeper.GetAuthority(), + Recipient: recipientAddr, + Amount: amount, + }) + suite.Require().NoError(err) } diff --git a/x/protocolpool/module.go b/x/protocolpool/module.go index 882da6eb6fc8..2e88385d54f9 100644 --- a/x/protocolpool/module.go +++ b/x/protocolpool/module.go @@ -29,6 +29,7 @@ var ( _ appmodule.HasServices = AppModule{} _ appmodule.HasGenesis = AppModule{} _ appmodule.HasRegisterInterfaces = AppModule{} + _ appmodule.HasBeginBlocker = AppModule{} ) // AppModule implements an application module for the pool module @@ -112,5 +113,10 @@ func (am AppModule) ExportGenesis(ctx context.Context) (json.RawMessage, error) return am.cdc.MarshalJSON(gs) } +// BeginBlock implements appmodule.HasBeginBlocker. +func (am AppModule) BeginBlock(ctx context.Context) error { + return am.keeper.BeginBlocker(ctx) +} + // ConsensusVersion implements HasConsensusVersion func (AppModule) ConsensusVersion() uint64 { return ConsensusVersion } diff --git a/x/protocolpool/proto/cosmos/protocolpool/v1/genesis.proto b/x/protocolpool/proto/cosmos/protocolpool/v1/genesis.proto index 5730f5257801..d9df6870a7a4 100644 --- a/x/protocolpool/proto/cosmos/protocolpool/v1/genesis.proto +++ b/x/protocolpool/proto/cosmos/protocolpool/v1/genesis.proto @@ -6,6 +6,7 @@ option go_package = "cosmossdk.io/x/protocolpool/types"; import "cosmos/protocolpool/v1/types.proto"; import "gogoproto/gogo.proto"; import "cosmos_proto/cosmos.proto"; +import "google/protobuf/timestamp.proto"; // GenesisState defines the protocolpool module's genesis state. message GenesisState { @@ -14,9 +15,26 @@ message GenesisState { // Budget defines the budget proposals at genesis. repeated Budget budget = 2; - string to_distribute = 3 [ + // last_balance contains the amount of tokens yet to be distributed, will be zero if + // there are no funds to distribute. + string last_balance = 3 [ (cosmos_proto.scalar) = "cosmos.Int", (gogoproto.customtype) = "cosmossdk.io/math.Int", (gogoproto.nullable) = false ]; + + // distributions contains the list of distributions to be made to continuous + // funds and budgets. It contains time in order to distribute to non-expired + // funds only. + repeated Distribution distributions = 4; } + +message Distribution { + string amount = 3 [ + (cosmos_proto.scalar) = "cosmos.Int", + (gogoproto.customtype) = "cosmossdk.io/math.Int", + (gogoproto.nullable) = false + ]; + + google.protobuf.Timestamp time = 6 [(gogoproto.stdtime) = true]; +} \ No newline at end of file diff --git a/x/protocolpool/simulation/operations.go b/x/protocolpool/simulation/operations.go index 004b850d52be..01da9484f953 100644 --- a/x/protocolpool/simulation/operations.go +++ b/x/protocolpool/simulation/operations.go @@ -6,7 +6,6 @@ import ( "cosmossdk.io/x/protocolpool/keeper" "cosmossdk.io/x/protocolpool/types" - "github.com/cosmos/cosmos-sdk/baseapp" "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/codec" sdk "github.com/cosmos/cosmos-sdk/types" @@ -47,7 +46,7 @@ func WeightedOperations( // a random account sends a random amount of its funds to the community pool. func SimulateMsgFundCommunityPool(txConfig client.TxConfig, ak types.AccountKeeper, bk types.BankKeeper, k keeper.Keeper) simtypes.Operation { return func( - r *rand.Rand, app *baseapp.BaseApp, ctx sdk.Context, accs []simtypes.Account, chainID string, + r *rand.Rand, app simtypes.AppEntrypoint, ctx sdk.Context, accs []simtypes.Account, chainID string, ) (simtypes.OperationMsg, []simtypes.FutureOperation, error) { funder, _ := simtypes.RandomAcc(r, accs) diff --git a/x/protocolpool/simulation/proposals.go b/x/protocolpool/simulation/proposals.go index 9a1af074a53b..0afddda38f01 100644 --- a/x/protocolpool/simulation/proposals.go +++ b/x/protocolpool/simulation/proposals.go @@ -1,6 +1,7 @@ package simulation import ( + "context" "math/rand" coreaddress "cosmossdk.io/core/address" @@ -20,7 +21,7 @@ const ( func ProposalMsgs() []simtypes.WeightedProposalMsg { return []simtypes.WeightedProposalMsg{ - simulation.NewWeightedProposalMsg( + simulation.NewWeightedProposalMsgX( OpWeightMsgCommunityPoolSpend, DefaultWeightMsgCommunityPoolSpend, SimulateMsgCommunityPoolSpend, @@ -28,7 +29,7 @@ func ProposalMsgs() []simtypes.WeightedProposalMsg { } } -func SimulateMsgCommunityPoolSpend(r *rand.Rand, _ []simtypes.Account, cdc coreaddress.Codec) (sdk.Msg, error) { +func SimulateMsgCommunityPoolSpend(_ context.Context, r *rand.Rand, _ []simtypes.Account, cdc coreaddress.Codec) (sdk.Msg, error) { // use the default gov module account address as authority var authority sdk.AccAddress = address.Module("gov") diff --git a/x/protocolpool/simulation/proposals_test.go b/x/protocolpool/simulation/proposals_test.go index 96046c2589f9..b452b01970fc 100644 --- a/x/protocolpool/simulation/proposals_test.go +++ b/x/protocolpool/simulation/proposals_test.go @@ -1,6 +1,7 @@ package simulation_test import ( + "context" "math/rand" "testing" @@ -32,7 +33,7 @@ func TestProposalMsgs(t *testing.T) { assert.Equal(t, simulation.OpWeightMsgCommunityPoolSpend, w0.AppParamsKey()) assert.Equal(t, simulation.DefaultWeightMsgCommunityPoolSpend, w0.DefaultWeight()) - msg, err := w0.MsgSimulatorFn()(r, accounts, addressCodec) + msg, err := w0.MsgSimulatorFn()(context.Background(), r, accounts, addressCodec) assert.NilError(t, err) msgCommunityPoolSpend, ok := msg.(*pooltypes.MsgCommunityPoolSpend) assert.Assert(t, ok) diff --git a/x/protocolpool/types/errors.go b/x/protocolpool/types/errors.go index a3790136b971..160e30dc8a21 100644 --- a/x/protocolpool/types/errors.go +++ b/x/protocolpool/types/errors.go @@ -3,6 +3,6 @@ package types import "cosmossdk.io/errors" var ( - ErrInvalidSigner = errors.Register(ModuleName, 2, "expected authority account as only signer for community pool spend message") - ErrNoRecipientFund = errors.Register(ModuleName, 3, "no recipient found") + ErrInvalidSigner = errors.Register(ModuleName, 2, "expected authority account as only signer for community pool spend message") + ErrNoRecipientFound = errors.Register(ModuleName, 3, "no recipient found") ) diff --git a/x/protocolpool/types/genesis.go b/x/protocolpool/types/genesis.go index 632a36573469..08ad95eaf4bd 100644 --- a/x/protocolpool/types/genesis.go +++ b/x/protocolpool/types/genesis.go @@ -13,6 +13,8 @@ func NewGenesisState(cf []*ContinuousFund, budget []*Budget) *GenesisState { return &GenesisState{ ContinuousFund: cf, Budget: budget, + LastBalance: math.ZeroInt(), + Distributions: []*Distribution{}, } } diff --git a/x/protocolpool/types/genesis.pb.go b/x/protocolpool/types/genesis.pb.go index ee3d83938081..8118de396b5e 100644 --- a/x/protocolpool/types/genesis.pb.go +++ b/x/protocolpool/types/genesis.pb.go @@ -9,15 +9,19 @@ import ( _ "github.com/cosmos/cosmos-proto" _ "github.com/cosmos/gogoproto/gogoproto" proto "github.com/cosmos/gogoproto/proto" + github_com_cosmos_gogoproto_types "github.com/cosmos/gogoproto/types" + _ "google.golang.org/protobuf/types/known/timestamppb" io "io" math "math" math_bits "math/bits" + time "time" ) // Reference imports to suppress errors if they are not otherwise used. var _ = proto.Marshal var _ = fmt.Errorf var _ = math.Inf +var _ = time.Kitchen // This is a compile-time assertion to ensure that this generated file // is compatible with the proto package it is being compiled against. @@ -30,8 +34,14 @@ type GenesisState struct { // ContinuousFund defines the continuous funds at genesis. ContinuousFund []*ContinuousFund `protobuf:"bytes,1,rep,name=continuous_fund,json=continuousFund,proto3" json:"continuous_fund,omitempty"` // Budget defines the budget proposals at genesis. - Budget []*Budget `protobuf:"bytes,2,rep,name=budget,proto3" json:"budget,omitempty"` - ToDistribute cosmossdk_io_math.Int `protobuf:"bytes,3,opt,name=to_distribute,json=toDistribute,proto3,customtype=cosmossdk.io/math.Int" json:"to_distribute"` + Budget []*Budget `protobuf:"bytes,2,rep,name=budget,proto3" json:"budget,omitempty"` + // last_balance contains the amount of tokens yet to be distributed, will be zero if + // there are no funds to distribute. + LastBalance cosmossdk_io_math.Int `protobuf:"bytes,3,opt,name=last_balance,json=lastBalance,proto3,customtype=cosmossdk.io/math.Int" json:"last_balance"` + // distributions contains the list of distributions to be made to continuous + // funds and budgets. It contains time in order to distribute to non-expired + // funds only. + Distributions []*Distribution `protobuf:"bytes,4,rep,name=distributions,proto3" json:"distributions,omitempty"` } func (m *GenesisState) Reset() { *m = GenesisState{} } @@ -81,8 +91,61 @@ func (m *GenesisState) GetBudget() []*Budget { return nil } +func (m *GenesisState) GetDistributions() []*Distribution { + if m != nil { + return m.Distributions + } + return nil +} + +type Distribution struct { + Amount cosmossdk_io_math.Int `protobuf:"bytes,3,opt,name=amount,proto3,customtype=cosmossdk.io/math.Int" json:"amount"` + Time *time.Time `protobuf:"bytes,6,opt,name=time,proto3,stdtime" json:"time,omitempty"` +} + +func (m *Distribution) Reset() { *m = Distribution{} } +func (m *Distribution) String() string { return proto.CompactTextString(m) } +func (*Distribution) ProtoMessage() {} +func (*Distribution) Descriptor() ([]byte, []int) { + return fileDescriptor_72560a99455b4146, []int{1} +} +func (m *Distribution) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *Distribution) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_Distribution.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *Distribution) XXX_Merge(src proto.Message) { + xxx_messageInfo_Distribution.Merge(m, src) +} +func (m *Distribution) XXX_Size() int { + return m.Size() +} +func (m *Distribution) XXX_DiscardUnknown() { + xxx_messageInfo_Distribution.DiscardUnknown(m) +} + +var xxx_messageInfo_Distribution proto.InternalMessageInfo + +func (m *Distribution) GetTime() *time.Time { + if m != nil { + return m.Time + } + return nil +} + func init() { proto.RegisterType((*GenesisState)(nil), "cosmos.protocolpool.v1.GenesisState") + proto.RegisterType((*Distribution)(nil), "cosmos.protocolpool.v1.Distribution") } func init() { @@ -90,26 +153,32 @@ func init() { } var fileDescriptor_72560a99455b4146 = []byte{ - // 290 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x52, 0x49, 0xce, 0x2f, 0xce, - 0xcd, 0x2f, 0xd6, 0x2f, 0x28, 0xca, 0x2f, 0xc9, 0x4f, 0xce, 0xcf, 0x29, 0xc8, 0xcf, 0xcf, 0xd1, - 0x2f, 0x33, 0xd4, 0x4f, 0x4f, 0xcd, 0x4b, 0x2d, 0xce, 0x2c, 0xd6, 0x03, 0x8b, 0x0b, 0x89, 0x41, - 0x54, 0xe9, 0x21, 0xab, 0xd2, 0x2b, 0x33, 0x94, 0x52, 0xc2, 0xa1, 0xbb, 0xa4, 0xb2, 0x20, 0x15, - 0xaa, 0x5a, 0x4a, 0x24, 0x3d, 0x3f, 0x3d, 0x1f, 0xcc, 0xd4, 0x07, 0xb1, 0xa0, 0xa2, 0x92, 0x10, - 0x9d, 0xf1, 0x10, 0x09, 0x64, 0xe3, 0x95, 0x5e, 0x32, 0x72, 0xf1, 0xb8, 0x43, 0xac, 0x0f, 0x2e, - 0x49, 0x2c, 0x49, 0x15, 0xf2, 0xe7, 0xe2, 0x4f, 0xce, 0xcf, 0x2b, 0xc9, 0xcc, 0x2b, 0xcd, 0x2f, - 0x2d, 0x8e, 0x4f, 0x2b, 0xcd, 0x4b, 0x91, 0x60, 0x54, 0x60, 0xd6, 0xe0, 0x36, 0x52, 0xd3, 0xc3, - 0xee, 0x2e, 0x3d, 0x67, 0xb8, 0x72, 0xb7, 0xd2, 0xbc, 0x94, 0x20, 0xbe, 0x64, 0x14, 0xbe, 0x90, - 0x19, 0x17, 0x5b, 0x52, 0x69, 0x4a, 0x7a, 0x6a, 0x89, 0x04, 0x13, 0xd8, 0x1c, 0x39, 0x5c, 0xe6, - 0x38, 0x81, 0x55, 0x05, 0x41, 0x55, 0x0b, 0x05, 0x70, 0xf1, 0x96, 0xe4, 0xc7, 0xa7, 0x64, 0x16, - 0x97, 0x14, 0x65, 0x26, 0x95, 0x96, 0xa4, 0x4a, 0x30, 0x2b, 0x30, 0x6a, 0x70, 0x3a, 0x69, 0x9f, - 0xb8, 0x27, 0xcf, 0x70, 0xeb, 0x9e, 0xbc, 0x28, 0xc4, 0x94, 0xe2, 0x94, 0x6c, 0xbd, 0xcc, 0x7c, - 0xfd, 0xdc, 0xc4, 0x92, 0x0c, 0x3d, 0xcf, 0xbc, 0x92, 0x4b, 0x5b, 0x74, 0xb9, 0xa0, 0xc6, 0x7b, - 0xe6, 0x95, 0x04, 0xf1, 0x94, 0xe4, 0xbb, 0xc0, 0x0d, 0x70, 0xb2, 0x3e, 0xf1, 0x48, 0x8e, 0xf1, - 0xc2, 0x23, 0x39, 0xc6, 0x07, 0x8f, 0xe4, 0x18, 0x27, 0x3c, 0x96, 0x63, 0xb8, 0xf0, 0x58, 0x8e, - 0xe1, 0xc6, 0x63, 0x39, 0x86, 0x28, 0x45, 0x14, 0xc3, 0x2a, 0x50, 0x83, 0x18, 0x1c, 0xbe, 0x49, - 0x6c, 0x60, 0x31, 0x63, 0x40, 0x00, 0x00, 0x00, 0xff, 0xff, 0x1e, 0x8d, 0xab, 0x75, 0xc4, 0x01, - 0x00, 0x00, + // 393 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x9c, 0x92, 0xcf, 0xca, 0xd3, 0x40, + 0x14, 0xc5, 0x33, 0x5f, 0x4b, 0xc0, 0x69, 0x55, 0x08, 0x2a, 0x31, 0x8b, 0xa4, 0x96, 0x22, 0x05, + 0x71, 0x42, 0xab, 0xb8, 0x71, 0x97, 0x8a, 0x52, 0x17, 0x0a, 0xd1, 0x95, 0x9b, 0x92, 0x3f, 0xd3, + 0x18, 0x4c, 0xe6, 0x86, 0xce, 0x4c, 0xd1, 0x47, 0x70, 0xd7, 0x77, 0xd1, 0x87, 0xe8, 0xb2, 0xb8, + 0x12, 0x17, 0x55, 0xda, 0x17, 0x91, 0xce, 0xa4, 0x92, 0x80, 0xdd, 0x7c, 0xbb, 0xc9, 0xbd, 0xbf, + 0x73, 0x72, 0xe0, 0x5c, 0x3c, 0x4a, 0x80, 0x97, 0xc0, 0xfd, 0x6a, 0x05, 0x02, 0x12, 0x28, 0x2a, + 0x80, 0xc2, 0x5f, 0x4f, 0xfc, 0x8c, 0x32, 0xca, 0x73, 0x4e, 0xd4, 0xdc, 0xba, 0xa7, 0x29, 0xd2, + 0xa4, 0xc8, 0x7a, 0xe2, 0x0c, 0x2f, 0xa8, 0xc5, 0x97, 0x8a, 0xd6, 0xb4, 0x73, 0x27, 0x83, 0x0c, + 0xd4, 0xd3, 0x3f, 0xbd, 0xea, 0xe9, 0x7d, 0xad, 0x5c, 0xe8, 0x45, 0xd3, 0xde, 0xf1, 0x32, 0x80, + 0xac, 0xa0, 0xda, 0x34, 0x96, 0x4b, 0x5f, 0xe4, 0x25, 0xe5, 0x22, 0x2a, 0x2b, 0x0d, 0x0c, 0xbf, + 0x5d, 0xe1, 0xfe, 0x2b, 0x9d, 0xef, 0x9d, 0x88, 0x04, 0xb5, 0xde, 0xe2, 0xdb, 0x09, 0x30, 0x91, + 0x33, 0x09, 0x92, 0x2f, 0x96, 0x92, 0xa5, 0x36, 0x1a, 0x74, 0xc6, 0xbd, 0xe9, 0x43, 0xf2, 0xff, + 0xe0, 0x64, 0xf6, 0x0f, 0x7f, 0x29, 0x59, 0x1a, 0xde, 0x4a, 0x5a, 0xdf, 0xd6, 0x33, 0x6c, 0xc6, + 0x32, 0xcd, 0xa8, 0xb0, 0xaf, 0x94, 0x8f, 0x7b, 0xc9, 0x27, 0x50, 0x54, 0x58, 0xd3, 0xd6, 0x1b, + 0xdc, 0x2f, 0x22, 0x2e, 0x16, 0x71, 0x54, 0x44, 0x2c, 0xa1, 0x76, 0x67, 0x80, 0xc6, 0x37, 0x82, + 0x47, 0xdb, 0xbd, 0x67, 0xfc, 0xda, 0x7b, 0x77, 0xb5, 0x09, 0x4f, 0x3f, 0x91, 0x1c, 0xfc, 0x32, + 0x12, 0x1f, 0xc9, 0x9c, 0x89, 0x1f, 0xdf, 0x1f, 0xe3, 0xda, 0x7d, 0xce, 0x44, 0xd8, 0x3b, 0x19, + 0x04, 0x5a, 0x6f, 0xbd, 0xc6, 0x37, 0xd3, 0x9c, 0x8b, 0x55, 0x1e, 0x4b, 0x91, 0x03, 0xe3, 0x76, + 0x57, 0xc5, 0x19, 0x5d, 0x8a, 0xf3, 0xa2, 0x01, 0x87, 0x6d, 0xe9, 0xf0, 0x2b, 0xc2, 0xfd, 0xe6, + 0xde, 0x9a, 0x61, 0x33, 0x2a, 0x41, 0x32, 0x71, 0x9d, 0x98, 0xb5, 0xd4, 0x7a, 0x8a, 0xbb, 0xa7, + 0x7a, 0x6c, 0x73, 0x80, 0xc6, 0xbd, 0xa9, 0x43, 0x74, 0x77, 0xe4, 0xdc, 0x1d, 0x79, 0x7f, 0xee, + 0x2e, 0xe8, 0x6e, 0x7e, 0x7b, 0x28, 0x54, 0x74, 0xf0, 0x7c, 0x7b, 0x70, 0xd1, 0xee, 0xe0, 0xa2, + 0x3f, 0x07, 0x17, 0x6d, 0x8e, 0xae, 0xb1, 0x3b, 0xba, 0xc6, 0xcf, 0xa3, 0x6b, 0x7c, 0x78, 0xd0, + 0xfa, 0xf9, 0xe7, 0xf6, 0x65, 0xa9, 0xb3, 0x8a, 0x4d, 0x35, 0x7b, 0xf2, 0x37, 0x00, 0x00, 0xff, + 0xff, 0x0c, 0x77, 0xdd, 0xf7, 0xbb, 0x02, 0x00, 0x00, } func (m *GenesisState) Marshal() (dAtA []byte, err error) { @@ -132,10 +201,24 @@ func (m *GenesisState) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l + if len(m.Distributions) > 0 { + for iNdEx := len(m.Distributions) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.Distributions[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintGenesis(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x22 + } + } { - size := m.ToDistribute.Size() + size := m.LastBalance.Size() i -= size - if _, err := m.ToDistribute.MarshalTo(dAtA[i:]); err != nil { + if _, err := m.LastBalance.MarshalTo(dAtA[i:]); err != nil { return 0, err } i = encodeVarintGenesis(dAtA, i, uint64(size)) @@ -173,6 +256,49 @@ func (m *GenesisState) MarshalToSizedBuffer(dAtA []byte) (int, error) { return len(dAtA) - i, nil } +func (m *Distribution) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *Distribution) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *Distribution) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.Time != nil { + n1, err1 := github_com_cosmos_gogoproto_types.StdTimeMarshalTo(*m.Time, dAtA[i-github_com_cosmos_gogoproto_types.SizeOfStdTime(*m.Time):]) + if err1 != nil { + return 0, err1 + } + i -= n1 + i = encodeVarintGenesis(dAtA, i, uint64(n1)) + i-- + dAtA[i] = 0x32 + } + { + size := m.Amount.Size() + i -= size + if _, err := m.Amount.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintGenesis(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x1a + return len(dAtA) - i, nil +} + func encodeVarintGenesis(dAtA []byte, offset int, v uint64) int { offset -= sovGenesis(v) base := offset @@ -202,8 +328,29 @@ func (m *GenesisState) Size() (n int) { n += 1 + l + sovGenesis(uint64(l)) } } - l = m.ToDistribute.Size() + l = m.LastBalance.Size() n += 1 + l + sovGenesis(uint64(l)) + if len(m.Distributions) > 0 { + for _, e := range m.Distributions { + l = e.Size() + n += 1 + l + sovGenesis(uint64(l)) + } + } + return n +} + +func (m *Distribution) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = m.Amount.Size() + n += 1 + l + sovGenesis(uint64(l)) + if m.Time != nil { + l = github_com_cosmos_gogoproto_types.SizeOfStdTime(*m.Time) + n += 1 + l + sovGenesis(uint64(l)) + } return n } @@ -312,7 +459,125 @@ func (m *GenesisState) Unmarshal(dAtA []byte) error { iNdEx = postIndex case 3: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field ToDistribute", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field LastBalance", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenesis + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthGenesis + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthGenesis + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.LastBalance.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Distributions", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenesis + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthGenesis + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthGenesis + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Distributions = append(m.Distributions, &Distribution{}) + if err := m.Distributions[len(m.Distributions)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipGenesis(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthGenesis + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *Distribution) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenesis + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: Distribution: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: Distribution: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Amount", wireType) } var stringLen uint64 for shift := uint(0); ; shift += 7 { @@ -340,7 +605,43 @@ func (m *GenesisState) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - if err := m.ToDistribute.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + if err := m.Amount.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 6: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Time", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenesis + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthGenesis + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthGenesis + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.Time == nil { + m.Time = new(time.Time) + } + if err := github_com_cosmos_gogoproto_types.StdTimeUnmarshal(m.Time, dAtA[iNdEx:postIndex]); err != nil { return err } iNdEx = postIndex diff --git a/x/protocolpool/types/keys.go b/x/protocolpool/types/keys.go index acb721c5edd2..072052937b55 100644 --- a/x/protocolpool/types/keys.go +++ b/x/protocolpool/types/keys.go @@ -9,6 +9,9 @@ const ( // StreamAccount is the name constant used for stream account StreamAccount = "stream_acc" + // ProtocolPoolDistrAccount is an intermediary account that holds the funds to be distributed to the protocolpool accounts. + ProtocolPoolDistrAccount = "protocolpool_distr" + // StoreKey is the store key string for protocolpool StoreKey = ModuleName @@ -26,5 +29,6 @@ var ( ContinuousFundKey = collections.NewPrefix(3) RecipientFundPercentageKey = collections.NewPrefix(4) RecipientFundDistributionKey = collections.NewPrefix(5) - ToDistributeKey = collections.NewPrefix(6) + DistributionsKey = collections.NewPrefix(6) + LastBalanceKey = collections.NewPrefix(7) ) diff --git a/x/simulation/params.go b/x/simulation/params.go index da62ffe1e87a..4fce44cff82e 100644 --- a/x/simulation/params.go +++ b/x/simulation/params.go @@ -1,15 +1,18 @@ package simulation import ( + "context" "encoding/json" "math/rand" cmtproto "github.com/cometbft/cometbft/api/cometbft/types/v1" "github.com/cometbft/cometbft/types" + "cosmossdk.io/core/address" stakingtypes "cosmossdk.io/x/staking/types" "github.com/cosmos/cosmos-sdk/codec" + sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/simulation" ) @@ -125,13 +128,20 @@ func NewSimLegacyParamChange(subspace, key string, simVal simulation.SimValFn) s // WeightedProposalMsg defines a common struct for proposal msgs defined by external modules (i.e outside gov) type WeightedProposalMsg struct { - appParamsKey string // key used to retrieve the value of the weight from the simulation application params - defaultWeight int // default weight - msgSimulatorFn simulation.MsgSimulatorFn // msg simulator function + appParamsKey string // key used to retrieve the value of the weight from the simulation application params + defaultWeight int // default weight + msgSimulatorFnX simulation.MsgSimulatorFnX // msg simulator function } +// Deprecated: use NewWeightedProposalMsgX instead func NewWeightedProposalMsg(appParamsKey string, defaultWeight int, msgSimulatorFn simulation.MsgSimulatorFn) simulation.WeightedProposalMsg { - return &WeightedProposalMsg{appParamsKey: appParamsKey, defaultWeight: defaultWeight, msgSimulatorFn: msgSimulatorFn} + return NewWeightedProposalMsgX(appParamsKey, defaultWeight, func(_ context.Context, r *rand.Rand, accs []simulation.Account, cdc address.Codec) (sdk.Msg, error) { + return msgSimulatorFn(r, accs, cdc) + }) +} + +func NewWeightedProposalMsgX(appParamsKey string, defaultWeight int, msgSimulatorFn simulation.MsgSimulatorFnX) simulation.WeightedProposalMsg { + return &WeightedProposalMsg{appParamsKey: appParamsKey, defaultWeight: defaultWeight, msgSimulatorFnX: msgSimulatorFn} } func (w WeightedProposalMsg) AppParamsKey() string { @@ -142,8 +152,8 @@ func (w WeightedProposalMsg) DefaultWeight() int { return w.defaultWeight } -func (w WeightedProposalMsg) MsgSimulatorFn() simulation.MsgSimulatorFn { - return w.msgSimulatorFn +func (w WeightedProposalMsg) MsgSimulatorFn() simulation.MsgSimulatorFnX { + return w.msgSimulatorFnX } // Legacy Proposal Content diff --git a/x/simulation/simulate.go b/x/simulation/simulate.go index 15bbd353cc2c..cd4fbe590799 100644 --- a/x/simulation/simulate.go +++ b/x/simulation/simulate.go @@ -16,7 +16,7 @@ import ( "cosmossdk.io/core/address" "cosmossdk.io/core/header" - "cosmossdk.io/core/log" + corelog "cosmossdk.io/core/log" "github.com/cosmos/cosmos-sdk/baseapp" "github.com/cosmos/cosmos-sdk/codec" @@ -61,7 +61,7 @@ func initChain( // operations, testing the provided invariants, but using the provided config.Seed. func SimulateFromSeed( // exists for backwards compatibility only tb testing.TB, - logger log.Logger, + logger corelog.Logger, w io.Writer, app *baseapp.BaseApp, appStateFn simulation.AppStateFn, @@ -81,7 +81,7 @@ func SimulateFromSeed( // exists for backwards compatibility only // operations, testing the provided invariants, but using the provided config.Seed. func SimulateFromSeedX( tb testing.TB, - logger log.Logger, + logger corelog.Logger, w io.Writer, app *baseapp.BaseApp, appStateFn simulation.AppStateFn, diff --git a/x/simulation/util.go b/x/simulation/util.go index 5fba0973f850..c2a3cdcd7bad 100644 --- a/x/simulation/util.go +++ b/x/simulation/util.go @@ -6,7 +6,6 @@ import ( "math/rand" "testing" - "github.com/cosmos/cosmos-sdk/baseapp" "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/codec" simtestutil "github.com/cosmos/cosmos-sdk/testutil/sims" @@ -65,7 +64,7 @@ func mustMarshalJSONIndent(o interface{}) []byte { // OperationInput is a struct that holds all the needed values to generate a tx and deliver it type OperationInput struct { R *rand.Rand - App *baseapp.BaseApp + App simtypes.AppEntrypoint TxGen client.TxConfig Cdc *codec.ProtoCodec Msg sdk.Msg diff --git a/x/slashing/go.mod b/x/slashing/go.mod index 0c254b35add6..011b2cf84175 100644 --- a/x/slashing/go.mod +++ b/x/slashing/go.mod @@ -7,7 +7,7 @@ require ( cosmossdk.io/collections v0.4.0 cosmossdk.io/core v0.12.1-0.20231114100755-569e3ff6a0d7 cosmossdk.io/core/testing v0.0.0-00010101000000-000000000000 - cosmossdk.io/depinject v1.0.0-alpha.4 + cosmossdk.io/depinject v1.0.0 cosmossdk.io/errors v1.0.1 cosmossdk.io/math v1.3.0 cosmossdk.io/store v1.1.1-0.20240418092142-896cdf1971bc @@ -15,7 +15,7 @@ require ( cosmossdk.io/x/staking v0.0.0-00010101000000-000000000000 github.com/bits-and-blooms/bitset v1.10.0 github.com/cosmos/cosmos-proto v1.0.0-beta.5 - github.com/cosmos/cosmos-sdk v0.51.0 + github.com/cosmos/cosmos-sdk v0.53.0 github.com/cosmos/gogoproto v1.5.0 github.com/golang/mock v1.6.0 github.com/golang/protobuf v1.5.4 @@ -58,7 +58,7 @@ require ( github.com/cosmos/crypto v0.1.2 // indirect github.com/cosmos/go-bip39 v1.0.0 // indirect github.com/cosmos/gogogateway v1.2.0 // indirect - github.com/cosmos/iavl v1.2.0 // indirect + github.com/cosmos/iavl v1.2.1-0.20240725141113-7adc688cf179 // indirect github.com/cosmos/ics23/go v0.10.0 // indirect github.com/cosmos/ledger-cosmos-go v0.13.3 // indirect github.com/danieljoos/wincred v1.2.1 // indirect @@ -178,8 +178,6 @@ replace ( cosmossdk.io/api => ../../api cosmossdk.io/core => ../../core cosmossdk.io/core/testing => ../../core/testing - cosmossdk.io/depinject => ../../depinject - cosmossdk.io/log => ../../log cosmossdk.io/x/accounts => ../accounts cosmossdk.io/x/auth => ../auth cosmossdk.io/x/bank => ../bank diff --git a/x/slashing/go.sum b/x/slashing/go.sum index 7bcffe139a9a..6a7a5c664517 100644 --- a/x/slashing/go.sum +++ b/x/slashing/go.sum @@ -6,8 +6,12 @@ cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMT cloud.google.com/go v0.34.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= cosmossdk.io/collections v0.4.0 h1:PFmwj2W8szgpD5nOd8GWH6AbYNi1f2J6akWXJ7P5t9s= cosmossdk.io/collections v0.4.0/go.mod h1:oa5lUING2dP+gdDquow+QjlF45eL1t4TJDypgGd+tv0= +cosmossdk.io/depinject v1.0.0 h1:dQaTu6+O6askNXO06+jyeUAnF2/ssKwrrszP9t5q050= +cosmossdk.io/depinject v1.0.0/go.mod h1:zxK/h3HgHoA/eJVtiSsoaRaRA2D5U4cJ5thIG4ssbB8= cosmossdk.io/errors v1.0.1 h1:bzu+Kcr0kS/1DuPBtUFdWjzLqyUuCiyHjyJB6srBV/0= cosmossdk.io/errors v1.0.1/go.mod h1:MeelVSZThMi4bEakzhhhE/CKqVv3nOJDA25bIqRDu/U= +cosmossdk.io/log v1.3.1 h1:UZx8nWIkfbbNEWusZqzAx3ZGvu54TZacWib3EzUYmGI= +cosmossdk.io/log v1.3.1/go.mod h1:2/dIomt8mKdk6vl3OWJcPk2be3pGOS8OQaLUM/3/tCM= cosmossdk.io/math v1.3.0 h1:RC+jryuKeytIiictDslBP9i1fhkVm6ZDmZEoNP316zE= cosmossdk.io/math v1.3.0/go.mod h1:vnRTxewy+M7BtXBNFybkuhSH4WfedVAAnERHgVFhp3k= cosmossdk.io/schema v0.1.1 h1:I0M6pgI7R10nq+/HCQfbO6BsGBZA8sQy+duR1Y3aKcA= @@ -113,8 +117,8 @@ github.com/cosmos/gogogateway v1.2.0/go.mod h1:iQpLkGWxYcnCdz5iAdLcRBSw3h7NXeOkZ github.com/cosmos/gogoproto v1.4.2/go.mod h1:cLxOsn1ljAHSV527CHOtaIP91kK6cCrZETRBrkzItWU= github.com/cosmos/gogoproto v1.5.0 h1:SDVwzEqZDDBoslaeZg+dGE55hdzHfgUA40pEanMh52o= github.com/cosmos/gogoproto v1.5.0/go.mod h1:iUM31aofn3ymidYG6bUR5ZFrk+Om8p5s754eMUcyp8I= -github.com/cosmos/iavl v1.2.0 h1:kVxTmjTh4k0Dh1VNL046v6BXqKziqMDzxo93oh3kOfM= -github.com/cosmos/iavl v1.2.0/go.mod h1:HidWWLVAtODJqFD6Hbne2Y0q3SdxByJepHUOeoH4LiI= +github.com/cosmos/iavl v1.2.1-0.20240725141113-7adc688cf179 h1:wmwDn7V3RodN9auB3FooSQxs46nHVE3u0mb87TJkZFE= +github.com/cosmos/iavl v1.2.1-0.20240725141113-7adc688cf179/go.mod h1:GiM43q0pB+uG53mLxLDzimxM9l/5N9UuSY3/D0huuVw= github.com/cosmos/ics23/go v0.10.0 h1:iXqLLgp2Lp+EdpIuwXTYIQU+AiHj9mOC2X9ab++bZDM= github.com/cosmos/ics23/go v0.10.0/go.mod h1:ZfJSmng/TBNTBkFemHHHj5YY7VAU/MBU980F4VU1NG0= github.com/cosmos/ledger-cosmos-go v0.13.3 h1:7ehuBGuyIytsXbd4MP43mLeoN2LTOEnk5nvue4rK+yM= diff --git a/x/slashing/simulation/operations.go b/x/slashing/simulation/operations.go index 45f61af3a999..e14cef141346 100644 --- a/x/slashing/simulation/operations.go +++ b/x/slashing/simulation/operations.go @@ -7,7 +7,6 @@ import ( "cosmossdk.io/x/slashing/keeper" "cosmossdk.io/x/slashing/types" - "github.com/cosmos/cosmos-sdk/baseapp" "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/codec" codectypes "github.com/cosmos/cosmos-sdk/codec/types" @@ -59,7 +58,7 @@ func SimulateMsgUnjail( sk types.StakingKeeper, ) simtypes.Operation { return func( - r *rand.Rand, app *baseapp.BaseApp, ctx sdk.Context, + r *rand.Rand, app simtypes.AppEntrypoint, ctx sdk.Context, accs []simtypes.Account, chainID string, ) (simtypes.OperationMsg, []simtypes.FutureOperation, error) { msgType := sdk.MsgTypeURL(&types.MsgUnjail{}) diff --git a/x/slashing/simulation/proposals.go b/x/slashing/simulation/proposals.go index 1ea39d97f19a..d625360de80f 100644 --- a/x/slashing/simulation/proposals.go +++ b/x/slashing/simulation/proposals.go @@ -1,6 +1,7 @@ package simulation import ( + "context" "math/rand" "time" @@ -24,7 +25,7 @@ const ( // ProposalMsgs defines the module weighted proposals' contents func ProposalMsgs() []simtypes.WeightedProposalMsg { return []simtypes.WeightedProposalMsg{ - simulation.NewWeightedProposalMsg( + simulation.NewWeightedProposalMsgX( OpWeightMsgUpdateParams, DefaultWeightMsgUpdateParams, SimulateMsgUpdateParams, @@ -33,7 +34,7 @@ func ProposalMsgs() []simtypes.WeightedProposalMsg { } // SimulateMsgUpdateParams returns a random MsgUpdateParams -func SimulateMsgUpdateParams(r *rand.Rand, _ []simtypes.Account, ac coreaddress.Codec) (sdk.Msg, error) { +func SimulateMsgUpdateParams(_ context.Context, r *rand.Rand, _ []simtypes.Account, ac coreaddress.Codec) (sdk.Msg, error) { // use the default gov module account address as authority var authority sdk.AccAddress = address.Module("gov") diff --git a/x/slashing/simulation/proposals_test.go b/x/slashing/simulation/proposals_test.go index d2b553964a00..f741f9ff689b 100644 --- a/x/slashing/simulation/proposals_test.go +++ b/x/slashing/simulation/proposals_test.go @@ -1,6 +1,7 @@ package simulation_test import ( + "context" "math/rand" "testing" "time" @@ -34,7 +35,7 @@ func TestProposalMsgs(t *testing.T) { assert.Equal(t, simulation.OpWeightMsgUpdateParams, w0.AppParamsKey()) assert.Equal(t, simulation.DefaultWeightMsgUpdateParams, w0.DefaultWeight()) - msg, err := w0.MsgSimulatorFn()(r, accounts, ac) + msg, err := w0.MsgSimulatorFn()(context.Background(), r, accounts, ac) assert.NilError(t, err) msgUpdateParams, ok := msg.(*types.MsgUpdateParams) assert.Assert(t, ok) diff --git a/x/staking/go.mod b/x/staking/go.mod index 9c3d495a8859..8d3086240a89 100644 --- a/x/staking/go.mod +++ b/x/staking/go.mod @@ -7,14 +7,14 @@ require ( cosmossdk.io/collections v0.4.0 cosmossdk.io/core v0.12.1-0.20231114100755-569e3ff6a0d7 cosmossdk.io/core/testing v0.0.0-00010101000000-000000000000 - cosmossdk.io/depinject v1.0.0-alpha.4 + cosmossdk.io/depinject v1.0.0 cosmossdk.io/errors v1.0.1 cosmossdk.io/math v1.3.0 cosmossdk.io/store v1.1.1-0.20240418092142-896cdf1971bc github.com/cometbft/cometbft v1.0.0-rc1 github.com/cometbft/cometbft/api v1.0.0-rc.1 github.com/cosmos/cosmos-proto v1.0.0-beta.5 - github.com/cosmos/cosmos-sdk v0.51.0 + github.com/cosmos/cosmos-sdk v0.53.0 github.com/cosmos/gogoproto v1.5.0 github.com/golang/mock v1.6.0 github.com/golang/protobuf v1.5.4 @@ -55,7 +55,7 @@ require ( github.com/cosmos/cosmos-db v1.0.2 // indirect github.com/cosmos/go-bip39 v1.0.0 // indirect github.com/cosmos/gogogateway v1.2.0 // indirect - github.com/cosmos/iavl v1.2.0 // indirect + github.com/cosmos/iavl v1.2.1-0.20240725141113-7adc688cf179 // indirect github.com/cosmos/ics23/go v0.10.0 // indirect github.com/cosmos/ledger-cosmos-go v0.13.3 // indirect github.com/danieljoos/wincred v1.2.1 // indirect @@ -158,7 +158,7 @@ require ( require ( buf.build/gen/go/cometbft/cometbft/protocolbuffers/go v1.34.2-20240701160653-fedbb9acfd2f.2 // indirect - cosmossdk.io/log v1.3.1 // indirect + cosmossdk.io/log v1.3.1 cosmossdk.io/x/consensus v0.0.0-00010101000000-000000000000 github.com/cosmos/crypto v0.1.2 // indirect github.com/dgraph-io/badger/v4 v4.2.0 // indirect @@ -183,8 +183,6 @@ replace ( cosmossdk.io/collections => ../../collections cosmossdk.io/core => ../../core cosmossdk.io/core/testing => ../../core/testing - cosmossdk.io/depinject => ../../depinject - cosmossdk.io/log => ../../log cosmossdk.io/x/accounts => ../accounts cosmossdk.io/x/auth => ../auth cosmossdk.io/x/bank => ../bank diff --git a/x/staking/go.sum b/x/staking/go.sum index 7c6b086874ef..4e269960625f 100644 --- a/x/staking/go.sum +++ b/x/staking/go.sum @@ -4,8 +4,12 @@ buf.build/gen/go/cosmos/gogo-proto/protocolbuffers/go v1.34.2-20240130113600-88e buf.build/gen/go/cosmos/gogo-proto/protocolbuffers/go v1.34.2-20240130113600-88ef6483f90f.2/go.mod h1:HqcXMSa5qnNuakaMUo+hWhF51mKbcrZxGl9Vp5EeJXc= cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= cloud.google.com/go v0.34.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= +cosmossdk.io/depinject v1.0.0 h1:dQaTu6+O6askNXO06+jyeUAnF2/ssKwrrszP9t5q050= +cosmossdk.io/depinject v1.0.0/go.mod h1:zxK/h3HgHoA/eJVtiSsoaRaRA2D5U4cJ5thIG4ssbB8= cosmossdk.io/errors v1.0.1 h1:bzu+Kcr0kS/1DuPBtUFdWjzLqyUuCiyHjyJB6srBV/0= cosmossdk.io/errors v1.0.1/go.mod h1:MeelVSZThMi4bEakzhhhE/CKqVv3nOJDA25bIqRDu/U= +cosmossdk.io/log v1.3.1 h1:UZx8nWIkfbbNEWusZqzAx3ZGvu54TZacWib3EzUYmGI= +cosmossdk.io/log v1.3.1/go.mod h1:2/dIomt8mKdk6vl3OWJcPk2be3pGOS8OQaLUM/3/tCM= cosmossdk.io/math v1.3.0 h1:RC+jryuKeytIiictDslBP9i1fhkVm6ZDmZEoNP316zE= cosmossdk.io/math v1.3.0/go.mod h1:vnRTxewy+M7BtXBNFybkuhSH4WfedVAAnERHgVFhp3k= cosmossdk.io/schema v0.1.1 h1:I0M6pgI7R10nq+/HCQfbO6BsGBZA8sQy+duR1Y3aKcA= @@ -109,8 +113,8 @@ github.com/cosmos/gogogateway v1.2.0/go.mod h1:iQpLkGWxYcnCdz5iAdLcRBSw3h7NXeOkZ github.com/cosmos/gogoproto v1.4.2/go.mod h1:cLxOsn1ljAHSV527CHOtaIP91kK6cCrZETRBrkzItWU= github.com/cosmos/gogoproto v1.5.0 h1:SDVwzEqZDDBoslaeZg+dGE55hdzHfgUA40pEanMh52o= github.com/cosmos/gogoproto v1.5.0/go.mod h1:iUM31aofn3ymidYG6bUR5ZFrk+Om8p5s754eMUcyp8I= -github.com/cosmos/iavl v1.2.0 h1:kVxTmjTh4k0Dh1VNL046v6BXqKziqMDzxo93oh3kOfM= -github.com/cosmos/iavl v1.2.0/go.mod h1:HidWWLVAtODJqFD6Hbne2Y0q3SdxByJepHUOeoH4LiI= +github.com/cosmos/iavl v1.2.1-0.20240725141113-7adc688cf179 h1:wmwDn7V3RodN9auB3FooSQxs46nHVE3u0mb87TJkZFE= +github.com/cosmos/iavl v1.2.1-0.20240725141113-7adc688cf179/go.mod h1:GiM43q0pB+uG53mLxLDzimxM9l/5N9UuSY3/D0huuVw= github.com/cosmos/ics23/go v0.10.0 h1:iXqLLgp2Lp+EdpIuwXTYIQU+AiHj9mOC2X9ab++bZDM= github.com/cosmos/ics23/go v0.10.0/go.mod h1:ZfJSmng/TBNTBkFemHHHj5YY7VAU/MBU980F4VU1NG0= github.com/cosmos/ledger-cosmos-go v0.13.3 h1:7ehuBGuyIytsXbd4MP43mLeoN2LTOEnk5nvue4rK+yM= diff --git a/x/staking/keeper/keeper_test.go b/x/staking/keeper/keeper_test.go index e148a7114ddd..0c4311a906ed 100644 --- a/x/staking/keeper/keeper_test.go +++ b/x/staking/keeper/keeper_test.go @@ -11,6 +11,7 @@ import ( "cosmossdk.io/collections" "cosmossdk.io/core/header" coretesting "cosmossdk.io/core/testing" + "cosmossdk.io/log" "cosmossdk.io/math" storetypes "cosmossdk.io/store/types" authtypes "cosmossdk.io/x/auth/types" @@ -65,7 +66,7 @@ func (s *KeeperTestSuite) SetupTest() { s.baseApp = baseapp.NewBaseApp( "staking", - coretesting.NewNopLogger(), + log.NewNopLogger(), testCtx.DB, encCfg.TxConfig.TxDecoder(), ) diff --git a/x/staking/keeper/slash.go b/x/staking/keeper/slash.go index 5179752a5b58..c7623d6b5c37 100644 --- a/x/staking/keeper/slash.go +++ b/x/staking/keeper/slash.go @@ -373,13 +373,12 @@ func (k Keeper) SlashRedelegation(ctx context.Context, srcValidator types.Valida if err != nil { return math.ZeroInt(), err } - sharesToUnbond, err := dstVal.SharesFromTokensTruncated(slashAmount) - if err != nil { - return math.ZeroInt(), err - } + sharesToUnbond, err := dstVal.SharesFromTokensTruncated(slashAmount) if sharesToUnbond.IsZero() { continue + } else if err != nil { + return math.ZeroInt(), err } // Delegations can be dynamic hence need to be looked up on every redelegation entry loop. diff --git a/x/staking/simulation/operations.go b/x/staking/simulation/operations.go index 7b3eecbbb6db..83ca16fb43c6 100644 --- a/x/staking/simulation/operations.go +++ b/x/staking/simulation/operations.go @@ -9,7 +9,6 @@ import ( "cosmossdk.io/x/staking/keeper" "cosmossdk.io/x/staking/types" - "github.com/cosmos/cosmos-sdk/baseapp" "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/codec" "github.com/cosmos/cosmos-sdk/testutil" @@ -124,7 +123,7 @@ func SimulateMsgCreateValidator( k *keeper.Keeper, ) simtypes.Operation { return func( - r *rand.Rand, app *baseapp.BaseApp, ctx sdk.Context, accs []simtypes.Account, chainID string, + r *rand.Rand, app simtypes.AppEntrypoint, ctx sdk.Context, accs []simtypes.Account, chainID string, ) (simtypes.OperationMsg, []simtypes.FutureOperation, error) { msgType := sdk.MsgTypeURL(&types.MsgCreateValidator{}) @@ -233,7 +232,7 @@ func SimulateMsgEditValidator( k *keeper.Keeper, ) simtypes.Operation { return func( - r *rand.Rand, app *baseapp.BaseApp, ctx sdk.Context, accs []simtypes.Account, chainID string, + r *rand.Rand, app simtypes.AppEntrypoint, ctx sdk.Context, accs []simtypes.Account, chainID string, ) (simtypes.OperationMsg, []simtypes.FutureOperation, error) { msgType := sdk.MsgTypeURL(&types.MsgEditValidator{}) @@ -308,7 +307,7 @@ func SimulateMsgDelegate( k *keeper.Keeper, ) simtypes.Operation { return func( - r *rand.Rand, app *baseapp.BaseApp, ctx sdk.Context, accs []simtypes.Account, chainID string, + r *rand.Rand, app simtypes.AppEntrypoint, ctx sdk.Context, accs []simtypes.Account, chainID string, ) (simtypes.OperationMsg, []simtypes.FutureOperation, error) { msgType := sdk.MsgTypeURL(&types.MsgDelegate{}) denom, err := k.BondDenom(ctx) @@ -390,7 +389,7 @@ func SimulateMsgUndelegate( k *keeper.Keeper, ) simtypes.Operation { return func( - r *rand.Rand, app *baseapp.BaseApp, ctx sdk.Context, accs []simtypes.Account, chainID string, + r *rand.Rand, app simtypes.AppEntrypoint, ctx sdk.Context, accs []simtypes.Account, chainID string, ) (simtypes.OperationMsg, []simtypes.FutureOperation, error) { msgType := sdk.MsgTypeURL(&types.MsgUndelegate{}) @@ -509,7 +508,7 @@ func SimulateMsgCancelUnbondingDelegate( k *keeper.Keeper, ) simtypes.Operation { return func( - r *rand.Rand, app *baseapp.BaseApp, ctx sdk.Context, accs []simtypes.Account, chainID string, + r *rand.Rand, app simtypes.AppEntrypoint, ctx sdk.Context, accs []simtypes.Account, chainID string, ) (simtypes.OperationMsg, []simtypes.FutureOperation, error) { msgType := sdk.MsgTypeURL(&types.MsgCancelUnbondingDelegation{}) @@ -613,7 +612,7 @@ func SimulateMsgBeginRedelegate( k *keeper.Keeper, ) simtypes.Operation { return func( - r *rand.Rand, app *baseapp.BaseApp, ctx sdk.Context, accs []simtypes.Account, chainID string, + r *rand.Rand, app simtypes.AppEntrypoint, ctx sdk.Context, accs []simtypes.Account, chainID string, ) (simtypes.OperationMsg, []simtypes.FutureOperation, error) { msgType := sdk.MsgTypeURL(&types.MsgBeginRedelegate{}) @@ -757,7 +756,7 @@ func SimulateMsgBeginRedelegate( func SimulateMsgRotateConsPubKey(txGen client.TxConfig, ak types.AccountKeeper, bk types.BankKeeper, k *keeper.Keeper) simtypes.Operation { return func( - r *rand.Rand, app *baseapp.BaseApp, ctx sdk.Context, accs []simtypes.Account, chainID string, + r *rand.Rand, app simtypes.AppEntrypoint, ctx sdk.Context, accs []simtypes.Account, chainID string, ) (simtypes.OperationMsg, []simtypes.FutureOperation, error) { msgType := sdk.MsgTypeURL(&types.MsgRotateConsPubKey{}) diff --git a/x/staking/simulation/proposals.go b/x/staking/simulation/proposals.go index 000984b46cdd..36afe6db90d3 100644 --- a/x/staking/simulation/proposals.go +++ b/x/staking/simulation/proposals.go @@ -1,11 +1,11 @@ package simulation import ( + "context" "math/rand" "time" coreaddress "cosmossdk.io/core/address" - sdkmath "cosmossdk.io/math" "cosmossdk.io/x/staking/types" sdk "github.com/cosmos/cosmos-sdk/types" @@ -24,7 +24,7 @@ const ( // ProposalMsgs defines the module weighted proposals' contents func ProposalMsgs() []simtypes.WeightedProposalMsg { return []simtypes.WeightedProposalMsg{ - simulation.NewWeightedProposalMsg( + simulation.NewWeightedProposalMsgX( OpWeightMsgUpdateParams, DefaultWeightMsgUpdateParams, SimulateMsgUpdateParams, @@ -33,17 +33,16 @@ func ProposalMsgs() []simtypes.WeightedProposalMsg { } // SimulateMsgUpdateParams returns a random MsgUpdateParams -func SimulateMsgUpdateParams(r *rand.Rand, _ []simtypes.Account, addressCodec coreaddress.Codec) (sdk.Msg, error) { +func SimulateMsgUpdateParams(_ context.Context, r *rand.Rand, _ []simtypes.Account, addressCodec coreaddress.Codec) (sdk.Msg, error) { // use the default gov module account address as authority var authority sdk.AccAddress = address.Module("gov") params := types.DefaultParams() - params.BondDenom = simtypes.RandStringOfLength(r, 10) params.HistoricalEntries = uint32(simtypes.RandIntBetween(r, 0, 1000)) params.MaxEntries = uint32(simtypes.RandIntBetween(r, 1, 1000)) params.MaxValidators = uint32(simtypes.RandIntBetween(r, 1, 1000)) params.UnbondingTime = time.Duration(simtypes.RandTimestamp(r).UnixNano()) - params.MinCommissionRate = simtypes.RandomDecAmount(r, sdkmath.LegacyNewDec(1)) + // changes to MinCommissionRate or BondDenom create issues for in flight messages or state operations addr, err := addressCodec.BytesToString(authority) if err != nil { diff --git a/x/staking/simulation/proposals_test.go b/x/staking/simulation/proposals_test.go index 64eb447a8559..4373ae15b290 100644 --- a/x/staking/simulation/proposals_test.go +++ b/x/staking/simulation/proposals_test.go @@ -1,13 +1,12 @@ package simulation_test import ( + "context" "math/rand" "testing" - "time" "gotest.tools/v3/assert" - sdkmath "cosmossdk.io/math" "cosmossdk.io/x/staking/simulation" "cosmossdk.io/x/staking/types" @@ -33,7 +32,7 @@ func TestProposalMsgs(t *testing.T) { assert.Equal(t, simulation.OpWeightMsgUpdateParams, w0.AppParamsKey()) assert.Equal(t, simulation.DefaultWeightMsgUpdateParams, w0.DefaultWeight()) - msg, err := w0.MsgSimulatorFn()(r, accounts, addressCodec) + msg, err := w0.MsgSimulatorFn()(context.Background(), r, accounts, addressCodec) assert.NilError(t, err) msgUpdateParams, ok := msg.(*types.MsgUpdateParams) assert.Assert(t, ok) @@ -42,10 +41,9 @@ func TestProposalMsgs(t *testing.T) { assert.NilError(t, err) assert.Equal(t, addr, msgUpdateParams.Authority) - assert.Equal(t, "GqiQWIXnku", msgUpdateParams.Params.BondDenom) - assert.Equal(t, uint32(213), msgUpdateParams.Params.MaxEntries) - assert.Equal(t, uint32(300), msgUpdateParams.Params.HistoricalEntries) - assert.Equal(t, uint32(539), msgUpdateParams.Params.MaxValidators) - assert.Equal(t, 8898194435*time.Second, msgUpdateParams.Params.UnbondingTime) - assert.DeepEqual(t, sdkmath.LegacyNewDecWithPrec(579040435581502128, 18), msgUpdateParams.Params.MinCommissionRate) + assert.Equal(t, "stake", msgUpdateParams.Params.BondDenom) + assert.Equal(t, uint32(905), msgUpdateParams.Params.MaxEntries) + assert.Equal(t, uint32(540), msgUpdateParams.Params.HistoricalEntries) + assert.Equal(t, uint32(151), msgUpdateParams.Params.MaxValidators) + assert.Equal(t, "2417694h42m25s", msgUpdateParams.Params.UnbondingTime.String()) } diff --git a/x/staking/testutil/expected_keepers_mocks.go b/x/staking/testutil/expected_keepers_mocks.go index e3004439c7b4..152d25e217f3 100644 --- a/x/staking/testutil/expected_keepers_mocks.go +++ b/x/staking/testutil/expected_keepers_mocks.go @@ -765,21 +765,6 @@ func (m *MockConsensusKeeper) EXPECT() *MockConsensusKeeperMockRecorder { return m.recorder } -// GetCometInfo mocks base method. -func (m *MockConsensusKeeper) GetCometInfo(arg0 context.Context, arg1 *types.QueryGetCometInfoRequest) (*types.QueryGetCometInfoResponse, error) { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "GetCometInfo", arg0, arg1) - ret0, _ := ret[0].(*types.QueryGetCometInfoResponse) - ret1, _ := ret[1].(error) - return ret0, ret1 -} - -// GetCometInfo indicates an expected call of GetCometInfo. -func (mr *MockConsensusKeeperMockRecorder) GetCometInfo(arg0, arg1 interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetCometInfo", reflect.TypeOf((*MockConsensusKeeper)(nil).GetCometInfo), arg0, arg1) -} - // Params mocks base method. func (m *MockConsensusKeeper) Params(arg0 context.Context, arg1 *types.QueryParamsRequest) (*types.QueryParamsResponse, error) { m.ctrl.T.Helper() diff --git a/x/staking/types/expected_keepers.go b/x/staking/types/expected_keepers.go index e10141452660..bd246775a8b6 100644 --- a/x/staking/types/expected_keepers.go +++ b/x/staking/types/expected_keepers.go @@ -118,5 +118,4 @@ func (StakingHooksWrapper) IsOnePerModuleType() {} type ConsensusKeeper interface { Params(context.Context, *consensustypes.QueryParamsRequest) (*consensustypes.QueryParamsResponse, error) - GetCometInfo(context.Context, *consensustypes.QueryGetCometInfoRequest) (*consensustypes.QueryGetCometInfoResponse, error) } diff --git a/x/staking/types/genesis.go b/x/staking/types/genesis.go index e144661afe55..e3534fc4ea58 100644 --- a/x/staking/types/genesis.go +++ b/x/staking/types/genesis.go @@ -3,8 +3,9 @@ package types import ( "encoding/json" + gogoprotoany "github.com/cosmos/gogoproto/types/any" + "github.com/cosmos/cosmos-sdk/codec" - codectypes "github.com/cosmos/cosmos-sdk/codec/types" ) // NewGenesisState creates a new GenesisState instance @@ -36,7 +37,7 @@ func GetGenesisStateFromAppState(cdc codec.JSONCodec, appState map[string]json.R } // UnpackInterfaces implements UnpackInterfacesMessage.UnpackInterfaces -func (g GenesisState) UnpackInterfaces(c codectypes.AnyUnpacker) error { +func (g GenesisState) UnpackInterfaces(c gogoprotoany.AnyUnpacker) error { for i := range g.Validators { if err := g.Validators[i].UnpackInterfaces(c); err != nil { return err diff --git a/x/staking/types/msg.go b/x/staking/types/msg.go index 3effad961f14..782183ff0684 100644 --- a/x/staking/types/msg.go +++ b/x/staking/types/msg.go @@ -1,6 +1,8 @@ package types import ( + gogoprotoany "github.com/cosmos/gogoproto/types/any" + "cosmossdk.io/core/address" coretransaction "cosmossdk.io/core/transaction" errorsmod "cosmossdk.io/errors" @@ -13,14 +15,14 @@ import ( ) var ( - _ coretransaction.Msg = &MsgCreateValidator{} - _ codectypes.UnpackInterfacesMessage = (*MsgCreateValidator)(nil) - _ coretransaction.Msg = &MsgEditValidator{} - _ coretransaction.Msg = &MsgDelegate{} - _ coretransaction.Msg = &MsgUndelegate{} - _ coretransaction.Msg = &MsgBeginRedelegate{} - _ coretransaction.Msg = &MsgCancelUnbondingDelegation{} - _ coretransaction.Msg = &MsgUpdateParams{} + _ coretransaction.Msg = &MsgCreateValidator{} + _ gogoprotoany.UnpackInterfacesMessage = (*MsgCreateValidator)(nil) + _ coretransaction.Msg = &MsgEditValidator{} + _ coretransaction.Msg = &MsgDelegate{} + _ coretransaction.Msg = &MsgUndelegate{} + _ coretransaction.Msg = &MsgBeginRedelegate{} + _ coretransaction.Msg = &MsgCancelUnbondingDelegation{} + _ coretransaction.Msg = &MsgUpdateParams{} ) // NewMsgCreateValidator creates a new MsgCreateValidator instance. @@ -89,7 +91,7 @@ func (msg MsgCreateValidator) Validate(ac address.Codec) error { } // UnpackInterfaces implements UnpackInterfacesMessage.UnpackInterfaces -func (msg MsgCreateValidator) UnpackInterfaces(unpacker codectypes.AnyUnpacker) error { +func (msg MsgCreateValidator) UnpackInterfaces(unpacker gogoprotoany.AnyUnpacker) error { var pubKey cryptotypes.PubKey return unpacker.UnpackAny(msg.Pubkey, &pubKey) } @@ -160,13 +162,13 @@ func NewMsgRotateConsPubKey(valAddr string, pubKey cryptotypes.PubKey) (*MsgRota } // UnpackInterfaces implements UnpackInterfacesMessage.UnpackInterfaces -func (msg MsgRotateConsPubKey) UnpackInterfaces(unpacker codectypes.AnyUnpacker) error { +func (msg MsgRotateConsPubKey) UnpackInterfaces(unpacker gogoprotoany.AnyUnpacker) error { var pubKey cryptotypes.PubKey return unpacker.UnpackAny(msg.NewPubkey, &pubKey) } // UnpackInterfaces implements UnpackInterfacesMessage.UnpackInterfaces -func (hi ConsPubKeyRotationHistory) UnpackInterfaces(unpacker codectypes.AnyUnpacker) error { +func (hi ConsPubKeyRotationHistory) UnpackInterfaces(unpacker gogoprotoany.AnyUnpacker) error { var oldPubKey cryptotypes.PubKey err := unpacker.UnpackAny(hi.OldConsPubkey, &oldPubKey) if err != nil { diff --git a/x/staking/types/validator.go b/x/staking/types/validator.go index 9906bc2b8009..c2e442d4c55a 100644 --- a/x/staking/types/validator.go +++ b/x/staking/types/validator.go @@ -7,6 +7,8 @@ import ( "strings" "time" + gogoprotoany "github.com/cosmos/gogoproto/types/any" + "cosmossdk.io/core/address" "cosmossdk.io/core/appmodule" "cosmossdk.io/errors" @@ -138,7 +140,7 @@ func (valz ValidatorsByVotingPower) Swap(i, j int) { } // UnpackInterfaces implements UnpackInterfacesMessage.UnpackInterfaces -func (v Validators) UnpackInterfaces(c codectypes.AnyUnpacker) error { +func (v Validators) UnpackInterfaces(c gogoprotoany.AnyUnpacker) error { for i := range v.Validators { if err := v.Validators[i].UnpackInterfaces(c); err != nil { return err @@ -494,7 +496,7 @@ func (v Validator) GetMinSelfDelegation() math.Int { return v.MinSelfDelegat func (v Validator) GetDelegatorShares() math.LegacyDec { return v.DelegatorShares } // UnpackInterfaces implements UnpackInterfacesMessage.UnpackInterfaces -func (v Validator) UnpackInterfaces(unpacker codectypes.AnyUnpacker) error { +func (v Validator) UnpackInterfaces(unpacker gogoprotoany.AnyUnpacker) error { var pk cryptotypes.PubKey return unpacker.UnpackAny(v.ConsensusPubkey, &pk) } diff --git a/x/tx/CHANGELOG.md b/x/tx/CHANGELOG.md index af095740513d..7dfbc54a8a73 100644 --- a/x/tx/CHANGELOG.md +++ b/x/tx/CHANGELOG.md @@ -33,6 +33,10 @@ Since v0.13.0, x/tx follows Cosmos SDK semver: https://github.com/cosmos/cosmos- ## [Unreleased] +### Improvements + +* [#21073](https://github.com/cosmos/cosmos-sdk/pull/21073) In Context use sync.Map `getSignersFuncs` map from concurrent writes, we also need to call Validate when using the legacy app. + ## [v0.13.3](https://github.com/cosmos/cosmos-sdk/releases/tag/x/tx/v0.13.3) - 2024-04-22 ### Improvements diff --git a/x/tx/signing/context.go b/x/tx/signing/context.go index 7aca6fd2b1cd..f44be0118cca 100644 --- a/x/tx/signing/context.go +++ b/x/tx/signing/context.go @@ -3,6 +3,7 @@ package signing import ( "errors" "fmt" + "sync" cosmos_proto "github.com/cosmos/cosmos-proto" gogoproto "github.com/cosmos/gogoproto/proto" @@ -29,7 +30,7 @@ type Context struct { typeResolver protoregistry.MessageTypeResolver addressCodec address.Codec validatorAddressCodec address.Codec - getSignersFuncs map[protoreflect.FullName]GetSignersFunc + getSignersFuncs sync.Map customGetSignerFuncs map[protoreflect.FullName]GetSignersFunc maxRecursionDepth int } @@ -110,7 +111,7 @@ func NewContext(options Options) (*Context, error) { typeResolver: protoTypes, addressCodec: options.AddressCodec, validatorAddressCodec: options.ValidatorAddressCodec, - getSignersFuncs: map[protoreflect.FullName]GetSignersFunc{}, + getSignersFuncs: sync.Map{}, customGetSignerFuncs: customGetSignerFuncs, maxRecursionDepth: options.MaxRecursionDepth, } @@ -334,14 +335,17 @@ func (c *Context) getGetSignersFn(messageDescriptor protoreflect.MessageDescript if ok { return f, nil } - f, ok = c.getSignersFuncs[messageDescriptor.FullName()] + + loadedFn, ok := c.getSignersFuncs.Load(messageDescriptor.FullName()) if !ok { var err error f, err = c.makeGetSignersFunc(messageDescriptor) if err != nil { return nil, err } - c.getSignersFuncs[messageDescriptor.FullName()] = f + c.getSignersFuncs.Store(messageDescriptor.FullName(), f) + } else { + f = loadedFn.(GetSignersFunc) } return f, nil diff --git a/x/tx/signing/context_test.go b/x/tx/signing/context_test.go index d8c2b370333a..88f0bf4aadf9 100644 --- a/x/tx/signing/context_test.go +++ b/x/tx/signing/context_test.go @@ -51,6 +51,21 @@ var deeplyNestedRepeatedSigner = &testpb.DeeplyNestedRepeatedSigner{ }, } +func TestGetGetSignersFnConcurrent(t *testing.T) { + ctx, err := NewContext(Options{ + AddressCodec: dummyAddressCodec{}, + ValidatorAddressCodec: dummyValidatorAddressCodec{}, + }) + require.NoError(t, err) + + desc := (&testpb.RepeatedSigner{}).ProtoReflect().Descriptor() + for i := 0; i < 50; i++ { + go func() { + _, _ = ctx.getGetSignersFn(desc) + }() + } +} + func TestGetSigners(t *testing.T) { ctx, err := NewContext(Options{ AddressCodec: dummyAddressCodec{}, diff --git a/x/upgrade/go.mod b/x/upgrade/go.mod index d530f48a27b0..cae69857a633 100644 --- a/x/upgrade/go.mod +++ b/x/upgrade/go.mod @@ -6,7 +6,7 @@ require ( cosmossdk.io/api v0.7.5 cosmossdk.io/core v0.12.1-0.20231114100755-569e3ff6a0d7 cosmossdk.io/core/testing v0.0.0-00010101000000-000000000000 - cosmossdk.io/depinject v1.0.0-alpha.4 + cosmossdk.io/depinject v1.0.0 cosmossdk.io/errors v1.0.1 cosmossdk.io/log v1.3.1 cosmossdk.io/store v1.1.1-0.20240418092142-896cdf1971bc @@ -17,7 +17,7 @@ require ( github.com/cometbft/cometbft/api v1.0.0-rc.1 github.com/cosmos/cosmos-db v1.0.2 github.com/cosmos/cosmos-proto v1.0.0-beta.5 - github.com/cosmos/cosmos-sdk v0.51.0 + github.com/cosmos/cosmos-sdk v0.53.0 github.com/cosmos/gogoproto v1.5.0 github.com/golang/protobuf v1.5.4 github.com/grpc-ecosystem/grpc-gateway v1.16.0 @@ -72,7 +72,7 @@ require ( github.com/cosmos/crypto v0.1.2 // indirect github.com/cosmos/go-bip39 v1.0.0 // indirect github.com/cosmos/gogogateway v1.2.0 // indirect - github.com/cosmos/iavl v1.2.0 // indirect + github.com/cosmos/iavl v1.2.1-0.20240725141113-7adc688cf179 // indirect github.com/cosmos/ics23/go v0.10.0 // indirect github.com/cosmos/ledger-cosmos-go v0.13.3 // indirect github.com/danieljoos/wincred v1.2.1 // indirect @@ -208,8 +208,7 @@ replace ( cosmossdk.io/api => ../../api cosmossdk.io/core => ../../core cosmossdk.io/core/testing => ../../core/testing - cosmossdk.io/depinject => ../../depinject - cosmossdk.io/log => ../../log + cosmossdk.io/store => ../../store cosmossdk.io/x/accounts => ../accounts cosmossdk.io/x/auth => ../auth cosmossdk.io/x/bank => ../bank diff --git a/x/upgrade/go.sum b/x/upgrade/go.sum index 5987b2057dcd..5e1769636979 100644 --- a/x/upgrade/go.sum +++ b/x/upgrade/go.sum @@ -194,14 +194,16 @@ cloud.google.com/go/workflows v1.6.0/go.mod h1:6t9F5h/unJz41YqfBmqSASJSXccBLtD1V cloud.google.com/go/workflows v1.7.0/go.mod h1:JhSrZuVZWuiDfKEFxU0/F1PQjmpnpcoISEXH2bcHC3M= cosmossdk.io/collections v0.4.0 h1:PFmwj2W8szgpD5nOd8GWH6AbYNi1f2J6akWXJ7P5t9s= cosmossdk.io/collections v0.4.0/go.mod h1:oa5lUING2dP+gdDquow+QjlF45eL1t4TJDypgGd+tv0= +cosmossdk.io/depinject v1.0.0 h1:dQaTu6+O6askNXO06+jyeUAnF2/ssKwrrszP9t5q050= +cosmossdk.io/depinject v1.0.0/go.mod h1:zxK/h3HgHoA/eJVtiSsoaRaRA2D5U4cJ5thIG4ssbB8= cosmossdk.io/errors v1.0.1 h1:bzu+Kcr0kS/1DuPBtUFdWjzLqyUuCiyHjyJB6srBV/0= cosmossdk.io/errors v1.0.1/go.mod h1:MeelVSZThMi4bEakzhhhE/CKqVv3nOJDA25bIqRDu/U= +cosmossdk.io/log v1.3.1 h1:UZx8nWIkfbbNEWusZqzAx3ZGvu54TZacWib3EzUYmGI= +cosmossdk.io/log v1.3.1/go.mod h1:2/dIomt8mKdk6vl3OWJcPk2be3pGOS8OQaLUM/3/tCM= cosmossdk.io/math v1.3.0 h1:RC+jryuKeytIiictDslBP9i1fhkVm6ZDmZEoNP316zE= cosmossdk.io/math v1.3.0/go.mod h1:vnRTxewy+M7BtXBNFybkuhSH4WfedVAAnERHgVFhp3k= cosmossdk.io/schema v0.1.1 h1:I0M6pgI7R10nq+/HCQfbO6BsGBZA8sQy+duR1Y3aKcA= cosmossdk.io/schema v0.1.1/go.mod h1:RDAhxIeNB4bYqAlF4NBJwRrgtnciMcyyg0DOKnhNZQQ= -cosmossdk.io/store v1.1.1-0.20240418092142-896cdf1971bc h1:R9O9d75e0qZYUsVV0zzi+D7cNLnX2JrUOQNoIPaF0Bg= -cosmossdk.io/store v1.1.1-0.20240418092142-896cdf1971bc/go.mod h1:amTTatOUV3u1PsKmNb87z6/galCxrRbz9kRdJkL0DyU= cosmossdk.io/x/protocolpool v0.0.0-20230925135524-a1bc045b3190 h1:XQJj9Dv9Gtze0l2TF79BU5lkP6MkUveTUuKICmxoz+o= cosmossdk.io/x/protocolpool v0.0.0-20230925135524-a1bc045b3190/go.mod h1:7WUGupOvmlHJoIMBz1JbObQxeo6/TDiuDBxmtod8HRg= dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU= @@ -319,8 +321,8 @@ github.com/cosmos/gogogateway v1.2.0/go.mod h1:iQpLkGWxYcnCdz5iAdLcRBSw3h7NXeOkZ github.com/cosmos/gogoproto v1.4.2/go.mod h1:cLxOsn1ljAHSV527CHOtaIP91kK6cCrZETRBrkzItWU= github.com/cosmos/gogoproto v1.5.0 h1:SDVwzEqZDDBoslaeZg+dGE55hdzHfgUA40pEanMh52o= github.com/cosmos/gogoproto v1.5.0/go.mod h1:iUM31aofn3ymidYG6bUR5ZFrk+Om8p5s754eMUcyp8I= -github.com/cosmos/iavl v1.2.0 h1:kVxTmjTh4k0Dh1VNL046v6BXqKziqMDzxo93oh3kOfM= -github.com/cosmos/iavl v1.2.0/go.mod h1:HidWWLVAtODJqFD6Hbne2Y0q3SdxByJepHUOeoH4LiI= +github.com/cosmos/iavl v1.2.1-0.20240725141113-7adc688cf179 h1:wmwDn7V3RodN9auB3FooSQxs46nHVE3u0mb87TJkZFE= +github.com/cosmos/iavl v1.2.1-0.20240725141113-7adc688cf179/go.mod h1:GiM43q0pB+uG53mLxLDzimxM9l/5N9UuSY3/D0huuVw= github.com/cosmos/ics23/go v0.10.0 h1:iXqLLgp2Lp+EdpIuwXTYIQU+AiHj9mOC2X9ab++bZDM= github.com/cosmos/ics23/go v0.10.0/go.mod h1:ZfJSmng/TBNTBkFemHHHj5YY7VAU/MBU980F4VU1NG0= github.com/cosmos/ledger-cosmos-go v0.13.3 h1:7ehuBGuyIytsXbd4MP43mLeoN2LTOEnk5nvue4rK+yM= diff --git a/x/upgrade/keeper/abci_test.go b/x/upgrade/keeper/abci_test.go index a07f49a7a282..4360a37797c1 100644 --- a/x/upgrade/keeper/abci_test.go +++ b/x/upgrade/keeper/abci_test.go @@ -13,6 +13,7 @@ import ( "cosmossdk.io/core/appmodule" "cosmossdk.io/core/header" coretesting "cosmossdk.io/core/testing" + "cosmossdk.io/log" storetypes "cosmossdk.io/store/types" authtypes "cosmossdk.io/x/auth/types" "cosmossdk.io/x/upgrade" @@ -122,7 +123,7 @@ func setupTest(t *testing.T, height int64, skip map[int64]bool) *TestSuite { testCtx := testutil.DefaultContextWithDB(t, key, storetypes.NewTransientStoreKey("transient_test")) s.baseApp = baseapp.NewBaseApp( "upgrade", - coretesting.NewNopLogger(), + log.NewNopLogger(), testCtx.DB, s.encCfg.TxConfig.TxDecoder(), ) diff --git a/x/upgrade/keeper/keeper_test.go b/x/upgrade/keeper/keeper_test.go index e26013a1b94b..a7add3e24f6e 100644 --- a/x/upgrade/keeper/keeper_test.go +++ b/x/upgrade/keeper/keeper_test.go @@ -12,6 +12,7 @@ import ( "cosmossdk.io/core/appmodule" "cosmossdk.io/core/header" coretesting "cosmossdk.io/core/testing" + "cosmossdk.io/log" storetypes "cosmossdk.io/store/types" authtypes "cosmossdk.io/x/auth/types" "cosmossdk.io/x/upgrade" @@ -54,7 +55,7 @@ func (s *KeeperTestSuite) SetupTest() { s.baseApp = baseapp.NewBaseApp( "upgrade", - coretesting.NewNopLogger(), + log.NewNopLogger(), testCtx.DB, s.encCfg.TxConfig.TxDecoder(), ) diff --git a/x/upgrade/types/storeloader_test.go b/x/upgrade/types/storeloader_test.go index 41f9e9956a5d..0d784b17ad6a 100644 --- a/x/upgrade/types/storeloader_test.go +++ b/x/upgrade/types/storeloader_test.go @@ -28,7 +28,7 @@ func useUpgradeLoader(height int64, upgrades *storetypes.StoreUpgrades) func(*ba func initStore(t *testing.T, db dbm.DB, storeKey string, k, v []byte) { t.Helper() - rs := rootmulti.NewStore(db, log.NewNopLogger(), metrics.NewNoOpMetrics()) + rs := rootmulti.NewStore(db, coretesting.NewNopLogger(), metrics.NewNoOpMetrics()) rs.SetPruning(pruningtypes.NewPruningOptions(pruningtypes.PruningNothing)) key := storetypes.NewKVStoreKey(storeKey) rs.MountStoreWithDB(key, storetypes.StoreTypeIAVL, nil) @@ -46,7 +46,7 @@ func initStore(t *testing.T, db dbm.DB, storeKey string, k, v []byte) { func checkStore(t *testing.T, db dbm.DB, ver int64, storeKey string, k, v []byte) { t.Helper() - rs := rootmulti.NewStore(db, log.NewNopLogger(), metrics.NewNoOpMetrics()) + rs := rootmulti.NewStore(db, coretesting.NewNopLogger(), metrics.NewNoOpMetrics()) rs.SetPruning(pruningtypes.NewPruningOptions(pruningtypes.PruningNothing)) key := storetypes.NewKVStoreKey(storeKey) rs.MountStoreWithDB(key, storetypes.StoreTypeIAVL, nil) @@ -119,9 +119,9 @@ func TestSetLoader(t *testing.T) { // load the app with the existing db opts := []func(*baseapp.BaseApp){baseapp.SetPruning(pruningtypes.NewPruningOptions(pruningtypes.PruningNothing))} - logger := coretesting.NewNopLogger() + logger := log.NewNopLogger() - oldApp := baseapp.NewBaseApp(t.Name(), logger.With("instance", "orig"), db, nil, opts...) + oldApp := baseapp.NewBaseApp(t.Name(), logger, db, nil, opts...) oldApp.MountStores(storetypes.NewKVStoreKey(tc.origStoreKey)) err := oldApp.LoadLatestVersion()