diff --git a/.github/workflows/backport.yml b/.github/workflows/backport.yml new file mode 100644 index 000000000..47c9985f6 --- /dev/null +++ b/.github/workflows/backport.yml @@ -0,0 +1,38 @@ +# Adapted from https://github.com/marketplace/actions/backporting +# +# Usage: +# - Let's say you want to backport a pull request on a branch named `production`. +# - Then label it with `backport production`. +# - That's it! When the pull request gets merged, it will be backported to +# the `production` branch. If the pull request cannot be backported, a comment +# explaining why will automatically be posted. +# +# Note: multiple backport labels can be added. For example, if a pull request +# has the labels `backport staging` and `backport production` it will be +# backported to both branches: `staging` and `production`. +name: Backport +on: + pull_request_target: + types: + - closed + - labeled + +jobs: + backport: + name: Backport + runs-on: ubuntu-latest + # Only react to merged PRs for security reasons. + # See https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#pull_request_target. + if: > + github.event.pull_request.merged + && ( + github.event.action == 'closed' + || ( + github.event.action == 'labeled' + && contains(github.event.label.name, 'backport') + ) + ) + steps: + - uses: tibdex/backport@v2 + with: + github_token: ${{ secrets.GITHUB_TOKEN }} \ No newline at end of file diff --git a/.github/workflows/changelog-reminder.yml b/.github/workflows/changelog-reminder.yml new file mode 100644 index 000000000..ebe2a5538 --- /dev/null +++ b/.github/workflows/changelog-reminder.yml @@ -0,0 +1,11 @@ +name: Changelog Reminder +on: + pull_request: + types: [assigned, opened, synchronize, reopened, labeled, unlabeled] + branches: + - main + +jobs: + changelog_reminder: + uses: babylonlabs-io/.github/.github/workflows/reusable_changelog_reminder.yml@v0.7.0 + secrets: inherit diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index f466cba4a..29e99fdd0 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -11,15 +11,17 @@ concurrency: jobs: lint_test: - uses: babylonlabs-io/.github/.github/workflows/reusable_go_lint_test.yml@v0.5.0 + uses: babylonlabs-io/.github/.github/workflows/reusable_go_lint_test.yml@v0.7.0 secrets: inherit with: + go-version: '1.23' + go-lint-version: 'v1.60.2' run-unit-tests: true run-integration-tests: false run-lint: true docker_pipeline: - uses: babylonlabs-io/.github/.github/workflows/reusable_docker_pipeline.yml@v0.5.0 + uses: babylonlabs-io/.github/.github/workflows/reusable_docker_pipeline.yml@v0.7.0 secrets: inherit with: publish: false @@ -47,29 +49,6 @@ jobs: name: babylond-${{ github.sha }} # so it renovates at every new sha path: /tmp/docker-babylond.tar.gz - e2e-docker-build-babylon-before-upgrade: - runs-on: ubuntu-22.04 - steps: - # - name: Artifact babylond-before-upgrade exists # TODO: check why it doesn't work to load from older workflow runs .-. - # uses: xSAVIKx/artifact-exists-action@v0 - # id: check-babylond-before-upgrade - # with: - # name: babylond-before-upgrade - - name: Checkout repository - uses: actions/checkout@v4 - - name: Build docker babylond-before-upgrade - run: | - make -C contrib/images babylond-before-upgrade - - name: Docker save babylond-before-upgrade - run: | - docker save -o /tmp/docker-babylond-before-upgrade.tar.gz babylonlabs-io/babylond-before-upgrade:latest - - name: Upload babylond-before-upgrade artifact - uses: actions/upload-artifact@v4 - with: - name: babylond-before-upgrade - path: /tmp/docker-babylond-before-upgrade.tar.gz - # retention-days: 90 active this back if artifact-exists-action works - e2e-docker-build-e2e-init-chain: runs-on: ubuntu-22.04 steps: @@ -127,7 +106,7 @@ jobs: - name: Cache Go uses: actions/setup-go@v5 with: - go-version: 1.21 + go-version: 1.23 - name: Run e2e TestIBCTranferTestSuite run: | make test-e2e-cache-ibc-transfer @@ -149,39 +128,12 @@ jobs: - name: Cache Go uses: actions/setup-go@v5 with: - go-version: 1.21 + go-version: 1.23 - name: Run e2e TestBTCTimestampingTestSuite run: | make test-e2e-cache-btc-timestamping - e2e-run-btc-timestamping-phase-2-hermes: - needs: [e2e-docker-build-babylon] - runs-on: ubuntu-22.04 - steps: - - name: Checkout repository - uses: actions/checkout@v4 - - name: Download babylon artifact - uses: actions/download-artifact@v4 - with: - name: babylond-${{ github.sha }} - path: /tmp - - name: Docker load babylond - run: | - docker load < /tmp/docker-babylond.tar.gz - - name: Login to Docker Hub - uses: docker/login-action@v3 - with: - username: ${{ secrets.DOCKERHUB_USERNAME }} - password: ${{ secrets.DOCKERHUB_TOKEN }} - - name: Cache Go - uses: actions/setup-go@v5 - with: - go-version: 1.21 - - name: Run e2e TestBTCTimestampingPhase2HermesTestSuite - run: | - make test-e2e-cache-btc-timestamping-phase-2-hermes - - e2e-run-btc-timestamping-phase-2-rly: + e2e-run-btc-staking: needs: [e2e-docker-build-babylon] runs-on: ubuntu-22.04 steps: @@ -195,20 +147,15 @@ jobs: - name: Docker load babylond run: | docker load < /tmp/docker-babylond.tar.gz - - name: Login to Docker Hub - uses: docker/login-action@v3 - with: - username: ${{ secrets.DOCKERHUB_USERNAME }} - password: ${{ secrets.DOCKERHUB_TOKEN }} - name: Cache Go uses: actions/setup-go@v5 with: - go-version: 1.21 - - name: Run e2e TestBTCTimestampingPhase2RlyTestSuite + go-version: 1.23 + - name: Run e2e TestBTCStakingTestSuite run: | - make test-e2e-cache-btc-timestamping-phase-2-rly + make test-e2e-cache-btc-staking - e2e-run-btc-staking: + e2e-run-btc-staking-pre-approval: needs: [e2e-docker-build-babylon] runs-on: ubuntu-22.04 steps: @@ -225,13 +172,16 @@ jobs: - name: Cache Go uses: actions/setup-go@v5 with: - go-version: 1.21 - - name: Run e2e TestBTCStakingTestSuite + go-version: 1.23 + - name: Run e2e TestBTCStakingPreApprovalTestSuite run: | - make test-e2e-cache-btc-staking + make test-e2e-cache-btc-staking-pre-approval - e2e-run-upgrade-signet: - needs: [e2e-docker-build-babylon, e2e-docker-build-babylon-before-upgrade, e2e-docker-build-e2e-init-chain] + # Disable this test because v1 upgrade does not cover integration features + # TODO: Reenable this test after having v2 upgrade + e2e-run-upgrade-v1: + if: false + needs: [e2e-docker-build-babylon, e2e-docker-build-e2e-init-chain] runs-on: ubuntu-22.04 steps: - name: Checkout repository @@ -241,11 +191,6 @@ jobs: with: name: babylond-${{ github.sha }} path: /tmp - - name: Download babylond-before-upgrade artifact - uses: actions/download-artifact@v4 - with: - name: babylond-before-upgrade - path: /tmp - name: Download init-chain artifact uses: actions/download-artifact@v4 with: @@ -255,10 +200,6 @@ jobs: run: | docker load < /tmp/docker-babylond.tar.gz - - name: Docker load babylond-before-upgrade - run: | - docker load < /tmp/docker-babylond-before-upgrade.tar.gz - - name: Docker load init chain run: | docker load < /tmp/docker-init-chain.tar.gz @@ -266,10 +207,13 @@ jobs: - name: Cache Go uses: actions/setup-go@v5 with: - go-version: 1.21 - - name: Run e2e TestSoftwareUpgradeSignetLaunchTestSuite + go-version: 1.23 + - name: Run e2e TestSoftwareUpgradeV1TestnetTestSuite run: | - sudo make test-e2e-cache-upgrade-signet + sudo make test-e2e-cache-upgrade-v1 + - name: Dump docker logs on failure + if: failure() + uses: jwalton/gh-docker-logs@v2 e2e-run-bcd-consumer-integration-test: needs: [e2e-docker-build-babylon, e2e-docker-build-ibcsim-bcd] @@ -300,6 +244,9 @@ jobs: - name: Start BCD consumer integration containers run: | sudo make -C contrib/images start-bcd-consumer-integration - - name: Run BCD consumer integration test + - name: Run BCD consumer integration test and dump logs run: | - sudo make test-e2e-cache-bcd-consumer-integration \ No newline at end of file + sudo make test-e2e-cache-bcd-consumer-integration + - name: Dump docker logs on failure + if: failure() + uses: jwalton/gh-docker-logs@v2 diff --git a/.github/workflows/goreleaser.yml b/.github/workflows/goreleaser.yml new file mode 100644 index 000000000..fae75527e --- /dev/null +++ b/.github/workflows/goreleaser.yml @@ -0,0 +1,13 @@ +name: goreleaser + +on: + release: + types: [published] + +permissions: + contents: write + +jobs: + release: + uses: babylonlabs-io/.github/.github/workflows/reusable_go_releaser.yml@v0.7.0 + secrets: inherit \ No newline at end of file diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 8f5d901cb..edf442a8a 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -10,15 +10,17 @@ on: jobs: lint_test: - uses: babylonlabs-io/.github/.github/workflows/reusable_go_lint_test.yml@v0.5.0 + uses: babylonlabs-io/.github/.github/workflows/reusable_go_lint_test.yml@v0.7.0 secrets: inherit with: + go-version: '1.23' + go-lint-version: 'v1.60.2' run-unit-tests: true run-integration-tests: false run-lint: true docker_pipeline: - uses: babylonlabs-io/.github/.github/workflows/reusable_docker_pipeline.yml@v0.5.0 + uses: babylonlabs-io/.github/.github/workflows/reusable_docker_pipeline.yml@v0.7.0 needs: ["lint_test"] secrets: inherit with: diff --git a/.gitignore b/.gitignore index 1919b38b7..ad778be8e 100644 --- a/.gitignore +++ b/.gitignore @@ -214,4 +214,5 @@ docs/diagrams/plantuml.jar .testnets/ .testnet/ mytestnet/ -output/ \ No newline at end of file +output/ +dist/ diff --git a/.goreleaser.yml b/.goreleaser.yml new file mode 100644 index 000000000..1ef75a523 --- /dev/null +++ b/.goreleaser.yml @@ -0,0 +1,57 @@ +version: 2 +project_name: babylon + +builds: + - id: babylond-linux-amd64 + main: ./cmd/babylond/main.go + binary: babylond + goos: + - linux + goarch: + - amd64 + env: + - GO111MODULE=on + flags: + - -mod=readonly + - -trimpath + ldflags: + - -X github.com/cosmos/cosmos-sdk/version.Name=babylon + - -X github.com/cosmos/cosmos-sdk/version.AppName=babylond + - -X github.com/cosmos/cosmos-sdk/version.Version={{ .Version }} + - -X github.com/cosmos/cosmos-sdk/version.Commit={{ .Commit }} + - -X github.com/cosmos/cosmos-sdk/version.BuildTags=netgo,ledger + - -w -s + tags: + - netgo + - ledger + +archives: + - id: zipped + builds: + - babylond-linux-amd64 + name_template: "{{.ProjectName}}-{{ .Version }}-{{ .Os }}-{{ .Arch }}" + format: tar.gz + files: + - none* + - id: binaries + builds: + - babylond-linux-amd64 + name_template: "{{.ProjectName}}-{{ .Version }}-{{ .Os }}-{{ .Arch }}" + format: binary + files: + - none* + +checksum: + name_template: "{{ .ProjectName }}_{{ .Version }}_checksums.txt" + algorithm: sha256 + +release: + github: + owner: babylonlabs-io + name: babylon + +# Docs: https://goreleaser.com/customization/changelog/ +changelog: + disable: true + +dist: dist diff --git a/CHANGELOG.md b/CHANGELOG.md index 4d0c0e9b4..a4d558525 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -65,6 +65,209 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) ## Unreleased + +### Bug fixes + +- [#270](https://github.com/babylonlabs-io/babylon/pull/270) Validate there is only +one finality provider key in the staking request + +### API Breaking + +- [#273](https://github.com/babylonlabs-io/babylon/pull/273) Add full staking tx to BTC delegation creation event +## v0.16.0 + +### Improvements + +* [#258](https://github.com/babylonlabs-io/babylon/pull/258) fix go releaser +and trigger by github action +* [#252](https://github.com/babylonlabs-io/babylon/pull/252) Fix +flunky TestValidateParsedMessageAgainstTheParams +* [#229](https://github.com/babylonlabs-io/babylon/pull/229) Remove babylond +e2e before upgrade +* [#250](https://github.com/babylonlabs-io/babylon/pull/250) Add tests for +unbonding value mismatch +* [#249](https://github.com/babylonlabs-io/babylon/pull/249) Add logs to checking +unbonding output +* [#253](https://github.com/babylonlabs-io/babylon/pull/253) Upgrade cometbft dependency +* [#256](https://github.com/babylonlabs-io/babylon/pull/256) Removes retry library +from core Babylon repository +* [#257](https://github.com/babylonlabs-io/babylon/pull/257) Fix error handling +in checkpointing module +* [#262](https://github.com/babylonlabs-io/babylon/pull/262) Upgrade wasmd, relayer dependencies + +### State Machine Breaking + +* [#260](https://github.com/babylonlabs-io/babylon/pull/260) Finish tokenomics +implementation +* [#254](https://github.com/babylonlabs-io/babylon/pull/254) Avoid constant +bech-32 decoding in power table +* [#265](https://github.com/babylonlabs-io/babylon/pull/265) Add allow list for staking txs + +## v0.15.0 + +### State Machine Breaking + +* [#211](https://github.com/babylonlabs-io/babylon/pull/211) Babylon inflation module +* [#217](https://github.com/babylonlabs-io/babylon/pull/217) Move voting power table to finality module + +### Improvements + +* [#235](https://github.com/babylonlabs-io/babylon/pull/235) Change default values +for iavl cache when using `testnet` command + +### API Breaking + +* [238](https://github.com/babylonlabs-io/babylon/pull/238) Add additional data +to delegation creation event + +## v0.14.1 + +### API Breaking + +* [#228](https://github.com/babylonlabs-io/babylon/pull/228) Add inclusion height to early unbonding event + +### State Machine Breaking + +* [#218](https://github.com/babylonlabs-io/babylon/pull/218) Fix removing voting +power during expiry + +## v0.14.0 + +### State Machine Breaking + +* [#224](https://github.com/babylonlabs-io/babylon/pull/224) Make injected checkpoint a standard tx +* [#207](https://github.com/babylonlabs-io/babylon/pull/207) Rename total voting power +to total bonded sat +* [#204](https://github.com/babylonlabs-io/babylon/pull/204) Add babylon finality +activation block height to start processing finality messages in `x/finality` params. +* [#215](https://github.com/babylonlabs-io/babylon/pull/215) Implement ADR-29 +generalized unbonding handler + +### Improvements + +* [#213](https://github.com/babylonlabs-io/babylon/pull/213) Bump wasmd and re-enable static linking +* [#210](https://github.com/babylonlabs-io/babylon/pull/210) Parameterize finality parameters in prepare-genesis cmd + +## v0.13.0 + +### API Breaking + +* [#194](https://github.com/babylonlabs-io/babylon/pull/194) Adjusted handling of `FinalityProviderSigningInfo` in finality keeper queries to improve API security. + * Modified `QuerySigningInfosResponse` to remove direct exposure of sensitive fields. + * Updated related tests in `x/finality/keeper/grpc_query_test.go`. +* [#200](https://github.com/babylonlabs-io/babylon/pull/200) Adjusted handling of `Gauge` in incentive keeper queries to improve API security. +* [#201](https://github.com/babylonlabs-io/babylon/pull/201) Adjusted handling of `ValidatorWithBlsKey` in checkpoint keeper queries to improve API security. +* [#202](https://github.com/babylonlabs-io/babylon/pull/202) Adjusted handling of `FinalityProviderWithMeta` in btcstaking keeper queries to improve API security. +* [#203](https://github.com/babylonlabs-io/babylon/pull/203) Adjusted handling of `RewardGauge` in incentive keeper queries to improve API security. +* [#208](https://github.com/babylonlabs-io/babylon/pull/208) Adjusted handling of `Evidence` in finality keeper queries to improve API security. + +### State Machine Breaking + +* [#181](https://github.com/babylonlabs-io/babylon/pull/181) Modify BTC heights + and depths to be of uint32 type instead of uint64. + +### Bug fixes + +* [#197](https://github.com/babylonlabs-io/babylon/pull/197) Fix `BTCDelgationResponse` missing `staking_time` +* [#193](https://github.com/babylonlabs-io/babylon/pull/193) Fix witness construction of slashing tx +* [#154](https://github.com/babylonlabs-io/babylon/pull/154) Fix "edit-finality-provider" cmd argument index +* [#186](https://github.com/babylonlabs-io/babylon/pull/186) Do not panic on `nil` +Proof when handling finality votes + +### Improvements + +* [#188](https://github.com/babylonlabs-io/babylon/pull/188) Simplify logic of FP set rotation +* [#169](https://github.com/babylonlabs-io/babylon/pull/169) Improve external events format and update events doc +* [#148](https://github.com/babylonlabs-io/babylon/pull/148) Add block results query + +### Misc Improvements + +* [#170](https://github.com/babylonlabs-io/babylon/pull/170) Go releaser setup +* [#168](https://github.com/babylonlabs-io/babylon/pull/168) Remove devdoc from + Makefile and remove unnecessary gin replace. +* [#184](https://github.com/babylonlabs-io/babylon/pull/184) Remove localnet + setup as it provides no additional testing value. + +## v0.12.1 + +### Bug fixes + +* [#180](https://github.com/babylonlabs-io/babylon/pull/180) Non-determinism in + sorting finality providers in the voting power table + +### Improvements + +* [#169](https://github.com/babylonlabs-io/babylon/pull/169) Improve external events format and update events doc + +### State Machine Breaking + +* [#185](https://github.com/babylonlabs-io/babylon/pull/185) Check that +unbonding / slashing transactions are standard + +## v0.12.0 + +### State Machine Breaking + +* [#132](https://github.com/babylonlabs-io/babylon/pull/132) Add CosmWasm parameters +update during v1 upgrade handler. +* [#142](https://github.com/babylonlabs-io/babylon/pull/142) Remove signed finality providers +insert from the v1 upgrade handler. + +### Improvements + +* [#151](https://github.com/babylonlabs-io/babylon/pull/151) Improve IBC transfer e2e test +* [#130](https://github.com/babylonlabs-io/babylon/pull/130) Fix bugs in the +transaction fee refunding mechanism for covenant signatures and finality signatures +* [#125](https://github.com/babylonlabs-io/babylon/pull/125) Implement ADR-028 and +refund transaction fee for certain transactions from protocol stakeholders +* [#137](https://github.com/babylonlabs-io/babylon/pull/137) Adapt tests to the +pre-approval flow. +* [#138](https://github.com/babylonlabs-io/babylon/pull/138) Intercept staking module +messages inside `authz.MsgExec`. +* [#146](https://github.com/babylonlabs-io/babylon/pull/146) Add property status as a filter +to BTC delegations rest request `QueryBTCDelegationsRequest`. +* [#144](https://github.com/babylonlabs-io/babylon/pull/144) Add new finality provider events +* [#131](https://github.com/babylonlabs-io/babylon/pull/131) Add new staking events +* [#113](https://github.com/babylonlabs-io/babylon/pull/113) Add multibuild binary +for upgrade handler `testnet` and `mainnet`. + +### Bug Fixes +* [#141](https://github.com/babylonlabs-io/babylon/pull/141) Generate voting +power events only once when reaching covenant committee quorum +* [#140](https://github.com/babylonlabs-io/babylon/pull/140) Removed `unbonding` +and add `verified` to delegation status parse `NewBTCDelegationStatusFromString`. + +## v0.11.0 + +### State Machine Breaking + +* [#107](https://github.com/babylonlabs-io/babylon/pull/107) Implement ADR-027 and +enable in-protocol minimum gas price +* [#103](https://github.com/babylonlabs-io/babylon/pull/103) Add token distribution +to upgrade handler and rename `signet-launch` to `v1` +* [#55](https://github.com/babylonlabs-io/babylon/pull/55) Remove `x/zoneconcierge` +module +* [#117](https://github.com/babylonlabs-io/babylon/pull/117) Add support for +pre-approval flow (ADR-026) + +### Bug fixes + +### Misc Improvements + +* [#106](https://github.com/babylonlabs-io/babylon/pull/106) Add CLI command for + querying signing info of finality providers. + +## v0.10.1 + +### Bug Fixes + +* [#91](https://github.com/babylonlabs-io/babylon/pull/91) fix testnet command +by add ibc default gen state and min gas price specification of `1ubbn` +* [#93](https://github.com/babylonlabs-io/babylon/pull/93) fix genesis epoch + initialization. + +## v0.10.0 + ### State Machine Breaking * [#45](https://github.com/babylonlabs-io/babylon/pull/45) Implement ADR-23 and improve diff --git a/Makefile b/Makefile index e9548cd2c..71536c9bf 100644 --- a/Makefile +++ b/Makefile @@ -79,6 +79,13 @@ ldflags = -X github.com/cosmos/cosmos-sdk/version.Name=babylon \ -X github.com/cosmos/cosmos-sdk/version.Commit=$(COMMIT) \ -X "github.com/cosmos/cosmos-sdk/version.BuildTags=$(build_tags_comma_sep)" +# Handles the inclusion of upgrade in binary +ifeq (testnet,$(findstring testnet,$(BABYLON_BUILD_OPTIONS))) + BUILD_TAGS += testnet +else + BUILD_TAGS += mainnet +endif + # DB backend selection ifeq (cleveldb,$(findstring cleveldb,$(BABYLON_BUILD_OPTIONS))) ldflags += -X github.com/cosmos/cosmos-sdk/types.DBBackend=cleveldb @@ -131,9 +138,6 @@ help: ## Print this help message all: tools build lint test ## Run build, lint, and test -# The below include contains the tools and runsim targets. -# TODO: Fix following make file so it will work on linux -# include contrib/devtools/Makefile ############################################################################### ### Build ### @@ -153,7 +157,10 @@ $(BUILD_TARGETS): $(BUILDDIR)/ $(BUILDDIR)/: mkdir -p $(BUILDDIR)/ -.PHONY: build build-linux +build-testnet: + BABYLON_BUILD_OPTIONS=testnet make build + +.PHONY: build build-linux build-testnet mockgen_cmd=go run github.com/golang/mock/mockgen@v1.6.0 @@ -278,8 +285,11 @@ test-e2e-cache-btc-timestamping-phase-2-rly: test-e2e-cache-btc-staking: go test -run TestBTCStakingTestSuite -mod=readonly -timeout=60m -v $(PACKAGES_E2E) --tags=e2e -test-e2e-cache-upgrade-signet: - go test -run TestSoftwareUpgradeSignetLaunchTestSuite -mod=readonly -timeout=60m -v $(PACKAGES_E2E) --tags=e2e +test-e2e-cache-btc-staking-pre-approval: + go test -run TestBTCStakingPreApprovalTestSuite -mod=readonly -timeout=60m -v $(PACKAGES_E2E) --tags=e2e + +test-e2e-cache-upgrade-v1: + go test -run TestSoftwareUpgradeV1TestnetTestSuite -mod=readonly -timeout=60m -v $(PACKAGES_E2E) --tags=e2e test-sim-nondeterminism: @echo "Running non-determinism test..." @@ -373,10 +383,11 @@ lint-go: .PHONY: lint lint-fix -format: ## Run code formater +format: ## Run code formatter find . -name '*.go' -type f -not -path "./vendor*" -not -path "*.git*" -not -path "./client/docs/statik/statik.go" -not -name '*.pb.go' | xargs gofmt -w -s find . -name '*.go' -type f -not -path "./vendor*" -not -path "*.git*" -not -path "./client/docs/statik/statik.go" -not -name '*.pb.go' | xargs misspell -w find . -name '*.go' -type f -not -path "./vendor*" -not -path "*.git*" -not -path "./client/docs/statik/statik.go" -not -name '*.pb.go' | xargs goimports -w -local github.com/babylonlabs-io/babylon + .PHONY: format ############################################################################### @@ -391,32 +402,6 @@ gosec-local: ## Run local security checkss .PHONY: gosec gosec-local -############################################################################### -### Devdoc ### -############################################################################### - -DEVDOC_SAVE = docker commit `docker ps -a -n 1 -q` devdoc:local - -devdoc-init: ## Initialize documentation - $(DOCKER) run -it -v "$(CURDIR):/go/src/github.com/babylonlabs-io/babylon" -w "/go/src/github.com/babylonlabs-io/babylon" tendermint/devdoc echo - # TODO make this safer - $(call DEVDOC_SAVE) - -devdoc: ## Generate documentation - $(DOCKER) run -it -v "$(CURDIR):/go/src/github.com/babylonlabs-io/babylon" -w "/go/src/github.com/babylonlabs-io/babylon" devdoc:local bash - -devdoc-save: ## Save documentation changes - # TODO make this safer - $(call DEVDOC_SAVE) - -devdoc-clean: ## Clean up documentation artifacts - docker rmi -f $$(docker images -f "dangling=true" -q) - -devdoc-update: ## Update documentation tools - docker pull tendermint/devdoc - -.PHONY: devdoc devdoc-clean devdoc-init devdoc-save devdoc-update - ############################################################################### ### Protobuf ### ############################################################################### @@ -453,7 +438,6 @@ build-docker: ## Build babylond Docker image build-docker-e2e: $(MAKE) -C contrib/images babylond-e2e - $(MAKE) -C contrib/images babylond-before-upgrade $(MAKE) -C contrib/images e2e-init-chain $(MAKE) -C contrib/images build-bcd-consumer-integration @@ -463,53 +447,73 @@ build-cosmos-relayer-docker: ## Build Docker image for the Cosmos relayer clean-docker-network: $(DOCKER) network rm ${dockerNetworkList} -.PHONY: build-docker build-docker-e2e build-cosmos-relayer-docker clean-docker-network - -############################################################################### -### Localnet ### -############################################################################### - -init-testnet-dirs: ## Initialize directories for testnet, creates a ./.testnets directory containing configuration for 4 Babylon nodes - # need to create the dir before hand so that the docker container has write access to the `.testnets` dir - # regardless of the user it uses - mkdir -p $(CURDIR)/.testnets && chmod o+w $(CURDIR)/.testnets - $(DOCKER) run --rm -v $(CURDIR)/.testnets:/home/babylon/.testnets:Z babylonlabs-io/babylond \ - babylond testnet init-files --v 4 -o /home/babylon/.testnets \ - --starting-ip-address 192.168.10.2 --keyring-backend=test \ - --chain-id chain-test --btc-confirmation-depth 2 --additional-sender-account true \ - --epoch-interval 5 - -localnet-start-nodes: init-testnet-dirs ## Boot the nodes described in the docker-compose.yml file - docker-compose up -d - -localnet-start: localnet-stop build-docker localnet-start-nodes ## Run with 4 nodes, a bitcoin instance, and a vigilante instance - -# localnet-stop will clean up and stop all localnets running -localnet-stop: - rm -rf $(CURDIR)/.testnets - docker-compose down - build-test-wasm: ## Build WASM bindings for testing - docker run --rm -v "$(WASM_DIR)":/code \ + $(DOCKER) run --rm -v "$(WASM_DIR)":/code \ --mount type=volume,source="$(WASM_DIR_BASE_NAME)_cache",target=/code/target \ --mount type=volume,source=registry_cache,target=/usr/local/cargo/registry \ cosmwasm/rust-optimizer-arm64:0.12.13 - docker run --rm -v "$(WASM_DIR)":/code \ + $(DOCKER) run --rm -v "$(WASM_DIR)":/code \ --mount type=volume,source="$(WASM_DIR_BASE_NAME)_cache",target=/code/target \ --mount type=volume,source=registry_cache,target=/usr/local/cargo/registry \ cosmwasm/rust-optimizer:0.12.13 -.PHONY: \ -init-testnet-dirs \ -localnet-start-nodes \ -localnet-start \ -localnet-stop +.PHONY: build-docker build-docker-e2e build-cosmos-relayer-docker clean-docker-network build-test-wasm -.PHONY: diagrams diagrams: ## Generate diagrams for documentation $(MAKE) -C client/docs/diagrams -.PHONY: update-changelog -update-changelog: ## Update the project changelog - @echo ./scripts/update_changelog.sh $(since_tag) $(upcoming_tag) - ./scripts/update_changelog.sh $(since_tag) $(upcoming_tag) +.PHONY: diagrams + +############################################################################### +### Release ### +############################################################################### + +# The below is adapted from https://github.com/osmosis-labs/osmosis/blob/main/Makefile +GO_VERSION := $(shell grep -E '^go [0-9]+\.[0-9]+' go.mod | awk '{print $$2}') +GORELEASER_IMAGE := ghcr.io/goreleaser/goreleaser-cross:v$(GO_VERSION) +COSMWASM_VERSION := $(shell go list -m github.com/CosmWasm/wasmvm/v2 | sed 's/.* //') + +.PHONY: release-dry-run release-snapshot release +release-dry-run: + docker run \ + --rm \ + -e COSMWASM_VERSION=$(COSMWASM_VERSION) \ + -v /var/run/docker.sock:/var/run/docker.sock \ + -v `pwd`:/go/src/babylon \ + -w /go/src/babylon \ + $(GORELEASER_IMAGE) \ + release \ + --clean \ + --skip=publish + +release-snapshot: + docker run \ + --rm \ + -e COSMWASM_VERSION=$(COSMWASM_VERSION) \ + -v /var/run/docker.sock:/var/run/docker.sock \ + -v `pwd`:/go/src/babylon \ + -w /go/src/babylon \ + $(GORELEASER_IMAGE) \ + release \ + --clean \ + --snapshot \ + --skip=publish,validate + +# NOTE: By default, the CI will handle the release process. +# this is for manually releasing. +ifdef GITHUB_TOKEN +release: + docker run \ + --rm \ + -e GITHUB_TOKEN=$(GITHUB_TOKEN) \ + -e COSMWASM_VERSION=$(COSMWASM_VERSION) \ + -v /var/run/docker.sock:/var/run/docker.sock \ + -v `pwd`:/go/src/babylon \ + -w /go/src/babylon \ + $(GORELEASER_IMAGE) \ + release \ + --clean +else +release: + @echo "Error: GITHUB_TOKEN is not defined. Please define it before running 'make release'." +endif diff --git a/README.md b/README.md index 3ed4699e6..1f3130025 100644 --- a/README.md +++ b/README.md @@ -35,7 +35,7 @@ that it is not highly performant or prone to crashing. ## Build and install -To build and install, you need to have Go 1.21 available. Follow the +To build and install, you need to have Go 1.23 available. Follow the instructions on the [Golang page](https://go.dev/doc/install) to do that. To build the binary: diff --git a/RELEASE_PROCESS.md b/RELEASE_PROCESS.md index eb58482c5..d5c61b57c 100644 --- a/RELEASE_PROCESS.md +++ b/RELEASE_PROCESS.md @@ -1,12 +1,11 @@ # Release Process -- [Release Process](#release-process) - - [Breaking Changes](#breaking-changes) - - [Release Procedure](#release-procedure) - - [Creating a new release branch](#creating-a-new-release-branch) - - [Cutting a new release](#cutting-a-new-release) - - [Tagging Procedure](#tagging-procedure) - - [Patch release Procedure](#patch-release-procedure) +- [Breaking Changes](#breaking-changes) +- [Release Procedure](#release-procedure) + - [Creating a new release branch](#creating-a-new-release-branch) + - [Cutting a new release](#cutting-a-new-release) + - [Tagging Procedure](#tagging-procedure) +- [Patch Release Procedure](#patch-release-procedure) This document outlines the release process for the Babylon node (babylond) @@ -111,6 +110,10 @@ git pull --tags git tag -s -a v0.10.0-rc.0 -m "Version v0.10.0-rc.0" ``` + +With every tag, the Github action will use the `goreleaser` tool to create a +release, including artifacts and their checksums. + ## Patch Release Procedure A _patch release_ is an increment of the patch number (eg: `v10.0.0` → `v10.0.1`). @@ -119,10 +122,13 @@ A _patch release_ is an increment of the patch number (eg: `v10.0.0` → `v10.0. circumstances .**_ Updates to the release branch should come from `main` by backporting PRs -(usually done by automatic cherry pick followed by a PRs to the release branch). -The backports must be marked using `backport/Y` label in PR for main. -It is the PR author's responsibility to fix merge conflicts and -ensure CI passes. +(usually done by automatic cherry pick followed by a PR to the release branch). +The backports must be marked using `backport release/v0.Y.x` label in PR for +`main`, where `release/v0.Y.x` is the name of the release branch. It is the PR +author's responsibility to fix merge conflicts, update changelog entries, and +ensure CI passes. If a PR originates from an external contributor, a member of +the stewarding team assumes responsibility to perform this process instead of +the original author. After the release branch has all commits required for the next patch release: * Create a new annotated git tag in the release diff --git a/app/ante.go b/app/ante.go deleted file mode 100644 index 1cd6b9dee..000000000 --- a/app/ante.go +++ /dev/null @@ -1,24 +0,0 @@ -package app - -import ( - sdk "github.com/cosmos/cosmos-sdk/types" -) - -// WrappedAnteHandler is the wrapped AnteHandler that implements the `AnteDecorator` interface, which has a single function `AnteHandle`. -// It allows us to chain an existing AnteHandler with other decorators by using `sdk.ChainAnteDecorators`. -type WrappedAnteHandler struct { - ah sdk.AnteHandler -} - -// NewWrappedAnteHandler creates a new WrappedAnteHandler for a given AnteHandler. -func NewWrappedAnteHandler(ah sdk.AnteHandler) WrappedAnteHandler { - return WrappedAnteHandler{ah} -} - -func (wah WrappedAnteHandler) AnteHandle(ctx sdk.Context, tx sdk.Tx, simulate bool, next sdk.AnteHandler) (newCtx sdk.Context, err error) { - newCtx, err = wah.ah(ctx, tx, simulate) - if err != nil { - return newCtx, err - } - return next(newCtx, tx, simulate) -} diff --git a/app/ante/ante.go b/app/ante/ante.go new file mode 100644 index 000000000..cd7b83a86 --- /dev/null +++ b/app/ante/ante.go @@ -0,0 +1,91 @@ +package ante + +import ( + "cosmossdk.io/core/store" + circuitkeeper "cosmossdk.io/x/circuit/keeper" + txsigning "cosmossdk.io/x/tx/signing" + wasmapp "github.com/CosmWasm/wasmd/app" + wasmkeeper "github.com/CosmWasm/wasmd/x/wasm/keeper" + wasmtypes "github.com/CosmWasm/wasmd/x/wasm/types" + bbn "github.com/babylonlabs-io/babylon/types" + btcckeeper "github.com/babylonlabs-io/babylon/x/btccheckpoint/keeper" + epochingkeeper "github.com/babylonlabs-io/babylon/x/epoching/keeper" + sdk "github.com/cosmos/cosmos-sdk/types" + authante "github.com/cosmos/cosmos-sdk/x/auth/ante" + authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" + ibckeeper "github.com/cosmos/ibc-go/v8/modules/core/keeper" +) + +// NewAnteHandler creates a new AnteHandler for the Babylon chain. +func NewAnteHandler( + accountKeeper authante.AccountKeeper, + bankKeeper authtypes.BankKeeper, + feegrantKeeper authante.FeegrantKeeper, + signModeHandler *txsigning.HandlerMap, + ibcKeeper *ibckeeper.Keeper, + wasmConfig *wasmtypes.WasmConfig, + wasmKeeper *wasmkeeper.Keeper, + circuitKeeper *circuitkeeper.Keeper, + epochingKeeper *epochingkeeper.Keeper, + btcConfig *bbn.BtcConfig, + btccKeeper *btcckeeper.Keeper, + txCounterStoreService store.KVStoreService, +) sdk.AnteHandler { + // initialize AnteHandler, which includes + // - authAnteHandler + // - custom wasm ante handler NewLimitSimulationGasDecorator and NewCountTXDecorator + // - Extra decorators introduced in Babylon, such as DropValidatorMsgDecorator that delays validator-related messages + // + // We are using constructor from wasmapp as it introduces custom wasm ante handle decorators + // early in chain of ante handlers. + authAnteHandler, err := wasmapp.NewAnteHandler( + wasmapp.HandlerOptions{ + HandlerOptions: authante.HandlerOptions{ + AccountKeeper: accountKeeper, + BankKeeper: bankKeeper, + SignModeHandler: signModeHandler, + FeegrantKeeper: feegrantKeeper, + SigGasConsumer: authante.DefaultSigVerificationGasConsumer, + // CheckTxFeeWithGlobalMinGasPrices will enforce the global minimum + // gas price for all transactions. + TxFeeChecker: CheckTxFeeWithGlobalMinGasPrices, + }, + IBCKeeper: ibcKeeper, + WasmConfig: wasmConfig, + TXCounterStoreService: txCounterStoreService, + WasmKeeper: wasmKeeper, + CircuitKeeper: circuitKeeper, + }, + ) + + if err != nil { + panic(err) + } + + anteHandler := sdk.ChainAnteDecorators( + NewWrappedAnteHandler(authAnteHandler), + epochingkeeper.NewDropValidatorMsgDecorator(epochingKeeper), + NewBtcValidationDecorator(btcConfig, btccKeeper), + ) + + return anteHandler +} + +// WrappedAnteHandler is the wrapped AnteHandler that implements the `AnteDecorator` interface, which has a single function `AnteHandle`. +// It allows us to chain an existing AnteHandler with other decorators by using `sdk.ChainAnteDecorators`. +type WrappedAnteHandler struct { + ah sdk.AnteHandler +} + +// NewWrappedAnteHandler creates a new WrappedAnteHandler for a given AnteHandler. +func NewWrappedAnteHandler(ah sdk.AnteHandler) WrappedAnteHandler { + return WrappedAnteHandler{ah} +} + +func (wah WrappedAnteHandler) AnteHandle(ctx sdk.Context, tx sdk.Tx, simulate bool, next sdk.AnteHandler) (newCtx sdk.Context, err error) { + newCtx, err = wah.ah(ctx, tx, simulate) + if err != nil { + return newCtx, err + } + return next(newCtx, tx, simulate) +} diff --git a/app/ante_btc_validation_decorator.go b/app/ante/ante_btc_validation_decorator.go similarity index 96% rename from app/ante_btc_validation_decorator.go rename to app/ante/ante_btc_validation_decorator.go index 8e5febfb8..ffe7d21cc 100644 --- a/app/ante_btc_validation_decorator.go +++ b/app/ante/ante_btc_validation_decorator.go @@ -1,4 +1,4 @@ -package app +package ante import ( bbn "github.com/babylonlabs-io/babylon/types" @@ -9,12 +9,12 @@ import ( ) type BtcValidationDecorator struct { - BtcCfg bbn.BtcConfig + BtcCfg *bbn.BtcConfig btccheckpointKeeper *btccheckpointkeeper.Keeper } func NewBtcValidationDecorator( - cfg bbn.BtcConfig, + cfg *bbn.BtcConfig, k *btccheckpointkeeper.Keeper, ) BtcValidationDecorator { return BtcValidationDecorator{ diff --git a/app/ante/fee_checker.go b/app/ante/fee_checker.go new file mode 100644 index 000000000..48118af23 --- /dev/null +++ b/app/ante/fee_checker.go @@ -0,0 +1,66 @@ +package ante + +import ( + "fmt" + + errors "cosmossdk.io/errors" + sdkmath "cosmossdk.io/math" + appparams "github.com/babylonlabs-io/babylon/app/params" + sdk "github.com/cosmos/cosmos-sdk/types" + sdkerror "github.com/cosmos/cosmos-sdk/types/errors" +) + +const ( + // priorityScalingFactor is a scaling factor to convert the gas price to a priority. + priorityScalingFactor = 1_000_000 +) + +// CheckTxFeeWithGlobalMinGasPrices implements the default fee logic, where the minimum price per +// unit of gas is fixed and set globally, and the tx priority is computed from the gas price. +// adapted from https://github.com/celestiaorg/celestia-app/pull/2985 +func CheckTxFeeWithGlobalMinGasPrices(ctx sdk.Context, tx sdk.Tx) (sdk.Coins, int64, error) { + feeTx, ok := tx.(sdk.FeeTx) + if !ok { + return nil, 0, errors.Wrap(sdkerror.ErrTxDecode, "Tx must be a FeeTx") + } + + denom := appparams.DefaultBondDenom + + fee := feeTx.GetFee().AmountOf(denom) + gas := feeTx.GetGas() + + // convert the global minimum gas price to a big.Int + globalMinGasPrice, err := sdkmath.LegacyNewDecFromStr(fmt.Sprintf("%f", appparams.GlobalMinGasPrice)) + if err != nil { + return nil, 0, errors.Wrap(err, "invalid GlobalMinGasPrice") + } + + gasInt := sdkmath.NewIntFromUint64(gas) + minFee := globalMinGasPrice.MulInt(gasInt).RoundInt() + + if !fee.GTE(minFee) { + return nil, 0, errors.Wrapf(sdkerror.ErrInsufficientFee, "insufficient fees; got: %s required: %s", fee, minFee) + } + + priority := getTxPriority(feeTx.GetFee(), int64(gas)) + return feeTx.GetFee(), priority, nil +} + +// getTxPriority returns a naive tx priority based on the amount of the smallest denomination of the gas price +// provided in a transaction. +// NOTE: This implementation should not be used for txs with multiple coins. +func getTxPriority(fee sdk.Coins, gas int64) int64 { + var priority int64 + for _, c := range fee { + p := c.Amount.Mul(sdkmath.NewInt(priorityScalingFactor)).QuoRaw(gas) + if !p.IsInt64() { + continue + } + // take the lowest priority as the tx priority + if priority == 0 || p.Int64() < priority { + priority = p.Int64() + } + } + + return priority +} diff --git a/app/ante/fee_checker_test.go b/app/ante/fee_checker_test.go new file mode 100644 index 000000000..35d025160 --- /dev/null +++ b/app/ante/fee_checker_test.go @@ -0,0 +1,100 @@ +package ante_test + +import ( + "math" + "testing" + + bbnapp "github.com/babylonlabs-io/babylon/app" + "github.com/babylonlabs-io/babylon/app/ante" + appparams "github.com/babylonlabs-io/babylon/app/params" + "github.com/babylonlabs-io/babylon/testutil/datagen" + sdk "github.com/cosmos/cosmos-sdk/types" + banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" + "github.com/stretchr/testify/require" +) + +// TestCheckTxFeeWithGlobalMinGasPrices tests the CheckTxFeeWithGlobalMinGasPrices +// function +// adapted from https://github.com/celestiaorg/celestia-app/pull/2985 +func TestCheckTxFeeWithGlobalMinGasPrices(t *testing.T) { + encCfg := bbnapp.GetEncodingConfig() + + builder := encCfg.TxConfig.NewTxBuilder() + err := builder.SetMsgs( + banktypes.NewMsgSend( + datagen.GenRandomAccount().GetAddress(), + datagen.GenRandomAccount().GetAddress(), + sdk.NewCoins(sdk.NewInt64Coin(appparams.DefaultBondDenom, 10)), + ), + ) + require.NoError(t, err) + + feeAmount := int64(1000) + ctx := sdk.Context{} + + testCases := []struct { + name string + fee sdk.Coins + gasLimit uint64 + appVersion uint64 + expErr bool + }{ + { + name: "bad tx; fee below required minimum", + fee: sdk.NewCoins(sdk.NewInt64Coin(appparams.DefaultBondDenom, feeAmount-1)), + gasLimit: uint64(float64(feeAmount) / appparams.GlobalMinGasPrice), + appVersion: uint64(2), + expErr: true, + }, + { + name: "good tx; fee equal to required minimum", + fee: sdk.NewCoins(sdk.NewInt64Coin(appparams.DefaultBondDenom, feeAmount)), + gasLimit: uint64(float64(feeAmount) / appparams.GlobalMinGasPrice), + appVersion: uint64(2), + expErr: false, + }, + { + name: "good tx; fee above required minimum", + fee: sdk.NewCoins(sdk.NewInt64Coin(appparams.DefaultBondDenom, feeAmount+1)), + gasLimit: uint64(float64(feeAmount) / appparams.GlobalMinGasPrice), + appVersion: uint64(2), + expErr: false, + }, + { + name: "good tx; gas limit and fee are maximum values", + fee: sdk.NewCoins(sdk.NewInt64Coin(appparams.DefaultBondDenom, math.MaxInt64)), + gasLimit: math.MaxUint64, + appVersion: uint64(2), + expErr: false, + }, + { + name: "bad tx; gas limit and fee are 0", + fee: sdk.NewCoins(sdk.NewInt64Coin(appparams.DefaultBondDenom, 0)), + gasLimit: 0, + appVersion: uint64(2), + expErr: false, + }, + { + name: "good tx; minFee = 0.8, rounds up to 1", + fee: sdk.NewCoins(sdk.NewInt64Coin(appparams.DefaultBondDenom, feeAmount)), + gasLimit: 400, + appVersion: uint64(2), + expErr: false, + }, + } + + for _, tc := range testCases { + t.Run(tc.name, func(t *testing.T) { + builder.SetGasLimit(tc.gasLimit) + builder.SetFeeAmount(tc.fee) + tx := builder.GetTx() + + _, _, err := ante.CheckTxFeeWithGlobalMinGasPrices(ctx, tx) + if tc.expErr { + require.Error(t, err) + } else { + require.NoError(t, err) + } + }) + } +} diff --git a/app/ante/get_tx_priority_test.go b/app/ante/get_tx_priority_test.go new file mode 100644 index 000000000..d4859dd14 --- /dev/null +++ b/app/ante/get_tx_priority_test.go @@ -0,0 +1,60 @@ +package ante + +import ( + "testing" + + appparams "github.com/babylonlabs-io/babylon/app/params" + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/stretchr/testify/assert" +) + +// TestGetTxPriority tests the getTxPriority function +// adapted from https://github.com/celestiaorg/celestia-app/pull/2985 +func TestGetTxPriority(t *testing.T) { + denom := appparams.DefaultBondDenom + + cases := []struct { + name string + fee sdk.Coins + gas int64 + expectedPri int64 + }{ + { + name: "1 bbn fee large gas", + fee: sdk.NewCoins(sdk.NewInt64Coin(denom, 1_000_000)), + gas: 1000000, + expectedPri: 1000000, + }, + { + name: "1 ubbn fee small gas", + fee: sdk.NewCoins(sdk.NewInt64Coin(denom, 1)), + gas: 1, + expectedPri: 1000000, + }, + { + name: "2 ubbn fee small gas", + fee: sdk.NewCoins(sdk.NewInt64Coin(denom, 2)), + gas: 1, + expectedPri: 2000000, + }, + { + name: "1_000_000 bbn fee normal gas tx", + fee: sdk.NewCoins(sdk.NewInt64Coin(denom, 1_000_000_000_000)), + gas: 75000, + expectedPri: 13333333333333, + }, + { + name: "0.001 ubbn gas price", + fee: sdk.NewCoins(sdk.NewInt64Coin(denom, 1_000)), + gas: 1_000_000, + expectedPri: 1000, + }, + } + + for _, tc := range cases { + t.Run(tc.name, func(t *testing.T) { + pri := getTxPriority(tc.fee, tc.gas) + assert.Equal(t, tc.expectedPri, pri) + }) + } +} diff --git a/app/app.go b/app/app.go index afa68737e..7fbcb97fd 100644 --- a/app/app.go +++ b/app/app.go @@ -20,10 +20,10 @@ import ( feegrantmodule "cosmossdk.io/x/feegrant/module" "cosmossdk.io/x/upgrade" upgradetypes "cosmossdk.io/x/upgrade/types" - wasmapp "github.com/CosmWasm/wasmd/app" "github.com/CosmWasm/wasmd/x/wasm" wasmkeeper "github.com/CosmWasm/wasmd/x/wasm/keeper" wasmtypes "github.com/CosmWasm/wasmd/x/wasm/types" + "github.com/babylonlabs-io/babylon/app/ante" appkeepers "github.com/babylonlabs-io/babylon/app/keepers" appparams "github.com/babylonlabs-io/babylon/app/params" "github.com/babylonlabs-io/babylon/app/upgrades" @@ -40,16 +40,17 @@ import ( "github.com/babylonlabs-io/babylon/x/checkpointing" checkpointingtypes "github.com/babylonlabs-io/babylon/x/checkpointing/types" "github.com/babylonlabs-io/babylon/x/epoching" - epochingkeeper "github.com/babylonlabs-io/babylon/x/epoching/keeper" epochingtypes "github.com/babylonlabs-io/babylon/x/epoching/types" "github.com/babylonlabs-io/babylon/x/finality" finalitytypes "github.com/babylonlabs-io/babylon/x/finality/types" "github.com/babylonlabs-io/babylon/x/incentive" + incentivekeeper "github.com/babylonlabs-io/babylon/x/incentive/keeper" incentivetypes "github.com/babylonlabs-io/babylon/x/incentive/types" + "github.com/babylonlabs-io/babylon/x/mint" + minttypes "github.com/babylonlabs-io/babylon/x/mint/types" "github.com/babylonlabs-io/babylon/x/monitor" monitortypes "github.com/babylonlabs-io/babylon/x/monitor/types" "github.com/babylonlabs-io/babylon/x/zoneconcierge" - zckeeper "github.com/babylonlabs-io/babylon/x/zoneconcierge/keeper" zctypes "github.com/babylonlabs-io/babylon/x/zoneconcierge/types" abci "github.com/cometbft/cometbft/abci/types" cmtos "github.com/cometbft/cometbft/libs/os" @@ -74,7 +75,6 @@ import ( "github.com/cosmos/cosmos-sdk/types/msgservice" "github.com/cosmos/cosmos-sdk/version" "github.com/cosmos/cosmos-sdk/x/auth" - "github.com/cosmos/cosmos-sdk/x/auth/ante" authcodec "github.com/cosmos/cosmos-sdk/x/auth/codec" authsims "github.com/cosmos/cosmos-sdk/x/auth/simulation" authtx "github.com/cosmos/cosmos-sdk/x/auth/tx" @@ -96,8 +96,6 @@ import ( "github.com/cosmos/cosmos-sdk/x/gov" govclient "github.com/cosmos/cosmos-sdk/x/gov/client" govtypes "github.com/cosmos/cosmos-sdk/x/gov/types" - "github.com/cosmos/cosmos-sdk/x/mint" - minttypes "github.com/cosmos/cosmos-sdk/x/mint/types" "github.com/cosmos/cosmos-sdk/x/params" paramsclient "github.com/cosmos/cosmos-sdk/x/params/client" paramstypes "github.com/cosmos/cosmos-sdk/x/params/types" @@ -289,7 +287,7 @@ func NewBabylonApp( crisis.NewAppModule(app.CrisisKeeper, skipGenesisInvariants, app.GetSubspace(crisistypes.ModuleName)), feegrantmodule.NewAppModule(appCodec, app.AccountKeeper, app.BankKeeper, app.FeeGrantKeeper, app.interfaceRegistry), gov.NewAppModule(appCodec, &app.GovKeeper, app.AccountKeeper, app.BankKeeper, app.GetSubspace(govtypes.ModuleName)), - mint.NewAppModule(appCodec, app.MintKeeper, app.AccountKeeper, nil, app.GetSubspace(minttypes.ModuleName)), + mint.NewAppModule(appCodec, app.MintKeeper, app.AccountKeeper), slashing.NewAppModule(appCodec, app.SlashingKeeper, app.AccountKeeper, app.BankKeeper, app.StakingKeeper, app.GetSubspace(slashingtypes.ModuleName), app.interfaceRegistry), distr.NewAppModule(appCodec, app.DistrKeeper, app.AccountKeeper, app.BankKeeper, app.StakingKeeper, app.GetSubspace(distrtypes.ModuleName)), staking.NewAppModule(appCodec, app.StakingKeeper, app.AccountKeeper, app.BankKeeper, app.GetSubspace(stakingtypes.ModuleName)), @@ -353,7 +351,7 @@ func NewBabylonApp( app.ModuleManager.SetOrderBeginBlockers( upgradetypes.ModuleName, capabilitytypes.ModuleName, // NOTE: incentive module's BeginBlock has to be after mint but before distribution - // so that it can intercept a part of new inflation to reward BTC staking/timestamping stakeholders + // so that it can intercept a part of new inflation to reward BTC staking stakeholders minttypes.ModuleName, incentivetypes.ModuleName, distrtypes.ModuleName, slashingtypes.ModuleName, evidencetypes.ModuleName, stakingtypes.ModuleName, @@ -486,43 +484,25 @@ func NewBabylonApp( app.MountTransientStores(app.GetTransientStoreKeys()) app.MountMemoryStores(app.GetMemoryStoreKeys()) - // initialize AnteHandler, which includes - // - authAnteHandler - // - custom wasm ante handler NewLimitSimulationGasDecorator and NewCountTXDecorator - // - Extra decorators introduced in Babylon, such as DropValidatorMsgDecorator that delays validator-related messages - // - // We are using constructor from wasmapp as it introduces custom wasm ante handle decorators - // early in chain of ante handlers. - authAnteHandler, err := wasmapp.NewAnteHandler( - wasmapp.HandlerOptions{ - HandlerOptions: ante.HandlerOptions{ - AccountKeeper: app.AccountKeeper, - BankKeeper: app.BankKeeper, - SignModeHandler: txConfig.SignModeHandler(), - FeegrantKeeper: app.FeeGrantKeeper, - SigGasConsumer: ante.DefaultSigVerificationGasConsumer, - }, - IBCKeeper: app.IBCKeeper, - WasmConfig: &wasmConfig, - TXCounterStoreService: runtime.NewKVStoreService(app.AppKeepers.GetKey(wasmtypes.StoreKey)), - WasmKeeper: &app.WasmKeeper, - CircuitKeeper: &app.CircuitKeeper, - }, - ) - - if err != nil { - panic(err) - } - - anteHandler := sdk.ChainAnteDecorators( - NewWrappedAnteHandler(authAnteHandler), - epochingkeeper.NewDropValidatorMsgDecorator(app.EpochingKeeper), - NewBtcValidationDecorator(btcConfig, &app.BtcCheckpointKeeper), + // initialize AnteHandler for the app + anteHandler := ante.NewAnteHandler( + &app.AccountKeeper, + app.BankKeeper, + &app.FeeGrantKeeper, + txConfig.SignModeHandler(), + app.IBCKeeper, + &wasmConfig, + &app.WasmKeeper, + &app.CircuitKeeper, + &app.EpochingKeeper, + &btcConfig, + &app.BtcCheckpointKeeper, + runtime.NewKVStoreService(app.AppKeepers.GetKey(wasmtypes.StoreKey)), ) // set proposal extension proposalHandler := checkpointing.NewProposalHandler( - logger, &app.CheckpointingKeeper, bApp.Mempool(), bApp) + logger, &app.CheckpointingKeeper, bApp.Mempool(), bApp, app.EncCfg) proposalHandler.SetHandlers(bApp) // set vote extension @@ -550,7 +530,7 @@ func NewBabylonApp( // set postHandler postHandler := sdk.ChainPostDecorators( - zckeeper.NewIBCHeaderDecorator(app.ZoneConciergeKeeper), + incentivekeeper.NewRefundTxDecorator(&app.IncentiveKeeper), ) app.SetPostHandler(postHandler) diff --git a/app/e2e_include_upgrades.go b/app/e2e_include_upgrades.go deleted file mode 100644 index 6f5770be5..000000000 --- a/app/e2e_include_upgrades.go +++ /dev/null @@ -1,13 +0,0 @@ -//go:build e2e - -package app - -import ( - "github.com/babylonlabs-io/babylon/app/upgrades/signetlaunch" -) - -// init is used to include signet upgrade used for e2e testing -// this file should be removed once the upgrade testing with signet ends. -func init() { - Upgrades = append(Upgrades, signetlaunch.Upgrade) -} diff --git a/app/include_upgrade_mainnet.go b/app/include_upgrade_mainnet.go new file mode 100644 index 000000000..4d492254d --- /dev/null +++ b/app/include_upgrade_mainnet.go @@ -0,0 +1,22 @@ +//go:build mainnet + +package app + +import ( + "github.com/babylonlabs-io/babylon/app/upgrades" + v1 "github.com/babylonlabs-io/babylon/app/upgrades/v1" + "github.com/babylonlabs-io/babylon/app/upgrades/v1/mainnet" +) + +// init is used to include v1 upgrade for mainnet data +func init() { + Upgrades = []upgrades.Upgrade{v1.CreateUpgrade(v1.UpgradeDataString{ + BtcStakingParamStr: mainnet.BtcStakingParamStr, + FinalityParamStr: mainnet.FinalityParamStr, + IncentiveParamStr: mainnet.IncentiveParamStr, + CosmWasmParamStr: mainnet.CosmWasmParamStr, + NewBtcHeadersStr: mainnet.NewBtcHeadersStr, + TokensDistributionStr: mainnet.TokensDistributionStr, + AllowedStakingTxHashesStr: mainnet.AllowedStakingTxHashesStr, + })} +} diff --git a/app/include_upgrade_testnet.go b/app/include_upgrade_testnet.go new file mode 100644 index 000000000..15f974952 --- /dev/null +++ b/app/include_upgrade_testnet.go @@ -0,0 +1,23 @@ +//go:build testnet + +package app + +import ( + "github.com/babylonlabs-io/babylon/app/upgrades" + v1 "github.com/babylonlabs-io/babylon/app/upgrades/v1" + "github.com/babylonlabs-io/babylon/app/upgrades/v1/testnet" +) + +// init is used to include v1 upgrade testnet data +// it is also used for e2e testing +func init() { + Upgrades = []upgrades.Upgrade{v1.CreateUpgrade(v1.UpgradeDataString{ + BtcStakingParamStr: testnet.BtcStakingParamStr, + FinalityParamStr: testnet.FinalityParamStr, + IncentiveParamStr: testnet.IncentiveParamStr, + CosmWasmParamStr: testnet.CosmWasmParamStr, + NewBtcHeadersStr: testnet.NewBtcHeadersStr, + TokensDistributionStr: testnet.TokensDistributionStr, + AllowedStakingTxHashesStr: testnet.AllowedStakingTxHashesStr, + })} +} diff --git a/app/keepers/keepers.go b/app/keepers/keepers.go index ecd1c80a8..0b3f17302 100644 --- a/app/keepers/keepers.go +++ b/app/keepers/keepers.go @@ -1,9 +1,9 @@ package keepers import ( + "fmt" "path/filepath" - errorsmod "cosmossdk.io/errors" "cosmossdk.io/log" storetypes "cosmossdk.io/store/types" circuitkeeper "cosmossdk.io/x/circuit/keeper" @@ -17,11 +17,13 @@ import ( "github.com/CosmWasm/wasmd/x/wasm" wasmkeeper "github.com/CosmWasm/wasmd/x/wasm/keeper" wasmtypes "github.com/CosmWasm/wasmd/x/wasm/types" + mintkeeper "github.com/babylonlabs-io/babylon/x/mint/keeper" + minttypes "github.com/babylonlabs-io/babylon/x/mint/types" + "github.com/babylonlabs-io/babylon/x/zoneconcierge" "github.com/cosmos/cosmos-sdk/baseapp" "github.com/cosmos/cosmos-sdk/codec" "github.com/cosmos/cosmos-sdk/runtime" servertypes "github.com/cosmos/cosmos-sdk/server/types" - sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" authcodec "github.com/cosmos/cosmos-sdk/x/auth/codec" authkeeper "github.com/cosmos/cosmos-sdk/x/auth/keeper" authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" @@ -37,8 +39,6 @@ import ( govkeeper "github.com/cosmos/cosmos-sdk/x/gov/keeper" govtypes "github.com/cosmos/cosmos-sdk/x/gov/types" govv1beta1 "github.com/cosmos/cosmos-sdk/x/gov/types/v1beta1" - mintkeeper "github.com/cosmos/cosmos-sdk/x/mint/keeper" - minttypes "github.com/cosmos/cosmos-sdk/x/mint/types" "github.com/cosmos/cosmos-sdk/x/params" paramskeeper "github.com/cosmos/cosmos-sdk/x/params/keeper" paramstypes "github.com/cosmos/cosmos-sdk/x/params/types" @@ -82,7 +82,6 @@ import ( incentivetypes "github.com/babylonlabs-io/babylon/x/incentive/types" monitorkeeper "github.com/babylonlabs-io/babylon/x/monitor/keeper" monitortypes "github.com/babylonlabs-io/babylon/x/monitor/types" - "github.com/babylonlabs-io/babylon/x/zoneconcierge" zckeeper "github.com/babylonlabs-io/babylon/x/zoneconcierge/keeper" zctypes "github.com/babylonlabs-io/babylon/x/zoneconcierge/types" ) @@ -447,6 +446,7 @@ func (ak *AppKeepers) InitKeepers( appCodec, runtime.NewKVStoreService(keys[btclightclienttypes.StoreKey]), *btcConfig, + &ak.IncentiveKeeper, authtypes.NewModuleAddress(govtypes.ModuleName).String(), ) @@ -461,12 +461,6 @@ func (ak *AppKeepers) InitKeepers( authtypes.NewModuleAddress(govtypes.ModuleName).String(), ) - // create querier for KVStore - storeQuerier, ok := bApp.CommitMultiStore().(storetypes.Queryable) - if !ok { - panic(errorsmod.Wrap(sdkerrors.ErrUnknownRequest, "multistore doesn't support queries")) - } - ak.IBCFeeKeeper = ibcfeekeeper.NewKeeper( appCodec, keys[ibcfeetypes.StoreKey], ak.IBCKeeper.ChannelKeeper, // may be replaced with IBC middleware @@ -497,24 +491,22 @@ func (ak *AppKeepers) InitKeepers( ) // set up BTC staking keeper - btcStakingKeeper := btcstakingkeeper.NewKeeper( + ak.BTCStakingKeeper = btcstakingkeeper.NewKeeper( appCodec, runtime.NewKVStoreService(keys[btcstakingtypes.StoreKey]), &btclightclientKeeper, &btcCheckpointKeeper, - // setting the finality keeper as nil for now - // need to set it after finality keeper is initiated - nil, &ak.BTCStkConsumerKeeper, + &ak.IncentiveKeeper, btcNetParams, authtypes.NewModuleAddress(govtypes.ModuleName).String(), ) // set up finality keeper - finalityKeeper := finalitykeeper.NewKeeper( + ak.FinalityKeeper = finalitykeeper.NewKeeper( appCodec, runtime.NewKVStoreService(keys[finalitytypes.StoreKey]), - btcStakingKeeper, + ak.BTCStakingKeeper, ak.IncentiveKeeper, checkpointingKeeper, authtypes.NewModuleAddress(govtypes.ModuleName).String(), @@ -526,6 +518,12 @@ func (ak *AppKeepers) InitKeepers( &btclightclientKeeper, ) + // create querier for KVStore + storeQuerier, ok := bApp.CommitMultiStore().(storetypes.Queryable) + if !ok { + panic(fmt.Errorf("multistore doesn't support queries")) + } + zcKeeper := zckeeper.NewKeeper( appCodec, runtime.NewKVStoreService(keys[zctypes.StoreKey]), @@ -568,14 +566,6 @@ func (ak *AppKeepers) InitKeepers( ak.MonitorKeeper = monitorKeeper ak.ZoneConciergeKeeper = *zcKeeper - // TODO: this introduces circular dependency between the finality module and - // the btcstaking modules, need refactoring - btcStakingKeeper.SetHooks(btcstakingtypes.NewMultiBtcStakingHooks(finalityKeeper.Hooks())) - finalityKeeper.SetHooks(finalitytypes.NewMultiFinalityHooks(btcStakingKeeper.Hooks())) - btcStakingKeeper.FinalityKeeper = finalityKeeper - ak.BTCStakingKeeper = btcStakingKeeper - ak.FinalityKeeper = finalityKeeper - // create evidence keeper with router evidenceKeeper := evidencekeeper.NewKeeper( appCodec, @@ -588,7 +578,7 @@ func (ak *AppKeepers) InitKeepers( // If evidence needs to be handled for the app, set routes in router here and seal ak.EvidenceKeeper = *evidenceKeeper - wasmOpts = append(owasm.RegisterCustomPlugins(&ak.EpochingKeeper, &ak.ZoneConciergeKeeper, &ak.BTCLightClientKeeper), wasmOpts...) + wasmOpts = append(owasm.RegisterCustomPlugins(&ak.EpochingKeeper, &ak.CheckpointingKeeper, &ak.BTCLightClientKeeper, &ak.ZoneConciergeKeeper), wasmOpts...) wasmOpts = append(owasm.RegisterGrpcQueries(*bApp.GRPCQueryRouter(), appCodec), wasmOpts...) ak.WasmKeeper = wasmkeeper.NewKeeper( @@ -664,7 +654,6 @@ func initParamsKeeper(appCodec codec.BinaryCodec, legacyAmino *codec.LegacyAmino // whole usage of params module paramsKeeper.Subspace(ibcexported.ModuleName) paramsKeeper.Subspace(ibctransfertypes.ModuleName) - paramsKeeper.Subspace(zctypes.ModuleName) return paramsKeeper } diff --git a/app/params/config.go b/app/params/config.go index 3d4322677..222752e95 100644 --- a/app/params/config.go +++ b/app/params/config.go @@ -20,6 +20,18 @@ const ( Bech32PrefixAccAddr = "bbn" ) +// taken from https://github.com/celestiaorg/celestia-app/pull/2985 +const ( + // DefaultMinGasPrice is the default min gas price that gets set in the app.toml file. + // The min gas price acts as a filter. Transactions below that limit will not pass + // a nodes `CheckTx` and thus not be proposed by that node. + DefaultMinGasPrice = 0.002 + + // GlobalMinGasPrice is used in the AnteHandler to ensure + // that all transactions have a gas price greater than or equal to this value. + GlobalMinGasPrice = DefaultMinGasPrice +) + var ( // Bech32PrefixAccPub defines the Bech32 prefix of an account's public key. Bech32PrefixAccPub = Bech32PrefixAccAddr + "pub" diff --git a/app/test_helpers.go b/app/test_helpers.go index 54514d809..c66b7b0e3 100644 --- a/app/test_helpers.go +++ b/app/test_helpers.go @@ -10,6 +10,7 @@ import ( "cosmossdk.io/log" "cosmossdk.io/math" pruningtypes "cosmossdk.io/store/pruning/types" + minttypes "github.com/babylonlabs-io/babylon/x/mint/types" abci "github.com/cometbft/cometbft/abci/types" "github.com/cometbft/cometbft/crypto/ed25519" tmjson "github.com/cometbft/cometbft/libs/json" @@ -27,7 +28,6 @@ import ( "github.com/cosmos/cosmos-sdk/types/mempool" authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" - minttypes "github.com/cosmos/cosmos-sdk/x/mint/types" stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" "github.com/stretchr/testify/require" diff --git a/app/upgrades/signetlaunch/README.md b/app/upgrades/signetlaunch/README.md deleted file mode 100644 index 9ac84d3e6..000000000 --- a/app/upgrades/signetlaunch/README.md +++ /dev/null @@ -1,59 +0,0 @@ -# Signet Launch - -This folder contains a software upgrade for testing purposes. -DO NOT USE IN PRODUCTION! - -## Compile signet launch upgrade - -This upgrade loads 2 JSONs from strings in different files. -BTC Headers from `./data_btc_headers.go` and signed messages -to create finality providers `./data_signed_fps.go`. - -### BTC Headers - -This upgrade accepts insertion of multiple -[`btclighttypes.BTCHeaderInfo`](../../../x/btclightclient/types/btclightclient.pb.go#36) -due to Babylon Phase-1 and Phase-2 launch will be a few months appart, so -during Phase-1 Babylon accepts BTC delegations without Babylonchain running. -At the time of launching the Babylonchain it is needed all the BTC block -headers that has passed since babylon started to accept BTC staking messages, -and to avoid giving too much work for -[vigilante](https://github.com/babylonlabs-io/vigilante) -to submit all of those missing headers. - -To generate this BTC headers there is a specific command in -[staking-indexer](https://github.com/babylonlabs-io/staking-indexer) -that query BTC for all the BTC headers and outputs it as json file -`sid btc-headers [from-block-height] [to-block-height]` and then -it is needed to recreate the golang file `./data_btc_headers.go` -with some simple bash script: - -```shell -GO_BTC_HEADERS_PATH="signetlaunch/data_btc_headers.go" -EXPORT_TO="./btc-headers.json" -# export the btc headers to a file -$SID_BIN btc-headers 1 1000 --output $EXPORT_TO -btcHeadersJson=$(cat $EXPORT_TO) - -# writes the headers to babylon as go file -echo "package signetlaunch - -const NewBtcHeadersStr = \`$btcHeadersJson\`" > $GO_BTC_HEADERS_PATH -``` - -### Signed Create Finality Provider - -For BTC stakers to stake during Phase-1 it is needed to have finality -providers. Babylon created a repository to publicly store this information -inside [networks](https://github.com/babylonlabs-io/networks) repository. -Inside the bbn-1 mainnet all the finality providers that wanted to be available -for BTC staking since the beginning would need to -[register](https://github.com/babylonlabs-io/networks/blob/main/bbn-1/finality-providers/README.md) -theirselves in the registry. -For the transition from Phase-1 to Phase-2, registered finality providers in -Phase-1 will need to provider a signed -[MsgCreateFinalityProvider](../../../x/btcstaking/types/tx.pb.go#38) as a -json file message inside the networks repository registry. - - diff --git a/app/upgrades/signetlaunch/btcstaking_params_test.go b/app/upgrades/signetlaunch/btcstaking_params_test.go deleted file mode 100644 index 1df82afe2..000000000 --- a/app/upgrades/signetlaunch/btcstaking_params_test.go +++ /dev/null @@ -1,17 +0,0 @@ -package signetlaunch_test - -import ( - "testing" - - "github.com/stretchr/testify/require" - - "github.com/babylonlabs-io/babylon/app" - v1 "github.com/babylonlabs-io/babylon/app/upgrades/signetlaunch" -) - -func TestHardCodedBtcStakingParamsAreValid(t *testing.T) { - bbnApp := app.NewTmpBabylonApp() - loadedParamas, err := v1.LoadBtcStakingParamsFromData(bbnApp.AppCodec()) - require.NoError(t, err) - require.NoError(t, loadedParamas.Validate()) -} diff --git a/app/upgrades/signetlaunch/data_signed_fps.go b/app/upgrades/signetlaunch/data_signed_fps.go deleted file mode 100644 index 38c531aeb..000000000 --- a/app/upgrades/signetlaunch/data_signed_fps.go +++ /dev/null @@ -1,122 +0,0 @@ -package signetlaunch - -const SignedFPsStr = `{ - "signed_txs_create_fp": [ - { - "body": { - "messages": [ - { - "@type": "/babylon.btcstaking.v1.MsgCreateFinalityProvider", - "addr": "bbn1gwecky0m842kvjg7mcvt9z330rz96948aplqlm", - "description": { - "moniker": "fp-1", - "identity": "", - "website": "fp1.com.br", - "security_contact": "fp.1@email.com", - "details": "best-fp-1" - }, - "commission": "0.050000000000000000", - "btc_pk": "a94eef36ea7c596ba01b2018d55c202ebd8a82a0baf1a435818bc524bfd4e10a", - "pop": { - "btc_sig_type": "BIP340", - "btc_sig": "q5aykrV4imao9kiIVvWhBf8hPbIQW7GbdnDDCAZQRyCm4ZBaUiAGO3oFbEgVeLKNAd0xGmcCAJSbXu0OrpcQkQ==" - } - } - ], - "memo": "", - "timeout_height": "0", - "extension_options": [], - "non_critical_extension_options": [] - }, - "auth_info": { - "signer_infos": [ - { - "public_key": { - "@type": "/cosmos.crypto.secp256k1.PubKey", - "key": "A9XXtGMjEFgavPv7GHo5rbI/XulwA0Hn2xlzsdCRDCTl" - }, - "mode_info": { - "single": { - "mode": "SIGN_MODE_DIRECT" - } - }, - "sequence": "0" - } - ], - "fee": { - "amount": [ - { - "denom": "ubbn", - "amount": "2000000" - } - ], - "gas_limit": "200000", - "payer": "", - "granter": "" - }, - "tip": null - }, - "signatures": [ - "8wQGbPM5Xc5PmrynGmxbslqSA6tFW/5Vgg9sVZZ1WWsRTR5m040t2wgR+BjUrLNnO+JtrDlb38Su4XFSR76b9Q==" - ] - }, - { - "body": { - "messages": [ - { - "@type": "/babylon.btcstaking.v1.MsgCreateFinalityProvider", - "addr": "bbn1mwwywrmynkf0n5maps6yrtvgx2qqh3mlccdg6g", - "description": { - "moniker": "fp-2", - "identity": "", - "website": "fp2.com.br", - "security_contact": "fp.2@email.com", - "details": "best-fp-2" - }, - "commission": "0.100000000000000000", - "btc_pk": "bae0f3bfedc4de9e776fcbbb4b1dbae2641193fc20527ffc0a728968ebcd2d95", - "pop": { - "btc_sig_type": "BIP340", - "btc_sig": "IFU+77I8e7VOGudJdN5kk/8Hs2Biqiiw+sejBbYrtPRSNhFRhFrxhOru5kYHPxZ2XwadlfZfZjmXB8Uvj/hb5w==" - } - } - ], - "memo": "", - "timeout_height": "0", - "extension_options": [], - "non_critical_extension_options": [] - }, - "auth_info": { - "signer_infos": [ - { - "public_key": { - "@type": "/cosmos.crypto.secp256k1.PubKey", - "key": "A3XkUtvcp3DnAvDKN4zYkES3xc6wi83LQBeAAlNG3Ebl" - }, - "mode_info": { - "single": { - "mode": "SIGN_MODE_DIRECT" - } - }, - "sequence": "0" - } - ], - "fee": { - "amount": [ - { - "denom": "ubbn", - "amount": "2000000" - } - ], - "gas_limit": "200000", - "payer": "", - "granter": "" - }, - "tip": null - }, - "signatures": [ - "QMpALwCa+mHtKRv9Jg9RyHg/lOnFNa5i09tHgHgSuwh8JbNalYy4v2bTZ2PGDUh0JZCPUMeO487WacZofVhl9g==" - ] - } - ] -}` diff --git a/app/upgrades/signetlaunch/data_signed_fps_test.go b/app/upgrades/signetlaunch/data_signed_fps_test.go deleted file mode 100644 index 338f863c8..000000000 --- a/app/upgrades/signetlaunch/data_signed_fps_test.go +++ /dev/null @@ -1,113 +0,0 @@ -package signetlaunch_test - -import ( - "bytes" - "encoding/json" - "testing" - "time" - - "github.com/babylonlabs-io/babylon/app" - v1 "github.com/babylonlabs-io/babylon/app/upgrades/signetlaunch" - btcstktypes "github.com/babylonlabs-io/babylon/x/btcstaking/types" - tmproto "github.com/cometbft/cometbft/proto/tendermint/types" - "github.com/cosmos/cosmos-sdk/codec" - sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/cosmos/cosmos-sdk/types/tx/signing" - "github.com/cosmos/cosmos-sdk/x/auth/ante" - authtx "github.com/cosmos/cosmos-sdk/x/auth/tx" - txmodule "github.com/cosmos/cosmos-sdk/x/auth/tx/config" - "github.com/stretchr/testify/require" -) - -func TestValidateSignatureSignedFPsFromData(t *testing.T) { - bbnApp := app.NewTmpBabylonApp() - cdc := bbnApp.AppCodec() - // the chain ID in context needs to match the one used when creating the tx signature. - chainID := "bbn-1" - - ctx := bbnApp.BaseApp.NewContextLegacy(true, tmproto.Header{Height: 1, ChainID: chainID, Time: time.Now().UTC()}) - buff := bytes.NewBufferString(v1.SignedFPsStr) - simulateTx := false - - var d v1.DataSignedFps - err := json.Unmarshal(buff.Bytes(), &d) - require.NoError(t, err) - - antehandlerSigVerifier := buildAnteHandlerSigVerifier(t, bbnApp) - - fpAddrs := make(map[string]interface{}, len(d.SignedTxsFP)) - for _, txAny := range d.SignedTxsFP { - txBytes, err := json.Marshal(txAny) - require.NoError(t, err) - - // decodes the transaction - tx, err := bbnApp.TxConfig().TxJSONDecoder()(txBytes) - require.NoError(t, err) - - msgs := tx.GetMsgs() - require.Len(t, msgs, 1) - - msg, ok := msgs[0].(*btcstktypes.MsgCreateFinalityProvider) - require.True(t, ok) - - _, exist := fpAddrs[msg.Addr] - require.False(t, exist) - fpAddrs[msg.Addr] = nil - - require.NoError(t, msg.ValidateBasic()) - - // loads messages from the tx, only one message per tx is allowed. - msgsV2, err := tx.GetMsgsV2() - require.NoError(t, err) - require.Len(t, msgsV2, 1) - - msgV2 := msgsV2[0] - signers, err := cdc.GetMsgV2Signers(msgV2) - require.NoError(t, err) - require.Len(t, signers, 1) - - // checks that the signer_infos corresponding address in the transaction - // matches the FP address defined. - signerAddrStr, err := cdc.InterfaceRegistry().SigningContext().AddressCodec().BytesToString(signers[0]) - require.NoError(t, err) - - signerBbnAddr, err := sdk.AccAddressFromBech32(signerAddrStr) - require.NoError(t, err) - - require.Equal(t, msg.Addr, signerAddrStr) - // Proof of Possession check only for type BIP340 as expected in the networks registry instructions - require.NoError(t, msg.Pop.VerifyBIP340(signerBbnAddr, msg.BtcPk)) - - // creates the account with the signer address and sets the - // sequence and acc number to zero every time, for this reason - // it needs to remove account right after, otherwise new accounts - // would have account number +1 and the signature verification would fail. - acc := bbnApp.AccountKeeper.NewAccountWithAddress(ctx, signerBbnAddr) - require.NoError(t, acc.SetSequence(0)) - require.NoError(t, acc.SetAccountNumber(0)) - bbnApp.AccountKeeper.SetAccount(ctx, acc) - - _, err = antehandlerSigVerifier(ctx, tx, simulateTx) - require.NoError(t, err) - - bbnApp.AccountKeeper.RemoveAccount(ctx, acc) - } -} - -func buildAnteHandlerSigVerifier(t *testing.T, bbnApp *app.BabylonApp) sdk.AnteHandler { - cdc := bbnApp.AppCodec() - - txConfigOpts := authtx.ConfigOptions{ - TextualCoinMetadataQueryFn: txmodule.NewBankKeeperCoinMetadataQueryFn(bbnApp.GetBankKeeper()), - EnabledSignModes: []signing.SignMode{signing.SignMode_SIGN_MODE_DIRECT}, - } - anteTxConfig, err := authtx.NewTxConfigWithOptions( - codec.NewProtoCodec(cdc.InterfaceRegistry()), - txConfigOpts, - ) - require.NoError(t, err) - - svd := ante.NewSigVerificationDecorator(bbnApp.AppKeepers.AccountKeeper, anteTxConfig.SignModeHandler()) - spkd := ante.NewSetPubKeyDecorator(bbnApp.AppKeepers.AccountKeeper) - return sdk.ChainAnteDecorators(spkd, svd) -} diff --git a/app/upgrades/signetlaunch/finality_params_test.go b/app/upgrades/signetlaunch/finality_params_test.go deleted file mode 100644 index d6ba29a34..000000000 --- a/app/upgrades/signetlaunch/finality_params_test.go +++ /dev/null @@ -1,17 +0,0 @@ -package signetlaunch_test - -import ( - "testing" - - "github.com/stretchr/testify/require" - - "github.com/babylonlabs-io/babylon/app" - v1 "github.com/babylonlabs-io/babylon/app/upgrades/signetlaunch" -) - -func TestHardCodedFinalityParamsAreValid(t *testing.T) { - bbnApp := app.NewTmpBabylonApp() - loadedParamas, err := v1.LoadFinalityParamsFromData(bbnApp.AppCodec()) - require.NoError(t, err) - require.NoError(t, loadedParamas.Validate()) -} diff --git a/app/upgrades/signetlaunch/upgrades.go b/app/upgrades/signetlaunch/upgrades.go deleted file mode 100644 index 2e3726f9e..000000000 --- a/app/upgrades/signetlaunch/upgrades.go +++ /dev/null @@ -1,269 +0,0 @@ -// This code is only for testing purposes. -// DO NOT USE IN PRODUCTION! - -package signetlaunch - -import ( - "bytes" - "context" - "encoding/json" - "errors" - "fmt" - "sort" - - store "cosmossdk.io/store/types" - upgradetypes "cosmossdk.io/x/upgrade/types" - "github.com/btcsuite/btcd/chaincfg" - "github.com/cosmos/cosmos-sdk/codec" - sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/cosmos/cosmos-sdk/types/module" - - "github.com/babylonlabs-io/babylon/app/keepers" - appparams "github.com/babylonlabs-io/babylon/app/params" - "github.com/babylonlabs-io/babylon/app/upgrades" - bbn "github.com/babylonlabs-io/babylon/types" - btclightkeeper "github.com/babylonlabs-io/babylon/x/btclightclient/keeper" - btclighttypes "github.com/babylonlabs-io/babylon/x/btclightclient/types" - btcstkkeeper "github.com/babylonlabs-io/babylon/x/btcstaking/keeper" - btcstktypes "github.com/babylonlabs-io/babylon/x/btcstaking/types" - bsctypes "github.com/babylonlabs-io/babylon/x/btcstkconsumer/types" - finalitykeeper "github.com/babylonlabs-io/babylon/x/finality/keeper" - finalitytypes "github.com/babylonlabs-io/babylon/x/finality/types" -) - -var Upgrade = upgrades.Upgrade{ - UpgradeName: "signet-launch", - CreateUpgradeHandler: CreateUpgradeHandler, - StoreUpgrades: store.StoreUpgrades{ - Added: []string{ - bsctypes.ModuleName, - }, - }, -} - -type DataSignedFps struct { - SignedTxsFP []any `json:"signed_txs_create_fp"` -} - -// CreateUpgradeHandler upgrade handler for launch. -func CreateUpgradeHandler( - mm *module.Manager, - cfg module.Configurator, - keepers *keepers.AppKeepers, -) upgradetypes.UpgradeHandler { - return func(context context.Context, _plan upgradetypes.Plan, fromVM module.VersionMap) (module.VersionMap, error) { - ctx := sdk.UnwrapSDKContext(context) - - migrations, err := mm.RunMigrations(ctx, cfg, fromVM) - if err != nil { - return nil, err - } - - // Upgrade the staking parameters as first, as other upgrades depend on it. - if err := upgradeBtcStakingParameters(ctx, keepers.EncCfg, &keepers.BTCStakingKeeper); err != nil { - panic(err) - } - - if err := upgradeFinalityParameters(ctx, keepers.EncCfg, &keepers.FinalityKeeper); err != nil { - panic(err) - } - - if err := propLaunch(ctx, keepers.EncCfg, &keepers.BTCLightClientKeeper, &keepers.BTCStakingKeeper); err != nil { - panic(err) - } - - return migrations, nil - } -} - -func LoadBtcStakingParamsFromData(cdc codec.Codec) (btcstktypes.Params, error) { - buff := bytes.NewBufferString(BtcStakingParamStr) - - var params btcstktypes.Params - err := cdc.UnmarshalJSON(buff.Bytes(), ¶ms) - if err != nil { - return btcstktypes.Params{}, err - } - - return params, nil -} - -func LoadFinalityParamsFromData(cdc codec.Codec) (finalitytypes.Params, error) { - buff := bytes.NewBufferString(FinalityParamStr) - - var params finalitytypes.Params - err := cdc.UnmarshalJSON(buff.Bytes(), ¶ms) - if err != nil { - return finalitytypes.Params{}, err - } - - return params, nil -} - -func upgradeBtcStakingParameters( - ctx sdk.Context, - e *appparams.EncodingConfig, - k *btcstkkeeper.Keeper, -) error { - - cdc := e.Codec - - params, err := LoadBtcStakingParamsFromData(cdc) - - if err != nil { - return err - } - - // We are overwriting the params at version 0, as the upgrade is happening from - // TGE chain so there should be only one version of the params - return k.OverwriteParamsAtVersion(ctx, 0, params) -} - -func upgradeFinalityParameters( - ctx sdk.Context, - e *appparams.EncodingConfig, - k *finalitykeeper.Keeper, -) error { - - cdc := e.Codec - - params, err := LoadFinalityParamsFromData(cdc) - - if err != nil { - return err - } - - return k.SetParams(ctx, params) -} - -// propLaunch runs the proposal of launch that is meant to insert new BTC Headers. -func propLaunch( - ctx sdk.Context, - encCfg *appparams.EncodingConfig, - btcLigthK *btclightkeeper.Keeper, - btcStkK *btcstkkeeper.Keeper, -) error { - cdc := encCfg.Codec - - newHeaders, err := LoadBTCHeadersFromData(cdc) - if err != nil { - return err - } - - if err := insertBtcHeaders(ctx, btcLigthK, newHeaders); err != nil { - return err - } - - fps, err := LoadSignedFPsFromData(cdc, encCfg.TxConfig.TxJSONDecoder()) - if err != nil { - return err - } - - return insertFPs(ctx, btcStkK, fps) -} - -// LoadBTCHeadersFromData returns the BTC headers load from the json string with the headers inside of it. -func LoadBTCHeadersFromData(cdc codec.Codec) ([]*btclighttypes.BTCHeaderInfo, error) { - buff := bytes.NewBufferString(NewBtcHeadersStr) - - var gs btclighttypes.GenesisState - err := cdc.UnmarshalJSON(buff.Bytes(), &gs) - if err != nil { - return nil, err - } - - return gs.BtcHeaders, nil -} - -// LoadSignedFPsFromData returns the finality providers from the json string. -func LoadSignedFPsFromData(cdc codec.Codec, txJSONDecoder sdk.TxDecoder) ([]*btcstktypes.MsgCreateFinalityProvider, error) { - buff := bytes.NewBufferString(SignedFPsStr) - - var d DataSignedFps - err := json.Unmarshal(buff.Bytes(), &d) - if err != nil { - return nil, err - } - - fps := make([]*btcstktypes.MsgCreateFinalityProvider, len(d.SignedTxsFP)) - for i, txAny := range d.SignedTxsFP { - txBytes, err := json.Marshal(txAny) - if err != nil { - return nil, err - } - - tx, err := txJSONDecoder(txBytes) - if err != nil { - return nil, err - } - - fp, err := parseCreateFPFromSignedTx(cdc, tx) - if err != nil { - return nil, err - } - - fps[i] = fp - } - - // sorts all the FPs by their addresses - sort.Slice(fps, func(i, j int) bool { - return fps[i].Addr > fps[j].Addr - }) - - return fps, nil -} - -func parseCreateFPFromSignedTx(cdc codec.Codec, tx sdk.Tx) (*btcstktypes.MsgCreateFinalityProvider, error) { - msgs := tx.GetMsgs() - if len(msgs) != 1 { - return nil, fmt.Errorf("each tx should contain only one message, invalid tx %+v", tx) - } - - msg, ok := msgs[0].(*btcstktypes.MsgCreateFinalityProvider) - if !ok { - return nil, fmt.Errorf("unable to parse %+v to MsgCreateFinalityProvider", msg) - } - - return msg, nil -} - -func insertFPs( - ctx sdk.Context, - k *btcstkkeeper.Keeper, - fps []*btcstktypes.MsgCreateFinalityProvider, -) error { - for _, fp := range fps { - if err := k.AddFinalityProvider(ctx, fp); err != nil { - return err - } - } - - return nil -} - -func insertBtcHeaders( - ctx sdk.Context, - k *btclightkeeper.Keeper, - btcHeaders []*btclighttypes.BTCHeaderInfo, -) error { - if len(btcHeaders) == 0 { - return errors.New("no headers to insert") - } - - headersBytes := make([]bbn.BTCHeaderBytes, len(btcHeaders)) - for i, btcHeader := range btcHeaders { - h := btcHeader - headersBytes[i] = *h.Header - } - - if err := k.InsertHeaders(ctx, headersBytes); err != nil { - return err - } - - allBlocks := k.GetMainChainFromWithLimit(ctx, 0, 1) - isRetarget := btclighttypes.IsRetargetBlock(allBlocks[0], &chaincfg.SigNetParams) - if !isRetarget { - return fmt.Errorf("first header be a difficulty adjustment block") - } - return nil -} diff --git a/app/upgrades/signetlaunch/upgrades_test.go b/app/upgrades/signetlaunch/upgrades_test.go deleted file mode 100644 index 11245bcc6..000000000 --- a/app/upgrades/signetlaunch/upgrades_test.go +++ /dev/null @@ -1,165 +0,0 @@ -package signetlaunch_test - -import ( - "fmt" - "testing" - "time" - - "cosmossdk.io/core/appmodule" - "cosmossdk.io/core/header" - "cosmossdk.io/x/upgrade" - upgradetypes "cosmossdk.io/x/upgrade/types" - tmproto "github.com/cometbft/cometbft/proto/tendermint/types" - sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/stretchr/testify/suite" - - "github.com/babylonlabs-io/babylon/app" - v1 "github.com/babylonlabs-io/babylon/app/upgrades/signetlaunch" - "github.com/babylonlabs-io/babylon/x/btclightclient" - btclighttypes "github.com/babylonlabs-io/babylon/x/btclightclient/types" - "github.com/babylonlabs-io/babylon/x/btcstaking/types" -) - -const ( - DummyUpgradeHeight = 5 -) - -type UpgradeTestSuite struct { - suite.Suite - - ctx sdk.Context - app *app.BabylonApp - preModule appmodule.HasPreBlocker -} - -func (s *UpgradeTestSuite) SetupTest() { - // add the upgrade plan - app.Upgrades = append(app.Upgrades, v1.Upgrade) - - // set up app - s.app = app.Setup(s.T(), false) - s.ctx = s.app.BaseApp.NewContextLegacy(false, tmproto.Header{Height: 1, ChainID: "babylon-1", Time: time.Now().UTC()}) - s.preModule = upgrade.NewAppModule(s.app.UpgradeKeeper, s.app.AccountKeeper.AddressCodec()) - - btcHeaderGenesis, err := app.SignetBtcHeaderGenesis(s.app.EncodingConfig().Codec) - s.NoError(err) - - k := s.app.BTCLightClientKeeper - btclightclient.InitGenesis(s.ctx, s.app.BTCLightClientKeeper, btclighttypes.GenesisState{ - Params: k.GetParams(s.ctx), - BtcHeaders: []*btclighttypes.BTCHeaderInfo{btcHeaderGenesis}, - }) -} - -func TestKeeperTestSuite(t *testing.T) { - suite.Run(t, new(UpgradeTestSuite)) -} - -func (s *UpgradeTestSuite) TestUpgrade() { - oldHeadersLen := 0 - oldFPsLen := 0 - - testCases := []struct { - msg string - pre_update func() - update func() - post_update func() - }{ - { - "Test launch software upgrade gov prop", - func() { - allBtcHeaders := s.app.BTCLightClientKeeper.GetMainChainFrom(s.ctx, 0) - oldHeadersLen = len(allBtcHeaders) - - resp, err := s.app.BTCStakingKeeper.FinalityProviders(s.ctx, &types.QueryFinalityProvidersRequest{}) - s.NoError(err) - oldFPsLen = len(resp.FinalityProviders) - - // Before upgrade, the params should be different - bsParamsFromUpgrade, err := v1.LoadBtcStakingParamsFromData(s.app.AppCodec()) - s.NoError(err) - bsModuleParams := s.app.BTCStakingKeeper.GetParams(s.ctx) - s.NotEqualValues(bsModuleParams, bsParamsFromUpgrade) - fParamsFromUpgrade, err := v1.LoadFinalityParamsFromData(s.app.AppCodec()) - s.NoError(err) - fModuleParams := s.app.FinalityKeeper.GetParams(s.ctx) - s.NotEqualValues(fModuleParams, fParamsFromUpgrade) - }, - func() { - // inject upgrade plan - s.ctx = s.ctx.WithBlockHeight(DummyUpgradeHeight - 1) - plan := upgradetypes.Plan{Name: v1.Upgrade.UpgradeName, Height: DummyUpgradeHeight} - err := s.app.UpgradeKeeper.ScheduleUpgrade(s.ctx, plan) - s.NoError(err) - - // ensure upgrade plan exists - actualPlan, err := s.app.UpgradeKeeper.GetUpgradePlan(s.ctx) - s.NoError(err) - s.Equal(plan, actualPlan) - - // execute upgrade - s.ctx = s.ctx.WithHeaderInfo(header.Info{Height: DummyUpgradeHeight, Time: s.ctx.BlockTime().Add(time.Second)}).WithBlockHeight(DummyUpgradeHeight) - s.NotPanics(func() { - _, err := s.preModule.PreBlock(s.ctx) - s.NoError(err) - }) - }, - func() { - // ensure the btc headers were added - allBtcHeaders := s.app.BTCLightClientKeeper.GetMainChainFrom(s.ctx, 0) - - btcHeadersInserted, err := v1.LoadBTCHeadersFromData(s.app.AppCodec()) - s.NoError(err) - lenHeadersInserted := len(btcHeadersInserted) - - newHeadersLen := len(allBtcHeaders) - s.Equal(newHeadersLen, oldHeadersLen+lenHeadersInserted) - - // ensure the headers were inserted as expected - for i, btcHeaderInserted := range btcHeadersInserted { - btcHeaderInState := allBtcHeaders[oldHeadersLen+i] - - s.EqualValues(btcHeaderInserted.Header.MarshalHex(), btcHeaderInState.Header.MarshalHex()) - } - - resp, err := s.app.BTCStakingKeeper.FinalityProviders(s.ctx, &types.QueryFinalityProvidersRequest{}) - s.NoError(err) - newFPsLen := len(resp.FinalityProviders) - - fpsInserted, err := v1.LoadSignedFPsFromData(s.app.AppCodec(), s.app.TxConfig().TxJSONDecoder()) - s.NoError(err) - - s.Equal(newFPsLen, oldFPsLen+len(fpsInserted)) - for _, fpInserted := range fpsInserted { - fpFromKeeper, err := s.app.BTCStakingKeeper.GetFinalityProvider(s.ctx, *fpInserted.BtcPk) - s.NoError(err) - - s.EqualValues(fpFromKeeper.Addr, fpInserted.Addr) - s.EqualValues(fpFromKeeper.Description, fpInserted.Description) - s.EqualValues(fpFromKeeper.Commission.String(), fpInserted.Commission.String()) - s.EqualValues(fpFromKeeper.Pop.String(), fpInserted.Pop.String()) - } - - // After upgrade, the params should be the same - bsParamsFromUpgrade, err := v1.LoadBtcStakingParamsFromData(s.app.AppCodec()) - s.NoError(err) - bsModuleParams := s.app.BTCStakingKeeper.GetParams(s.ctx) - s.EqualValues(bsModuleParams, bsParamsFromUpgrade) - fParamsFromUpgrade, err := v1.LoadFinalityParamsFromData(s.app.AppCodec()) - s.NoError(err) - fModuleParams := s.app.FinalityKeeper.GetParams(s.ctx) - s.EqualValues(fModuleParams, fParamsFromUpgrade) - }, - }, - } - - for _, tc := range testCases { - s.Run(fmt.Sprintf("Case %s", tc.msg), func() { - s.SetupTest() // reset - - tc.pre_update() - tc.update() - tc.post_update() - }) - } -} diff --git a/app/upgrades/types.go b/app/upgrades/types.go index 4ec0962af..8404ee292 100644 --- a/app/upgrades/types.go +++ b/app/upgrades/types.go @@ -26,12 +26,15 @@ type Upgrade struct { UpgradeName string // CreateUpgradeHandler defines the function that creates an upgrade handler - CreateUpgradeHandler func(*module.Manager, module.Configurator, *keepers.AppKeepers) upgradetypes.UpgradeHandler + CreateUpgradeHandler UpgradeHandlerCreator // Store upgrades, should be used for any new modules introduced, new modules deleted, or store names renamed. StoreUpgrades store.StoreUpgrades } +// UpgradeHandlerCreator returns a function to run the upgrade handler according to the x/upgrade handler. +type UpgradeHandlerCreator func(*module.Manager, module.Configurator, *keepers.AppKeepers) upgradetypes.UpgradeHandler + // Fork defines a struct containing the requisite fields for a non-software upgrade proposal // Hard Fork at a given height to implement. // There is one time code that can be added for the start of the Fork, in `BeginForkLogic`. diff --git a/app/upgrades/v1/README.md b/app/upgrades/v1/README.md new file mode 100644 index 000000000..518d3a472 --- /dev/null +++ b/app/upgrades/v1/README.md @@ -0,0 +1,96 @@ +# Upgrade V1 + +Babylon launched as Phase-1 without a cosmos chain running +to collect BTC staking prior to decentralize the finality provider +set of operators. The first upgrade of Babylon chain to start +receiving BTC delegations will include the BTC headers created +during Phase-1 and upgrade, tokens distribution for the active users +and operators that participated and need to finish their actions and +update of parameters for `x/finality` and `x/btcstaking` modules. + +## Testnet vs Mainnet + +Babylon upgrade data will be different for mainnet and testnet, +The BTC Headers are different as the Bitcoin mainnet and signet produces +different block headers. So, the upgrade data will be divided into 2 +`app/upgrades/v1`: + +- `app/upgrades/v1/mainnet` contains the files with JSON string for mainnet. +- `app/upgrades/v1/testnet` contains the files with JSON string for testnet. + +## Devnets + +Devnets that are only for internal testing should just replace the upgrade +data files in testnet and build the binary with `make build-testnet`. No need +to push the devenet data into the github repository. + +## Upgrade data as string + +The upgrade data was left as string to make it easier for `devnet` testing +where it is needed to replace the data files, and would be harder to create +the data files if it used actual go structures to generate the data. + +This upgrade loads 5 JSONs from strings in different files. + +- BTC Headers at `./data_btc_headers.go` +- Tokens distribution at `./data_token_distribution.go` +- BTC Staking Parameters `./btcstaking_params.go` +- Incentive Parameters `./incentive.go` +- Finality Parameters `./finality_params.go` +- CosmWasm Parameters `./cosmwasm_params.go` +- Allowed Staking Tx Hashes `./allowed_staking_tx_hashes.go` + +### BTC Headers + +This upgrade accepts insertion of multiple +[`btclighttypes.BTCHeaderInfo`](../../../x/btclightclient/types/btclightclient.pb.go#36) +due to Babylon Phase-1 and Phase-2 launch will be a few months apart, so +during Phase-1 Babylon accepts BTC delegations without Babylonchain running. +At the time of launching the Babylonchain it is needed all the BTC block +headers that has passed since babylon started to accept BTC staking messages, +and to avoid giving too much work for +[vigilante](https://github.com/babylonlabs-io/vigilante) +to submit all of those missing headers. + +To generate this BTC headers there is a specific command in +[staking-indexer](https://github.com/babylonlabs-io/staking-indexer) +that query BTC for all the BTC headers and outputs it as json file +`sid btc-headers [from-block-height] [to-block-height]` and then +it is needed to recreate the golang file `./data_btc_headers.go` +with some simple bash script: + +```shell +GO_BTC_HEADERS_PATH="signetlaunch/data_btc_headers.go" +EXPORT_TO="./btc-headers.json" +# export the btc headers to a file +$SID_BIN btc-headers 1 1000 --output $EXPORT_TO +btcHeadersJson=$(cat $EXPORT_TO) + +# writes the headers to babylon as go file +echo "package signetlaunch + +const NewBtcHeadersStr = \`$btcHeadersJson\`" > $GO_BTC_HEADERS_PATH +``` + +### Tokens distribution + +During the upgrade, some tokens will be distributed so users and operators can +finish their actions, by example: + +- BTC stakers to finalize their BTC delegation +- Finality providers to submit pub rand and finality +- New Cosmos-SDK validators to decentralize after the upgrade +- Vigilantes +- Covenant Emulators + +> This data for token distribution will be built accordingly with the +data collected during Phase-1. + +## Building with Upgrade + +Upgrade plan is included based on the build tags. +By default the mainnet data is included with the upgrade plan, +so running `make build` already adds the mainnet build tag and +includes the upgrade plan with the mainnet data. If `make build-testnet` +is run, it includes the `testnet` build tag and only includes the +data for testnet in the upgrade plan. diff --git a/app/upgrades/v1/data_allowed_staking_tx_hashes_test.go b/app/upgrades/v1/data_allowed_staking_tx_hashes_test.go new file mode 100644 index 000000000..0133096db --- /dev/null +++ b/app/upgrades/v1/data_allowed_staking_tx_hashes_test.go @@ -0,0 +1,23 @@ +package v1_test + +import ( + "testing" + + v1 "github.com/babylonlabs-io/babylon/app/upgrades/v1" + "github.com/btcsuite/btcd/chaincfg/chainhash" + "github.com/stretchr/testify/require" +) + +func TestLoadAllowedStakingTxHashesFromData(t *testing.T) { + for _, upgradeData := range UpgradeV1Data { + d, err := v1.LoadAllowedStakingTransactionHashesFromData(upgradeData.AllowedStakingTxHashesStr) + require.NoError(t, err) + require.NotNil(t, d) + require.Greater(t, len(d.TxHashes), 0) + + for _, txHash := range d.TxHashes { + _, err := chainhash.NewHashFromStr(txHash) + require.NoError(t, err) + } + } +} diff --git a/app/upgrades/v1/data_params_test.go b/app/upgrades/v1/data_params_test.go new file mode 100644 index 000000000..01586760f --- /dev/null +++ b/app/upgrades/v1/data_params_test.go @@ -0,0 +1,40 @@ +package v1_test + +import ( + "testing" + + wasmtypes "github.com/CosmWasm/wasmd/x/wasm/types" + "github.com/stretchr/testify/require" + + "github.com/babylonlabs-io/babylon/app" + v1 "github.com/babylonlabs-io/babylon/app/upgrades/v1" +) + +func TestHardCodedBtcStakingParamsAreValid(t *testing.T) { + bbnApp := app.NewTmpBabylonApp() + for _, upgradeData := range UpgradeV1Data { + params, err := v1.LoadBtcStakingParamsFromData(bbnApp.AppCodec(), upgradeData.BtcStakingParamStr) + require.NoError(t, err) + require.NoError(t, params.Validate()) + } +} + +func TestHardCodedFinalityParamsAreValid(t *testing.T) { + bbnApp := app.NewTmpBabylonApp() + for _, upgradeData := range UpgradeV1Data { + params, err := v1.LoadFinalityParamsFromData(bbnApp.AppCodec(), upgradeData.FinalityParamStr) + require.NoError(t, err) + require.NoError(t, params.Validate()) + } +} + +func TestHardCodedWasmParamsAreValid(t *testing.T) { + bbnApp := app.NewTmpBabylonApp() + + for _, upgradeData := range UpgradeV1Data { + params, err := v1.LoadCosmWasmParamsFromData(bbnApp.AppCodec(), upgradeData.CosmWasmParamStr) + require.NoError(t, err) + require.NotNil(t, params) + require.Equal(t, params.InstantiateDefaultPermission, wasmtypes.AccessTypeEverybody) + } +} diff --git a/app/upgrades/v1/data_token_distribution_test.go b/app/upgrades/v1/data_token_distribution_test.go new file mode 100644 index 000000000..62107cdf6 --- /dev/null +++ b/app/upgrades/v1/data_token_distribution_test.go @@ -0,0 +1,29 @@ +package v1_test + +import ( + "testing" + + v1 "github.com/babylonlabs-io/babylon/app/upgrades/v1" + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/stretchr/testify/require" +) + +func TestCheckTokensDistributionFromData(t *testing.T) { + for _, upgradeData := range UpgradeV1Data { + d, err := v1.LoadTokenDistributionFromData(upgradeData.TokensDistributionStr) + require.NoError(t, err) + require.Greater(t, len(d.TokenDistribution), 1) + + for _, td := range d.TokenDistribution { + sender, err := sdk.AccAddressFromBech32(td.AddressSender) + require.NoError(t, err) + require.Equal(t, sender.String(), td.AddressSender) + + receiver, err := sdk.AccAddressFromBech32(td.AddressReceiver) + require.NoError(t, err) + require.Equal(t, receiver.String(), td.AddressReceiver) + + require.True(t, td.Amount > 0) + } + } +} diff --git a/app/upgrades/v1/mainnet/allowed_staking_tx_hashes.go b/app/upgrades/v1/mainnet/allowed_staking_tx_hashes.go new file mode 100644 index 000000000..ce4c7ff29 --- /dev/null +++ b/app/upgrades/v1/mainnet/allowed_staking_tx_hashes.go @@ -0,0 +1,9 @@ +package mainnet + +// TODO: Specify allowed staking tx hashes for v1 upgrade for mainnet +const AllowedStakingTxHashesStr = `{ + "tx_hashes": [ + "90463a1e0b19137f07c304f2c1c79351fa6f97f1195f1f90dc0b3b57893a350d", + "1db6de324beefd6870ec62a7385cac7144a43eba8e61fca202a8b41d963680ef" + ] +}` diff --git a/app/upgrades/signetlaunch/data_btc_headers.go b/app/upgrades/v1/mainnet/btc_headers.go similarity index 99% rename from app/upgrades/signetlaunch/data_btc_headers.go rename to app/upgrades/v1/mainnet/btc_headers.go index 408de35f3..88fd8ce40 100644 --- a/app/upgrades/signetlaunch/data_btc_headers.go +++ b/app/upgrades/v1/mainnet/btc_headers.go @@ -1,4 +1,4 @@ -package signetlaunch +package mainnet const NewBtcHeadersStr = `{ "btc_headers": [ diff --git a/app/upgrades/signetlaunch/btcstaking_params.go b/app/upgrades/v1/mainnet/btcstaking_params.go similarity index 90% rename from app/upgrades/signetlaunch/btcstaking_params.go rename to app/upgrades/v1/mainnet/btcstaking_params.go index 2b189ca4c..da035c579 100644 --- a/app/upgrades/signetlaunch/btcstaking_params.go +++ b/app/upgrades/v1/mainnet/btcstaking_params.go @@ -1,4 +1,4 @@ -package signetlaunch +package mainnet // TODO Some default parameters. Consider how to switch those depending on network: // mainnet, testnet, devnet etc. @@ -22,5 +22,6 @@ const BtcStakingParamStr = ` "min_unbonding_time_blocks": 0, "unbonding_fee_sat": "1000", "min_commission_rate": "0.03", - "max_active_finality_providers": 100 + "delegation_creation_base_gas_fee": 1000, + "allow_list_expiration_height": 0 }` diff --git a/app/upgrades/v1/mainnet/cosmwasm_params.go b/app/upgrades/v1/mainnet/cosmwasm_params.go new file mode 100644 index 000000000..eedd6d770 --- /dev/null +++ b/app/upgrades/v1/mainnet/cosmwasm_params.go @@ -0,0 +1,12 @@ +package mainnet + +// CosmWasm parameters for mainnet should allow only the +// governance module account authtypes.NewModuleAddress(govtypes.ModuleName) +// to upload and everybody to instantiate. +const CosmWasmParamStr = `{ + "code_upload_access": { + "permission": "AnyOfAddresses", + "addresses": ["bbn10d07y265gmmuvt4z0w9aw880jnsr700jduz5f2"] + }, + "instantiate_default_permission": "Everybody" +}` diff --git a/app/upgrades/v1/mainnet/finality_params.go b/app/upgrades/v1/mainnet/finality_params.go new file mode 100644 index 000000000..1a83b3ac3 --- /dev/null +++ b/app/upgrades/v1/mainnet/finality_params.go @@ -0,0 +1,13 @@ +package mainnet + +// TODO Some default parameters. Consider how to switch those depending on network: +// mainnet, testnet, devnet etc. +const FinalityParamStr = `{ + "max_active_finality_providers": 100, + "signed_blocks_window": 100, + "finality_sig_timeout": 3, + "min_signed_per_window": "0.1", + "min_pub_rand": 100, + "jail_duration": "86400s", + "finality_activation_height": 17500 +}` diff --git a/app/upgrades/v1/mainnet/incentive.go b/app/upgrades/v1/mainnet/incentive.go new file mode 100644 index 000000000..8d0830157 --- /dev/null +++ b/app/upgrades/v1/mainnet/incentive.go @@ -0,0 +1,5 @@ +package mainnet + +const IncentiveParamStr = `{ + "btc_staking_portion": "0.6" +}` diff --git a/app/upgrades/v1/mainnet/token_distribution.go b/app/upgrades/v1/mainnet/token_distribution.go new file mode 100644 index 000000000..09ca08447 --- /dev/null +++ b/app/upgrades/v1/mainnet/token_distribution.go @@ -0,0 +1,26 @@ +package mainnet + +const TokensDistributionStr = `{ + "token_distribution": [ + { + "address_sender": "bbn14d97wthm9fqvvdd96ax8lnfppwknndxztevs7k", + "address_receiver": "bbn13t5cnqj6t0p4xa40cwhmgv4wju0zl6g8slk8rz", + "amount": 100000 + }, + { + "address_sender": "bbn10d07y265gmmuvt4z0w9aw880jnsr700jduz5f2", + "address_receiver": "bbn1yl6hdjhmkf37639730gffanpzndzdpmhep8cg6", + "amount": 1500000 + }, + { + "address_sender": "bbn10d07y265gmmuvt4z0w9aw880jnsr700jduz5f2", + "address_receiver": "bbn1k6u5pge8w6lavtmunp02smehr4qtazkw8clg04", + "amount": 700000 + }, + { + "address_sender": "bbn10d07y265gmmuvt4z0w9aw880jnsr700jduz5f2", + "address_receiver": "bbn1dj2c57fjv6md7pzykh9y6h407ln6xxcw090hre", + "amount": 100000 + } + ] +}` diff --git a/app/upgrades/v1/testdata/reflect_1_5.wasm b/app/upgrades/v1/testdata/reflect_1_5.wasm new file mode 100644 index 000000000..073a4f406 Binary files /dev/null and b/app/upgrades/v1/testdata/reflect_1_5.wasm differ diff --git a/app/upgrades/v1/testnet/allowed_staking_tx_hashes.go b/app/upgrades/v1/testnet/allowed_staking_tx_hashes.go new file mode 100644 index 000000000..56fa315f6 --- /dev/null +++ b/app/upgrades/v1/testnet/allowed_staking_tx_hashes.go @@ -0,0 +1,9 @@ +package testnet + +// TODO: Specify allowed staking tx hashes for v1 upgrade for testnet +const AllowedStakingTxHashesStr = `{ + "tx_hashes": [ + "a3572b22571b46b7688fbfe1e8aeee82bb772d52c5ddb069cda361dc33fb4191", + "276a2b384614976c9a6a737f347e981b91f4dc269ee510a6f71e5eec9ecb903a" + ] +}` diff --git a/app/upgrades/v1/testnet/btc_headers.go b/app/upgrades/v1/testnet/btc_headers.go new file mode 100644 index 000000000..768885016 --- /dev/null +++ b/app/upgrades/v1/testnet/btc_headers.go @@ -0,0 +1,51 @@ +package testnet + +const NewBtcHeadersStr = `{ + "btc_headers": [ + { + "header": "00000020f61eee3b63a380a477a063af32b2bbc97c9ff9f01f2c4225e973988108000000f575c83235984e7dc4afc1f30944c170462e84437ab6f2d52e16878a79e4678bd1914d5fae77031eccf40700" + }, + { + "header": "00000020533b53ded9bff4adc94101d32400a144c54edc5ed492a3b26c63b2d686000000b38fef50592017cfafbcab88eb3d9cf50b2c801711cad8299495d26df5e54812e7914d5fae77031ecfdd0b00" + }, + { + "header": "000000202960f3752f0bfa8858a3e333294aedc7808025e868c9dc03e71d88bb320000007765fcd3d5b4966beb338bba2675dc2cf2ad28d4ad1d83bdb6f286e7e27ac1f807924d5fae77031e81d60b00" + }, + { + "header": "00000020b06443a13ae1d3d50faef5ecad38c6818194dc46abca3e972e2aacdae800000069a5829097e80fee00ac49a56ea9f82d741a6af84d32b3bc455cf31871e2a8ac27924d5fae77031e9c910500" + }, + { + "header": "000000207ed403758a4f228a1939418a155e2ebd4ae6b26e5ffd0ae433123f7694010000542e80b609c5bc58af5bdf492e26d4f60cd43a3966c2e063c50444c29b3757a636924d5fae77031ee8601d00" + }, + { + "header": "000000205bea0a88d1422c3df08d766ad72df95084d0700e6f873b75dd4e986c7703000002b57516d33ed60c2bdd9f93d6d5614083324c837e68e5ba6e04287a7285633585924d5fae77031ed1719600" + }, + { + "header": "00000020daf3b60d374b19476461f97540498dcfa2eb7016238ec6b1d022f82fb60100007a7ae65b53cb988c2ec92d2384996713821d5645ffe61c9acea60da75cd5edfa1a944d5fae77031e9dbb0500" + }, + { + "header": "00000020457cc5f3c2e1a5655bc20e20e48d33e1b7ea68786c614032b5c518f0b6000000541f36942d82c6e7248275ff15c8933487fbe1819c67a9ecc0f4b70bb7e6cf672a944d5fae77031e8f398600" + }, + { + "header": "00000020a2eb61eb4f3831baa3a3363e1b42db4462663f756f07423e81ed30322102000077224de7dea0f8d0ec22b1d2e2e255f0a987b96fe7200e1a2e6373f48a2f5b7894954d5fae77031e36867e00" + }, + { + "header": "00000020a868e8514be5e46dabd6a122132f423f36a43b716a40c394e2a8d063e1010000f4c6c717e99d800c699c25a2006a75a0c5c09f432a936f385e6fce139cdbd1a5e9964d5fae77031e7d026e00" + }, + { + "header": "000000205b969d72d19a47f39703c89a0cdb9eada8c4db934064f30e31f89a8e41010000949eef89068ffc76bf4dca6762e26581d410d0df40edf147d4ffdc6dea404a1512984d5fae77031ee67c1200" + }, + { + "header": "000000209410d824b5c57e762922a4035d300bd1d24db4e57b130ff7762ae5df4c030000532299955b2dc6bd7c13c267d3c0990fefdf7aec3bcbab5b2c85d0d36316f93644984d5fae77031ecdea1600" + }, + { + "header": "0000002009f649453a4079cb1d1beb138ea915d2355788bd4689785ecf7a265d3700000010bd26b43a88350e614736674431e62cc7c77dc577d07edd80620a02339d5fab82984d5fae77031efe682400" + }, + { + "header": "0000002035b9ff9157a6e7b5b9ee3807b8246ab687d2ee340f5b0f86cd0e2798aa00000028ef48260b3c0d45bbe5321335b05dde8fcb130e063202457884585298b8a5dde4984d5fae77031ec0a08600" + }, + { + "header": "0000002086102ffb6fd14131a08faa1e87680d5470954ba9638f15b56b7345de500100009f423c63aa6d39330082b58808013a85af5a7f338a7a3587f0a85b587665e6174e9a4d5fae77031e79353a00" + } + ] +}` diff --git a/app/upgrades/v1/testnet/btcstaking_params.go b/app/upgrades/v1/testnet/btcstaking_params.go new file mode 100644 index 000000000..a83dabacc --- /dev/null +++ b/app/upgrades/v1/testnet/btcstaking_params.go @@ -0,0 +1,27 @@ +package testnet + +// TODO Some default parameters. Consider how to switch those depending on network: +// mainnet, testnet, devnet etc. +const BtcStakingParamStr = ` + { + "covenant_pks": [ + "43311589af63c2adda04fcd7792c038a05c12a4fe40351b3eb1612ff6b2e5a0e", + "d415b187c6e7ce9da46ac888d20df20737d6f16a41639e68ea055311e1535dd9", + "d27cd27dbff481bc6fc4aa39dd19405eb6010237784ecba13bab130a4a62df5d", + "a3e107fee8879f5cf901161dbf4ff61c252ba5fec6f6407fe81b9453d244c02c", + "c45753e856ad0abb06f68947604f11476c157d13b7efd54499eaa0f6918cf716" + ], + "covenant_quorum": 3, + "min_staking_value_sat": "1000", + "max_staking_value_sat": "10000000000", + "min_staking_time_blocks": 10, + "max_staking_time_blocks": 65535, + "slashing_pk_script": "dqkUAQEBAQEBAQEBAQEBAQEBAQEBAQGIrA==", + "min_slashing_tx_fee_sat": "1000", + "slashing_rate": "0.100000000000000000", + "min_unbonding_time_blocks": 0, + "unbonding_fee_sat": "1000", + "min_commission_rate": "0.03", + "delegation_creation_base_gas_fee": 1000, + "allow_list_expiration_height": 0 +}` diff --git a/app/upgrades/v1/testnet/cosmwasm_params.go b/app/upgrades/v1/testnet/cosmwasm_params.go new file mode 100644 index 000000000..a068d2524 --- /dev/null +++ b/app/upgrades/v1/testnet/cosmwasm_params.go @@ -0,0 +1,10 @@ +package testnet + +// CosmWasm parameters for testnet should allow everybody to +// upload and instantiate. +const CosmWasmParamStr = `{ + "code_upload_access": { + "permission": "Everybody" + }, + "instantiate_default_permission": "Everybody" +}` diff --git a/app/upgrades/signetlaunch/finality_params.go b/app/upgrades/v1/testnet/finality_params.go similarity index 68% rename from app/upgrades/signetlaunch/finality_params.go rename to app/upgrades/v1/testnet/finality_params.go index 08b75dcda..1c7fe9339 100644 --- a/app/upgrades/signetlaunch/finality_params.go +++ b/app/upgrades/v1/testnet/finality_params.go @@ -1,11 +1,13 @@ -package signetlaunch +package testnet // TODO Some default parameters. Consider how to switch those depending on network: // mainnet, testnet, devnet etc. const FinalityParamStr = `{ + "max_active_finality_providers": 100, "signed_blocks_window": 100, "finality_sig_timeout": 3, "min_signed_per_window": "0.1", "min_pub_rand": 100, - "jail_duration": "86400s" + "jail_duration": "86400s", + "finality_activation_height": 75 }` diff --git a/app/upgrades/v1/testnet/incentive.go b/app/upgrades/v1/testnet/incentive.go new file mode 100644 index 000000000..418c9964b --- /dev/null +++ b/app/upgrades/v1/testnet/incentive.go @@ -0,0 +1,5 @@ +package testnet + +const IncentiveParamStr = `{ + "btc_staking_portion": "0.6" +}` diff --git a/app/upgrades/v1/testnet/token_distribution.go b/app/upgrades/v1/testnet/token_distribution.go new file mode 100644 index 000000000..233346914 --- /dev/null +++ b/app/upgrades/v1/testnet/token_distribution.go @@ -0,0 +1,26 @@ +package testnet + +const TokensDistributionStr = `{ + "token_distribution": [ + { + "address_sender": "bbn14d97wthm9fqvvdd96ax8lnfppwknndxztevs7k", + "address_receiver": "bbn13t5cnqj6t0p4xa40cwhmgv4wju0zl6g8slk8rz", + "amount": 100000 + }, + { + "address_sender": "bbn10d07y265gmmuvt4z0w9aw880jnsr700jduz5f2", + "address_receiver": "bbn1yl6hdjhmkf37639730gffanpzndzdpmhep8cg6", + "amount": 1500000 + }, + { + "address_sender": "bbn10d07y265gmmuvt4z0w9aw880jnsr700jduz5f2", + "address_receiver": "bbn1k6u5pge8w6lavtmunp02smehr4qtazkw8clg04", + "amount": 700000 + }, + { + "address_sender": "bbn10d07y265gmmuvt4z0w9aw880jnsr700jduz5f2", + "address_receiver": "bbn1dj2c57fjv6md7pzykh9y6h407ln6xxcw090hre", + "amount": 100000 + } + ] +}` diff --git a/app/upgrades/v1/types.go b/app/upgrades/v1/types.go new file mode 100644 index 000000000..d4a46f783 --- /dev/null +++ b/app/upgrades/v1/types.go @@ -0,0 +1,23 @@ +package v1 + +type UpgradeDataString struct { + BtcStakingParamStr string + FinalityParamStr string + IncentiveParamStr string + CosmWasmParamStr string + NewBtcHeadersStr string + TokensDistributionStr string + AllowedStakingTxHashesStr string +} + +type DataTokenDistribution struct { + TokenDistribution []struct { + AddressSender string `json:"address_sender"` + AddressReceiver string `json:"address_receiver"` + Amount int64 `json:"amount"` + } `json:"token_distribution"` +} + +type AllowedStakingTransactionHashes struct { + TxHashes []string `json:"tx_hashes"` +} diff --git a/app/upgrades/v1/upgrades.go b/app/upgrades/v1/upgrades.go new file mode 100644 index 000000000..69995905a --- /dev/null +++ b/app/upgrades/v1/upgrades.go @@ -0,0 +1,409 @@ +// This code is only for testing purposes. +// DO NOT USE IN PRODUCTION! + +package v1 + +import ( + "bytes" + "context" + "encoding/json" + "errors" + "fmt" + + sdkmath "cosmossdk.io/math" + store "cosmossdk.io/store/types" + upgradetypes "cosmossdk.io/x/upgrade/types" + wasmkeeper "github.com/CosmWasm/wasmd/x/wasm/keeper" + wasmtypes "github.com/CosmWasm/wasmd/x/wasm/types" + "github.com/btcsuite/btcd/chaincfg" + "github.com/btcsuite/btcd/chaincfg/chainhash" + "github.com/cosmos/cosmos-sdk/codec" + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/cosmos-sdk/types/module" + accountkeeper "github.com/cosmos/cosmos-sdk/x/auth/keeper" + bankkeeper "github.com/cosmos/cosmos-sdk/x/bank/keeper" + stakingkeeper "github.com/cosmos/cosmos-sdk/x/staking/keeper" + + "github.com/babylonlabs-io/babylon/app/keepers" + appparams "github.com/babylonlabs-io/babylon/app/params" + "github.com/babylonlabs-io/babylon/app/upgrades" + bbn "github.com/babylonlabs-io/babylon/types" + btclightkeeper "github.com/babylonlabs-io/babylon/x/btclightclient/keeper" + btclighttypes "github.com/babylonlabs-io/babylon/x/btclightclient/types" + btcstkkeeper "github.com/babylonlabs-io/babylon/x/btcstaking/keeper" + btcstktypes "github.com/babylonlabs-io/babylon/x/btcstaking/types" + finalitykeeper "github.com/babylonlabs-io/babylon/x/finality/keeper" + finalitytypes "github.com/babylonlabs-io/babylon/x/finality/types" + incentivekeeper "github.com/babylonlabs-io/babylon/x/incentive/keeper" + incentivetypes "github.com/babylonlabs-io/babylon/x/incentive/types" + mintkeeper "github.com/babylonlabs-io/babylon/x/mint/keeper" + minttypes "github.com/babylonlabs-io/babylon/x/mint/types" +) + +const ( + ZoneConciergeStoreKey = "zoneconcierge" + UpgradeName = "v1" +) + +func CreateUpgrade(upgradeDataStr UpgradeDataString) upgrades.Upgrade { + return upgrades.Upgrade{ + UpgradeName: UpgradeName, + CreateUpgradeHandler: CreateUpgradeHandler(upgradeDataStr), + // Upgrade necessary for deletions of `zoneconcierge` + StoreUpgrades: store.StoreUpgrades{ + Deleted: []string{ZoneConciergeStoreKey}, + }, + } +} + +// CreateUpgradeHandler upgrade handler for launch. +func CreateUpgradeHandler(upgradeDataStr UpgradeDataString) upgrades.UpgradeHandlerCreator { + return func(mm *module.Manager, cfg module.Configurator, keepers *keepers.AppKeepers) upgradetypes.UpgradeHandler { + return func(context context.Context, _plan upgradetypes.Plan, fromVM module.VersionMap) (module.VersionMap, error) { + ctx := sdk.UnwrapSDKContext(context) + + migrations, err := mm.RunMigrations(ctx, cfg, fromVM) + if err != nil { + return nil, fmt.Errorf("failed to run migrations: %w", err) + } + + // Re-initialise the mint module as we have replaced Cosmos SDK's + // mint module with our own one. + err = upgradeMint( + ctx, + keepers.EncCfg.Codec, + &keepers.MintKeeper, + &keepers.AccountKeeper, + keepers.StakingKeeper, + ) + if err != nil { + return nil, fmt.Errorf("failed to upgrade mint module: %w", err) + } + + err = upgradeParameters( + ctx, + keepers.EncCfg.Codec, + &keepers.BTCStakingKeeper, + &keepers.FinalityKeeper, + &keepers.IncentiveKeeper, + &keepers.WasmKeeper, + upgradeDataStr.BtcStakingParamStr, + upgradeDataStr.FinalityParamStr, + upgradeDataStr.IncentiveParamStr, + upgradeDataStr.CosmWasmParamStr, + ) + if err != nil { + return nil, fmt.Errorf("failed to upgrade parameters: %w", err) + } + + err = upgradeLaunch( + ctx, + keepers.EncCfg, + &keepers.BTCLightClientKeeper, + &keepers.BTCStakingKeeper, + keepers.BankKeeper, + upgradeDataStr.NewBtcHeadersStr, + upgradeDataStr.TokensDistributionStr, + upgradeDataStr.AllowedStakingTxHashesStr, + ) + if err != nil { + return nil, fmt.Errorf("failed to upgrade inserting additional data: %w", err) + } + + return migrations, nil + } + } +} + +func upgradeMint( + ctx sdk.Context, + cdc codec.Codec, + k *mintkeeper.Keeper, + ak *accountkeeper.AccountKeeper, + stk *stakingkeeper.Keeper, +) error { + bondedDenom, err := stk.BondDenom(ctx) + if err != nil { + return err + } + k.InitGenesis(ctx, ak, &minttypes.GenesisState{ + BondDenom: bondedDenom, + }) + return nil +} + +func upgradeParameters( + ctx sdk.Context, + cdc codec.Codec, + btcK *btcstkkeeper.Keeper, + finK *finalitykeeper.Keeper, + iK *incentivekeeper.Keeper, + wasmK *wasmkeeper.Keeper, + btcStakingParam, finalityParam, incentiveParam, wasmParam string, +) error { + // Upgrade the staking parameters as first, as other upgrades depend on it. + if err := upgradeBtcStakingParameters(ctx, cdc, btcK, btcStakingParam); err != nil { + return fmt.Errorf("failed to upgrade btc staking parameters: %w", err) + } + if err := upgradeFinalityParameters(ctx, cdc, finK, finalityParam); err != nil { + return fmt.Errorf("failed to upgrade finality parameters: %w", err) + } + if err := upgradeIncentiveParameters(ctx, cdc, iK, incentiveParam); err != nil { + return err + } + + if err := upgradeCosmWasmParameters(ctx, cdc, wasmK, wasmParam); err != nil { + return fmt.Errorf("failed to upgrade cosmwasm parameters: %w", err) + } + + return nil +} + +func upgradeIncentiveParameters( + ctx sdk.Context, + cdc codec.Codec, + k *incentivekeeper.Keeper, + incentiveParam string, +) error { + params, err := LoadIncentiveParamsFromData(cdc, incentiveParam) + if err != nil { + return err + } + + return k.SetParams(ctx, params) +} + +func upgradeCosmWasmParameters( + ctx sdk.Context, + cdc codec.Codec, + k *wasmkeeper.Keeper, + wasmParam string, +) error { + params, err := LoadCosmWasmParamsFromData(cdc, wasmParam) + if err != nil { + return err + } + + return k.SetParams(ctx, params) +} + +func upgradeBtcStakingParameters( + ctx sdk.Context, + cdc codec.Codec, + k *btcstkkeeper.Keeper, + btcStakingParam string, +) error { + params, err := LoadBtcStakingParamsFromData(cdc, btcStakingParam) + if err != nil { + return err + } + + // We are overwriting the params at version 0, as the upgrade is happening from + // TGE chain so there should be only one version of the params + return k.OverwriteParamsAtVersion(ctx, 0, params) +} + +func upgradeFinalityParameters( + ctx sdk.Context, + cdc codec.Codec, + k *finalitykeeper.Keeper, + finalityParam string, +) error { + params, err := LoadFinalityParamsFromData(cdc, finalityParam) + if err != nil { + return err + } + + return k.SetParams(ctx, params) +} + +// upgradeLaunch runs the upgrade: +// - Transfer ubbn funds for token distribution +// - Insert new BTC Headers +func upgradeLaunch( + ctx sdk.Context, + encCfg *appparams.EncodingConfig, + btcLigthK *btclightkeeper.Keeper, + btcK *btcstkkeeper.Keeper, + bankK bankkeeper.SendKeeper, + btcHeaders, tokensDistribution, allowedStakingTxHashes string, +) error { + if err := upgradeTokensDistribution(ctx, bankK, tokensDistribution); err != nil { + return fmt.Errorf("failed to upgrade tokens distribution: %w", err) + } + + if err := upgradeAllowedStakingTransactions(ctx, encCfg.Codec, btcK, allowedStakingTxHashes); err != nil { + return fmt.Errorf("failed to upgrade allowed staking transactions: %w", err) + } + + if err := upgradeBTCHeaders(ctx, encCfg.Codec, btcLigthK, btcHeaders); err != nil { + return fmt.Errorf("failed to upgrade btc headers: %w", err) + } + + return nil +} + +func upgradeTokensDistribution(ctx sdk.Context, bankK bankkeeper.SendKeeper, tokensDistribution string) error { + data, err := LoadTokenDistributionFromData(tokensDistribution) + if err != nil { + return err + } + + for _, td := range data.TokenDistribution { + receiver, err := sdk.AccAddressFromBech32(td.AddressReceiver) + if err != nil { + return err + } + + sender, err := sdk.AccAddressFromBech32(td.AddressSender) + if err != nil { + return err + } + + amount := sdk.NewCoin(appparams.BaseCoinUnit, sdkmath.NewInt(td.Amount)) + if err := bankK.SendCoins(ctx, sender, receiver, sdk.NewCoins(amount)); err != nil { + return err + } + } + + return nil +} + +func upgradeAllowedStakingTransactions(ctx sdk.Context, cdc codec.Codec, btcStakingK *btcstkkeeper.Keeper, allowedStakingTxHashes string) error { + data, err := LoadAllowedStakingTransactionHashesFromData(allowedStakingTxHashes) + if err != nil { + return fmt.Errorf("failed to load allowed staking transaction hashes from string %s: %w", allowedStakingTxHashes, err) + } + + for _, txHash := range data.TxHashes { + hash, err := chainhash.NewHashFromStr(txHash) + if err != nil { + return fmt.Errorf("failed to parse tx hash: %w", err) + } + btcStakingK.IndexAllowedStakingTransaction(ctx, hash) + } + + return nil +} + +func upgradeBTCHeaders(ctx sdk.Context, cdc codec.Codec, btcLigthK *btclightkeeper.Keeper, btcHeaders string) error { + newHeaders, err := LoadBTCHeadersFromData(cdc, btcHeaders) + if err != nil { + return err + } + + return insertBtcHeaders(ctx, btcLigthK, newHeaders) +} + +func LoadBtcStakingParamsFromData(cdc codec.Codec, data string) (btcstktypes.Params, error) { + buff := bytes.NewBufferString(data) + + var params btcstktypes.Params + err := cdc.UnmarshalJSON(buff.Bytes(), ¶ms) + if err != nil { + return btcstktypes.Params{}, err + } + + return params, nil +} + +func LoadFinalityParamsFromData(cdc codec.Codec, data string) (finalitytypes.Params, error) { + buff := bytes.NewBufferString(data) + + var params finalitytypes.Params + err := cdc.UnmarshalJSON(buff.Bytes(), ¶ms) + if err != nil { + return finalitytypes.Params{}, err + } + + return params, nil +} + +func LoadIncentiveParamsFromData(cdc codec.Codec, data string) (incentivetypes.Params, error) { + buff := bytes.NewBufferString(data) + + var params incentivetypes.Params + err := cdc.UnmarshalJSON(buff.Bytes(), ¶ms) + if err != nil { + return incentivetypes.Params{}, err + } + + return params, nil +} + +func LoadCosmWasmParamsFromData(cdc codec.Codec, data string) (wasmtypes.Params, error) { + buff := bytes.NewBufferString(data) + + var params wasmtypes.Params + err := cdc.UnmarshalJSON(buff.Bytes(), ¶ms) + if err != nil { + return wasmtypes.Params{}, err + } + + return params, nil +} + +// LoadBTCHeadersFromData returns the BTC headers load from the json string with the headers inside of it. +func LoadBTCHeadersFromData(cdc codec.Codec, data string) ([]*btclighttypes.BTCHeaderInfo, error) { + buff := bytes.NewBufferString(data) + + var gs btclighttypes.GenesisState + err := cdc.UnmarshalJSON(buff.Bytes(), &gs) + if err != nil { + return nil, err + } + + return gs.BtcHeaders, nil +} + +// LoadTokenDistributionFromData returns the tokens to be distributed from the json string. +func LoadTokenDistributionFromData(data string) (DataTokenDistribution, error) { + buff := bytes.NewBufferString(data) + + var d DataTokenDistribution + err := json.Unmarshal(buff.Bytes(), &d) + if err != nil { + return d, err + } + + return d, nil +} + +func LoadAllowedStakingTransactionHashesFromData(data string) (*AllowedStakingTransactionHashes, error) { + buff := bytes.NewBufferString(data) + + var d AllowedStakingTransactionHashes + err := json.Unmarshal(buff.Bytes(), &d) + if err != nil { + return nil, err + } + + return &d, nil +} + +func insertBtcHeaders( + ctx sdk.Context, + k *btclightkeeper.Keeper, + btcHeaders []*btclighttypes.BTCHeaderInfo, +) error { + if len(btcHeaders) == 0 { + return errors.New("no headers to insert") + } + + headersBytes := make([]bbn.BTCHeaderBytes, len(btcHeaders)) + for i, btcHeader := range btcHeaders { + h := btcHeader + headersBytes[i] = *h.Header + } + + if err := k.InsertHeaders(ctx, headersBytes); err != nil { + return err + } + + allBlocks := k.GetMainChainFromWithLimit(ctx, 0, 1) + isRetarget := btclighttypes.IsRetargetBlock(allBlocks[0], &chaincfg.SigNetParams) + if !isRetarget { + return fmt.Errorf("first header be a difficulty adjustment block") + } + return nil +} diff --git a/app/upgrades/v1/upgrades_test.go b/app/upgrades/v1/upgrades_test.go new file mode 100644 index 000000000..3960ebc5d --- /dev/null +++ b/app/upgrades/v1/upgrades_test.go @@ -0,0 +1,321 @@ +package v1_test + +import ( + _ "embed" + "fmt" + "testing" + "time" + + "cosmossdk.io/core/appmodule" + "cosmossdk.io/core/header" + errorsmod "cosmossdk.io/errors" + sdkmath "cosmossdk.io/math" + "cosmossdk.io/x/upgrade" + upgradetypes "cosmossdk.io/x/upgrade/types" + wasmkeeper "github.com/CosmWasm/wasmd/x/wasm/keeper" + wasmtypes "github.com/CosmWasm/wasmd/x/wasm/types" + wasmvm "github.com/CosmWasm/wasmvm/v2" + wasmvmtypes "github.com/CosmWasm/wasmvm/v2/types" + appparams "github.com/babylonlabs-io/babylon/app/params" + "github.com/babylonlabs-io/babylon/app/upgrades" + "github.com/babylonlabs-io/babylon/test/e2e/util" + "github.com/babylonlabs-io/babylon/testutil/datagen" + minttypes "github.com/babylonlabs-io/babylon/x/mint/types" + "github.com/btcsuite/btcd/chaincfg/chainhash" + tmproto "github.com/cometbft/cometbft/proto/tendermint/types" + sdk "github.com/cosmos/cosmos-sdk/types" + sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" + authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" + govtypes "github.com/cosmos/cosmos-sdk/x/gov/types" + "github.com/stretchr/testify/suite" + + "github.com/babylonlabs-io/babylon/app" + v1 "github.com/babylonlabs-io/babylon/app/upgrades/v1" + mainnetdata "github.com/babylonlabs-io/babylon/app/upgrades/v1/mainnet" + testnetdata "github.com/babylonlabs-io/babylon/app/upgrades/v1/testnet" + "github.com/babylonlabs-io/babylon/x/btclightclient" + btclighttypes "github.com/babylonlabs-io/babylon/x/btclightclient/types" +) + +const ( + DummyUpgradeHeight = 5 +) + +var ( + //go:embed testdata/reflect_1_5.wasm + wasmContract []byte + + UpgradeV1DataTestnet = v1.UpgradeDataString{ + BtcStakingParamStr: testnetdata.BtcStakingParamStr, + FinalityParamStr: testnetdata.FinalityParamStr, + IncentiveParamStr: testnetdata.IncentiveParamStr, + CosmWasmParamStr: testnetdata.CosmWasmParamStr, + NewBtcHeadersStr: testnetdata.NewBtcHeadersStr, + TokensDistributionStr: testnetdata.TokensDistributionStr, + AllowedStakingTxHashesStr: testnetdata.AllowedStakingTxHashesStr, + } + UpgradeV1DataMainnet = v1.UpgradeDataString{ + BtcStakingParamStr: mainnetdata.BtcStakingParamStr, + FinalityParamStr: mainnetdata.FinalityParamStr, + IncentiveParamStr: mainnetdata.IncentiveParamStr, + CosmWasmParamStr: mainnetdata.CosmWasmParamStr, + NewBtcHeadersStr: mainnetdata.NewBtcHeadersStr, + TokensDistributionStr: mainnetdata.TokensDistributionStr, + AllowedStakingTxHashesStr: mainnetdata.AllowedStakingTxHashesStr, + } + UpgradeV1Data = []v1.UpgradeDataString{UpgradeV1DataTestnet, UpgradeV1DataMainnet} +) + +type UpgradeTestSuite struct { + suite.Suite + + ctx sdk.Context + app *app.BabylonApp + preModule appmodule.HasPreBlocker + + upgradeDataStr v1.UpgradeDataString + // BTC Header checker + btcHeadersLenPreUpgrade int + // TokenDistribution checker + balanceDiffByAddr map[string]int64 + balancesBeforeUpgrade map[string]sdk.Coin +} + +func TestKeeperTestSuite(t *testing.T) { + suite.Run(t, new(UpgradeTestSuite)) +} + +func (s *UpgradeTestSuite) TestUpgrade() { + stakingWasmChecksum, err := wasmvm.CreateChecksum(wasmContract) + s.NoError(err) + + testCases := []struct { + msg string + upgradeDataStr v1.UpgradeDataString + preUpgrade func() + upgrade func() + postUpgrade func() + }{ + { + "Test launch software upgrade v1 mainnet", + UpgradeV1DataMainnet, + s.PreUpgrade, + s.Upgrade, + func() { + s.PostUpgrade() + + randAddr := datagen.GenRandomAddress().String() + // checks that not everybody can instantiate a contract + wasmMsgServer := wasmkeeper.NewMsgServerImpl(&s.app.WasmKeeper) + resp, err := wasmMsgServer.StoreCode(s.ctx, &wasmtypes.MsgStoreCode{ + Sender: randAddr, + WASMByteCode: wasmContract, + }) + s.Nil(resp) + s.EqualError(err, errorsmod.Wrap(sdkerrors.ErrUnauthorized, "can not create code").Error()) + + // onlu gov account can store new contracts + respFromGov, err := wasmMsgServer.StoreCode(s.ctx, &wasmtypes.MsgStoreCode{ + Sender: authtypes.NewModuleAddress(govtypes.ModuleName).String(), + WASMByteCode: wasmContract, + }) + s.NoError(err) + s.EqualValues(respFromGov.CodeID, 1) + s.Equal(stakingWasmChecksum[:], wasmvmtypes.Checksum(respFromGov.Checksum)) + + // anyone can instantiate if it was stored already + respInst, err := wasmMsgServer.InstantiateContract(s.ctx, &wasmtypes.MsgInstantiateContract{ + Sender: randAddr, + CodeID: respFromGov.CodeID, + Label: "xxxx", + Msg: []byte(`{}`), + Funds: sdk.Coins{}, + }) + s.NoError(err) + s.NotNil(respInst.Address) + }, + }, + { + "Test launch software upgrade v1 testnet", + UpgradeV1DataTestnet, + s.PreUpgrade, + s.Upgrade, + func() { + s.PostUpgrade() + + // checks that anyone can instantiate a contract + wasmMsgServer := wasmkeeper.NewMsgServerImpl(&s.app.WasmKeeper) + resp, err := wasmMsgServer.StoreCode(s.ctx, &wasmtypes.MsgStoreCode{ + Sender: datagen.GenRandomAddress().String(), + WASMByteCode: wasmContract, + }) + s.NoError(err) + s.EqualValues(resp.CodeID, 1) + s.Equal(stakingWasmChecksum[:], wasmvmtypes.Checksum(resp.Checksum)) + }, + }, + } + + for _, tc := range testCases { + s.Run(fmt.Sprintf("Case %s", tc.msg), func() { + s.SetupTest(tc.upgradeDataStr) // reset + + tc.preUpgrade() + tc.upgrade() + tc.postUpgrade() + }) + } +} + +func (s *UpgradeTestSuite) SetupTest(upgradeDataStr v1.UpgradeDataString) { + s.upgradeDataStr = upgradeDataStr + + // add the upgrade plan + app.Upgrades = []upgrades.Upgrade{v1.CreateUpgrade(upgradeDataStr)} + + // set up app + s.app = app.Setup(s.T(), false) + s.ctx = s.app.BaseApp.NewContextLegacy(false, tmproto.Header{Height: 1, ChainID: "babylon-1", Time: time.Now().UTC()}) + s.preModule = upgrade.NewAppModule(s.app.UpgradeKeeper, s.app.AccountKeeper.AddressCodec()) + + btcHeaderGenesis, err := app.SignetBtcHeaderGenesis(s.app.EncodingConfig().Codec) + s.NoError(err) + + k := s.app.BTCLightClientKeeper + btclightclient.InitGenesis(s.ctx, s.app.BTCLightClientKeeper, btclighttypes.GenesisState{ + Params: k.GetParams(s.ctx), + BtcHeaders: []*btclighttypes.BTCHeaderInfo{btcHeaderGenesis}, + }) + + tokenDistData, err := v1.LoadTokenDistributionFromData(upgradeDataStr.TokensDistributionStr) + s.NoError(err) + + s.balancesBeforeUpgrade = make(map[string]sdk.Coin) + s.balanceDiffByAddr = make(map[string]int64) + for _, td := range tokenDistData.TokenDistribution { + s.balanceDiffByAddr[td.AddressSender] -= td.Amount + s.balanceDiffByAddr[td.AddressReceiver] += td.Amount + } +} + +func (s *UpgradeTestSuite) PreUpgrade() { + allBtcHeaders := s.app.BTCLightClientKeeper.GetMainChainFrom(s.ctx, 0) + s.btcHeadersLenPreUpgrade = len(allBtcHeaders) + + // Before upgrade, the params should be different + bsParamsFromUpgrade, err := v1.LoadBtcStakingParamsFromData(s.app.AppCodec(), s.upgradeDataStr.BtcStakingParamStr) + s.NoError(err) + bsModuleParams := s.app.BTCStakingKeeper.GetParams(s.ctx) + s.NotEqualValues(bsModuleParams, bsParamsFromUpgrade) + fParamsFromUpgrade, err := v1.LoadFinalityParamsFromData(s.app.AppCodec(), s.upgradeDataStr.FinalityParamStr) + s.NoError(err) + fModuleParams := s.app.FinalityKeeper.GetParams(s.ctx) + s.NotEqualValues(fModuleParams, fParamsFromUpgrade) + + for addr, amountDiff := range s.balanceDiffByAddr { + sdkAddr := sdk.MustAccAddressFromBech32(addr) + + if amountDiff < 0 { + // if the amount is lower than zero, it means the addr is going to spend tokens and + // could be that the addr does not have enough funds. + // For test completeness, mint the coins that the acc is going to spend. + coinsToMint := sdk.NewCoins(sdk.NewCoin(appparams.DefaultBondDenom, sdkmath.NewInt(util.Abs(amountDiff)))) + err = s.app.BankKeeper.MintCoins(s.ctx, minttypes.ModuleName, coinsToMint) + s.NoError(err) + + err = s.app.BankKeeper.SendCoinsFromModuleToAccount(s.ctx, minttypes.ModuleName, sdkAddr, coinsToMint) + s.NoError(err) + } + + // update the balances before upgrade only after mint check is done + s.balancesBeforeUpgrade[addr] = s.app.BankKeeper.GetBalance(s.ctx, sdkAddr, appparams.DefaultBondDenom) + } +} + +func (s *UpgradeTestSuite) Upgrade() { + // inject upgrade plan + s.ctx = s.ctx.WithBlockHeight(DummyUpgradeHeight - 1) + plan := upgradetypes.Plan{Name: v1.UpgradeName, Height: DummyUpgradeHeight} + err := s.app.UpgradeKeeper.ScheduleUpgrade(s.ctx, plan) + s.NoError(err) + + // ensure upgrade plan exists + actualPlan, err := s.app.UpgradeKeeper.GetUpgradePlan(s.ctx) + s.NoError(err) + s.Equal(plan, actualPlan) + + // execute upgrade + s.ctx = s.ctx.WithHeaderInfo(header.Info{Height: DummyUpgradeHeight, Time: s.ctx.BlockTime().Add(time.Second)}).WithBlockHeight(DummyUpgradeHeight) + s.NotPanics(func() { + _, err := s.preModule.PreBlock(s.ctx) + s.NoError(err) + }) +} + +func (s *UpgradeTestSuite) PostUpgrade() { + // ensure the btc headers were added + allBtcHeaders := s.app.BTCLightClientKeeper.GetMainChainFrom(s.ctx, 0) + + btcHeadersInserted, err := v1.LoadBTCHeadersFromData(s.app.AppCodec(), s.upgradeDataStr.NewBtcHeadersStr) + s.NoError(err) + lenHeadersInserted := len(btcHeadersInserted) + + newHeadersLen := len(allBtcHeaders) + s.Equal(newHeadersLen, s.btcHeadersLenPreUpgrade+lenHeadersInserted) + + // ensure the incentive params were set as expected + incentiveParamsFromUpgrade, err := v1.LoadIncentiveParamsFromData(s.app.AppCodec(), s.upgradeDataStr.IncentiveParamStr) + s.NoError(err) + incentiveParams := s.app.IncentiveKeeper.GetParams(s.ctx) + s.EqualValues(incentiveParamsFromUpgrade, incentiveParams) + + // ensure the headers were inserted as expected + for i, btcHeaderInserted := range btcHeadersInserted { + btcHeaderInState := allBtcHeaders[s.btcHeadersLenPreUpgrade+i] + + s.EqualValues(btcHeaderInserted.Header.MarshalHex(), btcHeaderInState.Header.MarshalHex()) + } + + // After upgrade, the params should be the same + bsParamsFromUpgrade, err := v1.LoadBtcStakingParamsFromData(s.app.AppCodec(), s.upgradeDataStr.BtcStakingParamStr) + s.NoError(err) + bsModuleParams := s.app.BTCStakingKeeper.GetParams(s.ctx) + s.EqualValues(bsModuleParams, bsParamsFromUpgrade) + fParamsFromUpgrade, err := v1.LoadFinalityParamsFromData(s.app.AppCodec(), s.upgradeDataStr.FinalityParamStr) + s.NoError(err) + fModuleParams := s.app.FinalityKeeper.GetParams(s.ctx) + s.EqualValues(fModuleParams, fParamsFromUpgrade) + + // verifies that all the modified balances match as expected after the upgrade + for addr, diff := range s.balanceDiffByAddr { + coinDiff := sdk.NewCoin(appparams.DefaultBondDenom, sdkmath.NewInt(util.Abs(diff))) + expectedBalance := s.balancesBeforeUpgrade[addr].Add(coinDiff) + if diff < 0 { + expectedBalance = s.balancesBeforeUpgrade[addr].Sub(coinDiff) + } + + sdkAddr := sdk.MustAccAddressFromBech32(addr) + balanceAfterUpgrade := s.app.BankKeeper.GetBalance(s.ctx, sdkAddr, appparams.DefaultBondDenom) + s.Equal(expectedBalance.String(), balanceAfterUpgrade.String()) + } + + chainWasmParams := s.app.WasmKeeper.GetParams(s.ctx) + upgradeWasmParams, err := v1.LoadCosmWasmParamsFromData(s.app.AppCodec(), s.upgradeDataStr.CosmWasmParamStr) + s.NoError(err) + s.EqualValues(chainWasmParams, upgradeWasmParams) + + allowedStakingTxHashes, err := v1.LoadAllowedStakingTransactionHashesFromData(s.upgradeDataStr.AllowedStakingTxHashesStr) + s.NoError(err) + s.NotNil(allowedStakingTxHashes) + s.Greater(len(allowedStakingTxHashes.TxHashes), 0) + + for _, txHash := range allowedStakingTxHashes.TxHashes { + hash, err := chainhash.NewHashFromStr(txHash) + s.NoError(err) + + s.True(s.app.BTCStakingKeeper.IsStakingTransactionAllowed(s.ctx, hash)) + } + + nonExistentTxHash := chainhash.Hash{} + s.False(s.app.BTCStakingKeeper.IsStakingTransactionAllowed(s.ctx, &nonExistentTxHash)) +} diff --git a/btcstaking/identifiable_staking.go b/btcstaking/identifiable_staking.go index d75288dd5..6b0c158c3 100644 --- a/btcstaking/identifiable_staking.go +++ b/btcstaking/identifiable_staking.go @@ -16,9 +16,9 @@ import ( ) const ( - // length of tag prefix indentifying staking transactions + // TagLen length of tag prefix identifying staking transactions TagLen = 4 - // 4 bytes tag + 1 byte version + 32 bytes staker public key + 32 bytes finality provider public key + 2 bytes staking time + // V0OpReturnDataSize 4 bytes tag + 1 byte version + 32 bytes staker public key + 32 bytes finality provider public key + 2 bytes staking time V0OpReturnDataSize = 71 v0OpReturnCreationErrMsg = "cannot create V0 op_return data" @@ -362,7 +362,7 @@ func ParseV0StakingTx( return nil, fmt.Errorf("no covenant keys specified") } - if covenantQuorum > uint32(len(covenantKeys)) { + if int(covenantQuorum) > len(covenantKeys) { return nil, fmt.Errorf("covenant quorum is greater than the number of covenant keys") } @@ -391,7 +391,7 @@ func ParseV0StakingTx( } if opReturnData.Version != 0 { - return nil, fmt.Errorf("unexpcted version: %d, expected: %d", opReturnData.Version, 0) + return nil, fmt.Errorf("unexpected version: %d, expected: %d", opReturnData.Version, 0) } // 3. Op return seems to be valid V0 op return output. Now, we need to check whether diff --git a/btcstaking/identifiable_staking_test.go b/btcstaking/identifiable_staking_test.go index 96692735b..c342e1b14 100644 --- a/btcstaking/identifiable_staking_test.go +++ b/btcstaking/identifiable_staking_test.go @@ -45,20 +45,20 @@ func FuzzGenerateAndParseValidV0StakingTransaction(f *testing.F) { r := rand.New(rand.NewSource(seed)) // 3 - 10 covenants numCovenantKeys := uint32(r.Int31n(7) + 3) - quroum := uint32(r.Intn(int(numCovenantKeys)) + 1) + quorum := uint32(r.Intn(int(numCovenantKeys)) + 1) stakingAmount := btcutil.Amount(r.Int63n(1000000000) + 10000) stakingTime := uint16(r.Int31n(math.MaxUint16-1) + 1) tag := datagen.GenRandomByteArray(r, btcstaking.TagLen) net := &chaincfg.MainNetParams - sc := GenerateTestScenario(r, t, 1, numCovenantKeys, quroum, stakingAmount, stakingTime) + sc := GenerateTestScenario(r, t, 1, numCovenantKeys, quorum, stakingAmount, stakingTime) outputs, err := btcstaking.BuildV0IdentifiableStakingOutputs( tag, sc.StakerKey.PubKey(), sc.FinalityProviderKeys[0].PubKey(), sc.CovenantPublicKeys(), - quroum, + quorum, stakingTime, stakingAmount, net, @@ -77,7 +77,7 @@ func FuzzGenerateAndParseValidV0StakingTransaction(f *testing.F) { tx, tag, sc.CovenantPublicKeys(), - quroum, + quorum, net, ) require.NoError(t, err) diff --git a/btcstaking/scripts_utils.go b/btcstaking/scripts_utils.go index 1c815c1d2..ad2c85937 100644 --- a/btcstaking/scripts_utils.go +++ b/btcstaking/scripts_utils.go @@ -11,7 +11,7 @@ import ( ) // private helper to assemble multisig script -// if `withVerify` is ture script will end with OP_NUMEQUALVERIFY otherwise with OP_NUMEQUAL +// if `withVerify` is true script will end with OP_NUMEQUALVERIFY otherwise with OP_NUMEQUAL // SCRIPT: OP_CHEKCSIG OP_CHECKSIGADD OP_CHECKSIGADD ... OP_CHECKSIGADD OP_NUMEQUALVERIFY (or OP_NUMEQUAL) func assembleMultiSigScript( pubkeys []*btcec.PublicKey, @@ -82,7 +82,7 @@ func buildMultiSigScript( return nil, fmt.Errorf("no keys provided") } - if threshold > uint32(len(keys)) { + if int(threshold) > len(keys) { return nil, fmt.Errorf("required number of valid signers is greater than number of provided keys") } diff --git a/btcstaking/staking.go b/btcstaking/staking.go index d872a4580..8a04f7342 100644 --- a/btcstaking/staking.go +++ b/btcstaking/staking.go @@ -6,6 +6,7 @@ import ( "fmt" sdkmath "cosmossdk.io/math" + asig "github.com/babylonlabs-io/babylon/crypto/schnorr-adaptor-signature" "github.com/btcsuite/btcd/blockchain" "github.com/btcsuite/btcd/btcec/v2" "github.com/btcsuite/btcd/btcec/v2/schnorr" @@ -14,8 +15,15 @@ import ( "github.com/btcsuite/btcd/mempool" "github.com/btcsuite/btcd/txscript" "github.com/btcsuite/btcd/wire" +) - asig "github.com/babylonlabs-io/babylon/crypto/schnorr-adaptor-signature" +const ( + // MaxTxVersion is the maximum transaction version allowed in Babylon system. + // Changing that constant will require upgrade in the future, if we ever need + // to support v3 transactions. + MaxTxVersion = 2 + + MaxStandardTxWeight = 400000 ) // buildSlashingTxFromOutpoint builds a valid slashing transaction by creating a new Bitcoin transaction that slashes a portion @@ -78,7 +86,7 @@ func buildSlashingTxFromOutpoint( // Create a new btc transaction tx := wire.NewMsgTx(wire.TxVersion) // TODO: this builds input with sequence number equal to MaxTxInSequenceNum, which - // means this tx is not replacable. + // means this tx is not replaceable. input := wire.NewTxIn(&stakingOutput, nil, nil) tx.AddTxIn(input) tx.AddTxOut(wire.NewTxOut(int64(slashingAmount), slashingPkScript)) @@ -102,7 +110,7 @@ func getPossibleStakingOutput( return nil, fmt.Errorf("provided staking transaction must not be nil") } - if stakingOutputIdx >= uint32(len(stakingTx.TxOut)) { + if int(stakingOutputIdx) >= len(stakingTx.TxOut) { return nil, fmt.Errorf("invalid staking output index %d, tx has %d outputs", stakingOutputIdx, len(stakingTx.TxOut)) } @@ -157,7 +165,7 @@ func BuildSlashingTxFromStakingTxStrict( stakingTxHash := stakingTx.TxHash() stakingOutpoint := wire.NewOutPoint(&stakingTxHash, stakingOutputIdx) - // Create taproot address commiting to timelock script + // Create taproot address committing to timelock script si, err := BuildRelativeTimelockTaprootScript( stakerPk, slashChangeLockTime, @@ -198,15 +206,15 @@ func IsTransferTx(tx *wire.MsgTx) error { // IsSimpleTransfer Simple transfer transaction is a transaction which: // - has exactly one input // - has exactly one output -// - is not replacable +// - is not replaceable // - does not have any locktime func IsSimpleTransfer(tx *wire.MsgTx) error { if err := IsTransferTx(tx); err != nil { - return fmt.Errorf("invalid simple tansfer tx: %w", err) + return fmt.Errorf("invalid simple transfer tx: %w", err) } if tx.TxIn[0].Sequence != wire.MaxTxInSequenceNum { - return fmt.Errorf("simple transfer tx must not be replacable") + return fmt.Errorf("simple transfer tx must not be replaceable") } if tx.LockTime != 0 { @@ -215,6 +223,89 @@ func IsSimpleTransfer(tx *wire.MsgTx) error { return nil } +// CheckPreSignedTxSanity performs basic checks on a pre-signed transaction: +// - the transaction is not nil. +// - the transaction obeys basic BTC rules. +// - the transaction has exactly numInputs inputs. +// - the transaction has exactly numOutputs outputs. +// - the transaction lock time is 0. +// - the transaction version is between 1 and maxTxVersion. +// - each input has a sequence number equal to MaxTxInSequenceNum. +// - each input has an empty signature script. +// - each input has an empty witness. +func CheckPreSignedTxSanity( + tx *wire.MsgTx, + numInputs, numOutputs uint32, + maxTxVersion int32, +) error { + if tx == nil { + return fmt.Errorf("tx must not be nil") + } + + transaction := btcutil.NewTx(tx) + + if err := blockchain.CheckTransactionSanity(transaction); err != nil { + return fmt.Errorf("btc transaction do not obey BTC rules: %w", err) + } + + if len(tx.TxIn) != int(numInputs) { + return fmt.Errorf("tx must have exactly %d inputs", numInputs) + } + + if len(tx.TxOut) != int(numOutputs) { + return fmt.Errorf("tx must have exactly %d outputs", numOutputs) + } + + // this requirement makes every pre-signed tx final + if tx.LockTime != 0 { + return fmt.Errorf("pre-signed tx must not have locktime") + } + + if tx.Version > maxTxVersion || tx.Version < 1 { + return fmt.Errorf("tx version must be between 1 and %d", maxTxVersion) + } + + txWeight := blockchain.GetTransactionWeight(transaction) + + // Check that the transaction weight does not exceed the maximum standard tx weight + // alternative would be to require len(in.Witness) == 0 for all inptus. + if txWeight > MaxStandardTxWeight { + return fmt.Errorf("tx weight must not exceed %d", MaxStandardTxWeight) + } + + for _, in := range tx.TxIn { + if in.Sequence != wire.MaxTxInSequenceNum { + return fmt.Errorf("pre-signed tx must not be replaceable") + } + + // We require this to be 0, as all babylon pre-signed transactions use + // witness + if len(in.SignatureScript) != 0 { + return fmt.Errorf("pre-signed tx must not have signature script") + } + } + + return nil +} + +func CheckPreSignedUnbondingTxSanity(tx *wire.MsgTx) error { + return CheckPreSignedTxSanity( + tx, + 1, + 1, + MaxTxVersion, + ) +} + +func CheckPreSignedSlashingTxSanity(tx *wire.MsgTx) error { + return CheckPreSignedTxSanity( + tx, + 1, + 2, + MaxTxVersion, + ) +} + // validateSlashingTx performs basic checks on a slashing transaction: // - the slashing transaction is not nil. // - the slashing transaction has exactly one input. @@ -235,29 +326,9 @@ func validateSlashingTx( slashingChangeLockTime uint16, net *chaincfg.Params, ) error { - // Verify that the slashing transaction is not nil. - if slashingTx == nil { - return fmt.Errorf("slashing transaction must not be nil") - } - // Verify that the slashing transaction has exactly one input. - if len(slashingTx.TxIn) != 1 { - return fmt.Errorf("slashing transaction must have exactly one input") - } - - // Verify that the slashing transaction is non-replaceable. - if slashingTx.TxIn[0].Sequence != wire.MaxTxInSequenceNum { - return fmt.Errorf("slashing transaction must not be replaceable") - } - - // Verify that lock time of the slashing transaction is 0. - if slashingTx.LockTime != 0 { - return fmt.Errorf("slashing tx must not have locktime") - } - - // Verify that the slashing transaction has exactly two outputs. - if len(slashingTx.TxOut) != 2 { - return fmt.Errorf("slashing transaction must have exactly 2 outputs") + if err := CheckPreSignedSlashingTxSanity(slashingTx); err != nil { + return fmt.Errorf("invalid slashing tx: %w", err) } // Verify that at least staking output value * slashing rate is slashed. @@ -324,13 +395,13 @@ func validateSlashingTx( return nil } -// CheckTransactions validates all relevant data of slashing and funding transaction. +// CheckSlashingTxMatchFundingTx validates all relevant data of slashing and funding transaction. // - both transactions are valid from pov of BTC rules // - funding transaction has output committing to the provided script // - slashing transaction is valid // - slashing transaction input hash is pointing to funding transaction hash -// - slashing transaction input index is pointing to funding transaction output commiting to the script -func CheckTransactions( +// - slashing transaction input index is pointing to funding transaction output committing to the script +func CheckSlashingTxMatchFundingTx( slashingTx *wire.MsgTx, fundingTransaction *wire.MsgTx, fundingOutputIdx uint32, @@ -345,10 +416,6 @@ func CheckTransactions( return fmt.Errorf("slashing and funding transactions must not be nil") } - if err := blockchain.CheckTransactionSanity(btcutil.NewTx(slashingTx)); err != nil { - return fmt.Errorf("slashing transaction does not obey BTC rules: %w", err) - } - if err := blockchain.CheckTransactionSanity(btcutil.NewTx(fundingTransaction)); err != nil { return fmt.Errorf("funding transaction does not obey BTC rules: %w", err) } @@ -363,7 +430,7 @@ func CheckTransactions( return ErrInvalidSlashingRate } - if fundingOutputIdx >= uint32(len(fundingTransaction.TxOut)) { + if int(fundingOutputIdx) >= len(fundingTransaction.TxOut) { return fmt.Errorf("invalid funding output index %d, tx has %d outputs", fundingOutputIdx, len(fundingTransaction.TxOut)) } @@ -552,7 +619,7 @@ func checkTxBeforeSigning(txToSign *wire.MsgTx, fundingTx *wire.MsgTx, fundingOu return fmt.Errorf("tx to sign must have exactly one input") } - if fundingOutputIdx >= uint32(len(fundingTx.TxOut)) { + if int(fundingOutputIdx) >= len(fundingTx.TxOut) { return fmt.Errorf("invalid funding output index %d, tx has %d outputs", fundingOutputIdx, len(fundingTx.TxOut)) } diff --git a/btcstaking/staking_test.go b/btcstaking/staking_test.go index f1a180038..b91265847 100644 --- a/btcstaking/staking_test.go +++ b/btcstaking/staking_test.go @@ -193,7 +193,7 @@ func testSlashingTx( require.ErrorIs(t, err, btcstaking.ErrDustOutputFound) } else { require.NoError(t, err) - err = btcstaking.CheckTransactions( + err = btcstaking.CheckSlashingTxMatchFundingTx( slashingTx, stakingTx, uint32(stakingOutputIdx), @@ -303,7 +303,7 @@ func TestSlashingTxWithOverflowMustNotAccepted(t *testing.T) { slashingTx.TxOut[0].Value = math.MaxInt64 / 8 slashingTx.TxOut[1].Value = math.MaxInt64 / 8 - err = btcstaking.CheckTransactions( + err = btcstaking.CheckSlashingTxMatchFundingTx( slashingTx, stakingTx, uint32(0), @@ -315,7 +315,7 @@ func TestSlashingTxWithOverflowMustNotAccepted(t *testing.T) { &chaincfg.MainNetParams, ) require.Error(t, err) - require.EqualError(t, err, "slashing transaction does not obey BTC rules: transaction output value is higher than max allowed value: 1152921504606846975 > 2.1e+15 ") + require.EqualError(t, err, "invalid slashing tx: btc transaction do not obey BTC rules: transaction output value is higher than max allowed value: 1152921504606846975 > 2.1e+15 ") } func TestNotAllowStakerKeyToBeFinalityProviderKey(t *testing.T) { @@ -413,3 +413,151 @@ func TestNotAllowFinalityProviderKeysAsCovenantKeys(t *testing.T) { require.Error(t, err) require.True(t, errors.Is(err, btcstaking.ErrDuplicatedKeyInScript)) } + +func TestCheckPreSignedTxSanity(t *testing.T) { + t.Parallel() + tests := []struct { + name string + genTx func() *wire.MsgTx + numInputs uint32 + numOutputs uint32 + maxTxVersion int32 + wantErr bool + expectedErrMsg string + }{ + { + name: "valid tx", + genTx: func() *wire.MsgTx { + tx := wire.NewMsgTx(2) + tx.AddTxIn(wire.NewTxIn(wire.NewOutPoint(&chainhash.Hash{}, 0), nil, nil)) + tx.AddTxOut(wire.NewTxOut(1000, nil)) + return tx + }, + numInputs: 1, + numOutputs: 1, + maxTxVersion: 2, + wantErr: false, + }, + { + name: "non standard version tx", + genTx: func() *wire.MsgTx { + tx := wire.NewMsgTx(0) + tx.AddTxIn(wire.NewTxIn(wire.NewOutPoint(&chainhash.Hash{}, 0), nil, nil)) + tx.AddTxOut(wire.NewTxOut(1000, nil)) + return tx + }, + numInputs: 1, + numOutputs: 1, + maxTxVersion: 2, + wantErr: true, + expectedErrMsg: "tx version must be between 1 and 2", + }, + { + name: "transaction with locktime", + genTx: func() *wire.MsgTx { + tx := wire.NewMsgTx(2) + tx.AddTxIn(wire.NewTxIn(wire.NewOutPoint(&chainhash.Hash{}, 0), nil, nil)) + tx.AddTxOut(wire.NewTxOut(1000, nil)) + tx.LockTime = 1 + return tx + }, + numInputs: 1, + numOutputs: 1, + maxTxVersion: 2, + wantErr: true, + expectedErrMsg: "pre-signed tx must not have locktime", + }, + { + name: "transaction with sig script", + genTx: func() *wire.MsgTx { + tx := wire.NewMsgTx(2) + tx.AddTxIn(wire.NewTxIn(wire.NewOutPoint(&chainhash.Hash{}, 0), nil, nil)) + tx.AddTxOut(wire.NewTxOut(1000, nil)) + tx.TxIn[0].SignatureScript = []byte{0x01, 0x02, 0x03} + return tx + }, + numInputs: 1, + numOutputs: 1, + maxTxVersion: 2, + wantErr: true, + expectedErrMsg: "pre-signed tx must not have signature script", + }, + { + name: "transaction with invalid amount of inputs", + genTx: func() *wire.MsgTx { + tx := wire.NewMsgTx(2) + tx.AddTxIn(wire.NewTxIn(wire.NewOutPoint(&chainhash.Hash{}, 0), nil, nil)) + tx.AddTxIn(wire.NewTxIn(wire.NewOutPoint(&chainhash.Hash{}, 1), nil, nil)) + tx.AddTxOut(wire.NewTxOut(1000, nil)) + return tx + }, + numInputs: 1, + numOutputs: 1, + maxTxVersion: 2, + wantErr: true, + expectedErrMsg: "tx must have exactly 1 inputs", + }, + { + name: "transaction with invalid amount of outputs", + genTx: func() *wire.MsgTx { + tx := wire.NewMsgTx(2) + tx.AddTxIn(wire.NewTxIn(wire.NewOutPoint(&chainhash.Hash{}, 0), nil, nil)) + tx.AddTxOut(wire.NewTxOut(1000, nil)) + tx.AddTxOut(wire.NewTxOut(1000, nil)) + return tx + }, + numInputs: 1, + numOutputs: 1, + maxTxVersion: 2, + wantErr: true, + expectedErrMsg: "tx must have exactly 1 outputs", + }, + { + name: "replacable transaction", + genTx: func() *wire.MsgTx { + tx := wire.NewMsgTx(2) + tx.AddTxIn(wire.NewTxIn(wire.NewOutPoint(&chainhash.Hash{}, 0), nil, nil)) + tx.AddTxOut(wire.NewTxOut(1000, nil)) + tx.TxIn[0].Sequence = wire.MaxTxInSequenceNum - 1 + return tx + }, + numInputs: 1, + numOutputs: 1, + maxTxVersion: 2, + wantErr: true, + expectedErrMsg: "pre-signed tx must not be replaceable", + }, + { + name: "transaction with too big witness", + genTx: func() *wire.MsgTx { + tx := wire.NewMsgTx(2) + tx.AddTxIn(wire.NewTxIn(wire.NewOutPoint(&chainhash.Hash{}, 0), nil, nil)) + tx.AddTxOut(wire.NewTxOut(1000, nil)) + witness := [20000000]byte{} + tx.TxIn[0].Witness = [][]byte{witness[:]} + return tx + }, + numInputs: 1, + numOutputs: 1, + maxTxVersion: 2, + wantErr: true, + expectedErrMsg: "tx weight must not exceed 400000", + }, + } + for _, tt := range tests { + tt := tt + t.Run(tt.name, func(t *testing.T) { + t.Parallel() + err := btcstaking.CheckPreSignedTxSanity( + tt.genTx(), tt.numInputs, tt.numOutputs, tt.maxTxVersion, + ) + + if tt.wantErr { + require.Error(t, err) + require.Contains(t, err.Error(), tt.expectedErrMsg) + } else { + require.NoError(t, err) + } + }) + } +} diff --git a/btcstaking/testvectors/vectors.json b/btcstaking/testvectors/vectors.json index a3272abf5..7d17f02de 100644 --- a/btcstaking/testvectors/vectors.json +++ b/btcstaking/testvectors/vectors.json @@ -34,7 +34,7 @@ } }, { - "name": "1 finality key, 3/5 covenant committe, 1 staker key with op_return", + "name": "1 finality key, 3/5 covenant committee, 1 staker key with op_return", "parameters": { "covenant_public_keys": [ "02cc5c77da065c490a320834fdcf2c3da70ecd442054c90f874a1edb4669607b83", @@ -71,7 +71,7 @@ } }, { - "name": "3 finality keys, 3/5 covenant committe, 1 staker key with no op_return", + "name": "3 finality keys, 3/5 covenant committee, 1 staker key with no op_return", "parameters": { "covenant_public_keys": [ "02042916c9cd52cfa146118c37b6b118f082bb50fb91da1c51b76dfc2100e66f00", @@ -110,7 +110,7 @@ } }, { - "name": "1 finality keys, 7/9 covenant committe, 1 staker key with op_return", + "name": "1 finality keys, 7/9 covenant committee, 1 staker key with op_return", "parameters": { "covenant_public_keys": [ "0287ed5bb2d036baf209eb49520327f6bd05285dabd30c97f239c3a69ff419950b", @@ -151,7 +151,7 @@ } }, { - "name": "10 finality keys, 18/20 covenant committe, 1 staker key with no op_return", + "name": "10 finality keys, 18/20 covenant committee, 1 staker key with no op_return", "parameters": { "covenant_public_keys": [ "02e3803a6ecff76daf35709c8484f382783d211970f22397d7a258f40ca3b46304", diff --git a/btcstaking/types.go b/btcstaking/types.go index d6dc68f8c..482238035 100644 --- a/btcstaking/types.go +++ b/btcstaking/types.go @@ -616,6 +616,8 @@ func BuildRelativeTimelockTaprootScript( // ParseBlkHeightAndPubKeyFromStoreKey expects to receive a key with // BigEndianUint64(blkHeight) || BIP340PubKey(fpBTCPK) +// TODO: this function should not be in the btcstaking library +// it is related to our internal cosmos sdk storage func ParseBlkHeightAndPubKeyFromStoreKey(key []byte) (blkHeight uint64, fpBTCPK *bbn.BIP340PubKey, err error) { sizeBigEndian := 8 if len(key) < sizeBigEndian+1 { diff --git a/client/client/tx.go b/client/client/tx.go index f3bac897e..47e18bbd3 100644 --- a/client/client/tx.go +++ b/client/client/tx.go @@ -56,7 +56,7 @@ func (c *Client) SendMsgsToMempool(ctx context.Context, msgs []sdk.Msg) error { } return sendMsgErr }, retry.Context(ctx), rtyAtt, rtyDel, rtyErr, retry.OnRetry(func(n uint, err error) { - c.logger.Debug("retrying", zap.Uint("attemp", n+1), zap.Uint("max_attempts", rtyAttNum), zap.Error(err)) + c.logger.Debug("retrying", zap.Uint("attempt", n+1), zap.Uint("max_attempts", rtyAttNum), zap.Error(err)) })); err != nil { return err } @@ -119,7 +119,7 @@ func (c *Client) ReliablySendMsgs(ctx context.Context, msgs []sdk.Msg, expectedE } return nil }, retry.Context(ctx), rtyAtt, rtyDel, rtyErr, retry.OnRetry(func(n uint, err error) { - c.logger.Debug("retrying", zap.Uint("attemp", n+1), zap.Uint("max_attempts", rtyAttNum), zap.Error(err)) + c.logger.Debug("retrying", zap.Uint("attempt", n+1), zap.Uint("max_attempts", rtyAttNum), zap.Error(err)) })); err != nil { return nil, err } @@ -179,7 +179,7 @@ func (c *Client) ReliablySendMsgsWithSigner(ctx context.Context, signerAddr sdk. wg.Done() return nil }, retry.Context(ctx), rtyAtt, rtyDel, rtyErr, retry.OnRetry(func(n uint, err error) { - c.logger.Debug("retrying", zap.Uint("attemp", n+1), zap.Uint("max_attempts", rtyAttNum), zap.Error(err)) + c.logger.Debug("retrying", zap.Uint("attempt", n+1), zap.Uint("max_attempts", rtyAttNum), zap.Error(err)) })); err != nil { return nil, err } @@ -377,7 +377,7 @@ func (c *Client) CalculateGas(ctx context.Context, txf tx.Factory, signingPK cry // Sign signs a given tx with the private key. The bytes signed over are canconical. // The resulting signature will be added to the transaction builder overwriting the previous // ones if overwrite=true (otherwise, the signature will be appended). -// Signing a transaction with mutltiple signers in the DIRECT mode is not supprted and will +// Signing a transaction with mutltiple signers in the DIRECT mode is not supported and will // return an error. // An error is returned upon failure. func Sign( diff --git a/client/docs/config.json b/client/docs/config.json index ece266f16..83337a2aa 100644 --- a/client/docs/config.json +++ b/client/docs/config.json @@ -37,14 +37,6 @@ "Params": "CheckpointingParams" } } - }, - { - "url": "./tmp-swagger-gen/babylon/zoneconcierge/v1/query.swagger.json", - "operationIds": { - "rename": { - "Params": "ZoneConciergeParams" - } - } } ] } diff --git a/client/docs/diagrams/submit_checkpoint.puml b/client/docs/diagrams/submit_checkpoint.puml index d7a3999c7..f8f664b79 100644 --- a/client/docs/diagrams/submit_checkpoint.puml +++ b/client/docs/diagrams/submit_checkpoint.puml @@ -64,7 +64,7 @@ loop Bitcoin --> submitter : Wait for previous checkpoint carrier BTC block to embed note right Even a light client can do this, - becuase the BTC block to observe + because the BTC block to observe is part of the Event from Babylon. Waiting ensures the checkpoint diff --git a/client/docs/swagger-ui/swagger.yaml b/client/docs/swagger-ui/swagger.yaml index a59dd6156..6499e284f 100644 --- a/client/docs/swagger-ui/swagger.yaml +++ b/client/docs/swagger-ui/swagger.yaml @@ -24,8 +24,8 @@ paths: format: uint64 description: EpochNumber of this checkpoint. best_submission_btc_block_height: - type: string - format: uint64 + type: integer + format: int64 title: btc height of the best submission of the epoch best_submission_btc_block_hash: type: string @@ -229,8 +229,8 @@ paths: type: object properties: btc_confirmation_depth: - type: string - format: uint64 + type: integer + format: int64 title: >- btc_confirmation_depth is the confirmation depth in BTC. @@ -239,8 +239,8 @@ paths: (k in research paper) checkpoint_finalization_timeout: - type: string - format: uint64 + type: integer + format: int64 title: >- checkpoint_finalization_timeout is the maximum time window (measured in BTC @@ -308,8 +308,8 @@ paths: format: uint64 description: EpochNumber of this checkpoint. best_submission_btc_block_height: - type: string - format: uint64 + type: integer + format: int64 title: btc height of the best submission of the epoch best_submission_btc_block_hash: type: string @@ -520,8 +520,8 @@ paths: hash_hex: type: string height: - type: string - format: uint64 + type: integer + format: int64 work: type: string description: Work is the sdkmath.Uint as string. @@ -676,8 +676,8 @@ paths: type: object properties: depth: - type: string - format: uint64 + type: integer + format: int64 title: >- QueryMainChainDepthResponse is the response type for the Query/MainChainDepth RPC @@ -859,8 +859,8 @@ paths: hash_hex: type: string height: - type: string - format: uint64 + type: integer + format: int64 work: type: string description: Work is the sdkmath.Uint as string. @@ -1055,8 +1055,8 @@ paths: hash_hex: type: string height: - type: string - format: uint64 + type: integer + format: int64 work: type: string description: Work is the sdkmath.Uint as string. @@ -3726,9 +3726,8 @@ paths: validator_address: type: string title: validator_address is the address of the validator - bls_pub_key: + bls_pub_key_hex: type: string - format: byte title: bls_pub_key is the BLS public key of the validator voting_power: type: string @@ -3737,8 +3736,8 @@ paths: voting_power is the voting power of the validator at the given epoch title: >- - ValidatorWithBlsKey couples validator address, voting power, - and its bls + BlsPublicKeyListResponse couples validator address, voting + power, and its bls public key pagination: @@ -4124,7 +4123,7 @@ paths: title: status defines the status of the checkpoint status_desc: type: string - description: status_desc respresents the description of status enum. + description: status_desc represents the description of status enum. bls_aggr_pk: type: string format: byte @@ -4163,7 +4162,7 @@ paths: status_desc: type: string description: >- - status_desc respresents the description of status + status_desc represents the description of status enum. block_height: type: string @@ -4302,7 +4301,7 @@ paths: title: status defines the status of the checkpoint status_desc: type: string - description: status_desc respresents the description of status enum. + description: status_desc represents the description of status enum. bls_aggr_pk: type: string format: byte @@ -4341,7 +4340,7 @@ paths: status_desc: type: string description: >- - status_desc respresents the description of status + status_desc represents the description of status enum. block_height: type: string @@ -4550,7 +4549,7 @@ paths: title: status defines the status of the checkpoint status_desc: type: string - description: status_desc respresents the description of status enum. + description: status_desc represents the description of status enum. bls_aggr_pk: type: string format: byte @@ -4589,7 +4588,7 @@ paths: status_desc: type: string description: >- - status_desc respresents the description of status + status_desc represents the description of status enum. block_height: type: string @@ -4738,6425 +4737,1149 @@ paths: type: boolean tags: - Query - /babylon/zoneconcierge/v1/chain_info/{consumer_id}/header/{height}: - get: - summary: Header queries the CZ header and fork headers at a given height. - operationId: Header - responses: - '200': - description: A successful response. - schema: - type: object - properties: - header: - type: object - properties: - consumer_id: - type: string - title: consumer_id is the unique ID of the consumer - hash: - type: string - format: byte - title: hash is the hash of this header - height: - type: string - format: uint64 - title: >- - height is the height of this header on CZ ledger - - (hash, height) jointly provides the position of the header - on CZ ledger - time: - type: string - format: date-time - title: >- - time is the timestamp of this header on CZ ledger - - it is needed for CZ to unbond all mature - validators/delegations - - before this timestamp when this header is BTC-finalised - babylon_header_hash: - type: string - format: byte - title: >- - babylon_header_hash is the hash of the babylon block that - includes this CZ - - header - babylon_header_height: - type: string - format: uint64 - title: >- - babylon_header_height is the height of the babylon block - that includes this CZ - - header - babylon_epoch: - type: string - format: uint64 - title: epoch is the epoch number of this header on Babylon ledger - babylon_tx_hash: - type: string - format: byte - title: >- - babylon_tx_hash is the hash of the tx that includes this - header - - (babylon_block_height, babylon_tx_hash) jointly provides - the position of - - the header on Babylon ledger - title: IndexedHeader is the metadata of a CZ header - fork_headers: - type: object - properties: - headers: - type: array - items: - type: object - properties: - consumer_id: - type: string - title: consumer_id is the unique ID of the consumer - hash: - type: string - format: byte - title: hash is the hash of this header - height: - type: string - format: uint64 - title: >- - height is the height of this header on CZ ledger - - (hash, height) jointly provides the position of the - header on CZ ledger - time: - type: string - format: date-time - title: >- - time is the timestamp of this header on CZ ledger +definitions: + babylon.btccheckpoint.v1.BTCCheckpointInfoResponse: + type: object + properties: + epoch_number: + type: string + format: uint64 + description: EpochNumber of this checkpoint. + best_submission_btc_block_height: + type: integer + format: int64 + title: btc height of the best submission of the epoch + best_submission_btc_block_hash: + type: string + title: >- + hash of the btc block which determines checkpoint btc block height + i.e. - it is needed for CZ to unbond all mature - validators/delegations + youngest block of best submission Hexadecimal + best_submission_transactions: + type: array + items: + type: object + properties: + index: + type: integer + format: int64 + description: Index Bitcoin Transaction index in block. + hash: + type: string + description: Hash BTC Header hash as hex. + transaction: + type: string + description: transaction is the full transaction data as str hex. + proof: + type: string + title: >- + proof is the Merkle proof that this tx is included in the + position in `key` + title: |- + TransactionInfoResponse is the info of a tx on Bitcoin, + including + - the position of the tx on BTC blockchain + - the full tx content + - the Merkle proof that this tx is on the above position + title: the BTC checkpoint transactions of the best submission + best_submission_vigilante_address_list: + type: array + items: + type: object + properties: + submitter: + type: string + description: >- + submitter is the address of the checkpoint submitter to BTC, + extracted from - before this timestamp when this header is - BTC-finalised - babylon_header_hash: - type: string - format: byte - title: >- - babylon_header_hash is the hash of the babylon block - that includes this CZ + the checkpoint itself. + reporter: + type: string + title: >- + reporter is the address of the reporter who reported the + submissions, - header - babylon_header_height: - type: string - format: uint64 - title: >- - babylon_header_height is the height of the babylon - block that includes this CZ + calculated from submission message MsgInsertBTCSpvProof itself + title: >- + CheckpointAddressesResponse contains the addresses of the submitter + and reporter of a - header - babylon_epoch: - type: string - format: uint64 - title: >- - epoch is the epoch number of this header on Babylon - ledger - babylon_tx_hash: - type: string - format: byte - title: >- - babylon_tx_hash is the hash of the tx that includes - this header + given checkpoint + title: list of vigilantes' addresses of the best submission + description: >- + BTCCheckpointInfoResponse contains all data about best submission of + checkpoint for - (babylon_block_height, babylon_tx_hash) jointly - provides the position of + given epoch. Best submission is the submission which is deeper in btc + ledger. + babylon.btccheckpoint.v1.CheckpointAddressesResponse: + type: object + properties: + submitter: + type: string + description: >- + submitter is the address of the checkpoint submitter to BTC, extracted + from - the header on Babylon ledger - title: IndexedHeader is the metadata of a CZ header - title: >- - blocks is the list of non-canonical indexed headers at the - same height - description: >- - Forks is a list of non-canonical `IndexedHeader`s at the same - height. + the checkpoint itself. + reporter: + type: string + title: |- + reporter is the address of the reporter who reported the submissions, + calculated from submission message MsgInsertBTCSpvProof itself + title: >- + CheckpointAddressesResponse contains the addresses of the submitter and + reporter of a - For example, assuming the following blockchain + given checkpoint + babylon.btccheckpoint.v1.Params: + type: object + properties: + btc_confirmation_depth: + type: integer + format: int64 + title: >- + btc_confirmation_depth is the confirmation depth in BTC. - ``` + A block is considered irreversible only when it is at least k-deep in + BTC - A <- B <- C <- D <- E - \ -- D1 - \ -- D2 - ``` + (k in research paper) + checkpoint_finalization_timeout: + type: integer + format: int64 + title: >- + checkpoint_finalization_timeout is the maximum time window (measured + in BTC - Then the fork will be {[D1, D2]} where each item is in struct - `IndexedBlock`. + blocks) between a checkpoint + - being submitted to BTC, and - Note that each `IndexedHeader` in the fork should have a valid - quorum + - being reported back to BBN - certificate. Such forks exist since Babylon considers CZs - might have + If a checkpoint has not been reported back within w BTC blocks, then + BBN - dishonest majority. Also note that the IBC-Go implementation - will only + has dishonest majority and is stalling checkpoints (w in research + paper) + checkpoint_tag: + type: string + title: >- + 4byte tag in hex format, required to be present in the OP_RETURN + transaction - consider the first header in a fork valid, since the - subsequent headers + related to babylon + description: Params defines the parameters for the module. + babylon.btccheckpoint.v1.QueryBtcCheckpointInfoResponse: + type: object + properties: + info: + type: object + properties: + epoch_number: + type: string + format: uint64 + description: EpochNumber of this checkpoint. + best_submission_btc_block_height: + type: integer + format: int64 + title: btc height of the best submission of the epoch + best_submission_btc_block_hash: + type: string + title: >- + hash of the btc block which determines checkpoint btc block height + i.e. - cannot be verified without knowing the validator set in the - previous header. - description: >- - QueryHeaderResponse is response type for the Query/Header RPC - method. - default: - description: An unexpected error response. - schema: - type: object - properties: - error: - type: string - code: - type: integer - format: int32 - message: - type: string - details: - type: array - items: - type: object - properties: - type_url: - type: string - description: >- - A URL/resource name that uniquely identifies the type of - the serialized - - protocol buffer message. This string must contain at - least - - one "/" character. The last segment of the URL's path - must represent - - the fully qualified name of the type (as in + youngest block of best submission Hexadecimal + best_submission_transactions: + type: array + items: + type: object + properties: + index: + type: integer + format: int64 + description: Index Bitcoin Transaction index in block. + hash: + type: string + description: Hash BTC Header hash as hex. + transaction: + type: string + description: transaction is the full transaction data as str hex. + proof: + type: string + title: >- + proof is the Merkle proof that this tx is included in the + position in `key` + title: |- + TransactionInfoResponse is the info of a tx on Bitcoin, + including + - the position of the tx on BTC blockchain + - the full tx content + - the Merkle proof that this tx is on the above position + title: the BTC checkpoint transactions of the best submission + best_submission_vigilante_address_list: + type: array + items: + type: object + properties: + submitter: + type: string + description: >- + submitter is the address of the checkpoint submitter to BTC, + extracted from - `path/google.protobuf.Duration`). The name should be in - a canonical form + the checkpoint itself. + reporter: + type: string + title: >- + reporter is the address of the reporter who reported the + submissions, - (e.g., leading "." is not accepted). + calculated from submission message MsgInsertBTCSpvProof + itself + title: >- + CheckpointAddressesResponse contains the addresses of the + submitter and reporter of a + given checkpoint + title: list of vigilantes' addresses of the best submission + description: >- + BTCCheckpointInfoResponse contains all data about best submission of + checkpoint for - In practice, teams usually precompile into the binary - all types that they + given epoch. Best submission is the submission which is deeper in btc + ledger. + title: |- + QueryBtcCheckpointInfoResponse is response type for the + Query/BtcCheckpointInfo RPC method + babylon.btccheckpoint.v1.QueryBtcCheckpointsInfoResponse: + type: object + properties: + info_list: + type: array + items: + type: object + properties: + epoch_number: + type: string + format: uint64 + description: EpochNumber of this checkpoint. + best_submission_btc_block_height: + type: integer + format: int64 + title: btc height of the best submission of the epoch + best_submission_btc_block_hash: + type: string + title: >- + hash of the btc block which determines checkpoint btc block + height i.e. - expect it to use in the context of Any. However, for - URLs which use the + youngest block of best submission Hexadecimal + best_submission_transactions: + type: array + items: + type: object + properties: + index: + type: integer + format: int64 + description: Index Bitcoin Transaction index in block. + hash: + type: string + description: Hash BTC Header hash as hex. + transaction: + type: string + description: transaction is the full transaction data as str hex. + proof: + type: string + title: >- + proof is the Merkle proof that this tx is included in the + position in `key` + title: |- + TransactionInfoResponse is the info of a tx on Bitcoin, + including + - the position of the tx on BTC blockchain + - the full tx content + - the Merkle proof that this tx is on the above position + title: the BTC checkpoint transactions of the best submission + best_submission_vigilante_address_list: + type: array + items: + type: object + properties: + submitter: + type: string + description: >- + submitter is the address of the checkpoint submitter to + BTC, extracted from - scheme `http`, `https`, or no scheme, one can optionally - set up a type + the checkpoint itself. + reporter: + type: string + title: >- + reporter is the address of the reporter who reported the + submissions, - server that maps type URLs to message definitions as - follows: + calculated from submission message MsgInsertBTCSpvProof + itself + title: >- + CheckpointAddressesResponse contains the addresses of the + submitter and reporter of a + given checkpoint + title: list of vigilantes' addresses of the best submission + description: >- + BTCCheckpointInfoResponse contains all data about best submission of + checkpoint for - * If no scheme is provided, `https` is assumed. + given epoch. Best submission is the submission which is deeper in + btc ledger. + pagination: + title: pagination defines the pagination in the response + type: object + properties: + next_key: + type: string + format: byte + description: |- + next_key is the key to be passed to PageRequest.key to + query the next page most efficiently. It will be empty if + there are no more results. + total: + type: string + format: uint64 + title: >- + total is total number of results available if + PageRequest.count_total - * An HTTP GET on the URL must yield a - [google.protobuf.Type][] - value in binary format, or produce an error. - * Applications are allowed to cache lookup results based - on the - URL, or have them precompiled into a binary to avoid any - lookup. Therefore, binary compatibility needs to be preserved - on changes to types. (Use versioned type names to manage - breaking changes.) + was set, its value is undefined otherwise + description: |- + PageResponse is to be embedded in gRPC response messages where the + corresponding request message has used PageRequest. - Note: this functionality is not currently available in - the official + message SomeResponse { + repeated Bar results = 1; + PageResponse page = 2; + } + title: |- + QueryBtcCheckpointsInfoResponse is response type for the + Query/BtcCheckpointsInfo RPC method + babylon.btccheckpoint.v1.QueryEpochSubmissionsResponse: + type: object + properties: + keys: + type: array + items: + type: object + properties: + first_tx_block_hash: + type: string + description: FirstTxBlockHash is the BTCHeaderHashBytes in hex. + first_tx_index: + type: integer + format: int64 + second_tx_block_hash: + type: string + description: SecondBlockHash is the BTCHeaderHashBytes in hex. + second_tx_index: + type: integer + format: int64 + title: >- + SubmissionKeyResponse Checkpoint can be composed from multiple + transactions, - protobuf release, and it is not used for type URLs - beginning with + so to identify whole submission we need list of transaction keys. - type.googleapis.com. + Each submission can generally be identified by this list of (txIdx, + blockHash) tuples. Note: this could possibly be optimized as if + transactions - Schemes other than `http`, `https` (or the empty scheme) - might be + were in one block they would have the same block hash and different + indexes, - used with implementation specific semantics. - value: - type: string - format: byte - description: >- - Must be a valid serialized protocol buffer of the above - specified type. - description: >- - `Any` contains an arbitrary serialized protocol buffer - message along with a + but each blockhash is only 33 (1 byte for prefix encoding and 32 + byte hash), - URL that describes the type of the serialized message. + so there should be other strong arguments for this optimization + description: Keys All submissions transactions key saved during an epoch. + title: |- + QueryEpochSubmissionsResponse defines a response to get all submissions in + given epoch (QueryEpochSubmissionsRequest) + babylon.btccheckpoint.v1.QueryParamsResponse: + type: object + properties: + params: + description: params holds all the parameters of this module. + type: object + properties: + btc_confirmation_depth: + type: integer + format: int64 + title: >- + btc_confirmation_depth is the confirmation depth in BTC. + A block is considered irreversible only when it is at least k-deep + in BTC - Protobuf library provides support to pack/unpack Any values - in the form + (k in research paper) + checkpoint_finalization_timeout: + type: integer + format: int64 + title: >- + checkpoint_finalization_timeout is the maximum time window + (measured in BTC - of utility functions or additional generated methods of the - Any type. + blocks) between a checkpoint + - being submitted to BTC, and - Example 1: Pack and unpack a message in C++. + - being reported back to BBN - Foo foo = ...; - Any any; - any.PackFrom(foo); - ... - if (any.UnpackTo(&foo)) { - ... - } + If a checkpoint has not been reported back within w BTC blocks, + then BBN - Example 2: Pack and unpack a message in Java. + has dishonest majority and is stalling checkpoints (w in research + paper) + checkpoint_tag: + type: string + title: >- + 4byte tag in hex format, required to be present in the OP_RETURN + transaction - Foo foo = ...; - Any any = Any.pack(foo); - ... - if (any.is(Foo.class)) { - foo = any.unpack(Foo.class); - } - // or ... - if (any.isSameTypeAs(Foo.getDefaultInstance())) { - foo = any.unpack(Foo.getDefaultInstance()); - } + related to babylon + description: QueryParamsResponse is response type for the Query/Params RPC method. + babylon.btccheckpoint.v1.SubmissionKeyResponse: + type: object + properties: + first_tx_block_hash: + type: string + description: FirstTxBlockHash is the BTCHeaderHashBytes in hex. + first_tx_index: + type: integer + format: int64 + second_tx_block_hash: + type: string + description: SecondBlockHash is the BTCHeaderHashBytes in hex. + second_tx_index: + type: integer + format: int64 + title: >- + SubmissionKeyResponse Checkpoint can be composed from multiple + transactions, - Example 3: Pack and unpack a message in Python. + so to identify whole submission we need list of transaction keys. - foo = Foo(...) - any = Any() - any.Pack(foo) - ... - if any.Is(Foo.DESCRIPTOR): - any.Unpack(foo) - ... + Each submission can generally be identified by this list of (txIdx, - Example 4: Pack and unpack a message in Go + blockHash) tuples. Note: this could possibly be optimized as if + transactions - foo := &pb.Foo{...} - any, err := anypb.New(foo) - if err != nil { - ... - } - ... - foo := &pb.Foo{} - if err := any.UnmarshalTo(foo); err != nil { - ... - } + were in one block they would have the same block hash and different + indexes, - The pack methods provided by protobuf library will by - default use + but each blockhash is only 33 (1 byte for prefix encoding and 32 byte + hash), - 'type.googleapis.com/full.type.name' as the type URL and the - unpack + so there should be other strong arguments for this optimization + babylon.btccheckpoint.v1.TransactionInfoResponse: + type: object + properties: + index: + type: integer + format: int64 + description: Index Bitcoin Transaction index in block. + hash: + type: string + description: Hash BTC Header hash as hex. + transaction: + type: string + description: transaction is the full transaction data as str hex. + proof: + type: string + title: >- + proof is the Merkle proof that this tx is included in the position in + `key` + title: |- + TransactionInfoResponse is the info of a tx on Bitcoin, + including + - the position of the tx on BTC blockchain + - the full tx content + - the Merkle proof that this tx is on the above position + cosmos.base.query.v1beta1.PageRequest: + type: object + properties: + key: + type: string + format: byte + description: |- + key is a value returned in PageResponse.next_key to begin + querying the next page most efficiently. Only one of offset or key + should be set. + offset: + type: string + format: uint64 + description: |- + offset is a numeric offset that can be used when key is unavailable. + It is less efficient than using key. Only one of offset or key should + be set. + limit: + type: string + format: uint64 + description: >- + limit is the total number of results to be returned in the result + page. - methods only use the fully qualified type name after the - last '/' + If left empty it will default to a value to be set by each app. + count_total: + type: boolean + description: >- + count_total is set to true to indicate that the result set should + include - in the type URL, for example "foo.bar.com/x/y.z" will yield - type + a count of the total number of items available for pagination in UIs. - name "y.z". + count_total is only respected when offset is used. It is ignored when + key + is set. + reverse: + type: boolean + description: >- + reverse is set to true if results are to be returned in the descending + order. - JSON + Since: cosmos-sdk 0.43 + description: |- + message SomeRequest { + Foo some_parameter = 1; + PageRequest pagination = 2; + } + title: |- + PageRequest is to be embedded in gRPC request messages for efficient + pagination. Ex: + cosmos.base.query.v1beta1.PageResponse: + type: object + properties: + next_key: + type: string + format: byte + description: |- + next_key is the key to be passed to PageRequest.key to + query the next page most efficiently. It will be empty if + there are no more results. + total: + type: string + format: uint64 + title: |- + total is total number of results available if PageRequest.count_total + was set, its value is undefined otherwise + description: |- + PageResponse is to be embedded in gRPC response messages where the + corresponding request message has used PageRequest. - The JSON representation of an `Any` value uses the regular + message SomeResponse { + repeated Bar results = 1; + PageResponse page = 2; + } + google.protobuf.Any: + type: object + properties: + type_url: + type: string + description: >- + A URL/resource name that uniquely identifies the type of the + serialized - representation of the deserialized, embedded message, with - an + protocol buffer message. This string must contain at least - additional field `@type` which contains the type URL. - Example: + one "/" character. The last segment of the URL's path must represent - package google.profile; - message Person { - string first_name = 1; - string last_name = 2; - } + the fully qualified name of the type (as in - { - "@type": "type.googleapis.com/google.profile.Person", - "firstName": , - "lastName": - } + `path/google.protobuf.Duration`). The name should be in a canonical + form - If the embedded message type is well-known and has a custom - JSON + (e.g., leading "." is not accepted). - representation, that representation will be embedded adding - a field - `value` which holds the custom JSON in addition to the - `@type` + In practice, teams usually precompile into the binary all types that + they - field. Example (for message [google.protobuf.Duration][]): + expect it to use in the context of Any. However, for URLs which use + the - { - "@type": "type.googleapis.com/google.protobuf.Duration", - "value": "1.212s" - } - parameters: - - name: consumer_id - in: path - required: true - type: string - - name: height - in: path - required: true - type: string - format: uint64 - tags: - - Query - /babylon/zoneconcierge/v1/chains: - get: - summary: ChainList queries the list of chains that checkpoint to Babylon - operationId: ChainList - responses: - '200': - description: A successful response. - schema: - type: object - properties: - consumer_ids: - type: array - items: - type: string - title: >- - consumer_ids are IDs of the chains in ascending alphabetical - order - pagination: - title: pagination defines the pagination in the response - type: object - properties: - next_key: - type: string - format: byte - description: |- - next_key is the key to be passed to PageRequest.key to - query the next page most efficiently. It will be empty if - there are no more results. - total: - type: string - format: uint64 - title: >- - total is total number of results available if - PageRequest.count_total - - was set, its value is undefined otherwise - description: >- - PageResponse is to be embedded in gRPC response messages where - the + scheme `http`, `https`, or no scheme, one can optionally set up a type - corresponding request message has used PageRequest. + server that maps type URLs to message definitions as follows: - message SomeResponse { - repeated Bar results = 1; - PageResponse page = 2; - } - title: >- - QueryChainListResponse is response type for the Query/ChainList - RPC method - default: - description: An unexpected error response. - schema: - type: object - properties: - error: - type: string - code: - type: integer - format: int32 - message: - type: string - details: - type: array - items: - type: object - properties: - type_url: - type: string - description: >- - A URL/resource name that uniquely identifies the type of - the serialized - protocol buffer message. This string must contain at - least + * If no scheme is provided, `https` is assumed. - one "/" character. The last segment of the URL's path - must represent + * An HTTP GET on the URL must yield a [google.protobuf.Type][] + value in binary format, or produce an error. + * Applications are allowed to cache lookup results based on the + URL, or have them precompiled into a binary to avoid any + lookup. Therefore, binary compatibility needs to be preserved + on changes to types. (Use versioned type names to manage + breaking changes.) - the fully qualified name of the type (as in + Note: this functionality is not currently available in the official - `path/google.protobuf.Duration`). The name should be in - a canonical form + protobuf release, and it is not used for type URLs beginning with - (e.g., leading "." is not accepted). + type.googleapis.com. - In practice, teams usually precompile into the binary - all types that they + Schemes other than `http`, `https` (or the empty scheme) might be - expect it to use in the context of Any. However, for - URLs which use the + used with implementation specific semantics. + value: + type: string + format: byte + description: >- + Must be a valid serialized protocol buffer of the above specified + type. + description: >- + `Any` contains an arbitrary serialized protocol buffer message along with + a - scheme `http`, `https`, or no scheme, one can optionally - set up a type + URL that describes the type of the serialized message. - server that maps type URLs to message definitions as - follows: + Protobuf library provides support to pack/unpack Any values in the form - * If no scheme is provided, `https` is assumed. + of utility functions or additional generated methods of the Any type. - * An HTTP GET on the URL must yield a - [google.protobuf.Type][] - value in binary format, or produce an error. - * Applications are allowed to cache lookup results based - on the - URL, or have them precompiled into a binary to avoid any - lookup. Therefore, binary compatibility needs to be preserved - on changes to types. (Use versioned type names to manage - breaking changes.) - Note: this functionality is not currently available in - the official + Example 1: Pack and unpack a message in C++. - protobuf release, and it is not used for type URLs - beginning with + Foo foo = ...; + Any any; + any.PackFrom(foo); + ... + if (any.UnpackTo(&foo)) { + ... + } - type.googleapis.com. + Example 2: Pack and unpack a message in Java. + Foo foo = ...; + Any any = Any.pack(foo); + ... + if (any.is(Foo.class)) { + foo = any.unpack(Foo.class); + } + // or ... + if (any.isSameTypeAs(Foo.getDefaultInstance())) { + foo = any.unpack(Foo.getDefaultInstance()); + } - Schemes other than `http`, `https` (or the empty scheme) - might be + Example 3: Pack and unpack a message in Python. - used with implementation specific semantics. - value: - type: string - format: byte - description: >- - Must be a valid serialized protocol buffer of the above - specified type. - description: >- - `Any` contains an arbitrary serialized protocol buffer - message along with a + foo = Foo(...) + any = Any() + any.Pack(foo) + ... + if any.Is(Foo.DESCRIPTOR): + any.Unpack(foo) + ... - URL that describes the type of the serialized message. + Example 4: Pack and unpack a message in Go + foo := &pb.Foo{...} + any, err := anypb.New(foo) + if err != nil { + ... + } + ... + foo := &pb.Foo{} + if err := any.UnmarshalTo(foo); err != nil { + ... + } - Protobuf library provides support to pack/unpack Any values - in the form + The pack methods provided by protobuf library will by default use - of utility functions or additional generated methods of the - Any type. + 'type.googleapis.com/full.type.name' as the type URL and the unpack + methods only use the fully qualified type name after the last '/' - Example 1: Pack and unpack a message in C++. + in the type URL, for example "foo.bar.com/x/y.z" will yield type - Foo foo = ...; - Any any; - any.PackFrom(foo); - ... - if (any.UnpackTo(&foo)) { - ... - } + name "y.z". - Example 2: Pack and unpack a message in Java. - Foo foo = ...; - Any any = Any.pack(foo); - ... - if (any.is(Foo.class)) { - foo = any.unpack(Foo.class); - } - // or ... - if (any.isSameTypeAs(Foo.getDefaultInstance())) { - foo = any.unpack(Foo.getDefaultInstance()); - } + JSON - Example 3: Pack and unpack a message in Python. - foo = Foo(...) - any = Any() - any.Pack(foo) - ... - if any.Is(Foo.DESCRIPTOR): - any.Unpack(foo) - ... + The JSON representation of an `Any` value uses the regular - Example 4: Pack and unpack a message in Go + representation of the deserialized, embedded message, with an - foo := &pb.Foo{...} - any, err := anypb.New(foo) - if err != nil { - ... - } - ... - foo := &pb.Foo{} - if err := any.UnmarshalTo(foo); err != nil { - ... - } + additional field `@type` which contains the type URL. Example: - The pack methods provided by protobuf library will by - default use + package google.profile; + message Person { + string first_name = 1; + string last_name = 2; + } - 'type.googleapis.com/full.type.name' as the type URL and the - unpack + { + "@type": "type.googleapis.com/google.profile.Person", + "firstName": , + "lastName": + } - methods only use the fully qualified type name after the - last '/' + If the embedded message type is well-known and has a custom JSON - in the type URL, for example "foo.bar.com/x/y.z" will yield - type + representation, that representation will be embedded adding a field - name "y.z". + `value` which holds the custom JSON in addition to the `@type` + field. Example (for message [google.protobuf.Duration][]): - JSON + { + "@type": "type.googleapis.com/google.protobuf.Duration", + "value": "1.212s" + } + grpc.gateway.runtime.Error: + type: object + properties: + error: + type: string + code: + type: integer + format: int32 + message: + type: string + details: + type: array + items: + type: object + properties: + type_url: + type: string + description: >- + A URL/resource name that uniquely identifies the type of the + serialized + protocol buffer message. This string must contain at least - The JSON representation of an `Any` value uses the regular + one "/" character. The last segment of the URL's path must + represent - representation of the deserialized, embedded message, with - an + the fully qualified name of the type (as in - additional field `@type` which contains the type URL. - Example: + `path/google.protobuf.Duration`). The name should be in a + canonical form - package google.profile; - message Person { - string first_name = 1; - string last_name = 2; - } + (e.g., leading "." is not accepted). - { - "@type": "type.googleapis.com/google.profile.Person", - "firstName": , - "lastName": - } - If the embedded message type is well-known and has a custom - JSON + In practice, teams usually precompile into the binary all types + that they - representation, that representation will be embedded adding - a field + expect it to use in the context of Any. However, for URLs which + use the - `value` which holds the custom JSON in addition to the - `@type` + scheme `http`, `https`, or no scheme, one can optionally set up + a type - field. Example (for message [google.protobuf.Duration][]): + server that maps type URLs to message definitions as follows: - { - "@type": "type.googleapis.com/google.protobuf.Duration", - "value": "1.212s" - } - parameters: - - name: pagination.key - description: |- - key is a value returned in PageResponse.next_key to begin - querying the next page most efficiently. Only one of offset or key - should be set. - in: query - required: false - type: string - format: byte - - name: pagination.offset - description: >- - offset is a numeric offset that can be used when key is unavailable. - It is less efficient than using key. Only one of offset or key - should + * If no scheme is provided, `https` is assumed. - be set. - in: query - required: false - type: string - format: uint64 - - name: pagination.limit - description: >- - limit is the total number of results to be returned in the result - page. + * An HTTP GET on the URL must yield a [google.protobuf.Type][] + value in binary format, or produce an error. + * Applications are allowed to cache lookup results based on the + URL, or have them precompiled into a binary to avoid any + lookup. Therefore, binary compatibility needs to be preserved + on changes to types. (Use versioned type names to manage + breaking changes.) - If left empty it will default to a value to be set by each app. - in: query - required: false - type: string - format: uint64 - - name: pagination.count_total - description: >- - count_total is set to true to indicate that the result set should - include + Note: this functionality is not currently available in the + official - a count of the total number of items available for pagination in - UIs. + protobuf release, and it is not used for type URLs beginning + with - count_total is only respected when offset is used. It is ignored - when key + type.googleapis.com. - is set. - in: query - required: false - type: boolean - - name: pagination.reverse + + Schemes other than `http`, `https` (or the empty scheme) might + be + + used with implementation specific semantics. + value: + type: string + format: byte + description: >- + Must be a valid serialized protocol buffer of the above + specified type. description: >- - reverse is set to true if results are to be returned in the - descending order. + `Any` contains an arbitrary serialized protocol buffer message along + with a + URL that describes the type of the serialized message. - Since: cosmos-sdk 0.43 - in: query - required: false - type: boolean - tags: - - Query - /babylon/zoneconcierge/v1/chains_info: - get: - summary: >- - ChainsInfo queries the latest info for a given list of chains in - Babylon's view - operationId: ChainsInfo - responses: - '200': - description: A successful response. - schema: - type: object - properties: - chains_info: - type: array - items: - type: object - properties: - consumer_id: - type: string - title: consumer_id is the ID of the consumer - latest_header: - type: object - properties: - consumer_id: - type: string - title: consumer_id is the unique ID of the consumer - hash: - type: string - format: byte - title: hash is the hash of this header - height: - type: string - format: uint64 - title: >- - height is the height of this header on CZ ledger - (hash, height) jointly provides the position of the - header on CZ ledger - time: - type: string - format: date-time - title: >- - time is the timestamp of this header on CZ ledger + Protobuf library provides support to pack/unpack Any values in the + form - it is needed for CZ to unbond all mature - validators/delegations + of utility functions or additional generated methods of the Any + type. - before this timestamp when this header is - BTC-finalised - babylon_header_hash: - type: string - format: byte - title: >- - babylon_header_hash is the hash of the babylon block - that includes this CZ - header - babylon_header_height: - type: string - format: uint64 - title: >- - babylon_header_height is the height of the babylon - block that includes this CZ + Example 1: Pack and unpack a message in C++. - header - babylon_epoch: - type: string - format: uint64 - title: >- - epoch is the epoch number of this header on Babylon - ledger - babylon_tx_hash: - type: string - format: byte - title: >- - babylon_tx_hash is the hash of the tx that includes - this header + Foo foo = ...; + Any any; + any.PackFrom(foo); + ... + if (any.UnpackTo(&foo)) { + ... + } - (babylon_block_height, babylon_tx_hash) jointly - provides the position of + Example 2: Pack and unpack a message in Java. - the header on Babylon ledger - title: IndexedHeader is the metadata of a CZ header - latest_forks: - type: object - properties: - headers: - type: array - items: - type: object - properties: - consumer_id: - type: string - title: consumer_id is the unique ID of the consumer - hash: - type: string - format: byte - title: hash is the hash of this header - height: - type: string - format: uint64 - title: >- - height is the height of this header on CZ - ledger - - (hash, height) jointly provides the position - of the header on CZ ledger - time: - type: string - format: date-time - title: >- - time is the timestamp of this header on CZ - ledger - - it is needed for CZ to unbond all mature - validators/delegations - - before this timestamp when this header is - BTC-finalised - babylon_header_hash: - type: string - format: byte - title: >- - babylon_header_hash is the hash of the babylon - block that includes this CZ - - header - babylon_header_height: - type: string - format: uint64 - title: >- - babylon_header_height is the height of the - babylon block that includes this CZ - - header - babylon_epoch: - type: string - format: uint64 - title: >- - epoch is the epoch number of this header on - Babylon ledger - babylon_tx_hash: - type: string - format: byte - title: >- - babylon_tx_hash is the hash of the tx that - includes this header - - (babylon_block_height, babylon_tx_hash) - jointly provides the position of - - the header on Babylon ledger - title: IndexedHeader is the metadata of a CZ header - title: >- - blocks is the list of non-canonical indexed headers - at the same height - description: >- - Forks is a list of non-canonical `IndexedHeader`s at the - same height. + Foo foo = ...; + Any any = Any.pack(foo); + ... + if (any.is(Foo.class)) { + foo = any.unpack(Foo.class); + } + // or ... + if (any.isSameTypeAs(Foo.getDefaultInstance())) { + foo = any.unpack(Foo.getDefaultInstance()); + } - For example, assuming the following blockchain + Example 3: Pack and unpack a message in Python. - ``` + foo = Foo(...) + any = Any() + any.Pack(foo) + ... + if any.Is(Foo.DESCRIPTOR): + any.Unpack(foo) + ... - A <- B <- C <- D <- E - \ -- D1 - \ -- D2 - ``` + Example 4: Pack and unpack a message in Go - Then the fork will be {[D1, D2]} where each item is in - struct `IndexedBlock`. + foo := &pb.Foo{...} + any, err := anypb.New(foo) + if err != nil { + ... + } + ... + foo := &pb.Foo{} + if err := any.UnmarshalTo(foo); err != nil { + ... + } + The pack methods provided by protobuf library will by default use - Note that each `IndexedHeader` in the fork should have a - valid quorum + 'type.googleapis.com/full.type.name' as the type URL and the unpack - certificate. Such forks exist since Babylon considers - CZs might have + methods only use the fully qualified type name after the last '/' - dishonest majority. Also note that the IBC-Go - implementation will only + in the type URL, for example "foo.bar.com/x/y.z" will yield type - consider the first header in a fork valid, since the - subsequent headers + name "y.z". - cannot be verified without knowing the validator set in - the previous header. - title: >- - latest_forks is the latest forks, formed as a series of - IndexedHeader (from - low to high) - timestamped_headers_count: - type: string - format: uint64 - title: >- - timestamped_headers_count is the number of timestamped - headers in CZ's - - canonical chain - title: ChainInfo is the information of a CZ - description: >- - QueryChainsInfoResponse is response type for the Query/ChainsInfo - RPC method. - default: - description: An unexpected error response. - schema: - type: object - properties: - error: - type: string - code: - type: integer - format: int32 - message: - type: string - details: - type: array - items: - type: object - properties: - type_url: - type: string - description: >- - A URL/resource name that uniquely identifies the type of - the serialized - - protocol buffer message. This string must contain at - least - - one "/" character. The last segment of the URL's path - must represent - - the fully qualified name of the type (as in - - `path/google.protobuf.Duration`). The name should be in - a canonical form - - (e.g., leading "." is not accepted). + JSON - In practice, teams usually precompile into the binary - all types that they - - expect it to use in the context of Any. However, for - URLs which use the + The JSON representation of an `Any` value uses the regular - scheme `http`, `https`, or no scheme, one can optionally - set up a type + representation of the deserialized, embedded message, with an - server that maps type URLs to message definitions as - follows: + additional field `@type` which contains the type URL. Example: + package google.profile; + message Person { + string first_name = 1; + string last_name = 2; + } - * If no scheme is provided, `https` is assumed. + { + "@type": "type.googleapis.com/google.profile.Person", + "firstName": , + "lastName": + } - * An HTTP GET on the URL must yield a - [google.protobuf.Type][] - value in binary format, or produce an error. - * Applications are allowed to cache lookup results based - on the - URL, or have them precompiled into a binary to avoid any - lookup. Therefore, binary compatibility needs to be preserved - on changes to types. (Use versioned type names to manage - breaking changes.) + If the embedded message type is well-known and has a custom JSON - Note: this functionality is not currently available in - the official + representation, that representation will be embedded adding a field - protobuf release, and it is not used for type URLs - beginning with + `value` which holds the custom JSON in addition to the `@type` - type.googleapis.com. + field. Example (for message [google.protobuf.Duration][]): + { + "@type": "type.googleapis.com/google.protobuf.Duration", + "value": "1.212s" + } + babylon.btclightclient.v1.BTCHeaderInfoResponse: + type: object + properties: + header_hex: + type: string + hash_hex: + type: string + height: + type: integer + format: int64 + work: + type: string + description: Work is the sdkmath.Uint as string. + description: >- + BTCHeaderInfoResponse is a structure that contains all relevant + information about a - Schemes other than `http`, `https` (or the empty scheme) - might be + BTC header response + - Full header as string hex. + - Header hash for easy retrieval as string hex. + - Height of the header in the BTC chain. + - Total work spent on the header. This is the sum of the work corresponding + to the header Bits field + and the total work of the header. + babylon.btclightclient.v1.Params: + type: object + properties: + insert_headers_allow_list: + type: array + items: + type: string + title: >- + List of addresses which are allowed to insert headers to btc light + client - used with implementation specific semantics. - value: - type: string - format: byte - description: >- - Must be a valid serialized protocol buffer of the above - specified type. - description: >- - `Any` contains an arbitrary serialized protocol buffer - message along with a + if the list is empty, any address can insert headers + description: Params defines the parameters for the module. + babylon.btclightclient.v1.QueryBaseHeaderResponse: + type: object + properties: + header: + type: object + properties: + header_hex: + type: string + hash_hex: + type: string + height: + type: integer + format: int64 + work: + type: string + description: Work is the sdkmath.Uint as string. + description: >- + BTCHeaderInfoResponse is a structure that contains all relevant + information about a - URL that describes the type of the serialized message. + BTC header response + - Full header as string hex. + - Header hash for easy retrieval as string hex. + - Height of the header in the BTC chain. + - Total work spent on the header. This is the sum of the work corresponding + to the header Bits field + and the total work of the header. + description: |- + QueryBaseHeaderResponse is the response type for the Query/BaseHeader RPC + method. + babylon.btclightclient.v1.QueryContainsBytesResponse: + type: object + properties: + contains: + type: boolean + description: >- + QueryContainsResponse is response type for the temporary + Query/ContainsBytes + RPC method. + babylon.btclightclient.v1.QueryContainsResponse: + type: object + properties: + contains: + type: boolean + description: QueryContainsResponse is response type for the Query/Contains RPC method. + babylon.btclightclient.v1.QueryHashesResponse: + type: object + properties: + hashes: + type: array + items: + type: string + format: byte + pagination: + type: object + properties: + next_key: + type: string + format: byte + description: |- + next_key is the key to be passed to PageRequest.key to + query the next page most efficiently. It will be empty if + there are no more results. + total: + type: string + format: uint64 + title: >- + total is total number of results available if + PageRequest.count_total - Protobuf library provides support to pack/unpack Any values - in the form + was set, its value is undefined otherwise + description: |- + PageResponse is to be embedded in gRPC response messages where the + corresponding request message has used PageRequest. - of utility functions or additional generated methods of the - Any type. + message SomeResponse { + repeated Bar results = 1; + PageResponse page = 2; + } + description: QueryHashesResponse is response type for the Query/Hashes RPC method. + babylon.btclightclient.v1.QueryHeaderDepthResponse: + type: object + properties: + depth: + type: integer + format: int64 + title: >- + QueryMainChainDepthResponse is the response type for the + Query/MainChainDepth RPC + it contains depth of the block in main chain + babylon.btclightclient.v1.QueryMainChainResponse: + type: object + properties: + headers: + type: array + items: + type: object + properties: + header_hex: + type: string + hash_hex: + type: string + height: + type: integer + format: int64 + work: + type: string + description: Work is the sdkmath.Uint as string. + description: >- + BTCHeaderInfoResponse is a structure that contains all relevant + information about a - Example 1: Pack and unpack a message in C++. + BTC header response + - Full header as string hex. + - Header hash for easy retrieval as string hex. + - Height of the header in the BTC chain. + - Total work spent on the header. This is the sum of the work corresponding + to the header Bits field + and the total work of the header. + pagination: + type: object + properties: + next_key: + type: string + format: byte + description: |- + next_key is the key to be passed to PageRequest.key to + query the next page most efficiently. It will be empty if + there are no more results. + total: + type: string + format: uint64 + title: >- + total is total number of results available if + PageRequest.count_total - Foo foo = ...; - Any any; - any.PackFrom(foo); - ... - if (any.UnpackTo(&foo)) { - ... - } + was set, its value is undefined otherwise + description: |- + PageResponse is to be embedded in gRPC response messages where the + corresponding request message has used PageRequest. - Example 2: Pack and unpack a message in Java. - - Foo foo = ...; - Any any = Any.pack(foo); - ... - if (any.is(Foo.class)) { - foo = any.unpack(Foo.class); - } - // or ... - if (any.isSameTypeAs(Foo.getDefaultInstance())) { - foo = any.unpack(Foo.getDefaultInstance()); - } - - Example 3: Pack and unpack a message in Python. - - foo = Foo(...) - any = Any() - any.Pack(foo) - ... - if any.Is(Foo.DESCRIPTOR): - any.Unpack(foo) - ... - - Example 4: Pack and unpack a message in Go - - foo := &pb.Foo{...} - any, err := anypb.New(foo) - if err != nil { - ... - } - ... - foo := &pb.Foo{} - if err := any.UnmarshalTo(foo); err != nil { - ... - } - - The pack methods provided by protobuf library will by - default use - - 'type.googleapis.com/full.type.name' as the type URL and the - unpack - - methods only use the fully qualified type name after the - last '/' - - in the type URL, for example "foo.bar.com/x/y.z" will yield - type - - name "y.z". - - - JSON - - - The JSON representation of an `Any` value uses the regular - - representation of the deserialized, embedded message, with - an - - additional field `@type` which contains the type URL. - Example: - - package google.profile; - message Person { - string first_name = 1; - string last_name = 2; - } - - { - "@type": "type.googleapis.com/google.profile.Person", - "firstName": , - "lastName": - } - - If the embedded message type is well-known and has a custom - JSON - - representation, that representation will be embedded adding - a field - - `value` which holds the custom JSON in addition to the - `@type` - - field. Example (for message [google.protobuf.Duration][]): - - { - "@type": "type.googleapis.com/google.protobuf.Duration", - "value": "1.212s" - } - parameters: - - name: consumer_ids - in: query - required: false - type: array - items: - type: string - collectionFormat: multi - tags: - - Query - /babylon/zoneconcierge/v1/epoch_chains_info: - get: - summary: |- - EpochChainsInfo queries the latest info for a list of chains - in a given epoch in Babylon's view - operationId: EpochChainsInfo - responses: - '200': - description: A successful response. - schema: - type: object - properties: - chains_info: - type: array - items: - type: object - properties: - consumer_id: - type: string - title: consumer_id is the ID of the consumer - latest_header: - type: object - properties: - consumer_id: - type: string - title: consumer_id is the unique ID of the consumer - hash: - type: string - format: byte - title: hash is the hash of this header - height: - type: string - format: uint64 - title: >- - height is the height of this header on CZ ledger - - (hash, height) jointly provides the position of the - header on CZ ledger - time: - type: string - format: date-time - title: >- - time is the timestamp of this header on CZ ledger - - it is needed for CZ to unbond all mature - validators/delegations - - before this timestamp when this header is - BTC-finalised - babylon_header_hash: - type: string - format: byte - title: >- - babylon_header_hash is the hash of the babylon block - that includes this CZ - - header - babylon_header_height: - type: string - format: uint64 - title: >- - babylon_header_height is the height of the babylon - block that includes this CZ - - header - babylon_epoch: - type: string - format: uint64 - title: >- - epoch is the epoch number of this header on Babylon - ledger - babylon_tx_hash: - type: string - format: byte - title: >- - babylon_tx_hash is the hash of the tx that includes - this header - - (babylon_block_height, babylon_tx_hash) jointly - provides the position of - - the header on Babylon ledger - title: IndexedHeader is the metadata of a CZ header - latest_forks: - type: object - properties: - headers: - type: array - items: - type: object - properties: - consumer_id: - type: string - title: consumer_id is the unique ID of the consumer - hash: - type: string - format: byte - title: hash is the hash of this header - height: - type: string - format: uint64 - title: >- - height is the height of this header on CZ - ledger - - (hash, height) jointly provides the position - of the header on CZ ledger - time: - type: string - format: date-time - title: >- - time is the timestamp of this header on CZ - ledger - - it is needed for CZ to unbond all mature - validators/delegations - - before this timestamp when this header is - BTC-finalised - babylon_header_hash: - type: string - format: byte - title: >- - babylon_header_hash is the hash of the babylon - block that includes this CZ - - header - babylon_header_height: - type: string - format: uint64 - title: >- - babylon_header_height is the height of the - babylon block that includes this CZ - - header - babylon_epoch: - type: string - format: uint64 - title: >- - epoch is the epoch number of this header on - Babylon ledger - babylon_tx_hash: - type: string - format: byte - title: >- - babylon_tx_hash is the hash of the tx that - includes this header - - (babylon_block_height, babylon_tx_hash) - jointly provides the position of - - the header on Babylon ledger - title: IndexedHeader is the metadata of a CZ header - title: >- - blocks is the list of non-canonical indexed headers - at the same height - description: >- - Forks is a list of non-canonical `IndexedHeader`s at the - same height. - - For example, assuming the following blockchain - - ``` - - A <- B <- C <- D <- E - \ -- D1 - \ -- D2 - ``` - - Then the fork will be {[D1, D2]} where each item is in - struct `IndexedBlock`. - - - Note that each `IndexedHeader` in the fork should have a - valid quorum - - certificate. Such forks exist since Babylon considers - CZs might have - - dishonest majority. Also note that the IBC-Go - implementation will only - - consider the first header in a fork valid, since the - subsequent headers - - cannot be verified without knowing the validator set in - the previous header. - title: >- - latest_forks is the latest forks, formed as a series of - IndexedHeader (from - - low to high) - timestamped_headers_count: - type: string - format: uint64 - title: >- - timestamped_headers_count is the number of timestamped - headers in CZ's - - canonical chain - title: ChainInfo is the information of a CZ - title: chain_info is the info of the CZ - description: >- - QueryEpochChainsInfoResponse is response type for the - Query/EpochChainsInfo RPC - - method. - default: - description: An unexpected error response. - schema: - type: object - properties: - error: - type: string - code: - type: integer - format: int32 - message: - type: string - details: - type: array - items: - type: object - properties: - type_url: - type: string - description: >- - A URL/resource name that uniquely identifies the type of - the serialized - - protocol buffer message. This string must contain at - least - - one "/" character. The last segment of the URL's path - must represent - - the fully qualified name of the type (as in - - `path/google.protobuf.Duration`). The name should be in - a canonical form - - (e.g., leading "." is not accepted). - - - In practice, teams usually precompile into the binary - all types that they - - expect it to use in the context of Any. However, for - URLs which use the - - scheme `http`, `https`, or no scheme, one can optionally - set up a type - - server that maps type URLs to message definitions as - follows: - - - * If no scheme is provided, `https` is assumed. - - * An HTTP GET on the URL must yield a - [google.protobuf.Type][] - value in binary format, or produce an error. - * Applications are allowed to cache lookup results based - on the - URL, or have them precompiled into a binary to avoid any - lookup. Therefore, binary compatibility needs to be preserved - on changes to types. (Use versioned type names to manage - breaking changes.) - - Note: this functionality is not currently available in - the official - - protobuf release, and it is not used for type URLs - beginning with - - type.googleapis.com. - - - Schemes other than `http`, `https` (or the empty scheme) - might be - - used with implementation specific semantics. - value: - type: string - format: byte - description: >- - Must be a valid serialized protocol buffer of the above - specified type. - description: >- - `Any` contains an arbitrary serialized protocol buffer - message along with a - - URL that describes the type of the serialized message. - - - Protobuf library provides support to pack/unpack Any values - in the form - - of utility functions or additional generated methods of the - Any type. - - - Example 1: Pack and unpack a message in C++. - - Foo foo = ...; - Any any; - any.PackFrom(foo); - ... - if (any.UnpackTo(&foo)) { - ... - } - - Example 2: Pack and unpack a message in Java. - - Foo foo = ...; - Any any = Any.pack(foo); - ... - if (any.is(Foo.class)) { - foo = any.unpack(Foo.class); - } - // or ... - if (any.isSameTypeAs(Foo.getDefaultInstance())) { - foo = any.unpack(Foo.getDefaultInstance()); - } - - Example 3: Pack and unpack a message in Python. - - foo = Foo(...) - any = Any() - any.Pack(foo) - ... - if any.Is(Foo.DESCRIPTOR): - any.Unpack(foo) - ... - - Example 4: Pack and unpack a message in Go - - foo := &pb.Foo{...} - any, err := anypb.New(foo) - if err != nil { - ... - } - ... - foo := &pb.Foo{} - if err := any.UnmarshalTo(foo); err != nil { - ... - } - - The pack methods provided by protobuf library will by - default use - - 'type.googleapis.com/full.type.name' as the type URL and the - unpack - - methods only use the fully qualified type name after the - last '/' - - in the type URL, for example "foo.bar.com/x/y.z" will yield - type - - name "y.z". - - - JSON - - - The JSON representation of an `Any` value uses the regular - - representation of the deserialized, embedded message, with - an - - additional field `@type` which contains the type URL. - Example: - - package google.profile; - message Person { - string first_name = 1; - string last_name = 2; - } - - { - "@type": "type.googleapis.com/google.profile.Person", - "firstName": , - "lastName": - } - - If the embedded message type is well-known and has a custom - JSON - - representation, that representation will be embedded adding - a field - - `value` which holds the custom JSON in addition to the - `@type` - - field. Example (for message [google.protobuf.Duration][]): - - { - "@type": "type.googleapis.com/google.protobuf.Duration", - "value": "1.212s" - } - parameters: - - name: epoch_num - in: query - required: false - type: string - format: uint64 - - name: consumer_ids - in: query - required: false - type: array - items: - type: string - collectionFormat: multi - tags: - - Query - /babylon/zoneconcierge/v1/finalized_chain_info/{consumer_id}/height/{height}: - get: - summary: >- - FinalizedChainInfoUntilHeight queries the BTC-finalised info no later - than - - the provided CZ height, with proofs - operationId: FinalizedChainInfoUntilHeight - responses: - '200': - description: A successful response. - schema: - type: object - properties: - finalized_chain_info: - type: object - properties: - consumer_id: - type: string - title: consumer_id is the ID of the consumer - latest_header: - type: object - properties: - consumer_id: - type: string - title: consumer_id is the unique ID of the consumer - hash: - type: string - format: byte - title: hash is the hash of this header - height: - type: string - format: uint64 - title: >- - height is the height of this header on CZ ledger - - (hash, height) jointly provides the position of the - header on CZ ledger - time: - type: string - format: date-time - title: >- - time is the timestamp of this header on CZ ledger - - it is needed for CZ to unbond all mature - validators/delegations - - before this timestamp when this header is - BTC-finalised - babylon_header_hash: - type: string - format: byte - title: >- - babylon_header_hash is the hash of the babylon block - that includes this CZ - - header - babylon_header_height: - type: string - format: uint64 - title: >- - babylon_header_height is the height of the babylon - block that includes this CZ - - header - babylon_epoch: - type: string - format: uint64 - title: >- - epoch is the epoch number of this header on Babylon - ledger - babylon_tx_hash: - type: string - format: byte - title: >- - babylon_tx_hash is the hash of the tx that includes - this header - - (babylon_block_height, babylon_tx_hash) jointly - provides the position of - - the header on Babylon ledger - title: IndexedHeader is the metadata of a CZ header - latest_forks: - type: object - properties: - headers: - type: array - items: - type: object - properties: - consumer_id: - type: string - title: consumer_id is the unique ID of the consumer - hash: - type: string - format: byte - title: hash is the hash of this header - height: - type: string - format: uint64 - title: >- - height is the height of this header on CZ ledger - - (hash, height) jointly provides the position of - the header on CZ ledger - time: - type: string - format: date-time - title: >- - time is the timestamp of this header on CZ - ledger - - it is needed for CZ to unbond all mature - validators/delegations - - before this timestamp when this header is - BTC-finalised - babylon_header_hash: - type: string - format: byte - title: >- - babylon_header_hash is the hash of the babylon - block that includes this CZ - - header - babylon_header_height: - type: string - format: uint64 - title: >- - babylon_header_height is the height of the - babylon block that includes this CZ - - header - babylon_epoch: - type: string - format: uint64 - title: >- - epoch is the epoch number of this header on - Babylon ledger - babylon_tx_hash: - type: string - format: byte - title: >- - babylon_tx_hash is the hash of the tx that - includes this header - - (babylon_block_height, babylon_tx_hash) jointly - provides the position of - - the header on Babylon ledger - title: IndexedHeader is the metadata of a CZ header - title: >- - blocks is the list of non-canonical indexed headers at - the same height - description: >- - Forks is a list of non-canonical `IndexedHeader`s at the - same height. - - For example, assuming the following blockchain - - ``` - - A <- B <- C <- D <- E - \ -- D1 - \ -- D2 - ``` - - Then the fork will be {[D1, D2]} where each item is in - struct `IndexedBlock`. - - - Note that each `IndexedHeader` in the fork should have a - valid quorum - - certificate. Such forks exist since Babylon considers CZs - might have - - dishonest majority. Also note that the IBC-Go - implementation will only - - consider the first header in a fork valid, since the - subsequent headers - - cannot be verified without knowing the validator set in - the previous header. - title: >- - latest_forks is the latest forks, formed as a series of - IndexedHeader (from - - low to high) - timestamped_headers_count: - type: string - format: uint64 - title: >- - timestamped_headers_count is the number of timestamped - headers in CZ's - - canonical chain - title: ChainInfo is the information of a CZ - epoch_info: - title: epoch_info is the metadata of the last BTC-finalised epoch - type: object - properties: - epoch_number: - type: string - format: uint64 - title: epoch_number is the number of this epoch - current_epoch_interval: - type: string - format: uint64 - title: >- - current_epoch_interval is the epoch interval at the time - of this epoch - first_block_height: - type: string - format: uint64 - title: >- - first_block_height is the height of the first block in - this epoch - last_block_time: - type: string - format: date-time - description: >- - last_block_time is the time of the last block in this - epoch. - - Babylon needs to remember the last header's time of each - epoch to complete - - unbonding validators/delegations when a previous epoch's - checkpoint is - - finalised. The last_block_time field is nil in the epoch's - beginning, and - - is set upon the end of this epoch. - sealer_app_hash: - type: string - format: byte - title: >- - sealer is the last block of the sealed epoch - - sealer_app_hash points to the sealer but stored in the 1st - header - - of the next epoch - sealer_block_hash: - type: string - format: byte - title: >- - sealer_block_hash is the hash of the sealer - - the validator set has generated a BLS multisig on the - hash, - - i.e., hash of the last block in the epoch - raw_checkpoint: - title: raw_checkpoint is the raw checkpoint of this epoch - type: object - properties: - epoch_num: - type: string - format: uint64 - title: >- - epoch_num defines the epoch number the raw checkpoint is - for - block_hash: - type: string - format: byte - title: >- - block_hash defines the 'BlockID.Hash', which is the hash - of - - the block that individual BLS sigs are signed on - bitmap: - type: string - format: byte - title: >- - bitmap defines the bitmap that indicates the signers of - the BLS multi sig - bls_multi_sig: - type: string - format: byte - title: >- - bls_multi_sig defines the multi sig that is aggregated - from individual BLS - - sigs - btc_submission_key: - title: >- - btc_submission_key is position of two BTC txs that include the - raw - - checkpoint of this epoch - type: object - properties: - key: - type: array - items: - type: object - properties: - index: - type: integer - format: int64 - hash: - type: string - format: byte - title: >- - Each provided OP_RETURN transaction can be identified by - hash of block in - - which transaction was included and transaction index in - the block - proof: - title: proof is the proof that the chain info is finalized - type: object - properties: - proof_cz_header_in_epoch: - title: >- - proof_cz_header_in_epoch is the proof that the CZ header - is timestamped - - within a certain epoch - type: object - properties: - ops: - type: array - items: - type: object - properties: - type: - type: string - key: - type: string - format: byte - data: - type: string - format: byte - title: >- - ProofOp defines an operation used for calculating - Merkle root - - The data could be arbitrary format, providing - nessecary data - - for example neighbouring node hash - proof_epoch_sealed: - title: proof_epoch_sealed is the proof that the epoch is sealed - type: object - properties: - validator_set: - type: array - items: - type: object - properties: - validator_address: - type: string - title: >- - validator_address is the address of the - validator - bls_pub_key: - type: string - format: byte - title: >- - bls_pub_key is the BLS public key of the - validator - voting_power: - type: string - format: uint64 - title: >- - voting_power is the voting power of the - validator at the given epoch - title: >- - ValidatorWithBlsKey couples validator address, - voting power, and its bls - - public key - title: >- - validator_set is the validator set of the sealed epoch - - This validator set has generated a BLS multisig on - `app_hash` of - - the sealer header - proof_epoch_info: - title: >- - proof_epoch_info is the Merkle proof that the epoch's - metadata is committed - - to `app_hash` of the sealer header - type: object - properties: - ops: - type: array - items: - type: object - properties: - type: - type: string - key: - type: string - format: byte - data: - type: string - format: byte - title: >- - ProofOp defines an operation used for - calculating Merkle root - - The data could be arbitrary format, providing - nessecary data - - for example neighbouring node hash - proof_epoch_val_set: - title: >- - proof_epoch_info is the Merkle proof that the epoch's - validator set is - - committed to `app_hash` of the sealer header - type: object - properties: - ops: - type: array - items: - type: object - properties: - type: - type: string - key: - type: string - format: byte - data: - type: string - format: byte - title: >- - ProofOp defines an operation used for - calculating Merkle root - - The data could be arbitrary format, providing - nessecary data - - for example neighbouring node hash - proof_epoch_submitted: - type: array - items: - type: object - properties: - key: - type: object - properties: - index: - type: integer - format: int64 - hash: - type: string - format: byte - title: >- - Each provided OP_RETURN transaction can be - identified by hash of block in - - which transaction was included and transaction index - in the block - description: >- - key is the position (txIdx, blockHash) of this tx on - BTC blockchain - - Although it is already a part of SubmissionKey, we - store it here again - - to make TransactionInfo self-contained. - - For example, storing the key allows TransactionInfo - to not relay on - - the fact that TransactionInfo will be ordered in the - same order as - - TransactionKeys in SubmissionKey. - transaction: - type: string - format: byte - title: transaction is the full transaction in bytes - proof: - type: string - format: byte - title: >- - proof is the Merkle proof that this tx is included - in the position in `key` - - TODO: maybe it could use here better format as we - already processed and - - validated the proof? - title: |- - TransactionInfo is the info of a tx on Bitcoin, - including - - the position of the tx on BTC blockchain - - the full tx content - - the Merkle proof that this tx is on the above position - title: >- - proof_epoch_submitted is the proof that the epoch's - checkpoint is included - - in BTC ledger It is the two TransactionInfo in the best - (i.e., earliest) - - checkpoint submission - description: >- - QueryFinalizedChainInfoUntilHeightResponse is response type for - the - - Query/FinalizedChainInfoUntilHeight RPC method. - default: - description: An unexpected error response. - schema: - type: object - properties: - error: - type: string - code: - type: integer - format: int32 - message: - type: string - details: - type: array - items: - type: object - properties: - type_url: - type: string - description: >- - A URL/resource name that uniquely identifies the type of - the serialized - - protocol buffer message. This string must contain at - least - - one "/" character. The last segment of the URL's path - must represent - - the fully qualified name of the type (as in - - `path/google.protobuf.Duration`). The name should be in - a canonical form - - (e.g., leading "." is not accepted). - - - In practice, teams usually precompile into the binary - all types that they - - expect it to use in the context of Any. However, for - URLs which use the - - scheme `http`, `https`, or no scheme, one can optionally - set up a type - - server that maps type URLs to message definitions as - follows: - - - * If no scheme is provided, `https` is assumed. - - * An HTTP GET on the URL must yield a - [google.protobuf.Type][] - value in binary format, or produce an error. - * Applications are allowed to cache lookup results based - on the - URL, or have them precompiled into a binary to avoid any - lookup. Therefore, binary compatibility needs to be preserved - on changes to types. (Use versioned type names to manage - breaking changes.) - - Note: this functionality is not currently available in - the official - - protobuf release, and it is not used for type URLs - beginning with - - type.googleapis.com. - - - Schemes other than `http`, `https` (or the empty scheme) - might be - - used with implementation specific semantics. - value: - type: string - format: byte - description: >- - Must be a valid serialized protocol buffer of the above - specified type. - description: >- - `Any` contains an arbitrary serialized protocol buffer - message along with a - - URL that describes the type of the serialized message. - - - Protobuf library provides support to pack/unpack Any values - in the form - - of utility functions or additional generated methods of the - Any type. - - - Example 1: Pack and unpack a message in C++. - - Foo foo = ...; - Any any; - any.PackFrom(foo); - ... - if (any.UnpackTo(&foo)) { - ... - } - - Example 2: Pack and unpack a message in Java. - - Foo foo = ...; - Any any = Any.pack(foo); - ... - if (any.is(Foo.class)) { - foo = any.unpack(Foo.class); - } - // or ... - if (any.isSameTypeAs(Foo.getDefaultInstance())) { - foo = any.unpack(Foo.getDefaultInstance()); - } - - Example 3: Pack and unpack a message in Python. - - foo = Foo(...) - any = Any() - any.Pack(foo) - ... - if any.Is(Foo.DESCRIPTOR): - any.Unpack(foo) - ... - - Example 4: Pack and unpack a message in Go - - foo := &pb.Foo{...} - any, err := anypb.New(foo) - if err != nil { - ... - } - ... - foo := &pb.Foo{} - if err := any.UnmarshalTo(foo); err != nil { - ... - } - - The pack methods provided by protobuf library will by - default use - - 'type.googleapis.com/full.type.name' as the type URL and the - unpack - - methods only use the fully qualified type name after the - last '/' - - in the type URL, for example "foo.bar.com/x/y.z" will yield - type - - name "y.z". - - - JSON - - - The JSON representation of an `Any` value uses the regular - - representation of the deserialized, embedded message, with - an - - additional field `@type` which contains the type URL. - Example: - - package google.profile; - message Person { - string first_name = 1; - string last_name = 2; - } - - { - "@type": "type.googleapis.com/google.profile.Person", - "firstName": , - "lastName": - } - - If the embedded message type is well-known and has a custom - JSON - - representation, that representation will be embedded adding - a field - - `value` which holds the custom JSON in addition to the - `@type` - - field. Example (for message [google.protobuf.Duration][]): - - { - "@type": "type.googleapis.com/google.protobuf.Duration", - "value": "1.212s" - } - parameters: - - name: consumer_id - description: consumer_id is the ID of the CZ - in: path - required: true - type: string - - name: height - description: >- - height is the height of the CZ chain - - such that the returned finalised chain info will be no later than - this - - height - in: path - required: true - type: string - format: uint64 - - name: prove - description: >- - prove indicates whether the querier wants to get proofs of this - timestamp. - in: query - required: false - type: boolean - tags: - - Query - /babylon/zoneconcierge/v1/finalized_chains_info: - get: - summary: >- - FinalizedChainsInfo queries the BTC-finalised info of chains with given - IDs, with proofs - operationId: FinalizedChainsInfo - responses: - '200': - description: A successful response. - schema: - type: object - properties: - finalized_chains_info: - type: array - items: - type: object - properties: - consumer_id: - type: string - title: consumer_id is the ID of the consumer - finalized_chain_info: - type: object - properties: - consumer_id: - type: string - title: consumer_id is the ID of the consumer - latest_header: - type: object - properties: - consumer_id: - type: string - title: consumer_id is the unique ID of the consumer - hash: - type: string - format: byte - title: hash is the hash of this header - height: - type: string - format: uint64 - title: >- - height is the height of this header on CZ ledger - - (hash, height) jointly provides the position of - the header on CZ ledger - time: - type: string - format: date-time - title: >- - time is the timestamp of this header on CZ - ledger - - it is needed for CZ to unbond all mature - validators/delegations - - before this timestamp when this header is - BTC-finalised - babylon_header_hash: - type: string - format: byte - title: >- - babylon_header_hash is the hash of the babylon - block that includes this CZ - - header - babylon_header_height: - type: string - format: uint64 - title: >- - babylon_header_height is the height of the - babylon block that includes this CZ - - header - babylon_epoch: - type: string - format: uint64 - title: >- - epoch is the epoch number of this header on - Babylon ledger - babylon_tx_hash: - type: string - format: byte - title: >- - babylon_tx_hash is the hash of the tx that - includes this header - - (babylon_block_height, babylon_tx_hash) jointly - provides the position of - - the header on Babylon ledger - title: IndexedHeader is the metadata of a CZ header - latest_forks: - type: object - properties: - headers: - type: array - items: - type: object - properties: - consumer_id: - type: string - title: >- - consumer_id is the unique ID of the - consumer - hash: - type: string - format: byte - title: hash is the hash of this header - height: - type: string - format: uint64 - title: >- - height is the height of this header on CZ - ledger - - (hash, height) jointly provides the - position of the header on CZ ledger - time: - type: string - format: date-time - title: >- - time is the timestamp of this header on CZ - ledger - - it is needed for CZ to unbond all mature - validators/delegations - - before this timestamp when this header is - BTC-finalised - babylon_header_hash: - type: string - format: byte - title: >- - babylon_header_hash is the hash of the - babylon block that includes this CZ - - header - babylon_header_height: - type: string - format: uint64 - title: >- - babylon_header_height is the height of the - babylon block that includes this CZ - - header - babylon_epoch: - type: string - format: uint64 - title: >- - epoch is the epoch number of this header - on Babylon ledger - babylon_tx_hash: - type: string - format: byte - title: >- - babylon_tx_hash is the hash of the tx that - includes this header - - (babylon_block_height, babylon_tx_hash) - jointly provides the position of - - the header on Babylon ledger - title: IndexedHeader is the metadata of a CZ header - title: >- - blocks is the list of non-canonical indexed - headers at the same height - description: >- - Forks is a list of non-canonical `IndexedHeader`s at - the same height. - - For example, assuming the following blockchain - - ``` - - A <- B <- C <- D <- E - \ -- D1 - \ -- D2 - ``` - - Then the fork will be {[D1, D2]} where each item is - in struct `IndexedBlock`. - - - Note that each `IndexedHeader` in the fork should - have a valid quorum - - certificate. Such forks exist since Babylon - considers CZs might have - - dishonest majority. Also note that the IBC-Go - implementation will only - - consider the first header in a fork valid, since the - subsequent headers - - cannot be verified without knowing the validator set - in the previous header. - title: >- - latest_forks is the latest forks, formed as a series - of IndexedHeader (from - - low to high) - timestamped_headers_count: - type: string - format: uint64 - title: >- - timestamped_headers_count is the number of - timestamped headers in CZ's - - canonical chain - title: ChainInfo is the information of a CZ - epoch_info: - title: >- - epoch_info is the metadata of the last BTC-finalised - epoch - type: object - properties: - epoch_number: - type: string - format: uint64 - title: epoch_number is the number of this epoch - current_epoch_interval: - type: string - format: uint64 - title: >- - current_epoch_interval is the epoch interval at the - time of this epoch - first_block_height: - type: string - format: uint64 - title: >- - first_block_height is the height of the first block - in this epoch - last_block_time: - type: string - format: date-time - description: >- - last_block_time is the time of the last block in - this epoch. - - Babylon needs to remember the last header's time of - each epoch to complete - - unbonding validators/delegations when a previous - epoch's checkpoint is - - finalised. The last_block_time field is nil in the - epoch's beginning, and - - is set upon the end of this epoch. - sealer_app_hash: - type: string - format: byte - title: >- - sealer is the last block of the sealed epoch - - sealer_app_hash points to the sealer but stored in - the 1st header - - of the next epoch - sealer_block_hash: - type: string - format: byte - title: >- - sealer_block_hash is the hash of the sealer - - the validator set has generated a BLS multisig on - the hash, - - i.e., hash of the last block in the epoch - raw_checkpoint: - title: raw_checkpoint is the raw checkpoint of this epoch - type: object - properties: - epoch_num: - type: string - format: uint64 - title: >- - epoch_num defines the epoch number the raw - checkpoint is for - block_hash: - type: string - format: byte - title: >- - block_hash defines the 'BlockID.Hash', which is the - hash of - - the block that individual BLS sigs are signed on - bitmap: - type: string - format: byte - title: >- - bitmap defines the bitmap that indicates the signers - of the BLS multi sig - bls_multi_sig: - type: string - format: byte - title: >- - bls_multi_sig defines the multi sig that is - aggregated from individual BLS - - sigs - btc_submission_key: - title: >- - btc_submission_key is position of two BTC txs that - include the raw - - checkpoint of this epoch - type: object - properties: - key: - type: array - items: - type: object - properties: - index: - type: integer - format: int64 - hash: - type: string - format: byte - title: >- - Each provided OP_RETURN transaction can be - identified by hash of block in - - which transaction was included and transaction - index in the block - proof: - title: proof is the proof that the chain info is finalized - type: object - properties: - proof_cz_header_in_epoch: - title: >- - proof_cz_header_in_epoch is the proof that the CZ - header is timestamped - - within a certain epoch - type: object - properties: - ops: - type: array - items: - type: object - properties: - type: - type: string - key: - type: string - format: byte - data: - type: string - format: byte - title: >- - ProofOp defines an operation used for - calculating Merkle root - - The data could be arbitrary format, providing - nessecary data - - for example neighbouring node hash - proof_epoch_sealed: - title: >- - proof_epoch_sealed is the proof that the epoch is - sealed - type: object - properties: - validator_set: - type: array - items: - type: object - properties: - validator_address: - type: string - title: >- - validator_address is the address of the - validator - bls_pub_key: - type: string - format: byte - title: >- - bls_pub_key is the BLS public key of the - validator - voting_power: - type: string - format: uint64 - title: >- - voting_power is the voting power of the - validator at the given epoch - title: >- - ValidatorWithBlsKey couples validator address, - voting power, and its bls - - public key - title: >- - validator_set is the validator set of the sealed - epoch - - This validator set has generated a BLS multisig - on `app_hash` of - - the sealer header - proof_epoch_info: - title: >- - proof_epoch_info is the Merkle proof that the - epoch's metadata is committed - - to `app_hash` of the sealer header - type: object - properties: - ops: - type: array - items: - type: object - properties: - type: - type: string - key: - type: string - format: byte - data: - type: string - format: byte - title: >- - ProofOp defines an operation used for - calculating Merkle root - - The data could be arbitrary format, - providing nessecary data - - for example neighbouring node hash - proof_epoch_val_set: - title: >- - proof_epoch_info is the Merkle proof that the - epoch's validator set is - - committed to `app_hash` of the sealer header - type: object - properties: - ops: - type: array - items: - type: object - properties: - type: - type: string - key: - type: string - format: byte - data: - type: string - format: byte - title: >- - ProofOp defines an operation used for - calculating Merkle root - - The data could be arbitrary format, - providing nessecary data - - for example neighbouring node hash - proof_epoch_submitted: - type: array - items: - type: object - properties: - key: - type: object - properties: - index: - type: integer - format: int64 - hash: - type: string - format: byte - title: >- - Each provided OP_RETURN transaction can be - identified by hash of block in - - which transaction was included and transaction - index in the block - description: >- - key is the position (txIdx, blockHash) of this - tx on BTC blockchain - - Although it is already a part of - SubmissionKey, we store it here again - - to make TransactionInfo self-contained. - - For example, storing the key allows - TransactionInfo to not relay on - - the fact that TransactionInfo will be ordered - in the same order as - - TransactionKeys in SubmissionKey. - transaction: - type: string - format: byte - title: transaction is the full transaction in bytes - proof: - type: string - format: byte - title: >- - proof is the Merkle proof that this tx is - included in the position in `key` - - TODO: maybe it could use here better format as - we already processed and - - validated the proof? - title: >- - TransactionInfo is the info of a tx on Bitcoin, - - including - - - the position of the tx on BTC blockchain - - - the full tx content - - - the Merkle proof that this tx is on the above - position - title: >- - proof_epoch_submitted is the proof that the epoch's - checkpoint is included - - in BTC ledger It is the two TransactionInfo in the - best (i.e., earliest) - - checkpoint submission - title: >- - FinalizedChainInfo is the information of a CZ that is - BTC-finalised - description: |- - QueryFinalizedChainsInfoResponse is response type for the - Query/FinalizedChainsInfo RPC method. - default: - description: An unexpected error response. - schema: - type: object - properties: - error: - type: string - code: - type: integer - format: int32 - message: - type: string - details: - type: array - items: - type: object - properties: - type_url: - type: string - description: >- - A URL/resource name that uniquely identifies the type of - the serialized - - protocol buffer message. This string must contain at - least - - one "/" character. The last segment of the URL's path - must represent - - the fully qualified name of the type (as in - - `path/google.protobuf.Duration`). The name should be in - a canonical form - - (e.g., leading "." is not accepted). - - - In practice, teams usually precompile into the binary - all types that they - - expect it to use in the context of Any. However, for - URLs which use the - - scheme `http`, `https`, or no scheme, one can optionally - set up a type - - server that maps type URLs to message definitions as - follows: - - - * If no scheme is provided, `https` is assumed. - - * An HTTP GET on the URL must yield a - [google.protobuf.Type][] - value in binary format, or produce an error. - * Applications are allowed to cache lookup results based - on the - URL, or have them precompiled into a binary to avoid any - lookup. Therefore, binary compatibility needs to be preserved - on changes to types. (Use versioned type names to manage - breaking changes.) - - Note: this functionality is not currently available in - the official - - protobuf release, and it is not used for type URLs - beginning with - - type.googleapis.com. - - - Schemes other than `http`, `https` (or the empty scheme) - might be - - used with implementation specific semantics. - value: - type: string - format: byte - description: >- - Must be a valid serialized protocol buffer of the above - specified type. - description: >- - `Any` contains an arbitrary serialized protocol buffer - message along with a - - URL that describes the type of the serialized message. - - - Protobuf library provides support to pack/unpack Any values - in the form - - of utility functions or additional generated methods of the - Any type. - - - Example 1: Pack and unpack a message in C++. - - Foo foo = ...; - Any any; - any.PackFrom(foo); - ... - if (any.UnpackTo(&foo)) { - ... - } - - Example 2: Pack and unpack a message in Java. - - Foo foo = ...; - Any any = Any.pack(foo); - ... - if (any.is(Foo.class)) { - foo = any.unpack(Foo.class); - } - // or ... - if (any.isSameTypeAs(Foo.getDefaultInstance())) { - foo = any.unpack(Foo.getDefaultInstance()); - } - - Example 3: Pack and unpack a message in Python. - - foo = Foo(...) - any = Any() - any.Pack(foo) - ... - if any.Is(Foo.DESCRIPTOR): - any.Unpack(foo) - ... - - Example 4: Pack and unpack a message in Go - - foo := &pb.Foo{...} - any, err := anypb.New(foo) - if err != nil { - ... - } - ... - foo := &pb.Foo{} - if err := any.UnmarshalTo(foo); err != nil { - ... - } - - The pack methods provided by protobuf library will by - default use - - 'type.googleapis.com/full.type.name' as the type URL and the - unpack - - methods only use the fully qualified type name after the - last '/' - - in the type URL, for example "foo.bar.com/x/y.z" will yield - type - - name "y.z". - - - JSON - - - The JSON representation of an `Any` value uses the regular - - representation of the deserialized, embedded message, with - an - - additional field `@type` which contains the type URL. - Example: - - package google.profile; - message Person { - string first_name = 1; - string last_name = 2; - } - - { - "@type": "type.googleapis.com/google.profile.Person", - "firstName": , - "lastName": - } - - If the embedded message type is well-known and has a custom - JSON - - representation, that representation will be embedded adding - a field - - `value` which holds the custom JSON in addition to the - `@type` - - field. Example (for message [google.protobuf.Duration][]): - - { - "@type": "type.googleapis.com/google.protobuf.Duration", - "value": "1.212s" - } - parameters: - - name: consumer_ids - description: consumer_ids is the list of ids of CZs. - in: query - required: false - type: array - items: - type: string - collectionFormat: multi - - name: prove - description: >- - prove indicates whether the querier wants to get proofs of this - timestamp. - in: query - required: false - type: boolean - tags: - - Query - /babylon/zoneconcierge/v1/headers/{consumer_id}: - get: - summary: |- - ListHeaders queries the headers of a chain in Babylon's view, with - pagination support - operationId: ListHeaders - responses: - '200': - description: A successful response. - schema: - type: object - properties: - headers: - type: array - items: - type: object - properties: - consumer_id: - type: string - title: consumer_id is the unique ID of the consumer - hash: - type: string - format: byte - title: hash is the hash of this header - height: - type: string - format: uint64 - title: >- - height is the height of this header on CZ ledger - - (hash, height) jointly provides the position of the - header on CZ ledger - time: - type: string - format: date-time - title: >- - time is the timestamp of this header on CZ ledger - - it is needed for CZ to unbond all mature - validators/delegations - - before this timestamp when this header is BTC-finalised - babylon_header_hash: - type: string - format: byte - title: >- - babylon_header_hash is the hash of the babylon block - that includes this CZ - - header - babylon_header_height: - type: string - format: uint64 - title: >- - babylon_header_height is the height of the babylon block - that includes this CZ - - header - babylon_epoch: - type: string - format: uint64 - title: >- - epoch is the epoch number of this header on Babylon - ledger - babylon_tx_hash: - type: string - format: byte - title: >- - babylon_tx_hash is the hash of the tx that includes this - header - - (babylon_block_height, babylon_tx_hash) jointly provides - the position of - - the header on Babylon ledger - title: IndexedHeader is the metadata of a CZ header - title: headers is the list of headers - pagination: - title: pagination defines the pagination in the response - type: object - properties: - next_key: - type: string - format: byte - description: |- - next_key is the key to be passed to PageRequest.key to - query the next page most efficiently. It will be empty if - there are no more results. - total: - type: string - format: uint64 - title: >- - total is total number of results available if - PageRequest.count_total - - was set, its value is undefined otherwise - description: >- - PageResponse is to be embedded in gRPC response messages where - the - - corresponding request message has used PageRequest. - - message SomeResponse { - repeated Bar results = 1; - PageResponse page = 2; - } - description: >- - QueryListHeadersResponse is response type for the - Query/ListHeaders RPC - - method. - default: - description: An unexpected error response. - schema: - type: object - properties: - error: - type: string - code: - type: integer - format: int32 - message: - type: string - details: - type: array - items: - type: object - properties: - type_url: - type: string - description: >- - A URL/resource name that uniquely identifies the type of - the serialized - - protocol buffer message. This string must contain at - least - - one "/" character. The last segment of the URL's path - must represent - - the fully qualified name of the type (as in - - `path/google.protobuf.Duration`). The name should be in - a canonical form - - (e.g., leading "." is not accepted). - - - In practice, teams usually precompile into the binary - all types that they - - expect it to use in the context of Any. However, for - URLs which use the - - scheme `http`, `https`, or no scheme, one can optionally - set up a type - - server that maps type URLs to message definitions as - follows: - - - * If no scheme is provided, `https` is assumed. - - * An HTTP GET on the URL must yield a - [google.protobuf.Type][] - value in binary format, or produce an error. - * Applications are allowed to cache lookup results based - on the - URL, or have them precompiled into a binary to avoid any - lookup. Therefore, binary compatibility needs to be preserved - on changes to types. (Use versioned type names to manage - breaking changes.) - - Note: this functionality is not currently available in - the official - - protobuf release, and it is not used for type URLs - beginning with - - type.googleapis.com. - - - Schemes other than `http`, `https` (or the empty scheme) - might be - - used with implementation specific semantics. - value: - type: string - format: byte - description: >- - Must be a valid serialized protocol buffer of the above - specified type. - description: >- - `Any` contains an arbitrary serialized protocol buffer - message along with a - - URL that describes the type of the serialized message. - - - Protobuf library provides support to pack/unpack Any values - in the form - - of utility functions or additional generated methods of the - Any type. - - - Example 1: Pack and unpack a message in C++. - - Foo foo = ...; - Any any; - any.PackFrom(foo); - ... - if (any.UnpackTo(&foo)) { - ... - } - - Example 2: Pack and unpack a message in Java. - - Foo foo = ...; - Any any = Any.pack(foo); - ... - if (any.is(Foo.class)) { - foo = any.unpack(Foo.class); - } - // or ... - if (any.isSameTypeAs(Foo.getDefaultInstance())) { - foo = any.unpack(Foo.getDefaultInstance()); - } - - Example 3: Pack and unpack a message in Python. - - foo = Foo(...) - any = Any() - any.Pack(foo) - ... - if any.Is(Foo.DESCRIPTOR): - any.Unpack(foo) - ... - - Example 4: Pack and unpack a message in Go - - foo := &pb.Foo{...} - any, err := anypb.New(foo) - if err != nil { - ... - } - ... - foo := &pb.Foo{} - if err := any.UnmarshalTo(foo); err != nil { - ... - } - - The pack methods provided by protobuf library will by - default use - - 'type.googleapis.com/full.type.name' as the type URL and the - unpack - - methods only use the fully qualified type name after the - last '/' - - in the type URL, for example "foo.bar.com/x/y.z" will yield - type - - name "y.z". - - - JSON - - - The JSON representation of an `Any` value uses the regular - - representation of the deserialized, embedded message, with - an - - additional field `@type` which contains the type URL. - Example: - - package google.profile; - message Person { - string first_name = 1; - string last_name = 2; - } - - { - "@type": "type.googleapis.com/google.profile.Person", - "firstName": , - "lastName": - } - - If the embedded message type is well-known and has a custom - JSON - - representation, that representation will be embedded adding - a field - - `value` which holds the custom JSON in addition to the - `@type` - - field. Example (for message [google.protobuf.Duration][]): - - { - "@type": "type.googleapis.com/google.protobuf.Duration", - "value": "1.212s" - } - parameters: - - name: consumer_id - in: path - required: true - type: string - - name: pagination.key - description: |- - key is a value returned in PageResponse.next_key to begin - querying the next page most efficiently. Only one of offset or key - should be set. - in: query - required: false - type: string - format: byte - - name: pagination.offset - description: >- - offset is a numeric offset that can be used when key is unavailable. - - It is less efficient than using key. Only one of offset or key - should - - be set. - in: query - required: false - type: string - format: uint64 - - name: pagination.limit - description: >- - limit is the total number of results to be returned in the result - page. - - If left empty it will default to a value to be set by each app. - in: query - required: false - type: string - format: uint64 - - name: pagination.count_total - description: >- - count_total is set to true to indicate that the result set should - include - - a count of the total number of items available for pagination in - UIs. - - count_total is only respected when offset is used. It is ignored - when key - - is set. - in: query - required: false - type: boolean - - name: pagination.reverse - description: >- - reverse is set to true if results are to be returned in the - descending order. - - - Since: cosmos-sdk 0.43 - in: query - required: false - type: boolean - tags: - - Query - /babylon/zoneconcierge/v1/headers/{consumer_id}/epochs/{epoch_num}: - get: - summary: |- - ListEpochHeaders queries the headers of a chain timestamped in a given - epoch of Babylon, with pagination support - operationId: ListEpochHeaders - responses: - '200': - description: A successful response. - schema: - type: object - properties: - headers: - type: array - items: - type: object - properties: - consumer_id: - type: string - title: consumer_id is the unique ID of the consumer - hash: - type: string - format: byte - title: hash is the hash of this header - height: - type: string - format: uint64 - title: >- - height is the height of this header on CZ ledger - - (hash, height) jointly provides the position of the - header on CZ ledger - time: - type: string - format: date-time - title: >- - time is the timestamp of this header on CZ ledger - - it is needed for CZ to unbond all mature - validators/delegations - - before this timestamp when this header is BTC-finalised - babylon_header_hash: - type: string - format: byte - title: >- - babylon_header_hash is the hash of the babylon block - that includes this CZ - - header - babylon_header_height: - type: string - format: uint64 - title: >- - babylon_header_height is the height of the babylon block - that includes this CZ - - header - babylon_epoch: - type: string - format: uint64 - title: >- - epoch is the epoch number of this header on Babylon - ledger - babylon_tx_hash: - type: string - format: byte - title: >- - babylon_tx_hash is the hash of the tx that includes this - header - - (babylon_block_height, babylon_tx_hash) jointly provides - the position of - - the header on Babylon ledger - title: IndexedHeader is the metadata of a CZ header - title: headers is the list of headers - description: >- - QueryListEpochHeadersResponse is response type for the - Query/ListEpochHeaders - - RPC method. - default: - description: An unexpected error response. - schema: - type: object - properties: - error: - type: string - code: - type: integer - format: int32 - message: - type: string - details: - type: array - items: - type: object - properties: - type_url: - type: string - description: >- - A URL/resource name that uniquely identifies the type of - the serialized - - protocol buffer message. This string must contain at - least - - one "/" character. The last segment of the URL's path - must represent - - the fully qualified name of the type (as in - - `path/google.protobuf.Duration`). The name should be in - a canonical form - - (e.g., leading "." is not accepted). - - - In practice, teams usually precompile into the binary - all types that they - - expect it to use in the context of Any. However, for - URLs which use the - - scheme `http`, `https`, or no scheme, one can optionally - set up a type - - server that maps type URLs to message definitions as - follows: - - - * If no scheme is provided, `https` is assumed. - - * An HTTP GET on the URL must yield a - [google.protobuf.Type][] - value in binary format, or produce an error. - * Applications are allowed to cache lookup results based - on the - URL, or have them precompiled into a binary to avoid any - lookup. Therefore, binary compatibility needs to be preserved - on changes to types. (Use versioned type names to manage - breaking changes.) - - Note: this functionality is not currently available in - the official - - protobuf release, and it is not used for type URLs - beginning with - - type.googleapis.com. - - - Schemes other than `http`, `https` (or the empty scheme) - might be - - used with implementation specific semantics. - value: - type: string - format: byte - description: >- - Must be a valid serialized protocol buffer of the above - specified type. - description: >- - `Any` contains an arbitrary serialized protocol buffer - message along with a - - URL that describes the type of the serialized message. - - - Protobuf library provides support to pack/unpack Any values - in the form - - of utility functions or additional generated methods of the - Any type. - - - Example 1: Pack and unpack a message in C++. - - Foo foo = ...; - Any any; - any.PackFrom(foo); - ... - if (any.UnpackTo(&foo)) { - ... - } - - Example 2: Pack and unpack a message in Java. - - Foo foo = ...; - Any any = Any.pack(foo); - ... - if (any.is(Foo.class)) { - foo = any.unpack(Foo.class); - } - // or ... - if (any.isSameTypeAs(Foo.getDefaultInstance())) { - foo = any.unpack(Foo.getDefaultInstance()); - } - - Example 3: Pack and unpack a message in Python. - - foo = Foo(...) - any = Any() - any.Pack(foo) - ... - if any.Is(Foo.DESCRIPTOR): - any.Unpack(foo) - ... - - Example 4: Pack and unpack a message in Go - - foo := &pb.Foo{...} - any, err := anypb.New(foo) - if err != nil { - ... - } - ... - foo := &pb.Foo{} - if err := any.UnmarshalTo(foo); err != nil { - ... - } - - The pack methods provided by protobuf library will by - default use - - 'type.googleapis.com/full.type.name' as the type URL and the - unpack - - methods only use the fully qualified type name after the - last '/' - - in the type URL, for example "foo.bar.com/x/y.z" will yield - type - - name "y.z". - - - JSON - - - The JSON representation of an `Any` value uses the regular - - representation of the deserialized, embedded message, with - an - - additional field `@type` which contains the type URL. - Example: - - package google.profile; - message Person { - string first_name = 1; - string last_name = 2; - } - - { - "@type": "type.googleapis.com/google.profile.Person", - "firstName": , - "lastName": - } - - If the embedded message type is well-known and has a custom - JSON - - representation, that representation will be embedded adding - a field - - `value` which holds the custom JSON in addition to the - `@type` - - field. Example (for message [google.protobuf.Duration][]): - - { - "@type": "type.googleapis.com/google.protobuf.Duration", - "value": "1.212s" - } - parameters: - - name: consumer_id - in: path - required: true - type: string - - name: epoch_num - in: path - required: true - type: string - format: uint64 - tags: - - Query - /babylon/zoneconcierge/v1/params: - get: - summary: Params queries the parameters of the module. - operationId: ZoneConciergeParams - responses: - '200': - description: A successful response. - schema: - type: object - properties: - params: - description: params holds all the parameters of this module. - type: object - properties: - ibc_packet_timeout_seconds: - type: integer - format: int64 - title: >- - ibc_packet_timeout_seconds is the time period after which - an unrelayed - - IBC packet becomes timeout, measured in seconds - description: >- - QueryParamsResponse is the response type for the Query/Params RPC - method. - default: - description: An unexpected error response. - schema: - type: object - properties: - error: - type: string - code: - type: integer - format: int32 - message: - type: string - details: - type: array - items: - type: object - properties: - type_url: - type: string - description: >- - A URL/resource name that uniquely identifies the type of - the serialized - - protocol buffer message. This string must contain at - least - - one "/" character. The last segment of the URL's path - must represent - - the fully qualified name of the type (as in - - `path/google.protobuf.Duration`). The name should be in - a canonical form - - (e.g., leading "." is not accepted). - - - In practice, teams usually precompile into the binary - all types that they - - expect it to use in the context of Any. However, for - URLs which use the - - scheme `http`, `https`, or no scheme, one can optionally - set up a type - - server that maps type URLs to message definitions as - follows: - - - * If no scheme is provided, `https` is assumed. - - * An HTTP GET on the URL must yield a - [google.protobuf.Type][] - value in binary format, or produce an error. - * Applications are allowed to cache lookup results based - on the - URL, or have them precompiled into a binary to avoid any - lookup. Therefore, binary compatibility needs to be preserved - on changes to types. (Use versioned type names to manage - breaking changes.) - - Note: this functionality is not currently available in - the official - - protobuf release, and it is not used for type URLs - beginning with - - type.googleapis.com. - - - Schemes other than `http`, `https` (or the empty scheme) - might be - - used with implementation specific semantics. - value: - type: string - format: byte - description: >- - Must be a valid serialized protocol buffer of the above - specified type. - description: >- - `Any` contains an arbitrary serialized protocol buffer - message along with a - - URL that describes the type of the serialized message. - - - Protobuf library provides support to pack/unpack Any values - in the form - - of utility functions or additional generated methods of the - Any type. - - - Example 1: Pack and unpack a message in C++. - - Foo foo = ...; - Any any; - any.PackFrom(foo); - ... - if (any.UnpackTo(&foo)) { - ... - } - - Example 2: Pack and unpack a message in Java. - - Foo foo = ...; - Any any = Any.pack(foo); - ... - if (any.is(Foo.class)) { - foo = any.unpack(Foo.class); - } - // or ... - if (any.isSameTypeAs(Foo.getDefaultInstance())) { - foo = any.unpack(Foo.getDefaultInstance()); - } - - Example 3: Pack and unpack a message in Python. - - foo = Foo(...) - any = Any() - any.Pack(foo) - ... - if any.Is(Foo.DESCRIPTOR): - any.Unpack(foo) - ... - - Example 4: Pack and unpack a message in Go - - foo := &pb.Foo{...} - any, err := anypb.New(foo) - if err != nil { - ... - } - ... - foo := &pb.Foo{} - if err := any.UnmarshalTo(foo); err != nil { - ... - } - - The pack methods provided by protobuf library will by - default use - - 'type.googleapis.com/full.type.name' as the type URL and the - unpack - - methods only use the fully qualified type name after the - last '/' - - in the type URL, for example "foo.bar.com/x/y.z" will yield - type - - name "y.z". - - - JSON - - - The JSON representation of an `Any` value uses the regular - - representation of the deserialized, embedded message, with - an - - additional field `@type` which contains the type URL. - Example: - - package google.profile; - message Person { - string first_name = 1; - string last_name = 2; - } - - { - "@type": "type.googleapis.com/google.profile.Person", - "firstName": , - "lastName": - } - - If the embedded message type is well-known and has a custom - JSON - - representation, that representation will be embedded adding - a field - - `value` which holds the custom JSON in addition to the - `@type` - - field. Example (for message [google.protobuf.Duration][]): - - { - "@type": "type.googleapis.com/google.protobuf.Duration", - "value": "1.212s" - } - tags: - - Query -definitions: - babylon.btccheckpoint.v1.BTCCheckpointInfoResponse: - type: object - properties: - epoch_number: - type: string - format: uint64 - description: EpochNumber of this checkpoint. - best_submission_btc_block_height: - type: string - format: uint64 - title: btc height of the best submission of the epoch - best_submission_btc_block_hash: - type: string - title: >- - hash of the btc block which determines checkpoint btc block height - i.e. - - youngest block of best submission Hexadecimal - best_submission_transactions: - type: array - items: - type: object - properties: - index: - type: integer - format: int64 - description: Index Bitcoin Transaction index in block. - hash: - type: string - description: Hash BTC Header hash as hex. - transaction: - type: string - description: transaction is the full transaction data as str hex. - proof: - type: string - title: >- - proof is the Merkle proof that this tx is included in the - position in `key` - title: |- - TransactionInfoResponse is the info of a tx on Bitcoin, - including - - the position of the tx on BTC blockchain - - the full tx content - - the Merkle proof that this tx is on the above position - title: the BTC checkpoint transactions of the best submission - best_submission_vigilante_address_list: - type: array - items: - type: object - properties: - submitter: - type: string - description: >- - submitter is the address of the checkpoint submitter to BTC, - extracted from - - the checkpoint itself. - reporter: - type: string - title: >- - reporter is the address of the reporter who reported the - submissions, - - calculated from submission message MsgInsertBTCSpvProof itself - title: >- - CheckpointAddressesResponse contains the addresses of the submitter - and reporter of a - - given checkpoint - title: list of vigilantes' addresses of the best submission - description: >- - BTCCheckpointInfoResponse contains all data about best submission of - checkpoint for - - given epoch. Best submission is the submission which is deeper in btc - ledger. - babylon.btccheckpoint.v1.CheckpointAddressesResponse: - type: object - properties: - submitter: - type: string - description: >- - submitter is the address of the checkpoint submitter to BTC, extracted - from - - the checkpoint itself. - reporter: - type: string - title: |- - reporter is the address of the reporter who reported the submissions, - calculated from submission message MsgInsertBTCSpvProof itself - title: >- - CheckpointAddressesResponse contains the addresses of the submitter and - reporter of a - - given checkpoint - babylon.btccheckpoint.v1.Params: - type: object - properties: - btc_confirmation_depth: - type: string - format: uint64 - title: >- - btc_confirmation_depth is the confirmation depth in BTC. - - A block is considered irreversible only when it is at least k-deep in - BTC - - (k in research paper) - checkpoint_finalization_timeout: - type: string - format: uint64 - title: >- - checkpoint_finalization_timeout is the maximum time window (measured - in BTC - - blocks) between a checkpoint - - - being submitted to BTC, and - - - being reported back to BBN - - If a checkpoint has not been reported back within w BTC blocks, then - BBN - - has dishonest majority and is stalling checkpoints (w in research - paper) - checkpoint_tag: - type: string - title: >- - 4byte tag in hex format, required to be present in the OP_RETURN - transaction - - related to babylon - description: Params defines the parameters for the module. - babylon.btccheckpoint.v1.QueryBtcCheckpointInfoResponse: - type: object - properties: - info: - type: object - properties: - epoch_number: - type: string - format: uint64 - description: EpochNumber of this checkpoint. - best_submission_btc_block_height: - type: string - format: uint64 - title: btc height of the best submission of the epoch - best_submission_btc_block_hash: - type: string - title: >- - hash of the btc block which determines checkpoint btc block height - i.e. - - youngest block of best submission Hexadecimal - best_submission_transactions: - type: array - items: - type: object - properties: - index: - type: integer - format: int64 - description: Index Bitcoin Transaction index in block. - hash: - type: string - description: Hash BTC Header hash as hex. - transaction: - type: string - description: transaction is the full transaction data as str hex. - proof: - type: string - title: >- - proof is the Merkle proof that this tx is included in the - position in `key` - title: |- - TransactionInfoResponse is the info of a tx on Bitcoin, - including - - the position of the tx on BTC blockchain - - the full tx content - - the Merkle proof that this tx is on the above position - title: the BTC checkpoint transactions of the best submission - best_submission_vigilante_address_list: - type: array - items: - type: object - properties: - submitter: - type: string - description: >- - submitter is the address of the checkpoint submitter to BTC, - extracted from - - the checkpoint itself. - reporter: - type: string - title: >- - reporter is the address of the reporter who reported the - submissions, - - calculated from submission message MsgInsertBTCSpvProof - itself - title: >- - CheckpointAddressesResponse contains the addresses of the - submitter and reporter of a - - given checkpoint - title: list of vigilantes' addresses of the best submission - description: >- - BTCCheckpointInfoResponse contains all data about best submission of - checkpoint for - - given epoch. Best submission is the submission which is deeper in btc - ledger. - title: |- - QueryBtcCheckpointInfoResponse is response type for the - Query/BtcCheckpointInfo RPC method - babylon.btccheckpoint.v1.QueryBtcCheckpointsInfoResponse: - type: object - properties: - info_list: - type: array - items: - type: object - properties: - epoch_number: - type: string - format: uint64 - description: EpochNumber of this checkpoint. - best_submission_btc_block_height: - type: string - format: uint64 - title: btc height of the best submission of the epoch - best_submission_btc_block_hash: - type: string - title: >- - hash of the btc block which determines checkpoint btc block - height i.e. - - youngest block of best submission Hexadecimal - best_submission_transactions: - type: array - items: - type: object - properties: - index: - type: integer - format: int64 - description: Index Bitcoin Transaction index in block. - hash: - type: string - description: Hash BTC Header hash as hex. - transaction: - type: string - description: transaction is the full transaction data as str hex. - proof: - type: string - title: >- - proof is the Merkle proof that this tx is included in the - position in `key` - title: |- - TransactionInfoResponse is the info of a tx on Bitcoin, - including - - the position of the tx on BTC blockchain - - the full tx content - - the Merkle proof that this tx is on the above position - title: the BTC checkpoint transactions of the best submission - best_submission_vigilante_address_list: - type: array - items: - type: object - properties: - submitter: - type: string - description: >- - submitter is the address of the checkpoint submitter to - BTC, extracted from - - the checkpoint itself. - reporter: - type: string - title: >- - reporter is the address of the reporter who reported the - submissions, - - calculated from submission message MsgInsertBTCSpvProof - itself - title: >- - CheckpointAddressesResponse contains the addresses of the - submitter and reporter of a - - given checkpoint - title: list of vigilantes' addresses of the best submission - description: >- - BTCCheckpointInfoResponse contains all data about best submission of - checkpoint for - - given epoch. Best submission is the submission which is deeper in - btc ledger. - pagination: - title: pagination defines the pagination in the response - type: object - properties: - next_key: - type: string - format: byte - description: |- - next_key is the key to be passed to PageRequest.key to - query the next page most efficiently. It will be empty if - there are no more results. - total: - type: string - format: uint64 - title: >- - total is total number of results available if - PageRequest.count_total - - was set, its value is undefined otherwise - description: |- - PageResponse is to be embedded in gRPC response messages where the - corresponding request message has used PageRequest. - - message SomeResponse { - repeated Bar results = 1; - PageResponse page = 2; - } - title: |- - QueryBtcCheckpointsInfoResponse is response type for the - Query/BtcCheckpointsInfo RPC method - babylon.btccheckpoint.v1.QueryEpochSubmissionsResponse: - type: object - properties: - keys: - type: array - items: - type: object - properties: - first_tx_block_hash: - type: string - description: FirstTxBlockHash is the BTCHeaderHashBytes in hex. - first_tx_index: - type: integer - format: int64 - second_tx_block_hash: - type: string - description: SecondBlockHash is the BTCHeaderHashBytes in hex. - second_tx_index: - type: integer - format: int64 - title: >- - SubmissionKeyResponse Checkpoint can be composed from multiple - transactions, - - so to identify whole submission we need list of transaction keys. - - Each submission can generally be identified by this list of (txIdx, - - blockHash) tuples. Note: this could possibly be optimized as if - transactions - - were in one block they would have the same block hash and different - indexes, - - but each blockhash is only 33 (1 byte for prefix encoding and 32 - byte hash), - - so there should be other strong arguments for this optimization - description: Keys All submissions transactions key saved during an epoch. - title: |- - QueryEpochSubmissionsResponse defines a response to get all submissions in - given epoch (QueryEpochSubmissionsRequest) - babylon.btccheckpoint.v1.QueryParamsResponse: - type: object - properties: - params: - description: params holds all the parameters of this module. - type: object - properties: - btc_confirmation_depth: - type: string - format: uint64 - title: >- - btc_confirmation_depth is the confirmation depth in BTC. - - A block is considered irreversible only when it is at least k-deep - in BTC - - (k in research paper) - checkpoint_finalization_timeout: - type: string - format: uint64 - title: >- - checkpoint_finalization_timeout is the maximum time window - (measured in BTC - - blocks) between a checkpoint - - - being submitted to BTC, and - - - being reported back to BBN - - If a checkpoint has not been reported back within w BTC blocks, - then BBN - - has dishonest majority and is stalling checkpoints (w in research - paper) - checkpoint_tag: - type: string - title: >- - 4byte tag in hex format, required to be present in the OP_RETURN - transaction - - related to babylon - description: QueryParamsResponse is response type for the Query/Params RPC method. - babylon.btccheckpoint.v1.SubmissionKeyResponse: - type: object - properties: - first_tx_block_hash: - type: string - description: FirstTxBlockHash is the BTCHeaderHashBytes in hex. - first_tx_index: - type: integer - format: int64 - second_tx_block_hash: - type: string - description: SecondBlockHash is the BTCHeaderHashBytes in hex. - second_tx_index: - type: integer - format: int64 - title: >- - SubmissionKeyResponse Checkpoint can be composed from multiple - transactions, - - so to identify whole submission we need list of transaction keys. - - Each submission can generally be identified by this list of (txIdx, - - blockHash) tuples. Note: this could possibly be optimized as if - transactions - - were in one block they would have the same block hash and different - indexes, - - but each blockhash is only 33 (1 byte for prefix encoding and 32 byte - hash), - - so there should be other strong arguments for this optimization - babylon.btccheckpoint.v1.TransactionInfoResponse: - type: object - properties: - index: - type: integer - format: int64 - description: Index Bitcoin Transaction index in block. - hash: - type: string - description: Hash BTC Header hash as hex. - transaction: - type: string - description: transaction is the full transaction data as str hex. - proof: - type: string - title: >- - proof is the Merkle proof that this tx is included in the position in - `key` - title: |- - TransactionInfoResponse is the info of a tx on Bitcoin, - including - - the position of the tx on BTC blockchain - - the full tx content - - the Merkle proof that this tx is on the above position - cosmos.base.query.v1beta1.PageRequest: - type: object - properties: - key: - type: string - format: byte - description: |- - key is a value returned in PageResponse.next_key to begin - querying the next page most efficiently. Only one of offset or key - should be set. - offset: - type: string - format: uint64 - description: |- - offset is a numeric offset that can be used when key is unavailable. - It is less efficient than using key. Only one of offset or key should - be set. - limit: - type: string - format: uint64 - description: >- - limit is the total number of results to be returned in the result - page. - - If left empty it will default to a value to be set by each app. - count_total: - type: boolean - description: >- - count_total is set to true to indicate that the result set should - include - - a count of the total number of items available for pagination in UIs. - - count_total is only respected when offset is used. It is ignored when - key - - is set. - reverse: - type: boolean - description: >- - reverse is set to true if results are to be returned in the descending - order. - - - Since: cosmos-sdk 0.43 - description: |- - message SomeRequest { - Foo some_parameter = 1; - PageRequest pagination = 2; - } - title: |- - PageRequest is to be embedded in gRPC request messages for efficient - pagination. Ex: - cosmos.base.query.v1beta1.PageResponse: - type: object - properties: - next_key: - type: string - format: byte - description: |- - next_key is the key to be passed to PageRequest.key to - query the next page most efficiently. It will be empty if - there are no more results. - total: - type: string - format: uint64 - title: |- - total is total number of results available if PageRequest.count_total - was set, its value is undefined otherwise - description: |- - PageResponse is to be embedded in gRPC response messages where the - corresponding request message has used PageRequest. - - message SomeResponse { - repeated Bar results = 1; - PageResponse page = 2; - } - google.protobuf.Any: - type: object - properties: - type_url: - type: string - description: >- - A URL/resource name that uniquely identifies the type of the - serialized - - protocol buffer message. This string must contain at least - - one "/" character. The last segment of the URL's path must represent - - the fully qualified name of the type (as in - - `path/google.protobuf.Duration`). The name should be in a canonical - form - - (e.g., leading "." is not accepted). - - - In practice, teams usually precompile into the binary all types that - they - - expect it to use in the context of Any. However, for URLs which use - the - - scheme `http`, `https`, or no scheme, one can optionally set up a type - - server that maps type URLs to message definitions as follows: - - - * If no scheme is provided, `https` is assumed. - - * An HTTP GET on the URL must yield a [google.protobuf.Type][] - value in binary format, or produce an error. - * Applications are allowed to cache lookup results based on the - URL, or have them precompiled into a binary to avoid any - lookup. Therefore, binary compatibility needs to be preserved - on changes to types. (Use versioned type names to manage - breaking changes.) - - Note: this functionality is not currently available in the official - - protobuf release, and it is not used for type URLs beginning with - - type.googleapis.com. - - - Schemes other than `http`, `https` (or the empty scheme) might be - - used with implementation specific semantics. - value: - type: string - format: byte - description: >- - Must be a valid serialized protocol buffer of the above specified - type. - description: >- - `Any` contains an arbitrary serialized protocol buffer message along with - a - - URL that describes the type of the serialized message. - - - Protobuf library provides support to pack/unpack Any values in the form - - of utility functions or additional generated methods of the Any type. - - - Example 1: Pack and unpack a message in C++. - - Foo foo = ...; - Any any; - any.PackFrom(foo); - ... - if (any.UnpackTo(&foo)) { - ... - } - - Example 2: Pack and unpack a message in Java. - - Foo foo = ...; - Any any = Any.pack(foo); - ... - if (any.is(Foo.class)) { - foo = any.unpack(Foo.class); - } - // or ... - if (any.isSameTypeAs(Foo.getDefaultInstance())) { - foo = any.unpack(Foo.getDefaultInstance()); - } - - Example 3: Pack and unpack a message in Python. - - foo = Foo(...) - any = Any() - any.Pack(foo) - ... - if any.Is(Foo.DESCRIPTOR): - any.Unpack(foo) - ... - - Example 4: Pack and unpack a message in Go - - foo := &pb.Foo{...} - any, err := anypb.New(foo) - if err != nil { - ... - } - ... - foo := &pb.Foo{} - if err := any.UnmarshalTo(foo); err != nil { - ... - } - - The pack methods provided by protobuf library will by default use - - 'type.googleapis.com/full.type.name' as the type URL and the unpack - - methods only use the fully qualified type name after the last '/' - - in the type URL, for example "foo.bar.com/x/y.z" will yield type - - name "y.z". - - - JSON - - - The JSON representation of an `Any` value uses the regular - - representation of the deserialized, embedded message, with an - - additional field `@type` which contains the type URL. Example: - - package google.profile; - message Person { - string first_name = 1; - string last_name = 2; - } - - { - "@type": "type.googleapis.com/google.profile.Person", - "firstName": , - "lastName": - } - - If the embedded message type is well-known and has a custom JSON - - representation, that representation will be embedded adding a field - - `value` which holds the custom JSON in addition to the `@type` - - field. Example (for message [google.protobuf.Duration][]): - - { - "@type": "type.googleapis.com/google.protobuf.Duration", - "value": "1.212s" - } - grpc.gateway.runtime.Error: - type: object - properties: - error: - type: string - code: - type: integer - format: int32 - message: - type: string - details: - type: array - items: - type: object - properties: - type_url: - type: string - description: >- - A URL/resource name that uniquely identifies the type of the - serialized - - protocol buffer message. This string must contain at least - - one "/" character. The last segment of the URL's path must - represent - - the fully qualified name of the type (as in - - `path/google.protobuf.Duration`). The name should be in a - canonical form - - (e.g., leading "." is not accepted). - - - In practice, teams usually precompile into the binary all types - that they - - expect it to use in the context of Any. However, for URLs which - use the - - scheme `http`, `https`, or no scheme, one can optionally set up - a type - - server that maps type URLs to message definitions as follows: - - - * If no scheme is provided, `https` is assumed. - - * An HTTP GET on the URL must yield a [google.protobuf.Type][] - value in binary format, or produce an error. - * Applications are allowed to cache lookup results based on the - URL, or have them precompiled into a binary to avoid any - lookup. Therefore, binary compatibility needs to be preserved - on changes to types. (Use versioned type names to manage - breaking changes.) - - Note: this functionality is not currently available in the - official - - protobuf release, and it is not used for type URLs beginning - with - - type.googleapis.com. - - - Schemes other than `http`, `https` (or the empty scheme) might - be - - used with implementation specific semantics. - value: - type: string - format: byte - description: >- - Must be a valid serialized protocol buffer of the above - specified type. - description: >- - `Any` contains an arbitrary serialized protocol buffer message along - with a - - URL that describes the type of the serialized message. - - - Protobuf library provides support to pack/unpack Any values in the - form - - of utility functions or additional generated methods of the Any - type. - - - Example 1: Pack and unpack a message in C++. - - Foo foo = ...; - Any any; - any.PackFrom(foo); - ... - if (any.UnpackTo(&foo)) { - ... - } - - Example 2: Pack and unpack a message in Java. - - Foo foo = ...; - Any any = Any.pack(foo); - ... - if (any.is(Foo.class)) { - foo = any.unpack(Foo.class); - } - // or ... - if (any.isSameTypeAs(Foo.getDefaultInstance())) { - foo = any.unpack(Foo.getDefaultInstance()); - } - - Example 3: Pack and unpack a message in Python. - - foo = Foo(...) - any = Any() - any.Pack(foo) - ... - if any.Is(Foo.DESCRIPTOR): - any.Unpack(foo) - ... - - Example 4: Pack and unpack a message in Go - - foo := &pb.Foo{...} - any, err := anypb.New(foo) - if err != nil { - ... - } - ... - foo := &pb.Foo{} - if err := any.UnmarshalTo(foo); err != nil { - ... - } - - The pack methods provided by protobuf library will by default use - - 'type.googleapis.com/full.type.name' as the type URL and the unpack - - methods only use the fully qualified type name after the last '/' - - in the type URL, for example "foo.bar.com/x/y.z" will yield type - - name "y.z". - - - JSON - - - The JSON representation of an `Any` value uses the regular - - representation of the deserialized, embedded message, with an - - additional field `@type` which contains the type URL. Example: - - package google.profile; - message Person { - string first_name = 1; - string last_name = 2; - } - - { - "@type": "type.googleapis.com/google.profile.Person", - "firstName": , - "lastName": - } - - If the embedded message type is well-known and has a custom JSON - - representation, that representation will be embedded adding a field - - `value` which holds the custom JSON in addition to the `@type` - - field. Example (for message [google.protobuf.Duration][]): - - { - "@type": "type.googleapis.com/google.protobuf.Duration", - "value": "1.212s" - } - babylon.btclightclient.v1.BTCHeaderInfoResponse: - type: object - properties: - header_hex: - type: string - hash_hex: - type: string - height: - type: string - format: uint64 - work: - type: string - description: Work is the sdkmath.Uint as string. - description: >- - BTCHeaderInfoResponse is a structure that contains all relevant - information about a - - BTC header response - - Full header as string hex. - - Header hash for easy retrieval as string hex. - - Height of the header in the BTC chain. - - Total work spent on the header. This is the sum of the work corresponding - to the header Bits field - and the total work of the header. - babylon.btclightclient.v1.Params: - type: object - properties: - insert_headers_allow_list: - type: array - items: - type: string - title: >- - List of addresses which are allowed to insert headers to btc light - client - - if the list is empty, any address can insert headers - description: Params defines the parameters for the module. - babylon.btclightclient.v1.QueryBaseHeaderResponse: - type: object - properties: - header: - type: object - properties: - header_hex: - type: string - hash_hex: - type: string - height: - type: string - format: uint64 - work: - type: string - description: Work is the sdkmath.Uint as string. - description: >- - BTCHeaderInfoResponse is a structure that contains all relevant - information about a - - BTC header response - - Full header as string hex. - - Header hash for easy retrieval as string hex. - - Height of the header in the BTC chain. - - Total work spent on the header. This is the sum of the work corresponding - to the header Bits field - and the total work of the header. - description: |- - QueryBaseHeaderResponse is the response type for the Query/BaseHeader RPC - method. - babylon.btclightclient.v1.QueryContainsBytesResponse: - type: object - properties: - contains: - type: boolean - description: >- - QueryContainsResponse is response type for the temporary - Query/ContainsBytes - - RPC method. - babylon.btclightclient.v1.QueryContainsResponse: - type: object - properties: - contains: - type: boolean - description: QueryContainsResponse is response type for the Query/Contains RPC method. - babylon.btclightclient.v1.QueryHashesResponse: - type: object - properties: - hashes: - type: array - items: - type: string - format: byte - pagination: - type: object - properties: - next_key: - type: string - format: byte - description: |- - next_key is the key to be passed to PageRequest.key to - query the next page most efficiently. It will be empty if - there are no more results. - total: - type: string - format: uint64 - title: >- - total is total number of results available if - PageRequest.count_total - - was set, its value is undefined otherwise - description: |- - PageResponse is to be embedded in gRPC response messages where the - corresponding request message has used PageRequest. - - message SomeResponse { - repeated Bar results = 1; - PageResponse page = 2; - } - description: QueryHashesResponse is response type for the Query/Hashes RPC method. - babylon.btclightclient.v1.QueryHeaderDepthResponse: - type: object - properties: - depth: - type: string - format: uint64 - title: >- - QueryMainChainDepthResponse is the response type for the - Query/MainChainDepth RPC - - it contains depth of the block in main chain - babylon.btclightclient.v1.QueryMainChainResponse: - type: object - properties: - headers: - type: array - items: - type: object - properties: - header_hex: - type: string - hash_hex: - type: string - height: - type: string - format: uint64 - work: - type: string - description: Work is the sdkmath.Uint as string. - description: >- - BTCHeaderInfoResponse is a structure that contains all relevant - information about a - - BTC header response - - Full header as string hex. - - Header hash for easy retrieval as string hex. - - Height of the header in the BTC chain. - - Total work spent on the header. This is the sum of the work corresponding - to the header Bits field - and the total work of the header. - pagination: - type: object - properties: - next_key: - type: string - format: byte - description: |- - next_key is the key to be passed to PageRequest.key to - query the next page most efficiently. It will be empty if - there are no more results. - total: - type: string - format: uint64 - title: >- - total is total number of results available if - PageRequest.count_total - - was set, its value is undefined otherwise - description: |- - PageResponse is to be embedded in gRPC response messages where the - corresponding request message has used PageRequest. - - message SomeResponse { - repeated Bar results = 1; - PageResponse page = 2; - } - description: >- - QueryMainChainResponse is response type for the Query/MainChain RPC - method. - babylon.btclightclient.v1.QueryParamsResponse: - type: object - properties: - params: - description: params holds all the parameters of this module. - type: object - properties: - insert_headers_allow_list: - type: array - items: - type: string - title: >- - List of addresses which are allowed to insert headers to btc light - client - - if the list is empty, any address can insert headers - description: QueryParamsResponse is the response type for the Query/Params RPC method. - babylon.btclightclient.v1.QueryTipResponse: - type: object - properties: - header: - type: object - properties: - header_hex: - type: string - hash_hex: - type: string - height: - type: string - format: uint64 - work: - type: string - description: Work is the sdkmath.Uint as string. - description: >- - BTCHeaderInfoResponse is a structure that contains all relevant - information about a - - BTC header response - - Full header as string hex. - - Header hash for easy retrieval as string hex. - - Height of the header in the BTC chain. - - Total work spent on the header. This is the sum of the work corresponding - to the header Bits field - and the total work of the header. - description: QueryTipResponse is the response type for the Query/Tip RPC method. - babylon.epoching.v1.BondState: - type: string - enum: - - CREATED - - BONDED - - UNBONDING - - UNBONDED - - REMOVED - default: CREATED - description: |- - - CREATED: CREATED is when the validator/delegation has been created - - BONDED: CREATED is when the validator/delegation has become bonded - - UNBONDING: CREATED is when the validator/delegation has become unbonding - - UNBONDED: CREATED is when the validator/delegation has become unbonded - - REMOVED: CREATED is when the validator/delegation has been removed - title: BondState is the bond state of a validator or delegation - babylon.epoching.v1.DelegationLifecycle: - type: object - properties: - del_addr: - type: string - del_life: - type: array - items: - type: object - properties: - state: - type: string - enum: - - CREATED - - BONDED - - UNBONDING - - UNBONDED - - REMOVED - default: CREATED - description: >- - - CREATED: CREATED is when the validator/delegation has been - created - - BONDED: CREATED is when the validator/delegation has become bonded - - UNBONDING: CREATED is when the validator/delegation has become unbonding - - UNBONDED: CREATED is when the validator/delegation has become unbonded - - REMOVED: CREATED is when the validator/delegation has been removed - title: BondState is the bond state of a validator or delegation - val_addr: - type: string - amount: - type: object - properties: - denom: - type: string - amount: - type: string - description: >- - Coin defines a token with a denomination and an amount. - - - NOTE: The amount field is an Int which implements the custom - method - - signatures required by gogoproto. - block_height: - type: string - format: uint64 - block_time: - type: string - format: date-time - title: >- - DelegationStateUpdate is the message that records a state update of - a - - delegation - title: |- - ValidatorLifecycle is a message that records the lifecycle of - a delegation - babylon.epoching.v1.DelegationStateUpdate: - type: object - properties: - state: - type: string - enum: - - CREATED - - BONDED - - UNBONDING - - UNBONDED - - REMOVED - default: CREATED - description: |- - - CREATED: CREATED is when the validator/delegation has been created - - BONDED: CREATED is when the validator/delegation has become bonded - - UNBONDING: CREATED is when the validator/delegation has become unbonding - - UNBONDED: CREATED is when the validator/delegation has become unbonded - - REMOVED: CREATED is when the validator/delegation has been removed - title: BondState is the bond state of a validator or delegation - val_addr: - type: string - amount: - type: object - properties: - denom: - type: string - amount: - type: string - description: |- - Coin defines a token with a denomination and an amount. - - NOTE: The amount field is an Int which implements the custom method - signatures required by gogoproto. - block_height: - type: string - format: uint64 - block_time: - type: string - format: date-time - title: |- - DelegationStateUpdate is the message that records a state update of a - delegation - babylon.epoching.v1.EpochResponse: - type: object - properties: - epoch_number: - type: string - format: uint64 - title: epoch_number is the number of this epoch - current_epoch_interval: - type: string - format: uint64 - title: current_epoch_interval is the epoch interval at the time of this epoch - first_block_height: - type: string - format: uint64 - title: first_block_height is the height of the first block in this epoch - last_block_time: - type: string - format: date-time - description: >- - last_block_time is the time of the last block in this epoch. - - Babylon needs to remember the last header's time of each epoch to - complete - - unbonding validators/delegations when a previous epoch's checkpoint is - - finalised. The last_block_time field is nil in the epoch's beginning, - and - - is set upon the end of this epoch. - sealer_app_hash_hex: - type: string - description: |- - sealer is the last block of the sealed epoch - sealer_app_hash points to the sealer but stored in the 1st header - of the next epoch as hex string. - sealer_block_hash: - type: string - description: |- - sealer_block_hash is the hash of the sealer - the validator set has generated a BLS multisig on the hash, - i.e., hash of the last block in the epoch as hex string. - title: EpochResponse is a structure that contains the metadata of an epoch - babylon.epoching.v1.Params: - type: object - properties: - epoch_interval: - type: string - format: uint64 - title: epoch_interval is the number of consecutive blocks to form an epoch - description: Params defines the parameters for the module. - babylon.epoching.v1.QueryCurrentEpochResponse: - type: object - properties: - current_epoch: - type: string - format: uint64 - title: current_epoch is the current epoch number - epoch_boundary: - type: string - format: uint64 - title: epoch_boundary is the height of this epoch's last block - title: >- - QueryCurrentEpochResponse is the response type for the Query/CurrentEpoch - RPC - - method - babylon.epoching.v1.QueryDelegationLifecycleResponse: - type: object - properties: - del_life: - type: object - properties: - del_addr: - type: string - del_life: - type: array - items: - type: object - properties: - state: - type: string - enum: - - CREATED - - BONDED - - UNBONDING - - UNBONDED - - REMOVED - default: CREATED - description: >- - - CREATED: CREATED is when the validator/delegation has been - created - - BONDED: CREATED is when the validator/delegation has become bonded - - UNBONDING: CREATED is when the validator/delegation has become unbonding - - UNBONDED: CREATED is when the validator/delegation has become unbonded - - REMOVED: CREATED is when the validator/delegation has been removed - title: BondState is the bond state of a validator or delegation - val_addr: - type: string - amount: - type: object - properties: - denom: - type: string - amount: - type: string - description: >- - Coin defines a token with a denomination and an amount. - - - NOTE: The amount field is an Int which implements the custom - method - - signatures required by gogoproto. - block_height: - type: string - format: uint64 - block_time: - type: string - format: date-time - title: >- - DelegationStateUpdate is the message that records a state update - of a - - delegation - title: |- - ValidatorLifecycle is a message that records the lifecycle of - a delegation - title: |- - QueryDelegationLifecycleRequest is the response type for the - Query/DelegationLifecycle RPC method - babylon.epoching.v1.QueryEpochInfoResponse: - type: object - properties: - epoch: - type: object - properties: - epoch_number: - type: string - format: uint64 - title: epoch_number is the number of this epoch - current_epoch_interval: - type: string - format: uint64 - title: >- - current_epoch_interval is the epoch interval at the time of this - epoch - first_block_height: - type: string - format: uint64 - title: first_block_height is the height of the first block in this epoch - last_block_time: - type: string - format: date-time - description: >- - last_block_time is the time of the last block in this epoch. - - Babylon needs to remember the last header's time of each epoch to - complete - - unbonding validators/delegations when a previous epoch's - checkpoint is - - finalised. The last_block_time field is nil in the epoch's - beginning, and - - is set upon the end of this epoch. - sealer_app_hash_hex: - type: string - description: |- - sealer is the last block of the sealed epoch - sealer_app_hash points to the sealer but stored in the 1st header - of the next epoch as hex string. - sealer_block_hash: - type: string - description: |- - sealer_block_hash is the hash of the sealer - the validator set has generated a BLS multisig on the hash, - i.e., hash of the last block in the epoch as hex string. - title: EpochResponse is a structure that contains the metadata of an epoch - title: QueryEpochInfoRequest is the response type for the Query/EpochInfo method - babylon.epoching.v1.QueryEpochMsgsResponse: - type: object - properties: - msgs: - type: array - items: - type: object - properties: - tx_id: - type: string - description: tx_id is the ID of the tx that contains the message as hex. - msg_id: - type: string - description: >- - msg_id is the original message ID, i.e., hash of the marshaled - message as hex. - block_height: - type: string - format: uint64 - title: block_height is the height when this msg is submitted to Babylon - block_time: - type: string - format: date-time - title: >- - block_time is the timestamp when this msg is submitted to - Babylon - msg: - type: string - description: >- - msg is the actual message that is sent by a user and is queued - by the - - epoching module as string. - title: >- - QueuedMessageResponse is a message that can change the validator set - and is delayed - - to the end of an epoch - title: msgs is the list of messages queued in the current epoch - pagination: - title: pagination defines the pagination in the response - type: object - properties: - next_key: - type: string - format: byte - description: |- - next_key is the key to be passed to PageRequest.key to - query the next page most efficiently. It will be empty if - there are no more results. - total: - type: string - format: uint64 - title: >- - total is total number of results available if - PageRequest.count_total - - was set, its value is undefined otherwise - description: |- - PageResponse is to be embedded in gRPC response messages where the - corresponding request message has used PageRequest. - - message SomeResponse { - repeated Bar results = 1; - PageResponse page = 2; - } - title: |- - QueryEpochMsgsResponse is the response type for the Query/EpochMsgs RPC - method - babylon.epoching.v1.QueryEpochValSetResponse: - type: object - properties: - validators: - type: array - items: - type: object - properties: - addr: - type: string - format: byte - title: addr is the validator's address (in sdk.ValAddress) - power: - type: string - format: int64 - title: power is the validator's voting power - title: Validator is a message that denotes a validator - total_voting_power: - type: string - format: int64 - pagination: - type: object - properties: - next_key: - type: string - format: byte - description: |- - next_key is the key to be passed to PageRequest.key to - query the next page most efficiently. It will be empty if - there are no more results. - total: - type: string - format: uint64 - title: >- - total is total number of results available if - PageRequest.count_total - - was set, its value is undefined otherwise - description: |- - PageResponse is to be embedded in gRPC response messages where the - corresponding request message has used PageRequest. - - message SomeResponse { - repeated Bar results = 1; - PageResponse page = 2; - } - title: |- - QueryEpochValSetRequest is the response type for the Query/EpochValSet RPC - method - babylon.epoching.v1.QueryEpochsInfoResponse: - type: object - properties: - epochs: - type: array - items: - type: object - properties: - epoch_number: - type: string - format: uint64 - title: epoch_number is the number of this epoch - current_epoch_interval: - type: string - format: uint64 - title: >- - current_epoch_interval is the epoch interval at the time of this - epoch - first_block_height: - type: string - format: uint64 - title: >- - first_block_height is the height of the first block in this - epoch - last_block_time: - type: string - format: date-time - description: >- - last_block_time is the time of the last block in this epoch. - - Babylon needs to remember the last header's time of each epoch - to complete - - unbonding validators/delegations when a previous epoch's - checkpoint is - - finalised. The last_block_time field is nil in the epoch's - beginning, and - - is set upon the end of this epoch. - sealer_app_hash_hex: - type: string - description: >- - sealer is the last block of the sealed epoch - - sealer_app_hash points to the sealer but stored in the 1st - header - - of the next epoch as hex string. - sealer_block_hash: - type: string - description: |- - sealer_block_hash is the hash of the sealer - the validator set has generated a BLS multisig on the hash, - i.e., hash of the last block in the epoch as hex string. - title: EpochResponse is a structure that contains the metadata of an epoch - pagination: - title: pagination defines the pagination in the response - type: object - properties: - next_key: - type: string - format: byte - description: |- - next_key is the key to be passed to PageRequest.key to - query the next page most efficiently. It will be empty if - there are no more results. - total: - type: string - format: uint64 - title: >- - total is total number of results available if - PageRequest.count_total - - was set, its value is undefined otherwise - description: |- - PageResponse is to be embedded in gRPC response messages where the - corresponding request message has used PageRequest. - - message SomeResponse { - repeated Bar results = 1; - PageResponse page = 2; - } - title: >- - QueryEpochsInfoResponse is the response type for the Query/EpochInfos - method - babylon.epoching.v1.QueryLatestEpochMsgsResponse: - type: object - properties: - latest_epoch_msgs: - type: array - items: - type: object - properties: - epoch_number: - type: string - format: uint64 - msgs: - type: array - items: - type: object - properties: - tx_id: - type: string - description: >- - tx_id is the ID of the tx that contains the message as - hex. - msg_id: - type: string - description: >- - msg_id is the original message ID, i.e., hash of the - marshaled message as hex. - block_height: - type: string - format: uint64 - title: >- - block_height is the height when this msg is submitted to - Babylon - block_time: - type: string - format: date-time - title: >- - block_time is the timestamp when this msg is submitted to - Babylon - msg: - type: string - description: >- - msg is the actual message that is sent by a user and is - queued by the - - epoching module as string. - title: >- - QueuedMessageResponse is a message that can change the - validator set and is delayed - - to the end of an epoch - title: >- - QueuedMessageList is a message that contains a list of - staking-related - - messages queued for an epoch - title: |- - latest_epoch_msgs is a list of QueuedMessageList - each QueuedMessageList has a field identifying the epoch number - pagination: - type: object - properties: - next_key: - type: string - format: byte - description: |- - next_key is the key to be passed to PageRequest.key to - query the next page most efficiently. It will be empty if - there are no more results. - total: - type: string - format: uint64 - title: >- - total is total number of results available if - PageRequest.count_total - - was set, its value is undefined otherwise - description: |- - PageResponse is to be embedded in gRPC response messages where the - corresponding request message has used PageRequest. - - message SomeResponse { - repeated Bar results = 1; - PageResponse page = 2; - } - title: |- - QueryLatestEpochMsgsResponse is the response type for the - Query/LatestEpochMsgs RPC method - babylon.epoching.v1.QueryParamsResponse: - type: object - properties: - params: - description: params holds all the parameters of this module. - type: object - properties: - epoch_interval: - type: string - format: uint64 - title: >- - epoch_interval is the number of consecutive blocks to form an - epoch - description: QueryParamsResponse is the response type for the Query/Params RPC method. - babylon.epoching.v1.QueryValidatorLifecycleResponse: - type: object - properties: - val_addr: - type: string - val_life: - type: array - items: - type: object - properties: - state_desc: - type: string - description: StateDesc defines the descriptive state. - block_height: - type: string - format: uint64 - block_time: - type: string - format: date-time - description: >- - ValStateUpdateResponse is a message response that records a state - update of a validator. - title: |- - QueryValidatorLifecycleResponse is the response type for the - Query/ValidatorLifecycle RPC method - babylon.epoching.v1.QueuedMessageList: - type: object - properties: - epoch_number: - type: string - format: uint64 - msgs: - type: array - items: - type: object - properties: - tx_id: - type: string - description: tx_id is the ID of the tx that contains the message as hex. - msg_id: - type: string - description: >- - msg_id is the original message ID, i.e., hash of the marshaled - message as hex. - block_height: - type: string - format: uint64 - title: block_height is the height when this msg is submitted to Babylon - block_time: - type: string - format: date-time - title: >- - block_time is the timestamp when this msg is submitted to - Babylon - msg: - type: string - description: >- - msg is the actual message that is sent by a user and is queued - by the - - epoching module as string. - title: >- - QueuedMessageResponse is a message that can change the validator set - and is delayed - - to the end of an epoch - title: |- - QueuedMessageList is a message that contains a list of staking-related - messages queued for an epoch - babylon.epoching.v1.QueuedMessageResponse: - type: object - properties: - tx_id: - type: string - description: tx_id is the ID of the tx that contains the message as hex. - msg_id: - type: string - description: >- - msg_id is the original message ID, i.e., hash of the marshaled message - as hex. - block_height: - type: string - format: uint64 - title: block_height is the height when this msg is submitted to Babylon - block_time: - type: string - format: date-time - title: block_time is the timestamp when this msg is submitted to Babylon - msg: - type: string - description: |- - msg is the actual message that is sent by a user and is queued by the - epoching module as string. - title: >- - QueuedMessageResponse is a message that can change the validator set and - is delayed - - to the end of an epoch - babylon.epoching.v1.ValStateUpdateResponse: - type: object - properties: - state_desc: - type: string - description: StateDesc defines the descriptive state. - block_height: - type: string - format: uint64 - block_time: - type: string - format: date-time - description: >- - ValStateUpdateResponse is a message response that records a state update - of a validator. - babylon.epoching.v1.Validator: - type: object - properties: - addr: - type: string - format: byte - title: addr is the validator's address (in sdk.ValAddress) - power: - type: string - format: int64 - title: power is the validator's voting power - title: Validator is a message that denotes a validator - cosmos.base.v1beta1.Coin: - type: object - properties: - denom: - type: string - amount: - type: string - description: |- - Coin defines a token with a denomination and an amount. - - NOTE: The amount field is an Int which implements the custom method - signatures required by gogoproto. - babylon.checkpointing.v1.CheckpointStateUpdateResponse: - type: object - properties: - state: - type: string - enum: - - CKPT_STATUS_ACCUMULATING - - CKPT_STATUS_SEALED - - CKPT_STATUS_SUBMITTED - - CKPT_STATUS_CONFIRMED - - CKPT_STATUS_FINALIZED - default: CKPT_STATUS_ACCUMULATING - description: |- - CheckpointStatus is the status of a checkpoint. - - - CKPT_STATUS_ACCUMULATING: ACCUMULATING defines a checkpoint that is awaiting for BLS signatures. - - CKPT_STATUS_SEALED: SEALED defines a checkpoint that has accumulated sufficient BLS signatures. - - CKPT_STATUS_SUBMITTED: SUBMITTED defines a checkpoint that is included on BTC. - - CKPT_STATUS_CONFIRMED: CONFIRMED defines a checkpoint that is k-deep on BTC. - - CKPT_STATUS_FINALIZED: FINALIZED defines a checkpoint that is w-deep on BTC. - title: state defines the event of a state transition towards this state - status_desc: - type: string - description: status_desc respresents the description of status enum. - block_height: - type: string - format: uint64 - title: >- - block_height is the height of the Babylon block that triggers the - state - - update - block_time: - type: string - format: date-time - title: >- - block_time is the timestamp in the Babylon block that triggers the - state - - update - description: >- - CheckpointStateUpdateResponse defines a state transition on the - checkpoint. - babylon.checkpointing.v1.CheckpointStatus: - type: string - enum: - - CKPT_STATUS_ACCUMULATING - - CKPT_STATUS_SEALED - - CKPT_STATUS_SUBMITTED - - CKPT_STATUS_CONFIRMED - - CKPT_STATUS_FINALIZED - default: CKPT_STATUS_ACCUMULATING - description: |- - CheckpointStatus is the status of a checkpoint. - - - CKPT_STATUS_ACCUMULATING: ACCUMULATING defines a checkpoint that is awaiting for BLS signatures. - - CKPT_STATUS_SEALED: SEALED defines a checkpoint that has accumulated sufficient BLS signatures. - - CKPT_STATUS_SUBMITTED: SUBMITTED defines a checkpoint that is included on BTC. - - CKPT_STATUS_CONFIRMED: CONFIRMED defines a checkpoint that is k-deep on BTC. - - CKPT_STATUS_FINALIZED: FINALIZED defines a checkpoint that is w-deep on BTC. - babylon.checkpointing.v1.QueryBlsPublicKeyListResponse: - type: object - properties: - validator_with_bls_keys: - type: array - items: - type: object - properties: - validator_address: - type: string - title: validator_address is the address of the validator - bls_pub_key: - type: string - format: byte - title: bls_pub_key is the BLS public key of the validator - voting_power: - type: string - format: uint64 - title: >- - voting_power is the voting power of the validator at the given - epoch - title: >- - ValidatorWithBlsKey couples validator address, voting power, and its - bls - - public key - pagination: - description: pagination defines the pagination in the response. - type: object - properties: - next_key: - type: string - format: byte - description: |- - next_key is the key to be passed to PageRequest.key to - query the next page most efficiently. It will be empty if - there are no more results. - total: - type: string - format: uint64 - title: >- - total is total number of results available if - PageRequest.count_total - - was set, its value is undefined otherwise - description: |- - QueryBlsPublicKeyListResponse is the response type for the - Query/BlsPublicKeys RPC method. - babylon.checkpointing.v1.QueryEpochStatusResponse: - type: object - properties: - status: - type: string - enum: - - CKPT_STATUS_ACCUMULATING - - CKPT_STATUS_SEALED - - CKPT_STATUS_SUBMITTED - - CKPT_STATUS_CONFIRMED - - CKPT_STATUS_FINALIZED - default: CKPT_STATUS_ACCUMULATING - description: |- - CheckpointStatus is the status of a checkpoint. - - - CKPT_STATUS_ACCUMULATING: ACCUMULATING defines a checkpoint that is awaiting for BLS signatures. - - CKPT_STATUS_SEALED: SEALED defines a checkpoint that has accumulated sufficient BLS signatures. - - CKPT_STATUS_SUBMITTED: SUBMITTED defines a checkpoint that is included on BTC. - - CKPT_STATUS_CONFIRMED: CONFIRMED defines a checkpoint that is k-deep on BTC. - - CKPT_STATUS_FINALIZED: FINALIZED defines a checkpoint that is w-deep on BTC. - description: |- - QueryEpochStatusResponse is the response type for the Query/EpochStatus - RPC method. - babylon.checkpointing.v1.QueryLastCheckpointWithStatusResponse: - type: object - properties: - raw_checkpoint: - type: object - properties: - epoch_num: - type: string - format: uint64 - title: epoch_num defines the epoch number the raw checkpoint is for - block_hash_hex: - type: string - title: |- - block_hash_hex defines the 'BlockID.Hash', which is the hash of - the block that individual BLS sigs are signed on as hex string - bitmap: - type: string - format: byte - title: >- - bitmap defines the bitmap that indicates the signers of the BLS - multi sig - bls_multi_sig: - type: string - format: byte - title: >- - bls_multi_sig defines the multi sig that is aggregated from - individual BLS - - sigs - title: RawCheckpointResponse wraps the BLS multi sig with metadata - description: |- - QueryLastCheckpointWithStatusResponse is the response type for the - Query/LastCheckpointWithStatus RPC method. - babylon.checkpointing.v1.QueryRawCheckpointListResponse: - type: object - properties: - raw_checkpoints: - type: array - items: - type: object - properties: - ckpt: - type: object - properties: - epoch_num: - type: string - format: uint64 - title: epoch_num defines the epoch number the raw checkpoint is for - block_hash_hex: - type: string - title: >- - block_hash_hex defines the 'BlockID.Hash', which is the hash - of - - the block that individual BLS sigs are signed on as hex - string - bitmap: - type: string - format: byte - title: >- - bitmap defines the bitmap that indicates the signers of the - BLS multi sig - bls_multi_sig: - type: string - format: byte - title: >- - bls_multi_sig defines the multi sig that is aggregated from - individual BLS - - sigs - title: RawCheckpointResponse wraps the BLS multi sig with metadata - status: - type: string - enum: - - CKPT_STATUS_ACCUMULATING - - CKPT_STATUS_SEALED - - CKPT_STATUS_SUBMITTED - - CKPT_STATUS_CONFIRMED - - CKPT_STATUS_FINALIZED - default: CKPT_STATUS_ACCUMULATING - description: |- - CheckpointStatus is the status of a checkpoint. - - - CKPT_STATUS_ACCUMULATING: ACCUMULATING defines a checkpoint that is awaiting for BLS signatures. - - CKPT_STATUS_SEALED: SEALED defines a checkpoint that has accumulated sufficient BLS signatures. - - CKPT_STATUS_SUBMITTED: SUBMITTED defines a checkpoint that is included on BTC. - - CKPT_STATUS_CONFIRMED: CONFIRMED defines a checkpoint that is k-deep on BTC. - - CKPT_STATUS_FINALIZED: FINALIZED defines a checkpoint that is w-deep on BTC. - title: status defines the status of the checkpoint - status_desc: - type: string - description: status_desc respresents the description of status enum. - bls_aggr_pk: - type: string - format: byte - title: bls_aggr_pk defines the aggregated BLS public key - power_sum: - type: string - format: uint64 - title: >- - power_sum defines the accumulated voting power for the - checkpoint - lifecycle: - type: array - items: - type: object - properties: - state: - type: string - enum: - - CKPT_STATUS_ACCUMULATING - - CKPT_STATUS_SEALED - - CKPT_STATUS_SUBMITTED - - CKPT_STATUS_CONFIRMED - - CKPT_STATUS_FINALIZED - default: CKPT_STATUS_ACCUMULATING - description: |- - CheckpointStatus is the status of a checkpoint. - - - CKPT_STATUS_ACCUMULATING: ACCUMULATING defines a checkpoint that is awaiting for BLS signatures. - - CKPT_STATUS_SEALED: SEALED defines a checkpoint that has accumulated sufficient BLS signatures. - - CKPT_STATUS_SUBMITTED: SUBMITTED defines a checkpoint that is included on BTC. - - CKPT_STATUS_CONFIRMED: CONFIRMED defines a checkpoint that is k-deep on BTC. - - CKPT_STATUS_FINALIZED: FINALIZED defines a checkpoint that is w-deep on BTC. - title: >- - state defines the event of a state transition towards this - state - status_desc: - type: string - description: status_desc respresents the description of status enum. - block_height: - type: string - format: uint64 - title: >- - block_height is the height of the Babylon block that - triggers the state - - update - block_time: - type: string - format: date-time - title: >- - block_time is the timestamp in the Babylon block that - triggers the state - - update - description: >- - CheckpointStateUpdateResponse defines a state transition on - the checkpoint. - description: >- - lifecycle defines the lifecycle of this checkpoint, i.e., each - state - - transition and the time (in both timestamp and block height) of - this - - transition. - description: >- - RawCheckpointWithMetaResponse wraps the raw checkpoint with - metadata. - title: the order is going from the newest to oldest based on the epoch number - pagination: - description: pagination defines the pagination in the response. - type: object - properties: - next_key: - type: string - format: byte - description: |- - next_key is the key to be passed to PageRequest.key to - query the next page most efficiently. It will be empty if - there are no more results. - total: - type: string - format: uint64 - title: >- - total is total number of results available if - PageRequest.count_total - - was set, its value is undefined otherwise - description: |- - QueryRawCheckpointListResponse is the response type for the - Query/RawCheckpoints RPC method. - babylon.checkpointing.v1.QueryRawCheckpointResponse: - type: object - properties: - raw_checkpoint: - type: object - properties: - ckpt: - type: object - properties: - epoch_num: - type: string - format: uint64 - title: epoch_num defines the epoch number the raw checkpoint is for - block_hash_hex: - type: string - title: >- - block_hash_hex defines the 'BlockID.Hash', which is the hash - of - - the block that individual BLS sigs are signed on as hex string - bitmap: - type: string - format: byte - title: >- - bitmap defines the bitmap that indicates the signers of the - BLS multi sig - bls_multi_sig: - type: string - format: byte - title: >- - bls_multi_sig defines the multi sig that is aggregated from - individual BLS - - sigs - title: RawCheckpointResponse wraps the BLS multi sig with metadata - status: - type: string - enum: - - CKPT_STATUS_ACCUMULATING - - CKPT_STATUS_SEALED - - CKPT_STATUS_SUBMITTED - - CKPT_STATUS_CONFIRMED - - CKPT_STATUS_FINALIZED - default: CKPT_STATUS_ACCUMULATING - description: |- - CheckpointStatus is the status of a checkpoint. - - - CKPT_STATUS_ACCUMULATING: ACCUMULATING defines a checkpoint that is awaiting for BLS signatures. - - CKPT_STATUS_SEALED: SEALED defines a checkpoint that has accumulated sufficient BLS signatures. - - CKPT_STATUS_SUBMITTED: SUBMITTED defines a checkpoint that is included on BTC. - - CKPT_STATUS_CONFIRMED: CONFIRMED defines a checkpoint that is k-deep on BTC. - - CKPT_STATUS_FINALIZED: FINALIZED defines a checkpoint that is w-deep on BTC. - title: status defines the status of the checkpoint - status_desc: - type: string - description: status_desc respresents the description of status enum. - bls_aggr_pk: - type: string - format: byte - title: bls_aggr_pk defines the aggregated BLS public key - power_sum: - type: string - format: uint64 - title: power_sum defines the accumulated voting power for the checkpoint - lifecycle: - type: array - items: - type: object - properties: - state: - type: string - enum: - - CKPT_STATUS_ACCUMULATING - - CKPT_STATUS_SEALED - - CKPT_STATUS_SUBMITTED - - CKPT_STATUS_CONFIRMED - - CKPT_STATUS_FINALIZED - default: CKPT_STATUS_ACCUMULATING - description: |- - CheckpointStatus is the status of a checkpoint. - - - CKPT_STATUS_ACCUMULATING: ACCUMULATING defines a checkpoint that is awaiting for BLS signatures. - - CKPT_STATUS_SEALED: SEALED defines a checkpoint that has accumulated sufficient BLS signatures. - - CKPT_STATUS_SUBMITTED: SUBMITTED defines a checkpoint that is included on BTC. - - CKPT_STATUS_CONFIRMED: CONFIRMED defines a checkpoint that is k-deep on BTC. - - CKPT_STATUS_FINALIZED: FINALIZED defines a checkpoint that is w-deep on BTC. - title: >- - state defines the event of a state transition towards this - state - status_desc: - type: string - description: status_desc respresents the description of status enum. - block_height: - type: string - format: uint64 - title: >- - block_height is the height of the Babylon block that - triggers the state - - update - block_time: - type: string - format: date-time - title: >- - block_time is the timestamp in the Babylon block that - triggers the state - - update - description: >- - CheckpointStateUpdateResponse defines a state transition on the - checkpoint. - description: >- - lifecycle defines the lifecycle of this checkpoint, i.e., each - state - - transition and the time (in both timestamp and block height) of - this - - transition. - description: RawCheckpointWithMetaResponse wraps the raw checkpoint with metadata. + message SomeResponse { + repeated Bar results = 1; + PageResponse page = 2; + } description: >- - QueryRawCheckpointResponse is the response type for the - Query/RawCheckpoint - - RPC method. - babylon.checkpointing.v1.QueryRawCheckpointsResponse: + QueryMainChainResponse is response type for the Query/MainChain RPC + method. + babylon.btclightclient.v1.QueryParamsResponse: type: object properties: - raw_checkpoints: - type: array - items: - type: object - properties: - ckpt: - type: object - properties: - epoch_num: - type: string - format: uint64 - title: epoch_num defines the epoch number the raw checkpoint is for - block_hash_hex: - type: string - title: >- - block_hash_hex defines the 'BlockID.Hash', which is the hash - of - - the block that individual BLS sigs are signed on as hex - string - bitmap: - type: string - format: byte - title: >- - bitmap defines the bitmap that indicates the signers of the - BLS multi sig - bls_multi_sig: - type: string - format: byte - title: >- - bls_multi_sig defines the multi sig that is aggregated from - individual BLS - - sigs - title: RawCheckpointResponse wraps the BLS multi sig with metadata - status: - type: string - enum: - - CKPT_STATUS_ACCUMULATING - - CKPT_STATUS_SEALED - - CKPT_STATUS_SUBMITTED - - CKPT_STATUS_CONFIRMED - - CKPT_STATUS_FINALIZED - default: CKPT_STATUS_ACCUMULATING - description: |- - CheckpointStatus is the status of a checkpoint. - - - CKPT_STATUS_ACCUMULATING: ACCUMULATING defines a checkpoint that is awaiting for BLS signatures. - - CKPT_STATUS_SEALED: SEALED defines a checkpoint that has accumulated sufficient BLS signatures. - - CKPT_STATUS_SUBMITTED: SUBMITTED defines a checkpoint that is included on BTC. - - CKPT_STATUS_CONFIRMED: CONFIRMED defines a checkpoint that is k-deep on BTC. - - CKPT_STATUS_FINALIZED: FINALIZED defines a checkpoint that is w-deep on BTC. - title: status defines the status of the checkpoint - status_desc: - type: string - description: status_desc respresents the description of status enum. - bls_aggr_pk: - type: string - format: byte - title: bls_aggr_pk defines the aggregated BLS public key - power_sum: - type: string - format: uint64 - title: >- - power_sum defines the accumulated voting power for the - checkpoint - lifecycle: - type: array - items: - type: object - properties: - state: - type: string - enum: - - CKPT_STATUS_ACCUMULATING - - CKPT_STATUS_SEALED - - CKPT_STATUS_SUBMITTED - - CKPT_STATUS_CONFIRMED - - CKPT_STATUS_FINALIZED - default: CKPT_STATUS_ACCUMULATING - description: |- - CheckpointStatus is the status of a checkpoint. - - - CKPT_STATUS_ACCUMULATING: ACCUMULATING defines a checkpoint that is awaiting for BLS signatures. - - CKPT_STATUS_SEALED: SEALED defines a checkpoint that has accumulated sufficient BLS signatures. - - CKPT_STATUS_SUBMITTED: SUBMITTED defines a checkpoint that is included on BTC. - - CKPT_STATUS_CONFIRMED: CONFIRMED defines a checkpoint that is k-deep on BTC. - - CKPT_STATUS_FINALIZED: FINALIZED defines a checkpoint that is w-deep on BTC. - title: >- - state defines the event of a state transition towards this - state - status_desc: - type: string - description: status_desc respresents the description of status enum. - block_height: - type: string - format: uint64 - title: >- - block_height is the height of the Babylon block that - triggers the state - - update - block_time: - type: string - format: date-time - title: >- - block_time is the timestamp in the Babylon block that - triggers the state - - update - description: >- - CheckpointStateUpdateResponse defines a state transition on - the checkpoint. - description: >- - lifecycle defines the lifecycle of this checkpoint, i.e., each - state - - transition and the time (in both timestamp and block height) of - this - - transition. - description: >- - RawCheckpointWithMetaResponse wraps the raw checkpoint with - metadata. - title: the order is going from the newest to oldest based on the epoch number - pagination: - description: pagination defines the pagination in the response. + params: + description: params holds all the parameters of this module. type: object properties: - next_key: - type: string - format: byte - description: |- - next_key is the key to be passed to PageRequest.key to - query the next page most efficiently. It will be empty if - there are no more results. - total: - type: string - format: uint64 + insert_headers_allow_list: + type: array + items: + type: string title: >- - total is total number of results available if - PageRequest.count_total - - was set, its value is undefined otherwise - description: >- - QueryRawCheckpointsResponse is the response type for the - Query/RawCheckpoints - - RPC method. - babylon.checkpointing.v1.QueryRecentEpochStatusCountResponse: - type: object - properties: - tip_epoch: - type: string - format: uint64 - epoch_count: - type: string - format: uint64 - status_count: - type: object - additionalProperties: - type: string - format: uint64 - description: |- - QueryRecentEpochStatusCountResponse is the response type for the - Query/EpochStatusCount RPC method. - babylon.checkpointing.v1.RawCheckpointResponse: - type: object - properties: - epoch_num: - type: string - format: uint64 - title: epoch_num defines the epoch number the raw checkpoint is for - block_hash_hex: - type: string - title: |- - block_hash_hex defines the 'BlockID.Hash', which is the hash of - the block that individual BLS sigs are signed on as hex string - bitmap: - type: string - format: byte - title: >- - bitmap defines the bitmap that indicates the signers of the BLS multi - sig - bls_multi_sig: - type: string - format: byte - title: >- - bls_multi_sig defines the multi sig that is aggregated from individual - BLS + List of addresses which are allowed to insert headers to btc light + client - sigs - title: RawCheckpointResponse wraps the BLS multi sig with metadata - babylon.checkpointing.v1.RawCheckpointWithMetaResponse: + if the list is empty, any address can insert headers + description: QueryParamsResponse is the response type for the Query/Params RPC method. + babylon.btclightclient.v1.QueryTipResponse: type: object properties: - ckpt: + header: type: object properties: - epoch_num: - type: string - format: uint64 - title: epoch_num defines the epoch number the raw checkpoint is for - block_hash_hex: + header_hex: type: string - title: |- - block_hash_hex defines the 'BlockID.Hash', which is the hash of - the block that individual BLS sigs are signed on as hex string - bitmap: + hash_hex: type: string - format: byte - title: >- - bitmap defines the bitmap that indicates the signers of the BLS - multi sig - bls_multi_sig: + height: + type: integer + format: int64 + work: type: string - format: byte - title: >- - bls_multi_sig defines the multi sig that is aggregated from - individual BLS - - sigs - title: RawCheckpointResponse wraps the BLS multi sig with metadata - status: - type: string - enum: - - CKPT_STATUS_ACCUMULATING - - CKPT_STATUS_SEALED - - CKPT_STATUS_SUBMITTED - - CKPT_STATUS_CONFIRMED - - CKPT_STATUS_FINALIZED - default: CKPT_STATUS_ACCUMULATING - description: |- - CheckpointStatus is the status of a checkpoint. + description: Work is the sdkmath.Uint as string. + description: >- + BTCHeaderInfoResponse is a structure that contains all relevant + information about a - - CKPT_STATUS_ACCUMULATING: ACCUMULATING defines a checkpoint that is awaiting for BLS signatures. - - CKPT_STATUS_SEALED: SEALED defines a checkpoint that has accumulated sufficient BLS signatures. - - CKPT_STATUS_SUBMITTED: SUBMITTED defines a checkpoint that is included on BTC. - - CKPT_STATUS_CONFIRMED: CONFIRMED defines a checkpoint that is k-deep on BTC. - - CKPT_STATUS_FINALIZED: FINALIZED defines a checkpoint that is w-deep on BTC. - title: status defines the status of the checkpoint - status_desc: - type: string - description: status_desc respresents the description of status enum. - bls_aggr_pk: - type: string - format: byte - title: bls_aggr_pk defines the aggregated BLS public key - power_sum: + BTC header response + - Full header as string hex. + - Header hash for easy retrieval as string hex. + - Height of the header in the BTC chain. + - Total work spent on the header. This is the sum of the work corresponding + to the header Bits field + and the total work of the header. + description: QueryTipResponse is the response type for the Query/Tip RPC method. + babylon.epoching.v1.BondState: + type: string + enum: + - CREATED + - BONDED + - UNBONDING + - UNBONDED + - REMOVED + default: CREATED + description: |- + - CREATED: CREATED is when the validator/delegation has been created + - BONDED: CREATED is when the validator/delegation has become bonded + - UNBONDING: CREATED is when the validator/delegation has become unbonding + - UNBONDED: CREATED is when the validator/delegation has become unbonded + - REMOVED: CREATED is when the validator/delegation has been removed + title: BondState is the bond state of a validator or delegation + babylon.epoching.v1.DelegationLifecycle: + type: object + properties: + del_addr: type: string - format: uint64 - title: power_sum defines the accumulated voting power for the checkpoint - lifecycle: + del_life: type: array items: type: object @@ -11164,188 +5887,94 @@ definitions: state: type: string enum: - - CKPT_STATUS_ACCUMULATING - - CKPT_STATUS_SEALED - - CKPT_STATUS_SUBMITTED - - CKPT_STATUS_CONFIRMED - - CKPT_STATUS_FINALIZED - default: CKPT_STATUS_ACCUMULATING - description: |- - CheckpointStatus is the status of a checkpoint. - - - CKPT_STATUS_ACCUMULATING: ACCUMULATING defines a checkpoint that is awaiting for BLS signatures. - - CKPT_STATUS_SEALED: SEALED defines a checkpoint that has accumulated sufficient BLS signatures. - - CKPT_STATUS_SUBMITTED: SUBMITTED defines a checkpoint that is included on BTC. - - CKPT_STATUS_CONFIRMED: CONFIRMED defines a checkpoint that is k-deep on BTC. - - CKPT_STATUS_FINALIZED: FINALIZED defines a checkpoint that is w-deep on BTC. - title: state defines the event of a state transition towards this state - status_desc: + - CREATED + - BONDED + - UNBONDING + - UNBONDED + - REMOVED + default: CREATED + description: >- + - CREATED: CREATED is when the validator/delegation has been + created + - BONDED: CREATED is when the validator/delegation has become bonded + - UNBONDING: CREATED is when the validator/delegation has become unbonding + - UNBONDED: CREATED is when the validator/delegation has become unbonded + - REMOVED: CREATED is when the validator/delegation has been removed + title: BondState is the bond state of a validator or delegation + val_addr: type: string - description: status_desc respresents the description of status enum. + amount: + type: object + properties: + denom: + type: string + amount: + type: string + description: >- + Coin defines a token with a denomination and an amount. + + + NOTE: The amount field is an Int which implements the custom + method + + signatures required by gogoproto. block_height: type: string format: uint64 - title: >- - block_height is the height of the Babylon block that triggers - the state - - update block_time: type: string format: date-time - title: >- - block_time is the timestamp in the Babylon block that triggers - the state - - update - description: >- - CheckpointStateUpdateResponse defines a state transition on the - checkpoint. - description: |- - lifecycle defines the lifecycle of this checkpoint, i.e., each state - transition and the time (in both timestamp and block height) of this - transition. - description: RawCheckpointWithMetaResponse wraps the raw checkpoint with metadata. - babylon.checkpointing.v1.ValidatorWithBlsKey: - type: object - properties: - validator_address: - type: string - title: validator_address is the address of the validator - bls_pub_key: - type: string - format: byte - title: bls_pub_key is the BLS public key of the validator - voting_power: - type: string - format: uint64 - title: voting_power is the voting power of the validator at the given epoch - title: |- - ValidatorWithBlsKey couples validator address, voting power, and its bls - public key - babylon.btccheckpoint.v1.SubmissionKey: - type: object - properties: - key: - type: array - items: - type: object - properties: - index: - type: integer - format: int64 - hash: - type: string - format: byte title: >- - Each provided OP_RETURN transaction can be identified by hash of - block in - - which transaction was included and transaction index in the block - title: >- - Checkpoint can be composed from multiple transactions, so to identify - whole - - submission we need list of transaction keys. - - Each submission can generally be identified by this list of (txIdx, - - blockHash) tuples. Note: this could possibly be optimized as if - transactions - - were in one block they would have the same block hash and different - indexes, - - but each blockhash is only 33 (1 byte for prefix encoding and 32 byte - hash), - - so there should be other strong arguments for this optimization - babylon.btccheckpoint.v1.TransactionInfo: - type: object - properties: - key: - type: object - properties: - index: - type: integer - format: int64 - hash: - type: string - format: byte - title: >- - Each provided OP_RETURN transaction can be identified by hash of block - in - - which transaction was included and transaction index in the block - description: |- - key is the position (txIdx, blockHash) of this tx on BTC blockchain - Although it is already a part of SubmissionKey, we store it here again - to make TransactionInfo self-contained. - For example, storing the key allows TransactionInfo to not relay on - the fact that TransactionInfo will be ordered in the same order as - TransactionKeys in SubmissionKey. - transaction: - type: string - format: byte - title: transaction is the full transaction in bytes - proof: - type: string - format: byte - title: >- - proof is the Merkle proof that this tx is included in the position in - `key` - - TODO: maybe it could use here better format as we already processed - and + DelegationStateUpdate is the message that records a state update of + a - validated the proof? - title: |- - TransactionInfo is the info of a tx on Bitcoin, - including - - the position of the tx on BTC blockchain - - the full tx content - - the Merkle proof that this tx is on the above position - babylon.btccheckpoint.v1.TransactionKey: - type: object - properties: - index: - type: integer - format: int64 - hash: - type: string - format: byte + delegation title: |- - Each provided OP_RETURN transaction can be identified by hash of block in - which transaction was included and transaction index in the block - babylon.checkpointing.v1.RawCheckpoint: + ValidatorLifecycle is a message that records the lifecycle of + a delegation + babylon.epoching.v1.DelegationStateUpdate: type: object properties: - epoch_num: + state: type: string - format: uint64 - title: epoch_num defines the epoch number the raw checkpoint is for - block_hash: + enum: + - CREATED + - BONDED + - UNBONDING + - UNBONDED + - REMOVED + default: CREATED + description: |- + - CREATED: CREATED is when the validator/delegation has been created + - BONDED: CREATED is when the validator/delegation has become bonded + - UNBONDING: CREATED is when the validator/delegation has become unbonding + - UNBONDED: CREATED is when the validator/delegation has become unbonded + - REMOVED: CREATED is when the validator/delegation has been removed + title: BondState is the bond state of a validator or delegation + val_addr: type: string - format: byte - title: |- - block_hash defines the 'BlockID.Hash', which is the hash of - the block that individual BLS sigs are signed on - bitmap: + amount: + type: object + properties: + denom: + type: string + amount: + type: string + description: |- + Coin defines a token with a denomination and an amount. + + NOTE: The amount field is an Int which implements the custom method + signatures required by gogoproto. + block_height: type: string - format: byte - title: >- - bitmap defines the bitmap that indicates the signers of the BLS multi - sig - bls_multi_sig: + format: uint64 + block_time: type: string - format: byte - title: >- - bls_multi_sig defines the multi sig that is aggregated from individual - BLS - - sigs - title: RawCheckpoint wraps the BLS multi sig with metadata - babylon.epoching.v1.Epoch: + format: date-time + title: |- + DelegationStateUpdate is the message that records a state update of a + delegation + babylon.epoching.v1.EpochResponse: type: object properties: epoch_number: @@ -11375,379 +6004,111 @@ definitions: and is set upon the end of this epoch. - sealer_app_hash: + sealer_app_hash_hex: type: string - format: byte - title: |- + description: |- sealer is the last block of the sealed epoch sealer_app_hash points to the sealer but stored in the 1st header - of the next epoch + of the next epoch as hex string. sealer_block_hash: type: string - format: byte - title: |- + description: |- sealer_block_hash is the hash of the sealer the validator set has generated a BLS multisig on the hash, - i.e., hash of the last block in the epoch - title: Epoch is a structure that contains the metadata of an epoch - babylon.zoneconcierge.v1.ChainInfo: + i.e., hash of the last block in the epoch as hex string. + title: EpochResponse is a structure that contains the metadata of an epoch + babylon.epoching.v1.Params: type: object properties: - consumer_id: + epoch_interval: type: string - title: consumer_id is the ID of the consumer - latest_header: - type: object - properties: - consumer_id: - type: string - title: consumer_id is the unique ID of the consumer - hash: - type: string - format: byte - title: hash is the hash of this header - height: - type: string - format: uint64 - title: >- - height is the height of this header on CZ ledger - - (hash, height) jointly provides the position of the header on CZ - ledger - time: - type: string - format: date-time - title: |- - time is the timestamp of this header on CZ ledger - it is needed for CZ to unbond all mature validators/delegations - before this timestamp when this header is BTC-finalised - babylon_header_hash: - type: string - format: byte - title: >- - babylon_header_hash is the hash of the babylon block that includes - this CZ - - header - babylon_header_height: - type: string - format: uint64 - title: >- - babylon_header_height is the height of the babylon block that - includes this CZ - - header - babylon_epoch: - type: string - format: uint64 - title: epoch is the epoch number of this header on Babylon ledger - babylon_tx_hash: - type: string - format: byte - title: >- - babylon_tx_hash is the hash of the tx that includes this header - - (babylon_block_height, babylon_tx_hash) jointly provides the - position of + format: uint64 + title: epoch_interval is the number of consecutive blocks to form an epoch + description: Params defines the parameters for the module. + babylon.epoching.v1.QueryCurrentEpochResponse: + type: object + properties: + current_epoch: + type: string + format: uint64 + title: current_epoch is the current epoch number + epoch_boundary: + type: string + format: uint64 + title: epoch_boundary is the height of this epoch's last block + title: >- + QueryCurrentEpochResponse is the response type for the Query/CurrentEpoch + RPC - the header on Babylon ledger - title: IndexedHeader is the metadata of a CZ header - latest_forks: + method + babylon.epoching.v1.QueryDelegationLifecycleResponse: + type: object + properties: + del_life: type: object properties: - headers: + del_addr: + type: string + del_life: type: array items: type: object properties: - consumer_id: - type: string - title: consumer_id is the unique ID of the consumer - hash: - type: string - format: byte - title: hash is the hash of this header - height: - type: string - format: uint64 - title: >- - height is the height of this header on CZ ledger - - (hash, height) jointly provides the position of the header - on CZ ledger - time: - type: string - format: date-time - title: >- - time is the timestamp of this header on CZ ledger - - it is needed for CZ to unbond all mature - validators/delegations - - before this timestamp when this header is BTC-finalised - babylon_header_hash: - type: string - format: byte - title: >- - babylon_header_hash is the hash of the babylon block that - includes this CZ - - header - babylon_header_height: - type: string - format: uint64 - title: >- - babylon_header_height is the height of the babylon block - that includes this CZ - - header - babylon_epoch: + state: type: string - format: uint64 - title: epoch is the epoch number of this header on Babylon ledger - babylon_tx_hash: + enum: + - CREATED + - BONDED + - UNBONDING + - UNBONDED + - REMOVED + default: CREATED + description: >- + - CREATED: CREATED is when the validator/delegation has been + created + - BONDED: CREATED is when the validator/delegation has become bonded + - UNBONDING: CREATED is when the validator/delegation has become unbonding + - UNBONDED: CREATED is when the validator/delegation has become unbonded + - REMOVED: CREATED is when the validator/delegation has been removed + title: BondState is the bond state of a validator or delegation + val_addr: type: string - format: byte - title: >- - babylon_tx_hash is the hash of the tx that includes this - header - - (babylon_block_height, babylon_tx_hash) jointly provides the - position of - - the header on Babylon ledger - title: IndexedHeader is the metadata of a CZ header - title: >- - blocks is the list of non-canonical indexed headers at the same - height - description: >- - Forks is a list of non-canonical `IndexedHeader`s at the same height. - - For example, assuming the following blockchain - - ``` - - A <- B <- C <- D <- E - \ -- D1 - \ -- D2 - ``` - - Then the fork will be {[D1, D2]} where each item is in struct - `IndexedBlock`. - - - Note that each `IndexedHeader` in the fork should have a valid quorum - - certificate. Such forks exist since Babylon considers CZs might have - - dishonest majority. Also note that the IBC-Go implementation will only - - consider the first header in a fork valid, since the subsequent - headers - - cannot be verified without knowing the validator set in the previous - header. - title: >- - latest_forks is the latest forks, formed as a series of IndexedHeader - (from - - low to high) - timestamped_headers_count: - type: string - format: uint64 - title: |- - timestamped_headers_count is the number of timestamped headers in CZ's - canonical chain - title: ChainInfo is the information of a CZ - babylon.zoneconcierge.v1.FinalizedChainInfo: - type: object - properties: - consumer_id: - type: string - title: consumer_id is the ID of the consumer - finalized_chain_info: - type: object - properties: - consumer_id: - type: string - title: consumer_id is the ID of the consumer - latest_header: - type: object - properties: - consumer_id: - type: string - title: consumer_id is the unique ID of the consumer - hash: - type: string - format: byte - title: hash is the hash of this header - height: - type: string - format: uint64 - title: >- - height is the height of this header on CZ ledger - - (hash, height) jointly provides the position of the header on - CZ ledger - time: - type: string - format: date-time - title: >- - time is the timestamp of this header on CZ ledger - - it is needed for CZ to unbond all mature - validators/delegations - - before this timestamp when this header is BTC-finalised - babylon_header_hash: - type: string - format: byte - title: >- - babylon_header_hash is the hash of the babylon block that - includes this CZ - - header - babylon_header_height: - type: string - format: uint64 - title: >- - babylon_header_height is the height of the babylon block that - includes this CZ - - header - babylon_epoch: - type: string - format: uint64 - title: epoch is the epoch number of this header on Babylon ledger - babylon_tx_hash: - type: string - format: byte - title: >- - babylon_tx_hash is the hash of the tx that includes this - header - - (babylon_block_height, babylon_tx_hash) jointly provides the - position of - - the header on Babylon ledger - title: IndexedHeader is the metadata of a CZ header - latest_forks: - type: object - properties: - headers: - type: array - items: + amount: type: object properties: - consumer_id: - type: string - title: consumer_id is the unique ID of the consumer - hash: - type: string - format: byte - title: hash is the hash of this header - height: - type: string - format: uint64 - title: >- - height is the height of this header on CZ ledger - - (hash, height) jointly provides the position of the - header on CZ ledger - time: - type: string - format: date-time - title: >- - time is the timestamp of this header on CZ ledger - - it is needed for CZ to unbond all mature - validators/delegations - - before this timestamp when this header is BTC-finalised - babylon_header_hash: - type: string - format: byte - title: >- - babylon_header_hash is the hash of the babylon block - that includes this CZ - - header - babylon_header_height: - type: string - format: uint64 - title: >- - babylon_header_height is the height of the babylon block - that includes this CZ - - header - babylon_epoch: + denom: type: string - format: uint64 - title: >- - epoch is the epoch number of this header on Babylon - ledger - babylon_tx_hash: + amount: type: string - format: byte - title: >- - babylon_tx_hash is the hash of the tx that includes this - header - - (babylon_block_height, babylon_tx_hash) jointly provides - the position of - - the header on Babylon ledger - title: IndexedHeader is the metadata of a CZ header - title: >- - blocks is the list of non-canonical indexed headers at the - same height - description: >- - Forks is a list of non-canonical `IndexedHeader`s at the same - height. - - For example, assuming the following blockchain - - ``` - - A <- B <- C <- D <- E - \ -- D1 - \ -- D2 - ``` - - Then the fork will be {[D1, D2]} where each item is in struct - `IndexedBlock`. - - - Note that each `IndexedHeader` in the fork should have a valid - quorum - - certificate. Such forks exist since Babylon considers CZs might - have - - dishonest majority. Also note that the IBC-Go implementation will - only + description: >- + Coin defines a token with a denomination and an amount. - consider the first header in a fork valid, since the subsequent - headers - cannot be verified without knowing the validator set in the - previous header. - title: >- - latest_forks is the latest forks, formed as a series of - IndexedHeader (from + NOTE: The amount field is an Int which implements the custom + method - low to high) - timestamped_headers_count: - type: string - format: uint64 - title: >- - timestamped_headers_count is the number of timestamped headers in - CZ's + signatures required by gogoproto. + block_height: + type: string + format: uint64 + block_time: + type: string + format: date-time + title: >- + DelegationStateUpdate is the message that records a state update + of a - canonical chain - title: ChainInfo is the information of a CZ - epoch_info: - title: epoch_info is the metadata of the last BTC-finalised epoch + delegation + title: |- + ValidatorLifecycle is a message that records the lifecycle of + a delegation + title: |- + QueryDelegationLifecycleRequest is the response type for the + Query/DelegationLifecycle RPC method + babylon.epoching.v1.QueryEpochInfoResponse: + type: object + properties: + epoch: type: object properties: epoch_number: @@ -11780,707 +6141,194 @@ definitions: beginning, and is set upon the end of this epoch. - sealer_app_hash: + sealer_app_hash_hex: type: string - format: byte - title: |- + description: |- sealer is the last block of the sealed epoch sealer_app_hash points to the sealer but stored in the 1st header - of the next epoch - sealer_block_hash: - type: string - format: byte - title: |- - sealer_block_hash is the hash of the sealer - the validator set has generated a BLS multisig on the hash, - i.e., hash of the last block in the epoch - raw_checkpoint: - title: raw_checkpoint is the raw checkpoint of this epoch - type: object - properties: - epoch_num: - type: string - format: uint64 - title: epoch_num defines the epoch number the raw checkpoint is for - block_hash: - type: string - format: byte - title: |- - block_hash defines the 'BlockID.Hash', which is the hash of - the block that individual BLS sigs are signed on - bitmap: - type: string - format: byte - title: >- - bitmap defines the bitmap that indicates the signers of the BLS - multi sig - bls_multi_sig: - type: string - format: byte - title: >- - bls_multi_sig defines the multi sig that is aggregated from - individual BLS - - sigs - btc_submission_key: - title: |- - btc_submission_key is position of two BTC txs that include the raw - checkpoint of this epoch - type: object - properties: - key: - type: array - items: - type: object - properties: - index: - type: integer - format: int64 - hash: - type: string - format: byte - title: >- - Each provided OP_RETURN transaction can be identified by hash of - block in - - which transaction was included and transaction index in the - block - proof: - title: proof is the proof that the chain info is finalized - type: object - properties: - proof_cz_header_in_epoch: - title: >- - proof_cz_header_in_epoch is the proof that the CZ header is - timestamped - - within a certain epoch - type: object - properties: - ops: - type: array - items: - type: object - properties: - type: - type: string - key: - type: string - format: byte - data: - type: string - format: byte - title: >- - ProofOp defines an operation used for calculating Merkle - root - - The data could be arbitrary format, providing nessecary data - - for example neighbouring node hash - proof_epoch_sealed: - title: proof_epoch_sealed is the proof that the epoch is sealed - type: object - properties: - validator_set: - type: array - items: - type: object - properties: - validator_address: - type: string - title: validator_address is the address of the validator - bls_pub_key: - type: string - format: byte - title: bls_pub_key is the BLS public key of the validator - voting_power: - type: string - format: uint64 - title: >- - voting_power is the voting power of the validator at the - given epoch - title: >- - ValidatorWithBlsKey couples validator address, voting power, - and its bls - - public key - title: >- - validator_set is the validator set of the sealed epoch - - This validator set has generated a BLS multisig on `app_hash` - of - - the sealer header - proof_epoch_info: - title: >- - proof_epoch_info is the Merkle proof that the epoch's metadata - is committed - - to `app_hash` of the sealer header - type: object - properties: - ops: - type: array - items: - type: object - properties: - type: - type: string - key: - type: string - format: byte - data: - type: string - format: byte - title: >- - ProofOp defines an operation used for calculating Merkle - root - - The data could be arbitrary format, providing nessecary - data - - for example neighbouring node hash - proof_epoch_val_set: - title: >- - proof_epoch_info is the Merkle proof that the epoch's - validator set is - - committed to `app_hash` of the sealer header - type: object - properties: - ops: - type: array - items: - type: object - properties: - type: - type: string - key: - type: string - format: byte - data: - type: string - format: byte - title: >- - ProofOp defines an operation used for calculating Merkle - root - - The data could be arbitrary format, providing nessecary - data - - for example neighbouring node hash - proof_epoch_submitted: - type: array - items: - type: object - properties: - key: - type: object - properties: - index: - type: integer - format: int64 - hash: - type: string - format: byte - title: >- - Each provided OP_RETURN transaction can be identified by - hash of block in - - which transaction was included and transaction index in the - block - description: >- - key is the position (txIdx, blockHash) of this tx on BTC - blockchain - - Although it is already a part of SubmissionKey, we store it - here again - - to make TransactionInfo self-contained. - - For example, storing the key allows TransactionInfo to not - relay on - - the fact that TransactionInfo will be ordered in the same - order as - - TransactionKeys in SubmissionKey. - transaction: - type: string - format: byte - title: transaction is the full transaction in bytes - proof: - type: string - format: byte - title: >- - proof is the Merkle proof that this tx is included in the - position in `key` - - TODO: maybe it could use here better format as we already - processed and - - validated the proof? - title: |- - TransactionInfo is the info of a tx on Bitcoin, - including - - the position of the tx on BTC blockchain - - the full tx content - - the Merkle proof that this tx is on the above position - title: >- - proof_epoch_submitted is the proof that the epoch's checkpoint is - included - - in BTC ledger It is the two TransactionInfo in the best (i.e., - earliest) - - checkpoint submission - title: FinalizedChainInfo is the information of a CZ that is BTC-finalised - babylon.zoneconcierge.v1.Forks: - type: object - properties: - headers: - type: array - items: - type: object - properties: - consumer_id: - type: string - title: consumer_id is the unique ID of the consumer - hash: - type: string - format: byte - title: hash is the hash of this header - height: - type: string - format: uint64 - title: >- - height is the height of this header on CZ ledger - - (hash, height) jointly provides the position of the header on CZ - ledger - time: - type: string - format: date-time - title: |- - time is the timestamp of this header on CZ ledger - it is needed for CZ to unbond all mature validators/delegations - before this timestamp when this header is BTC-finalised - babylon_header_hash: - type: string - format: byte - title: >- - babylon_header_hash is the hash of the babylon block that - includes this CZ - - header - babylon_header_height: - type: string - format: uint64 - title: >- - babylon_header_height is the height of the babylon block that - includes this CZ - - header - babylon_epoch: - type: string - format: uint64 - title: epoch is the epoch number of this header on Babylon ledger - babylon_tx_hash: - type: string - format: byte - title: >- - babylon_tx_hash is the hash of the tx that includes this header - - (babylon_block_height, babylon_tx_hash) jointly provides the - position of - - the header on Babylon ledger - title: IndexedHeader is the metadata of a CZ header - title: blocks is the list of non-canonical indexed headers at the same height - description: >- - Forks is a list of non-canonical `IndexedHeader`s at the same height. - - For example, assuming the following blockchain - - ``` - - A <- B <- C <- D <- E - \ -- D1 - \ -- D2 - ``` - - Then the fork will be {[D1, D2]} where each item is in struct - `IndexedBlock`. - - - Note that each `IndexedHeader` in the fork should have a valid quorum - - certificate. Such forks exist since Babylon considers CZs might have - - dishonest majority. Also note that the IBC-Go implementation will only - - consider the first header in a fork valid, since the subsequent headers - - cannot be verified without knowing the validator set in the previous - header. - babylon.zoneconcierge.v1.IndexedHeader: - type: object - properties: - consumer_id: - type: string - title: consumer_id is the unique ID of the consumer - hash: - type: string - format: byte - title: hash is the hash of this header - height: - type: string - format: uint64 - title: >- - height is the height of this header on CZ ledger - - (hash, height) jointly provides the position of the header on CZ - ledger - time: - type: string - format: date-time - title: |- - time is the timestamp of this header on CZ ledger - it is needed for CZ to unbond all mature validators/delegations - before this timestamp when this header is BTC-finalised - babylon_header_hash: - type: string - format: byte - title: >- - babylon_header_hash is the hash of the babylon block that includes - this CZ - - header - babylon_header_height: - type: string - format: uint64 - title: >- - babylon_header_height is the height of the babylon block that includes - this CZ - - header - babylon_epoch: - type: string - format: uint64 - title: epoch is the epoch number of this header on Babylon ledger - babylon_tx_hash: - type: string - format: byte - title: >- - babylon_tx_hash is the hash of the tx that includes this header - - (babylon_block_height, babylon_tx_hash) jointly provides the position - of - - the header on Babylon ledger - title: IndexedHeader is the metadata of a CZ header - babylon.zoneconcierge.v1.Params: - type: object - properties: - ibc_packet_timeout_seconds: - type: integer - format: int64 - title: >- - ibc_packet_timeout_seconds is the time period after which an - unrelayed - - IBC packet becomes timeout, measured in seconds - description: Params defines the parameters for the module. - babylon.zoneconcierge.v1.ProofEpochSealed: + of the next epoch as hex string. + sealer_block_hash: + type: string + description: |- + sealer_block_hash is the hash of the sealer + the validator set has generated a BLS multisig on the hash, + i.e., hash of the last block in the epoch as hex string. + title: EpochResponse is a structure that contains the metadata of an epoch + title: QueryEpochInfoRequest is the response type for the Query/EpochInfo method + babylon.epoching.v1.QueryEpochMsgsResponse: type: object properties: - validator_set: + msgs: type: array items: type: object properties: - validator_address: + tx_id: type: string - title: validator_address is the address of the validator - bls_pub_key: + description: tx_id is the ID of the tx that contains the message as hex. + msg_id: type: string - format: byte - title: bls_pub_key is the BLS public key of the validator - voting_power: + description: >- + msg_id is the original message ID, i.e., hash of the marshaled + message as hex. + block_height: type: string format: uint64 + title: block_height is the height when this msg is submitted to Babylon + block_time: + type: string + format: date-time title: >- - voting_power is the voting power of the validator at the given - epoch - title: >- - ValidatorWithBlsKey couples validator address, voting power, and its - bls + block_time is the timestamp when this msg is submitted to + Babylon + msg: + type: string + description: >- + msg is the actual message that is sent by a user and is queued + by the - public key - title: |- - validator_set is the validator set of the sealed epoch - This validator set has generated a BLS multisig on `app_hash` of - the sealer header - proof_epoch_info: - title: >- - proof_epoch_info is the Merkle proof that the epoch's metadata is - committed + epoching module as string. + title: >- + QueuedMessageResponse is a message that can change the validator set + and is delayed - to `app_hash` of the sealer header - type: object - properties: - ops: - type: array - items: - type: object - properties: - type: - type: string - key: - type: string - format: byte - data: - type: string - format: byte - title: |- - ProofOp defines an operation used for calculating Merkle root - The data could be arbitrary format, providing nessecary data - for example neighbouring node hash - proof_epoch_val_set: - title: |- - proof_epoch_info is the Merkle proof that the epoch's validator set is - committed to `app_hash` of the sealer header + to the end of an epoch + title: msgs is the list of messages queued in the current epoch + pagination: + title: pagination defines the pagination in the response type: object properties: - ops: - type: array - items: - type: object - properties: - type: - type: string - key: - type: string - format: byte - data: - type: string - format: byte - title: |- - ProofOp defines an operation used for calculating Merkle root - The data could be arbitrary format, providing nessecary data - for example neighbouring node hash - title: >- - ProofEpochSealed is the proof that an epoch is sealed by the sealer - header, - - i.e., the 2nd header of the next epoch With the access of metadata - - - Metadata of this epoch, which includes the sealer header - - - Raw checkpoint of this epoch - - The verifier can perform the following verification rules: - - - The raw checkpoint's `app_hash` is same as in the sealer header - - - More than 2/3 (in voting power) validators in the validator set of this - - epoch have signed `app_hash` of the sealer header + next_key: + type: string + format: byte + description: |- + next_key is the key to be passed to PageRequest.key to + query the next page most efficiently. It will be empty if + there are no more results. + total: + type: string + format: uint64 + title: >- + total is total number of results available if + PageRequest.count_total - - The epoch metadata is committed to the `app_hash` of the sealer header + was set, its value is undefined otherwise + description: |- + PageResponse is to be embedded in gRPC response messages where the + corresponding request message has used PageRequest. - - The validator set is committed to the `app_hash` of the sealer header - babylon.zoneconcierge.v1.ProofFinalizedChainInfo: + message SomeResponse { + repeated Bar results = 1; + PageResponse page = 2; + } + title: |- + QueryEpochMsgsResponse is the response type for the Query/EpochMsgs RPC + method + babylon.epoching.v1.QueryEpochValSetResponse: type: object properties: - proof_cz_header_in_epoch: - title: >- - proof_cz_header_in_epoch is the proof that the CZ header is - timestamped - - within a certain epoch - type: object - properties: - ops: - type: array - items: - type: object - properties: - type: - type: string - key: - type: string - format: byte - data: - type: string - format: byte - title: |- - ProofOp defines an operation used for calculating Merkle root - The data could be arbitrary format, providing nessecary data - for example neighbouring node hash - proof_epoch_sealed: - title: proof_epoch_sealed is the proof that the epoch is sealed + validators: + type: array + items: + type: object + properties: + addr: + type: string + format: byte + title: addr is the validator's address (in sdk.ValAddress) + power: + type: string + format: int64 + title: power is the validator's voting power + title: Validator is a message that denotes a validator + total_voting_power: + type: string + format: int64 + pagination: type: object properties: - validator_set: - type: array - items: - type: object - properties: - validator_address: - type: string - title: validator_address is the address of the validator - bls_pub_key: - type: string - format: byte - title: bls_pub_key is the BLS public key of the validator - voting_power: - type: string - format: uint64 - title: >- - voting_power is the voting power of the validator at the - given epoch - title: >- - ValidatorWithBlsKey couples validator address, voting power, and - its bls - - public key - title: |- - validator_set is the validator set of the sealed epoch - This validator set has generated a BLS multisig on `app_hash` of - the sealer header - proof_epoch_info: - title: >- - proof_epoch_info is the Merkle proof that the epoch's metadata is - committed - - to `app_hash` of the sealer header - type: object - properties: - ops: - type: array - items: - type: object - properties: - type: - type: string - key: - type: string - format: byte - data: - type: string - format: byte - title: >- - ProofOp defines an operation used for calculating Merkle - root - - The data could be arbitrary format, providing nessecary data - - for example neighbouring node hash - proof_epoch_val_set: + next_key: + type: string + format: byte + description: |- + next_key is the key to be passed to PageRequest.key to + query the next page most efficiently. It will be empty if + there are no more results. + total: + type: string + format: uint64 title: >- - proof_epoch_info is the Merkle proof that the epoch's validator - set is - - committed to `app_hash` of the sealer header - type: object - properties: - ops: - type: array - items: - type: object - properties: - type: - type: string - key: - type: string - format: byte - data: - type: string - format: byte - title: >- - ProofOp defines an operation used for calculating Merkle - root + total is total number of results available if + PageRequest.count_total - The data could be arbitrary format, providing nessecary data + was set, its value is undefined otherwise + description: |- + PageResponse is to be embedded in gRPC response messages where the + corresponding request message has used PageRequest. - for example neighbouring node hash - proof_epoch_submitted: + message SomeResponse { + repeated Bar results = 1; + PageResponse page = 2; + } + title: |- + QueryEpochValSetRequest is the response type for the Query/EpochValSet RPC + method + babylon.epoching.v1.QueryEpochsInfoResponse: + type: object + properties: + epochs: type: array items: type: object properties: - key: - type: object - properties: - index: - type: integer - format: int64 - hash: - type: string - format: byte + epoch_number: + type: string + format: uint64 + title: epoch_number is the number of this epoch + current_epoch_interval: + type: string + format: uint64 title: >- - Each provided OP_RETURN transaction can be identified by hash of - block in - - which transaction was included and transaction index in the - block + current_epoch_interval is the epoch interval at the time of this + epoch + first_block_height: + type: string + format: uint64 + title: >- + first_block_height is the height of the first block in this + epoch + last_block_time: + type: string + format: date-time description: >- - key is the position (txIdx, blockHash) of this tx on BTC - blockchain - - Although it is already a part of SubmissionKey, we store it here - again - - to make TransactionInfo self-contained. - - For example, storing the key allows TransactionInfo to not relay - on + last_block_time is the time of the last block in this epoch. - the fact that TransactionInfo will be ordered in the same order - as + Babylon needs to remember the last header's time of each epoch + to complete - TransactionKeys in SubmissionKey. - transaction: - type: string - format: byte - title: transaction is the full transaction in bytes - proof: - type: string - format: byte - title: >- - proof is the Merkle proof that this tx is included in the - position in `key` + unbonding validators/delegations when a previous epoch's + checkpoint is - TODO: maybe it could use here better format as we already - processed and + finalised. The last_block_time field is nil in the epoch's + beginning, and - validated the proof? - title: |- - TransactionInfo is the info of a tx on Bitcoin, - including - - the position of the tx on BTC blockchain - - the full tx content - - the Merkle proof that this tx is on the above position - title: >- - proof_epoch_submitted is the proof that the epoch's checkpoint is - included + is set upon the end of this epoch. + sealer_app_hash_hex: + type: string + description: >- + sealer is the last block of the sealed epoch - in BTC ledger It is the two TransactionInfo in the best (i.e., - earliest) + sealer_app_hash points to the sealer but stored in the 1st + header - checkpoint submission - title: |- - ProofFinalizedChainInfo is a set of proofs that attest a chain info is - BTC-finalised - babylon.zoneconcierge.v1.QueryChainListResponse: - type: object - properties: - consumer_ids: - type: array - items: - type: string - title: consumer_ids are IDs of the chains in ascending alphabetical order + of the next epoch as hex string. + sealer_block_hash: + type: string + description: |- + sealer_block_hash is the hash of the sealer + the validator set has generated a BLS multisig on the hash, + i.e., hash of the last block in the epoch as hex string. + title: EpochResponse is a structure that contains the metadata of an epoch pagination: title: pagination defines the pagination in the response type: object @@ -12508,1127 +6356,451 @@ definitions: repeated Bar results = 1; PageResponse page = 2; } - title: QueryChainListResponse is response type for the Query/ChainList RPC method - babylon.zoneconcierge.v1.QueryChainsInfoResponse: + title: >- + QueryEpochsInfoResponse is the response type for the Query/EpochInfos + method + babylon.epoching.v1.QueryLatestEpochMsgsResponse: type: object properties: - chains_info: + latest_epoch_msgs: type: array items: type: object properties: - consumer_id: + epoch_number: type: string - title: consumer_id is the ID of the consumer - latest_header: - type: object - properties: - consumer_id: - type: string - title: consumer_id is the unique ID of the consumer - hash: - type: string - format: byte - title: hash is the hash of this header - height: - type: string - format: uint64 - title: >- - height is the height of this header on CZ ledger - - (hash, height) jointly provides the position of the header - on CZ ledger - time: - type: string - format: date-time - title: >- - time is the timestamp of this header on CZ ledger - - it is needed for CZ to unbond all mature - validators/delegations - - before this timestamp when this header is BTC-finalised - babylon_header_hash: - type: string - format: byte - title: >- - babylon_header_hash is the hash of the babylon block that - includes this CZ - - header - babylon_header_height: - type: string - format: uint64 - title: >- - babylon_header_height is the height of the babylon block - that includes this CZ - - header - babylon_epoch: - type: string - format: uint64 - title: epoch is the epoch number of this header on Babylon ledger - babylon_tx_hash: - type: string - format: byte - title: >- - babylon_tx_hash is the hash of the tx that includes this - header - - (babylon_block_height, babylon_tx_hash) jointly provides the - position of - - the header on Babylon ledger - title: IndexedHeader is the metadata of a CZ header - latest_forks: - type: object - properties: - headers: - type: array - items: - type: object - properties: - consumer_id: - type: string - title: consumer_id is the unique ID of the consumer - hash: - type: string - format: byte - title: hash is the hash of this header - height: - type: string - format: uint64 - title: >- - height is the height of this header on CZ ledger - - (hash, height) jointly provides the position of the - header on CZ ledger - time: - type: string - format: date-time - title: >- - time is the timestamp of this header on CZ ledger - - it is needed for CZ to unbond all mature - validators/delegations - - before this timestamp when this header is - BTC-finalised - babylon_header_hash: - type: string - format: byte - title: >- - babylon_header_hash is the hash of the babylon block - that includes this CZ - - header - babylon_header_height: - type: string - format: uint64 - title: >- - babylon_header_height is the height of the babylon - block that includes this CZ - - header - babylon_epoch: - type: string - format: uint64 - title: >- - epoch is the epoch number of this header on Babylon - ledger - babylon_tx_hash: - type: string - format: byte - title: >- - babylon_tx_hash is the hash of the tx that includes - this header - - (babylon_block_height, babylon_tx_hash) jointly - provides the position of - - the header on Babylon ledger - title: IndexedHeader is the metadata of a CZ header - title: >- - blocks is the list of non-canonical indexed headers at the - same height - description: >- - Forks is a list of non-canonical `IndexedHeader`s at the same - height. - - For example, assuming the following blockchain - - ``` - - A <- B <- C <- D <- E - \ -- D1 - \ -- D2 - ``` - - Then the fork will be {[D1, D2]} where each item is in struct - `IndexedBlock`. - - - Note that each `IndexedHeader` in the fork should have a valid - quorum - - certificate. Such forks exist since Babylon considers CZs might - have + format: uint64 + msgs: + type: array + items: + type: object + properties: + tx_id: + type: string + description: >- + tx_id is the ID of the tx that contains the message as + hex. + msg_id: + type: string + description: >- + msg_id is the original message ID, i.e., hash of the + marshaled message as hex. + block_height: + type: string + format: uint64 + title: >- + block_height is the height when this msg is submitted to + Babylon + block_time: + type: string + format: date-time + title: >- + block_time is the timestamp when this msg is submitted to + Babylon + msg: + type: string + description: >- + msg is the actual message that is sent by a user and is + queued by the - dishonest majority. Also note that the IBC-Go implementation - will only + epoching module as string. + title: >- + QueuedMessageResponse is a message that can change the + validator set and is delayed - consider the first header in a fork valid, since the subsequent - headers + to the end of an epoch + title: >- + QueuedMessageList is a message that contains a list of + staking-related - cannot be verified without knowing the validator set in the - previous header. - title: >- - latest_forks is the latest forks, formed as a series of - IndexedHeader (from + messages queued for an epoch + title: |- + latest_epoch_msgs is a list of QueuedMessageList + each QueuedMessageList has a field identifying the epoch number + pagination: + type: object + properties: + next_key: + type: string + format: byte + description: |- + next_key is the key to be passed to PageRequest.key to + query the next page most efficiently. It will be empty if + there are no more results. + total: + type: string + format: uint64 + title: >- + total is total number of results available if + PageRequest.count_total - low to high) - timestamped_headers_count: - type: string - format: uint64 - title: >- - timestamped_headers_count is the number of timestamped headers - in CZ's + was set, its value is undefined otherwise + description: |- + PageResponse is to be embedded in gRPC response messages where the + corresponding request message has used PageRequest. - canonical chain - title: ChainInfo is the information of a CZ - description: >- - QueryChainsInfoResponse is response type for the Query/ChainsInfo RPC - method. - babylon.zoneconcierge.v1.QueryEpochChainsInfoResponse: + message SomeResponse { + repeated Bar results = 1; + PageResponse page = 2; + } + title: |- + QueryLatestEpochMsgsResponse is the response type for the + Query/LatestEpochMsgs RPC method + babylon.epoching.v1.QueryParamsResponse: type: object properties: - chains_info: + params: + description: params holds all the parameters of this module. + type: object + properties: + epoch_interval: + type: string + format: uint64 + title: >- + epoch_interval is the number of consecutive blocks to form an + epoch + description: QueryParamsResponse is the response type for the Query/Params RPC method. + babylon.epoching.v1.QueryValidatorLifecycleResponse: + type: object + properties: + val_addr: + type: string + val_life: type: array items: type: object properties: - consumer_id: - type: string - title: consumer_id is the ID of the consumer - latest_header: - type: object - properties: - consumer_id: - type: string - title: consumer_id is the unique ID of the consumer - hash: - type: string - format: byte - title: hash is the hash of this header - height: - type: string - format: uint64 - title: >- - height is the height of this header on CZ ledger - - (hash, height) jointly provides the position of the header - on CZ ledger - time: - type: string - format: date-time - title: >- - time is the timestamp of this header on CZ ledger - - it is needed for CZ to unbond all mature - validators/delegations - - before this timestamp when this header is BTC-finalised - babylon_header_hash: - type: string - format: byte - title: >- - babylon_header_hash is the hash of the babylon block that - includes this CZ - - header - babylon_header_height: - type: string - format: uint64 - title: >- - babylon_header_height is the height of the babylon block - that includes this CZ - - header - babylon_epoch: - type: string - format: uint64 - title: epoch is the epoch number of this header on Babylon ledger - babylon_tx_hash: - type: string - format: byte - title: >- - babylon_tx_hash is the hash of the tx that includes this - header - - (babylon_block_height, babylon_tx_hash) jointly provides the - position of - - the header on Babylon ledger - title: IndexedHeader is the metadata of a CZ header - latest_forks: - type: object - properties: - headers: - type: array - items: - type: object - properties: - consumer_id: - type: string - title: consumer_id is the unique ID of the consumer - hash: - type: string - format: byte - title: hash is the hash of this header - height: - type: string - format: uint64 - title: >- - height is the height of this header on CZ ledger - - (hash, height) jointly provides the position of the - header on CZ ledger - time: - type: string - format: date-time - title: >- - time is the timestamp of this header on CZ ledger - - it is needed for CZ to unbond all mature - validators/delegations - - before this timestamp when this header is - BTC-finalised - babylon_header_hash: - type: string - format: byte - title: >- - babylon_header_hash is the hash of the babylon block - that includes this CZ - - header - babylon_header_height: - type: string - format: uint64 - title: >- - babylon_header_height is the height of the babylon - block that includes this CZ - - header - babylon_epoch: - type: string - format: uint64 - title: >- - epoch is the epoch number of this header on Babylon - ledger - babylon_tx_hash: - type: string - format: byte - title: >- - babylon_tx_hash is the hash of the tx that includes - this header - - (babylon_block_height, babylon_tx_hash) jointly - provides the position of - - the header on Babylon ledger - title: IndexedHeader is the metadata of a CZ header - title: >- - blocks is the list of non-canonical indexed headers at the - same height + state_desc: + type: string + description: StateDesc defines the descriptive state. + block_height: + type: string + format: uint64 + block_time: + type: string + format: date-time + description: >- + ValStateUpdateResponse is a message response that records a state + update of a validator. + title: |- + QueryValidatorLifecycleResponse is the response type for the + Query/ValidatorLifecycle RPC method + babylon.epoching.v1.QueuedMessageList: + type: object + properties: + epoch_number: + type: string + format: uint64 + msgs: + type: array + items: + type: object + properties: + tx_id: + type: string + description: tx_id is the ID of the tx that contains the message as hex. + msg_id: + type: string description: >- - Forks is a list of non-canonical `IndexedHeader`s at the same - height. - - For example, assuming the following blockchain - - ``` - - A <- B <- C <- D <- E - \ -- D1 - \ -- D2 - ``` - - Then the fork will be {[D1, D2]} where each item is in struct - `IndexedBlock`. - - - Note that each `IndexedHeader` in the fork should have a valid - quorum - - certificate. Such forks exist since Babylon considers CZs might - have - - dishonest majority. Also note that the IBC-Go implementation - will only - - consider the first header in a fork valid, since the subsequent - headers - - cannot be verified without knowing the validator set in the - previous header. - title: >- - latest_forks is the latest forks, formed as a series of - IndexedHeader (from - - low to high) - timestamped_headers_count: + msg_id is the original message ID, i.e., hash of the marshaled + message as hex. + block_height: type: string format: uint64 + title: block_height is the height when this msg is submitted to Babylon + block_time: + type: string + format: date-time title: >- - timestamped_headers_count is the number of timestamped headers - in CZ's + block_time is the timestamp when this msg is submitted to + Babylon + msg: + type: string + description: >- + msg is the actual message that is sent by a user and is queued + by the - canonical chain - title: ChainInfo is the information of a CZ - title: chain_info is the info of the CZ - description: >- - QueryEpochChainsInfoResponse is response type for the - Query/EpochChainsInfo RPC + epoching module as string. + title: >- + QueuedMessageResponse is a message that can change the validator set + and is delayed - method. - babylon.zoneconcierge.v1.QueryFinalizedChainInfoUntilHeightResponse: + to the end of an epoch + title: |- + QueuedMessageList is a message that contains a list of staking-related + messages queued for an epoch + babylon.epoching.v1.QueuedMessageResponse: type: object properties: - finalized_chain_info: - type: object - properties: - consumer_id: - type: string - title: consumer_id is the ID of the consumer - latest_header: - type: object - properties: - consumer_id: - type: string - title: consumer_id is the unique ID of the consumer - hash: - type: string - format: byte - title: hash is the hash of this header - height: - type: string - format: uint64 - title: >- - height is the height of this header on CZ ledger - - (hash, height) jointly provides the position of the header on - CZ ledger - time: - type: string - format: date-time - title: >- - time is the timestamp of this header on CZ ledger - - it is needed for CZ to unbond all mature - validators/delegations - - before this timestamp when this header is BTC-finalised - babylon_header_hash: - type: string - format: byte - title: >- - babylon_header_hash is the hash of the babylon block that - includes this CZ - - header - babylon_header_height: - type: string - format: uint64 - title: >- - babylon_header_height is the height of the babylon block that - includes this CZ - - header - babylon_epoch: - type: string - format: uint64 - title: epoch is the epoch number of this header on Babylon ledger - babylon_tx_hash: - type: string - format: byte - title: >- - babylon_tx_hash is the hash of the tx that includes this - header - - (babylon_block_height, babylon_tx_hash) jointly provides the - position of - - the header on Babylon ledger - title: IndexedHeader is the metadata of a CZ header - latest_forks: - type: object - properties: - headers: - type: array - items: - type: object - properties: - consumer_id: - type: string - title: consumer_id is the unique ID of the consumer - hash: - type: string - format: byte - title: hash is the hash of this header - height: - type: string - format: uint64 - title: >- - height is the height of this header on CZ ledger - - (hash, height) jointly provides the position of the - header on CZ ledger - time: - type: string - format: date-time - title: >- - time is the timestamp of this header on CZ ledger - - it is needed for CZ to unbond all mature - validators/delegations - - before this timestamp when this header is BTC-finalised - babylon_header_hash: - type: string - format: byte - title: >- - babylon_header_hash is the hash of the babylon block - that includes this CZ - - header - babylon_header_height: - type: string - format: uint64 - title: >- - babylon_header_height is the height of the babylon block - that includes this CZ - - header - babylon_epoch: - type: string - format: uint64 - title: >- - epoch is the epoch number of this header on Babylon - ledger - babylon_tx_hash: - type: string - format: byte - title: >- - babylon_tx_hash is the hash of the tx that includes this - header - - (babylon_block_height, babylon_tx_hash) jointly provides - the position of - - the header on Babylon ledger - title: IndexedHeader is the metadata of a CZ header - title: >- - blocks is the list of non-canonical indexed headers at the - same height - description: >- - Forks is a list of non-canonical `IndexedHeader`s at the same - height. - - For example, assuming the following blockchain - - ``` - - A <- B <- C <- D <- E - \ -- D1 - \ -- D2 - ``` - - Then the fork will be {[D1, D2]} where each item is in struct - `IndexedBlock`. + tx_id: + type: string + description: tx_id is the ID of the tx that contains the message as hex. + msg_id: + type: string + description: >- + msg_id is the original message ID, i.e., hash of the marshaled message + as hex. + block_height: + type: string + format: uint64 + title: block_height is the height when this msg is submitted to Babylon + block_time: + type: string + format: date-time + title: block_time is the timestamp when this msg is submitted to Babylon + msg: + type: string + description: |- + msg is the actual message that is sent by a user and is queued by the + epoching module as string. + title: >- + QueuedMessageResponse is a message that can change the validator set and + is delayed + to the end of an epoch + babylon.epoching.v1.ValStateUpdateResponse: + type: object + properties: + state_desc: + type: string + description: StateDesc defines the descriptive state. + block_height: + type: string + format: uint64 + block_time: + type: string + format: date-time + description: >- + ValStateUpdateResponse is a message response that records a state update + of a validator. + babylon.epoching.v1.Validator: + type: object + properties: + addr: + type: string + format: byte + title: addr is the validator's address (in sdk.ValAddress) + power: + type: string + format: int64 + title: power is the validator's voting power + title: Validator is a message that denotes a validator + cosmos.base.v1beta1.Coin: + type: object + properties: + denom: + type: string + amount: + type: string + description: |- + Coin defines a token with a denomination and an amount. - Note that each `IndexedHeader` in the fork should have a valid - quorum + NOTE: The amount field is an Int which implements the custom method + signatures required by gogoproto. + babylon.checkpointing.v1.BlsPublicKeyListResponse: + type: object + properties: + validator_address: + type: string + title: validator_address is the address of the validator + bls_pub_key_hex: + type: string + title: bls_pub_key is the BLS public key of the validator + voting_power: + type: string + format: uint64 + title: voting_power is the voting power of the validator at the given epoch + title: >- + BlsPublicKeyListResponse couples validator address, voting power, and its + bls - certificate. Such forks exist since Babylon considers CZs might - have + public key + babylon.checkpointing.v1.CheckpointStateUpdateResponse: + type: object + properties: + state: + type: string + enum: + - CKPT_STATUS_ACCUMULATING + - CKPT_STATUS_SEALED + - CKPT_STATUS_SUBMITTED + - CKPT_STATUS_CONFIRMED + - CKPT_STATUS_FINALIZED + default: CKPT_STATUS_ACCUMULATING + description: |- + CheckpointStatus is the status of a checkpoint. - dishonest majority. Also note that the IBC-Go implementation will - only + - CKPT_STATUS_ACCUMULATING: ACCUMULATING defines a checkpoint that is awaiting for BLS signatures. + - CKPT_STATUS_SEALED: SEALED defines a checkpoint that has accumulated sufficient BLS signatures. + - CKPT_STATUS_SUBMITTED: SUBMITTED defines a checkpoint that is included on BTC. + - CKPT_STATUS_CONFIRMED: CONFIRMED defines a checkpoint that is k-deep on BTC. + - CKPT_STATUS_FINALIZED: FINALIZED defines a checkpoint that is w-deep on BTC. + title: state defines the event of a state transition towards this state + status_desc: + type: string + description: status_desc represents the description of status enum. + block_height: + type: string + format: uint64 + title: >- + block_height is the height of the Babylon block that triggers the + state - consider the first header in a fork valid, since the subsequent - headers + update + block_time: + type: string + format: date-time + title: >- + block_time is the timestamp in the Babylon block that triggers the + state - cannot be verified without knowing the validator set in the - previous header. - title: >- - latest_forks is the latest forks, formed as a series of - IndexedHeader (from + update + description: >- + CheckpointStateUpdateResponse defines a state transition on the + checkpoint. + babylon.checkpointing.v1.CheckpointStatus: + type: string + enum: + - CKPT_STATUS_ACCUMULATING + - CKPT_STATUS_SEALED + - CKPT_STATUS_SUBMITTED + - CKPT_STATUS_CONFIRMED + - CKPT_STATUS_FINALIZED + default: CKPT_STATUS_ACCUMULATING + description: |- + CheckpointStatus is the status of a checkpoint. - low to high) - timestamped_headers_count: - type: string - format: uint64 - title: >- - timestamped_headers_count is the number of timestamped headers in - CZ's + - CKPT_STATUS_ACCUMULATING: ACCUMULATING defines a checkpoint that is awaiting for BLS signatures. + - CKPT_STATUS_SEALED: SEALED defines a checkpoint that has accumulated sufficient BLS signatures. + - CKPT_STATUS_SUBMITTED: SUBMITTED defines a checkpoint that is included on BTC. + - CKPT_STATUS_CONFIRMED: CONFIRMED defines a checkpoint that is k-deep on BTC. + - CKPT_STATUS_FINALIZED: FINALIZED defines a checkpoint that is w-deep on BTC. + babylon.checkpointing.v1.QueryBlsPublicKeyListResponse: + type: object + properties: + validator_with_bls_keys: + type: array + items: + type: object + properties: + validator_address: + type: string + title: validator_address is the address of the validator + bls_pub_key_hex: + type: string + title: bls_pub_key is the BLS public key of the validator + voting_power: + type: string + format: uint64 + title: >- + voting_power is the voting power of the validator at the given + epoch + title: >- + BlsPublicKeyListResponse couples validator address, voting power, + and its bls - canonical chain - title: ChainInfo is the information of a CZ - epoch_info: - title: epoch_info is the metadata of the last BTC-finalised epoch + public key + pagination: + description: pagination defines the pagination in the response. type: object properties: - epoch_number: + next_key: type: string - format: uint64 - title: epoch_number is the number of this epoch - current_epoch_interval: + format: byte + description: |- + next_key is the key to be passed to PageRequest.key to + query the next page most efficiently. It will be empty if + there are no more results. + total: type: string format: uint64 title: >- - current_epoch_interval is the epoch interval at the time of this - epoch - first_block_height: - type: string - format: uint64 - title: first_block_height is the height of the first block in this epoch - last_block_time: - type: string - format: date-time - description: >- - last_block_time is the time of the last block in this epoch. - - Babylon needs to remember the last header's time of each epoch to - complete - - unbonding validators/delegations when a previous epoch's - checkpoint is + total is total number of results available if + PageRequest.count_total - finalised. The last_block_time field is nil in the epoch's - beginning, and + was set, its value is undefined otherwise + description: |- + QueryBlsPublicKeyListResponse is the response type for the + Query/BlsPublicKeys RPC method. + babylon.checkpointing.v1.QueryEpochStatusResponse: + type: object + properties: + status: + type: string + enum: + - CKPT_STATUS_ACCUMULATING + - CKPT_STATUS_SEALED + - CKPT_STATUS_SUBMITTED + - CKPT_STATUS_CONFIRMED + - CKPT_STATUS_FINALIZED + default: CKPT_STATUS_ACCUMULATING + description: |- + CheckpointStatus is the status of a checkpoint. - is set upon the end of this epoch. - sealer_app_hash: - type: string - format: byte - title: |- - sealer is the last block of the sealed epoch - sealer_app_hash points to the sealer but stored in the 1st header - of the next epoch - sealer_block_hash: - type: string - format: byte - title: |- - sealer_block_hash is the hash of the sealer - the validator set has generated a BLS multisig on the hash, - i.e., hash of the last block in the epoch + - CKPT_STATUS_ACCUMULATING: ACCUMULATING defines a checkpoint that is awaiting for BLS signatures. + - CKPT_STATUS_SEALED: SEALED defines a checkpoint that has accumulated sufficient BLS signatures. + - CKPT_STATUS_SUBMITTED: SUBMITTED defines a checkpoint that is included on BTC. + - CKPT_STATUS_CONFIRMED: CONFIRMED defines a checkpoint that is k-deep on BTC. + - CKPT_STATUS_FINALIZED: FINALIZED defines a checkpoint that is w-deep on BTC. + description: |- + QueryEpochStatusResponse is the response type for the Query/EpochStatus + RPC method. + babylon.checkpointing.v1.QueryLastCheckpointWithStatusResponse: + type: object + properties: raw_checkpoint: - title: raw_checkpoint is the raw checkpoint of this epoch type: object properties: epoch_num: type: string format: uint64 title: epoch_num defines the epoch number the raw checkpoint is for - block_hash: + block_hash_hex: type: string - format: byte title: |- - block_hash defines the 'BlockID.Hash', which is the hash of - the block that individual BLS sigs are signed on + block_hash_hex defines the 'BlockID.Hash', which is the hash of + the block that individual BLS sigs are signed on as hex string bitmap: type: string format: byte title: >- - bitmap defines the bitmap that indicates the signers of the BLS - multi sig - bls_multi_sig: - type: string - format: byte - title: >- - bls_multi_sig defines the multi sig that is aggregated from - individual BLS - - sigs - btc_submission_key: - title: |- - btc_submission_key is position of two BTC txs that include the raw - checkpoint of this epoch - type: object - properties: - key: - type: array - items: - type: object - properties: - index: - type: integer - format: int64 - hash: - type: string - format: byte - title: >- - Each provided OP_RETURN transaction can be identified by hash of - block in - - which transaction was included and transaction index in the - block - proof: - title: proof is the proof that the chain info is finalized - type: object - properties: - proof_cz_header_in_epoch: - title: >- - proof_cz_header_in_epoch is the proof that the CZ header is - timestamped - - within a certain epoch - type: object - properties: - ops: - type: array - items: - type: object - properties: - type: - type: string - key: - type: string - format: byte - data: - type: string - format: byte - title: >- - ProofOp defines an operation used for calculating Merkle - root - - The data could be arbitrary format, providing nessecary data - - for example neighbouring node hash - proof_epoch_sealed: - title: proof_epoch_sealed is the proof that the epoch is sealed - type: object - properties: - validator_set: - type: array - items: - type: object - properties: - validator_address: - type: string - title: validator_address is the address of the validator - bls_pub_key: - type: string - format: byte - title: bls_pub_key is the BLS public key of the validator - voting_power: - type: string - format: uint64 - title: >- - voting_power is the voting power of the validator at the - given epoch - title: >- - ValidatorWithBlsKey couples validator address, voting power, - and its bls - - public key - title: >- - validator_set is the validator set of the sealed epoch - - This validator set has generated a BLS multisig on `app_hash` - of - - the sealer header - proof_epoch_info: - title: >- - proof_epoch_info is the Merkle proof that the epoch's metadata - is committed - - to `app_hash` of the sealer header - type: object - properties: - ops: - type: array - items: - type: object - properties: - type: - type: string - key: - type: string - format: byte - data: - type: string - format: byte - title: >- - ProofOp defines an operation used for calculating Merkle - root - - The data could be arbitrary format, providing nessecary - data - - for example neighbouring node hash - proof_epoch_val_set: - title: >- - proof_epoch_info is the Merkle proof that the epoch's - validator set is - - committed to `app_hash` of the sealer header - type: object - properties: - ops: - type: array - items: - type: object - properties: - type: - type: string - key: - type: string - format: byte - data: - type: string - format: byte - title: >- - ProofOp defines an operation used for calculating Merkle - root - - The data could be arbitrary format, providing nessecary - data - - for example neighbouring node hash - proof_epoch_submitted: - type: array - items: - type: object - properties: - key: - type: object - properties: - index: - type: integer - format: int64 - hash: - type: string - format: byte - title: >- - Each provided OP_RETURN transaction can be identified by - hash of block in - - which transaction was included and transaction index in the - block - description: >- - key is the position (txIdx, blockHash) of this tx on BTC - blockchain - - Although it is already a part of SubmissionKey, we store it - here again - - to make TransactionInfo self-contained. - - For example, storing the key allows TransactionInfo to not - relay on - - the fact that TransactionInfo will be ordered in the same - order as - - TransactionKeys in SubmissionKey. - transaction: - type: string - format: byte - title: transaction is the full transaction in bytes - proof: - type: string - format: byte - title: >- - proof is the Merkle proof that this tx is included in the - position in `key` - - TODO: maybe it could use here better format as we already - processed and - - validated the proof? - title: |- - TransactionInfo is the info of a tx on Bitcoin, - including - - the position of the tx on BTC blockchain - - the full tx content - - the Merkle proof that this tx is on the above position - title: >- - proof_epoch_submitted is the proof that the epoch's checkpoint is - included - - in BTC ledger It is the two TransactionInfo in the best (i.e., - earliest) + bitmap defines the bitmap that indicates the signers of the BLS + multi sig + bls_multi_sig: + type: string + format: byte + title: >- + bls_multi_sig defines the multi sig that is aggregated from + individual BLS - checkpoint submission + sigs + title: RawCheckpointResponse wraps the BLS multi sig with metadata description: |- - QueryFinalizedChainInfoUntilHeightResponse is response type for the - Query/FinalizedChainInfoUntilHeight RPC method. - babylon.zoneconcierge.v1.QueryFinalizedChainsInfoResponse: + QueryLastCheckpointWithStatusResponse is the response type for the + Query/LastCheckpointWithStatus RPC method. + babylon.checkpointing.v1.QueryRawCheckpointListResponse: type: object properties: - finalized_chains_info: + raw_checkpoints: type: array items: type: object properties: - consumer_id: - type: string - title: consumer_id is the ID of the consumer - finalized_chain_info: - type: object - properties: - consumer_id: - type: string - title: consumer_id is the ID of the consumer - latest_header: - type: object - properties: - consumer_id: - type: string - title: consumer_id is the unique ID of the consumer - hash: - type: string - format: byte - title: hash is the hash of this header - height: - type: string - format: uint64 - title: >- - height is the height of this header on CZ ledger - - (hash, height) jointly provides the position of the - header on CZ ledger - time: - type: string - format: date-time - title: >- - time is the timestamp of this header on CZ ledger - - it is needed for CZ to unbond all mature - validators/delegations - - before this timestamp when this header is BTC-finalised - babylon_header_hash: - type: string - format: byte - title: >- - babylon_header_hash is the hash of the babylon block - that includes this CZ - - header - babylon_header_height: - type: string - format: uint64 - title: >- - babylon_header_height is the height of the babylon block - that includes this CZ - - header - babylon_epoch: - type: string - format: uint64 - title: >- - epoch is the epoch number of this header on Babylon - ledger - babylon_tx_hash: - type: string - format: byte - title: >- - babylon_tx_hash is the hash of the tx that includes this - header - - (babylon_block_height, babylon_tx_hash) jointly provides - the position of - - the header on Babylon ledger - title: IndexedHeader is the metadata of a CZ header - latest_forks: - type: object - properties: - headers: - type: array - items: - type: object - properties: - consumer_id: - type: string - title: consumer_id is the unique ID of the consumer - hash: - type: string - format: byte - title: hash is the hash of this header - height: - type: string - format: uint64 - title: >- - height is the height of this header on CZ ledger - - (hash, height) jointly provides the position of - the header on CZ ledger - time: - type: string - format: date-time - title: >- - time is the timestamp of this header on CZ ledger - - it is needed for CZ to unbond all mature - validators/delegations - - before this timestamp when this header is - BTC-finalised - babylon_header_hash: - type: string - format: byte - title: >- - babylon_header_hash is the hash of the babylon - block that includes this CZ - - header - babylon_header_height: - type: string - format: uint64 - title: >- - babylon_header_height is the height of the babylon - block that includes this CZ - - header - babylon_epoch: - type: string - format: uint64 - title: >- - epoch is the epoch number of this header on - Babylon ledger - babylon_tx_hash: - type: string - format: byte - title: >- - babylon_tx_hash is the hash of the tx that - includes this header - - (babylon_block_height, babylon_tx_hash) jointly - provides the position of - - the header on Babylon ledger - title: IndexedHeader is the metadata of a CZ header - title: >- - blocks is the list of non-canonical indexed headers at - the same height - description: >- - Forks is a list of non-canonical `IndexedHeader`s at the - same height. - - For example, assuming the following blockchain - - ``` - - A <- B <- C <- D <- E - \ -- D1 - \ -- D2 - ``` - - Then the fork will be {[D1, D2]} where each item is in - struct `IndexedBlock`. - - - Note that each `IndexedHeader` in the fork should have a - valid quorum - - certificate. Such forks exist since Babylon considers CZs - might have - - dishonest majority. Also note that the IBC-Go implementation - will only - - consider the first header in a fork valid, since the - subsequent headers - - cannot be verified without knowing the validator set in the - previous header. - title: >- - latest_forks is the latest forks, formed as a series of - IndexedHeader (from - - low to high) - timestamped_headers_count: - type: string - format: uint64 - title: >- - timestamped_headers_count is the number of timestamped - headers in CZ's - - canonical chain - title: ChainInfo is the information of a CZ - epoch_info: - title: epoch_info is the metadata of the last BTC-finalised epoch - type: object - properties: - epoch_number: - type: string - format: uint64 - title: epoch_number is the number of this epoch - current_epoch_interval: - type: string - format: uint64 - title: >- - current_epoch_interval is the epoch interval at the time of - this epoch - first_block_height: - type: string - format: uint64 - title: >- - first_block_height is the height of the first block in this - epoch - last_block_time: - type: string - format: date-time - description: >- - last_block_time is the time of the last block in this epoch. - - Babylon needs to remember the last header's time of each - epoch to complete - - unbonding validators/delegations when a previous epoch's - checkpoint is - - finalised. The last_block_time field is nil in the epoch's - beginning, and - - is set upon the end of this epoch. - sealer_app_hash: - type: string - format: byte - title: >- - sealer is the last block of the sealed epoch - - sealer_app_hash points to the sealer but stored in the 1st - header - - of the next epoch - sealer_block_hash: - type: string - format: byte - title: |- - sealer_block_hash is the hash of the sealer - the validator set has generated a BLS multisig on the hash, - i.e., hash of the last block in the epoch - raw_checkpoint: - title: raw_checkpoint is the raw checkpoint of this epoch + ckpt: type: object properties: epoch_num: type: string format: uint64 title: epoch_num defines the epoch number the raw checkpoint is for - block_hash: + block_hash_hex: type: string - format: byte - title: |- - block_hash defines the 'BlockID.Hash', which is the hash of - the block that individual BLS sigs are signed on + title: >- + block_hash_hex defines the 'BlockID.Hash', which is the hash + of + + the block that individual BLS sigs are signed on as hex + string bitmap: type: string format: byte @@ -13643,511 +6815,374 @@ definitions: individual BLS sigs - btc_submission_key: + title: RawCheckpointResponse wraps the BLS multi sig with metadata + status: + type: string + enum: + - CKPT_STATUS_ACCUMULATING + - CKPT_STATUS_SEALED + - CKPT_STATUS_SUBMITTED + - CKPT_STATUS_CONFIRMED + - CKPT_STATUS_FINALIZED + default: CKPT_STATUS_ACCUMULATING + description: |- + CheckpointStatus is the status of a checkpoint. + + - CKPT_STATUS_ACCUMULATING: ACCUMULATING defines a checkpoint that is awaiting for BLS signatures. + - CKPT_STATUS_SEALED: SEALED defines a checkpoint that has accumulated sufficient BLS signatures. + - CKPT_STATUS_SUBMITTED: SUBMITTED defines a checkpoint that is included on BTC. + - CKPT_STATUS_CONFIRMED: CONFIRMED defines a checkpoint that is k-deep on BTC. + - CKPT_STATUS_FINALIZED: FINALIZED defines a checkpoint that is w-deep on BTC. + title: status defines the status of the checkpoint + status_desc: + type: string + description: status_desc represents the description of status enum. + bls_aggr_pk: + type: string + format: byte + title: bls_aggr_pk defines the aggregated BLS public key + power_sum: + type: string + format: uint64 title: >- - btc_submission_key is position of two BTC txs that include the - raw + power_sum defines the accumulated voting power for the + checkpoint + lifecycle: + type: array + items: + type: object + properties: + state: + type: string + enum: + - CKPT_STATUS_ACCUMULATING + - CKPT_STATUS_SEALED + - CKPT_STATUS_SUBMITTED + - CKPT_STATUS_CONFIRMED + - CKPT_STATUS_FINALIZED + default: CKPT_STATUS_ACCUMULATING + description: |- + CheckpointStatus is the status of a checkpoint. - checkpoint of this epoch - type: object - properties: - key: - type: array - items: - type: object - properties: - index: - type: integer - format: int64 - hash: - type: string - format: byte + - CKPT_STATUS_ACCUMULATING: ACCUMULATING defines a checkpoint that is awaiting for BLS signatures. + - CKPT_STATUS_SEALED: SEALED defines a checkpoint that has accumulated sufficient BLS signatures. + - CKPT_STATUS_SUBMITTED: SUBMITTED defines a checkpoint that is included on BTC. + - CKPT_STATUS_CONFIRMED: CONFIRMED defines a checkpoint that is k-deep on BTC. + - CKPT_STATUS_FINALIZED: FINALIZED defines a checkpoint that is w-deep on BTC. title: >- - Each provided OP_RETURN transaction can be identified by - hash of block in - - which transaction was included and transaction index in - the block - proof: - title: proof is the proof that the chain info is finalized - type: object - properties: - proof_cz_header_in_epoch: - title: >- - proof_cz_header_in_epoch is the proof that the CZ header is - timestamped - - within a certain epoch - type: object - properties: - ops: - type: array - items: - type: object - properties: - type: - type: string - key: - type: string - format: byte - data: - type: string - format: byte - title: >- - ProofOp defines an operation used for calculating - Merkle root - - The data could be arbitrary format, providing - nessecary data - - for example neighbouring node hash - proof_epoch_sealed: - title: proof_epoch_sealed is the proof that the epoch is sealed - type: object - properties: - validator_set: - type: array - items: - type: object - properties: - validator_address: - type: string - title: validator_address is the address of the validator - bls_pub_key: - type: string - format: byte - title: bls_pub_key is the BLS public key of the validator - voting_power: - type: string - format: uint64 - title: >- - voting_power is the voting power of the validator - at the given epoch - title: >- - ValidatorWithBlsKey couples validator address, voting - power, and its bls - - public key - title: >- - validator_set is the validator set of the sealed epoch - - This validator set has generated a BLS multisig on - `app_hash` of - - the sealer header - proof_epoch_info: - title: >- - proof_epoch_info is the Merkle proof that the epoch's - metadata is committed - - to `app_hash` of the sealer header - type: object - properties: - ops: - type: array - items: - type: object - properties: - type: - type: string - key: - type: string - format: byte - data: - type: string - format: byte - title: >- - ProofOp defines an operation used for calculating - Merkle root - - The data could be arbitrary format, providing - nessecary data - - for example neighbouring node hash - proof_epoch_val_set: - title: >- - proof_epoch_info is the Merkle proof that the epoch's - validator set is - - committed to `app_hash` of the sealer header - type: object - properties: - ops: - type: array - items: - type: object - properties: - type: - type: string - key: - type: string - format: byte - data: - type: string - format: byte - title: >- - ProofOp defines an operation used for calculating - Merkle root - - The data could be arbitrary format, providing - nessecary data - - for example neighbouring node hash - proof_epoch_submitted: - type: array - items: - type: object - properties: - key: - type: object - properties: - index: - type: integer - format: int64 - hash: - type: string - format: byte - title: >- - Each provided OP_RETURN transaction can be identified - by hash of block in - - which transaction was included and transaction index - in the block - description: >- - key is the position (txIdx, blockHash) of this tx on - BTC blockchain - - Although it is already a part of SubmissionKey, we - store it here again - - to make TransactionInfo self-contained. - - For example, storing the key allows TransactionInfo to - not relay on + state defines the event of a state transition towards this + state + status_desc: + type: string + description: status_desc represents the description of status enum. + block_height: + type: string + format: uint64 + title: >- + block_height is the height of the Babylon block that + triggers the state - the fact that TransactionInfo will be ordered in the - same order as + update + block_time: + type: string + format: date-time + title: >- + block_time is the timestamp in the Babylon block that + triggers the state - TransactionKeys in SubmissionKey. - transaction: - type: string - format: byte - title: transaction is the full transaction in bytes - proof: - type: string - format: byte - title: >- - proof is the Merkle proof that this tx is included in - the position in `key` - - TODO: maybe it could use here better format as we - already processed and - - validated the proof? - title: |- - TransactionInfo is the info of a tx on Bitcoin, - including - - the position of the tx on BTC blockchain - - the full tx content - - the Merkle proof that this tx is on the above position - title: >- - proof_epoch_submitted is the proof that the epoch's - checkpoint is included + update + description: >- + CheckpointStateUpdateResponse defines a state transition on + the checkpoint. + description: >- + lifecycle defines the lifecycle of this checkpoint, i.e., each + state - in BTC ledger It is the two TransactionInfo in the best - (i.e., earliest) + transition and the time (in both timestamp and block height) of + this - checkpoint submission - title: FinalizedChainInfo is the information of a CZ that is BTC-finalised - description: |- - QueryFinalizedChainsInfoResponse is response type for the - Query/FinalizedChainsInfo RPC method. - babylon.zoneconcierge.v1.QueryHeaderResponse: - type: object - properties: - header: + transition. + description: >- + RawCheckpointWithMetaResponse wraps the raw checkpoint with + metadata. + title: the order is going from the newest to oldest based on the epoch number + pagination: + description: pagination defines the pagination in the response. type: object properties: - consumer_id: - type: string - title: consumer_id is the unique ID of the consumer - hash: + next_key: type: string format: byte - title: hash is the hash of this header - height: + description: |- + next_key is the key to be passed to PageRequest.key to + query the next page most efficiently. It will be empty if + there are no more results. + total: type: string format: uint64 title: >- - height is the height of this header on CZ ledger + total is total number of results available if + PageRequest.count_total - (hash, height) jointly provides the position of the header on CZ - ledger - time: - type: string - format: date-time - title: |- - time is the timestamp of this header on CZ ledger - it is needed for CZ to unbond all mature validators/delegations - before this timestamp when this header is BTC-finalised - babylon_header_hash: - type: string - format: byte - title: >- - babylon_header_hash is the hash of the babylon block that includes - this CZ + was set, its value is undefined otherwise + description: |- + QueryRawCheckpointListResponse is the response type for the + Query/RawCheckpoints RPC method. + babylon.checkpointing.v1.QueryRawCheckpointResponse: + type: object + properties: + raw_checkpoint: + type: object + properties: + ckpt: + type: object + properties: + epoch_num: + type: string + format: uint64 + title: epoch_num defines the epoch number the raw checkpoint is for + block_hash_hex: + type: string + title: >- + block_hash_hex defines the 'BlockID.Hash', which is the hash + of + + the block that individual BLS sigs are signed on as hex string + bitmap: + type: string + format: byte + title: >- + bitmap defines the bitmap that indicates the signers of the + BLS multi sig + bls_multi_sig: + type: string + format: byte + title: >- + bls_multi_sig defines the multi sig that is aggregated from + individual BLS - header - babylon_header_height: + sigs + title: RawCheckpointResponse wraps the BLS multi sig with metadata + status: type: string - format: uint64 - title: >- - babylon_header_height is the height of the babylon block that - includes this CZ + enum: + - CKPT_STATUS_ACCUMULATING + - CKPT_STATUS_SEALED + - CKPT_STATUS_SUBMITTED + - CKPT_STATUS_CONFIRMED + - CKPT_STATUS_FINALIZED + default: CKPT_STATUS_ACCUMULATING + description: |- + CheckpointStatus is the status of a checkpoint. - header - babylon_epoch: + - CKPT_STATUS_ACCUMULATING: ACCUMULATING defines a checkpoint that is awaiting for BLS signatures. + - CKPT_STATUS_SEALED: SEALED defines a checkpoint that has accumulated sufficient BLS signatures. + - CKPT_STATUS_SUBMITTED: SUBMITTED defines a checkpoint that is included on BTC. + - CKPT_STATUS_CONFIRMED: CONFIRMED defines a checkpoint that is k-deep on BTC. + - CKPT_STATUS_FINALIZED: FINALIZED defines a checkpoint that is w-deep on BTC. + title: status defines the status of the checkpoint + status_desc: type: string - format: uint64 - title: epoch is the epoch number of this header on Babylon ledger - babylon_tx_hash: + description: status_desc represents the description of status enum. + bls_aggr_pk: type: string format: byte - title: >- - babylon_tx_hash is the hash of the tx that includes this header - - (babylon_block_height, babylon_tx_hash) jointly provides the - position of - - the header on Babylon ledger - title: IndexedHeader is the metadata of a CZ header - fork_headers: - type: object - properties: - headers: + title: bls_aggr_pk defines the aggregated BLS public key + power_sum: + type: string + format: uint64 + title: power_sum defines the accumulated voting power for the checkpoint + lifecycle: type: array items: type: object properties: - consumer_id: - type: string - title: consumer_id is the unique ID of the consumer - hash: - type: string - format: byte - title: hash is the hash of this header - height: + state: type: string - format: uint64 - title: >- - height is the height of this header on CZ ledger + enum: + - CKPT_STATUS_ACCUMULATING + - CKPT_STATUS_SEALED + - CKPT_STATUS_SUBMITTED + - CKPT_STATUS_CONFIRMED + - CKPT_STATUS_FINALIZED + default: CKPT_STATUS_ACCUMULATING + description: |- + CheckpointStatus is the status of a checkpoint. - (hash, height) jointly provides the position of the header - on CZ ledger - time: - type: string - format: date-time + - CKPT_STATUS_ACCUMULATING: ACCUMULATING defines a checkpoint that is awaiting for BLS signatures. + - CKPT_STATUS_SEALED: SEALED defines a checkpoint that has accumulated sufficient BLS signatures. + - CKPT_STATUS_SUBMITTED: SUBMITTED defines a checkpoint that is included on BTC. + - CKPT_STATUS_CONFIRMED: CONFIRMED defines a checkpoint that is k-deep on BTC. + - CKPT_STATUS_FINALIZED: FINALIZED defines a checkpoint that is w-deep on BTC. title: >- - time is the timestamp of this header on CZ ledger - - it is needed for CZ to unbond all mature - validators/delegations - - before this timestamp when this header is BTC-finalised - babylon_header_hash: + state defines the event of a state transition towards this + state + status_desc: type: string - format: byte - title: >- - babylon_header_hash is the hash of the babylon block that - includes this CZ - - header - babylon_header_height: + description: status_desc represents the description of status enum. + block_height: type: string format: uint64 title: >- - babylon_header_height is the height of the babylon block - that includes this CZ + block_height is the height of the Babylon block that + triggers the state - header - babylon_epoch: - type: string - format: uint64 - title: epoch is the epoch number of this header on Babylon ledger - babylon_tx_hash: + update + block_time: type: string - format: byte + format: date-time title: >- - babylon_tx_hash is the hash of the tx that includes this - header - - (babylon_block_height, babylon_tx_hash) jointly provides the - position of - - the header on Babylon ledger - title: IndexedHeader is the metadata of a CZ header - title: >- - blocks is the list of non-canonical indexed headers at the same - height - description: >- - Forks is a list of non-canonical `IndexedHeader`s at the same height. - - For example, assuming the following blockchain - - ``` - - A <- B <- C <- D <- E - \ -- D1 - \ -- D2 - ``` - - Then the fork will be {[D1, D2]} where each item is in struct - `IndexedBlock`. - - - Note that each `IndexedHeader` in the fork should have a valid quorum + block_time is the timestamp in the Babylon block that + triggers the state - certificate. Such forks exist since Babylon considers CZs might have + update + description: >- + CheckpointStateUpdateResponse defines a state transition on the + checkpoint. + description: >- + lifecycle defines the lifecycle of this checkpoint, i.e., each + state - dishonest majority. Also note that the IBC-Go implementation will only + transition and the time (in both timestamp and block height) of + this - consider the first header in a fork valid, since the subsequent - headers + transition. + description: RawCheckpointWithMetaResponse wraps the raw checkpoint with metadata. + description: >- + QueryRawCheckpointResponse is the response type for the + Query/RawCheckpoint - cannot be verified without knowing the validator set in the previous - header. - description: QueryHeaderResponse is response type for the Query/Header RPC method. - babylon.zoneconcierge.v1.QueryListEpochHeadersResponse: + RPC method. + babylon.checkpointing.v1.QueryRawCheckpointsResponse: type: object properties: - headers: + raw_checkpoints: type: array items: type: object properties: - consumer_id: - type: string - title: consumer_id is the unique ID of the consumer - hash: - type: string - format: byte - title: hash is the hash of this header - height: - type: string - format: uint64 - title: >- - height is the height of this header on CZ ledger - - (hash, height) jointly provides the position of the header on CZ - ledger - time: - type: string - format: date-time - title: |- - time is the timestamp of this header on CZ ledger - it is needed for CZ to unbond all mature validators/delegations - before this timestamp when this header is BTC-finalised - babylon_header_hash: - type: string - format: byte - title: >- - babylon_header_hash is the hash of the babylon block that - includes this CZ + ckpt: + type: object + properties: + epoch_num: + type: string + format: uint64 + title: epoch_num defines the epoch number the raw checkpoint is for + block_hash_hex: + type: string + title: >- + block_hash_hex defines the 'BlockID.Hash', which is the hash + of - header - babylon_header_height: - type: string - format: uint64 - title: >- - babylon_header_height is the height of the babylon block that - includes this CZ + the block that individual BLS sigs are signed on as hex + string + bitmap: + type: string + format: byte + title: >- + bitmap defines the bitmap that indicates the signers of the + BLS multi sig + bls_multi_sig: + type: string + format: byte + title: >- + bls_multi_sig defines the multi sig that is aggregated from + individual BLS - header - babylon_epoch: - type: string - format: uint64 - title: epoch is the epoch number of this header on Babylon ledger - babylon_tx_hash: + sigs + title: RawCheckpointResponse wraps the BLS multi sig with metadata + status: type: string - format: byte - title: >- - babylon_tx_hash is the hash of the tx that includes this header - - (babylon_block_height, babylon_tx_hash) jointly provides the - position of - - the header on Babylon ledger - title: IndexedHeader is the metadata of a CZ header - title: headers is the list of headers - description: >- - QueryListEpochHeadersResponse is response type for the - Query/ListEpochHeaders + enum: + - CKPT_STATUS_ACCUMULATING + - CKPT_STATUS_SEALED + - CKPT_STATUS_SUBMITTED + - CKPT_STATUS_CONFIRMED + - CKPT_STATUS_FINALIZED + default: CKPT_STATUS_ACCUMULATING + description: |- + CheckpointStatus is the status of a checkpoint. - RPC method. - babylon.zoneconcierge.v1.QueryListHeadersResponse: - type: object - properties: - headers: - type: array - items: - type: object - properties: - consumer_id: + - CKPT_STATUS_ACCUMULATING: ACCUMULATING defines a checkpoint that is awaiting for BLS signatures. + - CKPT_STATUS_SEALED: SEALED defines a checkpoint that has accumulated sufficient BLS signatures. + - CKPT_STATUS_SUBMITTED: SUBMITTED defines a checkpoint that is included on BTC. + - CKPT_STATUS_CONFIRMED: CONFIRMED defines a checkpoint that is k-deep on BTC. + - CKPT_STATUS_FINALIZED: FINALIZED defines a checkpoint that is w-deep on BTC. + title: status defines the status of the checkpoint + status_desc: type: string - title: consumer_id is the unique ID of the consumer - hash: + description: status_desc represents the description of status enum. + bls_aggr_pk: type: string format: byte - title: hash is the hash of this header - height: + title: bls_aggr_pk defines the aggregated BLS public key + power_sum: type: string format: uint64 title: >- - height is the height of this header on CZ ledger + power_sum defines the accumulated voting power for the + checkpoint + lifecycle: + type: array + items: + type: object + properties: + state: + type: string + enum: + - CKPT_STATUS_ACCUMULATING + - CKPT_STATUS_SEALED + - CKPT_STATUS_SUBMITTED + - CKPT_STATUS_CONFIRMED + - CKPT_STATUS_FINALIZED + default: CKPT_STATUS_ACCUMULATING + description: |- + CheckpointStatus is the status of a checkpoint. - (hash, height) jointly provides the position of the header on CZ - ledger - time: - type: string - format: date-time - title: |- - time is the timestamp of this header on CZ ledger - it is needed for CZ to unbond all mature validators/delegations - before this timestamp when this header is BTC-finalised - babylon_header_hash: - type: string - format: byte - title: >- - babylon_header_hash is the hash of the babylon block that - includes this CZ + - CKPT_STATUS_ACCUMULATING: ACCUMULATING defines a checkpoint that is awaiting for BLS signatures. + - CKPT_STATUS_SEALED: SEALED defines a checkpoint that has accumulated sufficient BLS signatures. + - CKPT_STATUS_SUBMITTED: SUBMITTED defines a checkpoint that is included on BTC. + - CKPT_STATUS_CONFIRMED: CONFIRMED defines a checkpoint that is k-deep on BTC. + - CKPT_STATUS_FINALIZED: FINALIZED defines a checkpoint that is w-deep on BTC. + title: >- + state defines the event of a state transition towards this + state + status_desc: + type: string + description: status_desc represents the description of status enum. + block_height: + type: string + format: uint64 + title: >- + block_height is the height of the Babylon block that + triggers the state - header - babylon_header_height: - type: string - format: uint64 - title: >- - babylon_header_height is the height of the babylon block that - includes this CZ + update + block_time: + type: string + format: date-time + title: >- + block_time is the timestamp in the Babylon block that + triggers the state - header - babylon_epoch: - type: string - format: uint64 - title: epoch is the epoch number of this header on Babylon ledger - babylon_tx_hash: - type: string - format: byte - title: >- - babylon_tx_hash is the hash of the tx that includes this header + update + description: >- + CheckpointStateUpdateResponse defines a state transition on + the checkpoint. + description: >- + lifecycle defines the lifecycle of this checkpoint, i.e., each + state - (babylon_block_height, babylon_tx_hash) jointly provides the - position of + transition and the time (in both timestamp and block height) of + this - the header on Babylon ledger - title: IndexedHeader is the metadata of a CZ header - title: headers is the list of headers + transition. + description: >- + RawCheckpointWithMetaResponse wraps the raw checkpoint with + metadata. + title: the order is going from the newest to oldest based on the epoch number pagination: - title: pagination defines the pagination in the response + description: pagination defines the pagination in the response. type: object properties: next_key: @@ -14165,66 +7200,161 @@ definitions: PageRequest.count_total was set, its value is undefined otherwise - description: |- - PageResponse is to be embedded in gRPC response messages where the - corresponding request message has used PageRequest. + description: >- + QueryRawCheckpointsResponse is the response type for the + Query/RawCheckpoints - message SomeResponse { - repeated Bar results = 1; - PageResponse page = 2; - } - description: |- - QueryListHeadersResponse is response type for the Query/ListHeaders RPC - method. - babylon.zoneconcierge.v1.QueryParamsResponse: + RPC method. + babylon.checkpointing.v1.QueryRecentEpochStatusCountResponse: type: object properties: - params: - description: params holds all the parameters of this module. + tip_epoch: + type: string + format: uint64 + epoch_count: + type: string + format: uint64 + status_count: type: object - properties: - ibc_packet_timeout_seconds: - type: integer - format: int64 - title: >- - ibc_packet_timeout_seconds is the time period after which an - unrelayed - - IBC packet becomes timeout, measured in seconds - description: QueryParamsResponse is the response type for the Query/Params RPC method. - tendermint.crypto.ProofOp: + additionalProperties: + type: string + format: uint64 + description: |- + QueryRecentEpochStatusCountResponse is the response type for the + Query/EpochStatusCount RPC method. + babylon.checkpointing.v1.RawCheckpointResponse: type: object properties: - type: + epoch_num: type: string - key: + format: uint64 + title: epoch_num defines the epoch number the raw checkpoint is for + block_hash_hex: + type: string + title: |- + block_hash_hex defines the 'BlockID.Hash', which is the hash of + the block that individual BLS sigs are signed on as hex string + bitmap: type: string format: byte - data: + title: >- + bitmap defines the bitmap that indicates the signers of the BLS multi + sig + bls_multi_sig: type: string format: byte - title: |- - ProofOp defines an operation used for calculating Merkle root - The data could be arbitrary format, providing nessecary data - for example neighbouring node hash - tendermint.crypto.ProofOps: + title: >- + bls_multi_sig defines the multi sig that is aggregated from individual + BLS + + sigs + title: RawCheckpointResponse wraps the BLS multi sig with metadata + babylon.checkpointing.v1.RawCheckpointWithMetaResponse: type: object properties: - ops: + ckpt: + type: object + properties: + epoch_num: + type: string + format: uint64 + title: epoch_num defines the epoch number the raw checkpoint is for + block_hash_hex: + type: string + title: |- + block_hash_hex defines the 'BlockID.Hash', which is the hash of + the block that individual BLS sigs are signed on as hex string + bitmap: + type: string + format: byte + title: >- + bitmap defines the bitmap that indicates the signers of the BLS + multi sig + bls_multi_sig: + type: string + format: byte + title: >- + bls_multi_sig defines the multi sig that is aggregated from + individual BLS + + sigs + title: RawCheckpointResponse wraps the BLS multi sig with metadata + status: + type: string + enum: + - CKPT_STATUS_ACCUMULATING + - CKPT_STATUS_SEALED + - CKPT_STATUS_SUBMITTED + - CKPT_STATUS_CONFIRMED + - CKPT_STATUS_FINALIZED + default: CKPT_STATUS_ACCUMULATING + description: |- + CheckpointStatus is the status of a checkpoint. + + - CKPT_STATUS_ACCUMULATING: ACCUMULATING defines a checkpoint that is awaiting for BLS signatures. + - CKPT_STATUS_SEALED: SEALED defines a checkpoint that has accumulated sufficient BLS signatures. + - CKPT_STATUS_SUBMITTED: SUBMITTED defines a checkpoint that is included on BTC. + - CKPT_STATUS_CONFIRMED: CONFIRMED defines a checkpoint that is k-deep on BTC. + - CKPT_STATUS_FINALIZED: FINALIZED defines a checkpoint that is w-deep on BTC. + title: status defines the status of the checkpoint + status_desc: + type: string + description: status_desc represents the description of status enum. + bls_aggr_pk: + type: string + format: byte + title: bls_aggr_pk defines the aggregated BLS public key + power_sum: + type: string + format: uint64 + title: power_sum defines the accumulated voting power for the checkpoint + lifecycle: type: array items: type: object properties: - type: + state: + type: string + enum: + - CKPT_STATUS_ACCUMULATING + - CKPT_STATUS_SEALED + - CKPT_STATUS_SUBMITTED + - CKPT_STATUS_CONFIRMED + - CKPT_STATUS_FINALIZED + default: CKPT_STATUS_ACCUMULATING + description: |- + CheckpointStatus is the status of a checkpoint. + + - CKPT_STATUS_ACCUMULATING: ACCUMULATING defines a checkpoint that is awaiting for BLS signatures. + - CKPT_STATUS_SEALED: SEALED defines a checkpoint that has accumulated sufficient BLS signatures. + - CKPT_STATUS_SUBMITTED: SUBMITTED defines a checkpoint that is included on BTC. + - CKPT_STATUS_CONFIRMED: CONFIRMED defines a checkpoint that is k-deep on BTC. + - CKPT_STATUS_FINALIZED: FINALIZED defines a checkpoint that is w-deep on BTC. + title: state defines the event of a state transition towards this state + status_desc: type: string - key: + description: status_desc represents the description of status enum. + block_height: type: string - format: byte - data: + format: uint64 + title: >- + block_height is the height of the Babylon block that triggers + the state + + update + block_time: type: string - format: byte - title: |- - ProofOp defines an operation used for calculating Merkle root - The data could be arbitrary format, providing nessecary data - for example neighbouring node hash - title: ProofOps is Merkle proof defined by the list of ProofOps + format: date-time + title: >- + block_time is the timestamp in the Babylon block that triggers + the state + + update + description: >- + CheckpointStateUpdateResponse defines a state transition on the + checkpoint. + description: |- + lifecycle defines the lifecycle of this checkpoint, i.e., each state + transition and the time (in both timestamp and block height) of this + transition. + description: RawCheckpointWithMetaResponse wraps the raw checkpoint with metadata. diff --git a/client/query/btcstaking.go b/client/query/btcstaking.go index 04250fd3d..1f10e3262 100644 --- a/client/query/btcstaking.go +++ b/client/query/btcstaking.go @@ -121,48 +121,3 @@ func (c *QueryClient) BTCDelegation(stakingTxHashHex string) (*btcstakingtypes.Q return resp, err } - -// ActiveFinalityProvidersAtHeight queries the BTCStaking module for all finality providers -// with non-zero voting power at a given height -func (c *QueryClient) ActiveFinalityProvidersAtHeight(height uint64, pagination *sdkquerytypes.PageRequest) (*btcstakingtypes.QueryActiveFinalityProvidersAtHeightResponse, error) { - var resp *btcstakingtypes.QueryActiveFinalityProvidersAtHeightResponse - err := c.QueryBTCStaking(func(ctx context.Context, queryClient btcstakingtypes.QueryClient) error { - var err error - req := &btcstakingtypes.QueryActiveFinalityProvidersAtHeightRequest{ - Height: height, - Pagination: pagination, - } - resp, err = queryClient.ActiveFinalityProvidersAtHeight(ctx, req) - return err - }) - - return resp, err -} - -// FinalityProviderPowerAtHeight queries the BTCStaking module for the power of a finality provider at a given height -func (c *QueryClient) FinalityProviderPowerAtHeight(fpBtcPkHex string, height uint64) (*btcstakingtypes.QueryFinalityProviderPowerAtHeightResponse, error) { - var resp *btcstakingtypes.QueryFinalityProviderPowerAtHeightResponse - err := c.QueryBTCStaking(func(ctx context.Context, queryClient btcstakingtypes.QueryClient) error { - var err error - req := &btcstakingtypes.QueryFinalityProviderPowerAtHeightRequest{ - FpBtcPkHex: fpBtcPkHex, - Height: height, - } - resp, err = queryClient.FinalityProviderPowerAtHeight(ctx, req) - return err - }) - - return resp, err -} - -func (c *QueryClient) ActivatedHeight() (*btcstakingtypes.QueryActivatedHeightResponse, error) { - var resp *btcstakingtypes.QueryActivatedHeightResponse - err := c.QueryBTCStaking(func(ctx context.Context, queryClient btcstakingtypes.QueryClient) error { - var err error - req := &btcstakingtypes.QueryActivatedHeightRequest{} - resp, err = queryClient.ActivatedHeight(ctx, req) - return err - }) - - return resp, err -} diff --git a/client/query/finality.go b/client/query/finality.go index 2db05d281..504abeab4 100644 --- a/client/query/finality.go +++ b/client/query/finality.go @@ -19,6 +19,51 @@ func (c *QueryClient) QueryFinality(f func(ctx context.Context, queryClient fina return f(ctx, queryClient) } +// ActiveFinalityProvidersAtHeight queries the BTCStaking module for all finality providers +// with non-zero voting power at a given height +func (c *QueryClient) ActiveFinalityProvidersAtHeight(height uint64, pagination *sdkquerytypes.PageRequest) (*finalitytypes.QueryActiveFinalityProvidersAtHeightResponse, error) { + var resp *finalitytypes.QueryActiveFinalityProvidersAtHeightResponse + err := c.QueryFinality(func(ctx context.Context, queryClient finalitytypes.QueryClient) error { + var err error + req := &finalitytypes.QueryActiveFinalityProvidersAtHeightRequest{ + Height: height, + Pagination: pagination, + } + resp, err = queryClient.ActiveFinalityProvidersAtHeight(ctx, req) + return err + }) + + return resp, err +} + +// FinalityProviderPowerAtHeight queries the BTCStaking module for the power of a finality provider at a given height +func (c *QueryClient) FinalityProviderPowerAtHeight(fpBtcPkHex string, height uint64) (*finalitytypes.QueryFinalityProviderPowerAtHeightResponse, error) { + var resp *finalitytypes.QueryFinalityProviderPowerAtHeightResponse + err := c.QueryFinality(func(ctx context.Context, queryClient finalitytypes.QueryClient) error { + var err error + req := &finalitytypes.QueryFinalityProviderPowerAtHeightRequest{ + FpBtcPkHex: fpBtcPkHex, + Height: height, + } + resp, err = queryClient.FinalityProviderPowerAtHeight(ctx, req) + return err + }) + + return resp, err +} + +func (c *QueryClient) ActivatedHeight() (*finalitytypes.QueryActivatedHeightResponse, error) { + var resp *finalitytypes.QueryActivatedHeightResponse + err := c.QueryFinality(func(ctx context.Context, queryClient finalitytypes.QueryClient) error { + var err error + req := &finalitytypes.QueryActivatedHeightRequest{} + resp, err = queryClient.ActivatedHeight(ctx, req) + return err + }) + + return resp, err +} + // FinalityParams queries the finality module parameters func (c *QueryClient) FinalityParams() (*finalitytypes.Params, error) { var resp *finalitytypes.QueryParamsResponse diff --git a/client/query/tendermint.go b/client/query/tendermint.go index cf00304dc..b1afd123c 100644 --- a/client/query/tendermint.go +++ b/client/query/tendermint.go @@ -47,6 +47,13 @@ func (c *QueryClient) GetTx(hash []byte) (*coretypes.ResultTx, error) { return c.RPCClient.Tx(ctx, hash, false) } +func (c *QueryClient) BlockResults(height int64) (*coretypes.ResultBlockResults, error) { + ctx, cancel := c.getQueryContext() + defer cancel() + + return c.RPCClient.BlockResults(ctx, &height) +} + func (c *QueryClient) Subscribe(subscriber, query string, outCapacity ...int) (out <-chan coretypes.ResultEvent, err error) { return c.RPCClient.Subscribe(context.Background(), subscriber, query, outCapacity...) } diff --git a/client/query/zoneconcierge.go b/client/query/zoneconcierge.go deleted file mode 100644 index bdc20c193..000000000 --- a/client/query/zoneconcierge.go +++ /dev/null @@ -1,96 +0,0 @@ -package query - -import ( - "context" - - zctypes "github.com/babylonlabs-io/babylon/x/zoneconcierge/types" - "github.com/cosmos/cosmos-sdk/client" - sdkquerytypes "github.com/cosmos/cosmos-sdk/types/query" -) - -// QueryZoneConcierge queries the ZoneConcierge module of the Babylon node -// according to the given function -func (c *QueryClient) QueryZoneConcierge(f func(ctx context.Context, queryClient zctypes.QueryClient) error) error { - ctx, cancel := c.getQueryContext() - defer cancel() - - clientCtx := client.Context{Client: c.RPCClient} - queryClient := zctypes.NewQueryClient(clientCtx) - - return f(ctx, queryClient) -} - -// FinalizedConnectedChainsInfo queries the zoneconcierge module to get the finalization information for a connected chain -func (c *QueryClient) FinalizedConnectedChainsInfo(consumerIds []string) (*zctypes.QueryFinalizedChainsInfoResponse, error) { - var resp *zctypes.QueryFinalizedChainsInfoResponse - err := c.QueryZoneConcierge(func(ctx context.Context, queryClient zctypes.QueryClient) error { - var err error - req := &zctypes.QueryFinalizedChainsInfoRequest{ - ConsumerIds: consumerIds, - } - resp, err = queryClient.FinalizedChainsInfo(ctx, req) - return err - }) - - return resp, err -} - -// ConnectedChainsInfo queries the zoneconcierge module to get information for a connected chain -func (c *QueryClient) ConnectedChainsInfo(consumerIds []string) (*zctypes.QueryChainsInfoResponse, error) { - var resp *zctypes.QueryChainsInfoResponse - err := c.QueryZoneConcierge(func(ctx context.Context, queryClient zctypes.QueryClient) error { - var err error - req := &zctypes.QueryChainsInfoRequest{ - ConsumerIds: consumerIds, - } - resp, err = queryClient.ChainsInfo(ctx, req) - return err - }) - - return resp, err -} - -// ConnectedChainList queries the zoneconierge module for the chain IDs of the connected chains -func (c *QueryClient) ConnectedChainList() (*zctypes.QueryChainListResponse, error) { - var resp *zctypes.QueryChainListResponse - err := c.QueryZoneConcierge(func(ctx context.Context, queryClient zctypes.QueryClient) error { - var err error - req := &zctypes.QueryChainListRequest{} - resp, err = queryClient.ChainList(ctx, req) - return err - }) - - return resp, err -} - -// ConnectedChainHeaders queries the zoneconcierge module for the headers of a connected chain -func (c *QueryClient) ConnectedChainHeaders(consumerID string, pagination *sdkquerytypes.PageRequest) (*zctypes.QueryListHeadersResponse, error) { - var resp *zctypes.QueryListHeadersResponse - err := c.QueryZoneConcierge(func(ctx context.Context, queryClient zctypes.QueryClient) error { - var err error - req := &zctypes.QueryListHeadersRequest{ - ConsumerId: consumerID, - Pagination: pagination, - } - resp, err = queryClient.ListHeaders(ctx, req) - return err - }) - - return resp, err -} - -// ConnectedChainsEpochInfo queries the zoneconcierge module for the chain information of a connected chain at a particular epoch -func (c *QueryClient) ConnectedChainsEpochInfo(consumerIds []string, epochNum uint64) (*zctypes.QueryEpochChainsInfoResponse, error) { - var resp *zctypes.QueryEpochChainsInfoResponse - err := c.QueryZoneConcierge(func(ctx context.Context, queryClient zctypes.QueryClient) error { - var err error - req := &zctypes.QueryEpochChainsInfoRequest{ - ConsumerIds: consumerIds, - EpochNum: epochNum, - } - resp, err = queryClient.EpochChainsInfo(ctx, req) - return err - }) - - return resp, err -} diff --git a/cmd/babylond/cmd/custom_babylon_config.go b/cmd/babylond/cmd/custom_babylon_config.go index 055f6069f..6e4c4dfc2 100644 --- a/cmd/babylond/cmd/custom_babylon_config.go +++ b/cmd/babylond/cmd/custom_babylon_config.go @@ -1,9 +1,13 @@ package cmd import ( + "fmt" + wasmtypes "github.com/CosmWasm/wasmd/x/wasm/types" + serverconfig "github.com/cosmos/cosmos-sdk/server/config" + appparams "github.com/babylonlabs-io/babylon/app/params" bbn "github.com/babylonlabs-io/babylon/types" ) @@ -25,9 +29,13 @@ type BabylonAppConfig struct { BtcConfig BtcConfig `mapstructure:"btc-config"` } -func DefaultBabylonConfig() *BabylonAppConfig { +func DefaultBabylonAppConfig() *BabylonAppConfig { + baseConfig := *serverconfig.DefaultConfig() + // The SDK's default minimum gas price is set to "0.002ubbn" (empty value) inside + // app.toml, in order to avoid spamming attacks due to transactions with 0 gas price. + baseConfig.MinGasPrices = fmt.Sprintf("%f%s", appparams.GlobalMinGasPrice, appparams.BaseCoinUnit) return &BabylonAppConfig{ - Config: *serverconfig.DefaultConfig(), + Config: baseConfig, Wasm: wasmtypes.DefaultWasmConfig(), BtcConfig: defaultBabylonBtcConfig(), } diff --git a/cmd/babylond/cmd/flags.go b/cmd/babylond/cmd/flags.go index 899f1d1b1..2ade8ab09 100644 --- a/cmd/babylond/cmd/flags.go +++ b/cmd/babylond/cmd/flags.go @@ -2,11 +2,11 @@ package cmd import ( "encoding/hex" + "fmt" "strings" "time" "cosmossdk.io/math" - tmrand "github.com/cometbft/cometbft/libs/rand" "github.com/cosmos/cosmos-sdk/client/flags" "github.com/spf13/cobra" @@ -15,6 +15,7 @@ import ( btcctypes "github.com/babylonlabs-io/babylon/x/btccheckpoint/types" btcltypes "github.com/babylonlabs-io/babylon/x/btclightclient/types" btcstypes "github.com/babylonlabs-io/babylon/x/btcstaking/types" + ftypes "github.com/babylonlabs-io/babylon/x/finality/types" ) const ( @@ -47,39 +48,49 @@ const ( flagMinSlashingFee = "min-slashing-fee-sat" flagSlashingRate = "slashing-rate" flagMinCommissionRate = "min-commission-rate" + flagSignedBlocksWindow = "signed-blocks-window" + flagActivationHeight = "activation-height" + flagMinSignedPerWindow = "min-signed-per-window" + flagFinalitySigTimeout = "finality-sig-timeout" + flagJailDuration = "jail-duration" ) type GenesisCLIArgs struct { - ChainID string - MaxActiveValidators uint32 - BtcConfirmationDepth uint64 - BtcFinalizationTimeout uint64 - CheckpointTag string - EpochInterval uint64 - BaseBtcHeaderHex string - BaseBtcHeaderHeight uint64 - AllowedReporterAddresses []string - InflationRateChange float64 - InflationMax float64 - InflationMin float64 - GoalBonded float64 - BlocksPerYear uint64 - GenesisTime time.Time - BlockGasLimit int64 - VoteExtensionEnableHeight int64 - CovenantPKs []string - CovenantQuorum uint32 - MinStakingAmtSat int64 - MaxStakingAmtSat int64 - MinStakingTimeBlocks uint16 - MaxStakingTimeBlocks uint16 - SlashingPkScript string - MinSlashingTransactionFeeSat int64 - SlashingRate math.LegacyDec - MaxActiveFinalityProviders uint32 - MinUnbondingTime uint16 - UnbondingFeeSat int64 - MinCommissionRate math.LegacyDec + ChainID string + MaxActiveValidators uint32 + BtcConfirmationDepth uint32 + BtcFinalizationTimeout uint32 + CheckpointTag string + EpochInterval uint64 + BaseBtcHeaderHex string + BaseBtcHeaderHeight uint32 + AllowedReporterAddresses []string + InflationRateChange float64 + InflationMax float64 + InflationMin float64 + GoalBonded float64 + BlocksPerYear uint64 + GenesisTime time.Time + BlockGasLimit int64 + VoteExtensionEnableHeight int64 + CovenantPKs []string + CovenantQuorum uint32 + MinStakingAmtSat int64 + MaxStakingAmtSat int64 + MinStakingTimeBlocks uint16 + MaxStakingTimeBlocks uint16 + SlashingPkScript string + MinSlashingTransactionFeeSat int64 + SlashingRate math.LegacyDec + MaxActiveFinalityProviders uint32 + MinUnbondingTime uint16 + UnbondingFeeSat int64 + MinCommissionRate math.LegacyDec + SignedBlocksWindow int64 + MinSignedPerWindow math.LegacyDec + FinalitySigTimeout int64 + JailDuration time.Duration + FinalityActivationBlockHeight uint64 } func addGenesisFlags(cmd *cobra.Command) { @@ -87,8 +98,8 @@ func addGenesisFlags(cmd *cobra.Command) { // staking flags cmd.Flags().Uint32(flagMaxActiveValidators, 10, "Maximum number of validators.") // btccheckpoint flags - cmd.Flags().Uint64(flagBtcConfirmationDepth, 6, "Confirmation depth for Bitcoin headers.") - cmd.Flags().Uint64(flagBtcFinalizationTimeout, 20, "Finalization timeout for Bitcoin headers.") + cmd.Flags().Uint32(flagBtcConfirmationDepth, 6, "Confirmation depth for Bitcoin headers.") + cmd.Flags().Uint32(flagBtcFinalizationTimeout, 20, "Finalization timeout for Bitcoin headers.") cmd.Flags().String(flagCheckpointTag, btcctypes.DefaultCheckpointTag, "Hex encoded tag for babylon checkpoint on btc") // epoch args cmd.Flags().Uint64(flagEpochInterval, 400, "Number of blocks between epochs. Must be more than 0.") @@ -96,7 +107,7 @@ func addGenesisFlags(cmd *cobra.Command) { // Genesis header for the simnet cmd.Flags().String(flagBaseBtcHeaderHex, "0100000000000000000000000000000000000000000000000000000000000000000000003ba3edfd7a7b12b27ac72c3e67768f617fc81bc3888a51323a9fb8aa4b1e5e4a45068653ffff7f2002000000", "Hex of the base Bitcoin header.") cmd.Flags().String(flagAllowedReporterAddresses, strings.Join(btcltypes.DefaultParams().InsertHeadersAllowList, ","), "addresses of reporters allowed to submit Bitcoin headers to babylon") - cmd.Flags().Uint64(flagBaseBtcHeaderHeight, 0, "Height of the base Bitcoin header.") + cmd.Flags().Uint32(flagBaseBtcHeaderHeight, 0, "Height of the base Bitcoin header.") // btcstaking args cmd.Flags().String(flagCovenantPks, strings.Join(btcstypes.DefaultParams().CovenantPksHex(), ","), "Bitcoin staking covenant public keys, comma separated") cmd.Flags().Uint32(flagCovenantQuorum, btcstypes.DefaultParams().CovenantQuorum, "Bitcoin staking covenant quorum") @@ -122,17 +133,23 @@ func addGenesisFlags(cmd *cobra.Command) { // blocks args cmd.Flags().Int64(flagBlockGasLimit, babylonApp.DefaultGasLimit, "Block gas limit") cmd.Flags().Int64(flagVoteExtensionEnableHeight, babylonApp.DefaultVoteExtensionsEnableHeight, "Vote extension enable height") + cmd.Flags().Int64(flagSignedBlocksWindow, ftypes.DefaultSignedBlocksWindow, "Size of the sliding window for tracking finality provider liveness") + cmd.Flags().String(flagMinSignedPerWindow, ftypes.DefaultMinSignedPerWindow.String(), "Minimum number of blocks that a finality provider is required to sign within the sliding window to avoid being jailed") + cmd.Flags().Int64(flagFinalitySigTimeout, ftypes.DefaultFinalitySigTimeout, "How much time (in terms of blocks) finality providers have to cast a finality vote before being judged as missing their voting turn on the given block") + cmd.Flags().String(flagJailDuration, ftypes.DefaultJailDuration.String(), "Minimum period of time that a finality provider remains jailed") + // finality flags + cmd.Flags().Uint64(flagActivationHeight, ftypes.DefaultFinalityActivationHeight, "Finality bbn block height activation to start accepting finality vote and pub rand") } -func parseGenesisFlags(cmd *cobra.Command) *GenesisCLIArgs { +func parseGenesisFlags(cmd *cobra.Command) (*GenesisCLIArgs, error) { chainID, _ := cmd.Flags().GetString(flags.FlagChainID) maxActiveValidators, _ := cmd.Flags().GetUint32(flagMaxActiveValidators) - btcConfirmationDepth, _ := cmd.Flags().GetUint64(flagBtcConfirmationDepth) - btcFinalizationTimeout, _ := cmd.Flags().GetUint64(flagBtcFinalizationTimeout) + btcConfirmationDepth, _ := cmd.Flags().GetUint32(flagBtcConfirmationDepth) + btcFinalizationTimeout, _ := cmd.Flags().GetUint32(flagBtcFinalizationTimeout) checkpointTag, _ := cmd.Flags().GetString(flagCheckpointTag) epochInterval, _ := cmd.Flags().GetUint64(flagEpochInterval) baseBtcHeaderHex, _ := cmd.Flags().GetString(flagBaseBtcHeaderHex) - baseBtcHeaderHeight, _ := cmd.Flags().GetUint64(flagBaseBtcHeaderHeight) + baseBtcHeaderHeight, _ := cmd.Flags().GetUint32(flagBaseBtcHeaderHeight) reporterAddresses, _ := cmd.Flags().GetString(flagAllowedReporterAddresses) covenantPks, _ := cmd.Flags().GetString(flagCovenantPks) covenantQuorum, _ := cmd.Flags().GetUint32(flagCovenantQuorum) @@ -155,48 +172,68 @@ func parseGenesisFlags(cmd *cobra.Command) *GenesisCLIArgs { blocksPerYear, _ := cmd.Flags().GetUint64(flagBlocksPerYear) blockGasLimit, _ := cmd.Flags().GetInt64(flagBlockGasLimit) voteExtensionEnableHeight, _ := cmd.Flags().GetInt64(flagVoteExtensionEnableHeight) + signedBlocksWindow, _ := cmd.Flags().GetInt64(flagSignedBlocksWindow) + minSignedPerWindowStr, _ := cmd.Flags().GetString(flagMinSignedPerWindow) + finalitySigTimeout, _ := cmd.Flags().GetInt64(flagFinalitySigTimeout) + jailDurationStr, _ := cmd.Flags().GetString(flagJailDuration) + finalityActivationBlockHeight, _ := cmd.Flags().GetUint64(flagActivationHeight) if chainID == "" { chainID = "chain-" + tmrand.NewRand().Str(6) } - var allowedReporterAddresses []string = make([]string, 0) + var allowedReporterAddresses = make([]string, 0) if reporterAddresses != "" { allowedReporterAddresses = strings.Split(reporterAddresses, ",") } genesisTime := time.Unix(genesisTimeUnix, 0) - return &GenesisCLIArgs{ - ChainID: chainID, - MaxActiveValidators: maxActiveValidators, - BtcConfirmationDepth: btcConfirmationDepth, - BtcFinalizationTimeout: btcFinalizationTimeout, - CheckpointTag: checkpointTag, - EpochInterval: epochInterval, - BaseBtcHeaderHeight: baseBtcHeaderHeight, - BaseBtcHeaderHex: baseBtcHeaderHex, - AllowedReporterAddresses: allowedReporterAddresses, - CovenantPKs: strings.Split(covenantPks, ","), - CovenantQuorum: covenantQuorum, - MinStakingAmtSat: minStakingAmtSat, - MaxStakingAmtSat: maxStakingAmtSat, - MinStakingTimeBlocks: minStakingTimeBlocks, - MaxStakingTimeBlocks: maxStakingTimeBlocks, - SlashingPkScript: slashingPkScript, - MinSlashingTransactionFeeSat: minSlashingFee, - MinCommissionRate: math.LegacyMustNewDecFromStr(minCommissionRate), - SlashingRate: math.LegacyMustNewDecFromStr(slashingRate), - MaxActiveFinalityProviders: maxActiveFinalityProviders, - MinUnbondingTime: minUnbondingTime, - UnbondingFeeSat: unbondingFeeSat, - GenesisTime: genesisTime, - InflationRateChange: inflationRateChange, - InflationMax: inflationMax, - InflationMin: inflationMin, - GoalBonded: goalBonded, - BlocksPerYear: blocksPerYear, - BlockGasLimit: blockGasLimit, - VoteExtensionEnableHeight: voteExtensionEnableHeight, + minSignedPerWindow, err := math.LegacyNewDecFromStr(minSignedPerWindowStr) + if err != nil { + return nil, fmt.Errorf("invalid min-signed-per-window %s: %w", minSignedPerWindowStr, err) + } + + jailDuration, err := time.ParseDuration(jailDurationStr) + if err != nil { + return nil, fmt.Errorf("invalid jail-duration %s: %w", jailDurationStr, err) } + + return &GenesisCLIArgs{ + ChainID: chainID, + MaxActiveValidators: maxActiveValidators, + BtcConfirmationDepth: btcConfirmationDepth, + BtcFinalizationTimeout: btcFinalizationTimeout, + CheckpointTag: checkpointTag, + EpochInterval: epochInterval, + BaseBtcHeaderHeight: baseBtcHeaderHeight, + BaseBtcHeaderHex: baseBtcHeaderHex, + AllowedReporterAddresses: allowedReporterAddresses, + CovenantPKs: strings.Split(covenantPks, ","), + CovenantQuorum: covenantQuorum, + MinStakingAmtSat: minStakingAmtSat, + MaxStakingAmtSat: maxStakingAmtSat, + MinStakingTimeBlocks: minStakingTimeBlocks, + MaxStakingTimeBlocks: maxStakingTimeBlocks, + SlashingPkScript: slashingPkScript, + MinSlashingTransactionFeeSat: minSlashingFee, + MinCommissionRate: math.LegacyMustNewDecFromStr(minCommissionRate), + SlashingRate: math.LegacyMustNewDecFromStr(slashingRate), + MaxActiveFinalityProviders: maxActiveFinalityProviders, + MinUnbondingTime: minUnbondingTime, + UnbondingFeeSat: unbondingFeeSat, + GenesisTime: genesisTime, + InflationRateChange: inflationRateChange, + InflationMax: inflationMax, + InflationMin: inflationMin, + GoalBonded: goalBonded, + BlocksPerYear: blocksPerYear, + BlockGasLimit: blockGasLimit, + VoteExtensionEnableHeight: voteExtensionEnableHeight, + SignedBlocksWindow: signedBlocksWindow, + MinSignedPerWindow: minSignedPerWindow, + FinalitySigTimeout: finalitySigTimeout, + JailDuration: jailDuration, + FinalityActivationBlockHeight: finalityActivationBlockHeight, + }, nil } diff --git a/cmd/babylond/cmd/genesis.go b/cmd/babylond/cmd/genesis.go index 1a5acab27..6a992a54c 100644 --- a/cmd/babylond/cmd/genesis.go +++ b/cmd/babylond/cmd/genesis.go @@ -8,9 +8,7 @@ import ( sdkmath "cosmossdk.io/math" - btcstakingtypes "github.com/babylonlabs-io/babylon/x/btcstaking/types" - finalitytypes "github.com/babylonlabs-io/babylon/x/finality/types" - + minttypes "github.com/babylonlabs-io/babylon/x/mint/types" comettypes "github.com/cometbft/cometbft/types" "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/client/flags" @@ -26,16 +24,19 @@ import ( genutiltypes "github.com/cosmos/cosmos-sdk/x/genutil/types" govtypes "github.com/cosmos/cosmos-sdk/x/gov/types" govv1 "github.com/cosmos/cosmos-sdk/x/gov/types/v1" - minttypes "github.com/cosmos/cosmos-sdk/x/mint/types" stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" + ibcexported "github.com/cosmos/ibc-go/v8/modules/core/exported" + ibctypes "github.com/cosmos/ibc-go/v8/modules/core/types" "github.com/spf13/cobra" appparams "github.com/babylonlabs-io/babylon/app/params" bbn "github.com/babylonlabs-io/babylon/types" btccheckpointtypes "github.com/babylonlabs-io/babylon/x/btccheckpoint/types" btclightclienttypes "github.com/babylonlabs-io/babylon/x/btclightclient/types" + btcstakingtypes "github.com/babylonlabs-io/babylon/x/btcstaking/types" checkpointingtypes "github.com/babylonlabs-io/babylon/x/checkpointing/types" epochingtypes "github.com/babylonlabs-io/babylon/x/epoching/types" + finalitytypes "github.com/babylonlabs-io/babylon/x/finality/types" ) func PrepareGenesisCmd(defaultNodeHome string, mbm module.BasicManager) *cobra.Command { @@ -55,13 +56,16 @@ Example: serverCtx := server.GetServerContextFromCmd(cmd) config := serverCtx.Config - genesisCliArgs := parseGenesisFlags(cmd) + genesisCliArgs, err := parseGenesisFlags(cmd) + if err != nil { + return fmt.Errorf("failed to parse genesis flags: %w", err) + } genFile := config.GenesisFile() genesisState, genesis, err := genutiltypes.GenesisStateFromGenFile(genFile) if err != nil { - return fmt.Errorf("failed to unmarshal genesis state: %s", err) + return fmt.Errorf("failed to unmarshal genesis state: %w", err) } network := args[0] @@ -99,9 +103,13 @@ Example: genesisCliArgs.GenesisTime, genesisCliArgs.BlockGasLimit, genesisCliArgs.VoteExtensionEnableHeight, + genesisCliArgs.SignedBlocksWindow, + genesisCliArgs.MinSignedPerWindow, + genesisCliArgs.FinalitySigTimeout, + genesisCliArgs.JailDuration, + genesisCliArgs.FinalityActivationBlockHeight, ) } else if network == "mainnet" { - // TODO: mainnet genesis params panic("Mainnet params not implemented.") } else { return fmt.Errorf("please choose testnet or mainnet") @@ -193,7 +201,7 @@ func PrepareGenesis( // mint module genesis mintGenState := minttypes.DefaultGenesisState() - mintGenState.Params = genesisParams.MintParams + mintGenState.BondDenom = genesisParams.StakingParams.BondDenom genesisState[minttypes.ModuleName] = cdc.MustMarshalJSON(mintGenState) // distribution module genesis @@ -224,6 +232,8 @@ func PrepareGenesis( } genesisState[banktypes.ModuleName] = cdc.MustMarshalJSON(bankGenState) + genesisState[ibcexported.ModuleName] = clientCtx.Codec.MustMarshalJSON(ibctypes.DefaultGenesisState()) + appGenStateJSON, err := json.MarshalIndent(genesisState, "", " ") if err != nil { @@ -241,7 +251,6 @@ type GenesisParams struct { NativeCoinMetadatas []banktypes.Metadata StakingParams stakingtypes.Params - MintParams minttypes.Params DistributionParams distributiontypes.Params GovParams govv1.Params @@ -262,12 +271,12 @@ type GenesisParams struct { func TestnetGenesisParams( maxActiveValidators uint32, - btcConfirmationDepth uint64, - btcFinalizationTimeout uint64, + btcConfirmationDepth uint32, + btcFinalizationTimeout uint32, checkpointTag string, epochInterval uint64, baseBtcHeaderHex string, - baseBtcHeaderHeight uint64, + baseBtcHeaderHeight uint32, allowedReporters []string, covenantPKs []string, covenantQuorum uint32, @@ -290,6 +299,11 @@ func TestnetGenesisParams( genesisTime time.Time, blockGasLimit int64, voteExtensionEnableHeight int64, + signedBlocksWindow int64, + minSignedPerWindow sdkmath.LegacyDec, + finalitySigTimeout int64, + jailDuration time.Duration, + finalityActivationBlockHeight uint64, ) GenesisParams { genParams := GenesisParams{} @@ -323,17 +337,7 @@ func TestnetGenesisParams( genParams.StakingParams.MaxValidators = maxActiveValidators genParams.StakingParams.BondDenom = genParams.NativeCoinMetadatas[0].Base - genParams.MintParams = minttypes.DefaultParams() - genParams.MintParams.MintDenom = genParams.NativeCoinMetadatas[0].Base - genParams.MintParams.BlocksPerYear = blocksPerYear - // This should always work as inflation rate is already a float64 - genParams.MintParams.InflationRateChange = sdkmath.LegacyMustNewDecFromStr(fmt.Sprintf("%f", inflationRateChange)) - genParams.MintParams.InflationMin = sdkmath.LegacyMustNewDecFromStr(fmt.Sprintf("%f", inflationMin)) - genParams.MintParams.InflationMax = sdkmath.LegacyMustNewDecFromStr(fmt.Sprintf("%f", inflationMax)) - genParams.MintParams.GoalBonded = sdkmath.LegacyMustNewDecFromStr(fmt.Sprintf("%f", goalBonded)) - genParams.GovParams = govv1.DefaultParams() - // TODO investigate those numbers genParams.GovParams.MinDeposit = sdk.NewCoins(sdk.NewCoin( genParams.NativeCoinMetadatas[0].Base, sdkmath.NewInt(2_500_000_000), @@ -399,7 +403,6 @@ func TestnetGenesisParams( genParams.BtcstakingParams.MinSlashingTxFeeSat = minSlashingFee genParams.BtcstakingParams.MinCommissionRate = minCommissionRate genParams.BtcstakingParams.SlashingRate = slashingRate - genParams.BtcstakingParams.MaxActiveFinalityProviders = maxActiveFinalityProviders genParams.BtcstakingParams.MinUnbondingTimeBlocks = uint32(minUnbondingTime) genParams.BtcstakingParams.UnbondingFeeSat = unbondingFeeSat if err := genParams.BtcstakingParams.Validate(); err != nil { @@ -422,5 +425,16 @@ func TestnetGenesisParams( genParams.BlockGasLimit = blockGasLimit genParams.VoteExtensionsEnableHeight = voteExtensionEnableHeight + + genParams.FinalityParams.MaxActiveFinalityProviders = maxActiveFinalityProviders + genParams.FinalityParams.SignedBlocksWindow = signedBlocksWindow + genParams.FinalityParams.MinSignedPerWindow = minSignedPerWindow + genParams.FinalityParams.FinalitySigTimeout = finalitySigTimeout + genParams.FinalityParams.JailDuration = jailDuration + genParams.FinalityParams.FinalityActivationHeight = finalityActivationBlockHeight + if err := genParams.FinalityParams.Validate(); err != nil { + panic(err) + } + return genParams } diff --git a/cmd/babylond/cmd/genhelpers/set_btc_delegations_test.go b/cmd/babylond/cmd/genhelpers/set_btc_delegations_test.go index dde1d54a7..ef1da990d 100644 --- a/cmd/babylond/cmd/genhelpers/set_btc_delegations_test.go +++ b/cmd/babylond/cmd/genhelpers/set_btc_delegations_test.go @@ -9,18 +9,19 @@ import ( "testing" sdkmath "cosmossdk.io/math" - "github.com/babylonlabs-io/babylon/cmd/babylond/cmd/genhelpers" - "github.com/babylonlabs-io/babylon/testutil/datagen" - "github.com/babylonlabs-io/babylon/testutil/helper" - bbn "github.com/babylonlabs-io/babylon/types" - btcctypes "github.com/babylonlabs-io/babylon/x/btccheckpoint/types" - btcstktypes "github.com/babylonlabs-io/babylon/x/btcstaking/types" "github.com/btcsuite/btcd/chaincfg" "github.com/btcsuite/btcd/txscript" "github.com/cosmos/cosmos-sdk/client" genutiltest "github.com/cosmos/cosmos-sdk/x/genutil/client/testutil" genutiltypes "github.com/cosmos/cosmos-sdk/x/genutil/types" "github.com/stretchr/testify/require" + + "github.com/babylonlabs-io/babylon/cmd/babylond/cmd/genhelpers" + "github.com/babylonlabs-io/babylon/testutil/datagen" + "github.com/babylonlabs-io/babylon/testutil/helper" + bbn "github.com/babylonlabs-io/babylon/types" + btcctypes "github.com/babylonlabs-io/babylon/x/btccheckpoint/types" + btcstktypes "github.com/babylonlabs-io/babylon/x/btcstaking/types" ) func FuzzCmdSetBtcDels(f *testing.F) { @@ -67,8 +68,9 @@ func FuzzCmdSetBtcDels(f *testing.F) { slashingPkScript, err := txscript.PayToAddrScript(slashingAddress) require.NoError(t, err) - startHeight := datagen.RandomInt(r, 100) + 1 - endHeight := datagen.RandomInt(r, 1000) + startHeight + btcctypes.DefaultParams().CheckpointFinalizationTimeout + 1 + startHeight := uint32(datagen.RandomInt(r, 100)) + 1 + endHeight := uint32(datagen.RandomInt(r, 1000)) + startHeight + btcctypes.DefaultParams().CheckpointFinalizationTimeout + 1 + stakingTime := endHeight - startHeight slashingRate := sdkmath.LegacyNewDecWithPrec(int64(datagen.RandomInt(r, 41)+10), 2) slashingChangeLockTime := uint16(101) @@ -86,7 +88,7 @@ func FuzzCmdSetBtcDels(f *testing.F) { covenantPKs, covenantQuorum, slashingPkScript, - startHeight, endHeight, 10000, + stakingTime, startHeight, endHeight, 10000, slashingRate, slashingChangeLockTime, ) @@ -155,7 +157,7 @@ func FuzzCmdSetBtcDels(f *testing.F) { covenantPKs, covenantQuorum, slashingPkScript, - startHeight, endHeight, 10000, + stakingTime, startHeight, endHeight, 10000, slashingRate, slashingChangeLockTime, ) diff --git a/cmd/babylond/cmd/root.go b/cmd/babylond/cmd/root.go index efc9304c1..e5979db3a 100644 --- a/cmd/babylond/cmd/root.go +++ b/cmd/babylond/cmd/root.go @@ -153,22 +153,8 @@ func initAppConfig() (string, interface{}) { // Optionally allow the chain developer to overwrite the SDK's default // server config. - babylonConfig := DefaultBabylonConfig() + babylonConfig := DefaultBabylonAppConfig() babylonTemplate := DefaultBabylonTemplate() - // The SDK's default minimum gas price is set to "" (empty value) inside - // app.toml. If left empty by validators, the node will halt on startup. - // However, the chain developer can set a default app.toml value for their - // validators here. - // - // In summary: - // - if you leave srvCfg.MinGasPrices = "", all validators MUST tweak their - // own app.toml config, - // - if you set srvCfg.MinGasPrices non-empty, validators CAN tweak their - // own app.toml to override, or use this default value. - // - // In app, we set the min gas prices to 0. - babylonConfig.MinGasPrices = "0ubbn" - return babylonTemplate, babylonConfig } diff --git a/cmd/babylond/cmd/sizes_cmd.go b/cmd/babylond/cmd/sizes_cmd.go index 800c77730..17e310e68 100644 --- a/cmd/babylond/cmd/sizes_cmd.go +++ b/cmd/babylond/cmd/sizes_cmd.go @@ -18,7 +18,7 @@ const ( ) // r is a regular expression that matched the store key prefix -// we cannot use modules names direclty as sometimes module key != store key +// we cannot use modules names directly as sometimes module key != store key // for example account module has store key "acc" and module key "auth" var r, _ = regexp.Compile("s/k:[A-Za-z]+/") @@ -101,7 +101,7 @@ func PrintDBStats(db dbm.DB, printInterval int) { if err != nil { panic(err) } - fmt.Printf("****************** Retrived database iterator ******************\n") + fmt.Printf("****************** Retrieved database iterator ******************\n") defer itr.Close() for ; itr.Valid(); itr.Next() { @@ -172,7 +172,7 @@ func ModuleSizeCmd() *cobra.Command { }, } - cmd.Flags().Int(FlagPrintInterval, 100000, "interval between printing databse stats") + cmd.Flags().Int(FlagPrintInterval, 100000, "interval between printing database stats") return cmd } diff --git a/cmd/babylond/cmd/testnet.go b/cmd/babylond/cmd/testnet.go index e0c0d918d..bae46a5e6 100644 --- a/cmd/babylond/cmd/testnet.go +++ b/cmd/babylond/cmd/testnet.go @@ -3,7 +3,6 @@ package cmd import ( "bufio" "encoding/json" - "errors" "fmt" "net" "os" @@ -11,7 +10,6 @@ import ( "time" "cosmossdk.io/math" - appkeepers "github.com/babylonlabs-io/babylon/app/keepers" cmtconfig "github.com/cometbft/cometbft/config" cmtos "github.com/cometbft/cometbft/libs/os" cmttime "github.com/cometbft/cometbft/types/time" @@ -36,6 +34,8 @@ import ( stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" "github.com/spf13/cobra" + appkeepers "github.com/babylonlabs-io/babylon/app/keepers" + appparams "github.com/babylonlabs-io/babylon/app/params" "github.com/babylonlabs-io/babylon/privval" "github.com/babylonlabs-io/babylon/testutil/datagen" @@ -75,7 +75,10 @@ Example: serverCtx := server.GetServerContextFromCmd(cmd) config := serverCtx.Config - genesisCliArgs := parseGenesisFlags(cmd) + genesisCliArgs, err := parseGenesisFlags(cmd) + if err != nil { + return err + } outputDir, _ := cmd.Flags().GetString(flagOutputDir) keyringBackend, _ := cmd.Flags().GetString(flags.FlagKeyringBackend) @@ -88,9 +91,6 @@ Example: btcNetwork, _ := cmd.Flags().GetString(flagBtcNetwork) additionalAccount, _ := cmd.Flags().GetBool(flagAdditionalSenderAccount) timeBetweenBlocks, _ := cmd.Flags().GetUint64(flagTimeBetweenBlocks) - if err != nil { - return errors.New("base Bitcoin header height should be a uint64") - } genesisParams := TestnetGenesisParams( genesisCliArgs.MaxActiveValidators, @@ -122,6 +122,11 @@ Example: genesisCliArgs.GenesisTime, genesisCliArgs.BlockGasLimit, genesisCliArgs.VoteExtensionEnableHeight, + genesisCliArgs.SignedBlocksWindow, + genesisCliArgs.MinSignedPerWindow, + genesisCliArgs.FinalitySigTimeout, + genesisCliArgs.JailDuration, + genesisCliArgs.FinalityActivationBlockHeight, ) return InitTestnet( @@ -177,7 +182,7 @@ func InitTestnet( nodeIDs := make([]string, numValidators) valKeys := make([]*privval.ValidatorKeys, numValidators) - babylonConfig := DefaultBabylonConfig() + babylonConfig := DefaultBabylonAppConfig() babylonConfig.MinGasPrices = minGasPrices babylonConfig.API.Enable = true babylonConfig.API.Address = "tcp://0.0.0.0:1317" @@ -192,6 +197,11 @@ func InitTestnet( babylonConfig.GRPC.Enable = true babylonConfig.GRPC.Address = "0.0.0.0:9090" + // Disable IAVL cache by default as Babylon leaf nodes can be large, and in case + // of big cache values, Babylon node can run out of memory. + babylonConfig.IAVLCacheSize = 0 + babylonConfig.IAVLDisableFastNode = true + var ( genAccounts []authtypes.GenesisAccount genBalances []banktypes.Balance diff --git a/contrib/images/Makefile b/contrib/images/Makefile index e1def3991..c9502e882 100644 --- a/contrib/images/Makefile +++ b/contrib/images/Makefile @@ -4,34 +4,23 @@ BABYLON_VERSION_BEFORE_UPGRADE ?= v0.9.3 all: babylond cosmos-relayer -babylond: +babylond: babylond-rmi docker build --tag babylonlabs-io/babylond -f babylond/Dockerfile ${BABYLON_FULL_PATH} babylond-e2e: docker build --tag babylonlabs-io/babylond -f babylond/Dockerfile ${BABYLON_FULL_PATH} \ - --build-arg BUILD_TAGS="e2e" - -## TODO: once release docker public versions for tags, remove this! -babylond-before-upgrade: - docker build --tag babylonlabs-io/babylond-before-upgrade -f babylond/Dockerfile \ - --build-arg VERSION="${BABYLON_VERSION_BEFORE_UPGRADE}" ${BABYLON_FULL_PATH} + --build-arg BABYLON_BUILD_OPTIONS="testnet" babylond-rmi: docker rmi babylonlabs-io/babylond --force 2>/dev/null; true -babylond-rmi-upgrade: - docker rmi babylonlabs-io/babylond-before-upgrade --force 2>/dev/null; true - e2e-init-chain-rmi: docker rmi babylonlabs-io/babylond-e2e-init-chain --force 2>/dev/null; true -e2e-init-chain: +e2e-init-chain: e2e-init-chain-rmi @DOCKER_BUILDKIT=1 docker build -t babylonlabs-io/babylond-e2e-init-chain --build-arg E2E_SCRIPT_NAME=chain --platform=linux/x86_64 \ -f e2e-initialization/init.Dockerfile --build-arg VERSION="${BABYLON_VERSION_BEFORE_UPGRADE}" ${BABYLON_FULL_PATH} -e2e-init-chain-rmi: - docker rmi babylonlabs-io/babylond-e2e-init-chain 2>/dev/null; true - cosmos-relayer: cosmos-relayer-rmi docker build --tag babylonlabs-io/cosmos-relayer:${RELAYER_TAG} -f cosmos-relayer/Dockerfile \ ${BABYLON_FULL_PATH}/contrib/images/cosmos-relayer diff --git a/contrib/images/babylond/Dockerfile b/contrib/images/babylond/Dockerfile index 2b88ab848..7c1192f9e 100644 --- a/contrib/images/babylond/Dockerfile +++ b/contrib/images/babylond/Dockerfile @@ -1,45 +1,67 @@ -FROM golang:1.22 AS build-env +FROM golang:1.23-alpine AS build-env +# Customize to your build env + +# TARGETPLATFORM should be one of linux/amd64 or linux/arm64. +ARG TARGETPLATFORM="linux/amd64" # Version to build. Default is empty ARG VERSION -ARG BUILD_TAGS="" -ARG LEDGER_ENABLED="false" +ARG BABYLON_BUILD_OPTIONS="" ARG COSMOS_BUILD_OPTIONS="" +# Use muslc for static libs +ARG BUILD_TAGS="muslc" +ARG LEDGER_ENABLED="false" + + +# Install cli tools for building and final image +RUN apk add --update --no-cache make git bash gcc linux-headers eudev-dev ncurses-dev openssh curl jq +RUN apk add --no-cache musl-dev + +# Build WORKDIR /go/src/github.com/babylonlabs-io/babylon +# First cache dependencies +COPY go.mod go.sum /go/src/github.com/babylonlabs-io/babylon/ +RUN go mod download +# Then copy everything else COPY ./ /go/src/github.com/babylonlabs-io/babylon/ - -# Handle if version is set +# If version is set, then checkout this version RUN if [ -n "${VERSION}" ]; then \ - git fetch origin tag ${VERSION} --no-tags; \ + git fetch origin tag ${VERSION} --no-tags ; \ git checkout -f ${VERSION}; \ fi -# Cache mod dependencies -RUN go mod download +# Cosmwasm - Download correct libwasmvm version +RUN WASMVM_VERSION=$(go list -m github.com/CosmWasm/wasmvm/v2 | cut -d ' ' -f 2) && \ + wget https://github.com/CosmWasm/wasmvm/releases/download/$WASMVM_VERSION/libwasmvm_muslc.$(uname -m).a \ + -O /lib/libwasmvm_muslc.$(uname -m).a && \ + # verify checksum + wget https://github.com/CosmWasm/wasmvm/releases/download/$WASMVM_VERSION/checksums.txt -O /tmp/checksums.txt && \ + sha256sum /lib/libwasmvm_muslc.$(uname -m).a | grep $(cat /tmp/checksums.txt | grep libwasmvm_muslc.$(uname -m) | cut -d ' ' -f 1) RUN LEDGER_ENABLED=$LEDGER_ENABLED \ - BUILD_TAGS=$BUILD_TAGS \ + BABYLON_BUILD_OPTIONS=$BABYLON_BUILD_OPTIONS \ COSMOS_BUILD_OPTIONS=$COSMOS_BUILD_OPTIONS \ - LINK_STATICALLY=false \ + BUILD_TAGS=$BUILD_TAGS \ + LINK_STATICALLY=true \ make build -FROM debian:bookworm-slim AS wasm-link - -RUN apt-get update && apt-get install -y wget bash +FROM alpine:3.14 AS run +# Create a user +RUN addgroup --gid 1137 -S babylon && adduser --uid 1137 -S babylon -G babylon +RUN apk add bash curl jq # Label should match your github repo +ARG VERSION LABEL org.opencontainers.image.source="https://github.com/babylonlabs-io/babylond:${VERSION}" -# Install libraries -# Cosmwasm - Download correct libwasmvm version -COPY --from=build-env /go/src/github.com/babylonlabs-io/babylon/go.mod /tmp -RUN WASMVM_VERSION=$(grep github.com/CosmWasm/wasmvm /tmp/go.mod | cut -d' ' -f2) && \ - wget https://github.com/CosmWasm/wasmvm/releases/download/$WASMVM_VERSION/libwasmvm.$(uname -m).so \ - -O /lib/libwasmvm.$(uname -m).so && \ - # verify checksum - wget https://github.com/CosmWasm/wasmvm/releases/download/$WASMVM_VERSION/checksums.txt -O /tmp/checksums.txt && \ - sha256sum /lib/libwasmvm.$(uname -m).so | grep $(cat /tmp/checksums.txt | grep libwasmvm.$(uname -m) | cut -d ' ' -f 1) -RUN rm -f /tmp/go.mod +# Install Libraries +# COPY --from=build-env /usr/lib/libgcc_s.so.1 /lib/ +# COPY --from=build-env /lib/ld-musl*.so.1* /lib COPY --from=build-env /go/src/github.com/babylonlabs-io/babylon/build/babylond /bin/babylond + +# Set home directory and user +WORKDIR /home/babylon +RUN chown -R babylon /home/babylon +USER babylon \ No newline at end of file diff --git a/contrib/images/cosmos-relayer/Dockerfile b/contrib/images/cosmos-relayer/Dockerfile index 7f03954e5..5b23bc36d 100644 --- a/contrib/images/cosmos-relayer/Dockerfile +++ b/contrib/images/cosmos-relayer/Dockerfile @@ -7,7 +7,7 @@ WORKDIR /work ARG TARGETARCH # Download and install Go -ENV GOLANG_VERSION 1.21.4 +ENV GOLANG_VERSION 1.23.1 RUN echo "Target arch: ${TARGETARCH}" RUN echo "Go version: ${GOLANG_VERSION}" RUN wget -q https://golang.org/dl/go${GOLANG_VERSION}.linux-${TARGETARCH}.tar.gz && \ diff --git a/contrib/images/e2e-initialization/init.Dockerfile b/contrib/images/e2e-initialization/init.Dockerfile index 80c7ab973..c1c6b714d 100644 --- a/contrib/images/e2e-initialization/init.Dockerfile +++ b/contrib/images/e2e-initialization/init.Dockerfile @@ -1,4 +1,4 @@ -FROM golang:1.21 as build-env +FROM golang:1.23 AS build-env ARG E2E_SCRIPT_NAME # Version to build. Default is empty @@ -10,15 +10,19 @@ COPY ./ /go/src/github.com/babylonlabs-io/babylon/ # Handle if version is set RUN if [ -n "${VERSION}" ]; then \ - git fetch origin tag ${VERSION} --no-tags; \ - git checkout -f ${VERSION}; \ + git fetch origin tag ${VERSION} --no-tags ; \ + git checkout -f ${VERSION}; \ fi RUN LEDGER_ENABLED=false LINK_STATICALLY=false E2E_SCRIPT_NAME=${E2E_SCRIPT_NAME} make e2e-build-script FROM debian:bookworm-slim AS wasm-link -RUN apt-get update && apt-get install -y wget bash +ARG VERSION + +# Create a user +RUN addgroup --gid 1137 --system babylon && adduser --uid 1137 --gid 1137 --system --home /home/babylon babylon +RUN apt-get update && apt-get install -y bash curl jq wget # Label should match your github repo LABEL org.opencontainers.image.source="https://github.com/babylonlabs-io/babylond:${VERSION}" @@ -28,7 +32,7 @@ LABEL org.opencontainers.image.source="https://github.com/babylonlabs-io/babylon COPY --from=build-env /go/src/github.com/babylonlabs-io/babylon/go.mod /tmp RUN WASMVM_VERSION=$(grep github.com/CosmWasm/wasmvm /tmp/go.mod | cut -d' ' -f2) && \ wget https://github.com/CosmWasm/wasmvm/releases/download/$WASMVM_VERSION/libwasmvm.$(uname -m).so \ - -O /lib/libwasmvm.$(uname -m).so && \ + -O /lib/libwasmvm.$(uname -m).so && \ # verify checksum wget https://github.com/CosmWasm/wasmvm/releases/download/$WASMVM_VERSION/checksums.txt -O /tmp/checksums.txt && \ sha256sum /lib/libwasmvm.$(uname -m).so | grep $(cat /tmp/checksums.txt | grep libwasmvm.$(uname -m) | cut -d ' ' -f 1) @@ -38,10 +42,8 @@ RUN rm -f /tmp/go.mod ARG E2E_SCRIPT_NAME COPY --from=build-env /go/src/github.com/babylonlabs-io/babylon/build/${E2E_SCRIPT_NAME} /bin/${E2E_SCRIPT_NAME} - # Docker ARGs are not expanded in ENTRYPOINT in the exec mode. At the same time, # it is impossible to add CMD arguments when running a container in the shell mode. # As a workaround, we create the entrypoint.sh script to bypass these issues. RUN echo "#!/bin/bash\n${E2E_SCRIPT_NAME} \"\$@\"" >> entrypoint.sh && chmod +x entrypoint.sh - ENTRYPOINT ["./entrypoint.sh"] \ No newline at end of file diff --git a/crypto/ecdsa/ecdsa.go b/crypto/ecdsa/ecdsa.go index fed6dc1fb..74cda74f3 100644 --- a/crypto/ecdsa/ecdsa.go +++ b/crypto/ecdsa/ecdsa.go @@ -21,10 +21,14 @@ func magicHash(msg string) chainhash.Hash { buf := bytes.NewBuffer(nil) // we have to use wire.WriteVarString which encodes the string length into the byte array in Bitcoin's own way // message prefix - // NOTE: we have control over the buffer so no need to check error - wire.WriteVarString(buf, 0, MAGIC_MESSAGE_PREFIX) //nolint:errcheck + // NOTE: we have control over the buffer so errors should not happen + if err := wire.WriteVarString(buf, 0, MAGIC_MESSAGE_PREFIX); err != nil { + panic(err) + } // message - wire.WriteVarString(buf, 0, msg) //nolint:errcheck + if err := wire.WriteVarString(buf, 0, msg); err != nil { + panic(err) + } bytes := buf.Bytes() return chainhash.DoubleHashH(bytes) diff --git a/crypto/schnorr-adaptor-signature/keys.go b/crypto/schnorr-adaptor-signature/keys.go index 177a6156d..4a2ade947 100644 --- a/crypto/schnorr-adaptor-signature/keys.go +++ b/crypto/schnorr-adaptor-signature/keys.go @@ -43,7 +43,7 @@ func NewDecyptionKeyFromBytes(decKeyBytes []byte) (*DecryptionKey, error) { } var decKeyScalar btcec.ModNScalar - decKeyScalar.SetByteSlice(decKeyBytes) //nolint:errcheck + decKeyScalar.SetByteSlice(decKeyBytes) return NewDecyptionKeyFromModNScalar(&decKeyScalar) } diff --git a/crypto/schnorr-adaptor-signature/sig.go b/crypto/schnorr-adaptor-signature/sig.go index 09cebcfd8..7116664df 100644 --- a/crypto/schnorr-adaptor-signature/sig.go +++ b/crypto/schnorr-adaptor-signature/sig.go @@ -224,7 +224,7 @@ func NewAdaptorSignatureFromBytes(asigBytes []byte) (*AdaptorSignature, error) { } // extract sHat var sHat btcec.ModNScalar - sHat.SetByteSlice(asigBytes[JacobianPointSize : JacobianPointSize+ModNScalarSize]) //nolint:errcheck + sHat.SetByteSlice(asigBytes[JacobianPointSize : JacobianPointSize+ModNScalarSize]) // extract needNegation needNegation := asigBytes[AdaptorSignatureSize-1] != 0x00 diff --git a/docker-compose.yml b/docker-compose.yml deleted file mode 100644 index b92576e3f..000000000 --- a/docker-compose.yml +++ /dev/null @@ -1,95 +0,0 @@ -version: "3" - -services: - babylondnode0: - container_name: babylondnode0 - image: "babylonlabs-io/babylond" - command: > - babylond --home /babylondhome start --log_format 'plain' 2>&1 | tee /babylondhome/babylond.log - cap_add: - - SYS_PTRACE - security_opt: - - seccomp:unconfined - ports: - - "26656-26657:26656-26657" - - "1317:1317" - - "9090:9090" - - "2345:2345" - volumes: - - ./.testnets/node0/babylond:/babylondhome:Z - networks: - localnet: - ipv4_address: 192.168.10.2 - - babylondnode1: - container_name: babylondnode1 - image: "babylonlabs-io/babylond" - command: > - babylond --home /babylondhome start --log_format 'plain' 2>&1 | tee /babylondhome/babylond.log - cap_add: - - SYS_PTRACE - security_opt: - - seccomp:unconfined - ports: - - "26666-26667:26656-26657" - - "1318:1317" - - "9091:9090" - - "2346:2345" - volumes: - - ./.testnets/node1/babylond:/babylondhome:Z - networks: - localnet: - ipv4_address: 192.168.10.3 - - babylondnode2: - container_name: babylondnode2 - image: "babylonlabs-io/babylond" - environment: - - LOG=${LOG:-babylond.log} - command: > - babylond --home /babylondhome start --log_format 'plain' 2>&1 | tee /babylondhome/babylond.log - cap_add: - - SYS_PTRACE - security_opt: - - seccomp:unconfined - ports: - - "26676-26677:26656-26657" - - "1319:1317" - - "9092:9090" - - "2347:2345" - volumes: - - ./.testnets/node2/babylond:/babylondhome:Z - networks: - localnet: - ipv4_address: 192.168.10.4 - - babylondnode3: - container_name: babylondnode3 - image: "babylonlabs-io/babylond" - environment: - - LOG=${LOG:-babylond.log} - command: > - babylond --home /babylondhome start --log_format 'plain' 2>&1 | tee /babylondhome/babylond.log - cap_add: - - SYS_PTRACE - security_opt: - - seccomp:unconfined - ports: - - "26686-26687:26656-26657" - - "1320:1317" - - "9093:9090" - - "2348:2345" - volumes: - - ./.testnets/node3/babylond:/babylondhome:Z - networks: - localnet: - ipv4_address: 192.168.10.5 - - -networks: - localnet: - driver: bridge - ipam: - driver: default - config: - - subnet: 192.168.10.0/25 diff --git a/docs/run-node.md b/docs/run-node.md index a5505994b..4f2cef4f2 100644 --- a/docs/run-node.md +++ b/docs/run-node.md @@ -124,21 +124,6 @@ babylond --home .testnet/node0/babylond --chain-id chain-test \ tx btclightclient insert-header ``` -## Running a multi-node testnet - -We provide support for running a multi-node testnet using Docker. To build it - -```console -make localnet-start -``` - -The corresponding node directories can be found under `.testnets` - -```console -$ ls .testnets -gentxs node0 node1 node2 node3 -``` - ## Running node in Production When running the Babylon node in a production setting, operators should adhere to  diff --git a/go.mod b/go.mod index 4de35be67..2495646ad 100644 --- a/go.mod +++ b/go.mod @@ -1,28 +1,26 @@ -go 1.22 - -toolchain go1.22.7 +go 1.23.1 module github.com/babylonlabs-io/babylon require ( - github.com/CosmWasm/wasmd v0.51.0 + github.com/CosmWasm/wasmd v0.53.0 github.com/btcsuite/btcd v0.24.2 - github.com/cometbft/cometbft v0.38.10 - github.com/cometbft/cometbft-db v0.9.1 // indirect + github.com/cometbft/cometbft v0.38.14 + github.com/cometbft/cometbft-db v0.15.0 // indirect github.com/cosmos/cosmos-sdk v0.50.9 github.com/cosmos/ibc-go/modules/light-clients/08-wasm v0.0.0-20240429153234-e1e6da7e4ead - github.com/cosmos/relayer/v2 v2.5.1 + github.com/cosmos/relayer/v2 v2.5.2 github.com/gorilla/mux v1.8.1 github.com/grpc-ecosystem/grpc-gateway v1.16.0 github.com/pkg/errors v0.9.1 - github.com/spf13/cast v1.6.0 - github.com/spf13/cobra v1.8.0 - github.com/spf13/viper v1.18.2 + github.com/spf13/cast v1.7.0 + github.com/spf13/cobra v1.8.1 + github.com/spf13/viper v1.19.0 github.com/stretchr/testify v1.9.0 github.com/supranational/blst v0.3.11 google.golang.org/genproto v0.0.0-20240227224415-6ceb2ff114de // indirect - google.golang.org/grpc v1.66.1 - google.golang.org/protobuf v1.34.2 + google.golang.org/grpc v1.67.1 + google.golang.org/protobuf v1.35.1 gopkg.in/yaml.v2 v2.4.0 ) @@ -33,30 +31,30 @@ require ( cosmossdk.io/core v0.11.1 cosmossdk.io/depinject v1.0.0 cosmossdk.io/errors v1.0.1 - cosmossdk.io/log v1.3.1 + cosmossdk.io/log v1.4.1 cosmossdk.io/math v1.3.0 cosmossdk.io/store v1.1.0 - cosmossdk.io/tools/confix v0.1.1 - cosmossdk.io/x/circuit v0.1.0 + cosmossdk.io/tools/confix v0.1.2 + cosmossdk.io/x/circuit v0.1.1 cosmossdk.io/x/evidence v0.1.1 cosmossdk.io/x/feegrant v0.1.1 cosmossdk.io/x/tx v0.13.4 - cosmossdk.io/x/upgrade v0.1.2 - github.com/CosmWasm/wasmvm/v2 v2.0.3 + cosmossdk.io/x/upgrade v0.1.4 + github.com/CosmWasm/wasmvm/v2 v2.1.3 github.com/avast/retry-go/v4 v4.5.1 github.com/babylonlabs-io/babylon-sdk/demo v0.0.0-20240814002132-55e711397a82 github.com/babylonlabs-io/cosmwasm-client v0.0.0-20240908181148-88f10f0917e6 github.com/bits-and-blooms/bitset v1.10.0 github.com/boljen/go-bitmap v0.0.0-20151001105940-23cd2fb0ce7d github.com/btcsuite/btcd/btcec/v2 v2.3.2 - github.com/btcsuite/btcd/btcutil v1.1.5 + github.com/btcsuite/btcd/btcutil v1.1.6 github.com/btcsuite/btcd/chaincfg/chainhash v1.1.0 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/ibc-go/modules/capability v1.0.0 - github.com/cosmos/ibc-go/v8 v8.3.2 - github.com/decred/dcrd/dcrec/secp256k1/v4 v4.2.0 + github.com/cosmos/gogoproto v1.7.0 + github.com/cosmos/ibc-go/modules/capability v1.0.1 + github.com/cosmos/ibc-go/v8 v8.4.0 + github.com/decred/dcrd/dcrec/secp256k1/v4 v4.3.0 github.com/golang/mock v1.6.0 github.com/golang/protobuf v1.5.4 github.com/hashicorp/go-metrics v0.5.3 @@ -68,7 +66,7 @@ require ( go.uber.org/zap v1.26.0 golang.org/x/exp v0.0.0-20240404231335-c0f41cb1a7a0 golang.org/x/sync v0.8.0 - google.golang.org/genproto/googleapis/api v0.0.0-20240903143218-8af14fe29dc1 + google.golang.org/genproto/googleapis/api v0.0.0-20240814211410-ddb44dafa142 ) require ( @@ -77,29 +75,26 @@ require ( github.com/beorn7/perks v1.0.1 // indirect github.com/bgentry/speakeasy v0.1.1-0.20220910012023-760eaf8b6816 // indirect github.com/btcsuite/btclog v0.0.0-20170628155309-84c8d2346e9f // indirect - github.com/cespare/xxhash v1.1.0 // indirect github.com/cespare/xxhash/v2 v2.3.0 // indirect github.com/cosmos/btcutil v1.0.5 github.com/cosmos/go-bip39 v1.0.0 - github.com/cosmos/iavl v1.1.2 // indirect + github.com/cosmos/iavl v1.2.0 // indirect github.com/cosmos/ledger-cosmos-go v0.13.3 // indirect github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect github.com/desertbit/timer v0.0.0-20180107155436-c41aec40b27f // indirect - github.com/dgraph-io/badger/v2 v2.2007.4 // indirect - github.com/dgraph-io/ristretto v0.1.1 // indirect - github.com/dgryski/go-farm v0.0.0-20200201041132-a6ae2369ad13 // indirect + github.com/dgraph-io/ristretto v0.1.2-0.20240116140435-c67e07994f91 // indirect github.com/dustin/go-humanize v1.0.1 // indirect github.com/dvsekhvalnov/jose2go v1.6.0 // indirect github.com/fsnotify/fsnotify v1.7.0 // indirect - github.com/go-kit/kit v0.12.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/golang/snappy v0.0.5-0.20220116011046-fa5810519dcb // indirect - github.com/google/btree v1.1.2 // indirect + github.com/google/btree v1.1.3 // indirect github.com/google/orderedcode v0.0.1 // indirect github.com/gorilla/handlers v1.5.2 // indirect - github.com/gorilla/websocket v1.5.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-immutable-radix v1.3.1 // indirect @@ -109,43 +104,43 @@ require ( github.com/improbable-eng/grpc-web v0.15.0 // indirect github.com/inconshreveable/mousetrap v1.1.0 // indirect github.com/jmhodges/levigo v1.0.0 // indirect - github.com/klauspost/compress v1.17.7 // indirect - github.com/lib/pq v1.10.7 // indirect + github.com/klauspost/compress v1.17.9 // indirect + github.com/lib/pq v1.10.9 // indirect github.com/magiconair/properties v1.8.7 // indirect github.com/mattn/go-isatty v0.0.20 // indirect - github.com/minio/highwayhash v1.0.2 // indirect + github.com/minio/highwayhash v1.0.3 // indirect github.com/mitchellh/mapstructure v1.5.0 // indirect github.com/mtibben/percent v0.2.1 // indirect - github.com/petermattis/goid v0.0.0-20231207134359-e60b3f734c67 // indirect + github.com/petermattis/goid v0.0.0-20240813172612-4fcff4a6cae7 // indirect github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect - github.com/prometheus/client_golang v1.19.0 + github.com/prometheus/client_golang v1.20.5 github.com/prometheus/client_model v0.6.1 // indirect - github.com/prometheus/common v0.52.2 // indirect - github.com/prometheus/procfs v0.13.0 // indirect + github.com/prometheus/common v0.60.1 // indirect + github.com/prometheus/procfs v0.15.1 // indirect github.com/rcrowley/go-metrics v0.0.0-20201227073835-cf1acfcdf475 // indirect - github.com/rs/cors v1.8.3 // indirect - github.com/sasha-s/go-deadlock v0.3.1 // indirect + github.com/rs/cors v1.11.1 // indirect + github.com/sasha-s/go-deadlock v0.3.5 // indirect github.com/spf13/afero v1.11.0 // indirect github.com/spf13/pflag v1.0.5 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/zondax/hid v0.9.2 // indirect - go.etcd.io/bbolt v1.3.8 // indirect - golang.org/x/crypto v0.27.0 - golang.org/x/sys v0.25.0 // indirect - golang.org/x/term v0.24.0 // indirect - golang.org/x/text v0.18.0 // indirect + go.etcd.io/bbolt v1.4.0-alpha.0.0.20240404170359-43604f3112c5 // indirect + golang.org/x/crypto v0.28.0 + golang.org/x/sys v0.26.0 // indirect + golang.org/x/term v0.25.0 // indirect + golang.org/x/text v0.19.0 // indirect gopkg.in/ini.v1 v1.67.0 // indirect nhooyr.io/websocket v1.8.6 // indirect ) require ( cloud.google.com/go v0.112.1 // indirect - cloud.google.com/go/compute/metadata v0.3.0 // indirect + cloud.google.com/go/compute/metadata v0.5.0 // indirect cloud.google.com/go/iam v1.1.6 // indirect cloud.google.com/go/storage v1.38.0 // indirect - cosmossdk.io/x/nft v0.1.0 // indirect + cosmossdk.io/x/nft v0.1.1 // indirect dario.cat/mergo v1.0.0 // indirect github.com/99designs/go-keychain v0.0.0-20191008050251-8e49817e8af4 // indirect github.com/Azure/go-ansiterm v0.0.0-20230124172434-306776ec8161 // indirect @@ -160,21 +155,24 @@ require ( github.com/cenkalti/backoff/v4 v4.3.0 // indirect github.com/chzyer/readline v1.5.1 // indirect github.com/cockroachdb/apd/v2 v2.0.2 // indirect - github.com/cockroachdb/errors v1.11.1 // indirect + github.com/cockroachdb/errors v1.11.3 // indirect + github.com/cockroachdb/fifo v0.0.0-20240606204812-0bbfbd93a7ce // indirect github.com/cockroachdb/logtags v0.0.0-20230118201751-21c54148d20b // indirect - github.com/cockroachdb/pebble v1.1.0 // indirect + github.com/cockroachdb/pebble v1.1.2 // indirect github.com/cockroachdb/redact v1.1.5 // indirect github.com/cockroachdb/tokenbucket v0.0.0-20230807174530-cc333fc44b06 // indirect github.com/consensys/bavard v0.1.13 // indirect github.com/consensys/gnark-crypto v0.12.1 // indirect github.com/containerd/continuity v0.3.0 // indirect github.com/cosmos/gogogateway v1.2.0 // indirect + github.com/cosmos/ibc-go/modules/apps/callbacks v0.2.1-0.20231113120333-342c00b0f8bd // indirect github.com/cosmos/ics23/go v0.10.0 // indirect github.com/crate-crypto/go-kzg-4844 v0.7.0 // indirect github.com/creachadair/atomicfile v0.3.1 // indirect github.com/creachadair/tomledit v0.0.24 // indirect github.com/danieljoos/wincred v1.1.2 // indirect github.com/decred/dcrd/crypto/blake256 v1.0.1 // indirect + github.com/dgraph-io/badger/v4 v4.3.0 // indirect github.com/distribution/reference v0.5.0 // indirect github.com/docker/cli v25.0.6+incompatible // indirect github.com/docker/docker v25.0.6+incompatible // indirect @@ -190,17 +188,17 @@ require ( github.com/go-logr/stdr v1.2.2 // indirect github.com/gogo/googleapis v1.4.1 // indirect github.com/gogo/protobuf v1.3.2 // indirect - github.com/golang/glog v1.2.1 // indirect github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect + github.com/google/flatbuffers v2.0.8+incompatible // indirect github.com/google/go-cmp v0.6.0 // indirect github.com/google/gofuzz v1.2.0 // indirect github.com/google/s2a-go v0.1.7 // indirect github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510 // indirect github.com/google/uuid v1.6.0 // indirect github.com/googleapis/enterprise-certificate-proxy v0.3.2 // indirect - github.com/googleapis/gax-go/v2 v2.12.2 // indirect + github.com/googleapis/gax-go/v2 v2.12.3 // indirect github.com/hashicorp/go-cleanhttp v0.5.2 // indirect - github.com/hashicorp/go-getter v1.7.3 // indirect + github.com/hashicorp/go-getter v1.7.5 // indirect github.com/hashicorp/go-hclog v1.5.0 // indirect github.com/hashicorp/go-plugin v1.5.2 // indirect github.com/hashicorp/go-safetemp v1.0.0 // indirect @@ -214,23 +212,25 @@ require ( github.com/kkdai/bstream v0.0.0-20161212061736-f391b8402d23 // 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/linxGnu/grocksdb v1.9.3 // indirect github.com/manifoldco/promptui v0.9.0 // indirect github.com/mattn/go-colorable v0.1.13 // indirect github.com/mitchellh/go-homedir v1.1.0 // indirect github.com/mitchellh/go-testing-interface v1.14.1 // indirect github.com/mmcloughlin/addchain v0.4.0 // indirect github.com/moby/term v0.0.0-20221205130635-1aeaba878587 // 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/opencontainers/go-digest v1.0.0 // indirect github.com/opencontainers/image-spec v1.1.0-rc2 // indirect - github.com/opencontainers/runc v1.1.5 // indirect - github.com/pelletier/go-toml/v2 v2.1.0 // indirect + github.com/opencontainers/runc v1.1.12 // indirect + github.com/pelletier/go-toml/v2 v2.2.2 // indirect github.com/rogpeppe/go-internal v1.12.0 // indirect - github.com/rs/zerolog v1.32.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/shamaton/msgpack/v2 v2.2.0 // indirect github.com/sirupsen/logrus v1.9.3 // indirect github.com/sourcegraph/conc v0.3.0 // indirect github.com/strangelove-ventures/cometbft-client v0.1.0 // indirect @@ -245,18 +245,17 @@ require ( go.opencensus.io v0.24.0 // indirect go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.49.0 // indirect go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.49.0 // indirect - go.opentelemetry.io/otel v1.30.0 // indirect - go.opentelemetry.io/otel/metric v1.30.0 // indirect - go.opentelemetry.io/otel/sdk v1.30.0 // indirect - go.opentelemetry.io/otel/trace v1.30.0 // indirect + go.opentelemetry.io/otel v1.24.0 // indirect + go.opentelemetry.io/otel/metric v1.24.0 // indirect + go.opentelemetry.io/otel/trace v1.24.0 // indirect go.uber.org/multierr v1.11.0 // indirect golang.org/x/mod v0.17.0 // indirect - golang.org/x/net v0.29.0 // indirect - golang.org/x/oauth2 v0.22.0 // indirect + golang.org/x/net v0.30.0 // indirect + golang.org/x/oauth2 v0.23.0 // indirect golang.org/x/time v0.5.0 // indirect golang.org/x/tools v0.21.1-0.20240508182429-e35e4ccd0d2d // indirect - google.golang.org/api v0.169.0 // indirect - google.golang.org/genproto/googleapis/rpc v0.0.0-20240903143218-8af14fe29dc1 // indirect + google.golang.org/api v0.171.0 // indirect + google.golang.org/genproto/googleapis/rpc v0.0.0-20240814211410-ddb44dafa142 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect gotest.tools/v3 v3.5.1 // indirect pgregory.net/rapid v1.1.0 // indirect @@ -269,9 +268,6 @@ require ( replace ( // use cosmos fork of keyring github.com/99designs/keyring => github.com/cosmos/keyring v1.2.0 - // Fix upstream GHSA-h395-qcrw-5vmq vulnerability. - // TODO Remove it: https://github.com/cosmos/cosmos-sdk/issues/10409 - github.com/gin-gonic/gin => github.com/gin-gonic/gin v1.9.1 github.com/gogo/protobuf => github.com/regen-network/protobuf v1.3.3-alpha.regen.1 diff --git a/go.sum b/go.sum index 954c7c9e8..5ae273615 100644 --- a/go.sum +++ b/go.sum @@ -213,8 +213,9 @@ cloud.google.com/go/compute/metadata v0.1.0/go.mod h1:Z1VN+bulIf6bt4P/C37K4DyZYZ cloud.google.com/go/compute/metadata v0.2.0/go.mod h1:zFmK7XCadkQkj6TtorcaGlCW1hT1fIilQDwofLpJ20k= cloud.google.com/go/compute/metadata v0.2.1/go.mod h1:jgHgmJd2RKBGzXqF5LR2EZMGxBkeanZ9wwa75XHJgOM= cloud.google.com/go/compute/metadata v0.2.3/go.mod h1:VAV5nSsACxMJvgaAuX6Pk2AawlZn8kiOGuCv6gTkwuA= -cloud.google.com/go/compute/metadata v0.3.0 h1:Tz+eQXMEqDIKRsmY3cHTL6FVaynIjX2QxYC4trgAKZc= cloud.google.com/go/compute/metadata v0.3.0/go.mod h1:zFmK7XCadkQkj6TtorcaGlCW1hT1fIilQDwofLpJ20k= +cloud.google.com/go/compute/metadata v0.5.0 h1:Zr0eK8JbFv6+Wi4ilXAR8FJ3wyNdpxHKJNPos6LTZOY= +cloud.google.com/go/compute/metadata v0.5.0/go.mod h1:aHnloV2TPI38yx4s9+wAZhHykWvVCfu7hQbF+9CWoiY= cloud.google.com/go/contactcenterinsights v1.3.0/go.mod h1:Eu2oemoePuEFc/xKFPjbTuPSj0fYJcPls9TFlPNnHHY= cloud.google.com/go/contactcenterinsights v1.4.0/go.mod h1:L2YzkGbPsv+vMQMCADxJoT9YiTTnSEd6fEvCeHTYVck= cloud.google.com/go/contactcenterinsights v1.6.0/go.mod h1:IIDlT6CLcDoyv79kDv8iWxMSTZhLxSCofVV5W6YFM/w= @@ -768,26 +769,26 @@ 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/log v1.4.1 h1:wKdjfDRbDyZRuWa8M+9nuvpVYxrEOwbD/CA8hvhU8QM= +cosmossdk.io/log v1.4.1/go.mod h1:k08v0Pyq+gCP6phvdI6RCGhLf/r425UT6Rk/m+o74rU= cosmossdk.io/math v1.3.0 h1:RC+jryuKeytIiictDslBP9i1fhkVm6ZDmZEoNP316zE= cosmossdk.io/math v1.3.0/go.mod h1:vnRTxewy+M7BtXBNFybkuhSH4WfedVAAnERHgVFhp3k= cosmossdk.io/store v1.1.0 h1:LnKwgYMc9BInn9PhpTFEQVbL9UK475G2H911CGGnWHk= cosmossdk.io/store v1.1.0/go.mod h1:oZfW/4Fc/zYqu3JmQcQdUJ3fqu5vnYTn3LZFFy8P8ng= -cosmossdk.io/tools/confix v0.1.1 h1:aexyRv9+y15veH3Qw16lxQwo+ki7r2I+g0yNTEFEQM8= -cosmossdk.io/tools/confix v0.1.1/go.mod h1:nQVvP1tHsGXS83PonPVWJtSbddIqyjEw99L4M3rPJyQ= -cosmossdk.io/x/circuit v0.1.0 h1:IAej8aRYeuOMritczqTlljbUVHq1E85CpBqaCTwYgXs= -cosmossdk.io/x/circuit v0.1.0/go.mod h1:YDzblVE8+E+urPYQq5kq5foRY/IzhXovSYXb4nwd39w= +cosmossdk.io/tools/confix v0.1.2 h1:2hoM1oFCNisd0ltSAAZw2i4ponARPmlhuNu3yy0VwI4= +cosmossdk.io/tools/confix v0.1.2/go.mod h1:7XfcbK9sC/KNgVGxgLM0BrFbVcR/+6Dg7MFfpx7duYo= +cosmossdk.io/x/circuit v0.1.1 h1:KPJCnLChWrxD4jLwUiuQaf5mFD/1m7Omyo7oooefBVQ= +cosmossdk.io/x/circuit v0.1.1/go.mod h1:B6f/urRuQH8gjt4eLIXfZJucrbreuYrKh5CSjaOxr+Q= cosmossdk.io/x/evidence v0.1.1 h1:Ks+BLTa3uftFpElLTDp9L76t2b58htjVbSZ86aoK/E4= cosmossdk.io/x/evidence v0.1.1/go.mod h1:OoDsWlbtuyqS70LY51aX8FBTvguQqvFrt78qL7UzeNc= cosmossdk.io/x/feegrant v0.1.1 h1:EKFWOeo/pup0yF0svDisWWKAA9Zags6Zd0P3nRvVvw8= cosmossdk.io/x/feegrant v0.1.1/go.mod h1:2GjVVxX6G2fta8LWj7pC/ytHjryA6MHAJroBWHFNiEQ= -cosmossdk.io/x/nft v0.1.0 h1:VhcsFiEK33ODN27kxKLa0r/CeFd8laBfbDBwYqCyYCM= -cosmossdk.io/x/nft v0.1.0/go.mod h1:ec4j4QAO4mJZ+45jeYRnW7awLHby1JZANqe1hNZ4S3g= +cosmossdk.io/x/nft v0.1.1 h1:pslAVS8P5NkW080+LWOamInjDcq+v2GSCo+BjN9sxZ8= +cosmossdk.io/x/nft v0.1.1/go.mod h1:Kac6F6y2gsKvoxU+fy8uvxRTi4BIhLOor2zgCNQwVgY= cosmossdk.io/x/tx v0.13.4 h1:Eg0PbJgeO0gM8p5wx6xa0fKR7hIV6+8lC56UrsvSo0Y= cosmossdk.io/x/tx v0.13.4/go.mod h1:BkFqrnGGgW50Y6cwTy+JvgAhiffbGEKW6KF9ufcDpvk= -cosmossdk.io/x/upgrade v0.1.2 h1:O2FGb0mVSXl7P6BQm9uV3hRVKom1zBLDGhd4G8jysJg= -cosmossdk.io/x/upgrade v0.1.2/go.mod h1:P+e4/ZNd8km7lTAX5hC2pXz/042YDcB7gzKTHuY53nc= +cosmossdk.io/x/upgrade v0.1.4 h1:/BWJim24QHoXde8Bc64/2BSEB6W4eTydq0X/2f8+g38= +cosmossdk.io/x/upgrade v0.1.4/go.mod h1:9v0Aj+fs97O+Ztw+tG3/tp5JSlrmT7IcFhAebQHmOPo= dario.cat/mergo v1.0.0 h1:AGCNq9Evsj31mOgNPcLyXc+4PNABt905YmuqPYYpBWk= dario.cat/mergo v1.0.0/go.mod h1:uNxQE+84aUszobStD9th8a29P2fMDhsBdgRYvZOxGmk= dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU= @@ -801,10 +802,10 @@ github.com/Azure/go-ansiterm v0.0.0-20230124172434-306776ec8161 h1:L/gRVlceqvL25 github.com/Azure/go-ansiterm v0.0.0-20230124172434-306776ec8161/go.mod h1:xomTg63KZ2rFqZQzSB4Vz2SUXa1BpHTVz9L5PTmPC4E= github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo= -github.com/CosmWasm/wasmd v0.51.0 h1:3A2o20RrdF7P1D3Xb+R7A/pHbbHWsYCDXrHLa7S0SC8= -github.com/CosmWasm/wasmd v0.51.0/go.mod h1:7TSaj5HoolghujuVWeExqmcUKgpcYWEySGLSODbnnwY= -github.com/CosmWasm/wasmvm/v2 v2.0.3 h1:G9jpwDk+qFUfDkXCigpWPn9JTGM0H7egKzWQnMEONwE= -github.com/CosmWasm/wasmvm/v2 v2.0.3/go.mod h1:su9lg5qLr7adV95eOfzjZWkGiky8WNaNIHDr7Fpu7Ck= +github.com/CosmWasm/wasmd v0.53.0 h1:kdaoAi20bIb4VCsxw9pRaT2g5PpIp82Wqrr9DRVN9ao= +github.com/CosmWasm/wasmd v0.53.0/go.mod h1:FJl/aWjdpGof3usAMFQpDe07Rkx77PUzp0cygFMOvtw= +github.com/CosmWasm/wasmvm/v2 v2.1.3 h1:CSJTauZqkHyb9yic6JVYCjiGUgxI2MJV2QzfSu8m49c= +github.com/CosmWasm/wasmvm/v2 v2.1.3/go.mod h1:bMhLQL4Yp9CzJi9A83aR7VO9wockOsSlZbT4ztOl6bg= 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= @@ -815,8 +816,6 @@ github.com/Microsoft/go-winio v0.6.1 h1:9/kr64B9VUZrLm5YYwbGtUJnMgqWVOdUAXu6Migc github.com/Microsoft/go-winio v0.6.1/go.mod h1:LRdKpFKfdobln8UmuiYcKPot9D2v6svN5+sAH+4kjUM= github.com/Nvveen/Gotty v0.0.0-20120604004816-cd527374f1e5 h1:TngWCqHvy9oXAN6lEVMRuU21PR1EtLVZJmdB18Gu3Rw= github.com/Nvveen/Gotty v0.0.0-20120604004816-cd527374f1e5/go.mod h1:lmUJ/7eu/Q8D7ML55dXQrVaamCz2vxCfdQBasLZfHKk= -github.com/OneOfOne/xxhash v1.2.2 h1:KMrpdQIwFcEqXDklaen+P1axHaj9BSKzvpUUfnHldSE= -github.com/OneOfOne/xxhash v1.2.2/go.mod h1:HSdplMjZKSmBqAxg5vPj2TmRDmfkzw+cTzAElWljhcU= github.com/Shopify/sarama v1.19.0/go.mod h1:FVkBWblsNy7DGZRfXLU0O9RCGt5g3g3yEuWXgklEdEo= github.com/Shopify/toxiproxy v2.1.4+incompatible/go.mod h1:OXgGpZ6Cli1/URJOF1DMxUHB2q5Ap20/P/eIdh4G0pI= github.com/StackExchange/wmi v1.2.1 h1:VIkavFPXSjcnS+O8yTq7NI32k0R5Aj+v39y29VYDOSA= @@ -825,8 +824,8 @@ github.com/VictoriaMetrics/fastcache v1.12.1 h1:i0mICQuojGDL3KblA7wUNlY5lOK6a4bw github.com/VictoriaMetrics/fastcache v1.12.1/go.mod h1:tX04vaqcNoQeGLD+ra5pU5sWkuxnzWhEzLwhP9w653o= github.com/VividCortex/gohistogram v1.0.0 h1:6+hBz+qvs0JOrrNhhmR7lFxo5sINxBCGXrdtl/UvroE= github.com/VividCortex/gohistogram v1.0.0/go.mod h1:Pf5mBqqDxYaXu3hDrrU+w6nw50o/4+TcAqDqk/vUH7g= -github.com/adlio/schema v1.3.3 h1:oBJn8I02PyTB466pZO1UZEn1TV5XLlifBSyMrmHl/1I= -github.com/adlio/schema v1.3.3/go.mod h1:1EsRssiv9/Ce2CMzq5DoL7RiMshhuigQxrR4DMV9fHg= +github.com/adlio/schema v1.3.6 h1:k1/zc2jNfeiZBA5aFTRy37jlBIuCkXCm0XmvpzCKI9I= +github.com/adlio/schema v1.3.6/go.mod h1:qkxwLgPBd1FgLRHYVCmQT/rrBr3JH38J9LjmVzWNudg= github.com/aead/siphash v1.0.1 h1:FwHfE/T45KPKYuuSAKyyvE+oPWcaQ+CUmFW0bPlM+kg= github.com/aead/siphash v1.0.1/go.mod h1:Nywa3cDsYNNK3gaciGTWPwHt0wlpNV15vwmswBAUSII= github.com/afex/hystrix-go v0.0.0-20180502004556-fa1af6a1f4f5/go.mod h1:SkGFH1ia65gfNATL8TAiHDNxPzPdmEL5uirI2Uyuz6c= @@ -848,7 +847,6 @@ github.com/apache/thrift v0.12.0/go.mod h1:cp2SuWMxlEZw2r+iP2GNCdIi4C1qmUzdZFSVb github.com/apache/thrift v0.13.0/go.mod h1:cp2SuWMxlEZw2r+iP2GNCdIi4C1qmUzdZFSVb+bacwQ= github.com/apache/thrift v0.16.0/go.mod h1:PHK3hniurgQaNMZYaCLEqXKsYK8upmhPbmdP2FXSqgU= github.com/armon/circbuf v0.0.0-20150827004946-bbbad097214e/go.mod h1:3U/XgcO3hCbHZ8TKRvWD2dDTCfh9M9ya+I9JpbB7O8o= -github.com/armon/consul-api v0.0.0-20180202201655-eb2c6b5be1b6/go.mod h1:grANhF5doyWs3UAsr3K4I6qtAmlQcZDesFNEHPZAzj8= github.com/armon/go-metrics v0.0.0-20180917152333-f0300d1749da/go.mod h1:Q73ZrmVTwzkszR9V5SSuryQ31EELlFMUz1kKyl939pY= github.com/armon/go-radix v0.0.0-20180808171621-7fddfc383310/go.mod h1:ufUuZ+zHj4x4TnLV4JWEpy2hxWSpsRywHrMgIH9cCH8= github.com/aryann/difflib v0.0.0-20170710044230-e206f873d14a/go.mod h1:DAHtR1m6lCRdSC2Tm3DSWRPvIPr6xNKyeHdqDQSQT+A= @@ -893,8 +891,9 @@ github.com/btcsuite/btcd/btcec/v2 v2.3.2 h1:5n0X6hX0Zk+6omWcihdYvdAlGf2DfasC0GMf github.com/btcsuite/btcd/btcec/v2 v2.3.2/go.mod h1:zYzJ8etWJQIv1Ogk7OzpWjowwOdXY1W/17j2MW85J04= github.com/btcsuite/btcd/btcutil v1.0.0/go.mod h1:Uoxwv0pqYWhD//tfTiipkxNfdhG9UrLwaeswfjfdF0A= github.com/btcsuite/btcd/btcutil v1.1.0/go.mod h1:5OapHB7A2hBBWLm48mmw4MOHNJCcUBTwmWH/0Jn8VHE= -github.com/btcsuite/btcd/btcutil v1.1.5 h1:+wER79R5670vs/ZusMTF1yTcRYE5GUsFbdjdisflzM8= github.com/btcsuite/btcd/btcutil v1.1.5/go.mod h1:PSZZ4UitpLBWzxGd5VGOrLnmOjtPP/a6HaFo12zMs00= +github.com/btcsuite/btcd/btcutil v1.1.6 h1:zFL2+c3Lb9gEgqKNzowKUPQNb8jV7v5Oaodi/AYFd6c= +github.com/btcsuite/btcd/btcutil v1.1.6/go.mod h1:9dFymx8HpuLqBnsPELrImQeTQfKBQqzqGbbV3jK55aE= github.com/btcsuite/btcd/chaincfg/chainhash v1.0.0/go.mod h1:7SFka0XMvUgj3hfZtydOrQY2mwhPclbT2snogU7SQQc= github.com/btcsuite/btcd/chaincfg/chainhash v1.0.1/go.mod h1:7SFka0XMvUgj3hfZtydOrQY2mwhPclbT2snogU7SQQc= github.com/btcsuite/btcd/chaincfg/chainhash v1.1.0 h1:59Kx4K6lzOW5w6nFlA0v5+lk/6sjybR934QNHSJZPTQ= @@ -911,9 +910,6 @@ github.com/btcsuite/websocket v0.0.0-20150119174127-31079b680792/go.mod h1:ghJtE github.com/btcsuite/winsvc v1.0.0/go.mod h1:jsenWakMcC0zFBFurPLEAyrnc/teJEM1O46fmI40EZs= github.com/bufbuild/protocompile v0.6.0 h1:Uu7WiSQ6Yj9DbkdnOe7U4mNKp58y9WDMKDn28/ZlunY= github.com/bufbuild/protocompile v0.6.0/go.mod h1:YNP35qEYoYGme7QMtz5SBCoN4kL4g12jTtjuzRNdjpE= -github.com/bytedance/sonic v1.5.0/go.mod h1:ED5hyg4y6t3/9Ku1R6dU/4KyJ48DZ4jPhfY1O2AihPM= -github.com/bytedance/sonic v1.9.1 h1:6iJ6NqdoxCDr6mbY8h18oSO+cShGSMRGCEo7F2h0x8s= -github.com/bytedance/sonic v1.9.1/go.mod h1:i736AoUSYt75HyZLoJW9ERYxcy6eaN6h4BZXU064P/U= github.com/casbin/casbin/v2 v2.1.2/go.mod h1:YcPU1XXisHhLzuxH9coDNf2FbKpjGlbCg3n9yuLkIJQ= github.com/cenkalti/backoff v2.2.1+incompatible h1:tNowT99t7UNflLxfYYSlKYsBpXdEet03Pg2g16Swow4= github.com/cenkalti/backoff v2.2.1+incompatible/go.mod h1:90ReRw6GdpyfrHakVjL/QHaoyV4aDUVVkXQJJJ3NXXM= @@ -923,17 +919,11 @@ github.com/cenkalti/backoff/v4 v4.3.0/go.mod h1:Y3VNntkOUPxTVeUxJ/G5vcM//AlwfmyY github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU= github.com/census-instrumentation/opencensus-proto v0.3.0/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU= github.com/census-instrumentation/opencensus-proto v0.4.1/go.mod h1:4T9NM4+4Vw91VeyqjLS6ao50K5bOcLKN6Q42XnYaRYw= -github.com/cespare/xxhash v1.1.0 h1:a6HrQnmkObjyL+Gs60czilIUGqrzKutQD6XZog3p+ko= -github.com/cespare/xxhash v1.1.0/go.mod h1:XrSqR1VqqWfGrhpAt58auRo0WTKS1nRRg3ghfAqPWnc= github.com/cespare/xxhash/v2 v2.1.1/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= github.com/cespare/xxhash/v2 v2.2.0/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/checkpoint-restore/go-criu/v5 v5.3.0/go.mod h1:E/eQpaFtUKGOOSEBZgmKAcn+zUUwWxqcaKZlF54wK8E= github.com/cheggaaa/pb v1.0.27/go.mod h1:pQciLPpbU0oxA0h+VJYYLxO+XeDQb5pZijXscXHm81s= -github.com/chenzhuoyu/base64x v0.0.0-20211019084208-fb5309c8db06/go.mod h1:DH46F32mSOjUmXrMHnKwZdA8wcEefY7UVqBKYGjpdQY= -github.com/chenzhuoyu/base64x v0.0.0-20221115062448-fe3a3abad311 h1:qSGYFH7+jGhDF8vLC+iwCD4WpbV1EBDSzWkJODFLams= -github.com/chenzhuoyu/base64x v0.0.0-20221115062448-fe3a3abad311/go.mod h1:b583jCggY9gE99b6G5LEC39OIiVsWj+R97kbl5odCEk= github.com/chzyer/logex v1.1.10/go.mod h1:+Ywpsq7O8HXn0nuIou7OrIPyXbp3wmkHB+jjWRnGsAI= github.com/chzyer/logex v1.2.1 h1:XHDu3E6q+gdHgsdTPH6ImJMIp436vR6MPtH8gP05QzM= github.com/chzyer/logex v1.2.1/go.mod h1:JLbx6lG2kDbNRFnfkgvh4eRJRPX1QCoOIWomwysCBrQ= @@ -943,7 +933,6 @@ github.com/chzyer/readline v1.5.1/go.mod h1:Eh+b79XXUwfKfcPLepksvw2tcLE/Ct21YObk github.com/chzyer/test v0.0.0-20180213035817-a1ea475d72b1/go.mod h1:Q3SI9o4m/ZMnBNeIyt5eFwwo7qiLfzFZmjNmxjkiQlU= github.com/chzyer/test v1.0.0 h1:p3BQDXSxOhOG0P9z6/hGnII4LGiEPOYBhs8asl/fC04= github.com/chzyer/test v1.0.0/go.mod h1:2JlltgoNkt4TW/z9V/IzDdFaMTM2JPIi26O1pF38GC8= -github.com/cilium/ebpf v0.7.0/go.mod h1:/oI2+1shJiTGAMgl6/RgJr36Eo1jzrRcAWbcXO2usCA= 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/clbanning/x2j v0.0.0-20191024224557-825249438eec/go.mod h1:jMjuTZXRI4dUb/I5gc9Hdhagfvm9+RyrPryS/auMzxE= @@ -962,33 +951,31 @@ github.com/cockroachdb/apd/v2 v2.0.2/go.mod h1:DDxRlzC2lo3/vSlmSoS7JkqbbrARPuFOG github.com/cockroachdb/datadriven v0.0.0-20190809214429-80d97fb3cbaa/go.mod h1:zn76sxSg3SzpJ0PPJaLDCu+Bu0Lg3sKTORVIj19EIF8= 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/errors v1.11.3 h1:5bA+k2Y6r+oz/6Z/RFlNeVCesGARKuC6YymtcDrbC/I= +github.com/cockroachdb/errors v1.11.3/go.mod h1:m4UIW4CDjx+R5cybPsNrRbreomiFqt8o1h1wUVazSd8= +github.com/cockroachdb/fifo v0.0.0-20240606204812-0bbfbd93a7ce h1:giXvy4KSc/6g/esnpM7Geqxka4WSqI1SZc7sMJFd3y4= +github.com/cockroachdb/fifo v0.0.0-20240606204812-0bbfbd93a7ce/go.mod h1:9/y3cnZ5GKakj/H4y9r9GTjCvAFta7KLgSHPJJYc52M= 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/pebble v1.1.2 h1:CUh2IPtR4swHlEj48Rhfzw6l/d0qA31fItcIszQVIsA= +github.com/cockroachdb/pebble v1.1.2/go.mod h1:4exszw1r40423ZsmkG/09AFEG83I0uDgfujJdbL6kYU= 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/codahale/hdrhistogram v0.0.0-20161010025455-3a0bb77429bd/go.mod h1:sE/e/2PUdi/liOCUjSTXgM1o87ZssimdTWN964YiIeI= -github.com/cometbft/cometbft v0.38.10 h1:2ePuglchT+j0Iao+cfmt/nw5U7K2lnGDzXSUPGVdXaU= -github.com/cometbft/cometbft v0.38.10/go.mod h1:jHPx9vQpWzPHEAiYI/7EDKaB1NXhK6o3SArrrY8ExKc= -github.com/cometbft/cometbft-db v0.9.1 h1:MIhVX5ja5bXNHF8EYrThkG9F7r9kSfv8BX4LWaxWJ4M= -github.com/cometbft/cometbft-db v0.9.1/go.mod h1:iliyWaoV0mRwBJoizElCwwRA9Tf7jZJOURcRZF9m60U= +github.com/cometbft/cometbft v0.38.14 h1:ketYsx8uNLSm32GAMbm98SCSNTQ7Ek7VoZonSto+F/A= +github.com/cometbft/cometbft v0.38.14/go.mod h1:xdfvFic9BHPd/MXJZVRH79XK0iLLOkiMw3ynYNhuulk= +github.com/cometbft/cometbft-db v0.15.0 h1:VLtsRt8udD4jHCyjvrsTBpgz83qne5hnL245AcPJVRk= +github.com/cometbft/cometbft-db v0.15.0/go.mod h1:EBrFs1GDRiTqrWXYi4v90Awf/gcdD5ExzdPbg4X8+mk= github.com/consensys/bavard v0.1.13 h1:oLhMLOFGTLdlda/kma4VOJazblc7IM5y5QPd2A/YjhQ= github.com/consensys/bavard v0.1.13/go.mod h1:9ItSMtA/dXMAiL7BG6bqW2m3NdSEObYWoH223nGHukI= github.com/consensys/gnark-crypto v0.12.1 h1:lHH39WuuFgVHONRl3J0LRBtuYdQTumFSDtJF7HpyG8M= github.com/consensys/gnark-crypto v0.12.1/go.mod h1:v2Gy7L/4ZRosZ7Ivs+9SfUDr0f5UlG+EM5t7MPHiLuY= -github.com/containerd/console v1.0.3/go.mod h1:7LqA/THxQ86k76b8c/EMSiaJ3h1eZkMkXar0TQ1gf3U= github.com/containerd/continuity v0.3.0 h1:nisirsYROK15TAMVukJOUyGJjz4BNQJBVsNvAXZJ/eg= github.com/containerd/continuity v0.3.0/go.mod h1:wJEAIwKOm/pBZuBd0JmeTvnLquTB1Ag8espWhkykbPM= -github.com/coreos/etcd v3.3.10+incompatible/go.mod h1:uF7uidLiAD3TWHmW31ZFd/JWoc32PjwdhPthX9715RE= -github.com/coreos/go-etcd v2.0.0+incompatible/go.mod h1:Jez6KQU2B/sWsbdaef3ED8NzMklzPG4d5KIOhIy30Tk= github.com/coreos/go-semver v0.2.0/go.mod h1:nnelYz7RCh+5ahJtPPxZlU+153eP4D4r3EedlOD2RNk= github.com/coreos/go-systemd v0.0.0-20180511133405-39ca1b05acc7/go.mod h1:F5haX7vjVVG0kc13fIWeqUViNPyEJxv/OmvnBo0Yme4= -github.com/coreos/go-systemd/v22 v22.3.2/go.mod h1:Y58oyj3AT4RCenI/lSvhwexgC+NSVTIJ3seZv2GcEnc= github.com/coreos/go-systemd/v22 v22.5.0/go.mod h1:Y58oyj3AT4RCenI/lSvhwexgC+NSVTIJ3seZv2GcEnc= github.com/coreos/pkg v0.0.0-20160727233714-3ac0863d7acf/go.mod h1:E3G3o1h8I7cfcXa63jLwjI0eiQQMgzzUDFVpN/nH/eA= github.com/cosmos/btcutil v1.0.5 h1:t+ZFcX77LpKtDBhjucvnOH8C2l2ioGsBNEQ3jef8xFk= @@ -1004,27 +991,28 @@ github.com/cosmos/go-bip39 v1.0.0/go.mod h1:RNJv0H/pOIVgxw6KS7QeX2a0Uo0aKUlfhZ4x 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.1.2 h1:zL9FK7C4L/P4IF1Dm5fIwz0WXCnn7Bp1M2FxH0ayM7Y= -github.com/cosmos/iavl v1.1.2/go.mod h1:jLeUvm6bGT1YutCaL2fIar/8vGUE8cPZvh/gXEWDaDM= -github.com/cosmos/ibc-go/modules/capability v1.0.0 h1:r/l++byFtn7jHYa09zlAdSeevo8ci1mVZNO9+V0xsLE= -github.com/cosmos/ibc-go/modules/capability v1.0.0/go.mod h1:D81ZxzjZAe0ZO5ambnvn1qedsFQ8lOwtqicG6liLBco= +github.com/cosmos/gogoproto v1.7.0 h1:79USr0oyXAbxg3rspGh/m4SWNyoz/GLaAh0QlCe2fro= +github.com/cosmos/gogoproto v1.7.0/go.mod h1:yWChEv5IUEYURQasfyBW5ffkMHR/90hiHgbNgrtp4j0= +github.com/cosmos/iavl v1.2.0 h1:kVxTmjTh4k0Dh1VNL046v6BXqKziqMDzxo93oh3kOfM= +github.com/cosmos/iavl v1.2.0/go.mod h1:HidWWLVAtODJqFD6Hbne2Y0q3SdxByJepHUOeoH4LiI= +github.com/cosmos/ibc-go/modules/apps/callbacks v0.2.1-0.20231113120333-342c00b0f8bd h1:Lx+/5dZ/nN6qPXP2Ofog6u1fmlkCFA1ElcOconnofEM= +github.com/cosmos/ibc-go/modules/apps/callbacks v0.2.1-0.20231113120333-342c00b0f8bd/go.mod h1:JWfpWVKJKiKtd53/KbRoKfxWl8FsT2GPcNezTOk0o5Q= +github.com/cosmos/ibc-go/modules/capability v1.0.1 h1:ibwhrpJ3SftEEZRxCRkH0fQZ9svjthrX2+oXdZvzgGI= +github.com/cosmos/ibc-go/modules/capability v1.0.1/go.mod h1:rquyOV262nGJplkumH+/LeYs04P3eV8oB7ZM4Ygqk4E= github.com/cosmos/ibc-go/modules/light-clients/08-wasm v0.0.0-20240429153234-e1e6da7e4ead h1:QB50+AmrEVqFr2hzvIxMkICziWQ/uuebze0vNYKMnBg= github.com/cosmos/ibc-go/modules/light-clients/08-wasm v0.0.0-20240429153234-e1e6da7e4ead/go.mod h1:AJeroAXnPKeFpD1AfEfjYBHGEWt5gBfzUjgs4SYn2ZY= -github.com/cosmos/ibc-go/v8 v8.3.2 h1:8X1oHHKt2Bh9hcExWS89rntLaCKZp2EjFTUSxKlPhGI= -github.com/cosmos/ibc-go/v8 v8.3.2/go.mod h1:WVVIsG39jGrF9Cjggjci6LzySyWGloz194sjTxiGNIE= +github.com/cosmos/ibc-go/v8 v8.4.0 h1:K2PfX0AZ+1XKZytHGEMuSjQXG/MZshPb83RSTQt2+cE= +github.com/cosmos/ibc-go/v8 v8.4.0/go.mod h1:zh6x1osR0hNvEcFrC/lhGD08sMfQmr9wHVvZ/mRWMCs= 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= github.com/cosmos/keyring v1.2.0/go.mod h1:fc+wB5KTk9wQ9sDx0kFXB3A0MaeGHM9AwRStKOQ5vOA= github.com/cosmos/ledger-cosmos-go v0.13.3 h1:7ehuBGuyIytsXbd4MP43mLeoN2LTOEnk5nvue4rK+yM= github.com/cosmos/ledger-cosmos-go v0.13.3/go.mod h1:HENcEP+VtahZFw38HZ3+LS3Iv5XV6svsnkk9vdJtLr8= -github.com/cosmos/relayer/v2 v2.5.1 h1:gYYD/xywc0Lw3957NmWuyJr9idKQmhgVuVoLIiBNYog= -github.com/cosmos/relayer/v2 v2.5.1/go.mod h1:KygWPbGY9ley9Q42CMg5uzmrf4BIe+EfxU5j44xrLRQ= -github.com/cpuguy83/go-md2man v1.0.10/go.mod h1:SmD6nW6nTyfqj6ABTjUi3V3JVMnlJmwcJI5acqYI6dE= +github.com/cosmos/relayer/v2 v2.5.2 h1:AF0MOo1GvJo94QNB996fBHdKlH+vrIY3JcFNrIvZNP0= +github.com/cosmos/relayer/v2 v2.5.2/go.mod h1:h4Ng2QsVpxExIq5S+WvLr8slDb9MSBh82gQS4DeMwDo= github.com/cpuguy83/go-md2man/v2 v2.0.0-20190314233015-f79a8a8ca69d/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU= -github.com/cpuguy83/go-md2man/v2 v2.0.3/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o= +github.com/cpuguy83/go-md2man/v2 v2.0.4/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o= github.com/crate-crypto/go-ipa v0.0.0-20231025140028-3c0104f4b233 h1:d28BXYi+wUpz1KBmiF9bWrjEMacUEREV6MBi2ODnrfQ= github.com/crate-crypto/go-ipa v0.0.0-20231025140028-3c0104f4b233/go.mod h1:geZJZH3SzKCqnz5VT0q/DyIG/tvu/dZk+VIfXicupJs= github.com/crate-crypto/go-kzg-4844 v0.7.0 h1:C0vgZRk4q4EZ/JgPfzuSoxdCq3C3mOZMBShovmncxvA= @@ -1037,7 +1025,6 @@ github.com/creack/pty v1.1.7/go.mod h1:lj5s0c3V2DBrqTV7llrYr5NG6My20zk30Fl46Y7Do github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E= github.com/creack/pty v1.1.18 h1:n56/Zwd5o6whRC5PMGretI4IdRLlmBXYNjScPaBgsbY= github.com/creack/pty v1.1.18/go.mod h1:MOBLtS5ELjhRRrroQr9kyvTxUAFNvYEK993ew/Vr4O4= -github.com/cyphar/filepath-securejoin v0.2.3/go.mod h1:aPGpWjXOXUn2NCNjFvBE6aRxGGx79pTxQpKOJNYHHl4= github.com/danieljoos/wincred v1.1.2 h1:QLdCxFs1/Yl4zduvBdcHB8goaYk9RARS2SgLLRuAyr0= github.com/danieljoos/wincred v1.1.2/go.mod h1:GijpziifJoIBfYh+S7BbkdUTU4LfM+QnGqR5Vl2tAx0= github.com/davecgh/go-spew v0.0.0-20171005155431-ecdeabc65495/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= @@ -1049,18 +1036,16 @@ github.com/decred/dcrd/crypto/blake256 v1.0.0/go.mod h1:sQl2p6Y26YV+ZOcSTP6thNdn github.com/decred/dcrd/crypto/blake256 v1.0.1 h1:7PltbUIQB7u/FfZ39+DGa/ShuMyJ5ilcvdfma9wOH6Y= github.com/decred/dcrd/crypto/blake256 v1.0.1/go.mod h1:2OfgNZ5wDpcsFmHmCK5gZTPcCXqlm2ArzUIkw9czNJo= github.com/decred/dcrd/dcrec/secp256k1/v4 v4.0.1/go.mod h1:hyedUtir6IdtD/7lIxGeCxkaw7y45JueMRL4DIyJDKs= -github.com/decred/dcrd/dcrec/secp256k1/v4 v4.2.0 h1:8UrgZ3GkP4i/CLijOJx79Yu+etlyjdBU4sfcs2WYQMs= -github.com/decred/dcrd/dcrec/secp256k1/v4 v4.2.0/go.mod h1:v57UDF4pDQJcEfFUCRop3lJL149eHGSe9Jvczhzjo/0= +github.com/decred/dcrd/dcrec/secp256k1/v4 v4.3.0 h1:rpfIENRNNilwHwZeG5+P150SMrnNEcHYvcCuK6dPZSg= +github.com/decred/dcrd/dcrec/secp256k1/v4 v4.3.0/go.mod h1:v57UDF4pDQJcEfFUCRop3lJL149eHGSe9Jvczhzjo/0= github.com/decred/dcrd/lru v1.0.0/go.mod h1:mxKOwFd7lFjN2GZYsiz/ecgqR6kkYAl+0pz0tEMk218= github.com/desertbit/timer v0.0.0-20180107155436-c41aec40b27f h1:U5y3Y5UE0w7amNe7Z5G/twsBW0KEalRQXZzf8ufSh9I= github.com/desertbit/timer v0.0.0-20180107155436-c41aec40b27f/go.mod h1:xH/i4TFMt8koVQZ6WFms69WAsDWr2XsYL3Hkl7jkoLE= -github.com/dgraph-io/badger/v2 v2.2007.4 h1:TRWBQg8UrlUhaFdco01nO2uXwzKS7zd+HVdwV/GHc4o= -github.com/dgraph-io/badger/v2 v2.2007.4/go.mod h1:vSw/ax2qojzbN6eXHIx6KPKtCSHJN/Uz0X0VPruTIhk= -github.com/dgraph-io/ristretto v0.0.3-0.20200630154024-f66de99634de/go.mod h1:KPxhHT9ZxKefz+PCeOGsrHpl1qZ7i70dGTu2u+Ahh6E= -github.com/dgraph-io/ristretto v0.1.1 h1:6CWw5tJNgpegArSHpNHJKldNeq03FQCwYvfMVWajOK8= -github.com/dgraph-io/ristretto v0.1.1/go.mod h1:S1GPSBCYCIhmVNfcth17y2zZtQT6wzkzgwUve0VDWWA= +github.com/dgraph-io/badger/v4 v4.3.0 h1:lcsCE1/1qrRhqP+zYx6xDZb8n7U+QlwNicpc676Ub40= +github.com/dgraph-io/badger/v4 v4.3.0/go.mod h1:Sc0T595g8zqAQRDf44n+z3wG4BOqLwceaFntt8KPxUM= +github.com/dgraph-io/ristretto v0.1.2-0.20240116140435-c67e07994f91 h1:Pux6+xANi0I7RRo5E1gflI4EZ2yx3BGZ75JkAIvGEOA= +github.com/dgraph-io/ristretto v0.1.2-0.20240116140435-c67e07994f91/go.mod h1:swkazRqnUf1N62d0Nutz7KIj2UKqsm/H8tD0nBJAXqM= github.com/dgrijalva/jwt-go v3.2.0+incompatible/go.mod h1:E3ru+11k8xSBh+hMPgOLZmtrrCbhqsmaPHjLKYnJCaQ= -github.com/dgryski/go-farm v0.0.0-20190423205320-6a90982ecee2/go.mod h1:SqUrOPUnsFjfmXRMNPybcSiG0BgUW2AuFH8PAnS2iTw= github.com/dgryski/go-farm v0.0.0-20200201041132-a6ae2369ad13 h1:fAjc9m62+UWV/WAFKLNi6ZS0675eEUC9y3AlwSbQu1Y= github.com/dgryski/go-farm v0.0.0-20200201041132-a6ae2369ad13/go.mod h1:SqUrOPUnsFjfmXRMNPybcSiG0BgUW2AuFH8PAnS2iTw= github.com/distribution/reference v0.5.0 h1:/FUIFXtfc/x2gpa5/VGfiGLuOIdYa1t65IKK2OFGvA0= @@ -1071,7 +1056,6 @@ github.com/docker/docker v25.0.6+incompatible h1:5cPwbwriIcsua2REJe8HqQV+6WlWc1b github.com/docker/docker v25.0.6+incompatible/go.mod h1:eEKB0N0r5NX/I1kEveEz05bcu8tLC/8azJZsviup8Sk= github.com/docker/go-connections v0.4.0 h1:El9xVISelRB7BuFusrZozjnkIM5YnzCViNKohAFqRJQ= github.com/docker/go-connections v0.4.0/go.mod h1:Gbd7IOopHjR8Iph03tsViu4nIes5XhDvyHbTtUxmeec= -github.com/docker/go-units v0.4.0/go.mod h1:fgPhTUdO+D/Jk86RDLlptpiXQzgHJF7gydDDbaIK4Dk= github.com/docker/go-units v0.5.0 h1:69rxXcBk27SvSaaxTtLh/8llcHD8vYHT7WSdRZ/jvr4= github.com/docker/go-units v0.5.0/go.mod h1:fgPhTUdO+D/Jk86RDLlptpiXQzgHJF7gydDDbaIK4Dk= github.com/docopt/docopt-go v0.0.0-20180111231733-ee0de3bc6815/go.mod h1:WwZ+bS3ebgob9U8Nd0kOddGdZWjyMGR8Wziv+TBNwSE= @@ -1113,15 +1097,12 @@ github.com/fortytw2/leaktest v1.3.0 h1:u8491cBMTQ8ft8aeV+adlcytMZylmA5nnwwkRZjI8 github.com/fortytw2/leaktest v1.3.0/go.mod h1:jDsjWgpAGjm2CA7WthBh/CdZYEPF31XHquHwclZch5g= github.com/franela/goblin v0.0.0-20200105215937-c9ffbefa60db/go.mod h1:7dvUGVsVBjqR7JHJk0brhHOZYGmfBYOrK0ZhYMEtBr4= github.com/franela/goreq v0.0.0-20171204163338-bcd34c9993f8/go.mod h1:ZhphrRTfi2rbfLwlschooIH4+wKKDR4Pdxhh+TRoA20= -github.com/frankban/quicktest v1.11.3/go.mod h1:wRf/ReqHper53s+kmmSZizM8NamnL3IM0I9ntUbOk+k= 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.7.0 h1:8JEhPFa5W2WU7YfeZzPNqzMP6Lwt7L2715Ggo0nosvA= github.com/fsnotify/fsnotify v1.7.0/go.mod h1:40Bi/Hjc2AVfZrqy+aj+yEI+/bRxZnMJyTJwOpGvigM= -github.com/gabriel-vasile/mimetype v1.4.2 h1:w5qFW6JKBz9Y393Y4q372O9A7cUSequkh1Q7OhCmWKU= -github.com/gabriel-vasile/mimetype v1.4.2/go.mod h1:zApsH/mKG4w07erKIaJPFiX0Tsq9BFQgN3qGY5GnNgA= github.com/gballet/go-verkle v0.1.1-0.20231031103413-a67434b50f46 h1:BAIP2GihuqhwdILrV+7GJel5lyPV3u1+PgzrWLc0TkE= github.com/gballet/go-verkle v0.1.1-0.20231031103413-a67434b50f46/go.mod h1:QNpY22eby74jVhqH4WhDLDwxc/vqsern6pW+u2kbkpc= github.com/getsentry/sentry-go v0.27.0 h1:Pv98CIbtB3LkMWmXi4Joa5OOcwbmnX88sF5qbK3r3Ps= @@ -1129,8 +1110,9 @@ github.com/getsentry/sentry-go v0.27.0/go.mod h1:lc76E2QywIyW8WuBnwl8Lc4bkmQH4+w github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04= github.com/gin-contrib/sse v0.1.0 h1:Y/yl/+YNO8GZSjAhjMsSuLt29uWRFHdHYUb5lYOV9qE= github.com/gin-contrib/sse v0.1.0/go.mod h1:RHrZQHXnP2xjPF+u1gW/2HnVO7nvIa9PG3Gm+fLHvGI= -github.com/gin-gonic/gin v1.9.1 h1:4idEAncQnU5cB7BeOkPtxjfCSye0AAm1R0RVIqJ+Jmg= -github.com/gin-gonic/gin v1.9.1/go.mod h1:hPrL7YrpYKXt5YId3A/Tnip5kqbEAP+KLuI3SUcPTeU= +github.com/gin-gonic/gin v1.6.3/go.mod h1:75u5sXoLsGZoRN5Sgbi1eraJ4GU3++wFwWzhwvtwp4M= +github.com/gin-gonic/gin v1.8.1 h1:4+fr/el88TOO3ewCmQr8cx/CtZ/umlIRIs5M4NTNjf8= +github.com/gin-gonic/gin v1.8.1/go.mod h1:ji8BvRH1azfM+SYow9zQ6SZMvR8qOMZHmsCuWR9tTTk= 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-fonts/dejavu v0.1.0/go.mod h1:4Wt4I4OU2Nq9asgDCteaAaWZOV24E+0/Pwo0gppep4g= @@ -1144,8 +1126,8 @@ github.com/go-gl/glfw/v3.3/glfw v0.0.0-20200222043503-6f7a984d4dc4/go.mod h1:tQ2 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-kit/kit v0.10.0/go.mod h1:xUsJbQ/Fp4kEt7AFgCuvyX4a71u8h9jB8tj/ORgOZ7o= -github.com/go-kit/kit v0.12.0 h1:e4o3o3IsBfAKQh5Qbbiqyfu97Ku7jrO/JbohvztANh4= -github.com/go-kit/kit v0.12.0/go.mod h1:lHd+EkCZPIwYItmGDDRdhinkzX2A1sj+M9biaEaizzs= +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= @@ -1165,13 +1147,16 @@ github.com/go-ole/go-ole v1.3.0 h1:Dt6ye7+vXGIKZ7Xtk4s6/xVdGDQynvom7xCFEdWr6uE= github.com/go-ole/go-ole v1.3.0/go.mod h1:5LS6F96DhAwUc7C+1HLexzMXY1xGRSryjyPPKW6zv78= github.com/go-pdf/fpdf v0.5.0/go.mod h1:HzcnA+A23uwogo0tp9yU+l3V+KXhiESpt1PMayhOh5M= github.com/go-pdf/fpdf v0.6.0/go.mod h1:HzcnA+A23uwogo0tp9yU+l3V+KXhiESpt1PMayhOh5M= -github.com/go-playground/assert/v2 v2.2.0/go.mod h1:VDjEfimB/XKnb+ZQfWdccd7VUvScMdVu0Titje2rxJ4= -github.com/go-playground/locales v0.14.1 h1:EWaQ/wswjilfKLTECiXz7Rh+3BjFhfDFKv/oXslEjJA= -github.com/go-playground/locales v0.14.1/go.mod h1:hxrqLVvrK65+Rwrd5Fc6F2O76J/NuW9t0sjnWqG1slY= -github.com/go-playground/universal-translator v0.18.1 h1:Bcnm0ZwsGyWbCzImXv+pAJnYK9S473LQFuzCbDbfSFY= -github.com/go-playground/universal-translator v0.18.1/go.mod h1:xekY+UJKNuX9WP91TpwSH2VMlDf28Uj24BCp08ZFTUY= -github.com/go-playground/validator/v10 v10.14.0 h1:vgvQWe3XCz3gIeFDm/HnTIbj6UGmg/+t63MyGU2n5js= -github.com/go-playground/validator/v10 v10.14.0/go.mod h1:9iXMNT7sEkjXb0I+enO7QXmzG6QCsPWY4zveKFVRSyU= +github.com/go-playground/assert/v2 v2.0.1/go.mod h1:VDjEfimB/XKnb+ZQfWdccd7VUvScMdVu0Titje2rxJ4= +github.com/go-playground/locales v0.13.0/go.mod h1:taPMhCMXrRLJO55olJkUXHZBHCxTMfnGwq/HNwmWNS8= +github.com/go-playground/locales v0.14.0 h1:u50s323jtVGugKlcYeyzC0etD1HifMjqmJqb8WugfUU= +github.com/go-playground/locales v0.14.0/go.mod h1:sawfccIbzZTqEDETgFXqTho0QybSa7l++s0DH+LDiLs= +github.com/go-playground/universal-translator v0.17.0/go.mod h1:UkSxE5sNxxRwHyU+Scu5vgOQjsIJAF8j9muTVoKLVtA= +github.com/go-playground/universal-translator v0.18.0 h1:82dyy6p4OuJq4/CByFNOn/jYrnRPArHwAcmLoJZxyho= +github.com/go-playground/universal-translator v0.18.0/go.mod h1:UvRDBj+xPUEGrFYl+lu/H90nyDXpg0fqeB/AQUGNTVA= +github.com/go-playground/validator/v10 v10.2.0/go.mod h1:uOYAAleCW8F/7oMFd6aG0GOhaH6EGOAJShg8Id5JGkI= +github.com/go-playground/validator/v10 v10.11.1 h1:prmOlTVv+YjZjmRmNSF3VmspqJIxJWXmqUsHwfTRRkQ= +github.com/go-playground/validator/v10 v10.11.1/go.mod h1:i+3WkQ1FvaUjjxh1kSvIA4dMGDBiPU55YFDl0WbKdWU= github.com/go-sql-driver/mysql v1.4.0/go.mod h1:zAC/RDZ24gD3HViQzih4MyKcchzm+sOG5ZlKdlhCg5w= github.com/go-sql-driver/mysql v1.6.0 h1:BCTh4TKNUYmOmMUcQ3IipzF5prigylS7XXjEkfCHuOE= github.com/go-sql-driver/mysql v1.6.0/go.mod h1:DCzpHaOWr8IXmIStZouvnhqoel9Qv2LBy8hT2VhHyBg= @@ -1191,7 +1176,6 @@ github.com/goccy/go-json v0.10.2/go.mod h1:6MelG93GURQebXPDq3khkgXZkazVtN9CRI+MG github.com/godbus/dbus v0.0.0-20190726142602-4481cbc300e2 h1:ZpnhV/YsD2/4cESfV5+Hoeu/iUR3ruzNvZ+yQfO03a0= github.com/godbus/dbus v0.0.0-20190726142602-4481cbc300e2/go.mod h1:bBOAhwG1umN6/6ZUMtDFBMQR8jRg9O75tm9K00oMsK4= github.com/godbus/dbus/v5 v5.0.4/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA= -github.com/godbus/dbus/v5 v5.0.6/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA= github.com/gofrs/flock v0.8.1 h1:+gYjHKf32LDeiEEFhQaotPbLuUXjY5ZqxKgXy7n59aw= github.com/gofrs/flock v0.8.1/go.mod h1:F1TvTiK9OcQqauNUHlbJvyl9Qa1QvF/gOUDKA14jxHU= github.com/gogo/googleapis v1.4.1-0.20201022092350-68b0159b7869/go.mod h1:5YRNX2z1oM5gXdAkurHa942MDgEJyk02w4OecKY87+c= @@ -1201,7 +1185,6 @@ github.com/golang/freetype v0.0.0-20170609003504-e2365dfdc4a0/go.mod h1:E/TSTwGw github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q= github.com/golang/glog v1.0.0/go.mod h1:EWib/APOK0SL3dFbYqvxE3UYd8E6s1ouQ7iEp/0LWV4= github.com/golang/glog v1.1.0/go.mod h1:pfYeQZ3JWZoXTV5sFc986z3HTpwQs9At6P4ImfuP3NQ= -github.com/golang/glog v1.2.1 h1:OptwRhECazUx5ix5TTWC3EZhsZEHWcYWY4FQHTIubm4= github.com/golang/glog v1.2.1/go.mod h1:6AhwSGph0fcJtXVM/PEHPqZlFeoLxhs7/t5UDAwmO+w= github.com/golang/groupcache v0.0.0-20160516000752-02826c3e7903/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= github.com/golang/groupcache v0.0.0-20190702054246-869f871628b6/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= @@ -1246,8 +1229,9 @@ github.com/golang/snappy v0.0.5-0.20220116011046-fa5810519dcb h1:PBC98N2aIaM3XXi github.com/golang/snappy v0.0.5-0.20220116011046-fa5810519dcb/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= github.com/google/btree v0.0.0-20180813153112-4030bb1f1f0c/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ= github.com/google/btree v1.0.0/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ= -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/btree v1.1.3 h1:CVpQJjYgC4VbzxeGVHfvZrv1ctoYCAI8vbl07Fcxlyg= +github.com/google/btree v1.1.3/go.mod h1:qOPhT0dTNdNzV6Z/lhRX0YXUafgPLFUh+gZMl761Gm4= +github.com/google/flatbuffers v2.0.8+incompatible h1:ivUb1cGomAB101ZM1T0nOiWz9pSrTMoa9+EiY7igmkM= github.com/google/flatbuffers v2.0.8+incompatible/go.mod h1:1AeVuKshWv4vARoZatz6mlQ0JxURH0Kv5+zNeJKJCa8= 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= @@ -1329,8 +1313,8 @@ github.com/googleapis/gax-go/v2 v2.7.1/go.mod h1:4orTrqY6hXxxaUL4LHIPl6lGo8vAE38 github.com/googleapis/gax-go/v2 v2.8.0/go.mod h1:4orTrqY6hXxxaUL4LHIPl6lGo8vAE38/qKbhSAKP6QI= github.com/googleapis/gax-go/v2 v2.10.0/go.mod h1:4UOEnMCrxsSqQ940WnTiD6qJ63le2ev3xfyagutxiPw= github.com/googleapis/gax-go/v2 v2.11.0/go.mod h1:DxmR61SGKkGLa2xigwuZIQpkCI2S5iydzRfb3peWZJI= -github.com/googleapis/gax-go/v2 v2.12.2 h1:mhN09QQW1jEWeMF74zGR81R30z4VJzjZsfkUhuHF+DA= -github.com/googleapis/gax-go/v2 v2.12.2/go.mod h1:61M8vcyyXR2kqKFxKrfA22jaA8JGF7Dc8App1U3H6jc= +github.com/googleapis/gax-go/v2 v2.12.3 h1:5/zPPDvw8Q1SuXjrqrZslrqT7dL/uJT2CQii/cLCKqA= +github.com/googleapis/gax-go/v2 v2.12.3/go.mod h1:AKloxT6GtNbaLm8QTNSidHUVsHYcBHwWRvkNFJUQcS4= github.com/googleapis/go-type-adapters v1.0.0/go.mod h1:zHW75FOG2aur7gAO2B+MLby+cLsWGBF62rFAi7WjWO4= github.com/googleapis/google-cloud-go-testing v0.0.0-20200911160855-bcd43fbb19e8/go.mod h1:dvDLG8qkwmyD9a/MJJN3XJcT3xFxOKAvTZGvuZmac9g= github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1 h1:EGx4pi6eqNxGaHF6qqu48+N2wcFQ5qg5FXgOdqsJ5d8= @@ -1345,8 +1329,8 @@ github.com/gorilla/mux v1.8.1/go.mod h1:AKf9I4AEqPTmMytcMc0KkNouC66V3BtZ4qD5fmWS github.com/gorilla/websocket v0.0.0-20170926233335-4201258b820c/go.mod h1:E7qHFY5m1UJ88s3WnNqhKjPHQ0heANvMoAMk2YaljkQ= github.com/gorilla/websocket v1.4.1/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE= github.com/gorilla/websocket v1.5.0/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE= -github.com/gorilla/websocket v1.5.1 h1:gmztn0JnHVt9JZquRuzLw3g4wouNVzKL15iLr/zn/QY= -github.com/gorilla/websocket v1.5.1/go.mod h1:x3kM2JMyaluk02fnUJpQuwD2dCS5NDG2ZHL0uE0tcaY= +github.com/gorilla/websocket v1.5.3 h1:saDtZ6Pbx/0u+bgYQ3q96pZgCzfhKXGPqt7kZ72aNNg= +github.com/gorilla/websocket v1.5.3/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE= github.com/grpc-ecosystem/go-grpc-middleware v1.0.1-0.20190118093823-f849b5445de4/go.mod h1:FiyG127CGDf3tlThmgyCl78X/SZQqEOJBCDaAfeWzPs= github.com/grpc-ecosystem/go-grpc-middleware v1.2.2/go.mod h1:EaizFBKfUKtMIF5iaDEhniwNedqGo9FuLFzppDr3uwI= github.com/grpc-ecosystem/go-grpc-middleware v1.4.0 h1:UH//fgunKIs4JdUbpDl1VZCDaL56wXCB/5+wF6uHfaI= @@ -1367,8 +1351,8 @@ github.com/hashicorp/go-cleanhttp v0.5.0/go.mod h1:JpRdi6/HCYpAwUzNwuwqhbovhLtng github.com/hashicorp/go-cleanhttp v0.5.1/go.mod h1:JpRdi6/HCYpAwUzNwuwqhbovhLtngrth3wmdIIUrZ80= github.com/hashicorp/go-cleanhttp v0.5.2 h1:035FKYIWjmULyFRBKPs8TBQoi0x6d9G4xc9neXJWAZQ= github.com/hashicorp/go-cleanhttp v0.5.2/go.mod h1:kO/YDlP8L1346E6Sodw+PrpBSV4/SoxCXGY6BqNFT48= -github.com/hashicorp/go-getter v1.7.3 h1:bN2+Fw9XPFvOCjB0UOevFIMICZ7G2XSQHzfvLUyOM5E= -github.com/hashicorp/go-getter v1.7.3/go.mod h1:W7TalhMmbPmsSMdNjD0ZskARur/9GJ17cfHTRtXV744= +github.com/hashicorp/go-getter v1.7.5 h1:dT58k9hQ/vbxNMwoI5+xFYAJuv6152UNvdHokfI5wE4= +github.com/hashicorp/go-getter v1.7.5/go.mod h1:W7TalhMmbPmsSMdNjD0ZskARur/9GJ17cfHTRtXV744= github.com/hashicorp/go-hclog v1.5.0 h1:bI2ocEMgcVlz55Oj1xZNBsVi900c7II+fWDyV9o+13c= github.com/hashicorp/go-hclog v1.5.0/go.mod h1:W4Qnvbt70Wk/zYJryRzDRU/4r0kIg0PVHBcfoyhpF5M= github.com/hashicorp/go-immutable-radix v1.0.0/go.mod h1:0y9vanUI8NX6FsYoO3zeMjhV/C5i9g4Q3DwcSNZ4P60= @@ -1474,14 +1458,11 @@ github.com/kkdai/bstream v0.0.0-20161212061736-f391b8402d23/go.mod h1:J+Gs4SYgM6 github.com/klauspost/asmfmt v1.3.2/go.mod h1:AG8TuvYojzulgDAMCnYn50l/5QV3Bs/tp6j0HLHbNSE= github.com/klauspost/compress v1.10.3/go.mod h1:aoV0uJVorq1K+umq18yTdKaF57EivdYsUV+/s2qKfXs= github.com/klauspost/compress v1.11.7/go.mod h1:aoV0uJVorq1K+umq18yTdKaF57EivdYsUV+/s2qKfXs= -github.com/klauspost/compress v1.12.3/go.mod h1:8dP1Hq4DHOhN9w426knH3Rhby4rFm6D8eO+e+Dq5Gzg= github.com/klauspost/compress v1.15.9/go.mod h1:PhcZ0MbTNciWF3rruxRgKxI5NkcHHrHUDtV4Yw2GlzU= github.com/klauspost/compress v1.15.11/go.mod h1:QPwzmACJjUTFsnSHH934V6woptycfrDDJnH7hvFVbGM= -github.com/klauspost/compress v1.17.7 h1:ehO88t2UGzQK66LMdE8tibEd1ErmzZjNEqWkjLAKQQg= -github.com/klauspost/compress v1.17.7/go.mod h1:Di0epgTjJY877eYKx5yC51cX2A2Vl2ibi7bDH9ttBbw= +github.com/klauspost/compress v1.17.9 h1:6KIumPrER1LHsvBVuDa0r5xaG0Es51mhhB9BQB2qeMA= +github.com/klauspost/compress v1.17.9/go.mod h1:Di0epgTjJY877eYKx5yC51cX2A2Vl2ibi7bDH9ttBbw= github.com/klauspost/cpuid/v2 v2.0.9/go.mod h1:FInQzS24/EEf25PyTYn52gqo7WaD8xa0213Md/qVLRg= -github.com/klauspost/cpuid/v2 v2.2.4 h1:acbojRNwl3o09bUq+yDCtZFc1aiwaAAxtcn8YkZXnvk= -github.com/klauspost/cpuid/v2 v2.2.4/go.mod h1:RVVoqg1df56z8g3pUjL/3lE5UfnlrJX8tyFgg4nqhuY= github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= github.com/konsorten/go-windows-terminal-sequences v1.0.3/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= github.com/kr/fs v0.1.0/go.mod h1:FFnZGqtBN9Gxj7eW1uZ42v5BccTP0vu6NEaFoC2HwRg= @@ -1499,19 +1480,19 @@ github.com/kylelemons/godebug v1.1.0 h1:RPNrshWIDI6G2gRW9EHilWtl7Z6Sb1BR0xunSBf0 github.com/kylelemons/godebug v1.1.0/go.mod h1:9/0rRGxNHcop5bhtWyNeEfOS8JIWk580+fNqagV/RAw= github.com/leanovate/gopter v0.2.9 h1:fQjYxZaynp97ozCzfOyOuAGOU4aU/z37zf/tOujFk7c= github.com/leanovate/gopter v0.2.9/go.mod h1:U2L/78B+KVFIx2VmW6onHJQzXtFb+p5y3y2Sh+Jxxv8= -github.com/leodido/go-urn v1.2.4 h1:XlAE/cm/ms7TE/VMVoduSpNBoyc2dOxHs5MZSwAN63Q= -github.com/leodido/go-urn v1.2.4/go.mod h1:7ZrI8mTSeBSHl/UaRyKQW1qZeMgak41ANeCNaVckg+4= -github.com/lib/pq v1.10.7 h1:p7ZhMD+KsSRozJr34udlUrhboJwWAgCg34+/ZZNvZZw= -github.com/lib/pq v1.10.7/go.mod h1:AlVN5x4E4T544tWzH6hKfbfQvm3HdbOxrmggDNAPY9o= +github.com/leodido/go-urn v1.2.0/go.mod h1:+8+nEpDfqqsY+g338gtMEUOtuK+4dEMhiQEgxpxOKII= +github.com/leodido/go-urn v1.2.1 h1:BqpAaACuzVSgi/VLzGZIobT2z4v53pjosyNd9Yv6n/w= +github.com/leodido/go-urn v1.2.1/go.mod h1:zt4jvISO2HfUBqxjfIshjdMTYS56ZS/qv49ictyFfxY= +github.com/lib/pq v1.10.9 h1:YXG7RB+JIjhP29X+OtkiDnYaXQwpS4JEWq7dtCCRUEw= +github.com/lib/pq v1.10.9/go.mod h1:AlVN5x4E4T544tWzH6hKfbfQvm3HdbOxrmggDNAPY9o= github.com/lightstep/lightstep-tracer-common/golang/gogo v0.0.0-20190605223551-bc2310a04743/go.mod h1:qklhhLq1aX+mtWk9cPHPzaBjWImj5ULL6C7HFJtXQMM= github.com/lightstep/lightstep-tracer-go v0.18.1/go.mod h1:jlF1pusYV4pidLvZ+XD0UBX0ZE6WURAspgAczcDHrL4= -github.com/linxGnu/grocksdb v1.8.14 h1:HTgyYalNwBSG/1qCQUIott44wU5b2Y9Kr3z7SK5OfGQ= -github.com/linxGnu/grocksdb v1.8.14/go.mod h1:QYiYypR2d4v63Wj1adOOfzglnoII0gLj3PNh4fZkcFA= +github.com/linxGnu/grocksdb v1.9.3 h1:s1cbPcOd0cU2SKXRG1nEqCOWYAELQjdqg3RVI2MH9ik= +github.com/linxGnu/grocksdb v1.9.3/go.mod h1:QYiYypR2d4v63Wj1adOOfzglnoII0gLj3PNh4fZkcFA= github.com/lyft/protoc-gen-star v0.6.0/go.mod h1:TGAoBVkt8w7MPG72TrKIu85MIdXwDuzJYeZuUPFPNwA= github.com/lyft/protoc-gen-star v0.6.1/go.mod h1:TGAoBVkt8w7MPG72TrKIu85MIdXwDuzJYeZuUPFPNwA= github.com/lyft/protoc-gen-star/v2 v2.0.1/go.mod h1:RcCdONR2ScXaYnQC5tUzxzlpA3WVYF7/opLeUgcQs/o= github.com/lyft/protoc-gen-star/v2 v2.0.3/go.mod h1:amey7yeodaJhXSbf/TlLvWiqQfLOSpEk//mLlc+axEk= -github.com/magiconair/properties v1.8.0/go.mod h1:PppfXfuXeibc/6YijjN8zIbojt8czPbwD3XqdrwzmxQ= github.com/magiconair/properties v1.8.7 h1:IeQXZAiQcpL9mgcAe1Nu6cX9LLw6ExEHKjN0VQdvPDY= github.com/magiconair/properties v1.8.7/go.mod h1:Dhd985XPs7jluiymwWYZ0G4Z61jb3vdS329zhj2hYo0= github.com/manifoldco/promptui v0.9.0 h1:3V4HzJk1TtXW1MTZMP7mdlwbBpIinw3HztaIlYthEiA= @@ -1540,8 +1521,8 @@ github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5 github.com/miekg/dns v1.0.14/go.mod h1:W1PPwlIAgtquWBMBEV9nkV9Cazfe8ScdGz/Lj7v3Nrg= github.com/minio/asm2plan9s v0.0.0-20200509001527-cdd76441f9d8/go.mod h1:mC1jAcsrzbxHt8iiaC+zU4b1ylILSosueou12R++wfY= github.com/minio/c2goasm v0.0.0-20190812172519-36a3d3bbc4f3/go.mod h1:RagcQ7I8IeTMnF8JTXieKnO4Z6JCsikNEzj0DwauVzE= -github.com/minio/highwayhash v1.0.2 h1:Aak5U0nElisjDCfPSG79Tgzkn2gl66NxOMspRrKnA/g= -github.com/minio/highwayhash v1.0.2/go.mod h1:BQskDq+xkJ12lmlUUi7U0M5Swg3EWR+dLTk+kldvVxY= +github.com/minio/highwayhash v1.0.3 h1:kbnuUMoHYyVl7szWjSxJnxw11k2U709jqFPPmIUyD6Q= +github.com/minio/highwayhash v1.0.3/go.mod h1:GGYsuwP/fPD6Y9hMiXuapVvlIUEhFhMTh0rxU3ik1LQ= github.com/mitchellh/cli v1.0.0/go.mod h1:hNIlj7HEI86fIcpObd7a0FcrxTWetlwJDGcceTlRvqc= github.com/mitchellh/go-homedir v1.0.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0= github.com/mitchellh/go-homedir v1.1.0 h1:lukF9ziXFxDFPkA1vsr5zpc1XuPDn/wFntq5mG+4E0Y= @@ -1558,7 +1539,6 @@ github.com/mitchellh/mapstructure v1.5.0/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RR github.com/mmcloughlin/addchain v0.4.0 h1:SobOdjm2xLj1KkXN5/n0xTIWyZA2+s99UCY1iPfkHRY= github.com/mmcloughlin/addchain v0.4.0/go.mod h1:A86O+tHqZLMNO4w6ZZ4FlVQEadcoqkyU72HC5wJ4RlU= github.com/mmcloughlin/profile v0.1.1/go.mod h1:IhHD7q1ooxgwTgjxQYkACGA77oFTDdFVejUS1/tS/qU= -github.com/moby/sys/mountinfo v0.5.0/go.mod h1:3bMD3Rg+zkqx8MRYPi7Pyb0Ie97QEBmdxbhnCLlSvSU= github.com/moby/term v0.0.0-20221205130635-1aeaba878587 h1:HfkjXDfhgVaN5rmueG8cL8KKeFNecRCXFhaJ2qZ5SKA= github.com/moby/term v0.0.0-20221205130635-1aeaba878587/go.mod h1:8FzsFHVUBGZdbDsJw/ot+X+d5HLUbvklYLJ9uGfcI3Y= github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= @@ -1568,9 +1548,10 @@ github.com/modern-go/reflect2 v0.0.0-20180701023420-4b7aa43c6742/go.mod h1:bx2lN github.com/modern-go/reflect2 v1.0.1/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0= github.com/modern-go/reflect2 v1.0.2 h1:xBagoLtFs94CBntxluKeaWgTMpvLxC4ur3nMaC9Gz0M= github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk= -github.com/mrunalp/fileutils v0.5.0/go.mod h1:M1WthSahJixYnrXQl/DFQuteStB1weuxD2QJNHXfbSQ= github.com/mtibben/percent v0.2.1 h1:5gssi8Nqo8QU/r2pynCm+hBQHpkB/uNK7BJCFogWdzs= github.com/mtibben/percent v0.2.1/go.mod h1:KG9uO+SZkUp+VkRHsCdYQV3XSZrrSpR3O9ibNBTZrns= +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/mwitkow/go-conntrack v0.0.0-20190716064945-2f068394615f h1:KUppIJq7/+SVif2QVs3tOP0zanoHgBEVAwHxUSIzRqU= github.com/mwitkow/go-conntrack v0.0.0-20190716064945-2f068394615f/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U= @@ -1612,10 +1593,8 @@ github.com/opencontainers/go-digest v1.0.0 h1:apOUWs51W5PlhuyGyz9FCeeBIOUDA/6nW8 github.com/opencontainers/go-digest v1.0.0/go.mod h1:0JzlMkj0TRzQZfJkVvzbP0HBR3IKzErnv2BNG4W4MAM= github.com/opencontainers/image-spec v1.1.0-rc2 h1:2zx/Stx4Wc5pIPDvIxHXvXtQFW/7XWJGmnM7r3wg034= github.com/opencontainers/image-spec v1.1.0-rc2/go.mod h1:3OVijpioIKYWTqjiG0zfF6wvoJ4fAXGbjdZuI2NgsRQ= -github.com/opencontainers/runc v1.1.5 h1:L44KXEpKmfWDcS02aeGm8QNTFXTo2D+8MYGDIJ/GDEs= -github.com/opencontainers/runc v1.1.5/go.mod h1:1J5XiS+vdZ3wCyZybsuxXZWGrgSr8fFJHLXuG2PsnNg= -github.com/opencontainers/runtime-spec v1.0.3-0.20210326190908-1c3f411f0417/go.mod h1:jwyrGlmzljRJv/Fgzds9SsS/C5hL+LL3ko9hs6T5lQ0= -github.com/opencontainers/selinux v1.10.0/go.mod h1:2i0OySw99QjzBBQByd1Gr9gSjvuho1lHsJxIJ3gGbJI= +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-contrib/go-observer v0.0.0-20170622124052-a52f23424492/go.mod h1:Ngi6UdF0k5OKD5t5wlmGhe/EDKPoUM3BXZSSfIuJbis= github.com/opentracing/basictracer-go v1.0.0/go.mod h1:QfBfYuafItcjQuMwinw9GhYKwFXS9KnPs5lxoYwgW74= github.com/opentracing/opentracing-go v1.0.2/go.mod h1:UkNAQd3GIcIGf0SeVgPpRdFStlNbqXla1AfSYxPUl2o= @@ -1633,14 +1612,11 @@ github.com/pascaldekloe/goe v0.0.0-20180627143212-57f6aae5913c/go.mod h1:lzWF7FI github.com/pascaldekloe/goe v0.1.0 h1:cBOtyMzM9HTpWjXfbbunk26uA6nG3a8n06Wieeh0MwY= github.com/pascaldekloe/goe v0.1.0/go.mod h1:lzWF7FIEvWOWxwDKqyGYQf6ZUaNfKdP144TG7ZOy1lc= github.com/pborman/uuid v1.2.0/go.mod h1:X/NO0urCmaxf9VXbdlT7C2Yzkj2IKimNn4k+gtPdI/k= -github.com/pelletier/go-toml v1.2.0/go.mod h1:5z9KED0ma1S8pY6P1sdut58dfprrGBbd/94hg7ilaic= -github.com/pelletier/go-toml/v2 v2.0.8/go.mod h1:vuYfssBdrU2XDZ9bYydBu6t+6a6PYNcZljzZR9VXg+4= -github.com/pelletier/go-toml/v2 v2.1.0 h1:FnwAJ4oYMvbT/34k9zzHuZNrhlz48GB3/s6at6/MHO4= -github.com/pelletier/go-toml/v2 v2.1.0/go.mod h1:tJU2Z3ZkXwnxa4DPO899bsyIoywizdUvyaeZurnPPDc= +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/performancecopilot/speed v3.0.0+incompatible/go.mod h1:/CLtqpZ5gBg1M9iaPbIdPPGyKcA8hKdoy6hAWba7Yac= -github.com/petermattis/goid v0.0.0-20180202154549-b0b1615b78e5/go.mod h1:jvVRKCrJTQWu0XVbaOlby/2lO20uSCHEMzzplHXte1o= -github.com/petermattis/goid v0.0.0-20231207134359-e60b3f734c67 h1:jik8PHtAIsPlCRJjJzl4udgEf7hawInF9texMeO2jrU= -github.com/petermattis/goid v0.0.0-20231207134359-e60b3f734c67/go.mod h1:pxMtw7cyUw6B2bRH0ZBANSPg+AoSud1I1iyJHI69jH4= +github.com/petermattis/goid v0.0.0-20240813172612-4fcff4a6cae7 h1:Dx7Ovyv/SFnMFw3fD4oEoeorXc6saIiQ23LrGLth0Gw= +github.com/petermattis/goid v0.0.0-20240813172612-4fcff4a6cae7/go.mod h1:pxMtw7cyUw6B2bRH0ZBANSPg+AoSud1I1iyJHI69jH4= github.com/phpdave11/gofpdf v1.4.2/go.mod h1:zpO6xFn9yxo3YLyMvW8HcKWVdbNqgIfOOp2dXMnm1mY= github.com/phpdave11/gofpdi v1.0.12/go.mod h1:vBmVV0Do6hSBHC8uKUQ71JGW+ZGQq74llk/7bXwjDoI= github.com/phpdave11/gofpdi v1.0.13/go.mod h1:vBmVV0Do6hSBHC8uKUQ71JGW+ZGQq74llk/7bXwjDoI= @@ -1667,8 +1643,8 @@ github.com/prometheus/client_golang v1.0.0/go.mod h1:db9x61etRT2tGnBNRi70OPL5Fsn github.com/prometheus/client_golang v1.3.0/go.mod h1:hJaj2vgQTGQmVCsAACORcieXFeDPbaTKGT+JTgUa3og= github.com/prometheus/client_golang v1.4.0/go.mod h1:e9GMxYsXl05ICDXkRhurwBS4Q3OK1iX/F2sw+iXX5zU= github.com/prometheus/client_golang v1.7.1/go.mod h1:PY5Wy2awLA44sXw4AOSfFBetzPP4j5+D6mVACh+pe2M= -github.com/prometheus/client_golang v1.19.0 h1:ygXvpU1AoN1MhdzckN+PyD9QJOSD4x7kmXYlnfbA6JU= -github.com/prometheus/client_golang v1.19.0/go.mod h1:ZRM9uEAypZakd+q/x7+gmsvXdURP+DABIEIjnmDdp+k= +github.com/prometheus/client_golang v1.20.5 h1:cxppBPuYhUnsO6yo/aoRol4L7q7UFfdm+bR9r+8l63Y= +github.com/prometheus/client_golang v1.20.5/go.mod h1:PIEt8X02hGcP8JWbeHyeZ53Y/jReSnHgO035n//V5WE= github.com/prometheus/client_model v0.0.0-20180712105110-5c3871d89910/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo= github.com/prometheus/client_model v0.0.0-20190115171406-56726106282f/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo= github.com/prometheus/client_model v0.0.0-20190129233127-fd36f4220a90/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= @@ -1685,16 +1661,16 @@ github.com/prometheus/common v0.7.0/go.mod h1:DjGbpBbp5NYNiECxcL/VnbXCCaQpKd3tt2 github.com/prometheus/common v0.9.1/go.mod h1:yhUN8i9wzaXS3w1O07YhxHEBxD+W35wd8bs7vj7HSQ4= github.com/prometheus/common v0.10.0/go.mod h1:Tlit/dnDKsSWFlCLTWaA1cyBgKHSMdTB80sz/V91rCo= github.com/prometheus/common v0.15.0/go.mod h1:U+gB1OBLb1lF3O42bTCL+FK18tX9Oar16Clt/msog/s= -github.com/prometheus/common v0.52.2 h1:LW8Vk7BccEdONfrJBDffQGRtpSzi5CQaRZGtboOO2ck= -github.com/prometheus/common v0.52.2/go.mod h1:lrWtQx+iDfn2mbH5GUzlH9TSHyfZpHkSiG1W7y3sF2Q= +github.com/prometheus/common v0.60.1 h1:FUas6GcOw66yB/73KC+BOZoFJmbo/1pojoILArPAaSc= +github.com/prometheus/common v0.60.1/go.mod h1:h0LYf1R1deLSKtD4Vdg8gy4RuOvENW2J/h19V5NADQw= github.com/prometheus/procfs v0.0.0-20181005140218-185b4288413d/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk= github.com/prometheus/procfs v0.0.0-20190117184657-bf6a532e95b1/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk= github.com/prometheus/procfs v0.0.2/go.mod h1:TjEm7ze935MbeOT/UhFTIMYKhuLP4wbCsTZCD3I8kEA= github.com/prometheus/procfs v0.0.8/go.mod h1:7Qr8sr6344vo1JqZ6HhLceV9o3AJ1Ff+GxbHq6oeK9A= github.com/prometheus/procfs v0.1.3/go.mod h1:lV6e/gmhEcM9IjHGsFOCxxuZ+z1YqCvr4OA4YeYWdaU= github.com/prometheus/procfs v0.3.0/go.mod h1:lV6e/gmhEcM9IjHGsFOCxxuZ+z1YqCvr4OA4YeYWdaU= -github.com/prometheus/procfs v0.13.0 h1:GqzLlQyfsPbaEHaQkO7tbDlriv/4o5Hudv6OXHGKX7o= -github.com/prometheus/procfs v0.13.0/go.mod h1:cd4PFCR54QLnGKPaKGA6l+cfuNXtht43ZKY6tow0Y1g= +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/rcrowley/go-metrics v0.0.0-20181016184325-3113b8401b8a/go.mod h1:bCqnVzQkZxMG4s8nGwiZ5l3QUCyqpo9Y+/ZMZ9VjZe4= github.com/rcrowley/go-metrics v0.0.0-20201227073835-cf1acfcdf475 h1:N/ElC8H3+5XpJzTSTfLsJV/mx9Q9g7kxmchpfZyxgzM= github.com/rcrowley/go-metrics v0.0.0-20201227073835-cf1acfcdf475/go.mod h1:bCqnVzQkZxMG4s8nGwiZ5l3QUCyqpo9Y+/ZMZ9VjZe4= @@ -1712,12 +1688,11 @@ github.com/rogpeppe/go-internal v1.9.0/go.mod h1:WtVeX8xhTBvf0smdhujwtBcq4Qrzq/f 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/cors v1.7.0/go.mod h1:gFx+x8UowdsKA9AchylcLynDq+nNFfI8FkUZdN/jGCU= -github.com/rs/cors v1.8.3 h1:O+qNyWn7Z+F9M0ILBHgMVPuB1xTOucVd5gtaYyXBpRo= -github.com/rs/cors v1.8.3/go.mod h1:XyqrcTp5zjWr1wsJ8PIRZssZ8b/WMcMf71DJnit4EMU= +github.com/rs/cors v1.11.1 h1:eU3gRzXLRK57F5rKMGMZURNdIG4EoAmX8k94r9wXWHA= +github.com/rs/cors v1.11.1/go.mod h1:XyqrcTp5zjWr1wsJ8PIRZssZ8b/WMcMf71DJnit4EMU= github.com/rs/xid v1.5.0/go.mod h1:trrq9SKmegXys3aeAKXMUTdJsYXVwGY3RLcfgqegfbg= -github.com/rs/zerolog v1.32.0 h1:keLypqrlIjaFsbmJOBdB/qvyF8KEtCWHwobLp5l/mQ0= -github.com/rs/zerolog v1.32.0/go.mod h1:/7mN4D5sKwJLZQ2b/znpjC3/GQWY/xaDXUM0kKWRHss= -github.com/russross/blackfriday v1.5.2/go.mod h1:JO/DiYxRf+HjHt06OyowR9PTA263kcR/rfWxYHBV53g= +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/russross/blackfriday/v2 v2.0.1/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= github.com/ruudk/golang-pdf417 v0.0.0-20181029194003-1af4ab5afa58/go.mod h1:6lfFZQK844Gfx8o5WFuvpxWRwnSoipWe/p622j1v06w= @@ -1728,10 +1703,11 @@ github.com/sagikazarmark/locafero v0.4.0/go.mod h1:Pe1W6UlPYUk/+wc/6KFhbORCfqzgY 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/samuel/go-zookeeper v0.0.0-20190923202752-2cc03de413da/go.mod h1:gi+0XIa01GRL2eRQVjQkKGqKF3SF9vZR/HnPullcV2E= -github.com/sasha-s/go-deadlock v0.3.1 h1:sqv7fDNShgjcaxkO0JNcOAlr8B9+cV5Ey/OB71efZx0= -github.com/sasha-s/go-deadlock v0.3.1/go.mod h1:F73l+cr82YSh10GxyRI6qZiCgK64VaZjwesgfQ1/iLM= +github.com/sasha-s/go-deadlock v0.3.5 h1:tNCOEEDG6tBqrNDOX35j/7hL5FcFViG6awUGROb2NsU= +github.com/sasha-s/go-deadlock v0.3.5/go.mod h1:bugP6EGbdGYObIlx7pUZtWqlvo8k9H6vCBBsiChJQ5U= github.com/sean-/seed v0.0.0-20170313163322-e2103e2c3529/go.mod h1:DxrIzT+xaE7yg65j358z/aeFdxmN0P9QXhEzd20vsDc= -github.com/seccomp/libseccomp-golang v0.9.2-0.20220502022130-f33da4d89646/go.mod h1:JA8cRccbGaA1s33RQf7Y1+q9gHmZX1yB/z9WDN1C6fg= +github.com/shamaton/msgpack/v2 v2.2.0 h1:IP1m01pHwCrMa6ZccP9B3bqxEMKMSmMVAVKk54g3L/Y= +github.com/shamaton/msgpack/v2 v2.2.0/go.mod h1:6khjYnkx73f7VQU7wjcFS9DFjs+59naVWJv1TB7qdOI= github.com/shirou/gopsutil v3.21.4-0.20210419000835-c7a38de76ee5+incompatible h1:Bn1aCHHRnjv4Bl16T8rcaFjYSrGrIZvpiGO6P3Q4GpU= github.com/shirou/gopsutil v3.21.4-0.20210419000835-c7a38de76ee5+incompatible/go.mod h1:5b4v6he4MtMOwMlS0TUMTu2PcXUg8+E1lC7eC3UO/RA= github.com/shurcooL/sanitized_anchor_name v1.0.0/go.mod h1:1NzhyTcUVG4SuEtjjoZeVRXNmyL/1OwPU0+IJeTBvfc= @@ -1739,7 +1715,6 @@ github.com/sirupsen/logrus v1.2.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPx github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6MwdIuYE2rE= github.com/sirupsen/logrus v1.6.0/go.mod h1:7uNnSEd1DgxDLC74fIahvMZmmYsHGZGEOFrfsX/uA88= github.com/sirupsen/logrus v1.7.0/go.mod h1:yWOB1SBYBC5VeMP7gHvWumXLIWorT60ONWic61uBYv0= -github.com/sirupsen/logrus v1.8.1/go.mod h1:yWOB1SBYBC5VeMP7gHvWumXLIWorT60ONWic61uBYv0= github.com/sirupsen/logrus v1.9.3 h1:dueUQJ1C2q9oE3F7wvmSGAaVtTmUizReu6fjN8uqzbQ= github.com/sirupsen/logrus v1.9.3/go.mod h1:naHLuLoDiP4jHNo9R0sCBMtWGeIprob74mVsIT4qYEQ= github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d h1:zE9ykElWQ6/NYmHa3jpm/yHnI4xSofP+UP6SpjHcSeM= @@ -1750,31 +1725,22 @@ github.com/soheilhy/cmux v0.1.4/go.mod h1:IM3LyeVVIOuxMH7sFAkER9+bJ4dT7Ms6E4xg4k github.com/sony/gobreaker v0.4.1/go.mod h1:ZKptC7FHNvhBz7dN2LGjPVBz2sZJmc0/PkyDJOjmxWY= 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/spaolacci/murmur3 v0.0.0-20180118202830-f09979ecbc72/go.mod h1:JwIasOWyU6f++ZhiEuf87xNszmSA2myDM2Kzu9HwQUA= -github.com/spaolacci/murmur3 v1.1.0 h1:7c1g84S4BPRrfL5Xrdp6fOJ206sU9y293DDHaoy0bLI= -github.com/spaolacci/murmur3 v1.1.0/go.mod h1:JwIasOWyU6f++ZhiEuf87xNszmSA2myDM2Kzu9HwQUA= -github.com/spf13/afero v1.1.2/go.mod h1:j4pytiNVoe2o6bmDsKpLACNPDBIoEAkihy7loJ1B0CQ= github.com/spf13/afero v1.3.3/go.mod h1:5KUK8ByomD5Ti5Artl0RtHeI5pTF7MIDuXL3yY520V4= github.com/spf13/afero v1.6.0/go.mod h1:Ai8FlHk4v/PARR026UzYexafAt9roJ7LcLMAmO6Z93I= github.com/spf13/afero v1.9.2/go.mod h1:iUV7ddyEEZPO5gA3zD4fJt6iStLlL+Lg4m2cihcDf8Y= github.com/spf13/afero v1.10.0/go.mod h1:UBogFpq8E9Hx+xc5CNTTEpTnuHVmXDwZcZcE1eb/UhQ= 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.3.0/go.mod h1:Qx5cxh0v+4UWYiBimWS+eyWzqEqokIECu5etghLkUJE= -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/cast v1.7.0 h1:ntdiHjuueXFgm5nzDRdOS4yfT43P5Fnud6DH50rz/7w= +github.com/spf13/cast v1.7.0/go.mod h1:ancEpBxwJDODSW/UG4rDrAqiKolqNNh2DX3mk86cAdo= github.com/spf13/cobra v0.0.3/go.mod h1:1l0Ry5zgKvJasoi3XT1TypsSe7PqH0Sj9dhYf7v3XqQ= -github.com/spf13/cobra v0.0.5/go.mod h1:3K3wKZymM7VvHMDS9+Akkh4K60UwM26emMESw8tLCHU= -github.com/spf13/cobra v1.8.0 h1:7aJaZx1B85qltLMc546zn58BxxfZdR/W22ej9CFoEf0= -github.com/spf13/cobra v1.8.0/go.mod h1:WXLWApfZ71AjXPya3WOlMsY9yMs7YeiHhFVlvLyhcho= -github.com/spf13/jwalterweatherman v1.0.0/go.mod h1:cQK4TGJAtQXfYWX+Ddv3mKDzgVb68N+wFjFa4jdeBTo= +github.com/spf13/cobra v1.8.1 h1:e5/vxKd/rZsfSJMUX1agtjeTDf+qv1/JdBF8gg5k9ZM= +github.com/spf13/cobra v1.8.1/go.mod h1:wHxEcudfqmLYa8iTfL+OuZPbBZkmvliBWKIezN3kD9Y= github.com/spf13/pflag v1.0.1/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4= -github.com/spf13/pflag v1.0.3/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4= 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.3.2/go.mod h1:ZiWeW+zYFKm7srdB9IoDzzZXaJaI5eL9QjNiN/DMA2s= -github.com/spf13/viper v1.18.2 h1:LUXCnvUvSM6FXAsj6nnfc8Q2tp1dIgUfY9Kc8GsSOiQ= -github.com/spf13/viper v1.18.2/go.mod h1:EKmWIqdnk5lOcmR72yw6hS+8OPYcwD0jteitLMVB+yk= +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/strangelove-ventures/cometbft-client v0.1.0 h1:fcA652QaaR0LDnyJOZVjZKtuyAawnVXaq/p1MWJSYD4= github.com/strangelove-ventures/cometbft-client v0.1.0/go.mod h1:QzThgjzvsGgUNVNpGPitmxOWMIhp6a0oqf80nCRNt/0= github.com/streadway/amqp v0.0.0-20190404075320-75d898a42a94/go.mod h1:AZpEONHx3DKn8O/DFsRAY58/XVQiIPMTMB1SddzLXVw= @@ -1796,7 +1762,6 @@ github.com/stretchr/testify v1.7.2/go.mod h1:R6va5+xMeoiuVRoj+gSkQ7d3FALtqAAGI1F github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4= github.com/stretchr/testify v1.8.2/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4= -github.com/stretchr/testify v1.8.3/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= 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= @@ -1804,7 +1769,6 @@ github.com/subosito/gotenv v1.6.0 h1:9NlTDc1FTs4qu0DDq7AEtTPNw6SVm7uBMsUCUjABIf8 github.com/subosito/gotenv v1.6.0/go.mod h1:Dk4QP5c2W3ibzajGcXpNraDfq2IrhjMIvMSWPKKo0FU= github.com/supranational/blst v0.3.11 h1:LyU6FolezeWAhvQk0k6O/d49jqgO52MSDDfYgbeoEm4= github.com/supranational/blst v0.3.11/go.mod h1:jZJtfjgudtNl4en1tzwPIV3KjUnQUvG3/j+w+fVonLw= -github.com/syndtr/gocapability v0.0.0-20200815063812-42c35b437635/go.mod h1:hkRG7XYTFWNJGYcbNJQlaLq0fg1yr4J4t/NcTQtrfww= github.com/syndtr/goleveldb v1.0.1-0.20210819022825-2ae1ddf74ef7 h1:epCh84lMvA70Z7CTTCmYQn2CKbY8j86K7/FAIr141uY= github.com/syndtr/goleveldb v1.0.1-0.20210819022825-2ae1ddf74ef7/go.mod h1:q4W45IWZaF22tdD+VEXcAWRA037jwmWEB5VWYORlTpc= github.com/tendermint/go-amino v0.16.0 h1:GyhmgQKvqF82e2oZeuMSp9JTN0N09emoSZlb2lyGa2E= @@ -1817,11 +1781,11 @@ github.com/tklauser/numcpus v0.6.1 h1:ng9scYS7az0Bk4OZLvrNXNSAO2Pxr1XXRAPyjhIx+F github.com/tklauser/numcpus v0.6.1/go.mod h1:1XfjsgE2zo8GVw7POkMbHENHzVg3GzmoZ9fESEdAacY= github.com/tmc/grpc-websocket-proxy v0.0.0-20170815181823-89b8d40f7ca8/go.mod h1:ncp9v5uamzpCO7NfCPTXjqaC+bZgJeR0sMTm6dMHP7U= github.com/tv42/httpunix v0.0.0-20150427012821-b75d8614f926/go.mod h1:9ESjWnEqriFuLhtthL60Sar/7RFoluCcXsuvEwTV5KM= -github.com/twitchyliquid64/golang-asm v0.15.1 h1:SU5vSMR7hnwNxj24w34ZyCi/FmDZTkS4MhqMhdFk5YI= -github.com/twitchyliquid64/golang-asm v0.15.1/go.mod h1:a1lVb/DtPvCB8fslRZhAngC2+aY1QWCk3Cedj/Gdt08= github.com/tyler-smith/go-bip39 v1.1.0 h1:5eUemwrMargf3BSLRRCalXT93Ns6pQJIjYQN2nyfOP8= github.com/tyler-smith/go-bip39 v1.1.0/go.mod h1:gUYDtqQw1JS3ZJ8UWVcGTGqqr6YIN3CWg+kkNaLt55U= -github.com/ugorji/go/codec v0.0.0-20181204163529-d75b2dcb6bc8/go.mod h1:VFNgLljTbGfSG7qAOspJ7OScBnGdDN/yBr0sguwnwf0= +github.com/ugorji/go v1.1.7 h1:/68gy2h+1mWMrwZFeD1kQialdSzAb432dtpeJ42ovdo= +github.com/ugorji/go v1.1.7/go.mod h1:kZn38zHttfInRq0xu/PH0az30d+z6vm202qpg1oXVMw= +github.com/ugorji/go/codec v1.1.7/go.mod h1:Ax+UKWsSmolVDwsd+7N3ZtXu+yMGCf907BLYF3GoBXY= github.com/ugorji/go/codec v1.2.11 h1:BMaWp1Bb6fHwEtbplGBGJ498wD+LKlNSl25MjdZY4dU= github.com/ugorji/go/codec v1.2.11/go.mod h1:UNopzCgEMSXjBc6AOMqYvWC1ktqTAfzJZUZgYf6w6lg= github.com/ulikunitz/xz v0.5.10/go.mod h1:nbz6k7qbPmH4IRqmfOplQw/tblSgqTqBwxkY0oWt/14= @@ -1829,8 +1793,6 @@ github.com/ulikunitz/xz v0.5.11 h1:kpFauv27b6ynzBNT/Xy+1k+fK4WswhN/6PN5WhFAGw8= github.com/ulikunitz/xz v0.5.11/go.mod h1:nbz6k7qbPmH4IRqmfOplQw/tblSgqTqBwxkY0oWt/14= github.com/urfave/cli v1.20.0/go.mod h1:70zkFmudgCuE/ngEzBv17Jvp/497gISqfk5gWijbERA= github.com/urfave/cli v1.22.1/go.mod h1:Gos4lmkARVdJ6EkW0WaNv/tZAAMe9V7XWyB60NtXRu0= -github.com/vishvananda/netlink v1.1.0/go.mod h1:cTgwzPIzzgDAYoQrMm0EdrjRUBkTqKYppBueQtXaqoE= -github.com/vishvananda/netns v0.0.0-20191106174202-0a2b9b5464df/go.mod h1:JP3t17pCcGlemwknint6hfoeCVQrEMVwxRLRjXpq+BU= github.com/vulpine-io/io-test v1.0.0 h1:Ot8vMh+ssm1VWDAwJ3U4C5qG9aRnr5YfQFZPNZBAUGI= github.com/vulpine-io/io-test v1.0.0/go.mod h1:X1I+p5GCxVX9m4nFd1HBtr2bVX9v1ZE6x8w+Obt36AU= github.com/xeipuuv/gojsonpointer v0.0.0-20180127040702-4e3ac2762d5f/go.mod h1:N2zxlSyiKSe5eX1tZViRH5QA0qijqEDrYZiPEAiq3wU= @@ -1841,7 +1803,6 @@ github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415/go.mod h1: github.com/xeipuuv/gojsonschema v1.2.0 h1:LhYJRs+L4fBtjZUfuSZIKGeVu0QRy8e5Xi7D17UxZ74= github.com/xeipuuv/gojsonschema v1.2.0/go.mod h1:anYRn/JVcOK2ZgGU+IjEV4nwlhoK5sQluxsYJ78Id3Y= github.com/xiang90/probing v0.0.0-20190116061207-43a291ad63a2/go.mod h1:UETIi67q53MR2AWcXfiuqkDkRtnGDLqkBTpCHuJHxtU= -github.com/xordataexchange/crypt v0.0.3-0.20170626215501-b2862e3d0a77/go.mod h1:aYKd//L2LvnjZzWKhF00oedf4jCCReLcmhLdhm1A27Q= github.com/yuin/goldmark v1.1.25/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.1.32/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= @@ -1856,8 +1817,8 @@ github.com/zondax/hid v0.9.2/go.mod h1:l5wttcP0jwtdLjqjMMWFVEE7d1zO0jvSPA9OPZxWp github.com/zondax/ledger-go v0.14.3 h1:wEpJt2CEcBJ428md/5MgSLsXLBos98sBOyxNmCjfUCw= github.com/zondax/ledger-go v0.14.3/go.mod h1:IKKaoxupuB43g4NxeQmbLXv7T9AlQyie1UpHb342ycI= go.etcd.io/bbolt v1.3.3/go.mod h1:IbVyRI1SCnLcuJnV2u8VeU0CEYM7e686BmAb1XKL+uU= -go.etcd.io/bbolt v1.3.8 h1:xs88BrvEv273UsB79e0hcVrlUWmS0a8upikMFhSyAtA= -go.etcd.io/bbolt v1.3.8/go.mod h1:N9Mkw9X8x5fupy0IKsmuqVtoGDyxsaDlbk4Rd05IAQw= +go.etcd.io/bbolt v1.4.0-alpha.0.0.20240404170359-43604f3112c5 h1:qxen9oVGzDdIRP6ejyAJc760RwW4SnVDiTYTzwnXuxo= +go.etcd.io/bbolt v1.4.0-alpha.0.0.20240404170359-43604f3112c5/go.mod h1:eW0HG9/oHQhvRCvb1/pIXW4cOvtDqeQK+XSi3TnwaXY= go.etcd.io/etcd v0.0.0-20191023171146-3cf2f69b5738/go.mod h1:dnLIgRNXwCJa5e+c6mIZCrds/GIG4ncV9HhK5PX7jPg= go.opencensus.io v0.20.1/go.mod h1:6WKK9ahsWS3RSO+PY9ZHZUfv2irvY6gN279GOPZjmmk= go.opencensus.io v0.20.2/go.mod h1:6WKK9ahsWS3RSO+PY9ZHZUfv2irvY6gN279GOPZjmmk= @@ -1874,14 +1835,14 @@ go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.4 go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.49.0/go.mod h1:Mjt1i1INqiaoZOMGR1RIUJN+i3ChKoFRqzrRQhlkbs0= go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.49.0 h1:jq9TW8u3so/bN+JPT166wjOI6/vQPF6Xe7nMNIltagk= go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.49.0/go.mod h1:p8pYQP+m5XfbZm9fxtSKAbM6oIllS7s2AfxrChvc7iw= -go.opentelemetry.io/otel v1.30.0 h1:F2t8sK4qf1fAmY9ua4ohFS/K+FUuOPemHUIXHtktrts= -go.opentelemetry.io/otel v1.30.0/go.mod h1:tFw4Br9b7fOS+uEao81PJjVMjW/5fvNCbpsDIXqP0pc= -go.opentelemetry.io/otel/metric v1.30.0 h1:4xNulvn9gjzo4hjg+wzIKG7iNFEaBMX00Qd4QIZs7+w= -go.opentelemetry.io/otel/metric v1.30.0/go.mod h1:aXTfST94tswhWEb+5QjlSqG+cZlmyXy/u8jFpor3WqQ= -go.opentelemetry.io/otel/sdk v1.30.0 h1:cHdik6irO49R5IysVhdn8oaiR9m8XluDaJAs4DfOrYE= -go.opentelemetry.io/otel/sdk v1.30.0/go.mod h1:p14X4Ok8S+sygzblytT1nqG98QG2KYKv++HE0LY/mhg= -go.opentelemetry.io/otel/trace v1.30.0 h1:7UBkkYzeg3C7kQX8VAidWh2biiQbtAKjyIML8dQ9wmc= -go.opentelemetry.io/otel/trace v1.30.0/go.mod h1:5EyKqTzzmyqB9bwtCCq6pDLktPK6fmGf/Dph+8VI02o= +go.opentelemetry.io/otel v1.24.0 h1:0LAOdjNmQeSTzGBzduGe/rU4tZhMwL5rWgtp9Ku5Jfo= +go.opentelemetry.io/otel v1.24.0/go.mod h1:W7b9Ozg4nkF5tWI5zsXkaKKDjdVjpD4oAt9Qi/MArHo= +go.opentelemetry.io/otel/metric v1.24.0 h1:6EhoGWWK28x1fbpA4tYTOWBkPefTDQnb8WSGXlc88kI= +go.opentelemetry.io/otel/metric v1.24.0/go.mod h1:VYhLe1rFfxuTXLgj4CBiyz+9WYBA8pNGJgDcSFRKBco= +go.opentelemetry.io/otel/sdk v1.22.0 h1:6coWHw9xw7EfClIC/+O31R8IY3/+EiRFHevmHafB2Gw= +go.opentelemetry.io/otel/sdk v1.22.0/go.mod h1:iu7luyVGYovrRpe2fmj3CVKouQNdTOkxtLzPvPz1DOc= +go.opentelemetry.io/otel/trace v1.24.0 h1:CsKnnL4dUAr/0llH9FKuc698G04IrpWV0MQA/Y1YELI= +go.opentelemetry.io/otel/trace v1.24.0/go.mod h1:HPc3Xr/cOApsBI154IU0OI0HJexz+aw5uPdbs3UCjNU= go.opentelemetry.io/proto/otlp v0.7.0/go.mod h1:PqfVotwruBrMGOCsRd/89rSnXhoiJIqeYNgFYFoEGnI= go.opentelemetry.io/proto/otlp v0.15.0/go.mod h1:H7XAot3MsfNsj7EXtrA2q5xSNQ10UqI405h3+duxN4U= go.opentelemetry.io/proto/otlp v0.19.0/go.mod h1:H7XAot3MsfNsj7EXtrA2q5xSNQ10UqI405h3+duxN4U= @@ -1904,13 +1865,9 @@ go.uber.org/zap v1.13.0/go.mod h1:zwrFLgMcdUuIBviXEYEH1YKNaOBnKXsx2IPda5bBwHM= go.uber.org/zap v1.18.1/go.mod h1:xg/QME4nWcxGxrpdeYfq7UvYrLh66cuVKdrbD1XF/NI= go.uber.org/zap v1.26.0 h1:sI7k6L95XOKS281NhVKOFCUNIvv9e0w4BF8N3u+tCRo= go.uber.org/zap v1.26.0/go.mod h1:dtElttAiwGvoJ/vj4IwHBS/gXsEu/pZ50mUIRWuG0so= -golang.org/x/arch v0.0.0-20210923205945-b76863e36670/go.mod h1:5om86z9Hs0C8fWVUuoMHwpExlXzs5Tkyp9hOrfG7pp8= -golang.org/x/arch v0.3.0 h1:02VY4/ZcO/gBOH6PUaoiptASxtXU10jazRCP865E97k= -golang.org/x/arch v0.3.0/go.mod h1:5om86z9Hs0C8fWVUuoMHwpExlXzs5Tkyp9hOrfG7pp8= golang.org/x/crypto v0.0.0-20170930174604-9419663f5a44/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= golang.org/x/crypto v0.0.0-20180904163835-0709b304e793/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= golang.org/x/crypto v0.0.0-20181029021203-45a5f77698d3/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= -golang.org/x/crypto v0.0.0-20181203042331-505ab145d0a9/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-20190510104115-cbcb75029529/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20190605123033-f99c8df09eb5/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= @@ -1934,8 +1891,8 @@ golang.org/x/crypto v0.18.0/go.mod h1:R0j02AL6hcrfOiy9T4ZYp/rcWeMxM3L6QYxlOuEG1m golang.org/x/crypto v0.19.0/go.mod h1:Iy9bg/ha4yyC70EfRS8jz+B6ybOBKMaSxLj6P6oBDfU= golang.org/x/crypto v0.21.0/go.mod h1:0BP7YvVV9gBbVKyeTG0Gyn+gZm94bibOW5BjDEYAOMs= golang.org/x/crypto v0.23.0/go.mod h1:CKFgDieR+mRhux2Lsu27y0fO304Db0wZe70UKqHu0v8= -golang.org/x/crypto v0.27.0 h1:GXm2NjJrPaiv/h1tb2UH8QfgC/hOf/+z0p6PT8o1w7A= -golang.org/x/crypto v0.27.0/go.mod h1:1Xngt8kV6Dvbssa53Ziq6Eqn0HqbZi5Z6R0ZpwQzt70= +golang.org/x/crypto v0.28.0 h1:GBDwsMXVQi34v5CCYUm2jkJvu4cbtru2U4TN2PSyQnw= +golang.org/x/crypto v0.28.0/go.mod h1:rmgy+3RHxRZMyY0jjAJShp2zgEdOqj2AO7U0pYmeQ7U= golang.org/x/exp v0.0.0-20180321215751-8460e604b9de/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20180807140117-3d87b88a115f/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= @@ -2078,8 +2035,8 @@ golang.org/x/net v0.20.0/go.mod h1:z8BVo6PvndSri0LbOE3hAn0apkU+1YvI6E70E9jsnvY= golang.org/x/net v0.21.0/go.mod h1:bIjVDfnllIU7BJ2DNgfnXvpSvtn8VRwhlsaeUTyUS44= golang.org/x/net v0.22.0/go.mod h1:JKghWKKOSdJwpW2GEx0Ja7fmaKnMsbu+MWVZTokSYmg= golang.org/x/net v0.25.0/go.mod h1:JkAGAh7GEvH74S6FOH42FLoXpXbE/aqXSrIQjXgsiwM= -golang.org/x/net v0.29.0 h1:5ORfpBpCs4HzDYoodCDBbwHzdR5UrLBZ3sOnUJmFoHo= -golang.org/x/net v0.29.0/go.mod h1:gLkgy8jTGERgjzMic6DS9+SP0ajcu6Xu3Orq/SpETg0= +golang.org/x/net v0.30.0 h1:AcW1SDZMkb8IpzCdQUaIq2sP4sZ4zw+55h6ynffypl4= +golang.org/x/net v0.30.0/go.mod h1:2wGyMJ5iFasEhkwi13ChkO/t1ECNC4X4eBKkVFyYFlU= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= @@ -2111,8 +2068,8 @@ golang.org/x/oauth2 v0.6.0/go.mod h1:ycmewcwgD4Rpr3eZJLSB4Kyyljb3qDh40vJ8STE5HKw golang.org/x/oauth2 v0.7.0/go.mod h1:hPLQkd9LyjfXTiRohC/41GhcFqxisoUQ99sCUOHO9x4= golang.org/x/oauth2 v0.8.0/go.mod h1:yr7u4HXZRm1R1kBWqr/xKNqewf0plRYoB7sla+BCIXE= golang.org/x/oauth2 v0.20.0/go.mod h1:XYTD2NtWslqkgxebSiOHnXEap4TF09sJSc7H1sXbhtI= -golang.org/x/oauth2 v0.22.0 h1:BzDx2FehcG7jJwgWLELCdmLuxk2i+x9UDpSiss2u0ZA= -golang.org/x/oauth2 v0.22.0/go.mod h1:XYTD2NtWslqkgxebSiOHnXEap4TF09sJSc7H1sXbhtI= +golang.org/x/oauth2 v0.23.0 h1:PbgcYx2W7i4LvjJWEbf0ngHV6qJYr86PkAV3bXdLEbs= +golang.org/x/oauth2 v0.23.0/go.mod h1:XYTD2NtWslqkgxebSiOHnXEap4TF09sJSc7H1sXbhtI= golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= @@ -2141,8 +2098,6 @@ golang.org/x/sys v0.0.0-20181026203630-95b1ffbd15a5/go.mod h1:STP8DvDyc/dI5b8T5h golang.org/x/sys v0.0.0-20181107165924-66b7b1311ac8/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-20181122145206-62eef0e2fa9b/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/sys v0.0.0-20181205085412-a5c9d58dba9a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/sys v0.0.0-20190130150945-aca44879d564/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-20190312061237-fead79001313/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= @@ -2150,16 +2105,13 @@ golang.org/x/sys v0.0.0-20190422165155-953cdadca894/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20190502145724-3ef323f4f1fd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190507160741-ecd444e8653b/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190606165138-5da285871e9c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20190606203320-7fc4e5ec1444/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190624142023-c5567b49c5d0/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20190626221950-04f50cda93cb/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190726091711-fc99dfbffb4e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190826190057-c7b8b68b1456/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190904154756-749cb33beabd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20191001151750-bb3f8db39f24/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20191005200804-aed5e4c7ecf9/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20191026070338-33540a1f6037/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20191115151921-52ab43148777/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-20191220142924-d4481acd189f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= @@ -2190,7 +2142,6 @@ golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20201201145000-ef89a241ccb3/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210104204734-6f8348627aad/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210119212857-b64e53b001e4/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20210124154548-22da62e12c0c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210220050731-9a76102bfb43/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210225134936-a50acf3fe073/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210304124612-50617c2ba197/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= @@ -2211,13 +2162,11 @@ golang.org/x/sys v0.0.0-20210809222454-d867a43fc93e/go.mod h1:oPkhp1MJrh7nUepCBc golang.org/x/sys v0.0.0-20210816183151-1e6c022a8912/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210819135213-f52c844e1c1c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210823070655-63515b42dcdf/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20210906170528-6f6e22806c34/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210908233432-aa78b53d3365/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-20211007075335-d3039528d8ac/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20211019181941-9d821ace8654/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-20211116061358-0a5406a5449c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20211124211545-fe61309f8881/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20211210111614-af8b64212486/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= @@ -2234,13 +2183,11 @@ golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBc golang.org/x/sys v0.0.0-20220610221304-9f5ed59c137d/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220615213510-4f61da869c0c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220624220833-87e55d714810/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20220704084225-05e143d24a9e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220728004956-3c1f35247d10/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-20220829200755-d48e67d00261/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20221010170243-090e33056c14/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.1.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.2.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.3.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= @@ -2255,8 +2202,9 @@ golang.org/x/sys v0.16.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/sys v0.17.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/sys v0.18.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/sys v0.20.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= -golang.org/x/sys v0.25.0 h1:r+8e+loiHxRqhXVl6ML1nO3l1+oFoWbnlu2Ehimmi34= -golang.org/x/sys v0.25.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/sys v0.21.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/sys v0.26.0 h1:KHjCJyddX0LoSTb3J+vWpupP9p0oznkqVk/IfjymZbo= +golang.org/x/sys v0.26.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= golang.org/x/term v0.1.0/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= @@ -2273,8 +2221,8 @@ golang.org/x/term v0.16.0/go.mod h1:yn7UURbUtPyrVJPGPq404EukNFxcm/foM+bV/bfcDsY= golang.org/x/term v0.17.0/go.mod h1:lLRBjIVuehSbZlaOtGMbcMncT+aqLLLmKrsjNrUguwk= golang.org/x/term v0.18.0/go.mod h1:ILwASektA3OnRv7amZ1xhE/KTR+u50pbXfZ03+6Nx58= golang.org/x/term v0.20.0/go.mod h1:8UkIAJTvZgivsXaD6/pH6U9ecQzZ45awqEOzuCvwpFY= -golang.org/x/term v0.24.0 h1:Mh5cbb+Zk2hqqXNO7S1iTjEphVL+jb8ZWaqh/g+JWkM= -golang.org/x/term v0.24.0/go.mod h1:lOBK/LVxemqiMij05LGJ0tzNr8xlmwBRJ81PX6wVLH8= +golang.org/x/term v0.25.0 h1:WtHI/ltw4NvSUig5KARz9h521QvRC8RmF/cuYqifU24= +golang.org/x/term v0.25.0/go.mod h1:RPyXicDX+6vLxogjjRxjgD2TKtmAO6NZBsBRfrOLu7M= golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= @@ -2294,8 +2242,8 @@ golang.org/x/text v0.10.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE= golang.org/x/text v0.13.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE= golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU= golang.org/x/text v0.15.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU= -golang.org/x/text v0.18.0 h1:XvMDiNzPAl0jr17s6W9lcaIhGUfUORdGCNsuLmPG224= -golang.org/x/text v0.18.0/go.mod h1:BuEKDfySbSR4drPmRPG/7iBdf8hvFMuRexcpahXilzY= +golang.org/x/text v0.19.0 h1:kTxAhCbGbxhK0IwgSKiMO5awPoDQ0RpfiVYBfK860YM= +golang.org/x/text v0.19.0/go.mod h1:BuEKDfySbSR4drPmRPG/7iBdf8hvFMuRexcpahXilzY= golang.org/x/time v0.0.0-20180412165947-fbb02b2291d2/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= @@ -2458,8 +2406,8 @@ google.golang.org/api v0.122.0/go.mod h1:gcitW0lvnyWjSp9nKxAbdHKIZ6vF4aajGueeslZ google.golang.org/api v0.124.0/go.mod h1:xu2HQurE5gi/3t1aFCvhPD781p0a3p11sdunTJ2BlP4= google.golang.org/api v0.125.0/go.mod h1:mBwVAtz+87bEN6CbA1GtZPDOqY2R5ONPqJeIlvyo4Aw= google.golang.org/api v0.126.0/go.mod h1:mBwVAtz+87bEN6CbA1GtZPDOqY2R5ONPqJeIlvyo4Aw= -google.golang.org/api v0.169.0 h1:QwWPy71FgMWqJN/l6jVlFHUa29a7dcUy02I8o799nPY= -google.golang.org/api v0.169.0/go.mod h1:gpNOiMA2tZ4mf5R9Iwf4rK/Dcz0fbdIgWYWVoxmsyLg= +google.golang.org/api v0.171.0 h1:w174hnBPqut76FzW5Qaupt7zY8Kql6fiVjgys4f58sU= +google.golang.org/api v0.171.0/go.mod h1:Hnq5AHm4OTMt2BUVjael2CWZFD6vksJdWCWiUAmjC9o= google.golang.org/appengine v1.2.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= google.golang.org/appengine v1.5.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= @@ -2627,8 +2575,8 @@ google.golang.org/genproto/googleapis/api v0.0.0-20230711160842-782d3b101e98/go. google.golang.org/genproto/googleapis/api v0.0.0-20230726155614-23370e0ffb3e/go.mod h1:rsr7RhLuwsDKL7RmgDDCUc6yaGr1iqceVb5Wv6f6YvQ= google.golang.org/genproto/googleapis/api v0.0.0-20230822172742-b8732ec3820d/go.mod h1:KjSP20unUpOx5kyQUFa7k4OJg0qeJ7DEZflGDu2p6Bk= google.golang.org/genproto/googleapis/api v0.0.0-20240528184218-531527333157/go.mod h1:99sLkeliLXfdj2J75X3Ho+rrVCaJze0uwN7zDDkjPVU= -google.golang.org/genproto/googleapis/api v0.0.0-20240903143218-8af14fe29dc1 h1:hjSy6tcFQZ171igDaN5QHOw2n6vx40juYbC/x67CEhc= -google.golang.org/genproto/googleapis/api v0.0.0-20240903143218-8af14fe29dc1/go.mod h1:qpvKtACPCQhAdu3PyQgV4l3LMXZEtft7y8QcarRsp9I= +google.golang.org/genproto/googleapis/api v0.0.0-20240814211410-ddb44dafa142 h1:wKguEg1hsxI2/L3hUYrpo1RVi48K+uTyzKqprwLXsb8= +google.golang.org/genproto/googleapis/api v0.0.0-20240814211410-ddb44dafa142/go.mod h1:d6be+8HhtEtucleCbxpPW9PA9XwISACu8nvpPqF0BVo= google.golang.org/genproto/googleapis/bytestream v0.0.0-20230530153820-e85fd2cbaebc/go.mod h1:ylj+BE99M198VPbBh6A8d9n3w8fChvyLK3wwBOjXBFA= google.golang.org/genproto/googleapis/rpc v0.0.0-20230525234015-3fc162c6f38a/go.mod h1:xURIpW9ES5+/GZhnV6beoEtxQrnkRGIfP5VQG2tCBLc= google.golang.org/genproto/googleapis/rpc v0.0.0-20230525234030-28d5490b6b19/go.mod h1:66JfowdXAEgad5O9NnYcsNPLCPZJD++2L9X0PCMODrA= @@ -2642,8 +2590,8 @@ google.golang.org/genproto/googleapis/rpc v0.0.0-20230803162519-f966b187b2e5/go. google.golang.org/genproto/googleapis/rpc v0.0.0-20240318140521-94a12d6c2237/go.mod h1:WtryC6hu0hhx87FDGxWCDptyssuo68sk10vYjF+T9fY= google.golang.org/genproto/googleapis/rpc v0.0.0-20240521202816-d264139d666e/go.mod h1:EfXuqaE1J41VCDicxHzUDm+8rk+7ZdXzHV0IhO/I6s0= google.golang.org/genproto/googleapis/rpc v0.0.0-20240528184218-531527333157/go.mod h1:EfXuqaE1J41VCDicxHzUDm+8rk+7ZdXzHV0IhO/I6s0= -google.golang.org/genproto/googleapis/rpc v0.0.0-20240903143218-8af14fe29dc1 h1:pPJltXNxVzT4pK9yD8vR9X75DaWYYmLGMsEvBfFQZzQ= -google.golang.org/genproto/googleapis/rpc v0.0.0-20240903143218-8af14fe29dc1/go.mod h1:UqMtugtsSgubUsoxbuAoiCXvqvErP7Gf0so0mK9tHxU= +google.golang.org/genproto/googleapis/rpc v0.0.0-20240814211410-ddb44dafa142 h1:e7S5W7MGGLaSu8j3YjdezkZ+m1/Nm0uRVRMEMGk26Xs= +google.golang.org/genproto/googleapis/rpc v0.0.0-20240814211410-ddb44dafa142/go.mod h1:UqMtugtsSgubUsoxbuAoiCXvqvErP7Gf0so0mK9tHxU= google.golang.org/grpc v1.65.0 h1:bs/cUb4lp1G5iImFFd3u5ixQzweKizoZJAwBNLR42lc= google.golang.org/grpc v1.65.0/go.mod h1:WgYC2ypjlB0EiQi6wdKixMqukr6lBc0Vo+oOgjrM5ZQ= google.golang.org/grpc/cmd/protoc-gen-go-grpc v1.1.0/go.mod h1:6Kw0yEErY5E/yWrBtf03jp27GLLJujG4z/JK95pnjjw= @@ -2668,8 +2616,8 @@ google.golang.org/protobuf v1.31.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqw google.golang.org/protobuf v1.32.0/go.mod h1:c6P6GXX6sHbq/GpV6MGZEdwhWPcYBgnhAHhKbcUYpos= google.golang.org/protobuf v1.33.0/go.mod h1:c6P6GXX6sHbq/GpV6MGZEdwhWPcYBgnhAHhKbcUYpos= google.golang.org/protobuf v1.34.1/go.mod h1:c6P6GXX6sHbq/GpV6MGZEdwhWPcYBgnhAHhKbcUYpos= -google.golang.org/protobuf v1.34.2 h1:6xV6lTsCfpGD21XK49h7MhtcApnLqkfYgPcdHftf6hg= -google.golang.org/protobuf v1.34.2/go.mod h1:qYOHts0dSfpeUzUFpOMr/WGzszTmLH+DiWniOlNbLDw= +google.golang.org/protobuf v1.35.1 h1:m3LfL6/Ca+fqnjnlqQXNpFPABW1UD7mjh8KO2mKFytA= +google.golang.org/protobuf v1.35.1/go.mod h1:9fA7Ob0pmnwhb644+1+CVWFRbNajQ6iRojtC/QF5bRE= 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= diff --git a/proto/babylon/btccheckpoint/v1/btccheckpoint.proto b/proto/babylon/btccheckpoint/v1/btccheckpoint.proto index 70b3b5aeb..693991548 100644 --- a/proto/babylon/btccheckpoint/v1/btccheckpoint.proto +++ b/proto/babylon/btccheckpoint/v1/btccheckpoint.proto @@ -138,7 +138,7 @@ message BTCCheckpointInfo { // epoch number of this checkpoint uint64 epoch_number = 1; // btc height of the best submission of the epoch - uint64 best_submission_btc_block_height = 2; + uint32 best_submission_btc_block_height = 2; // hash of the btc block which determines checkpoint btc block height i.e. // youngest block of best submission bytes best_submission_btc_block_hash = 3 diff --git a/proto/babylon/btccheckpoint/v1/params.proto b/proto/babylon/btccheckpoint/v1/params.proto index 3315aa03d..a1af891d1 100644 --- a/proto/babylon/btccheckpoint/v1/params.proto +++ b/proto/babylon/btccheckpoint/v1/params.proto @@ -12,7 +12,7 @@ message Params { // btc_confirmation_depth is the confirmation depth in BTC. // A block is considered irreversible only when it is at least k-deep in BTC // (k in research paper) - uint64 btc_confirmation_depth = 1 + uint32 btc_confirmation_depth = 1 [ (gogoproto.moretags) = "yaml:\"btc_confirmation_depth\"" ]; // checkpoint_finalization_timeout is the maximum time window (measured in BTC @@ -21,7 +21,7 @@ message Params { // - being reported back to BBN // If a checkpoint has not been reported back within w BTC blocks, then BBN // has dishonest majority and is stalling checkpoints (w in research paper) - uint64 checkpoint_finalization_timeout = 2 + uint32 checkpoint_finalization_timeout = 2 [ (gogoproto.moretags) = "yaml:\"checkpoint_finalization_timeout\"" ]; // 4byte tag in hex format, required to be present in the OP_RETURN transaction diff --git a/proto/babylon/btccheckpoint/v1/query.proto b/proto/babylon/btccheckpoint/v1/query.proto index d7ee344ef..dd63f1ca6 100644 --- a/proto/babylon/btccheckpoint/v1/query.proto +++ b/proto/babylon/btccheckpoint/v1/query.proto @@ -92,7 +92,7 @@ message BTCCheckpointInfoResponse { // EpochNumber of this checkpoint. uint64 epoch_number = 1; // btc height of the best submission of the epoch - uint64 best_submission_btc_block_height = 2; + uint32 best_submission_btc_block_height = 2; // hash of the btc block which determines checkpoint btc block height i.e. // youngest block of best submission Hexadecimal string best_submission_btc_block_hash = 3; diff --git a/proto/babylon/btccheckpoint/v1/tx.proto b/proto/babylon/btccheckpoint/v1/tx.proto index 9664ea79c..dcb72d65e 100644 --- a/proto/babylon/btccheckpoint/v1/tx.proto +++ b/proto/babylon/btccheckpoint/v1/tx.proto @@ -21,7 +21,7 @@ service Msg { rpc UpdateParams(MsgUpdateParams) returns (MsgUpdateParamsResponse); } -// MsgInsertBTCSpvProof defines resquest to insert a new checkpoint into the +// MsgInsertBTCSpvProof defines request to insert a new checkpoint into the // store message MsgInsertBTCSpvProof { option (cosmos.msg.v1.signer) = "submitter"; diff --git a/proto/babylon/btclightclient/v1/btclightclient.proto b/proto/babylon/btclightclient/v1/btclightclient.proto index d38314f3d..395e26027 100644 --- a/proto/babylon/btclightclient/v1/btclightclient.proto +++ b/proto/babylon/btclightclient/v1/btclightclient.proto @@ -20,7 +20,7 @@ message BTCHeaderInfo { bytes hash = 2 [ (gogoproto.customtype) = "github.com/babylonlabs-io/babylon/types.BTCHeaderHashBytes" ]; - uint64 height = 3; + uint32 height = 3; bytes work = 4 [ (gogoproto.customtype) = "cosmossdk.io/math.Uint" ]; } diff --git a/proto/babylon/btclightclient/v1/query.proto b/proto/babylon/btclightclient/v1/query.proto index 51ea46cf1..50cdead4e 100644 --- a/proto/babylon/btclightclient/v1/query.proto +++ b/proto/babylon/btclightclient/v1/query.proto @@ -133,7 +133,7 @@ message QueryHeaderDepthRequest { string hash = 1; } // QueryMainChainDepthResponse is the response type for the Query/MainChainDepth RPC // it contains depth of the block in main chain -message QueryHeaderDepthResponse { uint64 depth = 1; } +message QueryHeaderDepthResponse { uint32 depth = 1; } // BTCHeaderInfoResponse is a structure that contains all relevant information about a // BTC header response @@ -146,7 +146,7 @@ message QueryHeaderDepthResponse { uint64 depth = 1; } message BTCHeaderInfoResponse { string header_hex = 1; string hash_hex = 2; - uint64 height = 3; + uint32 height = 3; // Work is the sdkmath.Uint as string. string work = 4 [ (cosmos_proto.scalar) = "cosmos.Uint", diff --git a/proto/babylon/btcstaking/v1/btcstaking.proto b/proto/babylon/btcstaking/v1/btcstaking.proto index 0d451f0fb..b1afc5e0c 100644 --- a/proto/babylon/btcstaking/v1/btcstaking.proto +++ b/proto/babylon/btcstaking/v1/btcstaking.proto @@ -5,6 +5,7 @@ import "gogoproto/gogo.proto"; import "cosmos_proto/cosmos.proto"; import "cosmos/staking/v1beta1/staking.proto"; import "babylon/btcstaking/v1/pop.proto"; +import "babylon/btccheckpoint/v1/btccheckpoint.proto"; option go_package = "github.com/babylonlabs-io/babylon/x/btcstaking/types"; @@ -32,7 +33,7 @@ message FinalityProvider { // slashed_btc_height indicates the BTC height when // the finality provider is slashed. // if it's 0 then the finality provider is not slashed - uint64 slashed_btc_height = 7; + uint32 slashed_btc_height = 7; // jailed defines whether the finality provider is jailed bool jailed = 8; // consumer_id is the ID of the consumer the finality provider is operating on. @@ -56,7 +57,7 @@ message FinalityProviderWithMeta { // slashed_btc_height indicates the BTC height when // the finality provider is slashed. // if it's 0 then the finality provider is not slashed - uint64 slashed_btc_height = 5; + uint32 slashed_btc_height = 5; // jailed defines whether the finality provider is detected jailed bool jailed = 6; } @@ -75,38 +76,50 @@ message BTCDelegation { // If there is more than 1 PKs, then this means the delegation is restaked // to multiple finality providers repeated bytes fp_btc_pk_list = 4 [ (gogoproto.customtype) = "github.com/babylonlabs-io/babylon/types.BIP340PubKey" ]; + // staking_time is the number of blocks for which the delegation is locked on BTC chain + uint32 staking_time = 5; // start_height is the start BTC height of the BTC delegation // it is the start BTC height of the timelock - uint64 start_height = 5; + uint32 start_height = 6; // end_height is the end height of the BTC delegation - // it is the end BTC height of the timelock - w - uint64 end_height = 6; + // it is calculated by end_height = start_height + staking_time + uint32 end_height = 7; // total_sat is the total amount of BTC stakes in this delegation // quantified in satoshi - uint64 total_sat = 7; + uint64 total_sat = 8; // staking_tx is the staking tx - bytes staking_tx = 8; + bytes staking_tx = 9; // staking_output_idx is the index of the staking output in the staking tx - uint32 staking_output_idx = 9; + uint32 staking_output_idx = 10; // slashing_tx is the slashing tx // It is partially signed by SK corresponding to btc_pk, but not signed by // finality provider or covenant yet. - bytes slashing_tx = 10 [ (gogoproto.customtype) = "BTCSlashingTx" ]; + bytes slashing_tx = 11 [ (gogoproto.customtype) = "BTCSlashingTx" ]; // delegator_sig is the signature on the slashing tx // by the delegator (i.e., SK corresponding to btc_pk). // It will be a part of the witness for the staking tx output. - bytes delegator_sig = 11 [ (gogoproto.customtype) = "github.com/babylonlabs-io/babylon/types.BIP340Signature" ]; + bytes delegator_sig = 12 [ (gogoproto.customtype) = "github.com/babylonlabs-io/babylon/types.BIP340Signature" ]; // covenant_sigs is a list of adaptor signatures on the slashing tx // by each covenant member // It will be a part of the witness for the staking tx output. - repeated CovenantAdaptorSignatures covenant_sigs = 12; + repeated CovenantAdaptorSignatures covenant_sigs = 13; // unbonding_time describes how long the funds will be locked either in unbonding output // or slashing change output - uint32 unbonding_time = 13; + uint32 unbonding_time = 14; // btc_undelegation is the information about the early unbonding path of the BTC delegation - BTCUndelegation btc_undelegation = 14; + BTCUndelegation btc_undelegation = 15; // version of the params used to validate the delegation - uint32 params_version = 15; + uint32 params_version = 16; +} + +// DelegatorUnbondingInfo contains the information about transaction which spent +// the staking output. It contains: +// - spend_stake_tx: the transaction which spent the staking output +message DelegatorUnbondingInfo { + // spend_stake_tx is the transaction which spent the staking output. It is + // filled only if spend_stake_tx is different than unbonding_tx registered + // on the Babylon chain. + bytes spend_stake_tx = 1; } // BTCUndelegation contains the information about the early unbonding path of the BTC delegation @@ -119,24 +132,21 @@ message BTCUndelegation { // It is partially signed by SK corresponding to btc_pk, but not signed by // finality provider or covenant yet. bytes slashing_tx = 2 [ (gogoproto.customtype) = "BTCSlashingTx" ]; - // delegator_unbonding_sig is the signature on the unbonding tx - // by the delegator (i.e., SK corresponding to btc_pk). - // It effectively proves that the delegator wants to unbond and thus - // Babylon will consider this BTC delegation unbonded. Delegator's BTC - // on Bitcoin will be unbonded after timelock - bytes delegator_unbonding_sig = 3 [ (gogoproto.customtype) = "github.com/babylonlabs-io/babylon/types.BIP340Signature" ]; // delegator_slashing_sig is the signature on the slashing tx // by the delegator (i.e., SK corresponding to btc_pk). // It will be a part of the witness for the unbonding tx output. - bytes delegator_slashing_sig = 4 [ (gogoproto.customtype) = "github.com/babylonlabs-io/babylon/types.BIP340Signature" ]; + bytes delegator_slashing_sig = 3 [ (gogoproto.customtype) = "github.com/babylonlabs-io/babylon/types.BIP340Signature" ]; // covenant_slashing_sigs is a list of adaptor signatures on the slashing tx // by each covenant member // It will be a part of the witness for the staking tx output. - repeated CovenantAdaptorSignatures covenant_slashing_sigs = 5; + repeated CovenantAdaptorSignatures covenant_slashing_sigs = 4; // covenant_unbonding_sig_list is the list of signatures on the unbonding tx // by covenant members // It must be provided after processing undelegate message by Babylon - repeated SignatureInfo covenant_unbonding_sig_list = 6; + repeated SignatureInfo covenant_unbonding_sig_list = 5; + // delegator_unbonding_info is the information about transaction which spent + // the staking output + DelegatorUnbondingInfo delegator_unbonding_info = 6; } // BTCDelegatorDelegations is a collection of BTC delegations from the same delegator. @@ -149,21 +159,30 @@ message BTCDelegatorDelegationIndex { repeated bytes staking_tx_hash_list = 1; } -// BTCDelegationStatus is the status of a delegation. The state transition path is -// PENDING -> ACTIVE -> UNBONDED with two possibilities: -// 1. the typical path when timelock of staking transaction expires. -// 2. the path when staker requests early undelegation through MsgBTCUndelegate message. +// BTCDelegationStatus is the status of a delegation. +// There are two possible valid state transition paths for a BTC delegation: +// - PENDING -> ACTIVE -> UNBONDED +// - PENDING -> VERIFIED -> ACTIVE -> UNBONDED +// and one invalid state transition path: +// - PENDING -> VERIFIED -> UNBONDED i.e the staker unbonded before +// activating delegation on Babylon chain. +// In valid transition paths, the delegation becomes UNBONDED when: +// - either the staking transaction timelock expires +// - or the staker requests early undelegation through MsgBTCUndelegate message. enum BTCDelegationStatus { - // PENDING defines a delegation that is waiting for covenant signatures to become active. + // PENDING defines a delegation that is waiting for covenant signatures. PENDING = 0; + // VERIFIED defines a delegation that has covenant signatures but is not yet + // included in the BTC chain. + VERIFIED = 1; // ACTIVE defines a delegation that has voting power - ACTIVE = 1; + ACTIVE = 2; // UNBONDED defines a delegation no longer has voting power: // - either reaching the end of staking transaction timelock // - or receiving unbonding tx with signatures from staker and covenant committee - UNBONDED = 2; + UNBONDED = 3; // ANY is any of the above status - ANY = 3; + ANY = 4; } // SignatureInfo is a BIP-340 signature together with its signer's BIP-340 PK @@ -198,4 +217,15 @@ message SelectiveSlashingEvidence { // the covenant adaptor/Schnorr signature pair. It is the consequence // of selective slashing. bytes recovered_fp_btc_sk = 3; - } +} + +// InclusionProof proves the existence of tx on BTC blockchain +// including +// - the position of the tx on BTC blockchain +// - the Merkle proof that this tx is on the above position +message InclusionProof { + // key is the position (txIdx, blockHash) of this tx on BTC blockchain + babylon.btccheckpoint.v1.TransactionKey key = 1; + // proof is the Merkle proof that this tx is included in the position in `key` + bytes proof = 2; +} diff --git a/proto/babylon/btcstaking/v1/events.proto b/proto/babylon/btcstaking/v1/events.proto index 2482e4411..882a39735 100644 --- a/proto/babylon/btcstaking/v1/events.proto +++ b/proto/babylon/btcstaking/v1/events.proto @@ -1,16 +1,56 @@ syntax = "proto3"; package babylon.btcstaking.v1; -import "babylon/btcstaking/v1/btcstaking.proto"; import "gogoproto/gogo.proto"; +import "cosmos/staking/v1beta1/staking.proto"; +import "babylon/btcstaking/v1/btcstaking.proto"; +import "cosmos_proto/cosmos.proto"; +import "amino/amino.proto"; option go_package = "github.com/babylonlabs-io/babylon/x/btcstaking/types"; -// EventNewFinalityProvider is the event emitted when a finality provider is created message EventNewFinalityProvider { FinalityProvider fp = 1; } +// EventFinalityProviderCreated is the event emitted when a finality provider is created +message EventFinalityProviderCreated { + // btc_pk_hex is the hex string of Bitcoin secp256k1 PK of this finality provider + string btc_pk_hex = 1 [(amino.dont_omitempty) = true]; + // addr is the babylon address to receive commission from delegations. + string addr = 2 [(amino.dont_omitempty) = true]; + // commission defines the commission rate of the finality provider in decimals. + string commission = 3 [(amino.dont_omitempty) = true]; + // moniker defines a human-readable name for the finality provider. + string moniker = 4; + // identity defines an optional identity signature (ex. UPort or Keybase). + string identity = 5; + // website defines an optional website link. + string website = 6; + // security_contact defines an optional email for security contact. + string security_contact = 7; + // details define other optional details. + string details = 8; +} + +// EventFinalityProviderEdited is the event emitted when a finality provider is edited +message EventFinalityProviderEdited { + // btc_pk_hex is the hex string of Bitcoin secp256k1 PK of this finality provider + string btc_pk_hex = 1 [(amino.dont_omitempty) = true]; + // commission defines the commission rate of the finality provider in decimals. + string commission = 2 [(amino.dont_omitempty) = true]; + // moniker defines a human-readable name for the finality provider. + string moniker = 3; + // identity defines an optional identity signature (ex. UPort or Keybase). + string identity = 4; + // website defines an optional website link. + string website = 5; + // security_contact defines an optional email for security contact. + string security_contact = 6; + // details define other optional details. + string details = 7; +} + // EventBTCDelegationStateUpdate is the event emitted when a BTC delegation's state is // updated. There are the following possible state transitions: // - non-existing -> pending, which happens upon `MsgCreateBTCDelegation` @@ -32,7 +72,7 @@ message EventSelectiveSlashing { SelectiveSlashingEvidence evidence = 1; } -// EventPowerDistUpdate is an event that affects voting power distirbution +// EventPowerDistUpdate is an event that affects voting power distribution // of BTC staking protocol message EventPowerDistUpdate { // EventSlashedFinalityProvider defines an event that a finality provider @@ -76,3 +116,143 @@ message EventPowerDistUpdate { EventSlashedBTCDelegation slashed_btc_delegation = 5; } } + +// A finality provider starts with status INACTIVE once registered. +// Possible status transitions are when: +// 1. it has accumulated sufficient delegations and has +// timestamped public randomness: +// INACTIVE -> ACTIVE +// 2. it is jailed due to downtime: +// ACTIVE -> JAILED +// 3. it is slashed due to double-sign: +// ACTIVE -> SLASHED +// 4. it is unjailed after a jailing period: +// JAILED -> INACTIVE/ACTIVE (depending on (1)) +// 5. it does not have sufficient delegations or does not +// have timestamped public randomness: +// ACTIVE -> INACTIVE. +// Note that it is impossible for a SLASHED finality provider to +// transition to other status +message EventFinalityProviderStatusChange { + // btc_pk is the BTC public key of the finality provider + string btc_pk = 1 [(amino.dont_omitempty) = true]; + // new_state is the status that the finality provider + // is transitioned to, following FinalityProviderStatus + string new_state = 2 [(amino.dont_omitempty) = true]; +} + +// FinalityProviderStatus is the status of a finality provider. +enum FinalityProviderStatus { + // FINALITY_PROVIDER_STATUS_INACTIVE defines a finality provider that does not have sufficient + // delegations or does not have timestamped public randomness. + FINALITY_PROVIDER_STATUS_INACTIVE = 0; + // FINALITY_PROVIDER_STATUS_ACTIVE defines a finality provider that have sufficient delegations + // and have timestamped public randomness. + FINALITY_PROVIDER_STATUS_ACTIVE = 1; + // FINALITY_PROVIDER_STATUS_JAILED defines a finality provider that is jailed due to downtime + FINALITY_PROVIDER_STATUS_JAILED = 2; + // FINALITY_PROVIDER_STATUS_SLASHED defines a finality provider that is slashed due to double-sign + FINALITY_PROVIDER_STATUS_SLASHED = 3; +} + +// EventBTCDelegationCreated is the event emitted when a BTC delegation is created +// on the Babylon chain +message EventBTCDelegationCreated { + // staking_tx_hex is the hex encoded staking tx + string staking_tx_hex = 1 [(amino.dont_omitempty) = true]; + // staking_output_index is the index of the staking output in the staking tx + string staking_output_index = 2 [(amino.dont_omitempty) = true]; + // version of the params used to validate the delegation + string params_version = 3 [(amino.dont_omitempty) = true]; + // finality_provider_btc_pks_hex is the list of hex str of Bitcoin secp256k1 PK of + // the finality providers that this BTC delegation delegates to + // the PK follows encoding in BIP-340 spec + repeated string finality_provider_btc_pks_hex = 4 [(amino.dont_omitempty) = true]; + // staker_btc_pk_hex is the hex str of Bitcoin secp256k1 PK of the staker that + // creates this BTC delegation the PK follows encoding in BIP-340 spec + string staker_btc_pk_hex = 5 [(amino.dont_omitempty) = true]; + // staking_time is the timelock of the staking tx specified in the BTC script + string staking_time = 6 [(amino.dont_omitempty) = true]; + // unbonding_time is the time is timelock on unbonding tx chosen by the staker + string unbonding_time = 7 [(amino.dont_omitempty) = true]; + // unbonding_tx is hex encoded bytes of the unsigned unbonding tx + string unbonding_tx = 8 [(amino.dont_omitempty) = true]; + // new_state of the BTC delegation + string new_state = 9 [(amino.dont_omitempty) = true]; +} + +// EventCovenantSignatureReceived is the event emitted when a covenant committee +// sends valid covenant signatures for a BTC delegation +message EventCovenantSignatureReceived{ + // staking_tx_hash is the hash of the staking identifing the BTC delegation + // that this covenant signature is for + string staking_tx_hash = 1 [(amino.dont_omitempty) = true]; + // covenant_btc_pk_hex is the hex str of Bitcoin secp256k1 PK of the + // covnenat committee that send the signature + string covenant_btc_pk_hex = 2 [(amino.dont_omitempty) = true]; + // covenant_unbonding_signature_hex is the hex str of the BIP340 Schnorr + // signature of the covenant committee on the unbonding tx + string covenant_unbonding_signature_hex = 3 [(amino.dont_omitempty) = true]; +} + +// EventCovenantQuorumReached is the event emitted quorum of covenant committee +// is reached for a BTC delegation +message EventCovenantQuorumReached { + // staking_tx_hash is the hash of the staking identifing the BTC delegation + // that this covenant signature is for + string staking_tx_hash = 1 [(amino.dont_omitempty) = true]; + // new_state of the BTC delegation + string new_state = 2 [(amino.dont_omitempty) = true]; +} + +// EventBTCDelegationInclusionProofReceived is the event emitted when a BTC delegation +// inclusion proof is received +message EventBTCDelegationInclusionProofReceived { + // staking_tx_hash is the hash of the staking tx. + // It uniquely identifies a BTC delegation + string staking_tx_hash = 1 [(amino.dont_omitempty) = true]; + // start_height is the start BTC height of the BTC delegation + // it is the start BTC height of the timelock + string start_height = 2 [(amino.dont_omitempty) = true]; + // end_height is the end height of the BTC delegation + // it is calculated by end_height = start_height + staking_time + string end_height = 3 [(amino.dont_omitempty) = true]; + // new_state of the BTC delegation + string new_state = 4 [(amino.dont_omitempty) = true]; +} + +// EventBTCDelgationUnbondedEarly is the event emitted when a BTC delegation +// is unbonded by staker sending unbonding tx to BTC +message EventBTCDelgationUnbondedEarly { + // staking_tx_hash is the hash of the staking tx. + // It uniquely identifies a BTC delegation + string staking_tx_hash = 1 [(amino.dont_omitempty) = true]; + // start_height is the start BTC height of the early unbonding + string start_height = 2 [(amino.dont_omitempty) = true]; + // new_state of the BTC delegation + string new_state = 3 [(amino.dont_omitempty) = true]; +} + +// EventBTCDelegationExpired is the event emitted when a BTC delegation +// is unbonded by expiration of the staking tx timelock +message EventBTCDelegationExpired { + // staking_tx_hash is the hash of the staking tx. + // It uniquely identifies a BTC delegation + string staking_tx_hash = 1 [(amino.dont_omitempty) = true]; + // new_state of the BTC delegation + string new_state = 2 [(amino.dont_omitempty) = true]; +} + +// EventUnexpectedUnbondingTx is the event emitted when an unbonding tx is +// is different that the one registered in the BTC delegation. +message EventUnexpectedUnbondingTx { + // staking_tx_hash uniquely identifies a BTC delegation being unbonded + string staking_tx_hash = 1 [(amino.dont_omitempty) = true]; + // spend_stake_tx_hash has of the transactin spending staking output + string spend_stake_tx_hash = 2 [(amino.dont_omitempty) = true]; + // spend_stake_tx_header_hash is the hash of the header of the block that + // includes the spend_stake_tx + string spend_stake_tx_header_hash = 3 [(amino.dont_omitempty) = true]; + // spend_stake_tx_block_index is the spend_stake_tx index in the block + uint32 spend_stake_tx_block_index = 4 [(amino.dont_omitempty) = true]; +} diff --git a/proto/babylon/btcstaking/v1/genesis.proto b/proto/babylon/btcstaking/v1/genesis.proto index 2e5d5966e..c87c54d75 100644 --- a/proto/babylon/btcstaking/v1/genesis.proto +++ b/proto/babylon/btcstaking/v1/genesis.proto @@ -4,7 +4,6 @@ package babylon.btcstaking.v1; import "gogoproto/gogo.proto"; import "babylon/btcstaking/v1/params.proto"; import "babylon/btcstaking/v1/btcstaking.proto"; -import "babylon/btcstaking/v1/incentive.proto"; import "babylon/btcstaking/v1/events.proto"; option go_package = "github.com/babylonlabs-io/babylon/x/btcstaking/types"; @@ -17,36 +16,12 @@ message GenesisState { repeated FinalityProvider finality_providers = 2; // btc_delegations all the btc delegations in the state. repeated BTCDelegation btc_delegations = 3; - // voting_powers the voting power of every finality provider at every block height. - repeated VotingPowerFP voting_powers = 4; // block_height_chains the block height of babylon and bitcoin. repeated BlockHeightBbnToBtc block_height_chains = 5; // btc_delegators contains all the btc delegators with the associated finality provider. repeated BTCDelegator btc_delegators = 6; // all the events and its indexes. repeated EventIndex events = 7; - // vp_dst_cache is the table of all providers voting power with the total at one specific block. - // TODO: remove this after not storing in the keeper store it anymore. - repeated VotingPowerDistCacheBlkHeight vp_dst_cache = 8; -} - -// VotingPowerFP contains the information about the voting power -// of an finality provider in a specific block height. -message VotingPowerFP { - // block_height is the height of the block the voting power was stored. - uint64 block_height = 1; - // fp_btc_pk the finality provider btc public key. - bytes fp_btc_pk = 2 [ (gogoproto.customtype) = "github.com/babylonlabs-io/babylon/types.BIP340PubKey" ]; - // voting_power is the power of the finality provider at this specific block height. - uint64 voting_power = 3; -} - -// VotingPowerDistCacheBlkHeight the total voting power of the finality providers at one specific block height -message VotingPowerDistCacheBlkHeight { - // block_height is the height of the block the voting power distribution cached was stored. - uint64 block_height = 1; - // vp_distribution the finality providers distribution cache at that height. - VotingPowerDistCache vp_distribution = 2; } // BlockHeightBbnToBtc stores the btc <-> bbn block. @@ -54,7 +29,7 @@ message BlockHeightBbnToBtc { // block_height_bbn is the height of the block in the babylon chain. uint64 block_height_bbn = 1; // block_height_btc is the height of the block in the BTC. - uint64 block_height_btc = 2; + uint32 block_height_btc = 2; } // BTCDelegator BTC delegator information with the associated finality provider. @@ -72,7 +47,7 @@ message EventIndex { // idx is the index the event was stored. uint64 idx = 1; // block_height_btc is the height of the block in the BTC chain. - uint64 block_height_btc = 2; + uint32 block_height_btc = 2; // event the event stored. EventPowerDistUpdate event = 3; } diff --git a/proto/babylon/btcstaking/v1/incentive.proto b/proto/babylon/btcstaking/v1/incentive.proto deleted file mode 100644 index 6f69a7fcf..000000000 --- a/proto/babylon/btcstaking/v1/incentive.proto +++ /dev/null @@ -1,58 +0,0 @@ -syntax = "proto3"; -package babylon.btcstaking.v1; - -import "gogoproto/gogo.proto"; -import "cosmos_proto/cosmos.proto"; - -option go_package = "github.com/babylonlabs-io/babylon/x/btcstaking/types"; - -// VotingPowerDistCache is the cache for voting power distribution of finality providers -// and their BTC delegations at a height -message VotingPowerDistCache { - option (gogoproto.goproto_getters) = false; - // total_voting_power is the total voting power of all the finality providers - // in the cache - uint64 total_voting_power = 1; - // finality_providers is a list of finality providers' voting power information - repeated FinalityProviderDistInfo finality_providers = 2; - // num_active_fps is the number of finality providers that have active BTC - // delegations as well as timestamped public randomness - uint32 num_active_fps = 3; -} - -// FinalityProviderDistInfo is the reward distribution of a finality provider and its BTC delegations -message FinalityProviderDistInfo { - // btc_pk is the Bitcoin secp256k1 PK of this finality provider - // the PK follows encoding in BIP-340 spec - bytes btc_pk = 1 [ (gogoproto.customtype) = "github.com/babylonlabs-io/babylon/types.BIP340PubKey" ]; - // addr is the address to receive commission from delegations. - string addr = 2 [(cosmos_proto.scalar) = "cosmos.AddressString"]; - // commission defines the commission rate of finality provider - string commission = 3 [ - (cosmos_proto.scalar) = "cosmos.Dec", - (gogoproto.customtype) = "cosmossdk.io/math.LegacyDec" - ]; - // total_voting_power is the total voting power of the finality provider - uint64 total_voting_power = 4; - // btc_dels is a list of BTC delegations' voting power information under this finality provider - repeated BTCDelDistInfo btc_dels = 5; - // is_timestamped indicates whether the finality provider - // has timestamped public randomness committed - bool is_timestamped = 6; - // is_jailed indicates whether the finality provider - // is jailed, if so, it should not be assigned voting power - bool is_jailed = 7; -} - -// BTCDelDistInfo contains the information related to reward distribution for a BTC delegation -message BTCDelDistInfo { - // btc_pk is the Bitcoin secp256k1 PK of this BTC delegation - // the PK follows encoding in BIP-340 spec - bytes btc_pk = 1 [ (gogoproto.customtype) = "github.com/babylonlabs-io/babylon/types.BIP340PubKey" ]; - // staker_addr is the address to receive rewards from BTC delegation. - string staker_addr = 2 [(cosmos_proto.scalar) = "cosmos.AddressString"]; - // staking_tx_hash is the staking tx hash of the BTC delegation - string staking_tx_hash = 3; - // voting_power is the voting power of the BTC delegation - uint64 voting_power = 4; -} diff --git a/proto/babylon/btcstaking/v1/packet.proto b/proto/babylon/btcstaking/v1/packet.proto index 286c1dbc3..ba492bf10 100644 --- a/proto/babylon/btcstaking/v1/packet.proto +++ b/proto/babylon/btcstaking/v1/packet.proto @@ -67,10 +67,10 @@ message ActiveBTCDelegation { repeated string fp_btc_pk_list = 2; // start_height is the start BTC height of the BTC delegation // it is the start BTC height of the timelock - uint64 start_height = 3; + uint32 start_height = 3; // end_height is the end height of the BTC delegation // it is the end BTC height of the timelock - w - uint64 end_height = 4; + uint32 end_height = 4; // total_sat is the total amount of BTC stakes in this delegation // quantified in satoshi uint64 total_sat = 5; @@ -144,6 +144,10 @@ message UnbondedBTCDelegation { // unbonding_tx_sig is the signature on the unbonding tx signed by the BTC delegator // It proves that the BTC delegator wants to unbond bytes unbonding_tx_sig = 2; + // stake_spending_tx is the stake spending tx + bytes stake_spending_tx = 3; + // proof is the inclusion proof for the stake spending tx + InclusionProof proof = 4; } // BTCStakingConsumerEvent defines the structure for storing BTC staking events diff --git a/proto/babylon/btcstaking/v1/params.proto b/proto/babylon/btcstaking/v1/params.proto index c857f3cc3..862a3756d 100644 --- a/proto/babylon/btcstaking/v1/params.proto +++ b/proto/babylon/btcstaking/v1/params.proto @@ -18,7 +18,7 @@ message Params { uint32 covenant_quorum = 2; // min_staking_value_sat is the minimum of satoshis locked in staking output int64 min_staking_value_sat = 3; - // max_staking_value_sat is the maxiumum of satoshis locked in staking output + // max_staking_value_sat is the maximum of satoshis locked in staking output int64 max_staking_value_sat = 4; // min_staking_time is the minimum lock time specified in staking output script uint32 min_staking_time_blocks = 5; @@ -53,8 +53,12 @@ message Params { (gogoproto.customtype) = "cosmossdk.io/math.LegacyDec", (gogoproto.nullable) = false ]; - // max_active_finality_providers is the maximum number of active finality providers in the BTC staking protocol - uint32 max_active_finality_providers = 13; + // base gas fee for delegation creation + uint64 delegation_creation_base_gas_fee = 13; + // allow_list_expiration_height is the height at which the allow list expires + // i.e all staking transactions are allowed to enter Babylon chain afterwards + // setting it to 0 means allow list is disabled + uint64 allow_list_expiration_height = 14; } // StoredParams attach information about the version of stored parameters diff --git a/proto/babylon/btcstaking/v1/query.proto b/proto/babylon/btcstaking/v1/query.proto index f2464f54b..896cf5b16 100644 --- a/proto/babylon/btcstaking/v1/query.proto +++ b/proto/babylon/btcstaking/v1/query.proto @@ -35,28 +35,7 @@ service Query { // BTCDelegations queries all BTC delegations under a given status rpc BTCDelegations(QueryBTCDelegationsRequest) returns (QueryBTCDelegationsResponse) { - option (google.api.http).get = "/babylon/btcstaking/v1/btc_delegations"; - } - - // ActiveFinalityProvidersAtHeight queries finality providers with non zero voting power at given height. - rpc ActiveFinalityProvidersAtHeight(QueryActiveFinalityProvidersAtHeightRequest) returns (QueryActiveFinalityProvidersAtHeightResponse) { - option (google.api.http).get = "/babylon/btcstaking/v1/finality_providers/{height}"; - } - - // FinalityProviderPowerAtHeight queries the voting power of a finality provider at a given height - rpc FinalityProviderPowerAtHeight(QueryFinalityProviderPowerAtHeightRequest) returns (QueryFinalityProviderPowerAtHeightResponse) { - option (google.api.http).get = "/babylon/btcstaking/v1/finality_providers/{fp_btc_pk_hex}/power/{height}"; - } - - // FinalityProviderCurrentPower queries the voting power of a finality provider at the current height - rpc FinalityProviderCurrentPower(QueryFinalityProviderCurrentPowerRequest) returns (QueryFinalityProviderCurrentPowerResponse) { - option (google.api.http).get = "/babylon/btcstaking/v1/finality_providers/{fp_btc_pk_hex}/power"; - } - - // ActivatedHeight queries the height when BTC staking protocol is activated, i.e., the first height when - // there exists 1 finality provider with voting power - rpc ActivatedHeight(QueryActivatedHeightRequest) returns (QueryActivatedHeightResponse) { - option (google.api.http).get = "/babylon/btcstaking/v1/activated_height"; + option (google.api.http).get = "/babylon/btcstaking/v1/btc_delegations/{status}"; } // FinalityProviderDelegations queries all BTC delegations of the given finality provider @@ -66,7 +45,7 @@ service Query { // BTCDelegation retrieves delegation by corresponding staking tx hash rpc BTCDelegation(QueryBTCDelegationRequest) returns (QueryBTCDelegationResponse) { - option (google.api.http).get = "/babylon/btcstaking/v1/btc_delegations/{staking_tx_hash_hex}"; + option (google.api.http).get = "/babylon/btcstaking/v1/btc_delegation/{staking_tx_hash_hex}"; } } @@ -140,71 +119,6 @@ message QueryBTCDelegationsResponse { cosmos.base.query.v1beta1.PageResponse pagination = 2; } -// QueryFinalityProviderPowerAtHeightRequest is the request type for the -// Query/FinalityProviderPowerAtHeight RPC method. -message QueryFinalityProviderPowerAtHeightRequest { - // fp_btc_pk_hex is the hex str of Bitcoin secp256k1 PK of the finality provider that - // this BTC delegation delegates to - // the PK follows encoding in BIP-340 spec - string fp_btc_pk_hex = 1; - - // height is used for querying the given finality provider's voting power at this height - uint64 height = 2; -} - -// QueryFinalityProviderPowerAtHeightResponse is the response type for the -// Query/FinalityProviderPowerAtHeight RPC method. -message QueryFinalityProviderPowerAtHeightResponse { - // voting_power is the voting power of the finality provider - uint64 voting_power = 1; -} - -// QueryFinalityProviderCurrentPowerRequest is the request type for the -// Query/FinalityProviderCurrentPower RPC method. -message QueryFinalityProviderCurrentPowerRequest { - // fp_btc_pk_hex is the hex str of Bitcoin secp256k1 PK of the finality provider that - // this BTC delegation delegates to - // the PK follows encoding in BIP-340 spec - string fp_btc_pk_hex = 1; -} - -// QueryFinalityProviderCurrentPowerResponse is the response type for the -// Query/FinalityProviderCurrentPower RPC method. -message QueryFinalityProviderCurrentPowerResponse { - // height is the current height - uint64 height = 1; - // voting_power is the voting power of the finality provider - uint64 voting_power = 2; -} - -// QueryActiveFinalityProvidersAtHeightRequest is the request type for the -// Query/ActiveFinalityProvidersAtHeight RPC method. -message QueryActiveFinalityProvidersAtHeightRequest { - // height defines at which Babylon height to query the finality providers info. - uint64 height = 1; - - // pagination defines an optional pagination for the request. - cosmos.base.query.v1beta1.PageRequest pagination = 2; -} - -// QueryActiveFinalityProvidersAtHeightResponse is the response type for the -// Query/ActiveFinalityProvidersAtHeight RPC method. -message QueryActiveFinalityProvidersAtHeightResponse { - // finality_providers contains all the queried finality providersn. - repeated FinalityProviderWithMeta finality_providers = 1; - - // pagination defines the pagination in the response. - cosmos.base.query.v1beta1.PageResponse pagination = 2; -} - -// QueryActivatedHeightRequest is the request type for the Query/ActivatedHeight RPC method. -message QueryActivatedHeightRequest {} - -// QueryActivatedHeightResponse is the response type for the Query/ActivatedHeight RPC method. -message QueryActivatedHeightResponse { - uint64 height = 1; -} - // QueryFinalityProviderDelegationsRequest is the request type for the // Query/FinalityProviderDelegations RPC method. message QueryFinalityProviderDelegationsRequest { @@ -251,40 +165,50 @@ message BTCDelegationResponse { // fp_btc_pk_list is the list of BIP-340 PKs of the finality providers that // this BTC delegation delegates to repeated bytes fp_btc_pk_list = 3 [ (gogoproto.customtype) = "github.com/babylonlabs-io/babylon/types.BIP340PubKey" ]; + // staking_time is the number of blocks for which the delegation is locked on BTC chain + uint32 staking_time = 4; // start_height is the start BTC height of the BTC delegation // it is the start BTC height of the timelock - uint64 start_height = 4; + uint32 start_height = 5; // end_height is the end height of the BTC delegation // it is the end BTC height of the timelock - w - uint64 end_height = 5; + uint32 end_height = 6; // total_sat is the total amount of BTC stakes in this delegation // quantified in satoshi - uint64 total_sat = 6; + uint64 total_sat = 7; // staking_tx_hex is the hex string of staking tx - string staking_tx_hex = 7; + string staking_tx_hex = 8; // slashing_tx_hex is the hex string of slashing tx - string slashing_tx_hex = 8; + string slashing_tx_hex = 9; // delegator_slash_sig_hex is the signature on the slashing tx // by the delegator (i.e., SK corresponding to btc_pk) as string hex. // It will be a part of the witness for the staking tx output. - string delegator_slash_sig_hex = 9; + string delegator_slash_sig_hex = 10; // covenant_sigs is a list of adaptor signatures on the slashing tx // by each covenant member // It will be a part of the witness for the staking tx output. - repeated CovenantAdaptorSignatures covenant_sigs = 10; + repeated CovenantAdaptorSignatures covenant_sigs = 11; // staking_output_idx is the index of the staking output in the staking tx - uint32 staking_output_idx = 11; + uint32 staking_output_idx = 12; // whether this delegation is active - bool active = 12; + bool active = 13; // descriptive status of current delegation. - string status_desc = 13; + string status_desc = 14; // unbonding_time used in unbonding output timelock path and in slashing transactions // change outputs - uint32 unbonding_time = 14; + uint32 unbonding_time = 15; // undelegation_response is the undelegation info of this delegation. - BTCUndelegationResponse undelegation_response = 15; + BTCUndelegationResponse undelegation_response = 16; // params version used to validate delegation - uint32 params_version = 16; + uint32 params_version = 17; +} + +// DelegatorUnbondingInfoResponse provides all necessary info about transaction +// which spent the staking output +message DelegatorUnbondingInfoResponse { + // spend_stake_tx_hex is the transaction which spent the staking output. It is + // filled only if the spend_stake_tx_hex is different than the unbonding_tx_hex + string spend_stake_tx_hex = 1; } // BTCUndelegationResponse provides all necessary info about the undeleagation @@ -293,26 +217,23 @@ message BTCUndelegationResponse { // output to unbonding output. Unbonding output will usually have lower timelock // than staking output. The unbonding tx as string hex. string unbonding_tx_hex = 1; - // delegator_unbonding_sig is the signature on the unbonding tx - // by the delegator (i.e., SK corresponding to btc_pk). - // It effectively proves that the delegator wants to unbond and thus - // Babylon will consider this BTC delegation unbonded. Delegator's BTC - // on Bitcoin will be unbonded after timelock. The unbonding delegator sig as string hex. - string delegator_unbonding_sig_hex = 2; // covenant_unbonding_sig_list is the list of signatures on the unbonding tx // by covenant members - repeated SignatureInfo covenant_unbonding_sig_list = 3; + repeated SignatureInfo covenant_unbonding_sig_list = 2; // slashingTxHex is the hex string of slashing tx - string slashing_tx_hex = 4; + string slashing_tx_hex = 3; // delegator_slashing_sig is the signature on the slashing tx // by the delegator (i.e., SK corresponding to btc_pk). // It will be a part of the witness for the unbonding tx output. // The delegator slashing sig as string hex. - string delegator_slashing_sig_hex = 5; + string delegator_slashing_sig_hex = 4; // covenant_slashing_sigs is a list of adaptor signatures on the // unbonding slashing tx by each covenant member // It will be a part of the witness for the staking tx output. - repeated CovenantAdaptorSignatures covenant_slashing_sigs = 6; + repeated CovenantAdaptorSignatures covenant_slashing_sigs = 5; + // btc_undelegation_info contains all necessary info about the transaction + // which spent the staking output + DelegatorUnbondingInfoResponse delegator_unbonding_info_response = 6; } // BTCDelegatorDelegationsResponse is a collection of BTC delegations responses from the same delegator. @@ -344,11 +265,9 @@ message FinalityProviderResponse { // slashed_btc_height indicates the BTC height when // the finality provider is slashed. // if it's 0 then the finality provider is not slashed - uint64 slashed_btc_height = 7; + uint32 slashed_btc_height = 7; // height is the queried Babylon height uint64 height = 8; - // voting_power is the voting power of this finality provider at the given height - uint64 voting_power = 9; // jailed defines whether the finality provider is jailed - bool jailed = 10; + bool jailed = 9; } diff --git a/proto/babylon/btcstaking/v1/tx.proto b/proto/babylon/btcstaking/v1/tx.proto index 3d1621f4a..f76362568 100644 --- a/proto/babylon/btcstaking/v1/tx.proto +++ b/proto/babylon/btcstaking/v1/tx.proto @@ -5,9 +5,9 @@ import "gogoproto/gogo.proto"; import "cosmos_proto/cosmos.proto"; import "cosmos/msg/v1/msg.proto"; import "babylon/btcstaking/v1/params.proto"; -import "babylon/btccheckpoint/v1/btccheckpoint.proto"; import "cosmos/staking/v1beta1/staking.proto"; import "babylon/btcstaking/v1/pop.proto"; +import "babylon/btcstaking/v1/btcstaking.proto"; option go_package = "github.com/babylonlabs-io/babylon/x/btcstaking/types"; @@ -22,6 +22,8 @@ service Msg { rpc EditFinalityProvider(MsgEditFinalityProvider) returns (MsgEditFinalityProviderResponse); // CreateBTCDelegation creates a new BTC delegation rpc CreateBTCDelegation(MsgCreateBTCDelegation) returns (MsgCreateBTCDelegationResponse); + // AddBTCDelegationInclusionProof adds inclusion proof of a given delegation on BTC chain + rpc AddBTCDelegationInclusionProof(MsgAddBTCDelegationInclusionProof) returns (MsgAddBTCDelegationInclusionProofResponse); // AddCovenantSigs handles signatures from a covenant member rpc AddCovenantSigs(MsgAddCovenantSigs) returns (MsgAddCovenantSigsResponse); // BTCUndelegate handles a signature on unbonding tx from its delegator @@ -93,38 +95,54 @@ message MsgCreateBTCDelegation { uint32 staking_time = 5; // staking_value is the amount of satoshis locked in staking output int64 staking_value = 6; - // staking_tx is the staking tx along with the merkle proof of inclusion in btc block - babylon.btccheckpoint.v1.TransactionInfo staking_tx = 7; + // staking_tx is a bitcoin staking transaction i.e transaction that locks funds + bytes staking_tx = 7 ; + // staking_tx_inclusion_proof is the inclusion proof of the staking tx in BTC chain + InclusionProof staking_tx_inclusion_proof = 8; // slashing_tx is the slashing tx // Note that the tx itself does not contain signatures, which are off-chain. - bytes slashing_tx = 8 [ (gogoproto.customtype) = "BTCSlashingTx" ]; + bytes slashing_tx = 9 [ (gogoproto.customtype) = "BTCSlashingTx" ]; // delegator_slashing_sig is the signature on the slashing tx by the delegator (i.e., SK corresponding to btc_pk). // It will be a part of the witness for the staking tx output. // The staking tx output further needs signatures from covenant and finality provider in // order to be spendable. - bytes delegator_slashing_sig = 9 [ (gogoproto.customtype) = "github.com/babylonlabs-io/babylon/types.BIP340Signature" ]; + bytes delegator_slashing_sig = 10 [ (gogoproto.customtype) = "github.com/babylonlabs-io/babylon/types.BIP340Signature" ]; // unbonding_time is the time lock used when funds are being unbonded. It is be used in: // - unbonding transaction, time lock spending path // - staking slashing transaction, change output // - unbonding slashing transaction, change output // It must be smaller than math.MaxUInt16 and larger that max(MinUnbondingTime, CheckpointFinalizationTimeout) - uint32 unbonding_time = 10; + uint32 unbonding_time = 11; // fields related to unbonding transaction // unbonding_tx is a bitcoin unbonding transaction i.e transaction that spends // staking output and sends it to the unbonding output - bytes unbonding_tx = 11; + bytes unbonding_tx = 12; // unbonding_value is amount of satoshis locked in unbonding output. // NOTE: staking_value and unbonding_value could be different because of the difference between the fee for staking tx and that for unbonding - int64 unbonding_value = 12; + int64 unbonding_value = 13; // unbonding_slashing_tx is the slashing tx which slash unbonding contract // Note that the tx itself does not contain signatures, which are off-chain. - bytes unbonding_slashing_tx = 13 [ (gogoproto.customtype) = "BTCSlashingTx" ]; + bytes unbonding_slashing_tx = 14 [ (gogoproto.customtype) = "BTCSlashingTx" ]; // delegator_unbonding_slashing_sig is the signature on the slashing tx by the delegator (i.e., SK corresponding to btc_pk). - bytes delegator_unbonding_slashing_sig = 14 [ (gogoproto.customtype) = "github.com/babylonlabs-io/babylon/types.BIP340Signature" ]; + bytes delegator_unbonding_slashing_sig = 15 [ (gogoproto.customtype) = "github.com/babylonlabs-io/babylon/types.BIP340Signature" ]; } // MsgCreateBTCDelegationResponse is the response for MsgCreateBTCDelegation message MsgCreateBTCDelegationResponse {} +// MsgAddBTCDelegationInclusionProof is the message for adding proof of inclusion of BTC delegation on BTC chain +message MsgAddBTCDelegationInclusionProof { + option (cosmos.msg.v1.signer) = "signer"; + + string signer = 1; + // staking_tx_hash is the hash of the staking tx. + // It uniquely identifies a BTC delegation + string staking_tx_hash = 2; + // staking_tx_inclusion_proof is the inclusion proof of the staking tx in BTC chain + InclusionProof staking_tx_inclusion_proof = 3; +} +// MsgAddBTCDelegationInclusionProofResponse is the response for MsgAddBTCDelegationInclusionProof +message MsgAddBTCDelegationInclusionProofResponse {} + // MsgAddCovenantSigs is the message for handling signatures from a covenant member message MsgAddCovenantSigs { option (cosmos.msg.v1.signer) = "signer"; @@ -161,9 +179,12 @@ message MsgBTCUndelegate { // staking_tx_hash is the hash of the staking tx. // It uniquely identifies a BTC delegation string staking_tx_hash = 2; - // unbonding_tx_sig is the signature of the staker on the unbonding tx submitted to babylon - // the signature follows encoding in BIP-340 spec - bytes unbonding_tx_sig = 3 [ (gogoproto.customtype) = "github.com/babylonlabs-io/babylon/types.BIP340Signature" ]; + // stake_spending_tx is a bitcoin transaction that spends the staking transaction + // i.e it has staking output as an input + bytes stake_spending_tx = 3; + // spend_spending_tx_inclusion_proof is the proof of inclusion of the + // stake_spending_tx in the BTC chain + InclusionProof stake_spending_tx_inclusion_proof = 4; } // MsgBTCUndelegateResponse is the response for MsgBTCUndelegate message MsgBTCUndelegateResponse {} diff --git a/proto/babylon/btcstkconsumer/v1/query.proto b/proto/babylon/btcstkconsumer/v1/query.proto index 3ababf823..d932d9819 100644 --- a/proto/babylon/btcstkconsumer/v1/query.proto +++ b/proto/babylon/btcstkconsumer/v1/query.proto @@ -134,7 +134,7 @@ message FinalityProviderResponse { // slashed_btc_height indicates the BTC height when // the finality provider is slashed. // if it's 0 then the finality provider is not slashed - uint64 slashed_btc_height = 7; + uint32 slashed_btc_height = 7; // height is the queried Babylon height uint64 height = 8; // voting_power is the voting power of this finality provider at the given height diff --git a/proto/babylon/checkpointing/v1/checkpoint.proto b/proto/babylon/checkpointing/v1/checkpoint.proto index 309447a7a..2afe6e991 100644 --- a/proto/babylon/checkpointing/v1/checkpoint.proto +++ b/proto/babylon/checkpointing/v1/checkpoint.proto @@ -44,8 +44,10 @@ message RawCheckpointWithMeta { repeated CheckpointStateUpdate lifecycle = 5; } -// InjectedCheckpoint wraps the checkpoint and the extended votes -message InjectedCheckpoint { +// MsgInjectedCheckpoint wraps the checkpoint and the extended votes +// Note: this is a special message type that is only for internal ABCI++ usage +// for inserting checkpoint into the block +message MsgInjectedCheckpoint { RawCheckpointWithMeta ckpt = 1; // extended_commit_info is the commit info including the vote extensions // from the previous proposal diff --git a/proto/babylon/checkpointing/v1/query.proto b/proto/babylon/checkpointing/v1/query.proto index 74c9853f7..84e72fe30 100644 --- a/proto/babylon/checkpointing/v1/query.proto +++ b/proto/babylon/checkpointing/v1/query.proto @@ -122,10 +122,21 @@ message QueryBlsPublicKeyListRequest { cosmos.base.query.v1beta1.PageRequest pagination = 2; } +// BlsPublicKeyListResponse couples validator address, voting power, and its bls +// public key +message BlsPublicKeyListResponse { + // validator_address is the address of the validator + string validator_address = 1; + // bls_pub_key is the BLS public key of the validator + string bls_pub_key_hex = 2; + // voting_power is the voting power of the validator at the given epoch + uint64 voting_power = 3; +} + // QueryBlsPublicKeyListResponse is the response type for the // Query/BlsPublicKeys RPC method. message QueryBlsPublicKeyListResponse { - repeated ValidatorWithBlsKey validator_with_bls_keys = 1; + repeated BlsPublicKeyListResponse validator_with_bls_keys = 1; // pagination defines the pagination in the response. cosmos.base.query.v1beta1.PageResponse pagination = 2; @@ -185,7 +196,7 @@ message RawCheckpointResponse { message CheckpointStateUpdateResponse { // state defines the event of a state transition towards this state CheckpointStatus state = 1; - // status_desc respresents the description of status enum. + // status_desc represents the description of status enum. string status_desc = 2; // block_height is the height of the Babylon block that triggers the state // update @@ -200,7 +211,7 @@ message RawCheckpointWithMetaResponse { RawCheckpointResponse ckpt = 1; // status defines the status of the checkpoint CheckpointStatus status = 2; - // status_desc respresents the description of status enum. + // status_desc represents the description of status enum. string status_desc = 3; // bls_aggr_pk defines the aggregated BLS public key bytes bls_aggr_pk = 4 diff --git a/proto/babylon/finality/v1/finality.proto b/proto/babylon/finality/v1/finality.proto index 87216e454..21f67f837 100644 --- a/proto/babylon/finality/v1/finality.proto +++ b/proto/babylon/finality/v1/finality.proto @@ -3,10 +3,66 @@ package babylon.finality.v1; option go_package = "github.com/babylonlabs-io/babylon/x/finality/types"; +import "cosmos_proto/cosmos.proto"; import "gogoproto/gogo.proto"; import "amino/amino.proto"; import "google/protobuf/timestamp.proto"; +// VotingPowerDistCache is the cache for voting power distribution of finality providers +// and their BTC delegations at a height +message VotingPowerDistCache { + option (gogoproto.goproto_getters) = false; + // total_voting_power is the total voting power of all (active) finality providers + // in the cache + uint64 total_voting_power = 1; + // finality_providers is a list of finality providers' voting power information + repeated FinalityProviderDistInfo finality_providers = 2; + // num_active_fps is the number of finality providers that have active BTC + // delegations as well as timestamped public randomness + uint32 num_active_fps = 3; +} + +// FinalityProviderDistInfo is the reward distribution of a finality provider and its BTC delegations +message FinalityProviderDistInfo { + // btc_pk is the Bitcoin secp256k1 PK of this finality provider + // the PK follows encoding in BIP-340 spec + bytes btc_pk = 1 [ (gogoproto.customtype) = "github.com/babylonlabs-io/babylon/types.BIP340PubKey" ]; + // addr is the bytes of the address to receive commission from delegations. + bytes addr = 2; + // commission defines the commission rate of finality provider + string commission = 3 [ + (cosmos_proto.scalar) = "cosmos.Dec", + (gogoproto.customtype) = "cosmossdk.io/math.LegacyDec" + ]; + // total_bonded_sat is the total amount of bonded BTC stake (in Satoshi) of the finality provider + uint64 total_bonded_sat = 4; + // btc_dels is a list of BTC delegations' voting power information under this finality provider + repeated BTCDelDistInfo btc_dels = 5; + // is_timestamped indicates whether the finality provider + // has timestamped public randomness committed + // if no, it should not be assigned voting power + bool is_timestamped = 6; + // is_jailed indicates whether the finality provider + // is jailed, if so, it should not be assigned voting power + bool is_jailed = 7; + // is_slashed indicates whether the finality provider + // is slashed, if so, it should not be assigned voting power + bool is_slashed = 8; +} + +// BTCDelDistInfo contains the information related to voting power distribution for a BTC delegation +message BTCDelDistInfo { + // btc_pk is the Bitcoin secp256k1 PK of this BTC delegation + // the PK follows encoding in BIP-340 spec + bytes btc_pk = 1 [ (gogoproto.customtype) = "github.com/babylonlabs-io/babylon/types.BIP340PubKey" ]; + // staker_addr is the address to receive rewards from BTC delegation. + string staker_addr = 2 [(cosmos_proto.scalar) = "cosmos.AddressString"]; + // staking_tx_hash is the staking tx hash of the BTC delegation + string staking_tx_hash = 3; + // total_sat is the amount of BTC stake (in Satoshi) of the BTC delegation + uint64 total_sat = 4; +} + // IndexedBlock is the necessary metadata and finalization status of a block message IndexedBlock { // height is the height of the block diff --git a/proto/babylon/finality/v1/genesis.proto b/proto/babylon/finality/v1/genesis.proto index 4e40c9bd0..553684fad 100644 --- a/proto/babylon/finality/v1/genesis.proto +++ b/proto/babylon/finality/v1/genesis.proto @@ -17,9 +17,9 @@ message GenesisState { repeated Evidence evidences = 3; // votes_sigs contains all the votes of finality providers ever registered. repeated VoteSig vote_sigs = 4; - // public_randomness contains all the public randomness ever commited from the finality providers. + // public_randomness contains all the public randomness ever committed from the finality providers. repeated PublicRandomness public_randomness = 5; - // pub_rand_commit contains all the public randomness commitment ever commited from the finality providers. + // pub_rand_commit contains all the public randomness commitment ever committed from the finality providers. repeated PubRandCommitWithPK pub_rand_commit = 6; // signing_infos represents a map between finality provider public key and their // signing infos. @@ -27,6 +27,10 @@ message GenesisState { // missed_blocks represents a map between finality provider public key and their // missed blocks. repeated FinalityProviderMissedBlocks missed_blocks = 8 [(gogoproto.nullable) = false]; + // voting_powers the voting power of every finality provider at every block height. + repeated VotingPowerFP voting_powers = 9; + // vp_dst_cache is the table of all providers voting power with the total at one specific block. + repeated VotingPowerDistCacheBlkHeight vp_dst_cache = 10; } // VoteSig the vote of an finality provider @@ -43,7 +47,7 @@ message VoteSig { // PublicRandomness the block height and public randomness that the finality provider has submitted. message PublicRandomness { - // block_height is the height of block which the finality provider submited public randomness. + // block_height is the height of block which the finality provider submitted public randomness. uint64 block_height = 1; // fp_btc_pk is the BTC PK of the finality provider that casts this vote. bytes fp_btc_pk = 2 [ (gogoproto.customtype) = "github.com/babylonlabs-io/babylon/types.BIP340PubKey" ]; @@ -83,3 +87,22 @@ message MissedBlock { // missed is the missed status. bool missed = 2; } + +// VotingPowerFP contains the information about the voting power +// of an finality provider in a specific block height. +message VotingPowerFP { + // block_height is the height of the block the voting power was stored. + uint64 block_height = 1; + // fp_btc_pk the finality provider btc public key. + bytes fp_btc_pk = 2 [ (gogoproto.customtype) = "github.com/babylonlabs-io/babylon/types.BIP340PubKey" ]; + // voting_power is the power of the finality provider at this specific block height. + uint64 voting_power = 3; +} + +// VotingPowerDistCacheBlkHeight the total voting power of the finality providers at one specific block height +message VotingPowerDistCacheBlkHeight { + // block_height is the height of the block the voting power distribution cached was stored. + uint64 block_height = 1; + // vp_distribution the finality providers distribution cache at that height. + VotingPowerDistCache vp_distribution = 2; +} diff --git a/proto/babylon/finality/v1/params.proto b/proto/babylon/finality/v1/params.proto index 711626486..74502aa49 100644 --- a/proto/babylon/finality/v1/params.proto +++ b/proto/babylon/finality/v1/params.proto @@ -11,14 +11,17 @@ option go_package = "github.com/babylonlabs-io/babylon/x/finality/types"; // Params defines the parameters for the module. message Params { option (gogoproto.goproto_stringer) = false; + + // max_active_finality_providers is the maximum number of active finality providers in the BTC staking protocol + uint32 max_active_finality_providers = 1; // signed_blocks_window defines the size of the sliding window for tracking finality provider liveness - int64 signed_blocks_window = 1; + int64 signed_blocks_window = 2; // finality_sig_timeout defines how much time (in terms of blocks) finality providers have to cast a finality // vote before being judged as missing their voting turn on the given block - int64 finality_sig_timeout = 2; + int64 finality_sig_timeout = 3; // min_signed_per_window defines the minimum number of blocks that a finality provider is required to sign // within the sliding window to avoid being jailed - bytes min_signed_per_window = 3 [ + bytes min_signed_per_window = 4 [ (cosmos_proto.scalar) = "cosmos.Dec", (gogoproto.customtype) = "cosmossdk.io/math.LegacyDec", (gogoproto.nullable) = false, @@ -26,8 +29,12 @@ message Params { ]; // min_pub_rand is the minimum number of public randomness each // message should commit - uint64 min_pub_rand = 4; + uint64 min_pub_rand = 5; // jail_duration is the minimum period of time that a finality provider remains jailed - google.protobuf.Duration jail_duration = 5 + google.protobuf.Duration jail_duration = 6 [(gogoproto.nullable) = false, (amino.dont_omitempty) = true, (gogoproto.stdduration) = true]; + // finality_activation_height is the babylon block height which the finality module will + // start to accept finality voting and the minimum allowed value for the public randomness + // commit start height. + uint64 finality_activation_height = 7; } diff --git a/proto/babylon/finality/v1/query.proto b/proto/babylon/finality/v1/query.proto index 159995a69..6030febe4 100644 --- a/proto/babylon/finality/v1/query.proto +++ b/proto/babylon/finality/v1/query.proto @@ -6,6 +6,8 @@ import "google/api/annotations.proto"; import "cosmos/base/query/v1beta1/pagination.proto"; import "babylon/finality/v1/params.proto"; import "babylon/finality/v1/finality.proto"; +import "google/protobuf/timestamp.proto"; +import "amino/amino.proto"; option go_package = "github.com/babylonlabs-io/babylon/x/finality/types"; @@ -16,11 +18,31 @@ service Query { option (google.api.http).get = "/babylon/finality/v1/params"; } + // ActiveFinalityProvidersAtHeight queries finality providers with non zero voting power at given height. + rpc ActiveFinalityProvidersAtHeight(QueryActiveFinalityProvidersAtHeightRequest) returns (QueryActiveFinalityProvidersAtHeightResponse) { + option (google.api.http).get = "/babylon/finality/v1/finality_providers/{height}"; + } + + // FinalityProviderPowerAtHeight queries the voting power of a finality provider at a given height + rpc FinalityProviderPowerAtHeight(QueryFinalityProviderPowerAtHeightRequest) returns (QueryFinalityProviderPowerAtHeightResponse) { + option (google.api.http).get = "/babylon/finality/v1/finality_providers/{fp_btc_pk_hex}/power/{height}"; + } + + // FinalityProviderCurrentPower queries the voting power of a finality provider at the current height + rpc FinalityProviderCurrentPower(QueryFinalityProviderCurrentPowerRequest) returns (QueryFinalityProviderCurrentPowerResponse) { + option (google.api.http).get = "/babylon/finality/v1/finality_providers/{fp_btc_pk_hex}/power"; + } + + // ActivatedHeight queries the height when BTC staking protocol is activated, i.e., the first height when + // there exists 1 finality provider with voting power + rpc ActivatedHeight(QueryActivatedHeightRequest) returns (QueryActivatedHeightResponse) { + option (google.api.http).get = "/babylon/finality/v1/activated_height"; + } + // ListPublicRandomness is a range query for public randomness of a given finality provider // NOTE: Babylon only has the knowledge of public randomness that is already revealed by - // finality providers, i.e., the finality provider alreayd provides a finality signature + // finality providers, i.e., the finality provider already provides a finality signature // at the corresponding height - // TODO: remove public randomness storage? rpc ListPublicRandomness(QueryListPublicRandomnessRequest) returns (QueryListPublicRandomnessResponse) { option (google.api.http).get = "/babylon/finality/v1/finality_providers/{fp_btc_pk_hex}/public_randomness_list"; } @@ -75,6 +97,92 @@ message QueryParamsResponse { Params params = 1 [(gogoproto.nullable) = false]; } +// QueryFinalityProviderPowerAtHeightRequest is the request type for the +// Query/FinalityProviderPowerAtHeight RPC method. +message QueryFinalityProviderPowerAtHeightRequest { + // fp_btc_pk_hex is the hex str of Bitcoin secp256k1 PK of the finality provider that + // this BTC delegation delegates to + // the PK follows encoding in BIP-340 spec + string fp_btc_pk_hex = 1; + + // height is used for querying the given finality provider's voting power at this height + uint64 height = 2; +} + +// QueryFinalityProviderPowerAtHeightResponse is the response type for the +// Query/FinalityProviderPowerAtHeight RPC method. +message QueryFinalityProviderPowerAtHeightResponse { + // voting_power is the voting power of the finality provider + uint64 voting_power = 1; +} + +// QueryFinalityProviderCurrentPowerRequest is the request type for the +// Query/FinalityProviderCurrentPower RPC method. +message QueryFinalityProviderCurrentPowerRequest { + // fp_btc_pk_hex is the hex str of Bitcoin secp256k1 PK of the finality provider that + // this BTC delegation delegates to + // the PK follows encoding in BIP-340 spec + string fp_btc_pk_hex = 1; +} + +// QueryFinalityProviderCurrentPowerResponse is the response type for the +// Query/FinalityProviderCurrentPower RPC method. +message QueryFinalityProviderCurrentPowerResponse { + // height is the current height + uint64 height = 1; + // voting_power is the voting power of the finality provider + uint64 voting_power = 2; +} + +// QueryActiveFinalityProvidersAtHeightRequest is the request type for the +// Query/ActiveFinalityProvidersAtHeight RPC method. +message QueryActiveFinalityProvidersAtHeightRequest { + // height defines at which Babylon height to query the finality providers info. + uint64 height = 1; + + // pagination defines an optional pagination for the request. + cosmos.base.query.v1beta1.PageRequest pagination = 2; +} + +// ActiveFinalityProvidersAtHeightResponse wraps the FinalityProvider with metadata. +message ActiveFinalityProvidersAtHeightResponse { + // btc_pk is the Bitcoin secp256k1 PK of thisfinality provider + // the PK follows encoding in BIP-340 spec + string btc_pk_hex = 1 [ (gogoproto.customtype) = "github.com/babylonlabs-io/babylon/types.BIP340PubKey" ]; + // height is the queried Babylon height + uint64 height = 2; + // voting_power is the voting power of this finality provider at the given height + uint64 voting_power = 3; + // slashed_babylon_height indicates the Babylon height when + // the finality provider is slashed. + // if it's 0 then the finality provider is not slashed + uint64 slashed_babylon_height = 4; + // slashed_btc_height indicates the BTC height when + // the finality provider is slashed. + // if it's 0 then the finality provider is not slashed + uint32 slashed_btc_height = 5; + // jailed defines whether the finality provider is detected jailed + bool jailed = 6; +} + +// QueryActiveFinalityProvidersAtHeightResponse is the response type for the +// Query/ActiveFinalityProvidersAtHeight RPC method. +message QueryActiveFinalityProvidersAtHeightResponse { + // finality_providers contains all the queried finality providersn. + repeated ActiveFinalityProvidersAtHeightResponse finality_providers = 1; + + // pagination defines the pagination in the response. + cosmos.base.query.v1beta1.PageResponse pagination = 2; +} + +// QueryActivatedHeightRequest is the request type for the Query/ActivatedHeight RPC method. +message QueryActivatedHeightRequest {} + +// QueryActivatedHeightResponse is the response type for the Query/ActivatedHeight RPC method. +message QueryActivatedHeightResponse { + uint64 height = 1; +} + // QueryListPublicRandomnessRequest is the request type for the // Query/ListPublicRandomness RPC method. message QueryListPublicRandomnessRequest { @@ -194,10 +302,33 @@ message QueryEvidenceRequest { string fp_btc_pk_hex = 1; } +// Evidence is the evidence that a finality provider has signed finality +// signatures with correct public randomness on two conflicting Babylon headers +message EvidenceResponse { + // fp_btc_pk_hex is the BTC PK of the finality provider that casts this vote + string fp_btc_pk_hex = 1; + // block_height is the height of the conflicting blocks + uint64 block_height = 2; + // pub_rand is the public randomness the finality provider has committed to + bytes pub_rand = 3 [ (gogoproto.customtype) = "github.com/babylonlabs-io/babylon/types.SchnorrPubRand" ]; + // canonical_app_hash is the AppHash of the canonical block + bytes canonical_app_hash = 4; + // fork_app_hash is the AppHash of the fork block + bytes fork_app_hash = 5; + // canonical_finality_sig is the finality signature to the canonical block + // where finality signature is an EOTS signature, i.e., + // the `s` in a Schnorr signature `(r, s)` + // `r` is the public randomness that is already committed by the finality provider + bytes canonical_finality_sig = 6 [ (gogoproto.customtype) = "github.com/babylonlabs-io/babylon/types.SchnorrEOTSSig" ]; + // fork_finality_sig is the finality signature to the fork block + // where finality signature is an EOTS signature + bytes fork_finality_sig = 7 [ (gogoproto.customtype) = "github.com/babylonlabs-io/babylon/types.SchnorrEOTSSig" ]; +} + // QueryEvidenceResponse is the response type for the // Query/Evidence RPC method. message QueryEvidenceResponse { - Evidence evidence = 1; + EvidenceResponse evidence = 1; } // QueryListEvidencesRequest is the request type for the @@ -215,7 +346,7 @@ message QueryListEvidencesRequest { // Query/ListEvidences RPC method. message QueryListEvidencesResponse { // blocks is the list of evidences - repeated Evidence evidences = 1; + repeated EvidenceResponse evidences = 1; // pagination defines the pagination in the response. cosmos.base.query.v1beta1.PageResponse pagination = 2; @@ -229,11 +360,24 @@ message QuerySigningInfoRequest { string fp_btc_pk_hex = 1; } +// SigningInfoResponse defines the API response containing a finality provider's signing info +// for monitoring their liveness activity. +message SigningInfoResponse { + // fp_btc_pk is the BTC PK of the finality provider that casts this vote + string fp_btc_pk_hex = 1; + // start_height is the block height at which finality provider become active + int64 start_height = 2; + // missed_blocks_counter defines a counter to avoid unnecessary array reads. + // Note that `Sum(MissedBlocksBitArray)` always equals `MissedBlocksCounter`. + int64 missed_blocks_counter = 3; + // Timestamp until which the validator is jailed due to liveness downtime. + google.protobuf.Timestamp jailed_until = 4 [(gogoproto.stdtime) = true, (gogoproto.nullable) = false, (amino.dont_omitempty) = true]; +} + // QuerySigningInfoResponse is the response type for the Query/SigningInfo RPC // method message QuerySigningInfoResponse { - // fp_signing_info is the signing info of requested finality provider BTC public key - FinalityProviderSigningInfo fp_signing_info = 1 [(gogoproto.nullable) = false]; + SigningInfoResponse signing_info = 1 [(gogoproto.nullable) = false]; } // QuerySigningInfosRequest is the request type for the Query/SigningInfos RPC @@ -246,6 +390,6 @@ message QuerySigningInfosRequest { // method message QuerySigningInfosResponse { // info is the signing info of all finality providers with signing info - repeated FinalityProviderSigningInfo fp_signing_infos = 1 [(gogoproto.nullable) = false]; + repeated SigningInfoResponse signing_infos = 1 [(gogoproto.nullable) = false]; cosmos.base.query.v1beta1.PageResponse pagination = 2; } diff --git a/proto/babylon/incentive/incentive.proto b/proto/babylon/incentive/incentive.proto index 1e606919f..1a942b843 100644 --- a/proto/babylon/incentive/incentive.proto +++ b/proto/babylon/incentive/incentive.proto @@ -17,7 +17,7 @@ message Gauge { ]; } -// RewardGauge is an object that stores rewards distributed to a BTC staking/timestamping stakeholder +// RewardGauge is an object that stores rewards distributed to a BTC staking stakeholder // code adapted from https://github.com/osmosis-labs/osmosis/blob/v18.0.0/proto/osmosis/incentives/gauge.proto message RewardGauge { // coins are coins that have been in the gauge diff --git a/proto/babylon/incentive/params.proto b/proto/babylon/incentive/params.proto index 8f5f6d54a..588ec00f8 100644 --- a/proto/babylon/incentive/params.proto +++ b/proto/babylon/incentive/params.proto @@ -13,22 +13,10 @@ option go_package = "github.com/babylonlabs-io/babylon/x/incentive/types"; message Params { option (gogoproto.goproto_stringer) = false; - // submitter_portion is the portion of rewards that goes to submitter - string submitter_portion = 1 [ - (cosmos_proto.scalar) = "cosmos.Dec", - (gogoproto.customtype) = "cosmossdk.io/math.LegacyDec", - (gogoproto.nullable) = false - ]; - // reporter_portion is the portion of rewards that goes to reporter - string reporter_portion = 2 [ - (cosmos_proto.scalar) = "cosmos.Dec", - (gogoproto.customtype) = "cosmossdk.io/math.LegacyDec", - (gogoproto.nullable) = false - ]; // btc_staking_portion is the portion of rewards that goes to Finality Providers/delegations // NOTE: the portion of each Finality Provider/delegation is calculated by using its voting // power and finality provider's commission - string btc_staking_portion = 3 [ + string btc_staking_portion = 1 [ (cosmos_proto.scalar) = "cosmos.Dec", (gogoproto.customtype) = "cosmossdk.io/math.LegacyDec", (gogoproto.nullable) = false diff --git a/proto/babylon/incentive/query.proto b/proto/babylon/incentive/query.proto index f31a511cb..30601ae7e 100644 --- a/proto/babylon/incentive/query.proto +++ b/proto/babylon/incentive/query.proto @@ -5,6 +5,7 @@ import "gogoproto/gogo.proto"; import "google/api/annotations.proto"; import "babylon/incentive/params.proto"; import "babylon/incentive/incentive.proto"; +import "cosmos/base/v1beta1/coin.proto"; option go_package = "github.com/babylonlabs-io/babylon/x/incentive/types"; @@ -22,10 +23,6 @@ service Query { rpc BTCStakingGauge(QueryBTCStakingGaugeRequest) returns (QueryBTCStakingGaugeResponse) { option (google.api.http).get = "/babylon/incentive/btc_staking_gauge/{height}"; } - // BTCTimestampingGauge queries the BTC timestamping gauge of a given epoch - rpc BTCTimestampingGauge(QueryBTCTimestampingGaugeRequest) returns (QueryBTCTimestampingGaugeResponse) { - option (google.api.http).get = "/babylon/incentive/btc_timestamping_gauge/{epoch_num}"; - } } // QueryParamsRequest is request type for the Query/Params RPC method. @@ -43,11 +40,26 @@ message QueryRewardGaugesRequest { string address = 1; } +// RewardGaugesResponse is an object that stores rewards distributed to a BTC staking stakeholder +message RewardGaugesResponse { + // coins are coins that have been in the gauge + // Can have multiple coin denoms + repeated cosmos.base.v1beta1.Coin coins = 1 [ + (gogoproto.nullable) = false, + (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins" + ]; + // withdrawn_coins are coins that have been withdrawn by the stakeholder already + repeated cosmos.base.v1beta1.Coin withdrawn_coins = 2 [ + (gogoproto.nullable) = false, + (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins" + ]; +} + // QueryRewardGaugesResponse is response type for the Query/RewardGauges RPC method. message QueryRewardGaugesResponse { // reward_gauges is the map of reward gauges, where key is the stakeholder type // and value is the reward gauge holding all rewards for the stakeholder in that type - map reward_gauges = 1; + map reward_gauges = 1; } // QueryBTCStakingGaugeRequest is request type for the Query/BTCStakingGauge RPC method. @@ -56,20 +68,19 @@ message QueryBTCStakingGaugeRequest { uint64 height = 1; } -// QueryBTCStakingGaugeResponse is response type for the Query/BTCStakingGauge RPC method. -message QueryBTCStakingGaugeResponse { - // gauge is the BTC staking gauge at the queried height - Gauge gauge = 1; -} +// BTCStakingGaugeResponse is response type for the Query/BTCStakingGauge RPC method. +message BTCStakingGaugeResponse { + // coins that have been in the gauge + // can have multiple coin denoms + repeated cosmos.base.v1beta1.Coin coins = 1 [ + (gogoproto.nullable) = false, + (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins" + ]; -// QueryBTCTimestampingGaugeRequest is request type for the Query/BTCTimestampingGauge RPC method. -message QueryBTCTimestampingGaugeRequest { - // epoch_num is the queried epoch number - uint64 epoch_num = 1; } -// QueryBTCTimestampingGaugeResponse is response type for the Query/BTCTimestampingGauge RPC method. -message QueryBTCTimestampingGaugeResponse { - // gauge is the BTC timestamping gauge at the queried epoch - Gauge gauge = 1; +// QueryBTCStakingGaugeResponse is response type for the Query/BTCStakingGauge RPC method. +message QueryBTCStakingGaugeResponse { + // gauge is the BTC staking gauge at the queried height + BTCStakingGaugeResponse gauge = 1; } diff --git a/proto/babylon/incentive/tx.proto b/proto/babylon/incentive/tx.proto index 13810102e..321996e71 100644 --- a/proto/babylon/incentive/tx.proto +++ b/proto/babylon/incentive/tx.proto @@ -23,7 +23,7 @@ service Msg { // MsgWithdrawReward defines a message for withdrawing reward of a stakeholder. message MsgWithdrawReward { option (cosmos.msg.v1.signer) = "address"; - // {submitter, reporter, finality_provider, btc_delegation} + // {finality_provider, btc_delegation} string type = 1; // address is the address of the stakeholder in bech32 string // signer of this msg has to be this address diff --git a/proto/babylon/mint/v1/genesis.proto b/proto/babylon/mint/v1/genesis.proto new file mode 100644 index 000000000..defc3a588 --- /dev/null +++ b/proto/babylon/mint/v1/genesis.proto @@ -0,0 +1,12 @@ +syntax = "proto3"; +package babylon.mint.v1; + +option go_package = "github.com/babylonlabs-io/babylon/x/mint/types"; + +// GenesisState defines the mint module's genesis state. +message GenesisState { + reserved 1; // 1 was previously used for the `Minter` field. + + // BondDenom is the denomination of the token that should be minted. + string bond_denom = 2; +} diff --git a/proto/babylon/mint/v1/mint.proto b/proto/babylon/mint/v1/mint.proto new file mode 100644 index 000000000..b14f6efd0 --- /dev/null +++ b/proto/babylon/mint/v1/mint.proto @@ -0,0 +1,40 @@ +syntax = "proto3"; +package babylon.mint.v1; + +option go_package = "github.com/babylonlabs-io/babylon/x/mint/types"; + +import "gogoproto/gogo.proto"; +import "cosmos_proto/cosmos.proto"; +import "google/protobuf/timestamp.proto"; + +// Minter represents the mint state. +message Minter { + // InflationRate is the rate at which new tokens should be minted for the + // current year. For example if InflationRate=0.1, then 10% of the total + // supply will be minted over the course of the year. + string inflation_rate = 1 [ + (cosmos_proto.scalar) = "cosmos.Dec", + (gogoproto.customtype) = "cosmossdk.io/math.LegacyDec", + (gogoproto.nullable) = false + ]; + // AnnualProvisions is the total number of tokens to be minted in the current + // year due to inflation. + string annual_provisions = 2 [ + (cosmos_proto.scalar) = "cosmos.Dec", + (gogoproto.customtype) = "cosmossdk.io/math.LegacyDec", + (gogoproto.nullable) = false + ]; + + // PreviousBlockTime is the timestamp of the previous block. + google.protobuf.Timestamp previous_block_time = 4 + [ (gogoproto.stdtime) = true ]; + + // BondDenom is the denomination of the token that should be minted. + string bond_denom = 5; +} + +// GenesisTime contains the timestamp of the genesis block. +message GenesisTime { + // GenesisTime is the timestamp of the genesis block. + google.protobuf.Timestamp genesis_time = 1 [ (gogoproto.stdtime) = true ]; +} diff --git a/proto/babylon/mint/v1/query.proto b/proto/babylon/mint/v1/query.proto new file mode 100644 index 000000000..5d88e85d6 --- /dev/null +++ b/proto/babylon/mint/v1/query.proto @@ -0,0 +1,68 @@ +syntax = "proto3"; +package babylon.mint.v1; + +import "gogoproto/gogo.proto"; +import "google/api/annotations.proto"; +import "babylon/mint/v1/mint.proto"; +import "google/protobuf/timestamp.proto"; + +option go_package = "github.com/babylonlabs-io/babylon/x/mint/types"; + +// Query defines the gRPC querier service. +service Query { + // InflationRate returns the current inflation rate. + rpc InflationRate(QueryInflationRateRequest) + returns (QueryInflationRateResponse) { + option (google.api.http).get = "/cosmos/mint/v1beta1/inflation_rate"; + } + + // AnnualProvisions returns the current annual provisions. + rpc AnnualProvisions(QueryAnnualProvisionsRequest) + returns (QueryAnnualProvisionsResponse) { + option (google.api.http).get = "/cosmos/mint/v1beta1/annual_provisions"; + } + + // GenesisTime returns the genesis time. + rpc GenesisTime(QueryGenesisTimeRequest) returns (QueryGenesisTimeResponse) { + option (google.api.http).get = "/cosmos/mint/v1beta1/genesis_time"; + } +} + +// QueryInflationRateRequest is the request type for the Query/InflationRate RPC +// method. +message QueryInflationRateRequest {} + +// QueryInflationRateResponse is the response type for the Query/InflationRate +// RPC method. +message QueryInflationRateResponse { + // InflationRate is the current inflation rate. + bytes inflation_rate = 1 [ + (gogoproto.customtype) = "cosmossdk.io/math.LegacyDec", + (gogoproto.nullable) = false + ]; +} + +// QueryAnnualProvisionsRequest is the request type for the +// Query/AnnualProvisions RPC method. +message QueryAnnualProvisionsRequest {} + +// QueryAnnualProvisionsResponse is the response type for the +// Query/AnnualProvisions RPC method. +message QueryAnnualProvisionsResponse { + // AnnualProvisions is the current annual provisions. + bytes annual_provisions = 1 [ + (gogoproto.customtype) = "cosmossdk.io/math.LegacyDec", + (gogoproto.nullable) = false + ]; +} + +// QueryGenesisTimeRequest is the request type for the Query/GenesisTime RPC +// method. +message QueryGenesisTimeRequest {} + +// QueryGenesisTimeResponse is the response type for the Query/GenesisTime RPC +// method. +message QueryGenesisTimeResponse { + // GenesisTime is the timestamp associated with the first block. + google.protobuf.Timestamp genesis_time = 1 [ (gogoproto.stdtime) = true ]; +} diff --git a/proto/babylon/monitor/v1/query.proto b/proto/babylon/monitor/v1/query.proto index c77bfc8f2..2f102eea1 100644 --- a/proto/babylon/monitor/v1/query.proto +++ b/proto/babylon/monitor/v1/query.proto @@ -30,7 +30,7 @@ message QueryEndedEpochBtcHeightRequest { uint64 epoch_num = 1; } // EndedEpochBtcHeight RPC method message QueryEndedEpochBtcHeightResponse { // height of btc light client when epoch ended - uint64 btc_light_client_height = 1; + uint32 btc_light_client_height = 1; } // QueryReportedCheckpointBtcHeightRequest defines a query type for @@ -44,5 +44,5 @@ message QueryReportedCheckpointBtcHeightRequest { // ReportedCheckpointBtcHeight RPC method message QueryReportedCheckpointBtcHeightResponse { // height of btc light client when checkpoint is reported - uint64 btc_light_client_height = 1; + uint32 btc_light_client_height = 1; } diff --git a/proto/scripts/protocgen.sh b/proto/scripts/protocgen.sh index a61d0e936..6f4d039cc 100755 --- a/proto/scripts/protocgen.sh +++ b/proto/scripts/protocgen.sh @@ -19,4 +19,4 @@ cd .. cp -r github.com/babylonlabs-io/babylon/* ./ rm -rf github.com -go mod tidy -compat=1.21 +# go mod tidy -compat=1.23 diff --git a/test/e2e/bcd_consumer_integration/clientcontroller/babylon/babylon.go b/test/e2e/bcd_consumer_integration/clientcontroller/babylon/babylon.go index db6e167c7..c105836ea 100644 --- a/test/e2e/bcd_consumer_integration/clientcontroller/babylon/babylon.go +++ b/test/e2e/bcd_consumer_integration/clientcontroller/babylon/babylon.go @@ -279,7 +279,8 @@ func (bc *BabylonController) CreateBTCDelegation( pop *btcstakingtypes.ProofOfPossessionBTC, stakingTime uint32, stakingValue int64, - stakingTxInfo *btcctypes.TransactionInfo, + stakingTx []byte, + stakingTxInclusionProof *btcstakingtypes.InclusionProof, slashingTx *btcstakingtypes.BTCSlashingTx, delSlashingSig *bbntypes.BIP340Signature, unbondingTx []byte, @@ -299,7 +300,8 @@ func (bc *BabylonController) CreateBTCDelegation( FpBtcPkList: fpBtcPks, StakingTime: stakingTime, StakingValue: stakingValue, - StakingTx: stakingTxInfo, + StakingTx: stakingTx, + StakingTxInclusionProof: stakingTxInclusionProof, SlashingTx: slashingTx, DelegatorSlashingSig: delSlashingSig, UnbondingTx: unbondingTx, @@ -471,7 +473,7 @@ func (bc *BabylonController) QueryFinalityProviderDelegations(fpBtcPkHex string, return resp.BtcDelegatorDelegations, nil } -func (bc *BabylonController) QueryActivatedHeight() (*btcstakingtypes.QueryActivatedHeightResponse, error) { +func (bc *BabylonController) QueryActivatedHeight() (*finalitytypes.QueryActivatedHeightResponse, error) { resp, err := bc.bbnClient.QueryClient.ActivatedHeight() if err != nil { return nil, fmt.Errorf("failed to query activated height: %w", err) diff --git a/test/e2e/bcd_consumer_integration/clientcontroller/cosmwasm/msg.go b/test/e2e/bcd_consumer_integration/clientcontroller/cosmwasm/msg.go index 639686da5..f103065fd 100644 --- a/test/e2e/bcd_consumer_integration/clientcontroller/cosmwasm/msg.go +++ b/test/e2e/bcd_consumer_integration/clientcontroller/cosmwasm/msg.go @@ -12,7 +12,7 @@ type ConsumerFpsResponse struct { type SingleConsumerFpResponse struct { BtcPkHex string `json:"btc_pk_hex"` SlashedHeight uint64 `json:"slashed_height"` - SlashedBtcHeight uint64 `json:"slashed_btc_height"` + SlashedBtcHeight uint32 `json:"slashed_btc_height"` ConsumerId string `json:"consumer_id"` } @@ -23,8 +23,8 @@ type ConsumerDelegationsResponse struct { type SingleConsumerDelegationResponse struct { BtcPkHex string `json:"btc_pk_hex"` FpBtcPkList []string `json:"fp_btc_pk_list"` - StartHeight uint64 `json:"start_height"` - EndHeight uint64 `json:"end_height"` + StartHeight uint32 `json:"start_height"` + EndHeight uint32 `json:"end_height"` TotalSat uint64 `json:"total_sat"` StakingTx []byte `json:"staking_tx"` SlashingTx []byte `json:"slashing_tx"` @@ -104,8 +104,8 @@ type ActiveBtcDelegation struct { StakerAddr string `json:"staker_addr"` BTCPkHex string `json:"btc_pk_hex"` FpBtcPkList []string `json:"fp_btc_pk_list"` - StartHeight uint64 `json:"start_height"` - EndHeight uint64 `json:"end_height"` + StartHeight uint32 `json:"start_height"` + EndHeight uint32 `json:"end_height"` TotalSat uint64 `json:"total_sat"` StakingTx []byte `json:"staking_tx"` SlashingTx []byte `json:"slashing_tx"` diff --git a/test/e2e/bcd_consumer_integration/clientcontroller/types/stakingparams.go b/test/e2e/bcd_consumer_integration/clientcontroller/types/stakingparams.go index 78747daed..9d91c43db 100644 --- a/test/e2e/bcd_consumer_integration/clientcontroller/types/stakingparams.go +++ b/test/e2e/bcd_consumer_integration/clientcontroller/types/stakingparams.go @@ -8,9 +8,9 @@ import ( type StakingParams struct { // K-deep - ComfirmationTimeBlocks uint64 + ComfirmationTimeBlocks uint32 // W-deep - FinalizationTimeoutBlocks uint64 + FinalizationTimeoutBlocks uint32 // Minimum amount of tx fee (quantified in Satoshi) needed for the pre-signed slashing tx MinSlashingTxFeeSat btcutil.Amount @@ -34,9 +34,9 @@ type StakingParams struct { // MinimumUnbondingTime returns the minimum unbonding time. It is the bigger value from: // - MinUnbondingTime // - CheckpointFinalizationTimeout -func (p *StakingParams) MinimumUnbondingTime() uint64 { - return sdkmath.Max[uint64]( - uint64(p.MinUnbondingTime), +func (p *StakingParams) MinimumUnbondingTime() uint32 { + return sdkmath.Max[uint32]( + p.MinUnbondingTime, p.FinalizationTimeoutBlocks, ) } diff --git a/test/e2e/bcd_consumer_integration_test.go b/test/e2e/bcd_consumer_integration_test.go index 8a60ff393..0f66fe253 100644 --- a/test/e2e/bcd_consumer_integration_test.go +++ b/test/e2e/bcd_consumer_integration_test.go @@ -5,7 +5,6 @@ import ( "fmt" "math/rand" "os" - "os/exec" "path/filepath" "strings" "time" @@ -48,6 +47,8 @@ var ( randListInfo1 *datagen.RandListInfo // TODO: get consumer id from ibc client-state query consumerID = "07-tendermint-0" + + czDelBtcSk, czDelBtcPk, _ = datagen.GenRandomBTCKeyPair(r) ) type BCDConsumerIntegrationTestSuite struct { @@ -68,26 +69,26 @@ func (s *BCDConsumerIntegrationTestSuite) SetupSuite() { } func (s *BCDConsumerIntegrationTestSuite) TearDownSuite() { - s.T().Log("tearing down e2e integration test suite...") - - // Get the current working directory - currentDir, err := os.Getwd() - if err != nil { - s.T().Errorf("Failed to get current working directory: %v", err) - return - } - - // Construct the path to the Makefile directory - makefileDir := filepath.Join(currentDir, "../../contrib/images") - - // Run the stop-bcd-consumer-integration make target - cmd := exec.Command("make", "-C", makefileDir, "stop-bcd-consumer-integration") - output, err := cmd.CombinedOutput() - if err != nil { - s.T().Errorf("Failed to run stop-bcd-consumer-integration: %v\nOutput: %s", err, output) - } else { - s.T().Log("Successfully stopped integration test") - } + // s.T().Log("tearing down e2e integration test suite...") + + // // Get the current working directory + // currentDir, err := os.Getwd() + // if err != nil { + // s.T().Errorf("Failed to get current working directory: %v", err) + // return + // } + + // // Construct the path to the Makefile directory + // makefileDir := filepath.Join(currentDir, "../../contrib/images") + + // // Run the stop-bcd-consumer-integration make target + // cmd := exec.Command("make", "-C", makefileDir, "stop-bcd-consumer-integration") + // output, err := cmd.CombinedOutput() + // if err != nil { + // s.T().Errorf("Failed to run stop-bcd-consumer-integration: %v\nOutput: %s", err, output) + // } else { + // s.T().Log("Successfully stopped integration test") + // } } func (s *BCDConsumerIntegrationTestSuite) Test1ChainStartup() { @@ -337,8 +338,7 @@ func (s *BCDConsumerIntegrationTestSuite) Test6BabylonFPCascadedSlashing() { return false } return fp != nil && - fp.FinalityProvider.SlashedBtcHeight > 0 && - fp.FinalityProvider.VotingPower == 0 + fp.FinalityProvider.SlashedBtcHeight > 0 }, time.Minute, time.Second*5) // query consumer finality providers @@ -480,7 +480,6 @@ func (s *BCDConsumerIntegrationTestSuite) Test7ConsumerFPCascadedSlashing() { return false } return fp != nil && - fp.FinalityProvider.VotingPower == 0 && // as there is only 1 delegation which got slashed fp.FinalityProvider.SlashedBtcHeight == 0 // should not be slashed }, time.Minute, time.Second*5) @@ -588,33 +587,38 @@ func (s *BCDConsumerIntegrationTestSuite) submitCovenantSigs(consumerFp *bsctype s.Require().NotNil(tx) } - // ensure the BTC delegation has covenant sigs now - activeDelsSet, err := s.babylonController.QueryFinalityProviderDelegations(consumerFp.BtcPk.MarshalHex(), 1) - s.NoError(err) - s.Len(activeDelsSet, 1) - s.Len(activeDelsSet[0].Dels, 1) - s.True(activeDelsSet[0].Dels[0].Active) - - activeDels, err := ParseRespsBTCDelToBTCDel(activeDelsSet[0]) - s.NoError(err) - s.NotNil(activeDels) - s.Len(activeDels.Dels, 1) - activeDel := activeDels.Dels[0] - s.True(activeDel.HasCovenantQuorums(1)) - - // ensure BTC staking is activated s.Eventually(func() bool { - activatedHeight, err := s.babylonController.QueryActivatedHeight() - if err != nil { - s.T().Logf("Error querying activated height: %v", err) + // ensure the BTC delegation has covenant sigs now + activeDelsSet, err := s.babylonController.QueryFinalityProviderDelegations(consumerFp.BtcPk.MarshalHex(), 1) + s.NoError(err) + if len(activeDelsSet) != 1 { + return false + } + if len(activeDelsSet[0].Dels) != 1 { return false } - if activatedHeight == nil { - s.T().Log("Activated height is nil") + if !activeDelsSet[0].Dels[0].Active { + s.T().Log(activeDelsSet[0].Dels[0].String()) return false } - return activatedHeight.Height > 0 - }, time.Minute, time.Second*15, "BTC staking was not activated within the expected time") + + activeDels, err := ParseRespsBTCDelToBTCDel(activeDelsSet[0]) + s.NoError(err) + s.NotNil(activeDels) + if len(activeDels.Dels) != 1 { + return false + } + if !activeDels.Dels[0].HasCovenantQuorums(1) { + return false + } + return true + }, time.Minute, time.Second*5, "BTC staking was not activated within the expected time") + + // ensure BTC staking is activated + activatedHeight, err := s.babylonController.QueryActivatedHeight() + s.NoError(err) + s.NotNil(activatedHeight) + s.Positive(activatedHeight.Height) } // helper function: createBabylonDelegation creates a random BTC delegation restaking to Babylon and consumer finality providers @@ -649,6 +653,8 @@ func (s *BCDConsumerIntegrationTestSuite) createBabylonDelegation(babylonFp *bst ) stakingMsgTx := testStakingInfo.StakingTx + stakingTxBytes, err := bbntypes.SerializeBTCTx(stakingMsgTx) + s.NoError(err) stakingTxHash := stakingMsgTx.TxHash().String() stakingSlashingPathInfo, err := testStakingInfo.StakingInfo.SlashingPathSpendInfo() s.NoError(err) @@ -685,10 +691,7 @@ func (s *BCDConsumerIntegrationTestSuite) createBabylonDelegation(babylonFp *bst } _, err = s.babylonController.InsertBtcBlockHeaders(headers) s.NoError(err) - btcHeader := blockWithStakingTx.HeaderBytes - serializedStakingTx, err := bbntypes.SerializeBTCTx(testStakingInfo.StakingTx) - s.NoError(err) - stakingTxInfo := btcctypes.NewTransactionInfo(&btcctypes.TransactionKey{Index: 1, Hash: btcHeader.Hash()}, serializedStakingTx, blockWithStakingTx.SpvProof.MerkleNodes) + inclusionProof := bstypes.NewInclusionProofFromSpvProof(blockWithStakingTx.SpvProof) // generate BTC undelegation stuff stkTxHash := testStakingInfo.StakingTx.TxHash() @@ -712,26 +715,28 @@ func (s *BCDConsumerIntegrationTestSuite) createBabylonDelegation(babylonFp *bst s.NoError(err) // submit the message for creating BTC delegation - delBTCPKs := []bbntypes.BIP340PubKey{*bbntypes.NewBIP340PubKeyFromBTCPK(czDelBtcPk)} + delBTCPK := *bbntypes.NewBIP340PubKeyFromBTCPK(czDelBtcPk) serializedUnbondingTx, err := bbntypes.SerializeBTCTx(testUnbondingInfo.UnbondingTx) s.NoError(err) // submit the BTC delegation to Babylon _, err = s.babylonController.CreateBTCDelegation( - &delBTCPKs[0], + &delBTCPK, []*btcec.PublicKey{babylonFp.BtcPk.MustToBTCPK(), consumerFp.BtcPk.MustToBTCPK()}, pop, uint32(stakingTimeBlocks), stakingValue, - stakingTxInfo, + stakingTxBytes, + inclusionProof, testStakingInfo.SlashingTx, delegatorSig, serializedUnbondingTx, uint32(unbondingTime), unbondingValue, testUnbondingInfo.SlashingTx, - delUnbondingSlashingSig) + delUnbondingSlashingSig, + ) s.NoError(err) return czDelBtcPk, stakingTxHash diff --git a/test/e2e/btc_staking_e2e_test.go b/test/e2e/btc_staking_e2e_test.go index 23afe4446..a3f6d8266 100644 --- a/test/e2e/btc_staking_e2e_test.go +++ b/test/e2e/btc_staking_e2e_test.go @@ -5,54 +5,59 @@ import ( "fmt" "math" "math/rand" + "testing" "time" + "github.com/btcsuite/btcd/btcec/v2" + "github.com/btcsuite/btcd/btcutil" + "github.com/btcsuite/btcd/chaincfg" + "github.com/btcsuite/btcd/wire" + "github.com/stretchr/testify/require" + "github.com/stretchr/testify/suite" + sdkmath "cosmossdk.io/math" feegrantcli "cosmossdk.io/x/feegrant/client/cli" - "github.com/babylonlabs-io/babylon/app/params" + appparams "github.com/babylonlabs-io/babylon/app/params" "github.com/babylonlabs-io/babylon/crypto/eots" "github.com/babylonlabs-io/babylon/test/e2e/configurer" "github.com/babylonlabs-io/babylon/test/e2e/configurer/chain" "github.com/babylonlabs-io/babylon/test/e2e/initialization" "github.com/babylonlabs-io/babylon/testutil/datagen" bbn "github.com/babylonlabs-io/babylon/types" - btcctypes "github.com/babylonlabs-io/babylon/x/btccheckpoint/types" bstypes "github.com/babylonlabs-io/babylon/x/btcstaking/types" ckpttypes "github.com/babylonlabs-io/babylon/x/checkpointing/types" ftypes "github.com/babylonlabs-io/babylon/x/finality/types" itypes "github.com/babylonlabs-io/babylon/x/incentive/types" - "github.com/btcsuite/btcd/btcec/v2" - "github.com/btcsuite/btcd/btcutil" - "github.com/btcsuite/btcd/chaincfg" - "github.com/btcsuite/btcd/wire" sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/stretchr/testify/suite" -) - -var ( - r = rand.New(rand.NewSource(time.Now().Unix())) - net = &chaincfg.SimNetParams - // finality provider - fpBTCSK, _, _ = datagen.GenRandomBTCKeyPair(r) - cacheFP *bstypes.FinalityProvider - // BTC delegation - delBTCSK, delBTCPK, _ = datagen.GenRandomBTCKeyPair(r) - // covenant - covenantSKs, _, covenantQuorum = bstypes.DefaultCovenantCommittee() - - stakingValue = int64(2 * 10e8) ) type BTCStakingTestSuite struct { suite.Suite - configurer configurer.Configurer + r *rand.Rand + net *chaincfg.Params + fptBTCSK *btcec.PrivateKey + delBTCSK *btcec.PrivateKey + cacheFP *bstypes.FinalityProvider + covenantSKs []*btcec.PrivateKey + covenantQuorum uint32 + stakingValue int64 + configurer configurer.Configurer } func (s *BTCStakingTestSuite) SetupSuite() { s.T().Log("setting up e2e integration test suite...") var err error + s.r = rand.New(rand.NewSource(time.Now().Unix())) + s.net = &chaincfg.SimNetParams + s.fptBTCSK, _, _ = datagen.GenRandomBTCKeyPair(s.r) + s.delBTCSK, _, _ = datagen.GenRandomBTCKeyPair(s.r) + s.stakingValue = int64(2 * 10e8) + covenantSKs, _, covenantQuorum := bstypes.DefaultCovenantCommittee() + s.covenantSKs = covenantSKs + s.covenantQuorum = covenantQuorum + // The e2e test flow is as follows: // // 1. Configure 1 chain with some validator nodes @@ -65,13 +70,6 @@ func (s *BTCStakingTestSuite) SetupSuite() { s.NoError(err) } -func (s *BTCStakingTestSuite) TearDownSuite() { - err := s.configurer.ClearResources() - if err != nil { - s.T().Logf("error to clear resources %s", err.Error()) - } -} - // TestCreateFinalityProviderAndDelegation is an end-to-end test for // user story 1: user creates finality provider and BTC delegation func (s *BTCStakingTestSuite) Test1CreateFinalityProviderAndDelegation() { @@ -80,7 +78,12 @@ func (s *BTCStakingTestSuite) Test1CreateFinalityProviderAndDelegation() { nonValidatorNode, err := chainA.GetNodeAtIndex(2) s.NoError(err) - cacheFP = s.CreateNodeFP(nonValidatorNode) + s.cacheFP = CreateNodeFP( + s.T(), + s.r, + s.fptBTCSK, + nonValidatorNode, + ) /* create a random BTC delegation under this finality provider @@ -93,25 +96,26 @@ func (s *BTCStakingTestSuite) Test1CreateFinalityProviderAndDelegation() { // NOTE: we use the node's address for the BTC delegation stakerAddr := sdk.MustAccAddressFromBech32(nonValidatorNode.PublicAddress) - pop, err := bstypes.NewPoPBTC(stakerAddr, delBTCSK) + pop, err := bstypes.NewPoPBTC(stakerAddr, s.delBTCSK) s.NoError(err) // generate staking tx and slashing tx stakingTimeBlocks := uint16(math.MaxUint16) - testStakingInfo, stakingTxInfo, testUnbondingInfo, delegatorSig := s.BTCStakingUnbondSlashInfo(nonValidatorNode, params, stakingTimeBlocks, cacheFP) + testStakingInfo, stakingTx, inclusionProof, testUnbondingInfo, delegatorSig := s.BTCStakingUnbondSlashInfo(nonValidatorNode, params, stakingTimeBlocks, s.cacheFP) - delUnbondingSlashingSig, err := testUnbondingInfo.GenDelSlashingTxSig(delBTCSK) + delUnbondingSlashingSig, err := testUnbondingInfo.GenDelSlashingTxSig(s.delBTCSK) s.NoError(err) // submit the message for creating BTC delegation - delBTCPKs := []bbn.BIP340PubKey{*bbn.NewBIP340PubKeyFromBTCPK(delBTCPK)} + btcPK := bbn.NewBIP340PubKeyFromBTCPK(s.delBTCSK.PubKey()) nonValidatorNode.CreateBTCDelegation( - delBTCPKs, + *btcPK, pop, - stakingTxInfo, - []*bbn.BIP340PubKey{cacheFP.BtcPk}, + stakingTx, + inclusionProof, + []*bbn.BIP340PubKey{s.cacheFP.BtcPk}, stakingTimeBlocks, - btcutil.Amount(stakingValue), + btcutil.Amount(s.stakingValue), testStakingInfo.SlashingTx, delegatorSig, testUnbondingInfo.UnbondingTx, @@ -126,11 +130,11 @@ func (s *BTCStakingTestSuite) Test1CreateFinalityProviderAndDelegation() { // wait for a block so that above txs take effect nonValidatorNode.WaitForNextBlock() - pendingDelSet := nonValidatorNode.QueryFinalityProviderDelegations(cacheFP.BtcPk.MarshalHex()) + pendingDelSet := nonValidatorNode.QueryFinalityProviderDelegations(s.cacheFP.BtcPk.MarshalHex()) s.Len(pendingDelSet, 1) pendingDels := pendingDelSet[0] s.Len(pendingDels.Dels, 1) - s.Equal(delBTCPK.SerializeCompressed()[1:], pendingDels.Dels[0].BtcPk.MustToBTCPK().SerializeCompressed()[1:]) + s.Equal(s.delBTCSK.PubKey().SerializeCompressed()[1:], pendingDels.Dels[0].BtcPk.MustToBTCPK().SerializeCompressed()[1:]) s.Len(pendingDels.Dels[0].CovenantSigs, 0) // check delegation @@ -148,7 +152,7 @@ func (s *BTCStakingTestSuite) Test2SubmitCovenantSignature() { s.NoError(err) // get last BTC delegation - pendingDelsSet := nonValidatorNode.QueryFinalityProviderDelegations(cacheFP.BtcPk.MarshalHex()) + pendingDelsSet := nonValidatorNode.QueryFinalityProviderDelegations(s.cacheFP.BtcPk.MarshalHex()) s.Len(pendingDelsSet, 1) pendingDels := pendingDelsSet[0] s.Len(pendingDels.Dels, 1) @@ -169,7 +173,7 @@ func (s *BTCStakingTestSuite) Test2SubmitCovenantSignature() { fpBTCPKs, err := bbn.NewBTCPKsFromBIP340PKs(pendingDel.FpBtcPkList) s.NoError(err) - stakingInfo, err := pendingDel.GetStakingInfo(params, net) + stakingInfo, err := pendingDel.GetStakingInfo(params, s.net) s.NoError(err) stakingSlashingPathInfo, err := stakingInfo.SlashingPathSpendInfo() @@ -180,7 +184,7 @@ func (s *BTCStakingTestSuite) Test2SubmitCovenantSignature() { */ // covenant signatures on slashing tx covenantSlashingSigs, err := datagen.GenCovenantAdaptorSigs( - covenantSKs, + s.covenantSKs, fpBTCPKs, stakingMsgTx, stakingSlashingPathInfo.GetPkScriptPath(), @@ -195,7 +199,7 @@ func (s *BTCStakingTestSuite) Test2SubmitCovenantSignature() { s.NoError(err) covUnbondingSigs, err := datagen.GenCovenantUnbondingSigs( - covenantSKs, + s.covenantSKs, stakingMsgTx, pendingDel.StakingOutputIdx, unbondingPathInfo.GetPkScriptPath(), @@ -203,12 +207,12 @@ func (s *BTCStakingTestSuite) Test2SubmitCovenantSignature() { ) s.NoError(err) - unbondingInfo, err := pendingDel.GetUnbondingInfo(params, net) + unbondingInfo, err := pendingDel.GetUnbondingInfo(params, s.net) s.NoError(err) unbondingSlashingPathInfo, err := unbondingInfo.SlashingPathSpendInfo() s.NoError(err) covenantUnbondingSlashingSigs, err := datagen.GenCovenantAdaptorSigs( - covenantSKs, + s.covenantSKs, fpBTCPKs, unbondingTx, unbondingSlashingPathInfo.GetPkScriptPath(), @@ -216,16 +220,19 @@ func (s *BTCStakingTestSuite) Test2SubmitCovenantSignature() { ) s.NoError(err) - for i := 0; i < int(covenantQuorum); i++ { - nonValidatorNode.AddCovenantSigs( - covenantSlashingSigs[i].CovPk, - stakingTxHash, - covenantSlashingSigs[i].AdaptorSigs, - bbn.NewBIP340SignatureFromBTCSig(covUnbondingSigs[i]), - covenantUnbondingSlashingSigs[i].AdaptorSigs, - ) - // wait for a block so that above txs take effect - nonValidatorNode.WaitForNextBlock() + for i := 0; i < int(s.covenantQuorum); i++ { + nonValidatorNode.SubmitRefundableTxWithAssertion(func() { + // add covenant sigs + nonValidatorNode.AddCovenantSigs( + covenantSlashingSigs[i].CovPk, + stakingTxHash, + covenantSlashingSigs[i].AdaptorSigs, + bbn.NewBIP340SignatureFromBTCSig(covUnbondingSigs[i]), + covenantUnbondingSlashingSigs[i].AdaptorSigs, + ) + // wait for a block so that above txs take effect + nonValidatorNode.WaitForNextBlock() + }, true) } // wait for a block so that above txs take effect @@ -233,7 +240,7 @@ func (s *BTCStakingTestSuite) Test2SubmitCovenantSignature() { nonValidatorNode.WaitForNextBlock() // ensure the BTC delegation has covenant sigs now - activeDelsSet := nonValidatorNode.QueryFinalityProviderDelegations(cacheFP.BtcPk.MarshalHex()) + activeDelsSet := nonValidatorNode.QueryFinalityProviderDelegations(s.cacheFP.BtcPk.MarshalHex()) s.Len(activeDelsSet, 1) activeDels, err := ParseRespsBTCDelToBTCDel(activeDelsSet[0]) @@ -242,7 +249,7 @@ func (s *BTCStakingTestSuite) Test2SubmitCovenantSignature() { s.Len(activeDels.Dels, 1) activeDel := activeDels.Dels[0] - s.True(activeDel.HasCovenantQuorums(covenantQuorum)) + s.True(activeDel.HasCovenantQuorums(s.covenantQuorum)) } // Test2CommitPublicRandomnessAndSubmitFinalitySignature is an end-to-end @@ -254,20 +261,13 @@ func (s *BTCStakingTestSuite) Test3CommitPublicRandomnessAndSubmitFinalitySignat nonValidatorNode, err := chainA.GetNodeAtIndex(2) s.NoError(err) - // get activated height - _, err = nonValidatorNode.QueryActivatedHeight() - s.ErrorContains(err, bstypes.ErrBTCStakingNotActivated.Error()) - fps := nonValidatorNode.QueryFinalityProviders() - s.Len(fps, 1) - s.Zero(fps[0].VotingPower) - /* - commit a number of public randomness since activatedHeight + commit a number of public randomness */ // commit public randomness list numPubRand := uint64(100) commitStartHeight := uint64(1) - randListInfo, msgCommitPubRandList, err := datagen.GenRandomMsgCommitPubRandList(r, fpBTCSK, commitStartHeight, numPubRand) + randListInfo, msgCommitPubRandList, err := datagen.GenRandomMsgCommitPubRandList(s.r, s.fptBTCSK, commitStartHeight, numPubRand) s.NoError(err) nonValidatorNode.CommitPubRandList( msgCommitPubRandList.FpBtcPk, @@ -293,7 +293,7 @@ func (s *BTCStakingTestSuite) Test3CommitPublicRandomnessAndSubmitFinalitySignat s.T().Logf("Successfully queried public randomness commitment for finality provider at epoch %d", commitEpoch) // no reward gauge for finality provider and delegation yet - fpBabylonAddr, err := sdk.AccAddressFromBech32(cacheFP.Addr) + fpBabylonAddr, err := sdk.AccAddressFromBech32(s.cacheFP.Addr) s.NoError(err) _, err = nonValidatorNode.QueryRewardGauge(fpBabylonAddr) @@ -342,21 +342,24 @@ func (s *BTCStakingTestSuite) Test3CommitPublicRandomnessAndSubmitFinalitySignat idx := activatedHeight - commitStartHeight msgToSign := append(sdk.Uint64ToBigEndian(activatedHeight), appHash...) // generate EOTS signature - sig, err := eots.Sign(fpBTCSK, randListInfo.SRList[idx], msgToSign) + sig, err := eots.Sign(s.fptBTCSK, randListInfo.SRList[idx], msgToSign) s.NoError(err) eotsSig := bbn.NewSchnorrEOTSSigFromModNScalar(sig) - // submit finality signature - nonValidatorNode.AddFinalitySig(cacheFP.BtcPk, activatedHeight, &randListInfo.PRList[idx], *randListInfo.ProofList[idx].ToProto(), appHash, eotsSig) - // ensure vote is eventually cast - var finalizedBlocks []*ftypes.IndexedBlock - s.Eventually(func() bool { - finalizedBlocks = nonValidatorNode.QueryListBlocks(ftypes.QueriedBlockStatus_FINALIZED) - return len(finalizedBlocks) > 0 - }, time.Minute, time.Millisecond*50) - s.Equal(activatedHeight, finalizedBlocks[0].Height) - s.Equal(appHash.Bytes(), finalizedBlocks[0].AppHash) - s.T().Logf("the block %d is finalized", activatedHeight) + nonValidatorNode.SubmitRefundableTxWithAssertion(func() { + // submit finality signature + nonValidatorNode.AddFinalitySig(s.cacheFP.BtcPk, activatedHeight, &randListInfo.PRList[idx], *randListInfo.ProofList[idx].ToProto(), appHash, eotsSig) + + // ensure vote is eventually cast + var finalizedBlocks []*ftypes.IndexedBlock + s.Eventually(func() bool { + finalizedBlocks = nonValidatorNode.QueryListBlocks(ftypes.QueriedBlockStatus_FINALIZED) + return len(finalizedBlocks) > 0 + }, time.Minute, time.Millisecond*50) + s.Equal(activatedHeight, finalizedBlocks[0].Height) + s.Equal(appHash.Bytes(), finalizedBlocks[0].AppHash) + s.T().Logf("the block %d is finalized", activatedHeight) + }, true) // ensure finality provider has received rewards after the block is finalised fpRewardGauges, err := nonValidatorNode.QueryRewardGauge(fpBabylonAddr) @@ -379,7 +382,7 @@ func (s *BTCStakingTestSuite) Test4WithdrawReward() { s.NoError(err) // finality provider balance before withdraw - fpBabylonAddr, err := sdk.AccAddressFromBech32(cacheFP.Addr) + fpBabylonAddr, err := sdk.AccAddressFromBech32(s.cacheFP.Addr) s.NoError(err) delBabylonAddr := fpBabylonAddr @@ -389,8 +392,8 @@ func (s *BTCStakingTestSuite) Test4WithdrawReward() { fpRgs, err := nonValidatorNode.QueryRewardGauge(fpBabylonAddr) s.NoError(err) fpRg := fpRgs[itypes.FinalityProviderType.String()] - s.T().Logf("finality provider's withdrawable reward before withdrawing: %s", fpRg.GetWithdrawableCoins().String()) - s.False(fpRg.IsFullyWithdrawn()) + s.T().Logf("finality provider's withdrawable reward before withdrawing: %s", convertToRewardGauge(fpRg).GetWithdrawableCoins().String()) + s.False(convertToRewardGauge(fpRg).IsFullyWithdrawn()) // withdraw finality provider reward nonValidatorNode.WithdrawReward(itypes.FinalityProviderType.String(), initialization.ValidatorWalletName) @@ -405,8 +408,8 @@ func (s *BTCStakingTestSuite) Test4WithdrawReward() { fpRgs2, err := nonValidatorNode.QueryRewardGauge(fpBabylonAddr) s.NoError(err) fpRg2 := fpRgs2[itypes.FinalityProviderType.String()] - s.T().Logf("finality provider's withdrawable reward after withdrawing: %s", fpRg2.GetWithdrawableCoins().String()) - s.True(fpRg2.IsFullyWithdrawn()) + s.T().Logf("finality provider's withdrawable reward after withdrawing: %s", convertToRewardGauge(fpRg2).GetWithdrawableCoins().String()) + s.True(convertToRewardGauge(fpRg2).IsFullyWithdrawn()) // BTC delegation balance before withdraw btcDelBalance, err := nonValidatorNode.QueryBalances(delBabylonAddr.String()) @@ -415,8 +418,8 @@ func (s *BTCStakingTestSuite) Test4WithdrawReward() { btcDelRgs, err := nonValidatorNode.QueryRewardGauge(delBabylonAddr) s.NoError(err) btcDelRg := btcDelRgs[itypes.BTCDelegationType.String()] - s.T().Logf("BTC delegation's withdrawable reward before withdrawing: %s", btcDelRg.GetWithdrawableCoins().String()) - s.False(btcDelRg.IsFullyWithdrawn()) + s.T().Logf("BTC delegation's withdrawable reward before withdrawing: %s", convertToRewardGauge(btcDelRg).GetWithdrawableCoins().String()) + s.False(convertToRewardGauge(btcDelRg).IsFullyWithdrawn()) // withdraw BTC delegation reward nonValidatorNode.WithdrawReward(itypes.BTCDelegationType.String(), initialization.ValidatorWalletName) @@ -431,8 +434,8 @@ func (s *BTCStakingTestSuite) Test4WithdrawReward() { btcDelRgs2, err := nonValidatorNode.QueryRewardGauge(delBabylonAddr) s.NoError(err) btcDelRg2 := btcDelRgs2[itypes.BTCDelegationType.String()] - s.T().Logf("BTC delegation's withdrawable reward after withdrawing: %s", btcDelRg2.GetWithdrawableCoins().String()) - s.True(btcDelRg2.IsFullyWithdrawn()) + s.T().Logf("BTC delegation's withdrawable reward after withdrawing: %s", convertToRewardGauge(btcDelRg2).GetWithdrawableCoins().String()) + s.True(convertToRewardGauge(btcDelRg2).IsFullyWithdrawn()) } // Test5SubmitStakerUnbonding is an end-to-end test for user unbonding @@ -444,7 +447,7 @@ func (s *BTCStakingTestSuite) Test5SubmitStakerUnbonding() { // wait for a block so that above txs take effect nonValidatorNode.WaitForNextBlock() - activeDelsSet := nonValidatorNode.QueryFinalityProviderDelegations(cacheFP.BtcPk.MarshalHex()) + activeDelsSet := nonValidatorNode.QueryFinalityProviderDelegations(s.cacheFP.BtcPk.MarshalHex()) s.Len(activeDelsSet, 1) activeDels := activeDelsSet[0] s.Len(activeDels.Dels, 1) @@ -458,15 +461,29 @@ func (s *BTCStakingTestSuite) Test5SubmitStakerUnbonding() { s.NoError(err) stakingTxHash := stakingMsgTx.TxHash() - // delegator signs unbonding tx - params := nonValidatorNode.QueryBTCStakingParams() - delUnbondingSig, err := activeDel.SignUnbondingTx(params, net, delBTCSK) + currentBtcTipResp, err := nonValidatorNode.QueryTip() + s.NoError(err) + currentBtcTip, err := chain.ParseBTCHeaderInfoResponseToInfo(currentBtcTipResp) s.NoError(err) - // submit the message for creating BTC undelegation - nonValidatorNode.BTCUndelegate(&stakingTxHash, delUnbondingSig) - // wait for a block so that above txs take effect - nonValidatorNode.WaitForNextBlock() + unbondingTx := activeDel.BtcUndelegation.UnbondingTx + unbondingTxMsg, err := bbn.NewBTCTxFromBytes(unbondingTx) + s.NoError(err) + + blockWithUnbondingTx := datagen.CreateBlockWithTransaction(s.r, currentBtcTip.Header.ToBlockHeader(), unbondingTxMsg) + nonValidatorNode.InsertHeader(&blockWithUnbondingTx.HeaderBytes) + inclusionProof := bstypes.NewInclusionProofFromSpvProof(blockWithUnbondingTx.SpvProof) + + nonValidatorNode.SubmitRefundableTxWithAssertion(func() { + // submit the message for creating BTC undelegation + nonValidatorNode.BTCUndelegate( + &stakingTxHash, + unbondingTxMsg, + inclusionProof, + ) + // wait for a block so that above txs take effect + nonValidatorNode.WaitForNextBlock() + }, true) // Wait for unbonded delegations to be created var unbondedDelsResp []*bstypes.BTCDelegationResponse @@ -506,25 +523,26 @@ func (s *BTCStakingTestSuite) Test6MultisigBTCDelegation() { // NOTE: we use the multisig address for the BTC delegation multisigStakerAddr := sdk.MustAccAddressFromBech32(multisigAddr) - pop, err := bstypes.NewPoPBTC(multisigStakerAddr, delBTCSK) + pop, err := bstypes.NewPoPBTC(multisigStakerAddr, s.delBTCSK) s.NoError(err) // generate staking tx and slashing tx stakingTimeBlocks := uint16(math.MaxUint16) - testStakingInfo, stakingTxInfo, testUnbondingInfo, delegatorSig := s.BTCStakingUnbondSlashInfo(nonValidatorNode, params, stakingTimeBlocks, cacheFP) + testStakingInfo, stakingTx, inclusionProof, testUnbondingInfo, delegatorSig := s.BTCStakingUnbondSlashInfo(nonValidatorNode, params, stakingTimeBlocks, s.cacheFP) - delUnbondingSlashingSig, err := testUnbondingInfo.GenDelSlashingTxSig(delBTCSK) + delUnbondingSlashingSig, err := testUnbondingInfo.GenDelSlashingTxSig(s.delBTCSK) s.NoError(err) // submit the message for only generate the Tx to create BTC delegation - delBTCPKs := []bbn.BIP340PubKey{*bbn.NewBIP340PubKeyFromBTCPK(delBTCPK)} + btcPK := bbn.NewBIP340PubKeyFromBTCPK(s.delBTCSK.PubKey()) jsonTx := nonValidatorNode.CreateBTCDelegation( - delBTCPKs, + *btcPK, pop, - stakingTxInfo, - []*bbn.BIP340PubKey{cacheFP.BtcPk}, + stakingTx, + inclusionProof, + []*bbn.BIP340PubKey{s.cacheFP.BtcPk}, stakingTimeBlocks, - btcutil.Amount(stakingValue), + btcutil.Amount(s.stakingValue), testStakingInfo.SlashingTx, delegatorSig, testUnbondingInfo.UnbondingTx, @@ -563,8 +581,7 @@ func (s *BTCStakingTestSuite) Test7BTCDelegationFeeGrant() { feePayerAddr := sdk.MustAccAddressFromBech32(nonValidatorNode.KeysAdd(wGranter)) granteeStakerAddr := sdk.MustAccAddressFromBech32(nonValidatorNode.KeysAdd(wGratee)) - feePayerBalanceBeforeBTCDel := sdk.NewCoin(params.DefaultBondDenom, sdkmath.NewInt(100000)) - fees := sdk.NewCoin(params.DefaultBondDenom, sdkmath.NewInt(50000)) + feePayerBalanceBeforeBTCDel := sdk.NewCoin(appparams.DefaultBondDenom, sdkmath.NewInt(100000)) // fund the granter nonValidatorNode.BankSendFromNode(feePayerAddr.String(), feePayerBalanceBeforeBTCDel.String()) @@ -577,14 +594,14 @@ func (s *BTCStakingTestSuite) Test7BTCDelegationFeeGrant() { unbondingTime := uint16(initialization.BabylonBtcFinalizationPeriod) + 1 // NOTE: we use the grantee staker address for the BTC delegation PoP - pop, err := bstypes.NewPoPBTC(granteeStakerAddr, delBTCSK) + pop, err := bstypes.NewPoPBTC(granteeStakerAddr, s.delBTCSK) s.NoError(err) // generate staking tx and slashing tx stakingTimeBlocks := uint16(math.MaxUint16) - 5 - testStakingInfo, stakingTxInfo, testUnbondingInfo, delegatorSig := s.BTCStakingUnbondSlashInfo(nonValidatorNode, btcStkParams, stakingTimeBlocks, cacheFP) + testStakingInfo, stakingTx, inclusionProof, testUnbondingInfo, delegatorSig := s.BTCStakingUnbondSlashInfo(nonValidatorNode, btcStkParams, stakingTimeBlocks, s.cacheFP) - delUnbondingSlashingSig, err := testUnbondingInfo.GenDelSlashingTxSig(delBTCSK) + delUnbondingSlashingSig, err := testUnbondingInfo.GenDelSlashingTxSig(s.delBTCSK) s.NoError(err) // conceive the fee grant from the payer to the staker. @@ -598,14 +615,15 @@ func (s *BTCStakingTestSuite) Test7BTCDelegationFeeGrant() { s.True(stakerBalances.IsZero()) // submit the message to create BTC delegation - delBTCPKs := []bbn.BIP340PubKey{*bbn.NewBIP340PubKeyFromBTCPK(delBTCPK)} + btcPK := bbn.NewBIP340PubKeyFromBTCPK(s.delBTCSK.PubKey()) nonValidatorNode.CreateBTCDelegation( - delBTCPKs, + *btcPK, pop, - stakingTxInfo, - []*bbn.BIP340PubKey{cacheFP.BtcPk}, + stakingTx, + inclusionProof, + []*bbn.BIP340PubKey{s.cacheFP.BtcPk}, stakingTimeBlocks, - btcutil.Amount(stakingValue), + btcutil.Amount(s.stakingValue), testStakingInfo.SlashingTx, delegatorSig, testUnbondingInfo.UnbondingTx, @@ -616,7 +634,6 @@ func (s *BTCStakingTestSuite) Test7BTCDelegationFeeGrant() { wGratee, false, fmt.Sprintf("--fee-granter=%s", feePayerAddr.String()), - fmt.Sprintf("--fees=%s", fees.String()), ) // wait for a block so that above txs take effect @@ -627,16 +644,16 @@ func (s *BTCStakingTestSuite) Test7BTCDelegationFeeGrant() { s.NotNil(delegation) s.Equal(granteeStakerAddr.String(), delegation.BtcDelegation.StakerAddr) - // verify the balances after the BTC delegation was submited + // verify the balances after the BTC delegation was submitted // the staker should continue to have zero as balance. stakerBalances, err = nonValidatorNode.QueryBalances(granteeStakerAddr.String()) s.NoError(err) s.True(stakerBalances.IsZero()) - // the fee payer should have the (feePayerBalanceBeforeBTCDel - fee) == currentBalance + // the fee payer should have the feePayerBalanceBeforeBTCDel > currentBalance feePayerBalances, err := nonValidatorNode.QueryBalances(feePayerAddr.String()) s.NoError(err) - s.Equal(feePayerBalanceBeforeBTCDel.Sub(fees).String(), feePayerBalances.String()) + s.True(feePayerBalanceBeforeBTCDel.Amount.GT(feePayerBalances.AmountOf(appparams.BaseCoinUnit))) } // Test8BTCDelegationFeeGrantTyped is an end-to-end test to create a BTC delegation @@ -653,9 +670,9 @@ func (s *BTCStakingTestSuite) Test8BTCDelegationFeeGrantTyped() { feePayerAddr := sdk.MustAccAddressFromBech32(node.KeysAdd(wGranter)) granteeStakerAddr := sdk.MustAccAddressFromBech32(node.KeysAdd(wGratee)) - feePayerBalanceBeforeBTCDel := sdk.NewCoin(params.DefaultBondDenom, sdkmath.NewInt(100000)) - stakerBalance := sdk.NewCoin(params.DefaultBondDenom, sdkmath.NewInt(100)) - fees := sdk.NewCoin(params.DefaultBondDenom, sdkmath.NewInt(50000)) + feePayerBalanceBeforeBTCDel := sdk.NewCoin(appparams.DefaultBondDenom, sdkmath.NewInt(100000)) + stakerBalance := sdk.NewCoin(appparams.DefaultBondDenom, sdkmath.NewInt(100)) + fees := sdk.NewCoin(appparams.DefaultBondDenom, sdkmath.NewInt(50000)) // fund the granter and the staker node.BankSendFromNode(feePayerAddr.String(), feePayerBalanceBeforeBTCDel.String()) @@ -669,14 +686,14 @@ func (s *BTCStakingTestSuite) Test8BTCDelegationFeeGrantTyped() { unbondingTime := uint16(initialization.BabylonBtcFinalizationPeriod) + 1 // NOTE: we use the grantee staker address for the BTC delegation PoP - pop, err := bstypes.NewPoPBTC(granteeStakerAddr, delBTCSK) + pop, err := bstypes.NewPoPBTC(granteeStakerAddr, s.delBTCSK) s.NoError(err) // generate staking tx and slashing tx stakingTimeBlocks := uint16(math.MaxUint16) - 2 - testStakingInfo, stakingTxInfo, testUnbondingInfo, delegatorSig := s.BTCStakingUnbondSlashInfo(node, btcStkParams, stakingTimeBlocks, cacheFP) + testStakingInfo, stakingTx, inclusionProof, testUnbondingInfo, delegatorSig := s.BTCStakingUnbondSlashInfo(node, btcStkParams, stakingTimeBlocks, s.cacheFP) - delUnbondingSlashingSig, err := testUnbondingInfo.GenDelSlashingTxSig(delBTCSK) + delUnbondingSlashingSig, err := testUnbondingInfo.GenDelSlashingTxSig(s.delBTCSK) s.NoError(err) // conceive the fee grant from the payer to the staker only for one specific msg type. @@ -733,14 +750,15 @@ func (s *BTCStakingTestSuite) Test8BTCDelegationFeeGrantTyped() { // s.Require().Contains(output, feegrant.ErrFeeLimitExceeded.Error()) // submit the message to create BTC delegation using the fee grant at the max of spend limit - btcPKs := []bbn.BIP340PubKey{*bbn.NewBIP340PubKeyFromBTCPK(delBTCPK)} + btcPK := bbn.NewBIP340PubKeyFromBTCPK(s.delBTCSK.PubKey()) node.CreateBTCDelegation( - btcPKs, + *btcPK, pop, - stakingTxInfo, - []*bbn.BIP340PubKey{cacheFP.BtcPk}, + stakingTx, + inclusionProof, + []*bbn.BIP340PubKey{s.cacheFP.BtcPk}, stakingTimeBlocks, - btcutil.Amount(stakingValue), + btcutil.Amount(s.stakingValue), testStakingInfo.SlashingTx, delegatorSig, testUnbondingInfo.UnbondingTx, @@ -751,7 +769,6 @@ func (s *BTCStakingTestSuite) Test8BTCDelegationFeeGrantTyped() { wGratee, false, fmt.Sprintf("--fee-granter=%s", feePayerAddr.String()), - fmt.Sprintf("--fees=%s", fees.String()), ) // wait for a block so that above txs take effect @@ -762,16 +779,16 @@ func (s *BTCStakingTestSuite) Test8BTCDelegationFeeGrantTyped() { s.NotNil(delegation) s.Equal(granteeStakerAddr.String(), delegation.BtcDelegation.StakerAddr) - // verify the balances after the BTC delegation was submited + // verify the balances after the BTC delegation was submitted // the staker should continue to have zero as balance. stakerBalances, err := node.QueryBalances(granteeStakerAddr.String()) s.NoError(err) s.Equal(stakerBalance.String(), stakerBalances.String()) - // the fee payer should have the (feePayerBalanceBeforeBTCDel - fee) == currentBalance + // the fee payer should have the feePayerBalanceBeforeBTCDel > currentBalance feePayerBalances, err := node.QueryBalances(feePayerAddr.String()) s.NoError(err) - s.Equal(feePayerBalanceBeforeBTCDel.Sub(fees).String(), feePayerBalances.String()) + s.True(feePayerBalanceBeforeBTCDel.Amount.GT(feePayerBalances.AmountOf(appparams.BaseCoinUnit))) } // ParseRespsBTCDelToBTCDel parses an BTC delegation response to BTC Delegation @@ -850,36 +867,50 @@ func ParseRespBTCDelToBTCDel(resp *bstypes.BTCDelegationResponse) (btcDel *bstyp DelegatorSlashingSig: delSlashingSig, } - if len(ud.DelegatorUnbondingSigHex) > 0 { - delUnbondingSig, err := bbn.NewBIP340SignatureFromHex(ud.DelegatorUnbondingSigHex) - if err != nil { - return nil, err + if ud.DelegatorUnbondingInfoResponse != nil { + var spendStakeTx []byte = make([]byte, 0) + if ud.DelegatorUnbondingInfoResponse.SpendStakeTxHex != "" { + spendStakeTx, err = hex.DecodeString(ud.DelegatorUnbondingInfoResponse.SpendStakeTxHex) + if err != nil { + return nil, err + } + } + + btcDel.BtcUndelegation.DelegatorUnbondingInfo = &bstypes.DelegatorUnbondingInfo{ + SpendStakeTx: spendStakeTx, } - btcDel.BtcUndelegation.DelegatorUnbondingSig = delUnbondingSig } } return btcDel, nil } -func (s *BTCStakingTestSuite) equalFinalityProviderResp(fp *bstypes.FinalityProvider, fpResp *bstypes.FinalityProviderResponse) { - s.Equal(fp.Description, fpResp.Description) - s.Equal(fp.Commission, fpResp.Commission) - s.Equal(fp.Addr, fpResp.Addr) - s.Equal(fp.BtcPk, fpResp.BtcPk) - s.Equal(fp.Pop, fpResp.Pop) - s.Equal(fp.SlashedBabylonHeight, fpResp.SlashedBabylonHeight) - s.Equal(fp.SlashedBtcHeight, fpResp.SlashedBtcHeight) +func equalFinalityProviderResp(t *testing.T, fp *bstypes.FinalityProvider, fpResp *bstypes.FinalityProviderResponse) { + require.Equal(t, fp.Description, fpResp.Description) + require.Equal(t, fp.Commission, fpResp.Commission) + require.Equal(t, fp.Addr, fpResp.Addr) + require.Equal(t, fp.BtcPk, fpResp.BtcPk) + require.Equal(t, fp.Pop, fpResp.Pop) + require.Equal(t, fp.SlashedBabylonHeight, fpResp.SlashedBabylonHeight) + require.Equal(t, fp.SlashedBtcHeight, fpResp.SlashedBtcHeight) } // CreateNodeFP creates a random finality provider. -func (s *BTCStakingTestSuite) CreateNodeFP(node *chain.NodeConfig) (newFP *bstypes.FinalityProvider) { +func CreateNodeFP( + t *testing.T, + r *rand.Rand, + fpSk *btcec.PrivateKey, + node *chain.NodeConfig) (newFP *bstypes.FinalityProvider) { // the node is the new FP nodeAddr, err := sdk.AccAddressFromBech32(node.PublicAddress) - s.NoError(err) + require.NoError(t, err) - newFP, err = datagen.GenCustomFinalityProvider(r, fpBTCSK, nodeAddr, "") - s.NoError(err) + newFP, err = datagen.GenCustomFinalityProvider(r, fpSk, nodeAddr, "") + require.NoError(t, err) + + // use a higher commission to ensure the reward is more than tx fee of a finality sig + commission := sdkmath.LegacyNewDecWithPrec(20, 2) + newFP.Commission = &commission node.CreateFinalityProvider(newFP.Addr, newFP.BtcPk, newFP.Pop, newFP.Description.Moniker, newFP.Description.Identity, newFP.Description.Website, newFP.Description.SecurityContact, newFP.Description.Details, newFP.Commission) // wait for a block so that above txs take effect @@ -887,8 +918,9 @@ func (s *BTCStakingTestSuite) CreateNodeFP(node *chain.NodeConfig) (newFP *bstyp // query the existence of finality provider and assert equivalence actualFps := node.QueryFinalityProviders() - s.Len(actualFps, 1) - s.equalFinalityProviderResp(newFP, actualFps[0]) + require.Len(t, actualFps, 1) + + equalFinalityProviderResp(t, newFP, actualFps[0]) return newFP } @@ -911,7 +943,8 @@ func (s *BTCStakingTestSuite) BTCStakingUnbondSlashInfo( fp *bstypes.FinalityProvider, ) ( testStakingInfo *datagen.TestStakingSlashingInfo, - stakingTxInfo *btcctypes.TransactionInfo, + stakingTx []byte, + txInclusionProof *bstypes.InclusionProof, testUnbondingInfo *datagen.TestUnbondingSlashingInfo, delegatorSig *bbn.BIP340Signature, ) { @@ -920,15 +953,15 @@ func (s *BTCStakingTestSuite) BTCStakingUnbondSlashInfo( unbondingTime := uint16(initialization.BabylonBtcFinalizationPeriod) + 1 testStakingInfo = datagen.GenBTCStakingSlashingInfo( - r, + s.r, s.T(), - net, - delBTCSK, + s.net, + s.delBTCSK, []*btcec.PublicKey{fp.BtcPk.MustToBTCPK()}, covenantBTCPKs, - covenantQuorum, + s.covenantQuorum, stakingTimeBlocks, - stakingValue, + s.stakingValue, params.SlashingPkScript, params.SlashingRate, unbondingTime, @@ -942,25 +975,25 @@ func (s *BTCStakingTestSuite) BTCStakingUnbondSlashInfo( stakingMsgTx := testStakingInfo.StakingTx - blockWithStakingTx := datagen.CreateBlockWithTransaction(r, currentBtcTip.Header.ToBlockHeader(), stakingMsgTx) + blockWithStakingTx := datagen.CreateBlockWithTransaction(s.r, currentBtcTip.Header.ToBlockHeader(), stakingMsgTx) node.InsertHeader(&blockWithStakingTx.HeaderBytes) // make block k-deep for i := 0; i < initialization.BabylonBtcConfirmationPeriod; i++ { - node.InsertNewEmptyBtcHeader(r) + node.InsertNewEmptyBtcHeader(s.r) } - stakingTxInfo = btcctypes.NewTransactionInfoFromSpvProof(blockWithStakingTx.SpvProof) + inclusionProof := bstypes.NewInclusionProofFromSpvProof(blockWithStakingTx.SpvProof) // generate BTC undelegation stuff stkTxHash := testStakingInfo.StakingTx.TxHash() - unbondingValue := stakingValue - datagen.UnbondingTxFee + unbondingValue := s.stakingValue - datagen.UnbondingTxFee testUnbondingInfo = datagen.GenBTCUnbondingSlashingInfo( - r, + s.r, s.T(), - net, - delBTCSK, + s.net, + s.delBTCSK, []*btcec.PublicKey{fp.BtcPk.MustToBTCPK()}, covenantBTCPKs, - covenantQuorum, + s.covenantQuorum, wire.NewOutPoint(&stkTxHash, datagen.StakingOutIdx), stakingTimeBlocks, unbondingValue, @@ -976,9 +1009,16 @@ func (s *BTCStakingTestSuite) BTCStakingUnbondSlashInfo( stakingMsgTx, datagen.StakingOutIdx, stakingSlashingPathInfo.GetPkScriptPath(), - delBTCSK, + s.delBTCSK, ) s.NoError(err) - return testStakingInfo, stakingTxInfo, testUnbondingInfo, delegatorSig + return testStakingInfo, blockWithStakingTx.SpvProof.BtcTransaction, inclusionProof, testUnbondingInfo, delegatorSig +} + +func convertToRewardGauge(rg *itypes.RewardGaugesResponse) *itypes.RewardGauge { + return &itypes.RewardGauge{ + Coins: rg.Coins, + WithdrawnCoins: rg.WithdrawnCoins, + } } diff --git a/test/e2e/btc_staking_integration_e2e_test.go b/test/e2e/btc_staking_integration_e2e_test.go index f8c32c367..1c47d8a78 100644 --- a/test/e2e/btc_staking_integration_e2e_test.go +++ b/test/e2e/btc_staking_integration_e2e_test.go @@ -3,6 +3,7 @@ package e2e import ( "encoding/hex" "math" + "math/rand" "time" "github.com/babylonlabs-io/babylon/test/e2e/configurer" @@ -10,11 +11,11 @@ import ( "github.com/babylonlabs-io/babylon/test/e2e/initialization" "github.com/babylonlabs-io/babylon/testutil/datagen" bbn "github.com/babylonlabs-io/babylon/types" - btcctypes "github.com/babylonlabs-io/babylon/x/btccheckpoint/types" bstypes "github.com/babylonlabs-io/babylon/x/btcstaking/types" bsctypes "github.com/babylonlabs-io/babylon/x/btcstkconsumer/types" "github.com/btcsuite/btcd/btcec/v2" "github.com/btcsuite/btcd/btcutil" + "github.com/btcsuite/btcd/chaincfg" "github.com/btcsuite/btcd/wire" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/query" @@ -23,7 +24,14 @@ import ( ) var ( - czDelBtcSk, czDelBtcPk, _ = datagen.GenRandomBTCKeyPair(r) + r = rand.New(rand.NewSource(time.Now().Unix())) + net = &chaincfg.SimNetParams + // BTC delegation + delBTCSK, delBTCPK, _ = datagen.GenRandomBTCKeyPair(r) + // covenant + covenantSKs, _, covenantQuorum = bstypes.DefaultCovenantCommittee() + + stakingValue = int64(2 * 10e8) ) type BTCStakingIntegrationTestSuite struct { @@ -283,13 +291,20 @@ func (s *BTCStakingIntegrationTestSuite) Test5UnbondDelegation() { s.NoError(err) stakingTxHash := stakingMsgTx.TxHash() - // delegator signs unbonding tx - params := nonValidatorNode.QueryBTCStakingParams() - delUnbondingSig, err := activeDel.SignUnbondingTx(params, net, czDelBtcSk) + // get unbonding tx + unbondingTx := activeDel.BtcUndelegation.UnbondingTx + unbondingTxMsg, err := bbn.NewBTCTxFromBytes(unbondingTx) s.NoError(err) - + // get inclusion proof of the unbonding tx + currentBtcTipResp, err := nonValidatorNode.QueryTip() + s.NoError(err) + currentBtcTip, err := chain.ParseBTCHeaderInfoResponseToInfo(currentBtcTipResp) + s.NoError(err) + blockWithUnbondingTx := datagen.CreateBlockWithTransaction(r, currentBtcTip.Header.ToBlockHeader(), unbondingTxMsg) + nonValidatorNode.InsertHeader(&blockWithUnbondingTx.HeaderBytes) + inclusionProof := bstypes.NewInclusionProofFromSpvProof(blockWithUnbondingTx.SpvProof) // submit the message for creating BTC undelegation - nonValidatorNode.BTCUndelegate(&stakingTxHash, delUnbondingSig) + nonValidatorNode.BTCUndelegate(&stakingTxHash, unbondingTxMsg, inclusionProof) // wait for a block so that above txs take effect nonValidatorNode.WaitForNextBlock() @@ -512,7 +527,7 @@ func (s *BTCStakingIntegrationTestSuite) createBabylonDelegation(nonValidatorNod covenantBTCPKs = append(covenantBTCPKs, covenantPK.MustToBTCPK()) } // NOTE: we use the node's secret key as Babylon secret key for the BTC delegation - pop, err := bstypes.NewPoPBTC(delBabylonAddr, czDelBtcSk) + pop, err := bstypes.NewPoPBTC(delBabylonAddr, delBTCSK) s.NoError(err) // generate staking tx and slashing tx stakingTimeBlocks := uint16(math.MaxUint16) @@ -520,7 +535,7 @@ func (s *BTCStakingIntegrationTestSuite) createBabylonDelegation(nonValidatorNod r, s.T(), net, - czDelBtcSk, + delBTCSK, []*btcec.PublicKey{babylonFp.BtcPk.MustToBTCPK(), consumerFp.BtcPk.MustToBTCPK()}, covenantBTCPKs, covenantQuorum, @@ -532,6 +547,8 @@ func (s *BTCStakingIntegrationTestSuite) createBabylonDelegation(nonValidatorNod ) stakingMsgTx := testStakingInfo.StakingTx + stakingMsgTxBytes, err := bbn.SerializeBTCTx(stakingMsgTx) + s.NoError(err) stakingTxHash := stakingMsgTx.TxHash().String() stakingSlashingPathInfo, err := testStakingInfo.StakingInfo.SlashingPathSpendInfo() s.NoError(err) @@ -541,7 +558,7 @@ func (s *BTCStakingIntegrationTestSuite) createBabylonDelegation(nonValidatorNod stakingMsgTx, datagen.StakingOutIdx, stakingSlashingPathInfo.GetPkScriptPath(), - czDelBtcSk, + delBTCSK, ) s.NoError(err) @@ -557,7 +574,7 @@ func (s *BTCStakingIntegrationTestSuite) createBabylonDelegation(nonValidatorNod for i := 0; i < initialization.BabylonBtcConfirmationPeriod; i++ { nonValidatorNode.InsertNewEmptyBtcHeader(r) } - stakingTxInfo := btcctypes.NewTransactionInfoFromSpvProof(blockWithStakingTx.SpvProof) + inclusionProof := bstypes.NewInclusionProofFromSpvProof(blockWithStakingTx.SpvProof) // generate BTC undelegation stuff stkTxHash := testStakingInfo.StakingTx.TxHash() @@ -566,7 +583,7 @@ func (s *BTCStakingIntegrationTestSuite) createBabylonDelegation(nonValidatorNod r, s.T(), net, - czDelBtcSk, + delBTCSK, []*btcec.PublicKey{babylonFp.BtcPk.MustToBTCPK(), consumerFp.BtcPk.MustToBTCPK()}, covenantBTCPKs, covenantQuorum, @@ -577,15 +594,16 @@ func (s *BTCStakingIntegrationTestSuite) createBabylonDelegation(nonValidatorNod params.SlashingRate, unbondingTime, ) - delUnbondingSlashingSig, err := testUnbondingInfo.GenDelSlashingTxSig(czDelBtcSk) + delUnbondingSlashingSig, err := testUnbondingInfo.GenDelSlashingTxSig(delBTCSK) s.NoError(err) // submit the message for creating BTC delegation - delBTCPKs := []bbn.BIP340PubKey{*bbn.NewBIP340PubKeyFromBTCPK(czDelBtcPk)} + delBtcPK := bbn.NewBIP340PubKeyFromBTCPK(delBTCPK) nonValidatorNode.CreateBTCDelegation( - delBTCPKs, + *delBtcPK, pop, - stakingTxInfo, + stakingMsgTxBytes, + inclusionProof, []*bbn.BIP340PubKey{babylonFp.BtcPk, consumerFp.BtcPk}, stakingTimeBlocks, btcutil.Amount(stakingValue), @@ -604,7 +622,7 @@ func (s *BTCStakingIntegrationTestSuite) createBabylonDelegation(nonValidatorNod nonValidatorNode.WaitForNextBlock() nonValidatorNode.WaitForNextBlock() - return czDelBtcPk, stakingTxHash + return delBTCPK, stakingTxHash } // helper function: verify if the ibc channels are open and get the ibc client id of the CZ node diff --git a/test/e2e/btc_staking_pre_approval_e2e_test.go b/test/e2e/btc_staking_pre_approval_e2e_test.go new file mode 100644 index 000000000..015b0bb11 --- /dev/null +++ b/test/e2e/btc_staking_pre_approval_e2e_test.go @@ -0,0 +1,603 @@ +package e2e + +import ( + "math" + "math/rand" + "time" + + "github.com/btcsuite/btcd/btcec/v2" + "github.com/btcsuite/btcd/btcutil" + "github.com/btcsuite/btcd/chaincfg" + "github.com/btcsuite/btcd/wire" + "github.com/stretchr/testify/suite" + + sdk "github.com/cosmos/cosmos-sdk/types" + + "github.com/babylonlabs-io/babylon/crypto/eots" + "github.com/babylonlabs-io/babylon/test/e2e/configurer" + "github.com/babylonlabs-io/babylon/test/e2e/configurer/chain" + "github.com/babylonlabs-io/babylon/test/e2e/initialization" + "github.com/babylonlabs-io/babylon/testutil/datagen" + bbn "github.com/babylonlabs-io/babylon/types" + bstypes "github.com/babylonlabs-io/babylon/x/btcstaking/types" + ckpttypes "github.com/babylonlabs-io/babylon/x/checkpointing/types" + ftypes "github.com/babylonlabs-io/babylon/x/finality/types" + itypes "github.com/babylonlabs-io/babylon/x/incentive/types" +) + +type BTCStakingPreApprovalTestSuite struct { + suite.Suite + + r *rand.Rand + net *chaincfg.Params + fptBTCSK *btcec.PrivateKey + delBTCSK *btcec.PrivateKey + cacheFP *bstypes.FinalityProvider + cachedInclusionProof *bstypes.InclusionProof + covenantSKs []*btcec.PrivateKey + covenantQuorum uint32 + stakingValue int64 + configurer configurer.Configurer +} + +func (s *BTCStakingPreApprovalTestSuite) SetupSuite() { + s.T().Log("setting up e2e integration test suite...") + var err error + + s.r = rand.New(rand.NewSource(time.Now().Unix())) + s.net = &chaincfg.SimNetParams + s.fptBTCSK, _, _ = datagen.GenRandomBTCKeyPair(s.r) + s.delBTCSK, _, _ = datagen.GenRandomBTCKeyPair(s.r) + s.stakingValue = int64(2 * 10e8) + covenantSKs, _, covenantQuorum := bstypes.DefaultCovenantCommittee() + s.covenantSKs = covenantSKs + s.covenantQuorum = covenantQuorum + + // The e2e test flow is as follows: + // + // 1. Configure 1 chain with some validator nodes + // 2. Execute various e2e tests + s.configurer, err = configurer.NewBTCStakingConfigurer(s.T(), true) + s.NoError(err) + err = s.configurer.ConfigureChains() + s.NoError(err) + err = s.configurer.RunSetup() + s.NoError(err) +} + +func (s *BTCStakingPreApprovalTestSuite) TearDownSuite() { + err := s.configurer.ClearResources() + if err != nil { + s.T().Logf("error to clear resources %s", err.Error()) + } +} + +func (s *BTCStakingPreApprovalTestSuite) Test1CreateFinalityProviderAndDelegation() { + chainA := s.configurer.GetChainConfig(0) + chainA.WaitUntilHeight(1) + nonValidatorNode, err := chainA.GetNodeAtIndex(2) + s.NoError(err) + + s.cacheFP = CreateNodeFP( + s.T(), + s.r, + s.fptBTCSK, + nonValidatorNode, + ) + + /* + create a random BTC delegation under this finality provider + */ + // BTC staking params, BTC delegation key pairs and PoP + params := nonValidatorNode.QueryBTCStakingParams() + + // minimal required unbonding time + unbondingTime := uint16(initialization.BabylonBtcFinalizationPeriod) + 1 + + // NOTE: we use the node's address for the BTC delegation + stakerAddr := sdk.MustAccAddressFromBech32(nonValidatorNode.PublicAddress) + pop, err := bstypes.NewPoPBTC(stakerAddr, s.delBTCSK) + s.NoError(err) + + // generate staking tx and slashing tx + stakingTimeBlocks := uint16(math.MaxUint16) + testStakingInfo, stakingTx, inclusionProof, testUnbondingInfo, delegatorSig := s.BTCStakingUnbondSlashInfo(nonValidatorNode, params, stakingTimeBlocks, s.cacheFP) + s.cachedInclusionProof = inclusionProof + + delUnbondingSlashingSig, err := testUnbondingInfo.GenDelSlashingTxSig(s.delBTCSK) + s.NoError(err) + + // submit the message for creating BTC delegation + delBtcPK := bbn.NewBIP340PubKeyFromBTCPK(s.delBTCSK.PubKey()) + nonValidatorNode.CreateBTCDelegation( + *delBtcPK, + pop, + stakingTx, + // We are passing `nil` as inclusion proof will be provided in separate tx + nil, + []*bbn.BIP340PubKey{s.cacheFP.BtcPk}, + stakingTimeBlocks, + btcutil.Amount(s.stakingValue), + testStakingInfo.SlashingTx, + delegatorSig, + testUnbondingInfo.UnbondingTx, + testUnbondingInfo.SlashingTx, + uint16(unbondingTime), + btcutil.Amount(testUnbondingInfo.UnbondingInfo.UnbondingOutput.Value), + delUnbondingSlashingSig, + nonValidatorNode.WalletName, + false, + ) + + // wait for a block so that above txs take effect + nonValidatorNode.WaitForNextBlock() + + pendingDelSet := nonValidatorNode.QueryFinalityProviderDelegations(s.cacheFP.BtcPk.MarshalHex()) + s.Len(pendingDelSet, 1) + pendingDels := pendingDelSet[0] + s.Len(pendingDels.Dels, 1) + s.Equal(s.delBTCSK.PubKey().SerializeCompressed()[1:], pendingDels.Dels[0].BtcPk.MustToBTCPK().SerializeCompressed()[1:]) + s.Len(pendingDels.Dels[0].CovenantSigs, 0) + + // check delegation + delegation := nonValidatorNode.QueryBtcDelegation(testStakingInfo.StakingTx.TxHash().String()) + s.NotNil(delegation) + s.Equal(delegation.BtcDelegation.StakerAddr, nonValidatorNode.PublicAddress) +} + +func (s *BTCStakingPreApprovalTestSuite) Test2SubmitCovenantSignature() { + chainA := s.configurer.GetChainConfig(0) + chainA.WaitUntilHeight(1) + nonValidatorNode, err := chainA.GetNodeAtIndex(2) + s.NoError(err) + + // get last BTC delegation + pendingDelsSet := nonValidatorNode.QueryFinalityProviderDelegations(s.cacheFP.BtcPk.MarshalHex()) + s.Len(pendingDelsSet, 1) + pendingDels := pendingDelsSet[0] + s.Len(pendingDels.Dels, 1) + pendingDelResp := pendingDels.Dels[0] + pendingDel, err := ParseRespBTCDelToBTCDel(pendingDelResp) + s.NoError(err) + s.Len(pendingDel.CovenantSigs, 0) + + slashingTx := pendingDel.SlashingTx + stakingTx := pendingDel.StakingTx + + stakingMsgTx, err := bbn.NewBTCTxFromBytes(stakingTx) + s.NoError(err) + stakingTxHash := stakingMsgTx.TxHash().String() + + params := nonValidatorNode.QueryBTCStakingParams() + + fpBTCPKs, err := bbn.NewBTCPKsFromBIP340PKs(pendingDel.FpBtcPkList) + s.NoError(err) + + stakingInfo, err := pendingDel.GetStakingInfo(params, s.net) + s.NoError(err) + + stakingSlashingPathInfo, err := stakingInfo.SlashingPathSpendInfo() + s.NoError(err) + + /* + generate and insert new covenant signature, in order to activate the BTC delegation + */ + // covenant signatures on slashing tx + covenantSlashingSigs, err := datagen.GenCovenantAdaptorSigs( + s.covenantSKs, + fpBTCPKs, + stakingMsgTx, + stakingSlashingPathInfo.GetPkScriptPath(), + slashingTx, + ) + s.NoError(err) + + // cov Schnorr sigs on unbonding signature + unbondingPathInfo, err := stakingInfo.UnbondingPathSpendInfo() + s.NoError(err) + unbondingTx, err := bbn.NewBTCTxFromBytes(pendingDel.BtcUndelegation.UnbondingTx) + s.NoError(err) + + covUnbondingSigs, err := datagen.GenCovenantUnbondingSigs( + s.covenantSKs, + stakingMsgTx, + pendingDel.StakingOutputIdx, + unbondingPathInfo.GetPkScriptPath(), + unbondingTx, + ) + s.NoError(err) + + unbondingInfo, err := pendingDel.GetUnbondingInfo(params, s.net) + s.NoError(err) + unbondingSlashingPathInfo, err := unbondingInfo.SlashingPathSpendInfo() + s.NoError(err) + covenantUnbondingSlashingSigs, err := datagen.GenCovenantAdaptorSigs( + s.covenantSKs, + fpBTCPKs, + unbondingTx, + unbondingSlashingPathInfo.GetPkScriptPath(), + pendingDel.BtcUndelegation.SlashingTx, + ) + s.NoError(err) + + for i := 0; i < int(s.covenantQuorum); i++ { + nonValidatorNode.SubmitRefundableTxWithAssertion(func() { + nonValidatorNode.AddCovenantSigs( + covenantSlashingSigs[i].CovPk, + stakingTxHash, + covenantSlashingSigs[i].AdaptorSigs, + bbn.NewBIP340SignatureFromBTCSig(covUnbondingSigs[i]), + covenantUnbondingSlashingSigs[i].AdaptorSigs, + ) + // wait for a block so that above txs take effect + nonValidatorNode.WaitForNextBlock() + }, true) + } + + // wait for a block so that above txs take effect + nonValidatorNode.WaitForNextBlock() + nonValidatorNode.WaitForNextBlock() + + // ensure the BTC delegation has covenant sigs now + activeDelsSet := nonValidatorNode.QueryFinalityProviderDelegations(s.cacheFP.BtcPk.MarshalHex()) + s.Len(activeDelsSet, 1) + + activeDels, err := ParseRespsBTCDelToBTCDel(activeDelsSet[0]) + s.NoError(err) + s.NotNil(activeDels) + s.Len(activeDels.Dels, 1) + + activeDel := activeDels.Dels[0] + s.True(activeDel.HasCovenantQuorums(s.covenantQuorum)) +} + +func (s *BTCStakingPreApprovalTestSuite) Test3SendStakingTransctionInclusionProof() { + chainA := s.configurer.GetChainConfig(0) + chainA.WaitUntilHeight(1) + nonValidatorNode, err := chainA.GetNodeAtIndex(2) + s.NoError(err) + + verifiedDelegations := nonValidatorNode.QueryVerifiedDelegations() + s.Len(verifiedDelegations, 1) + + btcDel, err := ParseRespBTCDelToBTCDel(verifiedDelegations[0]) + s.NoError(err) + s.True(btcDel.HasCovenantQuorums(s.covenantQuorum)) + + // staking tx hash + stakingMsgTx, err := bbn.NewBTCTxFromBytes(btcDel.StakingTx) + s.NoError(err) + stakingTxHash := stakingMsgTx.TxHash() + + nonValidatorNode.SubmitRefundableTxWithAssertion(func() { + nonValidatorNode.AddBTCDelegationInclusionProof( + &stakingTxHash, + s.cachedInclusionProof, + ) + nonValidatorNode.WaitForNextBlock() + nonValidatorNode.WaitForNextBlock() + }, true) + + activeBTCDelegations := nonValidatorNode.QueryActiveDelegations() + s.Len(activeBTCDelegations, 1) + nonValidatorNode.WaitForNextBlock() +} + +func (s *BTCStakingPreApprovalTestSuite) Test4CommitPublicRandomnessAndSubmitFinalitySignature() { + chainA := s.configurer.GetChainConfig(0) + chainA.WaitUntilHeight(1) + nonValidatorNode, err := chainA.GetNodeAtIndex(2) + s.NoError(err) + + /* + commit a number of public randomness + */ + // commit public randomness list + numPubRand := uint64(100) + commitStartHeight := uint64(1) + randListInfo, msgCommitPubRandList, err := datagen.GenRandomMsgCommitPubRandList(s.r, s.fptBTCSK, commitStartHeight, numPubRand) + s.NoError(err) + nonValidatorNode.CommitPubRandList( + msgCommitPubRandList.FpBtcPk, + msgCommitPubRandList.StartHeight, + msgCommitPubRandList.NumPubRand, + msgCommitPubRandList.Commitment, + msgCommitPubRandList.Sig, + ) + + // no reward gauge for finality provider and delegation yet + fpBabylonAddr, err := sdk.AccAddressFromBech32(s.cacheFP.Addr) + s.NoError(err) + + _, err = nonValidatorNode.QueryRewardGauge(fpBabylonAddr) + s.ErrorContains(err, itypes.ErrRewardGaugeNotFound.Error()) + delBabylonAddr := fpBabylonAddr + + // finalize epochs from 1 to the current epoch + currentEpoch, err := nonValidatorNode.QueryCurrentEpoch() + s.NoError(err) + + // wait until the end epoch is sealed + s.Eventually(func() bool { + resp, err := nonValidatorNode.QueryRawCheckpoint(currentEpoch) + if err != nil { + return false + } + return resp.Status == ckpttypes.Sealed + }, time.Minute, time.Millisecond*50) + nonValidatorNode.FinalizeSealedEpochs(1, currentEpoch) + + // ensure the committed epoch is finalized + lastFinalizedEpoch := uint64(0) + s.Eventually(func() bool { + lastFinalizedEpoch, err = nonValidatorNode.QueryLastFinalizedEpoch() + if err != nil { + return false + } + return lastFinalizedEpoch >= currentEpoch + }, time.Minute, time.Millisecond*50) + + // ensure btc staking is activated + var activatedHeight uint64 + s.Eventually(func() bool { + activatedHeight, err = nonValidatorNode.QueryActivatedHeight() + if err != nil { + return false + } + return activatedHeight > 0 + }, time.Minute, time.Millisecond*50) + s.T().Logf("the activated height is %d", activatedHeight) + + /* + submit finality signature + */ + // get block to vote + blockToVote, err := nonValidatorNode.QueryBlock(int64(activatedHeight)) + s.NoError(err) + appHash := blockToVote.AppHash + + idx := activatedHeight - commitStartHeight + msgToSign := append(sdk.Uint64ToBigEndian(activatedHeight), appHash...) + // generate EOTS signature + sig, err := eots.Sign(s.fptBTCSK, randListInfo.SRList[idx], msgToSign) + s.NoError(err) + eotsSig := bbn.NewSchnorrEOTSSigFromModNScalar(sig) + // submit finality signature + nonValidatorNode.SubmitRefundableTxWithAssertion(func() { + nonValidatorNode.AddFinalitySig(s.cacheFP.BtcPk, activatedHeight, &randListInfo.PRList[idx], *randListInfo.ProofList[idx].ToProto(), appHash, eotsSig) + + // ensure vote is eventually cast + var finalizedBlocks []*ftypes.IndexedBlock + s.Eventually(func() bool { + finalizedBlocks = nonValidatorNode.QueryListBlocks(ftypes.QueriedBlockStatus_FINALIZED) + return len(finalizedBlocks) > 0 + }, time.Minute, time.Millisecond*50) + s.Equal(activatedHeight, finalizedBlocks[0].Height) + s.Equal(appHash.Bytes(), finalizedBlocks[0].AppHash) + s.T().Logf("the block %d is finalized", activatedHeight) + }, true) + + // submit an invalid finality signature, and tx should NOT be refunded + nonValidatorNode.SubmitRefundableTxWithAssertion(func() { + _, pk, err := datagen.GenRandomBTCKeyPair(s.r) + s.NoError(err) + btcPK := bbn.NewBIP340PubKeyFromBTCPK(pk) + nonValidatorNode.AddFinalitySig(btcPK, activatedHeight, &randListInfo.PRList[idx], *randListInfo.ProofList[idx].ToProto(), appHash, eotsSig) + nonValidatorNode.WaitForNextBlock() + }, false) + + // ensure finality provider has received rewards after the block is finalised + fpRewardGauges, err := nonValidatorNode.QueryRewardGauge(fpBabylonAddr) + s.NoError(err) + fpRewardGauge, ok := fpRewardGauges[itypes.FinalityProviderType.String()] + s.True(ok) + s.True(fpRewardGauge.Coins.IsAllPositive()) + // ensure BTC delegation has received rewards after the block is finalised + btcDelRewardGauges, err := nonValidatorNode.QueryRewardGauge(delBabylonAddr) + s.NoError(err) + btcDelRewardGauge, ok := btcDelRewardGauges[itypes.BTCDelegationType.String()] + s.True(ok) + s.True(btcDelRewardGauge.Coins.IsAllPositive()) + s.T().Logf("the finality provider received rewards for providing finality") +} + +func (s *BTCStakingPreApprovalTestSuite) Test4WithdrawReward() { + chainA := s.configurer.GetChainConfig(0) + nonValidatorNode, err := chainA.GetNodeAtIndex(2) + s.NoError(err) + + // finality provider balance before withdraw + fpBabylonAddr, err := sdk.AccAddressFromBech32(s.cacheFP.Addr) + s.NoError(err) + delBabylonAddr := fpBabylonAddr + + fpBalance, err := nonValidatorNode.QueryBalances(fpBabylonAddr.String()) + s.NoError(err) + // finality provider reward gauge should not be fully withdrawn + fpRgs, err := nonValidatorNode.QueryRewardGauge(fpBabylonAddr) + s.NoError(err) + fpRg := fpRgs[itypes.FinalityProviderType.String()] + s.T().Logf("finality provider's withdrawable reward before withdrawing: %s", convertToRewardGauge(fpRg).GetWithdrawableCoins().String()) + s.False(convertToRewardGauge(fpRg).IsFullyWithdrawn()) + + // withdraw finality provider reward + nonValidatorNode.WithdrawReward(itypes.FinalityProviderType.String(), initialization.ValidatorWalletName) + nonValidatorNode.WaitForNextBlock() + + // balance after withdrawing finality provider reward + fpBalance2, err := nonValidatorNode.QueryBalances(fpBabylonAddr.String()) + s.NoError(err) + s.T().Logf("fpBalance2: %s; fpBalance: %s", fpBalance2.String(), fpBalance.String()) + s.True(fpBalance2.IsAllGT(fpBalance)) + // finality provider reward gauge should be fully withdrawn now + fpRgs2, err := nonValidatorNode.QueryRewardGauge(fpBabylonAddr) + s.NoError(err) + fpRg2 := fpRgs2[itypes.FinalityProviderType.String()] + s.T().Logf("finality provider's withdrawable reward after withdrawing: %s", convertToRewardGauge(fpRg2).GetWithdrawableCoins().String()) + s.True(convertToRewardGauge(fpRg2).IsFullyWithdrawn()) + + // BTC delegation balance before withdraw + btcDelBalance, err := nonValidatorNode.QueryBalances(delBabylonAddr.String()) + s.NoError(err) + // BTC delegation reward gauge should not be fully withdrawn + btcDelRgs, err := nonValidatorNode.QueryRewardGauge(delBabylonAddr) + s.NoError(err) + btcDelRg := btcDelRgs[itypes.BTCDelegationType.String()] + s.T().Logf("BTC delegation's withdrawable reward before withdrawing: %s", convertToRewardGauge(btcDelRg).GetWithdrawableCoins().String()) + s.False(convertToRewardGauge(btcDelRg).IsFullyWithdrawn()) + + // withdraw BTC delegation reward + nonValidatorNode.WithdrawReward(itypes.BTCDelegationType.String(), initialization.ValidatorWalletName) + nonValidatorNode.WaitForNextBlock() + + // balance after withdrawing BTC delegation reward + btcDelBalance2, err := nonValidatorNode.QueryBalances(delBabylonAddr.String()) + s.NoError(err) + s.T().Logf("btcDelBalance2: %s; btcDelBalance: %s", btcDelBalance2.String(), btcDelBalance.String()) + s.True(btcDelBalance2.IsAllGT(btcDelBalance)) + // BTC delegation reward gauge should be fully withdrawn now + btcDelRgs2, err := nonValidatorNode.QueryRewardGauge(delBabylonAddr) + s.NoError(err) + btcDelRg2 := convertToRewardGauge(btcDelRgs2[itypes.BTCDelegationType.String()]) + s.T().Logf("BTC delegation's withdrawable reward after withdrawing: %s", btcDelRg2.GetWithdrawableCoins().String()) + s.True(btcDelRg2.IsFullyWithdrawn()) +} + +// Test5SubmitStakerUnbonding is an end-to-end test for user unbonding +func (s *BTCStakingPreApprovalTestSuite) Test5SubmitStakerUnbonding() { + chainA := s.configurer.GetChainConfig(0) + chainA.WaitUntilHeight(1) + nonValidatorNode, err := chainA.GetNodeAtIndex(2) + s.NoError(err) + // wait for a block so that above txs take effect + nonValidatorNode.WaitForNextBlock() + + activeDelsSet := nonValidatorNode.QueryFinalityProviderDelegations(s.cacheFP.BtcPk.MarshalHex()) + s.Len(activeDelsSet, 1) + activeDels := activeDelsSet[0] + s.Len(activeDels.Dels, 1) + activeDelResp := activeDels.Dels[0] + activeDel, err := ParseRespBTCDelToBTCDel(activeDelResp) + s.NoError(err) + s.NotNil(activeDel.CovenantSigs) + + // staking tx hash + stakingMsgTx, err := bbn.NewBTCTxFromBytes(activeDel.StakingTx) + s.NoError(err) + stakingTxHash := stakingMsgTx.TxHash() + + currentBtcTipResp, err := nonValidatorNode.QueryTip() + s.NoError(err) + currentBtcTip, err := chain.ParseBTCHeaderInfoResponseToInfo(currentBtcTipResp) + s.NoError(err) + + unbondingTx := activeDel.BtcUndelegation.UnbondingTx + unbondingTxMsg, err := bbn.NewBTCTxFromBytes(unbondingTx) + s.NoError(err) + + blockWithUnbondingTx := datagen.CreateBlockWithTransaction(s.r, currentBtcTip.Header.ToBlockHeader(), unbondingTxMsg) + nonValidatorNode.InsertHeader(&blockWithUnbondingTx.HeaderBytes) + inclusionProof := bstypes.NewInclusionProofFromSpvProof(blockWithUnbondingTx.SpvProof) + + nonValidatorNode.SubmitRefundableTxWithAssertion(func() { + // submit the message for creating BTC undelegation + nonValidatorNode.BTCUndelegate( + &stakingTxHash, + unbondingTxMsg, + inclusionProof, + ) + // wait for a block so that above txs take effect + nonValidatorNode.WaitForNextBlock() + }, true) + + // Wait for unbonded delegations to be created + var unbondedDelsResp []*bstypes.BTCDelegationResponse + s.Eventually(func() bool { + unbondedDelsResp = nonValidatorNode.QueryUnbondedDelegations() + return len(unbondedDelsResp) > 0 + }, time.Minute, time.Second*2) + + unbondDel, err := ParseRespBTCDelToBTCDel(unbondedDelsResp[0]) + s.NoError(err) + s.Equal(stakingTxHash, unbondDel.MustGetStakingTxHash()) +} + +func (s *BTCStakingPreApprovalTestSuite) BTCStakingUnbondSlashInfo( + node *chain.NodeConfig, + params *bstypes.Params, + stakingTimeBlocks uint16, + fp *bstypes.FinalityProvider, +) ( + testStakingInfo *datagen.TestStakingSlashingInfo, + stakingTx []byte, + txInclusionProof *bstypes.InclusionProof, + testUnbondingInfo *datagen.TestUnbondingSlashingInfo, + delegatorSig *bbn.BIP340Signature, +) { + covenantBTCPKs := CovenantBTCPKs(params) + // minimal required unbonding time + unbondingTime := uint16(initialization.BabylonBtcFinalizationPeriod) + 1 + + testStakingInfo = datagen.GenBTCStakingSlashingInfo( + s.r, + s.T(), + s.net, + s.delBTCSK, + []*btcec.PublicKey{fp.BtcPk.MustToBTCPK()}, + covenantBTCPKs, + s.covenantQuorum, + stakingTimeBlocks, + s.stakingValue, + params.SlashingPkScript, + params.SlashingRate, + unbondingTime, + ) + + // submit staking tx to Bitcoin and get inclusion proof + currentBtcTipResp, err := node.QueryTip() + s.NoError(err) + currentBtcTip, err := chain.ParseBTCHeaderInfoResponseToInfo(currentBtcTipResp) + s.NoError(err) + + stakingMsgTx := testStakingInfo.StakingTx + + blockWithStakingTx := datagen.CreateBlockWithTransaction(s.r, currentBtcTip.Header.ToBlockHeader(), stakingMsgTx) + node.InsertHeader(&blockWithStakingTx.HeaderBytes) + // make block k-deep + for i := 0; i < initialization.BabylonBtcConfirmationPeriod; i++ { + node.InsertNewEmptyBtcHeader(s.r) + } + inclusionProof := bstypes.NewInclusionProofFromSpvProof(blockWithStakingTx.SpvProof) + + // generate BTC undelegation stuff + stkTxHash := testStakingInfo.StakingTx.TxHash() + unbondingValue := s.stakingValue - datagen.UnbondingTxFee + testUnbondingInfo = datagen.GenBTCUnbondingSlashingInfo( + s.r, + s.T(), + s.net, + s.delBTCSK, + []*btcec.PublicKey{fp.BtcPk.MustToBTCPK()}, + covenantBTCPKs, + s.covenantQuorum, + wire.NewOutPoint(&stkTxHash, datagen.StakingOutIdx), + stakingTimeBlocks, + unbondingValue, + params.SlashingPkScript, + params.SlashingRate, + unbondingTime, + ) + + stakingSlashingPathInfo, err := testStakingInfo.StakingInfo.SlashingPathSpendInfo() + s.NoError(err) + + delegatorSig, err = testStakingInfo.SlashingTx.Sign( + stakingMsgTx, + datagen.StakingOutIdx, + stakingSlashingPathInfo.GetPkScriptPath(), + s.delBTCSK, + ) + s.NoError(err) + + return testStakingInfo, blockWithStakingTx.SpvProof.BtcTransaction, inclusionProof, testUnbondingInfo, delegatorSig +} diff --git a/test/e2e/btc_timestamping_e2e_test.go b/test/e2e/btc_timestamping_e2e_test.go index a0648d6ac..95a96ac55 100644 --- a/test/e2e/btc_timestamping_e2e_test.go +++ b/test/e2e/btc_timestamping_e2e_test.go @@ -15,7 +15,6 @@ import ( bbn "github.com/babylonlabs-io/babylon/types" ct "github.com/babylonlabs-io/babylon/x/checkpointing/types" itypes "github.com/babylonlabs-io/babylon/x/incentive/types" - sdk "github.com/cosmos/cosmos-sdk/types" "github.com/stretchr/testify/suite" ) @@ -69,7 +68,7 @@ func (s *BTCTimestampingTestSuite) Test1ConnectIbc() { func (s *BTCTimestampingTestSuite) Test2BTCBaseHeader() { hardcodedHeader, _ := bbn.NewBTCHeaderBytesFromHex("0100000000000000000000000000000000000000000000000000000000000000000000003ba3edfd7a7b12b27ac72c3e67768f617fc81bc3888a51323a9fb8aa4b1e5e4a45068653ffff7f2002000000") - hardcodedHeaderHeight := uint64(0) + hardcodedHeaderHeight := uint32(0) chainA := s.configurer.GetChainConfig(0) nonValidatorNode, err := chainA.GetNodeAtIndex(2) @@ -99,46 +98,28 @@ func (s *BTCTimestampingTestSuite) Test3SendTx() { // check that light client properly updates its state tip1Depth, err := nonValidatorNode.QueryHeaderDepth(tip1.HashHex) s.NoError(err) - s.Equal(tip1Depth, uint64(1)) + s.Equal(tip1Depth, uint32(1)) tip2Depth, err := nonValidatorNode.QueryHeaderDepth(tip2.HashHex) s.NoError(err) // tip should have 0 depth - s.Equal(tip2Depth, uint64(0)) + s.Equal(tip2Depth, uint32(0)) } -func (s *BTCTimestampingTestSuite) Test4IbcCheckpointing() { +func (s *BTCTimestampingTestSuite) Test4FinalizeEpochs() { chainA := s.configurer.GetChainConfig(0) + chainA.WaitUntilHeight(35) nonValidatorNode, err := chainA.GetNodeAtIndex(2) s.NoError(err) - // Query open IBC channels and assert there is only one - channels, err := nonValidatorNode.QueryIBCChannels() - s.NoError(err) - s.Equal(1, len(channels.Channels), "Expected only one open IBC channel") - // Get the client ID under this IBC channel - channelClientState, err := nonValidatorNode.QueryChannelClientState(channels.Channels[0].ChannelId, channels.Channels[0].PortId) - s.NoError(err) - clientID := channelClientState.IdentifiedClientState.ClientId - - // Query checkpoint chain info for opposing chain - chainsInfo, err := nonValidatorNode.QueryChainsInfo([]string{clientID}) - s.NoError(err) - s.Equal(chainsInfo[0].ConsumerId, clientID) - - // Finalize epoch 1, 2, 3, as first headers of opposing chain are in epoch 3 + // Finalize epoch 1, 2, 3 var ( startEpochNum uint64 = 1 endEpochNum uint64 = 3 ) - // submitter/reporter address should not have any rewards yet - submitterReporterAddr := sdk.MustAccAddressFromBech32(nonValidatorNode.PublicAddress) - _, err = nonValidatorNode.QueryRewardGauge(submitterReporterAddr) - s.Error(err) - nonValidatorNode.FinalizeSealedEpochs(startEpochNum, endEpochNum) endEpoch, err := nonValidatorNode.QueryRawCheckpoint(endEpochNum) @@ -149,103 +130,9 @@ func (s *BTCTimestampingTestSuite) Test4IbcCheckpointing() { time.Sleep(20 * time.Second) // Wait for next block nonValidatorNode.WaitForNextBlock() - - // Check we have epoch info for opposing chain and some basic assertions - epochChainsInfo, err := nonValidatorNode.QueryEpochChainsInfo(endEpochNum, []string{clientID}) - s.NoError(err) - s.Equal(epochChainsInfo[0].ConsumerId, clientID) - s.Equal(epochChainsInfo[0].LatestHeader.BabylonEpoch, endEpochNum) - - // Check we have finalized epoch info for opposing chain and some basic assertions - finalizedChainsInfo, err := nonValidatorNode.QueryFinalizedChainsInfo([]string{clientID}) - s.NoError(err) - - // TODO Add more assertion here. Maybe check proofs ? - s.Equal(finalizedChainsInfo[0].FinalizedChainInfo.ConsumerId, clientID) - s.Equal(finalizedChainsInfo[0].EpochInfo.EpochNumber, endEpochNum) - - currEpoch, err := nonValidatorNode.QueryCurrentEpoch() - s.NoError(err) - - heightAtEndedEpoch, err := nonValidatorNode.QueryLightClientHeightEpochEnd(currEpoch - 1) - s.NoError(err) - - if heightAtEndedEpoch == 0 { - // we can only assert, that btc lc height is larger than 0. - s.FailNow(fmt.Sprintf("Light client height should be > 0 on epoch %d", currEpoch-1)) - } - - // ensure balance has increased after finalising some epochs - rewardGauges, err := nonValidatorNode.QueryRewardGauge(submitterReporterAddr) - s.NoError(err) - submitterRewardGauge, ok := rewardGauges[itypes.SubmitterType.String()] - s.True(ok) - s.True(submitterRewardGauge.Coins.IsAllPositive()) - reporterRewardGauge, ok := rewardGauges[itypes.ReporterType.String()] - s.True(ok) - s.True(reporterRewardGauge.Coins.IsAllPositive()) - - chainB := s.configurer.GetChainConfig(1) - _, err = chainB.GetDefaultNode() - s.NoError(err) -} - -func (s *BTCTimestampingTestSuite) Test5WithdrawReward() { - chainA := s.configurer.GetChainConfig(0) - nonValidatorNode, err := chainA.GetNodeAtIndex(2) - s.NoError(err) - - // NOTE: nonValidatorNode.PublicAddress is the address associated with key name `val` - // and is both the submitter and reporter - submitterReporterAddr := sdk.MustAccAddressFromBech32(nonValidatorNode.PublicAddress) - - // balance before withdraw - balance, err := nonValidatorNode.QueryBalances(submitterReporterAddr.String()) - s.NoError(err) - // submitter/reporter reward gauges before withdraw should not be fully withdrawn - rgs, err := nonValidatorNode.QueryRewardGauge(submitterReporterAddr) - s.NoError(err) - submitterRg, reporterRg := rgs[itypes.SubmitterType.String()], rgs[itypes.ReporterType.String()] - s.T().Logf("submitter witdhrawable reward: %s, reporter witdhrawable reward: %s before withdrawing", submitterRg.GetWithdrawableCoins().String(), reporterRg.GetWithdrawableCoins().String()) - s.False(submitterRg.IsFullyWithdrawn()) - s.False(reporterRg.IsFullyWithdrawn()) - - // withdraw submitter reward - nonValidatorNode.WithdrawReward(itypes.SubmitterType.String(), initialization.ValidatorWalletName) - nonValidatorNode.WaitForNextBlock() - - // balance after withdrawing submitter reward - balance2, err := nonValidatorNode.QueryBalances(submitterReporterAddr.String()) - s.NoError(err) - s.T().Logf("balance2: %s; balance: %s", balance2.String(), balance.String()) - s.True(balance2.IsAllGT(balance)) - - // submitter reward gauge should be fully withdrawn - rgs2, err := nonValidatorNode.QueryRewardGauge(submitterReporterAddr) - s.NoError(err) - submitterRg2 := rgs2[itypes.SubmitterType.String()] - s.T().Logf("submitter withdrawable reward: %s after withdrawing", submitterRg2.GetWithdrawableCoins().String()) - s.True(rgs2[itypes.SubmitterType.String()].IsFullyWithdrawn()) - - // withdraw reporter reward - nonValidatorNode.WithdrawReward(itypes.ReporterType.String(), initialization.ValidatorWalletName) - nonValidatorNode.WaitForNextBlock() - - // balance after withdrawing reporter reward - balance3, err := nonValidatorNode.QueryBalances(submitterReporterAddr.String()) - s.NoError(err) - s.T().Logf("balance3: %s; balance2: %s", balance3.String(), balance2.String()) - s.True(balance3.IsAllGT(balance2)) - - // reporter reward gauge should be fully withdrawn - rgs3, err := nonValidatorNode.QueryRewardGauge(submitterReporterAddr) - s.NoError(err) - reporterRg3 := rgs3[itypes.SubmitterType.String()] - s.T().Logf("reporter withdrawable reward: %s after withdrawing", reporterRg3.GetWithdrawableCoins().String()) - s.True(rgs3[itypes.ReporterType.String()].IsFullyWithdrawn()) } -func (s *BTCTimestampingTestSuite) Test6Wasm() { +func (s *BTCTimestampingTestSuite) Test5Wasm() { contractPath := "/bytecode/storage_contract.wasm" chainA := s.configurer.GetChainConfig(0) nonValidatorNode, err := chainA.GetNodeAtIndex(2) @@ -309,7 +196,7 @@ func (s *BTCTimestampingTestSuite) Test6Wasm() { s.Greater(saveEpoch, latestFinalizedEpoch) } -func (s *BTCTimestampingTestSuite) Test7InterceptFeeCollector() { +func (s *BTCTimestampingTestSuite) Test6InterceptFeeCollector() { chainA := s.configurer.GetChainConfig(0) nonValidatorNode, err := chainA.GetNodeAtIndex(2) s.NoError(err) @@ -337,31 +224,8 @@ func (s *BTCTimestampingTestSuite) Test7InterceptFeeCollector() { return len(btcStakingGauge.Coins) >= 1 && btcStakingGauge.Coins[0].Amount.IsPositive() }, time.Second*10, time.Second) - // ensure BTC timestamping gauge at the current epoch is non-empty - curEpoch, err := nonValidatorNode.QueryCurrentEpoch() - s.NoError(err) - // at the 1st block of an epoch, the gauge does not exist since incentive's BeginBlock - // at this block accumulates rewards for BTC timestamping gauge for the previous block - // need to wait for a block to ensure the gauge is created - var btcTimestampingGauge *itypes.Gauge - s.Eventually(func() bool { - btcTimestampingGauge, err = nonValidatorNode.QueryBTCTimestampingGauge(curEpoch) - if err != nil { - return false - } - s.T().Logf("BTC timestamping gauge at current epoch %d: %s", curEpoch, btcTimestampingGauge.String()) - return !btcTimestampingGauge.Coins.Empty() - }, time.Second*10, time.Second) - - // wait for 1 block to see if BTC timestamp gauge has accumulated - nonValidatorNode.WaitForNextBlock() - btcTimestampingGauge2, err := nonValidatorNode.QueryBTCTimestampingGauge(curEpoch) - s.NoError(err) - s.T().Logf("BTC timestamping gauge after a block at current epoch %d: %s", curEpoch, btcTimestampingGauge2.String()) - s.NotEmpty(btcTimestampingGauge2.Coins) - s.True(btcTimestampingGauge2.Coins.IsAllGTE(btcTimestampingGauge.Coins)) - // after 1 block, incentive's balance has to be accumulated + nonValidatorNode.WaitForNextBlock() incentiveBalance2, err := nonValidatorNode.QueryBalances(incentiveModuleAddr.String()) s.NoError(err) s.T().Logf("incentive module account's balance after a block: %s", incentiveBalance2.String()) diff --git a/test/e2e/btc_timestamping_phase2_hermes_test.go b/test/e2e/btc_timestamping_phase2_hermes_test.go deleted file mode 100644 index 4f656e068..000000000 --- a/test/e2e/btc_timestamping_phase2_hermes_test.go +++ /dev/null @@ -1,157 +0,0 @@ -package e2e - -import ( - "time" - - "github.com/babylonlabs-io/babylon/test/e2e/configurer" - ct "github.com/babylonlabs-io/babylon/x/checkpointing/types" - "github.com/cosmos/cosmos-sdk/types/query" - channeltypes "github.com/cosmos/ibc-go/v8/modules/core/04-channel/types" - "github.com/stretchr/testify/suite" -) - -type BTCTimestampingPhase2HermesTestSuite struct { - suite.Suite - - configurer configurer.Configurer -} - -func (s *BTCTimestampingPhase2HermesTestSuite) SetupSuite() { - s.T().Log("setting up phase 2 integration test suite...") - var ( - err error - ) - - // The e2e test flow is as follows: - // - // 1. Configure two chains - chain A and chain B. - // * For each chain, set up several validator nodes - // * Initialize configs and genesis for all them. - // 2. Start both networks. - // 3. Store and instantiate babylon contract on chain B. - // 3. Execute various e2e tests, excluding IBC - s.configurer, err = configurer.NewBTCTimestampingPhase2Configurer(s.T(), true) - - s.Require().NoError(err) - - err = s.configurer.ConfigureChains() - s.Require().NoError(err) - - err = s.configurer.RunSetup() - s.Require().NoError(err) -} - -func (s *BTCTimestampingPhase2HermesTestSuite) TearDownSuite() { - err := s.configurer.ClearResources() - if err != nil { - s.T().Logf("error to clear resources %s", err.Error()) - } -} - -func (s *BTCTimestampingPhase2HermesTestSuite) Test1IbcCheckpointingPhase2Hermes() { - chainA := s.configurer.GetChainConfig(0) - nonValidatorNode, err := chainA.GetNodeAtIndex(2) - s.NoError(err) - - babylonNode, err := chainA.GetNodeAtIndex(2) - s.NoError(err) - czNode, err := s.configurer.GetChainConfig(1).GetNodeAtIndex(2) - s.NoError(err) - - // Validate channel state and kind (Babylon side) - // Wait until the channel (Babylon side) is open - var babylonChannel *channeltypes.IdentifiedChannel - s.Eventually(func() bool { - babylonChannelsResp, err := babylonNode.QueryIBCChannels() - if err != nil { - return false - } - if len(babylonChannelsResp.Channels) != 1 { - return false - } - // channel has to be open and ordered - babylonChannel = babylonChannelsResp.Channels[0] - if babylonChannel.State != channeltypes.OPEN { - return false - } - s.Equal(channeltypes.ORDERED, babylonChannel.Ordering) - // the counterparty has to be the Babylon smart contract - s.Contains(babylonChannel.Counterparty.PortId, "wasm.") - return true - }, time.Minute, time.Second*2) - - // Wait until the channel (CZ side) is open - var czChannel *channeltypes.IdentifiedChannel - s.Eventually(func() bool { - czChannelsResp, err := czNode.QueryIBCChannels() - if err != nil { - return false - } - if len(czChannelsResp.Channels) != 1 { - return false - } - czChannel = czChannelsResp.Channels[0] - if czChannel.State != channeltypes.OPEN { - return false - } - s.Equal(channeltypes.ORDERED, czChannel.Ordering) - s.Equal(babylonChannel.PortId, czChannel.Counterparty.PortId) - return true - }, time.Minute, time.Second*2) - - // Get the client ID under this IBC channel - channelClientState, err := nonValidatorNode.QueryChannelClientState(babylonChannel.ChannelId, babylonChannel.PortId) - s.NoError(err) - clientID := channelClientState.IdentifiedClientState.ClientId - - // Query checkpoint chain info for the consumer chain - listHeaderResp, err := babylonNode.QueryListHeaders(clientID, &query.PageRequest{Limit: 1}) - s.NoError(err) - s.GreaterOrEqual(len(listHeaderResp.Headers), 1) - startEpochNum := listHeaderResp.Headers[0].BabylonEpoch - endEpochNum := startEpochNum + 2 - - // wait until epoch endEpochNum - // so that there will be endEpochNum - startEpochNum + 1 = 3 - // BTC timestamps in Babylon contract - chainA.WaitUntilHeight(int64(endEpochNum*10 + 5)) - babylonNode.FinalizeSealedEpochs(1, endEpochNum) - - // ensure endEpochNum has been finalised - endEpoch, err := babylonNode.QueryRawCheckpoint(endEpochNum) - s.NoError(err) - s.Equal(endEpoch.Status, ct.Finalized) - - // there should be 3 IBC packets sent (with sequence number 1, 2, 3). - // Thus, the next sequence number will eventually be 4 - s.Eventually(func() bool { - nextSequenceSendResp, err := babylonNode.QueryNextSequenceSend(babylonChannel.ChannelId, babylonChannel.PortId) - if err != nil { - return false - } - babylonNode.LogActionF("next sequence send at ZoneConcierge is %d", nextSequenceSendResp.NextSequenceSend) - return nextSequenceSendResp.NextSequenceSend >= endEpochNum-startEpochNum+1+1 - }, time.Minute, time.Second*2) - - // ensure the next receive sequence number of Babylon contract is also 3 - var nextSequenceRecv *channeltypes.QueryNextSequenceReceiveResponse - s.Eventually(func() bool { - nextSequenceRecv, err = czNode.QueryNextSequenceReceive(babylonChannel.Counterparty.ChannelId, babylonChannel.Counterparty.PortId) - if err != nil { - return false - } - czNode.LogActionF("next sequence receive at Babylon contract is %d", nextSequenceRecv.NextSequenceReceive) - return nextSequenceRecv.NextSequenceReceive >= endEpochNum-startEpochNum+1+1 - }, time.Minute, time.Second*2) - - // Ensure the IBC packet acknowledgements (on chain B) are there and do not contain error - nextSequence := nextSequenceRecv.NextSequenceReceive - for seq := uint64(1); seq < nextSequence; seq++ { - var seqResp *channeltypes.QueryPacketAcknowledgementResponse - s.Eventually(func() bool { - seqResp, err = czNode.QueryPacketAcknowledgement(czChannel.ChannelId, czChannel.PortId, seq) - czNode.LogActionF("acknowledgement resp of IBC packet #%d: %v, err: %v", seq, seqResp, err) - return err == nil - }, time.Minute, time.Second*2) - } -} diff --git a/test/e2e/btc_timestamping_phase2_rly_test.go b/test/e2e/btc_timestamping_phase2_rly_test.go deleted file mode 100644 index 744fc7d06..000000000 --- a/test/e2e/btc_timestamping_phase2_rly_test.go +++ /dev/null @@ -1,157 +0,0 @@ -package e2e - -import ( - "time" - - "github.com/babylonlabs-io/babylon/test/e2e/configurer" - ct "github.com/babylonlabs-io/babylon/x/checkpointing/types" - "github.com/cosmos/cosmos-sdk/types/query" - channeltypes "github.com/cosmos/ibc-go/v8/modules/core/04-channel/types" - "github.com/stretchr/testify/suite" -) - -type BTCTimestampingPhase2RlyTestSuite struct { - suite.Suite - - configurer configurer.Configurer -} - -func (s *BTCTimestampingPhase2RlyTestSuite) SetupSuite() { - s.T().Log("setting up phase 2 go relayer integration test suite...") - var ( - err error - ) - - // The e2e test flow is as follows: - // - // 1. Configure two chains - chain A and chain B. - // * For each chain, set up several validator nodes - // * Initialize configs and genesis for all them. - // 2. Start both networks. - // 3. Store and instantiate babylon contract on chain B. - // 3. Execute various e2e tests, excluding IBC - s.configurer, err = configurer.NewBTCTimestampingPhase2RlyConfigurer(s.T(), true) - - s.Require().NoError(err) - - err = s.configurer.ConfigureChains() - s.Require().NoError(err) - - err = s.configurer.RunSetup() - s.Require().NoError(err) -} - -func (s *BTCTimestampingPhase2RlyTestSuite) TearDownSuite() { - err := s.configurer.ClearResources() - if err != nil { - s.T().Logf("error to clear resources %s", err.Error()) - } -} - -func (s *BTCTimestampingPhase2RlyTestSuite) Test1IbcCheckpointingPhase2Rly() { - chainA := s.configurer.GetChainConfig(0) - nonValidatorNode, err := chainA.GetNodeAtIndex(2) - s.NoError(err) - - babylonNode, err := chainA.GetNodeAtIndex(2) - s.NoError(err) - czNode, err := s.configurer.GetChainConfig(1).GetNodeAtIndex(2) - s.NoError(err) - - // Validate channel state and kind (Babylon side) - // Wait until the channel (Babylon side) is open - var babylonChannel *channeltypes.IdentifiedChannel - s.Eventually(func() bool { - babylonChannelsResp, err := babylonNode.QueryIBCChannels() - if err != nil { - return false - } - if len(babylonChannelsResp.Channels) != 1 { - return false - } - // channel has to be open and ordered - babylonChannel = babylonChannelsResp.Channels[0] - if babylonChannel.State != channeltypes.OPEN { - return false - } - s.Equal(channeltypes.ORDERED, babylonChannel.Ordering) - // the counterparty has to be the Babylon smart contract - s.Contains(babylonChannel.Counterparty.PortId, "wasm.") - return true - }, time.Minute, time.Second*2) - - // Wait until the channel (CZ side) is open - var czChannel *channeltypes.IdentifiedChannel - s.Eventually(func() bool { - czChannelsResp, err := czNode.QueryIBCChannels() - if err != nil { - return false - } - if len(czChannelsResp.Channels) != 1 { - return false - } - czChannel = czChannelsResp.Channels[0] - if czChannel.State != channeltypes.OPEN { - return false - } - s.Equal(channeltypes.ORDERED, czChannel.Ordering) - s.Equal(babylonChannel.PortId, czChannel.Counterparty.PortId) - return true - }, time.Minute, time.Second*2) - - // Get the client ID under this IBC channel - channelClientState, err := nonValidatorNode.QueryChannelClientState(babylonChannel.ChannelId, babylonChannel.PortId) - s.NoError(err) - clientID := channelClientState.IdentifiedClientState.ClientId - - // Query checkpoint chain info for the consumer chain - listHeaderResp, err := babylonNode.QueryListHeaders(clientID, &query.PageRequest{Limit: 1}) - s.NoError(err) - s.GreaterOrEqual(len(listHeaderResp.Headers), 1) - startEpochNum := listHeaderResp.Headers[0].BabylonEpoch - endEpochNum := startEpochNum + 2 - - // wait until epoch endEpochNum - // so that there will be endEpochNum - startEpochNum + 1 = 3 - // BTC timestamps in Babylon contract - chainA.WaitUntilHeight(int64(endEpochNum*10 + 5)) - babylonNode.FinalizeSealedEpochs(1, endEpochNum) - - // ensure endEpochNum has been finalised - endEpoch, err := babylonNode.QueryRawCheckpoint(endEpochNum) - s.NoError(err) - s.Equal(endEpoch.Status, ct.Finalized) - - // there should be 3 IBC packets sent (with sequence number 1, 2, 3). - // Thus, the next sequence number will eventually be 4 - s.Eventually(func() bool { - nextSequenceSendResp, err := babylonNode.QueryNextSequenceSend(babylonChannel.ChannelId, babylonChannel.PortId) - if err != nil { - return false - } - s.T().Logf("next sequence send at ZoneConcierge is %d", nextSequenceSendResp.NextSequenceSend) - return nextSequenceSendResp.NextSequenceSend >= endEpochNum-startEpochNum+1+1 - }, time.Minute, time.Second*2) - - // ensure the next receive sequence number of Babylon contract is also 3 - var nextSequenceRecv *channeltypes.QueryNextSequenceReceiveResponse - s.Eventually(func() bool { - nextSequenceRecv, err = czNode.QueryNextSequenceReceive(babylonChannel.Counterparty.ChannelId, babylonChannel.Counterparty.PortId) - if err != nil { - return false - } - s.T().Logf("next sequence receive at Babylon contract is %d", nextSequenceRecv.NextSequenceReceive) - return nextSequenceRecv.NextSequenceReceive >= endEpochNum-startEpochNum+1+1 - }, time.Minute, time.Second*2) - - // Ensure the IBC packet acknowledgements (on chain B) are there - nextSequence := nextSequenceRecv.NextSequenceReceive - for seq := uint64(1); seq < nextSequence; seq++ { - var seqResp *channeltypes.QueryPacketAcknowledgementResponse - s.Eventually(func() bool { - seqResp, err = czNode.QueryPacketAcknowledgement(czChannel.ChannelId, czChannel.PortId, seq) - s.T().Logf("acknowledgement resp of IBC packet #%d: %v, err: %v", seq, seqResp, err) - return err == nil - }, time.Minute, time.Second*2) - } -} diff --git a/test/e2e/configurer/base.go b/test/e2e/configurer/base.go index 53cf86e77..f0e116565 100644 --- a/test/e2e/configurer/base.go +++ b/test/e2e/configurer/base.go @@ -160,9 +160,6 @@ func (bc *baseConfigurer) RunHermesRelayerIBC() error { if err := bc.runHermesIBCRelayer(bc.chainConfigs[i], bc.chainConfigs[j]); err != nil { return err } - if err := bc.createBabylonPhase2Channel(bc.chainConfigs[i], bc.chainConfigs[j]); err != nil { - return err - } } } return nil @@ -175,9 +172,6 @@ func (bc *baseConfigurer) RunCosmosRelayerIBC() error { if err := bc.runCosmosIBCRelayer(bc.chainConfigs[i], bc.chainConfigs[j]); err != nil { return err } - //if err := bc.createBabylonPhase2Channel(bc.chainConfigs[i], bc.chainConfigs[j]); err != nil { - // return err - //} } } // Launches a relayer between chain A (babylond) and chain B (wasmd) @@ -331,27 +325,6 @@ func (bc *baseConfigurer) runCosmosIBCRelayer(chainConfigA *chain.Config, chainC return nil } -func (bc *baseConfigurer) createBabylonPhase2Channel(chainA *chain.Config, chainB *chain.Config) error { - bc.t.Logf("connecting %s and %s chains via IBC", chainA.ChainMeta.Id, chainB.ChainMeta.Id) - require.Equal(bc.t, chainA.IBCConfig.Order, chainB.IBCConfig.Order) - require.Equal(bc.t, chainA.IBCConfig.Version, chainB.IBCConfig.Version) - cmd := []string{"hermes", "create", "channel", - "--a-chain", chainA.ChainMeta.Id, "--b-chain", chainB.ChainMeta.Id, // channel ID - "--a-port", chainA.IBCConfig.PortID, "--b-port", chainB.IBCConfig.PortID, // port - "--order", chainA.IBCConfig.Order.String(), - "--channel-version", chainA.IBCConfig.Version, - "--new-client-connection", "--yes", - } - _, _, err := bc.containerManager.ExecHermesCmd(bc.t, cmd, "SUCCESS") - if err != nil { - return err - } - bc.t.Logf("connected %s and %s chains via IBC", chainA.ChainMeta.Id, chainB.ChainMeta.Id) - bc.t.Logf("chainA's IBC config: %v", chainA.IBCConfig) - bc.t.Logf("chainB's IBC config: %v", chainB.IBCConfig) - return nil -} - func (bc *baseConfigurer) createIBCTransferChannel(chainA *chain.Config, chainB *chain.Config) error { bc.t.Logf("connecting %s and %s chains via IBC", chainA.ChainMeta.Id, chainB.ChainMeta.Id) cmd := []string{"hermes", "create", "channel", "--a-chain", chainA.ChainMeta.Id, "--b-chain", chainB.ChainMeta.Id, "--a-port", "transfer", "--b-port", "transfer", "--new-client-connection", "--yes"} diff --git a/test/e2e/configurer/chain/chain.go b/test/e2e/configurer/chain/chain.go index b93aeb0bc..76ac1f72c 100644 --- a/test/e2e/configurer/chain/chain.go +++ b/test/e2e/configurer/chain/chain.go @@ -190,7 +190,7 @@ func (c *Config) TxGovVoteFromAllNodes(propID int, option govv1.VoteOption, over // BTCHeaderBytesHexJoined join all the btc headers as byte string hex func (c *Config) BTCHeaderBytesHexJoined() string { - if c.BTCHeaders == nil || len(c.BTCHeaders) == 0 { + if len(c.BTCHeaders) == 0 { return "" } diff --git a/test/e2e/configurer/chain/commands.go b/test/e2e/configurer/chain/commands.go index feca59645..16c993a63 100644 --- a/test/e2e/configurer/chain/commands.go +++ b/test/e2e/configurer/chain/commands.go @@ -232,9 +232,13 @@ func (n *NodeConfig) FinalizeSealedEpochs(startEpoch uint64, lastEpoch uint64) { tx2 := datagen.CreatOpReturnTransaction(r, p2) opReturn2 := datagen.CreateBlockWithTransaction(r, opReturn1.HeaderBytes.ToBlockHeader(), tx2) - n.InsertHeader(&opReturn1.HeaderBytes) - n.InsertHeader(&opReturn2.HeaderBytes) - n.InsertProofs(opReturn1.SpvProof, opReturn2.SpvProof) + n.SubmitRefundableTxWithAssertion(func() { + n.InsertHeader(&opReturn1.HeaderBytes) + n.InsertHeader(&opReturn2.HeaderBytes) + }, true) + n.SubmitRefundableTxWithAssertion(func() { + n.InsertProofs(opReturn1.SpvProof, opReturn2.SpvProof) + }, true) n.WaitForCondition(func() bool { ckpt, err := n.QueryRawCheckpoint(checkpoint.Ckpt.EpochNum) @@ -258,8 +262,8 @@ func (n *NodeConfig) FinalizeSealedEpochs(startEpoch uint64, lastEpoch uint64) { func (n *NodeConfig) StoreWasmCode(wasmFile, from string) { n.LogActionF("storing wasm code from file %s", wasmFile) - cmd := []string{"babylond", "tx", "wasm", "store", wasmFile, fmt.Sprintf("--from=%s", from), "--gas=auto", "--gas-prices=1ubbn", "--gas-adjustment=1.3"} - n.LogActionF(strings.Join(cmd, " ")) + cmd := []string{"babylond", "tx", "wasm", "store", wasmFile, fmt.Sprintf("--from=%s", from), "--gas=auto", "--gas-adjustment=1.3"} + n.LogActionF("Executing command: %s", strings.Join(cmd, " ")) _, _, err := n.containerManager.ExecTxCmd(n.t, n.chainId, n.Name, cmd) require.NoError(n.t, err) n.LogActionF("successfully stored") @@ -267,8 +271,8 @@ func (n *NodeConfig) StoreWasmCode(wasmFile, from string) { func (n *NodeConfig) InstantiateWasmContract(codeId, initMsg, from string) { n.LogActionF("instantiating wasm contract %s with %s", codeId, initMsg) - cmd := []string{"babylond", "tx", "wasm", "instantiate", codeId, initMsg, fmt.Sprintf("--from=%s", from), "--no-admin", "--label=contract", "--gas=auto", "--gas-prices=1ubbn", "--gas-adjustment=1.3"} - n.LogActionF(strings.Join(cmd, " ")) + cmd := []string{"babylond", "tx", "wasm", "instantiate", codeId, initMsg, fmt.Sprintf("--from=%s", from), "--no-admin", "--label=contract", "--gas=auto", "--gas-adjustment=1.3"} + n.LogActionF("Executing command: %s", strings.Join(cmd, " ")) _, _, err := n.containerManager.ExecTxCmd(n.t, n.chainId, n.Name, cmd) require.NoError(n.t, err) n.LogActionF("successfully initialized") @@ -277,7 +281,7 @@ func (n *NodeConfig) InstantiateWasmContract(codeId, initMsg, from string) { func (n *NodeConfig) WasmExecute(contract, execMsg, from string) { n.LogActionF("executing %s on wasm contract %s from %s", execMsg, contract, from) cmd := []string{"babylond", "tx", "wasm", "execute", contract, execMsg, fmt.Sprintf("--from=%s", from)} - n.LogActionF(strings.Join(cmd, " ")) + n.LogActionF("Executing command: %s", strings.Join(cmd, " ")) _, _, err := n.containerManager.ExecTxCmd(n.t, n.chainId, n.Name, cmd) require.NoError(n.t, err) n.LogActionF("successfully executed") @@ -287,7 +291,7 @@ func (n *NodeConfig) WasmExecute(contract, execMsg, from string) { func (n *NodeConfig) WithdrawReward(sType, from string) { n.LogActionF("withdraw rewards of type %s for tx signer %s", sType, from) cmd := []string{"babylond", "tx", "incentive", "withdraw-reward", sType, fmt.Sprintf("--from=%s", from)} - n.LogActionF(strings.Join(cmd, " ")) + n.LogActionF("Executing command: %s", strings.Join(cmd, " ")) _, _, err := n.containerManager.ExecTxCmd(n.t, n.chainId, n.Name, cmd) require.NoError(n.t, err) n.LogActionF("successfully withdrawn") @@ -444,3 +448,26 @@ func (n *NodeConfig) TxGovVote(from string, propID int, option govv1.VoteOption, n.LogActionF("successfully submitted vote %s to prop %d", option, propID) } + +// submitRefundableTxWithAssertion submits a refundable transaction, +// and asserts that the tx fee is refunded +func (n *NodeConfig) SubmitRefundableTxWithAssertion( + f func(), + shouldBeRefunded bool, +) { + // balance before submitting the refundable tx + submitterBalanceBefore, err := n.QueryBalances(n.PublicAddress) + require.NoError(n.t, err) + + // submit refundable tx + f() + + // ensure the tx fee is refunded and the balance is not changed + submitterBalanceAfter, err := n.QueryBalances(n.PublicAddress) + require.NoError(n.t, err) + if shouldBeRefunded { + require.Equal(n.t, submitterBalanceBefore, submitterBalanceAfter) + } else { + require.True(n.t, submitterBalanceBefore.IsAllGT(submitterBalanceAfter)) + } +} diff --git a/test/e2e/configurer/chain/commands_btcstaking.go b/test/e2e/configurer/chain/commands_btcstaking.go index 541bf34ca..ee85a4725 100644 --- a/test/e2e/configurer/chain/commands_btcstaking.go +++ b/test/e2e/configurer/chain/commands_btcstaking.go @@ -8,7 +8,6 @@ import ( "github.com/stretchr/testify/require" - "github.com/btcsuite/btcd/btcec/v2/schnorr" "github.com/btcsuite/btcd/btcutil" "github.com/btcsuite/btcd/chaincfg/chainhash" "github.com/btcsuite/btcd/wire" @@ -19,7 +18,6 @@ import ( asig "github.com/babylonlabs-io/babylon/crypto/schnorr-adaptor-signature" "github.com/babylonlabs-io/babylon/test/e2e/containers" bbn "github.com/babylonlabs-io/babylon/types" - btcctypes "github.com/babylonlabs-io/babylon/x/btccheckpoint/types" bstypes "github.com/babylonlabs-io/babylon/x/btcstaking/types" ) @@ -43,9 +41,10 @@ func (n *NodeConfig) CreateFinalityProvider(walletAddrOrName string, btcPK *bbn. } func (n *NodeConfig) CreateBTCDelegation( - btcPKs []bbn.BIP340PubKey, + btcPK bbn.BIP340PubKey, pop *bstypes.ProofOfPossessionBTC, - stakingTxInfo *btcctypes.TransactionInfo, + stakingTx []byte, + inclusionProof *bstypes.InclusionProof, fpPKs []*bbn.BIP340PubKey, stakingTimeBlocks uint16, stakingValue btcutil.Amount, @@ -62,20 +61,22 @@ func (n *NodeConfig) CreateBTCDelegation( ) (outStr string) { n.LogActionF("creating BTC delegation") - var btcPKHexList []string - for _, btcPK := range btcPKs { - btcPKHex := btcPK.MarshalHex() - btcPKHexList = append(btcPKHexList, btcPKHex) - } - btcPKHexListStr := strings.Join(btcPKHexList, ",") + btcPKHex := btcPK.MarshalHex() // get pop hex popHex, err := pop.ToHexStr() require.NoError(n.t, err) // get staking tx info hex - stakingTxInfoHex, err := stakingTxInfo.ToHexStr() - require.NoError(n.t, err) + stakingTxHex := hex.EncodeToString(stakingTx) + + // get inclusion proof hex + var inclusionProofHex string + + if inclusionProof != nil { + inclusionProofHex, err = inclusionProof.MarshalHex() + require.NoError(n.t, err) + } fpPKHexList := make([]string, len(fpPKs)) for i, fpPK := range fpPKs { @@ -102,13 +103,21 @@ func (n *NodeConfig) CreateBTCDelegation( cmd := []string{ "babylond", "tx", "btcstaking", "create-btc-delegation", - btcPKHexListStr, popHex, stakingTxInfoHex, fpPKHexes, stakingTimeString, stakingValueString, slashingTxHex, delegatorSigHex, unbondingTxHex, unbondingSlashingTxHex, unbondingTimeStr, unbondingValueStr, delUnbondingSlashingSigHex, + btcPKHex, popHex, stakingTxHex, inclusionProofHex, fpPKHexes, stakingTimeString, stakingValueString, slashingTxHex, delegatorSigHex, unbondingTxHex, unbondingSlashingTxHex, unbondingTimeStr, unbondingValueStr, delUnbondingSlashingSigHex, fmt.Sprintf("--from=%s", fromWalletName), containers.FlagHome, flagKeyringTest, n.FlagChainID(), "--log_format=json", } + // gas price + cmd = append(cmd, "--gas-prices=0.002ubbn") + if generateOnly { cmd = append(cmd, "--generate-only") + } else { + // gas + cmd = append(cmd, "--gas=auto", "--gas-adjustment=1.3") + // broadcast stuff + cmd = append(cmd, "-b=sync", "--yes") } //cmd = append(cmd, fmt.Sprintf("--chain-id=%s", n.chainId), "-b=sync", "--yes", "--keyring-backend=test", "--log_format=json", "--home=/home/babylon/babylondata") cmd = append(cmd, fmt.Sprintf("--chain-id=%s", n.chainId), "-b=sync", "--yes") @@ -146,7 +155,7 @@ func (n *NodeConfig) AddCovenantSigs(covPK *bbn.BIP340PubKey, stakingTxHash stri // used key cmd = append(cmd, "--from=val") // gas - cmd = append(cmd, "--gas=auto", "--gas-prices=1ubbn", "--gas-adjustment=1.3") + cmd = append(cmd, "--gas=auto", "--gas-adjustment=2") _, _, err := n.containerManager.ExecTxCmd(n.t, n.chainId, n.Name, cmd) require.NoError(n.t, err) @@ -227,13 +236,35 @@ func (n *NodeConfig) AddCovenantUnbondingSigs( n.LogActionF("successfully added covenant unbonding sigs") } -func (n *NodeConfig) BTCUndelegate(stakingTxHash *chainhash.Hash, delUnbondingSig *schnorr.Signature) { +func (n *NodeConfig) BTCUndelegate( + stakingTxHash *chainhash.Hash, + spendStakeTx *wire.MsgTx, + spendStakeTxInclusionProof *bstypes.InclusionProof, +) { n.LogActionF("undelegate by using signature on unbonding tx from delegator") - sigHex := bbn.NewBIP340SignatureFromBTCSig(delUnbondingSig).ToHexStr() - cmd := []string{"babylond", "tx", "btcstaking", "btc-undelegate", stakingTxHash.String(), sigHex, "--from=val"} + spendStakeTxBytes, err := bbn.SerializeBTCTx(spendStakeTx) + require.NoError(n.t, err) + spendStakeTxHex := hex.EncodeToString(spendStakeTxBytes) + inclusionProofHex, err := spendStakeTxInclusionProof.MarshalHex() + require.NoError(n.t, err) + + cmd := []string{"babylond", "tx", "btcstaking", "btc-undelegate", stakingTxHash.String(), spendStakeTxHex, inclusionProofHex, "--from=val"} - _, _, err := n.containerManager.ExecTxCmd(n.t, n.chainId, n.Name, cmd) + _, _, err = n.containerManager.ExecTxCmd(n.t, n.chainId, n.Name, cmd) require.NoError(n.t, err) n.LogActionF("successfully added signature on unbonding tx from delegator") } + +func (n *NodeConfig) AddBTCDelegationInclusionProof( + stakingTxHash *chainhash.Hash, + inclusionProof *bstypes.InclusionProof) { + n.LogActionF("activate delegation by adding inclusion proof") + inclusionProofHex, err := inclusionProof.MarshalHex() + require.NoError(n.t, err) + + cmd := []string{"babylond", "tx", "btcstaking", "add-btc-inclusion-proof", stakingTxHash.String(), inclusionProofHex, "--from=val"} + _, _, err = n.containerManager.ExecTxCmd(n.t, n.chainId, n.Name, cmd) + require.NoError(n.t, err) + n.LogActionF("successfully added inclusion proof") +} diff --git a/test/e2e/configurer/chain/node.go b/test/e2e/configurer/chain/node.go index c07288c17..af2787e9c 100644 --- a/test/e2e/configurer/chain/node.go +++ b/test/e2e/configurer/chain/node.go @@ -130,8 +130,8 @@ func (n *NodeConfig) WaitForCondition(doneCondition func() bool, errorMsg string n.t.Errorf("node %s timed out waiting for condition. Msg: %s", n.Name, errorMsg) } -func (n *NodeConfig) WaitUntilBtcHeight(height uint64) { - var latestBlockHeight uint64 +func (n *NodeConfig) WaitUntilBtcHeight(height uint32) { + var latestBlockHeight uint32 n.WaitForCondition(func() bool { btcTip, err := n.QueryTip() require.NoError(n.t, err) diff --git a/test/e2e/configurer/chain/queries.go b/test/e2e/configurer/chain/queries.go index e773c70ae..66cbd87c3 100644 --- a/test/e2e/configurer/chain/queries.go +++ b/test/e2e/configurer/chain/queries.go @@ -28,11 +28,10 @@ import ( ct "github.com/babylonlabs-io/babylon/x/checkpointing/types" etypes "github.com/babylonlabs-io/babylon/x/epoching/types" mtypes "github.com/babylonlabs-io/babylon/x/monitor/types" - zctypes "github.com/babylonlabs-io/babylon/x/zoneconcierge/types" ) func (n *NodeConfig) QueryGRPCGateway(path string, queryParams url.Values) ([]byte, error) { - // add the URL for the given validator ID, and pre-pend to path. + // add the URL for the given validator ID, and prepend to path. hostPort, err := n.containerManager.GetHostPort(n.Name, "1317/tcp") require.NoError(n.t, err) endpoint := fmt.Sprintf("http://%s", hostPort) @@ -102,6 +101,22 @@ func (n *NodeConfig) QueryBalances(address string) (sdk.Coins, error) { return balancesResp.GetBalances(), nil } +// QueryBalance returns balance of some address. +func (n *NodeConfig) QueryBalance(address, denom string) (*sdk.Coin, error) { + path := fmt.Sprintf("cosmos/bank/v1beta1/balances/%s/by_denom", address) + + params := url.Values{} + params.Set("denom", denom) + bz, err := n.QueryGRPCGateway(path, params) + require.NoError(n.t, err) + + var balancesResp banktypes.QueryBalanceResponse + if err := util.Cdc.UnmarshalJSON(bz, &balancesResp); err != nil { + return nil, err + } + return balancesResp.GetBalance(), nil +} + func (n *NodeConfig) QuerySupplyOf(denom string) (sdkmath.Int, error) { path := fmt.Sprintf("cosmos/bank/v1beta1/supply/%s", denom) bz, err := n.QueryGRPCGateway(path, url.Values{}) @@ -233,7 +248,7 @@ func (n *NodeConfig) QueryTip() (*blc.BTCHeaderInfoResponse, error) { return blcResponse.Header, nil } -func (n *NodeConfig) QueryHeaderDepth(hash string) (uint64, error) { +func (n *NodeConfig) QueryHeaderDepth(hash string) (uint32, error) { path := fmt.Sprintf("babylon/btclightclient/v1/depth/%s", hash) bz, err := n.QueryGRPCGateway(path, url.Values{}) require.NoError(n.t, err) @@ -246,85 +261,6 @@ func (n *NodeConfig) QueryHeaderDepth(hash string) (uint64, error) { return blcResponse.Depth, nil } -func (n *NodeConfig) QueryListHeaders(consumerID string, pagination *query.PageRequest) (*zctypes.QueryListHeadersResponse, error) { - queryParams := url.Values{} - if pagination != nil { - queryParams.Set("pagination.key", base64.URLEncoding.EncodeToString(pagination.Key)) - queryParams.Set("pagination.limit", strconv.Itoa(int(pagination.Limit))) - } - - path := fmt.Sprintf("babylon/zoneconcierge/v1/headers/%s", consumerID) - bz, err := n.QueryGRPCGateway(path, queryParams) - require.NoError(n.t, err) - - var resp zctypes.QueryListHeadersResponse - if err := util.Cdc.UnmarshalJSON(bz, &resp); err != nil { - return nil, err - } - - return &resp, nil -} - -func (n *NodeConfig) QueryFinalizedChainsInfo(consumerIDs []string) ([]*zctypes.FinalizedChainInfo, error) { - queryParams := url.Values{} - for _, consumerID := range consumerIDs { - queryParams.Add("consumer_ids", consumerID) - } - - bz, err := n.QueryGRPCGateway("babylon/zoneconcierge/v1/finalized_chains_info", queryParams) - require.NoError(n.t, err) - - var resp zctypes.QueryFinalizedChainsInfoResponse - if err := util.Cdc.UnmarshalJSON(bz, &resp); err != nil { - return nil, err - } - - return resp.FinalizedChainsInfo, nil -} - -func (n *NodeConfig) QueryEpochChainsInfo(epochNum uint64, consumerIDs []string) ([]*zctypes.ChainInfo, error) { - queryParams := url.Values{} - for _, consumerID := range consumerIDs { - queryParams.Add("epoch_num", fmt.Sprintf("%d", epochNum)) - queryParams.Add("consumer_ids", consumerID) - } - - bz, err := n.QueryGRPCGateway("babylon/zoneconcierge/v1/epoch_chains_info", queryParams) - require.NoError(n.t, err) - - var resp zctypes.QueryEpochChainsInfoResponse - if err := util.Cdc.UnmarshalJSON(bz, &resp); err != nil { - return nil, err - } - - return resp.ChainsInfo, nil -} - -func (n *NodeConfig) QueryChains() (*[]string, error) { - bz, err := n.QueryGRPCGateway("babylon/zoneconcierge/v1/chains", url.Values{}) - require.NoError(n.t, err) - var chainsResponse zctypes.QueryChainListResponse - if err := util.Cdc.UnmarshalJSON(bz, &chainsResponse); err != nil { - return nil, err - } - return &chainsResponse.ConsumerIds, nil -} - -func (n *NodeConfig) QueryChainsInfo(consumerIDs []string) ([]*zctypes.ChainInfo, error) { - queryParams := url.Values{} - for _, consumerId := range consumerIDs { - queryParams.Add("consumer_ids", consumerId) - } - - bz, err := n.QueryGRPCGateway("/babylon/zoneconcierge/v1/chains_info", queryParams) - require.NoError(n.t, err) - var resp zctypes.QueryChainsInfoResponse - if err := util.Cdc.UnmarshalJSON(bz, &resp); err != nil { - return nil, err - } - return resp.ChainsInfo, nil -} - func (n *NodeConfig) QueryCurrentEpoch() (uint64, error) { bz, err := n.QueryGRPCGateway("/babylon/epoching/v1/current_epoch", url.Values{}) require.NoError(n.t, err) @@ -335,7 +271,7 @@ func (n *NodeConfig) QueryCurrentEpoch() (uint64, error) { return epochResponse.CurrentEpoch, nil } -func (n *NodeConfig) QueryLightClientHeightEpochEnd(epoch uint64) (uint64, error) { +func (n *NodeConfig) QueryLightClientHeightEpochEnd(epoch uint64) (uint32, error) { monitorPath := fmt.Sprintf("/babylon/monitor/v1/epochs/%d", epoch) bz, err := n.QueryGRPCGateway(monitorPath, url.Values{}) require.NoError(n.t, err) @@ -346,7 +282,7 @@ func (n *NodeConfig) QueryLightClientHeightEpochEnd(epoch uint64) (uint64, error return mResponse.BtcLightClientHeight, nil } -func (n *NodeConfig) QueryLightClientHeightCheckpointReported(ckptHash []byte) (uint64, error) { +func (n *NodeConfig) QueryLightClientHeightCheckpointReported(ckptHash []byte) (uint32, error) { monitorPath := fmt.Sprintf("/babylon/monitor/v1/checkpoints/%x", ckptHash) bz, err := n.QueryGRPCGateway(monitorPath, url.Values{}) require.NoError(n.t, err) diff --git a/test/e2e/configurer/chain/queries_btcstaking.go b/test/e2e/configurer/chain/queries_btcstaking.go index 6ed084972..149b8a76b 100644 --- a/test/e2e/configurer/chain/queries_btcstaking.go +++ b/test/e2e/configurer/chain/queries_btcstaking.go @@ -45,12 +45,12 @@ func (n *NodeConfig) QueryFinalityProviders() []*bstypes.FinalityProviderRespons return resp.FinalityProviders } -func (n *NodeConfig) QueryActiveFinalityProvidersAtHeight(height uint64) []*bstypes.FinalityProviderWithMeta { - path := fmt.Sprintf("/babylon/btcstaking/v1/finality_providers/%d", height) +func (n *NodeConfig) QueryActiveFinalityProvidersAtHeight(height uint64) []*ftypes.ActiveFinalityProvidersAtHeightResponse { + path := fmt.Sprintf("/babylon/finality/v1/finality_providers/%d", height) bz, err := n.QueryGRPCGateway(path, url.Values{}) require.NoError(n.t, err) - var resp bstypes.QueryActiveFinalityProvidersAtHeightResponse + var resp ftypes.QueryActiveFinalityProvidersAtHeightResponse err = util.Cdc.UnmarshalJSON(bz, &resp) require.NoError(n.t, err) @@ -70,7 +70,7 @@ func (n *NodeConfig) QueryFinalityProviderDelegations(fpBTCPK string) []*bstypes } func (n *NodeConfig) QueryBtcDelegation(stakingTxHash string) *bstypes.QueryBTCDelegationResponse { - path := fmt.Sprintf("/babylon/btcstaking/v1/btc_delegations/%s", stakingTxHash) + path := fmt.Sprintf("/babylon/btcstaking/v1/btc_delegation/%s", stakingTxHash) bz, err := n.QueryGRPCGateway(path, url.Values{}) require.NoError(n.t, err) @@ -81,8 +81,9 @@ func (n *NodeConfig) QueryBtcDelegation(stakingTxHash string) *bstypes.QueryBTCD return &resp } -func (n *NodeConfig) QueryBtcDelegations() *bstypes.QueryBTCDelegationsResponse { - bz, err := n.QueryGRPCGateway("/babylon/btcstaking/v1/btc_delegations", url.Values{}) +func (n *NodeConfig) QueryBtcDelegations(status bstypes.BTCDelegationStatus) *bstypes.QueryBTCDelegationsResponse { + path := fmt.Sprintf("/babylon/btcstaking/v1/btc_delegations/%d", status) + bz, err := n.QueryGRPCGateway(path, url.Values{}) require.NoError(n.t, err) var resp bstypes.QueryBTCDelegationsResponse @@ -93,25 +94,24 @@ func (n *NodeConfig) QueryBtcDelegations() *bstypes.QueryBTCDelegationsResponse } func (n *NodeConfig) QueryUnbondedDelegations() []*bstypes.BTCDelegationResponse { - queryParams := url.Values{} - queryParams.Add("status", fmt.Sprintf("%d", bstypes.BTCDelegationStatus_UNBONDED)) - bz, err := n.QueryGRPCGateway("/babylon/btcstaking/v1/btc_delegations", queryParams) - require.NoError(n.t, err) + return n.QueryBtcDelegations(bstypes.BTCDelegationStatus_UNBONDED).BtcDelegations +} - var resp bstypes.QueryBTCDelegationsResponse - err = util.Cdc.UnmarshalJSON(bz, &resp) - require.NoError(n.t, err) +func (n *NodeConfig) QueryVerifiedDelegations() []*bstypes.BTCDelegationResponse { + return n.QueryBtcDelegations(bstypes.BTCDelegationStatus_VERIFIED).BtcDelegations +} - return resp.BtcDelegations +func (n *NodeConfig) QueryActiveDelegations() []*bstypes.BTCDelegationResponse { + return n.QueryBtcDelegations(bstypes.BTCDelegationStatus_ACTIVE).BtcDelegations } func (n *NodeConfig) QueryActivatedHeight() (uint64, error) { - bz, err := n.QueryGRPCGateway("/babylon/btcstaking/v1/activated_height", url.Values{}) + bz, err := n.QueryGRPCGateway("/babylon/finality/v1/activated_height", url.Values{}) if err != nil { return 0, err } - var resp bstypes.QueryActivatedHeightResponse + var resp ftypes.QueryActivatedHeightResponse err = util.Cdc.UnmarshalJSON(bz, &resp) if err != nil { return 0, err @@ -121,7 +121,6 @@ func (n *NodeConfig) QueryActivatedHeight() (uint64, error) { } // TODO: pagination support -// TODO: remove public randomness storage? func (n *NodeConfig) QueryListPublicRandomness(fpBTCPK *bbn.BIP340PubKey) map[uint64]*bbn.SchnorrPubRand { path := fmt.Sprintf("/babylon/finality/v1/finality_providers/%s/public_randomness_list", fpBTCPK.MarshalHex()) bz, err := n.QueryGRPCGateway(path, url.Values{}) diff --git a/test/e2e/configurer/chain/queries_incentive.go b/test/e2e/configurer/chain/queries_incentive.go index 152c42352..b999aae19 100644 --- a/test/e2e/configurer/chain/queries_incentive.go +++ b/test/e2e/configurer/chain/queries_incentive.go @@ -10,7 +10,7 @@ import ( "github.com/stretchr/testify/require" ) -func (n *NodeConfig) QueryBTCStakingGauge(height uint64) (*incentivetypes.Gauge, error) { +func (n *NodeConfig) QueryBTCStakingGauge(height uint64) (*incentivetypes.BTCStakingGaugeResponse, error) { path := fmt.Sprintf("/babylon/incentive/btc_staking_gauge/%d", height) bz, err := n.QueryGRPCGateway(path, url.Values{}) if err != nil { @@ -38,7 +38,7 @@ func (n *NodeConfig) QueryIncentiveParams() (*incentivetypes.Params, error) { return &resp.Params, nil } -func (n *NodeConfig) QueryRewardGauge(sAddr sdk.AccAddress) (map[string]*incentivetypes.RewardGauge, error) { +func (n *NodeConfig) QueryRewardGauge(sAddr sdk.AccAddress) (map[string]*incentivetypes.RewardGaugesResponse, error) { path := fmt.Sprintf("/babylon/incentive/address/%s/reward_gauge", sAddr.String()) bz, err := n.QueryGRPCGateway(path, url.Values{}) if err != nil { @@ -51,18 +51,3 @@ func (n *NodeConfig) QueryRewardGauge(sAddr sdk.AccAddress) (map[string]*incenti return resp.RewardGauges, nil } - -func (n *NodeConfig) QueryBTCTimestampingGauge(epoch uint64) (*incentivetypes.Gauge, error) { - path := fmt.Sprintf("/babylon/incentive/btc_timestamping_gauge/%d", epoch) - bz, err := n.QueryGRPCGateway(path, url.Values{}) - if err != nil { - return nil, err - } - - var resp incentivetypes.QueryBTCTimestampingGaugeResponse - if err := util.Cdc.UnmarshalJSON(bz, &resp); err != nil { - return nil, err - } - - return resp.Gauge, nil -} diff --git a/test/e2e/configurer/config/constants.go b/test/e2e/configurer/config/constants.go index 685866478..975470927 100644 --- a/test/e2e/configurer/config/constants.go +++ b/test/e2e/configurer/config/constants.go @@ -16,5 +16,5 @@ const ( // PropSubmitBlocks estimated number of blocks it takes to submit for a proposal PropSubmitBlocks float32 = 1 // Upgrade prop files json - UpgradeSignetLaunchFilePath = "/upgrades/signet-launch.json" + UpgradeSignetLaunchFilePath = "/upgrades/v1.json" ) diff --git a/test/e2e/configurer/factory.go b/test/e2e/configurer/factory.go index 99848cebb..a16b664a3 100644 --- a/test/e2e/configurer/factory.go +++ b/test/e2e/configurer/factory.go @@ -129,8 +129,8 @@ func NewBTCTimestampingConfigurer(t *testing.T, isDebugLogEnabled bool) (Configu return NewCurrentBranchConfigurer(t, []*chain.Config{ - chain.New(t, containerManager, initialization.ChainAID, updateNodeConfigNameWithIdentifier(validatorConfigsChainA, identifier), ibcConfigChainA), - chain.New(t, containerManager, initialization.ChainBID, updateNodeConfigNameWithIdentifier(validatorConfigsChainB, identifier), ibcConfigChainB), + chain.New(t, containerManager, initialization.ChainAID, updateNodeConfigNameWithIdentifier(validatorConfigsChainA, identifier), nil), + chain.New(t, containerManager, initialization.ChainBID, updateNodeConfigNameWithIdentifier(validatorConfigsChainB, identifier), nil), }, withIBC(baseSetup), // base set up with IBC containerManager, @@ -146,8 +146,8 @@ func NewIBCTransferConfigurer(t *testing.T, isDebugLogEnabled bool) (Configurer, return NewCurrentBranchConfigurer(t, []*chain.Config{ - chain.New(t, containerManager, initialization.ChainAID, updateNodeConfigNameWithIdentifier(validatorConfigsChainA, identifier), ibcConfigChainA), - chain.New(t, containerManager, initialization.ChainBID, updateNodeConfigNameWithIdentifier(validatorConfigsChainB, identifier), ibcConfigChainB), + chain.New(t, containerManager, initialization.ChainAID, updateNodeConfigNameWithIdentifier(validatorConfigsChainA, identifier), nil), + chain.New(t, containerManager, initialization.ChainBID, updateNodeConfigNameWithIdentifier(validatorConfigsChainB, identifier), nil), }, withIBCTransferChannel(baseSetup), // base set up with IBC containerManager, @@ -164,8 +164,8 @@ func NewBTCTimestampingPhase2Configurer(t *testing.T, isDebugLogEnabled bool) (C return NewCurrentBranchConfigurer(t, []*chain.Config{ - chain.New(t, containerManager, initialization.ChainAID, updateNodeConfigNameWithIdentifier(validatorConfigsChainA, identifier), ibcConfigChainA), - chain.New(t, containerManager, initialization.ChainBID, updateNodeConfigNameWithIdentifier(validatorConfigsChainB, identifier), ibcConfigChainB), + chain.New(t, containerManager, initialization.ChainAID, updateNodeConfigNameWithIdentifier(validatorConfigsChainA, identifier), nil), + chain.New(t, containerManager, initialization.ChainBID, updateNodeConfigNameWithIdentifier(validatorConfigsChainB, identifier), nil), }, withPhase2HermesIBC(baseSetup, false), // IBC setup (requires contract address) containerManager, @@ -182,8 +182,8 @@ func NewBTCTimestampingPhase2RlyConfigurer(t *testing.T, isDebugLogEnabled bool) return NewCurrentBranchConfigurer(t, []*chain.Config{ - chain.New(t, containerManager, initialization.ChainAID, updateNodeConfigNameWithIdentifier(validatorConfigsChainA, identifier), ibcConfigChainA), - chain.New(t, containerManager, initialization.ChainBID, updateNodeConfigNameWithIdentifier(validatorConfigsChainB, identifier), ibcConfigChainB), + chain.New(t, containerManager, initialization.ChainAID, updateNodeConfigNameWithIdentifier(validatorConfigsChainA, identifier), nil), + chain.New(t, containerManager, initialization.ChainBID, updateNodeConfigNameWithIdentifier(validatorConfigsChainB, identifier), nil), }, withPhase2GoRlyIBC(baseSetup), // IBC setup with wasmd and Go relayer containerManager, @@ -226,7 +226,7 @@ func NewBTCStakingIntegrationConfigurer(t *testing.T, isDebugLogEnabled bool) (C } // NewSoftwareUpgradeConfigurer returns a new Configurer for Software Upgrade testing -func NewSoftwareUpgradeConfigurer(t *testing.T, isDebugLogEnabled bool, upgradePath string, btcHeaders []*btclighttypes.BTCHeaderInfo) (*UpgradeConfigurer, error) { +func NewSoftwareUpgradeConfigurer(t *testing.T, isDebugLogEnabled bool, upgradePath string, btcHeaders []*btclighttypes.BTCHeaderInfo, preUpgradeFunc PreUpgradeFunc) (*UpgradeConfigurer, error) { identifier := identifierName(t) containerManager, err := containers.NewManager(identifier, isDebugLogEnabled, false, true) if err != nil { @@ -247,6 +247,7 @@ func NewSoftwareUpgradeConfigurer(t *testing.T, isDebugLogEnabled bool, upgradeP containerManager, upgradePath, 0, + preUpgradeFunc, ), nil } diff --git a/test/e2e/configurer/upgrade.go b/test/e2e/configurer/upgrade.go index 65acb3204..9c692768c 100644 --- a/test/e2e/configurer/upgrade.go +++ b/test/e2e/configurer/upgrade.go @@ -29,10 +29,13 @@ type UpgradeSettings struct { ForkHeight int64 // non-zero height implies that this is a fork upgrade. } +type PreUpgradeFunc func([]*chain.Config) + type UpgradeConfigurer struct { baseConfigurer upgradeJsonFilePath string forkHeight int64 // forkHeight > 0 implies that this is a fork upgrade. Otherwise, proposal upgrade. + preUpgradeFunc PreUpgradeFunc } var _ Configurer = (*UpgradeConfigurer)(nil) @@ -40,7 +43,7 @@ var _ Configurer = (*UpgradeConfigurer)(nil) // NewUpgradeConfigurer returns a upgrade configurer, if forkHeight is bigger // than 0 it implies that it is a fork upgrade that does not pass by a gov prop // if it is set to zero it runs the upgrade by the gov prop. -func NewUpgradeConfigurer(t *testing.T, chainConfigs []*chain.Config, setupTests setupFn, containerManager *containers.Manager, upgradePlanFilePath string, forkHeight int64) *UpgradeConfigurer { +func NewUpgradeConfigurer(t *testing.T, chainConfigs []*chain.Config, setupTests setupFn, containerManager *containers.Manager, upgradePlanFilePath string, forkHeight int64, preUpgradeFunc PreUpgradeFunc) *UpgradeConfigurer { t.Helper() return &UpgradeConfigurer{ baseConfigurer: baseConfigurer{ @@ -52,6 +55,7 @@ func NewUpgradeConfigurer(t *testing.T, chainConfigs []*chain.Config, setupTests }, forkHeight: forkHeight, upgradeJsonFilePath: upgradePlanFilePath, + preUpgradeFunc: preUpgradeFunc, } } @@ -151,6 +155,7 @@ func (uc *UpgradeConfigurer) CreatePreUpgradeState() error { firstNode.BankMultiSendFromNode(addresses, amountToSend.String()) } + uc.preUpgradeFunc(uc.chainConfigs) return nil } @@ -248,6 +253,7 @@ func (uc *UpgradeConfigurer) upgradeContainers(chainConfig *chain.Config, propHe // upgrade containers to the locally compiled daemon uc.t.Logf("starting upgrade for chain-id: %s...", chainConfig.Id) uc.containerManager.CurrentRepository = containers.BabylonContainerName + uc.containerManager.CurrentTag = "latest" for _, node := range chainConfig.NodeConfigs { if err := node.Run(); err != nil { diff --git a/test/e2e/configurer/upgrade_test.go b/test/e2e/configurer/upgrade_test.go index b2acf9992..fb992c761 100644 --- a/test/e2e/configurer/upgrade_test.go +++ b/test/e2e/configurer/upgrade_test.go @@ -8,7 +8,7 @@ import ( "time" "github.com/babylonlabs-io/babylon/app" - v1 "github.com/babylonlabs-io/babylon/app/upgrades/signetlaunch" + v1 "github.com/babylonlabs-io/babylon/app/upgrades/v1" "github.com/babylonlabs-io/babylon/test/e2e/configurer/config" "github.com/stretchr/testify/require" ) @@ -23,7 +23,7 @@ func TestParseGovPropFromFile(t *testing.T) { _, msgProp, err := parseGovPropFromFile(cdc, upgradePath) require.NoError(t, err) - require.Equal(t, msgProp.Plan.Name, v1.Upgrade.UpgradeName) + require.Equal(t, msgProp.Plan.Name, v1.UpgradeName) } func TestWriteGovPropToFile(t *testing.T) { diff --git a/test/e2e/containers/config.go b/test/e2e/containers/config.go index 18b4f91e2..399c5103c 100644 --- a/test/e2e/containers/config.go +++ b/test/e2e/containers/config.go @@ -8,6 +8,7 @@ type ImageConfig struct { RelayerTag string CurrentRepository string + CurrentTag string } //nolint:deadcode @@ -15,8 +16,10 @@ const ( // Images that do not have specified tag, latest will be used by default. // name of babylon image produced by running `make build-docker` BabylonContainerName = "babylonlabs-io/babylond" - // name of babylon image produced by running `make build-docker-e2e` - BabylonContainerNameBeforeUpgrade = "babylonlabs-io/babylond-before-upgrade" + // name of babylon image before the upgrade + BabylonContainerNameBeforeUpgrade = "babylonlabs/babylond" + BabylonContainerTagBeforeUpgrade = "v0.9.3" + // name of the image produced by running `make e2e-init-chain` in contrib/images InitChainContainerE2E = "babylonlabs-io/babylond-e2e-init-chain" @@ -34,11 +37,13 @@ const ( func NewImageConfig(isCosmosRelayer, isUpgrade bool) (ic ImageConfig) { ic = ImageConfig{ CurrentRepository: BabylonContainerName, + CurrentTag: "latest", } if isUpgrade { // starts at the older version and later upgrades it to current branch... BabylonContainerName ic.CurrentRepository = BabylonContainerNameBeforeUpgrade + ic.CurrentTag = BabylonContainerTagBeforeUpgrade } if isCosmosRelayer { diff --git a/test/e2e/containers/containers.go b/test/e2e/containers/containers.go index 30c95d6b5..ee5518058 100644 --- a/test/e2e/containers/containers.go +++ b/test/e2e/containers/containers.go @@ -69,7 +69,7 @@ func (m *Manager) ExecTxCmd(t *testing.T, chainId string, nodeName string, comma // namely adding flags `--chain-id={chain-id} -b=block --yes --keyring-backend=test "--log_format=json"`, // and searching for `successStr` func (m *Manager) ExecTxCmdWithSuccessString(t *testing.T, chainId string, containerName string, command []string, successStr string) (bytes.Buffer, bytes.Buffer, error) { - allTxArgs := []string{fmt.Sprintf("--chain-id=%s", chainId), "-b=sync", "--yes", "--keyring-backend=test", "--log_format=json", "--home=/home/babylon/babylondata"} + allTxArgs := []string{fmt.Sprintf("--chain-id=%s", chainId), "--gas-prices=0.002ubbn", "-b=sync", "--yes", "--keyring-backend=test", "--log_format=json", "--home=/home/babylon/babylondata"} txCommand := append(command, allTxArgs...) return m.ExecCmd(t, containerName, txCommand, successStr) } @@ -132,6 +132,9 @@ func (m *Manager) ExecCmd(t *testing.T, fullContainerName string, command []stri // Note that this does not match all errors. // This only works if CLI outputs "Error" or "error" // to stderr. + fmt.Printf("\n Debug: errOut %s", errBufString) + fmt.Printf("\n Debug: output %s", outBuf.String()) + if (errRegex.MatchString(errBufString) || m.isDebugLogEnabled) && maxDebugLogTriesLeft > 0 { t.Log("\nstderr:") t.Log(errBufString) @@ -246,7 +249,7 @@ func (m *Manager) RunRlyResource(chainAID, osmoARelayerNodeName, osmoAValMnemoni return rlyResource, nil } -// RunNodeResource runs a node container. Assings containerName to the container. +// RunNodeResource runs a node container. Assigns containerName to the container. // Mounts the container on valConfigDir volume on the running host. Returns the container resource and error if any. func (m *Manager) RunNodeResource(chainId string, containerName, valCondifDir string) (*dockertest.Resource, error) { pwd, err := os.Getwd() @@ -257,6 +260,7 @@ func (m *Manager) RunNodeResource(chainId string, containerName, valCondifDir st runOpts := &dockertest.RunOptions{ Name: containerName, Repository: m.CurrentRepository, + Tag: m.CurrentTag, NetworkID: m.network.Network.ID, User: "root:root", Entrypoint: []string{ diff --git a/test/e2e/e2e_test.go b/test/e2e/e2e_test.go index ba03e4479..ed936b070 100644 --- a/test/e2e/e2e_test.go +++ b/test/e2e/e2e_test.go @@ -19,18 +19,6 @@ func TestBTCTimestampingTestSuite(t *testing.T) { suite.Run(t, new(BTCTimestampingTestSuite)) } -// TestBTCTimestampingPhase2HermesTestSuite tests BTC timestamping phase 2 protocol end-to-end, -// with the Hermes relayer -func TestBTCTimestampingPhase2HermesTestSuite(t *testing.T) { - suite.Run(t, new(BTCTimestampingPhase2HermesTestSuite)) -} - -// TestBTCTimestampingPhase2RlyTestSuite tests BTC timestamping phase 2 protocol end-to-end, -// with the Go relayer -func TestBTCTimestampingPhase2RlyTestSuite(t *testing.T) { - suite.Run(t, new(BTCTimestampingPhase2RlyTestSuite)) -} - // TestBTCStakingTestSuite tests BTC staking protocol end-to-end func TestBTCStakingTestSuite(t *testing.T) { suite.Run(t, new(BTCStakingTestSuite)) @@ -46,7 +34,11 @@ func TestBCDConsumerIntegrationTestSuite(t *testing.T) { suite.Run(t, new(BCDConsumerIntegrationTestSuite)) } -// TestSoftwareUpgradeSignetLaunchTestSuite tests software upgrade of signet launch end-to-end -func TestSoftwareUpgradeSignetLaunchTestSuite(t *testing.T) { - suite.Run(t, new(SoftwareUpgradeSignetLaunchTestSuite)) +func TestBTCStakingPreApprovalTestSuite(t *testing.T) { + suite.Run(t, new(BTCStakingPreApprovalTestSuite)) +} + +// TestSoftwareUpgradeV1TestnetTestSuite tests software upgrade of v1 testnet end-to-end +func TestSoftwareUpgradeV1TestnetTestSuite(t *testing.T) { + suite.Run(t, new(SoftwareUpgradeV1TestnetTestSuite)) } diff --git a/test/e2e/initialization/README.md b/test/e2e/initialization/README.md index 884b58a5a..5424c7b0b 100644 --- a/test/e2e/initialization/README.md +++ b/test/e2e/initialization/README.md @@ -5,4 +5,4 @@ This package contains all logic necessary for initializing configuration data either for a new chain or a single node via Docker containers. -Heavily based on Osmois init pacakage. +Heavily based on Osmois init package. diff --git a/test/e2e/initialization/config.go b/test/e2e/initialization/config.go index cb074552d..2bcba9c63 100644 --- a/test/e2e/initialization/config.go +++ b/test/e2e/initialization/config.go @@ -8,6 +8,7 @@ import ( sdkmath "cosmossdk.io/math" + minttypes "github.com/babylonlabs-io/babylon/x/mint/types" cryptocodec "github.com/cosmos/cosmos-sdk/crypto/codec" "github.com/cosmos/cosmos-sdk/crypto/keys/ed25519" "github.com/cosmos/cosmos-sdk/server" @@ -19,7 +20,6 @@ import ( genutiltypes "github.com/cosmos/cosmos-sdk/x/genutil/types" govtypes "github.com/cosmos/cosmos-sdk/x/gov/types" govv1 "github.com/cosmos/cosmos-sdk/x/gov/types/v1" - minttypes "github.com/cosmos/cosmos-sdk/x/mint/types" staketypes "github.com/cosmos/cosmos-sdk/x/staking/types" "github.com/cosmos/gogoproto/proto" @@ -29,11 +29,12 @@ import ( blctypes "github.com/babylonlabs-io/babylon/x/btclightclient/types" btclighttypes "github.com/babylonlabs-io/babylon/x/btclightclient/types" checkpointingtypes "github.com/babylonlabs-io/babylon/x/checkpointing/types" + finalitytypes "github.com/babylonlabs-io/babylon/x/finality/types" "github.com/babylonlabs-io/babylon/test/e2e/util" ) -// NodeConfig is a confiuration for the node supplied from the test runner +// NodeConfig is a configuration for the node supplied from the test runner // to initialization scripts. It should be backwards compatible with earlier // versions. If this struct is updated, the change must be backported to earlier // branches that might be used for upgrade testing. @@ -50,7 +51,7 @@ type NodeConfig struct { const ( // common BabylonDenom = "ubbn" - MinGasPrice = "0.000" + MinGasPrice = "0.002" ValidatorWalletName = "val" BabylonOpReturnTag = "01020304" @@ -58,11 +59,11 @@ const ( BabylonBtcFinalizationPeriod = 4 // chainA ChainAID = "bbn-test-a" - BabylonBalanceA = 200000000000 + BabylonBalanceA = 3000000000000 StakeAmountA = 100000000000 // chainB ChainBID = "bbn-test-b" - BabylonBalanceB = 500000000000 + BabylonBalanceB = 5000000000000 StakeAmountB = 400000000000 EpochDuration = time.Second * 60 @@ -264,6 +265,11 @@ func initGenesis( return err } + err = updateModuleGenesis(appGenState, finalitytypes.ModuleName, &finalitytypes.GenesisState{}, updateFinalityGenesis) + if err != nil { + return err + } + bz, err := json.MarshalIndent(appGenState, "", " ") if err != nil { return err @@ -310,7 +316,7 @@ func updateGovGenesis(votingPeriod, expeditedVotingPeriod time.Duration) func(go } func updateMintGenesis(mintGenState *minttypes.GenesisState) { - mintGenState.Params.MintDenom = BabylonDenom + mintGenState.BondDenom = BabylonDenom } func updateStakeGenesis(stakeGenState *staketypes.GenesisState) { @@ -352,6 +358,11 @@ func updateBtccheckpointGenesis(btccheckpointGenState *btccheckpointtypes.Genesi btccheckpointGenState.Params.CheckpointTag = BabylonOpReturnTag } +func updateFinalityGenesis(finalityGenState *finalitytypes.GenesisState) { + finalityGenState.Params = finalitytypes.DefaultParams() + finalityGenState.Params.FinalityActivationHeight = 0 +} + func updateGenUtilGenesis(c *internalChain) func(*genutiltypes.GenesisState) { return func(genUtilGenState *genutiltypes.GenesisState) { // generate genesis txs diff --git a/test/e2e/initialization/node.go b/test/e2e/initialization/node.go index 17eddb24d..dea6df497 100644 --- a/test/e2e/initialization/node.go +++ b/test/e2e/initialization/node.go @@ -32,6 +32,7 @@ import ( "github.com/spf13/viper" babylonApp "github.com/babylonlabs-io/babylon/app" + appparams "github.com/babylonlabs-io/babylon/app/params" "github.com/babylonlabs-io/babylon/cmd/babylond/cmd" "github.com/babylonlabs-io/babylon/crypto/bls12381" "github.com/babylonlabs-io/babylon/privval" @@ -120,7 +121,7 @@ func (n *internalNode) createAppConfig(nodeConfig *NodeConfig) { // set application configuration appCfgPath := filepath.Join(n.configDir(), "config", "app.toml") - appConfig := cmd.DefaultBabylonConfig() + appConfig := cmd.DefaultBabylonAppConfig() appConfig.BaseConfig.Pruning = nodeConfig.Pruning appConfig.BaseConfig.PruningKeepRecent = nodeConfig.PruningKeepRecent @@ -396,7 +397,7 @@ func (n *internalNode) signMsg(msgs ...sdk.Msg) (*sdktx.Tx, error) { } txBuilder.SetMemo(fmt.Sprintf("%s@%s:26656", n.nodeKey.ID(), n.moniker)) - txBuilder.SetFeeAmount(sdk.NewCoins()) + txBuilder.SetFeeAmount(sdk.NewCoins(sdk.NewCoin(appparams.DefaultBondDenom, math.NewInt(20000)))) txBuilder.SetGasLimit(uint64(200000 * len(msgs))) addr, err := n.keyInfo.GetAddress() diff --git a/test/e2e/scripts/hermes_bootstrap.sh b/test/e2e/scripts/hermes_bootstrap.sh index d9b2ccbac..2aed14c2b 100644 --- a/test/e2e/scripts/hermes_bootstrap.sh +++ b/test/e2e/scripts/hermes_bootstrap.sh @@ -50,7 +50,7 @@ store_prefix = 'ibc' max_gas = 50000000 gas_price = { price = 0.01, denom = 'ubbn' } gas_multiplier = 1.5 -clock_drift = '1m' # to accomdate docker containers +clock_drift = '1m' # to accommodate docker containers trusting_period = '14days' trust_threshold = { numerator = '1', denominator = '3' } [[chains]] @@ -66,7 +66,7 @@ store_prefix = 'ibc' max_gas = 50000000 gas_price = { price = 0.01, denom = 'ubbn' } gas_multiplier = 1.5 -clock_drift = '1m' # to accomdate docker containers +clock_drift = '1m' # to accommodate docker containers trusting_period = '14days' trust_threshold = { numerator = '1', denominator = '3' } EOF diff --git a/test/e2e/software_upgrade_e2e_signet_launch_test.go b/test/e2e/software_upgrade_e2e_signet_launch_test.go index 4323f3af9..4932b9658 100644 --- a/test/e2e/software_upgrade_e2e_signet_launch_test.go +++ b/test/e2e/software_upgrade_e2e_signet_launch_test.go @@ -1,32 +1,83 @@ package e2e import ( - "sort" + "math/rand" + "time" + sdkmath "cosmossdk.io/math" + sdk "github.com/cosmos/cosmos-sdk/types" "github.com/stretchr/testify/suite" "github.com/babylonlabs-io/babylon/app" - v1 "github.com/babylonlabs-io/babylon/app/upgrades/signetlaunch" + appparams "github.com/babylonlabs-io/babylon/app/params" + v1 "github.com/babylonlabs-io/babylon/app/upgrades/v1" + "github.com/babylonlabs-io/babylon/app/upgrades/v1/testnet" + "github.com/babylonlabs-io/babylon/testutil/datagen" btclighttypes "github.com/babylonlabs-io/babylon/x/btclightclient/types" "github.com/babylonlabs-io/babylon/test/e2e/configurer" + "github.com/babylonlabs-io/babylon/test/e2e/configurer/chain" "github.com/babylonlabs-io/babylon/test/e2e/configurer/config" + "github.com/babylonlabs-io/babylon/test/e2e/util" ) -type SoftwareUpgradeSignetLaunchTestSuite struct { +type SoftwareUpgradeV1TestnetTestSuite struct { suite.Suite - configurer *configurer.UpgradeConfigurer + configurer *configurer.UpgradeConfigurer + balancesBeforeUpgrade map[string]sdk.Coin } -func (s *SoftwareUpgradeSignetLaunchTestSuite) SetupSuite() { +func (s *SoftwareUpgradeV1TestnetTestSuite) SetupSuite() { s.T().Log("setting up e2e integration test suite...") var err error + s.balancesBeforeUpgrade = make(map[string]sdk.Coin) btcHeaderGenesis, err := app.SignetBtcHeaderGenesis(app.NewTmpBabylonApp().AppCodec()) s.NoError(err) - cfg, err := configurer.NewSoftwareUpgradeConfigurer(s.T(), true, config.UpgradeSignetLaunchFilePath, []*btclighttypes.BTCHeaderInfo{btcHeaderGenesis}) + tokenDistData, err := v1.LoadTokenDistributionFromData(testnet.TokensDistributionStr) + s.NoError(err) + + balanceToMintByAddr := make(map[string]int64) + for _, td := range tokenDistData.TokenDistribution { + balanceToMintByAddr[td.AddressSender] += td.Amount + balanceToMintByAddr[td.AddressReceiver] += 0 + } + + // func only runs right before the upgrade proposal is sent + preUpgradeFunc := func(chains []*chain.Config) { + node := chains[0].NodeConfigs[1] + uniqueAddrs := make(map[string]any) + + for addr, amountToMint := range balanceToMintByAddr { + uniqueAddrs[addr] = struct{}{} + if amountToMint <= 0 { + continue + } + + amountToSend := sdk.NewCoin(appparams.BaseCoinUnit, sdkmath.NewInt(amountToMint)) + node.BankSendFromNode(addr, amountToSend.String()) + } + + // needs to wait for a block to make sure the send tx was processed and + // it queries the real balances before upgrade. + node.WaitForNextBlock() + for addr := range uniqueAddrs { + balance, err := node.QueryBalance(addr, appparams.DefaultBondDenom) + s.NoError(err) + + s.balancesBeforeUpgrade[addr] = *balance + } + } + + cfg, err := configurer.NewSoftwareUpgradeConfigurer( + s.T(), + true, + config.UpgradeSignetLaunchFilePath, + []*btclighttypes.BTCHeaderInfo{btcHeaderGenesis}, + preUpgradeFunc, + ) s.NoError(err) s.configurer = cfg @@ -36,7 +87,7 @@ func (s *SoftwareUpgradeSignetLaunchTestSuite) SetupSuite() { s.Require().NoError(err) } -func (s *SoftwareUpgradeSignetLaunchTestSuite) TearDownSuite() { +func (s *SoftwareUpgradeV1TestnetTestSuite) TearDownSuite() { err := s.configurer.ClearResources() if err != nil { s.T().Logf("error to clear resources %s", err.Error()) @@ -44,25 +95,34 @@ func (s *SoftwareUpgradeSignetLaunchTestSuite) TearDownSuite() { } // TestUpgradeSignetLaunch Checks if the BTC Headers were inserted. -func (s *SoftwareUpgradeSignetLaunchTestSuite) TestUpgradeSignetLaunch() { +func (s *SoftwareUpgradeV1TestnetTestSuite) TestUpgradeSignetLaunch() { // chain is already upgraded, only checks for differences in state are expected chainA := s.configurer.GetChainConfig(0) - chainA.WaitUntilHeight(30) // five blocks more than upgrade - n, err := chainA.GetDefaultNode() + n, err := chainA.GetNodeAtIndex(2) s.NoError(err) govProp, err := s.configurer.ParseGovPropFromFile() s.NoError(err) + chainA.WaitUntilHeight(govProp.Plan.Height + 1) // waits for chain to produce blocks + + r := rand.New(rand.NewSource(time.Now().Unix())) + fptBTCSK, _, _ := datagen.GenRandomBTCKeyPair(r) + fp := CreateNodeFP( + s.T(), + r, + fptBTCSK, + n, + ) bbnApp := app.NewTmpBabylonApp() // makes sure that the upgrade was actually executed expectedUpgradeHeight := govProp.Plan.Height - resp := n.QueryAppliedPlan(v1.Upgrade.UpgradeName) + resp := n.QueryAppliedPlan(v1.UpgradeName) s.EqualValues(expectedUpgradeHeight, resp.Height, "the plan should be applied at the height %d", expectedUpgradeHeight) - btcHeadersInserted, err := v1.LoadBTCHeadersFromData(bbnApp.AppCodec()) + btcHeadersInserted, err := v1.LoadBTCHeadersFromData(bbnApp.AppCodec(), testnet.NewBtcHeadersStr) s.NoError(err) lenHeadersInserted := len(btcHeadersInserted) @@ -81,31 +141,11 @@ func (s *SoftwareUpgradeSignetLaunchTestSuite) TestUpgradeSignetLaunch() { s.EqualValues(headerInserted.Header.MarshalHex(), headerStoredResp.HeaderHex) } - oldFPsLen := 0 // it should not have any FP - fpsFromNode := n.QueryFinalityProviders() - - fpsInserted, err := v1.LoadSignedFPsFromData(bbnApp.AppCodec(), bbnApp.TxConfig().TxJSONDecoder()) - s.NoError(err) - s.Equal(len(fpsInserted), len(fpsFromNode)+oldFPsLen) - - // sorts all the FPs from node to match the ones from loaded string json - sort.Slice(fpsFromNode, func(i, j int) bool { - return fpsFromNode[i].Addr > fpsFromNode[j].Addr - }) - - for i, fpInserted := range fpsInserted { - fpFromKeeper := fpsFromNode[i] - s.EqualValues(fpFromKeeper.Addr, fpInserted.Addr) - s.EqualValues(fpFromKeeper.Description, fpInserted.Description) - s.EqualValues(fpFromKeeper.Commission.String(), fpInserted.Commission.String()) - s.EqualValues(fpFromKeeper.Pop.String(), fpInserted.Pop.String()) - } - // check that staking params correctly deserialize and that they are the same // as the one from the data stakingParams := n.QueryBTCStakingParams() - stakingParamsFromData, err := v1.LoadBtcStakingParamsFromData(bbnApp.AppCodec()) + stakingParamsFromData, err := v1.LoadBtcStakingParamsFromData(bbnApp.AppCodec(), testnet.BtcStakingParamStr) s.NoError(err) s.EqualValues(stakingParamsFromData, *stakingParams) @@ -114,8 +154,77 @@ func (s *SoftwareUpgradeSignetLaunchTestSuite) TestUpgradeSignetLaunch() { // as the one from the data finalityParams := n.QueryFinalityParams() - finalityParamsFromData, err := v1.LoadFinalityParamsFromData(bbnApp.AppCodec()) + finalityParamsFromData, err := v1.LoadFinalityParamsFromData(bbnApp.AppCodec(), testnet.FinalityParamStr) s.NoError(err) - s.EqualValues(finalityParamsFromData, *finalityParams) + + // check that incentive params correctly deserialize and that they are the same + // as the one from the data + incentiveParams, err := n.QueryIncentiveParams() + s.NoError(err) + + incentiveParamsFromData, err := v1.LoadIncentiveParamsFromData(bbnApp.AppCodec(), testnet.IncentiveParamStr) + s.NoError(err) + s.EqualValues(incentiveParamsFromData, *incentiveParams) + + // FP tries to commit with start height before finality activation height + // it should fail, after commits with start height = finality activation height + // and it should work. + _, msgCommitPubRandList, err := datagen.GenRandomMsgCommitPubRandList(r, fptBTCSK, finalityParamsFromData.FinalityActivationHeight-1, finalityParamsFromData.MinPubRand) + s.NoError(err) + n.CommitPubRandList( + fp.BtcPk, + msgCommitPubRandList.StartHeight, + msgCommitPubRandList.NumPubRand, + msgCommitPubRandList.Commitment, + msgCommitPubRandList.Sig, + ) + // the tx does not fails, but it actually + // does not commits for that height. + listByHeight := n.QueryListPubRandCommit(fp.BtcPk) + _, listFound := listByHeight[finalityParamsFromData.FinalityActivationHeight] + s.False(listFound, "this list should not exists, because the msg should have failed") + + // commits with valid start height + _, msgCommitPubRandList, err = datagen.GenRandomMsgCommitPubRandList(r, fptBTCSK, finalityParamsFromData.FinalityActivationHeight, finalityParamsFromData.MinPubRand) + s.NoError(err) + n.WaitForNextBlock() + n.CommitPubRandList( + msgCommitPubRandList.FpBtcPk, + msgCommitPubRandList.StartHeight, + msgCommitPubRandList.NumPubRand, + msgCommitPubRandList.Commitment, + msgCommitPubRandList.Sig, + ) + + n.WaitForNextBlock() + + listByHeight = n.QueryListPubRandCommit(msgCommitPubRandList.FpBtcPk) + _, listFound = listByHeight[finalityParamsFromData.FinalityActivationHeight] + s.True(listFound, "this list should exists, because the msg sent is after the activation height") + + // Verifies the balance differences were really executed + tokenDistData, err := v1.LoadTokenDistributionFromData(testnet.TokensDistributionStr) + s.NoError(err) + + balanceDiffByAddr := make(map[string]int64) + for _, td := range tokenDistData.TokenDistribution { + balanceDiffByAddr[td.AddressSender] -= td.Amount + balanceDiffByAddr[td.AddressReceiver] += td.Amount + } + + for addr, diff := range balanceDiffByAddr { + coinDiff := sdk.NewCoin(appparams.DefaultBondDenom, sdkmath.NewInt(util.Abs(diff))) + expectedBalance := s.balancesBeforeUpgrade[addr].Add(coinDiff) + if diff < 0 { + expectedBalance = s.balancesBeforeUpgrade[addr].Sub(coinDiff) + } + + balanceAfterUpgrade, err := n.QueryBalance(addr, appparams.DefaultBondDenom) + s.NoError(err) + + expBalance := expectedBalance.String() + actBalance := balanceAfterUpgrade.String() + s.Equal(expBalance, actBalance, "addr %s has different balances. Expected %s != %s Actual", addr, expBalance, actBalance) + } } diff --git a/test/e2e/upgrades/signet-launch.json b/test/e2e/upgrades/v1.json similarity index 87% rename from test/e2e/upgrades/signet-launch.json rename to test/e2e/upgrades/v1.json index 2bd5a9f31..282a018af 100644 --- a/test/e2e/upgrades/signet-launch.json +++ b/test/e2e/upgrades/v1.json @@ -4,9 +4,9 @@ "@type": "/cosmos.upgrade.v1beta1.MsgSoftwareUpgrade", "authority": "bbn10d07y265gmmuvt4z0w9aw880jnsr700jduz5f2", "plan": { - "name": "signet-launch", + "name": "v1", "time": "0001-01-01T00:00:00Z", - "height": "21", + "height": "52", "info": "Msg info", "upgraded_client_state": null } @@ -17,4 +17,4 @@ "title": "any title", "summary": "any summary", "expedited": false -} +} \ No newline at end of file diff --git a/test/e2e/util/math.go b/test/e2e/util/math.go new file mode 100644 index 000000000..1b8403e0a --- /dev/null +++ b/test/e2e/util/math.go @@ -0,0 +1,10 @@ +package util + +import "golang.org/x/exp/constraints" + +func Abs[T constraints.Integer](x T) T { + if x < 0 { + return -x + } + return x +} diff --git a/x/btcstaking/keeper/keeper_test.go b/testutil/btcstaking-helper/keeper.go similarity index 57% rename from x/btcstaking/keeper/keeper_test.go rename to testutil/btcstaking-helper/keeper.go index 14bf24e91..12999cb97 100644 --- a/x/btcstaking/keeper/keeper_test.go +++ b/testutil/btcstaking-helper/keeper.go @@ -1,15 +1,19 @@ -package keeper_test +package testutil import ( "math/rand" "testing" "cosmossdk.io/core/header" + "cosmossdk.io/log" sdkmath "cosmossdk.io/math" + "cosmossdk.io/store" + storemetrics "cosmossdk.io/store/metrics" "github.com/btcsuite/btcd/btcec/v2" "github.com/btcsuite/btcd/chaincfg" "github.com/btcsuite/btcd/txscript" "github.com/btcsuite/btcd/wire" + dbm "github.com/cosmos/cosmos-db" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/golang/mock/gomock" "github.com/stretchr/testify/require" @@ -23,10 +27,14 @@ import ( "github.com/babylonlabs-io/babylon/x/btcstaking/types" bsckeeper "github.com/babylonlabs-io/babylon/x/btcstkconsumer/keeper" bsctypes "github.com/babylonlabs-io/babylon/x/btcstkconsumer/types" + epochingtypes "github.com/babylonlabs-io/babylon/x/epoching/types" + fkeeper "github.com/babylonlabs-io/babylon/x/finality/keeper" + ftypes "github.com/babylonlabs-io/babylon/x/finality/types" ) var ( - net = &chaincfg.SimNetParams + btcTipHeight = uint32(30) + timestampedEpoch = uint64(10) ) // TODO: move this to keeper package rather than keeper_test so that @@ -34,57 +42,102 @@ var ( type Helper struct { t testing.TB - Ctx sdk.Context - BTCStakingKeeper *keeper.Keeper + Ctx sdk.Context + BTCStakingKeeper *keeper.Keeper + MsgServer types.MsgServer + BTCStkConsumerKeeper *bsckeeper.Keeper - BTCLightClientKeeper *types.MockBTCLightClientKeeper - BTCCheckpointKeeper *types.MockBtcCheckpointKeeper - FinalityKeeper *types.MockFinalityKeeper - BTCStakingHooks *types.MockBtcStakingHooks - MsgServer types.MsgServer BtcStkConsumerMsgServer bsctypes.MsgServer - Net *chaincfg.Params + + FinalityKeeper *fkeeper.Keeper + FMsgServer ftypes.MsgServer + + BTCLightClientKeeper *types.MockBTCLightClientKeeper + BTCCheckpointKeeper *types.MockBtcCheckpointKeeper + CheckpointingKeeper *ftypes.MockCheckpointingKeeper + Net *chaincfg.Params +} + +type UnbondingTxInfo struct { + UnbondingTxInclusionProof *types.InclusionProof + UnbondingHeaderInfo *btclctypes.BTCHeaderInfo } func NewHelper( t testing.TB, btclcKeeper *types.MockBTCLightClientKeeper, btccKeeper *types.MockBtcCheckpointKeeper, - finalityKeeper *types.MockFinalityKeeper, ) *Helper { - k, bscKeeper, ctx := keepertest.BTCStakingKeeper(t, btclcKeeper, btccKeeper, finalityKeeper) - ctx = ctx.WithHeaderInfo(header.Info{Height: 1}) + ctrl := gomock.NewController(t) + + // mock refundable messages + iKeeper := ftypes.NewMockIncentiveKeeper(ctrl) + iKeeper.EXPECT().IndexRefundableMsg(gomock.Any(), gomock.Any()).AnyTimes() + + ckptKeeper := ftypes.NewMockCheckpointingKeeper(ctrl) + ckptKeeper.EXPECT().GetLastFinalizedEpoch(gomock.Any()).Return(timestampedEpoch).AnyTimes() + + db := dbm.NewMemDB() + stateStore := store.NewCommitMultiStore(db, log.NewTestLogger(t), storemetrics.NewNoOpMetrics()) + + k, _ := keepertest.BTCStakingKeeperWithStore(t, db, stateStore, btclcKeeper, btccKeeper, iKeeper) msgSrvr := keeper.NewMsgServerImpl(*k) - btcStkConsumerMsgServer := bsckeeper.NewMsgServerImpl(*bscKeeper) - ctrl := gomock.NewController(t) - mockedHooks := types.NewMockBtcStakingHooks(ctrl) - mockedHooks.EXPECT().AfterFinalityProviderActivated(gomock.Any(), gomock.Any()).Return(nil).AnyTimes() - k.SetHooks(mockedHooks) + bscKeeper := k.BscKeeper.(bsckeeper.Keeper) + btcStkConsumerMsgServer := bsckeeper.NewMsgServerImpl(bscKeeper) + + fk, ctx := keepertest.FinalityKeeperWithStore(t, db, stateStore, k, iKeeper, ckptKeeper) + fMsgSrvr := fkeeper.NewMsgServerImpl(*fk) + + // set all parameters + err := k.SetParams(ctx, types.DefaultParams()) + require.NoError(t, err) + err = fk.SetParams(ctx, ftypes.DefaultParams()) + require.NoError(t, err) + + ctx = ctx.WithHeaderInfo(header.Info{Height: 1}).WithBlockHeight(1) return &Helper{ - t: t, - Ctx: ctx, - BTCStakingKeeper: k, - BTCStkConsumerKeeper: bscKeeper, - BTCLightClientKeeper: btclcKeeper, - BTCCheckpointKeeper: btccKeeper, - MsgServer: msgSrvr, + t: t, + Ctx: ctx, + + BTCStakingKeeper: k, + MsgServer: msgSrvr, + + BTCStkConsumerKeeper: &bscKeeper, BtcStkConsumerMsgServer: btcStkConsumerMsgServer, - Net: &chaincfg.SimNetParams, + + FinalityKeeper: fk, + FMsgServer: fMsgSrvr, + + BTCLightClientKeeper: btclcKeeper, + BTCCheckpointKeeper: btccKeeper, + CheckpointingKeeper: ckptKeeper, + Net: &chaincfg.SimNetParams, } } +func (h *Helper) T() testing.TB { + return h.t +} + func (h *Helper) NoError(err error) { require.NoError(h.t, err) } -func (h *Helper) Error(err error) { - require.Error(h.t, err) +func (h *Helper) Error(err error, msgAndArgs ...any) { + require.Error(h.t, err, msgAndArgs...) +} + +func (h *Helper) BeginBlocker() { + err := h.BTCStakingKeeper.BeginBlocker(h.Ctx) + h.NoError(err) + err = h.FinalityKeeper.BeginBlocker(h.Ctx) + h.NoError(err) } func (h *Helper) GenAndApplyParams(r *rand.Rand) ([]*btcec.PrivateKey, []*btcec.PublicKey) { - return h.GenAndApplyCustomParams(r, 100, 0) + return h.GenAndApplyCustomParams(r, 100, 0, 0) } func (h *Helper) SetCtxHeight(height uint64) { @@ -93,8 +146,9 @@ func (h *Helper) SetCtxHeight(height uint64) { func (h *Helper) GenAndApplyCustomParams( r *rand.Rand, - finalizationTimeout uint64, + finalizationTimeout uint32, minUnbondingTime uint32, + allowListExpirationHeight uint64, ) ([]*btcec.PrivateKey, []*btcec.PublicKey) { // mock base header baseHeader := btclctypes.SimnetGenesisBlock() @@ -113,19 +167,19 @@ func (h *Helper) GenAndApplyCustomParams( slashingPkScript, err := txscript.PayToAddrScript(slashingAddress) h.NoError(err) err = h.BTCStakingKeeper.SetParams(h.Ctx, types.Params{ - CovenantPks: bbn.NewBIP340PKsFromBTCPKs(covenantPKs), - CovenantQuorum: 3, - MinStakingValueSat: 1000, - MaxStakingValueSat: int64(4 * 10e8), - MinStakingTimeBlocks: 10, - MaxStakingTimeBlocks: 10000, - SlashingPkScript: slashingPkScript, - MinSlashingTxFeeSat: 10, - MinCommissionRate: sdkmath.LegacyMustNewDecFromStr("0.01"), - SlashingRate: sdkmath.LegacyNewDecWithPrec(int64(datagen.RandomInt(r, 41)+10), 2), - MaxActiveFinalityProviders: 100, - MinUnbondingTimeBlocks: minUnbondingTime, - UnbondingFeeSat: 1000, + CovenantPks: bbn.NewBIP340PKsFromBTCPKs(covenantPKs), + CovenantQuorum: 3, + MinStakingValueSat: 1000, + MaxStakingValueSat: int64(4 * 10e8), + MinStakingTimeBlocks: 10, + MaxStakingTimeBlocks: 10000, + SlashingPkScript: slashingPkScript, + MinSlashingTxFeeSat: 10, + MinCommissionRate: sdkmath.LegacyMustNewDecFromStr("0.01"), + SlashingRate: sdkmath.LegacyNewDecWithPrec(int64(datagen.RandomInt(r, 41)+10), 2), + MinUnbondingTimeBlocks: minUnbondingTime, + UnbondingFeeSat: 1000, + AllowListExpirationHeight: allowListExpirationHeight, }) h.NoError(err) return covenantSKs, covenantPKs @@ -191,22 +245,34 @@ func (h *Helper) CreateConsumerFinalityProvider(r *rand.Rand, consumerID string) return fpSK, fpPK, fp, nil } -func (h *Helper) CreateDelegationCustom( +func (h *Helper) CreateDelegation( r *rand.Rand, + delSK *btcec.PrivateKey, fpPKs []*btcec.PublicKey, changeAddress string, stakingValue int64, stakingTime uint16, unbondingValue int64, unbondingTime uint16, -) (string, *btcec.PrivateKey, *btcec.PublicKey, *types.MsgCreateBTCDelegation, error) { - delSK, delPK, err := datagen.GenRandomBTCKeyPair(r) - h.NoError(err) + usePreApproval bool, + addToAllowList bool, +) (string, *types.MsgCreateBTCDelegation, *types.BTCDelegation, *btclctypes.BTCHeaderInfo, *types.InclusionProof, *UnbondingTxInfo, error) { stakingTimeBlocks := stakingTime bsParams := h.BTCStakingKeeper.GetParams(h.Ctx) + bcParams := h.BTCCheckpointKeeper.GetParams(h.Ctx) covPKs, err := bbn.NewBTCPKsFromBIP340PKs(bsParams.CovenantPks) h.NoError(err) + // if not set, use default values for unbonding value and time + defaultUnbondingValue := stakingValue - 1000 + if unbondingValue == 0 { + unbondingValue = defaultUnbondingValue + } + defaultUnbondingTime := types.MinimumUnbondingTime(&bsParams, &bcParams) + 1 + if unbondingTime == 0 { + unbondingTime = uint16(defaultUnbondingTime) + } + testStakingInfo := datagen.GenBTCStakingSlashingInfo( r, h.t, @@ -234,14 +300,15 @@ func (h *Helper) CreateDelegationCustom( prevBlock, _ := datagen.GenRandomBtcdBlock(r, 0, nil) btcHeaderWithProof := datagen.CreateBlockWithTransaction(r, &prevBlock.Header, testStakingInfo.StakingTx) btcHeader := btcHeaderWithProof.HeaderBytes + btcHeaderInfo := &btclctypes.BTCHeaderInfo{Header: &btcHeader, Height: 10} serializedStakingTx, err := bbn.SerializeBTCTx(testStakingInfo.StakingTx) h.NoError(err) - txInfo := btcctypes.NewTransactionInfo(&btcctypes.TransactionKey{Index: 1, Hash: btcHeader.Hash()}, serializedStakingTx, btcHeaderWithProof.SpvProof.MerkleNodes) + txInclusionProof := types.NewInclusionProof(&btcctypes.TransactionKey{Index: 1, Hash: btcHeader.Hash()}, btcHeaderWithProof.SpvProof.MerkleNodes) // mock for testing k-deep stuff - h.BTCLightClientKeeper.EXPECT().GetHeaderByHash(gomock.Eq(h.Ctx), gomock.Eq(btcHeader.Hash())).Return(&btclctypes.BTCHeaderInfo{Header: &btcHeader, Height: 10}).AnyTimes() - h.BTCLightClientKeeper.EXPECT().GetTipInfo(gomock.Eq(h.Ctx)).Return(&btclctypes.BTCHeaderInfo{Height: 30}).AnyTimes() + h.BTCLightClientKeeper.EXPECT().GetHeaderByHash(gomock.Eq(h.Ctx), gomock.Eq(btcHeader.Hash())).Return(btcHeaderInfo).AnyTimes() + h.BTCLightClientKeeper.EXPECT().GetTipInfo(gomock.Eq(h.Ctx)).Return(&btclctypes.BTCHeaderInfo{Height: btcTipHeight}).AnyTimes() slashingSpendInfo, err := testStakingInfo.StakingInfo.SlashingPathSpendInfo() h.NoError(err) @@ -287,6 +354,16 @@ func (h *Helper) CreateDelegationCustom( serializedUnbondingTx, err := bbn.SerializeBTCTx(testUnbondingInfo.UnbondingTx) h.NoError(err) + prevBlockForUnbonding, _ := datagen.GenRandomBtcdBlock(r, 0, nil) + btcUnbondingHeaderWithProof := datagen.CreateBlockWithTransaction(r, &prevBlockForUnbonding.Header, testUnbondingInfo.UnbondingTx) + btcUnbondingHeader := btcUnbondingHeaderWithProof.HeaderBytes + btcUnbondingHeaderInfo := &btclctypes.BTCHeaderInfo{Header: &btcUnbondingHeader, Height: 11} + unbondingTxInclusionProof := types.NewInclusionProof( + &btcctypes.TransactionKey{Index: 1, Hash: btcUnbondingHeader.Hash()}, + btcUnbondingHeaderWithProof.SpvProof.MerkleNodes, + ) + h.BTCLightClientKeeper.EXPECT().GetHeaderByHash(gomock.Eq(h.Ctx), gomock.Eq(btcUnbondingHeader.Hash())).Return(btcUnbondingHeaderInfo).AnyTimes() + // all good, construct and send MsgCreateBTCDelegation message msgCreateBTCDel := &types.MsgCreateBTCDelegation{ StakerAddr: staker.String(), @@ -295,7 +372,7 @@ func (h *Helper) CreateDelegationCustom( Pop: pop, StakingTime: uint32(stakingTimeBlocks), StakingValue: stakingValue, - StakingTx: txInfo, + StakingTx: serializedStakingTx, SlashingTx: testStakingInfo.SlashingTx, DelegatorSlashingSig: delegatorSig, UnbondingTx: serializedUnbondingTx, @@ -305,52 +382,43 @@ func (h *Helper) CreateDelegationCustom( DelegatorUnbondingSlashingSig: delSlashingTxSig, } - _, err = h.MsgServer.CreateBTCDelegation(h.Ctx, msgCreateBTCDel) - if err != nil { - return "", nil, nil, nil, err + if !usePreApproval { + msgCreateBTCDel.StakingTxInclusionProof = txInclusionProof } - return stakingTxHash, delSK, delPK, msgCreateBTCDel, nil -} - -func (h *Helper) CreateDelegation( - r *rand.Rand, - fpPKs []*btcec.PublicKey, - changeAddress string, - stakingValue int64, - stakingTime uint16, -) (string, *btcec.PrivateKey, *btcec.PublicKey, *types.MsgCreateBTCDelegation, *types.BTCDelegation, error) { - bsParams := h.BTCStakingKeeper.GetParams(h.Ctx) - bcParams := h.BTCCheckpointKeeper.GetParams(h.Ctx) - - minUnbondingTime := types.MinimumUnbondingTime( - &bsParams, - &bcParams, - ) + if addToAllowList { + h.BTCStakingKeeper.IndexAllowedStakingTransaction(h.Ctx, &stkTxHash) + } - stakingTxHash, delSK, delPK, msgCreateBTCDel, err := h.CreateDelegationCustom( - r, - fpPKs, - changeAddress, - stakingValue, - stakingTime, - stakingValue-1000, - uint16(minUnbondingTime)+1, - ) + _, err = h.MsgServer.CreateBTCDelegation(h.Ctx, msgCreateBTCDel) if err != nil { - return "", nil, nil, nil, nil, err + return "", nil, nil, nil, nil, nil, err } - stakingMsgTx, err := bbn.NewBTCTxFromBytes(msgCreateBTCDel.StakingTx.Transaction) + stakingMsgTx, err := bbn.NewBTCTxFromBytes(msgCreateBTCDel.StakingTx) if err != nil { - return "", nil, nil, nil, nil, err + return "", nil, nil, nil, nil, nil, err } btcDel, err := h.BTCStakingKeeper.GetBTCDelegation(h.Ctx, stakingMsgTx.TxHash().String()) if err != nil { - return "", nil, nil, nil, nil, err + return "", nil, nil, nil, nil, nil, err + } + + // ensure the delegation is still pending + require.Equal(h.t, btcDel.GetStatus(btcTipHeight, bcParams.CheckpointFinalizationTimeout, bsParams.CovenantQuorum), types.BTCDelegationStatus_PENDING) + + if usePreApproval { + // the BTC delegation does not have inclusion proof + require.False(h.t, btcDel.HasInclusionProof()) + } else { + // the BTC delegation has inclusion proof + require.True(h.t, btcDel.HasInclusionProof()) } - return stakingTxHash, delSK, delPK, msgCreateBTCDel, btcDel, nil + return stakingTxHash, msgCreateBTCDel, btcDel, btcHeaderInfo, txInclusionProof, &UnbondingTxInfo{ + UnbondingTxInclusionProof: unbondingTxInclusionProof, + UnbondingHeaderInfo: btcUnbondingHeaderInfo, + }, nil } func (h *Helper) GenerateCovenantSignaturesMessages( @@ -434,15 +502,16 @@ func (h *Helper) CreateCovenantSigs( msgCreateBTCDel *types.MsgCreateBTCDelegation, del *types.BTCDelegation, ) { - stakingTx, err := bbn.NewBTCTxFromBytes(del.StakingTx) - stakingTxHash := stakingTx.TxHash().String() - + bcParams := h.BTCCheckpointKeeper.GetParams(h.Ctx) bsParams := h.BTCStakingKeeper.GetParams(h.Ctx) + stakingTx, err := bbn.NewBTCTxFromBytes(del.StakingTx) h.NoError(err) + stakingTxHash := stakingTx.TxHash().String() + covenantMsgs := h.GenerateCovenantSignaturesMessages(r, covenantSKs, msgCreateBTCDel, del) - for _, msg := range covenantMsgs { - msgCopy := msg + for _, m := range covenantMsgs { + msgCopy := m _, err := h.MsgServer.AddCovenantSigs(h.Ctx, msgCopy) h.NoError(err) } @@ -451,35 +520,85 @@ func (h *Helper) CreateCovenantSigs( */ actualDelWithCovenantSigs, err := h.BTCStakingKeeper.GetBTCDelegation(h.Ctx, stakingTxHash) h.NoError(err) - require.Equal(h.t, len(actualDelWithCovenantSigs.CovenantSigs), int(bsParams.CovenantQuorum)) + require.Equal(h.t, len(actualDelWithCovenantSigs.CovenantSigs), len(covenantMsgs)) require.True(h.t, actualDelWithCovenantSigs.HasCovenantQuorums(h.BTCStakingKeeper.GetParams(h.Ctx).CovenantQuorum)) require.NotNil(h.t, actualDelWithCovenantSigs.BtcUndelegation) require.NotNil(h.t, actualDelWithCovenantSigs.BtcUndelegation.CovenantSlashingSigs) require.NotNil(h.t, actualDelWithCovenantSigs.BtcUndelegation.CovenantUnbondingSigList) - require.Len(h.t, actualDelWithCovenantSigs.BtcUndelegation.CovenantUnbondingSigList, int(bsParams.CovenantQuorum)) - require.Len(h.t, actualDelWithCovenantSigs.BtcUndelegation.CovenantSlashingSigs, int(bsParams.CovenantQuorum)) + require.Len(h.t, actualDelWithCovenantSigs.BtcUndelegation.CovenantUnbondingSigList, len(covenantMsgs)) + require.Len(h.t, actualDelWithCovenantSigs.BtcUndelegation.CovenantSlashingSigs, len(covenantMsgs)) require.Len(h.t, actualDelWithCovenantSigs.BtcUndelegation.CovenantSlashingSigs[0].AdaptorSigs, len(del.FpBtcPkList)) + + // ensure the BTC delegation is verified (if using pre-approval flow) or active + status := actualDelWithCovenantSigs.GetStatus(btcTipHeight, bcParams.CheckpointFinalizationTimeout, bsParams.CovenantQuorum) + if msgCreateBTCDel.StakingTxInclusionProof != nil { + // not pre-approval flow, the BTC delegation should be active + require.Equal(h.t, status, types.BTCDelegationStatus_ACTIVE) + } else { + // pre-approval flow, the BTC delegation should be verified + require.Equal(h.t, status, types.BTCDelegationStatus_VERIFIED) + } } -func (h *Helper) GetDelegationAndCheckValues( - r *rand.Rand, - msgCreateBTCDel *types.MsgCreateBTCDelegation, - fpPK *btcec.PublicKey, - delegatorPK *btcec.PublicKey, +func (h *Helper) AddInclusionProof( stakingTxHash string, -) *types.BTCDelegation { - actualDel, err := h.BTCStakingKeeper.GetBTCDelegation(h.Ctx, stakingTxHash) - h.NoError(err) - // TODO: update pop in BTC delegation - require.Equal(h.t, msgCreateBTCDel.StakerAddr, actualDel.StakerAddr) - require.Equal(h.t, msgCreateBTCDel.Pop, actualDel.Pop) - require.Equal(h.t, msgCreateBTCDel.StakingTx.Transaction, actualDel.StakingTx) - require.Equal(h.t, msgCreateBTCDel.SlashingTx, actualDel.SlashingTx) - // ensure the BTC delegation in DB is correctly formatted - err = actualDel.ValidateBasic() - h.NoError(err) - // delegation is not activated by covenant yet - require.False(h.t, actualDel.HasCovenantQuorums(h.BTCStakingKeeper.GetParams(h.Ctx).CovenantQuorum)) - return actualDel + btcHeader *btclctypes.BTCHeaderInfo, + proof *types.InclusionProof, +) { + bcParams := h.BTCCheckpointKeeper.GetParams(h.Ctx) + bsParams := h.BTCStakingKeeper.GetParams(h.Ctx) + + // Get the BTC delegation and ensure it's verified + del, err := h.BTCStakingKeeper.GetBTCDelegation(h.Ctx, stakingTxHash) + h.NoError(err) + status := del.GetStatus(btcTipHeight, bcParams.CheckpointFinalizationTimeout, bsParams.CovenantQuorum) + require.Equal(h.t, status, types.BTCDelegationStatus_VERIFIED, "the BTC delegation shall be verified") + + // Create the MsgAddBTCDelegationInclusionProof message + msg := &types.MsgAddBTCDelegationInclusionProof{ + StakingTxHash: stakingTxHash, + StakingTxInclusionProof: proof, + } + + // mock BTC header that includes the staking tx + h.BTCLightClientKeeper.EXPECT().GetHeaderByHash(gomock.Eq(h.Ctx), gomock.Eq(btcHeader.Header.Hash())).Return(btcHeader).AnyTimes() + + // Call the AddBTCDelegationInclusionProof handler + _, err = h.MsgServer.AddBTCDelegationInclusionProof(h.Ctx, msg) + h.NoError(err) + + // Verify that the inclusion proof is added successfully and the BTC delegation + // has been activated + updatedDel, err := h.BTCStakingKeeper.GetBTCDelegation(h.Ctx, stakingTxHash) + h.NoError(err) + status = updatedDel.GetStatus(btcTipHeight, bcParams.CheckpointFinalizationTimeout, bsParams.CovenantQuorum) + require.Equal(h.t, status, types.BTCDelegationStatus_ACTIVE, "the BTC delegation shall be active") +} + +func (h *Helper) CommitPubRandList( + r *rand.Rand, + fpSK *btcec.PrivateKey, + fp *types.FinalityProvider, + startHeight uint64, + numPubRand uint64, + timestamped bool, +) *datagen.RandListInfo { + randListInfo, msg, err := datagen.GenRandomMsgCommitPubRandList(r, fpSK, startHeight, numPubRand) + h.NoError(err) + + // if timestamped, use the timestamped epoch, otherwise use the next epoch + var epoch uint64 + if timestamped { + epoch = timestampedEpoch + } else { + epoch = timestampedEpoch + 1 + } + + h.CheckpointingKeeper.EXPECT().GetEpoch(gomock.Any()).Return(&epochingtypes.Epoch{EpochNumber: epoch}).Times(1) + + _, err = h.FMsgServer.CommitPubRandList(h.Ctx, msg) + h.NoError(err) + + return randListInfo } diff --git a/testutil/datagen/btc_header_chain.go b/testutil/datagen/btc_header_chain.go index e28421ef3..d24649558 100644 --- a/testutil/datagen/btc_header_chain.go +++ b/testutil/datagen/btc_header_chain.go @@ -16,19 +16,19 @@ var initHeader = chaincfg.SimNetParams.GenesisBlock.Header type BTCHeaderPartialChain struct { // slice of Headers forming valid chain Headers []*wire.BlockHeader - initialHeaderHeight uint64 + initialHeaderHeight uint32 inititialHeaderTotalWork sdkmath.Uint } func NewBTCHeaderChainWithLength( r *rand.Rand, - initialHeaderHeight uint64, - initialHeaderTotalWork uint64, + initialHeaderHeight uint32, + initialHeaderTotalWork uint32, length uint32) *BTCHeaderPartialChain { return NewBTCHeaderChainFromParent( r, initialHeaderHeight, - sdkmath.NewUint(initialHeaderTotalWork), + sdkmath.NewUint(uint64(initialHeaderTotalWork)), &initHeader, length, ) @@ -50,14 +50,13 @@ func NewBTCHeaderChainFromParentInfo( func NewBTCHeaderChainFromParent( r *rand.Rand, - initialHeaderHeight uint64, + initialHeaderHeight uint32, initialHeaderTotalWork sdkmath.Uint, parent *wire.BlockHeader, length uint32, ) *BTCHeaderPartialChain { headers := GenRandomValidChainStartingFrom( r, - initialHeaderHeight, parent, nil, length, diff --git a/testutil/datagen/btc_header_info.go b/testutil/datagen/btc_header_info.go index c680acdef..796e0182e 100644 --- a/testutil/datagen/btc_header_info.go +++ b/testutil/datagen/btc_header_info.go @@ -161,9 +161,9 @@ func GenRandomBTCHeaderBytes(r *rand.Rand, parent *btclightclienttypes.BTCHeader return bbn.NewBTCHeaderBytesFromBlockHeader(btcdHeader) } -// GenRandomBTCHeight returns a random uint64 -func GenRandomBTCHeight(r *rand.Rand) uint64 { - return r.Uint64() +// GenRandomBTCHeight returns a random uint32 +func GenRandomBTCHeight(r *rand.Rand) uint32 { + return r.Uint32() } // GenRandomBTCHeaderInfoWithParentAndBits generates a BTCHeaderInfo object in which the `header.PrevBlock` points to the `parent` @@ -253,7 +253,6 @@ func GenRandomBtcdValidHeader( func GenRandomValidChainStartingFrom( r *rand.Rand, - parentHeaderHeight uint64, parentHeader *wire.BlockHeader, timeBetweenBlocks *TimeBetweenBlocksInfo, numHeaders uint32, @@ -283,8 +282,8 @@ func GenRandBtcChainInsertingInKeeper( r *rand.Rand, k *btclightclientk.Keeper, ctx context.Context, - initialHeight uint64, - chainLength uint64, + initialHeight uint32, + chainLength uint32, ) (*btclightclienttypes.BTCHeaderInfo, *BTCHeaderPartialChain) { genesisHeader := NewBTCHeaderChainWithLength(r, initialHeight, 0, 1) genesisHeaderInfo := genesisHeader.GetChainInfo()[0] @@ -292,7 +291,7 @@ func GenRandBtcChainInsertingInKeeper( randomChain := NewBTCHeaderChainFromParentInfo( r, genesisHeaderInfo, - uint32(chainLength), + chainLength, ) err := k.InsertHeadersWithHookAndEvents(ctx, randomChain.ChainToBytes()) require.NoError(t, err) @@ -304,7 +303,7 @@ func GenRandBtcChainInsertingInKeeper( func ChainToInfoChain( chain []*wire.BlockHeader, - initialHeaderNumber uint64, + initialHeaderNumber uint32, initialHeaderTotalWork sdkmath.Uint, ) []*btclightclienttypes.BTCHeaderInfo { if len(chain) == 0 { @@ -321,7 +320,7 @@ func ChainToInfoChain( hash := header.BlockHash() headerBytes := bbn.NewBTCHeaderBytesFromBlockHeader(header) headerHash := bbn.NewBTCHeaderHashBytesFromChainhash(&hash) - headerNumber := initialHeaderNumber + uint64(i) + headerNumber := initialHeaderNumber + uint32(i) headerInfo := btclightclienttypes.NewBTCHeaderInfo( &headerBytes, @@ -340,7 +339,7 @@ func ChainToInfoChain( func ChainToInfoResponseChain( chain []*wire.BlockHeader, - initialHeaderNumber uint64, + initialHeaderNumber uint32, initialHeaderTotalWork sdkmath.Uint, ) []*btclightclienttypes.BTCHeaderInfoResponse { if len(chain) == 0 { @@ -357,7 +356,7 @@ func ChainToInfoResponseChain( hash := header.BlockHash() headerBytes := bbn.NewBTCHeaderBytesFromBlockHeader(header) headerHash := bbn.NewBTCHeaderHashBytesFromChainhash(&hash) - headerNumber := initialHeaderNumber + uint64(i) + headerNumber := initialHeaderNumber + uint32(i) headerInfoResponse := btclightclienttypes.NewBTCHeaderInfoResponse( &headerBytes, diff --git a/testutil/datagen/btc_transaction.go b/testutil/datagen/btc_transaction.go index ae6a58947..dae95d047 100644 --- a/testutil/datagen/btc_transaction.go +++ b/testutil/datagen/btc_transaction.go @@ -466,7 +466,7 @@ func getRandomCheckpointDataForEpoch(r *rand.Rand, e uint64) testCheckpointData } } -// both f and s must be parts retrived from txformat.Encode +// both f and s must be parts retrieved from txformat.Encode func getExpectedOpReturn(tag txformat.BabylonTag, f []byte, s []byte) []byte { firstPartNoHeader, err := txformat.GetCheckpointData( tag, @@ -533,7 +533,7 @@ func EncodeRawCkptToTestData(rawBTCCkpt *txformat.RawBtcCheckpoint) *TestRawChec // test helper to generate random number int in range, min and max must be non-negative func numInRange(r *rand.Rand, min int, max int) int { if min < 0 || max < 0 || min >= max { - panic("min and max maust be positve numbers. min must be smaller than max") + panic("min and max maust be positive numbers. min must be smaller than max") } return r.Intn(max-min) + min diff --git a/testutil/datagen/btcstaking.go b/testutil/datagen/btcstaking.go index 8f7feb880..0deb9c0ea 100644 --- a/testutil/datagen/btcstaking.go +++ b/testutil/datagen/btcstaking.go @@ -79,7 +79,7 @@ func GenCustomFinalityProvider(r *rand.Rand, btcSK *btcec.PrivateKey, fpAddr sdk }, nil } -// TODO: accomodate presign unbonding flow +// TODO: accommodate presign unbonding flow func GenRandomBTCDelegation( r *rand.Rand, t *testing.T, @@ -90,7 +90,8 @@ func GenRandomBTCDelegation( covenantPks []*btcec.PublicKey, covenantQuorum uint32, slashingPkScript []byte, - startHeight, endHeight, totalSat uint64, + stakingTime, startHeight, endHeight uint32, + totalSat uint64, slashingRate sdkmath.LegacyDec, slashingChangeLockTime uint16, ) (*bstypes.BTCDelegation, error) { @@ -113,7 +114,7 @@ func GenRandomBTCDelegation( fpPKs, covenantPks, covenantQuorum, - uint16(endHeight-startHeight), + uint16(stakingTime), int64(totalSat), slashingPkScript, slashingRate, @@ -154,6 +155,7 @@ func GenRandomBTCDelegation( BtcPk: delBTCPK, Pop: pop, FpBtcPkList: fpBTCPKs, + StakingTime: uint32(stakingTime), StartHeight: startHeight, EndHeight: endHeight, TotalSat: totalSat, diff --git a/testutil/datagen/incentive.go b/testutil/datagen/incentive.go index d379e82ba..f22a5b82d 100644 --- a/testutil/datagen/incentive.go +++ b/testutil/datagen/incentive.go @@ -7,7 +7,7 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" btcctypes "github.com/babylonlabs-io/babylon/x/btccheckpoint/types" - bstypes "github.com/babylonlabs-io/babylon/x/btcstaking/types" + ftypes "github.com/babylonlabs-io/babylon/x/finality/types" itypes "github.com/babylonlabs-io/babylon/x/incentive/types" ) @@ -29,7 +29,7 @@ func GenRandomDenom(r *rand.Rand) string { } func GenRandomStakeholderType(r *rand.Rand) itypes.StakeholderType { - stBytes := []byte{byte(RandomInt(r, 4))} + stBytes := []byte{byte(RandomInt(r, 2))} st, err := itypes.NewStakeHolderType(stBytes) if err != nil { panic(err) // only programming error is possible @@ -77,26 +77,26 @@ func GenRandomGauge(r *rand.Rand) *itypes.Gauge { return itypes.NewGauge(coins...) } -func GenRandomBTCDelDistInfo(r *rand.Rand) (*bstypes.BTCDelDistInfo, error) { +func GenRandomBTCDelDistInfo(r *rand.Rand) (*ftypes.BTCDelDistInfo, error) { btcPK, err := GenRandomBIP340PubKey(r) if err != nil { return nil, err } - return &bstypes.BTCDelDistInfo{ - BtcPk: btcPK, - StakerAddr: GenRandomAccount().Address, - VotingPower: RandomInt(r, 1000) + 1, + return &ftypes.BTCDelDistInfo{ + BtcPk: btcPK, + StakerAddr: GenRandomAccount().Address, + TotalSat: RandomInt(r, 1000) + 1, }, nil } -func GenRandomFinalityProviderDistInfo(r *rand.Rand) (*bstypes.FinalityProviderDistInfo, error) { +func GenRandomFinalityProviderDistInfo(r *rand.Rand) (*ftypes.FinalityProviderDistInfo, error) { // create finality provider with random commission fp, err := GenRandomFinalityProvider(r) if err != nil { return nil, err } // create finality provider distribution info - fpDistInfo := bstypes.NewFinalityProviderDistInfo(fp) + fpDistInfo := ftypes.NewFinalityProviderDistInfo(fp) // add a random number of BTC delegation distribution info numBTCDels := RandomInt(r, 100) + 1 for i := uint64(0); i < numBTCDels; i++ { @@ -105,14 +105,14 @@ func GenRandomFinalityProviderDistInfo(r *rand.Rand) (*bstypes.FinalityProviderD return nil, err } fpDistInfo.BtcDels = append(fpDistInfo.BtcDels, btcDelDistInfo) - fpDistInfo.TotalVotingPower += btcDelDistInfo.VotingPower + fpDistInfo.TotalBondedSat += btcDelDistInfo.TotalSat fpDistInfo.IsTimestamped = true } return fpDistInfo, nil } -func GenRandomVotingPowerDistCache(r *rand.Rand, maxFPs uint32) (*bstypes.VotingPowerDistCache, error) { - dc := bstypes.NewVotingPowerDistCache() +func GenRandomVotingPowerDistCache(r *rand.Rand, maxFPs uint32) (*ftypes.VotingPowerDistCache, error) { + dc := ftypes.NewVotingPowerDistCache() // a random number of finality providers numFps := RandomInt(r, 10) + 1 for i := uint64(0); i < numFps; i++ { diff --git a/testutil/datagen/tendermint.go b/testutil/datagen/tendermint.go index 8a40fc275..2654d32bd 100644 --- a/testutil/datagen/tendermint.go +++ b/testutil/datagen/tendermint.go @@ -5,11 +5,10 @@ import ( "time" "cosmossdk.io/core/header" + zctypes "github.com/babylonlabs-io/babylon/x/zoneconcierge/types" cmtproto "github.com/cometbft/cometbft/proto/tendermint/types" sdk "github.com/cosmos/cosmos-sdk/types" ibctmtypes "github.com/cosmos/ibc-go/v8/modules/light-clients/07-tendermint" - - zctypes "github.com/babylonlabs-io/babylon/x/zoneconcierge/types" ) func GenRandomTMHeader(r *rand.Rand, chainID string, height uint64) *cmtproto.Header { diff --git a/testutil/datagen/val_set.go b/testutil/datagen/val_set.go index b98429e29..89c5f4731 100644 --- a/testutil/datagen/val_set.go +++ b/testutil/datagen/val_set.go @@ -29,6 +29,10 @@ func GenRandomValidatorAddress() sdk.ValAddress { return sdk.ValAddress(ed25519.GenPrivKey().PubKey().Address()) } +func GenRandomAddress() sdk.AccAddress { + return sdk.AccAddress(ed25519.GenPrivKey().PubKey().Address()) +} + func GenRandomPubkeysAndSigs(n int, msg []byte) ([]bls12381.PublicKey, []bls12381.Signature) { var blsPubkeys []bls12381.PublicKey var blsSigs []bls12381.Signature diff --git a/testutil/helper/helper.go b/testutil/helper/helper.go index fc34f024a..40dd21015 100644 --- a/testutil/helper/helper.go +++ b/testutil/helper/helper.go @@ -307,8 +307,8 @@ func (h *Helper) CheckDelegator(delegator sdk.AccAddress, val sdk.ValAddress, fo require.Equal(h.t, ok, found) } -func (h *Helper) AddDelegation(del *btcstakingtypes.BTCDelegation) { - err := h.App.BTCStakingKeeper.AddBTCDelegation(h.Ctx, del) +func (h *Helper) AddDelegation(del *btcstakingtypes.BTCDelegation, minUnbondingTime uint32) { + err := h.App.BTCStakingKeeper.AddBTCDelegation(h.Ctx, del, minUnbondingTime) h.NoError(err) } diff --git a/testutil/keeper/btclightclient.go b/testutil/keeper/btclightclient.go index ebacf965e..711308755 100644 --- a/testutil/keeper/btclightclient.go +++ b/testutil/keeper/btclightclient.go @@ -1,6 +1,7 @@ package keeper import ( + "context" "testing" "cosmossdk.io/core/header" @@ -26,6 +27,10 @@ import ( btclightclientt "github.com/babylonlabs-io/babylon/x/btclightclient/types" ) +type MockIncentiveKeeper struct{} + +func (mik MockIncentiveKeeper) IndexRefundableMsg(ctx context.Context, msg sdk.Msg) {} + func BTCLightClientKeeper(t testing.TB) (*btclightclientk.Keeper, sdk.Context) { k, ctx, _ := BTCLightClientKeeperWithCustomParams(t, btclightclientt.DefaultParams()) return k, ctx @@ -40,7 +45,10 @@ func NewBTCHeaderBytesList(chain []*wire.BlockHeader) []bbn.BTCHeaderBytes { return chainBytes } -func BTCLightClientKeeperWithCustomParams(t testing.TB, p btclightclientt.Params) (*btclightclientk.Keeper, sdk.Context, corestore.KVStoreService) { +func BTCLightClientKeeperWithCustomParams( + t testing.TB, + p btclightclientt.Params, +) (*btclightclientk.Keeper, sdk.Context, corestore.KVStoreService) { storeKey := storetypes.NewKVStoreKey(btclightclientt.StoreKey) db := dbm.NewMemDB() @@ -52,12 +60,12 @@ func BTCLightClientKeeperWithCustomParams(t testing.TB, p btclightclientt.Params cdc := codec.NewProtoCodec(registry) testCfg := bbn.ParseBtcOptionsFromConfig(bapp.TmpAppOptions()) - stServ := runtime.NewKVStoreService(storeKey) k := btclightclientk.NewKeeper( cdc, stServ, testCfg, + &MockIncentiveKeeper{}, authtypes.NewModuleAddress(govtypes.ModuleName).String(), ) diff --git a/testutil/keeper/btcstaking.go b/testutil/keeper/btcstaking.go index 90da0cb2e..c9940a385 100644 --- a/testutil/keeper/btcstaking.go +++ b/testutil/keeper/btcstaking.go @@ -8,10 +8,6 @@ import ( "cosmossdk.io/store" storemetrics "cosmossdk.io/store/metrics" storetypes "cosmossdk.io/store/types" - "github.com/babylonlabs-io/babylon/x/btcstaking/keeper" - "github.com/babylonlabs-io/babylon/x/btcstaking/types" - bsckeeper "github.com/babylonlabs-io/babylon/x/btcstkconsumer/keeper" - bsctypes "github.com/babylonlabs-io/babylon/x/btcstkconsumer/types" "github.com/btcsuite/btcd/chaincfg" cmtproto "github.com/cometbft/cometbft/proto/tendermint/types" dbm "github.com/cosmos/cosmos-db" @@ -22,16 +18,25 @@ import ( authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" govtypes "github.com/cosmos/cosmos-sdk/x/gov/types" "github.com/stretchr/testify/require" + + "github.com/babylonlabs-io/babylon/x/btcstaking/keeper" + "github.com/babylonlabs-io/babylon/x/btcstaking/types" + bsckeeper "github.com/babylonlabs-io/babylon/x/btcstkconsumer/keeper" + bsctypes "github.com/babylonlabs-io/babylon/x/btcstkconsumer/types" ) -func BTCStakingKeeper( +func BTCStakingKeeperWithStore( t testing.TB, + db dbm.DB, + stateStore store.CommitMultiStore, btclcKeeper types.BTCLightClientKeeper, btccKeeper types.BtcCheckpointKeeper, - finalityKeeper types.FinalityKeeper, -) (*keeper.Keeper, *bsckeeper.Keeper, sdk.Context) { - db := dbm.NewMemDB() - stateStore := store.NewCommitMultiStore(db, log.NewTestLogger(t), storemetrics.NewNoOpMetrics()) + iKeeper types.IncentiveKeeper, +) (*keeper.Keeper, sdk.Context) { + storeKey := storetypes.NewKVStoreKey(types.StoreKey) + + stateStore.MountStoreWithDB(storeKey, storetypes.StoreTypeIAVL, db) + require.NoError(t, stateStore.LoadLatestVersion()) registry := codectypes.NewInterfaceRegistry() cdc := codec.NewProtoCodec(registry) @@ -49,18 +54,13 @@ func BTCStakingKeeper( authtypes.NewModuleAddress(govtypes.ModuleName).String(), ) - // mount KV store for BTC staking keeper - storeKey := storetypes.NewKVStoreKey(types.StoreKey) - stateStore.MountStoreWithDB(storeKey, storetypes.StoreTypeIAVL, db) - require.NoError(t, stateStore.LoadLatestVersion()) - k := keeper.NewKeeper( cdc, runtime.NewKVStoreService(storeKey), btclcKeeper, btccKeeper, - finalityKeeper, bscKeeper, + iKeeper, &chaincfg.SimNetParams, authtypes.NewModuleAddress(govtypes.ModuleName).String(), ) @@ -68,10 +68,24 @@ func BTCStakingKeeper( ctx := sdk.NewContext(stateStore, cmtproto.Header{}, false, log.NewNopLogger()) ctx = ctx.WithHeaderInfo(header.Info{}) + return &k, ctx +} + +func BTCStakingKeeper( + t testing.TB, + btclcKeeper types.BTCLightClientKeeper, + btccKeeper types.BtcCheckpointKeeper, + iKeeper types.IncentiveKeeper, +) (*keeper.Keeper, sdk.Context) { + db := dbm.NewMemDB() + stateStore := store.NewCommitMultiStore(db, log.NewTestLogger(t), storemetrics.NewNoOpMetrics()) + + k, ctx := BTCStakingKeeperWithStore(t, db, stateStore, btclcKeeper, btccKeeper, iKeeper) + // Initialize params if err := k.SetParams(ctx, types.DefaultParams()); err != nil { panic(err) } - return &k, &bscKeeper, ctx + return k, ctx } diff --git a/testutil/keeper/finality.go b/testutil/keeper/finality.go index 1b8a2adee..c2b22e5f3 100644 --- a/testutil/keeper/finality.go +++ b/testutil/keeper/finality.go @@ -22,11 +22,16 @@ import ( "github.com/babylonlabs-io/babylon/x/finality/types" ) -func FinalityKeeper(t testing.TB, bsKeeper types.BTCStakingKeeper, iKeeper types.IncentiveKeeper, cKeeper types.CheckpointingKeeper) (*keeper.Keeper, sdk.Context) { +func FinalityKeeperWithStore( + t testing.TB, + db dbm.DB, + stateStore store.CommitMultiStore, + bsKeeper types.BTCStakingKeeper, + iKeeper types.IncentiveKeeper, + ckptKeeper types.CheckpointingKeeper, +) (*keeper.Keeper, sdk.Context) { storeKey := storetypes.NewKVStoreKey(types.StoreKey) - db := dbm.NewMemDB() - stateStore := store.NewCommitMultiStore(db, log.NewTestLogger(t), storemetrics.NewNoOpMetrics()) stateStore.MountStoreWithDB(storeKey, storetypes.StoreTypeIAVL, db) require.NoError(t, stateStore.LoadLatestVersion()) @@ -38,17 +43,33 @@ func FinalityKeeper(t testing.TB, bsKeeper types.BTCStakingKeeper, iKeeper types runtime.NewKVStoreService(storeKey), bsKeeper, iKeeper, - cKeeper, + ckptKeeper, authtypes.NewModuleAddress(govtypes.ModuleName).String(), ) ctx := sdk.NewContext(stateStore, cmtproto.Header{}, false, log.NewNopLogger()) ctx = ctx.WithHeaderInfo(header.Info{}) + return &k, ctx +} + +func FinalityKeeper( + t testing.TB, + bsKeeper types.BTCStakingKeeper, + iKeeper types.IncentiveKeeper, + ckptKeeper types.CheckpointingKeeper, +) (*keeper.Keeper, sdk.Context) { + db := dbm.NewMemDB() + stateStore := store.NewCommitMultiStore(db, log.NewTestLogger(t), storemetrics.NewNoOpMetrics()) + + k, ctx := FinalityKeeperWithStore(t, db, stateStore, bsKeeper, iKeeper, ckptKeeper) + // Initialize params - if err := k.SetParams(ctx, types.DefaultParams()); err != nil { + dParams := types.DefaultParams() + dParams.FinalityActivationHeight = 0 + if err := k.SetParams(ctx, dParams); err != nil { panic(err) } - return &k, ctx + return k, ctx } diff --git a/types/btcutils.go b/types/btcutils.go index a9a8fca66..04e04babf 100644 --- a/types/btcutils.go +++ b/types/btcutils.go @@ -5,6 +5,7 @@ import ( "encoding/hex" "errors" "fmt" + "math" "math/big" "time" @@ -88,7 +89,11 @@ func SerializeBTCTx(tx *wire.MsgTx) ([]byte, error) { func GetOutputIdxInBTCTx(tx *wire.MsgTx, output *wire.TxOut) (uint32, error) { for i, txOut := range tx.TxOut { if bytes.Equal(txOut.PkScript, output.PkScript) && txOut.Value == output.Value { - return uint32(i), nil + if i <= math.MaxUint32 { + return uint32(i), nil + } else { + return 0, fmt.Errorf("output index out of acceptable range") + } } } diff --git a/types/retry/log.go b/types/retry/log.go deleted file mode 100644 index 07b95b0f8..000000000 --- a/types/retry/log.go +++ /dev/null @@ -1,9 +0,0 @@ -package retry - -import ( - "cosmossdk.io/log" - "os" -) - -// TODO add log formatters -var logger = log.NewLogger(os.Stdout) diff --git a/types/retry/retry.go b/types/retry/retry.go deleted file mode 100644 index c26a5200b..000000000 --- a/types/retry/retry.go +++ /dev/null @@ -1,96 +0,0 @@ -package retry - -import ( - "crypto/rand" - "errors" - "math/big" - "time" - - btcctypes "github.com/babylonlabs-io/babylon/x/btccheckpoint/types" - btclctypes "github.com/babylonlabs-io/babylon/x/btclightclient/types" - checkpointingtypes "github.com/babylonlabs-io/babylon/x/checkpointing/types" -) - -// unrecoverableErrors is a list of errors which are unsafe and should not be retried. -var unrecoverableErrors = []error{ - btclctypes.ErrHeaderParentDoesNotExist, - btclctypes.ErrChainWithNotEnoughWork, - btclctypes.ErrInvalidHeader, - btcctypes.ErrProvidedHeaderDoesNotHaveAncestor, - btcctypes.ErrInvalidHeader, - btcctypes.ErrNoCheckpointsForPreviousEpoch, - btcctypes.ErrInvalidCheckpointProof, - checkpointingtypes.ErrBlsPrivKeyDoesNotExist, - // TODO Add more errors here -} - -// expectedErrors is a list of errors which can safely be ignored and should not be retried. -var expectedErrors = []error{ - btcctypes.ErrDuplicatedSubmission, - btcctypes.ErrInvalidHeader, - // TODO Add more errors here -} - -func isUnrecoverableErr(err error) bool { - for _, e := range unrecoverableErrors { - if errors.Is(err, e) { - return true - } - } - - return false -} - -func isExpectedErr(err error) bool { - for _, e := range expectedErrors { - if errors.Is(err, e) { - return true - } - } - - return false -} - -// Do executes a func with retry -// TODO: Remove this function, and make our programs to depend on retires based -// on some standard retry library -func Do(sleep time.Duration, maxSleepTime time.Duration, retryableFunc func() error) error { - if err := retryableFunc(); err != nil { - if isUnrecoverableErr(err) { - logger.Error("Skip retry, error unrecoverable", "err", err) - return err - } - - if isExpectedErr(err) { - logger.Error("Skip retry, error expected", "err", err) - return nil - } - - // Add some randomness to prevent thrashing - // TODO: This duration should be passed by the caller - jitter, randomnessErr := randDuration(int64(sleep)) - if randomnessErr != nil { - return randomnessErr - } - sleep = sleep + jitter/2 - - if sleep > maxSleepTime { - logger.Info("retry timed out") - return err - } - - logger.Info("starting exponential backoff", "sleep", sleep, "err", err) - time.Sleep(sleep) - - return Do(2*sleep, maxSleepTime, retryableFunc) - } - return nil -} - -func randDuration(maxNumber int64) (dur time.Duration, err error) { - randNumber, err := rand.Int(rand.Reader, big.NewInt(maxNumber)) - if err != nil { - return dur, err - } - return time.Duration(randNumber.Int64()), nil -} diff --git a/types/retry/retry_test.go b/types/retry/retry_test.go deleted file mode 100644 index 2b048c971..000000000 --- a/types/retry/retry_test.go +++ /dev/null @@ -1,33 +0,0 @@ -package retry - -import ( - "errors" - "testing" - "time" - - "github.com/stretchr/testify/require" -) - -func TestUnrecoverableError(t *testing.T) { - err := Do(1*time.Second, 1*time.Minute, func() error { - return unrecoverableErrors[0] - }) - require.Error(t, err) -} - -func TestExpectedError(t *testing.T) { - err := Do(1*time.Second, 1*time.Minute, func() error { - return expectedErrors[0] - }) - require.NoError(t, err) -} - -func TestDoNotShadowAnError(t *testing.T) { - var expectedError = errors.New("expected error") - - err := Do(1*time.Second, 1*time.Second, func() error { - return expectedError - }) - require.Error(t, err) - require.ErrorIs(t, err, expectedError) -} diff --git a/wasmbinding/bindings/query.go b/wasmbinding/bindings/query.go index cc81ecbff..cd1da2085 100644 --- a/wasmbinding/bindings/query.go +++ b/wasmbinding/bindings/query.go @@ -14,7 +14,7 @@ type BtcHeaderByHash struct { } type BtcHeaderByHeight struct { - Height uint64 `json:"height"` + Height uint32 `json:"height"` } type CurrentEpochResponse struct { @@ -41,7 +41,7 @@ type BtcBlockHeader struct { type BtcBlockHeaderInfo struct { Header *BtcBlockHeader `json:"header,omitempty"` - Height uint64 `json:"height"` + Height uint32 `json:"height"` } type BtcTipResponse struct { diff --git a/wasmbinding/grpc_whitelist.go b/wasmbinding/grpc_whitelist.go index 3c409b560..eadb5f13f 100644 --- a/wasmbinding/grpc_whitelist.go +++ b/wasmbinding/grpc_whitelist.go @@ -2,9 +2,9 @@ package wasmbinding import ( wasmkeeper "github.com/CosmWasm/wasmd/x/wasm/keeper" - bsttypes "github.com/babylonlabs-io/babylon/x/btcstaking/types" bsctypes "github.com/babylonlabs-io/babylon/x/btcstkconsumer/types" epochtypes "github.com/babylonlabs-io/babylon/x/epoching/types" + ftypes "github.com/babylonlabs-io/babylon/x/finality/types" ) // WhitelistedGrpcQuery returns the whitelisted Grpc queries @@ -13,7 +13,7 @@ func WhitelistedGrpcQuery() wasmkeeper.AcceptedQueries { // btcstkconsumer "/babylon.btcstkconsumer.v1.Query/FinalityProvider": &bsctypes.QueryFinalityProviderResponse{}, // btcstaking - "/babylon.btcstaking.v1.Query/FinalityProviderCurrentPower": &bsttypes.QueryFinalityProviderCurrentPowerResponse{}, + "/babylon.btcstaking.v1.Query/FinalityProviderCurrentPower": &ftypes.QueryFinalityProviderCurrentPowerResponse{}, // for testing "/babylon.epoching.v1.Query/CurrentEpoch": &epochtypes.QueryCurrentEpochResponse{}, } diff --git a/wasmbinding/test/custom_query_test.go b/wasmbinding/test/custom_query_test.go index 965019608..711fd0879 100644 --- a/wasmbinding/test/custom_query_test.go +++ b/wasmbinding/test/custom_query_test.go @@ -17,7 +17,7 @@ import ( "github.com/babylonlabs-io/babylon/wasmbinding/bindings" ) -// TODO consider doing it by enviromental variables as currently it may fail on some +// TODO consider doing it by environmental variables as currently it may fail on some // weird architectures func getArtifactPath() string { if runtime.GOARCH == "amd64" { diff --git a/wasmbinding/wasm.go b/wasmbinding/wasm.go index f2533962d..9e1e997e6 100644 --- a/wasmbinding/wasm.go +++ b/wasmbinding/wasm.go @@ -10,6 +10,7 @@ import ( bbn "github.com/babylonlabs-io/babylon/types" "github.com/babylonlabs-io/babylon/wasmbinding/bindings" lcKeeper "github.com/babylonlabs-io/babylon/x/btclightclient/keeper" + checkpointingkeeper "github.com/babylonlabs-io/babylon/x/checkpointing/keeper" epochingkeeper "github.com/babylonlabs-io/babylon/x/epoching/keeper" zckeeper "github.com/babylonlabs-io/babylon/x/zoneconcierge/keeper" "github.com/cosmos/cosmos-sdk/baseapp" @@ -18,21 +19,24 @@ import ( ) type QueryPlugin struct { - epochingKeeper *epochingkeeper.Keeper - zcKeeper *zckeeper.Keeper - lcKeeper *lcKeeper.Keeper + epochingKeeper *epochingkeeper.Keeper + checkpointingkeeper *checkpointingkeeper.Keeper + lcKeeper *lcKeeper.Keeper + zcKeeper *zckeeper.Keeper } // NewQueryPlugin returns a reference to a new QueryPlugin. func NewQueryPlugin( ek *epochingkeeper.Keeper, - zcKeeper *zckeeper.Keeper, + ch *checkpointingkeeper.Keeper, lcKeeper *lcKeeper.Keeper, + zcKeeper *zckeeper.Keeper, ) *QueryPlugin { return &QueryPlugin{ - epochingKeeper: ek, - zcKeeper: zcKeeper, - lcKeeper: lcKeeper, + epochingKeeper: ek, + checkpointingkeeper: ch, + lcKeeper: lcKeeper, + zcKeeper: zcKeeper, } } @@ -57,8 +61,10 @@ func CustomQuerier(qp *QueryPlugin) func(ctx sdk.Context, request json.RawMessag } return bz, nil + case contractQuery.LatestFinalizedEpochInfo != nil: - epoch := qp.zcKeeper.GetLastFinalizedEpoch(ctx) + epoch := qp.checkpointingkeeper.GetLastFinalizedEpoch(ctx) + epochInfo, err := qp.epochingKeeper.GetHistoricalEpoch(ctx, epoch) if err != nil { @@ -155,10 +161,11 @@ func CustomQuerier(qp *QueryPlugin) func(ctx sdk.Context, request json.RawMessag func RegisterCustomPlugins( ek *epochingkeeper.Keeper, - zcKeeper *zckeeper.Keeper, + ck *checkpointingkeeper.Keeper, lcKeeper *lcKeeper.Keeper, + zcKeeper *zckeeper.Keeper, ) []wasmkeeper.Option { - wasmQueryPlugin := NewQueryPlugin(ek, zcKeeper, lcKeeper) + wasmQueryPlugin := NewQueryPlugin(ek, ck, lcKeeper, zcKeeper) queryPluginOpt := wasmkeeper.WithQueryPlugins(&wasmkeeper.QueryPlugins{ Custom: CustomQuerier(wasmQueryPlugin), diff --git a/x/btccheckpoint/README.md b/x/btccheckpoint/README.md new file mode 100644 index 000000000..8e97e4606 --- /dev/null +++ b/x/btccheckpoint/README.md @@ -0,0 +1,224 @@ +# BTCCheckpoint + +The BTC Checkpoint module is responsible for receiving and managing the checkpoints of Babylon's state on the Bitcoin blockchain. This includes: +- handling requests for submitting raw checkpoints +- processing Bitcoin SPV proofs for submitted checkpoints +- managing the lifecycle of checkpoints (SEALED, SUBMITTED, CONFIRMED, FINALIZED) +- handling the verification and finalization of checkpoints +- distributing rewards for successful checkpoint submissions, and +- proactively updating the status of checkpoints based on Bitcoin blockchain confirmations + +## Table of contents + +- [Table of contents](#table-of-contents) +- [Concepts](#concepts) +- [States](#states) + - [Parameters](#parameters) + - [Epoch data](#epoch-data) + - [Latest Finalized Epoch](#latest-finalized-epoch) + - [Submission data](#submission-data) + - [Transient States](#transient-states) +- [Messages](#messages) + - [MsgInsertBTCSpvProof](#msginsertbtcspvproof) + - [MsgUpdateParams](#msgupdateparams) +- [EndBlocker](#endblocker) +- [Queries](#queries) + +## Concepts +Babylon's BTC Checkpoint module allows Babylon chain to periodically checkpoint its state onto the Bitcoin blockchain whilst simultaneously verifying the checkpoints. The process involves two main components: + +Checkpoint Submission: +1. When a new checkpoint for a specific epoch is available, the [vigilante](https://github.com/babylonlabs-io/vigilante) collects the necessary proof from the Bitcoin blockchain and submits raw transactions containing the checkpoint to the Babylon chain. +2. This proof is called an `SPVProof` (Simplified Payment Verification Proof), consisting of the Bitcoin transaction, Index of the transaction, the Merkle path and the Bitcoin header that confirms the transaction. +3. The [vigilante reporter](https://github.com/babylonlabs-io/vigilante/blob/47956edbb72112162e4cecca5b9d1e0ad840dd47/reporter/utils.go#L191) submits this proof to the Babylon chain using the `InsertBTCSpvProof` function. The proof is validated and stored in state. This includes parsing the submission, checking for duplicates, and verifying the checkpoint with the [checkpointing module](https://github.com/babylonlabs-io/babylon/blob/main/x/checkpointing/README.md). + +Checkpoint Verification: +1. The Babylon chain maintains a Bitcoin light client through the [BTC Light Client module](https://github.com/babylonchain/babylon/blob/dev/x/btclightclient/README.md). This module is responsible for tracking Bitcoin block headers, allowing Babylon to verify the depth and validity of Bitcoin transactions without running a full Bitcoin node. +2. When new Bitcoin blocks are produced, the headers are relayed to and processed by the Babylon chain's light client. +3. As the light client's tip changes, it triggers the `OnTipChange` callback. +4. This callback initiates the `checkCheckpoints` process, which verifies the status of all submitted checkpoints based on their confirmation depth in the Bitcoin blockchain. This process includes: + + * Checking if the checkpoint is still on the canonical chain + * Verifying if the deepest (best) submission of an older epoch happened + before the given submission + * Determining how deep the submission is in the blockchain + * Marking each submission for deletion if it is: + - Not known to the BTC light client, or + - On a fork of the BTC light client's chain + + For more details on submissions, see [Submissions](#submission-data). +5. Non-finalized epochs are retrieved from state. For each of these non-finalized epochs, the status is checked of the corresponding checkpoint. The depth of the checkpoint in the Bitcoin blockchain is verified and based on the depth and the module's parameters, the checkpoint's status may be updated. If the status changed, it's updated in the state and the corresponding status is set in the checkpointing module. Following an epoch being finalized, all submissions except the best one are deleted. + +## States + +The BTC Checkpoint module uses a combination of prefixed namespaces and individual keys within its KV store to organize different types of data. This approach allows for efficient storage and retrieval of various data elements related to checkpoints, epochs, and submissions. + +**Prefixes** + +- `SubmisionKeyPrefix` is used to prefix keys for storing submission data. + +- `EpochDataPrefix` is used to prefix keys for storing epoch-related data. + +**Keys** + +- `LastFinalizedEpochKey` stores the number of the last finalized epoch + +- `BtcLightClientUpdatedKey` indicates whether the BTC light client was updated during the current block execution. + +- `ParamsKey` stores modules parameters. + +### Parameters +The [parameter management](https://github.com/babylonlabs-io/babylon/blob/main/x/btccheckpoint/keeper/params.go) maintains the BTC Checkpoint module's parameters. The BTC Checkpoint module's parameters are represented as a `Params` [object](https://github.com/babylonlabs-io/babylon/blob/main/proto/babylon/btccheckpoint/v1/params.proto) defined as follows: + +```protobuf +// Params defines the parameters for the module. +message Params { + option (gogoproto.equal) = true; + + // btc_confirmation_depth is the confirmation depth in BTC. + // A block is considered irreversible only when it is at least k-deep in BTC + // (k in research paper) + uint64 btc_confirmation_depth = 1 + [ (gogoproto.moretags) = "yaml:\"btc_confirmation_depth\"" ]; + + // checkpoint_finalization_timeout is the maximum time window (measured in BTC + // blocks) between a checkpoint + // - being submitted to BTC, and + // - being reported back to BBN + // If a checkpoint has not been reported back within w BTC blocks, then BBN + // has dishonest majority and is stalling checkpoints (w in research paper) + uint64 checkpoint_finalization_timeout = 2 + [ (gogoproto.moretags) = "yaml:\"checkpoint_finalization_timeout\"" ]; + + // 4byte tag in hex format, required to be present in the OP_RETURN transaction + // related to babylon + string checkpoint_tag = 3 + [ (gogoproto.moretags) = "yaml:\"checkpoint_tag\"" ]; +} +``` + +### Epoch Data + +Epoch data is managed by [submissions management](https://github.com/babylonlabs-io/babylon/blob/main/x/btccheckpoint/keeper/submissions.go) and is used to store and retrieve epoch-related data. The epoch data is indexed by epoch number and is represented as an `EpochData` object: + +```protobuf +message EpochData { + // keys is the list of all received checkpoints during this epoch, sorted by + // order of submission. + repeated SubmissionKey keys = 1; + + // status is the current btc status of the epoch + BtcStatus status = 2; +} +``` + +### Latest Finalized Epoch + +The Last Finalized Epoch number is stored in the state as a big-endian encoded uint64 value. It's accessed and modified using specific getter and setter functions in the keeper. + +### Submission Data + +The [submissions management](https://github.com/babylonlabs-io/babylon/blob/main/x/btccheckpoint/keeper/submissions.go) is responsible for managing and interacting with checkpoint submissions in the BTC checkpoint module The `SubmissionData` is defined as an object below. + +```protobuf +message SubmissionData { + // address of the submitter and reporter + CheckpointAddresses vigilante_addresses = 1; + // txs_info is the two `TransactionInfo`s corresponding to the submission + // It is used for + // - recovering address of sender of btc transaction to payup the reward. + // - allowing the ZoneConcierge module to prove the checkpoint is submitted to + // BTC + repeated TransactionInfo txs_info = 2; + uint64 epoch = 3; +} +``` + +### Transient States + +### BTC Light Client Update + +The BTC Light Client Update is maintained in the transient store during block execution. It is accessed using the `BtcLightClientUpdatedKey` and indicates whether the BTC light client was updated during the current block execution. + +```go +func GetBtcLightClientUpdatedKey() []byte { + return BtcLightClientUpdatedKey +} +``` + +## Messages + +The BTC Checkpoint module primarily handles messages from the vigilante reporter. The message formats are defined in [proto/babylon/btccheckpoint/v1/tx.proto](proto/babylon/btccheckpoint/v1/tx.proto.). The message handlers are defined in [x/btccheckpoint/keeper/msg_server.go](x/btccheckpoint/keeper/msg_server.go). For more information on the SDK messages, refer to the [Cosmos SDK documentation on messages and queries](https://docs.cosmos.network/main/build/building-modules/messages-and-queries) + +### MsgInsertBTCSpvProof + +`MsgInsertBTCSpvProof` is used by vigilante reporter to insert a new checkpoint into the store, which can be seen [here](https://github.com/babylonlabs-io/vigilante/blob/24da0381465249aa7b55be682a66e32cdaddc81b/types/btccheckpoint.go#L11). + +```protobuf +message MsgInsertBTCSpvProof { +  option (cosmos.msg.v1.signer) = "submitter"; +  string submitter = 1; +  repeated babylon.btccheckpoint.v1.BTCSpvProof proofs = 2; +} +``` + +Upon receiving a `MsgInsertBTCSpvProof`, a Babylon node will execute as follows: + +1. Parse and validate the raw checkpoint data from the proof. +2. Create a new `RawCheckpointSubmission` object from the parsed data. +3. Verify if the submission is for the expected checkpoint by calling the checkpointing keeper. +4. Check if the checkpoint is valid for the current epoch. +5. Verify the ancestors of the checkpoint to ensure continuity. +6. If all verifications pass, the new checkpoint submission is stored and the checkpoint status is updated. + +## MsgUpdateParams + +This message is used to update the `btccheckpoint` module parameters. This should only be executable through governance proposals. + +```protobuf +message MsgUpdateParams { + option (cosmos.msg.v1.signer) = "authority"; + + // authority is the address of the governance account. + // just FYI: cosmos.AddressString marks that this field should use type alias + // for AddressString instead of string, but the functionality is not yet implemented + // in cosmos-proto + string authority = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"]; + + // params defines the btccheckpoint parameters to update. + // + // NOTE: All parameters must be supplied. + Params params = 2 [(gogoproto.nullable) = false]; +} +``` + +## EndBlocker + +Upon EndBlock, the BTC Checkpoint module executes the following: +- Check if the BTC light client head has been updated during the block execution using the `BtcLightClientUpdated` method. +- If the head has been updated, non-finalized epochs are checked to determine if their checkpoints have become confirmed, finalized, or abandoned. +The logic for the `EndBlocker` is defined in at [x/btccheckpoint/abci.go](https://github.com/babylonlabs-io/babylon/blob/main/x/btccheckpoint/abci.go). + +## Queries + +The BTC Checkpoint module provides a set of queries related to the status of checkpoints and other checkpoint-related data. These queries can be accessed via gRPC and REST endpoints. + +### Available Queries + +**Parameters**\ +Endpoint: `/babylon/btccheckpoint/v1/params`\ +Description: Queries the current parameters of the BTC Checkpoint module. + +**BTC Checkpoint Info**\ +Endpoint: `/babylon/btccheckpoint/v1/{epoch_num}`\ +Description: Retrieves the best checkpoint information for a given epoch. + +**BTC Checkpoints Info**\ +Endpoint: `/babylon/btccheckpoint/v1/`\ +Description: Retrieves checkpoint information for multiple epochs with pagination support. + +**Epoch Submissions**\ +Endpoint: `/babylon/btccheckpoint/v1/{epoch_num}/submissions`\ +Description: Retrieves all submissions for a given epoch. + +Additional Information: For further details on how to use these queries and additional documentation, please refer to docs.babylonchain.io. \ No newline at end of file diff --git a/x/btccheckpoint/abci.go b/x/btccheckpoint/abci.go index cb5579985..be0a78afd 100644 --- a/x/btccheckpoint/abci.go +++ b/x/btccheckpoint/abci.go @@ -7,7 +7,7 @@ import ( // EndBlocker checks if during block execution btc light client head had been // updated. If the head had been updated, status of all available checkpoints -// is checked to determine if any of them became confirmed/finalized/abandonded. +// is checked to determine if any of them became confirmed/finalized/abandoned. func EndBlocker(ctx context.Context, k keeper.Keeper) { if k.BtcLightClientUpdated(ctx) { k.OnTipChange(ctx) diff --git a/x/btccheckpoint/genesis_test.go b/x/btccheckpoint/genesis_test.go index 62b36760c..3032f15dd 100644 --- a/x/btccheckpoint/genesis_test.go +++ b/x/btccheckpoint/genesis_test.go @@ -35,6 +35,6 @@ func TestInitGenesis(t *testing.T) { } btccheckpoint.InitGenesis(ctx, app.BtcCheckpointKeeper, genesisState) - require.Equal(t, app.BtcCheckpointKeeper.GetParams(ctx).BtcConfirmationDepth, uint64(888)) - require.Equal(t, app.BtcCheckpointKeeper.GetParams(ctx).CheckpointFinalizationTimeout, uint64(999)) + require.Equal(t, app.BtcCheckpointKeeper.GetParams(ctx).BtcConfirmationDepth, uint32(888)) + require.Equal(t, app.BtcCheckpointKeeper.GetParams(ctx).CheckpointFinalizationTimeout, uint32(999)) } diff --git a/x/btccheckpoint/keeper/grpc_query_params_test.go b/x/btccheckpoint/keeper/grpc_query_params_test.go index 9624ef04a..3f45131cd 100644 --- a/x/btccheckpoint/keeper/grpc_query_params_test.go +++ b/x/btccheckpoint/keeper/grpc_query_params_test.go @@ -14,11 +14,11 @@ import ( // 2. When EpochInterval is 0, ensure `Validate` returns an error // 3. Randomly set the param via query and check if the param has been updated func FuzzParamsQuery(f *testing.F) { - f.Add(uint64(11111), uint64(3232), int64(23)) - f.Add(uint64(22222), uint64(444), int64(330)) - f.Add(uint64(22222), uint64(12333), int64(101)) + f.Add(uint32(11111), uint32(3232), int64(23)) + f.Add(uint32(22222), uint32(444), int64(330)) + f.Add(uint32(22222), uint32(12333), int64(101)) - f.Fuzz(func(t *testing.T, btcConfirmationDepth uint64, checkpointFinalizationTimeout uint64, seed int64) { + f.Fuzz(func(t *testing.T, btcConfirmationDepth uint32, checkpointFinalizationTimeout uint32, seed int64) { r := rand.New(rand.NewSource(seed)) // params generated by fuzzer @@ -31,7 +31,7 @@ func FuzzParamsQuery(f *testing.F) { if btcConfirmationDepth == 0 { // validation should not pass with zero EpochInterval require.Error(t, params.Validate()) - params.BtcConfirmationDepth = uint64(r.Int()) + params.BtcConfirmationDepth = uint32(r.Int31()) } // test the case of CheckpointFinalizationTimeout == 0 @@ -39,7 +39,7 @@ func FuzzParamsQuery(f *testing.F) { if checkpointFinalizationTimeout == 0 { // validation should not pass with zero EpochInterval require.Error(t, params.Validate()) - params.CheckpointFinalizationTimeout = uint64(r.Int()) + params.CheckpointFinalizationTimeout = uint32(r.Int31()) } if btcConfirmationDepth >= checkpointFinalizationTimeout { diff --git a/x/btccheckpoint/keeper/grpc_query_test.go b/x/btccheckpoint/keeper/grpc_query_test.go index f1b32d76d..7767124cf 100644 --- a/x/btccheckpoint/keeper/grpc_query_test.go +++ b/x/btccheckpoint/keeper/grpc_query_test.go @@ -28,8 +28,8 @@ func TestBtcCheckpointInfo(t *testing.T) { proofs := dg.BlockCreationResultToProofs(blockResults) msg := dg.GenerateMessageWithRandomSubmitter(blockResults) - tk.BTCLightClient.SetDepth(blck1.HeaderBytes.Hash(), uint64(1)) - tk.BTCLightClient.SetDepth(blck2.HeaderBytes.Hash(), uint64(1)) + tk.BTCLightClient.SetDepth(blck1.HeaderBytes.Hash(), uint32(1)) + tk.BTCLightClient.SetDepth(blck2.HeaderBytes.Hash(), uint32(1)) _, err := tk.insertProofMsg(msg) require.NoErrorf(t, err, "Unexpected message processing error: %v", err) diff --git a/x/btccheckpoint/keeper/incentive.go b/x/btccheckpoint/keeper/incentive.go deleted file mode 100644 index 259af1ae4..000000000 --- a/x/btccheckpoint/keeper/incentive.go +++ /dev/null @@ -1,44 +0,0 @@ -package keeper - -import ( - "context" - "github.com/babylonlabs-io/babylon/x/btccheckpoint/types" -) - -// rewardBTCTimestamping finds the (submitter, reporter) pairs of all submissions at the -// given finalised epoch according to the given epoch data, then distribute rewards to them -// by invoking the incentive module -func (k Keeper) rewardBTCTimestamping(ctx context.Context, epoch uint64, ed *types.EpochData, bestIdx int) { - var ( - bestSubmissionAddrs *types.CheckpointAddressPair - otherSubmissionAddrs []*types.CheckpointAddressPair - ) - - // iterate over all submission keys to find all submission addresses, including the best one - for i, sk := range ed.Keys { - // retrieve submission data, including vigilante addresses - submissionData := k.GetSubmissionData(ctx, *sk) - if submissionData == nil { - // ignore nil submission data for whatever reason - continue - } - - // get vigilante addresses of this submission - submissionAddrs, err := types.NewCheckpointAddressPair(submissionData.VigilanteAddresses) - if err != nil { - // failing to unmarshal checkpoint address pair in KVStore is a programming error - panic(err) - } - - // assign to best submission or append to other submission according to best submission index - if i == bestIdx { - bestSubmissionAddrs = submissionAddrs - } else { - otherSubmissionAddrs = append(otherSubmissionAddrs, submissionAddrs) - } - } - - // construct reward distribution information and invoke incentive module to distribute rewards - rewardDistInfo := types.NewRewardDistInfo(bestSubmissionAddrs, otherSubmissionAddrs...) - k.incentiveKeeper.RewardBTCTimestamping(ctx, epoch, rewardDistInfo) -} diff --git a/x/btccheckpoint/keeper/keeper.go b/x/btccheckpoint/keeper/keeper.go index 9d345cebd..265abf17d 100644 --- a/x/btccheckpoint/keeper/keeper.go +++ b/x/btccheckpoint/keeper/keeper.go @@ -2,13 +2,14 @@ package keeper import ( "context" - corestoretypes "cosmossdk.io/core/store" - storetypes "cosmossdk.io/store/types" "encoding/hex" "fmt" - "github.com/cosmos/cosmos-sdk/runtime" "math/big" + corestoretypes "cosmossdk.io/core/store" + storetypes "cosmossdk.io/store/types" + "github.com/cosmos/cosmos-sdk/runtime" + "cosmossdk.io/log" "cosmossdk.io/store/prefix" txformat "github.com/babylonlabs-io/babylon/btctxformatter" @@ -102,24 +103,24 @@ func (k Keeper) Logger(ctx sdk.Context) log.Logger { return ctx.Logger().With("module", fmt.Sprintf("x/%s", types.ModuleName)) } -func (k Keeper) GetBlockHeight(ctx context.Context, b *bbn.BTCHeaderHashBytes) (uint64, error) { +func (k Keeper) GetBlockHeight(ctx context.Context, b *bbn.BTCHeaderHashBytes) (uint32, error) { return k.btcLightClientKeeper.BlockHeight(ctx, b) } -func (k Keeper) headerDepth(ctx context.Context, headerHash *bbn.BTCHeaderHashBytes) (uint64, error) { +func (k Keeper) headerDepth(ctx context.Context, headerHash *bbn.BTCHeaderHashBytes) (uint32, error) { blockDepth, err := k.btcLightClientKeeper.MainChainDepth(ctx, headerHash) if err != nil { // one of blocks is not known to light client return 0, submissionUnknownErr } - return uint64(blockDepth), nil + return blockDepth, nil } // checkAncestors checks if there is at least one ancestor in previous epoch submissions // previous epoch submission is considered ancestor when: // - it is on main chain -// - its lowest depth is larger than highest depth of new submission +// - its lowest depth is larger than the highest depth of new submission func (k Keeper) checkAncestors( ctx context.Context, submisionEpoch uint64, @@ -155,7 +156,7 @@ func (k Keeper) checkAncestors( if err != nil { // Previous epoch submission block either landed on fork or was pruned - // Submission will be pruned, so it should not be treated vaiable ancestor + // Submission will be pruned, so it should not be treated variable ancestor continue } @@ -182,7 +183,7 @@ func (k Keeper) setBtcLightClientUpdated(ctx context.Context) { // BtcLightClientUpdated checks if btc light client was updated during block execution func (k Keeper) BtcLightClientUpdated(ctx context.Context) bool { - // transient store is cleared after each block execution, therfore if + // transient store is cleared after each block execution, therefore if // BtcLightClientKey is set, it means setBtcLightClientUpdated was called during // current block execution store := sdk.UnwrapSDKContext(ctx).TransientStore(k.tsKey) @@ -230,7 +231,7 @@ func (k Keeper) getEpochChanges( if err != nil { // submission no longer on main chain, mark it as to delete, and do not count - // it as vaiable submission + // it as variable submission submissionsToDelete = append(submissionsToDelete, sk) continue } @@ -405,8 +406,6 @@ func (k Keeper) checkCheckpoints(ctx context.Context) { } if currentEpoch.Status == types.Finalized { - // trigger incentive module to distribute rewards to submitters/reporters - k.rewardBTCTimestamping(ctx, epoch, ¤tEpoch, epochChanges.BestSubmissionIdx) // delete all submissions except best one for i, sk := range currentEpoch.Keys { if i != epochChanges.BestSubmissionIdx { diff --git a/x/btccheckpoint/keeper/keeper_test.go b/x/btccheckpoint/keeper/keeper_test.go index 5ed112659..f1a0ded46 100644 --- a/x/btccheckpoint/keeper/keeper_test.go +++ b/x/btccheckpoint/keeper/keeper_test.go @@ -13,7 +13,7 @@ import ( func TestKeeper_GetSubmissionBtcInfo(t *testing.T) { type TxKeyDesc struct { TxIdx uint32 - Depth uint64 + Depth uint32 } type args struct { @@ -24,9 +24,9 @@ func TestKeeper_GetSubmissionBtcInfo(t *testing.T) { tests := []struct { name string args args - expectedYoungestBlockDepth uint64 + expectedYoungestBlockDepth uint32 expectedTxIndex uint32 - expectedOldestBlockDepth uint64 + expectedOldestBlockDepth uint32 }{ {"First header older. TxIndex larger in older header.", args{TxKeyDesc{TxIdx: 5, Depth: 10}, TxKeyDesc{TxIdx: 1, Depth: 0}}, 0, 1, 10}, {"First header older. TxIndex larger in younger header.", args{TxKeyDesc{TxIdx: 1, Depth: 10}, TxKeyDesc{TxIdx: 5, Depth: 0}}, 0, 5, 10}, @@ -90,23 +90,23 @@ func FuzzGetSubmissionBtcInfo(f *testing.F) { {Index: txidx2, Hash: hash2}, }} - k.BTCLightClient.SetDepth(hash1, uint64(depth1)) - k.BTCLightClient.SetDepth(hash2, uint64(depth2)) + k.BTCLightClient.SetDepth(hash1, depth1) + k.BTCLightClient.SetDepth(hash2, depth2) info, err := k.BTCCheckpoint.GetSubmissionBtcInfo(k.SdkCtx, sk) require.NoError(t, err) - var expectedOldestDepth uint64 - var expectedYoungestDepth uint64 + var expectedOldestDepth uint32 + var expectedYoungestDepth uint32 var expectedTxIdx uint32 if depth1 > depth2 { - expectedOldestDepth = uint64(depth1) - expectedYoungestDepth = uint64(depth2) + expectedOldestDepth = depth1 + expectedYoungestDepth = depth2 expectedTxIdx = txidx2 } else if depth1 < depth2 { - expectedOldestDepth = uint64(depth2) - expectedYoungestDepth = uint64(depth1) + expectedOldestDepth = depth2 + expectedYoungestDepth = depth1 expectedTxIdx = txidx1 } else { if txidx1 > txidx2 { @@ -114,8 +114,8 @@ func FuzzGetSubmissionBtcInfo(f *testing.F) { } else { expectedTxIdx = txidx1 } - expectedOldestDepth = uint64(depth1) - expectedYoungestDepth = uint64(depth1) + expectedOldestDepth = depth1 + expectedYoungestDepth = depth1 } require.Equal(t, info.YoungestBlockDepth, expectedYoungestDepth) diff --git a/x/btccheckpoint/keeper/msg_server.go b/x/btccheckpoint/keeper/msg_server.go index d2cc65310..22c5421c9 100644 --- a/x/btccheckpoint/keeper/msg_server.go +++ b/x/btccheckpoint/keeper/msg_server.go @@ -22,7 +22,7 @@ func NewMsgServerImpl(keeper Keeper) types.MsgServer { } // TODO at some point add proper logging of error -// TODO emit some events for external consumers. Those should be probably emited +// TODO emit some events for external consumers. Those should be probably emitted // at EndBlockerCallback func (ms msgServer) InsertBTCSpvProof(ctx context.Context, req *types.MsgInsertBTCSpvProof) (*types.MsgInsertBTCSpvProofResponse, error) { @@ -92,6 +92,11 @@ func (ms msgServer) InsertBTCSpvProof(ctx context.Context, req *types.MsgInsertB return nil, err } + // At this point, the BTC checkpoint is a valid submission and is + // not duplicated (first time seeing the pair of BTC txs) + // Thus, we can safely consider this message as refundable + ms.k.incentiveKeeper.IndexRefundableMsg(sdkCtx, req) + return &types.MsgInsertBTCSpvProofResponse{}, nil } diff --git a/x/btccheckpoint/keeper/msg_server_test.go b/x/btccheckpoint/keeper/msg_server_test.go index c74e939c7..8b234d59d 100644 --- a/x/btccheckpoint/keeper/msg_server_test.go +++ b/x/btccheckpoint/keeper/msg_server_test.go @@ -92,8 +92,8 @@ func TestRejectDuplicatedSubmission(t *testing.T) { msg := dg.GenerateMessageWithRandomSubmitter([]*dg.BlockCreationResult{blck1, blck2}) // Now we will return depth enough for moving submission to be submitted - tk.BTCLightClient.SetDepth(blck1.HeaderBytes.Hash(), uint64(1)) - tk.BTCLightClient.SetDepth(blck2.HeaderBytes.Hash(), uint64(1)) + tk.BTCLightClient.SetDepth(blck1.HeaderBytes.Hash(), uint32(1)) + tk.BTCLightClient.SetDepth(blck2.HeaderBytes.Hash(), uint32(1)) _, err := tk.insertProofMsg(msg) @@ -130,7 +130,7 @@ func TestRejectUnknownToBtcLightClient(t *testing.T) { require.ErrorContainsf(t, err, btcctypes.ErrInvalidHeader.Error(), "Processing should return invalid header error") // even if one header is known, submission should still be considered invalid - tk.BTCLightClient.SetDepth(blck1.HeaderBytes.Hash(), uint64(1)) + tk.BTCLightClient.SetDepth(blck1.HeaderBytes.Hash(), uint32(1)) _, err = tk.insertProofMsg(msg) @@ -150,8 +150,8 @@ func TestSubmitValidNewCheckpoint(t *testing.T) { msg := dg.GenerateMessageWithRandomSubmitter([]*dg.BlockCreationResult{blck1, blck2}) // Now we will return depth enough for moving submission to be submitted - tk.BTCLightClient.SetDepth(blck1.HeaderBytes.Hash(), uint64(1)) - tk.BTCLightClient.SetDepth(blck2.HeaderBytes.Hash(), uint64(1)) + tk.BTCLightClient.SetDepth(blck1.HeaderBytes.Hash(), uint32(1)) + tk.BTCLightClient.SetDepth(blck2.HeaderBytes.Hash(), uint32(1)) _, err := tk.insertProofMsg(msg) @@ -196,7 +196,7 @@ func TestSubmitValidNewCheckpoint(t *testing.T) { ed1 := tk.GetEpochData(epoch) - // TODO Add custom equal fo submission key and transaction key to check + // TODO Add custom equal for submission key and transaction key to check // it is expected key if len(ed1.Keys) == 0 { t.Errorf("Unexpected missing unconfirmed submissions") @@ -216,8 +216,8 @@ func TestRejectSubmissionWithoutSubmissionsForPreviousEpoch(t *testing.T) { msg := dg.GenerateMessageWithRandomSubmitter([]*dg.BlockCreationResult{blck1, blck2}) // Now we will return depth enough for moving submission to be submitted - tk.BTCLightClient.SetDepth(blck1.HeaderBytes.Hash(), uint64(0)) - tk.BTCLightClient.SetDepth(blck2.HeaderBytes.Hash(), uint64(1)) + tk.BTCLightClient.SetDepth(blck1.HeaderBytes.Hash(), uint32(0)) + tk.BTCLightClient.SetDepth(blck2.HeaderBytes.Hash(), uint32(1)) _, err := tk.insertProofMsg(msg) @@ -241,8 +241,8 @@ func TestRejectSubmissionWithoutAncestorsOnMainchainInPreviousEpoch(t *testing.T msg := dg.GenerateMessageWithRandomSubmitter([]*dg.BlockCreationResult{epoch1Block1, epoch1Block2}) // Now we will return depth enough for moving submission to be submitted - tk.BTCLightClient.SetDepth(epoch1Block1.HeaderBytes.Hash(), uint64(5)) - tk.BTCLightClient.SetDepth(epoch1Block2.HeaderBytes.Hash(), uint64(4)) + tk.BTCLightClient.SetDepth(epoch1Block1.HeaderBytes.Hash(), uint32(5)) + tk.BTCLightClient.SetDepth(epoch1Block2.HeaderBytes.Hash(), uint32(4)) _, err := tk.insertProofMsg(msg) @@ -255,8 +255,8 @@ func TestRejectSubmissionWithoutAncestorsOnMainchainInPreviousEpoch(t *testing.T msg2 := dg.GenerateMessageWithRandomSubmitter([]*dg.BlockCreationResult{epoch2Block1, epoch2Block2}) // Both headers are deeper than epoch 1 submission, fail - tk.BTCLightClient.SetDepth(epoch2Block1.HeaderBytes.Hash(), uint64(7)) - tk.BTCLightClient.SetDepth(epoch2Block2.HeaderBytes.Hash(), uint64(6)) + tk.BTCLightClient.SetDepth(epoch2Block1.HeaderBytes.Hash(), uint32(7)) + tk.BTCLightClient.SetDepth(epoch2Block2.HeaderBytes.Hash(), uint32(6)) _, err = tk.insertProofMsg(msg2) @@ -268,8 +268,8 @@ func TestRejectSubmissionWithoutAncestorsOnMainchainInPreviousEpoch(t *testing.T ) // one header deeper than headers of previous epoch, one fresher, fail - tk.BTCLightClient.SetDepth(epoch2Block1.HeaderBytes.Hash(), uint64(7)) - tk.BTCLightClient.SetDepth(epoch2Block2.HeaderBytes.Hash(), uint64(3)) + tk.BTCLightClient.SetDepth(epoch2Block1.HeaderBytes.Hash(), uint32(7)) + tk.BTCLightClient.SetDepth(epoch2Block2.HeaderBytes.Hash(), uint32(3)) _, err = tk.insertProofMsg(msg2) @@ -281,8 +281,8 @@ func TestRejectSubmissionWithoutAncestorsOnMainchainInPreviousEpoch(t *testing.T ) // one header on the same depth as previous epoch, one fresher, fail - tk.BTCLightClient.SetDepth(epoch2Block1.HeaderBytes.Hash(), uint64(4)) - tk.BTCLightClient.SetDepth(epoch2Block2.HeaderBytes.Hash(), uint64(3)) + tk.BTCLightClient.SetDepth(epoch2Block1.HeaderBytes.Hash(), uint32(4)) + tk.BTCLightClient.SetDepth(epoch2Block2.HeaderBytes.Hash(), uint32(3)) _, err = tk.insertProofMsg(msg2) @@ -294,8 +294,8 @@ func TestRejectSubmissionWithoutAncestorsOnMainchainInPreviousEpoch(t *testing.T ) // Both Headers fresher that previous epoch, succeed - tk.BTCLightClient.SetDepth(epoch2Block1.HeaderBytes.Hash(), uint64(3)) - tk.BTCLightClient.SetDepth(epoch2Block2.HeaderBytes.Hash(), uint64(2)) + tk.BTCLightClient.SetDepth(epoch2Block1.HeaderBytes.Hash(), uint32(3)) + tk.BTCLightClient.SetDepth(epoch2Block2.HeaderBytes.Hash(), uint32(2)) _, err = tk.insertProofMsg(msg2) @@ -308,38 +308,38 @@ func TestClearChildEpochsWhenNoParenNotOnMainChain(t *testing.T) { tk := InitTestKeepers(t) msg1 := dg.GenerateMessageWithRandomSubmitterForEpoch(r, 1) - tk.BTCLightClient.SetDepth(b1Hash(msg1), uint64(5)) - tk.BTCLightClient.SetDepth(b2Hash(msg1), uint64(4)) + tk.BTCLightClient.SetDepth(b1Hash(msg1), uint32(5)) + tk.BTCLightClient.SetDepth(b2Hash(msg1), uint32(4)) _, err := tk.insertProofMsg(msg1) require.NoError(t, err, "failed to insert submission for epoch 1") msg1a := dg.GenerateMessageWithRandomSubmitterForEpoch(r, 1) - tk.BTCLightClient.SetDepth(b1Hash(msg1a), uint64(4)) - tk.BTCLightClient.SetDepth(b2Hash(msg1a), uint64(5)) + tk.BTCLightClient.SetDepth(b1Hash(msg1a), uint32(4)) + tk.BTCLightClient.SetDepth(b2Hash(msg1a), uint32(5)) _, err = tk.insertProofMsg(msg1a) require.NoError(t, err, "failed to insert submission for epoch 1") msg2 := dg.GenerateMessageWithRandomSubmitterForEpoch(r, 2) - tk.BTCLightClient.SetDepth(b1Hash(msg2), uint64(3)) - tk.BTCLightClient.SetDepth(b2Hash(msg2), uint64(2)) + tk.BTCLightClient.SetDepth(b1Hash(msg2), uint32(3)) + tk.BTCLightClient.SetDepth(b2Hash(msg2), uint32(2)) _, err = tk.insertProofMsg(msg2) require.NoError(t, err, "failed to insert submission for epoch 2") msg2a := dg.GenerateMessageWithRandomSubmitterForEpoch(r, 2) - tk.BTCLightClient.SetDepth(b1Hash(msg2a), uint64(3)) - tk.BTCLightClient.SetDepth(b2Hash(msg2a), uint64(2)) + tk.BTCLightClient.SetDepth(b1Hash(msg2a), uint32(3)) + tk.BTCLightClient.SetDepth(b2Hash(msg2a), uint32(2)) _, err = tk.insertProofMsg(msg2a) require.NoError(t, err, "failed to insert submission for epoch 2") msg3 := dg.GenerateMessageWithRandomSubmitterForEpoch(r, 3) - tk.BTCLightClient.SetDepth(b1Hash(msg3), uint64(1)) - tk.BTCLightClient.SetDepth(b2Hash(msg3), uint64(0)) + tk.BTCLightClient.SetDepth(b1Hash(msg3), uint32(1)) + tk.BTCLightClient.SetDepth(b2Hash(msg3), uint32(0)) _, err = tk.insertProofMsg(msg3) require.NoError(t, err, "failed to insert submission for epoch 3") msg3a := dg.GenerateMessageWithRandomSubmitterForEpoch(r, 3) - tk.BTCLightClient.SetDepth(b1Hash(msg3a), uint64(1)) - tk.BTCLightClient.SetDepth(b2Hash(msg3a), uint64(0)) + tk.BTCLightClient.SetDepth(b1Hash(msg3a), uint32(1)) + tk.BTCLightClient.SetDepth(b2Hash(msg3a), uint32(0)) _, err = tk.insertProofMsg(msg3a) require.NoError(t, err, "failed to insert submission for epoch 3") @@ -352,7 +352,7 @@ func TestClearChildEpochsWhenNoParenNotOnMainChain(t *testing.T) { } // Due to reorg one submission from epoch 1 lands on fork, which means it is no - // longer vaiable. It should be pruned. Other subbmissions should be left + // longer variable. It should be pruned. Other subbmissions should be left // intact tk.BTCLightClient.DeleteHeader(b2Hash(msg1)) @@ -394,20 +394,20 @@ func TestLeaveOnlyBestSubmissionWhenEpochFinalized(t *testing.T) { wDeep := defaultParams.CheckpointFinalizationTimeout msg1 := dg.GenerateMessageWithRandomSubmitterForEpoch(r, 1) - tk.BTCLightClient.SetDepth(b1Hash(msg1), uint64(1)) - tk.BTCLightClient.SetDepth(b2Hash(msg1), uint64(0)) + tk.BTCLightClient.SetDepth(b1Hash(msg1), uint32(1)) + tk.BTCLightClient.SetDepth(b2Hash(msg1), uint32(0)) _, err := tk.insertProofMsg(msg1) require.NoError(t, err, "failed to insert submission") msg2 := dg.GenerateMessageWithRandomSubmitterForEpoch(r, 1) - tk.BTCLightClient.SetDepth(b1Hash(msg2), uint64(1)) - tk.BTCLightClient.SetDepth(b2Hash(msg2), uint64(0)) + tk.BTCLightClient.SetDepth(b1Hash(msg2), uint32(1)) + tk.BTCLightClient.SetDepth(b2Hash(msg2), uint32(0)) _, err = tk.insertProofMsg(msg2) require.NoError(t, err, "failed to insert submission") msg3 := dg.GenerateMessageWithRandomSubmitterForEpoch(r, 1) - tk.BTCLightClient.SetDepth(b1Hash(msg3), uint64(1)) - tk.BTCLightClient.SetDepth(b2Hash(msg3), uint64(0)) + tk.BTCLightClient.SetDepth(b1Hash(msg3), uint32(1)) + tk.BTCLightClient.SetDepth(b2Hash(msg3), uint32(0)) _, err = tk.insertProofMsg(msg3) require.NoError(t, err, "failed to insert submission") @@ -443,14 +443,14 @@ func TestTxIdxShouldBreakTies(t *testing.T) { wDeep := defaultParams.CheckpointFinalizationTimeout msg1 := dg.GenerateMessageWithRandomSubmitterForEpoch(r, 1) - tk.BTCLightClient.SetDepth(b1Hash(msg1), uint64(1)) - tk.BTCLightClient.SetDepth(b2Hash(msg1), uint64(0)) + tk.BTCLightClient.SetDepth(b1Hash(msg1), uint32(1)) + tk.BTCLightClient.SetDepth(b2Hash(msg1), uint32(0)) _, err := tk.insertProofMsg(msg1) require.NoError(t, err, "failed to insert submission") msg2 := dg.GenerateMessageWithRandomSubmitterForEpoch(r, 1) - tk.BTCLightClient.SetDepth(b1Hash(msg2), uint64(1)) - tk.BTCLightClient.SetDepth(b2Hash(msg2), uint64(0)) + tk.BTCLightClient.SetDepth(b1Hash(msg2), uint32(1)) + tk.BTCLightClient.SetDepth(b2Hash(msg2), uint32(0)) _, err = tk.insertProofMsg(msg2) require.NoError(t, err, "failed to insert submission") @@ -475,7 +475,7 @@ func TestTxIdxShouldBreakTies(t *testing.T) { finalSubKey := ed.Keys[0] // There is small chance that we can draw the same transactions indexes, which - // cannot happend in real life i.e in real life if block has the same depth + // cannot happen in real life i.e. in real life if block has the same depth // then this is one block and transaction indexes. // In that case this test is noop to avoid spoutius failures if b1TxIdx(msg1) < b1TxIdx(msg2) { @@ -501,8 +501,8 @@ func TestStateTransitionOfValidSubmission(t *testing.T) { msg := dg.GenerateMessageWithRandomSubmitter([]*dg.BlockCreationResult{blck1, blck2}) // Now we will return depth enough for moving submission to confirmed - tk.BTCLightClient.SetDepth(blck1.HeaderBytes.Hash(), uint64(1)) - tk.BTCLightClient.SetDepth(blck2.HeaderBytes.Hash(), uint64(1)) + tk.BTCLightClient.SetDepth(blck1.HeaderBytes.Hash(), uint32(1)) + tk.BTCLightClient.SetDepth(blck2.HeaderBytes.Hash(), uint32(1)) _, err := tk.insertProofMsg(msg) @@ -571,7 +571,7 @@ func FuzzConfirmAndDinalizeManyEpochs(f *testing.F) { numOfEpochs := numFinalizedEpochs + numConfirmedEpochs + numSubmittedEpochs - bestSumbissionInfos := make(map[uint64]uint64) + bestSumbissionInfos := make(map[uint64]uint32) for i := 1; i <= numOfEpochs; i++ { epoch := uint64(i) @@ -587,13 +587,13 @@ func FuzzConfirmAndDinalizeManyEpochs(f *testing.F) { msg := dg.GenerateMessageWithRandomSubmitter([]*dg.BlockCreationResult{blck1, blck2}) if epoch <= uint64(numFinalizedEpochs) { - tk.BTCLightClient.SetDepth(blck1.HeaderBytes.Hash(), uint64(finalizationDepth)) + tk.BTCLightClient.SetDepth(blck1.HeaderBytes.Hash(), uint32(finalizationDepth)) finalizationDepth = finalizationDepth - 1 - tk.BTCLightClient.SetDepth(blck2.HeaderBytes.Hash(), uint64(finalizationDepth)) + tk.BTCLightClient.SetDepth(blck2.HeaderBytes.Hash(), uint32(finalizationDepth)) // first submission is always deepest one, and second block is the most recent one if j == 1 { - bestSumbissionInfos[epoch] = uint64(finalizationDepth) + bestSumbissionInfos[epoch] = uint32(finalizationDepth) } finalizationDepth = finalizationDepth - 1 } else if epoch <= uint64(numFinalizedEpochs+numConfirmedEpochs) { diff --git a/x/btccheckpoint/keeper/submissions.go b/x/btccheckpoint/keeper/submissions.go index 5e3f99b89..3ea2cc2b1 100644 --- a/x/btccheckpoint/keeper/submissions.go +++ b/x/btccheckpoint/keeper/submissions.go @@ -42,7 +42,7 @@ func (k Keeper) GetBestSubmission(ctx context.Context, epochNumber uint64) (type // addEpochSubmission save given submission key and data to database and takes // car of updating any necessary indexes. // Provided submmission should be known to btclightclient and all of its blocks -// should be on btc main chaing as viewed by btclightclient +// should be on btc main chain as viewed by btclightclient func (k Keeper) addEpochSubmission( ctx context.Context, epochNum uint64, @@ -132,12 +132,12 @@ func (k Keeper) checkSubmissionStatus(ctx context.Context, info *types.Submissio func (k Keeper) GetSubmissionBtcInfo(ctx context.Context, sk types.SubmissionKey) (*types.SubmissionBtcInfo, error) { - var youngestBlockDepth uint64 = math.MaxUint64 + var youngestBlockDepth uint32 = math.MaxUint32 var youngestBlockHash *bbn.BTCHeaderHashBytes var lowestIndexInMostFreshBlock uint32 = math.MaxUint32 - var oldestBlockDepth = uint64(0) + var oldestBlockDepth = uint32(0) for _, tk := range sk.Key { currentBlockDepth, err := k.headerDepth(ctx, tk.Hash) diff --git a/x/btccheckpoint/module.go b/x/btccheckpoint/module.go index 47b73657c..c91660855 100644 --- a/x/btccheckpoint/module.go +++ b/x/btccheckpoint/module.go @@ -80,8 +80,7 @@ func (AppModuleBasic) RegisterRESTRoutes(clientCtx client.Context, rtr *mux.Rout // RegisterGRPCGatewayRoutes registers the gRPC Gateway routes for the module. func (AppModuleBasic) RegisterGRPCGatewayRoutes(clientCtx client.Context, mux *runtime.ServeMux) { - err := types.RegisterQueryHandlerClient(context.Background(), mux, types.NewQueryClient(clientCtx)) - if err != nil { + if err := types.RegisterQueryHandlerClient(context.Background(), mux, types.NewQueryClient(clientCtx)); err != nil { panic(err) } } diff --git a/x/btccheckpoint/types/btccheckpoint.pb.go b/x/btccheckpoint/types/btccheckpoint.pb.go index 4e9ac7678..c65ba6c80 100644 --- a/x/btccheckpoint/types/btccheckpoint.pb.go +++ b/x/btccheckpoint/types/btccheckpoint.pb.go @@ -513,7 +513,7 @@ type BTCCheckpointInfo struct { // epoch number of this checkpoint EpochNumber uint64 `protobuf:"varint,1,opt,name=epoch_number,json=epochNumber,proto3" json:"epoch_number,omitempty"` // btc height of the best submission of the epoch - BestSubmissionBtcBlockHeight uint64 `protobuf:"varint,2,opt,name=best_submission_btc_block_height,json=bestSubmissionBtcBlockHeight,proto3" json:"best_submission_btc_block_height,omitempty"` + BestSubmissionBtcBlockHeight uint32 `protobuf:"varint,2,opt,name=best_submission_btc_block_height,json=bestSubmissionBtcBlockHeight,proto3" json:"best_submission_btc_block_height,omitempty"` // hash of the btc block which determines checkpoint btc block height i.e. // youngest block of best submission BestSubmissionBtcBlockHash *github_com_babylonlabs_io_babylon_types.BTCHeaderHashBytes `protobuf:"bytes,3,opt,name=best_submission_btc_block_hash,json=bestSubmissionBtcBlockHash,proto3,customtype=github.com/babylonlabs-io/babylon/types.BTCHeaderHashBytes" json:"best_submission_btc_block_hash,omitempty"` @@ -563,7 +563,7 @@ func (m *BTCCheckpointInfo) GetEpochNumber() uint64 { return 0 } -func (m *BTCCheckpointInfo) GetBestSubmissionBtcBlockHeight() uint64 { +func (m *BTCCheckpointInfo) GetBestSubmissionBtcBlockHeight() uint32 { if m != nil { return m.BestSubmissionBtcBlockHeight } @@ -601,58 +601,58 @@ func init() { } var fileDescriptor_e096cac78d49b0a6 = []byte{ - // 816 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x55, 0xcd, 0x8b, 0xdb, 0x46, - 0x14, 0xf7, 0xd8, 0xda, 0x34, 0x1e, 0x7b, 0x9d, 0xed, 0x78, 0x53, 0x84, 0x59, 0x14, 0x47, 0x85, - 0xc6, 0x29, 0x8d, 0x4d, 0xb6, 0xd0, 0xc2, 0x06, 0x0a, 0x2b, 0x7f, 0x60, 0x93, 0xc4, 0x9b, 0xca, - 0x4a, 0x0f, 0x39, 0x54, 0x48, 0xf2, 0xd8, 0x1a, 0x6c, 0x6b, 0x8c, 0x66, 0x6c, 0xec, 0xdc, 0x5a, - 0x28, 0x94, 0x9e, 0x4a, 0xef, 0x3d, 0xf5, 0x9f, 0xe9, 0xa1, 0x87, 0x1c, 0xcb, 0x1e, 0x96, 0xb2, - 0xfb, 0x2f, 0xf4, 0x5a, 0x28, 0x33, 0xd2, 0xfa, 0x6b, 0xd7, 0x6d, 0x0d, 0xbd, 0xf9, 0xbd, 0xf9, - 0xbd, 0x8f, 0xdf, 0xef, 0xbd, 0x67, 0xc1, 0x4f, 0x5c, 0xc7, 0x9d, 0x0f, 0x69, 0x50, 0x71, 0xb9, - 0xe7, 0xf9, 0xd8, 0x1b, 0x8c, 0x29, 0x09, 0x78, 0x65, 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b, 0x97, 0xf2, - 0x82, 0x30, 0xfe, 0xf1, 0x4f, 0x00, 0xa6, 0x17, 0xdb, 0x85, 0x1e, 0xc3, 0x0f, 0xea, 0xaf, 0xce, - 0xaa, 0x4d, 0xbb, 0x63, 0x9d, 0x5a, 0xaf, 0x3b, 0x76, 0xe7, 0xb5, 0xf1, 0xb2, 0x65, 0x59, 0xf5, - 0xda, 0x41, 0xa2, 0xb0, 0xff, 0xc3, 0xcf, 0xc5, 0x74, 0x27, 0xde, 0xa5, 0xee, 0x0d, 0x68, 0xf5, - 0xac, 0xdd, 0x68, 0x99, 0x2f, 0xeb, 0xb5, 0x03, 0x10, 0x41, 0xab, 0xd1, 0xbf, 0xeb, 0x2d, 0xd0, - 0x46, 0xab, 0x7d, 0xfa, 0xa2, 0xf5, 0xa6, 0x5e, 0x3b, 0x48, 0x46, 0xd0, 0x06, 0x09, 0x9c, 0x21, - 0x79, 0x8b, 0xbb, 0x05, 0xe5, 0xfb, 0x5f, 0xb4, 0x84, 0xf1, 0xe5, 0xaf, 0x97, 0x1a, 0x78, 0x77, - 0xa9, 0x81, 0x3f, 0x2e, 0x35, 0xf0, 0xe3, 0x95, 0x96, 0x78, 0x77, 0xa5, 0x25, 0x7e, 0xbf, 0xd2, - 0x12, 0x6f, 0x3e, 0xff, 0xf7, 0xb9, 0xcf, 0x36, 0x3e, 0x8c, 0x72, 0x0f, 0xdc, 0x3b, 0xf2, 0xf3, - 0xf6, 0xe9, 0xdf, 0x01, 0x00, 0x00, 0xff, 0xff, 0x35, 0x29, 0x9d, 0x36, 0x3e, 0x07, 0x00, 0x00, + // 814 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x55, 0xcd, 0x6b, 0xe3, 0x46, + 0x14, 0xf7, 0xd8, 0xce, 0x76, 0x3d, 0x76, 0xbc, 0xe9, 0x38, 0x5b, 0x84, 0x09, 0x5a, 0xaf, 0x0a,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x1f, 0x60, 0xcb, 0xa7, 0x1d, 0xcc, 0x94, 0x84, 0x8c, 0x9c, 0x0e, 0x75, 0x2d, + 0xa1, 0x42, 0x3e, 0x7c, 0xec, 0x52, 0xbf, 0x4b, 0x82, 0x21, 0xf1, 0x7b, 0x96, 0xc8, 0xe0, 0x61, + 0xbb, 0x83, 0x03, 0x25, 0x29, 0xb0, 0xfa, 0xd1, 0xe5, 0xd5, 0x93, 0xcf, 0x7a, 0x84, 0x7b, 0x63, + 0xa7, 0xe4, 0xd2, 0x61, 0x39, 0xea, 0x76, 0x60, 0x3b, 0xec, 0x05, 0xa1, 0xb7, 0x62, 0x99, 0xcf, + 0x46, 0x98, 0x95, 0x74, 0xb3, 0xd2, 0x90, 0xce, 0xfa, 0x8c, 0x63, 0x66, 0xe4, 0x16, 0x81, 0x75, + 0xee, 0x86, 0x16, 0xed, 0x1c, 0x66, 0x97, 0xca, 0x7c, 0x8d, 0x67, 0x68, 0x1f, 0xee, 0x84, 0x8d, + 0x00, 0xd9, 0x48, 0x28, 0x20, 0x03, 0x26, 0x3d, 0x9b, 0x79, 0xb2, 0xbb, 0x8c, 0xfe, 0xc5, 0xe5, + 0xd5, 0x93, 0xa3, 0xad, 0xcb, 0x68, 0xd8, 0xcc, 0x0b, 0x4b, 0x91, 0xb1, 0xb4, 0xd7, 0x70, 0xb7, + 0x3d, 0x76, 0x86, 0x84, 0xb1, 0x28, 0xf5, 0x11, 0x4c, 0xf4, 0xf1, 0x4c, 0x01, 0x85, 0x44, 0x31, + 0x7d, 0x58, 0x2c, 0x6d, 0x1a, 0x65, 0x69, 0xb5, 0x62, 0x43, 0x38, 0x69, 0xdf, 0x01, 0xf8, 0x68, + 0x85, 0xf0, 0x2e, 0x5d, 0xc4, 0x03, 0x5b, 0xc7, 0x43, 0x05, 0x98, 0x5e, 0x5e, 0x82, 0x78, 0x38, + 0xaa, 0x25, 0x95, 0x20, 0x6a, 0x24, 0x76, 0x26, 0x1a, 0x63, 0x28, 0x68, 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a8, 0x31, 0xfd, 0xcb, 0x5f, 0xaf, 0x55, 0x70, 0x71, 0xad, + 0x82, 0x3f, 0xae, 0x55, 0xf0, 0xe3, 0x8d, 0x1a, 0xbb, 0xb8, 0x51, 0x63, 0xbf, 0xdf, 0xa8, 0xb1, + 0xb3, 0xcf, 0xff, 0x7d, 0xee, 0xd3, 0xb5, 0x87, 0x51, 0xee, 0x81, 0xf3, 0x40, 0x3e, 0x6f, 0x9f, + 0xfe, 0x1d, 0x00, 0x00, 0xff, 0xff, 0xbb, 0x84, 0x86, 0x4f, 0x3e, 0x07, 0x00, 0x00, } func (m *BTCSpvProof) Marshal() (dAtA []byte, err error) { @@ -2158,7 +2158,7 @@ func (m *BTCCheckpointInfo) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - m.BestSubmissionBtcBlockHeight |= uint64(b&0x7F) << shift + m.BestSubmissionBtcBlockHeight |= uint32(b&0x7F) << shift if b < 0x80 { break } diff --git a/x/btccheckpoint/types/btcutils.go b/x/btccheckpoint/types/btcutils.go index f3b969028..02dedcd74 100644 --- a/x/btccheckpoint/types/btcutils.go +++ b/x/btccheckpoint/types/btcutils.go @@ -20,7 +20,7 @@ import ( // - Bitcoin Transaction index in block // - Non-empty OpReturnData type ParsedProof struct { - // keeping header hash to avoid recomputing it everytime + // keeping header hash to avoid recomputing it every time BlockHash types.BTCHeaderHashBytes Transaction *btcutil.Tx TransactionBytes []byte @@ -74,7 +74,7 @@ func createBranch(nodes []*chainhash.Hash, numfLeafs uint, idx uint) []*chainhas // index^1 means we want to get sibling of the node we are proving // ie. for index=2, index^1 = 3 and for index=3 index^1=2 - // so xoring last bit by 1, select node oposite to the node we want the proof + // so xoring last bit by 1, select node opposite to the node we want the proof // for. // case with `size-1` is needed when the number of leafs is not power of 2 // and xor^1 could point outside of the tree @@ -106,7 +106,7 @@ func CreateProofForIdx(transactions [][]byte, idx uint) ([]*chainhash.Hash, erro } if int(idx) >= len(transactions) { - return nil, errors.New("provided index should be smaller that lenght of transaction list") + return nil, errors.New("provided index should be smaller that length of transaction list") } var txs []*btcutil.Tx diff --git a/x/btccheckpoint/types/btcutils_test.go b/x/btccheckpoint/types/btcutils_test.go index 405b7bde3..c632ee3ff 100644 --- a/x/btccheckpoint/types/btcutils_test.go +++ b/x/btccheckpoint/types/btcutils_test.go @@ -18,9 +18,9 @@ import ( "github.com/stretchr/testify/require" ) -// Sanity test checking mostly btcd code, that we can realy parse bitcoin transaction +// Sanity test checking mostly btcd code, that we can really parse bitcoin transaction func TestBtcTransactionParsing(t *testing.T) { - // Few randomly chosed btc valid btc transactions + // Few randomly chosen btc valid btc transactions tests := []struct { bitcoinTransactionHex string txHash string diff --git a/x/btccheckpoint/types/expected_keepers.go b/x/btccheckpoint/types/expected_keepers.go index 324fccefc..b8e8cd04c 100644 --- a/x/btccheckpoint/types/expected_keepers.go +++ b/x/btccheckpoint/types/expected_keepers.go @@ -2,18 +2,20 @@ package types import ( "context" + txformat "github.com/babylonlabs-io/babylon/btctxformatter" bbn "github.com/babylonlabs-io/babylon/types" + sdk "github.com/cosmos/cosmos-sdk/types" ) type BTCLightClientKeeper interface { // BlockHeight should validate if header with given hash is valid and if it is // part of known chain. In case this is true it should return this block height // in case this is false it should return error - BlockHeight(ctx context.Context, headerHash *bbn.BTCHeaderHashBytes) (uint64, error) + BlockHeight(ctx context.Context, headerHash *bbn.BTCHeaderHashBytes) (uint32, error) // MainChainDepth returns the depth of the header in the main chain or error if the header does not exist - MainChainDepth(ctx context.Context, headerBytes *bbn.BTCHeaderHashBytes) (uint64, error) + MainChainDepth(ctx context.Context, headerBytes *bbn.BTCHeaderHashBytes) (uint32, error) } type CheckpointingKeeper interface { @@ -39,5 +41,5 @@ type CheckpointingKeeper interface { } type IncentiveKeeper interface { - RewardBTCTimestamping(ctx context.Context, epoch uint64, rewardDistInfo *RewardDistInfo) + IndexRefundableMsg(ctx context.Context, msg sdk.Msg) } diff --git a/x/btccheckpoint/types/mock_keepers.go b/x/btccheckpoint/types/mock_keepers.go index 8d58c3dc3..bc4e809d6 100644 --- a/x/btccheckpoint/types/mock_keepers.go +++ b/x/btccheckpoint/types/mock_keepers.go @@ -6,10 +6,11 @@ import ( txformat "github.com/babylonlabs-io/babylon/btctxformatter" bbn "github.com/babylonlabs-io/babylon/types" + sdk "github.com/cosmos/cosmos-sdk/types" ) type MockBTCLightClientKeeper struct { - headers map[string]uint64 + headers map[string]uint32 } type MockCheckpointingKeeper struct { @@ -21,7 +22,7 @@ type MockIncentiveKeeper struct { func NewMockBTCLightClientKeeper() *MockBTCLightClientKeeper { lc := MockBTCLightClientKeeper{ - headers: make(map[string]uint64), + headers: make(map[string]uint32), } return &lc } @@ -45,7 +46,7 @@ func (mc *MockCheckpointingKeeper) ReturnSuccess() { mc.returnError = false } -func (mc *MockBTCLightClientKeeper) SetDepth(header *bbn.BTCHeaderHashBytes, dd uint64) { +func (mc *MockBTCLightClientKeeper) SetDepth(header *bbn.BTCHeaderHashBytes, dd uint32) { mc.headers[header.String()] = dd } @@ -53,12 +54,12 @@ func (mc *MockBTCLightClientKeeper) DeleteHeader(header *bbn.BTCHeaderHashBytes) delete(mc.headers, header.String()) } -func (mb MockBTCLightClientKeeper) BlockHeight(ctx context.Context, header *bbn.BTCHeaderHashBytes) (uint64, error) { +func (mb MockBTCLightClientKeeper) BlockHeight(ctx context.Context, header *bbn.BTCHeaderHashBytes) (uint32, error) { // todo not used - return uint64(10), nil + return uint32(10), nil } -func (ck MockBTCLightClientKeeper) MainChainDepth(ctx context.Context, headerBytes *bbn.BTCHeaderHashBytes) (uint64, error) { +func (ck MockBTCLightClientKeeper) MainChainDepth(ctx context.Context, headerBytes *bbn.BTCHeaderHashBytes) (uint32, error) { depth, ok := ck.headers[headerBytes.String()] if ok { return depth, nil @@ -97,3 +98,6 @@ func (ck MockCheckpointingKeeper) SetCheckpointForgotten(ctx context.Context, ep func (ik *MockIncentiveKeeper) RewardBTCTimestamping(ctx context.Context, epoch uint64, rewardDistInfo *RewardDistInfo) { } + +func (ik *MockIncentiveKeeper) IndexRefundableMsg(ctx context.Context, msg sdk.Msg) { +} diff --git a/x/btccheckpoint/types/msgs.go b/x/btccheckpoint/types/msgs.go index ee645c24e..d3a2a1ff6 100644 --- a/x/btccheckpoint/types/msgs.go +++ b/x/btccheckpoint/types/msgs.go @@ -3,6 +3,7 @@ package types import ( "errors" fmt "fmt" + "math" "math/big" txformat "github.com/babylonlabs-io/babylon/btctxformatter" @@ -52,10 +53,14 @@ func ParseTwoProofs( var checkpointData [][]byte for i, proof := range parsedProofs { + if i > math.MaxUint8 || i < 0 { + return nil, fmt.Errorf("expected at most 255 proofs but got %d", len(parsedProofs)) + } + partIdxUint8 := uint8(i) data, err := txformat.GetCheckpointData( expectedTag, txformat.CurrentVersion, - uint8(i), + partIdxUint8, proof.OpReturnData, ) @@ -65,7 +70,7 @@ func ParseTwoProofs( checkpointData = append(checkpointData, data) } - // at this point we know we have two correctly formated babylon op return transacitons + // at this point we know we have two correctly formated babylon op return transactions // we need to check if parts match rawCkptData, err := txformat.ConnectParts(txformat.CurrentVersion, checkpointData[0], checkpointData[1]) diff --git a/x/btccheckpoint/types/params.go b/x/btccheckpoint/types/params.go index 68b62f4b7..fc3d42011 100644 --- a/x/btccheckpoint/types/params.go +++ b/x/btccheckpoint/types/params.go @@ -8,13 +8,13 @@ import ( ) const ( - DefaultBtcConfirmationDepth uint64 = 10 - DefaultCheckpointFinalizationTimeout uint64 = 100 + DefaultBtcConfirmationDepth uint32 = 10 + DefaultCheckpointFinalizationTimeout uint32 = 100 DefaultCheckpointTag = "01020304" ) // NewParams creates a new Params instance -func NewParams(btcConfirmationDepth uint64, checkpointFinalizationTimeout uint64, checkpointTag string) Params { +func NewParams(btcConfirmationDepth uint32, checkpointFinalizationTimeout uint32, checkpointTag string) Params { return Params{ BtcConfirmationDepth: btcConfirmationDepth, CheckpointFinalizationTimeout: checkpointFinalizationTimeout, @@ -52,7 +52,7 @@ func (p Params) Validate() error { } func validateBtcConfirmationDepth(i interface{}) error { - v, ok := i.(uint64) + v, ok := i.(uint32) if !ok { return fmt.Errorf("invalid parameter type: %T", i) } @@ -65,7 +65,7 @@ func validateBtcConfirmationDepth(i interface{}) error { } func validateCheckpointFinalizationTimeout(i interface{}) error { - v, ok := i.(uint64) + v, ok := i.(uint32) if !ok { return fmt.Errorf("invalid parameter type: %T", i) } diff --git a/x/btccheckpoint/types/params.pb.go b/x/btccheckpoint/types/params.pb.go index a2f432d08..07ab0102a 100644 --- a/x/btccheckpoint/types/params.pb.go +++ b/x/btccheckpoint/types/params.pb.go @@ -28,14 +28,14 @@ type Params struct { // btc_confirmation_depth is the confirmation depth in BTC. // A block is considered irreversible only when it is at least k-deep in BTC // (k in research paper) - BtcConfirmationDepth uint64 `protobuf:"varint,1,opt,name=btc_confirmation_depth,json=btcConfirmationDepth,proto3" json:"btc_confirmation_depth,omitempty" yaml:"btc_confirmation_depth"` + BtcConfirmationDepth uint32 `protobuf:"varint,1,opt,name=btc_confirmation_depth,json=btcConfirmationDepth,proto3" json:"btc_confirmation_depth,omitempty" yaml:"btc_confirmation_depth"` // checkpoint_finalization_timeout is the maximum time window (measured in BTC // blocks) between a checkpoint // - being submitted to BTC, and // - being reported back to BBN // If a checkpoint has not been reported back within w BTC blocks, then BBN // has dishonest majority and is stalling checkpoints (w in research paper) - CheckpointFinalizationTimeout uint64 `protobuf:"varint,2,opt,name=checkpoint_finalization_timeout,json=checkpointFinalizationTimeout,proto3" json:"checkpoint_finalization_timeout,omitempty" yaml:"checkpoint_finalization_timeout"` + CheckpointFinalizationTimeout uint32 `protobuf:"varint,2,opt,name=checkpoint_finalization_timeout,json=checkpointFinalizationTimeout,proto3" json:"checkpoint_finalization_timeout,omitempty" yaml:"checkpoint_finalization_timeout"` // 4byte tag in hex format, required to be present in the OP_RETURN transaction // related to babylon CheckpointTag string `protobuf:"bytes,3,opt,name=checkpoint_tag,json=checkpointTag,proto3" json:"checkpoint_tag,omitempty" yaml:"checkpoint_tag"` @@ -74,14 +74,14 @@ func (m *Params) XXX_DiscardUnknown() { var xxx_messageInfo_Params proto.InternalMessageInfo -func (m *Params) GetBtcConfirmationDepth() uint64 { +func (m *Params) GetBtcConfirmationDepth() uint32 { if m != nil { return m.BtcConfirmationDepth } return 0 } -func (m *Params) GetCheckpointFinalizationTimeout() uint64 { +func (m *Params) GetCheckpointFinalizationTimeout() uint32 { if m != nil { return m.CheckpointFinalizationTimeout } @@ -112,7 +112,7 @@ var fileDescriptor_5445a19005ae983c = []byte{ 0x9e, 0x0f, 0x56, 0xa4, 0x0f, 0x62, 0x41, 0xd4, 0x2b, 0xcd, 0x65, 0xe2, 0x62, 0x0b, 0x00, 0x1b, 0x20, 0x14, 0xce, 0x25, 0x96, 0x54, 0x92, 0x1c, 0x9f, 0x9c, 0x9f, 0x97, 0x96, 0x59, 0x94, 0x9b, 0x58, 0x92, 0x99, 0x9f, 0x17, 0x9f, 0x92, 0x5a, 0x50, 0x92, 0x21, 0xc1, 0xa8, 0xc0, 0xa8, 0xc1, - 0xe2, 0xa4, 0xf8, 0xe9, 0x9e, 0xbc, 0x6c, 0x65, 0x62, 0x6e, 0x8e, 0x95, 0x12, 0x76, 0x75, 0x4a, + 0xeb, 0xa4, 0xf8, 0xe9, 0x9e, 0xbc, 0x6c, 0x65, 0x62, 0x6e, 0x8e, 0x95, 0x12, 0x76, 0x75, 0x4a, 0x41, 0x22, 0x49, 0x25, 0xc9, 0xce, 0x48, 0xe2, 0x2e, 0x20, 0x61, 0xa1, 0x22, 0x2e, 0x79, 0x84, 0x53, 0xe2, 0xd3, 0x32, 0xf3, 0x12, 0x73, 0x32, 0xab, 0x20, 0xfa, 0x4a, 0x32, 0x73, 0x53, 0xf3, 0x4b, 0x4b, 0x24, 0x98, 0xc0, 0x36, 0x68, 0x7d, 0xba, 0x27, 0xaf, 0x06, 0xb1, 0x81, 0x80, 0x06, @@ -123,7 +123,7 @@ var fileDescriptor_5445a19005ae983c = []byte{ 0x24, 0xc7, 0x38, 0xe1, 0xb1, 0x1c, 0xc3, 0x85, 0xc7, 0x72, 0x0c, 0x37, 0x1e, 0xcb, 0x31, 0x44, 0x99, 0xa7, 0x67, 0x96, 0x64, 0x94, 0x26, 0xe9, 0x25, 0xe7, 0xe7, 0xea, 0x43, 0x03, 0x3d, 0x27, 0x31, 0xa9, 0x58, 0x37, 0x33, 0x1f, 0xc6, 0xd5, 0xaf, 0x40, 0x8b, 0xac, 0x92, 0xca, 0x82, 0xd4, - 0xe2, 0x24, 0x36, 0x70, 0xc8, 0x1b, 0x03, 0x02, 0x00, 0x00, 0xff, 0xff, 0x8e, 0x82, 0xde, 0x0b, + 0xe2, 0x24, 0x36, 0x70, 0xc8, 0x1b, 0x03, 0x02, 0x00, 0x00, 0xff, 0xff, 0xc3, 0x4e, 0xe2, 0x30, 0xd2, 0x01, 0x00, 0x00, } @@ -276,7 +276,7 @@ func (m *Params) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - m.BtcConfirmationDepth |= uint64(b&0x7F) << shift + m.BtcConfirmationDepth |= uint32(b&0x7F) << shift if b < 0x80 { break } @@ -295,7 +295,7 @@ func (m *Params) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - m.CheckpointFinalizationTimeout |= uint64(b&0x7F) << shift + m.CheckpointFinalizationTimeout |= uint32(b&0x7F) << shift if b < 0x80 { break } diff --git a/x/btccheckpoint/types/query.pb.go b/x/btccheckpoint/types/query.pb.go index 88a83251e..e989b2b2d 100644 --- a/x/btccheckpoint/types/query.pb.go +++ b/x/btccheckpoint/types/query.pb.go @@ -410,7 +410,7 @@ type BTCCheckpointInfoResponse struct { // EpochNumber of this checkpoint. EpochNumber uint64 `protobuf:"varint,1,opt,name=epoch_number,json=epochNumber,proto3" json:"epoch_number,omitempty"` // btc height of the best submission of the epoch - BestSubmissionBtcBlockHeight uint64 `protobuf:"varint,2,opt,name=best_submission_btc_block_height,json=bestSubmissionBtcBlockHeight,proto3" json:"best_submission_btc_block_height,omitempty"` + BestSubmissionBtcBlockHeight uint32 `protobuf:"varint,2,opt,name=best_submission_btc_block_height,json=bestSubmissionBtcBlockHeight,proto3" json:"best_submission_btc_block_height,omitempty"` // hash of the btc block which determines checkpoint btc block height i.e. // youngest block of best submission Hexadecimal BestSubmissionBtcBlockHash string `protobuf:"bytes,3,opt,name=best_submission_btc_block_hash,json=bestSubmissionBtcBlockHash,proto3" json:"best_submission_btc_block_hash,omitempty"` @@ -460,7 +460,7 @@ func (m *BTCCheckpointInfoResponse) GetEpochNumber() uint64 { return 0 } -func (m *BTCCheckpointInfoResponse) GetBestSubmissionBtcBlockHeight() uint64 { +func (m *BTCCheckpointInfoResponse) GetBestSubmissionBtcBlockHeight() uint32 { if m != nil { return m.BestSubmissionBtcBlockHeight } @@ -720,67 +720,67 @@ func init() { } var fileDescriptor_6b9a2f46ada7d854 = []byte{ - // 950 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x9c, 0x56, 0x41, 0x6f, 0x1b, 0x45, - 0x14, 0xce, 0x3a, 0x9b, 0x28, 0x7e, 0x69, 0xa1, 0x9d, 0x1a, 0xe1, 0x38, 0xc1, 0x75, 0x57, 0x6d, - 0x1a, 0x21, 0xbc, 0x2b, 0x37, 0xd0, 0x50, 0x81, 0x90, 0x70, 0x44, 0x4b, 0x05, 0x42, 0xe9, 0x36, - 0x70, 0xe0, 0xb2, 0x9a, 0x5d, 0x4f, 0xd6, 0xa3, 0xd8, 0x3b, 0xdb, 0x9d, 0x71, 0x14, 0xab, 0xe2, - 0xc2, 0x0d, 0x71, 0x00, 0x89, 0xbf, 0xc1, 0x11, 0x6e, 0x08, 0x89, 0x03, 0x52, 0x25, 0x2e, 0x15, - 0x5c, 0x38, 0x21, 0x94, 0xf0, 0x43, 0xd0, 0xce, 0x8c, 0xbd, 0x6b, 0x3b, 0x5b, 0x27, 0xbd, 0x79, - 0x77, 0xbe, 0xef, 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 0x05, 0x5d, 0xa8, 0x7e, - 0x7e, 0xdf, 0xd5, 0xee, 0xbd, 0x04, 0x53, 0x5b, 0xbf, 0x21, 0xad, 0xaf, 0xa3, 0xb5, 0x42, 0xeb, - 0xe8, 0x57, 0x03, 0xae, 0x4c, 0x6f, 0x01, 0x74, 0x77, 0x4e, 0xc9, 0x82, 0x9d, 0x53, 0xdb, 0xb9, - 0x30, 0x4f, 0x1b, 0xbd, 0x27, 0x8d, 0x6e, 0xa3, 0xd6, 0xb9, 0x32, 0x76, 0xb2, 0xaf, 0x21, 0x6f, - 0x3f, 0x7a, 0x76, 0x52, 0x37, 0x9e, 0x9f, 0xd4, 0x8d, 0x7f, 0x4f, 0xea, 0xc6, 0xf7, 0xa7, 0xf5, - 0x85, 0xe7, 0xa7, 0xf5, 0x85, 0xbf, 0x4f, 0xeb, 0x0b, 0x5f, 0xee, 0x84, 0x54, 0x74, 0x07, 0xbe, - 0x1d, 0xb0, 0xfe, 0x48, 0xb6, 0x87, 0x7d, 0xde, 0xa4, 0x6c, 0x5c, 0xe5, 0x78, 0xaa, 0x8e, 0x18, - 0xc6, 0x84, 0xfb, 0xcb, 0xf2, 0x1f, 0xb4, 0xed, 0xff, 0x03, 0x00, 0x00, 0xff, 0xff, 0x12, 0x02, - 0x0c, 0x21, 0x84, 0x0a, 0x00, 0x00, + // 948 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x9c, 0x56, 0x4f, 0x6f, 0x1b, 0x45, + 0x14, 0xcf, 0x26, 0x4e, 0x14, 0xbf, 0x34, 0xd0, 0x4e, 0x8d, 0x70, 0x9c, 0xe0, 0xba, 0xab, 0x36, + 0x8d, 0x10, 0xde, 0x95, 0x1b, 0x68, 0xa8, 0x40, 0x48, 0x38, 0xa2, 0xa5, 0x02, 0xa1, 0x74, 0x1b, + 0x38, 0x70, 0x59, 0xcd, 0xae, 0x27, 0xeb, 0x51, 0xec, 0x9d, 0xed, 0xce, 0x38, 0x8a, 0x55, 0x71, + 0xe1, 0x86, 0x38, 0x80, 0xc4, 0xd7, 0xe0, 0x08, 0x37, 0x84, 0xc4, 0x01, 0xa9, 0x12, 0x97, 0x0a, + 0x2e, 0x9c, 0x10, 0x4a, 0xf8, 0x20, 0x68, 0x67, 0xc6, 0xbb, 0x6b, 0x3b, 0x5b, 0x27, 0xb9, 0x79, + 0x77, 0x7e, 0xff, 0xe6, 0xbd, 0x97, 0x7d, 0x81, 0x5b, 0x1e, 0xf6, 0x86, 0x3d, 0x16, 0xda, 0x9e, + 0xf0, 0xfd, 0x2e, 0xf1, 0x0f, 0x23, 0x46, 0x43, 0x61, 0x1f, 0xb5, 0xec, 0xa7, 0x03, 0x12, 0x0f, + 0xad, 0x28, 0x66, 0x82, 0xa1, 0xaa, 0x46, 0x59, 0x63, 0x28, 0xeb, 0xa8, 0x55, 0xab, 0x04, 0x2c, + 0x60, 0x12, 0x64, 0x27, 0xbf, 0x14, 0xbe, 0xb6, 0xe6, 0x33, 0xde, 0x67, 0xdc, 0x55, 0x07, 0xea, + 0x41, 0x1f, 0x6d, 0x04, 0x8c, 0x05, 0x3d, 0x62, 0xe3, 0x88, 0xda, 0x38, 0x0c, 0x99, 0xc0, 0x82, + 0xb2, 0x70, 0x74, 0xfa, 0xa6, 0xc2, 0xda, 0x1e, 0xe6, 0x44, 0x25, 0xb0, 0x8f, 0x5a, 0x1e, 0x11, + 0xb8, 0x65, 0x47, 0x38, 0xa0, 0xa1, 0x04, 0x6b, 0xec, 0xed, 0xc2, 0xe8, 0x11, 0x8e, 0x71, 0x5f, + 0x4b, 0x9a, 0x15, 0x40, 0x8f, 0x13, 0xa1, 0x3d, 0xf9, 0xd2, 0x21, 0x4f, 0x07, 0x84, 0x0b, 0xf3, + 0x73, 0xb8, 0x3e, 0xf6, 0x96, 0x47, 0x2c, 0xe4, 0x04, 0x7d, 0x00, 0x4b, 0x8a, 0x5c, 0x35, 0x1a, + 0xc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e, 0xbe, 0x73, 0x46, 0xfe, 0x84, 0x0c, 0xb3, 0x5e, + 0x26, 0x64, 0xf3, 0x8f, 0x05, 0x58, 0x2b, 0xac, 0x09, 0xba, 0x09, 0x57, 0xd2, 0x80, 0x1e, 0x89, + 0x75, 0xc6, 0x95, 0x51, 0x46, 0x8f, 0xc4, 0xe8, 0x01, 0x34, 0x3c, 0xc2, 0x85, 0xcb, 0x53, 0x13, + 0xd7, 0x13, 0xbe, 0xeb, 0xf5, 0x98, 0x7f, 0xe8, 0x76, 0x09, 0x0d, 0xba, 0x42, 0x96, 0x70, 0xd5, + 0xd9, 0x48, 0x70, 0x59, 0x96, 0xb6, 0xf0, 0xdb, 0x09, 0xe8, 0x63, 0x89, 0x41, 0x6d, 0xa8, 0xbf, + 0x44, 0x07, 0xf3, 0x6e, 0x75, 0xa1, 0x61, 0x6c, 0x95, 0x9d, 0x5a, 0x81, 0x0a, 0xe6, 0x5d, 0xc4, + 0x61, 0x63, 0x52, 0x43, 0xc4, 0x38, 0xe4, 0xd8, 0x97, 0xdf, 0x89, 0x6a, 0x49, 0x56, 0xaa, 0x55, + 0x5c, 0xa9, 0xfd, 0x0c, 0x3d, 0x36, 0x1b, 0x13, 0xa6, 0x39, 0x18, 0x47, 0xdf, 0x18, 0xb0, 0x39, + 0xe9, 0x7a, 0x44, 0x03, 0xda, 0xc3, 0xa1, 0x20, 0x2e, 0xee, 0x74, 0x62, 0xc2, 0xb9, 0x9a, 0xce, + 0x45, 0xe9, 0xff, 0x4e, 0xb1, 0x7f, 0xd6, 0x86, 0x0f, 0x15, 0x8f, 0xa4, 0xed, 0x76, 0xcc, 0xf1, + 0x0c, 0x5f, 0x8c, 0x2c, 0x34, 0x32, 0x99, 0x5c, 0xf3, 0x19, 0xbc, 0x5e, 0x70, 0x05, 0x54, 0x81, + 0x45, 0x1a, 0x76, 0xc8, 0xb1, 0xec, 0xe1, 0xaa, 0xa3, 0x1e, 0x10, 0x82, 0x92, 0xac, 0xed, 0xbc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0xc0, 0xb5, 0xa9, 0x7d, 0x83, 0x76, 0x66, 0xd8, 0x15, + 0xed, 0xb7, 0xda, 0xbb, 0x17, 0x27, 0xea, 0xc8, 0x4d, 0x19, 0xf9, 0x0e, 0xba, 0x5d, 0x1c, 0xf9, + 0x59, 0xfa, 0x21, 0xfb, 0x0a, 0xfd, 0x68, 0x00, 0x9a, 0xde, 0x28, 0xe8, 0x42, 0xfe, 0xf9, 0x7d, + 0x57, 0xbb, 0x7f, 0x09, 0xa6, 0x8e, 0x7e, 0x53, 0x46, 0x5f, 0x47, 0x6b, 0x85, 0xd1, 0xd1, 0xaf, + 0x06, 0x5c, 0x9d, 0xdc, 0x02, 0xe8, 0xde, 0x0c, 0xcb, 0x82, 0x9d, 0x53, 0xdb, 0xb9, 0x30, 0x4f, + 0x07, 0xbd, 0x2f, 0x83, 0x6e, 0xa3, 0xd6, 0xb9, 0x6a, 0x6c, 0x67, 0x5f, 0x43, 0xde, 0x7e, 0xfc, + 0xfc, 0xa4, 0x6e, 0xbc, 0x38, 0xa9, 0x1b, 0xff, 0x9e, 0xd4, 0x8d, 0xef, 0x4f, 0xeb, 0x73, 0x2f, + 0x4e, 0xeb, 0x73, 0x7f, 0x9f, 0xd6, 0xe7, 0xbe, 0xdc, 0x09, 0xa8, 0xe8, 0x0e, 0x3c, 0xcb, 0x67, + 0xfd, 0x91, 0x6c, 0x0f, 0x7b, 0xbc, 0x49, 0x59, 0xea, 0x72, 0x3c, 0xe1, 0x23, 0x86, 0x11, 0xe1, + 0xde, 0x92, 0xfc, 0x07, 0x6d, 0xfb, 0xff, 0x00, 0x00, 0x00, 0xff, 0xff, 0x47, 0x16, 0xcd, 0xfc, + 0x84, 0x0a, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -2373,7 +2373,7 @@ func (m *BTCCheckpointInfoResponse) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - m.BestSubmissionBtcBlockHeight |= uint64(b&0x7F) << shift + m.BestSubmissionBtcBlockHeight |= uint32(b&0x7F) << shift if b < 0x80 { break } diff --git a/x/btccheckpoint/types/tx.pb.go b/x/btccheckpoint/types/tx.pb.go index 3e3f75258..070362d65 100644 --- a/x/btccheckpoint/types/tx.pb.go +++ b/x/btccheckpoint/types/tx.pb.go @@ -30,7 +30,7 @@ var _ = math.Inf // proto package needs to be updated. const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package -// MsgInsertBTCSpvProof defines resquest to insert a new checkpoint into the +// MsgInsertBTCSpvProof defines request to insert a new checkpoint into the // store type MsgInsertBTCSpvProof struct { Submitter string `protobuf:"bytes,1,opt,name=submitter,proto3" json:"submitter,omitempty"` diff --git a/x/btccheckpoint/types/types.go b/x/btccheckpoint/types/types.go index e70846158..7a55899d2 100644 --- a/x/btccheckpoint/types/types.go +++ b/x/btccheckpoint/types/types.go @@ -5,10 +5,11 @@ import ( "fmt" "math/big" - "github.com/babylonlabs-io/babylon/btctxformatter" - "github.com/babylonlabs-io/babylon/types" "github.com/cosmos/cosmos-sdk/codec" sdk "github.com/cosmos/cosmos-sdk/types" + + "github.com/babylonlabs-io/babylon/btctxformatter" + "github.com/babylonlabs-io/babylon/types" ) // RawCheckpointSubmission Semantically valid checkpoint submission with: @@ -28,10 +29,10 @@ type RawCheckpointSubmission struct { type SubmissionBtcInfo struct { SubmissionKey SubmissionKey // Depth of the oldest btc header of the submission - OldestBlockDepth uint64 + OldestBlockDepth uint32 // Depth of the youngest btc header of the submission - YoungestBlockDepth uint64 + YoungestBlockDepth uint32 // Hash of the youngest btc header of the submission YoungestBlockHash types.BTCHeaderHashBytes @@ -135,7 +136,7 @@ func (submission *SubmissionBtcInfo) HappenedAfter(parentEpochSubmission *Submis // SubmissionDepth return depth of the submission. Due to the fact that submissions // are split between several btc blocks, in Babylon submission depth is the depth // of the youngest btc block -func (submission *SubmissionBtcInfo) SubmissionDepth() uint64 { +func (submission *SubmissionBtcInfo) SubmissionDepth() uint32 { return submission.YoungestBlockDepth } diff --git a/x/btclightclient/README.md b/x/btclightclient/README.md index 7b7134b97..e43943bf6 100644 --- a/x/btclightclient/README.md +++ b/x/btclightclient/README.md @@ -119,7 +119,7 @@ message BTCHeaderInfo { bytes hash = 2 [ (gogoproto.customtype) = "github.com/babylonlabs-io/babylon/types.BTCHeaderHashBytes" ]; - uint64 height = 3; + uint32 height = 3; bytes work = 4 [ (gogoproto.customtype) = "cosmossdk.io/math.Uint" ]; } diff --git a/x/btclightclient/genesis_test.go b/x/btclightclient/genesis_test.go index 98ffd13a4..62ad9f028 100644 --- a/x/btclightclient/genesis_test.go +++ b/x/btclightclient/genesis_test.go @@ -55,7 +55,6 @@ func TestImportExport(t *testing.T) { chainExtension := datagen.GenRandomValidChainStartingFrom( r, - initTip.Height, initTip.Header.ToBlockHeader(), nil, 10, @@ -71,7 +70,6 @@ func TestImportExport(t *testing.T) { newChainExt := datagen.GenRandomValidChainStartingFrom( r, - newTip.Height, newTip.Header.ToBlockHeader(), nil, 10, @@ -94,5 +92,5 @@ func TestImportExport(t *testing.T) { failedKVAs, failedKVBs := thelper.DiffKVStores(KvA, KvB, [][]byte{}) require.Equal(t, len(failedKVAs), len(failedKVBs), "unequal sets of key-values to compare btcligthclient") - require.Equal(t, len(failedKVAs), 0, "should not exist any difference froms states.") + require.Equal(t, len(failedKVAs), 0, "should not exist any difference between states.") } diff --git a/x/btclightclient/keeper/grpc_query.go b/x/btclightclient/keeper/grpc_query.go index 91d3792e8..9024cc605 100644 --- a/x/btclightclient/keeper/grpc_query.go +++ b/x/btclightclient/keeper/grpc_query.go @@ -2,6 +2,7 @@ package keeper import ( "context" + "fmt" bbn "github.com/babylonlabs-io/babylon/types" "github.com/babylonlabs-io/babylon/x/btclightclient/types" @@ -11,6 +12,8 @@ import ( "google.golang.org/grpc/status" ) +const MaxHeadersPerRequest uint32 = 1000 + var _ types.QueryServer = Keeper{} func (k Keeper) Params(c context.Context, req *types.QueryParamsRequest) (*types.QueryParamsResponse, error) { @@ -91,6 +94,10 @@ func (k Keeper) MainChain(c context.Context, req *types.QueryMainChainRequest) ( req.Pagination.Limit = query.DefaultLimit } + if req.Pagination.Limit > uint64(MaxHeadersPerRequest) { + return nil, status.Error(codes.InvalidArgument, fmt.Sprintf("pagination limit is larger than the maximum limit of %d", MaxHeadersPerRequest)) + } + var keyHeader *types.BTCHeaderInfo if len(req.Pagination.Key) != 0 { headerHash, err := bbn.NewBTCHeaderHashBytesFromBytes(req.Pagination.Key) @@ -106,7 +113,7 @@ func (k Keeper) MainChain(c context.Context, req *types.QueryMainChainRequest) ( var headers []*types.BTCHeaderInfo var nextKey []byte if req.Pagination.Reverse { - var start, end uint64 + var start, end uint32 baseHeader := k.headersState(ctx).BaseHeader() // The base header is located at the end of the mainchain // which requires starting at the end @@ -118,19 +125,20 @@ func (k Keeper) MainChain(c context.Context, req *types.QueryMainChainRequest) ( } else { start = keyHeader.Height - baseHeader.Height } - end = start + req.Pagination.Limit + // req.Pagination.Limit can be safely converted as `MaxHeadersPerRequest` is a uint32 + end = start + uint32(req.Pagination.Limit) - if end >= uint64(len(mainchain)) { - end = uint64(len(mainchain)) + if int(end) >= len(mainchain) { + end = uint32(len(mainchain)) } // If the header's position on the mainchain is larger than the entire mainchain, then it is not part of the mainchain // Also, if the element at the header's position on the mainchain is not the provided one, then it is not part of the mainchain - if start >= uint64(len(mainchain)) || !mainchain[start].Eq(keyHeader) { + if int(start) >= len(mainchain) || !mainchain[start].Eq(keyHeader) { return nil, status.Error(codes.InvalidArgument, "header specified by key is not a part of the mainchain") } headers = mainchain[start:end] - if end < uint64(len(mainchain)) { + if int(end) < len(mainchain) { nextKey = mainchain[end].Hash.MustMarshal() } } else { @@ -143,11 +151,12 @@ func (k Keeper) MainChain(c context.Context, req *types.QueryMainChainRequest) ( startHeaderDepth := tip.Height - keyHeader.Height // The depth that we want to retrieve up to // -1 because the depth denotes how many headers have been built on top of it - depth := startHeaderDepth + req.Pagination.Limit - 1 + // req.Pagination.Limit can be safely converted as `MaxHeadersPerRequest` is a uint32 + depth := startHeaderDepth + uint32(req.Pagination.Limit) - 1 // Retrieve the mainchain up to the depth mainchain := k.GetMainChainUpTo(ctx, depth) // Check whether the key provided is part of the mainchain - if uint64(len(mainchain)) <= startHeaderDepth || !mainchain[startHeaderDepth].Eq(keyHeader) { + if uint32(len(mainchain)) <= startHeaderDepth || !mainchain[startHeaderDepth].Eq(keyHeader) { return nil, status.Error(codes.InvalidArgument, "header specified by key is not a part of the mainchain") } @@ -205,5 +214,5 @@ func (k Keeper) HeaderDepth(ctx context.Context, req *types.QueryHeaderDepthRequ return nil, err } - return &types.QueryHeaderDepthResponse{Depth: uint64(depth)}, nil + return &types.QueryHeaderDepthResponse{Depth: depth}, nil } diff --git a/x/btclightclient/keeper/grpc_query_test.go b/x/btclightclient/keeper/grpc_query_test.go index 6a6fed783..4e97f58c5 100644 --- a/x/btclightclient/keeper/grpc_query_test.go +++ b/x/btclightclient/keeper/grpc_query_test.go @@ -65,7 +65,7 @@ func FuzzHashesQuery(f *testing.F) { blcKeeper, ctx, 0, - datagen.RandomInt(r, 50)+100, + uint32(datagen.RandomInt(r, 50))+100, ) // Get the headers map @@ -74,17 +74,17 @@ func FuzzHashesQuery(f *testing.F) { // + 1 is necessary to account for the base header totalChainLength := chain.ChainLength() + 1 - chainSize := uint64(totalChainLength) - limit := uint64(r.Int63n(int64(totalChainLength)) + 1) + chainSize := uint32(totalChainLength) + limit := uint32(r.Int31n(int32(totalChainLength))) + 1 // Generate a page request with a limit and a nil key - pagination = constructRequestWithLimit(r, limit) + pagination = constructRequestWithLimit(r, uint64(limit)) // Generate the initial query hashesRequest = types.NewQueryHashesRequest(pagination) // Construct a mapping from the hashes found to a boolean value // Will be used later to evaluate whether all the hashes were returned hashesFound := make(map[string]bool, 0) - for headersRetrieved := uint64(0); headersRetrieved < chainSize; headersRetrieved += limit { + for headersRetrieved := uint32(0); headersRetrieved < chainSize; headersRetrieved += limit { resp, err = blcKeeper.Hashes(ctx, hashesRequest) if err != nil { t.Errorf("Valid request led to an error %s", err) @@ -93,11 +93,11 @@ func FuzzHashesQuery(f *testing.F) { t.Fatalf("Valid request led to a nil response") } // If we are on the last page the elements retrieved should be equal to the remaining ones - if headersRetrieved+limit >= chainSize && uint64(len(resp.Hashes)) != chainSize-headersRetrieved { + if headersRetrieved+uint32(limit) >= chainSize && uint32(len(resp.Hashes)) != chainSize-headersRetrieved { t.Fatalf("On the last page expected %d elements but got %d", chainSize-headersRetrieved, len(resp.Hashes)) } // Otherwise, the elements retrieved should be equal to the limit - if headersRetrieved+limit < chainSize && uint64(len(resp.Hashes)) != limit { + if headersRetrieved+uint32(limit) < chainSize && uint32(len(resp.Hashes)) != limit { t.Fatalf("On an intermediate page expected %d elements but got %d", limit, len(resp.Hashes)) } @@ -110,7 +110,7 @@ func FuzzHashesQuery(f *testing.F) { } // Construct the next page request - pagination = constructRequestWithKeyAndLimit(r, resp.Pagination.NextKey, limit) + pagination = constructRequestWithKeyAndLimit(r, resp.Pagination.NextKey, uint64(limit)) hashesRequest = types.NewQueryHashesRequest(pagination) } @@ -151,7 +151,7 @@ func FuzzContainsQuery(f *testing.F) { blcKeeper, ctx, 0, - datagen.RandomInt(r, 50)+100, + uint32(datagen.RandomInt(r, 50))+100, ) // Test with a non-existent header @@ -232,7 +232,7 @@ func FuzzMainChainQuery(f *testing.F) { blcKeeper, ctx, 0, - datagen.RandomInt(r, 50)+100, + uint32(datagen.RandomInt(r, 50))+100, ) // Check whether the key being set to an element that does not exist leads to an error @@ -261,12 +261,12 @@ func FuzzMainChainQuery(f *testing.F) { // Index into the current element of mainchain that we are iterating mcIdx := 0 // Generate a random limit - mcSize := uint64(len(mainchain)) - limit := uint64(r.Int63n(int64(len(mainchain))) + 1) + mcSize := uint32(len(mainchain)) + limit := uint32(r.Int31n(int32(len(mainchain))) + 1) // 50% of the time, do a reverse request // Generate a page request with a limit and a nil key - pagination = constructRequestWithLimit(r, limit) + pagination = constructRequestWithLimit(r, uint64(limit)) reverse := false if datagen.OneInN(r, 2) { reverse = true @@ -274,7 +274,7 @@ func FuzzMainChainQuery(f *testing.F) { } // Generate the initial query mainchainRequest = types.NewQueryMainChainRequest(pagination) - for headersRetrieved := uint64(0); headersRetrieved < mcSize; headersRetrieved += limit { + for headersRetrieved := uint32(0); headersRetrieved < mcSize; headersRetrieved += limit { resp, err = blcKeeper.MainChain(ctx, mainchainRequest) if err != nil { t.Errorf("Valid request led to an error %s", err) @@ -283,11 +283,11 @@ func FuzzMainChainQuery(f *testing.F) { t.Fatalf("Valid request led to nil response") } // If we are on the last page the elements retrieved should be equal to the remaining ones - if headersRetrieved+limit >= mcSize && uint64(len(resp.Headers)) != mcSize-headersRetrieved { + if headersRetrieved+limit >= mcSize && uint32(len(resp.Headers)) != mcSize-headersRetrieved { t.Fatalf("On the last page expected %d elements but got %d", mcSize-headersRetrieved, len(resp.Headers)) } // Otherwise, the elements retrieved should be equal to the limit - if headersRetrieved+limit < mcSize && uint64(len(resp.Headers)) != limit { + if headersRetrieved+limit < mcSize && uint32(len(resp.Headers)) != limit { t.Fatalf("On an intermediate page expected %d elements but got %d", limit, len(resp.Headers)) } @@ -306,7 +306,7 @@ func FuzzMainChainQuery(f *testing.F) { } // Construct the next page request - pagination = constructRequestWithKeyAndLimit(r, resp.Pagination.NextKey, limit) + pagination = constructRequestWithKeyAndLimit(r, resp.Pagination.NextKey, uint64(limit)) if reverse { pagination.Reverse = true } @@ -345,7 +345,7 @@ func FuzzTipQuery(f *testing.F) { blcKeeper, ctx, 0, - datagen.RandomInt(r, 50)+100, + uint32(datagen.RandomInt(r, 50))+100, ) resp, err = blcKeeper.Tip(ctx, types.NewQueryTipRequest()) @@ -391,7 +391,7 @@ func FuzzBaseHeaderQuery(f *testing.F) { blcKeeper, ctx, 0, - datagen.RandomInt(r, 50)+100, + uint32(datagen.RandomInt(r, 50))+100, ) resp, err = blcKeeper.BaseHeader(ctx, types.NewQueryBaseHeaderRequest()) @@ -411,7 +411,7 @@ func FuzzBaseHeaderQuery(f *testing.F) { func constructRequestWithKeyAndLimit(r *rand.Rand, key []byte, limit uint64) *query.PageRequest { // If limit is 0, set one randomly if limit == 0 { - limit = uint64(r.Int63() + 1) // Use Int63 instead of Uint64 to avoid overflows + limit = uint64(r.Int31n(100) + 1) // Use Int31 instead to avoid overflows } return &query.PageRequest{ Key: key, diff --git a/x/btclightclient/keeper/keeper.go b/x/btclightclient/keeper/keeper.go index f3df98e84..ecc1b3d3f 100644 --- a/x/btclightclient/keeper/keeper.go +++ b/x/btclightclient/keeper/keeper.go @@ -22,6 +22,7 @@ type ( cdc codec.BinaryCodec storeService corestoretypes.KVStoreService hooks types.BTCLightClientHooks + iKeeper types.IncentiveKeeper btcConfig bbn.BtcConfig bl *types.BtcLightClient authority string @@ -34,6 +35,7 @@ func NewKeeper( cdc codec.BinaryCodec, storeService corestoretypes.KVStoreService, btcConfig bbn.BtcConfig, + iKeeper types.IncentiveKeeper, authority string, ) Keeper { bl := types.NewBtcLightClientFromParams(btcConfig.NetParams()) @@ -42,6 +44,7 @@ func NewKeeper( cdc: cdc, storeService: storeService, hooks: nil, + iKeeper: iKeeper, btcConfig: btcConfig, bl: bl, authority: authority, @@ -58,7 +61,7 @@ func (k Keeper) emitTypedEventWithLog(ctx context.Context, evt proto.Message) { sdkCtx := sdk.UnwrapSDKContext(ctx) if err := sdkCtx.EventManager().EmitTypedEvent(evt); err != nil { k.Logger(sdkCtx).Error( - "faied to emit event", + "failed to emit event", "type", evt.String(), "reason", err.Error(), ) @@ -79,7 +82,7 @@ func (k Keeper) insertHandler() func(ctx context.Context, s headersState, result return func(ctx context.Context, s headersState, result *types.InsertResult) error { // if we receive rollback, should return error if result.RollbackInfo != nil { - return fmt.Errorf("rollback should not happend %+v", result.RollbackInfo) + return fmt.Errorf("rollback should not happen %+v", result.RollbackInfo) } for _, header := range result.HeadersToInsert { @@ -185,7 +188,7 @@ func btcHeadersBytesToBlockHeader(headers []bbn.BTCHeaderBytes) []*wire.BlockHea } // BlockHeight returns the height of the provided header -func (k Keeper) BlockHeight(ctx context.Context, headerHash *bbn.BTCHeaderHashBytes) (uint64, error) { +func (k Keeper) BlockHeight(ctx context.Context, headerHash *bbn.BTCHeaderHashBytes) (uint32, error) { if headerHash == nil { return 0, types.ErrEmptyMessage } @@ -199,8 +202,8 @@ func (k Keeper) BlockHeight(ctx context.Context, headerHash *bbn.BTCHeaderHashBy return headerInfo.Height, nil } -// MainChainDepth returns the depth of the header in the main chain, or error if it does not exists -func (k Keeper) MainChainDepth(ctx context.Context, headerHashBytes *bbn.BTCHeaderHashBytes) (uint64, error) { +// MainChainDepth returns the depth of the header in the main chain, or error if it does not exist +func (k Keeper) MainChainDepth(ctx context.Context, headerHashBytes *bbn.BTCHeaderHashBytes) (uint32, error) { if headerHashBytes == nil { return 0, types.ErrEmptyMessage } @@ -238,7 +241,7 @@ func (k Keeper) GetHeaderByHash(ctx context.Context, hash *bbn.BTCHeaderHashByte } // GetHeaderByHeight returns header with given height from main chain, returns nil if such header is not found -func (k Keeper) GetHeaderByHeight(ctx context.Context, height uint64) *types.BTCHeaderInfo { +func (k Keeper) GetHeaderByHeight(ctx context.Context, height uint32) *types.BTCHeaderInfo { header, err := k.headersState(ctx).GetHeaderByHeight(height) if err != nil { @@ -251,7 +254,7 @@ func (k Keeper) GetHeaderByHeight(ctx context.Context, height uint64) *types.BTC // GetMainChainFrom returns the current canonical chain from the given height up to the tip // If the height is higher than the tip, it returns an empty slice // If startHeight is 0, it returns the entire main chain -func (k Keeper) GetMainChainFrom(ctx context.Context, startHeight uint64) []*types.BTCHeaderInfo { +func (k Keeper) GetMainChainFrom(ctx context.Context, startHeight uint32) []*types.BTCHeaderInfo { headers := make([]*types.BTCHeaderInfo, 0) accHeaderFn := func(header *types.BTCHeaderInfo) bool { headers = append(headers, header) @@ -264,7 +267,7 @@ func (k Keeper) GetMainChainFrom(ctx context.Context, startHeight uint64) []*typ // GetMainChainFromWithLimit returns the current canonical chain from the given height up to the tip // If the height is higher than the tip, it returns an empty slice // If startHeight is 0, it returns the entire main chain -func (k Keeper) GetMainChainFromWithLimit(ctx context.Context, startHeight, limit uint64) []*types.BTCHeaderInfo { +func (k Keeper) GetMainChainFromWithLimit(ctx context.Context, startHeight uint32, limit uint32) []*types.BTCHeaderInfo { headers := make([]*types.BTCHeaderInfo, 0, limit) fn := func(header *types.BTCHeaderInfo) bool { if len(headers) >= int(limit) { @@ -279,10 +282,10 @@ func (k Keeper) GetMainChainFromWithLimit(ctx context.Context, startHeight, limi // GetMainChainUpTo returns the current canonical chain as a collection of block headers // starting from the tip and ending on the header that has `depth` distance from it. -func (k Keeper) GetMainChainUpTo(ctx context.Context, depth uint64) []*types.BTCHeaderInfo { +func (k Keeper) GetMainChainUpTo(ctx context.Context, depth uint32) []*types.BTCHeaderInfo { headers := make([]*types.BTCHeaderInfo, 0) - var currentDepth = uint64(0) + var currentDepth = uint32(0) accHeaderFn := func(header *types.BTCHeaderInfo) bool { // header header is at depth 0. if currentDepth > depth { diff --git a/x/btclightclient/keeper/keeper_test.go b/x/btclightclient/keeper/keeper_test.go index 896ebf88a..89aaa3b83 100644 --- a/x/btclightclient/keeper/keeper_test.go +++ b/x/btclightclient/keeper/keeper_test.go @@ -59,7 +59,7 @@ func FuzzKeeperMainChainDepth(f *testing.F) { blcKeeper, ctx, 0, - datagen.RandomInt(r, 50)+10, + uint32(datagen.RandomInt(r, 50))+10, ) randomHeader := chain.GetRandomHeaderInfo(r) depth, err = blcKeeper.MainChainDepth(ctx, randomHeader.Hash) @@ -112,7 +112,7 @@ func FuzzKeeperBlockHeight(f *testing.F) { blcKeeper, ctx, 0, - datagen.RandomInt(r, 50)+10, + uint32(datagen.RandomInt(r, 50))+10, ) header := chain.GetRandomHeaderInfo(r) @@ -137,8 +137,8 @@ func FuzzKeeperInsertValidChainExtension(f *testing.F) { r, blcKeeper, ctx, - datagen.RandomInt(r, 50)+10, - datagen.RandomInt(r, 50)+10, + uint32(datagen.RandomInt(r, 50))+10, + uint32(datagen.RandomInt(r, 50))+10, ) mockHooks := NewMockHooks() @@ -148,7 +148,6 @@ func FuzzKeeperInsertValidChainExtension(f *testing.F) { chainToInsert := datagen.GenRandomValidChainStartingFrom( r, - chain.GetTipInfo().Height, chain.GetTipInfo().Header.ToBlockHeader(), nil, newChainLength, @@ -158,7 +157,7 @@ func FuzzKeeperInsertValidChainExtension(f *testing.F) { ctx = ctx.WithEventManager(sdk.NewEventManager()) oldTip := blcKeeper.HeadersState(ctx).GetTip() extendedChainWork := oldTip.Work.Add(*chainExtensionWork) - extendedChainHeight := uint64(uint32(oldTip.Height) + newChainLength) + extendedChainHeight := oldTip.Height + newChainLength err := blcKeeper.InsertHeadersWithHookAndEvents(ctx, keepertest.NewBTCHeaderBytesList(chainToInsert)) require.NoError(t, err) @@ -219,8 +218,8 @@ func FuzzKeeperInsertValidBetterChain(f *testing.F) { r, blcKeeper, ctx, - datagen.RandomInt(r, 50)+10, - datagen.RandomInt(r, 50)+10, + uint32(datagen.RandomInt(r, 50))+10, + uint32(datagen.RandomInt(r, 50))+10, ) mockHooks := NewMockHooks() @@ -231,7 +230,6 @@ func FuzzKeeperInsertValidBetterChain(f *testing.F) { newChainLength := uint32(chain.ChainLength() + 1) chainToInsert := datagen.GenRandomValidChainStartingFrom( r, - forkHeaderParent.Height, forkHeaderParent.Header.ToBlockHeader(), nil, newChainLength, @@ -240,7 +238,7 @@ func FuzzKeeperInsertValidBetterChain(f *testing.F) { ctx = ctx.WithEventManager(sdk.NewEventManager()) extendedChainWork := forkHeaderParent.Work.Add(*chainExtensionWork) - extendedChainHeight := uint64(uint32(forkHeaderParent.Height) + newChainLength) + extendedChainHeight := forkHeaderParent.Height + newChainLength oldTip := blcKeeper.HeadersState(ctx).GetTip() removedBranch := blcKeeper.GetMainChainFrom(ctx, forkHeaderParent.Height+1) @@ -326,7 +324,7 @@ func FuzzKeeperInsertInvalidChain(f *testing.F) { blcKeeper, ctx, 0, - datagen.RandomInt(r, 50)+10, + uint32(datagen.RandomInt(r, 50))+10, ) currentTip := blcKeeper.GetTipInfo(ctx) require.NotNil(t, currentTip) @@ -350,7 +348,6 @@ func FuzzKeeperInsertInvalidChain(f *testing.F) { // valid chain with at least 5 headers chainToInsert := datagen.GenRandomValidChainStartingFrom( r, - chain.GetTipInfo().Height, chain.GetTipInfo().Header.ToBlockHeader(), nil, newChainLength, @@ -369,7 +366,6 @@ func FuzzKeeperInsertInvalidChain(f *testing.F) { require.NotNil(t, headerBeforeTip) worseChain := datagen.GenRandomValidChainStartingFrom( r, - headerBeforeTip.Height, headerBeforeTip.Header.ToBlockHeader(), nil, 1, @@ -420,7 +416,7 @@ func FuzzKeeperValdateHeaderAtDifficultyAdjustmentBoundaries(f *testing.F) { currentTip := blcKeeper.GetTipInfo(ctx) require.NotNil(t, currentTip) - require.Equal(t, currentTip.Height, uint64(numBlockPerRetarget)-1) + require.Equal(t, currentTip.Height, uint32(numBlockPerRetarget)-1) invalidAdjustedHeader := datagen.GenRandomBtcdValidHeader( r, @@ -439,7 +435,7 @@ func FuzzKeeperValdateHeaderAtDifficultyAdjustmentBoundaries(f *testing.F) { } validAdjustedHeader := datagen.GenRandomBtcdValidHeader( r, - // current tip heigh is 2015 + // current tip height is 2015 currentTip.Header.ToBlockHeader(), nil, &rt, @@ -452,7 +448,7 @@ func FuzzKeeperValdateHeaderAtDifficultyAdjustmentBoundaries(f *testing.F) { newTip := blcKeeper.GetTipInfo(ctx) require.NotNil(t, newTip) // tip should be at adjustment boundary now - require.Equal(t, newTip.Height, uint64(numBlockPerRetarget)) + require.Equal(t, newTip.Height, uint32(numBlockPerRetarget)) require.True(t, newTip.Header.Eq(&validAdjustedHeaderBytes)) require.True(t, types.IsRetargetBlock(newTip, &chaincfg.SimNetParams)) }) diff --git a/x/btclightclient/keeper/msg_server.go b/x/btclightclient/keeper/msg_server.go index b40880e5f..c51af85ab 100644 --- a/x/btclightclient/keeper/msg_server.go +++ b/x/btclightclient/keeper/msg_server.go @@ -48,10 +48,16 @@ func (m msgServer) InsertHeaders(ctx context.Context, msg *types.MsgInsertHeader } err := m.k.InsertHeadersWithHookAndEvents(sdkCtx, msg.Headers) - if err != nil { return nil, err } + + // At this point, the headers have been inserted, and the inserted + // headers extend the current chain or a fork that is longer than + // the current chain. + // Thus, we can safely consider this message as refundable + m.k.iKeeper.IndexRefundableMsg(sdkCtx, msg) + return &types.MsgInsertHeadersResponse{}, nil } diff --git a/x/btclightclient/keeper/msg_server_test.go b/x/btclightclient/keeper/msg_server_test.go index 343b6859a..26eaac2aa 100644 --- a/x/btclightclient/keeper/msg_server_test.go +++ b/x/btclightclient/keeper/msg_server_test.go @@ -43,8 +43,8 @@ func FuzzMsgServerInsertNewTip(f *testing.F) { r, blcKeeper, ctx, - datagen.RandomInt(r, 50)+10, - datagen.RandomInt(r, 50)+10, + uint32(datagen.RandomInt(r, 50))+10, + uint32(datagen.RandomInt(r, 50))+10, ) initTip := chain.GetTipInfo() @@ -60,7 +60,6 @@ func FuzzMsgServerInsertNewTip(f *testing.F) { chainExenstionLength := uint32(r.Int31n(200) + 1) chainExtension := datagen.GenRandomValidChainStartingFrom( r, - initTip.Height, initTip.Header.ToBlockHeader(), nil, chainExenstionLength, @@ -73,7 +72,7 @@ func FuzzMsgServerInsertNewTip(f *testing.F) { require.NoError(t, err) extendedChainWork := initTip.Work.Add(*chainExtensionWork) - extendedChainHeight := uint64(uint32(initTip.Height) + chainExenstionLength) + extendedChainHeight := initTip.Height + chainExenstionLength checkTip( t, @@ -98,13 +97,13 @@ func FuzzMsgServerReorgChain(f *testing.F) { srv, blcKeeper, sdkCtx := setupMsgServer(t) ctx := sdk.UnwrapSDKContext(sdkCtx) - chainLength := datagen.RandomInt(r, 50) + 10 + chainLength := uint32(datagen.RandomInt(r, 50)) + 10 _, chain := datagen.GenRandBtcChainInsertingInKeeper( t, r, blcKeeper, ctx, - datagen.RandomInt(r, 50)+10, + uint32(datagen.RandomInt(r, 50))+10, chainLength, ) initTip := chain.GetTipInfo() @@ -118,17 +117,16 @@ func FuzzMsgServerReorgChain(f *testing.F) { initTip.Header.ToBlockHeader(), ) - reorgDepth := r.Intn(int(chainLength-1)) + 1 + reorgDepth := r.Int31n(int32(chainLength-1)) + 1 - forkHeaderHeight := initTip.Height - uint64(reorgDepth) + forkHeaderHeight := initTip.Height - uint32(reorgDepth) forkHeader := blcKeeper.GetHeaderByHeight(ctx, forkHeaderHeight) require.NotNil(t, forkHeader) // fork chain will always be longer that current c - forkChainLen := reorgDepth + 10 + forkChainLen := uint32(reorgDepth + 10) chainExtension := datagen.GenRandomValidChainStartingFrom( r, - forkHeader.Height, forkHeader.Header.ToBlockHeader(), nil, uint32(forkChainLen), @@ -140,7 +138,7 @@ func FuzzMsgServerReorgChain(f *testing.F) { require.NoError(t, err) extendedChainWork := forkHeader.Work.Add(*chainExtensionWork) - extendedChainHeight := forkHeader.Height + uint64(forkChainLen) + extendedChainHeight := forkHeader.Height + forkChainLen checkTip( t, @@ -194,7 +192,6 @@ func TestAllowUpdatesOnlyFromReportesInTheList(t *testing.T) { chainExtension := datagen.GenRandomValidChainStartingFrom( r, - initTip.Height, initTip.Header.ToBlockHeader(), nil, 10, @@ -210,7 +207,6 @@ func TestAllowUpdatesOnlyFromReportesInTheList(t *testing.T) { newChainExt := datagen.GenRandomValidChainStartingFrom( r, - newTip.Height, newTip.Header.ToBlockHeader(), nil, 10, diff --git a/x/btclightclient/keeper/state.go b/x/btclightclient/keeper/state.go index 55ddb4e71..55986659d 100644 --- a/x/btclightclient/keeper/state.go +++ b/x/btclightclient/keeper/state.go @@ -40,7 +40,7 @@ func (s headersState) insertHeader(h *types.BTCHeaderInfo) { // save concrete object s.headers.Set(headersKey, s.cdc.MustMarshal(h)) - s.hashToHeight.Set(heightKey, sdk.Uint64ToBigEndian(h.Height)) + s.hashToHeight.Set(heightKey, sdk.Uint64ToBigEndian(uint64(h.Height))) } func (s headersState) deleteHeader(h *types.BTCHeaderInfo) { @@ -53,7 +53,7 @@ func (s headersState) deleteHeader(h *types.BTCHeaderInfo) { s.hashToHeight.Delete(heightKey) } -func (s headersState) rollBackHeadersUpTo(height uint64) { +func (s headersState) rollBackHeadersUpTo(height uint32) { headersToDelete := make([]*types.BTCHeaderInfo, 0) handleInfoFn := func(header *types.BTCHeaderInfo) bool { @@ -80,7 +80,7 @@ func (s headersState) rollBackHeadersUpTo(height uint64) { } // GetHeaderByHeight Retrieve a header by its height and hash -func (s headersState) GetHeaderByHeight(height uint64) (*types.BTCHeaderInfo, error) { +func (s headersState) GetHeaderByHeight(height uint32) (*types.BTCHeaderInfo, error) { headersKey := types.HeadersObjectKey(height) // Retrieve the raw bytes @@ -165,7 +165,7 @@ func (s headersState) IterateReverseHeaders(fn func(*types.BTCHeaderInfo) bool) // - if startPoint is lower that the lowest height, it will start from the lowest height // - if startPoint is higher than the highest height, it will not iterate at all i.e provided // callback will not be called -func (s headersState) IterateForwardHeaders(startPoint uint64, fn func(*types.BTCHeaderInfo) bool) { +func (s headersState) IterateForwardHeaders(startPoint uint32, fn func(*types.BTCHeaderInfo) bool) { // Iterate it in increasing order to get lowest heights first var startKey []byte = nil if startPoint != 0 { diff --git a/x/btclightclient/keeper/state_test.go b/x/btclightclient/keeper/state_test.go index 10d5e34e8..018e194e9 100644 --- a/x/btclightclient/keeper/state_test.go +++ b/x/btclightclient/keeper/state_test.go @@ -22,7 +22,7 @@ func FuzzHeadersStateCreateHeader(f *testing.F) { Data generation: - Create four headers: 1. The Base header. This will test whether the tip is set. - 2. Create random chain of of headers, and insert them into the state + 2. Create random chain of headers, and insert them into the state 3. All operations should be consistent with each other. */ datagen.AddRandomSeedsToFuzzer(f, 10) @@ -57,9 +57,9 @@ func FuzzHeadersStateCreateHeader(f *testing.F) { require.Error(t, err) // 10 to 60 headers - chainLength := datagen.RandomInt(r, 50) + 10 + chainLength := uint32(datagen.RandomInt(r, 50) + 10) // height from 10 to 60 - initchainHeight := datagen.RandomInt(r, 50) + 10 + initchainHeight := uint32(datagen.RandomInt(r, 50) + 10) // populate the state with random chain _, chain := datagen.GenRandBtcChainInsertingInKeeper( @@ -86,8 +86,8 @@ func FuzzHeadersStateCreateHeader(f *testing.F) { numBackward++ return false }) - require.Equal(t, chainLength+1, uint64(numForward)) - require.Equal(t, chainLength+1, uint64(numBackward)) + require.Equal(t, chainLength+1, uint32(numForward)) + require.Equal(t, chainLength+1, uint32(numBackward)) chainInfos := chain.GetChainInfo() diff --git a/x/btclightclient/keeper/utils_test.go b/x/btclightclient/keeper/utils_test.go index cbf1a3421..7c4504e15 100644 --- a/x/btclightclient/keeper/utils_test.go +++ b/x/btclightclient/keeper/utils_test.go @@ -56,7 +56,7 @@ func checkTip( ctx context.Context, blcKeeper *keeper.Keeper, expectedWork sdkmath.Uint, - expectedHeight uint64, + expectedHeight uint32, expectedTipHeader *wire.BlockHeader) { currentTip := blcKeeper.GetTipInfo(ctx) diff --git a/x/btclightclient/module.go b/x/btclightclient/module.go index 74957909b..06e6341e0 100644 --- a/x/btclightclient/module.go +++ b/x/btclightclient/module.go @@ -80,7 +80,9 @@ func (AppModuleBasic) RegisterRESTRoutes(clientCtx client.Context, rtr *mux.Rout // RegisterGRPCGatewayRoutes registers the gRPC Gateway routes for the module. func (AppModuleBasic) RegisterGRPCGatewayRoutes(clientCtx client.Context, mux *runtime.ServeMux) { - types.RegisterQueryHandlerClient(context.Background(), mux, types.NewQueryClient(clientCtx)) //nolint:errcheck // generally we don't handle errors here + if err := types.RegisterQueryHandlerClient(context.Background(), mux, types.NewQueryClient(clientCtx)); err != nil { + panic(err) + } } // GetTxCmd returns the capability module's root tx command. diff --git a/x/btclightclient/types/btc_header_info.go b/x/btclightclient/types/btc_header_info.go index 2cfdb00f6..866e08e97 100644 --- a/x/btclightclient/types/btc_header_info.go +++ b/x/btclightclient/types/btc_header_info.go @@ -8,7 +8,7 @@ import ( bbn "github.com/babylonlabs-io/babylon/types" ) -func NewBTCHeaderInfo(header *bbn.BTCHeaderBytes, headerHash *bbn.BTCHeaderHashBytes, height uint64, work *sdkmath.Uint) *BTCHeaderInfo { +func NewBTCHeaderInfo(header *bbn.BTCHeaderBytes, headerHash *bbn.BTCHeaderHashBytes, height uint32, work *sdkmath.Uint) *BTCHeaderInfo { return &BTCHeaderInfo{ Header: header, Hash: headerHash, @@ -55,7 +55,7 @@ func (m *BTCHeaderInfo) Validate() error { return nil } -func NewBTCHeaderInfoResponse(header *bbn.BTCHeaderBytes, headerHash *bbn.BTCHeaderHashBytes, height uint64, work *sdkmath.Uint) *BTCHeaderInfoResponse { +func NewBTCHeaderInfoResponse(header *bbn.BTCHeaderBytes, headerHash *bbn.BTCHeaderHashBytes, height uint32, work *sdkmath.Uint) *BTCHeaderInfoResponse { return &BTCHeaderInfoResponse{ HeaderHex: header.MarshalHex(), HashHex: headerHash.MarshalHex(), diff --git a/x/btclightclient/types/btc_light_client.go b/x/btclightclient/types/btc_light_client.go index 69440383f..25ad59f70 100644 --- a/x/btclightclient/types/btc_light_client.go +++ b/x/btclightclient/types/btc_light_client.go @@ -14,7 +14,7 @@ import ( type BtcChainReadStore interface { GetHeaderByHash(hash *bbn.BTCHeaderHashBytes) (*BTCHeaderInfo, error) - GetHeaderByHeight(height uint64) (*BTCHeaderInfo, error) + GetHeaderByHeight(height uint32) (*BTCHeaderInfo, error) GetTip() *BTCHeaderInfo } @@ -82,13 +82,13 @@ func (l *lightChainCtx) FindPreviousCheckpoint() (blockchain.HeaderCtx, error) { type localHeaderInfo struct { header *wire.BlockHeader - height uint64 + height uint32 totalWork sdkmath.Uint } func newLocalHeaderInfo( header *wire.BlockHeader, - height uint64, + height uint32, totalWork sdkmath.Uint) *localHeaderInfo { return &localHeaderInfo{ @@ -132,7 +132,7 @@ func toBTCHeaderInfos(infos []*localHeaderInfo) []*BTCHeaderInfo { // based on neutrio light client // https://github.com/lightninglabs/neutrino/blob/master/blockmanager.go#L2944 type lightHeaderCtx struct { - height uint64 + height uint32 bits uint32 timestamp int64 store *storeWithExtensionChain @@ -140,7 +140,7 @@ type lightHeaderCtx struct { var _ blockchain.HeaderCtx = (*lightHeaderCtx)(nil) -func newLightHeaderCtx(height uint64, header *wire.BlockHeader, +func newLightHeaderCtx(height uint32, header *wire.BlockHeader, store *storeWithExtensionChain) *lightHeaderCtx { return &lightHeaderCtx{ @@ -184,16 +184,16 @@ func (l *lightHeaderCtx) RelativeAncestorCtx( return nil } - ancU64 := uint64(ancestorHeight) + ancU32 := uint32(ancestorHeight) - ancestor := l.store.getHeaderAtHeight(ancU64) + ancestor := l.store.getHeaderAtHeight(ancU32) if ancestor == nil { return nil } return newLightHeaderCtx( - ancU64, ancestor.header, l.store, + ancU32, ancestor.header, l.store, ) } @@ -285,7 +285,7 @@ func (s *storeWithExtensionChain) addHeader(header *localHeaderInfo) { s.headers = append(s.headers, header) } -func (s *storeWithExtensionChain) getHeaderAtHeight(height uint64) *localHeaderInfo { +func (s *storeWithExtensionChain) getHeaderAtHeight(height uint32) *localHeaderInfo { if len(s.headers) == 0 || height < s.headers[0].height { h, err := s.store.GetHeaderByHeight(height) @@ -397,7 +397,7 @@ func (l *BtcLightClient) InsertHeaders(readStore BtcChainReadStore, headers []*w return &InsertResult{ HeadersToInsert: toBTCHeaderInfos(store.headers), RollbackInfo: &RollbackInfo{ - // we need to rollback to fork parent + // we need to roll back to fork parent HeaderToRollbackTo: forkParent, }, }, nil @@ -405,7 +405,7 @@ func (l *BtcLightClient) InsertHeaders(readStore BtcChainReadStore, headers []*w } // checkHeader checks if the header is valid and can be added to the store. -// One criticial condition is that to properly validate difficulty adjustments +// One critical condition is that to properly validate difficulty adjustments // we should have at least one header which is at difficulty adjustment boundary // in store. func (l *BtcLightClient) checkHeader( diff --git a/x/btclightclient/types/btclightclient.pb.go b/x/btclightclient/types/btclightclient.pb.go index 5384959e7..d3025f25b 100644 --- a/x/btclightclient/types/btclightclient.pb.go +++ b/x/btclightclient/types/btclightclient.pb.go @@ -36,7 +36,7 @@ const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package type BTCHeaderInfo struct { Header *github_com_babylonlabs_io_babylon_types.BTCHeaderBytes `protobuf:"bytes,1,opt,name=header,proto3,customtype=github.com/babylonlabs-io/babylon/types.BTCHeaderBytes" json:"header,omitempty"` Hash *github_com_babylonlabs_io_babylon_types.BTCHeaderHashBytes `protobuf:"bytes,2,opt,name=hash,proto3,customtype=github.com/babylonlabs-io/babylon/types.BTCHeaderHashBytes" json:"hash,omitempty"` - Height uint64 `protobuf:"varint,3,opt,name=height,proto3" json:"height,omitempty"` + Height uint32 `protobuf:"varint,3,opt,name=height,proto3" json:"height,omitempty"` Work *cosmossdk_io_math.Uint `protobuf:"bytes,4,opt,name=work,proto3,customtype=cosmossdk.io/math.Uint" json:"work,omitempty"` } @@ -73,7 +73,7 @@ func (m *BTCHeaderInfo) XXX_DiscardUnknown() { var xxx_messageInfo_BTCHeaderInfo proto.InternalMessageInfo -func (m *BTCHeaderInfo) GetHeight() uint64 { +func (m *BTCHeaderInfo) GetHeight() uint32 { if m != nil { return m.Height } @@ -101,13 +101,13 @@ var fileDescriptor_84bf438d909b681d = []byte{ 0x6a, 0xb1, 0x1e, 0xdc, 0x28, 0xa7, 0xca, 0x92, 0xd4, 0xe2, 0x20, 0xa8, 0x49, 0x42, 0x41, 0x5c, 0x2c, 0x19, 0x89, 0xc5, 0x19, 0x12, 0x4c, 0x60, 0x13, 0xed, 0x6e, 0xdd, 0x93, 0xb7, 0x22, 0xd9, 0x44, 0x8f, 0xc4, 0xe2, 0x0c, 0x88, 0xa9, 0x60, 0xb3, 0x84, 0xc4, 0x40, 0xee, 0x04, 0x79, 0x51, - 0x82, 0x59, 0x81, 0x51, 0x83, 0x25, 0x08, 0xca, 0x13, 0xd2, 0xe3, 0x62, 0x29, 0xcf, 0x2f, 0xca, + 0x82, 0x59, 0x81, 0x51, 0x83, 0x37, 0x08, 0xca, 0x13, 0xd2, 0xe3, 0x62, 0x29, 0xcf, 0x2f, 0xca, 0x96, 0x60, 0x01, 0xdb, 0x25, 0x75, 0xeb, 0x9e, 0xbc, 0x58, 0x72, 0x7e, 0x71, 0x6e, 0x7e, 0x71, 0x71, 0x4a, 0xb6, 0x5e, 0x66, 0xbe, 0x7e, 0x6e, 0x62, 0x49, 0x86, 0x5e, 0x68, 0x66, 0x5e, 0x49, 0x10, 0x58, 0x9d, 0x53, 0xd0, 0x89, 0x47, 0x72, 0x8c, 0x17, 0x1e, 0xc9, 0x31, 0x3e, 0x78, 0x24, 0xc7, 0x38, 0xe1, 0xb1, 0x1c, 0xc3, 0x85, 0xc7, 0x72, 0x0c, 0x37, 0x1e, 0xcb, 0x31, 0x44, 0x59, 0x10, 0x76, 0x63, 0x05, 0x7a, 0xc4, 0x80, 0x1d, 0x9d, 0xc4, 0x06, 0x0e, 0x5c, 0x63, 0x40, 0x00, - 0x00, 0x00, 0xff, 0xff, 0x93, 0x3f, 0xdd, 0x6c, 0xbf, 0x01, 0x00, 0x00, + 0x00, 0x00, 0xff, 0xff, 0x5d, 0xd6, 0x30, 0xf9, 0xbf, 0x01, 0x00, 0x00, } func (m *BTCHeaderInfo) Marshal() (dAtA []byte, err error) { @@ -328,7 +328,7 @@ func (m *BTCHeaderInfo) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - m.Height |= uint64(b&0x7F) << shift + m.Height |= uint32(b&0x7F) << shift if b < 0x80 { break } diff --git a/x/btclightclient/types/expected_keepers.go b/x/btclightclient/types/expected_keepers.go index 387b50c76..b3f5f9146 100644 --- a/x/btclightclient/types/expected_keepers.go +++ b/x/btclightclient/types/expected_keepers.go @@ -2,6 +2,8 @@ package types import ( "context" + + sdk "github.com/cosmos/cosmos-sdk/types" ) type BTCLightClientHooks interface { @@ -9,3 +11,7 @@ type BTCLightClientHooks interface { AfterBTCRollForward(ctx context.Context, headerInfo *BTCHeaderInfo) // Must be called after the chain is rolled forward AfterBTCHeaderInserted(ctx context.Context, headerInfo *BTCHeaderInfo) // Must be called after a header is inserted } + +type IncentiveKeeper interface { + IndexRefundableMsg(ctx context.Context, msg sdk.Msg) +} diff --git a/x/btclightclient/types/keys.go b/x/btclightclient/types/keys.go index 4761c2be8..1927fbfb8 100644 --- a/x/btclightclient/types/keys.go +++ b/x/btclightclient/types/keys.go @@ -28,8 +28,8 @@ var ( ParamsKey = []byte{0x03} // key for params ) -func HeadersObjectKey(height uint64) []byte { - return sdk.Uint64ToBigEndian(height) +func HeadersObjectKey(height uint32) []byte { + return sdk.Uint64ToBigEndian(uint64(height)) } func HeadersObjectHeightKey(hash *bbn.BTCHeaderHashBytes) []byte { diff --git a/x/btclightclient/types/keys_test.go b/x/btclightclient/types/keys_test.go index e7095b95c..82acf1fba 100644 --- a/x/btclightclient/types/keys_test.go +++ b/x/btclightclient/types/keys_test.go @@ -16,9 +16,9 @@ func FuzzHeadersObjectKey(f *testing.F) { f.Fuzz(func(t *testing.T, seed int64) { r := rand.New(rand.NewSource(seed)) - height := r.Uint64() + height := r.Uint32() // get chainhash and height - heightBytes := sdk.Uint64ToBigEndian(height) + heightBytes := sdk.Uint64ToBigEndian(uint64(height)) // construct the expected key var expectedKey []byte expectedKey = append(expectedKey, heightBytes...) diff --git a/x/btclightclient/types/msgs.go b/x/btclightclient/types/msgs.go index 7b6bfbdd8..e91f0bb90 100644 --- a/x/btclightclient/types/msgs.go +++ b/x/btclightclient/types/msgs.go @@ -40,7 +40,7 @@ func NewMsgInsertHeaders(signer sdk.AccAddress, headersHex string) (*MsgInsertHe } func (msg *MsgInsertHeaders) ValidateHeaders(powLimit *big.Int) error { - // TOOD: Limit number of headers in message? + // TODO: Limit number of headers in message? for _, header := range msg.Headers { err := bbn.ValidateBTCHeader(header.ToBlockHeader(), powLimit) if err != nil { diff --git a/x/btclightclient/types/query.go b/x/btclightclient/types/query.go index a0deed675..52faf4c94 100644 --- a/x/btclightclient/types/query.go +++ b/x/btclightclient/types/query.go @@ -10,7 +10,7 @@ func (b *BTCHeaderInfo) ToResponse() *BTCHeaderInfoResponse { } } -// ParseBTCHeadersToResponse parses the infos into resposes. +// ParseBTCHeadersToResponse parses the infos into responses. func ParseBTCHeadersToResponse(infos []*BTCHeaderInfo) (resp []*BTCHeaderInfoResponse) { resp = make([]*BTCHeaderInfoResponse, len(infos)) for i, info := range infos { diff --git a/x/btclightclient/types/query.pb.go b/x/btclightclient/types/query.pb.go index b8eb8bb97..2b47da48d 100644 --- a/x/btclightclient/types/query.pb.go +++ b/x/btclightclient/types/query.pb.go @@ -698,7 +698,7 @@ func (m *QueryHeaderDepthRequest) GetHash() string { // QueryMainChainDepthResponse is the response type for the Query/MainChainDepth RPC // it contains depth of the block in main chain type QueryHeaderDepthResponse struct { - Depth uint64 `protobuf:"varint,1,opt,name=depth,proto3" json:"depth,omitempty"` + Depth uint32 `protobuf:"varint,1,opt,name=depth,proto3" json:"depth,omitempty"` } func (m *QueryHeaderDepthResponse) Reset() { *m = QueryHeaderDepthResponse{} } @@ -734,7 +734,7 @@ func (m *QueryHeaderDepthResponse) XXX_DiscardUnknown() { var xxx_messageInfo_QueryHeaderDepthResponse proto.InternalMessageInfo -func (m *QueryHeaderDepthResponse) GetDepth() uint64 { +func (m *QueryHeaderDepthResponse) GetDepth() uint32 { if m != nil { return m.Depth } @@ -752,7 +752,7 @@ func (m *QueryHeaderDepthResponse) GetDepth() uint64 { type BTCHeaderInfoResponse struct { HeaderHex string `protobuf:"bytes,1,opt,name=header_hex,json=headerHex,proto3" json:"header_hex,omitempty"` HashHex string `protobuf:"bytes,2,opt,name=hash_hex,json=hashHex,proto3" json:"hash_hex,omitempty"` - Height uint64 `protobuf:"varint,3,opt,name=height,proto3" json:"height,omitempty"` + Height uint32 `protobuf:"varint,3,opt,name=height,proto3" json:"height,omitempty"` // Work is the sdkmath.Uint as string. Work cosmossdk_io_math.Uint `protobuf:"bytes,4,opt,name=work,proto3,customtype=cosmossdk.io/math.Uint" json:"work"` } @@ -804,7 +804,7 @@ func (m *BTCHeaderInfoResponse) GetHashHex() string { return "" } -func (m *BTCHeaderInfoResponse) GetHeight() uint64 { +func (m *BTCHeaderInfoResponse) GetHeight() uint32 { if m != nil { return m.Height } @@ -838,63 +838,63 @@ func init() { var fileDescriptor_3961270631e52721 = []byte{ // 924 bytes of a gzipped FileDescriptorProto 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x96, 0xcf, 0x6f, 0x1b, 0x45, - 0x14, 0xc7, 0x33, 0x89, 0xeb, 0x26, 0x2f, 0x20, 0x60, 0x48, 0x83, 0xb3, 0x02, 0x27, 0xdd, 0x92, - 0x1f, 0x4d, 0xf1, 0x4e, 0x9c, 0x80, 0x54, 0x71, 0x00, 0xe1, 0x20, 0x08, 0x48, 0x48, 0x65, 0x15, - 0x7a, 0x40, 0x95, 0xa2, 0x59, 0x67, 0xd8, 0x5d, 0x1a, 0xef, 0x6c, 0xbd, 0x9b, 0x90, 0x08, 0x71, - 0xe1, 0xc0, 0x19, 0xc1, 0x8d, 0x03, 0x07, 0x2e, 0x5c, 0x80, 0x13, 0xe2, 0x6f, 0xe8, 0xb1, 0x82, - 0x0b, 0xea, 0x21, 0x42, 0x09, 0x7f, 0x04, 0x47, 0x34, 0x33, 0x6f, 0x6d, 0xaf, 0x9d, 0x7a, 0x6d, - 0x35, 0x97, 0x28, 0x33, 0xf3, 0xde, 0xfb, 0x7e, 0xe6, 0xf9, 0xed, 0x77, 0x17, 0x96, 0x3d, 0xee, - 0x9d, 0x1c, 0xc8, 0x88, 0x79, 0x69, 0xf3, 0x20, 0xf4, 0x03, 0xf5, 0x57, 0x44, 0x29, 0x3b, 0xaa, - 0xb3, 0x07, 0x87, 0xa2, 0x7d, 0xe2, 0xc4, 0x6d, 0x99, 0x4a, 0xba, 0x80, 0x61, 0x4e, 0x3e, 0xcc, - 0x39, 0xaa, 0x5b, 0x73, 0xbe, 0xf4, 0xa5, 0x8e, 0x62, 0xea, 0x3f, 0x93, 0x60, 0x2d, 0x34, 0x65, - 0xd2, 0x92, 0xc9, 0x9e, 0x39, 0x30, 0x0b, 0x3c, 0x7a, 0xd9, 0x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3a, 0xe9, 0xaf, 0xae, 0x3f, 0x8c, 0xbc, 0x92, 0xfe, 0xee, 0xdd, 0xfe, 0x2f, + 0x00, 0x00, 0xff, 0xff, 0xc6, 0x41, 0x02, 0xa9, 0xde, 0x0b, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -3330,7 +3330,7 @@ func (m *QueryHeaderDepthResponse) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - m.Depth |= uint64(b&0x7F) << shift + m.Depth |= uint32(b&0x7F) << shift if b < 0x80 { break } @@ -3463,7 +3463,7 @@ func (m *BTCHeaderInfoResponse) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - m.Height |= uint64(b&0x7F) << shift + m.Height |= uint32(b&0x7F) << shift if b < 0x80 { break } diff --git a/x/btclightclient/types/utils.go b/x/btclightclient/types/utils.go index e5181ea4a..2de6de5d2 100644 --- a/x/btclightclient/types/utils.go +++ b/x/btclightclient/types/utils.go @@ -13,6 +13,9 @@ func BlocksPerRetarget(params *chaincfg.Params) int32 { } func IsRetargetBlock(info *BTCHeaderInfo, params *chaincfg.Params) bool { - hI32 := int32(info.Height) - return hI32%BlocksPerRetarget(params) == 0 + blocksPerRetarget := BlocksPerRetarget(params) + if blocksPerRetarget < 0 { + panic("Invalid blocks per retarget value") + } + return info.Height%uint32(blocksPerRetarget) == 0 } diff --git a/x/btcstaking/README.md b/x/btcstaking/README.md index a54c93953..b6bff33ae 100644 --- a/x/btcstaking/README.md +++ b/x/btcstaking/README.md @@ -19,8 +19,6 @@ providers and BTC delegations under them. This includes: - [Finality providers](#finality-providers) - [BTC delegations](#btc-delegations) - [BTC delegation index](#btc-delegation-index) - - [Voting power table](#voting-power-table) - - [Params](#params) - [Messages](#messages) - [MsgCreateFinalityProvider](#msgcreatefinalityprovider) - [MsgEditFinalityProvider](#msgeditfinalityprovider) @@ -31,6 +29,8 @@ providers and BTC delegations under them. This includes: - [MsgSelectiveSlashingEvidence](#msgselectiveslashingevidence) - [BeginBlocker](#beginblocker) - [Events](#events) + - [Finality provider events](#finality-provider-events) + - [Delegation events](#delegation-events) - [Queries](#queries) ## Concepts @@ -90,11 +90,11 @@ delegation unbonded immediately upon such a signature. ## States -The BTC Staking module maintains the following KV stores. +The BTC Staking module uses the following prefixed namespaces within its KV store to organize different types of data ### Parameters -The [parameter storage](./keeper/params.go) maintains the BTC Staking module's +The [parameter management](./keeper/params.go) maintains the BTC Staking module's parameters. The BTC Staking module's parameters are represented as a `Params` [object](../../proto/babylon/btcstaking/v1/params.proto) defined as follows: @@ -102,52 +102,58 @@ parameters. The BTC Staking module's parameters are represented as a `Params` // Params defines the parameters for the module. message Params { option (gogoproto.goproto_stringer) = false; - + // PARAMETERS COVERING STAKING // covenant_pks is the list of public keys held by the covenant committee // each PK follows encoding in BIP-340 spec on Bitcoin repeated bytes covenant_pks = 1 [ (gogoproto.customtype) = "github.com/babylonlabs-io/babylon/types.BIP340PubKey" ]; // covenant_quorum is the minimum number of signatures needed for the covenant // multisignature uint32 covenant_quorum = 2; - // slashing address is the address that the slashed BTC goes to - // the address is in string on Bitcoin - string slashing_address = 3; + // min_staking_value_sat is the minimum of satoshis locked in staking output + int64 min_staking_value_sat = 3; + // max_staking_value_sat is the maximum of satoshis locked in staking output + int64 max_staking_value_sat = 4; + // min_staking_time is the minimum lock time specified in staking output script + uint32 min_staking_time_blocks = 5; + // max_staking_time_blocks is the maximum lock time time specified in staking output script + uint32 max_staking_time_blocks = 6; + // PARAMETERS COVERING SLASHING + // slashing_pk_script is the pk_script expected in slashing output ie. the first + // output of slashing transaction + bytes slashing_pk_script = 7; // min_slashing_tx_fee_sat is the minimum amount of tx fee (quantified - // in Satoshi) needed for the pre-signed slashing tx - int64 min_slashing_tx_fee_sat = 4; - // min_commission_rate is the chain-wide minimum commission rate that a finality provider can charge their delegators - string min_commission_rate = 5 [ - (gogoproto.customtype) = "cosmossdk.io/math.LegacyDec", - (gogoproto.nullable) = false - ]; + // in Satoshi) needed for the pre-signed slashing tx. It covers both: + // staking slashing transaction and unbonding slashing transaction + int64 min_slashing_tx_fee_sat = 8; // slashing_rate determines the portion of the staked amount to be slashed, - // expressed as a decimal (e.g., 0.5 for 50%). - string slashing_rate = 6 [ + // expressed as a decimal (e.g., 0.5 for 50%). Maximal precion is 2 decimal + // places + string slashing_rate = 9 [ (cosmos_proto.scalar) = "cosmos.Dec", (gogoproto.customtype) = "cosmossdk.io/math.LegacyDec", (gogoproto.nullable) = false ]; - // max_active_finality_providers is the maximum number of active finality providers in the BTC staking protocol - uint32 max_active_finality_providers = 7; + // PARAMETERS COVERING UNBONDING // min_unbonding_time is the minimum time for unbonding transaction timelock in BTC blocks - uint32 min_unbonding_time = 8; - - // min_unbonding_rate is the minimum amount of BTC that are required in unbonding - // output, expressed as a fraction of staking output - // example: if min_unbonding_rate=0.9, then the unbonding output value - // must be at least 90% of staking output, for staking request to be considered - // valid - string min_unbonding_rate = 9 [ - (cosmos_proto.scalar) = "cosmos.Dec", + uint32 min_unbonding_time_blocks = 10; + // unbonding_fee exact fee required for unbonding transaction + int64 unbonding_fee_sat = 11; + // PARAMETERS COVERING FINALITY PROVIDERS + // min_commission_rate is the chain-wide minimum commission rate that a finality provider + // can charge their delegators expressed as a decimal (e.g., 0.5 for 50%). Maximal precion + // is 2 decimal places + string min_commission_rate = 12 [ (gogoproto.customtype) = "cosmossdk.io/math.LegacyDec", (gogoproto.nullable) = false ]; + // base gas fee for delegation creation + uint64 delegation_creation_base_gas_fee = 13; } ``` ### Finality providers -The [finality provider storage](./keeper/finality_providers.go) maintains all +The [finality provider management](./keeper/finality_providers.go) maintains all finality providers. The key is the finality provider's Bitcoin Secp256k1 public key in [BIP-340](https://github.com/bitcoin/bips/blob/master/bip-0340.mediawiki) format, and the value is a `FinalityProvider` @@ -157,35 +163,37 @@ finality provider. ```protobuf // FinalityProvider defines a finality provider message FinalityProvider { - // addr is the bech32 address identifier of the finality provider. - string addr = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"]; - // description defines the description terms for the finality provider. - cosmos.staking.v1beta1.Description description = 2; - // commission defines the commission rate of the finality provider. - string commission = 3 [ - (cosmos_proto.scalar) = "cosmos.Dec", - (gogoproto.customtype) = "cosmossdk.io/math.LegacyDec" - ]; - // btc_pk is the Bitcoin secp256k1 PK of this finality provider - // the PK follows encoding in BIP-340 spec - bytes btc_pk = 4 [ (gogoproto.customtype) = "github.com/babylonlabs-io/babylon/types.BIP340PubKey" ]; - // pop is the proof of possession of the btc_pk, where the BTC - // private key signs the bech32 bbn addr of the finality provider. - ProofOfPossessionBTC pop = 5; - // slashed_babylon_height indicates the Babylon height when - // the finality provider is slashed. - // if it's 0 then the finality provider is not slashed - uint64 slashed_babylon_height = 6; - // slashed_btc_height indicates the BTC height when - // the finality provider is slashed. - // if it's 0 then the finality provider is not slashed - uint64 slashed_btc_height = 7; + // addr is the bech32 address identifier of the finality provider. + string addr = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"]; + // description defines the description terms for the finality provider. + cosmos.staking.v1beta1.Description description = 2; + // commission defines the commission rate of the finality provider. + string commission = 3 [ + (cosmos_proto.scalar) = "cosmos.Dec", + (gogoproto.customtype) = "cosmossdk.io/math.LegacyDec" + ]; + // btc_pk is the Bitcoin secp256k1 PK of this finality provider + // the PK follows encoding in BIP-340 spec + bytes btc_pk = 4 [ (gogoproto.customtype) = "github.com/babylonlabs-io/babylon/types.BIP340PubKey" ]; + // pop is the proof of possession of the btc_pk, where the BTC + // private key signs the bech32 bbn addr of the finality provider. + ProofOfPossessionBTC pop = 5; + // slashed_babylon_height indicates the Babylon height when + // the finality provider is slashed. + // if it's 0 then the finality provider is not slashed + uint64 slashed_babylon_height = 6; + // slashed_btc_height indicates the BTC height when + // the finality provider is slashed. + // if it's 0 then the finality provider is not slashed + uint32 slashed_btc_height = 7; + // jailed defines whether the finality provider is jailed + bool jailed = 8; } ``` ### BTC delegations -The [BTC delegation storage](./keeper/btc_delegations.go) maintains all BTC +The [BTC delegation management](./keeper/btc_delegations.go) maintains all BTC delegations. The key is the staking transaction hash corresponding to the BTC delegation, and the value is a `BTCDelegation` object. The `BTCDelegation` [structure](../../proto/babylon/btcstaking/v1/btcstaking.proto) includes @@ -197,86 +205,98 @@ submit a staking transaction to Bitcoin. ```protobuf // BTCDelegation defines a BTC delegation message BTCDelegation { - // staker_addr is the address to receive rewards from BTC delegation. - string staker_addr = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"]; - // btc_pk is the Bitcoin secp256k1 PK of this BTC delegation - // the PK follows encoding in BIP-340 spec - bytes btc_pk = 2 [ (gogoproto.customtype) = "github.com/babylonlabs-io/babylon/types.BIP340PubKey" ]; - // pop is the proof of possession of babylon_pk and btc_pk - ProofOfPossessionBTC pop = 3; - // fp_btc_pk_list is the list of BIP-340 PKs of the finality providers that - // this BTC delegation delegates to - // If there is more than 1 PKs, then this means the delegation is restaked - // to multiple finality providers - repeated bytes fp_btc_pk_list = 4 [ (gogoproto.customtype) = "github.com/babylonlabs-io/babylon/types.BIP340PubKey" ]; - // start_height is the start BTC height of the BTC delegation - // it is the start BTC height of the timelock - uint64 start_height = 5; - // end_height is the end height of the BTC delegation - // it is the end BTC height of the timelock - w - uint64 end_height = 6; - // total_sat is the total amount of BTC stakes in this delegation - // quantified in satoshi - uint64 total_sat = 7; - // staking_tx is the staking tx - bytes staking_tx = 8; - // staking_output_idx is the index of the staking output in the staking tx - uint32 staking_output_idx = 9; - // slashing_tx is the slashing tx - // It is partially signed by SK corresponding to btc_pk, but not signed by - // finality provider or covenant yet. - bytes slashing_tx = 10 [ (gogoproto.customtype) = "BTCSlashingTx" ]; - // delegator_sig is the signature on the slashing tx - // by the delegator (i.e., SK corresponding to btc_pk). - // It will be a part of the witness for the staking tx output. - bytes delegator_sig = 11 [ (gogoproto.customtype) = "github.com/babylonlabs-io/babylon/types.BIP340Signature" ]; - // covenant_sigs is a list of adaptor signatures on the slashing tx - // by each covenant member - // It will be a part of the witness for the staking tx output. - repeated CovenantAdaptorSignatures covenant_sigs = 12; - // unbonding_time describes how long the funds will be locked either in unbonding output - // or slashing change output - uint32 unbonding_time = 13; - // btc_undelegation is the information about the early unbonding path of the BTC delegation - BTCUndelegation btc_undelegation = 14; - // version of the params used to validate the delegation - uint32 params_version = 15; + // staker_addr is the address to receive rewards from BTC delegation. + string staker_addr = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"]; + // btc_pk is the Bitcoin secp256k1 PK of this BTC delegation + // the PK follows encoding in BIP-340 spec + bytes btc_pk = 2 [ (gogoproto.customtype) = "github.com/babylonlabs-io/babylon/types.BIP340PubKey" ]; + // pop is the proof of possession of babylon_pk and btc_pk + ProofOfPossessionBTC pop = 3; + // fp_btc_pk_list is the list of BIP-340 PKs of the finality providers that + // this BTC delegation delegates to + // If there is more than 1 PKs, then this means the delegation is restaked + // to multiple finality providers + repeated bytes fp_btc_pk_list = 4 [ (gogoproto.customtype) = "github.com/babylonlabs-io/babylon/types.BIP340PubKey" ]; + // staking_time is the number of blocks for which the delegation is locked on BTC chain + uint32 staking_time = 5; + // start_height is the start BTC height of the BTC delegation + // it is the start BTC height of the timelock + uint32 start_height = 6; + // end_height is the end height of the BTC delegation + // it is calculated by end_height = start_height + staking_time + uint32 end_height = 7; + // total_sat is the total amount of BTC stakes in this delegation + // quantified in satoshi + uint64 total_sat = 8; + // staking_tx is the staking tx + bytes staking_tx = 9; + // staking_output_idx is the index of the staking output in the staking tx + uint32 staking_output_idx = 10; + // slashing_tx is the slashing tx + // It is partially signed by SK corresponding to btc_pk, but not signed by + // finality provider or covenant yet. + bytes slashing_tx = 11 [ (gogoproto.customtype) = "BTCSlashingTx" ]; + // delegator_sig is the signature on the slashing tx + // by the delegator (i.e., SK corresponding to btc_pk). + // It will be a part of the witness for the staking tx output. + bytes delegator_sig = 12 [ (gogoproto.customtype) = "github.com/babylonlabs-io/babylon/types.BIP340Signature" ]; + // covenant_sigs is a list of adaptor signatures on the slashing tx + // by each covenant member + // It will be a part of the witness for the staking tx output. + repeated CovenantAdaptorSignatures covenant_sigs = 13; + // unbonding_time describes how long the funds will be locked either in unbonding output + // or slashing change output + uint32 unbonding_time = 14; + // btc_undelegation is the information about the early unbonding path of the BTC delegation + BTCUndelegation btc_undelegation = 15; + // version of the params used to validate the delegation + uint32 params_version = 16; +} + +// DelegatorUnbondingInfo contains the information about transaction which spent +// the staking output. It contains: +// - spend_stake_tx: the transaction which spent the staking output +// - spend_stake_tx_inclusion_block_hash: the block hash of the block in which +// spend_stake_tx was included +// - spend_stake_tx_sig_inclusion_index: the index of spend_stake_tx in the block +message DelegatorUnbondingInfo { + // spend_stake_tx is the transaction which spent the staking output. It is + // filled only if spend_stake_tx is different than unbonding_tx registered + // on the Babylon chain. + bytes spend_stake_tx = 1; } // BTCUndelegation contains the information about the early unbonding path of the BTC delegation message BTCUndelegation { - // unbonding_tx is the transaction which will transfer the funds from staking - // output to unbonding output. Unbonding output will usually have lower timelock - // than staking output. - bytes unbonding_tx = 1; - // slashing_tx is the slashing tx for unbonding transactions - // It is partially signed by SK corresponding to btc_pk, but not signed by - // finality provider or covenant yet. - bytes slashing_tx = 2 [ (gogoproto.customtype) = "BTCSlashingTx" ]; - // delegator_unbonding_sig is the signature on the unbonding tx - // by the delegator (i.e., SK corresponding to btc_pk). - // It effectively proves that the delegator wants to unbond and thus - // Babylon will consider this BTC delegation unbonded. Delegator's BTC - // on Bitcoin will be unbonded after timelock - bytes delegator_unbonding_sig = 3 [ (gogoproto.customtype) = "github.com/babylonlabs-io/babylon/types.BIP340Signature" ]; - // delegator_slashing_sig is the signature on the slashing tx - // by the delegator (i.e., SK corresponding to btc_pk). - // It will be a part of the witness for the unbonding tx output. - bytes delegator_slashing_sig = 4 [ (gogoproto.customtype) = "github.com/babylonlabs-io/babylon/types.BIP340Signature" ]; - // covenant_slashing_sigs is a list of adaptor signatures on the slashing tx - // by each covenant member - // It will be a part of the witness for the staking tx output. - repeated CovenantAdaptorSignatures covenant_slashing_sigs = 5; - // covenant_unbonding_sig_list is the list of signatures on the unbonding tx - // by covenant members - // It must be provided after processing undelegate message by Babylon - repeated SignatureInfo covenant_unbonding_sig_list = 6; + // unbonding_tx is the transaction which will transfer the funds from staking + // output to unbonding output. Unbonding output will usually have lower timelock + // than staking output. + bytes unbonding_tx = 1; + // slashing_tx is the slashing tx for unbonding transactions + // It is partially signed by SK corresponding to btc_pk, but not signed by + // finality provider or covenant yet. + bytes slashing_tx = 2 [ (gogoproto.customtype) = "BTCSlashingTx" ]; + // delegator_slashing_sig is the signature on the slashing tx + // by the delegator (i.e., SK corresponding to btc_pk). + // It will be a part of the witness for the unbonding tx output. + bytes delegator_slashing_sig = 3 [ (gogoproto.customtype) = "github.com/babylonlabs-io/babylon/types.BIP340Signature" ]; + // covenant_slashing_sigs is a list of adaptor signatures on the slashing tx + // by each covenant member + // It will be a part of the witness for the staking tx output. + repeated CovenantAdaptorSignatures covenant_slashing_sigs = 4; + // covenant_unbonding_sig_list is the list of signatures on the unbonding tx + // by covenant members + // It must be provided after processing undelegate message by Babylon + repeated SignatureInfo covenant_unbonding_sig_list = 5; + // delegator_unbonding_info is the information about transaction which spent + // the staking output + DelegatorUnbondingInfo delegator_unbonding_info = 6; } ``` ### BTC delegation index -The [BTC delegation index storage](./keeper/btc_delegators.go) maintains an +The [BTC delegation index management](./keeper/btc_delegators.go) maintains an index between the BTC delegator and its BTC delegations. The key is the BTC delegator's Bitcoin secp256k1 public key in BIP-340 format, and the value is a `BTCDelegatorDelegationIndex` @@ -290,58 +310,6 @@ message BTCDelegatorDelegationIndex { } ``` -### Voting power table - -The [voting power table storage](./keeper/voting_power_table.go) maintains the -voting power table of all finality providers at each height of the Babylon -chain. The key is the block height concatenated with the finality provider's -Bitcoin secp256k1 public key in BIP-340 format, and the value is the finality -provider's voting power quantified in Satoshis. -Voting power is assigned to top `N` (defined in parameters) finality providers -that have BTC-timestamped public randomness for the height, ranked by the total -delegated value. - -### Params - -The [parameter storage](./keeper/params.go) maintains the parameters for the BTC -staking module. - -```protobuf -// Params defines the parameters for the module. -message Params { - option (gogoproto.goproto_stringer) = false; - - // covenant_pks is the list of public keys held by the covenant committee - // each PK follows encoding in BIP-340 spec on Bitcoin - repeated bytes covenant_pks = 1 [ (gogoproto.customtype) = "github.com/babylonlabs-io/babylon/types.BIP340PubKey" ]; - // covenant_quorum is the minimum number of signatures needed for the covenant - // multisignature - uint32 covenant_quorum = 2; - // slashing address is the address that the slashed BTC goes to - // the address is in string on Bitcoin - string slashing_address = 3; - // min_slashing_tx_fee_sat is the minimum amount of tx fee (quantified - // in Satoshi) needed for the pre-signed slashing tx - int64 min_slashing_tx_fee_sat = 4; - // min_commission_rate is the chain-wide minimum commission rate that a finality provider can charge their delegators - string min_commission_rate = 5 [ - (gogoproto.customtype) = "cosmossdk.io/math.LegacyDec", - (gogoproto.nullable) = false - ]; - // slashing_rate determines the portion of the staked amount to be slashed, - // expressed as a decimal (e.g., 0.5 for 50%). - string slashing_rate = 6 [ - (cosmos_proto.scalar) = "cosmos.Dec", - (gogoproto.customtype) = "cosmossdk.io/math.LegacyDec", - (gogoproto.nullable) = false - ]; - // max_active_finality_providers is the maximum number of active finality providers in the BTC staking protocol - uint32 max_active_finality_providers = 7; - // min_unbonding_time is the minimum time for unbonding transaction timelock in BTC blocks - uint32 min_unbonding_time = 8; -} -``` - ## Messages The BTC Staking module handles the following messages from finality providers, @@ -349,7 +317,7 @@ BTC stakers (aka delegators), and covenant emulators. The message formats are defined at [proto/babylon/btcstaking/v1/tx.proto](../../proto/babylon/btcstaking/v1/tx.proto). The message handlers are defined at -[x/btcstaking/keeper/msg_server.go](./keeper/msg_server.go). +[x/btcstaking/keeper/msg_server.go](./keeper/msg_server.go). For more information on the SDK messages, refer to the [Cosmos SDK documentation on messages and queries](https://docs.cosmos.network/main/build/building-modules/messages-and-queries) ### MsgCreateFinalityProvider @@ -696,77 +664,224 @@ submit it to Babylon. ## BeginBlocker -Upon `BeginBlock`, the BTC Staking module will execute the following: - -1. Index the current BTC tip height. This will be used for determining the - status of BTC delegations. -2. Record the voting power table at the current height, by reconciling the - voting power table at the last height with all events that affect voting - power distribution (including newly active BTC delegations, newly unbonded - BTC delegations, and slashed finality providers). - Note that the voting power is assigned to a finality provider if it (1) has - BTC-timestamped public randomness, and (2) it is ranked at top `N` by the - total delegated value. -3. If the BTC Staking protocol is activated, i.e., there exists at least 1 - active BTC delegation, then record the reward distribution w.r.t. the active - finality providers and active BTC delegations. +Upon `BeginBlock`, the BTC Staking module will index the current BTC tip height. This will be used for determining the status of BTC delegations. The logic is defined at [x/btcstaking/abci.go](./abci.go). ## Events -The BTC staking module emits a set of events as follows. The events are defined +The BTC staking module emits a set of events for external subscribers. The events are defined at `proto/babylon/btcstaking/v1/events.proto`. +### Finality provider events + ```protobuf -// EventNewFinalityProvider is the event emitted when a finality provider is created -message EventNewFinalityProvider { FinalityProvider fp = 1; } - -// EventBTCDelegationStateUpdate is the event emitted when a BTC delegation's state is -// updated. There are the following possible state transitions: -// - non-existing -> pending, which happens upon `MsgCreateBTCDelegation` -// - pending -> active, which happens upon `MsgAddCovenantSigs` -// - active -> unbonded, which happens upon `MsgBTCUndelegate` or upon staking tx timelock expires -message EventBTCDelegationStateUpdate { +// EventFinalityProviderCreated is the event emitted when a finality provider is created +message EventFinalityProviderCreated { + // btc_pk_hex is the hex string of Bitcoin secp256k1 PK of this finality provider + string btc_pk_hex = 1; + // addr is the babylon address to receive commission from delegations. + string addr = 2; + // commission defines the commission rate of the finality provider in decimals. + string commission = 3; + // moniker defines a human-readable name for the finality provider. + string moniker = 4; + // identity defines an optional identity signature (ex. UPort or Keybase). + string identity = 5; + // website defines an optional website link. + string website = 6; + // security_contact defines an optional email for security contact. + string security_contact = 7; + // details define other optional details. + string details = 8; +} + +// EventFinalityProviderEdited is the event emitted when a finality provider is edited +message EventFinalityProviderEdited { + // btc_pk_hex is the hex string of Bitcoin secp256k1 PK of this finality provider + string btc_pk_hex = 1; + // commission defines the commission rate of the finality provider in decimals. + string commission = 2; + // moniker defines a human-readable name for the finality provider. + string moniker = 3; + // identity defines an optional identity signature (ex. UPort or Keybase). + string identity = 4; + // website defines an optional website link. + string website = 5; + // security_contact defines an optional email for security contact. + string security_contact = 6; + // details define other optional details. + string details = 7; +} + +// A finality provider starts with status INACTIVE once registered. +// Possible status transitions are when: +// 1. it has accumulated sufficient delegations and has +// timestamped public randomness: +// INACTIVE -> ACTIVE +// 2. it is jailed due to downtime: +// ACTIVE -> JAILED +// 3. it is slashed due to double-sign: +// ACTIVE -> SLASHED +// 4. it is unjailed after a jailing period: +// JAILED -> INACTIVE/ACTIVE (depending on (1)) +// 5. it does not have sufficient delegations or does not +// have timestamped public randomness: +// ACTIVE -> INACTIVE. +// Note that it is impossible for a SLASHED finality provider to +// transition to other status +message EventFinalityProviderStatusChange { + // btc_pk is the BTC public key of the finality provider + string btc_pk = 1; + // new_status is the status that the finality provider + // is transitioned to, following FinalityProviderStatus + string new_state = 2; +} +``` + +### Delegation events + +```protobuf + +// EventBTCDelegationCreated is the event emitted when a BTC delegation is created +// on the Babylon chain +message EventBTCDelegationCreated { + // staking_tx_hash is the hash of the staking tx. + // It uniquely identifies a BTC delegation + string staking_tx_hash = 1; + // version of the params used to validate the delegation + string params_version = 2; + // finality_provider_btc_pks_hex is the list of hex str of Bitcoin secp256k1 PK of + // the finality providers that this BTC delegation delegates to + // the PK follows encoding in BIP-340 spec + repeated string finality_provider_btc_pks_hex = 3; + // staker_btc_pk_hex is the hex str of Bitcoin secp256k1 PK of the staker that + // creates this BTC delegation the PK follows encoding in BIP-340 spec + string staker_btc_pk_hex = 4; + // staking_time is the timelock of the staking tx specified in the BTC script + string staking_time = 5; + // staking_amount is the total amount of BTC stake in this delegation + // quantified in satoshi + string staking_amount = 6; + // unbonding_time is the time is timelock on unbonding tx chosen by the staker + string unbonding_time = 7; + // unbonding_tx is hex encoded bytes of the unsigned unbonding tx + string unbonding_tx = 8; + // new_state of the BTC delegation + string new_state = 9; +} + +// EventCovenantSignatureReceived is the event emitted when a covenant committee +// sends valid covenant signatures for a BTC delegation +message EventCovenantSignatureReceived{ + // staking_tx_hash is the hash of the staking identifing the BTC delegation + // that this covenant signature is for + string staking_tx_hash = 1; + // covenant_btc_pk_hex is the hex str of Bitcoin secp256k1 PK of the + // covnenat committee that send the signature + string covenant_btc_pk_hex = 2; + // covenant_unbonding_signature_hex is the hex str of the BIP340 Schnorr + // signature of the covenant committee on the unbonding tx + string covenant_unbonding_signature_hex = 3; +} + +// EventCovenantQuorumReached is the event emitted quorum of covenant committee +// is reached for a BTC delegation +message EventCovenantQuorumReached { + // staking_tx_hash is the hash of the staking identifing the BTC delegation + // that this covenant signature is for + string staking_tx_hash = 1; + // new_state of the BTC delegation + string new_state = 2; +} + +// EventBTCDelegationInclusionProofReceived is the event emitted when a BTC delegation +// inclusion proof is received +message EventBTCDelegationInclusionProofReceived { // staking_tx_hash is the hash of the staking tx. // It uniquely identifies a BTC delegation string staking_tx_hash = 1; - // new_state is the new state of this BTC delegation - BTCDelegationStatus new_state = 2; + // start_height is the start BTC height of the BTC delegation + // it is the start BTC height of the timelock + string start_height = 2; + // end_height is the end height of the BTC delegation + // it is calculated by end_height = start_height + staking_time + string end_height = 3; + // new_state of the BTC delegation + string new_state = 4; } -// EventSelectiveSlashing is the event emitted when an adversarial -// finality provider selectively slashes a BTC delegation. This will -// result in slashing of all BTC delegations under this finality provider. -message EventSelectiveSlashing { - // evidence is the evidence of selective slashing - SelectiveSlashingEvidence evidence = 1; +// EventBTCDelgationUnbondedEarly is the event emitted when a BTC delegation +// is unbonded by staker sending unbonding tx to BTC +message EventBTCDelgationUnbondedEarly { + // staking_tx_hash is the hash of the staking tx. + // It uniquely identifies a BTC delegation + string staking_tx_hash = 1; + // new_state of the BTC delegation + string new_state = 2; } -// EventPowerDistUpdate is an event that affects voting power distirbution -// of BTC staking protocol -message EventPowerDistUpdate { - // EventSlashedFinalityProvider defines an event that a finality provider - // is slashed - // TODO: unify with existing slashing events - message EventSlashedFinalityProvider { - bytes pk = 1 [ (gogoproto.customtype) = "github.com/babylonlabs-io/babylon/types.BIP340PubKey" ]; - } - - // ev is the event that affects voting power distribution - oneof ev { - // slashed_fp means a finality provider is slashed - EventSlashedFinalityProvider slashed_fp = 1; - // btc_del_state_update means a BTC delegation's state is updated - EventBTCDelegationStateUpdate btc_del_state_update = 2; - } +// EventBTCDelegationExpired is the event emitted when a BTC delegation +// is unbonded by expiration of the staking tx timelock +message EventBTCDelegationExpired { + // staking_tx_hash is the hash of the staking tx. + // It uniquely identifies a BTC delegation + string staking_tx_hash = 1; + // new_state of the BTC delegation + string new_state = 2; } ``` ## Queries -The BTC staking module provides a set of queries about the status of finality -providers and BTC delegations, listed at -[docs.babylonchain.io](https://docs.babylonchain.io/docs/developer-guides/grpcrestapi#tag/BTCStaking). +The BTC Staking module provides a set of queries related to the status of finality providers, BTC delegations, and other staking-related data. These queries can be accessed via gRPC and REST endpoints. + +Available Queries: +Parameters +Endpoint: `/babylon/btcstaking/v1/params` +Description: Queries the current parameters of the BTC Staking module. + +Params by Version +Endpoint: `/babylon/btcstaking/v1/params/{version}` +Description: Queries the parameters of the module for a specific past version. + +Finality Providers +Endpoint: `/babylon/btcstaking/v1/finality_providers` +Description: Retrieves all finality providers in the Babylon staking module. + +Finality Provider by Public Key +Endpoint: `/babylon/btcstaking/v1/finality_providers/{fp_btc_pk_hex}/finality_provider` +Description: Retrieves information about a specific finality provider by its Bitcoin public key (in BIP-340 format). + +BTC Delegations by Status +Endpoint: `/babylon/btcstaking/v1/btc_delegations/{status}` +Description: Queries all BTC delegations under a given status. + +Active Finality Providers at Height +Endpoint: `/babylon/btcstaking/v1/finality_providers/{height}` +Description: Retrieves finality providers with non-zero voting power at a specific Babylon block height. + +Finality Provider Power at Height +Endpoint: `/babylon/btcstaking/v1/finality_providers/{fp_btc_pk_hex}/power/`{height} +Description: Queries the voting power of a specific finality provider at a given Babylon block height. + +Finality Provider Current Power +Endpoint: `/babylon/btcstaking/v1/finality_providers/{fp_btc_pk_hex}/power` +Description: Queries the current voting power of a specific finality provider. + +Activated Height +Endpoint: `/babylon/btcstaking/v1/activated_height` +Description: Queries the block height when the BTC staking protocol was activated (i.e., the first height when there existed at least one finality provider with voting power). + +Finality Provider Delegations +Endpoint: `/babylon/btcstaking/v1/finality_providers/{fp_btc_pk_hex}/delegations` +Description: Queries all BTC delegations under a specific finality provider. + +BTC Delegation by Staking Transaction Hash +Endpoint: `/babylon/btcstaking/v1/btc_delegation/{staking_tx_hash_hex}` +Description: Retrieves a specific BTC delegation by its corresponding staking transaction hash. + +Additional Information: +For further details on how to use these queries and additional documentation, please refer to docs.babylonchain.io. diff --git a/x/btcstaking/client/cli/query.go b/x/btcstaking/client/cli/query.go index 7f3b19126..4466d29ed 100644 --- a/x/btcstaking/client/cli/query.go +++ b/x/btcstaking/client/cli/query.go @@ -2,7 +2,6 @@ package cli import ( "fmt" - "strconv" "github.com/cosmos/cosmos-sdk/client/flags" @@ -26,9 +25,6 @@ func GetQueryCmd(queryRoute string) *cobra.Command { cmd.AddCommand(CmdFinalityProvider()) cmd.AddCommand(CmdFinalityProviders()) cmd.AddCommand(CmdBTCDelegations()) - cmd.AddCommand(CmdFinalityProvidersAtHeight()) - cmd.AddCommand(CmdFinalityProviderPowerAtHeight()) - cmd.AddCommand(CmdActivatedHeight()) cmd.AddCommand(CmdFinalityProviderDelegations()) cmd.AddCommand(CmdDelegation()) @@ -160,99 +156,6 @@ func CmdBTCDelegations() *cobra.Command { return cmd } -func CmdFinalityProviderPowerAtHeight() *cobra.Command { - cmd := &cobra.Command{ - Use: "finality-provider-power-at-height [fp_btc_pk_hex] [height]", - Short: "get the voting power of a given finality provider at a given height", - Args: cobra.ExactArgs(2), - RunE: func(cmd *cobra.Command, args []string) error { - clientCtx := client.GetClientContextFromCmd(cmd) - - queryClient := types.NewQueryClient(clientCtx) - - height, err := strconv.ParseUint(args[1], 10, 64) - if err != nil { - return err - } - res, err := queryClient.FinalityProviderPowerAtHeight(cmd.Context(), &types.QueryFinalityProviderPowerAtHeightRequest{ - FpBtcPkHex: args[0], - Height: height, - }) - if err != nil { - return err - } - - return clientCtx.PrintProto(res) - }, - } - - flags.AddQueryFlagsToCmd(cmd) - - return cmd -} - -func CmdActivatedHeight() *cobra.Command { - cmd := &cobra.Command{ - Use: "activated-height", - Short: "get activated height, i.e., the first height where there exists 1 finality provider with voting power", - Args: cobra.NoArgs, - RunE: func(cmd *cobra.Command, args []string) error { - clientCtx := client.GetClientContextFromCmd(cmd) - - queryClient := types.NewQueryClient(clientCtx) - - res, err := queryClient.ActivatedHeight(cmd.Context(), &types.QueryActivatedHeightRequest{}) - if err != nil { - return err - } - - return clientCtx.PrintProto(res) - }, - } - - flags.AddQueryFlagsToCmd(cmd) - - return cmd -} - -func CmdFinalityProvidersAtHeight() *cobra.Command { - cmd := &cobra.Command{ - Use: "finality-providers-at-height [height]", - Short: "retrieve all finality providers at a given babylon height", - Args: cobra.ExactArgs(1), - RunE: func(cmd *cobra.Command, args []string) error { - clientCtx := client.GetClientContextFromCmd(cmd) - - queryClient := types.NewQueryClient(clientCtx) - - height, err := strconv.ParseUint(args[0], 10, 64) - if err != nil { - return err - } - - pageReq, err := client.ReadPageRequest(cmd.Flags()) - if err != nil { - return err - } - - res, err := queryClient.ActiveFinalityProvidersAtHeight(cmd.Context(), &types.QueryActiveFinalityProvidersAtHeightRequest{ - Height: height, - Pagination: pageReq, - }) - if err != nil { - return err - } - - return clientCtx.PrintProto(res) - }, - } - - flags.AddQueryFlagsToCmd(cmd) - flags.AddPaginationFlagsToCmd(cmd, "finality-providers-at-height") - - return cmd -} - func CmdFinalityProviderDelegations() *cobra.Command { cmd := &cobra.Command{ Use: "finality-provider-delegations [fp_pk_hex]", diff --git a/x/btcstaking/client/cli/tx.go b/x/btcstaking/client/cli/tx.go index 67cf18600..b17cd9afa 100644 --- a/x/btcstaking/client/cli/tx.go +++ b/x/btcstaking/client/cli/tx.go @@ -14,7 +14,6 @@ import ( asig "github.com/babylonlabs-io/babylon/crypto/schnorr-adaptor-signature" bbn "github.com/babylonlabs-io/babylon/types" - btcctypes "github.com/babylonlabs-io/babylon/x/btccheckpoint/types" "github.com/babylonlabs-io/babylon/x/btcstaking/types" ) @@ -45,6 +44,7 @@ func GetTxCmd() *cobra.Command { NewAddCovenantSigsCmd(), NewBTCUndelegateCmd(), NewSelectiveSlashingEvidenceCmd(), + NewAddBTCDelegationInclusionProofCmd(), ) return cmd @@ -163,7 +163,7 @@ func NewEditFinalityProviderCmd() *cobra.Command { } // get BTC PK - btcPK, err := hex.DecodeString(args[1]) + btcPK, err := hex.DecodeString(args[0]) if err != nil { return err } @@ -194,8 +194,8 @@ func NewEditFinalityProviderCmd() *cobra.Command { func NewCreateBTCDelegationCmd() *cobra.Command { cmd := &cobra.Command{ - Use: "create-btc-delegation [btc_pk] [pop_hex] [staking_tx_info] [fp_pk1],[fp_pk2],... [staking_time] [staking_value] [slashing_tx] [delegator_slashing_sig] [unbonding_tx] [unbonding_slashing_tx] [unbonding_time] [unbonding_value] [delegator_unbonding_slashing_sig]", - Args: cobra.ExactArgs(13), + Use: "create-btc-delegation [btc_pk] [pop_hex] [staking_tx] [inclusion_proof] [fp_pk1],[fp_pk2],... [staking_time] [staking_value] [slashing_tx] [delegator_slashing_sig] [unbonding_tx] [unbonding_slashing_tx] [unbonding_time] [unbonding_value] [delegator_unbonding_slashing_sig]", + Args: cobra.ExactArgs(14), Short: "Create a BTC delegation", Long: strings.TrimSpace( `Create a BTC delegation.`, // TODO: example @@ -219,14 +219,23 @@ func NewCreateBTCDelegationCmd() *cobra.Command { return err } - // get staking tx info - stakingTxInfo, err := btcctypes.NewTransactionInfoFromHex(args[2]) + // get staking tx bytes + stakingTx, err := hex.DecodeString(args[2]) if err != nil { return err } + var inclusionProof *types.InclusionProof + // inclusionProof can be nil if empty argument is provided + if len(args[3]) > 0 { + inclusionProof, err = types.NewInclusionProofFromHex(args[3]) + if err != nil { + return err + } + } + // get finality provider PKs - fpPKStrs := strings.Split(args[3], ",") + fpPKStrs := strings.Split(args[4], ",") fpPKs := make([]bbn.BIP340PubKey, len(fpPKStrs)) for i := range fpPKStrs { fpPK, err := bbn.NewBIP340PubKeyFromHex(fpPKStrs[i]) @@ -237,53 +246,53 @@ func NewCreateBTCDelegationCmd() *cobra.Command { } // get staking time - stakingTime, err := parseLockTime(args[4]) + stakingTime, err := parseLockTime(args[5]) if err != nil { return err } - stakingValue, err := parseBtcAmount(args[5]) + stakingValue, err := parseBtcAmount(args[6]) if err != nil { return err } // get slashing tx - slashingTx, err := types.NewBTCSlashingTxFromHex(args[6]) + slashingTx, err := types.NewBTCSlashingTxFromHex(args[7]) if err != nil { return err } // get delegator sig on slashing tx - delegatorSlashingSig, err := bbn.NewBIP340SignatureFromHex(args[7]) + delegatorSlashingSig, err := bbn.NewBIP340SignatureFromHex(args[8]) if err != nil { return err } // get unbonding tx - _, unbondingTxBytes, err := bbn.NewBTCTxFromHex(args[8]) + _, unbondingTxBytes, err := bbn.NewBTCTxFromHex(args[9]) if err != nil { return err } // get unbonding slashing tx - unbondingSlashingTx, err := types.NewBTCSlashingTxFromHex(args[9]) + unbondingSlashingTx, err := types.NewBTCSlashingTxFromHex(args[10]) if err != nil { return err } // get staking time - unbondingTime, err := parseLockTime(args[10]) + unbondingTime, err := parseLockTime(args[11]) if err != nil { return err } - unbondingValue, err := parseBtcAmount(args[11]) + unbondingValue, err := parseBtcAmount(args[12]) if err != nil { return err } // get delegator sig on unbonding slashing tx - delegatorUnbondingSlashingSig, err := bbn.NewBIP340SignatureFromHex(args[12]) + delegatorUnbondingSlashingSig, err := bbn.NewBIP340SignatureFromHex(args[13]) if err != nil { return err } @@ -295,7 +304,8 @@ func NewCreateBTCDelegationCmd() *cobra.Command { Pop: pop, StakingTime: uint32(stakingTime), StakingValue: int64(stakingValue), - StakingTx: stakingTxInfo, + StakingTx: stakingTx, + StakingTxInclusionProof: inclusionProof, SlashingTx: slashingTx, DelegatorSlashingSig: delegatorSlashingSig, UnbondingTx: unbondingTxBytes, @@ -314,6 +324,43 @@ func NewCreateBTCDelegationCmd() *cobra.Command { return cmd } +func NewAddBTCDelegationInclusionProofCmd() *cobra.Command { + cmd := &cobra.Command{ + Use: "add-btc-inclusion-proof [staking_tx_hash] [inclusion_proof]", + Args: cobra.ExactArgs(2), + Short: "Add a signature on the unbonding tx of a BTC delegation identified by a given staking tx hash. ", + Long: strings.TrimSpace( + `Add a signature on the unbonding tx of a BTC delegation identified by a given staking tx hash signed by the delegator. The signature proves that delegator wants to unbond, and Babylon will consider the BTC delegation unbonded.`, // TODO: example + ), + RunE: func(cmd *cobra.Command, args []string) error { + clientCtx, err := client.GetClientTxContext(cmd) + if err != nil { + return err + } + + // get staking tx hash + stakingTxHash := args[0] + + inclusionProof, err := types.NewInclusionProofFromHex(args[1]) + if err != nil { + return err + } + + msg := types.MsgAddBTCDelegationInclusionProof{ + Signer: clientCtx.FromAddress.String(), + StakingTxHash: stakingTxHash, + StakingTxInclusionProof: inclusionProof, + } + + return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), &msg) + }, + } + + flags.AddTxFlagsToCmd(cmd) + + return cmd +} + func NewAddCovenantSigsCmd() *cobra.Command { cmd := &cobra.Command{ Use: "add-covenant-sigs [covenant_pk] [staking_tx_hash] [slashing_tx_sig1],[slashing_tx_sig2],... [unbonding_tx_sig] [slashing_unbonding_tx_sig1],[slashing_unbonding_tx_sig2],...", @@ -382,11 +429,11 @@ func NewAddCovenantSigsCmd() *cobra.Command { func NewBTCUndelegateCmd() *cobra.Command { cmd := &cobra.Command{ - Use: "btc-undelegate [staking_tx_hash] [unbonding_tx_sig]", - Args: cobra.ExactArgs(2), - Short: "Add a signature on the unbonding tx of a BTC delegation identified by a given staking tx hash. ", + Use: "btc-undelegate [staking_tx_hash] [spend_stake_tx] [spend_stake_tx_inclusion_proof]", + Args: cobra.ExactArgs(3), + Short: "Add unbonding information about a BTC delegation identified by a given staking tx hash.", Long: strings.TrimSpace( - `Add a signature on the unbonding tx of a BTC delegation identified by a given staking tx hash signed by the delegator. The signature proves that delegator wants to unbond, and Babylon will consider the BTC delegation unbonded.`, // TODO: example + `Add unbonding information about a BTC delegation identified by a given staking tx hash. Proof of inclusion proves stake was spent on BTC chain`, // TODO: example ), RunE: func(cmd *cobra.Command, args []string) error { clientCtx, err := client.GetClientTxContext(cmd) @@ -397,16 +444,21 @@ func NewBTCUndelegateCmd() *cobra.Command { // get staking tx hash stakingTxHash := args[0] - // get delegator signature for unbonding tx - unbondingTxSig, err := bbn.NewBIP340SignatureFromHex(args[1]) + _, bytes, err := bbn.NewBTCTxFromHex(args[1]) + if err != nil { + return err + } + + inclusionProof, err := types.NewInclusionProofFromHex(args[2]) if err != nil { return err } msg := types.MsgBTCUndelegate{ - Signer: clientCtx.FromAddress.String(), - StakingTxHash: stakingTxHash, - UnbondingTxSig: unbondingTxSig, + Signer: clientCtx.FromAddress.String(), + StakingTxHash: stakingTxHash, + StakeSpendingTx: bytes, + StakeSpendingTxInclusionProof: inclusionProof, } return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), &msg) diff --git a/x/btcstaking/genesis_test.go b/x/btcstaking/genesis_test.go index f373bbcea..2ab7d793c 100644 --- a/x/btcstaking/genesis_test.go +++ b/x/btcstaking/genesis_test.go @@ -17,7 +17,7 @@ func TestGenesis(t *testing.T) { Params: []*types.Params{&p}, } - k, _, ctx := keepertest.BTCStakingKeeper(t, nil, nil, nil) + k, ctx := keepertest.BTCStakingKeeper(t, nil, nil, nil) btcstaking.InitGenesis(ctx, *k, genesisState) got := btcstaking.ExportGenesis(ctx, *k) require.NotNil(t, got) diff --git a/x/btcstaking/keeper/allowed_transaction_index.go b/x/btcstaking/keeper/allowed_transaction_index.go new file mode 100644 index 000000000..d3e482f06 --- /dev/null +++ b/x/btcstaking/keeper/allowed_transaction_index.go @@ -0,0 +1,24 @@ +package keeper + +import ( + "context" + + "github.com/btcsuite/btcd/chaincfg/chainhash" +) + +// IndexAllowedStakingTransaction indexes the given allowed staking transaction by its hash. +func (k Keeper) IndexAllowedStakingTransaction(ctx context.Context, txHash *chainhash.Hash) { + err := k.AllowedStakingTxHashesKeySet.Set(ctx, txHash[:]) + if err != nil { + panic(err) // encoding issue; this can only be a programming error + } +} + +// IsStakingTransactionAllowed checks if the given staking transaction is allowed. +func (k Keeper) IsStakingTransactionAllowed(ctx context.Context, txHash *chainhash.Hash) bool { + has, err := k.AllowedStakingTxHashesKeySet.Has(ctx, txHash[:]) + if err != nil { + panic(err) // encoding issue; this can only be a programming error + } + return has +} diff --git a/x/btcstaking/keeper/bench_test.go b/x/btcstaking/keeper/bench_test.go index 1584ba0e0..a7d9b6c79 100644 --- a/x/btcstaking/keeper/bench_test.go +++ b/x/btcstaking/keeper/bench_test.go @@ -8,6 +8,7 @@ import ( "testing" "time" + testutil "github.com/babylonlabs-io/babylon/testutil/btcstaking-helper" "github.com/babylonlabs-io/babylon/testutil/datagen" btclctypes "github.com/babylonlabs-io/babylon/x/btclightclient/types" bsmodule "github.com/babylonlabs-io/babylon/x/btcstaking" @@ -24,8 +25,7 @@ func benchBeginBlock(b *testing.B, numFPs int, numDelsUnderFP int) { defer ctrl.Finish() btclcKeeper := types.NewMockBTCLightClientKeeper(ctrl) btccKeeper := types.NewMockBtcCheckpointKeeper(ctrl) - finalityKeeper := types.NewMockFinalityKeeper(ctrl) - h := NewHelper(b, btclcKeeper, btccKeeper, finalityKeeper) + h := testutil.NewHelper(b, btclcKeeper, btccKeeper) // set all parameters covenantSKs, _ := h.GenAndApplyParams(r) changeAddress, err := datagen.GenRandomBTCAddress(r, h.Net) @@ -54,19 +54,28 @@ func benchBeginBlock(b *testing.B, numFPs int, numDelsUnderFP int) { for i := 0; i < numDelsUnderFP; i++ { // generate and insert new BTC delegation stakingValue := int64(2 * 10e8) - stakingTxHash, _, _, msgCreateBTCDel, actualDel, err := h.CreateDelegation( + delSK, _, err := datagen.GenRandomBTCKeyPair(r) + h.NoError(err) + stakingTxHash, msgCreateBTCDel, actualDel, btcHeaderInfo, inclusionProof, _, err := h.CreateDelegation( r, + delSK, []*btcec.PublicKey{fp.BtcPk.MustToBTCPK()}, changeAddress.EncodeAddress(), stakingValue, 1000, + 0, + 0, + true, + false, ) h.NoError(err) // retrieve BTC delegation in DB btcDelMap[stakingTxHash] = append(btcDelMap[stakingTxHash], actualDel) // generate and insert new covenant signatures - // after that, all BTC delegations will have voting power h.CreateCovenantSigs(r, covenantSKs, msgCreateBTCDel, actualDel) + // activate BTC delegation + // after that, all BTC delegations will have voting power + h.AddInclusionProof(stakingTxHash, btcHeaderInfo, inclusionProof) } } diff --git a/x/btcstaking/keeper/btc_consumer_delegations.go b/x/btcstaking/keeper/btc_consumer_delegations.go index 2fc80d7df..69cf9699f 100644 --- a/x/btcstaking/keeper/btc_consumer_delegations.go +++ b/x/btcstaking/keeper/btc_consumer_delegations.go @@ -31,7 +31,7 @@ func (k Keeper) IndexBTCConsumerDelegation(ctx sdk.Context, btcDel *bstypes.BTCD fpBTCPK := btcDel.FpBtcPkList[i] // skip Babylon finality providers - if !k.bscKeeper.HasConsumerFinalityProvider(ctx, &fpBTCPK) { + if !k.BscKeeper.HasConsumerFinalityProvider(ctx, &fpBTCPK) { continue } @@ -42,7 +42,7 @@ func (k Keeper) IndexBTCConsumerDelegation(ctx sdk.Context, btcDel *bstypes.BTCD } // index staking tx hash of this BTC delegation if err := btcDelIndex.Add(stakingTxHash); err != nil { - return bstypes.ErrInvalidStakingTx.Wrapf(err.Error()) + return bstypes.ErrInvalidStakingTx.Wrapf("%s", err.Error()) } // save the index k.setBTCConsumerDelegatorDelegationIndex(ctx, &fpBTCPK, btcDel.BtcPk, btcDelIndex) @@ -58,8 +58,8 @@ func (k Keeper) GetBTCConsumerDelegatorDelegationsResponses( ctx sdk.Context, fpBTCPK *bbn.BIP340PubKey, pagination *query.PageRequest, - wValue uint64, - btcHeight uint64, + wValue uint32, + btcHeight uint32, covenantQuorum uint32, ) ([]*bstypes.BTCDelegatorDelegationsResponse, *query.PageResponse, error) { btcDelStore := k.btcConsumerDelegatorStore(ctx, fpBTCPK) @@ -97,15 +97,15 @@ func (k Keeper) GetBTCConsumerDelegatorDelegationsResponses( // SetConsumerFinalityProvider checks conditions and sets a new finality provider for a consumer. func (k Keeper) SetConsumerFinalityProvider(ctx context.Context, fp *bstypes.FinalityProvider, consumerID string) error { // check if the finality provider already exists to prevent duplicates - if k.bscKeeper.HasConsumerFinalityProvider(ctx, fp.BtcPk) { + if k.BscKeeper.HasConsumerFinalityProvider(ctx, fp.BtcPk) { return bstypes.ErrFpRegistered } // verify that the consumer is registered within the btcstkconsumer module - if !k.bscKeeper.IsConsumerRegistered(ctx, consumerID) { + if !k.BscKeeper.IsConsumerRegistered(ctx, consumerID) { return bstypes.ErrConsumerIDNotRegistered } // set the finality provider in btcstkconsumer module - k.bscKeeper.SetConsumerFinalityProvider(ctx, fp) + k.BscKeeper.SetConsumerFinalityProvider(ctx, fp) // record the event in btc staking consumer event store if err := k.AddBTCStakingConsumerEvent(ctx, consumerID, bstypes.CreateNewFinalityProviderEvent(fp)); err != nil { @@ -118,7 +118,7 @@ func (k Keeper) SetConsumerFinalityProvider(ctx context.Context, fp *bstypes.Fin // getBTCConsumerDelegatorDelegationIndex gets the BTC delegation index with a given BTC PK under a given finality provider func (k Keeper) getBTCConsumerDelegatorDelegationIndex(ctx context.Context, fpBTCPK *bbn.BIP340PubKey, delBTCPK *bbn.BIP340PubKey) *bstypes.BTCDelegatorDelegationIndex { // ensure the finality provider exists - if !k.bscKeeper.HasConsumerFinalityProvider(ctx, fpBTCPK) { + if !k.BscKeeper.HasConsumerFinalityProvider(ctx, fpBTCPK) { return nil } diff --git a/x/btcstaking/keeper/btc_delegations.go b/x/btcstaking/keeper/btc_delegations.go index 339cfcf82..4bd7b1e1f 100644 --- a/x/btcstaking/keeper/btc_delegations.go +++ b/x/btcstaking/keeper/btc_delegations.go @@ -5,19 +5,24 @@ import ( "fmt" "cosmossdk.io/store/prefix" - asig "github.com/babylonlabs-io/babylon/crypto/schnorr-adaptor-signature" - bbn "github.com/babylonlabs-io/babylon/types" - "github.com/babylonlabs-io/babylon/x/btcstaking/types" "github.com/btcsuite/btcd/chaincfg/chainhash" "github.com/cosmos/cosmos-sdk/runtime" sdk "github.com/cosmos/cosmos-sdk/types" + + asig "github.com/babylonlabs-io/babylon/crypto/schnorr-adaptor-signature" + bbn "github.com/babylonlabs-io/babylon/types" + "github.com/babylonlabs-io/babylon/x/btcstaking/types" ) // AddBTCDelegation adds a BTC delegation post verification to the system, including // - indexing the given BTC delegation in the BTC delegator store, // - saving it under BTC delegation store, and // - emit events about this BTC delegation. -func (k Keeper) AddBTCDelegation(ctx sdk.Context, btcDel *types.BTCDelegation) error { +func (k Keeper) AddBTCDelegation( + ctx sdk.Context, + btcDel *types.BTCDelegation, + minUnbondingTime uint32, +) error { if err := btcDel.ValidateBasic(); err != nil { return err } @@ -38,7 +43,7 @@ func (k Keeper) AddBTCDelegation(ctx sdk.Context, btcDel *types.BTCDelegation) e } // index staking tx hash of this BTC delegation if err := btcDelIndex.Add(stakingTxHash); err != nil { - return types.ErrInvalidStakingTx.Wrapf(err.Error()) + return types.ErrInvalidStakingTx.Wrapf("error adding staking tx hash to BTC delegator index: %s", err.Error()) } // save the index k.setBTCDelegatorDelegationIndex(ctx, &fpBTCPK, btcDel.BtcPk, btcDelIndex) @@ -47,25 +52,36 @@ func (k Keeper) AddBTCDelegation(ctx sdk.Context, btcDel *types.BTCDelegation) e // save this BTC delegation k.setBTCDelegation(ctx, btcDel) - // notify subscriber - event := &types.EventBTCDelegationStateUpdate{ - StakingTxHash: stakingTxHash.String(), - NewState: types.BTCDelegationStatus_PENDING, - } - if err := ctx.EventManager().EmitTypedEvent(event); err != nil { - panic(fmt.Errorf("failed to emit EventBTCDelegationStateUpdate for the new pending BTC delegation: %w", err)) + if err := ctx.EventManager().EmitTypedEvents(types.NewBtcDelCreationEvent( + btcDel, + )); err != nil { + panic(fmt.Errorf("failed to emit events for the new pending BTC delegation: %w", err)) } // NOTE: we don't need to record events for pending BTC delegations since these // do not affect voting power distribution + // NOTE: we only insert unbonded event if the delegation already has inclusion proof + if btcDel.HasInclusionProof() { + if err := ctx.EventManager().EmitTypedEvent(types.NewInclusionProofEvent( + stakingTxHash.String(), + btcDel.StartHeight, + btcDel.EndHeight, + types.BTCDelegationStatus_PENDING, + )); err != nil { + panic(fmt.Errorf("failed to emit EventBTCDelegationInclusionProofReceived for the new pending BTC delegation: %w", err)) + } - // record event that the BTC delegation will become unbonded at endHeight-w - unbondedEvent := types.NewEventPowerDistUpdateWithBTCDel(&types.EventBTCDelegationStateUpdate{ - StakingTxHash: stakingTxHash.String(), - NewState: types.BTCDelegationStatus_UNBONDED, - }) - wValue := k.btccKeeper.GetParams(ctx).CheckpointFinalizationTimeout - k.addPowerDistUpdateEvent(ctx, btcDel.EndHeight-wValue, unbondedEvent) + // record event that the BTC delegation will become unbonded at endHeight-w + // This event will be generated to subscribers as block event, when the + // btc light client block height will reach btcDel.EndHeight-wValue + unbondedEvent := types.NewEventPowerDistUpdateWithBTCDel(&types.EventBTCDelegationStateUpdate{ + StakingTxHash: stakingTxHash.String(), + NewState: types.BTCDelegationStatus_UNBONDED, + }) + + // NOTE: we should have verified that EndHeight > btcTip.Height + max(w, min_unbonding_time) + k.addPowerDistUpdateEvent(ctx, btcDel.EndHeight-minUnbondingTime, unbondedEvent) + } return nil } @@ -81,6 +97,8 @@ func (k Keeper) addCovenantSigsToBTCDelegation( parsedUnbondingSlashingAdaptorSignatures []asig.AdaptorSignature, params *types.Params, ) { + hadQuorum := btcDel.HasCovenantQuorums(params.CovenantQuorum) + // All is fine add received signatures to the BTC delegation and BtcUndelegation btcDel.AddCovenantSigs( covPK, @@ -92,62 +110,92 @@ func (k Keeper) addCovenantSigsToBTCDelegation( // set BTC delegation back to KV store k.setBTCDelegation(ctx, btcDel) + if err := ctx.EventManager().EmitTypedEvent(types.NewCovenantSignatureReceivedEvent( + btcDel, + covPK, + unbondingTxSig, + )); err != nil { + panic(fmt.Errorf("failed to emit EventCovenantSignatureRecevied for the new active BTC delegation: %w", err)) + } + // If reaching the covenant quorum after this msg, the BTC delegation becomes // active. Then, record and emit this event - if len(btcDel.CovenantSigs) == int(params.CovenantQuorum) { - // notify subscriber - event := &types.EventBTCDelegationStateUpdate{ - StakingTxHash: btcDel.MustGetStakingTxHash().String(), - NewState: types.BTCDelegationStatus_ACTIVE, - } - if err := ctx.EventManager().EmitTypedEvent(event); err != nil { - panic(fmt.Errorf("failed to emit EventBTCDelegationStateUpdate for the new active BTC delegation: %w", err)) - } + // We only emit power distribution events, and external quorum events if it + // is the first time the quorum is reached + if !hadQuorum && btcDel.HasCovenantQuorums(params.CovenantQuorum) { + if btcDel.HasInclusionProof() { + quorumReachedEvent := types.NewCovenantQuorumReachedEvent( + btcDel, + types.BTCDelegationStatus_ACTIVE, + ) + if err := ctx.EventManager().EmitTypedEvent(quorumReachedEvent); err != nil { + panic(fmt.Errorf("failed to emit emit for the new verified BTC delegation: %w", err)) + } - // record event that the BTC delegation becomes active at this height - activeEvent := types.NewEventPowerDistUpdateWithBTCDel(event) - btcTip := k.btclcKeeper.GetTipInfo(ctx) - k.addPowerDistUpdateEvent(ctx, btcTip.Height, activeEvent) + // record event that the BTC delegation becomes active at this height + activeEvent := types.NewEventPowerDistUpdateWithBTCDel( + &types.EventBTCDelegationStateUpdate{ + StakingTxHash: btcDel.MustGetStakingTxHash().String(), + NewState: types.BTCDelegationStatus_ACTIVE, + }, + ) + btcTip := k.btclcKeeper.GetTipInfo(ctx) + k.addPowerDistUpdateEvent(ctx, btcTip.Height, activeEvent) + + // notify consumer chains about the active BTC delegation + k.notifyConsumersOnActiveBTCDel(ctx, btcDel) + } else { + quorumReachedEvent := types.NewCovenantQuorumReachedEvent( + btcDel, + types.BTCDelegationStatus_VERIFIED, + ) - // get consumer ids of only non-Babylon finality providers - restakedFPConsumerIDs, err := k.restakedFPConsumerIDs(ctx, btcDel.FpBtcPkList) - if err != nil { - panic(fmt.Errorf("failed to get consumer ids for the restaked BTC delegation: %w", err)) - } - consumerEvent, err := types.CreateActiveBTCDelegationEvent(btcDel) - if err != nil { - panic(fmt.Errorf("failed to create active BTC delegation event: %w", err)) - } - for _, consumerID := range restakedFPConsumerIDs { - if err := k.AddBTCStakingConsumerEvent(ctx, consumerID, consumerEvent); err != nil { - panic(fmt.Errorf("failed to add active BTC delegation event: %w", err)) + if err := ctx.EventManager().EmitTypedEvent(quorumReachedEvent); err != nil { + panic(fmt.Errorf("failed to emit emit for the new verified BTC delegation: %w", err)) } } } } +func (k Keeper) notifyConsumersOnActiveBTCDel(ctx context.Context, btcDel *types.BTCDelegation) { + // get consumer ids of only non-Babylon finality providers + restakedFPConsumerIDs, err := k.restakedFPConsumerIDs(ctx, btcDel.FpBtcPkList) + if err != nil { + panic(fmt.Errorf("failed to get consumer ids for the restaked BTC delegation: %w", err)) + } + consumerEvent, err := types.CreateActiveBTCDelegationEvent(btcDel) + if err != nil { + panic(fmt.Errorf("failed to create active BTC delegation event: %w", err)) + } + for _, consumerID := range restakedFPConsumerIDs { + if err := k.AddBTCStakingConsumerEvent(ctx, consumerID, consumerEvent); err != nil { + panic(fmt.Errorf("failed to add active BTC delegation event: %w", err)) + } + } +} + // btcUndelegate adds the signature of the unbonding tx signed by the staker // to the given BTC delegation func (k Keeper) btcUndelegate( ctx sdk.Context, btcDel *types.BTCDelegation, - unbondingTxSig *bbn.BIP340Signature, + u *types.DelegatorUnbondingInfo, + stakeSpendingTx []byte, + proof *types.InclusionProof, ) { - btcDel.BtcUndelegation.DelegatorUnbondingSig = unbondingTxSig - - // set BTC delegation back to KV store + btcDel.BtcUndelegation.DelegatorUnbondingInfo = u k.setBTCDelegation(ctx, btcDel) + if !btcDel.HasInclusionProof() { + return + } + // notify subscriber about this unbonded BTC delegation event := &types.EventBTCDelegationStateUpdate{ StakingTxHash: btcDel.MustGetStakingTxHash().String(), NewState: types.BTCDelegationStatus_UNBONDED, } - if err := ctx.EventManager().EmitTypedEvent(event); err != nil { - panic(fmt.Errorf("failed to emit EventBTCDelegationStateUpdate for the new unbonded BTC delegation: %w", err)) - } - // record event that the BTC delegation becomes unbonded at this height unbondedEvent := types.NewEventPowerDistUpdateWithBTCDel(event) btcTip := k.btclcKeeper.GetTipInfo(ctx) @@ -159,7 +207,7 @@ func (k Keeper) btcUndelegate( panic(fmt.Errorf("failed to get consumer ids for the restaked BTC delegation: %w", err)) } // create consumer event for unbonded BTC delegation and add it to the consumer's event store - consumerEvent, err := types.CreateUnbondedBTCDelegationEvent(btcDel) + consumerEvent, err := types.CreateUnbondedBTCDelegationEvent(btcDel, stakeSpendingTx, proof) if err != nil { panic(fmt.Errorf("failed to create unbonded BTC delegation event: %w", err)) } @@ -195,8 +243,8 @@ func (k Keeper) validateRestakedFPs(ctx context.Context, fpBTCPKs []bbn.BIP340Pu } restakedToBabylon = true continue - } else if consumerID, err := k.bscKeeper.GetConsumerOfFinalityProvider(ctx, &fpBTCPK); err == nil { - fp, err := k.bscKeeper.GetConsumerFinalityProvider(ctx, consumerID, &fpBTCPK) + } else if consumerID, err := k.BscKeeper.GetConsumerOfFinalityProvider(ctx, &fpBTCPK); err == nil { + fp, err := k.BscKeeper.GetConsumerFinalityProvider(ctx, consumerID, &fpBTCPK) if err != nil { return false, err } @@ -225,7 +273,7 @@ func (k Keeper) restakedFPConsumerIDs(ctx context.Context, fpBTCPKs []bbn.BIP340 fpBTCPK := fpBTCPKs[i] if _, err := k.GetFinalityProvider(ctx, fpBTCPK); err == nil { continue - } else if consumerID, err := k.bscKeeper.GetConsumerOfFinalityProvider(ctx, &fpBTCPK); err == nil { + } else if consumerID, err := k.BscKeeper.GetConsumerOfFinalityProvider(ctx, &fpBTCPK); err == nil { consumerIDMap[consumerID] = struct{}{} } else { return nil, types.ErrFpNotFound.Wrapf("finality provider pk %s is not found", fpBTCPK.MarshalHex()) diff --git a/x/btcstaking/keeper/btc_delegators.go b/x/btcstaking/keeper/btc_delegators.go index dc95c191f..dd74ef037 100644 --- a/x/btcstaking/keeper/btc_delegators.go +++ b/x/btcstaking/keeper/btc_delegators.go @@ -77,7 +77,7 @@ func (k Keeper) GetFPBTCDelegations(ctx context.Context, fpBTCPK *bbn.BIP340PubK if k.HasFinalityProvider(ctx, *fpBTCPK) { // Babylon finality provider store = k.btcDelegatorFpStore(ctx, fpBTCPK) - } else if k.bscKeeper.HasConsumerFinalityProvider(ctx, fpBTCPK) { + } else if k.BscKeeper.HasConsumerFinalityProvider(ctx, fpBTCPK) { // Consumer finality provider store = k.btcConsumerDelegatorStore(ctx, fpBTCPK) } else { diff --git a/x/btcstaking/keeper/btc_height_index.go b/x/btcstaking/keeper/btc_height_index.go index 1f7adcc64..17ef33657 100644 --- a/x/btcstaking/keeper/btc_height_index.go +++ b/x/btcstaking/keeper/btc_height_index.go @@ -2,6 +2,7 @@ package keeper import ( "context" + "math" "cosmossdk.io/store/prefix" "github.com/babylonlabs-io/babylon/x/btcstaking/types" @@ -18,10 +19,10 @@ func (k Keeper) IndexBTCHeight(ctx context.Context) { } btcHeight := btcTip.Height store := k.btcHeightStore(ctx) - store.Set(sdk.Uint64ToBigEndian(babylonHeight), sdk.Uint64ToBigEndian(btcHeight)) + store.Set(sdk.Uint64ToBigEndian(babylonHeight), sdk.Uint64ToBigEndian(uint64(btcHeight))) } -func (k Keeper) GetBTCHeightAtBabylonHeight(ctx context.Context, babylonHeight uint64) uint64 { +func (k Keeper) GetBTCHeightAtBabylonHeight(ctx context.Context, babylonHeight uint64) uint32 { store := k.btcHeightStore(ctx) btcHeightBytes := store.Get(sdk.Uint64ToBigEndian(babylonHeight)) if len(btcHeightBytes) == 0 { @@ -29,10 +30,14 @@ func (k Keeper) GetBTCHeightAtBabylonHeight(ctx context.Context, babylonHeight u // use the base header return k.btclcKeeper.GetBaseBTCHeader(ctx).Height } - return sdk.BigEndianToUint64(btcHeightBytes) + btcHeightUint64 := sdk.BigEndianToUint64(btcHeightBytes) + if btcHeightUint64 > math.MaxUint32 { + panic("Storage involves a btc height that is larger than math.MaxUint32") + } + return uint32(btcHeightUint64) } -func (k Keeper) GetCurrentBTCHeight(ctx context.Context) uint64 { +func (k Keeper) GetCurrentBTCHeight(ctx context.Context) uint32 { babylonHeight := uint64(sdk.UnwrapSDKContext(ctx).HeaderInfo().Height) return k.GetBTCHeightAtBabylonHeight(ctx, babylonHeight) } diff --git a/x/btcstaking/keeper/btc_height_index_test.go b/x/btcstaking/keeper/btc_height_index_test.go index 98d432da5..594fb75ea 100644 --- a/x/btcstaking/keeper/btc_height_index_test.go +++ b/x/btcstaking/keeper/btc_height_index_test.go @@ -23,12 +23,12 @@ func FuzzBTCHeightIndex(f *testing.F) { // mock BTC light client btclcKeeper := types.NewMockBTCLightClientKeeper(ctrl) - keeper, _, ctx := keepertest.BTCStakingKeeper(t, btclcKeeper, nil, nil) + keeper, ctx := keepertest.BTCStakingKeeper(t, btclcKeeper, nil, nil) // randomise Babylon height and BTC height babylonHeight := datagen.RandomInt(r, 100) ctx = datagen.WithCtxHeight(ctx, babylonHeight) - btcHeight := datagen.RandomInt(r, 100) + btcHeight := uint32(datagen.RandomInt(r, 100)) btclcKeeper.EXPECT().GetTipInfo(gomock.Any()).Return(&btclctypes.BTCHeaderInfo{Height: btcHeight}).Times(1) keeper.IndexBTCHeight(ctx) diff --git a/x/btcstaking/keeper/btc_staking_consumer_events_test.go b/x/btcstaking/keeper/btc_staking_consumer_events_test.go index 91308d54d..eb1763ba5 100644 --- a/x/btcstaking/keeper/btc_staking_consumer_events_test.go +++ b/x/btcstaking/keeper/btc_staking_consumer_events_test.go @@ -4,8 +4,8 @@ import ( "math/rand" "testing" + testutil "github.com/babylonlabs-io/babylon/testutil/btcstaking-helper" "github.com/babylonlabs-io/babylon/testutil/datagen" - bbn "github.com/babylonlabs-io/babylon/types" "github.com/babylonlabs-io/babylon/x/btcstaking/types" bsctypes "github.com/babylonlabs-io/babylon/x/btcstkconsumer/types" "github.com/btcsuite/btcd/btcec/v2" @@ -24,7 +24,7 @@ func FuzzSetBTCStakingEventStore_NewFp(f *testing.F) { // mock BTC light client and BTC checkpoint modules btclcKeeper := types.NewMockBTCLightClientKeeper(ctrl) btccKeeper := types.NewMockBtcCheckpointKeeper(ctrl) - h := NewHelper(t, btclcKeeper, btccKeeper, nil) + h := testutil.NewHelper(t, btclcKeeper, btccKeeper) h.GenAndApplyParams(r) // register a random consumer on Babylon @@ -81,7 +81,7 @@ func FuzzSetBTCStakingEventStore_ActiveDel(f *testing.F) { // mock BTC light client and BTC checkpoint modules btclcKeeper := types.NewMockBTCLightClientKeeper(ctrl) btccKeeper := types.NewMockBtcCheckpointKeeper(ctrl) - h := NewHelper(t, btclcKeeper, btccKeeper, nil) + h := testutil.NewHelper(t, btclcKeeper, btccKeeper) // set all parameters covenantSKs, _ := h.GenAndApplyParams(r) @@ -98,19 +98,26 @@ func FuzzSetBTCStakingEventStore_ActiveDel(f *testing.F) { // generate and insert new BTC delegation, restake to 1 consumer fp and 1 babylon fp stakingValue := int64(2 * 10e8) - stakingTxHash, _, _, msgCreateBTCDel, _, err := h.CreateDelegation( + delSK, _, err := datagen.GenRandomBTCKeyPair(r) + h.NoError(err) + stakingTxHash, msgCreateBTCDel, _, _, _, _, err := h.CreateDelegation( r, + delSK, []*btcec.PublicKey{consumerFpPK, babylonFpPK}, changeAddress.EncodeAddress(), stakingValue, 1000, + 0, + 0, + false, + false, ) h.NoError(err) // delegation related assertions actualDel, err := h.BTCStakingKeeper.GetBTCDelegation(h.Ctx, stakingTxHash) h.NoError(err) - require.False(h.t, actualDel.HasCovenantQuorums(h.BTCStakingKeeper.GetParams(h.Ctx).CovenantQuorum)) + require.False(t, actualDel.HasCovenantQuorums(h.BTCStakingKeeper.GetParams(h.Ctx).CovenantQuorum)) // create cov sigs to activate the delegation msgs := h.GenerateCovenantSignaturesMessages(r, covenantSKs, msgCreateBTCDel, actualDel) bogusMsg := *msgs[0] @@ -120,15 +127,12 @@ func FuzzSetBTCStakingEventStore_ActiveDel(f *testing.F) { for _, msg := range msgs { _, err = h.MsgServer.AddCovenantSigs(h.Ctx, msg) h.NoError(err) - // check that submitting the same covenant signature does not produce an error - _, err = h.MsgServer.AddCovenantSigs(h.Ctx, msg) - h.NoError(err) } // ensure the BTC delegation now has voting power as it has been activated actualDel, err = h.BTCStakingKeeper.GetBTCDelegation(h.Ctx, stakingTxHash) h.NoError(err) - require.True(h.t, actualDel.HasCovenantQuorums(h.BTCStakingKeeper.GetParams(h.Ctx).CovenantQuorum)) - require.True(h.t, actualDel.BtcUndelegation.HasCovenantQuorums(h.BTCStakingKeeper.GetParams(h.Ctx).CovenantQuorum)) + require.True(t, actualDel.HasCovenantQuorums(h.BTCStakingKeeper.GetParams(h.Ctx).CovenantQuorum)) + require.True(t, actualDel.BtcUndelegation.HasCovenantQuorums(h.BTCStakingKeeper.GetParams(h.Ctx).CovenantQuorum)) votingPower := actualDel.VotingPower(h.BTCLightClientKeeper.GetTipInfo(h.Ctx).Height, h.BTCCheckpointKeeper.GetParams(h.Ctx).CheckpointFinalizationTimeout, h.BTCStakingKeeper.GetParams(h.Ctx).CovenantQuorum) require.Equal(t, uint64(stakingValue), votingPower) @@ -167,7 +171,7 @@ func FuzzSetBTCStakingEventStore_UnbondedDel(f *testing.F) { // mock BTC light client and BTC checkpoint modules btclcKeeper := types.NewMockBTCLightClientKeeper(ctrl) btccKeeper := types.NewMockBtcCheckpointKeeper(ctrl) - h := NewHelper(t, btclcKeeper, btccKeeper, nil) + h := testutil.NewHelper(t, btclcKeeper, btccKeeper) // set all parameters covenantSKs, _ := h.GenAndApplyParams(r) @@ -187,12 +191,19 @@ func FuzzSetBTCStakingEventStore_UnbondedDel(f *testing.F) { // generate and insert new BTC delegation stakingValue := int64(2 * 10e8) - stakingTxHash, delSK, _, msgCreateBTCDel, actualDel, err := h.CreateDelegation( + delSK, _, err := datagen.GenRandomBTCKeyPair(r) + h.NoError(err) + stakingTxHash, msgCreateBTCDel, actualDel, _, _, unbondingInfo, err := h.CreateDelegation( r, + delSK, []*btcec.PublicKey{consumerFpPK, babylonFpPK}, changeAddress.EncodeAddress(), stakingValue, 1000, + 0, + 0, + false, + false, ) h.NoError(err) @@ -207,12 +218,12 @@ func FuzzSetBTCStakingEventStore_UnbondedDel(f *testing.F) { require.Equal(t, types.BTCDelegationStatus_ACTIVE, status) // construct unbonding msg - delUnbondingSig, err := actualDel.SignUnbondingTx(&bsParams, h.Net, delSK) h.NoError(err) msg := &types.MsgBTCUndelegate{ - Signer: datagen.GenRandomAccount().Address, - StakingTxHash: stakingTxHash, - UnbondingTxSig: bbn.NewBIP340SignatureFromBTCSig(delUnbondingSig), + Signer: datagen.GenRandomAccount().Address, + StakingTxHash: stakingTxHash, + StakeSpendingTx: actualDel.BtcUndelegation.UnbondingTx, + StakeSpendingTxInclusionProof: unbondingInfo.UnbondingTxInclusionProof, } // ensure the system does not panic due to a bogus unbonding msg @@ -247,7 +258,6 @@ func FuzzSetBTCStakingEventStore_UnbondedDel(f *testing.F) { ev := evs.GetUnbondedDel()[0] require.NotNil(t, ev) require.Equal(t, actualDel.MustGetStakingTxHash().String(), ev.StakingTxHash) - require.Equal(t, actualDel.BtcUndelegation.DelegatorUnbondingSig.MustMarshal(), ev.UnbondingTxSig) }) } @@ -262,7 +272,7 @@ func FuzzDeleteBTCStakingEventStore(f *testing.F) { // mock BTC light client and BTC checkpoint modules btclcKeeper := types.NewMockBTCLightClientKeeper(ctrl) btccKeeper := types.NewMockBtcCheckpointKeeper(ctrl) - h := NewHelper(t, btclcKeeper, btccKeeper, nil) + h := testutil.NewHelper(t, btclcKeeper, btccKeeper) h.GenAndApplyParams(r) // register random number of consumers on Babylon @@ -300,7 +310,7 @@ func FuzzDeleteBTCStakingEventStore(f *testing.F) { } // helper function: register a random consumer on Babylon and verify the registration -func registerAndVerifyConsumer(t *testing.T, r *rand.Rand, h *Helper) *bsctypes.ConsumerRegister { +func registerAndVerifyConsumer(t *testing.T, r *rand.Rand, h *testutil.Helper) *bsctypes.ConsumerRegister { // Generate a random consumer register randomConsumer := datagen.GenRandomConsumerRegister(r) diff --git a/x/btcstaking/keeper/finality_providers.go b/x/btcstaking/keeper/finality_providers.go index 5507d8766..130874e9a 100644 --- a/x/btcstaking/keeper/finality_providers.go +++ b/x/btcstaking/keeper/finality_providers.go @@ -59,7 +59,7 @@ func (k Keeper) AddFinalityProvider(goCtx context.Context, msg *types.MsgCreateF } // notify subscriber - return ctx.EventManager().EmitTypedEvent(&types.EventNewFinalityProvider{Fp: &fp}) + return ctx.EventManager().EmitTypedEvent(types.NewEventFinalityProviderCreated(&fp)) } // setFinalityProvider adds the given finality provider to KVStore @@ -121,7 +121,7 @@ func (k Keeper) SlashFinalityProvider(ctx context.Context, fpBTCPK []byte) error // SlashConsumerFinalityProvider slashes a consumer finality provider with the given PK func (k Keeper) SlashConsumerFinalityProvider(ctx context.Context, consumerID string, fpBTCPK *bbn.BIP340PubKey) error { // Get consumer finality provider - fp, err := k.bscKeeper.GetConsumerFinalityProvider(ctx, consumerID, fpBTCPK) + fp, err := k.BscKeeper.GetConsumerFinalityProvider(ctx, consumerID, fpBTCPK) if err != nil { return err } @@ -138,7 +138,7 @@ func (k Keeper) SlashConsumerFinalityProvider(ctx context.Context, consumerID st return fmt.Errorf("failed to get current BTC tip") } fp.SlashedBtcHeight = btcTip.Height - k.bscKeeper.SetConsumerFinalityProvider(ctx, fp) + k.BscKeeper.SetConsumerFinalityProvider(ctx, fp) // Get all delegations for this consumer finality provider btcDels, err := k.GetFPBTCDelegations(ctx, fpBTCPK) @@ -229,7 +229,7 @@ func (k Keeper) collectSlashedConsumerEvents(ctx context.Context, delegations [] // If not in map, check if it's a Babylon FP or get its consumer if _, err := k.GetFinalityProvider(ctx, delegationFPBTCPK); err == nil { continue // It's a Babylon FP, skip - } else if consumerID, err = k.bscKeeper.GetConsumerOfFinalityProvider(ctx, &delegationFPBTCPK); err == nil { + } else if consumerID, err = k.BscKeeper.GetConsumerOfFinalityProvider(ctx, &delegationFPBTCPK); err == nil { // Found consumer, add to map fpToConsumerMap[fpBTCPKHex] = consumerID } else { diff --git a/x/btcstaking/keeper/genesis.go b/x/btcstaking/keeper/genesis.go index dc787b62a..faebc7ee2 100644 --- a/x/btcstaking/keeper/genesis.go +++ b/x/btcstaking/keeper/genesis.go @@ -3,8 +3,8 @@ package keeper import ( "context" "fmt" + "math" - btcstk "github.com/babylonlabs-io/babylon/btcstaking" bbn "github.com/babylonlabs-io/babylon/types" "github.com/babylonlabs-io/babylon/x/btcstaking/types" sdk "github.com/cosmos/cosmos-sdk/types" @@ -28,10 +28,6 @@ func (k Keeper) InitGenesis(ctx context.Context, gs types.GenesisState) error { k.setBTCDelegation(ctx, btcDel) } - for _, fpVP := range gs.VotingPowers { - k.SetVotingPower(ctx, *fpVP.FpBtcPk, fpVP.BlockHeight, fpVP.VotingPower) - } - for _, blocks := range gs.BlockHeightChains { k.setBlockHeightChains(ctx, blocks) } @@ -51,10 +47,6 @@ func (k Keeper) InitGenesis(ctx context.Context, gs types.GenesisState) error { } } - for _, vpCache := range gs.VpDstCache { - k.setVotingPowerDistCache(ctx, vpCache.BlockHeight, vpCache.VpDistribution) - } - return nil } @@ -70,11 +62,6 @@ func (k Keeper) ExportGenesis(ctx context.Context) (*types.GenesisState, error) return nil, err } - vpFps, err := k.fpVotingPowers(ctx) - if err != nil { - return nil, err - } - btcDels, err := k.btcDelegators(ctx) if err != nil { return nil, err @@ -85,20 +72,13 @@ func (k Keeper) ExportGenesis(ctx context.Context) (*types.GenesisState, error) return nil, err } - vpsCache, err := k.votingPowersDistCacheBlkHeight(ctx) - if err != nil { - return nil, err - } - return &types.GenesisState{ Params: k.GetAllParams(ctx), FinalityProviders: fps, BtcDelegations: dels, - VotingPowers: vpFps, BlockHeightChains: k.blockHeightChains(ctx), BtcDelegators: btcDels, Events: evts, - VpDstCache: vpsCache, }, nil } @@ -134,39 +114,19 @@ func (k Keeper) btcDelegations(ctx context.Context) ([]*types.BTCDelegation, err return dels, nil } -// fpVotingPowers gets the voting power of a given finality provider at a given Babylon height. -func (k Keeper) fpVotingPowers(ctx context.Context) ([]*types.VotingPowerFP, error) { - iter := k.votingPowerStore(ctx).Iterator(nil, nil) - defer iter.Close() - - vpFps := make([]*types.VotingPowerFP, 0) - - for ; iter.Valid(); iter.Next() { - blkHeight, fpBTCPK, err := btcstk.ParseBlkHeightAndPubKeyFromStoreKey(iter.Key()) - if err != nil { - return nil, err - } - - vp := sdk.BigEndianToUint64(iter.Value()) - vpFps = append(vpFps, &types.VotingPowerFP{ - BlockHeight: blkHeight, - FpBtcPk: fpBTCPK, - VotingPower: vp, - }) - } - - return vpFps, nil -} - func (k Keeper) blockHeightChains(ctx context.Context) []*types.BlockHeightBbnToBtc { iter := k.btcHeightStore(ctx).Iterator(nil, nil) defer iter.Close() blocks := make([]*types.BlockHeightBbnToBtc, 0) for ; iter.Valid(); iter.Next() { + blkHeightUint64 := sdk.BigEndianToUint64(iter.Value()) + if blkHeightUint64 > math.MaxUint32 { + panic("block height value in storage is larger than math.MaxUint64") + } blocks = append(blocks, &types.BlockHeightBbnToBtc{ BlockHeightBbn: sdk.BigEndianToUint64(iter.Key()), - BlockHeightBtc: sdk.BigEndianToUint64(iter.Value()), + BlockHeightBtc: uint32(blkHeightUint64), }) } @@ -227,28 +187,9 @@ func (k Keeper) eventIdxs( return evts, nil } -func (k Keeper) votingPowersDistCacheBlkHeight(ctx context.Context) ([]*types.VotingPowerDistCacheBlkHeight, error) { - vps := make([]*types.VotingPowerDistCacheBlkHeight, 0) - iter := k.votingPowerDistCacheStore(ctx).Iterator(nil, nil) - defer iter.Close() - - for ; iter.Valid(); iter.Next() { - var dc types.VotingPowerDistCache - if err := dc.Unmarshal(iter.Value()); err != nil { - return nil, err - } - vps = append(vps, &types.VotingPowerDistCacheBlkHeight{ - BlockHeight: sdk.BigEndianToUint64(iter.Key()), - VpDistribution: &dc, - }) - } - - return vps, nil -} - func (k Keeper) setBlockHeightChains(ctx context.Context, blocks *types.BlockHeightBbnToBtc) { store := k.btcHeightStore(ctx) - store.Set(sdk.Uint64ToBigEndian(blocks.BlockHeightBbn), sdk.Uint64ToBigEndian(blocks.BlockHeightBtc)) + store.Set(sdk.Uint64ToBigEndian(blocks.BlockHeightBbn), sdk.Uint64ToBigEndian(uint64(blocks.BlockHeightBtc))) } // setEventIdx sets an event into the store. @@ -269,13 +210,18 @@ func (k Keeper) setEventIdx( // parseUintsFromStoreKey expects to receive a key with // BigEndianUint64(blkHeight) || BigEndianUint64(Idx) -func parseUintsFromStoreKey(key []byte) (blkHeight, idx uint64, err error) { +func parseUintsFromStoreKey(key []byte) (blkHeight uint32, idx uint64, err error) { sizeBigEndian := 8 if len(key) < sizeBigEndian*2 { return 0, 0, fmt.Errorf("key not long enough to parse two uint64: %s", key) } - return sdk.BigEndianToUint64(key[:sizeBigEndian]), sdk.BigEndianToUint64(key[sizeBigEndian:]), nil + blkHeightUint64 := sdk.BigEndianToUint64(key[:sizeBigEndian]) + if blkHeightUint64 > math.MaxUint32 { + return 0, 0, fmt.Errorf("block height %d is larger than math.MaxUint32", blkHeightUint64) + } + idx = sdk.BigEndianToUint64(key[sizeBigEndian:]) + return uint32(blkHeightUint64), idx, nil } // parseBIP340PubKeysFromStoreKey expects to receive a key with diff --git a/x/btcstaking/keeper/genesis_test.go b/x/btcstaking/keeper/genesis_test.go index f9d5e7d0f..7300e7f31 100644 --- a/x/btcstaking/keeper/genesis_test.go +++ b/x/btcstaking/keeper/genesis_test.go @@ -20,7 +20,9 @@ func TestExportGenesis(t *testing.T) { fps := datagen.CreateNFinalityProviders(r, t, numFps) params := k.GetParams(ctx) - wValue := btcCheckK.GetParams(ctx).CheckpointFinalizationTimeout + btcckptParams := btcCheckK.GetParams(ctx) + + minUnbondingTime := types.MinimumUnbondingTime(¶ms, &btcckptParams) chainsHeight := make([]*types.BlockHeightBbnToBtc, 0) // creates the first as it starts already with an chain height from the helper. @@ -28,7 +30,6 @@ func TestExportGenesis(t *testing.T) { BlockHeightBbn: 1, BlockHeightBtc: 0, }) - vpFps := make(map[string]*types.VotingPowerFP, 0) btcDelegations := make([]*types.BTCDelegation, 0) eventsIdx := make(map[uint64]*types.EventIndex, 0) btcDelegatorIndex := make(map[string]*types.BTCDelegator, 0) @@ -38,7 +39,7 @@ func TestExportGenesis(t *testing.T) { for _, fp := range fps { btcHead := btclcK.GetTipInfo(ctx) - btcHead.Height = blkHeight + 100 + btcHead.Height = uint32(blkHeight + 100) btclcK.InsertHeaderInfos(ctx, []*btclightclientt.BTCHeaderInfo{ btcHead, }) @@ -56,21 +57,12 @@ func TestExportGenesis(t *testing.T) { int(numDelegations), params.CovenantQuorum, ) - vp := uint64(stakingValue) - - // sets voting power - k.SetVotingPower(ctx, *fp.BtcPk, blkHeight, vp) - vpFps[fp.BtcPk.MarshalHex()] = &types.VotingPowerFP{ - BlockHeight: blkHeight, - FpBtcPk: fp.BtcPk, - VotingPower: vp, - } for _, del := range delegations { totalDelegations++ // sets delegations - h.AddDelegation(del) + h.AddDelegation(del, minUnbondingTime) btcDelegations = append(btcDelegations, del) // BTC delegators idx @@ -99,7 +91,7 @@ func TestExportGenesis(t *testing.T) { idxEvent := uint64(totalDelegations - 1) eventsIdx[idxEvent] = &types.EventIndex{ Idx: idxEvent, - BlockHeightBtc: del.EndHeight - wValue, + BlockHeightBtc: del.EndHeight - minUnbondingTime, Event: unbondedEvent, } } @@ -149,12 +141,6 @@ func TestExportGenesis(t *testing.T) { } require.Equal(t, correctDels, len(btcDelegations)) - // voting powers - for _, gsFpVp := range gs.VotingPowers { - vp := vpFps[gsFpVp.FpBtcPk.MarshalHex()] - require.Equal(t, gsFpVp, vp) - } - // chains height require.Equal(t, chainsHeight, gs.BlockHeightChains) diff --git a/x/btcstaking/keeper/grpc_query.go b/x/btcstaking/keeper/grpc_query.go index 83a50285e..74df4c03f 100644 --- a/x/btcstaking/keeper/grpc_query.go +++ b/x/btcstaking/keeper/grpc_query.go @@ -34,8 +34,7 @@ func (k Keeper) FinalityProviders(c context.Context, req *types.QueryFinalityPro return err } - votingPower := k.GetVotingPower(ctx, key, currBlockHeight) - resp := types.NewFinalityProviderResponse(&fp, currBlockHeight, votingPower) + resp := types.NewFinalityProviderResponse(&fp, currBlockHeight) fpResp = append(fpResp, resp) return nil }) @@ -71,25 +70,24 @@ func (k Keeper) FinalityProvider(c context.Context, req *types.QueryFinalityProv fp, err := k.GetFinalityProvider(ctx, key) if err != nil { // Try in the btcstkconsumer module - if k.bscKeeper.HasConsumerFinalityProvider(ctx, fpPK) { - fpConsumer, err := k.bscKeeper.GetConsumerOfFinalityProvider(ctx, fpPK) + if k.BscKeeper.HasConsumerFinalityProvider(ctx, fpPK) { + fpConsumer, err := k.BscKeeper.GetConsumerOfFinalityProvider(ctx, fpPK) if err != nil { return nil, err } - fp, err := k.bscKeeper.GetConsumerFinalityProvider(ctx, fpConsumer, fpPK) + fp, err := k.BscKeeper.GetConsumerFinalityProvider(ctx, fpConsumer, fpPK) if err != nil { return nil, err } // FPs for consumers are not stored in the voting power table - fpResp := types.NewFinalityProviderResponse(fp, 0, 0) + fpResp := types.NewFinalityProviderResponse(fp, 0) return &types.QueryFinalityProviderResponse{FinalityProvider: fpResp}, nil } return nil, err } currBlockHeight := uint64(ctx.BlockHeight()) - votingPower := k.GetVotingPower(ctx, key, currBlockHeight) - fpResp := types.NewFinalityProviderResponse(fp, currBlockHeight, votingPower) + fpResp := types.NewFinalityProviderResponse(fp, currBlockHeight) return &types.QueryFinalityProviderResponse{FinalityProvider: fpResp}, nil } @@ -134,105 +132,6 @@ func (k Keeper) BTCDelegations(ctx context.Context, req *types.QueryBTCDelegatio }, nil } -// FinalityProviderPowerAtHeight returns the voting power of the specified finality provider -// at the provided Babylon height -func (k Keeper) FinalityProviderPowerAtHeight(ctx context.Context, req *types.QueryFinalityProviderPowerAtHeightRequest) (*types.QueryFinalityProviderPowerAtHeightResponse, error) { - if req == nil { - return nil, status.Error(codes.InvalidArgument, "empty request") - } - - fpBTCPK, err := bbn.NewBIP340PubKeyFromHex(req.FpBtcPkHex) - if err != nil { - return nil, status.Errorf(codes.InvalidArgument, "failed to unmarshal finality provider BTC PK hex: %v", err) - } - - if !k.HasFinalityProvider(ctx, *fpBTCPK) { - return nil, types.ErrFpNotFound - } - - store := k.votingPowerBbnBlockHeightStore(ctx, req.Height) - iter := store.ReverseIterator(nil, nil) - defer iter.Close() - - if !iter.Valid() { - return nil, types.ErrVotingPowerTableNotUpdated.Wrapf("height: %d", req.Height) - } - - sdkCtx := sdk.UnwrapSDKContext(ctx) - power := k.GetVotingPower(sdkCtx, fpBTCPK.MustMarshal(), req.Height) - - return &types.QueryFinalityProviderPowerAtHeightResponse{VotingPower: power}, nil -} - -// FinalityProviderCurrentPower returns the voting power of the specified finality provider -// at the current height -func (k Keeper) FinalityProviderCurrentPower(ctx context.Context, req *types.QueryFinalityProviderCurrentPowerRequest) (*types.QueryFinalityProviderCurrentPowerResponse, error) { - if req == nil { - return nil, status.Error(codes.InvalidArgument, "empty request") - } - - fpBTCPK, err := bbn.NewBIP340PubKeyFromHex(req.FpBtcPkHex) - if err != nil { - return nil, status.Errorf(codes.InvalidArgument, "failed to unmarshal finality provider BTC PK hex: %v", err) - } - - height, power := k.GetCurrentVotingPower(ctx, *fpBTCPK) - - return &types.QueryFinalityProviderCurrentPowerResponse{Height: height, VotingPower: power}, nil -} - -// ActiveFinalityProvidersAtHeight returns the active finality providers at the provided height -func (k Keeper) ActiveFinalityProvidersAtHeight(ctx context.Context, req *types.QueryActiveFinalityProvidersAtHeightRequest) (*types.QueryActiveFinalityProvidersAtHeightResponse, error) { - if req == nil { - return nil, status.Error(codes.InvalidArgument, "empty request") - } - - sdkCtx := sdk.UnwrapSDKContext(ctx) - store := k.votingPowerBbnBlockHeightStore(sdkCtx, req.Height) - - var finalityProvidersWithMeta []*types.FinalityProviderWithMeta - pageRes, err := query.Paginate(store, req.Pagination, func(key, value []byte) error { - finalityProvider, err := k.GetFinalityProvider(sdkCtx, key) - if err != nil { - return err - } - - votingPower := k.GetVotingPower(sdkCtx, key, req.Height) - if votingPower > 0 { - finalityProviderWithMeta := types.FinalityProviderWithMeta{ - BtcPk: finalityProvider.BtcPk, - Height: req.Height, - VotingPower: votingPower, - SlashedBabylonHeight: finalityProvider.SlashedBabylonHeight, - SlashedBtcHeight: finalityProvider.SlashedBtcHeight, - } - finalityProvidersWithMeta = append(finalityProvidersWithMeta, &finalityProviderWithMeta) - } - - return nil - }) - if err != nil { - return nil, err - } - - return &types.QueryActiveFinalityProvidersAtHeightResponse{FinalityProviders: finalityProvidersWithMeta, Pagination: pageRes}, nil -} - -// ActivatedHeight returns the Babylon height in which the BTC Staking protocol was enabled -// TODO: Requires investigation on whether we can enable the BTC staking protocol at genesis -func (k Keeper) ActivatedHeight(ctx context.Context, req *types.QueryActivatedHeightRequest) (*types.QueryActivatedHeightResponse, error) { - if req == nil { - return nil, status.Error(codes.InvalidArgument, "empty request") - } - - sdkCtx := sdk.UnwrapSDKContext(ctx) - activatedHeight, err := k.GetBTCStakingActivatedHeight(sdkCtx) - if err != nil { - return nil, err - } - return &types.QueryActivatedHeightResponse{Height: activatedHeight}, nil -} - // FinalityProviderDelegations returns all the delegations of the provided finality provider filtered by the provided status. func (k Keeper) FinalityProviderDelegations(ctx context.Context, req *types.QueryFinalityProviderDelegationsRequest) (*types.QueryFinalityProviderDelegationsResponse, error) { if req == nil { @@ -288,7 +187,7 @@ func (k Keeper) FinalityProviderDelegations(ctx context.Context, req *types.Quer if err != nil { return nil, err } - } else if k.bscKeeper.HasConsumerFinalityProvider(ctx, fpPK) { + } else if k.BscKeeper.HasConsumerFinalityProvider(ctx, fpPK) { // this is a consumer finality provider btcDels, pageRes, err = k.GetBTCConsumerDelegatorDelegationsResponses(sdkCtx, fpPK, req.Pagination, currentWValue, btcHeight, covenantQuorum) if err != nil { diff --git a/x/btcstaking/keeper/grpc_query_test.go b/x/btcstaking/keeper/grpc_query_test.go index d33f7073a..d80e7f89a 100644 --- a/x/btcstaking/keeper/grpc_query_test.go +++ b/x/btcstaking/keeper/grpc_query_test.go @@ -8,6 +8,7 @@ import ( sdkmath "cosmossdk.io/math" + "github.com/btcsuite/btcd/chaincfg" "github.com/btcsuite/btcd/txscript" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/query" @@ -23,30 +24,7 @@ import ( "github.com/babylonlabs-io/babylon/x/btcstaking/types" ) -func FuzzActivatedHeight(f *testing.F) { - datagen.AddRandomSeedsToFuzzer(f, 10) - f.Fuzz(func(t *testing.T, seed int64) { - r := rand.New(rand.NewSource(seed)) - - // Setup keeper and context - keeper, _, ctx := testkeeper.BTCStakingKeeper(t, nil, nil, nil) - ctx = sdk.UnwrapSDKContext(ctx) - - // not activated yet - _, err := keeper.GetBTCStakingActivatedHeight(ctx) - require.Error(t, err) - - randomActivatedHeight := datagen.RandomInt(r, 100) + 1 - fp, err := datagen.GenRandomFinalityProvider(r) - require.NoError(t, err) - keeper.SetVotingPower(ctx, fp.BtcPk.MustMarshal(), randomActivatedHeight, uint64(10)) - - // now it's activated - resp, err := keeper.ActivatedHeight(ctx, &types.QueryActivatedHeightRequest{}) - require.NoError(t, err) - require.Equal(t, randomActivatedHeight, resp.Height) - }) -} +var net = &chaincfg.SimNetParams func FuzzFinalityProviders(f *testing.F) { datagen.AddRandomSeedsToFuzzer(f, 10) @@ -54,7 +32,7 @@ func FuzzFinalityProviders(f *testing.F) { r := rand.New(rand.NewSource(seed)) // Setup keeper and context - keeper, _, ctx := testkeeper.BTCStakingKeeper(t, nil, nil, nil) + keeper, ctx := testkeeper.BTCStakingKeeper(t, nil, nil, nil) ctx = sdk.UnwrapSDKContext(ctx) // Generate random finality providers and add them to kv store @@ -119,7 +97,7 @@ func FuzzFinalityProvider(f *testing.F) { f.Fuzz(func(t *testing.T, seed int64) { r := rand.New(rand.NewSource(seed)) // Setup keeper and context - keeper, _, ctx := testkeeper.BTCStakingKeeper(t, nil, nil, nil) + keeper, ctx := testkeeper.BTCStakingKeeper(t, nil, nil, nil) ctx = sdk.UnwrapSDKContext(ctx) // Generate random finality providers and add them to kv store @@ -164,7 +142,7 @@ func FuzzFinalityProvider(f *testing.F) { }) } -func FuzzPendingBTCDelegations(f *testing.F) { +func FuzzFinalityProviderDelegations(f *testing.F) { datagen.AddRandomSeedsToFuzzer(f, 10) f.Fuzz(func(t *testing.T, seed int64) { r := rand.New(rand.NewSource(seed)) @@ -175,7 +153,7 @@ func FuzzPendingBTCDelegations(f *testing.F) { btclcKeeper := types.NewMockBTCLightClientKeeper(ctrl) btccKeeper := types.NewMockBtcCheckpointKeeper(ctrl) btccKeeper.EXPECT().GetParams(gomock.Any()).Return(btcctypes.DefaultParams()).AnyTimes() - keeper, _, ctx := testkeeper.BTCStakingKeeper(t, btclcKeeper, btccKeeper, nil) + keeper, ctx := testkeeper.BTCStakingKeeper(t, btclcKeeper, btccKeeper, nil) // covenant and slashing addr covenantSKs, covenantPKs, covenantQuorum := datagen.GenCovenantCommittee(r) @@ -192,183 +170,95 @@ func FuzzPendingBTCDelegations(f *testing.F) { // this is already covered in FuzzGeneratingValidStakingSlashingTx slashingRate := sdkmath.LegacyNewDecWithPrec(int64(datagen.RandomInt(r, 41)+10), 2) - // Generate a random number of finality providers - numFps := datagen.RandomInt(r, 5) + 1 - fps := []*types.FinalityProvider{} - for i := uint64(0); i < numFps; i++ { - fp, err := datagen.GenRandomFinalityProvider(r) - require.NoError(t, err) - AddFinalityProvider(t, ctx, *keeper, fp) - fps = append(fps, fp) - } + // Generate a finality provider + fp, err := datagen.GenRandomFinalityProvider(r) + require.NoError(t, err) + AddFinalityProvider(t, ctx, *keeper, fp) - // Generate a random number of BTC delegations under each finality provider - startHeight := datagen.RandomInt(r, 100) + 1 + startHeight := uint32(datagen.RandomInt(r, 100)) + 1 + endHeight := uint32(datagen.RandomInt(r, 1000)) + startHeight + btcctypes.DefaultParams().CheckpointFinalizationTimeout + 1 + stakingTime := endHeight - startHeight btclcKeeper.EXPECT().GetTipInfo(gomock.Any()).Return(&btclctypes.BTCHeaderInfo{Height: startHeight}).AnyTimes() - - endHeight := datagen.RandomInt(r, 1000) + startHeight + btcctypes.DefaultParams().CheckpointFinalizationTimeout + 1 + // Generate a random number of BTC delegations under this finality provider numBTCDels := datagen.RandomInt(r, 10) + 1 - pendingBtcDelsMap := make(map[string]*types.BTCDelegation) - for _, fp := range fps { - for j := uint64(0); j < numBTCDels; j++ { - delSK, _, err := datagen.GenRandomBTCKeyPair(r) - require.NoError(t, err) - btcDel, err := datagen.GenRandomBTCDelegation( - r, - t, - net, - []bbn.BIP340PubKey{*fp.BtcPk}, - delSK, - covenantSKs, - covenantPKs, - covenantQuorum, - slashingPkScript, - startHeight, endHeight, 10000, - slashingRate, - slashingChangeLockTime, - ) - require.NoError(t, err) - if datagen.RandomInt(r, 2) == 1 { - // remove covenant sig in random BTC delegations to make them inactive - btcDel.CovenantSigs = nil - pendingBtcDelsMap[btcDel.BtcPk.MarshalHex()] = btcDel - } - err = keeper.AddBTCDelegation(ctx, btcDel) - require.NoError(t, err) - - txHash := btcDel.MustGetStakingTxHash().String() - delView, err := keeper.BTCDelegation(ctx, &types.QueryBTCDelegationRequest{ - StakingTxHashHex: txHash, - }) - require.NoError(t, err) - require.NotNil(t, delView) - } + expectedBtcDelsMap := make(map[string]*types.BTCDelegation) + for j := uint64(0); j < numBTCDels; j++ { + delSK, _, err := datagen.GenRandomBTCKeyPair(r) + require.NoError(t, err) + btcDel, err := datagen.GenRandomBTCDelegation( + r, + t, + net, + []bbn.BIP340PubKey{*fp.BtcPk}, + delSK, + covenantSKs, + covenantPKs, + covenantQuorum, + slashingPkScript, + stakingTime, startHeight, endHeight, 10000, + slashingRate, + slashingChangeLockTime, + ) + require.NoError(t, err) + expectedBtcDelsMap[btcDel.BtcPk.MarshalHex()] = btcDel + err = keeper.AddBTCDelegation(ctx, btcDel, btcDel.UnbondingTime-1) + require.NoError(t, err) } + // Test nil request + resp, err := keeper.FinalityProviderDelegations(ctx, nil) + require.Nil(t, resp) + require.Error(t, err) + babylonHeight := datagen.RandomInt(r, 10) + 1 ctx = datagen.WithCtxHeight(ctx, babylonHeight) + keeper.IndexBTCHeight(ctx) - // querying paginated BTC delegations and assert // Generate a page request with a limit and a nil key - if len(pendingBtcDelsMap) == 0 { - return - } - limit := datagen.RandomInt(r, len(pendingBtcDelsMap)) + 1 + // query a page of BTC delegations and assert consistency + limit := datagen.RandomInt(r, len(expectedBtcDelsMap)) + 1 + + // FinalityProviderDelegations loads status, which calls GetTipInfo + btclcKeeper.EXPECT().GetTipInfo(gomock.Any()).Return(&btclctypes.BTCHeaderInfo{Height: startHeight}).AnyTimes() + + keeper.IndexBTCHeight(ctx) + pagination := constructRequestWithLimit(r, limit) - req := &types.QueryBTCDelegationsRequest{ - Status: types.BTCDelegationStatus_PENDING, + // Generate the initial query + req := types.QueryFinalityProviderDelegationsRequest{ + FpBtcPkHex: fp.BtcPk.MarshalHex(), Pagination: pagination, } + // Construct a mapping from the finality providers found to a boolean value + // Will be used later to evaluate whether all the finality providers were returned + btcDelsFound := make(map[string]bool, 0) + for i := uint64(0); i < numBTCDels; i += limit { - resp, err := keeper.BTCDelegations(ctx, req) + resp, err = keeper.FinalityProviderDelegations(ctx, &req) require.NoError(t, err) require.NotNil(t, resp) - for _, btcDel := range resp.BtcDelegations { - _, ok := pendingBtcDelsMap[btcDel.BtcPk.MarshalHex()] + for _, btcDels := range resp.BtcDelegatorDelegations { + require.Len(t, btcDels.Dels, 1) + btcDel := btcDels.Dels[0] + require.Equal(t, fp.BtcPk, &btcDel.FpBtcPkList[0]) + // Check if the pk exists in the map + _, ok := expectedBtcDelsMap[btcDel.BtcPk.MarshalHex()] require.True(t, ok) + btcDelsFound[btcDel.BtcPk.MarshalHex()] = true } // Construct the next page request - pagination.Key = resp.Pagination.NextKey - } - }) -} - -func FuzzFinalityProviderPowerAtHeight(f *testing.F) { - datagen.AddRandomSeedsToFuzzer(f, 10) - f.Fuzz(func(t *testing.T, seed int64) { - r := rand.New(rand.NewSource(seed)) - - // Setup keeper and context - keeper, _, ctx := testkeeper.BTCStakingKeeper(t, nil, nil, nil) - - // random finality provider - fp, err := datagen.GenRandomFinalityProvider(r) - require.NoError(t, err) - // add this finality provider - AddFinalityProvider(t, ctx, *keeper, fp) - // set random voting power at random height - randomHeight := datagen.RandomInt(r, 100) + 1 - randomPower := datagen.RandomInt(r, 100) + 1 - keeper.SetVotingPower(ctx, fp.BtcPk.MustMarshal(), randomHeight, randomPower) - - // happy case - req1 := &types.QueryFinalityProviderPowerAtHeightRequest{ - FpBtcPkHex: fp.BtcPk.MarshalHex(), - Height: randomHeight, - } - resp, err := keeper.FinalityProviderPowerAtHeight(ctx, req1) - require.NoError(t, err) - require.Equal(t, randomPower, resp.VotingPower) - - // case where the voting power store is not updated in - // the given height - requestHeight := randomHeight + datagen.RandomInt(r, 10) + 1 - req2 := &types.QueryFinalityProviderPowerAtHeightRequest{ - FpBtcPkHex: fp.BtcPk.MarshalHex(), - Height: requestHeight, - } - _, err = keeper.FinalityProviderPowerAtHeight(ctx, req2) - require.ErrorIs(t, err, types.ErrVotingPowerTableNotUpdated) - - // case where the given fp pk does not exist - randPk, err := datagen.GenRandomBIP340PubKey(r) - require.NoError(t, err) - req3 := &types.QueryFinalityProviderPowerAtHeightRequest{ - FpBtcPkHex: randPk.MarshalHex(), - Height: randomHeight, - } - _, err = keeper.FinalityProviderPowerAtHeight(ctx, req3) - require.ErrorIs(t, err, types.ErrFpNotFound) - }) -} - -func FuzzFinalityProviderCurrentVotingPower(f *testing.F) { - datagen.AddRandomSeedsToFuzzer(f, 10) - f.Fuzz(func(t *testing.T, seed int64) { - r := rand.New(rand.NewSource(seed)) - - // Setup keeper and context - keeper, _, ctx := testkeeper.BTCStakingKeeper(t, nil, nil, nil) - - // random finality provider - fp, err := datagen.GenRandomFinalityProvider(r) - require.NoError(t, err) - // add this finality provider - AddFinalityProvider(t, ctx, *keeper, fp) - // set random voting power at random height - randomHeight := datagen.RandomInt(r, 100) + 1 - ctx = datagen.WithCtxHeight(ctx, randomHeight) - randomPower := datagen.RandomInt(r, 100) + 1 - keeper.SetVotingPower(ctx, fp.BtcPk.MustMarshal(), randomHeight, randomPower) - - // assert voting power at current height - req := &types.QueryFinalityProviderCurrentPowerRequest{ - FpBtcPkHex: fp.BtcPk.MarshalHex(), + pagination = constructRequestWithKeyAndLimit(r, resp.Pagination.NextKey, limit) + req = types.QueryFinalityProviderDelegationsRequest{ + FpBtcPkHex: fp.BtcPk.MarshalHex(), + Pagination: pagination, + } } - resp, err := keeper.FinalityProviderCurrentPower(ctx, req) - require.NoError(t, err) - require.Equal(t, randomHeight, resp.Height) - require.Equal(t, randomPower, resp.VotingPower) - - // if height increments but voting power hasn't recorded yet, then - // we need to return the height and voting power at the last height - ctx = datagen.WithCtxHeight(ctx, randomHeight+1) - resp, err = keeper.FinalityProviderCurrentPower(ctx, req) - require.NoError(t, err) - require.Equal(t, randomHeight, resp.Height) - require.Equal(t, randomPower, resp.VotingPower) + require.Equal(t, len(btcDelsFound), len(expectedBtcDelsMap)) - // test the case when the finality provider has 0 voting power - ctx = datagen.WithCtxHeight(ctx, randomHeight+2) - keeper.SetVotingPower(ctx, fp.BtcPk.MustMarshal(), randomHeight+2, 0) - resp, err = keeper.FinalityProviderCurrentPower(ctx, req) - require.NoError(t, err) - require.Equal(t, randomHeight+2, resp.Height) - require.Equal(t, uint64(0), resp.VotingPower) }) } -func FuzzActiveFinalityProvidersAtHeight(f *testing.F) { +func FuzzPendingBTCDelegations(f *testing.F) { datagen.AddRandomSeedsToFuzzer(f, 10) f.Fuzz(func(t *testing.T, seed int64) { r := rand.New(rand.NewSource(seed)) @@ -377,10 +267,9 @@ func FuzzActiveFinalityProvidersAtHeight(f *testing.F) { // Setup keeper and context btclcKeeper := types.NewMockBTCLightClientKeeper(ctrl) - btclcKeeper.EXPECT().GetTipInfo(gomock.Any()).Return(&btclctypes.BTCHeaderInfo{Height: 10}).AnyTimes() btccKeeper := types.NewMockBtcCheckpointKeeper(ctrl) btccKeeper.EXPECT().GetParams(gomock.Any()).Return(btcctypes.DefaultParams()).AnyTimes() - keeper, _, ctx := testkeeper.BTCStakingKeeper(t, btclcKeeper, btccKeeper, nil) + keeper, ctx := testkeeper.BTCStakingKeeper(t, btclcKeeper, btccKeeper, nil) // covenant and slashing addr covenantSKs, covenantPKs, covenantQuorum := datagen.GenCovenantCommittee(r) @@ -397,10 +286,9 @@ func FuzzActiveFinalityProvidersAtHeight(f *testing.F) { // this is already covered in FuzzGeneratingValidStakingSlashingTx slashingRate := sdkmath.LegacyNewDecWithPrec(int64(datagen.RandomInt(r, 41)+10), 2) - // Generate a random batch of finality providers - var fps []*types.FinalityProvider - numFpsWithVotingPower := datagen.RandomInt(r, 10) + 1 - numFps := numFpsWithVotingPower + datagen.RandomInt(r, 10) + // Generate a random number of finality providers + numFps := datagen.RandomInt(r, 5) + 1 + fps := []*types.FinalityProvider{} for i := uint64(0); i < numFps; i++ { fp, err := datagen.GenRandomFinalityProvider(r) require.NoError(t, err) @@ -408,199 +296,80 @@ func FuzzActiveFinalityProvidersAtHeight(f *testing.F) { fps = append(fps, fp) } - // For numFpsWithVotingPower finality providers, generate a random number of BTC delegations - numBTCDels := datagen.RandomInt(r, 10) + 1 - babylonHeight := datagen.RandomInt(r, 10) + 1 - fpsWithVotingPowerMap := make(map[string]*types.FinalityProvider) - for i := uint64(0); i < numFpsWithVotingPower; i++ { - fpBTCPK := fps[i].BtcPk - fpsWithVotingPowerMap[fpBTCPK.MarshalHex()] = fps[i] + // Generate a random number of BTC delegations under each finality provider + startHeight := uint32(datagen.RandomInt(r, 100)) + 1 + btclcKeeper.EXPECT().GetTipInfo(gomock.Any()).Return(&btclctypes.BTCHeaderInfo{Height: startHeight}).AnyTimes() - var totalVotingPower uint64 + endHeight := uint32(datagen.RandomInt(r, 1000)) + startHeight + btcctypes.DefaultParams().CheckpointFinalizationTimeout + 1 + stakingTime := endHeight - startHeight + numBTCDels := datagen.RandomInt(r, 10) + 1 + pendingBtcDelsMap := make(map[string]*types.BTCDelegation) + for _, fp := range fps { for j := uint64(0); j < numBTCDels; j++ { delSK, _, err := datagen.GenRandomBTCKeyPair(r) require.NoError(t, err) + // 0.5 chance that the delegation is created via pre-approval flow + if r.Intn(2) == 0 { + startHeight, endHeight = 0, 0 + } btcDel, err := datagen.GenRandomBTCDelegation( r, t, net, - []bbn.BIP340PubKey{*fpBTCPK}, + []bbn.BIP340PubKey{*fp.BtcPk}, delSK, covenantSKs, covenantPKs, covenantQuorum, slashingPkScript, - 1, 1000, 10000, + stakingTime, startHeight, endHeight, 10000, slashingRate, slashingChangeLockTime, ) require.NoError(t, err) - err = keeper.AddBTCDelegation(ctx, btcDel) + if datagen.RandomInt(r, 2) == 1 { + // remove covenant sig in random BTC delegations to make them inactive + btcDel.CovenantSigs = nil + pendingBtcDelsMap[btcDel.BtcPk.MarshalHex()] = btcDel + } + err = keeper.AddBTCDelegation(ctx, btcDel, btcDel.UnbondingTime-1) require.NoError(t, err) - totalVotingPower += btcDel.TotalSat - } - - keeper.SetVotingPower(ctx, fpBTCPK.MustMarshal(), babylonHeight, totalVotingPower) - } - - // Test nil request - resp, err := keeper.ActiveFinalityProvidersAtHeight(ctx, nil) - if resp != nil { - t.Errorf("Nil input led to a non-nil response") - } - if err == nil { - t.Errorf("Nil input led to a nil error") - } - - // Generate a page request with a limit and a nil key - limit := datagen.RandomInt(r, int(numFpsWithVotingPower)) + 1 - pagination := constructRequestWithLimit(r, limit) - // Generate the initial query - req := types.QueryActiveFinalityProvidersAtHeightRequest{Height: babylonHeight, Pagination: pagination} - // Construct a mapping from the finality providers found to a boolean value - // Will be used later to evaluate whether all the finality providers were returned - fpsFound := make(map[string]bool, 0) - - for i := uint64(0); i < numFpsWithVotingPower; i += limit { - resp, err = keeper.ActiveFinalityProvidersAtHeight(ctx, &req) - if err != nil { - t.Errorf("Valid request led to an error %s", err) - } - if resp == nil { - t.Fatalf("Valid request led to a nil response") - } - for _, fp := range resp.FinalityProviders { - // Check if the pk exists in the map - if _, ok := fpsWithVotingPowerMap[fp.BtcPk.MarshalHex()]; !ok { - t.Fatalf("rpc returned a finality provider that was not created") - } - fpsFound[fp.BtcPk.MarshalHex()] = true + txHash := btcDel.MustGetStakingTxHash().String() + delView, err := keeper.BTCDelegation(ctx, &types.QueryBTCDelegationRequest{ + StakingTxHashHex: txHash, + }) + require.NoError(t, err) + require.NotNil(t, delView) } - - // Construct the next page request - pagination = constructRequestWithKeyAndLimit(r, resp.Pagination.NextKey, limit) - req = types.QueryActiveFinalityProvidersAtHeightRequest{Height: babylonHeight, Pagination: pagination} - } - - if len(fpsFound) != len(fpsWithVotingPowerMap) { - t.Errorf("Some finality providers were missed. Got %d while %d were expected", len(fpsFound), len(fpsWithVotingPowerMap)) - } - }) -} - -func FuzzFinalityProviderDelegations(f *testing.F) { - datagen.AddRandomSeedsToFuzzer(f, 10) - f.Fuzz(func(t *testing.T, seed int64) { - r := rand.New(rand.NewSource(seed)) - ctrl := gomock.NewController(t) - defer ctrl.Finish() - - // Setup keeper and context - btclcKeeper := types.NewMockBTCLightClientKeeper(ctrl) - btccKeeper := types.NewMockBtcCheckpointKeeper(ctrl) - btccKeeper.EXPECT().GetParams(gomock.Any()).Return(btcctypes.DefaultParams()).AnyTimes() - keeper, _, ctx := testkeeper.BTCStakingKeeper(t, btclcKeeper, btccKeeper, nil) - - // covenant and slashing addr - covenantSKs, covenantPKs, covenantQuorum := datagen.GenCovenantCommittee(r) - slashingAddress, err := datagen.GenRandomBTCAddress(r, net) - require.NoError(t, err) - slashingPkScript, err := txscript.PayToAddrScript(slashingAddress) - require.NoError(t, err) - slashingChangeLockTime := uint16(101) - - // Generate a slashing rate in the range [0.1, 0.50] i.e., 10-50%. - // NOTE - if the rate is higher or lower, it may produce slashing or change outputs - // with value below the dust threshold, causing test failure. - // Our goal is not to test failure due to such extreme cases here; - // this is already covered in FuzzGeneratingValidStakingSlashingTx - slashingRate := sdkmath.LegacyNewDecWithPrec(int64(datagen.RandomInt(r, 41)+10), 2) - - // Generate a finality provider - fp, err := datagen.GenRandomFinalityProvider(r) - require.NoError(t, err) - AddFinalityProvider(t, ctx, *keeper, fp) - - startHeight := datagen.RandomInt(r, 100) + 1 - endHeight := datagen.RandomInt(r, 1000) + startHeight + btcctypes.DefaultParams().CheckpointFinalizationTimeout + 1 - btclcKeeper.EXPECT().GetTipInfo(gomock.Any()).Return(&btclctypes.BTCHeaderInfo{Height: startHeight}).AnyTimes() - // Generate a random number of BTC delegations under this finality provider - numBTCDels := datagen.RandomInt(r, 10) + 1 - expectedBtcDelsMap := make(map[string]*types.BTCDelegation) - for j := uint64(0); j < numBTCDels; j++ { - delSK, _, err := datagen.GenRandomBTCKeyPair(r) - require.NoError(t, err) - btcDel, err := datagen.GenRandomBTCDelegation( - r, - t, - net, - []bbn.BIP340PubKey{*fp.BtcPk}, - delSK, - covenantSKs, - covenantPKs, - covenantQuorum, - slashingPkScript, - startHeight, endHeight, 10000, - slashingRate, - slashingChangeLockTime, - ) - require.NoError(t, err) - expectedBtcDelsMap[btcDel.BtcPk.MarshalHex()] = btcDel - err = keeper.AddBTCDelegation(ctx, btcDel) - require.NoError(t, err) } - // Test nil request - resp, err := keeper.FinalityProviderDelegations(ctx, nil) - require.Nil(t, resp) - require.Error(t, err) - babylonHeight := datagen.RandomInt(r, 10) + 1 ctx = datagen.WithCtxHeight(ctx, babylonHeight) - keeper.IndexBTCHeight(ctx) + // querying paginated BTC delegations and assert // Generate a page request with a limit and a nil key - // query a page of BTC delegations and assert consistency - limit := datagen.RandomInt(r, len(expectedBtcDelsMap)) + 1 - - // FinalityProviderDelegations loads status, which calls GetTipInfo - btclcKeeper.EXPECT().GetTipInfo(gomock.Any()).Return(&btclctypes.BTCHeaderInfo{Height: startHeight}).AnyTimes() - - keeper.IndexBTCHeight(ctx) - + if len(pendingBtcDelsMap) == 0 { + return + } + limit := datagen.RandomInt(r, len(pendingBtcDelsMap)) + 1 pagination := constructRequestWithLimit(r, limit) - // Generate the initial query - req := types.QueryFinalityProviderDelegationsRequest{ - FpBtcPkHex: fp.BtcPk.MarshalHex(), + req := &types.QueryBTCDelegationsRequest{ + Status: types.BTCDelegationStatus_PENDING, Pagination: pagination, } - // Construct a mapping from the finality providers found to a boolean value - // Will be used later to evaluate whether all the finality providers were returned - btcDelsFound := make(map[string]bool, 0) - for i := uint64(0); i < numBTCDels; i += limit { - resp, err = keeper.FinalityProviderDelegations(ctx, &req) + resp, err := keeper.BTCDelegations(ctx, req) require.NoError(t, err) require.NotNil(t, resp) - for _, btcDels := range resp.BtcDelegatorDelegations { - require.Len(t, btcDels.Dels, 1) - btcDel := btcDels.Dels[0] - require.Equal(t, fp.BtcPk, &btcDel.FpBtcPkList[0]) - // Check if the pk exists in the map - _, ok := expectedBtcDelsMap[btcDel.BtcPk.MarshalHex()] + for _, btcDel := range resp.BtcDelegations { + _, ok := pendingBtcDelsMap[btcDel.BtcPk.MarshalHex()] require.True(t, ok) - btcDelsFound[btcDel.BtcPk.MarshalHex()] = true + require.Equal(t, stakingTime, btcDel.StakingTime) } // Construct the next page request - pagination = constructRequestWithKeyAndLimit(r, resp.Pagination.NextKey, limit) - req = types.QueryFinalityProviderDelegationsRequest{ - FpBtcPkHex: fp.BtcPk.MarshalHex(), - Pagination: pagination, - } + pagination.Key = resp.Pagination.NextKey } - require.Equal(t, len(btcDelsFound), len(expectedBtcDelsMap)) - }) } diff --git a/x/btcstaking/keeper/hooks.go b/x/btcstaking/keeper/hooks.go deleted file mode 100644 index b4d93cefe..000000000 --- a/x/btcstaking/keeper/hooks.go +++ /dev/null @@ -1,25 +0,0 @@ -package keeper - -import ( - "context" - - bbntypes "github.com/babylonlabs-io/babylon/types" - "github.com/babylonlabs-io/babylon/x/finality/types" -) - -var _ types.FinalityHooks = Hooks{} - -// Hooks wrapper struct for BTC staking keeper -type Hooks struct { - k Keeper -} - -// Return the finality hooks -func (k Keeper) Hooks() Hooks { - return Hooks{k} -} - -// AfterSluggishFinalityProviderDetected updates the status of the given finality provider to `sluggish` -func (h Hooks) AfterSluggishFinalityProviderDetected(ctx context.Context, fpPk *bbntypes.BIP340PubKey) error { - return h.k.JailFinalityProvider(ctx, fpPk.MustMarshal()) -} diff --git a/x/btcstaking/keeper/incentive.go b/x/btcstaking/keeper/incentive.go deleted file mode 100644 index ac65638b9..000000000 --- a/x/btcstaking/keeper/incentive.go +++ /dev/null @@ -1,48 +0,0 @@ -package keeper - -import ( - "context" - - "cosmossdk.io/store/prefix" - "github.com/babylonlabs-io/babylon/x/btcstaking/types" - "github.com/cosmos/cosmos-sdk/runtime" - sdk "github.com/cosmos/cosmos-sdk/types" -) - -func (k Keeper) setVotingPowerDistCache(ctx context.Context, height uint64, dc *types.VotingPowerDistCache) { - store := k.votingPowerDistCacheStore(ctx) - store.Set(sdk.Uint64ToBigEndian(height), k.cdc.MustMarshal(dc)) -} - -func (k Keeper) getVotingPowerDistCache(ctx context.Context, height uint64) *types.VotingPowerDistCache { - store := k.votingPowerDistCacheStore(ctx) - rdcBytes := store.Get(sdk.Uint64ToBigEndian(height)) - if len(rdcBytes) == 0 { - return nil - } - var dc types.VotingPowerDistCache - k.cdc.MustUnmarshal(rdcBytes, &dc) - return &dc -} - -func (k Keeper) GetVotingPowerDistCache(ctx context.Context, height uint64) (*types.VotingPowerDistCache, error) { - dc := k.getVotingPowerDistCache(ctx, height) - if dc == nil { - return nil, types.ErrVotingPowerDistCacheNotFound - } - return dc, nil -} - -func (k Keeper) RemoveVotingPowerDistCache(ctx context.Context, height uint64) { - store := k.votingPowerDistCacheStore(ctx) - store.Delete(sdk.Uint64ToBigEndian(height)) -} - -// votingPowerDistCacheStore returns the KVStore of the voting power distribution cache -// prefix: VotingPowerDistCacheKey -// key: Babylon block height -// value: VotingPowerDistCache -func (k Keeper) votingPowerDistCacheStore(ctx context.Context) prefix.Store { - storeAdapter := runtime.KVStoreAdapter(k.storeService.OpenKVStore(ctx)) - return prefix.NewStore(storeAdapter, types.VotingPowerDistCacheKey) -} diff --git a/x/btcstaking/keeper/incentive_test.go b/x/btcstaking/keeper/incentive_test.go deleted file mode 100644 index 76a6dd55b..000000000 --- a/x/btcstaking/keeper/incentive_test.go +++ /dev/null @@ -1,90 +0,0 @@ -package keeper_test - -import ( - "math/rand" - "testing" - - "github.com/btcsuite/btcd/btcec/v2" - "github.com/golang/mock/gomock" - "github.com/stretchr/testify/require" - - "github.com/babylonlabs-io/babylon/testutil/datagen" - btclctypes "github.com/babylonlabs-io/babylon/x/btclightclient/types" - "github.com/babylonlabs-io/babylon/x/btcstaking/types" -) - -func FuzzRecordVotingPowerDistCache(f *testing.F) { - datagen.AddRandomSeedsToFuzzer(f, 10) - - f.Fuzz(func(t *testing.T, seed int64) { - r := rand.New(rand.NewSource(seed)) - ctrl := gomock.NewController(t) - defer ctrl.Finish() - - // mock BTC light client and BTC checkpoint modules - btclcKeeper := types.NewMockBTCLightClientKeeper(ctrl) - btccKeeper := types.NewMockBtcCheckpointKeeper(ctrl) - finalityKeeper := types.NewMockFinalityKeeper(ctrl) - finalityKeeper.EXPECT().HasTimestampedPubRand(gomock.Any(), gomock.Any(), gomock.Any()).Return(true).AnyTimes() - h := NewHelper(t, btclcKeeper, btccKeeper, finalityKeeper) - - // set all parameters - covenantSKs, _ := h.GenAndApplyParams(r) - changeAddress, err := datagen.GenRandomBTCAddress(r, h.Net) - h.NoError(err) - - // generate a random batch of finality providers - numFpsWithVotingPower := datagen.RandomInt(r, 10) + 2 - numFps := numFpsWithVotingPower + datagen.RandomInt(r, 10) - fpsWithVotingPowerMap := map[string]*types.FinalityProvider{} - for i := uint64(0); i < numFps; i++ { - _, _, fp := h.CreateFinalityProvider(r) - if i < numFpsWithVotingPower { - // these finality providers will receive BTC delegations and have voting power - fpsWithVotingPowerMap[fp.Addr] = fp - } - } - - // for the first numFpsWithVotingPower finality providers, generate a random number of BTC - // delegations and add covenant signatures to activate them - numBTCDels := datagen.RandomInt(r, 10) + 1 - stakingValue := datagen.RandomInt(r, 100000) + 100000 - for _, fp := range fpsWithVotingPowerMap { - for j := uint64(0); j < numBTCDels; j++ { - _, _, _, delMsg, del, err := h.CreateDelegation( - r, - []*btcec.PublicKey{fp.BtcPk.MustToBTCPK()}, - changeAddress.EncodeAddress(), - int64(stakingValue), - 1000, - ) - h.NoError(err) - h.CreateCovenantSigs(r, covenantSKs, delMsg, del) - } - } - - // record voting power distribution cache - babylonHeight := datagen.RandomInt(r, 10) + 1 - h.Ctx = datagen.WithCtxHeight(h.Ctx, babylonHeight) - h.BTCLightClientKeeper.EXPECT().GetTipInfo(gomock.Eq(h.Ctx)).Return(&btclctypes.BTCHeaderInfo{Height: 30}).AnyTimes() - err = h.BTCStakingKeeper.BeginBlocker(h.Ctx) - require.NoError(t, err) - - // assert voting power distribution cache is correct - dc, err := h.BTCStakingKeeper.GetVotingPowerDistCache(h.Ctx, babylonHeight) - require.NoError(t, err) - require.NotNil(t, dc) - require.Equal(t, dc.TotalVotingPower, numFpsWithVotingPower*numBTCDels*stakingValue) - activeFPs := dc.GetActiveFinalityProviderSet() - for _, fpDistInfo := range activeFPs { - require.Equal(t, fpDistInfo.TotalVotingPower, numBTCDels*stakingValue) - fp, ok := fpsWithVotingPowerMap[fpDistInfo.Addr] - require.True(t, ok) - require.Equal(t, fpDistInfo.Commission, fp.Commission) - require.Len(t, fpDistInfo.BtcDels, int(numBTCDels)) - for _, delDistInfo := range fpDistInfo.BtcDels { - require.Equal(t, delDistInfo.VotingPower, stakingValue) - } - } - }) -} diff --git a/x/btcstaking/keeper/inclusion_proof.go b/x/btcstaking/keeper/inclusion_proof.go new file mode 100644 index 000000000..acedcba29 --- /dev/null +++ b/x/btcstaking/keeper/inclusion_proof.go @@ -0,0 +1,70 @@ +package keeper + +import ( + "fmt" + + "github.com/btcsuite/btcd/btcutil" + sdk "github.com/cosmos/cosmos-sdk/types" + + btcckpttypes "github.com/babylonlabs-io/babylon/x/btccheckpoint/types" + "github.com/babylonlabs-io/babylon/x/btcstaking/types" +) + +type delegationTimeRangeInfo struct { + startHeight uint32 + endHeight uint32 +} + +// VerifyInclusionProofAndGetHeight verifies the inclusion proof of the given staking tx +// and returns the start height and end height +func (k Keeper) VerifyInclusionProofAndGetHeight( + ctx sdk.Context, + stakingTx *btcutil.Tx, + confirmationDepth uint32, + stakingTime uint32, + minUnbondingTime uint32, + inclusionProof *types.ParsedProofOfInclusion, +) (*delegationTimeRangeInfo, error) { + // Check: + // - timelock of staking tx + // - staking tx is k-deep + // - staking tx inclusion proof + stakingTxHeader := k.btclcKeeper.GetHeaderByHash(ctx, inclusionProof.HeaderHash) + + if stakingTxHeader == nil { + return nil, fmt.Errorf("header that includes the staking tx is not found") + } + + // no need to do more validations to the btc header as it was already + // validated by the btclightclient module + btcHeader := stakingTxHeader.Header.ToBlockHeader() + + proofValid := btcckpttypes.VerifyInclusionProof( + stakingTx, + &btcHeader.MerkleRoot, + inclusionProof.Proof, + inclusionProof.Index, + ) + + if !proofValid { + return nil, types.ErrInvalidStakingTx.Wrapf("not included in the Bitcoin chain") + } + + startHeight := stakingTxHeader.Height + endHeight := stakingTxHeader.Height + stakingTime + + btcTip := k.btclcKeeper.GetTipInfo(ctx) + stakingTxDepth := btcTip.Height - stakingTxHeader.Height + if stakingTxDepth < confirmationDepth { + return nil, types.ErrInvalidStakingTx.Wrapf("not k-deep: k=%d; depth=%d", confirmationDepth, stakingTxDepth) + } + // ensure staking tx's timelock has more than unbonding BTC blocks left + if btcTip.Height+minUnbondingTime >= endHeight { + return nil, types.ErrInvalidStakingTx.Wrapf("staking tx's timelock has no more than unbonding(=%d) blocks left", minUnbondingTime) + } + + return &delegationTimeRangeInfo{ + startHeight: startHeight, + endHeight: endHeight, + }, nil +} diff --git a/x/btcstaking/keeper/keeper.go b/x/btcstaking/keeper/keeper.go index aa99daf30..0664be7b3 100644 --- a/x/btcstaking/keeper/keeper.go +++ b/x/btcstaking/keeper/keeper.go @@ -4,6 +4,7 @@ import ( "context" "fmt" + "cosmossdk.io/collections" corestoretypes "cosmossdk.io/core/store" "cosmossdk.io/log" @@ -19,12 +20,13 @@ type ( cdc codec.BinaryCodec storeService corestoretypes.KVStoreService - btclcKeeper types.BTCLightClientKeeper - btccKeeper types.BtcCheckpointKeeper - FinalityKeeper types.FinalityKeeper - bscKeeper types.BTCStkConsumerKeeper + btclcKeeper types.BTCLightClientKeeper + btccKeeper types.BtcCheckpointKeeper + BscKeeper types.BTCStkConsumerKeeper + iKeeper types.IncentiveKeeper - hooks types.BtcStakingHooks + Schema collections.Schema + AllowedStakingTxHashesKeySet collections.KeySet[[]byte] btcNet *chaincfg.Params // the address capable of executing a MsgUpdateParams message. Typically, this @@ -39,35 +41,38 @@ func NewKeeper( btclcKeeper types.BTCLightClientKeeper, btccKeeper types.BtcCheckpointKeeper, - finalityKeeper types.FinalityKeeper, bscKeeper types.BTCStkConsumerKeeper, + iKeeper types.IncentiveKeeper, btcNet *chaincfg.Params, authority string, ) Keeper { - return Keeper{ + sb := collections.NewSchemaBuilder(storeService) + + k := Keeper{ cdc: cdc, storeService: storeService, - btclcKeeper: btclcKeeper, - btccKeeper: btccKeeper, - FinalityKeeper: finalityKeeper, - bscKeeper: bscKeeper, - - hooks: nil, - + btclcKeeper: btclcKeeper, + btccKeeper: btccKeeper, + BscKeeper: bscKeeper, + iKeeper: iKeeper, + + AllowedStakingTxHashesKeySet: collections.NewKeySet( + sb, + types.AllowedStakingTxHashesKey, + "allowed_staking_tx_hashes_key_set", + collections.BytesKey, + ), btcNet: btcNet, authority: authority, } -} -// SetHooks sets the BTC staking hooks -func (k *Keeper) SetHooks(sh types.BtcStakingHooks) *Keeper { - if k.hooks != nil { - panic("cannot set BTC staking hooks twice") + schema, err := sb.Build() + if err != nil { + panic(err) } - - k.hooks = sh + k.Schema = schema return k } @@ -84,8 +89,6 @@ func (k Keeper) Logger(ctx sdk.Context) log.Logger { func (k Keeper) BeginBlocker(ctx context.Context) error { // index BTC height at the current height k.IndexBTCHeight(ctx) - // update voting power distribution - k.UpdatePowerDist(ctx) return nil } diff --git a/x/btcstaking/keeper/msg_server.go b/x/btcstaking/keeper/msg_server.go index d579dbd3b..0ade5b022 100644 --- a/x/btcstaking/keeper/msg_server.go +++ b/x/btcstaking/keeper/msg_server.go @@ -12,6 +12,8 @@ import ( sdkmath "cosmossdk.io/math" "github.com/btcsuite/btcd/btcec/v2" "github.com/btcsuite/btcd/btcutil" + "github.com/btcsuite/btcd/chaincfg/chainhash" + "github.com/btcsuite/btcd/wire" "github.com/cosmos/cosmos-sdk/telemetry" sdk "github.com/cosmos/cosmos-sdk/types" govtypes "github.com/cosmos/cosmos-sdk/x/gov/types" @@ -80,7 +82,7 @@ func (ms msgServer) CreateFinalityProvider(goCtx context.Context, req *types.Msg } // EditFinalityProvider edits an existing finality provider -func (ms msgServer) EditFinalityProvider(ctx context.Context, req *types.MsgEditFinalityProvider) (*types.MsgEditFinalityProviderResponse, error) { +func (ms msgServer) EditFinalityProvider(goCtx context.Context, req *types.MsgEditFinalityProvider) (*types.MsgEditFinalityProviderResponse, error) { // basic stateless checks // NOTE: after this, description is guaranteed to be valid if err := req.ValidateBasic(); err != nil { @@ -90,8 +92,10 @@ func (ms msgServer) EditFinalityProvider(ctx context.Context, req *types.MsgEdit // ensure commission rate is // - at least the minimum commission rate in parameters, and // - at most 1 - if req.Commission.LT(ms.MinCommissionRate(ctx)) { - return nil, types.ErrCommissionLTMinRate.Wrapf("cannot set finality provider commission to less than minimum rate of %s", ms.MinCommissionRate(ctx)) + if req.Commission.LT(ms.MinCommissionRate(goCtx)) { + return nil, types.ErrCommissionLTMinRate.Wrapf( + "cannot set finality provider commission to less than minimum rate of %s", + ms.MinCommissionRate(goCtx)) } if req.Commission.GT(sdkmath.LegacyOneDec()) { return nil, types.ErrCommissionGTMaxRate @@ -99,7 +103,7 @@ func (ms msgServer) EditFinalityProvider(ctx context.Context, req *types.MsgEdit // TODO: check to index the finality provider by his address instead of the BTC pk // find the finality provider with the given BTC PK - fp, err := ms.GetFinalityProvider(ctx, req.BtcPk) + fp, err := ms.GetFinalityProvider(goCtx, req.BtcPk) if err != nil { return nil, err } @@ -117,17 +121,32 @@ func (ms msgServer) EditFinalityProvider(ctx context.Context, req *types.MsgEdit // all good, update the finality provider and set back fp.Description = req.Description fp.Commission = req.Commission - ms.setFinalityProvider(ctx, fp) + ms.setFinalityProvider(goCtx, fp) + + // notify subscriber + ctx := sdk.UnwrapSDKContext(goCtx) + if err := ctx.EventManager().EmitTypedEvent(types.NewEventFinalityProviderEdited(fp)); err != nil { + panic(fmt.Errorf("failed to emit EventFinalityProviderEdited event: %w", err)) + } return &types.MsgEditFinalityProviderResponse{}, nil } +// isAllowListEnabled checks if the allow list is enabled at the given height +// allow list is enabled if AllowListExpirationHeight is larger than 0, +// and current block height is less than AllowListExpirationHeight +func (ms msgServer) isAllowListEnabled(ctx sdk.Context, p *types.Params) bool { + return p.AllowListExpirationHeight > 0 && uint64(ctx.BlockHeight()) < p.AllowListExpirationHeight +} + // CreateBTCDelegation creates a BTC delegation func (ms msgServer) CreateBTCDelegation(goCtx context.Context, req *types.MsgCreateBTCDelegation) (*types.MsgCreateBTCDelegationResponse, error) { defer telemetry.ModuleMeasureSince(types.ModuleName, time.Now(), types.MetricsKeyCreateBTCDelegation) ctx := sdk.UnwrapSDKContext(goCtx) + vp := ms.GetParamsWithVersion(ctx) + // 1. Parse the message into better domain format parsedMsg, err := types.ParseCreateDelegationMessage(req) @@ -143,8 +162,8 @@ func (ms msgServer) CreateBTCDelegation(goCtx context.Context, req *types.MsgCre // 3. Check if it is not duplicated staking tx stakingTxHash := parsedMsg.StakingTx.Transaction.TxHash() - delgation := ms.getBTCDelegation(ctx, stakingTxHash) - if delgation != nil { + delegation := ms.getBTCDelegation(ctx, stakingTxHash) + if delegation != nil { return nil, types.ErrReusedStakingTx.Wrapf("duplicated tx hash: %s", stakingTxHash.String()) } @@ -166,9 +185,15 @@ func (ms msgServer) CreateBTCDelegation(goCtx context.Context, req *types.MsgCre return nil, err } - // 5. Validate parsed message against parameters - vp := ms.GetParamsWithVersion(ctx) + // 5. if allow list is enabled we need to check whether staking transactions hash + // is in the allow list + if ms.isAllowListEnabled(ctx, &vp.Params) { + if !ms.IsStakingTransactionAllowed(ctx, &stakingTxHash) { + return nil, types.ErrInvalidStakingTx.Wrapf("staking tx hash: %s, is not in the allow list", stakingTxHash.String()) + } + } + // 6. Validate parsed message against parameters btccParams := ms.btccKeeper.GetParams(ctx) paramsValidationResult, err := types.ValidateParsedMessageAgainstTheParams(parsedMsg, &vp.Params, &btccParams, ms.btcNet) @@ -177,46 +202,30 @@ func (ms msgServer) CreateBTCDelegation(goCtx context.Context, req *types.MsgCre return nil, err } - // 6. Check: - // - timelock of staking tx - // - staking tx is k-deep - // - staking tx inclusion proof - stakingTxHeader := ms.btclcKeeper.GetHeaderByHash(ctx, parsedMsg.StakingTxProofOfInclusion.HeaderHash) - - if stakingTxHeader == nil { - return nil, fmt.Errorf("header that includes the staking tx is not found") - } - - // no need to do more validations to the btc header as it was already - // validated by the btclightclient module - btcHeader := stakingTxHeader.Header.ToBlockHeader() - - proofValid := btcckpttypes.VerifyInclusionProof( - btcutil.NewTx(parsedMsg.StakingTx.Transaction), - &btcHeader.MerkleRoot, - parsedMsg.StakingTxProofOfInclusion.Proof, - parsedMsg.StakingTxProofOfInclusion.Index, - ) + // 7. If the delegation contains the inclusion proof, we need to verify the proof + // and set start height and end height + var startHeight, endHeight uint32 + if parsedMsg.StakingTxProofOfInclusion != nil { + timeInfo, err := ms.VerifyInclusionProofAndGetHeight( + ctx, + btcutil.NewTx(parsedMsg.StakingTx.Transaction), + btccParams.BtcConfirmationDepth, + uint32(parsedMsg.StakingTime), + paramsValidationResult.MinUnbondingTime, + parsedMsg.StakingTxProofOfInclusion) + if err != nil { + return nil, fmt.Errorf("invalid inclusion proof: %w", err) + } - if !proofValid { - return nil, types.ErrInvalidStakingTx.Wrapf("not included in the Bitcoin chain") + startHeight = timeInfo.startHeight + endHeight = timeInfo.endHeight + } else { + // NOTE: here we consume more gas to protect Babylon chain and covenant members against spamming + // i.e creating delegation that will never reach BTC + ctx.GasMeter().ConsumeGas(vp.Params.DelegationCreationBaseGasFee, "delegation creation fee") } - startHeight := stakingTxHeader.Height - - endHeight := stakingTxHeader.Height + uint64(parsedMsg.StakingTime) - - btcTip := ms.btclcKeeper.GetTipInfo(ctx) - stakingTxDepth := btcTip.Height - stakingTxHeader.Height - if stakingTxDepth < btccParams.BtcConfirmationDepth { - return nil, types.ErrInvalidStakingTx.Wrapf("not k-deep: k=%d; depth=%d", btccParams.BtcConfirmationDepth, stakingTxDepth) - } - // ensure staking tx's timelock has more than w BTC blocks left - if btcTip.Height+btccParams.CheckpointFinalizationTimeout >= endHeight { - return nil, types.ErrInvalidStakingTx.Wrapf("staking tx's timelock has no more than w(=%d) blocks left", btccParams.CheckpointFinalizationTimeout) - } - - // 7.all good, construct BTCDelegation and insert BTC delegation + // 8.all good, construct BTCDelegation and insert BTC delegation // NOTE: the BTC delegation does not have voting power yet. It will // have voting power only when it receives a covenant signatures newBTCDel := &types.BTCDelegation{ @@ -224,6 +233,7 @@ func (ms msgServer) CreateBTCDelegation(goCtx context.Context, req *types.MsgCre BtcPk: parsedMsg.StakerPK.BIP340PubKey, Pop: parsedMsg.ParsedPop, FpBtcPkList: parsedMsg.FinalityProviderKeys.PublicKeysBbnFormat, + StakingTime: uint32(parsedMsg.StakingTime), StartHeight: startHeight, EndHeight: endHeight, TotalSat: uint64(parsedMsg.StakingValue), @@ -237,15 +247,15 @@ func (ms msgServer) CreateBTCDelegation(goCtx context.Context, req *types.MsgCre UnbondingTx: parsedMsg.UnbondingTx.TransactionBytes, SlashingTx: types.NewBtcSlashingTxFromBytes(parsedMsg.UnbondingSlashingTx.TransactionBytes), DelegatorSlashingSig: parsedMsg.StakerUnbondingSlashingSig.BIP340Signature, - DelegatorUnbondingSig: nil, CovenantSlashingSigs: nil, // NOTE: covenant signature will be submitted in a separate msg by covenant CovenantUnbondingSigList: nil, // NOTE: covenant signature will be submitted in a separate msg by covenant + DelegatorUnbondingInfo: nil, }, ParamsVersion: vp.Version, // version of the params against delegations was validated } // add this BTC delegation, and emit corresponding events - if err := ms.AddBTCDelegation(ctx, newBTCDel); err != nil { + if err := ms.AddBTCDelegation(ctx, newBTCDel, paramsValidationResult.MinUnbondingTime); err != nil { panic(fmt.Errorf("failed to add BTC delegation that has passed verification: %w", err)) } // if this BTC delegation is restaked to consumers' FPs, add it to btcstkconsumer indexes @@ -259,6 +269,110 @@ func (ms msgServer) CreateBTCDelegation(goCtx context.Context, req *types.MsgCre return &types.MsgCreateBTCDelegationResponse{}, nil } +// AddBTCDelegationInclusionProof adds inclusion proof of the given delegation on BTC chain +func (ms msgServer) AddBTCDelegationInclusionProof( + goCtx context.Context, + req *types.MsgAddBTCDelegationInclusionProof, +) (*types.MsgAddBTCDelegationInclusionProofResponse, error) { + defer telemetry.ModuleMeasureSince(types.ModuleName, time.Now(), types.MetricsKeyAddBTCDelegationInclusionProof) + + ctx := sdk.UnwrapSDKContext(goCtx) + + // 1. make sure the delegation exists + btcDel, params, err := ms.getBTCDelWithParams(ctx, req.StakingTxHash) + if err != nil { + return nil, err + } + + // 2. check if the delegation already has inclusion proof + if btcDel.HasInclusionProof() { + return nil, fmt.Errorf("the delegation %s already has inclusion proof", req.StakingTxHash) + } + + // 3. check if the delegation has received a quorum of covenant sigs + if !btcDel.HasCovenantQuorums(params.CovenantQuorum) { + return nil, fmt.Errorf("the delegation %s has not received a quorum of covenant signatures", req.StakingTxHash) + } + + // 4. check if the delegation is already unbonded + if btcDel.BtcUndelegation.DelegatorUnbondingInfo != nil { + return nil, fmt.Errorf("the delegation %s is already unbonded", req.StakingTxHash) + } + + // 5. verify inclusion proof + parsedInclusionProof, err := types.NewParsedProofOfInclusion(req.StakingTxInclusionProof) + if err != nil { + return nil, err + } + stakingTx, err := bbn.NewBTCTxFromBytes(btcDel.StakingTx) + if err != nil { + return nil, err + } + + btccParams := ms.btccKeeper.GetParams(ctx) + + minUnbondingTime := types.MinimumUnbondingTime(params, &btccParams) + + timeInfo, err := ms.VerifyInclusionProofAndGetHeight( + ctx, + btcutil.NewTx(stakingTx), + btccParams.BtcConfirmationDepth, + btcDel.StakingTime, + minUnbondingTime, + parsedInclusionProof, + ) + + if err != nil { + return nil, fmt.Errorf("invalid inclusion proof: %w", err) + } + + // 6. set start height and end height and save it to db + btcDel.StartHeight = timeInfo.startHeight + btcDel.EndHeight = timeInfo.endHeight + ms.setBTCDelegation(ctx, btcDel) + + // 7. emit events + stakingTxHash := btcDel.MustGetStakingTxHash() + + newInclusionProofEvent := types.NewInclusionProofEvent( + stakingTxHash.String(), + btcDel.StartHeight, + btcDel.EndHeight, + types.BTCDelegationStatus_ACTIVE, + ) + + if err := ctx.EventManager().EmitTypedEvents(newInclusionProofEvent); err != nil { + panic(fmt.Errorf("failed to emit events for the new active BTC delegation: %w", err)) + } + + activeEvent := types.NewEventPowerDistUpdateWithBTCDel( + &types.EventBTCDelegationStateUpdate{ + StakingTxHash: stakingTxHash.String(), + NewState: types.BTCDelegationStatus_ACTIVE, + }, + ) + btcTip := ms.btclcKeeper.GetTipInfo(ctx) + ms.addPowerDistUpdateEvent(ctx, btcTip.Height, activeEvent) + + // notify consumer chains about the active BTC delegation + ms.notifyConsumersOnActiveBTCDel(ctx, btcDel) + + // record event that the BTC delegation will become unbonded at endHeight-w + unbondedEvent := types.NewEventPowerDistUpdateWithBTCDel(&types.EventBTCDelegationStateUpdate{ + StakingTxHash: req.StakingTxHash, + NewState: types.BTCDelegationStatus_UNBONDED, + }) + + // NOTE: we should have verified that EndHeight > btcTip.Height + max(w, min_unbonding_time) + ms.addPowerDistUpdateEvent(ctx, btcDel.EndHeight-minUnbondingTime, unbondedEvent) + + // at this point, the BTC delegation inclusion proof is verified and is not duplicated + // thus, we can safely consider this message as refundable + ms.iKeeper.IndexRefundableMsg(ctx, req) + + return &types.MsgAddBTCDelegationInclusionProofResponse{}, nil +} + func (ms msgServer) getBTCDelWithParams( ctx context.Context, stakingTxHash string) (*types.BTCDelegation, *types.Params, error) { @@ -305,21 +419,18 @@ func (ms msgServer) AddCovenantSigs(goCtx context.Context, req *types.MsgAddCove if btcDel.IsSignedByCovMember(req.Pk) && btcDel.BtcUndelegation.IsSignedByCovMember(req.Pk) { ms.Logger(ctx).Debug("Received duplicated covenant signature", "covenant pk", req.Pk.MarshalHex()) - return &types.MsgAddCovenantSigsResponse{}, nil - } - - if btcDel.HasCovenantQuorums(params.CovenantQuorum) { - ms.Logger(ctx).Debug("Received covenant signature after achieving quorum", "covenant pk", req.Pk.MarshalHex()) - return &types.MsgAddCovenantSigsResponse{}, nil + // return error if the covenant signature is already submitted + // this is to secure the tx refunding against duplicated messages + return nil, types.ErrDuplicatedCovenantSig } - // ensure BTC delegation is still pending, i.e., not expired + // ensure BTC delegation is still pending, i.e., not unbonded btcTipHeight := ms.btclcKeeper.GetTipInfo(ctx).Height wValue := ms.btccKeeper.GetParams(ctx).CheckpointFinalizationTimeout status := btcDel.GetStatus(btcTipHeight, wValue, params.CovenantQuorum) - if status != types.BTCDelegationStatus_PENDING { - ms.Logger(ctx).Debug("Received covenant signature after the BTC delegation is already expired", "covenant pk", req.Pk.MarshalHex()) - return &types.MsgAddCovenantSigsResponse{}, nil + if status == types.BTCDelegationStatus_UNBONDED { + ms.Logger(ctx).Debug("Received covenant signature after the BTC delegation is already unbonded", "covenant pk", req.Pk.MarshalHex()) + return nil, types.ErrInvalidCovenantSig.Wrap("the BTC delegation is already unbonded") } // Check that the number of covenant sigs and number of the @@ -422,9 +533,26 @@ func (ms msgServer) AddCovenantSigs(goCtx context.Context, req *types.MsgAddCove params, ) + // at this point, the covenant signatures are verified and are not duplicated. + // Thus, we can safely consider this message as refundable + // NOTE: currently we refund tx fee for covenant signatures even if the BTC + // delegation already has a covenant quorum. This is to ensure that covenant + // members do not spend transaction fee, even if they submit covenant signatures + // late. + ms.iKeeper.IndexRefundableMsg(ctx, req) + return &types.MsgAddCovenantSigsResponse{}, nil } +func containsInput(tx *wire.MsgTx, inputHash *chainhash.Hash, inputIdx uint32) bool { + for _, txIn := range tx.TxIn { + if txIn.PreviousOutPoint.Hash.IsEqual(inputHash) && txIn.PreviousOutPoint.Index == inputIdx { + return true + } + } + return false +} + // BTCUndelegate adds a signature on the unbonding tx from the BTC delegator // this effectively proves that the BTC delegator wants to unbond and Babylon // will consider its BTC delegation unbonded @@ -452,38 +580,93 @@ func (ms msgServer) BTCUndelegate(goCtx context.Context, req *types.MsgBTCUndele // ensure the BTC delegation with the given staking tx hash is active btcTip := ms.btclcKeeper.GetTipInfo(ctx) wValue := ms.btccKeeper.GetParams(ctx).CheckpointFinalizationTimeout - if btcDel.GetStatus(btcTip.Height, wValue, bsParams.CovenantQuorum) != types.BTCDelegationStatus_ACTIVE { - return nil, types.ErrInvalidBTCUndelegateReq.Wrap("cannot unbond an inactive BTC delegation") + + btcDelStatus := btcDel.GetStatus(btcTip.Height, wValue, bsParams.CovenantQuorum) + + if btcDelStatus == types.BTCDelegationStatus_UNBONDED { + return nil, types.ErrInvalidBTCUndelegateReq.Wrap("cannot unbond an unbonded BTC delegation") } - // verify the signature on unbonding tx from delegator - unbondingMsgTx, err := bbn.NewBTCTxFromBytes(btcDel.BtcUndelegation.UnbondingTx) + stakeSpendingTx, err := bbn.NewBTCTxFromBytes(req.StakeSpendingTx) + if err != nil { - panic(fmt.Errorf("failed to parse unbonding tx from existing delegation with hash %s : %v", req.StakingTxHash, err)) + return nil, types.ErrInvalidBTCUndelegateReq.Wrapf("failed to parse staking spending tx: %v", err) } - stakingInfo, err := btcDel.GetStakingInfo(bsParams, ms.btcNet) - if err != nil { - panic(fmt.Errorf("failed to get staking info from a verified delegation: %w", err)) + + stakerSpendigTxHeader := ms.btclcKeeper.GetHeaderByHash(ctx, req.StakeSpendingTxInclusionProof.Key.Hash) + + if stakerSpendigTxHeader == nil { + return nil, types.ErrInvalidBTCUndelegateReq.Wrap("stake spending tx is not on BTC chain") } - unbondingSpendInfo, err := stakingInfo.UnbondingPathSpendInfo() + + btcHeader := stakerSpendigTxHeader.Header.ToBlockHeader() + + proofValid := btcckpttypes.VerifyInclusionProof( + btcutil.NewTx(stakeSpendingTx), + &btcHeader.MerkleRoot, + req.StakeSpendingTxInclusionProof.Proof, + req.StakeSpendingTxInclusionProof.Key.Index, + ) + + if !proofValid { + return nil, types.ErrInvalidBTCUndelegateReq.Wrap("stake spending tx is not included in the Bitcoin chain: invalid inclusion proof") + } + + registeredUnbondingTx, err := bbn.NewBTCTxFromBytes(btcDel.BtcUndelegation.UnbondingTx) + if err != nil { - // our staking info was constructed by using BuildStakingInfo constructor, so if - // this fails, it is a programming error - panic(err) + panic(fmt.Errorf("failed to parse unbonding tx from existing delegation with hash %s: %w", req.StakingTxHash, err)) } - if err := btcstaking.VerifyTransactionSigWithOutput( - unbondingMsgTx, - stakingInfo.StakingOutput, - unbondingSpendInfo.GetPkScriptPath(), - btcDel.BtcPk.MustToBTCPK(), - *req.UnbondingTxSig, - ); err != nil { - return nil, types.ErrInvalidCovenantSig.Wrap(err.Error()) + + registeredUnbondingTxHash := registeredUnbondingTx.TxHash() + + spendStakeTxHash := stakeSpendingTx.TxHash() + + var delegatorUnbondingInfo *types.DelegatorUnbondingInfo + + // Check if stake spending tx is already registered unbonding tx. If so, we do + // not need to save it in database + if spendStakeTxHash.IsEqual(®isteredUnbondingTxHash) { + delegatorUnbondingInfo = &types.DelegatorUnbondingInfo{ + // if the stake spending tx is the same as the registered unbonding tx, + // we do not need to save it in the database + SpendStakeTx: []byte{}, + } + + types.EmitEarlyUnbondedEvent(ctx, btcDel.MustGetStakingTxHash().String(), stakerSpendigTxHeader.Height) + } else { + // stakeSpendingTx is not unbonding tx, first we need to verify whether it + // acutally spends staking output + stakingTxHash, err := chainhash.NewHashFromStr(req.StakingTxHash) + + if err != nil { + // panic as we already verified the staking tx hash in the beginning + panic(fmt.Errorf("failed to parse staking tx hash from existing delegation with hash %s: %w", req.StakingTxHash, err)) + } + + if !containsInput(stakeSpendingTx, stakingTxHash, btcDel.StakingOutputIdx) { + return nil, types.ErrInvalidBTCUndelegateReq.Wrap("stake spending tx does not spend staking output") + } + + delegatorUnbondingInfo = &types.DelegatorUnbondingInfo{ + SpendStakeTx: req.StakeSpendingTx, + } + + types.EmitUnexpectedUnbondingTxEvent(ctx, + btcDel.MustGetStakingTxHash().String(), + spendStakeTxHash.String(), + req.StakeSpendingTxInclusionProof.Key.Hash.MarshalHex(), + req.StakeSpendingTxInclusionProof.Key.Index, + ) } // all good, add the signature to BTC delegation's undelegation // and set back - ms.btcUndelegate(ctx, btcDel, req.UnbondingTxSig) + ms.btcUndelegate(ctx, btcDel, delegatorUnbondingInfo, req.StakeSpendingTx, req.StakeSpendingTxInclusionProof) + + // At this point, the unbonding signature is verified. + // Thus, we can safely consider this message as refundable + ms.iKeeper.IndexRefundableMsg(ctx, req) return &types.MsgBTCUndelegateResponse{}, nil } @@ -549,5 +732,9 @@ func (ms msgServer) SelectiveSlashingEvidence(goCtx context.Context, req *types. panic(fmt.Errorf("failed to emit EventSelectiveSlashing event: %w", err)) } + // At this point, the selective slashing evidence is verified and is not duplicated. + // Thus, we can safely consider this message as refundable + ms.iKeeper.IndexRefundableMsg(ctx, req) + return &types.MsgSelectiveSlashingEvidenceResponse{}, nil } diff --git a/x/btcstaking/keeper/msg_server_test.go b/x/btcstaking/keeper/msg_server_test.go index fe33df0e5..12dcc8e25 100644 --- a/x/btcstaking/keeper/msg_server_test.go +++ b/x/btcstaking/keeper/msg_server_test.go @@ -19,11 +19,11 @@ import ( "google.golang.org/grpc/status" asig "github.com/babylonlabs-io/babylon/crypto/schnorr-adaptor-signature" + testutil "github.com/babylonlabs-io/babylon/testutil/btcstaking-helper" "github.com/babylonlabs-io/babylon/testutil/datagen" testhelper "github.com/babylonlabs-io/babylon/testutil/helper" bbn "github.com/babylonlabs-io/babylon/types" btcctypes "github.com/babylonlabs-io/babylon/x/btccheckpoint/types" - "github.com/babylonlabs-io/babylon/x/btcstaking/keeper" "github.com/babylonlabs-io/babylon/x/btcstaking/types" ) @@ -38,8 +38,7 @@ func FuzzMsgCreateFinalityProvider(f *testing.F) { // mock BTC light client and BTC checkpoint modules btclcKeeper := types.NewMockBTCLightClientKeeper(ctrl) btccKeeper := types.NewMockBtcCheckpointKeeper(ctrl) - finalityKeeper := types.NewMockFinalityKeeper(ctrl) - h := NewHelper(t, btclcKeeper, btccKeeper, finalityKeeper) + h := testutil.NewHelper(t, btclcKeeper, btccKeeper) // set all parameters h.GenAndApplyParams(r) @@ -87,17 +86,20 @@ func FuzzMsgEditFinalityProvider(f *testing.F) { f.Fuzz(func(t *testing.T, seed int64) { r := rand.New(rand.NewSource(seed)) - h := testhelper.NewHelper(t) - bsKeeper := h.App.BTCStakingKeeper - msgSrvr := keeper.NewMsgServerImpl(bsKeeper) + ctrl := gomock.NewController(t) + defer ctrl.Finish() + + // mock BTC light client and BTC checkpoint modules + btclcKeeper := types.NewMockBTCLightClientKeeper(ctrl) + btccKeeper := types.NewMockBtcCheckpointKeeper(ctrl) + h := testutil.NewHelper(t, btclcKeeper, btccKeeper) + + h.GenAndApplyParams(r) - // generate new finality provider - fp, err := datagen.GenRandomFinalityProvider(r) - require.NoError(t, err) // insert the finality provider - h.AddFinalityProvider(fp) + _, _, fp := h.CreateFinalityProvider(r) // assert the finality providers exist in KVStore - require.True(t, bsKeeper.HasFinalityProvider(h.Ctx, *fp.BtcPk)) + require.True(t, h.BTCStakingKeeper.HasFinalityProvider(h.Ctx, *fp.BtcPk)) // updated commission and description newCommission := datagen.GenRandomCommission(r) @@ -110,9 +112,9 @@ func FuzzMsgEditFinalityProvider(f *testing.F) { Description: newDescription, Commission: &newCommission, } - _, err = msgSrvr.EditFinalityProvider(h.Ctx, msg) + _, err := h.MsgServer.EditFinalityProvider(h.Ctx, msg) h.NoError(err) - editedFp, err := bsKeeper.GetFinalityProvider(h.Ctx, *fp.BtcPk) + editedFp, err := h.BTCStakingKeeper.GetFinalityProvider(h.Ctx, *fp.BtcPk) h.NoError(err) require.Equal(t, newCommission, *editedFp.Commission) require.Equal(t, newDescription, editedFp.Description) @@ -127,10 +129,10 @@ func FuzzMsgEditFinalityProvider(f *testing.F) { Description: newDescription, Commission: &newCommission, } - _, err = msgSrvr.EditFinalityProvider(h.Ctx, msg) - h.EqualError(err, status.Errorf(codes.PermissionDenied, "the signer does not correspond to the finality provider's Babylon address")) + _, err = h.MsgServer.EditFinalityProvider(h.Ctx, msg) + require.Equal(h.T(), err, status.Errorf(codes.PermissionDenied, "the signer does not correspond to the finality provider's Babylon address")) errStatus := status.Convert(err) - require.Equal(t, codes.PermissionDenied, errStatus.Code()) + require.Equal(h.T(), codes.PermissionDenied, errStatus.Code()) }) } @@ -145,8 +147,7 @@ func FuzzCreateBTCDelegation(f *testing.F) { // mock BTC light client and BTC checkpoint modules btclcKeeper := types.NewMockBTCLightClientKeeper(ctrl) btccKeeper := types.NewMockBtcCheckpointKeeper(ctrl) - finalityKeeper := types.NewMockFinalityKeeper(ctrl) - h := NewHelper(t, btclcKeeper, btccKeeper, finalityKeeper) + h := testutil.NewHelper(t, btclcKeeper, btccKeeper) // set all parameters h.GenAndApplyParams(r) @@ -157,29 +158,46 @@ func FuzzCreateBTCDelegation(f *testing.F) { // generate and insert new finality provider _, fpPK, _ := h.CreateFinalityProvider(r) + usePreApproval := datagen.OneInN(r, 2) + // generate and insert new BTC delegation stakingValue := int64(2 * 10e8) - stakingTxHash, _, _, msgCreateBTCDel, _, err := h.CreateDelegation( + delSK, _, err := datagen.GenRandomBTCKeyPair(r) + h.NoError(err) + stakingTxHash, msgCreateBTCDel, _, _, _, _, err := h.CreateDelegation( r, + delSK, []*btcec.PublicKey{fpPK}, changeAddress.EncodeAddress(), stakingValue, 1000, + 0, + 0, + usePreApproval, + false, ) h.NoError(err) // ensure consistency between the msg and the BTC delegation in DB actualDel, err := h.BTCStakingKeeper.GetBTCDelegation(h.Ctx, stakingTxHash) h.NoError(err) - require.Equal(h.t, msgCreateBTCDel.StakerAddr, actualDel.StakerAddr) - require.Equal(h.t, msgCreateBTCDel.Pop, actualDel.Pop) - require.Equal(h.t, msgCreateBTCDel.StakingTx.Transaction, actualDel.StakingTx) - require.Equal(h.t, msgCreateBTCDel.SlashingTx, actualDel.SlashingTx) + require.Equal(h.T(), msgCreateBTCDel.StakerAddr, actualDel.StakerAddr) + require.Equal(h.T(), msgCreateBTCDel.Pop, actualDel.Pop) + require.Equal(h.T(), msgCreateBTCDel.StakingTx, actualDel.StakingTx) + require.Equal(h.T(), msgCreateBTCDel.SlashingTx, actualDel.SlashingTx) // ensure the BTC delegation in DB is correctly formatted err = actualDel.ValidateBasic() h.NoError(err) // delegation is not activated by covenant yet - require.False(h.t, actualDel.HasCovenantQuorums(h.BTCStakingKeeper.GetParams(h.Ctx).CovenantQuorum)) + require.False(h.T(), actualDel.HasCovenantQuorums(h.BTCStakingKeeper.GetParams(h.Ctx).CovenantQuorum)) + + if usePreApproval { + require.Zero(h.T(), actualDel.StartHeight) + require.Zero(h.T(), actualDel.EndHeight) + } else { + require.Positive(h.T(), actualDel.StartHeight) + require.Positive(h.T(), actualDel.EndHeight) + } }) } @@ -191,8 +209,7 @@ func TestProperVersionInDelegation(t *testing.T) { // mock BTC light client and BTC checkpoint modules btclcKeeper := types.NewMockBTCLightClientKeeper(ctrl) btccKeeper := types.NewMockBtcCheckpointKeeper(ctrl) - finalityKeeper := types.NewMockFinalityKeeper(ctrl) - h := NewHelper(t, btclcKeeper, btccKeeper, finalityKeeper) + h := testutil.NewHelper(t, btclcKeeper, btccKeeper) // set all parameters h.GenAndApplyParams(r) @@ -205,12 +222,19 @@ func TestProperVersionInDelegation(t *testing.T) { // generate and insert new BTC delegation stakingValue := int64(2 * 10e8) - stakingTxHash, _, _, _, _, err := h.CreateDelegation( + delSK, _, err := datagen.GenRandomBTCKeyPair(r) + h.NoError(err) + stakingTxHash, _, _, _, _, _, err := h.CreateDelegation( r, + delSK, []*btcec.PublicKey{fpPK}, changeAddress.EncodeAddress(), stakingValue, 1000, + 0, + 0, + false, + false, ) h.NoError(err) @@ -231,16 +255,19 @@ func TestProperVersionInDelegation(t *testing.T) { err = h.BTCStakingKeeper.SetParams(h.Ctx, currentParams) require.NoError(t, err) // create new delegation - stakingTxHash1, _, _, _, err := h.CreateDelegationCustom( + stakingTxHash1, _, _, _, _, _, err := h.CreateDelegation( r, + delSK, []*btcec.PublicKey{fpPK}, changeAddress.EncodeAddress(), stakingValue, - 1000, + 10000, stakingValue-1000, uint16(customMinUnbondingTime)+1, + false, + false, ) - require.NoError(t, err) + h.NoError(err) actualDel1, err := h.BTCStakingKeeper.GetBTCDelegation(h.Ctx, stakingTxHash1) h.NoError(err) err = actualDel1.ValidateBasic() @@ -260,8 +287,7 @@ func FuzzAddCovenantSigs(f *testing.F) { // mock BTC light client and BTC checkpoint modules btclcKeeper := types.NewMockBTCLightClientKeeper(ctrl) btccKeeper := types.NewMockBtcCheckpointKeeper(ctrl) - finalityKeeper := types.NewMockFinalityKeeper(ctrl) - h := NewHelper(t, btclcKeeper, btccKeeper, finalityKeeper) + h := testutil.NewHelper(t, btclcKeeper, btccKeeper) // set all parameters covenantSKs, _ := h.GenAndApplyParams(r) @@ -272,14 +298,23 @@ func FuzzAddCovenantSigs(f *testing.F) { // generate and insert new finality provider _, fpPK, _ := h.CreateFinalityProvider(r) + usePreApproval := datagen.OneInN(r, 2) + // generate and insert new BTC delegation stakingValue := int64(2 * 10e8) - stakingTxHash, _, _, msgCreateBTCDel, _, err := h.CreateDelegation( + delSK, _, err := datagen.GenRandomBTCKeyPair(r) + h.NoError(err) + stakingTxHash, msgCreateBTCDel, _, _, _, _, err := h.CreateDelegation( r, + delSK, []*btcec.PublicKey{fpPK}, changeAddress.EncodeAddress(), stakingValue, 1000, + 0, + 0, + usePreApproval, + false, ) h.NoError(err) @@ -287,7 +322,7 @@ func FuzzAddCovenantSigs(f *testing.F) { actualDel, err := h.BTCStakingKeeper.GetBTCDelegation(h.Ctx, stakingTxHash) h.NoError(err) // delegation is not activated by covenant yet - require.False(h.t, actualDel.HasCovenantQuorums(h.BTCStakingKeeper.GetParams(h.Ctx).CovenantQuorum)) + require.False(h.T(), actualDel.HasCovenantQuorums(h.BTCStakingKeeper.GetParams(h.Ctx).CovenantQuorum)) msgs := h.GenerateCovenantSignaturesMessages(r, covenantSKs, msgCreateBTCDel, actualDel) @@ -297,20 +332,101 @@ func FuzzAddCovenantSigs(f *testing.F) { _, err = h.MsgServer.AddCovenantSigs(h.Ctx, &bogusMsg) h.Error(err) - for _, msg := range msgs { + for i, msg := range msgs { _, err = h.MsgServer.AddCovenantSigs(h.Ctx, msg) h.NoError(err) - // check that submitting the same covenant signature does not produce an error + // check that submitting the same covenant signature returns error _, err = h.MsgServer.AddCovenantSigs(h.Ctx, msg) - h.NoError(err) + h.Error(err, "i: %d", i) } // ensure the BTC delegation now has voting power actualDel, err = h.BTCStakingKeeper.GetBTCDelegation(h.Ctx, stakingTxHash) h.NoError(err) - require.True(h.t, actualDel.HasCovenantQuorums(h.BTCStakingKeeper.GetParams(h.Ctx).CovenantQuorum)) - require.True(h.t, actualDel.BtcUndelegation.HasCovenantQuorums(h.BTCStakingKeeper.GetParams(h.Ctx).CovenantQuorum)) - votingPower := actualDel.VotingPower(h.BTCLightClientKeeper.GetTipInfo(h.Ctx).Height, h.BTCCheckpointKeeper.GetParams(h.Ctx).CheckpointFinalizationTimeout, h.BTCStakingKeeper.GetParams(h.Ctx).CovenantQuorum) + require.True(h.T(), actualDel.HasCovenantQuorums(h.BTCStakingKeeper.GetParams(h.Ctx).CovenantQuorum)) + require.True(h.T(), actualDel.BtcUndelegation.HasCovenantQuorums(h.BTCStakingKeeper.GetParams(h.Ctx).CovenantQuorum)) + + tipHeight := h.BTCLightClientKeeper.GetTipInfo(h.Ctx).Height + checkpointTimeout := h.BTCCheckpointKeeper.GetParams(h.Ctx).CheckpointFinalizationTimeout + covenantQuorum := h.BTCStakingKeeper.GetParams(h.Ctx).CovenantQuorum + status := actualDel.GetStatus(tipHeight, checkpointTimeout, covenantQuorum) + votingPower := actualDel.VotingPower(tipHeight, checkpointTimeout, covenantQuorum) + + if usePreApproval { + require.Equal(t, status, types.BTCDelegationStatus_VERIFIED) + require.Zero(t, votingPower) + } else { + require.Equal(t, status, types.BTCDelegationStatus_ACTIVE) + require.Equal(t, uint64(stakingValue), votingPower) + } + }) +} + +func FuzzAddBTCDelegationInclusionProof(f *testing.F) { + datagen.AddRandomSeedsToFuzzer(f, 10) + + f.Fuzz(func(t *testing.T, seed int64) { + r := rand.New(rand.NewSource(seed)) + ctrl := gomock.NewController(t) + defer ctrl.Finish() + + // mock BTC light client and BTC checkpoint modules + btclcKeeper := types.NewMockBTCLightClientKeeper(ctrl) + btccKeeper := types.NewMockBtcCheckpointKeeper(ctrl) + h := testutil.NewHelper(t, btclcKeeper, btccKeeper) + + // set all parameters + covenantSKs, _ := h.GenAndApplyParams(r) + changeAddress, err := datagen.GenRandomBTCAddress(r, h.Net) + require.NoError(t, err) + + // generate and insert new finality provider + _, fpPK, _ := h.CreateFinalityProvider(r) + + // generate and insert new BTC delegation + stakingValue := int64(2 * 10e8) + delSK, _, err := datagen.GenRandomBTCKeyPair(r) + h.NoError(err) + stakingTxHash, msgCreateBTCDel, actualDel, btcHeaderInfo, inclusionProof, _, err := h.CreateDelegation( + r, + delSK, + []*btcec.PublicKey{fpPK}, + changeAddress.EncodeAddress(), + stakingValue, + 1000, + 0, + 0, + true, + false, + ) + h.NoError(err) + + // add covenant signatures to this BTC delegation + h.CreateCovenantSigs(r, covenantSKs, msgCreateBTCDel, actualDel) + + actualDel, err = h.BTCStakingKeeper.GetBTCDelegation(h.Ctx, stakingTxHash) + h.NoError(err) + + // ensure the BTC delegation is now verified and does not have voting power + tipHeight := h.BTCLightClientKeeper.GetTipInfo(h.Ctx).Height + checkpointTimeout := h.BTCCheckpointKeeper.GetParams(h.Ctx).CheckpointFinalizationTimeout + covenantQuorum := h.BTCStakingKeeper.GetParams(h.Ctx).CovenantQuorum + status := actualDel.GetStatus(tipHeight, checkpointTimeout, covenantQuorum) + votingPower := actualDel.VotingPower(tipHeight, checkpointTimeout, covenantQuorum) + + require.Equal(t, status, types.BTCDelegationStatus_VERIFIED) + require.Zero(t, votingPower) + + // activate the BTC delegation, such that the BTC delegation becomes active + // and has voting power + h.AddInclusionProof(stakingTxHash, btcHeaderInfo, inclusionProof) + + actualDel, err = h.BTCStakingKeeper.GetBTCDelegation(h.Ctx, stakingTxHash) + h.NoError(err) + status = actualDel.GetStatus(tipHeight, checkpointTimeout, covenantQuorum) + votingPower = actualDel.VotingPower(tipHeight, checkpointTimeout, covenantQuorum) + + require.Equal(t, status, types.BTCDelegationStatus_ACTIVE) require.Equal(t, uint64(stakingValue), votingPower) }) } @@ -326,8 +442,7 @@ func FuzzBTCUndelegate(f *testing.F) { // mock BTC light client and BTC checkpoint modules btclcKeeper := types.NewMockBTCLightClientKeeper(ctrl) btccKeeper := types.NewMockBtcCheckpointKeeper(ctrl) - finalityKeeper := types.NewMockFinalityKeeper(ctrl) - h := NewHelper(t, btclcKeeper, btccKeeper, finalityKeeper) + h := testutil.NewHelper(t, btclcKeeper, btccKeeper) // set all parameters covenantSKs, _ := h.GenAndApplyParams(r) @@ -343,17 +458,26 @@ func FuzzBTCUndelegate(f *testing.F) { // generate and insert new BTC delegation stakingValue := int64(2 * 10e8) - stakingTxHash, delSK, _, msgCreateBTCDel, actualDel, err := h.CreateDelegation( + delSK, _, err := datagen.GenRandomBTCKeyPair(r) + h.NoError(err) + stakingTxHash, msgCreateBTCDel, actualDel, btcHeaderInfo, inclusionProof, unbondingInfo, err := h.CreateDelegation( r, + delSK, []*btcec.PublicKey{fpPK}, changeAddress.EncodeAddress(), stakingValue, 1000, + 0, + 0, + true, + false, ) h.NoError(err) // add covenant signatures to this BTC delegation h.CreateCovenantSigs(r, covenantSKs, msgCreateBTCDel, actualDel) + // activate the BTC delegation + h.AddInclusionProof(stakingTxHash, btcHeaderInfo, inclusionProof) // ensure the BTC delegation is bonded right now actualDel, err = h.BTCStakingKeeper.GetBTCDelegation(h.Ctx, stakingTxHash) @@ -362,13 +486,11 @@ func FuzzBTCUndelegate(f *testing.F) { status := actualDel.GetStatus(btcTip, wValue, bsParams.CovenantQuorum) require.Equal(t, types.BTCDelegationStatus_ACTIVE, status) - // construct unbonding msg - delUnbondingSig, err := actualDel.SignUnbondingTx(&bsParams, h.Net, delSK) - h.NoError(err) msg := &types.MsgBTCUndelegate{ - Signer: datagen.GenRandomAccount().Address, - StakingTxHash: stakingTxHash, - UnbondingTxSig: bbn.NewBIP340SignatureFromBTCSig(delUnbondingSig), + Signer: datagen.GenRandomAccount().Address, + StakingTxHash: stakingTxHash, + StakeSpendingTx: actualDel.BtcUndelegation.UnbondingTx, + StakeSpendingTxInclusionProof: unbondingInfo.UnbondingTxInclusionProof, } // ensure the system does not panick due to a bogus unbonding msg @@ -400,8 +522,7 @@ func FuzzSelectiveSlashing(f *testing.F) { // mock BTC light client and BTC checkpoint modules btclcKeeper := types.NewMockBTCLightClientKeeper(ctrl) btccKeeper := types.NewMockBtcCheckpointKeeper(ctrl) - finalityKeeper := types.NewMockFinalityKeeper(ctrl) - h := NewHelper(t, btclcKeeper, btccKeeper, finalityKeeper) + h := testutil.NewHelper(t, btclcKeeper, btccKeeper) // set all parameters covenantSKs, _ := h.GenAndApplyParams(r) @@ -416,18 +537,28 @@ func FuzzSelectiveSlashing(f *testing.F) { // generate and insert new BTC delegation stakingValue := int64(2 * 10e8) - stakingTxHash, _, _, msgCreateBTCDel, actualDel, err := h.CreateDelegation( + delSK, _, err := datagen.GenRandomBTCKeyPair(r) + h.NoError(err) + stakingTxHash, msgCreateBTCDel, actualDel, btcHeaderInfo, inclusionProof, _, err := h.CreateDelegation( r, + delSK, []*btcec.PublicKey{fpPK}, changeAddress.EncodeAddress(), stakingValue, 1000, + 0, + 0, + true, + false, ) h.NoError(err) // add covenant signatures to this BTC delegation // so that the BTC delegation becomes bonded h.CreateCovenantSigs(r, covenantSKs, msgCreateBTCDel, actualDel) + // activate the BTC delegation + h.AddInclusionProof(stakingTxHash, btcHeaderInfo, inclusionProof) + // now BTC delegation has all covenant signatures actualDel, err = h.BTCStakingKeeper.GetBTCDelegation(h.Ctx, stakingTxHash) h.NoError(err) @@ -468,8 +599,7 @@ func FuzzSelectiveSlashing_StakingTx(f *testing.F) { // mock BTC light client and BTC checkpoint modules btclcKeeper := types.NewMockBTCLightClientKeeper(ctrl) btccKeeper := types.NewMockBtcCheckpointKeeper(ctrl) - finalityKeeper := types.NewMockFinalityKeeper(ctrl) - h := NewHelper(t, btclcKeeper, btccKeeper, finalityKeeper) + h := testutil.NewHelper(t, btclcKeeper, btccKeeper) // set all parameters covenantSKs, _ := h.GenAndApplyParams(r) @@ -484,18 +614,27 @@ func FuzzSelectiveSlashing_StakingTx(f *testing.F) { // generate and insert new BTC delegation stakingValue := int64(2 * 10e8) - stakingTxHash, _, _, msgCreateBTCDel, actualDel, err := h.CreateDelegation( + delSK, _, err := datagen.GenRandomBTCKeyPair(r) + h.NoError(err) + stakingTxHash, msgCreateBTCDel, actualDel, btcHeaderInfo, inclusionProof, _, err := h.CreateDelegation( r, + delSK, []*btcec.PublicKey{fpPK}, changeAddress.EncodeAddress(), stakingValue, 1000, + 0, + 0, + true, + false, ) h.NoError(err) // add covenant signatures to this BTC delegation // so that the BTC delegation becomes bonded h.CreateCovenantSigs(r, covenantSKs, msgCreateBTCDel, actualDel) + // activate the BTC delegation + h.AddInclusionProof(stakingTxHash, btcHeaderInfo, inclusionProof) // now BTC delegation has all covenant signatures actualDel, err = h.BTCStakingKeeper.GetBTCDelegation(h.Ctx, stakingTxHash) h.NoError(err) @@ -546,8 +685,7 @@ func TestDoNotAllowDelegationWithoutFinalityProvider(t *testing.T) { btclcKeeper := types.NewMockBTCLightClientKeeper(ctrl) btccKeeper := types.NewMockBtcCheckpointKeeper(ctrl) btccKeeper.EXPECT().GetParams(gomock.Any()).Return(btcctypes.DefaultParams()).AnyTimes() - finalityKeeper := types.NewMockFinalityKeeper(ctrl) - h := NewHelper(t, btclcKeeper, btccKeeper, finalityKeeper) + h := testutil.NewHelper(t, btclcKeeper, btccKeeper) // set covenant PK to params _, covenantPKs := h.GenAndApplyParams(r) @@ -602,9 +740,8 @@ func TestDoNotAllowDelegationWithoutFinalityProvider(t *testing.T) { prevBlock, _ := datagen.GenRandomBtcdBlock(r, 0, nil) btcHeaderWithProof := datagen.CreateBlockWithTransaction(r, &prevBlock.Header, stakingMsgTx) btcHeader := btcHeaderWithProof.HeaderBytes - txInfo := btcctypes.NewTransactionInfo( + txInclusionProof := types.NewInclusionProof( &btcctypes.TransactionKey{Index: 1, Hash: btcHeader.Hash()}, - serializedStakingTx, btcHeaderWithProof.SpvProof.MerkleNodes, ) @@ -652,7 +789,8 @@ func TestDoNotAllowDelegationWithoutFinalityProvider(t *testing.T) { Pop: pop, StakingTime: uint32(stakingTimeBlocks), StakingValue: stakingValue, - StakingTx: txInfo, + StakingTx: serializedStakingTx, + StakingTxInclusionProof: txInclusionProof, SlashingTx: testStakingInfo.SlashingTx, DelegatorSlashingSig: delegatorSig, UnbondingTx: unbondingTx, @@ -670,7 +808,7 @@ func TestDoNotAllowDelegationWithoutFinalityProvider(t *testing.T) { func TestCorrectUnbondingTimeInDelegation(t *testing.T) { tests := []struct { name string - finalizationTimeout uint64 + finalizationTimeout uint32 minUnbondingTime uint32 unbondingTimeInDelegation uint16 err error @@ -714,11 +852,10 @@ func TestCorrectUnbondingTimeInDelegation(t *testing.T) { // mock BTC light client and BTC checkpoint modules btclcKeeper := types.NewMockBTCLightClientKeeper(ctrl) btccKeeper := types.NewMockBtcCheckpointKeeper(ctrl) - finalityKeeper := types.NewMockFinalityKeeper(ctrl) - h := NewHelper(t, btclcKeeper, btccKeeper, finalityKeeper) + h := testutil.NewHelper(t, btclcKeeper, btccKeeper) // set all parameters - _, _ = h.GenAndApplyCustomParams(r, tt.finalizationTimeout, tt.minUnbondingTime) + _, _ = h.GenAndApplyCustomParams(r, tt.finalizationTimeout, tt.minUnbondingTime, 0) changeAddress, err := datagen.GenRandomBTCAddress(r, h.Net) require.NoError(t, err) @@ -728,14 +865,19 @@ func TestCorrectUnbondingTimeInDelegation(t *testing.T) { // generate and insert new BTC delegation stakingValue := int64(2 * 10e8) - stakingTxHash, _, _, _, err := h.CreateDelegationCustom( + delSK, _, err := datagen.GenRandomBTCKeyPair(r) + h.NoError(err) + stakingTxHash, _, _, _, _, _, err := h.CreateDelegation( r, + delSK, []*btcec.PublicKey{fpPK}, changeAddress.EncodeAddress(), stakingValue, 1000, stakingValue-1000, tt.unbondingTimeInDelegation, + true, + false, ) if tt.err != nil { require.Error(t, err) @@ -751,6 +893,88 @@ func TestCorrectUnbondingTimeInDelegation(t *testing.T) { } } +func TestAllowList(t *testing.T) { + r := rand.New(rand.NewSource(time.Now().UnixNano())) + ctrl := gomock.NewController(t) + defer ctrl.Finish() + + // mock BTC light client and BTC checkpoint modules + btclcKeeper := types.NewMockBTCLightClientKeeper(ctrl) + btccKeeper := types.NewMockBtcCheckpointKeeper(ctrl) + h := testutil.NewHelper(t, btclcKeeper, btccKeeper) + + allowListExpirationHeight := uint64(10) + // set all parameters, use the allow list + h.GenAndApplyCustomParams(r, 100, 0, allowListExpirationHeight) + + changeAddress, err := datagen.GenRandomBTCAddress(r, h.Net) + require.NoError(t, err) + + // generate and insert new finality provider + _, fpPK, _ := h.CreateFinalityProvider(r) + + usePreApproval := datagen.OneInN(r, 2) + + // generate and insert new BTC delegation + stakingValue := int64(2 * 10e8) + delSK, _, err := datagen.GenRandomBTCKeyPair(r) + h.NoError(err) + _, msgCreateBTCDel, _, _, _, _, err := h.CreateDelegation( + r, + delSK, + []*btcec.PublicKey{fpPK}, + changeAddress.EncodeAddress(), + stakingValue, + 1000, + 0, + 0, + usePreApproval, + // add delegation to the allow list, it should succeed + true, + ) + h.NoError(err) + require.NotNil(t, msgCreateBTCDel) + + delSK1, _, err := datagen.GenRandomBTCKeyPair(r) + h.NoError(err) + _, msgCreateBTCDel1, _, _, _, _, err := h.CreateDelegation( + r, + delSK1, + []*btcec.PublicKey{fpPK}, + changeAddress.EncodeAddress(), + stakingValue, + 1000, + 0, + 0, + usePreApproval, + // do not add delegation to the allow list, it should fail + false, + ) + require.Error(t, err) + require.ErrorIs(t, err, types.ErrInvalidStakingTx) + require.Nil(t, msgCreateBTCDel1) + + // move forward in the block height, allow list should be expired + h.Ctx = h.Ctx.WithBlockHeight(int64(allowListExpirationHeight)) + delSK2, _, err := datagen.GenRandomBTCKeyPair(r) + h.NoError(err) + _, msgCreateBTCDel2, _, _, _, _, err := h.CreateDelegation( + r, + delSK2, + []*btcec.PublicKey{fpPK}, + changeAddress.EncodeAddress(), + stakingValue, + 1000, + 0, + 0, + usePreApproval, + // do not add delegation to the allow list, it should succeed as allow list is expired + false, + ) + h.NoError(err) + require.NotNil(t, msgCreateBTCDel2) +} + func createNDelegationsForFinalityProvider( r *rand.Rand, t *testing.T, @@ -774,6 +998,8 @@ func createNDelegationsForFinalityProvider( slashingRate := sdkmath.LegacyNewDecWithPrec(int64(datagen.RandomInt(r, 41)+10), 2) + startHeight, endHeight := 1, math.MaxUint16 + stakingTime := uint32(endHeight) - uint32(startHeight) del, err := datagen.GenRandomBTCDelegation( r, t, @@ -784,8 +1010,9 @@ func createNDelegationsForFinalityProvider( covenantPks, quorum, slashingPkScript, - 0, - 0+math.MaxUint16, + stakingTime, + 1, + 1+(math.MaxUint16-1), uint64(stakingValue), slashingRate, math.MaxUint16, @@ -833,15 +1060,18 @@ func FuzzDeterminismBtcstakingBeginBlocker(f *testing.F) { require.Equal(t, appHash1, appHash2) // Default params are the same in both apps - covQuorum := h.App.BTCStakingKeeper.GetParams(h.Ctx).CovenantQuorum - maxFinalityProviders := int32(h.App.BTCStakingKeeper.GetParams(h.Ctx).MaxActiveFinalityProviders) + stakingParams := h.App.BTCStakingKeeper.GetParams(h.Ctx) + covQuorum := stakingParams.CovenantQuorum + maxFinalityProviders := int32(h.App.FinalityKeeper.GetParams(h.Ctx).MaxActiveFinalityProviders) + btcckptParams := h.App.BtcCheckpointKeeper.GetParams(h.Ctx) + minUnbondingTime := types.MinimumUnbondingTime(&stakingParams, &btcckptParams) // Number of finality providers from 10 to maxFinalityProviders + 10 numFinalityProviders := int(r.Int31n(maxFinalityProviders) + 10) fps := datagen.CreateNFinalityProviders(r, t, numFinalityProviders) - // Fill the databse of both apps with the same finality providers and delegations + // Fill the database of both apps with the same finality providers and delegations for _, fp := range fps { h.AddFinalityProvider(fp) h1.AddFinalityProvider(fp) @@ -869,8 +1099,8 @@ func FuzzDeterminismBtcstakingBeginBlocker(f *testing.F) { ) for _, del := range delegations { - h.AddDelegation(del) - h1.AddDelegation(del) + h.AddDelegation(del, minUnbondingTime) + h1.AddDelegation(del, minUnbondingTime) } } diff --git a/x/btcstaking/keeper/params_test.go b/x/btcstaking/keeper/params_test.go index 97de180aa..81f4d53a6 100644 --- a/x/btcstaking/keeper/params_test.go +++ b/x/btcstaking/keeper/params_test.go @@ -13,7 +13,7 @@ import ( ) func TestGetParams(t *testing.T) { - k, _, ctx := testkeeper.BTCStakingKeeper(t, nil, nil, nil) + k, ctx := testkeeper.BTCStakingKeeper(t, nil, nil, nil) params := types.DefaultParams() err := k.SetParams(ctx, params) @@ -23,7 +23,7 @@ func TestGetParams(t *testing.T) { } func TestGetParamsVersions(t *testing.T) { - k, _, ctx := testkeeper.BTCStakingKeeper(t, nil, nil, nil) + k, ctx := testkeeper.BTCStakingKeeper(t, nil, nil, nil) params := types.DefaultParams() pv := k.GetParamsWithVersion(ctx) @@ -56,7 +56,7 @@ func FuzzParamsVersioning(f *testing.F) { datagen.AddRandomSeedsToFuzzer(f, 10) f.Fuzz(func(t *testing.T, seed int64) { r := rand.New(rand.NewSource(seed)) - k, _, ctx := testkeeper.BTCStakingKeeper(t, nil, nil, nil) + k, ctx := testkeeper.BTCStakingKeeper(t, nil, nil, nil) numVersionsToGenerate := r.Intn(100) + 1 params0 := k.GetParams(ctx) var generatedParams []*types.Params diff --git a/x/btcstaking/keeper/power_dist_change.go b/x/btcstaking/keeper/power_dist_change.go index bd0602ae6..b0277941f 100644 --- a/x/btcstaking/keeper/power_dist_change.go +++ b/x/btcstaking/keeper/power_dist_change.go @@ -2,335 +2,20 @@ package keeper import ( "context" - "fmt" - "sort" "cosmossdk.io/store/prefix" - "github.com/btcsuite/btcd/btcutil" + "github.com/babylonlabs-io/babylon/x/btcstaking/types" "github.com/cosmos/cosmos-sdk/runtime" sdk "github.com/cosmos/cosmos-sdk/types" - - bbn "github.com/babylonlabs-io/babylon/types" - "github.com/babylonlabs-io/babylon/x/btcstaking/types" ) -/* power distribution update */ - -// UpdatePowerDist updates the voting power table and distribution cache. -// This is triggered upon each `BeginBlock` -func (k Keeper) UpdatePowerDist(ctx context.Context) { - height := uint64(sdk.UnwrapSDKContext(ctx).HeaderInfo().Height) - btcTipHeight := k.GetCurrentBTCHeight(ctx) - maxActiveFps := k.GetParams(ctx).MaxActiveFinalityProviders - - // get the power dist cache in the last height - dc := k.getVotingPowerDistCache(ctx, height-1) - - // get all power distribution update events during the previous tip - // and the current tip - lastBTCTipHeight := k.GetBTCHeightAtBabylonHeight(ctx, height-1) - events := k.GetAllPowerDistUpdateEvents(ctx, lastBTCTipHeight, btcTipHeight) - - // if no event exists, then map previous voting power and - // cache to the current height - if len(events) == 0 { - if dc != nil { - // map everything in prev height to this height - // NOTE: deep copy the previous dist cache because the - // cache for the new height shares the same distribution - // info due to no new events but timestamping status - // might be changed in the new dist cache after calling - // k.recordVotingPowerAndCache() - newDc := types.NewVotingPowerDistCache() - newDc.TotalVotingPower = dc.TotalVotingPower - newDc.NumActiveFps = dc.NumActiveFps - newFps := make([]*types.FinalityProviderDistInfo, len(dc.FinalityProviders)) - for i, prevFp := range dc.FinalityProviders { - newFp := *prevFp - newFps[i] = &newFp - } - newDc.FinalityProviders = newFps - k.recordVotingPowerAndCache(ctx, dc, newDc, maxActiveFps) - } - - return - } - - if dc == nil { - // no BTC staker at the prior height - dc = types.NewVotingPowerDistCache() - } - - // clear all events that have been consumed in this function - defer func() { - for i := lastBTCTipHeight; i <= btcTipHeight; i++ { - k.ClearPowerDistUpdateEvents(ctx, i) - } - }() - - // reconcile old voting power distribution cache and new events - // to construct the new distribution - newDc := k.ProcessAllPowerDistUpdateEvents(ctx, dc, events) - - // record voting power and cache for this height - k.recordVotingPowerAndCache(ctx, dc, newDc, maxActiveFps) - // record metrics - k.recordMetrics(newDc) -} - -// recordVotingPowerAndCache assigns voting power to each active finality provider -// with the following consideration: -// 1. the fp must have timestamped pub rand -// 2. the fp must in the top x ranked by the voting power (x is given by maxActiveFps) -// NOTE: the previous and the new dist cache cannot be nil -func (k Keeper) recordVotingPowerAndCache(ctx context.Context, prevDc, newDc *types.VotingPowerDistCache, maxActiveFps uint32) { - if prevDc == nil || newDc == nil { - panic("the voting power distribution cache cannot be nil") - } - - babylonTipHeight := uint64(sdk.UnwrapSDKContext(ctx).HeaderInfo().Height) - - // label fps with whether it has timestamped pub rand so that these fps - // will not be assigned voting power - for _, fpDistInfo := range newDc.FinalityProviders { - // TODO calling HasTimestampedPubRand potentially iterates - // all the pub rand committed by the fpDistInfo, which might slow down - // the process, need optimization - fpDistInfo.IsTimestamped = k.FinalityKeeper.HasTimestampedPubRand(ctx, fpDistInfo.BtcPk, babylonTipHeight) - } - - // apply the finality provider voting power dist info to the new cache - // after which the cache would have active fps that are top N fps ranked - // by voting power with timestamped pub rand - newDc.ApplyActiveFinalityProviders(maxActiveFps) - - // set voting power table for each active finality providers at this height - for i := uint32(0); i < newDc.NumActiveFps; i++ { - fp := newDc.FinalityProviders[i] - k.SetVotingPower(ctx, fp.BtcPk.MustMarshal(), babylonTipHeight, fp.TotalVotingPower) - } - - // find newly activated finality providers and execute the hooks by comparing - // the previous dist cache - newActivatedFinalityProviders := newDc.FindNewActiveFinalityProviders(prevDc) - for _, fp := range newActivatedFinalityProviders { - if err := k.hooks.AfterFinalityProviderActivated(ctx, fp.BtcPk); err != nil { - panic(fmt.Errorf("failed to execute after finality provider %s activated", fp.BtcPk.MarshalHex())) - } - k.Logger(sdk.UnwrapSDKContext(ctx)).Info("a new finality provider is activated", "pk", fp.BtcPk.MarshalHex()) - } - - // set the voting power distribution cache of the current height - k.setVotingPowerDistCache(ctx, babylonTipHeight, newDc) -} - -func (k Keeper) recordMetrics(dc *types.VotingPowerDistCache) { - // number of active FPs - numActiveFPs := int(dc.NumActiveFps) - types.RecordActiveFinalityProviders(numActiveFPs) - // number of inactive FPs - numInactiveFPs := len(dc.FinalityProviders) - numActiveFPs - types.RecordInactiveFinalityProviders(numInactiveFPs) - // staked Satoshi - stakedSats := btcutil.Amount(0) - for _, fp := range dc.FinalityProviders { - stakedSats += btcutil.Amount(fp.TotalVotingPower) - } - numStakedBTCs := stakedSats.ToBTC() - types.RecordMetricsKeyStakedBitcoins(float32(numStakedBTCs)) - // TODO: record number of BTC delegations under different status -} - -// ProcessAllPowerDistUpdateEvents processes all events that affect -// voting power distribution and returns a new distribution cache. -// The following events will affect the voting power distribution: -// - newly active BTC delegations -// - newly unbonded BTC delegations -// - slashed finality providers -func (k Keeper) ProcessAllPowerDistUpdateEvents( - ctx context.Context, - dc *types.VotingPowerDistCache, - events []*types.EventPowerDistUpdate, -) *types.VotingPowerDistCache { - // a map where key is finality provider's BTC PK hex and value is a list - // of BTC delegations that newly become active under this provider - activeBTCDels := map[string][]*types.BTCDelegation{} - // a map where key is unbonded BTC delegation's staking tx hash - unbondedBTCDels := map[string]struct{}{} - // a map where key is slashed finality providers' BTC PK - slashedFPs := map[string]struct{}{} - // a map where key is jailed finality providers' BTC PK - jailedFPs := map[string]struct{}{} - // a map where key is unjailed finality providers' BTC PK - unjailedFPs := map[string]struct{}{} - // a map where key is slashed BTC delegation's staking tx hash - slashedBTCDels := map[string]struct{}{} - - /* - filter and classify all events into new/expired BTC delegations and jailed/slashed FPs - */ - for _, event := range events { - switch typedEvent := event.Ev.(type) { - case *types.EventPowerDistUpdate_BtcDelStateUpdate: - delEvent := typedEvent.BtcDelStateUpdate - if delEvent.NewState == types.BTCDelegationStatus_ACTIVE { - // newly active BTC delegation - btcDel, err := k.GetBTCDelegation(ctx, delEvent.StakingTxHash) - if err != nil { - panic(err) // only programming error - } - // add the BTC delegation to each restaked **Babylon** finality provider - // TODO: separate FpBtcPkList for Babylon FPs and consumer chain FPs - for _, fpBTCPK := range btcDel.FpBtcPkList { - if k.HasFinalityProvider(ctx, fpBTCPK) { - fpBTCPKHex := fpBTCPK.MarshalHex() - activeBTCDels[fpBTCPKHex] = append(activeBTCDels[fpBTCPKHex], btcDel) - } - } - } else if delEvent.NewState == types.BTCDelegationStatus_UNBONDED { - // add the expired BTC delegation to the map - unbondedBTCDels[delEvent.StakingTxHash] = struct{}{} - } - case *types.EventPowerDistUpdate_SlashedFp: - // record slashed fps - slashedFPs[typedEvent.SlashedFp.Pk.MarshalHex()] = struct{}{} - case *types.EventPowerDistUpdate_JailedFp: - // record jailed fps - jailedFPs[typedEvent.JailedFp.Pk.MarshalHex()] = struct{}{} - case *types.EventPowerDistUpdate_UnjailedFp: - // record unjailed fps - unjailedFPs[typedEvent.UnjailedFp.Pk.MarshalHex()] = struct{}{} - case *types.EventPowerDistUpdate_SlashedBtcDelegation: - // Add the slashed BTC delegation to the map - slashedBTCDels[typedEvent.SlashedBtcDelegation.StakingTxHash] = struct{}{} - } - } - - /* - At this point, there is voting power update. - Then, construct a voting power dist cache by reconciling the previous - cache and all the new events. - */ - // TODO: the algorithm needs to iterate over all BTC delegations so remains - // sub-optimal. Ideally we only need to iterate over all events above rather - // than the entire cache. This is made difficulty since BTC delegations are - // not keyed in the cache. Need to find a way to optimise this. - newDc := types.NewVotingPowerDistCache() - - // iterate over all finality providers and apply all events - for i := range dc.FinalityProviders { - // create a copy of the finality provider - fp := *dc.FinalityProviders[i] - fp.TotalVotingPower = 0 - fp.BtcDels = []*types.BTCDelDistInfo{} - - fpBTCPKHex := fp.BtcPk.MarshalHex() - - // if this finality provider is slashed, continue to avoid - // assigning delegation to it - if _, ok := slashedFPs[fpBTCPKHex]; ok { - continue - } - - // set IsJailed to be true if the fp is jailed - // Note that jailed fp can still accept delegations - // but won't be assigned with voting power - if _, ok := jailedFPs[fpBTCPKHex]; ok { - fp.IsJailed = true - } - - // set IsJailed to be false if the fp is unjailed - if _, ok := unjailedFPs[fpBTCPKHex]; ok { - fp.IsJailed = false - } - - // add all BTC delegations that are not unbonded to the new finality provider - for j := range dc.FinalityProviders[i].BtcDels { - btcDel := *dc.FinalityProviders[i].BtcDels[j] - // skip this delegation if it's unbonded - if _, unbonded := unbondedBTCDels[btcDel.StakingTxHash]; unbonded { - continue - } - // skip this delegation if it's slashed - if _, slashed := slashedBTCDels[btcDel.StakingTxHash]; slashed { - continue - } - // add the delegation info only if it's not unbonded and not slashed (i.e it's active) - fp.AddBTCDelDistInfo(&btcDel) - } - - // process all new BTC delegations under this finality provider - if fpActiveBTCDels, ok := activeBTCDels[fpBTCPKHex]; ok { - // handle new BTC delegations for this finality provider - for _, d := range fpActiveBTCDels { - // skip this delegation if it's slashed - if _, slashed := slashedBTCDels[d.MustGetStakingTxHash().String()]; slashed { - continue - } - fp.AddBTCDel(d) - } - // remove the finality provider entry in activeBTCDels map, so that - // after the for loop the rest entries in activeBTCDels belongs to new - // finality providers with new BTC delegations - delete(activeBTCDels, fpBTCPKHex) - } - - // add this finality provider to the new cache if it has voting power - if fp.TotalVotingPower > 0 { - newDc.AddFinalityProviderDistInfo(&fp) - } - } - - /* - process new BTC delegations under new finality providers in activeBTCDels - */ - // sort new finality providers in activeBTCDels to ensure determinism - fpBTCPKHexList := make([]string, 0, len(activeBTCDels)) - for fpBTCPKHex := range activeBTCDels { - fpBTCPKHexList = append(fpBTCPKHexList, fpBTCPKHex) - } - sort.SliceStable(fpBTCPKHexList, func(i, j int) bool { - return fpBTCPKHexList[i] < fpBTCPKHexList[j] - }) - // for each new finality provider, apply the new BTC delegations to the new dist cache - for _, fpBTCPKHex := range fpBTCPKHexList { - // get the finality provider and initialise its dist info - fpBTCPK, err := bbn.NewBIP340PubKeyFromHex(fpBTCPKHex) - if err != nil { - panic(err) // only programming error - } - newFP, err := k.GetFinalityProvider(ctx, *fpBTCPK) - if err != nil { - panic(err) // only programming error - } - fpDistInfo := types.NewFinalityProviderDistInfo(newFP) - - // add each BTC delegation - fpActiveBTCDels := activeBTCDels[fpBTCPKHex] - for _, d := range fpActiveBTCDels { - // skip this delegation if it's slashed - if _, slashed := slashedBTCDels[d.MustGetStakingTxHash().String()]; slashed { - continue - } - fpDistInfo.AddBTCDel(d) - } - - // add this finality provider to the new cache if it has voting power - if fpDistInfo.TotalVotingPower > 0 { - newDc.AddFinalityProviderDistInfo(fpDistInfo) - } - } - - return newDc -} - /* voting power distribution update event store */ // addPowerDistUpdateEvent appends an event that affect voting power distribution // to the store func (k Keeper) addPowerDistUpdateEvent( ctx context.Context, - btcHeight uint64, + btcHeight uint32, event *types.EventPowerDistUpdate, ) { store := k.powerDistUpdateEventBtcHeightStore(ctx, btcHeight) @@ -352,7 +37,7 @@ func (k Keeper) addPowerDistUpdateEvent( // at a given BTC height // This is called after processing all BTC delegation events in `BeginBlocker` // nolint:unused -func (k Keeper) ClearPowerDistUpdateEvents(ctx context.Context, btcHeight uint64) { +func (k Keeper) ClearPowerDistUpdateEvents(ctx context.Context, btcHeight uint32) { store := k.powerDistUpdateEventBtcHeightStore(ctx, btcHeight) keys := [][]byte{} @@ -374,10 +59,10 @@ func (k Keeper) ClearPowerDistUpdateEvents(ctx context.Context, btcHeight uint64 } // GetAllPowerDistUpdateEvents gets all voting power update events -func (k Keeper) GetAllPowerDistUpdateEvents(ctx context.Context, lastBTCTip uint64, curBTCTip uint64) []*types.EventPowerDistUpdate { +func (k Keeper) GetAllPowerDistUpdateEvents(ctx context.Context, lastBTCTip uint32, curBTCTip uint32) []*types.EventPowerDistUpdate { events := []*types.EventPowerDistUpdate{} for i := lastBTCTip; i <= curBTCTip; i++ { - k.IteratePowerDistUpdateEvents(ctx, i, func(event *types.EventPowerDistUpdate) bool { + k.iteratePowerDistUpdateEvents(ctx, i, func(event *types.EventPowerDistUpdate) bool { events = append(events, event) return true }) @@ -385,12 +70,12 @@ func (k Keeper) GetAllPowerDistUpdateEvents(ctx context.Context, lastBTCTip uint return events } -// IteratePowerDistUpdateEvents uses the given handler function to handle each +// iteratePowerDistUpdateEvents uses the given handler function to handle each // voting power distribution update event that happens at the given BTC height. // This is called in `BeginBlocker` -func (k Keeper) IteratePowerDistUpdateEvents( +func (k Keeper) iteratePowerDistUpdateEvents( ctx context.Context, - btcHeight uint64, + btcHeight uint32, handleFunc func(event *types.EventPowerDistUpdate) bool, ) { store := k.powerDistUpdateEventBtcHeightStore(ctx, btcHeight) @@ -411,9 +96,9 @@ func (k Keeper) IteratePowerDistUpdateEvents( // prefix: PowerDistUpdateKey || BTC height // key: event index) // value: BTCDelegationStatus -func (k Keeper) powerDistUpdateEventBtcHeightStore(ctx context.Context, btcHeight uint64) prefix.Store { +func (k Keeper) powerDistUpdateEventBtcHeightStore(ctx context.Context, btcHeight uint32) prefix.Store { store := k.powerDistUpdateEventStore(ctx) - return prefix.NewStore(store, sdk.Uint64ToBigEndian(btcHeight)) + return prefix.NewStore(store, sdk.Uint64ToBigEndian(uint64(btcHeight))) } // powerDistUpdateEventStore returns the KVStore of events that affect diff --git a/x/btcstaking/keeper/power_dist_change_test.go b/x/btcstaking/keeper/power_dist_change_test.go deleted file mode 100644 index bba952517..000000000 --- a/x/btcstaking/keeper/power_dist_change_test.go +++ /dev/null @@ -1,502 +0,0 @@ -package keeper_test - -import ( - "math/rand" - "testing" - - "github.com/btcsuite/btcd/btcec/v2" - "github.com/golang/mock/gomock" - "github.com/stretchr/testify/require" - - "github.com/babylonlabs-io/babylon/testutil/datagen" - btclctypes "github.com/babylonlabs-io/babylon/x/btclightclient/types" - "github.com/babylonlabs-io/babylon/x/btcstaking/types" -) - -func FuzzProcessAllPowerDistUpdateEvents_Determinism(f *testing.F) { - datagen.AddRandomSeedsToFuzzer(f, 10) - - f.Fuzz(func(t *testing.T, seed int64) { - r := rand.New(rand.NewSource(seed)) - ctrl := gomock.NewController(t) - defer ctrl.Finish() - - // mock BTC light client and BTC checkpoint modules - btclcKeeper := types.NewMockBTCLightClientKeeper(ctrl) - btccKeeper := types.NewMockBtcCheckpointKeeper(ctrl) - finalityKeeper := types.NewMockFinalityKeeper(ctrl) - finalityKeeper.EXPECT().HasTimestampedPubRand(gomock.Any(), gomock.Any(), gomock.Any()).Return(true).AnyTimes() - h := NewHelper(t, btclcKeeper, btccKeeper, finalityKeeper) - - // set all parameters - h.GenAndApplyParams(r) - changeAddress, err := datagen.GenRandomBTCAddress(r, h.Net) - require.NoError(t, err) - - // generate and insert a number of new finality providers - fpPKs := []*btcec.PublicKey{} - for i := 0; i < 5; i++ { - _, fpPK, _ := h.CreateFinalityProvider(r) - fpPKs = append(fpPKs, fpPK) - } - - // empty dist cache - dc := types.NewVotingPowerDistCache() - - stakingValue := int64(2 * 10e8) - - // generate many new BTC delegations under each finality provider, and their corresponding events - events := []*types.EventPowerDistUpdate{} - for _, fpPK := range fpPKs { - for i := 0; i < 5; i++ { - _, _, _, _, del, err := h.CreateDelegation(r, []*btcec.PublicKey{fpPK}, changeAddress.EncodeAddress(), stakingValue, 1000) - require.NoError(t, err) - event := types.NewEventPowerDistUpdateWithBTCDel(&types.EventBTCDelegationStateUpdate{ - StakingTxHash: del.MustGetStakingTxHash().String(), - NewState: types.BTCDelegationStatus_ACTIVE, - }) - events = append(events, event) - } - } - - newDc := h.BTCStakingKeeper.ProcessAllPowerDistUpdateEvents(h.Ctx, dc, events) - for i := 0; i < 10; i++ { - newDc2 := h.BTCStakingKeeper.ProcessAllPowerDistUpdateEvents(h.Ctx, dc, events) - require.Equal(t, newDc, newDc2) - } - }) -} - -func FuzzSlashFinalityProviderEvent(f *testing.F) { - datagen.AddRandomSeedsToFuzzer(f, 10) - - f.Fuzz(func(t *testing.T, seed int64) { - r := rand.New(rand.NewSource(seed)) - ctrl := gomock.NewController(t) - defer ctrl.Finish() - - // mock BTC light client and BTC checkpoint modules - btclcKeeper := types.NewMockBTCLightClientKeeper(ctrl) - btccKeeper := types.NewMockBtcCheckpointKeeper(ctrl) - finalityKeeper := types.NewMockFinalityKeeper(ctrl) - finalityKeeper.EXPECT().HasTimestampedPubRand(gomock.Any(), gomock.Any(), gomock.Any()).Return(true).AnyTimes() - h := NewHelper(t, btclcKeeper, btccKeeper, finalityKeeper) - - // set all parameters - covenantSKs, _ := h.GenAndApplyParams(r) - changeAddress, err := datagen.GenRandomBTCAddress(r, h.Net) - require.NoError(t, err) - - // generate and insert new finality provider - _, fpPK, fp := h.CreateFinalityProvider(r) - - /* - insert new BTC delegation and give it covenant quorum - ensure that it has voting power - */ - stakingValue := int64(2 * 10e8) - _, _, _, msgCreateBTCDel, actualDel, err := h.CreateDelegation( - r, - []*btcec.PublicKey{fpPK}, - changeAddress.EncodeAddress(), - stakingValue, - 1000, - ) - h.NoError(err) - - // give it a quorum number of covenant signatures - msgs := h.GenerateCovenantSignaturesMessages(r, covenantSKs, msgCreateBTCDel, actualDel) - for i := 0; i < int(h.BTCStakingKeeper.GetParams(h.Ctx).CovenantQuorum); i++ { - _, err = h.MsgServer.AddCovenantSigs(h.Ctx, msgs[i]) - h.NoError(err) - } - - // execute BeginBlock - btcTip := btclcKeeper.GetTipInfo(h.Ctx) - babylonHeight := datagen.RandomInt(r, 10) + 1 - h.SetCtxHeight(babylonHeight) - h.BTCLightClientKeeper.EXPECT().GetTipInfo(gomock.Eq(h.Ctx)).Return(btcTip).AnyTimes() - err = h.BTCStakingKeeper.BeginBlocker(h.Ctx) - h.NoError(err) - // ensure the finality provider has voting power at this height - require.Equal(t, uint64(stakingValue), h.BTCStakingKeeper.GetVotingPower(h.Ctx, *fp.BtcPk, babylonHeight)) - - /* - Slash the finality provider and execute BeginBlock - Then, ensure the finality provider does not have voting power anymore - */ - err = h.BTCStakingKeeper.SlashFinalityProvider(h.Ctx, fp.BtcPk.MustMarshal()) - h.NoError(err) - - err = h.BTCStakingKeeper.SlashFinalityProvider(h.Ctx, fp.BtcPk.MustMarshal()) - require.ErrorIs(t, err, types.ErrFpAlreadySlashed) - - err = h.BTCStakingKeeper.JailFinalityProvider(h.Ctx, fp.BtcPk.MustMarshal()) - require.ErrorIs(t, err, types.ErrFpAlreadySlashed) - - // at this point, there should be only 1 event that the finality provider is slashed - btcTipHeight := btclcKeeper.GetTipInfo(h.Ctx).Height - h.BTCStakingKeeper.IteratePowerDistUpdateEvents(h.Ctx, btcTipHeight, func(ev *types.EventPowerDistUpdate) bool { - slashedFPEvent := ev.GetSlashedFp() - require.NotNil(t, slashedFPEvent) - require.Equal(t, fp.BtcPk.MustMarshal(), slashedFPEvent.Pk.MustMarshal()) - return true - }) - - // execute BeginBlock - babylonHeight += 1 - h.SetCtxHeight(babylonHeight) - h.BTCLightClientKeeper.EXPECT().GetTipInfo(gomock.Eq(h.Ctx)).Return(btcTip).AnyTimes() - err = h.BTCStakingKeeper.BeginBlocker(h.Ctx) - h.NoError(err) - // ensure the finality provider does not have voting power anymore - require.Zero(t, h.BTCStakingKeeper.GetVotingPower(h.Ctx, *fp.BtcPk, babylonHeight)) - }) -} - -func FuzzJailFinalityProviderEvents(f *testing.F) { - datagen.AddRandomSeedsToFuzzer(f, 10) - - f.Fuzz(func(t *testing.T, seed int64) { - r := rand.New(rand.NewSource(seed)) - ctrl := gomock.NewController(t) - defer ctrl.Finish() - - // mock BTC light client and BTC checkpoint modules - btclcKeeper := types.NewMockBTCLightClientKeeper(ctrl) - btccKeeper := types.NewMockBtcCheckpointKeeper(ctrl) - finalityKeeper := types.NewMockFinalityKeeper(ctrl) - finalityKeeper.EXPECT().HasTimestampedPubRand(gomock.Any(), gomock.Any(), gomock.Any()).Return(true).AnyTimes() - h := NewHelper(t, btclcKeeper, btccKeeper, finalityKeeper) - - // set all parameters - covenantSKs, _ := h.GenAndApplyParams(r) - changeAddress, err := datagen.GenRandomBTCAddress(r, h.Net) - require.NoError(t, err) - - // generate and insert new finality provider - _, fpPK, fp := h.CreateFinalityProvider(r) - - /* - insert new BTC delegation and give it covenant quorum - ensure that it has voting power - */ - stakingValue := int64(2 * 10e8) - _, _, _, msgCreateBTCDel, actualDel, err := h.CreateDelegation( - r, - []*btcec.PublicKey{fpPK}, - changeAddress.EncodeAddress(), - stakingValue, - 1000, - ) - require.NoError(t, err) - // give it a quorum number of covenant signatures - msgs := h.GenerateCovenantSignaturesMessages(r, covenantSKs, msgCreateBTCDel, actualDel) - for i := 0; i < int(h.BTCStakingKeeper.GetParams(h.Ctx).CovenantQuorum); i++ { - _, err = h.MsgServer.AddCovenantSigs(h.Ctx, msgs[i]) - h.NoError(err) - } - - // execute BeginBlock - btcTip := btclcKeeper.GetTipInfo(h.Ctx) - babylonHeight := datagen.RandomInt(r, 10) + 1 - h.SetCtxHeight(babylonHeight) - h.BTCLightClientKeeper.EXPECT().GetTipInfo(gomock.Eq(h.Ctx)).Return(btcTip).AnyTimes() - err = h.BTCStakingKeeper.BeginBlocker(h.Ctx) - h.NoError(err) - // ensure the finality provider is not jailed and has voting power at this height - - fpBeforeJailing, err := h.BTCStakingKeeper.GetFinalityProvider(h.Ctx, fp.BtcPk.MustMarshal()) - h.NoError(err) - require.False(t, fpBeforeJailing.IsJailed()) - require.Equal(t, uint64(stakingValue), h.BTCStakingKeeper.GetVotingPower(h.Ctx, *fp.BtcPk, babylonHeight)) - - /* - Jail the finality provider and execute BeginBlock - Then, ensure the finality provider does not have voting power anymore - */ - err = h.BTCStakingKeeper.JailFinalityProvider(h.Ctx, fp.BtcPk.MustMarshal()) - h.NoError(err) - - err = h.BTCStakingKeeper.JailFinalityProvider(h.Ctx, fp.BtcPk.MustMarshal()) - require.ErrorIs(t, err, types.ErrFpAlreadyJailed) - - // ensure the jailed label is set - fpAfterJailing, err := h.BTCStakingKeeper.GetFinalityProvider(h.Ctx, fp.BtcPk.MustMarshal()) - h.NoError(err) - require.True(t, fpAfterJailing.IsJailed()) - - // at this point, there should be only 1 event that the finality provider is jailed - btcTipHeight := btclcKeeper.GetTipInfo(h.Ctx).Height - h.BTCStakingKeeper.IteratePowerDistUpdateEvents(h.Ctx, btcTipHeight, func(ev *types.EventPowerDistUpdate) bool { - jailedFPEvent := ev.GetJailedFp() - require.NotNil(t, jailedFPEvent) - require.Equal(t, fp.BtcPk.MustMarshal(), jailedFPEvent.Pk.MustMarshal()) - return true - }) - - // execute BeginBlock - babylonHeight += 1 - h.SetCtxHeight(babylonHeight) - h.BTCLightClientKeeper.EXPECT().GetTipInfo(gomock.Eq(h.Ctx)).Return(btcTip).AnyTimes() - err = h.BTCStakingKeeper.BeginBlocker(h.Ctx) - h.NoError(err) - // ensure the finality provider does not have voting power anymore - require.Zero(t, h.BTCStakingKeeper.GetVotingPower(h.Ctx, *fp.BtcPk, babylonHeight)) - - /* - insert another active BTC delegation and check whether the jailed - fp has voting power - */ - stakingValue = int64(2 * 10e8) - _, _, _, msgCreateBTCDel, actualDel, err = h.CreateDelegation( - r, - []*btcec.PublicKey{fpPK}, - changeAddress.EncodeAddress(), - stakingValue, - 1000, - ) - require.NoError(t, err) - // give it a quorum number of covenant signatures - msgs = h.GenerateCovenantSignaturesMessages(r, covenantSKs, msgCreateBTCDel, actualDel) - for i := 0; i < int(h.BTCStakingKeeper.GetParams(h.Ctx).CovenantQuorum); i++ { - _, err = h.MsgServer.AddCovenantSigs(h.Ctx, msgs[i]) - h.NoError(err) - } - - // execute BeginBlock - btcTip = btclcKeeper.GetTipInfo(h.Ctx) - babylonHeight += 1 - h.SetCtxHeight(babylonHeight) - h.BTCLightClientKeeper.EXPECT().GetTipInfo(gomock.Eq(h.Ctx)).Return(btcTip).AnyTimes() - err = h.BTCStakingKeeper.BeginBlocker(h.Ctx) - h.NoError(err) - // ensure the finality provider is not jailed and has voting power at this height - - fpAfterJailing, err = h.BTCStakingKeeper.GetFinalityProvider(h.Ctx, fp.BtcPk.MustMarshal()) - h.NoError(err) - require.True(t, fpAfterJailing.IsJailed()) - require.Equal(t, uint64(0), h.BTCStakingKeeper.GetVotingPower(h.Ctx, *fp.BtcPk, babylonHeight)) - }) -} - -func FuzzUnjailFinalityProviderEvents(f *testing.F) { - datagen.AddRandomSeedsToFuzzer(f, 10) - - f.Fuzz(func(t *testing.T, seed int64) { - r := rand.New(rand.NewSource(seed)) - ctrl := gomock.NewController(t) - defer ctrl.Finish() - - // mock BTC light client and BTC checkpoint modules - btclcKeeper := types.NewMockBTCLightClientKeeper(ctrl) - btccKeeper := types.NewMockBtcCheckpointKeeper(ctrl) - finalityKeeper := types.NewMockFinalityKeeper(ctrl) - finalityKeeper.EXPECT().HasTimestampedPubRand(gomock.Any(), gomock.Any(), gomock.Any()).Return(true).AnyTimes() - h := NewHelper(t, btclcKeeper, btccKeeper, finalityKeeper) - - // set all parameters - covenantSKs, _ := h.GenAndApplyParams(r) - changeAddress, err := datagen.GenRandomBTCAddress(r, h.Net) - require.NoError(t, err) - - // generate and insert new finality provider - _, fpPK, fp := h.CreateFinalityProvider(r) - - /* - insert new BTC delegation and give it covenant quorum - ensure that it has voting power - */ - stakingValue := int64(2 * 10e8) - _, _, _, msgCreateBTCDel, actualDel, err := h.CreateDelegation( - r, - []*btcec.PublicKey{fpPK}, - changeAddress.EncodeAddress(), - stakingValue, - 1000, - ) - require.NoError(t, err) - // give it a quorum number of covenant signatures - msgs := h.GenerateCovenantSignaturesMessages(r, covenantSKs, msgCreateBTCDel, actualDel) - for i := 0; i < int(h.BTCStakingKeeper.GetParams(h.Ctx).CovenantQuorum); i++ { - _, err = h.MsgServer.AddCovenantSigs(h.Ctx, msgs[i]) - h.NoError(err) - } - - // execute BeginBlock - btcTip := btclcKeeper.GetTipInfo(h.Ctx) - babylonHeight := datagen.RandomInt(r, 10) + 1 - h.SetCtxHeight(babylonHeight) - h.BTCLightClientKeeper.EXPECT().GetTipInfo(gomock.Eq(h.Ctx)).Return(btcTip).AnyTimes() - err = h.BTCStakingKeeper.BeginBlocker(h.Ctx) - h.NoError(err) - - // ensure the finality provider is not jailed and has voting power - fpBeforeJailing, err := h.BTCStakingKeeper.GetFinalityProvider(h.Ctx, fp.BtcPk.MustMarshal()) - h.NoError(err) - require.False(t, fpBeforeJailing.IsJailed()) - require.Equal(t, uint64(stakingValue), h.BTCStakingKeeper.GetVotingPower(h.Ctx, *fp.BtcPk, babylonHeight)) - - // try unjail fp that is not jailed, should expect error - err = h.BTCStakingKeeper.UnjailFinalityProvider(h.Ctx, fp.BtcPk.MustMarshal()) - require.ErrorIs(t, err, types.ErrFpNotJailed) - - /* - Jail the finality provider and execute BeginBlock - Then, ensure the finality provider does not have voting power anymore - */ - err = h.BTCStakingKeeper.JailFinalityProvider(h.Ctx, fp.BtcPk.MustMarshal()) - h.NoError(err) - - // ensure the jailed label is set - fpAfterJailing, err := h.BTCStakingKeeper.GetFinalityProvider(h.Ctx, fp.BtcPk.MustMarshal()) - h.NoError(err) - require.True(t, fpAfterJailing.IsJailed()) - - // execute BeginBlock - babylonHeight += 1 - h.SetCtxHeight(babylonHeight) - h.BTCLightClientKeeper.EXPECT().GetTipInfo(gomock.Eq(h.Ctx)).Return(btcTip).AnyTimes() - err = h.BTCStakingKeeper.BeginBlocker(h.Ctx) - h.NoError(err) - // ensure the finality provider does not have voting power anymore - require.Zero(t, h.BTCStakingKeeper.GetVotingPower(h.Ctx, *fp.BtcPk, babylonHeight)) - - /* - Unjail the finality provider and execute BeginBlock - Ensure that the finality provider regains voting power - */ - err = h.BTCStakingKeeper.UnjailFinalityProvider(h.Ctx, fp.BtcPk.MustMarshal()) - h.NoError(err) - - // ensure the jailed label is reverted - fpAfterUnjailing, err := h.BTCStakingKeeper.GetFinalityProvider(h.Ctx, fp.BtcPk.MustMarshal()) - h.NoError(err) - require.False(t, fpAfterUnjailing.IsJailed()) - - // execute BeginBlock - babylonHeight += 1 - h.SetCtxHeight(babylonHeight) - h.BTCLightClientKeeper.EXPECT().GetTipInfo(gomock.Eq(h.Ctx)).Return(btcTip).AnyTimes() - err = h.BTCStakingKeeper.BeginBlocker(h.Ctx) - h.NoError(err) - // ensure the finality provider does not have voting power anymore - require.Equal(t, uint64(stakingValue), h.BTCStakingKeeper.GetVotingPower(h.Ctx, *fp.BtcPk, babylonHeight)) - }) -} - -func FuzzBTCDelegationEvents(f *testing.F) { - datagen.AddRandomSeedsToFuzzer(f, 10) - - f.Fuzz(func(t *testing.T, seed int64) { - r := rand.New(rand.NewSource(seed)) - ctrl := gomock.NewController(t) - defer ctrl.Finish() - - // mock BTC light client and BTC checkpoint modules - btclcKeeper := types.NewMockBTCLightClientKeeper(ctrl) - btccKeeper := types.NewMockBtcCheckpointKeeper(ctrl) - finalityKeeper := types.NewMockFinalityKeeper(ctrl) - h := NewHelper(t, btclcKeeper, btccKeeper, finalityKeeper) - - // set all parameters - covenantSKs, _ := h.GenAndApplyParams(r) - changeAddress, err := datagen.GenRandomBTCAddress(r, h.Net) - require.NoError(t, err) - - // generate and insert new finality provider - _, fpPK, fp := h.CreateFinalityProvider(r) - - // generate and insert new BTC delegation - stakingValue := int64(2 * 10e8) - expectedStakingTxHash, _, _, msgCreateBTCDel, actualDel, err := h.CreateDelegation( - r, - []*btcec.PublicKey{fpPK}, - changeAddress.EncodeAddress(), - stakingValue, - 1000, - ) - h.NoError(err) - - /* - at this point, there should be 1 event that BTC delegation - will become expired at end height - w - */ - // there exists no event at the current BTC tip - btcTip := btclcKeeper.GetTipInfo(h.Ctx) - events := h.BTCStakingKeeper.GetAllPowerDistUpdateEvents(h.Ctx, btcTip.Height, btcTip.Height) - require.Len(t, events, 0) - // the BTC delegation will be unbonded at end height - w - unbondedHeight := actualDel.EndHeight - btccKeeper.GetParams(h.Ctx).CheckpointFinalizationTimeout - events = h.BTCStakingKeeper.GetAllPowerDistUpdateEvents(h.Ctx, unbondedHeight, unbondedHeight) - require.Len(t, events, 1) - btcDelStateUpdate := events[0].GetBtcDelStateUpdate() - require.NotNil(t, btcDelStateUpdate) - require.Equal(t, expectedStakingTxHash, btcDelStateUpdate.StakingTxHash) - require.Equal(t, types.BTCDelegationStatus_UNBONDED, btcDelStateUpdate.NewState) - - // ensure this finality provider does not have voting power at the current height - babylonHeight := datagen.RandomInt(r, 10) + 1 - h.SetCtxHeight(babylonHeight) - h.BTCLightClientKeeper.EXPECT().GetTipInfo(gomock.Eq(h.Ctx)).Return(btcTip).AnyTimes() - err = h.BTCStakingKeeper.BeginBlocker(h.Ctx) - h.NoError(err) - require.Zero(t, h.BTCStakingKeeper.GetVotingPower(h.Ctx, *fp.BtcPk, babylonHeight)) - - /* - Generate a quorum number of covenant signatures - Then, there should be an event that the BTC delegation becomes - active at the current height - */ - msgs := h.GenerateCovenantSignaturesMessages(r, covenantSKs, msgCreateBTCDel, actualDel) - for i := 0; i < int(h.BTCStakingKeeper.GetParams(h.Ctx).CovenantQuorum); i++ { - _, err = h.MsgServer.AddCovenantSigs(h.Ctx, msgs[i]) - h.NoError(err) - } - - events = h.BTCStakingKeeper.GetAllPowerDistUpdateEvents(h.Ctx, btcTip.Height, btcTip.Height) - require.Len(t, events, 1) - btcDelStateUpdate = events[0].GetBtcDelStateUpdate() - require.NotNil(t, btcDelStateUpdate) - require.Equal(t, expectedStakingTxHash, btcDelStateUpdate.StakingTxHash) - require.Equal(t, types.BTCDelegationStatus_ACTIVE, btcDelStateUpdate.NewState) - - // ensure this finality provider does not have voting power at the current height - // due to no timestamped randomness - babylonHeight += 1 - h.SetCtxHeight(babylonHeight) - h.BTCLightClientKeeper.EXPECT().GetTipInfo(gomock.Eq(h.Ctx)).Return(btcTip).AnyTimes() - finalityKeeper.EXPECT().HasTimestampedPubRand(gomock.Any(), gomock.Any(), gomock.Eq(babylonHeight)).Return(false).AnyTimes() - err = h.BTCStakingKeeper.BeginBlocker(h.Ctx) - h.NoError(err) - require.Zero(t, h.BTCStakingKeeper.GetVotingPower(h.Ctx, *fp.BtcPk, babylonHeight)) - - // ensure this finality provider has voting power at the current height after having timestamped pub rand - babylonHeight += 1 - h.SetCtxHeight(babylonHeight) - h.BTCLightClientKeeper.EXPECT().GetTipInfo(gomock.Eq(h.Ctx)).Return(btcTip).AnyTimes() - finalityKeeper.EXPECT().HasTimestampedPubRand(gomock.Any(), gomock.Any(), gomock.Eq(babylonHeight)).Return(true).AnyTimes() - err = h.BTCStakingKeeper.BeginBlocker(h.Ctx) - h.NoError(err) - require.Equal(t, uint64(stakingValue), h.BTCStakingKeeper.GetVotingPower(h.Ctx, *fp.BtcPk, babylonHeight)) - - // ensure event queue is cleared at BTC tip height - events = h.BTCStakingKeeper.GetAllPowerDistUpdateEvents(h.Ctx, btcTip.Height, btcTip.Height) - require.Len(t, events, 0) - - /* - BTC height reaches end height - w, such that the BTC delegation becomes expired - ensure the finality provider does not have voting power anymore - */ - babylonHeight += 1 - h.SetCtxHeight(babylonHeight) - h.BTCLightClientKeeper.EXPECT().GetTipInfo(gomock.Eq(h.Ctx)).Return(&btclctypes.BTCHeaderInfo{Height: unbondedHeight}).AnyTimes() - err = h.BTCStakingKeeper.BeginBlocker(h.Ctx) - h.NoError(err) - require.Zero(t, h.BTCStakingKeeper.GetVotingPower(h.Ctx, *fp.BtcPk, babylonHeight)) - - // ensure the unbonded event is processed and cleared - events = h.BTCStakingKeeper.GetAllPowerDistUpdateEvents(h.Ctx, unbondedHeight, unbondedHeight) - require.Len(t, events, 0) - }) -} diff --git a/x/btcstaking/keeper/query_params_test.go b/x/btcstaking/keeper/query_params_test.go index fd6bfdf31..410a856f0 100644 --- a/x/btcstaking/keeper/query_params_test.go +++ b/x/btcstaking/keeper/query_params_test.go @@ -10,7 +10,7 @@ import ( ) func TestParamsQuery(t *testing.T) { - keeper, _, ctx := testkeeper.BTCStakingKeeper(t, nil, nil, nil) + keeper, ctx := testkeeper.BTCStakingKeeper(t, nil, nil, nil) params := types.DefaultParams() err := keeper.SetParams(ctx, params) @@ -22,7 +22,7 @@ func TestParamsQuery(t *testing.T) { } func TestParamsByVersionQuery(t *testing.T) { - keeper, _, ctx := testkeeper.BTCStakingKeeper(t, nil, nil, nil) + keeper, ctx := testkeeper.BTCStakingKeeper(t, nil, nil, nil) // starting with `1` as BTCStakingKeeper creates params with version 0 params1 := types.DefaultParams() @@ -32,7 +32,7 @@ func TestParamsByVersionQuery(t *testing.T) { params3 := types.DefaultParams() params3.MinUnbondingTimeBlocks = 30000 - // Check that after update we always return the latest version of params throuh Params query + // Check that after update we always return the latest version of params through Params query err := keeper.SetParams(ctx, params1) require.NoError(t, err) response, err := keeper.Params(ctx, &types.QueryParamsRequest{}) diff --git a/x/btcstaking/keeper/restaking_test.go b/x/btcstaking/keeper/restaking_test.go index a039b54f1..974a07067 100644 --- a/x/btcstaking/keeper/restaking_test.go +++ b/x/btcstaking/keeper/restaking_test.go @@ -5,6 +5,7 @@ import ( "math/rand" "testing" + testutil "github.com/babylonlabs-io/babylon/testutil/btcstaking-helper" "github.com/babylonlabs-io/babylon/testutil/datagen" bbn "github.com/babylonlabs-io/babylon/types" "github.com/babylonlabs-io/babylon/x/btcstaking/types" @@ -23,7 +24,7 @@ func FuzzRestaking_RestakedBTCDelegation(f *testing.F) { // mock BTC light client and BTC checkpoint modules btclcKeeper := types.NewMockBTCLightClientKeeper(ctrl) btccKeeper := types.NewMockBtcCheckpointKeeper(ctrl) - h := NewHelper(t, btclcKeeper, btccKeeper, nil) + h := testutil.NewHelper(t, btclcKeeper, btccKeeper) // set all parameters covenantSKs, _ := h.GenAndApplyParams(r) @@ -35,6 +36,10 @@ func FuzzRestaking_RestakedBTCDelegation(f *testing.F) { // generate and insert new Babylon finality provider _, fpPK, _ := h.CreateFinalityProvider(r) + + delSK, _, err := datagen.GenRandomBTCKeyPair(r) + h.NoError(err) + /* ensure that registering a consumer finality provider with non-existing consumer ID will fail @@ -61,12 +66,17 @@ func FuzzRestaking_RestakedBTCDelegation(f *testing.F) { stakingValue := int64(2 * 10e8) _, randomFPPK, err := datagen.GenRandomBTCKeyPair(r) h.NoError(err) - _, _, _, _, _, err = h.CreateDelegation( + _, _, _, _, _, _, err = h.CreateDelegation( r, + delSK, []*btcec.PublicKey{fpPK, randomFPPK}, changeAddress.EncodeAddress(), stakingValue, 1000, + 0, + 0, + false, + false, ) h.Error(err) require.True(t, errors.Is(err, types.ErrFpNotFound)) @@ -74,12 +84,17 @@ func FuzzRestaking_RestakedBTCDelegation(f *testing.F) { /* ensure BTC delegation request will fail if no PK corresponds to a Babylon fp */ - _, _, _, _, _, err = h.CreateDelegation( + _, _, _, _, _, _, err = h.CreateDelegation( r, + delSK, []*btcec.PublicKey{czFPPK}, changeAddress.EncodeAddress(), stakingValue, 1000, + 0, + 0, + false, + false, ) h.Error(err) require.True(t, errors.Is(err, types.ErrNoBabylonFPRestaked), err) @@ -87,12 +102,17 @@ func FuzzRestaking_RestakedBTCDelegation(f *testing.F) { /* happy case -- restaking to a Babylon fp and a consumer fp */ - _, _, _, msgBTCDel, actualDel, err := h.CreateDelegation( + _, msgBTCDel, actualDel, _, _, _, err := h.CreateDelegation( r, + delSK, []*btcec.PublicKey{fpPK, czFPPK}, changeAddress.EncodeAddress(), stakingValue, 1000, + 0, + 0, + false, + false, ) h.NoError(err) @@ -119,7 +139,7 @@ func FuzzFinalityProviderDelegations_RestakingConsumers(f *testing.F) { // mock BTC light client and BTC checkpoint modules btclcKeeper := types.NewMockBTCLightClientKeeper(ctrl) btccKeeper := types.NewMockBtcCheckpointKeeper(ctrl) - h := NewHelper(t, btclcKeeper, btccKeeper, nil) + h := testutil.NewHelper(t, btclcKeeper, btccKeeper) // set all parameters h.GenAndApplyParams(r) @@ -142,12 +162,19 @@ func FuzzFinalityProviderDelegations_RestakingConsumers(f *testing.F) { expectedBtcDelsMap := make(map[string]*types.BTCDelegation) stakingValue := int64(2 * 10e8) for j := uint64(0); j < numBTCDels; j++ { - _, _, _, _, btcDel, err := h.CreateDelegation( + delSK, _, err := datagen.GenRandomBTCKeyPair(r) + h.NoError(err) + _, _, btcDel, _, _, _, err := h.CreateDelegation( r, + delSK, []*btcec.PublicKey{fpPK, czFPPK}, changeAddress.EncodeAddress(), stakingValue, 1000, + 0, + 0, + false, + false, ) h.NoError(err) expectedBtcDelsMap[btcDel.BtcPk.MarshalHex()] = btcDel diff --git a/x/btcstaking/module.go b/x/btcstaking/module.go index e8e431b76..483ab5d63 100644 --- a/x/btcstaking/module.go +++ b/x/btcstaking/module.go @@ -72,7 +72,9 @@ func (AppModuleBasic) ValidateGenesis(cdc codec.JSONCodec, config client.TxEncod // RegisterGRPCGatewayRoutes registers the gRPC Gateway routes for the module func (AppModuleBasic) RegisterGRPCGatewayRoutes(clientCtx client.Context, mux *runtime.ServeMux) { - types.RegisterQueryHandlerClient(context.Background(), mux, types.NewQueryClient(clientCtx)) //nolint:errcheck // generally we don't handle errors here + if err := types.RegisterQueryHandlerClient(context.Background(), mux, types.NewQueryClient(clientCtx)); err != nil { + panic(err) + } } // GetTxCmd returns the root Tx command for the module. The subcommands of this root command are used by end-users to generate new transactions containing messages defined in the module diff --git a/x/btcstaking/types/btc_delegation.go b/x/btcstaking/types/btc_delegation.go index b17ef18ee..e9a877a26 100644 --- a/x/btcstaking/types/btc_delegation.go +++ b/x/btcstaking/types/btc_delegation.go @@ -3,25 +3,28 @@ package types import ( "bytes" "fmt" - math "math" + "math" sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/babylonlabs-io/babylon/btcstaking" - asig "github.com/babylonlabs-io/babylon/crypto/schnorr-adaptor-signature" - bbn "github.com/babylonlabs-io/babylon/types" "github.com/btcsuite/btcd/btcec/v2" "github.com/btcsuite/btcd/btcec/v2/schnorr" "github.com/btcsuite/btcd/btcutil" "github.com/btcsuite/btcd/chaincfg" "github.com/btcsuite/btcd/chaincfg/chainhash" "github.com/btcsuite/btcd/wire" + + "github.com/babylonlabs-io/babylon/btcstaking" + asig "github.com/babylonlabs-io/babylon/crypto/schnorr-adaptor-signature" + bbn "github.com/babylonlabs-io/babylon/types" ) func NewBTCDelegationStatusFromString(statusStr string) (BTCDelegationStatus, error) { switch statusStr { case "pending": return BTCDelegationStatus_PENDING, nil + case "verified": + return BTCDelegationStatus_VERIFIED, nil case "active": return BTCDelegationStatus_ACTIVE, nil case "unbonded": @@ -29,19 +32,20 @@ func NewBTCDelegationStatusFromString(statusStr string) (BTCDelegationStatus, er case "any": return BTCDelegationStatus_ANY, nil default: - return -1, fmt.Errorf("invalid status string; should be one of {pending, active, unbonding, unbonded, any}") + return -1, fmt.Errorf("invalid status string; should be one of {pending, verified, active, unbonded, any}") } } -func (d *BTCDelegation) GetStakingTime() uint16 { - diff := d.EndHeight - d.StartHeight - - if diff > math.MaxUint16 { - // In valid delegation, EndHeight is always greater than StartHeight and it is always uint16 value +func (d *BTCDelegation) MustGetValidStakingTime() uint16 { + if d.StakingTime > math.MaxUint16 { panic("invalid delegation in database") } - return uint16(diff) + return uint16(d.StakingTime) +} + +func (d *BTCDelegation) HasInclusionProof() bool { + return d.StartHeight > 0 && d.EndHeight > 0 } // GetFpIdx returns the index of the finality provider in the list of finality providers @@ -80,40 +84,58 @@ func (d *BTCDelegation) GetCovSlashingAdaptorSig( // Signing unbonding signature means the delegator wants to unbond early, and // Babylon will consider this BTC delegation unbonded directly func (d *BTCDelegation) IsUnbondedEarly() bool { - return d.BtcUndelegation.DelegatorUnbondingSig != nil + return d.BtcUndelegation.DelegatorUnbondingInfo != nil +} + +func (d *BTCDelegation) FinalityProviderKeys() []string { + var fpPks = make([]string, len(d.FpBtcPkList)) + + for i, fpPk := range d.FpBtcPkList { + fpPks[i] = fpPk.MarshalHex() + } + + return fpPks } // GetStatus returns the status of the BTC Delegation based on BTC height, w value, and covenant quorum // Pending: the BTC height is in the range of d's [startHeight, endHeight-w] and the delegation does not have covenant signatures // Active: the BTC height is in the range of d's [startHeight, endHeight-w] and the delegation has quorum number of signatures over slashing tx, unbonding tx, and slashing unbonding tx from covenant committee // Unbonded: the BTC height is larger than `endHeight-w` or the BTC delegation has received a signature on unbonding tx from the delegator -func (d *BTCDelegation) GetStatus(btcHeight uint64, w uint64, covenantQuorum uint32) BTCDelegationStatus { +func (d *BTCDelegation) GetStatus(btcHeight uint32, w uint32, covenantQuorum uint32) BTCDelegationStatus { if d.IsUnbondedEarly() { return BTCDelegationStatus_UNBONDED } + // we are still pending covenant quorum + if !d.HasCovenantQuorums(covenantQuorum) { + return BTCDelegationStatus_PENDING + } + + // we are still pending activation by inclusion proof + if !d.HasInclusionProof() { + // staking tx has not been included in a block yet + return BTCDelegationStatus_VERIFIED + } + + // At this point we already have covenant quorum and inclusion proof, + // we can check the status based on the BTC height if btcHeight < d.StartHeight || btcHeight+w > d.EndHeight { // staking tx's timelock has not begun, or is less than w BTC // blocks left, or is expired return BTCDelegationStatus_UNBONDED } - // at this point, BTC delegation has an active timelock, and Babylon is not - // aware of unbonding tx with delegator's signature - if d.HasCovenantQuorums(covenantQuorum) { - // this BTC delegation receives covenant quorums on - // {slashing/unbonding/unbondingslashing} txs, thus is active - return BTCDelegationStatus_ACTIVE - } - - // no covenant quorum yet, pending - return BTCDelegationStatus_PENDING + // - we have covenant quorum + // - we have inclusion proof + // - we are not unbonded early + // - we are not expired + return BTCDelegationStatus_ACTIVE } // VotingPower returns the voting power of the BTC delegation at a given BTC height // and a given w value. // The BTC delegation d has voting power iff it is active. -func (d *BTCDelegation) VotingPower(btcHeight uint64, w uint64, covenantQuorum uint32) uint64 { +func (d *BTCDelegation) VotingPower(btcHeight uint32, w uint32, covenantQuorum uint32) uint64 { if d.GetStatus(btcHeight, w, covenantQuorum) != BTCDelegationStatus_ACTIVE { return 0 } @@ -140,6 +162,16 @@ func (d *BTCDelegation) MustGetStakingTxHash() chainhash.Hash { return txHash } +func (d *BTCDelegation) MustGetStakingTx() *wire.MsgTx { + stakingTx, err := bbn.NewBTCTxFromBytes(d.StakingTx) + + if err != nil { + panic(err) + } + + return stakingTx +} + func (d *BTCDelegation) ValidateBasic() error { if _, err := sdk.AccAddressFromBech32(d.StakerAddr); err != nil { return fmt.Errorf("invalid staker address: %s - %w", d.StakerAddr, err) @@ -174,13 +206,13 @@ func (d *BTCDelegation) ValidateBasic() error { return nil } -// HasCovenantQuorum returns whether a BTC delegation has a quorum number of signatures +// HasCovenantQuorums returns whether a BTC delegation has a quorum number of signatures // from covenant members, including // - adaptor signatures on slashing tx // - Schnorr signatures on unbonding tx // - adaptor signatrues on unbonding slashing tx func (d *BTCDelegation) HasCovenantQuorums(quorum uint32) bool { - return uint32(len(d.CovenantSigs)) >= quorum && d.BtcUndelegation.HasCovenantQuorums(quorum) + return len(d.CovenantSigs) >= int(quorum) && d.BtcUndelegation.HasCovenantQuorums(quorum) } // IsSignedByCovMember checks whether the given covenant PK has signed the delegation @@ -233,7 +265,7 @@ func (d *BTCDelegation) GetStakingInfo(bsParams *Params, btcNet *chaincfg.Params fpBtcPkList, covenantBtcPkList, bsParams.CovenantQuorum, - d.GetStakingTime(), + d.MustGetValidStakingTime(), btcutil.Amount(d.TotalSat), btcNet, ) @@ -360,6 +392,7 @@ func (d *BTCDelegation) BuildSlashingTxWithWitness(bsParams *Params, btcNet *cha d.StakingOutputIdx, d.DelegatorSig, covAdaptorSigs, + bsParams.CovenantQuorum, slashingSpendInfo, ) if err != nil { @@ -411,6 +444,7 @@ func (d *BTCDelegation) BuildUnbondingSlashingTxWithWitness(bsParams *Params, bt 0, d.BtcUndelegation.DelegatorSlashingSig, covAdaptorSigs, + bsParams.CovenantQuorum, slashingSpendInfo, ) if err != nil { @@ -454,7 +488,7 @@ func (i *BTCDelegatorDelegationIndex) Add(stakingTxHash chainhash.Hash) error { } // VotingPower calculates the total voting power of all BTC delegations -func (dels *BTCDelegatorDelegations) VotingPower(btcHeight uint64, w uint64, covenantQuorum uint32) uint64 { +func (dels *BTCDelegatorDelegations) VotingPower(btcHeight uint32, w uint32, covenantQuorum uint32) uint64 { power := uint64(0) for _, del := range dels.Dels { power += del.VotingPower(btcHeight, w, covenantQuorum) diff --git a/x/btcstaking/types/btc_delegation_test.go b/x/btcstaking/types/btc_delegation_test.go index 75785529f..b15788dfa 100644 --- a/x/btcstaking/types/btc_delegation_test.go +++ b/x/btcstaking/types/btc_delegation_test.go @@ -5,12 +5,13 @@ import ( "testing" sdkmath "cosmossdk.io/math" - bbn "github.com/babylonlabs-io/babylon/types" "github.com/btcsuite/btcd/btcec/v2" "github.com/btcsuite/btcd/chaincfg" "github.com/btcsuite/btcd/txscript" "github.com/stretchr/testify/require" + bbn "github.com/babylonlabs-io/babylon/types" + asig "github.com/babylonlabs-io/babylon/crypto/schnorr-adaptor-signature" btctest "github.com/babylonlabs-io/babylon/testutil/bitcoin" "github.com/babylonlabs-io/babylon/testutil/datagen" @@ -50,12 +51,12 @@ func FuzzBTCDelegation(f *testing.F) { } // randomise start height and end height - btcDel.StartHeight = datagen.RandomInt(r, 100) - btcDel.EndHeight = btcDel.StartHeight + datagen.RandomInt(r, 100) + btcDel.StartHeight = uint32(datagen.RandomInt(r, 100)) + 1 + btcDel.EndHeight = btcDel.StartHeight + uint32(datagen.RandomInt(r, 100)) + 1 // randomise BTC tip and w - btcHeight := btcDel.StartHeight + datagen.RandomInt(r, 50) - w := datagen.RandomInt(r, 50) + btcHeight := btcDel.StartHeight + uint32(datagen.RandomInt(r, 50)) + w := uint32(datagen.RandomInt(r, 50)) // test expected voting power hasVotingPower := hasCovenantSig && btcDel.StartHeight <= btcHeight && btcHeight+w <= btcDel.EndHeight @@ -97,7 +98,7 @@ func FuzzBTCDelegation_SlashingTx(f *testing.F) { CovenantQuorum: covenantQuorum, } - stakingTimeBlocks := uint16(5) + stakingTimeBlocks := uint32(5) stakingValue := int64(2 * 10e8) slashingAddress, err := datagen.GenRandomBTCAddress(r, &chaincfg.SimNetParams) require.NoError(t, err) @@ -109,8 +110,7 @@ func FuzzBTCDelegation_SlashingTx(f *testing.F) { slashingChangeLockTime := unbondingTime // only the quorum of signers provided the signatures - covenantSigners := covenantSKs[:covenantQuorum] - + covenantSigners := covenantSKs // construct the BTC delegation with everything btcDel, err := datagen.GenRandomBTCDelegation( r, @@ -122,8 +122,9 @@ func FuzzBTCDelegation_SlashingTx(f *testing.F) { covenantPKs, covenantQuorum, slashingPkScript, + stakingTimeBlocks, 1000, - uint64(1000+stakingTimeBlocks), + 1000+stakingTimeBlocks, uint64(stakingValue), slashingRate, slashingChangeLockTime, diff --git a/x/btcstaking/types/btc_slashing_tx.go b/x/btcstaking/types/btc_slashing_tx.go index 613caec3d..7258fdea6 100644 --- a/x/btcstaking/types/btc_slashing_tx.go +++ b/x/btcstaking/types/btc_slashing_tx.go @@ -274,6 +274,7 @@ func (tx *BTCSlashingTx) BuildSlashingTxWithWitness( outputIdx uint32, delegatorSig *bbn.BIP340Signature, covenantSigs []*asig.AdaptorSignature, + covenantQuorum uint32, slashingPathSpendInfo *btcstaking.SpendInfo, ) (*wire.MsgTx, error) { /* @@ -288,12 +289,21 @@ func (tx *BTCSlashingTx) BuildSlashingTxWithWitness( } // decrypt each covenant adaptor signature to Schnorr signature covSigs := make([]*schnorr.Signature, len(covenantSigs)) + numSigs := uint32(0) for i, covenantSig := range covenantSigs { if covenantSig != nil { covSigs[i] = covenantSig.Decrypt(decKey) + numSigs++ } else { covSigs[i] = nil } + if numSigs == covenantQuorum { + break + } + } + // ensure the number of covenant signatures is at least the quorum number + if numSigs < covenantQuorum { + return nil, fmt.Errorf("not enough covenant signatures to reach quorum") } /* diff --git a/x/btcstaking/types/btc_slashing_tx_test.go b/x/btcstaking/types/btc_slashing_tx_test.go index 10a77da0e..9cd253555 100644 --- a/x/btcstaking/types/btc_slashing_tx_test.go +++ b/x/btcstaking/types/btc_slashing_tx_test.go @@ -194,7 +194,10 @@ func FuzzSlashingTxWithWitness(f *testing.F) { delSig, err := slashingTx.Sign(stakingMsgTx, 0, slashingPkScriptPath, delSK) require.NoError(t, err) - covenantSigners := covenantSKs[:covenantQuorum] + // ensure that event if all covenant members provide covenant signatures, + // BuildSlashingTxWithWitness will only take a quorum number of signatures + // to construct the witness + covenantSigners := covenantSKs // get covenant Schnorr signatures covenantSigs, err := datagen.GenCovenantAdaptorSigs( covenantSigners, @@ -235,7 +238,7 @@ func FuzzSlashingTxWithWitness(f *testing.F) { } // create slashing tx with witness - slashingMsgTxWithWitness, err := slashingTx.BuildSlashingTxWithWitness(fpSK, fpBTCPKs, stakingMsgTx, 0, delSig, covSigsForFP, slashingSpendInfo) + slashingMsgTxWithWitness, err := slashingTx.BuildSlashingTxWithWitness(fpSK, fpBTCPKs, stakingMsgTx, 0, delSig, covSigsForFP, covenantQuorum, slashingSpendInfo) require.NoError(t, err) // verify slashing tx with witness diff --git a/x/btcstaking/types/btc_staking_consumer_events.go b/x/btcstaking/types/btc_staking_consumer_events.go index 2f0c12aa3..aac73e207 100644 --- a/x/btcstaking/types/btc_staking_consumer_events.go +++ b/x/btcstaking/types/btc_staking_consumer_events.go @@ -35,8 +35,8 @@ func CreateActiveBTCDelegationEvent(activeDel *BTCDelegation) (*BTCStakingConsum return nil, fmt.Errorf("failed to marshal DelegatorSig: %w", err) } - if activeDel.BtcUndelegation.DelegatorUnbondingSig != nil { - return nil, fmt.Errorf("unexpected DelegatorUnbondingSig in active delegation") + if activeDel.BtcUndelegation.DelegatorUnbondingInfo != nil { + return nil, fmt.Errorf("unexpected DelegatorUnbondingInfo in active delegation") } unbondingSlashingTxBytes, err := activeDel.BtcUndelegation.SlashingTx.Marshal() @@ -78,21 +78,17 @@ func CreateActiveBTCDelegationEvent(activeDel *BTCDelegation) (*BTCStakingConsum return event, nil } -func CreateUnbondedBTCDelegationEvent(unbondedDel *BTCDelegation) (*BTCStakingConsumerEvent, error) { - if unbondedDel.BtcUndelegation.DelegatorUnbondingSig == nil { - return nil, fmt.Errorf("missing DelegatorUnbondingSig in unbonded delegation") - } - - unbondingTxSigBytes, err := unbondedDel.BtcUndelegation.DelegatorUnbondingSig.Marshal() - if err != nil { - return nil, fmt.Errorf("failed to marshal DelegatorUnbondingSig: %w", err) +func CreateUnbondedBTCDelegationEvent(unbondedDel *BTCDelegation, stakeSpendingTx []byte, proof *InclusionProof) (*BTCStakingConsumerEvent, error) { + if unbondedDel.BtcUndelegation.DelegatorUnbondingInfo == nil { + return nil, fmt.Errorf("missing DelegatorUnbondingInfo in unbonded delegation") } event := &BTCStakingConsumerEvent{ Event: &BTCStakingConsumerEvent_UnbondedDel{ UnbondedDel: &UnbondedBTCDelegation{ - StakingTxHash: unbondedDel.MustGetStakingTxHash().String(), - UnbondingTxSig: unbondingTxSigBytes, + StakingTxHash: unbondedDel.MustGetStakingTxHash().String(), + StakeSpendingTx: stakeSpendingTx, + Proof: proof, }, }, } diff --git a/x/btcstaking/types/btc_undelegation_test.go b/x/btcstaking/types/btc_undelegation_test.go index 59694c426..7cfaecdba 100644 --- a/x/btcstaking/types/btc_undelegation_test.go +++ b/x/btcstaking/types/btc_undelegation_test.go @@ -5,14 +5,15 @@ import ( "testing" sdkmath "cosmossdk.io/math" + "github.com/btcsuite/btcd/chaincfg" + "github.com/btcsuite/btcd/txscript" + "github.com/stretchr/testify/require" + asig "github.com/babylonlabs-io/babylon/crypto/schnorr-adaptor-signature" btctest "github.com/babylonlabs-io/babylon/testutil/bitcoin" "github.com/babylonlabs-io/babylon/testutil/datagen" bbn "github.com/babylonlabs-io/babylon/types" "github.com/babylonlabs-io/babylon/x/btcstaking/types" - "github.com/btcsuite/btcd/chaincfg" - "github.com/btcsuite/btcd/txscript" - "github.com/stretchr/testify/require" ) func FuzzBTCUndelegation_SlashingTx(f *testing.F) { @@ -47,9 +48,9 @@ func FuzzBTCUndelegation_SlashingTx(f *testing.F) { CovenantPks: bbn.NewBIP340PKsFromBTCPKs(covenantPKs), CovenantQuorum: covenantQuorum, } - covenantSigners := covenantSKs[:covenantQuorum] + covenantSigners := covenantSKs - stakingTimeBlocks := uint16(5) + stakingTimeBlocks := uint32(5) stakingValue := int64(2 * 10e8) slashingAddress, err := datagen.GenRandomBTCAddress(r, &chaincfg.SimNetParams) require.NoError(t, err) @@ -72,8 +73,9 @@ func FuzzBTCUndelegation_SlashingTx(f *testing.F) { covenantPKs, covenantQuorum, slashingPkScript, + stakingTimeBlocks, 1000, - uint64(1000+stakingTimeBlocks), + uint32(stakingTimeBlocks)+1000, uint64(stakingValue), slashingRate, slashingChangeLockTime, diff --git a/x/btcstaking/types/btcstaking.go b/x/btcstaking/types/btcstaking.go index 2914205c3..5a0fe1b6c 100644 --- a/x/btcstaking/types/btcstaking.go +++ b/x/btcstaking/types/btcstaking.go @@ -2,7 +2,6 @@ package types import ( "fmt" - "sort" "cosmossdk.io/math" @@ -42,28 +41,6 @@ func (fp *FinalityProvider) ValidateBasic() error { return nil } -// SortFinalityProvidersWithZeroedVotingPower sorts the finality providers slice, -// from higher to lower voting power. In the following cases, the voting power -// is treated as zero: -// 1. IsTimestamped is false -// 2. IsJailed is true -func SortFinalityProvidersWithZeroedVotingPower(fps []*FinalityProviderDistInfo) { - sort.SliceStable(fps, func(i, j int) bool { - iShouldBeZeroed := fps[i].IsJailed || !fps[i].IsTimestamped - jShouldBeZeroed := fps[j].IsJailed || !fps[j].IsTimestamped - - if iShouldBeZeroed && !jShouldBeZeroed { - return false - } - - if !iShouldBeZeroed && jShouldBeZeroed { - return true - } - - return fps[i].TotalVotingPower > fps[j].TotalVotingPower - }) -} - func ExistsDup(btcPKs []bbn.BIP340PubKey) bool { seen := make(map[string]struct{}) @@ -112,7 +89,7 @@ func GetOrderedCovenantSignatures(fpIdx int, covSigsList []*CovenantAdaptorSigna covSigsMap[covSigs.CovPk.MarshalHex()] = covSig } - // sort covenant PKs in reverse reverse lexicographical order + // sort covenant PKs in reverse lexicographical order orderedCovenantPKs := bbn.SortBIP340PKs(params.CovenantPks) // get ordered list of covenant signatures w.r.t. the order of sorted covenant PKs @@ -134,9 +111,9 @@ func GetOrderedCovenantSignatures(fpIdx int, covSigsList []*CovenantAdaptorSigna // - CheckpointFinalizationTimeout func MinimumUnbondingTime( stakingParams *Params, - checkpointingParams *btcctypes.Params) uint64 { - return math.Max[uint64]( - uint64(stakingParams.MinUnbondingTimeBlocks), + checkpointingParams *btcctypes.Params) uint32 { + return math.Max[uint32]( + stakingParams.MinUnbondingTimeBlocks, checkpointingParams.CheckpointFinalizationTimeout, ) } diff --git a/x/btcstaking/types/btcstaking.pb.go b/x/btcstaking/types/btcstaking.pb.go index cece63543..6045a5afc 100644 --- a/x/btcstaking/types/btcstaking.pb.go +++ b/x/btcstaking/types/btcstaking.pb.go @@ -7,6 +7,7 @@ import ( cosmossdk_io_math "cosmossdk.io/math" fmt "fmt" github_com_babylonlabs_io_babylon_types "github.com/babylonlabs-io/babylon/types" + types1 "github.com/babylonlabs-io/babylon/x/btccheckpoint/types" _ "github.com/cosmos/cosmos-proto" types "github.com/cosmos/cosmos-sdk/x/staking/types" _ "github.com/cosmos/gogoproto/gogoproto" @@ -27,37 +28,48 @@ var _ = math.Inf // proto package needs to be updated. const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package -// BTCDelegationStatus is the status of a delegation. The state transition path is -// PENDING -> ACTIVE -> UNBONDED with two possibilities: -// 1. the typical path when timelock of staking transaction expires. -// 2. the path when staker requests early undelegation through MsgBTCUndelegate message. +// BTCDelegationStatus is the status of a delegation. +// There are two possible valid state transition paths for a BTC delegation: +// - PENDING -> ACTIVE -> UNBONDED +// - PENDING -> VERIFIED -> ACTIVE -> UNBONDED +// and one invalid state transition path: +// - PENDING -> VERIFIED -> UNBONDED i.e the staker unbonded before +// activating delegation on Babylon chain. +// In valid transition paths, the delegation becomes UNBONDED when: +// - either the staking transaction timelock expires +// - or the staker requests early undelegation through MsgBTCUndelegate message. type BTCDelegationStatus int32 const ( - // PENDING defines a delegation that is waiting for covenant signatures to become active. + // PENDING defines a delegation that is waiting for covenant signatures. BTCDelegationStatus_PENDING BTCDelegationStatus = 0 + // VERIFIED defines a delegation that has covenant signatures but is not yet + // included in the BTC chain. + BTCDelegationStatus_VERIFIED BTCDelegationStatus = 1 // ACTIVE defines a delegation that has voting power - BTCDelegationStatus_ACTIVE BTCDelegationStatus = 1 + BTCDelegationStatus_ACTIVE BTCDelegationStatus = 2 // UNBONDED defines a delegation no longer has voting power: // - either reaching the end of staking transaction timelock // - or receiving unbonding tx with signatures from staker and covenant committee - BTCDelegationStatus_UNBONDED BTCDelegationStatus = 2 + BTCDelegationStatus_UNBONDED BTCDelegationStatus = 3 // ANY is any of the above status - BTCDelegationStatus_ANY BTCDelegationStatus = 3 + BTCDelegationStatus_ANY BTCDelegationStatus = 4 ) var BTCDelegationStatus_name = map[int32]string{ 0: "PENDING", - 1: "ACTIVE", - 2: "UNBONDED", - 3: "ANY", + 1: "VERIFIED", + 2: "ACTIVE", + 3: "UNBONDED", + 4: "ANY", } var BTCDelegationStatus_value = map[string]int32{ "PENDING": 0, - "ACTIVE": 1, - "UNBONDED": 2, - "ANY": 3, + "VERIFIED": 1, + "ACTIVE": 2, + "UNBONDED": 3, + "ANY": 4, } func (x BTCDelegationStatus) String() string { @@ -89,7 +101,7 @@ type FinalityProvider struct { // slashed_btc_height indicates the BTC height when // the finality provider is slashed. // if it's 0 then the finality provider is not slashed - SlashedBtcHeight uint64 `protobuf:"varint,7,opt,name=slashed_btc_height,json=slashedBtcHeight,proto3" json:"slashed_btc_height,omitempty"` + SlashedBtcHeight uint32 `protobuf:"varint,7,opt,name=slashed_btc_height,json=slashedBtcHeight,proto3" json:"slashed_btc_height,omitempty"` // jailed defines whether the finality provider is jailed Jailed bool `protobuf:"varint,8,opt,name=jailed,proto3" json:"jailed,omitempty"` // consumer_id is the ID of the consumer the finality provider is operating on. @@ -158,7 +170,7 @@ func (m *FinalityProvider) GetSlashedBabylonHeight() uint64 { return 0 } -func (m *FinalityProvider) GetSlashedBtcHeight() uint64 { +func (m *FinalityProvider) GetSlashedBtcHeight() uint32 { if m != nil { return m.SlashedBtcHeight } @@ -195,7 +207,7 @@ type FinalityProviderWithMeta struct { // slashed_btc_height indicates the BTC height when // the finality provider is slashed. // if it's 0 then the finality provider is not slashed - SlashedBtcHeight uint64 `protobuf:"varint,5,opt,name=slashed_btc_height,json=slashedBtcHeight,proto3" json:"slashed_btc_height,omitempty"` + SlashedBtcHeight uint32 `protobuf:"varint,5,opt,name=slashed_btc_height,json=slashedBtcHeight,proto3" json:"slashed_btc_height,omitempty"` // jailed defines whether the finality provider is detected jailed Jailed bool `protobuf:"varint,6,opt,name=jailed,proto3" json:"jailed,omitempty"` } @@ -254,7 +266,7 @@ func (m *FinalityProviderWithMeta) GetSlashedBabylonHeight() uint64 { return 0 } -func (m *FinalityProviderWithMeta) GetSlashedBtcHeight() uint64 { +func (m *FinalityProviderWithMeta) GetSlashedBtcHeight() uint32 { if m != nil { return m.SlashedBtcHeight } @@ -282,38 +294,40 @@ type BTCDelegation struct { // If there is more than 1 PKs, then this means the delegation is restaked // to multiple finality providers FpBtcPkList []github_com_babylonlabs_io_babylon_types.BIP340PubKey `protobuf:"bytes,4,rep,name=fp_btc_pk_list,json=fpBtcPkList,proto3,customtype=github.com/babylonlabs-io/babylon/types.BIP340PubKey" json:"fp_btc_pk_list,omitempty"` + // staking_time is the number of blocks for which the delegation is locked on BTC chain + StakingTime uint32 `protobuf:"varint,5,opt,name=staking_time,json=stakingTime,proto3" json:"staking_time,omitempty"` // start_height is the start BTC height of the BTC delegation // it is the start BTC height of the timelock - StartHeight uint64 `protobuf:"varint,5,opt,name=start_height,json=startHeight,proto3" json:"start_height,omitempty"` + StartHeight uint32 `protobuf:"varint,6,opt,name=start_height,json=startHeight,proto3" json:"start_height,omitempty"` // end_height is the end height of the BTC delegation - // it is the end BTC height of the timelock - w - EndHeight uint64 `protobuf:"varint,6,opt,name=end_height,json=endHeight,proto3" json:"end_height,omitempty"` + // it is calculated by end_height = start_height + staking_time + EndHeight uint32 `protobuf:"varint,7,opt,name=end_height,json=endHeight,proto3" json:"end_height,omitempty"` // total_sat is the total amount of BTC stakes in this delegation // quantified in satoshi - TotalSat uint64 `protobuf:"varint,7,opt,name=total_sat,json=totalSat,proto3" json:"total_sat,omitempty"` + TotalSat uint64 `protobuf:"varint,8,opt,name=total_sat,json=totalSat,proto3" json:"total_sat,omitempty"` // staking_tx is the staking tx - StakingTx []byte `protobuf:"bytes,8,opt,name=staking_tx,json=stakingTx,proto3" json:"staking_tx,omitempty"` + StakingTx []byte `protobuf:"bytes,9,opt,name=staking_tx,json=stakingTx,proto3" json:"staking_tx,omitempty"` // staking_output_idx is the index of the staking output in the staking tx - StakingOutputIdx uint32 `protobuf:"varint,9,opt,name=staking_output_idx,json=stakingOutputIdx,proto3" json:"staking_output_idx,omitempty"` + StakingOutputIdx uint32 `protobuf:"varint,10,opt,name=staking_output_idx,json=stakingOutputIdx,proto3" json:"staking_output_idx,omitempty"` // slashing_tx is the slashing tx // It is partially signed by SK corresponding to btc_pk, but not signed by // finality provider or covenant yet. - SlashingTx *BTCSlashingTx `protobuf:"bytes,10,opt,name=slashing_tx,json=slashingTx,proto3,customtype=BTCSlashingTx" json:"slashing_tx,omitempty"` + SlashingTx *BTCSlashingTx `protobuf:"bytes,11,opt,name=slashing_tx,json=slashingTx,proto3,customtype=BTCSlashingTx" json:"slashing_tx,omitempty"` // delegator_sig is the signature on the slashing tx // by the delegator (i.e., SK corresponding to btc_pk). // It will be a part of the witness for the staking tx output. - DelegatorSig *github_com_babylonlabs_io_babylon_types.BIP340Signature `protobuf:"bytes,11,opt,name=delegator_sig,json=delegatorSig,proto3,customtype=github.com/babylonlabs-io/babylon/types.BIP340Signature" json:"delegator_sig,omitempty"` + DelegatorSig *github_com_babylonlabs_io_babylon_types.BIP340Signature `protobuf:"bytes,12,opt,name=delegator_sig,json=delegatorSig,proto3,customtype=github.com/babylonlabs-io/babylon/types.BIP340Signature" json:"delegator_sig,omitempty"` // covenant_sigs is a list of adaptor signatures on the slashing tx // by each covenant member // It will be a part of the witness for the staking tx output. - CovenantSigs []*CovenantAdaptorSignatures `protobuf:"bytes,12,rep,name=covenant_sigs,json=covenantSigs,proto3" json:"covenant_sigs,omitempty"` + CovenantSigs []*CovenantAdaptorSignatures `protobuf:"bytes,13,rep,name=covenant_sigs,json=covenantSigs,proto3" json:"covenant_sigs,omitempty"` // unbonding_time describes how long the funds will be locked either in unbonding output // or slashing change output - UnbondingTime uint32 `protobuf:"varint,13,opt,name=unbonding_time,json=unbondingTime,proto3" json:"unbonding_time,omitempty"` + UnbondingTime uint32 `protobuf:"varint,14,opt,name=unbonding_time,json=unbondingTime,proto3" json:"unbonding_time,omitempty"` // btc_undelegation is the information about the early unbonding path of the BTC delegation - BtcUndelegation *BTCUndelegation `protobuf:"bytes,14,opt,name=btc_undelegation,json=btcUndelegation,proto3" json:"btc_undelegation,omitempty"` + BtcUndelegation *BTCUndelegation `protobuf:"bytes,15,opt,name=btc_undelegation,json=btcUndelegation,proto3" json:"btc_undelegation,omitempty"` // version of the params used to validate the delegation - ParamsVersion uint32 `protobuf:"varint,15,opt,name=params_version,json=paramsVersion,proto3" json:"params_version,omitempty"` + ParamsVersion uint32 `protobuf:"varint,16,opt,name=params_version,json=paramsVersion,proto3" json:"params_version,omitempty"` } func (m *BTCDelegation) Reset() { *m = BTCDelegation{} } @@ -363,14 +377,21 @@ func (m *BTCDelegation) GetPop() *ProofOfPossessionBTC { return nil } -func (m *BTCDelegation) GetStartHeight() uint64 { +func (m *BTCDelegation) GetStakingTime() uint32 { + if m != nil { + return m.StakingTime + } + return 0 +} + +func (m *BTCDelegation) GetStartHeight() uint32 { if m != nil { return m.StartHeight } return 0 } -func (m *BTCDelegation) GetEndHeight() uint64 { +func (m *BTCDelegation) GetEndHeight() uint32 { if m != nil { return m.EndHeight } @@ -426,6 +447,56 @@ func (m *BTCDelegation) GetParamsVersion() uint32 { return 0 } +// DelegatorUnbondingInfo contains the information about transaction which spent +// the staking output. It contains: +// - spend_stake_tx: the transaction which spent the staking output +type DelegatorUnbondingInfo struct { + // spend_stake_tx is the transaction which spent the staking output. It is + // filled only if spend_stake_tx is different than unbonding_tx registered + // on the Babylon chain. + SpendStakeTx []byte `protobuf:"bytes,1,opt,name=spend_stake_tx,json=spendStakeTx,proto3" json:"spend_stake_tx,omitempty"` +} + +func (m *DelegatorUnbondingInfo) Reset() { *m = DelegatorUnbondingInfo{} } +func (m *DelegatorUnbondingInfo) String() string { return proto.CompactTextString(m) } +func (*DelegatorUnbondingInfo) ProtoMessage() {} +func (*DelegatorUnbondingInfo) Descriptor() ([]byte, []int) { + return fileDescriptor_3851ae95ccfaf7db, []int{3} +} +func (m *DelegatorUnbondingInfo) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *DelegatorUnbondingInfo) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_DelegatorUnbondingInfo.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 *DelegatorUnbondingInfo) XXX_Merge(src proto.Message) { + xxx_messageInfo_DelegatorUnbondingInfo.Merge(m, src) +} +func (m *DelegatorUnbondingInfo) XXX_Size() int { + return m.Size() +} +func (m *DelegatorUnbondingInfo) XXX_DiscardUnknown() { + xxx_messageInfo_DelegatorUnbondingInfo.DiscardUnknown(m) +} + +var xxx_messageInfo_DelegatorUnbondingInfo proto.InternalMessageInfo + +func (m *DelegatorUnbondingInfo) GetSpendStakeTx() []byte { + if m != nil { + return m.SpendStakeTx + } + return nil +} + // BTCUndelegation contains the information about the early unbonding path of the BTC delegation type BTCUndelegation struct { // unbonding_tx is the transaction which will transfer the funds from staking @@ -436,31 +507,28 @@ type BTCUndelegation struct { // It is partially signed by SK corresponding to btc_pk, but not signed by // finality provider or covenant yet. SlashingTx *BTCSlashingTx `protobuf:"bytes,2,opt,name=slashing_tx,json=slashingTx,proto3,customtype=BTCSlashingTx" json:"slashing_tx,omitempty"` - // delegator_unbonding_sig is the signature on the unbonding tx - // by the delegator (i.e., SK corresponding to btc_pk). - // It effectively proves that the delegator wants to unbond and thus - // Babylon will consider this BTC delegation unbonded. Delegator's BTC - // on Bitcoin will be unbonded after timelock - DelegatorUnbondingSig *github_com_babylonlabs_io_babylon_types.BIP340Signature `protobuf:"bytes,3,opt,name=delegator_unbonding_sig,json=delegatorUnbondingSig,proto3,customtype=github.com/babylonlabs-io/babylon/types.BIP340Signature" json:"delegator_unbonding_sig,omitempty"` // delegator_slashing_sig is the signature on the slashing tx // by the delegator (i.e., SK corresponding to btc_pk). // It will be a part of the witness for the unbonding tx output. - DelegatorSlashingSig *github_com_babylonlabs_io_babylon_types.BIP340Signature `protobuf:"bytes,4,opt,name=delegator_slashing_sig,json=delegatorSlashingSig,proto3,customtype=github.com/babylonlabs-io/babylon/types.BIP340Signature" json:"delegator_slashing_sig,omitempty"` + DelegatorSlashingSig *github_com_babylonlabs_io_babylon_types.BIP340Signature `protobuf:"bytes,3,opt,name=delegator_slashing_sig,json=delegatorSlashingSig,proto3,customtype=github.com/babylonlabs-io/babylon/types.BIP340Signature" json:"delegator_slashing_sig,omitempty"` // covenant_slashing_sigs is a list of adaptor signatures on the slashing tx // by each covenant member // It will be a part of the witness for the staking tx output. - CovenantSlashingSigs []*CovenantAdaptorSignatures `protobuf:"bytes,5,rep,name=covenant_slashing_sigs,json=covenantSlashingSigs,proto3" json:"covenant_slashing_sigs,omitempty"` + CovenantSlashingSigs []*CovenantAdaptorSignatures `protobuf:"bytes,4,rep,name=covenant_slashing_sigs,json=covenantSlashingSigs,proto3" json:"covenant_slashing_sigs,omitempty"` // covenant_unbonding_sig_list is the list of signatures on the unbonding tx // by covenant members // It must be provided after processing undelegate message by Babylon - CovenantUnbondingSigList []*SignatureInfo `protobuf:"bytes,6,rep,name=covenant_unbonding_sig_list,json=covenantUnbondingSigList,proto3" json:"covenant_unbonding_sig_list,omitempty"` + CovenantUnbondingSigList []*SignatureInfo `protobuf:"bytes,5,rep,name=covenant_unbonding_sig_list,json=covenantUnbondingSigList,proto3" json:"covenant_unbonding_sig_list,omitempty"` + // delegator_unbonding_info is the information about transaction which spent + // the staking output + DelegatorUnbondingInfo *DelegatorUnbondingInfo `protobuf:"bytes,6,opt,name=delegator_unbonding_info,json=delegatorUnbondingInfo,proto3" json:"delegator_unbonding_info,omitempty"` } func (m *BTCUndelegation) Reset() { *m = BTCUndelegation{} } func (m *BTCUndelegation) String() string { return proto.CompactTextString(m) } func (*BTCUndelegation) ProtoMessage() {} func (*BTCUndelegation) Descriptor() ([]byte, []int) { - return fileDescriptor_3851ae95ccfaf7db, []int{3} + return fileDescriptor_3851ae95ccfaf7db, []int{4} } func (m *BTCUndelegation) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -510,6 +578,13 @@ func (m *BTCUndelegation) GetCovenantUnbondingSigList() []*SignatureInfo { return nil } +func (m *BTCUndelegation) GetDelegatorUnbondingInfo() *DelegatorUnbondingInfo { + if m != nil { + return m.DelegatorUnbondingInfo + } + return nil +} + // BTCDelegatorDelegations is a collection of BTC delegations from the same delegator. type BTCDelegatorDelegations struct { Dels []*BTCDelegation `protobuf:"bytes,1,rep,name=dels,proto3" json:"dels,omitempty"` @@ -519,7 +594,7 @@ func (m *BTCDelegatorDelegations) Reset() { *m = BTCDelegatorDelegations func (m *BTCDelegatorDelegations) String() string { return proto.CompactTextString(m) } func (*BTCDelegatorDelegations) ProtoMessage() {} func (*BTCDelegatorDelegations) Descriptor() ([]byte, []int) { - return fileDescriptor_3851ae95ccfaf7db, []int{4} + return fileDescriptor_3851ae95ccfaf7db, []int{5} } func (m *BTCDelegatorDelegations) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -564,7 +639,7 @@ func (m *BTCDelegatorDelegationIndex) Reset() { *m = BTCDelegatorDelegat func (m *BTCDelegatorDelegationIndex) String() string { return proto.CompactTextString(m) } func (*BTCDelegatorDelegationIndex) ProtoMessage() {} func (*BTCDelegatorDelegationIndex) Descriptor() ([]byte, []int) { - return fileDescriptor_3851ae95ccfaf7db, []int{5} + return fileDescriptor_3851ae95ccfaf7db, []int{6} } func (m *BTCDelegatorDelegationIndex) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -610,7 +685,7 @@ func (m *SignatureInfo) Reset() { *m = SignatureInfo{} } func (m *SignatureInfo) String() string { return proto.CompactTextString(m) } func (*SignatureInfo) ProtoMessage() {} func (*SignatureInfo) Descriptor() ([]byte, []int) { - return fileDescriptor_3851ae95ccfaf7db, []int{6} + return fileDescriptor_3851ae95ccfaf7db, []int{7} } func (m *SignatureInfo) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -652,7 +727,7 @@ func (m *CovenantAdaptorSignatures) Reset() { *m = CovenantAdaptorSignat func (m *CovenantAdaptorSignatures) String() string { return proto.CompactTextString(m) } func (*CovenantAdaptorSignatures) ProtoMessage() {} func (*CovenantAdaptorSignatures) Descriptor() ([]byte, []int) { - return fileDescriptor_3851ae95ccfaf7db, []int{7} + return fileDescriptor_3851ae95ccfaf7db, []int{8} } func (m *CovenantAdaptorSignatures) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -711,7 +786,7 @@ func (m *SelectiveSlashingEvidence) Reset() { *m = SelectiveSlashingEvid func (m *SelectiveSlashingEvidence) String() string { return proto.CompactTextString(m) } func (*SelectiveSlashingEvidence) ProtoMessage() {} func (*SelectiveSlashingEvidence) Descriptor() ([]byte, []int) { - return fileDescriptor_3851ae95ccfaf7db, []int{8} + return fileDescriptor_3851ae95ccfaf7db, []int{9} } func (m *SelectiveSlashingEvidence) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -754,17 +829,77 @@ func (m *SelectiveSlashingEvidence) GetRecoveredFpBtcSk() []byte { return nil } +// InclusionProof proves the existence of tx on BTC blockchain +// including +// - the position of the tx on BTC blockchain +// - the Merkle proof that this tx is on the above position +type InclusionProof struct { + // key is the position (txIdx, blockHash) of this tx on BTC blockchain + Key *types1.TransactionKey `protobuf:"bytes,1,opt,name=key,proto3" json:"key,omitempty"` + // proof is the Merkle proof that this tx is included in the position in `key` + Proof []byte `protobuf:"bytes,2,opt,name=proof,proto3" json:"proof,omitempty"` +} + +func (m *InclusionProof) Reset() { *m = InclusionProof{} } +func (m *InclusionProof) String() string { return proto.CompactTextString(m) } +func (*InclusionProof) ProtoMessage() {} +func (*InclusionProof) Descriptor() ([]byte, []int) { + return fileDescriptor_3851ae95ccfaf7db, []int{10} +} +func (m *InclusionProof) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *InclusionProof) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_InclusionProof.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 *InclusionProof) XXX_Merge(src proto.Message) { + xxx_messageInfo_InclusionProof.Merge(m, src) +} +func (m *InclusionProof) XXX_Size() int { + return m.Size() +} +func (m *InclusionProof) XXX_DiscardUnknown() { + xxx_messageInfo_InclusionProof.DiscardUnknown(m) +} + +var xxx_messageInfo_InclusionProof proto.InternalMessageInfo + +func (m *InclusionProof) GetKey() *types1.TransactionKey { + if m != nil { + return m.Key + } + return nil +} + +func (m *InclusionProof) GetProof() []byte { + if m != nil { + return m.Proof + } + return nil +} + func init() { proto.RegisterEnum("babylon.btcstaking.v1.BTCDelegationStatus", BTCDelegationStatus_name, BTCDelegationStatus_value) proto.RegisterType((*FinalityProvider)(nil), "babylon.btcstaking.v1.FinalityProvider") proto.RegisterType((*FinalityProviderWithMeta)(nil), "babylon.btcstaking.v1.FinalityProviderWithMeta") proto.RegisterType((*BTCDelegation)(nil), "babylon.btcstaking.v1.BTCDelegation") + proto.RegisterType((*DelegatorUnbondingInfo)(nil), "babylon.btcstaking.v1.DelegatorUnbondingInfo") proto.RegisterType((*BTCUndelegation)(nil), "babylon.btcstaking.v1.BTCUndelegation") proto.RegisterType((*BTCDelegatorDelegations)(nil), "babylon.btcstaking.v1.BTCDelegatorDelegations") proto.RegisterType((*BTCDelegatorDelegationIndex)(nil), "babylon.btcstaking.v1.BTCDelegatorDelegationIndex") proto.RegisterType((*SignatureInfo)(nil), "babylon.btcstaking.v1.SignatureInfo") proto.RegisterType((*CovenantAdaptorSignatures)(nil), "babylon.btcstaking.v1.CovenantAdaptorSignatures") proto.RegisterType((*SelectiveSlashingEvidence)(nil), "babylon.btcstaking.v1.SelectiveSlashingEvidence") + proto.RegisterType((*InclusionProof)(nil), "babylon.btcstaking.v1.InclusionProof") } func init() { @@ -772,84 +907,93 @@ func init() { } var fileDescriptor_3851ae95ccfaf7db = []byte{ - // 1232 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x57, 0xdd, 0x6e, 0x1b, 0xc5, - 0x17, 0xcf, 0xda, 0x8e, 0x93, 0x9c, 0xb5, 0x1b, 0x77, 0x9a, 0xa6, 0xdb, 0x46, 0xff, 0x24, 0x7f, - 0x53, 0xaa, 0x08, 0x1a, 0xbb, 0x5f, 0x12, 0x45, 0x88, 0x8b, 0x38, 0x4e, 0xa9, 0x45, 0xeb, 0x98, - 0xb5, 0x53, 0x04, 0x12, 0x5a, 0xc6, 0xbb, 0xe3, 0xf5, 0x60, 0x7b, 0x67, 0xd9, 0x19, 0x1b, 0xe7, - 0x9a, 0x07, 0x80, 0x17, 0xe0, 0x86, 0x2b, 0x1e, 0xa0, 0x0f, 0xd1, 0xcb, 0xaa, 0x57, 0x28, 0x17, - 0x11, 0x6a, 0x1f, 0x81, 0x17, 0x40, 0x33, 0xbb, 0x5e, 0xaf, 0x4b, 0x53, 0xd2, 0x26, 0x77, 0x9e, - 0xf3, 0xf5, 0x3b, 0x1f, 0xbf, 0x39, 0xe3, 0x85, 0x1b, 0x6d, 0xdc, 0x3e, 0xec, 0x33, 0xaf, 0xdc, - 0x16, 0x36, 0x17, 0xb8, 0x47, 0x3d, 0xb7, 0x3c, 0xba, 0x9d, 0x38, 0x95, 0xfc, 0x80, 0x09, 0x86, - 0x2e, 0x47, 0x76, 0xa5, 0x84, 0x66, 0x74, 0xfb, 0xda, 0x8a, 0xcb, 0x5c, 0xa6, 0x2c, 0xca, 0xf2, - 0x57, 0x68, 0x7c, 0xed, 0xaa, 0xcd, 0xf8, 0x80, 0x71, 0x2b, 0x54, 0x84, 0x87, 0x48, 0x75, 0x3d, - 0x3c, 0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0x4d, 0xd0, 0x0d, 0x58, 0x7e, 0x6d, 0x16, 0xe1, 0x3b, 0x6c, 0xe6, 0x67, - 0xc6, 0x80, 0x5a, 0xb0, 0x14, 0x3f, 0x70, 0x67, 0x7e, 0x73, 0x17, 0xa2, 0xb7, 0x0d, 0x6d, 0xc3, - 0xa5, 0x80, 0x48, 0x6e, 0x06, 0xc4, 0xb1, 0xa2, 0xf8, 0xbc, 0x17, 0xae, 0x0b, 0xb3, 0x10, 0xab, - 0x1e, 0x48, 0xf3, 0x66, 0xef, 0xa3, 0x3d, 0xb8, 0x34, 0x43, 0xb7, 0xa6, 0xc0, 0x62, 0xc8, 0x91, - 0x0e, 0x0b, 0x8d, 0xbd, 0x7a, 0xb5, 0x56, 0xff, 0xa2, 0x30, 0x87, 0x00, 0xb2, 0x3b, 0xbb, 0xad, - 0xda, 0x93, 0xbd, 0x82, 0x86, 0x72, 0xb0, 0x78, 0x50, 0xaf, 0xec, 0xd7, 0xab, 0x7b, 0xd5, 0x42, - 0x0a, 0x2d, 0x40, 0x7a, 0xa7, 0xfe, 0x4d, 0x21, 0x5d, 0xa9, 0x3f, 0x7b, 0xb9, 0xae, 0x3d, 0x7f, - 0xb9, 0xae, 0xfd, 0xf5, 0x72, 0x5d, 0xfb, 0xf5, 0xd5, 0xfa, 0xdc, 0xf3, 0x57, 0xeb, 0x73, 0x7f, - 0xbe, 0x5a, 0x9f, 0xfb, 0xf6, 0x14, 0xe5, 0x8c, 0x93, 0xdf, 0x02, 0xaa, 0xb6, 0x76, 0x56, 0x7d, - 0x0b, 0xdc, 0xfd, 0x27, 0x00, 0x00, 0xff, 0xff, 0x7b, 0x70, 0xf4, 0xf1, 0xc4, 0x0c, 0x00, 0x00, + // 1362 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x57, 0xcd, 0x6e, 0xdb, 0xc6, + 0x16, 0x36, 0x25, 0xf9, 0xef, 0x50, 0xb2, 0x95, 0x89, 0xaf, 0x2f, 0x13, 0xe3, 0xda, 0xbe, 0xba, + 0xb9, 0x81, 0xd0, 0xc6, 0x52, 0xec, 0x04, 0x68, 0xda, 0xa2, 0x05, 0x2c, 0xcb, 0x69, 0x84, 0x26, + 0xb6, 0x4a, 0xc9, 0x29, 0x5a, 0xa0, 0x60, 0x29, 0x72, 0x4c, 0x4d, 0x25, 0x71, 0x58, 0xce, 0x48, + 0x95, 0xd7, 0x7d, 0x80, 0xb6, 0x9b, 0x3e, 0x40, 0x57, 0x7d, 0x80, 0x3c, 0x44, 0x96, 0x41, 0x56, + 0x85, 0x17, 0x46, 0x91, 0xbc, 0x48, 0x31, 0xc3, 0x11, 0x49, 0xa7, 0x76, 0x9a, 0xc4, 0xde, 0x69, + 0xce, 0xff, 0x7c, 0xe7, 0x3b, 0x67, 0x44, 0xb8, 0xd9, 0xb1, 0x3b, 0x47, 0x7d, 0xea, 0x57, 0x3b, + 0xdc, 0x61, 0xdc, 0xee, 0x11, 0xdf, 0xab, 0x8e, 0x36, 0x53, 0xa7, 0x4a, 0x10, 0x52, 0x4e, 0xd1, + 0xbf, 0x94, 0x5d, 0x25, 0xa5, 0x19, 0x6d, 0x5e, 0x5f, 0xf2, 0xa8, 0x47, 0xa5, 0x45, 0x55, 0xfc, + 0x8a, 0x8c, 0xaf, 0x5f, 0x73, 0x28, 0x1b, 0x50, 0x66, 0x45, 0x8a, 0xe8, 0xa0, 0x54, 0x37, 0xa2, + 0x53, 0x35, 0xc9, 0xd5, 0xc1, 0xdc, 0xde, 0xac, 0x9e, 0xca, 0x76, 0x7d, 0xed, 0xec, 0xaa, 0x02, + 0x1a, 0x28, 0x83, 0x5b, 0x29, 0x03, 0xa7, 0x8b, 0x9d, 0x5e, 0x40, 0x89, 0xcf, 0x55, 0xe5, 0x89, + 0x20, 0xb2, 0x2e, 0xfd, 0x98, 0x83, 0xe2, 0x7d, 0xe2, 0xdb, 0x7d, 0xc2, 0x8f, 0x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ef, 0xfd, 0xca, 0x99, 0x4d, 0xaf, 0x34, 0x43, 0x4a, 0x0f, 0xf7, 0x0f, 0x9b, 0x94, + 0x31, 0x2c, 0xeb, 0xa8, 0xb5, 0x77, 0x4c, 0xe1, 0x87, 0xee, 0xc2, 0x32, 0xeb, 0xdb, 0xac, 0x8b, + 0x5d, 0x4b, 0xb9, 0x5a, 0x5d, 0x4c, 0xbc, 0x2e, 0x37, 0x66, 0xd6, 0xb5, 0x72, 0xce, 0x5c, 0x52, + 0xda, 0x5a, 0xa4, 0x7c, 0x20, 0x75, 0xe8, 0x16, 0xa0, 0xd8, 0x8b, 0x3b, 0x13, 0x8f, 0xd9, 0x75, + 0xad, 0x5c, 0x30, 0x8b, 0x13, 0x0f, 0xee, 0x28, 0xeb, 0x65, 0x98, 0xf9, 0xce, 0x26, 0x7d, 0xec, + 0x1a, 0x73, 0xeb, 0x5a, 0x79, 0xce, 0x54, 0x27, 0xb4, 0x06, 0xba, 0x43, 0x7d, 0x36, 0x1c, 0xe0, + 0xd0, 0x22, 0xae, 0x31, 0x2f, 0xb0, 0x15, 0x60, 0x45, 0xa2, 0x86, 0x5b, 0xfa, 0x2d, 0x03, 0xc6, + 0xab, 0x2c, 0xf8, 0x92, 0xf0, 0xee, 0x23, 0xcc, 0xed, 0x14, 0x92, 0xda, 0xe5, 0x20, 0xb9, 0x0c, + 0x33, 0xea, 0x22, 0x19, 0x79, 0x75, 0x75, 0x42, 0xff, 0x85, 0xfc, 0x88, 0x72, 0xe2, 0x7b, 0x56, + 0x40, 0x7f, 0xc0, 0xa1, 0xe4, 0x40, 0xce, 0xd4, 0x23, 0x59, 0x53, 0x88, 0x5e, 0x83, 0x62, 0xee, + 0xad, 0x51, 0x9c, 0xfe, 0x47, 0x14, 0x67, 0xd2, 0x28, 0x96, 0x7e, 0x9d, 0x85, 0x42, 0xad, 0xbd, + 0x53, 0xc7, 0x7d, 0xec, 0xd9, 0x92, 0xb2, 0x1f, 0x82, 0x2e, 0x7a, 0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, 0xb7, 0xf7, 0xbe, 0x2a, 0xe6, 0x6a, 0x7b, 0x4f, 0x5f, 0xac, 0x6a, + 0xcf, 0x5e, 0xac, 0x6a, 0x7f, 0xbe, 0x58, 0xd5, 0x7e, 0x7e, 0xb9, 0x3a, 0xf5, 0xec, 0xe5, 0xea, + 0xd4, 0x1f, 0x2f, 0x57, 0xa7, 0xbe, 0x7e, 0x03, 0x00, 0xc7, 0xe9, 0x4f, 0x20, 0x89, 0x66, 0x67, + 0x46, 0x7e, 0xd4, 0xdc, 0xf9, 0x2b, 0x00, 0x00, 0xff, 0xff, 0xec, 0x60, 0x15, 0xaa, 0xbb, 0x0d, + 0x00, 0x00, } func (m *FinalityProvider) Marshal() (dAtA []byte, err error) { @@ -1045,7 +1189,9 @@ func (m *BTCDelegation) MarshalToSizedBuffer(dAtA []byte) (int, error) { if m.ParamsVersion != 0 { i = encodeVarintBtcstaking(dAtA, i, uint64(m.ParamsVersion)) i-- - dAtA[i] = 0x78 + dAtA[i] = 0x1 + i-- + dAtA[i] = 0x80 } if m.BtcUndelegation != nil { { @@ -1057,12 +1203,12 @@ func (m *BTCDelegation) MarshalToSizedBuffer(dAtA []byte) (int, error) { i = encodeVarintBtcstaking(dAtA, i, uint64(size)) } i-- - dAtA[i] = 0x72 + dAtA[i] = 0x7a } if m.UnbondingTime != 0 { i = encodeVarintBtcstaking(dAtA, i, uint64(m.UnbondingTime)) i-- - dAtA[i] = 0x68 + dAtA[i] = 0x70 } if len(m.CovenantSigs) > 0 { for iNdEx := len(m.CovenantSigs) - 1; iNdEx >= 0; iNdEx-- { @@ -1075,7 +1221,7 @@ func (m *BTCDelegation) MarshalToSizedBuffer(dAtA []byte) (int, error) { i = encodeVarintBtcstaking(dAtA, i, uint64(size)) } i-- - dAtA[i] = 0x62 + dAtA[i] = 0x6a } } if m.DelegatorSig != nil { @@ -1088,7 +1234,7 @@ func (m *BTCDelegation) MarshalToSizedBuffer(dAtA []byte) (int, error) { i = encodeVarintBtcstaking(dAtA, i, uint64(size)) } i-- - dAtA[i] = 0x5a + dAtA[i] = 0x62 } if m.SlashingTx != nil { { @@ -1100,33 +1246,38 @@ func (m *BTCDelegation) MarshalToSizedBuffer(dAtA []byte) (int, error) { i = encodeVarintBtcstaking(dAtA, i, uint64(size)) } i-- - dAtA[i] = 0x52 + dAtA[i] = 0x5a } if m.StakingOutputIdx != 0 { i = encodeVarintBtcstaking(dAtA, i, uint64(m.StakingOutputIdx)) i-- - dAtA[i] = 0x48 + dAtA[i] = 0x50 } if len(m.StakingTx) > 0 { i -= len(m.StakingTx) copy(dAtA[i:], m.StakingTx) i = encodeVarintBtcstaking(dAtA, i, uint64(len(m.StakingTx))) i-- - dAtA[i] = 0x42 + dAtA[i] = 0x4a } if m.TotalSat != 0 { i = encodeVarintBtcstaking(dAtA, i, uint64(m.TotalSat)) i-- - dAtA[i] = 0x38 + dAtA[i] = 0x40 } if m.EndHeight != 0 { i = encodeVarintBtcstaking(dAtA, i, uint64(m.EndHeight)) i-- - dAtA[i] = 0x30 + dAtA[i] = 0x38 } if m.StartHeight != 0 { i = encodeVarintBtcstaking(dAtA, i, uint64(m.StartHeight)) i-- + dAtA[i] = 0x30 + } + if m.StakingTime != 0 { + i = encodeVarintBtcstaking(dAtA, i, uint64(m.StakingTime)) + i-- dAtA[i] = 0x28 } if len(m.FpBtcPkList) > 0 { @@ -1177,6 +1328,36 @@ func (m *BTCDelegation) MarshalToSizedBuffer(dAtA []byte) (int, error) { return len(dAtA) - i, nil } +func (m *DelegatorUnbondingInfo) 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 *DelegatorUnbondingInfo) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *DelegatorUnbondingInfo) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.SpendStakeTx) > 0 { + i -= len(m.SpendStakeTx) + copy(dAtA[i:], m.SpendStakeTx) + i = encodeVarintBtcstaking(dAtA, i, uint64(len(m.SpendStakeTx))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + func (m *BTCUndelegation) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) @@ -1197,6 +1378,18 @@ func (m *BTCUndelegation) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l + if m.DelegatorUnbondingInfo != nil { + { + size, err := m.DelegatorUnbondingInfo.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintBtcstaking(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x32 + } if len(m.CovenantUnbondingSigList) > 0 { for iNdEx := len(m.CovenantUnbondingSigList) - 1; iNdEx >= 0; iNdEx-- { { @@ -1208,7 +1401,7 @@ func (m *BTCUndelegation) MarshalToSizedBuffer(dAtA []byte) (int, error) { i = encodeVarintBtcstaking(dAtA, i, uint64(size)) } i-- - dAtA[i] = 0x32 + dAtA[i] = 0x2a } } if len(m.CovenantSlashingSigs) > 0 { @@ -1222,7 +1415,7 @@ func (m *BTCUndelegation) MarshalToSizedBuffer(dAtA []byte) (int, error) { i = encodeVarintBtcstaking(dAtA, i, uint64(size)) } i-- - dAtA[i] = 0x2a + dAtA[i] = 0x22 } } if m.DelegatorSlashingSig != nil { @@ -1235,18 +1428,6 @@ func (m *BTCUndelegation) MarshalToSizedBuffer(dAtA []byte) (int, error) { i = encodeVarintBtcstaking(dAtA, i, uint64(size)) } i-- - dAtA[i] = 0x22 - } - if m.DelegatorUnbondingSig != nil { - { - size := m.DelegatorUnbondingSig.Size() - i -= size - if _, err := m.DelegatorUnbondingSig.MarshalTo(dAtA[i:]); err != nil { - return 0, err - } - i = encodeVarintBtcstaking(dAtA, i, uint64(size)) - } - i-- dAtA[i] = 0x1a } if m.SlashingTx != nil { @@ -1480,6 +1661,48 @@ func (m *SelectiveSlashingEvidence) MarshalToSizedBuffer(dAtA []byte) (int, erro return len(dAtA) - i, nil } +func (m *InclusionProof) 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 *InclusionProof) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *InclusionProof) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Proof) > 0 { + i -= len(m.Proof) + copy(dAtA[i:], m.Proof) + i = encodeVarintBtcstaking(dAtA, i, uint64(len(m.Proof))) + i-- + dAtA[i] = 0x12 + } + if m.Key != nil { + { + size, err := m.Key.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintBtcstaking(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + func encodeVarintBtcstaking(dAtA []byte, offset int, v uint64) int { offset -= sovBtcstaking(v) base := offset @@ -1585,6 +1808,9 @@ func (m *BTCDelegation) Size() (n int) { n += 1 + l + sovBtcstaking(uint64(l)) } } + if m.StakingTime != 0 { + n += 1 + sovBtcstaking(uint64(m.StakingTime)) + } if m.StartHeight != 0 { n += 1 + sovBtcstaking(uint64(m.StartHeight)) } @@ -1623,7 +1849,20 @@ func (m *BTCDelegation) Size() (n int) { n += 1 + l + sovBtcstaking(uint64(l)) } if m.ParamsVersion != 0 { - n += 1 + sovBtcstaking(uint64(m.ParamsVersion)) + n += 2 + sovBtcstaking(uint64(m.ParamsVersion)) + } + return n +} + +func (m *DelegatorUnbondingInfo) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.SpendStakeTx) + if l > 0 { + n += 1 + l + sovBtcstaking(uint64(l)) } return n } @@ -1642,10 +1881,6 @@ func (m *BTCUndelegation) Size() (n int) { l = m.SlashingTx.Size() n += 1 + l + sovBtcstaking(uint64(l)) } - if m.DelegatorUnbondingSig != nil { - l = m.DelegatorUnbondingSig.Size() - n += 1 + l + sovBtcstaking(uint64(l)) - } if m.DelegatorSlashingSig != nil { l = m.DelegatorSlashingSig.Size() n += 1 + l + sovBtcstaking(uint64(l)) @@ -1662,6 +1897,10 @@ func (m *BTCUndelegation) Size() (n int) { n += 1 + l + sovBtcstaking(uint64(l)) } } + if m.DelegatorUnbondingInfo != nil { + l = m.DelegatorUnbondingInfo.Size() + n += 1 + l + sovBtcstaking(uint64(l)) + } return n } @@ -1752,6 +1991,23 @@ func (m *SelectiveSlashingEvidence) Size() (n int) { return n } +func (m *InclusionProof) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.Key != nil { + l = m.Key.Size() + n += 1 + l + sovBtcstaking(uint64(l)) + } + l = len(m.Proof) + if l > 0 { + n += 1 + l + sovBtcstaking(uint64(l)) + } + return n +} + func sovBtcstaking(x uint64) (n int) { return (math_bits.Len64(x|1) + 6) / 7 } @@ -1995,7 +2251,7 @@ func (m *FinalityProvider) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - m.SlashedBtcHeight |= uint64(b&0x7F) << shift + m.SlashedBtcHeight |= uint32(b&0x7F) << shift if b < 0x80 { break } @@ -2208,7 +2464,7 @@ func (m *FinalityProviderWithMeta) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - m.SlashedBtcHeight |= uint64(b&0x7F) << shift + m.SlashedBtcHeight |= uint32(b&0x7F) << shift if b < 0x80 { break } @@ -2422,6 +2678,25 @@ func (m *BTCDelegation) Unmarshal(dAtA []byte) error { } iNdEx = postIndex case 5: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field StakingTime", wireType) + } + m.StakingTime = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowBtcstaking + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.StakingTime |= uint32(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 6: if wireType != 0 { return fmt.Errorf("proto: wrong wireType = %d for field StartHeight", wireType) } @@ -2435,12 +2710,12 @@ func (m *BTCDelegation) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - m.StartHeight |= uint64(b&0x7F) << shift + m.StartHeight |= uint32(b&0x7F) << shift if b < 0x80 { break } } - case 6: + case 7: if wireType != 0 { return fmt.Errorf("proto: wrong wireType = %d for field EndHeight", wireType) } @@ -2454,12 +2729,12 @@ func (m *BTCDelegation) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - m.EndHeight |= uint64(b&0x7F) << shift + m.EndHeight |= uint32(b&0x7F) << shift if b < 0x80 { break } } - case 7: + case 8: if wireType != 0 { return fmt.Errorf("proto: wrong wireType = %d for field TotalSat", wireType) } @@ -2478,7 +2753,7 @@ func (m *BTCDelegation) Unmarshal(dAtA []byte) error { break } } - case 8: + case 9: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field StakingTx", wireType) } @@ -2512,7 +2787,7 @@ func (m *BTCDelegation) Unmarshal(dAtA []byte) error { m.StakingTx = []byte{} } iNdEx = postIndex - case 9: + case 10: if wireType != 0 { return fmt.Errorf("proto: wrong wireType = %d for field StakingOutputIdx", wireType) } @@ -2531,7 +2806,7 @@ func (m *BTCDelegation) Unmarshal(dAtA []byte) error { break } } - case 10: + case 11: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field SlashingTx", wireType) } @@ -2566,7 +2841,7 @@ func (m *BTCDelegation) Unmarshal(dAtA []byte) error { return err } iNdEx = postIndex - case 11: + case 12: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field DelegatorSig", wireType) } @@ -2601,7 +2876,7 @@ func (m *BTCDelegation) Unmarshal(dAtA []byte) error { return err } iNdEx = postIndex - case 12: + case 13: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field CovenantSigs", wireType) } @@ -2635,7 +2910,7 @@ func (m *BTCDelegation) Unmarshal(dAtA []byte) error { return err } iNdEx = postIndex - case 13: + case 14: if wireType != 0 { return fmt.Errorf("proto: wrong wireType = %d for field UnbondingTime", wireType) } @@ -2654,7 +2929,7 @@ func (m *BTCDelegation) Unmarshal(dAtA []byte) error { break } } - case 14: + case 15: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field BtcUndelegation", wireType) } @@ -2690,7 +2965,7 @@ func (m *BTCDelegation) Unmarshal(dAtA []byte) error { return err } iNdEx = postIndex - case 15: + case 16: if wireType != 0 { return fmt.Errorf("proto: wrong wireType = %d for field ParamsVersion", wireType) } @@ -2730,6 +3005,90 @@ func (m *BTCDelegation) Unmarshal(dAtA []byte) error { } return nil } +func (m *DelegatorUnbondingInfo) 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 ErrIntOverflowBtcstaking + } + 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: DelegatorUnbondingInfo: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: DelegatorUnbondingInfo: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field SpendStakeTx", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowBtcstaking + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthBtcstaking + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthBtcstaking + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.SpendStakeTx = append(m.SpendStakeTx[:0], dAtA[iNdEx:postIndex]...) + if m.SpendStakeTx == nil { + m.SpendStakeTx = []byte{} + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipBtcstaking(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthBtcstaking + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} func (m *BTCUndelegation) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 @@ -2830,7 +3189,7 @@ func (m *BTCUndelegation) Unmarshal(dAtA []byte) error { iNdEx = postIndex case 3: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field DelegatorUnbondingSig", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field DelegatorSlashingSig", wireType) } var byteLen int for shift := uint(0); ; shift += 7 { @@ -2858,16 +3217,16 @@ func (m *BTCUndelegation) Unmarshal(dAtA []byte) error { return io.ErrUnexpectedEOF } var v github_com_babylonlabs_io_babylon_types.BIP340Signature - m.DelegatorUnbondingSig = &v - if err := m.DelegatorUnbondingSig.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + m.DelegatorSlashingSig = &v + if err := m.DelegatorSlashingSig.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } iNdEx = postIndex case 4: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field DelegatorSlashingSig", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field CovenantSlashingSigs", wireType) } - var byteLen int + var msglen int for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowBtcstaking @@ -2877,30 +3236,29 @@ func (m *BTCUndelegation) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - byteLen |= int(b&0x7F) << shift + msglen |= int(b&0x7F) << shift if b < 0x80 { break } } - if byteLen < 0 { + if msglen < 0 { return ErrInvalidLengthBtcstaking } - postIndex := iNdEx + byteLen + postIndex := iNdEx + msglen if postIndex < 0 { return ErrInvalidLengthBtcstaking } if postIndex > l { return io.ErrUnexpectedEOF } - var v github_com_babylonlabs_io_babylon_types.BIP340Signature - m.DelegatorSlashingSig = &v - if err := m.DelegatorSlashingSig.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + m.CovenantSlashingSigs = append(m.CovenantSlashingSigs, &CovenantAdaptorSignatures{}) + if err := m.CovenantSlashingSigs[len(m.CovenantSlashingSigs)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } iNdEx = postIndex case 5: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field CovenantSlashingSigs", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field CovenantUnbondingSigList", wireType) } var msglen int for shift := uint(0); ; shift += 7 { @@ -2927,14 +3285,14 @@ func (m *BTCUndelegation) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.CovenantSlashingSigs = append(m.CovenantSlashingSigs, &CovenantAdaptorSignatures{}) - if err := m.CovenantSlashingSigs[len(m.CovenantSlashingSigs)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + m.CovenantUnbondingSigList = append(m.CovenantUnbondingSigList, &SignatureInfo{}) + if err := m.CovenantUnbondingSigList[len(m.CovenantUnbondingSigList)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } iNdEx = postIndex case 6: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field CovenantUnbondingSigList", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field DelegatorUnbondingInfo", wireType) } var msglen int for shift := uint(0); ; shift += 7 { @@ -2961,8 +3319,10 @@ func (m *BTCUndelegation) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.CovenantUnbondingSigList = append(m.CovenantUnbondingSigList, &SignatureInfo{}) - if err := m.CovenantUnbondingSigList[len(m.CovenantUnbondingSigList)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + if m.DelegatorUnbondingInfo == nil { + m.DelegatorUnbondingInfo = &DelegatorUnbondingInfo{} + } + if err := m.DelegatorUnbondingInfo.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } iNdEx = postIndex @@ -3541,6 +3901,126 @@ func (m *SelectiveSlashingEvidence) Unmarshal(dAtA []byte) error { } return nil } +func (m *InclusionProof) 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 ErrIntOverflowBtcstaking + } + 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: InclusionProof: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: InclusionProof: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Key", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowBtcstaking + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthBtcstaking + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthBtcstaking + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.Key == nil { + m.Key = &types1.TransactionKey{} + } + if err := m.Key.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Proof", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowBtcstaking + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthBtcstaking + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthBtcstaking + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Proof = append(m.Proof[:0], dAtA[iNdEx:postIndex]...) + if m.Proof == nil { + m.Proof = []byte{} + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipBtcstaking(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthBtcstaking + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} func skipBtcstaking(dAtA []byte) (n int, err error) { l := len(dAtA) iNdEx := 0 diff --git a/x/btcstaking/types/codec.go b/x/btcstaking/types/codec.go index e859ded71..1f5b890d8 100644 --- a/x/btcstaking/types/codec.go +++ b/x/btcstaking/types/codec.go @@ -14,6 +14,7 @@ func RegisterCodec(cdc *codec.LegacyAmino) { cdc.RegisterConcrete(&MsgAddCovenantSigs{}, "btcstaking/MsgAddCovenantSigs", nil) cdc.RegisterConcrete(&MsgBTCUndelegate{}, "btcstaking/MsgBTCUndelegate", nil) cdc.RegisterConcrete(&MsgUpdateParams{}, "btcstaking/MsgUpdateParams", nil) + cdc.RegisterConcrete(&MsgAddBTCDelegationInclusionProof{}, "btcstaking/MsgAddBTCDelegationInclusionProof", nil) } func RegisterInterfaces(registry cdctypes.InterfaceRegistry) { @@ -26,6 +27,7 @@ func RegisterInterfaces(registry cdctypes.InterfaceRegistry) { &MsgAddCovenantSigs{}, &MsgBTCUndelegate{}, &MsgUpdateParams{}, + &MsgAddBTCDelegationInclusionProof{}, ) msgservice.RegisterMsgServiceDesc(registry, &_Msg_serviceDesc) diff --git a/x/btcstaking/types/create_delegation_parser.go b/x/btcstaking/types/create_delegation_parser.go index 44b645e03..a00fa5640 100644 --- a/x/btcstaking/types/create_delegation_parser.go +++ b/x/btcstaking/types/create_delegation_parser.go @@ -2,16 +2,15 @@ package types import ( "fmt" - math "math" + "math" - "github.com/babylonlabs-io/babylon/btcstaking" - bbn "github.com/babylonlabs-io/babylon/types" - btcckpttypes "github.com/babylonlabs-io/babylon/x/btccheckpoint/types" "github.com/btcsuite/btcd/btcec/v2" "github.com/btcsuite/btcd/btcec/v2/schnorr" "github.com/btcsuite/btcd/btcutil" "github.com/btcsuite/btcd/wire" sdk "github.com/cosmos/cosmos-sdk/types" + + bbn "github.com/babylonlabs-io/babylon/types" ) type ParsedPublicKey struct { @@ -21,7 +20,7 @@ type ParsedPublicKey struct { func NewParsedPublicKey(key *bbn.BIP340PubKey) (*ParsedPublicKey, error) { if key == nil { - return nil, fmt.Errorf("cannont parse nil *bbn.BIP340PubKey") + return nil, fmt.Errorf("cannot parse nil *bbn.BIP340PubKey") } pk, err := key.ToBTCPK() @@ -104,26 +103,29 @@ type ParsedProofOfInclusion struct { } func NewParsedProofOfInclusion( - info *btcckpttypes.TransactionInfo, + ip *InclusionProof, ) (*ParsedProofOfInclusion, error) { - if info == nil { - return nil, fmt.Errorf("cannot parse nil *btcckpttypes.TransactionInfo") + if ip == nil { + // this is allowed + return nil, nil } - if err := info.ValidateBasic(); err != nil { + if err := ip.ValidateBasic(); err != nil { return nil, err } return &ParsedProofOfInclusion{ - HeaderHash: info.Key.Hash, - Proof: info.Proof, - Index: info.Key.Index, + HeaderHash: ip.Key.Hash, + Proof: ip.Proof, + Index: ip.Key.Index, }, nil } type ParsedCreateDelegationMessage struct { - StakerAddress sdk.AccAddress - StakingTx *ParsedBtcTransaction + StakerAddress sdk.AccAddress + StakingTx *ParsedBtcTransaction + // StakingTxInclusionProof is optional is and it is up to the caller to verify + // whether it is present or not StakingTxProofOfInclusion *ParsedProofOfInclusion StakingTime uint16 StakingValue btcutil.Amount @@ -148,14 +150,15 @@ func ParseCreateDelegationMessage(msg *MsgCreateBTCDelegation) (*ParsedCreateDel return nil, fmt.Errorf("cannot parse nil MsgCreateBTCDelegation") } - stakingTxProofOfInclusion, err := NewParsedProofOfInclusion(msg.StakingTx) + // NOTE: stakingTxProofOfInclusion could be nil as we allow msg.StakingTxInclusionProof to be nil + stakingTxProofOfInclusion, err := NewParsedProofOfInclusion(msg.StakingTxInclusionProof) if err != nil { return nil, fmt.Errorf("failed to parse staking tx proof of inclusion: %v", err) } // 1. Parse all transactions - stakingTx, err := NewBtcTransaction(msg.StakingTx.Transaction) + stakingTx, err := NewBtcTransaction(msg.StakingTx) if err != nil { return nil, fmt.Errorf("failed to deserialize staking tx: %v", err) @@ -173,10 +176,6 @@ func ParseCreateDelegationMessage(msg *MsgCreateBTCDelegation) (*ParsedCreateDel return nil, fmt.Errorf("failed to deserialize unbonding tx: %v", err) } - if err := btcstaking.IsSimpleTransfer(unbondingTx.Transaction); err != nil { - return nil, fmt.Errorf("unbonding tx is not a simple transfer: %v", err) - } - unbondingSlashingTx, err := NewBtcTransaction(msg.UnbondingSlashingTx.MustMarshal()) if err != nil { diff --git a/x/btcstaking/types/errors.go b/x/btcstaking/types/errors.go index 927009d3c..987d14596 100644 --- a/x/btcstaking/types/errors.go +++ b/x/btcstaking/types/errors.go @@ -6,32 +6,30 @@ import ( // x/btcstaking module sentinel errors var ( - ErrFpNotFound = errorsmod.Register(ModuleName, 1100, "the finality provider is not found") - ErrBTCDelegatorNotFound = errorsmod.Register(ModuleName, 1101, "the BTC delegator is not found") - ErrBTCDelegationNotFound = errorsmod.Register(ModuleName, 1102, "the BTC delegation is not found") - ErrFpRegistered = errorsmod.Register(ModuleName, 1103, "the finality provider has already been registered") - ErrFpAlreadySlashed = errorsmod.Register(ModuleName, 1104, "the finality provider has already been slashed") - ErrBTCStakingNotActivated = errorsmod.Register(ModuleName, 1106, "the BTC staking protocol is not activated yet") - ErrBTCHeightNotFound = errorsmod.Register(ModuleName, 1107, "the BTC height is not found") - ErrReusedStakingTx = errorsmod.Register(ModuleName, 1108, "the BTC staking tx is already used") - ErrInvalidCovenantPK = errorsmod.Register(ModuleName, 1109, "the BTC staking tx specifies a wrong covenant PK") - ErrInvalidStakingTx = errorsmod.Register(ModuleName, 1110, "the BTC staking tx is not valid") - ErrInvalidSlashingTx = errorsmod.Register(ModuleName, 1111, "the BTC slashing tx is not valid") - ErrInvalidCovenantSig = errorsmod.Register(ModuleName, 1112, "the covenant signature is not valid") - ErrCommissionLTMinRate = errorsmod.Register(ModuleName, 1113, "commission cannot be less than min rate") - ErrCommissionGTMaxRate = errorsmod.Register(ModuleName, 1114, "commission cannot be more than one") - ErrInvalidDelegationState = errorsmod.Register(ModuleName, 1115, "Unexpected delegation state") - ErrInvalidUnbondingTx = errorsmod.Register(ModuleName, 1116, "the BTC unbonding tx is not valid") - ErrRewardDistCacheNotFound = errorsmod.Register(ModuleName, 1117, "the reward distribution cache is not found") - ErrEmptyFpList = errorsmod.Register(ModuleName, 1118, "the finality provider list is empty") - ErrInvalidProofOfPossession = errorsmod.Register(ModuleName, 1119, "the proof of possession is not valid") - ErrDuplicatedFp = errorsmod.Register(ModuleName, 1120, "the staking request contains duplicated finality provider public key") - ErrInvalidBTCUndelegateReq = errorsmod.Register(ModuleName, 1121, "invalid undelegation request") - ErrVotingPowerTableNotUpdated = errorsmod.Register(ModuleName, 1122, "voting power table has not been updated") - ErrVotingPowerDistCacheNotFound = errorsmod.Register(ModuleName, 1123, "the voting power distribution cache is not found") - ErrParamsNotFound = errorsmod.Register(ModuleName, 1124, "the parameters are not found") - ErrFpAlreadyJailed = errorsmod.Register(ModuleName, 1125, "the finality provider has already been jailed") - ErrFpNotJailed = errorsmod.Register(ModuleName, 1126, "the finality provider is not jailed") - ErrConsumerIDNotRegistered = errorsmod.Register(ModuleName, 1127, "Consumer is not registered") - ErrNoBabylonFPRestaked = errorsmod.Register(ModuleName, 1128, "the BTC delegation request does not restake to any Babylon finality provider") + ErrFpNotFound = errorsmod.Register(ModuleName, 1100, "the finality provider is not found") + ErrBTCDelegatorNotFound = errorsmod.Register(ModuleName, 1101, "the BTC delegator is not found") + ErrBTCDelegationNotFound = errorsmod.Register(ModuleName, 1102, "the BTC delegation is not found") + ErrFpRegistered = errorsmod.Register(ModuleName, 1103, "the finality provider has already been registered") + ErrFpAlreadySlashed = errorsmod.Register(ModuleName, 1104, "the finality provider has already been slashed") + ErrBTCHeightNotFound = errorsmod.Register(ModuleName, 1105, "the BTC height is not found") + ErrReusedStakingTx = errorsmod.Register(ModuleName, 1106, "the BTC staking tx is already used") + ErrInvalidCovenantPK = errorsmod.Register(ModuleName, 1107, "the BTC staking tx specifies a wrong covenant PK") + ErrInvalidStakingTx = errorsmod.Register(ModuleName, 1108, "the BTC staking tx is not valid") + ErrInvalidSlashingTx = errorsmod.Register(ModuleName, 1109, "the BTC slashing tx is not valid") + ErrInvalidCovenantSig = errorsmod.Register(ModuleName, 1110, "the covenant signature is not valid") + ErrCommissionLTMinRate = errorsmod.Register(ModuleName, 1111, "commission cannot be less than min rate") + ErrCommissionGTMaxRate = errorsmod.Register(ModuleName, 1112, "commission cannot be more than one") + ErrInvalidDelegationState = errorsmod.Register(ModuleName, 1113, "Unexpected delegation state") + ErrInvalidUnbondingTx = errorsmod.Register(ModuleName, 1114, "the BTC unbonding tx is not valid") + ErrEmptyFpList = errorsmod.Register(ModuleName, 1115, "the finality provider list is empty") + ErrTooManyFpKeys = errorsmod.Register(ModuleName, 1116, "the finality provider list contains too many public keys, it must contain exactly one") + ErrInvalidProofOfPossession = errorsmod.Register(ModuleName, 1117, "the proof of possession is not valid") + ErrDuplicatedFp = errorsmod.Register(ModuleName, 1118, "the staking request contains duplicated finality provider public key") + ErrInvalidBTCUndelegateReq = errorsmod.Register(ModuleName, 1119, "invalid undelegation request") + ErrParamsNotFound = errorsmod.Register(ModuleName, 1120, "the parameters are not found") + ErrFpAlreadyJailed = errorsmod.Register(ModuleName, 1121, "the finality provider has already been jailed") + ErrFpNotJailed = errorsmod.Register(ModuleName, 1122, "the finality provider is not jailed") + ErrDuplicatedCovenantSig = errorsmod.Register(ModuleName, 1123, "the covenant signature is already submitted") + ErrConsumerIDNotRegistered = errorsmod.Register(ModuleName, 1124, "Consumer is not registered") + ErrNoBabylonFPRestaked = errorsmod.Register(ModuleName, 1125, "the BTC delegation request does not restake to any Babylon finality provider") ) diff --git a/x/btcstaking/types/events.go b/x/btcstaking/types/events.go index 8494c3270..4970ec137 100644 --- a/x/btcstaking/types/events.go +++ b/x/btcstaking/types/events.go @@ -1,6 +1,12 @@ package types import ( + "encoding/hex" + "fmt" + "strconv" + + sdk "github.com/cosmos/cosmos-sdk/types" + bbn "github.com/babylonlabs-io/babylon/types" ) @@ -51,3 +57,167 @@ func NewEventPowerDistUpdateWithSlashedBTCDelegation(stakingTxHash string) *Even }, } } +func NewEventFinalityProviderCreated(fp *FinalityProvider) *EventFinalityProviderCreated { + return &EventFinalityProviderCreated{ + BtcPkHex: fp.BtcPk.MarshalHex(), + Addr: fp.Addr, + Commission: fp.Commission.String(), + Moniker: fp.Description.Moniker, + Identity: fp.Description.Identity, + Website: fp.Description.Website, + SecurityContact: fp.Description.SecurityContact, + Details: fp.Description.Details, + } +} + +func NewEventFinalityProviderEdited(fp *FinalityProvider) *EventFinalityProviderEdited { + return &EventFinalityProviderEdited{ + BtcPkHex: fp.BtcPk.MarshalHex(), + Commission: fp.Commission.String(), + Moniker: fp.Description.Moniker, + Identity: fp.Description.Identity, + Website: fp.Description.Website, + SecurityContact: fp.Description.SecurityContact, + Details: fp.Description.Details, + } +} + +func NewInclusionProofEvent( + stakingTxHash string, + startHeight uint32, + endHeight uint32, + state BTCDelegationStatus, +) *EventBTCDelegationInclusionProofReceived { + return &EventBTCDelegationInclusionProofReceived{ + StakingTxHash: stakingTxHash, + StartHeight: strconv.FormatUint(uint64(startHeight), 10), + EndHeight: strconv.FormatUint(uint64(endHeight), 10), + NewState: state.String(), + } +} + +func NewBtcDelCreationEvent( + btcDel *BTCDelegation, +) *EventBTCDelegationCreated { + return &EventBTCDelegationCreated{ + StakingTxHex: hex.EncodeToString(btcDel.StakingTx), + StakingOutputIndex: strconv.FormatUint(uint64(btcDel.StakingOutputIdx), 10), + ParamsVersion: strconv.FormatUint(uint64(btcDel.ParamsVersion), 10), + FinalityProviderBtcPksHex: btcDel.FinalityProviderKeys(), + StakerBtcPkHex: btcDel.BtcPk.MarshalHex(), + StakingTime: strconv.FormatUint(uint64(btcDel.StakingTime), 10), + UnbondingTime: strconv.FormatUint(uint64(btcDel.UnbondingTime), 10), + UnbondingTx: hex.EncodeToString(btcDel.BtcUndelegation.UnbondingTx), + NewState: BTCDelegationStatus_PENDING.String(), + } +} + +func NewCovenantSignatureReceivedEvent( + btcDel *BTCDelegation, + covPK *bbn.BIP340PubKey, + unbondingTxSig *bbn.BIP340Signature, +) *EventCovenantSignatureReceived { + return &EventCovenantSignatureReceived{ + StakingTxHash: btcDel.MustGetStakingTxHash().String(), + CovenantBtcPkHex: covPK.MarshalHex(), + CovenantUnbondingSignatureHex: unbondingTxSig.ToHexStr(), + } +} + +func NewCovenantQuorumReachedEvent( + btcDel *BTCDelegation, + state BTCDelegationStatus, +) *EventCovenantQuorumReached { + return &EventCovenantQuorumReached{ + StakingTxHash: btcDel.MustGetStakingTxHash().String(), + NewState: state.String(), + } +} + +func NewDelegationUnbondedEarlyEvent( + stakingTxHash string, + startHeight uint32, +) *EventBTCDelgationUnbondedEarly { + return &EventBTCDelgationUnbondedEarly{ + StakingTxHash: stakingTxHash, + StartHeight: strconv.FormatUint(uint64(startHeight), 10), + NewState: BTCDelegationStatus_UNBONDED.String(), + } +} + +func NewExpiredDelegationEvent( + stakingTxHash string, +) *EventBTCDelegationExpired { + return &EventBTCDelegationExpired{ + StakingTxHash: stakingTxHash, + NewState: BTCDelegationStatus_UNBONDED.String(), + } +} + +func NewFinalityProviderStatusChangeEvent( + fpPk *bbn.BIP340PubKey, + status FinalityProviderStatus, +) *EventFinalityProviderStatusChange { + return &EventFinalityProviderStatusChange{ + BtcPk: fpPk.MarshalHex(), + NewState: status.String(), + } +} + +func NewUnexpectedUnbondingTxEvent( + stakingTxHash, spendStakeTxHash, spendStakeTxHeaderHash string, + spendStakeTxBlockIndex uint32, +) *EventUnexpectedUnbondingTx { + return &EventUnexpectedUnbondingTx{ + StakingTxHash: stakingTxHash, + SpendStakeTxHash: spendStakeTxHash, + SpendStakeTxHeaderHash: spendStakeTxHeaderHash, + SpendStakeTxBlockIndex: spendStakeTxBlockIndex, + } +} + +// EmitUnexpectedUnbondingTxEvent emits events for an unexpected unbonding tx +func EmitUnexpectedUnbondingTxEvent( + sdkCtx sdk.Context, + stakingTxHash, spendStakeTxHash, spendStakeTxHeaderHash string, + spendStakeTxBlockIndex uint32, +) { + ev := NewUnexpectedUnbondingTxEvent(stakingTxHash, spendStakeTxHash, spendStakeTxHeaderHash, spendStakeTxBlockIndex) + if err := sdkCtx.EventManager().EmitTypedEvent(ev); err != nil { + panic(fmt.Errorf("failed to emit event the unexpected unbonding tx event: %w", err)) + } +} + +// EmitEarlyUnbondedEvent emits events for an early unbonded BTC delegation +func EmitEarlyUnbondedEvent(sdkCtx sdk.Context, stakingTxHash string, inclusionHeight uint32) { + ev := NewDelegationUnbondedEarlyEvent(stakingTxHash, inclusionHeight) + if err := sdkCtx.EventManager().EmitTypedEvent(ev); err != nil { + panic(fmt.Errorf("failed to emit event the early unbonded BTC delegation: %w", err)) + } +} + +// EmitExpiredDelegationEvent emits events for an expired delegation +func EmitExpiredDelegationEvent(sdkCtx sdk.Context, stakingTxHash string) { + ev := NewExpiredDelegationEvent(stakingTxHash) + if err := sdkCtx.EventManager().EmitTypedEvent(ev); err != nil { + panic(fmt.Errorf("failed to emit event the expired BTC delegation: %w", err)) + } +} + +func EmitSlashedFPEvent(sdkCtx sdk.Context, fpBTCPK *bbn.BIP340PubKey) { + statusChangeEvent := NewFinalityProviderStatusChangeEvent(fpBTCPK, FinalityProviderStatus_FINALITY_PROVIDER_STATUS_SLASHED) + if err := sdkCtx.EventManager().EmitTypedEvent(statusChangeEvent); err != nil { + panic(fmt.Errorf( + "failed to emit FinalityProviderStatusChangeEvent with status %s: %w", + FinalityProviderStatus_FINALITY_PROVIDER_STATUS_SLASHED.String(), err)) + } +} + +func EmitJailedFPEvent(sdkCtx sdk.Context, fpBTCPK *bbn.BIP340PubKey) { + statusChangeEvent := NewFinalityProviderStatusChangeEvent(fpBTCPK, FinalityProviderStatus_FINALITY_PROVIDER_STATUS_JAILED) + if err := sdkCtx.EventManager().EmitTypedEvent(statusChangeEvent); err != nil { + panic(fmt.Errorf( + "failed to emit FinalityProviderStatusChangeEvent with status %s: %w", + FinalityProviderStatus_FINALITY_PROVIDER_STATUS_JAILED.String(), err)) + } +} diff --git a/x/btcstaking/types/events.pb.go b/x/btcstaking/types/events.pb.go index 8187a1cb2..1a7b2d74c 100644 --- a/x/btcstaking/types/events.pb.go +++ b/x/btcstaking/types/events.pb.go @@ -6,6 +6,9 @@ package types import ( fmt "fmt" github_com_babylonlabs_io_babylon_types "github.com/babylonlabs-io/babylon/types" + _ "github.com/cosmos/cosmos-proto" + _ "github.com/cosmos/cosmos-sdk/types/tx/amino" + _ "github.com/cosmos/cosmos-sdk/x/staking/types" _ "github.com/cosmos/gogoproto/gogoproto" proto "github.com/cosmos/gogoproto/proto" io "io" @@ -24,7 +27,44 @@ var _ = math.Inf // proto package needs to be updated. const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package -// EventNewFinalityProvider is the event emitted when a finality provider is created +// FinalityProviderStatus is the status of a finality provider. +type FinalityProviderStatus int32 + +const ( + // FINALITY_PROVIDER_STATUS_INACTIVE defines a finality provider that does not have sufficient + // delegations or does not have timestamped public randomness. + FinalityProviderStatus_FINALITY_PROVIDER_STATUS_INACTIVE FinalityProviderStatus = 0 + // FINALITY_PROVIDER_STATUS_ACTIVE defines a finality provider that have sufficient delegations + // and have timestamped public randomness. + FinalityProviderStatus_FINALITY_PROVIDER_STATUS_ACTIVE FinalityProviderStatus = 1 + // FINALITY_PROVIDER_STATUS_JAILED defines a finality provider that is jailed due to downtime + FinalityProviderStatus_FINALITY_PROVIDER_STATUS_JAILED FinalityProviderStatus = 2 + // FINALITY_PROVIDER_STATUS_SLASHED defines a finality provider that is slashed due to double-sign + FinalityProviderStatus_FINALITY_PROVIDER_STATUS_SLASHED FinalityProviderStatus = 3 +) + +var FinalityProviderStatus_name = map[int32]string{ + 0: "FINALITY_PROVIDER_STATUS_INACTIVE", + 1: "FINALITY_PROVIDER_STATUS_ACTIVE", + 2: "FINALITY_PROVIDER_STATUS_JAILED", + 3: "FINALITY_PROVIDER_STATUS_SLASHED", +} + +var FinalityProviderStatus_value = map[string]int32{ + "FINALITY_PROVIDER_STATUS_INACTIVE": 0, + "FINALITY_PROVIDER_STATUS_ACTIVE": 1, + "FINALITY_PROVIDER_STATUS_JAILED": 2, + "FINALITY_PROVIDER_STATUS_SLASHED": 3, +} + +func (x FinalityProviderStatus) String() string { + return proto.EnumName(FinalityProviderStatus_name, int32(x)) +} + +func (FinalityProviderStatus) EnumDescriptor() ([]byte, []int) { + return fileDescriptor_74118427820fff75, []int{0} +} + type EventNewFinalityProvider struct { Fp *FinalityProvider `protobuf:"bytes,1,opt,name=fp,proto3" json:"fp,omitempty"` } @@ -69,6 +109,215 @@ func (m *EventNewFinalityProvider) GetFp() *FinalityProvider { return nil } +// EventFinalityProviderCreated is the event emitted when a finality provider is created +type EventFinalityProviderCreated struct { + // btc_pk_hex is the hex string of Bitcoin secp256k1 PK of this finality provider + BtcPkHex string `protobuf:"bytes,1,opt,name=btc_pk_hex,json=btcPkHex,proto3" json:"btc_pk_hex,omitempty"` + // addr is the babylon address to receive commission from delegations. + Addr string `protobuf:"bytes,2,opt,name=addr,proto3" json:"addr,omitempty"` + // commission defines the commission rate of the finality provider in decimals. + Commission string `protobuf:"bytes,3,opt,name=commission,proto3" json:"commission,omitempty"` + // moniker defines a human-readable name for the finality provider. + Moniker string `protobuf:"bytes,4,opt,name=moniker,proto3" json:"moniker,omitempty"` + // identity defines an optional identity signature (ex. UPort or Keybase). + Identity string `protobuf:"bytes,5,opt,name=identity,proto3" json:"identity,omitempty"` + // website defines an optional website link. + Website string `protobuf:"bytes,6,opt,name=website,proto3" json:"website,omitempty"` + // security_contact defines an optional email for security contact. + SecurityContact string `protobuf:"bytes,7,opt,name=security_contact,json=securityContact,proto3" json:"security_contact,omitempty"` + // details define other optional details. + Details string `protobuf:"bytes,8,opt,name=details,proto3" json:"details,omitempty"` +} + +func (m *EventFinalityProviderCreated) Reset() { *m = EventFinalityProviderCreated{} } +func (m *EventFinalityProviderCreated) String() string { return proto.CompactTextString(m) } +func (*EventFinalityProviderCreated) ProtoMessage() {} +func (*EventFinalityProviderCreated) Descriptor() ([]byte, []int) { + return fileDescriptor_74118427820fff75, []int{1} +} +func (m *EventFinalityProviderCreated) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *EventFinalityProviderCreated) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_EventFinalityProviderCreated.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 *EventFinalityProviderCreated) XXX_Merge(src proto.Message) { + xxx_messageInfo_EventFinalityProviderCreated.Merge(m, src) +} +func (m *EventFinalityProviderCreated) XXX_Size() int { + return m.Size() +} +func (m *EventFinalityProviderCreated) XXX_DiscardUnknown() { + xxx_messageInfo_EventFinalityProviderCreated.DiscardUnknown(m) +} + +var xxx_messageInfo_EventFinalityProviderCreated proto.InternalMessageInfo + +func (m *EventFinalityProviderCreated) GetBtcPkHex() string { + if m != nil { + return m.BtcPkHex + } + return "" +} + +func (m *EventFinalityProviderCreated) GetAddr() string { + if m != nil { + return m.Addr + } + return "" +} + +func (m *EventFinalityProviderCreated) GetCommission() string { + if m != nil { + return m.Commission + } + return "" +} + +func (m *EventFinalityProviderCreated) GetMoniker() string { + if m != nil { + return m.Moniker + } + return "" +} + +func (m *EventFinalityProviderCreated) GetIdentity() string { + if m != nil { + return m.Identity + } + return "" +} + +func (m *EventFinalityProviderCreated) GetWebsite() string { + if m != nil { + return m.Website + } + return "" +} + +func (m *EventFinalityProviderCreated) GetSecurityContact() string { + if m != nil { + return m.SecurityContact + } + return "" +} + +func (m *EventFinalityProviderCreated) GetDetails() string { + if m != nil { + return m.Details + } + return "" +} + +// EventFinalityProviderEdited is the event emitted when a finality provider is edited +type EventFinalityProviderEdited struct { + // btc_pk_hex is the hex string of Bitcoin secp256k1 PK of this finality provider + BtcPkHex string `protobuf:"bytes,1,opt,name=btc_pk_hex,json=btcPkHex,proto3" json:"btc_pk_hex,omitempty"` + // commission defines the commission rate of the finality provider in decimals. + Commission string `protobuf:"bytes,2,opt,name=commission,proto3" json:"commission,omitempty"` + // moniker defines a human-readable name for the finality provider. + Moniker string `protobuf:"bytes,3,opt,name=moniker,proto3" json:"moniker,omitempty"` + // identity defines an optional identity signature (ex. UPort or Keybase). + Identity string `protobuf:"bytes,4,opt,name=identity,proto3" json:"identity,omitempty"` + // website defines an optional website link. + Website string `protobuf:"bytes,5,opt,name=website,proto3" json:"website,omitempty"` + // security_contact defines an optional email for security contact. + SecurityContact string `protobuf:"bytes,6,opt,name=security_contact,json=securityContact,proto3" json:"security_contact,omitempty"` + // details define other optional details. + Details string `protobuf:"bytes,7,opt,name=details,proto3" json:"details,omitempty"` +} + +func (m *EventFinalityProviderEdited) Reset() { *m = EventFinalityProviderEdited{} } +func (m *EventFinalityProviderEdited) String() string { return proto.CompactTextString(m) } +func (*EventFinalityProviderEdited) ProtoMessage() {} +func (*EventFinalityProviderEdited) Descriptor() ([]byte, []int) { + return fileDescriptor_74118427820fff75, []int{2} +} +func (m *EventFinalityProviderEdited) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *EventFinalityProviderEdited) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_EventFinalityProviderEdited.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 *EventFinalityProviderEdited) XXX_Merge(src proto.Message) { + xxx_messageInfo_EventFinalityProviderEdited.Merge(m, src) +} +func (m *EventFinalityProviderEdited) XXX_Size() int { + return m.Size() +} +func (m *EventFinalityProviderEdited) XXX_DiscardUnknown() { + xxx_messageInfo_EventFinalityProviderEdited.DiscardUnknown(m) +} + +var xxx_messageInfo_EventFinalityProviderEdited proto.InternalMessageInfo + +func (m *EventFinalityProviderEdited) GetBtcPkHex() string { + if m != nil { + return m.BtcPkHex + } + return "" +} + +func (m *EventFinalityProviderEdited) GetCommission() string { + if m != nil { + return m.Commission + } + return "" +} + +func (m *EventFinalityProviderEdited) GetMoniker() string { + if m != nil { + return m.Moniker + } + return "" +} + +func (m *EventFinalityProviderEdited) GetIdentity() string { + if m != nil { + return m.Identity + } + return "" +} + +func (m *EventFinalityProviderEdited) GetWebsite() string { + if m != nil { + return m.Website + } + return "" +} + +func (m *EventFinalityProviderEdited) GetSecurityContact() string { + if m != nil { + return m.SecurityContact + } + return "" +} + +func (m *EventFinalityProviderEdited) GetDetails() string { + if m != nil { + return m.Details + } + return "" +} + // EventBTCDelegationStateUpdate is the event emitted when a BTC delegation's state is // updated. There are the following possible state transitions: // - non-existing -> pending, which happens upon `MsgCreateBTCDelegation` @@ -86,7 +335,7 @@ func (m *EventBTCDelegationStateUpdate) Reset() { *m = EventBTCDelegatio func (m *EventBTCDelegationStateUpdate) String() string { return proto.CompactTextString(m) } func (*EventBTCDelegationStateUpdate) ProtoMessage() {} func (*EventBTCDelegationStateUpdate) Descriptor() ([]byte, []int) { - return fileDescriptor_74118427820fff75, []int{1} + return fileDescriptor_74118427820fff75, []int{3} } func (m *EventBTCDelegationStateUpdate) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -141,7 +390,7 @@ func (m *EventSelectiveSlashing) Reset() { *m = EventSelectiveSlashing{} func (m *EventSelectiveSlashing) String() string { return proto.CompactTextString(m) } func (*EventSelectiveSlashing) ProtoMessage() {} func (*EventSelectiveSlashing) Descriptor() ([]byte, []int) { - return fileDescriptor_74118427820fff75, []int{2} + return fileDescriptor_74118427820fff75, []int{4} } func (m *EventSelectiveSlashing) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -177,7 +426,7 @@ func (m *EventSelectiveSlashing) GetEvidence() *SelectiveSlashingEvidence { return nil } -// EventPowerDistUpdate is an event that affects voting power distirbution +// EventPowerDistUpdate is an event that affects voting power distribution // of BTC staking protocol type EventPowerDistUpdate struct { // ev is the event that affects voting power distribution @@ -195,7 +444,7 @@ func (m *EventPowerDistUpdate) Reset() { *m = EventPowerDistUpdate{} } func (m *EventPowerDistUpdate) String() string { return proto.CompactTextString(m) } func (*EventPowerDistUpdate) ProtoMessage() {} func (*EventPowerDistUpdate) Descriptor() ([]byte, []int) { - return fileDescriptor_74118427820fff75, []int{3} + return fileDescriptor_74118427820fff75, []int{5} } func (m *EventPowerDistUpdate) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -320,7 +569,7 @@ func (m *EventPowerDistUpdate_EventSlashedFinalityProvider) String() string { } func (*EventPowerDistUpdate_EventSlashedFinalityProvider) ProtoMessage() {} func (*EventPowerDistUpdate_EventSlashedFinalityProvider) Descriptor() ([]byte, []int) { - return fileDescriptor_74118427820fff75, []int{3, 0} + return fileDescriptor_74118427820fff75, []int{5, 0} } func (m *EventPowerDistUpdate_EventSlashedFinalityProvider) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -365,7 +614,7 @@ func (m *EventPowerDistUpdate_EventSlashedBTCDelegation) String() string { } func (*EventPowerDistUpdate_EventSlashedBTCDelegation) ProtoMessage() {} func (*EventPowerDistUpdate_EventSlashedBTCDelegation) Descriptor() ([]byte, []int) { - return fileDescriptor_74118427820fff75, []int{3, 1} + return fileDescriptor_74118427820fff75, []int{5, 1} } func (m *EventPowerDistUpdate_EventSlashedBTCDelegation) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -415,7 +664,7 @@ func (m *EventPowerDistUpdate_EventJailedFinalityProvider) String() string { } func (*EventPowerDistUpdate_EventJailedFinalityProvider) ProtoMessage() {} func (*EventPowerDistUpdate_EventJailedFinalityProvider) Descriptor() ([]byte, []int) { - return fileDescriptor_74118427820fff75, []int{3, 2} + return fileDescriptor_74118427820fff75, []int{5, 2} } func (m *EventPowerDistUpdate_EventJailedFinalityProvider) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -458,7 +707,7 @@ func (m *EventPowerDistUpdate_EventUnjailedFinalityProvider) String() string { } func (*EventPowerDistUpdate_EventUnjailedFinalityProvider) ProtoMessage() {} func (*EventPowerDistUpdate_EventUnjailedFinalityProvider) Descriptor() ([]byte, []int) { - return fileDescriptor_74118427820fff75, []int{3, 3} + return fileDescriptor_74118427820fff75, []int{5, 3} } func (m *EventPowerDistUpdate_EventUnjailedFinalityProvider) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -487,369 +736,715 @@ func (m *EventPowerDistUpdate_EventUnjailedFinalityProvider) XXX_DiscardUnknown( var xxx_messageInfo_EventPowerDistUpdate_EventUnjailedFinalityProvider proto.InternalMessageInfo -func init() { - proto.RegisterType((*EventNewFinalityProvider)(nil), "babylon.btcstaking.v1.EventNewFinalityProvider") - proto.RegisterType((*EventBTCDelegationStateUpdate)(nil), "babylon.btcstaking.v1.EventBTCDelegationStateUpdate") - proto.RegisterType((*EventSelectiveSlashing)(nil), "babylon.btcstaking.v1.EventSelectiveSlashing") - proto.RegisterType((*EventPowerDistUpdate)(nil), "babylon.btcstaking.v1.EventPowerDistUpdate") - proto.RegisterType((*EventPowerDistUpdate_EventSlashedFinalityProvider)(nil), "babylon.btcstaking.v1.EventPowerDistUpdate.EventSlashedFinalityProvider") - proto.RegisterType((*EventPowerDistUpdate_EventSlashedBTCDelegation)(nil), "babylon.btcstaking.v1.EventPowerDistUpdate.EventSlashedBTCDelegation") - proto.RegisterType((*EventPowerDistUpdate_EventJailedFinalityProvider)(nil), "babylon.btcstaking.v1.EventPowerDistUpdate.EventJailedFinalityProvider") - proto.RegisterType((*EventPowerDistUpdate_EventUnjailedFinalityProvider)(nil), "babylon.btcstaking.v1.EventPowerDistUpdate.EventUnjailedFinalityProvider") +// A finality provider starts with status INACTIVE once registered. +// Possible status transitions are when: +// 1. it has accumulated sufficient delegations and has +// timestamped public randomness: +// INACTIVE -> ACTIVE +// 2. it is jailed due to downtime: +// ACTIVE -> JAILED +// 3. it is slashed due to double-sign: +// ACTIVE -> SLASHED +// 4. it is unjailed after a jailing period: +// JAILED -> INACTIVE/ACTIVE (depending on (1)) +// 5. it does not have sufficient delegations or does not +// have timestamped public randomness: +// ACTIVE -> INACTIVE. +// Note that it is impossible for a SLASHED finality provider to +// transition to other status +type EventFinalityProviderStatusChange struct { + // btc_pk is the BTC public key of the finality provider + BtcPk string `protobuf:"bytes,1,opt,name=btc_pk,json=btcPk,proto3" json:"btc_pk,omitempty"` + // new_state is the status that the finality provider + // is transitioned to, following FinalityProviderStatus + NewState string `protobuf:"bytes,2,opt,name=new_state,json=newState,proto3" json:"new_state,omitempty"` } -func init() { - proto.RegisterFile("babylon/btcstaking/v1/events.proto", fileDescriptor_74118427820fff75) +func (m *EventFinalityProviderStatusChange) Reset() { *m = EventFinalityProviderStatusChange{} } +func (m *EventFinalityProviderStatusChange) String() string { return proto.CompactTextString(m) } +func (*EventFinalityProviderStatusChange) ProtoMessage() {} +func (*EventFinalityProviderStatusChange) Descriptor() ([]byte, []int) { + return fileDescriptor_74118427820fff75, []int{6} +} +func (m *EventFinalityProviderStatusChange) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *EventFinalityProviderStatusChange) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_EventFinalityProviderStatusChange.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 *EventFinalityProviderStatusChange) XXX_Merge(src proto.Message) { + xxx_messageInfo_EventFinalityProviderStatusChange.Merge(m, src) +} +func (m *EventFinalityProviderStatusChange) XXX_Size() int { + return m.Size() +} +func (m *EventFinalityProviderStatusChange) XXX_DiscardUnknown() { + xxx_messageInfo_EventFinalityProviderStatusChange.DiscardUnknown(m) } -var fileDescriptor_74118427820fff75 = []byte{ - // 569 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x94, 0xcd, 0x6e, 0xd3, 0x40, - 0x14, 0x85, 0x6d, 0x53, 0xa0, 0x99, 0xf2, 0x23, 0xac, 0x50, 0x85, 0x00, 0xa6, 0xca, 0xa2, 0x54, - 0x48, 0xd8, 0xfd, 0x89, 0x04, 0x6b, 0x37, 0x49, 0x5d, 0x40, 0x55, 0xe4, 0xb4, 0x1b, 0x36, 0xd6, - 0xd8, 0xb9, 0xb1, 0x87, 0x18, 0xdb, 0xca, 0x4c, 0x9c, 0x64, 0xc1, 0x3b, 0xf4, 0xb1, 0xba, 0xec, - 0x12, 0xb1, 0x40, 0x28, 0x79, 0x11, 0x94, 0xf1, 0xa4, 0x0d, 0x6d, 0x1c, 0xb5, 0xa8, 0xbb, 0xf1, - 0xd5, 0x9c, 0xf3, 0x9d, 0x99, 0xb9, 0xbe, 0xa8, 0xe2, 0x62, 0x77, 0x14, 0xc6, 0x91, 0xe1, 0x32, - 0x8f, 0x32, 0xdc, 0x25, 0x91, 0x6f, 0xa4, 0x3b, 0x06, 0xa4, 0x10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0x38, 0x54, 0xce, 0x1e, 0xa2, 0x22, 0x07, 0x35, 0xe3, 0x01, 0xf4, 0x6a, 0x84, 0x32, 0x71, 0x62, - 0x82, 0x10, 0x9d, 0xca, 0xa0, 0xed, 0x5c, 0x5c, 0xaa, 0x95, 0x03, 0x5a, 0x64, 0x90, 0x15, 0x5b, - 0x99, 0xc5, 0xd5, 0x5b, 0xb7, 0x24, 0xbb, 0x20, 0xdc, 0x1b, 0x89, 0xda, 0x41, 0x85, 0x6f, 0x98, - 0x84, 0x19, 0x49, 0xe1, 0xa4, 0x83, 0x5b, 0x93, 0x3e, 0x71, 0x87, 0x05, 0xa0, 0xd5, 0xcc, 0xbb, - 0x91, 0xa8, 0x21, 0x5a, 0xeb, 0x47, 0x97, 0xa4, 0x7b, 0x9c, 0x74, 0x78, 0x6b, 0xd2, 0x89, 0xf0, - 0x58, 0xc0, 0x42, 0x33, 0xff, 0x46, 0xa2, 0xfa, 0xa8, 0xe8, 0x32, 0xcf, 0x69, 0x43, 0x98, 0xb5, - 0x83, 0xd3, 0xe7, 0x1e, 0xa5, 0x15, 0x8e, 0xad, 0x2e, 0xc3, 0xe6, 0xb5, 0xa1, 0x25, 0xd9, 0xcf, - 0x5c, 0xe6, 0xd5, 0x20, 0x9c, 0xef, 0xcd, 0x1f, 0x68, 0x7d, 0xf6, 0x52, 0x02, 0x28, 0x94, 0xa5, - 0xfb, 0x1c, 0x55, 0xff, 0xdf, 0x57, 0xfb, 0x27, 0x86, 0x25, 0xd9, 0x45, 0x81, 0x31, 0x79, 0x04, - 0x51, 0x2f, 0x07, 0xe8, 0xd5, 0xb2, 0xa7, 0x56, 0x2d, 0xa4, 0x24, 0x5d, 0xde, 0x40, 0x8f, 0xcc, - 0x8f, 0xbf, 0x7e, 0xbf, 0xa9, 0xfa, 0x84, 0x05, 0x7d, 0x57, 0xf7, 0xe2, 0xef, 0x86, 0x08, 0x16, - 0x62, 0x97, 0xbe, 0x27, 0xf1, 0xec, 0xd3, 0x60, 0xa3, 0x04, 0xa8, 0x6e, 0x1e, 0x36, 0xf7, 0xaa, - 0xdb, 0xcd, 0xbe, 0xfb, 0x19, 0x46, 0xb6, 0x92, 0x74, 0xcb, 0xfb, 0xe8, 0x45, 0x6e, 0xbc, 0x9b, - 0xfe, 0xa1, 0x65, 0x1f, 0xbd, 0x5c, 0xd2, 0x2f, 0x77, 0x98, 0x96, 0x88, 0x99, 0x92, 0xd7, 0x2e, - 0x77, 0x87, 0x32, 0x57, 0x90, 0x02, 0xa9, 0x79, 0x74, 0x36, 0xd6, 0xe4, 0xf3, 0xb1, 0x26, 0xff, - 0x19, 0x6b, 0xf2, 0xe9, 0x44, 0x93, 0xce, 0x27, 0x9a, 0xf4, 0x73, 0xa2, 0x49, 0x5f, 0x6f, 0xe0, - 0x3c, 0x9c, 0x1f, 0xc7, 0x1c, 0xe3, 0x3e, 0xe0, 0x13, 0x77, 0xef, 0x6f, 0x00, 0x00, 0x00, 0xff, - 0xff, 0x44, 0x44, 0x28, 0x4c, 0xec, 0x05, 0x00, 0x00, +var xxx_messageInfo_EventFinalityProviderStatusChange proto.InternalMessageInfo + +func (m *EventFinalityProviderStatusChange) GetBtcPk() string { + if m != nil { + return m.BtcPk + } + return "" } -func (m *EventNewFinalityProvider) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err +func (m *EventFinalityProviderStatusChange) GetNewState() string { + if m != nil { + return m.NewState } - return dAtA[:n], nil + return "" } -func (m *EventNewFinalityProvider) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) +// EventBTCDelegationCreated is the event emitted when a BTC delegation is created +// on the Babylon chain +type EventBTCDelegationCreated struct { + // staking_tx_hex is the hex encoded staking tx + StakingTxHex string `protobuf:"bytes,1,opt,name=staking_tx_hex,json=stakingTxHex,proto3" json:"staking_tx_hex,omitempty"` + // staking_output_index is the index of the staking output in the staking tx + StakingOutputIndex string `protobuf:"bytes,2,opt,name=staking_output_index,json=stakingOutputIndex,proto3" json:"staking_output_index,omitempty"` + // version of the params used to validate the delegation + ParamsVersion string `protobuf:"bytes,3,opt,name=params_version,json=paramsVersion,proto3" json:"params_version,omitempty"` + // finality_provider_btc_pks_hex is the list of hex str of Bitcoin secp256k1 PK of + // the finality providers that this BTC delegation delegates to + // the PK follows encoding in BIP-340 spec + FinalityProviderBtcPksHex []string `protobuf:"bytes,4,rep,name=finality_provider_btc_pks_hex,json=finalityProviderBtcPksHex,proto3" json:"finality_provider_btc_pks_hex,omitempty"` + // staker_btc_pk_hex is the hex str of Bitcoin secp256k1 PK of the staker that + // creates this BTC delegation the PK follows encoding in BIP-340 spec + StakerBtcPkHex string `protobuf:"bytes,5,opt,name=staker_btc_pk_hex,json=stakerBtcPkHex,proto3" json:"staker_btc_pk_hex,omitempty"` + // staking_time is the timelock of the staking tx specified in the BTC script + StakingTime string `protobuf:"bytes,6,opt,name=staking_time,json=stakingTime,proto3" json:"staking_time,omitempty"` + // unbonding_time is the time is timelock on unbonding tx chosen by the staker + UnbondingTime string `protobuf:"bytes,7,opt,name=unbonding_time,json=unbondingTime,proto3" json:"unbonding_time,omitempty"` + // unbonding_tx is hex encoded bytes of the unsigned unbonding tx + UnbondingTx string `protobuf:"bytes,8,opt,name=unbonding_tx,json=unbondingTx,proto3" json:"unbonding_tx,omitempty"` + // new_state of the BTC delegation + NewState string `protobuf:"bytes,9,opt,name=new_state,json=newState,proto3" json:"new_state,omitempty"` } -func (m *EventNewFinalityProvider) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if m.Fp != nil { - { - size, err := m.Fp.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintEvents(dAtA, i, uint64(size)) +func (m *EventBTCDelegationCreated) Reset() { *m = EventBTCDelegationCreated{} } +func (m *EventBTCDelegationCreated) String() string { return proto.CompactTextString(m) } +func (*EventBTCDelegationCreated) ProtoMessage() {} +func (*EventBTCDelegationCreated) Descriptor() ([]byte, []int) { + return fileDescriptor_74118427820fff75, []int{7} +} +func (m *EventBTCDelegationCreated) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *EventBTCDelegationCreated) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_EventBTCDelegationCreated.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err } - i-- - dAtA[i] = 0xa + return b[:n], nil } - return len(dAtA) - i, nil +} +func (m *EventBTCDelegationCreated) XXX_Merge(src proto.Message) { + xxx_messageInfo_EventBTCDelegationCreated.Merge(m, src) +} +func (m *EventBTCDelegationCreated) XXX_Size() int { + return m.Size() +} +func (m *EventBTCDelegationCreated) XXX_DiscardUnknown() { + xxx_messageInfo_EventBTCDelegationCreated.DiscardUnknown(m) } -func (m *EventBTCDelegationStateUpdate) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err +var xxx_messageInfo_EventBTCDelegationCreated proto.InternalMessageInfo + +func (m *EventBTCDelegationCreated) GetStakingTxHex() string { + if m != nil { + return m.StakingTxHex } - return dAtA[:n], nil + return "" } -func (m *EventBTCDelegationStateUpdate) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) +func (m *EventBTCDelegationCreated) GetStakingOutputIndex() string { + if m != nil { + return m.StakingOutputIndex + } + return "" } -func (m *EventBTCDelegationStateUpdate) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if m.NewState != 0 { - i = encodeVarintEvents(dAtA, i, uint64(m.NewState)) - i-- - dAtA[i] = 0x10 - } - if len(m.StakingTxHash) > 0 { - i -= len(m.StakingTxHash) - copy(dAtA[i:], m.StakingTxHash) - i = encodeVarintEvents(dAtA, i, uint64(len(m.StakingTxHash))) - i-- - dAtA[i] = 0xa +func (m *EventBTCDelegationCreated) GetParamsVersion() string { + if m != nil { + return m.ParamsVersion } - return len(dAtA) - i, nil + return "" } -func (m *EventSelectiveSlashing) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err +func (m *EventBTCDelegationCreated) GetFinalityProviderBtcPksHex() []string { + if m != nil { + return m.FinalityProviderBtcPksHex } - return dAtA[:n], nil + return nil } -func (m *EventSelectiveSlashing) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) +func (m *EventBTCDelegationCreated) GetStakerBtcPkHex() string { + if m != nil { + return m.StakerBtcPkHex + } + return "" } -func (m *EventSelectiveSlashing) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if m.Evidence != nil { - { - size, err := m.Evidence.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintEvents(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0xa +func (m *EventBTCDelegationCreated) GetStakingTime() string { + if m != nil { + return m.StakingTime } - return len(dAtA) - i, nil + return "" } -func (m *EventPowerDistUpdate) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err +func (m *EventBTCDelegationCreated) GetUnbondingTime() string { + if m != nil { + return m.UnbondingTime } - return dAtA[:n], nil + return "" } -func (m *EventPowerDistUpdate) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) +func (m *EventBTCDelegationCreated) GetUnbondingTx() string { + if m != nil { + return m.UnbondingTx + } + return "" } -func (m *EventPowerDistUpdate) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if m.Ev != nil { - { - size := m.Ev.Size() - i -= size - if _, err := m.Ev.MarshalTo(dAtA[i:]); err != nil { - return 0, err - } - } +func (m *EventBTCDelegationCreated) GetNewState() string { + if m != nil { + return m.NewState } - return len(dAtA) - i, nil + return "" } -func (m *EventPowerDistUpdate_SlashedFp) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) +// EventCovenantSignatureReceived is the event emitted when a covenant committee +// sends valid covenant signatures for a BTC delegation +type EventCovenantSignatureReceived struct { + // staking_tx_hash is the hash of the staking identifing the BTC delegation + // that this covenant signature is for + StakingTxHash string `protobuf:"bytes,1,opt,name=staking_tx_hash,json=stakingTxHash,proto3" json:"staking_tx_hash,omitempty"` + // covenant_btc_pk_hex is the hex str of Bitcoin secp256k1 PK of the + // covnenat committee that send the signature + CovenantBtcPkHex string `protobuf:"bytes,2,opt,name=covenant_btc_pk_hex,json=covenantBtcPkHex,proto3" json:"covenant_btc_pk_hex,omitempty"` + // covenant_unbonding_signature_hex is the hex str of the BIP340 Schnorr + // signature of the covenant committee on the unbonding tx + CovenantUnbondingSignatureHex string `protobuf:"bytes,3,opt,name=covenant_unbonding_signature_hex,json=covenantUnbondingSignatureHex,proto3" json:"covenant_unbonding_signature_hex,omitempty"` } -func (m *EventPowerDistUpdate_SlashedFp) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - if m.SlashedFp != nil { - { - size, err := m.SlashedFp.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintEvents(dAtA, i, uint64(size)) +func (m *EventCovenantSignatureReceived) Reset() { *m = EventCovenantSignatureReceived{} } +func (m *EventCovenantSignatureReceived) String() string { return proto.CompactTextString(m) } +func (*EventCovenantSignatureReceived) ProtoMessage() {} +func (*EventCovenantSignatureReceived) Descriptor() ([]byte, []int) { + return fileDescriptor_74118427820fff75, []int{8} +} +func (m *EventCovenantSignatureReceived) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *EventCovenantSignatureReceived) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_EventCovenantSignatureReceived.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err } - i-- - dAtA[i] = 0xa + return b[:n], nil } - return len(dAtA) - i, nil } -func (m *EventPowerDistUpdate_JailedFp) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) +func (m *EventCovenantSignatureReceived) XXX_Merge(src proto.Message) { + xxx_messageInfo_EventCovenantSignatureReceived.Merge(m, src) +} +func (m *EventCovenantSignatureReceived) XXX_Size() int { + return m.Size() +} +func (m *EventCovenantSignatureReceived) XXX_DiscardUnknown() { + xxx_messageInfo_EventCovenantSignatureReceived.DiscardUnknown(m) } -func (m *EventPowerDistUpdate_JailedFp) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - if m.JailedFp != nil { - { - size, err := m.JailedFp.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintEvents(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x12 +var xxx_messageInfo_EventCovenantSignatureReceived proto.InternalMessageInfo + +func (m *EventCovenantSignatureReceived) GetStakingTxHash() string { + if m != nil { + return m.StakingTxHash } - return len(dAtA) - i, nil + return "" } -func (m *EventPowerDistUpdate_UnjailedFp) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) + +func (m *EventCovenantSignatureReceived) GetCovenantBtcPkHex() string { + if m != nil { + return m.CovenantBtcPkHex + } + return "" } -func (m *EventPowerDistUpdate_UnjailedFp) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - if m.UnjailedFp != nil { - { - size, err := m.UnjailedFp.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintEvents(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x1a +func (m *EventCovenantSignatureReceived) GetCovenantUnbondingSignatureHex() string { + if m != nil { + return m.CovenantUnbondingSignatureHex } - return len(dAtA) - i, nil + return "" } -func (m *EventPowerDistUpdate_BtcDelStateUpdate) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) + +// EventCovenantQuorumReached is the event emitted quorum of covenant committee +// is reached for a BTC delegation +type EventCovenantQuorumReached struct { + // staking_tx_hash is the hash of the staking identifing the BTC delegation + // that this covenant signature is for + StakingTxHash string `protobuf:"bytes,1,opt,name=staking_tx_hash,json=stakingTxHash,proto3" json:"staking_tx_hash,omitempty"` + // new_state of the BTC delegation + NewState string `protobuf:"bytes,2,opt,name=new_state,json=newState,proto3" json:"new_state,omitempty"` } -func (m *EventPowerDistUpdate_BtcDelStateUpdate) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - if m.BtcDelStateUpdate != nil { - { - size, err := m.BtcDelStateUpdate.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintEvents(dAtA, i, uint64(size)) +func (m *EventCovenantQuorumReached) Reset() { *m = EventCovenantQuorumReached{} } +func (m *EventCovenantQuorumReached) String() string { return proto.CompactTextString(m) } +func (*EventCovenantQuorumReached) ProtoMessage() {} +func (*EventCovenantQuorumReached) Descriptor() ([]byte, []int) { + return fileDescriptor_74118427820fff75, []int{9} +} +func (m *EventCovenantQuorumReached) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *EventCovenantQuorumReached) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_EventCovenantQuorumReached.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err } - i-- - dAtA[i] = 0x22 + return b[:n], nil } - return len(dAtA) - i, nil } -func (m *EventPowerDistUpdate_SlashedBtcDelegation) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) +func (m *EventCovenantQuorumReached) XXX_Merge(src proto.Message) { + xxx_messageInfo_EventCovenantQuorumReached.Merge(m, src) +} +func (m *EventCovenantQuorumReached) XXX_Size() int { + return m.Size() +} +func (m *EventCovenantQuorumReached) XXX_DiscardUnknown() { + xxx_messageInfo_EventCovenantQuorumReached.DiscardUnknown(m) } -func (m *EventPowerDistUpdate_SlashedBtcDelegation) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - if m.SlashedBtcDelegation != nil { - { - size, err := m.SlashedBtcDelegation.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintEvents(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x2a +var xxx_messageInfo_EventCovenantQuorumReached proto.InternalMessageInfo + +func (m *EventCovenantQuorumReached) GetStakingTxHash() string { + if m != nil { + return m.StakingTxHash } - return len(dAtA) - i, nil + return "" } -func (m *EventPowerDistUpdate_EventSlashedFinalityProvider) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err + +func (m *EventCovenantQuorumReached) GetNewState() string { + if m != nil { + return m.NewState } - return dAtA[:n], nil + return "" } -func (m *EventPowerDistUpdate_EventSlashedFinalityProvider) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) +// EventBTCDelegationInclusionProofReceived is the event emitted when a BTC delegation +// inclusion proof is received +type EventBTCDelegationInclusionProofReceived struct { + // staking_tx_hash is the hash of the staking tx. + // It uniquely identifies a BTC delegation + StakingTxHash string `protobuf:"bytes,1,opt,name=staking_tx_hash,json=stakingTxHash,proto3" json:"staking_tx_hash,omitempty"` + // start_height is the start BTC height of the BTC delegation + // it is the start BTC height of the timelock + StartHeight string `protobuf:"bytes,2,opt,name=start_height,json=startHeight,proto3" json:"start_height,omitempty"` + // end_height is the end height of the BTC delegation + // it is calculated by end_height = start_height + staking_time + EndHeight string `protobuf:"bytes,3,opt,name=end_height,json=endHeight,proto3" json:"end_height,omitempty"` + // new_state of the BTC delegation + NewState string `protobuf:"bytes,4,opt,name=new_state,json=newState,proto3" json:"new_state,omitempty"` } -func (m *EventPowerDistUpdate_EventSlashedFinalityProvider) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if m.Pk != nil { - { - size := m.Pk.Size() - i -= size - if _, err := m.Pk.MarshalTo(dAtA[i:]); err != nil { - return 0, err - } - i = encodeVarintEvents(dAtA, i, uint64(size)) +func (m *EventBTCDelegationInclusionProofReceived) Reset() { + *m = EventBTCDelegationInclusionProofReceived{} +} +func (m *EventBTCDelegationInclusionProofReceived) String() string { return proto.CompactTextString(m) } +func (*EventBTCDelegationInclusionProofReceived) ProtoMessage() {} +func (*EventBTCDelegationInclusionProofReceived) Descriptor() ([]byte, []int) { + return fileDescriptor_74118427820fff75, []int{10} +} +func (m *EventBTCDelegationInclusionProofReceived) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *EventBTCDelegationInclusionProofReceived) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_EventBTCDelegationInclusionProofReceived.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err } - i-- - dAtA[i] = 0xa + return b[:n], nil } - return len(dAtA) - i, nil } - -func (m *EventPowerDistUpdate_EventSlashedBTCDelegation) 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 *EventBTCDelegationInclusionProofReceived) XXX_Merge(src proto.Message) { + xxx_messageInfo_EventBTCDelegationInclusionProofReceived.Merge(m, src) } - -func (m *EventPowerDistUpdate_EventSlashedBTCDelegation) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) +func (m *EventBTCDelegationInclusionProofReceived) XXX_Size() int { + return m.Size() +} +func (m *EventBTCDelegationInclusionProofReceived) XXX_DiscardUnknown() { + xxx_messageInfo_EventBTCDelegationInclusionProofReceived.DiscardUnknown(m) } -func (m *EventPowerDistUpdate_EventSlashedBTCDelegation) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if len(m.StakingTxHash) > 0 { - i -= len(m.StakingTxHash) - copy(dAtA[i:], m.StakingTxHash) - i = encodeVarintEvents(dAtA, i, uint64(len(m.StakingTxHash))) - i-- - dAtA[i] = 0xa +var xxx_messageInfo_EventBTCDelegationInclusionProofReceived proto.InternalMessageInfo + +func (m *EventBTCDelegationInclusionProofReceived) GetStakingTxHash() string { + if m != nil { + return m.StakingTxHash } - return len(dAtA) - i, nil + return "" } -func (m *EventPowerDistUpdate_EventJailedFinalityProvider) Marshal() (dAtA []byte, err error) { +func (m *EventBTCDelegationInclusionProofReceived) GetStartHeight() string { + if m != nil { + return m.StartHeight + } + return "" +} + +func (m *EventBTCDelegationInclusionProofReceived) GetEndHeight() string { + if m != nil { + return m.EndHeight + } + return "" +} + +func (m *EventBTCDelegationInclusionProofReceived) GetNewState() string { + if m != nil { + return m.NewState + } + return "" +} + +// EventBTCDelgationUnbondedEarly is the event emitted when a BTC delegation +// is unbonded by staker sending unbonding tx to BTC +type EventBTCDelgationUnbondedEarly struct { + // staking_tx_hash is the hash of the staking tx. + // It uniquely identifies a BTC delegation + StakingTxHash string `protobuf:"bytes,1,opt,name=staking_tx_hash,json=stakingTxHash,proto3" json:"staking_tx_hash,omitempty"` + // start_height is the start BTC height of the early unbonding + StartHeight string `protobuf:"bytes,2,opt,name=start_height,json=startHeight,proto3" json:"start_height,omitempty"` + // new_state of the BTC delegation + NewState string `protobuf:"bytes,3,opt,name=new_state,json=newState,proto3" json:"new_state,omitempty"` +} + +func (m *EventBTCDelgationUnbondedEarly) Reset() { *m = EventBTCDelgationUnbondedEarly{} } +func (m *EventBTCDelgationUnbondedEarly) String() string { return proto.CompactTextString(m) } +func (*EventBTCDelgationUnbondedEarly) ProtoMessage() {} +func (*EventBTCDelgationUnbondedEarly) Descriptor() ([]byte, []int) { + return fileDescriptor_74118427820fff75, []int{11} +} +func (m *EventBTCDelgationUnbondedEarly) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *EventBTCDelgationUnbondedEarly) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_EventBTCDelgationUnbondedEarly.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 *EventBTCDelgationUnbondedEarly) XXX_Merge(src proto.Message) { + xxx_messageInfo_EventBTCDelgationUnbondedEarly.Merge(m, src) +} +func (m *EventBTCDelgationUnbondedEarly) XXX_Size() int { + return m.Size() +} +func (m *EventBTCDelgationUnbondedEarly) XXX_DiscardUnknown() { + xxx_messageInfo_EventBTCDelgationUnbondedEarly.DiscardUnknown(m) +} + +var xxx_messageInfo_EventBTCDelgationUnbondedEarly proto.InternalMessageInfo + +func (m *EventBTCDelgationUnbondedEarly) GetStakingTxHash() string { + if m != nil { + return m.StakingTxHash + } + return "" +} + +func (m *EventBTCDelgationUnbondedEarly) GetStartHeight() string { + if m != nil { + return m.StartHeight + } + return "" +} + +func (m *EventBTCDelgationUnbondedEarly) GetNewState() string { + if m != nil { + return m.NewState + } + return "" +} + +// EventBTCDelegationExpired is the event emitted when a BTC delegation +// is unbonded by expiration of the staking tx timelock +type EventBTCDelegationExpired struct { + // staking_tx_hash is the hash of the staking tx. + // It uniquely identifies a BTC delegation + StakingTxHash string `protobuf:"bytes,1,opt,name=staking_tx_hash,json=stakingTxHash,proto3" json:"staking_tx_hash,omitempty"` + // new_state of the BTC delegation + NewState string `protobuf:"bytes,2,opt,name=new_state,json=newState,proto3" json:"new_state,omitempty"` +} + +func (m *EventBTCDelegationExpired) Reset() { *m = EventBTCDelegationExpired{} } +func (m *EventBTCDelegationExpired) String() string { return proto.CompactTextString(m) } +func (*EventBTCDelegationExpired) ProtoMessage() {} +func (*EventBTCDelegationExpired) Descriptor() ([]byte, []int) { + return fileDescriptor_74118427820fff75, []int{12} +} +func (m *EventBTCDelegationExpired) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *EventBTCDelegationExpired) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_EventBTCDelegationExpired.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 *EventBTCDelegationExpired) XXX_Merge(src proto.Message) { + xxx_messageInfo_EventBTCDelegationExpired.Merge(m, src) +} +func (m *EventBTCDelegationExpired) XXX_Size() int { + return m.Size() +} +func (m *EventBTCDelegationExpired) XXX_DiscardUnknown() { + xxx_messageInfo_EventBTCDelegationExpired.DiscardUnknown(m) +} + +var xxx_messageInfo_EventBTCDelegationExpired proto.InternalMessageInfo + +func (m *EventBTCDelegationExpired) GetStakingTxHash() string { + if m != nil { + return m.StakingTxHash + } + return "" +} + +func (m *EventBTCDelegationExpired) GetNewState() string { + if m != nil { + return m.NewState + } + return "" +} + +// EventUnexpectedUnbondingTx is the event emitted when an unbonding tx is +// is different that the one registered in the BTC delegation. +type EventUnexpectedUnbondingTx struct { + // staking_tx_hash uniquely identifies a BTC delegation being unbonded + StakingTxHash string `protobuf:"bytes,1,opt,name=staking_tx_hash,json=stakingTxHash,proto3" json:"staking_tx_hash,omitempty"` + // spend_stake_tx_hash has of the transactin spending staking output + SpendStakeTxHash string `protobuf:"bytes,2,opt,name=spend_stake_tx_hash,json=spendStakeTxHash,proto3" json:"spend_stake_tx_hash,omitempty"` + // spend_stake_tx_header_hash is the hash of the header of the block that + // includes the spend_stake_tx + SpendStakeTxHeaderHash string `protobuf:"bytes,3,opt,name=spend_stake_tx_header_hash,json=spendStakeTxHeaderHash,proto3" json:"spend_stake_tx_header_hash,omitempty"` + // spend_stake_tx_block_index is the spend_stake_tx index in the block + SpendStakeTxBlockIndex uint32 `protobuf:"varint,4,opt,name=spend_stake_tx_block_index,json=spendStakeTxBlockIndex,proto3" json:"spend_stake_tx_block_index,omitempty"` +} + +func (m *EventUnexpectedUnbondingTx) Reset() { *m = EventUnexpectedUnbondingTx{} } +func (m *EventUnexpectedUnbondingTx) String() string { return proto.CompactTextString(m) } +func (*EventUnexpectedUnbondingTx) ProtoMessage() {} +func (*EventUnexpectedUnbondingTx) Descriptor() ([]byte, []int) { + return fileDescriptor_74118427820fff75, []int{13} +} +func (m *EventUnexpectedUnbondingTx) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *EventUnexpectedUnbondingTx) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_EventUnexpectedUnbondingTx.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 *EventUnexpectedUnbondingTx) XXX_Merge(src proto.Message) { + xxx_messageInfo_EventUnexpectedUnbondingTx.Merge(m, src) +} +func (m *EventUnexpectedUnbondingTx) XXX_Size() int { + return m.Size() +} +func (m *EventUnexpectedUnbondingTx) XXX_DiscardUnknown() { + xxx_messageInfo_EventUnexpectedUnbondingTx.DiscardUnknown(m) +} + +var xxx_messageInfo_EventUnexpectedUnbondingTx proto.InternalMessageInfo + +func (m *EventUnexpectedUnbondingTx) GetStakingTxHash() string { + if m != nil { + return m.StakingTxHash + } + return "" +} + +func (m *EventUnexpectedUnbondingTx) GetSpendStakeTxHash() string { + if m != nil { + return m.SpendStakeTxHash + } + return "" +} + +func (m *EventUnexpectedUnbondingTx) GetSpendStakeTxHeaderHash() string { + if m != nil { + return m.SpendStakeTxHeaderHash + } + return "" +} + +func (m *EventUnexpectedUnbondingTx) GetSpendStakeTxBlockIndex() uint32 { + if m != nil { + return m.SpendStakeTxBlockIndex + } + return 0 +} + +func init() { + proto.RegisterEnum("babylon.btcstaking.v1.FinalityProviderStatus", FinalityProviderStatus_name, FinalityProviderStatus_value) + proto.RegisterType((*EventNewFinalityProvider)(nil), "babylon.btcstaking.v1.EventNewFinalityProvider") + proto.RegisterType((*EventFinalityProviderCreated)(nil), "babylon.btcstaking.v1.EventFinalityProviderCreated") + proto.RegisterType((*EventFinalityProviderEdited)(nil), "babylon.btcstaking.v1.EventFinalityProviderEdited") + proto.RegisterType((*EventBTCDelegationStateUpdate)(nil), "babylon.btcstaking.v1.EventBTCDelegationStateUpdate") + proto.RegisterType((*EventSelectiveSlashing)(nil), "babylon.btcstaking.v1.EventSelectiveSlashing") + proto.RegisterType((*EventPowerDistUpdate)(nil), "babylon.btcstaking.v1.EventPowerDistUpdate") + proto.RegisterType((*EventPowerDistUpdate_EventSlashedFinalityProvider)(nil), "babylon.btcstaking.v1.EventPowerDistUpdate.EventSlashedFinalityProvider") + proto.RegisterType((*EventPowerDistUpdate_EventSlashedBTCDelegation)(nil), "babylon.btcstaking.v1.EventPowerDistUpdate.EventSlashedBTCDelegation") + proto.RegisterType((*EventPowerDistUpdate_EventJailedFinalityProvider)(nil), "babylon.btcstaking.v1.EventPowerDistUpdate.EventJailedFinalityProvider") + proto.RegisterType((*EventPowerDistUpdate_EventUnjailedFinalityProvider)(nil), "babylon.btcstaking.v1.EventPowerDistUpdate.EventUnjailedFinalityProvider") + proto.RegisterType((*EventFinalityProviderStatusChange)(nil), "babylon.btcstaking.v1.EventFinalityProviderStatusChange") + proto.RegisterType((*EventBTCDelegationCreated)(nil), "babylon.btcstaking.v1.EventBTCDelegationCreated") + proto.RegisterType((*EventCovenantSignatureReceived)(nil), "babylon.btcstaking.v1.EventCovenantSignatureReceived") + proto.RegisterType((*EventCovenantQuorumReached)(nil), "babylon.btcstaking.v1.EventCovenantQuorumReached") + proto.RegisterType((*EventBTCDelegationInclusionProofReceived)(nil), "babylon.btcstaking.v1.EventBTCDelegationInclusionProofReceived") + proto.RegisterType((*EventBTCDelgationUnbondedEarly)(nil), "babylon.btcstaking.v1.EventBTCDelgationUnbondedEarly") + proto.RegisterType((*EventBTCDelegationExpired)(nil), "babylon.btcstaking.v1.EventBTCDelegationExpired") + proto.RegisterType((*EventUnexpectedUnbondingTx)(nil), "babylon.btcstaking.v1.EventUnexpectedUnbondingTx") +} + +func init() { + proto.RegisterFile("babylon/btcstaking/v1/events.proto", fileDescriptor_74118427820fff75) +} + +var fileDescriptor_74118427820fff75 = []byte{ + // 1327 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xb4, 0x57, 0x4b, 0x6f, 0xdb, 0xc6, + 0x16, 0xd6, 0xc3, 0xcf, 0xb1, 0xe3, 0x38, 0x73, 0x7d, 0x0d, 0x59, 0x37, 0x51, 0x1c, 0xe5, 0x71, + 0x7d, 0x73, 0x1b, 0x29, 0x71, 0x0c, 0xa4, 0x5b, 0x4b, 0x96, 0x23, 0xa5, 0x86, 0xa3, 0x52, 0x76, + 0x80, 0x76, 0x43, 0xf0, 0x71, 0x24, 0x4d, 0x45, 0x0d, 0x09, 0x72, 0x24, 0x4b, 0x8b, 0xae, 0xbb, + 0xcd, 0xba, 0x40, 0xf7, 0xdd, 0xb5, 0x3f, 0x23, 0x9b, 0x02, 0xd9, 0x14, 0x28, 0xba, 0x28, 0x8a, + 0x64, 0xd1, 0x7f, 0x51, 0x14, 0x9c, 0x19, 0x52, 0xa2, 0x4c, 0x26, 0x76, 0x90, 0x6c, 0x0c, 0xcf, + 0xcc, 0x77, 0xce, 0x77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 0x3e, 0x81, 0xef, 0xff, 0x94, 0x46, 0x9b, + 0xf1, 0x0f, 0x0d, 0xbe, 0x8b, 0x6e, 0x1d, 0x36, 0x8e, 0xf7, 0x8f, 0x1a, 0x27, 0x5f, 0xa9, 0x4d, + 0xe5, 0xf9, 0x8b, 0xc6, 0x41, 0x4d, 0x51, 0x5b, 0x27, 0xfb, 0x27, 0xa7, 0x2d, 0xb5, 0x71, 0xbc, + 0x5f, 0x3d, 0x69, 0xbc, 0xa8, 0xad, 0xa7, 0xf0, 0x6d, 0x74, 0x33, 0x11, 0x26, 0x41, 0xe9, 0x77, + 0x82, 0x9e, 0xed, 0x37, 0x8e, 0x6a, 0x07, 0xeb, 0x19, 0x7c, 0x07, 0x6d, 0x27, 0x82, 0x5a, 0x47, + 0xfb, 0xad, 0x7a, 0xed, 0x60, 0x3d, 0x5b, 0x39, 0x7e, 0xf5, 0xa6, 0x90, 0x7e, 0xfd, 0xa6, 0x90, + 0xfe, 0xf3, 0x4d, 0x21, 0xfd, 0xf2, 0x6d, 0x21, 0xf5, 0xfa, 0x6d, 0x21, 0xf5, 0xdb, 0xdb, 0x42, + 0xea, 0xeb, 0x0b, 0x3c, 0xbc, 0xa3, 0xe9, 0x6f, 0x5c, 0xfe, 0x0a, 0xeb, 0x0b, 0xfc, 0x73, 0xf5, + 0xf1, 0x3f, 0x01, 0x00, 0x00, 0xff, 0xff, 0xe8, 0x77, 0x69, 0x4c, 0x7d, 0x0f, 0x00, 0x00, +} + +func (m *EventNewFinalityProvider) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalToSizedBuffer(dAtA[:size]) @@ -859,23 +1454,23 @@ func (m *EventPowerDistUpdate_EventJailedFinalityProvider) Marshal() (dAtA []byt return dAtA[:n], nil } -func (m *EventPowerDistUpdate_EventJailedFinalityProvider) MarshalTo(dAtA []byte) (int, error) { +func (m *EventNewFinalityProvider) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *EventPowerDistUpdate_EventJailedFinalityProvider) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *EventNewFinalityProvider) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) _ = i var l int _ = l - if m.Pk != nil { + if m.Fp != nil { { - size := m.Pk.Size() - i -= size - if _, err := m.Pk.MarshalTo(dAtA[i:]); err != nil { + size, err := m.Fp.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { return 0, err } + i -= size i = encodeVarintEvents(dAtA, i, uint64(size)) } i-- @@ -884,7 +1479,7 @@ func (m *EventPowerDistUpdate_EventJailedFinalityProvider) MarshalToSizedBuffer( return len(dAtA) - i, nil } -func (m *EventPowerDistUpdate_EventUnjailedFinalityProvider) Marshal() (dAtA []byte, err error) { +func (m *EventFinalityProviderCreated) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalToSizedBuffer(dAtA[:size]) @@ -894,248 +1489,3113 @@ func (m *EventPowerDistUpdate_EventUnjailedFinalityProvider) Marshal() (dAtA []b return dAtA[:n], nil } -func (m *EventPowerDistUpdate_EventUnjailedFinalityProvider) MarshalTo(dAtA []byte) (int, error) { +func (m *EventFinalityProviderCreated) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *EventPowerDistUpdate_EventUnjailedFinalityProvider) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *EventFinalityProviderCreated) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) _ = i var l int _ = l - if m.Pk != nil { - { - size := m.Pk.Size() - i -= size - if _, err := m.Pk.MarshalTo(dAtA[i:]); err != nil { - return 0, err - } - i = encodeVarintEvents(dAtA, i, uint64(size)) - } + if len(m.Details) > 0 { + i -= len(m.Details) + copy(dAtA[i:], m.Details) + i = encodeVarintEvents(dAtA, i, uint64(len(m.Details))) + i-- + dAtA[i] = 0x42 + } + if len(m.SecurityContact) > 0 { + i -= len(m.SecurityContact) + copy(dAtA[i:], m.SecurityContact) + i = encodeVarintEvents(dAtA, i, uint64(len(m.SecurityContact))) + i-- + dAtA[i] = 0x3a + } + if len(m.Website) > 0 { + i -= len(m.Website) + copy(dAtA[i:], m.Website) + i = encodeVarintEvents(dAtA, i, uint64(len(m.Website))) + i-- + dAtA[i] = 0x32 + } + if len(m.Identity) > 0 { + i -= len(m.Identity) + copy(dAtA[i:], m.Identity) + i = encodeVarintEvents(dAtA, i, uint64(len(m.Identity))) + i-- + dAtA[i] = 0x2a + } + if len(m.Moniker) > 0 { + i -= len(m.Moniker) + copy(dAtA[i:], m.Moniker) + i = encodeVarintEvents(dAtA, i, uint64(len(m.Moniker))) + i-- + dAtA[i] = 0x22 + } + if len(m.Commission) > 0 { + i -= len(m.Commission) + copy(dAtA[i:], m.Commission) + i = encodeVarintEvents(dAtA, i, uint64(len(m.Commission))) + i-- + dAtA[i] = 0x1a + } + if len(m.Addr) > 0 { + i -= len(m.Addr) + copy(dAtA[i:], m.Addr) + i = encodeVarintEvents(dAtA, i, uint64(len(m.Addr))) + i-- + dAtA[i] = 0x12 + } + if len(m.BtcPkHex) > 0 { + i -= len(m.BtcPkHex) + copy(dAtA[i:], m.BtcPkHex) + i = encodeVarintEvents(dAtA, i, uint64(len(m.BtcPkHex))) i-- dAtA[i] = 0xa } return len(dAtA) - i, nil } -func encodeVarintEvents(dAtA []byte, offset int, v uint64) int { - offset -= sovEvents(v) - base := offset - for v >= 1<<7 { - dAtA[offset] = uint8(v&0x7f | 0x80) - v >>= 7 - offset++ +func (m *EventFinalityProviderEdited) 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 *EventNewFinalityProvider) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if m.Fp != nil { - l = m.Fp.Size() - n += 1 + l + sovEvents(uint64(l)) - } - return n + +func (m *EventFinalityProviderEdited) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *EventBTCDelegationStateUpdate) Size() (n int) { - if m == nil { - return 0 - } +func (m *EventFinalityProviderEdited) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i var l int _ = l - l = len(m.StakingTxHash) - if l > 0 { - n += 1 + l + sovEvents(uint64(l)) + if len(m.Details) > 0 { + i -= len(m.Details) + copy(dAtA[i:], m.Details) + i = encodeVarintEvents(dAtA, i, uint64(len(m.Details))) + i-- + dAtA[i] = 0x3a } - if m.NewState != 0 { - n += 1 + sovEvents(uint64(m.NewState)) + if len(m.SecurityContact) > 0 { + i -= len(m.SecurityContact) + copy(dAtA[i:], m.SecurityContact) + i = encodeVarintEvents(dAtA, i, uint64(len(m.SecurityContact))) + i-- + dAtA[i] = 0x32 } - return n -} - -func (m *EventSelectiveSlashing) Size() (n int) { - if m == nil { - return 0 + if len(m.Website) > 0 { + i -= len(m.Website) + copy(dAtA[i:], m.Website) + i = encodeVarintEvents(dAtA, i, uint64(len(m.Website))) + i-- + dAtA[i] = 0x2a } - var l int - _ = l - if m.Evidence != nil { - l = m.Evidence.Size() - n += 1 + l + sovEvents(uint64(l)) + if len(m.Identity) > 0 { + i -= len(m.Identity) + copy(dAtA[i:], m.Identity) + i = encodeVarintEvents(dAtA, i, uint64(len(m.Identity))) + i-- + dAtA[i] = 0x22 } - return n -} - -func (m *EventPowerDistUpdate) Size() (n int) { - if m == nil { - return 0 + if len(m.Moniker) > 0 { + i -= len(m.Moniker) + copy(dAtA[i:], m.Moniker) + i = encodeVarintEvents(dAtA, i, uint64(len(m.Moniker))) + i-- + dAtA[i] = 0x1a } - var l int - _ = l - if m.Ev != nil { - n += m.Ev.Size() + if len(m.Commission) > 0 { + i -= len(m.Commission) + copy(dAtA[i:], m.Commission) + i = encodeVarintEvents(dAtA, i, uint64(len(m.Commission))) + i-- + dAtA[i] = 0x12 } - return n + if len(m.BtcPkHex) > 0 { + i -= len(m.BtcPkHex) + copy(dAtA[i:], m.BtcPkHex) + i = encodeVarintEvents(dAtA, i, uint64(len(m.BtcPkHex))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil } -func (m *EventPowerDistUpdate_SlashedFp) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if m.SlashedFp != nil { - l = m.SlashedFp.Size() - n += 1 + l + sovEvents(uint64(l)) +func (m *EventBTCDelegationStateUpdate) 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 n + return dAtA[:n], nil } -func (m *EventPowerDistUpdate_JailedFp) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if m.JailedFp != nil { - l = m.JailedFp.Size() - n += 1 + l + sovEvents(uint64(l)) - } - return n + +func (m *EventBTCDelegationStateUpdate) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *EventPowerDistUpdate_UnjailedFp) Size() (n int) { - if m == nil { - return 0 - } + +func (m *EventBTCDelegationStateUpdate) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i var l int _ = l - if m.UnjailedFp != nil { - l = m.UnjailedFp.Size() - n += 1 + l + sovEvents(uint64(l)) - } - return n -} -func (m *EventPowerDistUpdate_BtcDelStateUpdate) Size() (n int) { - if m == nil { - return 0 + if m.NewState != 0 { + i = encodeVarintEvents(dAtA, i, uint64(m.NewState)) + i-- + dAtA[i] = 0x10 } - var l int - _ = l - if m.BtcDelStateUpdate != nil { - l = m.BtcDelStateUpdate.Size() - n += 1 + l + sovEvents(uint64(l)) + if len(m.StakingTxHash) > 0 { + i -= len(m.StakingTxHash) + copy(dAtA[i:], m.StakingTxHash) + i = encodeVarintEvents(dAtA, i, uint64(len(m.StakingTxHash))) + i-- + dAtA[i] = 0xa } - return n + return len(dAtA) - i, nil } -func (m *EventPowerDistUpdate_SlashedBtcDelegation) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if m.SlashedBtcDelegation != nil { - l = m.SlashedBtcDelegation.Size() - n += 1 + l + sovEvents(uint64(l)) + +func (m *EventSelectiveSlashing) 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 n + return dAtA[:n], nil } -func (m *EventPowerDistUpdate_EventSlashedFinalityProvider) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if m.Pk != nil { - l = m.Pk.Size() - n += 1 + l + sovEvents(uint64(l)) - } - return n + +func (m *EventSelectiveSlashing) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *EventPowerDistUpdate_EventSlashedBTCDelegation) Size() (n int) { - if m == nil { - return 0 - } +func (m *EventSelectiveSlashing) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i var l int _ = l - l = len(m.StakingTxHash) - if l > 0 { - n += 1 + l + sovEvents(uint64(l)) + if m.Evidence != nil { + { + size, err := m.Evidence.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintEvents(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa } - return n + return len(dAtA) - i, nil } -func (m *EventPowerDistUpdate_EventJailedFinalityProvider) Size() (n int) { - if m == nil { - return 0 +func (m *EventPowerDistUpdate) 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 *EventPowerDistUpdate) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *EventPowerDistUpdate) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i var l int _ = l - if m.Pk != nil { - l = m.Pk.Size() - n += 1 + l + sovEvents(uint64(l)) + if m.Ev != nil { + { + size := m.Ev.Size() + i -= size + if _, err := m.Ev.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + } } - return n + return len(dAtA) - i, nil } -func (m *EventPowerDistUpdate_EventUnjailedFinalityProvider) Size() (n int) { - if m == nil { - return 0 +func (m *EventPowerDistUpdate_SlashedFp) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *EventPowerDistUpdate_SlashedFp) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + if m.SlashedFp != nil { + { + size, err := m.SlashedFp.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintEvents(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa } - var l int - _ = l - if m.Pk != nil { - l = m.Pk.Size() - n += 1 + l + sovEvents(uint64(l)) + return len(dAtA) - i, nil +} +func (m *EventPowerDistUpdate_JailedFp) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *EventPowerDistUpdate_JailedFp) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + if m.JailedFp != nil { + { + size, err := m.JailedFp.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintEvents(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 } - return n + return len(dAtA) - i, nil +} +func (m *EventPowerDistUpdate_UnjailedFp) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) } -func sovEvents(x uint64) (n int) { - return (math_bits.Len64(x|1) + 6) / 7 +func (m *EventPowerDistUpdate_UnjailedFp) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + if m.UnjailedFp != nil { + { + size, err := m.UnjailedFp.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintEvents(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x1a + } + return len(dAtA) - i, nil } -func sozEvents(x uint64) (n int) { - return sovEvents(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +func (m *EventPowerDistUpdate_BtcDelStateUpdate) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *EventNewFinalityProvider) 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 ErrIntOverflowEvents + +func (m *EventPowerDistUpdate_BtcDelStateUpdate) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + if m.BtcDelStateUpdate != nil { + { + size, err := m.BtcDelStateUpdate.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintEvents(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x22 + } + return len(dAtA) - i, nil +} +func (m *EventPowerDistUpdate_SlashedBtcDelegation) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *EventPowerDistUpdate_SlashedBtcDelegation) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + if m.SlashedBtcDelegation != nil { + { + size, err := m.SlashedBtcDelegation.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintEvents(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x2a + } + return len(dAtA) - i, nil +} +func (m *EventPowerDistUpdate_EventSlashedFinalityProvider) 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 *EventPowerDistUpdate_EventSlashedFinalityProvider) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *EventPowerDistUpdate_EventSlashedFinalityProvider) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.Pk != nil { + { + size := m.Pk.Size() + i -= size + if _, err := m.Pk.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintEvents(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *EventPowerDistUpdate_EventSlashedBTCDelegation) 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 *EventPowerDistUpdate_EventSlashedBTCDelegation) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *EventPowerDistUpdate_EventSlashedBTCDelegation) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.StakingTxHash) > 0 { + i -= len(m.StakingTxHash) + copy(dAtA[i:], m.StakingTxHash) + i = encodeVarintEvents(dAtA, i, uint64(len(m.StakingTxHash))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *EventPowerDistUpdate_EventJailedFinalityProvider) 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 *EventPowerDistUpdate_EventJailedFinalityProvider) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *EventPowerDistUpdate_EventJailedFinalityProvider) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.Pk != nil { + { + size := m.Pk.Size() + i -= size + if _, err := m.Pk.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintEvents(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *EventPowerDistUpdate_EventUnjailedFinalityProvider) 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 *EventPowerDistUpdate_EventUnjailedFinalityProvider) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *EventPowerDistUpdate_EventUnjailedFinalityProvider) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.Pk != nil { + { + size := m.Pk.Size() + i -= size + if _, err := m.Pk.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintEvents(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *EventFinalityProviderStatusChange) 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 *EventFinalityProviderStatusChange) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *EventFinalityProviderStatusChange) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.NewState) > 0 { + i -= len(m.NewState) + copy(dAtA[i:], m.NewState) + i = encodeVarintEvents(dAtA, i, uint64(len(m.NewState))) + i-- + dAtA[i] = 0x12 + } + if len(m.BtcPk) > 0 { + i -= len(m.BtcPk) + copy(dAtA[i:], m.BtcPk) + i = encodeVarintEvents(dAtA, i, uint64(len(m.BtcPk))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *EventBTCDelegationCreated) 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 *EventBTCDelegationCreated) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *EventBTCDelegationCreated) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.NewState) > 0 { + i -= len(m.NewState) + copy(dAtA[i:], m.NewState) + i = encodeVarintEvents(dAtA, i, uint64(len(m.NewState))) + i-- + dAtA[i] = 0x4a + } + if len(m.UnbondingTx) > 0 { + i -= len(m.UnbondingTx) + copy(dAtA[i:], m.UnbondingTx) + i = encodeVarintEvents(dAtA, i, uint64(len(m.UnbondingTx))) + i-- + dAtA[i] = 0x42 + } + if len(m.UnbondingTime) > 0 { + i -= len(m.UnbondingTime) + copy(dAtA[i:], m.UnbondingTime) + i = encodeVarintEvents(dAtA, i, uint64(len(m.UnbondingTime))) + i-- + dAtA[i] = 0x3a + } + if len(m.StakingTime) > 0 { + i -= len(m.StakingTime) + copy(dAtA[i:], m.StakingTime) + i = encodeVarintEvents(dAtA, i, uint64(len(m.StakingTime))) + i-- + dAtA[i] = 0x32 + } + if len(m.StakerBtcPkHex) > 0 { + i -= len(m.StakerBtcPkHex) + copy(dAtA[i:], m.StakerBtcPkHex) + i = encodeVarintEvents(dAtA, i, uint64(len(m.StakerBtcPkHex))) + i-- + dAtA[i] = 0x2a + } + if len(m.FinalityProviderBtcPksHex) > 0 { + for iNdEx := len(m.FinalityProviderBtcPksHex) - 1; iNdEx >= 0; iNdEx-- { + i -= len(m.FinalityProviderBtcPksHex[iNdEx]) + copy(dAtA[i:], m.FinalityProviderBtcPksHex[iNdEx]) + i = encodeVarintEvents(dAtA, i, uint64(len(m.FinalityProviderBtcPksHex[iNdEx]))) + i-- + dAtA[i] = 0x22 + } + } + if len(m.ParamsVersion) > 0 { + i -= len(m.ParamsVersion) + copy(dAtA[i:], m.ParamsVersion) + i = encodeVarintEvents(dAtA, i, uint64(len(m.ParamsVersion))) + i-- + dAtA[i] = 0x1a + } + if len(m.StakingOutputIndex) > 0 { + i -= len(m.StakingOutputIndex) + copy(dAtA[i:], m.StakingOutputIndex) + i = encodeVarintEvents(dAtA, i, uint64(len(m.StakingOutputIndex))) + i-- + dAtA[i] = 0x12 + } + if len(m.StakingTxHex) > 0 { + i -= len(m.StakingTxHex) + copy(dAtA[i:], m.StakingTxHex) + i = encodeVarintEvents(dAtA, i, uint64(len(m.StakingTxHex))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *EventCovenantSignatureReceived) 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 *EventCovenantSignatureReceived) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *EventCovenantSignatureReceived) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.CovenantUnbondingSignatureHex) > 0 { + i -= len(m.CovenantUnbondingSignatureHex) + copy(dAtA[i:], m.CovenantUnbondingSignatureHex) + i = encodeVarintEvents(dAtA, i, uint64(len(m.CovenantUnbondingSignatureHex))) + i-- + dAtA[i] = 0x1a + } + if len(m.CovenantBtcPkHex) > 0 { + i -= len(m.CovenantBtcPkHex) + copy(dAtA[i:], m.CovenantBtcPkHex) + i = encodeVarintEvents(dAtA, i, uint64(len(m.CovenantBtcPkHex))) + i-- + dAtA[i] = 0x12 + } + if len(m.StakingTxHash) > 0 { + i -= len(m.StakingTxHash) + copy(dAtA[i:], m.StakingTxHash) + i = encodeVarintEvents(dAtA, i, uint64(len(m.StakingTxHash))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *EventCovenantQuorumReached) 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 *EventCovenantQuorumReached) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *EventCovenantQuorumReached) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.NewState) > 0 { + i -= len(m.NewState) + copy(dAtA[i:], m.NewState) + i = encodeVarintEvents(dAtA, i, uint64(len(m.NewState))) + i-- + dAtA[i] = 0x12 + } + if len(m.StakingTxHash) > 0 { + i -= len(m.StakingTxHash) + copy(dAtA[i:], m.StakingTxHash) + i = encodeVarintEvents(dAtA, i, uint64(len(m.StakingTxHash))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *EventBTCDelegationInclusionProofReceived) 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 *EventBTCDelegationInclusionProofReceived) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *EventBTCDelegationInclusionProofReceived) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.NewState) > 0 { + i -= len(m.NewState) + copy(dAtA[i:], m.NewState) + i = encodeVarintEvents(dAtA, i, uint64(len(m.NewState))) + i-- + dAtA[i] = 0x22 + } + if len(m.EndHeight) > 0 { + i -= len(m.EndHeight) + copy(dAtA[i:], m.EndHeight) + i = encodeVarintEvents(dAtA, i, uint64(len(m.EndHeight))) + i-- + dAtA[i] = 0x1a + } + if len(m.StartHeight) > 0 { + i -= len(m.StartHeight) + copy(dAtA[i:], m.StartHeight) + i = encodeVarintEvents(dAtA, i, uint64(len(m.StartHeight))) + i-- + dAtA[i] = 0x12 + } + if len(m.StakingTxHash) > 0 { + i -= len(m.StakingTxHash) + copy(dAtA[i:], m.StakingTxHash) + i = encodeVarintEvents(dAtA, i, uint64(len(m.StakingTxHash))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *EventBTCDelgationUnbondedEarly) 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 *EventBTCDelgationUnbondedEarly) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *EventBTCDelgationUnbondedEarly) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.NewState) > 0 { + i -= len(m.NewState) + copy(dAtA[i:], m.NewState) + i = encodeVarintEvents(dAtA, i, uint64(len(m.NewState))) + i-- + dAtA[i] = 0x1a + } + if len(m.StartHeight) > 0 { + i -= len(m.StartHeight) + copy(dAtA[i:], m.StartHeight) + i = encodeVarintEvents(dAtA, i, uint64(len(m.StartHeight))) + i-- + dAtA[i] = 0x12 + } + if len(m.StakingTxHash) > 0 { + i -= len(m.StakingTxHash) + copy(dAtA[i:], m.StakingTxHash) + i = encodeVarintEvents(dAtA, i, uint64(len(m.StakingTxHash))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *EventBTCDelegationExpired) 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 *EventBTCDelegationExpired) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *EventBTCDelegationExpired) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.NewState) > 0 { + i -= len(m.NewState) + copy(dAtA[i:], m.NewState) + i = encodeVarintEvents(dAtA, i, uint64(len(m.NewState))) + i-- + dAtA[i] = 0x12 + } + if len(m.StakingTxHash) > 0 { + i -= len(m.StakingTxHash) + copy(dAtA[i:], m.StakingTxHash) + i = encodeVarintEvents(dAtA, i, uint64(len(m.StakingTxHash))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *EventUnexpectedUnbondingTx) 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 *EventUnexpectedUnbondingTx) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *EventUnexpectedUnbondingTx) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.SpendStakeTxBlockIndex != 0 { + i = encodeVarintEvents(dAtA, i, uint64(m.SpendStakeTxBlockIndex)) + i-- + dAtA[i] = 0x20 + } + if len(m.SpendStakeTxHeaderHash) > 0 { + i -= len(m.SpendStakeTxHeaderHash) + copy(dAtA[i:], m.SpendStakeTxHeaderHash) + i = encodeVarintEvents(dAtA, i, uint64(len(m.SpendStakeTxHeaderHash))) + i-- + dAtA[i] = 0x1a + } + if len(m.SpendStakeTxHash) > 0 { + i -= len(m.SpendStakeTxHash) + copy(dAtA[i:], m.SpendStakeTxHash) + i = encodeVarintEvents(dAtA, i, uint64(len(m.SpendStakeTxHash))) + i-- + dAtA[i] = 0x12 + } + if len(m.StakingTxHash) > 0 { + i -= len(m.StakingTxHash) + copy(dAtA[i:], m.StakingTxHash) + i = encodeVarintEvents(dAtA, i, uint64(len(m.StakingTxHash))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func encodeVarintEvents(dAtA []byte, offset int, v uint64) int { + offset -= sovEvents(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *EventNewFinalityProvider) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.Fp != nil { + l = m.Fp.Size() + n += 1 + l + sovEvents(uint64(l)) + } + return n +} + +func (m *EventFinalityProviderCreated) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.BtcPkHex) + if l > 0 { + n += 1 + l + sovEvents(uint64(l)) + } + l = len(m.Addr) + if l > 0 { + n += 1 + l + sovEvents(uint64(l)) + } + l = len(m.Commission) + if l > 0 { + n += 1 + l + sovEvents(uint64(l)) + } + l = len(m.Moniker) + if l > 0 { + n += 1 + l + sovEvents(uint64(l)) + } + l = len(m.Identity) + if l > 0 { + n += 1 + l + sovEvents(uint64(l)) + } + l = len(m.Website) + if l > 0 { + n += 1 + l + sovEvents(uint64(l)) + } + l = len(m.SecurityContact) + if l > 0 { + n += 1 + l + sovEvents(uint64(l)) + } + l = len(m.Details) + if l > 0 { + n += 1 + l + sovEvents(uint64(l)) + } + return n +} + +func (m *EventFinalityProviderEdited) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.BtcPkHex) + if l > 0 { + n += 1 + l + sovEvents(uint64(l)) + } + l = len(m.Commission) + if l > 0 { + n += 1 + l + sovEvents(uint64(l)) + } + l = len(m.Moniker) + if l > 0 { + n += 1 + l + sovEvents(uint64(l)) + } + l = len(m.Identity) + if l > 0 { + n += 1 + l + sovEvents(uint64(l)) + } + l = len(m.Website) + if l > 0 { + n += 1 + l + sovEvents(uint64(l)) + } + l = len(m.SecurityContact) + if l > 0 { + n += 1 + l + sovEvents(uint64(l)) + } + l = len(m.Details) + if l > 0 { + n += 1 + l + sovEvents(uint64(l)) + } + return n +} + +func (m *EventBTCDelegationStateUpdate) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.StakingTxHash) + if l > 0 { + n += 1 + l + sovEvents(uint64(l)) + } + if m.NewState != 0 { + n += 1 + sovEvents(uint64(m.NewState)) + } + return n +} + +func (m *EventSelectiveSlashing) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.Evidence != nil { + l = m.Evidence.Size() + n += 1 + l + sovEvents(uint64(l)) + } + return n +} + +func (m *EventPowerDistUpdate) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.Ev != nil { + n += m.Ev.Size() + } + return n +} + +func (m *EventPowerDistUpdate_SlashedFp) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.SlashedFp != nil { + l = m.SlashedFp.Size() + n += 1 + l + sovEvents(uint64(l)) + } + return n +} +func (m *EventPowerDistUpdate_JailedFp) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.JailedFp != nil { + l = m.JailedFp.Size() + n += 1 + l + sovEvents(uint64(l)) + } + return n +} +func (m *EventPowerDistUpdate_UnjailedFp) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.UnjailedFp != nil { + l = m.UnjailedFp.Size() + n += 1 + l + sovEvents(uint64(l)) + } + return n +} +func (m *EventPowerDistUpdate_BtcDelStateUpdate) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.BtcDelStateUpdate != nil { + l = m.BtcDelStateUpdate.Size() + n += 1 + l + sovEvents(uint64(l)) + } + return n +} +func (m *EventPowerDistUpdate_SlashedBtcDelegation) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.SlashedBtcDelegation != nil { + l = m.SlashedBtcDelegation.Size() + n += 1 + l + sovEvents(uint64(l)) + } + return n +} +func (m *EventPowerDistUpdate_EventSlashedFinalityProvider) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.Pk != nil { + l = m.Pk.Size() + n += 1 + l + sovEvents(uint64(l)) + } + return n +} + +func (m *EventPowerDistUpdate_EventSlashedBTCDelegation) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.StakingTxHash) + if l > 0 { + n += 1 + l + sovEvents(uint64(l)) + } + return n +} + +func (m *EventPowerDistUpdate_EventJailedFinalityProvider) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.Pk != nil { + l = m.Pk.Size() + n += 1 + l + sovEvents(uint64(l)) + } + return n +} + +func (m *EventPowerDistUpdate_EventUnjailedFinalityProvider) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.Pk != nil { + l = m.Pk.Size() + n += 1 + l + sovEvents(uint64(l)) + } + return n +} + +func (m *EventFinalityProviderStatusChange) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.BtcPk) + if l > 0 { + n += 1 + l + sovEvents(uint64(l)) + } + l = len(m.NewState) + if l > 0 { + n += 1 + l + sovEvents(uint64(l)) + } + return n +} + +func (m *EventBTCDelegationCreated) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.StakingTxHex) + if l > 0 { + n += 1 + l + sovEvents(uint64(l)) + } + l = len(m.StakingOutputIndex) + if l > 0 { + n += 1 + l + sovEvents(uint64(l)) + } + l = len(m.ParamsVersion) + if l > 0 { + n += 1 + l + sovEvents(uint64(l)) + } + if len(m.FinalityProviderBtcPksHex) > 0 { + for _, s := range m.FinalityProviderBtcPksHex { + l = len(s) + n += 1 + l + sovEvents(uint64(l)) + } + } + l = len(m.StakerBtcPkHex) + if l > 0 { + n += 1 + l + sovEvents(uint64(l)) + } + l = len(m.StakingTime) + if l > 0 { + n += 1 + l + sovEvents(uint64(l)) + } + l = len(m.UnbondingTime) + if l > 0 { + n += 1 + l + sovEvents(uint64(l)) + } + l = len(m.UnbondingTx) + if l > 0 { + n += 1 + l + sovEvents(uint64(l)) + } + l = len(m.NewState) + if l > 0 { + n += 1 + l + sovEvents(uint64(l)) + } + return n +} + +func (m *EventCovenantSignatureReceived) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.StakingTxHash) + if l > 0 { + n += 1 + l + sovEvents(uint64(l)) + } + l = len(m.CovenantBtcPkHex) + if l > 0 { + n += 1 + l + sovEvents(uint64(l)) + } + l = len(m.CovenantUnbondingSignatureHex) + if l > 0 { + n += 1 + l + sovEvents(uint64(l)) + } + return n +} + +func (m *EventCovenantQuorumReached) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.StakingTxHash) + if l > 0 { + n += 1 + l + sovEvents(uint64(l)) + } + l = len(m.NewState) + if l > 0 { + n += 1 + l + sovEvents(uint64(l)) + } + return n +} + +func (m *EventBTCDelegationInclusionProofReceived) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.StakingTxHash) + if l > 0 { + n += 1 + l + sovEvents(uint64(l)) + } + l = len(m.StartHeight) + if l > 0 { + n += 1 + l + sovEvents(uint64(l)) + } + l = len(m.EndHeight) + if l > 0 { + n += 1 + l + sovEvents(uint64(l)) + } + l = len(m.NewState) + if l > 0 { + n += 1 + l + sovEvents(uint64(l)) + } + return n +} + +func (m *EventBTCDelgationUnbondedEarly) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.StakingTxHash) + if l > 0 { + n += 1 + l + sovEvents(uint64(l)) + } + l = len(m.StartHeight) + if l > 0 { + n += 1 + l + sovEvents(uint64(l)) + } + l = len(m.NewState) + if l > 0 { + n += 1 + l + sovEvents(uint64(l)) + } + return n +} + +func (m *EventBTCDelegationExpired) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.StakingTxHash) + if l > 0 { + n += 1 + l + sovEvents(uint64(l)) + } + l = len(m.NewState) + if l > 0 { + n += 1 + l + sovEvents(uint64(l)) + } + return n +} + +func (m *EventUnexpectedUnbondingTx) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.StakingTxHash) + if l > 0 { + n += 1 + l + sovEvents(uint64(l)) + } + l = len(m.SpendStakeTxHash) + if l > 0 { + n += 1 + l + sovEvents(uint64(l)) + } + l = len(m.SpendStakeTxHeaderHash) + if l > 0 { + n += 1 + l + sovEvents(uint64(l)) + } + if m.SpendStakeTxBlockIndex != 0 { + n += 1 + sovEvents(uint64(m.SpendStakeTxBlockIndex)) + } + return n +} + +func sovEvents(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozEvents(x uint64) (n int) { + return sovEvents(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *EventNewFinalityProvider) 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 ErrIntOverflowEvents + } + 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: EventNewFinalityProvider: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: EventNewFinalityProvider: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Fp", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowEvents + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthEvents + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthEvents + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.Fp == nil { + m.Fp = &FinalityProvider{} + } + if err := m.Fp.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipEvents(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthEvents + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *EventFinalityProviderCreated) 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 ErrIntOverflowEvents + } + 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: EventFinalityProviderCreated: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: EventFinalityProviderCreated: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field BtcPkHex", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowEvents + } + 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 ErrInvalidLengthEvents + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthEvents + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.BtcPkHex = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Addr", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowEvents + } + 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 ErrInvalidLengthEvents + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthEvents + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Addr = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Commission", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowEvents + } + 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 ErrInvalidLengthEvents + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthEvents + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Commission = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Moniker", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowEvents + } + 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 ErrInvalidLengthEvents + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthEvents + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Moniker = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 5: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Identity", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowEvents + } + 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 ErrInvalidLengthEvents + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthEvents + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Identity = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 6: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Website", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowEvents + } + 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 ErrInvalidLengthEvents + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthEvents + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Website = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 7: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field SecurityContact", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowEvents + } + 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 ErrInvalidLengthEvents + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthEvents + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.SecurityContact = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 8: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Details", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowEvents + } + 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 ErrInvalidLengthEvents + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthEvents + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Details = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipEvents(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthEvents + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *EventFinalityProviderEdited) 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 ErrIntOverflowEvents + } + 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: EventFinalityProviderEdited: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: EventFinalityProviderEdited: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field BtcPkHex", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowEvents + } + 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 ErrInvalidLengthEvents + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthEvents + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.BtcPkHex = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Commission", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowEvents + } + 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 ErrInvalidLengthEvents + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthEvents + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Commission = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Moniker", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowEvents + } + 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 ErrInvalidLengthEvents + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthEvents + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Moniker = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Identity", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowEvents + } + 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 ErrInvalidLengthEvents + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthEvents + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Identity = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 5: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Website", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowEvents + } + 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 ErrInvalidLengthEvents + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthEvents + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Website = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 6: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field SecurityContact", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowEvents + } + 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 ErrInvalidLengthEvents + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthEvents + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.SecurityContact = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 7: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Details", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowEvents + } + 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 ErrInvalidLengthEvents + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthEvents + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Details = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipEvents(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthEvents + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *EventBTCDelegationStateUpdate) 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 ErrIntOverflowEvents + } + 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: EventBTCDelegationStateUpdate: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: EventBTCDelegationStateUpdate: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field StakingTxHash", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowEvents + } + 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 ErrInvalidLengthEvents + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthEvents + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.StakingTxHash = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field NewState", wireType) + } + m.NewState = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowEvents + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.NewState |= BTCDelegationStatus(b&0x7F) << shift + if b < 0x80 { + break + } + } + default: + iNdEx = preIndex + skippy, err := skipEvents(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthEvents + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *EventSelectiveSlashing) 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 ErrIntOverflowEvents + } + 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: EventSelectiveSlashing: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: EventSelectiveSlashing: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + 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 ErrIntOverflowEvents + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthEvents + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthEvents + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.Evidence == nil { + m.Evidence = &SelectiveSlashingEvidence{} + } + if err := m.Evidence.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipEvents(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthEvents + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *EventPowerDistUpdate) 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 ErrIntOverflowEvents + } + 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: EventPowerDistUpdate: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: EventPowerDistUpdate: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field SlashedFp", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowEvents + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthEvents + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthEvents + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + v := &EventPowerDistUpdate_EventSlashedFinalityProvider{} + if err := v.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + m.Ev = &EventPowerDistUpdate_SlashedFp{v} + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field JailedFp", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowEvents + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthEvents + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthEvents + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + v := &EventPowerDistUpdate_EventJailedFinalityProvider{} + if err := v.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + m.Ev = &EventPowerDistUpdate_JailedFp{v} + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field UnjailedFp", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowEvents + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthEvents + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthEvents + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + v := &EventPowerDistUpdate_EventUnjailedFinalityProvider{} + if err := v.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + m.Ev = &EventPowerDistUpdate_UnjailedFp{v} + iNdEx = postIndex + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field BtcDelStateUpdate", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowEvents + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthEvents + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthEvents + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + v := &EventBTCDelegationStateUpdate{} + if err := v.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + m.Ev = &EventPowerDistUpdate_BtcDelStateUpdate{v} + iNdEx = postIndex + case 5: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field SlashedBtcDelegation", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowEvents + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthEvents + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthEvents + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + v := &EventPowerDistUpdate_EventSlashedBTCDelegation{} + if err := v.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + m.Ev = &EventPowerDistUpdate_SlashedBtcDelegation{v} + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipEvents(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthEvents + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *EventPowerDistUpdate_EventSlashedFinalityProvider) 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 ErrIntOverflowEvents + } + 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: EventSlashedFinalityProvider: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: EventSlashedFinalityProvider: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Pk", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowEvents + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthEvents + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthEvents + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + var v github_com_babylonlabs_io_babylon_types.BIP340PubKey + m.Pk = &v + if err := m.Pk.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipEvents(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthEvents + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *EventPowerDistUpdate_EventSlashedBTCDelegation) 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 ErrIntOverflowEvents + } + 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: EventSlashedBTCDelegation: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: EventSlashedBTCDelegation: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field StakingTxHash", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowEvents + } + 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 ErrInvalidLengthEvents + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthEvents + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.StakingTxHash = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipEvents(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthEvents + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *EventPowerDistUpdate_EventJailedFinalityProvider) 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 ErrIntOverflowEvents + } + 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: EventJailedFinalityProvider: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: EventJailedFinalityProvider: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Pk", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowEvents + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthEvents + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthEvents + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + var v github_com_babylonlabs_io_babylon_types.BIP340PubKey + m.Pk = &v + if err := m.Pk.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipEvents(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthEvents + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *EventPowerDistUpdate_EventUnjailedFinalityProvider) 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 ErrIntOverflowEvents + } + 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: EventUnjailedFinalityProvider: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: EventUnjailedFinalityProvider: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Pk", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowEvents + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthEvents + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthEvents + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + var v github_com_babylonlabs_io_babylon_types.BIP340PubKey + m.Pk = &v + if err := m.Pk.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipEvents(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthEvents + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *EventFinalityProviderStatusChange) 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 ErrIntOverflowEvents + } + 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: EventFinalityProviderStatusChange: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: EventFinalityProviderStatusChange: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field BtcPk", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowEvents + } + 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 ErrInvalidLengthEvents + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthEvents + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.BtcPk = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field NewState", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowEvents + } + 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 ErrInvalidLengthEvents + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthEvents + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.NewState = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipEvents(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthEvents + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *EventBTCDelegationCreated) 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 ErrIntOverflowEvents + } + 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: EventBTCDelegationCreated: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: EventBTCDelegationCreated: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field StakingTxHex", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowEvents + } + 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 ErrInvalidLengthEvents + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthEvents + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.StakingTxHex = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field StakingOutputIndex", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowEvents + } + 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 ErrInvalidLengthEvents + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthEvents + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.StakingOutputIndex = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ParamsVersion", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowEvents + } + 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 ErrInvalidLengthEvents + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthEvents + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.ParamsVersion = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field FinalityProviderBtcPksHex", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowEvents + } + 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 ErrInvalidLengthEvents + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthEvents + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.FinalityProviderBtcPksHex = append(m.FinalityProviderBtcPksHex, string(dAtA[iNdEx:postIndex])) + iNdEx = postIndex + case 5: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field StakerBtcPkHex", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowEvents + } + 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 ErrInvalidLengthEvents + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthEvents + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.StakerBtcPkHex = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 6: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field StakingTime", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowEvents + } + 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 ErrInvalidLengthEvents + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthEvents + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.StakingTime = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 7: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field UnbondingTime", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowEvents + } + 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 ErrInvalidLengthEvents } - if iNdEx >= l { - return io.ErrUnexpectedEOF + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthEvents } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break + if postIndex > l { + return io.ErrUnexpectedEOF } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: EventNewFinalityProvider: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: EventNewFinalityProvider: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: + m.UnbondingTime = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 8: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Fp", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field UnbondingTx", wireType) } - var msglen int + var stringLen uint64 for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowEvents @@ -1145,27 +4605,55 @@ func (m *EventNewFinalityProvider) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - msglen |= int(b&0x7F) << shift + stringLen |= uint64(b&0x7F) << shift if b < 0x80 { break } } - if msglen < 0 { + intStringLen := int(stringLen) + if intStringLen < 0 { return ErrInvalidLengthEvents } - postIndex := iNdEx + msglen + postIndex := iNdEx + intStringLen if postIndex < 0 { return ErrInvalidLengthEvents } if postIndex > l { return io.ErrUnexpectedEOF } - if m.Fp == nil { - m.Fp = &FinalityProvider{} + m.UnbondingTx = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 9: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field NewState", wireType) } - if err := m.Fp.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowEvents + } + 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 ErrInvalidLengthEvents + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthEvents + } + if postIndex > l { + return io.ErrUnexpectedEOF } + m.NewState = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex default: iNdEx = preIndex @@ -1188,7 +4676,7 @@ func (m *EventNewFinalityProvider) Unmarshal(dAtA []byte) error { } return nil } -func (m *EventBTCDelegationStateUpdate) Unmarshal(dAtA []byte) error { +func (m *EventCovenantSignatureReceived) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -1211,10 +4699,10 @@ func (m *EventBTCDelegationStateUpdate) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: EventBTCDelegationStateUpdate: wiretype end group for non-group") + return fmt.Errorf("proto: EventCovenantSignatureReceived: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: EventBTCDelegationStateUpdate: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: EventCovenantSignatureReceived: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: @@ -1250,10 +4738,10 @@ func (m *EventBTCDelegationStateUpdate) Unmarshal(dAtA []byte) error { m.StakingTxHash = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex case 2: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field NewState", wireType) + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field CovenantBtcPkHex", wireType) } - m.NewState = 0 + var stringLen uint64 for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowEvents @@ -1263,11 +4751,56 @@ func (m *EventBTCDelegationStateUpdate) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - m.NewState |= BTCDelegationStatus(b&0x7F) << shift + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthEvents + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthEvents + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.CovenantBtcPkHex = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field CovenantUnbondingSignatureHex", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowEvents + } + 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 ErrInvalidLengthEvents + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthEvents + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.CovenantUnbondingSignatureHex = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex default: iNdEx = preIndex skippy, err := skipEvents(dAtA[iNdEx:]) @@ -1289,7 +4822,7 @@ func (m *EventBTCDelegationStateUpdate) Unmarshal(dAtA []byte) error { } return nil } -func (m *EventSelectiveSlashing) Unmarshal(dAtA []byte) error { +func (m *EventCovenantQuorumReached) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -1312,17 +4845,17 @@ func (m *EventSelectiveSlashing) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: EventSelectiveSlashing: wiretype end group for non-group") + return fmt.Errorf("proto: EventCovenantQuorumReached: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: EventSelectiveSlashing: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: EventCovenantQuorumReached: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Evidence", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field StakingTxHash", wireType) } - var msglen int + var stringLen uint64 for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowEvents @@ -1332,27 +4865,55 @@ func (m *EventSelectiveSlashing) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - msglen |= int(b&0x7F) << shift + stringLen |= uint64(b&0x7F) << shift if b < 0x80 { break } } - if msglen < 0 { + intStringLen := int(stringLen) + if intStringLen < 0 { return ErrInvalidLengthEvents } - postIndex := iNdEx + msglen + postIndex := iNdEx + intStringLen if postIndex < 0 { return ErrInvalidLengthEvents } if postIndex > l { return io.ErrUnexpectedEOF } - if m.Evidence == nil { - m.Evidence = &SelectiveSlashingEvidence{} + m.StakingTxHash = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field NewState", wireType) } - if err := m.Evidence.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowEvents + } + 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 ErrInvalidLengthEvents + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthEvents + } + if postIndex > l { + return io.ErrUnexpectedEOF } + m.NewState = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex default: iNdEx = preIndex @@ -1375,7 +4936,7 @@ func (m *EventSelectiveSlashing) Unmarshal(dAtA []byte) error { } return nil } -func (m *EventPowerDistUpdate) Unmarshal(dAtA []byte) error { +func (m *EventBTCDelegationInclusionProofReceived) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -1398,17 +4959,17 @@ func (m *EventPowerDistUpdate) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: EventPowerDistUpdate: wiretype end group for non-group") + return fmt.Errorf("proto: EventBTCDelegationInclusionProofReceived: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: EventPowerDistUpdate: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: EventBTCDelegationInclusionProofReceived: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field SlashedFp", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field StakingTxHash", wireType) } - var msglen int + var stringLen uint64 for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowEvents @@ -1418,32 +4979,29 @@ func (m *EventPowerDistUpdate) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - msglen |= int(b&0x7F) << shift + stringLen |= uint64(b&0x7F) << shift if b < 0x80 { break } } - if msglen < 0 { + intStringLen := int(stringLen) + if intStringLen < 0 { return ErrInvalidLengthEvents } - postIndex := iNdEx + msglen + postIndex := iNdEx + intStringLen if postIndex < 0 { return ErrInvalidLengthEvents } if postIndex > l { return io.ErrUnexpectedEOF } - v := &EventPowerDistUpdate_EventSlashedFinalityProvider{} - if err := v.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - m.Ev = &EventPowerDistUpdate_SlashedFp{v} + m.StakingTxHash = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex case 2: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field JailedFp", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field StartHeight", wireType) } - var msglen int + var stringLen uint64 for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowEvents @@ -1453,67 +5011,29 @@ func (m *EventPowerDistUpdate) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - msglen |= int(b&0x7F) << shift + stringLen |= uint64(b&0x7F) << shift if b < 0x80 { break } } - if msglen < 0 { + intStringLen := int(stringLen) + if intStringLen < 0 { return ErrInvalidLengthEvents } - postIndex := iNdEx + msglen + postIndex := iNdEx + intStringLen if postIndex < 0 { return ErrInvalidLengthEvents } if postIndex > l { return io.ErrUnexpectedEOF } - v := &EventPowerDistUpdate_EventJailedFinalityProvider{} - if err := v.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - m.Ev = &EventPowerDistUpdate_JailedFp{v} + m.StartHeight = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex case 3: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field UnjailedFp", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowEvents - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthEvents - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthEvents - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - v := &EventPowerDistUpdate_EventUnjailedFinalityProvider{} - if err := v.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - m.Ev = &EventPowerDistUpdate_UnjailedFp{v} - iNdEx = postIndex - case 4: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field BtcDelStateUpdate", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field EndHeight", wireType) } - var msglen int + var stringLen uint64 for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowEvents @@ -1523,32 +5043,29 @@ func (m *EventPowerDistUpdate) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - msglen |= int(b&0x7F) << shift + stringLen |= uint64(b&0x7F) << shift if b < 0x80 { break } } - if msglen < 0 { + intStringLen := int(stringLen) + if intStringLen < 0 { return ErrInvalidLengthEvents } - postIndex := iNdEx + msglen + postIndex := iNdEx + intStringLen if postIndex < 0 { return ErrInvalidLengthEvents } - if postIndex > l { - return io.ErrUnexpectedEOF - } - v := &EventBTCDelegationStateUpdate{} - if err := v.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - m.Ev = &EventPowerDistUpdate_BtcDelStateUpdate{v} + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.EndHeight = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex - case 5: + case 4: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field SlashedBtcDelegation", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field NewState", wireType) } - var msglen int + var stringLen uint64 for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowEvents @@ -1558,26 +5075,23 @@ func (m *EventPowerDistUpdate) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - msglen |= int(b&0x7F) << shift + stringLen |= uint64(b&0x7F) << shift if b < 0x80 { break } } - if msglen < 0 { + intStringLen := int(stringLen) + if intStringLen < 0 { return ErrInvalidLengthEvents } - postIndex := iNdEx + msglen + postIndex := iNdEx + intStringLen if postIndex < 0 { return ErrInvalidLengthEvents } if postIndex > l { return io.ErrUnexpectedEOF } - v := &EventPowerDistUpdate_EventSlashedBTCDelegation{} - if err := v.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - m.Ev = &EventPowerDistUpdate_SlashedBtcDelegation{v} + m.NewState = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex default: iNdEx = preIndex @@ -1600,7 +5114,7 @@ func (m *EventPowerDistUpdate) Unmarshal(dAtA []byte) error { } return nil } -func (m *EventPowerDistUpdate_EventSlashedFinalityProvider) Unmarshal(dAtA []byte) error { +func (m *EventBTCDelgationUnbondedEarly) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -1623,17 +5137,17 @@ func (m *EventPowerDistUpdate_EventSlashedFinalityProvider) Unmarshal(dAtA []byt fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: EventSlashedFinalityProvider: wiretype end group for non-group") + return fmt.Errorf("proto: EventBTCDelgationUnbondedEarly: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: EventSlashedFinalityProvider: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: EventBTCDelgationUnbondedEarly: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Pk", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field StakingTxHash", wireType) } - var byteLen int + var stringLen uint64 for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowEvents @@ -1643,26 +5157,87 @@ func (m *EventPowerDistUpdate_EventSlashedFinalityProvider) Unmarshal(dAtA []byt } b := dAtA[iNdEx] iNdEx++ - byteLen |= int(b&0x7F) << shift + stringLen |= uint64(b&0x7F) << shift if b < 0x80 { break } } - if byteLen < 0 { + intStringLen := int(stringLen) + if intStringLen < 0 { return ErrInvalidLengthEvents } - postIndex := iNdEx + byteLen + postIndex := iNdEx + intStringLen if postIndex < 0 { return ErrInvalidLengthEvents } if postIndex > l { return io.ErrUnexpectedEOF } - var v github_com_babylonlabs_io_babylon_types.BIP340PubKey - m.Pk = &v - if err := m.Pk.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err + m.StakingTxHash = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field StartHeight", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowEvents + } + 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 ErrInvalidLengthEvents + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthEvents + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.StartHeight = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field NewState", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowEvents + } + 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 ErrInvalidLengthEvents + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthEvents + } + if postIndex > l { + return io.ErrUnexpectedEOF } + m.NewState = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex default: iNdEx = preIndex @@ -1685,7 +5260,7 @@ func (m *EventPowerDistUpdate_EventSlashedFinalityProvider) Unmarshal(dAtA []byt } return nil } -func (m *EventPowerDistUpdate_EventSlashedBTCDelegation) Unmarshal(dAtA []byte) error { +func (m *EventBTCDelegationExpired) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -1708,10 +5283,10 @@ func (m *EventPowerDistUpdate_EventSlashedBTCDelegation) Unmarshal(dAtA []byte) fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: EventSlashedBTCDelegation: wiretype end group for non-group") + return fmt.Errorf("proto: EventBTCDelegationExpired: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: EventSlashedBTCDelegation: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: EventBTCDelegationExpired: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: @@ -1746,6 +5321,38 @@ func (m *EventPowerDistUpdate_EventSlashedBTCDelegation) Unmarshal(dAtA []byte) } m.StakingTxHash = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field NewState", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowEvents + } + 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 ErrInvalidLengthEvents + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthEvents + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.NewState = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex default: iNdEx = preIndex skippy, err := skipEvents(dAtA[iNdEx:]) @@ -1767,7 +5374,7 @@ func (m *EventPowerDistUpdate_EventSlashedBTCDelegation) Unmarshal(dAtA []byte) } return nil } -func (m *EventPowerDistUpdate_EventJailedFinalityProvider) Unmarshal(dAtA []byte) error { +func (m *EventUnexpectedUnbondingTx) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -1790,17 +5397,17 @@ func (m *EventPowerDistUpdate_EventJailedFinalityProvider) Unmarshal(dAtA []byte fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: EventJailedFinalityProvider: wiretype end group for non-group") + return fmt.Errorf("proto: EventUnexpectedUnbondingTx: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: EventJailedFinalityProvider: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: EventUnexpectedUnbondingTx: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Pk", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field StakingTxHash", wireType) } - var byteLen int + var stringLen uint64 for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowEvents @@ -1810,82 +5417,61 @@ func (m *EventPowerDistUpdate_EventJailedFinalityProvider) Unmarshal(dAtA []byte } b := dAtA[iNdEx] iNdEx++ - byteLen |= int(b&0x7F) << shift + stringLen |= uint64(b&0x7F) << shift if b < 0x80 { break } } - if byteLen < 0 { + intStringLen := int(stringLen) + if intStringLen < 0 { return ErrInvalidLengthEvents } - postIndex := iNdEx + byteLen + postIndex := iNdEx + intStringLen if postIndex < 0 { return ErrInvalidLengthEvents } if postIndex > l { return io.ErrUnexpectedEOF } - var v github_com_babylonlabs_io_babylon_types.BIP340PubKey - m.Pk = &v - if err := m.Pk.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } + m.StakingTxHash = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipEvents(dAtA[iNdEx:]) - if err != nil { - return err + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field SpendStakeTxHash", wireType) } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthEvents + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowEvents + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthEvents } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *EventPowerDistUpdate_EventUnjailedFinalityProvider) 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 ErrIntOverflowEvents + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthEvents } - if iNdEx >= l { + if postIndex > 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: EventUnjailedFinalityProvider: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: EventUnjailedFinalityProvider: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: + m.SpendStakeTxHash = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 3: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Pk", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field SpendStakeTxHeaderHash", wireType) } - var byteLen int + var stringLen uint64 for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowEvents @@ -1895,27 +5481,43 @@ func (m *EventPowerDistUpdate_EventUnjailedFinalityProvider) Unmarshal(dAtA []by } b := dAtA[iNdEx] iNdEx++ - byteLen |= int(b&0x7F) << shift + stringLen |= uint64(b&0x7F) << shift if b < 0x80 { break } } - if byteLen < 0 { + intStringLen := int(stringLen) + if intStringLen < 0 { return ErrInvalidLengthEvents } - postIndex := iNdEx + byteLen + postIndex := iNdEx + intStringLen if postIndex < 0 { return ErrInvalidLengthEvents } if postIndex > l { return io.ErrUnexpectedEOF } - var v github_com_babylonlabs_io_babylon_types.BIP340PubKey - m.Pk = &v - if err := m.Pk.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } + m.SpendStakeTxHeaderHash = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex + case 4: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field SpendStakeTxBlockIndex", wireType) + } + m.SpendStakeTxBlockIndex = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowEvents + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.SpendStakeTxBlockIndex |= uint32(b&0x7F) << shift + if b < 0x80 { + break + } + } default: iNdEx = preIndex skippy, err := skipEvents(dAtA[iNdEx:]) diff --git a/x/btcstaking/types/expected_keepers.go b/x/btcstaking/types/expected_keepers.go index 9699cabb3..a49d70a6d 100644 --- a/x/btcstaking/types/expected_keepers.go +++ b/x/btcstaking/types/expected_keepers.go @@ -6,6 +6,7 @@ import ( bbn "github.com/babylonlabs-io/babylon/types" btcctypes "github.com/babylonlabs-io/babylon/x/btccheckpoint/types" btclctypes "github.com/babylonlabs-io/babylon/x/btclightclient/types" + sdk "github.com/cosmos/cosmos-sdk/types" ) type BTCLightClientKeeper interface { @@ -30,6 +31,6 @@ type BTCStkConsumerKeeper interface { SetConsumerFinalityProvider(ctx context.Context, fp *FinalityProvider) } -type BtcStakingHooks interface { - AfterFinalityProviderActivated(ctx context.Context, fpPk *bbn.BIP340PubKey) error +type IncentiveKeeper interface { + IndexRefundableMsg(ctx context.Context, msg sdk.Msg) } diff --git a/x/btcstaking/types/genesis.pb.go b/x/btcstaking/types/genesis.pb.go index 3994319ac..e02787029 100644 --- a/x/btcstaking/types/genesis.pb.go +++ b/x/btcstaking/types/genesis.pb.go @@ -32,17 +32,12 @@ type GenesisState struct { FinalityProviders []*FinalityProvider `protobuf:"bytes,2,rep,name=finality_providers,json=finalityProviders,proto3" json:"finality_providers,omitempty"` // btc_delegations all the btc delegations in the state. BtcDelegations []*BTCDelegation `protobuf:"bytes,3,rep,name=btc_delegations,json=btcDelegations,proto3" json:"btc_delegations,omitempty"` - // voting_powers the voting power of every finality provider at every block height. - VotingPowers []*VotingPowerFP `protobuf:"bytes,4,rep,name=voting_powers,json=votingPowers,proto3" json:"voting_powers,omitempty"` // block_height_chains the block height of babylon and bitcoin. BlockHeightChains []*BlockHeightBbnToBtc `protobuf:"bytes,5,rep,name=block_height_chains,json=blockHeightChains,proto3" json:"block_height_chains,omitempty"` // btc_delegators contains all the btc delegators with the associated finality provider. BtcDelegators []*BTCDelegator `protobuf:"bytes,6,rep,name=btc_delegators,json=btcDelegators,proto3" json:"btc_delegators,omitempty"` // all the events and its indexes. Events []*EventIndex `protobuf:"bytes,7,rep,name=events,proto3" json:"events,omitempty"` - // vp_dst_cache is the table of all providers voting power with the total at one specific block. - // TODO: remove this after not storing in the keeper store it anymore. - VpDstCache []*VotingPowerDistCacheBlkHeight `protobuf:"bytes,8,rep,name=vp_dst_cache,json=vpDstCache,proto3" json:"vp_dst_cache,omitempty"` } func (m *GenesisState) Reset() { *m = GenesisState{} } @@ -99,13 +94,6 @@ func (m *GenesisState) GetBtcDelegations() []*BTCDelegation { return nil } -func (m *GenesisState) GetVotingPowers() []*VotingPowerFP { - if m != nil { - return m.VotingPowers - } - return nil -} - func (m *GenesisState) GetBlockHeightChains() []*BlockHeightBbnToBtc { if m != nil { return m.BlockHeightChains @@ -127,139 +115,19 @@ func (m *GenesisState) GetEvents() []*EventIndex { return nil } -func (m *GenesisState) GetVpDstCache() []*VotingPowerDistCacheBlkHeight { - if m != nil { - return m.VpDstCache - } - return nil -} - -// VotingPowerFP contains the information about the voting power -// of an finality provider in a specific block height. -type VotingPowerFP struct { - // block_height is the height of the block the voting power was stored. - BlockHeight uint64 `protobuf:"varint,1,opt,name=block_height,json=blockHeight,proto3" json:"block_height,omitempty"` - // fp_btc_pk the finality provider btc public key. - FpBtcPk *github_com_babylonlabs_io_babylon_types.BIP340PubKey `protobuf:"bytes,2,opt,name=fp_btc_pk,json=fpBtcPk,proto3,customtype=github.com/babylonlabs-io/babylon/types.BIP340PubKey" json:"fp_btc_pk,omitempty"` - // voting_power is the power of the finality provider at this specific block height. - VotingPower uint64 `protobuf:"varint,3,opt,name=voting_power,json=votingPower,proto3" json:"voting_power,omitempty"` -} - -func (m *VotingPowerFP) Reset() { *m = VotingPowerFP{} } -func (m *VotingPowerFP) String() string { return proto.CompactTextString(m) } -func (*VotingPowerFP) ProtoMessage() {} -func (*VotingPowerFP) Descriptor() ([]byte, []int) { - return fileDescriptor_85d7b95fa5620238, []int{1} -} -func (m *VotingPowerFP) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *VotingPowerFP) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_VotingPowerFP.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 *VotingPowerFP) XXX_Merge(src proto.Message) { - xxx_messageInfo_VotingPowerFP.Merge(m, src) -} -func (m *VotingPowerFP) XXX_Size() int { - return m.Size() -} -func (m *VotingPowerFP) XXX_DiscardUnknown() { - xxx_messageInfo_VotingPowerFP.DiscardUnknown(m) -} - -var xxx_messageInfo_VotingPowerFP proto.InternalMessageInfo - -func (m *VotingPowerFP) GetBlockHeight() uint64 { - if m != nil { - return m.BlockHeight - } - return 0 -} - -func (m *VotingPowerFP) GetVotingPower() uint64 { - if m != nil { - return m.VotingPower - } - return 0 -} - -// VotingPowerDistCacheBlkHeight the total voting power of the finality providers at one specific block height -type VotingPowerDistCacheBlkHeight struct { - // block_height is the height of the block the voting power distribution cached was stored. - BlockHeight uint64 `protobuf:"varint,1,opt,name=block_height,json=blockHeight,proto3" json:"block_height,omitempty"` - // vp_distribution the finality providers distribution cache at that height. - VpDistribution *VotingPowerDistCache `protobuf:"bytes,2,opt,name=vp_distribution,json=vpDistribution,proto3" json:"vp_distribution,omitempty"` -} - -func (m *VotingPowerDistCacheBlkHeight) Reset() { *m = VotingPowerDistCacheBlkHeight{} } -func (m *VotingPowerDistCacheBlkHeight) String() string { return proto.CompactTextString(m) } -func (*VotingPowerDistCacheBlkHeight) ProtoMessage() {} -func (*VotingPowerDistCacheBlkHeight) Descriptor() ([]byte, []int) { - return fileDescriptor_85d7b95fa5620238, []int{2} -} -func (m *VotingPowerDistCacheBlkHeight) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *VotingPowerDistCacheBlkHeight) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_VotingPowerDistCacheBlkHeight.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 *VotingPowerDistCacheBlkHeight) XXX_Merge(src proto.Message) { - xxx_messageInfo_VotingPowerDistCacheBlkHeight.Merge(m, src) -} -func (m *VotingPowerDistCacheBlkHeight) XXX_Size() int { - return m.Size() -} -func (m *VotingPowerDistCacheBlkHeight) XXX_DiscardUnknown() { - xxx_messageInfo_VotingPowerDistCacheBlkHeight.DiscardUnknown(m) -} - -var xxx_messageInfo_VotingPowerDistCacheBlkHeight proto.InternalMessageInfo - -func (m *VotingPowerDistCacheBlkHeight) GetBlockHeight() uint64 { - if m != nil { - return m.BlockHeight - } - return 0 -} - -func (m *VotingPowerDistCacheBlkHeight) GetVpDistribution() *VotingPowerDistCache { - if m != nil { - return m.VpDistribution - } - return nil -} - // BlockHeightBbnToBtc stores the btc <-> bbn block. type BlockHeightBbnToBtc struct { // block_height_bbn is the height of the block in the babylon chain. BlockHeightBbn uint64 `protobuf:"varint,1,opt,name=block_height_bbn,json=blockHeightBbn,proto3" json:"block_height_bbn,omitempty"` // block_height_btc is the height of the block in the BTC. - BlockHeightBtc uint64 `protobuf:"varint,2,opt,name=block_height_btc,json=blockHeightBtc,proto3" json:"block_height_btc,omitempty"` + BlockHeightBtc uint32 `protobuf:"varint,2,opt,name=block_height_btc,json=blockHeightBtc,proto3" json:"block_height_btc,omitempty"` } func (m *BlockHeightBbnToBtc) Reset() { *m = BlockHeightBbnToBtc{} } func (m *BlockHeightBbnToBtc) String() string { return proto.CompactTextString(m) } func (*BlockHeightBbnToBtc) ProtoMessage() {} func (*BlockHeightBbnToBtc) Descriptor() ([]byte, []int) { - return fileDescriptor_85d7b95fa5620238, []int{3} + return fileDescriptor_85d7b95fa5620238, []int{1} } func (m *BlockHeightBbnToBtc) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -295,7 +163,7 @@ func (m *BlockHeightBbnToBtc) GetBlockHeightBbn() uint64 { return 0 } -func (m *BlockHeightBbnToBtc) GetBlockHeightBtc() uint64 { +func (m *BlockHeightBbnToBtc) GetBlockHeightBtc() uint32 { if m != nil { return m.BlockHeightBtc } @@ -316,7 +184,7 @@ func (m *BTCDelegator) Reset() { *m = BTCDelegator{} } func (m *BTCDelegator) String() string { return proto.CompactTextString(m) } func (*BTCDelegator) ProtoMessage() {} func (*BTCDelegator) Descriptor() ([]byte, []int) { - return fileDescriptor_85d7b95fa5620238, []int{4} + return fileDescriptor_85d7b95fa5620238, []int{2} } func (m *BTCDelegator) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -357,7 +225,7 @@ type EventIndex struct { // idx is the index the event was stored. Idx uint64 `protobuf:"varint,1,opt,name=idx,proto3" json:"idx,omitempty"` // block_height_btc is the height of the block in the BTC chain. - BlockHeightBtc uint64 `protobuf:"varint,2,opt,name=block_height_btc,json=blockHeightBtc,proto3" json:"block_height_btc,omitempty"` + BlockHeightBtc uint32 `protobuf:"varint,2,opt,name=block_height_btc,json=blockHeightBtc,proto3" json:"block_height_btc,omitempty"` // event the event stored. Event *EventPowerDistUpdate `protobuf:"bytes,3,opt,name=event,proto3" json:"event,omitempty"` } @@ -366,7 +234,7 @@ func (m *EventIndex) Reset() { *m = EventIndex{} } func (m *EventIndex) String() string { return proto.CompactTextString(m) } func (*EventIndex) ProtoMessage() {} func (*EventIndex) Descriptor() ([]byte, []int) { - return fileDescriptor_85d7b95fa5620238, []int{5} + return fileDescriptor_85d7b95fa5620238, []int{3} } func (m *EventIndex) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -402,7 +270,7 @@ func (m *EventIndex) GetIdx() uint64 { return 0 } -func (m *EventIndex) GetBlockHeightBtc() uint64 { +func (m *EventIndex) GetBlockHeightBtc() uint32 { if m != nil { return m.BlockHeightBtc } @@ -418,8 +286,6 @@ func (m *EventIndex) GetEvent() *EventPowerDistUpdate { func init() { proto.RegisterType((*GenesisState)(nil), "babylon.btcstaking.v1.GenesisState") - proto.RegisterType((*VotingPowerFP)(nil), "babylon.btcstaking.v1.VotingPowerFP") - proto.RegisterType((*VotingPowerDistCacheBlkHeight)(nil), "babylon.btcstaking.v1.VotingPowerDistCacheBlkHeight") proto.RegisterType((*BlockHeightBbnToBtc)(nil), "babylon.btcstaking.v1.BlockHeightBbnToBtc") proto.RegisterType((*BTCDelegator)(nil), "babylon.btcstaking.v1.BTCDelegator") proto.RegisterType((*EventIndex)(nil), "babylon.btcstaking.v1.EventIndex") @@ -430,51 +296,42 @@ func init() { } var fileDescriptor_85d7b95fa5620238 = []byte{ - // 694 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xb4, 0x95, 0x4f, 0x4f, 0xd4, 0x40, - 0x18, 0xc6, 0x29, 0xbb, 0x2c, 0x38, 0xbb, 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d, 0x00, 0xbb, - 0x84, 0xda, 0x3e, 0x11, 0x03, 0x2b, 0x08, 0x59, 0x44, 0x5c, 0x1c, 0x72, 0x75, 0x52, 0x22, 0xee, - 0x8e, 0x40, 0x6c, 0xa7, 0x05, 0x46, 0xaa, 0x37, 0x17, 0xba, 0x17, 0x76, 0x38, 0x7c, 0x0d, 0xe6, - 0x90, 0x70, 0x2c, 0x17, 0xfb, 0xd8, 0xb3, 0x05, 0x61, 0x94, 0xab, 0x05, 0x09, 0xbd, 0x35, 0x02, - 0xaa, 0xef, 0x6e, 0xb5, 0xcf, 0xc4, 0x66, 0x15, 0x09, 0x27, 0x5b, 0x72, 0xb8, 0x03, 0x66, 0x23, - 0x26, 0x08, 0xf5, 0xac, 0x80, 0xbd, 0x8f, 0x3b, 0x2c, 0x5e, 0x0a, 0xeb, 0x48, 0xad, 0x11, 0x4b, - 0xb7, 0x0d, 0xb3, 0x12, 0x65, 0x4b, 0x0e, 0xf7, 0xc0, 0x22, 0xf2, 0x99, 0xd3, 0xb7, 0x7a, 0x98, - 0x78, 0x3d, 0x61, 0x39, 0x3d, 0x9b, 0x50, 0xae, 0x4e, 0x49, 0xe0, 0xbd, 0x51, 0xdd, 0xc5, 0x15, - 0x2f, 0x64, 0x81, 0x8e, 0xe8, 0x2e, 0xd3, 0x85, 0x63, 0x2e, 0xa0, 0x6c, 0x73, 0x4b, 0x42, 0xe0, - 0x4b, 0x50, 0xcd, 0xb9, 0x66, 0x21, 0x57, 0x4b, 0x12, 0xbb, 0x76, 0xa5, 0x69, 0x16, 0x9a, 0xb3, - 0x99, 0x67, 0x16, 0x72, 0xf8, 0x04, 0x94, 0x92, 0x1b, 0x57, 0xa7, 0x25, 0x63, 0x75, 0x04, 0xe3, - 0x59, 0x2c, 0xda, 0xa1, 0x2e, 0x3e, 0x34, 0xd3, 0x02, 0xd8, 0x01, 0x95, 0x28, 0xb0, 0x5c, 0x2e, - 0x2c, 0xc7, 0x76, 0x7a, 0x58, 0x9d, 0x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0xa1, 0xe4, - 0x96, 0x5b, 0xad, 0x31, 0x82, 0x99, 0xbd, 0xc3, 0x24, 0x65, 0x71, 0xf9, 0x7f, 0xba, 0xd5, 0x0e, - 0x00, 0x2e, 0xf6, 0x4f, 0xb1, 0x85, 0x7f, 0xc4, 0xce, 0xb8, 0xd8, 0x97, 0xdc, 0xfa, 0x47, 0x05, - 0x80, 0xec, 0x9d, 0xc0, 0xf9, 0x6c, 0x04, 0xc5, 0xc4, 0xce, 0xd8, 0xf3, 0x84, 0x4f, 0xc1, 0x94, - 0x7c, 0x65, 0xb2, 0xbb, 0xd1, 0x31, 0x90, 0xa7, 0x9d, 0xa5, 0xe0, 0x5d, 0xe0, 0xda, 0x02, 0x9b, - 0x49, 0xa5, 0xfe, 0xe6, 0xeb, 0x71, 0x4d, 0x39, 0x3a, 0xae, 0x29, 0x3f, 0x8f, 0x6b, 0xca, 0xa7, - 0x93, 0xda, 0xc4, 0xd1, 0x49, 0x6d, 0xe2, 0xdb, 0x49, 0x6d, 0x62, 0x6f, 0x0c, 0x9f, 0x87, 0xf9, - 0xbf, 0x82, 0x34, 0x8d, 0x4a, 0xf2, 0x97, 0xb0, 0xf1, 0x3b, 0x00, 0x00, 0xff, 0xff, 0x9a, 0xc8, - 0x8f, 0x84, 0xfd, 0x06, 0x00, 0x00, + // 556 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xa4, 0x94, 0x4f, 0x6f, 0xd3, 0x3c, + 0x1c, 0xc7, 0x9b, 0x76, 0xeb, 0x9e, 0xc7, 0xed, 0xca, 0xe6, 0x81, 0x14, 0x55, 0x22, 0x94, 0x0e, + 0x41, 0x05, 0x22, 0x61, 0xdd, 0x90, 0xe0, 0x48, 0x56, 0xfe, 0x0c, 0x04, 0x8a, 0x42, 0xd9, 0x61, + 0x97, 0x2a, 0x76, 0xdc, 0xd4, 0x6a, 0x66, 0x47, 0xb1, 0x57, 0x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0xad, 0x5f, 0xb0, 0x5b, 0x41, 0x12, 0x67, 0xaf, 0x02, 0x9e, 0x80, 0x1d, 0x14, 0x72, + 0xdc, 0xef, 0xf4, 0x08, 0x0d, 0x7a, 0xb2, 0x83, 0x7b, 0x1e, 0x65, 0x42, 0x5f, 0x57, 0xca, 0xbb, + 0xcb, 0x94, 0xd3, 0x89, 0x17, 0x6a, 0xc0, 0x46, 0xac, 0xcd, 0x6d, 0x89, 0xdd, 0x6d, 0x94, 0x7d, + 0x3c, 0x54, 0x12, 0xf8, 0x12, 0x54, 0x66, 0xa2, 0xf2, 0x58, 0xe8, 0x45, 0xa5, 0xdd, 0xfd, 0x6b, + 0x52, 0x1e, 0xbb, 0x9b, 0x59, 0x50, 0x1e, 0x0b, 0xf8, 0x18, 0x14, 0x93, 0x35, 0xe9, 0x1b, 0xca, + 0x71, 0x73, 0x89, 0xe3, 0xe9, 0x14, 0x3a, 0x62, 0x3e, 0x19, 0xba, 0xe9, 0x40, 0x9d, 0x82, 0x9d, + 0x05, 0x81, 0x61, 0x03, 0x6c, 0xcd, 0x35, 0x47, 0x88, 0xe9, 0x5a, 0x4d, 0x6b, 0xac, 0xb9, 0x15, + 0x34, 0x87, 0xff, 0x49, 0x4a, 0xac, 0xe7, 0x6b, 0x5a, 0x63, 0x73, 0x9e, 0x94, 0xb8, 0xfe, 0x21, + 0x0f, 0xca, 0xb3, 0x2d, 0x60, 0x0b, 0x14, 0xa8, 0x3f, 0x54, 0xde, 0x52, 0xb3, 0xb9, 0x42, 0xef, + 0x6c, 0x37, 0x49, 0x89, 0xe9, 0x38, 0x6c, 0x83, 0xff, 0xbb, 0xd1, 0xf4, 0xd8, 0x4e, 0xd4, 0x57, + 0x27, 0x97, 0xed, 0x47, 0xdf, 0xbe, 0xdf, 0x38, 0x08, 0xa8, 0xec, 0x9d, 0x21, 0x13, 0xf3, 0x53, + 0x2b, 0x35, 0x87, 0x1e, 0x12, 0xf7, 0x29, 0xbf, 0x78, 0xb5, 0xe4, 0x28, 0x22, 0xc2, 0xb4, 0x8f, + 0x9c, 0xfd, 0x83, 0x07, 0xce, 0x19, 0x7a, 0x45, 0x46, 0xee, 0x46, 0x37, 0xb2, 0x25, 0x76, 0xfa, + 0xf0, 0x18, 0x00, 0x9f, 0x84, 0x17, 0xda, 0xc2, 0x3f, 0x6a, 0xff, 0xf3, 0x49, 0xa8, 0xbc, 0xf5, + 0x8f, 0x1a, 0x00, 0xd9, 0x1a, 0xe0, 0x56, 0xf6, 0x0b, 0xd6, 0x92, 0x3a, 0x2b, 0xff, 0x4f, 0xf8, + 0x04, 0xac, 0xab, 0x25, 0xaa, 0x74, 0xa5, 0xe6, 0xbd, 0xcb, 0x96, 0xee, 0xf0, 0xf7, 0x24, 0x6e, + 0x51, 0x21, 0xdf, 0x45, 0xbe, 0x27, 0x89, 0x9b, 0x4c, 0xda, 0x6f, 0x3e, 0x8f, 0x0d, 0xed, 0x7c, + 0x6c, 0x68, 0x3f, 0xc6, 0x86, 0xf6, 0x69, 0x62, 0xe4, 0xce, 0x27, 0x46, 0xee, 0xeb, 0xc4, 0xc8, + 0x9d, 0xac, 0xd0, 0x73, 0x38, 0x7b, 0x53, 0xa8, 0xd2, 0xa8, 0xa8, 0xae, 0x89, 0xfd, 0x9f, 0x01, + 0x00, 0x00, 0xff, 0xff, 0x54, 0x96, 0xa0, 0xb9, 0xea, 0x04, 0x00, 0x00, } func (m *GenesisState) Marshal() (dAtA []byte, err error) { @@ -497,20 +354,6 @@ func (m *GenesisState) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l - if len(m.VpDstCache) > 0 { - for iNdEx := len(m.VpDstCache) - 1; iNdEx >= 0; iNdEx-- { - { - size, err := m.VpDstCache[iNdEx].MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintGenesis(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x42 - } - } if len(m.Events) > 0 { for iNdEx := len(m.Events) - 1; iNdEx >= 0; iNdEx-- { { @@ -553,20 +396,6 @@ func (m *GenesisState) MarshalToSizedBuffer(dAtA []byte) (int, error) { dAtA[i] = 0x2a } } - if len(m.VotingPowers) > 0 { - for iNdEx := len(m.VotingPowers) - 1; iNdEx >= 0; iNdEx-- { - { - size, err := m.VotingPowers[iNdEx].MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintGenesis(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x22 - } - } if len(m.BtcDelegations) > 0 { for iNdEx := len(m.BtcDelegations) - 1; iNdEx >= 0; iNdEx-- { { @@ -612,91 +441,6 @@ func (m *GenesisState) MarshalToSizedBuffer(dAtA []byte) (int, error) { return len(dAtA) - i, nil } -func (m *VotingPowerFP) 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 *VotingPowerFP) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *VotingPowerFP) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if m.VotingPower != 0 { - i = encodeVarintGenesis(dAtA, i, uint64(m.VotingPower)) - i-- - dAtA[i] = 0x18 - } - if m.FpBtcPk != nil { - { - size := m.FpBtcPk.Size() - i -= size - if _, err := m.FpBtcPk.MarshalTo(dAtA[i:]); err != nil { - return 0, err - } - i = encodeVarintGenesis(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x12 - } - if m.BlockHeight != 0 { - i = encodeVarintGenesis(dAtA, i, uint64(m.BlockHeight)) - i-- - dAtA[i] = 0x8 - } - return len(dAtA) - i, nil -} - -func (m *VotingPowerDistCacheBlkHeight) 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 *VotingPowerDistCacheBlkHeight) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *VotingPowerDistCacheBlkHeight) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if m.VpDistribution != nil { - { - size, err := m.VpDistribution.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintGenesis(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x12 - } - if m.BlockHeight != 0 { - i = encodeVarintGenesis(dAtA, i, uint64(m.BlockHeight)) - i-- - dAtA[i] = 0x8 - } - return len(dAtA) - i, nil -} - func (m *BlockHeightBbnToBtc) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) @@ -869,12 +613,6 @@ func (m *GenesisState) Size() (n int) { n += 1 + l + sovGenesis(uint64(l)) } } - if len(m.VotingPowers) > 0 { - for _, e := range m.VotingPowers { - l = e.Size() - n += 1 + l + sovGenesis(uint64(l)) - } - } if len(m.BlockHeightChains) > 0 { for _, e := range m.BlockHeightChains { l = e.Size() @@ -893,47 +631,6 @@ func (m *GenesisState) Size() (n int) { n += 1 + l + sovGenesis(uint64(l)) } } - if len(m.VpDstCache) > 0 { - for _, e := range m.VpDstCache { - l = e.Size() - n += 1 + l + sovGenesis(uint64(l)) - } - } - return n -} - -func (m *VotingPowerFP) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if m.BlockHeight != 0 { - n += 1 + sovGenesis(uint64(m.BlockHeight)) - } - if m.FpBtcPk != nil { - l = m.FpBtcPk.Size() - n += 1 + l + sovGenesis(uint64(l)) - } - if m.VotingPower != 0 { - n += 1 + sovGenesis(uint64(m.VotingPower)) - } - return n -} - -func (m *VotingPowerDistCacheBlkHeight) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if m.BlockHeight != 0 { - n += 1 + sovGenesis(uint64(m.BlockHeight)) - } - if m.VpDistribution != nil { - l = m.VpDistribution.Size() - n += 1 + l + sovGenesis(uint64(l)) - } return n } @@ -1129,40 +826,6 @@ func (m *GenesisState) Unmarshal(dAtA []byte) error { return err } iNdEx = postIndex - case 4: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field VotingPowers", 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.VotingPowers = append(m.VotingPowers, &VotingPowerFP{}) - if err := m.VotingPowers[len(m.VotingPowers)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex case 5: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field BlockHeightChains", wireType) @@ -1265,268 +928,6 @@ func (m *GenesisState) Unmarshal(dAtA []byte) error { return err } iNdEx = postIndex - case 8: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field VpDstCache", 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.VpDstCache = append(m.VpDstCache, &VotingPowerDistCacheBlkHeight{}) - if err := m.VpDstCache[len(m.VpDstCache)-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 *VotingPowerFP) 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: VotingPowerFP: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: VotingPowerFP: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field BlockHeight", wireType) - } - m.BlockHeight = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowGenesis - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.BlockHeight |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field FpBtcPk", wireType) - } - var byteLen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowGenesis - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - byteLen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if byteLen < 0 { - return ErrInvalidLengthGenesis - } - postIndex := iNdEx + byteLen - if postIndex < 0 { - return ErrInvalidLengthGenesis - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - var v github_com_babylonlabs_io_babylon_types.BIP340PubKey - m.FpBtcPk = &v - if err := m.FpBtcPk.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 3: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field VotingPower", wireType) - } - m.VotingPower = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowGenesis - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.VotingPower |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - 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 *VotingPowerDistCacheBlkHeight) 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: VotingPowerDistCacheBlkHeight: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: VotingPowerDistCacheBlkHeight: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field BlockHeight", wireType) - } - m.BlockHeight = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowGenesis - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.BlockHeight |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field VpDistribution", 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.VpDistribution == nil { - m.VpDistribution = &VotingPowerDistCache{} - } - if err := m.VpDistribution.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex default: iNdEx = preIndex skippy, err := skipGenesis(dAtA[iNdEx:]) @@ -1610,7 +1011,7 @@ func (m *BlockHeightBbnToBtc) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - m.BlockHeightBtc |= uint64(b&0x7F) << shift + m.BlockHeightBtc |= uint32(b&0x7F) << shift if b < 0x80 { break } @@ -1854,7 +1255,7 @@ func (m *EventIndex) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - m.BlockHeightBtc |= uint64(b&0x7F) << shift + m.BlockHeightBtc |= uint32(b&0x7F) << shift if b < 0x80 { break } diff --git a/x/btcstaking/types/genesis_test.go b/x/btcstaking/types/genesis_test.go index 2d1f4759a..3a2ce6cc9 100644 --- a/x/btcstaking/types/genesis_test.go +++ b/x/btcstaking/types/genesis_test.go @@ -28,18 +28,17 @@ func TestGenesisState_Validate(t *testing.T) { return &types.GenesisState{ Params: []*types.Params{ &types.Params{ - CovenantPks: types.DefaultParams().CovenantPks, - CovenantQuorum: types.DefaultParams().CovenantQuorum, - MinStakingValueSat: 1000, - MaxStakingValueSat: 100000000, - MinStakingTimeBlocks: 100, - MaxStakingTimeBlocks: 1000, - SlashingPkScript: types.DefaultParams().SlashingPkScript, - MinSlashingTxFeeSat: 500, - MinCommissionRate: sdkmath.LegacyMustNewDecFromStr("0.5"), - SlashingRate: sdkmath.LegacyMustNewDecFromStr("0.1"), - MaxActiveFinalityProviders: 100, - UnbondingFeeSat: types.DefaultParams().UnbondingFeeSat, + CovenantPks: types.DefaultParams().CovenantPks, + CovenantQuorum: types.DefaultParams().CovenantQuorum, + MinStakingValueSat: 1000, + MaxStakingValueSat: 100000000, + MinStakingTimeBlocks: 100, + MaxStakingTimeBlocks: 1000, + SlashingPkScript: types.DefaultParams().SlashingPkScript, + MinSlashingTxFeeSat: 500, + MinCommissionRate: sdkmath.LegacyMustNewDecFromStr("0.5"), + SlashingRate: sdkmath.LegacyMustNewDecFromStr("0.1"), + UnbondingFeeSat: types.DefaultParams().UnbondingFeeSat, }, }, } @@ -52,14 +51,13 @@ func TestGenesisState_Validate(t *testing.T) { return &types.GenesisState{ Params: []*types.Params{ &types.Params{ - CovenantPks: types.DefaultParams().CovenantPks, - CovenantQuorum: types.DefaultParams().CovenantQuorum, - SlashingPkScript: types.DefaultParams().SlashingPkScript, - MinSlashingTxFeeSat: 500, - MinCommissionRate: sdkmath.LegacyMustNewDecFromStr("0.5"), - SlashingRate: sdkmath.LegacyZeroDec(), // invalid slashing rate - MaxActiveFinalityProviders: 100, - UnbondingFeeSat: types.DefaultParams().UnbondingFeeSat, + CovenantPks: types.DefaultParams().CovenantPks, + CovenantQuorum: types.DefaultParams().CovenantQuorum, + SlashingPkScript: types.DefaultParams().SlashingPkScript, + MinSlashingTxFeeSat: 500, + MinCommissionRate: sdkmath.LegacyMustNewDecFromStr("0.5"), + SlashingRate: sdkmath.LegacyZeroDec(), // invalid slashing rate + UnbondingFeeSat: types.DefaultParams().UnbondingFeeSat, }, }, } diff --git a/x/btcstaking/types/hooks.go b/x/btcstaking/types/hooks.go deleted file mode 100644 index 89307fe1e..000000000 --- a/x/btcstaking/types/hooks.go +++ /dev/null @@ -1,26 +0,0 @@ -package types - -import ( - "context" - - "github.com/babylonlabs-io/babylon/types" -) - -// combine multiple BTC staking hooks, all hook functions are run in array sequence -var _ BtcStakingHooks = &MultiBtcStakingHooks{} - -type MultiBtcStakingHooks []BtcStakingHooks - -func NewMultiBtcStakingHooks(hooks ...BtcStakingHooks) MultiBtcStakingHooks { - return hooks -} - -func (h MultiBtcStakingHooks) AfterFinalityProviderActivated(ctx context.Context, btcPk *types.BIP340PubKey) error { - for i := range h { - if err := h[i].AfterFinalityProviderActivated(ctx, btcPk); err != nil { - return err - } - } - - return nil -} diff --git a/x/btcstaking/types/incentive.pb.go b/x/btcstaking/types/incentive.pb.go deleted file mode 100644 index b1884734e..000000000 --- a/x/btcstaking/types/incentive.pb.go +++ /dev/null @@ -1,1193 +0,0 @@ -// Code generated by protoc-gen-gogo. DO NOT EDIT. -// source: babylon/btcstaking/v1/incentive.proto - -package types - -import ( - cosmossdk_io_math "cosmossdk.io/math" - fmt "fmt" - github_com_babylonlabs_io_babylon_types "github.com/babylonlabs-io/babylon/types" - _ "github.com/cosmos/cosmos-proto" - _ "github.com/cosmos/gogoproto/gogoproto" - proto "github.com/cosmos/gogoproto/proto" - io "io" - math "math" - math_bits "math/bits" -) - -// Reference imports to suppress errors if they are not otherwise used. -var _ = proto.Marshal -var _ = fmt.Errorf -var _ = math.Inf - -// This is a compile-time assertion to ensure that this generated file -// is compatible with the proto package it is being compiled against. -// A compilation error at this line likely means your copy of the -// proto package needs to be updated. -const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package - -// VotingPowerDistCache is the cache for voting power distribution of finality providers -// and their BTC delegations at a height -type VotingPowerDistCache struct { - // total_voting_power is the total voting power of all the finality providers - // in the cache - TotalVotingPower uint64 `protobuf:"varint,1,opt,name=total_voting_power,json=totalVotingPower,proto3" json:"total_voting_power,omitempty"` - // finality_providers is a list of finality providers' voting power information - FinalityProviders []*FinalityProviderDistInfo `protobuf:"bytes,2,rep,name=finality_providers,json=finalityProviders,proto3" json:"finality_providers,omitempty"` - // num_active_fps is the number of finality providers that have active BTC - // delegations as well as timestamped public randomness - NumActiveFps uint32 `protobuf:"varint,3,opt,name=num_active_fps,json=numActiveFps,proto3" json:"num_active_fps,omitempty"` -} - -func (m *VotingPowerDistCache) Reset() { *m = VotingPowerDistCache{} } -func (m *VotingPowerDistCache) String() string { return proto.CompactTextString(m) } -func (*VotingPowerDistCache) ProtoMessage() {} -func (*VotingPowerDistCache) Descriptor() ([]byte, []int) { - return fileDescriptor_ac354c3bd6d7a66b, []int{0} -} -func (m *VotingPowerDistCache) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *VotingPowerDistCache) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_VotingPowerDistCache.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 *VotingPowerDistCache) XXX_Merge(src proto.Message) { - xxx_messageInfo_VotingPowerDistCache.Merge(m, src) -} -func (m *VotingPowerDistCache) XXX_Size() int { - return m.Size() -} -func (m *VotingPowerDistCache) XXX_DiscardUnknown() { - xxx_messageInfo_VotingPowerDistCache.DiscardUnknown(m) -} - -var xxx_messageInfo_VotingPowerDistCache proto.InternalMessageInfo - -// FinalityProviderDistInfo is the reward distribution of a finality provider and its BTC delegations -type FinalityProviderDistInfo struct { - // btc_pk is the Bitcoin secp256k1 PK of this finality provider - // the PK follows encoding in BIP-340 spec - BtcPk *github_com_babylonlabs_io_babylon_types.BIP340PubKey `protobuf:"bytes,1,opt,name=btc_pk,json=btcPk,proto3,customtype=github.com/babylonlabs-io/babylon/types.BIP340PubKey" json:"btc_pk,omitempty"` - // addr is the address to receive commission from delegations. - Addr string `protobuf:"bytes,2,opt,name=addr,proto3" json:"addr,omitempty"` - // commission defines the commission rate of finality provider - Commission *cosmossdk_io_math.LegacyDec `protobuf:"bytes,3,opt,name=commission,proto3,customtype=cosmossdk.io/math.LegacyDec" json:"commission,omitempty"` - // total_voting_power is the total voting power of the finality provider - TotalVotingPower uint64 `protobuf:"varint,4,opt,name=total_voting_power,json=totalVotingPower,proto3" json:"total_voting_power,omitempty"` - // btc_dels is a list of BTC delegations' voting power information under this finality provider - BtcDels []*BTCDelDistInfo `protobuf:"bytes,5,rep,name=btc_dels,json=btcDels,proto3" json:"btc_dels,omitempty"` - // is_timestamped indicates whether the finality provider - // has timestamped public randomness committed - IsTimestamped bool `protobuf:"varint,6,opt,name=is_timestamped,json=isTimestamped,proto3" json:"is_timestamped,omitempty"` - // is_jailed indicates whether the finality provider - // is jailed, if so, it should not be assigned voting power - IsJailed bool `protobuf:"varint,7,opt,name=is_jailed,json=isJailed,proto3" json:"is_jailed,omitempty"` -} - -func (m *FinalityProviderDistInfo) Reset() { *m = FinalityProviderDistInfo{} } -func (m *FinalityProviderDistInfo) String() string { return proto.CompactTextString(m) } -func (*FinalityProviderDistInfo) ProtoMessage() {} -func (*FinalityProviderDistInfo) Descriptor() ([]byte, []int) { - return fileDescriptor_ac354c3bd6d7a66b, []int{1} -} -func (m *FinalityProviderDistInfo) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *FinalityProviderDistInfo) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_FinalityProviderDistInfo.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 *FinalityProviderDistInfo) XXX_Merge(src proto.Message) { - xxx_messageInfo_FinalityProviderDistInfo.Merge(m, src) -} -func (m *FinalityProviderDistInfo) XXX_Size() int { - return m.Size() -} -func (m *FinalityProviderDistInfo) XXX_DiscardUnknown() { - xxx_messageInfo_FinalityProviderDistInfo.DiscardUnknown(m) -} - -var xxx_messageInfo_FinalityProviderDistInfo proto.InternalMessageInfo - -func (m *FinalityProviderDistInfo) GetAddr() string { - if m != nil { - return m.Addr - } - return "" -} - -func (m *FinalityProviderDistInfo) GetTotalVotingPower() uint64 { - if m != nil { - return m.TotalVotingPower - } - return 0 -} - -func (m *FinalityProviderDistInfo) GetBtcDels() []*BTCDelDistInfo { - if m != nil { - return m.BtcDels - } - return nil -} - -func (m *FinalityProviderDistInfo) GetIsTimestamped() bool { - if m != nil { - return m.IsTimestamped - } - return false -} - -func (m *FinalityProviderDistInfo) GetIsJailed() bool { - if m != nil { - return m.IsJailed - } - return false -} - -// BTCDelDistInfo contains the information related to reward distribution for a BTC delegation -type BTCDelDistInfo struct { - // btc_pk is the Bitcoin secp256k1 PK of this BTC delegation - // the PK follows encoding in BIP-340 spec - BtcPk *github_com_babylonlabs_io_babylon_types.BIP340PubKey `protobuf:"bytes,1,opt,name=btc_pk,json=btcPk,proto3,customtype=github.com/babylonlabs-io/babylon/types.BIP340PubKey" json:"btc_pk,omitempty"` - // staker_addr is the address to receive rewards from BTC delegation. - StakerAddr string `protobuf:"bytes,2,opt,name=staker_addr,json=stakerAddr,proto3" json:"staker_addr,omitempty"` - // staking_tx_hash is the staking tx hash of the BTC delegation - StakingTxHash string `protobuf:"bytes,3,opt,name=staking_tx_hash,json=stakingTxHash,proto3" json:"staking_tx_hash,omitempty"` - // voting_power is the voting power of the BTC delegation - VotingPower uint64 `protobuf:"varint,4,opt,name=voting_power,json=votingPower,proto3" json:"voting_power,omitempty"` -} - -func (m *BTCDelDistInfo) Reset() { *m = BTCDelDistInfo{} } -func (m *BTCDelDistInfo) String() string { return proto.CompactTextString(m) } -func (*BTCDelDistInfo) ProtoMessage() {} -func (*BTCDelDistInfo) Descriptor() ([]byte, []int) { - return fileDescriptor_ac354c3bd6d7a66b, []int{2} -} -func (m *BTCDelDistInfo) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *BTCDelDistInfo) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_BTCDelDistInfo.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 *BTCDelDistInfo) XXX_Merge(src proto.Message) { - xxx_messageInfo_BTCDelDistInfo.Merge(m, src) -} -func (m *BTCDelDistInfo) XXX_Size() int { - return m.Size() -} -func (m *BTCDelDistInfo) XXX_DiscardUnknown() { - xxx_messageInfo_BTCDelDistInfo.DiscardUnknown(m) -} - -var xxx_messageInfo_BTCDelDistInfo proto.InternalMessageInfo - -func (m *BTCDelDistInfo) GetStakerAddr() string { - if m != nil { - return m.StakerAddr - } - return "" -} - -func (m *BTCDelDistInfo) GetStakingTxHash() string { - if m != nil { - return m.StakingTxHash - } - return "" -} - -func (m *BTCDelDistInfo) GetVotingPower() uint64 { - if m != nil { - return m.VotingPower - } - return 0 -} - -func init() { - proto.RegisterType((*VotingPowerDistCache)(nil), "babylon.btcstaking.v1.VotingPowerDistCache") - proto.RegisterType((*FinalityProviderDistInfo)(nil), "babylon.btcstaking.v1.FinalityProviderDistInfo") - proto.RegisterType((*BTCDelDistInfo)(nil), "babylon.btcstaking.v1.BTCDelDistInfo") -} - -func init() { - proto.RegisterFile("babylon/btcstaking/v1/incentive.proto", fileDescriptor_ac354c3bd6d7a66b) -} - -var fileDescriptor_ac354c3bd6d7a66b = []byte{ - // 585 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x54, 0xcd, 0x6e, 0xd3, 0x4c, - 0x14, 0x8d, 0xdb, 0xf4, 0x6f, 0xfa, 0xf3, 0x7d, 0x8c, 0x8a, 0x64, 0x5a, 0xc9, 0x0d, 0x15, 0x45, - 0x59, 0x34, 0x36, 0xa5, 0x5d, 0x00, 0x2b, 0xea, 0x46, 0x15, 0xe5, 0x37, 0x32, 0x15, 0x0b, 0x16, - 0x58, 0xe3, 0xf1, 0xc4, 0x1e, 0x62, 0x7b, 0x2c, 0xdf, 0x89, 0x69, 0xde, 0x80, 0x25, 0x0f, 0xc0, - 0x82, 0x87, 0xe8, 0x43, 0xb0, 0xac, 0xba, 0x42, 0x5d, 0x54, 0xa8, 0x5d, 0xf0, 0x1a, 0xc8, 0x63, - 0x43, 0x02, 0x6a, 0xa4, 0x2e, 0xd8, 0xf9, 0xde, 0x73, 0xee, 0x9d, 0x39, 0xe7, 0xc8, 0x83, 0x36, - 0x3c, 0xe2, 0x0d, 0x22, 0x91, 0x58, 0x9e, 0xa4, 0x20, 0x49, 0x8f, 0x27, 0x81, 0x95, 0x6f, 0x59, - 0x3c, 0xa1, 0x2c, 0x91, 0x3c, 0x67, 0x66, 0x9a, 0x09, 0x29, 0xf0, 0xcd, 0x8a, 0x66, 0x0e, 0x69, - 0x66, 0xbe, 0xb5, 0xb2, 0x1c, 0x88, 0x40, 0x28, 0x86, 0x55, 0x7c, 0x95, 0xe4, 0x95, 0x5b, 0x54, - 0x40, 0x2c, 0xc0, 0x2d, 0x81, 0xb2, 0x28, 0xa1, 0xf5, 0x13, 0x0d, 0x2d, 0xbf, 0x11, 0x92, 0x27, - 0x41, 0x47, 0x7c, 0x60, 0x59, 0x9b, 0x83, 0xdc, 0x23, 0x34, 0x64, 0x78, 0x13, 0x61, 0x29, 0x24, - 0x89, 0xdc, 0x5c, 0xa1, 0x6e, 0x5a, 0xc0, 0xba, 0xd6, 0xd0, 0x9a, 0x75, 0xe7, 0x7f, 0x85, 0x8c, - 0x8c, 0xe1, 0x77, 0x08, 0x77, 0x79, 0x42, 0x22, 0x2e, 0x07, 0xc5, 0x29, 0x39, 0xf7, 0x59, 0x06, - 0xfa, 0x44, 0x63, 0xb2, 0x39, 0x7f, 0xdf, 0x32, 0xaf, 0xbc, 0xab, 0xb9, 0x5f, 0x0d, 0x74, 0x2a, - 0x7e, 0x71, 0xf6, 0x41, 0xd2, 0x15, 0xce, 0x8d, 0xee, 0x5f,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 0xcf, - 0x22, 0xd0, 0xa7, 0x54, 0x34, 0x1b, 0x63, 0xa2, 0xb1, 0x0f, 0xf7, 0xda, 0x2c, 0xfa, 0x1d, 0xc8, - 0x8c, 0x27, 0x69, 0x9b, 0x45, 0x80, 0x37, 0xd0, 0x12, 0x07, 0x57, 0xf2, 0x98, 0x81, 0x24, 0x71, - 0xca, 0x7c, 0x7d, 0xba, 0xa1, 0x35, 0x67, 0x9d, 0x45, 0x0e, 0x87, 0xc3, 0x26, 0x5e, 0x45, 0x73, - 0x1c, 0xdc, 0xf7, 0x84, 0x47, 0xcc, 0xd7, 0x67, 0x14, 0x63, 0x96, 0xc3, 0x53, 0x55, 0xaf, 0xff, - 0xd0, 0xd0, 0xd2, 0x9f, 0xfb, 0xff, 0x7d, 0x28, 0x0f, 0xd1, 0x7c, 0xa1, 0x86, 0x65, 0xee, 0xb5, - 0xb2, 0x41, 0x25, 0xb9, 0x68, 0xe2, 0xbb, 0xe8, 0xbf, 0xca, 0x08, 0x57, 0x1e, 0xb9, 0x21, 0x81, - 0xb0, 0x8c, 0xc9, 0x59, 0xac, 0xda, 0x87, 0x47, 0x4f, 0x08, 0x84, 0xf8, 0x36, 0x5a, 0xb8, 0xc2, - 0xf4, 0xf9, 0x7c, 0xe8, 0xb7, 0xfd, 0xf2, 0xeb, 0x85, 0xa1, 0x9d, 0x5c, 0x18, 0xda, 0xf7, 0x0b, - 0x43, 0xfb, 0x74, 0x69, 0xd4, 0x4e, 0x2e, 0x8d, 0xda, 0xb7, 0x4b, 0xa3, 0xf6, 0xf6, 0x1a, 0xe2, - 0x8e, 0x46, 0x1f, 0x00, 0xa5, 0xd4, 0x9b, 0x56, 0xbf, 0xec, 0xf6, 0xcf, 0x00, 0x00, 0x00, 0xff, - 0xff, 0xd8, 0x71, 0x40, 0x06, 0x23, 0x04, 0x00, 0x00, -} - -func (m *VotingPowerDistCache) 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 *VotingPowerDistCache) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *VotingPowerDistCache) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if m.NumActiveFps != 0 { - i = encodeVarintIncentive(dAtA, i, uint64(m.NumActiveFps)) - i-- - dAtA[i] = 0x18 - } - if len(m.FinalityProviders) > 0 { - for iNdEx := len(m.FinalityProviders) - 1; iNdEx >= 0; iNdEx-- { - { - size, err := m.FinalityProviders[iNdEx].MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintIncentive(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x12 - } - } - if m.TotalVotingPower != 0 { - i = encodeVarintIncentive(dAtA, i, uint64(m.TotalVotingPower)) - i-- - dAtA[i] = 0x8 - } - return len(dAtA) - i, nil -} - -func (m *FinalityProviderDistInfo) 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 *FinalityProviderDistInfo) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *FinalityProviderDistInfo) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if m.IsJailed { - i-- - if m.IsJailed { - dAtA[i] = 1 - } else { - dAtA[i] = 0 - } - i-- - dAtA[i] = 0x38 - } - if m.IsTimestamped { - i-- - if m.IsTimestamped { - dAtA[i] = 1 - } else { - dAtA[i] = 0 - } - i-- - dAtA[i] = 0x30 - } - if len(m.BtcDels) > 0 { - for iNdEx := len(m.BtcDels) - 1; iNdEx >= 0; iNdEx-- { - { - size, err := m.BtcDels[iNdEx].MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintIncentive(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x2a - } - } - if m.TotalVotingPower != 0 { - i = encodeVarintIncentive(dAtA, i, uint64(m.TotalVotingPower)) - i-- - dAtA[i] = 0x20 - } - if m.Commission != nil { - { - size := m.Commission.Size() - i -= size - if _, err := m.Commission.MarshalTo(dAtA[i:]); err != nil { - return 0, err - } - i = encodeVarintIncentive(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x1a - } - if len(m.Addr) > 0 { - i -= len(m.Addr) - copy(dAtA[i:], m.Addr) - i = encodeVarintIncentive(dAtA, i, uint64(len(m.Addr))) - i-- - dAtA[i] = 0x12 - } - if m.BtcPk != nil { - { - size := m.BtcPk.Size() - i -= size - if _, err := m.BtcPk.MarshalTo(dAtA[i:]); err != nil { - return 0, err - } - i = encodeVarintIncentive(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0xa - } - return len(dAtA) - i, nil -} - -func (m *BTCDelDistInfo) 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 *BTCDelDistInfo) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *BTCDelDistInfo) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if m.VotingPower != 0 { - i = encodeVarintIncentive(dAtA, i, uint64(m.VotingPower)) - i-- - dAtA[i] = 0x20 - } - if len(m.StakingTxHash) > 0 { - i -= len(m.StakingTxHash) - copy(dAtA[i:], m.StakingTxHash) - i = encodeVarintIncentive(dAtA, i, uint64(len(m.StakingTxHash))) - i-- - dAtA[i] = 0x1a - } - if len(m.StakerAddr) > 0 { - i -= len(m.StakerAddr) - copy(dAtA[i:], m.StakerAddr) - i = encodeVarintIncentive(dAtA, i, uint64(len(m.StakerAddr))) - i-- - dAtA[i] = 0x12 - } - if m.BtcPk != nil { - { - size := m.BtcPk.Size() - i -= size - if _, err := m.BtcPk.MarshalTo(dAtA[i:]); err != nil { - return 0, err - } - i = encodeVarintIncentive(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0xa - } - return len(dAtA) - i, nil -} - -func encodeVarintIncentive(dAtA []byte, offset int, v uint64) int { - offset -= sovIncentive(v) - base := offset - for v >= 1<<7 { - dAtA[offset] = uint8(v&0x7f | 0x80) - v >>= 7 - offset++ - } - dAtA[offset] = uint8(v) - return base -} -func (m *VotingPowerDistCache) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if m.TotalVotingPower != 0 { - n += 1 + sovIncentive(uint64(m.TotalVotingPower)) - } - if len(m.FinalityProviders) > 0 { - for _, e := range m.FinalityProviders { - l = e.Size() - n += 1 + l + sovIncentive(uint64(l)) - } - } - if m.NumActiveFps != 0 { - n += 1 + sovIncentive(uint64(m.NumActiveFps)) - } - return n -} - -func (m *FinalityProviderDistInfo) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if m.BtcPk != nil { - l = m.BtcPk.Size() - n += 1 + l + sovIncentive(uint64(l)) - } - l = len(m.Addr) - if l > 0 { - n += 1 + l + sovIncentive(uint64(l)) - } - if m.Commission != nil { - l = m.Commission.Size() - n += 1 + l + sovIncentive(uint64(l)) - } - if m.TotalVotingPower != 0 { - n += 1 + sovIncentive(uint64(m.TotalVotingPower)) - } - if len(m.BtcDels) > 0 { - for _, e := range m.BtcDels { - l = e.Size() - n += 1 + l + sovIncentive(uint64(l)) - } - } - if m.IsTimestamped { - n += 2 - } - if m.IsJailed { - n += 2 - } - return n -} - -func (m *BTCDelDistInfo) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if m.BtcPk != nil { - l = m.BtcPk.Size() - n += 1 + l + sovIncentive(uint64(l)) - } - l = len(m.StakerAddr) - if l > 0 { - n += 1 + l + sovIncentive(uint64(l)) - } - l = len(m.StakingTxHash) - if l > 0 { - n += 1 + l + sovIncentive(uint64(l)) - } - if m.VotingPower != 0 { - n += 1 + sovIncentive(uint64(m.VotingPower)) - } - return n -} - -func sovIncentive(x uint64) (n int) { - return (math_bits.Len64(x|1) + 6) / 7 -} -func sozIncentive(x uint64) (n int) { - return sovIncentive(uint64((x << 1) ^ uint64((int64(x) >> 63)))) -} -func (m *VotingPowerDistCache) 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 ErrIntOverflowIncentive - } - 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: VotingPowerDistCache: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: VotingPowerDistCache: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field TotalVotingPower", wireType) - } - m.TotalVotingPower = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowIncentive - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.TotalVotingPower |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field FinalityProviders", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowIncentive - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthIncentive - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthIncentive - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.FinalityProviders = append(m.FinalityProviders, &FinalityProviderDistInfo{}) - if err := m.FinalityProviders[len(m.FinalityProviders)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 3: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field NumActiveFps", wireType) - } - m.NumActiveFps = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowIncentive - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.NumActiveFps |= uint32(b&0x7F) << shift - if b < 0x80 { - break - } - } - default: - iNdEx = preIndex - skippy, err := skipIncentive(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthIncentive - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *FinalityProviderDistInfo) 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 ErrIntOverflowIncentive - } - 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: FinalityProviderDistInfo: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: FinalityProviderDistInfo: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field BtcPk", wireType) - } - var byteLen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowIncentive - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - byteLen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if byteLen < 0 { - return ErrInvalidLengthIncentive - } - postIndex := iNdEx + byteLen - if postIndex < 0 { - return ErrInvalidLengthIncentive - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - var v github_com_babylonlabs_io_babylon_types.BIP340PubKey - m.BtcPk = &v - if err := m.BtcPk.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Addr", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowIncentive - } - 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 ErrInvalidLengthIncentive - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthIncentive - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Addr = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 3: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Commission", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowIncentive - } - 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 ErrInvalidLengthIncentive - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthIncentive - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - var v cosmossdk_io_math.LegacyDec - m.Commission = &v - if err := m.Commission.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 4: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field TotalVotingPower", wireType) - } - m.TotalVotingPower = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowIncentive - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.TotalVotingPower |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - case 5: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field BtcDels", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowIncentive - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthIncentive - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthIncentive - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.BtcDels = append(m.BtcDels, &BTCDelDistInfo{}) - if err := m.BtcDels[len(m.BtcDels)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 6: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field IsTimestamped", wireType) - } - var v int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowIncentive - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - v |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - m.IsTimestamped = bool(v != 0) - case 7: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field IsJailed", wireType) - } - var v int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowIncentive - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - v |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - m.IsJailed = bool(v != 0) - default: - iNdEx = preIndex - skippy, err := skipIncentive(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthIncentive - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *BTCDelDistInfo) 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 ErrIntOverflowIncentive - } - 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: BTCDelDistInfo: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: BTCDelDistInfo: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field BtcPk", wireType) - } - var byteLen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowIncentive - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - byteLen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if byteLen < 0 { - return ErrInvalidLengthIncentive - } - postIndex := iNdEx + byteLen - if postIndex < 0 { - return ErrInvalidLengthIncentive - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - var v github_com_babylonlabs_io_babylon_types.BIP340PubKey - m.BtcPk = &v - if err := m.BtcPk.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field StakerAddr", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowIncentive - } - 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 ErrInvalidLengthIncentive - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthIncentive - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.StakerAddr = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 3: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field StakingTxHash", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowIncentive - } - 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 ErrInvalidLengthIncentive - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthIncentive - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.StakingTxHash = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 4: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field VotingPower", wireType) - } - m.VotingPower = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowIncentive - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.VotingPower |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - default: - iNdEx = preIndex - skippy, err := skipIncentive(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthIncentive - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func skipIncentive(dAtA []byte) (n int, err error) { - l := len(dAtA) - iNdEx := 0 - depth := 0 - for iNdEx < l { - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return 0, ErrIntOverflowIncentive - } - if iNdEx >= l { - return 0, io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= (uint64(b) & 0x7F) << shift - if b < 0x80 { - break - } - } - wireType := int(wire & 0x7) - switch wireType { - case 0: - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return 0, ErrIntOverflowIncentive - } - if iNdEx >= l { - return 0, io.ErrUnexpectedEOF - } - iNdEx++ - if dAtA[iNdEx-1] < 0x80 { - break - } - } - case 1: - iNdEx += 8 - case 2: - var length int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return 0, ErrIntOverflowIncentive - } - if iNdEx >= l { - return 0, io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - length |= (int(b) & 0x7F) << shift - if b < 0x80 { - break - } - } - if length < 0 { - return 0, ErrInvalidLengthIncentive - } - iNdEx += length - case 3: - depth++ - case 4: - if depth == 0 { - return 0, ErrUnexpectedEndOfGroupIncentive - } - depth-- - case 5: - iNdEx += 4 - default: - return 0, fmt.Errorf("proto: illegal wireType %d", wireType) - } - if iNdEx < 0 { - return 0, ErrInvalidLengthIncentive - } - if depth == 0 { - return iNdEx, nil - } - } - return 0, io.ErrUnexpectedEOF -} - -var ( - ErrInvalidLengthIncentive = fmt.Errorf("proto: negative length found during unmarshaling") - ErrIntOverflowIncentive = fmt.Errorf("proto: integer overflow") - ErrUnexpectedEndOfGroupIncentive = fmt.Errorf("proto: unexpected end of group") -) diff --git a/x/btcstaking/types/incentive_test.go b/x/btcstaking/types/incentive_test.go deleted file mode 100644 index fe844fe21..000000000 --- a/x/btcstaking/types/incentive_test.go +++ /dev/null @@ -1,119 +0,0 @@ -package types - -import ( - "testing" - - "github.com/btcsuite/btcd/btcec/v2" - "github.com/stretchr/testify/require" - - "github.com/babylonlabs-io/babylon/types" -) - -var ( - fpPrivKey1, _ = btcec.NewPrivateKey() - fpPrivKey2, _ = btcec.NewPrivateKey() - fpPubKey1 = types.NewBIP340PubKeyFromBTCPK(fpPrivKey1.PubKey()) - fpPubKey2 = types.NewBIP340PubKeyFromBTCPK(fpPrivKey2.PubKey()) -) - -func TestVotingPowerDistCache(t *testing.T) { - tests := []struct { - desc string - maxActiveFPs uint32 - numActiveFps uint32 - totalVotingPower uint64 - prevDistCache *VotingPowerDistCache - fps []*FinalityProviderDistInfo - }{ - { - desc: "all not timestamped", - maxActiveFPs: 80, - numActiveFps: 0, - totalVotingPower: 0, - prevDistCache: NewVotingPowerDistCache(), - fps: []*FinalityProviderDistInfo{ - { - BtcPk: fpPubKey1, - TotalVotingPower: 1000, - IsTimestamped: false, - }, - { - BtcPk: fpPubKey2, - TotalVotingPower: 2000, - IsTimestamped: false, - }, - }, - }, - { - desc: "all timestamped", - maxActiveFPs: 80, - numActiveFps: 2, - totalVotingPower: 3000, - prevDistCache: NewVotingPowerDistCache(), - fps: []*FinalityProviderDistInfo{ - { - BtcPk: fpPubKey1, - TotalVotingPower: 1000, - IsTimestamped: true, - }, - { - BtcPk: fpPubKey2, - TotalVotingPower: 2000, - IsTimestamped: true, - }, - }, - }, - { - desc: "partly timestamped", - maxActiveFPs: 80, - numActiveFps: 1, - totalVotingPower: 1000, - prevDistCache: NewVotingPowerDistCache(), - fps: []*FinalityProviderDistInfo{ - { - BtcPk: fpPubKey1, - TotalVotingPower: 1000, - IsTimestamped: true, - }, - { - BtcPk: fpPubKey2, - TotalVotingPower: 2000, - IsTimestamped: false, - }, - }, - }, - { - desc: "small max active fps", - maxActiveFPs: 1, - numActiveFps: 1, - totalVotingPower: 2000, - prevDistCache: NewVotingPowerDistCache(), - fps: []*FinalityProviderDistInfo{ - { - BtcPk: fpPubKey1, - TotalVotingPower: 1000, - IsTimestamped: true, - }, - { - BtcPk: fpPubKey2, - TotalVotingPower: 2000, - IsTimestamped: true, - }, - }, - }, - } - for _, tc := range tests { - t.Run(tc.desc, func(t *testing.T) { - dc := NewVotingPowerDistCache() - for _, fp := range tc.fps { - dc.AddFinalityProviderDistInfo(fp) - } - dc.ApplyActiveFinalityProviders(tc.maxActiveFPs) - require.Equal(t, tc.totalVotingPower, dc.TotalVotingPower) - require.Equal(t, tc.numActiveFps, dc.NumActiveFps) - - newBondedFps := dc.FindNewActiveFinalityProviders(tc.prevDistCache) - require.Equal(t, tc.numActiveFps, uint32(len(newBondedFps))) - }) - } -} diff --git a/x/btcstaking/types/inclusion_proof.go b/x/btcstaking/types/inclusion_proof.go new file mode 100644 index 000000000..e850e74ff --- /dev/null +++ b/x/btcstaking/types/inclusion_proof.go @@ -0,0 +1,57 @@ +package types + +import ( + "encoding/hex" + "fmt" + + btcctypes "github.com/babylonlabs-io/babylon/x/btccheckpoint/types" +) + +func NewInclusionProof(txKey *btcctypes.TransactionKey, proof []byte) *InclusionProof { + return &InclusionProof{ + Key: txKey, + Proof: proof, + } +} + +func NewInclusionProofFromHex(inclusionProofHex string) (*InclusionProof, error) { + inclusionProofBytes, err := hex.DecodeString(inclusionProofHex) + if err != nil { + return nil, err + } + var inclusionProof InclusionProof + if err := inclusionProof.Unmarshal(inclusionProofBytes); err != nil { + return nil, err + } + return &inclusionProof, nil +} + +func NewInclusionProofFromSpvProof(proof *btcctypes.BTCSpvProof) *InclusionProof { + return &InclusionProof{ + Key: &btcctypes.TransactionKey{ + Index: proof.BtcTransactionIndex, + Hash: proof.ConfirmingBtcHeader.Hash(), + }, + Proof: proof.MerkleNodes, + } +} + +func (ip *InclusionProof) MarshalHex() (string, error) { + ipBytes, err := ip.Marshal() + if err != nil { + return "", err + } + + return hex.EncodeToString(ipBytes), nil +} + +func (ip *InclusionProof) ValidateBasic() error { + if ip.Key == nil { + return fmt.Errorf("key in InclusionProof is nil") + } + if ip.Proof == nil { + return fmt.Errorf("proof in InclussionProof is nil") + } + + return nil +} diff --git a/x/btcstaking/types/keys.go b/x/btcstaking/types/keys.go index 54a56cb81..f9e415423 100644 --- a/x/btcstaking/types/keys.go +++ b/x/btcstaking/types/keys.go @@ -1,5 +1,7 @@ package types +import "cosmossdk.io/collections" + const ( // ModuleName defines the module name ModuleName = "btcstaking" @@ -15,14 +17,15 @@ const ( ) var ( - ParamsKey = []byte{0x01} // key prefix for the parameters - FinalityProviderKey = []byte{0x02} // key prefix for the finality providers - BTCDelegatorKey = []byte{0x03} // key prefix for the BTC delegators - BTCDelegationKey = []byte{0x04} // key prefix for the BTC delegations - VotingPowerKey = []byte{0x05} // key prefix for the voting power - BTCHeightKey = []byte{0x06} // key prefix for the BTC heights - VotingPowerDistCacheKey = []byte{0x07} // key prefix for voting power distribution cache - PowerDistUpdateKey = []byte{0x08} // key prefix for power distribution update events - BTCConsumerDelegatorKey = []byte{0x09} // key prefix for the Consumer BTC delegators - BTCStakingEventKey = []byte{0x0A} // key prefix for the BTC staking events + ParamsKey = []byte{0x01} // key prefix for the parameters + FinalityProviderKey = []byte{0x02} // key prefix for the finality providers + BTCDelegatorKey = []byte{0x03} // key prefix for the BTC delegators + BTCDelegationKey = []byte{0x04} // key prefix for the BTC delegations + // 0x05 was used for something else in the past + BTCHeightKey = []byte{0x06} // key prefix for the BTC heights + // 0x07 was used for something else in the past + PowerDistUpdateKey = []byte{0x08} // key prefix for power distribution update events + AllowedStakingTxHashesKey = collections.NewPrefix(9) // key prefix for allowed staking tx hashes + BTCConsumerDelegatorKey = []byte{0x10} // key prefix for the Consumer BTC delegators + BTCStakingEventKey = []byte{0x11} // key prefix for the BTC staking events ) diff --git a/x/btcstaking/types/metrics.go b/x/btcstaking/types/metrics.go index ab0cc699a..0a5abccc6 100644 --- a/x/btcstaking/types/metrics.go +++ b/x/btcstaking/types/metrics.go @@ -7,11 +7,12 @@ import ( // performance oriented metrics measuring the execution time of each message const ( - MetricsKeyCreateFinalityProvider = "create_finality_provider" - MetricsKeyCreateBTCDelegation = "create_btc_delegation" - MetricsKeyAddCovenantSigs = "add_covenant_sigs" - MetricsKeyBTCUndelegate = "btc_undelegate" - MetricsKeySelectiveSlashingEvidence = "selective_slashing_evidence" + MetricsKeyCreateFinalityProvider = "create_finality_provider" + MetricsKeyCreateBTCDelegation = "create_btc_delegation" + MetricsKeyAddCovenantSigs = "add_covenant_sigs" + MetricsKeyAddBTCDelegationInclusionProof = "add_btc_delegation_inclusion_proof" + MetricsKeyBTCUndelegate = "btc_undelegate" + MetricsKeySelectiveSlashingEvidence = "selective_slashing_evidence" ) // Metrics for monitoring finality providers and BTC delegations diff --git a/x/btcstaking/types/mocked_keepers.go b/x/btcstaking/types/mocked_keepers.go index c1f6be7ea..52c61ca0d 100644 --- a/x/btcstaking/types/mocked_keepers.go +++ b/x/btcstaking/types/mocked_keepers.go @@ -11,6 +11,7 @@ import ( types "github.com/babylonlabs-io/babylon/types" types0 "github.com/babylonlabs-io/babylon/x/btccheckpoint/types" types1 "github.com/babylonlabs-io/babylon/x/btclightclient/types" + types2 "github.com/cosmos/cosmos-sdk/types" gomock "github.com/golang/mock/gomock" ) @@ -246,39 +247,37 @@ func (mr *MockBTCStkConsumerKeeperMockRecorder) SetConsumerFinalityProvider(ctx, return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SetConsumerFinalityProvider", reflect.TypeOf((*MockBTCStkConsumerKeeper)(nil).SetConsumerFinalityProvider), ctx, fp) } -// MockBtcStakingHooks is a mock of BtcStakingHooks interface. -type MockBtcStakingHooks struct { +// MockIncentiveKeeper is a mock of IncentiveKeeper interface. +type MockIncentiveKeeper struct { ctrl *gomock.Controller - recorder *MockBtcStakingHooksMockRecorder + recorder *MockIncentiveKeeperMockRecorder } -// MockBtcStakingHooksMockRecorder is the mock recorder for MockBtcStakingHooks. -type MockBtcStakingHooksMockRecorder struct { - mock *MockBtcStakingHooks +// MockIncentiveKeeperMockRecorder is the mock recorder for MockIncentiveKeeper. +type MockIncentiveKeeperMockRecorder struct { + mock *MockIncentiveKeeper } -// NewMockBtcStakingHooks creates a new mock instance. -func NewMockBtcStakingHooks(ctrl *gomock.Controller) *MockBtcStakingHooks { - mock := &MockBtcStakingHooks{ctrl: ctrl} - mock.recorder = &MockBtcStakingHooksMockRecorder{mock} +// NewMockIncentiveKeeper creates a new mock instance. +func NewMockIncentiveKeeper(ctrl *gomock.Controller) *MockIncentiveKeeper { + mock := &MockIncentiveKeeper{ctrl: ctrl} + mock.recorder = &MockIncentiveKeeperMockRecorder{mock} return mock } // EXPECT returns an object that allows the caller to indicate expected use. -func (m *MockBtcStakingHooks) EXPECT() *MockBtcStakingHooksMockRecorder { +func (m *MockIncentiveKeeper) EXPECT() *MockIncentiveKeeperMockRecorder { return m.recorder } -// AfterFinalityProviderActivated mocks base method. -func (m *MockBtcStakingHooks) AfterFinalityProviderActivated(ctx context.Context, fpPk *types.BIP340PubKey) error { +// IndexRefundableMsg mocks base method. +func (m *MockIncentiveKeeper) IndexRefundableMsg(ctx context.Context, msg types2.Msg) { m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "AfterFinalityProviderActivated", ctx, fpPk) - ret0, _ := ret[0].(error) - return ret0 + m.ctrl.Call(m, "IndexRefundableMsg", ctx, msg) } -// AfterFinalityProviderActivated indicates an expected call of AfterFinalityProviderActivated. -func (mr *MockBtcStakingHooksMockRecorder) AfterFinalityProviderActivated(ctx, fpPk interface{}) *gomock.Call { +// IndexRefundableMsg indicates an expected call of IndexRefundableMsg. +func (mr *MockIncentiveKeeperMockRecorder) IndexRefundableMsg(ctx, msg interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "AfterFinalityProviderActivated", reflect.TypeOf((*MockBtcStakingHooks)(nil).AfterFinalityProviderActivated), ctx, fpPk) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "IndexRefundableMsg", reflect.TypeOf((*MockIncentiveKeeper)(nil).IndexRefundableMsg), ctx, msg) } diff --git a/x/btcstaking/types/msg.go b/x/btcstaking/types/msg.go index 9d4e29708..9603f91e6 100644 --- a/x/btcstaking/types/msg.go +++ b/x/btcstaking/types/msg.go @@ -4,6 +4,8 @@ import ( "fmt" bbn "github.com/babylonlabs-io/babylon/types" + "github.com/btcsuite/btcd/blockchain" + "github.com/btcsuite/btcd/btcutil" "github.com/btcsuite/btcd/chaincfg/chainhash" sdk "github.com/cosmos/cosmos-sdk/types" ) @@ -16,6 +18,7 @@ var ( _ sdk.Msg = &MsgCreateBTCDelegation{} _ sdk.Msg = &MsgAddCovenantSigs{} _ sdk.Msg = &MsgBTCUndelegate{} + _ sdk.Msg = &MsgAddBTCDelegationInclusionProof{} ) func (m *MsgCreateFinalityProvider) ValidateBasic() error { @@ -112,12 +115,50 @@ func (m *MsgBTCUndelegate) ValidateBasic() error { return fmt.Errorf("staking tx hash is not %d", chainhash.MaxHashStringSize) } - if m.UnbondingTxSig == nil { + if m == nil { return fmt.Errorf("empty signature from the delegator") } - if _, err := m.UnbondingTxSig.ToBTCSig(); err != nil { - return fmt.Errorf("invalid delegator unbonding signature: %w", err) + if m.StakeSpendingTxInclusionProof == nil { + return fmt.Errorf("empty inclusion proof") + } + + if err := m.StakeSpendingTxInclusionProof.ValidateBasic(); err != nil { + return fmt.Errorf("invalid inclusion proof: %w", err) + } + + if m.StakeSpendingTx == nil { + return fmt.Errorf("empty delegator unbonding signature") + } + + tx, err := bbn.NewBTCTxFromBytes(m.StakeSpendingTx) + + if err != nil { + return fmt.Errorf("invalid stake spending tx tx: %w", err) + } + + if err := blockchain.CheckTransactionSanity(btcutil.NewTx(tx)); err != nil { + return fmt.Errorf("invalid stake spending tx: %w", err) + } + + return nil +} + +func (m *MsgAddBTCDelegationInclusionProof) ValidateBasic() error { + if len(m.StakingTxHash) != chainhash.MaxHashStringSize { + return fmt.Errorf("staking tx hash is not %d", chainhash.MaxHashStringSize) + } + + if m.StakingTxInclusionProof == nil { + return fmt.Errorf("empty inclusion proof") + } + + if err := m.StakingTxInclusionProof.ValidateBasic(); err != nil { + return fmt.Errorf("invalid inclusion proof: %w", err) + } + + if _, err := sdk.AccAddressFromBech32(m.Signer); err != nil { + return fmt.Errorf("invalid signer addr: %s - %v", m.Signer, err) } return nil diff --git a/x/btcstaking/types/packet.pb.go b/x/btcstaking/types/packet.pb.go index 53c2797b5..0c50e9b12 100644 --- a/x/btcstaking/types/packet.pb.go +++ b/x/btcstaking/types/packet.pb.go @@ -306,10 +306,10 @@ type ActiveBTCDelegation struct { FpBtcPkList []string `protobuf:"bytes,2,rep,name=fp_btc_pk_list,json=fpBtcPkList,proto3" json:"fp_btc_pk_list,omitempty"` // start_height is the start BTC height of the BTC delegation // it is the start BTC height of the timelock - StartHeight uint64 `protobuf:"varint,3,opt,name=start_height,json=startHeight,proto3" json:"start_height,omitempty"` + StartHeight uint32 `protobuf:"varint,3,opt,name=start_height,json=startHeight,proto3" json:"start_height,omitempty"` // end_height is the end height of the BTC delegation // it is the end BTC height of the timelock - w - EndHeight uint64 `protobuf:"varint,4,opt,name=end_height,json=endHeight,proto3" json:"end_height,omitempty"` + EndHeight uint32 `protobuf:"varint,4,opt,name=end_height,json=endHeight,proto3" json:"end_height,omitempty"` // total_sat is the total amount of BTC stakes in this delegation // quantified in satoshi TotalSat uint64 `protobuf:"varint,5,opt,name=total_sat,json=totalSat,proto3" json:"total_sat,omitempty"` @@ -390,14 +390,14 @@ func (m *ActiveBTCDelegation) GetFpBtcPkList() []string { return nil } -func (m *ActiveBTCDelegation) GetStartHeight() uint64 { +func (m *ActiveBTCDelegation) GetStartHeight() uint32 { if m != nil { return m.StartHeight } return 0 } -func (m *ActiveBTCDelegation) GetEndHeight() uint64 { +func (m *ActiveBTCDelegation) GetEndHeight() uint32 { if m != nil { return m.EndHeight } @@ -636,6 +636,10 @@ type UnbondedBTCDelegation struct { // unbonding_tx_sig is the signature on the unbonding tx signed by the BTC delegator // It proves that the BTC delegator wants to unbond UnbondingTxSig []byte `protobuf:"bytes,2,opt,name=unbonding_tx_sig,json=unbondingTxSig,proto3" json:"unbonding_tx_sig,omitempty"` + // stake_spending_tx is the stake spending tx + StakeSpendingTx []byte `protobuf:"bytes,3,opt,name=stake_spending_tx,json=stakeSpendingTx,proto3" json:"stake_spending_tx,omitempty"` + // proof is the inclusion proof for the stake spending tx + Proof *InclusionProof `protobuf:"bytes,4,opt,name=proof,proto3" json:"proof,omitempty"` } func (m *UnbondedBTCDelegation) Reset() { *m = UnbondedBTCDelegation{} } @@ -685,6 +689,20 @@ func (m *UnbondedBTCDelegation) GetUnbondingTxSig() []byte { return nil } +func (m *UnbondedBTCDelegation) GetStakeSpendingTx() []byte { + if m != nil { + return m.StakeSpendingTx + } + return nil +} + +func (m *UnbondedBTCDelegation) GetProof() *InclusionProof { + if m != nil { + return m.Proof + } + return nil +} + // BTCStakingConsumerEvent defines the structure for storing BTC staking events // which will be later sent to consumer chains as IBC packets. type BTCStakingConsumerEvent struct { @@ -818,72 +836,75 @@ func init() { } var fileDescriptor_3ed0d17ad14d6c0e = []byte{ - // 1039 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x9c, 0x56, 0x4f, 0x73, 0xda, 0x46, - 0x14, 0x47, 0x80, 0x1d, 0xf3, 0x00, 0xc7, 0x59, 0xdb, 0xb1, 0x26, 0x69, 0x89, 0x4b, 0xd2, 0x0c, - 0xd3, 0x26, 0xa2, 0x4e, 0x33, 0xbd, 0xf5, 0x60, 0x70, 0x3c, 0x78, 0x9a, 0xda, 0x54, 0xe0, 0x76, - 0xa6, 0x17, 0xcd, 0x4a, 0x5a, 0x60, 0x07, 0xa1, 0xd5, 0x68, 0x17, 0x8c, 0xbf, 0x44, 0xa7, 0x87, - 0x7e, 0xa2, 0x9e, 0x7a, 0xf4, 0xad, 0x3d, 0x76, 0xec, 0x6f, 0xd1, 0x53, 0x47, 0x2b, 0x09, 0x09, - 0x0c, 0x9e, 0xd2, 0x1b, 0xbc, 0xf7, 0x7b, 0xff, 0x7f, 0x6f, 0x9f, 0xa0, 0x6a, 0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 0xfe, 0x96, - 0xb2, 0xf8, 0x6f, 0x7d, 0x9a, 0xfe, 0x8e, 0x13, 0xd7, 0x1e, 0xe1, 0xe6, 0xa6, 0xfc, 0x80, 0xfb, - 0xfa, 0xdf, 0x00, 0x00, 0x00, 0xff, 0xff, 0x6d, 0xdf, 0x64, 0x3a, 0x6c, 0x0a, 0x00, 0x00, + // 1085 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x9c, 0x56, 0x4f, 0x6f, 0xe2, 0x56, + 0x10, 0xc7, 0x40, 0xb2, 0xcb, 0x40, 0xb2, 0xc9, 0x4b, 0xb2, 0xb1, 0x76, 0x5b, 0x36, 0x65, 0xff, + 0x28, 0xda, 0xee, 0x42, 0x93, 0xae, 0x7a, 0xa9, 0x7a, 0x08, 0x64, 0x23, 0xa2, 0x6e, 0x13, 0x6a, + 0x48, 0x2b, 0xf5, 0x62, 0xf9, 0xcf, 0x03, 0x9e, 0x30, 0x7e, 0x96, 0xdf, 0x83, 0x90, 0x2f, 0x51, + 0xf5, 0xd0, 0x4f, 0xd4, 0x53, 0x8f, 0xab, 0x5e, 0xda, 0x63, 0x95, 0x7c, 0x8b, 0x9e, 0x2a, 0x8f, + 0x6d, 0xec, 0x10, 0x88, 0x4a, 0x6f, 0x30, 0xf3, 0x9b, 0x3f, 0x6f, 0xe6, 0x37, 0x33, 0x86, 0x8a, + 0x69, 0x98, 0x57, 0x0e, 0x77, 0x6b, 0xa6, 0xb4, 0x84, 0x34, 0x06, 0xcc, 0xed, 0xd5, 0xc6, 0x07, + 0x35, 0xcf, 0xb0, 0x06, 0x54, 0x56, 0x3d, 0x9f, 0x4b, 0x4e, 0x76, 0x22, 0x4c, 0x35, 0xc1, 0x54, + 0xc7, 0x07, 0x4f, 0x5e, 0x58, 0x5c, 0x0c, 0xb9, 0xa8, 0x25, 0x66, 0x26, 0x95, 0xc6, 0x41, 0xfc, + 0x3f, 0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c, 0xc9, 0xb8, 0xab, 0x15, 0x42, 0xeb, 0x63, 0xea, 0x90, + 0x0f, 0x50, 0x8c, 0x8b, 0x1b, 0xf8, 0xca, 0xa1, 0xaf, 0xcf, 0xef, 0xaf, 0xee, 0x6d, 0x67, 0x71, + 0x73, 0x02, 0x6f, 0xe7, 0x50, 0x1a, 0xb9, 0x26, 0x77, 0xed, 0xc8, 0x5d, 0x1e, 0xdd, 0xbd, 0x59, + 0xe0, 0xee, 0x22, 0x82, 0xde, 0xf6, 0x57, 0x8c, 0x3d, 0x1c, 0x53, 0xa7, 0xf2, 0x73, 0x16, 0xb6, + 0xe6, 0x14, 0x82, 0xbc, 0x87, 0xa2, 0x4d, 0x85, 0xe5, 0x33, 0x2f, 0xb0, 0xc1, 0x56, 0x15, 0x0f, + 0x9f, 0x57, 0x43, 0xb6, 0x56, 0x93, 0x18, 0xc8, 0xd6, 0xea, 0x71, 0x02, 0xd5, 0xd2, 0x76, 0xa4, + 0x0c, 0x60, 0xf1, 0xe1, 0x90, 0x09, 0x11, 0x78, 0x09, 0x3b, 0x99, 0x92, 0x10, 0x02, 0x79, 0xc3, + 0xb6, 0x7d, 0x35, 0x87, 0x1a, 0xfc, 0x3d, 0x43, 0x92, 0xfc, 0x0c, 0x49, 0xbe, 0x81, 0x9c, 0xc7, + 0x3d, 0x75, 0x05, 0x13, 0x5a, 0x54, 0xc7, 0x96, 0xcf, 0x79, 0xf7, 0xbc, 0xdb, 0xe2, 0x42, 0x50, + 0x0c, 0x54, 0xef, 0x34, 0xb4, 0xc0, 0x8e, 0x3c, 0x83, 0xa2, 0x15, 0x0d, 0x80, 0xce, 0x6c, 0xf5, + 0x61, 0x9c, 0x51, 0x34, 0x13, 0x76, 0xe5, 0x9f, 0x3c, 0x6c, 0xcd, 0x69, 0x69, 0x60, 0x18, 0x04, + 0xa0, 0xbe, 0x8e, 0x09, 0x17, 0x43, 0xc3, 0x50, 0x74, 0x74, 0x37, 0xed, 0x59, 0x6e, 0x3f, 0x87, + 0xf5, 0x88, 0xd1, 0xde, 0x40, 0x77, 0x98, 0x90, 0xc8, 0xaa, 0x82, 0x56, 0xec, 0x06, 0x6c, 0x6e, + 0x0d, 0x3e, 0x30, 0x21, 0xc9, 0x67, 0x50, 0x12, 0xd2, 0xf0, 0xa5, 0xde, 0xa7, 0xac, 0xd7, 0x97, + 0x58, 0x95, 0x35, 0xad, 0x88, 0xb2, 0x26, 0x8a, 0xc8, 0xa7, 0x00, 0xd4, 0xb5, 0x63, 0x40, 0x1e, + 0x01, 0x05, 0xea, 0xda, 0x91, 0xfa, 0x29, 0x14, 0x24, 0x97, 0x86, 0xa3, 0x0b, 0x43, 0x62, 0x8d, + 0xf2, 0xda, 0x43, 0x14, 0xb4, 0x0d, 0xb4, 0x8d, 0x6a, 0xa4, 0xcb, 0x89, 0xba, 0xba, 0xa7, 0xec, + 0x97, 0xb4, 0x42, 0x24, 0xe9, 0x4c, 0xf0, 0x85, 0x01, 0xd3, 0x22, 0xfd, 0x03, 0xd4, 0x43, 0x2c, + 0xea, 0x4c, 0xc8, 0x3b, 0x78, 0x6c, 0x87, 0x05, 0xe1, 0xbe, 0x3e, 0x85, 0x0a, 0xd6, 0xc3, 0x32, + 0x96, 0xb4, 0xed, 0xa9, 0xb6, 0x1d, 0x29, 0xdb, 0xac, 0x47, 0x2e, 0x60, 0x2d, 0x18, 0x5c, 0xd7, + 0x70, 0x65, 0x80, 0x15, 0x6a, 0x01, 0x39, 0xfb, 0xc5, 0x82, 0xd6, 0x35, 0x22, 0xec, 0x91, 0x6d, + 0x78, 0x81, 0x27, 0xd6, 0x73, 0x0d, 0x39, 0xf2, 0xa9, 0xd0, 0x4a, 0xb1, 0x9b, 0x36, 0xeb, 0x09, + 0xf2, 0x06, 0x48, 0xfc, 0x18, 0x3e, 0x92, 0xde, 0x48, 0xea, 0xcc, 0x9e, 0xa8, 0x80, 0x05, 0xd9, + 0x88, 0x34, 0xe7, 0xa8, 0x38, 0xb5, 0x27, 0xe4, 0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bf, 0x18, 0xe5, 0x95, 0x47, 0x85, 0xb9, 0x8a, 0x9f, 0x8a, 0x5f, 0xfe, + 0x1b, 0x00, 0x00, 0xff, 0xff, 0x54, 0xdd, 0x92, 0x14, 0xd6, 0x0a, 0x00, 0x00, } func (m *ConsumerIBCPacket) Marshal() (dAtA []byte, err error) { @@ -1373,6 +1394,25 @@ func (m *UnbondedBTCDelegation) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l + if m.Proof != nil { + { + size, err := m.Proof.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintPacket(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x22 + } + if len(m.StakeSpendingTx) > 0 { + i -= len(m.StakeSpendingTx) + copy(dAtA[i:], m.StakeSpendingTx) + i = encodeVarintPacket(dAtA, i, uint64(len(m.StakeSpendingTx))) + i-- + dAtA[i] = 0x1a + } if len(m.UnbondingTxSig) > 0 { i -= len(m.UnbondingTxSig) copy(dAtA[i:], m.UnbondingTxSig) @@ -1746,6 +1786,14 @@ func (m *UnbondedBTCDelegation) Size() (n int) { if l > 0 { n += 1 + l + sovPacket(uint64(l)) } + l = len(m.StakeSpendingTx) + if l > 0 { + n += 1 + l + sovPacket(uint64(l)) + } + if m.Proof != nil { + l = m.Proof.Size() + n += 1 + l + sovPacket(uint64(l)) + } return n } @@ -2557,7 +2605,7 @@ func (m *ActiveBTCDelegation) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - m.StartHeight |= uint64(b&0x7F) << shift + m.StartHeight |= uint32(b&0x7F) << shift if b < 0x80 { break } @@ -2576,7 +2624,7 @@ func (m *ActiveBTCDelegation) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - m.EndHeight |= uint64(b&0x7F) << shift + m.EndHeight |= uint32(b&0x7F) << shift if b < 0x80 { break } @@ -3345,6 +3393,76 @@ func (m *UnbondedBTCDelegation) Unmarshal(dAtA []byte) error { m.UnbondingTxSig = []byte{} } iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field StakeSpendingTx", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowPacket + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthPacket + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthPacket + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.StakeSpendingTx = append(m.StakeSpendingTx[:0], dAtA[iNdEx:postIndex]...) + if m.StakeSpendingTx == nil { + m.StakeSpendingTx = []byte{} + } + iNdEx = postIndex + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Proof", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowPacket + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthPacket + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthPacket + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.Proof == nil { + m.Proof = &InclusionProof{} + } + if err := m.Proof.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex default: iNdEx = preIndex skippy, err := skipPacket(dAtA[iNdEx:]) diff --git a/x/btcstaking/types/params.go b/x/btcstaking/types/params.go index 0370ac128..43528030c 100644 --- a/x/btcstaking/types/params.go +++ b/x/btcstaking/types/params.go @@ -5,8 +5,6 @@ import ( "math" sdkmath "cosmossdk.io/math" - "github.com/babylonlabs-io/babylon/btcstaking" - bbn "github.com/babylonlabs-io/babylon/types" "github.com/btcsuite/btcd/btcec/v2" "github.com/btcsuite/btcd/btcutil" "github.com/btcsuite/btcd/chaincfg" @@ -14,10 +12,14 @@ import ( "github.com/cometbft/cometbft/crypto/tmhash" paramtypes "github.com/cosmos/cosmos-sdk/x/params/types" "gopkg.in/yaml.v2" + + "github.com/babylonlabs-io/babylon/btcstaking" + bbn "github.com/babylonlabs-io/babylon/types" ) const ( - defaultMaxActiveFinalityProviders uint32 = 100 + // TODO: need to determine a proper default value + defaultDelegationCreationBaseGasFee = 1000 ) var _ paramtypes.ParamSet = (*Params)(nil) @@ -69,12 +71,15 @@ func DefaultParams() Params { MinSlashingTxFeeSat: 1000, MinCommissionRate: sdkmath.LegacyZeroDec(), // The Default slashing rate is 0.1 i.e., 10% of the total staked BTC will be burned. - SlashingRate: sdkmath.LegacyNewDecWithPrec(1, 1), // 1 * 10^{-1} = 0.1 - MaxActiveFinalityProviders: defaultMaxActiveFinalityProviders, + SlashingRate: sdkmath.LegacyNewDecWithPrec(1, 1), // 1 * 10^{-1} = 0.1 // The default minimum unbonding time is 0, which effectively defaults to checkpoint // finalization timeout. - MinUnbondingTimeBlocks: 0, - UnbondingFeeSat: 1000, + MinUnbondingTimeBlocks: 0, + UnbondingFeeSat: 1000, + DelegationCreationBaseGasFee: defaultDelegationCreationBaseGasFee, + // The default allow list expiration height is 0, which effectively disables the allow list. + // Allow list can only be enabled by upgrade + AllowListExpirationHeight: 0, } } @@ -105,15 +110,6 @@ func validateMinCommissionRate(rate sdkmath.LegacyDec) error { return nil } -// validateMaxActiveFinalityProviders checks if the maximum number of -// active finality providers is at least the default value -func validateMaxActiveFinalityProviders(maxActiveFinalityProviders uint32) error { - if maxActiveFinalityProviders == 0 { - return fmt.Errorf("max finality providers must be positive") - } - return nil -} - // validateCovenantPks checks whether the covenants list contains any duplicates func validateCovenantPks(covenantPks []bbn.BIP340PubKey) error { if ExistsDup(covenantPks) { @@ -175,7 +171,7 @@ func (p Params) Validate() error { if p.CovenantQuorum == 0 { return fmt.Errorf("covenant quorum size has to be positive") } - if p.CovenantQuorum*2 <= uint32(len(p.CovenantPks)) { + if int(p.CovenantQuorum)*2 <= len(p.CovenantPks) { return fmt.Errorf("covenant quorum size has to be more than 1/2 of the covenant committee size") } @@ -202,10 +198,6 @@ func (p Params) Validate() error { return btcstaking.ErrInvalidSlashingRate } - if err := validateMaxActiveFinalityProviders(p.MaxActiveFinalityProviders); err != nil { - return err - } - if err := validateMinUnbondingTime(p.MinUnbondingTimeBlocks); err != nil { return err } diff --git a/x/btcstaking/types/params.pb.go b/x/btcstaking/types/params.pb.go index 773816ad3..1d96cd61b 100644 --- a/x/btcstaking/types/params.pb.go +++ b/x/btcstaking/types/params.pb.go @@ -37,7 +37,7 @@ type Params struct { CovenantQuorum uint32 `protobuf:"varint,2,opt,name=covenant_quorum,json=covenantQuorum,proto3" json:"covenant_quorum,omitempty"` // min_staking_value_sat is the minimum of satoshis locked in staking output MinStakingValueSat int64 `protobuf:"varint,3,opt,name=min_staking_value_sat,json=minStakingValueSat,proto3" json:"min_staking_value_sat,omitempty"` - // max_staking_value_sat is the maxiumum of satoshis locked in staking output + // max_staking_value_sat is the maximum of satoshis locked in staking output MaxStakingValueSat int64 `protobuf:"varint,4,opt,name=max_staking_value_sat,json=maxStakingValueSat,proto3" json:"max_staking_value_sat,omitempty"` // min_staking_time is the minimum lock time specified in staking output script MinStakingTimeBlocks uint32 `protobuf:"varint,5,opt,name=min_staking_time_blocks,json=minStakingTimeBlocks,proto3" json:"min_staking_time_blocks,omitempty"` @@ -65,8 +65,12 @@ type Params struct { // can charge their delegators expressed as a decimal (e.g., 0.5 for 50%). Maximal precion // is 2 decimal places MinCommissionRate cosmossdk_io_math.LegacyDec `protobuf:"bytes,12,opt,name=min_commission_rate,json=minCommissionRate,proto3,customtype=cosmossdk.io/math.LegacyDec" json:"min_commission_rate"` - // max_active_finality_providers is the maximum number of active finality providers in the BTC staking protocol - MaxActiveFinalityProviders uint32 `protobuf:"varint,13,opt,name=max_active_finality_providers,json=maxActiveFinalityProviders,proto3" json:"max_active_finality_providers,omitempty"` + // base gas fee for delegation creation + DelegationCreationBaseGasFee uint64 `protobuf:"varint,13,opt,name=delegation_creation_base_gas_fee,json=delegationCreationBaseGasFee,proto3" json:"delegation_creation_base_gas_fee,omitempty"` + // allow_list_expiration_height is the height at which the allow list expires + // i.e all staking transactions are allowed to enter Babylon chain afterwards + // setting it to 0 means allow list is disabled + AllowListExpirationHeight uint64 `protobuf:"varint,14,opt,name=allow_list_expiration_height,json=allowListExpirationHeight,proto3" json:"allow_list_expiration_height,omitempty"` } func (m *Params) Reset() { *m = Params{} } @@ -164,9 +168,16 @@ func (m *Params) GetUnbondingFeeSat() int64 { return 0 } -func (m *Params) GetMaxActiveFinalityProviders() uint32 { +func (m *Params) GetDelegationCreationBaseGasFee() uint64 { if m != nil { - return m.MaxActiveFinalityProviders + return m.DelegationCreationBaseGasFee + } + return 0 +} + +func (m *Params) GetAllowListExpirationHeight() uint64 { + if m != nil { + return m.AllowListExpirationHeight } return 0 } @@ -237,46 +248,49 @@ func init() { } var fileDescriptor_8d1392776a3e15b9 = []byte{ - // 619 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x8c, 0x94, 0x4f, 0x4f, 0xd4, 0x4e, - 0x18, 0xc7, 0xb7, 0x3f, 0xf8, 0x2d, 0x32, 0x2c, 0x22, 0x15, 0xb4, 0x60, 0xd8, 0xdd, 0xe0, 0xc1, - 0x8d, 0x91, 0xd6, 0x15, 0x4c, 0xfc, 0x73, 0xa2, 0x12, 0x12, 0xa3, 0x31, 0xb5, 0x8b, 0x1c, 0xf4, - 0xd0, 0x4c, 0xbb, 0xc3, 0x32, 0x69, 0x67, 0xa6, 0x76, 0xa6, 0x4d, 0xf7, 0x5d, 0x78, 0xf4, 0x68, - 0xe2, 0x5b, 0xf0, 0x45, 0x70, 0x24, 0x9e, 0x0c, 0x07, 0x62, 0xe0, 0x8d, 0x98, 0x4e, 0xa7, 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xc1, 0xf2, 0xd4, 0x56, 0x21, 0x2c, - 0x48, 0x84, 0xa5, 0x89, 0xa0, 0xd6, 0x1f, 0x80, 0x82, 0xca, 0x0b, 0x18, 0x21, 0x98, 0x73, 0xcc, - 0x68, 0x09, 0xd1, 0x92, 0x10, 0x0f, 0x6f, 0x00, 0xe1, 0x2e, 0x13, 0x4c, 0xdf, 0x4c, 0xec, 0x72, - 0xf7, 0x5d, 0xb0, 0x51, 0x7c, 0x2e, 0x18, 0x08, 0x9c, 0x21, 0xef, 0x08, 0x53, 0x18, 0x61, 0x31, - 0x2e, 0x62, 0x90, 0xe1, 0x21, 0x4a, 0xb8, 0xb1, 0x28, 0xf7, 0x5f, 0x27, 0x30, 0xdf, 0x95, 0x35, - 0xfb, 0xaa, 0xc4, 0xa9, 0x2a, 0x5e, 0xcd, 0x7e, 0xff, 0xd1, 0x69, 0x6c, 0x22, 0xd0, 0x1a, 0x08, - 0x96, 0xa0, 0xa1, 0x8a, 0x8a, 0x01, 0xe6, 0x32, 0x94, 0x14, 0x73, 0x0c, 0x4d, 0xb6, 0xa8, 0x8e, - 0xfa, 0x6b, 0xd0, 0x2c, 0x73, 0x2a, 0x9f, 0xf7, 0xc2, 0xb3, 0x0d, 0xf3, 0xda, 0xa0, 0x9a, 0x65, - 0x23, 0x7b, 0xb6, 0x20, 0x73, 0x95, 0xc5, 0xfe, 0x70, 0x72, 0xd1, 0xd6, 0x4e, 0x2f, 0xda, 0xda, - 0xdf, 0x8b, 0xb6, 0xf6, 0xed, 0xb2, 0xdd, 0x38, 0xbd, 0x6c, 0x37, 0xfe, 0x5c, 0xb6, 0x1b, 0x9f, - 0x6f, 0x90, 0xc0, 0xbc, 0xfe, 0x77, 0x21, 0xe3, 0xe8, 0x37, 0x65, 0xc6, 0xb7, 0xff, 0x05, 0x00, - 0x00, 0xff, 0xff, 0xc6, 0x9f, 0xaa, 0x8d, 0x51, 0x04, 0x00, 0x00, + // 658 bytes of a gzipped FileDescriptorProto + 0x1f,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xcc, 0x78, 0x2d, 0x09, 0xcf, 0xca, 0xdf, 0x7f, 0xd4, 0x4b, + 0x9b, 0x80, 0xaa, 0x6d, 0xc1, 0x12, 0xe8, 0xe4, 0x0b, 0xa7, 0xa1, 0xd9, 0x3e, 0x24, 0x69, 0x5a, + 0x4d, 0x91, 0x2f, 0xb2, 0x38, 0xaa, 0xcf, 0x51, 0x25, 0xdb, 0x76, 0xb9, 0x24, 0xf3, 0x8f, 0xee, + 0x18, 0x97, 0xae, 0xbb, 0x91, 0x19, 0x59, 0xe5, 0xf4, 0xfd, 0xd8, 0xb9, 0xc4, 0x7a, 0x77, 0x7c, + 0x5e, 0x53, 0x4e, 0xce, 0x6b, 0xca, 0x9f, 0xf3, 0x9a, 0xf2, 0x6d, 0x54, 0x2b, 0x9d, 0x8c, 0x6a, + 0xa5, 0xdf, 0xa3, 0x5a, 0xe9, 0xe3, 0x15, 0xf6, 0x78, 0x30, 0xfd, 0xd1, 0x91, 0x4b, 0xed, 0x56, + 0xe4, 0x97, 0x62, 0xfb, 0x5f, 0x00, 0x00, 0x00, 0xff, 0xff, 0xdc, 0xd0, 0x43, 0xb7, 0x97, 0x04, + 0x00, 0x00, } func (m *Params) Marshal() (dAtA []byte, err error) { @@ -299,8 +313,13 @@ func (m *Params) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l - if m.MaxActiveFinalityProviders != 0 { - i = encodeVarintParams(dAtA, i, uint64(m.MaxActiveFinalityProviders)) + if m.AllowListExpirationHeight != 0 { + i = encodeVarintParams(dAtA, i, uint64(m.AllowListExpirationHeight)) + i-- + dAtA[i] = 0x70 + } + if m.DelegationCreationBaseGasFee != 0 { + i = encodeVarintParams(dAtA, i, uint64(m.DelegationCreationBaseGasFee)) i-- dAtA[i] = 0x68 } @@ -481,8 +500,11 @@ func (m *Params) Size() (n int) { } l = m.MinCommissionRate.Size() n += 1 + l + sovParams(uint64(l)) - if m.MaxActiveFinalityProviders != 0 { - n += 1 + sovParams(uint64(m.MaxActiveFinalityProviders)) + if m.DelegationCreationBaseGasFee != 0 { + n += 1 + sovParams(uint64(m.DelegationCreationBaseGasFee)) + } + if m.AllowListExpirationHeight != 0 { + n += 1 + sovParams(uint64(m.AllowListExpirationHeight)) } return n } @@ -827,9 +849,28 @@ func (m *Params) Unmarshal(dAtA []byte) error { iNdEx = postIndex case 13: if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field MaxActiveFinalityProviders", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field DelegationCreationBaseGasFee", wireType) + } + m.DelegationCreationBaseGasFee = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowParams + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.DelegationCreationBaseGasFee |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 14: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field AllowListExpirationHeight", wireType) } - m.MaxActiveFinalityProviders = 0 + m.AllowListExpirationHeight = 0 for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowParams @@ -839,7 +880,7 @@ func (m *Params) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - m.MaxActiveFinalityProviders |= uint32(b&0x7F) << shift + m.AllowListExpirationHeight |= uint64(b&0x7F) << shift if b < 0x80 { break } diff --git a/x/btcstaking/types/pop.go b/x/btcstaking/types/pop.go index 004b31ca1..bbfbaafc1 100644 --- a/x/btcstaking/types/pop.go +++ b/x/btcstaking/types/pop.go @@ -284,7 +284,7 @@ func VerifyBIP322SigPop( net *chaincfg.Params, ) error { if len(msg) == 0 || len(address) == 0 || len(signature) == 0 || len(pubKeyNoCoord) == 0 { - return fmt.Errorf("cannot verfiy bip322 signature. One of the required parameters is empty") + return fmt.Errorf("cannot verify bip322 signature. One of the required parameters is empty") } witness, err := bip322.SimpleSigToWitness(signature) diff --git a/x/btcstaking/types/pop_test.go b/x/btcstaking/types/pop_test.go index 86bd8ceff..0c77a3cb7 100644 --- a/x/btcstaking/types/pop_test.go +++ b/x/btcstaking/types/pop_test.go @@ -320,7 +320,7 @@ func TestPoPBTCVerify(t *testing.T) { BtcSigType: types.BTCSigType_BIP322, BtcSig: nil, }, - fmt.Errorf("failed to verify possession of babylon sig by the BTC key: cannot verfiy bip322 signature. One of the required parameters is empty"), + fmt.Errorf("failed to verify possession of babylon sig by the BTC key: cannot verify bip322 signature. One of the required parameters is empty"), }, { "invalid: nil signed msg", diff --git a/x/btcstaking/types/query.go b/x/btcstaking/types/query.go index d5dee31c4..eff648127 100644 --- a/x/btcstaking/types/query.go +++ b/x/btcstaking/types/query.go @@ -4,12 +4,25 @@ import ( "encoding/hex" ) +func delegatorUnbondingInfoToResponse(ui *DelegatorUnbondingInfo) *DelegatorUnbondingInfoResponse { + var spendStakeTxHex = "" + + if len(ui.SpendStakeTx) > 0 { + spendStakeTxHex = hex.EncodeToString(ui.SpendStakeTx) + } + + return &DelegatorUnbondingInfoResponse{ + SpendStakeTxHex: spendStakeTxHex, + } +} + // NewBTCDelegationResponse returns a new delegation response structure. func NewBTCDelegationResponse(btcDel *BTCDelegation, status BTCDelegationStatus) (resp *BTCDelegationResponse) { resp = &BTCDelegationResponse{ StakerAddr: btcDel.StakerAddr, BtcPk: btcDel.BtcPk, FpBtcPkList: btcDel.FpBtcPkList, + StakingTime: btcDel.StakingTime, StartHeight: btcDel.StartHeight, EndHeight: btcDel.EndHeight, TotalSat: btcDel.TotalSat, @@ -43,8 +56,8 @@ func (ud *BTCUndelegation) ToResponse() (resp *BTCUndelegationResponse) { CovenantSlashingSigs: ud.CovenantSlashingSigs, } - if ud.DelegatorUnbondingSig != nil { - resp.DelegatorUnbondingSigHex = ud.DelegatorUnbondingSig.ToHexStr() + if ud.DelegatorUnbondingInfo != nil { + resp.DelegatorUnbondingInfoResponse = delegatorUnbondingInfoToResponse(ud.DelegatorUnbondingInfo) } if ud.SlashingTx != nil { resp.SlashingTxHex = ud.SlashingTx.ToHexStr() @@ -56,8 +69,8 @@ func (ud *BTCUndelegation) ToResponse() (resp *BTCUndelegationResponse) { return resp } -// NewFinalityProviderResponse creates a new finality provider response based on the finality provider and his voting power. -func NewFinalityProviderResponse(f *FinalityProvider, bbnBlockHeight, votingPower uint64) *FinalityProviderResponse { +// NewFinalityProviderResponse creates a new finality provider response based on the finality provider +func NewFinalityProviderResponse(f *FinalityProvider, bbnBlockHeight uint64) *FinalityProviderResponse { return &FinalityProviderResponse{ Description: f.Description, Commission: f.Commission, @@ -68,6 +81,5 @@ func NewFinalityProviderResponse(f *FinalityProvider, bbnBlockHeight, votingPowe SlashedBtcHeight: f.SlashedBtcHeight, Jailed: f.Jailed, Height: bbnBlockHeight, - VotingPower: votingPower, } } diff --git a/x/btcstaking/types/query.pb.go b/x/btcstaking/types/query.pb.go index 91b814236..8ed1ef4bc 100644 --- a/x/btcstaking/types/query.pb.go +++ b/x/btcstaking/types/query.pb.go @@ -515,33 +515,31 @@ func (m *QueryBTCDelegationsResponse) GetPagination() *query.PageResponse { return nil } -// QueryFinalityProviderPowerAtHeightRequest is the request type for the -// Query/FinalityProviderPowerAtHeight RPC method. -type QueryFinalityProviderPowerAtHeightRequest struct { - // fp_btc_pk_hex is the hex str of Bitcoin secp256k1 PK of the finality provider that +// QueryFinalityProviderDelegationsRequest is the request type for the +// Query/FinalityProviderDelegations RPC method. +type QueryFinalityProviderDelegationsRequest struct { + // fp_btc_pk_hex is the hex str of Bitcoin secp256k1 PK of the finality providerthat // this BTC delegation delegates to // the PK follows encoding in BIP-340 spec FpBtcPkHex string `protobuf:"bytes,1,opt,name=fp_btc_pk_hex,json=fpBtcPkHex,proto3" json:"fp_btc_pk_hex,omitempty"` - // height is used for querying the given finality provider's voting power at this height - Height uint64 `protobuf:"varint,2,opt,name=height,proto3" json:"height,omitempty"` + // pagination defines an optional pagination for the request. + Pagination *query.PageRequest `protobuf:"bytes,2,opt,name=pagination,proto3" json:"pagination,omitempty"` } -func (m *QueryFinalityProviderPowerAtHeightRequest) Reset() { - *m = QueryFinalityProviderPowerAtHeightRequest{} -} -func (m *QueryFinalityProviderPowerAtHeightRequest) String() string { - return proto.CompactTextString(m) +func (m *QueryFinalityProviderDelegationsRequest) Reset() { + *m = QueryFinalityProviderDelegationsRequest{} } -func (*QueryFinalityProviderPowerAtHeightRequest) ProtoMessage() {} -func (*QueryFinalityProviderPowerAtHeightRequest) Descriptor() ([]byte, []int) { +func (m *QueryFinalityProviderDelegationsRequest) String() string { return proto.CompactTextString(m) } +func (*QueryFinalityProviderDelegationsRequest) ProtoMessage() {} +func (*QueryFinalityProviderDelegationsRequest) Descriptor() ([]byte, []int) { return fileDescriptor_74d49d26f7429697, []int{10} } -func (m *QueryFinalityProviderPowerAtHeightRequest) XXX_Unmarshal(b []byte) error { +func (m *QueryFinalityProviderDelegationsRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } -func (m *QueryFinalityProviderPowerAtHeightRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { +func (m *QueryFinalityProviderDelegationsRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { - return xxx_messageInfo_QueryFinalityProviderPowerAtHeightRequest.Marshal(b, m, deterministic) + return xxx_messageInfo_QueryFinalityProviderDelegationsRequest.Marshal(b, m, deterministic) } else { b = b[:cap(b)] n, err := m.MarshalToSizedBuffer(b) @@ -551,55 +549,55 @@ func (m *QueryFinalityProviderPowerAtHeightRequest) XXX_Marshal(b []byte, determ return b[:n], nil } } -func (m *QueryFinalityProviderPowerAtHeightRequest) XXX_Merge(src proto.Message) { - xxx_messageInfo_QueryFinalityProviderPowerAtHeightRequest.Merge(m, src) +func (m *QueryFinalityProviderDelegationsRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryFinalityProviderDelegationsRequest.Merge(m, src) } -func (m *QueryFinalityProviderPowerAtHeightRequest) XXX_Size() int { +func (m *QueryFinalityProviderDelegationsRequest) XXX_Size() int { return m.Size() } -func (m *QueryFinalityProviderPowerAtHeightRequest) XXX_DiscardUnknown() { - xxx_messageInfo_QueryFinalityProviderPowerAtHeightRequest.DiscardUnknown(m) +func (m *QueryFinalityProviderDelegationsRequest) XXX_DiscardUnknown() { + xxx_messageInfo_QueryFinalityProviderDelegationsRequest.DiscardUnknown(m) } -var xxx_messageInfo_QueryFinalityProviderPowerAtHeightRequest proto.InternalMessageInfo +var xxx_messageInfo_QueryFinalityProviderDelegationsRequest proto.InternalMessageInfo -func (m *QueryFinalityProviderPowerAtHeightRequest) GetFpBtcPkHex() string { +func (m *QueryFinalityProviderDelegationsRequest) GetFpBtcPkHex() string { if m != nil { return m.FpBtcPkHex } return "" } -func (m *QueryFinalityProviderPowerAtHeightRequest) GetHeight() uint64 { +func (m *QueryFinalityProviderDelegationsRequest) GetPagination() *query.PageRequest { if m != nil { - return m.Height + return m.Pagination } - return 0 + return nil } -// QueryFinalityProviderPowerAtHeightResponse is the response type for the -// Query/FinalityProviderPowerAtHeight RPC method. -type QueryFinalityProviderPowerAtHeightResponse struct { - // voting_power is the voting power of the finality provider - VotingPower uint64 `protobuf:"varint,1,opt,name=voting_power,json=votingPower,proto3" json:"voting_power,omitempty"` +// QueryFinalityProviderDelegationsResponse is the response type for the +// Query/FinalityProviderDelegations RPC method. +type QueryFinalityProviderDelegationsResponse struct { + // btc_delegator_delegations contains all the queried BTC delegations. + BtcDelegatorDelegations []*BTCDelegatorDelegationsResponse `protobuf:"bytes,1,rep,name=btc_delegator_delegations,json=btcDelegatorDelegations,proto3" json:"btc_delegator_delegations,omitempty"` + // pagination defines the pagination in the response. + Pagination *query.PageResponse `protobuf:"bytes,2,opt,name=pagination,proto3" json:"pagination,omitempty"` } -func (m *QueryFinalityProviderPowerAtHeightResponse) Reset() { - *m = QueryFinalityProviderPowerAtHeightResponse{} -} -func (m *QueryFinalityProviderPowerAtHeightResponse) String() string { - return proto.CompactTextString(m) +func (m *QueryFinalityProviderDelegationsResponse) Reset() { + *m = QueryFinalityProviderDelegationsResponse{} } -func (*QueryFinalityProviderPowerAtHeightResponse) ProtoMessage() {} -func (*QueryFinalityProviderPowerAtHeightResponse) Descriptor() ([]byte, []int) { +func (m *QueryFinalityProviderDelegationsResponse) String() string { return proto.CompactTextString(m) } +func (*QueryFinalityProviderDelegationsResponse) ProtoMessage() {} +func (*QueryFinalityProviderDelegationsResponse) Descriptor() ([]byte, []int) { return fileDescriptor_74d49d26f7429697, []int{11} } -func (m *QueryFinalityProviderPowerAtHeightResponse) XXX_Unmarshal(b []byte) error { +func (m *QueryFinalityProviderDelegationsResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } -func (m *QueryFinalityProviderPowerAtHeightResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { +func (m *QueryFinalityProviderDelegationsResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { - return xxx_messageInfo_QueryFinalityProviderPowerAtHeightResponse.Marshal(b, m, deterministic) + return xxx_messageInfo_QueryFinalityProviderDelegationsResponse.Marshal(b, m, deterministic) } else { b = b[:cap(b)] n, err := m.MarshalToSizedBuffer(b) @@ -609,48 +607,51 @@ func (m *QueryFinalityProviderPowerAtHeightResponse) XXX_Marshal(b []byte, deter return b[:n], nil } } -func (m *QueryFinalityProviderPowerAtHeightResponse) XXX_Merge(src proto.Message) { - xxx_messageInfo_QueryFinalityProviderPowerAtHeightResponse.Merge(m, src) +func (m *QueryFinalityProviderDelegationsResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryFinalityProviderDelegationsResponse.Merge(m, src) } -func (m *QueryFinalityProviderPowerAtHeightResponse) XXX_Size() int { +func (m *QueryFinalityProviderDelegationsResponse) XXX_Size() int { return m.Size() } -func (m *QueryFinalityProviderPowerAtHeightResponse) XXX_DiscardUnknown() { - xxx_messageInfo_QueryFinalityProviderPowerAtHeightResponse.DiscardUnknown(m) +func (m *QueryFinalityProviderDelegationsResponse) XXX_DiscardUnknown() { + xxx_messageInfo_QueryFinalityProviderDelegationsResponse.DiscardUnknown(m) } -var xxx_messageInfo_QueryFinalityProviderPowerAtHeightResponse proto.InternalMessageInfo +var xxx_messageInfo_QueryFinalityProviderDelegationsResponse proto.InternalMessageInfo -func (m *QueryFinalityProviderPowerAtHeightResponse) GetVotingPower() uint64 { +func (m *QueryFinalityProviderDelegationsResponse) GetBtcDelegatorDelegations() []*BTCDelegatorDelegationsResponse { if m != nil { - return m.VotingPower + return m.BtcDelegatorDelegations } - return 0 + return nil } -// QueryFinalityProviderCurrentPowerRequest is the request type for the -// Query/FinalityProviderCurrentPower RPC method. -type QueryFinalityProviderCurrentPowerRequest struct { - // fp_btc_pk_hex is the hex str of Bitcoin secp256k1 PK of the finality provider that - // this BTC delegation delegates to - // the PK follows encoding in BIP-340 spec - FpBtcPkHex string `protobuf:"bytes,1,opt,name=fp_btc_pk_hex,json=fpBtcPkHex,proto3" json:"fp_btc_pk_hex,omitempty"` +func (m *QueryFinalityProviderDelegationsResponse) GetPagination() *query.PageResponse { + if m != nil { + return m.Pagination + } + return nil } -func (m *QueryFinalityProviderCurrentPowerRequest) Reset() { - *m = QueryFinalityProviderCurrentPowerRequest{} +// QueryBTCDelegationRequest is the request type to retrieve a BTC delegation by +// staking tx hash +type QueryBTCDelegationRequest struct { + // Hash of staking transaction in btc format + StakingTxHashHex string `protobuf:"bytes,1,opt,name=staking_tx_hash_hex,json=stakingTxHashHex,proto3" json:"staking_tx_hash_hex,omitempty"` } -func (m *QueryFinalityProviderCurrentPowerRequest) String() string { return proto.CompactTextString(m) } -func (*QueryFinalityProviderCurrentPowerRequest) ProtoMessage() {} -func (*QueryFinalityProviderCurrentPowerRequest) Descriptor() ([]byte, []int) { + +func (m *QueryBTCDelegationRequest) Reset() { *m = QueryBTCDelegationRequest{} } +func (m *QueryBTCDelegationRequest) String() string { return proto.CompactTextString(m) } +func (*QueryBTCDelegationRequest) ProtoMessage() {} +func (*QueryBTCDelegationRequest) Descriptor() ([]byte, []int) { return fileDescriptor_74d49d26f7429697, []int{12} } -func (m *QueryFinalityProviderCurrentPowerRequest) XXX_Unmarshal(b []byte) error { +func (m *QueryBTCDelegationRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } -func (m *QueryFinalityProviderCurrentPowerRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { +func (m *QueryBTCDelegationRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { - return xxx_messageInfo_QueryFinalityProviderCurrentPowerRequest.Marshal(b, m, deterministic) + return xxx_messageInfo_QueryBTCDelegationRequest.Marshal(b, m, deterministic) } else { b = b[:cap(b)] n, err := m.MarshalToSizedBuffer(b) @@ -660,50 +661,44 @@ func (m *QueryFinalityProviderCurrentPowerRequest) XXX_Marshal(b []byte, determi return b[:n], nil } } -func (m *QueryFinalityProviderCurrentPowerRequest) XXX_Merge(src proto.Message) { - xxx_messageInfo_QueryFinalityProviderCurrentPowerRequest.Merge(m, src) +func (m *QueryBTCDelegationRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryBTCDelegationRequest.Merge(m, src) } -func (m *QueryFinalityProviderCurrentPowerRequest) XXX_Size() int { +func (m *QueryBTCDelegationRequest) XXX_Size() int { return m.Size() } -func (m *QueryFinalityProviderCurrentPowerRequest) XXX_DiscardUnknown() { - xxx_messageInfo_QueryFinalityProviderCurrentPowerRequest.DiscardUnknown(m) +func (m *QueryBTCDelegationRequest) XXX_DiscardUnknown() { + xxx_messageInfo_QueryBTCDelegationRequest.DiscardUnknown(m) } -var xxx_messageInfo_QueryFinalityProviderCurrentPowerRequest proto.InternalMessageInfo +var xxx_messageInfo_QueryBTCDelegationRequest proto.InternalMessageInfo -func (m *QueryFinalityProviderCurrentPowerRequest) GetFpBtcPkHex() string { +func (m *QueryBTCDelegationRequest) GetStakingTxHashHex() string { if m != nil { - return m.FpBtcPkHex + return m.StakingTxHashHex } return "" } -// QueryFinalityProviderCurrentPowerResponse is the response type for the -// Query/FinalityProviderCurrentPower RPC method. -type QueryFinalityProviderCurrentPowerResponse struct { - // height is the current height - Height uint64 `protobuf:"varint,1,opt,name=height,proto3" json:"height,omitempty"` - // voting_power is the voting power of the finality provider - VotingPower uint64 `protobuf:"varint,2,opt,name=voting_power,json=votingPower,proto3" json:"voting_power,omitempty"` +// QueryBTCDelegationResponse is response type matching QueryBTCDelegationRequest +// and containing BTC delegation information +type QueryBTCDelegationResponse struct { + // BTCDelegation represents the client needed information of an BTCDelegation. + BtcDelegation *BTCDelegationResponse `protobuf:"bytes,1,opt,name=btc_delegation,json=btcDelegation,proto3" json:"btc_delegation,omitempty"` } -func (m *QueryFinalityProviderCurrentPowerResponse) Reset() { - *m = QueryFinalityProviderCurrentPowerResponse{} -} -func (m *QueryFinalityProviderCurrentPowerResponse) String() string { - return proto.CompactTextString(m) -} -func (*QueryFinalityProviderCurrentPowerResponse) ProtoMessage() {} -func (*QueryFinalityProviderCurrentPowerResponse) Descriptor() ([]byte, []int) { +func (m *QueryBTCDelegationResponse) Reset() { *m = QueryBTCDelegationResponse{} } +func (m *QueryBTCDelegationResponse) String() string { return proto.CompactTextString(m) } +func (*QueryBTCDelegationResponse) ProtoMessage() {} +func (*QueryBTCDelegationResponse) Descriptor() ([]byte, []int) { return fileDescriptor_74d49d26f7429697, []int{13} } -func (m *QueryFinalityProviderCurrentPowerResponse) XXX_Unmarshal(b []byte) error { +func (m *QueryBTCDelegationResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } -func (m *QueryFinalityProviderCurrentPowerResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { +func (m *QueryBTCDelegationResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { - return xxx_messageInfo_QueryFinalityProviderCurrentPowerResponse.Marshal(b, m, deterministic) + return xxx_messageInfo_QueryBTCDelegationResponse.Marshal(b, m, deterministic) } else { b = b[:cap(b)] n, err := m.MarshalToSizedBuffer(b) @@ -713,57 +708,85 @@ func (m *QueryFinalityProviderCurrentPowerResponse) XXX_Marshal(b []byte, determ return b[:n], nil } } -func (m *QueryFinalityProviderCurrentPowerResponse) XXX_Merge(src proto.Message) { - xxx_messageInfo_QueryFinalityProviderCurrentPowerResponse.Merge(m, src) +func (m *QueryBTCDelegationResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryBTCDelegationResponse.Merge(m, src) } -func (m *QueryFinalityProviderCurrentPowerResponse) XXX_Size() int { +func (m *QueryBTCDelegationResponse) XXX_Size() int { return m.Size() } -func (m *QueryFinalityProviderCurrentPowerResponse) XXX_DiscardUnknown() { - xxx_messageInfo_QueryFinalityProviderCurrentPowerResponse.DiscardUnknown(m) +func (m *QueryBTCDelegationResponse) XXX_DiscardUnknown() { + xxx_messageInfo_QueryBTCDelegationResponse.DiscardUnknown(m) } -var xxx_messageInfo_QueryFinalityProviderCurrentPowerResponse proto.InternalMessageInfo - -func (m *QueryFinalityProviderCurrentPowerResponse) GetHeight() uint64 { - if m != nil { - return m.Height - } - return 0 -} +var xxx_messageInfo_QueryBTCDelegationResponse proto.InternalMessageInfo -func (m *QueryFinalityProviderCurrentPowerResponse) GetVotingPower() uint64 { +func (m *QueryBTCDelegationResponse) GetBtcDelegation() *BTCDelegationResponse { if m != nil { - return m.VotingPower + return m.BtcDelegation } - return 0 + return nil } -// QueryActiveFinalityProvidersAtHeightRequest is the request type for the -// Query/ActiveFinalityProvidersAtHeight RPC method. -type QueryActiveFinalityProvidersAtHeightRequest struct { - // height defines at which Babylon height to query the finality providers info. - Height uint64 `protobuf:"varint,1,opt,name=height,proto3" json:"height,omitempty"` - // pagination defines an optional pagination for the request. - Pagination *query.PageRequest `protobuf:"bytes,2,opt,name=pagination,proto3" json:"pagination,omitempty"` +// BTCDelegationResponse is the client needed information from a BTCDelegation with the current status based on parameters. +type BTCDelegationResponse struct { + // staker_addr is the address to receive rewards from BTC delegation. + StakerAddr string `protobuf:"bytes,1,opt,name=staker_addr,json=stakerAddr,proto3" json:"staker_addr,omitempty"` + // btc_pk is the Bitcoin secp256k1 PK of this BTC delegation + // the PK follows encoding in BIP-340 spec + BtcPk *github_com_babylonlabs_io_babylon_types.BIP340PubKey `protobuf:"bytes,2,opt,name=btc_pk,json=btcPk,proto3,customtype=github.com/babylonlabs-io/babylon/types.BIP340PubKey" json:"btc_pk,omitempty"` + // fp_btc_pk_list is the list of BIP-340 PKs of the finality providers that + // this BTC delegation delegates to + FpBtcPkList []github_com_babylonlabs_io_babylon_types.BIP340PubKey `protobuf:"bytes,3,rep,name=fp_btc_pk_list,json=fpBtcPkList,proto3,customtype=github.com/babylonlabs-io/babylon/types.BIP340PubKey" json:"fp_btc_pk_list,omitempty"` + // staking_time is the number of blocks for which the delegation is locked on BTC chain + StakingTime uint32 `protobuf:"varint,4,opt,name=staking_time,json=stakingTime,proto3" json:"staking_time,omitempty"` + // start_height is the start BTC height of the BTC delegation + // it is the start BTC height of the timelock + StartHeight uint32 `protobuf:"varint,5,opt,name=start_height,json=startHeight,proto3" json:"start_height,omitempty"` + // end_height is the end height of the BTC delegation + // it is the end BTC height of the timelock - w + EndHeight uint32 `protobuf:"varint,6,opt,name=end_height,json=endHeight,proto3" json:"end_height,omitempty"` + // total_sat is the total amount of BTC stakes in this delegation + // quantified in satoshi + TotalSat uint64 `protobuf:"varint,7,opt,name=total_sat,json=totalSat,proto3" json:"total_sat,omitempty"` + // staking_tx_hex is the hex string of staking tx + StakingTxHex string `protobuf:"bytes,8,opt,name=staking_tx_hex,json=stakingTxHex,proto3" json:"staking_tx_hex,omitempty"` + // slashing_tx_hex is the hex string of slashing tx + SlashingTxHex string `protobuf:"bytes,9,opt,name=slashing_tx_hex,json=slashingTxHex,proto3" json:"slashing_tx_hex,omitempty"` + // delegator_slash_sig_hex is the signature on the slashing tx + // by the delegator (i.e., SK corresponding to btc_pk) as string hex. + // It will be a part of the witness for the staking tx output. + DelegatorSlashSigHex string `protobuf:"bytes,10,opt,name=delegator_slash_sig_hex,json=delegatorSlashSigHex,proto3" json:"delegator_slash_sig_hex,omitempty"` + // covenant_sigs is a list of adaptor signatures on the slashing tx + // by each covenant member + // It will be a part of the witness for the staking tx output. + CovenantSigs []*CovenantAdaptorSignatures `protobuf:"bytes,11,rep,name=covenant_sigs,json=covenantSigs,proto3" json:"covenant_sigs,omitempty"` + // staking_output_idx is the index of the staking output in the staking tx + StakingOutputIdx uint32 `protobuf:"varint,12,opt,name=staking_output_idx,json=stakingOutputIdx,proto3" json:"staking_output_idx,omitempty"` + // whether this delegation is active + Active bool `protobuf:"varint,13,opt,name=active,proto3" json:"active,omitempty"` + // descriptive status of current delegation. + StatusDesc string `protobuf:"bytes,14,opt,name=status_desc,json=statusDesc,proto3" json:"status_desc,omitempty"` + // unbonding_time used in unbonding output timelock path and in slashing transactions + // change outputs + UnbondingTime uint32 `protobuf:"varint,15,opt,name=unbonding_time,json=unbondingTime,proto3" json:"unbonding_time,omitempty"` + // undelegation_response is the undelegation info of this delegation. + UndelegationResponse *BTCUndelegationResponse `protobuf:"bytes,16,opt,name=undelegation_response,json=undelegationResponse,proto3" json:"undelegation_response,omitempty"` + // params version used to validate delegation + ParamsVersion uint32 `protobuf:"varint,17,opt,name=params_version,json=paramsVersion,proto3" json:"params_version,omitempty"` } -func (m *QueryActiveFinalityProvidersAtHeightRequest) Reset() { - *m = QueryActiveFinalityProvidersAtHeightRequest{} -} -func (m *QueryActiveFinalityProvidersAtHeightRequest) String() string { - return proto.CompactTextString(m) -} -func (*QueryActiveFinalityProvidersAtHeightRequest) ProtoMessage() {} -func (*QueryActiveFinalityProvidersAtHeightRequest) Descriptor() ([]byte, []int) { +func (m *BTCDelegationResponse) Reset() { *m = BTCDelegationResponse{} } +func (m *BTCDelegationResponse) String() string { return proto.CompactTextString(m) } +func (*BTCDelegationResponse) ProtoMessage() {} +func (*BTCDelegationResponse) Descriptor() ([]byte, []int) { return fileDescriptor_74d49d26f7429697, []int{14} } -func (m *QueryActiveFinalityProvidersAtHeightRequest) XXX_Unmarshal(b []byte) error { +func (m *BTCDelegationResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } -func (m *QueryActiveFinalityProvidersAtHeightRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { +func (m *BTCDelegationResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { - return xxx_messageInfo_QueryActiveFinalityProvidersAtHeightRequest.Marshal(b, m, deterministic) + return xxx_messageInfo_BTCDelegationResponse.Marshal(b, m, deterministic) } else { b = b[:cap(b)] n, err := m.MarshalToSizedBuffer(b) @@ -773,108 +796,143 @@ func (m *QueryActiveFinalityProvidersAtHeightRequest) XXX_Marshal(b []byte, dete return b[:n], nil } } -func (m *QueryActiveFinalityProvidersAtHeightRequest) XXX_Merge(src proto.Message) { - xxx_messageInfo_QueryActiveFinalityProvidersAtHeightRequest.Merge(m, src) +func (m *BTCDelegationResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_BTCDelegationResponse.Merge(m, src) } -func (m *QueryActiveFinalityProvidersAtHeightRequest) XXX_Size() int { +func (m *BTCDelegationResponse) XXX_Size() int { return m.Size() } -func (m *QueryActiveFinalityProvidersAtHeightRequest) XXX_DiscardUnknown() { - xxx_messageInfo_QueryActiveFinalityProvidersAtHeightRequest.DiscardUnknown(m) +func (m *BTCDelegationResponse) XXX_DiscardUnknown() { + xxx_messageInfo_BTCDelegationResponse.DiscardUnknown(m) } -var xxx_messageInfo_QueryActiveFinalityProvidersAtHeightRequest proto.InternalMessageInfo +var xxx_messageInfo_BTCDelegationResponse proto.InternalMessageInfo -func (m *QueryActiveFinalityProvidersAtHeightRequest) GetHeight() uint64 { +func (m *BTCDelegationResponse) GetStakerAddr() string { if m != nil { - return m.Height + return m.StakerAddr + } + return "" +} + +func (m *BTCDelegationResponse) GetStakingTime() uint32 { + if m != nil { + return m.StakingTime } return 0 } -func (m *QueryActiveFinalityProvidersAtHeightRequest) GetPagination() *query.PageRequest { +func (m *BTCDelegationResponse) GetStartHeight() uint32 { if m != nil { - return m.Pagination + return m.StartHeight } - return nil + return 0 } -// QueryActiveFinalityProvidersAtHeightResponse is the response type for the -// Query/ActiveFinalityProvidersAtHeight RPC method. -type QueryActiveFinalityProvidersAtHeightResponse struct { - // finality_providers contains all the queried finality providersn. - FinalityProviders []*FinalityProviderWithMeta `protobuf:"bytes,1,rep,name=finality_providers,json=finalityProviders,proto3" json:"finality_providers,omitempty"` - // pagination defines the pagination in the response. - Pagination *query.PageResponse `protobuf:"bytes,2,opt,name=pagination,proto3" json:"pagination,omitempty"` +func (m *BTCDelegationResponse) GetEndHeight() uint32 { + if m != nil { + return m.EndHeight + } + return 0 } -func (m *QueryActiveFinalityProvidersAtHeightResponse) Reset() { - *m = QueryActiveFinalityProvidersAtHeightResponse{} +func (m *BTCDelegationResponse) GetTotalSat() uint64 { + if m != nil { + return m.TotalSat + } + return 0 } -func (m *QueryActiveFinalityProvidersAtHeightResponse) String() string { - return proto.CompactTextString(m) + +func (m *BTCDelegationResponse) GetStakingTxHex() string { + if m != nil { + return m.StakingTxHex + } + return "" } -func (*QueryActiveFinalityProvidersAtHeightResponse) ProtoMessage() {} -func (*QueryActiveFinalityProvidersAtHeightResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_74d49d26f7429697, []int{15} + +func (m *BTCDelegationResponse) GetSlashingTxHex() string { + if m != nil { + return m.SlashingTxHex + } + return "" } -func (m *QueryActiveFinalityProvidersAtHeightResponse) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) + +func (m *BTCDelegationResponse) GetDelegatorSlashSigHex() string { + if m != nil { + return m.DelegatorSlashSigHex + } + return "" } -func (m *QueryActiveFinalityProvidersAtHeightResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_QueryActiveFinalityProvidersAtHeightResponse.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 *BTCDelegationResponse) GetCovenantSigs() []*CovenantAdaptorSignatures { + if m != nil { + return m.CovenantSigs } + return nil } -func (m *QueryActiveFinalityProvidersAtHeightResponse) XXX_Merge(src proto.Message) { - xxx_messageInfo_QueryActiveFinalityProvidersAtHeightResponse.Merge(m, src) + +func (m *BTCDelegationResponse) GetStakingOutputIdx() uint32 { + if m != nil { + return m.StakingOutputIdx + } + return 0 } -func (m *QueryActiveFinalityProvidersAtHeightResponse) XXX_Size() int { - return m.Size() + +func (m *BTCDelegationResponse) GetActive() bool { + if m != nil { + return m.Active + } + return false } -func (m *QueryActiveFinalityProvidersAtHeightResponse) XXX_DiscardUnknown() { - xxx_messageInfo_QueryActiveFinalityProvidersAtHeightResponse.DiscardUnknown(m) + +func (m *BTCDelegationResponse) GetStatusDesc() string { + if m != nil { + return m.StatusDesc + } + return "" } -var xxx_messageInfo_QueryActiveFinalityProvidersAtHeightResponse proto.InternalMessageInfo +func (m *BTCDelegationResponse) GetUnbondingTime() uint32 { + if m != nil { + return m.UnbondingTime + } + return 0 +} -func (m *QueryActiveFinalityProvidersAtHeightResponse) GetFinalityProviders() []*FinalityProviderWithMeta { +func (m *BTCDelegationResponse) GetUndelegationResponse() *BTCUndelegationResponse { if m != nil { - return m.FinalityProviders + return m.UndelegationResponse } return nil } -func (m *QueryActiveFinalityProvidersAtHeightResponse) GetPagination() *query.PageResponse { +func (m *BTCDelegationResponse) GetParamsVersion() uint32 { if m != nil { - return m.Pagination + return m.ParamsVersion } - return nil + return 0 } -// QueryActivatedHeightRequest is the request type for the Query/ActivatedHeight RPC method. -type QueryActivatedHeightRequest struct { +// DelegatorUnbondingInfoResponse provides all necessary info about transaction +// which spent the staking output +type DelegatorUnbondingInfoResponse struct { + // spend_stake_tx_hex is the transaction which spent the staking output. It is + // filled only if the spend_stake_tx_hex is different than the unbonding_tx_hex + SpendStakeTxHex string `protobuf:"bytes,1,opt,name=spend_stake_tx_hex,json=spendStakeTxHex,proto3" json:"spend_stake_tx_hex,omitempty"` } -func (m *QueryActivatedHeightRequest) Reset() { *m = QueryActivatedHeightRequest{} } -func (m *QueryActivatedHeightRequest) String() string { return proto.CompactTextString(m) } -func (*QueryActivatedHeightRequest) ProtoMessage() {} -func (*QueryActivatedHeightRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_74d49d26f7429697, []int{16} +func (m *DelegatorUnbondingInfoResponse) Reset() { *m = DelegatorUnbondingInfoResponse{} } +func (m *DelegatorUnbondingInfoResponse) String() string { return proto.CompactTextString(m) } +func (*DelegatorUnbondingInfoResponse) ProtoMessage() {} +func (*DelegatorUnbondingInfoResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_74d49d26f7429697, []int{15} } -func (m *QueryActivatedHeightRequest) XXX_Unmarshal(b []byte) error { +func (m *DelegatorUnbondingInfoResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } -func (m *QueryActivatedHeightRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { +func (m *DelegatorUnbondingInfoResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { - return xxx_messageInfo_QueryActivatedHeightRequest.Marshal(b, m, deterministic) + return xxx_messageInfo_DelegatorUnbondingInfoResponse.Marshal(b, m, deterministic) } else { b = b[:cap(b)] n, err := m.MarshalToSizedBuffer(b) @@ -884,35 +942,62 @@ func (m *QueryActivatedHeightRequest) XXX_Marshal(b []byte, deterministic bool) return b[:n], nil } } -func (m *QueryActivatedHeightRequest) XXX_Merge(src proto.Message) { - xxx_messageInfo_QueryActivatedHeightRequest.Merge(m, src) +func (m *DelegatorUnbondingInfoResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_DelegatorUnbondingInfoResponse.Merge(m, src) } -func (m *QueryActivatedHeightRequest) XXX_Size() int { +func (m *DelegatorUnbondingInfoResponse) XXX_Size() int { return m.Size() } -func (m *QueryActivatedHeightRequest) XXX_DiscardUnknown() { - xxx_messageInfo_QueryActivatedHeightRequest.DiscardUnknown(m) +func (m *DelegatorUnbondingInfoResponse) XXX_DiscardUnknown() { + xxx_messageInfo_DelegatorUnbondingInfoResponse.DiscardUnknown(m) } -var xxx_messageInfo_QueryActivatedHeightRequest proto.InternalMessageInfo +var xxx_messageInfo_DelegatorUnbondingInfoResponse proto.InternalMessageInfo -// QueryActivatedHeightResponse is the response type for the Query/ActivatedHeight RPC method. -type QueryActivatedHeightResponse struct { - Height uint64 `protobuf:"varint,1,opt,name=height,proto3" json:"height,omitempty"` +func (m *DelegatorUnbondingInfoResponse) GetSpendStakeTxHex() string { + if m != nil { + return m.SpendStakeTxHex + } + return "" } -func (m *QueryActivatedHeightResponse) Reset() { *m = QueryActivatedHeightResponse{} } -func (m *QueryActivatedHeightResponse) String() string { return proto.CompactTextString(m) } -func (*QueryActivatedHeightResponse) ProtoMessage() {} -func (*QueryActivatedHeightResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_74d49d26f7429697, []int{17} +// BTCUndelegationResponse provides all necessary info about the undeleagation +type BTCUndelegationResponse struct { + // unbonding_tx is the transaction which will transfer the funds from staking + // output to unbonding output. Unbonding output will usually have lower timelock + // than staking output. The unbonding tx as string hex. + UnbondingTxHex string `protobuf:"bytes,1,opt,name=unbonding_tx_hex,json=unbondingTxHex,proto3" json:"unbonding_tx_hex,omitempty"` + // covenant_unbonding_sig_list is the list of signatures on the unbonding tx + // by covenant members + CovenantUnbondingSigList []*SignatureInfo `protobuf:"bytes,2,rep,name=covenant_unbonding_sig_list,json=covenantUnbondingSigList,proto3" json:"covenant_unbonding_sig_list,omitempty"` + // slashingTxHex is the hex string of slashing tx + SlashingTxHex string `protobuf:"bytes,3,opt,name=slashing_tx_hex,json=slashingTxHex,proto3" json:"slashing_tx_hex,omitempty"` + // delegator_slashing_sig is the signature on the slashing tx + // by the delegator (i.e., SK corresponding to btc_pk). + // It will be a part of the witness for the unbonding tx output. + // The delegator slashing sig as string hex. + DelegatorSlashingSigHex string `protobuf:"bytes,4,opt,name=delegator_slashing_sig_hex,json=delegatorSlashingSigHex,proto3" json:"delegator_slashing_sig_hex,omitempty"` + // covenant_slashing_sigs is a list of adaptor signatures on the + // unbonding slashing tx by each covenant member + // It will be a part of the witness for the staking tx output. + CovenantSlashingSigs []*CovenantAdaptorSignatures `protobuf:"bytes,5,rep,name=covenant_slashing_sigs,json=covenantSlashingSigs,proto3" json:"covenant_slashing_sigs,omitempty"` + // btc_undelegation_info contains all necessary info about the transaction + // which spent the staking output + DelegatorUnbondingInfoResponse *DelegatorUnbondingInfoResponse `protobuf:"bytes,6,opt,name=delegator_unbonding_info_response,json=delegatorUnbondingInfoResponse,proto3" json:"delegator_unbonding_info_response,omitempty"` } -func (m *QueryActivatedHeightResponse) XXX_Unmarshal(b []byte) error { + +func (m *BTCUndelegationResponse) Reset() { *m = BTCUndelegationResponse{} } +func (m *BTCUndelegationResponse) String() string { return proto.CompactTextString(m) } +func (*BTCUndelegationResponse) ProtoMessage() {} +func (*BTCUndelegationResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_74d49d26f7429697, []int{16} +} +func (m *BTCUndelegationResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } -func (m *QueryActivatedHeightResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { +func (m *BTCUndelegationResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { - return xxx_messageInfo_QueryActivatedHeightResponse.Marshal(b, m, deterministic) + return xxx_messageInfo_BTCUndelegationResponse.Marshal(b, m, deterministic) } else { b = b[:cap(b)] n, err := m.MarshalToSizedBuffer(b) @@ -922,108 +1007,77 @@ func (m *QueryActivatedHeightResponse) XXX_Marshal(b []byte, deterministic bool) return b[:n], nil } } -func (m *QueryActivatedHeightResponse) XXX_Merge(src proto.Message) { - xxx_messageInfo_QueryActivatedHeightResponse.Merge(m, src) +func (m *BTCUndelegationResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_BTCUndelegationResponse.Merge(m, src) } -func (m *QueryActivatedHeightResponse) XXX_Size() int { +func (m *BTCUndelegationResponse) XXX_Size() int { return m.Size() } -func (m *QueryActivatedHeightResponse) XXX_DiscardUnknown() { - xxx_messageInfo_QueryActivatedHeightResponse.DiscardUnknown(m) +func (m *BTCUndelegationResponse) XXX_DiscardUnknown() { + xxx_messageInfo_BTCUndelegationResponse.DiscardUnknown(m) } -var xxx_messageInfo_QueryActivatedHeightResponse proto.InternalMessageInfo +var xxx_messageInfo_BTCUndelegationResponse proto.InternalMessageInfo -func (m *QueryActivatedHeightResponse) GetHeight() uint64 { +func (m *BTCUndelegationResponse) GetUnbondingTxHex() string { if m != nil { - return m.Height + return m.UnbondingTxHex } - return 0 + return "" } -// QueryFinalityProviderDelegationsRequest is the request type for the -// Query/FinalityProviderDelegations RPC method. -type QueryFinalityProviderDelegationsRequest struct { - // fp_btc_pk_hex is the hex str of Bitcoin secp256k1 PK of the finality providerthat - // this BTC delegation delegates to - // the PK follows encoding in BIP-340 spec - FpBtcPkHex string `protobuf:"bytes,1,opt,name=fp_btc_pk_hex,json=fpBtcPkHex,proto3" json:"fp_btc_pk_hex,omitempty"` - // pagination defines an optional pagination for the request. - Pagination *query.PageRequest `protobuf:"bytes,2,opt,name=pagination,proto3" json:"pagination,omitempty"` +func (m *BTCUndelegationResponse) GetCovenantUnbondingSigList() []*SignatureInfo { + if m != nil { + return m.CovenantUnbondingSigList + } + return nil } -func (m *QueryFinalityProviderDelegationsRequest) Reset() { - *m = QueryFinalityProviderDelegationsRequest{} -} -func (m *QueryFinalityProviderDelegationsRequest) String() string { return proto.CompactTextString(m) } -func (*QueryFinalityProviderDelegationsRequest) ProtoMessage() {} -func (*QueryFinalityProviderDelegationsRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_74d49d26f7429697, []int{18} -} -func (m *QueryFinalityProviderDelegationsRequest) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *QueryFinalityProviderDelegationsRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_QueryFinalityProviderDelegationsRequest.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 *BTCUndelegationResponse) GetSlashingTxHex() string { + if m != nil { + return m.SlashingTxHex } + return "" } -func (m *QueryFinalityProviderDelegationsRequest) XXX_Merge(src proto.Message) { - xxx_messageInfo_QueryFinalityProviderDelegationsRequest.Merge(m, src) -} -func (m *QueryFinalityProviderDelegationsRequest) XXX_Size() int { - return m.Size() -} -func (m *QueryFinalityProviderDelegationsRequest) XXX_DiscardUnknown() { - xxx_messageInfo_QueryFinalityProviderDelegationsRequest.DiscardUnknown(m) -} - -var xxx_messageInfo_QueryFinalityProviderDelegationsRequest proto.InternalMessageInfo -func (m *QueryFinalityProviderDelegationsRequest) GetFpBtcPkHex() string { +func (m *BTCUndelegationResponse) GetDelegatorSlashingSigHex() string { if m != nil { - return m.FpBtcPkHex + return m.DelegatorSlashingSigHex } return "" } -func (m *QueryFinalityProviderDelegationsRequest) GetPagination() *query.PageRequest { +func (m *BTCUndelegationResponse) GetCovenantSlashingSigs() []*CovenantAdaptorSignatures { if m != nil { - return m.Pagination + return m.CovenantSlashingSigs } return nil } -// QueryFinalityProviderDelegationsResponse is the response type for the -// Query/FinalityProviderDelegations RPC method. -type QueryFinalityProviderDelegationsResponse struct { - // btc_delegator_delegations contains all the queried BTC delegations. - BtcDelegatorDelegations []*BTCDelegatorDelegationsResponse `protobuf:"bytes,1,rep,name=btc_delegator_delegations,json=btcDelegatorDelegations,proto3" json:"btc_delegator_delegations,omitempty"` - // pagination defines the pagination in the response. - Pagination *query.PageResponse `protobuf:"bytes,2,opt,name=pagination,proto3" json:"pagination,omitempty"` +func (m *BTCUndelegationResponse) GetDelegatorUnbondingInfoResponse() *DelegatorUnbondingInfoResponse { + if m != nil { + return m.DelegatorUnbondingInfoResponse + } + return nil } -func (m *QueryFinalityProviderDelegationsResponse) Reset() { - *m = QueryFinalityProviderDelegationsResponse{} +// BTCDelegatorDelegationsResponse is a collection of BTC delegations responses from the same delegator. +type BTCDelegatorDelegationsResponse struct { + Dels []*BTCDelegationResponse `protobuf:"bytes,1,rep,name=dels,proto3" json:"dels,omitempty"` } -func (m *QueryFinalityProviderDelegationsResponse) String() string { return proto.CompactTextString(m) } -func (*QueryFinalityProviderDelegationsResponse) ProtoMessage() {} -func (*QueryFinalityProviderDelegationsResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_74d49d26f7429697, []int{19} + +func (m *BTCDelegatorDelegationsResponse) Reset() { *m = BTCDelegatorDelegationsResponse{} } +func (m *BTCDelegatorDelegationsResponse) String() string { return proto.CompactTextString(m) } +func (*BTCDelegatorDelegationsResponse) ProtoMessage() {} +func (*BTCDelegatorDelegationsResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_74d49d26f7429697, []int{17} } -func (m *QueryFinalityProviderDelegationsResponse) XXX_Unmarshal(b []byte) error { +func (m *BTCDelegatorDelegationsResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } -func (m *QueryFinalityProviderDelegationsResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { +func (m *BTCDelegatorDelegationsResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { - return xxx_messageInfo_QueryFinalityProviderDelegationsResponse.Marshal(b, m, deterministic) + return xxx_messageInfo_BTCDelegatorDelegationsResponse.Marshal(b, m, deterministic) } else { b = b[:cap(b)] n, err := m.MarshalToSizedBuffer(b) @@ -1033,51 +1087,65 @@ func (m *QueryFinalityProviderDelegationsResponse) XXX_Marshal(b []byte, determi return b[:n], nil } } -func (m *QueryFinalityProviderDelegationsResponse) XXX_Merge(src proto.Message) { - xxx_messageInfo_QueryFinalityProviderDelegationsResponse.Merge(m, src) +func (m *BTCDelegatorDelegationsResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_BTCDelegatorDelegationsResponse.Merge(m, src) } -func (m *QueryFinalityProviderDelegationsResponse) XXX_Size() int { +func (m *BTCDelegatorDelegationsResponse) XXX_Size() int { return m.Size() } -func (m *QueryFinalityProviderDelegationsResponse) XXX_DiscardUnknown() { - xxx_messageInfo_QueryFinalityProviderDelegationsResponse.DiscardUnknown(m) +func (m *BTCDelegatorDelegationsResponse) XXX_DiscardUnknown() { + xxx_messageInfo_BTCDelegatorDelegationsResponse.DiscardUnknown(m) } -var xxx_messageInfo_QueryFinalityProviderDelegationsResponse proto.InternalMessageInfo - -func (m *QueryFinalityProviderDelegationsResponse) GetBtcDelegatorDelegations() []*BTCDelegatorDelegationsResponse { - if m != nil { - return m.BtcDelegatorDelegations - } - return nil -} +var xxx_messageInfo_BTCDelegatorDelegationsResponse proto.InternalMessageInfo -func (m *QueryFinalityProviderDelegationsResponse) GetPagination() *query.PageResponse { +func (m *BTCDelegatorDelegationsResponse) GetDels() []*BTCDelegationResponse { if m != nil { - return m.Pagination + return m.Dels } return nil } -// QueryBTCDelegationRequest is the request type to retrieve a BTC delegation by -// staking tx hash -type QueryBTCDelegationRequest struct { - // Hash of staking transaction in btc format - StakingTxHashHex string `protobuf:"bytes,1,opt,name=staking_tx_hash_hex,json=stakingTxHashHex,proto3" json:"staking_tx_hash_hex,omitempty"` +// FinalityProviderResponse defines a finality provider with voting power information. +type FinalityProviderResponse struct { + // description defines the description terms for the finality provider. + Description *types.Description `protobuf:"bytes,1,opt,name=description,proto3" json:"description,omitempty"` + // commission defines the commission rate of the finality provider. + Commission *cosmossdk_io_math.LegacyDec `protobuf:"bytes,2,opt,name=commission,proto3,customtype=cosmossdk.io/math.LegacyDec" json:"commission,omitempty"` + // addr is the address to receive commission from delegations. + Addr string `protobuf:"bytes,3,opt,name=addr,proto3" json:"addr,omitempty"` + // btc_pk is the Bitcoin secp256k1 PK of this finality provider + // the PK follows encoding in BIP-340 spec + BtcPk *github_com_babylonlabs_io_babylon_types.BIP340PubKey `protobuf:"bytes,4,opt,name=btc_pk,json=btcPk,proto3,customtype=github.com/babylonlabs-io/babylon/types.BIP340PubKey" json:"btc_pk,omitempty"` + // pop is the proof of possession of the BTC_PK by the fp addr. + // Essentially is the signature where the BTC SK sigs the fp addr. + Pop *ProofOfPossessionBTC `protobuf:"bytes,5,opt,name=pop,proto3" json:"pop,omitempty"` + // slashed_babylon_height indicates the Babylon height when + // the finality provider is slashed. + // if it's 0 then the finality provider is not slashed + SlashedBabylonHeight uint64 `protobuf:"varint,6,opt,name=slashed_babylon_height,json=slashedBabylonHeight,proto3" json:"slashed_babylon_height,omitempty"` + // slashed_btc_height indicates the BTC height when + // the finality provider is slashed. + // if it's 0 then the finality provider is not slashed + SlashedBtcHeight uint32 `protobuf:"varint,7,opt,name=slashed_btc_height,json=slashedBtcHeight,proto3" json:"slashed_btc_height,omitempty"` + // height is the queried Babylon height + Height uint64 `protobuf:"varint,8,opt,name=height,proto3" json:"height,omitempty"` + // jailed defines whether the finality provider is jailed + Jailed bool `protobuf:"varint,9,opt,name=jailed,proto3" json:"jailed,omitempty"` } -func (m *QueryBTCDelegationRequest) Reset() { *m = QueryBTCDelegationRequest{} } -func (m *QueryBTCDelegationRequest) String() string { return proto.CompactTextString(m) } -func (*QueryBTCDelegationRequest) ProtoMessage() {} -func (*QueryBTCDelegationRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_74d49d26f7429697, []int{20} +func (m *FinalityProviderResponse) Reset() { *m = FinalityProviderResponse{} } +func (m *FinalityProviderResponse) String() string { return proto.CompactTextString(m) } +func (*FinalityProviderResponse) ProtoMessage() {} +func (*FinalityProviderResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_74d49d26f7429697, []int{18} } -func (m *QueryBTCDelegationRequest) XXX_Unmarshal(b []byte) error { +func (m *FinalityProviderResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } -func (m *QueryBTCDelegationRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { +func (m *FinalityProviderResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { - return xxx_messageInfo_QueryBTCDelegationRequest.Marshal(b, m, deterministic) + return xxx_messageInfo_FinalityProviderResponse.Marshal(b, m, deterministic) } else { b = b[:cap(b)] n, err := m.MarshalToSizedBuffer(b) @@ -1087,934 +1155,399 @@ func (m *QueryBTCDelegationRequest) XXX_Marshal(b []byte, deterministic bool) ([ return b[:n], nil } } -func (m *QueryBTCDelegationRequest) XXX_Merge(src proto.Message) { - xxx_messageInfo_QueryBTCDelegationRequest.Merge(m, src) +func (m *FinalityProviderResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_FinalityProviderResponse.Merge(m, src) } -func (m *QueryBTCDelegationRequest) XXX_Size() int { +func (m *FinalityProviderResponse) XXX_Size() int { return m.Size() } -func (m *QueryBTCDelegationRequest) XXX_DiscardUnknown() { - xxx_messageInfo_QueryBTCDelegationRequest.DiscardUnknown(m) +func (m *FinalityProviderResponse) XXX_DiscardUnknown() { + xxx_messageInfo_FinalityProviderResponse.DiscardUnknown(m) } -var xxx_messageInfo_QueryBTCDelegationRequest proto.InternalMessageInfo +var xxx_messageInfo_FinalityProviderResponse proto.InternalMessageInfo -func (m *QueryBTCDelegationRequest) GetStakingTxHashHex() string { +func (m *FinalityProviderResponse) GetDescription() *types.Description { if m != nil { - return m.StakingTxHashHex + return m.Description } - return "" -} - -// QueryBTCDelegationResponse is response type matching QueryBTCDelegationRequest -// and containing BTC delegation information -type QueryBTCDelegationResponse struct { - // BTCDelegation represents the client needed information of an BTCDelegation. - BtcDelegation *BTCDelegationResponse `protobuf:"bytes,1,opt,name=btc_delegation,json=btcDelegation,proto3" json:"btc_delegation,omitempty"` + return nil } -func (m *QueryBTCDelegationResponse) Reset() { *m = QueryBTCDelegationResponse{} } -func (m *QueryBTCDelegationResponse) String() string { return proto.CompactTextString(m) } -func (*QueryBTCDelegationResponse) ProtoMessage() {} -func (*QueryBTCDelegationResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_74d49d26f7429697, []int{21} -} -func (m *QueryBTCDelegationResponse) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *QueryBTCDelegationResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_QueryBTCDelegationResponse.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 *FinalityProviderResponse) GetAddr() string { + if m != nil { + return m.Addr } -} -func (m *QueryBTCDelegationResponse) XXX_Merge(src proto.Message) { - xxx_messageInfo_QueryBTCDelegationResponse.Merge(m, src) -} -func (m *QueryBTCDelegationResponse) XXX_Size() int { - return m.Size() -} -func (m *QueryBTCDelegationResponse) XXX_DiscardUnknown() { - xxx_messageInfo_QueryBTCDelegationResponse.DiscardUnknown(m) + return "" } -var xxx_messageInfo_QueryBTCDelegationResponse proto.InternalMessageInfo - -func (m *QueryBTCDelegationResponse) GetBtcDelegation() *BTCDelegationResponse { +func (m *FinalityProviderResponse) GetPop() *ProofOfPossessionBTC { if m != nil { - return m.BtcDelegation + return m.Pop } return nil } -// BTCDelegationResponse is the client needed information from a BTCDelegation with the current status based on parameters. -type BTCDelegationResponse struct { - // staker_addr is the address to receive rewards from BTC delegation. - StakerAddr string `protobuf:"bytes,1,opt,name=staker_addr,json=stakerAddr,proto3" json:"staker_addr,omitempty"` - // btc_pk is the Bitcoin secp256k1 PK of this BTC delegation - // the PK follows encoding in BIP-340 spec - BtcPk *github_com_babylonlabs_io_babylon_types.BIP340PubKey `protobuf:"bytes,2,opt,name=btc_pk,json=btcPk,proto3,customtype=github.com/babylonlabs-io/babylon/types.BIP340PubKey" json:"btc_pk,omitempty"` - // fp_btc_pk_list is the list of BIP-340 PKs of the finality providers that - // this BTC delegation delegates to - FpBtcPkList []github_com_babylonlabs_io_babylon_types.BIP340PubKey `protobuf:"bytes,3,rep,name=fp_btc_pk_list,json=fpBtcPkList,proto3,customtype=github.com/babylonlabs-io/babylon/types.BIP340PubKey" json:"fp_btc_pk_list,omitempty"` - // start_height is the start BTC height of the BTC delegation - // it is the start BTC height of the timelock - StartHeight uint64 `protobuf:"varint,4,opt,name=start_height,json=startHeight,proto3" json:"start_height,omitempty"` - // end_height is the end height of the BTC delegation - // it is the end BTC height of the timelock - w - EndHeight uint64 `protobuf:"varint,5,opt,name=end_height,json=endHeight,proto3" json:"end_height,omitempty"` - // total_sat is the total amount of BTC stakes in this delegation - // quantified in satoshi - TotalSat uint64 `protobuf:"varint,6,opt,name=total_sat,json=totalSat,proto3" json:"total_sat,omitempty"` - // staking_tx_hex is the hex string of staking tx - StakingTxHex string `protobuf:"bytes,7,opt,name=staking_tx_hex,json=stakingTxHex,proto3" json:"staking_tx_hex,omitempty"` - // slashing_tx_hex is the hex string of slashing tx - SlashingTxHex string `protobuf:"bytes,8,opt,name=slashing_tx_hex,json=slashingTxHex,proto3" json:"slashing_tx_hex,omitempty"` - // delegator_slash_sig_hex is the signature on the slashing tx - // by the delegator (i.e., SK corresponding to btc_pk) as string hex. - // It will be a part of the witness for the staking tx output. - DelegatorSlashSigHex string `protobuf:"bytes,9,opt,name=delegator_slash_sig_hex,json=delegatorSlashSigHex,proto3" json:"delegator_slash_sig_hex,omitempty"` - // covenant_sigs is a list of adaptor signatures on the slashing tx - // by each covenant member - // It will be a part of the witness for the staking tx output. - CovenantSigs []*CovenantAdaptorSignatures `protobuf:"bytes,10,rep,name=covenant_sigs,json=covenantSigs,proto3" json:"covenant_sigs,omitempty"` - // staking_output_idx is the index of the staking output in the staking tx - StakingOutputIdx uint32 `protobuf:"varint,11,opt,name=staking_output_idx,json=stakingOutputIdx,proto3" json:"staking_output_idx,omitempty"` - // whether this delegation is active - Active bool `protobuf:"varint,12,opt,name=active,proto3" json:"active,omitempty"` - // descriptive status of current delegation. - StatusDesc string `protobuf:"bytes,13,opt,name=status_desc,json=statusDesc,proto3" json:"status_desc,omitempty"` - // unbonding_time used in unbonding output timelock path and in slashing transactions - // change outputs - UnbondingTime uint32 `protobuf:"varint,14,opt,name=unbonding_time,json=unbondingTime,proto3" json:"unbonding_time,omitempty"` - // undelegation_response is the undelegation info of this delegation. - UndelegationResponse *BTCUndelegationResponse `protobuf:"bytes,15,opt,name=undelegation_response,json=undelegationResponse,proto3" json:"undelegation_response,omitempty"` - // params version used to validate delegation - ParamsVersion uint32 `protobuf:"varint,16,opt,name=params_version,json=paramsVersion,proto3" json:"params_version,omitempty"` -} - -func (m *BTCDelegationResponse) Reset() { *m = BTCDelegationResponse{} } -func (m *BTCDelegationResponse) String() string { return proto.CompactTextString(m) } -func (*BTCDelegationResponse) ProtoMessage() {} -func (*BTCDelegationResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_74d49d26f7429697, []int{22} -} -func (m *BTCDelegationResponse) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *BTCDelegationResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_BTCDelegationResponse.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 *BTCDelegationResponse) XXX_Merge(src proto.Message) { - xxx_messageInfo_BTCDelegationResponse.Merge(m, src) -} -func (m *BTCDelegationResponse) XXX_Size() int { - return m.Size() -} -func (m *BTCDelegationResponse) XXX_DiscardUnknown() { - xxx_messageInfo_BTCDelegationResponse.DiscardUnknown(m) -} - -var xxx_messageInfo_BTCDelegationResponse proto.InternalMessageInfo - -func (m *BTCDelegationResponse) GetStakerAddr() string { +func (m *FinalityProviderResponse) GetSlashedBabylonHeight() uint64 { if m != nil { - return m.StakerAddr + return m.SlashedBabylonHeight } - return "" + return 0 } -func (m *BTCDelegationResponse) GetStartHeight() uint64 { +func (m *FinalityProviderResponse) GetSlashedBtcHeight() uint32 { if m != nil { - return m.StartHeight + return m.SlashedBtcHeight } return 0 } -func (m *BTCDelegationResponse) GetEndHeight() uint64 { +func (m *FinalityProviderResponse) GetHeight() uint64 { if m != nil { - return m.EndHeight + return m.Height } return 0 } -func (m *BTCDelegationResponse) GetTotalSat() uint64 { +func (m *FinalityProviderResponse) GetJailed() bool { if m != nil { - return m.TotalSat + return m.Jailed } - return 0 + return false } -func (m *BTCDelegationResponse) GetStakingTxHex() string { - if m != nil { - return m.StakingTxHex - } - return "" +func init() { + proto.RegisterType((*QueryParamsRequest)(nil), "babylon.btcstaking.v1.QueryParamsRequest") + proto.RegisterType((*QueryParamsResponse)(nil), "babylon.btcstaking.v1.QueryParamsResponse") + proto.RegisterType((*QueryParamsByVersionRequest)(nil), "babylon.btcstaking.v1.QueryParamsByVersionRequest") + proto.RegisterType((*QueryParamsByVersionResponse)(nil), "babylon.btcstaking.v1.QueryParamsByVersionResponse") + proto.RegisterType((*QueryFinalityProvidersRequest)(nil), "babylon.btcstaking.v1.QueryFinalityProvidersRequest") + proto.RegisterType((*QueryFinalityProvidersResponse)(nil), "babylon.btcstaking.v1.QueryFinalityProvidersResponse") + proto.RegisterType((*QueryFinalityProviderRequest)(nil), "babylon.btcstaking.v1.QueryFinalityProviderRequest") + proto.RegisterType((*QueryFinalityProviderResponse)(nil), "babylon.btcstaking.v1.QueryFinalityProviderResponse") + proto.RegisterType((*QueryBTCDelegationsRequest)(nil), "babylon.btcstaking.v1.QueryBTCDelegationsRequest") + proto.RegisterType((*QueryBTCDelegationsResponse)(nil), "babylon.btcstaking.v1.QueryBTCDelegationsResponse") + proto.RegisterType((*QueryFinalityProviderDelegationsRequest)(nil), "babylon.btcstaking.v1.QueryFinalityProviderDelegationsRequest") + proto.RegisterType((*QueryFinalityProviderDelegationsResponse)(nil), "babylon.btcstaking.v1.QueryFinalityProviderDelegationsResponse") + proto.RegisterType((*QueryBTCDelegationRequest)(nil), "babylon.btcstaking.v1.QueryBTCDelegationRequest") + proto.RegisterType((*QueryBTCDelegationResponse)(nil), "babylon.btcstaking.v1.QueryBTCDelegationResponse") + proto.RegisterType((*BTCDelegationResponse)(nil), "babylon.btcstaking.v1.BTCDelegationResponse") + proto.RegisterType((*DelegatorUnbondingInfoResponse)(nil), "babylon.btcstaking.v1.DelegatorUnbondingInfoResponse") + proto.RegisterType((*BTCUndelegationResponse)(nil), "babylon.btcstaking.v1.BTCUndelegationResponse") + proto.RegisterType((*BTCDelegatorDelegationsResponse)(nil), "babylon.btcstaking.v1.BTCDelegatorDelegationsResponse") + proto.RegisterType((*FinalityProviderResponse)(nil), "babylon.btcstaking.v1.FinalityProviderResponse") } -func (m *BTCDelegationResponse) GetSlashingTxHex() string { - if m != nil { - return m.SlashingTxHex - } - return "" +func init() { proto.RegisterFile("babylon/btcstaking/v1/query.proto", fileDescriptor_74d49d26f7429697) } + +var fileDescriptor_74d49d26f7429697 = []byte{ + // 1673 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x58, 0x4b, 0x6f, 0xdb, 0xca, + 0x15, 0x36, 0x6d, 0x59, 0xb1, 0x8f, 0x2c, 0xd9, 0x9e, 0xeb, 0xd8, 0x8c, 0x7c, 0x2d, 0x3b, 0x6a, + 0x6e, 0xe2, 0x3c, 0x2c, 0xc6, 0x8f, 0xf4, 0xb6, 0x08, 0x6e, 0xdb, 0xc8, 0xce, 0xab, 0x89, 0x1b, + 0x97, 0x8a, 0xbb, 0xe8, 0x4b, 0xa0, 0xc8, 0x11, 0xc5, 0x5a, 0x22, 0x19, 0xce, 0xc8, 0x90, 0x11, + 0x18, 0x28, 0xb2, 0xe8, 0xba, 0x40, 0xfb, 0x23, 0x02, 0x74, 0x53, 0xa0, 0xd9, 0x74, 0xd1, 0x7d, + 0xba, 0x0b, 0xd2, 0x4d, 0x91, 0x45, 0x50, 0x24, 0x05, 0xba, 0xea, 0xbe, 0xe8, 0xaa, 0xe0, 0xcc, + 0xf0, 0x21, 0x59, 0xb4, 0x2d, 0xd7, 0x3b, 0x71, 0xce, 0xfb, 0x9b, 0xef, 0xf0, 0xf0, 0x08, 0x2e, + 0xd7, 0xb4, 0xda, 0x41, 0xd3, 0xb1, 0x95, 0x1a, 0xd5, 0x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, 0x7e, 0x51, 0xb1, 0xc2, + 0xd1, 0x9f, 0x25, 0xc8, 0x76, 0x61, 0x88, 0x6e, 0x9f, 0x1a, 0xee, 0xa0, 0xa6, 0xd5, 0x01, 0x2c, + 0x44, 0x15, 0x9b, 0xac, 0x8a, 0x6f, 0xd0, 0xdd, 0x53, 0xdd, 0x0f, 0xbb, 0x9e, 0xde, 0x2d, 0xef, + 0xb0, 0xfc, 0xa3, 0xb7, 0x9f, 0x0a, 0xd2, 0xbb, 0x4f, 0x05, 0xe9, 0x1f, 0x9f, 0x0a, 0xd2, 0x6f, + 0x3f, 0x17, 0x86, 0xde, 0x7d, 0x2e, 0x0c, 0xfd, 0xfd, 0x73, 0x61, 0xe8, 0xa7, 0xa7, 0x18, 0x2a, + 0x9d, 0x78, 0x44, 0x36, 0x61, 0x6a, 0x69, 0xf6, 0xa7, 0xe2, 0xfa, 0xff, 0x02, 0x00, 0x00, 0xff, + 0xff, 0xd4, 0x91, 0x2b, 0x9a, 0x9e, 0x15, 0x00, 0x00, } -func (m *BTCDelegationResponse) GetDelegatorSlashSigHex() string { - if m != nil { - return m.DelegatorSlashSigHex - } - return "" +// Reference imports to suppress errors if they are not otherwise used. +var _ context.Context +var _ grpc.ClientConn + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the grpc package it is being compiled against. +const _ = grpc.SupportPackageIsVersion4 + +// QueryClient is the client API for Query service. +// +// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream. +type QueryClient interface { + // Parameters queries the parameters of the module. + Params(ctx context.Context, in *QueryParamsRequest, opts ...grpc.CallOption) (*QueryParamsResponse, error) + // ParamsByVersion queries the parameters of the module for a specific version of past params. + ParamsByVersion(ctx context.Context, in *QueryParamsByVersionRequest, opts ...grpc.CallOption) (*QueryParamsByVersionResponse, error) + // FinalityProviders queries all finality providers + FinalityProviders(ctx context.Context, in *QueryFinalityProvidersRequest, opts ...grpc.CallOption) (*QueryFinalityProvidersResponse, error) + // FinalityProvider info about one finality provider + FinalityProvider(ctx context.Context, in *QueryFinalityProviderRequest, opts ...grpc.CallOption) (*QueryFinalityProviderResponse, error) + // BTCDelegations queries all BTC delegations under a given status + BTCDelegations(ctx context.Context, in *QueryBTCDelegationsRequest, opts ...grpc.CallOption) (*QueryBTCDelegationsResponse, error) + // FinalityProviderDelegations queries all BTC delegations of the given finality provider + FinalityProviderDelegations(ctx context.Context, in *QueryFinalityProviderDelegationsRequest, opts ...grpc.CallOption) (*QueryFinalityProviderDelegationsResponse, error) + // BTCDelegation retrieves delegation by corresponding staking tx hash + BTCDelegation(ctx context.Context, in *QueryBTCDelegationRequest, opts ...grpc.CallOption) (*QueryBTCDelegationResponse, error) } -func (m *BTCDelegationResponse) GetCovenantSigs() []*CovenantAdaptorSignatures { - if m != nil { - return m.CovenantSigs - } - return nil +type queryClient struct { + cc grpc1.ClientConn } -func (m *BTCDelegationResponse) GetStakingOutputIdx() uint32 { - if m != nil { - return m.StakingOutputIdx - } - return 0 +func NewQueryClient(cc grpc1.ClientConn) QueryClient { + return &queryClient{cc} } -func (m *BTCDelegationResponse) GetActive() bool { - if m != nil { - return m.Active +func (c *queryClient) Params(ctx context.Context, in *QueryParamsRequest, opts ...grpc.CallOption) (*QueryParamsResponse, error) { + out := new(QueryParamsResponse) + err := c.cc.Invoke(ctx, "/babylon.btcstaking.v1.Query/Params", in, out, opts...) + if err != nil { + return nil, err } - return false + return out, nil } -func (m *BTCDelegationResponse) GetStatusDesc() string { - if m != nil { - return m.StatusDesc +func (c *queryClient) ParamsByVersion(ctx context.Context, in *QueryParamsByVersionRequest, opts ...grpc.CallOption) (*QueryParamsByVersionResponse, error) { + out := new(QueryParamsByVersionResponse) + err := c.cc.Invoke(ctx, "/babylon.btcstaking.v1.Query/ParamsByVersion", in, out, opts...) + if err != nil { + return nil, err } - return "" + return out, nil } -func (m *BTCDelegationResponse) GetUnbondingTime() uint32 { - if m != nil { - return m.UnbondingTime +func (c *queryClient) FinalityProviders(ctx context.Context, in *QueryFinalityProvidersRequest, opts ...grpc.CallOption) (*QueryFinalityProvidersResponse, error) { + out := new(QueryFinalityProvidersResponse) + err := c.cc.Invoke(ctx, "/babylon.btcstaking.v1.Query/FinalityProviders", in, out, opts...) + if err != nil { + return nil, err } - return 0 + return out, nil } -func (m *BTCDelegationResponse) GetUndelegationResponse() *BTCUndelegationResponse { - if m != nil { - return m.UndelegationResponse +func (c *queryClient) FinalityProvider(ctx context.Context, in *QueryFinalityProviderRequest, opts ...grpc.CallOption) (*QueryFinalityProviderResponse, error) { + out := new(QueryFinalityProviderResponse) + err := c.cc.Invoke(ctx, "/babylon.btcstaking.v1.Query/FinalityProvider", in, out, opts...) + if err != nil { + return nil, err } - return nil + return out, nil } -func (m *BTCDelegationResponse) GetParamsVersion() uint32 { - if m != nil { - return m.ParamsVersion +func (c *queryClient) BTCDelegations(ctx context.Context, in *QueryBTCDelegationsRequest, opts ...grpc.CallOption) (*QueryBTCDelegationsResponse, error) { + out := new(QueryBTCDelegationsResponse) + err := c.cc.Invoke(ctx, "/babylon.btcstaking.v1.Query/BTCDelegations", in, out, opts...) + if err != nil { + return nil, err } - return 0 + return out, nil } -// BTCUndelegationResponse provides all necessary info about the undeleagation -type BTCUndelegationResponse struct { - // unbonding_tx is the transaction which will transfer the funds from staking - // output to unbonding output. Unbonding output will usually have lower timelock - // than staking output. The unbonding tx as string hex. - UnbondingTxHex string `protobuf:"bytes,1,opt,name=unbonding_tx_hex,json=unbondingTxHex,proto3" json:"unbonding_tx_hex,omitempty"` - // delegator_unbonding_sig is the signature on the unbonding tx - // by the delegator (i.e., SK corresponding to btc_pk). - // It effectively proves that the delegator wants to unbond and thus - // Babylon will consider this BTC delegation unbonded. Delegator's BTC - // on Bitcoin will be unbonded after timelock. The unbonding delegator sig as string hex. - DelegatorUnbondingSigHex string `protobuf:"bytes,2,opt,name=delegator_unbonding_sig_hex,json=delegatorUnbondingSigHex,proto3" json:"delegator_unbonding_sig_hex,omitempty"` - // covenant_unbonding_sig_list is the list of signatures on the unbonding tx - // by covenant members - CovenantUnbondingSigList []*SignatureInfo `protobuf:"bytes,3,rep,name=covenant_unbonding_sig_list,json=covenantUnbondingSigList,proto3" json:"covenant_unbonding_sig_list,omitempty"` - // slashingTxHex is the hex string of slashing tx - SlashingTxHex string `protobuf:"bytes,4,opt,name=slashing_tx_hex,json=slashingTxHex,proto3" json:"slashing_tx_hex,omitempty"` - // delegator_slashing_sig is the signature on the slashing tx - // by the delegator (i.e., SK corresponding to btc_pk). - // It will be a part of the witness for the unbonding tx output. - // The delegator slashing sig as string hex. - DelegatorSlashingSigHex string `protobuf:"bytes,5,opt,name=delegator_slashing_sig_hex,json=delegatorSlashingSigHex,proto3" json:"delegator_slashing_sig_hex,omitempty"` - // covenant_slashing_sigs is a list of adaptor signatures on the - // unbonding slashing tx by each covenant member - // It will be a part of the witness for the staking tx output. - CovenantSlashingSigs []*CovenantAdaptorSignatures `protobuf:"bytes,6,rep,name=covenant_slashing_sigs,json=covenantSlashingSigs,proto3" json:"covenant_slashing_sigs,omitempty"` +func (c *queryClient) FinalityProviderDelegations(ctx context.Context, in *QueryFinalityProviderDelegationsRequest, opts ...grpc.CallOption) (*QueryFinalityProviderDelegationsResponse, error) { + out := new(QueryFinalityProviderDelegationsResponse) + err := c.cc.Invoke(ctx, "/babylon.btcstaking.v1.Query/FinalityProviderDelegations", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil } -func (m *BTCUndelegationResponse) Reset() { *m = BTCUndelegationResponse{} } -func (m *BTCUndelegationResponse) String() string { return proto.CompactTextString(m) } -func (*BTCUndelegationResponse) ProtoMessage() {} -func (*BTCUndelegationResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_74d49d26f7429697, []int{23} -} -func (m *BTCUndelegationResponse) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *BTCUndelegationResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_BTCUndelegationResponse.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 (c *queryClient) BTCDelegation(ctx context.Context, in *QueryBTCDelegationRequest, opts ...grpc.CallOption) (*QueryBTCDelegationResponse, error) { + out := new(QueryBTCDelegationResponse) + err := c.cc.Invoke(ctx, "/babylon.btcstaking.v1.Query/BTCDelegation", in, out, opts...) + if err != nil { + return nil, err } -} -func (m *BTCUndelegationResponse) XXX_Merge(src proto.Message) { - xxx_messageInfo_BTCUndelegationResponse.Merge(m, src) -} -func (m *BTCUndelegationResponse) XXX_Size() int { - return m.Size() -} -func (m *BTCUndelegationResponse) XXX_DiscardUnknown() { - xxx_messageInfo_BTCUndelegationResponse.DiscardUnknown(m) -} - -var xxx_messageInfo_BTCUndelegationResponse proto.InternalMessageInfo - -func (m *BTCUndelegationResponse) GetUnbondingTxHex() string { - if m != nil { - return m.UnbondingTxHex - } - return "" -} - -func (m *BTCUndelegationResponse) GetDelegatorUnbondingSigHex() string { - if m != nil { - return m.DelegatorUnbondingSigHex - } - return "" -} - -func (m *BTCUndelegationResponse) GetCovenantUnbondingSigList() []*SignatureInfo { - if m != nil { - return m.CovenantUnbondingSigList - } - return nil -} - -func (m *BTCUndelegationResponse) GetSlashingTxHex() string { - if m != nil { - return m.SlashingTxHex - } - return "" -} - -func (m *BTCUndelegationResponse) GetDelegatorSlashingSigHex() string { - if m != nil { - return m.DelegatorSlashingSigHex - } - return "" + return out, nil } -func (m *BTCUndelegationResponse) GetCovenantSlashingSigs() []*CovenantAdaptorSignatures { - if m != nil { - return m.CovenantSlashingSigs - } - return nil +// QueryServer is the server API for Query service. +type QueryServer interface { + // Parameters queries the parameters of the module. + Params(context.Context, *QueryParamsRequest) (*QueryParamsResponse, error) + // ParamsByVersion queries the parameters of the module for a specific version of past params. + ParamsByVersion(context.Context, *QueryParamsByVersionRequest) (*QueryParamsByVersionResponse, error) + // FinalityProviders queries all finality providers + FinalityProviders(context.Context, *QueryFinalityProvidersRequest) (*QueryFinalityProvidersResponse, error) + // FinalityProvider info about one finality provider + FinalityProvider(context.Context, *QueryFinalityProviderRequest) (*QueryFinalityProviderResponse, error) + // BTCDelegations queries all BTC delegations under a given status + BTCDelegations(context.Context, *QueryBTCDelegationsRequest) (*QueryBTCDelegationsResponse, error) + // FinalityProviderDelegations queries all BTC delegations of the given finality provider + FinalityProviderDelegations(context.Context, *QueryFinalityProviderDelegationsRequest) (*QueryFinalityProviderDelegationsResponse, error) + // BTCDelegation retrieves delegation by corresponding staking tx hash + BTCDelegation(context.Context, *QueryBTCDelegationRequest) (*QueryBTCDelegationResponse, error) } -// BTCDelegatorDelegationsResponse is a collection of BTC delegations responses from the same delegator. -type BTCDelegatorDelegationsResponse struct { - Dels []*BTCDelegationResponse `protobuf:"bytes,1,rep,name=dels,proto3" json:"dels,omitempty"` +// UnimplementedQueryServer can be embedded to have forward compatible implementations. +type UnimplementedQueryServer struct { } -func (m *BTCDelegatorDelegationsResponse) Reset() { *m = BTCDelegatorDelegationsResponse{} } -func (m *BTCDelegatorDelegationsResponse) String() string { return proto.CompactTextString(m) } -func (*BTCDelegatorDelegationsResponse) ProtoMessage() {} -func (*BTCDelegatorDelegationsResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_74d49d26f7429697, []int{24} +func (*UnimplementedQueryServer) Params(ctx context.Context, req *QueryParamsRequest) (*QueryParamsResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method Params not implemented") } -func (m *BTCDelegatorDelegationsResponse) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) +func (*UnimplementedQueryServer) ParamsByVersion(ctx context.Context, req *QueryParamsByVersionRequest) (*QueryParamsByVersionResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method ParamsByVersion not implemented") } -func (m *BTCDelegatorDelegationsResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_BTCDelegatorDelegationsResponse.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 (*UnimplementedQueryServer) FinalityProviders(ctx context.Context, req *QueryFinalityProvidersRequest) (*QueryFinalityProvidersResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method FinalityProviders not implemented") } -func (m *BTCDelegatorDelegationsResponse) XXX_Merge(src proto.Message) { - xxx_messageInfo_BTCDelegatorDelegationsResponse.Merge(m, src) +func (*UnimplementedQueryServer) FinalityProvider(ctx context.Context, req *QueryFinalityProviderRequest) (*QueryFinalityProviderResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method FinalityProvider not implemented") } -func (m *BTCDelegatorDelegationsResponse) XXX_Size() int { - return m.Size() +func (*UnimplementedQueryServer) BTCDelegations(ctx context.Context, req *QueryBTCDelegationsRequest) (*QueryBTCDelegationsResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method BTCDelegations not implemented") } -func (m *BTCDelegatorDelegationsResponse) XXX_DiscardUnknown() { - xxx_messageInfo_BTCDelegatorDelegationsResponse.DiscardUnknown(m) +func (*UnimplementedQueryServer) FinalityProviderDelegations(ctx context.Context, req *QueryFinalityProviderDelegationsRequest) (*QueryFinalityProviderDelegationsResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method FinalityProviderDelegations not implemented") } - -var xxx_messageInfo_BTCDelegatorDelegationsResponse proto.InternalMessageInfo - -func (m *BTCDelegatorDelegationsResponse) GetDels() []*BTCDelegationResponse { - if m != nil { - return m.Dels - } - return nil +func (*UnimplementedQueryServer) BTCDelegation(ctx context.Context, req *QueryBTCDelegationRequest) (*QueryBTCDelegationResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method BTCDelegation not implemented") } -// FinalityProviderResponse defines a finality provider with voting power information. -type FinalityProviderResponse struct { - // description defines the description terms for the finality provider. - Description *types.Description `protobuf:"bytes,1,opt,name=description,proto3" json:"description,omitempty"` - // commission defines the commission rate of the finality provider. - Commission *cosmossdk_io_math.LegacyDec `protobuf:"bytes,2,opt,name=commission,proto3,customtype=cosmossdk.io/math.LegacyDec" json:"commission,omitempty"` - // addr is the address to receive commission from delegations. - Addr string `protobuf:"bytes,3,opt,name=addr,proto3" json:"addr,omitempty"` - // btc_pk is the Bitcoin secp256k1 PK of this finality provider - // the PK follows encoding in BIP-340 spec - BtcPk *github_com_babylonlabs_io_babylon_types.BIP340PubKey `protobuf:"bytes,4,opt,name=btc_pk,json=btcPk,proto3,customtype=github.com/babylonlabs-io/babylon/types.BIP340PubKey" json:"btc_pk,omitempty"` - // pop is the proof of possession of the BTC_PK by the fp addr. - // Essentially is the signature where the BTC SK sigs the fp addr. - Pop *ProofOfPossessionBTC `protobuf:"bytes,5,opt,name=pop,proto3" json:"pop,omitempty"` - // slashed_babylon_height indicates the Babylon height when - // the finality provider is slashed. - // if it's 0 then the finality provider is not slashed - SlashedBabylonHeight uint64 `protobuf:"varint,6,opt,name=slashed_babylon_height,json=slashedBabylonHeight,proto3" json:"slashed_babylon_height,omitempty"` - // slashed_btc_height indicates the BTC height when - // the finality provider is slashed. - // if it's 0 then the finality provider is not slashed - SlashedBtcHeight uint64 `protobuf:"varint,7,opt,name=slashed_btc_height,json=slashedBtcHeight,proto3" json:"slashed_btc_height,omitempty"` - // height is the queried Babylon height - Height uint64 `protobuf:"varint,8,opt,name=height,proto3" json:"height,omitempty"` - // voting_power is the voting power of this finality provider at the given height - VotingPower uint64 `protobuf:"varint,9,opt,name=voting_power,json=votingPower,proto3" json:"voting_power,omitempty"` - // jailed defines whether the finality provider is jailed - Jailed bool `protobuf:"varint,10,opt,name=jailed,proto3" json:"jailed,omitempty"` +func RegisterQueryServer(s grpc1.Server, srv QueryServer) { + s.RegisterService(&_Query_serviceDesc, srv) } -func (m *FinalityProviderResponse) Reset() { *m = FinalityProviderResponse{} } -func (m *FinalityProviderResponse) String() string { return proto.CompactTextString(m) } -func (*FinalityProviderResponse) ProtoMessage() {} -func (*FinalityProviderResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_74d49d26f7429697, []int{25} -} -func (m *FinalityProviderResponse) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *FinalityProviderResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_FinalityProviderResponse.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 _Query_Params_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(QueryParamsRequest) + if err := dec(in); err != nil { + return nil, err } -} -func (m *FinalityProviderResponse) XXX_Merge(src proto.Message) { - xxx_messageInfo_FinalityProviderResponse.Merge(m, src) -} -func (m *FinalityProviderResponse) XXX_Size() int { - return m.Size() -} -func (m *FinalityProviderResponse) XXX_DiscardUnknown() { - xxx_messageInfo_FinalityProviderResponse.DiscardUnknown(m) -} - -var xxx_messageInfo_FinalityProviderResponse proto.InternalMessageInfo - -func (m *FinalityProviderResponse) GetDescription() *types.Description { - if m != nil { - return m.Description + if interceptor == nil { + return srv.(QueryServer).Params(ctx, in) } - return nil -} - -func (m *FinalityProviderResponse) GetAddr() string { - if m != nil { - return m.Addr + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/babylon.btcstaking.v1.Query/Params", } - return "" -} - -func (m *FinalityProviderResponse) GetPop() *ProofOfPossessionBTC { - if m != nil { - return m.Pop + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(QueryServer).Params(ctx, req.(*QueryParamsRequest)) } - return nil + return interceptor(ctx, in, info, handler) } -func (m *FinalityProviderResponse) GetSlashedBabylonHeight() uint64 { - if m != nil { - return m.SlashedBabylonHeight +func _Query_ParamsByVersion_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(QueryParamsByVersionRequest) + if err := dec(in); err != nil { + return nil, err } - return 0 -} - -func (m *FinalityProviderResponse) GetSlashedBtcHeight() uint64 { - if m != nil { - return m.SlashedBtcHeight + if interceptor == nil { + return srv.(QueryServer).ParamsByVersion(ctx, in) } - return 0 -} - -func (m *FinalityProviderResponse) GetHeight() uint64 { - if m != nil { - return m.Height + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/babylon.btcstaking.v1.Query/ParamsByVersion", } - return 0 -} - -func (m *FinalityProviderResponse) GetVotingPower() uint64 { - if m != nil { - return m.VotingPower + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(QueryServer).ParamsByVersion(ctx, req.(*QueryParamsByVersionRequest)) } - return 0 + return interceptor(ctx, in, info, handler) } -func (m *FinalityProviderResponse) GetJailed() bool { - if m != nil { - return m.Jailed +func _Query_FinalityProviders_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(QueryFinalityProvidersRequest) + if err := dec(in); err != nil { + return nil, err } - return false -} - -func init() { - proto.RegisterType((*QueryParamsRequest)(nil), "babylon.btcstaking.v1.QueryParamsRequest") - proto.RegisterType((*QueryParamsResponse)(nil), "babylon.btcstaking.v1.QueryParamsResponse") - proto.RegisterType((*QueryParamsByVersionRequest)(nil), "babylon.btcstaking.v1.QueryParamsByVersionRequest") - proto.RegisterType((*QueryParamsByVersionResponse)(nil), "babylon.btcstaking.v1.QueryParamsByVersionResponse") - proto.RegisterType((*QueryFinalityProvidersRequest)(nil), "babylon.btcstaking.v1.QueryFinalityProvidersRequest") - proto.RegisterType((*QueryFinalityProvidersResponse)(nil), "babylon.btcstaking.v1.QueryFinalityProvidersResponse") - proto.RegisterType((*QueryFinalityProviderRequest)(nil), "babylon.btcstaking.v1.QueryFinalityProviderRequest") - proto.RegisterType((*QueryFinalityProviderResponse)(nil), "babylon.btcstaking.v1.QueryFinalityProviderResponse") - proto.RegisterType((*QueryBTCDelegationsRequest)(nil), "babylon.btcstaking.v1.QueryBTCDelegationsRequest") - proto.RegisterType((*QueryBTCDelegationsResponse)(nil), "babylon.btcstaking.v1.QueryBTCDelegationsResponse") - proto.RegisterType((*QueryFinalityProviderPowerAtHeightRequest)(nil), "babylon.btcstaking.v1.QueryFinalityProviderPowerAtHeightRequest") - proto.RegisterType((*QueryFinalityProviderPowerAtHeightResponse)(nil), "babylon.btcstaking.v1.QueryFinalityProviderPowerAtHeightResponse") - proto.RegisterType((*QueryFinalityProviderCurrentPowerRequest)(nil), "babylon.btcstaking.v1.QueryFinalityProviderCurrentPowerRequest") - proto.RegisterType((*QueryFinalityProviderCurrentPowerResponse)(nil), "babylon.btcstaking.v1.QueryFinalityProviderCurrentPowerResponse") - proto.RegisterType((*QueryActiveFinalityProvidersAtHeightRequest)(nil), "babylon.btcstaking.v1.QueryActiveFinalityProvidersAtHeightRequest") - proto.RegisterType((*QueryActiveFinalityProvidersAtHeightResponse)(nil), "babylon.btcstaking.v1.QueryActiveFinalityProvidersAtHeightResponse") - proto.RegisterType((*QueryActivatedHeightRequest)(nil), "babylon.btcstaking.v1.QueryActivatedHeightRequest") - proto.RegisterType((*QueryActivatedHeightResponse)(nil), "babylon.btcstaking.v1.QueryActivatedHeightResponse") - proto.RegisterType((*QueryFinalityProviderDelegationsRequest)(nil), "babylon.btcstaking.v1.QueryFinalityProviderDelegationsRequest") - proto.RegisterType((*QueryFinalityProviderDelegationsResponse)(nil), "babylon.btcstaking.v1.QueryFinalityProviderDelegationsResponse") - proto.RegisterType((*QueryBTCDelegationRequest)(nil), "babylon.btcstaking.v1.QueryBTCDelegationRequest") - proto.RegisterType((*QueryBTCDelegationResponse)(nil), "babylon.btcstaking.v1.QueryBTCDelegationResponse") - proto.RegisterType((*BTCDelegationResponse)(nil), "babylon.btcstaking.v1.BTCDelegationResponse") - proto.RegisterType((*BTCUndelegationResponse)(nil), "babylon.btcstaking.v1.BTCUndelegationResponse") - proto.RegisterType((*BTCDelegatorDelegationsResponse)(nil), "babylon.btcstaking.v1.BTCDelegatorDelegationsResponse") - proto.RegisterType((*FinalityProviderResponse)(nil), "babylon.btcstaking.v1.FinalityProviderResponse") -} - -func init() { proto.RegisterFile("babylon/btcstaking/v1/query.proto", fileDescriptor_74d49d26f7429697) } - -var fileDescriptor_74d49d26f7429697 = []byte{ - // 1887 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xb4, 0x59, 0x4b, 0x6c, 0xdb, 0xc8, - 0x19, 0x0e, 0x6d, 0x45, 0x89, 0x7f, 0xd9, 0x8e, 0x33, 0xeb, 0x24, 0x8c, 0x1c, 0xdb, 0x09, 0x9b, - 0x4d, 0x9c, 0x87, 0xc5, 0x58, 0xf1, 0x6e, 0x1f, 0xdb, 0xdd, 0xc4, 0xb2, 0x77, 0x93, 0xec, 0xae, - 0x1b, 0x95, 0x4e, 0x5a, 0xa0, 0x2f, 0x81, 0x22, 0x47, 0x14, 0x1b, 0x89, 0xa3, 0x70, 0x46, 0xae, - 0x8c, 0xc0, 0x97, 0x1e, 0x7a, 0x2b, 0x50, 0xa0, 0xbd, 0xf6, 0x58, 0xb4, 0x40, 0x8f, 0xcd, 0xa9, - 0x40, 0xef, 0xdb, 0xdb, 0x22, 0x3d, 0x6c, 0xb1, 0x87, 0xa0, 0x48, 0x8a, 0x16, 0x28, 0xd0, 0x6b, - 0xcf, 0x05, 0x67, 0x86, 0x22, 0x25, 0x91, 0xb2, 0xe4, 0x78, 0x6f, 0xd6, 0xcc, 0xff, 0x9e, 0xef, - 0xff, 0x86, 0xf3, 0x1b, 0x2e, 0x55, 0xcd, 0xea, 0x5e, 0x83, 0x78, 0x7a, 0x95, 0x59, 0x94, 0x99, - 0x4f, 0x5c, 0xcf, 0xd1, 0x77, 0xd7, 0xf4, 0xa7, 0x6d, 0xec, 0xef, 0x15, 0x5a, 0x3e, 0x61, 0x04, - 0x9d, 0x91, 0x22, 0x85, 0x48, 0xa4, 0xb0,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f, 0x97, 0x38, 0xd9, 0xfc, 0x59, 0x81, 0x99, 0x1e, 0xde, 0x42, 0xb7, 0x46, 0xa6, 0xb8, 0x30, - 0xa7, 0xb5, 0x31, 0x34, 0x64, 0x16, 0x5b, 0x3c, 0x8b, 0x0f, 0xd0, 0xb7, 0x47, 0xe3, 0x44, 0xfd, - 0x59, 0xc2, 0x1c, 0x63, 0xbf, 0xf4, 0x9d, 0xcf, 0x5e, 0x2d, 0x29, 0x9f, 0xbf, 0x5a, 0x52, 0xfe, - 0xf1, 0x6a, 0x49, 0xf9, 0xd5, 0xeb, 0xa5, 0x63, 0x9f, 0xbf, 0x5e, 0x3a, 0xf6, 0xf7, 0xd7, 0x4b, - 0xc7, 0x7e, 0x30, 0xc2, 0xc7, 0x5e, 0x27, 0xee, 0x92, 0x7f, 0xf9, 0x55, 0xb3, 0xfc, 0xff, 0x4c, - 0xb7, 0xff, 0x1f, 0x00, 0x00, 0xff, 0xff, 0x5a, 0xfa, 0xfe, 0xb7, 0xb1, 0x1b, 0x00, 0x00, -} - -// Reference imports to suppress errors if they are not otherwise used. -var _ context.Context -var _ grpc.ClientConn - -// This is a compile-time assertion to ensure that this generated file -// is compatible with the grpc package it is being compiled against. -const _ = grpc.SupportPackageIsVersion4 - -// QueryClient is the client API for Query service. -// -// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream. -type QueryClient interface { - // Parameters queries the parameters of the module. - Params(ctx context.Context, in *QueryParamsRequest, opts ...grpc.CallOption) (*QueryParamsResponse, error) - // ParamsByVersion queries the parameters of the module for a specific version of past params. - ParamsByVersion(ctx context.Context, in *QueryParamsByVersionRequest, opts ...grpc.CallOption) (*QueryParamsByVersionResponse, error) - // FinalityProviders queries all finality providers - FinalityProviders(ctx context.Context, in *QueryFinalityProvidersRequest, opts ...grpc.CallOption) (*QueryFinalityProvidersResponse, error) - // FinalityProvider info about one finality provider - FinalityProvider(ctx context.Context, in *QueryFinalityProviderRequest, opts ...grpc.CallOption) (*QueryFinalityProviderResponse, error) - // BTCDelegations queries all BTC delegations under a given status - BTCDelegations(ctx context.Context, in *QueryBTCDelegationsRequest, opts ...grpc.CallOption) (*QueryBTCDelegationsResponse, error) - // ActiveFinalityProvidersAtHeight queries finality providers with non zero voting power at given height. - ActiveFinalityProvidersAtHeight(ctx context.Context, in *QueryActiveFinalityProvidersAtHeightRequest, opts ...grpc.CallOption) (*QueryActiveFinalityProvidersAtHeightResponse, error) - // FinalityProviderPowerAtHeight queries the voting power of a finality provider at a given height - FinalityProviderPowerAtHeight(ctx context.Context, in *QueryFinalityProviderPowerAtHeightRequest, opts ...grpc.CallOption) (*QueryFinalityProviderPowerAtHeightResponse, error) - // FinalityProviderCurrentPower queries the voting power of a finality provider at the current height - FinalityProviderCurrentPower(ctx context.Context, in *QueryFinalityProviderCurrentPowerRequest, opts ...grpc.CallOption) (*QueryFinalityProviderCurrentPowerResponse, error) - // ActivatedHeight queries the height when BTC staking protocol is activated, i.e., the first height when - // there exists 1 finality provider with voting power - ActivatedHeight(ctx context.Context, in *QueryActivatedHeightRequest, opts ...grpc.CallOption) (*QueryActivatedHeightResponse, error) - // FinalityProviderDelegations queries all BTC delegations of the given finality provider - FinalityProviderDelegations(ctx context.Context, in *QueryFinalityProviderDelegationsRequest, opts ...grpc.CallOption) (*QueryFinalityProviderDelegationsResponse, error) - // BTCDelegation retrieves delegation by corresponding staking tx hash - BTCDelegation(ctx context.Context, in *QueryBTCDelegationRequest, opts ...grpc.CallOption) (*QueryBTCDelegationResponse, error) -} - -type queryClient struct { - cc grpc1.ClientConn -} - -func NewQueryClient(cc grpc1.ClientConn) QueryClient { - return &queryClient{cc} -} - -func (c *queryClient) Params(ctx context.Context, in *QueryParamsRequest, opts ...grpc.CallOption) (*QueryParamsResponse, error) { - out := new(QueryParamsResponse) - err := c.cc.Invoke(ctx, "/babylon.btcstaking.v1.Query/Params", in, out, opts...) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *queryClient) ParamsByVersion(ctx context.Context, in *QueryParamsByVersionRequest, opts ...grpc.CallOption) (*QueryParamsByVersionResponse, error) { - out := new(QueryParamsByVersionResponse) - err := c.cc.Invoke(ctx, "/babylon.btcstaking.v1.Query/ParamsByVersion", in, out, opts...) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *queryClient) FinalityProviders(ctx context.Context, in *QueryFinalityProvidersRequest, opts ...grpc.CallOption) (*QueryFinalityProvidersResponse, error) { - out := new(QueryFinalityProvidersResponse) - err := c.cc.Invoke(ctx, "/babylon.btcstaking.v1.Query/FinalityProviders", in, out, opts...) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *queryClient) FinalityProvider(ctx context.Context, in *QueryFinalityProviderRequest, opts ...grpc.CallOption) (*QueryFinalityProviderResponse, error) { - out := new(QueryFinalityProviderResponse) - err := c.cc.Invoke(ctx, "/babylon.btcstaking.v1.Query/FinalityProvider", in, out, opts...) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *queryClient) BTCDelegations(ctx context.Context, in *QueryBTCDelegationsRequest, opts ...grpc.CallOption) (*QueryBTCDelegationsResponse, error) { - out := new(QueryBTCDelegationsResponse) - err := c.cc.Invoke(ctx, "/babylon.btcstaking.v1.Query/BTCDelegations", in, out, opts...) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *queryClient) ActiveFinalityProvidersAtHeight(ctx context.Context, in *QueryActiveFinalityProvidersAtHeightRequest, opts ...grpc.CallOption) (*QueryActiveFinalityProvidersAtHeightResponse, error) { - out := new(QueryActiveFinalityProvidersAtHeightResponse) - err := c.cc.Invoke(ctx, "/babylon.btcstaking.v1.Query/ActiveFinalityProvidersAtHeight", in, out, opts...) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *queryClient) FinalityProviderPowerAtHeight(ctx context.Context, in *QueryFinalityProviderPowerAtHeightRequest, opts ...grpc.CallOption) (*QueryFinalityProviderPowerAtHeightResponse, error) { - out := new(QueryFinalityProviderPowerAtHeightResponse) - err := c.cc.Invoke(ctx, "/babylon.btcstaking.v1.Query/FinalityProviderPowerAtHeight", in, out, opts...) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *queryClient) FinalityProviderCurrentPower(ctx context.Context, in *QueryFinalityProviderCurrentPowerRequest, opts ...grpc.CallOption) (*QueryFinalityProviderCurrentPowerResponse, error) { - out := new(QueryFinalityProviderCurrentPowerResponse) - err := c.cc.Invoke(ctx, "/babylon.btcstaking.v1.Query/FinalityProviderCurrentPower", in, out, opts...) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *queryClient) ActivatedHeight(ctx context.Context, in *QueryActivatedHeightRequest, opts ...grpc.CallOption) (*QueryActivatedHeightResponse, error) { - out := new(QueryActivatedHeightResponse) - err := c.cc.Invoke(ctx, "/babylon.btcstaking.v1.Query/ActivatedHeight", in, out, opts...) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *queryClient) FinalityProviderDelegations(ctx context.Context, in *QueryFinalityProviderDelegationsRequest, opts ...grpc.CallOption) (*QueryFinalityProviderDelegationsResponse, error) { - out := new(QueryFinalityProviderDelegationsResponse) - err := c.cc.Invoke(ctx, "/babylon.btcstaking.v1.Query/FinalityProviderDelegations", in, out, opts...) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *queryClient) BTCDelegation(ctx context.Context, in *QueryBTCDelegationRequest, opts ...grpc.CallOption) (*QueryBTCDelegationResponse, error) { - out := new(QueryBTCDelegationResponse) - err := c.cc.Invoke(ctx, "/babylon.btcstaking.v1.Query/BTCDelegation", in, out, opts...) - if err != nil { - return nil, err - } - return out, nil -} - -// QueryServer is the server API for Query service. -type QueryServer interface { - // Parameters queries the parameters of the module. - Params(context.Context, *QueryParamsRequest) (*QueryParamsResponse, error) - // ParamsByVersion queries the parameters of the module for a specific version of past params. - ParamsByVersion(context.Context, *QueryParamsByVersionRequest) (*QueryParamsByVersionResponse, error) - // FinalityProviders queries all finality providers - FinalityProviders(context.Context, *QueryFinalityProvidersRequest) (*QueryFinalityProvidersResponse, error) - // FinalityProvider info about one finality provider - FinalityProvider(context.Context, *QueryFinalityProviderRequest) (*QueryFinalityProviderResponse, error) - // BTCDelegations queries all BTC delegations under a given status - BTCDelegations(context.Context, *QueryBTCDelegationsRequest) (*QueryBTCDelegationsResponse, error) - // ActiveFinalityProvidersAtHeight queries finality providers with non zero voting power at given height. - ActiveFinalityProvidersAtHeight(context.Context, *QueryActiveFinalityProvidersAtHeightRequest) (*QueryActiveFinalityProvidersAtHeightResponse, error) - // FinalityProviderPowerAtHeight queries the voting power of a finality provider at a given height - FinalityProviderPowerAtHeight(context.Context, *QueryFinalityProviderPowerAtHeightRequest) (*QueryFinalityProviderPowerAtHeightResponse, error) - // FinalityProviderCurrentPower queries the voting power of a finality provider at the current height - FinalityProviderCurrentPower(context.Context, *QueryFinalityProviderCurrentPowerRequest) (*QueryFinalityProviderCurrentPowerResponse, error) - // ActivatedHeight queries the height when BTC staking protocol is activated, i.e., the first height when - // there exists 1 finality provider with voting power - ActivatedHeight(context.Context, *QueryActivatedHeightRequest) (*QueryActivatedHeightResponse, error) - // FinalityProviderDelegations queries all BTC delegations of the given finality provider - FinalityProviderDelegations(context.Context, *QueryFinalityProviderDelegationsRequest) (*QueryFinalityProviderDelegationsResponse, error) - // BTCDelegation retrieves delegation by corresponding staking tx hash - BTCDelegation(context.Context, *QueryBTCDelegationRequest) (*QueryBTCDelegationResponse, error) -} - -// UnimplementedQueryServer can be embedded to have forward compatible implementations. -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) ParamsByVersion(ctx context.Context, req *QueryParamsByVersionRequest) (*QueryParamsByVersionResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method ParamsByVersion not implemented") -} -func (*UnimplementedQueryServer) FinalityProviders(ctx context.Context, req *QueryFinalityProvidersRequest) (*QueryFinalityProvidersResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method FinalityProviders not implemented") -} -func (*UnimplementedQueryServer) FinalityProvider(ctx context.Context, req *QueryFinalityProviderRequest) (*QueryFinalityProviderResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method FinalityProvider not implemented") -} -func (*UnimplementedQueryServer) BTCDelegations(ctx context.Context, req *QueryBTCDelegationsRequest) (*QueryBTCDelegationsResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method BTCDelegations not implemented") -} -func (*UnimplementedQueryServer) ActiveFinalityProvidersAtHeight(ctx context.Context, req *QueryActiveFinalityProvidersAtHeightRequest) (*QueryActiveFinalityProvidersAtHeightResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method ActiveFinalityProvidersAtHeight not implemented") -} -func (*UnimplementedQueryServer) FinalityProviderPowerAtHeight(ctx context.Context, req *QueryFinalityProviderPowerAtHeightRequest) (*QueryFinalityProviderPowerAtHeightResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method FinalityProviderPowerAtHeight not implemented") -} -func (*UnimplementedQueryServer) FinalityProviderCurrentPower(ctx context.Context, req *QueryFinalityProviderCurrentPowerRequest) (*QueryFinalityProviderCurrentPowerResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method FinalityProviderCurrentPower not implemented") -} -func (*UnimplementedQueryServer) ActivatedHeight(ctx context.Context, req *QueryActivatedHeightRequest) (*QueryActivatedHeightResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method ActivatedHeight not implemented") -} -func (*UnimplementedQueryServer) FinalityProviderDelegations(ctx context.Context, req *QueryFinalityProviderDelegationsRequest) (*QueryFinalityProviderDelegationsResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method FinalityProviderDelegations not implemented") -} -func (*UnimplementedQueryServer) BTCDelegation(ctx context.Context, req *QueryBTCDelegationRequest) (*QueryBTCDelegationResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method BTCDelegation not implemented") -} - -func RegisterQueryServer(s grpc1.Server, srv QueryServer) { - s.RegisterService(&_Query_serviceDesc, srv) -} - -func _Query_Params_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(QueryParamsRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(QueryServer).Params(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/babylon.btcstaking.v1.Query/Params", - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(QueryServer).Params(ctx, req.(*QueryParamsRequest)) - } - return interceptor(ctx, in, info, handler) -} - -func _Query_ParamsByVersion_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(QueryParamsByVersionRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(QueryServer).ParamsByVersion(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/babylon.btcstaking.v1.Query/ParamsByVersion", - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(QueryServer).ParamsByVersion(ctx, req.(*QueryParamsByVersionRequest)) - } - return interceptor(ctx, in, info, handler) -} - -func _Query_FinalityProviders_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(QueryFinalityProvidersRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(QueryServer).FinalityProviders(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/babylon.btcstaking.v1.Query/FinalityProviders", - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(QueryServer).FinalityProviders(ctx, req.(*QueryFinalityProvidersRequest)) - } - return interceptor(ctx, in, info, handler) + if interceptor == nil { + return srv.(QueryServer).FinalityProviders(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/babylon.btcstaking.v1.Query/FinalityProviders", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(QueryServer).FinalityProviders(ctx, req.(*QueryFinalityProvidersRequest)) + } + return interceptor(ctx, in, info, handler) } func _Query_FinalityProvider_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { @@ -2053,103 +1586,31 @@ func _Query_BTCDelegations_Handler(srv interface{}, ctx context.Context, dec fun return interceptor(ctx, in, info, handler) } -func _Query_ActiveFinalityProvidersAtHeight_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(QueryActiveFinalityProvidersAtHeightRequest) +func _Query_FinalityProviderDelegations_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(QueryFinalityProviderDelegationsRequest) if err := dec(in); err != nil { return nil, err } if interceptor == nil { - return srv.(QueryServer).ActiveFinalityProvidersAtHeight(ctx, in) + return srv.(QueryServer).FinalityProviderDelegations(ctx, in) } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: "/babylon.btcstaking.v1.Query/ActiveFinalityProvidersAtHeight", + FullMethod: "/babylon.btcstaking.v1.Query/FinalityProviderDelegations", } handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(QueryServer).ActiveFinalityProvidersAtHeight(ctx, req.(*QueryActiveFinalityProvidersAtHeightRequest)) + return srv.(QueryServer).FinalityProviderDelegations(ctx, req.(*QueryFinalityProviderDelegationsRequest)) } return interceptor(ctx, in, info, handler) } -func _Query_FinalityProviderPowerAtHeight_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(QueryFinalityProviderPowerAtHeightRequest) +func _Query_BTCDelegation_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(QueryBTCDelegationRequest) if err := dec(in); err != nil { return nil, err } if interceptor == nil { - return srv.(QueryServer).FinalityProviderPowerAtHeight(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/babylon.btcstaking.v1.Query/FinalityProviderPowerAtHeight", - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(QueryServer).FinalityProviderPowerAtHeight(ctx, req.(*QueryFinalityProviderPowerAtHeightRequest)) - } - return interceptor(ctx, in, info, handler) -} - -func _Query_FinalityProviderCurrentPower_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(QueryFinalityProviderCurrentPowerRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(QueryServer).FinalityProviderCurrentPower(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/babylon.btcstaking.v1.Query/FinalityProviderCurrentPower", - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(QueryServer).FinalityProviderCurrentPower(ctx, req.(*QueryFinalityProviderCurrentPowerRequest)) - } - return interceptor(ctx, in, info, handler) -} - -func _Query_ActivatedHeight_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(QueryActivatedHeightRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(QueryServer).ActivatedHeight(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/babylon.btcstaking.v1.Query/ActivatedHeight", - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(QueryServer).ActivatedHeight(ctx, req.(*QueryActivatedHeightRequest)) - } - return interceptor(ctx, in, info, handler) -} - -func _Query_FinalityProviderDelegations_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(QueryFinalityProviderDelegationsRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(QueryServer).FinalityProviderDelegations(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/babylon.btcstaking.v1.Query/FinalityProviderDelegations", - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(QueryServer).FinalityProviderDelegations(ctx, req.(*QueryFinalityProviderDelegationsRequest)) - } - return interceptor(ctx, in, info, handler) -} - -func _Query_BTCDelegation_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(QueryBTCDelegationRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(QueryServer).BTCDelegation(ctx, in) + return srv.(QueryServer).BTCDelegation(ctx, in) } info := &grpc.UnaryServerInfo{ Server: srv, @@ -2185,22 +1646,6 @@ var _Query_serviceDesc = grpc.ServiceDesc{ MethodName: "BTCDelegations", Handler: _Query_BTCDelegations_Handler, }, - { - MethodName: "ActiveFinalityProvidersAtHeight", - Handler: _Query_ActiveFinalityProvidersAtHeight_Handler, - }, - { - MethodName: "FinalityProviderPowerAtHeight", - Handler: _Query_FinalityProviderPowerAtHeight_Handler, - }, - { - MethodName: "FinalityProviderCurrentPower", - Handler: _Query_FinalityProviderCurrentPower_Handler, - }, - { - MethodName: "ActivatedHeight", - Handler: _Query_ActivatedHeight_Handler, - }, { MethodName: "FinalityProviderDelegations", Handler: _Query_FinalityProviderDelegations_Handler, @@ -2569,133 +2014,7 @@ func (m *QueryBTCDelegationsResponse) MarshalToSizedBuffer(dAtA []byte) (int, er return len(dAtA) - i, nil } -func (m *QueryFinalityProviderPowerAtHeightRequest) 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 *QueryFinalityProviderPowerAtHeightRequest) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *QueryFinalityProviderPowerAtHeightRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if m.Height != 0 { - i = encodeVarintQuery(dAtA, i, uint64(m.Height)) - i-- - dAtA[i] = 0x10 - } - if len(m.FpBtcPkHex) > 0 { - i -= len(m.FpBtcPkHex) - copy(dAtA[i:], m.FpBtcPkHex) - i = encodeVarintQuery(dAtA, i, uint64(len(m.FpBtcPkHex))) - i-- - dAtA[i] = 0xa - } - return len(dAtA) - i, nil -} - -func (m *QueryFinalityProviderPowerAtHeightResponse) 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 *QueryFinalityProviderPowerAtHeightResponse) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *QueryFinalityProviderPowerAtHeightResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if m.VotingPower != 0 { - i = encodeVarintQuery(dAtA, i, uint64(m.VotingPower)) - i-- - dAtA[i] = 0x8 - } - return len(dAtA) - i, nil -} - -func (m *QueryFinalityProviderCurrentPowerRequest) 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 *QueryFinalityProviderCurrentPowerRequest) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *QueryFinalityProviderCurrentPowerRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if len(m.FpBtcPkHex) > 0 { - i -= len(m.FpBtcPkHex) - copy(dAtA[i:], m.FpBtcPkHex) - i = encodeVarintQuery(dAtA, i, uint64(len(m.FpBtcPkHex))) - i-- - dAtA[i] = 0xa - } - return len(dAtA) - i, nil -} - -func (m *QueryFinalityProviderCurrentPowerResponse) 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 *QueryFinalityProviderCurrentPowerResponse) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *QueryFinalityProviderCurrentPowerResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if m.VotingPower != 0 { - i = encodeVarintQuery(dAtA, i, uint64(m.VotingPower)) - i-- - dAtA[i] = 0x10 - } - if m.Height != 0 { - i = encodeVarintQuery(dAtA, i, uint64(m.Height)) - i-- - dAtA[i] = 0x8 - } - return len(dAtA) - i, nil -} - -func (m *QueryActiveFinalityProvidersAtHeightRequest) Marshal() (dAtA []byte, err error) { +func (m *QueryFinalityProviderDelegationsRequest) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalToSizedBuffer(dAtA[:size]) @@ -2705,12 +2024,12 @@ func (m *QueryActiveFinalityProvidersAtHeightRequest) Marshal() (dAtA []byte, er return dAtA[:n], nil } -func (m *QueryActiveFinalityProvidersAtHeightRequest) MarshalTo(dAtA []byte) (int, error) { +func (m *QueryFinalityProviderDelegationsRequest) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *QueryActiveFinalityProvidersAtHeightRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *QueryFinalityProviderDelegationsRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) _ = i var l int @@ -2727,15 +2046,17 @@ func (m *QueryActiveFinalityProvidersAtHeightRequest) MarshalToSizedBuffer(dAtA i-- dAtA[i] = 0x12 } - if m.Height != 0 { - i = encodeVarintQuery(dAtA, i, uint64(m.Height)) + if len(m.FpBtcPkHex) > 0 { + i -= len(m.FpBtcPkHex) + copy(dAtA[i:], m.FpBtcPkHex) + i = encodeVarintQuery(dAtA, i, uint64(len(m.FpBtcPkHex))) i-- - dAtA[i] = 0x8 + dAtA[i] = 0xa } return len(dAtA) - i, nil } -func (m *QueryActiveFinalityProvidersAtHeightResponse) Marshal() (dAtA []byte, err error) { +func (m *QueryFinalityProviderDelegationsResponse) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalToSizedBuffer(dAtA[:size]) @@ -2745,12 +2066,12 @@ func (m *QueryActiveFinalityProvidersAtHeightResponse) Marshal() (dAtA []byte, e return dAtA[:n], nil } -func (m *QueryActiveFinalityProvidersAtHeightResponse) MarshalTo(dAtA []byte) (int, error) { +func (m *QueryFinalityProviderDelegationsResponse) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *QueryActiveFinalityProvidersAtHeightResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *QueryFinalityProviderDelegationsResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) _ = i var l int @@ -2767,10 +2088,10 @@ func (m *QueryActiveFinalityProvidersAtHeightResponse) MarshalToSizedBuffer(dAtA i-- dAtA[i] = 0x12 } - if len(m.FinalityProviders) > 0 { - for iNdEx := len(m.FinalityProviders) - 1; iNdEx >= 0; iNdEx-- { + if len(m.BtcDelegatorDelegations) > 0 { + for iNdEx := len(m.BtcDelegatorDelegations) - 1; iNdEx >= 0; iNdEx-- { { - size, err := m.FinalityProviders[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + size, err := m.BtcDelegatorDelegations[iNdEx].MarshalToSizedBuffer(dAtA[:i]) if err != nil { return 0, err } @@ -2784,7 +2105,7 @@ func (m *QueryActiveFinalityProvidersAtHeightResponse) MarshalToSizedBuffer(dAtA return len(dAtA) - i, nil } -func (m *QueryActivatedHeightRequest) Marshal() (dAtA []byte, err error) { +func (m *QueryBTCDelegationRequest) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalToSizedBuffer(dAtA[:size]) @@ -2794,20 +2115,27 @@ func (m *QueryActivatedHeightRequest) Marshal() (dAtA []byte, err error) { return dAtA[:n], nil } -func (m *QueryActivatedHeightRequest) MarshalTo(dAtA []byte) (int, error) { +func (m *QueryBTCDelegationRequest) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *QueryActivatedHeightRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *QueryBTCDelegationRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) _ = i var l int _ = l + if len(m.StakingTxHashHex) > 0 { + i -= len(m.StakingTxHashHex) + copy(dAtA[i:], m.StakingTxHashHex) + i = encodeVarintQuery(dAtA, i, uint64(len(m.StakingTxHashHex))) + i-- + dAtA[i] = 0xa + } return len(dAtA) - i, nil } -func (m *QueryActivatedHeightResponse) Marshal() (dAtA []byte, err error) { +func (m *QueryBTCDelegationResponse) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalToSizedBuffer(dAtA[:size]) @@ -2817,25 +2145,32 @@ func (m *QueryActivatedHeightResponse) Marshal() (dAtA []byte, err error) { return dAtA[:n], nil } -func (m *QueryActivatedHeightResponse) MarshalTo(dAtA []byte) (int, error) { +func (m *QueryBTCDelegationResponse) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *QueryActivatedHeightResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *QueryBTCDelegationResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) _ = i var l int _ = l - if m.Height != 0 { - i = encodeVarintQuery(dAtA, i, uint64(m.Height)) + if m.BtcDelegation != nil { + { + size, err := m.BtcDelegation.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } i-- - dAtA[i] = 0x8 + dAtA[i] = 0xa } return len(dAtA) - i, nil } -func (m *QueryFinalityProviderDelegationsRequest) Marshal() (dAtA []byte, err error) { +func (m *BTCDelegationResponse) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalToSizedBuffer(dAtA[:size]) @@ -2845,19 +2180,26 @@ func (m *QueryFinalityProviderDelegationsRequest) Marshal() (dAtA []byte, err er return dAtA[:n], nil } -func (m *QueryFinalityProviderDelegationsRequest) MarshalTo(dAtA []byte) (int, error) { +func (m *BTCDelegationResponse) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *QueryFinalityProviderDelegationsRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *BTCDelegationResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) _ = i var l int _ = l - if m.Pagination != nil { + if m.ParamsVersion != 0 { + i = encodeVarintQuery(dAtA, i, uint64(m.ParamsVersion)) + i-- + dAtA[i] = 0x1 + i-- + dAtA[i] = 0x88 + } + if m.UndelegationResponse != nil { { - size, err := m.Pagination.MarshalToSizedBuffer(dAtA[:i]) + size, err := m.UndelegationResponse.MarshalToSizedBuffer(dAtA[:i]) if err != nil { return 0, err } @@ -2865,182 +2207,21 @@ func (m *QueryFinalityProviderDelegationsRequest) MarshalToSizedBuffer(dAtA []by i = encodeVarintQuery(dAtA, i, uint64(size)) } i-- - dAtA[i] = 0x12 + dAtA[i] = 0x1 + i-- + dAtA[i] = 0x82 } - if len(m.FpBtcPkHex) > 0 { - i -= len(m.FpBtcPkHex) - copy(dAtA[i:], m.FpBtcPkHex) - i = encodeVarintQuery(dAtA, i, uint64(len(m.FpBtcPkHex))) + if m.UnbondingTime != 0 { + i = encodeVarintQuery(dAtA, i, uint64(m.UnbondingTime)) i-- - dAtA[i] = 0xa - } - return len(dAtA) - i, nil -} - -func (m *QueryFinalityProviderDelegationsResponse) 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 *QueryFinalityProviderDelegationsResponse) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *QueryFinalityProviderDelegationsResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if m.Pagination != nil { - { - size, err := m.Pagination.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintQuery(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x12 - } - if len(m.BtcDelegatorDelegations) > 0 { - for iNdEx := len(m.BtcDelegatorDelegations) - 1; iNdEx >= 0; iNdEx-- { - { - size, err := m.BtcDelegatorDelegations[iNdEx].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 *QueryBTCDelegationRequest) 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 *QueryBTCDelegationRequest) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *QueryBTCDelegationRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if len(m.StakingTxHashHex) > 0 { - i -= len(m.StakingTxHashHex) - copy(dAtA[i:], m.StakingTxHashHex) - i = encodeVarintQuery(dAtA, i, uint64(len(m.StakingTxHashHex))) - i-- - dAtA[i] = 0xa - } - return len(dAtA) - i, nil -} - -func (m *QueryBTCDelegationResponse) 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 *QueryBTCDelegationResponse) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *QueryBTCDelegationResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if m.BtcDelegation != nil { - { - size, err := m.BtcDelegation.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 *BTCDelegationResponse) 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 *BTCDelegationResponse) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *BTCDelegationResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if m.ParamsVersion != 0 { - i = encodeVarintQuery(dAtA, i, uint64(m.ParamsVersion)) - i-- - dAtA[i] = 0x1 - i-- - dAtA[i] = 0x80 - } - if m.UndelegationResponse != nil { - { - size, err := m.UndelegationResponse.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintQuery(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x7a - } - if m.UnbondingTime != 0 { - i = encodeVarintQuery(dAtA, i, uint64(m.UnbondingTime)) - i-- - dAtA[i] = 0x70 + dAtA[i] = 0x78 } if len(m.StatusDesc) > 0 { i -= len(m.StatusDesc) copy(dAtA[i:], m.StatusDesc) i = encodeVarintQuery(dAtA, i, uint64(len(m.StatusDesc))) i-- - dAtA[i] = 0x6a + dAtA[i] = 0x72 } if m.Active { i-- @@ -3050,12 +2231,12 @@ func (m *BTCDelegationResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { dAtA[i] = 0 } i-- - dAtA[i] = 0x60 + dAtA[i] = 0x68 } if m.StakingOutputIdx != 0 { i = encodeVarintQuery(dAtA, i, uint64(m.StakingOutputIdx)) i-- - dAtA[i] = 0x58 + dAtA[i] = 0x60 } if len(m.CovenantSigs) > 0 { for iNdEx := len(m.CovenantSigs) - 1; iNdEx >= 0; iNdEx-- { @@ -3068,7 +2249,7 @@ func (m *BTCDelegationResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { i = encodeVarintQuery(dAtA, i, uint64(size)) } i-- - dAtA[i] = 0x52 + dAtA[i] = 0x5a } } if len(m.DelegatorSlashSigHex) > 0 { @@ -3076,35 +2257,40 @@ func (m *BTCDelegationResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { copy(dAtA[i:], m.DelegatorSlashSigHex) i = encodeVarintQuery(dAtA, i, uint64(len(m.DelegatorSlashSigHex))) i-- - dAtA[i] = 0x4a + dAtA[i] = 0x52 } if len(m.SlashingTxHex) > 0 { i -= len(m.SlashingTxHex) copy(dAtA[i:], m.SlashingTxHex) i = encodeVarintQuery(dAtA, i, uint64(len(m.SlashingTxHex))) i-- - dAtA[i] = 0x42 + dAtA[i] = 0x4a } if len(m.StakingTxHex) > 0 { i -= len(m.StakingTxHex) copy(dAtA[i:], m.StakingTxHex) i = encodeVarintQuery(dAtA, i, uint64(len(m.StakingTxHex))) i-- - dAtA[i] = 0x3a + dAtA[i] = 0x42 } if m.TotalSat != 0 { i = encodeVarintQuery(dAtA, i, uint64(m.TotalSat)) i-- - dAtA[i] = 0x30 + dAtA[i] = 0x38 } if m.EndHeight != 0 { i = encodeVarintQuery(dAtA, i, uint64(m.EndHeight)) i-- - dAtA[i] = 0x28 + dAtA[i] = 0x30 } if m.StartHeight != 0 { i = encodeVarintQuery(dAtA, i, uint64(m.StartHeight)) i-- + dAtA[i] = 0x28 + } + if m.StakingTime != 0 { + i = encodeVarintQuery(dAtA, i, uint64(m.StakingTime)) + i-- dAtA[i] = 0x20 } if len(m.FpBtcPkList) > 0 { @@ -3143,6 +2329,36 @@ func (m *BTCDelegationResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { return len(dAtA) - i, nil } +func (m *DelegatorUnbondingInfoResponse) 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 *DelegatorUnbondingInfoResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *DelegatorUnbondingInfoResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.SpendStakeTxHex) > 0 { + i -= len(m.SpendStakeTxHex) + copy(dAtA[i:], m.SpendStakeTxHex) + i = encodeVarintQuery(dAtA, i, uint64(len(m.SpendStakeTxHex))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + func (m *BTCUndelegationResponse) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) @@ -3163,6 +2379,18 @@ func (m *BTCUndelegationResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) _ = i var l int _ = l + if m.DelegatorUnbondingInfoResponse != nil { + { + size, err := m.DelegatorUnbondingInfoResponse.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x32 + } if len(m.CovenantSlashingSigs) > 0 { for iNdEx := len(m.CovenantSlashingSigs) - 1; iNdEx >= 0; iNdEx-- { { @@ -3174,7 +2402,7 @@ func (m *BTCUndelegationResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) i = encodeVarintQuery(dAtA, i, uint64(size)) } i-- - dAtA[i] = 0x32 + dAtA[i] = 0x2a } } if len(m.DelegatorSlashingSigHex) > 0 { @@ -3182,14 +2410,14 @@ func (m *BTCUndelegationResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) copy(dAtA[i:], m.DelegatorSlashingSigHex) i = encodeVarintQuery(dAtA, i, uint64(len(m.DelegatorSlashingSigHex))) i-- - dAtA[i] = 0x2a + dAtA[i] = 0x22 } if len(m.SlashingTxHex) > 0 { i -= len(m.SlashingTxHex) copy(dAtA[i:], m.SlashingTxHex) i = encodeVarintQuery(dAtA, i, uint64(len(m.SlashingTxHex))) i-- - dAtA[i] = 0x22 + dAtA[i] = 0x1a } if len(m.CovenantUnbondingSigList) > 0 { for iNdEx := len(m.CovenantUnbondingSigList) - 1; iNdEx >= 0; iNdEx-- { @@ -3202,16 +2430,9 @@ func (m *BTCUndelegationResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) i = encodeVarintQuery(dAtA, i, uint64(size)) } i-- - dAtA[i] = 0x1a + dAtA[i] = 0x12 } } - if len(m.DelegatorUnbondingSigHex) > 0 { - i -= len(m.DelegatorUnbondingSigHex) - copy(dAtA[i:], m.DelegatorUnbondingSigHex) - i = encodeVarintQuery(dAtA, i, uint64(len(m.DelegatorUnbondingSigHex))) - i-- - dAtA[i] = 0x12 - } if len(m.UnbondingTxHex) > 0 { i -= len(m.UnbondingTxHex) copy(dAtA[i:], m.UnbondingTxHex) @@ -3287,11 +2508,6 @@ func (m *FinalityProviderResponse) MarshalToSizedBuffer(dAtA []byte) (int, error dAtA[i] = 0 } i-- - dAtA[i] = 0x50 - } - if m.VotingPower != 0 { - i = encodeVarintQuery(dAtA, i, uint64(m.VotingPower)) - i-- dAtA[i] = 0x48 } if m.Height != 0 { @@ -3514,7 +2730,7 @@ func (m *QueryBTCDelegationsResponse) Size() (n int) { return n } -func (m *QueryFinalityProviderPowerAtHeightRequest) Size() (n int) { +func (m *QueryFinalityProviderDelegationsRequest) Size() (n int) { if m == nil { return 0 } @@ -3524,189 +2740,80 @@ func (m *QueryFinalityProviderPowerAtHeightRequest) Size() (n int) { if l > 0 { n += 1 + l + sovQuery(uint64(l)) } - if m.Height != 0 { - n += 1 + sovQuery(uint64(m.Height)) + if m.Pagination != nil { + l = m.Pagination.Size() + n += 1 + l + sovQuery(uint64(l)) } return n } -func (m *QueryFinalityProviderPowerAtHeightResponse) Size() (n int) { +func (m *QueryFinalityProviderDelegationsResponse) Size() (n int) { if m == nil { return 0 } var l int _ = l - if m.VotingPower != 0 { - n += 1 + sovQuery(uint64(m.VotingPower)) + if len(m.BtcDelegatorDelegations) > 0 { + for _, e := range m.BtcDelegatorDelegations { + l = e.Size() + n += 1 + l + sovQuery(uint64(l)) + } + } + if m.Pagination != nil { + l = m.Pagination.Size() + n += 1 + l + sovQuery(uint64(l)) } return n } -func (m *QueryFinalityProviderCurrentPowerRequest) Size() (n int) { +func (m *QueryBTCDelegationRequest) Size() (n int) { if m == nil { return 0 } var l int _ = l - l = len(m.FpBtcPkHex) + l = len(m.StakingTxHashHex) if l > 0 { n += 1 + l + sovQuery(uint64(l)) } return n } -func (m *QueryFinalityProviderCurrentPowerResponse) Size() (n int) { +func (m *QueryBTCDelegationResponse) Size() (n int) { if m == nil { return 0 } var l int _ = l - if m.Height != 0 { - n += 1 + sovQuery(uint64(m.Height)) - } - if m.VotingPower != 0 { - n += 1 + sovQuery(uint64(m.VotingPower)) + if m.BtcDelegation != nil { + l = m.BtcDelegation.Size() + n += 1 + l + sovQuery(uint64(l)) } return n } -func (m *QueryActiveFinalityProvidersAtHeightRequest) Size() (n int) { +func (m *BTCDelegationResponse) Size() (n int) { if m == nil { return 0 } var l int _ = l - if m.Height != 0 { - n += 1 + sovQuery(uint64(m.Height)) - } - if m.Pagination != nil { - l = m.Pagination.Size() + l = len(m.StakerAddr) + if l > 0 { n += 1 + l + sovQuery(uint64(l)) } - return n -} - -func (m *QueryActiveFinalityProvidersAtHeightResponse) Size() (n int) { - if m == nil { - return 0 + if m.BtcPk != nil { + l = m.BtcPk.Size() + n += 1 + l + sovQuery(uint64(l)) } - var l int - _ = l - if len(m.FinalityProviders) > 0 { - for _, e := range m.FinalityProviders { + if len(m.FpBtcPkList) > 0 { + for _, e := range m.FpBtcPkList { l = e.Size() n += 1 + l + sovQuery(uint64(l)) } } - if m.Pagination != nil { - l = m.Pagination.Size() - n += 1 + l + sovQuery(uint64(l)) - } - return n -} - -func (m *QueryActivatedHeightRequest) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - return n -} - -func (m *QueryActivatedHeightResponse) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if m.Height != 0 { - n += 1 + sovQuery(uint64(m.Height)) - } - return n -} - -func (m *QueryFinalityProviderDelegationsRequest) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = len(m.FpBtcPkHex) - if l > 0 { - n += 1 + l + sovQuery(uint64(l)) - } - if m.Pagination != nil { - l = m.Pagination.Size() - n += 1 + l + sovQuery(uint64(l)) - } - return n -} - -func (m *QueryFinalityProviderDelegationsResponse) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if len(m.BtcDelegatorDelegations) > 0 { - for _, e := range m.BtcDelegatorDelegations { - l = e.Size() - n += 1 + l + sovQuery(uint64(l)) - } - } - if m.Pagination != nil { - l = m.Pagination.Size() - n += 1 + l + sovQuery(uint64(l)) - } - return n -} - -func (m *QueryBTCDelegationRequest) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = len(m.StakingTxHashHex) - if l > 0 { - n += 1 + l + sovQuery(uint64(l)) - } - return n -} - -func (m *QueryBTCDelegationResponse) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if m.BtcDelegation != nil { - l = m.BtcDelegation.Size() - n += 1 + l + sovQuery(uint64(l)) - } - return n -} - -func (m *BTCDelegationResponse) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = len(m.StakerAddr) - if l > 0 { - n += 1 + l + sovQuery(uint64(l)) - } - if m.BtcPk != nil { - l = m.BtcPk.Size() - n += 1 + l + sovQuery(uint64(l)) - } - if len(m.FpBtcPkList) > 0 { - for _, e := range m.FpBtcPkList { - l = e.Size() - n += 1 + l + sovQuery(uint64(l)) - } + if m.StakingTime != 0 { + n += 1 + sovQuery(uint64(m.StakingTime)) } if m.StartHeight != 0 { n += 1 + sovQuery(uint64(m.StartHeight)) @@ -3750,7 +2857,7 @@ func (m *BTCDelegationResponse) Size() (n int) { } if m.UndelegationResponse != nil { l = m.UndelegationResponse.Size() - n += 1 + l + sovQuery(uint64(l)) + n += 2 + l + sovQuery(uint64(l)) } if m.ParamsVersion != 0 { n += 2 + sovQuery(uint64(m.ParamsVersion)) @@ -3758,768 +2865,119 @@ func (m *BTCDelegationResponse) Size() (n int) { return n } -func (m *BTCUndelegationResponse) Size() (n int) { +func (m *DelegatorUnbondingInfoResponse) Size() (n int) { if m == nil { return 0 } var l int _ = l - l = len(m.UnbondingTxHex) - if l > 0 { - n += 1 + l + sovQuery(uint64(l)) - } - l = len(m.DelegatorUnbondingSigHex) - if l > 0 { - n += 1 + l + sovQuery(uint64(l)) - } - if len(m.CovenantUnbondingSigList) > 0 { - for _, e := range m.CovenantUnbondingSigList { - l = e.Size() - n += 1 + l + sovQuery(uint64(l)) - } - } - l = len(m.SlashingTxHex) + l = len(m.SpendStakeTxHex) if l > 0 { n += 1 + l + sovQuery(uint64(l)) } - l = len(m.DelegatorSlashingSigHex) - if l > 0 { - n += 1 + l + sovQuery(uint64(l)) - } - if len(m.CovenantSlashingSigs) > 0 { - for _, e := range m.CovenantSlashingSigs { - l = e.Size() - n += 1 + l + sovQuery(uint64(l)) - } - } return n } -func (m *BTCDelegatorDelegationsResponse) Size() (n int) { +func (m *BTCUndelegationResponse) Size() (n int) { if m == nil { return 0 } var l int _ = l - if len(m.Dels) > 0 { - for _, e := range m.Dels { + l = len(m.UnbondingTxHex) + if l > 0 { + n += 1 + l + sovQuery(uint64(l)) + } + if len(m.CovenantUnbondingSigList) > 0 { + for _, e := range m.CovenantUnbondingSigList { l = e.Size() n += 1 + l + sovQuery(uint64(l)) } } - return n -} - -func (m *FinalityProviderResponse) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if m.Description != nil { - l = m.Description.Size() - n += 1 + l + sovQuery(uint64(l)) - } - if m.Commission != nil { - l = m.Commission.Size() - n += 1 + l + sovQuery(uint64(l)) - } - l = len(m.Addr) + l = len(m.SlashingTxHex) if l > 0 { n += 1 + l + sovQuery(uint64(l)) } - if m.BtcPk != nil { - l = m.BtcPk.Size() - n += 1 + l + sovQuery(uint64(l)) - } - if m.Pop != nil { - l = m.Pop.Size() - n += 1 + l + sovQuery(uint64(l)) - } - if m.SlashedBabylonHeight != 0 { - n += 1 + sovQuery(uint64(m.SlashedBabylonHeight)) - } - if m.SlashedBtcHeight != 0 { - n += 1 + sovQuery(uint64(m.SlashedBtcHeight)) - } - if m.Height != 0 { - n += 1 + sovQuery(uint64(m.Height)) - } - if m.VotingPower != 0 { - n += 1 + sovQuery(uint64(m.VotingPower)) - } - if m.Jailed { - n += 2 - } - return n -} - -func sovQuery(x uint64) (n int) { - return (math_bits.Len64(x|1) + 6) / 7 -} -func sozQuery(x uint64) (n int) { - return sovQuery(uint64((x << 1) ^ uint64((int64(x) >> 63)))) -} -func (m *QueryParamsRequest) 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: QueryParamsRequest: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: QueryParamsRequest: 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 *QueryParamsResponse) 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: QueryParamsResponse: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: QueryParamsResponse: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Params", 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 err := m.Params.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 *QueryParamsByVersionRequest) 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: QueryParamsByVersionRequest: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: QueryParamsByVersionRequest: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field Version", wireType) - } - m.Version = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowQuery - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.Version |= uint32(b&0x7F) << shift - if b < 0x80 { - break - } - } - 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 *QueryParamsByVersionResponse) 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: QueryParamsByVersionResponse: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: QueryParamsByVersionResponse: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Params", 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 err := m.Params.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 *QueryFinalityProvidersRequest) 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: QueryFinalityProvidersRequest: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: QueryFinalityProvidersRequest: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Pagination", 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.Pagination == nil { - m.Pagination = &query.PageRequest{} - } - if err := m.Pagination.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 *QueryFinalityProvidersResponse) 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: QueryFinalityProvidersResponse: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: QueryFinalityProvidersResponse: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field FinalityProviders", 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 - } - m.FinalityProviders = append(m.FinalityProviders, &FinalityProviderResponse{}) - if err := m.FinalityProviders[len(m.FinalityProviders)-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 Pagination", 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.Pagination == nil { - m.Pagination = &query.PageResponse{} - } - if err := m.Pagination.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 *QueryFinalityProviderRequest) 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: QueryFinalityProviderRequest: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: QueryFinalityProviderRequest: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field FpBtcPkHex", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowQuery - } - 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 ErrInvalidLengthQuery - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthQuery - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.FpBtcPkHex = string(dAtA[iNdEx:postIndex]) - 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 + l = len(m.DelegatorSlashingSigHex) + if l > 0 { + n += 1 + l + sovQuery(uint64(l)) + } + if len(m.CovenantSlashingSigs) > 0 { + for _, e := range m.CovenantSlashingSigs { + l = e.Size() + n += 1 + l + sovQuery(uint64(l)) } } - - if iNdEx > l { - return io.ErrUnexpectedEOF + if m.DelegatorUnbondingInfoResponse != nil { + l = m.DelegatorUnbondingInfoResponse.Size() + n += 1 + l + sovQuery(uint64(l)) } - return nil + return n } -func (m *QueryFinalityProviderResponse) 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: QueryFinalityProviderResponse: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: QueryFinalityProviderResponse: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field FinalityProvider", 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.FinalityProvider == nil { - m.FinalityProvider = &FinalityProviderResponse{} - } - if err := m.FinalityProvider.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 + +func (m *BTCDelegatorDelegationsResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if len(m.Dels) > 0 { + for _, e := range m.Dels { + l = e.Size() + n += 1 + l + sovQuery(uint64(l)) } } + return n +} - if iNdEx > l { - return io.ErrUnexpectedEOF +func (m *FinalityProviderResponse) Size() (n int) { + if m == nil { + return 0 } - return nil + var l int + _ = l + if m.Description != nil { + l = m.Description.Size() + n += 1 + l + sovQuery(uint64(l)) + } + if m.Commission != nil { + l = m.Commission.Size() + n += 1 + l + sovQuery(uint64(l)) + } + l = len(m.Addr) + if l > 0 { + n += 1 + l + sovQuery(uint64(l)) + } + if m.BtcPk != nil { + l = m.BtcPk.Size() + n += 1 + l + sovQuery(uint64(l)) + } + if m.Pop != nil { + l = m.Pop.Size() + n += 1 + l + sovQuery(uint64(l)) + } + if m.SlashedBabylonHeight != 0 { + n += 1 + sovQuery(uint64(m.SlashedBabylonHeight)) + } + if m.SlashedBtcHeight != 0 { + n += 1 + sovQuery(uint64(m.SlashedBtcHeight)) + } + if m.Height != 0 { + n += 1 + sovQuery(uint64(m.Height)) + } + if m.Jailed { + n += 2 + } + return n } -func (m *QueryBTCDelegationsRequest) Unmarshal(dAtA []byte) error { + +func sovQuery(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozQuery(x uint64) (n int) { + return sovQuery(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *QueryParamsRequest) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -4542,67 +3000,12 @@ func (m *QueryBTCDelegationsRequest) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: QueryBTCDelegationsRequest: wiretype end group for non-group") + return fmt.Errorf("proto: QueryParamsRequest: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: QueryBTCDelegationsRequest: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: QueryParamsRequest: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { - case 1: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field Status", wireType) - } - m.Status = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowQuery - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.Status |= BTCDelegationStatus(b&0x7F) << shift - if b < 0x80 { - break - } - } - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Pagination", 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.Pagination == nil { - m.Pagination = &query.PageRequest{} - } - if err := m.Pagination.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex default: iNdEx = preIndex skippy, err := skipQuery(dAtA[iNdEx:]) @@ -4624,7 +3027,7 @@ func (m *QueryBTCDelegationsRequest) Unmarshal(dAtA []byte) error { } return nil } -func (m *QueryBTCDelegationsResponse) Unmarshal(dAtA []byte) error { +func (m *QueryParamsResponse) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -4647,49 +3050,15 @@ func (m *QueryBTCDelegationsResponse) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: QueryBTCDelegationsResponse: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: QueryBTCDelegationsResponse: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field BtcDelegations", 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 - } - m.BtcDelegations = append(m.BtcDelegations, &BTCDelegationResponse{}) - if err := m.BtcDelegations[len(m.BtcDelegations)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 2: + return fmt.Errorf("proto: QueryParamsResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryParamsResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Pagination", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field Params", wireType) } var msglen int for shift := uint(0); ; shift += 7 { @@ -4716,10 +3085,7 @@ func (m *QueryBTCDelegationsResponse) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - if m.Pagination == nil { - m.Pagination = &query.PageResponse{} - } - if err := m.Pagination.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + if err := m.Params.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } iNdEx = postIndex @@ -4744,7 +3110,7 @@ func (m *QueryBTCDelegationsResponse) Unmarshal(dAtA []byte) error { } return nil } -func (m *QueryFinalityProviderPowerAtHeightRequest) Unmarshal(dAtA []byte) error { +func (m *QueryParamsByVersionRequest) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -4767,49 +3133,17 @@ func (m *QueryFinalityProviderPowerAtHeightRequest) Unmarshal(dAtA []byte) error fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: QueryFinalityProviderPowerAtHeightRequest: wiretype end group for non-group") + return fmt.Errorf("proto: QueryParamsByVersionRequest: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: QueryFinalityProviderPowerAtHeightRequest: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: QueryParamsByVersionRequest: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field FpBtcPkHex", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowQuery - } - 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 ErrInvalidLengthQuery - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthQuery - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.FpBtcPkHex = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 2: if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field Height", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field Version", wireType) } - m.Height = 0 + m.Version = 0 for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowQuery @@ -4819,7 +3153,7 @@ func (m *QueryFinalityProviderPowerAtHeightRequest) Unmarshal(dAtA []byte) error } b := dAtA[iNdEx] iNdEx++ - m.Height |= uint64(b&0x7F) << shift + m.Version |= uint32(b&0x7F) << shift if b < 0x80 { break } @@ -4845,7 +3179,7 @@ func (m *QueryFinalityProviderPowerAtHeightRequest) Unmarshal(dAtA []byte) error } return nil } -func (m *QueryFinalityProviderPowerAtHeightResponse) Unmarshal(dAtA []byte) error { +func (m *QueryParamsByVersionResponse) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -4868,17 +3202,17 @@ func (m *QueryFinalityProviderPowerAtHeightResponse) Unmarshal(dAtA []byte) erro fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: QueryFinalityProviderPowerAtHeightResponse: wiretype end group for non-group") + return fmt.Errorf("proto: QueryParamsByVersionResponse: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: QueryFinalityProviderPowerAtHeightResponse: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: QueryParamsByVersionResponse: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field VotingPower", wireType) + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Params", wireType) } - m.VotingPower = 0 + var msglen int for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowQuery @@ -4888,11 +3222,25 @@ func (m *QueryFinalityProviderPowerAtHeightResponse) Unmarshal(dAtA []byte) erro } b := dAtA[iNdEx] iNdEx++ - m.VotingPower |= uint64(b&0x7F) << shift + 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 err := m.Params.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex default: iNdEx = preIndex skippy, err := skipQuery(dAtA[iNdEx:]) @@ -4914,7 +3262,7 @@ func (m *QueryFinalityProviderPowerAtHeightResponse) Unmarshal(dAtA []byte) erro } return nil } -func (m *QueryFinalityProviderCurrentPowerRequest) Unmarshal(dAtA []byte) error { +func (m *QueryFinalityProvidersRequest) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -4937,17 +3285,17 @@ func (m *QueryFinalityProviderCurrentPowerRequest) Unmarshal(dAtA []byte) error fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: QueryFinalityProviderCurrentPowerRequest: wiretype end group for non-group") + return fmt.Errorf("proto: QueryFinalityProvidersRequest: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: QueryFinalityProviderCurrentPowerRequest: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: QueryFinalityProvidersRequest: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field FpBtcPkHex", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field Pagination", wireType) } - var stringLen uint64 + var msglen int for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowQuery @@ -4957,23 +3305,27 @@ func (m *QueryFinalityProviderCurrentPowerRequest) Unmarshal(dAtA []byte) error } b := dAtA[iNdEx] iNdEx++ - stringLen |= uint64(b&0x7F) << shift + msglen |= int(b&0x7F) << shift if b < 0x80 { break } } - intStringLen := int(stringLen) - if intStringLen < 0 { + if msglen < 0 { return ErrInvalidLengthQuery } - postIndex := iNdEx + intStringLen + postIndex := iNdEx + msglen if postIndex < 0 { return ErrInvalidLengthQuery } if postIndex > l { return io.ErrUnexpectedEOF } - m.FpBtcPkHex = string(dAtA[iNdEx:postIndex]) + if m.Pagination == nil { + m.Pagination = &query.PageRequest{} + } + if err := m.Pagination.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } iNdEx = postIndex default: iNdEx = preIndex @@ -4996,7 +3348,7 @@ func (m *QueryFinalityProviderCurrentPowerRequest) Unmarshal(dAtA []byte) error } return nil } -func (m *QueryFinalityProviderCurrentPowerResponse) Unmarshal(dAtA []byte) error { +func (m *QueryFinalityProvidersResponse) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -5019,17 +3371,17 @@ func (m *QueryFinalityProviderCurrentPowerResponse) Unmarshal(dAtA []byte) error fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: QueryFinalityProviderCurrentPowerResponse: wiretype end group for non-group") + return fmt.Errorf("proto: QueryFinalityProvidersResponse: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: QueryFinalityProviderCurrentPowerResponse: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: QueryFinalityProvidersResponse: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field Height", wireType) + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field FinalityProviders", wireType) } - m.Height = 0 + var msglen int for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowQuery @@ -5039,16 +3391,31 @@ func (m *QueryFinalityProviderCurrentPowerResponse) Unmarshal(dAtA []byte) error } b := dAtA[iNdEx] iNdEx++ - m.Height |= uint64(b&0x7F) << shift + 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 + } + m.FinalityProviders = append(m.FinalityProviders, &FinalityProviderResponse{}) + if err := m.FinalityProviders[len(m.FinalityProviders)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex case 2: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field VotingPower", wireType) + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Pagination", wireType) } - m.VotingPower = 0 + var msglen int for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowQuery @@ -5058,11 +3425,28 @@ func (m *QueryFinalityProviderCurrentPowerResponse) Unmarshal(dAtA []byte) error } b := dAtA[iNdEx] iNdEx++ - m.VotingPower |= uint64(b&0x7F) << shift + 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.Pagination == nil { + m.Pagination = &query.PageResponse{} + } + if err := m.Pagination.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex default: iNdEx = preIndex skippy, err := skipQuery(dAtA[iNdEx:]) @@ -5084,7 +3468,7 @@ func (m *QueryFinalityProviderCurrentPowerResponse) Unmarshal(dAtA []byte) error } return nil } -func (m *QueryActiveFinalityProvidersAtHeightRequest) Unmarshal(dAtA []byte) error { +func (m *QueryFinalityProviderRequest) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -5107,17 +3491,17 @@ func (m *QueryActiveFinalityProvidersAtHeightRequest) Unmarshal(dAtA []byte) err fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: QueryActiveFinalityProvidersAtHeightRequest: wiretype end group for non-group") + return fmt.Errorf("proto: QueryFinalityProviderRequest: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: QueryActiveFinalityProvidersAtHeightRequest: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: QueryFinalityProviderRequest: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field Height", wireType) + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field FpBtcPkHex", wireType) } - m.Height = 0 + var stringLen uint64 for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowQuery @@ -5127,14 +3511,77 @@ func (m *QueryActiveFinalityProvidersAtHeightRequest) Unmarshal(dAtA []byte) err } b := dAtA[iNdEx] iNdEx++ - m.Height |= uint64(b&0x7F) << shift + stringLen |= uint64(b&0x7F) << shift if b < 0x80 { break } } - case 2: + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.FpBtcPkHex = string(dAtA[iNdEx:postIndex]) + 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 *QueryFinalityProviderResponse) 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: QueryFinalityProviderResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryFinalityProviderResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Pagination", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field FinalityProvider", wireType) } var msglen int for shift := uint(0); ; shift += 7 { @@ -5161,10 +3608,10 @@ func (m *QueryActiveFinalityProvidersAtHeightRequest) Unmarshal(dAtA []byte) err if postIndex > l { return io.ErrUnexpectedEOF } - if m.Pagination == nil { - m.Pagination = &query.PageRequest{} + if m.FinalityProvider == nil { + m.FinalityProvider = &FinalityProviderResponse{} } - if err := m.Pagination.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + if err := m.FinalityProvider.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } iNdEx = postIndex @@ -5189,7 +3636,7 @@ func (m *QueryActiveFinalityProvidersAtHeightRequest) Unmarshal(dAtA []byte) err } return nil } -func (m *QueryActiveFinalityProvidersAtHeightResponse) Unmarshal(dAtA []byte) error { +func (m *QueryBTCDelegationsRequest) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -5212,17 +3659,17 @@ func (m *QueryActiveFinalityProvidersAtHeightResponse) Unmarshal(dAtA []byte) er fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: QueryActiveFinalityProvidersAtHeightResponse: wiretype end group for non-group") + return fmt.Errorf("proto: QueryBTCDelegationsRequest: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: QueryActiveFinalityProvidersAtHeightResponse: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: QueryBTCDelegationsRequest: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field FinalityProviders", wireType) + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Status", wireType) } - var msglen int + m.Status = 0 for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowQuery @@ -5232,26 +3679,11 @@ func (m *QueryActiveFinalityProvidersAtHeightResponse) Unmarshal(dAtA []byte) er } b := dAtA[iNdEx] iNdEx++ - msglen |= int(b&0x7F) << shift + m.Status |= BTCDelegationStatus(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 - } - m.FinalityProviders = append(m.FinalityProviders, &FinalityProviderWithMeta{}) - if err := m.FinalityProviders[len(m.FinalityProviders)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err + break + } } - iNdEx = postIndex case 2: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field Pagination", wireType) @@ -5282,7 +3714,7 @@ func (m *QueryActiveFinalityProvidersAtHeightResponse) Unmarshal(dAtA []byte) er return io.ErrUnexpectedEOF } if m.Pagination == nil { - m.Pagination = &query.PageResponse{} + m.Pagination = &query.PageRequest{} } if err := m.Pagination.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err @@ -5309,7 +3741,7 @@ func (m *QueryActiveFinalityProvidersAtHeightResponse) Unmarshal(dAtA []byte) er } return nil } -func (m *QueryActivatedHeightRequest) Unmarshal(dAtA []byte) error { +func (m *QueryBTCDelegationsResponse) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -5332,67 +3764,51 @@ func (m *QueryActivatedHeightRequest) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: QueryActivatedHeightRequest: wiretype end group for non-group") + return fmt.Errorf("proto: QueryBTCDelegationsResponse: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: QueryActivatedHeightRequest: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: QueryBTCDelegationsResponse: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { - default: - iNdEx = preIndex - skippy, err := skipQuery(dAtA[iNdEx:]) - if err != nil { - return err + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field BtcDelegations", wireType) } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthQuery + 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 (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF + if msglen < 0 { + return ErrInvalidLengthQuery } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *QueryActivatedHeightResponse) 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 + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthQuery } - if iNdEx >= l { + if postIndex > l { return io.ErrUnexpectedEOF } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break + m.BtcDelegations = append(m.BtcDelegations, &BTCDelegationResponse{}) + if err := m.BtcDelegations[len(m.BtcDelegations)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: QueryActivatedHeightResponse: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: QueryActivatedHeightResponse: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field Height", wireType) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Pagination", wireType) } - m.Height = 0 + var msglen int for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowQuery @@ -5402,11 +3818,28 @@ func (m *QueryActivatedHeightResponse) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - m.Height |= uint64(b&0x7F) << shift + 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.Pagination == nil { + m.Pagination = &query.PageResponse{} + } + if err := m.Pagination.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex default: iNdEx = preIndex skippy, err := skipQuery(dAtA[iNdEx:]) @@ -5966,6 +4399,25 @@ func (m *BTCDelegationResponse) Unmarshal(dAtA []byte) error { } iNdEx = postIndex case 4: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field StakingTime", wireType) + } + m.StakingTime = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.StakingTime |= uint32(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 5: if wireType != 0 { return fmt.Errorf("proto: wrong wireType = %d for field StartHeight", wireType) } @@ -5979,12 +4431,12 @@ func (m *BTCDelegationResponse) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - m.StartHeight |= uint64(b&0x7F) << shift + m.StartHeight |= uint32(b&0x7F) << shift if b < 0x80 { break } } - case 5: + case 6: if wireType != 0 { return fmt.Errorf("proto: wrong wireType = %d for field EndHeight", wireType) } @@ -5998,12 +4450,12 @@ func (m *BTCDelegationResponse) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - m.EndHeight |= uint64(b&0x7F) << shift + m.EndHeight |= uint32(b&0x7F) << shift if b < 0x80 { break } } - case 6: + case 7: if wireType != 0 { return fmt.Errorf("proto: wrong wireType = %d for field TotalSat", wireType) } @@ -6022,7 +4474,7 @@ func (m *BTCDelegationResponse) Unmarshal(dAtA []byte) error { break } } - case 7: + case 8: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field StakingTxHex", wireType) } @@ -6054,7 +4506,7 @@ func (m *BTCDelegationResponse) Unmarshal(dAtA []byte) error { } m.StakingTxHex = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex - case 8: + case 9: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field SlashingTxHex", wireType) } @@ -6086,7 +4538,7 @@ func (m *BTCDelegationResponse) Unmarshal(dAtA []byte) error { } m.SlashingTxHex = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex - case 9: + case 10: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field DelegatorSlashSigHex", wireType) } @@ -6118,7 +4570,7 @@ func (m *BTCDelegationResponse) Unmarshal(dAtA []byte) error { } m.DelegatorSlashSigHex = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex - case 10: + case 11: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field CovenantSigs", wireType) } @@ -6152,7 +4604,7 @@ func (m *BTCDelegationResponse) Unmarshal(dAtA []byte) error { return err } iNdEx = postIndex - case 11: + case 12: if wireType != 0 { return fmt.Errorf("proto: wrong wireType = %d for field StakingOutputIdx", wireType) } @@ -6171,7 +4623,7 @@ func (m *BTCDelegationResponse) Unmarshal(dAtA []byte) error { break } } - case 12: + case 13: if wireType != 0 { return fmt.Errorf("proto: wrong wireType = %d for field Active", wireType) } @@ -6191,7 +4643,7 @@ func (m *BTCDelegationResponse) Unmarshal(dAtA []byte) error { } } m.Active = bool(v != 0) - case 13: + case 14: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field StatusDesc", wireType) } @@ -6223,7 +4675,7 @@ func (m *BTCDelegationResponse) Unmarshal(dAtA []byte) error { } m.StatusDesc = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex - case 14: + case 15: if wireType != 0 { return fmt.Errorf("proto: wrong wireType = %d for field UnbondingTime", wireType) } @@ -6242,7 +4694,7 @@ func (m *BTCDelegationResponse) Unmarshal(dAtA []byte) error { break } } - case 15: + case 16: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field UndelegationResponse", wireType) } @@ -6278,7 +4730,7 @@ func (m *BTCDelegationResponse) Unmarshal(dAtA []byte) error { return err } iNdEx = postIndex - case 16: + case 17: if wireType != 0 { return fmt.Errorf("proto: wrong wireType = %d for field ParamsVersion", wireType) } @@ -6318,7 +4770,7 @@ func (m *BTCDelegationResponse) Unmarshal(dAtA []byte) error { } return nil } -func (m *BTCUndelegationResponse) Unmarshal(dAtA []byte) error { +func (m *DelegatorUnbondingInfoResponse) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -6341,15 +4793,15 @@ func (m *BTCUndelegationResponse) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: BTCUndelegationResponse: wiretype end group for non-group") + return fmt.Errorf("proto: DelegatorUnbondingInfoResponse: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: BTCUndelegationResponse: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: DelegatorUnbondingInfoResponse: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field UnbondingTxHex", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field SpendStakeTxHex", wireType) } var stringLen uint64 for shift := uint(0); ; shift += 7 { @@ -6377,11 +4829,61 @@ func (m *BTCUndelegationResponse) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.UnbondingTxHex = string(dAtA[iNdEx:postIndex]) + m.SpendStakeTxHex = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex - case 2: + 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 *BTCUndelegationResponse) 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: BTCUndelegationResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: BTCUndelegationResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field DelegatorUnbondingSigHex", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field UnbondingTxHex", wireType) } var stringLen uint64 for shift := uint(0); ; shift += 7 { @@ -6409,9 +4911,9 @@ func (m *BTCUndelegationResponse) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.DelegatorUnbondingSigHex = string(dAtA[iNdEx:postIndex]) + m.UnbondingTxHex = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex - case 3: + case 2: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field CovenantUnbondingSigList", wireType) } @@ -6445,7 +4947,7 @@ func (m *BTCUndelegationResponse) Unmarshal(dAtA []byte) error { return err } iNdEx = postIndex - case 4: + case 3: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field SlashingTxHex", wireType) } @@ -6477,7 +4979,7 @@ func (m *BTCUndelegationResponse) Unmarshal(dAtA []byte) error { } m.SlashingTxHex = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex - case 5: + case 4: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field DelegatorSlashingSigHex", wireType) } @@ -6509,7 +5011,7 @@ func (m *BTCUndelegationResponse) Unmarshal(dAtA []byte) error { } m.DelegatorSlashingSigHex = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex - case 6: + case 5: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field CovenantSlashingSigs", wireType) } @@ -6543,6 +5045,42 @@ func (m *BTCUndelegationResponse) Unmarshal(dAtA []byte) error { return err } iNdEx = postIndex + case 6: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field DelegatorUnbondingInfoResponse", 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.DelegatorUnbondingInfoResponse == nil { + m.DelegatorUnbondingInfoResponse = &DelegatorUnbondingInfoResponse{} + } + if err := m.DelegatorUnbondingInfoResponse.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex default: iNdEx = preIndex skippy, err := skipQuery(dAtA[iNdEx:]) @@ -6885,7 +5423,7 @@ func (m *FinalityProviderResponse) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - m.SlashedBtcHeight |= uint64(b&0x7F) << shift + m.SlashedBtcHeight |= uint32(b&0x7F) << shift if b < 0x80 { break } @@ -6910,25 +5448,6 @@ func (m *FinalityProviderResponse) Unmarshal(dAtA []byte) error { } } case 9: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field VotingPower", wireType) - } - m.VotingPower = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowQuery - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.VotingPower |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - case 10: if wireType != 0 { return fmt.Errorf("proto: wrong wireType = %d for field Jailed", wireType) } diff --git a/x/btcstaking/types/query.pb.gw.go b/x/btcstaking/types/query.pb.gw.go index 532fbec7f..aa5969378 100644 --- a/x/btcstaking/types/query.pb.gw.go +++ b/x/btcstaking/types/query.pb.gw.go @@ -196,257 +196,79 @@ func local_request_Query_FinalityProvider_0(ctx context.Context, marshaler runti } var ( - filter_Query_BTCDelegations_0 = &utilities.DoubleArray{Encoding: map[string]int{}, Base: []int(nil), Check: []int(nil)} + filter_Query_BTCDelegations_0 = &utilities.DoubleArray{Encoding: map[string]int{"status": 0}, Base: []int{1, 1, 0}, Check: []int{0, 1, 2}} ) func request_Query_BTCDelegations_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { var protoReq QueryBTCDelegationsRequest var metadata runtime.ServerMetadata - if err := req.ParseForm(); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_BTCDelegations_0); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - - msg, err := client.BTCDelegations(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) - return msg, metadata, err - -} - -func local_request_Query_BTCDelegations_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq QueryBTCDelegationsRequest - var metadata runtime.ServerMetadata - - if err := req.ParseForm(); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_BTCDelegations_0); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - - msg, err := server.BTCDelegations(ctx, &protoReq) - return msg, metadata, err - -} - -var ( - filter_Query_ActiveFinalityProvidersAtHeight_0 = &utilities.DoubleArray{Encoding: map[string]int{"height": 0}, Base: []int{1, 1, 0}, Check: []int{0, 1, 2}} -) - -func request_Query_ActiveFinalityProvidersAtHeight_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq QueryActiveFinalityProvidersAtHeightRequest - var metadata runtime.ServerMetadata - var ( val string + e int32 ok bool err error _ = err ) - val, ok = pathParams["height"] + val, ok = pathParams["status"] if !ok { - return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "height") + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "status") } - protoReq.Height, err = runtime.Uint64(val) + e, err = runtime.Enum(val, BTCDelegationStatus_value) if err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "height", err) + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "status", err) } + protoReq.Status = BTCDelegationStatus(e) + if err := req.ParseForm(); err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } - if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_ActiveFinalityProvidersAtHeight_0); err != nil { + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_BTCDelegations_0); err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } - msg, err := client.ActiveFinalityProvidersAtHeight(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + msg, err := client.BTCDelegations(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) return msg, metadata, err } -func local_request_Query_ActiveFinalityProvidersAtHeight_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq QueryActiveFinalityProvidersAtHeightRequest +func local_request_Query_BTCDelegations_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryBTCDelegationsRequest var metadata runtime.ServerMetadata var ( val string + e int32 ok bool err error _ = err ) - val, ok = pathParams["height"] + val, ok = pathParams["status"] if !ok { - return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "height") + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "status") } - protoReq.Height, err = runtime.Uint64(val) + e, err = runtime.Enum(val, BTCDelegationStatus_value) if err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "height", err) + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "status", err) } + protoReq.Status = BTCDelegationStatus(e) + if err := req.ParseForm(); err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } - if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_ActiveFinalityProvidersAtHeight_0); err != nil { + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_BTCDelegations_0); err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } - msg, err := server.ActiveFinalityProvidersAtHeight(ctx, &protoReq) - return msg, metadata, err - -} - -func request_Query_FinalityProviderPowerAtHeight_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq QueryFinalityProviderPowerAtHeightRequest - var metadata runtime.ServerMetadata - - var ( - val string - ok bool - err error - _ = err - ) - - val, ok = pathParams["fp_btc_pk_hex"] - if !ok { - return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "fp_btc_pk_hex") - } - - protoReq.FpBtcPkHex, err = runtime.String(val) - - if err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "fp_btc_pk_hex", err) - } - - val, ok = pathParams["height"] - if !ok { - return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "height") - } - - protoReq.Height, err = runtime.Uint64(val) - - if err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "height", err) - } - - msg, err := client.FinalityProviderPowerAtHeight(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) - return msg, metadata, err - -} - -func local_request_Query_FinalityProviderPowerAtHeight_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq QueryFinalityProviderPowerAtHeightRequest - var metadata runtime.ServerMetadata - - var ( - val string - ok bool - err error - _ = err - ) - - val, ok = pathParams["fp_btc_pk_hex"] - if !ok { - return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "fp_btc_pk_hex") - } - - protoReq.FpBtcPkHex, err = runtime.String(val) - - if err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "fp_btc_pk_hex", err) - } - - val, ok = pathParams["height"] - if !ok { - return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "height") - } - - protoReq.Height, err = runtime.Uint64(val) - - if err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "height", err) - } - - msg, err := server.FinalityProviderPowerAtHeight(ctx, &protoReq) - return msg, metadata, err - -} - -func request_Query_FinalityProviderCurrentPower_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq QueryFinalityProviderCurrentPowerRequest - var metadata runtime.ServerMetadata - - var ( - val string - ok bool - err error - _ = err - ) - - val, ok = pathParams["fp_btc_pk_hex"] - if !ok { - return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "fp_btc_pk_hex") - } - - protoReq.FpBtcPkHex, err = runtime.String(val) - - if err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "fp_btc_pk_hex", err) - } - - msg, err := client.FinalityProviderCurrentPower(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) - return msg, metadata, err - -} - -func local_request_Query_FinalityProviderCurrentPower_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq QueryFinalityProviderCurrentPowerRequest - var metadata runtime.ServerMetadata - - var ( - val string - ok bool - err error - _ = err - ) - - val, ok = pathParams["fp_btc_pk_hex"] - if !ok { - return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "fp_btc_pk_hex") - } - - protoReq.FpBtcPkHex, err = runtime.String(val) - - if err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "fp_btc_pk_hex", err) - } - - msg, err := server.FinalityProviderCurrentPower(ctx, &protoReq) - return msg, metadata, err - -} - -func request_Query_ActivatedHeight_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq QueryActivatedHeightRequest - var metadata runtime.ServerMetadata - - msg, err := client.ActivatedHeight(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) - return msg, metadata, err - -} - -func local_request_Query_ActivatedHeight_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq QueryActivatedHeightRequest - var metadata runtime.ServerMetadata - - msg, err := server.ActivatedHeight(ctx, &protoReq) + msg, err := server.BTCDelegations(ctx, &protoReq) return msg, metadata, err } @@ -698,98 +520,6 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv }) - mux.Handle("GET", pattern_Query_ActiveFinalityProvidersAtHeight_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { - ctx, cancel := context.WithCancel(req.Context()) - defer cancel() - var stream runtime.ServerTransportStream - ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) - inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - resp, md, err := local_request_Query_ActiveFinalityProvidersAtHeight_0(rctx, inboundMarshaler, server, req, pathParams) - md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) - ctx = runtime.NewServerMetadataContext(ctx, md) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - - forward_Query_ActiveFinalityProvidersAtHeight_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - - }) - - mux.Handle("GET", pattern_Query_FinalityProviderPowerAtHeight_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { - ctx, cancel := context.WithCancel(req.Context()) - defer cancel() - var stream runtime.ServerTransportStream - ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) - inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - resp, md, err := local_request_Query_FinalityProviderPowerAtHeight_0(rctx, inboundMarshaler, server, req, pathParams) - md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) - ctx = runtime.NewServerMetadataContext(ctx, md) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - - forward_Query_FinalityProviderPowerAtHeight_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - - }) - - mux.Handle("GET", pattern_Query_FinalityProviderCurrentPower_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { - ctx, cancel := context.WithCancel(req.Context()) - defer cancel() - var stream runtime.ServerTransportStream - ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) - inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - resp, md, err := local_request_Query_FinalityProviderCurrentPower_0(rctx, inboundMarshaler, server, req, pathParams) - md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) - ctx = runtime.NewServerMetadataContext(ctx, md) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - - forward_Query_FinalityProviderCurrentPower_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - - }) - - mux.Handle("GET", pattern_Query_ActivatedHeight_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { - ctx, cancel := context.WithCancel(req.Context()) - defer cancel() - var stream runtime.ServerTransportStream - ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) - inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - resp, md, err := local_request_Query_ActivatedHeight_0(rctx, inboundMarshaler, server, req, pathParams) - md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) - ctx = runtime.NewServerMetadataContext(ctx, md) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - - forward_Query_ActivatedHeight_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - - }) - mux.Handle("GET", pattern_Query_FinalityProviderDelegations_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() @@ -977,86 +707,6 @@ func RegisterQueryHandlerClient(ctx context.Context, mux *runtime.ServeMux, clie }) - mux.Handle("GET", pattern_Query_ActiveFinalityProvidersAtHeight_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { - ctx, cancel := context.WithCancel(req.Context()) - defer cancel() - inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - rctx, err := runtime.AnnotateContext(ctx, mux, req) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - resp, md, err := request_Query_ActiveFinalityProvidersAtHeight_0(rctx, inboundMarshaler, client, req, pathParams) - ctx = runtime.NewServerMetadataContext(ctx, md) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - - forward_Query_ActiveFinalityProvidersAtHeight_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - - }) - - mux.Handle("GET", pattern_Query_FinalityProviderPowerAtHeight_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { - ctx, cancel := context.WithCancel(req.Context()) - defer cancel() - inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - rctx, err := runtime.AnnotateContext(ctx, mux, req) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - resp, md, err := request_Query_FinalityProviderPowerAtHeight_0(rctx, inboundMarshaler, client, req, pathParams) - ctx = runtime.NewServerMetadataContext(ctx, md) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - - forward_Query_FinalityProviderPowerAtHeight_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - - }) - - mux.Handle("GET", pattern_Query_FinalityProviderCurrentPower_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { - ctx, cancel := context.WithCancel(req.Context()) - defer cancel() - inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - rctx, err := runtime.AnnotateContext(ctx, mux, req) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - resp, md, err := request_Query_FinalityProviderCurrentPower_0(rctx, inboundMarshaler, client, req, pathParams) - ctx = runtime.NewServerMetadataContext(ctx, md) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - - forward_Query_FinalityProviderCurrentPower_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - - }) - - mux.Handle("GET", pattern_Query_ActivatedHeight_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { - ctx, cancel := context.WithCancel(req.Context()) - defer cancel() - inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - rctx, err := runtime.AnnotateContext(ctx, mux, req) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - resp, md, err := request_Query_ActivatedHeight_0(rctx, inboundMarshaler, client, req, pathParams) - ctx = runtime.NewServerMetadataContext(ctx, md) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - - forward_Query_ActivatedHeight_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - - }) - mux.Handle("GET", pattern_Query_FinalityProviderDelegations_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() @@ -1109,19 +759,11 @@ var ( pattern_Query_FinalityProvider_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 1, 0, 4, 1, 5, 4, 2, 5}, []string{"babylon", "btcstaking", "v1", "finality_providers", "fp_btc_pk_hex", "finality_provider"}, "", runtime.AssumeColonVerbOpt(false))) - pattern_Query_BTCDelegations_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"babylon", "btcstaking", "v1", "btc_delegations"}, "", runtime.AssumeColonVerbOpt(false))) - - pattern_Query_ActiveFinalityProvidersAtHeight_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 1, 0, 4, 1, 5, 4}, []string{"babylon", "btcstaking", "v1", "finality_providers", "height"}, "", runtime.AssumeColonVerbOpt(false))) - - pattern_Query_FinalityProviderPowerAtHeight_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 1, 0, 4, 1, 5, 4, 2, 5, 1, 0, 4, 1, 5, 6}, []string{"babylon", "btcstaking", "v1", "finality_providers", "fp_btc_pk_hex", "power", "height"}, "", runtime.AssumeColonVerbOpt(false))) - - pattern_Query_FinalityProviderCurrentPower_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 1, 0, 4, 1, 5, 4, 2, 5}, []string{"babylon", "btcstaking", "v1", "finality_providers", "fp_btc_pk_hex", "power"}, "", runtime.AssumeColonVerbOpt(false))) - - pattern_Query_ActivatedHeight_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"babylon", "btcstaking", "v1", "activated_height"}, "", runtime.AssumeColonVerbOpt(false))) + pattern_Query_BTCDelegations_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 1, 0, 4, 1, 5, 4}, []string{"babylon", "btcstaking", "v1", "btc_delegations", "status"}, "", runtime.AssumeColonVerbOpt(false))) pattern_Query_FinalityProviderDelegations_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 1, 0, 4, 1, 5, 4, 2, 5}, []string{"babylon", "btcstaking", "v1", "finality_providers", "fp_btc_pk_hex", "delegations"}, "", runtime.AssumeColonVerbOpt(false))) - pattern_Query_BTCDelegation_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 1, 0, 4, 1, 5, 4}, []string{"babylon", "btcstaking", "v1", "btc_delegations", "staking_tx_hash_hex"}, "", runtime.AssumeColonVerbOpt(false))) + pattern_Query_BTCDelegation_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 1, 0, 4, 1, 5, 4}, []string{"babylon", "btcstaking", "v1", "btc_delegation", "staking_tx_hash_hex"}, "", runtime.AssumeColonVerbOpt(false))) ) var ( @@ -1135,14 +777,6 @@ var ( forward_Query_BTCDelegations_0 = runtime.ForwardResponseMessage - forward_Query_ActiveFinalityProvidersAtHeight_0 = runtime.ForwardResponseMessage - - forward_Query_FinalityProviderPowerAtHeight_0 = runtime.ForwardResponseMessage - - forward_Query_FinalityProviderCurrentPower_0 = runtime.ForwardResponseMessage - - forward_Query_ActivatedHeight_0 = runtime.ForwardResponseMessage - forward_Query_FinalityProviderDelegations_0 = runtime.ForwardResponseMessage forward_Query_BTCDelegation_0 = runtime.ForwardResponseMessage diff --git a/x/btcstaking/types/tx.pb.go b/x/btcstaking/types/tx.pb.go index a71b27121..b8657aba5 100644 --- a/x/btcstaking/types/tx.pb.go +++ b/x/btcstaking/types/tx.pb.go @@ -8,7 +8,6 @@ import ( cosmossdk_io_math "cosmossdk.io/math" fmt "fmt" github_com_babylonlabs_io_babylon_types "github.com/babylonlabs-io/babylon/types" - types1 "github.com/babylonlabs-io/babylon/x/btccheckpoint/types" _ "github.com/cosmos/cosmos-proto" _ "github.com/cosmos/cosmos-sdk/types/msgservice" types "github.com/cosmos/cosmos-sdk/x/staking/types" @@ -269,34 +268,36 @@ type MsgCreateBTCDelegation struct { StakingTime uint32 `protobuf:"varint,5,opt,name=staking_time,json=stakingTime,proto3" json:"staking_time,omitempty"` // staking_value is the amount of satoshis locked in staking output StakingValue int64 `protobuf:"varint,6,opt,name=staking_value,json=stakingValue,proto3" json:"staking_value,omitempty"` - // staking_tx is the staking tx along with the merkle proof of inclusion in btc block - StakingTx *types1.TransactionInfo `protobuf:"bytes,7,opt,name=staking_tx,json=stakingTx,proto3" json:"staking_tx,omitempty"` + // staking_tx is a bitcoin staking transaction i.e transaction that locks funds + StakingTx []byte `protobuf:"bytes,7,opt,name=staking_tx,json=stakingTx,proto3" json:"staking_tx,omitempty"` + // staking_tx_inclusion_proof is the inclusion proof of the staking tx in BTC chain + StakingTxInclusionProof *InclusionProof `protobuf:"bytes,8,opt,name=staking_tx_inclusion_proof,json=stakingTxInclusionProof,proto3" json:"staking_tx_inclusion_proof,omitempty"` // slashing_tx is the slashing tx // Note that the tx itself does not contain signatures, which are off-chain. - SlashingTx *BTCSlashingTx `protobuf:"bytes,8,opt,name=slashing_tx,json=slashingTx,proto3,customtype=BTCSlashingTx" json:"slashing_tx,omitempty"` + SlashingTx *BTCSlashingTx `protobuf:"bytes,9,opt,name=slashing_tx,json=slashingTx,proto3,customtype=BTCSlashingTx" json:"slashing_tx,omitempty"` // delegator_slashing_sig is the signature on the slashing tx by the delegator (i.e., SK corresponding to btc_pk). // It will be a part of the witness for the staking tx output. // The staking tx output further needs signatures from covenant and finality provider in // order to be spendable. - DelegatorSlashingSig *github_com_babylonlabs_io_babylon_types.BIP340Signature `protobuf:"bytes,9,opt,name=delegator_slashing_sig,json=delegatorSlashingSig,proto3,customtype=github.com/babylonlabs-io/babylon/types.BIP340Signature" json:"delegator_slashing_sig,omitempty"` + DelegatorSlashingSig *github_com_babylonlabs_io_babylon_types.BIP340Signature `protobuf:"bytes,10,opt,name=delegator_slashing_sig,json=delegatorSlashingSig,proto3,customtype=github.com/babylonlabs-io/babylon/types.BIP340Signature" json:"delegator_slashing_sig,omitempty"` // unbonding_time is the time lock used when funds are being unbonded. It is be used in: // - unbonding transaction, time lock spending path // - staking slashing transaction, change output // - unbonding slashing transaction, change output // It must be smaller than math.MaxUInt16 and larger that max(MinUnbondingTime, CheckpointFinalizationTimeout) - UnbondingTime uint32 `protobuf:"varint,10,opt,name=unbonding_time,json=unbondingTime,proto3" json:"unbonding_time,omitempty"` + UnbondingTime uint32 `protobuf:"varint,11,opt,name=unbonding_time,json=unbondingTime,proto3" json:"unbonding_time,omitempty"` // fields related to unbonding transaction // unbonding_tx is a bitcoin unbonding transaction i.e transaction that spends // staking output and sends it to the unbonding output - UnbondingTx []byte `protobuf:"bytes,11,opt,name=unbonding_tx,json=unbondingTx,proto3" json:"unbonding_tx,omitempty"` + UnbondingTx []byte `protobuf:"bytes,12,opt,name=unbonding_tx,json=unbondingTx,proto3" json:"unbonding_tx,omitempty"` // unbonding_value is amount of satoshis locked in unbonding output. // NOTE: staking_value and unbonding_value could be different because of the difference between the fee for staking tx and that for unbonding - UnbondingValue int64 `protobuf:"varint,12,opt,name=unbonding_value,json=unbondingValue,proto3" json:"unbonding_value,omitempty"` + UnbondingValue int64 `protobuf:"varint,13,opt,name=unbonding_value,json=unbondingValue,proto3" json:"unbonding_value,omitempty"` // unbonding_slashing_tx is the slashing tx which slash unbonding contract // Note that the tx itself does not contain signatures, which are off-chain. - UnbondingSlashingTx *BTCSlashingTx `protobuf:"bytes,13,opt,name=unbonding_slashing_tx,json=unbondingSlashingTx,proto3,customtype=BTCSlashingTx" json:"unbonding_slashing_tx,omitempty"` + UnbondingSlashingTx *BTCSlashingTx `protobuf:"bytes,14,opt,name=unbonding_slashing_tx,json=unbondingSlashingTx,proto3,customtype=BTCSlashingTx" json:"unbonding_slashing_tx,omitempty"` // delegator_unbonding_slashing_sig is the signature on the slashing tx by the delegator (i.e., SK corresponding to btc_pk). - DelegatorUnbondingSlashingSig *github_com_babylonlabs_io_babylon_types.BIP340Signature `protobuf:"bytes,14,opt,name=delegator_unbonding_slashing_sig,json=delegatorUnbondingSlashingSig,proto3,customtype=github.com/babylonlabs-io/babylon/types.BIP340Signature" json:"delegator_unbonding_slashing_sig,omitempty"` + DelegatorUnbondingSlashingSig *github_com_babylonlabs_io_babylon_types.BIP340Signature `protobuf:"bytes,15,opt,name=delegator_unbonding_slashing_sig,json=delegatorUnbondingSlashingSig,proto3,customtype=github.com/babylonlabs-io/babylon/types.BIP340Signature" json:"delegator_unbonding_slashing_sig,omitempty"` } func (m *MsgCreateBTCDelegation) Reset() { *m = MsgCreateBTCDelegation{} } @@ -360,13 +361,20 @@ func (m *MsgCreateBTCDelegation) GetStakingValue() int64 { return 0 } -func (m *MsgCreateBTCDelegation) GetStakingTx() *types1.TransactionInfo { +func (m *MsgCreateBTCDelegation) GetStakingTx() []byte { if m != nil { return m.StakingTx } return nil } +func (m *MsgCreateBTCDelegation) GetStakingTxInclusionProof() *InclusionProof { + if m != nil { + return m.StakingTxInclusionProof + } + return nil +} + func (m *MsgCreateBTCDelegation) GetUnbondingTime() uint32 { if m != nil { return m.UnbondingTime @@ -425,6 +433,111 @@ func (m *MsgCreateBTCDelegationResponse) XXX_DiscardUnknown() { var xxx_messageInfo_MsgCreateBTCDelegationResponse proto.InternalMessageInfo +// MsgAddBTCDelegationInclusionProof is the message for adding proof of inclusion of BTC delegation on BTC chain +type MsgAddBTCDelegationInclusionProof struct { + Signer string `protobuf:"bytes,1,opt,name=signer,proto3" json:"signer,omitempty"` + // staking_tx_hash is the hash of the staking tx. + // It uniquely identifies a BTC delegation + StakingTxHash string `protobuf:"bytes,2,opt,name=staking_tx_hash,json=stakingTxHash,proto3" json:"staking_tx_hash,omitempty"` + // staking_tx_inclusion_proof is the inclusion proof of the staking tx in BTC chain + StakingTxInclusionProof *InclusionProof `protobuf:"bytes,3,opt,name=staking_tx_inclusion_proof,json=stakingTxInclusionProof,proto3" json:"staking_tx_inclusion_proof,omitempty"` +} + +func (m *MsgAddBTCDelegationInclusionProof) Reset() { *m = MsgAddBTCDelegationInclusionProof{} } +func (m *MsgAddBTCDelegationInclusionProof) String() string { return proto.CompactTextString(m) } +func (*MsgAddBTCDelegationInclusionProof) ProtoMessage() {} +func (*MsgAddBTCDelegationInclusionProof) Descriptor() ([]byte, []int) { + return fileDescriptor_4baddb53e97f38f2, []int{6} +} +func (m *MsgAddBTCDelegationInclusionProof) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgAddBTCDelegationInclusionProof) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgAddBTCDelegationInclusionProof.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 *MsgAddBTCDelegationInclusionProof) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgAddBTCDelegationInclusionProof.Merge(m, src) +} +func (m *MsgAddBTCDelegationInclusionProof) XXX_Size() int { + return m.Size() +} +func (m *MsgAddBTCDelegationInclusionProof) XXX_DiscardUnknown() { + xxx_messageInfo_MsgAddBTCDelegationInclusionProof.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgAddBTCDelegationInclusionProof proto.InternalMessageInfo + +func (m *MsgAddBTCDelegationInclusionProof) GetSigner() string { + if m != nil { + return m.Signer + } + return "" +} + +func (m *MsgAddBTCDelegationInclusionProof) GetStakingTxHash() string { + if m != nil { + return m.StakingTxHash + } + return "" +} + +func (m *MsgAddBTCDelegationInclusionProof) GetStakingTxInclusionProof() *InclusionProof { + if m != nil { + return m.StakingTxInclusionProof + } + return nil +} + +// MsgAddBTCDelegationInclusionProofResponse is the response for MsgAddBTCDelegationInclusionProof +type MsgAddBTCDelegationInclusionProofResponse struct { +} + +func (m *MsgAddBTCDelegationInclusionProofResponse) Reset() { + *m = MsgAddBTCDelegationInclusionProofResponse{} +} +func (m *MsgAddBTCDelegationInclusionProofResponse) String() string { + return proto.CompactTextString(m) +} +func (*MsgAddBTCDelegationInclusionProofResponse) ProtoMessage() {} +func (*MsgAddBTCDelegationInclusionProofResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_4baddb53e97f38f2, []int{7} +} +func (m *MsgAddBTCDelegationInclusionProofResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgAddBTCDelegationInclusionProofResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgAddBTCDelegationInclusionProofResponse.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 *MsgAddBTCDelegationInclusionProofResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgAddBTCDelegationInclusionProofResponse.Merge(m, src) +} +func (m *MsgAddBTCDelegationInclusionProofResponse) XXX_Size() int { + return m.Size() +} +func (m *MsgAddBTCDelegationInclusionProofResponse) XXX_DiscardUnknown() { + xxx_messageInfo_MsgAddBTCDelegationInclusionProofResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgAddBTCDelegationInclusionProofResponse proto.InternalMessageInfo + // MsgAddCovenantSigs is the message for handling signatures from a covenant member type MsgAddCovenantSigs struct { Signer string `protobuf:"bytes,1,opt,name=signer,proto3" json:"signer,omitempty"` @@ -451,7 +564,7 @@ func (m *MsgAddCovenantSigs) Reset() { *m = MsgAddCovenantSigs{} } func (m *MsgAddCovenantSigs) String() string { return proto.CompactTextString(m) } func (*MsgAddCovenantSigs) ProtoMessage() {} func (*MsgAddCovenantSigs) Descriptor() ([]byte, []int) { - return fileDescriptor_4baddb53e97f38f2, []int{6} + return fileDescriptor_4baddb53e97f38f2, []int{8} } func (m *MsgAddCovenantSigs) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -516,7 +629,7 @@ func (m *MsgAddCovenantSigsResponse) Reset() { *m = MsgAddCovenantSigsRe func (m *MsgAddCovenantSigsResponse) String() string { return proto.CompactTextString(m) } func (*MsgAddCovenantSigsResponse) ProtoMessage() {} func (*MsgAddCovenantSigsResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_4baddb53e97f38f2, []int{7} + return fileDescriptor_4baddb53e97f38f2, []int{9} } func (m *MsgAddCovenantSigsResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -553,16 +666,19 @@ type MsgBTCUndelegate struct { // staking_tx_hash is the hash of the staking tx. // It uniquely identifies a BTC delegation StakingTxHash string `protobuf:"bytes,2,opt,name=staking_tx_hash,json=stakingTxHash,proto3" json:"staking_tx_hash,omitempty"` - // unbonding_tx_sig is the signature of the staker on the unbonding tx submitted to babylon - // the signature follows encoding in BIP-340 spec - UnbondingTxSig *github_com_babylonlabs_io_babylon_types.BIP340Signature `protobuf:"bytes,3,opt,name=unbonding_tx_sig,json=unbondingTxSig,proto3,customtype=github.com/babylonlabs-io/babylon/types.BIP340Signature" json:"unbonding_tx_sig,omitempty"` + // stake_spending_tx is a bitcoin transaction that spends the staking transaction + // i.e it has staking output as an input + StakeSpendingTx []byte `protobuf:"bytes,3,opt,name=stake_spending_tx,json=stakeSpendingTx,proto3" json:"stake_spending_tx,omitempty"` + // spend_spending_tx_inclusion_proof is the proof of inclusion of the + // stake_spending_tx in the BTC chain + StakeSpendingTxInclusionProof *InclusionProof `protobuf:"bytes,4,opt,name=stake_spending_tx_inclusion_proof,json=stakeSpendingTxInclusionProof,proto3" json:"stake_spending_tx_inclusion_proof,omitempty"` } func (m *MsgBTCUndelegate) Reset() { *m = MsgBTCUndelegate{} } func (m *MsgBTCUndelegate) String() string { return proto.CompactTextString(m) } func (*MsgBTCUndelegate) ProtoMessage() {} func (*MsgBTCUndelegate) Descriptor() ([]byte, []int) { - return fileDescriptor_4baddb53e97f38f2, []int{8} + return fileDescriptor_4baddb53e97f38f2, []int{10} } func (m *MsgBTCUndelegate) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -605,6 +721,20 @@ func (m *MsgBTCUndelegate) GetStakingTxHash() string { return "" } +func (m *MsgBTCUndelegate) GetStakeSpendingTx() []byte { + if m != nil { + return m.StakeSpendingTx + } + return nil +} + +func (m *MsgBTCUndelegate) GetStakeSpendingTxInclusionProof() *InclusionProof { + if m != nil { + return m.StakeSpendingTxInclusionProof + } + return nil +} + // MsgBTCUndelegateResponse is the response for MsgBTCUndelegate type MsgBTCUndelegateResponse struct { } @@ -613,7 +743,7 @@ func (m *MsgBTCUndelegateResponse) Reset() { *m = MsgBTCUndelegateRespon func (m *MsgBTCUndelegateResponse) String() string { return proto.CompactTextString(m) } func (*MsgBTCUndelegateResponse) ProtoMessage() {} func (*MsgBTCUndelegateResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_4baddb53e97f38f2, []int{9} + return fileDescriptor_4baddb53e97f38f2, []int{11} } func (m *MsgBTCUndelegateResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -660,7 +790,7 @@ func (m *MsgSelectiveSlashingEvidence) Reset() { *m = MsgSelectiveSlashi func (m *MsgSelectiveSlashingEvidence) String() string { return proto.CompactTextString(m) } func (*MsgSelectiveSlashingEvidence) ProtoMessage() {} func (*MsgSelectiveSlashingEvidence) Descriptor() ([]byte, []int) { - return fileDescriptor_4baddb53e97f38f2, []int{10} + return fileDescriptor_4baddb53e97f38f2, []int{12} } func (m *MsgSelectiveSlashingEvidence) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -718,7 +848,7 @@ func (m *MsgSelectiveSlashingEvidenceResponse) Reset() { *m = MsgSelecti func (m *MsgSelectiveSlashingEvidenceResponse) String() string { return proto.CompactTextString(m) } func (*MsgSelectiveSlashingEvidenceResponse) ProtoMessage() {} func (*MsgSelectiveSlashingEvidenceResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_4baddb53e97f38f2, []int{11} + return fileDescriptor_4baddb53e97f38f2, []int{13} } func (m *MsgSelectiveSlashingEvidenceResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -764,7 +894,7 @@ func (m *MsgUpdateParams) Reset() { *m = MsgUpdateParams{} } func (m *MsgUpdateParams) String() string { return proto.CompactTextString(m) } func (*MsgUpdateParams) ProtoMessage() {} func (*MsgUpdateParams) Descriptor() ([]byte, []int) { - return fileDescriptor_4baddb53e97f38f2, []int{12} + return fileDescriptor_4baddb53e97f38f2, []int{14} } func (m *MsgUpdateParams) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -815,7 +945,7 @@ func (m *MsgUpdateParamsResponse) Reset() { *m = MsgUpdateParamsResponse func (m *MsgUpdateParamsResponse) String() string { return proto.CompactTextString(m) } func (*MsgUpdateParamsResponse) ProtoMessage() {} func (*MsgUpdateParamsResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_4baddb53e97f38f2, []int{13} + return fileDescriptor_4baddb53e97f38f2, []int{15} } func (m *MsgUpdateParamsResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -851,6 +981,8 @@ func init() { proto.RegisterType((*MsgEditFinalityProviderResponse)(nil), "babylon.btcstaking.v1.MsgEditFinalityProviderResponse") proto.RegisterType((*MsgCreateBTCDelegation)(nil), "babylon.btcstaking.v1.MsgCreateBTCDelegation") proto.RegisterType((*MsgCreateBTCDelegationResponse)(nil), "babylon.btcstaking.v1.MsgCreateBTCDelegationResponse") + proto.RegisterType((*MsgAddBTCDelegationInclusionProof)(nil), "babylon.btcstaking.v1.MsgAddBTCDelegationInclusionProof") + proto.RegisterType((*MsgAddBTCDelegationInclusionProofResponse)(nil), "babylon.btcstaking.v1.MsgAddBTCDelegationInclusionProofResponse") proto.RegisterType((*MsgAddCovenantSigs)(nil), "babylon.btcstaking.v1.MsgAddCovenantSigs") proto.RegisterType((*MsgAddCovenantSigsResponse)(nil), "babylon.btcstaking.v1.MsgAddCovenantSigsResponse") proto.RegisterType((*MsgBTCUndelegate)(nil), "babylon.btcstaking.v1.MsgBTCUndelegate") @@ -864,88 +996,93 @@ func init() { func init() { proto.RegisterFile("babylon/btcstaking/v1/tx.proto", fileDescriptor_4baddb53e97f38f2) } var fileDescriptor_4baddb53e97f38f2 = []byte{ - // 1284 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x57, 0xcf, 0x6f, 0x13, 0xc7, - 0x17, 0xcf, 0xc6, 0x89, 0xf9, 0xe6, 0x39, 0x4e, 0xf2, 0x5d, 0x42, 0xd8, 0x6c, 0xc1, 0x76, 0x0c, - 0x85, 0x40, 0xc9, 0x9a, 0x04, 0x4a, 0x69, 0xa2, 0x1e, 0x70, 0x12, 0x04, 0x2a, 0x2e, 0xd6, 0xda, - 0xe9, 0xa1, 0x52, 0x65, 0xad, 0x77, 0x27, 0xeb, 0x91, 0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, 0x9e, - 0x0a, 0x1e, 0x3a, 0x27, 0x30, 0x7f, 0xfc, 0xfc, 0xbd, 0x96, 0xcc, 0x74, 0x0c, 0x2a, 0xaf, 0x9f, - 0x18, 0x1a, 0x3a, 0xc4, 0x90, 0x1d, 0x3e, 0x56, 0xae, 0x26, 0x73, 0x0c, 0x01, 0xe5, 0xd2, 0x09, - 0x81, 0xa1, 0xab, 0x1f, 0x04, 0x58, 0x4e, 0x9e, 0xee, 0x5b, 0xc9, 0x74, 0x89, 0x46, 0xf2, 0xd6, - 0x5b, 0x18, 0x85, 0xf1, 0xec, 0xc3, 0xec, 0xd0, 0x9c, 0x5e, 0x49, 0x26, 0x8b, 0xe3, 0x64, 0xe5, - 0x64, 0xb8, 0xc0, 0x8f, 0x3c, 0xfd, 0xed, 0xeb, 0x27, 0xd7, 0x85, 0xf2, 0x67, 0xcf, 0x5e, 0xe6, - 0x84, 0xe7, 0x2f, 0x73, 0xc2, 0x1f, 0x2f, 0x73, 0xc2, 0x8f, 0xaf, 0x72, 0x13, 0xcf, 0x5f, 0xe5, - 0x26, 0x7e, 0x7f, 0x95, 0x9b, 0xf8, 0xe2, 0x04, 0x37, 0xe7, 0x20, 0xfe, 0x87, 0x94, 0x1f, 0xbc, - 0xcd, 0x34, 0xff, 0x43, 0x7a, 0xeb, 0x9f, 0x00, 0x00, 0x00, 0xff, 0xff, 0xf0, 0x32, 0xb3, 0x35, - 0xac, 0x0f, 0x00, 0x00, + // 1365 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x58, 0x4f, 0x6f, 0x13, 0x47, + 0x14, 0xcf, 0xc6, 0x49, 0x4a, 0x9e, 0xed, 0x24, 0x2c, 0x21, 0x71, 0xb6, 0xc4, 0x76, 0x0c, 0x84, + 0x00, 0x8d, 0x4d, 0x80, 0x52, 0x9a, 0xa8, 0x52, 0x71, 0x12, 0x04, 0x2a, 0x2e, 0x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, 0xf4, 0xc8, 0xf3, 0x57, + 0xe9, 0x91, 0xbf, 0x5e, 0xa5, 0x47, 0xbe, 0x3c, 0xc1, 0x73, 0xa0, 0x1b, 0xfe, 0xa7, 0x82, 0xdd, + 0xb8, 0xf5, 0x09, 0xf6, 0x17, 0xc5, 0xad, 0xff, 0x03, 0x00, 0x00, 0xff, 0xff, 0x37, 0x44, 0x0c, + 0x6e, 0xb8, 0x11, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -966,6 +1103,8 @@ type MsgClient interface { EditFinalityProvider(ctx context.Context, in *MsgEditFinalityProvider, opts ...grpc.CallOption) (*MsgEditFinalityProviderResponse, error) // CreateBTCDelegation creates a new BTC delegation CreateBTCDelegation(ctx context.Context, in *MsgCreateBTCDelegation, opts ...grpc.CallOption) (*MsgCreateBTCDelegationResponse, error) + // AddBTCDelegationInclusionProof adds inclusion proof of a given delegation on BTC chain + AddBTCDelegationInclusionProof(ctx context.Context, in *MsgAddBTCDelegationInclusionProof, opts ...grpc.CallOption) (*MsgAddBTCDelegationInclusionProofResponse, error) // AddCovenantSigs handles signatures from a covenant member AddCovenantSigs(ctx context.Context, in *MsgAddCovenantSigs, opts ...grpc.CallOption) (*MsgAddCovenantSigsResponse, error) // BTCUndelegate handles a signature on unbonding tx from its delegator @@ -1012,6 +1151,15 @@ func (c *msgClient) CreateBTCDelegation(ctx context.Context, in *MsgCreateBTCDel return out, nil } +func (c *msgClient) AddBTCDelegationInclusionProof(ctx context.Context, in *MsgAddBTCDelegationInclusionProof, opts ...grpc.CallOption) (*MsgAddBTCDelegationInclusionProofResponse, error) { + out := new(MsgAddBTCDelegationInclusionProofResponse) + err := c.cc.Invoke(ctx, "/babylon.btcstaking.v1.Msg/AddBTCDelegationInclusionProof", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + func (c *msgClient) AddCovenantSigs(ctx context.Context, in *MsgAddCovenantSigs, opts ...grpc.CallOption) (*MsgAddCovenantSigsResponse, error) { out := new(MsgAddCovenantSigsResponse) err := c.cc.Invoke(ctx, "/babylon.btcstaking.v1.Msg/AddCovenantSigs", in, out, opts...) @@ -1056,6 +1204,8 @@ type MsgServer interface { EditFinalityProvider(context.Context, *MsgEditFinalityProvider) (*MsgEditFinalityProviderResponse, error) // CreateBTCDelegation creates a new BTC delegation CreateBTCDelegation(context.Context, *MsgCreateBTCDelegation) (*MsgCreateBTCDelegationResponse, error) + // AddBTCDelegationInclusionProof adds inclusion proof of a given delegation on BTC chain + AddBTCDelegationInclusionProof(context.Context, *MsgAddBTCDelegationInclusionProof) (*MsgAddBTCDelegationInclusionProofResponse, error) // AddCovenantSigs handles signatures from a covenant member AddCovenantSigs(context.Context, *MsgAddCovenantSigs) (*MsgAddCovenantSigsResponse, error) // BTCUndelegate handles a signature on unbonding tx from its delegator @@ -1080,6 +1230,9 @@ func (*UnimplementedMsgServer) EditFinalityProvider(ctx context.Context, req *Ms func (*UnimplementedMsgServer) CreateBTCDelegation(ctx context.Context, req *MsgCreateBTCDelegation) (*MsgCreateBTCDelegationResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method CreateBTCDelegation not implemented") } +func (*UnimplementedMsgServer) AddBTCDelegationInclusionProof(ctx context.Context, req *MsgAddBTCDelegationInclusionProof) (*MsgAddBTCDelegationInclusionProofResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method AddBTCDelegationInclusionProof not implemented") +} func (*UnimplementedMsgServer) AddCovenantSigs(ctx context.Context, req *MsgAddCovenantSigs) (*MsgAddCovenantSigsResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method AddCovenantSigs not implemented") } @@ -1151,6 +1304,24 @@ func _Msg_CreateBTCDelegation_Handler(srv interface{}, ctx context.Context, dec return interceptor(ctx, in, info, handler) } +func _Msg_AddBTCDelegationInclusionProof_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(MsgAddBTCDelegationInclusionProof) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(MsgServer).AddBTCDelegationInclusionProof(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/babylon.btcstaking.v1.Msg/AddBTCDelegationInclusionProof", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(MsgServer).AddBTCDelegationInclusionProof(ctx, req.(*MsgAddBTCDelegationInclusionProof)) + } + return interceptor(ctx, in, info, handler) +} + func _Msg_AddCovenantSigs_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { in := new(MsgAddCovenantSigs) if err := dec(in); err != nil { @@ -1239,6 +1410,10 @@ var _Msg_serviceDesc = grpc.ServiceDesc{ MethodName: "CreateBTCDelegation", Handler: _Msg_CreateBTCDelegation_Handler, }, + { + MethodName: "AddBTCDelegationInclusionProof", + Handler: _Msg_AddBTCDelegationInclusionProof_Handler, + }, { MethodName: "AddCovenantSigs", Handler: _Msg_AddCovenantSigs_Handler, @@ -1482,7 +1657,7 @@ func (m *MsgCreateBTCDelegation) MarshalToSizedBuffer(dAtA []byte) (int, error) i = encodeVarintTx(dAtA, i, uint64(size)) } i-- - dAtA[i] = 0x72 + dAtA[i] = 0x7a } if m.UnbondingSlashingTx != nil { { @@ -1494,24 +1669,24 @@ func (m *MsgCreateBTCDelegation) MarshalToSizedBuffer(dAtA []byte) (int, error) i = encodeVarintTx(dAtA, i, uint64(size)) } i-- - dAtA[i] = 0x6a + dAtA[i] = 0x72 } if m.UnbondingValue != 0 { i = encodeVarintTx(dAtA, i, uint64(m.UnbondingValue)) i-- - dAtA[i] = 0x60 + dAtA[i] = 0x68 } if len(m.UnbondingTx) > 0 { i -= len(m.UnbondingTx) copy(dAtA[i:], m.UnbondingTx) i = encodeVarintTx(dAtA, i, uint64(len(m.UnbondingTx))) i-- - dAtA[i] = 0x5a + dAtA[i] = 0x62 } if m.UnbondingTime != 0 { i = encodeVarintTx(dAtA, i, uint64(m.UnbondingTime)) i-- - dAtA[i] = 0x50 + dAtA[i] = 0x58 } if m.DelegatorSlashingSig != nil { { @@ -1523,7 +1698,7 @@ func (m *MsgCreateBTCDelegation) MarshalToSizedBuffer(dAtA []byte) (int, error) i = encodeVarintTx(dAtA, i, uint64(size)) } i-- - dAtA[i] = 0x4a + dAtA[i] = 0x52 } if m.SlashingTx != nil { { @@ -1535,11 +1710,11 @@ func (m *MsgCreateBTCDelegation) MarshalToSizedBuffer(dAtA []byte) (int, error) i = encodeVarintTx(dAtA, i, uint64(size)) } i-- - dAtA[i] = 0x42 + dAtA[i] = 0x4a } - if m.StakingTx != nil { + if m.StakingTxInclusionProof != nil { { - size, err := m.StakingTx.MarshalToSizedBuffer(dAtA[:i]) + size, err := m.StakingTxInclusionProof.MarshalToSizedBuffer(dAtA[:i]) if err != nil { return 0, err } @@ -1547,6 +1722,13 @@ func (m *MsgCreateBTCDelegation) MarshalToSizedBuffer(dAtA []byte) (int, error) i = encodeVarintTx(dAtA, i, uint64(size)) } i-- + dAtA[i] = 0x42 + } + if len(m.StakingTx) > 0 { + i -= len(m.StakingTx) + copy(dAtA[i:], m.StakingTx) + i = encodeVarintTx(dAtA, i, uint64(len(m.StakingTx))) + i-- dAtA[i] = 0x3a } if m.StakingValue != 0 { @@ -1630,6 +1812,78 @@ func (m *MsgCreateBTCDelegationResponse) MarshalToSizedBuffer(dAtA []byte) (int, return len(dAtA) - i, nil } +func (m *MsgAddBTCDelegationInclusionProof) 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 *MsgAddBTCDelegationInclusionProof) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgAddBTCDelegationInclusionProof) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.StakingTxInclusionProof != nil { + { + size, err := m.StakingTxInclusionProof.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintTx(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x1a + } + if len(m.StakingTxHash) > 0 { + i -= len(m.StakingTxHash) + copy(dAtA[i:], m.StakingTxHash) + i = encodeVarintTx(dAtA, i, uint64(len(m.StakingTxHash))) + i-- + dAtA[i] = 0x12 + } + if len(m.Signer) > 0 { + i -= len(m.Signer) + copy(dAtA[i:], m.Signer) + i = encodeVarintTx(dAtA, i, uint64(len(m.Signer))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *MsgAddBTCDelegationInclusionProofResponse) 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 *MsgAddBTCDelegationInclusionProofResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgAddBTCDelegationInclusionProofResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + return len(dAtA) - i, nil +} + func (m *MsgAddCovenantSigs) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) @@ -1752,16 +2006,23 @@ func (m *MsgBTCUndelegate) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l - if m.UnbondingTxSig != nil { + if m.StakeSpendingTxInclusionProof != nil { { - size := m.UnbondingTxSig.Size() - i -= size - if _, err := m.UnbondingTxSig.MarshalTo(dAtA[i:]); err != nil { + size, err := m.StakeSpendingTxInclusionProof.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { return 0, err } + i -= size i = encodeVarintTx(dAtA, i, uint64(size)) } i-- + dAtA[i] = 0x22 + } + if len(m.StakeSpendingTx) > 0 { + i -= len(m.StakeSpendingTx) + copy(dAtA[i:], m.StakeSpendingTx) + i = encodeVarintTx(dAtA, i, uint64(len(m.StakeSpendingTx))) + i-- dAtA[i] = 0x1a } if len(m.StakingTxHash) > 0 { @@ -2051,8 +2312,12 @@ func (m *MsgCreateBTCDelegation) Size() (n int) { if m.StakingValue != 0 { n += 1 + sovTx(uint64(m.StakingValue)) } - if m.StakingTx != nil { - l = m.StakingTx.Size() + l = len(m.StakingTx) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + if m.StakingTxInclusionProof != nil { + l = m.StakingTxInclusionProof.Size() n += 1 + l + sovTx(uint64(l)) } if m.SlashingTx != nil { @@ -2093,6 +2358,36 @@ func (m *MsgCreateBTCDelegationResponse) Size() (n int) { return n } +func (m *MsgAddBTCDelegationInclusionProof) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Signer) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + l = len(m.StakingTxHash) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + if m.StakingTxInclusionProof != nil { + l = m.StakingTxInclusionProof.Size() + n += 1 + l + sovTx(uint64(l)) + } + return n +} + +func (m *MsgAddBTCDelegationInclusionProofResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + return n +} + func (m *MsgAddCovenantSigs) Size() (n int) { if m == nil { return 0 @@ -2153,8 +2448,12 @@ func (m *MsgBTCUndelegate) Size() (n int) { if l > 0 { n += 1 + l + sovTx(uint64(l)) } - if m.UnbondingTxSig != nil { - l = m.UnbondingTxSig.Size() + l = len(m.StakeSpendingTx) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + if m.StakeSpendingTxInclusionProof != nil { + l = m.StakeSpendingTxInclusionProof.Size() n += 1 + l + sovTx(uint64(l)) } return n @@ -2983,6 +3282,40 @@ func (m *MsgCreateBTCDelegation) Unmarshal(dAtA []byte) error { if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field StakingTx", 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.StakingTx = append(m.StakingTx[:0], dAtA[iNdEx:postIndex]...) + if m.StakingTx == nil { + m.StakingTx = []byte{} + } + iNdEx = postIndex + case 8: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field StakingTxInclusionProof", wireType) + } var msglen int for shift := uint(0); ; shift += 7 { if shift >= 64 { @@ -3008,14 +3341,14 @@ func (m *MsgCreateBTCDelegation) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - if m.StakingTx == nil { - m.StakingTx = &types1.TransactionInfo{} + if m.StakingTxInclusionProof == nil { + m.StakingTxInclusionProof = &InclusionProof{} } - if err := m.StakingTx.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + if err := m.StakingTxInclusionProof.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } iNdEx = postIndex - case 8: + case 9: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field SlashingTx", wireType) } @@ -3050,7 +3383,7 @@ func (m *MsgCreateBTCDelegation) Unmarshal(dAtA []byte) error { return err } iNdEx = postIndex - case 9: + case 10: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field DelegatorSlashingSig", wireType) } @@ -3085,7 +3418,7 @@ func (m *MsgCreateBTCDelegation) Unmarshal(dAtA []byte) error { return err } iNdEx = postIndex - case 10: + case 11: if wireType != 0 { return fmt.Errorf("proto: wrong wireType = %d for field UnbondingTime", wireType) } @@ -3104,7 +3437,7 @@ func (m *MsgCreateBTCDelegation) Unmarshal(dAtA []byte) error { break } } - case 11: + case 12: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field UnbondingTx", wireType) } @@ -3138,7 +3471,7 @@ func (m *MsgCreateBTCDelegation) Unmarshal(dAtA []byte) error { m.UnbondingTx = []byte{} } iNdEx = postIndex - case 12: + case 13: if wireType != 0 { return fmt.Errorf("proto: wrong wireType = %d for field UnbondingValue", wireType) } @@ -3157,7 +3490,7 @@ func (m *MsgCreateBTCDelegation) Unmarshal(dAtA []byte) error { break } } - case 13: + case 14: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field UnbondingSlashingTx", wireType) } @@ -3192,7 +3525,7 @@ func (m *MsgCreateBTCDelegation) Unmarshal(dAtA []byte) error { return err } iNdEx = postIndex - case 14: + case 15: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field DelegatorUnbondingSlashingSig", wireType) } @@ -3298,6 +3631,206 @@ func (m *MsgCreateBTCDelegationResponse) Unmarshal(dAtA []byte) error { } return nil } +func (m *MsgAddBTCDelegationInclusionProof) 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: MsgAddBTCDelegationInclusionProof: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgAddBTCDelegationInclusionProof: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + 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 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.Signer = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field StakingTxHash", 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.StakingTxHash = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field StakingTxInclusionProof", 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.StakingTxInclusionProof == nil { + m.StakingTxInclusionProof = &InclusionProof{} + } + if err := m.StakingTxInclusionProof.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 *MsgAddBTCDelegationInclusionProofResponse) 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: MsgAddBTCDelegationInclusionProofResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgAddBTCDelegationInclusionProofResponse: 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 (m *MsgAddCovenantSigs) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 @@ -3691,7 +4224,7 @@ func (m *MsgBTCUndelegate) Unmarshal(dAtA []byte) error { iNdEx = postIndex case 3: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field UnbondingTxSig", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field StakeSpendingTx", wireType) } var byteLen int for shift := uint(0); ; shift += 7 { @@ -3718,9 +4251,44 @@ func (m *MsgBTCUndelegate) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - var v github_com_babylonlabs_io_babylon_types.BIP340Signature - m.UnbondingTxSig = &v - if err := m.UnbondingTxSig.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + m.StakeSpendingTx = append(m.StakeSpendingTx[:0], dAtA[iNdEx:postIndex]...) + if m.StakeSpendingTx == nil { + m.StakeSpendingTx = []byte{} + } + iNdEx = postIndex + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field StakeSpendingTxInclusionProof", 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.StakeSpendingTxInclusionProof == nil { + m.StakeSpendingTxInclusionProof = &InclusionProof{} + } + if err := m.StakeSpendingTxInclusionProof.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } iNdEx = postIndex diff --git a/x/btcstaking/types/validate_parsed_message.go b/x/btcstaking/types/validate_parsed_message.go index a8d8d3abb..33d8897ab 100644 --- a/x/btcstaking/types/validate_parsed_message.go +++ b/x/btcstaking/types/validate_parsed_message.go @@ -1,33 +1,36 @@ package types import ( + "bytes" "fmt" + "github.com/btcsuite/btcd/chaincfg" + "github.com/babylonlabs-io/babylon/btcstaking" bbn "github.com/babylonlabs-io/babylon/types" btcckpttypes "github.com/babylonlabs-io/babylon/x/btccheckpoint/types" - "github.com/btcsuite/btcd/chaincfg" ) type ParamsValidationResult struct { StakingOutputIdx uint32 UnbondingOutputIdx uint32 + MinUnbondingTime uint32 } // ValidateParsedMessageAgainstTheParams validates parsed message against parameters func ValidateParsedMessageAgainstTheParams( pm *ParsedCreateDelegationMessage, parameters *Params, - btcheckpointParamseters *btcckpttypes.Params, + btcheckpointParameters *btcckpttypes.Params, net *chaincfg.Params, ) (*ParamsValidationResult, error) { // 1. Validate unbonding time first as it will be used in other checks - minUnbondingTime := MinimumUnbondingTime(parameters, btcheckpointParamseters) + minUnbondingTime := MinimumUnbondingTime(parameters, btcheckpointParameters) // Check unbonding time (staking time from unbonding tx) is larger than min unbonding time // which is larger value from: // - MinUnbondingTime // - CheckpointFinalizationTimeout - if uint64(pm.UnbondingTime) <= minUnbondingTime { + if uint32(pm.UnbondingTime) <= minUnbondingTime { return nil, ErrInvalidUnbondingTx.Wrapf("unbonding time %d must be larger than %d", pm.UnbondingTime, minUnbondingTime) } @@ -37,7 +40,7 @@ func ValidateParsedMessageAgainstTheParams( // 2. Validate all data related to staking tx: // - it has valid staking output // - that staking time and value are correct - // - slashing tx is relevent to staking tx + // - slashing tx is relevant to staking tx // - slashing tx signature is valid stakingInfo, err := btcstaking.BuildStakingInfo( pm.StakerPK.PublicKey, @@ -49,7 +52,7 @@ func ValidateParsedMessageAgainstTheParams( net, ) if err != nil { - return nil, ErrInvalidStakingTx.Wrapf("err: %v", err) + return nil, ErrInvalidStakingTx.Wrapf("failed to build staking info: %v", err) } stakingOutputIdx, err := bbn.GetOutputIdxInBTCTx(pm.StakingTx.Transaction, stakingInfo.StakingOutput) @@ -78,7 +81,7 @@ func ValidateParsedMessageAgainstTheParams( ) } - if err := btcstaking.CheckTransactions( + if err := btcstaking.CheckSlashingTxMatchFundingTx( pm.StakingSlashingTx.Transaction, pm.StakingTx.Transaction, stakingOutputIdx, @@ -108,9 +111,16 @@ func ValidateParsedMessageAgainstTheParams( } // 3. Validate all data related to unbonding tx: + // - it is valid BTC pre-signed transaction // - it has valid unbonding output - // - slashing tx is relevent to unbonding tx + // - slashing tx is relevant to unbonding tx // - slashing tx signature is valid + if err := btcstaking.CheckPreSignedUnbondingTxSanity( + pm.UnbondingTx.Transaction, + ); err != nil { + return nil, ErrInvalidUnbondingTx.Wrapf("unbonding tx is not a valid pre-signed transaction: %v", err) + } + unbondingInfo, err := btcstaking.BuildUnbondingInfo( pm.StakerPK.PublicKey, pm.FinalityProviderKeys.PublicKeys, @@ -121,18 +131,25 @@ func ValidateParsedMessageAgainstTheParams( net, ) if err != nil { - return nil, ErrInvalidUnbondingTx.Wrapf("err: %v", err) + return nil, ErrInvalidUnbondingTx.Wrapf("failed to build the unbonding info: %v", err) } - unbondingOutputIdx, err := bbn.GetOutputIdxInBTCTx(pm.UnbondingTx.Transaction, unbondingInfo.UnbondingOutput) - if err != nil { - return nil, ErrInvalidUnbondingTx.Wrapf("unbonding tx does not contain expected unbonding output") + unbondingTx := pm.UnbondingTx.Transaction + if !bytes.Equal(unbondingTx.TxOut[0].PkScript, unbondingInfo.UnbondingOutput.PkScript) { + return nil, ErrInvalidUnbondingTx. + Wrapf("the unbonding output script is not expected, expected: %x, got: %s", + unbondingInfo.UnbondingOutput.PkScript, unbondingTx.TxOut[0].PkScript) + } + if unbondingTx.TxOut[0].Value != unbondingInfo.UnbondingOutput.Value { + return nil, ErrInvalidUnbondingTx. + Wrapf("the unbonding output value is not expected, expected: %d, got: %d", + unbondingInfo.UnbondingOutput.Value, unbondingTx.TxOut[0].Value) } - err = btcstaking.CheckTransactions( + err = btcstaking.CheckSlashingTxMatchFundingTx( pm.UnbondingSlashingTx.Transaction, pm.UnbondingTx.Transaction, - unbondingOutputIdx, + 0, // unbonding output always has only 1 output parameters.MinSlashingTxFeeSat, parameters.SlashingRate, parameters.SlashingPkScript, @@ -151,7 +168,7 @@ func ValidateParsedMessageAgainstTheParams( if err := btcstaking.VerifyTransactionSigWithOutput( pm.UnbondingSlashingTx.Transaction, - pm.UnbondingTx.Transaction.TxOut[unbondingOutputIdx], + pm.UnbondingTx.Transaction.TxOut[0], // unbonding output always has only 1 output unbondingSlashingSpendInfo.RevealedLeaf.Script, pm.StakerPK.PublicKey, pm.StakerUnbondingSlashingSig.BIP340Signature.MustMarshal(), @@ -169,10 +186,10 @@ func ValidateParsedMessageAgainstTheParams( } // 5. Check unbonding tx fees against staking tx. // - fee is larger than 0 - // - ubonding output value is is at leat `MinUnbondingValue` percent of staking output value + // - ubonding output value is at least `MinUnbondingValue` percent of staking output value if pm.UnbondingTx.Transaction.TxOut[0].Value >= pm.StakingTx.Transaction.TxOut[stakingOutputIdx].Value { - // Note: we do not enfore any minimum fee for unbonding tx, we only require that it is larger than 0 - // Given that unbonding tx must not be replacable and we do not allow sending it second time, it places + // Note: we do not enforce any minimum fee for unbonding tx, we only require that it is larger than 0 + // Given that unbonding tx must not be replaceable, and we do not allow sending it second time, it places // burden on staker to choose right fee. // Unbonding tx should not be replaceable at babylon level (and by extension on btc level), as this would // allow staker to spam the network with unbonding txs, which would force covenant and finality provider to send signatures. @@ -188,6 +205,7 @@ func ValidateParsedMessageAgainstTheParams( return &ParamsValidationResult{ StakingOutputIdx: stakingOutputIdx, - UnbondingOutputIdx: unbondingOutputIdx, + UnbondingOutputIdx: 0, // unbonding output always has only 1 output + MinUnbondingTime: minUnbondingTime, }, nil } diff --git a/x/btcstaking/types/validate_parsed_message_test.go b/x/btcstaking/types/validate_parsed_message_test.go index 1c133abe4..3b08cf5ab 100644 --- a/x/btcstaking/types/validate_parsed_message_test.go +++ b/x/btcstaking/types/validate_parsed_message_test.go @@ -6,11 +6,6 @@ import ( "time" sdkmath "cosmossdk.io/math" - "github.com/babylonlabs-io/babylon/btcstaking" - "github.com/babylonlabs-io/babylon/testutil/datagen" - bbn "github.com/babylonlabs-io/babylon/types" - btcckpttypes "github.com/babylonlabs-io/babylon/x/btccheckpoint/types" - "github.com/babylonlabs-io/babylon/x/btcstaking/types" "github.com/btcsuite/btcd/btcec/v2" "github.com/btcsuite/btcd/btcutil" "github.com/btcsuite/btcd/chaincfg" @@ -19,6 +14,12 @@ import ( "github.com/btcsuite/btcd/wire" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/stretchr/testify/require" + + "github.com/babylonlabs-io/babylon/btcstaking" + "github.com/babylonlabs-io/babylon/testutil/datagen" + bbn "github.com/babylonlabs-io/babylon/types" + btcckpttypes "github.com/babylonlabs-io/babylon/x/btccheckpoint/types" + "github.com/babylonlabs-io/babylon/x/btcstaking/types" ) // testStakingParams generates valid staking parameters with randomized @@ -37,19 +38,18 @@ func testStakingParams( require.NoError(t, err) return &types.Params{ - CovenantPks: bbn.NewBIP340PKsFromBTCPKs(covenantPKs), - CovenantQuorum: 3, - MinStakingValueSat: 100000, - MaxStakingValueSat: int64(4 * 10e8), - MinStakingTimeBlocks: 10, - MaxStakingTimeBlocks: 10000, - SlashingPkScript: slashingPkScript, - MinSlashingTxFeeSat: 1000, - MinCommissionRate: sdkmath.LegacyMustNewDecFromStr("0.01"), - SlashingRate: sdkmath.LegacyNewDecWithPrec(int64(datagen.RandomInt(r, 41)+10), 2), - MaxActiveFinalityProviders: 100, - MinUnbondingTimeBlocks: 200, - UnbondingFeeSat: 1000, + CovenantPks: bbn.NewBIP340PKsFromBTCPKs(covenantPKs), + CovenantQuorum: 3, + MinStakingValueSat: 100000, + MaxStakingValueSat: int64(4 * 10e8), + MinStakingTimeBlocks: 1000, + MaxStakingTimeBlocks: 10000, + SlashingPkScript: slashingPkScript, + MinSlashingTxFeeSat: 1000, + MinCommissionRate: sdkmath.LegacyMustNewDecFromStr("0.01"), + SlashingRate: sdkmath.LegacyNewDecWithPrec(int64(datagen.RandomInt(r, 41)+10), 2), + MinUnbondingTimeBlocks: 200, + UnbondingFeeSat: 1000, } } @@ -188,9 +188,8 @@ func createMsgDelegationForParams( serializedStakingTx, err := bbn.SerializeBTCTx(testStakingInfo.StakingTx) require.NoError(t, err) - txInfo := btcckpttypes.NewTransactionInfo( + txInclusionProof := types.NewInclusionProof( &btcckpttypes.TransactionKey{Index: 1, Hash: btcHeader.Hash()}, - serializedStakingTx, btcHeaderWithProof.SpvProof.MerkleNodes, ) @@ -218,7 +217,8 @@ func createMsgDelegationForParams( Pop: pop, StakingTime: uint32(stakingTimeBlocks), StakingValue: stakingValue, - StakingTx: txInfo, + StakingTx: serializedStakingTx, + StakingTxInclusionProof: txInclusionProof, SlashingTx: testStakingInfo.SlashingTx, DelegatorSlashingSig: delegatorSig, UnbondingTx: unbondingInfo.serializedUnbondingTx, @@ -233,9 +233,10 @@ func createMsgDelegationForParams( func TestValidateParsedMessageAgainstTheParams(t *testing.T) { tests := []struct { - name string - fn func(r *rand.Rand, t *testing.T) (*types.MsgCreateBTCDelegation, *types.Params, *btcckpttypes.Params) - err error + name string + fn func(r *rand.Rand, t *testing.T) (*types.MsgCreateBTCDelegation, *types.Params, *btcckpttypes.Params) + errParsing error + errValidation error }{ { name: "valid create delegation message", @@ -246,7 +247,22 @@ func TestValidateParsedMessageAgainstTheParams(t *testing.T) { return msg, params, checkpointParams }, - err: nil, + errParsing: nil, + errValidation: nil, + }, + { + name: "empty finality provider list", + fn: func(r *rand.Rand, t *testing.T) (*types.MsgCreateBTCDelegation, *types.Params, *btcckpttypes.Params) { + params := testStakingParams(r, t) + checkpointParams := testCheckpointParams() + msg, _ := createMsgDelegationForParams(r, t, params, checkpointParams) + + msg.FpBtcPkList = []bbn.BIP340PubKey{} + + return msg, params, checkpointParams + }, + errParsing: types.ErrEmptyFpList, + errValidation: nil, }, { name: "too low unbonding time", @@ -259,7 +275,8 @@ func TestValidateParsedMessageAgainstTheParams(t *testing.T) { return msg, params, checkpointParams }, - err: types.ErrInvalidUnbondingTx, + errParsing: nil, + errValidation: types.ErrInvalidUnbondingTx, }, { name: "Msg.BtcPk do not match pk in staking transaction", @@ -277,10 +294,11 @@ func TestValidateParsedMessageAgainstTheParams(t *testing.T) { return msg, params, checkpointParams }, - err: types.ErrInvalidStakingTx, + errParsing: nil, + errValidation: types.ErrInvalidStakingTx, }, { - name: "Msg.StakingTime do not match staking time commited in staking transaction", + name: "Msg.StakingTime do not match staking time committed in staking transaction", fn: func(r *rand.Rand, t *testing.T) (*types.MsgCreateBTCDelegation, *types.Params, *btcckpttypes.Params) { params := testStakingParams(r, t) checkpointParams := testCheckpointParams() @@ -290,10 +308,11 @@ func TestValidateParsedMessageAgainstTheParams(t *testing.T) { return msg, params, checkpointParams }, - err: types.ErrInvalidStakingTx, + errParsing: nil, + errValidation: types.ErrInvalidStakingTx, }, { - name: "Msg.StakingValue do not match staking time commited in staking transaction", + name: "Msg.StakingValue do not match staking value committed in staking transaction", fn: func(r *rand.Rand, t *testing.T) (*types.MsgCreateBTCDelegation, *types.Params, *btcckpttypes.Params) { params := testStakingParams(r, t) checkpointParams := testCheckpointParams() @@ -303,7 +322,8 @@ func TestValidateParsedMessageAgainstTheParams(t *testing.T) { return msg, params, checkpointParams }, - err: types.ErrInvalidStakingTx, + errParsing: nil, + errValidation: types.ErrInvalidStakingTx.Wrap("staking tx does not contain expected staking output"), }, { name: "Msg.StakingValue is lower than params.MinStakingValueSat", @@ -316,7 +336,8 @@ func TestValidateParsedMessageAgainstTheParams(t *testing.T) { return msg, params, checkpointParams }, - err: types.ErrInvalidStakingTx, + errParsing: nil, + errValidation: types.ErrInvalidStakingTx, }, { name: "Msg.StakingValue is higher than params.MinStakingValueSat", @@ -329,7 +350,8 @@ func TestValidateParsedMessageAgainstTheParams(t *testing.T) { return msg, params, checkpointParams }, - err: types.ErrInvalidStakingTx, + errParsing: nil, + errValidation: types.ErrInvalidStakingTx, }, { name: "Msg.StakingTime is lower than params.MinStakingTimeBlocks", @@ -340,7 +362,7 @@ func TestValidateParsedMessageAgainstTheParams(t *testing.T) { // modify staking output so that staking output is valid but it will have // invalid time - currentStakingTx, err := bbn.NewBTCTxFromBytes(msg.StakingTx.Transaction) + currentStakingTx, err := bbn.NewBTCTxFromBytes(msg.StakingTx) require.NoError(t, err) invalidStakingTime := uint16(params.MinStakingTimeBlocks - 1) @@ -365,11 +387,12 @@ func TestValidateParsedMessageAgainstTheParams(t *testing.T) { require.NoError(t, err) msg.StakingTime = uint32(invalidStakingTime) - msg.StakingTx.Transaction = serializedNewStakingTx + msg.StakingTx = serializedNewStakingTx return msg, params, checkpointParams }, - err: types.ErrInvalidStakingTx, + errParsing: nil, + errValidation: types.ErrInvalidStakingTx, }, { name: "Msg.StakingTime is higher than params.MinStakingTimeBlocks", @@ -380,7 +403,7 @@ func TestValidateParsedMessageAgainstTheParams(t *testing.T) { // modify staking output so that staking output is valid but it will have // invalid time - currentStakingTx, err := bbn.NewBTCTxFromBytes(msg.StakingTx.Transaction) + currentStakingTx, err := bbn.NewBTCTxFromBytes(msg.StakingTx) require.NoError(t, err) invalidStakingTime := uint16(params.MaxStakingTimeBlocks + 1) @@ -405,11 +428,12 @@ func TestValidateParsedMessageAgainstTheParams(t *testing.T) { require.NoError(t, err) msg.StakingTime = uint32(invalidStakingTime) - msg.StakingTx.Transaction = serializedNewStakingTx + msg.StakingTx = serializedNewStakingTx return msg, params, checkpointParams }, - err: types.ErrInvalidStakingTx, + errParsing: nil, + errValidation: types.ErrInvalidStakingTx, }, { name: "Msg.StakingValue is lower than params.MinStakingValueSat", @@ -420,7 +444,7 @@ func TestValidateParsedMessageAgainstTheParams(t *testing.T) { // modify staking output so that staking output is valid but it will have // invalid time - currentStakingTx, err := bbn.NewBTCTxFromBytes(msg.StakingTx.Transaction) + currentStakingTx, err := bbn.NewBTCTxFromBytes(msg.StakingTx) require.NoError(t, err) invalidStakingValue := params.MinStakingValueSat - 1 @@ -431,11 +455,12 @@ func TestValidateParsedMessageAgainstTheParams(t *testing.T) { require.NoError(t, err) msg.StakingValue = invalidStakingValue - msg.StakingTx.Transaction = serializedNewStakingTx + msg.StakingTx = serializedNewStakingTx return msg, params, checkpointParams }, - err: types.ErrInvalidStakingTx, + errParsing: nil, + errValidation: types.ErrInvalidStakingTx, }, { name: "Msg.StakingValue is higher than params.MaxStakingValueSat", @@ -446,7 +471,7 @@ func TestValidateParsedMessageAgainstTheParams(t *testing.T) { // modify staking output so that staking output is valid but it will have // invalid time - currentStakingTx, err := bbn.NewBTCTxFromBytes(msg.StakingTx.Transaction) + currentStakingTx, err := bbn.NewBTCTxFromBytes(msg.StakingTx) require.NoError(t, err) invalidStakingValue := params.MaxStakingValueSat + 1 @@ -457,11 +482,12 @@ func TestValidateParsedMessageAgainstTheParams(t *testing.T) { require.NoError(t, err) msg.StakingValue = invalidStakingValue - msg.StakingTx.Transaction = serializedNewStakingTx + msg.StakingTx = serializedNewStakingTx return msg, params, checkpointParams }, - err: types.ErrInvalidStakingTx, + errParsing: nil, + errValidation: types.ErrInvalidStakingTx, }, { name: "Msg.SlashingTx have invalid pk script", @@ -487,7 +513,8 @@ func TestValidateParsedMessageAgainstTheParams(t *testing.T) { return msg, params, checkpointParams }, - err: types.ErrInvalidStakingTx, + errParsing: nil, + errValidation: types.ErrInvalidStakingTx, }, { name: "Msg.SlashingTx does not point to staking tx hash", @@ -514,7 +541,8 @@ func TestValidateParsedMessageAgainstTheParams(t *testing.T) { return msg, params, checkpointParams }, - err: types.ErrInvalidStakingTx, + errParsing: nil, + errValidation: types.ErrInvalidStakingTx, }, { name: "Msg.SlashingTx does not point to staking tx output index", @@ -534,7 +562,8 @@ func TestValidateParsedMessageAgainstTheParams(t *testing.T) { return msg, params, checkpointParams }, - err: types.ErrInvalidStakingTx, + errParsing: nil, + errValidation: types.ErrInvalidStakingTx, }, { name: "Msg.DelegatorSlashingSig is invalid signature", @@ -557,7 +586,8 @@ func TestValidateParsedMessageAgainstTheParams(t *testing.T) { return msg, params, checkpointParams }, - err: types.ErrInvalidSlashingTx, + errParsing: nil, + errValidation: types.ErrInvalidSlashingTx, }, { name: "Msg.UnbondingSlashingTx does not point to unbonding tx hash", @@ -584,7 +614,8 @@ func TestValidateParsedMessageAgainstTheParams(t *testing.T) { return msg, params, checkpointParams }, - err: types.ErrInvalidUnbondingTx, + errParsing: nil, + errValidation: types.ErrInvalidUnbondingTx, }, { name: "Msg.UnbondingSlashingTx does not point to unbonding tx output index", @@ -604,7 +635,8 @@ func TestValidateParsedMessageAgainstTheParams(t *testing.T) { return msg, params, checkpointParams }, - err: types.ErrInvalidUnbondingTx, + errParsing: nil, + errValidation: types.ErrInvalidUnbondingTx, }, { name: "Msg.UnbondingSlashingTx have invalid pk script", @@ -630,7 +662,8 @@ func TestValidateParsedMessageAgainstTheParams(t *testing.T) { return msg, params, checkpointParams }, - err: types.ErrInvalidUnbondingTx, + errParsing: nil, + errValidation: types.ErrInvalidUnbondingTx, }, { name: "Msg.DelegatorUnbondingSlashingSig is invalid signature", @@ -653,7 +686,8 @@ func TestValidateParsedMessageAgainstTheParams(t *testing.T) { return msg, params, checkpointParams }, - err: types.ErrInvalidSlashingTx, + errParsing: nil, + errValidation: types.ErrInvalidSlashingTx, }, { name: "Msg.UnbondingTx does not point to staking tx hash", @@ -691,7 +725,8 @@ func TestValidateParsedMessageAgainstTheParams(t *testing.T) { return msg, params, checkpointParams }, - err: types.ErrInvalidUnbondingTx, + errParsing: nil, + errValidation: types.ErrInvalidUnbondingTx, }, { name: "Msg.UnbondingTx does not point to staking tx output index", @@ -722,7 +757,8 @@ func TestValidateParsedMessageAgainstTheParams(t *testing.T) { return msg, params, checkpointParams }, - err: types.ErrInvalidUnbondingTx, + errParsing: nil, + errValidation: types.ErrInvalidUnbondingTx, }, { name: "Msg.UnbondingTx does not have required fee", @@ -756,7 +792,65 @@ func TestValidateParsedMessageAgainstTheParams(t *testing.T) { return msg, params, checkpointParams }, - err: types.ErrInvalidUnbondingTx, + errParsing: nil, + errValidation: types.ErrInvalidUnbondingTx, + }, + { + name: "Msg.UnbondingTx has more than one output", + fn: func(r *rand.Rand, t *testing.T) (*types.MsgCreateBTCDelegation, *types.Params, *btcckpttypes.Params) { + params := testStakingParams(r, t) + checkpointParams := testCheckpointParams() + msg, _ := createMsgDelegationForParams(r, t, params, checkpointParams) + + currentUnbondingTx, err := bbn.NewBTCTxFromBytes(msg.UnbondingTx) + require.NoError(t, err) + + // add randomnes output + randAddrScript, err := datagen.GenRandomPubKeyHashScript(r, &chaincfg.MainNetParams) + require.NoError(t, err) + currentUnbondingTx.AddTxOut(wire.NewTxOut(10000, randAddrScript)) + + msg.UnbondingTx, err = bbn.SerializeBTCTx(currentUnbondingTx) + require.NoError(t, err) + + return msg, params, checkpointParams + }, + errParsing: nil, + errValidation: types.ErrInvalidUnbondingTx.Wrap("unbonding tx is not a valid pre-signed transaction: tx must have exactly 1 outputs"), + }, + { + name: "Msg.UnbondingTx unbonding value in the msg does not match the output value in the unbonding tx", + fn: func(r *rand.Rand, t *testing.T) (*types.MsgCreateBTCDelegation, *types.Params, *btcckpttypes.Params) { + params := testStakingParams(r, t) + checkpointParams := testCheckpointParams() + msg, delSk := createMsgDelegationForParams(r, t, params, checkpointParams) + + currentUnbondingTx, err := bbn.NewBTCTxFromBytes(msg.UnbondingTx) + require.NoError(t, err) + + // generate unbonding info with invalid staking idx + newUnbondingInfdo := generateUnbondingInfo( + r, + t, + delSk, + msg.FpBtcPkList[0].MustToBTCPK(), + currentUnbondingTx.TxIn[0].PreviousOutPoint.Hash, + currentUnbondingTx.TxIn[0].PreviousOutPoint.Index, + uint16(msg.UnbondingTime), + msg.UnbondingValue, + params, + ) + + // to cause the unbonding value mismatch with the unbonding tx output value + msg.UnbondingValue = msg.UnbondingValue + 1 + msg.UnbondingTx = newUnbondingInfdo.serializedUnbondingTx + msg.UnbondingSlashingTx = newUnbondingInfdo.unbondingSlashingTx + msg.DelegatorUnbondingSlashingSig = newUnbondingInfdo.unbondingSlashinSig + + return msg, params, checkpointParams + }, + errParsing: nil, + errValidation: types.ErrInvalidUnbondingTx.Wrap("the unbonding output value is not expected"), }, } for _, tt := range tests { @@ -766,8 +860,14 @@ func TestValidateParsedMessageAgainstTheParams(t *testing.T) { msg, params, checkpointParams := tt.fn(r, t) parsed, err := types.ParseCreateDelegationMessage(msg) - require.NoError(t, err) + if tt.errParsing != nil { + require.Error(t, err) + require.ErrorAs(t, err, &tt.errParsing) + return + } + + require.NoError(t, err) got, err := types.ValidateParsedMessageAgainstTheParams( parsed, params, @@ -775,12 +875,15 @@ func TestValidateParsedMessageAgainstTheParams(t *testing.T) { &chaincfg.MainNetParams, ) - if tt.err != nil { + if tt.errValidation != nil { require.Error(t, err) - require.ErrorAs(t, err, &tt.err) + require.ErrorAs(t, err, &tt.errValidation) } else { require.NoError(t, err) require.NotNil(t, got) + + minUnbondingTime := types.MinimumUnbondingTime(params, checkpointParams) + require.Equal(t, minUnbondingTime, got.MinUnbondingTime) } }) diff --git a/x/btcstkconsumer/types/query.pb.go b/x/btcstkconsumer/types/query.pb.go index 24687ad6a..9acd0cb4f 100644 --- a/x/btcstkconsumer/types/query.pb.go +++ b/x/btcstkconsumer/types/query.pb.go @@ -542,7 +542,7 @@ type FinalityProviderResponse struct { // slashed_btc_height indicates the BTC height when // the finality provider is slashed. // if it's 0 then the finality provider is not slashed - SlashedBtcHeight uint64 `protobuf:"varint,7,opt,name=slashed_btc_height,json=slashedBtcHeight,proto3" json:"slashed_btc_height,omitempty"` + SlashedBtcHeight uint32 `protobuf:"varint,7,opt,name=slashed_btc_height,json=slashedBtcHeight,proto3" json:"slashed_btc_height,omitempty"` // height is the queried Babylon height Height uint64 `protobuf:"varint,8,opt,name=height,proto3" json:"height,omitempty"` // voting_power is the voting power of this finality provider at the given height @@ -612,7 +612,7 @@ func (m *FinalityProviderResponse) GetSlashedBabylonHeight() uint64 { return 0 } -func (m *FinalityProviderResponse) GetSlashedBtcHeight() uint64 { +func (m *FinalityProviderResponse) GetSlashedBtcHeight() uint32 { if m != nil { return m.SlashedBtcHeight } @@ -752,78 +752,78 @@ func init() { } var fileDescriptor_4e6c48e60b6a8bd8 = []byte{ - // 1125 bytes of a gzipped FileDescriptorProto + // 1128 bytes of a gzipped FileDescriptorProto 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x57, 0x4b, 0x6f, 0x1b, 0x45, - 0x1c, 0xcf, 0xe6, 0x61, 0xf0, 0xb8, 0x48, 0xf1, 0x10, 0x55, 0xae, 0x29, 0x4e, 0xbc, 0x7d, 0x10, - 0x4a, 0xbd, 0x8b, 0x93, 0x48, 0xa4, 0x6a, 0xcb, 0xc3, 0x71, 0xdb, 0x04, 0x52, 0xd5, 0x2c, 0x9c, - 0xca, 0x61, 0xd9, 0xc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0xdb, 0x54, 0xd0, 0xc3, 0x0e, 0x22, + 0x54, 0xfc, 0x14, 0xbc, 0x12, 0xd9, 0x25, 0x2e, 0x76, 0x08, 0x82, 0x55, 0x90, 0x0a, 0x82, 0x73, + 0xc2, 0x8a, 0x50, 0xcc, 0xac, 0xad, 0x4a, 0x63, 0xbb, 0x25, 0x05, 0xa1, 0x95, 0xf4, 0x93, 0x83, + 0xe5, 0x99, 0x1f, 0xff, 0xf9, 0xf9, 0xaa, 0xa0, 0xf0, 0x58, 0xf1, 0x73, 0xb0, 0xc2, 0x92, 0x6f, + 0x71, 0x6f, 0x05, 0x59, 0x36, 0xa1, 0x5e, 0x6f, 0xd7, 0x26, 0x94, 0x03, 0x80, 0x77, 0x00, 0x38, + 0xd6, 0x92, 0x57, 0xbb, 0x22, 0xf1, 0x66, 0xf9, 0xc2, 0x4b, 0xc1, 0xa1, 0xe1, 0xc2, 0x4b, 0x35, + 0xcd, 0x42, 0x3c, 0x56, 0x19, 0x88, 0x14, 0xbf, 0x15, 0xc0, 0xea, 0x84, 0x62, 0x9c, 0xd7, 0x2a, + 0x38, 0x13, 0x42, 0x57, 0x6d, 0xd3, 0x67, 0x37, 0x57, 0x4c, 0x2b, 0x99, 0x70, 0x6f, 0xc7, 0x24, + 0xf0, 0x6e, 0x04, 0xd0, 0x2c, 0x03, 0xf4, 0x7a, 0x22, 0xa0, 0x20, 0x7f, 0x04, 0x51, 0x05, 0xbc, + 0x16, 0x01, 0x44, 0x42, 0x44, 0x21, 0xf5, 0x64, 0x30, 0xe2, 0x97, 0xa0, 0x30, 0x2e, 0x07, 0x67, + 0xf4, 0x00, 0xc0, 0x30, 0x80, 0xa8, 0x1e, 0xb3, 0x22, 0x8f, 0xa5, 0xca, 0xac, 0xbd, 0x39, 0xa1, + 0x6b, 0x51, 0x99, 0x90, 0xa7, 0x64, 0x8d, 0x68, 0x0d, 0xe4, 0x89, 0xdf, 0x08, 0x9c, 0xc2, 0x1d, + 0xdb, 0xd1, 0x5a, 0x36, 0xed, 0xd5, 0x3c, 0xdc, 0xb5, 0x4d, 0xe6, 0x12, 0x50, 0x58, 0x06, 0x99, + 0x01, 0x0a, 0xac, 0x7d, 0x69, 0x05, 0x1c, 0x33, 0x88, 0xb5, 0x77, 0x76, 0xea, 0xf6, 0x3e, 0x15, + 0xb8, 0x12, 0x23, 0xa0, 0x70, 0x25, 0x74, 0x00, 0xeb, 0xdc, 0xe8, 0x5f, 0xf9, 0xc0, 0xca, 0x95, + 0x58, 0x9f, 0xa0, 0x44, 0x3c, 0x63, 0xbf, 0x99, 0xd9, 0x7a, 0xbc, 0xd6, 0xff, 0x77, 0x38, 0x74, + 0x70, 0x61, 0x24, 0x9d, 0x13, 0x0b, 0xbb, 0x0a, 0xce, 0xd6, 0x5d, 0x55, 0xa7, 0x86, 0xea, 0x36, + 0xd5, 0x06, 0xda, 0x63, 0x60, 0xd2, 0x0a, 0xa8, 0xbb, 0x15, 0x6a, 0xd4, 0x9a, 0xdb, 0x68, 0x4f, + 0xfc, 0x6a, 0x5c, 0xfb, 0xfa, 0x92, 0x7d, 0x06, 0xb2, 0x43, 0x92, 0xf1, 0x3b, 0x38, 0x95, 0x62, + 0x8b, 0x71, 0xc5, 0xc4, 0x9f, 0xe6, 0x41, 0x6e, 0x6c, 0xf9, 0xdb, 0x20, 0x63, 0x22, 0x62, 0x78, + 0xb6, 0x3b, 0x70, 0xf9, 0x2f, 0x86, 0x72, 0x86, 0xef, 0x66, 0xa8, 0x65, 0xf5, 0xd8, 0x55, 0x19, + 0x8c, 0x83, 0xf7, 0x00, 0x30, 0x70, 0xbb, 0x6d, 0x13, 0x12, 0x36, 0x25, 0x5d, 0x29, 0xbd, 0x38, + 0x58, 0x7e, 0x35, 0x48, 0x44, 0xcc, 0xa6, 0x64, 0x63, 0xb9, 0xad, 0xd1, 0x86, 0xb4, 0x8b, 0x2c, + 0xcd, 0xe8, 0x55, 0x91, 0xf1, 0xfc, 0x71, 0x09, 0xf0, 0x3a, 0x55, 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x63, 0x79, 0x17, 0xde, 0x9e, 0xc0, 0x72, 0x68, 0x4e, 0xa8, 0x7d, + 0xeb, 0xa3, 0xc8, 0x45, 0xdc, 0x87, 0x4f, 0x05, 0x90, 0x1d, 0x1a, 0xd3, 0xc9, 0xfd, 0x1b, 0xf7, + 0x91, 0x91, 0xdc, 0xbf, 0xb1, 0xdf, 0x04, 0xe2, 0x16, 0x63, 0x76, 0x0b, 0xde, 0x38, 0x0d, 0x33, + 0x12, 0xe9, 0xdf, 0x3e, 0xfc, 0x53, 0x00, 0x8b, 0xf1, 0x12, 0xf0, 0xed, 0xd3, 0x82, 0x0a, 0xd9, + 0x6c, 0x9e, 0x3e, 0x90, 0x93, 0x51, 0x18, 0x99, 0x5d, 0xf8, 0xc1, 0x69, 0xc8, 0x44, 0xb9, 0xc4, + 0x7b, 0x55, 0x51, 0x9e, 0x1c, 0x16, 0x84, 0x67, 0x87, 0x05, 0xe1, 0xaf, 0xc3, 0x82, 0xf0, 0xdd, + 0x51, 0x61, 0xe6, 0xd9, 0x51, 0x61, 0xe6, 0x8f, 0xa3, 0xc2, 0xcc, 0x83, 0xcd, 0xe4, 0x21, 0xb6, + 0x17, 0x07, 0xc0, 0xa6, 0x9a, 0x9e, 0x62, 0xff, 0x70, 0xac, 0xff, 0x17, 0x00, 0x00, 0xff, 0xff, + 0xc7, 0xfb, 0x59, 0xe4, 0x09, 0x0e, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -3044,7 +3044,7 @@ func (m *FinalityProviderResponse) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - m.SlashedBtcHeight |= uint64(b&0x7F) << shift + m.SlashedBtcHeight |= uint32(b&0x7F) << shift if b < 0x80 { break } diff --git a/x/checkpointing/keeper/grpc_query_bls.go b/x/checkpointing/keeper/grpc_query_bls.go index 35efb113f..e5cb78e48 100644 --- a/x/checkpointing/keeper/grpc_query_bls.go +++ b/x/checkpointing/keeper/grpc_query_bls.go @@ -2,6 +2,8 @@ package keeper import ( "context" + "encoding/hex" + "github.com/babylonlabs-io/babylon/x/checkpointing/types" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/jinzhu/copier" @@ -21,7 +23,7 @@ func (k Keeper) BlsPublicKeyList(c context.Context, req *types.QueryBlsPublicKey if req.Pagination == nil { return &types.QueryBlsPublicKeyListResponse{ - ValidatorWithBlsKeys: valBLSKeys, + ValidatorWithBlsKeys: convertToBlsPublicKeyListResponse(valBLSKeys), }, nil } @@ -46,6 +48,19 @@ func (k Keeper) BlsPublicKeyList(c context.Context, req *types.QueryBlsPublicKey } return &types.QueryBlsPublicKeyListResponse{ - ValidatorWithBlsKeys: copiedValBLSKeys, + ValidatorWithBlsKeys: convertToBlsPublicKeyListResponse(copiedValBLSKeys), }, nil } + +func convertToBlsPublicKeyListResponse(valBLSKeys []*types.ValidatorWithBlsKey) []*types.BlsPublicKeyListResponse { + blsPublicKeyListResponse := make([]*types.BlsPublicKeyListResponse, len(valBLSKeys)) + + for i, valBlsKey := range valBLSKeys { + blsPublicKeyListResponse[i] = &types.BlsPublicKeyListResponse{ + ValidatorAddress: valBlsKey.ValidatorAddress, + BlsPubKeyHex: hex.EncodeToString(valBlsKey.BlsPubKey), + VotingPower: valBlsKey.VotingPower, + } + } + return blsPublicKeyListResponse +} diff --git a/x/checkpointing/keeper/grpc_query_bls_test.go b/x/checkpointing/keeper/grpc_query_bls_test.go index d6f74661f..12e6b289e 100644 --- a/x/checkpointing/keeper/grpc_query_bls_test.go +++ b/x/checkpointing/keeper/grpc_query_bls_test.go @@ -1,6 +1,7 @@ package keeper_test import ( + "encoding/hex" "math/rand" "testing" @@ -34,7 +35,7 @@ func FuzzQueryBLSKeySet(f *testing.F) { types.RegisterQueryServer(queryHelper, ck) queryClient := types.NewQueryClient(queryHelper) msgServer := checkpointingkeeper.NewMsgServerImpl(ck) - genesisVal := ek.GetValidatorSet(helper.Ctx, 0)[0] + genesisVal := ek.GetValidatorSet(helper.Ctx, 1)[0] genesisBLSPubkey, err := ck.GetBlsPubKey(helper.Ctx, genesisVal.Addr) require.NoError(t, err) @@ -48,7 +49,7 @@ func FuzzQueryBLSKeySet(f *testing.F) { res, err := queryClient.BlsPublicKeyList(ctx, queryRequest) require.NoError(t, err) require.Len(t, res.ValidatorWithBlsKeys, 1) - require.Equal(t, res.ValidatorWithBlsKeys[0].BlsPubKey, genesisBLSPubkey.Bytes()) + require.Equal(t, res.ValidatorWithBlsKeys[0].BlsPubKeyHex, hex.EncodeToString(genesisBLSPubkey.Bytes())) require.Equal(t, res.ValidatorWithBlsKeys[0].VotingPower, uint64(1000)) require.Equal(t, res.ValidatorWithBlsKeys[0].ValidatorAddress, genesisVal.GetValAddressStr()) diff --git a/x/checkpointing/keeper/grpc_query_checkpoint.go b/x/checkpointing/keeper/grpc_query_checkpoint.go index fa56c1843..ea1fc62ad 100644 --- a/x/checkpointing/keeper/grpc_query_checkpoint.go +++ b/x/checkpointing/keeper/grpc_query_checkpoint.go @@ -109,9 +109,11 @@ func (k Keeper) RecentEpochStatusCount(ctx context.Context, req *types.QueryRece if err != nil { return nil, fmt.Errorf("failed to get the last checkpointed epoch") } - targetEpoch := tipEpoch - req.EpochCount + 1 - if targetEpoch < 0 { //nolint:staticcheck // uint64 doesn't go below zero + targetEpoch := tipEpoch + if req.EpochCount > tipEpoch { targetEpoch = 0 + } else { + targetEpoch -= req.EpochCount - 1 } // iterate epochs in the reverse order and count epoch numbers for each status epochStatusCount := make(map[string]uint64, 0) @@ -146,14 +148,23 @@ func (k Keeper) LastCheckpointWithStatus(ctx context.Context, req *types.QueryLa if err != nil { return nil, fmt.Errorf("failed to get the last checkpointed epoch number: %w", err) } - for e := int(tipCheckpointedEpoch); e >= 0; e-- { - ckpt, err := k.GetRawCheckpoint(sdkCtx, uint64(e)) + // This loop iterates indefinitely, as tipCheckpointedEpoch is a uint64 + // that can only go up to 0 and not lower. + // Given that we want to also check epoch 0, we have this loop iterate + // indefinitely and specify the end-condition at the end of the loop + // i.e. we break if we have processed epoch 0. + for e := tipCheckpointedEpoch; ; e-- { + ckpt, err := k.GetRawCheckpoint(sdkCtx, e) if err != nil { return nil, fmt.Errorf("failed to get the raw checkpoint at epoch %v: %w", e, err) } if ckpt.Status == req.Status || ckpt.IsMoreMatureThanStatus(req.Status) { return &types.QueryLastCheckpointWithStatusResponse{RawCheckpoint: ckpt.Ckpt.ToResponse()}, nil } + // break as there are no more epochs to process + if e == 0 { + break + } } return nil, fmt.Errorf("cannot find checkpoint with status %v", req.Status) } diff --git a/x/checkpointing/keeper/keeper.go b/x/checkpointing/keeper/keeper.go index 59f9a9c7f..b5c0d677f 100644 --- a/x/checkpointing/keeper/keeper.go +++ b/x/checkpointing/keeper/keeper.go @@ -277,8 +277,12 @@ func (k *Keeper) SetEpochingKeeper(ek types.EpochingKeeper) { // and records the associated state update in lifecycle func (k Keeper) SetCheckpointSubmitted(ctx context.Context, epoch uint64) { sdkCtx := sdk.UnwrapSDKContext(ctx) - ckpt := k.setCheckpointStatus(ctx, epoch, types.Sealed, types.Submitted) - err := sdkCtx.EventManager().EmitTypedEvent( + ckpt, err := k.setCheckpointStatus(ctx, epoch, types.Sealed, types.Submitted) + if err != nil { + k.Logger(sdkCtx).Error("failed to set checkpoint status to SUBMITTED for epoch %v: %v", epoch, err) + return + } + err = sdkCtx.EventManager().EmitTypedEvent( &types.EventCheckpointSubmitted{Checkpoint: ckpt}, ) if err != nil { @@ -290,8 +294,12 @@ func (k Keeper) SetCheckpointSubmitted(ctx context.Context, epoch uint64) { // and records the associated state update in lifecycle func (k Keeper) SetCheckpointConfirmed(ctx context.Context, epoch uint64) { sdkCtx := sdk.UnwrapSDKContext(ctx) - ckpt := k.setCheckpointStatus(ctx, epoch, types.Submitted, types.Confirmed) - err := sdkCtx.EventManager().EmitTypedEvent( + ckpt, err := k.setCheckpointStatus(ctx, epoch, types.Submitted, types.Confirmed) + if err != nil { + k.Logger(sdkCtx).Error("failed to set checkpoint status to CONFIRMED for epoch %v: %v", epoch, err) + return + } + err = sdkCtx.EventManager().EmitTypedEvent( &types.EventCheckpointConfirmed{Checkpoint: ckpt}, ) if err != nil { @@ -308,11 +316,15 @@ func (k Keeper) SetCheckpointConfirmed(ctx context.Context, epoch uint64) { func (k Keeper) SetCheckpointFinalized(ctx context.Context, epoch uint64) { sdkCtx := sdk.UnwrapSDKContext(ctx) // set the checkpoint's status to be finalised - ckpt := k.setCheckpointStatus(ctx, epoch, types.Confirmed, types.Finalized) + ckpt, err := k.setCheckpointStatus(ctx, epoch, types.Confirmed, types.Finalized) + if err != nil { + k.Logger(sdkCtx).Error("failed to set checkpoint status to FINALIZED for epoch %v: %v", epoch, err) + return + } // remember the last finalised epoch k.SetLastFinalizedEpoch(ctx, epoch) // emit event - err := sdkCtx.EventManager().EmitTypedEvent( + err = sdkCtx.EventManager().EmitTypedEvent( &types.EventCheckpointFinalized{Checkpoint: ckpt}, ) if err != nil { @@ -328,8 +340,12 @@ func (k Keeper) SetCheckpointFinalized(ctx context.Context, epoch uint64) { // and records the associated state update in lifecycle func (k Keeper) SetCheckpointForgotten(ctx context.Context, epoch uint64) { sdkCtx := sdk.UnwrapSDKContext(ctx) - ckpt := k.setCheckpointStatus(ctx, epoch, types.Submitted, types.Sealed) - err := sdkCtx.EventManager().EmitTypedEvent( + ckpt, err := k.setCheckpointStatus(ctx, epoch, types.Submitted, types.Sealed) + if err != nil { + k.Logger(sdkCtx).Error("failed to set checkpoint status to SEALED for epoch %v: %v", epoch, err) + return + } + err = sdkCtx.EventManager().EmitTypedEvent( &types.EventCheckpointForgotten{Checkpoint: ckpt}, ) if err != nil { @@ -339,18 +355,13 @@ func (k Keeper) SetCheckpointForgotten(ctx context.Context, epoch uint64) { // setCheckpointStatus sets a ckptWithMeta to the given state, // and records the state update in its lifecycle -func (k Keeper) setCheckpointStatus(ctx context.Context, epoch uint64, from types.CheckpointStatus, to types.CheckpointStatus) *types.RawCheckpointWithMeta { +func (k Keeper) setCheckpointStatus(ctx context.Context, epoch uint64, from types.CheckpointStatus, to types.CheckpointStatus) (*types.RawCheckpointWithMeta, error) { ckptWithMeta, err := k.GetRawCheckpoint(ctx, epoch) if err != nil { - // TODO: ignore err for now - return nil + return nil, err } if ckptWithMeta.Status != from { - err = types.ErrInvalidCkptStatus.Wrapf("the status of the checkpoint should be %s", from.String()) - if err != nil { - // TODO: ignore err for now - return nil - } + return nil, types.ErrInvalidCkptStatus.Wrapf("the status of the checkpoint should be %s", from.String()) } ckptWithMeta.Status = to // set status ckptWithMeta.RecordStateUpdate(ctx, to) // record state update to the lifecycle @@ -360,7 +371,7 @@ func (k Keeper) setCheckpointStatus(ctx context.Context, epoch uint64, from type } statusChangeMsg := fmt.Sprintf("Checkpointing: checkpoint status for epoch %v successfully changed from %v to %v", epoch, from.String(), to.String()) k.Logger(sdk.UnwrapSDKContext(ctx)).Info(statusChangeMsg) - return ckptWithMeta + return ckptWithMeta, nil } func (k Keeper) UpdateCheckpoint(ctx context.Context, ckptWithMeta *types.RawCheckpointWithMeta) error { diff --git a/x/checkpointing/keeper/val_bls_set_test.go b/x/checkpointing/keeper/val_bls_set_test.go index 36f4cf822..9b47aafc6 100644 --- a/x/checkpointing/keeper/val_bls_set_test.go +++ b/x/checkpointing/keeper/val_bls_set_test.go @@ -28,7 +28,7 @@ func FuzzGetValidatorBlsKeySet(f *testing.F) { queryHelper := baseapp.NewQueryServerTestHelper(helper.Ctx, helper.App.InterfaceRegistry()) types.RegisterQueryServer(queryHelper, ck) msgServer := checkpointingkeeper.NewMsgServerImpl(ck) - genesisVal := ek.GetValidatorSet(helper.Ctx, 0)[0] + genesisVal := ek.GetValidatorSet(helper.Ctx, 1)[0] genesisBLSPubkey, err := ck.GetBlsPubKey(helper.Ctx, genesisVal.Addr) require.NoError(t, err) diff --git a/x/checkpointing/module.go b/x/checkpointing/module.go index ff29c666f..4602c5744 100644 --- a/x/checkpointing/module.go +++ b/x/checkpointing/module.go @@ -81,7 +81,9 @@ func (AppModuleBasic) RegisterRESTRoutes(clientCtx client.Context, rtr *mux.Rout // RegisterGRPCGatewayRoutes registers the gRPC Gateway routes for the module. func (AppModuleBasic) RegisterGRPCGatewayRoutes(clientCtx client.Context, mux *runtime.ServeMux) { - types.RegisterQueryHandlerClient(context.Background(), mux, types.NewQueryClient(clientCtx)) //nolint:errcheck // generally we don't handle errors here + if err := types.RegisterQueryHandlerClient(context.Background(), mux, types.NewQueryClient(clientCtx)); err != nil { + panic(err) + } } // GetTxCmd returns the capability module's root tx command. diff --git a/x/checkpointing/proposal.go b/x/checkpointing/proposal.go index 68748c460..de0662345 100644 --- a/x/checkpointing/proposal.go +++ b/x/checkpointing/proposal.go @@ -7,21 +7,28 @@ import ( "slices" "cosmossdk.io/log" + abci "github.com/cometbft/cometbft/abci/types" "github.com/cosmos/cosmos-sdk/baseapp" + "github.com/cosmos/cosmos-sdk/client" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/mempool" - abci "github.com/cometbft/cometbft/abci/types" - + appparams "github.com/babylonlabs-io/babylon/app/params" ckpttypes "github.com/babylonlabs-io/babylon/x/checkpointing/types" ) const defaultInjectedTxIndex = 0 type ProposalHandler struct { - logger log.Logger - ckptKeeper CheckpointingKeeper - txVerifier baseapp.ProposalTxVerifier + logger log.Logger + ckptKeeper CheckpointingKeeper + bApp *baseapp.BaseApp + + // used for building and parsing the injected tx + txEncoder sdk.TxEncoder + txDecoder sdk.TxDecoder + txBuilder client.TxBuilder + defaultPrepareProposalHandler sdk.PrepareProposalHandler defaultProcessProposalHandler sdk.ProcessProposalHandler } @@ -30,13 +37,19 @@ func NewProposalHandler( logger log.Logger, ckptKeeper CheckpointingKeeper, mp mempool.Mempool, - txVerifier baseapp.ProposalTxVerifier, + bApp *baseapp.BaseApp, + encCfg *appparams.EncodingConfig, ) *ProposalHandler { - defaultHandler := baseapp.NewDefaultProposalHandler(mp, txVerifier) + defaultHandler := baseapp.NewDefaultProposalHandler(mp, bApp) + ckpttypes.RegisterInterfaces(encCfg.InterfaceRegistry) + return &ProposalHandler{ logger: logger, ckptKeeper: ckptKeeper, - txVerifier: txVerifier, + bApp: bApp, + txEncoder: encCfg.TxConfig.TxEncoder(), + txDecoder: encCfg.TxConfig.TxDecoder(), + txBuilder: encCfg.TxConfig.NewTxBuilder(), defaultPrepareProposalHandler: defaultHandler.PrepareProposalHandler(), defaultProcessProposalHandler: defaultHandler.ProcessProposalHandler(), } @@ -91,11 +104,11 @@ func (h *ProposalHandler) PrepareProposal() sdk.PrepareProposalHandler { } // 3. inject a "fake" tx into the proposal s.t. validators can decode, verify the checkpoint - injectedCkpt := &ckpttypes.InjectedCheckpoint{ + injectedCkpt := &ckpttypes.MsgInjectedCheckpoint{ Ckpt: ckpt, ExtendedCommitInfo: &req.LocalLastCommit, } - injectedVoteExtTx, err := injectedCkpt.Marshal() + injectedVoteExtTx, err := h.buildInjectedTxBytes(injectedCkpt) if err != nil { return nil, fmt.Errorf("failed to encode vote extensions into a special tx: %w", err) } @@ -268,7 +281,7 @@ func (h *ProposalHandler) ProcessProposal() sdk.ProcessProposalHandler { // and no BLS signatures are send in epoch 0 if epoch.IsVoteExtensionProposal(ctx) { // 1. extract the special tx containing the checkpoint - injectedCkpt, err := extractInjectedCheckpoint(req.Txs) + injectedCkpt, err := h.ExtractInjectedCheckpoint(req.Txs) if err != nil { h.logger.Error( "processProposal: failed to extract injected checkpoint from the tx set", "err", err) @@ -345,7 +358,7 @@ func (h *ProposalHandler) PreBlocker() sdk.PreBlocker { } // 1. extract the special tx containing BLS sigs - injectedCkpt, err := extractInjectedCheckpoint(req.Txs) + injectedCkpt, err := h.ExtractInjectedCheckpoint(req.Txs) if err != nil { return res, fmt.Errorf( "preblocker: failed to extract injected checkpoint from the tx set: %w", err) @@ -360,24 +373,37 @@ func (h *ProposalHandler) PreBlocker() sdk.PreBlocker { } } -// extractInjectedCheckpoint extracts the injected checkpoint from the tx set -func extractInjectedCheckpoint(txs [][]byte) (*ckpttypes.InjectedCheckpoint, error) { +func (h *ProposalHandler) buildInjectedTxBytes(injectedCkpt *ckpttypes.MsgInjectedCheckpoint) ([]byte, error) { + if err := h.txBuilder.SetMsgs(injectedCkpt); err != nil { + return nil, err + } + + return h.txEncoder(h.txBuilder.GetTx()) +} + +// ExtractInjectedCheckpoint extracts the injected checkpoint from the tx set +func (h *ProposalHandler) ExtractInjectedCheckpoint(txs [][]byte) (*ckpttypes.MsgInjectedCheckpoint, error) { if len(txs) < defaultInjectedTxIndex+1 { return nil, fmt.Errorf("the tx set does not contain the injected tx") } - injectedTx := txs[defaultInjectedTxIndex] + injectedTxBytes := txs[defaultInjectedTxIndex] - if len(injectedTx) == 0 { + if len(injectedTxBytes) == 0 { return nil, fmt.Errorf("the injected vote extensions tx is empty") } - var injectedCkpt ckpttypes.InjectedCheckpoint - if err := injectedCkpt.Unmarshal(injectedTx); err != nil { + injectedTx, err := h.txDecoder(injectedTxBytes) + if err != nil { return nil, fmt.Errorf("failed to decode injected vote extension tx: %w", err) } + msgs := injectedTx.GetMsgs() + if len(msgs) != 1 { + return nil, fmt.Errorf("injected tx must have exact one message, got %d", len(msgs)) + } + injectedCkpt := msgs[0].(*ckpttypes.MsgInjectedCheckpoint) - return &injectedCkpt, nil + return injectedCkpt, nil } // removeInjectedTx removes the injected tx from the tx set diff --git a/x/checkpointing/proposal_test.go b/x/checkpointing/proposal_test.go index afd88afd4..65ffb139f 100644 --- a/x/checkpointing/proposal_test.go +++ b/x/checkpointing/proposal_test.go @@ -13,6 +13,8 @@ import ( cbftt "github.com/cometbft/cometbft/abci/types" cmtprotocrypto "github.com/cometbft/cometbft/proto/tendermint/crypto" tendermintTypes "github.com/cometbft/cometbft/proto/tendermint/types" + dbm "github.com/cosmos/cosmos-db" + "github.com/cosmos/cosmos-sdk/baseapp" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/mempool" protoio "github.com/cosmos/gogoproto/io" @@ -20,6 +22,7 @@ import ( "github.com/golang/mock/gomock" "github.com/stretchr/testify/require" + appparams "github.com/babylonlabs-io/babylon/app/params" "github.com/babylonlabs-io/babylon/crypto/bls12381" "github.com/babylonlabs-io/babylon/testutil/datagen" "github.com/babylonlabs-io/babylon/testutil/helper" @@ -484,11 +487,17 @@ func TestPrepareProposalAtVoteExtensionHeight(t *testing.T) { ek.EXPECT().GetTotalVotingPower(gomock.Any(), ec.Epoch.EpochNumber).Return(scenario.TotalPower).AnyTimes() ek.EXPECT().GetValidatorSet(gomock.Any(), ec.Epoch.EpochNumber).Return(et.NewSortedValidatorSet(ToValidatorSet(scenario.ValidatorSet))).AnyTimes() + logger := log.NewTestLogger(t) + db := dbm.NewMemDB() + name := t.Name() + encCfg := appparams.DefaultEncodingConfig() + bApp := baseapp.NewBaseApp(name, logger, db, encCfg.TxConfig.TxDecoder(), baseapp.SetChainID("chain-test")) h := checkpointing.NewProposalHandler( log.NewNopLogger(), ek, mem, - nil, + bApp, + encCfg, ) commitInfo, _, cometInfo := helper.ExtendedCommitToLastCommit(cbftt.ExtendedCommitInfo{Round: 0, Votes: scenario.Extensions}) @@ -502,8 +511,7 @@ func TestPrepareProposalAtVoteExtensionHeight(t *testing.T) { } else { require.NoError(t, err) require.Len(t, prop.Txs, 1) - var checkpoint checkpointingtypes.InjectedCheckpoint - err := checkpoint.Unmarshal(prop.Txs[0]) + checkpoint, err := h.ExtractInjectedCheckpoint(prop.Txs) require.NoError(t, err) err = verifyCheckpoint(scenario.ValidatorSet, checkpoint.Ckpt.Ckpt) require.NoError(t, err) diff --git a/x/checkpointing/types/checkpoint.pb.go b/x/checkpointing/types/checkpoint.pb.go index 801ac381d..7850a21b2 100644 --- a/x/checkpointing/types/checkpoint.pb.go +++ b/x/checkpointing/types/checkpoint.pb.go @@ -207,26 +207,28 @@ func (m *RawCheckpointWithMeta) GetLifecycle() []*CheckpointStateUpdate { return nil } -// InjectedCheckpoint wraps the checkpoint and the extended votes -type InjectedCheckpoint struct { +// MsgInjectedCheckpoint wraps the checkpoint and the extended votes +// Note: this is a special message type that is only for internal ABCI++ usage +// for inserting checkpoint into the block +type MsgInjectedCheckpoint struct { Ckpt *RawCheckpointWithMeta `protobuf:"bytes,1,opt,name=ckpt,proto3" json:"ckpt,omitempty"` // extended_commit_info is the commit info including the vote extensions // from the previous proposal ExtendedCommitInfo *types.ExtendedCommitInfo `protobuf:"bytes,2,opt,name=extended_commit_info,json=extendedCommitInfo,proto3" json:"extended_commit_info,omitempty"` } -func (m *InjectedCheckpoint) Reset() { *m = InjectedCheckpoint{} } -func (m *InjectedCheckpoint) String() string { return proto.CompactTextString(m) } -func (*InjectedCheckpoint) ProtoMessage() {} -func (*InjectedCheckpoint) Descriptor() ([]byte, []int) { +func (m *MsgInjectedCheckpoint) Reset() { *m = MsgInjectedCheckpoint{} } +func (m *MsgInjectedCheckpoint) String() string { return proto.CompactTextString(m) } +func (*MsgInjectedCheckpoint) ProtoMessage() {} +func (*MsgInjectedCheckpoint) Descriptor() ([]byte, []int) { return fileDescriptor_73996df9c6aabde4, []int{2} } -func (m *InjectedCheckpoint) XXX_Unmarshal(b []byte) error { +func (m *MsgInjectedCheckpoint) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } -func (m *InjectedCheckpoint) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { +func (m *MsgInjectedCheckpoint) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { - return xxx_messageInfo_InjectedCheckpoint.Marshal(b, m, deterministic) + return xxx_messageInfo_MsgInjectedCheckpoint.Marshal(b, m, deterministic) } else { b = b[:cap(b)] n, err := m.MarshalToSizedBuffer(b) @@ -236,26 +238,26 @@ func (m *InjectedCheckpoint) XXX_Marshal(b []byte, deterministic bool) ([]byte, return b[:n], nil } } -func (m *InjectedCheckpoint) XXX_Merge(src proto.Message) { - xxx_messageInfo_InjectedCheckpoint.Merge(m, src) +func (m *MsgInjectedCheckpoint) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgInjectedCheckpoint.Merge(m, src) } -func (m *InjectedCheckpoint) XXX_Size() int { +func (m *MsgInjectedCheckpoint) XXX_Size() int { return m.Size() } -func (m *InjectedCheckpoint) XXX_DiscardUnknown() { - xxx_messageInfo_InjectedCheckpoint.DiscardUnknown(m) +func (m *MsgInjectedCheckpoint) XXX_DiscardUnknown() { + xxx_messageInfo_MsgInjectedCheckpoint.DiscardUnknown(m) } -var xxx_messageInfo_InjectedCheckpoint proto.InternalMessageInfo +var xxx_messageInfo_MsgInjectedCheckpoint proto.InternalMessageInfo -func (m *InjectedCheckpoint) GetCkpt() *RawCheckpointWithMeta { +func (m *MsgInjectedCheckpoint) GetCkpt() *RawCheckpointWithMeta { if m != nil { return m.Ckpt } return nil } -func (m *InjectedCheckpoint) GetExtendedCommitInfo() *types.ExtendedCommitInfo { +func (m *MsgInjectedCheckpoint) GetExtendedCommitInfo() *types.ExtendedCommitInfo { if m != nil { return m.ExtendedCommitInfo } @@ -404,7 +406,7 @@ func init() { proto.RegisterEnum("babylon.checkpointing.v1.CheckpointStatus", CheckpointStatus_name, CheckpointStatus_value) proto.RegisterType((*RawCheckpoint)(nil), "babylon.checkpointing.v1.RawCheckpoint") proto.RegisterType((*RawCheckpointWithMeta)(nil), "babylon.checkpointing.v1.RawCheckpointWithMeta") - proto.RegisterType((*InjectedCheckpoint)(nil), "babylon.checkpointing.v1.InjectedCheckpoint") + proto.RegisterType((*MsgInjectedCheckpoint)(nil), "babylon.checkpointing.v1.MsgInjectedCheckpoint") proto.RegisterType((*CheckpointStateUpdate)(nil), "babylon.checkpointing.v1.CheckpointStateUpdate") proto.RegisterType((*BlsSig)(nil), "babylon.checkpointing.v1.BlsSig") } @@ -414,61 +416,61 @@ func init() { } var fileDescriptor_73996df9c6aabde4 = []byte{ - // 852 bytes of a gzipped FileDescriptorProto + // 855 bytes of a gzipped FileDescriptorProto 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x55, 0xcf, 0x6e, 0x1b, 0x45, 0x1c, 0xf6, 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x8e, 0x0f, 0x3a, + 0xa3, 0xc1, 0xe1, 0xa7, 0xd5, 0x42, 0xbd, 0x7a, 0x72, 0xda, 0xda, 0xec, 0x78, 0x5e, 0x1a, 0xa6, + 0x01, 0x92, 0x9e, 0xc2, 0x6d, 0x00, 0x2f, 0xf3, 0xed, 0x7e, 0xe7, 0xa0, 0xbf, 0x57, 0xd5, 0xea, + 0xe0, 0xe4, 0xb4, 0x55, 0xb4, 0x31, 0x0a, 0xb0, 0x0f, 0x77, 0xc0, 0xd6, 0x0a, 0x67, 0xdc, 0x1d, + 0x0e, 0x46, 0xa3, 0xfe, 0x5e, 0x75, 0xad, 0x5e, 0x39, 0x39, 0x6d, 0x95, 0xec, 0xd4, 0x0d, 0xa9, + 0x10, 0x57, 0x99, 0xbd, 0xcf, 0x0f, 0xf7, 0x07, 0xd6, 0xb0, 0xbf, 0x57, 0x5d, 0xcf, 0x98, 0x3d, + 0x16, 0x4d, 0x68, 0x12, 0x5e, 0x65, 0xee, 0x0f, 0x0e, 0x3b, 0x07, 0x83, 0x87, 0xfd, 0xbd, 0xaa, + 0x9e, 0x31, 0xf7, 0x69, 0x84, 0x02, 0xfa, 0x0d, 0xf6, 0xeb, 0xfa, 0x77, 0x3f, 0x34, 0x0a, 0xdd, + 0x2f, 0x7e, 0x3e, 0x6b, 0x68, 0x4f, 0xcf, 0x1a, 0xda, 0xef, 0x67, 0x0d, 0xed, 0xc9, 0x79, 0xa3, + 0xf0, 0xf4, 0xbc, 0x51, 0xf8, 0xe5, 0xbc, 0x51, 0x78, 0xf8, 0xe1, 0xbf, 0xbb, 0xf4, 0xf8, 0x85, + 0xf7, 0x48, 0xbd, 0x0c, 0x6e, 0x51, 0x85, 0xee, 0xee, 0xdf, 0x01, 0x00, 0x00, 0xff, 0xff, 0x1e, + 0x6e, 0xa3, 0xf0, 0xb5, 0x06, 0x00, 0x00, } func (this *RawCheckpoint) Equal(that interface{}) bool { @@ -721,7 +723,7 @@ func (m *RawCheckpointWithMeta) MarshalToSizedBuffer(dAtA []byte) (int, error) { return len(dAtA) - i, nil } -func (m *InjectedCheckpoint) Marshal() (dAtA []byte, err error) { +func (m *MsgInjectedCheckpoint) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalToSizedBuffer(dAtA[:size]) @@ -731,12 +733,12 @@ func (m *InjectedCheckpoint) Marshal() (dAtA []byte, err error) { return dAtA[:n], nil } -func (m *InjectedCheckpoint) MarshalTo(dAtA []byte) (int, error) { +func (m *MsgInjectedCheckpoint) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *InjectedCheckpoint) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *MsgInjectedCheckpoint) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) _ = i var l int @@ -941,7 +943,7 @@ func (m *RawCheckpointWithMeta) Size() (n int) { return n } -func (m *InjectedCheckpoint) Size() (n int) { +func (m *MsgInjectedCheckpoint) Size() (n int) { if m == nil { return 0 } @@ -1377,7 +1379,7 @@ func (m *RawCheckpointWithMeta) Unmarshal(dAtA []byte) error { } return nil } -func (m *InjectedCheckpoint) Unmarshal(dAtA []byte) error { +func (m *MsgInjectedCheckpoint) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -1400,10 +1402,10 @@ func (m *InjectedCheckpoint) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: InjectedCheckpoint: wiretype end group for non-group") + return fmt.Errorf("proto: MsgInjectedCheckpoint: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: InjectedCheckpoint: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: MsgInjectedCheckpoint: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: diff --git a/x/checkpointing/types/codec.go b/x/checkpointing/types/codec.go index 5faec792e..6f5610d04 100644 --- a/x/checkpointing/types/codec.go +++ b/x/checkpointing/types/codec.go @@ -15,6 +15,7 @@ func RegisterInterfaces(registry cdctypes.InterfaceRegistry) { // Register messages registry.RegisterImplementations((*sdk.Msg)(nil), &MsgWrappedCreateValidator{}, + &MsgInjectedCheckpoint{}, ) msgservice.RegisterMsgServiceDesc(registry, &_Msg_serviceDesc) } diff --git a/x/checkpointing/types/query.pb.go b/x/checkpointing/types/query.pb.go index 30aef80a1..a83900823 100644 --- a/x/checkpointing/types/query.pb.go +++ b/x/checkpointing/types/query.pb.go @@ -399,10 +399,75 @@ func (m *QueryBlsPublicKeyListRequest) GetPagination() *query.PageRequest { return nil } +// BlsPublicKeyListResponse couples validator address, voting power, and its bls +// public key +type BlsPublicKeyListResponse struct { + // validator_address is the address of the validator + ValidatorAddress string `protobuf:"bytes,1,opt,name=validator_address,json=validatorAddress,proto3" json:"validator_address,omitempty"` + // bls_pub_key is the BLS public key of the validator + BlsPubKeyHex string `protobuf:"bytes,2,opt,name=bls_pub_key_hex,json=blsPubKeyHex,proto3" json:"bls_pub_key_hex,omitempty"` + // voting_power is the voting power of the validator at the given epoch + VotingPower uint64 `protobuf:"varint,3,opt,name=voting_power,json=votingPower,proto3" json:"voting_power,omitempty"` +} + +func (m *BlsPublicKeyListResponse) Reset() { *m = BlsPublicKeyListResponse{} } +func (m *BlsPublicKeyListResponse) String() string { return proto.CompactTextString(m) } +func (*BlsPublicKeyListResponse) ProtoMessage() {} +func (*BlsPublicKeyListResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_113f1ca5c3c2ca44, []int{7} +} +func (m *BlsPublicKeyListResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *BlsPublicKeyListResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_BlsPublicKeyListResponse.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 *BlsPublicKeyListResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_BlsPublicKeyListResponse.Merge(m, src) +} +func (m *BlsPublicKeyListResponse) XXX_Size() int { + return m.Size() +} +func (m *BlsPublicKeyListResponse) XXX_DiscardUnknown() { + xxx_messageInfo_BlsPublicKeyListResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_BlsPublicKeyListResponse proto.InternalMessageInfo + +func (m *BlsPublicKeyListResponse) GetValidatorAddress() string { + if m != nil { + return m.ValidatorAddress + } + return "" +} + +func (m *BlsPublicKeyListResponse) GetBlsPubKeyHex() string { + if m != nil { + return m.BlsPubKeyHex + } + return "" +} + +func (m *BlsPublicKeyListResponse) GetVotingPower() uint64 { + if m != nil { + return m.VotingPower + } + return 0 +} + // QueryBlsPublicKeyListResponse is the response type for the // Query/BlsPublicKeys RPC method. type QueryBlsPublicKeyListResponse struct { - ValidatorWithBlsKeys []*ValidatorWithBlsKey `protobuf:"bytes,1,rep,name=validator_with_bls_keys,json=validatorWithBlsKeys,proto3" json:"validator_with_bls_keys,omitempty"` + ValidatorWithBlsKeys []*BlsPublicKeyListResponse `protobuf:"bytes,1,rep,name=validator_with_bls_keys,json=validatorWithBlsKeys,proto3" json:"validator_with_bls_keys,omitempty"` // pagination defines the pagination in the response. Pagination *query.PageResponse `protobuf:"bytes,2,opt,name=pagination,proto3" json:"pagination,omitempty"` } @@ -411,7 +476,7 @@ func (m *QueryBlsPublicKeyListResponse) Reset() { *m = QueryBlsPublicKey func (m *QueryBlsPublicKeyListResponse) String() string { return proto.CompactTextString(m) } func (*QueryBlsPublicKeyListResponse) ProtoMessage() {} func (*QueryBlsPublicKeyListResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_113f1ca5c3c2ca44, []int{7} + return fileDescriptor_113f1ca5c3c2ca44, []int{8} } func (m *QueryBlsPublicKeyListResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -440,7 +505,7 @@ func (m *QueryBlsPublicKeyListResponse) XXX_DiscardUnknown() { var xxx_messageInfo_QueryBlsPublicKeyListResponse proto.InternalMessageInfo -func (m *QueryBlsPublicKeyListResponse) GetValidatorWithBlsKeys() []*ValidatorWithBlsKey { +func (m *QueryBlsPublicKeyListResponse) GetValidatorWithBlsKeys() []*BlsPublicKeyListResponse { if m != nil { return m.ValidatorWithBlsKeys } @@ -464,7 +529,7 @@ func (m *QueryEpochStatusRequest) Reset() { *m = QueryEpochStatusRequest func (m *QueryEpochStatusRequest) String() string { return proto.CompactTextString(m) } func (*QueryEpochStatusRequest) ProtoMessage() {} func (*QueryEpochStatusRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_113f1ca5c3c2ca44, []int{8} + return fileDescriptor_113f1ca5c3c2ca44, []int{9} } func (m *QueryEpochStatusRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -510,7 +575,7 @@ func (m *QueryEpochStatusResponse) Reset() { *m = QueryEpochStatusRespon func (m *QueryEpochStatusResponse) String() string { return proto.CompactTextString(m) } func (*QueryEpochStatusResponse) ProtoMessage() {} func (*QueryEpochStatusResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_113f1ca5c3c2ca44, []int{9} + return fileDescriptor_113f1ca5c3c2ca44, []int{10} } func (m *QueryEpochStatusResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -558,7 +623,7 @@ func (m *QueryRecentEpochStatusCountRequest) Reset() { *m = QueryRecentE func (m *QueryRecentEpochStatusCountRequest) String() string { return proto.CompactTextString(m) } func (*QueryRecentEpochStatusCountRequest) ProtoMessage() {} func (*QueryRecentEpochStatusCountRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_113f1ca5c3c2ca44, []int{10} + return fileDescriptor_113f1ca5c3c2ca44, []int{11} } func (m *QueryRecentEpochStatusCountRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -606,7 +671,7 @@ func (m *QueryRecentEpochStatusCountResponse) Reset() { *m = QueryRecent func (m *QueryRecentEpochStatusCountResponse) String() string { return proto.CompactTextString(m) } func (*QueryRecentEpochStatusCountResponse) ProtoMessage() {} func (*QueryRecentEpochStatusCountResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_113f1ca5c3c2ca44, []int{11} + return fileDescriptor_113f1ca5c3c2ca44, []int{12} } func (m *QueryRecentEpochStatusCountResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -666,7 +731,7 @@ func (m *QueryLastCheckpointWithStatusRequest) Reset() { *m = QueryLastC func (m *QueryLastCheckpointWithStatusRequest) String() string { return proto.CompactTextString(m) } func (*QueryLastCheckpointWithStatusRequest) ProtoMessage() {} func (*QueryLastCheckpointWithStatusRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_113f1ca5c3c2ca44, []int{12} + return fileDescriptor_113f1ca5c3c2ca44, []int{13} } func (m *QueryLastCheckpointWithStatusRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -712,7 +777,7 @@ func (m *QueryLastCheckpointWithStatusResponse) Reset() { *m = QueryLast func (m *QueryLastCheckpointWithStatusResponse) String() string { return proto.CompactTextString(m) } func (*QueryLastCheckpointWithStatusResponse) ProtoMessage() {} func (*QueryLastCheckpointWithStatusResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_113f1ca5c3c2ca44, []int{13} + return fileDescriptor_113f1ca5c3c2ca44, []int{14} } func (m *QueryLastCheckpointWithStatusResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -766,7 +831,7 @@ func (m *RawCheckpointResponse) Reset() { *m = RawCheckpointResponse{} } func (m *RawCheckpointResponse) String() string { return proto.CompactTextString(m) } func (*RawCheckpointResponse) ProtoMessage() {} func (*RawCheckpointResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_113f1ca5c3c2ca44, []int{14} + return fileDescriptor_113f1ca5c3c2ca44, []int{15} } func (m *RawCheckpointResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -820,7 +885,7 @@ func (m *RawCheckpointResponse) GetBitmap() []byte { type CheckpointStateUpdateResponse struct { // state defines the event of a state transition towards this state State CheckpointStatus `protobuf:"varint,1,opt,name=state,proto3,enum=babylon.checkpointing.v1.CheckpointStatus" json:"state,omitempty"` - // status_desc respresents the description of status enum. + // status_desc represents the description of status enum. StatusDesc string `protobuf:"bytes,2,opt,name=status_desc,json=statusDesc,proto3" json:"status_desc,omitempty"` // block_height is the height of the Babylon block that triggers the state // update @@ -834,7 +899,7 @@ func (m *CheckpointStateUpdateResponse) Reset() { *m = CheckpointStateUp func (m *CheckpointStateUpdateResponse) String() string { return proto.CompactTextString(m) } func (*CheckpointStateUpdateResponse) ProtoMessage() {} func (*CheckpointStateUpdateResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_113f1ca5c3c2ca44, []int{15} + return fileDescriptor_113f1ca5c3c2ca44, []int{16} } func (m *CheckpointStateUpdateResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -896,7 +961,7 @@ type RawCheckpointWithMetaResponse struct { Ckpt *RawCheckpointResponse `protobuf:"bytes,1,opt,name=ckpt,proto3" json:"ckpt,omitempty"` // status defines the status of the checkpoint Status CheckpointStatus `protobuf:"varint,2,opt,name=status,proto3,enum=babylon.checkpointing.v1.CheckpointStatus" json:"status,omitempty"` - // status_desc respresents the description of status enum. + // status_desc represents the description of status enum. StatusDesc string `protobuf:"bytes,3,opt,name=status_desc,json=statusDesc,proto3" json:"status_desc,omitempty"` // bls_aggr_pk defines the aggregated BLS public key BlsAggrPk *github_com_babylonlabs_io_babylon_crypto_bls12381.PublicKey `protobuf:"bytes,4,opt,name=bls_aggr_pk,json=blsAggrPk,proto3,customtype=github.com/babylonlabs-io/babylon/crypto/bls12381.PublicKey" json:"bls_aggr_pk,omitempty"` @@ -912,7 +977,7 @@ func (m *RawCheckpointWithMetaResponse) Reset() { *m = RawCheckpointWith func (m *RawCheckpointWithMetaResponse) String() string { return proto.CompactTextString(m) } func (*RawCheckpointWithMetaResponse) ProtoMessage() {} func (*RawCheckpointWithMetaResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_113f1ca5c3c2ca44, []int{16} + return fileDescriptor_113f1ca5c3c2ca44, []int{17} } func (m *RawCheckpointWithMetaResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -984,6 +1049,7 @@ func init() { proto.RegisterType((*QueryRawCheckpointsRequest)(nil), "babylon.checkpointing.v1.QueryRawCheckpointsRequest") proto.RegisterType((*QueryRawCheckpointsResponse)(nil), "babylon.checkpointing.v1.QueryRawCheckpointsResponse") proto.RegisterType((*QueryBlsPublicKeyListRequest)(nil), "babylon.checkpointing.v1.QueryBlsPublicKeyListRequest") + proto.RegisterType((*BlsPublicKeyListResponse)(nil), "babylon.checkpointing.v1.BlsPublicKeyListResponse") proto.RegisterType((*QueryBlsPublicKeyListResponse)(nil), "babylon.checkpointing.v1.QueryBlsPublicKeyListResponse") proto.RegisterType((*QueryEpochStatusRequest)(nil), "babylon.checkpointing.v1.QueryEpochStatusRequest") proto.RegisterType((*QueryEpochStatusResponse)(nil), "babylon.checkpointing.v1.QueryEpochStatusResponse") @@ -1002,87 +1068,90 @@ func init() { } var fileDescriptor_113f1ca5c3c2ca44 = []byte{ - // 1265 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xd4, 0x57, 0xdd, 0x6f, 0xdb, 0x54, - 0x14, 0x9f, 0x93, 0xb6, 0x22, 0x27, 0x5d, 0x19, 0x57, 0x63, 0x0b, 0xd9, 0x96, 0x0e, 0x33, 0x46, - 0x37, 0x34, 0x5b, 0x49, 0xd7, 0x0f, 0xed, 0x13, 0x32, 0x0a, 0x93, 0xf6, 0xa1, 0xce, 0x65, 0x43, - 0xe2, 0x61, 0xe6, 0xda, 0xbd, 0x73, 0x4c, 0x1c, 0xdb, 0xcd, 0xbd, 0x4e, 0x1b, 0x8d, 0x09, 0x09, - 0x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0xf8, 0x91, 0x17, 0x78, 0x52, 0x2a, 0xba, 0x30, 0x2c, - 0xa9, 0x4b, 0x9d, 0xc2, 0x0b, 0xfd, 0x29, 0x41, 0x2e, 0x49, 0x65, 0xa0, 0x6b, 0x43, 0x20, 0x0d, - 0x91, 0x42, 0xf9, 0xeb, 0x63, 0xc7, 0x8b, 0xa4, 0xae, 0xf1, 0xa4, 0x96, 0xd1, 0x62, 0x72, 0x52, - 0x0e, 0xa6, 0x4c, 0xef, 0x9e, 0x6d, 0xb1, 0x93, 0xca, 0xf7, 0x9e, 0x6d, 0x17, 0xa4, 0xe7, 0xdb, - 0x05, 0xe9, 0xc5, 0x76, 0x41, 0x7a, 0xba, 0x53, 0x38, 0xf4, 0x7c, 0xa7, 0x70, 0xe8, 0xf7, 0x9d, - 0xc2, 0xa1, 0x8f, 0x97, 0x86, 0x3f, 0x1c, 0x5b, 0x5d, 0x97, 0xb1, 0xa6, 0x4f, 0xa8, 0x31, 0xc5, - 0xdf, 0xde, 0xf9, 0xff, 0x02, 0x00, 0x00, 0xff, 0xff, 0xae, 0x51, 0x3c, 0x6e, 0xd7, 0x11, 0x00, - 0x00, + // 1322 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xd4, 0x57, 0x5b, 0x8f, 0xdb, 0xc4, + 0x17, 0xaf, 0xf7, 0xa6, 0xff, 0x9e, 0x6c, 0xb7, 0xdb, 0x51, 0xff, 0x6d, 0x48, 0xdb, 0x6c, 0x31, + 0x6d, 0xe9, 0x45, 0xb5, 0x95, 0x6c, 0xf7, 0xa2, 0x5e, 0xe9, 0x96, 0x42, 0xa5, 0x5e, 0xb4, 0xf5, + 0x52, 0x90, 0x78, 0xa8, 0x19, 0x7b, 0xa7, 0x8e, 0x89, 0x63, 0xbb, 0x9e, 0xf1, 0x6e, 0xa3, 0x52, + 0x21, 0xc1, 0x17, 0x28, 0x42, 0xe2, 0x91, 0x2f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fd, 0x07, + 0x05, 0x72, 0x6d, 0xaf, 0x39, 0x2a, 0x0d, 0xc0, 0xd1, 0x4d, 0xb9, 0x0a, 0xe5, 0x61, 0x4c, 0x24, + 0xea, 0xf3, 0x02, 0xf5, 0x22, 0x5a, 0xc8, 0x46, 0x2d, 0x40, 0xa6, 0xc0, 0xea, 0x72, 0x57, 0xfd, + 0xa2, 0xc0, 0xfe, 0xde, 0x3c, 0x04, 0x5d, 0x18, 0x91, 0xbe, 0x24, 0x91, 0x5c, 0x7c, 0x2d, 0xf2, + 0xa3, 0x2e, 0x8a, 0xa0, 0x74, 0x74, 0x66, 0x50, 0x50, 0xe7, 0xda, 0x89, 0x17, 0xfa, 0x43, 0x81, + 0x7c, 0x16, 0xcb, 0x40, 0x97, 0x06, 0x40, 0x1a, 0x40, 0x85, 0x0a, 0x97, 0x47, 0xb6, 0x97, 0x41, + 0x5d, 0x12, 0x41, 0xad, 0xa0, 0xa5, 0xec, 0xa0, 0x3c, 0x4c, 0x99, 0xd9, 0x39, 0xdb, 0x72, 0x27, + 0xad, 0xde, 0x79, 0xfa, 0xb2, 0xa8, 0x3c, 0x7b, 0x59, 0x54, 0x5e, 0xbc, 0x2c, 0x2a, 0x4f, 0x5e, + 0x15, 0x77, 0x3d, 0x7b, 0x55, 0xdc, 0xf5, 0xdb, 0xab, 0xe2, 0xae, 0x8f, 0x97, 0x07, 0x3f, 0x1c, + 0x0f, 0x3b, 0x2e, 0x63, 0xf5, 0x90, 0x50, 0x6b, 0x4a, 0xbc, 0xbd, 0x0b, 0xff, 0x06, 0x00, 0x00, + 0xff, 0xff, 0x7b, 0x7c, 0xcd, 0x82, 0x70, 0x12, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -1677,6 +1746,48 @@ func (m *QueryBlsPublicKeyListRequest) MarshalToSizedBuffer(dAtA []byte) (int, e return len(dAtA) - i, nil } +func (m *BlsPublicKeyListResponse) 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 *BlsPublicKeyListResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *BlsPublicKeyListResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.VotingPower != 0 { + i = encodeVarintQuery(dAtA, i, uint64(m.VotingPower)) + i-- + dAtA[i] = 0x18 + } + if len(m.BlsPubKeyHex) > 0 { + i -= len(m.BlsPubKeyHex) + copy(dAtA[i:], m.BlsPubKeyHex) + i = encodeVarintQuery(dAtA, i, uint64(len(m.BlsPubKeyHex))) + i-- + dAtA[i] = 0x12 + } + if len(m.ValidatorAddress) > 0 { + i -= len(m.ValidatorAddress) + copy(dAtA[i:], m.ValidatorAddress) + i = encodeVarintQuery(dAtA, i, uint64(len(m.ValidatorAddress))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + func (m *QueryBlsPublicKeyListResponse) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) @@ -2224,6 +2335,26 @@ func (m *QueryBlsPublicKeyListRequest) Size() (n int) { return n } +func (m *BlsPublicKeyListResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.ValidatorAddress) + if l > 0 { + n += 1 + l + sovQuery(uint64(l)) + } + l = len(m.BlsPubKeyHex) + if l > 0 { + n += 1 + l + sovQuery(uint64(l)) + } + if m.VotingPower != 0 { + n += 1 + sovQuery(uint64(m.VotingPower)) + } + return n +} + func (m *QueryBlsPublicKeyListResponse) Size() (n int) { if m == nil { return 0 @@ -3104,6 +3235,139 @@ func (m *QueryBlsPublicKeyListRequest) Unmarshal(dAtA []byte) error { } return nil } +func (m *BlsPublicKeyListResponse) 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: BlsPublicKeyListResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: BlsPublicKeyListResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ValidatorAddress", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + 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 ErrInvalidLengthQuery + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.ValidatorAddress = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field BlsPubKeyHex", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + 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 ErrInvalidLengthQuery + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.BlsPubKeyHex = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 3: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field VotingPower", wireType) + } + m.VotingPower = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.VotingPower |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + 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 *QueryBlsPublicKeyListResponse) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 @@ -3162,7 +3426,7 @@ func (m *QueryBlsPublicKeyListResponse) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.ValidatorWithBlsKeys = append(m.ValidatorWithBlsKeys, &ValidatorWithBlsKey{}) + m.ValidatorWithBlsKeys = append(m.ValidatorWithBlsKeys, &BlsPublicKeyListResponse{}) if err := m.ValidatorWithBlsKeys[len(m.ValidatorWithBlsKeys)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } diff --git a/x/checkpointing/types/types.go b/x/checkpointing/types/types.go index 116728539..aaeba6b2c 100644 --- a/x/checkpointing/types/types.go +++ b/x/checkpointing/types/types.go @@ -184,11 +184,11 @@ func (ckpt RawCheckpoint) ValidateBasic() error { } err := ckpt.BlockHash.ValidateBasic() if err != nil { - return ErrInvalidRawCheckpoint.Wrapf(err.Error()) + return ErrInvalidRawCheckpoint.Wrapf("error validating block hash: %s", err.Error()) } err = ckpt.BlsMultiSig.ValidateBasic() if err != nil { - return ErrInvalidRawCheckpoint.Wrapf(err.Error()) + return ErrInvalidRawCheckpoint.Wrapf("error validating BLS multi-signature: %s", err.Error()) } return nil diff --git a/x/epoching/keeper/drop_validator_msg_decorator.go b/x/epoching/keeper/drop_validator_msg_decorator.go index c6261b1e3..36479145d 100644 --- a/x/epoching/keeper/drop_validator_msg_decorator.go +++ b/x/epoching/keeper/drop_validator_msg_decorator.go @@ -3,16 +3,17 @@ package keeper import ( epochingtypes "github.com/babylonlabs-io/babylon/x/epoching/types" sdk "github.com/cosmos/cosmos-sdk/types" + authz "github.com/cosmos/cosmos-sdk/x/authz" stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" ) // DropValidatorMsgDecorator defines an AnteHandler decorator that rejects all messages that might change the validator set. type DropValidatorMsgDecorator struct { - ek Keeper + ek *Keeper } // NewDropValidatorMsgDecorator creates a new DropValidatorMsgDecorator -func NewDropValidatorMsgDecorator(ek Keeper) *DropValidatorMsgDecorator { +func NewDropValidatorMsgDecorator(ek *Keeper) *DropValidatorMsgDecorator { return &DropValidatorMsgDecorator{ ek: ek, } @@ -32,20 +33,40 @@ func (qmd DropValidatorMsgDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, simu } // after genesis, if validator-related message, reject msg for _, msg := range tx.GetMsgs() { - if qmd.IsValidatorRelatedMsg(msg) { - return ctx, epochingtypes.ErrUnwrappedMsgType - } + err := qmd.ValidateMsg(msg) + return ctx, err } return next(ctx, tx, simulate) } -// IsValidatorRelatedMsg checks if the given message is of non-wrapped type, which should be rejected -func (qmd DropValidatorMsgDecorator) IsValidatorRelatedMsg(msg sdk.Msg) bool { - switch msg.(type) { +// ValidateMsg checks if the given message is of non-wrapped type, which should be rejected +// It returns true if the message is a validator-related message, and false otherwise. +// It returns an error if it is a MsgExec message which contains invalid messages. +func (qmd DropValidatorMsgDecorator) ValidateMsg(msg sdk.Msg) error { + switch msg := msg.(type) { case *stakingtypes.MsgCreateValidator, *stakingtypes.MsgDelegate, *stakingtypes.MsgUndelegate, *stakingtypes.MsgBeginRedelegate, *stakingtypes.MsgCancelUnbondingDelegation: - return true + // validator-related message + return epochingtypes.ErrUnwrappedMsgType + case *authz.MsgExec: + // MsgExec might contain a validator-related message and those should + // not bypass the ante handler + // https://jumpcrypto.com/writing/bypassing-ethermint-ante-handlers/ + // unpack the exec message + internalMsgs, err := msg.GetMessages() + if err != nil { + // the internal message is not valid + return err + } + // check if any of the internal messages is a validator-related message + for _, internalMsg := range internalMsgs { + // recursively validate the internal message + if err := qmd.ValidateMsg(internalMsg); err != nil { + return err + } + } + return nil default: - return false + return nil } } diff --git a/x/epoching/keeper/drop_validator_msg_decorator_test.go b/x/epoching/keeper/drop_validator_msg_decorator_test.go index a6411e373..b1094e353 100644 --- a/x/epoching/keeper/drop_validator_msg_decorator_test.go +++ b/x/epoching/keeper/drop_validator_msg_decorator_test.go @@ -3,35 +3,55 @@ package keeper import ( "testing" + "github.com/babylonlabs-io/babylon/x/epoching/types" + sdk "github.com/cosmos/cosmos-sdk/types" + authz "github.com/cosmos/cosmos-sdk/x/authz" stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" "github.com/stretchr/testify/require" - - sdk "github.com/cosmos/cosmos-sdk/types" ) +func newMsgExecWithStakingMsg() *authz.MsgExec { + msg := authz.NewMsgExec(sdk.AccAddress("test"), []sdk.Msg{ + &stakingtypes.MsgCreateValidator{}, + &stakingtypes.MsgEditValidator{}, + }) + return &msg +} + +func newValidMsgExec() *authz.MsgExec { + msg := authz.NewMsgExec(sdk.AccAddress("test"), []sdk.Msg{ + &stakingtypes.MsgEditValidator{}, + }) + return &msg +} + func TestDropValidatorMsgDecorator(t *testing.T) { testCases := []struct { - msg sdk.Msg - expectPass bool + msg sdk.Msg + expectErr error }{ // wrapped message types that should be rejected - {&stakingtypes.MsgCreateValidator{}, true}, - {&stakingtypes.MsgDelegate{}, true}, - {&stakingtypes.MsgUndelegate{}, true}, - {&stakingtypes.MsgBeginRedelegate{}, true}, - {&stakingtypes.MsgCancelUnbondingDelegation{}, true}, + {&stakingtypes.MsgCreateValidator{}, types.ErrUnwrappedMsgType}, + {&stakingtypes.MsgDelegate{}, types.ErrUnwrappedMsgType}, + {&stakingtypes.MsgUndelegate{}, types.ErrUnwrappedMsgType}, + {&stakingtypes.MsgBeginRedelegate{}, types.ErrUnwrappedMsgType}, + {&stakingtypes.MsgCancelUnbondingDelegation{}, types.ErrUnwrappedMsgType}, + // MsgExec that contains staking messages should be rejected + {newMsgExecWithStakingMsg(), types.ErrUnwrappedMsgType}, // allowed message types - {&stakingtypes.MsgEditValidator{}, false}, + {&stakingtypes.MsgEditValidator{}, nil}, + {newValidMsgExec(), nil}, } - decorator := NewDropValidatorMsgDecorator(Keeper{}) + decorator := NewDropValidatorMsgDecorator(&Keeper{}) for _, tc := range testCases { - res := decorator.IsValidatorRelatedMsg(tc.msg) - if tc.expectPass { - require.True(t, res) + err := decorator.ValidateMsg(tc.msg) + if tc.expectErr != nil { + require.Error(t, err) + require.Equal(t, tc.expectErr, err) } else { - require.False(t, res) + require.NoError(t, err) } } } diff --git a/x/epoching/keeper/epoch_val_set_test.go b/x/epoching/keeper/epoch_val_set_test.go index 32b886bbb..0f17fd14b 100644 --- a/x/epoching/keeper/epoch_val_set_test.go +++ b/x/epoching/keeper/epoch_val_set_test.go @@ -23,7 +23,7 @@ func FuzzEpochValSet(f *testing.F) { ctx, keeper := helper.Ctx, helper.App.EpochingKeeper valSet, err := helper.App.StakingKeeper.GetLastValidators(helper.Ctx) require.NoError(t, err) - getValSet := keeper.GetValidatorSet(ctx, 0) + getValSet := keeper.GetValidatorSet(ctx, 1) require.Equal(t, len(valSet), len(getValSet)) for i := range getValSet { consAddr, err := valSet[i].GetConsAddr() @@ -37,7 +37,7 @@ func FuzzEpochValSet(f *testing.F) { params := keeper.GetParams(ctx) // generate a random number of new blocks - for i := uint64(0); i < params.EpochInterval; i++ { + for i := uint64(1); i < params.EpochInterval; i++ { ctx, err = helper.ApplyEmptyBlockWithVoteExtension(r) require.NoError(t, err) } diff --git a/x/epoching/keeper/epochs.go b/x/epoching/keeper/epochs.go index 089318d63..d8967bb0b 100644 --- a/x/epoching/keeper/epochs.go +++ b/x/epoching/keeper/epochs.go @@ -37,10 +37,10 @@ func (k Keeper) InitEpoch(ctx context.Context) *types.Epoch { if header.Height > 0 { panic("InitEpoch can be invoked only at genesis") } - epochInterval := k.GetParams(ctx).EpochInterval - epoch := types.NewEpoch(0, epochInterval, 0, &header.Time) - k.setEpochInfo(ctx, 0, &epoch) - return &epoch + genesisEpoch := types.NewEpoch(0, 1, 0, &header.Time) + k.setEpochInfo(ctx, 0, &genesisEpoch) + + return &genesisEpoch } // GetEpoch fetches the current epoch diff --git a/x/epoching/keeper/grpc_query_test.go b/x/epoching/keeper/grpc_query_test.go index fa92bb853..de42d125f 100644 --- a/x/epoching/keeper/grpc_query_test.go +++ b/x/epoching/keeper/grpc_query_test.go @@ -109,7 +109,7 @@ func FuzzEpochsInfo(f *testing.F) { helper := testhelper.NewHelper(t) ctx, keeper, queryClient := helper.Ctx, helper.App.EpochingKeeper, helper.QueryClient - // enque the 1st block of the numEpochs'th epoch + // enqueue the 1st block of the numEpochs'th epoch epochInterval := keeper.GetParams(ctx).EpochInterval for i := uint64(0); i < (numEpochs - 2); i++ { // exclude the existing epoch 0 and 1 for j := uint64(0); j < epochInterval; j++ { @@ -149,7 +149,7 @@ func FuzzEpochMsgsQuery(f *testing.F) { txidsMap := map[string]bool{} helper := testhelper.NewHelper(t) ctx, keeper, queryClient := helper.Ctx, helper.App.EpochingKeeper, helper.QueryClient - // enque a random number of msgs with random txids + // enqueue a random number of msgs with random txids for i := uint64(0); i < numMsgs; i++ { txid := datagen.GenRandomByteArray(r, 32) txidsMap[hex.EncodeToString(txid)] = true diff --git a/x/epoching/module.go b/x/epoching/module.go index 06e611eb6..4d308bdfb 100644 --- a/x/epoching/module.go +++ b/x/epoching/module.go @@ -80,7 +80,9 @@ func (AppModuleBasic) RegisterRESTRoutes(clientCtx client.Context, rtr *mux.Rout // RegisterGRPCGatewayRoutes registers the gRPC Gateway routes for the module. func (AppModuleBasic) RegisterGRPCGatewayRoutes(clientCtx client.Context, mux *runtime.ServeMux) { - types.RegisterQueryHandlerClient(context.Background(), mux, types.NewQueryClient(clientCtx)) //nolint: errcheck // cosmos convention is not to check the error here. + if err := types.RegisterQueryHandlerClient(context.Background(), mux, types.NewQueryClient(clientCtx)); err != nil { + panic(err) + } } // GetTxCmd returns the capability module's root tx command. diff --git a/x/finality/README.md b/x/finality/README.md index 11c35a766..c4f19e6d2 100644 --- a/x/finality/README.md +++ b/x/finality/README.md @@ -22,14 +22,17 @@ providers; - [Concepts](#concepts) - [States](#states) - [Parameters](#parameters) + - [Voting power table](#voting-power-table) - [Public randomness](#public-randomness) - [Finality votes](#finality-votes) - [Indexed blocks with finalization status](#indexed-blocks-with-finalization-status) - [Equivocation evidences](#equivocation-evidences) + - [Signing info tracker](#signing-info-tracker) - [Messages](#messages) - [MsgCommitPubRandList](#msgcommitpubrandlist) - [MsgAddFinalitySig](#msgaddfinalitysig) - [MsgUpdateParams](#msgupdateparams) +- [BeginBlocker](#beginblocker) - [EndBlocker](#endblocker) - [Events](#events) - [Queries](#queries) @@ -82,14 +85,13 @@ participate in the finality voting round, an active finality provider with BTC delegations (as specified in the [BTC Staking module](../btcstaking/README.md)) needs to interact with Babylon as follows: -- **Committing EOTS public randomness.** The finality provider proactively - sends a merkle-tree-based commit of a list of *EOTS public randomness* - for future heights to the Finality module. EOTS ensures that given an EOTS - public randomness, a signer can only sign a single message. - Otherwise, anyone can extract the signer's secret key - by using two EOTS signatures on different messages, the corresponding EOTS - public randomness, and the signer's public key. - A public randomness commit takes effect only after it is BTC-timestamped. +- **Committing EOTS public randomness.** The finality provider proactively sends + a merkle-tree-based commit of a list of *EOTS public randomness* for future + heights to the Finality module. EOTS ensures that given an EOTS public + randomness, a signer can only sign a single message. Otherwise, anyone can + extract the signer's secret key by using two EOTS signatures on different + messages, the corresponding EOTS public randomness, and the signer's public + key. A public randomness commit takes effect only after it is BTC-timestamped. - **Submitting EOTS signatures.** Upon a new block, the finality provider submits an EOTS signature w.r.t. the derived public randomness at that height. The Finality module will verify the EOTS signature, and check if there are @@ -137,14 +139,24 @@ message Params { } ``` +### Voting power table + +The [voting power table management](./keeper/voting_power_table.go) maintains +the voting power table of all finality providers at each height of the Babylon +chain. The key is the block height concatenated with the finality provider's +Bitcoin secp256k1 public key in BIP-340 format, and the value is the finality +provider's voting power quantified in Satoshis. Voting power is assigned to top +`N` (defined in parameters) finality providers that have BTC-timestamped public +randomness for the height, ranked by the total delegated value. + ### Public randomness The [public randomness storage](./keeper/public_randomness.go) maintains the EOTS public randomness commit that each finality provider commits to Babylon. The key is the finality provider's Bitcoin secp256k1 public key concatenated -with the block height, and the value is a merkle tree constructed by the list -of public randomness with starting height, and the number of public randomness. -It also stores the epoch number at which Babylon receives the commit. +with the block height, and the value is a merkle tree constructed by the list of +public randomness with starting height, and the number of public randomness. It +also stores the epoch number at which Babylon receives the commit. ```protobuf // PubRandCommit is a commitment to a series of public randomness @@ -250,18 +262,17 @@ Information about finality providers' voting histories is tracked through The first mapping allows us to easily look at the recent signing info for a finality provider based on its public key, while the second mapping -(`MissedBlocksBitArray`) acts as a bit-array of size `SignedBlocksWindow` -that tells us if the finality provider missed the block for a given index in -the bit-array. The index in the bit-array is given as little-endian uint64. -The result is a varint that takes on 0 or 1, where 0 indicates the finality -provider did not miss (did sign) the corresponding block, and 1 indicates -they missed the block (did not sign). +(`MissedBlocksBitArray`) acts as a bit-array of size `SignedBlocksWindow` that +tells us if the finality provider missed the block for a given index in the +bit-array. The index in the bit-array is given as little-endian uint64. The +result is a varint that takes on 0 or 1, where 0 indicates the finality provider +did not miss (did sign) the corresponding block, and 1 indicates they missed the +block (did not sign). Note that the `MissedBlocksBitArray` is not explicitly initialized up-front. -Keys are added as the first `SignedBlocksWindow` blocks -for a newly active finality provider. The `SignedBlocksWindow` parameter -defines the size (number of blocks) of the sliding window used to track -finality provider liveness. +Keys are added as the first `SignedBlocksWindow` blocks for a newly active +finality provider. The `SignedBlocksWindow` parameter defines the size (number +of blocks) of the sliding window used to track finality provider liveness. The information stored for tracking finality provider liveness is as follows: @@ -300,9 +311,9 @@ The message handlers are defined at ### MsgCommitPubRandList The `MsgCommitPubRandList` message is used for committing a merkle tree -constructed by a list of EOTS public randomness that will be used by a -finality provider in the future. It is typically submitted by a finality -provider via the [finality provider](https://github.com/babylonchain/finality-provider) program. +constructed by a list of EOTS public randomness that will be used by a finality +provider in the future. It is typically submitted by a finality provider via the +[finality provider](https://github.com/babylonchain/finality-provider) program. ```protobuf // MsgCommitPubRandList defines a message for committing a list of public randomness for EOTS @@ -410,6 +421,21 @@ message MsgUpdateParams { } ``` +## BeginBlocker + +Upon `EndBlocker`, the Finality module of each Babylon node will [execute the +following](./abci.go): + +1. Record the voting power table at the current height, by reconciling the + voting power table at the last height with all events that affect voting + power distribution (including newly active BTC delegations, newly unbonded + BTC delegations, and slashed finality providers). Note that the voting power + is assigned to a finality provider if it (1) has BTC-timestamped public + randomness, and (2) it is ranked at top `N` by the total delegated value. +2. If the BTC Staking protocol is activated, i.e., there exists at least 1 + active BTC delegation, then record the voting power distribution w.r.t. the + active finality providers and active BTC delegations. + ## EndBlocker Upon `EndBlocker`, the Finality module of each Babylon node will [execute the @@ -435,8 +461,8 @@ been >=1 active BTC delegations)*: distribute rewards to the voted finality providers and their BTC delegations. Otherwise, none of the subsequent blocks shall be finalized and the loop breaks here. -3. Update the finality provider's voting history and label it to `sluggish` - if the number of block it has missed has passed the parameterized threshold. +3. Update the finality provider's voting history and label it to `sluggish` if + the number of block it has missed has passed the parameterized threshold. ## Events diff --git a/x/finality/abci.go b/x/finality/abci.go index 93ef8852a..656929837 100644 --- a/x/finality/abci.go +++ b/x/finality/abci.go @@ -14,7 +14,8 @@ import ( func BeginBlocker(ctx context.Context, k keeper.Keeper) error { defer telemetry.ModuleMeasureSince(types.ModuleName, time.Now(), telemetry.MetricKeyBeginBlocker) - return nil + + return k.BeginBlocker(ctx) } func EndBlocker(ctx context.Context, k keeper.Keeper) ([]abci.ValidatorUpdate, error) { @@ -22,7 +23,7 @@ func EndBlocker(ctx context.Context, k keeper.Keeper) ([]abci.ValidatorUpdate, e // if the BTC staking protocol is activated, i.e., there exists a height where a finality provider // has voting power, start indexing and tallying blocks - if _, err := k.BTCStakingKeeper.GetBTCStakingActivatedHeight(ctx); err == nil { + if k.IsFinalityActive(ctx) { // index the current block k.IndexBlock(ctx) // tally all non-finalised blocks diff --git a/x/finality/client/cli/query.go b/x/finality/client/cli/query.go index da6ef9361..01d0a7b07 100644 --- a/x/finality/client/cli/query.go +++ b/x/finality/client/cli/query.go @@ -28,13 +28,113 @@ func GetQueryCmd(queryRoute string) *cobra.Command { RunE: client.ValidateCmd, } - cmd.AddCommand(CmdQueryParams()) - cmd.AddCommand(CmdListPublicRandomness()) - cmd.AddCommand(CmdListPubRandCommit()) - cmd.AddCommand(CmdBlock()) - cmd.AddCommand(CmdListBlocks()) - cmd.AddCommand(CmdVotesAtHeight()) - cmd.AddCommand(CmdListEvidences()) + cmd.AddCommand( + CmdQueryParams(), + CmdFinalityProvidersAtHeight(), + CmdFinalityProviderPowerAtHeight(), + CmdActivatedHeight(), + CmdListPublicRandomness(), + CmdListPubRandCommit(), + CmdBlock(), + CmdListBlocks(), + CmdVotesAtHeight(), + CmdListEvidences(), + CmdSigningInfo(), + CmdAllSigningInfo(), + ) + + return cmd +} + +func CmdFinalityProviderPowerAtHeight() *cobra.Command { + cmd := &cobra.Command{ + Use: "finality-provider-power-at-height [fp_btc_pk_hex] [height]", + Short: "get the voting power of a given finality provider at a given height", + Args: cobra.ExactArgs(2), + RunE: func(cmd *cobra.Command, args []string) error { + clientCtx := client.GetClientContextFromCmd(cmd) + + queryClient := types.NewQueryClient(clientCtx) + + height, err := strconv.ParseUint(args[1], 10, 64) + if err != nil { + return err + } + res, err := queryClient.FinalityProviderPowerAtHeight(cmd.Context(), &types.QueryFinalityProviderPowerAtHeightRequest{ + FpBtcPkHex: args[0], + Height: height, + }) + if err != nil { + return err + } + + return clientCtx.PrintProto(res) + }, + } + + flags.AddQueryFlagsToCmd(cmd) + + return cmd +} + +func CmdActivatedHeight() *cobra.Command { + cmd := &cobra.Command{ + Use: "activated-height", + Short: "get activated height, i.e., the first height where there exists 1 finality provider with voting power", + Args: cobra.NoArgs, + RunE: func(cmd *cobra.Command, args []string) error { + clientCtx := client.GetClientContextFromCmd(cmd) + + queryClient := types.NewQueryClient(clientCtx) + + res, err := queryClient.ActivatedHeight(cmd.Context(), &types.QueryActivatedHeightRequest{}) + if err != nil { + return err + } + + return clientCtx.PrintProto(res) + }, + } + + flags.AddQueryFlagsToCmd(cmd) + + return cmd +} + +func CmdFinalityProvidersAtHeight() *cobra.Command { + cmd := &cobra.Command{ + Use: "finality-providers-at-height [height]", + Short: "retrieve all finality providers at a given babylon height", + Args: cobra.ExactArgs(1), + RunE: func(cmd *cobra.Command, args []string) error { + clientCtx := client.GetClientContextFromCmd(cmd) + + queryClient := types.NewQueryClient(clientCtx) + + height, err := strconv.ParseUint(args[0], 10, 64) + if err != nil { + return err + } + + pageReq, err := client.ReadPageRequest(cmd.Flags()) + if err != nil { + return err + } + + res, err := queryClient.ActiveFinalityProvidersAtHeight(cmd.Context(), &types.QueryActiveFinalityProvidersAtHeightRequest{ + Height: height, + Pagination: pageReq, + }) + if err != nil { + return err + } + + return clientCtx.PrintProto(res) + }, + } + + flags.AddQueryFlagsToCmd(cmd) + flags.AddPaginationFlagsToCmd(cmd, "finality-providers-at-height") return cmd } @@ -244,3 +344,67 @@ func CmdListEvidences() *cobra.Command { return cmd } + +func CmdSigningInfo() *cobra.Command { + cmd := &cobra.Command{ + Use: "signing-info [fp-pk-hex]", + Short: "Show signing info of a given finality provider", + Args: cobra.ExactArgs(1), + RunE: func(cmd *cobra.Command, args []string) error { + clientCtx := client.GetClientContextFromCmd(cmd) + + queryClient := types.NewQueryClient(clientCtx) + + fpPkHex := args[0] + + // query for the signing info of a given finality provider + res, err := queryClient.SigningInfo( + cmd.Context(), + &types.QuerySigningInfoRequest{FpBtcPkHex: fpPkHex}, + ) + if err != nil { + return err + } + + return clientCtx.PrintProto(res) + }, + } + + flags.AddQueryFlagsToCmd(cmd) + + return cmd +} + +func CmdAllSigningInfo() *cobra.Command { + cmd := &cobra.Command{ + Use: "all-signing-info", + Short: "Show signing info of finality providers", + Args: cobra.NoArgs, + RunE: func(cmd *cobra.Command, args []string) error { + clientCtx := client.GetClientContextFromCmd(cmd) + + queryClient := types.NewQueryClient(clientCtx) + + // query for all the signing infos + pageReq, err := client.ReadPageRequest(cmd.Flags()) + if err != nil { + return err + } + + res, err := queryClient.SigningInfos( + cmd.Context(), + &types.QuerySigningInfosRequest{Pagination: pageReq}, + ) + if err != nil { + return err + } + + return clientCtx.PrintProto(res) + }, + } + + flags.AddQueryFlagsToCmd(cmd) + flags.AddPaginationFlagsToCmd(cmd, "all-signing-info") + + return cmd +} diff --git a/x/finality/keeper/genesis.go b/x/finality/keeper/genesis.go index 1c41be585..ee5f21688 100644 --- a/x/finality/keeper/genesis.go +++ b/x/finality/keeper/genesis.go @@ -48,6 +48,14 @@ func (k Keeper) InitGenesis(ctx context.Context, gs types.GenesisState) error { } } + for _, fpVP := range gs.VotingPowers { + k.SetVotingPower(ctx, *fpVP.FpBtcPk, fpVP.BlockHeight, fpVP.VotingPower) + } + + for _, vpCache := range gs.VpDstCache { + k.SetVotingPowerDistCache(ctx, vpCache.BlockHeight, vpCache.VpDistribution) + } + return k.SetParams(ctx, gs.Params) } @@ -83,6 +91,16 @@ func (k Keeper) ExportGenesis(ctx context.Context) (*types.GenesisState, error) return nil, err } + vpFps, err := k.fpVotingPowers(ctx) + if err != nil { + return nil, err + } + + vpDstCache, err := k.votingPowersDistCacheBlkHeight(ctx) + if err != nil { + return nil, err + } + return &types.GenesisState{ Params: k.GetParams(ctx), IndexedBlocks: blocks, @@ -92,6 +110,8 @@ func (k Keeper) ExportGenesis(ctx context.Context) (*types.GenesisState, error) PubRandCommit: prCommit, SigningInfos: signingInfos, MissedBlocks: missedBlocks, + VotingPowers: vpFps, + VpDstCache: vpDstCache, }, nil } @@ -163,8 +183,8 @@ func (k Keeper) voteSigs(ctx context.Context) ([]*types.VoteSig, error) { return voteSigs, nil } -// publicRandomness iterates over all commited randoms on the store, parses the finality provider public key -// and the height from the iterator key and the commited random from the iterator value. +// publicRandomness iterates over all committed randoms on the store, parses the finality provider public key +// and the height from the iterator key and the committed random from the iterator value. // This function has high resource consumption and should be only used on export genesis. func (k Keeper) publicRandomness(ctx context.Context) ([]*types.PublicRandomness, error) { store := k.pubRandStore(ctx) @@ -254,6 +274,49 @@ func (k Keeper) signingInfosAndMissedBlock(ctx context.Context) ([]types.Signing return signingInfos, missedBlocks, nil } +// fpVotingPowers gets the voting power of a given finality provider at a given Babylon height. +func (k Keeper) fpVotingPowers(ctx context.Context) ([]*types.VotingPowerFP, error) { + iter := k.votingPowerStore(ctx).Iterator(nil, nil) + defer iter.Close() + + vpFps := make([]*types.VotingPowerFP, 0) + + for ; iter.Valid(); iter.Next() { + blkHeight, fpBTCPK, err := btcstk.ParseBlkHeightAndPubKeyFromStoreKey(iter.Key()) + if err != nil { + return nil, err + } + + vp := sdk.BigEndianToUint64(iter.Value()) + vpFps = append(vpFps, &types.VotingPowerFP{ + BlockHeight: blkHeight, + FpBtcPk: fpBTCPK, + VotingPower: vp, + }) + } + + return vpFps, nil +} + +func (k Keeper) votingPowersDistCacheBlkHeight(ctx context.Context) ([]*types.VotingPowerDistCacheBlkHeight, error) { + vps := make([]*types.VotingPowerDistCacheBlkHeight, 0) + iter := k.votingPowerDistCacheStore(ctx).Iterator(nil, nil) + defer iter.Close() + + for ; iter.Valid(); iter.Next() { + var dc types.VotingPowerDistCache + if err := dc.Unmarshal(iter.Value()); err != nil { + return nil, err + } + vps = append(vps, &types.VotingPowerDistCacheBlkHeight{ + BlockHeight: sdk.BigEndianToUint64(iter.Key()), + VpDistribution: &dc, + }) + } + + return vps, nil +} + // parsePubKeyAndBlkHeightFromStoreKey expects to receive a key with // BIP340PubKey(fpBTCPK) || BigEndianUint64(blkHeight) func parsePubKeyAndBlkHeightFromStoreKey(key []byte) (fpBTCPK *bbn.BIP340PubKey, blkHeight uint64, err error) { diff --git a/x/finality/keeper/genesis_test.go b/x/finality/keeper/genesis_test.go index 695b504d5..df9286152 100644 --- a/x/finality/keeper/genesis_test.go +++ b/x/finality/keeper/genesis_test.go @@ -36,6 +36,7 @@ func FuzzTestExportGenesis(f *testing.F) { allBlocks := make([]*types.IndexedBlock, numPubRand) allEvidences := make([]*types.Evidence, numPubRand) allPublicRandomness := make([]*types.PublicRandomness, numPubRand) + for i := 0; i < int(numPubRand); i++ { // Votes vt := &types.VoteSig{ @@ -78,7 +79,7 @@ func FuzzTestExportGenesis(f *testing.F) { } allPublicRandomness[i] = randomness - // updates the block everytime to make sure something is different. + // updates the block every time to make sure something is different. blkHeight++ } @@ -109,6 +110,20 @@ func FuzzTestExportGenesis(f *testing.F) { fpSigningInfos[fpPk.MarshalHex()] = &signingInfo } + numFps := datagen.RandomInt(r, 10) + 1 + fps := datagen.CreateNFinalityProviders(r, t, int(numFps)) + vpFps := make(map[string]*types.VotingPowerFP, 0) + for _, fp := range fps { + vp := uint64(datagen.RandomInt(r, 1000000)) + // sets voting power + k.SetVotingPower(ctx, *fp.BtcPk, blkHeight, vp) + vpFps[fp.BtcPk.MarshalHex()] = &types.VotingPowerFP{ + BlockHeight: blkHeight, + FpBtcPk: fp.BtcPk, + VotingPower: vp, + } + } + require.Equal(t, len(allVotes), int(numPubRand)) require.Equal(t, len(allBlocks), int(numPubRand)) require.Equal(t, len(allEvidences), int(numPubRand)) @@ -128,5 +143,10 @@ func FuzzTestExportGenesis(f *testing.F) { require.Equal(t, fpSigningInfos[info.FpBtcPk.MarshalHex()].MissedBlocksCounter, info.FpSigningInfo.MissedBlocksCounter) require.Equal(t, fpSigningInfos[info.FpBtcPk.MarshalHex()].StartHeight, info.FpSigningInfo.StartHeight) } + + require.Equal(t, len(vpFps), len(gs.VotingPowers)) + for _, fpVp := range gs.VotingPowers { + require.Equal(t, vpFps[fpVp.FpBtcPk.MarshalHex()], fpVp) + } }) } diff --git a/x/finality/keeper/grpc_query.go b/x/finality/keeper/grpc_query.go index 1478f8f26..6b0289e49 100644 --- a/x/finality/keeper/grpc_query.go +++ b/x/finality/keeper/grpc_query.go @@ -13,14 +13,112 @@ import ( "google.golang.org/grpc/status" bbn "github.com/babylonlabs-io/babylon/types" + bstypes "github.com/babylonlabs-io/babylon/x/btcstaking/types" "github.com/babylonlabs-io/babylon/x/finality/types" ) var _ types.QueryServer = Keeper{} +// FinalityProviderPowerAtHeight returns the voting power of the specified finality provider +// at the provided Babylon height +func (k Keeper) FinalityProviderPowerAtHeight(ctx context.Context, req *types.QueryFinalityProviderPowerAtHeightRequest) (*types.QueryFinalityProviderPowerAtHeightResponse, error) { + if req == nil { + return nil, status.Error(codes.InvalidArgument, "empty request") + } + + fpBTCPK, err := bbn.NewBIP340PubKeyFromHex(req.FpBtcPkHex) + if err != nil { + return nil, status.Errorf(codes.InvalidArgument, "failed to unmarshal finality provider BTC PK hex: %v", err) + } + + if !k.BTCStakingKeeper.HasFinalityProvider(ctx, *fpBTCPK) { + return nil, bstypes.ErrFpNotFound + } + + store := k.votingPowerBbnBlockHeightStore(ctx, req.Height) + iter := store.ReverseIterator(nil, nil) + defer iter.Close() + + if !iter.Valid() { + return nil, types.ErrVotingPowerTableNotUpdated.Wrapf("height: %d", req.Height) + } + + sdkCtx := sdk.UnwrapSDKContext(ctx) + power := k.GetVotingPower(sdkCtx, fpBTCPK.MustMarshal(), req.Height) + + return &types.QueryFinalityProviderPowerAtHeightResponse{VotingPower: power}, nil +} + +// FinalityProviderCurrentPower returns the voting power of the specified finality provider +// at the current height +func (k Keeper) FinalityProviderCurrentPower(ctx context.Context, req *types.QueryFinalityProviderCurrentPowerRequest) (*types.QueryFinalityProviderCurrentPowerResponse, error) { + if req == nil { + return nil, status.Error(codes.InvalidArgument, "empty request") + } + + fpBTCPK, err := bbn.NewBIP340PubKeyFromHex(req.FpBtcPkHex) + if err != nil { + return nil, status.Errorf(codes.InvalidArgument, "failed to unmarshal finality provider BTC PK hex: %v", err) + } + + height, power := k.GetCurrentVotingPower(ctx, *fpBTCPK) + + return &types.QueryFinalityProviderCurrentPowerResponse{Height: height, VotingPower: power}, nil +} + +// ActiveFinalityProvidersAtHeight returns the active finality providers at the provided height +func (k Keeper) ActiveFinalityProvidersAtHeight(ctx context.Context, req *types.QueryActiveFinalityProvidersAtHeightRequest) (*types.QueryActiveFinalityProvidersAtHeightResponse, error) { + if req == nil { + return nil, status.Error(codes.InvalidArgument, "empty request") + } + + sdkCtx := sdk.UnwrapSDKContext(ctx) + store := k.votingPowerBbnBlockHeightStore(sdkCtx, req.Height) + + var finalityProvidersWithMeta []*bstypes.FinalityProviderWithMeta + pageRes, err := query.Paginate(store, req.Pagination, func(key, value []byte) error { + finalityProvider, err := k.BTCStakingKeeper.GetFinalityProvider(sdkCtx, key) + if err != nil { + return err + } + + votingPower := k.GetVotingPower(sdkCtx, key, req.Height) + if votingPower > 0 { + finalityProviderWithMeta := bstypes.FinalityProviderWithMeta{ + BtcPk: finalityProvider.BtcPk, + Height: req.Height, + VotingPower: votingPower, + SlashedBabylonHeight: finalityProvider.SlashedBabylonHeight, + SlashedBtcHeight: finalityProvider.SlashedBtcHeight, + } + finalityProvidersWithMeta = append(finalityProvidersWithMeta, &finalityProviderWithMeta) + } + + return nil + }) + if err != nil { + return nil, err + } + + return &types.QueryActiveFinalityProvidersAtHeightResponse{FinalityProviders: convertToActiveFinalityProvidersAtHeightResponse(finalityProvidersWithMeta), Pagination: pageRes}, nil +} + +// ActivatedHeight returns the Babylon height in which the BTC Staking protocol was enabled +func (k Keeper) ActivatedHeight(ctx context.Context, req *types.QueryActivatedHeightRequest) (*types.QueryActivatedHeightResponse, error) { + if req == nil { + return nil, status.Error(codes.InvalidArgument, "empty request") + } + + sdkCtx := sdk.UnwrapSDKContext(ctx) + activatedHeight, err := k.GetBTCStakingActivatedHeight(sdkCtx) + if err != nil { + return nil, err + } + return &types.QueryActivatedHeightResponse{Height: activatedHeight}, nil +} + // ListPublicRandomness returns a list of public randomness committed by a given // finality provider -// TODO: remove public randomness storage? func (k Keeper) ListPublicRandomness(ctx context.Context, req *types.QueryListPublicRandomnessRequest) (*types.QueryListPublicRandomnessResponse, error) { if req == nil { return nil, status.Error(codes.InvalidArgument, "empty request") @@ -178,7 +276,7 @@ func (k Keeper) Evidence(ctx context.Context, req *types.QueryEvidenceRequest) ( } resp := &types.QueryEvidenceResponse{ - Evidence: evidence, + Evidence: convertToEvidenceResponse(evidence), } return resp, nil } @@ -220,7 +318,7 @@ func (k Keeper) ListEvidences(ctx context.Context, req *types.QueryListEvidences } resp := &types.QueryListEvidencesResponse{ - Evidences: evidences, + Evidences: convertToEvidenceListResponse(evidences), Pagination: pageRes, } return resp, nil @@ -246,7 +344,7 @@ func (k Keeper) SigningInfo(ctx context.Context, req *types.QuerySigningInfoRequ return nil, status.Errorf(codes.NotFound, "SigningInfo not found for the finality provider %s", req.FpBtcPkHex) } - return &types.QuerySigningInfoResponse{FpSigningInfo: signingInfo}, nil + return &types.QuerySigningInfoResponse{SigningInfo: convertToSigningInfoResponse(signingInfo)}, nil } // SigningInfos returns signing-infos of all finality providers. @@ -271,5 +369,58 @@ func (k Keeper) SigningInfos(ctx context.Context, req *types.QuerySigningInfosRe if err != nil { return nil, err } - return &types.QuerySigningInfosResponse{FpSigningInfos: signInfos, Pagination: pageRes}, nil + return &types.QuerySigningInfosResponse{SigningInfos: convertToSigningInfosResponse(signInfos), Pagination: pageRes}, nil +} + +func convertToSigningInfoResponse(info types.FinalityProviderSigningInfo) types.SigningInfoResponse { + return types.SigningInfoResponse{ + FpBtcPkHex: info.FpBtcPk.MarshalHex(), + StartHeight: info.StartHeight, + MissedBlocksCounter: info.MissedBlocksCounter, + JailedUntil: info.JailedUntil, + } +} + +func convertToSigningInfosResponse(signInfos []types.FinalityProviderSigningInfo) []types.SigningInfoResponse { + response := make([]types.SigningInfoResponse, len(signInfos)) + for i, info := range signInfos { + response[i] = convertToSigningInfoResponse(info) + } + return response +} + +func convertToEvidenceResponse(evidence *types.Evidence) *types.EvidenceResponse { + return &types.EvidenceResponse{ + FpBtcPkHex: evidence.FpBtcPk.MarshalHex(), + BlockHeight: evidence.BlockHeight, + PubRand: evidence.PubRand, + CanonicalAppHash: evidence.CanonicalAppHash, + ForkAppHash: evidence.ForkAppHash, + CanonicalFinalitySig: evidence.CanonicalFinalitySig, + ForkFinalitySig: evidence.ForkFinalitySig, + } +} + +func convertToEvidenceListResponse(evidences []*types.Evidence) []*types.EvidenceResponse { + response := make([]*types.EvidenceResponse, len(evidences)) + for i, evidence := range evidences { + resp := convertToEvidenceResponse(evidence) + response[i] = resp + } + return response +} + +func convertToActiveFinalityProvidersAtHeightResponse(finalityProvidersWithMeta []*bstypes.FinalityProviderWithMeta) []*types.ActiveFinalityProvidersAtHeightResponse { + var activeFinalityProvidersAtHeightResponse []*types.ActiveFinalityProvidersAtHeightResponse + for _, fpWithMeta := range finalityProvidersWithMeta { + activeFinalityProvidersAtHeightResponse = append(activeFinalityProvidersAtHeightResponse, &types.ActiveFinalityProvidersAtHeightResponse{ + BtcPkHex: fpWithMeta.BtcPk, + Height: fpWithMeta.Height, + VotingPower: fpWithMeta.VotingPower, + SlashedBabylonHeight: fpWithMeta.SlashedBabylonHeight, + SlashedBtcHeight: fpWithMeta.SlashedBtcHeight, + Jailed: fpWithMeta.Jailed, + }) + } + return activeFinalityProvidersAtHeightResponse } diff --git a/x/finality/keeper/grpc_query_test.go b/x/finality/keeper/grpc_query_test.go index baecb562b..3e9483521 100644 --- a/x/finality/keeper/grpc_query_test.go +++ b/x/finality/keeper/grpc_query_test.go @@ -11,14 +11,214 @@ import ( "github.com/golang/mock/gomock" "github.com/stretchr/testify/require" + testutil "github.com/babylonlabs-io/babylon/testutil/btcstaking-helper" "github.com/babylonlabs-io/babylon/testutil/datagen" testkeeper "github.com/babylonlabs-io/babylon/testutil/keeper" bbn "github.com/babylonlabs-io/babylon/types" + btclctypes "github.com/babylonlabs-io/babylon/x/btclightclient/types" + bstypes "github.com/babylonlabs-io/babylon/x/btcstaking/types" epochingtypes "github.com/babylonlabs-io/babylon/x/epoching/types" "github.com/babylonlabs-io/babylon/x/finality/keeper" "github.com/babylonlabs-io/babylon/x/finality/types" ) +func FuzzActivatedHeight(f *testing.F) { + datagen.AddRandomSeedsToFuzzer(f, 10) + f.Fuzz(func(t *testing.T, seed int64) { + r := rand.New(rand.NewSource(seed)) + + // Setup keeper and context + keeper, ctx := testkeeper.FinalityKeeper(t, nil, nil, nil) + ctx = sdk.UnwrapSDKContext(ctx) + + // not activated yet + _, err := keeper.GetBTCStakingActivatedHeight(ctx) + require.Error(t, err) + + randomActivatedHeight := datagen.RandomInt(r, 100) + 1 + fp, err := datagen.GenRandomFinalityProvider(r) + require.NoError(t, err) + keeper.SetVotingPower(ctx, fp.BtcPk.MustMarshal(), randomActivatedHeight, uint64(10)) + + // now it's activated + resp, err := keeper.ActivatedHeight(ctx, &types.QueryActivatedHeightRequest{}) + require.NoError(t, err) + require.Equal(t, randomActivatedHeight, resp.Height) + }) +} + +func FuzzFinalityProviderPowerAtHeight(f *testing.F) { + datagen.AddRandomSeedsToFuzzer(f, 10) + f.Fuzz(func(t *testing.T, seed int64) { + r := rand.New(rand.NewSource(seed)) + ctrl := gomock.NewController(t) + defer ctrl.Finish() + + // Setup keeper and context + bk := types.NewMockBTCStakingKeeper(ctrl) + keeper, ctx := testkeeper.FinalityKeeper(t, bk, nil, nil) + + // random finality provider + fp, err := datagen.GenRandomFinalityProvider(r) + require.NoError(t, err) + // set random voting power at random height + randomHeight := datagen.RandomInt(r, 100) + 1 + randomPower := datagen.RandomInt(r, 100) + 1 + keeper.SetVotingPower(ctx, fp.BtcPk.MustMarshal(), randomHeight, randomPower) + + // happy case + bk.EXPECT().HasFinalityProvider(gomock.Any(), gomock.Any()).Return(true).Times(1) + req1 := &types.QueryFinalityProviderPowerAtHeightRequest{ + FpBtcPkHex: fp.BtcPk.MarshalHex(), + Height: randomHeight, + } + resp, err := keeper.FinalityProviderPowerAtHeight(ctx, req1) + require.NoError(t, err) + require.Equal(t, randomPower, resp.VotingPower) + + // case where the voting power store is not updated in + // the given height + bk.EXPECT().HasFinalityProvider(gomock.Any(), gomock.Any()).Return(true).Times(1) + requestHeight := randomHeight + datagen.RandomInt(r, 10) + 1 + req2 := &types.QueryFinalityProviderPowerAtHeightRequest{ + FpBtcPkHex: fp.BtcPk.MarshalHex(), + Height: requestHeight, + } + _, err = keeper.FinalityProviderPowerAtHeight(ctx, req2) + require.ErrorIs(t, err, types.ErrVotingPowerTableNotUpdated) + + // case where the given fp pk does not exist + bk.EXPECT().HasFinalityProvider(gomock.Any(), gomock.Any()).Return(false).Times(1) + randPk, err := datagen.GenRandomBIP340PubKey(r) + require.NoError(t, err) + req3 := &types.QueryFinalityProviderPowerAtHeightRequest{ + FpBtcPkHex: randPk.MarshalHex(), + Height: randomHeight, + } + _, err = keeper.FinalityProviderPowerAtHeight(ctx, req3) + require.ErrorIs(t, err, bstypes.ErrFpNotFound) + }) +} + +func FuzzFinalityProviderCurrentVotingPower(f *testing.F) { + datagen.AddRandomSeedsToFuzzer(f, 10) + f.Fuzz(func(t *testing.T, seed int64) { + r := rand.New(rand.NewSource(seed)) + ctrl := gomock.NewController(t) + defer ctrl.Finish() + + // Setup keeper and context + bk := types.NewMockBTCStakingKeeper(ctrl) + bk.EXPECT().HasFinalityProvider(gomock.Any(), gomock.Any()).Return(true).AnyTimes() + keeper, ctx := testkeeper.FinalityKeeper(t, bk, nil, nil) + + // random finality provider + fp, err := datagen.GenRandomFinalityProvider(r) + require.NoError(t, err) + // set random voting power at random height + randomHeight := datagen.RandomInt(r, 100) + 1 + ctx = datagen.WithCtxHeight(ctx, randomHeight) + randomPower := datagen.RandomInt(r, 100) + 1 + keeper.SetVotingPower(ctx, fp.BtcPk.MustMarshal(), randomHeight, randomPower) + + // assert voting power at current height + req := &types.QueryFinalityProviderCurrentPowerRequest{ + FpBtcPkHex: fp.BtcPk.MarshalHex(), + } + resp, err := keeper.FinalityProviderCurrentPower(ctx, req) + require.NoError(t, err) + require.Equal(t, randomHeight, resp.Height) + require.Equal(t, randomPower, resp.VotingPower) + + // if height increments but voting power hasn't recorded yet, then + // we need to return the height and voting power at the last height + ctx = datagen.WithCtxHeight(ctx, randomHeight+1) + resp, err = keeper.FinalityProviderCurrentPower(ctx, req) + require.NoError(t, err) + require.Equal(t, randomHeight, resp.Height) + require.Equal(t, randomPower, resp.VotingPower) + + // test the case when the finality provider has 0 voting power + ctx = datagen.WithCtxHeight(ctx, randomHeight+2) + keeper.SetVotingPower(ctx, fp.BtcPk.MustMarshal(), randomHeight+2, 0) + resp, err = keeper.FinalityProviderCurrentPower(ctx, req) + require.NoError(t, err) + require.Equal(t, randomHeight+2, resp.Height) + require.Equal(t, uint64(0), resp.VotingPower) + }) +} + +func FuzzActiveFinalityProvidersAtHeight(f *testing.F) { + datagen.AddRandomSeedsToFuzzer(f, 10) + f.Fuzz(func(t *testing.T, seed int64) { + r := rand.New(rand.NewSource(seed)) + ctrl := gomock.NewController(t) + defer ctrl.Finish() + + // mock BTC light client and BTC checkpoint modules + btclcKeeper := bstypes.NewMockBTCLightClientKeeper(ctrl) + btclcKeeper.EXPECT().GetTipInfo(gomock.Any()).Return(&btclctypes.BTCHeaderInfo{Height: 30}).AnyTimes() + btccKeeper := bstypes.NewMockBtcCheckpointKeeper(ctrl) + h := testutil.NewHelper(t, btclcKeeper, btccKeeper) + + h.GenAndApplyParams(r) + + // Generate a random batch of finality providers + var fps []*bstypes.FinalityProvider + numFpsWithVotingPower := datagen.RandomInt(r, 10) + 1 + numFps := numFpsWithVotingPower + datagen.RandomInt(r, 10) + for i := uint64(0); i < numFps; i++ { + _, _, fp := h.CreateFinalityProvider(r) + fps = append(fps, fp) + } + + // For numFpsWithVotingPower finality providers, generate a random number of BTC delegations + babylonHeight := datagen.RandomInt(r, 10) + 1 + fpsWithVotingPowerMap := make(map[string]*bstypes.FinalityProvider) + for i := uint64(0); i < numFpsWithVotingPower; i++ { + fpBTCPK := fps[i].BtcPk + fpsWithVotingPowerMap[fpBTCPK.MarshalHex()] = fps[i] + h.FinalityKeeper.SetVotingPower(h.Ctx, fpBTCPK.MustMarshal(), babylonHeight, 1) + } + + h.BeginBlocker() + + // Test nil request + resp, err := h.FinalityKeeper.ActiveFinalityProvidersAtHeight(h.Ctx, nil) + require.Nil(t, resp) + require.Error(t, err) + + // Generate a page request with a limit and a nil key + limit := datagen.RandomInt(r, int(numFpsWithVotingPower)) + 1 + pagination := constructRequestWithLimit(r, limit) + // Generate the initial query + req := types.QueryActiveFinalityProvidersAtHeightRequest{Height: babylonHeight, Pagination: pagination} + // Construct a mapping from the finality providers found to a boolean value + // Will be used later to evaluate whether all the finality providers were returned + fpsFound := make(map[string]bool, 0) + + for i := uint64(0); i < numFpsWithVotingPower; i += limit { + resp, err = h.FinalityKeeper.ActiveFinalityProvidersAtHeight(h.Ctx, &req) + h.NoError(err) + require.NotNil(t, resp) + + for _, fp := range resp.FinalityProviders { + // Check if the pk exists in the map + if _, ok := fpsWithVotingPowerMap[fp.BtcPkHex.MarshalHex()]; !ok { + t.Fatalf("rpc returned a finality provider that was not created") + } + fpsFound[fp.BtcPkHex.MarshalHex()] = true + } + + // Construct the next page request + pagination = constructRequestWithKeyAndLimit(r, resp.Pagination.NextKey, limit) + req = types.QueryActiveFinalityProvidersAtHeightRequest{Height: babylonHeight, Pagination: pagination} + } + + require.Equal(t, len(fpsFound), len(fpsWithVotingPowerMap), "some finality providers were missed, got %d while %d were expected", len(fpsFound), len(fpsWithVotingPowerMap)) + }) +} + func FuzzBlock(f *testing.F) { datagen.AddRandomSeedsToFuzzer(f, 10) f.Fuzz(func(t *testing.T, seed int64) { @@ -297,8 +497,8 @@ func FuzzQueryEvidence(f *testing.F) { require.Nil(t, evidenceResp) } else { require.NoError(t, err) - require.Equal(t, randomFirstSlashableEvidence, evidenceResp.Evidence) - require.True(t, evidenceResp.Evidence.IsSlashable()) + require.Equal(t, randomFirstSlashableEvidence, convertToEvidence(evidenceResp.Evidence)) + require.True(t, convertToEvidence(evidenceResp.Evidence).IsSlashable()) } }) } @@ -360,9 +560,10 @@ func FuzzListEvidences(f *testing.F) { require.NoError(t, err) require.LessOrEqual(t, len(resp.Evidences), int(limit)) // check if pagination takes effect require.EqualValues(t, resp.Pagination.Total, numEvidences) // ensure evidences before startHeight are not included - for _, actualEvidence := range resp.Evidences { - require.Equal(t, evidences[actualEvidence.FpBtcPk.MarshalHex()].CanonicalAppHash, actualEvidence.CanonicalAppHash) - require.Equal(t, evidences[actualEvidence.FpBtcPk.MarshalHex()].ForkAppHash, actualEvidence.ForkAppHash) + for _, actualEvidenceResponse := range resp.Evidences { + actualEvidence := convertToEvidence(actualEvidenceResponse) + expectedEvidence := evidences[actualEvidenceResponse.FpBtcPkHex] + require.Equal(t, expectedEvidence, actualEvidence) } }) } @@ -404,9 +605,9 @@ func FuzzSigningInfo(f *testing.F) { req := &types.QuerySigningInfoRequest{FpBtcPkHex: fpPk} resp, err := fKeeper.SigningInfo(ctx, req) require.NoError(t, err) - require.Equal(t, fpSigningInfos[fpPk].StartHeight, resp.FpSigningInfo.StartHeight) - require.Equal(t, fpSigningInfos[fpPk].MissedBlocksCounter, resp.FpSigningInfo.MissedBlocksCounter) - require.Equal(t, fpPk, resp.FpSigningInfo.FpBtcPk.MarshalHex()) + require.Equal(t, fpSigningInfos[fpPk].StartHeight, resp.SigningInfo.StartHeight) + require.Equal(t, fpSigningInfos[fpPk].MissedBlocksCounter, resp.SigningInfo.MissedBlocksCounter) + require.Equal(t, fpPk, resp.SigningInfo.FpBtcPkHex) } // perform a query for signing info of non-exist finality provider @@ -427,12 +628,46 @@ func FuzzSigningInfo(f *testing.F) { } resp, err := fKeeper.SigningInfos(ctx, req) require.NoError(t, err) - require.LessOrEqual(t, len(resp.FpSigningInfos), int(limit)) // check if pagination takes effect + require.LessOrEqual(t, len(resp.SigningInfos), int(limit)) // check if pagination takes effect require.EqualValues(t, resp.Pagination.Total, numSigningInfo) // ensure evidences before startHeight are not included - for _, si := range resp.FpSigningInfos { - require.Equal(t, fpSigningInfos[si.FpBtcPk.MarshalHex()].MissedBlocksCounter, si.MissedBlocksCounter) - require.Equal(t, fpSigningInfos[si.FpBtcPk.MarshalHex()].FpBtcPk.MarshalHex(), si.FpBtcPk.MarshalHex()) - require.Equal(t, fpSigningInfos[si.FpBtcPk.MarshalHex()].StartHeight, si.StartHeight) + for _, si := range resp.SigningInfos { + require.Equal(t, fpSigningInfos[si.FpBtcPkHex].MissedBlocksCounter, si.MissedBlocksCounter) + require.Equal(t, fpSigningInfos[si.FpBtcPkHex].StartHeight, si.StartHeight) } }) } + +func convertToEvidence(er *types.EvidenceResponse) *types.Evidence { + fpBtcPk, err := bbn.NewBIP340PubKeyFromHex(er.FpBtcPkHex) + if err != nil { + return nil + } + return &types.Evidence{ + FpBtcPk: fpBtcPk, + BlockHeight: er.BlockHeight, + PubRand: er.PubRand, + CanonicalAppHash: er.CanonicalAppHash, + ForkAppHash: er.ForkAppHash, + CanonicalFinalitySig: er.CanonicalFinalitySig, + ForkFinalitySig: er.ForkFinalitySig, + } +} + +// Constructors for PageRequest objects +func constructRequestWithKeyAndLimit(r *rand.Rand, key []byte, limit uint64) *query.PageRequest { + // If limit is 0, set one randomly + if limit == 0 { + limit = uint64(r.Int63() + 1) // Use Int63 instead of Uint64 to avoid overflows + } + return &query.PageRequest{ + Key: key, + Offset: 0, // only offset or key is set + Limit: limit, + CountTotal: false, // only used when offset is used + Reverse: false, + } +} + +func constructRequestWithLimit(r *rand.Rand, limit uint64) *query.PageRequest { + return constructRequestWithKeyAndLimit(r, nil, limit) +} diff --git a/x/finality/keeper/hooks.go b/x/finality/keeper/hooks.go deleted file mode 100644 index ba2140001..000000000 --- a/x/finality/keeper/hooks.go +++ /dev/null @@ -1,41 +0,0 @@ -package keeper - -import ( - "context" - "errors" - - "cosmossdk.io/collections" - sdk "github.com/cosmos/cosmos-sdk/types" - - bbntypes "github.com/babylonlabs-io/babylon/types" - "github.com/babylonlabs-io/babylon/x/finality/types" -) - -var _ types.BtcStakingHooks = Hooks{} - -// Hooks wrapper struct for finality keeper -type Hooks struct { - k Keeper -} - -// Return the BTC staking hooks -func (k Keeper) Hooks() Hooks { - return Hooks{k} -} - -// AfterFinalityProviderActivated updates the signing info start height or create a new signing info -func (h Hooks) AfterFinalityProviderActivated(ctx context.Context, fpPk *bbntypes.BIP340PubKey) error { - signingInfo, err := h.k.FinalityProviderSigningTracker.Get(ctx, fpPk.MustMarshal()) - sdkCtx := sdk.UnwrapSDKContext(ctx) - if err == nil { - signingInfo.StartHeight = sdkCtx.BlockHeight() - } else if errors.Is(err, collections.ErrNotFound) { - signingInfo = types.NewFinalityProviderSigningInfo( - fpPk, - sdkCtx.BlockHeight(), - 0, - ) - } - - return h.k.FinalityProviderSigningTracker.Set(ctx, fpPk.MustMarshal(), signingInfo) -} diff --git a/x/finality/keeper/keeper.go b/x/finality/keeper/keeper.go index d569896f9..1a9851104 100644 --- a/x/finality/keeper/keeper.go +++ b/x/finality/keeper/keeper.go @@ -25,8 +25,6 @@ type ( // should be the x/gov module account. authority string - hooks types.FinalityHooks - // FinalityProviderSigningTracker key: BIP340PubKey bytes | value: FinalityProviderSigningInfo FinalityProviderSigningTracker collections.Map[[]byte, types.FinalityProviderSigningInfo] // FinalityProviderMissedBlockBitmap key: BIP340PubKey bytes | value: byte key for a finality provider's missed block bitmap chunk @@ -68,15 +66,11 @@ func NewKeeper( } } -// SetHooks sets the finality hooks -func (k *Keeper) SetHooks(sh types.FinalityHooks) *Keeper { - if k.hooks != nil { - panic("cannot set finality hooks twice") - } - - k.hooks = sh +func (k Keeper) BeginBlocker(ctx context.Context) error { + // update voting power distribution + k.UpdatePowerDist(ctx) - return k + return nil } func (k Keeper) Logger(ctx sdk.Context) log.Logger { @@ -95,3 +89,14 @@ func (k Keeper) GetCurrentEpoch(ctx context.Context) uint64 { return currentEpoch.EpochNumber } + +// IsFinalityActive returns true if the finality is activated and ready +// to start handling liveness, tally and index blocks. +func (k Keeper) IsFinalityActive(ctx context.Context) (activated bool) { + if uint64(sdk.UnwrapSDKContext(ctx).HeaderInfo().Height) < k.GetParams(ctx).FinalityActivationHeight { + return false + } + + _, err := k.GetBTCStakingActivatedHeight(ctx) + return err == nil +} diff --git a/x/finality/keeper/liveness.go b/x/finality/keeper/liveness.go index 314216999..ec2cc3a4a 100644 --- a/x/finality/keeper/liveness.go +++ b/x/finality/keeper/liveness.go @@ -14,7 +14,7 @@ import ( // including jailing sluggish finality providers and applying punishment (TBD) func (k Keeper) HandleLiveness(ctx context.Context, height int64) { // get all the active finality providers for the height - fpSet := k.BTCStakingKeeper.GetVotingPowerTable(ctx, uint64(height)) + fpSet := k.GetVotingPowerTable(ctx, uint64(height)) // get all the voters for the height voterBTCPKs := k.GetVoters(ctx, uint64(height)) @@ -184,7 +184,7 @@ func (k Keeper) updateSigningInfo( } func (k Keeper) jailSluggishFinalityProvider(ctx context.Context, fpBtcPk *types.BIP340PubKey) error { - err := k.hooks.AfterSluggishFinalityProviderDetected(ctx, fpBtcPk) + err := k.BTCStakingKeeper.JailFinalityProvider(ctx, fpBtcPk.MustMarshal()) if err != nil { return err } diff --git a/x/finality/keeper/liveness_test.go b/x/finality/keeper/liveness_test.go index 5eb1bda51..3b043d741 100644 --- a/x/finality/keeper/liveness_test.go +++ b/x/finality/keeper/liveness_test.go @@ -24,17 +24,14 @@ func FuzzHandleLiveness(f *testing.F) { defer ctrl.Finish() bsKeeper := types.NewMockBTCStakingKeeper(ctrl) - bsKeeper.EXPECT().GetParams(gomock.Any()).Return(bstypes.Params{MaxActiveFinalityProviders: 100}).AnyTimes() + bsKeeper.EXPECT().JailFinalityProvider(gomock.Any(), gomock.Any()).Return(nil).AnyTimes() + iKeeper := types.NewMockIncentiveKeeper(ctrl) cKeeper := types.NewMockCheckpointingKeeper(ctrl) fKeeper, ctx := keepertest.FinalityKeeper(t, bsKeeper, iKeeper, cKeeper) blockTime := time.Now() ctx = ctx.WithHeaderInfo(header.Info{Time: blockTime}) - mockedHooks := types.NewMockFinalityHooks(ctrl) - mockedHooks.EXPECT().AfterSluggishFinalityProviderDetected(gomock.Any(), gomock.Any()).Return(nil).AnyTimes() - fKeeper.SetHooks(mockedHooks) - params := fKeeper.GetParams(ctx) fpPk, err := datagen.GenRandomBIP340PubKey(r) require.NoError(t, err) diff --git a/x/finality/keeper/msg_server.go b/x/finality/keeper/msg_server.go index ed4f5610b..e7c25f2a8 100644 --- a/x/finality/keeper/msg_server.go +++ b/x/finality/keeper/msg_server.go @@ -49,12 +49,17 @@ func (ms msgServer) UpdateParams(goCtx context.Context, req *types.MsgUpdatePara func (ms msgServer) AddFinalitySig(goCtx context.Context, req *types.MsgAddFinalitySig) (*types.MsgAddFinalitySigResponse, error) { defer telemetry.ModuleMeasureSince(types.ModuleName, time.Now(), types.MetricsKeyAddFinalitySig) - if req.FpBtcPk == nil { - return nil, types.ErrInvalidFinalitySig.Wrap("empty finality provider BTC PK") + if err := req.ValidateBasic(); err != nil { + return nil, err } - fpPK := req.FpBtcPk ctx := sdk.UnwrapSDKContext(goCtx) + activationHeight, errMod := ms.validateActivationHeight(ctx, req.BlockHeight) + if errMod != nil { + return nil, errMod.Wrapf("finality block height: %d is lower than activation height %d", req.BlockHeight, activationHeight) + } + + fpPK := req.FpBtcPk // ensure the finality provider exists fp, err := ms.BTCStakingKeeper.GetFinalityProvider(ctx, req.FpBtcPk.MustMarshal()) @@ -79,27 +84,24 @@ func (ms msgServer) AddFinalitySig(goCtx context.Context, req *types.MsgAddFinal // corrupt a new finality provider and equivocate a historical block over and over again, making a previous block // unfinalisable forever if fp.IsSlashed() { - return nil, bstypes.ErrFpAlreadySlashed.Wrapf(fmt.Sprintf("finality provider public key: %s", fpPK.MarshalHex())) + return nil, bstypes.ErrFpAlreadySlashed.Wrapf("finality provider public key: %s", fpPK.MarshalHex()) } if fp.IsJailed() { - return nil, bstypes.ErrFpAlreadyJailed.Wrapf(fmt.Sprintf("finality provider public key: %s", fpPK.MarshalHex())) + return nil, bstypes.ErrFpAlreadyJailed.Wrapf("finality provider public key: %s", fpPK.MarshalHex()) } // ensure the finality provider has voting power at this height - if ms.BTCStakingKeeper.GetVotingPower(ctx, fpPK.MustMarshal(), req.BlockHeight) == 0 { + if ms.GetVotingPower(ctx, fpPK.MustMarshal(), req.BlockHeight) == 0 { return nil, types.ErrInvalidFinalitySig.Wrapf("the finality provider %s does not have voting power at height %d", fpPK.MarshalHex(), req.BlockHeight) } - // ensure the finality provider has not cast the same vote yet - if req.FinalitySig == nil { - return nil, types.ErrInvalidFinalitySig.Wrap("empty finality signature") - } existingSig, err := ms.GetSig(ctx, req.BlockHeight, fpPK) if err == nil && existingSig.Equals(req.FinalitySig) { ms.Logger(ctx).Debug("Received duplicated finality vote", "block height", req.BlockHeight, "finality provider", req.FpBtcPk) - // exactly same vote alreay exists, return success to the provider - return &types.MsgAddFinalitySigResponse{}, nil + // exactly same vote already exists, return error + // this is to secure the tx refunding against duplicated messages + return nil, types.ErrDuplicatedFinalitySig } // find the timestamped public randomness commitment for this height from this finality provider @@ -177,6 +179,11 @@ func (ms msgServer) AddFinalitySig(goCtx context.Context, req *types.MsgAddFinal ms.slashFinalityProvider(ctx, req.FpBtcPk, evidence) } + // at this point, the finality signature is 1) valid, 2) over a canonical block, + // and 3) not duplicated. + // Thus, we can safely consider this message as refundable + ms.IncentiveKeeper.IndexRefundableMsg(ctx, req) + return &types.MsgAddFinalitySigResponse{}, nil } @@ -185,6 +192,13 @@ func (ms msgServer) CommitPubRandList(goCtx context.Context, req *types.MsgCommi defer telemetry.ModuleMeasureSince(types.ModuleName, time.Now(), types.MetricsKeyCommitPubRandList) ctx := sdk.UnwrapSDKContext(goCtx) + activationHeight, errMod := ms.validateActivationHeight(ctx, req.StartHeight) + if errMod != nil { + return nil, types.ErrFinalityNotActivated.Wrapf( + "public rand commit start block height: %d is lower than activation height %d", + req.StartHeight, activationHeight, + ) + } // ensure the request contains enough number of public randomness minPubRand := ms.GetParams(ctx).MinPubRand @@ -271,8 +285,7 @@ func (ms msgServer) UnjailFinalityProvider(ctx context.Context, req *types.MsgUn return nil, err } if !jailingPeriodPassed { - return nil, types.ErrJailingPeriodNotPassed.Wrapf( - fmt.Sprintf("current block time: %v, required %v", curBlockTime, info.JailedUntil)) + return nil, types.ErrJailingPeriodNotPassed.Wrapf("current block time: %v, required %v", curBlockTime, info.JailedUntil) } err = ms.BTCStakingKeeper.UnjailFinalityProvider(ctx, fpPk.MustMarshal()) @@ -305,3 +318,18 @@ func (k Keeper) slashFinalityProvider(ctx context.Context, fpBtcPk *bbn.BIP340Pu panic(fmt.Errorf("failed to emit EventSlashedFinalityProvider event: %w", err)) } } + +// validateActivationHeight returns error if the height received is lower than the finality +// activation block height +func (ms msgServer) validateActivationHeight(ctx sdk.Context, height uint64) (uint64, *errorsmod.Error) { + // TODO: remove it after Phase-2 launch in a future coordinated upgrade + activationHeight := ms.GetParams(ctx).FinalityActivationHeight + if height < activationHeight { + ms.Logger(ctx).With( + "height", height, + "activationHeight", activationHeight, + ).Info("BTC finality is not activated yet") + return activationHeight, types.ErrFinalityNotActivated + } + return activationHeight, nil +} diff --git a/x/finality/keeper/msg_server_test.go b/x/finality/keeper/msg_server_test.go index 0e72b20a1..b3a4cad27 100644 --- a/x/finality/keeper/msg_server_test.go +++ b/x/finality/keeper/msg_server_test.go @@ -104,7 +104,7 @@ func FuzzCommitPubRandList(f *testing.F) { } func FuzzAddFinalitySig(f *testing.F) { - datagen.AddRandomSeedsToFuzzer(f, 100) + datagen.AddRandomSeedsToFuzzer(f, 10) f.Fuzz(func(t *testing.T, seed int64) { r := rand.New(rand.NewSource(seed)) @@ -113,7 +113,9 @@ func FuzzAddFinalitySig(f *testing.F) { bsKeeper := types.NewMockBTCStakingKeeper(ctrl) cKeeper := types.NewMockCheckpointingKeeper(ctrl) - fKeeper, ctx := keepertest.FinalityKeeper(t, bsKeeper, nil, cKeeper) + iKeeper := types.NewMockIncentiveKeeper(ctrl) + iKeeper.EXPECT().IndexRefundableMsg(gomock.Any(), gomock.Any()).AnyTimes() + fKeeper, ctx := keepertest.FinalityKeeper(t, bsKeeper, iKeeper, cKeeper) ms := keeper.NewMsgServerImpl(*fKeeper) // create and register a random finality provider @@ -148,7 +150,7 @@ func FuzzAddFinalitySig(f *testing.F) { // Case 0: fail if the committed epoch is not finalized lastFinalizedEpoch := datagen.RandomInt(r, int(committedEpochNum)) o1 := cKeeper.EXPECT().GetLastFinalizedEpoch(gomock.Any()).Return(lastFinalizedEpoch).Times(1) - bsKeeper.EXPECT().GetVotingPower(gomock.Any(), gomock.Eq(fpBTCPKBytes), gomock.Eq(blockHeight)).Return(uint64(1)).Times(1) + fKeeper.SetVotingPower(ctx, fpBTCPKBytes, blockHeight, 1) bsKeeper.EXPECT().GetFinalityProvider(gomock.Any(), gomock.Eq(fpBTCPKBytes)).Return(fp, nil).Times(1) _, err = ms.AddFinalitySig(ctx, msg) require.ErrorIs(t, err, types.ErrPubRandCommitNotBTCTimestamped) @@ -158,17 +160,17 @@ func FuzzAddFinalitySig(f *testing.F) { cKeeper.EXPECT().GetLastFinalizedEpoch(gomock.Any()).Return(lastFinalizedEpoch).After(o1).AnyTimes() // Case 1: fail if the finality provider does not have voting power - bsKeeper.EXPECT().GetVotingPower(gomock.Any(), gomock.Eq(fpBTCPKBytes), gomock.Eq(blockHeight)).Return(uint64(0)).Times(1) + fKeeper.SetVotingPower(ctx, fpBTCPKBytes, blockHeight, 0) bsKeeper.EXPECT().GetFinalityProvider(gomock.Any(), gomock.Eq(fpBTCPKBytes)).Return(fp, nil).Times(1) _, err = ms.AddFinalitySig(ctx, msg) require.Error(t, err) // mock voting power - bsKeeper.EXPECT().GetVotingPower(gomock.Any(), gomock.Eq(fpBTCPKBytes), gomock.Eq(blockHeight)).Return(uint64(1)).AnyTimes() + fKeeper.SetVotingPower(ctx, fpBTCPKBytes, blockHeight, 1) // Case 2: fail if the finality provider has not committed public randomness at that height blockHeight2 := startHeight + numPubRand + 1 - bsKeeper.EXPECT().GetVotingPower(gomock.Any(), gomock.Eq(fpBTCPKBytes), gomock.Eq(blockHeight2)).Return(uint64(1)).Times(1) + fKeeper.SetVotingPower(ctx, fpBTCPKBytes, blockHeight, 1) bsKeeper.EXPECT().GetFinalityProvider(gomock.Any(), gomock.Eq(fpBTCPKBytes)).Return(fp, nil).Times(1) msg.BlockHeight = blockHeight2 _, err = ms.AddFinalitySig(ctx, msg) @@ -191,9 +193,8 @@ func FuzzAddFinalitySig(f *testing.F) { // Case 4: In case of duplicate vote return success bsKeeper.EXPECT().GetFinalityProvider(gomock.Any(), gomock.Eq(fpBTCPKBytes)).Return(fp, nil).Times(1) - resp, err := ms.AddFinalitySig(ctx, msg) - require.NoError(t, err) - require.NotNil(t, resp) + _, err = ms.AddFinalitySig(ctx, msg) + require.Error(t, err) // Case 5: the finality provider is slashed if it votes for a fork blockAppHash2 := datagen.GenRandomByteArray(r, 32) @@ -312,7 +313,9 @@ func TestVoteForConflictingHashShouldRetrieveEvidenceAndSlash(t *testing.T) { defer ctrl.Finish() bsKeeper := types.NewMockBTCStakingKeeper(ctrl) cKeeper := types.NewMockCheckpointingKeeper(ctrl) - fKeeper, ctx := keepertest.FinalityKeeper(t, bsKeeper, nil, cKeeper) + iKeeper := types.NewMockIncentiveKeeper(ctrl) + iKeeper.EXPECT().IndexRefundableMsg(gomock.Any(), gomock.Any()).AnyTimes() + fKeeper, ctx := keepertest.FinalityKeeper(t, bsKeeper, iKeeper, cKeeper) ms := keeper.NewMsgServerImpl(*fKeeper) // create and register a random finality provider btcSK, btcPK, err := datagen.GenRandomBTCKeyPair(r) @@ -352,9 +355,7 @@ func TestVoteForConflictingHashShouldRetrieveEvidenceAndSlash(t *testing.T) { ctx = ctx.WithHeaderInfo(header.Info{Height: int64(blockHeight), AppHash: forkHash}) msg1, err := datagen.NewMsgAddFinalitySig(signer, btcSK, startHeight, blockHeight, randListInfo, forkHash) require.NoError(t, err) - bsKeeper.EXPECT().GetVotingPower(gomock.Any(), - gomock.Eq(fpBTCPKBytes), - gomock.Eq(blockHeight)).Return(uint64(1)).AnyTimes() + fKeeper.SetVotingPower(ctx, fpBTCPKBytes, blockHeight, 1) bsKeeper.EXPECT().GetFinalityProvider(gomock.Any(), gomock.Eq(fpBTCPKBytes)).Return(fp, nil).Times(1) _, err = ms.AddFinalitySig(ctx, msg1) @@ -363,9 +364,7 @@ func TestVoteForConflictingHashShouldRetrieveEvidenceAndSlash(t *testing.T) { msg, err := datagen.NewMsgAddFinalitySig(signer, btcSK, startHeight, blockHeight, randListInfo, canonicalHash) ctx = ctx.WithHeaderInfo(header.Info{Height: int64(blockHeight), AppHash: canonicalHash}) require.NoError(t, err) - bsKeeper.EXPECT().GetVotingPower(gomock.Any(), - gomock.Eq(fpBTCPKBytes), - gomock.Eq(blockHeight)).Return(uint64(1)).AnyTimes() + fKeeper.SetVotingPower(ctx, fpBTCPKBytes, blockHeight, 1) bsKeeper.EXPECT().GetFinalityProvider(gomock.Any(), gomock.Eq(fpBTCPKBytes)).Return(fp, nil).Times(1) bsKeeper.EXPECT().SlashFinalityProvider(gomock.Any(), @@ -379,3 +378,112 @@ func TestVoteForConflictingHashShouldRetrieveEvidenceAndSlash(t *testing.T) { require.Equal(t, msg.FinalitySig.MustMarshal(), sig.MustMarshal()) } + +func TestDoNotPanicOnNilProof(t *testing.T) { + r := rand.New(rand.NewSource(time.Now().Unix())) + ctrl := gomock.NewController(t) + defer ctrl.Finish() + + bsKeeper := types.NewMockBTCStakingKeeper(ctrl) + cKeeper := types.NewMockCheckpointingKeeper(ctrl) + iKeeper := types.NewMockIncentiveKeeper(ctrl) + iKeeper.EXPECT().IndexRefundableMsg(gomock.Any(), gomock.Any()).AnyTimes() + fKeeper, ctx := keepertest.FinalityKeeper(t, bsKeeper, iKeeper, cKeeper) + ms := keeper.NewMsgServerImpl(*fKeeper) + + // create and register a random finality provider + btcSK, btcPK, err := datagen.GenRandomBTCKeyPair(r) + require.NoError(t, err) + fp, err := datagen.GenRandomFinalityProviderWithBTCSK(r, btcSK, "") + require.NoError(t, err) + fpBTCPK := bbn.NewBIP340PubKeyFromBTCPK(btcPK) + fpBTCPKBytes := fpBTCPK.MustMarshal() + require.NoError(t, err) + bsKeeper.EXPECT().HasFinalityProvider(gomock.Any(), gomock.Eq(fpBTCPKBytes)).Return(true).AnyTimes() + + // set committed epoch num + committedEpochNum := datagen.GenRandomEpochNum(r) + 1 + cKeeper.EXPECT().GetEpoch(gomock.Any()).Return(&epochingtypes.Epoch{EpochNumber: committedEpochNum}).AnyTimes() + + // commit some public randomness + startHeight := uint64(0) + numPubRand := uint64(200) + randListInfo, msgCommitPubRandList, err := datagen.GenRandomMsgCommitPubRandList(r, btcSK, startHeight, numPubRand) + require.NoError(t, err) + _, err = ms.CommitPubRandList(ctx, msgCommitPubRandList) + require.NoError(t, err) + + // generate a vote + blockHeight := startHeight + uint64(1) + blockAppHash := datagen.GenRandomByteArray(r, 32) + signer := datagen.GenRandomAccount().Address + msg, err := datagen.NewMsgAddFinalitySig( + signer, + btcSK, + startHeight, + blockHeight, + randListInfo, + blockAppHash, + ) + require.NoError(t, err) + + // Not panic on empty proof + msg.Proof = nil + // Case 3: successful if the finality provider has voting power and has not casted this vote yet + // index this block first + ctx = ctx.WithHeaderInfo(header.Info{Height: int64(blockHeight), AppHash: blockAppHash}) + fKeeper.IndexBlock(ctx) + bsKeeper.EXPECT().GetFinalityProvider(gomock.Any(), gomock.Eq(fpBTCPKBytes)).Return(fp, nil).AnyTimes() + // mock voting power + fKeeper.SetVotingPower(ctx, fpBTCPKBytes, blockHeight, 1) + // set the committed epoch finalized for the rest of the cases + lastFinalizedEpoch := datagen.GenRandomEpochNum(r) + committedEpochNum + cKeeper.EXPECT().GetLastFinalizedEpoch(gomock.Any()).Return(lastFinalizedEpoch).AnyTimes() + + // add vote and it should work + _, err = ms.AddFinalitySig(ctx, msg) + require.Error(t, err) +} + +func TestVerifyActivationHeight(t *testing.T) { + r := rand.New(rand.NewSource(time.Now().Unix())) + fKeeper, ctx := keepertest.FinalityKeeper(t, nil, nil, nil) + ms := keeper.NewMsgServerImpl(*fKeeper) + err := fKeeper.SetParams(ctx, types.DefaultParams()) + require.NoError(t, err) + activationHeight := fKeeper.GetParams(ctx).FinalityActivationHeight + + // checks pub rand commit + btcSK, _, err := datagen.GenRandomBTCKeyPair(r) + require.NoError(t, err) + startHeight := activationHeight - 1 + numPubRand := uint64(200) + randListInfo, msgCommitPubRandList, err := datagen.GenRandomMsgCommitPubRandList(r, btcSK, startHeight, numPubRand) + require.NoError(t, err) + + _, err = ms.CommitPubRandList(ctx, msgCommitPubRandList) + require.EqualError(t, err, types.ErrFinalityNotActivated.Wrapf( + "public rand commit start block height: %d is lower than activation height %d", + startHeight, activationHeight, + ).Error()) + + // check finality vote + blockHeight := activationHeight - 1 + blockAppHash := datagen.GenRandomByteArray(r, 32) + signer := datagen.GenRandomAccount().Address + msgFinality, err := datagen.NewMsgAddFinalitySig( + signer, + btcSK, + startHeight, + blockHeight, + randListInfo, + blockAppHash, + ) + require.NoError(t, err) + + _, err = ms.AddFinalitySig(ctx, msgFinality) + require.EqualError(t, err, types.ErrFinalityNotActivated.Wrapf( + "finality block height: %d is lower than activation height %d", + blockHeight, activationHeight, + ).Error()) +} diff --git a/x/finality/keeper/power_dist_change.go b/x/finality/keeper/power_dist_change.go new file mode 100644 index 000000000..8873851d6 --- /dev/null +++ b/x/finality/keeper/power_dist_change.go @@ -0,0 +1,360 @@ +package keeper + +import ( + "context" + "errors" + "fmt" + "sort" + + "cosmossdk.io/collections" + "cosmossdk.io/store/prefix" + "github.com/btcsuite/btcd/btcutil" + "github.com/cosmos/cosmos-sdk/runtime" + sdk "github.com/cosmos/cosmos-sdk/types" + + bbn "github.com/babylonlabs-io/babylon/types" + "github.com/babylonlabs-io/babylon/x/btcstaking/types" + ftypes "github.com/babylonlabs-io/babylon/x/finality/types" +) + +/* power distribution update */ + +// UpdatePowerDist updates the voting power table and distribution cache. +// This is triggered upon each `BeginBlock` +func (k Keeper) UpdatePowerDist(ctx context.Context) { + height := uint64(sdk.UnwrapSDKContext(ctx).HeaderInfo().Height) + btcTipHeight := k.BTCStakingKeeper.GetCurrentBTCHeight(ctx) + + // get the power dist cache in the last height + dc := k.GetVotingPowerDistCache(ctx, height-1) + if dc == nil { + // no BTC staker at the prior height + dc = ftypes.NewVotingPowerDistCache() + } + + // get all power distribution update events during the previous tip + // and the current tip + lastBTCTipHeight := k.BTCStakingKeeper.GetBTCHeightAtBabylonHeight(ctx, height-1) + events := k.BTCStakingKeeper.GetAllPowerDistUpdateEvents(ctx, lastBTCTipHeight, btcTipHeight) + + // clear all events that have been consumed in this function + defer func() { + for i := lastBTCTipHeight; i <= btcTipHeight; i++ { + k.BTCStakingKeeper.ClearPowerDistUpdateEvents(ctx, i) + } + }() + + // reconcile old voting power distribution cache and new events + // to construct the new distribution + newDc := k.ProcessAllPowerDistUpdateEvents(ctx, dc, events) + + // record voting power and cache for this height + k.recordVotingPowerAndCache(ctx, newDc) + // emit events for finality providers with state updates + k.handleFPStateUpdates(ctx, dc, newDc) + // record metrics + k.recordMetrics(newDc) +} + +// recordVotingPowerAndCache assigns voting power to each active finality provider +// with the following consideration: +// 1. the fp must have timestamped pub rand +// 2. the fp must in the top x ranked by the voting power (x is given by maxActiveFps) +func (k Keeper) recordVotingPowerAndCache(ctx context.Context, newDc *ftypes.VotingPowerDistCache) { + if newDc == nil { + panic("the voting power distribution cache cannot be nil") + } + + babylonTipHeight := uint64(sdk.UnwrapSDKContext(ctx).HeaderInfo().Height) + + // label fps with whether it has timestamped pub rand so that these fps + // will not be assigned voting power + for _, fpDistInfo := range newDc.FinalityProviders { + // TODO calling HasTimestampedPubRand potentially iterates + // all the pub rand committed by the fpDistInfo, which might slow down + // the process, need optimization + fpDistInfo.IsTimestamped = k.HasTimestampedPubRand(ctx, fpDistInfo.BtcPk, babylonTipHeight) + } + + // apply the finality provider voting power dist info to the new cache + // after which the cache would have active fps that are top N fps ranked + // by voting power with timestamped pub rand + maxActiveFps := k.GetParams(ctx).MaxActiveFinalityProviders + newDc.ApplyActiveFinalityProviders(maxActiveFps) + + // set voting power table for each active finality providers at this height + for i := uint32(0); i < newDc.NumActiveFps; i++ { + fp := newDc.FinalityProviders[i] + k.SetVotingPower(ctx, fp.BtcPk.MustMarshal(), babylonTipHeight, fp.TotalBondedSat) + } + + // set the voting power distribution cache of the current height + k.SetVotingPowerDistCache(ctx, babylonTipHeight, newDc) +} + +// handleFPStateUpdates emits events and triggers hooks for finality providers with state updates +func (k Keeper) handleFPStateUpdates(ctx context.Context, prevDc, newDc *ftypes.VotingPowerDistCache) { + sdkCtx := sdk.UnwrapSDKContext(ctx) + + newlyActiveFPs := newDc.FindNewActiveFinalityProviders(prevDc) + for _, fp := range newlyActiveFPs { + if err := k.handleActivatedFinalityProvider(ctx, fp.BtcPk); err != nil { + panic(fmt.Errorf("failed to execute after finality provider %s activated", fp.BtcPk.MarshalHex())) + } + + statusChangeEvent := types.NewFinalityProviderStatusChangeEvent(fp.BtcPk, types.FinalityProviderStatus_FINALITY_PROVIDER_STATUS_ACTIVE) + if err := sdkCtx.EventManager().EmitTypedEvent(statusChangeEvent); err != nil { + panic(fmt.Errorf( + "failed to emit FinalityProviderStatusChangeEvent with status %s: %w", + types.FinalityProviderStatus_FINALITY_PROVIDER_STATUS_ACTIVE.String(), err)) + } + + k.Logger(sdkCtx).Info("a new finality provider becomes active", "pk", fp.BtcPk.MarshalHex()) + } + + newlyInactiveFPs := newDc.FindNewInactiveFinalityProviders(prevDc) + for _, fp := range newlyInactiveFPs { + statusChangeEvent := types.NewFinalityProviderStatusChangeEvent(fp.BtcPk, types.FinalityProviderStatus_FINALITY_PROVIDER_STATUS_INACTIVE) + if err := sdkCtx.EventManager().EmitTypedEvent(statusChangeEvent); err != nil { + panic(fmt.Errorf( + "failed to emit FinalityProviderStatusChangeEvent with status %s: %w", + types.FinalityProviderStatus_FINALITY_PROVIDER_STATUS_INACTIVE.String(), err)) + } + + k.Logger(sdkCtx).Info("a new finality provider becomes inactive", "pk", fp.BtcPk.MarshalHex()) + } +} + +// handleActivatedFinalityProvider updates the signing info start height or create a new signing info +func (k Keeper) handleActivatedFinalityProvider(ctx context.Context, fpPk *bbn.BIP340PubKey) error { + signingInfo, err := k.FinalityProviderSigningTracker.Get(ctx, fpPk.MustMarshal()) + sdkCtx := sdk.UnwrapSDKContext(ctx) + if err == nil { + signingInfo.StartHeight = sdkCtx.BlockHeight() + } else if errors.Is(err, collections.ErrNotFound) { + signingInfo = ftypes.NewFinalityProviderSigningInfo( + fpPk, + sdkCtx.BlockHeight(), + 0, + ) + } + + return k.FinalityProviderSigningTracker.Set(ctx, fpPk.MustMarshal(), signingInfo) +} + +func (k Keeper) recordMetrics(dc *ftypes.VotingPowerDistCache) { + // number of active FPs + numActiveFPs := int(dc.NumActiveFps) + types.RecordActiveFinalityProviders(numActiveFPs) + // number of inactive FPs + numInactiveFPs := len(dc.FinalityProviders) - numActiveFPs + types.RecordInactiveFinalityProviders(numInactiveFPs) + // staked Satoshi + stakedSats := btcutil.Amount(0) + for _, fp := range dc.FinalityProviders { + stakedSats += btcutil.Amount(fp.TotalBondedSat) + } + numStakedBTCs := stakedSats.ToBTC() + types.RecordMetricsKeyStakedBitcoins(float32(numStakedBTCs)) + // TODO: record number of BTC delegations under different status +} + +// ProcessAllPowerDistUpdateEvents processes all events that affect +// voting power distribution and returns a new distribution cache. +// The following events will affect the voting power distribution: +// - newly active BTC delegations +// - newly unbonded BTC delegations +// - slashed finality providers +// - newly jailed finality providers +// - newly unjailed finality providers +func (k Keeper) ProcessAllPowerDistUpdateEvents( + ctx context.Context, + dc *ftypes.VotingPowerDistCache, + events []*types.EventPowerDistUpdate, +) *ftypes.VotingPowerDistCache { + // a map where key is finality provider's BTC PK hex and value is a list + // of BTC delegations that newly become active under this provider + activeBTCDels := map[string][]*types.BTCDelegation{} + // a map where key is unbonded BTC delegation's staking tx hash + unbondedBTCDels := map[string]struct{}{} + // a map where key is slashed finality providers' BTC PK + slashedFPs := map[string]struct{}{} + // a map where key is jailed finality providers' BTC PK + jailedFPs := map[string]struct{}{} + // a map where key is unjailed finality providers' BTC PK + unjailedFPs := map[string]struct{}{} + + /* + filter and classify all events into new/expired BTC delegations and jailed/slashed FPs + */ + sdkCtx := sdk.UnwrapSDKContext(ctx) + for _, event := range events { + switch typedEvent := event.Ev.(type) { + case *types.EventPowerDistUpdate_BtcDelStateUpdate: + delEvent := typedEvent.BtcDelStateUpdate + btcDel, err := k.BTCStakingKeeper.GetBTCDelegation(ctx, delEvent.StakingTxHash) + if err != nil { + panic(err) // only programming error + } + if delEvent.NewState == types.BTCDelegationStatus_ACTIVE { + // newly active BTC delegation + // add the BTC delegation to each restaked finality provider + for _, fpBTCPK := range btcDel.FpBtcPkList { + fpBTCPKHex := fpBTCPK.MarshalHex() + activeBTCDels[fpBTCPKHex] = append(activeBTCDels[fpBTCPKHex], btcDel) + } + } else if delEvent.NewState == types.BTCDelegationStatus_UNBONDED { + // emit expired event if it is not early unbonding + if !btcDel.IsUnbondedEarly() { + types.EmitExpiredDelegationEvent(sdkCtx, delEvent.StakingTxHash) + } + // add the unbonded BTC delegation to the map + unbondedBTCDels[delEvent.StakingTxHash] = struct{}{} + } + case *types.EventPowerDistUpdate_SlashedFp: + // record slashed fps + types.EmitSlashedFPEvent(sdkCtx, typedEvent.SlashedFp.Pk) + slashedFPs[typedEvent.SlashedFp.Pk.MarshalHex()] = struct{}{} + case *types.EventPowerDistUpdate_JailedFp: + // record jailed fps + types.EmitJailedFPEvent(sdkCtx, typedEvent.JailedFp.Pk) + jailedFPs[typedEvent.JailedFp.Pk.MarshalHex()] = struct{}{} + case *types.EventPowerDistUpdate_UnjailedFp: + // record unjailed fps + unjailedFPs[typedEvent.UnjailedFp.Pk.MarshalHex()] = struct{}{} + } + } + + /* + At this point, there is voting power update. + Then, construct a voting power dist cache by reconciling the previous + cache and all the new events. + */ + // TODO: the algorithm needs to iterate over all BTC delegations so remains + // sub-optimal. Ideally we only need to iterate over all events above rather + // than the entire cache. This is made difficulty since BTC delegations are + // not keyed in the cache. Need to find a way to optimise this. + newDc := ftypes.NewVotingPowerDistCache() + + // iterate over all finality providers and apply all events + for i := range dc.FinalityProviders { + // create a copy of the finality provider + fp := *dc.FinalityProviders[i] + fp.TotalBondedSat = 0 + fp.BtcDels = []*ftypes.BTCDelDistInfo{} + + fpBTCPKHex := fp.BtcPk.MarshalHex() + + // if this finality provider is slashed, continue to avoid + // assigning delegation to it + if _, ok := slashedFPs[fpBTCPKHex]; ok { + fp.IsSlashed = true + continue + } + + // set IsJailed to be true if the fp is jailed + // Note that jailed fp can still accept delegations + // but won't be assigned with voting power + if _, ok := jailedFPs[fpBTCPKHex]; ok { + fp.IsJailed = true + } + + // set IsJailed to be false if the fp is unjailed + if _, ok := unjailedFPs[fpBTCPKHex]; ok { + fp.IsJailed = false + } + + // add all BTC delegations that are not unbonded to the new finality provider + for j := range dc.FinalityProviders[i].BtcDels { + btcDel := *dc.FinalityProviders[i].BtcDels[j] + if _, ok := unbondedBTCDels[btcDel.StakingTxHash]; !ok { + fp.AddBTCDelDistInfo(&btcDel) + } + } + + // process all new BTC delegations under this finality provider + if fpActiveBTCDels, ok := activeBTCDels[fpBTCPKHex]; ok { + // handle new BTC delegations for this finality provider + for _, d := range fpActiveBTCDels { + fp.AddBTCDel(d) + } + // remove the finality provider entry in activeBTCDels map, so that + // after the for loop the rest entries in activeBTCDels belongs to new + // finality providers with new BTC delegations + delete(activeBTCDels, fpBTCPKHex) + } + + // add this finality provider to the new cache if it has voting power + if fp.TotalBondedSat > 0 { + newDc.AddFinalityProviderDistInfo(&fp) + } + } + + /* + process new BTC delegations under new finality providers in activeBTCDels + */ + // sort new finality providers in activeBTCDels to ensure determinism + fpBTCPKHexList := make([]string, 0, len(activeBTCDels)) + for fpBTCPKHex := range activeBTCDels { + fpBTCPKHexList = append(fpBTCPKHexList, fpBTCPKHex) + } + sort.SliceStable(fpBTCPKHexList, func(i, j int) bool { + return fpBTCPKHexList[i] < fpBTCPKHexList[j] + }) + // for each new finality provider, apply the new BTC delegations to the new dist cache + for _, fpBTCPKHex := range fpBTCPKHexList { + // get the finality provider and initialise its dist info + fpBTCPK, err := bbn.NewBIP340PubKeyFromHex(fpBTCPKHex) + if err != nil { + panic(err) // only programming error + } + newFP, err := k.BTCStakingKeeper.GetFinalityProvider(ctx, *fpBTCPK) + if err != nil { + panic(err) // only programming error + } + fpDistInfo := ftypes.NewFinalityProviderDistInfo(newFP) + + // add each BTC delegation + fpActiveBTCDels := activeBTCDels[fpBTCPKHex] + for _, d := range fpActiveBTCDels { + fpDistInfo.AddBTCDel(d) + } + + // add this finality provider to the new cache if it has voting power + if fpDistInfo.TotalBondedSat > 0 { + newDc.AddFinalityProviderDistInfo(fpDistInfo) + } + } + + return newDc +} + +func (k Keeper) SetVotingPowerDistCache(ctx context.Context, height uint64, dc *ftypes.VotingPowerDistCache) { + store := k.votingPowerDistCacheStore(ctx) + store.Set(sdk.Uint64ToBigEndian(height), k.cdc.MustMarshal(dc)) +} + +func (k Keeper) GetVotingPowerDistCache(ctx context.Context, height uint64) *ftypes.VotingPowerDistCache { + store := k.votingPowerDistCacheStore(ctx) + rdcBytes := store.Get(sdk.Uint64ToBigEndian(height)) + if len(rdcBytes) == 0 { + return nil + } + var dc ftypes.VotingPowerDistCache + k.cdc.MustUnmarshal(rdcBytes, &dc) + return &dc +} + +func (k Keeper) RemoveVotingPowerDistCache(ctx context.Context, height uint64) { + store := k.votingPowerDistCacheStore(ctx) + store.Delete(sdk.Uint64ToBigEndian(height)) +} + +// votingPowerDistCacheStore returns the KVStore of the voting power distribution cache +// prefix: VotingPowerDistCacheKey +// key: Babylon block height +// value: VotingPowerDistCache +func (k Keeper) votingPowerDistCacheStore(ctx context.Context) prefix.Store { + storeAdapter := runtime.KVStoreAdapter(k.storeService.OpenKVStore(ctx)) + return prefix.NewStore(storeAdapter, ftypes.VotingPowerDistCacheKey) +} diff --git a/x/finality/keeper/power_dist_change_test.go b/x/finality/keeper/power_dist_change_test.go new file mode 100644 index 000000000..06431fdf4 --- /dev/null +++ b/x/finality/keeper/power_dist_change_test.go @@ -0,0 +1,741 @@ +package keeper_test + +import ( + "math/rand" + "testing" + "time" + + "github.com/btcsuite/btcd/btcec/v2" + "github.com/golang/mock/gomock" + "github.com/stretchr/testify/require" + + testutil "github.com/babylonlabs-io/babylon/testutil/btcstaking-helper" + "github.com/babylonlabs-io/babylon/testutil/datagen" + btclctypes "github.com/babylonlabs-io/babylon/x/btclightclient/types" + "github.com/babylonlabs-io/babylon/x/btcstaking/types" + ftypes "github.com/babylonlabs-io/babylon/x/finality/types" +) + +func FuzzProcessAllPowerDistUpdateEvents_Determinism(f *testing.F) { + datagen.AddRandomSeedsToFuzzer(f, 10) + + f.Fuzz(func(t *testing.T, seed int64) { + r := rand.New(rand.NewSource(seed)) + ctrl := gomock.NewController(t) + defer ctrl.Finish() + + // mock BTC light client and BTC checkpoint modules + btclcKeeper := types.NewMockBTCLightClientKeeper(ctrl) + btccKeeper := types.NewMockBtcCheckpointKeeper(ctrl) + h := testutil.NewHelper(t, btclcKeeper, btccKeeper) + + // set all parameters + h.GenAndApplyParams(r) + changeAddress, err := datagen.GenRandomBTCAddress(r, h.Net) + require.NoError(t, err) + + // generate and insert a number of new finality providers + fpPKs := []*btcec.PublicKey{} + for i := 0; i < 5; i++ { + _, fpPK, _ := h.CreateFinalityProvider(r) + fpPKs = append(fpPKs, fpPK) + } + + // empty dist cache + dc := ftypes.NewVotingPowerDistCache() + + stakingValue := int64(2 * 10e8) + + // generate many new BTC delegations under each finality provider, and their corresponding events + events := []*types.EventPowerDistUpdate{} + for _, fpPK := range fpPKs { + for i := 0; i < 5; i++ { + delSK, _, err := datagen.GenRandomBTCKeyPair(r) + h.NoError(err) + _, _, del, _, _, _, err := h.CreateDelegation( + r, + delSK, + []*btcec.PublicKey{fpPK}, + changeAddress.EncodeAddress(), + stakingValue, + 1000, + 0, + 0, + false, + false, + ) + h.NoError(err) + event := types.NewEventPowerDistUpdateWithBTCDel(&types.EventBTCDelegationStateUpdate{ + StakingTxHash: del.MustGetStakingTxHash().String(), + NewState: types.BTCDelegationStatus_ACTIVE, + }) + events = append(events, event) + } + } + + newDc := h.FinalityKeeper.ProcessAllPowerDistUpdateEvents(h.Ctx, dc, events) + for i := 0; i < 10; i++ { + newDc2 := h.FinalityKeeper.ProcessAllPowerDistUpdateEvents(h.Ctx, dc, events) + require.Equal(t, newDc, newDc2) + } + }) +} + +func FuzzSlashFinalityProviderEvent(f *testing.F) { + datagen.AddRandomSeedsToFuzzer(f, 10) + + f.Fuzz(func(t *testing.T, seed int64) { + r := rand.New(rand.NewSource(seed)) + ctrl := gomock.NewController(t) + defer ctrl.Finish() + + // mock BTC light client and BTC checkpoint modules + btclcKeeper := types.NewMockBTCLightClientKeeper(ctrl) + btccKeeper := types.NewMockBtcCheckpointKeeper(ctrl) + h := testutil.NewHelper(t, btclcKeeper, btccKeeper) + + // set all parameters + covenantSKs, _ := h.GenAndApplyParams(r) + changeAddress, err := datagen.GenRandomBTCAddress(r, h.Net) + require.NoError(t, err) + + // generate and insert new finality provider + fpSK, fpPK, fp := h.CreateFinalityProvider(r) + h.CommitPubRandList(r, fpSK, fp, 1, 100, true) + + /* + insert new BTC delegation and give it covenant quorum + ensure that it has voting power + */ + stakingValue := int64(2 * 10e8) + delSK, _, err := datagen.GenRandomBTCKeyPair(r) + h.NoError(err) + stakingTxHash, msgCreateBTCDel, actualDel, btcHeaderInfo, inclusionProof, _, err := h.CreateDelegation( + r, + delSK, + []*btcec.PublicKey{fpPK}, + changeAddress.EncodeAddress(), + stakingValue, + 1000, + 0, + 0, + true, + false, + ) + h.NoError(err) + // give it a quorum number of covenant signatures + h.CreateCovenantSigs(r, covenantSKs, msgCreateBTCDel, actualDel) + // activate the BTC delegation + h.AddInclusionProof(stakingTxHash, btcHeaderInfo, inclusionProof) + + // execute BeginBlock + btcTip := btclcKeeper.GetTipInfo(h.Ctx) + babylonHeight := datagen.RandomInt(r, 10) + 1 + h.SetCtxHeight(babylonHeight) + h.BTCLightClientKeeper.EXPECT().GetTipInfo(gomock.Eq(h.Ctx)).Return(btcTip).AnyTimes() + h.BeginBlocker() + // ensure the finality provider has voting power at this height + require.Equal(t, uint64(stakingValue), h.FinalityKeeper.GetVotingPower(h.Ctx, *fp.BtcPk, babylonHeight)) + + /* + Slash the finality provider and execute BeginBlock + Then, ensure the finality provider does not have voting power anymore + */ + err = h.BTCStakingKeeper.SlashFinalityProvider(h.Ctx, fp.BtcPk.MustMarshal()) + h.NoError(err) + + err = h.BTCStakingKeeper.SlashFinalityProvider(h.Ctx, fp.BtcPk.MustMarshal()) + require.ErrorIs(t, err, types.ErrFpAlreadySlashed) + + err = h.BTCStakingKeeper.JailFinalityProvider(h.Ctx, fp.BtcPk.MustMarshal()) + require.ErrorIs(t, err, types.ErrFpAlreadySlashed) + + // at this point, there should be only 1 event that the finality provider is slashed + btcTipHeight := btclcKeeper.GetTipInfo(h.Ctx).Height + events := h.BTCStakingKeeper.GetAllPowerDistUpdateEvents(h.Ctx, btcTipHeight, btcTipHeight) + require.Len(t, events, 1) + slashedFPEvent := events[0].GetSlashedFp() + require.NotNil(t, slashedFPEvent) + require.Equal(t, fp.BtcPk.MustMarshal(), slashedFPEvent.Pk.MustMarshal()) + + // execute BeginBlock + babylonHeight += 1 + h.SetCtxHeight(babylonHeight) + h.BTCLightClientKeeper.EXPECT().GetTipInfo(gomock.Eq(h.Ctx)).Return(btcTip).AnyTimes() + h.BeginBlocker() + // ensure the finality provider does not have voting power anymore + require.Zero(t, h.FinalityKeeper.GetVotingPower(h.Ctx, *fp.BtcPk, babylonHeight)) + }) +} + +func FuzzJailFinalityProviderEvents(f *testing.F) { + datagen.AddRandomSeedsToFuzzer(f, 10) + + f.Fuzz(func(t *testing.T, seed int64) { + r := rand.New(rand.NewSource(seed)) + ctrl := gomock.NewController(t) + defer ctrl.Finish() + + // mock BTC light client and BTC checkpoint modules + btclcKeeper := types.NewMockBTCLightClientKeeper(ctrl) + btccKeeper := types.NewMockBtcCheckpointKeeper(ctrl) + h := testutil.NewHelper(t, btclcKeeper, btccKeeper) + + // set all parameters + covenantSKs, _ := h.GenAndApplyParams(r) + changeAddress, err := datagen.GenRandomBTCAddress(r, h.Net) + require.NoError(t, err) + + // generate and insert new finality provider + fpSK, fpPK, fp := h.CreateFinalityProvider(r) + h.CommitPubRandList(r, fpSK, fp, 1, 100, true) + + /* + insert new BTC delegation and give it covenant quorum + ensure that it has voting power + */ + stakingValue := int64(2 * 10e8) + delSK, _, err := datagen.GenRandomBTCKeyPair(r) + h.NoError(err) + stakingTxHash, msgCreateBTCDel, actualDel, btcHeaderInfo, inclusionProof, _, err := h.CreateDelegation( + r, + delSK, + []*btcec.PublicKey{fpPK}, + changeAddress.EncodeAddress(), + stakingValue, + 1000, + 0, + 0, + true, + false, + ) + h.NoError(err) + // give it a quorum number of covenant signatures + h.CreateCovenantSigs(r, covenantSKs, msgCreateBTCDel, actualDel) + // activate the BTC delegation + h.AddInclusionProof(stakingTxHash, btcHeaderInfo, inclusionProof) + + // execute BeginBlock + btcTip := btclcKeeper.GetTipInfo(h.Ctx) + babylonHeight := datagen.RandomInt(r, 10) + 1 + h.SetCtxHeight(babylonHeight) + h.BTCLightClientKeeper.EXPECT().GetTipInfo(gomock.Eq(h.Ctx)).Return(btcTip).AnyTimes() + h.BeginBlocker() + // ensure the finality provider is not jailed and has voting power at this height + + fpBeforeJailing, err := h.BTCStakingKeeper.GetFinalityProvider(h.Ctx, fp.BtcPk.MustMarshal()) + h.NoError(err) + require.False(t, fpBeforeJailing.IsJailed()) + require.Equal(t, uint64(stakingValue), h.FinalityKeeper.GetVotingPower(h.Ctx, *fp.BtcPk, babylonHeight)) + + /* + Jail the finality provider and execute BeginBlock + Then, ensure the finality provider does not have voting power anymore + */ + err = h.BTCStakingKeeper.JailFinalityProvider(h.Ctx, fp.BtcPk.MustMarshal()) + h.NoError(err) + + err = h.BTCStakingKeeper.JailFinalityProvider(h.Ctx, fp.BtcPk.MustMarshal()) + require.ErrorIs(t, err, types.ErrFpAlreadyJailed) + + // ensure the jailed label is set + fpAfterJailing, err := h.BTCStakingKeeper.GetFinalityProvider(h.Ctx, fp.BtcPk.MustMarshal()) + h.NoError(err) + require.True(t, fpAfterJailing.IsJailed()) + + // at this point, there should be only 1 event that the finality provider is jailed + btcTipHeight := btclcKeeper.GetTipInfo(h.Ctx).Height + events := h.BTCStakingKeeper.GetAllPowerDistUpdateEvents(h.Ctx, btcTipHeight, btcTipHeight) + require.Len(t, events, 1) + jailedFPEvent := events[0].GetJailedFp() + require.NotNil(t, jailedFPEvent) + require.Equal(t, fp.BtcPk.MustMarshal(), jailedFPEvent.Pk.MustMarshal()) + + // execute BeginBlock + babylonHeight += 1 + h.SetCtxHeight(babylonHeight) + h.BTCLightClientKeeper.EXPECT().GetTipInfo(gomock.Eq(h.Ctx)).Return(btcTip).AnyTimes() + h.BeginBlocker() + // ensure the finality provider does not have voting power anymore + require.Zero(t, h.FinalityKeeper.GetVotingPower(h.Ctx, *fp.BtcPk, babylonHeight)) + + /* + insert another active BTC delegation and check whether the jailed + fp has voting power + */ + stakingValue = int64(2 * 10e8) + h.NoError(err) + delSK2, _, err := datagen.GenRandomBTCKeyPair(r) + h.NoError(err) + stakingTxHash2, msgCreateBTCDel, actualDel, btcHeaderInfo, inclusionProof, _, err := h.CreateDelegation( + r, + delSK2, + []*btcec.PublicKey{fpPK}, + changeAddress.EncodeAddress(), + stakingValue, + 1000, + 0, + 0, + true, + false, + ) + h.NoError(err) + // give it a quorum number of covenant signatures + h.CreateCovenantSigs(r, covenantSKs, msgCreateBTCDel, actualDel) + // activate the BTC delegation + h.AddInclusionProof(stakingTxHash2, btcHeaderInfo, inclusionProof) + + // execute BeginBlock + btcTip = btclcKeeper.GetTipInfo(h.Ctx) + babylonHeight += 1 + h.SetCtxHeight(babylonHeight) + h.BTCLightClientKeeper.EXPECT().GetTipInfo(gomock.Eq(h.Ctx)).Return(btcTip).AnyTimes() + h.BeginBlocker() + // ensure the finality provider is not jailed and has voting power at this height + + fpAfterJailing, err = h.BTCStakingKeeper.GetFinalityProvider(h.Ctx, fp.BtcPk.MustMarshal()) + h.NoError(err) + require.True(t, fpAfterJailing.IsJailed()) + require.Equal(t, uint64(0), h.FinalityKeeper.GetVotingPower(h.Ctx, *fp.BtcPk, babylonHeight)) + }) +} + +func FuzzUnjailFinalityProviderEvents(f *testing.F) { + datagen.AddRandomSeedsToFuzzer(f, 10) + + f.Fuzz(func(t *testing.T, seed int64) { + r := rand.New(rand.NewSource(seed)) + ctrl := gomock.NewController(t) + defer ctrl.Finish() + + // mock BTC light client and BTC checkpoint modules + btclcKeeper := types.NewMockBTCLightClientKeeper(ctrl) + btccKeeper := types.NewMockBtcCheckpointKeeper(ctrl) + h := testutil.NewHelper(t, btclcKeeper, btccKeeper) + + // set all parameters + covenantSKs, _ := h.GenAndApplyParams(r) + changeAddress, err := datagen.GenRandomBTCAddress(r, h.Net) + require.NoError(t, err) + + // generate and insert new finality provider + fpSK, fpPK, fp := h.CreateFinalityProvider(r) + h.CommitPubRandList(r, fpSK, fp, 1, 100, true) + + /* + insert new BTC delegation and give it covenant quorum + ensure that it has voting power + */ + stakingValue := int64(2 * 10e8) + delSK, _, err := datagen.GenRandomBTCKeyPair(r) + h.NoError(err) + stakingTxHash, msgCreateBTCDel, actualDel, btcHeaderInfo, inclusionProof, _, err := h.CreateDelegation( + r, + delSK, + []*btcec.PublicKey{fpPK}, + changeAddress.EncodeAddress(), + stakingValue, + 1000, + 0, + 0, + true, + false, + ) + h.NoError(err) + // give it a quorum number of covenant signatures + h.CreateCovenantSigs(r, covenantSKs, msgCreateBTCDel, actualDel) + // activate the BTC delegation + h.AddInclusionProof(stakingTxHash, btcHeaderInfo, inclusionProof) + + // execute BeginBlock + btcTip := btclcKeeper.GetTipInfo(h.Ctx) + babylonHeight := datagen.RandomInt(r, 10) + 1 + h.SetCtxHeight(babylonHeight) + h.BTCLightClientKeeper.EXPECT().GetTipInfo(gomock.Eq(h.Ctx)).Return(btcTip).AnyTimes() + h.BeginBlocker() + + // ensure the finality provider is not jailed and has voting power + fpBeforeJailing, err := h.BTCStakingKeeper.GetFinalityProvider(h.Ctx, fp.BtcPk.MustMarshal()) + h.NoError(err) + require.False(t, fpBeforeJailing.IsJailed()) + require.Equal(t, uint64(stakingValue), h.FinalityKeeper.GetVotingPower(h.Ctx, *fp.BtcPk, babylonHeight)) + + // try unjail fp that is not jailed, should expect error + err = h.BTCStakingKeeper.UnjailFinalityProvider(h.Ctx, fp.BtcPk.MustMarshal()) + require.ErrorIs(t, err, types.ErrFpNotJailed) + + /* + Jail the finality provider and execute BeginBlock + Then, ensure the finality provider does not have voting power anymore + */ + err = h.BTCStakingKeeper.JailFinalityProvider(h.Ctx, fp.BtcPk.MustMarshal()) + h.NoError(err) + + // ensure the jailed label is set + fpAfterJailing, err := h.BTCStakingKeeper.GetFinalityProvider(h.Ctx, fp.BtcPk.MustMarshal()) + h.NoError(err) + require.True(t, fpAfterJailing.IsJailed()) + + // execute BeginBlock + babylonHeight += 1 + h.SetCtxHeight(babylonHeight) + h.BTCLightClientKeeper.EXPECT().GetTipInfo(gomock.Eq(h.Ctx)).Return(btcTip).AnyTimes() + h.BeginBlocker() + // ensure the finality provider does not have voting power anymore + require.Zero(t, h.FinalityKeeper.GetVotingPower(h.Ctx, *fp.BtcPk, babylonHeight)) + + /* + Unjail the finality provider and execute BeginBlock + Ensure that the finality provider regains voting power + */ + err = h.BTCStakingKeeper.UnjailFinalityProvider(h.Ctx, fp.BtcPk.MustMarshal()) + h.NoError(err) + + // ensure the jailed label is reverted + fpAfterUnjailing, err := h.BTCStakingKeeper.GetFinalityProvider(h.Ctx, fp.BtcPk.MustMarshal()) + h.NoError(err) + require.False(t, fpAfterUnjailing.IsJailed()) + + // execute BeginBlock + babylonHeight += 1 + h.SetCtxHeight(babylonHeight) + h.BTCLightClientKeeper.EXPECT().GetTipInfo(gomock.Eq(h.Ctx)).Return(btcTip).AnyTimes() + h.BeginBlocker() + // ensure the finality provider does not have voting power anymore + require.Equal(t, uint64(stakingValue), h.FinalityKeeper.GetVotingPower(h.Ctx, *fp.BtcPk, babylonHeight)) + }) +} + +func FuzzBTCDelegationEvents_NoPreApproval(f *testing.F) { + datagen.AddRandomSeedsToFuzzer(f, 10) + + f.Fuzz(func(t *testing.T, seed int64) { + r := rand.New(rand.NewSource(seed)) + ctrl := gomock.NewController(t) + defer ctrl.Finish() + + // mock BTC light client and BTC checkpoint modules + btclcKeeper := types.NewMockBTCLightClientKeeper(ctrl) + btccKeeper := types.NewMockBtcCheckpointKeeper(ctrl) + h := testutil.NewHelper(t, btclcKeeper, btccKeeper) + + // set all parameters + covenantSKs, _ := h.GenAndApplyParams(r) + changeAddress, err := datagen.GenRandomBTCAddress(r, h.Net) + require.NoError(t, err) + + // generate and insert new finality provider + fpSK, fpPK, fp := h.CreateFinalityProvider(r) + + // generate and insert new BTC delegation + stakingValue := int64(2 * 10e8) + delSK, _, err := datagen.GenRandomBTCKeyPair(r) + h.NoError(err) + stakingTxHash, msgCreateBTCDel, actualDel, _, _, _, err := h.CreateDelegation( + r, + delSK, + []*btcec.PublicKey{fpPK}, + changeAddress.EncodeAddress(), + stakingValue, + 1000, + 0, + 0, + false, + false, + ) + h.NoError(err) + + /* + at this point, there should be 1 event that BTC delegation + will become expired at end height - w + */ + // there exists no event at the current BTC tip + btcTip := btclcKeeper.GetTipInfo(h.Ctx) + events := h.BTCStakingKeeper.GetAllPowerDistUpdateEvents(h.Ctx, btcTip.Height, btcTip.Height) + require.Len(t, events, 0) + + btckptParams := btccKeeper.GetParams(h.Ctx) + stakingParams := h.BTCStakingKeeper.GetParamsWithVersion(h.Ctx).Params + + minUnbondingTime := types.MinimumUnbondingTime(&stakingParams, &btckptParams) + + // the BTC delegation will be unbonded at end height - max(w, min_unbonding_time) + unbondedHeight := actualDel.EndHeight - minUnbondingTime + events = h.BTCStakingKeeper.GetAllPowerDistUpdateEvents(h.Ctx, unbondedHeight, unbondedHeight) + require.Len(t, events, 1) + btcDelStateUpdate := events[0].GetBtcDelStateUpdate() + require.NotNil(t, btcDelStateUpdate) + require.Equal(t, stakingTxHash, btcDelStateUpdate.StakingTxHash) + require.Equal(t, types.BTCDelegationStatus_UNBONDED, btcDelStateUpdate.NewState) + + // ensure this finality provider does not have voting power at the current height + babylonHeight := datagen.RandomInt(r, 10) + 1 + h.SetCtxHeight(babylonHeight) + h.BTCLightClientKeeper.EXPECT().GetTipInfo(gomock.Eq(h.Ctx)).Return(btcTip).AnyTimes() + h.BeginBlocker() + require.Zero(t, h.FinalityKeeper.GetVotingPower(h.Ctx, *fp.BtcPk, babylonHeight)) + + /* + Generate a quorum number of covenant signatures + Then, there should be an event that the BTC delegation becomes + active at the current height + */ + h.CreateCovenantSigs(r, covenantSKs, msgCreateBTCDel, actualDel) + + events = h.BTCStakingKeeper.GetAllPowerDistUpdateEvents(h.Ctx, btcTip.Height, btcTip.Height) + require.Len(t, events, 1) + btcDelStateUpdate = events[0].GetBtcDelStateUpdate() + require.NotNil(t, btcDelStateUpdate) + require.Equal(t, stakingTxHash, btcDelStateUpdate.StakingTxHash) + require.Equal(t, types.BTCDelegationStatus_ACTIVE, btcDelStateUpdate.NewState) + + // ensure this finality provider does not have voting power at the current height + // due to no timestamped randomness + babylonHeight += 1 + h.SetCtxHeight(babylonHeight) + h.BTCLightClientKeeper.EXPECT().GetTipInfo(gomock.Eq(h.Ctx)).Return(btcTip).AnyTimes() + h.BeginBlocker() + require.Zero(t, h.FinalityKeeper.GetVotingPower(h.Ctx, *fp.BtcPk, babylonHeight)) + + // ensure this finality provider has voting power at the current height after having timestamped pub rand + babylonHeight += 1 + h.SetCtxHeight(babylonHeight) + h.BTCLightClientKeeper.EXPECT().GetTipInfo(gomock.Eq(h.Ctx)).Return(btcTip).AnyTimes() + h.CommitPubRandList(r, fpSK, fp, 1, 100, true) + h.BeginBlocker() + require.Equal(t, uint64(stakingValue), h.FinalityKeeper.GetVotingPower(h.Ctx, *fp.BtcPk, babylonHeight)) + + // ensure event queue is cleared at BTC tip height + events = h.BTCStakingKeeper.GetAllPowerDistUpdateEvents(h.Ctx, btcTip.Height, btcTip.Height) + require.Len(t, events, 0) + + /* + BTC height reaches end height - w, such that the BTC delegation becomes expired + ensure the finality provider does not have voting power anymore + */ + babylonHeight += 1 + h.SetCtxHeight(babylonHeight) + h.BTCLightClientKeeper.EXPECT().GetTipInfo(gomock.Eq(h.Ctx)).Return(&btclctypes.BTCHeaderInfo{Height: unbondedHeight}).AnyTimes() + h.BeginBlocker() + require.Zero(t, h.FinalityKeeper.GetVotingPower(h.Ctx, *fp.BtcPk, babylonHeight)) + + // ensure the unbonded event is processed and cleared + events = h.BTCStakingKeeper.GetAllPowerDistUpdateEvents(h.Ctx, unbondedHeight, unbondedHeight) + require.Len(t, events, 0) + }) +} + +func FuzzBTCDelegationEvents_WithPreApproval(f *testing.F) { + datagen.AddRandomSeedsToFuzzer(f, 10) + + f.Fuzz(func(t *testing.T, seed int64) { + r := rand.New(rand.NewSource(seed)) + ctrl := gomock.NewController(t) + defer ctrl.Finish() + + // mock BTC light client and BTC checkpoint modules + btclcKeeper := types.NewMockBTCLightClientKeeper(ctrl) + btccKeeper := types.NewMockBtcCheckpointKeeper(ctrl) + h := testutil.NewHelper(t, btclcKeeper, btccKeeper) + + // set all parameters + covenantSKs, _ := h.GenAndApplyParams(r) + changeAddress, err := datagen.GenRandomBTCAddress(r, h.Net) + require.NoError(t, err) + + // generate and insert new finality provider + fpSK, fpPK, fp := h.CreateFinalityProvider(r) + + // generate and insert new BTC delegation + stakingValue := int64(2 * 10e8) + delSK, _, err := datagen.GenRandomBTCKeyPair(r) + h.NoError(err) + stakingTxHash, msgCreateBTCDel, actualDel, btcHeaderInfo, inclusionProof, _, err := h.CreateDelegation( + r, + delSK, + []*btcec.PublicKey{fpPK}, + changeAddress.EncodeAddress(), + stakingValue, + 1000, + 0, + 0, + true, + false, + ) + h.NoError(err) + + btcTip := btclctypes.BTCHeaderInfo{Height: 30} // TODO: parameterise + + // ensure this finality provider does not have voting power at the current height + babylonHeight := datagen.RandomInt(r, 10) + 1 + h.SetCtxHeight(babylonHeight) + h.BTCLightClientKeeper.EXPECT().GetTipInfo(gomock.Eq(h.Ctx)).Return(&btcTip).AnyTimes() + h.BeginBlocker() + require.Zero(t, h.FinalityKeeper.GetVotingPower(h.Ctx, *fp.BtcPk, babylonHeight)) + + /* + Generate a quorum number of covenant signatures + */ + h.CreateCovenantSigs(r, covenantSKs, msgCreateBTCDel, actualDel) + // no event will be emitted to the event bus upon an verified BTC delegation + // since it does not affect voting power distribution + events := h.BTCStakingKeeper.GetAllPowerDistUpdateEvents(h.Ctx, btcTip.Height, btcTip.Height) + require.Len(t, events, 0) + + // ensure this finality provider does not have voting power at the current height + babylonHeight += 1 + h.SetCtxHeight(babylonHeight) + h.BTCLightClientKeeper.EXPECT().GetTipInfo(gomock.Eq(h.Ctx)).Return(&btcTip).AnyTimes() + h.BeginBlocker() + require.Zero(t, h.FinalityKeeper.GetVotingPower(h.Ctx, *fp.BtcPk, babylonHeight)) + + /* + submit the inclusion proof to activate the BTC delegation + at this point, there should be + - 1 event that BTC delegation becomes active at the current height + - 1 event that BTC delegation will become expired at end height - w + */ + h.AddInclusionProof(stakingTxHash, btcHeaderInfo, inclusionProof) + activatedDel, err := h.BTCStakingKeeper.GetBTCDelegation(h.Ctx, stakingTxHash) + h.NoError(err) + // there exists 1 event that the BTC delegation becomes active + events = h.BTCStakingKeeper.GetAllPowerDistUpdateEvents(h.Ctx, btcTip.Height, btcTip.Height) + require.Len(t, events, 1) + btcDelStateUpdate := events[0].GetBtcDelStateUpdate() + require.NotNil(t, btcDelStateUpdate) + require.Equal(t, stakingTxHash, btcDelStateUpdate.StakingTxHash) + require.Equal(t, types.BTCDelegationStatus_ACTIVE, btcDelStateUpdate.NewState) + + btckptParams := btccKeeper.GetParams(h.Ctx) + stakingParams := h.BTCStakingKeeper.GetParamsWithVersion(h.Ctx).Params + + minUnbondingTime := types.MinimumUnbondingTime(&stakingParams, &btckptParams) + + // the BTC delegation will be unbonded at end height - max(w, min_unbonding_time) + unbondedHeight := activatedDel.EndHeight - minUnbondingTime + events = h.BTCStakingKeeper.GetAllPowerDistUpdateEvents(h.Ctx, unbondedHeight, unbondedHeight) + require.Len(t, events, 1) + btcDelStateUpdate = events[0].GetBtcDelStateUpdate() + require.NotNil(t, btcDelStateUpdate) + require.Equal(t, stakingTxHash, btcDelStateUpdate.StakingTxHash) + require.Equal(t, types.BTCDelegationStatus_UNBONDED, btcDelStateUpdate.NewState) + + // ensure this finality provider does not have voting power at the current height + // due to no timestamped randomness + babylonHeight += 1 + h.SetCtxHeight(babylonHeight) + h.BTCLightClientKeeper.EXPECT().GetTipInfo(gomock.Eq(h.Ctx)).Return(&btcTip).AnyTimes() + h.BeginBlocker() + require.Zero(t, h.FinalityKeeper.GetVotingPower(h.Ctx, *fp.BtcPk, babylonHeight)) + + // ensure this finality provider has voting power at the current height after having timestamped pub rand + babylonHeight += 1 + h.SetCtxHeight(babylonHeight) + h.BTCLightClientKeeper.EXPECT().GetTipInfo(gomock.Eq(h.Ctx)).Return(&btcTip).AnyTimes() + h.CommitPubRandList(r, fpSK, fp, 1, 100, true) + h.BeginBlocker() + require.Equal(t, uint64(stakingValue), h.FinalityKeeper.GetVotingPower(h.Ctx, *fp.BtcPk, babylonHeight)) + + // ensure event queue is cleared at BTC tip height + events = h.BTCStakingKeeper.GetAllPowerDistUpdateEvents(h.Ctx, btcTip.Height, btcTip.Height) + require.Len(t, events, 0) + + /* + BTC height reaches end height - w, such that the BTC delegation becomes expired + ensure the finality provider does not have voting power anymore + */ + babylonHeight += 1 + h.SetCtxHeight(babylonHeight) + h.BTCLightClientKeeper.EXPECT().GetTipInfo(gomock.Eq(h.Ctx)).Return(&btclctypes.BTCHeaderInfo{Height: unbondedHeight}).AnyTimes() + h.BeginBlocker() + require.Zero(t, h.FinalityKeeper.GetVotingPower(h.Ctx, *fp.BtcPk, babylonHeight)) + + // ensure the unbonded event is processed and cleared + events = h.BTCStakingKeeper.GetAllPowerDistUpdateEvents(h.Ctx, unbondedHeight, unbondedHeight) + require.Len(t, events, 0) + }) +} + +func TestDoNotGenerateDuplicateEventsAfterHavingCovenantQuorum(t *testing.T) { + r := rand.New(rand.NewSource(time.Now().UnixNano())) + ctrl := gomock.NewController(t) + defer ctrl.Finish() + + // mock BTC light client and BTC checkpoint modules + btclcKeeper := types.NewMockBTCLightClientKeeper(ctrl) + btccKeeper := types.NewMockBtcCheckpointKeeper(ctrl) + h := testutil.NewHelper(t, btclcKeeper, btccKeeper) + + // set all parameters + covenantSKs, _ := h.GenAndApplyParams(r) + changeAddress, err := datagen.GenRandomBTCAddress(r, h.Net) + require.NoError(t, err) + + // generate and insert new finality provider + _, fpPK, fp := h.CreateFinalityProvider(r) + + // generate and insert new BTC delegation + stakingValue := int64(2 * 10e8) + delSK, _, err := datagen.GenRandomBTCKeyPair(r) + h.NoError(err) + expectedStakingTxHash, msgCreateBTCDel, actualDel, _, _, _, err := h.CreateDelegation( + r, + delSK, + []*btcec.PublicKey{fpPK}, + changeAddress.EncodeAddress(), + stakingValue, + 1000, + 0, + 0, + false, + false, + ) + h.NoError(err) + /* + at this point, there should be 1 event that BTC delegation + will become expired at end height - w + */ + // there exists no event at the current BTC tip + btcTip := btclcKeeper.GetTipInfo(h.Ctx) + events := h.BTCStakingKeeper.GetAllPowerDistUpdateEvents(h.Ctx, btcTip.Height, btcTip.Height) + require.Len(t, events, 0) + + btckptParams := btccKeeper.GetParams(h.Ctx) + stakingParams := h.BTCStakingKeeper.GetParamsWithVersion(h.Ctx).Params + + minUnbondingTime := types.MinimumUnbondingTime(&stakingParams, &btckptParams) + + // the BTC delegation will be unbonded at end height - max(w, min_unbonding_time) + unbondedHeight := actualDel.EndHeight - minUnbondingTime + events = h.BTCStakingKeeper.GetAllPowerDistUpdateEvents(h.Ctx, unbondedHeight, unbondedHeight) + require.Len(t, events, 1) + btcDelStateUpdate := events[0].GetBtcDelStateUpdate() + require.NotNil(t, btcDelStateUpdate) + require.Equal(t, expectedStakingTxHash, btcDelStateUpdate.StakingTxHash) + require.Equal(t, types.BTCDelegationStatus_UNBONDED, btcDelStateUpdate.NewState) + + // ensure this finality provider does not have voting power at the current height + babylonHeight := datagen.RandomInt(r, 10) + 1 + h.SetCtxHeight(babylonHeight) + h.BTCLightClientKeeper.EXPECT().GetTipInfo(gomock.Eq(h.Ctx)).Return(btcTip).AnyTimes() + h.BeginBlocker() + require.Zero(t, h.FinalityKeeper.GetVotingPower(h.Ctx, *fp.BtcPk, babylonHeight)) + + msgs := h.GenerateCovenantSignaturesMessages(r, covenantSKs, msgCreateBTCDel, actualDel) + + // Generate and report covenant signatures from all covenant members. + for _, m := range msgs { + mCopy := m + _, err = h.MsgServer.AddCovenantSigs(h.Ctx, mCopy) + h.NoError(err) + } + + // event though all covenant signatures are reported, only one event should be generated + events = h.BTCStakingKeeper.GetAllPowerDistUpdateEvents(h.Ctx, btcTip.Height, btcTip.Height) + // we should only have one event that the BTC delegation becomes active + require.Len(t, events, 1) + btcDelStateUpdate = events[0].GetBtcDelStateUpdate() + require.NotNil(t, btcDelStateUpdate) + require.Equal(t, expectedStakingTxHash, btcDelStateUpdate.StakingTxHash) + require.Equal(t, types.BTCDelegationStatus_ACTIVE, btcDelStateUpdate.NewState) +} diff --git a/x/btcstaking/keeper/voting_power_table.go b/x/finality/keeper/power_table.go similarity index 82% rename from x/btcstaking/keeper/voting_power_table.go rename to x/finality/keeper/power_table.go index f7abc715b..0d0101dca 100644 --- a/x/btcstaking/keeper/voting_power_table.go +++ b/x/finality/keeper/power_table.go @@ -8,37 +8,10 @@ import ( "cosmossdk.io/store/prefix" bbn "github.com/babylonlabs-io/babylon/types" - "github.com/babylonlabs-io/babylon/x/btcstaking/types" + "github.com/babylonlabs-io/babylon/x/finality/types" sdk "github.com/cosmos/cosmos-sdk/types" ) -// IterateActiveFPs iterates over all finality providers that are not slashed -func (k Keeper) IterateActiveFPs(ctx context.Context, handler func(fp *types.FinalityProvider) (shouldContinue bool)) { - k.IterateFPs(ctx, func(fp *types.FinalityProvider) (shouldContinue bool) { - if fp.IsSlashed() { - // slashed finality provider is removed from finality provider set - return true - } - - return handler(fp) - }) -} - -// IterateFPs iterates over all finality providers. -func (k Keeper) IterateFPs(ctx context.Context, handler func(fp *types.FinalityProvider) (shouldContinue bool)) { - // filter out all finality providers with positive voting power - fpIter := k.finalityProviderStore(ctx).Iterator(nil, nil) - defer fpIter.Close() - for ; fpIter.Valid(); fpIter.Next() { - var fp types.FinalityProvider - k.cdc.MustUnmarshal(fpIter.Value(), &fp) - shouldContinue := handler(&fp) - if !shouldContinue { - return - } - } -} - func (k Keeper) SetVotingPower(ctx context.Context, fpBTCPK []byte, height uint64, power uint64) { store := k.votingPowerBbnBlockHeightStore(ctx, height) store.Set(fpBTCPK, sdk.Uint64ToBigEndian(power)) @@ -46,9 +19,6 @@ func (k Keeper) SetVotingPower(ctx context.Context, fpBTCPK []byte, height uint6 // GetVotingPower gets the voting power of a given finality provider at a given Babylon height func (k Keeper) GetVotingPower(ctx context.Context, fpBTCPK []byte, height uint64) uint64 { - if !k.HasFinalityProvider(ctx, fpBTCPK) { - return 0 - } store := k.votingPowerBbnBlockHeightStore(ctx, height) powerBytes := store.Get(fpBTCPK) if len(powerBytes) == 0 { @@ -77,7 +47,7 @@ func (k Keeper) GetCurrentVotingPower(ctx context.Context, fpBTCPK []byte) (uint storeAtHeight := prefix.NewStore(store, sdk.Uint64ToBigEndian(lastHeight)) // if the finality provider is not known, return 0 voting power - if !k.HasFinalityProvider(ctx, fpBTCPK) { + if !k.BTCStakingKeeper.HasFinalityProvider(ctx, fpBTCPK) { return lastHeight, 0 } diff --git a/x/btcstaking/keeper/voting_power_table_test.go b/x/finality/keeper/power_table_test.go similarity index 60% rename from x/btcstaking/keeper/voting_power_table_test.go rename to x/finality/keeper/power_table_test.go index 14ef309c1..a6e3fc36e 100644 --- a/x/btcstaking/keeper/voting_power_table_test.go +++ b/x/finality/keeper/power_table_test.go @@ -6,12 +6,15 @@ import ( "testing" "github.com/btcsuite/btcd/btcec/v2" + sdk "github.com/cosmos/cosmos-sdk/types" "github.com/golang/mock/gomock" "github.com/stretchr/testify/require" + testutil "github.com/babylonlabs-io/babylon/testutil/btcstaking-helper" "github.com/babylonlabs-io/babylon/testutil/datagen" btclctypes "github.com/babylonlabs-io/babylon/x/btclightclient/types" "github.com/babylonlabs-io/babylon/x/btcstaking/types" + ftypes "github.com/babylonlabs-io/babylon/x/finality/types" ) func FuzzVotingPowerTable(f *testing.F) { @@ -25,21 +28,20 @@ func FuzzVotingPowerTable(f *testing.F) { // mock BTC light client and BTC checkpoint modules btclcKeeper := types.NewMockBTCLightClientKeeper(ctrl) btccKeeper := types.NewMockBtcCheckpointKeeper(ctrl) - finalityKeeper := types.NewMockFinalityKeeper(ctrl) - finalityKeeper.EXPECT().HasTimestampedPubRand(gomock.Any(), gomock.Any(), gomock.Any()).Return(true).AnyTimes() - h := NewHelper(t, btclcKeeper, btccKeeper, finalityKeeper) + h := testutil.NewHelper(t, btclcKeeper, btccKeeper) // set all parameters covenantSKs, _ := h.GenAndApplyParams(r) changeAddress, err := datagen.GenRandomBTCAddress(r, h.Net) h.NoError(err) - // generate a random batch of finality providers + // generate a random batch of finality providers, and commit pub rand list with timestamp fps := []*types.FinalityProvider{} numFpsWithVotingPower := datagen.RandomInt(r, 10) + 2 numFps := numFpsWithVotingPower + datagen.RandomInt(r, 10) for i := uint64(0); i < numFps; i++ { - _, _, fp := h.CreateFinalityProvider(r) + fpSK, _, fp := h.CreateFinalityProvider(r) + h.CommitPubRandList(r, fpSK, fp, 1, 100, true) fps = append(fps, fp) } @@ -48,15 +50,23 @@ func FuzzVotingPowerTable(f *testing.F) { stakingValue := datagen.RandomInt(r, 100000) + 100000 for i := uint64(0); i < numFpsWithVotingPower; i++ { for j := uint64(0); j < numBTCDels; j++ { - _, _, _, delMsg, del, err := h.CreateDelegation( + delSK, _, err := datagen.GenRandomBTCKeyPair(r) + h.NoError(err) + stakingTxHash, delMsg, del, btcHeaderInfo, inclusionProof, _, err := h.CreateDelegation( r, + delSK, []*btcec.PublicKey{fps[i].BtcPk.MustToBTCPK()}, changeAddress.EncodeAddress(), int64(stakingValue), 1000, + 0, + 0, + true, + false, ) h.NoError(err) h.CreateCovenantSigs(r, covenantSKs, delMsg, del) + h.AddInclusionProof(stakingTxHash, btcHeaderInfo, inclusionProof) } } @@ -68,25 +78,27 @@ func FuzzVotingPowerTable(f *testing.F) { h.BTCLightClientKeeper.EXPECT().GetTipInfo(gomock.Eq(h.Ctx)).Return(&btclctypes.BTCHeaderInfo{Height: 30}).AnyTimes() err = h.BTCStakingKeeper.BeginBlocker(h.Ctx) require.NoError(t, err) + err = h.FinalityKeeper.BeginBlocker(h.Ctx) + require.NoError(t, err) for i := uint64(0); i < numFpsWithVotingPower; i++ { - power := h.BTCStakingKeeper.GetVotingPower(h.Ctx, *fps[i].BtcPk, babylonHeight) + power := h.FinalityKeeper.GetVotingPower(h.Ctx, *fps[i].BtcPk, babylonHeight) require.Equal(t, numBTCDels*stakingValue, power) } for i := numFpsWithVotingPower; i < numFps; i++ { - power := h.BTCStakingKeeper.GetVotingPower(h.Ctx, *fps[i].BtcPk, babylonHeight) + power := h.FinalityKeeper.GetVotingPower(h.Ctx, *fps[i].BtcPk, babylonHeight) require.Zero(t, power) } // also, get voting power table and assert consistency - powerTable := h.BTCStakingKeeper.GetVotingPowerTable(h.Ctx, babylonHeight) + powerTable := h.FinalityKeeper.GetVotingPowerTable(h.Ctx, babylonHeight) require.NotNil(t, powerTable) for i := uint64(0); i < numFpsWithVotingPower; i++ { - power := h.BTCStakingKeeper.GetVotingPower(h.Ctx, *fps[i].BtcPk, babylonHeight) + power := h.FinalityKeeper.GetVotingPower(h.Ctx, *fps[i].BtcPk, babylonHeight) require.Equal(t, powerTable[fps[i].BtcPk.MarshalHex()], power) } // the activation height should be the current Babylon height as well - activatedHeight, err := h.BTCStakingKeeper.GetBTCStakingActivatedHeight(h.Ctx) + activatedHeight, err := h.FinalityKeeper.GetBTCStakingActivatedHeight(h.Ctx) require.NoError(t, err) require.Equal(t, babylonHeight, activatedHeight) @@ -107,10 +119,12 @@ func FuzzVotingPowerTable(f *testing.F) { // index height and record power table err = h.BTCStakingKeeper.BeginBlocker(h.Ctx) require.NoError(t, err) + err = h.FinalityKeeper.BeginBlocker(h.Ctx) + require.NoError(t, err) // check if the slashed finality provider's voting power becomes zero for i := uint64(0); i < numFpsWithVotingPower; i++ { - power := h.BTCStakingKeeper.GetVotingPower(h.Ctx, *fps[i].BtcPk, babylonHeight) + power := h.FinalityKeeper.GetVotingPower(h.Ctx, *fps[i].BtcPk, babylonHeight) if i == slashedIdx { require.Zero(t, power) } else { @@ -118,15 +132,15 @@ func FuzzVotingPowerTable(f *testing.F) { } } for i := numFpsWithVotingPower; i < numFps; i++ { - power := h.BTCStakingKeeper.GetVotingPower(h.Ctx, *fps[i].BtcPk, babylonHeight) + power := h.FinalityKeeper.GetVotingPower(h.Ctx, *fps[i].BtcPk, babylonHeight) require.Zero(t, power) } // also, get voting power table and assert consistency - powerTable = h.BTCStakingKeeper.GetVotingPowerTable(h.Ctx, babylonHeight) + powerTable = h.FinalityKeeper.GetVotingPowerTable(h.Ctx, babylonHeight) require.NotNil(t, powerTable) for i := uint64(0); i < numFpsWithVotingPower; i++ { - power := h.BTCStakingKeeper.GetVotingPower(h.Ctx, *fps[i].BtcPk, babylonHeight) + power := h.FinalityKeeper.GetVotingPower(h.Ctx, *fps[i].BtcPk, babylonHeight) if i == slashedIdx { require.Zero(t, power) } @@ -144,16 +158,97 @@ func FuzzVotingPowerTable(f *testing.F) { require.NoError(t, err) for _, fp := range fps { - power := h.BTCStakingKeeper.GetVotingPower(h.Ctx, *fp.BtcPk, babylonHeight) + power := h.FinalityKeeper.GetVotingPower(h.Ctx, *fp.BtcPk, babylonHeight) require.Zero(t, power) } // the activation height should be same as before - activatedHeight2, err := h.BTCStakingKeeper.GetBTCStakingActivatedHeight(h.Ctx) + activatedHeight2, err := h.FinalityKeeper.GetBTCStakingActivatedHeight(h.Ctx) require.NoError(t, err) require.Equal(t, activatedHeight, activatedHeight2) }) } +func FuzzRecordVotingPowerDistCache(f *testing.F) { + datagen.AddRandomSeedsToFuzzer(f, 10) + + f.Fuzz(func(t *testing.T, seed int64) { + r := rand.New(rand.NewSource(seed)) + ctrl := gomock.NewController(t) + defer ctrl.Finish() + + // mock BTC light client and BTC checkpoint modules + btclcKeeper := types.NewMockBTCLightClientKeeper(ctrl) + btccKeeper := types.NewMockBtcCheckpointKeeper(ctrl) + h := testutil.NewHelper(t, btclcKeeper, btccKeeper) + + // set all parameters + covenantSKs, _ := h.GenAndApplyParams(r) + changeAddress, err := datagen.GenRandomBTCAddress(r, h.Net) + h.NoError(err) + + // generate a random batch of finality providers, and commit + // pub rand list with timestamp + numFpsWithVotingPower := datagen.RandomInt(r, 10) + 2 + numFps := numFpsWithVotingPower + datagen.RandomInt(r, 10) + fpsWithVotingPowerMap := map[string]*types.FinalityProvider{} + for i := uint64(0); i < numFps; i++ { + fpSK, _, fp := h.CreateFinalityProvider(r) + h.CommitPubRandList(r, fpSK, fp, 1, 100, true) + if i < numFpsWithVotingPower { + // these finality providers will receive BTC delegations and have voting power + fpsWithVotingPowerMap[fp.Addr] = fp + } + } + + // for the first numFpsWithVotingPower finality providers, generate a random number of BTC + // delegations and add covenant signatures to activate them + numBTCDels := datagen.RandomInt(r, 10) + 1 + stakingValue := datagen.RandomInt(r, 100000) + 100000 + for _, fp := range fpsWithVotingPowerMap { + for j := uint64(0); j < numBTCDels; j++ { + delSK, _, err := datagen.GenRandomBTCKeyPair(r) + h.NoError(err) + stakingTxHash, delMsg, del, btcHeaderInfo, inclusionProof, _, err := h.CreateDelegation( + r, + delSK, + []*btcec.PublicKey{fp.BtcPk.MustToBTCPK()}, + changeAddress.EncodeAddress(), + int64(stakingValue), + 1000, + 0, + 0, + true, + false, + ) + h.NoError(err) + h.CreateCovenantSigs(r, covenantSKs, delMsg, del) + h.AddInclusionProof(stakingTxHash, btcHeaderInfo, inclusionProof) + } + } + + // record voting power distribution cache + babylonHeight := datagen.RandomInt(r, 10) + 1 + h.Ctx = datagen.WithCtxHeight(h.Ctx, babylonHeight) + h.BTCLightClientKeeper.EXPECT().GetTipInfo(gomock.Eq(h.Ctx)).Return(&btclctypes.BTCHeaderInfo{Height: 30}).AnyTimes() + h.BeginBlocker() + + // assert voting power distribution cache is correct + dc := h.FinalityKeeper.GetVotingPowerDistCache(h.Ctx, babylonHeight) + require.NotNil(t, dc) + require.Equal(t, dc.TotalVotingPower, numFpsWithVotingPower*numBTCDels*stakingValue, dc.String()) + activeFPs := dc.GetActiveFinalityProviderSet() + for _, fpDistInfo := range activeFPs { + require.Equal(t, fpDistInfo.TotalBondedSat, numBTCDels*stakingValue) + fp, ok := fpsWithVotingPowerMap[sdk.AccAddress(fpDistInfo.Addr).String()] + require.True(t, ok) + require.Equal(t, fpDistInfo.Commission, fp.Commission) + require.Len(t, fpDistInfo.BtcDels, int(numBTCDels)) + for _, delDistInfo := range fpDistInfo.BtcDels { + require.Equal(t, delDistInfo.TotalSat, stakingValue) + } + } + }) +} func FuzzVotingPowerTable_ActiveFinalityProviders(f *testing.F) { datagen.AddRandomSeedsToFuzzer(f, 10) @@ -166,8 +261,7 @@ func FuzzVotingPowerTable_ActiveFinalityProviders(f *testing.F) { // mock BTC light client and BTC checkpoint modules btclcKeeper := types.NewMockBTCLightClientKeeper(ctrl) btccKeeper := types.NewMockBtcCheckpointKeeper(ctrl) - finalityKeeper := types.NewMockFinalityKeeper(ctrl) - h := NewHelper(t, btclcKeeper, btccKeeper, finalityKeeper) + h := testutil.NewHelper(t, btclcKeeper, btccKeeper) // set all parameters covenantSKs, _ := h.GenAndApplyParams(r) @@ -175,34 +269,42 @@ func FuzzVotingPowerTable_ActiveFinalityProviders(f *testing.F) { h.NoError(err) // generate a random batch of finality providers, each with a BTC delegation with random power - fpsWithMeta := []*types.FinalityProviderDistInfo{} + fpsWithMeta := []*ftypes.FinalityProviderDistInfo{} numFps := datagen.RandomInt(r, 300) + 1 noTimestampedFps := map[string]bool{} for i := uint64(0); i < numFps; i++ { // generate finality provider - _, _, fp := h.CreateFinalityProvider(r) + fpSK, _, fp := h.CreateFinalityProvider(r) // delegate to this finality provider stakingValue := datagen.RandomInt(r, 100000) + 100000 - _, _, _, delMsg, del, err := h.CreateDelegation( + delSK, _, err := datagen.GenRandomBTCKeyPair(r) + h.NoError(err) + stakingTxHash, delMsg, del, btcHeaderInfo, inclusionProof, _, err := h.CreateDelegation( r, + delSK, []*btcec.PublicKey{fp.BtcPk.MustToBTCPK()}, changeAddress.EncodeAddress(), int64(stakingValue), 1000, + 0, + 0, + true, + false, ) h.NoError(err) h.CreateCovenantSigs(r, covenantSKs, delMsg, del) + h.AddInclusionProof(stakingTxHash, btcHeaderInfo, inclusionProof) // 30 percent not have timestamped randomness, which causes // zero voting power in the table - fpDistInfo := &types.FinalityProviderDistInfo{BtcPk: fp.BtcPk, TotalVotingPower: stakingValue} + fpDistInfo := &ftypes.FinalityProviderDistInfo{BtcPk: fp.BtcPk, TotalBondedSat: stakingValue} if r.Intn(10) <= 2 { - finalityKeeper.EXPECT().HasTimestampedPubRand(gomock.Any(), fp.BtcPk, gomock.Any()).Return(false).AnyTimes() + h.CommitPubRandList(r, fpSK, fp, 1, 100, false) noTimestampedFps[fp.BtcPk.MarshalHex()] = true fpDistInfo.IsTimestamped = false } else { - finalityKeeper.EXPECT().HasTimestampedPubRand(gomock.Any(), fp.BtcPk, gomock.Any()).Return(true).AnyTimes() + h.CommitPubRandList(r, fpSK, fp, 1, 100, true) fpDistInfo.IsTimestamped = true } @@ -210,25 +312,24 @@ func FuzzVotingPowerTable_ActiveFinalityProviders(f *testing.F) { fpsWithMeta = append(fpsWithMeta, fpDistInfo) } - maxActiveFpsParam := h.BTCStakingKeeper.GetParams(h.Ctx).MaxActiveFinalityProviders + maxActiveFpsParam := h.FinalityKeeper.GetParams(h.Ctx).MaxActiveFinalityProviders // get a map of expected active finality providers - types.SortFinalityProvidersWithZeroedVotingPower(fpsWithMeta) + ftypes.SortFinalityProvidersWithZeroedVotingPower(fpsWithMeta) expectedActiveFps := fpsWithMeta[:min(uint32(len(fpsWithMeta)-len(noTimestampedFps)), maxActiveFpsParam)] expectedActiveFpsMap := map[string]uint64{} for _, fp := range expectedActiveFps { - expectedActiveFpsMap[fp.BtcPk.MarshalHex()] = fp.TotalVotingPower + expectedActiveFpsMap[fp.BtcPk.MarshalHex()] = fp.TotalBondedSat } // record voting power table babylonHeight := datagen.RandomInt(r, 10) + 1 h.SetCtxHeight(babylonHeight) h.BTCLightClientKeeper.EXPECT().GetTipInfo(gomock.Eq(h.Ctx)).Return(&btclctypes.BTCHeaderInfo{Height: 30}).AnyTimes() - err = h.BTCStakingKeeper.BeginBlocker(h.Ctx) - require.NoError(t, err) + h.BeginBlocker() // only finality providers in expectedActiveFpsMap have voting power for _, fp := range fpsWithMeta { - power := h.BTCStakingKeeper.GetVotingPower(h.Ctx, fp.BtcPk.MustMarshal(), babylonHeight) + power := h.FinalityKeeper.GetVotingPower(h.Ctx, fp.BtcPk.MustMarshal(), babylonHeight) if expectedPower, ok := expectedActiveFpsMap[fp.BtcPk.MarshalHex()]; ok { require.Equal(t, expectedPower, power) } else { @@ -238,7 +339,7 @@ func FuzzVotingPowerTable_ActiveFinalityProviders(f *testing.F) { // also, get voting power table and assert there is // min(len(expectedActiveFps), MaxActiveFinalityProviders) active finality providers - powerTable := h.BTCStakingKeeper.GetVotingPowerTable(h.Ctx, babylonHeight) + powerTable := h.FinalityKeeper.GetVotingPowerTable(h.Ctx, babylonHeight) expectedNumActiveFps := len(expectedActiveFpsMap) if expectedNumActiveFps > int(maxActiveFpsParam) { expectedNumActiveFps = int(maxActiveFpsParam) @@ -262,25 +363,23 @@ func FuzzVotingPowerTable_ActiveFinalityProviderRotation(f *testing.F) { // mock BTC light client and BTC checkpoint modules btclcKeeper := types.NewMockBTCLightClientKeeper(ctrl) btccKeeper := types.NewMockBtcCheckpointKeeper(ctrl) - finalityKeeper := types.NewMockFinalityKeeper(ctrl) - finalityKeeper.EXPECT().HasTimestampedPubRand(gomock.Any(), gomock.Any(), gomock.Any()).Return(true).AnyTimes() - h := NewHelper(t, btclcKeeper, btccKeeper, finalityKeeper) + h := testutil.NewHelper(t, btclcKeeper, btccKeeper) // set all parameters covenantSKs, _ := h.GenAndApplyParams(r) // set random number of max number of finality providers // in order to cover cases that number of finality providers is more or // less than `MaxActiveFinalityProviders` - bsParams := h.BTCStakingKeeper.GetParams(h.Ctx) - bsParams.MaxActiveFinalityProviders = uint32(datagen.RandomInt(r, 20) + 10) - err := h.BTCStakingKeeper.SetParams(h.Ctx, bsParams) + fParams := h.FinalityKeeper.GetParams(h.Ctx) + fParams.MaxActiveFinalityProviders = uint32(datagen.RandomInt(r, 20) + 10) + err := h.FinalityKeeper.SetParams(h.Ctx, fParams) h.NoError(err) // change address changeAddress, err := datagen.GenRandomBTCAddress(r, h.Net) h.NoError(err) numFps := datagen.RandomInt(r, 20) + 10 - numActiveFPs := int(min(numFps, uint64(bsParams.MaxActiveFinalityProviders))) + numActiveFPs := int(min(numFps, uint64(fParams.MaxActiveFinalityProviders))) /* Generate a random batch of finality providers, each with a BTC delegation @@ -291,19 +390,28 @@ func FuzzVotingPowerTable_ActiveFinalityProviderRotation(f *testing.F) { for i := uint64(0); i < numFps; i++ { // generate finality provider // generate and insert new finality provider - _, fpPK, fp := h.CreateFinalityProvider(r) + fpSK, _, fp := h.CreateFinalityProvider(r) + h.CommitPubRandList(r, fpSK, fp, 1, 100, true) // create BTC delegation and add covenant signatures to activate it stakingValue := datagen.RandomInt(r, 100000) + 100000 - _, _, _, delMsg, del, err := h.CreateDelegation( + delSK, _, err := datagen.GenRandomBTCKeyPair(r) + h.NoError(err) + stakingTxHash, delMsg, del, btcHeaderInfo, inclusionProof, _, err := h.CreateDelegation( r, - []*btcec.PublicKey{fpPK}, + delSK, + []*btcec.PublicKey{fp.BtcPk.MustToBTCPK()}, changeAddress.EncodeAddress(), int64(stakingValue), 1000, + 0, + 0, + true, + false, ) h.NoError(err) h.CreateCovenantSigs(r, covenantSKs, delMsg, del) + h.AddInclusionProof(stakingTxHash, btcHeaderInfo, inclusionProof) // record voting power fpsWithMeta = append(fpsWithMeta, &types.FinalityProviderWithMeta{ @@ -316,19 +424,18 @@ func FuzzVotingPowerTable_ActiveFinalityProviderRotation(f *testing.F) { babylonHeight := datagen.RandomInt(r, 10) + 1 h.Ctx = datagen.WithCtxHeight(h.Ctx, babylonHeight) h.BTCLightClientKeeper.EXPECT().GetTipInfo(gomock.Eq(h.Ctx)).Return(&btclctypes.BTCHeaderInfo{Height: 30}).AnyTimes() - err = h.BTCStakingKeeper.BeginBlocker(h.Ctx) - h.NoError(err) + h.BeginBlocker() // assert that only top `min(MaxActiveFinalityProviders, numFPs)` finality providers have voting power sort.SliceStable(fpsWithMeta, func(i, j int) bool { return fpsWithMeta[i].VotingPower > fpsWithMeta[j].VotingPower }) for i := 0; i < numActiveFPs; i++ { - votingPower := h.BTCStakingKeeper.GetVotingPower(h.Ctx, *fpsWithMeta[i].BtcPk, babylonHeight) + votingPower := h.FinalityKeeper.GetVotingPower(h.Ctx, *fpsWithMeta[i].BtcPk, babylonHeight) require.Equal(t, fpsWithMeta[i].VotingPower, votingPower) } for i := numActiveFPs; i < int(numFps); i++ { - votingPower := h.BTCStakingKeeper.GetVotingPower(h.Ctx, *fpsWithMeta[i].BtcPk, babylonHeight) + votingPower := h.FinalityKeeper.GetVotingPower(h.Ctx, *fpsWithMeta[i].BtcPk, babylonHeight) require.Zero(t, votingPower) } @@ -345,15 +452,23 @@ func FuzzVotingPowerTable_ActiveFinalityProviderRotation(f *testing.F) { stakingValue := datagen.RandomInt(r, 100000) + 100000 fpBTCPK := fpsWithMeta[i].BtcPk - _, _, _, delMsg, del, err := h.CreateDelegation( + delSK, _, err := datagen.GenRandomBTCKeyPair(r) + h.NoError(err) + stakingTxHash, delMsg, del, btcHeaderInfo, inclusionProof, _, err := h.CreateDelegation( r, + delSK, []*btcec.PublicKey{fpBTCPK.MustToBTCPK()}, changeAddress.EncodeAddress(), int64(stakingValue), 1000, + 0, + 0, + true, + false, ) h.NoError(err) h.CreateCovenantSigs(r, covenantSKs, delMsg, del) + h.AddInclusionProof(stakingTxHash, btcHeaderInfo, inclusionProof) // accumulate voting power for this finality provider fpsWithMeta[i].VotingPower += stakingValue @@ -363,23 +478,32 @@ func FuzzVotingPowerTable_ActiveFinalityProviderRotation(f *testing.F) { // create more finality providers numNewFps := datagen.RandomInt(r, 20) + 10 numFps += numNewFps - numActiveFPs = int(min(numFps, uint64(bsParams.MaxActiveFinalityProviders))) + numActiveFPs = int(min(numFps, uint64(fParams.MaxActiveFinalityProviders))) for i := uint64(0); i < numNewFps; i++ { // generate finality provider // generate and insert new finality provider - _, fpPK, fp := h.CreateFinalityProvider(r) + fpSK, fpPK, fp := h.CreateFinalityProvider(r) + h.CommitPubRandList(r, fpSK, fp, 1, 100, true) // create BTC delegation and add covenant signatures to activate it stakingValue := datagen.RandomInt(r, 100000) + 100000 - _, _, _, delMsg, del, err := h.CreateDelegation( + delSK, _, err := datagen.GenRandomBTCKeyPair(r) + h.NoError(err) + stakingTxHash, delMsg, del, btcHeaderInfo, inclusionProof, _, err := h.CreateDelegation( r, + delSK, []*btcec.PublicKey{fpPK}, changeAddress.EncodeAddress(), int64(stakingValue), 1000, + 0, + 0, + true, + false, ) h.NoError(err) h.CreateCovenantSigs(r, covenantSKs, delMsg, del) + h.AddInclusionProof(stakingTxHash, btcHeaderInfo, inclusionProof) // record voting power fpsWithMeta = append(fpsWithMeta, &types.FinalityProviderWithMeta{ @@ -392,19 +516,18 @@ func FuzzVotingPowerTable_ActiveFinalityProviderRotation(f *testing.F) { babylonHeight += 1 h.Ctx = datagen.WithCtxHeight(h.Ctx, babylonHeight) h.BTCLightClientKeeper.EXPECT().GetTipInfo(gomock.Eq(h.Ctx)).Return(&btclctypes.BTCHeaderInfo{Height: 30}).AnyTimes() - err = h.BTCStakingKeeper.BeginBlocker(h.Ctx) - h.NoError(err) + h.BeginBlocker() // again, assert that only top `min(MaxActiveFinalityProviders, numFPs)` finality providers have voting power sort.SliceStable(fpsWithMeta, func(i, j int) bool { return fpsWithMeta[i].VotingPower > fpsWithMeta[j].VotingPower }) for i := 0; i < numActiveFPs; i++ { - votingPower := h.BTCStakingKeeper.GetVotingPower(h.Ctx, *fpsWithMeta[i].BtcPk, babylonHeight) + votingPower := h.FinalityKeeper.GetVotingPower(h.Ctx, *fpsWithMeta[i].BtcPk, babylonHeight) require.Equal(t, fpsWithMeta[i].VotingPower, votingPower) } for i := numActiveFPs; i < int(numFps); i++ { - votingPower := h.BTCStakingKeeper.GetVotingPower(h.Ctx, *fpsWithMeta[i].BtcPk, babylonHeight) + votingPower := h.FinalityKeeper.GetVotingPower(h.Ctx, *fpsWithMeta[i].BtcPk, babylonHeight) require.Zero(t, votingPower) } }) diff --git a/x/finality/keeper/tallying.go b/x/finality/keeper/tallying.go index efc2ef4e1..939e67c22 100644 --- a/x/finality/keeper/tallying.go +++ b/x/finality/keeper/tallying.go @@ -19,7 +19,7 @@ import ( // but without block that has finality providers set AND does not receive QC func (k Keeper) TallyBlocks(ctx context.Context) { sdkCtx := sdk.UnwrapSDKContext(ctx) - activatedHeight, err := k.BTCStakingKeeper.GetBTCStakingActivatedHeight(ctx) + activatedHeight, err := k.GetBTCStakingActivatedHeight(ctx) if err != nil { // invoking TallyBlocks when BTC staking protocol is not activated is a programming error panic(fmt.Errorf("cannot tally a block when the BTC staking protocol hasn't been activated yet, current height: %v, activated height: %v", @@ -46,14 +46,14 @@ func (k Keeper) TallyBlocks(ctx context.Context) { } // get the finality provider set of this block - fpSet := k.BTCStakingKeeper.GetVotingPowerTable(ctx, ib.Height) + fpSet := k.GetVotingPowerTable(ctx, ib.Height) if fpSet != nil && !ib.Finalized { // has finality providers, non-finalised: tally and try to finalise the block voterBTCPKs := k.GetVoters(ctx, ib.Height) if tally(fpSet, voterBTCPKs) { // if this block gets >2/3 votes, finalise it - k.finalizeBlock(ctx, ib, voterBTCPKs) + k.finalizeBlock(ctx, ib) } else { // if not, then this block and all subsequent blocks should not be finalised // thus, we need to break here @@ -77,24 +77,22 @@ func (k Keeper) TallyBlocks(ctx context.Context) { // finalizeBlock sets a block to be finalised in KVStore and distributes rewards to // finality providers and delegations -func (k Keeper) finalizeBlock(ctx context.Context, block *types.IndexedBlock, voterBTCPKs map[string]struct{}) { +func (k Keeper) finalizeBlock(ctx context.Context, block *types.IndexedBlock) { // set block to be finalised in KVStore block.Finalized = true k.SetBlock(ctx, block) // set next height to finalise as height+1 k.setNextHeightToFinalize(ctx, block.Height+1) // distribute rewards to BTC staking stakeholders w.r.t. the voting power distribution cache - dc, err := k.BTCStakingKeeper.GetVotingPowerDistCache(ctx, block.Height) - if err != nil { + dc := k.GetVotingPowerDistCache(ctx, block.Height) + if dc == nil { // failing to get a voting power distribution cache before distributing reward is a programming error - panic(err) + panic(fmt.Errorf("voting power distribution cache not found at height %d", block.Height)) } - // filter out voted finality providers - filteredDc := dc.FilterVotedDistCache(voterBTCPKs) - // reward voted finality providers - k.IncentiveKeeper.RewardBTCStaking(ctx, block.Height, filteredDc) + // reward active finality providers + k.IncentiveKeeper.RewardBTCStaking(ctx, block.Height, dc) // remove reward distribution cache afterwards - k.BTCStakingKeeper.RemoveVotingPowerDistCache(ctx, block.Height) + k.RemoveVotingPowerDistCache(ctx, block.Height) // record the last finalized height metric types.RecordLastFinalizedHeight(block.Height) } diff --git a/x/finality/keeper/tallying_bench_test.go b/x/finality/keeper/tallying_bench_test.go index 52b1532d7..9e1d5f998 100644 --- a/x/finality/keeper/tallying_bench_test.go +++ b/x/finality/keeper/tallying_bench_test.go @@ -14,7 +14,6 @@ import ( "github.com/babylonlabs-io/babylon/testutil/datagen" keepertest "github.com/babylonlabs-io/babylon/testutil/keeper" bbn "github.com/babylonlabs-io/babylon/types" - bstypes "github.com/babylonlabs-io/babylon/x/btcstaking/types" "github.com/babylonlabs-io/babylon/x/finality/types" ) @@ -32,7 +31,6 @@ func benchmarkTallyBlocks(b *testing.B, numFPs int) { activatedHeight := uint64(1) // add mock queries to GetBTCStakingActivatedHeight ctx = datagen.WithCtxHeight(ctx, uint64(activatedHeight)) - bsKeeper.EXPECT().GetBTCStakingActivatedHeight(gomock.Any()).Return(activatedHeight, nil).AnyTimes() // simulate fp set fpSet := map[string]uint64{} @@ -40,13 +38,11 @@ func benchmarkTallyBlocks(b *testing.B, numFPs int) { votedFpPK, err := datagen.GenRandomBIP340PubKey(r) require.NoError(b, err) fpSet[votedFpPK.MarshalHex()] = 1 + fKeeper.SetVotingPower(ctx, []byte(votedFpPK.MarshalHex()), activatedHeight, 1) } - bsKeeper.EXPECT().GetVotingPowerTable(gomock.Any(), gomock.Any()).Return(fpSet).AnyTimes() // TODO: test incentive - bsKeeper.EXPECT().GetVotingPowerDistCache(gomock.Any(), gomock.Any()).Return(bstypes.NewVotingPowerDistCache(), nil).AnyTimes() iKeeper.EXPECT().RewardBTCStaking(gomock.Any(), gomock.Any(), gomock.Any()).Return().AnyTimes() - bsKeeper.EXPECT().RemoveVotingPowerDistCache(gomock.Any(), gomock.Any()).Return().AnyTimes() // Start the CPU profiler cpuProfileFile := fmt.Sprintf("/tmp/finality-tally-blocks-%d-cpu.pprof", numFPs) f, err := os.Create(cpuProfileFile) diff --git a/x/finality/keeper/tallying_test.go b/x/finality/keeper/tallying_test.go index 9a69988d2..24b4c13e3 100644 --- a/x/finality/keeper/tallying_test.go +++ b/x/finality/keeper/tallying_test.go @@ -1,7 +1,6 @@ package keeper_test import ( - "encoding/hex" "math/rand" "testing" @@ -12,42 +11,10 @@ import ( "github.com/babylonlabs-io/babylon/testutil/datagen" keepertest "github.com/babylonlabs-io/babylon/testutil/keeper" bbn "github.com/babylonlabs-io/babylon/types" - bstypes "github.com/babylonlabs-io/babylon/x/btcstaking/types" "github.com/babylonlabs-io/babylon/x/finality/keeper" "github.com/babylonlabs-io/babylon/x/finality/types" ) -func FuzzTallying_PanicCases(f *testing.F) { - datagen.AddRandomSeedsToFuzzer(f, 10) - - f.Fuzz(func(t *testing.T, seed int64) { - r := rand.New(rand.NewSource(seed)) - ctrl := gomock.NewController(t) - defer ctrl.Finish() - - bsKeeper := types.NewMockBTCStakingKeeper(ctrl) - iKeeper := types.NewMockIncentiveKeeper(ctrl) - cKeeper := types.NewMockCheckpointingKeeper(ctrl) - fKeeper, ctx := keepertest.FinalityKeeper(t, bsKeeper, iKeeper, cKeeper) - - // Case 1: expect to panic if tallying upon BTC staking protocol is not activated - bsKeeper.EXPECT().GetBTCStakingActivatedHeight(gomock.Any()).Return(uint64(0), bstypes.ErrBTCStakingNotActivated).Times(1) - require.Panics(t, func() { fKeeper.TallyBlocks(ctx) }) - - // Case 2: expect to panic if finalised block with nil finality provider - fKeeper.SetBlock(ctx, &types.IndexedBlock{ - Height: 1, - AppHash: datagen.GenRandomByteArray(r, 32), - Finalized: true, - }) - // activate BTC staking protocol at height 1 - ctx = datagen.WithCtxHeight(ctx, 1) - bsKeeper.EXPECT().GetBTCStakingActivatedHeight(gomock.Any()).Return(uint64(1), nil).Times(1) - bsKeeper.EXPECT().GetVotingPowerTable(gomock.Any(), gomock.Eq(uint64(1))).Return(nil).Times(1) - require.Panics(t, func() { fKeeper.TallyBlocks(ctx) }) - }) -} - func FuzzTallying_FinalizingNoBlock(f *testing.F) { datagen.AddRandomSeedsToFuzzer(f, 10) @@ -74,13 +41,13 @@ func FuzzTallying_FinalizingNoBlock(f *testing.F) { Finalized: false, }) // this block does not have QC - err := giveNoQCToHeight(r, ctx, bsKeeper, fKeeper, i) + err := giveNoQCToHeight(r, ctx, fKeeper, i) require.NoError(t, err) } - // add mock queries to GetBTCStakingActivatedHeight - ctx = datagen.WithCtxHeight(ctx, activatedHeight+10-1) - bsKeeper.EXPECT().GetBTCStakingActivatedHeight(gomock.Any()).Return(activatedHeight, nil).Times(1) + // mock activated height + fKeeper.SetVotingPower(ctx, datagen.GenRandomByteArray(r, 32), activatedHeight, 1) // tally blocks and none of them should be finalised + ctx = datagen.WithCtxHeight(ctx, activatedHeight+10-1) fKeeper.TallyBlocks(ctx) for i := activatedHeight; i < activatedHeight+10; i++ { ib, err := fKeeper.GetBlock(ctx, i) @@ -100,7 +67,6 @@ func FuzzTallying_FinalizingSomeBlocks(f *testing.F) { defer ctrl.Finish() bsKeeper := types.NewMockBTCStakingKeeper(ctrl) - bsKeeper.EXPECT().GetParams(gomock.Any()).Return(bstypes.Params{MaxActiveFinalityProviders: 100}).AnyTimes() iKeeper := types.NewMockIncentiveKeeper(ctrl) cKeeper := types.NewMockCheckpointingKeeper(ctrl) fKeeper, ctx := keepertest.FinalityKeeper(t, bsKeeper, iKeeper, cKeeper) @@ -120,22 +86,18 @@ func FuzzTallying_FinalizingSomeBlocks(f *testing.F) { }) if i < activatedHeight+numWithQCs { // this block has QC - err := giveQCToHeight(r, ctx, bsKeeper, fKeeper, i) + err := giveQCToHeight(r, ctx, fKeeper, i) require.NoError(t, err) } else { // this block does not have QC - err := giveNoQCToHeight(r, ctx, bsKeeper, fKeeper, i) + err := giveNoQCToHeight(r, ctx, fKeeper, i) require.NoError(t, err) } } // we don't test incentive in this function - bsKeeper.EXPECT().GetVotingPowerDistCache(gomock.Any(), gomock.Any()).Return(bstypes.NewVotingPowerDistCache(), nil).Times(int(numWithQCs)) iKeeper.EXPECT().RewardBTCStaking(gomock.Any(), gomock.Any(), gomock.Any()).Return().Times(int(numWithQCs)) - bsKeeper.EXPECT().RemoveVotingPowerDistCache(gomock.Any(), gomock.Any()).Return().Times(int(numWithQCs)) - // add mock queries to GetBTCStakingActivatedHeight - ctx = datagen.WithCtxHeight(ctx, activatedHeight+10-1) - bsKeeper.EXPECT().GetBTCStakingActivatedHeight(gomock.Any()).Return(activatedHeight, nil).Times(1) // tally blocks and none of them should be finalised + ctx = datagen.WithCtxHeight(ctx, activatedHeight+10-1) fKeeper.TallyBlocks(ctx) for i := activatedHeight; i < activatedHeight+10; i++ { ib, err := fKeeper.GetBlock(ctx, i) @@ -150,49 +112,62 @@ func FuzzTallying_FinalizingSomeBlocks(f *testing.F) { } -func giveQCToHeight(r *rand.Rand, ctx sdk.Context, bsKeeper *types.MockBTCStakingKeeper, fKeeper *keeper.Keeper, height uint64) error { - // 4 finality providers - fpSet := map[string]uint64{} +func giveQCToHeight(r *rand.Rand, ctx sdk.Context, fKeeper *keeper.Keeper, height uint64) error { + dc := types.NewVotingPowerDistCache() // 3 votes for i := 0; i < 3; i++ { votedFpPK, err := datagen.GenRandomBIP340PubKey(r) if err != nil { return err } + fKeeper.SetVotingPower(ctx, votedFpPK.MustMarshal(), height, 1) + dc.AddFinalityProviderDistInfo(&types.FinalityProviderDistInfo{ + BtcPk: votedFpPK, + TotalBondedSat: 1, + }) votedSig, err := bbn.NewSchnorrEOTSSig(datagen.GenRandomByteArray(r, 32)) if err != nil { return err } fKeeper.SetSig(ctx, height, votedFpPK, votedSig) - // add finality provider - fpSet[votedFpPK.MarshalHex()] = 1 } // the rest of the finality providers do not vote - fpSet[hex.EncodeToString(datagen.GenRandomByteArray(r, 32))] = 1 - bsKeeper.EXPECT().GetVotingPowerTable(gomock.Any(), gomock.Eq(height)).Return(fpSet).Times(1) - + fKeeper.SetVotingPower(ctx, datagen.GenRandomByteArray(r, 32), height, 1) + fKeeper.SetVotingPowerDistCache(ctx, height, dc) return nil } -func giveNoQCToHeight(r *rand.Rand, ctx sdk.Context, bsKeeper *types.MockBTCStakingKeeper, fKeeper *keeper.Keeper, height uint64) error { +func giveNoQCToHeight(r *rand.Rand, ctx sdk.Context, fKeeper *keeper.Keeper, height uint64) error { + dc := types.NewVotingPowerDistCache() // 1 vote votedFpPK, err := datagen.GenRandomBIP340PubKey(r) if err != nil { return err } + fKeeper.SetVotingPower(ctx, votedFpPK.MustMarshal(), height, 1) + dc.AddFinalityProviderDistInfo(&types.FinalityProviderDistInfo{ + BtcPk: votedFpPK, + TotalBondedSat: 1, + }) votedSig, err := bbn.NewSchnorrEOTSSig(datagen.GenRandomByteArray(r, 32)) if err != nil { return err } fKeeper.SetSig(ctx, height, votedFpPK, votedSig) - // 4 finality providers - fpSet := map[string]uint64{ - votedFpPK.MarshalHex(): 1, - hex.EncodeToString(datagen.GenRandomByteArray(r, 32)): 1, - hex.EncodeToString(datagen.GenRandomByteArray(r, 32)): 1, - hex.EncodeToString(datagen.GenRandomByteArray(r, 32)): 1, + + // the other 3 finality providers + for i := 0; i < 3; i++ { + fpPK, err := datagen.GenRandomBIP340PubKey(r) + if err != nil { + return err + } + fKeeper.SetVotingPower(ctx, fpPK.MustMarshal(), height, 1) + dc.AddFinalityProviderDistInfo(&types.FinalityProviderDistInfo{ + BtcPk: fpPK, + TotalBondedSat: 1, + }) } - bsKeeper.EXPECT().GetVotingPowerTable(gomock.Any(), gomock.Eq(height)).Return(fpSet).MaxTimes(1) + fKeeper.SetVotingPowerDistCache(ctx, height, dc) return nil } diff --git a/x/finality/keeper/votes_bench_test.go b/x/finality/keeper/votes_bench_test.go index 5103ff06a..6c870f9f0 100644 --- a/x/finality/keeper/votes_bench_test.go +++ b/x/finality/keeper/votes_bench_test.go @@ -40,8 +40,6 @@ func benchmarkAddFinalitySig(b *testing.B) { // register the finality provider bsKeeper.EXPECT().HasFinalityProvider(gomock.Any(), gomock.Eq(fpBTCPKBytes)).Return(true).AnyTimes() bsKeeper.EXPECT().GetFinalityProvider(gomock.Any(), gomock.Eq(fpBTCPKBytes)).Return(fp, nil).AnyTimes() - // mock voting power - bsKeeper.EXPECT().GetVotingPower(gomock.Any(), gomock.Eq(fpBTCPKBytes), gomock.Any()).Return(uint64(1)).AnyTimes() // commit enough public randomness // TODO: generalise commit public randomness to allow arbitrary benchtime diff --git a/x/finality/module.go b/x/finality/module.go index 1ab4e359e..62f1039d5 100644 --- a/x/finality/module.go +++ b/x/finality/module.go @@ -72,7 +72,9 @@ func (AppModuleBasic) ValidateGenesis(cdc codec.JSONCodec, config client.TxEncod // RegisterGRPCGatewayRoutes registers the gRPC Gateway routes for the module func (AppModuleBasic) RegisterGRPCGatewayRoutes(clientCtx client.Context, mux *runtime.ServeMux) { - types.RegisterQueryHandlerClient(context.Background(), mux, types.NewQueryClient(clientCtx)) //nolint:errcheck // generally we don't handle errors here + if err := types.RegisterQueryHandlerClient(context.Background(), mux, types.NewQueryClient(clientCtx)); err != nil { + panic(err) + } } // GetTxCmd returns the root Tx command for the module. The subcommands of this root command are used by end-users to generate new transactions containing messages defined in the module diff --git a/x/finality/types/errors.go b/x/finality/types/errors.go index d496d2b92..1b026b6dc 100644 --- a/x/finality/types/errors.go +++ b/x/finality/types/errors.go @@ -15,7 +15,11 @@ var ( ErrInvalidPubRand = errorsmod.Register(ModuleName, 1106, "the public randomness list is invalid") ErrEvidenceNotFound = errorsmod.Register(ModuleName, 1107, "evidence is not found") ErrInvalidFinalitySig = errorsmod.Register(ModuleName, 1108, "finality signature is not valid") - ErrNoSlashableEvidence = errorsmod.Register(ModuleName, 1109, "there is no slashable evidence") - ErrPubRandCommitNotBTCTimestamped = errorsmod.Register(ModuleName, 1110, "the public randomness commit is not BTC timestamped yet") - ErrJailingPeriodNotPassed = errorsmod.Register(ModuleName, 1111, "the jailing period is not passed") + ErrDuplicatedFinalitySig = errorsmod.Register(ModuleName, 1109, "duplicated finality vote") + ErrNoSlashableEvidence = errorsmod.Register(ModuleName, 1110, "there is no slashable evidence") + ErrPubRandCommitNotBTCTimestamped = errorsmod.Register(ModuleName, 1111, "the public randomness commit is not BTC timestamped yet") + ErrJailingPeriodNotPassed = errorsmod.Register(ModuleName, 1112, "the jailing period is not passed") + ErrVotingPowerTableNotUpdated = errorsmod.Register(ModuleName, 1113, "voting power table has not been updated") + ErrBTCStakingNotActivated = errorsmod.Register(ModuleName, 1114, "the BTC staking protocol is not activated yet") + ErrFinalityNotActivated = errorsmod.Register(ModuleName, 1115, "finality is not active yet") ) diff --git a/x/finality/types/expected_keepers.go b/x/finality/types/expected_keepers.go index 85b0f9e0b..c1e43100f 100644 --- a/x/finality/types/expected_keepers.go +++ b/x/finality/types/expected_keepers.go @@ -6,19 +6,21 @@ import ( bbn "github.com/babylonlabs-io/babylon/types" bstypes "github.com/babylonlabs-io/babylon/x/btcstaking/types" etypes "github.com/babylonlabs-io/babylon/x/epoching/types" + sdk "github.com/cosmos/cosmos-sdk/types" ) type BTCStakingKeeper interface { GetParams(ctx context.Context) bstypes.Params + GetCurrentBTCHeight(ctx context.Context) uint32 + GetBTCHeightAtBabylonHeight(ctx context.Context, babylonHeight uint64) uint32 GetFinalityProvider(ctx context.Context, fpBTCPK []byte) (*bstypes.FinalityProvider, error) HasFinalityProvider(ctx context.Context, fpBTCPK []byte) bool SlashFinalityProvider(ctx context.Context, fpBTCPK []byte) error PropagateFPSlashingToConsumers(ctx context.Context, fpBTCPK *bbn.BIP340PubKey) error - GetVotingPower(ctx context.Context, fpBTCPK []byte, height uint64) uint64 - GetVotingPowerTable(ctx context.Context, height uint64) map[string]uint64 - GetBTCStakingActivatedHeight(ctx context.Context) (uint64, error) - GetVotingPowerDistCache(ctx context.Context, height uint64) (*bstypes.VotingPowerDistCache, error) - RemoveVotingPowerDistCache(ctx context.Context, height uint64) + GetBTCDelegation(ctx context.Context, stakingTxHashStr string) (*bstypes.BTCDelegation, error) + GetAllPowerDistUpdateEvents(ctx context.Context, lastBTCTipHeight, btcTipHeight uint32) []*bstypes.EventPowerDistUpdate + ClearPowerDistUpdateEvents(ctx context.Context, btcHeight uint32) + JailFinalityProvider(ctx context.Context, fpBTCPK []byte) error UnjailFinalityProvider(ctx context.Context, fpBTCPK []byte) error } @@ -27,15 +29,9 @@ type CheckpointingKeeper interface { GetLastFinalizedEpoch(ctx context.Context) uint64 } -// IncentiveKeeper defines the expected interface needed to distribute rewards. +// IncentiveKeeper defines the expected interface needed for distributing rewards +// and refund transaction fee for finality signatures type IncentiveKeeper interface { - RewardBTCStaking(ctx context.Context, height uint64, filteredDc *bstypes.VotingPowerDistCache) -} - -type BtcStakingHooks interface { - AfterFinalityProviderActivated(ctx context.Context, btcPk *bbn.BIP340PubKey) error -} - -type FinalityHooks interface { - AfterSluggishFinalityProviderDetected(ctx context.Context, btcPk *bbn.BIP340PubKey) error + RewardBTCStaking(ctx context.Context, height uint64, filteredDc *VotingPowerDistCache) + IndexRefundableMsg(ctx context.Context, msg sdk.Msg) } diff --git a/x/finality/types/finality.go b/x/finality/types/finality.go index 48527a2aa..5d96f5839 100644 --- a/x/finality/types/finality.go +++ b/x/finality/types/finality.go @@ -4,9 +4,10 @@ import ( "bytes" "fmt" - "github.com/babylonlabs-io/babylon/crypto/eots" "github.com/btcsuite/btcd/btcec/v2" sdk "github.com/cosmos/cosmos-sdk/types" + + "github.com/babylonlabs-io/babylon/crypto/eots" ) func (c *PubRandCommit) IsInRange(height uint64) bool { diff --git a/x/finality/types/finality.pb.go b/x/finality/types/finality.pb.go index 93c60cba2..1f7c74471 100644 --- a/x/finality/types/finality.pb.go +++ b/x/finality/types/finality.pb.go @@ -4,8 +4,10 @@ package types import ( + cosmossdk_io_math "cosmossdk.io/math" fmt "fmt" github_com_babylonlabs_io_babylon_types "github.com/babylonlabs-io/babylon/types" + _ "github.com/cosmos/cosmos-proto" _ "github.com/cosmos/cosmos-sdk/types/tx/amino" _ "github.com/cosmos/gogoproto/gogoproto" proto "github.com/cosmos/gogoproto/proto" @@ -29,6 +31,219 @@ var _ = time.Kitchen // proto package needs to be updated. const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package +// VotingPowerDistCache is the cache for voting power distribution of finality providers +// and their BTC delegations at a height +type VotingPowerDistCache struct { + // total_voting_power is the total voting power of all (active) finality providers + // in the cache + TotalVotingPower uint64 `protobuf:"varint,1,opt,name=total_voting_power,json=totalVotingPower,proto3" json:"total_voting_power,omitempty"` + // finality_providers is a list of finality providers' voting power information + FinalityProviders []*FinalityProviderDistInfo `protobuf:"bytes,2,rep,name=finality_providers,json=finalityProviders,proto3" json:"finality_providers,omitempty"` + // num_active_fps is the number of finality providers that have active BTC + // delegations as well as timestamped public randomness + NumActiveFps uint32 `protobuf:"varint,3,opt,name=num_active_fps,json=numActiveFps,proto3" json:"num_active_fps,omitempty"` +} + +func (m *VotingPowerDistCache) Reset() { *m = VotingPowerDistCache{} } +func (m *VotingPowerDistCache) String() string { return proto.CompactTextString(m) } +func (*VotingPowerDistCache) ProtoMessage() {} +func (*VotingPowerDistCache) Descriptor() ([]byte, []int) { + return fileDescriptor_ca5b87e52e3e6d02, []int{0} +} +func (m *VotingPowerDistCache) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *VotingPowerDistCache) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_VotingPowerDistCache.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 *VotingPowerDistCache) XXX_Merge(src proto.Message) { + xxx_messageInfo_VotingPowerDistCache.Merge(m, src) +} +func (m *VotingPowerDistCache) XXX_Size() int { + return m.Size() +} +func (m *VotingPowerDistCache) XXX_DiscardUnknown() { + xxx_messageInfo_VotingPowerDistCache.DiscardUnknown(m) +} + +var xxx_messageInfo_VotingPowerDistCache proto.InternalMessageInfo + +// FinalityProviderDistInfo is the reward distribution of a finality provider and its BTC delegations +type FinalityProviderDistInfo struct { + // btc_pk is the Bitcoin secp256k1 PK of this finality provider + // the PK follows encoding in BIP-340 spec + BtcPk *github_com_babylonlabs_io_babylon_types.BIP340PubKey `protobuf:"bytes,1,opt,name=btc_pk,json=btcPk,proto3,customtype=github.com/babylonlabs-io/babylon/types.BIP340PubKey" json:"btc_pk,omitempty"` + // addr is the bytes of the address to receive commission from delegations. + Addr []byte `protobuf:"bytes,2,opt,name=addr,proto3" json:"addr,omitempty"` + // commission defines the commission rate of finality provider + Commission *cosmossdk_io_math.LegacyDec `protobuf:"bytes,3,opt,name=commission,proto3,customtype=cosmossdk.io/math.LegacyDec" json:"commission,omitempty"` + // total_bonded_sat is the total amount of bonded BTC stake (in Satoshi) of the finality provider + TotalBondedSat uint64 `protobuf:"varint,4,opt,name=total_bonded_sat,json=totalBondedSat,proto3" json:"total_bonded_sat,omitempty"` + // btc_dels is a list of BTC delegations' voting power information under this finality provider + BtcDels []*BTCDelDistInfo `protobuf:"bytes,5,rep,name=btc_dels,json=btcDels,proto3" json:"btc_dels,omitempty"` + // is_timestamped indicates whether the finality provider + // has timestamped public randomness committed + // if no, it should not be assigned voting power + IsTimestamped bool `protobuf:"varint,6,opt,name=is_timestamped,json=isTimestamped,proto3" json:"is_timestamped,omitempty"` + // is_jailed indicates whether the finality provider + // is jailed, if so, it should not be assigned voting power + IsJailed bool `protobuf:"varint,7,opt,name=is_jailed,json=isJailed,proto3" json:"is_jailed,omitempty"` + // is_slashed indicates whether the finality provider + // is slashed, if so, it should not be assigned voting power + IsSlashed bool `protobuf:"varint,8,opt,name=is_slashed,json=isSlashed,proto3" json:"is_slashed,omitempty"` +} + +func (m *FinalityProviderDistInfo) Reset() { *m = FinalityProviderDistInfo{} } +func (m *FinalityProviderDistInfo) String() string { return proto.CompactTextString(m) } +func (*FinalityProviderDistInfo) ProtoMessage() {} +func (*FinalityProviderDistInfo) Descriptor() ([]byte, []int) { + return fileDescriptor_ca5b87e52e3e6d02, []int{1} +} +func (m *FinalityProviderDistInfo) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *FinalityProviderDistInfo) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_FinalityProviderDistInfo.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 *FinalityProviderDistInfo) XXX_Merge(src proto.Message) { + xxx_messageInfo_FinalityProviderDistInfo.Merge(m, src) +} +func (m *FinalityProviderDistInfo) XXX_Size() int { + return m.Size() +} +func (m *FinalityProviderDistInfo) XXX_DiscardUnknown() { + xxx_messageInfo_FinalityProviderDistInfo.DiscardUnknown(m) +} + +var xxx_messageInfo_FinalityProviderDistInfo proto.InternalMessageInfo + +func (m *FinalityProviderDistInfo) GetAddr() []byte { + if m != nil { + return m.Addr + } + return nil +} + +func (m *FinalityProviderDistInfo) GetTotalBondedSat() uint64 { + if m != nil { + return m.TotalBondedSat + } + return 0 +} + +func (m *FinalityProviderDistInfo) GetBtcDels() []*BTCDelDistInfo { + if m != nil { + return m.BtcDels + } + return nil +} + +func (m *FinalityProviderDistInfo) GetIsTimestamped() bool { + if m != nil { + return m.IsTimestamped + } + return false +} + +func (m *FinalityProviderDistInfo) GetIsJailed() bool { + if m != nil { + return m.IsJailed + } + return false +} + +func (m *FinalityProviderDistInfo) GetIsSlashed() bool { + if m != nil { + return m.IsSlashed + } + return false +} + +// BTCDelDistInfo contains the information related to voting power distribution for a BTC delegation +type BTCDelDistInfo struct { + // btc_pk is the Bitcoin secp256k1 PK of this BTC delegation + // the PK follows encoding in BIP-340 spec + BtcPk *github_com_babylonlabs_io_babylon_types.BIP340PubKey `protobuf:"bytes,1,opt,name=btc_pk,json=btcPk,proto3,customtype=github.com/babylonlabs-io/babylon/types.BIP340PubKey" json:"btc_pk,omitempty"` + // staker_addr is the address to receive rewards from BTC delegation. + StakerAddr string `protobuf:"bytes,2,opt,name=staker_addr,json=stakerAddr,proto3" json:"staker_addr,omitempty"` + // staking_tx_hash is the staking tx hash of the BTC delegation + StakingTxHash string `protobuf:"bytes,3,opt,name=staking_tx_hash,json=stakingTxHash,proto3" json:"staking_tx_hash,omitempty"` + // total_sat is the amount of BTC stake (in Satoshi) of the BTC delegation + TotalSat uint64 `protobuf:"varint,4,opt,name=total_sat,json=totalSat,proto3" json:"total_sat,omitempty"` +} + +func (m *BTCDelDistInfo) Reset() { *m = BTCDelDistInfo{} } +func (m *BTCDelDistInfo) String() string { return proto.CompactTextString(m) } +func (*BTCDelDistInfo) ProtoMessage() {} +func (*BTCDelDistInfo) Descriptor() ([]byte, []int) { + return fileDescriptor_ca5b87e52e3e6d02, []int{2} +} +func (m *BTCDelDistInfo) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *BTCDelDistInfo) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_BTCDelDistInfo.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 *BTCDelDistInfo) XXX_Merge(src proto.Message) { + xxx_messageInfo_BTCDelDistInfo.Merge(m, src) +} +func (m *BTCDelDistInfo) XXX_Size() int { + return m.Size() +} +func (m *BTCDelDistInfo) XXX_DiscardUnknown() { + xxx_messageInfo_BTCDelDistInfo.DiscardUnknown(m) +} + +var xxx_messageInfo_BTCDelDistInfo proto.InternalMessageInfo + +func (m *BTCDelDistInfo) GetStakerAddr() string { + if m != nil { + return m.StakerAddr + } + return "" +} + +func (m *BTCDelDistInfo) GetStakingTxHash() string { + if m != nil { + return m.StakingTxHash + } + return "" +} + +func (m *BTCDelDistInfo) GetTotalSat() uint64 { + if m != nil { + return m.TotalSat + } + return 0 +} + // IndexedBlock is the necessary metadata and finalization status of a block type IndexedBlock struct { // height is the height of the block @@ -44,7 +259,7 @@ func (m *IndexedBlock) Reset() { *m = IndexedBlock{} } func (m *IndexedBlock) String() string { return proto.CompactTextString(m) } func (*IndexedBlock) ProtoMessage() {} func (*IndexedBlock) Descriptor() ([]byte, []int) { - return fileDescriptor_ca5b87e52e3e6d02, []int{0} + return fileDescriptor_ca5b87e52e3e6d02, []int{3} } func (m *IndexedBlock) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -113,7 +328,7 @@ func (m *PubRandCommit) Reset() { *m = PubRandCommit{} } func (m *PubRandCommit) String() string { return proto.CompactTextString(m) } func (*PubRandCommit) ProtoMessage() {} func (*PubRandCommit) Descriptor() ([]byte, []int) { - return fileDescriptor_ca5b87e52e3e6d02, []int{1} + return fileDescriptor_ca5b87e52e3e6d02, []int{4} } func (m *PubRandCommit) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -197,7 +412,7 @@ func (m *Evidence) Reset() { *m = Evidence{} } func (m *Evidence) String() string { return proto.CompactTextString(m) } func (*Evidence) ProtoMessage() {} func (*Evidence) Descriptor() ([]byte, []int) { - return fileDescriptor_ca5b87e52e3e6d02, []int{2} + return fileDescriptor_ca5b87e52e3e6d02, []int{5} } func (m *Evidence) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -265,7 +480,7 @@ func (m *FinalityProviderSigningInfo) Reset() { *m = FinalityProviderSig func (m *FinalityProviderSigningInfo) String() string { return proto.CompactTextString(m) } func (*FinalityProviderSigningInfo) ProtoMessage() {} func (*FinalityProviderSigningInfo) Descriptor() ([]byte, []int) { - return fileDescriptor_ca5b87e52e3e6d02, []int{3} + return fileDescriptor_ca5b87e52e3e6d02, []int{6} } func (m *FinalityProviderSigningInfo) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -316,6 +531,9 @@ func (m *FinalityProviderSigningInfo) GetJailedUntil() time.Time { } func init() { + proto.RegisterType((*VotingPowerDistCache)(nil), "babylon.finality.v1.VotingPowerDistCache") + proto.RegisterType((*FinalityProviderDistInfo)(nil), "babylon.finality.v1.FinalityProviderDistInfo") + proto.RegisterType((*BTCDelDistInfo)(nil), "babylon.finality.v1.BTCDelDistInfo") proto.RegisterType((*IndexedBlock)(nil), "babylon.finality.v1.IndexedBlock") proto.RegisterType((*PubRandCommit)(nil), "babylon.finality.v1.PubRandCommit") proto.RegisterType((*Evidence)(nil), "babylon.finality.v1.Evidence") @@ -327,48 +545,275 @@ func init() { } var fileDescriptor_ca5b87e52e3e6d02 = []byte{ - // 646 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xb4, 0x54, 0xcf, 0x6e, 0xd3, 0x4e, - 0x10, 0x8e, 0xdb, 0xfc, 0x9a, 0x74, 0xe3, 0xea, 0x47, 0xdd, 0x52, 0x85, 0x16, 0x39, 0x21, 0xa7, - 0x0a, 0x81, 0x4d, 0xff, 0x08, 0x21, 0x6e, 0xb8, 0x2a, 0x6a, 0x45, 0x05, 0x91, 0xd3, 0x5e, 0xb8, - 0xac, 0xd6, 0xf6, 0xda, 0x5e, 0x62, 0xef, 0xae, 0xec, 0x75, 0xd5, 0xf0, 0x00, 0x9c, 0xcb, 0x8d, - 0x47, 0xe0, 0xc8, 0x63, 0xf4, 0xd8, 0x23, 0xea, 0xa1, 0xa0, 0xe6, 0xc0, 0x6b, 0x20, 0xaf, 0xed, - 0xa4, 0x39, 0x81, 0x40, 0x5c, 0x2c, 0xef, 0x37, 0xb3, 0xf3, 0xcd, 0x37, 0x33, 0x3b, 0xa0, 0xe7, - 0x20, 0x67, 0x14, 0x31, 0x6a, 0xfa, 0x84, 0xa2, 0x88, 0x88, 0x91, 0x79, 0xba, 0x35, 0xf9, 0x37, - 0x78, 0xc2, 0x04, 0xd3, 0x56, 0x4a, 0x1f, 0x63, 0x82, 0x9f, 0x6e, 0xad, 0xaf, 0x06, 0x2c, 0x60, - 0xd2, 0x6e, 0xe6, 0x7f, 0x85, 0xeb, 0xfa, 0x32, 0x8a, 0x09, 0x65, 0xa6, 0xfc, 0x96, 0x50, 0x27, - 0x60, 0x2c, 0x88, 0xb0, 0x29, 0x4f, 0x4e, 0xe6, 0x9b, 0x82, 0xc4, 0x38, 0x15, 0x28, 0xe6, 0x85, - 0x43, 0x0f, 0x02, 0xf5, 0x90, 0x7a, 0xf8, 0x0c, 0x7b, 0x56, 0xc4, 0xdc, 0xa1, 0xb6, 0x06, 0x16, - 0x42, 0x4c, 0x82, 0x50, 0xb4, 0x95, 0xae, 0xb2, 0x59, 0xb7, 0xcb, 0x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xc1, 0x8c, 0x0a, 0x12, 0xc9, 0x96, - 0xb7, 0xb6, 0xd7, 0x8d, 0x62, 0x05, 0x18, 0xd5, 0x0a, 0x30, 0x8e, 0xab, 0x15, 0x60, 0x2d, 0x5d, - 0x5c, 0x77, 0x6a, 0xe7, 0xdf, 0x3a, 0xca, 0xe7, 0x1f, 0x5f, 0x1e, 0x2a, 0x76, 0xab, 0xb8, 0x7e, - 0x92, 0xdf, 0xb6, 0x8e, 0x2e, 0x6e, 0x74, 0xe5, 0xf2, 0x46, 0x57, 0xbe, 0xdf, 0xe8, 0xca, 0xf9, - 0x58, 0xaf, 0x5d, 0x8e, 0xf5, 0xda, 0xd7, 0xb1, 0x5e, 0x7b, 0xbb, 0xfd, 0x6b, 0xf5, 0x67, 0xd3, - 0x8d, 0x26, 0x0b, 0xe1, 0x2c, 0x48, 0xf6, 0x9d, 0x9f, 0x01, 0x00, 0x00, 0xff, 0xff, 0xa3, 0xae, - 0x27, 0x1f, 0xf2, 0x04, 0x00, 0x00, + // 1019 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xb4, 0x56, 0x4f, 0x6f, 0x1b, 0x45, + 0x14, 0xcf, 0x26, 0x4e, 0x6c, 0x8f, 0xed, 0xb4, 0x99, 0x86, 0x6a, 0x9b, 0x80, 0x9d, 0x9a, 0x3f, + 0x8a, 0x50, 0xb3, 0xa6, 0x69, 0x85, 0xa0, 0x07, 0xa4, 0x6c, 0xd2, 0xaa, 0x81, 0x40, 0xad, 0x75, + 0xca, 0x01, 0x21, 0x8d, 0x66, 0x77, 0xc7, 0xbb, 0x83, 0x77, 0x67, 0x56, 0x3b, 0xb3, 0x21, 0xe6, + 0x03, 0x20, 0x8e, 0xe5, 0x86, 0xc4, 0x85, 0x23, 0x47, 0x0e, 0xfd, 0x10, 0x3d, 0xa1, 0xaa, 0x27, + 0x94, 0x43, 0x80, 0xe4, 0xc0, 0xd7,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0x3f, 0xa8, 0x42, 0xb8, 0x4b, 0xca, 0xfb, 0xad, 0x3f, 0x03, 0x00, + 0x00, 0xff, 0xff, 0xe6, 0xb7, 0x70, 0x5d, 0x60, 0x08, 0x00, 0x00, +} + +func (m *VotingPowerDistCache) 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 *VotingPowerDistCache) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *VotingPowerDistCache) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.NumActiveFps != 0 { + i = encodeVarintFinality(dAtA, i, uint64(m.NumActiveFps)) + i-- + dAtA[i] = 0x18 + } + if len(m.FinalityProviders) > 0 { + for iNdEx := len(m.FinalityProviders) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.FinalityProviders[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintFinality(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + } + } + if m.TotalVotingPower != 0 { + i = encodeVarintFinality(dAtA, i, uint64(m.TotalVotingPower)) + i-- + dAtA[i] = 0x8 + } + return len(dAtA) - i, nil +} + +func (m *FinalityProviderDistInfo) 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 *FinalityProviderDistInfo) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *FinalityProviderDistInfo) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.IsSlashed { + i-- + if m.IsSlashed { + dAtA[i] = 1 + } else { + dAtA[i] = 0 + } + i-- + dAtA[i] = 0x40 + } + if m.IsJailed { + i-- + if m.IsJailed { + dAtA[i] = 1 + } else { + dAtA[i] = 0 + } + i-- + dAtA[i] = 0x38 + } + if m.IsTimestamped { + i-- + if m.IsTimestamped { + dAtA[i] = 1 + } else { + dAtA[i] = 0 + } + i-- + dAtA[i] = 0x30 + } + if len(m.BtcDels) > 0 { + for iNdEx := len(m.BtcDels) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.BtcDels[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintFinality(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x2a + } + } + if m.TotalBondedSat != 0 { + i = encodeVarintFinality(dAtA, i, uint64(m.TotalBondedSat)) + i-- + dAtA[i] = 0x20 + } + if m.Commission != nil { + { + size := m.Commission.Size() + i -= size + if _, err := m.Commission.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintFinality(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x1a + } + if len(m.Addr) > 0 { + i -= len(m.Addr) + copy(dAtA[i:], m.Addr) + i = encodeVarintFinality(dAtA, i, uint64(len(m.Addr))) + i-- + dAtA[i] = 0x12 + } + if m.BtcPk != nil { + { + size := m.BtcPk.Size() + i -= size + if _, err := m.BtcPk.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintFinality(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *BTCDelDistInfo) 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 *BTCDelDistInfo) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *BTCDelDistInfo) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.TotalSat != 0 { + i = encodeVarintFinality(dAtA, i, uint64(m.TotalSat)) + i-- + dAtA[i] = 0x20 + } + if len(m.StakingTxHash) > 0 { + i -= len(m.StakingTxHash) + copy(dAtA[i:], m.StakingTxHash) + i = encodeVarintFinality(dAtA, i, uint64(len(m.StakingTxHash))) + i-- + dAtA[i] = 0x1a + } + if len(m.StakerAddr) > 0 { + i -= len(m.StakerAddr) + copy(dAtA[i:], m.StakerAddr) + i = encodeVarintFinality(dAtA, i, uint64(len(m.StakerAddr))) + i-- + dAtA[i] = 0x12 + } + if m.BtcPk != nil { + { + size := m.BtcPk.Size() + i -= size + if _, err := m.BtcPk.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintFinality(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil } func (m *IndexedBlock) Marshal() (dAtA []byte, err error) { @@ -615,18 +1060,102 @@ func encodeVarintFinality(dAtA []byte, offset int, v uint64) int { dAtA[offset] = uint8(v) return base } -func (m *IndexedBlock) Size() (n int) { +func (m *VotingPowerDistCache) Size() (n int) { if m == nil { return 0 } var l int _ = l - if m.Height != 0 { - n += 1 + sovFinality(uint64(m.Height)) + if m.TotalVotingPower != 0 { + n += 1 + sovFinality(uint64(m.TotalVotingPower)) } - l = len(m.AppHash) - if l > 0 { - n += 1 + l + sovFinality(uint64(l)) + if len(m.FinalityProviders) > 0 { + for _, e := range m.FinalityProviders { + l = e.Size() + n += 1 + l + sovFinality(uint64(l)) + } + } + if m.NumActiveFps != 0 { + n += 1 + sovFinality(uint64(m.NumActiveFps)) + } + return n +} + +func (m *FinalityProviderDistInfo) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.BtcPk != nil { + l = m.BtcPk.Size() + n += 1 + l + sovFinality(uint64(l)) + } + l = len(m.Addr) + if l > 0 { + n += 1 + l + sovFinality(uint64(l)) + } + if m.Commission != nil { + l = m.Commission.Size() + n += 1 + l + sovFinality(uint64(l)) + } + if m.TotalBondedSat != 0 { + n += 1 + sovFinality(uint64(m.TotalBondedSat)) + } + if len(m.BtcDels) > 0 { + for _, e := range m.BtcDels { + l = e.Size() + n += 1 + l + sovFinality(uint64(l)) + } + } + if m.IsTimestamped { + n += 2 + } + if m.IsJailed { + n += 2 + } + if m.IsSlashed { + n += 2 + } + return n +} + +func (m *BTCDelDistInfo) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.BtcPk != nil { + l = m.BtcPk.Size() + n += 1 + l + sovFinality(uint64(l)) + } + l = len(m.StakerAddr) + if l > 0 { + n += 1 + l + sovFinality(uint64(l)) + } + l = len(m.StakingTxHash) + if l > 0 { + n += 1 + l + sovFinality(uint64(l)) + } + if m.TotalSat != 0 { + n += 1 + sovFinality(uint64(m.TotalSat)) + } + return n +} + +func (m *IndexedBlock) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.Height != 0 { + n += 1 + sovFinality(uint64(m.Height)) + } + l = len(m.AppHash) + if l > 0 { + n += 1 + l + sovFinality(uint64(l)) } if m.Finalized { n += 2 @@ -719,6 +1248,564 @@ func sovFinality(x uint64) (n int) { func sozFinality(x uint64) (n int) { return sovFinality(uint64((x << 1) ^ uint64((int64(x) >> 63)))) } +func (m *VotingPowerDistCache) 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 ErrIntOverflowFinality + } + 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: VotingPowerDistCache: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: VotingPowerDistCache: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field TotalVotingPower", wireType) + } + m.TotalVotingPower = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowFinality + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.TotalVotingPower |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field FinalityProviders", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowFinality + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthFinality + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthFinality + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.FinalityProviders = append(m.FinalityProviders, &FinalityProviderDistInfo{}) + if err := m.FinalityProviders[len(m.FinalityProviders)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 3: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field NumActiveFps", wireType) + } + m.NumActiveFps = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowFinality + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.NumActiveFps |= uint32(b&0x7F) << shift + if b < 0x80 { + break + } + } + default: + iNdEx = preIndex + skippy, err := skipFinality(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthFinality + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *FinalityProviderDistInfo) 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 ErrIntOverflowFinality + } + 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: FinalityProviderDistInfo: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: FinalityProviderDistInfo: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field BtcPk", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowFinality + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthFinality + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthFinality + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + var v github_com_babylonlabs_io_babylon_types.BIP340PubKey + m.BtcPk = &v + if err := m.BtcPk.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Addr", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowFinality + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthFinality + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthFinality + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Addr = append(m.Addr[:0], dAtA[iNdEx:postIndex]...) + if m.Addr == nil { + m.Addr = []byte{} + } + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Commission", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowFinality + } + 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 ErrInvalidLengthFinality + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthFinality + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + var v cosmossdk_io_math.LegacyDec + m.Commission = &v + if err := m.Commission.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 4: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field TotalBondedSat", wireType) + } + m.TotalBondedSat = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowFinality + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.TotalBondedSat |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 5: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field BtcDels", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowFinality + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthFinality + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthFinality + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.BtcDels = append(m.BtcDels, &BTCDelDistInfo{}) + if err := m.BtcDels[len(m.BtcDels)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 6: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field IsTimestamped", wireType) + } + var v int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowFinality + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + v |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + m.IsTimestamped = bool(v != 0) + case 7: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field IsJailed", wireType) + } + var v int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowFinality + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + v |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + m.IsJailed = bool(v != 0) + case 8: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field IsSlashed", wireType) + } + var v int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowFinality + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + v |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + m.IsSlashed = bool(v != 0) + default: + iNdEx = preIndex + skippy, err := skipFinality(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthFinality + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *BTCDelDistInfo) 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 ErrIntOverflowFinality + } + 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: BTCDelDistInfo: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: BTCDelDistInfo: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field BtcPk", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowFinality + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthFinality + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthFinality + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + var v github_com_babylonlabs_io_babylon_types.BIP340PubKey + m.BtcPk = &v + if err := m.BtcPk.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field StakerAddr", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowFinality + } + 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 ErrInvalidLengthFinality + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthFinality + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.StakerAddr = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field StakingTxHash", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowFinality + } + 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 ErrInvalidLengthFinality + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthFinality + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.StakingTxHash = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 4: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field TotalSat", wireType) + } + m.TotalSat = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowFinality + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.TotalSat |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + default: + iNdEx = preIndex + skippy, err := skipFinality(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthFinality + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} func (m *IndexedBlock) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 diff --git a/x/finality/types/genesis.pb.go b/x/finality/types/genesis.pb.go index 6707ca5ab..97bda62d0 100644 --- a/x/finality/types/genesis.pb.go +++ b/x/finality/types/genesis.pb.go @@ -34,9 +34,9 @@ type GenesisState struct { Evidences []*Evidence `protobuf:"bytes,3,rep,name=evidences,proto3" json:"evidences,omitempty"` // votes_sigs contains all the votes of finality providers ever registered. VoteSigs []*VoteSig `protobuf:"bytes,4,rep,name=vote_sigs,json=voteSigs,proto3" json:"vote_sigs,omitempty"` - // public_randomness contains all the public randomness ever commited from the finality providers. + // public_randomness contains all the public randomness ever committed from the finality providers. PublicRandomness []*PublicRandomness `protobuf:"bytes,5,rep,name=public_randomness,json=publicRandomness,proto3" json:"public_randomness,omitempty"` - // pub_rand_commit contains all the public randomness commitment ever commited from the finality providers. + // pub_rand_commit contains all the public randomness commitment ever committed from the finality providers. PubRandCommit []*PubRandCommitWithPK `protobuf:"bytes,6,rep,name=pub_rand_commit,json=pubRandCommit,proto3" json:"pub_rand_commit,omitempty"` // signing_infos represents a map between finality provider public key and their // signing infos. @@ -44,6 +44,10 @@ type GenesisState struct { // missed_blocks represents a map between finality provider public key and their // missed blocks. MissedBlocks []FinalityProviderMissedBlocks `protobuf:"bytes,8,rep,name=missed_blocks,json=missedBlocks,proto3" json:"missed_blocks"` + // voting_powers the voting power of every finality provider at every block height. + VotingPowers []*VotingPowerFP `protobuf:"bytes,9,rep,name=voting_powers,json=votingPowers,proto3" json:"voting_powers,omitempty"` + // vp_dst_cache is the table of all providers voting power with the total at one specific block. + VpDstCache []*VotingPowerDistCacheBlkHeight `protobuf:"bytes,10,rep,name=vp_dst_cache,json=vpDstCache,proto3" json:"vp_dst_cache,omitempty"` } func (m *GenesisState) Reset() { *m = GenesisState{} } @@ -135,6 +139,20 @@ func (m *GenesisState) GetMissedBlocks() []FinalityProviderMissedBlocks { return nil } +func (m *GenesisState) GetVotingPowers() []*VotingPowerFP { + if m != nil { + return m.VotingPowers + } + return nil +} + +func (m *GenesisState) GetVpDstCache() []*VotingPowerDistCacheBlkHeight { + if m != nil { + return m.VpDstCache + } + return nil +} + // VoteSig the vote of an finality provider // with the block of the vote, the finality provider btc public key and the vote signature. type VoteSig struct { @@ -189,7 +207,7 @@ func (m *VoteSig) GetBlockHeight() uint64 { // PublicRandomness the block height and public randomness that the finality provider has submitted. type PublicRandomness struct { - // block_height is the height of block which the finality provider submited public randomness. + // block_height is the height of block which the finality provider submitted public randomness. BlockHeight uint64 `protobuf:"varint,1,opt,name=block_height,json=blockHeight,proto3" json:"block_height,omitempty"` // fp_btc_pk is the BTC PK of the finality provider that casts this vote. FpBtcPk *github_com_babylonlabs_io_babylon_types.BIP340PubKey `protobuf:"bytes,2,opt,name=fp_btc_pk,json=fpBtcPk,proto3,customtype=github.com/babylonlabs-io/babylon/types.BIP340PubKey" json:"fp_btc_pk,omitempty"` @@ -437,6 +455,119 @@ func (m *MissedBlock) GetMissed() bool { return false } +// VotingPowerFP contains the information about the voting power +// of an finality provider in a specific block height. +type VotingPowerFP struct { + // block_height is the height of the block the voting power was stored. + BlockHeight uint64 `protobuf:"varint,1,opt,name=block_height,json=blockHeight,proto3" json:"block_height,omitempty"` + // fp_btc_pk the finality provider btc public key. + FpBtcPk *github_com_babylonlabs_io_babylon_types.BIP340PubKey `protobuf:"bytes,2,opt,name=fp_btc_pk,json=fpBtcPk,proto3,customtype=github.com/babylonlabs-io/babylon/types.BIP340PubKey" json:"fp_btc_pk,omitempty"` + // voting_power is the power of the finality provider at this specific block height. + VotingPower uint64 `protobuf:"varint,3,opt,name=voting_power,json=votingPower,proto3" json:"voting_power,omitempty"` +} + +func (m *VotingPowerFP) Reset() { *m = VotingPowerFP{} } +func (m *VotingPowerFP) String() string { return proto.CompactTextString(m) } +func (*VotingPowerFP) ProtoMessage() {} +func (*VotingPowerFP) Descriptor() ([]byte, []int) { + return fileDescriptor_52dc577f74d797d1, []int{7} +} +func (m *VotingPowerFP) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *VotingPowerFP) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_VotingPowerFP.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 *VotingPowerFP) XXX_Merge(src proto.Message) { + xxx_messageInfo_VotingPowerFP.Merge(m, src) +} +func (m *VotingPowerFP) XXX_Size() int { + return m.Size() +} +func (m *VotingPowerFP) XXX_DiscardUnknown() { + xxx_messageInfo_VotingPowerFP.DiscardUnknown(m) +} + +var xxx_messageInfo_VotingPowerFP proto.InternalMessageInfo + +func (m *VotingPowerFP) GetBlockHeight() uint64 { + if m != nil { + return m.BlockHeight + } + return 0 +} + +func (m *VotingPowerFP) GetVotingPower() uint64 { + if m != nil { + return m.VotingPower + } + return 0 +} + +// VotingPowerDistCacheBlkHeight the total voting power of the finality providers at one specific block height +type VotingPowerDistCacheBlkHeight struct { + // block_height is the height of the block the voting power distribution cached was stored. + BlockHeight uint64 `protobuf:"varint,1,opt,name=block_height,json=blockHeight,proto3" json:"block_height,omitempty"` + // vp_distribution the finality providers distribution cache at that height. + VpDistribution *VotingPowerDistCache `protobuf:"bytes,2,opt,name=vp_distribution,json=vpDistribution,proto3" json:"vp_distribution,omitempty"` +} + +func (m *VotingPowerDistCacheBlkHeight) Reset() { *m = VotingPowerDistCacheBlkHeight{} } +func (m *VotingPowerDistCacheBlkHeight) String() string { return proto.CompactTextString(m) } +func (*VotingPowerDistCacheBlkHeight) ProtoMessage() {} +func (*VotingPowerDistCacheBlkHeight) Descriptor() ([]byte, []int) { + return fileDescriptor_52dc577f74d797d1, []int{8} +} +func (m *VotingPowerDistCacheBlkHeight) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *VotingPowerDistCacheBlkHeight) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_VotingPowerDistCacheBlkHeight.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 *VotingPowerDistCacheBlkHeight) XXX_Merge(src proto.Message) { + xxx_messageInfo_VotingPowerDistCacheBlkHeight.Merge(m, src) +} +func (m *VotingPowerDistCacheBlkHeight) XXX_Size() int { + return m.Size() +} +func (m *VotingPowerDistCacheBlkHeight) XXX_DiscardUnknown() { + xxx_messageInfo_VotingPowerDistCacheBlkHeight.DiscardUnknown(m) +} + +var xxx_messageInfo_VotingPowerDistCacheBlkHeight proto.InternalMessageInfo + +func (m *VotingPowerDistCacheBlkHeight) GetBlockHeight() uint64 { + if m != nil { + return m.BlockHeight + } + return 0 +} + +func (m *VotingPowerDistCacheBlkHeight) GetVpDistribution() *VotingPowerDistCache { + if m != nil { + return m.VpDistribution + } + return nil +} + func init() { proto.RegisterType((*GenesisState)(nil), "babylon.finality.v1.GenesisState") proto.RegisterType((*VoteSig)(nil), "babylon.finality.v1.VoteSig") @@ -445,56 +576,66 @@ func init() { proto.RegisterType((*SigningInfo)(nil), "babylon.finality.v1.SigningInfo") proto.RegisterType((*FinalityProviderMissedBlocks)(nil), "babylon.finality.v1.FinalityProviderMissedBlocks") proto.RegisterType((*MissedBlock)(nil), "babylon.finality.v1.MissedBlock") + proto.RegisterType((*VotingPowerFP)(nil), "babylon.finality.v1.VotingPowerFP") + proto.RegisterType((*VotingPowerDistCacheBlkHeight)(nil), "babylon.finality.v1.VotingPowerDistCacheBlkHeight") } func init() { proto.RegisterFile("babylon/finality/v1/genesis.proto", fileDescriptor_52dc577f74d797d1) } var fileDescriptor_52dc577f74d797d1 = []byte{ - // 693 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xc4, 0x95, 0xcf, 0x6f, 0xd3, 0x4a, - 0x10, 0xc7, 0xe3, 0x24, 0x4d, 0xd2, 0x4d, 0xf2, 0xda, 0xb7, 0xad, 0x9e, 0xac, 0xbe, 0x92, 0xa6, - 0x96, 0x90, 0x72, 0xc1, 0xe9, 0x2f, 0x21, 0x4a, 0x6f, 0x41, 0x85, 0x96, 0x80, 0xb0, 0x36, 0x05, - 0x24, 0x04, 0x58, 0xb6, 0xb3, 0x76, 0x56, 0x8d, 0xbd, 0x96, 0x77, 0x13, 0x35, 0xff, 0x05, 0xff, - 0x0d, 0x67, 0xc4, 0xa5, 0xc7, 0x1e, 0x51, 0x85, 0x2a, 0x48, 0xff, 0x11, 0x94, 0xb5, 0xd3, 0x98, - 0xd4, 0xb4, 0x95, 0xa0, 0xe2, 0xb6, 0x3b, 0xf9, 0xce, 0x27, 0x33, 0xb3,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, 0x57, 0x40, 0xd1, 0xad, - 0xf1, 0xec, 0x78, 0x58, 0x91, 0x4e, 0x86, 0x15, 0xe9, 0xdb, 0xb0, 0x22, 0x7d, 0x38, 0xaf, 0xa4, - 0x4e, 0xce, 0x2b, 0xa9, 0x2f, 0xe7, 0x95, 0xd4, 0x9b, 0x8d, 0xeb, 0x53, 0x3c, 0x9a, 0x7c, 0x02, - 0x45, 0xb6, 0x66, 0x4e, 0x7c, 0xfd, 0x36, 0x7f, 0x04, 0x00, 0x00, 0xff, 0xff, 0xae, 0x0d, 0xf5, - 0xca, 0x93, 0x07, 0x00, 0x00, + // 824 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xc4, 0x96, 0x4d, 0x6f, 0xe3, 0x44, + 0x18, 0xc7, 0xe3, 0x24, 0xcd, 0xcb, 0xc4, 0xd9, 0x2e, 0xb3, 0x2b, 0x64, 0x95, 0xdd, 0x34, 0xb1, + 0x84, 0x14, 0x0e, 0x24, 0xdb, 0xec, 0x0a, 0xb1, 0xec, 0x2d, 0xdb, 0x7d, 0x29, 0x01, 0x61, 0x4d, + 0x0a, 0x48, 0x08, 0xb0, 0x6c, 0x67, 0xe2, 0x8c, 0x92, 0x78, 0x46, 0x9e, 0x89, 0xd9, 0x7c, 0x0b, + 0x4e, 0x7c, 0x09, 0x3e, 0x00, 0x67, 0xc4, 0xa5, 0xc7, 0x1e, 0x51, 0x0f, 0x15, 0xa4, 0x1f, 0x83, + 0x0b, 0xf2, 0xd8, 0x69, 0xdc, 0xd4, 0x6d, 0x23, 0x41, 0xd5, 0xdb, 0xcc, 0x93, 0xff, 0xf3, 0xd3, + 0x33, 0x33, 0xcf, 0xf3, 0x8f, 0x41, 0xc3, 0xb6, 0xec, 0xf9, 0x84, 0x7a, 0xed, 0x21, 0xf1, 0xac, + 0x09, 0x11, 0xf3, 0x76, 0xb0, 0xd7, 0x76, 0xb1, 0x87, 0x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xf0, 0xe8, 0x3a, 0x73, + 0xb8, 0xa5, 0x63, 0xf5, 0xd6, 0xcd, 0x2b, 0x7b, 0x8d, 0x13, 0x26, 0xea, 0x49, 0xf3, 0x2a, 0xfd, + 0x05, 0xa8, 0x24, 0x24, 0xf0, 0x21, 0xd8, 0x92, 0x7f, 0x4a, 0xb2, 0xda, 0x1c, 0x8a, 0x36, 0xf0, + 0x7d, 0x50, 0x88, 0x92, 0xe4, 0xfd, 0x95, 0x50, 0xbc, 0xd3, 0x7f, 0x55, 0x40, 0xf5, 0x82, 0x7f, + 0xdd, 0xdd, 0x88, 0x35, 0x80, 0x9a, 0xf4, 0x5c, 0x39, 0x66, 0x79, 0x54, 0x49, 0xd8, 0xa9, 0xfe, + 0x8b, 0x02, 0x1e, 0x5f, 0xeb, 0x92, 0x9b, 0x54, 0x8f, 0xc0, 0x76, 0x68, 0xc9, 0x84, 0x0b, 0x9f, + 0xd8, 0x33, 0x41, 0xa8, 0x17, 0xf7, 0xd4, 0x47, 0x1b, 0xbb, 0x32, 0xba, 0x17, 0xb0, 0xfd, 0x04, + 0xa0, 0xfb, 0xc5, 0xd1, 0xa2, 0xa6, 0x1c, 0x2f, 0x6a, 0xca, 0x5f, 0x8b, 0x9a, 0xf2, 0xf3, 0x59, + 0x2d, 0x73, 0x7c, 0x56, 0xcb, 0xfc, 0x79, 0x56, 0xcb, 0x7c, 0xd7, 0xb9, 0xf9, 0x52, 0xde, 0xad, + 0x3e, 0x74, 0xe4, 0xfd, 0xd8, 0x05, 0xf9, 0x8d, 0xf3, 0xf4, 0xdf, 0x00, 0x00, 0x00, 0xff, 0xff, + 0x47, 0x03, 0xe3, 0xd4, 0x79, 0x09, 0x00, 0x00, } func (m *GenesisState) Marshal() (dAtA []byte, err error) { @@ -517,6 +658,34 @@ func (m *GenesisState) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l + if len(m.VpDstCache) > 0 { + for iNdEx := len(m.VpDstCache) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.VpDstCache[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintGenesis(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x52 + } + } + if len(m.VotingPowers) > 0 { + for iNdEx := len(m.VotingPowers) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.VotingPowers[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintGenesis(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x4a + } + } if len(m.MissedBlocks) > 0 { for iNdEx := len(m.MissedBlocks) - 1; iNdEx >= 0; iNdEx-- { { @@ -911,6 +1080,91 @@ func (m *MissedBlock) MarshalToSizedBuffer(dAtA []byte) (int, error) { return len(dAtA) - i, nil } +func (m *VotingPowerFP) 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 *VotingPowerFP) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *VotingPowerFP) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.VotingPower != 0 { + i = encodeVarintGenesis(dAtA, i, uint64(m.VotingPower)) + i-- + dAtA[i] = 0x18 + } + if m.FpBtcPk != nil { + { + size := m.FpBtcPk.Size() + i -= size + if _, err := m.FpBtcPk.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintGenesis(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + } + if m.BlockHeight != 0 { + i = encodeVarintGenesis(dAtA, i, uint64(m.BlockHeight)) + i-- + dAtA[i] = 0x8 + } + return len(dAtA) - i, nil +} + +func (m *VotingPowerDistCacheBlkHeight) 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 *VotingPowerDistCacheBlkHeight) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *VotingPowerDistCacheBlkHeight) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.VpDistribution != nil { + { + size, err := m.VpDistribution.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintGenesis(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + } + if m.BlockHeight != 0 { + i = encodeVarintGenesis(dAtA, i, uint64(m.BlockHeight)) + i-- + dAtA[i] = 0x8 + } + return len(dAtA) - i, nil +} + func encodeVarintGenesis(dAtA []byte, offset int, v uint64) int { offset -= sovGenesis(v) base := offset @@ -972,6 +1226,18 @@ func (m *GenesisState) Size() (n int) { n += 1 + l + sovGenesis(uint64(l)) } } + if len(m.VotingPowers) > 0 { + for _, e := range m.VotingPowers { + l = e.Size() + n += 1 + l + sovGenesis(uint64(l)) + } + } + if len(m.VpDstCache) > 0 { + for _, e := range m.VpDstCache { + l = e.Size() + n += 1 + l + sovGenesis(uint64(l)) + } + } return n } @@ -1081,6 +1347,41 @@ func (m *MissedBlock) Size() (n int) { return n } +func (m *VotingPowerFP) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.BlockHeight != 0 { + n += 1 + sovGenesis(uint64(m.BlockHeight)) + } + if m.FpBtcPk != nil { + l = m.FpBtcPk.Size() + n += 1 + l + sovGenesis(uint64(l)) + } + if m.VotingPower != 0 { + n += 1 + sovGenesis(uint64(m.VotingPower)) + } + return n +} + +func (m *VotingPowerDistCacheBlkHeight) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.BlockHeight != 0 { + n += 1 + sovGenesis(uint64(m.BlockHeight)) + } + if m.VpDistribution != nil { + l = m.VpDistribution.Size() + n += 1 + l + sovGenesis(uint64(l)) + } + return n +} + func sovGenesis(x uint64) (n int) { return (math_bits.Len64(x|1) + 6) / 7 } @@ -1387,6 +1688,74 @@ func (m *GenesisState) Unmarshal(dAtA []byte) error { return err } iNdEx = postIndex + case 9: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field VotingPowers", 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.VotingPowers = append(m.VotingPowers, &VotingPowerFP{}) + if err := m.VotingPowers[len(m.VotingPowers)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 10: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field VpDstCache", 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.VpDstCache = append(m.VpDstCache, &VotingPowerDistCacheBlkHeight{}) + if err := m.VpDstCache[len(m.VpDstCache)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex default: iNdEx = preIndex skippy, err := skipGenesis(dAtA[iNdEx:]) @@ -2133,6 +2502,234 @@ func (m *MissedBlock) Unmarshal(dAtA []byte) error { } return nil } +func (m *VotingPowerFP) 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: VotingPowerFP: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: VotingPowerFP: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field BlockHeight", wireType) + } + m.BlockHeight = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenesis + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.BlockHeight |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field FpBtcPk", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenesis + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthGenesis + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthGenesis + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + var v github_com_babylonlabs_io_babylon_types.BIP340PubKey + m.FpBtcPk = &v + if err := m.FpBtcPk.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 3: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field VotingPower", wireType) + } + m.VotingPower = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenesis + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.VotingPower |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + 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 *VotingPowerDistCacheBlkHeight) 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: VotingPowerDistCacheBlkHeight: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: VotingPowerDistCacheBlkHeight: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field BlockHeight", wireType) + } + m.BlockHeight = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenesis + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.BlockHeight |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field VpDistribution", 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.VpDistribution == nil { + m.VpDistribution = &VotingPowerDistCache{} + } + if err := m.VpDistribution.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 skipGenesis(dAtA []byte) (n int, err error) { l := len(dAtA) iNdEx := 0 diff --git a/x/finality/types/hooks.go b/x/finality/types/hooks.go deleted file mode 100644 index d87591ab8..000000000 --- a/x/finality/types/hooks.go +++ /dev/null @@ -1,26 +0,0 @@ -package types - -import ( - "context" - - "github.com/babylonlabs-io/babylon/types" -) - -// combine multiple finality hooks, all hook functions are run in array sequence -var _ FinalityHooks = &MultiFinalityHooks{} - -type MultiFinalityHooks []FinalityHooks - -func NewMultiFinalityHooks(hooks ...FinalityHooks) MultiFinalityHooks { - return hooks -} - -func (h MultiFinalityHooks) AfterSluggishFinalityProviderDetected(ctx context.Context, btcPk *types.BIP340PubKey) error { - for i := range h { - if err := h[i].AfterSluggishFinalityProviderDetected(ctx, btcPk); err != nil { - return err - } - } - - return nil -} diff --git a/x/finality/types/keys.go b/x/finality/types/keys.go index 96b9fc331..8adaa365c 100644 --- a/x/finality/types/keys.go +++ b/x/finality/types/keys.go @@ -47,4 +47,6 @@ var ( NextHeightToFinalizeKey = []byte{0x07} // key prefix for next height to finalise FinalityProviderSigningInfoKeyPrefix = collections.NewPrefix(8) // key prefix for signing info FinalityProviderMissedBlockBitmapKeyPrefix = collections.NewPrefix(9) // key prefix for missed block bitmap + VotingPowerKey = []byte{0x10} // key prefix for the voting power + VotingPowerDistCacheKey = []byte{0x11} // key prefix for voting power distribution cache ) diff --git a/x/finality/types/mocked_keepers.go b/x/finality/types/mocked_keepers.go index c394199f4..6eb636d1b 100644 --- a/x/finality/types/mocked_keepers.go +++ b/x/finality/types/mocked_keepers.go @@ -11,6 +11,7 @@ import ( types "github.com/babylonlabs-io/babylon/types" types0 "github.com/babylonlabs-io/babylon/x/btcstaking/types" types1 "github.com/babylonlabs-io/babylon/x/epoching/types" + types2 "github.com/cosmos/cosmos-sdk/types" gomock "github.com/golang/mock/gomock" ) @@ -37,91 +38,102 @@ func (m *MockBTCStakingKeeper) EXPECT() *MockBTCStakingKeeperMockRecorder { return m.recorder } -// GetBTCStakingActivatedHeight mocks base method. -func (m *MockBTCStakingKeeper) GetBTCStakingActivatedHeight(ctx context.Context) (uint64, error) { +// ClearPowerDistUpdateEvents mocks base method. +func (m *MockBTCStakingKeeper) ClearPowerDistUpdateEvents(ctx context.Context, btcHeight uint32) { m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "GetBTCStakingActivatedHeight", ctx) - ret0, _ := ret[0].(uint64) - ret1, _ := ret[1].(error) - return ret0, ret1 + m.ctrl.Call(m, "ClearPowerDistUpdateEvents", ctx, btcHeight) } -// GetBTCStakingActivatedHeight indicates an expected call of GetBTCStakingActivatedHeight. -func (mr *MockBTCStakingKeeperMockRecorder) GetBTCStakingActivatedHeight(ctx interface{}) *gomock.Call { +// ClearPowerDistUpdateEvents indicates an expected call of ClearPowerDistUpdateEvents. +func (mr *MockBTCStakingKeeperMockRecorder) ClearPowerDistUpdateEvents(ctx, btcHeight interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetBTCStakingActivatedHeight", reflect.TypeOf((*MockBTCStakingKeeper)(nil).GetBTCStakingActivatedHeight), ctx) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ClearPowerDistUpdateEvents", reflect.TypeOf((*MockBTCStakingKeeper)(nil).ClearPowerDistUpdateEvents), ctx, btcHeight) } -// GetFinalityProvider mocks base method. -func (m *MockBTCStakingKeeper) GetFinalityProvider(ctx context.Context, fpBTCPK []byte) (*types0.FinalityProvider, error) { +// GetAllPowerDistUpdateEvents mocks base method. +func (m *MockBTCStakingKeeper) GetAllPowerDistUpdateEvents(ctx context.Context, lastBTCTipHeight, btcTipHeight uint32) []*types0.EventPowerDistUpdate { m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "GetFinalityProvider", ctx, fpBTCPK) - ret0, _ := ret[0].(*types0.FinalityProvider) + ret := m.ctrl.Call(m, "GetAllPowerDistUpdateEvents", ctx, lastBTCTipHeight, btcTipHeight) + ret0, _ := ret[0].([]*types0.EventPowerDistUpdate) + return ret0 +} + +// GetAllPowerDistUpdateEvents indicates an expected call of GetAllPowerDistUpdateEvents. +func (mr *MockBTCStakingKeeperMockRecorder) GetAllPowerDistUpdateEvents(ctx, lastBTCTipHeight, btcTipHeight interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetAllPowerDistUpdateEvents", reflect.TypeOf((*MockBTCStakingKeeper)(nil).GetAllPowerDistUpdateEvents), ctx, lastBTCTipHeight, btcTipHeight) +} + +// GetBTCDelegation mocks base method. +func (m *MockBTCStakingKeeper) GetBTCDelegation(ctx context.Context, stakingTxHashStr string) (*types0.BTCDelegation, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "GetBTCDelegation", ctx, stakingTxHashStr) + ret0, _ := ret[0].(*types0.BTCDelegation) ret1, _ := ret[1].(error) return ret0, ret1 } -// GetFinalityProvider indicates an expected call of GetFinalityProvider. -func (mr *MockBTCStakingKeeperMockRecorder) GetFinalityProvider(ctx, fpBTCPK interface{}) *gomock.Call { +// GetBTCDelegation indicates an expected call of GetBTCDelegation. +func (mr *MockBTCStakingKeeperMockRecorder) GetBTCDelegation(ctx, stakingTxHashStr interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetFinalityProvider", reflect.TypeOf((*MockBTCStakingKeeper)(nil).GetFinalityProvider), ctx, fpBTCPK) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetBTCDelegation", reflect.TypeOf((*MockBTCStakingKeeper)(nil).GetBTCDelegation), ctx, stakingTxHashStr) } -// GetParams mocks base method. -func (m *MockBTCStakingKeeper) GetParams(ctx context.Context) types0.Params { +// GetBTCHeightAtBabylonHeight mocks base method. +func (m *MockBTCStakingKeeper) GetBTCHeightAtBabylonHeight(ctx context.Context, babylonHeight uint64) uint32 { m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "GetParams", ctx) - ret0, _ := ret[0].(types0.Params) + ret := m.ctrl.Call(m, "GetBTCHeightAtBabylonHeight", ctx, babylonHeight) + ret0, _ := ret[0].(uint32) return ret0 } -// GetParams indicates an expected call of GetParams. -func (mr *MockBTCStakingKeeperMockRecorder) GetParams(ctx interface{}) *gomock.Call { +// GetBTCHeightAtBabylonHeight indicates an expected call of GetBTCHeightAtBabylonHeight. +func (mr *MockBTCStakingKeeperMockRecorder) GetBTCHeightAtBabylonHeight(ctx, babylonHeight interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetParams", reflect.TypeOf((*MockBTCStakingKeeper)(nil).GetParams), ctx) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetBTCHeightAtBabylonHeight", reflect.TypeOf((*MockBTCStakingKeeper)(nil).GetBTCHeightAtBabylonHeight), ctx, babylonHeight) } -// GetVotingPower mocks base method. -func (m *MockBTCStakingKeeper) GetVotingPower(ctx context.Context, fpBTCPK []byte, height uint64) uint64 { +// GetCurrentBTCHeight mocks base method. +func (m *MockBTCStakingKeeper) GetCurrentBTCHeight(ctx context.Context) uint32 { m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "GetVotingPower", ctx, fpBTCPK, height) - ret0, _ := ret[0].(uint64) + ret := m.ctrl.Call(m, "GetCurrentBTCHeight", ctx) + ret0, _ := ret[0].(uint32) return ret0 } -// GetVotingPower indicates an expected call of GetVotingPower. -func (mr *MockBTCStakingKeeperMockRecorder) GetVotingPower(ctx, fpBTCPK, height interface{}) *gomock.Call { +// GetCurrentBTCHeight indicates an expected call of GetCurrentBTCHeight. +func (mr *MockBTCStakingKeeperMockRecorder) GetCurrentBTCHeight(ctx interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetVotingPower", reflect.TypeOf((*MockBTCStakingKeeper)(nil).GetVotingPower), ctx, fpBTCPK, height) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetCurrentBTCHeight", reflect.TypeOf((*MockBTCStakingKeeper)(nil).GetCurrentBTCHeight), ctx) } -// GetVotingPowerDistCache mocks base method. -func (m *MockBTCStakingKeeper) GetVotingPowerDistCache(ctx context.Context, height uint64) (*types0.VotingPowerDistCache, error) { +// GetFinalityProvider mocks base method. +func (m *MockBTCStakingKeeper) GetFinalityProvider(ctx context.Context, fpBTCPK []byte) (*types0.FinalityProvider, error) { m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "GetVotingPowerDistCache", ctx, height) - ret0, _ := ret[0].(*types0.VotingPowerDistCache) + ret := m.ctrl.Call(m, "GetFinalityProvider", ctx, fpBTCPK) + ret0, _ := ret[0].(*types0.FinalityProvider) ret1, _ := ret[1].(error) return ret0, ret1 } -// GetVotingPowerDistCache indicates an expected call of GetVotingPowerDistCache. -func (mr *MockBTCStakingKeeperMockRecorder) GetVotingPowerDistCache(ctx, height interface{}) *gomock.Call { +// GetFinalityProvider indicates an expected call of GetFinalityProvider. +func (mr *MockBTCStakingKeeperMockRecorder) GetFinalityProvider(ctx, fpBTCPK interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetVotingPowerDistCache", reflect.TypeOf((*MockBTCStakingKeeper)(nil).GetVotingPowerDistCache), ctx, height) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetFinalityProvider", reflect.TypeOf((*MockBTCStakingKeeper)(nil).GetFinalityProvider), ctx, fpBTCPK) } -// GetVotingPowerTable mocks base method. -func (m *MockBTCStakingKeeper) GetVotingPowerTable(ctx context.Context, height uint64) map[string]uint64 { +// GetParams mocks base method. +func (m *MockBTCStakingKeeper) GetParams(ctx context.Context) types0.Params { m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "GetVotingPowerTable", ctx, height) - ret0, _ := ret[0].(map[string]uint64) + ret := m.ctrl.Call(m, "GetParams", ctx) + ret0, _ := ret[0].(types0.Params) return ret0 } -// GetVotingPowerTable indicates an expected call of GetVotingPowerTable. -func (mr *MockBTCStakingKeeperMockRecorder) GetVotingPowerTable(ctx, height interface{}) *gomock.Call { +// GetParams indicates an expected call of GetParams. +func (mr *MockBTCStakingKeeperMockRecorder) GetParams(ctx interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetVotingPowerTable", reflect.TypeOf((*MockBTCStakingKeeper)(nil).GetVotingPowerTable), ctx, height) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetParams", reflect.TypeOf((*MockBTCStakingKeeper)(nil).GetParams), ctx) } // HasFinalityProvider mocks base method. @@ -138,30 +150,32 @@ func (mr *MockBTCStakingKeeperMockRecorder) HasFinalityProvider(ctx, fpBTCPK int return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "HasFinalityProvider", reflect.TypeOf((*MockBTCStakingKeeper)(nil).HasFinalityProvider), ctx, fpBTCPK) } -// PropagateFPSlashingToConsumers mocks base method. -func (m *MockBTCStakingKeeper) PropagateFPSlashingToConsumers(ctx context.Context, fpBTCPK *types.BIP340PubKey) error { +// JailFinalityProvider mocks base method. +func (m *MockBTCStakingKeeper) JailFinalityProvider(ctx context.Context, fpBTCPK []byte) error { m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "PropagateFPSlashingToConsumers", ctx, fpBTCPK) + ret := m.ctrl.Call(m, "JailFinalityProvider", ctx, fpBTCPK) ret0, _ := ret[0].(error) return ret0 } -// PropagateFPSlashingToConsumers indicates an expected call of PropagateFPSlashingToConsumers. -func (mr *MockBTCStakingKeeperMockRecorder) PropagateFPSlashingToConsumers(ctx, fpBTCPK interface{}) *gomock.Call { +// JailFinalityProvider indicates an expected call of JailFinalityProvider. +func (mr *MockBTCStakingKeeperMockRecorder) JailFinalityProvider(ctx, fpBTCPK interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "PropagateFPSlashingToConsumers", reflect.TypeOf((*MockBTCStakingKeeper)(nil).PropagateFPSlashingToConsumers), ctx, fpBTCPK) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "JailFinalityProvider", reflect.TypeOf((*MockBTCStakingKeeper)(nil).JailFinalityProvider), ctx, fpBTCPK) } -// RemoveVotingPowerDistCache mocks base method. -func (m *MockBTCStakingKeeper) RemoveVotingPowerDistCache(ctx context.Context, height uint64) { +// PropagateFPSlashingToConsumers mocks base method. +func (m *MockBTCStakingKeeper) PropagateFPSlashingToConsumers(ctx context.Context, fpBTCPK *types.BIP340PubKey) error { m.ctrl.T.Helper() - m.ctrl.Call(m, "RemoveVotingPowerDistCache", ctx, height) + ret := m.ctrl.Call(m, "PropagateFPSlashingToConsumers", ctx, fpBTCPK) + ret0, _ := ret[0].(error) + return ret0 } -// RemoveVotingPowerDistCache indicates an expected call of RemoveVotingPowerDistCache. -func (mr *MockBTCStakingKeeperMockRecorder) RemoveVotingPowerDistCache(ctx, height interface{}) *gomock.Call { +// PropagateFPSlashingToConsumers indicates an expected call of PropagateFPSlashingToConsumers. +func (mr *MockBTCStakingKeeperMockRecorder) PropagateFPSlashingToConsumers(ctx, fpBTCPK interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "RemoveVotingPowerDistCache", reflect.TypeOf((*MockBTCStakingKeeper)(nil).RemoveVotingPowerDistCache), ctx, height) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "PropagateFPSlashingToConsumers", reflect.TypeOf((*MockBTCStakingKeeper)(nil).PropagateFPSlashingToConsumers), ctx, fpBTCPK) } // SlashFinalityProvider mocks base method. @@ -266,88 +280,26 @@ func (m *MockIncentiveKeeper) EXPECT() *MockIncentiveKeeperMockRecorder { return m.recorder } -// RewardBTCStaking mocks base method. -func (m *MockIncentiveKeeper) RewardBTCStaking(ctx context.Context, height uint64, filteredDc *types0.VotingPowerDistCache) { - m.ctrl.T.Helper() - m.ctrl.Call(m, "RewardBTCStaking", ctx, height, filteredDc) -} - -// RewardBTCStaking indicates an expected call of RewardBTCStaking. -func (mr *MockIncentiveKeeperMockRecorder) RewardBTCStaking(ctx, height, filteredDc interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "RewardBTCStaking", reflect.TypeOf((*MockIncentiveKeeper)(nil).RewardBTCStaking), ctx, height, filteredDc) -} - -// MockBtcStakingHooks is a mock of BtcStakingHooks interface. -type MockBtcStakingHooks struct { - ctrl *gomock.Controller - recorder *MockBtcStakingHooksMockRecorder -} - -// MockBtcStakingHooksMockRecorder is the mock recorder for MockBtcStakingHooks. -type MockBtcStakingHooksMockRecorder struct { - mock *MockBtcStakingHooks -} - -// NewMockBtcStakingHooks creates a new mock instance. -func NewMockBtcStakingHooks(ctrl *gomock.Controller) *MockBtcStakingHooks { - mock := &MockBtcStakingHooks{ctrl: ctrl} - mock.recorder = &MockBtcStakingHooksMockRecorder{mock} - return mock -} - -// EXPECT returns an object that allows the caller to indicate expected use. -func (m *MockBtcStakingHooks) EXPECT() *MockBtcStakingHooksMockRecorder { - return m.recorder -} - -// AfterFinalityProviderActivated mocks base method. -func (m *MockBtcStakingHooks) AfterFinalityProviderActivated(ctx context.Context, btcPk *types.BIP340PubKey) error { +// IndexRefundableMsg mocks base method. +func (m *MockIncentiveKeeper) IndexRefundableMsg(ctx context.Context, msg types2.Msg) { m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "AfterFinalityProviderActivated", ctx, btcPk) - ret0, _ := ret[0].(error) - return ret0 + m.ctrl.Call(m, "IndexRefundableMsg", ctx, msg) } -// AfterFinalityProviderActivated indicates an expected call of AfterFinalityProviderActivated. -func (mr *MockBtcStakingHooksMockRecorder) AfterFinalityProviderActivated(ctx, btcPk interface{}) *gomock.Call { +// IndexRefundableMsg indicates an expected call of IndexRefundableMsg. +func (mr *MockIncentiveKeeperMockRecorder) IndexRefundableMsg(ctx, msg interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "AfterFinalityProviderActivated", reflect.TypeOf((*MockBtcStakingHooks)(nil).AfterFinalityProviderActivated), ctx, btcPk) -} - -// MockFinalityHooks is a mock of FinalityHooks interface. -type MockFinalityHooks struct { - ctrl *gomock.Controller - recorder *MockFinalityHooksMockRecorder -} - -// MockFinalityHooksMockRecorder is the mock recorder for MockFinalityHooks. -type MockFinalityHooksMockRecorder struct { - mock *MockFinalityHooks -} - -// NewMockFinalityHooks creates a new mock instance. -func NewMockFinalityHooks(ctrl *gomock.Controller) *MockFinalityHooks { - mock := &MockFinalityHooks{ctrl: ctrl} - mock.recorder = &MockFinalityHooksMockRecorder{mock} - return mock -} - -// EXPECT returns an object that allows the caller to indicate expected use. -func (m *MockFinalityHooks) EXPECT() *MockFinalityHooksMockRecorder { - return m.recorder + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "IndexRefundableMsg", reflect.TypeOf((*MockIncentiveKeeper)(nil).IndexRefundableMsg), ctx, msg) } -// AfterSluggishFinalityProviderDetected mocks base method. -func (m *MockFinalityHooks) AfterSluggishFinalityProviderDetected(ctx context.Context, btcPk *types.BIP340PubKey) error { +// RewardBTCStaking mocks base method. +func (m *MockIncentiveKeeper) RewardBTCStaking(ctx context.Context, height uint64, filteredDc *VotingPowerDistCache) { m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "AfterSluggishFinalityProviderDetected", ctx, btcPk) - ret0, _ := ret[0].(error) - return ret0 + m.ctrl.Call(m, "RewardBTCStaking", ctx, height, filteredDc) } -// AfterSluggishFinalityProviderDetected indicates an expected call of AfterSluggishFinalityProviderDetected. -func (mr *MockFinalityHooksMockRecorder) AfterSluggishFinalityProviderDetected(ctx, btcPk interface{}) *gomock.Call { +// RewardBTCStaking indicates an expected call of RewardBTCStaking. +func (mr *MockIncentiveKeeperMockRecorder) RewardBTCStaking(ctx, height, filteredDc interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "AfterSluggishFinalityProviderDetected", reflect.TypeOf((*MockFinalityHooks)(nil).AfterSluggishFinalityProviderDetected), ctx, btcPk) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "RewardBTCStaking", reflect.TypeOf((*MockIncentiveKeeper)(nil).RewardBTCStaking), ctx, height, filteredDc) } diff --git a/x/finality/types/msg.go b/x/finality/types/msg.go index a92b1bbc9..177e9a817 100644 --- a/x/finality/types/msg.go +++ b/x/finality/types/msg.go @@ -4,6 +4,7 @@ import ( fmt "fmt" "github.com/babylonlabs-io/babylon/crypto/eots" + bbn "github.com/babylonlabs-io/babylon/types" "github.com/cometbft/cometbft/crypto/merkle" "github.com/cometbft/cometbft/crypto/tmhash" sdk "github.com/cosmos/cosmos-sdk/types" @@ -20,6 +21,30 @@ func (m *MsgAddFinalitySig) MsgToSign() []byte { return msgToSignForVote(m.BlockHeight, m.BlockAppHash) } +func (m *MsgAddFinalitySig) ValidateBasic() error { + if m.FpBtcPk.Size() != bbn.BIP340PubKeyLen { + return ErrInvalidFinalitySig.Wrapf("invalid finality provider BTC public key length: got %d, want %d", m.FpBtcPk.Size(), bbn.BIP340PubKeyLen) + } + + if m.PubRand.Size() != bbn.SchnorrPubRandLen { + return ErrInvalidFinalitySig.Wrapf("invalind public randomness length: got %d, want %d", m.PubRand.Size(), bbn.SchnorrPubRandLen) + } + + if m.Proof == nil { + return ErrInvalidFinalitySig.Wrap("empty inclusion proof") + } + + if m.FinalitySig.Size() != bbn.SchnorrEOTSSigLen { + return ErrInvalidFinalitySig.Wrapf("invalid finality signature length: got %d, want %d", m.FinalitySig.Size(), bbn.BIP340SignatureLen) + } + + if len(m.BlockAppHash) != tmhash.Size { + return ErrInvalidFinalitySig.Wrapf("invalid block app hash length: got %d, want %d", len(m.BlockAppHash), tmhash.Size) + } + + return nil +} + // VerifyFinalitySig verifies the finality signature message w.r.t. the // public randomness commitment. The verification includes // - verifying the proof of inclusion of the given public randomness diff --git a/x/finality/types/params.go b/x/finality/types/params.go index 1bf540a06..591ae302c 100644 --- a/x/finality/types/params.go +++ b/x/finality/types/params.go @@ -11,10 +11,18 @@ import ( // Default parameter namespace const ( - DefaultSignedBlocksWindow = int64(100) - DefaultMinPubRand = 100 - DefaultFinalitySigTimeout = 3 - DefaultJailDuration = 24 * 60 * 60 * 1 * time.Second // 1 day + DefaultMaxActiveFinalityProviders = uint32(100) + DefaultSignedBlocksWindow = int64(100) + DefaultMinPubRand = 100 + DefaultFinalitySigTimeout = 3 + DefaultJailDuration = 24 * 60 * 60 * 1 * time.Second // 1 day + // For mainnet considering we want 48 hours + // at a block time of 10s that would be 17280 blocks + // considering the upgrade for Phase-2 will happen at block + // 220, the mainnet activation height for btcstaking should + // be 17280 + 220 = 17500. + // For now it is set to 1 to avoid breaking dependencies. + DefaultFinalityActivationHeight = 1 ) var ( @@ -26,11 +34,13 @@ var _ paramtypes.ParamSet = (*Params)(nil) // DefaultParams returns a default set of parameters func DefaultParams() Params { return Params{ - FinalitySigTimeout: DefaultFinalitySigTimeout, - SignedBlocksWindow: DefaultSignedBlocksWindow, - MinSignedPerWindow: DefaultMinSignedPerWindow, - MinPubRand: DefaultMinPubRand, - JailDuration: DefaultJailDuration, + MaxActiveFinalityProviders: DefaultMaxActiveFinalityProviders, + FinalitySigTimeout: DefaultFinalitySigTimeout, + SignedBlocksWindow: DefaultSignedBlocksWindow, + MinSignedPerWindow: DefaultMinSignedPerWindow, + MinPubRand: DefaultMinPubRand, + JailDuration: DefaultJailDuration, + FinalityActivationHeight: DefaultFinalityActivationHeight, } } @@ -53,7 +63,12 @@ func (p Params) String() string { } // Validate validates the params +// finality activation height can be any value, even 0. func (p Params) Validate() error { + if err := validateMaxActiveFinalityProviders(p.MaxActiveFinalityProviders); err != nil { + return err + } + if err := validateSignedBlocksWindow(p.SignedBlocksWindow); err != nil { return err } @@ -73,6 +88,15 @@ func (p Params) Validate() error { return nil } +// validateMaxActiveFinalityProviders checks if the maximum number of +// active finality providers is at least the default value +func validateMaxActiveFinalityProviders(maxActiveFinalityProviders uint32) error { + if maxActiveFinalityProviders == 0 { + return fmt.Errorf("max finality providers must be positive") + } + return nil +} + func validateSignedBlocksWindow(i interface{}) error { v, ok := i.(int64) if !ok { diff --git a/x/finality/types/params.pb.go b/x/finality/types/params.pb.go index 1fe6ea1a4..17847a72b 100644 --- a/x/finality/types/params.pb.go +++ b/x/finality/types/params.pb.go @@ -32,19 +32,25 @@ const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package // Params defines the parameters for the module. type Params struct { + // max_active_finality_providers is the maximum number of active finality providers in the BTC staking protocol + MaxActiveFinalityProviders uint32 `protobuf:"varint,1,opt,name=max_active_finality_providers,json=maxActiveFinalityProviders,proto3" json:"max_active_finality_providers,omitempty"` // signed_blocks_window defines the size of the sliding window for tracking finality provider liveness - SignedBlocksWindow int64 `protobuf:"varint,1,opt,name=signed_blocks_window,json=signedBlocksWindow,proto3" json:"signed_blocks_window,omitempty"` + SignedBlocksWindow int64 `protobuf:"varint,2,opt,name=signed_blocks_window,json=signedBlocksWindow,proto3" json:"signed_blocks_window,omitempty"` // finality_sig_timeout defines how much time (in terms of blocks) finality providers have to cast a finality // vote before being judged as missing their voting turn on the given block - FinalitySigTimeout int64 `protobuf:"varint,2,opt,name=finality_sig_timeout,json=finalitySigTimeout,proto3" json:"finality_sig_timeout,omitempty"` + FinalitySigTimeout int64 `protobuf:"varint,3,opt,name=finality_sig_timeout,json=finalitySigTimeout,proto3" json:"finality_sig_timeout,omitempty"` // min_signed_per_window defines the minimum number of blocks that a finality provider is required to sign // within the sliding window to avoid being jailed - MinSignedPerWindow cosmossdk_io_math.LegacyDec `protobuf:"bytes,3,opt,name=min_signed_per_window,json=minSignedPerWindow,proto3,customtype=cosmossdk.io/math.LegacyDec" json:"min_signed_per_window"` + MinSignedPerWindow cosmossdk_io_math.LegacyDec `protobuf:"bytes,4,opt,name=min_signed_per_window,json=minSignedPerWindow,proto3,customtype=cosmossdk.io/math.LegacyDec" json:"min_signed_per_window"` // min_pub_rand is the minimum number of public randomness each // message should commit - MinPubRand uint64 `protobuf:"varint,4,opt,name=min_pub_rand,json=minPubRand,proto3" json:"min_pub_rand,omitempty"` + MinPubRand uint64 `protobuf:"varint,5,opt,name=min_pub_rand,json=minPubRand,proto3" json:"min_pub_rand,omitempty"` // jail_duration is the minimum period of time that a finality provider remains jailed - JailDuration time.Duration `protobuf:"bytes,5,opt,name=jail_duration,json=jailDuration,proto3,stdduration" json:"jail_duration"` + JailDuration time.Duration `protobuf:"bytes,6,opt,name=jail_duration,json=jailDuration,proto3,stdduration" json:"jail_duration"` + // finality_activation_height is the babylon block height which the finality module will + // start to accept finality voting and the minimum allowed value for the public randomness + // commit start height. + FinalityActivationHeight uint64 `protobuf:"varint,7,opt,name=finality_activation_height,json=finalityActivationHeight,proto3" json:"finality_activation_height,omitempty"` } func (m *Params) Reset() { *m = Params{} } @@ -79,6 +85,13 @@ func (m *Params) XXX_DiscardUnknown() { var xxx_messageInfo_Params proto.InternalMessageInfo +func (m *Params) GetMaxActiveFinalityProviders() uint32 { + if m != nil { + return m.MaxActiveFinalityProviders + } + return 0 +} + func (m *Params) GetSignedBlocksWindow() int64 { if m != nil { return m.SignedBlocksWindow @@ -107,6 +120,13 @@ func (m *Params) GetJailDuration() time.Duration { return 0 } +func (m *Params) GetFinalityActivationHeight() uint64 { + if m != nil { + return m.FinalityActivationHeight + } + return 0 +} + func init() { proto.RegisterType((*Params)(nil), "babylon.finality.v1.Params") } @@ -114,34 +134,38 @@ func init() { func init() { proto.RegisterFile("babylon/finality/v1/params.proto", fileDescriptor_25539c9a61c72ee9) } var fileDescriptor_25539c9a61c72ee9 = []byte{ - // 420 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x44, 0x92, 0x31, 0x6f, 0xd4, 0x30, - 0x14, 0xc7, 0xe3, 0xf6, 0xe8, 0x10, 0xae, 0x03, 0xa1, 0x48, 0xd7, 0x22, 0xe5, 0x22, 0xa6, 0x13, - 0x52, 0x6d, 0x5a, 0x24, 0x06, 0xc6, 0xd3, 0x8d, 0x45, 0x3a, 0x5d, 0x91, 0x90, 0x58, 0x22, 0x3b, - 0x71, 0xdd, 0x47, 0x63, 0xbf, 0x28, 0x4e, 0x5a, 0xf2, 0x2d, 0x18, 0x3b, 0x32, 0x32, 0x32, 0xf0, - 0x21, 0x3a, 0xa1, 0x8a, 0x09, 0x31, 0x1c, 0xe8, 0x6e, 0xe0, 0x6b, 0xa0, 0xc4, 0xb1, 0x58, 0xa2, - 0xbc, 0xfc, 0xfe, 0x2f, 0xff, 0xff, 0x7b, 0x76, 0x98, 0x08, 0x2e, 0xda, 0x02, 0x0d, 0xbb, 0x00, - 0xc3, 0x0b, 0xa8, 0x5b, 0x76, 0x7d, 0xc2, 0x4a, 0x5e, 0x71, 0x6d, 0x69, 0x59, 0x61, 0x8d, 0xd1, - 0xe3, 0x41, 0x41, 0xbd, 0x82, 0x5e, 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x21, 0xb3, 0xd1, 0x2a, 0xd4, - 0x60, 0x96, 0x8d, 0x58, 0x71, 0x93, 0x47, 0x6f, 0xc2, 0xfd, 0x0f, 0x1c, 0x8a, 0xd4, 0xaf, 0x64, - 0xf2, 0x20, 0x21, 0xb3, 0x87, 0xa7, 0x87, 0xd4, 0xed, 0x8c, 0xfa, 0x9d, 0xd1, 0xc5, 0x20, 0x98, - 0xef, 0x77, 0xf9, 0x6e, 0x7f, 0x4f, 0x89, 0xb3, 0x1d, 0x77, 0xed, 0x1e, 0xbe, 0x1e, 0xdd, 0x7e, - 0x9e, 0x06, 0xf3, 0xb3, 0xbb, 0x4d, 0x4c, 0xee, 0x37, 0x31, 0xf9, 0xb3, 0x89, 0xc9, 0xa7, 0x6d, - 0x1c, 0xdc, 0x6f, 0xe3, 0xe0, 0xe7, 0x36, 0x0e, 0xde, 0x9f, 0x2a, 0xa8, 0x2f, 0x1b, 0x41, 0x33, - 0xd4, 0x6c, 0x38, 0xee, 0x82, 0x0b, 0x7b, 0x0c, 0xe8, 0x4b, 0xf6, 0xf1, 0xff, 0x0d, 0xa9, 0xdb, - 0x52, 0x5a, 0xb1, 0xd7, 0x67, 0x78, 0xf9, 0x2f, 0x00, 0x00, 0xff, 0xff, 0xf4, 0xd4, 0xa2, 0x2b, - 0x42, 0x02, 0x00, 0x00, + // 486 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x44, 0x92, 0x31, 0x8f, 0xd3, 0x3e, + 0x18, 0xc6, 0xeb, 0x7f, 0xfb, 0x2f, 0x52, 0x68, 0x07, 0xc2, 0x21, 0xe5, 0x8a, 0x48, 0x23, 0xa6, + 0x0a, 0xe9, 0x12, 0xee, 0x90, 0x18, 0x10, 0x4b, 0xab, 0x0a, 0x31, 0x1c, 0x52, 0xd5, 0x43, 0x42, + 0x62, 0xb1, 0x9c, 0xc4, 0xe7, 0xbe, 0x5c, 0x6c, 0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a, 0xbd, 0x0d, 0xd1, 0xcd, 0x36, 0x44, 0xbf, 0xb7, 0x21, 0xfa, 0xb8, + 0x0b, 0x5b, 0x37, 0xbb, 0xb0, 0xf5, 0x63, 0x17, 0xb6, 0xde, 0x9f, 0x30, 0xd0, 0x8b, 0x2a, 0x8d, + 0x33, 0xc9, 0x93, 0x66, 0xdf, 0x0a, 0x92, 0xaa, 0x23, 0x90, 0xae, 0x4c, 0xd6, 0xff, 0x56, 0x54, + 0x6f, 0x96, 0x54, 0xa5, 0x5d, 0xf3, 0x05, 0xcf, 0xfe, 0x06, 0x00, 0x00, 0xff, 0xff, 0xa2, 0x27, + 0x77, 0xaf, 0xc3, 0x02, 0x00, 0x00, } func (m *Params) Marshal() (dAtA []byte, err error) { @@ -164,6 +188,11 @@ func (m *Params) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l + if m.FinalityActivationHeight != 0 { + i = encodeVarintParams(dAtA, i, uint64(m.FinalityActivationHeight)) + i-- + dAtA[i] = 0x38 + } n1, err1 := github_com_cosmos_gogoproto_types.StdDurationMarshalTo(m.JailDuration, dAtA[i-github_com_cosmos_gogoproto_types.SizeOfStdDuration(m.JailDuration):]) if err1 != nil { return 0, err1 @@ -171,11 +200,11 @@ func (m *Params) MarshalToSizedBuffer(dAtA []byte) (int, error) { i -= n1 i = encodeVarintParams(dAtA, i, uint64(n1)) i-- - dAtA[i] = 0x2a + dAtA[i] = 0x32 if m.MinPubRand != 0 { i = encodeVarintParams(dAtA, i, uint64(m.MinPubRand)) i-- - dAtA[i] = 0x20 + dAtA[i] = 0x28 } { size := m.MinSignedPerWindow.Size() @@ -186,15 +215,20 @@ func (m *Params) MarshalToSizedBuffer(dAtA []byte) (int, error) { i = encodeVarintParams(dAtA, i, uint64(size)) } i-- - dAtA[i] = 0x1a + dAtA[i] = 0x22 if m.FinalitySigTimeout != 0 { i = encodeVarintParams(dAtA, i, uint64(m.FinalitySigTimeout)) i-- - dAtA[i] = 0x10 + dAtA[i] = 0x18 } if m.SignedBlocksWindow != 0 { i = encodeVarintParams(dAtA, i, uint64(m.SignedBlocksWindow)) i-- + dAtA[i] = 0x10 + } + if m.MaxActiveFinalityProviders != 0 { + i = encodeVarintParams(dAtA, i, uint64(m.MaxActiveFinalityProviders)) + i-- dAtA[i] = 0x8 } return len(dAtA) - i, nil @@ -217,6 +251,9 @@ func (m *Params) Size() (n int) { } var l int _ = l + if m.MaxActiveFinalityProviders != 0 { + n += 1 + sovParams(uint64(m.MaxActiveFinalityProviders)) + } if m.SignedBlocksWindow != 0 { n += 1 + sovParams(uint64(m.SignedBlocksWindow)) } @@ -230,6 +267,9 @@ func (m *Params) Size() (n int) { } l = github_com_cosmos_gogoproto_types.SizeOfStdDuration(m.JailDuration) n += 1 + l + sovParams(uint64(l)) + if m.FinalityActivationHeight != 0 { + n += 1 + sovParams(uint64(m.FinalityActivationHeight)) + } return n } @@ -269,6 +309,25 @@ func (m *Params) Unmarshal(dAtA []byte) error { } switch fieldNum { case 1: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field MaxActiveFinalityProviders", wireType) + } + m.MaxActiveFinalityProviders = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowParams + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.MaxActiveFinalityProviders |= uint32(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 2: if wireType != 0 { return fmt.Errorf("proto: wrong wireType = %d for field SignedBlocksWindow", wireType) } @@ -287,7 +346,7 @@ func (m *Params) Unmarshal(dAtA []byte) error { break } } - case 2: + case 3: if wireType != 0 { return fmt.Errorf("proto: wrong wireType = %d for field FinalitySigTimeout", wireType) } @@ -306,7 +365,7 @@ func (m *Params) Unmarshal(dAtA []byte) error { break } } - case 3: + case 4: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field MinSignedPerWindow", wireType) } @@ -339,7 +398,7 @@ func (m *Params) Unmarshal(dAtA []byte) error { return err } iNdEx = postIndex - case 4: + case 5: if wireType != 0 { return fmt.Errorf("proto: wrong wireType = %d for field MinPubRand", wireType) } @@ -358,7 +417,7 @@ func (m *Params) Unmarshal(dAtA []byte) error { break } } - case 5: + case 6: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field JailDuration", wireType) } @@ -391,6 +450,25 @@ func (m *Params) Unmarshal(dAtA []byte) error { return err } iNdEx = postIndex + case 7: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field FinalityActivationHeight", wireType) + } + m.FinalityActivationHeight = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowParams + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.FinalityActivationHeight |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } default: iNdEx = preIndex skippy, err := skipParams(dAtA[iNdEx:]) diff --git a/x/btcstaking/types/incentive.go b/x/finality/types/power_table.go similarity index 50% rename from x/btcstaking/types/incentive.go rename to x/finality/types/power_table.go index 41cc24de5..c25aebe72 100644 --- a/x/btcstaking/types/incentive.go +++ b/x/finality/types/power_table.go @@ -1,7 +1,10 @@ package types import ( + "sort" + sdkmath "cosmossdk.io/math" + bstypes "github.com/babylonlabs-io/babylon/x/btcstaking/types" sdk "github.com/cosmos/cosmos-sdk/types" ) @@ -12,6 +15,15 @@ func NewVotingPowerDistCache() *VotingPowerDistCache { } } +func NewVotingPowerDistCacheWithFinalityProviders(fps []*FinalityProviderDistInfo) *VotingPowerDistCache { + cache := NewVotingPowerDistCache() + for _, fp := range fps { + cache.AddFinalityProviderDistInfo(fp) + } + + return cache +} + func (dc *VotingPowerDistCache) Empty() bool { return len(dc.FinalityProviders) == 0 } @@ -35,6 +47,21 @@ func (dc *VotingPowerDistCache) FindNewActiveFinalityProviders(prevDc *VotingPow return newActiveFps } +func (dc *VotingPowerDistCache) FindNewInactiveFinalityProviders(prevDc *VotingPowerDistCache) []*FinalityProviderDistInfo { + inactiveFps := dc.GetInactiveFinalityProviderSet() + prevInactiveFps := prevDc.GetInactiveFinalityProviderSet() + newInactiveFps := make([]*FinalityProviderDistInfo, 0) + + for pk, fp := range inactiveFps { + _, exists := prevInactiveFps[pk] + if !exists { + newInactiveFps = append(newInactiveFps, fp) + } + } + + return newInactiveFps +} + // ApplyActiveFinalityProviders sorts all finality providers, counts the total voting // power of top N finality providers, excluding those who don't have timestamped pub rand // and records them in cache @@ -50,7 +77,7 @@ func (dc *VotingPowerDistCache) ApplyActiveFinalityProviders(maxActiveFPs uint32 if numActiveFPs == maxActiveFPs { break } - if fp.TotalVotingPower == 0 { + if fp.TotalBondedSat == 0 { break } if !fp.IsTimestamped { @@ -65,7 +92,7 @@ func (dc *VotingPowerDistCache) ApplyActiveFinalityProviders(maxActiveFPs uint32 totalVotingPower := uint64(0) for i := uint32(0); i < numActiveFPs; i++ { - totalVotingPower += dc.FinalityProviders[i].TotalVotingPower + totalVotingPower += dc.FinalityProviders[i].TotalBondedSat } dc.TotalVotingPower = totalVotingPower @@ -87,67 +114,102 @@ func (dc *VotingPowerDistCache) GetActiveFinalityProviderSet() map[string]*Final return activeFps } -// FilterVotedDistCache filters out a voting power distribution cache -// with finality providers that have voted according to a map of given -// voters, and their total voted power. -func (dc *VotingPowerDistCache) FilterVotedDistCache(voterBTCPKs map[string]struct{}) *VotingPowerDistCache { - activeFPs := dc.GetActiveFinalityProviderSet() - var filteredFps []*FinalityProviderDistInfo - totalVotingPower := uint64(0) - for k, v := range activeFPs { - if _, ok := voterBTCPKs[k]; ok { - filteredFps = append(filteredFps, v) - totalVotingPower += v.TotalVotingPower - } +// GetInactiveFinalityProviderSet returns a set of inactive finality providers +// keyed by the hex string of the finality provider's BTC public key +// i.e., not within top N of them in terms of voting power and not slashed or jailed +func (dc *VotingPowerDistCache) GetInactiveFinalityProviderSet() map[string]*FinalityProviderDistInfo { + numActiveFPs := dc.NumActiveFps + + if len(dc.FinalityProviders) <= int(numActiveFPs) { + return nil } - return &VotingPowerDistCache{ - FinalityProviders: filteredFps, - TotalVotingPower: totalVotingPower, + inactiveFps := make(map[string]*FinalityProviderDistInfo) + + for _, fp := range dc.FinalityProviders[numActiveFPs:] { + if !fp.IsSlashed && !fp.IsJailed { + inactiveFps[fp.BtcPk.MarshalHex()] = fp + } } + + return inactiveFps } // GetFinalityProviderPortion returns the portion of a finality provider's voting power out of the total voting power func (dc *VotingPowerDistCache) GetFinalityProviderPortion(v *FinalityProviderDistInfo) sdkmath.LegacyDec { - return sdkmath.LegacyNewDec(int64(v.TotalVotingPower)).QuoTruncate(sdkmath.LegacyNewDec(int64(dc.TotalVotingPower))) + return sdkmath.LegacyNewDec(int64(v.TotalBondedSat)).QuoTruncate(sdkmath.LegacyNewDec(int64(dc.TotalVotingPower))) } -func NewFinalityProviderDistInfo(fp *FinalityProvider) *FinalityProviderDistInfo { +func NewFinalityProviderDistInfo(fp *bstypes.FinalityProvider) *FinalityProviderDistInfo { return &FinalityProviderDistInfo{ - BtcPk: fp.BtcPk, - Addr: fp.Addr, - Commission: fp.Commission, - TotalVotingPower: 0, - BtcDels: []*BTCDelDistInfo{}, + BtcPk: fp.BtcPk, + Addr: sdk.MustAccAddressFromBech32(fp.Addr), + Commission: fp.Commission, + TotalBondedSat: 0, + BtcDels: []*BTCDelDistInfo{}, } } func (v *FinalityProviderDistInfo) GetAddress() sdk.AccAddress { - return sdk.MustAccAddressFromBech32(v.Addr) + return v.Addr } -func (v *FinalityProviderDistInfo) AddBTCDel(btcDel *BTCDelegation) { +func (v *FinalityProviderDistInfo) AddBTCDel(btcDel *bstypes.BTCDelegation) { btcDelDistInfo := &BTCDelDistInfo{ BtcPk: btcDel.BtcPk, StakerAddr: btcDel.StakerAddr, StakingTxHash: btcDel.MustGetStakingTxHash().String(), - VotingPower: btcDel.TotalSat, + TotalSat: btcDel.TotalSat, } v.BtcDels = append(v.BtcDels, btcDelDistInfo) - v.TotalVotingPower += btcDelDistInfo.VotingPower + v.TotalBondedSat += btcDelDistInfo.TotalSat } func (v *FinalityProviderDistInfo) AddBTCDelDistInfo(d *BTCDelDistInfo) { v.BtcDels = append(v.BtcDels, d) - v.TotalVotingPower += d.VotingPower + v.TotalBondedSat += d.TotalSat } // GetBTCDelPortion returns the portion of a BTC delegation's voting power out of // the finality provider's total voting power func (v *FinalityProviderDistInfo) GetBTCDelPortion(d *BTCDelDistInfo) sdkmath.LegacyDec { - return sdkmath.LegacyNewDec(int64(d.VotingPower)).QuoTruncate(sdkmath.LegacyNewDec(int64(v.TotalVotingPower))) + return sdkmath.LegacyNewDec(int64(d.TotalSat)).QuoTruncate(sdkmath.LegacyNewDec(int64(v.TotalBondedSat))) } func (d *BTCDelDistInfo) GetAddress() sdk.AccAddress { return sdk.MustAccAddressFromBech32(d.StakerAddr) } + +// SortFinalityProvidersWithZeroedVotingPower sorts the finality providers slice, +// from higher to lower voting power. In the following cases, the voting power +// is treated as zero: +// 1. IsTimestamped is false +// 2. IsJailed is true +func SortFinalityProvidersWithZeroedVotingPower(fps []*FinalityProviderDistInfo) { + sort.SliceStable(fps, func(i, j int) bool { + iShouldBeZeroed := fps[i].IsJailed || !fps[i].IsTimestamped + jShouldBeZeroed := fps[j].IsJailed || !fps[j].IsTimestamped + + if iShouldBeZeroed && !jShouldBeZeroed { + return false + } + + if !iShouldBeZeroed && jShouldBeZeroed { + return true + } + + iPkHex, jPkHex := fps[i].BtcPk.MarshalHex(), fps[j].BtcPk.MarshalHex() + + if iShouldBeZeroed && jShouldBeZeroed { + // Both have zeroed voting power, compare BTC public keys + return iPkHex < jPkHex + } + + // both voting power the same, compare BTC public keys + if fps[i].TotalBondedSat == fps[j].TotalBondedSat { + return iPkHex < jPkHex + } + + return fps[i].TotalBondedSat > fps[j].TotalBondedSat + }) +} diff --git a/x/finality/types/power_table_test.go b/x/finality/types/power_table_test.go new file mode 100644 index 000000000..c15a00486 --- /dev/null +++ b/x/finality/types/power_table_test.go @@ -0,0 +1,330 @@ +package types_test + +import ( + "math/rand" + "testing" + + "github.com/btcsuite/btcd/btcec/v2" + "github.com/stretchr/testify/require" + + "github.com/babylonlabs-io/babylon/testutil/datagen" + bbn "github.com/babylonlabs-io/babylon/types" + types "github.com/babylonlabs-io/babylon/x/finality/types" +) + +var ( + fpPrivKey1, _ = btcec.NewPrivateKey() + fpPrivKey2, _ = btcec.NewPrivateKey() + fpPubKey1 = bbn.NewBIP340PubKeyFromBTCPK(fpPrivKey1.PubKey()) + fpPubKey2 = bbn.NewBIP340PubKeyFromBTCPK(fpPrivKey2.PubKey()) +) + +func TestVotingPowerDistCache(t *testing.T) { + tests := []struct { + desc string + maxActiveFPs uint32 + numActiveFps uint32 + numInactiveFps uint32 + totalVotingPower uint64 + prevDistCache *types.VotingPowerDistCache + fps []*types.FinalityProviderDistInfo + }{ + { + desc: "all not timestamped", + maxActiveFPs: 80, + numActiveFps: 0, + numInactiveFps: 2, + totalVotingPower: 0, + prevDistCache: types.NewVotingPowerDistCache(), + fps: []*types.FinalityProviderDistInfo{ + { + BtcPk: fpPubKey1, + TotalBondedSat: 1000, + IsTimestamped: false, + }, + { + BtcPk: fpPubKey2, + TotalBondedSat: 2000, + IsTimestamped: false, + }, + }, + }, + { + desc: "all timestamped", + maxActiveFPs: 80, + numActiveFps: 2, + numInactiveFps: 0, + totalVotingPower: 3000, + prevDistCache: types.NewVotingPowerDistCache(), + fps: []*types.FinalityProviderDistInfo{ + { + BtcPk: fpPubKey1, + TotalBondedSat: 1000, + IsTimestamped: true, + }, + { + BtcPk: fpPubKey2, + TotalBondedSat: 2000, + IsTimestamped: true, + }, + }, + }, + { + desc: "partly timestamped", + maxActiveFPs: 80, + numActiveFps: 1, + numInactiveFps: 1, + totalVotingPower: 1000, + prevDistCache: types.NewVotingPowerDistCache(), + fps: []*types.FinalityProviderDistInfo{ + { + BtcPk: fpPubKey1, + TotalBondedSat: 1000, + IsTimestamped: true, + }, + { + BtcPk: fpPubKey2, + TotalBondedSat: 2000, + IsTimestamped: false, + }, + }, + }, + { + desc: "small max active fps", + maxActiveFPs: 1, + numActiveFps: 1, + numInactiveFps: 1, + totalVotingPower: 2000, + prevDistCache: types.NewVotingPowerDistCache(), + fps: []*types.FinalityProviderDistInfo{ + { + BtcPk: fpPubKey1, + TotalBondedSat: 1000, + IsTimestamped: true, + }, + { + BtcPk: fpPubKey2, + TotalBondedSat: 2000, + IsTimestamped: true, + }, + }, + }, + { + desc: "one got jailed", + maxActiveFPs: 80, + numActiveFps: 1, + numInactiveFps: 0, + totalVotingPower: 1000, + prevDistCache: types.NewVotingPowerDistCache(), + fps: []*types.FinalityProviderDistInfo{ + { + BtcPk: fpPubKey1, + TotalBondedSat: 1000, + IsTimestamped: true, + }, + { + BtcPk: fpPubKey2, + TotalBondedSat: 2000, + IsTimestamped: true, + IsJailed: true, + }, + }, + }, + { + desc: "one got slashed", + maxActiveFPs: 80, + numActiveFps: 1, + numInactiveFps: 0, + totalVotingPower: 1000, + prevDistCache: types.NewVotingPowerDistCache(), + fps: []*types.FinalityProviderDistInfo{ + { + BtcPk: fpPubKey1, + TotalBondedSat: 1000, + IsTimestamped: true, + }, + { + BtcPk: fpPubKey2, + TotalBondedSat: 0, // a jailed fp cannot accept delegation + IsTimestamped: true, + IsSlashed: true, + }, + }, + }, + { + desc: "previous one got unjailed", + maxActiveFPs: 80, + numActiveFps: 1, + numInactiveFps: 0, + totalVotingPower: 1000, + prevDistCache: types.NewVotingPowerDistCacheWithFinalityProviders( + []*types.FinalityProviderDistInfo{ + { + BtcPk: fpPubKey1, + TotalBondedSat: 1000, + IsTimestamped: true, + IsJailed: true, + }}), + fps: []*types.FinalityProviderDistInfo{ + { + BtcPk: fpPubKey1, + TotalBondedSat: 1000, + IsTimestamped: true, + IsJailed: false, + }, + }, + }, + } + for _, tc := range tests { + t.Run(tc.desc, func(t *testing.T) { + dc := types.NewVotingPowerDistCacheWithFinalityProviders(tc.fps) + dc.ApplyActiveFinalityProviders(tc.maxActiveFPs) + require.Equal(t, tc.totalVotingPower, dc.TotalVotingPower) + require.Equal(t, tc.numActiveFps, dc.NumActiveFps) + + newActiveFps := dc.FindNewActiveFinalityProviders(tc.prevDistCache) + require.Equal(t, tc.numActiveFps, uint32(len(newActiveFps))) + + newInactiveFps := dc.FindNewInactiveFinalityProviders(tc.prevDistCache) + require.Equal(t, tc.numInactiveFps, uint32(len(newInactiveFps))) + }) + } +} + +func TestSortFinalityProvidersWithZeroedVotingPower(t *testing.T) { + tests := []struct { + name string + fps []*types.FinalityProviderDistInfo + expected []*types.FinalityProviderDistInfo + }{ + { + name: "Sort by voting power", + fps: []*types.FinalityProviderDistInfo{ + {Addr: []byte("fp1"), TotalBondedSat: 100, IsJailed: false, IsTimestamped: true, BtcPk: &bbn.BIP340PubKey{0x03}}, + {Addr: []byte("fp2"), TotalBondedSat: 200, IsJailed: false, IsTimestamped: true, BtcPk: &bbn.BIP340PubKey{0x02}}, + {Addr: []byte("fp3"), TotalBondedSat: 150, IsJailed: false, IsTimestamped: true, BtcPk: &bbn.BIP340PubKey{0x01}}, + }, + expected: []*types.FinalityProviderDistInfo{ + {Addr: []byte("fp2"), TotalBondedSat: 200, IsJailed: false, IsTimestamped: true, BtcPk: &bbn.BIP340PubKey{0x02}}, + {Addr: []byte("fp3"), TotalBondedSat: 150, IsJailed: false, IsTimestamped: true, BtcPk: &bbn.BIP340PubKey{0x01}}, + {Addr: []byte("fp1"), TotalBondedSat: 100, IsJailed: false, IsTimestamped: true, BtcPk: &bbn.BIP340PubKey{0x03}}, + }, + }, + { + name: "Jailed and non-timestamped providers at the end", + fps: []*types.FinalityProviderDistInfo{ + {Addr: []byte("fp1"), TotalBondedSat: 100, IsJailed: false, IsTimestamped: true, BtcPk: &bbn.BIP340PubKey{0x04}}, + {Addr: []byte("fp2"), TotalBondedSat: 200, IsJailed: true, IsTimestamped: true, BtcPk: &bbn.BIP340PubKey{0x02}}, + {Addr: []byte("fp3"), TotalBondedSat: 150, IsJailed: false, IsTimestamped: false, BtcPk: &bbn.BIP340PubKey{0x03}}, + {Addr: []byte("fp4"), TotalBondedSat: 50, IsJailed: false, IsTimestamped: true, BtcPk: &bbn.BIP340PubKey{0x01}}, + }, + expected: []*types.FinalityProviderDistInfo{ + {Addr: []byte("fp1"), TotalBondedSat: 100, IsJailed: false, IsTimestamped: true, BtcPk: &bbn.BIP340PubKey{0x04}}, + {Addr: []byte("fp4"), TotalBondedSat: 50, IsJailed: false, IsTimestamped: true, BtcPk: &bbn.BIP340PubKey{0x01}}, + {Addr: []byte("fp2"), TotalBondedSat: 200, IsJailed: true, IsTimestamped: true, BtcPk: &bbn.BIP340PubKey{0x02}}, + {Addr: []byte("fp3"), TotalBondedSat: 150, IsJailed: false, IsTimestamped: false, BtcPk: &bbn.BIP340PubKey{0x03}}, + }, + }, + { + name: "Equal voting power, sort by BTC public key", + fps: []*types.FinalityProviderDistInfo{ + {Addr: []byte("fp1"), TotalBondedSat: 100, IsJailed: false, IsTimestamped: true, BtcPk: &bbn.BIP340PubKey{0x03}}, + {Addr: []byte("fp2"), TotalBondedSat: 100, IsJailed: false, IsTimestamped: true, BtcPk: &bbn.BIP340PubKey{0x01}}, + {Addr: []byte("fp3"), TotalBondedSat: 100, IsJailed: false, IsTimestamped: true, BtcPk: &bbn.BIP340PubKey{0x02}}, + }, + expected: []*types.FinalityProviderDistInfo{ + {Addr: []byte("fp2"), TotalBondedSat: 100, IsJailed: false, IsTimestamped: true, BtcPk: &bbn.BIP340PubKey{0x01}}, + {Addr: []byte("fp3"), TotalBondedSat: 100, IsJailed: false, IsTimestamped: true, BtcPk: &bbn.BIP340PubKey{0x02}}, + {Addr: []byte("fp1"), TotalBondedSat: 100, IsJailed: false, IsTimestamped: true, BtcPk: &bbn.BIP340PubKey{0x03}}, + }, + }, + { + name: "Zeroed voting power, sort by BTC public key", + fps: []*types.FinalityProviderDistInfo{ + {Addr: []byte("fp1"), TotalBondedSat: 200, IsJailed: true, IsTimestamped: true, BtcPk: &bbn.BIP340PubKey{0x03}}, + {Addr: []byte("fp2"), TotalBondedSat: 150, IsJailed: false, IsTimestamped: false, BtcPk: &bbn.BIP340PubKey{0x01}}, + {Addr: []byte("fp3"), TotalBondedSat: 100, IsJailed: true, IsTimestamped: false, BtcPk: &bbn.BIP340PubKey{0x02}}, + }, + expected: []*types.FinalityProviderDistInfo{ + {Addr: []byte("fp2"), TotalBondedSat: 150, IsJailed: false, IsTimestamped: false, BtcPk: &bbn.BIP340PubKey{0x01}}, + {Addr: []byte("fp3"), TotalBondedSat: 100, IsJailed: true, IsTimestamped: false, BtcPk: &bbn.BIP340PubKey{0x02}}, + {Addr: []byte("fp1"), TotalBondedSat: 200, IsJailed: true, IsTimestamped: true, BtcPk: &bbn.BIP340PubKey{0x03}}, + }, + }, + } + + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + types.SortFinalityProvidersWithZeroedVotingPower(tt.fps) + require.Equal(t, tt.expected, tt.fps, "Sorted slice should match expected order") + }) + } +} + +// FuzzSortingDeterminism tests the property of the sorting algorithm that the result should +// be deterministic +func FuzzSortingDeterminism(f *testing.F) { + datagen.AddRandomSeedsToFuzzer(f, 1000) + f.Fuzz(func(t *testing.T, seed int64) { + r := rand.New(rand.NewSource(seed)) + max_vp := 10000 + + vp0 := datagen.RandomInt(r, max_vp) + 10 + vp1 := vp0 // this is for the case voting power is the same + vp2 := datagen.RandomInt(r, max_vp) + 10 + vp3 := datagen.RandomInt(r, max_vp) + 10 + vp4 := datagen.RandomInt(r, max_vp) + 10 + + pk1, err := datagen.GenRandomBIP340PubKey(r) + require.NoError(t, err) + pk2, err := datagen.GenRandomBIP340PubKey(r) + require.NoError(t, err) + pk3, err := datagen.GenRandomBIP340PubKey(r) + require.NoError(t, err) + pk4, err := datagen.GenRandomBIP340PubKey(r) + require.NoError(t, err) + pk5, err := datagen.GenRandomBIP340PubKey(r) + require.NoError(t, err) + + fpsWithMeta := []*types.FinalityProviderDistInfo{ + {TotalBondedSat: vp0, IsJailed: false, IsTimestamped: true, Addr: []byte("addr0"), BtcPk: pk1}, + {TotalBondedSat: vp1, IsJailed: false, IsTimestamped: true, Addr: []byte("addr1"), BtcPk: pk2}, + {TotalBondedSat: vp2, IsJailed: false, IsTimestamped: true, Addr: []byte("addr2"), BtcPk: pk3}, + {TotalBondedSat: vp3, IsJailed: false, IsTimestamped: true, Addr: []byte("addr3"), BtcPk: pk4}, + {TotalBondedSat: vp4, IsJailed: false, IsTimestamped: true, Addr: []byte("addr4"), BtcPk: pk5}, + } + jailedIdx := datagen.RandomInt(r, len(fpsWithMeta)) + noTimestampedIdx := datagen.RandomIntOtherThan(r, int(jailedIdx), len(fpsWithMeta)) + + fpsWithMeta[jailedIdx].IsJailed = true + fpsWithMeta[jailedIdx].IsTimestamped = false + fpsWithMeta[noTimestampedIdx].IsJailed = false + fpsWithMeta[noTimestampedIdx].IsTimestamped = false + + fpsWithMeta1 := []*types.FinalityProviderDistInfo{ + {TotalBondedSat: vp0, IsJailed: false, IsTimestamped: true, Addr: []byte("addr0"), BtcPk: pk1}, + {TotalBondedSat: vp1, IsJailed: false, IsTimestamped: true, Addr: []byte("addr1"), BtcPk: pk2}, + {TotalBondedSat: vp2, IsJailed: false, IsTimestamped: true, Addr: []byte("addr2"), BtcPk: pk3}, + {TotalBondedSat: vp3, IsJailed: false, IsTimestamped: true, Addr: []byte("addr3"), BtcPk: pk4}, + {TotalBondedSat: vp4, IsJailed: false, IsTimestamped: true, Addr: []byte("addr4"), BtcPk: pk5}, + } + + fpsWithMeta1[jailedIdx].IsJailed = true + fpsWithMeta1[jailedIdx].IsTimestamped = false + fpsWithMeta1[noTimestampedIdx].IsJailed = false + fpsWithMeta1[noTimestampedIdx].IsTimestamped = false + + // Shuffle the fpsWithMeta1 slice + r.Shuffle(len(fpsWithMeta1), func(i, j int) { + fpsWithMeta1[i], fpsWithMeta1[j] = fpsWithMeta1[j], fpsWithMeta1[i] + }) + + types.SortFinalityProvidersWithZeroedVotingPower(fpsWithMeta) + types.SortFinalityProvidersWithZeroedVotingPower(fpsWithMeta1) + + for i := 0; i < len(fpsWithMeta); i++ { + // our lists should be sorted in same order + require.Equal(t, fpsWithMeta[i].BtcPk.MarshalHex(), fpsWithMeta1[i].BtcPk.MarshalHex()) + } + }) +} diff --git a/x/finality/types/query.pb.go b/x/finality/types/query.pb.go index 76aa68501..64ccbf9ac 100644 --- a/x/finality/types/query.pb.go +++ b/x/finality/types/query.pb.go @@ -8,22 +8,27 @@ import ( fmt "fmt" github_com_babylonlabs_io_babylon_types "github.com/babylonlabs-io/babylon/types" query "github.com/cosmos/cosmos-sdk/types/query" + _ "github.com/cosmos/cosmos-sdk/types/tx/amino" _ "github.com/cosmos/gogoproto/gogoproto" grpc1 "github.com/cosmos/gogoproto/grpc" proto "github.com/cosmos/gogoproto/proto" + github_com_cosmos_gogoproto_types "github.com/cosmos/gogoproto/types" _ "google.golang.org/genproto/googleapis/api/annotations" grpc "google.golang.org/grpc" codes "google.golang.org/grpc/codes" status "google.golang.org/grpc/status" + _ "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. @@ -146,27 +151,33 @@ func (m *QueryParamsResponse) GetParams() Params { return Params{} } -// QueryListPublicRandomnessRequest is the request type for the -// Query/ListPublicRandomness RPC method. -type QueryListPublicRandomnessRequest struct { - // fp_btc_pk_hex is the hex str of Bitcoin secp256k1 PK of the finality provider +// QueryFinalityProviderPowerAtHeightRequest is the request type for the +// Query/FinalityProviderPowerAtHeight RPC method. +type QueryFinalityProviderPowerAtHeightRequest struct { + // fp_btc_pk_hex is the hex str of Bitcoin secp256k1 PK of the finality provider that + // this BTC delegation delegates to + // the PK follows encoding in BIP-340 spec FpBtcPkHex string `protobuf:"bytes,1,opt,name=fp_btc_pk_hex,json=fpBtcPkHex,proto3" json:"fp_btc_pk_hex,omitempty"` - // pagination defines an optional pagination for the request. - Pagination *query.PageRequest `protobuf:"bytes,2,opt,name=pagination,proto3" json:"pagination,omitempty"` + // height is used for querying the given finality provider's voting power at this height + Height uint64 `protobuf:"varint,2,opt,name=height,proto3" json:"height,omitempty"` } -func (m *QueryListPublicRandomnessRequest) Reset() { *m = QueryListPublicRandomnessRequest{} } -func (m *QueryListPublicRandomnessRequest) String() string { return proto.CompactTextString(m) } -func (*QueryListPublicRandomnessRequest) ProtoMessage() {} -func (*QueryListPublicRandomnessRequest) Descriptor() ([]byte, []int) { +func (m *QueryFinalityProviderPowerAtHeightRequest) Reset() { + *m = QueryFinalityProviderPowerAtHeightRequest{} +} +func (m *QueryFinalityProviderPowerAtHeightRequest) String() string { + return proto.CompactTextString(m) +} +func (*QueryFinalityProviderPowerAtHeightRequest) ProtoMessage() {} +func (*QueryFinalityProviderPowerAtHeightRequest) Descriptor() ([]byte, []int) { return fileDescriptor_32bddab77af6fdae, []int{2} } -func (m *QueryListPublicRandomnessRequest) XXX_Unmarshal(b []byte) error { +func (m *QueryFinalityProviderPowerAtHeightRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } -func (m *QueryListPublicRandomnessRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { +func (m *QueryFinalityProviderPowerAtHeightRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { - return xxx_messageInfo_QueryListPublicRandomnessRequest.Marshal(b, m, deterministic) + return xxx_messageInfo_QueryFinalityProviderPowerAtHeightRequest.Marshal(b, m, deterministic) } else { b = b[:cap(b)] n, err := m.MarshalToSizedBuffer(b) @@ -176,54 +187,55 @@ func (m *QueryListPublicRandomnessRequest) XXX_Marshal(b []byte, deterministic b return b[:n], nil } } -func (m *QueryListPublicRandomnessRequest) XXX_Merge(src proto.Message) { - xxx_messageInfo_QueryListPublicRandomnessRequest.Merge(m, src) +func (m *QueryFinalityProviderPowerAtHeightRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryFinalityProviderPowerAtHeightRequest.Merge(m, src) } -func (m *QueryListPublicRandomnessRequest) XXX_Size() int { +func (m *QueryFinalityProviderPowerAtHeightRequest) XXX_Size() int { return m.Size() } -func (m *QueryListPublicRandomnessRequest) XXX_DiscardUnknown() { - xxx_messageInfo_QueryListPublicRandomnessRequest.DiscardUnknown(m) +func (m *QueryFinalityProviderPowerAtHeightRequest) XXX_DiscardUnknown() { + xxx_messageInfo_QueryFinalityProviderPowerAtHeightRequest.DiscardUnknown(m) } -var xxx_messageInfo_QueryListPublicRandomnessRequest proto.InternalMessageInfo +var xxx_messageInfo_QueryFinalityProviderPowerAtHeightRequest proto.InternalMessageInfo -func (m *QueryListPublicRandomnessRequest) GetFpBtcPkHex() string { +func (m *QueryFinalityProviderPowerAtHeightRequest) GetFpBtcPkHex() string { if m != nil { return m.FpBtcPkHex } return "" } -func (m *QueryListPublicRandomnessRequest) GetPagination() *query.PageRequest { +func (m *QueryFinalityProviderPowerAtHeightRequest) GetHeight() uint64 { if m != nil { - return m.Pagination + return m.Height } - return nil + return 0 } -// QueryListPublicRandomnessResponse is the response type for the -// Query/ListPublicRandomness RPC method. -type QueryListPublicRandomnessResponse struct { - // pub_rand_map is the map where the key is the height and the value - // is the public randomness at this height for the given finality provider - PubRandMap map[uint64]*github_com_babylonlabs_io_babylon_types.SchnorrPubRand `protobuf:"bytes,1,rep,name=pub_rand_map,json=pubRandMap,proto3,customtype=github.com/babylonlabs-io/babylon/types.SchnorrPubRand" json:"pub_rand_map,omitempty" protobuf_key:"varint,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"` - // pagination defines the pagination in the response. - Pagination *query.PageResponse `protobuf:"bytes,2,opt,name=pagination,proto3" json:"pagination,omitempty"` +// QueryFinalityProviderPowerAtHeightResponse is the response type for the +// Query/FinalityProviderPowerAtHeight RPC method. +type QueryFinalityProviderPowerAtHeightResponse struct { + // voting_power is the voting power of the finality provider + VotingPower uint64 `protobuf:"varint,1,opt,name=voting_power,json=votingPower,proto3" json:"voting_power,omitempty"` } -func (m *QueryListPublicRandomnessResponse) Reset() { *m = QueryListPublicRandomnessResponse{} } -func (m *QueryListPublicRandomnessResponse) String() string { return proto.CompactTextString(m) } -func (*QueryListPublicRandomnessResponse) ProtoMessage() {} -func (*QueryListPublicRandomnessResponse) Descriptor() ([]byte, []int) { +func (m *QueryFinalityProviderPowerAtHeightResponse) Reset() { + *m = QueryFinalityProviderPowerAtHeightResponse{} +} +func (m *QueryFinalityProviderPowerAtHeightResponse) String() string { + return proto.CompactTextString(m) +} +func (*QueryFinalityProviderPowerAtHeightResponse) ProtoMessage() {} +func (*QueryFinalityProviderPowerAtHeightResponse) Descriptor() ([]byte, []int) { return fileDescriptor_32bddab77af6fdae, []int{3} } -func (m *QueryListPublicRandomnessResponse) XXX_Unmarshal(b []byte) error { +func (m *QueryFinalityProviderPowerAtHeightResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } -func (m *QueryListPublicRandomnessResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { +func (m *QueryFinalityProviderPowerAtHeightResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { - return xxx_messageInfo_QueryListPublicRandomnessResponse.Marshal(b, m, deterministic) + return xxx_messageInfo_QueryFinalityProviderPowerAtHeightResponse.Marshal(b, m, deterministic) } else { b = b[:cap(b)] n, err := m.MarshalToSizedBuffer(b) @@ -233,47 +245,48 @@ func (m *QueryListPublicRandomnessResponse) XXX_Marshal(b []byte, deterministic return b[:n], nil } } -func (m *QueryListPublicRandomnessResponse) XXX_Merge(src proto.Message) { - xxx_messageInfo_QueryListPublicRandomnessResponse.Merge(m, src) +func (m *QueryFinalityProviderPowerAtHeightResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryFinalityProviderPowerAtHeightResponse.Merge(m, src) } -func (m *QueryListPublicRandomnessResponse) XXX_Size() int { +func (m *QueryFinalityProviderPowerAtHeightResponse) XXX_Size() int { return m.Size() } -func (m *QueryListPublicRandomnessResponse) XXX_DiscardUnknown() { - xxx_messageInfo_QueryListPublicRandomnessResponse.DiscardUnknown(m) +func (m *QueryFinalityProviderPowerAtHeightResponse) XXX_DiscardUnknown() { + xxx_messageInfo_QueryFinalityProviderPowerAtHeightResponse.DiscardUnknown(m) } -var xxx_messageInfo_QueryListPublicRandomnessResponse proto.InternalMessageInfo +var xxx_messageInfo_QueryFinalityProviderPowerAtHeightResponse proto.InternalMessageInfo -func (m *QueryListPublicRandomnessResponse) GetPagination() *query.PageResponse { +func (m *QueryFinalityProviderPowerAtHeightResponse) GetVotingPower() uint64 { if m != nil { - return m.Pagination + return m.VotingPower } - return nil + return 0 } -// PubRandCommitResponse is the response type for a public randomness commitment -type PubRandCommitResponse struct { - // num_pub_rand is the number of committed public randomness - NumPubRand uint64 `protobuf:"varint,1,opt,name=num_pub_rand,json=numPubRand,proto3" json:"num_pub_rand,omitempty"` - // commitment is the value of the commitment - Commitment []byte `protobuf:"bytes,2,opt,name=commitment,proto3" json:"commitment,omitempty"` - // epoch_num defines the epoch number that the commit falls into - EpochNum uint64 `protobuf:"varint,3,opt,name=epoch_num,json=epochNum,proto3" json:"epoch_num,omitempty"` +// QueryFinalityProviderCurrentPowerRequest is the request type for the +// Query/FinalityProviderCurrentPower RPC method. +type QueryFinalityProviderCurrentPowerRequest struct { + // fp_btc_pk_hex is the hex str of Bitcoin secp256k1 PK of the finality provider that + // this BTC delegation delegates to + // the PK follows encoding in BIP-340 spec + FpBtcPkHex string `protobuf:"bytes,1,opt,name=fp_btc_pk_hex,json=fpBtcPkHex,proto3" json:"fp_btc_pk_hex,omitempty"` } -func (m *PubRandCommitResponse) Reset() { *m = PubRandCommitResponse{} } -func (m *PubRandCommitResponse) String() string { return proto.CompactTextString(m) } -func (*PubRandCommitResponse) ProtoMessage() {} -func (*PubRandCommitResponse) Descriptor() ([]byte, []int) { +func (m *QueryFinalityProviderCurrentPowerRequest) Reset() { + *m = QueryFinalityProviderCurrentPowerRequest{} +} +func (m *QueryFinalityProviderCurrentPowerRequest) String() string { return proto.CompactTextString(m) } +func (*QueryFinalityProviderCurrentPowerRequest) ProtoMessage() {} +func (*QueryFinalityProviderCurrentPowerRequest) Descriptor() ([]byte, []int) { return fileDescriptor_32bddab77af6fdae, []int{4} } -func (m *PubRandCommitResponse) XXX_Unmarshal(b []byte) error { +func (m *QueryFinalityProviderCurrentPowerRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } -func (m *PubRandCommitResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { +func (m *QueryFinalityProviderCurrentPowerRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { - return xxx_messageInfo_PubRandCommitResponse.Marshal(b, m, deterministic) + return xxx_messageInfo_QueryFinalityProviderCurrentPowerRequest.Marshal(b, m, deterministic) } else { b = b[:cap(b)] n, err := m.MarshalToSizedBuffer(b) @@ -283,60 +296,50 @@ func (m *PubRandCommitResponse) XXX_Marshal(b []byte, deterministic bool) ([]byt return b[:n], nil } } -func (m *PubRandCommitResponse) XXX_Merge(src proto.Message) { - xxx_messageInfo_PubRandCommitResponse.Merge(m, src) +func (m *QueryFinalityProviderCurrentPowerRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryFinalityProviderCurrentPowerRequest.Merge(m, src) } -func (m *PubRandCommitResponse) XXX_Size() int { +func (m *QueryFinalityProviderCurrentPowerRequest) XXX_Size() int { return m.Size() } -func (m *PubRandCommitResponse) XXX_DiscardUnknown() { - xxx_messageInfo_PubRandCommitResponse.DiscardUnknown(m) +func (m *QueryFinalityProviderCurrentPowerRequest) XXX_DiscardUnknown() { + xxx_messageInfo_QueryFinalityProviderCurrentPowerRequest.DiscardUnknown(m) } -var xxx_messageInfo_PubRandCommitResponse proto.InternalMessageInfo +var xxx_messageInfo_QueryFinalityProviderCurrentPowerRequest proto.InternalMessageInfo -func (m *PubRandCommitResponse) GetNumPubRand() uint64 { +func (m *QueryFinalityProviderCurrentPowerRequest) GetFpBtcPkHex() string { if m != nil { - return m.NumPubRand + return m.FpBtcPkHex } - return 0 + return "" } -func (m *PubRandCommitResponse) GetCommitment() []byte { - if m != nil { - return m.Commitment - } - return nil +// QueryFinalityProviderCurrentPowerResponse is the response type for the +// Query/FinalityProviderCurrentPower RPC method. +type QueryFinalityProviderCurrentPowerResponse struct { + // height is the current height + Height uint64 `protobuf:"varint,1,opt,name=height,proto3" json:"height,omitempty"` + // voting_power is the voting power of the finality provider + VotingPower uint64 `protobuf:"varint,2,opt,name=voting_power,json=votingPower,proto3" json:"voting_power,omitempty"` } -func (m *PubRandCommitResponse) GetEpochNum() uint64 { - if m != nil { - return m.EpochNum - } - return 0 +func (m *QueryFinalityProviderCurrentPowerResponse) Reset() { + *m = QueryFinalityProviderCurrentPowerResponse{} } - -// QueryListPubRandCommitRequest is the request type for the -// Query/ListPubRandCommit RPC method. -type QueryListPubRandCommitRequest struct { - // fp_btc_pk_hex is the hex str of Bitcoin secp256k1 PK of the finality provider - FpBtcPkHex string `protobuf:"bytes,1,opt,name=fp_btc_pk_hex,json=fpBtcPkHex,proto3" json:"fp_btc_pk_hex,omitempty"` - // pagination defines an optional pagination for the request. - Pagination *query.PageRequest `protobuf:"bytes,2,opt,name=pagination,proto3" json:"pagination,omitempty"` +func (m *QueryFinalityProviderCurrentPowerResponse) String() string { + return proto.CompactTextString(m) } - -func (m *QueryListPubRandCommitRequest) Reset() { *m = QueryListPubRandCommitRequest{} } -func (m *QueryListPubRandCommitRequest) String() string { return proto.CompactTextString(m) } -func (*QueryListPubRandCommitRequest) ProtoMessage() {} -func (*QueryListPubRandCommitRequest) Descriptor() ([]byte, []int) { +func (*QueryFinalityProviderCurrentPowerResponse) ProtoMessage() {} +func (*QueryFinalityProviderCurrentPowerResponse) Descriptor() ([]byte, []int) { return fileDescriptor_32bddab77af6fdae, []int{5} } -func (m *QueryListPubRandCommitRequest) XXX_Unmarshal(b []byte) error { +func (m *QueryFinalityProviderCurrentPowerResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } -func (m *QueryListPubRandCommitRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { +func (m *QueryFinalityProviderCurrentPowerResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { - return xxx_messageInfo_QueryListPubRandCommitRequest.Marshal(b, m, deterministic) + return xxx_messageInfo_QueryFinalityProviderCurrentPowerResponse.Marshal(b, m, deterministic) } else { b = b[:cap(b)] n, err := m.MarshalToSizedBuffer(b) @@ -346,54 +349,57 @@ func (m *QueryListPubRandCommitRequest) XXX_Marshal(b []byte, deterministic bool return b[:n], nil } } -func (m *QueryListPubRandCommitRequest) XXX_Merge(src proto.Message) { - xxx_messageInfo_QueryListPubRandCommitRequest.Merge(m, src) +func (m *QueryFinalityProviderCurrentPowerResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryFinalityProviderCurrentPowerResponse.Merge(m, src) } -func (m *QueryListPubRandCommitRequest) XXX_Size() int { +func (m *QueryFinalityProviderCurrentPowerResponse) XXX_Size() int { return m.Size() } -func (m *QueryListPubRandCommitRequest) XXX_DiscardUnknown() { - xxx_messageInfo_QueryListPubRandCommitRequest.DiscardUnknown(m) +func (m *QueryFinalityProviderCurrentPowerResponse) XXX_DiscardUnknown() { + xxx_messageInfo_QueryFinalityProviderCurrentPowerResponse.DiscardUnknown(m) } -var xxx_messageInfo_QueryListPubRandCommitRequest proto.InternalMessageInfo +var xxx_messageInfo_QueryFinalityProviderCurrentPowerResponse proto.InternalMessageInfo -func (m *QueryListPubRandCommitRequest) GetFpBtcPkHex() string { +func (m *QueryFinalityProviderCurrentPowerResponse) GetHeight() uint64 { if m != nil { - return m.FpBtcPkHex + return m.Height } - return "" + return 0 } -func (m *QueryListPubRandCommitRequest) GetPagination() *query.PageRequest { +func (m *QueryFinalityProviderCurrentPowerResponse) GetVotingPower() uint64 { if m != nil { - return m.Pagination + return m.VotingPower } - return nil + return 0 } -// QueryListPubRandCommitResponse is the response type for the -// Query/ListPubRandCommit RPC method. -type QueryListPubRandCommitResponse struct { - // pub_rand_commit_map is the map where the key is the start height and the value - // is the public randomness commitment at this height for the given finality provider - PubRandCommitMap map[uint64]*PubRandCommitResponse `protobuf:"bytes,1,rep,name=pub_rand_commit_map,json=pubRandCommitMap,proto3" json:"pub_rand_commit_map,omitempty" protobuf_key:"varint,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"` - // pagination defines the pagination in the response. - Pagination *query.PageResponse `protobuf:"bytes,2,opt,name=pagination,proto3" json:"pagination,omitempty"` +// QueryActiveFinalityProvidersAtHeightRequest is the request type for the +// Query/ActiveFinalityProvidersAtHeight RPC method. +type QueryActiveFinalityProvidersAtHeightRequest struct { + // height defines at which Babylon height to query the finality providers info. + Height uint64 `protobuf:"varint,1,opt,name=height,proto3" json:"height,omitempty"` + // pagination defines an optional pagination for the request. + Pagination *query.PageRequest `protobuf:"bytes,2,opt,name=pagination,proto3" json:"pagination,omitempty"` } -func (m *QueryListPubRandCommitResponse) Reset() { *m = QueryListPubRandCommitResponse{} } -func (m *QueryListPubRandCommitResponse) String() string { return proto.CompactTextString(m) } -func (*QueryListPubRandCommitResponse) ProtoMessage() {} -func (*QueryListPubRandCommitResponse) Descriptor() ([]byte, []int) { +func (m *QueryActiveFinalityProvidersAtHeightRequest) Reset() { + *m = QueryActiveFinalityProvidersAtHeightRequest{} +} +func (m *QueryActiveFinalityProvidersAtHeightRequest) String() string { + return proto.CompactTextString(m) +} +func (*QueryActiveFinalityProvidersAtHeightRequest) ProtoMessage() {} +func (*QueryActiveFinalityProvidersAtHeightRequest) Descriptor() ([]byte, []int) { return fileDescriptor_32bddab77af6fdae, []int{6} } -func (m *QueryListPubRandCommitResponse) XXX_Unmarshal(b []byte) error { +func (m *QueryActiveFinalityProvidersAtHeightRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } -func (m *QueryListPubRandCommitResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { +func (m *QueryActiveFinalityProvidersAtHeightRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { - return xxx_messageInfo_QueryListPubRandCommitResponse.Marshal(b, m, deterministic) + return xxx_messageInfo_QueryActiveFinalityProvidersAtHeightRequest.Marshal(b, m, deterministic) } else { b = b[:cap(b)] n, err := m.MarshalToSizedBuffer(b) @@ -403,51 +409,67 @@ func (m *QueryListPubRandCommitResponse) XXX_Marshal(b []byte, deterministic boo return b[:n], nil } } -func (m *QueryListPubRandCommitResponse) XXX_Merge(src proto.Message) { - xxx_messageInfo_QueryListPubRandCommitResponse.Merge(m, src) +func (m *QueryActiveFinalityProvidersAtHeightRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryActiveFinalityProvidersAtHeightRequest.Merge(m, src) } -func (m *QueryListPubRandCommitResponse) XXX_Size() int { +func (m *QueryActiveFinalityProvidersAtHeightRequest) XXX_Size() int { return m.Size() } -func (m *QueryListPubRandCommitResponse) XXX_DiscardUnknown() { - xxx_messageInfo_QueryListPubRandCommitResponse.DiscardUnknown(m) +func (m *QueryActiveFinalityProvidersAtHeightRequest) XXX_DiscardUnknown() { + xxx_messageInfo_QueryActiveFinalityProvidersAtHeightRequest.DiscardUnknown(m) } -var xxx_messageInfo_QueryListPubRandCommitResponse proto.InternalMessageInfo +var xxx_messageInfo_QueryActiveFinalityProvidersAtHeightRequest proto.InternalMessageInfo -func (m *QueryListPubRandCommitResponse) GetPubRandCommitMap() map[uint64]*PubRandCommitResponse { +func (m *QueryActiveFinalityProvidersAtHeightRequest) GetHeight() uint64 { if m != nil { - return m.PubRandCommitMap + return m.Height } - return nil + return 0 } -func (m *QueryListPubRandCommitResponse) GetPagination() *query.PageResponse { +func (m *QueryActiveFinalityProvidersAtHeightRequest) GetPagination() *query.PageRequest { if m != nil { return m.Pagination } return nil } -// QueryBlockRequest is the request type for the -// Query/Block RPC method. -type QueryBlockRequest struct { - // height is the height of the Babylon block - Height uint64 `protobuf:"varint,1,opt,name=height,proto3" json:"height,omitempty"` -} - -func (m *QueryBlockRequest) Reset() { *m = QueryBlockRequest{} } -func (m *QueryBlockRequest) String() string { return proto.CompactTextString(m) } -func (*QueryBlockRequest) ProtoMessage() {} -func (*QueryBlockRequest) Descriptor() ([]byte, []int) { +// ActiveFinalityProvidersAtHeightResponse wraps the FinalityProvider with metadata. +type ActiveFinalityProvidersAtHeightResponse struct { + // btc_pk is the Bitcoin secp256k1 PK of thisfinality provider + // the PK follows encoding in BIP-340 spec + BtcPkHex *github_com_babylonlabs_io_babylon_types.BIP340PubKey `protobuf:"bytes,1,opt,name=btc_pk_hex,json=btcPkHex,proto3,customtype=github.com/babylonlabs-io/babylon/types.BIP340PubKey" json:"btc_pk_hex,omitempty"` + // height is the queried Babylon height + Height uint64 `protobuf:"varint,2,opt,name=height,proto3" json:"height,omitempty"` + // voting_power is the voting power of this finality provider at the given height + VotingPower uint64 `protobuf:"varint,3,opt,name=voting_power,json=votingPower,proto3" json:"voting_power,omitempty"` + // slashed_babylon_height indicates the Babylon height when + // the finality provider is slashed. + // if it's 0 then the finality provider is not slashed + SlashedBabylonHeight uint64 `protobuf:"varint,4,opt,name=slashed_babylon_height,json=slashedBabylonHeight,proto3" json:"slashed_babylon_height,omitempty"` + // slashed_btc_height indicates the BTC height when + // the finality provider is slashed. + // if it's 0 then the finality provider is not slashed + SlashedBtcHeight uint32 `protobuf:"varint,5,opt,name=slashed_btc_height,json=slashedBtcHeight,proto3" json:"slashed_btc_height,omitempty"` + // jailed defines whether the finality provider is detected jailed + Jailed bool `protobuf:"varint,6,opt,name=jailed,proto3" json:"jailed,omitempty"` +} + +func (m *ActiveFinalityProvidersAtHeightResponse) Reset() { + *m = ActiveFinalityProvidersAtHeightResponse{} +} +func (m *ActiveFinalityProvidersAtHeightResponse) String() string { return proto.CompactTextString(m) } +func (*ActiveFinalityProvidersAtHeightResponse) ProtoMessage() {} +func (*ActiveFinalityProvidersAtHeightResponse) Descriptor() ([]byte, []int) { return fileDescriptor_32bddab77af6fdae, []int{7} } -func (m *QueryBlockRequest) XXX_Unmarshal(b []byte) error { +func (m *ActiveFinalityProvidersAtHeightResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } -func (m *QueryBlockRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { +func (m *ActiveFinalityProvidersAtHeightResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { - return xxx_messageInfo_QueryBlockRequest.Marshal(b, m, deterministic) + return xxx_messageInfo_ActiveFinalityProvidersAtHeightResponse.Marshal(b, m, deterministic) } else { b = b[:cap(b)] n, err := m.MarshalToSizedBuffer(b) @@ -457,44 +479,78 @@ func (m *QueryBlockRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, e return b[:n], nil } } -func (m *QueryBlockRequest) XXX_Merge(src proto.Message) { - xxx_messageInfo_QueryBlockRequest.Merge(m, src) +func (m *ActiveFinalityProvidersAtHeightResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_ActiveFinalityProvidersAtHeightResponse.Merge(m, src) } -func (m *QueryBlockRequest) XXX_Size() int { +func (m *ActiveFinalityProvidersAtHeightResponse) XXX_Size() int { return m.Size() } -func (m *QueryBlockRequest) XXX_DiscardUnknown() { - xxx_messageInfo_QueryBlockRequest.DiscardUnknown(m) +func (m *ActiveFinalityProvidersAtHeightResponse) XXX_DiscardUnknown() { + xxx_messageInfo_ActiveFinalityProvidersAtHeightResponse.DiscardUnknown(m) } -var xxx_messageInfo_QueryBlockRequest proto.InternalMessageInfo +var xxx_messageInfo_ActiveFinalityProvidersAtHeightResponse proto.InternalMessageInfo -func (m *QueryBlockRequest) GetHeight() uint64 { +func (m *ActiveFinalityProvidersAtHeightResponse) GetHeight() uint64 { if m != nil { return m.Height } return 0 } -// QueryBlockResponse is the response type for the -// Query/Block RPC method. -type QueryBlockResponse struct { - // block is the Babylon at the given height - Block *IndexedBlock `protobuf:"bytes,1,opt,name=block,proto3" json:"block,omitempty"` +func (m *ActiveFinalityProvidersAtHeightResponse) GetVotingPower() uint64 { + if m != nil { + return m.VotingPower + } + return 0 } -func (m *QueryBlockResponse) Reset() { *m = QueryBlockResponse{} } -func (m *QueryBlockResponse) String() string { return proto.CompactTextString(m) } -func (*QueryBlockResponse) ProtoMessage() {} -func (*QueryBlockResponse) Descriptor() ([]byte, []int) { +func (m *ActiveFinalityProvidersAtHeightResponse) GetSlashedBabylonHeight() uint64 { + if m != nil { + return m.SlashedBabylonHeight + } + return 0 +} + +func (m *ActiveFinalityProvidersAtHeightResponse) GetSlashedBtcHeight() uint32 { + if m != nil { + return m.SlashedBtcHeight + } + return 0 +} + +func (m *ActiveFinalityProvidersAtHeightResponse) GetJailed() bool { + if m != nil { + return m.Jailed + } + return false +} + +// QueryActiveFinalityProvidersAtHeightResponse is the response type for the +// Query/ActiveFinalityProvidersAtHeight RPC method. +type QueryActiveFinalityProvidersAtHeightResponse struct { + // finality_providers contains all the queried finality providersn. + FinalityProviders []*ActiveFinalityProvidersAtHeightResponse `protobuf:"bytes,1,rep,name=finality_providers,json=finalityProviders,proto3" json:"finality_providers,omitempty"` + // pagination defines the pagination in the response. + Pagination *query.PageResponse `protobuf:"bytes,2,opt,name=pagination,proto3" json:"pagination,omitempty"` +} + +func (m *QueryActiveFinalityProvidersAtHeightResponse) Reset() { + *m = QueryActiveFinalityProvidersAtHeightResponse{} +} +func (m *QueryActiveFinalityProvidersAtHeightResponse) String() string { + return proto.CompactTextString(m) +} +func (*QueryActiveFinalityProvidersAtHeightResponse) ProtoMessage() {} +func (*QueryActiveFinalityProvidersAtHeightResponse) Descriptor() ([]byte, []int) { return fileDescriptor_32bddab77af6fdae, []int{8} } -func (m *QueryBlockResponse) XXX_Unmarshal(b []byte) error { +func (m *QueryActiveFinalityProvidersAtHeightResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } -func (m *QueryBlockResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { +func (m *QueryActiveFinalityProvidersAtHeightResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { - return xxx_messageInfo_QueryBlockResponse.Marshal(b, m, deterministic) + return xxx_messageInfo_QueryActiveFinalityProvidersAtHeightResponse.Marshal(b, m, deterministic) } else { b = b[:cap(b)] n, err := m.MarshalToSizedBuffer(b) @@ -504,46 +560,48 @@ func (m *QueryBlockResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, return b[:n], nil } } -func (m *QueryBlockResponse) XXX_Merge(src proto.Message) { - xxx_messageInfo_QueryBlockResponse.Merge(m, src) +func (m *QueryActiveFinalityProvidersAtHeightResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryActiveFinalityProvidersAtHeightResponse.Merge(m, src) } -func (m *QueryBlockResponse) XXX_Size() int { +func (m *QueryActiveFinalityProvidersAtHeightResponse) XXX_Size() int { return m.Size() } -func (m *QueryBlockResponse) XXX_DiscardUnknown() { - xxx_messageInfo_QueryBlockResponse.DiscardUnknown(m) +func (m *QueryActiveFinalityProvidersAtHeightResponse) XXX_DiscardUnknown() { + xxx_messageInfo_QueryActiveFinalityProvidersAtHeightResponse.DiscardUnknown(m) } -var xxx_messageInfo_QueryBlockResponse proto.InternalMessageInfo +var xxx_messageInfo_QueryActiveFinalityProvidersAtHeightResponse proto.InternalMessageInfo -func (m *QueryBlockResponse) GetBlock() *IndexedBlock { +func (m *QueryActiveFinalityProvidersAtHeightResponse) GetFinalityProviders() []*ActiveFinalityProvidersAtHeightResponse { if m != nil { - return m.Block + return m.FinalityProviders } return nil } -// QueryListBlocksRequest is the request type for the -// Query/ListBlocks RPC method. -type QueryListBlocksRequest struct { - // status indicates the status of blocks that the querier wants to query - Status QueriedBlockStatus `protobuf:"varint,1,opt,name=status,proto3,enum=babylon.finality.v1.QueriedBlockStatus" json:"status,omitempty"` - // pagination defines an optional pagination for the request. - Pagination *query.PageRequest `protobuf:"bytes,2,opt,name=pagination,proto3" json:"pagination,omitempty"` +func (m *QueryActiveFinalityProvidersAtHeightResponse) GetPagination() *query.PageResponse { + if m != nil { + return m.Pagination + } + return nil } -func (m *QueryListBlocksRequest) Reset() { *m = QueryListBlocksRequest{} } -func (m *QueryListBlocksRequest) String() string { return proto.CompactTextString(m) } -func (*QueryListBlocksRequest) ProtoMessage() {} -func (*QueryListBlocksRequest) Descriptor() ([]byte, []int) { +// QueryActivatedHeightRequest is the request type for the Query/ActivatedHeight RPC method. +type QueryActivatedHeightRequest struct { +} + +func (m *QueryActivatedHeightRequest) Reset() { *m = QueryActivatedHeightRequest{} } +func (m *QueryActivatedHeightRequest) String() string { return proto.CompactTextString(m) } +func (*QueryActivatedHeightRequest) ProtoMessage() {} +func (*QueryActivatedHeightRequest) Descriptor() ([]byte, []int) { return fileDescriptor_32bddab77af6fdae, []int{9} } -func (m *QueryListBlocksRequest) XXX_Unmarshal(b []byte) error { +func (m *QueryActivatedHeightRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } -func (m *QueryListBlocksRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { +func (m *QueryActivatedHeightRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { - return xxx_messageInfo_QueryListBlocksRequest.Marshal(b, m, deterministic) + return xxx_messageInfo_QueryActivatedHeightRequest.Marshal(b, m, deterministic) } else { b = b[:cap(b)] n, err := m.MarshalToSizedBuffer(b) @@ -553,53 +611,35 @@ func (m *QueryListBlocksRequest) XXX_Marshal(b []byte, deterministic bool) ([]by return b[:n], nil } } -func (m *QueryListBlocksRequest) XXX_Merge(src proto.Message) { - xxx_messageInfo_QueryListBlocksRequest.Merge(m, src) +func (m *QueryActivatedHeightRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryActivatedHeightRequest.Merge(m, src) } -func (m *QueryListBlocksRequest) XXX_Size() int { +func (m *QueryActivatedHeightRequest) XXX_Size() int { return m.Size() } -func (m *QueryListBlocksRequest) XXX_DiscardUnknown() { - xxx_messageInfo_QueryListBlocksRequest.DiscardUnknown(m) +func (m *QueryActivatedHeightRequest) XXX_DiscardUnknown() { + xxx_messageInfo_QueryActivatedHeightRequest.DiscardUnknown(m) } -var xxx_messageInfo_QueryListBlocksRequest proto.InternalMessageInfo +var xxx_messageInfo_QueryActivatedHeightRequest proto.InternalMessageInfo -func (m *QueryListBlocksRequest) GetStatus() QueriedBlockStatus { - if m != nil { - return m.Status - } - return QueriedBlockStatus_NON_FINALIZED +// QueryActivatedHeightResponse is the response type for the Query/ActivatedHeight RPC method. +type QueryActivatedHeightResponse struct { + Height uint64 `protobuf:"varint,1,opt,name=height,proto3" json:"height,omitempty"` } -func (m *QueryListBlocksRequest) GetPagination() *query.PageRequest { - if m != nil { - return m.Pagination - } - return nil -} - -// QueryListBlocksResponse is the response type for the -// Query/ListBlocks RPC method. -type QueryListBlocksResponse struct { - // blocks is the list of blocks at the given status - Blocks []*IndexedBlock `protobuf:"bytes,1,rep,name=blocks,proto3" json:"blocks,omitempty"` - // pagination defines the pagination in the response. - Pagination *query.PageResponse `protobuf:"bytes,2,opt,name=pagination,proto3" json:"pagination,omitempty"` -} - -func (m *QueryListBlocksResponse) Reset() { *m = QueryListBlocksResponse{} } -func (m *QueryListBlocksResponse) String() string { return proto.CompactTextString(m) } -func (*QueryListBlocksResponse) ProtoMessage() {} -func (*QueryListBlocksResponse) Descriptor() ([]byte, []int) { +func (m *QueryActivatedHeightResponse) Reset() { *m = QueryActivatedHeightResponse{} } +func (m *QueryActivatedHeightResponse) String() string { return proto.CompactTextString(m) } +func (*QueryActivatedHeightResponse) ProtoMessage() {} +func (*QueryActivatedHeightResponse) Descriptor() ([]byte, []int) { return fileDescriptor_32bddab77af6fdae, []int{10} } -func (m *QueryListBlocksResponse) XXX_Unmarshal(b []byte) error { +func (m *QueryActivatedHeightResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } -func (m *QueryListBlocksResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { +func (m *QueryActivatedHeightResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { - return xxx_messageInfo_QueryListBlocksResponse.Marshal(b, m, deterministic) + return xxx_messageInfo_QueryActivatedHeightResponse.Marshal(b, m, deterministic) } else { b = b[:cap(b)] n, err := m.MarshalToSizedBuffer(b) @@ -609,51 +649,46 @@ func (m *QueryListBlocksResponse) XXX_Marshal(b []byte, deterministic bool) ([]b return b[:n], nil } } -func (m *QueryListBlocksResponse) XXX_Merge(src proto.Message) { - xxx_messageInfo_QueryListBlocksResponse.Merge(m, src) +func (m *QueryActivatedHeightResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryActivatedHeightResponse.Merge(m, src) } -func (m *QueryListBlocksResponse) XXX_Size() int { +func (m *QueryActivatedHeightResponse) XXX_Size() int { return m.Size() } -func (m *QueryListBlocksResponse) XXX_DiscardUnknown() { - xxx_messageInfo_QueryListBlocksResponse.DiscardUnknown(m) +func (m *QueryActivatedHeightResponse) XXX_DiscardUnknown() { + xxx_messageInfo_QueryActivatedHeightResponse.DiscardUnknown(m) } -var xxx_messageInfo_QueryListBlocksResponse proto.InternalMessageInfo - -func (m *QueryListBlocksResponse) GetBlocks() []*IndexedBlock { - if m != nil { - return m.Blocks - } - return nil -} +var xxx_messageInfo_QueryActivatedHeightResponse proto.InternalMessageInfo -func (m *QueryListBlocksResponse) GetPagination() *query.PageResponse { +func (m *QueryActivatedHeightResponse) GetHeight() uint64 { if m != nil { - return m.Pagination + return m.Height } - return nil + return 0 } -// QueryVotesAtHeightRequest is the request type for the -// Query/VotesAtHeight RPC method. -type QueryVotesAtHeightRequest struct { - // height defines at which height to query the finality providers. - Height uint64 `protobuf:"varint,1,opt,name=height,proto3" json:"height,omitempty"` +// QueryListPublicRandomnessRequest is the request type for the +// Query/ListPublicRandomness RPC method. +type QueryListPublicRandomnessRequest struct { + // fp_btc_pk_hex is the hex str of Bitcoin secp256k1 PK of the finality provider + FpBtcPkHex string `protobuf:"bytes,1,opt,name=fp_btc_pk_hex,json=fpBtcPkHex,proto3" json:"fp_btc_pk_hex,omitempty"` + // pagination defines an optional pagination for the request. + Pagination *query.PageRequest `protobuf:"bytes,2,opt,name=pagination,proto3" json:"pagination,omitempty"` } -func (m *QueryVotesAtHeightRequest) Reset() { *m = QueryVotesAtHeightRequest{} } -func (m *QueryVotesAtHeightRequest) String() string { return proto.CompactTextString(m) } -func (*QueryVotesAtHeightRequest) ProtoMessage() {} -func (*QueryVotesAtHeightRequest) Descriptor() ([]byte, []int) { +func (m *QueryListPublicRandomnessRequest) Reset() { *m = QueryListPublicRandomnessRequest{} } +func (m *QueryListPublicRandomnessRequest) String() string { return proto.CompactTextString(m) } +func (*QueryListPublicRandomnessRequest) ProtoMessage() {} +func (*QueryListPublicRandomnessRequest) Descriptor() ([]byte, []int) { return fileDescriptor_32bddab77af6fdae, []int{11} } -func (m *QueryVotesAtHeightRequest) XXX_Unmarshal(b []byte) error { +func (m *QueryListPublicRandomnessRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } -func (m *QueryVotesAtHeightRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { +func (m *QueryListPublicRandomnessRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { - return xxx_messageInfo_QueryVotesAtHeightRequest.Marshal(b, m, deterministic) + return xxx_messageInfo_QueryListPublicRandomnessRequest.Marshal(b, m, deterministic) } else { b = b[:cap(b)] n, err := m.MarshalToSizedBuffer(b) @@ -663,45 +698,54 @@ func (m *QueryVotesAtHeightRequest) XXX_Marshal(b []byte, deterministic bool) ([ return b[:n], nil } } -func (m *QueryVotesAtHeightRequest) XXX_Merge(src proto.Message) { - xxx_messageInfo_QueryVotesAtHeightRequest.Merge(m, src) +func (m *QueryListPublicRandomnessRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryListPublicRandomnessRequest.Merge(m, src) } -func (m *QueryVotesAtHeightRequest) XXX_Size() int { +func (m *QueryListPublicRandomnessRequest) XXX_Size() int { return m.Size() } -func (m *QueryVotesAtHeightRequest) XXX_DiscardUnknown() { - xxx_messageInfo_QueryVotesAtHeightRequest.DiscardUnknown(m) +func (m *QueryListPublicRandomnessRequest) XXX_DiscardUnknown() { + xxx_messageInfo_QueryListPublicRandomnessRequest.DiscardUnknown(m) } -var xxx_messageInfo_QueryVotesAtHeightRequest proto.InternalMessageInfo +var xxx_messageInfo_QueryListPublicRandomnessRequest proto.InternalMessageInfo -func (m *QueryVotesAtHeightRequest) GetHeight() uint64 { +func (m *QueryListPublicRandomnessRequest) GetFpBtcPkHex() string { if m != nil { - return m.Height + return m.FpBtcPkHex } - return 0 + return "" } -// QueryVotesAtHeightResponse is the response type for the -// Query/VotesAtHeight RPC method. -type QueryVotesAtHeightResponse struct { - // btc_pk is the Bitcoin secp256k1 PK of finality providers who have signed the block at given height. - // the PK follows encoding in BIP-340 spec - BtcPks []github_com_babylonlabs_io_babylon_types.BIP340PubKey `protobuf:"bytes,1,rep,name=btc_pks,json=btcPks,proto3,customtype=github.com/babylonlabs-io/babylon/types.BIP340PubKey" json:"btc_pks,omitempty"` +func (m *QueryListPublicRandomnessRequest) GetPagination() *query.PageRequest { + if m != nil { + return m.Pagination + } + return nil } -func (m *QueryVotesAtHeightResponse) Reset() { *m = QueryVotesAtHeightResponse{} } -func (m *QueryVotesAtHeightResponse) String() string { return proto.CompactTextString(m) } -func (*QueryVotesAtHeightResponse) ProtoMessage() {} -func (*QueryVotesAtHeightResponse) Descriptor() ([]byte, []int) { +// QueryListPublicRandomnessResponse is the response type for the +// Query/ListPublicRandomness RPC method. +type QueryListPublicRandomnessResponse struct { + // pub_rand_map is the map where the key is the height and the value + // is the public randomness at this height for the given finality provider + PubRandMap map[uint64]*github_com_babylonlabs_io_babylon_types.SchnorrPubRand `protobuf:"bytes,1,rep,name=pub_rand_map,json=pubRandMap,proto3,customtype=github.com/babylonlabs-io/babylon/types.SchnorrPubRand" json:"pub_rand_map,omitempty" protobuf_key:"varint,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"` + // pagination defines the pagination in the response. + Pagination *query.PageResponse `protobuf:"bytes,2,opt,name=pagination,proto3" json:"pagination,omitempty"` +} + +func (m *QueryListPublicRandomnessResponse) Reset() { *m = QueryListPublicRandomnessResponse{} } +func (m *QueryListPublicRandomnessResponse) String() string { return proto.CompactTextString(m) } +func (*QueryListPublicRandomnessResponse) ProtoMessage() {} +func (*QueryListPublicRandomnessResponse) Descriptor() ([]byte, []int) { return fileDescriptor_32bddab77af6fdae, []int{12} } -func (m *QueryVotesAtHeightResponse) XXX_Unmarshal(b []byte) error { +func (m *QueryListPublicRandomnessResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } -func (m *QueryVotesAtHeightResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { +func (m *QueryListPublicRandomnessResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { - return xxx_messageInfo_QueryVotesAtHeightResponse.Marshal(b, m, deterministic) + return xxx_messageInfo_QueryListPublicRandomnessResponse.Marshal(b, m, deterministic) } else { b = b[:cap(b)] n, err := m.MarshalToSizedBuffer(b) @@ -711,38 +755,47 @@ func (m *QueryVotesAtHeightResponse) XXX_Marshal(b []byte, deterministic bool) ( return b[:n], nil } } -func (m *QueryVotesAtHeightResponse) XXX_Merge(src proto.Message) { - xxx_messageInfo_QueryVotesAtHeightResponse.Merge(m, src) +func (m *QueryListPublicRandomnessResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryListPublicRandomnessResponse.Merge(m, src) } -func (m *QueryVotesAtHeightResponse) XXX_Size() int { +func (m *QueryListPublicRandomnessResponse) XXX_Size() int { return m.Size() } -func (m *QueryVotesAtHeightResponse) XXX_DiscardUnknown() { - xxx_messageInfo_QueryVotesAtHeightResponse.DiscardUnknown(m) +func (m *QueryListPublicRandomnessResponse) XXX_DiscardUnknown() { + xxx_messageInfo_QueryListPublicRandomnessResponse.DiscardUnknown(m) } -var xxx_messageInfo_QueryVotesAtHeightResponse proto.InternalMessageInfo +var xxx_messageInfo_QueryListPublicRandomnessResponse proto.InternalMessageInfo -// QueryEvidenceRequest is the request type for the -// Query/Evidence RPC method. -type QueryEvidenceRequest struct { - // fp_btc_pk_hex is the hex str of Bitcoin secp256k1 PK - // (in BIP340 format) of the finality provider - FpBtcPkHex string `protobuf:"bytes,1,opt,name=fp_btc_pk_hex,json=fpBtcPkHex,proto3" json:"fp_btc_pk_hex,omitempty"` +func (m *QueryListPublicRandomnessResponse) GetPagination() *query.PageResponse { + if m != nil { + return m.Pagination + } + return nil } -func (m *QueryEvidenceRequest) Reset() { *m = QueryEvidenceRequest{} } -func (m *QueryEvidenceRequest) String() string { return proto.CompactTextString(m) } -func (*QueryEvidenceRequest) ProtoMessage() {} -func (*QueryEvidenceRequest) Descriptor() ([]byte, []int) { +// PubRandCommitResponse is the response type for a public randomness commitment +type PubRandCommitResponse struct { + // num_pub_rand is the number of committed public randomness + NumPubRand uint64 `protobuf:"varint,1,opt,name=num_pub_rand,json=numPubRand,proto3" json:"num_pub_rand,omitempty"` + // commitment is the value of the commitment + Commitment []byte `protobuf:"bytes,2,opt,name=commitment,proto3" json:"commitment,omitempty"` + // epoch_num defines the epoch number that the commit falls into + EpochNum uint64 `protobuf:"varint,3,opt,name=epoch_num,json=epochNum,proto3" json:"epoch_num,omitempty"` +} + +func (m *PubRandCommitResponse) Reset() { *m = PubRandCommitResponse{} } +func (m *PubRandCommitResponse) String() string { return proto.CompactTextString(m) } +func (*PubRandCommitResponse) ProtoMessage() {} +func (*PubRandCommitResponse) Descriptor() ([]byte, []int) { return fileDescriptor_32bddab77af6fdae, []int{13} } -func (m *QueryEvidenceRequest) XXX_Unmarshal(b []byte) error { +func (m *PubRandCommitResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } -func (m *QueryEvidenceRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { +func (m *PubRandCommitResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { - return xxx_messageInfo_QueryEvidenceRequest.Marshal(b, m, deterministic) + return xxx_messageInfo_PubRandCommitResponse.Marshal(b, m, deterministic) } else { b = b[:cap(b)] n, err := m.MarshalToSizedBuffer(b) @@ -752,43 +805,60 @@ func (m *QueryEvidenceRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte return b[:n], nil } } -func (m *QueryEvidenceRequest) XXX_Merge(src proto.Message) { - xxx_messageInfo_QueryEvidenceRequest.Merge(m, src) +func (m *PubRandCommitResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_PubRandCommitResponse.Merge(m, src) } -func (m *QueryEvidenceRequest) XXX_Size() int { +func (m *PubRandCommitResponse) XXX_Size() int { return m.Size() } -func (m *QueryEvidenceRequest) XXX_DiscardUnknown() { - xxx_messageInfo_QueryEvidenceRequest.DiscardUnknown(m) +func (m *PubRandCommitResponse) XXX_DiscardUnknown() { + xxx_messageInfo_PubRandCommitResponse.DiscardUnknown(m) } -var xxx_messageInfo_QueryEvidenceRequest proto.InternalMessageInfo +var xxx_messageInfo_PubRandCommitResponse proto.InternalMessageInfo -func (m *QueryEvidenceRequest) GetFpBtcPkHex() string { +func (m *PubRandCommitResponse) GetNumPubRand() uint64 { if m != nil { - return m.FpBtcPkHex + return m.NumPubRand } - return "" + return 0 } -// QueryEvidenceResponse is the response type for the -// Query/Evidence RPC method. -type QueryEvidenceResponse struct { - Evidence *Evidence `protobuf:"bytes,1,opt,name=evidence,proto3" json:"evidence,omitempty"` +func (m *PubRandCommitResponse) GetCommitment() []byte { + if m != nil { + return m.Commitment + } + return nil } -func (m *QueryEvidenceResponse) Reset() { *m = QueryEvidenceResponse{} } -func (m *QueryEvidenceResponse) String() string { return proto.CompactTextString(m) } -func (*QueryEvidenceResponse) ProtoMessage() {} -func (*QueryEvidenceResponse) Descriptor() ([]byte, []int) { +func (m *PubRandCommitResponse) GetEpochNum() uint64 { + if m != nil { + return m.EpochNum + } + return 0 +} + +// QueryListPubRandCommitRequest is the request type for the +// Query/ListPubRandCommit RPC method. +type QueryListPubRandCommitRequest struct { + // fp_btc_pk_hex is the hex str of Bitcoin secp256k1 PK of the finality provider + FpBtcPkHex string `protobuf:"bytes,1,opt,name=fp_btc_pk_hex,json=fpBtcPkHex,proto3" json:"fp_btc_pk_hex,omitempty"` + // pagination defines an optional pagination for the request. + Pagination *query.PageRequest `protobuf:"bytes,2,opt,name=pagination,proto3" json:"pagination,omitempty"` +} + +func (m *QueryListPubRandCommitRequest) Reset() { *m = QueryListPubRandCommitRequest{} } +func (m *QueryListPubRandCommitRequest) String() string { return proto.CompactTextString(m) } +func (*QueryListPubRandCommitRequest) ProtoMessage() {} +func (*QueryListPubRandCommitRequest) Descriptor() ([]byte, []int) { return fileDescriptor_32bddab77af6fdae, []int{14} } -func (m *QueryEvidenceResponse) XXX_Unmarshal(b []byte) error { +func (m *QueryListPubRandCommitRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } -func (m *QueryEvidenceResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { +func (m *QueryListPubRandCommitRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { - return xxx_messageInfo_QueryEvidenceResponse.Marshal(b, m, deterministic) + return xxx_messageInfo_QueryListPubRandCommitRequest.Marshal(b, m, deterministic) } else { b = b[:cap(b)] n, err := m.MarshalToSizedBuffer(b) @@ -798,47 +868,54 @@ func (m *QueryEvidenceResponse) XXX_Marshal(b []byte, deterministic bool) ([]byt return b[:n], nil } } -func (m *QueryEvidenceResponse) XXX_Merge(src proto.Message) { - xxx_messageInfo_QueryEvidenceResponse.Merge(m, src) +func (m *QueryListPubRandCommitRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryListPubRandCommitRequest.Merge(m, src) } -func (m *QueryEvidenceResponse) XXX_Size() int { +func (m *QueryListPubRandCommitRequest) XXX_Size() int { return m.Size() } -func (m *QueryEvidenceResponse) XXX_DiscardUnknown() { - xxx_messageInfo_QueryEvidenceResponse.DiscardUnknown(m) +func (m *QueryListPubRandCommitRequest) XXX_DiscardUnknown() { + xxx_messageInfo_QueryListPubRandCommitRequest.DiscardUnknown(m) } -var xxx_messageInfo_QueryEvidenceResponse proto.InternalMessageInfo +var xxx_messageInfo_QueryListPubRandCommitRequest proto.InternalMessageInfo -func (m *QueryEvidenceResponse) GetEvidence() *Evidence { +func (m *QueryListPubRandCommitRequest) GetFpBtcPkHex() string { if m != nil { - return m.Evidence + return m.FpBtcPkHex } - return nil + return "" } -// QueryListEvidencesRequest is the request type for the -// Query/ListEvidences RPC method. -type QueryListEvidencesRequest struct { - // start_height is the starting height that the querier specifies - // such that the RPC will only return evidences since this height - StartHeight uint64 `protobuf:"varint,1,opt,name=start_height,json=startHeight,proto3" json:"start_height,omitempty"` - // pagination defines an optional pagination for the request. - Pagination *query.PageRequest `protobuf:"bytes,2,opt,name=pagination,proto3" json:"pagination,omitempty"` +func (m *QueryListPubRandCommitRequest) GetPagination() *query.PageRequest { + if m != nil { + return m.Pagination + } + return nil } -func (m *QueryListEvidencesRequest) Reset() { *m = QueryListEvidencesRequest{} } -func (m *QueryListEvidencesRequest) String() string { return proto.CompactTextString(m) } -func (*QueryListEvidencesRequest) ProtoMessage() {} -func (*QueryListEvidencesRequest) Descriptor() ([]byte, []int) { +// QueryListPubRandCommitResponse is the response type for the +// Query/ListPubRandCommit RPC method. +type QueryListPubRandCommitResponse struct { + // pub_rand_commit_map is the map where the key is the start height and the value + // is the public randomness commitment at this height for the given finality provider + PubRandCommitMap map[uint64]*PubRandCommitResponse `protobuf:"bytes,1,rep,name=pub_rand_commit_map,json=pubRandCommitMap,proto3" json:"pub_rand_commit_map,omitempty" protobuf_key:"varint,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"` + // pagination defines the pagination in the response. + Pagination *query.PageResponse `protobuf:"bytes,2,opt,name=pagination,proto3" json:"pagination,omitempty"` +} + +func (m *QueryListPubRandCommitResponse) Reset() { *m = QueryListPubRandCommitResponse{} } +func (m *QueryListPubRandCommitResponse) String() string { return proto.CompactTextString(m) } +func (*QueryListPubRandCommitResponse) ProtoMessage() {} +func (*QueryListPubRandCommitResponse) Descriptor() ([]byte, []int) { return fileDescriptor_32bddab77af6fdae, []int{15} } -func (m *QueryListEvidencesRequest) XXX_Unmarshal(b []byte) error { +func (m *QueryListPubRandCommitResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } -func (m *QueryListEvidencesRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { +func (m *QueryListPubRandCommitResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { - return xxx_messageInfo_QueryListEvidencesRequest.Marshal(b, m, deterministic) + return xxx_messageInfo_QueryListPubRandCommitResponse.Marshal(b, m, deterministic) } else { b = b[:cap(b)] n, err := m.MarshalToSizedBuffer(b) @@ -848,53 +925,51 @@ func (m *QueryListEvidencesRequest) XXX_Marshal(b []byte, deterministic bool) ([ return b[:n], nil } } -func (m *QueryListEvidencesRequest) XXX_Merge(src proto.Message) { - xxx_messageInfo_QueryListEvidencesRequest.Merge(m, src) +func (m *QueryListPubRandCommitResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryListPubRandCommitResponse.Merge(m, src) } -func (m *QueryListEvidencesRequest) XXX_Size() int { +func (m *QueryListPubRandCommitResponse) XXX_Size() int { return m.Size() } -func (m *QueryListEvidencesRequest) XXX_DiscardUnknown() { - xxx_messageInfo_QueryListEvidencesRequest.DiscardUnknown(m) +func (m *QueryListPubRandCommitResponse) XXX_DiscardUnknown() { + xxx_messageInfo_QueryListPubRandCommitResponse.DiscardUnknown(m) } -var xxx_messageInfo_QueryListEvidencesRequest proto.InternalMessageInfo +var xxx_messageInfo_QueryListPubRandCommitResponse proto.InternalMessageInfo -func (m *QueryListEvidencesRequest) GetStartHeight() uint64 { +func (m *QueryListPubRandCommitResponse) GetPubRandCommitMap() map[uint64]*PubRandCommitResponse { if m != nil { - return m.StartHeight + return m.PubRandCommitMap } - return 0 + return nil } -func (m *QueryListEvidencesRequest) GetPagination() *query.PageRequest { +func (m *QueryListPubRandCommitResponse) GetPagination() *query.PageResponse { if m != nil { return m.Pagination } return nil } -// QueryListEvidencesResponse is the response type for the -// Query/ListEvidences RPC method. -type QueryListEvidencesResponse struct { - // blocks is the list of evidences - Evidences []*Evidence `protobuf:"bytes,1,rep,name=evidences,proto3" json:"evidences,omitempty"` - // pagination defines the pagination in the response. - Pagination *query.PageResponse `protobuf:"bytes,2,opt,name=pagination,proto3" json:"pagination,omitempty"` +// QueryBlockRequest is the request type for the +// Query/Block RPC method. +type QueryBlockRequest struct { + // height is the height of the Babylon block + Height uint64 `protobuf:"varint,1,opt,name=height,proto3" json:"height,omitempty"` } -func (m *QueryListEvidencesResponse) Reset() { *m = QueryListEvidencesResponse{} } -func (m *QueryListEvidencesResponse) String() string { return proto.CompactTextString(m) } -func (*QueryListEvidencesResponse) ProtoMessage() {} -func (*QueryListEvidencesResponse) Descriptor() ([]byte, []int) { +func (m *QueryBlockRequest) Reset() { *m = QueryBlockRequest{} } +func (m *QueryBlockRequest) String() string { return proto.CompactTextString(m) } +func (*QueryBlockRequest) ProtoMessage() {} +func (*QueryBlockRequest) Descriptor() ([]byte, []int) { return fileDescriptor_32bddab77af6fdae, []int{16} } -func (m *QueryListEvidencesResponse) XXX_Unmarshal(b []byte) error { +func (m *QueryBlockRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } -func (m *QueryListEvidencesResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { +func (m *QueryBlockRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { - return xxx_messageInfo_QueryListEvidencesResponse.Marshal(b, m, deterministic) + return xxx_messageInfo_QueryBlockRequest.Marshal(b, m, deterministic) } else { b = b[:cap(b)] n, err := m.MarshalToSizedBuffer(b) @@ -904,52 +979,44 @@ func (m *QueryListEvidencesResponse) XXX_Marshal(b []byte, deterministic bool) ( return b[:n], nil } } -func (m *QueryListEvidencesResponse) XXX_Merge(src proto.Message) { - xxx_messageInfo_QueryListEvidencesResponse.Merge(m, src) +func (m *QueryBlockRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryBlockRequest.Merge(m, src) } -func (m *QueryListEvidencesResponse) XXX_Size() int { +func (m *QueryBlockRequest) XXX_Size() int { return m.Size() } -func (m *QueryListEvidencesResponse) XXX_DiscardUnknown() { - xxx_messageInfo_QueryListEvidencesResponse.DiscardUnknown(m) +func (m *QueryBlockRequest) XXX_DiscardUnknown() { + xxx_messageInfo_QueryBlockRequest.DiscardUnknown(m) } -var xxx_messageInfo_QueryListEvidencesResponse proto.InternalMessageInfo - -func (m *QueryListEvidencesResponse) GetEvidences() []*Evidence { - if m != nil { - return m.Evidences - } - return nil -} +var xxx_messageInfo_QueryBlockRequest proto.InternalMessageInfo -func (m *QueryListEvidencesResponse) GetPagination() *query.PageResponse { +func (m *QueryBlockRequest) GetHeight() uint64 { if m != nil { - return m.Pagination + return m.Height } - return nil + return 0 } -// QuerySigningInfoRequest is the request type for the Query/SigningInfo RPC -// method -type QuerySigningInfoRequest struct { - // fp_btc_pk_hex is the hex str of Bitcoin secp256k1 PK - // (in BIP340 format) of the finality provider - FpBtcPkHex string `protobuf:"bytes,1,opt,name=fp_btc_pk_hex,json=fpBtcPkHex,proto3" json:"fp_btc_pk_hex,omitempty"` +// QueryBlockResponse is the response type for the +// Query/Block RPC method. +type QueryBlockResponse struct { + // block is the Babylon at the given height + Block *IndexedBlock `protobuf:"bytes,1,opt,name=block,proto3" json:"block,omitempty"` } -func (m *QuerySigningInfoRequest) Reset() { *m = QuerySigningInfoRequest{} } -func (m *QuerySigningInfoRequest) String() string { return proto.CompactTextString(m) } -func (*QuerySigningInfoRequest) ProtoMessage() {} -func (*QuerySigningInfoRequest) Descriptor() ([]byte, []int) { +func (m *QueryBlockResponse) Reset() { *m = QueryBlockResponse{} } +func (m *QueryBlockResponse) String() string { return proto.CompactTextString(m) } +func (*QueryBlockResponse) ProtoMessage() {} +func (*QueryBlockResponse) Descriptor() ([]byte, []int) { return fileDescriptor_32bddab77af6fdae, []int{17} } -func (m *QuerySigningInfoRequest) XXX_Unmarshal(b []byte) error { +func (m *QueryBlockResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } -func (m *QuerySigningInfoRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { +func (m *QueryBlockResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { - return xxx_messageInfo_QuerySigningInfoRequest.Marshal(b, m, deterministic) + return xxx_messageInfo_QueryBlockResponse.Marshal(b, m, deterministic) } else { b = b[:cap(b)] n, err := m.MarshalToSizedBuffer(b) @@ -959,44 +1026,46 @@ func (m *QuerySigningInfoRequest) XXX_Marshal(b []byte, deterministic bool) ([]b return b[:n], nil } } -func (m *QuerySigningInfoRequest) XXX_Merge(src proto.Message) { - xxx_messageInfo_QuerySigningInfoRequest.Merge(m, src) +func (m *QueryBlockResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryBlockResponse.Merge(m, src) } -func (m *QuerySigningInfoRequest) XXX_Size() int { +func (m *QueryBlockResponse) XXX_Size() int { return m.Size() } -func (m *QuerySigningInfoRequest) XXX_DiscardUnknown() { - xxx_messageInfo_QuerySigningInfoRequest.DiscardUnknown(m) +func (m *QueryBlockResponse) XXX_DiscardUnknown() { + xxx_messageInfo_QueryBlockResponse.DiscardUnknown(m) } -var xxx_messageInfo_QuerySigningInfoRequest proto.InternalMessageInfo +var xxx_messageInfo_QueryBlockResponse proto.InternalMessageInfo -func (m *QuerySigningInfoRequest) GetFpBtcPkHex() string { +func (m *QueryBlockResponse) GetBlock() *IndexedBlock { if m != nil { - return m.FpBtcPkHex + return m.Block } - return "" + return nil } -// QuerySigningInfoResponse is the response type for the Query/SigningInfo RPC -// method -type QuerySigningInfoResponse struct { - // fp_signing_info is the signing info of requested finality provider BTC public key - FpSigningInfo FinalityProviderSigningInfo `protobuf:"bytes,1,opt,name=fp_signing_info,json=fpSigningInfo,proto3" json:"fp_signing_info"` +// QueryListBlocksRequest is the request type for the +// Query/ListBlocks RPC method. +type QueryListBlocksRequest struct { + // status indicates the status of blocks that the querier wants to query + Status QueriedBlockStatus `protobuf:"varint,1,opt,name=status,proto3,enum=babylon.finality.v1.QueriedBlockStatus" json:"status,omitempty"` + // pagination defines an optional pagination for the request. + Pagination *query.PageRequest `protobuf:"bytes,2,opt,name=pagination,proto3" json:"pagination,omitempty"` } -func (m *QuerySigningInfoResponse) Reset() { *m = QuerySigningInfoResponse{} } -func (m *QuerySigningInfoResponse) String() string { return proto.CompactTextString(m) } -func (*QuerySigningInfoResponse) ProtoMessage() {} -func (*QuerySigningInfoResponse) Descriptor() ([]byte, []int) { +func (m *QueryListBlocksRequest) Reset() { *m = QueryListBlocksRequest{} } +func (m *QueryListBlocksRequest) String() string { return proto.CompactTextString(m) } +func (*QueryListBlocksRequest) ProtoMessage() {} +func (*QueryListBlocksRequest) Descriptor() ([]byte, []int) { return fileDescriptor_32bddab77af6fdae, []int{18} } -func (m *QuerySigningInfoResponse) XXX_Unmarshal(b []byte) error { +func (m *QueryListBlocksRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } -func (m *QuerySigningInfoResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { +func (m *QueryListBlocksRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { - return xxx_messageInfo_QuerySigningInfoResponse.Marshal(b, m, deterministic) + return xxx_messageInfo_QueryListBlocksRequest.Marshal(b, m, deterministic) } else { b = b[:cap(b)] n, err := m.MarshalToSizedBuffer(b) @@ -1006,43 +1075,53 @@ func (m *QuerySigningInfoResponse) XXX_Marshal(b []byte, deterministic bool) ([] return b[:n], nil } } -func (m *QuerySigningInfoResponse) XXX_Merge(src proto.Message) { - xxx_messageInfo_QuerySigningInfoResponse.Merge(m, src) +func (m *QueryListBlocksRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryListBlocksRequest.Merge(m, src) } -func (m *QuerySigningInfoResponse) XXX_Size() int { +func (m *QueryListBlocksRequest) XXX_Size() int { return m.Size() } -func (m *QuerySigningInfoResponse) XXX_DiscardUnknown() { - xxx_messageInfo_QuerySigningInfoResponse.DiscardUnknown(m) +func (m *QueryListBlocksRequest) XXX_DiscardUnknown() { + xxx_messageInfo_QueryListBlocksRequest.DiscardUnknown(m) } -var xxx_messageInfo_QuerySigningInfoResponse proto.InternalMessageInfo +var xxx_messageInfo_QueryListBlocksRequest proto.InternalMessageInfo -func (m *QuerySigningInfoResponse) GetFpSigningInfo() FinalityProviderSigningInfo { +func (m *QueryListBlocksRequest) GetStatus() QueriedBlockStatus { if m != nil { - return m.FpSigningInfo + return m.Status } - return FinalityProviderSigningInfo{} + return QueriedBlockStatus_NON_FINALIZED } -// QuerySigningInfosRequest is the request type for the Query/SigningInfos RPC -// method -type QuerySigningInfosRequest struct { - Pagination *query.PageRequest `protobuf:"bytes,1,opt,name=pagination,proto3" json:"pagination,omitempty"` +func (m *QueryListBlocksRequest) GetPagination() *query.PageRequest { + if m != nil { + return m.Pagination + } + return nil } -func (m *QuerySigningInfosRequest) Reset() { *m = QuerySigningInfosRequest{} } -func (m *QuerySigningInfosRequest) String() string { return proto.CompactTextString(m) } -func (*QuerySigningInfosRequest) ProtoMessage() {} -func (*QuerySigningInfosRequest) Descriptor() ([]byte, []int) { +// QueryListBlocksResponse is the response type for the +// Query/ListBlocks RPC method. +type QueryListBlocksResponse struct { + // blocks is the list of blocks at the given status + Blocks []*IndexedBlock `protobuf:"bytes,1,rep,name=blocks,proto3" json:"blocks,omitempty"` + // pagination defines the pagination in the response. + Pagination *query.PageResponse `protobuf:"bytes,2,opt,name=pagination,proto3" json:"pagination,omitempty"` +} + +func (m *QueryListBlocksResponse) Reset() { *m = QueryListBlocksResponse{} } +func (m *QueryListBlocksResponse) String() string { return proto.CompactTextString(m) } +func (*QueryListBlocksResponse) ProtoMessage() {} +func (*QueryListBlocksResponse) Descriptor() ([]byte, []int) { return fileDescriptor_32bddab77af6fdae, []int{19} } -func (m *QuerySigningInfosRequest) XXX_Unmarshal(b []byte) error { +func (m *QueryListBlocksResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } -func (m *QuerySigningInfosRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { +func (m *QueryListBlocksResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { - return xxx_messageInfo_QuerySigningInfosRequest.Marshal(b, m, deterministic) + return xxx_messageInfo_QueryListBlocksResponse.Marshal(b, m, deterministic) } else { b = b[:cap(b)] n, err := m.MarshalToSizedBuffer(b) @@ -1052,45 +1131,51 @@ func (m *QuerySigningInfosRequest) XXX_Marshal(b []byte, deterministic bool) ([] return b[:n], nil } } -func (m *QuerySigningInfosRequest) XXX_Merge(src proto.Message) { - xxx_messageInfo_QuerySigningInfosRequest.Merge(m, src) +func (m *QueryListBlocksResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryListBlocksResponse.Merge(m, src) } -func (m *QuerySigningInfosRequest) XXX_Size() int { +func (m *QueryListBlocksResponse) XXX_Size() int { return m.Size() } -func (m *QuerySigningInfosRequest) XXX_DiscardUnknown() { - xxx_messageInfo_QuerySigningInfosRequest.DiscardUnknown(m) +func (m *QueryListBlocksResponse) XXX_DiscardUnknown() { + xxx_messageInfo_QueryListBlocksResponse.DiscardUnknown(m) } -var xxx_messageInfo_QuerySigningInfosRequest proto.InternalMessageInfo +var xxx_messageInfo_QueryListBlocksResponse proto.InternalMessageInfo -func (m *QuerySigningInfosRequest) GetPagination() *query.PageRequest { +func (m *QueryListBlocksResponse) GetBlocks() []*IndexedBlock { + if m != nil { + return m.Blocks + } + return nil +} + +func (m *QueryListBlocksResponse) GetPagination() *query.PageResponse { if m != nil { return m.Pagination } return nil } -// QuerySigningInfosResponse is the response type for the Query/SigningInfos RPC -// method -type QuerySigningInfosResponse struct { - // info is the signing info of all finality providers with signing info - FpSigningInfos []FinalityProviderSigningInfo `protobuf:"bytes,1,rep,name=fp_signing_infos,json=fpSigningInfos,proto3" json:"fp_signing_infos"` - Pagination *query.PageResponse `protobuf:"bytes,2,opt,name=pagination,proto3" json:"pagination,omitempty"` +// QueryVotesAtHeightRequest is the request type for the +// Query/VotesAtHeight RPC method. +type QueryVotesAtHeightRequest struct { + // height defines at which height to query the finality providers. + Height uint64 `protobuf:"varint,1,opt,name=height,proto3" json:"height,omitempty"` } -func (m *QuerySigningInfosResponse) Reset() { *m = QuerySigningInfosResponse{} } -func (m *QuerySigningInfosResponse) String() string { return proto.CompactTextString(m) } -func (*QuerySigningInfosResponse) ProtoMessage() {} -func (*QuerySigningInfosResponse) Descriptor() ([]byte, []int) { +func (m *QueryVotesAtHeightRequest) Reset() { *m = QueryVotesAtHeightRequest{} } +func (m *QueryVotesAtHeightRequest) String() string { return proto.CompactTextString(m) } +func (*QueryVotesAtHeightRequest) ProtoMessage() {} +func (*QueryVotesAtHeightRequest) Descriptor() ([]byte, []int) { return fileDescriptor_32bddab77af6fdae, []int{20} } -func (m *QuerySigningInfosResponse) XXX_Unmarshal(b []byte) error { +func (m *QueryVotesAtHeightRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } -func (m *QuerySigningInfosResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { +func (m *QueryVotesAtHeightRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { - return xxx_messageInfo_QuerySigningInfosResponse.Marshal(b, m, deterministic) + return xxx_messageInfo_QueryVotesAtHeightRequest.Marshal(b, m, deterministic) } else { b = b[:cap(b)] n, err := m.MarshalToSizedBuffer(b) @@ -1100,1251 +1185,1378 @@ func (m *QuerySigningInfosResponse) XXX_Marshal(b []byte, deterministic bool) ([ return b[:n], nil } } -func (m *QuerySigningInfosResponse) XXX_Merge(src proto.Message) { - xxx_messageInfo_QuerySigningInfosResponse.Merge(m, src) +func (m *QueryVotesAtHeightRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryVotesAtHeightRequest.Merge(m, src) } -func (m *QuerySigningInfosResponse) XXX_Size() int { +func (m *QueryVotesAtHeightRequest) XXX_Size() int { return m.Size() } -func (m *QuerySigningInfosResponse) XXX_DiscardUnknown() { - xxx_messageInfo_QuerySigningInfosResponse.DiscardUnknown(m) -} +func (m *QueryVotesAtHeightRequest) XXX_DiscardUnknown() { + xxx_messageInfo_QueryVotesAtHeightRequest.DiscardUnknown(m) +} -var xxx_messageInfo_QuerySigningInfosResponse proto.InternalMessageInfo +var xxx_messageInfo_QueryVotesAtHeightRequest proto.InternalMessageInfo -func (m *QuerySigningInfosResponse) GetFpSigningInfos() []FinalityProviderSigningInfo { +func (m *QueryVotesAtHeightRequest) GetHeight() uint64 { if m != nil { - return m.FpSigningInfos + return m.Height } - return nil + return 0 } -func (m *QuerySigningInfosResponse) GetPagination() *query.PageResponse { - if m != nil { - return m.Pagination - } - return nil +// QueryVotesAtHeightResponse is the response type for the +// Query/VotesAtHeight RPC method. +type QueryVotesAtHeightResponse struct { + // btc_pk is the Bitcoin secp256k1 PK of finality providers who have signed the block at given height. + // the PK follows encoding in BIP-340 spec + BtcPks []github_com_babylonlabs_io_babylon_types.BIP340PubKey `protobuf:"bytes,1,rep,name=btc_pks,json=btcPks,proto3,customtype=github.com/babylonlabs-io/babylon/types.BIP340PubKey" json:"btc_pks,omitempty"` } -func init() { - proto.RegisterEnum("babylon.finality.v1.QueriedBlockStatus", QueriedBlockStatus_name, QueriedBlockStatus_value) - proto.RegisterType((*QueryParamsRequest)(nil), "babylon.finality.v1.QueryParamsRequest") - proto.RegisterType((*QueryParamsResponse)(nil), "babylon.finality.v1.QueryParamsResponse") - proto.RegisterType((*QueryListPublicRandomnessRequest)(nil), "babylon.finality.v1.QueryListPublicRandomnessRequest") - proto.RegisterType((*QueryListPublicRandomnessResponse)(nil), "babylon.finality.v1.QueryListPublicRandomnessResponse") - proto.RegisterMapType((map[uint64]*github_com_babylonlabs_io_babylon_types.SchnorrPubRand)(nil), "babylon.finality.v1.QueryListPublicRandomnessResponse.PubRandMapEntry") - proto.RegisterType((*PubRandCommitResponse)(nil), "babylon.finality.v1.PubRandCommitResponse") - proto.RegisterType((*QueryListPubRandCommitRequest)(nil), "babylon.finality.v1.QueryListPubRandCommitRequest") - proto.RegisterType((*QueryListPubRandCommitResponse)(nil), "babylon.finality.v1.QueryListPubRandCommitResponse") - proto.RegisterMapType((map[uint64]*PubRandCommitResponse)(nil), "babylon.finality.v1.QueryListPubRandCommitResponse.PubRandCommitMapEntry") - proto.RegisterType((*QueryBlockRequest)(nil), "babylon.finality.v1.QueryBlockRequest") - proto.RegisterType((*QueryBlockResponse)(nil), "babylon.finality.v1.QueryBlockResponse") - proto.RegisterType((*QueryListBlocksRequest)(nil), "babylon.finality.v1.QueryListBlocksRequest") - proto.RegisterType((*QueryListBlocksResponse)(nil), "babylon.finality.v1.QueryListBlocksResponse") - proto.RegisterType((*QueryVotesAtHeightRequest)(nil), "babylon.finality.v1.QueryVotesAtHeightRequest") - proto.RegisterType((*QueryVotesAtHeightResponse)(nil), "babylon.finality.v1.QueryVotesAtHeightResponse") - proto.RegisterType((*QueryEvidenceRequest)(nil), "babylon.finality.v1.QueryEvidenceRequest") - proto.RegisterType((*QueryEvidenceResponse)(nil), "babylon.finality.v1.QueryEvidenceResponse") - proto.RegisterType((*QueryListEvidencesRequest)(nil), "babylon.finality.v1.QueryListEvidencesRequest") - proto.RegisterType((*QueryListEvidencesResponse)(nil), "babylon.finality.v1.QueryListEvidencesResponse") - proto.RegisterType((*QuerySigningInfoRequest)(nil), "babylon.finality.v1.QuerySigningInfoRequest") - proto.RegisterType((*QuerySigningInfoResponse)(nil), "babylon.finality.v1.QuerySigningInfoResponse") - proto.RegisterType((*QuerySigningInfosRequest)(nil), "babylon.finality.v1.QuerySigningInfosRequest") - proto.RegisterType((*QuerySigningInfosResponse)(nil), "babylon.finality.v1.QuerySigningInfosResponse") +func (m *QueryVotesAtHeightResponse) Reset() { *m = QueryVotesAtHeightResponse{} } +func (m *QueryVotesAtHeightResponse) String() string { return proto.CompactTextString(m) } +func (*QueryVotesAtHeightResponse) ProtoMessage() {} +func (*QueryVotesAtHeightResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_32bddab77af6fdae, []int{21} } - -func init() { proto.RegisterFile("babylon/finality/v1/query.proto", fileDescriptor_32bddab77af6fdae) } - -var fileDescriptor_32bddab77af6fdae = []byte{ - // 1338 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xbc, 0x58, 0xdf, 0x6f, 0xd3, 0xd6, - 0x17, 0xef, 0x6d, 0x69, 0xa1, 0xa7, 0x09, 0x94, 0x4b, 0xe1, 0xdb, 0x6f, 0x18, 0x69, 0x30, 0xac, - 0xb0, 0x02, 0x36, 0x4d, 0x19, 0x03, 0xb6, 0x09, 0xc8, 0x46, 0x47, 0xb4, 0x92, 0x05, 0x33, 0x21, - 0x8d, 0x87, 0x79, 0x76, 0x7a, 0x93, 0x58, 0x8d, 0x7d, 0x4d, 0x6c, 0x47, 0xcd, 0x10, 0xd2, 0x34, - 0x69, 0x3c, 0x4c, 0x9b, 0x34, 0x69, 0x2f, 0xdb, 0x03, 0x0f, 0x9b, 0xa6, 0xbd, 0xec, 0xff, 0x98, - 0x78, 0x44, 0x6c, 0x0f, 0x13, 0xd2, 0xd0, 0x04, 0xfb, 0x43, 0xa6, 0xdc, 0x7b, 0x9d, 0xd8, 0x89, - 0xf3, 0x83, 0x2e, 0xda, 0x5b, 0x7c, 0x7c, 0x7e, 0x7c, 0xce, 0xe7, 0x1c, 0x9f, 0x73, 0x5a, 0x58, - 0x32, 0x74, 0xa3, 0x59, 0xa3, 0xb6, 0x52, 0x36, 0x6d, 0xbd, 0x66, 0x7a, 0x4d, 0xa5, 0xb1, 0xaa, - 0xdc, 0xf5, 0x49, 0xbd, 0x29, 0x3b, 0x75, 0xea, 0x51, 0x7c, 0x40, 0x28, 0xc8, 0x81, 0x82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01, 0xbd, 0xd4, 0xbb, 0x8d, 0x53, 0x67, 0x46, 0xd4, 0x16, 0xa0, 0x2e, 0x31, - 0x50, 0xe7, 0x70, 0x36, 0x16, 0x54, 0x64, 0x67, 0x75, 0x93, 0x89, 0xbf, 0x47, 0x90, 0x88, 0xac, - 0xa1, 0xd1, 0x62, 0xb7, 0x19, 0x94, 0x47, 0x55, 0x17, 0x58, 0x57, 0x18, 0xd6, 0xe3, 0x58, 0x1a, - 0x8e, 0x35, 0xb7, 0xf1, 0xe8, 0x79, 0x1a, 0x3d, 0x7e, 0x9e, 0x46, 0x7f, 0x3d, 0x4f, 0xa3, 0x6f, - 0x5e, 0xa4, 0x27, 0x1e, 0xbf, 0x48, 0x4f, 0xfc, 0xf1, 0x22, 0x3d, 0x71, 0x27, 0x3b, 0xfc, 0x88, - 0xdd, 0xee, 0x38, 0x66, 0xf7, 0xac, 0x31, 0xc3, 0xfe, 0xa1, 0xb3, 0xf6, 0x4f, 0x00, 0x00, 0x00, - 0xff, 0xff, 0xb3, 0x40, 0x11, 0x10, 0xae, 0x12, 0x00, 0x00, +func (m *QueryVotesAtHeightResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryVotesAtHeightResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryVotesAtHeightResponse.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 *QueryVotesAtHeightResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryVotesAtHeightResponse.Merge(m, src) +} +func (m *QueryVotesAtHeightResponse) XXX_Size() int { + return m.Size() +} +func (m *QueryVotesAtHeightResponse) XXX_DiscardUnknown() { + xxx_messageInfo_QueryVotesAtHeightResponse.DiscardUnknown(m) } -// Reference imports to suppress errors if they are not otherwise used. -var _ context.Context -var _ grpc.ClientConn - -// This is a compile-time assertion to ensure that this generated file -// is compatible with the grpc package it is being compiled against. -const _ = grpc.SupportPackageIsVersion4 +var xxx_messageInfo_QueryVotesAtHeightResponse proto.InternalMessageInfo -// QueryClient is the client API for Query service. -// -// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream. -type QueryClient interface { - // Parameters queries the parameters of the module. - Params(ctx context.Context, in *QueryParamsRequest, opts ...grpc.CallOption) (*QueryParamsResponse, error) - // ListPublicRandomness is a range query for public randomness of a given finality provider - // NOTE: Babylon only has the knowledge of public randomness that is already revealed by - // finality providers, i.e., the finality provider alreayd provides a finality signature - // at the corresponding height - // TODO: remove public randomness storage? - ListPublicRandomness(ctx context.Context, in *QueryListPublicRandomnessRequest, opts ...grpc.CallOption) (*QueryListPublicRandomnessResponse, error) - // ListPubRandCommit is a range query for public randomness commitments of a given finality provider - ListPubRandCommit(ctx context.Context, in *QueryListPubRandCommitRequest, opts ...grpc.CallOption) (*QueryListPubRandCommitResponse, error) - // Block queries a block at a given height - Block(ctx context.Context, in *QueryBlockRequest, opts ...grpc.CallOption) (*QueryBlockResponse, error) - // ListBlocks is a range query for blocks at a given status - ListBlocks(ctx context.Context, in *QueryListBlocksRequest, opts ...grpc.CallOption) (*QueryListBlocksResponse, error) - // VotesAtHeight queries finality providers who have signed the block at given height. - VotesAtHeight(ctx context.Context, in *QueryVotesAtHeightRequest, opts ...grpc.CallOption) (*QueryVotesAtHeightResponse, error) - // Evidence queries the first evidence which can be used for extracting the BTC SK - Evidence(ctx context.Context, in *QueryEvidenceRequest, opts ...grpc.CallOption) (*QueryEvidenceResponse, error) - // ListEvidences queries is a range query for evidences - ListEvidences(ctx context.Context, in *QueryListEvidencesRequest, opts ...grpc.CallOption) (*QueryListEvidencesResponse, error) - // SigningInfo queries the signing info of given finality provider BTC public key - SigningInfo(ctx context.Context, in *QuerySigningInfoRequest, opts ...grpc.CallOption) (*QuerySigningInfoResponse, error) - // SigningInfos queries the signing info of all the active finality providers - SigningInfos(ctx context.Context, in *QuerySigningInfosRequest, opts ...grpc.CallOption) (*QuerySigningInfosResponse, error) +// QueryEvidenceRequest is the request type for the +// Query/Evidence RPC method. +type QueryEvidenceRequest struct { + // fp_btc_pk_hex is the hex str of Bitcoin secp256k1 PK + // (in BIP340 format) of the finality provider + FpBtcPkHex string `protobuf:"bytes,1,opt,name=fp_btc_pk_hex,json=fpBtcPkHex,proto3" json:"fp_btc_pk_hex,omitempty"` } -type queryClient struct { - cc grpc1.ClientConn +func (m *QueryEvidenceRequest) Reset() { *m = QueryEvidenceRequest{} } +func (m *QueryEvidenceRequest) String() string { return proto.CompactTextString(m) } +func (*QueryEvidenceRequest) ProtoMessage() {} +func (*QueryEvidenceRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_32bddab77af6fdae, []int{22} } - -func NewQueryClient(cc grpc1.ClientConn) QueryClient { - return &queryClient{cc} +func (m *QueryEvidenceRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) } - -func (c *queryClient) Params(ctx context.Context, in *QueryParamsRequest, opts ...grpc.CallOption) (*QueryParamsResponse, error) { - out := new(QueryParamsResponse) - err := c.cc.Invoke(ctx, "/babylon.finality.v1.Query/Params", in, out, opts...) - if err != nil { - return nil, err +func (m *QueryEvidenceRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryEvidenceRequest.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil } - return out, nil } - -func (c *queryClient) ListPublicRandomness(ctx context.Context, in *QueryListPublicRandomnessRequest, opts ...grpc.CallOption) (*QueryListPublicRandomnessResponse, error) { - out := new(QueryListPublicRandomnessResponse) - err := c.cc.Invoke(ctx, "/babylon.finality.v1.Query/ListPublicRandomness", in, out, opts...) - if err != nil { - return nil, err - } - return out, nil +func (m *QueryEvidenceRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryEvidenceRequest.Merge(m, src) } - -func (c *queryClient) ListPubRandCommit(ctx context.Context, in *QueryListPubRandCommitRequest, opts ...grpc.CallOption) (*QueryListPubRandCommitResponse, error) { - out := new(QueryListPubRandCommitResponse) - err := c.cc.Invoke(ctx, "/babylon.finality.v1.Query/ListPubRandCommit", in, out, opts...) - if err != nil { - return nil, err - } - return out, nil +func (m *QueryEvidenceRequest) XXX_Size() int { + return m.Size() +} +func (m *QueryEvidenceRequest) XXX_DiscardUnknown() { + xxx_messageInfo_QueryEvidenceRequest.DiscardUnknown(m) } -func (c *queryClient) Block(ctx context.Context, in *QueryBlockRequest, opts ...grpc.CallOption) (*QueryBlockResponse, error) { - out := new(QueryBlockResponse) - err := c.cc.Invoke(ctx, "/babylon.finality.v1.Query/Block", in, out, opts...) - if err != nil { - return nil, err +var xxx_messageInfo_QueryEvidenceRequest proto.InternalMessageInfo + +func (m *QueryEvidenceRequest) GetFpBtcPkHex() string { + if m != nil { + return m.FpBtcPkHex } - return out, nil + return "" } -func (c *queryClient) ListBlocks(ctx context.Context, in *QueryListBlocksRequest, opts ...grpc.CallOption) (*QueryListBlocksResponse, error) { - out := new(QueryListBlocksResponse) - err := c.cc.Invoke(ctx, "/babylon.finality.v1.Query/ListBlocks", in, out, opts...) - if err != nil { - return nil, err +// Evidence is the evidence that a finality provider has signed finality +// signatures with correct public randomness on two conflicting Babylon headers +type EvidenceResponse struct { + // fp_btc_pk_hex is the BTC PK of the finality provider that casts this vote + FpBtcPkHex string `protobuf:"bytes,1,opt,name=fp_btc_pk_hex,json=fpBtcPkHex,proto3" json:"fp_btc_pk_hex,omitempty"` + // block_height is the height of the conflicting blocks + BlockHeight uint64 `protobuf:"varint,2,opt,name=block_height,json=blockHeight,proto3" json:"block_height,omitempty"` + // pub_rand is the public randomness the finality provider has committed to + PubRand *github_com_babylonlabs_io_babylon_types.SchnorrPubRand `protobuf:"bytes,3,opt,name=pub_rand,json=pubRand,proto3,customtype=github.com/babylonlabs-io/babylon/types.SchnorrPubRand" json:"pub_rand,omitempty"` + // canonical_app_hash is the AppHash of the canonical block + CanonicalAppHash []byte `protobuf:"bytes,4,opt,name=canonical_app_hash,json=canonicalAppHash,proto3" json:"canonical_app_hash,omitempty"` + // fork_app_hash is the AppHash of the fork block + ForkAppHash []byte `protobuf:"bytes,5,opt,name=fork_app_hash,json=forkAppHash,proto3" json:"fork_app_hash,omitempty"` + // canonical_finality_sig is the finality signature to the canonical block + // where finality signature is an EOTS signature, i.e., + // the `s` in a Schnorr signature `(r, s)` + // `r` is the public randomness that is already committed by the finality provider + CanonicalFinalitySig *github_com_babylonlabs_io_babylon_types.SchnorrEOTSSig `protobuf:"bytes,6,opt,name=canonical_finality_sig,json=canonicalFinalitySig,proto3,customtype=github.com/babylonlabs-io/babylon/types.SchnorrEOTSSig" json:"canonical_finality_sig,omitempty"` + // fork_finality_sig is the finality signature to the fork block + // where finality signature is an EOTS signature + ForkFinalitySig *github_com_babylonlabs_io_babylon_types.SchnorrEOTSSig `protobuf:"bytes,7,opt,name=fork_finality_sig,json=forkFinalitySig,proto3,customtype=github.com/babylonlabs-io/babylon/types.SchnorrEOTSSig" json:"fork_finality_sig,omitempty"` +} + +func (m *EvidenceResponse) Reset() { *m = EvidenceResponse{} } +func (m *EvidenceResponse) String() string { return proto.CompactTextString(m) } +func (*EvidenceResponse) ProtoMessage() {} +func (*EvidenceResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_32bddab77af6fdae, []int{23} +} +func (m *EvidenceResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *EvidenceResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_EvidenceResponse.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil } - return out, nil +} +func (m *EvidenceResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_EvidenceResponse.Merge(m, src) +} +func (m *EvidenceResponse) XXX_Size() int { + return m.Size() +} +func (m *EvidenceResponse) XXX_DiscardUnknown() { + xxx_messageInfo_EvidenceResponse.DiscardUnknown(m) } -func (c *queryClient) VotesAtHeight(ctx context.Context, in *QueryVotesAtHeightRequest, opts ...grpc.CallOption) (*QueryVotesAtHeightResponse, error) { - out := new(QueryVotesAtHeightResponse) - err := c.cc.Invoke(ctx, "/babylon.finality.v1.Query/VotesAtHeight", in, out, opts...) - if err != nil { - return nil, err +var xxx_messageInfo_EvidenceResponse proto.InternalMessageInfo + +func (m *EvidenceResponse) GetFpBtcPkHex() string { + if m != nil { + return m.FpBtcPkHex } - return out, nil + return "" } -func (c *queryClient) Evidence(ctx context.Context, in *QueryEvidenceRequest, opts ...grpc.CallOption) (*QueryEvidenceResponse, error) { - out := new(QueryEvidenceResponse) - err := c.cc.Invoke(ctx, "/babylon.finality.v1.Query/Evidence", in, out, opts...) - if err != nil { - return nil, err +func (m *EvidenceResponse) GetBlockHeight() uint64 { + if m != nil { + return m.BlockHeight } - return out, nil + return 0 } -func (c *queryClient) ListEvidences(ctx context.Context, in *QueryListEvidencesRequest, opts ...grpc.CallOption) (*QueryListEvidencesResponse, error) { - out := new(QueryListEvidencesResponse) - err := c.cc.Invoke(ctx, "/babylon.finality.v1.Query/ListEvidences", in, out, opts...) - if err != nil { - return nil, err +func (m *EvidenceResponse) GetCanonicalAppHash() []byte { + if m != nil { + return m.CanonicalAppHash } - return out, nil + return nil } -func (c *queryClient) SigningInfo(ctx context.Context, in *QuerySigningInfoRequest, opts ...grpc.CallOption) (*QuerySigningInfoResponse, error) { - out := new(QuerySigningInfoResponse) - err := c.cc.Invoke(ctx, "/babylon.finality.v1.Query/SigningInfo", in, out, opts...) - if err != nil { - return nil, err +func (m *EvidenceResponse) GetForkAppHash() []byte { + if m != nil { + return m.ForkAppHash } - return out, nil + return nil } -func (c *queryClient) SigningInfos(ctx context.Context, in *QuerySigningInfosRequest, opts ...grpc.CallOption) (*QuerySigningInfosResponse, error) { - out := new(QuerySigningInfosResponse) - err := c.cc.Invoke(ctx, "/babylon.finality.v1.Query/SigningInfos", in, out, opts...) - if err != nil { - return nil, err - } - return out, nil +// QueryEvidenceResponse is the response type for the +// Query/Evidence RPC method. +type QueryEvidenceResponse struct { + Evidence *EvidenceResponse `protobuf:"bytes,1,opt,name=evidence,proto3" json:"evidence,omitempty"` } -// QueryServer is the server API for Query service. -type QueryServer interface { - // Parameters queries the parameters of the module. - Params(context.Context, *QueryParamsRequest) (*QueryParamsResponse, error) - // ListPublicRandomness is a range query for public randomness of a given finality provider - // NOTE: Babylon only has the knowledge of public randomness that is already revealed by - // finality providers, i.e., the finality provider alreayd provides a finality signature - // at the corresponding height - // TODO: remove public randomness storage? - ListPublicRandomness(context.Context, *QueryListPublicRandomnessRequest) (*QueryListPublicRandomnessResponse, error) - // ListPubRandCommit is a range query for public randomness commitments of a given finality provider - ListPubRandCommit(context.Context, *QueryListPubRandCommitRequest) (*QueryListPubRandCommitResponse, error) - // Block queries a block at a given height - Block(context.Context, *QueryBlockRequest) (*QueryBlockResponse, error) - // ListBlocks is a range query for blocks at a given status - ListBlocks(context.Context, *QueryListBlocksRequest) (*QueryListBlocksResponse, error) - // VotesAtHeight queries finality providers who have signed the block at given height. - VotesAtHeight(context.Context, *QueryVotesAtHeightRequest) (*QueryVotesAtHeightResponse, error) - // Evidence queries the first evidence which can be used for extracting the BTC SK - Evidence(context.Context, *QueryEvidenceRequest) (*QueryEvidenceResponse, error) - // ListEvidences queries is a range query for evidences - ListEvidences(context.Context, *QueryListEvidencesRequest) (*QueryListEvidencesResponse, error) - // SigningInfo queries the signing info of given finality provider BTC public key - SigningInfo(context.Context, *QuerySigningInfoRequest) (*QuerySigningInfoResponse, error) - // SigningInfos queries the signing info of all the active finality providers - SigningInfos(context.Context, *QuerySigningInfosRequest) (*QuerySigningInfosResponse, error) +func (m *QueryEvidenceResponse) Reset() { *m = QueryEvidenceResponse{} } +func (m *QueryEvidenceResponse) String() string { return proto.CompactTextString(m) } +func (*QueryEvidenceResponse) ProtoMessage() {} +func (*QueryEvidenceResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_32bddab77af6fdae, []int{24} } - -// UnimplementedQueryServer can be embedded to have forward compatible implementations. -type UnimplementedQueryServer struct { +func (m *QueryEvidenceResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) } - -func (*UnimplementedQueryServer) Params(ctx context.Context, req *QueryParamsRequest) (*QueryParamsResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method Params not implemented") +func (m *QueryEvidenceResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryEvidenceResponse.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 (*UnimplementedQueryServer) ListPublicRandomness(ctx context.Context, req *QueryListPublicRandomnessRequest) (*QueryListPublicRandomnessResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method ListPublicRandomness not implemented") +func (m *QueryEvidenceResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryEvidenceResponse.Merge(m, src) } -func (*UnimplementedQueryServer) ListPubRandCommit(ctx context.Context, req *QueryListPubRandCommitRequest) (*QueryListPubRandCommitResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method ListPubRandCommit not implemented") +func (m *QueryEvidenceResponse) XXX_Size() int { + return m.Size() } -func (*UnimplementedQueryServer) Block(ctx context.Context, req *QueryBlockRequest) (*QueryBlockResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method Block not implemented") +func (m *QueryEvidenceResponse) XXX_DiscardUnknown() { + xxx_messageInfo_QueryEvidenceResponse.DiscardUnknown(m) } -func (*UnimplementedQueryServer) ListBlocks(ctx context.Context, req *QueryListBlocksRequest) (*QueryListBlocksResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method ListBlocks not implemented") + +var xxx_messageInfo_QueryEvidenceResponse proto.InternalMessageInfo + +func (m *QueryEvidenceResponse) GetEvidence() *EvidenceResponse { + if m != nil { + return m.Evidence + } + return nil } -func (*UnimplementedQueryServer) VotesAtHeight(ctx context.Context, req *QueryVotesAtHeightRequest) (*QueryVotesAtHeightResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method VotesAtHeight not implemented") + +// QueryListEvidencesRequest is the request type for the +// Query/ListEvidences RPC method. +type QueryListEvidencesRequest struct { + // start_height is the starting height that the querier specifies + // such that the RPC will only return evidences since this height + StartHeight uint64 `protobuf:"varint,1,opt,name=start_height,json=startHeight,proto3" json:"start_height,omitempty"` + // pagination defines an optional pagination for the request. + Pagination *query.PageRequest `protobuf:"bytes,2,opt,name=pagination,proto3" json:"pagination,omitempty"` } -func (*UnimplementedQueryServer) Evidence(ctx context.Context, req *QueryEvidenceRequest) (*QueryEvidenceResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method Evidence not implemented") + +func (m *QueryListEvidencesRequest) Reset() { *m = QueryListEvidencesRequest{} } +func (m *QueryListEvidencesRequest) String() string { return proto.CompactTextString(m) } +func (*QueryListEvidencesRequest) ProtoMessage() {} +func (*QueryListEvidencesRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_32bddab77af6fdae, []int{25} } -func (*UnimplementedQueryServer) ListEvidences(ctx context.Context, req *QueryListEvidencesRequest) (*QueryListEvidencesResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method ListEvidences not implemented") +func (m *QueryListEvidencesRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) } -func (*UnimplementedQueryServer) SigningInfo(ctx context.Context, req *QuerySigningInfoRequest) (*QuerySigningInfoResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method SigningInfo not implemented") +func (m *QueryListEvidencesRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryListEvidencesRequest.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 (*UnimplementedQueryServer) SigningInfos(ctx context.Context, req *QuerySigningInfosRequest) (*QuerySigningInfosResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method SigningInfos not implemented") +func (m *QueryListEvidencesRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryListEvidencesRequest.Merge(m, src) } - -func RegisterQueryServer(s grpc1.Server, srv QueryServer) { - s.RegisterService(&_Query_serviceDesc, srv) +func (m *QueryListEvidencesRequest) XXX_Size() int { + return m.Size() +} +func (m *QueryListEvidencesRequest) XXX_DiscardUnknown() { + xxx_messageInfo_QueryListEvidencesRequest.DiscardUnknown(m) } -func _Query_Params_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(QueryParamsRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(QueryServer).Params(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/babylon.finality.v1.Query/Params", - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(QueryServer).Params(ctx, req.(*QueryParamsRequest)) +var xxx_messageInfo_QueryListEvidencesRequest proto.InternalMessageInfo + +func (m *QueryListEvidencesRequest) GetStartHeight() uint64 { + if m != nil { + return m.StartHeight } - return interceptor(ctx, in, info, handler) + return 0 } -func _Query_ListPublicRandomness_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(QueryListPublicRandomnessRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(QueryServer).ListPublicRandomness(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/babylon.finality.v1.Query/ListPublicRandomness", - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(QueryServer).ListPublicRandomness(ctx, req.(*QueryListPublicRandomnessRequest)) +func (m *QueryListEvidencesRequest) GetPagination() *query.PageRequest { + if m != nil { + return m.Pagination } - return interceptor(ctx, in, info, handler) + return nil } -func _Query_ListPubRandCommit_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(QueryListPubRandCommitRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(QueryServer).ListPubRandCommit(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/babylon.finality.v1.Query/ListPubRandCommit", - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(QueryServer).ListPubRandCommit(ctx, req.(*QueryListPubRandCommitRequest)) - } - return interceptor(ctx, in, info, handler) +// QueryListEvidencesResponse is the response type for the +// Query/ListEvidences RPC method. +type QueryListEvidencesResponse struct { + // blocks is the list of evidences + Evidences []*EvidenceResponse `protobuf:"bytes,1,rep,name=evidences,proto3" json:"evidences,omitempty"` + // pagination defines the pagination in the response. + Pagination *query.PageResponse `protobuf:"bytes,2,opt,name=pagination,proto3" json:"pagination,omitempty"` } -func _Query_Block_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(QueryBlockRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(QueryServer).Block(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/babylon.finality.v1.Query/Block", - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(QueryServer).Block(ctx, req.(*QueryBlockRequest)) +func (m *QueryListEvidencesResponse) Reset() { *m = QueryListEvidencesResponse{} } +func (m *QueryListEvidencesResponse) String() string { return proto.CompactTextString(m) } +func (*QueryListEvidencesResponse) ProtoMessage() {} +func (*QueryListEvidencesResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_32bddab77af6fdae, []int{26} +} +func (m *QueryListEvidencesResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryListEvidencesResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryListEvidencesResponse.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil } - return interceptor(ctx, in, info, handler) +} +func (m *QueryListEvidencesResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryListEvidencesResponse.Merge(m, src) +} +func (m *QueryListEvidencesResponse) XXX_Size() int { + return m.Size() +} +func (m *QueryListEvidencesResponse) XXX_DiscardUnknown() { + xxx_messageInfo_QueryListEvidencesResponse.DiscardUnknown(m) } -func _Query_ListBlocks_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(QueryListBlocksRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(QueryServer).ListBlocks(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/babylon.finality.v1.Query/ListBlocks", - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(QueryServer).ListBlocks(ctx, req.(*QueryListBlocksRequest)) +var xxx_messageInfo_QueryListEvidencesResponse proto.InternalMessageInfo + +func (m *QueryListEvidencesResponse) GetEvidences() []*EvidenceResponse { + if m != nil { + return m.Evidences } - return interceptor(ctx, in, info, handler) + return nil } -func _Query_VotesAtHeight_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(QueryVotesAtHeightRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(QueryServer).VotesAtHeight(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/babylon.finality.v1.Query/VotesAtHeight", - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(QueryServer).VotesAtHeight(ctx, req.(*QueryVotesAtHeightRequest)) +func (m *QueryListEvidencesResponse) GetPagination() *query.PageResponse { + if m != nil { + return m.Pagination } - return interceptor(ctx, in, info, handler) + return nil } -func _Query_Evidence_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(QueryEvidenceRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(QueryServer).Evidence(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/babylon.finality.v1.Query/Evidence", - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(QueryServer).Evidence(ctx, req.(*QueryEvidenceRequest)) - } - return interceptor(ctx, in, info, handler) +// QuerySigningInfoRequest is the request type for the Query/SigningInfo RPC +// method +type QuerySigningInfoRequest struct { + // fp_btc_pk_hex is the hex str of Bitcoin secp256k1 PK + // (in BIP340 format) of the finality provider + FpBtcPkHex string `protobuf:"bytes,1,opt,name=fp_btc_pk_hex,json=fpBtcPkHex,proto3" json:"fp_btc_pk_hex,omitempty"` } -func _Query_ListEvidences_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(QueryListEvidencesRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(QueryServer).ListEvidences(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/babylon.finality.v1.Query/ListEvidences", - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(QueryServer).ListEvidences(ctx, req.(*QueryListEvidencesRequest)) +func (m *QuerySigningInfoRequest) Reset() { *m = QuerySigningInfoRequest{} } +func (m *QuerySigningInfoRequest) String() string { return proto.CompactTextString(m) } +func (*QuerySigningInfoRequest) ProtoMessage() {} +func (*QuerySigningInfoRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_32bddab77af6fdae, []int{27} +} +func (m *QuerySigningInfoRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QuerySigningInfoRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QuerySigningInfoRequest.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil } - return interceptor(ctx, in, info, handler) +} +func (m *QuerySigningInfoRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_QuerySigningInfoRequest.Merge(m, src) +} +func (m *QuerySigningInfoRequest) XXX_Size() int { + return m.Size() +} +func (m *QuerySigningInfoRequest) XXX_DiscardUnknown() { + xxx_messageInfo_QuerySigningInfoRequest.DiscardUnknown(m) } -func _Query_SigningInfo_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(QuerySigningInfoRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(QueryServer).SigningInfo(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/babylon.finality.v1.Query/SigningInfo", - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(QueryServer).SigningInfo(ctx, req.(*QuerySigningInfoRequest)) +var xxx_messageInfo_QuerySigningInfoRequest proto.InternalMessageInfo + +func (m *QuerySigningInfoRequest) GetFpBtcPkHex() string { + if m != nil { + return m.FpBtcPkHex } - return interceptor(ctx, in, info, handler) + return "" } -func _Query_SigningInfos_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(QuerySigningInfosRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(QueryServer).SigningInfos(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/babylon.finality.v1.Query/SigningInfos", - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(QueryServer).SigningInfos(ctx, req.(*QuerySigningInfosRequest)) +// SigningInfoResponse defines the API response containing a finality provider's signing info +// for monitoring their liveness activity. +type SigningInfoResponse struct { + // fp_btc_pk is the BTC PK of the finality provider that casts this vote + FpBtcPkHex string `protobuf:"bytes,1,opt,name=fp_btc_pk_hex,json=fpBtcPkHex,proto3" json:"fp_btc_pk_hex,omitempty"` + // start_height is the block height at which finality provider become active + StartHeight int64 `protobuf:"varint,2,opt,name=start_height,json=startHeight,proto3" json:"start_height,omitempty"` + // missed_blocks_counter defines a counter to avoid unnecessary array reads. + // Note that `Sum(MissedBlocksBitArray)` always equals `MissedBlocksCounter`. + MissedBlocksCounter int64 `protobuf:"varint,3,opt,name=missed_blocks_counter,json=missedBlocksCounter,proto3" json:"missed_blocks_counter,omitempty"` + // Timestamp until which the validator is jailed due to liveness downtime. + JailedUntil time.Time `protobuf:"bytes,4,opt,name=jailed_until,json=jailedUntil,proto3,stdtime" json:"jailed_until"` +} + +func (m *SigningInfoResponse) Reset() { *m = SigningInfoResponse{} } +func (m *SigningInfoResponse) String() string { return proto.CompactTextString(m) } +func (*SigningInfoResponse) ProtoMessage() {} +func (*SigningInfoResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_32bddab77af6fdae, []int{28} +} +func (m *SigningInfoResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *SigningInfoResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_SigningInfoResponse.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil } - return interceptor(ctx, in, info, handler) } - -var _Query_serviceDesc = grpc.ServiceDesc{ - ServiceName: "babylon.finality.v1.Query", - HandlerType: (*QueryServer)(nil), - Methods: []grpc.MethodDesc{ - { - MethodName: "Params", - Handler: _Query_Params_Handler, - }, - { - MethodName: "ListPublicRandomness", - Handler: _Query_ListPublicRandomness_Handler, - }, - { - MethodName: "ListPubRandCommit", - Handler: _Query_ListPubRandCommit_Handler, - }, - { - MethodName: "Block", - Handler: _Query_Block_Handler, - }, - { - MethodName: "ListBlocks", - Handler: _Query_ListBlocks_Handler, - }, - { - MethodName: "VotesAtHeight", - Handler: _Query_VotesAtHeight_Handler, - }, - { - MethodName: "Evidence", - Handler: _Query_Evidence_Handler, - }, - { - MethodName: "ListEvidences", - Handler: _Query_ListEvidences_Handler, - }, - { - MethodName: "SigningInfo", - Handler: _Query_SigningInfo_Handler, - }, - { - MethodName: "SigningInfos", - Handler: _Query_SigningInfos_Handler, - }, - }, - Streams: []grpc.StreamDesc{}, - Metadata: "babylon/finality/v1/query.proto", +func (m *SigningInfoResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_SigningInfoResponse.Merge(m, src) +} +func (m *SigningInfoResponse) XXX_Size() int { + return m.Size() +} +func (m *SigningInfoResponse) XXX_DiscardUnknown() { + xxx_messageInfo_SigningInfoResponse.DiscardUnknown(m) } -func (m *QueryParamsRequest) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err +var xxx_messageInfo_SigningInfoResponse proto.InternalMessageInfo + +func (m *SigningInfoResponse) GetFpBtcPkHex() string { + if m != nil { + return m.FpBtcPkHex } - return dAtA[:n], nil + return "" } -func (m *QueryParamsRequest) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) +func (m *SigningInfoResponse) GetStartHeight() int64 { + if m != nil { + return m.StartHeight + } + return 0 } -func (m *QueryParamsRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - return len(dAtA) - i, nil +func (m *SigningInfoResponse) GetMissedBlocksCounter() int64 { + if m != nil { + return m.MissedBlocksCounter + } + return 0 } -func (m *QueryParamsResponse) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err +func (m *SigningInfoResponse) GetJailedUntil() time.Time { + if m != nil { + return m.JailedUntil } - return dAtA[:n], nil + return time.Time{} } -func (m *QueryParamsResponse) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) +// QuerySigningInfoResponse is the response type for the Query/SigningInfo RPC +// method +type QuerySigningInfoResponse struct { + SigningInfo SigningInfoResponse `protobuf:"bytes,1,opt,name=signing_info,json=signingInfo,proto3" json:"signing_info"` } -func (m *QueryParamsResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - { - size, err := m.Params.MarshalToSizedBuffer(dAtA[:i]) +func (m *QuerySigningInfoResponse) Reset() { *m = QuerySigningInfoResponse{} } +func (m *QuerySigningInfoResponse) String() string { return proto.CompactTextString(m) } +func (*QuerySigningInfoResponse) ProtoMessage() {} +func (*QuerySigningInfoResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_32bddab77af6fdae, []int{29} +} +func (m *QuerySigningInfoResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QuerySigningInfoResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QuerySigningInfoResponse.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) if err != nil { - return 0, err + return nil, err } - i -= size - i = encodeVarintQuery(dAtA, i, uint64(size)) + return b[:n], nil } - i-- - dAtA[i] = 0xa - return len(dAtA) - i, nil +} +func (m *QuerySigningInfoResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_QuerySigningInfoResponse.Merge(m, src) +} +func (m *QuerySigningInfoResponse) XXX_Size() int { + return m.Size() +} +func (m *QuerySigningInfoResponse) XXX_DiscardUnknown() { + xxx_messageInfo_QuerySigningInfoResponse.DiscardUnknown(m) } -func (m *QueryListPublicRandomnessRequest) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err +var xxx_messageInfo_QuerySigningInfoResponse proto.InternalMessageInfo + +func (m *QuerySigningInfoResponse) GetSigningInfo() SigningInfoResponse { + if m != nil { + return m.SigningInfo } - return dAtA[:n], nil + return SigningInfoResponse{} } -func (m *QueryListPublicRandomnessRequest) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) +// QuerySigningInfosRequest is the request type for the Query/SigningInfos RPC +// method +type QuerySigningInfosRequest struct { + Pagination *query.PageRequest `protobuf:"bytes,1,opt,name=pagination,proto3" json:"pagination,omitempty"` } -func (m *QueryListPublicRandomnessRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if m.Pagination != nil { - { - size, err := m.Pagination.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintQuery(dAtA, i, uint64(size)) +func (m *QuerySigningInfosRequest) Reset() { *m = QuerySigningInfosRequest{} } +func (m *QuerySigningInfosRequest) String() string { return proto.CompactTextString(m) } +func (*QuerySigningInfosRequest) ProtoMessage() {} +func (*QuerySigningInfosRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_32bddab77af6fdae, []int{30} +} +func (m *QuerySigningInfosRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QuerySigningInfosRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QuerySigningInfosRequest.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err } - i-- - dAtA[i] = 0x12 - } - if len(m.FpBtcPkHex) > 0 { - i -= len(m.FpBtcPkHex) - copy(dAtA[i:], m.FpBtcPkHex) - i = encodeVarintQuery(dAtA, i, uint64(len(m.FpBtcPkHex))) - i-- - dAtA[i] = 0xa + return b[:n], nil } - return len(dAtA) - i, nil +} +func (m *QuerySigningInfosRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_QuerySigningInfosRequest.Merge(m, src) +} +func (m *QuerySigningInfosRequest) XXX_Size() int { + return m.Size() +} +func (m *QuerySigningInfosRequest) XXX_DiscardUnknown() { + xxx_messageInfo_QuerySigningInfosRequest.DiscardUnknown(m) } -func (m *QueryListPublicRandomnessResponse) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err +var xxx_messageInfo_QuerySigningInfosRequest proto.InternalMessageInfo + +func (m *QuerySigningInfosRequest) GetPagination() *query.PageRequest { + if m != nil { + return m.Pagination } - return dAtA[:n], nil + return nil } -func (m *QueryListPublicRandomnessResponse) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) +// QuerySigningInfosResponse is the response type for the Query/SigningInfos RPC +// method +type QuerySigningInfosResponse struct { + // info is the signing info of all finality providers with signing info + SigningInfos []SigningInfoResponse `protobuf:"bytes,1,rep,name=signing_infos,json=signingInfos,proto3" json:"signing_infos"` + Pagination *query.PageResponse `protobuf:"bytes,2,opt,name=pagination,proto3" json:"pagination,omitempty"` } -func (m *QueryListPublicRandomnessResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if m.Pagination != nil { - { - size, err := m.Pagination.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintQuery(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x12 - } - if len(m.PubRandMap) > 0 { - for k := range m.PubRandMap { - v := m.PubRandMap[k] - baseI := i - if v != nil { - { - size := v.Size() - i -= size - if _, err := v.MarshalTo(dAtA[i:]); err != nil { - return 0, err - } - i = encodeVarintQuery(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x12 - } - i = encodeVarintQuery(dAtA, i, uint64(k)) - i-- - dAtA[i] = 0x8 - i = encodeVarintQuery(dAtA, i, uint64(baseI-i)) - i-- - dAtA[i] = 0xa +func (m *QuerySigningInfosResponse) Reset() { *m = QuerySigningInfosResponse{} } +func (m *QuerySigningInfosResponse) String() string { return proto.CompactTextString(m) } +func (*QuerySigningInfosResponse) ProtoMessage() {} +func (*QuerySigningInfosResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_32bddab77af6fdae, []int{31} +} +func (m *QuerySigningInfosResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QuerySigningInfosResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QuerySigningInfosResponse.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err } + return b[:n], nil } - return len(dAtA) - i, nil } - -func (m *PubRandCommitResponse) 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 *QuerySigningInfosResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_QuerySigningInfosResponse.Merge(m, src) } - -func (m *PubRandCommitResponse) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) +func (m *QuerySigningInfosResponse) XXX_Size() int { + return m.Size() +} +func (m *QuerySigningInfosResponse) XXX_DiscardUnknown() { + xxx_messageInfo_QuerySigningInfosResponse.DiscardUnknown(m) } -func (m *PubRandCommitResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if m.EpochNum != 0 { - i = encodeVarintQuery(dAtA, i, uint64(m.EpochNum)) - i-- - dAtA[i] = 0x18 - } - if len(m.Commitment) > 0 { - i -= len(m.Commitment) - copy(dAtA[i:], m.Commitment) - i = encodeVarintQuery(dAtA, i, uint64(len(m.Commitment))) - i-- - dAtA[i] = 0x12 - } - if m.NumPubRand != 0 { - i = encodeVarintQuery(dAtA, i, uint64(m.NumPubRand)) - i-- - dAtA[i] = 0x8 +var xxx_messageInfo_QuerySigningInfosResponse proto.InternalMessageInfo + +func (m *QuerySigningInfosResponse) GetSigningInfos() []SigningInfoResponse { + if m != nil { + return m.SigningInfos } - return len(dAtA) - i, nil + return nil } -func (m *QueryListPubRandCommitRequest) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err +func (m *QuerySigningInfosResponse) GetPagination() *query.PageResponse { + if m != nil { + return m.Pagination } - return dAtA[:n], nil + return nil } -func (m *QueryListPubRandCommitRequest) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) +func init() { + proto.RegisterEnum("babylon.finality.v1.QueriedBlockStatus", QueriedBlockStatus_name, QueriedBlockStatus_value) + proto.RegisterType((*QueryParamsRequest)(nil), "babylon.finality.v1.QueryParamsRequest") + proto.RegisterType((*QueryParamsResponse)(nil), "babylon.finality.v1.QueryParamsResponse") + proto.RegisterType((*QueryFinalityProviderPowerAtHeightRequest)(nil), "babylon.finality.v1.QueryFinalityProviderPowerAtHeightRequest") + proto.RegisterType((*QueryFinalityProviderPowerAtHeightResponse)(nil), "babylon.finality.v1.QueryFinalityProviderPowerAtHeightResponse") + proto.RegisterType((*QueryFinalityProviderCurrentPowerRequest)(nil), "babylon.finality.v1.QueryFinalityProviderCurrentPowerRequest") + proto.RegisterType((*QueryFinalityProviderCurrentPowerResponse)(nil), "babylon.finality.v1.QueryFinalityProviderCurrentPowerResponse") + proto.RegisterType((*QueryActiveFinalityProvidersAtHeightRequest)(nil), "babylon.finality.v1.QueryActiveFinalityProvidersAtHeightRequest") + proto.RegisterType((*ActiveFinalityProvidersAtHeightResponse)(nil), "babylon.finality.v1.ActiveFinalityProvidersAtHeightResponse") + proto.RegisterType((*QueryActiveFinalityProvidersAtHeightResponse)(nil), "babylon.finality.v1.QueryActiveFinalityProvidersAtHeightResponse") + proto.RegisterType((*QueryActivatedHeightRequest)(nil), "babylon.finality.v1.QueryActivatedHeightRequest") + proto.RegisterType((*QueryActivatedHeightResponse)(nil), "babylon.finality.v1.QueryActivatedHeightResponse") + proto.RegisterType((*QueryListPublicRandomnessRequest)(nil), "babylon.finality.v1.QueryListPublicRandomnessRequest") + proto.RegisterType((*QueryListPublicRandomnessResponse)(nil), "babylon.finality.v1.QueryListPublicRandomnessResponse") + proto.RegisterMapType((map[uint64]*github_com_babylonlabs_io_babylon_types.SchnorrPubRand)(nil), "babylon.finality.v1.QueryListPublicRandomnessResponse.PubRandMapEntry") + proto.RegisterType((*PubRandCommitResponse)(nil), "babylon.finality.v1.PubRandCommitResponse") + proto.RegisterType((*QueryListPubRandCommitRequest)(nil), "babylon.finality.v1.QueryListPubRandCommitRequest") + proto.RegisterType((*QueryListPubRandCommitResponse)(nil), "babylon.finality.v1.QueryListPubRandCommitResponse") + proto.RegisterMapType((map[uint64]*PubRandCommitResponse)(nil), "babylon.finality.v1.QueryListPubRandCommitResponse.PubRandCommitMapEntry") + proto.RegisterType((*QueryBlockRequest)(nil), "babylon.finality.v1.QueryBlockRequest") + proto.RegisterType((*QueryBlockResponse)(nil), "babylon.finality.v1.QueryBlockResponse") + proto.RegisterType((*QueryListBlocksRequest)(nil), "babylon.finality.v1.QueryListBlocksRequest") + proto.RegisterType((*QueryListBlocksResponse)(nil), "babylon.finality.v1.QueryListBlocksResponse") + proto.RegisterType((*QueryVotesAtHeightRequest)(nil), "babylon.finality.v1.QueryVotesAtHeightRequest") + proto.RegisterType((*QueryVotesAtHeightResponse)(nil), "babylon.finality.v1.QueryVotesAtHeightResponse") + proto.RegisterType((*QueryEvidenceRequest)(nil), "babylon.finality.v1.QueryEvidenceRequest") + proto.RegisterType((*EvidenceResponse)(nil), "babylon.finality.v1.EvidenceResponse") + proto.RegisterType((*QueryEvidenceResponse)(nil), "babylon.finality.v1.QueryEvidenceResponse") + proto.RegisterType((*QueryListEvidencesRequest)(nil), "babylon.finality.v1.QueryListEvidencesRequest") + proto.RegisterType((*QueryListEvidencesResponse)(nil), "babylon.finality.v1.QueryListEvidencesResponse") + proto.RegisterType((*QuerySigningInfoRequest)(nil), "babylon.finality.v1.QuerySigningInfoRequest") + proto.RegisterType((*SigningInfoResponse)(nil), "babylon.finality.v1.SigningInfoResponse") + proto.RegisterType((*QuerySigningInfoResponse)(nil), "babylon.finality.v1.QuerySigningInfoResponse") + proto.RegisterType((*QuerySigningInfosRequest)(nil), "babylon.finality.v1.QuerySigningInfosRequest") + proto.RegisterType((*QuerySigningInfosResponse)(nil), "babylon.finality.v1.QuerySigningInfosResponse") } -func (m *QueryListPubRandCommitRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if m.Pagination != nil { - { - size, err := m.Pagination.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintQuery(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x12 - } - if len(m.FpBtcPkHex) > 0 { - i -= len(m.FpBtcPkHex) - copy(dAtA[i:], m.FpBtcPkHex) - i = encodeVarintQuery(dAtA, i, uint64(len(m.FpBtcPkHex))) - i-- - dAtA[i] = 0xa - } - return len(dAtA) - i, nil -} +func init() { proto.RegisterFile("babylon/finality/v1/query.proto", fileDescriptor_32bddab77af6fdae) } -func (m *QueryListPubRandCommitResponse) 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 +var fileDescriptor_32bddab77af6fdae = []byte{ + // 1950 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xbc, 0x58, 0xcd, 0x6f, 0xdb, 0xd8, + 0x11, 0xf7, 0xb3, 0x63, 0xc7, 0x19, 0x49, 0x8d, 0xfd, 0xec, 0xb8, 0xae, 0x92, 0xc8, 0x32, 0x77, + 0x13, 0x7b, 0x9d, 0x84, 0x8c, 0x95, 0x34, 0xcd, 0x06, 0x9b, 0x4d, 0xac, 0xd4, 0xae, 0x8d, 0x3a, + 0x8e, 0x96, 0xce, 0x06, 0x68, 0x2e, 0x04, 0x25, 0x53, 0x12, 0x6b, 0xf1, 0x63, 0x45, 0x52, 0xb5, + 0x51, 0x2c, 0x50, 0xf4, 0xb0, 0x87, 0xa2, 0x05, 0x16, 0xe8, 0xa5, 0x3d, 0xec, 0xa1, 0x40, 0x5b, + 0x14, 0xed, 0xa5, 0xc7, 0xf6, 0x3f, 0xd8, 0xe3, 0x62, 0xdb, 0x43, 0xb1, 0xc5, 0xa6, 0x41, 0x12, + 0xa0, 0x40, 0x4f, 0xfd, 0x13, 0x0a, 0xbe, 0x37, 0x14, 0x45, 0x89, 0x92, 0xe8, 0x0f, 0xf4, 0x62, + 0x58, 0xef, 0xcd, 0xc7, 0x6f, 0xe6, 0xcd, 0x0c, 0x67, 0x06, 0x16, 0xca, 0x6a, 0xf9, 0xb0, 0x61, + 0x99, 0x52, 0x55, 0x37, 0xd5, 0x86, 0xee, 0x1e, 0x4a, 0xad, 0x55, 0xe9, 0x23, 0x4f, 0x6b, 0x1e, + 0x8a, 0x76, 0xd3, 0x72, 0x2d, 0x3a, 0x83, 0x04, 0x62, 0x40, 0x20, 0xb6, 0x56, 0xb3, 0xb3, 0x35, + 0xab, 0x66, 0xb1, 0x7b, 0xc9, 0xff, 0x8f, 0x93, 0x66, 0x2f, 0xd5, 0x2c, 0xab, 0xd6, 0xd0, 0x24, + 0xd5, 0xd6, 0x25, 0xd5, 0x34, 0x2d, 0x57, 0x75, 0x75, 0xcb, 0x74, 0xf0, 0x76, 0xa5, 0x62, 0x39, + 0x86, 0xe5, 0x48, 0x65, 0xd5, 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, 0x16, 0x7c, 0xd8, 0xde, 0xff, + 0x9e, 0x40, 0xaa, 0xa3, 0xbb, 0xa2, 0x03, 0x62, 0xa9, 0xb7, 0x71, 0xcf, 0xde, 0x48, 0x48, 0x8d, + 0xa0, 0xee, 0x31, 0x50, 0xb7, 0x69, 0x21, 0x16, 0x54, 0xa4, 0x1d, 0xec, 0x76, 0x26, 0xfd, 0x35, + 0x81, 0x74, 0x67, 0x23, 0x49, 0x93, 0xe9, 0x6e, 0x7b, 0x50, 0x4c, 0x4a, 0x8e, 0x58, 0x57, 0x18, + 0xd6, 0xb7, 0xa9, 0x30, 0x1c, 0x6b, 0x71, 0xfb, 0xf3, 0x57, 0x39, 0xf2, 0xc5, 0xab, 0x1c, 0x79, + 0xf9, 0x2a, 0x47, 0x3e, 0x7d, 0x9d, 0x1b, 0xf9, 0xe2, 0x75, 0x6e, 0xe4, 0x1f, 0xaf, 0x73, 0x23, + 0xcf, 0x0b, 0xc3, 0xe7, 0xd9, 0x83, 0x50, 0x30, 0x1b, 0x6d, 0xcb, 0x13, 0x6c, 0x74, 0xb8, 0xf5, + 0xbf, 0x00, 0x00, 0x00, 0xff, 0xff, 0xd9, 0x4d, 0x5d, 0x1d, 0x74, 0x1d, 0x00, 0x00, } -func (m *QueryListPubRandCommitResponse) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} +// Reference imports to suppress errors if they are not otherwise used. +var _ context.Context +var _ grpc.ClientConn -func (m *QueryListPubRandCommitResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if m.Pagination != nil { - { - size, err := m.Pagination.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintQuery(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x12 - } - if len(m.PubRandCommitMap) > 0 { - for k := range m.PubRandCommitMap { - v := m.PubRandCommitMap[k] - baseI := i - if v != nil { - { - size, err := v.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintQuery(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x12 - } - i = encodeVarintQuery(dAtA, i, uint64(k)) - i-- - dAtA[i] = 0x8 - i = encodeVarintQuery(dAtA, i, uint64(baseI-i)) - i-- - dAtA[i] = 0xa - } - } - return len(dAtA) - i, nil -} +// This is a compile-time assertion to ensure that this generated file +// is compatible with the grpc package it is being compiled against. +const _ = grpc.SupportPackageIsVersion4 -func (m *QueryBlockRequest) 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 +// QueryClient is the client API for Query service. +// +// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream. +type QueryClient interface { + // Parameters queries the parameters of the module. + Params(ctx context.Context, in *QueryParamsRequest, opts ...grpc.CallOption) (*QueryParamsResponse, error) + // ActiveFinalityProvidersAtHeight queries finality providers with non zero voting power at given height. + ActiveFinalityProvidersAtHeight(ctx context.Context, in *QueryActiveFinalityProvidersAtHeightRequest, opts ...grpc.CallOption) (*QueryActiveFinalityProvidersAtHeightResponse, error) + // FinalityProviderPowerAtHeight queries the voting power of a finality provider at a given height + FinalityProviderPowerAtHeight(ctx context.Context, in *QueryFinalityProviderPowerAtHeightRequest, opts ...grpc.CallOption) (*QueryFinalityProviderPowerAtHeightResponse, error) + // FinalityProviderCurrentPower queries the voting power of a finality provider at the current height + FinalityProviderCurrentPower(ctx context.Context, in *QueryFinalityProviderCurrentPowerRequest, opts ...grpc.CallOption) (*QueryFinalityProviderCurrentPowerResponse, error) + // ActivatedHeight queries the height when BTC staking protocol is activated, i.e., the first height when + // there exists 1 finality provider with voting power + ActivatedHeight(ctx context.Context, in *QueryActivatedHeightRequest, opts ...grpc.CallOption) (*QueryActivatedHeightResponse, error) + // ListPublicRandomness is a range query for public randomness of a given finality provider + // NOTE: Babylon only has the knowledge of public randomness that is already revealed by + // finality providers, i.e., the finality provider already provides a finality signature + // at the corresponding height + ListPublicRandomness(ctx context.Context, in *QueryListPublicRandomnessRequest, opts ...grpc.CallOption) (*QueryListPublicRandomnessResponse, error) + // ListPubRandCommit is a range query for public randomness commitments of a given finality provider + ListPubRandCommit(ctx context.Context, in *QueryListPubRandCommitRequest, opts ...grpc.CallOption) (*QueryListPubRandCommitResponse, error) + // Block queries a block at a given height + Block(ctx context.Context, in *QueryBlockRequest, opts ...grpc.CallOption) (*QueryBlockResponse, error) + // ListBlocks is a range query for blocks at a given status + ListBlocks(ctx context.Context, in *QueryListBlocksRequest, opts ...grpc.CallOption) (*QueryListBlocksResponse, error) + // VotesAtHeight queries finality providers who have signed the block at given height. + VotesAtHeight(ctx context.Context, in *QueryVotesAtHeightRequest, opts ...grpc.CallOption) (*QueryVotesAtHeightResponse, error) + // Evidence queries the first evidence which can be used for extracting the BTC SK + Evidence(ctx context.Context, in *QueryEvidenceRequest, opts ...grpc.CallOption) (*QueryEvidenceResponse, error) + // ListEvidences queries is a range query for evidences + ListEvidences(ctx context.Context, in *QueryListEvidencesRequest, opts ...grpc.CallOption) (*QueryListEvidencesResponse, error) + // SigningInfo queries the signing info of given finality provider BTC public key + SigningInfo(ctx context.Context, in *QuerySigningInfoRequest, opts ...grpc.CallOption) (*QuerySigningInfoResponse, error) + // SigningInfos queries the signing info of all the active finality providers + SigningInfos(ctx context.Context, in *QuerySigningInfosRequest, opts ...grpc.CallOption) (*QuerySigningInfosResponse, error) } -func (m *QueryBlockRequest) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) +type queryClient struct { + cc grpc1.ClientConn } -func (m *QueryBlockRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if m.Height != 0 { - i = encodeVarintQuery(dAtA, i, uint64(m.Height)) - i-- - dAtA[i] = 0x8 - } - return len(dAtA) - i, nil +func NewQueryClient(cc grpc1.ClientConn) QueryClient { + return &queryClient{cc} } -func (m *QueryBlockResponse) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) +func (c *queryClient) Params(ctx context.Context, in *QueryParamsRequest, opts ...grpc.CallOption) (*QueryParamsResponse, error) { + out := new(QueryParamsResponse) + err := c.cc.Invoke(ctx, "/babylon.finality.v1.Query/Params", in, out, opts...) if err != nil { return nil, err } - return dAtA[:n], nil -} - -func (m *QueryBlockResponse) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) + return out, nil } -func (m *QueryBlockResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if m.Block != nil { - { - size, err := m.Block.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintQuery(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0xa +func (c *queryClient) ActiveFinalityProvidersAtHeight(ctx context.Context, in *QueryActiveFinalityProvidersAtHeightRequest, opts ...grpc.CallOption) (*QueryActiveFinalityProvidersAtHeightResponse, error) { + out := new(QueryActiveFinalityProvidersAtHeightResponse) + err := c.cc.Invoke(ctx, "/babylon.finality.v1.Query/ActiveFinalityProvidersAtHeight", in, out, opts...) + if err != nil { + return nil, err } - return len(dAtA) - i, nil + return out, nil } -func (m *QueryListBlocksRequest) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) +func (c *queryClient) FinalityProviderPowerAtHeight(ctx context.Context, in *QueryFinalityProviderPowerAtHeightRequest, opts ...grpc.CallOption) (*QueryFinalityProviderPowerAtHeightResponse, error) { + out := new(QueryFinalityProviderPowerAtHeightResponse) + err := c.cc.Invoke(ctx, "/babylon.finality.v1.Query/FinalityProviderPowerAtHeight", in, out, opts...) if err != nil { return nil, err } - return dAtA[:n], nil -} - -func (m *QueryListBlocksRequest) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) + return out, nil } -func (m *QueryListBlocksRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if m.Pagination != nil { - { - size, err := m.Pagination.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintQuery(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x12 - } - if m.Status != 0 { - i = encodeVarintQuery(dAtA, i, uint64(m.Status)) - i-- - dAtA[i] = 0x8 +func (c *queryClient) FinalityProviderCurrentPower(ctx context.Context, in *QueryFinalityProviderCurrentPowerRequest, opts ...grpc.CallOption) (*QueryFinalityProviderCurrentPowerResponse, error) { + out := new(QueryFinalityProviderCurrentPowerResponse) + err := c.cc.Invoke(ctx, "/babylon.finality.v1.Query/FinalityProviderCurrentPower", in, out, opts...) + if err != nil { + return nil, err } - return len(dAtA) - i, nil + return out, nil } -func (m *QueryListBlocksResponse) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) +func (c *queryClient) ActivatedHeight(ctx context.Context, in *QueryActivatedHeightRequest, opts ...grpc.CallOption) (*QueryActivatedHeightResponse, error) { + out := new(QueryActivatedHeightResponse) + err := c.cc.Invoke(ctx, "/babylon.finality.v1.Query/ActivatedHeight", in, out, opts...) if err != nil { return nil, err } - return dAtA[:n], nil + return out, nil } -func (m *QueryListBlocksResponse) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) +func (c *queryClient) ListPublicRandomness(ctx context.Context, in *QueryListPublicRandomnessRequest, opts ...grpc.CallOption) (*QueryListPublicRandomnessResponse, error) { + out := new(QueryListPublicRandomnessResponse) + err := c.cc.Invoke(ctx, "/babylon.finality.v1.Query/ListPublicRandomness", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil } -func (m *QueryListBlocksResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if m.Pagination != nil { - { - size, err := m.Pagination.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintQuery(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x12 - } - if len(m.Blocks) > 0 { - for iNdEx := len(m.Blocks) - 1; iNdEx >= 0; iNdEx-- { - { - size, err := m.Blocks[iNdEx].MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintQuery(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0xa - } +func (c *queryClient) ListPubRandCommit(ctx context.Context, in *QueryListPubRandCommitRequest, opts ...grpc.CallOption) (*QueryListPubRandCommitResponse, error) { + out := new(QueryListPubRandCommitResponse) + err := c.cc.Invoke(ctx, "/babylon.finality.v1.Query/ListPubRandCommit", in, out, opts...) + if err != nil { + return nil, err } - return len(dAtA) - i, nil + return out, nil } -func (m *QueryVotesAtHeightRequest) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) +func (c *queryClient) Block(ctx context.Context, in *QueryBlockRequest, opts ...grpc.CallOption) (*QueryBlockResponse, error) { + out := new(QueryBlockResponse) + err := c.cc.Invoke(ctx, "/babylon.finality.v1.Query/Block", in, out, opts...) if err != nil { return nil, err } - return dAtA[:n], nil + return out, nil } -func (m *QueryVotesAtHeightRequest) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) +func (c *queryClient) ListBlocks(ctx context.Context, in *QueryListBlocksRequest, opts ...grpc.CallOption) (*QueryListBlocksResponse, error) { + out := new(QueryListBlocksResponse) + err := c.cc.Invoke(ctx, "/babylon.finality.v1.Query/ListBlocks", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil } -func (m *QueryVotesAtHeightRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if m.Height != 0 { - i = encodeVarintQuery(dAtA, i, uint64(m.Height)) - i-- - dAtA[i] = 0x8 +func (c *queryClient) VotesAtHeight(ctx context.Context, in *QueryVotesAtHeightRequest, opts ...grpc.CallOption) (*QueryVotesAtHeightResponse, error) { + out := new(QueryVotesAtHeightResponse) + err := c.cc.Invoke(ctx, "/babylon.finality.v1.Query/VotesAtHeight", in, out, opts...) + if err != nil { + return nil, err } - return len(dAtA) - i, nil + return out, nil } -func (m *QueryVotesAtHeightResponse) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) +func (c *queryClient) Evidence(ctx context.Context, in *QueryEvidenceRequest, opts ...grpc.CallOption) (*QueryEvidenceResponse, error) { + out := new(QueryEvidenceResponse) + err := c.cc.Invoke(ctx, "/babylon.finality.v1.Query/Evidence", in, out, opts...) if err != nil { return nil, err } - return dAtA[:n], nil + return out, nil } -func (m *QueryVotesAtHeightResponse) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) +func (c *queryClient) ListEvidences(ctx context.Context, in *QueryListEvidencesRequest, opts ...grpc.CallOption) (*QueryListEvidencesResponse, error) { + out := new(QueryListEvidencesResponse) + err := c.cc.Invoke(ctx, "/babylon.finality.v1.Query/ListEvidences", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil } -func (m *QueryVotesAtHeightResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if len(m.BtcPks) > 0 { - for iNdEx := len(m.BtcPks) - 1; iNdEx >= 0; iNdEx-- { - { - size := m.BtcPks[iNdEx].Size() - i -= size - if _, err := m.BtcPks[iNdEx].MarshalTo(dAtA[i:]); err != nil { - return 0, err - } - i = encodeVarintQuery(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0xa - } +func (c *queryClient) SigningInfo(ctx context.Context, in *QuerySigningInfoRequest, opts ...grpc.CallOption) (*QuerySigningInfoResponse, error) { + out := new(QuerySigningInfoResponse) + err := c.cc.Invoke(ctx, "/babylon.finality.v1.Query/SigningInfo", in, out, opts...) + if err != nil { + return nil, err } - return len(dAtA) - i, nil + return out, nil } -func (m *QueryEvidenceRequest) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) +func (c *queryClient) SigningInfos(ctx context.Context, in *QuerySigningInfosRequest, opts ...grpc.CallOption) (*QuerySigningInfosResponse, error) { + out := new(QuerySigningInfosResponse) + err := c.cc.Invoke(ctx, "/babylon.finality.v1.Query/SigningInfos", in, out, opts...) if err != nil { return nil, err } - return dAtA[:n], nil + return out, nil } -func (m *QueryEvidenceRequest) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) +// QueryServer is the server API for Query service. +type QueryServer interface { + // Parameters queries the parameters of the module. + Params(context.Context, *QueryParamsRequest) (*QueryParamsResponse, error) + // ActiveFinalityProvidersAtHeight queries finality providers with non zero voting power at given height. + ActiveFinalityProvidersAtHeight(context.Context, *QueryActiveFinalityProvidersAtHeightRequest) (*QueryActiveFinalityProvidersAtHeightResponse, error) + // FinalityProviderPowerAtHeight queries the voting power of a finality provider at a given height + FinalityProviderPowerAtHeight(context.Context, *QueryFinalityProviderPowerAtHeightRequest) (*QueryFinalityProviderPowerAtHeightResponse, error) + // FinalityProviderCurrentPower queries the voting power of a finality provider at the current height + FinalityProviderCurrentPower(context.Context, *QueryFinalityProviderCurrentPowerRequest) (*QueryFinalityProviderCurrentPowerResponse, error) + // ActivatedHeight queries the height when BTC staking protocol is activated, i.e., the first height when + // there exists 1 finality provider with voting power + ActivatedHeight(context.Context, *QueryActivatedHeightRequest) (*QueryActivatedHeightResponse, error) + // ListPublicRandomness is a range query for public randomness of a given finality provider + // NOTE: Babylon only has the knowledge of public randomness that is already revealed by + // finality providers, i.e., the finality provider already provides a finality signature + // at the corresponding height + ListPublicRandomness(context.Context, *QueryListPublicRandomnessRequest) (*QueryListPublicRandomnessResponse, error) + // ListPubRandCommit is a range query for public randomness commitments of a given finality provider + ListPubRandCommit(context.Context, *QueryListPubRandCommitRequest) (*QueryListPubRandCommitResponse, error) + // Block queries a block at a given height + Block(context.Context, *QueryBlockRequest) (*QueryBlockResponse, error) + // ListBlocks is a range query for blocks at a given status + ListBlocks(context.Context, *QueryListBlocksRequest) (*QueryListBlocksResponse, error) + // VotesAtHeight queries finality providers who have signed the block at given height. + VotesAtHeight(context.Context, *QueryVotesAtHeightRequest) (*QueryVotesAtHeightResponse, error) + // Evidence queries the first evidence which can be used for extracting the BTC SK + Evidence(context.Context, *QueryEvidenceRequest) (*QueryEvidenceResponse, error) + // ListEvidences queries is a range query for evidences + ListEvidences(context.Context, *QueryListEvidencesRequest) (*QueryListEvidencesResponse, error) + // SigningInfo queries the signing info of given finality provider BTC public key + SigningInfo(context.Context, *QuerySigningInfoRequest) (*QuerySigningInfoResponse, error) + // SigningInfos queries the signing info of all the active finality providers + SigningInfos(context.Context, *QuerySigningInfosRequest) (*QuerySigningInfosResponse, error) } -func (m *QueryEvidenceRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if len(m.FpBtcPkHex) > 0 { - i -= len(m.FpBtcPkHex) - copy(dAtA[i:], m.FpBtcPkHex) - i = encodeVarintQuery(dAtA, i, uint64(len(m.FpBtcPkHex))) - i-- - dAtA[i] = 0xa - } - return len(dAtA) - i, nil +// UnimplementedQueryServer can be embedded to have forward compatible implementations. +type UnimplementedQueryServer struct { } -func (m *QueryEvidenceResponse) 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 (*UnimplementedQueryServer) Params(ctx context.Context, req *QueryParamsRequest) (*QueryParamsResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method Params not implemented") +} +func (*UnimplementedQueryServer) ActiveFinalityProvidersAtHeight(ctx context.Context, req *QueryActiveFinalityProvidersAtHeightRequest) (*QueryActiveFinalityProvidersAtHeightResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method ActiveFinalityProvidersAtHeight not implemented") +} +func (*UnimplementedQueryServer) FinalityProviderPowerAtHeight(ctx context.Context, req *QueryFinalityProviderPowerAtHeightRequest) (*QueryFinalityProviderPowerAtHeightResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method FinalityProviderPowerAtHeight not implemented") +} +func (*UnimplementedQueryServer) FinalityProviderCurrentPower(ctx context.Context, req *QueryFinalityProviderCurrentPowerRequest) (*QueryFinalityProviderCurrentPowerResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method FinalityProviderCurrentPower not implemented") +} +func (*UnimplementedQueryServer) ActivatedHeight(ctx context.Context, req *QueryActivatedHeightRequest) (*QueryActivatedHeightResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method ActivatedHeight not implemented") +} +func (*UnimplementedQueryServer) ListPublicRandomness(ctx context.Context, req *QueryListPublicRandomnessRequest) (*QueryListPublicRandomnessResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method ListPublicRandomness not implemented") +} +func (*UnimplementedQueryServer) ListPubRandCommit(ctx context.Context, req *QueryListPubRandCommitRequest) (*QueryListPubRandCommitResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method ListPubRandCommit not implemented") +} +func (*UnimplementedQueryServer) Block(ctx context.Context, req *QueryBlockRequest) (*QueryBlockResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method Block not implemented") +} +func (*UnimplementedQueryServer) ListBlocks(ctx context.Context, req *QueryListBlocksRequest) (*QueryListBlocksResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method ListBlocks not implemented") +} +func (*UnimplementedQueryServer) VotesAtHeight(ctx context.Context, req *QueryVotesAtHeightRequest) (*QueryVotesAtHeightResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method VotesAtHeight not implemented") +} +func (*UnimplementedQueryServer) Evidence(ctx context.Context, req *QueryEvidenceRequest) (*QueryEvidenceResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method Evidence not implemented") +} +func (*UnimplementedQueryServer) ListEvidences(ctx context.Context, req *QueryListEvidencesRequest) (*QueryListEvidencesResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method ListEvidences not implemented") +} +func (*UnimplementedQueryServer) SigningInfo(ctx context.Context, req *QuerySigningInfoRequest) (*QuerySigningInfoResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method SigningInfo not implemented") +} +func (*UnimplementedQueryServer) SigningInfos(ctx context.Context, req *QuerySigningInfosRequest) (*QuerySigningInfosResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method SigningInfos not implemented") } -func (m *QueryEvidenceResponse) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) +func RegisterQueryServer(s grpc1.Server, srv QueryServer) { + s.RegisterService(&_Query_serviceDesc, srv) } -func (m *QueryEvidenceResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if m.Evidence != nil { - { - size, err := m.Evidence.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintQuery(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0xa +func _Query_Params_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(QueryParamsRequest) + if err := dec(in); err != nil { + return nil, err } - return len(dAtA) - i, nil + if interceptor == nil { + return srv.(QueryServer).Params(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/babylon.finality.v1.Query/Params", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(QueryServer).Params(ctx, req.(*QueryParamsRequest)) + } + return interceptor(ctx, in, info, handler) } -func (m *QueryListEvidencesRequest) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { +func _Query_ActiveFinalityProvidersAtHeight_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(QueryActiveFinalityProvidersAtHeightRequest) + if err := dec(in); err != nil { return nil, err } - return dAtA[:n], nil + if interceptor == nil { + return srv.(QueryServer).ActiveFinalityProvidersAtHeight(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/babylon.finality.v1.Query/ActiveFinalityProvidersAtHeight", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(QueryServer).ActiveFinalityProvidersAtHeight(ctx, req.(*QueryActiveFinalityProvidersAtHeightRequest)) + } + return interceptor(ctx, in, info, handler) } -func (m *QueryListEvidencesRequest) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) +func _Query_FinalityProviderPowerAtHeight_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(QueryFinalityProviderPowerAtHeightRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(QueryServer).FinalityProviderPowerAtHeight(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/babylon.finality.v1.Query/FinalityProviderPowerAtHeight", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(QueryServer).FinalityProviderPowerAtHeight(ctx, req.(*QueryFinalityProviderPowerAtHeightRequest)) + } + return interceptor(ctx, in, info, handler) } -func (m *QueryListEvidencesRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if m.Pagination != nil { - { - size, err := m.Pagination.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintQuery(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x12 +func _Query_FinalityProviderCurrentPower_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(QueryFinalityProviderCurrentPowerRequest) + if err := dec(in); err != nil { + return nil, err } - if m.StartHeight != 0 { - i = encodeVarintQuery(dAtA, i, uint64(m.StartHeight)) - i-- - dAtA[i] = 0x8 + if interceptor == nil { + return srv.(QueryServer).FinalityProviderCurrentPower(ctx, in) } - return len(dAtA) - i, nil + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/babylon.finality.v1.Query/FinalityProviderCurrentPower", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(QueryServer).FinalityProviderCurrentPower(ctx, req.(*QueryFinalityProviderCurrentPowerRequest)) + } + return interceptor(ctx, in, info, handler) } -func (m *QueryListEvidencesResponse) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { +func _Query_ActivatedHeight_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(QueryActivatedHeightRequest) + if err := dec(in); err != nil { return nil, err } - return dAtA[:n], nil + if interceptor == nil { + return srv.(QueryServer).ActivatedHeight(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/babylon.finality.v1.Query/ActivatedHeight", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(QueryServer).ActivatedHeight(ctx, req.(*QueryActivatedHeightRequest)) + } + return interceptor(ctx, in, info, handler) } -func (m *QueryListEvidencesResponse) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) +func _Query_ListPublicRandomness_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(QueryListPublicRandomnessRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(QueryServer).ListPublicRandomness(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/babylon.finality.v1.Query/ListPublicRandomness", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(QueryServer).ListPublicRandomness(ctx, req.(*QueryListPublicRandomnessRequest)) + } + return interceptor(ctx, in, info, handler) } -func (m *QueryListEvidencesResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if m.Pagination != nil { - { - size, err := m.Pagination.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintQuery(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x12 +func _Query_ListPubRandCommit_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(QueryListPubRandCommitRequest) + if err := dec(in); err != nil { + return nil, err } - if len(m.Evidences) > 0 { - for iNdEx := len(m.Evidences) - 1; iNdEx >= 0; iNdEx-- { - { - size, err := m.Evidences[iNdEx].MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintQuery(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0xa - } + if interceptor == nil { + return srv.(QueryServer).ListPubRandCommit(ctx, in) } - return len(dAtA) - i, nil + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/babylon.finality.v1.Query/ListPubRandCommit", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(QueryServer).ListPubRandCommit(ctx, req.(*QueryListPubRandCommitRequest)) + } + return interceptor(ctx, in, info, handler) } -func (m *QuerySigningInfoRequest) Marshal() (dAtA []byte, err error) { +func _Query_Block_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(QueryBlockRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(QueryServer).Block(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/babylon.finality.v1.Query/Block", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(QueryServer).Block(ctx, req.(*QueryBlockRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _Query_ListBlocks_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(QueryListBlocksRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(QueryServer).ListBlocks(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/babylon.finality.v1.Query/ListBlocks", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(QueryServer).ListBlocks(ctx, req.(*QueryListBlocksRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _Query_VotesAtHeight_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(QueryVotesAtHeightRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(QueryServer).VotesAtHeight(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/babylon.finality.v1.Query/VotesAtHeight", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(QueryServer).VotesAtHeight(ctx, req.(*QueryVotesAtHeightRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _Query_Evidence_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(QueryEvidenceRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(QueryServer).Evidence(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/babylon.finality.v1.Query/Evidence", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(QueryServer).Evidence(ctx, req.(*QueryEvidenceRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _Query_ListEvidences_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(QueryListEvidencesRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(QueryServer).ListEvidences(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/babylon.finality.v1.Query/ListEvidences", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(QueryServer).ListEvidences(ctx, req.(*QueryListEvidencesRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _Query_SigningInfo_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(QuerySigningInfoRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(QueryServer).SigningInfo(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/babylon.finality.v1.Query/SigningInfo", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(QueryServer).SigningInfo(ctx, req.(*QuerySigningInfoRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _Query_SigningInfos_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(QuerySigningInfosRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(QueryServer).SigningInfos(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/babylon.finality.v1.Query/SigningInfos", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(QueryServer).SigningInfos(ctx, req.(*QuerySigningInfosRequest)) + } + return interceptor(ctx, in, info, handler) +} + +var _Query_serviceDesc = grpc.ServiceDesc{ + ServiceName: "babylon.finality.v1.Query", + HandlerType: (*QueryServer)(nil), + Methods: []grpc.MethodDesc{ + { + MethodName: "Params", + Handler: _Query_Params_Handler, + }, + { + MethodName: "ActiveFinalityProvidersAtHeight", + Handler: _Query_ActiveFinalityProvidersAtHeight_Handler, + }, + { + MethodName: "FinalityProviderPowerAtHeight", + Handler: _Query_FinalityProviderPowerAtHeight_Handler, + }, + { + MethodName: "FinalityProviderCurrentPower", + Handler: _Query_FinalityProviderCurrentPower_Handler, + }, + { + MethodName: "ActivatedHeight", + Handler: _Query_ActivatedHeight_Handler, + }, + { + MethodName: "ListPublicRandomness", + Handler: _Query_ListPublicRandomness_Handler, + }, + { + MethodName: "ListPubRandCommit", + Handler: _Query_ListPubRandCommit_Handler, + }, + { + MethodName: "Block", + Handler: _Query_Block_Handler, + }, + { + MethodName: "ListBlocks", + Handler: _Query_ListBlocks_Handler, + }, + { + MethodName: "VotesAtHeight", + Handler: _Query_VotesAtHeight_Handler, + }, + { + MethodName: "Evidence", + Handler: _Query_Evidence_Handler, + }, + { + MethodName: "ListEvidences", + Handler: _Query_ListEvidences_Handler, + }, + { + MethodName: "SigningInfo", + Handler: _Query_SigningInfo_Handler, + }, + { + MethodName: "SigningInfos", + Handler: _Query_SigningInfos_Handler, + }, + }, + Streams: []grpc.StreamDesc{}, + Metadata: "babylon/finality/v1/query.proto", +} + +func (m *QueryParamsRequest) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalToSizedBuffer(dAtA[:size]) @@ -2354,27 +2566,20 @@ func (m *QuerySigningInfoRequest) Marshal() (dAtA []byte, err error) { return dAtA[:n], nil } -func (m *QuerySigningInfoRequest) MarshalTo(dAtA []byte) (int, error) { +func (m *QueryParamsRequest) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *QuerySigningInfoRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *QueryParamsRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) _ = i var l int _ = l - if len(m.FpBtcPkHex) > 0 { - i -= len(m.FpBtcPkHex) - copy(dAtA[i:], m.FpBtcPkHex) - i = encodeVarintQuery(dAtA, i, uint64(len(m.FpBtcPkHex))) - i-- - dAtA[i] = 0xa - } return len(dAtA) - i, nil } -func (m *QuerySigningInfoResponse) Marshal() (dAtA []byte, err error) { +func (m *QueryParamsResponse) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalToSizedBuffer(dAtA[:size]) @@ -2384,18 +2589,18 @@ func (m *QuerySigningInfoResponse) Marshal() (dAtA []byte, err error) { return dAtA[:n], nil } -func (m *QuerySigningInfoResponse) MarshalTo(dAtA []byte) (int, error) { +func (m *QueryParamsResponse) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *QuerySigningInfoResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *QueryParamsResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) _ = i var l int _ = l { - size, err := m.FpSigningInfo.MarshalToSizedBuffer(dAtA[:i]) + size, err := m.Params.MarshalToSizedBuffer(dAtA[:i]) if err != nil { return 0, err } @@ -2407,7 +2612,7 @@ func (m *QuerySigningInfoResponse) MarshalToSizedBuffer(dAtA []byte) (int, error return len(dAtA) - i, nil } -func (m *QuerySigningInfosRequest) Marshal() (dAtA []byte, err error) { +func (m *QueryFinalityProviderPowerAtHeightRequest) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalToSizedBuffer(dAtA[:size]) @@ -2417,32 +2622,32 @@ func (m *QuerySigningInfosRequest) Marshal() (dAtA []byte, err error) { return dAtA[:n], nil } -func (m *QuerySigningInfosRequest) MarshalTo(dAtA []byte) (int, error) { +func (m *QueryFinalityProviderPowerAtHeightRequest) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *QuerySigningInfosRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *QueryFinalityProviderPowerAtHeightRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) _ = i var l int _ = l - if m.Pagination != nil { - { - size, err := m.Pagination.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintQuery(dAtA, i, uint64(size)) - } + if m.Height != 0 { + i = encodeVarintQuery(dAtA, i, uint64(m.Height)) + i-- + dAtA[i] = 0x10 + } + if len(m.FpBtcPkHex) > 0 { + i -= len(m.FpBtcPkHex) + copy(dAtA[i:], m.FpBtcPkHex) + i = encodeVarintQuery(dAtA, i, uint64(len(m.FpBtcPkHex))) i-- dAtA[i] = 0xa } return len(dAtA) - i, nil } -func (m *QuerySigningInfosResponse) Marshal() (dAtA []byte, err error) { +func (m *QueryFinalityProviderPowerAtHeightResponse) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalToSizedBuffer(dAtA[:size]) @@ -2452,392 +2657,2846 @@ func (m *QuerySigningInfosResponse) Marshal() (dAtA []byte, err error) { return dAtA[:n], nil } -func (m *QuerySigningInfosResponse) MarshalTo(dAtA []byte) (int, error) { +func (m *QueryFinalityProviderPowerAtHeightResponse) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *QuerySigningInfosResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *QueryFinalityProviderPowerAtHeightResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) _ = i var l int _ = l - if m.Pagination != nil { - { - size, err := m.Pagination.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintQuery(dAtA, i, uint64(size)) - } + if m.VotingPower != 0 { + i = encodeVarintQuery(dAtA, i, uint64(m.VotingPower)) i-- - dAtA[i] = 0x12 - } - if len(m.FpSigningInfos) > 0 { - for iNdEx := len(m.FpSigningInfos) - 1; iNdEx >= 0; iNdEx-- { - { - size, err := m.FpSigningInfos[iNdEx].MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintQuery(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0xa - } + dAtA[i] = 0x8 } return len(dAtA) - i, nil } -func encodeVarintQuery(dAtA []byte, offset int, v uint64) int { - offset -= sovQuery(v) - base := offset - for v >= 1<<7 { - dAtA[offset] = uint8(v&0x7f | 0x80) - v >>= 7 - offset++ +func (m *QueryFinalityProviderCurrentPowerRequest) 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 *QueryParamsRequest) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - return n + +func (m *QueryFinalityProviderCurrentPowerRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *QueryParamsResponse) Size() (n int) { - if m == nil { - return 0 - } +func (m *QueryFinalityProviderCurrentPowerRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i var l int _ = l - l = m.Params.Size() - n += 1 + l + sovQuery(uint64(l)) - return n + if len(m.FpBtcPkHex) > 0 { + i -= len(m.FpBtcPkHex) + copy(dAtA[i:], m.FpBtcPkHex) + i = encodeVarintQuery(dAtA, i, uint64(len(m.FpBtcPkHex))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil } -func (m *QueryListPublicRandomnessRequest) Size() (n int) { - if m == nil { - return 0 +func (m *QueryFinalityProviderCurrentPowerResponse) 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 *QueryFinalityProviderCurrentPowerResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryFinalityProviderCurrentPowerResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i var l int _ = l - l = len(m.FpBtcPkHex) - if l > 0 { - n += 1 + l + sovQuery(uint64(l)) + if m.VotingPower != 0 { + i = encodeVarintQuery(dAtA, i, uint64(m.VotingPower)) + i-- + dAtA[i] = 0x10 } - if m.Pagination != nil { - l = m.Pagination.Size() - n += 1 + l + sovQuery(uint64(l)) + if m.Height != 0 { + i = encodeVarintQuery(dAtA, i, uint64(m.Height)) + i-- + dAtA[i] = 0x8 } - return n + return len(dAtA) - i, nil } -func (m *QueryListPublicRandomnessResponse) Size() (n int) { - if m == nil { - return 0 +func (m *QueryActiveFinalityProvidersAtHeightRequest) 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 *QueryActiveFinalityProvidersAtHeightRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryActiveFinalityProvidersAtHeightRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i var l int _ = l - if len(m.PubRandMap) > 0 { - for k, v := range m.PubRandMap { - _ = k - _ = v - l = 0 - if v != nil { - l = v.Size() - l += 1 + sovQuery(uint64(l)) + if m.Pagination != nil { + { + size, err := m.Pagination.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err } - mapEntrySize := 1 + sovQuery(uint64(k)) + l - n += mapEntrySize + 1 + sovQuery(uint64(mapEntrySize)) + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) } + i-- + dAtA[i] = 0x12 } - if m.Pagination != nil { - l = m.Pagination.Size() - n += 1 + l + sovQuery(uint64(l)) + if m.Height != 0 { + i = encodeVarintQuery(dAtA, i, uint64(m.Height)) + i-- + dAtA[i] = 0x8 } - return n + return len(dAtA) - i, nil } -func (m *PubRandCommitResponse) Size() (n int) { - if m == nil { - return 0 +func (m *ActiveFinalityProvidersAtHeightResponse) 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 *ActiveFinalityProvidersAtHeightResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *ActiveFinalityProvidersAtHeightResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i var l int _ = l - if m.NumPubRand != 0 { - n += 1 + sovQuery(uint64(m.NumPubRand)) + if m.Jailed { + i-- + if m.Jailed { + dAtA[i] = 1 + } else { + dAtA[i] = 0 + } + i-- + dAtA[i] = 0x30 } - l = len(m.Commitment) - if l > 0 { - n += 1 + l + sovQuery(uint64(l)) + if m.SlashedBtcHeight != 0 { + i = encodeVarintQuery(dAtA, i, uint64(m.SlashedBtcHeight)) + i-- + dAtA[i] = 0x28 } - if m.EpochNum != 0 { - n += 1 + sovQuery(uint64(m.EpochNum)) + if m.SlashedBabylonHeight != 0 { + i = encodeVarintQuery(dAtA, i, uint64(m.SlashedBabylonHeight)) + i-- + dAtA[i] = 0x20 } - return n -} - -func (m *QueryListPubRandCommitRequest) Size() (n int) { - if m == nil { - return 0 + if m.VotingPower != 0 { + i = encodeVarintQuery(dAtA, i, uint64(m.VotingPower)) + i-- + dAtA[i] = 0x18 } - var l int - _ = l - l = len(m.FpBtcPkHex) - if l > 0 { - n += 1 + l + sovQuery(uint64(l)) + if m.Height != 0 { + i = encodeVarintQuery(dAtA, i, uint64(m.Height)) + i-- + dAtA[i] = 0x10 } - if m.Pagination != nil { - l = m.Pagination.Size() - n += 1 + l + sovQuery(uint64(l)) + if m.BtcPkHex != nil { + { + size := m.BtcPkHex.Size() + i -= size + if _, err := m.BtcPkHex.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa } - return n + return len(dAtA) - i, nil } -func (m *QueryListPubRandCommitResponse) Size() (n int) { - if m == nil { - return 0 +func (m *QueryActiveFinalityProvidersAtHeightResponse) 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 *QueryActiveFinalityProvidersAtHeightResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryActiveFinalityProvidersAtHeightResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i var l int _ = l - if len(m.PubRandCommitMap) > 0 { - for k, v := range m.PubRandCommitMap { - _ = k - _ = v - l = 0 - if v != nil { - l = v.Size() - l += 1 + sovQuery(uint64(l)) + if m.Pagination != nil { + { + size, err := m.Pagination.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err } - mapEntrySize := 1 + sovQuery(uint64(k)) + l - n += mapEntrySize + 1 + sovQuery(uint64(mapEntrySize)) + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) } + i-- + dAtA[i] = 0x12 } - if m.Pagination != nil { - l = m.Pagination.Size() - n += 1 + l + sovQuery(uint64(l)) - } - return n -} - -func (m *QueryBlockRequest) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if m.Height != 0 { - n += 1 + sovQuery(uint64(m.Height)) + if len(m.FinalityProviders) > 0 { + for iNdEx := len(m.FinalityProviders) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.FinalityProviders[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + } } - return n + return len(dAtA) - i, nil } -func (m *QueryBlockResponse) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if m.Block != nil { - l = m.Block.Size() - n += 1 + l + sovQuery(uint64(l)) +func (m *QueryActivatedHeightRequest) 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 n + return dAtA[:n], nil } -func (m *QueryListBlocksRequest) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if m.Status != 0 { - n += 1 + sovQuery(uint64(m.Status)) - } - if m.Pagination != nil { - l = m.Pagination.Size() - n += 1 + l + sovQuery(uint64(l)) - } - return n +func (m *QueryActivatedHeightRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *QueryListBlocksResponse) Size() (n int) { - if m == nil { - return 0 - } +func (m *QueryActivatedHeightRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i var l int _ = l - if len(m.Blocks) > 0 { - for _, e := range m.Blocks { - l = e.Size() - n += 1 + l + sovQuery(uint64(l)) - } - } - if m.Pagination != nil { - l = m.Pagination.Size() - n += 1 + l + sovQuery(uint64(l)) - } - return n + return len(dAtA) - i, nil } -func (m *QueryVotesAtHeightRequest) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if m.Height != 0 { - n += 1 + sovQuery(uint64(m.Height)) +func (m *QueryActivatedHeightResponse) 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 n + return dAtA[:n], nil } -func (m *QueryVotesAtHeightResponse) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if len(m.BtcPks) > 0 { - for _, e := range m.BtcPks { - l = e.Size() - n += 1 + l + sovQuery(uint64(l)) - } - } - return n +func (m *QueryActivatedHeightResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *QueryEvidenceRequest) Size() (n int) { - if m == nil { - return 0 - } +func (m *QueryActivatedHeightResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i var l int _ = l - l = len(m.FpBtcPkHex) - if l > 0 { - n += 1 + l + sovQuery(uint64(l)) + if m.Height != 0 { + i = encodeVarintQuery(dAtA, i, uint64(m.Height)) + i-- + dAtA[i] = 0x8 } - return n + return len(dAtA) - i, nil } -func (m *QueryEvidenceResponse) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if m.Evidence != nil { - l = m.Evidence.Size() - n += 1 + l + sovQuery(uint64(l)) +func (m *QueryListPublicRandomnessRequest) 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 n + return dAtA[:n], nil } -func (m *QueryListEvidencesRequest) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if m.StartHeight != 0 { - n += 1 + sovQuery(uint64(m.StartHeight)) - } - if m.Pagination != nil { - l = m.Pagination.Size() - n += 1 + l + sovQuery(uint64(l)) - } - return n +func (m *QueryListPublicRandomnessRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *QueryListEvidencesResponse) Size() (n int) { - if m == nil { - return 0 - } +func (m *QueryListPublicRandomnessRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i var l int _ = l - if len(m.Evidences) > 0 { - for _, e := range m.Evidences { - l = e.Size() - n += 1 + l + sovQuery(uint64(l)) + if m.Pagination != nil { + { + size, err := m.Pagination.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) } + i-- + dAtA[i] = 0x12 } - if m.Pagination != nil { - l = m.Pagination.Size() - n += 1 + l + sovQuery(uint64(l)) + if len(m.FpBtcPkHex) > 0 { + i -= len(m.FpBtcPkHex) + copy(dAtA[i:], m.FpBtcPkHex) + i = encodeVarintQuery(dAtA, i, uint64(len(m.FpBtcPkHex))) + i-- + dAtA[i] = 0xa } - return n + return len(dAtA) - i, nil } -func (m *QuerySigningInfoRequest) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = len(m.FpBtcPkHex) - if l > 0 { - n += 1 + l + sovQuery(uint64(l)) +func (m *QueryListPublicRandomnessResponse) 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 n + return dAtA[:n], nil } -func (m *QuerySigningInfoResponse) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = m.FpSigningInfo.Size() - n += 1 + l + sovQuery(uint64(l)) - return n +func (m *QueryListPublicRandomnessResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *QuerySigningInfosRequest) Size() (n int) { - if m == nil { - return 0 - } +func (m *QueryListPublicRandomnessResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i var l int _ = l if m.Pagination != nil { - l = m.Pagination.Size() - n += 1 + l + sovQuery(uint64(l)) + { + size, err := m.Pagination.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 } - return n + if len(m.PubRandMap) > 0 { + for k := range m.PubRandMap { + v := m.PubRandMap[k] + baseI := i + if v != nil { + { + size := v.Size() + i -= size + if _, err := v.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + } + i = encodeVarintQuery(dAtA, i, uint64(k)) + i-- + dAtA[i] = 0x8 + i = encodeVarintQuery(dAtA, i, uint64(baseI-i)) + i-- + dAtA[i] = 0xa + } + } + return len(dAtA) - i, nil } -func (m *QuerySigningInfosResponse) Size() (n int) { - if m == nil { - return 0 - } +func (m *PubRandCommitResponse) 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 *PubRandCommitResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *PubRandCommitResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i var l int _ = l - if len(m.FpSigningInfos) > 0 { - for _, e := range m.FpSigningInfos { - l = e.Size() - n += 1 + l + sovQuery(uint64(l)) + if m.EpochNum != 0 { + i = encodeVarintQuery(dAtA, i, uint64(m.EpochNum)) + i-- + dAtA[i] = 0x18 + } + if len(m.Commitment) > 0 { + i -= len(m.Commitment) + copy(dAtA[i:], m.Commitment) + i = encodeVarintQuery(dAtA, i, uint64(len(m.Commitment))) + i-- + dAtA[i] = 0x12 + } + if m.NumPubRand != 0 { + i = encodeVarintQuery(dAtA, i, uint64(m.NumPubRand)) + i-- + dAtA[i] = 0x8 + } + return len(dAtA) - i, nil +} + +func (m *QueryListPubRandCommitRequest) 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 *QueryListPubRandCommitRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryListPubRandCommitRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.Pagination != nil { + { + size, err := m.Pagination.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) } + i-- + dAtA[i] = 0x12 + } + if len(m.FpBtcPkHex) > 0 { + i -= len(m.FpBtcPkHex) + copy(dAtA[i:], m.FpBtcPkHex) + i = encodeVarintQuery(dAtA, i, uint64(len(m.FpBtcPkHex))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *QueryListPubRandCommitResponse) 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 *QueryListPubRandCommitResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryListPubRandCommitResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l if m.Pagination != nil { - l = m.Pagination.Size() - n += 1 + l + sovQuery(uint64(l)) + { + size, err := m.Pagination.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 } - return n + if len(m.PubRandCommitMap) > 0 { + for k := range m.PubRandCommitMap { + v := m.PubRandCommitMap[k] + baseI := i + if v != nil { + { + size, err := v.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + } + i = encodeVarintQuery(dAtA, i, uint64(k)) + i-- + dAtA[i] = 0x8 + i = encodeVarintQuery(dAtA, i, uint64(baseI-i)) + i-- + dAtA[i] = 0xa + } + } + return len(dAtA) - i, nil } -func sovQuery(x uint64) (n int) { - return (math_bits.Len64(x|1) + 6) / 7 +func (m *QueryBlockRequest) 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 sozQuery(x uint64) (n int) { - return sovQuery(uint64((x << 1) ^ uint64((int64(x) >> 63)))) + +func (m *QueryBlockRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *QueryParamsRequest) Unmarshal(dAtA []byte) error { + +func (m *QueryBlockRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.Height != 0 { + i = encodeVarintQuery(dAtA, i, uint64(m.Height)) + i-- + dAtA[i] = 0x8 + } + return len(dAtA) - i, nil +} + +func (m *QueryBlockResponse) 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 *QueryBlockResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryBlockResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.Block != nil { + { + size, err := m.Block.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 *QueryListBlocksRequest) 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 *QueryListBlocksRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryListBlocksRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.Pagination != nil { + { + size, err := m.Pagination.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + } + if m.Status != 0 { + i = encodeVarintQuery(dAtA, i, uint64(m.Status)) + i-- + dAtA[i] = 0x8 + } + return len(dAtA) - i, nil +} + +func (m *QueryListBlocksResponse) 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 *QueryListBlocksResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryListBlocksResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.Pagination != nil { + { + size, err := m.Pagination.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + } + if len(m.Blocks) > 0 { + for iNdEx := len(m.Blocks) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.Blocks[iNdEx].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 *QueryVotesAtHeightRequest) 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 *QueryVotesAtHeightRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryVotesAtHeightRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.Height != 0 { + i = encodeVarintQuery(dAtA, i, uint64(m.Height)) + i-- + dAtA[i] = 0x8 + } + return len(dAtA) - i, nil +} + +func (m *QueryVotesAtHeightResponse) 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 *QueryVotesAtHeightResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryVotesAtHeightResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.BtcPks) > 0 { + for iNdEx := len(m.BtcPks) - 1; iNdEx >= 0; iNdEx-- { + { + size := m.BtcPks[iNdEx].Size() + i -= size + if _, err := m.BtcPks[iNdEx].MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + } + } + return len(dAtA) - i, nil +} + +func (m *QueryEvidenceRequest) 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 *QueryEvidenceRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryEvidenceRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.FpBtcPkHex) > 0 { + i -= len(m.FpBtcPkHex) + copy(dAtA[i:], m.FpBtcPkHex) + i = encodeVarintQuery(dAtA, i, uint64(len(m.FpBtcPkHex))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *EvidenceResponse) 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 *EvidenceResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *EvidenceResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.ForkFinalitySig != nil { + { + size := m.ForkFinalitySig.Size() + i -= size + if _, err := m.ForkFinalitySig.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x3a + } + if m.CanonicalFinalitySig != nil { + { + size := m.CanonicalFinalitySig.Size() + i -= size + if _, err := m.CanonicalFinalitySig.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x32 + } + if len(m.ForkAppHash) > 0 { + i -= len(m.ForkAppHash) + copy(dAtA[i:], m.ForkAppHash) + i = encodeVarintQuery(dAtA, i, uint64(len(m.ForkAppHash))) + i-- + dAtA[i] = 0x2a + } + if len(m.CanonicalAppHash) > 0 { + i -= len(m.CanonicalAppHash) + copy(dAtA[i:], m.CanonicalAppHash) + i = encodeVarintQuery(dAtA, i, uint64(len(m.CanonicalAppHash))) + i-- + dAtA[i] = 0x22 + } + if m.PubRand != nil { + { + size := m.PubRand.Size() + i -= size + if _, err := m.PubRand.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x1a + } + if m.BlockHeight != 0 { + i = encodeVarintQuery(dAtA, i, uint64(m.BlockHeight)) + i-- + dAtA[i] = 0x10 + } + if len(m.FpBtcPkHex) > 0 { + i -= len(m.FpBtcPkHex) + copy(dAtA[i:], m.FpBtcPkHex) + i = encodeVarintQuery(dAtA, i, uint64(len(m.FpBtcPkHex))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *QueryEvidenceResponse) 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 *QueryEvidenceResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryEvidenceResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.Evidence != nil { + { + size, err := m.Evidence.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 *QueryListEvidencesRequest) 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 *QueryListEvidencesRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryListEvidencesRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.Pagination != nil { + { + size, err := m.Pagination.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + } + if m.StartHeight != 0 { + i = encodeVarintQuery(dAtA, i, uint64(m.StartHeight)) + i-- + dAtA[i] = 0x8 + } + return len(dAtA) - i, nil +} + +func (m *QueryListEvidencesResponse) 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 *QueryListEvidencesResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryListEvidencesResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.Pagination != nil { + { + size, err := m.Pagination.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + } + if len(m.Evidences) > 0 { + for iNdEx := len(m.Evidences) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.Evidences[iNdEx].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 *QuerySigningInfoRequest) 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 *QuerySigningInfoRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QuerySigningInfoRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.FpBtcPkHex) > 0 { + i -= len(m.FpBtcPkHex) + copy(dAtA[i:], m.FpBtcPkHex) + i = encodeVarintQuery(dAtA, i, uint64(len(m.FpBtcPkHex))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *SigningInfoResponse) 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 *SigningInfoResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *SigningInfoResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + n15, err15 := github_com_cosmos_gogoproto_types.StdTimeMarshalTo(m.JailedUntil, dAtA[i-github_com_cosmos_gogoproto_types.SizeOfStdTime(m.JailedUntil):]) + if err15 != nil { + return 0, err15 + } + i -= n15 + i = encodeVarintQuery(dAtA, i, uint64(n15)) + i-- + dAtA[i] = 0x22 + if m.MissedBlocksCounter != 0 { + i = encodeVarintQuery(dAtA, i, uint64(m.MissedBlocksCounter)) + i-- + dAtA[i] = 0x18 + } + if m.StartHeight != 0 { + i = encodeVarintQuery(dAtA, i, uint64(m.StartHeight)) + i-- + dAtA[i] = 0x10 + } + if len(m.FpBtcPkHex) > 0 { + i -= len(m.FpBtcPkHex) + copy(dAtA[i:], m.FpBtcPkHex) + i = encodeVarintQuery(dAtA, i, uint64(len(m.FpBtcPkHex))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *QuerySigningInfoResponse) 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 *QuerySigningInfoResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QuerySigningInfoResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + { + size, err := m.SigningInfo.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 *QuerySigningInfosRequest) 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 *QuerySigningInfosRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QuerySigningInfosRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.Pagination != nil { + { + size, err := m.Pagination.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 *QuerySigningInfosResponse) 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 *QuerySigningInfosResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QuerySigningInfosResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.Pagination != nil { + { + size, err := m.Pagination.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + } + if len(m.SigningInfos) > 0 { + for iNdEx := len(m.SigningInfos) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.SigningInfos[iNdEx].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 encodeVarintQuery(dAtA []byte, offset int, v uint64) int { + offset -= sovQuery(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *QueryParamsRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + return n +} + +func (m *QueryParamsResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = m.Params.Size() + n += 1 + l + sovQuery(uint64(l)) + return n +} + +func (m *QueryFinalityProviderPowerAtHeightRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.FpBtcPkHex) + if l > 0 { + n += 1 + l + sovQuery(uint64(l)) + } + if m.Height != 0 { + n += 1 + sovQuery(uint64(m.Height)) + } + return n +} + +func (m *QueryFinalityProviderPowerAtHeightResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.VotingPower != 0 { + n += 1 + sovQuery(uint64(m.VotingPower)) + } + return n +} + +func (m *QueryFinalityProviderCurrentPowerRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.FpBtcPkHex) + if l > 0 { + n += 1 + l + sovQuery(uint64(l)) + } + return n +} + +func (m *QueryFinalityProviderCurrentPowerResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.Height != 0 { + n += 1 + sovQuery(uint64(m.Height)) + } + if m.VotingPower != 0 { + n += 1 + sovQuery(uint64(m.VotingPower)) + } + return n +} + +func (m *QueryActiveFinalityProvidersAtHeightRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.Height != 0 { + n += 1 + sovQuery(uint64(m.Height)) + } + if m.Pagination != nil { + l = m.Pagination.Size() + n += 1 + l + sovQuery(uint64(l)) + } + return n +} + +func (m *ActiveFinalityProvidersAtHeightResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.BtcPkHex != nil { + l = m.BtcPkHex.Size() + n += 1 + l + sovQuery(uint64(l)) + } + if m.Height != 0 { + n += 1 + sovQuery(uint64(m.Height)) + } + if m.VotingPower != 0 { + n += 1 + sovQuery(uint64(m.VotingPower)) + } + if m.SlashedBabylonHeight != 0 { + n += 1 + sovQuery(uint64(m.SlashedBabylonHeight)) + } + if m.SlashedBtcHeight != 0 { + n += 1 + sovQuery(uint64(m.SlashedBtcHeight)) + } + if m.Jailed { + n += 2 + } + return n +} + +func (m *QueryActiveFinalityProvidersAtHeightResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if len(m.FinalityProviders) > 0 { + for _, e := range m.FinalityProviders { + l = e.Size() + n += 1 + l + sovQuery(uint64(l)) + } + } + if m.Pagination != nil { + l = m.Pagination.Size() + n += 1 + l + sovQuery(uint64(l)) + } + return n +} + +func (m *QueryActivatedHeightRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + return n +} + +func (m *QueryActivatedHeightResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.Height != 0 { + n += 1 + sovQuery(uint64(m.Height)) + } + return n +} + +func (m *QueryListPublicRandomnessRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.FpBtcPkHex) + if l > 0 { + n += 1 + l + sovQuery(uint64(l)) + } + if m.Pagination != nil { + l = m.Pagination.Size() + n += 1 + l + sovQuery(uint64(l)) + } + return n +} + +func (m *QueryListPublicRandomnessResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if len(m.PubRandMap) > 0 { + for k, v := range m.PubRandMap { + _ = k + _ = v + l = 0 + if v != nil { + l = v.Size() + l += 1 + sovQuery(uint64(l)) + } + mapEntrySize := 1 + sovQuery(uint64(k)) + l + n += mapEntrySize + 1 + sovQuery(uint64(mapEntrySize)) + } + } + if m.Pagination != nil { + l = m.Pagination.Size() + n += 1 + l + sovQuery(uint64(l)) + } + return n +} + +func (m *PubRandCommitResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.NumPubRand != 0 { + n += 1 + sovQuery(uint64(m.NumPubRand)) + } + l = len(m.Commitment) + if l > 0 { + n += 1 + l + sovQuery(uint64(l)) + } + if m.EpochNum != 0 { + n += 1 + sovQuery(uint64(m.EpochNum)) + } + return n +} + +func (m *QueryListPubRandCommitRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.FpBtcPkHex) + if l > 0 { + n += 1 + l + sovQuery(uint64(l)) + } + if m.Pagination != nil { + l = m.Pagination.Size() + n += 1 + l + sovQuery(uint64(l)) + } + return n +} + +func (m *QueryListPubRandCommitResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if len(m.PubRandCommitMap) > 0 { + for k, v := range m.PubRandCommitMap { + _ = k + _ = v + l = 0 + if v != nil { + l = v.Size() + l += 1 + sovQuery(uint64(l)) + } + mapEntrySize := 1 + sovQuery(uint64(k)) + l + n += mapEntrySize + 1 + sovQuery(uint64(mapEntrySize)) + } + } + if m.Pagination != nil { + l = m.Pagination.Size() + n += 1 + l + sovQuery(uint64(l)) + } + return n +} + +func (m *QueryBlockRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.Height != 0 { + n += 1 + sovQuery(uint64(m.Height)) + } + return n +} + +func (m *QueryBlockResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.Block != nil { + l = m.Block.Size() + n += 1 + l + sovQuery(uint64(l)) + } + return n +} + +func (m *QueryListBlocksRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.Status != 0 { + n += 1 + sovQuery(uint64(m.Status)) + } + if m.Pagination != nil { + l = m.Pagination.Size() + n += 1 + l + sovQuery(uint64(l)) + } + return n +} + +func (m *QueryListBlocksResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if len(m.Blocks) > 0 { + for _, e := range m.Blocks { + l = e.Size() + n += 1 + l + sovQuery(uint64(l)) + } + } + if m.Pagination != nil { + l = m.Pagination.Size() + n += 1 + l + sovQuery(uint64(l)) + } + return n +} + +func (m *QueryVotesAtHeightRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.Height != 0 { + n += 1 + sovQuery(uint64(m.Height)) + } + return n +} + +func (m *QueryVotesAtHeightResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if len(m.BtcPks) > 0 { + for _, e := range m.BtcPks { + l = e.Size() + n += 1 + l + sovQuery(uint64(l)) + } + } + return n +} + +func (m *QueryEvidenceRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.FpBtcPkHex) + if l > 0 { + n += 1 + l + sovQuery(uint64(l)) + } + return n +} + +func (m *EvidenceResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.FpBtcPkHex) + if l > 0 { + n += 1 + l + sovQuery(uint64(l)) + } + if m.BlockHeight != 0 { + n += 1 + sovQuery(uint64(m.BlockHeight)) + } + if m.PubRand != nil { + l = m.PubRand.Size() + n += 1 + l + sovQuery(uint64(l)) + } + l = len(m.CanonicalAppHash) + if l > 0 { + n += 1 + l + sovQuery(uint64(l)) + } + l = len(m.ForkAppHash) + if l > 0 { + n += 1 + l + sovQuery(uint64(l)) + } + if m.CanonicalFinalitySig != nil { + l = m.CanonicalFinalitySig.Size() + n += 1 + l + sovQuery(uint64(l)) + } + if m.ForkFinalitySig != nil { + l = m.ForkFinalitySig.Size() + n += 1 + l + sovQuery(uint64(l)) + } + return n +} + +func (m *QueryEvidenceResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.Evidence != nil { + l = m.Evidence.Size() + n += 1 + l + sovQuery(uint64(l)) + } + return n +} + +func (m *QueryListEvidencesRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.StartHeight != 0 { + n += 1 + sovQuery(uint64(m.StartHeight)) + } + if m.Pagination != nil { + l = m.Pagination.Size() + n += 1 + l + sovQuery(uint64(l)) + } + return n +} + +func (m *QueryListEvidencesResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if len(m.Evidences) > 0 { + for _, e := range m.Evidences { + l = e.Size() + n += 1 + l + sovQuery(uint64(l)) + } + } + if m.Pagination != nil { + l = m.Pagination.Size() + n += 1 + l + sovQuery(uint64(l)) + } + return n +} + +func (m *QuerySigningInfoRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.FpBtcPkHex) + if l > 0 { + n += 1 + l + sovQuery(uint64(l)) + } + return n +} + +func (m *SigningInfoResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.FpBtcPkHex) + if l > 0 { + n += 1 + l + sovQuery(uint64(l)) + } + if m.StartHeight != 0 { + n += 1 + sovQuery(uint64(m.StartHeight)) + } + if m.MissedBlocksCounter != 0 { + n += 1 + sovQuery(uint64(m.MissedBlocksCounter)) + } + l = github_com_cosmos_gogoproto_types.SizeOfStdTime(m.JailedUntil) + n += 1 + l + sovQuery(uint64(l)) + return n +} + +func (m *QuerySigningInfoResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = m.SigningInfo.Size() + n += 1 + l + sovQuery(uint64(l)) + return n +} + +func (m *QuerySigningInfosRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.Pagination != nil { + l = m.Pagination.Size() + n += 1 + l + sovQuery(uint64(l)) + } + return n +} + +func (m *QuerySigningInfosResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if len(m.SigningInfos) > 0 { + for _, e := range m.SigningInfos { + l = e.Size() + n += 1 + l + sovQuery(uint64(l)) + } + } + if m.Pagination != nil { + l = m.Pagination.Size() + n += 1 + l + sovQuery(uint64(l)) + } + return n +} + +func sovQuery(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozQuery(x uint64) (n int) { + return sovQuery(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *QueryParamsRequest) 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: QueryParamsRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryParamsRequest: 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 *QueryParamsResponse) 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: QueryParamsResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryParamsResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Params", 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 err := m.Params.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 *QueryFinalityProviderPowerAtHeightRequest) 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: QueryFinalityProviderPowerAtHeightRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryFinalityProviderPowerAtHeightRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field FpBtcPkHex", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + 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 ErrInvalidLengthQuery + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.FpBtcPkHex = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Height", wireType) + } + m.Height = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Height |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + 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 *QueryFinalityProviderPowerAtHeightResponse) 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: QueryFinalityProviderPowerAtHeightResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryFinalityProviderPowerAtHeightResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field VotingPower", wireType) + } + m.VotingPower = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.VotingPower |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + 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 *QueryFinalityProviderCurrentPowerRequest) 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: QueryFinalityProviderCurrentPowerRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryFinalityProviderCurrentPowerRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field FpBtcPkHex", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + 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 ErrInvalidLengthQuery + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.FpBtcPkHex = string(dAtA[iNdEx:postIndex]) + 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 *QueryFinalityProviderCurrentPowerResponse) 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: QueryFinalityProviderCurrentPowerResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryFinalityProviderCurrentPowerResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Height", wireType) + } + m.Height = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Height |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 2: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field VotingPower", wireType) + } + m.VotingPower = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.VotingPower |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + 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 *QueryActiveFinalityProvidersAtHeightRequest) 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: QueryActiveFinalityProvidersAtHeightRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryActiveFinalityProvidersAtHeightRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Height", wireType) + } + m.Height = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Height |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Pagination", 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.Pagination == nil { + m.Pagination = &query.PageRequest{} + } + if err := m.Pagination.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 *ActiveFinalityProvidersAtHeightResponse) 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: ActiveFinalityProvidersAtHeightResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: ActiveFinalityProvidersAtHeightResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field BtcPkHex", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + 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 ErrInvalidLengthQuery + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + var v github_com_babylonlabs_io_babylon_types.BIP340PubKey + m.BtcPkHex = &v + if err := m.BtcPkHex.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 2: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Height", wireType) + } + m.Height = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Height |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 3: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field VotingPower", wireType) + } + m.VotingPower = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.VotingPower |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 4: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field SlashedBabylonHeight", wireType) + } + m.SlashedBabylonHeight = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.SlashedBabylonHeight |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 5: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field SlashedBtcHeight", wireType) + } + m.SlashedBtcHeight = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.SlashedBtcHeight |= uint32(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 6: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Jailed", wireType) + } + var v int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + v |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + m.Jailed = bool(v != 0) + 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 *QueryActiveFinalityProvidersAtHeightResponse) 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: QueryActiveFinalityProvidersAtHeightResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryActiveFinalityProvidersAtHeightResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field FinalityProviders", 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 + } + m.FinalityProviders = append(m.FinalityProviders, &ActiveFinalityProvidersAtHeightResponse{}) + if err := m.FinalityProviders[len(m.FinalityProviders)-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 Pagination", 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.Pagination == nil { + m.Pagination = &query.PageResponse{} + } + if err := m.Pagination.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 *QueryActivatedHeightRequest) 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: QueryActivatedHeightRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryActivatedHeightRequest: 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 *QueryActivatedHeightResponse) 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: QueryActivatedHeightResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryActivatedHeightResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Height", wireType) + } + m.Height = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Height |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + 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 *QueryListPublicRandomnessRequest) 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: QueryListPublicRandomnessRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryListPublicRandomnessRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field FpBtcPkHex", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + 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 ErrInvalidLengthQuery + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.FpBtcPkHex = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Pagination", 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.Pagination == nil { + m.Pagination = &query.PageRequest{} + } + if err := m.Pagination.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 *QueryListPublicRandomnessResponse) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -2860,12 +5519,164 @@ func (m *QueryParamsRequest) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: QueryParamsRequest: wiretype end group for non-group") + return fmt.Errorf("proto: QueryListPublicRandomnessResponse: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: QueryParamsRequest: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: QueryListPublicRandomnessResponse: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field PubRandMap", 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.PubRandMap == nil { + m.PubRandMap = make(map[uint64]*github_com_babylonlabs_io_babylon_types.SchnorrPubRand) + } + var mapkey uint64 + var mapvalue1 github_com_babylonlabs_io_babylon_types.SchnorrPubRand + var mapvalue = &mapvalue1 + for iNdEx < postIndex { + entryPreIndex := 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) + if fieldNum == 1 { + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + mapkey |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + } else if fieldNum == 2 { + var mapbyteLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + mapbyteLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intMapbyteLen := int(mapbyteLen) + if intMapbyteLen < 0 { + return ErrInvalidLengthQuery + } + postbytesIndex := iNdEx + intMapbyteLen + if postbytesIndex < 0 { + return ErrInvalidLengthQuery + } + if postbytesIndex > l { + return io.ErrUnexpectedEOF + } + if err := mapvalue.Unmarshal(dAtA[iNdEx:postbytesIndex]); err != nil { + return err + } + iNdEx = postbytesIndex + } else { + iNdEx = entryPreIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > postIndex { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + m.PubRandMap[mapkey] = ((*github_com_babylonlabs_io_babylon_types.SchnorrPubRand)(mapvalue)) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Pagination", 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.Pagination == nil { + m.Pagination = &query.PageResponse{} + } + if err := m.Pagination.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex default: iNdEx = preIndex skippy, err := skipQuery(dAtA[iNdEx:]) @@ -2887,7 +5698,7 @@ func (m *QueryParamsRequest) Unmarshal(dAtA []byte) error { } return nil } -func (m *QueryParamsResponse) Unmarshal(dAtA []byte) error { +func (m *PubRandCommitResponse) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -2910,17 +5721,36 @@ func (m *QueryParamsResponse) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: QueryParamsResponse: wiretype end group for non-group") + return fmt.Errorf("proto: PubRandCommitResponse: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: QueryParamsResponse: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: PubRandCommitResponse: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field NumPubRand", wireType) + } + m.NumPubRand = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.NumPubRand |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 2: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Params", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field Commitment", wireType) } - var msglen int + var byteLen int for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowQuery @@ -2930,25 +5760,45 @@ func (m *QueryParamsResponse) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - msglen |= int(b&0x7F) << shift + byteLen |= int(b&0x7F) << shift if b < 0x80 { break } } - if msglen < 0 { + if byteLen < 0 { return ErrInvalidLengthQuery } - postIndex := iNdEx + msglen + postIndex := iNdEx + byteLen if postIndex < 0 { return ErrInvalidLengthQuery } if postIndex > l { return io.ErrUnexpectedEOF } - if err := m.Params.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err + m.Commitment = append(m.Commitment[:0], dAtA[iNdEx:postIndex]...) + if m.Commitment == nil { + m.Commitment = []byte{} } iNdEx = postIndex + case 3: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field EpochNum", wireType) + } + m.EpochNum = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.EpochNum |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } default: iNdEx = preIndex skippy, err := skipQuery(dAtA[iNdEx:]) @@ -2970,7 +5820,7 @@ func (m *QueryParamsResponse) Unmarshal(dAtA []byte) error { } return nil } -func (m *QueryListPublicRandomnessRequest) Unmarshal(dAtA []byte) error { +func (m *QueryListPubRandCommitRequest) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -2993,10 +5843,10 @@ func (m *QueryListPublicRandomnessRequest) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: QueryListPublicRandomnessRequest: wiretype end group for non-group") + return fmt.Errorf("proto: QueryListPubRandCommitRequest: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: QueryListPublicRandomnessRequest: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: QueryListPubRandCommitRequest: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: @@ -3088,7 +5938,7 @@ func (m *QueryListPublicRandomnessRequest) Unmarshal(dAtA []byte) error { } return nil } -func (m *QueryListPublicRandomnessResponse) Unmarshal(dAtA []byte) error { +func (m *QueryListPubRandCommitResponse) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -3111,15 +5961,15 @@ func (m *QueryListPublicRandomnessResponse) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: QueryListPublicRandomnessResponse: wiretype end group for non-group") + return fmt.Errorf("proto: QueryListPubRandCommitResponse: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: QueryListPublicRandomnessResponse: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: QueryListPubRandCommitResponse: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field PubRandMap", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field PubRandCommitMap", wireType) } var msglen int for shift := uint(0); ; shift += 7 { @@ -3146,12 +5996,11 @@ func (m *QueryListPublicRandomnessResponse) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - if m.PubRandMap == nil { - m.PubRandMap = make(map[uint64]*github_com_babylonlabs_io_babylon_types.SchnorrPubRand) + if m.PubRandCommitMap == nil { + m.PubRandCommitMap = make(map[uint64]*PubRandCommitResponse) } var mapkey uint64 - var mapvalue1 github_com_babylonlabs_io_babylon_types.SchnorrPubRand - var mapvalue = &mapvalue1 + var mapvalue *PubRandCommitResponse for iNdEx < postIndex { entryPreIndex := iNdEx var wire uint64 @@ -3186,7 +6035,7 @@ func (m *QueryListPublicRandomnessResponse) Unmarshal(dAtA []byte) error { } } } else if fieldNum == 2 { - var mapbyteLen uint64 + var mapmsglen int for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowQuery @@ -3196,26 +6045,26 @@ func (m *QueryListPublicRandomnessResponse) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - mapbyteLen |= uint64(b&0x7F) << shift + mapmsglen |= int(b&0x7F) << shift if b < 0x80 { break } } - intMapbyteLen := int(mapbyteLen) - if intMapbyteLen < 0 { + if mapmsglen < 0 { return ErrInvalidLengthQuery } - postbytesIndex := iNdEx + intMapbyteLen - if postbytesIndex < 0 { + postmsgIndex := iNdEx + mapmsglen + if postmsgIndex < 0 { return ErrInvalidLengthQuery } - if postbytesIndex > l { + if postmsgIndex > l { return io.ErrUnexpectedEOF } - if err := mapvalue.Unmarshal(dAtA[iNdEx:postbytesIndex]); err != nil { + mapvalue = &PubRandCommitResponse{} + if err := mapvalue.Unmarshal(dAtA[iNdEx:postmsgIndex]); err != nil { return err } - iNdEx = postbytesIndex + iNdEx = postmsgIndex } else { iNdEx = entryPreIndex skippy, err := skipQuery(dAtA[iNdEx:]) @@ -3231,7 +6080,7 @@ func (m *QueryListPublicRandomnessResponse) Unmarshal(dAtA []byte) error { iNdEx += skippy } } - m.PubRandMap[mapkey] = ((*github_com_babylonlabs_io_babylon_types.SchnorrPubRand)(mapvalue)) + m.PubRandCommitMap[mapkey] = mapvalue iNdEx = postIndex case 2: if wireType != 2 { @@ -3290,7 +6139,7 @@ func (m *QueryListPublicRandomnessResponse) Unmarshal(dAtA []byte) error { } return nil } -func (m *PubRandCommitResponse) Unmarshal(dAtA []byte) error { +func (m *QueryBlockRequest) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -3313,17 +6162,17 @@ func (m *PubRandCommitResponse) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: PubRandCommitResponse: wiretype end group for non-group") + return fmt.Errorf("proto: QueryBlockRequest: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: PubRandCommitResponse: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: QueryBlockRequest: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field NumPubRand", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field Height", wireType) } - m.NumPubRand = 0 + m.Height = 0 for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowQuery @@ -3333,16 +6182,66 @@ func (m *PubRandCommitResponse) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - m.NumPubRand |= uint64(b&0x7F) << shift + m.Height |= uint64(b&0x7F) << shift if b < 0x80 { break } } - case 2: + 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 *QueryBlockResponse) 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: QueryBlockResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryBlockResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Commitment", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field Block", wireType) } - var byteLen int + var msglen int for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowQuery @@ -3352,45 +6251,28 @@ func (m *PubRandCommitResponse) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - byteLen |= int(b&0x7F) << shift + msglen |= int(b&0x7F) << shift if b < 0x80 { break } } - if byteLen < 0 { + if msglen < 0 { return ErrInvalidLengthQuery } - postIndex := iNdEx + byteLen + postIndex := iNdEx + msglen if postIndex < 0 { return ErrInvalidLengthQuery } if postIndex > l { return io.ErrUnexpectedEOF } - m.Commitment = append(m.Commitment[:0], dAtA[iNdEx:postIndex]...) - if m.Commitment == nil { - m.Commitment = []byte{} - } - iNdEx = postIndex - case 3: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field EpochNum", wireType) + if m.Block == nil { + m.Block = &IndexedBlock{} } - m.EpochNum = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowQuery - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.EpochNum |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } + if err := m.Block.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err } + iNdEx = postIndex default: iNdEx = preIndex skippy, err := skipQuery(dAtA[iNdEx:]) @@ -3412,7 +6294,7 @@ func (m *PubRandCommitResponse) Unmarshal(dAtA []byte) error { } return nil } -func (m *QueryListPubRandCommitRequest) Unmarshal(dAtA []byte) error { +func (m *QueryListBlocksRequest) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -3435,17 +6317,17 @@ func (m *QueryListPubRandCommitRequest) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: QueryListPubRandCommitRequest: wiretype end group for non-group") + return fmt.Errorf("proto: QueryListBlocksRequest: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: QueryListPubRandCommitRequest: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: QueryListBlocksRequest: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field FpBtcPkHex", wireType) + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Status", wireType) } - var stringLen uint64 + m.Status = 0 for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowQuery @@ -3455,24 +6337,11 @@ func (m *QueryListPubRandCommitRequest) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - stringLen |= uint64(b&0x7F) << shift + m.Status |= QueriedBlockStatus(b&0x7F) << shift if b < 0x80 { break } } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthQuery - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthQuery - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.FpBtcPkHex = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex case 2: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field Pagination", wireType) @@ -3530,7 +6399,7 @@ func (m *QueryListPubRandCommitRequest) Unmarshal(dAtA []byte) error { } return nil } -func (m *QueryListPubRandCommitResponse) Unmarshal(dAtA []byte) error { +func (m *QueryListBlocksResponse) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -3545,134 +6414,53 @@ func (m *QueryListPubRandCommitResponse) Unmarshal(dAtA []byte) error { } 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: QueryListPubRandCommitResponse: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: QueryListPubRandCommitResponse: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field PubRandCommitMap", 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.PubRandCommitMap == nil { - m.PubRandCommitMap = make(map[uint64]*PubRandCommitResponse) - } - var mapkey uint64 - var mapvalue *PubRandCommitResponse - for iNdEx < postIndex { - entryPreIndex := 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) - if fieldNum == 1 { - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowQuery - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - mapkey |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - } else if fieldNum == 2 { - var mapmsglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowQuery - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - mapmsglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if mapmsglen < 0 { - return ErrInvalidLengthQuery - } - postmsgIndex := iNdEx + mapmsglen - if postmsgIndex < 0 { - return ErrInvalidLengthQuery - } - if postmsgIndex > l { - return io.ErrUnexpectedEOF - } - mapvalue = &PubRandCommitResponse{} - if err := mapvalue.Unmarshal(dAtA[iNdEx:postmsgIndex]); err != nil { - return err - } - iNdEx = postmsgIndex - } else { - iNdEx = entryPreIndex - skippy, err := skipQuery(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthQuery - } - if (iNdEx + skippy) > postIndex { - return io.ErrUnexpectedEOF - } - iNdEx += skippy + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: QueryListBlocksResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryListBlocksResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Blocks", 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 } } - m.PubRandCommitMap[mapkey] = mapvalue + if msglen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Blocks = append(m.Blocks, &IndexedBlock{}) + if err := m.Blocks[len(m.Blocks)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } iNdEx = postIndex case 2: if wireType != 2 { @@ -3731,7 +6519,7 @@ func (m *QueryListPubRandCommitResponse) Unmarshal(dAtA []byte) error { } return nil } -func (m *QueryBlockRequest) Unmarshal(dAtA []byte) error { +func (m *QueryVotesAtHeightRequest) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -3754,10 +6542,10 @@ func (m *QueryBlockRequest) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: QueryBlockRequest: wiretype end group for non-group") + return fmt.Errorf("proto: QueryVotesAtHeightRequest: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: QueryBlockRequest: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: QueryVotesAtHeightRequest: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: @@ -3800,7 +6588,7 @@ func (m *QueryBlockRequest) Unmarshal(dAtA []byte) error { } return nil } -func (m *QueryBlockResponse) Unmarshal(dAtA []byte) error { +func (m *QueryVotesAtHeightResponse) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -3823,17 +6611,17 @@ func (m *QueryBlockResponse) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: QueryBlockResponse: wiretype end group for non-group") + return fmt.Errorf("proto: QueryVotesAtHeightResponse: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: QueryBlockResponse: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: QueryVotesAtHeightResponse: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Block", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field BtcPks", wireType) } - var msglen int + var byteLen int for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowQuery @@ -3843,25 +6631,24 @@ func (m *QueryBlockResponse) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - msglen |= int(b&0x7F) << shift + byteLen |= int(b&0x7F) << shift if b < 0x80 { break } } - if msglen < 0 { + if byteLen < 0 { return ErrInvalidLengthQuery } - postIndex := iNdEx + msglen + postIndex := iNdEx + byteLen if postIndex < 0 { return ErrInvalidLengthQuery } if postIndex > l { return io.ErrUnexpectedEOF } - if m.Block == nil { - m.Block = &IndexedBlock{} - } - if err := m.Block.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + var v github_com_babylonlabs_io_babylon_types.BIP340PubKey + m.BtcPks = append(m.BtcPks, v) + if err := m.BtcPks[len(m.BtcPks)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } iNdEx = postIndex @@ -3886,7 +6673,7 @@ func (m *QueryBlockResponse) Unmarshal(dAtA []byte) error { } return nil } -func (m *QueryListBlocksRequest) Unmarshal(dAtA []byte) error { +func (m *QueryEvidenceRequest) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -3909,36 +6696,17 @@ func (m *QueryListBlocksRequest) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: QueryListBlocksRequest: wiretype end group for non-group") + return fmt.Errorf("proto: QueryEvidenceRequest: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: QueryListBlocksRequest: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: QueryEvidenceRequest: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field Status", wireType) - } - m.Status = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowQuery - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.Status |= QueriedBlockStatus(b&0x7F) << shift - if b < 0x80 { - break - } - } - case 2: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Pagination", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field FpBtcPkHex", wireType) } - var msglen int + var stringLen uint64 for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowQuery @@ -3948,27 +6716,23 @@ func (m *QueryListBlocksRequest) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - msglen |= int(b&0x7F) << shift + stringLen |= uint64(b&0x7F) << shift if b < 0x80 { break } } - if msglen < 0 { + intStringLen := int(stringLen) + if intStringLen < 0 { return ErrInvalidLengthQuery } - postIndex := iNdEx + msglen + postIndex := iNdEx + intStringLen if postIndex < 0 { return ErrInvalidLengthQuery } if postIndex > l { return io.ErrUnexpectedEOF } - if m.Pagination == nil { - m.Pagination = &query.PageRequest{} - } - if err := m.Pagination.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } + m.FpBtcPkHex = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex default: iNdEx = preIndex @@ -3991,7 +6755,7 @@ func (m *QueryListBlocksRequest) Unmarshal(dAtA []byte) error { } return nil } -func (m *QueryListBlocksResponse) Unmarshal(dAtA []byte) error { +func (m *EvidenceResponse) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -4014,17 +6778,17 @@ func (m *QueryListBlocksResponse) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: QueryListBlocksResponse: wiretype end group for non-group") + return fmt.Errorf("proto: EvidenceResponse: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: QueryListBlocksResponse: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: EvidenceResponse: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Blocks", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field FpBtcPkHex", wireType) } - var msglen int + var stringLen uint64 for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowQuery @@ -4034,31 +6798,48 @@ func (m *QueryListBlocksResponse) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - msglen |= int(b&0x7F) << shift + stringLen |= uint64(b&0x7F) << shift if b < 0x80 { break } } - if msglen < 0 { + intStringLen := int(stringLen) + if intStringLen < 0 { return ErrInvalidLengthQuery } - postIndex := iNdEx + msglen + postIndex := iNdEx + intStringLen if postIndex < 0 { return ErrInvalidLengthQuery } if postIndex > l { return io.ErrUnexpectedEOF } - m.Blocks = append(m.Blocks, &IndexedBlock{}) - if err := m.Blocks[len(m.Blocks)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } + m.FpBtcPkHex = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex case 2: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field BlockHeight", wireType) + } + m.BlockHeight = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.BlockHeight |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 3: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Pagination", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field PubRand", wireType) } - var msglen int + var byteLen int for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowQuery @@ -4068,83 +6849,32 @@ func (m *QueryListBlocksResponse) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - msglen |= int(b&0x7F) << shift + byteLen |= int(b&0x7F) << shift if b < 0x80 { break } } - if msglen < 0 { + if byteLen < 0 { return ErrInvalidLengthQuery } - postIndex := iNdEx + msglen + postIndex := iNdEx + byteLen if postIndex < 0 { return ErrInvalidLengthQuery } if postIndex > l { return io.ErrUnexpectedEOF } - if m.Pagination == nil { - m.Pagination = &query.PageResponse{} - } - if err := m.Pagination.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + var v github_com_babylonlabs_io_babylon_types.SchnorrPubRand + m.PubRand = &v + if err := m.PubRand.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 *QueryVotesAtHeightRequest) 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: QueryVotesAtHeightRequest: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: QueryVotesAtHeightRequest: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field Height", wireType) + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field CanonicalAppHash", wireType) } - m.Height = 0 + var byteLen int for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowQuery @@ -4154,64 +6884,29 @@ func (m *QueryVotesAtHeightRequest) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - m.Height |= uint64(b&0x7F) << shift + byteLen |= int(b&0x7F) << shift if b < 0x80 { break } } - 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 *QueryVotesAtHeightResponse) 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 { + if byteLen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { return io.ErrUnexpectedEOF } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break + m.CanonicalAppHash = append(m.CanonicalAppHash[:0], dAtA[iNdEx:postIndex]...) + if m.CanonicalAppHash == nil { + m.CanonicalAppHash = []byte{} } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: QueryVotesAtHeightResponse: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: QueryVotesAtHeightResponse: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: + iNdEx = postIndex + case 5: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field BtcPks", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field ForkAppHash", wireType) } var byteLen int for shift := uint(0); ; shift += 7 { @@ -4238,67 +6933,51 @@ func (m *QueryVotesAtHeightResponse) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - var v github_com_babylonlabs_io_babylon_types.BIP340PubKey - m.BtcPks = append(m.BtcPks, v) - if err := m.BtcPks[len(m.BtcPks)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err + m.ForkAppHash = append(m.ForkAppHash[:0], dAtA[iNdEx:postIndex]...) + if m.ForkAppHash == nil { + m.ForkAppHash = []byte{} } iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipQuery(dAtA[iNdEx:]) - if err != nil { - return err + case 6: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field CanonicalFinalitySig", wireType) } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthQuery + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF + if byteLen < 0 { + return ErrInvalidLengthQuery } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *QueryEvidenceRequest) 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 + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthQuery } - if iNdEx >= l { + if postIndex > l { return io.ErrUnexpectedEOF } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break + var v github_com_babylonlabs_io_babylon_types.SchnorrEOTSSig + m.CanonicalFinalitySig = &v + if err := m.CanonicalFinalitySig.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: QueryEvidenceRequest: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: QueryEvidenceRequest: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: + iNdEx = postIndex + case 7: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field FpBtcPkHex", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field ForkFinalitySig", wireType) } - var stringLen uint64 + var byteLen int for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowQuery @@ -4308,23 +6987,26 @@ func (m *QueryEvidenceRequest) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - stringLen |= uint64(b&0x7F) << shift + byteLen |= int(b&0x7F) << shift if b < 0x80 { break } } - intStringLen := int(stringLen) - if intStringLen < 0 { + if byteLen < 0 { return ErrInvalidLengthQuery } - postIndex := iNdEx + intStringLen + postIndex := iNdEx + byteLen if postIndex < 0 { return ErrInvalidLengthQuery } if postIndex > l { return io.ErrUnexpectedEOF } - m.FpBtcPkHex = string(dAtA[iNdEx:postIndex]) + var v github_com_babylonlabs_io_babylon_types.SchnorrEOTSSig + m.ForkFinalitySig = &v + if err := m.ForkFinalitySig.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } iNdEx = postIndex default: iNdEx = preIndex @@ -4406,7 +7088,7 @@ func (m *QueryEvidenceResponse) Unmarshal(dAtA []byte) error { return io.ErrUnexpectedEOF } if m.Evidence == nil { - m.Evidence = &Evidence{} + m.Evidence = &EvidenceResponse{} } if err := m.Evidence.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err @@ -4596,7 +7278,7 @@ func (m *QueryListEvidencesResponse) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.Evidences = append(m.Evidences, &Evidence{}) + m.Evidences = append(m.Evidences, &EvidenceResponse{}) if err := m.Evidences[len(m.Evidences)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } @@ -4740,6 +7422,159 @@ func (m *QuerySigningInfoRequest) Unmarshal(dAtA []byte) error { } return nil } +func (m *SigningInfoResponse) 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: SigningInfoResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: SigningInfoResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field FpBtcPkHex", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + 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 ErrInvalidLengthQuery + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.FpBtcPkHex = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field StartHeight", wireType) + } + m.StartHeight = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.StartHeight |= int64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 3: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field MissedBlocksCounter", wireType) + } + m.MissedBlocksCounter = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.MissedBlocksCounter |= int64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field JailedUntil", 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 err := github_com_cosmos_gogoproto_types.StdTimeUnmarshal(&m.JailedUntil, 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 *QuerySigningInfoResponse) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 @@ -4771,7 +7606,7 @@ func (m *QuerySigningInfoResponse) Unmarshal(dAtA []byte) error { switch fieldNum { case 1: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field FpSigningInfo", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field SigningInfo", wireType) } var msglen int for shift := uint(0); ; shift += 7 { @@ -4798,7 +7633,7 @@ func (m *QuerySigningInfoResponse) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - if err := m.FpSigningInfo.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + if err := m.SigningInfo.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } iNdEx = postIndex @@ -4940,7 +7775,7 @@ func (m *QuerySigningInfosResponse) Unmarshal(dAtA []byte) error { switch fieldNum { case 1: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field FpSigningInfos", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field SigningInfos", wireType) } var msglen int for shift := uint(0); ; shift += 7 { @@ -4967,8 +7802,8 @@ func (m *QuerySigningInfosResponse) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.FpSigningInfos = append(m.FpSigningInfos, FinalityProviderSigningInfo{}) - if err := m.FpSigningInfos[len(m.FpSigningInfos)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + m.SigningInfos = append(m.SigningInfos, SigningInfoResponse{}) + if err := m.SigningInfos[len(m.SigningInfos)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } iNdEx = postIndex diff --git a/x/finality/types/query.pb.gw.go b/x/finality/types/query.pb.gw.go index 6211809d2..d51945089 100644 --- a/x/finality/types/query.pb.gw.go +++ b/x/finality/types/query.pb.gw.go @@ -51,6 +51,226 @@ func local_request_Query_Params_0(ctx context.Context, marshaler runtime.Marshal } +var ( + filter_Query_ActiveFinalityProvidersAtHeight_0 = &utilities.DoubleArray{Encoding: map[string]int{"height": 0}, Base: []int{1, 1, 0}, Check: []int{0, 1, 2}} +) + +func request_Query_ActiveFinalityProvidersAtHeight_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryActiveFinalityProvidersAtHeightRequest + var metadata runtime.ServerMetadata + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["height"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "height") + } + + protoReq.Height, err = runtime.Uint64(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "height", err) + } + + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_ActiveFinalityProvidersAtHeight_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + msg, err := client.ActiveFinalityProvidersAtHeight(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_Query_ActiveFinalityProvidersAtHeight_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryActiveFinalityProvidersAtHeightRequest + var metadata runtime.ServerMetadata + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["height"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "height") + } + + protoReq.Height, err = runtime.Uint64(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "height", err) + } + + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_ActiveFinalityProvidersAtHeight_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + msg, err := server.ActiveFinalityProvidersAtHeight(ctx, &protoReq) + return msg, metadata, err + +} + +func request_Query_FinalityProviderPowerAtHeight_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryFinalityProviderPowerAtHeightRequest + var metadata runtime.ServerMetadata + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["fp_btc_pk_hex"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "fp_btc_pk_hex") + } + + protoReq.FpBtcPkHex, err = runtime.String(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "fp_btc_pk_hex", err) + } + + val, ok = pathParams["height"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "height") + } + + protoReq.Height, err = runtime.Uint64(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "height", err) + } + + msg, err := client.FinalityProviderPowerAtHeight(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_Query_FinalityProviderPowerAtHeight_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryFinalityProviderPowerAtHeightRequest + var metadata runtime.ServerMetadata + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["fp_btc_pk_hex"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "fp_btc_pk_hex") + } + + protoReq.FpBtcPkHex, err = runtime.String(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "fp_btc_pk_hex", err) + } + + val, ok = pathParams["height"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "height") + } + + protoReq.Height, err = runtime.Uint64(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "height", err) + } + + msg, err := server.FinalityProviderPowerAtHeight(ctx, &protoReq) + return msg, metadata, err + +} + +func request_Query_FinalityProviderCurrentPower_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryFinalityProviderCurrentPowerRequest + var metadata runtime.ServerMetadata + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["fp_btc_pk_hex"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "fp_btc_pk_hex") + } + + protoReq.FpBtcPkHex, err = runtime.String(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "fp_btc_pk_hex", err) + } + + msg, err := client.FinalityProviderCurrentPower(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_Query_FinalityProviderCurrentPower_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryFinalityProviderCurrentPowerRequest + var metadata runtime.ServerMetadata + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["fp_btc_pk_hex"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "fp_btc_pk_hex") + } + + protoReq.FpBtcPkHex, err = runtime.String(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "fp_btc_pk_hex", err) + } + + msg, err := server.FinalityProviderCurrentPower(ctx, &protoReq) + return msg, metadata, err + +} + +func request_Query_ActivatedHeight_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryActivatedHeightRequest + var metadata runtime.ServerMetadata + + msg, err := client.ActivatedHeight(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_Query_ActivatedHeight_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryActivatedHeightRequest + var metadata runtime.ServerMetadata + + msg, err := server.ActivatedHeight(ctx, &protoReq) + return msg, metadata, err + +} + var ( filter_Query_ListPublicRandomness_0 = &utilities.DoubleArray{Encoding: map[string]int{"fp_btc_pk_hex": 0}, Base: []int{1, 1, 0}, Check: []int{0, 1, 2}} ) @@ -548,6 +768,98 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv }) + mux.Handle("GET", pattern_Query_ActiveFinalityProvidersAtHeight_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_Query_ActiveFinalityProvidersAtHeight_0(rctx, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Query_ActiveFinalityProvidersAtHeight_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("GET", pattern_Query_FinalityProviderPowerAtHeight_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_Query_FinalityProviderPowerAtHeight_0(rctx, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Query_FinalityProviderPowerAtHeight_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("GET", pattern_Query_FinalityProviderCurrentPower_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_Query_FinalityProviderCurrentPower_0(rctx, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Query_FinalityProviderCurrentPower_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("GET", pattern_Query_ActivatedHeight_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_Query_ActivatedHeight_0(rctx, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Query_ActivatedHeight_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + mux.Handle("GET", pattern_Query_ListPublicRandomness_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() @@ -816,6 +1128,86 @@ func RegisterQueryHandlerClient(ctx context.Context, mux *runtime.ServeMux, clie }) + mux.Handle("GET", pattern_Query_ActiveFinalityProvidersAtHeight_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_Query_ActiveFinalityProvidersAtHeight_0(rctx, inboundMarshaler, client, req, pathParams) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Query_ActiveFinalityProvidersAtHeight_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("GET", pattern_Query_FinalityProviderPowerAtHeight_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_Query_FinalityProviderPowerAtHeight_0(rctx, inboundMarshaler, client, req, pathParams) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Query_FinalityProviderPowerAtHeight_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("GET", pattern_Query_FinalityProviderCurrentPower_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_Query_FinalityProviderCurrentPower_0(rctx, inboundMarshaler, client, req, pathParams) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Query_FinalityProviderCurrentPower_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("GET", pattern_Query_ActivatedHeight_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_Query_ActivatedHeight_0(rctx, inboundMarshaler, client, req, pathParams) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Query_ActivatedHeight_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + mux.Handle("GET", pattern_Query_ListPublicRandomness_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() @@ -1002,6 +1394,14 @@ func RegisterQueryHandlerClient(ctx context.Context, mux *runtime.ServeMux, clie var ( pattern_Query_Params_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"babylon", "finality", "v1", "params"}, "", runtime.AssumeColonVerbOpt(false))) + pattern_Query_ActiveFinalityProvidersAtHeight_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 1, 0, 4, 1, 5, 4}, []string{"babylon", "finality", "v1", "finality_providers", "height"}, "", runtime.AssumeColonVerbOpt(false))) + + pattern_Query_FinalityProviderPowerAtHeight_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 1, 0, 4, 1, 5, 4, 2, 5, 1, 0, 4, 1, 5, 6}, []string{"babylon", "finality", "v1", "finality_providers", "fp_btc_pk_hex", "power", "height"}, "", runtime.AssumeColonVerbOpt(false))) + + pattern_Query_FinalityProviderCurrentPower_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 1, 0, 4, 1, 5, 4, 2, 5}, []string{"babylon", "finality", "v1", "finality_providers", "fp_btc_pk_hex", "power"}, "", runtime.AssumeColonVerbOpt(false))) + + pattern_Query_ActivatedHeight_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"babylon", "finality", "v1", "activated_height"}, "", runtime.AssumeColonVerbOpt(false))) + pattern_Query_ListPublicRandomness_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 1, 0, 4, 1, 5, 4, 2, 5}, []string{"babylon", "finality", "v1", "finality_providers", "fp_btc_pk_hex", "public_randomness_list"}, "", runtime.AssumeColonVerbOpt(false))) pattern_Query_ListPubRandCommit_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 1, 0, 4, 1, 5, 4, 2, 5}, []string{"babylon", "finality", "v1", "finality_providers", "fp_btc_pk_hex", "pub_rand_commit_list"}, "", runtime.AssumeColonVerbOpt(false))) @@ -1024,6 +1424,14 @@ var ( var ( forward_Query_Params_0 = runtime.ForwardResponseMessage + forward_Query_ActiveFinalityProvidersAtHeight_0 = runtime.ForwardResponseMessage + + forward_Query_FinalityProviderPowerAtHeight_0 = runtime.ForwardResponseMessage + + forward_Query_FinalityProviderCurrentPower_0 = runtime.ForwardResponseMessage + + forward_Query_ActivatedHeight_0 = runtime.ForwardResponseMessage + forward_Query_ListPublicRandomness_0 = runtime.ForwardResponseMessage forward_Query_ListPubRandCommit_0 = runtime.ForwardResponseMessage diff --git a/x/incentive/abci.go b/x/incentive/abci.go index 7967e1f43..0b2dd1c5b 100644 --- a/x/incentive/abci.go +++ b/x/incentive/abci.go @@ -17,7 +17,6 @@ func BeginBlocker(ctx context.Context, k keeper.Keeper) error { // handle coins in the fee collector account, including // - send a portion of coins in the fee collector account to the incentive module account // - accumulate BTC staking gauge at the current height - // - accumulate BTC timestamping gauge at the current epoch if sdk.UnwrapSDKContext(ctx).HeaderInfo().Height > 0 { k.HandleCoinsInFeeCollector(ctx) } diff --git a/x/incentive/client/cli/query.go b/x/incentive/client/cli/query.go index 7831a6d71..05fcc200c 100644 --- a/x/incentive/client/cli/query.go +++ b/x/incentive/client/cli/query.go @@ -25,7 +25,6 @@ func GetQueryCmd(queryRoute string) *cobra.Command { CmdQueryParams(), CmdQueryRewardGauges(), CmdQueryBTCStakingGauge(), - CmdQueryBTCTimestampingGauge(), ) return cmd @@ -95,38 +94,3 @@ func CmdQueryBTCStakingGauge() *cobra.Command { return cmd } - -func CmdQueryBTCTimestampingGauge() *cobra.Command { - cmd := &cobra.Command{ - Use: "btc-timestamping-gauge [epoch]", - Short: "shows BTC timestamping gauge of a given epoch", - Args: cobra.ExactArgs(1), - RunE: func(cmd *cobra.Command, args []string) error { - clientCtx, err := client.GetClientQueryContext(cmd) - if err != nil { - return err - } - - epoch, err := strconv.ParseUint(args[0], 10, 64) - if err != nil { - return err - } - - queryClient := types.NewQueryClient(clientCtx) - - req := &types.QueryBTCTimestampingGaugeRequest{ - EpochNum: epoch, - } - res, err := queryClient.BTCTimestampingGauge(cmd.Context(), req) - if err != nil { - return err - } - - return clientCtx.PrintProto(res) - }, - } - - flags.AddQueryFlagsToCmd(cmd) - - return cmd -} diff --git a/x/incentive/client/cli/tx.go b/x/incentive/client/cli/tx.go index b3f12788d..83c56bf95 100644 --- a/x/incentive/client/cli/tx.go +++ b/x/incentive/client/cli/tx.go @@ -2,6 +2,7 @@ package cli import ( "fmt" + "github.com/spf13/cobra" "github.com/babylonlabs-io/babylon/x/incentive/types" @@ -30,7 +31,7 @@ func GetTxCmd() *cobra.Command { func NewWithdrawRewardCmd() *cobra.Command { cmd := &cobra.Command{ Use: "withdraw-reward [type]", - Short: "withdraw reward of the stakeholder behind the transaction submitter in a given type (one of {submitter, reporter, finality_provider, btc_delegation})", + Short: "withdraw reward of the stakeholder behind the transaction submitter in a given type (one of {finality_provider, btc_delegation})", Args: cobra.ExactArgs(1), RunE: func(cmd *cobra.Command, args []string) error { clientCtx, err := client.GetClientTxContext(cmd) diff --git a/x/incentive/keeper/btc_staking_gauge.go b/x/incentive/keeper/btc_staking_gauge.go index 4992ef782..a8ad38f33 100644 --- a/x/incentive/keeper/btc_staking_gauge.go +++ b/x/incentive/keeper/btc_staking_gauge.go @@ -4,7 +4,7 @@ import ( "context" "cosmossdk.io/store/prefix" - bstypes "github.com/babylonlabs-io/babylon/x/btcstaking/types" + ftypes "github.com/babylonlabs-io/babylon/x/finality/types" "github.com/babylonlabs-io/babylon/x/incentive/types" "github.com/cosmos/cosmos-sdk/runtime" sdk "github.com/cosmos/cosmos-sdk/types" @@ -13,16 +13,23 @@ import ( // RewardBTCStaking distributes rewards to finality providers/delegations at a given height according // to the filtered reward distribution cache (that only contains voted finality providers) // (adapted from https://github.com/cosmos/cosmos-sdk/blob/release/v0.47.x/x/distribution/keeper/allocation.go#L12-L64) -func (k Keeper) RewardBTCStaking(ctx context.Context, height uint64, filteredDc *bstypes.VotingPowerDistCache) { +func (k Keeper) RewardBTCStaking(ctx context.Context, height uint64, dc *ftypes.VotingPowerDistCache) { gauge := k.GetBTCStakingGauge(ctx, height) if gauge == nil { // failing to get a reward gauge at previous height is a programming error panic("failed to get a reward gauge at previous height") } // reward each of the finality provider and its BTC delegations in proportion - for _, fp := range filteredDc.FinalityProviders { + for i, fp := range dc.FinalityProviders { + // only reward the first NumActiveFps finality providers + // note that ApplyActiveFinalityProviders is called before saving `dc` + // in DB so that the top dc.NumActiveFps ones in dc.FinalityProviders + // are the active finality providers + if i >= int(dc.NumActiveFps) { + break + } // get coins that will be allocated to the finality provider and its BTC delegations - fpPortion := filteredDc.GetFinalityProviderPortion(fp) + fpPortion := dc.GetFinalityProviderPortion(fp) coinsForFpsAndDels := gauge.GetCoinsPortion(fpPortion) // reward the finality provider with commission coinsForCommission := types.GetCoinsPortion(coinsForFpsAndDels, *fp.Commission) @@ -35,8 +42,6 @@ func (k Keeper) RewardBTCStaking(ctx context.Context, height uint64, filteredDc k.accumulateRewardGauge(ctx, types.BTCDelegationType, btcDel.GetAddress(), coinsForDel) } } - - // TODO: handle the change in the gauge due to the truncating operations } func (k Keeper) accumulateBTCStakingReward(ctx context.Context, btcStakingReward sdk.Coins) { diff --git a/x/incentive/keeper/btc_timestamping_gauge.go b/x/incentive/keeper/btc_timestamping_gauge.go deleted file mode 100644 index d4ed4f01d..000000000 --- a/x/incentive/keeper/btc_timestamping_gauge.go +++ /dev/null @@ -1,121 +0,0 @@ -package keeper - -import ( - "context" - "cosmossdk.io/math" - "cosmossdk.io/store/prefix" - btcctypes "github.com/babylonlabs-io/babylon/x/btccheckpoint/types" - "github.com/babylonlabs-io/babylon/x/incentive/types" - "github.com/cosmos/cosmos-sdk/runtime" - sdk "github.com/cosmos/cosmos-sdk/types" -) - -// RewardBTCTimestamping distributes rewards to submitters/reporters of a checkpoint at a given epoch -// according to the reward distribution cache -func (k Keeper) RewardBTCTimestamping(ctx context.Context, epoch uint64, rdi *btcctypes.RewardDistInfo) { - gauge := k.GetBTCTimestampingGauge(ctx, epoch) - if gauge == nil { - // failing to get a reward gauge at a finalised epoch is a programming error - panic("failed to get a reward gauge at a finalized epoch") - } - - params := k.GetParams(ctx) - btcTimestampingPortion := params.BTCTimestampingPortion() - // TODO: parameterise bestPortion - bestPortion := math.LegacyNewDecWithPrec(80, 2) // 80 * 10^{-2} = 0.8 - - // distribute coins to best submitter - submitterPortion := params.SubmitterPortion.QuoTruncate(btcTimestampingPortion) - coinsToSubmitters := gauge.GetCoinsPortion(submitterPortion) - coinsToBestSubmitter := types.GetCoinsPortion(coinsToSubmitters, bestPortion) - k.accumulateRewardGauge(ctx, types.SubmitterType, rdi.Best.Submitter, coinsToBestSubmitter) - restCoinsToSubmitters := coinsToSubmitters.Sub(coinsToBestSubmitter...) - - // distribute coins to best reporter - reporterPortion := params.ReporterPortion.QuoTruncate(btcTimestampingPortion) - coinsToReporters := gauge.GetCoinsPortion(reporterPortion) - coinsToBestReporter := types.GetCoinsPortion(coinsToReporters, bestPortion) - k.accumulateRewardGauge(ctx, types.ReporterType, rdi.Best.Reporter, coinsToBestReporter) - restCoinsToReporters := coinsToReporters.Sub(coinsToBestReporter...) - - // if there is only 1 submission, distribute the rest to submitter and reporter, then skip the rest logic - if len(rdi.Others) == 0 { - // give rest coins to the best submitter - k.accumulateRewardGauge(ctx, types.SubmitterType, rdi.Best.Submitter, restCoinsToSubmitters) - // give rest coins to the best reporter - k.accumulateRewardGauge(ctx, types.ReporterType, rdi.Best.Reporter, restCoinsToReporters) - // skip the rest logic - return - } - - // distribute the rest to each of the other submitters - // TODO: our tokenomics might specify weights for the rest submitters in the future - eachOtherSubmitterPortion := math.LegacyOneDec().QuoTruncate(math.LegacyOneDec().MulInt64(int64(len(rdi.Others)))) - coinsToEachOtherSubmitter := types.GetCoinsPortion(restCoinsToSubmitters, eachOtherSubmitterPortion) - if coinsToEachOtherSubmitter.IsAllPositive() { - for _, submission := range rdi.Others { - k.accumulateRewardGauge(ctx, types.SubmitterType, submission.Submitter, coinsToEachOtherSubmitter) - } - } - - // distribute the rest to each of the other reporters - // TODO: our tokenomics might specify weights for the rest reporters in the future - eachOtherReporterPortion := math.LegacyOneDec().QuoTruncate(math.LegacyOneDec().MulInt64(int64(len(rdi.Others)))) - coinsToEachOtherReporter := types.GetCoinsPortion(restCoinsToReporters, eachOtherReporterPortion) - if coinsToEachOtherReporter.IsAllPositive() { - for _, submission := range rdi.Others { - k.accumulateRewardGauge(ctx, types.ReporterType, submission.Reporter, coinsToEachOtherReporter) - } - } -} - -func (k Keeper) accumulateBTCTimestampingReward(ctx context.Context, btcTimestampingReward sdk.Coins) { - epoch := k.epochingKeeper.GetEpoch(ctx) - - // update BTC timestamping reward gauge - gauge := k.GetBTCTimestampingGauge(ctx, epoch.EpochNumber) - if gauge == nil { - // if this epoch does not have a gauge yet, create a new one - gauge = types.NewGauge(btcTimestampingReward...) - } else { - // if this epoch already has a gauge, accumulate coins in the gauge - gauge.Coins = gauge.Coins.Add(btcTimestampingReward...) - } - - k.SetBTCTimestampingGauge(ctx, epoch.EpochNumber, gauge) - - // transfer the BTC timestamping reward from fee collector account to incentive module account - err := k.bankKeeper.SendCoinsFromModuleToModule(ctx, k.feeCollectorName, types.ModuleName, btcTimestampingReward) - if err != nil { - // this can only be programming error and is unrecoverable - panic(err) - } -} - -func (k Keeper) SetBTCTimestampingGauge(ctx context.Context, epoch uint64, gauge *types.Gauge) { - store := k.btcTimestampingGaugeStore(ctx) - gaugeBytes := k.cdc.MustMarshal(gauge) - store.Set(sdk.Uint64ToBigEndian(epoch), gaugeBytes) -} - -func (k Keeper) GetBTCTimestampingGauge(ctx context.Context, epoch uint64) *types.Gauge { - store := k.btcTimestampingGaugeStore(ctx) - gaugeBytes := store.Get(sdk.Uint64ToBigEndian(epoch)) - if gaugeBytes == nil { - return nil - } - - var gauge types.Gauge - k.cdc.MustUnmarshal(gaugeBytes, &gauge) - return &gauge -} - -// btcTimestampingGaugeStore returns the KVStore of the gauge of total reward for -// BTC timestamping at each epoch -// prefix: BTCTimestampingGaugeKey -// key: epoch number -// value: gauge of rewards for BTC timestamping at this epoch -func (k Keeper) btcTimestampingGaugeStore(ctx context.Context) prefix.Store { - storeAdaptor := runtime.KVStoreAdapter(k.storeService.OpenKVStore(ctx)) - return prefix.NewStore(storeAdaptor, types.BTCTimestampingGaugeKey) -} diff --git a/x/incentive/keeper/btc_timestamping_gauge_test.go b/x/incentive/keeper/btc_timestamping_gauge_test.go deleted file mode 100644 index 84d962b65..000000000 --- a/x/incentive/keeper/btc_timestamping_gauge_test.go +++ /dev/null @@ -1,123 +0,0 @@ -package keeper_test - -import ( - "math/rand" - "testing" - - "cosmossdk.io/math" - "github.com/babylonlabs-io/babylon/testutil/datagen" - testkeeper "github.com/babylonlabs-io/babylon/testutil/keeper" - "github.com/babylonlabs-io/babylon/x/incentive/types" - sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/golang/mock/gomock" - "github.com/stretchr/testify/require" -) - -func FuzzRewardBTCTimestamping(f *testing.F) { - datagen.AddRandomSeedsToFuzzer(f, 10) - f.Fuzz(func(t *testing.T, seed int64) { - r := rand.New(rand.NewSource(seed)) - - ctrl := gomock.NewController(t) - defer ctrl.Finish() - - // mock bank keeper - bankKeeper := types.NewMockBankKeeper(ctrl) - - // create incentive keeper - keeper, ctx := testkeeper.IncentiveKeeper(t, bankKeeper, nil, nil) - epoch := datagen.RandomInt(r, 1000) + 1 - - // set a random gauge - gauge := datagen.GenRandomGauge(r) - keeper.SetBTCTimestampingGauge(ctx, epoch, gauge) - - // generate a random BTC timestamping reward distribution info - rdi := datagen.GenRandomBTCTimestampingRewardDistInfo(r) - - // parameters - params := types.DefaultParams() - btcTimestampingPortion := params.BTCTimestampingPortion() - bestPortion := math.LegacyNewDecWithPrec(80, 2) // 80 * 10^{-2} = 0.8 - - // expected values - distributedCoins := sdk.NewCoins() - submitterRewardMap := map[string]sdk.Coins{} // key: address, value: reward - reporterRewardMap := map[string]sdk.Coins{} // key: address, value: reward - - submitterPortion := params.SubmitterPortion.QuoTruncate(btcTimestampingPortion) - coinsToSubmitters := gauge.GetCoinsPortion(submitterPortion) - coinsToBestSubmitter := types.GetCoinsPortion(coinsToSubmitters, bestPortion) - if coinsToBestSubmitter.IsAllPositive() { - submitterRewardMap[rdi.Best.Submitter.String()] = coinsToBestSubmitter - distributedCoins.Add(coinsToBestSubmitter...) - } - // best reporter - reporterPortion := params.ReporterPortion.QuoTruncate(btcTimestampingPortion) - coinsToReporters := gauge.GetCoinsPortion(reporterPortion) - coinsToBestReporter := types.GetCoinsPortion(coinsToReporters, bestPortion) - if coinsToBestReporter.IsAllPositive() { - reporterRewardMap[rdi.Best.Reporter.String()] = coinsToBestReporter - distributedCoins.Add(coinsToBestReporter...) - } - // other submitters and reporters - if len(rdi.Others) > 0 { - // other submitters - coinsToOtherSubmitters := coinsToSubmitters.Sub(coinsToBestSubmitter...) - eachOtherSubmitterPortion := math.LegacyOneDec().QuoTruncate(math.LegacyOneDec().MulInt64(int64(len(rdi.Others)))) - coinsToEachOtherSubmitter := types.GetCoinsPortion(coinsToOtherSubmitters, eachOtherSubmitterPortion) - if coinsToEachOtherSubmitter.IsAllPositive() { - for _, submission := range rdi.Others { - submitterRewardMap[submission.Submitter.String()] = coinsToEachOtherSubmitter - distributedCoins.Add(coinsToEachOtherSubmitter...) - } - } - // other reporters - coinsToOtherReporters := coinsToReporters.Sub(coinsToBestReporter...) - eachOtherReporterPortion := math.LegacyOneDec().QuoTruncate(math.LegacyOneDec().MulInt64(int64(len(rdi.Others)))) - coinsToEachOtherReporter := types.GetCoinsPortion(coinsToOtherReporters, eachOtherReporterPortion) - if coinsToEachOtherReporter.IsAllPositive() { - for _, submission := range rdi.Others { - reporterRewardMap[submission.Reporter.String()] = coinsToEachOtherReporter - distributedCoins.Add(coinsToEachOtherReporter...) - } - } - } else { - // no other submission. give rest coins to best submitter/reporter - // give rest coins to the best submitter - restCoinsToSubmitter := coinsToSubmitters.Sub(coinsToBestSubmitter...) - if restCoinsToSubmitter.IsAllPositive() { - submitterRewardMap[rdi.Best.Submitter.String()] = submitterRewardMap[rdi.Best.Submitter.String()].Add(restCoinsToSubmitter...) - distributedCoins.Add(restCoinsToSubmitter...) - } - // give rest coins to the best reporter - restCoinsToReporter := coinsToReporters.Sub(coinsToBestReporter...) - if restCoinsToReporter.IsAllPositive() { - reporterRewardMap[rdi.Best.Reporter.String()] = reporterRewardMap[rdi.Best.Reporter.String()].Add(restCoinsToSubmitter...) - distributedCoins.Add(restCoinsToReporter...) - } - } - - // distribute rewards in the gauge to reporters/submitters - keeper.RewardBTCTimestamping(ctx, epoch, rdi) - - // assert consistency between reward map and reward gauge - for addrStr, reward := range submitterRewardMap { - addr, err := sdk.AccAddressFromBech32(addrStr) - require.NoError(t, err) - rg := keeper.GetRewardGauge(ctx, types.SubmitterType, addr) - require.NotNil(t, rg) - require.Equal(t, reward, rg.Coins) - } - for addrStr, reward := range reporterRewardMap { - addr, err := sdk.AccAddressFromBech32(addrStr) - require.NoError(t, err) - rg := keeper.GetRewardGauge(ctx, types.ReporterType, addr) - require.NotNil(t, rg) - require.Equal(t, reward, rg.Coins) - } - - // assert distributedCoins is a subset of coins in gauge - require.True(t, gauge.Coins.IsAllGTE(distributedCoins)) - }) -} diff --git a/x/incentive/keeper/grpc_query.go b/x/incentive/keeper/grpc_query.go index 3f1274d3b..a526fdc47 100644 --- a/x/incentive/keeper/grpc_query.go +++ b/x/incentive/keeper/grpc_query.go @@ -39,7 +39,7 @@ func (k Keeper) RewardGauges(goCtx context.Context, req *types.QueryRewardGauges return nil, types.ErrRewardGaugeNotFound } - return &types.QueryRewardGaugesResponse{RewardGauges: rgMap}, nil + return &types.QueryRewardGaugesResponse{RewardGauges: convertToRewardGaugesResponse(rgMap)}, nil } func (k Keeper) BTCStakingGauge(goCtx context.Context, req *types.QueryBTCStakingGaugeRequest) (*types.QueryBTCStakingGaugeResponse, error) { @@ -54,20 +54,22 @@ func (k Keeper) BTCStakingGauge(goCtx context.Context, req *types.QueryBTCStakin return nil, types.ErrBTCStakingGaugeNotFound } - return &types.QueryBTCStakingGaugeResponse{Gauge: gauge}, nil + return &types.QueryBTCStakingGaugeResponse{Gauge: convertGaugeToBTCStakingResponse(*gauge)}, nil } -func (k Keeper) BTCTimestampingGauge(goCtx context.Context, req *types.QueryBTCTimestampingGaugeRequest) (*types.QueryBTCTimestampingGaugeResponse, error) { - if req == nil { - return nil, status.Error(codes.InvalidArgument, "invalid request") +func convertGaugeToBTCStakingResponse(gauge types.Gauge) *types.BTCStakingGaugeResponse { + return &types.BTCStakingGaugeResponse{ + Coins: gauge.Coins, } - ctx := sdk.UnwrapSDKContext(goCtx) +} - // find gauge - gauge := k.GetBTCTimestampingGauge(ctx, req.EpochNum) - if gauge == nil { - return nil, types.ErrBTCTimestampingGaugeNotFound +func convertToRewardGaugesResponse(rgMap map[string]*types.RewardGauge) map[string]*types.RewardGaugesResponse { + rewardGuagesResponse := make(map[string]*types.RewardGaugesResponse) + for stakeholderType, rg := range rgMap { + rewardGuagesResponse[stakeholderType] = &types.RewardGaugesResponse{ + Coins: rg.Coins, + WithdrawnCoins: rg.WithdrawnCoins, + } } - - return &types.QueryBTCTimestampingGaugeResponse{Gauge: gauge}, nil + return rewardGuagesResponse } diff --git a/x/incentive/keeper/grpc_query_test.go b/x/incentive/keeper/grpc_query_test.go index 048a7ad55..cd2dc12d5 100644 --- a/x/incentive/keeper/grpc_query_test.go +++ b/x/incentive/keeper/grpc_query_test.go @@ -20,17 +20,20 @@ func FuzzRewardGaugesQuery(f *testing.F) { // generate a list of random RewardGauge map and insert them to KVStore // where in each map, key is stakeholder type and address is the reward gauge - rgMaps := []map[string]*types.RewardGauge{} + rgMaps := []map[string]*types.RewardGaugesResponse{} sAddrList := []sdk.AccAddress{} numRgMaps := datagen.RandomInt(r, 100) for i := uint64(0); i < numRgMaps; i++ { - rgMap := map[string]*types.RewardGauge{} + rgMap := map[string]*types.RewardGaugesResponse{} sAddr := datagen.GenRandomAccount().GetAddress() sAddrList = append(sAddrList, sAddr) for i := uint64(0); i <= datagen.RandomInt(r, 4); i++ { sType := datagen.GenRandomStakeholderType(r) rg := datagen.GenRandomRewardGauge(r) - rgMap[sType.String()] = rg + rgMap[sType.String()] = &types.RewardGaugesResponse{ + Coins: rg.Coins, + WithdrawnCoins: rg.WithdrawnCoins, + } keeper.SetRewardGauge(ctx, sType, sAddr, rg) } @@ -83,43 +86,3 @@ func FuzzBTCStakingGaugeQuery(f *testing.F) { } }) } - -func FuzzBTCTimestampingGaugeQuery(f *testing.F) { - datagen.AddRandomSeedsToFuzzer(f, 10) - f.Fuzz(func(t *testing.T, seed int64) { - r := rand.New(rand.NewSource(seed)) - - keeper, ctx := testkeeper.IncentiveKeeper(t, nil, nil, nil) - - // initialise the 1st gauge - epochList := []uint64{datagen.RandomInt(r, 1000) + 1} - gaugeList := []*types.Gauge{datagen.GenRandomGauge(r)} - keeper.SetBTCTimestampingGauge(ctx, epochList[0], gaugeList[0]) - - // generate a list of random gauges at random heights, then insert them to KVStore - numGauges := datagen.RandomInt(r, 100) + 1 - for i := uint64(1); i < numGauges; i++ { - // increment a random number of epochs - epoch := epochList[i-1] + datagen.RandomInt(r, 1000) + 1 - epochList = append(epochList, epoch) - gauge := datagen.GenRandomGauge(r) - gaugeList = append(gaugeList, gauge) - keeper.SetBTCTimestampingGauge(ctx, epoch, gauge) - } - - // query existence and assert consistency - for i := range gaugeList { - req := &types.QueryBTCTimestampingGaugeRequest{ - EpochNum: epochList[i], - } - resp, err := keeper.BTCTimestampingGauge(ctx, req) - require.NoError(t, err) - require.True(t, resp.Gauge.Coins.Equal(gaugeList[i].Coins), - "epoch: %d\nresp.Gauge.Coins: %s\ngaugeList[i].Coins: %s\n", - epochList[i], - resp.Gauge.Coins.Sort().String(), - gaugeList[i].Coins.Sort().String(), - ) - } - }) -} diff --git a/x/incentive/keeper/intercept_fee_collector.go b/x/incentive/keeper/intercept_fee_collector.go index 05cc6c5be..2930b3c47 100644 --- a/x/incentive/keeper/intercept_fee_collector.go +++ b/x/incentive/keeper/intercept_fee_collector.go @@ -2,11 +2,12 @@ package keeper import ( "context" + "github.com/babylonlabs-io/babylon/x/incentive/types" ) // HandleCoinsInFeeCollector intercepts a portion of coins in fee collector, and distributes -// them to BTC staking gauge and BTC timestamping gauge of the current height and epoch, respectively. +// them to BTC staking gauge of the current height. // It is invoked upon every `BeginBlock`. // adapted from https://github.com/cosmos/cosmos-sdk/blob/release/v0.47.x/x/distribution/keeper/allocation.go#L15-L26 func (k Keeper) HandleCoinsInFeeCollector(ctx context.Context) { @@ -31,10 +32,4 @@ func (k Keeper) HandleCoinsInFeeCollector(ctx context.Context) { btcStakingPortion := params.BTCStakingPortion() btcStakingReward := types.GetCoinsPortion(feesCollectedInt, btcStakingPortion) k.accumulateBTCStakingReward(ctx, btcStakingReward) - - // record BTC timestamping gauge for the current epoch, and transfer corresponding amount - // from fee collector account to incentive module account - btcTimestampingPortion := params.BTCTimestampingPortion() - btcTimestampingReward := types.GetCoinsPortion(feesCollectedInt, btcTimestampingPortion) - k.accumulateBTCTimestampingReward(ctx, btcTimestampingReward) } diff --git a/x/incentive/keeper/intercept_fee_collector_test.go b/x/incentive/keeper/intercept_fee_collector_test.go index 2f583caa2..78a66a8f1 100644 --- a/x/incentive/keeper/intercept_fee_collector_test.go +++ b/x/incentive/keeper/intercept_fee_collector_test.go @@ -8,7 +8,6 @@ import ( "github.com/babylonlabs-io/babylon/testutil/datagen" testkeeper "github.com/babylonlabs-io/babylon/testutil/keeper" - epochingtypes "github.com/babylonlabs-io/babylon/x/epoching/types" "github.com/babylonlabs-io/babylon/x/incentive/types" sdk "github.com/cosmos/cosmos-sdk/types" authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" @@ -38,9 +37,7 @@ func FuzzInterceptFeeCollector(f *testing.F) { accountKeeper.EXPECT().GetModuleAccount(gomock.Any(), authtypes.FeeCollectorName).Return(feeCollectorAcc).Times(1) // mock epoching keeper - epochNum := datagen.RandomInt(r, 100) + 1 epochingKeeper := types.NewMockEpochingKeeper(ctrl) - epochingKeeper.EXPECT().GetEpoch(gomock.Any()).Return(&epochingtypes.Epoch{EpochNumber: epochNum}).Times(1) keeper, ctx := testkeeper.IncentiveKeeper(t, bankKeeper, accountKeeper, epochingKeeper) height := datagen.RandomInt(r, 1000) @@ -50,9 +47,7 @@ func FuzzInterceptFeeCollector(f *testing.F) { // NOTE: if the actual fees are different from feesForIncentive the test will fail params := keeper.GetParams(ctx) feesForBTCStaking := types.GetCoinsPortion(fees, params.BTCStakingPortion()) - feesForBTCTimestamping := types.GetCoinsPortion(fees, params.BTCTimestampingPortion()) bankKeeper.EXPECT().SendCoinsFromModuleToModule(gomock.Any(), gomock.Eq(authtypes.FeeCollectorName), gomock.Eq(types.ModuleName), gomock.Eq(feesForBTCStaking)).Times(1) - bankKeeper.EXPECT().SendCoinsFromModuleToModule(gomock.Any(), gomock.Eq(authtypes.FeeCollectorName), gomock.Eq(types.ModuleName), gomock.Eq(feesForBTCTimestamping)).Times(1) // handle coins in fee collector keeper.HandleCoinsInFeeCollector(ctx) @@ -62,30 +57,5 @@ func FuzzInterceptFeeCollector(f *testing.F) { btcStakingGauge := keeper.GetBTCStakingGauge(ctx, height) require.NotNil(t, btcStakingGauge) require.Equal(t, btcStakingFee, btcStakingGauge.Coins) - - // assert correctness of BTC timestamping gauge at epoch - btcTimestampingFee := types.GetCoinsPortion(fees, params.BTCTimestampingPortion()) - btcTimestampingGauge := keeper.GetBTCTimestampingGauge(ctx, epochNum) - require.NotNil(t, btcTimestampingGauge) - require.Equal(t, btcTimestampingFee, btcTimestampingGauge.Coins) - - // accumulate for this epoch again and see if the epoch's BTC timestamping gauge has accumulated or not - height += 1 - ctx = datagen.WithCtxHeight(ctx, height) - bankKeeper.EXPECT().GetAllBalances(gomock.Any(), feeCollectorAcc.GetAddress()).Return(fees).Times(1) - accountKeeper.EXPECT().GetModuleAccount(gomock.Any(), authtypes.FeeCollectorName).Return(feeCollectorAcc).Times(1) - epochingKeeper.EXPECT().GetEpoch(gomock.Any()).Return(&epochingtypes.Epoch{EpochNumber: epochNum}).Times(1) - bankKeeper.EXPECT().SendCoinsFromModuleToModule(gomock.Any(), gomock.Eq(authtypes.FeeCollectorName), gomock.Eq(types.ModuleName), gomock.Eq(feesForBTCStaking)).Times(1) - bankKeeper.EXPECT().SendCoinsFromModuleToModule(gomock.Any(), gomock.Eq(authtypes.FeeCollectorName), gomock.Eq(types.ModuleName), gomock.Eq(feesForBTCTimestamping)).Times(1) - // handle coins in fee collector - keeper.HandleCoinsInFeeCollector(ctx) - // assert BTC timestamping gauge has doubled - btcTimestampingGauge2 := keeper.GetBTCTimestampingGauge(ctx, epochNum) - require.NotNil(t, btcTimestampingGauge2) - for i := range btcTimestampingGauge.Coins { - amount := btcTimestampingGauge.Coins[i].Amount.Uint64() - amount2 := btcTimestampingGauge2.Coins[i].Amount.Uint64() - require.Equal(t, amount*2, amount2) - } }) } diff --git a/x/incentive/keeper/keeper.go b/x/incentive/keeper/keeper.go index 9929989cd..c66d3804f 100644 --- a/x/incentive/keeper/keeper.go +++ b/x/incentive/keeper/keeper.go @@ -1,9 +1,10 @@ package keeper import ( - corestoretypes "cosmossdk.io/core/store" "fmt" + "cosmossdk.io/collections" + corestoretypes "cosmossdk.io/core/store" "cosmossdk.io/log" "github.com/babylonlabs-io/babylon/x/incentive/types" "github.com/cosmos/cosmos-sdk/codec" @@ -15,9 +16,14 @@ type ( cdc codec.BinaryCodec storeService corestoretypes.KVStoreService - epochingKeeper types.EpochingKeeper bankKeeper types.BankKeeper accountKeeper types.AccountKeeper + epochingKeeper types.EpochingKeeper + + // RefundableMsgKeySet is the set of hashes of messages that can be refunded + // Each key is a hash of the message bytes + RefundableMsgKeySet collections.KeySet[[]byte] + // the address capable of executing a MsgUpdateParams message. Typically, this // should be the x/gov module account. authority string @@ -35,12 +41,20 @@ func NewKeeper( authority string, feeCollectorName string, ) Keeper { + sb := collections.NewSchemaBuilder(storeService) + return Keeper{ - cdc: cdc, - storeService: storeService, - epochingKeeper: epochingKeeper, - bankKeeper: bankKeeper, - accountKeeper: accountKeeper, + cdc: cdc, + storeService: storeService, + bankKeeper: bankKeeper, + accountKeeper: accountKeeper, + epochingKeeper: epochingKeeper, + RefundableMsgKeySet: collections.NewKeySet( + sb, + types.RefundableMsgKeySetPrefix, + "refundable_msg_key_set", + collections.BytesKey, + ), authority: authority, feeCollectorName: feeCollectorName, } diff --git a/x/incentive/keeper/refund_tx_decorator.go b/x/incentive/keeper/refund_tx_decorator.go new file mode 100644 index 000000000..edfde087f --- /dev/null +++ b/x/incentive/keeper/refund_tx_decorator.go @@ -0,0 +1,78 @@ +package keeper + +import ( + "github.com/babylonlabs-io/babylon/x/incentive/types" + sdk "github.com/cosmos/cosmos-sdk/types" +) + +var _ sdk.PostDecorator = &RefundTxDecorator{} + +type RefundTxDecorator struct { + k *Keeper +} + +// NewRefundTxDecorator creates a new RefundTxDecorator +func NewRefundTxDecorator(k *Keeper) *RefundTxDecorator { + return &RefundTxDecorator{ + k: k, + } +} + +func (d *RefundTxDecorator) PostHandle(ctx sdk.Context, tx sdk.Tx, simulate, success bool, next sdk.PostHandler) (sdk.Context, error) { + // refund only when finalizing a block or simulating the current tx + if ctx.ExecMode() != sdk.ExecModeFinalize && !simulate { + return next(ctx, tx, simulate, success) + } + // avoid refunding failed tx + if !success { + return next(ctx, tx, simulate, success) + } + // ignore tx that does not need to pay fee + feeTx, ok := tx.(sdk.FeeTx) + if !ok { + return next(ctx, tx, simulate, success) + } + + refundable := d.CheckTxAndClearIndex(ctx, tx) + + // if the tx is refundable, refund it + if refundable { + err := d.k.RefundTx(ctx, feeTx) + if err != nil { + d.k.Logger(ctx).Error("failed to refund tx", "error", err) + return next(ctx, tx, simulate, success) + } + } + + // move to the next PostHandler + return next(ctx, tx, simulate, success) +} + +// CheckTxAndClearIndex parses the given tx and returns a boolean indicating +// whether the tx is refundable, and clears the refundable messages from the index +// NOTE: a tx is refundable if all of its messages are unique and refundable +func (d *RefundTxDecorator) CheckTxAndClearIndex(ctx sdk.Context, tx sdk.Tx) bool { + // NOTE: we use a map to avoid duplicated refundable messages, as + // otherwise one can fill a tx with duplicate messages to bloat the blockchain + refundableMsgHashSet := make(map[string]struct{}) + + // iterate over all messages in the tx, and record whether they are refundable + for _, msg := range tx.GetMsgs() { + msgHash := types.HashMsg(msg) + if d.k.HasRefundableMsg(ctx, msgHash) { + refundableMsgHashSet[string(msgHash)] = struct{}{} + } + } + + // if all messages in the tx are unique and refundable, then this tx is refundable + refundable := len(refundableMsgHashSet) == len(tx.GetMsgs()) + + // remove the refundable messages from the index, regardless whether the tx is refunded or not + // NOTE: If the message with same hash shows up in a later tx, the refunding rule will + // consider it duplicated and the tx will not be refunded + for msgHash := range refundableMsgHashSet { + d.k.RemoveRefundableMsg(ctx, []byte(msgHash)) + } + + return refundable +} diff --git a/x/incentive/keeper/refund_tx_decorator_test.go b/x/incentive/keeper/refund_tx_decorator_test.go new file mode 100644 index 000000000..a9eabd360 --- /dev/null +++ b/x/incentive/keeper/refund_tx_decorator_test.go @@ -0,0 +1,104 @@ +package keeper_test + +import ( + "testing" + + keepertest "github.com/babylonlabs-io/babylon/testutil/keeper" + "github.com/babylonlabs-io/babylon/x/incentive/keeper" + "github.com/babylonlabs-io/babylon/x/incentive/types" + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/golang/mock/gomock" + "github.com/stretchr/testify/require" + "google.golang.org/protobuf/reflect/protoreflect" +) + +var _ sdk.Tx = &TestTx{} + +type TestTx struct { + Msgs []sdk.Msg +} + +func (tx *TestTx) GetMsgs() []sdk.Msg { + return tx.Msgs +} + +func (tx *TestTx) GetMsgsV2() ([]protoreflect.ProtoMessage, error) { + return nil, nil +} + +func TestCheckTxAndClearIndex(t *testing.T) { + ctrl := gomock.NewController(t) + defer ctrl.Finish() + + iKeeper, ctx := keepertest.IncentiveKeeper(t, nil, nil, nil) + decorator := keeper.NewRefundTxDecorator(iKeeper) + + testCases := []struct { + name string + setup func(ctx sdk.Context) sdk.Tx + expected bool + }{ + { + name: "if all messages are unique and refundable, the tx is refundable", + setup: func(ctx sdk.Context) sdk.Tx { + msg1 := types.MsgWithdrawReward{ + Address: "address", + } + msg2 := types.MsgWithdrawReward{ + Address: "address2", + } + iKeeper.IndexRefundableMsg(ctx, &msg1) + iKeeper.IndexRefundableMsg(ctx, &msg2) + return &TestTx{Msgs: []sdk.Msg{&msg1, &msg2}} + }, + expected: true, + }, + { + name: "if some messages are not refundable, the tx is not refundable", + setup: func(ctx sdk.Context) sdk.Tx { + msg1 := types.MsgWithdrawReward{ + Address: "address", + } + msg2 := types.MsgWithdrawReward{ + Address: "address2", + } + iKeeper.IndexRefundableMsg(ctx, &msg1) + return &TestTx{Msgs: []sdk.Msg{&msg1, &msg2}} + }, + expected: false, + }, + { + name: "if some messages are duplicated, the tx is not refundable", + setup: func(ctx sdk.Context) sdk.Tx { + msg := types.MsgWithdrawReward{ + Address: "address", + } + msg2 := types.MsgWithdrawReward{ + Address: "address", + } + msg3 := types.MsgWithdrawReward{ + Address: "address2", + } + iKeeper.IndexRefundableMsg(ctx, &msg) + iKeeper.IndexRefundableMsg(ctx, &msg2) + iKeeper.IndexRefundableMsg(ctx, &msg3) + return &TestTx{Msgs: []sdk.Msg{&msg, &msg2, &msg3}} + }, + expected: false, + }, + } + + for _, tc := range testCases { + t.Run(tc.name, func(t *testing.T) { + tx := tc.setup(ctx) + result := decorator.CheckTxAndClearIndex(ctx, tx) + + require.Equal(t, tc.expected, result) + + // Check that all messages have been cleared from the index + for _, msg := range tx.GetMsgs() { + require.False(t, iKeeper.HasRefundableMsg(ctx, types.HashMsg(msg))) + } + }) + } +} diff --git a/x/incentive/keeper/refundable_msg_index.go b/x/incentive/keeper/refundable_msg_index.go new file mode 100644 index 000000000..ffb1d7f80 --- /dev/null +++ b/x/incentive/keeper/refundable_msg_index.go @@ -0,0 +1,47 @@ +package keeper + +import ( + "context" + + "github.com/babylonlabs-io/babylon/x/incentive/types" + sdk "github.com/cosmos/cosmos-sdk/types" +) + +// RefundTx refunds the given tx by sending the fee back to the fee payer. +func (k Keeper) RefundTx(ctx context.Context, tx sdk.FeeTx) error { + txFee := tx.GetFee() + if txFee.IsZero() { + // not possible with the global min gas price mechanism + // but having this check for compatibility in the future + return nil + } + txFeePayer := tx.FeePayer() + + return k.bankKeeper.SendCoinsFromModuleToAccount(ctx, k.feeCollectorName, txFeePayer, txFee) +} + +// IndexRefundableMsg indexes the given refundable message by its hash. +func (k Keeper) IndexRefundableMsg(ctx context.Context, msg sdk.Msg) { + msgHash := types.HashMsg(msg) + err := k.RefundableMsgKeySet.Set(ctx, msgHash) + if err != nil { + panic(err) // encoding issue; this can only be a programming error + } +} + +// HasRefundableMsg checks if the message with a given hash is refundable. +func (k Keeper) HasRefundableMsg(ctx context.Context, msgHash []byte) bool { + has, err := k.RefundableMsgKeySet.Has(ctx, msgHash) + if err != nil { + panic(err) // encoding issue; this can only be a programming error + } + return has +} + +// RemoveRefundableMsg removes the given refundable message from the index. +func (k Keeper) RemoveRefundableMsg(ctx context.Context, msgHash []byte) { + err := k.RefundableMsgKeySet.Remove(ctx, msgHash) + if err != nil { + panic(err) // encoding issue; this can only be a programming error + } +} diff --git a/x/incentive/keeper/reward_gauge.go b/x/incentive/keeper/reward_gauge.go index 57c598150..0da3f94cb 100644 --- a/x/incentive/keeper/reward_gauge.go +++ b/x/incentive/keeper/reward_gauge.go @@ -2,6 +2,7 @@ package keeper import ( "context" + "cosmossdk.io/store/prefix" "github.com/babylonlabs-io/babylon/x/incentive/types" "github.com/cosmos/cosmos-sdk/runtime" @@ -66,7 +67,7 @@ func (k Keeper) GetRewardGauge(ctx context.Context, sType types.StakeholderType, } // rewardGaugeStore returns the KVStore of the reward gauge of a stakeholder -// of a given type {submitter, reporter, finality provider, BTC delegation} +// of a given type {finality provider or BTC delegation} // prefix: RewardGaugeKey // key: (stakeholder type || stakeholder address) // value: reward gauge diff --git a/x/incentive/module.go b/x/incentive/module.go index 254a95231..a7143f104 100644 --- a/x/incentive/module.go +++ b/x/incentive/module.go @@ -70,7 +70,9 @@ func (AppModuleBasic) ValidateGenesis(cdc codec.JSONCodec, config client.TxEncod // RegisterGRPCGatewayRoutes registers the gRPC Gateway routes for the module func (AppModuleBasic) RegisterGRPCGatewayRoutes(clientCtx client.Context, mux *runtime.ServeMux) { - types.RegisterQueryHandlerClient(context.Background(), mux, types.NewQueryClient(clientCtx)) //nolint:errcheck + if err := types.RegisterQueryHandlerClient(context.Background(), mux, types.NewQueryClient(clientCtx)); err != nil { + panic(err) + } } // GetTxCmd returns the root Tx command for the module. The subcommands of this root command are used by end-users to generate new transactions containing messages defined in the module diff --git a/x/incentive/types/errors.go b/x/incentive/types/errors.go index 3e56f8d36..ccf8a9dab 100644 --- a/x/incentive/types/errors.go +++ b/x/incentive/types/errors.go @@ -6,8 +6,7 @@ import ( // x/incentive module sentinel errors var ( - ErrBTCStakingGaugeNotFound = errorsmod.Register(ModuleName, 1100, "BTC staking gauge not found") - ErrBTCTimestampingGaugeNotFound = errorsmod.Register(ModuleName, 1101, "BTC timestamping gauge not found") - ErrRewardGaugeNotFound = errorsmod.Register(ModuleName, 1102, "reward gauge not found") - ErrNoWithdrawableCoins = errorsmod.Register(ModuleName, 1103, "no coin is withdrawable") + ErrBTCStakingGaugeNotFound = errorsmod.Register(ModuleName, 1100, "BTC staking gauge not found") + ErrRewardGaugeNotFound = errorsmod.Register(ModuleName, 1101, "reward gauge not found") + ErrNoWithdrawableCoins = errorsmod.Register(ModuleName, 1102, "no coin is withdrawable") ) diff --git a/x/incentive/types/expected_keepers.go b/x/incentive/types/expected_keepers.go index 434a96c0d..aac8d0816 100644 --- a/x/incentive/types/expected_keepers.go +++ b/x/incentive/types/expected_keepers.go @@ -2,6 +2,7 @@ package types import ( "context" + epochingtypes "github.com/babylonlabs-io/babylon/x/epoching/types" sdk "github.com/cosmos/cosmos-sdk/types" ) diff --git a/x/incentive/types/incentive.go b/x/incentive/types/incentive.go index 9b0184cb8..4b55fc533 100644 --- a/x/incentive/types/incentive.go +++ b/x/incentive/types/incentive.go @@ -59,44 +59,34 @@ func GetCoinsPortion(coinsInt sdk.Coins, portion math.LegacyDec) sdk.Coins { type StakeholderType byte const ( - SubmitterType StakeholderType = iota - ReporterType - FinalityProviderType + FinalityProviderType StakeholderType = iota BTCDelegationType ) func GetAllStakeholderTypes() []StakeholderType { - return []StakeholderType{SubmitterType, ReporterType, FinalityProviderType, BTCDelegationType} + return []StakeholderType{FinalityProviderType, BTCDelegationType} } func NewStakeHolderType(stBytes []byte) (StakeholderType, error) { if len(stBytes) != 1 { - return SubmitterType, fmt.Errorf("invalid format for stBytes") + return FinalityProviderType, fmt.Errorf("invalid format for stBytes") } - if stBytes[0] == byte(SubmitterType) { - return SubmitterType, nil - } else if stBytes[0] == byte(ReporterType) { - return ReporterType, nil - } else if stBytes[0] == byte(FinalityProviderType) { + if stBytes[0] == byte(FinalityProviderType) { return FinalityProviderType, nil } else if stBytes[0] == byte(BTCDelegationType) { return BTCDelegationType, nil } else { - return SubmitterType, fmt.Errorf("invalid stBytes") + return FinalityProviderType, fmt.Errorf("invalid stBytes") } } func NewStakeHolderTypeFromString(stStr string) (StakeholderType, error) { - if stStr == "submitter" { - return SubmitterType, nil - } else if stStr == "reporter" { - return ReporterType, nil - } else if stStr == "finality_provider" { + if stStr == "finality_provider" { return FinalityProviderType, nil } else if stStr == "btc_delegation" { return BTCDelegationType, nil } else { - return SubmitterType, fmt.Errorf("invalid stStr") + return FinalityProviderType, fmt.Errorf("invalid stStr") } } @@ -105,11 +95,7 @@ func (st StakeholderType) Bytes() []byte { } func (st StakeholderType) String() string { - if st == SubmitterType { - return "submitter" - } else if st == ReporterType { - return "reporter" - } else if st == FinalityProviderType { + if st == FinalityProviderType { return "finality_provider" } else if st == BTCDelegationType { return "btc_delegation" diff --git a/x/incentive/types/incentive.pb.go b/x/incentive/types/incentive.pb.go index 98d972e2e..ad3822609 100644 --- a/x/incentive/types/incentive.pb.go +++ b/x/incentive/types/incentive.pb.go @@ -73,7 +73,7 @@ func (m *Gauge) GetCoins() github_com_cosmos_cosmos_sdk_types.Coins { return nil } -// RewardGauge is an object that stores rewards distributed to a BTC staking/timestamping stakeholder +// RewardGauge is an object that stores rewards distributed to a BTC staking stakeholder // code adapted from https://github.com/osmosis-labs/osmosis/blob/v18.0.0/proto/osmosis/incentives/gauge.proto type RewardGauge struct { // coins are coins that have been in the gauge diff --git a/x/incentive/types/keys.go b/x/incentive/types/keys.go index 83bb1ea32..a7aeced74 100644 --- a/x/incentive/types/keys.go +++ b/x/incentive/types/keys.go @@ -1,5 +1,7 @@ package types +import "cosmossdk.io/collections" + const ( // ModuleName defines the module name ModuleName = "incentive" @@ -15,8 +17,9 @@ const ( ) var ( - ParamsKey = []byte{0x01} // key prefix for the parameters - BTCStakingGaugeKey = []byte{0x02} // key prefix for BTC staking gauge at each height - BTCTimestampingGaugeKey = []byte{0x03} // key prefix for BTC timestamping gauge at each height - RewardGaugeKey = []byte{0x04} // key prefix for reward gauge for a given stakeholder in a given type + ParamsKey = []byte{0x01} // key prefix for the parameters + BTCStakingGaugeKey = []byte{0x02} // key prefix for BTC staking gauge at each height + ReservedKey = []byte{0x03} // reserved //nolint:unused + RewardGaugeKey = []byte{0x04} // key prefix for reward gauge for a given stakeholder in a given type + RefundableMsgKeySetPrefix = collections.NewPrefix(5) // key prefix for refundable msg key set ) diff --git a/x/incentive/types/params.go b/x/incentive/types/params.go index 8173d4be2..d6f5b5bba 100644 --- a/x/incentive/types/params.go +++ b/x/incentive/types/params.go @@ -18,9 +18,7 @@ func ParamKeyTable() paramtypes.KeyTable { // DefaultParams returns a default set of parameters func DefaultParams() Params { return Params{ - SubmitterPortion: math.LegacyNewDecWithPrec(5, 2), // 5 * 10^{-2} = 0.05 - ReporterPortion: math.LegacyNewDecWithPrec(5, 2), // 5 * 10^{-2} = 0.05 - BtcStakingPortion: math.LegacyNewDecWithPrec(2, 1), // 2 * 10^{-1} = 0.2 + BtcStakingPortion: math.LegacyNewDecWithPrec(6, 1), // 6 * 10^{-1} = 0.6 } } @@ -31,16 +29,7 @@ func (p *Params) ParamSetPairs() paramtypes.ParamSetPairs { // TotalPortion calculates the sum of portions of all stakeholders func (p *Params) TotalPortion() math.LegacyDec { - sum := p.SubmitterPortion - sum = sum.Add(p.ReporterPortion) - sum = sum.Add(p.BtcStakingPortion) - return sum -} - -// BTCTimestampingPortion calculates the sum of portions of all BTC timestamping stakeholders -func (p *Params) BTCTimestampingPortion() math.LegacyDec { - sum := p.SubmitterPortion - sum = sum.Add(p.ReporterPortion) + sum := p.BtcStakingPortion return sum } @@ -51,12 +40,6 @@ func (p *Params) BTCStakingPortion() math.LegacyDec { // Validate validates the set of params func (p Params) Validate() error { - if p.SubmitterPortion.IsNil() { - return fmt.Errorf("SubmitterPortion should not be nil") - } - if p.ReporterPortion.IsNil() { - return fmt.Errorf("ReporterPortion should not be nil") - } if p.BtcStakingPortion.IsNil() { return fmt.Errorf("BtcStakingPortion should not be nil") } diff --git a/x/incentive/types/params.pb.go b/x/incentive/types/params.pb.go index ac7b99865..aab8a71a9 100644 --- a/x/incentive/types/params.pb.go +++ b/x/incentive/types/params.pb.go @@ -30,14 +30,10 @@ const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package // be strictly less than 1 so that the rest will go to Comet validators/delegations // adapted from https://github.com/cosmos/cosmos-sdk/blob/release/v0.47.x/proto/cosmos/distribution/v1beta1/distribution.proto type Params struct { - // submitter_portion is the portion of rewards that goes to submitter - SubmitterPortion cosmossdk_io_math.LegacyDec `protobuf:"bytes,1,opt,name=submitter_portion,json=submitterPortion,proto3,customtype=cosmossdk.io/math.LegacyDec" json:"submitter_portion"` - // reporter_portion is the portion of rewards that goes to reporter - ReporterPortion cosmossdk_io_math.LegacyDec `protobuf:"bytes,2,opt,name=reporter_portion,json=reporterPortion,proto3,customtype=cosmossdk.io/math.LegacyDec" json:"reporter_portion"` // btc_staking_portion is the portion of rewards that goes to Finality Providers/delegations // NOTE: the portion of each Finality Provider/delegation is calculated by using its voting // power and finality provider's commission - BtcStakingPortion cosmossdk_io_math.LegacyDec `protobuf:"bytes,3,opt,name=btc_staking_portion,json=btcStakingPortion,proto3,customtype=cosmossdk.io/math.LegacyDec" json:"btc_staking_portion"` + BtcStakingPortion cosmossdk_io_math.LegacyDec `protobuf:"bytes,1,opt,name=btc_staking_portion,json=btcStakingPortion,proto3,customtype=cosmossdk.io/math.LegacyDec" json:"btc_staking_portion"` } func (m *Params) Reset() { *m = Params{} } @@ -79,26 +75,23 @@ func init() { func init() { proto.RegisterFile("babylon/incentive/params.proto", fileDescriptor_c42276168f0adf4b) } var fileDescriptor_c42276168f0adf4b = []byte{ - // 296 bytes of a gzipped FileDescriptorProto + // 253 bytes of a gzipped FileDescriptorProto 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x92, 0x4b, 0x4a, 0x4c, 0xaa, 0xcc, 0xc9, 0xcf, 0xd3, 0xcf, 0xcc, 0x4b, 0x4e, 0xcd, 0x2b, 0xc9, 0x2c, 0x4b, 0xd5, 0x2f, 0x48, 0x2c, 0x4a, 0xcc, 0x2d, 0xd6, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0x12, 0x84, 0xca, 0xeb, 0xc1, 0xe5, 0xa5, 0x44, 0xd2, 0xf3, 0xd3, 0xf3, 0xc1, 0xb2, 0xfa, 0x20, 0x16, 0x44, 0xa1, 0x94, 0x64, - 0x72, 0x7e, 0x71, 0x6e, 0x7e, 0x71, 0x3c, 0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xd5, - 0x87, 0x46, 0x4d, 0x4e, 0x62, 0x52, 0xb1, 0x6e, 0x66, 0x3e, 0x8c, 0xab, 0x5f, 0x81, 0x14, 0x97, - 0x25, 0x95, 0x05, 0xa9, 0xc5, 0x49, 0x6c, 0xe0, 0x78, 0x30, 0x06, 0x04, 0x00, 0x00, 0xff, 0xff, - 0x1a, 0x83, 0x6c, 0xe6, 0xed, 0x01, 0x00, 0x00, + 0x72, 0x7e, 0x71, 0x6e, 0x7e, 0x71, 0x3c, 0x44, 0x02, 0xc2, 0x81, 0x48, 0x29, 0x15, 0x72, 0xb1, + 0x05, 0x80, 0xcd, 0x14, 0x4a, 0xe4, 0x12, 0x4e, 0x2a, 0x49, 0x8e, 0x2f, 0x2e, 0x49, 0xcc, 0xce, + 0xcc, 0x4b, 0x8f, 0x2f, 0xc8, 0x2f, 0x2a, 0xc9, 0xcc, 0xcf, 0x93, 0x60, 0x54, 0x60, 0xd4, 0xe0, + 0x74, 0x32, 0x3c, 0x71, 0x4f, 0x9e, 0xe1, 0xd6, 0x3d, 0x79, 0x69, 0x88, 0xe6, 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, 0x66, 0xbb, 0xa4, 0x26, 0x07, 0x09, 0x26, 0x95, 0x24, + 0x07, 0x43, 0x0c, 0x0b, 0x80, 0x98, 0x65, 0xc5, 0x32, 0x63, 0x81, 0x3c, 0x83, 0x93, 0xef, 0x89, + 0x47, 0x72, 0x8c, 0x17, 0x1e, 0xc9, 0x31, 0x3e, 0x78, 0x24, 0xc7, 0x38, 0xe1, 0xb1, 0x1c, 0xc3, + 0x85, 0xc7, 0x72, 0x0c, 0x37, 0x1e, 0xcb, 0x31, 0x44, 0x19, 0xa7, 0x67, 0x96, 0x64, 0x94, 0x26, + 0xe9, 0x25, 0xe7, 0xe7, 0xea, 0x43, 0xfd, 0x96, 0x93, 0x98, 0x54, 0xac, 0x9b, 0x99, 0x0f, 0xe3, + 0xea, 0x57, 0x20, 0x05, 0x46, 0x49, 0x65, 0x41, 0x6a, 0x71, 0x12, 0x1b, 0xd8, 0x23, 0xc6, 0x80, + 0x00, 0x00, 0x00, 0xff, 0xff, 0x0f, 0xfd, 0x78, 0x13, 0x2e, 0x01, 0x00, 0x00, } func (m *Params) Marshal() (dAtA []byte, err error) { @@ -130,26 +123,6 @@ func (m *Params) MarshalToSizedBuffer(dAtA []byte) (int, error) { i = encodeVarintParams(dAtA, i, uint64(size)) } i-- - dAtA[i] = 0x1a - { - size := m.ReporterPortion.Size() - i -= size - if _, err := m.ReporterPortion.MarshalTo(dAtA[i:]); err != nil { - return 0, err - } - i = encodeVarintParams(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x12 - { - size := m.SubmitterPortion.Size() - i -= size - if _, err := m.SubmitterPortion.MarshalTo(dAtA[i:]); err != nil { - return 0, err - } - i = encodeVarintParams(dAtA, i, uint64(size)) - } - i-- dAtA[i] = 0xa return len(dAtA) - i, nil } @@ -171,10 +144,6 @@ func (m *Params) Size() (n int) { } var l int _ = l - l = m.SubmitterPortion.Size() - n += 1 + l + sovParams(uint64(l)) - l = m.ReporterPortion.Size() - n += 1 + l + sovParams(uint64(l)) l = m.BtcStakingPortion.Size() n += 1 + l + sovParams(uint64(l)) return n @@ -216,74 +185,6 @@ func (m *Params) Unmarshal(dAtA []byte) error { } switch fieldNum { case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field SubmitterPortion", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowParams - } - 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 ErrInvalidLengthParams - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthParams - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := m.SubmitterPortion.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field ReporterPortion", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowParams - } - 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 ErrInvalidLengthParams - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthParams - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := m.ReporterPortion.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 3: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field BtcStakingPortion", wireType) } diff --git a/x/incentive/types/query.pb.go b/x/incentive/types/query.pb.go index a0829633e..baab5bc94 100644 --- a/x/incentive/types/query.pb.go +++ b/x/incentive/types/query.pb.go @@ -6,6 +6,8 @@ package types import ( context "context" fmt "fmt" + github_com_cosmos_cosmos_sdk_types "github.com/cosmos/cosmos-sdk/types" + types "github.com/cosmos/cosmos-sdk/types" _ "github.com/cosmos/gogoproto/gogoproto" grpc1 "github.com/cosmos/gogoproto/grpc" proto "github.com/cosmos/gogoproto/proto" @@ -158,18 +160,74 @@ func (m *QueryRewardGaugesRequest) GetAddress() string { return "" } +// RewardGaugesResponse is an object that stores rewards distributed to a BTC staking stakeholder +type RewardGaugesResponse struct { + // coins are coins that have been in the gauge + // Can have multiple coin denoms + Coins github_com_cosmos_cosmos_sdk_types.Coins `protobuf:"bytes,1,rep,name=coins,proto3,castrepeated=github.com/cosmos/cosmos-sdk/types.Coins" json:"coins"` + // withdrawn_coins are coins that have been withdrawn by the stakeholder already + WithdrawnCoins github_com_cosmos_cosmos_sdk_types.Coins `protobuf:"bytes,2,rep,name=withdrawn_coins,json=withdrawnCoins,proto3,castrepeated=github.com/cosmos/cosmos-sdk/types.Coins" json:"withdrawn_coins"` +} + +func (m *RewardGaugesResponse) Reset() { *m = RewardGaugesResponse{} } +func (m *RewardGaugesResponse) String() string { return proto.CompactTextString(m) } +func (*RewardGaugesResponse) ProtoMessage() {} +func (*RewardGaugesResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_e1a59cc0c7c44135, []int{3} +} +func (m *RewardGaugesResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *RewardGaugesResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_RewardGaugesResponse.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 *RewardGaugesResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_RewardGaugesResponse.Merge(m, src) +} +func (m *RewardGaugesResponse) XXX_Size() int { + return m.Size() +} +func (m *RewardGaugesResponse) XXX_DiscardUnknown() { + xxx_messageInfo_RewardGaugesResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_RewardGaugesResponse proto.InternalMessageInfo + +func (m *RewardGaugesResponse) GetCoins() github_com_cosmos_cosmos_sdk_types.Coins { + if m != nil { + return m.Coins + } + return nil +} + +func (m *RewardGaugesResponse) GetWithdrawnCoins() github_com_cosmos_cosmos_sdk_types.Coins { + if m != nil { + return m.WithdrawnCoins + } + return nil +} + // QueryRewardGaugesResponse is response type for the Query/RewardGauges RPC method. type QueryRewardGaugesResponse struct { // reward_gauges is the map of reward gauges, where key is the stakeholder type // and value is the reward gauge holding all rewards for the stakeholder in that type - RewardGauges map[string]*RewardGauge `protobuf:"bytes,1,rep,name=reward_gauges,json=rewardGauges,proto3" json:"reward_gauges,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"` + RewardGauges map[string]*RewardGaugesResponse `protobuf:"bytes,1,rep,name=reward_gauges,json=rewardGauges,proto3" json:"reward_gauges,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"` } func (m *QueryRewardGaugesResponse) Reset() { *m = QueryRewardGaugesResponse{} } func (m *QueryRewardGaugesResponse) String() string { return proto.CompactTextString(m) } func (*QueryRewardGaugesResponse) ProtoMessage() {} func (*QueryRewardGaugesResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_e1a59cc0c7c44135, []int{3} + return fileDescriptor_e1a59cc0c7c44135, []int{4} } func (m *QueryRewardGaugesResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -198,7 +256,7 @@ func (m *QueryRewardGaugesResponse) XXX_DiscardUnknown() { var xxx_messageInfo_QueryRewardGaugesResponse proto.InternalMessageInfo -func (m *QueryRewardGaugesResponse) GetRewardGauges() map[string]*RewardGauge { +func (m *QueryRewardGaugesResponse) GetRewardGauges() map[string]*RewardGaugesResponse { if m != nil { return m.RewardGauges } @@ -215,7 +273,7 @@ func (m *QueryBTCStakingGaugeRequest) Reset() { *m = QueryBTCStakingGaug func (m *QueryBTCStakingGaugeRequest) String() string { return proto.CompactTextString(m) } func (*QueryBTCStakingGaugeRequest) ProtoMessage() {} func (*QueryBTCStakingGaugeRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_e1a59cc0c7c44135, []int{4} + return fileDescriptor_e1a59cc0c7c44135, []int{5} } func (m *QueryBTCStakingGaugeRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -251,70 +309,25 @@ func (m *QueryBTCStakingGaugeRequest) GetHeight() uint64 { return 0 } -// QueryBTCStakingGaugeResponse is response type for the Query/BTCStakingGauge RPC method. -type QueryBTCStakingGaugeResponse struct { - // gauge is the BTC staking gauge at the queried height - Gauge *Gauge `protobuf:"bytes,1,opt,name=gauge,proto3" json:"gauge,omitempty"` +// BTCStakingGaugeResponse is response type for the Query/BTCStakingGauge RPC method. +type BTCStakingGaugeResponse struct { + // coins that have been in the gauge + // can have multiple coin denoms + Coins github_com_cosmos_cosmos_sdk_types.Coins `protobuf:"bytes,1,rep,name=coins,proto3,castrepeated=github.com/cosmos/cosmos-sdk/types.Coins" json:"coins"` } -func (m *QueryBTCStakingGaugeResponse) Reset() { *m = QueryBTCStakingGaugeResponse{} } -func (m *QueryBTCStakingGaugeResponse) String() string { return proto.CompactTextString(m) } -func (*QueryBTCStakingGaugeResponse) ProtoMessage() {} -func (*QueryBTCStakingGaugeResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_e1a59cc0c7c44135, []int{5} -} -func (m *QueryBTCStakingGaugeResponse) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *QueryBTCStakingGaugeResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_QueryBTCStakingGaugeResponse.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 *QueryBTCStakingGaugeResponse) XXX_Merge(src proto.Message) { - xxx_messageInfo_QueryBTCStakingGaugeResponse.Merge(m, src) -} -func (m *QueryBTCStakingGaugeResponse) XXX_Size() int { - return m.Size() -} -func (m *QueryBTCStakingGaugeResponse) XXX_DiscardUnknown() { - xxx_messageInfo_QueryBTCStakingGaugeResponse.DiscardUnknown(m) -} - -var xxx_messageInfo_QueryBTCStakingGaugeResponse proto.InternalMessageInfo - -func (m *QueryBTCStakingGaugeResponse) GetGauge() *Gauge { - if m != nil { - return m.Gauge - } - return nil -} - -// QueryBTCTimestampingGaugeRequest is request type for the Query/BTCTimestampingGauge RPC method. -type QueryBTCTimestampingGaugeRequest struct { - // epoch_num is the queried epoch number - EpochNum uint64 `protobuf:"varint,1,opt,name=epoch_num,json=epochNum,proto3" json:"epoch_num,omitempty"` -} - -func (m *QueryBTCTimestampingGaugeRequest) Reset() { *m = QueryBTCTimestampingGaugeRequest{} } -func (m *QueryBTCTimestampingGaugeRequest) String() string { return proto.CompactTextString(m) } -func (*QueryBTCTimestampingGaugeRequest) ProtoMessage() {} -func (*QueryBTCTimestampingGaugeRequest) Descriptor() ([]byte, []int) { +func (m *BTCStakingGaugeResponse) Reset() { *m = BTCStakingGaugeResponse{} } +func (m *BTCStakingGaugeResponse) String() string { return proto.CompactTextString(m) } +func (*BTCStakingGaugeResponse) ProtoMessage() {} +func (*BTCStakingGaugeResponse) Descriptor() ([]byte, []int) { return fileDescriptor_e1a59cc0c7c44135, []int{6} } -func (m *QueryBTCTimestampingGaugeRequest) XXX_Unmarshal(b []byte) error { +func (m *BTCStakingGaugeResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } -func (m *QueryBTCTimestampingGaugeRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { +func (m *BTCStakingGaugeResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { - return xxx_messageInfo_QueryBTCTimestampingGaugeRequest.Marshal(b, m, deterministic) + return xxx_messageInfo_BTCStakingGaugeResponse.Marshal(b, m, deterministic) } else { b = b[:cap(b)] n, err := m.MarshalToSizedBuffer(b) @@ -324,43 +337,43 @@ func (m *QueryBTCTimestampingGaugeRequest) XXX_Marshal(b []byte, deterministic b return b[:n], nil } } -func (m *QueryBTCTimestampingGaugeRequest) XXX_Merge(src proto.Message) { - xxx_messageInfo_QueryBTCTimestampingGaugeRequest.Merge(m, src) +func (m *BTCStakingGaugeResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_BTCStakingGaugeResponse.Merge(m, src) } -func (m *QueryBTCTimestampingGaugeRequest) XXX_Size() int { +func (m *BTCStakingGaugeResponse) XXX_Size() int { return m.Size() } -func (m *QueryBTCTimestampingGaugeRequest) XXX_DiscardUnknown() { - xxx_messageInfo_QueryBTCTimestampingGaugeRequest.DiscardUnknown(m) +func (m *BTCStakingGaugeResponse) XXX_DiscardUnknown() { + xxx_messageInfo_BTCStakingGaugeResponse.DiscardUnknown(m) } -var xxx_messageInfo_QueryBTCTimestampingGaugeRequest proto.InternalMessageInfo +var xxx_messageInfo_BTCStakingGaugeResponse proto.InternalMessageInfo -func (m *QueryBTCTimestampingGaugeRequest) GetEpochNum() uint64 { +func (m *BTCStakingGaugeResponse) GetCoins() github_com_cosmos_cosmos_sdk_types.Coins { if m != nil { - return m.EpochNum + return m.Coins } - return 0 + return nil } -// QueryBTCTimestampingGaugeResponse is response type for the Query/BTCTimestampingGauge RPC method. -type QueryBTCTimestampingGaugeResponse struct { - // gauge is the BTC timestamping gauge at the queried epoch - Gauge *Gauge `protobuf:"bytes,1,opt,name=gauge,proto3" json:"gauge,omitempty"` +// QueryBTCStakingGaugeResponse is response type for the Query/BTCStakingGauge RPC method. +type QueryBTCStakingGaugeResponse struct { + // gauge is the BTC staking gauge at the queried height + Gauge *BTCStakingGaugeResponse `protobuf:"bytes,1,opt,name=gauge,proto3" json:"gauge,omitempty"` } -func (m *QueryBTCTimestampingGaugeResponse) Reset() { *m = QueryBTCTimestampingGaugeResponse{} } -func (m *QueryBTCTimestampingGaugeResponse) String() string { return proto.CompactTextString(m) } -func (*QueryBTCTimestampingGaugeResponse) ProtoMessage() {} -func (*QueryBTCTimestampingGaugeResponse) Descriptor() ([]byte, []int) { +func (m *QueryBTCStakingGaugeResponse) Reset() { *m = QueryBTCStakingGaugeResponse{} } +func (m *QueryBTCStakingGaugeResponse) String() string { return proto.CompactTextString(m) } +func (*QueryBTCStakingGaugeResponse) ProtoMessage() {} +func (*QueryBTCStakingGaugeResponse) Descriptor() ([]byte, []int) { return fileDescriptor_e1a59cc0c7c44135, []int{7} } -func (m *QueryBTCTimestampingGaugeResponse) XXX_Unmarshal(b []byte) error { +func (m *QueryBTCStakingGaugeResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } -func (m *QueryBTCTimestampingGaugeResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { +func (m *QueryBTCStakingGaugeResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { - return xxx_messageInfo_QueryBTCTimestampingGaugeResponse.Marshal(b, m, deterministic) + return xxx_messageInfo_QueryBTCStakingGaugeResponse.Marshal(b, m, deterministic) } else { b = b[:cap(b)] n, err := m.MarshalToSizedBuffer(b) @@ -370,19 +383,19 @@ func (m *QueryBTCTimestampingGaugeResponse) XXX_Marshal(b []byte, deterministic return b[:n], nil } } -func (m *QueryBTCTimestampingGaugeResponse) XXX_Merge(src proto.Message) { - xxx_messageInfo_QueryBTCTimestampingGaugeResponse.Merge(m, src) +func (m *QueryBTCStakingGaugeResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryBTCStakingGaugeResponse.Merge(m, src) } -func (m *QueryBTCTimestampingGaugeResponse) XXX_Size() int { +func (m *QueryBTCStakingGaugeResponse) XXX_Size() int { return m.Size() } -func (m *QueryBTCTimestampingGaugeResponse) XXX_DiscardUnknown() { - xxx_messageInfo_QueryBTCTimestampingGaugeResponse.DiscardUnknown(m) +func (m *QueryBTCStakingGaugeResponse) XXX_DiscardUnknown() { + xxx_messageInfo_QueryBTCStakingGaugeResponse.DiscardUnknown(m) } -var xxx_messageInfo_QueryBTCTimestampingGaugeResponse proto.InternalMessageInfo +var xxx_messageInfo_QueryBTCStakingGaugeResponse proto.InternalMessageInfo -func (m *QueryBTCTimestampingGaugeResponse) GetGauge() *Gauge { +func (m *QueryBTCStakingGaugeResponse) GetGauge() *BTCStakingGaugeResponse { if m != nil { return m.Gauge } @@ -393,57 +406,59 @@ func init() { proto.RegisterType((*QueryParamsRequest)(nil), "babylon.incentive.QueryParamsRequest") proto.RegisterType((*QueryParamsResponse)(nil), "babylon.incentive.QueryParamsResponse") proto.RegisterType((*QueryRewardGaugesRequest)(nil), "babylon.incentive.QueryRewardGaugesRequest") + proto.RegisterType((*RewardGaugesResponse)(nil), "babylon.incentive.RewardGaugesResponse") proto.RegisterType((*QueryRewardGaugesResponse)(nil), "babylon.incentive.QueryRewardGaugesResponse") - proto.RegisterMapType((map[string]*RewardGauge)(nil), "babylon.incentive.QueryRewardGaugesResponse.RewardGaugesEntry") + proto.RegisterMapType((map[string]*RewardGaugesResponse)(nil), "babylon.incentive.QueryRewardGaugesResponse.RewardGaugesEntry") proto.RegisterType((*QueryBTCStakingGaugeRequest)(nil), "babylon.incentive.QueryBTCStakingGaugeRequest") + proto.RegisterType((*BTCStakingGaugeResponse)(nil), "babylon.incentive.BTCStakingGaugeResponse") proto.RegisterType((*QueryBTCStakingGaugeResponse)(nil), "babylon.incentive.QueryBTCStakingGaugeResponse") - proto.RegisterType((*QueryBTCTimestampingGaugeRequest)(nil), "babylon.incentive.QueryBTCTimestampingGaugeRequest") - proto.RegisterType((*QueryBTCTimestampingGaugeResponse)(nil), "babylon.incentive.QueryBTCTimestampingGaugeResponse") } func init() { proto.RegisterFile("babylon/incentive/query.proto", fileDescriptor_e1a59cc0c7c44135) } var fileDescriptor_e1a59cc0c7c44135 = []byte{ - // 611 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x9c, 0x94, 0x3f, 0x6f, 0xd3, 0x40, - 0x18, 0xc6, 0xe3, 0xb4, 0x09, 0xf4, 0x5a, 0x04, 0x3d, 0x22, 0xe4, 0x38, 0xc5, 0x24, 0x96, 0x40, - 0x95, 0xa0, 0xb6, 0xc8, 0x1f, 0x15, 0x90, 0x00, 0x29, 0x08, 0x31, 0x11, 0x81, 0xdb, 0x89, 0x25, - 0x3a, 0x27, 0x27, 0xc7, 0x6a, 0xec, 0x73, 0xed, 0x73, 0x21, 0x54, 0x59, 0xf8, 0x04, 0x48, 0x4c, - 0xec, 0x2c, 0x7c, 0x0b, 0xc6, 0x8e, 0x95, 0x58, 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0x36, 0xb2, 0xbe, 0x25, 0xf8, 0x45, 0x02, 0x6b, 0xc9, 0x10, 0xc0, 0xbb, - 0xe7, 0x8b, 0x18, 0x07, 0xb9, 0x77, 0x91, 0x3c, 0x6a, 0x0f, 0x19, 0x4e, 0x03, 0xde, 0x4f, 0xc1, - 0x11, 0x9f, 0x85, 0x71, 0x28, 0x0e, 0x63, 0x23, 0x99, 0x7f, 0xf8, 0x55, 0x02, 0x57, 0x4f, 0xc5, - 0x01, 0xea, 0x59, 0xcb, 0xd3, 0xe3, 0xa6, 0x18, 0xe7, 0xd6, 0x0b, 0xde, 0x16, 0xe3, 0x35, 0xe0, - 0x56, 0x0a, 0xaf, 0x45, 0x7b, 0xdd, 0x90, 0x0f, 0x71, 0x44, 0xe3, 0x90, 0xa7, 0x77, 0x0c, 0xbf, - 0x49, 0xa0, 0x94, 0x96, 0x14, 0xd8, 0x38, 0x03, 0x20, 0x2b, 0x98, 0x4a, 0xf3, 0x62, 0x43, 0x02, - 0xfd, 0x31, 0x43, 0xdf, 0x86, 0xad, 0x0c, 0x74, 0x9a, 0x98, 0x8c, 0xf9, 0xe7, 0xf9, 0x1f, 0xb7, - 0x5f, 0x1e, 0x4d, 0x54, 0xe9, 0x78, 0xa2, 0x4a, 0xbf, 0x26, 0xaa, 0xf4, 0x71, 0xaa, 0xe6, 0x8e, - 0xa7, 0x6a, 0xee, 0xc7, 0x54, 0xcd, 0xbd, 0x69, 0xd8, 0x0e, 0x1d, 0x44, 0x96, 0xde, 0x23, 0x6e, - 0x6c, 0x3d, 0x44, 0x56, 0xb8, 0xe5, 0x90, 0xf9, 0xa6, 0x77, 0x89, 0x5d, 0x74, 0xe4, 0xe3, 0xd0, - 0x2a, 0xb2, 0xbf, 0xe3, 0xc6, 0xdf, 0x00, 0x00, 0x00, 0xff, 0xff, 0x8a, 0xfc, 0x04, 0x89, 0x39, - 0x06, 0x00, 0x00, + // 644 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xbc, 0x54, 0x4f, 0x6f, 0xd3, 0x30, + 0x14, 0x6f, 0xba, 0xb5, 0x08, 0x33, 0x18, 0x33, 0x13, 0xb4, 0xdd, 0xc8, 0x58, 0x24, 0x60, 0x02, + 0x1a, 0xd3, 0x95, 0x89, 0x3f, 0x12, 0x08, 0x75, 0x42, 0x9c, 0x40, 0x10, 0x38, 0x71, 0x29, 0x4e, + 0x6a, 0xa5, 0x51, 0x5b, 0xbb, 0x8b, 0xdd, 0x96, 0x32, 0x76, 0xe1, 0x13, 0x20, 0xf1, 0x15, 0xb8, + 0xc0, 0x27, 0xd9, 0x71, 0x12, 0x12, 0xe2, 0x04, 0xa8, 0xe5, 0xc4, 0x85, 0xaf, 0x80, 0x62, 0xbb, + 0x55, 0x4a, 0x53, 0x31, 0x24, 0xc4, 0x29, 0x8e, 0xdf, 0xfb, 0xbd, 0xdf, 0xef, 0xf9, 0xfd, 0x6c, + 0x70, 0xd6, 0xc5, 0x6e, 0xbf, 0xc9, 0x28, 0x0a, 0xa8, 0x47, 0xa8, 0x08, 0xba, 0x04, 0xed, 0x74, + 0x48, 0xd8, 0xb7, 0xdb, 0x21, 0x13, 0x0c, 0x2e, 0xe9, 0xb0, 0x3d, 0x0e, 0x17, 0x96, 0x7d, 0xe6, + 0x33, 0x19, 0x45, 0xd1, 0x4a, 0x25, 0x16, 0x56, 0x7d, 0xc6, 0xfc, 0x26, 0x41, 0xb8, 0x1d, 0x20, + 0x4c, 0x29, 0x13, 0x58, 0x04, 0x8c, 0x72, 0x1d, 0x35, 0xa7, 0x59, 0xda, 0x38, 0xc4, 0xad, 0x51, + 0x7c, 0x7d, 0x3a, 0x3e, 0x5e, 0x8d, 0x4a, 0x78, 0x8c, 0xb7, 0x18, 0x47, 0x2e, 0xe6, 0x04, 0x75, + 0x4b, 0x2e, 0x11, 0xb8, 0x84, 0x3c, 0x16, 0x50, 0x15, 0xb7, 0x96, 0x01, 0x7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x13, 0xda, 0xb3, 0xc8, 0x93, 0x8d, + 0x56, 0x40, 0x87, 0xce, 0xd7, 0x7a, 0xb7, 0xa4, 0x5e, 0x04, 0x8b, 0x09, 0x7a, 0x5d, 0xe1, 0x55, + 0xb9, 0x02, 0x29, 0x89, 0x68, 0x57, 0xf9, 0x76, 0xaf, 0xf2, 0x60, 0x7f, 0x60, 0x1a, 0x07, 0x03, + 0xd3, 0xf8, 0x36, 0x30, 0x8d, 0x37, 0x43, 0x33, 0x75, 0x30, 0x34, 0x53, 0x9f, 0x87, 0x66, 0xea, + 0x59, 0x39, 0xe6, 0x42, 0x5d, 0xb2, 0x89, 0x5d, 0x5e, 0x0c, 0xd8, 0x98, 0xe1, 0x45, 0x8c, 0x43, + 0xda, 0xd2, 0xcd, 0xca, 0x07, 0xbc, 0xfc, 0x2b, 0x00, 0x00, 0xff, 0xff, 0xe1, 0xe8, 0x0e, 0x15, + 0x8b, 0x06, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -464,8 +479,6 @@ type QueryClient interface { RewardGauges(ctx context.Context, in *QueryRewardGaugesRequest, opts ...grpc.CallOption) (*QueryRewardGaugesResponse, error) // BTCStakingGauge queries the BTC staking gauge of a given height BTCStakingGauge(ctx context.Context, in *QueryBTCStakingGaugeRequest, opts ...grpc.CallOption) (*QueryBTCStakingGaugeResponse, error) - // BTCTimestampingGauge queries the BTC timestamping gauge of a given epoch - BTCTimestampingGauge(ctx context.Context, in *QueryBTCTimestampingGaugeRequest, opts ...grpc.CallOption) (*QueryBTCTimestampingGaugeResponse, error) } type queryClient struct { @@ -503,15 +516,6 @@ func (c *queryClient) BTCStakingGauge(ctx context.Context, in *QueryBTCStakingGa return out, nil } -func (c *queryClient) BTCTimestampingGauge(ctx context.Context, in *QueryBTCTimestampingGaugeRequest, opts ...grpc.CallOption) (*QueryBTCTimestampingGaugeResponse, error) { - out := new(QueryBTCTimestampingGaugeResponse) - err := c.cc.Invoke(ctx, "/babylon.incentive.Query/BTCTimestampingGauge", in, out, opts...) - if err != nil { - return nil, err - } - return out, nil -} - // QueryServer is the server API for Query service. type QueryServer interface { // Parameters queries the parameters of the module. @@ -520,8 +524,6 @@ type QueryServer interface { RewardGauges(context.Context, *QueryRewardGaugesRequest) (*QueryRewardGaugesResponse, error) // BTCStakingGauge queries the BTC staking gauge of a given height BTCStakingGauge(context.Context, *QueryBTCStakingGaugeRequest) (*QueryBTCStakingGaugeResponse, error) - // BTCTimestampingGauge queries the BTC timestamping gauge of a given epoch - BTCTimestampingGauge(context.Context, *QueryBTCTimestampingGaugeRequest) (*QueryBTCTimestampingGaugeResponse, error) } // UnimplementedQueryServer can be embedded to have forward compatible implementations. @@ -537,9 +539,6 @@ func (*UnimplementedQueryServer) RewardGauges(ctx context.Context, req *QueryRew func (*UnimplementedQueryServer) BTCStakingGauge(ctx context.Context, req *QueryBTCStakingGaugeRequest) (*QueryBTCStakingGaugeResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method BTCStakingGauge not implemented") } -func (*UnimplementedQueryServer) BTCTimestampingGauge(ctx context.Context, req *QueryBTCTimestampingGaugeRequest) (*QueryBTCTimestampingGaugeResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method BTCTimestampingGauge not implemented") -} func RegisterQueryServer(s grpc1.Server, srv QueryServer) { s.RegisterService(&_Query_serviceDesc, srv) @@ -599,24 +598,6 @@ func _Query_BTCStakingGauge_Handler(srv interface{}, ctx context.Context, dec fu return interceptor(ctx, in, info, handler) } -func _Query_BTCTimestampingGauge_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(QueryBTCTimestampingGaugeRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(QueryServer).BTCTimestampingGauge(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/babylon.incentive.Query/BTCTimestampingGauge", - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(QueryServer).BTCTimestampingGauge(ctx, req.(*QueryBTCTimestampingGaugeRequest)) - } - return interceptor(ctx, in, info, handler) -} - var _Query_serviceDesc = grpc.ServiceDesc{ ServiceName: "babylon.incentive.Query", HandlerType: (*QueryServer)(nil), @@ -633,10 +614,6 @@ var _Query_serviceDesc = grpc.ServiceDesc{ MethodName: "BTCStakingGauge", Handler: _Query_BTCStakingGauge_Handler, }, - { - MethodName: "BTCTimestampingGauge", - Handler: _Query_BTCTimestampingGauge_Handler, - }, }, Streams: []grpc.StreamDesc{}, Metadata: "babylon/incentive/query.proto", @@ -728,6 +705,57 @@ func (m *QueryRewardGaugesRequest) MarshalToSizedBuffer(dAtA []byte) (int, error return len(dAtA) - i, nil } +func (m *RewardGaugesResponse) 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 *RewardGaugesResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *RewardGaugesResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.WithdrawnCoins) > 0 { + for iNdEx := len(m.WithdrawnCoins) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.WithdrawnCoins[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + } + } + if len(m.Coins) > 0 { + for iNdEx := len(m.Coins) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.Coins[iNdEx].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 *QueryRewardGaugesResponse) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) @@ -805,7 +833,7 @@ func (m *QueryBTCStakingGaugeRequest) MarshalToSizedBuffer(dAtA []byte) (int, er return len(dAtA) - i, nil } -func (m *QueryBTCStakingGaugeResponse) Marshal() (dAtA []byte, err error) { +func (m *BTCStakingGaugeResponse) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalToSizedBuffer(dAtA[:size]) @@ -815,60 +843,34 @@ func (m *QueryBTCStakingGaugeResponse) Marshal() (dAtA []byte, err error) { return dAtA[:n], nil } -func (m *QueryBTCStakingGaugeResponse) MarshalTo(dAtA []byte) (int, error) { +func (m *BTCStakingGaugeResponse) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *QueryBTCStakingGaugeResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *BTCStakingGaugeResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) _ = i var l int _ = l - if m.Gauge != nil { - { - size, err := m.Gauge.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err + if len(m.Coins) > 0 { + for iNdEx := len(m.Coins) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.Coins[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) } - i -= size - i = encodeVarintQuery(dAtA, i, uint64(size)) + i-- + dAtA[i] = 0xa } - i-- - dAtA[i] = 0xa - } - return len(dAtA) - i, nil -} - -func (m *QueryBTCTimestampingGaugeRequest) 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 *QueryBTCTimestampingGaugeRequest) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *QueryBTCTimestampingGaugeRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if m.EpochNum != 0 { - i = encodeVarintQuery(dAtA, i, uint64(m.EpochNum)) - i-- - dAtA[i] = 0x8 } return len(dAtA) - i, nil } -func (m *QueryBTCTimestampingGaugeResponse) Marshal() (dAtA []byte, err error) { +func (m *QueryBTCStakingGaugeResponse) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalToSizedBuffer(dAtA[:size]) @@ -878,12 +880,12 @@ func (m *QueryBTCTimestampingGaugeResponse) Marshal() (dAtA []byte, err error) { return dAtA[:n], nil } -func (m *QueryBTCTimestampingGaugeResponse) MarshalTo(dAtA []byte) (int, error) { +func (m *QueryBTCStakingGaugeResponse) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *QueryBTCTimestampingGaugeResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *QueryBTCStakingGaugeResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) _ = i var l int @@ -947,6 +949,27 @@ func (m *QueryRewardGaugesRequest) Size() (n int) { return n } +func (m *RewardGaugesResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if len(m.Coins) > 0 { + for _, e := range m.Coins { + l = e.Size() + n += 1 + l + sovQuery(uint64(l)) + } + } + if len(m.WithdrawnCoins) > 0 { + for _, e := range m.WithdrawnCoins { + l = e.Size() + n += 1 + l + sovQuery(uint64(l)) + } + } + return n +} + func (m *QueryRewardGaugesResponse) Size() (n int) { if m == nil { return 0 @@ -981,32 +1004,22 @@ func (m *QueryBTCStakingGaugeRequest) Size() (n int) { return n } -func (m *QueryBTCStakingGaugeResponse) Size() (n int) { +func (m *BTCStakingGaugeResponse) Size() (n int) { if m == nil { return 0 } var l int _ = l - if m.Gauge != nil { - l = m.Gauge.Size() - n += 1 + l + sovQuery(uint64(l)) - } - return n -} - -func (m *QueryBTCTimestampingGaugeRequest) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if m.EpochNum != 0 { - n += 1 + sovQuery(uint64(m.EpochNum)) + if len(m.Coins) > 0 { + for _, e := range m.Coins { + l = e.Size() + n += 1 + l + sovQuery(uint64(l)) + } } return n } -func (m *QueryBTCTimestampingGaugeResponse) Size() (n int) { +func (m *QueryBTCStakingGaugeResponse) Size() (n int) { if m == nil { return 0 } @@ -1240,6 +1253,124 @@ func (m *QueryRewardGaugesRequest) Unmarshal(dAtA []byte) error { } return nil } +func (m *RewardGaugesResponse) 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: RewardGaugesResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: RewardGaugesResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Coins", 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 + } + m.Coins = append(m.Coins, types.Coin{}) + if err := m.Coins[len(m.Coins)-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 WithdrawnCoins", 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 + } + m.WithdrawnCoins = append(m.WithdrawnCoins, types.Coin{}) + if err := m.WithdrawnCoins[len(m.WithdrawnCoins)-1].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 *QueryRewardGaugesResponse) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 @@ -1299,10 +1430,10 @@ func (m *QueryRewardGaugesResponse) Unmarshal(dAtA []byte) error { return io.ErrUnexpectedEOF } if m.RewardGauges == nil { - m.RewardGauges = make(map[string]*RewardGauge) + m.RewardGauges = make(map[string]*RewardGaugesResponse) } var mapkey string - var mapvalue *RewardGauge + var mapvalue *RewardGaugesResponse for iNdEx < postIndex { entryPreIndex := iNdEx var wire uint64 @@ -1376,7 +1507,7 @@ func (m *QueryRewardGaugesResponse) Unmarshal(dAtA []byte) error { if postmsgIndex > l { return io.ErrUnexpectedEOF } - mapvalue = &RewardGauge{} + mapvalue = &RewardGaugesResponse{} if err := mapvalue.Unmarshal(dAtA[iNdEx:postmsgIndex]); err != nil { return err } @@ -1488,7 +1619,7 @@ func (m *QueryBTCStakingGaugeRequest) Unmarshal(dAtA []byte) error { } return nil } -func (m *QueryBTCStakingGaugeResponse) Unmarshal(dAtA []byte) error { +func (m *BTCStakingGaugeResponse) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -1511,15 +1642,15 @@ func (m *QueryBTCStakingGaugeResponse) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: QueryBTCStakingGaugeResponse: wiretype end group for non-group") + return fmt.Errorf("proto: BTCStakingGaugeResponse: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: QueryBTCStakingGaugeResponse: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: BTCStakingGaugeResponse: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Gauge", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field Coins", wireType) } var msglen int for shift := uint(0); ; shift += 7 { @@ -1546,10 +1677,8 @@ func (m *QueryBTCStakingGaugeResponse) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - if m.Gauge == nil { - m.Gauge = &Gauge{} - } - if err := m.Gauge.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + m.Coins = append(m.Coins, types.Coin{}) + if err := m.Coins[len(m.Coins)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } iNdEx = postIndex @@ -1574,76 +1703,7 @@ func (m *QueryBTCStakingGaugeResponse) Unmarshal(dAtA []byte) error { } return nil } -func (m *QueryBTCTimestampingGaugeRequest) 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: QueryBTCTimestampingGaugeRequest: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: QueryBTCTimestampingGaugeRequest: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field EpochNum", wireType) - } - m.EpochNum = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowQuery - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.EpochNum |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - 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 *QueryBTCTimestampingGaugeResponse) Unmarshal(dAtA []byte) error { +func (m *QueryBTCStakingGaugeResponse) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -1666,10 +1726,10 @@ func (m *QueryBTCTimestampingGaugeResponse) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: QueryBTCTimestampingGaugeResponse: wiretype end group for non-group") + return fmt.Errorf("proto: QueryBTCStakingGaugeResponse: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: QueryBTCTimestampingGaugeResponse: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: QueryBTCStakingGaugeResponse: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: @@ -1702,7 +1762,7 @@ func (m *QueryBTCTimestampingGaugeResponse) Unmarshal(dAtA []byte) error { return io.ErrUnexpectedEOF } if m.Gauge == nil { - m.Gauge = &Gauge{} + m.Gauge = &BTCStakingGaugeResponse{} } if err := m.Gauge.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err diff --git a/x/incentive/types/query.pb.gw.go b/x/incentive/types/query.pb.gw.go index 584a8f9c2..27215ac49 100644 --- a/x/incentive/types/query.pb.gw.go +++ b/x/incentive/types/query.pb.gw.go @@ -159,60 +159,6 @@ func local_request_Query_BTCStakingGauge_0(ctx context.Context, marshaler runtim } -func request_Query_BTCTimestampingGauge_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq QueryBTCTimestampingGaugeRequest - var metadata runtime.ServerMetadata - - var ( - val string - ok bool - err error - _ = err - ) - - val, ok = pathParams["epoch_num"] - if !ok { - return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "epoch_num") - } - - protoReq.EpochNum, err = runtime.Uint64(val) - - if err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "epoch_num", err) - } - - msg, err := client.BTCTimestampingGauge(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) - return msg, metadata, err - -} - -func local_request_Query_BTCTimestampingGauge_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq QueryBTCTimestampingGaugeRequest - var metadata runtime.ServerMetadata - - var ( - val string - ok bool - err error - _ = err - ) - - val, ok = pathParams["epoch_num"] - if !ok { - return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "epoch_num") - } - - protoReq.EpochNum, err = runtime.Uint64(val) - - if err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "epoch_num", err) - } - - msg, err := server.BTCTimestampingGauge(ctx, &protoReq) - return msg, metadata, err - -} - // RegisterQueryHandlerServer registers the http handlers for service Query to "mux". // UnaryRPC :call QueryServer directly. // StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906. @@ -288,29 +234,6 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv }) - mux.Handle("GET", pattern_Query_BTCTimestampingGauge_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { - ctx, cancel := context.WithCancel(req.Context()) - defer cancel() - var stream runtime.ServerTransportStream - ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) - inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - resp, md, err := local_request_Query_BTCTimestampingGauge_0(rctx, inboundMarshaler, server, req, pathParams) - md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) - ctx = runtime.NewServerMetadataContext(ctx, md) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - - forward_Query_BTCTimestampingGauge_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - - }) - return nil } @@ -412,26 +335,6 @@ func RegisterQueryHandlerClient(ctx context.Context, mux *runtime.ServeMux, clie }) - mux.Handle("GET", pattern_Query_BTCTimestampingGauge_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { - ctx, cancel := context.WithCancel(req.Context()) - defer cancel() - inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - rctx, err := runtime.AnnotateContext(ctx, mux, req) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - resp, md, err := request_Query_BTCTimestampingGauge_0(rctx, inboundMarshaler, client, req, pathParams) - ctx = runtime.NewServerMetadataContext(ctx, md) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - - forward_Query_BTCTimestampingGauge_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - - }) - return nil } @@ -441,8 +344,6 @@ var ( pattern_Query_RewardGauges_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 1, 0, 4, 1, 5, 2, 2, 3}, []string{"babylon", "incentive", "address", "reward_gauge"}, "", runtime.AssumeColonVerbOpt(false))) pattern_Query_BTCStakingGauge_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 1, 0, 4, 1, 5, 3}, []string{"babylon", "incentive", "btc_staking_gauge", "height"}, "", runtime.AssumeColonVerbOpt(false))) - - pattern_Query_BTCTimestampingGauge_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 1, 0, 4, 1, 5, 3}, []string{"babylon", "incentive", "btc_timestamping_gauge", "epoch_num"}, "", runtime.AssumeColonVerbOpt(false))) ) var ( @@ -451,6 +352,4 @@ var ( forward_Query_RewardGauges_0 = runtime.ForwardResponseMessage forward_Query_BTCStakingGauge_0 = runtime.ForwardResponseMessage - - forward_Query_BTCTimestampingGauge_0 = runtime.ForwardResponseMessage ) diff --git a/x/incentive/types/tx.pb.go b/x/incentive/types/tx.pb.go index 6d52b0959..93306f8d7 100644 --- a/x/incentive/types/tx.pb.go +++ b/x/incentive/types/tx.pb.go @@ -34,7 +34,7 @@ const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package // MsgWithdrawReward defines a message for withdrawing reward of a stakeholder. type MsgWithdrawReward struct { - // {submitter, reporter, finality_provider, btc_delegation} + // {finality_provider, btc_delegation} Type string `protobuf:"bytes,1,opt,name=type,proto3" json:"type,omitempty"` // address is the address of the stakeholder in bech32 string // signer of this msg has to be this address diff --git a/x/incentive/types/types.go b/x/incentive/types/types.go index ab1254f4c..b2cb2d67b 100644 --- a/x/incentive/types/types.go +++ b/x/incentive/types/types.go @@ -1 +1,12 @@ package types + +import ( + "github.com/cometbft/cometbft/crypto/tmhash" + sdk "github.com/cosmos/cosmos-sdk/types" +) + +func HashMsg(msg sdk.Msg) []byte { + msgBytes := ModuleCdc.MustMarshal(msg) + msgHash := tmhash.Sum(msgBytes) + return msgHash +} diff --git a/x/mint/README.md b/x/mint/README.md new file mode 100644 index 000000000..7fbf86428 --- /dev/null +++ b/x/mint/README.md @@ -0,0 +1,153 @@ +# `x/mint` + +- [Abstract](#abstract) + - [Inflation Schedule](#inflation-schedule) +- [Terms](#terms) +- [State](#state) +- [State Transitions](#state-transitions) + - [Begin Block](#begin-block) + - [Events](#events) +- [Client](#client) + - [CLI](#cli) +- [Genesis State](#genesis-state) +- [Params](#params) +- [Assumptions and Considerations](#assumptions-and-considerations) +- [Implementation](#implementation) +- [References](#references) + +## Abstract + +Babylon's `x/mint` is a fork of the Cosmos SDK +[`x/mint`](https://github.com/cosmos/cosmos-sdk/tree/main/x/mint) module that +makes some changes to the inflation mechanism. The code is adapted from +[Celestia's mint +module](https://github.com/celestiaorg/celestia-app/tree/main/x/mint). + +### Inflation Schedule + +| Year | Inflation (%) | +| ---- | ----------------- | +| 0 | 8.00 | +| 1 | 7.20 | +| 2 | 6.48 | +| 3 | 5.832 | +| 4 | 5.2488 | +| 5 | 4.72392 | +| 6 | 4.251528 | +| 7 | 3.8263752 | +| 8 | 3.44373768 | +| 9 | 3.099363912 | +| 10 | 2.7894275208 | +| 11 | 2.51048476872 | +| 12 | 2.259436291848 | +| 13 | 2.0334926626632 | +| 14 | 1.83014339639688 | +| 15 | 1.647129056757192 | +| 16 | 1.50 | +| 17 | 1.50 | +| 18 | 1.50 | +| 19 | 1.50 | +| 20 | 1.50 | + +- **Year** indicates the number of years elapsed since chain genesis. +- **Inflation (%)** indicates the percentage of the total supply that will be + minted in the next year. + +## Terms + +- **Inflation Rate**: The percentage of the total supply that will be minted + each year. The inflation rate is calculated once per year on the anniversary + of chain genesis based on the number of years elapsed since genesis. The + inflation rate is calculated as `InitialInflationRate * ((1 - + DisinflationRate) ^ YearsSinceGenesis)`. See + [./types/constants.go](./types/constants.go) for the constants used in this + module. +- **Annual Provisions**: The total amount of tokens that will be minted each + year. Annual provisions are calculated once per year on the anniversary of + chain genesis based on the total supply and the inflation rate. Annual + provisions are calculated as `TotalSupply * InflationRate` +- **Block Provision**: The amount of tokens that will be minted in the current + block. Block provisions are calculated once per block based on the annual + provisions and the number of nanoseconds elapsed between the current block and + the previous block. Block provisions are calculated as `AnnualProvisions * + (NanosecondsSincePreviousBlock / NanosecondsPerYear)` + +## State + +See [./types/minter.go](./types/minter.go) for the `Minter` struct which +contains this module's state. + +## State Transitions + +The `Minter` struct is updated every block via `BeginBlocker`. + +### Begin Block + +See `BeginBlocker` in [./abci.go](./abci.go). + +### Events + +An event is emitted every block when a block provision is minted. See +`mintBlockProvision` in [./abci.go](./abci.go). + +## Client + +### CLI + +```shell +$ babylond query mint annual-provisions +80235005639941.760000000000000000 +``` + +```shell +$ babylond query mint genesis-time +2023-05-09 00:56:15.59304 +0000 UTC +``` + +```shell +$ babylond query mint inflation +0.080000000000000000 +``` + +## Genesis State + +The genesis state is defined in [./types/genesis.go](./types/genesis.go). + +## Params + +All params have been removed from this module because they should not be +modifiable via governance. The constants used in this module are defined in +[./types/constants.go](./types/constants.go) and they are subject to change via +hardforks. + +## Assumptions and Considerations + +> For the Gregorian calendar, the average length of the calendar year (the mean +> year) across the complete leap cycle of 400 years is 365.2425 days (97 out of +> 400 years are leap years). + +Source: + +This module assumes `DaysPerYear = 365.2425` so when modifying tests, developers +must define durations based on this assumption because ordinary durations won't +return the expected results. In other words: + +```go +// oneYear is 31,556,952 seconds which will likely return expected results in tests +oneYear := time.Duration(minttypes.NanosecondsPerYear) + +// oneYear is 31,536,000 seconds which will likely return unexpected results in tests +oneYear := time.Hour * 24 * 365 +``` + +## Implementation + +See [x/mint](../../x/mint) for the implementation of this module. + +## References + +1. [ADR-031](https://github.com/babylonlabs-io/pm/blob/main/adr/adr-031-mint-module.md) +2. [Celestia's + ADR-019](https://github.com/celestiaorg/celestia-app/tree/main/docs/architecture/adr-019-strict-inflation-schedule.md) +3. [Celestia's mint + module](https://github.com/celestiaorg/celestia-app/tree/main/x/mint) diff --git a/x/mint/abci.go b/x/mint/abci.go new file mode 100644 index 000000000..dcb7257e1 --- /dev/null +++ b/x/mint/abci.go @@ -0,0 +1,103 @@ +package mint + +import ( + "context" + "time" + + "github.com/babylonlabs-io/babylon/x/mint/keeper" + "github.com/babylonlabs-io/babylon/x/mint/types" + "github.com/cosmos/cosmos-sdk/telemetry" + sdk "github.com/cosmos/cosmos-sdk/types" +) + +// BeginBlocker updates the inflation rate, annual provisions, and then mints +// the block provision for the current block. +func BeginBlocker(ctx context.Context, k keeper.Keeper) { + defer telemetry.ModuleMeasureSince(types.ModuleName, time.Now(), telemetry.MetricKeyBeginBlocker) + + maybeUpdateMinter(ctx, k) + mintBlockProvision(ctx, k) + setPreviousBlockTime(ctx, k) +} + +// maybeUpdateMinter updates the inflation rate and annual provisions if the +// inflation rate has changed. The inflation rate is expected to change once per +// year at the genesis time anniversary until the TargetInflationRate is +// reached. +func maybeUpdateMinter(ctx context.Context, k keeper.Keeper) { + minter := k.GetMinter(ctx) + genesisTime := k.GetGenesisTime(ctx).GenesisTime + sdkCtx := sdk.UnwrapSDKContext(ctx) + newInflationRate := minter.CalculateInflationRate(sdkCtx, *genesisTime) + + isNonZeroAnnualProvisions := !minter.AnnualProvisions.IsZero() + if newInflationRate.Equal(minter.InflationRate) && isNonZeroAnnualProvisions { + // The minter's InflationRate and AnnualProvisions already reflect the + // values for this year. Exit early because we don't need to update + // them. AnnualProvisions must be updated if it is zero (expected at + // genesis). + return + } + + totalSupply, err := k.StakingTokenSupply(ctx) + if err != nil { + panic(err) + } + + minter.InflationRate = newInflationRate + minter.AnnualProvisions = newInflationRate.MulInt(totalSupply) + if err := k.SetMinter(ctx, minter); err != nil { + panic(err) + } +} + +// mintBlockProvision mints the block provision for the current block. +func mintBlockProvision(ctx context.Context, k keeper.Keeper) { + minter := k.GetMinter(ctx) + if minter.PreviousBlockTime == nil { + // exit early if previous block time is nil + // this is expected to happen for block height = 1 + return + } + + sdkCtx := sdk.UnwrapSDKContext(ctx) + + toMintCoin, err := minter.CalculateBlockProvision(sdkCtx.BlockTime(), *minter.PreviousBlockTime) + if err != nil { + panic(err) + } + toMintCoins := sdk.NewCoins(toMintCoin) + + err = k.MintCoins(ctx, toMintCoins) + if err != nil { + panic(err) + } + + err = k.SendCoinsToFeeCollector(ctx, toMintCoins) + if err != nil { + panic(err) + } + + if toMintCoin.Amount.IsInt64() { + defer telemetry.ModuleSetGauge(types.ModuleName, float32(toMintCoin.Amount.Int64()), "minted_tokens") + } + + sdkCtx.EventManager().EmitEvent( + sdk.NewEvent( + types.EventTypeMint, + sdk.NewAttribute(types.AttributeKeyInflationRate, minter.InflationRate.String()), + sdk.NewAttribute(types.AttributeKeyAnnualProvisions, minter.AnnualProvisions.String()), + sdk.NewAttribute(sdk.AttributeKeyAmount, toMintCoin.Amount.String()), + ), + ) +} + +func setPreviousBlockTime(ctx context.Context, k keeper.Keeper) { + minter := k.GetMinter(ctx) + sdkCtx := sdk.UnwrapSDKContext(ctx) + blockTime := sdkCtx.BlockTime() + minter.PreviousBlockTime = &blockTime + if err := k.SetMinter(ctx, minter); err != nil { + panic(err) + } +} diff --git a/x/mint/abci_test.go b/x/mint/abci_test.go new file mode 100644 index 000000000..e50be7b6b --- /dev/null +++ b/x/mint/abci_test.go @@ -0,0 +1,134 @@ +package mint_test + +import ( + "fmt" + "testing" + "time" + + "cosmossdk.io/log" + "cosmossdk.io/math" + "github.com/babylonlabs-io/babylon/testutil/helper" + "github.com/babylonlabs-io/babylon/x/mint" + minttypes "github.com/babylonlabs-io/babylon/x/mint/types" + "github.com/cometbft/cometbft/proto/tendermint/types" + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" +) + +var oneYear = time.Duration(minttypes.NanosecondsPerYear) + +func TestInflationRate(t *testing.T) { + h := helper.NewHelper(t) + app := h.App + ctx := sdk.NewContext(app.CommitMultiStore(), types.Header{}, false, log.NewNopLogger()) + genesisTime := app.MintKeeper.GetGenesisTime(ctx).GenesisTime + + yearOneMinusOneSecond := genesisTime.Add(oneYear).Add(-time.Second) + yearOne := genesisTime.Add(oneYear) + yearTwo := genesisTime.Add(2 * oneYear) + yearFifteen := genesisTime.Add(15 * oneYear) + yearTwenty := genesisTime.Add(20 * oneYear) + + type testCase struct { + name string + ctx sdk.Context + want math.LegacyDec + } + + testCases := []testCase{ + { + name: "inflation rate is 0.08 for year zero", + ctx: ctx.WithBlockHeight(1).WithBlockTime(*genesisTime), + want: math.LegacyMustNewDecFromStr("0.08"), + }, + { + name: "inflation rate is 0.08 for year one minus one second", + ctx: ctx.WithBlockTime(yearOneMinusOneSecond), + want: math.LegacyMustNewDecFromStr("0.08"), + }, + { + name: "inflation rate is 0.072 for year one", + ctx: ctx.WithBlockTime(yearOne), + want: math.LegacyMustNewDecFromStr("0.072"), + }, + { + name: "inflation rate is 0.0648 for year two", + ctx: ctx.WithBlockTime(yearTwo), + want: math.LegacyMustNewDecFromStr("0.0648"), + }, + { + name: "inflation rate is 0.01647129056757192 for year fifteen", + ctx: ctx.WithBlockTime(yearFifteen), + want: math.LegacyMustNewDecFromStr("0.01647129056757192"), + }, + { + name: "inflation rate is 0.015 for year twenty", + ctx: ctx.WithBlockTime(yearTwenty), + want: math.LegacyMustNewDecFromStr("0.015"), + }, + } + + for _, tc := range testCases { + t.Run(tc.name, func(t *testing.T) { + mint.BeginBlocker(tc.ctx, app.MintKeeper) + got, err := app.MintKeeper.InflationRate(ctx, &minttypes.QueryInflationRateRequest{}) + assert.NoError(t, err) + assert.Equal(t, tc.want, got.InflationRate) + }) + } +} + +func TestAnnualProvisions(t *testing.T) { + t.Run("annual provisions are set after the chain starts", func(t *testing.T) { + h := helper.NewHelper(t) + a, ctx := h.App, h.Ctx + + assert.False(t, a.MintKeeper.GetMinter(ctx).AnnualProvisions.IsZero()) + }) + + t.Run("annual provisions are not updated more than once per year", func(t *testing.T) { + h := helper.NewHelper(t) + a, ctx := h.App, h.Ctx + + genesisTime := a.MintKeeper.GetGenesisTime(ctx).GenesisTime + yearOneMinusOneSecond := genesisTime.Add(oneYear).Add(-time.Second) + + initialSupply, err := a.StakingKeeper.StakingTokenSupply(ctx) + require.NoError(t, err) + stakingBondDenom, err := a.StakingKeeper.BondDenom(ctx) + require.NoError(t, err) + require.Equal(t, a.MintKeeper.GetMinter(ctx).BondDenom, stakingBondDenom) + + blockInterval := time.Second * 15 + + want := minttypes.InitialInflationRateAsDec().MulInt(initialSupply) + + type testCase struct { + height int64 + time time.Time + } + testCases := []testCase{ + {1, genesisTime.Add(blockInterval)}, + {2, genesisTime.Add(blockInterval * 2)}, + {3, yearOneMinusOneSecond}, + // testing annual provisions for years after year zero depends on the + // total supply which increased due to inflation in year zero. + } + + for _, tc := range testCases { + t.Run(fmt.Sprintf("block height %v", tc.height), func(t *testing.T) { + ctx = ctx.WithBlockHeight(tc.height).WithBlockTime(tc.time) + mint.BeginBlocker(ctx, a.MintKeeper) + assert.True(t, a.MintKeeper.GetMinter(ctx).AnnualProvisions.Equal(want)) + }) + } + + t.Run("one year later", func(t *testing.T) { + yearOne := genesisTime.Add(oneYear) + ctx = ctx.WithBlockHeight(5).WithBlockTime(yearOne) + mint.BeginBlocker(ctx, a.MintKeeper) + assert.False(t, a.MintKeeper.GetMinter(ctx).AnnualProvisions.Equal(want)) + }) + }) +} diff --git a/x/mint/client/cli/query.go b/x/mint/client/cli/query.go new file mode 100644 index 000000000..15f898f97 --- /dev/null +++ b/x/mint/client/cli/query.go @@ -0,0 +1,116 @@ +package cli + +import ( + "fmt" + + "github.com/spf13/cobra" + + "github.com/babylonlabs-io/babylon/x/mint/types" + "github.com/cosmos/cosmos-sdk/client" + "github.com/cosmos/cosmos-sdk/client/flags" +) + +// GetQueryCmd returns the CLI query commands for the mint module. +func GetQueryCmd() *cobra.Command { + mintQueryCmd := &cobra.Command{ + Use: types.ModuleName, + Short: "Querying commands for the mint module", + DisableFlagParsing: true, + SuggestionsMinimumDistance: 2, + RunE: client.ValidateCmd, + } + + mintQueryCmd.AddCommand( + GetCmdQueryInflationRate(), + GetCmdQueryAnnualProvisions(), + GetCmdQueryGenesisTime(), + ) + + return mintQueryCmd +} + +// GetCmdQueryInflationRate implements a command to return the current mint +// inflation rate. +func GetCmdQueryInflationRate() *cobra.Command { + cmd := &cobra.Command{ + Use: "inflation", + Short: "Query the current inflation rate", + Args: cobra.NoArgs, + RunE: func(cmd *cobra.Command, _ []string) error { + clientCtx, err := client.GetClientQueryContext(cmd) + if err != nil { + return err + } + queryClient := types.NewQueryClient(clientCtx) + + request := &types.QueryInflationRateRequest{} + res, err := queryClient.InflationRate(cmd.Context(), request) + if err != nil { + return err + } + + return clientCtx.PrintString(fmt.Sprintf("%s\n", res.InflationRate)) + }, + } + + flags.AddQueryFlagsToCmd(cmd) + + return cmd +} + +// GetCmdQueryAnnualProvisions implements a command to return the current mint +// annual provisions. +func GetCmdQueryAnnualProvisions() *cobra.Command { + cmd := &cobra.Command{ + Use: "annual-provisions", + Short: "Query the current annual provisions", + Args: cobra.NoArgs, + RunE: func(cmd *cobra.Command, _ []string) error { + clientCtx, err := client.GetClientQueryContext(cmd) + if err != nil { + return err + } + queryClient := types.NewQueryClient(clientCtx) + + request := &types.QueryAnnualProvisionsRequest{} + res, err := queryClient.AnnualProvisions(cmd.Context(), request) + if err != nil { + return err + } + + return clientCtx.PrintString(fmt.Sprintf("%s\n", res.AnnualProvisions)) + }, + } + + flags.AddQueryFlagsToCmd(cmd) + + return cmd +} + +// GetCmdQueryGenesisTime implements a command to return the genesis time. +func GetCmdQueryGenesisTime() *cobra.Command { + cmd := &cobra.Command{ + Use: "genesis-time", + Short: "Query the genesis time", + Args: cobra.NoArgs, + RunE: func(cmd *cobra.Command, _ []string) error { + clientCtx, err := client.GetClientQueryContext(cmd) + if err != nil { + return err + } + queryClient := types.NewQueryClient(clientCtx) + + request := &types.QueryGenesisTimeRequest{} + res, err := queryClient.GenesisTime(cmd.Context(), request) + if err != nil { + return err + } + + return clientCtx.PrintString(fmt.Sprintf("%s\n", res.GenesisTime)) + }, + } + + flags.AddQueryFlagsToCmd(cmd) + + return cmd +} diff --git a/x/mint/keeper/genesis.go b/x/mint/keeper/genesis.go new file mode 100644 index 000000000..afa0b5cc0 --- /dev/null +++ b/x/mint/keeper/genesis.go @@ -0,0 +1,33 @@ +package keeper + +import ( + "github.com/babylonlabs-io/babylon/x/mint/types" + sdk "github.com/cosmos/cosmos-sdk/types" +) + +// InitGenesis initializes the x/mint store with data from the genesis state. +func (k Keeper) InitGenesis(ctx sdk.Context, ak types.AccountKeeper, data *types.GenesisState) { + minter := types.DefaultMinter() + minter.BondDenom = data.BondDenom + if err := k.SetMinter(ctx, minter); err != nil { + panic(err) + } + // override the genesis time with the actual genesis time supplied in `InitChain` + blockTime := ctx.BlockTime() + gt := types.GenesisTime{ + GenesisTime: &blockTime, + } + if err := k.SetGenesisTime(ctx, gt); err != nil { + panic(err) + } + // Although ak.GetModuleAccount appears to be a no-op, it actually creates a + // new module account in the x/auth account store if it doesn't exist. See + // the x/auth keeper for more details. + ak.GetModuleAccount(ctx, types.ModuleName) +} + +// ExportGenesis returns a x/mint GenesisState for the given context. +func (k Keeper) ExportGenesis(ctx sdk.Context) *types.GenesisState { + bondDenom := k.GetMinter(ctx).BondDenom + return types.NewGenesisState(bondDenom) +} diff --git a/x/mint/keeper/grpc_query.go b/x/mint/keeper/grpc_query.go new file mode 100644 index 000000000..0779c5f63 --- /dev/null +++ b/x/mint/keeper/grpc_query.go @@ -0,0 +1,34 @@ +package keeper + +import ( + "context" + + "github.com/babylonlabs-io/babylon/x/mint/types" + sdk "github.com/cosmos/cosmos-sdk/types" +) + +var _ types.QueryServer = Keeper{} + +// InflationRate returns minter.InflationRate of the mint module. +func (k Keeper) InflationRate(c context.Context, _ *types.QueryInflationRateRequest) (*types.QueryInflationRateResponse, error) { + ctx := sdk.UnwrapSDKContext(c) + minter := k.GetMinter(ctx) + + return &types.QueryInflationRateResponse{InflationRate: minter.InflationRate}, nil +} + +// AnnualProvisions returns minter.AnnualProvisions of the mint module. +func (k Keeper) AnnualProvisions(c context.Context, _ *types.QueryAnnualProvisionsRequest) (*types.QueryAnnualProvisionsResponse, error) { + ctx := sdk.UnwrapSDKContext(c) + minter := k.GetMinter(ctx) + + return &types.QueryAnnualProvisionsResponse{AnnualProvisions: minter.AnnualProvisions}, nil +} + +// GenesisTime returns the GensisTime of the mint module. +func (k Keeper) GenesisTime(c context.Context, _ *types.QueryGenesisTimeRequest) (*types.QueryGenesisTimeResponse, error) { + ctx := sdk.UnwrapSDKContext(c) + genesisTime := k.GetGenesisTime(ctx).GenesisTime + + return &types.QueryGenesisTimeResponse{GenesisTime: genesisTime}, nil +} diff --git a/x/mint/keeper/grpc_query_test.go b/x/mint/keeper/grpc_query_test.go new file mode 100644 index 000000000..77d647941 --- /dev/null +++ b/x/mint/keeper/grpc_query_test.go @@ -0,0 +1,56 @@ +package keeper_test //nolint:all + +import ( + gocontext "context" + "testing" + + "github.com/stretchr/testify/suite" + + "github.com/babylonlabs-io/babylon/app" + "github.com/babylonlabs-io/babylon/testutil/helper" + "github.com/babylonlabs-io/babylon/x/mint/types" + "github.com/cosmos/cosmos-sdk/baseapp" + sdk "github.com/cosmos/cosmos-sdk/types" +) + +type MintTestSuite struct { + suite.Suite + + app *app.BabylonApp + ctx sdk.Context + queryClient types.QueryClient +} + +func (suite *MintTestSuite) SetupTest() { + h := helper.NewHelper(suite.T()) + testApp, ctx := h.App, h.Ctx + + queryHelper := baseapp.NewQueryServerTestHelper(ctx, testApp.InterfaceRegistry()) + types.RegisterQueryServer(queryHelper, testApp.MintKeeper) + queryClient := types.NewQueryClient(queryHelper) + + suite.app = testApp + suite.ctx = ctx + + suite.queryClient = queryClient +} + +func (suite *MintTestSuite) TestGRPC() { + app, ctx, queryClient := suite.app, suite.ctx, suite.queryClient + + inflation, err := queryClient.InflationRate(gocontext.Background(), &types.QueryInflationRateRequest{}) + suite.Require().NoError(err) + suite.Require().Equal(inflation.InflationRate, app.MintKeeper.GetMinter(ctx).InflationRate) + + annualProvisions, err := queryClient.AnnualProvisions(gocontext.Background(), &types.QueryAnnualProvisionsRequest{}) + suite.Require().NoError(err) + suite.Require().Equal(annualProvisions.AnnualProvisions, app.MintKeeper.GetMinter(ctx).AnnualProvisions) + + genesisTime, err := queryClient.GenesisTime(gocontext.Background(), &types.QueryGenesisTimeRequest{}) + suite.Require().NoError(err) + suite.Require().Equal(genesisTime.GenesisTime, app.MintKeeper.GetGenesisTime(ctx).GenesisTime) +} + +func TestMintTestSuite(t *testing.T) { + suite.Run(t, new(MintTestSuite)) +} diff --git a/x/mint/keeper/keeper.go b/x/mint/keeper/keeper.go new file mode 100644 index 000000000..5de927f49 --- /dev/null +++ b/x/mint/keeper/keeper.go @@ -0,0 +1,121 @@ +package keeper + +import ( + "context" + "fmt" + + "cosmossdk.io/collections" + "cosmossdk.io/core/store" + "cosmossdk.io/log" + "cosmossdk.io/math" + + "github.com/babylonlabs-io/babylon/x/mint/types" + "github.com/cosmos/cosmos-sdk/codec" + sdk "github.com/cosmos/cosmos-sdk/types" +) + +// Keeper of the mint store +type Keeper struct { + cdc codec.BinaryCodec + storeService store.KVStoreService + stakingKeeper types.StakingKeeper + bankKeeper types.BankKeeper + feeCollectorName string + // the address capable of executing a MsgUpdateParams message. Typically, this + // should be the x/gov module account. + authority string + + Schema collections.Schema + MinterStore collections.Item[types.Minter] + GenesisTimeStore collections.Item[types.GenesisTime] +} + +// NewKeeper creates a new mint Keeper instance. +func NewKeeper( + cdc codec.BinaryCodec, + storeService store.KVStoreService, + stakingKeeper types.StakingKeeper, + ak types.AccountKeeper, + bankKeeper types.BankKeeper, + feeCollectorName string, + authority string, +) Keeper { + // Ensure the mint module account has been set + if addr := ak.GetModuleAddress(types.ModuleName); addr == nil { + panic("the mint module account has not been set") + } + + sb := collections.NewSchemaBuilder(storeService) + k := Keeper{ + cdc: cdc, + storeService: storeService, + stakingKeeper: stakingKeeper, + bankKeeper: bankKeeper, + feeCollectorName: feeCollectorName, + authority: authority, + MinterStore: collections.NewItem(sb, types.MinterKey, "minter", codec.CollValue[types.Minter](cdc)), + GenesisTimeStore: collections.NewItem(sb, types.GenesisTimeKey, "genesis_time", codec.CollValue[types.GenesisTime](cdc)), + } + + schema, err := sb.Build() + if err != nil { + panic(err) + } + k.Schema = schema + + return k +} + +func (k Keeper) Logger(ctx sdk.Context) log.Logger { + return ctx.Logger().With("module", fmt.Sprintf("x/%s", types.ModuleName)) +} + +// GetMinter returns the minter. +func (k Keeper) GetMinter(ctx context.Context) types.Minter { + minter, err := k.MinterStore.Get(ctx) + if err != nil { + panic(err) + } + return minter +} + +// SetMinter sets the minter. +func (k Keeper) SetMinter(ctx context.Context, minter types.Minter) error { + return k.MinterStore.Set(ctx, minter) +} + +// GetGenesisTime returns the genesis time. +func (k Keeper) GetGenesisTime(ctx context.Context) (gt types.GenesisTime) { + genesisTime, err := k.GenesisTimeStore.Get(ctx) + if err != nil { + panic(err) + } + return genesisTime +} + +// SetGenesisTime sets the genesis time. +func (k Keeper) SetGenesisTime(ctx context.Context, gt types.GenesisTime) error { + return k.GenesisTimeStore.Set(ctx, gt) +} + +// StakingTokenSupply implements an alias call to the underlying staking keeper's +// StakingTokenSupply. +func (k Keeper) StakingTokenSupply(ctx context.Context) (math.Int, error) { + return k.stakingKeeper.StakingTokenSupply(ctx) +} + +// MintCoins implements an alias call to the underlying bank keeper's +// MintCoins. +func (k Keeper) MintCoins(ctx context.Context, newCoins sdk.Coins) error { + if newCoins.Empty() { + return nil + } + + return k.bankKeeper.MintCoins(ctx, types.ModuleName, newCoins) +} + +// SendCoinsToFeeCollector sends newly minted coins from the x/mint module to +// the x/auth fee collector module account. +func (k Keeper) SendCoinsToFeeCollector(ctx context.Context, coins sdk.Coins) error { + return k.bankKeeper.SendCoinsFromModuleToModule(ctx, types.ModuleName, k.feeCollectorName, coins) +} diff --git a/x/mint/module.go b/x/mint/module.go new file mode 100644 index 000000000..d92c904f6 --- /dev/null +++ b/x/mint/module.go @@ -0,0 +1,165 @@ +package mint + +import ( + "context" + "encoding/json" + "fmt" + + "cosmossdk.io/core/appmodule" + abci "github.com/cometbft/cometbft/abci/types" + "github.com/grpc-ecosystem/grpc-gateway/runtime" + "github.com/spf13/cobra" + + "github.com/babylonlabs-io/babylon/x/mint/client/cli" + "github.com/babylonlabs-io/babylon/x/mint/keeper" + "github.com/babylonlabs-io/babylon/x/mint/types" + "github.com/cosmos/cosmos-sdk/client" + "github.com/cosmos/cosmos-sdk/codec" + cdctypes "github.com/cosmos/cosmos-sdk/codec/types" + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/cosmos-sdk/types/module" + simtypes "github.com/cosmos/cosmos-sdk/types/simulation" +) + +var ( + _ module.AppModule = AppModule{} + _ module.AppModuleBasic = AppModuleBasic{} + _ appmodule.HasBeginBlocker = AppModule{} +) + +// AppModuleBasic defines the basic application module used by the mint module. +type AppModuleBasic struct { + cdc codec.Codec +} + +var _ module.AppModuleBasic = AppModuleBasic{} + +// Name returns the mint module's name. +func (AppModuleBasic) Name() string { + return types.ModuleName +} + +// RegisterLegacyAminoCodec registers the mint module's types on the given LegacyAmino codec. +func (AppModuleBasic) RegisterLegacyAminoCodec(_ *codec.LegacyAmino) {} + +// RegisterInterfaces registers the module's interface types +func (b AppModuleBasic) RegisterInterfaces(_ cdctypes.InterfaceRegistry) {} + +// DefaultGenesis returns default genesis state as raw bytes for the mint +// module. +func (AppModuleBasic) DefaultGenesis(cdc codec.JSONCodec) json.RawMessage { + return cdc.MustMarshalJSON(types.DefaultGenesisState()) +} + +// ValidateGenesis performs genesis state validation for the mint module. +func (AppModuleBasic) ValidateGenesis(cdc codec.JSONCodec, _ client.TxEncodingConfig, bz json.RawMessage) error { + var data types.GenesisState + if err := cdc.UnmarshalJSON(bz, &data); err != nil { + return fmt.Errorf("failed to unmarshal %s genesis state: %w", types.ModuleName, err) + } + + return types.ValidateGenesis(data) +} + +// RegisterGRPCGatewayRoutes registers the gRPC Gateway routes for the mint module. +func (AppModuleBasic) RegisterGRPCGatewayRoutes(clientCtx client.Context, mux *runtime.ServeMux) { + if err := types.RegisterQueryHandlerClient(context.Background(), mux, types.NewQueryClient(clientCtx)); err != nil { + panic(err) + } +} + +// GetTxCmd returns no root tx command for the mint module. +func (AppModuleBasic) GetTxCmd() *cobra.Command { return nil } + +// GetQueryCmd returns the root query command for the mint module. +func (AppModuleBasic) GetQueryCmd() *cobra.Command { + return cli.GetQueryCmd() +} + +// AppModule implements an application module for the mint module. +type AppModule struct { + AppModuleBasic + + keeper keeper.Keeper + authKeeper types.AccountKeeper +} + +// NewAppModule creates a new AppModule object. If the InflationCalculationFn +// argument is nil, then the SDK's default inflation function will be used. +func NewAppModule(cdc codec.Codec, keeper keeper.Keeper, ak types.AccountKeeper) AppModule { + return AppModule{ + AppModuleBasic: AppModuleBasic{cdc: cdc}, + keeper: keeper, + authKeeper: ak, + } +} + +// Name returns the mint module's name. +func (AppModule) Name() string { + return types.ModuleName +} + +// RegisterInvariants registers the mint module invariants. +func (am AppModule) RegisterInvariants(_ sdk.InvariantRegistry) {} + +// QuerierRoute returns the mint module's querier route name. +func (AppModule) QuerierRoute() string { + return types.QuerierRoute +} + +// RegisterServices registers a gRPC query service to respond to the +// module-specific gRPC queries. +func (am AppModule) RegisterServices(cfg module.Configurator) { + types.RegisterQueryServer(cfg.QueryServer(), am.keeper) +} + +// InitGenesis performs genesis initialization for the mint module. It returns +// no validator updates. +func (am AppModule) InitGenesis(ctx sdk.Context, cdc codec.JSONCodec, data json.RawMessage) []abci.ValidatorUpdate { + var genesisState types.GenesisState + cdc.MustUnmarshalJSON(data, &genesisState) + + am.keeper.InitGenesis(ctx, am.authKeeper, &genesisState) + return []abci.ValidatorUpdate{} +} + +// ExportGenesis returns the exported genesis state as raw bytes for the mint +// module. +func (am AppModule) ExportGenesis(ctx sdk.Context, cdc codec.JSONCodec) json.RawMessage { + gs := am.keeper.ExportGenesis(ctx) + return cdc.MustMarshalJSON(gs) +} + +// ConsensusVersion implements AppModule/ConsensusVersion. +func (AppModule) ConsensusVersion() uint64 { return 1 } + +// BeginBlock returns the begin blocker for the mint module. +func (am AppModule) BeginBlock(ctx context.Context) error { + BeginBlocker(ctx, am.keeper) + return nil +} + +// AppModuleSimulation functions + +// GenerateGenesisState is a no-op. +func (AppModule) GenerateGenesisState(_ *module.SimulationState) { + // no-op +} + +// ProposalContents doesn't return any content functions for governance proposals. +func (AppModule) ProposalContents(_ module.SimulationState) []simtypes.WeightedProposalMsg { + return nil +} + +// WeightedOperations doesn't return any mint module operation. +func (AppModule) WeightedOperations(_ module.SimulationState) []simtypes.WeightedOperation { + return nil +} + +// IsOnePerModuleType implements the depinject.OnePerModuleType interface. +func (am AppModule) IsOnePerModuleType() { // marker +} + +// IsAppModule implements the appmodule.AppModule interface. +func (am AppModule) IsAppModule() { // marker +} diff --git a/x/mint/module_test.go b/x/mint/module_test.go new file mode 100644 index 000000000..2bb48a10c --- /dev/null +++ b/x/mint/module_test.go @@ -0,0 +1,18 @@ +package mint_test + +import ( + "testing" + + "github.com/babylonlabs-io/babylon/testutil/helper" + "github.com/babylonlabs-io/babylon/x/mint/types" + authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" + "github.com/stretchr/testify/require" +) + +func TestItCreatesModuleAccountOnInitBlock(t *testing.T) { + h := helper.NewHelper(t) + app, ctx := h.App, h.Ctx + + acc := app.AccountKeeper.GetAccount(ctx, authtypes.NewModuleAddress(types.ModuleName)) + require.NotNil(t, acc) +} diff --git a/x/mint/simulation/decoder.go b/x/mint/simulation/decoder.go new file mode 100644 index 000000000..1f0298b84 --- /dev/null +++ b/x/mint/simulation/decoder.go @@ -0,0 +1,31 @@ +package simulation + +import ( + "bytes" + "fmt" + + "github.com/babylonlabs-io/babylon/x/mint/types" + "github.com/cosmos/cosmos-sdk/codec" + "github.com/cosmos/cosmos-sdk/types/kv" +) + +// NewDecodeStore returns a decoder function closure that unmarshals the KVPair's +// Value to the corresponding mint type. +func NewDecodeStore(cdc codec.Codec) func(kvA, kvB kv.Pair) string { + return func(kvA, kvB kv.Pair) string { + switch { + case bytes.Equal(kvA.Key, types.MinterKey): + var minterA, minterB types.Minter + cdc.MustUnmarshal(kvA.Value, &minterA) + cdc.MustUnmarshal(kvB.Value, &minterB) + return fmt.Sprintf("%v\n%v", minterA, minterB) + case bytes.Equal(kvA.Key, types.GenesisTimeKey): + var genesisTimeA, genesisTimeB types.GenesisTime + cdc.MustUnmarshal(kvA.Value, &genesisTimeA) + cdc.MustUnmarshal(kvB.Value, &genesisTimeB) + return fmt.Sprintf("%v\n%v", genesisTimeA, genesisTimeB) + default: + panic(fmt.Sprintf("invalid mint key %X", kvA.Key)) + } + } +} diff --git a/x/mint/simulation/decoder_test.go b/x/mint/simulation/decoder_test.go new file mode 100644 index 000000000..3f1fd073d --- /dev/null +++ b/x/mint/simulation/decoder_test.go @@ -0,0 +1,62 @@ +package simulation_test + +import ( + "fmt" + "testing" + "time" + + "cosmossdk.io/math" + "github.com/stretchr/testify/require" + + appparams "github.com/babylonlabs-io/babylon/app/params" + "github.com/babylonlabs-io/babylon/x/mint/simulation" + "github.com/babylonlabs-io/babylon/x/mint/types" + "github.com/cosmos/cosmos-sdk/types/kv" +) + +func TestDecodeStore(t *testing.T) { + cdc := appparams.DefaultEncodingConfig().Codec + decoder := simulation.NewDecodeStore(cdc) + minter := types.NewMinter(math.LegacyOneDec(), math.LegacyNewDec(15), appparams.DefaultBondDenom) + unixEpoch := time.Unix(0, 0).UTC() + genesisTime := types.GenesisTime{GenesisTime: &unixEpoch} + + kvPairs := kv.Pairs{ + Pairs: []kv.Pair{ + {Key: types.MinterKey, Value: cdc.MustMarshal(&minter)}, + {Key: types.GenesisTimeKey, Value: cdc.MustMarshal(&genesisTime)}, + {Key: []byte{0x99}, Value: []byte{0x99}}, + }, + } + tests := []struct { + name string + expected string + expectPanic bool + }{ + { + name: "Minter", + expected: fmt.Sprintf("%v\n%v", minter, minter), + expectPanic: false, + }, + { + name: "GenesisTime", + expected: fmt.Sprintf("%v\n%v", genesisTime, genesisTime), + expectPanic: false, + }, + { + name: "other", + expected: "", + expectPanic: true, + }, + } + + for i, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + if tt.expectPanic { + require.Panics(t, func() { decoder(kvPairs.Pairs[i], kvPairs.Pairs[i]) }, tt.name) + return + } + require.Equal(t, tt.expected, decoder(kvPairs.Pairs[i], kvPairs.Pairs[i]), tt.name) + }) + } +} diff --git a/x/mint/types/constants.go b/x/mint/types/constants.go new file mode 100644 index 000000000..6da66546a --- /dev/null +++ b/x/mint/types/constants.go @@ -0,0 +1,46 @@ +package types + +import ( + "cosmossdk.io/math" +) + +// TODO: should these be parameters? +const ( + NanosecondsPerSecond = 1_000_000_000 + SecondsPerMinute = 60 + MinutesPerHour = 60 + HoursPerDay = 24 + // DaysPerYear is the mean length of the Gregorian calendar year. Note this + // value isn't 365 because 97 out of 400 years are leap years. See + // https://en.wikipedia.org/wiki/Year + DaysPerYear = 365.2425 + SecondsPerYear = int64(SecondsPerMinute * MinutesPerHour * HoursPerDay * DaysPerYear) // 31,556,952 + NanosecondsPerYear = NanosecondsPerSecond * SecondsPerYear // 31,556,952,000,000,000 + + // InitialInflationRate is the inflation rate that the network starts at. + InitialInflationRate = 0.08 + // DisinflationRate is the rate at which the inflation rate decreases each year. + DisinflationRate = 0.1 + // TargetInflationRate is the inflation rate that the network aims to + // stabilize at. In practice, TargetInflationRate acts as a minimum so that + // the inflation rate doesn't decrease after reaching it. + TargetInflationRate = 0.015 +) + +var ( + initialInflationRateAsDec = math.LegacyNewDecWithPrec(InitialInflationRate*1000, 3) + disinflationRateAsDec = math.LegacyNewDecWithPrec(DisinflationRate*1000, 3) + targetInflationRateAsDec = math.LegacyNewDecWithPrec(TargetInflationRate*1000, 3) +) + +func InitialInflationRateAsDec() math.LegacyDec { + return initialInflationRateAsDec +} + +func DisinflationRateAsDec() math.LegacyDec { + return disinflationRateAsDec +} + +func TargetInflationRateAsDec() math.LegacyDec { + return targetInflationRateAsDec +} diff --git a/x/mint/types/events.go b/x/mint/types/events.go new file mode 100644 index 000000000..9dea531eb --- /dev/null +++ b/x/mint/types/events.go @@ -0,0 +1,8 @@ +package types + +const ( + EventTypeMint = ModuleName + + AttributeKeyInflationRate = "inflation_rate" + AttributeKeyAnnualProvisions = "annual_provisions" +) diff --git a/x/mint/types/expected_keepers.go b/x/mint/types/expected_keepers.go new file mode 100644 index 000000000..5c4409581 --- /dev/null +++ b/x/mint/types/expected_keepers.go @@ -0,0 +1,26 @@ +package types + +import ( + context "context" + + "cosmossdk.io/math" + sdk "github.com/cosmos/cosmos-sdk/types" +) + +// StakingKeeper defines the expected staking keeper. +type StakingKeeper interface { + StakingTokenSupply(ctx context.Context) (math.Int, error) +} + +// AccountKeeper defines the contract required for account APIs. +type AccountKeeper interface { + GetModuleAddress(name string) sdk.AccAddress + GetModuleAccount(ctx context.Context, name string) sdk.ModuleAccountI +} + +// BankKeeper defines the contract needed to be fulfilled for banking and supply +// dependencies. +type BankKeeper interface { + SendCoinsFromModuleToModule(ctx context.Context, senderModule, recipientModule string, amt sdk.Coins) error + MintCoins(ctx context.Context, name string, amt sdk.Coins) error +} diff --git a/x/mint/types/genesis.go b/x/mint/types/genesis.go new file mode 100644 index 000000000..9fec24f16 --- /dev/null +++ b/x/mint/types/genesis.go @@ -0,0 +1,26 @@ +package types + +import "errors" + +// NewGenesisState creates a new GenesisState object +func NewGenesisState(bondDenom string) *GenesisState { + return &GenesisState{ + BondDenom: bondDenom, + } +} + +// DefaultGenesisState creates a default GenesisState object +func DefaultGenesisState() *GenesisState { + return &GenesisState{ + BondDenom: DefaultBondDenom, + } +} + +// ValidateGenesis validates the provided genesis state to ensure the +// expected invariants holds. +func ValidateGenesis(data GenesisState) error { + if data.BondDenom == "" { + return errors.New("bond denom cannot be empty") + } + return nil +} diff --git a/x/mint/types/genesis.pb.go b/x/mint/types/genesis.pb.go new file mode 100644 index 000000000..8880ee04d --- /dev/null +++ b/x/mint/types/genesis.pb.go @@ -0,0 +1,317 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: babylon/mint/v1/genesis.proto + +package types + +import ( + fmt "fmt" + proto "github.com/cosmos/gogoproto/proto" + io "io" + math "math" + math_bits "math/bits" +) + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the proto package it is being compiled against. +// A compilation error at this line likely means your copy of the +// proto package needs to be updated. +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package + +// GenesisState defines the mint module's genesis state. +type GenesisState struct { + // BondDenom is the denomination of the token that should be minted. + BondDenom string `protobuf:"bytes,2,opt,name=bond_denom,json=bondDenom,proto3" json:"bond_denom,omitempty"` +} + +func (m *GenesisState) Reset() { *m = GenesisState{} } +func (m *GenesisState) String() string { return proto.CompactTextString(m) } +func (*GenesisState) ProtoMessage() {} +func (*GenesisState) Descriptor() ([]byte, []int) { + return fileDescriptor_cc1262885e03592c, []int{0} +} +func (m *GenesisState) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *GenesisState) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_GenesisState.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 *GenesisState) XXX_Merge(src proto.Message) { + xxx_messageInfo_GenesisState.Merge(m, src) +} +func (m *GenesisState) XXX_Size() int { + return m.Size() +} +func (m *GenesisState) XXX_DiscardUnknown() { + xxx_messageInfo_GenesisState.DiscardUnknown(m) +} + +var xxx_messageInfo_GenesisState proto.InternalMessageInfo + +func (m *GenesisState) GetBondDenom() string { + if m != nil { + return m.BondDenom + } + return "" +} + +func init() { + proto.RegisterType((*GenesisState)(nil), "babylon.mint.v1.GenesisState") +} + +func init() { proto.RegisterFile("babylon/mint/v1/genesis.proto", fileDescriptor_cc1262885e03592c) } + +var fileDescriptor_cc1262885e03592c = []byte{ + // 175 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x92, 0x4d, 0x4a, 0x4c, 0xaa, + 0xcc, 0xc9, 0xcf, 0xd3, 0xcf, 0xcd, 0xcc, 0x2b, 0xd1, 0x2f, 0x33, 0xd4, 0x4f, 0x4f, 0xcd, 0x4b, + 0x2d, 0xce, 0x2c, 0xd6, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0xe2, 0x87, 0x4a, 0xeb, 0x81, 0xa4, + 0xf5, 0xca, 0x0c, 0x95, 0x8c, 0xb9, 0x78, 0xdc, 0x21, 0x2a, 0x82, 0x4b, 0x12, 0x4b, 0x52, 0x85, + 0x64, 0xb9, 0xb8, 0x92, 0xf2, 0xf3, 0x52, 0xe2, 0x53, 0x52, 0xf3, 0xf2, 0x73, 0x25, 0x98, 0x14, + 0x18, 0x35, 0x38, 0x83, 0x38, 0x41, 0x22, 0x2e, 0x20, 0x01, 0x2f, 0x16, 0x0e, 0x46, 0x01, 0x26, + 0x27, 0x8f, 0x13, 0x8f, 0xe4, 0x18, 0x2f, 0x3c, 0x92, 0x63, 0x7c, 0xf0, 0x48, 0x8e, 0x71, 0xc2, + 0x63, 0x39, 0x86, 0x0b, 0x8f, 0xe5, 0x18, 0x6e, 0x3c, 0x96, 0x63, 0x88, 0xd2, 0x4b, 0xcf, 0x2c, + 0xc9, 0x28, 0x4d, 0xd2, 0x4b, 0xce, 0xcf, 0xd5, 0x87, 0x5a, 0x95, 0x93, 0x98, 0x54, 0xac, 0x9b, + 0x99, 0x0f, 0xe3, 0xea, 0x57, 0x40, 0x9c, 0x56, 0x52, 0x59, 0x90, 0x5a, 0x9c, 0xc4, 0x06, 0x76, + 0x96, 0x31, 0x20, 0x00, 0x00, 0xff, 0xff, 0x9c, 0xb8, 0x8a, 0x90, 0xb7, 0x00, 0x00, 0x00, +} + +func (m *GenesisState) 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 *GenesisState) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *GenesisState) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.BondDenom) > 0 { + i -= len(m.BondDenom) + copy(dAtA[i:], m.BondDenom) + i = encodeVarintGenesis(dAtA, i, uint64(len(m.BondDenom))) + i-- + dAtA[i] = 0x12 + } + return len(dAtA) - i, nil +} + +func encodeVarintGenesis(dAtA []byte, offset int, v uint64) int { + offset -= sovGenesis(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *GenesisState) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.BondDenom) + if l > 0 { + n += 1 + l + sovGenesis(uint64(l)) + } + return n +} + +func sovGenesis(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozGenesis(x uint64) (n int) { + return sovGenesis(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *GenesisState) 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: GenesisState: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: GenesisState: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field BondDenom", 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 + } + m.BondDenom = string(dAtA[iNdEx:postIndex]) + 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 skipGenesis(dAtA []byte) (n int, err error) { + l := len(dAtA) + iNdEx := 0 + depth := 0 + for iNdEx < l { + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowGenesis + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + wireType := int(wire & 0x7) + switch wireType { + case 0: + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowGenesis + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + iNdEx++ + if dAtA[iNdEx-1] < 0x80 { + break + } + } + case 1: + iNdEx += 8 + case 2: + var length int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowGenesis + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + length |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + if length < 0 { + return 0, ErrInvalidLengthGenesis + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupGenesis + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthGenesis + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthGenesis = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowGenesis = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupGenesis = fmt.Errorf("proto: unexpected end of group") +) diff --git a/x/mint/types/keys.go b/x/mint/types/keys.go new file mode 100644 index 000000000..9a8a5ff44 --- /dev/null +++ b/x/mint/types/keys.go @@ -0,0 +1,26 @@ +package types + +import "cosmossdk.io/collections" + +var ( + MinterKey = collections.NewPrefix(0) + //nolint:unused + reservedKey = collections.NewPrefix(1) // reserved for parameters + GenesisTimeKey = collections.NewPrefix(2) +) + +const ( + // ModuleName is the name of the mint module. + ModuleName = "mint" + + // StoreKey is the default store key for mint + StoreKey = ModuleName + + // QuerierRoute is the querier route for the mint store. + QuerierRoute = StoreKey + + // Query endpoints supported by the mint querier + QueryInflationRate = "inflation_rate" + QueryAnnualProvisions = "annual_provisions" + QueryGenesisTime = "genesis_time" +) diff --git a/x/mint/types/mint.pb.go b/x/mint/types/mint.pb.go new file mode 100644 index 000000000..1ca04a527 --- /dev/null +++ b/x/mint/types/mint.pb.go @@ -0,0 +1,675 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: babylon/mint/v1/mint.proto + +package types + +import ( + cosmossdk_io_math "cosmossdk.io/math" + fmt "fmt" + _ "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. +// A compilation error at this line likely means your copy of the +// proto package needs to be updated. +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package + +// Minter represents the mint state. +type Minter struct { + // InflationRate is the rate at which new tokens should be minted for the + // current year. For example if InflationRate=0.1, then 10% of the total + // supply will be minted over the course of the year. + InflationRate cosmossdk_io_math.LegacyDec `protobuf:"bytes,1,opt,name=inflation_rate,json=inflationRate,proto3,customtype=cosmossdk.io/math.LegacyDec" json:"inflation_rate"` + // AnnualProvisions is the total number of tokens to be minted in the current + // year due to inflation. + AnnualProvisions cosmossdk_io_math.LegacyDec `protobuf:"bytes,2,opt,name=annual_provisions,json=annualProvisions,proto3,customtype=cosmossdk.io/math.LegacyDec" json:"annual_provisions"` + // PreviousBlockTime is the timestamp of the previous block. + PreviousBlockTime *time.Time `protobuf:"bytes,4,opt,name=previous_block_time,json=previousBlockTime,proto3,stdtime" json:"previous_block_time,omitempty"` + // BondDenom is the denomination of the token that should be minted. + BondDenom string `protobuf:"bytes,5,opt,name=bond_denom,json=bondDenom,proto3" json:"bond_denom,omitempty"` +} + +func (m *Minter) Reset() { *m = Minter{} } +func (m *Minter) String() string { return proto.CompactTextString(m) } +func (*Minter) ProtoMessage() {} +func (*Minter) Descriptor() ([]byte, []int) { + return fileDescriptor_a78f7d85d8f9d75c, []int{0} +} +func (m *Minter) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *Minter) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_Minter.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 *Minter) XXX_Merge(src proto.Message) { + xxx_messageInfo_Minter.Merge(m, src) +} +func (m *Minter) XXX_Size() int { + return m.Size() +} +func (m *Minter) XXX_DiscardUnknown() { + xxx_messageInfo_Minter.DiscardUnknown(m) +} + +var xxx_messageInfo_Minter proto.InternalMessageInfo + +func (m *Minter) GetPreviousBlockTime() *time.Time { + if m != nil { + return m.PreviousBlockTime + } + return nil +} + +func (m *Minter) GetBondDenom() string { + if m != nil { + return m.BondDenom + } + return "" +} + +// GenesisTime contains the timestamp of the genesis block. +type GenesisTime struct { + // GenesisTime is the timestamp of the genesis block. + GenesisTime *time.Time `protobuf:"bytes,1,opt,name=genesis_time,json=genesisTime,proto3,stdtime" json:"genesis_time,omitempty"` +} + +func (m *GenesisTime) Reset() { *m = GenesisTime{} } +func (m *GenesisTime) String() string { return proto.CompactTextString(m) } +func (*GenesisTime) ProtoMessage() {} +func (*GenesisTime) Descriptor() ([]byte, []int) { + return fileDescriptor_a78f7d85d8f9d75c, []int{1} +} +func (m *GenesisTime) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *GenesisTime) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_GenesisTime.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 *GenesisTime) XXX_Merge(src proto.Message) { + xxx_messageInfo_GenesisTime.Merge(m, src) +} +func (m *GenesisTime) XXX_Size() int { + return m.Size() +} +func (m *GenesisTime) XXX_DiscardUnknown() { + xxx_messageInfo_GenesisTime.DiscardUnknown(m) +} + +var xxx_messageInfo_GenesisTime proto.InternalMessageInfo + +func (m *GenesisTime) GetGenesisTime() *time.Time { + if m != nil { + return m.GenesisTime + } + return nil +} + +func init() { + proto.RegisterType((*Minter)(nil), "babylon.mint.v1.Minter") + proto.RegisterType((*GenesisTime)(nil), "babylon.mint.v1.GenesisTime") +} + +func init() { proto.RegisterFile("babylon/mint/v1/mint.proto", fileDescriptor_a78f7d85d8f9d75c) } + +var fileDescriptor_a78f7d85d8f9d75c = []byte{ + // 386 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x9c, 0x52, 0xcd, 0x6e, 0xd4, 0x30, + 0x10, 0x8e, 0xab, 0x52, 0xa9, 0x5e, 0xfe, 0x1a, 0x38, 0x84, 0x20, 0x92, 0xaa, 0xa7, 0x5e, 0x6a, + 0x6b, 0xe1, 0x0d, 0xc2, 0x4a, 0x70, 0x00, 0xa9, 0x8a, 0x38, 0x20, 0x0e, 0x44, 0x76, 0xd6, 0x75, + 0xad, 0x26, 0x9e, 0x28, 0x76, 0x22, 0xf6, 0x2d, 0xfa, 0x2e, 0xf0, 0x10, 0x3d, 0xae, 0x38, 0x21, + 0x0e, 0x0b, 0xda, 0x7d, 0x11, 0xe4, 0x38, 0x59, 0xae, 0x88, 0x53, 0xf2, 0xcd, 0x37, 0xf3, 0x7d, + 0xe3, 0x4f, 0x83, 0x63, 0xce, 0xf8, 0xaa, 0x02, 0x4d, 0x6b, 0xa5, 0x2d, 0xed, 0xe7, 0xc3, 0x97, + 0x34, 0x2d, 0x58, 0x08, 0x1f, 0x8d, 0x1c, 0x19, 0x6a, 0xfd, 0x3c, 0x7e, 0x2a, 0x41, 0xc2, 0xc0, + 0x51, 0xf7, 0xe7, 0xdb, 0xe2, 0x67, 0x25, 0x98, 0x1a, 0x4c, 0xe1, 0x09, 0x0f, 0x46, 0x2a, 0x95,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x5f, 0xe3, 0xfb, 0xd2, 0x43, 0x6f, 0x8c, 0xfe, 0xd1, 0x78, 0x26, 0xff, + 0x8a, 0x64, 0x6f, 0xef, 0xb6, 0x09, 0x5a, 0x6f, 0x13, 0xf4, 0x7b, 0x9b, 0xa0, 0xdb, 0x5d, 0x12, + 0xac, 0x77, 0x49, 0xf0, 0x63, 0x97, 0x04, 0x9f, 0x88, 0x54, 0xf6, 0xba, 0xe3, 0xa4, 0x84, 0x9a, + 0x8e, 0x17, 0x51, 0x31, 0x6e, 0x2e, 0x14, 0x4c, 0x90, 0x7e, 0xf1, 0xe7, 0x63, 0x57, 0x8d, 0x30, + 0xfc, 0x68, 0x30, 0x7c, 0xf5, 0x27, 0x00, 0x00, 0xff, 0xff, 0x7e, 0x0d, 0x96, 0x13, 0x5b, 0x02, + 0x00, 0x00, +} + +func (m *Minter) 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 *Minter) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *Minter) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.BondDenom) > 0 { + i -= len(m.BondDenom) + copy(dAtA[i:], m.BondDenom) + i = encodeVarintMint(dAtA, i, uint64(len(m.BondDenom))) + i-- + dAtA[i] = 0x2a + } + if m.PreviousBlockTime != nil { + n1, err1 := github_com_cosmos_gogoproto_types.StdTimeMarshalTo(*m.PreviousBlockTime, dAtA[i-github_com_cosmos_gogoproto_types.SizeOfStdTime(*m.PreviousBlockTime):]) + if err1 != nil { + return 0, err1 + } + i -= n1 + i = encodeVarintMint(dAtA, i, uint64(n1)) + i-- + dAtA[i] = 0x22 + } + { + size := m.AnnualProvisions.Size() + i -= size + if _, err := m.AnnualProvisions.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintMint(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + { + size := m.InflationRate.Size() + i -= size + if _, err := m.InflationRate.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintMint(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + return len(dAtA) - i, nil +} + +func (m *GenesisTime) 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 *GenesisTime) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *GenesisTime) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.GenesisTime != nil { + n2, err2 := github_com_cosmos_gogoproto_types.StdTimeMarshalTo(*m.GenesisTime, dAtA[i-github_com_cosmos_gogoproto_types.SizeOfStdTime(*m.GenesisTime):]) + if err2 != nil { + return 0, err2 + } + i -= n2 + i = encodeVarintMint(dAtA, i, uint64(n2)) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func encodeVarintMint(dAtA []byte, offset int, v uint64) int { + offset -= sovMint(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *Minter) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = m.InflationRate.Size() + n += 1 + l + sovMint(uint64(l)) + l = m.AnnualProvisions.Size() + n += 1 + l + sovMint(uint64(l)) + if m.PreviousBlockTime != nil { + l = github_com_cosmos_gogoproto_types.SizeOfStdTime(*m.PreviousBlockTime) + n += 1 + l + sovMint(uint64(l)) + } + l = len(m.BondDenom) + if l > 0 { + n += 1 + l + sovMint(uint64(l)) + } + return n +} + +func (m *GenesisTime) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.GenesisTime != nil { + l = github_com_cosmos_gogoproto_types.SizeOfStdTime(*m.GenesisTime) + n += 1 + l + sovMint(uint64(l)) + } + return n +} + +func sovMint(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozMint(x uint64) (n int) { + return sovMint(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *Minter) 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 ErrIntOverflowMint + } + 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: Minter: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: Minter: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field InflationRate", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowMint + } + 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 ErrInvalidLengthMint + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthMint + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.InflationRate.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field AnnualProvisions", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowMint + } + 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 ErrInvalidLengthMint + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthMint + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.AnnualProvisions.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field PreviousBlockTime", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowMint + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthMint + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthMint + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.PreviousBlockTime == nil { + m.PreviousBlockTime = new(time.Time) + } + if err := github_com_cosmos_gogoproto_types.StdTimeUnmarshal(m.PreviousBlockTime, dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 5: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field BondDenom", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowMint + } + 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 ErrInvalidLengthMint + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthMint + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.BondDenom = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipMint(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthMint + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *GenesisTime) 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 ErrIntOverflowMint + } + 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: GenesisTime: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: GenesisTime: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field GenesisTime", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowMint + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthMint + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthMint + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.GenesisTime == nil { + m.GenesisTime = new(time.Time) + } + if err := github_com_cosmos_gogoproto_types.StdTimeUnmarshal(m.GenesisTime, dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipMint(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthMint + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func skipMint(dAtA []byte) (n int, err error) { + l := len(dAtA) + iNdEx := 0 + depth := 0 + for iNdEx < l { + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowMint + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + wireType := int(wire & 0x7) + switch wireType { + case 0: + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowMint + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + iNdEx++ + if dAtA[iNdEx-1] < 0x80 { + break + } + } + case 1: + iNdEx += 8 + case 2: + var length int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowMint + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + length |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + if length < 0 { + return 0, ErrInvalidLengthMint + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupMint + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthMint + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthMint = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowMint = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupMint = fmt.Errorf("proto: unexpected end of group") +) diff --git a/x/mint/types/minter.go b/x/mint/types/minter.go new file mode 100644 index 000000000..7c0ee60dd --- /dev/null +++ b/x/mint/types/minter.go @@ -0,0 +1,74 @@ +package types + +import ( + "fmt" + "time" + + "cosmossdk.io/math" + sdk "github.com/cosmos/cosmos-sdk/types" +) + +const DefaultBondDenom = "ubbn" + +// NewMinter returns a new Minter object. +func NewMinter(inflationRate math.LegacyDec, annualProvisions math.LegacyDec, bondDenom string) Minter { + return Minter{ + InflationRate: inflationRate, + AnnualProvisions: annualProvisions, + BondDenom: bondDenom, + } +} + +// DefaultMinter returns a Minter object with default values. +func DefaultMinter() Minter { + annualProvisions := math.LegacyNewDec(0) + return NewMinter(InitialInflationRateAsDec(), annualProvisions, DefaultBondDenom) +} + +// Validate returns an error if the minter is invalid. +func (m Minter) Validate() error { + if m.InflationRate.IsNegative() { + return fmt.Errorf("inflation rate %v should be positive", m.InflationRate.String()) + } + if m.AnnualProvisions.IsNegative() { + return fmt.Errorf("annual provisions %v should be positive", m.AnnualProvisions.String()) + } + if m.BondDenom == "" { + return fmt.Errorf("bond denom should not be empty string") + } + return nil +} + +// CalculateInflationRate returns the inflation rate for the current year depending on +// the current block height in context. The inflation rate is expected to +// decrease every year according to the schedule specified in the README. +func (m Minter) CalculateInflationRate(ctx sdk.Context, genesis time.Time) math.LegacyDec { + years := yearsSinceGenesis(genesis, ctx.BlockTime()) + inflationRate := InitialInflationRateAsDec().Mul(math.LegacyOneDec().Sub(DisinflationRateAsDec()).Power(uint64(years))) + + if inflationRate.LT(TargetInflationRateAsDec()) { + return TargetInflationRateAsDec() + } + return inflationRate +} + +// CalculateBlockProvision returns the total number of coins that should be +// minted due to inflation for the current block. +func (m Minter) CalculateBlockProvision(current time.Time, previous time.Time) (sdk.Coin, error) { + if current.Before(previous) { + return sdk.Coin{}, fmt.Errorf("current time %v cannot be before previous time %v", current, previous) + } + timeElapsed := current.Sub(previous).Nanoseconds() + portionOfYear := math.LegacyNewDec(timeElapsed).Quo(math.LegacyNewDec(NanosecondsPerYear)) + blockProvision := m.AnnualProvisions.Mul(portionOfYear) + return sdk.NewCoin(m.BondDenom, blockProvision.TruncateInt()), nil +} + +// yearsSinceGenesis returns the number of years that have passed between +// genesis and current (rounded down). +func yearsSinceGenesis(genesis time.Time, current time.Time) (years int64) { + if current.Before(genesis) { + return 0 + } + return current.Sub(genesis).Nanoseconds() / NanosecondsPerYear +} diff --git a/x/mint/types/minter_test.go b/x/mint/types/minter_test.go new file mode 100644 index 000000000..a2a066912 --- /dev/null +++ b/x/mint/types/minter_test.go @@ -0,0 +1,261 @@ +package types + +import ( + "math/rand" + "testing" + time "time" + + "cosmossdk.io/math" + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" + + tmproto "github.com/cometbft/cometbft/proto/tendermint/types" + sdk "github.com/cosmos/cosmos-sdk/types" +) + +func TestCalculateInflationRate(t *testing.T) { + minter := DefaultMinter() + genesisTime := time.Date(2023, 1, 1, 0, 0, 0, 0, time.UTC) + + type testCase struct { + year int64 + want float64 + } + + testCases := []testCase{ + {0, 0.08}, + {1, 0.072}, + {2, 0.0648}, + {3, 0.05832}, + {4, 0.052488}, + {5, 0.0472392}, + {6, 0.04251528}, + {7, 0.038263752}, + {8, 0.0344373768}, + {9, 0.03099363912}, + {10, 0.027894275208}, + {11, 0.0251048476872}, + {12, 0.02259436291848}, + {13, 0.020334926626632}, + {14, 0.0183014339639688}, + {15, 0.01647129056757192}, + {16, 0.0150}, + {17, 0.0150}, + {18, 0.0150}, + {19, 0.0150}, + {20, 0.0150}, + {21, 0.0150}, + {22, 0.0150}, + {23, 0.0150}, + {24, 0.0150}, + {25, 0.0150}, + {26, 0.0150}, + {27, 0.0150}, + {28, 0.0150}, + {29, 0.0150}, + {30, 0.0150}, + {31, 0.0150}, + {32, 0.0150}, + {33, 0.0150}, + {34, 0.0150}, + {35, 0.0150}, + {36, 0.0150}, + {37, 0.0150}, + {38, 0.0150}, + {39, 0.0150}, + {40, 0.0150}, + } + + for _, tc := range testCases { + years := time.Duration(tc.year * NanosecondsPerYear * int64(time.Nanosecond)) + blockTime := genesisTime.Add(years) + ctx := sdk.NewContext(nil, tmproto.Header{}, false, nil).WithBlockTime(blockTime) + inflationRate := minter.CalculateInflationRate(ctx, genesisTime) + got, err := inflationRate.Float64() + assert.NoError(t, err) + assert.Equal(t, tc.want, got, "want %v got %v year %v blockTime %v", tc.want, got, tc.year, blockTime) + } +} + +func TestCalculateBlockProvision(t *testing.T) { + minter := DefaultMinter() + current := time.Date(2023, 1, 2, 0, 0, 0, 0, time.UTC) + blockInterval := 15 * time.Second + totalSupply := math.LegacyNewDec(1_000_000_000_000) // 1 trillion ubbn + annualProvisions := totalSupply.Mul(InitialInflationRateAsDec()) // 80 billion ubbn + + type testCase struct { + name string + annualProvisions math.LegacyDec + current time.Time + previous time.Time + want sdk.Coin + wantErr bool + } + + testCases := []testCase{ + { + name: "one 15 second block during the first year", + annualProvisions: annualProvisions, + current: current, + previous: current.Add(-blockInterval), + // 80 billion ubbn (annual provisions) * 15 (seconds) / 31,556,952 (seconds per year) = 38026.48620817 which truncates to 38026 ubbn + want: sdk.NewCoin(DefaultBondDenom, math.NewInt(38026)), + }, + { + name: "one 30 second block during the first year", + annualProvisions: annualProvisions, + current: current, + previous: current.Add(-2 * blockInterval), + // 80 billion ubbn (annual provisions) * 30 (seconds) / 31,556,952 (seconds per year) = 76052.97241635 which truncates to 76052 ubbn + want: sdk.NewCoin(DefaultBondDenom, math.NewInt(76052)), + }, + { + name: "want error when current time is before previous time", + annualProvisions: annualProvisions, + current: current, + previous: current.Add(blockInterval), + wantErr: true, + }, + } + for _, tc := range testCases { + minter.AnnualProvisions = tc.annualProvisions + got, err := minter.CalculateBlockProvision(tc.current, tc.previous) + if tc.wantErr { + assert.Error(t, err) + return + } + assert.NoError(t, err) + require.True(t, tc.want.IsEqual(got), "want %v got %v", tc.want, got) + } +} + +// TestCalculateBlockProvisionError verifies that the error for total block +// provisions in a year is less than .01 +func TestCalculateBlockProvisionError(t *testing.T) { + minter := DefaultMinter() + current := time.Date(2023, 1, 2, 0, 0, 0, 0, time.UTC) + oneYear := time.Duration(NanosecondsPerYear) + end := current.Add(oneYear) + + totalSupply := math.LegacyNewDec(1_000_000_000_000) // 1 trillion ubbn + annualProvisions := totalSupply.Mul(InitialInflationRateAsDec()) // 80 billion ubbn + minter.AnnualProvisions = annualProvisions + totalBlockProvisions := math.LegacyNewDec(0) + for current.Before(end) { + blockInterval := randomBlockInterval() + previous := current + current = current.Add(blockInterval) + got, err := minter.CalculateBlockProvision(current, previous) + require.NoError(t, err) + totalBlockProvisions = totalBlockProvisions.Add(math.LegacyNewDecFromInt(got.Amount)) + } + + gotError := totalBlockProvisions.Sub(annualProvisions).Abs().Quo(annualProvisions) + wantError := math.LegacyNewDecWithPrec(1, 2) // .01 + assert.True(t, gotError.LTE(wantError)) +} + +func randomBlockInterval() time.Duration { + min := (14 * time.Second).Nanoseconds() + max := (16 * time.Second).Nanoseconds() + return time.Duration(randInRange(min, max)) +} + +// randInRange returns a random number in the range (min, max) inclusive. +func randInRange(min int64, max int64) int64 { + return rand.Int63n(max-min) + min +} + +func BenchmarkCalculateBlockProvision(b *testing.B) { + b.ReportAllocs() + minter := DefaultMinter() + + s1 := rand.NewSource(100) + r1 := rand.New(s1) + minter.AnnualProvisions = math.LegacyNewDec(r1.Int63n(1000000)) + current := time.Unix(r1.Int63n(1000000), 0) + previous := current.Add(-time.Second * 15) + + for n := 0; n < b.N; n++ { + _, err := minter.CalculateBlockProvision(current, previous) + require.NoError(b, err) + } +} + +func BenchmarkCalculateInflationRate(b *testing.B) { + b.ReportAllocs() + minter := DefaultMinter() + genesisTime := time.Date(2023, 1, 1, 0, 0, 0, 0, time.UTC) + + for n := 0; n < b.N; n++ { + ctx := sdk.NewContext(nil, tmproto.Header{Height: int64(n)}, false, nil) + minter.CalculateInflationRate(ctx, genesisTime) + } +} + +func Test_yearsSinceGenesis(t *testing.T) { + type testCase struct { + name string + current time.Time + want int64 + } + + genesis := time.Date(2023, 1, 1, 12, 30, 15, 0, time.UTC) // 2023-01-01T12:30:15Z + oneDay, err := time.ParseDuration("24h") + assert.NoError(t, err) + oneWeek := oneDay * 7 + oneMonth := oneDay * 30 + oneYear := time.Duration(NanosecondsPerYear) + twoYears := 2 * oneYear + tenYears := 10 * oneYear + tenYearsOneMonth := tenYears + oneMonth + + testCases := []testCase{ + { + name: "one day after genesis", + current: genesis.Add(oneDay), + want: 0, + }, + { + name: "one day before genesis", + current: genesis.Add(-oneDay), + want: 0, + }, + { + name: "one week after genesis", + current: genesis.Add(oneWeek), + want: 0, + }, + { + name: "one month after genesis", + current: genesis.Add(oneMonth), + want: 0, + }, + { + name: "one year after genesis", + current: genesis.Add(oneYear), + want: 1, + }, + { + name: "two years after genesis", + current: genesis.Add(twoYears), + want: 2, + }, + { + name: "ten years after genesis", + current: genesis.Add(tenYears), + want: 10, + }, + { + name: "ten years and one month after genesis", + current: genesis.Add(tenYearsOneMonth), + want: 10, + }, + } + + for _, tc := range testCases { + got := yearsSinceGenesis(genesis, tc.current) + assert.Equal(t, tc.want, got, tc.name) + } +} diff --git a/x/mint/types/query.pb.go b/x/mint/types/query.pb.go new file mode 100644 index 000000000..e5e2ff960 --- /dev/null +++ b/x/mint/types/query.pb.go @@ -0,0 +1,1215 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: babylon/mint/v1/query.proto + +package types + +import ( + context "context" + cosmossdk_io_math "cosmossdk.io/math" + fmt "fmt" + _ "github.com/cosmos/gogoproto/gogoproto" + grpc1 "github.com/cosmos/gogoproto/grpc" + proto "github.com/cosmos/gogoproto/proto" + github_com_cosmos_gogoproto_types "github.com/cosmos/gogoproto/types" + _ "google.golang.org/genproto/googleapis/api/annotations" + grpc "google.golang.org/grpc" + codes "google.golang.org/grpc/codes" + status "google.golang.org/grpc/status" + _ "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. +// A compilation error at this line likely means your copy of the +// proto package needs to be updated. +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package + +// QueryInflationRateRequest is the request type for the Query/InflationRate RPC +// method. +type QueryInflationRateRequest struct { +} + +func (m *QueryInflationRateRequest) Reset() { *m = QueryInflationRateRequest{} } +func (m *QueryInflationRateRequest) String() string { return proto.CompactTextString(m) } +func (*QueryInflationRateRequest) ProtoMessage() {} +func (*QueryInflationRateRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_bab217370cac4c70, []int{0} +} +func (m *QueryInflationRateRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryInflationRateRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryInflationRateRequest.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 *QueryInflationRateRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryInflationRateRequest.Merge(m, src) +} +func (m *QueryInflationRateRequest) XXX_Size() int { + return m.Size() +} +func (m *QueryInflationRateRequest) XXX_DiscardUnknown() { + xxx_messageInfo_QueryInflationRateRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryInflationRateRequest proto.InternalMessageInfo + +// QueryInflationRateResponse is the response type for the Query/InflationRate +// RPC method. +type QueryInflationRateResponse struct { + // InflationRate is the current inflation rate. + InflationRate cosmossdk_io_math.LegacyDec `protobuf:"bytes,1,opt,name=inflation_rate,json=inflationRate,proto3,customtype=cosmossdk.io/math.LegacyDec" json:"inflation_rate"` +} + +func (m *QueryInflationRateResponse) Reset() { *m = QueryInflationRateResponse{} } +func (m *QueryInflationRateResponse) String() string { return proto.CompactTextString(m) } +func (*QueryInflationRateResponse) ProtoMessage() {} +func (*QueryInflationRateResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_bab217370cac4c70, []int{1} +} +func (m *QueryInflationRateResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryInflationRateResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryInflationRateResponse.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 *QueryInflationRateResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryInflationRateResponse.Merge(m, src) +} +func (m *QueryInflationRateResponse) XXX_Size() int { + return m.Size() +} +func (m *QueryInflationRateResponse) XXX_DiscardUnknown() { + xxx_messageInfo_QueryInflationRateResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryInflationRateResponse proto.InternalMessageInfo + +// QueryAnnualProvisionsRequest is the request type for the +// Query/AnnualProvisions RPC method. +type QueryAnnualProvisionsRequest struct { +} + +func (m *QueryAnnualProvisionsRequest) Reset() { *m = QueryAnnualProvisionsRequest{} } +func (m *QueryAnnualProvisionsRequest) String() string { return proto.CompactTextString(m) } +func (*QueryAnnualProvisionsRequest) ProtoMessage() {} +func (*QueryAnnualProvisionsRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_bab217370cac4c70, []int{2} +} +func (m *QueryAnnualProvisionsRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryAnnualProvisionsRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryAnnualProvisionsRequest.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 *QueryAnnualProvisionsRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryAnnualProvisionsRequest.Merge(m, src) +} +func (m *QueryAnnualProvisionsRequest) XXX_Size() int { + return m.Size() +} +func (m *QueryAnnualProvisionsRequest) XXX_DiscardUnknown() { + xxx_messageInfo_QueryAnnualProvisionsRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryAnnualProvisionsRequest proto.InternalMessageInfo + +// QueryAnnualProvisionsResponse is the response type for the +// Query/AnnualProvisions RPC method. +type QueryAnnualProvisionsResponse struct { + // AnnualProvisions is the current annual provisions. + AnnualProvisions cosmossdk_io_math.LegacyDec `protobuf:"bytes,1,opt,name=annual_provisions,json=annualProvisions,proto3,customtype=cosmossdk.io/math.LegacyDec" json:"annual_provisions"` +} + +func (m *QueryAnnualProvisionsResponse) Reset() { *m = QueryAnnualProvisionsResponse{} } +func (m *QueryAnnualProvisionsResponse) String() string { return proto.CompactTextString(m) } +func (*QueryAnnualProvisionsResponse) ProtoMessage() {} +func (*QueryAnnualProvisionsResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_bab217370cac4c70, []int{3} +} +func (m *QueryAnnualProvisionsResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryAnnualProvisionsResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryAnnualProvisionsResponse.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 *QueryAnnualProvisionsResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryAnnualProvisionsResponse.Merge(m, src) +} +func (m *QueryAnnualProvisionsResponse) XXX_Size() int { + return m.Size() +} +func (m *QueryAnnualProvisionsResponse) XXX_DiscardUnknown() { + xxx_messageInfo_QueryAnnualProvisionsResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryAnnualProvisionsResponse proto.InternalMessageInfo + +// QueryGenesisTimeRequest is the request type for the Query/GenesisTime RPC +// method. +type QueryGenesisTimeRequest struct { +} + +func (m *QueryGenesisTimeRequest) Reset() { *m = QueryGenesisTimeRequest{} } +func (m *QueryGenesisTimeRequest) String() string { return proto.CompactTextString(m) } +func (*QueryGenesisTimeRequest) ProtoMessage() {} +func (*QueryGenesisTimeRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_bab217370cac4c70, []int{4} +} +func (m *QueryGenesisTimeRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryGenesisTimeRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryGenesisTimeRequest.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 *QueryGenesisTimeRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryGenesisTimeRequest.Merge(m, src) +} +func (m *QueryGenesisTimeRequest) XXX_Size() int { + return m.Size() +} +func (m *QueryGenesisTimeRequest) XXX_DiscardUnknown() { + xxx_messageInfo_QueryGenesisTimeRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryGenesisTimeRequest proto.InternalMessageInfo + +// QueryGenesisTimeResponse is the response type for the Query/GenesisTime RPC +// method. +type QueryGenesisTimeResponse struct { + // GenesisTime is the timestamp associated with the first block. + GenesisTime *time.Time `protobuf:"bytes,1,opt,name=genesis_time,json=genesisTime,proto3,stdtime" json:"genesis_time,omitempty"` +} + +func (m *QueryGenesisTimeResponse) Reset() { *m = QueryGenesisTimeResponse{} } +func (m *QueryGenesisTimeResponse) String() string { return proto.CompactTextString(m) } +func (*QueryGenesisTimeResponse) ProtoMessage() {} +func (*QueryGenesisTimeResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_bab217370cac4c70, []int{5} +} +func (m *QueryGenesisTimeResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryGenesisTimeResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryGenesisTimeResponse.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 *QueryGenesisTimeResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryGenesisTimeResponse.Merge(m, src) +} +func (m *QueryGenesisTimeResponse) XXX_Size() int { + return m.Size() +} +func (m *QueryGenesisTimeResponse) XXX_DiscardUnknown() { + xxx_messageInfo_QueryGenesisTimeResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryGenesisTimeResponse proto.InternalMessageInfo + +func (m *QueryGenesisTimeResponse) GetGenesisTime() *time.Time { + if m != nil { + return m.GenesisTime + } + return nil +} + +func init() { + proto.RegisterType((*QueryInflationRateRequest)(nil), "babylon.mint.v1.QueryInflationRateRequest") + proto.RegisterType((*QueryInflationRateResponse)(nil), "babylon.mint.v1.QueryInflationRateResponse") + proto.RegisterType((*QueryAnnualProvisionsRequest)(nil), "babylon.mint.v1.QueryAnnualProvisionsRequest") + proto.RegisterType((*QueryAnnualProvisionsResponse)(nil), "babylon.mint.v1.QueryAnnualProvisionsResponse") + proto.RegisterType((*QueryGenesisTimeRequest)(nil), "babylon.mint.v1.QueryGenesisTimeRequest") + proto.RegisterType((*QueryGenesisTimeResponse)(nil), "babylon.mint.v1.QueryGenesisTimeResponse") +} + +func init() { proto.RegisterFile("babylon/mint/v1/query.proto", fileDescriptor_bab217370cac4c70) } + +var fileDescriptor_bab217370cac4c70 = []byte{ + // 501 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94, 0x92, 0xcd, 0x6e, 0xd3, 0x40, + 0x14, 0x85, 0x33, 0xfc, 0x2d, 0x26, 0x2d, 0x94, 0x11, 0x12, 0xad, 0x53, 0x1c, 0x70, 0x04, 0x4a, + 0xa9, 0x3a, 0xa3, 0x94, 0x27, 0x20, 0x20, 0xf1, 0x23, 0x16, 0x25, 0xea, 0x8a, 0x4d, 0x34, 0x0e, + 0x53, 0x67, 0x84, 0x3d, 0xd7, 0xc9, 0x8c, 0x23, 0xb2, 0x65, 0x8f, 0x54, 0x09, 0xf1, 0x00, 0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, 0x35, 0xc8, 0xa3, 0x52, 0xa8, + 0xd9, 0x53, 0x68, 0xbf, 0x3e, 0x99, 0xb8, 0xe8, 0x74, 0xe2, 0xa2, 0x3f, 0x13, 0x17, 0x1d, 0x4f, + 0xdd, 0xca, 0xe9, 0xd4, 0xad, 0xfc, 0x9c, 0xba, 0x95, 0x0f, 0x34, 0x90, 0xa6, 0x9f, 0xf8, 0xb4, + 0x07, 0x11, 0xcb, 0x93, 0x43, 0xee, 0xeb, 0x3d, 0x09, 0xc5, 0x93, 0x7d, 0xce, 0x8c, 0xcd, 0x38, + 0x16, 0xda, 0xbf, 0x65, 0xcf, 0xe8, 0xd9, 0xbf, 0x00, 0x00, 0x00, 0xff, 0xff, 0xd3, 0xa4, 0xd5, + 0x0a, 0x5d, 0x04, 0x00, 0x00, +} + +// Reference imports to suppress errors if they are not otherwise used. +var _ context.Context +var _ grpc.ClientConn + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the grpc package it is being compiled against. +const _ = grpc.SupportPackageIsVersion4 + +// QueryClient is the client API for Query service. +// +// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream. +type QueryClient interface { + // InflationRate returns the current inflation rate. + InflationRate(ctx context.Context, in *QueryInflationRateRequest, opts ...grpc.CallOption) (*QueryInflationRateResponse, error) + // AnnualProvisions returns the current annual provisions. + AnnualProvisions(ctx context.Context, in *QueryAnnualProvisionsRequest, opts ...grpc.CallOption) (*QueryAnnualProvisionsResponse, error) + // GenesisTime returns the genesis time. + GenesisTime(ctx context.Context, in *QueryGenesisTimeRequest, opts ...grpc.CallOption) (*QueryGenesisTimeResponse, error) +} + +type queryClient struct { + cc grpc1.ClientConn +} + +func NewQueryClient(cc grpc1.ClientConn) QueryClient { + return &queryClient{cc} +} + +func (c *queryClient) InflationRate(ctx context.Context, in *QueryInflationRateRequest, opts ...grpc.CallOption) (*QueryInflationRateResponse, error) { + out := new(QueryInflationRateResponse) + err := c.cc.Invoke(ctx, "/babylon.mint.v1.Query/InflationRate", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *queryClient) AnnualProvisions(ctx context.Context, in *QueryAnnualProvisionsRequest, opts ...grpc.CallOption) (*QueryAnnualProvisionsResponse, error) { + out := new(QueryAnnualProvisionsResponse) + err := c.cc.Invoke(ctx, "/babylon.mint.v1.Query/AnnualProvisions", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *queryClient) GenesisTime(ctx context.Context, in *QueryGenesisTimeRequest, opts ...grpc.CallOption) (*QueryGenesisTimeResponse, error) { + out := new(QueryGenesisTimeResponse) + err := c.cc.Invoke(ctx, "/babylon.mint.v1.Query/GenesisTime", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +// QueryServer is the server API for Query service. +type QueryServer interface { + // InflationRate returns the current inflation rate. + InflationRate(context.Context, *QueryInflationRateRequest) (*QueryInflationRateResponse, error) + // AnnualProvisions returns the current annual provisions. + AnnualProvisions(context.Context, *QueryAnnualProvisionsRequest) (*QueryAnnualProvisionsResponse, error) + // GenesisTime returns the genesis time. + GenesisTime(context.Context, *QueryGenesisTimeRequest) (*QueryGenesisTimeResponse, error) +} + +// UnimplementedQueryServer can be embedded to have forward compatible implementations. +type UnimplementedQueryServer struct { +} + +func (*UnimplementedQueryServer) InflationRate(ctx context.Context, req *QueryInflationRateRequest) (*QueryInflationRateResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method InflationRate not implemented") +} +func (*UnimplementedQueryServer) AnnualProvisions(ctx context.Context, req *QueryAnnualProvisionsRequest) (*QueryAnnualProvisionsResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method AnnualProvisions not implemented") +} +func (*UnimplementedQueryServer) GenesisTime(ctx context.Context, req *QueryGenesisTimeRequest) (*QueryGenesisTimeResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method GenesisTime not implemented") +} + +func RegisterQueryServer(s grpc1.Server, srv QueryServer) { + s.RegisterService(&_Query_serviceDesc, srv) +} + +func _Query_InflationRate_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(QueryInflationRateRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(QueryServer).InflationRate(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/babylon.mint.v1.Query/InflationRate", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(QueryServer).InflationRate(ctx, req.(*QueryInflationRateRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _Query_AnnualProvisions_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(QueryAnnualProvisionsRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(QueryServer).AnnualProvisions(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/babylon.mint.v1.Query/AnnualProvisions", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(QueryServer).AnnualProvisions(ctx, req.(*QueryAnnualProvisionsRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _Query_GenesisTime_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(QueryGenesisTimeRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(QueryServer).GenesisTime(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/babylon.mint.v1.Query/GenesisTime", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(QueryServer).GenesisTime(ctx, req.(*QueryGenesisTimeRequest)) + } + return interceptor(ctx, in, info, handler) +} + +var _Query_serviceDesc = grpc.ServiceDesc{ + ServiceName: "babylon.mint.v1.Query", + HandlerType: (*QueryServer)(nil), + Methods: []grpc.MethodDesc{ + { + MethodName: "InflationRate", + Handler: _Query_InflationRate_Handler, + }, + { + MethodName: "AnnualProvisions", + Handler: _Query_AnnualProvisions_Handler, + }, + { + MethodName: "GenesisTime", + Handler: _Query_GenesisTime_Handler, + }, + }, + Streams: []grpc.StreamDesc{}, + Metadata: "babylon/mint/v1/query.proto", +} + +func (m *QueryInflationRateRequest) 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 *QueryInflationRateRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryInflationRateRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + return len(dAtA) - i, nil +} + +func (m *QueryInflationRateResponse) 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 *QueryInflationRateResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryInflationRateResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + { + size := m.InflationRate.Size() + i -= size + if _, err := m.InflationRate.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + return len(dAtA) - i, nil +} + +func (m *QueryAnnualProvisionsRequest) 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 *QueryAnnualProvisionsRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryAnnualProvisionsRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + return len(dAtA) - i, nil +} + +func (m *QueryAnnualProvisionsResponse) 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 *QueryAnnualProvisionsResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryAnnualProvisionsResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + { + size := m.AnnualProvisions.Size() + i -= size + if _, err := m.AnnualProvisions.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + return len(dAtA) - i, nil +} + +func (m *QueryGenesisTimeRequest) 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 *QueryGenesisTimeRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryGenesisTimeRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + return len(dAtA) - i, nil +} + +func (m *QueryGenesisTimeResponse) 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 *QueryGenesisTimeResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryGenesisTimeResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.GenesisTime != nil { + n1, err1 := github_com_cosmos_gogoproto_types.StdTimeMarshalTo(*m.GenesisTime, dAtA[i-github_com_cosmos_gogoproto_types.SizeOfStdTime(*m.GenesisTime):]) + if err1 != nil { + return 0, err1 + } + i -= n1 + i = encodeVarintQuery(dAtA, i, uint64(n1)) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func encodeVarintQuery(dAtA []byte, offset int, v uint64) int { + offset -= sovQuery(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *QueryInflationRateRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + return n +} + +func (m *QueryInflationRateResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = m.InflationRate.Size() + n += 1 + l + sovQuery(uint64(l)) + return n +} + +func (m *QueryAnnualProvisionsRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + return n +} + +func (m *QueryAnnualProvisionsResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = m.AnnualProvisions.Size() + n += 1 + l + sovQuery(uint64(l)) + return n +} + +func (m *QueryGenesisTimeRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + return n +} + +func (m *QueryGenesisTimeResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.GenesisTime != nil { + l = github_com_cosmos_gogoproto_types.SizeOfStdTime(*m.GenesisTime) + n += 1 + l + sovQuery(uint64(l)) + } + return n +} + +func sovQuery(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozQuery(x uint64) (n int) { + return sovQuery(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *QueryInflationRateRequest) 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: QueryInflationRateRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryInflationRateRequest: 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 *QueryInflationRateResponse) 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: QueryInflationRateResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryInflationRateResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field InflationRate", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.InflationRate.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 *QueryAnnualProvisionsRequest) 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: QueryAnnualProvisionsRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryAnnualProvisionsRequest: 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 *QueryAnnualProvisionsResponse) 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: QueryAnnualProvisionsResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryAnnualProvisionsResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field AnnualProvisions", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.AnnualProvisions.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 *QueryGenesisTimeRequest) 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: QueryGenesisTimeRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryGenesisTimeRequest: 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 *QueryGenesisTimeResponse) 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: QueryGenesisTimeResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryGenesisTimeResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field GenesisTime", 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.GenesisTime == nil { + m.GenesisTime = new(time.Time) + } + if err := github_com_cosmos_gogoproto_types.StdTimeUnmarshal(m.GenesisTime, 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 skipQuery(dAtA []byte) (n int, err error) { + l := len(dAtA) + iNdEx := 0 + depth := 0 + for iNdEx < l { + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowQuery + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + wireType := int(wire & 0x7) + switch wireType { + case 0: + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowQuery + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + iNdEx++ + if dAtA[iNdEx-1] < 0x80 { + break + } + } + case 1: + iNdEx += 8 + case 2: + var length int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowQuery + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + length |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + if length < 0 { + return 0, ErrInvalidLengthQuery + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupQuery + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthQuery + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthQuery = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowQuery = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupQuery = fmt.Errorf("proto: unexpected end of group") +) diff --git a/x/mint/types/query.pb.gw.go b/x/mint/types/query.pb.gw.go new file mode 100644 index 000000000..d9ca42c48 --- /dev/null +++ b/x/mint/types/query.pb.gw.go @@ -0,0 +1,283 @@ +// Code generated by protoc-gen-grpc-gateway. DO NOT EDIT. +// source: babylon/mint/v1/query.proto + +/* +Package types is a reverse proxy. + +It translates gRPC into RESTful JSON APIs. +*/ +package types + +import ( + "context" + "io" + "net/http" + + "github.com/golang/protobuf/descriptor" + "github.com/golang/protobuf/proto" + "github.com/grpc-ecosystem/grpc-gateway/runtime" + "github.com/grpc-ecosystem/grpc-gateway/utilities" + "google.golang.org/grpc" + "google.golang.org/grpc/codes" + "google.golang.org/grpc/grpclog" + "google.golang.org/grpc/metadata" + "google.golang.org/grpc/status" +) + +// Suppress "imported and not used" errors +var _ codes.Code +var _ io.Reader +var _ status.Status +var _ = runtime.String +var _ = utilities.NewDoubleArray +var _ = descriptor.ForMessage +var _ = metadata.Join + +func request_Query_InflationRate_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryInflationRateRequest + var metadata runtime.ServerMetadata + + msg, err := client.InflationRate(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_Query_InflationRate_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryInflationRateRequest + var metadata runtime.ServerMetadata + + msg, err := server.InflationRate(ctx, &protoReq) + return msg, metadata, err + +} + +func request_Query_AnnualProvisions_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryAnnualProvisionsRequest + var metadata runtime.ServerMetadata + + msg, err := client.AnnualProvisions(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_Query_AnnualProvisions_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryAnnualProvisionsRequest + var metadata runtime.ServerMetadata + + msg, err := server.AnnualProvisions(ctx, &protoReq) + return msg, metadata, err + +} + +func request_Query_GenesisTime_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryGenesisTimeRequest + var metadata runtime.ServerMetadata + + msg, err := client.GenesisTime(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_Query_GenesisTime_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryGenesisTimeRequest + var metadata runtime.ServerMetadata + + msg, err := server.GenesisTime(ctx, &protoReq) + return msg, metadata, err + +} + +// RegisterQueryHandlerServer registers the http handlers for service Query to "mux". +// UnaryRPC :call QueryServer directly. +// StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906. +// Note that using this registration option will cause many gRPC library features to stop working. Consider using RegisterQueryHandlerFromEndpoint instead. +func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, server QueryServer) error { + + mux.Handle("GET", pattern_Query_InflationRate_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_Query_InflationRate_0(rctx, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Query_InflationRate_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("GET", pattern_Query_AnnualProvisions_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_Query_AnnualProvisions_0(rctx, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Query_AnnualProvisions_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("GET", pattern_Query_GenesisTime_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_Query_GenesisTime_0(rctx, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Query_GenesisTime_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + return nil +} + +// RegisterQueryHandlerFromEndpoint is same as RegisterQueryHandler but +// automatically dials to "endpoint" and closes the connection when "ctx" gets done. +func RegisterQueryHandlerFromEndpoint(ctx context.Context, mux *runtime.ServeMux, endpoint string, opts []grpc.DialOption) (err error) { + conn, err := grpc.Dial(endpoint, opts...) + if err != nil { + return err + } + defer func() { + if err != nil { + if cerr := conn.Close(); cerr != nil { + grpclog.Infof("Failed to close conn to %s: %v", endpoint, cerr) + } + return + } + go func() { + <-ctx.Done() + if cerr := conn.Close(); cerr != nil { + grpclog.Infof("Failed to close conn to %s: %v", endpoint, cerr) + } + }() + }() + + return RegisterQueryHandler(ctx, mux, conn) +} + +// RegisterQueryHandler registers the http handlers for service Query to "mux". +// The handlers forward requests to the grpc endpoint over "conn". +func RegisterQueryHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc.ClientConn) error { + return RegisterQueryHandlerClient(ctx, mux, NewQueryClient(conn)) +} + +// RegisterQueryHandlerClient registers the http handlers for service Query +// to "mux". The handlers forward requests to the grpc endpoint over the given implementation of "QueryClient". +// Note: the gRPC framework executes interceptors within the gRPC handler. If the passed in "QueryClient" +// doesn't go through the normal gRPC flow (creating a gRPC client etc.) then it will be up to the passed in +// "QueryClient" to call the correct interceptors. +func RegisterQueryHandlerClient(ctx context.Context, mux *runtime.ServeMux, client QueryClient) error { + + mux.Handle("GET", pattern_Query_InflationRate_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_Query_InflationRate_0(rctx, inboundMarshaler, client, req, pathParams) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Query_InflationRate_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("GET", pattern_Query_AnnualProvisions_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_Query_AnnualProvisions_0(rctx, inboundMarshaler, client, req, pathParams) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Query_AnnualProvisions_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("GET", pattern_Query_GenesisTime_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_Query_GenesisTime_0(rctx, inboundMarshaler, client, req, pathParams) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Query_GenesisTime_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + return nil +} + +var ( + pattern_Query_InflationRate_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"cosmos", "mint", "v1beta1", "inflation_rate"}, "", runtime.AssumeColonVerbOpt(false))) + + pattern_Query_AnnualProvisions_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"cosmos", "mint", "v1beta1", "annual_provisions"}, "", runtime.AssumeColonVerbOpt(false))) + + pattern_Query_GenesisTime_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"cosmos", "mint", "v1beta1", "genesis_time"}, "", runtime.AssumeColonVerbOpt(false))) +) + +var ( + forward_Query_InflationRate_0 = runtime.ForwardResponseMessage + + forward_Query_AnnualProvisions_0 = runtime.ForwardResponseMessage + + forward_Query_GenesisTime_0 = runtime.ForwardResponseMessage +) diff --git a/x/monitor/keeper/grpc_query_test.go b/x/monitor/keeper/grpc_query_test.go index 9f47095b4..623498a58 100644 --- a/x/monitor/keeper/grpc_query_test.go +++ b/x/monitor/keeper/grpc_query_test.go @@ -35,7 +35,6 @@ func FuzzQueryEndedEpochBtcHeight(f *testing.F) { root := lck.GetBaseBTCHeader(ctx) chain := datagen.GenRandomValidChainStartingFrom( r, - 0, root.Header.ToBlockHeader(), nil, 10, @@ -92,7 +91,6 @@ func FuzzQueryReportedCheckpointBtcHeight(f *testing.F) { root := lck.GetBaseBTCHeader(ctx) chain := datagen.GenRandomValidChainStartingFrom( r, - 0, root.Header.ToBlockHeader(), nil, 10, diff --git a/x/monitor/keeper/keeper.go b/x/monitor/keeper/keeper.go index c7ada1120..9b711c2cf 100644 --- a/x/monitor/keeper/keeper.go +++ b/x/monitor/keeper/keeper.go @@ -4,6 +4,7 @@ import ( "context" corestoretypes "cosmossdk.io/core/store" "fmt" + "math" ckpttypes "github.com/babylonlabs-io/babylon/x/checkpointing/types" @@ -37,18 +38,23 @@ func (k Keeper) Logger(ctx sdk.Context) log.Logger { return ctx.Logger().With("module", fmt.Sprintf("x/%s", types.ModuleName)) } -func bytesToUint64(bytes []byte) (uint64, error) { - if len(bytes) != 8 { - return 0, fmt.Errorf("epoch bytes must have exactly 8 bytes") +func bytesToBtcHeight(heightBytes []byte) (uint32, error) { + if len(heightBytes) != 8 { + return 0, fmt.Errorf("height bytes must have exactly 8 bytes") } - return sdk.BigEndianToUint64(bytes), nil + heightUint64 := sdk.BigEndianToUint64(heightBytes) + if heightUint64 > math.MaxUint32 { + return 0, fmt.Errorf("height should not be higher than math.MaxUint32") + } + + return uint32(heightUint64), nil } func (k Keeper) updateBtcLightClientHeightForEpoch(ctx context.Context, epoch uint64) { store := k.storeService.OpenKVStore(ctx) currentTipHeight := k.btcLightClientKeeper.GetTipInfo(ctx).Height - if err := store.Set(types.GetEpochEndLightClientHeightKey(epoch), sdk.Uint64ToBigEndian(currentTipHeight)); err != nil { + if err := store.Set(types.GetEpochEndLightClientHeightKey(epoch), sdk.Uint64ToBigEndian(uint64(currentTipHeight))); err != nil { panic(err) } } @@ -74,7 +80,7 @@ func (k Keeper) updateBtcLightClientHeightForCheckpoint(ctx context.Context, ckp } currentTipHeight := k.btcLightClientKeeper.GetTipInfo(ctx).Height - return store.Set(storeKey, sdk.Uint64ToBigEndian(currentTipHeight)) + return store.Set(storeKey, sdk.Uint64ToBigEndian(uint64(currentTipHeight))) } func (k Keeper) removeCheckpointRecord(ctx context.Context, ckpt *ckpttypes.RawCheckpoint) error { @@ -92,7 +98,7 @@ func (k Keeper) removeCheckpointRecord(ctx context.Context, ckpt *ckpttypes.RawC return nil } -func (k Keeper) LightclientHeightAtEpochEnd(ctx context.Context, epoch uint64) (uint64, error) { +func (k Keeper) LightclientHeightAtEpochEnd(ctx context.Context, epoch uint64) (uint32, error) { if epoch == 0 { return k.btcLightClientKeeper.GetBaseBTCHeader(ctx).Height, nil } @@ -110,7 +116,7 @@ func (k Keeper) LightclientHeightAtEpochEnd(ctx context.Context, epoch uint64) ( return 0, types.ErrEpochNotEnded.Wrapf("epoch %d", epoch) } - btcHeight, err := bytesToUint64(btcHeightBytes) + btcHeight, err := bytesToBtcHeight(btcHeightBytes) if err != nil { panic("Invalid data in database") @@ -119,7 +125,7 @@ func (k Keeper) LightclientHeightAtEpochEnd(ctx context.Context, epoch uint64) ( return btcHeight, nil } -func (k Keeper) LightclientHeightAtCheckpointReported(ctx context.Context, hashString string) (uint64, error) { +func (k Keeper) LightclientHeightAtCheckpointReported(ctx context.Context, hashString string) (uint32, error) { store := k.storeService.OpenKVStore(ctx) storeKey, err := types.GetCheckpointReportedLightClientHeightKey(hashString) @@ -136,7 +142,7 @@ func (k Keeper) LightclientHeightAtCheckpointReported(ctx context.Context, hashS return 0, types.ErrCheckpointNotReported.Wrapf("checkpoint hash: %s", hashString) } - btcHeight, err := bytesToUint64(btcHeightBytes) + btcHeight, err := bytesToBtcHeight(btcHeightBytes) if err != nil { panic("invalid data in database") } diff --git a/x/monitor/module.go b/x/monitor/module.go index 40586622e..0c1c95864 100644 --- a/x/monitor/module.go +++ b/x/monitor/module.go @@ -81,7 +81,9 @@ func (AppModuleBasic) RegisterRESTRoutes(clientCtx client.Context, rtr *mux.Rout // RegisterGRPCGatewayRoutes registers the gRPC Gateway routes for the module. func (AppModuleBasic) RegisterGRPCGatewayRoutes(clientCtx client.Context, mux *runtime.ServeMux) { - types.RegisterQueryHandlerClient(context.Background(), mux, types.NewQueryClient(clientCtx)) //nolint:errcheck // generally we don't handle errors in these registration functions + if err := types.RegisterQueryHandlerClient(context.Background(), mux, types.NewQueryClient(clientCtx)); err != nil { + panic(err) + } } // GetTxCmd returns the capability module's root tx command. diff --git a/x/monitor/types/query.pb.go b/x/monitor/types/query.pb.go index 321e6d2de..ea4ce0689 100644 --- a/x/monitor/types/query.pb.go +++ b/x/monitor/types/query.pb.go @@ -78,7 +78,7 @@ func (m *QueryEndedEpochBtcHeightRequest) GetEpochNum() uint64 { // EndedEpochBtcHeight RPC method type QueryEndedEpochBtcHeightResponse struct { // height of btc light client when epoch ended - BtcLightClientHeight uint64 `protobuf:"varint,1,opt,name=btc_light_client_height,json=btcLightClientHeight,proto3" json:"btc_light_client_height,omitempty"` + BtcLightClientHeight uint32 `protobuf:"varint,1,opt,name=btc_light_client_height,json=btcLightClientHeight,proto3" json:"btc_light_client_height,omitempty"` } func (m *QueryEndedEpochBtcHeightResponse) Reset() { *m = QueryEndedEpochBtcHeightResponse{} } @@ -114,7 +114,7 @@ func (m *QueryEndedEpochBtcHeightResponse) XXX_DiscardUnknown() { var xxx_messageInfo_QueryEndedEpochBtcHeightResponse proto.InternalMessageInfo -func (m *QueryEndedEpochBtcHeightResponse) GetBtcLightClientHeight() uint64 { +func (m *QueryEndedEpochBtcHeightResponse) GetBtcLightClientHeight() uint32 { if m != nil { return m.BtcLightClientHeight } @@ -174,7 +174,7 @@ func (m *QueryReportedCheckpointBtcHeightRequest) GetCkptHash() string { // ReportedCheckpointBtcHeight RPC method type QueryReportedCheckpointBtcHeightResponse struct { // height of btc light client when checkpoint is reported - BtcLightClientHeight uint64 `protobuf:"varint,1,opt,name=btc_light_client_height,json=btcLightClientHeight,proto3" json:"btc_light_client_height,omitempty"` + BtcLightClientHeight uint32 `protobuf:"varint,1,opt,name=btc_light_client_height,json=btcLightClientHeight,proto3" json:"btc_light_client_height,omitempty"` } func (m *QueryReportedCheckpointBtcHeightResponse) Reset() { @@ -212,7 +212,7 @@ func (m *QueryReportedCheckpointBtcHeightResponse) XXX_DiscardUnknown() { var xxx_messageInfo_QueryReportedCheckpointBtcHeightResponse proto.InternalMessageInfo -func (m *QueryReportedCheckpointBtcHeightResponse) GetBtcLightClientHeight() uint64 { +func (m *QueryReportedCheckpointBtcHeightResponse) GetBtcLightClientHeight() uint32 { if m != nil { return m.BtcLightClientHeight } @@ -229,33 +229,33 @@ func init() { func init() { proto.RegisterFile("babylon/monitor/v1/query.proto", fileDescriptor_a8aafb034c55a8f2) } var fileDescriptor_a8aafb034c55a8f2 = []byte{ - // 405 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xa4, 0x53, 0x4d, 0xab, 0x13, 0x31, - 0x14, 0xed, 0xf8, 0x45, 0x9b, 0x65, 0x14, 0x94, 0x56, 0xc6, 0x32, 0x0b, 0x2d, 0x48, 0x27, 0xd4, - 0xea, 0x4a, 0x71, 0xd1, 0x52, 0x29, 0x28, 0x82, 0xb3, 0xd3, 0xcd, 0x90, 0x49, 0xc3, 0x24, 0x74, - 0x26, 0x49, 0x27, 0x99, 0x62, 0x29, 0xdd, 0xb8, 0x74, 0x25, 0xf8, 0x47, 0xfc, 0x19, 0x6e, 0x84, - 0x82, 0x1b, 0x97, 0xd2, 0xfa, 0x43, 0x64, 0xd2, 0x79, 0xb3, 0x79, 0xd3, 0x57, 0xde, 0x7b, 0xcb, - 0xdc, 0x93, 0x73, 0xee, 0x3d, 0xf7, 0x24, 0xc0, 0x8d, 0x70, 0xb4, 0x4a, 0xa4, 0x40, 0xa9, 0x14, - 0xdc, 0xc8, 0x0c, 0x2d, 0x07, 0x68, 0x91, 0xd3, 0x6c, 0xe5, 0xab, 0x4c, 0x1a, 0x09, 0x61, 0x89, - 0xfb, 0x25, 0xee, 0x2f, 0x07, 0xed, 0x87, 0xb1, 0x94, 0x71, 0x42, 0x11, 0x56, 0x1c, 0x61, 0x21, - 0xa4, 0xc1, 0x86, 0x4b, 0xa1, 0x0f, 0x0c, 0xef, 0x35, 0x78, 0xf4, 0xa1, 0x10, 0x98, 0x88, 0x19, - 0x9d, 0x4d, 0x94, 0x24, 0x6c, 0x64, 0xc8, 0x94, 0xf2, 0x98, 0x99, 0x80, 0x2e, 0x72, 0xaa, 0x0d, - 0xec, 0x80, 0x16, 0x2d, 0x80, 0x50, 0xe4, 0xe9, 0x03, 0xa7, 0xeb, 0xf4, 0x6e, 0x05, 0x4d, 0x5b, - 0x78, 0x9f, 0xa7, 0xde, 0x47, 0xd0, 0x3d, 0xce, 0xd7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xdc, 0xb0, 0x3c, - 0xf2, 0x89, 0x4c, 0xcf, 0x04, 0x13, 0x1c, 0xe9, 0x3e, 0x97, 0x95, 0xfe, 0xe7, 0xaa, 0x83, 0x59, - 0x29, 0xaa, 0xa3, 0x3b, 0xf6, 0x9b, 0x0c, 0xff, 0x07, 0x00, 0x00, 0xff, 0xff, 0x10, 0xaa, 0x98, - 0x3e, 0x7a, 0x03, 0x00, 0x00, + // 408 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xa4, 0x53, 0xcf, 0x8b, 0x13, 0x31, + 0x18, 0xed, 0xf8, 0x8b, 0x36, 0xe0, 0x25, 0x0a, 0x4a, 0x2b, 0x63, 0x99, 0x83, 0x16, 0xa4, 0x13, + 0x6a, 0xf5, 0xa4, 0x78, 0x68, 0xa9, 0x14, 0x14, 0xc1, 0xb9, 0xe9, 0x65, 0xc8, 0xa4, 0x61, 0x12, + 0x3a, 0x93, 0xa4, 0x93, 0x4c, 0xb1, 0x94, 0x5e, 0x3c, 0x7a, 0x12, 0xfc, 0x47, 0xfc, 0x33, 0xbc, + 0x08, 0x05, 0x2f, 0x1e, 0x97, 0x76, 0xff, 0x90, 0x65, 0xd2, 0xee, 0x5c, 0x76, 0xba, 0x65, 0x77, + 0x8f, 0xf9, 0x5e, 0xde, 0xfb, 0xbe, 0xf7, 0xbd, 0x04, 0xb8, 0x11, 0x8e, 0x16, 0x89, 0x14, 0x28, + 0x95, 0x82, 0x1b, 0x99, 0xa1, 0x79, 0x0f, 0xcd, 0x72, 0x9a, 0x2d, 0x7c, 0x95, 0x49, 0x23, 0x21, + 0xdc, 0xe3, 0xfe, 0x1e, 0xf7, 0xe7, 0xbd, 0xe6, 0x93, 0x58, 0xca, 0x38, 0xa1, 0x08, 0x2b, 0x8e, + 0xb0, 0x10, 0xd2, 0x60, 0xc3, 0xa5, 0xd0, 0x3b, 0x86, 0xf7, 0x0e, 0x3c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6f, 0xaf, 0x47, 0xde, 0x5b, 0xe9, 0x5b, 0x2b, 0x5d, 0xf8, 0xa2, 0xca, 0x0a, + 0x29, 0x89, 0x1a, 0x2d, 0xcb, 0xf8, 0x57, 0x83, 0x0f, 0x7f, 0x36, 0xae, 0xb3, 0xde, 0xb8, 0xce, + 0xc9, 0xc6, 0x75, 0x7e, 0x6e, 0xdd, 0xda, 0x7a, 0xeb, 0xd6, 0xfe, 0x6f, 0xdd, 0xda, 0xd7, 0x5e, + 0xcc, 0x0d, 0xcb, 0x23, 0x9f, 0xc8, 0xf4, 0x5c, 0x30, 0xc1, 0x91, 0xee, 0x72, 0x59, 0xea, 0x7f, + 0x2b, 0x3b, 0x98, 0x85, 0xa2, 0x3a, 0xba, 0x67, 0xbf, 0x49, 0xff, 0x2c, 0x00, 0x00, 0xff, 0xff, + 0x85, 0xb8, 0x2a, 0x58, 0x7a, 0x03, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -674,7 +674,7 @@ func (m *QueryEndedEpochBtcHeightResponse) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - m.BtcLightClientHeight |= uint64(b&0x7F) << shift + m.BtcLightClientHeight |= uint32(b&0x7F) << shift if b < 0x80 { break } @@ -825,7 +825,7 @@ func (m *QueryReportedCheckpointBtcHeightResponse) Unmarshal(dAtA []byte) error } b := dAtA[iNdEx] iNdEx++ - m.BtcLightClientHeight |= uint64(b&0x7F) << shift + m.BtcLightClientHeight |= uint32(b&0x7F) << shift if b < 0x80 { break } diff --git a/x/zoneconcierge/keeper/ibc_packet_btc_timestamp.go b/x/zoneconcierge/keeper/ibc_packet_btc_timestamp.go index 447051973..bfc995f2a 100644 --- a/x/zoneconcierge/keeper/ibc_packet_btc_timestamp.go +++ b/x/zoneconcierge/keeper/ibc_packet_btc_timestamp.go @@ -102,7 +102,7 @@ func (k Keeper) createBTCTimestamp( var btcHeaders []*btclctypes.BTCHeaderInfo if k.isChannelUninitialized(ctx, channel) { w := k.btccKeeper.GetParams(ctx).CheckpointFinalizationTimeout - depth := w + 1 + uint64(len(finalizedInfo.BTCHeaders)) + depth := w + 1 + uint32(len(finalizedInfo.BTCHeaders)) btcHeaders = k.btclcKeeper.GetMainChainUpTo(ctx, depth) if btcHeaders == nil { diff --git a/x/zoneconcierge/keeper/ibc_packet_btc_timestamp_test.go b/x/zoneconcierge/keeper/ibc_packet_btc_timestamp_test.go index 014203fe5..1b3194664 100644 --- a/x/zoneconcierge/keeper/ibc_packet_btc_timestamp_test.go +++ b/x/zoneconcierge/keeper/ibc_packet_btc_timestamp_test.go @@ -23,8 +23,8 @@ func genRandomChain( r *rand.Rand, k *btclckeeper.Keeper, ctx context.Context, - initialHeight uint64, - chainLength uint64, + initialHeight uint32, + chainLength uint32, ) *datagen.BTCHeaderPartialChain { initHeader := k.GetHeaderByHeight(ctx, initialHeight) randomChain := datagen.NewBTCHeaderChainFromParentInfo( @@ -55,7 +55,7 @@ func FuzzGetHeadersToBroadcast(f *testing.F) { // insert a random number of BTC headers to BTC light client wValue := babylonApp.BtcCheckpointKeeper.GetParams(ctx).CheckpointFinalizationTimeout - chainLength := datagen.RandomInt(r, 10) + wValue + chainLength := uint32(datagen.RandomInt(r, 10)) + wValue genRandomChain( t, r, @@ -75,12 +75,12 @@ func FuzzGetHeadersToBroadcast(f *testing.F) { lastSegment := zcKeeper.GetLastSentSegment(ctx) require.Len(t, lastSegment.BtcHeaders, int(wValue)+1) for i := range lastSegment.BtcHeaders { - require.Equal(t, btclcKeeper.GetHeaderByHeight(ctx, btcTip.Height-wValue+uint64(i)), lastSegment.BtcHeaders[i]) + require.Equal(t, btclcKeeper.GetHeaderByHeight(ctx, btcTip.Height-wValue+uint32(i)), lastSegment.BtcHeaders[i]) } // finalise another epoch, during which a small number of new BTC headers are inserted epochNum += 1 - chainLength = datagen.RandomInt(r, 10) + 1 + chainLength = uint32(datagen.RandomInt(r, 10)) + 1 genRandomChain( t, r, @@ -95,22 +95,22 @@ func FuzzGetHeadersToBroadcast(f *testing.F) { lastSegment = zcKeeper.GetLastSentSegment(ctx) require.Len(t, lastSegment.BtcHeaders, int(chainLength)) for i := range lastSegment.BtcHeaders { - require.Equal(t, btclcKeeper.GetHeaderByHeight(ctx, uint64(i)+btcTip.Height+1), lastSegment.BtcHeaders[i]) + require.Equal(t, btclcKeeper.GetHeaderByHeight(ctx, uint32(i)+btcTip.Height+1), lastSegment.BtcHeaders[i]) } // remember the current tip and the segment length btcTip = btclcKeeper.GetTipInfo(ctx) - lastSegmentLength := uint64(len(lastSegment.BtcHeaders)) + lastSegmentLength := uint32(len(lastSegment.BtcHeaders)) // finalise another epoch, during which a number of new BTC headers with reorg are inserted epochNum += 1 // reorg at a super random point // NOTE: it's possible that the last segment is totally reverted. We want to be resilient against // this, by sending the BTC headers since the last reorg point - reorgPoint := datagen.RandomInt(r, int(btcTip.Height)) - revertedChainLength := btcTip.Height - reorgPoint + reorgPoint := uint32(datagen.RandomInt(r, int(btcTip.Height))) + revertedChainLength := btcTip.Height - uint32(reorgPoint) // the fork chain needs to be longer than the canonical one - forkChainLength := revertedChainLength + datagen.RandomInt(r, 10) + 1 + forkChainLength := revertedChainLength + uint32(datagen.RandomInt(r, 10)) + 1 genRandomChain( t, r, @@ -130,7 +130,7 @@ func FuzzGetHeadersToBroadcast(f *testing.F) { require.Len(t, lastSegment.BtcHeaders, int(wValue)+1) // assert the consistency of w+1 sent BTC headers for i := range lastSegment.BtcHeaders { - expectedHeight := btcTip.Height - wValue + uint64(i) + expectedHeight := btcTip.Height - wValue + uint32(i) require.Equal(t, btclcKeeper.GetHeaderByHeight(ctx, expectedHeight), lastSegment.BtcHeaders[i]) } } else { @@ -138,7 +138,7 @@ func FuzzGetHeadersToBroadcast(f *testing.F) { require.Len(t, lastSegment.BtcHeaders, int(forkChainLength)) // assert the consistency of the sent fork BTC headers for i := range lastSegment.BtcHeaders { - expectedHeight := btcTip.Height - forkChainLength + 1 + uint64(i) + expectedHeight := btcTip.Height - forkChainLength + 1 + uint32(i) require.Equal(t, btclcKeeper.GetHeaderByHeight(ctx, expectedHeight), lastSegment.BtcHeaders[i]) } } diff --git a/x/zoneconcierge/types/btc_timestamp.go b/x/zoneconcierge/types/btc_timestamp.go index de88561d5..7d9871a15 100644 --- a/x/zoneconcierge/types/btc_timestamp.go +++ b/x/zoneconcierge/types/btc_timestamp.go @@ -261,7 +261,7 @@ func VerifyEpochSubmitted(rawCkpt *checkpointingtypes.RawCheckpoint, txsInfo []* func (ts *BTCTimestamp) Verify( ctx context.Context, btclcKeeper *btclckeeper.Keeper, - wValue uint64, + wValue uint32, ckptTag txformat.BabylonTag, ) error { // BTC net diff --git a/x/zoneconcierge/types/expected_keepers.go b/x/zoneconcierge/types/expected_keepers.go index 97b2cde0e..a3f769408 100644 --- a/x/zoneconcierge/types/expected_keepers.go +++ b/x/zoneconcierge/types/expected_keepers.go @@ -81,8 +81,8 @@ type ScopedKeeper interface { type BTCLightClientKeeper interface { GetTipInfo(ctx context.Context) *btclctypes.BTCHeaderInfo - GetMainChainFrom(ctx context.Context, startHeight uint64) []*btclctypes.BTCHeaderInfo - GetMainChainUpTo(ctx context.Context, depth uint64) []*btclctypes.BTCHeaderInfo + GetMainChainFrom(ctx context.Context, startHeight uint32) []*btclctypes.BTCHeaderInfo + GetMainChainUpTo(ctx context.Context, depth uint32) []*btclctypes.BTCHeaderInfo GetHeaderByHash(ctx context.Context, hash *bbn.BTCHeaderHashBytes) *btclctypes.BTCHeaderInfo } diff --git a/x/zoneconcierge/types/mocked_keepers.go b/x/zoneconcierge/types/mocked_keepers.go index d50e8fc48..9ef04a13c 100644 --- a/x/zoneconcierge/types/mocked_keepers.go +++ b/x/zoneconcierge/types/mocked_keepers.go @@ -548,7 +548,7 @@ func (mr *MockBTCLightClientKeeperMockRecorder) GetHeaderByHash(ctx, hash interf } // GetMainChainFrom mocks base method. -func (m *MockBTCLightClientKeeper) GetMainChainFrom(ctx context.Context, startHeight uint64) []*types1.BTCHeaderInfo { +func (m *MockBTCLightClientKeeper) GetMainChainFrom(ctx context.Context, startHeight uint32) []*types1.BTCHeaderInfo { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "GetMainChainFrom", ctx, startHeight) ret0, _ := ret[0].([]*types1.BTCHeaderInfo) @@ -562,7 +562,7 @@ func (mr *MockBTCLightClientKeeperMockRecorder) GetMainChainFrom(ctx, startHeigh } // GetMainChainUpTo mocks base method. -func (m *MockBTCLightClientKeeper) GetMainChainUpTo(ctx context.Context, depth uint64) []*types1.BTCHeaderInfo { +func (m *MockBTCLightClientKeeper) GetMainChainUpTo(ctx context.Context, depth uint32) []*types1.BTCHeaderInfo { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "GetMainChainUpTo", ctx, depth) ret0, _ := ret[0].([]*types1.BTCHeaderInfo) @@ -852,6 +852,49 @@ func (mr *MockBTCStakingKeeperMockRecorder) GetAllBTCStakingConsumerIBCPackets(c return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetAllBTCStakingConsumerIBCPackets", reflect.TypeOf((*MockBTCStakingKeeper)(nil).GetAllBTCStakingConsumerIBCPackets), ctx) } +// GetFPBTCDelegations mocks base method. +func (m *MockBTCStakingKeeper) GetFPBTCDelegations(ctx context.Context, fpBTCPK *types.BIP340PubKey) ([]*types2.BTCDelegation, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "GetFPBTCDelegations", ctx, fpBTCPK) + ret0, _ := ret[0].([]*types2.BTCDelegation) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// GetFPBTCDelegations indicates an expected call of GetFPBTCDelegations. +func (mr *MockBTCStakingKeeperMockRecorder) GetFPBTCDelegations(ctx, fpBTCPK interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetFPBTCDelegations", reflect.TypeOf((*MockBTCStakingKeeper)(nil).GetFPBTCDelegations), ctx, fpBTCPK) +} + +// PropagateFPSlashingToConsumers mocks base method. +func (m *MockBTCStakingKeeper) PropagateFPSlashingToConsumers(ctx context.Context, fpBTCPK *types.BIP340PubKey) error { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "PropagateFPSlashingToConsumers", ctx, fpBTCPK) + ret0, _ := ret[0].(error) + return ret0 +} + +// PropagateFPSlashingToConsumers indicates an expected call of PropagateFPSlashingToConsumers. +func (mr *MockBTCStakingKeeperMockRecorder) PropagateFPSlashingToConsumers(ctx, fpBTCPK interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "PropagateFPSlashingToConsumers", reflect.TypeOf((*MockBTCStakingKeeper)(nil).PropagateFPSlashingToConsumers), ctx, fpBTCPK) +} + +// SlashConsumerFinalityProvider mocks base method. +func (m *MockBTCStakingKeeper) SlashConsumerFinalityProvider(ctx context.Context, consumerID string, fpBTCPK *types.BIP340PubKey) error { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "SlashConsumerFinalityProvider", ctx, consumerID, fpBTCPK) + ret0, _ := ret[0].(error) + return ret0 +} + +// SlashConsumerFinalityProvider indicates an expected call of SlashConsumerFinalityProvider. +func (mr *MockBTCStakingKeeperMockRecorder) SlashConsumerFinalityProvider(ctx, consumerID, fpBTCPK interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SlashConsumerFinalityProvider", reflect.TypeOf((*MockBTCStakingKeeper)(nil).SlashConsumerFinalityProvider), ctx, consumerID, fpBTCPK) +} + // MockBTCStkConsumerKeeper is a mock of BTCStkConsumerKeeper interface. type MockBTCStkConsumerKeeper struct { ctrl *gomock.Controller @@ -875,6 +918,36 @@ func (m *MockBTCStkConsumerKeeper) EXPECT() *MockBTCStkConsumerKeeperMockRecorde return m.recorder } +// GetConsumerFinalityProvider mocks base method. +func (m *MockBTCStkConsumerKeeper) GetConsumerFinalityProvider(ctx context.Context, consumerID string, fpBTCPK *types.BIP340PubKey) (*types2.FinalityProvider, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "GetConsumerFinalityProvider", ctx, consumerID, fpBTCPK) + ret0, _ := ret[0].(*types2.FinalityProvider) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// GetConsumerFinalityProvider indicates an expected call of GetConsumerFinalityProvider. +func (mr *MockBTCStkConsumerKeeperMockRecorder) GetConsumerFinalityProvider(ctx, consumerID, fpBTCPK interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetConsumerFinalityProvider", reflect.TypeOf((*MockBTCStkConsumerKeeper)(nil).GetConsumerFinalityProvider), ctx, consumerID, fpBTCPK) +} + +// GetConsumerOfFinalityProvider mocks base method. +func (m *MockBTCStkConsumerKeeper) GetConsumerOfFinalityProvider(ctx context.Context, fpBTCPK *types.BIP340PubKey) (string, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "GetConsumerOfFinalityProvider", ctx, fpBTCPK) + ret0, _ := ret[0].(string) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// GetConsumerOfFinalityProvider indicates an expected call of GetConsumerOfFinalityProvider. +func (mr *MockBTCStkConsumerKeeperMockRecorder) GetConsumerOfFinalityProvider(ctx, fpBTCPK interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetConsumerOfFinalityProvider", reflect.TypeOf((*MockBTCStkConsumerKeeper)(nil).GetConsumerOfFinalityProvider), ctx, fpBTCPK) +} + // RegisterConsumer mocks base method. func (m *MockBTCStkConsumerKeeper) RegisterConsumer(ctx context.Context, consumerRegister *types3.ConsumerRegister) error { m.ctrl.T.Helper() @@ -888,3 +961,15 @@ func (mr *MockBTCStkConsumerKeeperMockRecorder) RegisterConsumer(ctx, consumerRe mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "RegisterConsumer", reflect.TypeOf((*MockBTCStkConsumerKeeper)(nil).RegisterConsumer), ctx, consumerRegister) } + +// SetConsumerFinalityProvider mocks base method. +func (m *MockBTCStkConsumerKeeper) SetConsumerFinalityProvider(ctx context.Context, fp *types2.FinalityProvider) { + m.ctrl.T.Helper() + m.ctrl.Call(m, "SetConsumerFinalityProvider", ctx, fp) +} + +// SetConsumerFinalityProvider indicates an expected call of SetConsumerFinalityProvider. +func (mr *MockBTCStkConsumerKeeperMockRecorder) SetConsumerFinalityProvider(ctx, fp interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SetConsumerFinalityProvider", reflect.TypeOf((*MockBTCStkConsumerKeeper)(nil).SetConsumerFinalityProvider), ctx, fp) +}