diff --git a/.circleci/config.yml b/.circleci/config.yml deleted file mode 100644 index 538d46c07..000000000 --- a/.circleci/config.yml +++ /dev/null @@ -1,143 +0,0 @@ -# Use the latest 2.1 version of CircleCI pipeline process engine. -# See: https://circleci.com/docs/2.0/configuration-reference -version: 2.1 - -orbs: - aws-ecr: circleci/aws-ecr@8.2.1 - go: circleci/go@1.9.0 - - -jobs: - build-test: - machine: - image: ubuntu-2204:2022.10.1 - resource_class: large - steps: - - go/install: - version: "1.21.4" - - checkout - - run: - name: Print Go environment - command: "go env" - - add_ssh_keys - - go/load-cache: - key: go-mod-v6-{{ checksum "go.sum" }} - - go/mod-download - - go/save-cache: - key: go-mod-v6-{{ checksum "go.sum" }} - path: "/home/circleci/.go_workspace/pkg/mod" - - run: - name: Build babylond - command: make build - - run: - name: Run tests - command: | - make test - e2e-test: - machine: - image: ubuntu-2204:2022.10.1 - resource_class: large - steps: - - go/install: - version: "1.21.4" - - checkout - - run: - name: Print Go environment - command: "go env" - - add_ssh_keys - - run: - name: Run e2e tests - command: | - sudo ln -s /usr/local/go/bin/go /usr/bin/go - sudo make test-e2e - lint: - machine: - image: ubuntu-2204:2022.10.1 - resource_class: large - steps: - - go/install: - version: "1.21.4" - - checkout - - add_ssh_keys - - run: - name: Lint proto files - command: make proto-lint - - run: - name: Lint - command: | - curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s v1.55.2 - ./bin/golangci-lint run - - build_docker: - machine: - image: ubuntu-2204:2022.10.1 - resource_class: large - steps: - - checkout - - add_ssh_keys - - aws-ecr/build-image: - push-image: false - dockerfile: Dockerfile - path: ./contrib/images/babylond/ - build-path: ./ - tag: "$CIRCLE_SHA1,$CIRCLE_TAG" - repo: "babylond" - - run: - name: Save Docker image to export it to workspace - command: | - docker save $(docker image ls --format '{{.Repository}}:{{.Tag}}') > /tmp/babylond.tar - - persist_to_workspace: - root: /tmp - paths: - - babylond.tar - - push_docker: - machine: - image: ubuntu-2204:2022.10.1 - resource_class: large - steps: - - attach_workspace: - at: /tmp - - run: - name: Load Docker image from workspace - command: | - docker load -i /tmp/babylond.tar - - aws-ecr/ecr-login: - aws-access-key-id: AWS_ACCESS_KEY_ID - aws-secret-access-key: AWS_SECRET_ACCESS_KEY - region: "$AWS_REGION" - - aws-ecr/push-image: - registry-id: AWS_ECR_REGISTRY_ID - region: "$AWS_REGION" - repo: "babylond" - tag: "$CIRCLE_SHA1,$CIRCLE_TAG" - -# Invoke jobs via workflows -# See: https://circleci.com/docs/2.0/configuration-reference/#workflows -workflows: - version: 2 - build-test: - jobs: - - build-test - e2e-test: - jobs: - - e2e-test - lint: - jobs: - - lint - docker: - jobs: - - build_docker: - filters: - tags: - only: /.*/ - - push_docker: - requires: - - build_docker - filters: - tags: - only: /.*/ - branches: - only: - - main - - dev diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 000000000..859d3b1cf --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,24 @@ +name: ci + +on: + push: + branches: + - '**' + +jobs: + lint_test: + uses: babylonchain/.github/.github/workflows/reusable_go_lint_test.yml@v0.1.0 + with: + run-unit-tests: true + run-integration-tests: true + run-lint: true + integration-tests-command: | + sudo make test-e2e + + docker_pipeline: + uses: babylonchain/.github/.github/workflows/reusable_docker_pipeline.yml@v0.1.0 + secrets: inherit + with: + publish: false + dockerfile: ./contrib/images/babylond/Dockerfile + repoName: babylond \ No newline at end of file diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml new file mode 100644 index 000000000..b5c3cdb81 --- /dev/null +++ b/.github/workflows/publish.yml @@ -0,0 +1,28 @@ +name: docker_publish + +on: + push: + branches: + - 'main' + - 'dev' + tags: + - '*' + +jobs: + lint_test: + uses: babylonlabs-io/.github/.github/workflows/reusable_go_lint_test.yml@v0.1.0 + with: + run-unit-tests: true + run-integration-tests: true + run-lint: true + integration-tests-command: | + sudo make test-e2e + + docker_pipeline: + uses: babylonlabs-io/.github/.github/workflows/reusable_docker_pipeline.yml@v0.1.0 + needs: ["lint_test"] + secrets: inherit + with: + publish: true + dockerfile: ./contrib/images/babylond/Dockerfile + repoName: babylond diff --git a/.gitignore b/.gitignore index cf18c804e..1919b38b7 100644 --- a/.gitignore +++ b/.gitignore @@ -214,4 +214,4 @@ docs/diagrams/plantuml.jar .testnets/ .testnet/ mytestnet/ -output/ +output/ \ No newline at end of file diff --git a/CHANGELOG.md b/CHANGELOG.md index 825c32f0d..54dbc9709 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1 +1,530 @@ # Changelog + +## [v0.8.0](https://github.com/babylonlabs-io/babylon/tree/v0.8.0) (2024-02-08) + +[Full Changelog](https://github.com/babylonlabs-io/babylon/compare/v0.8.0-rc.0...v0.8.0) + +## [v0.8.0-rc.0](https://github.com/babylonlabs-io/babylon/tree/v0.8.0-rc.0) (2024-01-22) + +[Full Changelog](https://github.com/babylonlabs-io/babylon/compare/v0.7.2...v0.8.0-rc.0) + +**Closed issues:** + +- Dead Link in the Git "Joining the testnet" [\#406](https://github.com/babylonlabs-io/babylon/issues/406) +- Broken link for testnet in the main README.md [\#403](https://github.com/babylonlabs-io/babylon/issues/403) +- Random failure when running integration test [\#319](https://github.com/babylonlabs-io/babylon/issues/319) +- Refactor BLS signer to load gas settings during initiation [\#311](https://github.com/babylonlabs-io/babylon/issues/311) +- Random CI failure on QueryFinalizedChainInfo [\#288](https://github.com/babylonlabs-io/babylon/issues/288) + +**Merged pull requests:** + +- chore: add parameter sections for module docs [\#418](https://github.com/babylonlabs-io/babylon/pull/418) ([SebastianElvis](https://github.com/SebastianElvis)) +- doc: documentation for the epoching module [\#416](https://github.com/babylonlabs-io/babylon/pull/416) ([SebastianElvis](https://github.com/SebastianElvis)) +- fix: making zoneconcierge resilient against long BTC reorg \(again\) [\#413](https://github.com/babylonlabs-io/babylon/pull/413) ([SebastianElvis](https://github.com/SebastianElvis)) +- BTC Staking [\#409](https://github.com/babylonlabs-io/babylon/pull/409) ([vitsalis](https://github.com/vitsalis)) +- Fix typos [\#405](https://github.com/babylonlabs-io/babylon/pull/405) ([AtomicInnovation321](https://github.com/AtomicInnovation321)) +- Updated testnet link [\#404](https://github.com/babylonlabs-io/babylon/pull/404) ([kunallimaye](https://github.com/kunallimaye)) +- README: updating discord link [\#402](https://github.com/babylonlabs-io/babylon/pull/402) ([GakiBash](https://github.com/GakiBash)) +- README: Add medium link [\#400](https://github.com/babylonlabs-io/babylon/pull/400) ([EdwardFanfan](https://github.com/EdwardFanfan)) +- Bump comet bft [\#399](https://github.com/babylonlabs-io/babylon/pull/399) ([KonradStaniec](https://github.com/KonradStaniec)) +- hotfix: Barberry upgrade [\#398](https://github.com/babylonlabs-io/babylon/pull/398) ([vitsalis](https://github.com/vitsalis)) +- Bump wasmd to stable [\#396](https://github.com/babylonlabs-io/babylon/pull/396) ([KonradStaniec](https://github.com/KonradStaniec)) +- hotfix: fixing marshaling of MsgWrappedCreateValidator [\#394](https://github.com/babylonlabs-io/babylon/pull/394) ([SebastianElvis](https://github.com/SebastianElvis)) +- chore: adding a flag for retrieving proofs of a FinalizedChainInfo [\#391](https://github.com/babylonlabs-io/babylon/pull/391) ([SebastianElvis](https://github.com/SebastianElvis)) +- e2e: merge integration tests with e2e tests [\#390](https://github.com/babylonlabs-io/babylon/pull/390) ([SebastianElvis](https://github.com/SebastianElvis)) + +## [v0.7.2](https://github.com/babylonlabs-io/babylon/tree/v0.7.2) (2023-06-10) + +[Full Changelog](https://github.com/babylonlabs-io/babylon/compare/v0.7.1...v0.7.2) + +## [v0.7.1](https://github.com/babylonlabs-io/babylon/tree/v0.7.1) (2023-05-30) + +[Full Changelog](https://github.com/babylonlabs-io/babylon/compare/v0.7.0...v0.7.1) + +**Closed issues:** + +- zoneconcierge: parameterise timeout for IBC packets [\#207](https://github.com/babylonlabs-io/babylon/issues/207) + +**Merged pull requests:** + +- hotfix: fixing marshaling of `MsgWrappedCreateValidator` [\#393](https://github.com/babylonlabs-io/babylon/pull/393) ([SebastianElvis](https://github.com/SebastianElvis)) + +## [v0.7.0](https://github.com/babylonlabs-io/babylon/tree/v0.7.0) (2023-05-26) + +[Full Changelog](https://github.com/babylonlabs-io/babylon/compare/v0.6.0...v0.7.0) + +**Closed issues:** + +- Nil hooks [\#214](https://github.com/babylonlabs-io/babylon/issues/214) + +**Merged pull requests:** + +- Release v0.7.0 [\#388](https://github.com/babylonlabs-io/babylon/pull/388) ([vitsalis](https://github.com/vitsalis)) +- zoneconcierge: adding header timestamp to IndexedHeader [\#387](https://github.com/babylonlabs-io/babylon/pull/387) ([SebastianElvis](https://github.com/SebastianElvis)) +- zoneconcierge: parameterise timeout for IBC packets [\#386](https://github.com/babylonlabs-io/babylon/pull/386) ([SebastianElvis](https://github.com/SebastianElvis)) +- CI: Push images for dev branch commits [\#385](https://github.com/babylonlabs-io/babylon/pull/385) ([filippos47](https://github.com/filippos47)) +- dockerfile: opt out version when building [\#384](https://github.com/babylonlabs-io/babylon/pull/384) ([SebastianElvis](https://github.com/SebastianElvis)) +- Use fee module [\#383](https://github.com/babylonlabs-io/babylon/pull/383) ([KonradStaniec](https://github.com/KonradStaniec)) +- Bump vulnerable docker/distribution [\#382](https://github.com/babylonlabs-io/babylon/pull/382) ([vitsalis](https://github.com/vitsalis)) +- Bump wasmd to rc2 [\#381](https://github.com/babylonlabs-io/babylon/pull/381) ([KonradStaniec](https://github.com/KonradStaniec)) +- Add wasm e2e test [\#380](https://github.com/babylonlabs-io/babylon/pull/380) ([KonradStaniec](https://github.com/KonradStaniec)) +- phase2: IBC packet and logic [\#368](https://github.com/babylonlabs-io/babylon/pull/368) ([SebastianElvis](https://github.com/SebastianElvis)) + +## [v0.6.0](https://github.com/babylonlabs-io/babylon/tree/v0.6.0) (2023-05-10) + +[Full Changelog](https://github.com/babylonlabs-io/babylon/compare/v0.6.0rc0...v0.6.0) + +**Merged pull requests:** + +- Release v0.6.0 [\#379](https://github.com/babylonlabs-io/babylon/pull/379) ([vitsalis](https://github.com/vitsalis)) +- Fix non-determinism in integration test [\#377](https://github.com/babylonlabs-io/babylon/pull/377) ([KonradStaniec](https://github.com/KonradStaniec)) +- Fix consensus version in our custom modules [\#376](https://github.com/babylonlabs-io/babylon/pull/376) ([KonradStaniec](https://github.com/KonradStaniec)) +- Add fuzz test for epoch finalization/confirmation [\#375](https://github.com/babylonlabs-io/babylon/pull/375) ([KonradStaniec](https://github.com/KonradStaniec)) + +## [v0.6.0rc0](https://github.com/babylonlabs-io/babylon/tree/v0.6.0rc0) (2023-05-04) + +[Full Changelog](https://github.com/babylonlabs-io/babylon/compare/v0.6.0-rc0...v0.6.0rc0) + +## [v0.6.0-rc0](https://github.com/babylonlabs-io/babylon/tree/v0.6.0-rc0) (2023-05-04) + +[Full Changelog](https://github.com/babylonlabs-io/babylon/compare/devnet...v0.6.0-rc0) + +**Merged pull requests:** + +- use tagged branch in test contract [\#374](https://github.com/babylonlabs-io/babylon/pull/374) ([KonradStaniec](https://github.com/KonradStaniec)) +- chore: Reduce default number of tests from 100 to 10 [\#373](https://github.com/babylonlabs-io/babylon/pull/373) ([vitsalis](https://github.com/vitsalis)) +- feat: new rpc RawCheckpoints [\#372](https://github.com/babylonlabs-io/babylon/pull/372) ([gusin13](https://github.com/gusin13)) +- chore: circleci: Use image with go 1.20.3 installed [\#371](https://github.com/babylonlabs-io/babylon/pull/371) ([vitsalis](https://github.com/vitsalis)) +- Improve btccheckpointinfo rpc [\#370](https://github.com/babylonlabs-io/babylon/pull/370) ([KonradStaniec](https://github.com/KonradStaniec)) +- feat: Add support for multiple chain ids in EpochChainsInfo API [\#369](https://github.com/babylonlabs-io/babylon/pull/369) ([gusin13](https://github.com/gusin13)) +- Fix bug in submission btc info [\#367](https://github.com/babylonlabs-io/babylon/pull/367) ([KonradStaniec](https://github.com/KonradStaniec)) +- chore: Bump Cosmos SDK to v0.47.2 and minor bug fix [\#366](https://github.com/babylonlabs-io/babylon/pull/366) ([vitsalis](https://github.com/vitsalis)) +- feat: support multiple chain ids in FinalizedChainsInfo [\#365](https://github.com/babylonlabs-io/babylon/pull/365) ([gusin13](https://github.com/gusin13)) +- chore: Update runc and docker dependencies due to security alerts [\#364](https://github.com/babylonlabs-io/babylon/pull/364) ([vitsalis](https://github.com/vitsalis)) +- chore: Replace deprecated `rand.Seed` with dedicated datagen random generators [\#363](https://github.com/babylonlabs-io/babylon/pull/363) ([vitsalis](https://github.com/vitsalis)) +- feat: support multiple chain ids in zoneconcierge chains info api [\#362](https://github.com/babylonlabs-io/babylon/pull/362) ([gusin13](https://github.com/gusin13)) +- Add last block height to finalized epoch info [\#361](https://github.com/babylonlabs-io/babylon/pull/361) ([KonradStaniec](https://github.com/KonradStaniec)) +- Version bumps [\#358](https://github.com/babylonlabs-io/babylon/pull/358) ([KonradStaniec](https://github.com/KonradStaniec)) +- fix: Make testnet command produce addresses bound to the host IP [\#357](https://github.com/babylonlabs-io/babylon/pull/357) ([vitsalis](https://github.com/vitsalis)) +- Move checkpoint tag to params [\#356](https://github.com/babylonlabs-io/babylon/pull/356) ([KonradStaniec](https://github.com/KonradStaniec)) +- chore: Use more descriptive error message for using wrapped transactions [\#355](https://github.com/babylonlabs-io/babylon/pull/355) ([vitsalis](https://github.com/vitsalis)) +- chore: Enable building docker image with unpushed changes [\#354](https://github.com/babylonlabs-io/babylon/pull/354) ([vitsalis](https://github.com/vitsalis)) +- Handle btc related wasm queries [\#353](https://github.com/babylonlabs-io/babylon/pull/353) ([KonradStaniec](https://github.com/KonradStaniec)) +- fix: fix query height in `ProveEpochSealed` [\#352](https://github.com/babylonlabs-io/babylon/pull/352) ([SebastianElvis](https://github.com/SebastianElvis)) +- fix: fixing the bug in generating proof of sealed epoch [\#351](https://github.com/babylonlabs-io/babylon/pull/351) ([SebastianElvis](https://github.com/SebastianElvis)) +- testnet: Add flag for time between blocks [\#134](https://github.com/babylonlabs-io/babylon/pull/134) ([vitsalis](https://github.com/vitsalis)) + +## [devnet](https://github.com/babylonlabs-io/babylon/tree/devnet) (2023-04-17) + +[Full Changelog](https://github.com/babylonlabs-io/babylon/compare/test...devnet) + +**Breaking changes:** + +- fix gas cost of insert header [\#309](https://github.com/babylonlabs-io/babylon/pull/309) ([KonradStaniec](https://github.com/KonradStaniec)) + +**Closed issues:** + +- Remove `handler.go` from modules [\#336](https://github.com/babylonlabs-io/babylon/issues/336) + +**Merged pull requests:** + +- Add support for querying for latest finalized epoch [\#350](https://github.com/babylonlabs-io/babylon/pull/350) ([KonradStaniec](https://github.com/KonradStaniec)) +- Use block gas limit when defining genesis [\#349](https://github.com/babylonlabs-io/babylon/pull/349) ([KonradStaniec](https://github.com/KonradStaniec)) +- fix: Use the account specified in app.toml to sign BLS transactions [\#348](https://github.com/babylonlabs-io/babylon/pull/348) ([vitsalis](https://github.com/vitsalis)) +- Custom bindings for smart contracts [\#347](https://github.com/babylonlabs-io/babylon/pull/347) ([KonradStaniec](https://github.com/KonradStaniec)) +- fix: Make e2e tests work with new docker image [\#345](https://github.com/babylonlabs-io/babylon/pull/345) ([vitsalis](https://github.com/vitsalis)) +- Migrate epoching and btccheckpointing module to new way of handling params [\#344](https://github.com/babylonlabs-io/babylon/pull/344) ([KonradStaniec](https://github.com/KonradStaniec)) +- Feature/lint proto ci [\#343](https://github.com/babylonlabs-io/babylon/pull/343) ([KonradStaniec](https://github.com/KonradStaniec)) +- Re-enable e2e tests [\#342](https://github.com/babylonlabs-io/babylon/pull/342) ([KonradStaniec](https://github.com/KonradStaniec)) +- chore: Parallelize CircleCI lint build [\#341](https://github.com/babylonlabs-io/babylon/pull/341) ([vitsalis](https://github.com/vitsalis)) +- docker: Refactor to a lightweight unified image [\#340](https://github.com/babylonlabs-io/babylon/pull/340) ([danbryan](https://github.com/danbryan)) +- chore: set up OpenAPI [\#339](https://github.com/babylonlabs-io/babylon/pull/339) ([fadeev](https://github.com/fadeev)) +- refactor: remove `handler.go` files from modules [\#337](https://github.com/babylonlabs-io/babylon/pull/337) ([fadeev](https://github.com/fadeev)) +- Cleanup params in Babylon custom modules. [\#334](https://github.com/babylonlabs-io/babylon/pull/334) ([KonradStaniec](https://github.com/KonradStaniec)) +- zoneconcierge: moving extended client keeper to Babylon repo [\#333](https://github.com/babylonlabs-io/babylon/pull/333) ([SebastianElvis](https://github.com/SebastianElvis)) +- Use new version for our fork of ibc go [\#332](https://github.com/babylonlabs-io/babylon/pull/332) ([KonradStaniec](https://github.com/KonradStaniec)) +- proto: fix proto-linter comments for epoching/zoneconcierge [\#331](https://github.com/babylonlabs-io/babylon/pull/331) ([SebastianElvis](https://github.com/SebastianElvis)) +- Fix proto linter comments in btccheckpoint and monitor [\#330](https://github.com/babylonlabs-io/babylon/pull/330) ([KonradStaniec](https://github.com/KonradStaniec)) +- proto-lint: Add comments to btclightclient and checkpointing proto files [\#329](https://github.com/babylonlabs-io/babylon/pull/329) ([vitsalis](https://github.com/vitsalis)) +- CI: Build and push Docker image to ECR [\#328](https://github.com/babylonlabs-io/babylon/pull/328) ([filippos47](https://github.com/filippos47)) +- Bump cosmos-sdk to stable version [\#327](https://github.com/babylonlabs-io/babylon/pull/327) ([KonradStaniec](https://github.com/KonradStaniec)) +- Integrate wasmd [\#324](https://github.com/babylonlabs-io/babylon/pull/324) ([KonradStaniec](https://github.com/KonradStaniec)) +- Migrate to comet bft [\#323](https://github.com/babylonlabs-io/babylon/pull/323) ([KonradStaniec](https://github.com/KonradStaniec)) +- Update protobuf generation [\#322](https://github.com/babylonlabs-io/babylon/pull/322) ([KonradStaniec](https://github.com/KonradStaniec)) +- Use cosmos v47 [\#320](https://github.com/babylonlabs-io/babylon/pull/320) ([KonradStaniec](https://github.com/KonradStaniec)) +- chore: Add balance check before inserting MsgWrappedCreateValidator into the epoch message queue [\#318](https://github.com/babylonlabs-io/babylon/pull/318) ([gitferry](https://github.com/gitferry)) +- checkpointing: stateless checks on `MsgCreateValidator` [\#316](https://github.com/babylonlabs-io/babylon/pull/316) ([SebastianElvis](https://github.com/SebastianElvis)) +- chore: Add fuzz test of addBlsSig [\#313](https://github.com/babylonlabs-io/babylon/pull/313) ([gitferry](https://github.com/gitferry)) +- btccheckpoint: Add information about transactions to BTCCheckpointInfo [\#312](https://github.com/babylonlabs-io/babylon/pull/312) ([vitsalis](https://github.com/vitsalis)) +- chore: Keep a single encoding config in the application [\#308](https://github.com/babylonlabs-io/babylon/pull/308) ([gitferry](https://github.com/gitferry)) +- feat: Checkpointing/Add fee estimation in sending BLS-sig tx [\#307](https://github.com/babylonlabs-io/babylon/pull/307) ([gitferry](https://github.com/gitferry)) +- prepare-genesis cmd: Add flags related to inflation [\#306](https://github.com/babylonlabs-io/babylon/pull/306) ([vitsalis](https://github.com/vitsalis)) +- fix: remove `start_epoch` and `end_epoch` parameters in APIs [\#305](https://github.com/babylonlabs-io/babylon/pull/305) ([SebastianElvis](https://github.com/SebastianElvis)) +- Fix whitespace for Make 4.3 [\#303](https://github.com/babylonlabs-io/babylon/pull/303) ([freshe4qa](https://github.com/freshe4qa)) + +## [test](https://github.com/babylonlabs-io/babylon/tree/test) (2023-03-17) + +[Full Changelog](https://github.com/babylonlabs-io/babylon/compare/v0.5.0...test) + +**Implemented enhancements:** + +- Fees as a parameter for the BlsSig transaction [\#168](https://github.com/babylonlabs-io/babylon/issues/168) + +**Fixed bugs:** + +- flaky Test: `TestRawCheckpointWithMeta_Accumulate4` [\#124](https://github.com/babylonlabs-io/babylon/issues/124) + +**Closed issues:** + +- Use proto linter and formatter [\#321](https://github.com/babylonlabs-io/babylon/issues/321) +- Lack of balance check before inserting MsgWrappedCreateValidator into the message queue [\#317](https://github.com/babylonlabs-io/babylon/issues/317) +- Duplicate txs queued in the same epoch show inconsistent execution result [\#314](https://github.com/babylonlabs-io/babylon/issues/314) +- Redundant pagination parameters in API [\#304](https://github.com/babylonlabs-io/babylon/issues/304) +- Chain died on block 621 [\#302](https://github.com/babylonlabs-io/babylon/issues/302) +- Add test for adding a BLS-sig transaction [\#279](https://github.com/babylonlabs-io/babylon/issues/279) +- Add logs to show the submitter of each BLS-sig transaction [\#278](https://github.com/babylonlabs-io/babylon/issues/278) +- zoneconcierge: API for querying submitted/confirmed chain info [\#212](https://github.com/babylonlabs-io/babylon/issues/212) +- Validators should stop submitting BLS-sigs when they are syncing [\#182](https://github.com/babylonlabs-io/babylon/issues/182) +- Accept encoding config in `InitPrivSigner` function instead of creating it. [\#174](https://github.com/babylonlabs-io/babylon/issues/174) +- Improving Undelegating Requests and Lifecycle [\#159](https://github.com/babylonlabs-io/babylon/issues/159) + +## [v0.5.0](https://github.com/babylonlabs-io/babylon/tree/v0.5.0) (2023-02-03) + +[Full Changelog](https://github.com/babylonlabs-io/babylon/compare/v0.4.0...v0.5.0) + +**Breaking changes:** + +- Improve btc checkpoint data model [\#284](https://github.com/babylonlabs-io/babylon/pull/284) ([KonradStaniec](https://github.com/KonradStaniec)) + +**Fixed bugs:** + +- Fix vulnerability when processing bls sig transactions [\#287](https://github.com/babylonlabs-io/babylon/pull/287) ([KonradStaniec](https://github.com/KonradStaniec)) + +**Closed issues:** + +- Error results in RawCheckpointList [\#280](https://github.com/babylonlabs-io/babylon/issues/280) +- Creating a validator after the chain has been running for a while leads to the validator never becoming bonded. [\#275](https://github.com/babylonlabs-io/babylon/issues/275) +- Flaky zoneconcierge test [\#251](https://github.com/babylonlabs-io/babylon/issues/251) +- go 1.19 [\#227](https://github.com/babylonlabs-io/babylon/issues/227) + +**Merged pull requests:** + +- Release v0.5.0 [\#301](https://github.com/babylonlabs-io/babylon/pull/301) ([vitsalis](https://github.com/vitsalis)) +- zoneconcierge API: pagtinating chain IDs API [\#300](https://github.com/babylonlabs-io/babylon/pull/300) ([SebastianElvis](https://github.com/SebastianElvis)) +- Fix: Monitor/fix reported checkpoint BTC height query bugs [\#299](https://github.com/babylonlabs-io/babylon/pull/299) ([gitferry](https://github.com/gitferry)) +- Add Apache 2.0 licence [\#298](https://github.com/babylonlabs-io/babylon/pull/298) ([vitsalis](https://github.com/vitsalis)) +- Clean and split up README [\#297](https://github.com/babylonlabs-io/babylon/pull/297) ([vitsalis](https://github.com/vitsalis)) +- fix: add BLST\_PORTABLE flag before build instruction [\#295](https://github.com/babylonlabs-io/babylon/pull/295) ([vitsalis](https://github.com/vitsalis)) +- btccheckpoint API: enriching existing APIs with `BTCCheckpointInfo` [\#294](https://github.com/babylonlabs-io/babylon/pull/294) ([SebastianElvis](https://github.com/SebastianElvis)) +- chore: Remove checkpointing spec [\#293](https://github.com/babylonlabs-io/babylon/pull/293) ([gitferry](https://github.com/gitferry)) +- API: add parameters to range queries and improve outputs [\#292](https://github.com/babylonlabs-io/babylon/pull/292) ([SebastianElvis](https://github.com/SebastianElvis)) +- btccheckpoint API: range query for BTC checkpoints [\#291](https://github.com/babylonlabs-io/babylon/pull/291) ([SebastianElvis](https://github.com/SebastianElvis)) +- btccheckpoint API: add hash to `BtcCheckpointHeightAndHash` API [\#290](https://github.com/babylonlabs-io/babylon/pull/290) ([SebastianElvis](https://github.com/SebastianElvis)) +- epoching: range query for epochs [\#289](https://github.com/babylonlabs-io/babylon/pull/289) ([SebastianElvis](https://github.com/SebastianElvis)) +- feat: Monitor/Add new KV and query for checkpoint reported btc height [\#286](https://github.com/babylonlabs-io/babylon/pull/286) ([gitferry](https://github.com/gitferry)) +- zoneconcierge: proper initialisation for chain info [\#285](https://github.com/babylonlabs-io/babylon/pull/285) ([SebastianElvis](https://github.com/SebastianElvis)) +- fix: API/Fix checkpoint list total error [\#283](https://github.com/babylonlabs-io/babylon/pull/283) ([gitferry](https://github.com/gitferry)) +- fix: Fix pagination error of RawCheckpointList [\#282](https://github.com/babylonlabs-io/babylon/pull/282) ([gitferry](https://github.com/gitferry)) +- Bump btcd versions to fix 2 consensus issues [\#281](https://github.com/babylonlabs-io/babylon/pull/281) ([KonradStaniec](https://github.com/KonradStaniec)) +- fix: add HTTP URL for LastCheckpointWithStatusRequest [\#277](https://github.com/babylonlabs-io/babylon/pull/277) ([gitferry](https://github.com/gitferry)) +- epoching/checkpointing: fuzz test for validators with zero voting power [\#276](https://github.com/babylonlabs-io/babylon/pull/276) ([SebastianElvis](https://github.com/SebastianElvis)) +- Add simple monitor module [\#274](https://github.com/babylonlabs-io/babylon/pull/274) ([KonradStaniec](https://github.com/KonradStaniec)) +- fix: checkpointing: Do not make the `home` flag a required one and unmarshall PubKey \(\#271\) [\#271](https://github.com/babylonlabs-io/babylon/pull/271) ([vitsalis](https://github.com/vitsalis)) +- Fix: Increase gas in e2e test [\#270](https://github.com/babylonlabs-io/babylon/pull/270) ([KonradStaniec](https://github.com/KonradStaniec)) +- Add integration test for zoneconcierge checkpointing [\#269](https://github.com/babylonlabs-io/babylon/pull/269) ([KonradStaniec](https://github.com/KonradStaniec)) +- chore: refactor `FinalizedChainInfo` API [\#268](https://github.com/babylonlabs-io/babylon/pull/268) ([SebastianElvis](https://github.com/SebastianElvis)) +- checkpointing API: add checkpoint lifecycle in `RawCheckpointWithMeta` [\#267](https://github.com/babylonlabs-io/babylon/pull/267) ([SebastianElvis](https://github.com/SebastianElvis)) +- zoneconcierge API: find header and fork headers at a given height [\#266](https://github.com/babylonlabs-io/babylon/pull/266) ([SebastianElvis](https://github.com/SebastianElvis)) +- zoneconcierge API: find the BTC-finalised chain info before specific CZ height [\#264](https://github.com/babylonlabs-io/babylon/pull/264) ([SebastianElvis](https://github.com/SebastianElvis)) +- zoneconcierge API: adding total number of timestamped headers to chainInfo [\#263](https://github.com/babylonlabs-io/babylon/pull/263) ([SebastianElvis](https://github.com/SebastianElvis)) +- zoneconcierge: API for querying headers in a given epoch [\#261](https://github.com/babylonlabs-io/babylon/pull/261) ([SebastianElvis](https://github.com/SebastianElvis)) +- zoneconcierge: API for querying the chain info of a given epoch [\#260](https://github.com/babylonlabs-io/babylon/pull/260) ([SebastianElvis](https://github.com/SebastianElvis)) +- add e2e test to CI [\#259](https://github.com/babylonlabs-io/babylon/pull/259) ([KonradStaniec](https://github.com/KonradStaniec)) +- Bump golang to 1.19 [\#257](https://github.com/babylonlabs-io/babylon/pull/257) ([KonradStaniec](https://github.com/KonradStaniec)) +- zoneconcierge: fix flaky test `FuzzProofEpochSealed_BLSSig` [\#256](https://github.com/babylonlabs-io/babylon/pull/256) ([SebastianElvis](https://github.com/SebastianElvis)) +- zoneconcierge: ignore out-of-order headers in ZoneConcierge [\#255](https://github.com/babylonlabs-io/babylon/pull/255) ([SebastianElvis](https://github.com/SebastianElvis)) +- zoneconcierge: API for listing the last checkpointed headers [\#254](https://github.com/babylonlabs-io/babylon/pull/254) ([SebastianElvis](https://github.com/SebastianElvis)) +- feat: Add new query for the last checkpoint with a given status [\#253](https://github.com/babylonlabs-io/babylon/pull/253) ([gitferry](https://github.com/gitferry)) + +## [v0.4.0](https://github.com/babylonlabs-io/babylon/tree/v0.4.0) (2022-12-20) + +[Full Changelog](https://github.com/babylonlabs-io/babylon/compare/v0.3.0...v0.4.0) + +**Closed issues:** + +- epoching: excessive `absent validator` logs during simulation [\#75](https://github.com/babylonlabs-io/babylon/issues/75) + +**Merged pull requests:** + +- Release v0.4.0 [\#252](https://github.com/babylonlabs-io/babylon/pull/252) ([vitsalis](https://github.com/vitsalis)) +- zoneconcierge: typos and rename filenames [\#250](https://github.com/babylonlabs-io/babylon/pull/250) ([SebastianElvis](https://github.com/SebastianElvis)) +- chore: Introduce more control over home directory name for localnet [\#249](https://github.com/babylonlabs-io/babylon/pull/249) ([vitsalis](https://github.com/vitsalis)) +- zoneconcierge/epoching: proof that a header is in an epoch [\#248](https://github.com/babylonlabs-io/babylon/pull/248) ([SebastianElvis](https://github.com/SebastianElvis)) +- Add e2e testing framework based on Osmosis [\#247](https://github.com/babylonlabs-io/babylon/pull/247) ([KonradStaniec](https://github.com/KonradStaniec)) +- zoneconcierge: verifier for `ProofEpochSubmitted` [\#246](https://github.com/babylonlabs-io/babylon/pull/246) ([SebastianElvis](https://github.com/SebastianElvis)) +- Add versioning based on Git names for the executable [\#245](https://github.com/babylonlabs-io/babylon/pull/245) ([vitsalis](https://github.com/vitsalis)) +- Fix: Resolve linting errors [\#244](https://github.com/babylonlabs-io/babylon/pull/244) ([vitsalis](https://github.com/vitsalis)) +- zoneconcierge: query inclusion proofs and add them to `ProofEpochSealed` [\#243](https://github.com/babylonlabs-io/babylon/pull/243) ([SebastianElvis](https://github.com/SebastianElvis)) +- feat: Add kv for validator BLS key set [\#242](https://github.com/babylonlabs-io/babylon/pull/242) ([gitferry](https://github.com/gitferry)) +- zoneconcierge: verifying BLS multisig in `ProofEpochSealed` [\#241](https://github.com/babylonlabs-io/babylon/pull/241) ([SebastianElvis](https://github.com/SebastianElvis)) +- chore: Unify bitmap length [\#240](https://github.com/babylonlabs-io/babylon/pull/240) ([gitferry](https://github.com/gitferry)) +- zoneconcierge: enriching `SubmissionData` to store BTCSpvProof [\#239](https://github.com/babylonlabs-io/babylon/pull/239) ([SebastianElvis](https://github.com/SebastianElvis)) +- chore: Move functionalities from the verifier [\#238](https://github.com/babylonlabs-io/babylon/pull/238) ([gitferry](https://github.com/gitferry)) +- zoneconcierge: proof of a sealed epoch and make proof generation optional [\#237](https://github.com/babylonlabs-io/babylon/pull/237) ([SebastianElvis](https://github.com/SebastianElvis)) +- epoching: API for querying the validator set of a given epoch [\#236](https://github.com/babylonlabs-io/babylon/pull/236) ([SebastianElvis](https://github.com/SebastianElvis)) +- feat: Add voting power to BLS key set API [\#235](https://github.com/babylonlabs-io/babylon/pull/235) ([gitferry](https://github.com/gitferry)) +- zoneconcierge: proof that a tx is in a block [\#234](https://github.com/babylonlabs-io/babylon/pull/234) ([SebastianElvis](https://github.com/SebastianElvis)) +- zoneconcierge: repurpose heartbeat mechanism to a generic function [\#233](https://github.com/babylonlabs-io/babylon/pull/233) ([SebastianElvis](https://github.com/SebastianElvis)) +- feat: Add bls pubkey set api [\#232](https://github.com/babylonlabs-io/babylon/pull/232) ([gitferry](https://github.com/gitferry)) +- golangci-lint [\#222](https://github.com/babylonlabs-io/babylon/pull/222) ([faddat](https://github.com/faddat)) + +## [v0.3.0](https://github.com/babylonlabs-io/babylon/tree/v0.3.0) (2022-11-30) + +[Full Changelog](https://github.com/babylonlabs-io/babylon/compare/v0.2.0...v0.3.0) + +**Breaking changes:** + +- Submission pruning improvements [\#204](https://github.com/babylonlabs-io/babylon/pull/204) ([KonradStaniec](https://github.com/KonradStaniec)) + +**Closed issues:** + +- zoneconcierge: Chain info indexer snapshots the latest chain info for each epoch even without any relayer [\#220](https://github.com/babylonlabs-io/babylon/issues/220) + +**Merged pull requests:** + +- Release v0.3.0 [\#231](https://github.com/babylonlabs-io/babylon/pull/231) ([vitsalis](https://github.com/vitsalis)) +- doc: update swagger yml file [\#230](https://github.com/babylonlabs-io/babylon/pull/230) ([SebastianElvis](https://github.com/SebastianElvis)) +- fix: Update verification rule for btc raw checkpoints [\#229](https://github.com/babylonlabs-io/babylon/pull/229) ([gitferry](https://github.com/gitferry)) +- zoneconcierge: API route [\#228](https://github.com/babylonlabs-io/babylon/pull/228) ([SebastianElvis](https://github.com/SebastianElvis)) +- Bump protogen cosmos [\#226](https://github.com/babylonlabs-io/babylon/pull/226) ([vitsalis](https://github.com/vitsalis)) +- chore: Remove starport references [\#225](https://github.com/babylonlabs-io/babylon/pull/225) ([faddat](https://github.com/faddat)) +- bump ledger and cosmos-proto [\#223](https://github.com/babylonlabs-io/babylon/pull/223) ([faddat](https://github.com/faddat)) +- zoneconcierge: find the earliest epoch that finalised a chain info for the API [\#221](https://github.com/babylonlabs-io/babylon/pull/221) ([SebastianElvis](https://github.com/SebastianElvis)) +- bump deps [\#218](https://github.com/babylonlabs-io/babylon/pull/218) ([faddat](https://github.com/faddat)) +- fix: fixed marshaling issue when enqueueing CreateValidator message and added tests [\#215](https://github.com/babylonlabs-io/babylon/pull/215) ([gitferry](https://github.com/gitferry)) + +## [v0.2.0](https://github.com/babylonlabs-io/babylon/tree/v0.2.0) (2022-11-23) + +[Full Changelog](https://github.com/babylonlabs-io/babylon/compare/v0.1.0...v0.2.0) + +**Fixed bugs:** + +- Concurrent issue when sending BLS-sig tx in a gorouting [\#197](https://github.com/babylonlabs-io/babylon/issues/197) + +**Closed issues:** + +- Make FromName an attribute in app.toml [\#188](https://github.com/babylonlabs-io/babylon/issues/188) +- Add correspondence check for genesis BLS keys and genesis txs [\#180](https://github.com/babylonlabs-io/babylon/issues/180) + +**Merged pull requests:** + +- Release v0.2.0 [\#217](https://github.com/babylonlabs-io/babylon/pull/217) ([vitsalis](https://github.com/vitsalis)) +- hotfix: fixing the hook issue in `app.go` [\#213](https://github.com/babylonlabs-io/babylon/pull/213) ([SebastianElvis](https://github.com/SebastianElvis)) +- zoneconcierge: debugging API `ChainInfo` [\#211](https://github.com/babylonlabs-io/babylon/pull/211) ([SebastianElvis](https://github.com/SebastianElvis)) +- zoneconcierge: add checkpoint info and epoch info to `FinalizedChainInfo` API [\#210](https://github.com/babylonlabs-io/babylon/pull/210) ([SebastianElvis](https://github.com/SebastianElvis)) +- zoneconcierge: restrict the used port for IBC [\#209](https://github.com/babylonlabs-io/babylon/pull/209) ([SebastianElvis](https://github.com/SebastianElvis)) +- fix: Use better short description for the babylond executable [\#208](https://github.com/babylonlabs-io/babylon/pull/208) ([vitsalis](https://github.com/vitsalis)) +- IBC: bug fixes for creating IBC channels [\#206](https://github.com/babylonlabs-io/babylon/pull/206) ([SebastianElvis](https://github.com/SebastianElvis)) +- zoneconcierge: API for listing all chain IDs [\#205](https://github.com/babylonlabs-io/babylon/pull/205) ([SebastianElvis](https://github.com/SebastianElvis)) +- zoneconcierge: fuzz tests for various indexers [\#203](https://github.com/babylonlabs-io/babylon/pull/203) ([SebastianElvis](https://github.com/SebastianElvis)) +- fix: Resolved concurrency issue when sending BLS-sig txs [\#202](https://github.com/babylonlabs-io/babylon/pull/202) ([gitferry](https://github.com/gitferry)) +- zoneconcierge: track latest BTC-finalised header and add the query [\#201](https://github.com/babylonlabs-io/babylon/pull/201) ([SebastianElvis](https://github.com/SebastianElvis)) +- zoneconcierge: subscribe to checkpointing/epoching's hooks, and add a new hooks [\#200](https://github.com/babylonlabs-io/babylon/pull/200) ([SebastianElvis](https://github.com/SebastianElvis)) +- chore: Add signer key name into app custom config [\#199](https://github.com/babylonlabs-io/babylon/pull/199) ([gitferry](https://github.com/gitferry)) +- feat: Introduce swagger docs for RPC queries [\#198](https://github.com/babylonlabs-io/babylon/pull/198) ([vitsalis](https://github.com/vitsalis)) +- feat: Add genesis time on genesis parameters [\#196](https://github.com/babylonlabs-io/babylon/pull/196) ([vitsalis](https://github.com/vitsalis)) +- zoneconcierge: heartbeat IBC packet to keep relayer awake [\#195](https://github.com/babylonlabs-io/babylon/pull/195) ([SebastianElvis](https://github.com/SebastianElvis)) +- zoneconcierge: test infra for IBC and vanilla tests [\#193](https://github.com/babylonlabs-io/babylon/pull/193) ([SebastianElvis](https://github.com/SebastianElvis)) +- Add changelog [\#192](https://github.com/babylonlabs-io/babylon/pull/192) ([KonradStaniec](https://github.com/KonradStaniec)) +- datagen: add datagen functions for testing reporter [\#190](https://github.com/babylonlabs-io/babylon/pull/190) ([SebastianElvis](https://github.com/SebastianElvis)) +- zoneconcierge: hook onto the light client and index headers/forks [\#189](https://github.com/babylonlabs-io/babylon/pull/189) ([SebastianElvis](https://github.com/SebastianElvis)) +- zoneconcierge: replace IBC-Go with Babylon's fork, and implement DB schemas [\#184](https://github.com/babylonlabs-io/babylon/pull/184) ([SebastianElvis](https://github.com/SebastianElvis)) + +## [v0.1.0](https://github.com/babylonlabs-io/babylon/tree/v0.1.0) (2022-11-05) + +[Full Changelog](https://github.com/babylonlabs-io/babylon/compare/b1645c9eea6511069c0b2ad0328d794018450eac...v0.1.0) + +**Implemented enhancements:** + +- Checkpointing: remove hardcoded FlagFee [\#160](https://github.com/babylonlabs-io/babylon/issues/160) +- Proper coin denomination for testnet [\#139](https://github.com/babylonlabs-io/babylon/issues/139) +- chore: bump Cosmos SDK dependency to `v0.46.0` [\#93](https://github.com/babylonlabs-io/babylon/issues/93) +- btclightclient: Store BTCHeaderInfo objects instead of BTCHeaderBytes objects [\#57](https://github.com/babylonlabs-io/babylon/issues/57) + +**Fixed bugs:** + +- bug: Transaction submission panics due to unavailability of BTC config [\#117](https://github.com/babylonlabs-io/babylon/issues/117) +- epoching: simulation panicked with error message `panic: no delegation distribution info` [\#74](https://github.com/babylonlabs-io/babylon/issues/74) +- Epoching AnteHandler rejects genesis staking transactions [\#36](https://github.com/babylonlabs-io/babylon/issues/36) +- Fix handling duplicated submissions [\#163](https://github.com/babylonlabs-io/babylon/pull/163) ([KonradStaniec](https://github.com/KonradStaniec)) + +**Closed issues:** + +- Improve sending of bls transaction by checkpointing module. [\#155](https://github.com/babylonlabs-io/babylon/issues/155) +- Checkpointing: random BLS-sig transactions are not executed successfully [\#141](https://github.com/babylonlabs-io/babylon/issues/141) +- Fix integration test and blssigner denominations [\#137](https://github.com/babylonlabs-io/babylon/issues/137) +- Errors prompted by the static analyser in `x/btclightclient` [\#9](https://github.com/babylonlabs-io/babylon/issues/9) + +**Merged pull requests:** + +- Release v0.1.0 [\#191](https://github.com/babylonlabs-io/babylon/pull/191) ([KonradStaniec](https://github.com/KonradStaniec)) +- feat: add validate-genesis cmd [\#187](https://github.com/babylonlabs-io/babylon/pull/187) ([gitferry](https://github.com/gitferry)) +- chore: add correspondence check against gentx when adding genesis BLS keys [\#186](https://github.com/babylonlabs-io/babylon/pull/186) ([gitferry](https://github.com/gitferry)) +- chore: regtest support [\#185](https://github.com/babylonlabs-io/babylon/pull/185) ([SebastianElvis](https://github.com/SebastianElvis)) +- Implement ADR-01 [\#183](https://github.com/babylonlabs-io/babylon/pull/183) ([KonradStaniec](https://github.com/KonradStaniec)) +- chore: Upgrade proto generation Docker image and script [\#181](https://github.com/babylonlabs-io/babylon/pull/181) ([vitsalis](https://github.com/vitsalis)) +- Fix accepting submission [\#179](https://github.com/babylonlabs-io/babylon/pull/179) ([KonradStaniec](https://github.com/KonradStaniec)) +- feat: add add-genesis-bls cmd [\#178](https://github.com/babylonlabs-io/babylon/pull/178) ([gitferry](https://github.com/gitferry)) +- fix: CI failed after merging \#175 [\#177](https://github.com/babylonlabs-io/babylon/pull/177) ([gitferry](https://github.com/gitferry)) +- ibc: vanilla IBC module [\#176](https://github.com/babylonlabs-io/babylon/pull/176) ([SebastianElvis](https://github.com/SebastianElvis)) +- feat: add create-genesis-bls cmd [\#175](https://github.com/babylonlabs-io/babylon/pull/175) ([gitferry](https://github.com/gitferry)) +- Bump cosmos sdk [\#173](https://github.com/babylonlabs-io/babylon/pull/173) ([KonradStaniec](https://github.com/KonradStaniec)) +- feat: Add prepare-genesis command [\#172](https://github.com/babylonlabs-io/babylon/pull/172) ([vitsalis](https://github.com/vitsalis)) +- Refactor submission bitcoin status [\#170](https://github.com/babylonlabs-io/babylon/pull/170) ([KonradStaniec](https://github.com/KonradStaniec)) +- Validate btc objects in ante-handler [\#169](https://github.com/babylonlabs-io/babylon/pull/169) ([KonradStaniec](https://github.com/KonradStaniec)) +- feat: Use \(u\)bbn bond denominations [\#167](https://github.com/babylonlabs-io/babylon/pull/167) ([vitsalis](https://github.com/vitsalis)) +- feat: checkpointing/improve the sending of BLS-sig tx [\#166](https://github.com/babylonlabs-io/babylon/pull/166) ([gitferry](https://github.com/gitferry)) +- feat: checkpointing/implement WrappedCreateValidator cli [\#165](https://github.com/babylonlabs-io/babylon/pull/165) ([gitferry](https://github.com/gitferry)) +- Move retry module from Vigilante to BBN [\#164](https://github.com/babylonlabs-io/babylon/pull/164) ([gusin13](https://github.com/gusin13)) +- feat: checkpointing/add create-bls-key cli [\#162](https://github.com/babylonlabs-io/babylon/pull/162) ([gitferry](https://github.com/gitferry)) +- chore: checkpointing/refactor validate basic [\#161](https://github.com/babylonlabs-io/babylon/pull/161) ([gitferry](https://github.com/gitferry)) +- Query to get submissions for given epoch [\#158](https://github.com/babylonlabs-io/babylon/pull/158) ([KonradStaniec](https://github.com/KonradStaniec)) +- Functionality for building custom mainnet tags [\#157](https://github.com/babylonlabs-io/babylon/pull/157) ([vitsalis](https://github.com/vitsalis)) +- Improve integration tests [\#156](https://github.com/babylonlabs-io/babylon/pull/156) ([KonradStaniec](https://github.com/KonradStaniec)) +- epoching: fix error of `unexpected validator in unbonding queue` [\#154](https://github.com/babylonlabs-io/babylon/pull/154) ([SebastianElvis](https://github.com/SebastianElvis)) +- Fix ancestry error [\#153](https://github.com/babylonlabs-io/babylon/pull/153) ([KonradStaniec](https://github.com/KonradStaniec)) +- chore: fix error msg typo of btccheckpoint [\#151](https://github.com/babylonlabs-io/babylon/pull/151) ([SebastianElvis](https://github.com/SebastianElvis)) +- epoching/checkpointing: checkpoint-assisted unbonding [\#150](https://github.com/babylonlabs-io/babylon/pull/150) ([SebastianElvis](https://github.com/SebastianElvis)) +- fix: Allow minimum work headers for a testnet/simnet [\#148](https://github.com/babylonlabs-io/babylon/pull/148) ([vitsalis](https://github.com/vitsalis)) +- Add test for checkpoint submissions and state change [\#147](https://github.com/babylonlabs-io/babylon/pull/147) ([KonradStaniec](https://github.com/KonradStaniec)) +- fix: fixed decoder for checkpoint [\#146](https://github.com/babylonlabs-io/babylon/pull/146) ([gitferry](https://github.com/gitferry)) +- epoching: add delegator address to events [\#145](https://github.com/babylonlabs-io/babylon/pull/145) ([SebastianElvis](https://github.com/SebastianElvis)) +- chore: checkpointing/add logs for checkpoint status change [\#144](https://github.com/babylonlabs-io/babylon/pull/144) ([gitferry](https://github.com/gitferry)) +- epoching: delegation lifecycle [\#143](https://github.com/babylonlabs-io/babylon/pull/143) ([SebastianElvis](https://github.com/SebastianElvis)) +- Relax tx formatter rules [\#142](https://github.com/babylonlabs-io/babylon/pull/142) ([KonradStaniec](https://github.com/KonradStaniec)) +- epoching: bugfix of `LatestEpochMsgs` API [\#140](https://github.com/babylonlabs-io/babylon/pull/140) ([SebastianElvis](https://github.com/SebastianElvis)) +- epoching: CLI for delegating/undelegating/redelegating requests [\#138](https://github.com/babylonlabs-io/babylon/pull/138) ([SebastianElvis](https://github.com/SebastianElvis)) +- Revert: testnet: denom of gas price \#133 [\#136](https://github.com/babylonlabs-io/babylon/pull/136) ([vitsalis](https://github.com/vitsalis)) +- bitcoinsim: Remove it from the repository [\#135](https://github.com/babylonlabs-io/babylon/pull/135) ([vitsalis](https://github.com/vitsalis)) +- testnet: denom of gas price [\#133](https://github.com/babylonlabs-io/babylon/pull/133) ([SebastianElvis](https://github.com/SebastianElvis)) +- btclightclient: create temporary method for Contains request with bytes parameter [\#132](https://github.com/babylonlabs-io/babylon/pull/132) ([SebastianElvis](https://github.com/SebastianElvis)) +- btclightclient: Add BaseHeader query [\#130](https://github.com/babylonlabs-io/babylon/pull/130) ([vitsalis](https://github.com/vitsalis)) +- Remove full stack deployment and irrelevant files [\#129](https://github.com/babylonlabs-io/babylon/pull/129) ([vitsalis](https://github.com/vitsalis)) +- testnet: Add CLI args for specifying btccheckpoint and staking genesis params [\#128](https://github.com/babylonlabs-io/babylon/pull/128) ([vitsalis](https://github.com/vitsalis)) +- Add extending btc light client chain in tests [\#127](https://github.com/babylonlabs-io/babylon/pull/127) ([KonradStaniec](https://github.com/KonradStaniec)) +- chore: checkpointing/refactor bls-signer [\#126](https://github.com/babylonlabs-io/babylon/pull/126) ([gitferry](https://github.com/gitferry)) +- fix: Re-introduce localnet start to enable integration tests [\#125](https://github.com/babylonlabs-io/babylon/pull/125) ([vitsalis](https://github.com/vitsalis)) +- docker: Include vigilantes and explorer in the localnet deployment [\#123](https://github.com/babylonlabs-io/babylon/pull/123) ([vitsalis](https://github.com/vitsalis)) +- fix: checkpointing/query epoch status count bug [\#122](https://github.com/babylonlabs-io/babylon/pull/122) ([gitferry](https://github.com/gitferry)) +- Fixes initialisation bug [\#121](https://github.com/babylonlabs-io/babylon/pull/121) ([KonradStaniec](https://github.com/KonradStaniec)) +- feat: checkpointing/integrate bls-sig tx into the message flow [\#120](https://github.com/babylonlabs-io/babylon/pull/120) ([gitferry](https://github.com/gitferry)) +- epoching API: add epoch msg range queries and add timestamp to validator lifecycle [\#119](https://github.com/babylonlabs-io/babylon/pull/119) ([SebastianElvis](https://github.com/SebastianElvis)) +- fix: bls-sig accumulating bug and added tests [\#118](https://github.com/babylonlabs-io/babylon/pull/118) ([gitferry](https://github.com/gitferry)) +- epoching API: add timestamp to queued messages [\#116](https://github.com/babylonlabs-io/babylon/pull/116) ([SebastianElvis](https://github.com/SebastianElvis)) +- Parameterize genesis and config through testnet command flags [\#115](https://github.com/babylonlabs-io/babylon/pull/115) ([vitsalis](https://github.com/vitsalis)) +- Add custom query [\#114](https://github.com/babylonlabs-io/babylon/pull/114) ([KonradStaniec](https://github.com/KonradStaniec)) +- btccheckpoint: make kDeep/wDeep as system parameters [\#113](https://github.com/babylonlabs-io/babylon/pull/113) ([SebastianElvis](https://github.com/SebastianElvis)) +- feat: checkpointing/add typed events [\#112](https://github.com/babylonlabs-io/babylon/pull/112) ([gitferry](https://github.com/gitferry)) +- feat: checkpointing/ add queries about epoch status [\#111](https://github.com/babylonlabs-io/babylon/pull/111) ([gitferry](https://github.com/gitferry)) +- chore: BLS signer refactor [\#110](https://github.com/babylonlabs-io/babylon/pull/110) ([gitferry](https://github.com/gitferry)) +- epoching API: validator lifecycle [\#109](https://github.com/babylonlabs-io/babylon/pull/109) ([SebastianElvis](https://github.com/SebastianElvis)) +- epoching: API: epoch\_msgs/{epoch\_num} -\> all events during this epoch [\#108](https://github.com/babylonlabs-io/babylon/pull/108) ([SebastianElvis](https://github.com/SebastianElvis)) +- btcutils: refactor for vigilante [\#107](https://github.com/babylonlabs-io/babylon/pull/107) ([SebastianElvis](https://github.com/SebastianElvis)) +- chore: Replace all instances of bbl with bbn [\#106](https://github.com/babylonlabs-io/babylon/pull/106) ([vitsalis](https://github.com/vitsalis)) +- Add babylon app config [\#105](https://github.com/babylonlabs-io/babylon/pull/105) ([KonradStaniec](https://github.com/KonradStaniec)) +- feat: checkpointing/implement BLS signer [\#104](https://github.com/babylonlabs-io/babylon/pull/104) ([gitferry](https://github.com/gitferry)) +- Add parsing correct format in btccheckpoint [\#102](https://github.com/babylonlabs-io/babylon/pull/102) ([KonradStaniec](https://github.com/KonradStaniec)) +- feat: add genesis state for checkpointing [\#101](https://github.com/babylonlabs-io/babylon/pull/101) ([gitferry](https://github.com/gitferry)) +- Add fuzz tests to formatter [\#100](https://github.com/babylonlabs-io/babylon/pull/100) ([KonradStaniec](https://github.com/KonradStaniec)) +- Fix: checkpointing/epoch growth bug [\#99](https://github.com/babylonlabs-io/babylon/pull/99) ([gitferry](https://github.com/gitferry)) +- chore: replace bbl with bbn and gitignore [\#98](https://github.com/babylonlabs-io/babylon/pull/98) ([SebastianElvis](https://github.com/SebastianElvis)) +- FIX: checkpointing/changed PoP by signing BLS public key [\#97](https://github.com/babylonlabs-io/babylon/pull/97) ([gitferry](https://github.com/gitferry)) +- Add initial implementation of tx formatter [\#96](https://github.com/babylonlabs-io/babylon/pull/96) ([KonradStaniec](https://github.com/KonradStaniec)) +- BM-102: Single BTC node in docker producing blocks [\#95](https://github.com/babylonlabs-io/babylon/pull/95) ([aakoshh](https://github.com/aakoshh)) +- Add initial test checking progress [\#94](https://github.com/babylonlabs-io/babylon/pull/94) ([KonradStaniec](https://github.com/KonradStaniec)) +- Add tests to ci [\#90](https://github.com/babylonlabs-io/babylon/pull/90) ([KonradStaniec](https://github.com/KonradStaniec)) +- FIX: Add checkpoint query with status [\#89](https://github.com/babylonlabs-io/babylon/pull/89) ([gitferry](https://github.com/gitferry)) +- enable gRPC gateway routes for rest queries [\#88](https://github.com/babylonlabs-io/babylon/pull/88) ([toliujiayi](https://github.com/toliujiayi)) +- Wire app without mocks [\#87](https://github.com/babylonlabs-io/babylon/pull/87) ([KonradStaniec](https://github.com/KonradStaniec)) +- feat: implement bls key generation [\#86](https://github.com/babylonlabs-io/babylon/pull/86) ([gitferry](https://github.com/gitferry)) +- Add integration tests [\#85](https://github.com/babylonlabs-io/babylon/pull/85) ([KonradStaniec](https://github.com/KonradStaniec)) +- feat: checkpointing/implement checkpoint verification and keeper tests [\#84](https://github.com/babylonlabs-io/babylon/pull/84) ([gitferry](https://github.com/gitferry)) +- Add btccheckpoit unit tests [\#83](https://github.com/babylonlabs-io/babylon/pull/83) ([KonradStaniec](https://github.com/KonradStaniec)) +- feat: btclightclient: Add BTCHeaderInserted event [\#82](https://github.com/babylonlabs-io/babylon/pull/82) ([vitsalis](https://github.com/vitsalis)) +- fix: Remove WASM config from application configuration [\#81](https://github.com/babylonlabs-io/babylon/pull/81) ([vitsalis](https://github.com/vitsalis)) +- epoching: smaller epoch interval in simulation [\#80](https://github.com/babylonlabs-io/babylon/pull/80) ([SebastianElvis](https://github.com/SebastianElvis)) +- FIX: Use a caching multistore in delayed staking message handler [\#79](https://github.com/babylonlabs-io/babylon/pull/79) ([aakoshh](https://github.com/aakoshh)) +- feat: checkpointing/implement cli [\#78](https://github.com/babylonlabs-io/babylon/pull/78) ([gitferry](https://github.com/gitferry)) +- fix: Add installation instructions and executable reference [\#77](https://github.com/babylonlabs-io/babylon/pull/77) ([vitsalis](https://github.com/vitsalis)) +- chore: issue templates [\#76](https://github.com/babylonlabs-io/babylon/pull/76) ([SebastianElvis](https://github.com/SebastianElvis)) +- feat: Register msg server for all modules & instructions for tx submission [\#73](https://github.com/babylonlabs-io/babylon/pull/73) ([vitsalis](https://github.com/vitsalis)) +- feat: btclightclient: Refactor keepers based on needs of btcheckpoint module [\#72](https://github.com/babylonlabs-io/babylon/pull/72) ([vitsalis](https://github.com/vitsalis)) +- simulation: vanilla simulation tests [\#71](https://github.com/babylonlabs-io/babylon/pull/71) ([SebastianElvis](https://github.com/SebastianElvis)) +- Implement core btc handling logic [\#70](https://github.com/babylonlabs-io/babylon/pull/70) ([KonradStaniec](https://github.com/KonradStaniec)) +- feat: btclightclient: gRPC query fuzz tests [\#69](https://github.com/babylonlabs-io/babylon/pull/69) ([vitsalis](https://github.com/vitsalis)) +- epoching: simulation infra for integration testing [\#68](https://github.com/babylonlabs-io/babylon/pull/68) ([SebastianElvis](https://github.com/SebastianElvis)) +- feat: btclightclient: Add keeper fuzz tests [\#67](https://github.com/babylonlabs-io/babylon/pull/67) ([vitsalis](https://github.com/vitsalis)) +- epoching: fuzz tests on epoched undelegations and redelegations [\#66](https://github.com/babylonlabs-io/babylon/pull/66) ([SebastianElvis](https://github.com/SebastianElvis)) +- epoching: refactor test infra, mock messages and sample fuzz tests [\#65](https://github.com/babylonlabs-io/babylon/pull/65) ([SebastianElvis](https://github.com/SebastianElvis)) +- epoching: fuzz tests for slashed validator set [\#64](https://github.com/babylonlabs-io/babylon/pull/64) ([SebastianElvis](https://github.com/SebastianElvis)) +- epoching: replace deprecated `EmitEvent` APIs with `EmitTypedEvent` ones [\#63](https://github.com/babylonlabs-io/babylon/pull/63) ([SebastianElvis](https://github.com/SebastianElvis)) +- feat: btclightclient HeadersState keeper fuzz tests [\#61](https://github.com/babylonlabs-io/babylon/pull/61) ([vitsalis](https://github.com/vitsalis)) +- epoching: more test infra and some fuzz tests on keeper functionalities [\#60](https://github.com/babylonlabs-io/babylon/pull/60) ([SebastianElvis](https://github.com/SebastianElvis)) +- feat: checkpointing/aggregate BLS signatures [\#59](https://github.com/babylonlabs-io/babylon/pull/59) ([gitferry](https://github.com/gitferry)) +- feat: btclightclient: Abstract the usage of btcd types and store BTCHeaderInfo objects [\#58](https://github.com/babylonlabs-io/babylon/pull/58) ([vitsalis](https://github.com/vitsalis)) +- feat: Replace BTC types unit tests with fuzz tests [\#56](https://github.com/babylonlabs-io/babylon/pull/56) ([vitsalis](https://github.com/vitsalis)) +- feat: Create datagen testutil for common random generation functions [\#55](https://github.com/babylonlabs-io/babylon/pull/55) ([vitsalis](https://github.com/vitsalis)) +- epoching: wrapper type `Epoch` and simplify code using this type [\#54](https://github.com/babylonlabs-io/babylon/pull/54) ([SebastianElvis](https://github.com/SebastianElvis)) +- feat: Add btclightclient events and hooks [\#53](https://github.com/babylonlabs-io/babylon/pull/53) ([vitsalis](https://github.com/vitsalis)) +- feat: add raw checkpoint creation [\#52](https://github.com/babylonlabs-io/babylon/pull/52) ([gitferry](https://github.com/gitferry)) +- feat: Add accumulattive PoW functionality to btclightclient [\#51](https://github.com/babylonlabs-io/babylon/pull/51) ([vitsalis](https://github.com/vitsalis)) +- btclightclient: Cleanup codebase and add descriptive comments [\#50](https://github.com/babylonlabs-io/babylon/pull/50) ([vitsalis](https://github.com/vitsalis)) +- Update go to 1.18 in README [\#49](https://github.com/babylonlabs-io/babylon/pull/49) ([vitsalis](https://github.com/vitsalis)) +- Upgrade to go 1.18 [\#48](https://github.com/babylonlabs-io/babylon/pull/48) ([vitsalis](https://github.com/vitsalis)) +- feat: define checkpointing registration proto and state [\#46](https://github.com/babylonlabs-io/babylon/pull/46) ([gitferry](https://github.com/gitferry)) +- BM-60: Database schema ER diagram [\#45](https://github.com/babylonlabs-io/babylon/pull/45) ([aakoshh](https://github.com/aakoshh)) +- Revert "feat: CI: Generate a single block in build check " [\#44](https://github.com/babylonlabs-io/babylon/pull/44) ([vitsalis](https://github.com/vitsalis)) +- Btccheckpoint oracle schema and processing [\#43](https://github.com/babylonlabs-io/babylon/pull/43) ([KonradStaniec](https://github.com/KonradStaniec)) +- feat: Fuzz and unit tests for btclightclient types [\#42](https://github.com/babylonlabs-io/babylon/pull/42) ([vitsalis](https://github.com/vitsalis)) +- epoching: fix genesis, param and bootstrapping [\#41](https://github.com/babylonlabs-io/babylon/pull/41) ([SebastianElvis](https://github.com/SebastianElvis)) +- feat: Add unit tests for ValidateHeader of btcutils [\#40](https://github.com/babylonlabs-io/babylon/pull/40) ([vitsalis](https://github.com/vitsalis)) +- feat: Add unit tests for BTCHeaderHashBytes and BTCHeaderBytes types [\#39](https://github.com/babylonlabs-io/babylon/pull/39) ([vitsalis](https://github.com/vitsalis)) +- Add building, testing, and testnet instructions on README [\#38](https://github.com/babylonlabs-io/babylon/pull/38) ([vitsalis](https://github.com/vitsalis)) +- feat: CI: Generate a single block in build check [\#37](https://github.com/babylonlabs-io/babylon/pull/37) ([vitsalis](https://github.com/vitsalis)) +- epoching: event and hook upon a certain threshold amount of slashed voting power [\#35](https://github.com/babylonlabs-io/babylon/pull/35) ([SebastianElvis](https://github.com/SebastianElvis)) +- doc: add BLS key registration spec [\#34](https://github.com/babylonlabs-io/babylon/pull/34) ([gitferry](https://github.com/gitferry)) +- feat: add hooks, events, and error types to the checkpointing module [\#33](https://github.com/babylonlabs-io/babylon/pull/33) ([gitferry](https://github.com/gitferry)) +- epoching: state transition upon `BeginBlock` and `EndBlock` [\#32](https://github.com/babylonlabs-io/babylon/pull/32) ([SebastianElvis](https://github.com/SebastianElvis)) +- Handle insert checkpoint [\#31](https://github.com/babylonlabs-io/babylon/pull/31) ([KonradStaniec](https://github.com/KonradStaniec)) +- feat: Add btclightclient chain query [\#30](https://github.com/babylonlabs-io/babylon/pull/30) ([vitsalis](https://github.com/vitsalis)) +- feat: Implement BTCHeaderBytes and BTCHeaderHashBytes types [\#29](https://github.com/babylonlabs-io/babylon/pull/29) ([vitsalis](https://github.com/vitsalis)) +- epoching: copy/paste necessary code from staking/evidence/slashing and make modifications [\#28](https://github.com/babylonlabs-io/babylon/pull/28) ([SebastianElvis](https://github.com/SebastianElvis)) +- checkpointing: add keeper and core state [\#27](https://github.com/babylonlabs-io/babylon/pull/27) ([gitferry](https://github.com/gitferry)) +- FIX: btclightclient: Properly convert the input of contains to bytes [\#26](https://github.com/babylonlabs-io/babylon/pull/26) ([vitsalis](https://github.com/vitsalis)) +- BM-32: Update diagrams for out-of-sequence checkpoint handling [\#25](https://github.com/babylonlabs-io/babylon/pull/25) ([aakoshh](https://github.com/aakoshh)) +- FIX\(localnet\): Redirect babylond stderr to stdout [\#24](https://github.com/babylonlabs-io/babylon/pull/24) ([vitsalis](https://github.com/vitsalis)) +- BM-31: Add CircleCI pipeline for building and testing [\#23](https://github.com/babylonlabs-io/babylon/pull/23) ([vitsalis](https://github.com/vitsalis)) +- FIX: Failing btclightclient tests, remove unneeded ones, clean up [\#22](https://github.com/babylonlabs-io/babylon/pull/22) ([vitsalis](https://github.com/vitsalis)) +- FIX: Replace 'unimplemented' AnteHandler panic with comment [\#21](https://github.com/babylonlabs-io/babylon/pull/21) ([vitsalis](https://github.com/vitsalis)) +- FIX: Implement Msg interface for MsgInsertBTCSpvProof [\#20](https://github.com/babylonlabs-io/babylon/pull/20) ([vitsalis](https://github.com/vitsalis)) +- epoching: keeper functions, queries, and testing infra [\#19](https://github.com/babylonlabs-io/babylon/pull/19) ([SebastianElvis](https://github.com/SebastianElvis)) +- epoching: Wrapped messages and AnteHandler implementation [\#18](https://github.com/babylonlabs-io/babylon/pull/18) ([SebastianElvis](https://github.com/SebastianElvis)) +- FIX: Stringer in RawCheckpoint and correct checkpointing module ModuleName [\#17](https://github.com/babylonlabs-io/babylon/pull/17) ([vitsalis](https://github.com/vitsalis)) +- BM-16: feat\(epoching\): add AnteHandler `DropValidatorMsgDecorator` [\#15](https://github.com/babylonlabs-io/babylon/pull/15) ([SebastianElvis](https://github.com/SebastianElvis)) +- BM-13: feat\(epoching\): add hooks, events and keeper functions [\#14](https://github.com/babylonlabs-io/babylon/pull/14) ([SebastianElvis](https://github.com/SebastianElvis)) +- BM-10: Basic btcheaderoracle module [\#13](https://github.com/babylonlabs-io/babylon/pull/13) ([vitsalis](https://github.com/vitsalis)) +- BM-17: Add basic functianalities of bls crypto [\#12](https://github.com/babylonlabs-io/babylon/pull/12) ([gitferry](https://github.com/gitferry)) +- FIX: Resolve inconsistent BTCLightClientKeeper name [\#11](https://github.com/babylonlabs-io/babylon/pull/11) ([vitsalis](https://github.com/vitsalis)) +- BM-15: feat\(epoching\): add protobuf messages [\#10](https://github.com/babylonlabs-io/babylon/pull/10) ([SebastianElvis](https://github.com/SebastianElvis)) +- BM-6: Initial proposal for btc checkpoint message [\#8](https://github.com/babylonlabs-io/babylon/pull/8) ([KonradStaniec](https://github.com/KonradStaniec)) +- FIX: Do not modify go.mod when generating proto files [\#7](https://github.com/babylonlabs-io/babylon/pull/7) ([vitsalis](https://github.com/vitsalis)) +- BM-5: feat\(btc light client\): BTC Light Client module setup [\#6](https://github.com/babylonlabs-io/babylon/pull/6) ([vitsalis](https://github.com/vitsalis)) +- BM-2: feat\(checkpointing\): init checkpointing module and define proto types [\#5](https://github.com/babylonlabs-io/babylon/pull/5) ([gitferry](https://github.com/gitferry)) +- BM-6: Add initial scaffold for rawcheckpoint module [\#4](https://github.com/babylonlabs-io/babylon/pull/4) ([KonradStaniec](https://github.com/KonradStaniec)) +- FIX: Add script that downloads third party proto dependencies [\#3](https://github.com/babylonlabs-io/babylon/pull/3) ([vitsalis](https://github.com/vitsalis)) +- BM-3: feat\(epoching\): Epoching module setup [\#2](https://github.com/babylonlabs-io/babylon/pull/2) ([SebastianElvis](https://github.com/SebastianElvis)) +- BM-4: Add docs/diagrams with a Makefile and a test. [\#1](https://github.com/babylonlabs-io/babylon/pull/1) ([aakoshh](https://github.com/aakoshh)) + + + +\* *This Changelog was automatically generated by [github_changelog_generator](https://github.com/github-changelog-generator/github-changelog-generator)* diff --git a/LICENSE b/LICENSE index 45ff37b20..dc41cf54b 100644 --- a/LICENSE +++ b/LICENSE @@ -8,14 +8,14 @@ License text copyright (c) 2017 MariaDB Corporation Ab, All Rights Reserved. Parameters -Licensor: Babylonchain, Inc. +Licensor: Babylon Labs, Ltd. Licensed Work: Babylon - The Licensed Work is (c) 2023 Babylonchain, Inc. + The Licensed Work is (c) 2023 Babylon Labs, Ltd. Additional Use Grant: None. -Change Date: 2027-01-20 (January 20th, 2027] +Change Date: 2027-01-20 (January 20th, 2027) Change License: Apache 2.0 diff --git a/Makefile b/Makefile index bd525c73e..4c8db9052 100644 --- a/Makefile +++ b/Makefile @@ -5,8 +5,9 @@ PACKAGES_SIMTEST=$(shell go list ./... | grep '/simulation') COMMIT := $(shell git log -1 --format='%H') LEDGER_ENABLED ?= true BINDIR ?= $(GOPATH)/bin +PROJECT_NAME ?= babylon BUILDDIR ?= $(CURDIR)/build -HTTPS_GIT := https://github.com/babylonchain/babylon.git +HTTPS_GIT := https://github.com/babylonlabs-io/babylon.git DOCKER := $(shell which docker) SIMAPP = ./simapp @@ -117,7 +118,18 @@ ifeq (,$(findstring nostrip,$(BABYLON_BUILD_OPTIONS))) BUILD_FLAGS += -trimpath endif -all: tools build lint test +# Update changelog vars +ifneq (,$(SINCE_TAG)) + since_tag := --since-tag $(SINCE_TAG) +endif +ifneq (,$(UPCOMING_TAG)) + upcoming_tag := --upcoming-tag $(UPCOMING_TAG) +endif + +help: ## Print this help message + @grep -E '^[a-zA-Z0-9_-]+:.*?## .*$$' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}' + +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 @@ -131,12 +143,12 @@ BUILD_TARGETS := build install PACKAGES_E2E=$(shell go list ./... | grep '/e2e') -build: BUILD_ARGS=-o $(BUILDDIR)/ -build-linux: +build: BUILD_ARGS=-o $(BUILDDIR)/ ## Build babylond binary +build-linux: ## Build babylond linux version binary GOOS=linux GOARCH=$(if $(findstring aarch64,$(shell uname -m)) || $(findstring arm64,$(shell uname -m)),arm64,amd64) LEDGER_ENABLED=false $(MAKE) build $(BUILD_TARGETS): go.sum $(BUILDDIR)/ - CGO_CFLAGS="-O -D__BLST_PORTABLE__" go $@ -mod=readonly $(BUILD_FLAGS) $(BUILD_ARGS) ./... + go $@ -mod=readonly $(BUILD_FLAGS) $(BUILD_ARGS) ./... $(BUILDDIR)/: mkdir -p $(BUILDDIR)/ @@ -145,7 +157,7 @@ $(BUILDDIR)/: mockgen_cmd=go run github.com/golang/mock/mockgen@v1.6.0 -mocks: $(MOCKS_DIR) +mocks: $(MOCKS_DIR) ## Generate mock objects for testing $(mockgen_cmd) -source=x/checkpointing/types/expected_keepers.go -package mocks -destination testutil/mocks/checkpointing_expected_keepers.go $(mockgen_cmd) -source=x/checkpointing/keeper/bls_signer.go -package mocks -destination testutil/mocks/bls_signer.go $(mockgen_cmd) -source=x/zoneconcierge/types/expected_keepers.go -package types -destination x/zoneconcierge/types/mocked_keepers.go @@ -157,8 +169,8 @@ mocks: $(MOCKS_DIR) $(MOCKS_DIR): mkdir -p $(MOCKS_DIR) -distclean: clean tools-clean -clean: +distclean: clean tools-clean ## Remove all files generated by builds and remove all installed tools +clean: ## Remove all files generated by builds rm -rf \ $(BUILDDIR)/ \ artifacts/ \ @@ -182,7 +194,7 @@ go.sum: go.mod # This builds a docs site for each branch/tag in `./docs/versions` # and copies each site to a version prefixed path. The last entry inside # the `versions` file will be the default root index.html. -build-docs: diagrams +build-docs: diagrams ## Builds a docs site @cd client/docs && \ while read -r branch path_prefix; do \ (git checkout $${branch} && npm install && VUEPRESS_BASE="/$${path_prefix}/" npm run build) ; \ @@ -196,8 +208,8 @@ build-docs: diagrams ### Tests & Simulation ### ############################################################################### -test: test-unit -test-all: test-unit test-ledger-mock test-race test-cover +test: test-unit ## Run unit tests +test-all: test-unit test-ledger-mock test-race test-cover ## Run all tests TEST_PACKAGES=./... TEST_TARGETS := test-unit test-unit-amino test-unit-proto test-ledger-mock test-race test-ledger test-race test-cover @@ -313,10 +325,10 @@ containerMarkdownLintFix=babylon-markdownlint-fix golangci_lint_cmd=go run github.com/golangci/golangci-lint/cmd/golangci-lint -lint: lint-go +lint: lint-go ## Run go linter @if docker ps -a --format '{{.Names}}' | grep -Eq "^${containerMarkdownLint}$$"; then docker start -a $(containerMarkdownLint); else docker run --name $(containerMarkdownLint) -i -v "$(CURDIR):/work" $(markdownLintImage); fi -lint-fix: +lint-fix: ## Run go linter and fix reported issues $(golangci_lint_cmd) run --fix --out-format=tab --issues-exit-code=0 @if docker ps -a --format '{{.Names}}' | grep -Eq "^${containerMarkdownLintFix}$$"; then docker start -a $(containerMarkdownLintFix); else docker run --name $(containerMarkdownLintFix) -i -v "$(CURDIR):/work" $(markdownLintImage) . --fix; fi @@ -326,34 +338,46 @@ lint-go: .PHONY: lint lint-fix -format: +format: ## Run code formater 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/babylonchain/babylon + 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 +############################################################################### +### Gosec ### +############################################################################### + +gosec: ## Run security checks + $(DOCKER) run --rm -it -w /$(PROJECT_NAME)/ -v $(CURDIR):/$(PROJECT_NAME) securego/gosec -exclude-generated -exclude-dir=/$(PROJECT_NAME)/testutil -exclude-dir=/$(PROJECT_NAME)/test -conf /$(PROJECT_NAME)/gosec.json /$(PROJECT_NAME)/... + +gosec-local: ## Run local security checkss + gosec -exclude-generated -exclude-dir=$(CURDIR)/testutil -exclude-dir=$(CURDIR)/test -conf $(CURDIR)/gosec.json $(CURDIR)/... + +.PHONY: gosec gosec-local + ############################################################################### ### Devdoc ### ############################################################################### DEVDOC_SAVE = docker commit `docker ps -a -n 1 -q` devdoc:local -devdoc-init: - $(DOCKER) run -it -v "$(CURDIR):/go/src/github.com/babylonchain/babylon" -w "/go/src/github.com/babylonchain/babylon" tendermint/devdoc echo +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: - $(DOCKER) run -it -v "$(CURDIR):/go/src/github.com/babylonchain/babylon" -w "/go/src/github.com/babylonchain/babylon" devdoc:local bash +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: +devdoc-save: ## Save documentation changes # TODO make this safer $(call DEVDOC_SAVE) -devdoc-clean: +devdoc-clean: ## Clean up documentation artifacts docker rmi -f $$(docker images -f "dangling=true" -q) -devdoc-update: +devdoc-update: ## Update documentation tools docker pull tendermint/devdoc .PHONY: devdoc devdoc-clean devdoc-init devdoc-save devdoc-update @@ -366,20 +390,20 @@ protoVer=0.14.0 protoImageName=ghcr.io/cosmos/proto-builder:$(protoVer) protoImage=$(DOCKER) run --rm -v $(CURDIR):/workspace --workdir /workspace $(protoImageName) -proto-all: proto-gen proto-swagger-gen +proto-all: proto-gen proto-swagger-gen ## Generate all protobuf related files -proto-gen: +proto-gen: ## Generate protobuf files @echo "Generating Protobuf files" @$(protoImage) sh ./proto/scripts/protocgen.sh -proto-swagger-gen: +proto-swagger-gen: ## Generate Swagger files from protobuf @echo "Generating Protobuf Swagger" @$(protoImage) sh ./proto/scripts/protoc-swagger-gen.sh -proto-format: +proto-format: ## Format protobuf files @$(protoImage) find ./ -name "*.proto" -exec clang-format -i {} \; -proto-lint: +proto-lint: ## Lint protobuf files @$(protoImage) buf lint --error-format=json .PHONY: proto-gen proto-swagger-gen proto-format prot-lint @@ -388,10 +412,10 @@ proto-lint: ### Docker ### ############################################################################### -build-docker: +build-docker: ## Build babylond Docker image $(MAKE) -C contrib/images babylond -build-cosmos-relayer-docker: +build-cosmos-relayer-docker: ## Build Docker image for the Cosmos relayer $(MAKE) -C contrib/images cosmos-relayer .PHONY: build-docker build-cosmos-relayer-docker @@ -400,29 +424,27 @@ build-cosmos-relayer-docker: ### Localnet ### ############################################################################### -# init-testnet-dirs will create a ./.testnets directory containing configuration for 4 Babylon nodes -init-testnet-dirs: +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 babylonchain/babylond \ + $(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 will boot the nodes described in the docker-compose.yml file -localnet-start-nodes: init-testnet-dirs +localnet-start-nodes: init-testnet-dirs ## Boot the nodes described in the docker-compose.yml file docker-compose up -d -# localnet-start will run a with 4 nodes with 4 nodes, a bitcoin instance, and a vigilante instance -localnet-start: localnet-stop build-docker localnet-start-nodes +localnet-start: localnet-stop build-docker localnet-start-nodes ## Run with 4 nodes, a bitcoin instance, and a vigilante instance -# localnet-stop will stop all localnets running +# localnet-stop will clean up and stop all localnets running localnet-stop: + rm -rf $(CURDIR)/.testnets docker-compose down -build-test-wasm: +build-test-wasm: ## Build WASM bindings for testing 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 \ @@ -439,5 +461,10 @@ localnet-start \ localnet-stop .PHONY: diagrams -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) diff --git a/README.md b/README.md index 3c9ccfbb1..3ed4699e6 100644 --- a/README.md +++ b/README.md @@ -21,12 +21,19 @@ litepaper](https://badgen.net/badge/icon/BTC%20staking%20litepaper?label=)](http [![BTC timestamping whitepaper](https://badgen.net/badge/icon/BTC%20timestamping%20whitepaper?label=)](https://arxiv.org/abs/2207.08392) -## Build and install +## System requirements + +This system spec has been tested by validators and found to be comfortable: -This repository contains the Golang implementation of the Babylon node. It is -based on the [Cosmos SDK](https://github.com/cosmos/cosmos-sdk). +- Quad Core or larger AMD or Intel (amd64) CPU +- 32GB RAM +- 1TB NVMe Storage +- 100MBps bidirectional internet connection -### Requirements +You can run Babylon on lower-spec hardware for each component, but you may find +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 instructions on the [Golang page](https://go.dev/doc/install) to do that. @@ -56,7 +63,7 @@ document about its design and implementation. ## Joining the testnet Please follow the instructions on the [User -Guides](https://docs.babylonchain.io/docs/user-guides/). +Guides](https://docs.babylonchain.io/docs/user-guides/overview). ## Contributing diff --git a/SECURITY.md b/SECURITY.md index e30d358d5..ee8c3febf 100644 --- a/SECURITY.md +++ b/SECURITY.md @@ -25,7 +25,7 @@ Send your detailed vulnerability report to `security@babylonchain.io`. ### 2. GitHub Private Vulnerability Reporting -Utilize [GitHub's Private Vulnerability Reporting](https://github.com/babylonchain/babylon/security/advisories/new) +Utilize [GitHub's Private Vulnerability Reporting](https://github.com/babylonlabs-io/babylon/security/advisories/new) for confidential disclosure. ## Submit Vulnerability Report diff --git a/app/ante_btc_validation_decorator.go b/app/ante_btc_validation_decorator.go index 79f800257..8e5febfb8 100644 --- a/app/ante_btc_validation_decorator.go +++ b/app/ante_btc_validation_decorator.go @@ -1,10 +1,10 @@ package app import ( - bbn "github.com/babylonchain/babylon/types" - btccheckpointkeeper "github.com/babylonchain/babylon/x/btccheckpoint/keeper" - btccheckpointtypes "github.com/babylonchain/babylon/x/btccheckpoint/types" - btclightclient "github.com/babylonchain/babylon/x/btclightclient/types" + bbn "github.com/babylonlabs-io/babylon/types" + btccheckpointkeeper "github.com/babylonlabs-io/babylon/x/btccheckpoint/keeper" + btccheckpointtypes "github.com/babylonlabs-io/babylon/x/btccheckpoint/types" + btclightclient "github.com/babylonlabs-io/babylon/x/btclightclient/types" sdk "github.com/cosmos/cosmos-sdk/types" ) @@ -42,7 +42,7 @@ func (bvd BtcValidationDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, simulat powLimit := bvd.BtcCfg.PowLimit() err := msg.ValidateHeaders(&powLimit) if err != nil { - return ctx, btclightclient.ErrInvalidProofOfWOrk + return ctx, btclightclient.ErrInvalidProofOfWOrk.Wrapf("MsgInsertHeaders error: %s - PoW Limit - %s", err.Error(), powLimit.String()) } default: // NOOP in case of other messages diff --git a/app/app.go b/app/app.go index 9d9aa6436..541bcd8d3 100644 --- a/app/app.go +++ b/app/app.go @@ -11,20 +11,14 @@ import ( reflectionv1 "cosmossdk.io/api/cosmos/reflection/v1" "cosmossdk.io/client/v2/autocli" "cosmossdk.io/core/appmodule" - errorsmod "cosmossdk.io/errors" "cosmossdk.io/log" - storetypes "cosmossdk.io/store/types" "cosmossdk.io/x/circuit" - circuitkeeper "cosmossdk.io/x/circuit/keeper" circuittypes "cosmossdk.io/x/circuit/types" "cosmossdk.io/x/evidence" - evidencekeeper "cosmossdk.io/x/evidence/keeper" evidencetypes "cosmossdk.io/x/evidence/types" "cosmossdk.io/x/feegrant" - feegrantkeeper "cosmossdk.io/x/feegrant/keeper" feegrantmodule "cosmossdk.io/x/feegrant/module" "cosmossdk.io/x/upgrade" - upgradekeeper "cosmossdk.io/x/upgrade/keeper" upgradetypes "cosmossdk.io/x/upgrade/types" wasmapp "github.com/CosmWasm/wasmd/app" "github.com/CosmWasm/wasmd/x/wasm" @@ -49,103 +43,82 @@ import ( "github.com/cosmos/cosmos-sdk/std" "github.com/cosmos/cosmos-sdk/testutil/testdata" sdk "github.com/cosmos/cosmos-sdk/types" - sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" "github.com/cosmos/cosmos-sdk/types/module" "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" - authkeeper "github.com/cosmos/cosmos-sdk/x/auth/keeper" authsims "github.com/cosmos/cosmos-sdk/x/auth/simulation" authtx "github.com/cosmos/cosmos-sdk/x/auth/tx" authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" "github.com/cosmos/cosmos-sdk/x/auth/vesting" vestingtypes "github.com/cosmos/cosmos-sdk/x/auth/vesting/types" "github.com/cosmos/cosmos-sdk/x/authz" - authzkeeper "github.com/cosmos/cosmos-sdk/x/authz/keeper" authzmodule "github.com/cosmos/cosmos-sdk/x/authz/module" "github.com/cosmos/cosmos-sdk/x/bank" - bankkeeper "github.com/cosmos/cosmos-sdk/x/bank/keeper" banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" "github.com/cosmos/cosmos-sdk/x/consensus" - consensusparamkeeper "github.com/cosmos/cosmos-sdk/x/consensus/keeper" consensusparamtypes "github.com/cosmos/cosmos-sdk/x/consensus/types" "github.com/cosmos/cosmos-sdk/x/crisis" - crisiskeeper "github.com/cosmos/cosmos-sdk/x/crisis/keeper" crisistypes "github.com/cosmos/cosmos-sdk/x/crisis/types" distr "github.com/cosmos/cosmos-sdk/x/distribution" - distrkeeper "github.com/cosmos/cosmos-sdk/x/distribution/keeper" distrtypes "github.com/cosmos/cosmos-sdk/x/distribution/types" "github.com/cosmos/cosmos-sdk/x/genutil" genutiltypes "github.com/cosmos/cosmos-sdk/x/genutil/types" "github.com/cosmos/cosmos-sdk/x/gov" govclient "github.com/cosmos/cosmos-sdk/x/gov/client" - 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" "github.com/cosmos/cosmos-sdk/x/mint" - 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" paramsclient "github.com/cosmos/cosmos-sdk/x/params/client" - paramskeeper "github.com/cosmos/cosmos-sdk/x/params/keeper" paramstypes "github.com/cosmos/cosmos-sdk/x/params/types" - paramproposal "github.com/cosmos/cosmos-sdk/x/params/types/proposal" "github.com/cosmos/cosmos-sdk/x/slashing" - slashingkeeper "github.com/cosmos/cosmos-sdk/x/slashing/keeper" slashingtypes "github.com/cosmos/cosmos-sdk/x/slashing/types" "github.com/cosmos/cosmos-sdk/x/staking" - stakingkeeper "github.com/cosmos/cosmos-sdk/x/staking/keeper" stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" "github.com/cosmos/gogoproto/proto" "github.com/cosmos/ibc-go/modules/capability" - capabilitykeeper "github.com/cosmos/ibc-go/modules/capability/keeper" capabilitytypes "github.com/cosmos/ibc-go/modules/capability/types" + ibcwasm "github.com/cosmos/ibc-go/modules/light-clients/08-wasm" + ibcwasmkeeper "github.com/cosmos/ibc-go/modules/light-clients/08-wasm/keeper" + ibcwasmtypes "github.com/cosmos/ibc-go/modules/light-clients/08-wasm/types" ibcfee "github.com/cosmos/ibc-go/v8/modules/apps/29-fee" - ibcfeekeeper "github.com/cosmos/ibc-go/v8/modules/apps/29-fee/keeper" ibcfeetypes "github.com/cosmos/ibc-go/v8/modules/apps/29-fee/types" "github.com/cosmos/ibc-go/v8/modules/apps/transfer" - ibctransferkeeper "github.com/cosmos/ibc-go/v8/modules/apps/transfer/keeper" ibctransfertypes "github.com/cosmos/ibc-go/v8/modules/apps/transfer/types" - ibc "github.com/cosmos/ibc-go/v8/modules/core" - porttypes "github.com/cosmos/ibc-go/v8/modules/core/05-port/types" // ibc module puts types under `ibchost` rather than `ibctypes` + ibc "github.com/cosmos/ibc-go/v8/modules/core" // ibc module puts types under `ibchost` rather than `ibctypes` ibcexported "github.com/cosmos/ibc-go/v8/modules/core/exported" - ibckeeper "github.com/cosmos/ibc-go/v8/modules/core/keeper" ibctm "github.com/cosmos/ibc-go/v8/modules/light-clients/07-tendermint" "github.com/spf13/cast" - appparams "github.com/babylonchain/babylon/app/params" - "github.com/babylonchain/babylon/client/docs" - bbn "github.com/babylonchain/babylon/types" - owasm "github.com/babylonchain/babylon/wasmbinding" - "github.com/babylonchain/babylon/x/btccheckpoint" - btccheckpointkeeper "github.com/babylonchain/babylon/x/btccheckpoint/keeper" - btccheckpointtypes "github.com/babylonchain/babylon/x/btccheckpoint/types" - "github.com/babylonchain/babylon/x/btclightclient" - btclightclientkeeper "github.com/babylonchain/babylon/x/btclightclient/keeper" - btclightclienttypes "github.com/babylonchain/babylon/x/btclightclient/types" - "github.com/babylonchain/babylon/x/btcstaking" - btcstakingkeeper "github.com/babylonchain/babylon/x/btcstaking/keeper" - btcstakingtypes "github.com/babylonchain/babylon/x/btcstaking/types" - "github.com/babylonchain/babylon/x/checkpointing" - checkpointingkeeper "github.com/babylonchain/babylon/x/checkpointing/keeper" - checkpointingtypes "github.com/babylonchain/babylon/x/checkpointing/types" - "github.com/babylonchain/babylon/x/epoching" - epochingkeeper "github.com/babylonchain/babylon/x/epoching/keeper" - epochingtypes "github.com/babylonchain/babylon/x/epoching/types" - "github.com/babylonchain/babylon/x/finality" - finalitykeeper "github.com/babylonchain/babylon/x/finality/keeper" - finalitytypes "github.com/babylonchain/babylon/x/finality/types" - "github.com/babylonchain/babylon/x/incentive" - incentivekeeper "github.com/babylonchain/babylon/x/incentive/keeper" - incentivetypes "github.com/babylonchain/babylon/x/incentive/types" - "github.com/babylonchain/babylon/x/monitor" - monitorkeeper "github.com/babylonchain/babylon/x/monitor/keeper" - monitortypes "github.com/babylonchain/babylon/x/monitor/types" - "github.com/babylonchain/babylon/x/zoneconcierge" - zckeeper "github.com/babylonchain/babylon/x/zoneconcierge/keeper" - zctypes "github.com/babylonchain/babylon/x/zoneconcierge/types" + "github.com/babylonlabs-io/babylon/app/upgrades" + bbn "github.com/babylonlabs-io/babylon/types" + + appkeepers "github.com/babylonlabs-io/babylon/app/keepers" + appparams "github.com/babylonlabs-io/babylon/app/params" + "github.com/babylonlabs-io/babylon/client/docs" + "github.com/babylonlabs-io/babylon/x/btccheckpoint" + btccheckpointtypes "github.com/babylonlabs-io/babylon/x/btccheckpoint/types" + "github.com/babylonlabs-io/babylon/x/btclightclient" + btclightclienttypes "github.com/babylonlabs-io/babylon/x/btclightclient/types" + "github.com/babylonlabs-io/babylon/x/btcstaking" + btcstakingtypes "github.com/babylonlabs-io/babylon/x/btcstaking/types" + "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" + incentivetypes "github.com/babylonlabs-io/babylon/x/incentive/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" ) const ( @@ -156,12 +129,6 @@ const ( // environmental variables - https://github.com/cosmos/cosmos-sdk/pull/10950 BabylonAppEnvPrefix = "" - // TODO review possible capabilities - // The last arguments can contain custom message handlers, and custom query handlers, - // if we want to allow any custom callbacks - // See https://github.com/CosmWasm/cosmwasm/blob/main/docs/CAPABILITIES-BUILT-IN.md - wasmCapabilities = "iterator,stargate,cosmwasm_1_1,cosmwasm_1_2,babylon" - // According to https://github.com/CosmWasm/wasmd#genesis-configuration chains // using smart contracts should configure proper gas limits per block. // https://medium.com/cosmwasm/cosmwasm-for-ctos-iv-native-integrations-713140bf75fc @@ -172,6 +139,9 @@ const ( ) var ( + // EmptyWasmOpts defines a type alias for a list of wasm options. + EmptyWasmOpts []wasmkeeper.Option + // DefaultNodeHome default home directories for the application daemon DefaultNodeHome string // fee collector account, module accounts and their permissions @@ -186,14 +156,22 @@ var ( ibcfeetypes.ModuleName: nil, incentivetypes.ModuleName: nil, // this line is needed to create an account for incentive module } -) -// Wasm related variables -var ( - // EmptyWasmOpts defines a type alias for a list of wasm options. - EmptyWasmOpts []wasmkeeper.Option + // software upgrades and forks + Upgrades = []upgrades.Upgrade{} + Forks = []upgrades.Fork{} ) +func init() { + // Note: If this changes, the home directory under x/checkpointing/client/cli/tx.go needs to change as well + userHomeDir, err := os.UserHomeDir() + if err != nil { + panic(err) + } + + DefaultNodeHome = filepath.Join(userHomeDir, ".babylond") +} + var ( _ runtime.AppI = (*BabylonApp)(nil) _ servertypes.Application = (*BabylonApp)(nil) @@ -204,65 +182,14 @@ var ( // capabilities aren't needed for testing. type BabylonApp struct { *baseapp.BaseApp + *appkeepers.AppKeepers + legacyAmino *codec.LegacyAmino appCodec codec.Codec txConfig client.TxConfig interfaceRegistry types.InterfaceRegistry - - invCheckPeriod uint - - // keys to access the substores - keys map[string]*storetypes.KVStoreKey - tkeys map[string]*storetypes.TransientStoreKey - memKeys map[string]*storetypes.MemoryStoreKey - - // keepers - AccountKeeper authkeeper.AccountKeeper - BankKeeper bankkeeper.Keeper - CapabilityKeeper *capabilitykeeper.Keeper - StakingKeeper *stakingkeeper.Keeper - SlashingKeeper slashingkeeper.Keeper - MintKeeper mintkeeper.Keeper - DistrKeeper distrkeeper.Keeper - GovKeeper govkeeper.Keeper - CrisisKeeper *crisiskeeper.Keeper - UpgradeKeeper *upgradekeeper.Keeper - ParamsKeeper paramskeeper.Keeper - AuthzKeeper authzkeeper.Keeper - EvidenceKeeper evidencekeeper.Keeper - FeeGrantKeeper feegrantkeeper.Keeper - ConsensusParamsKeeper consensusparamkeeper.Keeper - CircuitKeeper circuitkeeper.Keeper - - // Babylon modules - EpochingKeeper epochingkeeper.Keeper - BTCLightClientKeeper btclightclientkeeper.Keeper - BtcCheckpointKeeper btccheckpointkeeper.Keeper - CheckpointingKeeper checkpointingkeeper.Keeper - MonitorKeeper monitorkeeper.Keeper - - // IBC-related modules - IBCKeeper *ibckeeper.Keeper // IBC Keeper must be a pointer in the app, so we can SetRouter on it correctly - IBCFeeKeeper ibcfeekeeper.Keeper // for relayer incentivization - https://github.com/cosmos/ibc/tree/main/spec/app/ics-029-fee-payment - TransferKeeper ibctransferkeeper.Keeper // for cross-chain fungible token transfers - ZoneConciergeKeeper zckeeper.Keeper // for cross-chain fungible token transfers - - // BTC staking related modules - BTCStakingKeeper btcstakingkeeper.Keeper - FinalityKeeper finalitykeeper.Keeper - - // wasm smart contract module - WasmKeeper wasmkeeper.Keeper - - // tokenomics-related modules - IncentiveKeeper incentivekeeper.Keeper - - // make scoped keepers public for test purposes - ScopedIBCKeeper capabilitykeeper.ScopedKeeper - ScopedTransferKeeper capabilitykeeper.ScopedKeeper - ScopedZoneConciergeKeeper capabilitykeeper.ScopedKeeper - ScopedWasmKeeper capabilitykeeper.ScopedKeeper + invCheckPeriod uint // the module manager ModuleManager *module.Manager @@ -275,29 +202,22 @@ type BabylonApp struct { configurator module.Configurator } -func init() { - // Note: If this changes, the home directory under x/checkpointing/client/cli/tx.go needs to change as well - userHomeDir, err := os.UserHomeDir() - if err != nil { - panic(err) - } - - DefaultNodeHome = filepath.Join(userHomeDir, ".babylond") -} - // NewBabylonApp returns a reference to an initialized BabylonApp. func NewBabylonApp( - logger log.Logger, db dbm.DB, traceStore io.Writer, loadLatest bool, skipUpgradeHeights map[int64]bool, - invCheckPeriod uint, privSigner *PrivSigner, + logger log.Logger, + db dbm.DB, + traceStore io.Writer, + loadLatest bool, + skipUpgradeHeights map[int64]bool, + invCheckPeriod uint, + privSigner *appkeepers.PrivSigner, appOpts servertypes.AppOptions, wasmOpts []wasmkeeper.Option, baseAppOptions ...func(*baseapp.BaseApp), ) *BabylonApp { - // we could also take it from global object which should be initilised in rootCmd + // we could also take it from global object which should be initialised in rootCmd // but this way it makes babylon app more testable btcConfig := bbn.ParseBtcOptionsFromConfig(appOpts) - powLimit := btcConfig.PowLimit() - btcNetParams := btcConfig.NetParams() homePath := cast.ToString(appOpts.Get(flags.FlagHome)) if homePath == "" { homePath = DefaultNodeHome @@ -311,451 +231,44 @@ func NewBabylonApp( std.RegisterLegacyAminoCodec(legacyAmino) std.RegisterInterfaces(interfaceRegistry) - keys := storetypes.NewKVStoreKeys( - authtypes.StoreKey, banktypes.StoreKey, stakingtypes.StoreKey, crisistypes.StoreKey, - minttypes.StoreKey, distrtypes.StoreKey, slashingtypes.StoreKey, - govtypes.StoreKey, paramstypes.StoreKey, consensusparamtypes.StoreKey, upgradetypes.StoreKey, feegrant.StoreKey, - evidencetypes.StoreKey, circuittypes.StoreKey, capabilitytypes.StoreKey, - authzkeeper.StoreKey, - // Babylon modules - epochingtypes.StoreKey, - btclightclienttypes.StoreKey, - btccheckpointtypes.StoreKey, - checkpointingtypes.StoreKey, - monitortypes.StoreKey, - // IBC-related modules - ibcexported.StoreKey, - ibctransfertypes.StoreKey, - ibcfeetypes.StoreKey, - zctypes.StoreKey, - // BTC staking related modules - btcstakingtypes.StoreKey, - finalitytypes.StoreKey, - // WASM - wasmtypes.StoreKey, - // tokenomics-related modules - incentivetypes.StoreKey, - ) - accountKeeper := authkeeper.NewAccountKeeper( - appCodec, - runtime.NewKVStoreService(keys[authtypes.StoreKey]), - authtypes.ProtoBaseAccount, - maccPerms, - authcodec.NewBech32Codec(appparams.Bech32PrefixAccAddr), - appparams.Bech32PrefixAccAddr, - authtypes.NewModuleAddress(govtypes.ModuleName).String(), - ) - - bankKeeper := bankkeeper.NewBaseKeeper( - appCodec, - runtime.NewKVStoreService(keys[banktypes.StoreKey]), - accountKeeper, - BlockedAddresses(), - authtypes.NewModuleAddress(govtypes.ModuleName).String(), - logger, - ) - - stakingKeeper := stakingkeeper.NewKeeper( - appCodec, - runtime.NewKVStoreService(keys[stakingtypes.StoreKey]), - accountKeeper, - bankKeeper, - authtypes.NewModuleAddress(govtypes.ModuleName).String(), - authcodec.NewBech32Codec(appparams.Bech32PrefixValAddr), - authcodec.NewBech32Codec(appparams.Bech32PrefixConsAddr), - ) - - // NOTE: the epoching module has to be set before the chekpointing module, as the checkpointing module will have access to the epoching module - epochingKeeper := epochingkeeper.NewKeeper( - appCodec, - runtime.NewKVStoreService(keys[epochingtypes.StoreKey]), - bankKeeper, - stakingKeeper, - authtypes.NewModuleAddress(govtypes.ModuleName).String(), - ) - - checkpointingKeeper := checkpointingkeeper.NewKeeper( - appCodec, - runtime.NewKVStoreService(keys[checkpointingtypes.StoreKey]), - privSigner.WrappedPV, - epochingKeeper, - ) - bApp := baseapp.NewBaseApp(appName, logger, db, txConfig.TxDecoder(), baseAppOptions...) bApp.SetCommitMultiStoreTracer(traceStore) bApp.SetVersion(version.Version) bApp.SetInterfaceRegistry(interfaceRegistry) bApp.SetTxEncoder(txConfig.TxEncoder()) - // set handlers of vote extension - voteExtHandler := checkpointing.NewVoteExtensionHandler(logger, &checkpointingKeeper) - voteExtHandler.SetHandlers(bApp) - proposalHandler := checkpointing.NewProposalHandler( - logger, &checkpointingKeeper, bApp.Mempool(), bApp) - proposalHandler.SetHandlers(bApp) - - tkeys := storetypes.NewTransientStoreKeys( - paramstypes.TStoreKey, btccheckpointtypes.TStoreKey) - // NOTE: The testingkey is just mounted for testing purposes. Actual applications should - // not include this key. - memKeys := storetypes.NewMemoryStoreKeys(capabilitytypes.MemStoreKey, "testingkey") - - // register streaming services - if err := bApp.RegisterStreamingServices(appOpts, keys); err != nil { - panic(err) + wasmConfig, err := wasm.ReadWasmConfig(appOpts) + if err != nil { + panic(fmt.Sprintf("error while reading wasm config: %s", err)) } app := &BabylonApp{ + AppKeepers: &appkeepers.AppKeepers{}, BaseApp: bApp, legacyAmino: legacyAmino, appCodec: appCodec, txConfig: txConfig, interfaceRegistry: interfaceRegistry, invCheckPeriod: invCheckPeriod, - keys: keys, - tkeys: tkeys, - memKeys: memKeys, } - app.ParamsKeeper = initParamsKeeper( - appCodec, - legacyAmino, - keys[paramstypes.StoreKey], - tkeys[paramstypes.TStoreKey], - ) - - app.ConsensusParamsKeeper = consensusparamkeeper.NewKeeper( - appCodec, - runtime.NewKVStoreService(keys[consensusparamtypes.StoreKey]), - authtypes.NewModuleAddress(govtypes.ModuleName).String(), - runtime.EventService{}, - ) - bApp.SetParamStore(app.ConsensusParamsKeeper.ParamsStore) - - app.CapabilityKeeper = capabilitykeeper.NewKeeper( - appCodec, - keys[capabilitytypes.StoreKey], - memKeys[capabilitytypes.MemStoreKey], - ) - - // grant capabilities for the ibc and ibc-transfer modules - scopedIBCKeeper := app.CapabilityKeeper.ScopeToModule(ibcexported.ModuleName) - scopedTransferKeeper := app.CapabilityKeeper.ScopeToModule(ibctransfertypes.ModuleName) - scopedZoneConciergeKeeper := app.CapabilityKeeper.ScopeToModule(zctypes.ModuleName) - scopedWasmKeeper := app.CapabilityKeeper.ScopeToModule(wasmtypes.ModuleName) - - // Applications that wish to enforce statically created ScopedKeepers should call `Seal` after creating - // their scoped modules in `NewApp` with `ScopeToModule` - app.CapabilityKeeper.Seal() - - // add keepers - app.AccountKeeper = accountKeeper - - app.BankKeeper = bankKeeper - - app.StakingKeeper = stakingKeeper - - app.CircuitKeeper = circuitkeeper.NewKeeper( - appCodec, - runtime.NewKVStoreService(keys[circuittypes.StoreKey]), - authtypes.NewModuleAddress(govtypes.ModuleName).String(), - app.AccountKeeper.AddressCodec(), - ) - app.BaseApp.SetCircuitBreaker(&app.CircuitKeeper) - - app.MintKeeper = mintkeeper.NewKeeper( - appCodec, - runtime.NewKVStoreService(keys[minttypes.StoreKey]), - app.StakingKeeper, - app.AccountKeeper, - app.BankKeeper, - authtypes.FeeCollectorName, - authtypes.NewModuleAddress(govtypes.ModuleName).String(), - ) - - app.DistrKeeper = distrkeeper.NewKeeper( - appCodec, - runtime.NewKVStoreService(keys[distrtypes.StoreKey]), - app.AccountKeeper, - app.BankKeeper, - app.StakingKeeper, - authtypes.FeeCollectorName, - authtypes.NewModuleAddress(govtypes.ModuleName).String(), - ) - - // set up incentive keeper - app.IncentiveKeeper = incentivekeeper.NewKeeper( - appCodec, - runtime.NewKVStoreService(keys[incentivetypes.StoreKey]), - app.BankKeeper, - app.AccountKeeper, - &epochingKeeper, - authtypes.NewModuleAddress(govtypes.ModuleName).String(), - authtypes.FeeCollectorName, - ) - - app.SlashingKeeper = slashingkeeper.NewKeeper( - appCodec, - legacyAmino, - runtime.NewKVStoreService(keys[slashingtypes.StoreKey]), - app.StakingKeeper, - authtypes.NewModuleAddress(govtypes.ModuleName).String(), - ) - - app.CrisisKeeper = crisiskeeper.NewKeeper( + app.AppKeepers.InitKeepers( + logger, appCodec, - runtime.NewKVStoreService(keys[crisistypes.StoreKey]), + &btcConfig, + encCfg, + bApp, + maccPerms, + homePath, invCheckPeriod, - app.BankKeeper, - authtypes.FeeCollectorName, - authtypes.NewModuleAddress(govtypes.ModuleName).String(), - app.AccountKeeper.AddressCodec(), - ) - - app.FeeGrantKeeper = feegrantkeeper.NewKeeper( - appCodec, - runtime.NewKVStoreService(keys[feegrant.StoreKey]), - app.AccountKeeper, - ) - // register the staking hooks - // NOTE: stakingKeeper above is passed by reference, so that it will contain these hooks - app.StakingKeeper.SetHooks( - stakingtypes.NewMultiStakingHooks(app.DistrKeeper.Hooks(), app.SlashingKeeper.Hooks(), epochingKeeper.Hooks()), - ) - - // set the governance module account as the authority for conducting upgrades - app.UpgradeKeeper = upgradekeeper.NewKeeper( skipUpgradeHeights, - runtime.NewKVStoreService(keys[upgradetypes.StoreKey]), - appCodec, - homePath, - app.BaseApp, - authtypes.NewModuleAddress(govtypes.ModuleName).String(), - ) - - app.AuthzKeeper = authzkeeper.NewKeeper( - runtime.NewKVStoreService(keys[authzkeeper.StoreKey]), - appCodec, - app.MsgServiceRouter(), - app.AccountKeeper, - ) - - app.IBCKeeper = ibckeeper.NewKeeper( - appCodec, - keys[ibcexported.StoreKey], - app.GetSubspace(ibcexported.ModuleName), - app.StakingKeeper, - app.UpgradeKeeper, - scopedIBCKeeper, - // From 8.0.0 the IBC keeper requires an authority for the messages - // `MsgIBCSoftwareUpgrade` and `MsgRecoverClient` - // https://github.com/cosmos/ibc-go/releases/tag/v8.0.0 - // Gov is the proper authority for those types of messages - authtypes.NewModuleAddress(govtypes.ModuleName).String(), - ) - - // register the proposal types - // Deprecated: Avoid adding new handlers, instead use the new proposal flow - // by granting the governance module the right to execute the message. - // See: https://github.com/cosmos/cosmos-sdk/blob/release/v0.46.x/x/gov/spec/01_concepts.md#proposal-messages - // TODO: investigate how to migrate to new proposal flow - govRouter := govv1beta1.NewRouter() - govRouter.AddRoute(govtypes.RouterKey, govv1beta1.ProposalHandler). - AddRoute(paramproposal.RouterKey, params.NewParamChangeProposalHandler(app.ParamsKeeper)) - - // TODO: this should be a function parameter - govConfig := govtypes.DefaultConfig() - /* - Example of setting gov params: - govConfig.MaxMetadataLen = 10000 - */ - govKeeper := govkeeper.NewKeeper( - appCodec, - runtime.NewKVStoreService(keys[govtypes.StoreKey]), - app.AccountKeeper, - app.BankKeeper, - app.StakingKeeper, - app.DistrKeeper, - app.MsgServiceRouter(), - govConfig, - authtypes.NewModuleAddress(govtypes.ModuleName).String()) - - app.GovKeeper = *govKeeper.SetHooks( - govtypes.NewMultiGovHooks( - // register the governance hooks - ), - ) - - btclightclientKeeper := btclightclientkeeper.NewKeeper( - appCodec, - runtime.NewKVStoreService(keys[btclightclienttypes.StoreKey]), - btcConfig, - authtypes.NewModuleAddress(govtypes.ModuleName).String(), - ) - - btcCheckpointKeeper := btccheckpointkeeper.NewKeeper( - appCodec, - runtime.NewKVStoreService(keys[btccheckpointtypes.StoreKey]), - tkeys[btccheckpointtypes.TStoreKey], - &btclightclientKeeper, - &checkpointingKeeper, - &app.IncentiveKeeper, - &powLimit, - authtypes.NewModuleAddress(govtypes.ModuleName).String(), - ) - - // create querier for KVStore - storeQuerier, ok := app.CommitMultiStore().(storetypes.Queryable) - if !ok { - panic(errorsmod.Wrap(sdkerrors.ErrUnknownRequest, "multistore doesn't support queries")) - } - - app.IBCFeeKeeper = ibcfeekeeper.NewKeeper( - appCodec, keys[ibcfeetypes.StoreKey], - app.IBCKeeper.ChannelKeeper, // may be replaced with IBC middleware - app.IBCKeeper.ChannelKeeper, - app.IBCKeeper.PortKeeper, app.AccountKeeper, app.BankKeeper, - ) - - zcKeeper := zckeeper.NewKeeper( - appCodec, - runtime.NewKVStoreService(keys[zctypes.StoreKey]), - app.IBCFeeKeeper, - app.IBCKeeper.ClientKeeper, - app.IBCKeeper.ChannelKeeper, - app.IBCKeeper.PortKeeper, - app.AccountKeeper, - app.BankKeeper, - &btclightclientKeeper, - &checkpointingKeeper, - &btcCheckpointKeeper, - epochingKeeper, - storeQuerier, - scopedZoneConciergeKeeper, - authtypes.NewModuleAddress(govtypes.ModuleName).String(), - ) - app.ZoneConciergeKeeper = *zcKeeper - - // Create Transfer Keepers - app.TransferKeeper = ibctransferkeeper.NewKeeper( - appCodec, - keys[ibctransfertypes.StoreKey], - app.GetSubspace(ibctransfertypes.ModuleName), - app.IBCFeeKeeper, - app.IBCKeeper.ChannelKeeper, - app.IBCKeeper.PortKeeper, - app.AccountKeeper, - app.BankKeeper, - scopedTransferKeeper, - authtypes.NewModuleAddress(govtypes.ModuleName).String(), - ) - - app.MonitorKeeper = monitorkeeper.NewKeeper( - appCodec, - runtime.NewKVStoreService(keys[monitortypes.StoreKey]), - &btclightclientKeeper, - ) - - // add msgServiceRouter so that the epoching module can forward unwrapped messages to the staking module - epochingKeeper.SetMsgServiceRouter(app.BaseApp.MsgServiceRouter()) - // make ZoneConcierge and Monitor to subscribe to the epoching's hooks - app.EpochingKeeper = *epochingKeeper.SetHooks( - epochingtypes.NewMultiEpochingHooks(app.ZoneConciergeKeeper.Hooks(), app.MonitorKeeper.Hooks()), - ) - - // set up Checkpointing, BTCCheckpoint, and BTCLightclient keepers - app.CheckpointingKeeper = *checkpointingKeeper.SetHooks( - checkpointingtypes.NewMultiCheckpointingHooks(app.EpochingKeeper.Hooks(), app.ZoneConciergeKeeper.Hooks(), app.MonitorKeeper.Hooks()), - ) - app.BtcCheckpointKeeper = btcCheckpointKeeper - app.BTCLightClientKeeper = *btclightclientKeeper.SetHooks( - btclightclienttypes.NewMultiBTCLightClientHooks(app.BtcCheckpointKeeper.Hooks()), - ) - - // set up BTC staking keeper - app.BTCStakingKeeper = btcstakingkeeper.NewKeeper( - appCodec, - runtime.NewKVStoreService(keys[btcstakingtypes.StoreKey]), - &btclightclientKeeper, - &btcCheckpointKeeper, - btcNetParams, - authtypes.NewModuleAddress(govtypes.ModuleName).String(), - ) - // set up finality keeper - app.FinalityKeeper = finalitykeeper.NewKeeper( - appCodec, - runtime.NewKVStoreService(keys[finalitytypes.StoreKey]), - app.BTCStakingKeeper, - app.IncentiveKeeper, - authtypes.NewModuleAddress(govtypes.ModuleName).String(), - ) - - // create evidence keeper with router - evidenceKeeper := evidencekeeper.NewKeeper( - appCodec, - runtime.NewKVStoreService(keys[evidencetypes.StoreKey]), - app.StakingKeeper, - app.SlashingKeeper, - app.AccountKeeper.AddressCodec(), - runtime.ProvideCometInfoService(), - ) - // If evidence needs to be handled for the app, set routes in router here and seal - app.EvidenceKeeper = *evidenceKeeper - - wasmConfig, err := wasm.ReadWasmConfig(appOpts) - if err != nil { - panic(fmt.Sprintf("error while reading wasm config: %s", err)) - } - - wasmOpts = append(owasm.RegisterCustomPlugins(&app.EpochingKeeper, &app.ZoneConciergeKeeper, &app.BTCLightClientKeeper), wasmOpts...) - - app.WasmKeeper = wasmkeeper.NewKeeper( - appCodec, - runtime.NewKVStoreService(keys[wasmtypes.StoreKey]), - app.AccountKeeper, - app.BankKeeper, - app.StakingKeeper, - distrkeeper.NewQuerier(app.DistrKeeper), - app.IBCFeeKeeper, - app.IBCKeeper.ChannelKeeper, - app.IBCKeeper.PortKeeper, - scopedWasmKeeper, - app.TransferKeeper, - app.MsgServiceRouter(), - app.GRPCQueryRouter(), - homePath, + privSigner, + appOpts, wasmConfig, - wasmCapabilities, - authtypes.NewModuleAddress(govtypes.ModuleName).String(), - wasmOpts..., + wasmOpts, + BlockedAddresses(), ) - // Set legacy router for backwards compatibility with gov v1beta1 - app.GovKeeper.SetLegacyRouter(govRouter) - - // Create all supported IBC routes - var transferStack porttypes.IBCModule - transferStack = transfer.NewIBCModule(app.TransferKeeper) - transferStack = ibcfee.NewIBCMiddleware(transferStack, app.IBCFeeKeeper) - - var zoneConciergeStack porttypes.IBCModule - zoneConciergeStack = zoneconcierge.NewIBCModule(app.ZoneConciergeKeeper) - zoneConciergeStack = ibcfee.NewIBCMiddleware(zoneConciergeStack, app.IBCFeeKeeper) - - var wasmStack porttypes.IBCModule - wasmStack = wasm.NewIBCHandler(app.WasmKeeper, app.IBCKeeper.ChannelKeeper, app.IBCFeeKeeper) - wasmStack = ibcfee.NewIBCMiddleware(wasmStack, app.IBCFeeKeeper) - - // Create static IBC router, add ibc-tranfer module route, then set and seal it - ibcRouter := porttypes.NewRouter(). - AddRoute(ibctransfertypes.ModuleName, transferStack). - AddRoute(zctypes.ModuleName, zoneConciergeStack). - AddRoute(wasmtypes.ModuleName, wasmStack) - - // Setting Router will finalize all routes by sealing router - // No more routes can be added - app.IBCKeeper.SetRouter(ibcRouter) - /**** Module Options ****/ // NOTE: we may consider parsing `appOpts` inside module constructors. For the moment @@ -794,6 +307,7 @@ func NewBabylonApp( transfer.NewAppModule(app.TransferKeeper), ibcfee.NewAppModule(app.IBCFeeKeeper), ibctm.AppModule{}, + ibcwasm.NewAppModule(app.IBCWasmKeeper), // Babylon modules - btc timestamping epoching.NewAppModule(appCodec, app.EpochingKeeper, app.AccountKeeper, app.BankKeeper, app.StakingKeeper), btclightclient.NewAppModule(appCodec, app.BTCLightClientKeeper), @@ -853,6 +367,7 @@ func NewBabylonApp( monitortypes.ModuleName, // IBC-related modules ibcexported.ModuleName, + ibcwasmtypes.ModuleName, ibctransfertypes.ModuleName, zctypes.ModuleName, ibcfeetypes.ModuleName, @@ -881,6 +396,7 @@ func NewBabylonApp( monitortypes.ModuleName, // IBC-related modules ibcexported.ModuleName, + ibcwasmtypes.ModuleName, ibctransfertypes.ModuleName, zctypes.ModuleName, ibcfeetypes.ModuleName, @@ -906,13 +422,14 @@ func NewBabylonApp( feegrant.ModuleName, paramstypes.ModuleName, upgradetypes.ModuleName, vestingtypes.ModuleName, consensusparamtypes.ModuleName, circuittypes.ModuleName, // Babylon modules - epochingtypes.ModuleName, btclightclienttypes.ModuleName, + epochingtypes.ModuleName, btccheckpointtypes.ModuleName, checkpointingtypes.ModuleName, monitortypes.ModuleName, // IBC-related modules ibcexported.ModuleName, + ibcwasmtypes.ModuleName, ibctransfertypes.ModuleName, zctypes.ModuleName, ibcfeetypes.ModuleName, @@ -931,8 +448,7 @@ func NewBabylonApp( app.ModuleManager.RegisterInvariants(app.CrisisKeeper) app.configurator = module.NewConfigurator(app.appCodec, app.MsgServiceRouter(), app.GRPCQueryRouter()) - err = app.ModuleManager.RegisterServices(app.configurator) - if err != nil { + if err := app.ModuleManager.RegisterServices(app.configurator); err != nil { panic(err) } @@ -959,9 +475,9 @@ func NewBabylonApp( app.sm.RegisterStoreDecoders() // initialize stores - app.MountKVStores(keys) - app.MountTransientStores(tkeys) - app.MountMemoryStores(memKeys) + app.MountKVStores(app.GetKVStoreKeys()) + app.MountTransientStores(app.GetTransientStoreKeys()) + app.MountMemoryStores(app.GetMemoryStoreKeys()) // initialize AnteHandler, which includes // - authAnteHandler @@ -981,7 +497,7 @@ func NewBabylonApp( }, IBCKeeper: app.IBCKeeper, WasmConfig: &wasmConfig, - TXCounterStoreService: runtime.NewKVStoreService(keys[wasmtypes.StoreKey]), + TXCounterStoreService: runtime.NewKVStoreService(app.AppKeepers.GetKey(wasmtypes.StoreKey)), WasmKeeper: &app.WasmKeeper, CircuitKeeper: &app.CircuitKeeper, }, @@ -997,8 +513,30 @@ func NewBabylonApp( NewBtcValidationDecorator(btcConfig, &app.BtcCheckpointKeeper), ) - // initialize BaseApp + // set proposal extension + proposalHandler := checkpointing.NewProposalHandler( + logger, &app.CheckpointingKeeper, bApp.Mempool(), bApp) + proposalHandler.SetHandlers(bApp) + + // set vote extension + voteExtHandler := checkpointing.NewVoteExtensionHandler(logger, &app.CheckpointingKeeper) + voteExtHandler.SetHandlers(bApp) + app.SetInitChainer(app.InitChainer) + app.SetPreBlocker(func(ctx sdk.Context, req *abci.RequestFinalizeBlock) (*sdk.ResponsePreBlock, error) { + // execute the existing PreBlocker + res, err := app.PreBlocker(ctx, req) + if err != nil { + return res, err + } + // execute checkpointing module's PreBlocker + // NOTE: this does not change the consensus parameter in `res` + ckptPreBlocker := proposalHandler.PreBlocker() + if _, err := ckptPreBlocker(ctx, req); err != nil { + return res, err + } + return res, nil + }) app.SetBeginBlocker(app.BeginBlocker) app.SetEndBlocker(app.EndBlocker) app.SetAnteHandler(anteHandler) @@ -1019,12 +557,14 @@ func NewBabylonApp( if err != nil { panic(fmt.Errorf("failed to register snapshot extension: %s", err)) } - } - app.ScopedIBCKeeper = scopedIBCKeeper - app.ScopedZoneConciergeKeeper = scopedZoneConciergeKeeper - app.ScopedTransferKeeper = scopedTransferKeeper - app.ScopedWasmKeeper = scopedWasmKeeper + err = manager.RegisterExtensions( + ibcwasmkeeper.NewWasmSnapshotter(app.CommitMultiStore(), &app.IBCWasmKeeper), + ) + if err != nil { + panic(fmt.Errorf("failed to register snapshot extension: %s", err)) + } + } // At startup, after all modules have been registered, check that all proto // annotations are correct. @@ -1039,6 +579,10 @@ func NewBabylonApp( _, _ = fmt.Fprintln(os.Stderr, err.Error()) } + // set upgrade handler and store loader for supporting software upgrade + app.setupUpgradeHandlers() + app.setupUpgradeStoreLoaders() + if loadLatest { if err := app.LoadLatestVersion(); err != nil { cmtos.Exit(err.Error()) @@ -1069,8 +613,19 @@ func (app *BabylonApp) PreBlocker(ctx sdk.Context, _ *abci.RequestFinalizeBlock) return app.ModuleManager.PreBlock(ctx) } +// BeginBlockForks is intended to be ran in a chain upgrade. +func (app *BabylonApp) BeginBlockForks(ctx sdk.Context) { + for _, fork := range Forks { + if ctx.BlockHeight() == fork.UpgradeHeight { + fork.BeginForkLogic(ctx, app.AppKeepers) + return + } + } +} + // BeginBlocker application updates every begin block func (app *BabylonApp) BeginBlocker(ctx sdk.Context) (sdk.BeginBlock, error) { + app.BeginBlockForks(ctx) return app.ModuleManager.BeginBlock(ctx) } @@ -1147,35 +702,6 @@ func (app *BabylonApp) EncodingConfig() *appparams.EncodingConfig { } } -// GetKey returns the KVStoreKey for the provided store key. -// -// NOTE: This is solely to be used for testing purposes. -func (app *BabylonApp) GetKey(storeKey string) *storetypes.KVStoreKey { - return app.keys[storeKey] -} - -// GetTKey returns the TransientStoreKey for the provided store key. -// -// NOTE: This is solely to be used for testing purposes. -func (app *BabylonApp) GetTKey(storeKey string) *storetypes.TransientStoreKey { - return app.tkeys[storeKey] -} - -// GetMemKey returns the MemStoreKey for the provided mem key. -// -// NOTE: This is solely used for testing purposes. -func (app *BabylonApp) GetMemKey(storeKey string) *storetypes.MemoryStoreKey { - return app.memKeys[storeKey] -} - -// GetSubspace returns a param subspace for a given module name. -// -// NOTE: This is solely to be used for testing purposes. -func (app *BabylonApp) GetSubspace(moduleName string) paramstypes.Subspace { - subspace, _ := app.ParamsKeeper.GetSubspace(moduleName) - return subspace -} - // SimulationManager implements the SimulationApp interface func (app *BabylonApp) SimulationManager() *module.SimulationManager { return app.sm @@ -1252,6 +778,39 @@ func (app *BabylonApp) AutoCliOpts() autocli.AppOptions { } } +// configure store loader that checks if version == upgradeHeight and applies store upgrades +func (app *BabylonApp) setupUpgradeStoreLoaders() { + upgradeInfo, err := app.UpgradeKeeper.ReadUpgradeInfoFromDisk() + if err != nil { + panic(fmt.Sprintf("failed to read upgrade info from disk %s", err)) + } + + if app.UpgradeKeeper.IsSkipHeight(upgradeInfo.Height) { + return + } + + for _, upgrade := range Upgrades { + if upgradeInfo.Name == upgrade.UpgradeName { + storeUpgrades := upgrade.StoreUpgrades + app.SetStoreLoader(upgradetypes.UpgradeStoreLoader(upgradeInfo.Height, &storeUpgrades)) + } + } +} + +func (app *BabylonApp) setupUpgradeHandlers() { + for _, upgrade := range Upgrades { + app.UpgradeKeeper.SetUpgradeHandler( + upgrade.UpgradeName, + upgrade.CreateUpgradeHandler( + app.ModuleManager, + app.configurator, + app.BaseApp, + app.AppKeepers, + ), + ) + } +} + // GetMaccPerms returns a copy of the module account permissions func GetMaccPerms() map[string][]string { dupMaccPerms := make(map[string][]string) @@ -1273,17 +832,3 @@ func BlockedAddresses() map[string]bool { return modAccAddrs } - -// initParamsKeeper init params keeper and its subspaces -func initParamsKeeper(appCodec codec.BinaryCodec, legacyAmino *codec.LegacyAmino, key, tkey storetypes.StoreKey) paramskeeper.Keeper { - paramsKeeper := paramskeeper.NewKeeper(appCodec, legacyAmino, key, tkey) - - // TODO: Only modules which did not migrate yet to new way of hanldling params - // are the IBC-related modules. Once they are migrated, we can remove this and - // whole usage of params module - paramsKeeper.Subspace(ibcexported.ModuleName) - paramsKeeper.Subspace(ibctransfertypes.ModuleName) - paramsKeeper.Subspace(zctypes.ModuleName) - - return paramsKeeper -} diff --git a/app/app_test.go b/app/app_test.go index 4e2ac57d0..47599538d 100644 --- a/app/app_test.go +++ b/app/app_test.go @@ -4,9 +4,8 @@ import ( "fmt" "testing" - abci "github.com/cometbft/cometbft/abci/types" - "cosmossdk.io/log" + abci "github.com/cometbft/cometbft/abci/types" dbm "github.com/cosmos/cosmos-db" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/module" @@ -23,7 +22,7 @@ func TestBabylonBlockedAddrs(t *testing.T) { DB: db, InvCheckPeriod: 0, SkipUpgradeHeights: map[int64]bool{}, - AppOpts: EmptyAppOptions{}, + AppOpts: TmpAppOptions(), }) for acc := range BlockedAddresses() { @@ -58,7 +57,7 @@ func TestBabylonBlockedAddrs(t *testing.T) { map[int64]bool{}, 0, signer, - EmptyAppOptions{}, + TmpAppOptions(), EmptyWasmOpts, ) _, err = app2.ExportAppStateAndValidators(false, []string{}, []string{}) @@ -81,7 +80,7 @@ func TestUpgradeStateOnGenesis(t *testing.T) { DB: db, InvCheckPeriod: 0, SkipUpgradeHeights: map[int64]bool{}, - AppOpts: EmptyAppOptions{}, + AppOpts: TmpAppOptions(), }) // make sure the upgrade keeper has version map in state diff --git a/app/encoding.go b/app/encoding.go index 8aa2a472f..57a5b6cf5 100644 --- a/app/encoding.go +++ b/app/encoding.go @@ -1,13 +1,31 @@ package app import ( + "os" + "cosmossdk.io/log" wasmkeeper "github.com/CosmWasm/wasmd/x/wasm/keeper" dbm "github.com/cosmos/cosmos-db" + "github.com/cosmos/cosmos-sdk/client/flags" + simsutils "github.com/cosmos/cosmos-sdk/testutil/sims" - appparams "github.com/babylonchain/babylon/app/params" + appparams "github.com/babylonlabs-io/babylon/app/params" + bbn "github.com/babylonlabs-io/babylon/types" ) +// TmpAppOptions returns an app option with tmp dir and btc network +func TmpAppOptions() simsutils.AppOptionsMap { + dir, err := os.MkdirTemp("", "babylon-tmp-app") + if err != nil { + panic(err) + } + appOpts := simsutils.AppOptionsMap{ + flags.FlagHome: dir, + "btc-config.network": string(bbn.BtcSimnet), + } + return appOpts +} + func NewTmpBabylonApp() *BabylonApp { signer, _ := SetupTestPrivSigner() return NewBabylonApp( @@ -18,7 +36,7 @@ func NewTmpBabylonApp() *BabylonApp { map[int64]bool{}, 0, signer, - EmptyAppOptions{}, + TmpAppOptions(), []wasmkeeper.Option{}) } diff --git a/app/export.go b/app/export.go index 105c96987..a83de8d0e 100644 --- a/app/export.go +++ b/app/export.go @@ -203,7 +203,7 @@ func (app *BabylonApp) prepForZeroHeightGenesis(ctx sdk.Context, jailAllowedAddr // Iterate through validators by power descending, reset bond heights, and // update bond intra-tx counters. - store := ctx.KVStore(app.keys[stakingtypes.StoreKey]) + store := ctx.KVStore(app.GetKey(stakingtypes.StoreKey)) iter := storetypes.KVStoreReversePrefixIterator(store, stakingtypes.ValidatorsKey) for ; iter.Valid(); iter.Next() { diff --git a/app/genesis.go b/app/genesis.go index ae974c8e6..107cc0126 100644 --- a/app/genesis.go +++ b/app/genesis.go @@ -1,10 +1,7 @@ package app import ( - "cosmossdk.io/log" "encoding/json" - wasmkeeper "github.com/CosmWasm/wasmd/x/wasm/keeper" - dbm "github.com/cosmos/cosmos-db" "testing" ) @@ -22,15 +19,6 @@ func NewDefaultGenesisState(t *testing.T) GenesisState { t.Helper() // we "pre"-instantiate the application for getting the injected/configured encoding configuration // note, this is not necessary when using app wiring, as depinject can be directly used (see root_v2.go) - tempApp := NewBabylonApp( - log.NewNopLogger(), - dbm.NewMemDB(), - nil, - true, - map[int64]bool{}, - 0, - nil, - EmptyAppOptions{}, - []wasmkeeper.Option{}) + tempApp := NewTmpBabylonApp() return tempApp.DefaultGenesis() } diff --git a/app/keepers/keepers.go b/app/keepers/keepers.go new file mode 100644 index 000000000..74174a608 --- /dev/null +++ b/app/keepers/keepers.go @@ -0,0 +1,633 @@ +package keepers + +import ( + "path/filepath" + + errorsmod "cosmossdk.io/errors" + "cosmossdk.io/log" + storetypes "cosmossdk.io/store/types" + circuitkeeper "cosmossdk.io/x/circuit/keeper" + circuittypes "cosmossdk.io/x/circuit/types" + evidencekeeper "cosmossdk.io/x/evidence/keeper" + evidencetypes "cosmossdk.io/x/evidence/types" + "cosmossdk.io/x/feegrant" + feegrantkeeper "cosmossdk.io/x/feegrant/keeper" + upgradekeeper "cosmossdk.io/x/upgrade/keeper" + upgradetypes "cosmossdk.io/x/upgrade/types" + "github.com/CosmWasm/wasmd/x/wasm" + wasmkeeper "github.com/CosmWasm/wasmd/x/wasm/keeper" + wasmtypes "github.com/CosmWasm/wasmd/x/wasm/types" + "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" + authzkeeper "github.com/cosmos/cosmos-sdk/x/authz/keeper" + bankkeeper "github.com/cosmos/cosmos-sdk/x/bank/keeper" + banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" + consensusparamkeeper "github.com/cosmos/cosmos-sdk/x/consensus/keeper" + consensusparamtypes "github.com/cosmos/cosmos-sdk/x/consensus/types" + crisiskeeper "github.com/cosmos/cosmos-sdk/x/crisis/keeper" + crisistypes "github.com/cosmos/cosmos-sdk/x/crisis/types" + distrkeeper "github.com/cosmos/cosmos-sdk/x/distribution/keeper" + distrtypes "github.com/cosmos/cosmos-sdk/x/distribution/types" + 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" + paramproposal "github.com/cosmos/cosmos-sdk/x/params/types/proposal" + slashingkeeper "github.com/cosmos/cosmos-sdk/x/slashing/keeper" + slashingtypes "github.com/cosmos/cosmos-sdk/x/slashing/types" + stakingkeeper "github.com/cosmos/cosmos-sdk/x/staking/keeper" + stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" + capabilitykeeper "github.com/cosmos/ibc-go/modules/capability/keeper" + capabilitytypes "github.com/cosmos/ibc-go/modules/capability/types" + ibcwasmkeeper "github.com/cosmos/ibc-go/modules/light-clients/08-wasm/keeper" + ibcwasmtypes "github.com/cosmos/ibc-go/modules/light-clients/08-wasm/types" + ibcfee "github.com/cosmos/ibc-go/v8/modules/apps/29-fee" + ibcfeekeeper "github.com/cosmos/ibc-go/v8/modules/apps/29-fee/keeper" + ibcfeetypes "github.com/cosmos/ibc-go/v8/modules/apps/29-fee/types" + "github.com/cosmos/ibc-go/v8/modules/apps/transfer" + ibctransferkeeper "github.com/cosmos/ibc-go/v8/modules/apps/transfer/keeper" + ibctransfertypes "github.com/cosmos/ibc-go/v8/modules/apps/transfer/types" + porttypes "github.com/cosmos/ibc-go/v8/modules/core/05-port/types" // ibc module puts types under `ibchost` rather than `ibctypes` + ibcexported "github.com/cosmos/ibc-go/v8/modules/core/exported" + ibckeeper "github.com/cosmos/ibc-go/v8/modules/core/keeper" + + appparams "github.com/babylonlabs-io/babylon/app/params" + bbn "github.com/babylonlabs-io/babylon/types" + owasm "github.com/babylonlabs-io/babylon/wasmbinding" + btccheckpointkeeper "github.com/babylonlabs-io/babylon/x/btccheckpoint/keeper" + btccheckpointtypes "github.com/babylonlabs-io/babylon/x/btccheckpoint/types" + btclightclientkeeper "github.com/babylonlabs-io/babylon/x/btclightclient/keeper" + btclightclienttypes "github.com/babylonlabs-io/babylon/x/btclightclient/types" + btcstakingkeeper "github.com/babylonlabs-io/babylon/x/btcstaking/keeper" + btcstakingtypes "github.com/babylonlabs-io/babylon/x/btcstaking/types" + checkpointingkeeper "github.com/babylonlabs-io/babylon/x/checkpointing/keeper" + checkpointingtypes "github.com/babylonlabs-io/babylon/x/checkpointing/types" + epochingkeeper "github.com/babylonlabs-io/babylon/x/epoching/keeper" + epochingtypes "github.com/babylonlabs-io/babylon/x/epoching/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" + 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" +) + +// Capabilities of the IBC wasm contracts +func WasmCapabilities() []string { + // The last arguments can contain custom message handlers, and custom query handlers, + // if we want to allow any custom callbacks + return []string{ + "iterator", + "staking", + "stargate", + "cosmwasm_1_1", + "cosmwasm_1_2", + "cosmwasm_1_3", + "cosmwasm_1_4", + "cosmwasm_2_0", + "babylon", + } +} + +type AppKeepers struct { + // keepers + AccountKeeper authkeeper.AccountKeeper + BankKeeper bankkeeper.Keeper + CapabilityKeeper *capabilitykeeper.Keeper + StakingKeeper *stakingkeeper.Keeper + SlashingKeeper slashingkeeper.Keeper + MintKeeper mintkeeper.Keeper + DistrKeeper distrkeeper.Keeper + GovKeeper govkeeper.Keeper + CrisisKeeper *crisiskeeper.Keeper + UpgradeKeeper *upgradekeeper.Keeper + ParamsKeeper paramskeeper.Keeper + AuthzKeeper authzkeeper.Keeper + EvidenceKeeper evidencekeeper.Keeper + FeeGrantKeeper feegrantkeeper.Keeper + ConsensusParamsKeeper consensusparamkeeper.Keeper + CircuitKeeper circuitkeeper.Keeper + + // Babylon modules + EpochingKeeper epochingkeeper.Keeper + BTCLightClientKeeper btclightclientkeeper.Keeper + BtcCheckpointKeeper btccheckpointkeeper.Keeper + CheckpointingKeeper checkpointingkeeper.Keeper + MonitorKeeper monitorkeeper.Keeper + + // IBC-related modules + IBCKeeper *ibckeeper.Keeper // IBC Keeper must be a pointer in the app, so we can SetRouter on it correctly + IBCFeeKeeper ibcfeekeeper.Keeper // for relayer incentivization - https://github.com/cosmos/ibc/tree/main/spec/app/ics-029-fee-payment + TransferKeeper ibctransferkeeper.Keeper // for cross-chain fungible token transfers + IBCWasmKeeper ibcwasmkeeper.Keeper // for IBC wasm light clients + ZoneConciergeKeeper zckeeper.Keeper // for cross-chain fungible token transfers + + // BTC staking related modules + BTCStakingKeeper btcstakingkeeper.Keeper + FinalityKeeper finalitykeeper.Keeper + + // wasm smart contract module + WasmKeeper wasmkeeper.Keeper + + // tokenomics-related modules + IncentiveKeeper incentivekeeper.Keeper + + // make scoped keepers public for test purposes + ScopedIBCKeeper capabilitykeeper.ScopedKeeper + ScopedTransferKeeper capabilitykeeper.ScopedKeeper + ScopedZoneConciergeKeeper capabilitykeeper.ScopedKeeper + ScopedWasmKeeper capabilitykeeper.ScopedKeeper + + // keys to access the substores + keys map[string]*storetypes.KVStoreKey + tkeys map[string]*storetypes.TransientStoreKey + memKeys map[string]*storetypes.MemoryStoreKey +} + +func (ak *AppKeepers) InitKeepers( + logger log.Logger, + appCodec codec.Codec, + btcConfig *bbn.BtcConfig, + encodingConfig *appparams.EncodingConfig, + bApp *baseapp.BaseApp, + maccPerms map[string][]string, + homePath string, + invCheckPeriod uint, + skipUpgradeHeights map[int64]bool, + privSigner *PrivSigner, + appOpts servertypes.AppOptions, + wasmConfig wasmtypes.WasmConfig, + wasmOpts []wasmkeeper.Option, + blockedAddress map[string]bool, +) { + powLimit := btcConfig.PowLimit() + btcNetParams := btcConfig.NetParams() + + // set persistent store keys + keys := storetypes.NewKVStoreKeys( + authtypes.StoreKey, banktypes.StoreKey, stakingtypes.StoreKey, crisistypes.StoreKey, + minttypes.StoreKey, distrtypes.StoreKey, slashingtypes.StoreKey, + govtypes.StoreKey, paramstypes.StoreKey, consensusparamtypes.StoreKey, upgradetypes.StoreKey, feegrant.StoreKey, + evidencetypes.StoreKey, circuittypes.StoreKey, capabilitytypes.StoreKey, + authzkeeper.StoreKey, + // Babylon modules + epochingtypes.StoreKey, + btclightclienttypes.StoreKey, + btccheckpointtypes.StoreKey, + checkpointingtypes.StoreKey, + monitortypes.StoreKey, + // IBC-related modules + ibcexported.StoreKey, + ibctransfertypes.StoreKey, + ibcfeetypes.StoreKey, + ibcwasmtypes.StoreKey, + zctypes.StoreKey, + // BTC staking related modules + btcstakingtypes.StoreKey, + finalitytypes.StoreKey, + // WASM + wasmtypes.StoreKey, + // tokenomics-related modules + incentivetypes.StoreKey, + ) + ak.keys = keys + + // set transient store keys + ak.tkeys = storetypes.NewTransientStoreKeys(paramstypes.TStoreKey, btccheckpointtypes.TStoreKey) + + // set memory store keys + // NOTE: The testingkey is just mounted for testing purposes. Actual applications should + // not include this key. + ak.memKeys = storetypes.NewMemoryStoreKeys(capabilitytypes.MemStoreKey, "testingkey") + + accountKeeper := authkeeper.NewAccountKeeper( + appCodec, + runtime.NewKVStoreService(keys[authtypes.StoreKey]), + authtypes.ProtoBaseAccount, + maccPerms, + authcodec.NewBech32Codec(appparams.Bech32PrefixAccAddr), + appparams.Bech32PrefixAccAddr, + authtypes.NewModuleAddress(govtypes.ModuleName).String(), + ) + + bankKeeper := bankkeeper.NewBaseKeeper( + appCodec, + runtime.NewKVStoreService(keys[banktypes.StoreKey]), + accountKeeper, + blockedAddress, + authtypes.NewModuleAddress(govtypes.ModuleName).String(), + logger, + ) + + stakingKeeper := stakingkeeper.NewKeeper( + appCodec, + runtime.NewKVStoreService(keys[stakingtypes.StoreKey]), + accountKeeper, + bankKeeper, + authtypes.NewModuleAddress(govtypes.ModuleName).String(), + authcodec.NewBech32Codec(appparams.Bech32PrefixValAddr), + authcodec.NewBech32Codec(appparams.Bech32PrefixConsAddr), + ) + + // NOTE: the epoching module has to be set before the chekpointing module, as the checkpointing module will have access to the epoching module + epochingKeeper := epochingkeeper.NewKeeper( + appCodec, + runtime.NewKVStoreService(keys[epochingtypes.StoreKey]), + bankKeeper, + stakingKeeper, + authtypes.NewModuleAddress(govtypes.ModuleName).String(), + ) + + checkpointingKeeper := checkpointingkeeper.NewKeeper( + appCodec, + runtime.NewKVStoreService(keys[checkpointingtypes.StoreKey]), + privSigner.WrappedPV, + epochingKeeper, + ) + + // register streaming services + if err := bApp.RegisterStreamingServices(appOpts, keys); err != nil { + panic(err) + } + + ak.ParamsKeeper = initParamsKeeper( + appCodec, + encodingConfig.Amino, + keys[paramstypes.StoreKey], + ak.tkeys[paramstypes.TStoreKey], + ) + + ak.ConsensusParamsKeeper = consensusparamkeeper.NewKeeper( + appCodec, + runtime.NewKVStoreService(keys[consensusparamtypes.StoreKey]), + authtypes.NewModuleAddress(govtypes.ModuleName).String(), + runtime.EventService{}, + ) + bApp.SetParamStore(ak.ConsensusParamsKeeper.ParamsStore) + + ak.CapabilityKeeper = capabilitykeeper.NewKeeper( + appCodec, + keys[capabilitytypes.StoreKey], + ak.memKeys[capabilitytypes.MemStoreKey], + ) + + // grant capabilities for the ibc and ibc-transfer modules + scopedIBCKeeper := ak.CapabilityKeeper.ScopeToModule(ibcexported.ModuleName) + scopedTransferKeeper := ak.CapabilityKeeper.ScopeToModule(ibctransfertypes.ModuleName) + scopedZoneConciergeKeeper := ak.CapabilityKeeper.ScopeToModule(zctypes.ModuleName) + scopedWasmKeeper := ak.CapabilityKeeper.ScopeToModule(wasmtypes.ModuleName) + + // Applications that wish to enforce statically created ScopedKeepers should call `Seal` after creating + // their scoped modules in `NewApp` with `ScopeToModule` + ak.CapabilityKeeper.Seal() + + // add keepers + ak.AccountKeeper = accountKeeper + + ak.BankKeeper = bankKeeper + + ak.StakingKeeper = stakingKeeper + + ak.CircuitKeeper = circuitkeeper.NewKeeper( + appCodec, + runtime.NewKVStoreService(keys[circuittypes.StoreKey]), + authtypes.NewModuleAddress(govtypes.ModuleName).String(), + ak.AccountKeeper.AddressCodec(), + ) + bApp.SetCircuitBreaker(&ak.CircuitKeeper) + + ak.MintKeeper = mintkeeper.NewKeeper( + appCodec, + runtime.NewKVStoreService(keys[minttypes.StoreKey]), + ak.StakingKeeper, + ak.AccountKeeper, + ak.BankKeeper, + authtypes.FeeCollectorName, + authtypes.NewModuleAddress(govtypes.ModuleName).String(), + ) + + ak.DistrKeeper = distrkeeper.NewKeeper( + appCodec, + runtime.NewKVStoreService(keys[distrtypes.StoreKey]), + ak.AccountKeeper, + ak.BankKeeper, + ak.StakingKeeper, + authtypes.FeeCollectorName, + authtypes.NewModuleAddress(govtypes.ModuleName).String(), + ) + + // set up incentive keeper + ak.IncentiveKeeper = incentivekeeper.NewKeeper( + appCodec, + runtime.NewKVStoreService(keys[incentivetypes.StoreKey]), + ak.BankKeeper, + ak.AccountKeeper, + &epochingKeeper, + authtypes.NewModuleAddress(govtypes.ModuleName).String(), + authtypes.FeeCollectorName, + ) + + ak.SlashingKeeper = slashingkeeper.NewKeeper( + appCodec, + encodingConfig.Amino, + runtime.NewKVStoreService(keys[slashingtypes.StoreKey]), + ak.StakingKeeper, + authtypes.NewModuleAddress(govtypes.ModuleName).String(), + ) + + ak.CrisisKeeper = crisiskeeper.NewKeeper( + appCodec, + runtime.NewKVStoreService(keys[crisistypes.StoreKey]), + invCheckPeriod, + ak.BankKeeper, + authtypes.FeeCollectorName, + authtypes.NewModuleAddress(govtypes.ModuleName).String(), + ak.AccountKeeper.AddressCodec(), + ) + + ak.FeeGrantKeeper = feegrantkeeper.NewKeeper( + appCodec, + runtime.NewKVStoreService(keys[feegrant.StoreKey]), + ak.AccountKeeper, + ) + // register the staking hooks + // NOTE: stakingKeeper above is passed by reference, so that it will contain these hooks + ak.StakingKeeper.SetHooks( + stakingtypes.NewMultiStakingHooks(ak.DistrKeeper.Hooks(), ak.SlashingKeeper.Hooks(), epochingKeeper.Hooks()), + ) + + // set the governance module account as the authority for conducting upgrades + ak.UpgradeKeeper = upgradekeeper.NewKeeper( + skipUpgradeHeights, + runtime.NewKVStoreService(keys[upgradetypes.StoreKey]), + appCodec, + homePath, + bApp, + authtypes.NewModuleAddress(govtypes.ModuleName).String(), + ) + + ak.AuthzKeeper = authzkeeper.NewKeeper( + runtime.NewKVStoreService(keys[authzkeeper.StoreKey]), + appCodec, + bApp.MsgServiceRouter(), + ak.AccountKeeper, + ) + + ak.IBCKeeper = ibckeeper.NewKeeper( + appCodec, + keys[ibcexported.StoreKey], + ak.GetSubspace(ibcexported.ModuleName), + ak.StakingKeeper, + ak.UpgradeKeeper, + scopedIBCKeeper, + // From 8.0.0 the IBC keeper requires an authority for the messages + // `MsgIBCSoftwareUpgrade` and `MsgRecoverClient` + // https://github.com/cosmos/ibc-go/releases/tag/v8.0.0 + // Gov is the proper authority for those types of messages + authtypes.NewModuleAddress(govtypes.ModuleName).String(), + ) + + // register the proposal types + // Deprecated: Avoid adding new handlers, instead use the new proposal flow + // by granting the governance module the right to execute the message. + // See: https://github.com/cosmos/cosmos-sdk/blob/release/v0.46.x/x/gov/spec/01_concepts.md#proposal-messages + // TODO: investigate how to migrate to new proposal flow + govRouter := govv1beta1.NewRouter() + govRouter.AddRoute(govtypes.RouterKey, govv1beta1.ProposalHandler). + AddRoute(paramproposal.RouterKey, params.NewParamChangeProposalHandler(ak.ParamsKeeper)) + + // TODO: this should be a function parameter + govConfig := govtypes.DefaultConfig() + /* + Example of setting gov params: + govConfig.MaxMetadataLen = 10000 + */ + govKeeper := govkeeper.NewKeeper( + appCodec, + runtime.NewKVStoreService(keys[govtypes.StoreKey]), + ak.AccountKeeper, + ak.BankKeeper, + ak.StakingKeeper, + ak.DistrKeeper, + bApp.MsgServiceRouter(), + govConfig, + authtypes.NewModuleAddress(govtypes.ModuleName).String()) + + ak.GovKeeper = *govKeeper.SetHooks( + govtypes.NewMultiGovHooks( + // register the governance hooks + ), + ) + + btclightclientKeeper := btclightclientkeeper.NewKeeper( + appCodec, + runtime.NewKVStoreService(keys[btclightclienttypes.StoreKey]), + *btcConfig, + authtypes.NewModuleAddress(govtypes.ModuleName).String(), + ) + + btcCheckpointKeeper := btccheckpointkeeper.NewKeeper( + appCodec, + runtime.NewKVStoreService(keys[btccheckpointtypes.StoreKey]), + ak.tkeys[btccheckpointtypes.TStoreKey], + &btclightclientKeeper, + &checkpointingKeeper, + &ak.IncentiveKeeper, + &powLimit, + 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 + ak.IBCKeeper.ChannelKeeper, + ak.IBCKeeper.PortKeeper, ak.AccountKeeper, ak.BankKeeper, + ) + + zcKeeper := zckeeper.NewKeeper( + appCodec, + runtime.NewKVStoreService(keys[zctypes.StoreKey]), + ak.IBCFeeKeeper, + ak.IBCKeeper.ClientKeeper, + ak.IBCKeeper.ChannelKeeper, + ak.IBCKeeper.PortKeeper, + ak.AccountKeeper, + ak.BankKeeper, + &btclightclientKeeper, + &checkpointingKeeper, + &btcCheckpointKeeper, + epochingKeeper, + storeQuerier, + scopedZoneConciergeKeeper, + authtypes.NewModuleAddress(govtypes.ModuleName).String(), + ) + ak.ZoneConciergeKeeper = *zcKeeper + + // Create Transfer Keepers + ak.TransferKeeper = ibctransferkeeper.NewKeeper( + appCodec, + keys[ibctransfertypes.StoreKey], + ak.GetSubspace(ibctransfertypes.ModuleName), + ak.IBCFeeKeeper, + ak.IBCKeeper.ChannelKeeper, + ak.IBCKeeper.PortKeeper, + ak.AccountKeeper, + ak.BankKeeper, + scopedTransferKeeper, + authtypes.NewModuleAddress(govtypes.ModuleName).String(), + ) + + ak.MonitorKeeper = monitorkeeper.NewKeeper( + appCodec, + runtime.NewKVStoreService(keys[monitortypes.StoreKey]), + &btclightclientKeeper, + ) + + // add msgServiceRouter so that the epoching module can forward unwrapped messages to the staking module + epochingKeeper.SetMsgServiceRouter(bApp.MsgServiceRouter()) + // make ZoneConcierge and Monitor to subscribe to the epoching's hooks + ak.EpochingKeeper = *epochingKeeper.SetHooks( + epochingtypes.NewMultiEpochingHooks(ak.ZoneConciergeKeeper.Hooks(), ak.MonitorKeeper.Hooks()), + ) + + // set up Checkpointing, BTCCheckpoint, and BTCLightclient keepers + ak.CheckpointingKeeper = *checkpointingKeeper.SetHooks( + checkpointingtypes.NewMultiCheckpointingHooks(ak.EpochingKeeper.Hooks(), ak.ZoneConciergeKeeper.Hooks(), ak.MonitorKeeper.Hooks()), + ) + ak.BtcCheckpointKeeper = btcCheckpointKeeper + ak.BTCLightClientKeeper = *btclightclientKeeper.SetHooks( + btclightclienttypes.NewMultiBTCLightClientHooks(ak.BtcCheckpointKeeper.Hooks()), + ) + + // set up BTC staking keeper + ak.BTCStakingKeeper = btcstakingkeeper.NewKeeper( + appCodec, + runtime.NewKVStoreService(keys[btcstakingtypes.StoreKey]), + &btclightclientKeeper, + &btcCheckpointKeeper, + &checkpointingKeeper, + btcNetParams, + authtypes.NewModuleAddress(govtypes.ModuleName).String(), + ) + + // set up finality keeper + ak.FinalityKeeper = finalitykeeper.NewKeeper( + appCodec, + runtime.NewKVStoreService(keys[finalitytypes.StoreKey]), + ak.BTCStakingKeeper, + ak.IncentiveKeeper, + authtypes.NewModuleAddress(govtypes.ModuleName).String(), + ) + ak.BTCStakingKeeper = *ak.BTCStakingKeeper.SetHooks(btcstakingtypes.NewMultiBtcStakingHooks(ak.FinalityKeeper.Hooks())) + ak.FinalityKeeper = *ak.FinalityKeeper.SetHooks(finalitytypes.NewMultiFinalityHooks(ak.BTCStakingKeeper.Hooks())) + + // create evidence keeper with router + evidenceKeeper := evidencekeeper.NewKeeper( + appCodec, + runtime.NewKVStoreService(keys[evidencetypes.StoreKey]), + ak.StakingKeeper, + ak.SlashingKeeper, + ak.AccountKeeper.AddressCodec(), + runtime.ProvideCometInfoService(), + ) + // 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...) + + ak.WasmKeeper = wasmkeeper.NewKeeper( + appCodec, + runtime.NewKVStoreService(keys[wasmtypes.StoreKey]), + ak.AccountKeeper, + ak.BankKeeper, + ak.StakingKeeper, + distrkeeper.NewQuerier(ak.DistrKeeper), + ak.IBCFeeKeeper, + ak.IBCKeeper.ChannelKeeper, + ak.IBCKeeper.PortKeeper, + scopedWasmKeeper, + ak.TransferKeeper, + bApp.MsgServiceRouter(), + bApp.GRPCQueryRouter(), + homePath, + wasmConfig, + WasmCapabilities(), + authtypes.NewModuleAddress(govtypes.ModuleName).String(), + wasmOpts..., + ) + + ibcWasmConfig := + ibcwasmtypes.WasmConfig{ + DataDir: filepath.Join(homePath, "ibc_08-wasm"), + SupportedCapabilities: WasmCapabilities(), + ContractDebugMode: false, + } + + ak.IBCWasmKeeper = ibcwasmkeeper.NewKeeperWithConfig( + appCodec, + runtime.NewKVStoreService(keys[ibcwasmtypes.StoreKey]), + ak.IBCKeeper.ClientKeeper, + authtypes.NewModuleAddress(govtypes.ModuleName).String(), + ibcWasmConfig, + bApp.GRPCQueryRouter(), + ) + + // Set legacy router for backwards compatibility with gov v1beta1 + ak.GovKeeper.SetLegacyRouter(govRouter) + + // Create all supported IBC routes + var transferStack porttypes.IBCModule + transferStack = transfer.NewIBCModule(ak.TransferKeeper) + transferStack = ibcfee.NewIBCMiddleware(transferStack, ak.IBCFeeKeeper) + + var zoneConciergeStack porttypes.IBCModule + zoneConciergeStack = zoneconcierge.NewIBCModule(ak.ZoneConciergeKeeper) + zoneConciergeStack = ibcfee.NewIBCMiddleware(zoneConciergeStack, ak.IBCFeeKeeper) + + var wasmStack porttypes.IBCModule + wasmStack = wasm.NewIBCHandler(ak.WasmKeeper, ak.IBCKeeper.ChannelKeeper, ak.IBCFeeKeeper) + wasmStack = ibcfee.NewIBCMiddleware(wasmStack, ak.IBCFeeKeeper) + + // Create static IBC router, add ibc-transfer module route, then set and seal it + ibcRouter := porttypes.NewRouter(). + AddRoute(ibctransfertypes.ModuleName, transferStack). + AddRoute(zctypes.ModuleName, zoneConciergeStack). + AddRoute(wasmtypes.ModuleName, wasmStack) + + // Setting Router will finalize all routes by sealing router + // No more routes can be added + ak.IBCKeeper.SetRouter(ibcRouter) +} + +// initParamsKeeper init params keeper and its subspaces +func initParamsKeeper(appCodec codec.BinaryCodec, legacyAmino *codec.LegacyAmino, key, tkey storetypes.StoreKey) paramskeeper.Keeper { + paramsKeeper := paramskeeper.NewKeeper(appCodec, legacyAmino, key, tkey) + + // TODO: Only modules which did not migrate yet to new way of hanldling params + // are the IBC-related modules. Once they are migrated, we can remove this and + // whole usage of params module + paramsKeeper.Subspace(ibcexported.ModuleName) + paramsKeeper.Subspace(ibctransfertypes.ModuleName) + paramsKeeper.Subspace(zctypes.ModuleName) + + return paramsKeeper +} diff --git a/app/keepers/keys.go b/app/keepers/keys.go new file mode 100644 index 000000000..c01bf564c --- /dev/null +++ b/app/keepers/keys.go @@ -0,0 +1,48 @@ +package keepers + +import ( + storetypes "cosmossdk.io/store/types" + paramstypes "github.com/cosmos/cosmos-sdk/x/params/types" +) + +// GetSubspace gets existing substore from keeper. +func (appKeepers *AppKeepers) GetSubspace(moduleName string) paramstypes.Subspace { + subspace, _ := appKeepers.ParamsKeeper.GetSubspace(moduleName) + return subspace +} + +// GetKVStoreKey gets KV Store keys. +func (appKeepers *AppKeepers) GetKVStoreKeys() map[string]*storetypes.KVStoreKey { + return appKeepers.keys +} + +// GetTransientStoreKey gets Transient Store keys. +func (appKeepers *AppKeepers) GetTransientStoreKeys() map[string]*storetypes.TransientStoreKey { + return appKeepers.tkeys +} + +// GetMemoryStoreKey get memory Store keys. +func (appKeepers *AppKeepers) GetMemoryStoreKeys() map[string]*storetypes.MemoryStoreKey { + return appKeepers.memKeys +} + +// GetKey returns the KVStoreKey for the provided store key. +// +// NOTE: This is solely to be used for testing purposes. +func (appKeepers *AppKeepers) GetKey(storeKey string) *storetypes.KVStoreKey { + return appKeepers.keys[storeKey] +} + +// GetTKey returns the TransientStoreKey for the provided store key. +// +// NOTE: This is solely to be used for testing purposes. +func (appKeepers *AppKeepers) GetTKey(storeKey string) *storetypes.TransientStoreKey { + return appKeepers.tkeys[storeKey] +} + +// GetMemKey returns the MemStoreKey for the provided mem key. +// +// NOTE: This is solely used for testing purposes. +func (appKeepers *AppKeepers) GetMemKey(storeKey string) *storetypes.MemoryStoreKey { + return appKeepers.memKeys[storeKey] +} diff --git a/app/utils.go b/app/keepers/utils.go similarity index 96% rename from app/utils.go rename to app/keepers/utils.go index 8869582bf..7efe4b78a 100644 --- a/app/utils.go +++ b/app/keepers/utils.go @@ -1,4 +1,4 @@ -package app +package keepers import ( "bytes" @@ -11,7 +11,7 @@ import ( cmtos "github.com/cometbft/cometbft/libs/os" "github.com/cosmos/cosmos-sdk/client/config" - "github.com/babylonchain/babylon/privval" + "github.com/babylonlabs-io/babylon/privval" ) const defaultConfigTemplate = `# This is a TOML config file. @@ -89,7 +89,7 @@ func saveClientConfig(homePath string, cliConf *config.ClientConfig) error { // ensureConfigPath creates a directory configPath if it does not exist func ensureConfigPath(configPath string) error { - return os.MkdirAll(configPath, os.ModePerm) + return os.MkdirAll(filepath.Clean(configPath), 0750) } func writeConfigToFile(configFilePath string, config *config.ClientConfig) error { diff --git a/app/modules.go b/app/modules.go index b6482870c..8c2039250 100644 --- a/app/modules.go +++ b/app/modules.go @@ -1,27 +1,45 @@ package app import ( + "github.com/CosmWasm/wasmd/x/wasm/ibctesting" + wasmkeeper "github.com/CosmWasm/wasmd/x/wasm/keeper" "github.com/cosmos/cosmos-sdk/client" + authkeeper "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" capabilitykeeper "github.com/cosmos/ibc-go/modules/capability/keeper" ibckeeper "github.com/cosmos/ibc-go/v8/modules/core/keeper" - ibctestingtypes "github.com/cosmos/ibc-go/v8/testing/types" ) +var _ ibctesting.ChainApp = &BabylonApp{} + // The following functions are required by ibctesting // (copied from https://github.com/osmosis-labs/osmosis/blob/main/app/modules.go) -func (app *BabylonApp) GetStakingKeeper() ibctestingtypes.StakingKeeper { - return app.StakingKeeper -} - func (app *BabylonApp) GetIBCKeeper() *ibckeeper.Keeper { - return app.IBCKeeper // This is a *ibckeeper.Keeper + return app.IBCKeeper } func (app *BabylonApp) GetScopedIBCKeeper() capabilitykeeper.ScopedKeeper { return app.ScopedIBCKeeper } +func (app *BabylonApp) GetBankKeeper() bankkeeper.Keeper { + return app.BankKeeper +} + +func (app *BabylonApp) GetStakingKeeper() *stakingkeeper.Keeper { + return app.StakingKeeper +} + +func (app *BabylonApp) GetAccountKeeper() authkeeper.AccountKeeper { + return app.AccountKeeper +} + +func (app *BabylonApp) GetWasmKeeper() wasmkeeper.Keeper { + return app.WasmKeeper +} + func (app *BabylonApp) GetTxConfig() client.TxConfig { return app.TxConfig() } diff --git a/app/test_helpers.go b/app/test_helpers.go index 3a31fa6a4..08ff94d76 100644 --- a/app/test_helpers.go +++ b/app/test_helpers.go @@ -2,7 +2,6 @@ package app import ( "encoding/json" - "math/rand" "os" "testing" "time" @@ -15,13 +14,10 @@ import ( tmjson "github.com/cometbft/cometbft/libs/json" cmtproto "github.com/cometbft/cometbft/proto/tendermint/types" dbm "github.com/cosmos/cosmos-db" - bam "github.com/cosmos/cosmos-sdk/baseapp" - "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/client/flags" codectypes "github.com/cosmos/cosmos-sdk/codec/types" cryptocodec "github.com/cosmos/cosmos-sdk/crypto/codec" cosmosed "github.com/cosmos/cosmos-sdk/crypto/keys/ed25519" - cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types" "github.com/cosmos/cosmos-sdk/server" "github.com/cosmos/cosmos-sdk/server/types" simsutils "github.com/cosmos/cosmos-sdk/testutil/sims" @@ -34,11 +30,12 @@ import ( "github.com/docker/docker/pkg/ioutils" "github.com/stretchr/testify/require" - appparams "github.com/babylonchain/babylon/app/params" - "github.com/babylonchain/babylon/crypto/bls12381" - "github.com/babylonchain/babylon/privval" - bbn "github.com/babylonchain/babylon/types" - checkpointingtypes "github.com/babylonchain/babylon/x/checkpointing/types" + appkeepers "github.com/babylonlabs-io/babylon/app/keepers" + appparams "github.com/babylonlabs-io/babylon/app/params" + "github.com/babylonlabs-io/babylon/crypto/bls12381" + "github.com/babylonlabs-io/babylon/privval" + bbn "github.com/babylonlabs-io/babylon/types" + checkpointingtypes "github.com/babylonlabs-io/babylon/x/checkpointing/types" ) // SetupOptions defines arguments that are passed into `Simapp` constructor. @@ -50,7 +47,7 @@ type SetupOptions struct { AppOpts types.AppOptions } -func setup(t *testing.T, ps *PrivSigner, withGenesis bool, invCheckPeriod uint) (*BabylonApp, GenesisState) { +func setup(t *testing.T, ps *appkeepers.PrivSigner, withGenesis bool, invCheckPeriod uint) (*BabylonApp, GenesisState) { db := dbm.NewMemDB() nodeHome := t.TempDir() @@ -81,10 +78,10 @@ func setup(t *testing.T, ps *PrivSigner, withGenesis bool, invCheckPeriod uint) } // NewBabylonAppWithCustomOptions initializes a new BabylonApp with custom options. -// Created Babylon application will have one validator with hardcoed amout of tokens. +// Created Babylon application will have one validator with hardcoed amount of tokens. // This is necessary as from cosmos-sdk 0.46 it is required that there is at least // one validator in validator set during InitGenesis abci call - https://github.com/cosmos/cosmos-sdk/pull/9697 -func NewBabylonAppWithCustomOptions(t *testing.T, isCheckTx bool, privSigner *PrivSigner, options SetupOptions) *BabylonApp { +func NewBabylonAppWithCustomOptions(t *testing.T, isCheckTx bool, privSigner *appkeepers.PrivSigner, options SetupOptions) *BabylonApp { t.Helper() // create validator set with single validator valKeys, err := privval.NewValidatorKeys(ed25519.GenPrivKey(), bls12381.GenPrivKey()) @@ -222,7 +219,7 @@ func genesisStateWithValSet(t *testing.T, } // Setup initializes a new BabylonApp. A Nop logger is set in BabylonApp. -// Created Babylon application will have one validator with hardoced amout of tokens. +// Created Babylon application will have one validator with hardoced amount of tokens. // This is necessary as from cosmos-sdk 0.46 it is required that there is at least // one validator in validator set during InitGenesis abci call - https://github.com/cosmos/cosmos-sdk/pull/9697 func Setup(t *testing.T, isCheckTx bool) *BabylonApp { @@ -249,7 +246,7 @@ func Setup(t *testing.T, isCheckTx bool) *BabylonApp { } // SetupTestPrivSigner sets up a PrivSigner for testing -func SetupTestPrivSigner() (*PrivSigner, error) { +func SetupTestPrivSigner() (*appkeepers.PrivSigner, error) { // Create a temporary node directory nodeDir, err := ioutils.TempDir("", "tmp-signer") if err != nil { @@ -258,7 +255,7 @@ func SetupTestPrivSigner() (*PrivSigner, error) { defer func() { _ = os.RemoveAll(nodeDir) }() - privSigner, _ := InitPrivSigner(nodeDir) + privSigner, _ := appkeepers.InitPrivSigner(nodeDir) return privSigner, nil } @@ -267,7 +264,7 @@ func SetupTestPrivSigner() (*PrivSigner, error) { // of one consensus engine unit (10^6) in the default token of the babylon app from first genesis // account. A Nop logger is set in BabylonApp. // Note that the privSigner should be the 0th item of valSet -func SetupWithGenesisValSet(t *testing.T, valSet []*checkpointingtypes.GenesisKey, privSigner *PrivSigner, genAccs []authtypes.GenesisAccount, balances ...banktypes.Balance) *BabylonApp { +func SetupWithGenesisValSet(t *testing.T, valSet []*checkpointingtypes.GenesisKey, privSigner *appkeepers.PrivSigner, genAccs []authtypes.GenesisAccount, balances ...banktypes.Balance) *BabylonApp { t.Helper() app, genesisState := setup(t, privSigner, true, 5) genesisState = genesisStateWithValSet(t, app, genesisState, valSet, genAccs, balances...) @@ -300,7 +297,7 @@ func SetupWithGenesisValSet(t *testing.T, valSet []*checkpointingtypes.GenesisKe return app } -func GenesisKeyFromPrivSigner(ps *PrivSigner) (*checkpointingtypes.GenesisKey, error) { +func GenesisKeyFromPrivSigner(ps *appkeepers.PrivSigner) (*checkpointingtypes.GenesisKey, error) { valKeys, err := privval.NewValidatorKeys(ps.WrappedPV.GetValPrivKey(), ps.WrappedPV.GetBlsPrivKey()) if err != nil { return nil, err @@ -357,43 +354,3 @@ func initAccountWithCoins(app *BabylonApp, ctx sdk.Context, addr sdk.AccAddress, panic(err) } } - -// EmptyAppOptions is a stub implementing AppOptions -type EmptyAppOptions struct{} - -// Get implements AppOptions -func (ao EmptyAppOptions) Get(o string) interface{} { - // some defaults required for app.toml config - - if o == "btc-config.network" { - return string(bbn.BtcSimnet) - } - - return nil -} - -// SignAndDeliverWithoutCommit signs and delivers a transaction. No commit -func SignAndDeliverWithoutCommit(t *testing.T, txCfg client.TxConfig, app *bam.BaseApp, msgs []sdk.Msg, fees sdk.Coins, chainID string, accNums, accSeqs []uint64, blockTime time.Time, priv ...cryptotypes.PrivKey) (*abci.ResponseFinalizeBlock, error) { - tx, err := simsutils.GenSignedMockTx( - rand.New(rand.NewSource(time.Now().UnixNano())), - txCfg, - msgs, - fees, - simsutils.DefaultGenTxGas, - chainID, - accNums, - accSeqs, - priv..., - ) - require.NoError(t, err) - - bz, err := txCfg.TxEncoder()(tx) - require.NoError(t, err) - - return app.FinalizeBlock(&abci.RequestFinalizeBlock{ - Height: app.LastBlockHeight() + 1, - Hash: app.LastCommitID().Hash, - Time: blockTime, - Txs: [][]byte{bz}, - }) -} diff --git a/app/upgrades/README.md b/app/upgrades/README.md new file mode 100644 index 000000000..e7e799a56 --- /dev/null +++ b/app/upgrades/README.md @@ -0,0 +1,43 @@ +# Babylon Upgrades + +This folder contains sub-folders for every babylon upgrade. (Both state +migrations, and hard forks) It also defines upgrade & hard fork structs, +that each upgrade implements. These then get included in the application +app.go to run the upgrade. + +The code is adapted from [Osmosis](https://github.com/osmosis-labs/osmosis/blob/68d546d94acbf1aa99d6b514cb66b2b40afff4a4/app/upgrades). + +## Version History + +TODO + +## Upgrade types + +There are two upgrade types exposed, `Upgrade` and `Fork`. An `Upgrade` +defines an upgrade that is to be acted upon by state migrations from the +SDK `x/upgrade` module. A `Fork` defines a hard fork that changes some +logic at a block height. If the goal is to have a new binary be +compatible with the old binary prior to the upgrade height, as is the +case for all babylon `Fork`s, then all logic changes must be +height-gated or in the `BeginForkLogic` code. + +```go +type Upgrade struct { + // Upgrade version name, for the upgrade handler, e.g. `v7` + UpgradeName string + // Function that creates an upgrade handler + CreateUpgradeHandler func(mm *module.Manager, configurator module.Configurator, keepers *keepers.AppKeepers) upgradetypes.UpgradeHandler + // Store upgrades, should be used for any new modules introduced, new modules deleted, or store names renamed. + StoreUpgrades store.StoreUpgrades +} + +type Fork struct { + // Upgrade version name, for the upgrade handler, e.g. `v7` + UpgradeName string + // height the upgrade occurs at + UpgradeHeight int64 + + // Function that runs some custom state transition code at the beginning of a fork. + BeginForkLogic func(ctx sdk.Context, keepers *keepers.AppKeepers) +} +``` diff --git a/app/upgrades/types.go b/app/upgrades/types.go new file mode 100644 index 000000000..15fa8ae05 --- /dev/null +++ b/app/upgrades/types.go @@ -0,0 +1,48 @@ +package upgrades + +import ( + store "cosmossdk.io/store/types" + upgradetypes "cosmossdk.io/x/upgrade/types" + tmproto "github.com/cometbft/cometbft/proto/tendermint/types" + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/cosmos-sdk/types/module" + + "github.com/babylonlabs-io/babylon/app/keepers" +) + +// BaseAppParamManager defines an interrace that BaseApp is expected to fulfill +// that allows upgrade handlers to modify BaseApp parameters. +type BaseAppParamManager interface { + GetConsensusParams(ctx sdk.Context) tmproto.ConsensusParams + StoreConsensusParams(ctx sdk.Context, cp tmproto.ConsensusParams) error +} + +// Upgrade defines a struct containing necessary fields that a SoftwareUpgradeProposal +// must have written, in order for the state migration to go smoothly. +// An upgrade must implement this struct, and then set it in the app.go. +// The app.go will then define the handler. +type Upgrade struct { + // Upgrade version name, for the upgrade handler, e.g. `v7` + UpgradeName string + + // CreateUpgradeHandler defines the function that creates an upgrade handler + CreateUpgradeHandler func(*module.Manager, module.Configurator, BaseAppParamManager, *keepers.AppKeepers) upgradetypes.UpgradeHandler + + // Store upgrades, should be used for any new modules introduced, new modules deleted, or store names renamed. + StoreUpgrades store.StoreUpgrades +} + +// 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`. +// Any other change in the code should be height-gated, if the goal is to have old and new binaries +// to be compatible prior to the upgrade height. +type Fork struct { + // Upgrade version name, for the upgrade handler, e.g. `v7` + UpgradeName string + // height the upgrade occurs at + UpgradeHeight int64 + + // Function that runs some custom state transition code at the beginning of a fork. + BeginForkLogic func(ctx sdk.Context, keepers *keepers.AppKeepers) +} diff --git a/app/upgrades/vanilla/README.md b/app/upgrades/vanilla/README.md new file mode 100644 index 000000000..3909ea3f3 --- /dev/null +++ b/app/upgrades/vanilla/README.md @@ -0,0 +1,4 @@ +# vanilla + +This folder contains a vanilla software upgrade for testing purposes. +DO NOT USE IN PRODUCTION! diff --git a/app/upgrades/vanilla/upgrades.go b/app/upgrades/vanilla/upgrades.go new file mode 100644 index 000000000..35d546958 --- /dev/null +++ b/app/upgrades/vanilla/upgrades.go @@ -0,0 +1,64 @@ +// This code is only for testing purposes. +// DO NOT USE IN PRODUCTION! + +package vanilla + +import ( + "context" + + store "cosmossdk.io/store/types" + upgradetypes "cosmossdk.io/x/upgrade/types" + "github.com/babylonlabs-io/babylon/app/keepers" + "github.com/babylonlabs-io/babylon/app/upgrades" + bbn "github.com/babylonlabs-io/babylon/types" + btcstakingkeeper "github.com/babylonlabs-io/babylon/x/btcstaking/keeper" + bstypes "github.com/babylonlabs-io/babylon/x/btcstaking/types" + "github.com/btcsuite/btcd/btcec/v2" + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/cosmos-sdk/types/module" + authkeeper "github.com/cosmos/cosmos-sdk/x/auth/keeper" +) + +var Upgrade = upgrades.Upgrade{ + UpgradeName: "vanilla", + CreateUpgradeHandler: CreateUpgradeHandler, + StoreUpgrades: store.StoreUpgrades{}, +} + +func CreateUpgradeHandler( + mm *module.Manager, + cfg module.Configurator, + _ upgrades.BaseAppParamManager, + keepers *keepers.AppKeepers, +) upgradetypes.UpgradeHandler { + return func(context context.Context, _plan upgradetypes.Plan, fromVM module.VersionMap) (module.VersionMap, error) { + + ctx := sdk.UnwrapSDKContext(context) + + propVanilla(ctx, &keepers.AccountKeeper, &keepers.BTCStakingKeeper) + + return mm.RunMigrations(ctx, cfg, fromVM) + } +} + +func propVanilla( + ctx sdk.Context, + accountKeeper *authkeeper.AccountKeeper, + bsKeeper *btcstakingkeeper.Keeper, +) { + // remove an account + allAccounts := accountKeeper.GetAllAccounts(ctx) + accountKeeper.RemoveAccount(ctx, allAccounts[len(allAccounts)-1]) + + // insert a FP + sk, err := btcec.NewPrivateKey() + if err != nil { + panic(err) + } + btcPK := bbn.NewBIP340PubKeyFromBTCPK(sk.PubKey()) + fp := &bstypes.FinalityProvider{ + Addr: allAccounts[0].GetAddress().String(), + BtcPk: btcPK, + } + bsKeeper.SetFinalityProvider(ctx, fp) +} diff --git a/app/upgrades/vanilla/upgrades_test.go b/app/upgrades/vanilla/upgrades_test.go new file mode 100644 index 000000000..19511629f --- /dev/null +++ b/app/upgrades/vanilla/upgrades_test.go @@ -0,0 +1,105 @@ +package vanilla_test + +import ( + "fmt" + "testing" + "time" + + "cosmossdk.io/core/appmodule" + "cosmossdk.io/core/header" + "cosmossdk.io/x/upgrade" + upgradetypes "cosmossdk.io/x/upgrade/types" + "github.com/babylonlabs-io/babylon/app" + v1 "github.com/babylonlabs-io/babylon/app/upgrades/vanilla" + bstypes "github.com/babylonlabs-io/babylon/x/btcstaking/types" + tmproto "github.com/cometbft/cometbft/proto/tendermint/types" + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/stretchr/testify/suite" +) + +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()) +} + +func TestKeeperTestSuite(t *testing.T) { + suite.Run(t, new(UpgradeTestSuite)) +} + +func (s *UpgradeTestSuite) TestUpgradePayments() { + oldAcctNum := 0 + + testCases := []struct { + msg string + pre_update func() + update func() + post_update func() + expPass bool + }{ + { + "Test vanilla software upgrade gov prop", + func() { + allAccounts := s.app.AccountKeeper.GetAllAccounts(s.ctx) + oldAcctNum = len(allAccounts) + }, + 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 account is removed + allAccounts := s.app.AccountKeeper.GetAllAccounts(s.ctx) + newAcctNum := len(allAccounts) + s.Equal(newAcctNum, oldAcctNum-1) + + // ensure finality provider is inserted + resp, err := s.app.BTCStakingKeeper.FinalityProviders(s.ctx, &bstypes.QueryFinalityProvidersRequest{}) + s.NoError(err) + s.Len(resp.FinalityProviders, 1) + }, + true, + }, + } + + 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/btcstaking/btcstaking_test.go b/btcstaking/btcstaking_test.go index 22f0df961..940a4aace 100644 --- a/btcstaking/btcstaking_test.go +++ b/btcstaking/btcstaking_test.go @@ -7,8 +7,8 @@ import ( "testing" "time" - "github.com/babylonchain/babylon/btcstaking" - btctest "github.com/babylonchain/babylon/testutil/bitcoin" + "github.com/babylonlabs-io/babylon/btcstaking" + btctest "github.com/babylonlabs-io/babylon/testutil/bitcoin" "github.com/btcsuite/btcd/btcec/v2" "github.com/btcsuite/btcd/btcec/v2/schnorr" "github.com/btcsuite/btcd/btcutil" @@ -86,6 +86,18 @@ func (t *TestScenario) FinalityProviderPublicKeys() []*btcec.PublicKey { return finalityProviderPubKeys } +func createSpendStakeTx(amount btcutil.Amount) *wire.MsgTx { + spendStakeTx := wire.NewMsgTx(2) + spendStakeTx.AddTxIn(wire.NewTxIn(&wire.OutPoint{}, nil, nil)) + spendStakeTx.AddTxOut( + &wire.TxOut{ + PkScript: []byte("doesn't matter"), + Value: int64(amount), + }, + ) + return spendStakeTx +} + func TestSpendingTimeLockPath(t *testing.T) { r := rand.New(rand.NewSource(time.Now().Unix())) scenario := GenerateTestScenario( @@ -110,15 +122,7 @@ func TestSpendingTimeLockPath(t *testing.T) { require.NoError(t, err) - spendStakeTx := wire.NewMsgTx(2) - spendStakeTx.AddTxIn(wire.NewTxIn(&wire.OutPoint{}, nil, nil)) - spendStakeTx.AddTxOut( - &wire.TxOut{ - PkScript: []byte("doesn't matter"), - // spend half of the staking amount - Value: int64(scenario.StakingAmount.MulF64(0.5)), - }, - ) + spendStakeTx := createSpendStakeTx(scenario.StakingAmount.MulF64(0.5)) // to spend tx as staker, we need to set the sequence number to be >= stakingTimeBlocks spendStakeTx.TxIn[0].Sequence = uint32(scenario.StakingTime) @@ -248,15 +252,7 @@ func TestSpendingUnbondingPathCovenant35MultiSig(t *testing.T) { require.NoError(t, err) - spendStakeTx := wire.NewMsgTx(2) - spendStakeTx.AddTxIn(wire.NewTxIn(&wire.OutPoint{}, nil, nil)) - spendStakeTx.AddTxOut( - &wire.TxOut{ - PkScript: []byte("doesn't matter"), - // spend half of the staking amount - Value: int64(scenario.StakingAmount.MulF64(0.5)), - }, - ) + spendStakeTx := createSpendStakeTx(scenario.StakingAmount.MulF64(0.5)) si, err := stakingInfo.UnbondingPathSpendInfo() require.NoError(t, err) @@ -278,6 +274,10 @@ func TestSpendingUnbondingPathCovenant35MultiSig(t *testing.T) { stakingInfo.StakingOutput, si.RevealedLeaf, ) + + covenantSigantures[1] = nil + covenantSigantures[3] = nil + witness, err := si.CreateUnbondingPathWitness(covenantSigantures, stakerSig) require.NoError(t, err) spendStakeTx.TxIn[0].Witness = witness @@ -294,37 +294,6 @@ func TestSpendingUnbondingPathCovenant35MultiSig(t *testing.T) { } btctest.AssertEngineExecution(t, 0, true, newEngine) - numOfCovenantMembers := len(scenario.CovenantKeys) - // with each loop iteration we remove one key from the list of signatures - for i := 0; i < numOfCovenantMembers; i++ { - numOfRemovedSignatures := i + 1 - - covenantSigantures := GenerateSignatures( - t, - scenario.CovenantKeys, - spendStakeTx, - stakingInfo.StakingOutput, - si.RevealedLeaf, - ) - - for j := 0; j <= i; j++ { - // NOTE: Number provides signatures must match number of public keys in the script, - // if we are missing some signatures those must be set to empty signature in witness - covenantSigantures[j] = nil - } - - witness, err := si.CreateUnbondingPathWitness(covenantSigantures, stakerSig) - require.NoError(t, err) - spendStakeTx.TxIn[0].Witness = witness - - if numOfCovenantMembers-numOfRemovedSignatures >= int(scenario.RequiredCovenantSigs) { - // if we are above threshold execution should be successful - btctest.AssertEngineExecution(t, 0, true, newEngine) - } else { - // we are below threshold execution should be unsuccessful - btctest.AssertEngineExecution(t, 0, false, newEngine) - } - } } func TestSpendingUnbondingPathSingleKeyCovenant(t *testing.T) { @@ -353,15 +322,7 @@ func TestSpendingUnbondingPathSingleKeyCovenant(t *testing.T) { require.NoError(t, err) - spendStakeTx := wire.NewMsgTx(2) - spendStakeTx.AddTxIn(wire.NewTxIn(&wire.OutPoint{}, nil, nil)) - spendStakeTx.AddTxOut( - &wire.TxOut{ - PkScript: []byte("doesn't matter"), - // spend half of the staking amount - Value: int64(scenario.StakingAmount.MulF64(0.5)), - }, - ) + spendStakeTx := createSpendStakeTx(scenario.StakingAmount.MulF64(0.5)) si, err := stakingInfo.UnbondingPathSpendInfo() require.NoError(t, err) @@ -425,15 +386,7 @@ func TestSpendingSlashingPathCovenant35MultiSig(t *testing.T) { require.NoError(t, err) - spendStakeTx := wire.NewMsgTx(2) - spendStakeTx.AddTxIn(wire.NewTxIn(&wire.OutPoint{}, nil, nil)) - spendStakeTx.AddTxOut( - &wire.TxOut{ - PkScript: []byte("doesn't matter"), - // spend half of the staking amount - Value: int64(scenario.StakingAmount.MulF64(0.5)), - }, - ) + spendStakeTx := createSpendStakeTx(scenario.StakingAmount.MulF64(0.5)) si, err := stakingInfo.SlashingPathSpendInfo() require.NoError(t, err) @@ -461,6 +414,9 @@ func TestSpendingSlashingPathCovenant35MultiSig(t *testing.T) { ) require.NoError(t, err) + covenantSigantures[0] = nil + covenantSigantures[3] = nil + witness, err := si.CreateSlashingPathWitness( covenantSigantures, []*schnorr.Signature{fpSig}, @@ -508,15 +464,7 @@ func TestSpendingSlashingPathCovenant35MultiSigFinalityProviderRestaking(t *test require.NoError(t, err) - spendStakeTx := wire.NewMsgTx(2) - spendStakeTx.AddTxIn(wire.NewTxIn(&wire.OutPoint{}, nil, nil)) - spendStakeTx.AddTxOut( - &wire.TxOut{ - PkScript: []byte("doesn't matter"), - // spend half of the staking amount - Value: int64(scenario.StakingAmount.MulF64(0.5)), - }, - ) + spendStakeTx := createSpendStakeTx(scenario.StakingAmount.MulF64(0.5)) si, err := stakingInfo.SlashingPathSpendInfo() require.NoError(t, err) @@ -577,15 +525,7 @@ func TestSpendingRelativeTimeLockScript(t *testing.T) { lockedAmount := btcutil.Amount(2 * 10e8) // to spend output with relative timelock transaction need to be version two or higher - spendStakeTx := wire.NewMsgTx(2) - spendStakeTx.AddTxIn(wire.NewTxIn(&wire.OutPoint{}, nil, nil)) - spendStakeTx.AddTxOut( - &wire.TxOut{ - PkScript: []byte("doesn't matter"), - // spend half of the staking amount - Value: int64(lockedAmount.MulF64(0.5)), - }, - ) + spendStakeTx := createSpendStakeTx(lockedAmount.MulF64(0.5)) tls, err := btcstaking.BuildRelativeTimelockTaprootScript( stakerPubKey, diff --git a/btcstaking/identifiable_staking.go b/btcstaking/identifiable_staking.go new file mode 100644 index 000000000..d75288dd5 --- /dev/null +++ b/btcstaking/identifiable_staking.go @@ -0,0 +1,480 @@ +package btcstaking + +import ( + "bytes" + "encoding/binary" + "encoding/hex" + "fmt" + + "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/txscript" + "github.com/btcsuite/btcd/wire" +) + +const ( + // length of tag prefix indentifying 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 = 71 + + v0OpReturnCreationErrMsg = "cannot create V0 op_return data" +) + +type IdentifiableStakingInfo struct { + StakingOutput *wire.TxOut + scriptHolder *taprootScriptHolder + timeLockPathLeafHash chainhash.Hash + unbondingPathLeafHash chainhash.Hash + slashingPathLeafHash chainhash.Hash + OpReturnOutput *wire.TxOut +} + +func uint16ToBytes(v uint16) []byte { + var buf [2]byte + binary.BigEndian.PutUint16(buf[:], v) + return buf[:] +} + +func uint16FromBytes(b []byte) (uint16, error) { + if len(b) != 2 { + return 0, fmt.Errorf("invalid uint16 bytes length: %d", len(b)) + } + + return binary.BigEndian.Uint16(b), nil +} + +// V0OpReturnData represents the data that is embedded in the OP_RETURN output +// It marshalls to exactly 71 bytes +type V0OpReturnData struct { + Tag []byte + Version byte + StakerPublicKey *XonlyPubKey + FinalityProviderPublicKey *XonlyPubKey + StakingTime uint16 +} + +func NewV0OpReturnData( + tag []byte, + stakerPublicKey []byte, + finalityProviderPublicKey []byte, + stakingTime []byte, +) (*V0OpReturnData, error) { + if len(tag) != TagLen { + return nil, fmt.Errorf("%s: invalid tag length: %d, expected: %d", v0OpReturnCreationErrMsg, len(tag), TagLen) + } + + stakerKey, err := XOnlyPublicKeyFromBytes(stakerPublicKey) + + if err != nil { + return nil, fmt.Errorf("%s:invalid staker public key:%w", v0OpReturnCreationErrMsg, err) + } + + fpKey, err := XOnlyPublicKeyFromBytes(finalityProviderPublicKey) + + if err != nil { + return nil, fmt.Errorf("%s:invalid finality provider public key:%w", v0OpReturnCreationErrMsg, err) + } + + stakingTimeValue, err := uint16FromBytes(stakingTime) + + if err != nil { + return nil, fmt.Errorf("%s:invalid staking time:%w", v0OpReturnCreationErrMsg, err) + } + + return NewV0OpReturnDataFromParsed(tag, stakerKey.PubKey, fpKey.PubKey, stakingTimeValue) +} + +func NewV0OpReturnDataFromParsed( + tag []byte, + stakerPublicKey *btcec.PublicKey, + finalityProviderPublicKey *btcec.PublicKey, + stakingTime uint16, +) (*V0OpReturnData, error) { + if len(tag) != TagLen { + return nil, fmt.Errorf("%s:invalid tag length: %d, expected: %d", v0OpReturnCreationErrMsg, len(tag), TagLen) + } + + if stakerPublicKey == nil { + return nil, fmt.Errorf("%s:nil staker public key", v0OpReturnCreationErrMsg) + } + + if finalityProviderPublicKey == nil { + return nil, fmt.Errorf("%s: nil finality provider public key", v0OpReturnCreationErrMsg) + } + + return &V0OpReturnData{ + Tag: tag, + Version: 0, + StakerPublicKey: &XonlyPubKey{stakerPublicKey}, + FinalityProviderPublicKey: &XonlyPubKey{finalityProviderPublicKey}, + StakingTime: stakingTime, + }, nil +} + +func NewV0OpReturnDataFromBytes(b []byte) (*V0OpReturnData, error) { + if len(b) != V0OpReturnDataSize { + return nil, fmt.Errorf("invalid op return data length: %d, expected: %d", len(b), V0OpReturnDataSize) + } + tag := b[:TagLen] + + version := b[TagLen] + + if version != 0 { + return nil, fmt.Errorf("invalid op return version: %d, expected: %d", version, 0) + } + + stakerPublicKey := b[TagLen+1 : TagLen+1+schnorr.PubKeyBytesLen] + finalityProviderPublicKey := b[TagLen+1+schnorr.PubKeyBytesLen : TagLen+1+schnorr.PubKeyBytesLen*2] + stakingTime := b[TagLen+1+schnorr.PubKeyBytesLen*2:] + return NewV0OpReturnData(tag, stakerPublicKey, finalityProviderPublicKey, stakingTime) +} + +func getV0OpReturnBytes(out *wire.TxOut) ([]byte, error) { + if out == nil { + return nil, fmt.Errorf("nil tx output") + } + + // We are adding `+2` as each op return has additional 2 for: + // 1. OP_RETURN opcode - which signalizes that data is provably unspendable + // 2. OP_DATA_71 opcode - which pushes 71 bytes of data to the stack + if len(out.PkScript) != V0OpReturnDataSize+2 { + return nil, fmt.Errorf("invalid op return data length: %d, expected: %d", len(out.PkScript), V0OpReturnDataSize+2) + } + + if !txscript.IsNullData(out.PkScript) { + return nil, fmt.Errorf("invalid op return script") + } + + return out.PkScript[2:], nil +} + +func NewV0OpReturnDataFromTxOutput(out *wire.TxOut) (*V0OpReturnData, error) { + data, err := getV0OpReturnBytes(out) + + if err != nil { + return nil, fmt.Errorf("cannot parse op return data: %w", err) + } + + return NewV0OpReturnDataFromBytes(data) +} + +func (d *V0OpReturnData) Marshall() []byte { + var data []byte + data = append(data, d.Tag...) + data = append(data, d.Version) + data = append(data, d.StakerPublicKey.Marshall()...) + data = append(data, d.FinalityProviderPublicKey.Marshall()...) + data = append(data, uint16ToBytes(d.StakingTime)...) + return data +} + +func (d *V0OpReturnData) ToTxOutput() (*wire.TxOut, error) { + dataScript, err := txscript.NullDataScript(d.Marshall()) + if err != nil { + return nil, err + } + return wire.NewTxOut(0, dataScript), nil +} + +// BuildV0IdentifiableStakingOutputs creates outputs which every staking transaction must have +func BuildV0IdentifiableStakingOutputs( + tag []byte, + stakerKey *btcec.PublicKey, + fpKey *btcec.PublicKey, + covenantKeys []*btcec.PublicKey, + covenantQuorum uint32, + stakingTime uint16, + stakingAmount btcutil.Amount, + net *chaincfg.Params, +) (*IdentifiableStakingInfo, error) { + info, err := BuildStakingInfo( + stakerKey, + []*btcec.PublicKey{fpKey}, + covenantKeys, + covenantQuorum, + stakingTime, + stakingAmount, + net, + ) + if err != nil { + return nil, err + } + + opReturnData, err := NewV0OpReturnDataFromParsed(tag, stakerKey, fpKey, stakingTime) + + if err != nil { + return nil, err + } + + dataOutput, err := opReturnData.ToTxOutput() + + if err != nil { + return nil, err + } + + return &IdentifiableStakingInfo{ + StakingOutput: info.StakingOutput, + scriptHolder: info.scriptHolder, + timeLockPathLeafHash: info.timeLockPathLeafHash, + unbondingPathLeafHash: info.unbondingPathLeafHash, + slashingPathLeafHash: info.slashingPathLeafHash, + OpReturnOutput: dataOutput, + }, nil +} + +// BuildV0IdentifiableStakingOutputsAndTx creates outputs which every staking transaction must have and +// returns the not-funded transaction with these outputs +func BuildV0IdentifiableStakingOutputsAndTx( + tag []byte, + stakerKey *btcec.PublicKey, + fpKey *btcec.PublicKey, + covenantKeys []*btcec.PublicKey, + covenantQuorum uint32, + stakingTime uint16, + stakingAmount btcutil.Amount, + net *chaincfg.Params, +) (*IdentifiableStakingInfo, *wire.MsgTx, error) { + info, err := BuildV0IdentifiableStakingOutputs( + tag, + stakerKey, + fpKey, + covenantKeys, + covenantQuorum, + stakingTime, + stakingAmount, + net, + ) + if err != nil { + return nil, nil, err + } + + tx := wire.NewMsgTx(2) + tx.AddTxOut(info.StakingOutput) + tx.AddTxOut(info.OpReturnOutput) + return info, tx, nil +} + +func (i *IdentifiableStakingInfo) TimeLockPathSpendInfo() (*SpendInfo, error) { + return i.scriptHolder.scriptSpendInfoByName(i.timeLockPathLeafHash) +} + +func (i *IdentifiableStakingInfo) UnbondingPathSpendInfo() (*SpendInfo, error) { + return i.scriptHolder.scriptSpendInfoByName(i.unbondingPathLeafHash) +} + +func (i *IdentifiableStakingInfo) SlashingPathSpendInfo() (*SpendInfo, error) { + return i.scriptHolder.scriptSpendInfoByName(i.slashingPathLeafHash) +} + +type ParsedV0StakingTx struct { + StakingOutput *wire.TxOut + StakingOutputIdx int + OpReturnOutput *wire.TxOut + OpReturnOutputIdx int + OpReturnData *V0OpReturnData +} + +func tryToGetOpReturnDataFromOutputs(outputs []*wire.TxOut) (*V0OpReturnData, int, error) { + // lack of outputs is not an error + if len(outputs) == 0 { + return nil, -1, nil + } + + var opReturnData *V0OpReturnData + var opReturnOutputIdx int + + for i, o := range outputs { + output := o + d, err := NewV0OpReturnDataFromTxOutput(output) + + if err != nil { + // this is not an op return output recognized by Babylon, move forward + continue + } + // this case should not happen as standard bitcoin node propagation rules + // disallow multiple op return outputs in a single transaction. However, miner could + // include multiple op return outputs in a single transaction. In such case, we should + // return an error. + if opReturnData != nil { + return nil, -1, fmt.Errorf("multiple op return outputs found") + } + + opReturnData = d + opReturnOutputIdx = i + } + + return opReturnData, opReturnOutputIdx, nil +} + +func tryToGetStakingOutput(outputs []*wire.TxOut, stakingOutputPkScript []byte) (*wire.TxOut, int, error) { + // lack of outputs is not an error + if len(outputs) == 0 { + return nil, -1, nil + } + + var stakingOutput *wire.TxOut + var stakingOutputIdx int + + for i, o := range outputs { + output := o + + if !bytes.Equal(output.PkScript, stakingOutputPkScript) { + // this is not the staking output we are looking for + continue + } + + if stakingOutput != nil { + // we only allow for one staking output per transaction + return nil, -1, fmt.Errorf("multiple staking outputs found") + } + + stakingOutput = output + stakingOutputIdx = i + } + + return stakingOutput, stakingOutputIdx, nil +} + +// ParseV0StakingTx takes a btc transaction and checks whether it is a staking transaction and if so parses it +// for easy data retrieval. +// It does all necessary checks to ensure that the transaction is valid staking transaction. +func ParseV0StakingTx( + tx *wire.MsgTx, + expectedTag []byte, + covenantKeys []*btcec.PublicKey, + covenantQuorum uint32, + net *chaincfg.Params, +) (*ParsedV0StakingTx, error) { + // 1. Basic arguments checks + if tx == nil { + return nil, fmt.Errorf("nil tx") + } + + if len(expectedTag) != TagLen { + return nil, fmt.Errorf("invalid tag length: %d, expected: %d", len(expectedTag), TagLen) + } + + if len(covenantKeys) == 0 { + return nil, fmt.Errorf("no covenant keys specified") + } + + if covenantQuorum > uint32(len(covenantKeys)) { + return nil, fmt.Errorf("covenant quorum is greater than the number of covenant keys") + } + + // 2. Identify whether the transaction has expected shape + if len(tx.TxOut) < 2 { + return nil, fmt.Errorf("staking tx must have at least 2 outputs") + } + + opReturnData, opReturnOutputIdx, err := tryToGetOpReturnDataFromOutputs(tx.TxOut) + + if err != nil { + return nil, fmt.Errorf("cannot parse staking transaction: %w", err) + } + + if opReturnData == nil { + return nil, fmt.Errorf("transaction does not have expected op return output") + } + + // at this point we know that transaction has op return output which seems to match + // the expected shape. Check the tag and version. + if !bytes.Equal(opReturnData.Tag, expectedTag) { + return nil, fmt.Errorf("unexpected tag: %s, expected: %s", + hex.EncodeToString(opReturnData.Tag), + hex.EncodeToString(expectedTag), + ) + } + + if opReturnData.Version != 0 { + return nil, fmt.Errorf("unexpcted version: %d, expected: %d", opReturnData.Version, 0) + } + + // 3. Op return seems to be valid V0 op return output. Now, we need to check whether + // the staking output exists and is valid. + stakingInfo, err := BuildStakingInfo( + opReturnData.StakerPublicKey.PubKey, + []*btcec.PublicKey{opReturnData.FinalityProviderPublicKey.PubKey}, + covenantKeys, + covenantQuorum, + opReturnData.StakingTime, + // we can pass 0 here, as staking amount is not used when creating taproot address + 0, + net, + ) + + if err != nil { + return nil, fmt.Errorf("cannot build staking info: %w", err) + } + + stakingOutput, stakingOutputIdx, err := tryToGetStakingOutput(tx.TxOut, stakingInfo.StakingOutput.PkScript) + + if err != nil { + return nil, fmt.Errorf("cannot parse staking transaction: %w", err) + } + + if stakingOutput == nil { + return nil, fmt.Errorf("staking output not found in potential staking transaction") + } + + return &ParsedV0StakingTx{ + StakingOutput: stakingOutput, + StakingOutputIdx: stakingOutputIdx, + OpReturnOutput: tx.TxOut[opReturnOutputIdx], + OpReturnOutputIdx: opReturnOutputIdx, + OpReturnData: opReturnData, + }, nil +} + +// IsPossibleV0StakingTx checks whether transaction may be a valid staking transaction +// checks: +// 1. Whether the transaction has at least 2 outputs +// 2. have an op return output +// 3. op return output has expected tag +// This function is much faster than ParseV0StakingTx, as it does not perform +// all necessary checks. +func IsPossibleV0StakingTx(tx *wire.MsgTx, expectedTag []byte) bool { + if len(expectedTag) != TagLen { + return false + } + + if len(tx.TxOut) < 2 { + return false + } + + var possibleStakingTx = false + for _, o := range tx.TxOut { + output := o + + data, err := getV0OpReturnBytes(output) + + if err != nil { + // this is not an op return output recognized by Babylon, move forward + continue + } + + if !bytes.Equal(data[:TagLen], expectedTag) { + // this is not the op return output we are looking for as tag do not match + continue + } + + if data[TagLen] != 0 { + // this is not the v0 op return output + continue + } + + if possibleStakingTx { + // this is second output that matches the tag, we do not allow for multiple op return outputs + // so this is not a valid staking transaction + return false + } + + possibleStakingTx = true + } + + return possibleStakingTx +} diff --git a/btcstaking/identifiable_staking_test.go b/btcstaking/identifiable_staking_test.go new file mode 100644 index 000000000..96692735b --- /dev/null +++ b/btcstaking/identifiable_staking_test.go @@ -0,0 +1,103 @@ +package btcstaking_test + +import ( + "math" + "math/rand" + "testing" + + "github.com/babylonlabs-io/babylon/btcstaking" + + "github.com/btcsuite/btcd/btcec/v2/schnorr" + "github.com/btcsuite/btcd/btcutil" + "github.com/btcsuite/btcd/chaincfg" + "github.com/btcsuite/btcd/wire" + "github.com/stretchr/testify/require" + + "github.com/babylonlabs-io/babylon/testutil/datagen" +) + +func generateTxFromOutputs(r *rand.Rand, info *btcstaking.IdentifiableStakingInfo) (*wire.MsgTx, int, int) { + numOutputs := r.Int31n(18) + 2 + + stakingOutputIdx := int(r.Int31n(numOutputs)) + opReturnOutputIdx := int(datagen.RandomIntOtherThan(r, int(stakingOutputIdx), int(numOutputs))) + + tx := wire.NewMsgTx(2) + for i := 0; i < int(numOutputs); i++ { + if i == stakingOutputIdx { + tx.AddTxOut(info.StakingOutput) + } else if i == opReturnOutputIdx { + tx.AddTxOut(info.OpReturnOutput) + } else { + tx.AddTxOut(wire.NewTxOut((r.Int63n(1000000000) + 10000), datagen.GenRandomByteArray(r, 32))) + } + } + + return tx, stakingOutputIdx, opReturnOutputIdx +} + +// Property: Every staking tx generated by our generator should be properly parsed by +// our parser +func FuzzGenerateAndParseValidV0StakingTransaction(f *testing.F) { + // lot of seeds as test is pretty fast and we want to test a lot of different values + datagen.AddRandomSeedsToFuzzer(f, 1000) + f.Fuzz(func(t *testing.T, seed int64) { + r := rand.New(rand.NewSource(seed)) + // 3 - 10 covenants + numCovenantKeys := uint32(r.Int31n(7) + 3) + quroum := 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) + + outputs, err := btcstaking.BuildV0IdentifiableStakingOutputs( + tag, + sc.StakerKey.PubKey(), + sc.FinalityProviderKeys[0].PubKey(), + sc.CovenantPublicKeys(), + quroum, + stakingTime, + stakingAmount, + net, + ) + + require.NoError(t, err) + require.NotNil(t, outputs) + + tx, stakingOutputIdx, opReturnOutputIdx := generateTxFromOutputs(r, outputs) + + // ParseV0StakingTx and IsPossibleV0StakingTx should be consistent and recognize + // the same tx as a valid staking tx + require.True(t, btcstaking.IsPossibleV0StakingTx(tx, tag)) + + parsedTx, err := btcstaking.ParseV0StakingTx( + tx, + tag, + sc.CovenantPublicKeys(), + quroum, + net, + ) + require.NoError(t, err) + require.NotNil(t, parsedTx) + + require.Equal(t, outputs.StakingOutput.PkScript, parsedTx.StakingOutput.PkScript) + require.Equal(t, outputs.StakingOutput.Value, parsedTx.StakingOutput.Value) + require.Equal(t, stakingOutputIdx, parsedTx.StakingOutputIdx) + + require.Equal(t, outputs.OpReturnOutput.PkScript, parsedTx.OpReturnOutput.PkScript) + require.Equal(t, outputs.OpReturnOutput.Value, parsedTx.OpReturnOutput.Value) + require.Equal(t, opReturnOutputIdx, parsedTx.OpReturnOutputIdx) + + require.Equal(t, tag, parsedTx.OpReturnData.Tag) + require.Equal(t, uint8(0), parsedTx.OpReturnData.Version) + require.Equal(t, stakingTime, parsedTx.OpReturnData.StakingTime) + + require.Equal(t, schnorr.SerializePubKey(sc.StakerKey.PubKey()), parsedTx.OpReturnData.StakerPublicKey.Marshall()) + require.Equal(t, schnorr.SerializePubKey(sc.FinalityProviderKeys[0].PubKey()), parsedTx.OpReturnData.FinalityProviderPublicKey.Marshall()) + }) +} + +// TODO Negative test cases diff --git a/btcstaking/identifiable_staking_types.go b/btcstaking/identifiable_staking_types.go new file mode 100644 index 000000000..b1ce12702 --- /dev/null +++ b/btcstaking/identifiable_staking_types.go @@ -0,0 +1,27 @@ +package btcstaking + +import ( + "github.com/btcsuite/btcd/btcec/v2" + "github.com/btcsuite/btcd/btcec/v2/schnorr" +) + +// XonlyPubKey is a wrapper around btcec.PublicKey that represents BTC public +// key deserialized from a 32-byte array i.e with implicit assumption that Y coordinate +// is even. +type XonlyPubKey struct { + PubKey *btcec.PublicKey +} + +func XOnlyPublicKeyFromBytes(pkBytes []byte) (*XonlyPubKey, error) { + pk, err := schnorr.ParsePubKey(pkBytes) + + if err != nil { + return nil, err + } + + return &XonlyPubKey{pk}, nil +} + +func (p *XonlyPubKey) Marshall() []byte { + return schnorr.SerializePubKey(p.PubKey) +} diff --git a/btcstaking/scripts_utils.go b/btcstaking/scripts_utils.go index e9e2a2928..1c815c1d2 100644 --- a/btcstaking/scripts_utils.go +++ b/btcstaking/scripts_utils.go @@ -11,7 +11,8 @@ import ( ) // private helper to assemble multisig script -// SCRIPT: OP_CHEKCSIG OP_CHECKSIGADD OP_CHECKSIGADD ... OP_CHECKSIGADD OP_GREATERTHANOREQUAL OP_VERIFY +// if `withVerify` is ture 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, threshold uint32, @@ -29,51 +30,49 @@ func assembleMultiSigScript( } builder.AddInt64(int64(threshold)) - builder.AddOp(txscript.OP_GREATERTHANOREQUAL) if withVerify { - builder.AddOp(txscript.OP_VERIFY) + builder.AddOp(txscript.OP_NUMEQUALVERIFY) + } else { + builder.AddOp(txscript.OP_NUMEQUAL) } return builder.Script() } -// sortKeys takes a set of schnorr public keys and returns a new slice that is +// SortKeys takes a set of schnorr public keys and returns a new slice that is // a copy of the keys sorted in lexicographical order bytes on the x-only // pubkey serialization. -func sortKeys(keys []*btcec.PublicKey) []*btcec.PublicKey { - sort.SliceStable(keys, func(i, j int) bool { - keyIBytes := schnorr.SerializePubKey(keys[i]) - keyJBytes := schnorr.SerializePubKey(keys[j]) +func SortKeys(keys []*btcec.PublicKey) []*btcec.PublicKey { + sortedKeys := make([]*btcec.PublicKey, len(keys)) + copy(sortedKeys, keys) + sort.SliceStable(sortedKeys, func(i, j int) bool { + keyIBytes := schnorr.SerializePubKey(sortedKeys[i]) + keyJBytes := schnorr.SerializePubKey(sortedKeys[j]) return bytes.Compare(keyIBytes, keyJBytes) == -1 }) - return keys + return sortedKeys } // prepareKeys prepares keys to be used in multisig script // Validates: -// - whether there are at lest 2 keys -// - whether there are no duplicate keys +// - whether there are at least 2 keys // returns copy of the slice of keys sorted lexicographically +// Note: It is up to the caller to ensure that the keys are unique func prepareKeysForMultisigScript(keys []*btcec.PublicKey) ([]*btcec.PublicKey, error) { if len(keys) < 2 { return nil, fmt.Errorf("cannot create multisig script with less than 2 keys") } - sortedKeys := sortKeys(keys) - - for i := 0; i < len(sortedKeys)-1; i++ { - if bytes.Equal(schnorr.SerializePubKey(sortedKeys[i]), schnorr.SerializePubKey(sortedKeys[i+1])) { - return nil, fmt.Errorf("duplicate key in list of keys") - } - } + sortedKeys := SortKeys(keys) return sortedKeys, nil } // buildMultiSigScript creates multisig script with given keys and signer threshold to // successfully execute script -// it validates whether provided keys are unique and the threshold is not greater than number of keys +// it validates whether threshold is not greater than number of keys // If there is only one key provided it will return single key sig script +// Note: It is up to the caller to ensure that the keys are unique func buildMultiSigScript( keys []*btcec.PublicKey, threshold uint32, diff --git a/btcstaking/staking.go b/btcstaking/staking.go index 47a224298..d82cb0f2a 100644 --- a/btcstaking/staking.go +++ b/btcstaking/staking.go @@ -6,6 +6,7 @@ import ( "fmt" sdkmath "cosmossdk.io/math" + "github.com/btcsuite/btcd/blockchain" "github.com/btcsuite/btcd/btcec/v2" "github.com/btcsuite/btcd/btcec/v2/schnorr" "github.com/btcsuite/btcd/btcutil" @@ -14,7 +15,7 @@ import ( "github.com/btcsuite/btcd/txscript" "github.com/btcsuite/btcd/wire" - asig "github.com/babylonchain/babylon/crypto/schnorr-adaptor-signature" + asig "github.com/babylonlabs-io/babylon/crypto/schnorr-adaptor-signature" ) // buildSlashingTxFromOutpoint builds a valid slashing transaction by creating a new Bitcoin transaction that slashes a portion @@ -44,7 +45,7 @@ func buildSlashingTxFromOutpoint( } // Validate slashing rate - if !IsSlashingRateValid(slashingRate) { + if !IsRateValid(slashingRate) { return nil, ErrInvalidSlashingRate } @@ -214,7 +215,7 @@ func IsSimpleTransfer(tx *wire.MsgTx) error { return nil } -// ValidateSlashingTx performs basic checks on a slashing transaction: +// validateSlashingTx performs basic checks on a slashing transaction: // - the slashing transaction is not nil. // - the slashing transaction has exactly one input. // - the slashing transaction is non-replaceable. @@ -225,7 +226,7 @@ func IsSimpleTransfer(tx *wire.MsgTx) error { // - neither of the outputs are considered dust. // // - the min fee for slashing tx is preserved -func ValidateSlashingTx( +func validateSlashingTx( slashingTx *wire.MsgTx, slashingAddress btcutil.Address, slashingRate sdkmath.LegacyDec, @@ -329,6 +330,7 @@ func ValidateSlashingTx( } // CheckTransactions 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 @@ -344,13 +346,25 @@ func CheckTransactions( slashingChangeLockTime uint16, net *chaincfg.Params, ) error { + if slashingTx == nil || fundingTransaction == nil { + 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) + } + // Check if slashing tx min fee is valid if slashingTxMinFee <= 0 { return fmt.Errorf("slashing transaction min fee must be larger than 0") } // Check if slashing rate is in the valid range (0,1) - if !IsSlashingRateValid(slashingRate) { + if !IsRateValid(slashingRate) { return ErrInvalidSlashingRate } @@ -360,7 +374,7 @@ func CheckTransactions( stakingOutput := fundingTransaction.TxOut[fundingOutputIdx] // 3. Check if slashing transaction is valid - if err := ValidateSlashingTx( + if err := validateSlashingTx( slashingTx, slashingAddress, slashingRate, @@ -575,28 +589,6 @@ func VerifyTransactionSigWithOutput( return fmt.Errorf("funding output must not be nil") } - return VerifyTransactionSigWithOutputData( - transaction, - fundingOutput.PkScript, - fundingOutput.Value, - script, - pubKey, - signature, - ) -} - -// VerifyTransactionSigWithOutputData verifies that: -// - provided transaction has exactly one input -// - provided signature is valid schnorr BIP340 signature -// - provided signature is signing whole provided transaction (SigHashDefault) -func VerifyTransactionSigWithOutputData( - transaction *wire.MsgTx, - fundingOutputPkScript []byte, - fundingOutputValue int64, - script []byte, - pubKey *btcec.PublicKey, - signature []byte) error { - if transaction == nil { return fmt.Errorf("tx to verify not be nil") } @@ -612,8 +604,8 @@ func VerifyTransactionSigWithOutputData( tapLeaf := txscript.NewBaseTapLeaf(script) inputFetcher := txscript.NewCannedPrevOutputFetcher( - fundingOutputPkScript, - fundingOutputValue, + fundingOutput.PkScript, + fundingOutput.Value, ) sigHashes := txscript.NewTxSigHashes(transaction, inputFetcher) @@ -641,14 +633,13 @@ func VerifyTransactionSigWithOutputData( return nil } -// EncVerifyTransactionSigWithOutputData verifies that: +// EncVerifyTransactionSigWithOutput verifies that: // - provided transaction has exactly one input // - provided signature is valid adaptor signature // - provided signature is signing whole provided transaction (SigHashDefault) -func EncVerifyTransactionSigWithOutputData( +func EncVerifyTransactionSigWithOutput( transaction *wire.MsgTx, - fundingOutputPkScript []byte, - fundingOutputValue int64, + fundingOut *wire.TxOut, script []byte, pubKey *btcec.PublicKey, encKey *asig.EncryptionKey, @@ -669,8 +660,8 @@ func EncVerifyTransactionSigWithOutputData( tapLeaf := txscript.NewBaseTapLeaf(script) inputFetcher := txscript.NewCannedPrevOutputFetcher( - fundingOutputPkScript, - fundingOutputValue, + fundingOut.PkScript, + fundingOut.Value, ) sigHashes := txscript.NewTxSigHashes(transaction, inputFetcher) diff --git a/btcstaking/staking_test.go b/btcstaking/staking_test.go index 1837bf719..b54c97c95 100644 --- a/btcstaking/staking_test.go +++ b/btcstaking/staking_test.go @@ -1,14 +1,16 @@ package btcstaking_test import ( + "errors" "fmt" "math" "math/rand" "testing" + "time" sdkmath "cosmossdk.io/math" - "github.com/babylonchain/babylon/btcstaking" - "github.com/babylonchain/babylon/testutil/datagen" + "github.com/babylonlabs-io/babylon/btcstaking" + "github.com/babylonlabs-io/babylon/testutil/datagen" "github.com/btcsuite/btcd/btcec/v2" "github.com/btcsuite/btcd/btcutil" "github.com/btcsuite/btcd/chaincfg" @@ -66,6 +68,12 @@ func FuzzGeneratingValidStakingSlashingTx(f *testing.F) { r := rand.New(rand.NewSource(seed)) // we do not care for inputs in staking tx stakingTx := wire.NewMsgTx(2) + bogusInputHashBytes := [32]byte{} + bogusInputHash, _ := chainhash.NewHash(bogusInputHashBytes[:]) + stakingTx.AddTxIn( + wire.NewTxIn(wire.NewOutPoint(bogusInputHash, 0), nil, nil), + ) + stakingOutputIdx := r.Intn(5) // always more outputs than stakingOutputIdx stakingTxNumOutputs := r.Intn(5) + 10 @@ -155,7 +163,7 @@ func testSlashingTx( &chaincfg.MainNetParams, ) - if btcstaking.IsSlashingRateValid(slashingRate) { + if btcstaking.IsRateValid(slashingRate) { // If the slashing rate is valid i.e., in the range (0,1) with at most 2 decimal places, // it is still possible that the slashing transaction is invalid. The following checks will confirm that // slashing tx is not constructed if @@ -240,3 +248,162 @@ func FuzzGeneratingSignatureValidation(f *testing.F) { require.NoError(t, err) }) } + +func TestSlashingTxWithOverflowMustNotAccepted(t *testing.T) { + r := rand.New(rand.NewSource(time.Now().Unix())) + // we do not care for inputs in staking tx + stakingTx := wire.NewMsgTx(2) + slashingLockTime := uint16(100) + minStakingValue := 10000 + minFee := 2000 + slashingRate := sdkmath.LegacyNewDecWithPrec(1000, 4) + sd := genValidStakingScriptData(t, r) + + info, err := btcstaking.BuildStakingInfo( + sd.StakerKey, + []*btcec.PublicKey{sd.FinalityProviderKey}, + []*btcec.PublicKey{sd.CovenantKey}, + 1, + sd.StakingTime, + btcutil.Amount(r.Intn(5000)+minStakingValue), + &chaincfg.MainNetParams, + ) + + require.NoError(t, err) + stakingTx.AddTxOut(info.StakingOutput) + bogusInputHashBytes := [32]byte{} + bogusInputHash, _ := chainhash.NewHash(bogusInputHashBytes[:]) + stakingTx.AddTxIn( + wire.NewTxIn(wire.NewOutPoint(bogusInputHash, 0), nil, nil), + ) + + slashingAddress, err := genRandomBTCAddress(r) + require.NoError(t, err) + + // Construct slashing transaction using the provided parameters + slashingTx, err := btcstaking.BuildSlashingTxFromStakingTxStrict( + stakingTx, + uint32(0), + slashingAddress, + sd.StakerKey, + slashingLockTime, + int64(minFee), + slashingRate, + &chaincfg.MainNetParams, + ) + require.NoError(t, err) + require.NotNil(t, slashingTx) + + slashingTx.TxOut[0].Value = math.MaxInt64 / 8 + slashingTx.TxOut[1].Value = math.MaxInt64 / 8 + + err = btcstaking.CheckTransactions( + slashingTx, + stakingTx, + uint32(0), + int64(minFee), + slashingRate, + slashingAddress, + sd.StakerKey, + slashingLockTime, + &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 ") +} + +func TestNotAllowStakerKeyToBeFinalityProviderKey(t *testing.T) { + r := rand.New(rand.NewSource(0)) + sd := genValidStakingScriptData(t, r) + + // Construct staking transaction using the provided parameters + stakingTx, err := btcstaking.BuildStakingInfo( + sd.StakerKey, + []*btcec.PublicKey{sd.StakerKey}, + []*btcec.PublicKey{sd.CovenantKey}, + 1, + sd.StakingTime, + btcutil.Amount(10000), + &chaincfg.MainNetParams, + ) + require.Nil(t, stakingTx) + require.Error(t, err) + require.True(t, errors.Is(err, btcstaking.ErrDuplicatedKeyInScript)) + + unbondingTx, err := btcstaking.BuildUnbondingInfo( + sd.StakerKey, + []*btcec.PublicKey{sd.StakerKey}, + []*btcec.PublicKey{sd.CovenantKey}, + 1, + sd.StakingTime, + btcutil.Amount(10000), + &chaincfg.MainNetParams, + ) + require.Nil(t, unbondingTx) + require.Error(t, err) + require.True(t, errors.Is(err, btcstaking.ErrDuplicatedKeyInScript)) +} + +func TestNotAllowStakerKeyToBeCovenantKey(t *testing.T) { + r := rand.New(rand.NewSource(0)) + sd := genValidStakingScriptData(t, r) + + // Construct staking transaction using the provided parameters + stakingTx, err := btcstaking.BuildStakingInfo( + sd.StakerKey, + []*btcec.PublicKey{sd.FinalityProviderKey}, + []*btcec.PublicKey{sd.StakerKey}, + 1, + sd.StakingTime, + btcutil.Amount(10000), + &chaincfg.MainNetParams, + ) + require.Nil(t, stakingTx) + require.Error(t, err) + require.True(t, errors.Is(err, btcstaking.ErrDuplicatedKeyInScript)) + + unbondingTx, err := btcstaking.BuildUnbondingInfo( + sd.StakerKey, + []*btcec.PublicKey{sd.FinalityProviderKey}, + []*btcec.PublicKey{sd.StakerKey}, + 1, + sd.StakingTime, + btcutil.Amount(10000), + &chaincfg.MainNetParams, + ) + require.Nil(t, unbondingTx) + require.Error(t, err) + require.True(t, errors.Is(err, btcstaking.ErrDuplicatedKeyInScript)) +} + +func TestNotAllowFinalityProviderKeysAsCovenantKeys(t *testing.T) { + r := rand.New(rand.NewSource(0)) + sd := genValidStakingScriptData(t, r) + + // Construct staking transaction using the provided parameters + stakingTx, err := btcstaking.BuildStakingInfo( + sd.StakerKey, + []*btcec.PublicKey{sd.FinalityProviderKey}, + []*btcec.PublicKey{sd.FinalityProviderKey}, + 1, + sd.StakingTime, + btcutil.Amount(10000), + &chaincfg.MainNetParams, + ) + require.Nil(t, stakingTx) + require.Error(t, err) + require.True(t, errors.Is(err, btcstaking.ErrDuplicatedKeyInScript)) + + unbondingTx, err := btcstaking.BuildUnbondingInfo( + sd.StakerKey, + []*btcec.PublicKey{sd.FinalityProviderKey}, + []*btcec.PublicKey{sd.FinalityProviderKey}, + 1, + sd.StakingTime, + btcutil.Amount(10000), + &chaincfg.MainNetParams, + ) + require.Nil(t, unbondingTx) + require.Error(t, err) + require.True(t, errors.Is(err, btcstaking.ErrDuplicatedKeyInScript)) +} diff --git a/btcstaking/staking_testvectors_test.go b/btcstaking/staking_testvectors_test.go new file mode 100644 index 000000000..b8e3613b7 --- /dev/null +++ b/btcstaking/staking_testvectors_test.go @@ -0,0 +1,433 @@ +package btcstaking_test + +import ( + "bytes" + "encoding/hex" + "encoding/json" + "fmt" + "os" + "testing" + + "github.com/btcsuite/btcd/btcec/v2" + "github.com/btcsuite/btcd/btcutil" + "github.com/btcsuite/btcd/chaincfg" + "github.com/btcsuite/btcd/chaincfg/chainhash" + "github.com/btcsuite/btcd/wire" + "github.com/stretchr/testify/require" + + "github.com/babylonlabs-io/babylon/btcstaking" +) + +func getBtcNetworkParams(network string) (*chaincfg.Params, error) { + switch network { + case "testnet3": + return &chaincfg.TestNet3Params, nil + case "mainnet": + return &chaincfg.MainNetParams, nil + case "regtest": + return &chaincfg.RegressionNetParams, nil + case "simnet": + return &chaincfg.SimNetParams, nil + case "signet": + return &chaincfg.SigNetParams, nil + default: + return nil, fmt.Errorf("unknown network %s", network) + } +} + +func serializeBTCTx(tx *wire.MsgTx) ([]byte, error) { + var txBuf bytes.Buffer + if err := tx.Serialize(&txBuf); err != nil { + return nil, err + } + return txBuf.Bytes(), nil +} + +func serializeBTCTxToHex(tx *wire.MsgTx) (string, error) { + bytes, err := serializeBTCTx(tx) + + if err != nil { + return "", err + } + + return hex.EncodeToString(bytes), nil +} + +func ReadTestCases() *TestCases { + // Open the JSON file + file, err := os.Open("./testvectors/vectors.json") + if err != nil { + panic(fmt.Errorf("Error opening file: %w", err)) + } + defer file.Close() + + // Create a decoder + decoder := json.NewDecoder(file) + + // Create a variable of the type of your struct + var cases TestCases + + // Decode the JSON data into the struct + if err := decoder.Decode(&cases); err != nil { + panic(fmt.Sprintf("Error decoding JSON: %s", err)) + } + + return &cases +} + +type Parameters struct { + CovenantPublicKeys []string `json:"covenant_public_keys"` + CovenantQuorum int `json:"covenant_quorum"` + FinalityProviderPublicKeys []string `json:"finality_provider_public_keys"` + StakerPublicKey string `json:"staker_public_key"` + StakingTime int `json:"staking_time"` + StakingValue int `json:"staking_value"` + StakingTxHash string `json:"staking_tx_hash"` + StakingOutputIndex int `json:"staking_output_index"` + UnbondingTxVersion int `json:"unbonding_tx_version"` + UnbondingTime int `json:"unbonding_time"` + UnbondingFee int `json:"unbonding_fee"` + Tag string `json:"tag"` + Network string `json:"network"` +} + +type Expected struct { + StakingOutputPkScript string `json:"staking_output_pkscript_hex"` + StakingOutputValue int `json:"staking_output_value"` + StakingTransactionTimeLockScript string `json:"staking_transaction_timelock_script_hex"` + StakingTransactionUnbondingScript string `json:"staking_transaction_unbonding_script_hex"` + StakingTransactionSlashingScript string `json:"staking_transaction_slashing_script_hex"` + UnbondingTransactionHex string `json:"unbonding_transaction_hex"` + UnbondingTransactionTimeLockScript string `json:"unbonding_transaction_time_lock_script_hex"` + UnbondingTransactionSlashingScript string `json:"unbonding_transaction_slashing_script_hex"` + OpReturnScript string `json:"op_return_script_hex"` +} + +type TestCase struct { + Description string `json:"name"` + Parameters *Parameters `json:"parameters"` + Expected *Expected `json:"expected"` +} + +type TestCases struct { + Test []TestCase `json:"vectors"` +} + +type ParsedParams struct { + CovenantPublicKeys []*btcec.PublicKey + CovenantQuorum uint32 + FinalityProviderPublicKeys []*btcec.PublicKey + StakerPublicKey *btcec.PublicKey + StakingTime uint16 + StakingValue btcutil.Amount + StakingTxHash *chainhash.Hash + StakingOutputIndex uint32 + UnbondingTxVersion uint32 + UnbondingTime uint16 + UnbondingFee btcutil.Amount + Tag []byte + Network *chaincfg.Params +} + +// function which parses Parameters +func parseTestParams(t *testing.T, p *Parameters) (*ParsedParams, error) { + covenantKeys := keysToPubKeys(t, p.CovenantPublicKeys) + finalityKeys := keysToPubKeys(t, p.FinalityProviderPublicKeys) + stakerPk := keysToPubKeys(t, []string{p.StakerPublicKey})[0] + + stakingTxHash, err := chainhash.NewHashFromStr(p.StakingTxHash) + if err != nil { + return nil, err + } + + tag, err := hex.DecodeString(p.Tag) + if err != nil { + return nil, err + } + + network, err := getBtcNetworkParams(p.Network) + if err != nil { + return nil, err + } + + return &ParsedParams{ + CovenantPublicKeys: covenantKeys, + CovenantQuorum: uint32(p.CovenantQuorum), + FinalityProviderPublicKeys: finalityKeys, + StakerPublicKey: stakerPk, + StakingTime: uint16(p.StakingTime), + StakingValue: btcutil.Amount(p.StakingValue), + StakingTxHash: stakingTxHash, + StakingOutputIndex: uint32(p.StakingOutputIndex), + UnbondingTxVersion: uint32(p.UnbondingTxVersion), + UnbondingTime: uint16(p.UnbondingTime), + UnbondingFee: btcutil.Amount(p.UnbondingFee), + Tag: tag, + Network: network, + }, nil +} + +func TestVectorsCompatiblity(t *testing.T) { + cases := ReadTestCases() + + for _, tc := range cases.Test { + t.Logf("Running test case: %s", tc.Description) + parsedParams, err := parseTestParams(t, tc.Parameters) + + if err != nil { + require.NoError(t, fmt.Errorf("error parsing test parameters for case %s: %w", tc.Description, err)) + } + + info, err := btcstaking.BuildStakingInfo( + parsedParams.StakerPublicKey, + parsedParams.FinalityProviderPublicKeys, + parsedParams.CovenantPublicKeys, + parsedParams.CovenantQuorum, + parsedParams.StakingTime, + parsedParams.StakingValue, + parsedParams.Network, + ) + + if err != nil { + require.NoError(t, fmt.Errorf("error building staking info for case %s: %w", tc.Description, err)) + } + + sti, err := info.TimeLockPathSpendInfo() + + if err != nil { + require.NoError(t, fmt.Errorf("error building staking timelock path spend info for case %s: %w", tc.Description, err)) + } + + sui, err := info.UnbondingPathSpendInfo() + + if err != nil { + require.NoError(t, fmt.Errorf("error building staking unbonding path spend info for case %s: %w", tc.Description, err)) + } + + ssi, err := info.SlashingPathSpendInfo() + + if err != nil { + require.NoError(t, fmt.Errorf("error building staking slashing path spend info for case %s: %w", tc.Description, err)) + } + + ubInfo, err := btcstaking.BuildUnbondingInfo( + parsedParams.StakerPublicKey, + parsedParams.FinalityProviderPublicKeys, + parsedParams.CovenantPublicKeys, + parsedParams.CovenantQuorum, + parsedParams.UnbondingTime, + parsedParams.StakingValue-parsedParams.UnbondingFee, + parsedParams.Network, + ) + + if err != nil { + require.NoError(t, fmt.Errorf("error building unbonding info for case %s: %w", tc.Description, err)) + } + + uti, err := ubInfo.TimeLockPathSpendInfo() + if err != nil { + require.NoError(t, fmt.Errorf("error building unbonding timelock path spend info for case %s: %w", tc.Description, err)) + } + usi, err := ubInfo.SlashingPathSpendInfo() + + if err != nil { + require.NoError(t, fmt.Errorf("error building unbonding slashing path spend info for case %s: %w", tc.Description, err)) + } + + ubtTx := wire.NewMsgTx(2) + ubtTx.AddTxIn(wire.NewTxIn( + wire.NewOutPoint( + parsedParams.StakingTxHash, + parsedParams.StakingOutputIndex, + ), + nil, + nil, + )) + ubtTx.AddTxOut(ubInfo.UnbondingOutput) + + serializedUbtTx, err := serializeBTCTx(ubtTx) + if err != nil { + require.NoError(t, fmt.Errorf("error serializing unbonding tx for case %s: %w", tc.Description, err)) + } + + require.Equal(t, tc.Expected.StakingOutputPkScript, hex.EncodeToString(info.StakingOutput.PkScript), fmt.Sprintf("failed case: %s", tc.Description)) + require.Equal(t, tc.Expected.StakingOutputValue, int(info.StakingOutput.Value), fmt.Sprintf("failed case: %s", tc.Description)) + require.Equal(t, tc.Expected.StakingTransactionTimeLockScript, hex.EncodeToString(sti.RevealedLeaf.Script), fmt.Sprintf("failed case: %s", tc.Description)) + require.Equal(t, tc.Expected.StakingTransactionUnbondingScript, hex.EncodeToString(sui.RevealedLeaf.Script), fmt.Sprintf("failed case: %s", tc.Description)) + require.Equal(t, tc.Expected.StakingTransactionSlashingScript, hex.EncodeToString(ssi.RevealedLeaf.Script), fmt.Sprintf("failed case: %s", tc.Description)) + require.Equal(t, tc.Expected.UnbondingTransactionHex, hex.EncodeToString(serializedUbtTx), fmt.Sprintf("failed case: %s", tc.Description)) + require.Equal(t, tc.Expected.UnbondingTransactionTimeLockScript, hex.EncodeToString(uti.RevealedLeaf.Script), fmt.Sprintf("failed case: %s", tc.Description)) + require.Equal(t, tc.Expected.UnbondingTransactionSlashingScript, hex.EncodeToString(usi.RevealedLeaf.Script), fmt.Sprintf("failed case: %s", tc.Description)) + + if tc.Expected.OpReturnScript != "" { + data, err := btcstaking.NewV0OpReturnDataFromParsed( + parsedParams.Tag, + parsedParams.StakerPublicKey, + parsedParams.FinalityProviderPublicKeys[0], + parsedParams.StakingTime, + ) + + if err != nil { + require.NoError(t, fmt.Errorf("error building op_return data for case %s: %w", tc.Description, err)) + } + + opReturnOutput, err := data.ToTxOutput() + + if err != nil { + require.NoError(t, fmt.Errorf("error building op_return output for case %s: %w", tc.Description, err)) + } + + require.Equal(t, tc.Expected.OpReturnScript, hex.EncodeToString(opReturnOutput.PkScript), fmt.Sprintf("failed case: %s", tc.Description)) + } + } +} + +func generateKeys(t *testing.T, num int) []string { + var keys []string + + for i := 0; i < num; i++ { + k, err := btcec.NewPrivateKey() + require.NoError(t, err) + + keys = append(keys, hex.EncodeToString(k.PubKey().SerializeCompressed())) + } + return keys +} + +func keysToPubKeys(t *testing.T, keys []string) []*btcec.PublicKey { + var pks []*btcec.PublicKey + + for _, key := range keys { + b, err := hex.DecodeString(key) + require.NoError(t, err) + + pk, err := btcec.ParsePubKey(b) + require.NoError(t, err) + + pks = append(pks, pk) + } + + return pks +} + +// helper to easily generate test cases +func GenerateTestCase( + t *testing.T, + desc string, + numCovenantKeys int, + covenantQuorum int, + numFinalityKeys int, + stakingAmout int, + stakingTime int, + unbondingTime int, + unbondingFee int, + tag []byte, +) string { + emptyHash := [32]byte{} + eh, err := chainhash.NewHash(emptyHash[:]) + require.NoError(t, err) + covenantKeys := generateKeys(t, numCovenantKeys) + finalityKeys := generateKeys(t, numFinalityKeys) + stakerKeys := generateKeys(t, 1) + + info, err := btcstaking.BuildStakingInfo( + keysToPubKeys(t, stakerKeys)[0], + keysToPubKeys(t, finalityKeys), + keysToPubKeys(t, covenantKeys), + uint32(covenantQuorum), + uint16(stakingTime), + btcutil.Amount(stakingAmout), + &chaincfg.MainNetParams, + ) + require.NoError(t, err) + sti, err := info.TimeLockPathSpendInfo() + require.NoError(t, err) + sui, err := info.UnbondingPathSpendInfo() + require.NoError(t, err) + ssi, err := info.SlashingPathSpendInfo() + require.NoError(t, err) + + unbondingInfo, err := btcstaking.BuildUnbondingInfo( + keysToPubKeys(t, stakerKeys)[0], + keysToPubKeys(t, finalityKeys), + keysToPubKeys(t, covenantKeys), + uint32(covenantQuorum), + uint16(unbondingTime), + btcutil.Amount(stakingAmout)-btcutil.Amount(unbondingFee), + &chaincfg.MainNetParams, + ) + + require.NoError(t, err) + + ubtTx := wire.NewMsgTx(2) + ubtTx.AddTxIn(wire.NewTxIn( + wire.NewOutPoint( + eh, + 0, + ), + nil, + nil, + )) + ubtTx.AddTxOut(unbondingInfo.UnbondingOutput) + ubtTxHex, err := serializeBTCTxToHex(ubtTx) + require.NoError(t, err) + uti, err := unbondingInfo.TimeLockPathSpendInfo() + require.NoError(t, err) + usi, err := unbondingInfo.SlashingPathSpendInfo() + require.NoError(t, err) + + opReturnOutput := "" + // if there is more build op_return output + if len(finalityKeys) == 1 { + opInfo, err := btcstaking.BuildV0IdentifiableStakingOutputs( + tag, + keysToPubKeys(t, stakerKeys)[0], + keysToPubKeys(t, finalityKeys)[0], + keysToPubKeys(t, covenantKeys), + uint32(covenantQuorum), + uint16(stakingTime), + btcutil.Amount(stakingAmout), + &chaincfg.MainNetParams, + ) + require.NoError(t, err) + opReturnOutput = hex.EncodeToString(opInfo.OpReturnOutput.PkScript) + } + + params := Parameters{ + CovenantPublicKeys: covenantKeys, + CovenantQuorum: covenantQuorum, + FinalityProviderPublicKeys: finalityKeys, + StakerPublicKey: stakerKeys[0], + StakingTime: stakingTime, + StakingValue: stakingAmout, + StakingTxHash: eh.String(), + StakingOutputIndex: 0, + UnbondingTxVersion: 2, + UnbondingTime: unbondingTime, + UnbondingFee: unbondingFee, + Tag: hex.EncodeToString(tag), + Network: "mainnet", + } + + expected := Expected{ + StakingOutputPkScript: hex.EncodeToString(info.StakingOutput.PkScript), + StakingOutputValue: int(info.StakingOutput.Value), + StakingTransactionTimeLockScript: hex.EncodeToString(sti.RevealedLeaf.Script), + StakingTransactionUnbondingScript: hex.EncodeToString(sui.RevealedLeaf.Script), + StakingTransactionSlashingScript: hex.EncodeToString(ssi.RevealedLeaf.Script), + UnbondingTransactionHex: ubtTxHex, + UnbondingTransactionTimeLockScript: hex.EncodeToString(uti.RevealedLeaf.Script), + UnbondingTransactionSlashingScript: hex.EncodeToString(usi.RevealedLeaf.Script), + OpReturnScript: opReturnOutput, + } + + tc := TestCase{ + Description: desc, + Parameters: ¶ms, + Expected: &expected, + } + + marshaled, err := json.MarshalIndent(&tc, "", "") + require.NoError(t, err) + return string(marshaled) +} diff --git a/btcstaking/staking_utils_test.go b/btcstaking/staking_utils_test.go new file mode 100644 index 000000000..7cb2da873 --- /dev/null +++ b/btcstaking/staking_utils_test.go @@ -0,0 +1,35 @@ +package btcstaking_test + +import ( + "math/rand" + "testing" + "time" + + "github.com/babylonlabs-io/babylon/btcstaking" + "github.com/babylonlabs-io/babylon/testutil/datagen" + bbn "github.com/babylonlabs-io/babylon/types" + "github.com/btcsuite/btcd/btcec/v2/schnorr" + "github.com/stretchr/testify/require" +) + +func TestSortKeys(t *testing.T) { + r := rand.New(rand.NewSource(time.Now().Unix())) + + _, pks, err := datagen.GenRandomBTCKeyPairs(r, 10) + require.NoError(t, err) + + sortedPKs := btcstaking.SortKeys(pks) + + btcPKs := bbn.NewBIP340PKsFromBTCPKs(pks) + sortedBTCPKs := bbn.SortBIP340PKs(btcPKs) + + // ensure sorted PKs and sorted BIP340 PKs are in reverse order + for i := range sortedPKs { + pkBytes := schnorr.SerializePubKey(sortedPKs[i]) + + btcPK := sortedBTCPKs[len(sortedBTCPKs)-1-i] + btcPKBytes := btcPK.MustMarshal() + + require.Equal(t, pkBytes, btcPKBytes, "comparing %d-th key", i) + } +} diff --git a/btcstaking/testvectors/vectors.json b/btcstaking/testvectors/vectors.json new file mode 100644 index 000000000..a3272abf5 --- /dev/null +++ b/btcstaking/testvectors/vectors.json @@ -0,0 +1,215 @@ +{ + "vectors": [ + { + "name": "1 finality key, 1 covenant key, 1 staker key with op_return", + "parameters": { + "covenant_public_keys": [ + "024852a5d3e79cfdee1bda4ea729e879c1db0f19230eadd3cb96d3cb1efa8d30fa" + ], + "covenant_quorum": 1, + "finality_provider_public_keys": [ + "0246542ccdcbde8a8c147c8d00f14d47f0d5c13c684d27497fc4610c7a4def15e5" + ], + "staker_public_key": "024000bd2c8b975d351c5f3a42618aca31e07e2b253fcd571e9630540a3cb6eafd", + "staking_time": 1000, + "staking_value": 100000, + "staking_tx_hash": "0000000000000000000000000000000000000000000000000000000000000000", + "staking_output_index": 0, + "unbonding_tx_version": 2, + "unbonding_time": 100, + "unbonding_fee": 2000, + "tag": "01020304", + "network": "mainnet" + }, + "expected": { + "staking_output_pkscript_hex": "5120b2b169d39fb8ea9828f6ed8dbbeaa12594706d03bfd1638a912608a085fdd7a5", + "staking_output_value": 100000, + "staking_transaction_timelock_script_hex": "204000bd2c8b975d351c5f3a42618aca31e07e2b253fcd571e9630540a3cb6eafdad02e803b2", + "staking_transaction_unbonding_script_hex": "204000bd2c8b975d351c5f3a42618aca31e07e2b253fcd571e9630540a3cb6eafdad204852a5d3e79cfdee1bda4ea729e879c1db0f19230eadd3cb96d3cb1efa8d30faac", + "staking_transaction_slashing_script_hex": "204000bd2c8b975d351c5f3a42618aca31e07e2b253fcd571e9630540a3cb6eafdad2046542ccdcbde8a8c147c8d00f14d47f0d5c13c684d27497fc4610c7a4def15e5ad204852a5d3e79cfdee1bda4ea729e879c1db0f19230eadd3cb96d3cb1efa8d30faac", + "unbonding_transaction_hex": "020000000100000000000000000000000000000000000000000000000000000000000000000000000000ffffffff01d07e01000000000022512071f38cba0e3c0453eb34ac8f9a60805965e9500a9ab69724f636a00fcafc252f00000000", + "unbonding_transaction_time_lock_script_hex": "204000bd2c8b975d351c5f3a42618aca31e07e2b253fcd571e9630540a3cb6eafdad0164b2", + "unbonding_transaction_slashing_script_hex": "204000bd2c8b975d351c5f3a42618aca31e07e2b253fcd571e9630540a3cb6eafdad2046542ccdcbde8a8c147c8d00f14d47f0d5c13c684d27497fc4610c7a4def15e5ad204852a5d3e79cfdee1bda4ea729e879c1db0f19230eadd3cb96d3cb1efa8d30faac", + "op_return_script_hex": "6a4701020304004000bd2c8b975d351c5f3a42618aca31e07e2b253fcd571e9630540a3cb6eafd46542ccdcbde8a8c147c8d00f14d47f0d5c13c684d27497fc4610c7a4def15e503e8" + } + }, + { + "name": "1 finality key, 3/5 covenant committe, 1 staker key with op_return", + "parameters": { + "covenant_public_keys": [ + "02cc5c77da065c490a320834fdcf2c3da70ecd442054c90f874a1edb4669607b83", + "022f57b6d267043beda2deebab1187a67316121f1eac24047c16d1209c5e6cd0a5", + "03784bdab9a1c71ea51fa5904227e721681453e59d20af3d97485e79e5518bdfff", + "03f31cf8fb9ee1d9157e172d65b1bd00a0b54cee3906df13ced709bfd8d407e9a2", + "035c3e1bb7c6b475a9caeebcb09fab74546a9b8a364dd0ccede7e5aea5c5b12ed0" + ], + "covenant_quorum": 3, + "finality_provider_public_keys": [ + "03b5e37d93a8d04daee62838ac680ead407d7cbe0c858525781f8834495be0bce7" + ], + "staker_public_key": "03cc327c2a1ee1a70d7033bee61ed2e3e6ffc7c5f5d6c637c4f0d2ddfae8a257fe", + "staking_time": 10000, + "staking_value": 1000000, + "staking_tx_hash": "0000000000000000000000000000000000000000000000000000000000000000", + "staking_output_index": 0, + "unbonding_tx_version": 2, + "unbonding_time": 50, + "unbonding_fee": 20000, + "tag": "01020304", + "network": "mainnet" + }, + "expected": { + "staking_output_pkscript_hex": "5120bbc6be1fff9cb4d93cb638f0fc9e5df7036c137b89c8baa762fb8637acdf3da7", + "staking_output_value": 1000000, + "staking_transaction_timelock_script_hex": "20cc327c2a1ee1a70d7033bee61ed2e3e6ffc7c5f5d6c637c4f0d2ddfae8a257fead021027b2", + "staking_transaction_unbonding_script_hex": "20cc327c2a1ee1a70d7033bee61ed2e3e6ffc7c5f5d6c637c4f0d2ddfae8a257fead202f57b6d267043beda2deebab1187a67316121f1eac24047c16d1209c5e6cd0a5ac205c3e1bb7c6b475a9caeebcb09fab74546a9b8a364dd0ccede7e5aea5c5b12ed0ba20784bdab9a1c71ea51fa5904227e721681453e59d20af3d97485e79e5518bdfffba20cc5c77da065c490a320834fdcf2c3da70ecd442054c90f874a1edb4669607b83ba20f31cf8fb9ee1d9157e172d65b1bd00a0b54cee3906df13ced709bfd8d407e9a2ba539c", + "staking_transaction_slashing_script_hex": "20cc327c2a1ee1a70d7033bee61ed2e3e6ffc7c5f5d6c637c4f0d2ddfae8a257fead20b5e37d93a8d04daee62838ac680ead407d7cbe0c858525781f8834495be0bce7ad202f57b6d267043beda2deebab1187a67316121f1eac24047c16d1209c5e6cd0a5ac205c3e1bb7c6b475a9caeebcb09fab74546a9b8a364dd0ccede7e5aea5c5b12ed0ba20784bdab9a1c71ea51fa5904227e721681453e59d20af3d97485e79e5518bdfffba20cc5c77da065c490a320834fdcf2c3da70ecd442054c90f874a1edb4669607b83ba20f31cf8fb9ee1d9157e172d65b1bd00a0b54cee3906df13ced709bfd8d407e9a2ba539c", + "unbonding_transaction_hex": "020000000100000000000000000000000000000000000000000000000000000000000000000000000000ffffffff0120f40e0000000000225120d4ea23776e49e47df891d52a42a2ec389786aa3bdafa874b5e69df13070fb4bf00000000", + "unbonding_transaction_time_lock_script_hex": "20cc327c2a1ee1a70d7033bee61ed2e3e6ffc7c5f5d6c637c4f0d2ddfae8a257fead0132b2", + "unbonding_transaction_slashing_script_hex": "20cc327c2a1ee1a70d7033bee61ed2e3e6ffc7c5f5d6c637c4f0d2ddfae8a257fead20b5e37d93a8d04daee62838ac680ead407d7cbe0c858525781f8834495be0bce7ad202f57b6d267043beda2deebab1187a67316121f1eac24047c16d1209c5e6cd0a5ac205c3e1bb7c6b475a9caeebcb09fab74546a9b8a364dd0ccede7e5aea5c5b12ed0ba20784bdab9a1c71ea51fa5904227e721681453e59d20af3d97485e79e5518bdfffba20cc5c77da065c490a320834fdcf2c3da70ecd442054c90f874a1edb4669607b83ba20f31cf8fb9ee1d9157e172d65b1bd00a0b54cee3906df13ced709bfd8d407e9a2ba539c", + "op_return_script_hex": "6a470102030400cc327c2a1ee1a70d7033bee61ed2e3e6ffc7c5f5d6c637c4f0d2ddfae8a257feb5e37d93a8d04daee62838ac680ead407d7cbe0c858525781f8834495be0bce72710" + } + }, + { + "name": "3 finality keys, 3/5 covenant committe, 1 staker key with no op_return", + "parameters": { + "covenant_public_keys": [ + "02042916c9cd52cfa146118c37b6b118f082bb50fb91da1c51b76dfc2100e66f00", + "03a2bfd2843357efda60fd26238b6affe6cbafa65d1f3cfbfb63ae3841d35887e6", + "035df1524dfc57fc1b0288ebac9b7abbcf5c61cfbfb8e4667ae0009445b04ecf22", + "03652ea9ac1c526218691e6b94769beaebbaedda080c5f1f036c239d5af69088b6", + "02dca4c9e5848db62e0f62e2c1cafca10f4464c10ae00bf579a8f7b5d81cd697f6" + ], + "covenant_quorum": 3, + "finality_provider_public_keys": [ + "0275e96ca4067b937f8e93bcb962523a1713c25d2af1a26f61034dd81f4e4687fe", + "0396c5c62af047a0839f8ea2b230315db93af25fa7074c71a2b95deeb47e507a63", + "034d4fb121fbe9f13ed7b55440fb9f3ad0f8bce8bd92589423b5f90d871db5142d" + ], + "staker_public_key": "037b251c30f5bd7a29f3b1749d599c60f2bcdc11553e500a6c32e4075b80d5bd29", + "staking_time": 10000, + "staking_value": 1000000, + "staking_tx_hash": "0000000000000000000000000000000000000000000000000000000000000000", + "staking_output_index": 0, + "unbonding_tx_version": 2, + "unbonding_time": 50, + "unbonding_fee": 20000, + "tag": "01020304", + "network": "mainnet" + }, + "expected": { + "staking_output_pkscript_hex": "51206136db5cccc1b9fca70164b3445020d6f6f8dd1428e78cef9111b295bd4eec89", + "staking_output_value": 1000000, + "staking_transaction_timelock_script_hex": "207b251c30f5bd7a29f3b1749d599c60f2bcdc11553e500a6c32e4075b80d5bd29ad021027b2", + "staking_transaction_unbonding_script_hex": "207b251c30f5bd7a29f3b1749d599c60f2bcdc11553e500a6c32e4075b80d5bd29ad20042916c9cd52cfa146118c37b6b118f082bb50fb91da1c51b76dfc2100e66f00ac205df1524dfc57fc1b0288ebac9b7abbcf5c61cfbfb8e4667ae0009445b04ecf22ba20652ea9ac1c526218691e6b94769beaebbaedda080c5f1f036c239d5af69088b6ba20a2bfd2843357efda60fd26238b6affe6cbafa65d1f3cfbfb63ae3841d35887e6ba20dca4c9e5848db62e0f62e2c1cafca10f4464c10ae00bf579a8f7b5d81cd697f6ba539c", + "staking_transaction_slashing_script_hex": "207b251c30f5bd7a29f3b1749d599c60f2bcdc11553e500a6c32e4075b80d5bd29ad204d4fb121fbe9f13ed7b55440fb9f3ad0f8bce8bd92589423b5f90d871db5142dac2075e96ca4067b937f8e93bcb962523a1713c25d2af1a26f61034dd81f4e4687feba2096c5c62af047a0839f8ea2b230315db93af25fa7074c71a2b95deeb47e507a63ba519d20042916c9cd52cfa146118c37b6b118f082bb50fb91da1c51b76dfc2100e66f00ac205df1524dfc57fc1b0288ebac9b7abbcf5c61cfbfb8e4667ae0009445b04ecf22ba20652ea9ac1c526218691e6b94769beaebbaedda080c5f1f036c239d5af69088b6ba20a2bfd2843357efda60fd26238b6affe6cbafa65d1f3cfbfb63ae3841d35887e6ba20dca4c9e5848db62e0f62e2c1cafca10f4464c10ae00bf579a8f7b5d81cd697f6ba539c", + "unbonding_transaction_hex": "020000000100000000000000000000000000000000000000000000000000000000000000000000000000ffffffff0120f40e0000000000225120a52e08ebd0db898e6a52870ca3e72a78391b799eac97a1675eccd416adace90e00000000", + "unbonding_transaction_time_lock_script_hex": "207b251c30f5bd7a29f3b1749d599c60f2bcdc11553e500a6c32e4075b80d5bd29ad0132b2", + "unbonding_transaction_slashing_script_hex": "207b251c30f5bd7a29f3b1749d599c60f2bcdc11553e500a6c32e4075b80d5bd29ad204d4fb121fbe9f13ed7b55440fb9f3ad0f8bce8bd92589423b5f90d871db5142dac2075e96ca4067b937f8e93bcb962523a1713c25d2af1a26f61034dd81f4e4687feba2096c5c62af047a0839f8ea2b230315db93af25fa7074c71a2b95deeb47e507a63ba519d20042916c9cd52cfa146118c37b6b118f082bb50fb91da1c51b76dfc2100e66f00ac205df1524dfc57fc1b0288ebac9b7abbcf5c61cfbfb8e4667ae0009445b04ecf22ba20652ea9ac1c526218691e6b94769beaebbaedda080c5f1f036c239d5af69088b6ba20a2bfd2843357efda60fd26238b6affe6cbafa65d1f3cfbfb63ae3841d35887e6ba20dca4c9e5848db62e0f62e2c1cafca10f4464c10ae00bf579a8f7b5d81cd697f6ba539c", + "op_return_script_hex": "" + } + }, + { + "name": "1 finality keys, 7/9 covenant committe, 1 staker key with op_return", + "parameters": { + "covenant_public_keys": [ + "0287ed5bb2d036baf209eb49520327f6bd05285dabd30c97f239c3a69ff419950b", + "02ce45e9c7828b2f1b52f29076b0fbbac380db5e6a8318cb7718c99e0b3fe6228f", + "0354967fa36311ba41a19a725925a68053579122e7e833c5b76a7dde99eec8fb31", + "02cdf01d771c38b4ee3363daf4d33c25796adbade4da3f621e954fd1d2e40d7c1f", + "038a7f080c5629980a5f3ccbfb1ea8a1bc20e7ce0dccbfefe3f35620e69c589e63", + "03b2729d612586227170a2116d9f97e2728f7cdc5f1c2e8eb4c4acd35a143917fd", + "0357925d2886601e7d9cecc60352cf435111f429b3fc97be8704dbf1f0fe491089", + "0369769314404fb9c68cd5c77adb2a5837372c4d5e5ef5d564e8de98f886a1a13e", + "02792a29aeaaaa1bc69ed57612ef050b29345e6f987951b2e22fcb00195b3ae2d5" + ], + "covenant_quorum": 7, + "finality_provider_public_keys": [ + "03bc9d21a6400b831e1741056dd45aaeecd42f23fafdf3ea49b815e49ebb4f95fc" + ], + "staker_public_key": "03a9200483d40c3c81a7a983a8f0a0de37955fbea587595b4bf8fcb878d857c0c0", + "staking_time": 20000, + "staking_value": 10000000, + "staking_tx_hash": "0000000000000000000000000000000000000000000000000000000000000000", + "staking_output_index": 0, + "unbonding_tx_version": 2, + "unbonding_time": 201, + "unbonding_fee": 50000, + "tag": "01020304", + "network": "mainnet" + }, + "expected": { + "staking_output_pkscript_hex": "51208b763bd20b8bca50c7bc059e3c7810471bfe30111f546bbbf4d879e437dd6ae2", + "staking_output_value": 10000000, + "staking_transaction_timelock_script_hex": "20a9200483d40c3c81a7a983a8f0a0de37955fbea587595b4bf8fcb878d857c0c0ad02204eb2", + "staking_transaction_unbonding_script_hex": "20a9200483d40c3c81a7a983a8f0a0de37955fbea587595b4bf8fcb878d857c0c0ad2054967fa36311ba41a19a725925a68053579122e7e833c5b76a7dde99eec8fb31ac2057925d2886601e7d9cecc60352cf435111f429b3fc97be8704dbf1f0fe491089ba2069769314404fb9c68cd5c77adb2a5837372c4d5e5ef5d564e8de98f886a1a13eba20792a29aeaaaa1bc69ed57612ef050b29345e6f987951b2e22fcb00195b3ae2d5ba2087ed5bb2d036baf209eb49520327f6bd05285dabd30c97f239c3a69ff419950bba208a7f080c5629980a5f3ccbfb1ea8a1bc20e7ce0dccbfefe3f35620e69c589e63ba20b2729d612586227170a2116d9f97e2728f7cdc5f1c2e8eb4c4acd35a143917fdba20cdf01d771c38b4ee3363daf4d33c25796adbade4da3f621e954fd1d2e40d7c1fba20ce45e9c7828b2f1b52f29076b0fbbac380db5e6a8318cb7718c99e0b3fe6228fba579c", + "staking_transaction_slashing_script_hex": "20a9200483d40c3c81a7a983a8f0a0de37955fbea587595b4bf8fcb878d857c0c0ad20bc9d21a6400b831e1741056dd45aaeecd42f23fafdf3ea49b815e49ebb4f95fcad2054967fa36311ba41a19a725925a68053579122e7e833c5b76a7dde99eec8fb31ac2057925d2886601e7d9cecc60352cf435111f429b3fc97be8704dbf1f0fe491089ba2069769314404fb9c68cd5c77adb2a5837372c4d5e5ef5d564e8de98f886a1a13eba20792a29aeaaaa1bc69ed57612ef050b29345e6f987951b2e22fcb00195b3ae2d5ba2087ed5bb2d036baf209eb49520327f6bd05285dabd30c97f239c3a69ff419950bba208a7f080c5629980a5f3ccbfb1ea8a1bc20e7ce0dccbfefe3f35620e69c589e63ba20b2729d612586227170a2116d9f97e2728f7cdc5f1c2e8eb4c4acd35a143917fdba20cdf01d771c38b4ee3363daf4d33c25796adbade4da3f621e954fd1d2e40d7c1fba20ce45e9c7828b2f1b52f29076b0fbbac380db5e6a8318cb7718c99e0b3fe6228fba579c", + "unbonding_transaction_hex": "020000000100000000000000000000000000000000000000000000000000000000000000000000000000ffffffff0130d3970000000000225120bd14e11a13e473ed65a7233cd8ae5ccae670fedc9b50bb99c1a09b9cff669fc800000000", + "unbonding_transaction_time_lock_script_hex": "20a9200483d40c3c81a7a983a8f0a0de37955fbea587595b4bf8fcb878d857c0c0ad02c900b2", + "unbonding_transaction_slashing_script_hex": "20a9200483d40c3c81a7a983a8f0a0de37955fbea587595b4bf8fcb878d857c0c0ad20bc9d21a6400b831e1741056dd45aaeecd42f23fafdf3ea49b815e49ebb4f95fcad2054967fa36311ba41a19a725925a68053579122e7e833c5b76a7dde99eec8fb31ac2057925d2886601e7d9cecc60352cf435111f429b3fc97be8704dbf1f0fe491089ba2069769314404fb9c68cd5c77adb2a5837372c4d5e5ef5d564e8de98f886a1a13eba20792a29aeaaaa1bc69ed57612ef050b29345e6f987951b2e22fcb00195b3ae2d5ba2087ed5bb2d036baf209eb49520327f6bd05285dabd30c97f239c3a69ff419950bba208a7f080c5629980a5f3ccbfb1ea8a1bc20e7ce0dccbfefe3f35620e69c589e63ba20b2729d612586227170a2116d9f97e2728f7cdc5f1c2e8eb4c4acd35a143917fdba20cdf01d771c38b4ee3363daf4d33c25796adbade4da3f621e954fd1d2e40d7c1fba20ce45e9c7828b2f1b52f29076b0fbbac380db5e6a8318cb7718c99e0b3fe6228fba579c", + "op_return_script_hex": "6a470102030400a9200483d40c3c81a7a983a8f0a0de37955fbea587595b4bf8fcb878d857c0c0bc9d21a6400b831e1741056dd45aaeecd42f23fafdf3ea49b815e49ebb4f95fc4e20" + } + }, + { + "name": "10 finality keys, 18/20 covenant committe, 1 staker key with no op_return", + "parameters": { + "covenant_public_keys": [ + "02e3803a6ecff76daf35709c8484f382783d211970f22397d7a258f40ca3b46304", + "03378f464f4365136230d30c3ad7d6425457d6c0742ed7fefd1015f0040cc70769", + "03583c7fbf7450f8f78977b8c9f2981ff10676efefb6399ec925ba54eed7978a2e", + "021fccb5af3a431a928c32267e556f1ba256871f98428419fae1cce6e7b8356cb9", + "03243b84dd7a170a6e1edc32b22357b20f8365a4149a12ef1d340342701d535991", + "037947f704a584a804c91d07250239ec528300bd01dd3137770f7227309f63db0a", + "021e435d3bbab5fb0244c273e38d6f078bfe57a1bd151016ab5c4ac84457d724b3", + "039010f319cde80190717d96dd60823b8e05905a2da458c69f4de19d5c9226cca8", + "03db2bb56299fe3219ea5901198d1872f0523234d529a29fa912a76c9cb6d70db6", + "030f14729c14b6a9b292e7b5142fc5483d7c25196af1ef4b9722ea5821719e2c40", + "02dbf2c13d6e3b0a8ad7286966bd00164ca0a163b483d305df6b492119cbffbabb", + "03f399ff078d6d954a390f67989705ed21e575ccf43a1340ca8752cd1613ca7ce0", + "030feacb370b7fcfcdd5ee7a363d73fda02d596ce61fd00e308d0ab68a7b955f48", + "022367edcf01edd517d46c1b3cc3d40f5a28608e0313636dd09b0904799bccd635", + "03a63763c4100bacdb1c06e5e1ba5599e379a2e23553d56d2b1d0ee3c990bd1192", + "0364df415d63ef3ce23ddd639c4a5ec8fdbfa67254db91228ca77fbec9610367ae", + "03f6a33481886c7d5ed5429c3bb0a83dbdefafd6d140b22a87aa7081cf7073136c", + "0336612620ae82332e4f5da8d78d0d8a4ff7c8b09e88ee988b3dde18ef6a04c497", + "03e0647bb72f1b3d33d69f360d7e9f58f6a693d40b6ef58f49f140a212bf16931c", + "0339eca9e5cf04e22471d6cde649604e6fd0aae077cd5b1af9a1dc26e56d8502f3" + ], + "covenant_quorum": 18, + "finality_provider_public_keys": [ + "027bb40e3cb76545a71fafcb29738fb27b452c3176b41ffd614f7231b40ff5ce68", + "0378c5d7a263ab7e98e311c8d2d7305d13d78a014d4ae0603b427bb55cb42dbed1", + "03f1209d7248936f9ff2fa7b0ec97e5c0d26e4f41ad6de9f2e423128780da5dfec", + "0350eff2669c6d83f858937cd9229fc93ad57c10cc8d8cfb7ec9bc40e32a9f7ff2", + "03fe96402099f8387ce0ddef84bee2d0f869b35bb599a58b9aaec4a73db08dc490", + "0329f526a81bc92dd2ed8cf1682fc4ae5956987f3f6d3c0da71fbcf230c71781ff", + "03cca2d8aa1feb47ad4933154ef8196db229cfbba676607c3c0583397d65a1e4ee", + "02ae3c70699ae235ddebef85378a550f796723a6b961dcff1f33716d5dbb096a1e", + "03a7165ffc90d12c25187b75b2ebdcb57b1c759e357d655d8371cfb96dc4df2ecc", + "034bcfb4042e5d13286fcd3d481b81a61cdfc3715aaf7909c4ee93de49356cd0b4" + ], + "staker_public_key": "037aa0dafe26a7b663b679418f2c19fe7ea1215919051aa5ac76e4a9fbef2f33c5", + "staking_time": 65535, + "staking_value": 100000000, + "staking_tx_hash": "0000000000000000000000000000000000000000000000000000000000000000", + "staking_output_index": 0, + "unbonding_tx_version": 2, + "unbonding_time": 201, + "unbonding_fee": 100000, + "tag": "01020304", + "network": "mainnet" + }, + "expected": { + "staking_output_pkscript_hex": "51205c7f92282283bf913e9a1cf7659b574104b4ca10095cb4cd293d77664e9d6a2d", + "staking_output_value": 100000000, + "staking_transaction_timelock_script_hex": "207aa0dafe26a7b663b679418f2c19fe7ea1215919051aa5ac76e4a9fbef2f33c5ad03ffff00b2", + "staking_transaction_unbonding_script_hex": "207aa0dafe26a7b663b679418f2c19fe7ea1215919051aa5ac76e4a9fbef2f33c5ad200f14729c14b6a9b292e7b5142fc5483d7c25196af1ef4b9722ea5821719e2c40ac200feacb370b7fcfcdd5ee7a363d73fda02d596ce61fd00e308d0ab68a7b955f48ba201e435d3bbab5fb0244c273e38d6f078bfe57a1bd151016ab5c4ac84457d724b3ba201fccb5af3a431a928c32267e556f1ba256871f98428419fae1cce6e7b8356cb9ba202367edcf01edd517d46c1b3cc3d40f5a28608e0313636dd09b0904799bccd635ba20243b84dd7a170a6e1edc32b22357b20f8365a4149a12ef1d340342701d535991ba2036612620ae82332e4f5da8d78d0d8a4ff7c8b09e88ee988b3dde18ef6a04c497ba20378f464f4365136230d30c3ad7d6425457d6c0742ed7fefd1015f0040cc70769ba2039eca9e5cf04e22471d6cde649604e6fd0aae077cd5b1af9a1dc26e56d8502f3ba20583c7fbf7450f8f78977b8c9f2981ff10676efefb6399ec925ba54eed7978a2eba2064df415d63ef3ce23ddd639c4a5ec8fdbfa67254db91228ca77fbec9610367aeba207947f704a584a804c91d07250239ec528300bd01dd3137770f7227309f63db0aba209010f319cde80190717d96dd60823b8e05905a2da458c69f4de19d5c9226cca8ba20a63763c4100bacdb1c06e5e1ba5599e379a2e23553d56d2b1d0ee3c990bd1192ba20db2bb56299fe3219ea5901198d1872f0523234d529a29fa912a76c9cb6d70db6ba20dbf2c13d6e3b0a8ad7286966bd00164ca0a163b483d305df6b492119cbffbabbba20e0647bb72f1b3d33d69f360d7e9f58f6a693d40b6ef58f49f140a212bf16931cba20e3803a6ecff76daf35709c8484f382783d211970f22397d7a258f40ca3b46304ba20f399ff078d6d954a390f67989705ed21e575ccf43a1340ca8752cd1613ca7ce0ba20f6a33481886c7d5ed5429c3bb0a83dbdefafd6d140b22a87aa7081cf7073136cba01129c", + "staking_transaction_slashing_script_hex": "207aa0dafe26a7b663b679418f2c19fe7ea1215919051aa5ac76e4a9fbef2f33c5ad2029f526a81bc92dd2ed8cf1682fc4ae5956987f3f6d3c0da71fbcf230c71781ffac204bcfb4042e5d13286fcd3d481b81a61cdfc3715aaf7909c4ee93de49356cd0b4ba2050eff2669c6d83f858937cd9229fc93ad57c10cc8d8cfb7ec9bc40e32a9f7ff2ba2078c5d7a263ab7e98e311c8d2d7305d13d78a014d4ae0603b427bb55cb42dbed1ba207bb40e3cb76545a71fafcb29738fb27b452c3176b41ffd614f7231b40ff5ce68ba20a7165ffc90d12c25187b75b2ebdcb57b1c759e357d655d8371cfb96dc4df2eccba20ae3c70699ae235ddebef85378a550f796723a6b961dcff1f33716d5dbb096a1eba20cca2d8aa1feb47ad4933154ef8196db229cfbba676607c3c0583397d65a1e4eeba20f1209d7248936f9ff2fa7b0ec97e5c0d26e4f41ad6de9f2e423128780da5dfecba20fe96402099f8387ce0ddef84bee2d0f869b35bb599a58b9aaec4a73db08dc490ba519d200f14729c14b6a9b292e7b5142fc5483d7c25196af1ef4b9722ea5821719e2c40ac200feacb370b7fcfcdd5ee7a363d73fda02d596ce61fd00e308d0ab68a7b955f48ba201e435d3bbab5fb0244c273e38d6f078bfe57a1bd151016ab5c4ac84457d724b3ba201fccb5af3a431a928c32267e556f1ba256871f98428419fae1cce6e7b8356cb9ba202367edcf01edd517d46c1b3cc3d40f5a28608e0313636dd09b0904799bccd635ba20243b84dd7a170a6e1edc32b22357b20f8365a4149a12ef1d340342701d535991ba2036612620ae82332e4f5da8d78d0d8a4ff7c8b09e88ee988b3dde18ef6a04c497ba20378f464f4365136230d30c3ad7d6425457d6c0742ed7fefd1015f0040cc70769ba2039eca9e5cf04e22471d6cde649604e6fd0aae077cd5b1af9a1dc26e56d8502f3ba20583c7fbf7450f8f78977b8c9f2981ff10676efefb6399ec925ba54eed7978a2eba2064df415d63ef3ce23ddd639c4a5ec8fdbfa67254db91228ca77fbec9610367aeba207947f704a584a804c91d07250239ec528300bd01dd3137770f7227309f63db0aba209010f319cde80190717d96dd60823b8e05905a2da458c69f4de19d5c9226cca8ba20a63763c4100bacdb1c06e5e1ba5599e379a2e23553d56d2b1d0ee3c990bd1192ba20db2bb56299fe3219ea5901198d1872f0523234d529a29fa912a76c9cb6d70db6ba20dbf2c13d6e3b0a8ad7286966bd00164ca0a163b483d305df6b492119cbffbabbba20e0647bb72f1b3d33d69f360d7e9f58f6a693d40b6ef58f49f140a212bf16931cba20e3803a6ecff76daf35709c8484f382783d211970f22397d7a258f40ca3b46304ba20f399ff078d6d954a390f67989705ed21e575ccf43a1340ca8752cd1613ca7ce0ba20f6a33481886c7d5ed5429c3bb0a83dbdefafd6d140b22a87aa7081cf7073136cba01129c", + "unbonding_transaction_hex": "020000000100000000000000000000000000000000000000000000000000000000000000000000000000ffffffff01605af4050000000022512044b4c847be70ba60488426ae7c59a636dc952b8494fb2f01584c9f533cd4b07c00000000", + "unbonding_transaction_time_lock_script_hex": "207aa0dafe26a7b663b679418f2c19fe7ea1215919051aa5ac76e4a9fbef2f33c5ad02c900b2", + "unbonding_transaction_slashing_script_hex": "207aa0dafe26a7b663b679418f2c19fe7ea1215919051aa5ac76e4a9fbef2f33c5ad2029f526a81bc92dd2ed8cf1682fc4ae5956987f3f6d3c0da71fbcf230c71781ffac204bcfb4042e5d13286fcd3d481b81a61cdfc3715aaf7909c4ee93de49356cd0b4ba2050eff2669c6d83f858937cd9229fc93ad57c10cc8d8cfb7ec9bc40e32a9f7ff2ba2078c5d7a263ab7e98e311c8d2d7305d13d78a014d4ae0603b427bb55cb42dbed1ba207bb40e3cb76545a71fafcb29738fb27b452c3176b41ffd614f7231b40ff5ce68ba20a7165ffc90d12c25187b75b2ebdcb57b1c759e357d655d8371cfb96dc4df2eccba20ae3c70699ae235ddebef85378a550f796723a6b961dcff1f33716d5dbb096a1eba20cca2d8aa1feb47ad4933154ef8196db229cfbba676607c3c0583397d65a1e4eeba20f1209d7248936f9ff2fa7b0ec97e5c0d26e4f41ad6de9f2e423128780da5dfecba20fe96402099f8387ce0ddef84bee2d0f869b35bb599a58b9aaec4a73db08dc490ba519d200f14729c14b6a9b292e7b5142fc5483d7c25196af1ef4b9722ea5821719e2c40ac200feacb370b7fcfcdd5ee7a363d73fda02d596ce61fd00e308d0ab68a7b955f48ba201e435d3bbab5fb0244c273e38d6f078bfe57a1bd151016ab5c4ac84457d724b3ba201fccb5af3a431a928c32267e556f1ba256871f98428419fae1cce6e7b8356cb9ba202367edcf01edd517d46c1b3cc3d40f5a28608e0313636dd09b0904799bccd635ba20243b84dd7a170a6e1edc32b22357b20f8365a4149a12ef1d340342701d535991ba2036612620ae82332e4f5da8d78d0d8a4ff7c8b09e88ee988b3dde18ef6a04c497ba20378f464f4365136230d30c3ad7d6425457d6c0742ed7fefd1015f0040cc70769ba2039eca9e5cf04e22471d6cde649604e6fd0aae077cd5b1af9a1dc26e56d8502f3ba20583c7fbf7450f8f78977b8c9f2981ff10676efefb6399ec925ba54eed7978a2eba2064df415d63ef3ce23ddd639c4a5ec8fdbfa67254db91228ca77fbec9610367aeba207947f704a584a804c91d07250239ec528300bd01dd3137770f7227309f63db0aba209010f319cde80190717d96dd60823b8e05905a2da458c69f4de19d5c9226cca8ba20a63763c4100bacdb1c06e5e1ba5599e379a2e23553d56d2b1d0ee3c990bd1192ba20db2bb56299fe3219ea5901198d1872f0523234d529a29fa912a76c9cb6d70db6ba20dbf2c13d6e3b0a8ad7286966bd00164ca0a163b483d305df6b492119cbffbabbba20e0647bb72f1b3d33d69f360d7e9f58f6a693d40b6ef58f49f140a212bf16931cba20e3803a6ecff76daf35709c8484f382783d211970f22397d7a258f40ca3b46304ba20f399ff078d6d954a390f67989705ed21e575ccf43a1340ca8752cd1613ca7ce0ba20f6a33481886c7d5ed5429c3bb0a83dbdefafd6d140b22a87aa7081cf7073136cba01129c", + "op_return_script_hex": "" + } + } + ] +} diff --git a/btcstaking/types.go b/btcstaking/types.go index 9ef508069..d6dc68f8c 100644 --- a/btcstaking/types.go +++ b/btcstaking/types.go @@ -12,16 +12,22 @@ import ( "github.com/btcsuite/btcd/chaincfg/chainhash" "github.com/btcsuite/btcd/txscript" "github.com/btcsuite/btcd/wire" + + bbn "github.com/babylonlabs-io/babylon/types" + sdk "github.com/cosmos/cosmos-sdk/types" ) const ( // Point with unknown discrete logarithm defined in: https://github.com/bitcoin/bips/blob/master/bip-0341.mediawiki#constructing-and-spending-taproot-outputs - // using it as internal public key efectively disables taproot key spends + // using it as internal public key effectively disables taproot key spends unspendableKeyPath = "0250929b74c1a04954b78b4b6035e97a5e078a5a0f28ec96d547bfee9ace803ac0" ) var ( - unspendableKeyPathKey = unspendableKeyPathInternalPubKeyInternal(unspendableKeyPath) + unspendableKeyPathKey = unspendableKeyPathInternalPubKeyInternal(unspendableKeyPath) + errBuildingStakingInfo = fmt.Errorf("error building staking info") + errBuildingUnbondingInfo = fmt.Errorf("error building unbonding info") + ErrDuplicatedKeyInScript = fmt.Errorf("duplicated key in script") ) func unspendableKeyPathInternalPubKeyInternal(keyHex string) btcec.PublicKey { @@ -255,15 +261,51 @@ type babylonScriptPaths struct { timeLockPathScript []byte // unbondingPathScript is the script path for on-demand early unbonding // OP_CHECKSIGVERIFY - // OP_CHECKSIG ... OP_CHECKSIGADD M OP_GREATERTHANOREQUAL OP_VERIFY + // OP_CHECKSIG ... OP_CHECKSIGADD M OP_NUMEQUAL unbondingPathScript []byte // slashingPathScript is the script path for slashing // OP_CHECKSIGVERIFY - // OP_CHECKSIG ... OP_CHECKSIGADD M OP_GREATERTHANOREQUAL OP_VERIFY - // OP_CHECKSIG ... OP_CHECKSIGADD 1 OP_GREATERTHANOREQUAL OP_VERIFY + // OP_CHECKSIG ... OP_CHECKSIGADD 1 OP_NUMEQUALVERIFY + // OP_CHECKSIG ... OP_CHECKSIGADD M OP_NUMEQUAL slashingPathScript []byte } +func keyToString(key *btcec.PublicKey) string { + return hex.EncodeToString(schnorr.SerializePubKey(key)) +} + +func checkForDuplicateKeys( + stakerKey *btcec.PublicKey, + fpKeys []*btcec.PublicKey, + covenantKeys []*btcec.PublicKey, +) error { + keyMap := make(map[string]struct{}) + + keyMap[keyToString(stakerKey)] = struct{}{} + + for _, key := range fpKeys { + keyStr := keyToString(key) + + if _, ok := keyMap[keyStr]; ok { + return fmt.Errorf("key: %s: %w", keyStr, ErrDuplicatedKeyInScript) + } + + keyMap[keyStr] = struct{}{} + } + + for _, key := range covenantKeys { + keyStr := keyToString(key) + + if _, ok := keyMap[keyStr]; ok { + return fmt.Errorf("key: %s: %w", keyStr, ErrDuplicatedKeyInScript) + } + + keyMap[keyStr] = struct{}{} + } + + return nil +} + func newBabylonScriptPaths( stakerKey *btcec.PublicKey, fpKeys []*btcec.PublicKey, @@ -275,6 +317,10 @@ func newBabylonScriptPaths( return nil, fmt.Errorf("staker key is nil") } + if err := checkForDuplicateKeys(stakerKey, fpKeys, covenantKeys); err != nil { + return nil, fmt.Errorf("error building scripts: %w", err) + } + timeLockPathScript, err := buildTimeLockScript(stakerKey, lockTime) if err != nil { @@ -300,7 +346,7 @@ func newBabylonScriptPaths( return nil, err } - fpSigScript, err := buildMultiSigScript( + fpMultisigScript, err := buildMultiSigScript( fpKeys, // we always require only one finality provider to sign 1, @@ -319,7 +365,7 @@ func newBabylonScriptPaths( slashingPathScript := aggregateScripts( stakerSigScript, - fpSigScript, + fpMultisigScript, covenantMultisigScript, ) @@ -330,6 +376,12 @@ func newBabylonScriptPaths( }, nil } +// BuildStakingInfo builds all Babylon specific BTC scripts that must +// be committed to in the staking output. +// Returned `StakingInfo` object exposes methods to build spend info for each +// of the script spending paths which later must be included in the witness. +// It is up to the caller to verify whether parameters provided to this function +// obey parameters expected by Babylon chain. func BuildStakingInfo( stakerKey *btcec.PublicKey, fpKeys []*btcec.PublicKey, @@ -350,7 +402,7 @@ func BuildStakingInfo( ) if err != nil { - return nil, err + return nil, fmt.Errorf("%s: %w", errBuildingStakingInfo, err) } var unbondingPaths [][]byte @@ -368,13 +420,13 @@ func BuildStakingInfo( ) if err != nil { - return nil, err + return nil, fmt.Errorf("%s: %w", errBuildingStakingInfo, err) } taprootPkScript, err := sh.taprootPkScript(net) if err != nil { - return nil, err + return nil, fmt.Errorf("%s: %w", errBuildingStakingInfo, err) } stakingOutput := wire.NewTxOut(int64(stakingAmount), taprootPkScript) @@ -410,6 +462,12 @@ type UnbondingInfo struct { slashingPathLeafHash chainhash.Hash } +// BuildUnbondingInfo builds all Babylon specific BTC scripts that must +// be committed to in the unbonding output. +// Returned `UnbondingInfo` object exposes methods to build spend info for each +// of the script spending paths which later must be included in the witness. +// It is up to the caller to verify whether parameters provided to this function +// obey parameters expected by Babylon chain. func BuildUnbondingInfo( stakerKey *btcec.PublicKey, fpKeys []*btcec.PublicKey, @@ -430,7 +488,7 @@ func BuildUnbondingInfo( ) if err != nil { - return nil, err + return nil, fmt.Errorf("%s: %w", errBuildingUnbondingInfo, err) } var unbondingPaths [][]byte @@ -446,13 +504,13 @@ func BuildUnbondingInfo( ) if err != nil { - return nil, err + return nil, fmt.Errorf("%s: %w", errBuildingUnbondingInfo, err) } taprootPkScript, err := sh.taprootPkScript(net) if err != nil { - return nil, err + return nil, fmt.Errorf("%s: %w", errBuildingUnbondingInfo, err) } unbondingOutput := wire.NewTxOut(int64(unbondingAmount), taprootPkScript) @@ -473,15 +531,15 @@ func (i *UnbondingInfo) SlashingPathSpendInfo() (*SpendInfo, error) { return i.scriptHolder.scriptSpendInfoByName(i.slashingPathLeafHash) } -// IsSlashingRateValid checks if the given slashing rate is between the valid range i.e., (0,1) with a precision of at most 2 decimal places. -func IsSlashingRateValid(slashingRate sdkmath.LegacyDec) bool { +// IsRateValid checks if the given rate is between the valid range i.e., (0,1) with a precision of at most 2 decimal places. +func IsRateValid(rate sdkmath.LegacyDec) bool { // Check if the slashing rate is between 0 and 1 - if slashingRate.LTE(sdkmath.LegacyZeroDec()) || slashingRate.GTE(sdkmath.LegacyOneDec()) { + if rate.LTE(sdkmath.LegacyZeroDec()) || rate.GTE(sdkmath.LegacyOneDec()) { return false } // Multiply by 100 to move the decimal places and check if precision is at most 2 decimal places - multipliedRate := slashingRate.Mul(sdkmath.LegacyNewDec(100)) + multipliedRate := rate.Mul(sdkmath.LegacyNewDec(100)) // Truncate the rate to remove decimal places truncatedRate := multipliedRate.TruncateDec() @@ -498,7 +556,7 @@ type RelativeTimeLockTapScriptInfo struct { LockTime uint16 // taproot address of the script TapAddress btcutil.Address - // pkscript in output wchich commits to the given script/leaf + // pkscript in output which commits to the given script/leaf PkScript []byte } @@ -555,3 +613,20 @@ func BuildRelativeTimelockTaprootScript( PkScript: taprootPkScript, }, nil } + +// ParseBlkHeightAndPubKeyFromStoreKey expects to receive a key with +// BigEndianUint64(blkHeight) || BIP340PubKey(fpBTCPK) +func ParseBlkHeightAndPubKeyFromStoreKey(key []byte) (blkHeight uint64, fpBTCPK *bbn.BIP340PubKey, err error) { + sizeBigEndian := 8 + if len(key) < sizeBigEndian+1 { + return 0, nil, fmt.Errorf("key not long enough to parse block height and BIP340PubKey: %s", key) + } + + fpBTCPK, err = bbn.NewBIP340PubKey(key[sizeBigEndian:]) + if err != nil { + return 0, nil, fmt.Errorf("failed to parse pub key from key %w: %w", bbn.ErrUnmarshal, err) + } + + blkHeight = sdk.BigEndianToUint64(key[:sizeBigEndian]) + return blkHeight, fpBTCPK, nil +} diff --git a/btcstaking/witness_utils.go b/btcstaking/witness_utils.go index a733ab1e9..8e45f2f0a 100644 --- a/btcstaking/witness_utils.go +++ b/btcstaking/witness_utils.go @@ -17,7 +17,14 @@ func (si *SpendInfo) CreateTimeLockPathWitness(delegatorSig *schnorr.Signature) return CreateWitness(si, [][]byte{delegatorSig.Serialize()}) } -func (si *SpendInfo) CreateUnbondingPathWitness(covenantSigs []*schnorr.Signature, delegatorSig *schnorr.Signature) (wire.TxWitness, error) { +// CreateUnbondingPathWitness helper function to create a witness to spend +// transaction through the unbonding path. +// It is up to the caller to ensure that the amount of covenantSigs matches the +// expected quorum of covenenant members and the transaction has unbonding path. +func (si *SpendInfo) CreateUnbondingPathWitness( + covenantSigs []*schnorr.Signature, + delegatorSig *schnorr.Signature, +) (wire.TxWitness, error) { if si == nil { panic("cannot build witness without spend info") } @@ -46,7 +53,16 @@ func (si *SpendInfo) CreateUnbondingPathWitness(covenantSigs []*schnorr.Signatur return CreateWitness(si, witnessStack) } -func (si *SpendInfo) CreateSlashingPathWitness(covenantSigs []*schnorr.Signature, fpSigs []*schnorr.Signature, delegatorSig *schnorr.Signature) (wire.TxWitness, error) { +// CreateSlashingPathWitness helper function to create a witness to spend +// transaction through the slashing path. +// It is up to the caller to ensure that the amount of covenantSigs matches the +// expected quorum of covenenant members, the finality provider sigs respect the finality providers +// that the delegation belongs to, and the transaction has slashing path. +func (si *SpendInfo) CreateSlashingPathWitness( + covenantSigs []*schnorr.Signature, + fpSigs []*schnorr.Signature, + delegatorSig *schnorr.Signature, +) (wire.TxWitness, error) { if si == nil { panic("cannot build witness without spend info") } diff --git a/client/README.md b/client/README.md new file mode 100644 index 000000000..d0d4a9be1 --- /dev/null +++ b/client/README.md @@ -0,0 +1,3 @@ +# client + +client is meant to be imported as a library in other Babylon repos to easily navigate and interact with the Babylon nodes. diff --git a/client/client/client.go b/client/client/client.go new file mode 100644 index 000000000..e641c96bc --- /dev/null +++ b/client/client/client.go @@ -0,0 +1,100 @@ +package client + +import ( + "context" + "time" + + bbn "github.com/babylonlabs-io/babylon/app" + "github.com/babylonlabs-io/babylon/client/config" + "github.com/babylonlabs-io/babylon/client/query" + rpchttp "github.com/cometbft/cometbft/rpc/client/http" + "github.com/cosmos/relayer/v2/relayer/chains/cosmos" + "go.uber.org/zap" +) + +type Client struct { + *query.QueryClient + + provider *cosmos.CosmosProvider + timeout time.Duration + logger *zap.Logger + cfg *config.BabylonConfig +} + +func New(cfg *config.BabylonConfig, logger *zap.Logger) (*Client, error) { + var ( + zapLogger *zap.Logger + err error + ) + + // ensure cfg is valid + if err := cfg.Validate(); err != nil { + return nil, err + } + + // use the existing logger or create a new one if not given + zapLogger = logger + if zapLogger == nil { + zapLogger, err = newRootLogger("console", true) + if err != nil { + return nil, err + } + } + + provider, err := cfg.ToCosmosProviderConfig().NewProvider( + zapLogger, + "", // TODO: set home path + true, + "babylon", + ) + if err != nil { + return nil, err + } + + cp := provider.(*cosmos.CosmosProvider) + cp.PCfg.KeyDirectory = cfg.KeyDirectory + + // Create tmp Babylon app to retrieve and register codecs + // Need to override this manually as otherwise option from config is ignored + encCfg := bbn.GetEncodingConfig() + cp.Cdc = cosmos.Codec{ + InterfaceRegistry: encCfg.InterfaceRegistry, + Marshaler: encCfg.Codec, + TxConfig: encCfg.TxConfig, + Amino: encCfg.Amino, + } + + // initialise Cosmos provider + // NOTE: this will create a RPC client. The RPC client will be used for + // submitting txs and making ad hoc queries. It won't create WebSocket + // connection with Babylon node + err = cp.Init(context.Background()) + if err != nil { + return nil, err + } + + // create a queryClient so that the Client inherits all query functions + // TODO: merge this RPC client with the one in `cp` after Cosmos side + // finishes the migration to new RPC client + // see https://github.com/strangelove-ventures/cometbft-client + c, err := rpchttp.NewWithTimeout(cp.PCfg.RPCAddr, "/websocket", uint(cfg.Timeout.Seconds())) + if err != nil { + return nil, err + } + queryClient, err := query.NewWithClient(c, cfg.Timeout) + if err != nil { + return nil, err + } + + return &Client{ + queryClient, + cp, + cfg.Timeout, + zapLogger, + cfg, + }, nil +} + +func (c *Client) GetConfig() *config.BabylonConfig { + return c.cfg +} diff --git a/client/client/keys.go b/client/client/keys.go new file mode 100644 index 000000000..2974ccbde --- /dev/null +++ b/client/client/keys.go @@ -0,0 +1,49 @@ +package client + +import ( + "fmt" + "path" + + "github.com/cosmos/cosmos-sdk/crypto/keyring" + "github.com/juju/fslock" +) + +func (c *Client) GetAddr() (string, error) { + return c.provider.Address() +} + +func (c *Client) MustGetAddr() string { + addr, err := c.provider.Address() + if err != nil { + panic(fmt.Errorf("failed to get signer: %v", err)) + } + return addr +} + +func (c *Client) GetKeyring() keyring.Keyring { + return c.provider.Keybase +} + +// accessKeyWithLock triggers a function that access key ring while acquiring +// the file system lock, in order to remain thread-safe when multiple concurrent +// relayers are running on the same machine and accessing the same keyring +// adapted from +// https://github.com/babylonlabs-io/babylon-relayer/blob/f962d0940832a8f84f747c5d9cbc67bc1b156386/bbnrelayer/utils.go#L212 +func (c *Client) accessKeyWithLock(accessFunc func()) error { + // use lock file to guard concurrent access to the keyring + lockFilePath := path.Join(c.provider.PCfg.KeyDirectory, "keys.lock") + lock := fslock.New(lockFilePath) + if err := lock.Lock(); err != nil { + return fmt.Errorf("failed to acquire file system lock (%s): %w", lockFilePath, err) + } + + // trigger function that access keyring + accessFunc() + + // unlock and release access + if err := lock.Unlock(); err != nil { + return fmt.Errorf("error unlocking file system lock (%s), please manually delete", lockFilePath) + } + + return nil +} diff --git a/client/client/keys_test.go b/client/client/keys_test.go new file mode 100644 index 000000000..4192b87ab --- /dev/null +++ b/client/client/keys_test.go @@ -0,0 +1,59 @@ +package client_test + +import ( + "math/rand" + "strings" + "testing" + + bbn "github.com/babylonlabs-io/babylon/app" + "github.com/babylonlabs-io/babylon/client/client" + "github.com/babylonlabs-io/babylon/client/config" + "github.com/babylonlabs-io/babylon/testutil/datagen" + "github.com/cosmos/cosmos-sdk/crypto/hd" + "github.com/cosmos/cosmos-sdk/crypto/keyring" + "github.com/stretchr/testify/require" +) + +func FuzzKeys(f *testing.F) { + datagen.AddRandomSeedsToFuzzer(f, 10) + + f.Fuzz(func(t *testing.T, seed int64) { + r := rand.New(rand.NewSource(seed)) + + // create a keyring + keyringName := datagen.GenRandomHexStr(r, 10) + dir := t.TempDir() + mockIn := strings.NewReader("") + cdc := bbn.GetEncodingConfig() + kr, err := keyring.New(keyringName, "test", dir, mockIn, cdc.Codec) + require.NoError(t, err) + + // create a random key pair in this keyring + keyName := datagen.GenRandomHexStr(r, 10) + _, _, err = kr.NewMnemonic( + keyName, + keyring.English, + hd.CreateHDPath(118, 0, 0).String(), + keyring.DefaultBIP39Passphrase, + hd.Secp256k1, + ) + require.NoError(t, err) + + // create a Babylon client with this random keyring + cfg := config.DefaultBabylonConfig() + cfg.KeyDirectory = dir + cfg.Key = keyName + cl, err := client.New(&cfg, nil) + require.NoError(t, err) + + // retrieve the key info from key ring + keys, err := kr.List() + require.NoError(t, err) + require.Equal(t, 1, len(keys)) + + // test if the key is consistent in Babylon client and keyring + bbnAddr := cl.MustGetAddr() + addr, _ := keys[0].GetAddress() + require.Equal(t, addr.String(), bbnAddr) + }) +} diff --git a/client/client/log.go b/client/client/log.go new file mode 100644 index 000000000..ae9b45a96 --- /dev/null +++ b/client/client/log.go @@ -0,0 +1,40 @@ +package client + +import ( + "fmt" + zaplogfmt "github.com/jsternberg/zap-logfmt" + "go.uber.org/zap" + "go.uber.org/zap/zapcore" + "os" + "time" +) + +func newRootLogger(format string, debug bool) (*zap.Logger, error) { + cfg := zap.NewProductionEncoderConfig() + cfg.EncodeTime = func(ts time.Time, encoder zapcore.PrimitiveArrayEncoder) { + encoder.AppendString(ts.UTC().Format("2006-01-02T15:04:05.000000Z07:00")) + } + cfg.LevelKey = "lvl" + + var enc zapcore.Encoder + switch format { + case "json": + enc = zapcore.NewJSONEncoder(cfg) + case "auto", "console": + enc = zapcore.NewConsoleEncoder(cfg) + case "logfmt": + enc = zaplogfmt.NewEncoder(cfg) + default: + return nil, fmt.Errorf("unrecognized log format %q", format) + } + + level := zap.InfoLevel + if debug { + level = zap.DebugLevel + } + return zap.New(zapcore.NewCore( + enc, + os.Stderr, + level, + )), nil +} diff --git a/client/client/retry_utils.go b/client/client/retry_utils.go new file mode 100644 index 000000000..f9bef5fe0 --- /dev/null +++ b/client/client/retry_utils.go @@ -0,0 +1,26 @@ +package client + +import ( + "cosmossdk.io/errors" + "github.com/avast/retry-go/v4" + "strings" + "time" +) + +// Variables used for retries +var ( + rtyAttNum = uint(5) + rtyAtt = retry.Attempts(rtyAttNum) + rtyDel = retry.Delay(time.Millisecond * 400) + rtyErr = retry.LastErrorOnly(true) +) + +func errorContained(err error, errList []*errors.Error) bool { + for _, e := range errList { + if strings.Contains(err.Error(), e.Error()) { + return true + } + } + + return false +} diff --git a/client/client/tx.go b/client/client/tx.go new file mode 100644 index 000000000..f3bac897e --- /dev/null +++ b/client/client/tx.go @@ -0,0 +1,505 @@ +package client + +import ( + "context" + "fmt" + "sync" + + signingv1beta1 "cosmossdk.io/api/cosmos/tx/signing/v1beta1" + "cosmossdk.io/errors" + txsigning "cosmossdk.io/x/tx/signing" + "github.com/avast/retry-go/v4" + btcctypes "github.com/babylonlabs-io/babylon/x/btccheckpoint/types" + btclctypes "github.com/babylonlabs-io/babylon/x/btclightclient/types" + abci "github.com/cometbft/cometbft/abci/types" + coretypes "github.com/cometbft/cometbft/rpc/core/types" + "github.com/cosmos/cosmos-sdk/client" + "github.com/cosmos/cosmos-sdk/client/tx" + "github.com/cosmos/cosmos-sdk/crypto/keys/secp256k1" + cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types" + sdk "github.com/cosmos/cosmos-sdk/types" + txtypes "github.com/cosmos/cosmos-sdk/types/tx" + "github.com/cosmos/cosmos-sdk/types/tx/signing" + authsigning "github.com/cosmos/cosmos-sdk/x/auth/signing" + "github.com/cosmos/relayer/v2/relayer/chains/cosmos" + pv "github.com/cosmos/relayer/v2/relayer/provider" + "go.uber.org/zap" +) + +// ToProviderMsgs converts a list of sdk.Msg to a list of provider.RelayerMessage +func ToProviderMsgs(msgs []sdk.Msg) []pv.RelayerMessage { + relayerMsgs := []pv.RelayerMessage{} + for _, m := range msgs { + relayerMsgs = append(relayerMsgs, cosmos.NewCosmosMessage(m, func(signer string) {})) + } + return relayerMsgs +} + +// SendMsgToMempool sends a message to the mempool. +// It does not wait for the messages to be included. +func (c *Client) SendMsgToMempool(ctx context.Context, msg sdk.Msg) error { + return c.SendMsgsToMempool(ctx, []sdk.Msg{msg}) +} + +// SendMsgsToMempool sends a set of messages to the mempool. +// It does not wait for the messages to be included. +func (c *Client) SendMsgsToMempool(ctx context.Context, msgs []sdk.Msg) error { + relayerMsgs := ToProviderMsgs(msgs) + if err := retry.Do(func() error { + var sendMsgErr error + krErr := c.accessKeyWithLock(func() { + sendMsgErr = c.provider.SendMessagesToMempool(ctx, relayerMsgs, "", ctx, []func(*pv.RelayerTxResponse, error){}) + }) + if krErr != nil { + c.logger.Error("unrecoverable err when submitting the tx, skip retrying", zap.Error(krErr)) + return retry.Unrecoverable(krErr) + } + 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)) + })); err != nil { + return err + } + + return nil +} + +// ReliablySendMsg reliable sends a message to the chain. +// It utilizes a file lock as well as a keyring lock to ensure atomic access. +// TODO: needs tests +func (c *Client) ReliablySendMsg(ctx context.Context, msg sdk.Msg, expectedErrors []*errors.Error, unrecoverableErrors []*errors.Error) (*pv.RelayerTxResponse, error) { + return c.ReliablySendMsgs(ctx, []sdk.Msg{msg}, expectedErrors, unrecoverableErrors) +} + +// ReliablySendMsgs reliably sends a list of messages to the chain. +// It utilizes a file lock as well as a keyring lock to ensure atomic access. +// TODO: needs tests +func (c *Client) ReliablySendMsgs(ctx context.Context, msgs []sdk.Msg, expectedErrors []*errors.Error, unrecoverableErrors []*errors.Error) (*pv.RelayerTxResponse, error) { + var ( + rlyResp *pv.RelayerTxResponse + callbackErr error + wg sync.WaitGroup + ) + + callback := func(rtr *pv.RelayerTxResponse, err error) { + rlyResp = rtr + callbackErr = err + wg.Done() + } + + wg.Add(1) + + // convert message type + relayerMsgs := ToProviderMsgs(msgs) + + // TODO: consider using Babylon's retry package + if err := retry.Do(func() error { + var sendMsgErr error + krErr := c.accessKeyWithLock(func() { + sendMsgErr = c.provider.SendMessagesToMempool(ctx, relayerMsgs, "", ctx, []func(*pv.RelayerTxResponse, error){callback}) + }) + if krErr != nil { + c.logger.Error("unrecoverable err when submitting the tx, skip retrying", zap.Error(krErr)) + return retry.Unrecoverable(krErr) + } + if sendMsgErr != nil { + if errorContained(sendMsgErr, unrecoverableErrors) { + c.logger.Error("unrecoverable err when submitting the tx, skip retrying", zap.Error(sendMsgErr)) + return retry.Unrecoverable(sendMsgErr) + } + if errorContained(sendMsgErr, expectedErrors) { + // this is necessary because if err is returned + // the callback function will not be executed so + // that the inside wg.Done will not be executed + wg.Done() + c.logger.Error("expected err when submitting the tx, skip retrying", zap.Error(sendMsgErr)) + return nil + } + return sendMsgErr + } + 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)) + })); err != nil { + return nil, err + } + + wg.Wait() + + if callbackErr != nil { + if errorContained(callbackErr, expectedErrors) { + return nil, nil + } + return nil, callbackErr + } + + if rlyResp == nil { + // this case could happen if the error within the retry is an expected error + return nil, nil + } + + if rlyResp.Code != 0 { + return rlyResp, fmt.Errorf("transaction failed with code: %d", rlyResp.Code) + } + + return rlyResp, nil +} + +// ReliablySendMsgsWithSigner reliably sends a list of messages to the chain. +// It utilizes the signer private key to sign all msgs +func (c *Client) ReliablySendMsgsWithSigner(ctx context.Context, signerAddr sdk.AccAddress, signerPvKey *secp256k1.PrivKey, msgs []sdk.Msg, expectedErrors []*errors.Error, unrecoverableErrors []*errors.Error) (*pv.RelayerTxResponse, error) { + var ( + rlyResp *pv.RelayerTxResponse + callbackErr error + wg sync.WaitGroup + ) + wg.Add(1) + + // convert message type + relayerMsgs := ToProviderMsgs(msgs) + + // TODO: consider using Babylon's retry package + if err := retry.Do(func() error { + _, sendMsgErr := c.SendMessageWithSigner(ctx, signerAddr, signerPvKey, relayerMsgs) + if sendMsgErr != nil { + if errorContained(sendMsgErr, unrecoverableErrors) { + c.logger.Error("unrecoverable err when submitting the tx, skip retrying", zap.Error(sendMsgErr)) + return retry.Unrecoverable(sendMsgErr) + } + if errorContained(sendMsgErr, expectedErrors) { + // this is necessary because if err is returned + // the callback function will not be executed so + // that the inside wg.Done will not be executed + wg.Done() + c.logger.Error("expected err when submitting the tx, skip retrying", zap.Error(sendMsgErr)) + return nil + } + return sendMsgErr + } + 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)) + })); err != nil { + return nil, err + } + + wg.Wait() + + if callbackErr != nil { + if errorContained(callbackErr, expectedErrors) { + return nil, nil + } + return nil, callbackErr + } + + if rlyResp == nil { + // this case could happen if the error within the retry is an expected error + return nil, nil + } + + if rlyResp.Code != 0 { + return rlyResp, fmt.Errorf("transaction failed with code: %d", rlyResp.Code) + } + + return rlyResp, nil +} + +func (c *Client) SendMessageWithSigner( + ctx context.Context, + signerAddr sdk.AccAddress, + signerPvKey *secp256k1.PrivKey, + relayerMsgs []pv.RelayerMessage, +) (result *coretypes.ResultBroadcastTx, err error) { + cMsgs := cosmos.CosmosMsgs(relayerMsgs...) + var ( + num, seq uint64 + ) + + cc := c.provider + cliCtx := client.Context{}.WithClient(cc.RPCClient). + WithInterfaceRegistry(cc.Cdc.InterfaceRegistry). + WithChainID(cc.PCfg.ChainID). + WithCodec(cc.Cdc.Marshaler). + WithFromAddress(signerAddr) + + txf := cc.TxFactory() + if err := retry.Do(func() error { + if err := txf.AccountRetriever().EnsureExists(cliCtx, signerAddr); err != nil { + return err + } + return err + }, rtyAtt, rtyDel, rtyErr); err != nil { + return nil, err + } + + initNum, initSeq := txf.AccountNumber(), txf.Sequence() + if initNum == 0 || initSeq == 0 { + if err := retry.Do(func() error { + num, seq, err = txf.AccountRetriever().GetAccountNumberSequence(cliCtx, signerAddr) + if err != nil { + return err + } + return err + }, rtyAtt, rtyDel, rtyErr); err != nil { + return nil, err + } + + if initNum == 0 { + txf = txf.WithAccountNumber(num) + } + + if initSeq == 0 { + txf = txf.WithSequence(seq) + } + } + + if cc.PCfg.MinGasAmount != 0 { + txf = txf.WithGas(cc.PCfg.MinGasAmount) + } + + if cc.PCfg.MaxGasAmount != 0 { + txf = txf.WithGas(cc.PCfg.MaxGasAmount) + } + txf, err = cc.SetWithExtensionOptions(txf) + if err != nil { + return nil, err + } + + //txf ready + _, adjusted, err := c.CalculateGas(ctx, txf, signerPvKey.PubKey(), cMsgs...) + if err != nil { + return nil, err + } + + // Set the gas amount on the transaction factory + txf = txf.WithGas(adjusted) + + // Build the transaction builder + txb, err := txf.BuildUnsignedTx(cMsgs...) + if err != nil { + return nil, err + } + + // Attach the signature to the transaction + // c.LogFailedTx(nil, err, msgs) + // Force encoding in the chain specific address + for _, msg := range cMsgs { + cc.Cdc.Marshaler.MustMarshalJSON(msg) + } + if err := Sign(ctx, txf, signerPvKey, txb, cc.Cdc.TxConfig.SignModeHandler(), false); err != nil { + return nil, err + } + + tx := txb.GetTx() + + // Generate the transaction bytes + txBytes, err := cc.Cdc.TxConfig.TxEncoder()(tx) + if err != nil { + return nil, err + } + + return cc.RPCClient.BroadcastTxSync(ctx, txBytes) +} + +// BuildSimTx creates an unsigned tx with an empty single signature and returns +// the encoded transaction or an error if the unsigned transaction cannot be built. +func BuildSimTx(pk cryptotypes.PubKey, txf tx.Factory, msgs ...sdk.Msg) ([]byte, error) { + txb, err := txf.BuildUnsignedTx(msgs...) + if err != nil { + return nil, err + } + + // Create an empty signature literal as the ante handler will populate with a + // sentinel pubkey. + sig := signing.SignatureV2{ + PubKey: pk, + Data: &signing.SingleSignatureData{ + SignMode: txf.SignMode(), + }, + Sequence: txf.Sequence(), + } + if err := txb.SetSignatures(sig); err != nil { + return nil, err + } + + protoProvider, ok := txb.(protoTxProvider) + if !ok { + return nil, fmt.Errorf("cannot simulate amino tx") + } + + simReq := txtypes.SimulateRequest{Tx: protoProvider.GetProtoTx()} + return simReq.Marshal() +} + +// CalculateGas simulates a tx to generate the appropriate gas settings before broadcasting a tx. +func (c *Client) CalculateGas(ctx context.Context, txf tx.Factory, signingPK cryptotypes.PubKey, msgs ...sdk.Msg) (txtypes.SimulateResponse, uint64, error) { + cc := c.provider + + var txBytes []byte + if err := retry.Do(func() error { + var err error + txBytes, err = BuildSimTx(signingPK, txf, msgs...) + if err != nil { + return err + } + return nil + }, retry.Context(ctx), rtyAtt, rtyDel, rtyErr); err != nil { + return txtypes.SimulateResponse{}, 0, err + } + + simQuery := abci.RequestQuery{ + Path: "/cosmos.tx.v1beta1.Service/Simulate", + Data: txBytes, + } + + var res abci.ResponseQuery + if err := retry.Do(func() error { + var err error + res, err = cc.QueryABCI(ctx, simQuery) + if err != nil { + return err + } + return nil + }, retry.Context(ctx), rtyAtt, rtyDel, rtyErr); err != nil { + return txtypes.SimulateResponse{}, 0, err + } + + var simRes txtypes.SimulateResponse + if err := simRes.Unmarshal(res.Value); err != nil { + return txtypes.SimulateResponse{}, 0, err + } + + gas, err := cc.AdjustEstimatedGas(simRes.GasInfo.GasUsed) + return simRes, gas, err +} + +// 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 +// return an error. +// An error is returned upon failure. +func Sign( + ctx context.Context, + txf tx.Factory, + signerPvKey *secp256k1.PrivKey, + txBuilder client.TxBuilder, + handlerMap *txsigning.HandlerMap, + overwriteSig bool, +) error { + var err error + signMode := txf.SignMode() + if signMode == signing.SignMode_SIGN_MODE_UNSPECIFIED { + // use the SignModeHandler's default mode if unspecified + signMode, err = authsigning.APISignModeToInternal(signingv1beta1.SignMode_SIGN_MODE_DIRECT_AUX) + if err != nil { + return err + } + } + + pubKey := signerPvKey.PubKey() + + signerData := authsigning.SignerData{ + ChainID: txf.ChainID(), + AccountNumber: txf.AccountNumber(), + Sequence: txf.Sequence(), + PubKey: pubKey, + Address: sdk.AccAddress(pubKey.Address()).String(), + } + + // For SIGN_MODE_DIRECT, calling SetSignatures calls setSignerInfos on + // TxBuilder under the hood, and SignerInfos is needed to generated the + // sign bytes. This is the reason for setting SetSignatures here, with a + // nil signature. + // + // Note: this line is not needed for SIGN_MODE_LEGACY_AMINO, but putting it + // also doesn't affect its generated sign bytes, so for code's simplicity + // sake, we put it here. + sigData := signing.SingleSignatureData{ + SignMode: signMode, + Signature: nil, + } + sig := signing.SignatureV2{ + PubKey: pubKey, + Data: &sigData, + Sequence: txf.Sequence(), + } + + var prevSignatures []signing.SignatureV2 + if !overwriteSig { + prevSignatures, err = txBuilder.GetTx().GetSignaturesV2() + if err != nil { + return err + } + } + // Overwrite or append signer infos. + var sigs []signing.SignatureV2 + if overwriteSig { + sigs = []signing.SignatureV2{sig} + } else { + sigs = append(sigs, prevSignatures...) + sigs = append(sigs, sig) + } + if err := txBuilder.SetSignatures(sigs...); err != nil { + return err + } + + bytesToSign, err := authsigning.GetSignBytesAdapter(ctx, handlerMap, signMode, signerData, txBuilder.GetTx()) + if err != nil { + return err + } + + sigBytes, err := signerPvKey.Sign(bytesToSign) + if err != nil { + return err + } + + // Construct the SignatureV2 struct + sigData = signing.SingleSignatureData{ + SignMode: signMode, + Signature: sigBytes, + } + sig = signing.SignatureV2{ + PubKey: pubKey, + Data: &sigData, + Sequence: txf.Sequence(), + } + + if overwriteSig { + err = txBuilder.SetSignatures(sig) + } else { + prevSignatures = append(prevSignatures, sig) + err = txBuilder.SetSignatures(prevSignatures...) + } + + if err != nil { + return fmt.Errorf("unable to set signatures on payload: %w", err) + } + + // Run optional preprocessing if specified. By default, this is unset + // and will return nil. + return nil +} + +// We do not expose ctx in our client calls, which means: +// - we do not support cancellation of submitting messages +// - the only timeout is the block inclusion timeout i.e block-timeout +// TODO: To properly support cancellation we need to expose ctx in our client calls +func (c *Client) InsertBTCSpvProof(ctx context.Context, msg *btcctypes.MsgInsertBTCSpvProof) (*pv.RelayerTxResponse, error) { + return c.ReliablySendMsg(ctx, msg, []*errors.Error{}, []*errors.Error{}) +} + +func (c *Client) InsertHeaders(ctx context.Context, msg *btclctypes.MsgInsertHeaders) (*pv.RelayerTxResponse, error) { + return c.ReliablySendMsg(ctx, msg, []*errors.Error{}, []*errors.Error{}) +} + +// protoTxProvider is a type which can provide a proto transaction. It is a +// workaround to get access to the wrapper TxBuilder's method GetProtoTx(). +type protoTxProvider interface { + GetProtoTx() *txtypes.Tx +} + +// TODO: implement necessary message invocations here +// - MsgInconsistencyEvidence +// - MsgStallingEvidence diff --git a/client/config/babylon_config.go b/client/config/babylon_config.go new file mode 100644 index 000000000..680e5fb1a --- /dev/null +++ b/client/config/babylon_config.go @@ -0,0 +1,95 @@ +package config + +import ( + "fmt" + "github.com/cosmos/relayer/v2/relayer/chains/cosmos" + "net/url" + "os" + "path/filepath" + "time" +) + +// BabylonConfig defines configuration for the Babylon client +// adapted from https://github.com/strangelove-ventures/lens/blob/v0.5.1/client/config.go +type BabylonConfig struct { + Key string `mapstructure:"key"` + ChainID string `mapstructure:"chain-id"` + RPCAddr string `mapstructure:"rpc-addr"` + GRPCAddr string `mapstructure:"grpc-addr"` + AccountPrefix string `mapstructure:"account-prefix"` + KeyringBackend string `mapstructure:"keyring-backend"` + GasAdjustment float64 `mapstructure:"gas-adjustment"` + GasPrices string `mapstructure:"gas-prices"` + KeyDirectory string `mapstructure:"key-directory"` + Debug bool `mapstructure:"debug"` + Timeout time.Duration `mapstructure:"timeout"` + BlockTimeout time.Duration `mapstructure:"block-timeout"` + OutputFormat string `mapstructure:"output-format"` + SignModeStr string `mapstructure:"sign-mode"` + SubmitterAddress string `mapstructure:"submitter-address"` +} + +func (cfg *BabylonConfig) Validate() error { + if _, err := url.Parse(cfg.RPCAddr); err != nil { + return fmt.Errorf("rpc-addr is not correctly formatted: %w", err) + } + if cfg.Timeout <= 0 { + return fmt.Errorf("timeout must be positive") + } + if cfg.BlockTimeout < 0 { + return fmt.Errorf("block-timeout can't be negative") + } + return nil +} + +func (cfg *BabylonConfig) ToCosmosProviderConfig() cosmos.CosmosProviderConfig { + return cosmos.CosmosProviderConfig{ + Key: cfg.Key, + ChainID: cfg.ChainID, + RPCAddr: cfg.RPCAddr, + AccountPrefix: cfg.AccountPrefix, + KeyringBackend: cfg.KeyringBackend, + GasAdjustment: cfg.GasAdjustment, + GasPrices: cfg.GasPrices, + KeyDirectory: cfg.KeyDirectory, + Debug: cfg.Debug, + Timeout: cfg.Timeout.String(), + BlockTimeout: cfg.BlockTimeout.String(), + OutputFormat: cfg.OutputFormat, + SignModeStr: cfg.SignModeStr, + } +} + +func DefaultBabylonConfig() BabylonConfig { + return BabylonConfig{ + Key: "node0", + ChainID: "chain-test", + // see https://docs.cosmos.network/master/core/grpc_rest.html for default ports + // TODO: configure HTTPS for Babylon's RPC server + // TODO: how to use Cosmos SDK's RPC server (port 1317) rather than Tendermint's RPC server (port 26657)? + RPCAddr: "http://localhost:26657", + // TODO: how to support GRPC in the Babylon client? + GRPCAddr: "https://localhost:9090", + AccountPrefix: "bbn", + KeyringBackend: "test", + GasAdjustment: 1.2, + GasPrices: "0.01ubbn", + KeyDirectory: defaultBabylonHome(), + Debug: true, + Timeout: 20 * time.Second, + OutputFormat: "json", + SignModeStr: "direct", + SubmitterAddress: "bbn1v6k7k9s8md3k29cu9runasstq5zaa0lpznk27w", // this is currently a placeholder, will not recognized by Babylon + } +} + +// defaultBabylonHome returns the default Babylon node directory, which is $HOME/.babylond +// copied from https://github.com/babylonlabs-io/babylon/blob/648b804bc492ded2cb826ba261d7164b4614d78a/app/app.go#L205-L210 +func defaultBabylonHome() string { + userHomeDir, err := os.UserHomeDir() + if err != nil { + panic(err) + } + + return filepath.Join(userHomeDir, ".babylond") +} diff --git a/client/config/babylon_query_config.go b/client/config/babylon_query_config.go new file mode 100644 index 000000000..5a378f221 --- /dev/null +++ b/client/config/babylon_query_config.go @@ -0,0 +1,30 @@ +package config + +import ( + "fmt" + "net/url" + "time" +) + +// BabylonConfig defines configuration for the Babylon query client +type BabylonQueryConfig struct { + RPCAddr string `mapstructure:"rpc-addr"` + Timeout time.Duration `mapstructure:"timeout"` +} + +func (cfg *BabylonQueryConfig) Validate() error { + if _, err := url.Parse(cfg.RPCAddr); err != nil { + return fmt.Errorf("cfg.RPCAddr is not correctly formatted: %w", err) + } + if cfg.Timeout <= 0 { + return fmt.Errorf("cfg.Timeout must be positive") + } + return nil +} + +func DefaultBabylonQueryConfig() BabylonQueryConfig { + return BabylonQueryConfig{ + RPCAddr: "http://localhost:26657", + Timeout: 20 * time.Second, + } +} diff --git a/client/config/babylon_query_config_test.go b/client/config/babylon_query_config_test.go new file mode 100644 index 000000000..18c9ac2e5 --- /dev/null +++ b/client/config/babylon_query_config_test.go @@ -0,0 +1,15 @@ +package config_test + +import ( + "testing" + + "github.com/babylonlabs-io/babylon/client/config" + "github.com/stretchr/testify/require" +) + +// TestBabylonQueryConfig ensures that the default Babylon query config is valid +func TestBabylonQueryConfig(t *testing.T) { + defaultConfig := config.DefaultBabylonQueryConfig() + err := defaultConfig.Validate() + require.NoError(t, err) +} diff --git a/client/docs/swagger-ui/swagger.yaml b/client/docs/swagger-ui/swagger.yaml index cccf807c2..00e83b140 100644 --- a/client/docs/swagger-ui/swagger.yaml +++ b/client/docs/swagger-ui/swagger.yaml @@ -22,72 +22,43 @@ paths: epoch_number: type: string format: uint64 - title: epoch number of this checkpoint + 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 - format: byte title: >- hash of the btc block which determines checkpoint btc block height i.e. - youngest block of best submission + youngest block of best submission Hexadecimal best_submission_transactions: type: array items: type: object properties: - key: - 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. - type: object - properties: - index: - type: integer - format: int64 - hash: - type: string - format: byte - title: >- - Each provided OP_RETURN transaction can be - idendtified by hash of block in - - which transaction was included and transaction - index in the block + 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 - format: byte - title: transaction is the full transaction in bytes + description: >- + transaction is the full transaction data as str + hex. 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 - - valideated the proof? title: >- - TransactionInfo is the info of a tx on Bitcoin, + TransactionInfoResponse is the info of a tx on + Bitcoin, including @@ -105,17 +76,13 @@ paths: properties: submitter: type: string - format: byte description: >- - TODO: this could probably be better typed - submitter is the address of the checkpoint submitter to BTC, extracted from the checkpoint itself. reporter: type: string - format: byte title: >- reporter is the address of the reporter who reported the submissions, @@ -123,17 +90,17 @@ paths: calculated from submission message MsgInsertBTCSpvProof itself title: >- - CheckpointAddresses contains the addresses of the - submitter and reporter of a + CheckpointAddressesResponse contains the addresses of + the submitter and reporter of a given checkpoint title: list of vigilantes' addresses of the best submission - title: >- - BTCCheckpointInfo contains all data about best submission of - checkpoint for + description: >- + BTCCheckpointInfoResponse contains all data about best + submission of checkpoint for given epoch. Best submission is the submission which is - deeper in btc ledger + deeper in btc ledger. pagination: title: pagination defines the pagination in the response type: object @@ -339,72 +306,40 @@ paths: epoch_number: type: string format: uint64 - title: epoch number of this checkpoint + 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 - format: byte title: >- hash of the btc block which determines checkpoint btc block height i.e. - youngest block of best submission + youngest block of best submission Hexadecimal best_submission_transactions: type: array items: type: object properties: - key: - 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. - type: object - properties: - index: - type: integer - format: int64 - hash: - type: string - format: byte - title: >- - Each provided OP_RETURN transaction can be - idendtified by hash of block in - - which transaction was included and transaction index - in the block + 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 - format: byte - title: transaction is the full transaction in bytes + description: transaction is the full transaction data as str hex. 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 - - valideated the proof? title: |- - TransactionInfo is the info of a tx on Bitcoin, + TransactionInfoResponse is the info of a tx on Bitcoin, including - the position of the tx on BTC blockchain - the full tx content @@ -417,17 +352,13 @@ paths: properties: submitter: type: string - format: byte description: >- - TODO: this could probably be better typed - submitter is the address of the checkpoint submitter to BTC, extracted from the checkpoint itself. reporter: type: string - format: byte title: >- reporter is the address of the reporter who reported the submissions, @@ -435,17 +366,17 @@ paths: calculated from submission message MsgInsertBTCSpvProof itself title: >- - CheckpointAddresses contains the addresses of the - submitter and reporter of a + CheckpointAddressesResponse contains the addresses of + the submitter and reporter of a given checkpoint title: list of vigilantes' addresses of the best submission - title: >- - BTCCheckpointInfo contains all data about best submission of - checkpoint for + description: >- + BTCCheckpointInfoResponse contains all data about best + submission of checkpoint for given epoch. Best submission is the submission which is deeper - in btc ledger + in btc ledger. title: |- QueryBtcCheckpointInfoResponse is response type for the Query/BtcCheckpointInfo RPC method @@ -497,28 +428,24 @@ paths: items: 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 idendtified - by hash of block in - - which transaction was included and transaction index - in the block + 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: >- - Checkpoint can be composed from multiple transactions, so to - identify whole + SubmissionKeyResponse Checkpoint can be composed from + multiple transactions, - submission we need list of transaction keys. + so to identify whole submission we need list of transaction + keys. Each submission can generally be identified by this list of (txIdx, @@ -534,35 +461,7 @@ paths: so there should be other strong arguments for this optimization - description: All submissions saved during an epoch. - 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: Keys All submissions transactions key saved during an epoch. title: >- QueryEpochSubmissionsResponse defines a response to get all submissions in @@ -597,62 +496,6 @@ paths: required: true type: string format: uint64 - - 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/btclightclient/v1/baseheader: @@ -672,26 +515,24 @@ paths: header: type: object properties: - header: + header_hex: type: string - format: byte - hash: + hash_hex: type: string - format: byte height: type: string format: uint64 work: type: string - format: byte + description: Work is the sdkmath.Uint as string. description: >- - BTCHeaderInfo is a structure that contains all relevant - information about a + BTCHeaderInfoResponse is a structure that contains all + relevant information about a - BTC header - - Full header bytes - - Header hash for easy retrieval - - Height of the header in the BTC chain + 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. @@ -774,7 +615,7 @@ paths: summary: |- ContainsBytes is a temporary method that checks whether a hash is maintained by the module. - See discussion at https://github.com/babylonchain/babylon/pull/132 + See discussion at https://github.com/babylonlabs-io/babylon/pull/132 for more details. operationId: ContainsBytes responses: @@ -1013,26 +854,24 @@ paths: items: type: object properties: - header: + header_hex: type: string - format: byte - hash: + hash_hex: type: string - format: byte height: type: string format: uint64 work: type: string - format: byte + description: Work is the sdkmath.Uint as string. description: >- - BTCHeaderInfo is a structure that contains all relevant - information about a + BTCHeaderInfoResponse is a structure that contains all + relevant information about a - BTC header - - Full header bytes - - Header hash for easy retrieval - - Height of the header in the BTC chain + 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. @@ -1211,26 +1050,24 @@ paths: header: type: object properties: - header: + header_hex: type: string - format: byte - hash: + hash_hex: type: string - format: byte height: type: string format: uint64 work: type: string - format: byte + description: Work is the sdkmath.Uint as string. description: >- - BTCHeaderInfo is a structure that contains all relevant - information about a + BTCHeaderInfoResponse is a structure that contains all + relevant information about a - BTC header - - Full header bytes - - Header hash for easy retrieval - - Height of the header in the BTC chain + 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. @@ -1548,10 +1385,8 @@ paths: state update of a delegation - title: >- - ValidatorLifecycle is a message that records records the - lifecycle of - + title: |- + ValidatorLifecycle is a message that records the lifecycle of a delegation title: |- QueryDelegationLifecycleRequest is the response type for the @@ -1811,35 +1646,27 @@ paths: epoch's beginning, and is set upon the end of this epoch. - app_hash_root: - type: string - format: byte - title: >- - app_hash_root is the Merkle root of all AppHashs in this - epoch - - It will be used for proving a block is in an 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 + 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 @@ -2171,35 +1998,27 @@ paths: beginning, and is set upon the end of this epoch. - app_hash_root: - type: string - format: byte - title: >- - app_hash_root is the Merkle root of all AppHashs in this - epoch - - It will be used for proving a block is in an 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 + 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 @@ -2422,14 +2241,14 @@ paths: properties: tx_id: type: string - format: byte - title: tx_id is the ID of the tx that contains the message + description: >- + tx_id is the ID of the tx that contains the message as + hex. msg_id: type: string - format: byte - title: >- + description: >- msg_id is the original message ID, i.e., hash of the - marshaled message + marshaled message as hex. block_height: type: string format: uint64 @@ -2442,401 +2261,16 @@ paths: title: >- block_time is the timestamp when this msg is submitted to Babylon - msg_create_validator: - type: object - properties: - description: - type: object - properties: - moniker: - type: string - description: >- - moniker defines a human-readable name for the - validator. - identity: - type: string - description: >- - identity defines an optional identity signature - (ex. UPort or Keybase). - website: - type: string - description: website defines an optional website link. - security_contact: - type: string - description: >- - security_contact defines an optional email for - security contact. - details: - type: string - description: details define other optional details. - description: Description defines a validator description. - commission: - type: object - properties: - rate: - type: string - description: >- - rate is the commission rate charged to - delegators, as a fraction. - max_rate: - type: string - description: >- - max_rate defines the maximum commission rate - which validator can ever charge, as a fraction. - max_change_rate: - type: string - description: >- - max_change_rate defines the maximum daily - increase of the validator commission, as a - fraction. - description: >- - CommissionRates defines the initial commission rates - to be used for creating + msg: + type: string + description: >- + msg is the actual message that is sent by a user and is + queued by the - a validator. - min_self_delegation: - type: string - delegator_address: - type: string - description: >- - Deprecated: Use of Delegator Address in - MsgCreateValidator is deprecated. - - The validator address bytes and delegator address - bytes refer to the same account while creating - validator (defer - - only in bech32 notation). - validator_address: - type: string - pubkey: - 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" - } - value: - 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. - description: >- - MsgCreateValidator defines a SDK message for creating a - new validator. - msg_delegate: - type: object - properties: - delegator_address: - type: string - validator_address: - 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. - description: >- - MsgDelegate defines a SDK message for performing a - delegation of coins - - from a delegator to a validator. - msg_undelegate: - type: object - properties: - delegator_address: - type: string - validator_address: - 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. - description: >- - MsgUndelegate defines a SDK message for performing an - undelegation from a - - delegate and a validator. - msg_begin_redelegate: - type: object - properties: - delegator_address: - type: string - validator_src_address: - type: string - validator_dst_address: - 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. - description: >- - MsgBeginRedelegate defines a SDK message for performing - a redelegation - - of coins from a delegator and source validator to a - destination validator. - msg_cancel_unbonding_delegation: - type: object - properties: - delegator_address: - type: string - validator_address: - 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. - title: >- - amount is always less than or equal to unbonding - delegation entry balance - creation_height: - type: string - format: int64 - description: >- - creation_height is the height which the unbonding - took place. - description: 'Since: cosmos-sdk 0.46' - title: >- - MsgCancelUnbondingDelegation defines the SDK message for - performing a cancel unbonding delegation for delegator + epoching module as string. title: >- - QueuedMessage is a message that can change the validator set - and is delayed + 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 @@ -3480,16 +2914,14 @@ paths: properties: tx_id: type: string - format: byte - title: >- + description: >- tx_id is the ID of the tx that contains the - message + message as hex. msg_id: type: string - format: byte - title: >- + description: >- msg_id is the original message ID, i.e., hash of - the marshaled message + the marshaled message as hex. block_height: type: string format: uint64 @@ -3502,442 +2934,51 @@ paths: title: >- block_time is the timestamp when this msg is submitted to Babylon - msg_create_validator: - type: object - properties: - description: - type: object - properties: - moniker: - type: string - description: >- - moniker defines a human-readable name for - the validator. - identity: - type: string - description: >- - identity defines an optional identity - signature (ex. UPort or Keybase). - website: - type: string - description: website defines an optional website link. - security_contact: - type: string - description: >- - security_contact defines an optional email - for security contact. - details: - type: string - description: details define other optional details. - description: Description defines a validator description. - commission: - type: object - properties: - rate: - type: string - description: >- - rate is the commission rate charged to - delegators, as a fraction. - max_rate: - type: string - description: >- - max_rate defines the maximum commission - rate which validator can ever charge, as a - fraction. - max_change_rate: - type: string - description: >- - max_change_rate defines the maximum daily - increase of the validator commission, as a - fraction. - description: >- - CommissionRates defines the initial commission - rates to be used for creating - - a validator. - min_self_delegation: - type: string - delegator_address: - type: string - description: >- - Deprecated: Use of Delegator Address in - MsgCreateValidator is deprecated. - - The validator address bytes and delegator - address bytes refer to the same account while - creating validator (defer - - only in bech32 notation). - validator_address: - type: string - pubkey: - 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. - + msg: + type: string + description: >- + msg is the actual message that is sent by a user + and is queued by the - Protobuf library provides support to - pack/unpack Any values in the form + epoching module as string. + title: >- + QueuedMessageResponse is a message that can change the + validator set and is delayed - of utility functions or additional generated - methods of the Any type. + 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 - Example 1: Pack and unpack a message in C++. + 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 - 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 - 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" - } - value: - 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. - description: >- - MsgCreateValidator defines a SDK message for - creating a new validator. - msg_delegate: - type: object - properties: - delegator_address: - type: string - validator_address: - 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. - description: >- - MsgDelegate defines a SDK message for performing a - delegation of coins - - from a delegator to a validator. - msg_undelegate: - type: object - properties: - delegator_address: - type: string - validator_address: - 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. - description: >- - MsgUndelegate defines a SDK message for performing - an undelegation from a - - delegate and a validator. - msg_begin_redelegate: - type: object - properties: - delegator_address: - type: string - validator_src_address: - type: string - validator_dst_address: - 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. - description: >- - MsgBeginRedelegate defines a SDK message for - performing a redelegation - - of coins from a delegator and source validator to - a destination validator. - msg_cancel_unbonding_delegation: - type: object - properties: - delegator_address: - type: string - validator_address: - 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. - title: >- - amount is always less than or equal to - unbonding delegation entry balance - creation_height: - type: string - format: int64 - description: >- - creation_height is the height which the - unbonding took place. - description: 'Since: cosmos-sdk 0.46' - title: >- - MsgCancelUnbondingDelegation defines the SDK - message for performing a cancel unbonding - delegation for delegator - title: >- - QueuedMessage 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: >- - epoch_msg_map 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. + corresponding request message has used PageRequest. message SomeResponse { repeated Bar results = 1; @@ -4440,49 +3481,25 @@ paths: schema: type: object properties: + val_addr: + type: string val_life: - type: object - properties: - val_addr: - type: string - val_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 - block_height: - type: string - format: uint64 - block_time: - type: string - format: date-time - title: >- - ValStateUpdate is a messages that records a state update - of a validator - title: >- - ValidatorLifecycle is a message that records records the - lifecycle of - - a validator + 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 @@ -4979,14 +3996,14 @@ paths: 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 + block_hash_hex defines the 'BlockID.Hash', which is the + hash of - the block that individual BLS sigs are signed on + the block that individual BLS sigs are signed on as hex + string bitmap: type: string format: byte @@ -5001,7 +4018,7 @@ paths: from individual BLS sigs - title: RawCheckpoint wraps the BLS multi sig with metadata + title: RawCheckpointResponse wraps the BLS multi sig with metadata description: |- QueryLastCheckpointWithStatusResponse is the response type for the Query/LastCheckpointWithStatus RPC method. @@ -5062,14 +4079,14 @@ paths: 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 + block_hash_hex defines the 'BlockID.Hash', which is + the hash of - the block that individual BLS sigs are signed on + the block that individual BLS sigs are signed on as + hex string bitmap: type: string format: byte @@ -5084,7 +4101,9 @@ paths: from individual BLS sigs - title: RawCheckpoint wraps the BLS multi sig with metadata + title: >- + RawCheckpointResponse wraps the BLS multi sig with + metadata status: type: string enum: @@ -5103,6 +4122,9 @@ paths: - 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 @@ -5138,6 +4160,11 @@ paths: 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 @@ -5155,8 +4182,8 @@ paths: update description: >- - CheckpointStateUpdate defines a state transition on the - checkpoint. + CheckpointStateUpdateResponse defines a state transition + on the checkpoint. description: >- lifecycle defines the lifecycle of this checkpoint, i.e., each state @@ -5165,7 +4192,9 @@ paths: height) of this transition. - description: RawCheckpointWithMeta wraps the raw checkpoint with metadata. + description: >- + RawCheckpointWithMetaResponse wraps the raw checkpoint with + metadata. description: >- QueryRawCheckpointResponse is the response type for the Query/RawCheckpoint @@ -5228,14 +4257,14 @@ paths: 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 + block_hash_hex defines the 'BlockID.Hash', which is + the hash of - the block that individual BLS sigs are signed on + the block that individual BLS sigs are signed on as + hex string bitmap: type: string format: byte @@ -5250,7 +4279,9 @@ paths: aggregated from individual BLS sigs - title: RawCheckpoint wraps the BLS multi sig with metadata + title: >- + RawCheckpointResponse wraps the BLS multi sig with + metadata status: type: string enum: @@ -5269,6 +4300,9 @@ paths: - 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 @@ -5304,6 +4338,11 @@ paths: 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 @@ -5321,8 +4360,8 @@ paths: update description: >- - CheckpointStateUpdate defines a state transition on - the checkpoint. + CheckpointStateUpdateResponse defines a state + transition on the checkpoint. description: >- lifecycle defines the lifecycle of this checkpoint, i.e., each state @@ -5332,7 +4371,7 @@ paths: transition. description: >- - RawCheckpointWithMeta wraps the raw checkpoint with + RawCheckpointWithMetaResponse wraps the raw checkpoint with metadata. title: >- the order is going from the newest to oldest based on the @@ -5466,14 +4505,14 @@ paths: 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 + block_hash_hex defines the 'BlockID.Hash', which is + the hash of - the block that individual BLS sigs are signed on + the block that individual BLS sigs are signed on as + hex string bitmap: type: string format: byte @@ -5488,7 +4527,9 @@ paths: aggregated from individual BLS sigs - title: RawCheckpoint wraps the BLS multi sig with metadata + title: >- + RawCheckpointResponse wraps the BLS multi sig with + metadata status: type: string enum: @@ -5507,6 +4548,9 @@ paths: - 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 @@ -5542,6 +4586,11 @@ paths: 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 @@ -5559,8 +4608,8 @@ paths: update description: >- - CheckpointStateUpdate defines a state transition on - the checkpoint. + CheckpointStateUpdateResponse defines a state + transition on the checkpoint. description: >- lifecycle defines the lifecycle of this checkpoint, i.e., each state @@ -5570,7 +4619,7 @@ paths: transition. description: >- - RawCheckpointWithMeta wraps the raw checkpoint with + RawCheckpointWithMetaResponse wraps the raw checkpoint with metadata. title: >- the order is going from the newest to oldest based on the @@ -7433,14 +6482,6 @@ paths: beginning, and is set upon the end of this epoch. - app_hash_root: - type: string - format: byte - title: >- - app_hash_root is the Merkle root of all AppHashs in this - epoch - - It will be used for proving a block is in an epoch sealer_app_hash: type: string format: byte @@ -7513,8 +6554,8 @@ paths: type: string format: byte title: >- - Each provided OP_RETURN transaction can be idendtified - by hash of block in + Each provided OP_RETURN transaction can be identified by + hash of block in which transaction was included and transaction index in the block @@ -7663,7 +6704,7 @@ paths: format: byte title: >- Each provided OP_RETURN transaction can be - idendtified by hash of block in + identified by hash of block in which transaction was included and transaction index in the block @@ -7697,7 +6738,7 @@ paths: TODO: maybe it could use here better format as we already processed and - valideated the proof? + validated the proof? title: |- TransactionInfo is the info of a tx on Bitcoin, including @@ -8185,14 +7226,6 @@ paths: epoch's beginning, and is set upon the end of this epoch. - app_hash_root: - type: string - format: byte - title: >- - app_hash_root is the Merkle root of all AppHashs in - this epoch - - It will be used for proving a block is in an epoch sealer_app_hash: type: string format: byte @@ -8266,7 +7299,7 @@ paths: format: byte title: >- Each provided OP_RETURN transaction can be - idendtified by hash of block in + identified by hash of block in which transaction was included and transaction index in the block @@ -8418,7 +7451,7 @@ paths: format: byte title: >- Each provided OP_RETURN transaction can be - idendtified by hash of block in + identified by hash of block in which transaction was included and transaction index in the block @@ -8452,7 +7485,7 @@ paths: TODO: maybe it could use here better format as we already processed and - valideated the proof? + validated the proof? title: >- TransactionInfo is the info of a tx on Bitcoin, @@ -9568,78 +8601,46 @@ paths: tags: - Query definitions: - babylon.btccheckpoint.v1.BTCCheckpointInfo: + babylon.btccheckpoint.v1.BTCCheckpointInfoResponse: type: object properties: epoch_number: type: string format: uint64 - title: epoch number of this checkpoint + 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 - format: byte title: >- hash of the btc block which determines checkpoint btc block height i.e. - youngest block of best submission + youngest block of best submission Hexadecimal best_submission_transactions: type: array items: type: object properties: - key: - 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. - type: object - properties: - index: - type: integer - format: int64 - hash: - type: string - format: byte - title: >- - Each provided OP_RETURN transaction can be idendtified by hash - of block in - - which transaction was included and transaction index in the - block + 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 - format: byte - title: transaction is the full transaction in bytes + description: transaction is the full transaction data as str hex. 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 - - valideated the proof? title: |- - TransactionInfo is the info of a tx on Bitcoin, + TransactionInfoResponse is the info of a tx on Bitcoin, including - the position of the tx on BTC blockchain - the full tx content @@ -9652,56 +8653,48 @@ definitions: properties: submitter: type: string - format: byte description: >- - TODO: this could probably be better typed - submitter is the address of the checkpoint submitter to BTC, extracted from the checkpoint itself. reporter: type: string - format: byte title: >- reporter is the address of the reporter who reported the submissions, calculated from submission message MsgInsertBTCSpvProof itself title: >- - CheckpointAddresses contains the addresses of the submitter and - reporter of a + CheckpointAddressesResponse contains the addresses of the submitter + and reporter of a given checkpoint title: list of vigilantes' addresses of the best submission - title: >- - BTCCheckpointInfo contains all data about best submission of checkpoint - for + 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.CheckpointAddresses: + ledger. + babylon.btccheckpoint.v1.CheckpointAddressesResponse: type: object properties: submitter: type: string - format: byte description: >- - TODO: this could probably be better typed - submitter is the address of the checkpoint submitter to BTC, extracted from the checkpoint itself. reporter: type: string - format: byte title: |- reporter is the address of the reporter who reported the submissions, calculated from submission message MsgInsertBTCSpvProof itself title: >- - CheckpointAddresses contains the addresses of the submitter and reporter - of a + CheckpointAddressesResponse contains the addresses of the submitter and + reporter of a given checkpoint babylon.btccheckpoint.v1.Params: @@ -9752,72 +8745,40 @@ definitions: epoch_number: type: string format: uint64 - title: epoch number of this checkpoint + 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 - format: byte title: >- hash of the btc block which determines checkpoint btc block height i.e. - youngest block of best submission + youngest block of best submission Hexadecimal best_submission_transactions: type: array items: type: object properties: - key: - 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. - type: object - properties: - index: - type: integer - format: int64 - hash: - type: string - format: byte - title: >- - Each provided OP_RETURN transaction can be idendtified by - hash of block in - - which transaction was included and transaction index in the - block + 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 - format: byte - title: transaction is the full transaction in bytes + description: transaction is the full transaction data as str hex. 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 - - valideated the proof? title: |- - TransactionInfo is the info of a tx on Bitcoin, + TransactionInfoResponse is the info of a tx on Bitcoin, including - the position of the tx on BTC blockchain - the full tx content @@ -9830,17 +8791,13 @@ definitions: properties: submitter: type: string - format: byte description: >- - TODO: this could probably be better typed - submitter is the address of the checkpoint submitter to BTC, extracted from the checkpoint itself. reporter: type: string - format: byte title: >- reporter is the address of the reporter who reported the submissions, @@ -9848,17 +8805,17 @@ definitions: calculated from submission message MsgInsertBTCSpvProof itself title: >- - CheckpointAddresses contains the addresses of the submitter and - reporter of a + CheckpointAddressesResponse contains the addresses of the + submitter and reporter of a given checkpoint title: list of vigilantes' addresses of the best submission - title: >- - BTCCheckpointInfo contains all data about best submission of + description: >- + BTCCheckpointInfoResponse contains all data about best submission of checkpoint for given epoch. Best submission is the submission which is deeper in btc - ledger + ledger. title: |- QueryBtcCheckpointInfoResponse is response type for the Query/BtcCheckpointInfo RPC method @@ -9873,72 +8830,40 @@ definitions: epoch_number: type: string format: uint64 - title: epoch number of this checkpoint + 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 - format: byte title: >- hash of the btc block which determines checkpoint btc block height i.e. - youngest block of best submission + youngest block of best submission Hexadecimal best_submission_transactions: type: array items: type: object properties: - key: - 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. - type: object - properties: - index: - type: integer - format: int64 - hash: - type: string - format: byte - title: >- - Each provided OP_RETURN transaction can be idendtified by - hash of block in - - which transaction was included and transaction index in - the block + 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 - format: byte - title: transaction is the full transaction in bytes + description: transaction is the full transaction data as str hex. 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 - - valideated the proof? title: |- - TransactionInfo is the info of a tx on Bitcoin, + TransactionInfoResponse is the info of a tx on Bitcoin, including - the position of the tx on BTC blockchain - the full tx content @@ -9951,17 +8876,13 @@ definitions: properties: submitter: type: string - format: byte description: >- - TODO: this could probably be better typed - submitter is the address of the checkpoint submitter to BTC, extracted from the checkpoint itself. reporter: type: string - format: byte title: >- reporter is the address of the reporter who reported the submissions, @@ -9969,17 +8890,17 @@ definitions: calculated from submission message MsgInsertBTCSpvProof itself title: >- - CheckpointAddresses contains the addresses of the submitter - and reporter of a + CheckpointAddressesResponse contains the addresses of the + submitter and reporter of a given checkpoint title: list of vigilantes' addresses of the best submission - title: >- - BTCCheckpointInfo contains all data about best submission of + description: >- + BTCCheckpointInfoResponse contains all data about best submission of checkpoint for given epoch. Best submission is the submission which is deeper in - btc ledger + btc ledger. pagination: title: pagination defines the pagination in the response type: object @@ -10018,28 +8939,23 @@ definitions: items: 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 idendtified by hash - of block in - - which transaction was included and transaction index in the - block + 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: >- - Checkpoint can be composed from multiple transactions, so to - identify whole + SubmissionKeyResponse Checkpoint can be composed from multiple + transactions, - submission we need list of transaction keys. + so to identify whole submission we need list of transaction keys. Each submission can generally be identified by this list of (txIdx, @@ -10053,33 +8969,7 @@ definitions: byte hash), so there should be other strong arguments for this optimization - description: All submissions saved during an epoch. - 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: Keys All submissions transactions key saved during an epoch. title: |- QueryEpochSubmissionsResponse defines a response to get all submissions in given epoch (QueryEpochSubmissionsRequest) @@ -10126,30 +9016,26 @@ definitions: related to babylon description: QueryParamsResponse is response type for the Query/Params RPC method. - babylon.btccheckpoint.v1.SubmissionKey: + babylon.btccheckpoint.v1.SubmissionKeyResponse: 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 idendtified by hash of - block in - - which transaction was included and transaction index in the block + 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: >- - Checkpoint can be composed from multiple transactions, so to identify - whole + SubmissionKeyResponse Checkpoint can be composed from multiple + transactions, - submission we need list of transaction keys. + so to identify whole submission we need list of transaction keys. Each submission can generally be identified by this list of (txIdx, @@ -10163,63 +9049,30 @@ definitions: hash), so there should be other strong arguments for this optimization - babylon.btccheckpoint.v1.TransactionInfo: + babylon.btccheckpoint.v1.TransactionInfoResponse: type: object properties: - key: - 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. - type: object - properties: - index: - type: integer - format: int64 - hash: - type: string - format: byte - title: >- - Each provided OP_RETURN transaction can be idendtified by hash of - block in - - which transaction was included and transaction index in the block + 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 - format: byte - title: transaction is the full transaction in bytes + description: transaction is the full transaction data as str hex. 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 - - valideated the proof? title: |- - TransactionInfo is the info of a tx on Bitcoin, + 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 - babylon.btccheckpoint.v1.TransactionKey: - type: object - properties: - index: - type: integer - format: int64 - hash: - type: string - format: byte - title: |- - Each provided OP_RETURN transaction can be idendtified by hash of block in - which transaction was included and transaction index in the block cosmos.base.query.v1beta1.PageRequest: type: object properties: @@ -10636,29 +9489,27 @@ definitions: "@type": "type.googleapis.com/google.protobuf.Duration", "value": "1.212s" } - babylon.btclightclient.v1.BTCHeaderInfo: + babylon.btclightclient.v1.BTCHeaderInfoResponse: type: object properties: - header: + header_hex: type: string - format: byte - hash: + hash_hex: type: string - format: byte height: type: string format: uint64 work: type: string - format: byte + description: Work is the sdkmath.Uint as string. description: >- - BTCHeaderInfo is a structure that contains all relevant information about - a + BTCHeaderInfoResponse is a structure that contains all relevant + information about a - BTC header - - Full header bytes - - Header hash for easy retrieval - - Height of the header in the BTC chain + 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. @@ -10681,26 +9532,24 @@ definitions: header: type: object properties: - header: + header_hex: type: string - format: byte - hash: + hash_hex: type: string - format: byte height: type: string format: uint64 work: type: string - format: byte + description: Work is the sdkmath.Uint as string. description: >- - BTCHeaderInfo is a structure that contains all relevant information - about a + BTCHeaderInfoResponse is a structure that contains all relevant + information about a - BTC header - - Full header bytes - - Header hash for easy retrieval - - Height of the header in the BTC chain + 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. @@ -10777,26 +9626,24 @@ definitions: items: type: object properties: - header: + header_hex: type: string - format: byte - hash: + hash_hex: type: string - format: byte height: type: string format: uint64 work: type: string - format: byte + description: Work is the sdkmath.Uint as string. description: >- - BTCHeaderInfo is a structure that contains all relevant information - about a + BTCHeaderInfoResponse is a structure that contains all relevant + information about a - BTC header - - Full header bytes - - Header hash for easy retrieval - - Height of the header in the BTC chain + 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. @@ -10852,26 +9699,24 @@ definitions: header: type: object properties: - header: + header_hex: type: string - format: byte - hash: + hash_hex: type: string - format: byte height: type: string format: uint64 work: type: string - format: byte + description: Work is the sdkmath.Uint as string. description: >- - BTCHeaderInfo is a structure that contains all relevant information - about a + BTCHeaderInfoResponse is a structure that contains all relevant + information about a - BTC header - - Full header bytes - - Header hash for easy retrieval - - Height of the header in the BTC chain + 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. @@ -10948,7 +9793,7 @@ definitions: delegation title: |- - ValidatorLifecycle is a message that records records the lifecycle of + ValidatorLifecycle is a message that records the lifecycle of a delegation babylon.epoching.v1.DelegationStateUpdate: type: object @@ -10992,7 +9837,7 @@ definitions: title: |- DelegationStateUpdate is the message that records a state update of a delegation - babylon.epoching.v1.Epoch: + babylon.epoching.v1.EpochResponse: type: object properties: epoch_number: @@ -11022,27 +9867,19 @@ definitions: and is set upon the end of this epoch. - app_hash_root: - type: string - format: byte - title: |- - app_hash_root is the Merkle root of all AppHashs in this epoch - It will be used for proving a block is in an 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 + 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: @@ -11126,7 +9963,7 @@ definitions: delegation title: |- - ValidatorLifecycle is a message that records records the lifecycle of + ValidatorLifecycle is a message that records the lifecycle of a delegation title: |- QueryDelegationLifecycleRequest is the response type for the @@ -11167,27 +10004,19 @@ definitions: beginning, and is set upon the end of this epoch. - app_hash_root: - type: string - format: byte - title: |- - app_hash_root is the Merkle root of all AppHashs in this epoch - It will be used for proving a block is in an 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 + 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 @@ -11199,14 +10028,12 @@ definitions: properties: tx_id: type: string - format: byte - title: tx_id is the ID of the tx that contains the message + description: tx_id is the ID of the tx that contains the message as hex. msg_id: type: string - format: byte - title: >- + description: >- msg_id is the original message ID, i.e., hash of the marshaled - message + message as hex. block_height: type: string format: uint64 @@ -11217,1939 +10044,286 @@ definitions: title: >- block_time is the timestamp when this msg is submitted to Babylon - msg_create_validator: - type: object - properties: - description: - type: object - properties: - moniker: - type: string - description: moniker defines a human-readable name for the validator. - identity: - type: string - description: >- - identity defines an optional identity signature (ex. - UPort or Keybase). - website: - type: string - description: website defines an optional website link. - security_contact: - type: string - description: >- - security_contact defines an optional email for security - contact. - details: - type: string - description: details define other optional details. - description: Description defines a validator description. - commission: - type: object - properties: - rate: - type: string - description: >- - rate is the commission rate charged to delegators, as a - fraction. - max_rate: - type: string - description: >- - max_rate defines the maximum commission rate which - validator can ever charge, as a fraction. - max_change_rate: - type: string - description: >- - max_change_rate defines the maximum daily increase of - the validator commission, as a fraction. - description: >- - CommissionRates defines the initial commission rates to be - used for creating - - a validator. - min_self_delegation: - type: string - delegator_address: - type: string - description: >- - Deprecated: Use of Delegator Address in MsgCreateValidator - is deprecated. - - The validator address bytes and delegator address bytes - refer to the same account while creating validator (defer - - only in bech32 notation). - validator_address: - type: string - pubkey: - 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" - } - value: - 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. - description: >- - MsgCreateValidator defines a SDK message for creating a new - validator. - msg_delegate: - type: object - properties: - delegator_address: - type: string - validator_address: - 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. - description: >- - MsgDelegate defines a SDK message for performing a delegation of - coins - - from a delegator to a validator. - msg_undelegate: - type: object - properties: - delegator_address: - type: string - validator_address: - 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. - description: >- - MsgUndelegate defines a SDK message for performing an - undelegation from a - - delegate and a validator. - msg_begin_redelegate: - type: object - properties: - delegator_address: - type: string - validator_src_address: - type: string - validator_dst_address: - 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. - description: >- - MsgBeginRedelegate defines a SDK message for performing a - redelegation - - of coins from a delegator and source validator to a destination - validator. - msg_cancel_unbonding_delegation: - type: object - properties: - delegator_address: - type: string - validator_address: - 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. - title: >- - amount is always less than or equal to unbonding delegation - entry balance - creation_height: - type: string - format: int64 - description: >- - creation_height is the height which the unbonding took - place. - description: 'Since: cosmos-sdk 0.46' - title: >- - MsgCancelUnbondingDelegation defines the SDK message for - performing a cancel unbonding delegation for delegator - title: >- - QueuedMessage 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. - app_hash_root: - type: string - format: byte - title: |- - app_hash_root is the Merkle root of all AppHashs in this epoch - It will be used for proving a block is in an 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 - title: Epoch 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 - format: byte - title: tx_id is the ID of the tx that contains the message - msg_id: - type: string - format: byte - title: >- - msg_id is the original message ID, i.e., hash of the - marshaled message - 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_create_validator: - type: object - properties: - description: - type: object - properties: - moniker: - type: string - description: >- - moniker defines a human-readable name for the - validator. - identity: - type: string - description: >- - identity defines an optional identity signature - (ex. UPort or Keybase). - website: - type: string - description: website defines an optional website link. - security_contact: - type: string - description: >- - security_contact defines an optional email for - security contact. - details: - type: string - description: details define other optional details. - description: Description defines a validator description. - commission: - type: object - properties: - rate: - type: string - description: >- - rate is the commission rate charged to delegators, - as a fraction. - max_rate: - type: string - description: >- - max_rate defines the maximum commission rate which - validator can ever charge, as a fraction. - max_change_rate: - type: string - description: >- - max_change_rate defines the maximum daily increase - of the validator commission, as a fraction. - description: >- - CommissionRates defines the initial commission rates - to be used for creating - - a validator. - min_self_delegation: - type: string - delegator_address: - type: string - description: >- - Deprecated: Use of Delegator Address in - MsgCreateValidator is deprecated. - - The validator address bytes and delegator address - bytes refer to the same account while creating - validator (defer - - only in bech32 notation). - validator_address: - type: string - pubkey: - 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" - } - value: - 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. - description: >- - MsgCreateValidator defines a SDK message for creating a - new validator. - msg_delegate: - type: object - properties: - delegator_address: - type: string - validator_address: - 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. - description: >- - MsgDelegate defines a SDK message for performing a - delegation of coins - - from a delegator to a validator. - msg_undelegate: - type: object - properties: - delegator_address: - type: string - validator_address: - 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. - description: >- - MsgUndelegate defines a SDK message for performing an - undelegation from a - - delegate and a validator. - msg_begin_redelegate: - type: object - properties: - delegator_address: - type: string - validator_src_address: - type: string - validator_dst_address: - 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. - description: >- - MsgBeginRedelegate defines a SDK message for performing a - redelegation - - of coins from a delegator and source validator to a - destination validator. - msg_cancel_unbonding_delegation: - type: object - properties: - delegator_address: - type: string - validator_address: - 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. - title: >- - amount is always less than or equal to unbonding - delegation entry balance - creation_height: - type: string - format: int64 - description: >- - creation_height is the height which the unbonding took - place. - description: 'Since: cosmos-sdk 0.46' - title: >- - MsgCancelUnbondingDelegation defines the SDK message for - performing a cancel unbonding delegation for delegator - title: >- - QueuedMessage 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: |- - epoch_msg_map 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_life: - type: object - properties: - val_addr: - type: string - val_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 - block_height: - type: string - format: uint64 - block_time: - type: string - format: date-time - title: >- - ValStateUpdate is a messages that records a state update of a - validator - title: |- - ValidatorLifecycle is a message that records records the lifecycle of - a validator - title: |- - QueryValidatorLifecycleResponse is the response type for the - Query/ValidatorLifecycle RPC method - babylon.epoching.v1.QueuedMessage: - type: object - properties: - tx_id: - type: string - format: byte - title: tx_id is the ID of the tx that contains the message - msg_id: - type: string - format: byte - title: msg_id is the original message ID, i.e., hash of the marshaled message - 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_create_validator: - type: object - properties: - description: - type: object - properties: - moniker: - type: string - description: moniker defines a human-readable name for the validator. - identity: - type: string - description: >- - identity defines an optional identity signature (ex. UPort or - Keybase). - website: - type: string - description: website defines an optional website link. - security_contact: - type: string - description: >- - security_contact defines an optional email for security - contact. - details: - type: string - description: details define other optional details. - description: Description defines a validator description. - commission: - type: object - properties: - rate: - type: string - description: >- - rate is the commission rate charged to delegators, as a - fraction. - max_rate: - type: string - description: >- - max_rate defines the maximum commission rate which validator - can ever charge, as a fraction. - max_change_rate: - type: string - description: >- - max_change_rate defines the maximum daily increase of the - validator commission, as a fraction. - description: >- - CommissionRates defines the initial commission rates to be used - for creating - - a validator. - min_self_delegation: - type: string - delegator_address: - type: string - description: >- - Deprecated: Use of Delegator Address in MsgCreateValidator is - deprecated. - - The validator address bytes and delegator address bytes refer to - the same account while creating validator (defer - - only in bech32 notation). - validator_address: - type: string - pubkey: - 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" - } - value: - 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. - description: MsgCreateValidator defines a SDK message for creating a new validator. - msg_delegate: - type: object - properties: - delegator_address: - type: string - validator_address: - 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. - description: |- - MsgDelegate defines a SDK message for performing a delegation of coins - from a delegator to a validator. - msg_undelegate: - type: object - properties: - delegator_address: - type: string - validator_address: - 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. - description: >- - MsgUndelegate defines a SDK message for performing an undelegation - from a - - delegate and a validator. - msg_begin_redelegate: - type: object - properties: - delegator_address: - type: string - validator_src_address: - type: string - validator_dst_address: - 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. - description: >- - MsgBeginRedelegate defines a SDK message for performing a redelegation - - of coins from a delegator and source validator to a destination - validator. - msg_cancel_unbonding_delegation: - type: object - properties: - delegator_address: - type: string - validator_address: - 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. - title: >- - amount is always less than or equal to unbonding delegation entry - balance - creation_height: - type: string - format: int64 - description: creation_height is the height which the unbonding took place. - description: 'Since: cosmos-sdk 0.46' - title: >- - MsgCancelUnbondingDelegation defines the SDK message for performing a - cancel unbonding delegation for delegator - title: >- - QueuedMessage is a message that can change the validator set and is - delayed - - to the end of an epoch - babylon.epoching.v1.QueuedMessageList: - type: object - properties: - epoch_number: - type: string - format: uint64 - msgs: - type: array - items: - type: object - properties: - tx_id: - type: string - format: byte - title: tx_id is the ID of the tx that contains the message - msg_id: - type: string - format: byte - title: >- - msg_id is the original message ID, i.e., hash of the marshaled - message - 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_create_validator: - type: object - properties: - description: - type: object - properties: - moniker: - type: string - description: moniker defines a human-readable name for the validator. - identity: - type: string - description: >- - identity defines an optional identity signature (ex. - UPort or Keybase). - website: - type: string - description: website defines an optional website link. - security_contact: - type: string - description: >- - security_contact defines an optional email for security - contact. - details: - type: string - description: details define other optional details. - description: Description defines a validator description. - commission: - type: object - properties: - rate: - type: string - description: >- - rate is the commission rate charged to delegators, as a - fraction. - max_rate: - type: string - description: >- - max_rate defines the maximum commission rate which - validator can ever charge, as a fraction. - max_change_rate: - type: string - description: >- - max_change_rate defines the maximum daily increase of - the validator commission, as a fraction. - description: >- - CommissionRates defines the initial commission rates to be - used for creating - - a validator. - min_self_delegation: - type: string - delegator_address: - type: string - description: >- - Deprecated: Use of Delegator Address in MsgCreateValidator - is deprecated. - - The validator address bytes and delegator address bytes - refer to the same account while creating validator (defer - - only in bech32 notation). - validator_address: - type: string - pubkey: - 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" - } - value: - type: object - properties: - denom: - type: string - amount: - type: string - description: >- - Coin defines a token with a denomination and an amount. + 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 - NOTE: The amount field is an Int which implements the custom - method + 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 - signatures required by gogoproto. - description: >- - MsgCreateValidator defines a SDK message for creating a new - validator. - msg_delegate: - type: object - properties: - delegator_address: - type: string - validator_address: - type: string - amount: - type: object - properties: - denom: - type: string - amount: - type: string - description: >- - Coin defines a token with a denomination and an amount. + 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 - NOTE: The amount field is an Int which implements the custom - method + 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. - signatures required by gogoproto. + 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: >- - MsgDelegate defines a SDK message for performing a delegation of - coins + last_block_time is the time of the last block in this epoch. - from a delegator to a validator. - msg_undelegate: - type: object - properties: - delegator_address: - type: string - validator_address: - type: string - amount: - type: object - properties: - denom: - type: string - amount: - type: string - description: >- - Coin defines a token with a denomination and an amount. + Babylon needs to remember the last header's time of each epoch + to complete + unbonding validators/delegations when a previous epoch's + checkpoint is - NOTE: The amount field is an Int which implements the custom - method + finalised. The last_block_time field is nil in the epoch's + beginning, and - signatures required by gogoproto. + is set upon the end of this epoch. + sealer_app_hash_hex: + type: string description: >- - MsgUndelegate defines a SDK message for performing an - undelegation from a - - delegate and a validator. - msg_begin_redelegate: - type: object - properties: - delegator_address: - type: string - validator_src_address: - type: string - validator_dst_address: - type: string - amount: - type: object - properties: - denom: - type: string - amount: - type: string - description: >- - Coin defines a token with a denomination and an amount. - + sealer is the last block of the sealed epoch - NOTE: The amount field is an Int which implements the custom - method + sealer_app_hash points to the sealer but stored in the 1st + header - signatures required by gogoproto. - description: >- - MsgBeginRedelegate defines a SDK message for performing a - redelegation + 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 - of coins from a delegator and source validator to a destination - validator. - msg_cancel_unbonding_delegation: - type: object - properties: - delegator_address: - type: string - validator_address: - type: string - amount: - type: object - properties: - denom: - type: string - amount: - type: string - description: >- - Coin defines a token with a denomination and an amount. + 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 - NOTE: The amount field is an Int which implements the custom - method + epoching module as string. + title: >- + QueuedMessageResponse is a message that can change the + validator set and is delayed - signatures required by gogoproto. - title: >- - amount is always less than or equal to unbonding delegation - entry balance - creation_height: - type: string - format: int64 - description: >- - creation_height is the height which the unbonding took - place. - description: 'Since: cosmos-sdk 0.46' - title: >- - MsgCancelUnbondingDelegation defines the SDK message for - performing a cancel unbonding delegation for delegator + to the end of an epoch title: >- - QueuedMessage is a message that can change the validator set and is - delayed + QueuedMessageList is a message that contains a list of + staking-related - 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.ValStateUpdate: - type: object - properties: - state: - type: string - enum: - - CREATED - - BONDED - - UNBONDING - - UNBONDED - - REMOVED - default: CREATED + 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: |- - - 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 - block_height: - type: string - format: uint64 - block_time: - type: string - format: date-time - title: ValStateUpdate is a messages that records a state update of a validator - babylon.epoching.v1.Validator: + 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: - 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 - babylon.epoching.v1.ValidatorLifecycle: + 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: @@ -13159,424 +10333,134 @@ definitions: items: type: object properties: - state: + state_desc: 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 + description: StateDesc defines the descriptive state. block_height: type: string format: uint64 block_time: type: string format: date-time - title: >- - ValStateUpdate is a messages that records a state update of a - validator + description: >- + ValStateUpdateResponse is a message response that records a state + update of a validator. title: |- - ValidatorLifecycle is a message that records records the lifecycle of - a validator - cosmos.base.v1beta1.Coin: + QueryValidatorLifecycleResponse is the response type for the + Query/ValidatorLifecycle RPC method + babylon.epoching.v1.QueuedMessageList: type: object properties: - denom: - type: string - amount: + epoch_number: type: string - description: |- - Coin defines a token with a denomination and an amount. + 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 - NOTE: The amount field is an Int which implements the custom method - signatures required by gogoproto. - cosmos.staking.v1beta1.CommissionRates: - type: object - properties: - rate: - type: string - description: rate is the commission rate charged to delegators, as a fraction. - max_rate: - type: string - description: >- - max_rate defines the maximum commission rate which validator can ever - charge, as a fraction. - max_change_rate: - type: string - description: >- - max_change_rate defines the maximum daily increase of the validator - commission, as a fraction. - description: >- - CommissionRates defines the initial commission rates to be used for - creating + epoching module as string. + title: >- + QueuedMessageResponse is a message that can change the validator set + and is delayed - a validator. - cosmos.staking.v1beta1.Description: + 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: - moniker: + tx_id: type: string - description: moniker defines a human-readable name for the validator. - identity: + description: tx_id is the ID of the tx that contains the message as hex. + msg_id: type: string description: >- - identity defines an optional identity signature (ex. UPort or - Keybase). - website: - type: string - description: website defines an optional website link. - security_contact: - type: string - description: security_contact defines an optional email for security contact. - details: - type: string - description: details define other optional details. - description: Description defines a validator description. - cosmos.staking.v1beta1.MsgBeginRedelegate: - type: object - properties: - delegator_address: - type: string - validator_src_address: - type: string - validator_dst_address: + msg_id is the original message ID, i.e., hash of the marshaled message + as hex. + block_height: 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. - description: |- - MsgBeginRedelegate defines a SDK message for performing a redelegation - of coins from a delegator and source validator to a destination validator. - cosmos.staking.v1beta1.MsgCancelUnbondingDelegation: - type: object - properties: - delegator_address: + format: uint64 + title: block_height is the height when this msg is submitted to Babylon + block_time: type: string - validator_address: + format: date-time + title: block_time is the timestamp when this msg is submitted to Babylon + msg: 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. - title: >- - amount is always less than or equal to unbonding delegation entry - balance - creation_height: - type: string - format: int64 - description: creation_height is the height which the unbonding took place. - description: 'Since: cosmos-sdk 0.46' + msg is the actual message that is sent by a user and is queued by the + epoching module as string. title: >- - MsgCancelUnbondingDelegation defines the SDK message for performing a - cancel unbonding delegation for delegator - cosmos.staking.v1beta1.MsgCreateValidator: - type: object - properties: - description: - type: object - properties: - moniker: - type: string - description: moniker defines a human-readable name for the validator. - identity: - type: string - description: >- - identity defines an optional identity signature (ex. UPort or - Keybase). - website: - type: string - description: website defines an optional website link. - security_contact: - type: string - description: security_contact defines an optional email for security contact. - details: - type: string - description: details define other optional details. - description: Description defines a validator description. - commission: - type: object - properties: - rate: - type: string - description: rate is the commission rate charged to delegators, as a fraction. - max_rate: - type: string - description: >- - max_rate defines the maximum commission rate which validator can - ever charge, as a fraction. - max_change_rate: - type: string - description: >- - max_change_rate defines the maximum daily increase of the - validator commission, as a fraction. - description: >- - CommissionRates defines the initial commission rates to be used for - creating - - a validator. - min_self_delegation: - type: string - delegator_address: - type: string - description: >- - Deprecated: Use of Delegator Address in MsgCreateValidator is - deprecated. - - The validator address bytes and delegator address bytes refer to the - same account while creating validator (defer - - only in bech32 notation). - validator_address: - type: string - pubkey: - 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 + QueuedMessageResponse is a message that can change the validator set and + is delayed - 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" - } - value: - 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. - description: MsgCreateValidator defines a SDK message for creating a new validator. - cosmos.staking.v1beta1.MsgDelegate: + to the end of an epoch + babylon.epoching.v1.ValStateUpdateResponse: type: object properties: - delegator_address: - type: string - validator_address: + state_desc: 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. - description: |- - MsgDelegate defines a SDK message for performing a delegation of coins - from a delegator to a validator. - cosmos.staking.v1beta1.MsgUndelegate: + 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: - delegator_address: + addr: type: string - validator_address: + 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: 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. + type: string description: |- - MsgUndelegate defines a SDK message for performing an undelegation from a - delegate and a validator. - babylon.checkpointing.v1.CheckpointStateUpdate: + 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: @@ -13597,6 +10481,9 @@ definitions: - 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 @@ -13613,7 +10500,9 @@ definitions: state update - description: CheckpointStateUpdate defines a state transition on the checkpoint. + description: >- + CheckpointStateUpdateResponse defines a state transition on the + checkpoint. babylon.checkpointing.v1.CheckpointStatus: type: string enum: @@ -13712,12 +10601,11 @@ definitions: 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 @@ -13732,7 +10620,7 @@ definitions: individual BLS sigs - title: RawCheckpoint wraps the BLS multi sig with metadata + title: RawCheckpointResponse wraps the BLS multi sig with metadata description: |- QueryLastCheckpointWithStatusResponse is the response type for the Query/LastCheckpointWithStatus RPC method. @@ -13751,12 +10639,14 @@ definitions: 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 @@ -13771,7 +10661,7 @@ definitions: individual BLS sigs - title: RawCheckpoint wraps the BLS multi sig with metadata + title: RawCheckpointResponse wraps the BLS multi sig with metadata status: type: string enum: @@ -13790,6 +10680,9 @@ definitions: - 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 @@ -13825,6 +10718,9 @@ definitions: 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 @@ -13842,8 +10738,8 @@ definitions: update description: >- - CheckpointStateUpdate defines a state transition on the - checkpoint. + CheckpointStateUpdateResponse defines a state transition on + the checkpoint. description: >- lifecycle defines the lifecycle of this checkpoint, i.e., each state @@ -13852,7 +10748,9 @@ definitions: this transition. - description: RawCheckpointWithMeta wraps the raw checkpoint with metadata. + 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. @@ -13889,12 +10787,13 @@ definitions: 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 @@ -13909,7 +10808,7 @@ definitions: individual BLS sigs - title: RawCheckpoint wraps the BLS multi sig with metadata + title: RawCheckpointResponse wraps the BLS multi sig with metadata status: type: string enum: @@ -13928,6 +10827,9 @@ definitions: - 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 @@ -13961,6 +10863,9 @@ definitions: 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 @@ -13978,7 +10883,7 @@ definitions: update description: >- - CheckpointStateUpdate defines a state transition on the + CheckpointStateUpdateResponse defines a state transition on the checkpoint. description: >- lifecycle defines the lifecycle of this checkpoint, i.e., each @@ -13988,7 +10893,7 @@ definitions: this transition. - description: RawCheckpointWithMeta wraps the raw checkpoint with metadata. + description: RawCheckpointWithMetaResponse wraps the raw checkpoint with metadata. description: >- QueryRawCheckpointResponse is the response type for the Query/RawCheckpoint @@ -14009,12 +10914,14 @@ definitions: 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 @@ -14029,7 +10936,7 @@ definitions: individual BLS sigs - title: RawCheckpoint wraps the BLS multi sig with metadata + title: RawCheckpointResponse wraps the BLS multi sig with metadata status: type: string enum: @@ -14048,6 +10955,9 @@ definitions: - 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 @@ -14083,6 +10993,9 @@ definitions: 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 @@ -14100,8 +11013,8 @@ definitions: update description: >- - CheckpointStateUpdate defines a state transition on the - checkpoint. + CheckpointStateUpdateResponse defines a state transition on + the checkpoint. description: >- lifecycle defines the lifecycle of this checkpoint, i.e., each state @@ -14110,7 +11023,9 @@ definitions: this transition. - description: RawCheckpointWithMeta wraps the raw checkpoint with metadata. + 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. @@ -14153,19 +11068,18 @@ definitions: description: |- QueryRecentEpochStatusCountResponse is the response type for the Query/EpochStatusCount RPC method. - babylon.checkpointing.v1.RawCheckpoint: + 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: + 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 @@ -14180,8 +11094,8 @@ definitions: BLS sigs - title: RawCheckpoint wraps the BLS multi sig with metadata - babylon.checkpointing.v1.RawCheckpointWithMeta: + title: RawCheckpointResponse wraps the BLS multi sig with metadata + babylon.checkpointing.v1.RawCheckpointWithMetaResponse: type: object properties: ckpt: @@ -14191,12 +11105,11 @@ definitions: 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 @@ -14211,7 +11124,7 @@ definitions: individual BLS sigs - title: RawCheckpoint wraps the BLS multi sig with metadata + title: RawCheckpointResponse wraps the BLS multi sig with metadata status: type: string enum: @@ -14230,6 +11143,9 @@ definitions: - 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 @@ -14261,6 +11177,9 @@ definitions: - 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 @@ -14277,12 +11196,14 @@ definitions: the state update - description: CheckpointStateUpdate defines a state transition on the checkpoint. + 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: RawCheckpointWithMeta wraps the raw checkpoint with metadata. + description: RawCheckpointWithMetaResponse wraps the raw checkpoint with metadata. babylon.checkpointing.v1.ValidatorWithBlsKey: type: object properties: @@ -14300,6 +11221,173 @@ definitions: 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 + + 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 + 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: + 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 + title: RawCheckpoint wraps the BLS multi sig with metadata + babylon.epoching.v1.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 + title: Epoch is a structure that contains the metadata of an epoch babylon.zoneconcierge.v1.ChainInfo: type: object properties: @@ -14690,12 +11778,6 @@ definitions: beginning, and is set upon the end of this epoch. - app_hash_root: - type: string - format: byte - title: |- - app_hash_root is the Merkle root of all AppHashs in this epoch - It will be used for proving a block is in an epoch sealer_app_hash: type: string format: byte @@ -14756,8 +11838,8 @@ definitions: type: string format: byte title: >- - Each provided OP_RETURN transaction can be idendtified by hash - of block in + Each provided OP_RETURN transaction can be identified by hash of + block in which transaction was included and transaction index in the block @@ -14900,7 +11982,7 @@ definitions: type: string format: byte title: >- - Each provided OP_RETURN transaction can be idendtified by + Each provided OP_RETURN transaction can be identified by hash of block in which transaction was included and transaction index in the @@ -14935,7 +12017,7 @@ definitions: TODO: maybe it could use here better format as we already processed and - valideated the proof? + validated the proof? title: |- TransactionInfo is the info of a tx on Bitcoin, including @@ -15203,7 +12285,7 @@ definitions: epoch have signed `app_hash` of the sealer header - - The epoch medatata is committed to the `app_hash` of the sealer header + - The epoch metadata is committed to the `app_hash` of the sealer header - The validator set is committed to the `app_hash` of the sealer header babylon.zoneconcierge.v1.ProofFinalizedChainInfo: @@ -15336,8 +12418,8 @@ definitions: type: string format: byte title: >- - Each provided OP_RETURN transaction can be idendtified by hash - of block in + Each provided OP_RETURN transaction can be identified by hash of + block in which transaction was included and transaction index in the block @@ -15371,7 +12453,7 @@ definitions: TODO: maybe it could use here better format as we already processed and - valideated the proof? + validated the proof? title: |- TransactionInfo is the info of a tx on Bitcoin, including @@ -16026,12 +13108,6 @@ definitions: beginning, and is set upon the end of this epoch. - app_hash_root: - type: string - format: byte - title: |- - app_hash_root is the Merkle root of all AppHashs in this epoch - It will be used for proving a block is in an epoch sealer_app_hash: type: string format: byte @@ -16092,8 +13168,8 @@ definitions: type: string format: byte title: >- - Each provided OP_RETURN transaction can be idendtified by hash - of block in + Each provided OP_RETURN transaction can be identified by hash of + block in which transaction was included and transaction index in the block @@ -16236,7 +13312,7 @@ definitions: type: string format: byte title: >- - Each provided OP_RETURN transaction can be idendtified by + Each provided OP_RETURN transaction can be identified by hash of block in which transaction was included and transaction index in the @@ -16271,7 +13347,7 @@ definitions: TODO: maybe it could use here better format as we already processed and - valideated the proof? + validated the proof? title: |- TransactionInfo is the info of a tx on Bitcoin, including @@ -16520,14 +13596,6 @@ definitions: beginning, and is set upon the end of this epoch. - app_hash_root: - type: string - format: byte - title: >- - app_hash_root is the Merkle root of all AppHashs in this - epoch - - It will be used for proving a block is in an epoch sealer_app_hash: type: string format: byte @@ -16593,7 +13661,7 @@ definitions: type: string format: byte title: >- - Each provided OP_RETURN transaction can be idendtified by + Each provided OP_RETURN transaction can be identified by hash of block in which transaction was included and transaction index in @@ -16738,7 +13806,7 @@ definitions: type: string format: byte title: >- - Each provided OP_RETURN transaction can be idendtified + Each provided OP_RETURN transaction can be identified by hash of block in which transaction was included and transaction index @@ -16773,7 +13841,7 @@ definitions: TODO: maybe it could use here better format as we already processed and - valideated the proof? + validated the proof? title: |- TransactionInfo is the info of a tx on Bitcoin, including diff --git a/client/docs/versions b/client/docs/versions deleted file mode 100644 index e69de29bb..000000000 diff --git a/client/query/btccheckpoint.go b/client/query/btccheckpoint.go new file mode 100644 index 000000000..c5947cd68 --- /dev/null +++ b/client/query/btccheckpoint.go @@ -0,0 +1,63 @@ +package query + +import ( + "context" + + btcctypes "github.com/babylonlabs-io/babylon/x/btccheckpoint/types" + "github.com/cosmos/cosmos-sdk/client" + sdkquerytypes "github.com/cosmos/cosmos-sdk/types/query" +) + +// QueryBTCCheckpoint queries the BTCCheckpoint module of the Babylon node +// according to the given function +func (c *QueryClient) QueryBTCCheckpoint(f func(ctx context.Context, queryClient btcctypes.QueryClient) error) error { + ctx, cancel := c.getQueryContext() + defer cancel() + + clientCtx := client.Context{Client: c.RPCClient} + queryClient := btcctypes.NewQueryClient(clientCtx) + + return f(ctx, queryClient) +} + +// BTCCheckpointParams queries btccheckpoint module's parameters via ChainClient +func (c *QueryClient) BTCCheckpointParams() (*btcctypes.QueryParamsResponse, error) { + var resp *btcctypes.QueryParamsResponse + err := c.QueryBTCCheckpoint(func(ctx context.Context, queryClient btcctypes.QueryClient) error { + var err error + req := &btcctypes.QueryParamsRequest{} + resp, err = queryClient.Params(ctx, req) + return err + }) + + return resp, err +} + +// BTCCheckpointInfo queries btccheckpoint module for the Bitcoin position of an epoch +func (c *QueryClient) BTCCheckpointInfo(epochNumber uint64) (*btcctypes.QueryBtcCheckpointInfoResponse, error) { + var resp *btcctypes.QueryBtcCheckpointInfoResponse + err := c.QueryBTCCheckpoint(func(ctx context.Context, queryClient btcctypes.QueryClient) error { + var err error + req := &btcctypes.QueryBtcCheckpointInfoRequest{ + EpochNum: epochNumber, + } + resp, err = queryClient.BtcCheckpointInfo(ctx, req) + return err + }) + + return resp, err +} + +// BTCCheckpointsInfo queries btccheckpoint module for the Bitcoin position of an epoch range +func (c *QueryClient) BTCCheckpointsInfo(pagination *sdkquerytypes.PageRequest) (*btcctypes.QueryBtcCheckpointsInfoResponse, error) { + var resp *btcctypes.QueryBtcCheckpointsInfoResponse + err := c.QueryBTCCheckpoint(func(ctx context.Context, queryClient btcctypes.QueryClient) error { + var err error + req := &btcctypes.QueryBtcCheckpointsInfoRequest{ + Pagination: pagination, + } + resp, err = queryClient.BtcCheckpointsInfo(ctx, req) + return err + }) + return resp, err +} diff --git a/client/query/btclightclient.go b/client/query/btclightclient.go new file mode 100644 index 000000000..3c400c631 --- /dev/null +++ b/client/query/btclightclient.go @@ -0,0 +1,78 @@ +package query + +import ( + "context" + + btclctypes "github.com/babylonlabs-io/babylon/x/btclightclient/types" + "github.com/btcsuite/btcd/chaincfg/chainhash" + "github.com/cosmos/cosmos-sdk/client" + sdkquerytypes "github.com/cosmos/cosmos-sdk/types/query" +) + +// QueryBTCLightclient queries the BTCLightclient module of the Babylon node +// according to the given function +func (c *QueryClient) QueryBTCLightclient(f func(ctx context.Context, queryClient btclctypes.QueryClient) error) error { + ctx, cancel := c.getQueryContext() + defer cancel() + + clientCtx := client.Context{Client: c.RPCClient} + queryClient := btclctypes.NewQueryClient(clientCtx) + + return f(ctx, queryClient) +} + +// BTCHeaderChainTip queries hash/height of the latest BTC block in the btclightclient module +func (c *QueryClient) BTCHeaderChainTip() (*btclctypes.QueryTipResponse, error) { + var resp *btclctypes.QueryTipResponse + err := c.QueryBTCLightclient(func(ctx context.Context, queryClient btclctypes.QueryClient) error { + var err error + req := &btclctypes.QueryTipRequest{} + resp, err = queryClient.Tip(ctx, req) + return err + }) + + return resp, err +} + +// BTCBaseHeader queries the base BTC header of the btclightclient module +func (c *QueryClient) BTCBaseHeader() (*btclctypes.QueryBaseHeaderResponse, error) { + var resp *btclctypes.QueryBaseHeaderResponse + err := c.QueryBTCLightclient(func(ctx context.Context, queryClient btclctypes.QueryClient) error { + var err error + req := &btclctypes.QueryBaseHeaderRequest{} + resp, err = queryClient.BaseHeader(ctx, req) + return err + }) + + return resp, err +} + +// ContainsBTCBlock queries the btclightclient module for the existence of a block hash +func (c *QueryClient) ContainsBTCBlock(blockHash *chainhash.Hash) (*btclctypes.QueryContainsBytesResponse, error) { + var resp *btclctypes.QueryContainsBytesResponse + err := c.QueryBTCLightclient(func(ctx context.Context, queryClient btclctypes.QueryClient) error { + var err error + req := &btclctypes.QueryContainsBytesRequest{ + Hash: blockHash.CloneBytes(), + } + resp, err = queryClient.ContainsBytes(ctx, req) + return err + }) + + return resp, err +} + +// BTCMainChain queries the btclightclient module for the BTC canonical chain +func (c *QueryClient) BTCMainChain(pagination *sdkquerytypes.PageRequest) (*btclctypes.QueryMainChainResponse, error) { + var resp *btclctypes.QueryMainChainResponse + err := c.QueryBTCLightclient(func(ctx context.Context, queryClient btclctypes.QueryClient) error { + var err error + req := &btclctypes.QueryMainChainRequest{ + Pagination: pagination, + } + resp, err = queryClient.MainChain(ctx, req) + return err + }) + + return resp, err +} diff --git a/client/query/btcstaking.go b/client/query/btcstaking.go new file mode 100644 index 000000000..04250fd3d --- /dev/null +++ b/client/query/btcstaking.go @@ -0,0 +1,168 @@ +package query + +import ( + "context" + + btcstakingtypes "github.com/babylonlabs-io/babylon/x/btcstaking/types" + "github.com/cosmos/cosmos-sdk/client" + sdkquerytypes "github.com/cosmos/cosmos-sdk/types/query" +) + +// QueryBTCStaking queries the BTCStaking module of the Babylon node according to the given function +func (c *QueryClient) QueryBTCStaking(f func(ctx context.Context, queryClient btcstakingtypes.QueryClient) error) error { + ctx, cancel := c.getQueryContext() + defer cancel() + + clientCtx := client.Context{Client: c.RPCClient} + queryClient := btcstakingtypes.NewQueryClient(clientCtx) + + return f(ctx, queryClient) +} + +// BTCStakingParams queries the BTC staking module parameters +func (c *QueryClient) BTCStakingParams() (*btcstakingtypes.QueryParamsResponse, error) { + var resp *btcstakingtypes.QueryParamsResponse + err := c.QueryBTCStaking(func(ctx context.Context, queryClient btcstakingtypes.QueryClient) error { + var err error + req := &btcstakingtypes.QueryParamsRequest{} + resp, err = queryClient.Params(ctx, req) + return err + }) + + return resp, err +} + +// BTCStakingParamsByVersion queries the BTC staking module parameters at a given version +func (c *QueryClient) BTCStakingParamsByVersion(version uint32) (*btcstakingtypes.QueryParamsByVersionResponse, error) { + var resp *btcstakingtypes.QueryParamsByVersionResponse + err := c.QueryBTCStaking(func(ctx context.Context, queryClient btcstakingtypes.QueryClient) error { + var err error + req := &btcstakingtypes.QueryParamsByVersionRequest{Version: version} + resp, err = queryClient.ParamsByVersion(ctx, req) + return err + }) + + return resp, err +} + +// FinalityProvider queries the BTCStaking module for a given finlaity provider +func (c *QueryClient) FinalityProvider(fpBtcPkHex string) (*btcstakingtypes.QueryFinalityProviderResponse, error) { + var resp *btcstakingtypes.QueryFinalityProviderResponse + err := c.QueryBTCStaking(func(ctx context.Context, queryClient btcstakingtypes.QueryClient) error { + var err error + req := &btcstakingtypes.QueryFinalityProviderRequest{ + FpBtcPkHex: fpBtcPkHex, + } + resp, err = queryClient.FinalityProvider(ctx, req) + return err + }) + + return resp, err +} + +// FinalityProviders queries the BTCStaking module for all finality providers +func (c *QueryClient) FinalityProviders(pagination *sdkquerytypes.PageRequest) (*btcstakingtypes.QueryFinalityProvidersResponse, error) { + var resp *btcstakingtypes.QueryFinalityProvidersResponse + err := c.QueryBTCStaking(func(ctx context.Context, queryClient btcstakingtypes.QueryClient) error { + var err error + req := &btcstakingtypes.QueryFinalityProvidersRequest{ + Pagination: pagination, + } + resp, err = queryClient.FinalityProviders(ctx, req) + return err + }) + + return resp, err +} + +// FinalityProviderDelegations queries the BTCStaking module for all delegations of a finality provider +func (c *QueryClient) FinalityProviderDelegations(fpBtcPkHex string, pagination *sdkquerytypes.PageRequest) (*btcstakingtypes.QueryFinalityProviderDelegationsResponse, error) { + var resp *btcstakingtypes.QueryFinalityProviderDelegationsResponse + err := c.QueryBTCStaking(func(ctx context.Context, queryClient btcstakingtypes.QueryClient) error { + var err error + req := &btcstakingtypes.QueryFinalityProviderDelegationsRequest{ + FpBtcPkHex: fpBtcPkHex, + Pagination: pagination, + } + resp, err = queryClient.FinalityProviderDelegations(ctx, req) + return err + }) + + return resp, err +} + +// BTCDelegations queries the BTCStaking module for all delegations under a given status +func (c *QueryClient) BTCDelegations(status btcstakingtypes.BTCDelegationStatus, pagination *sdkquerytypes.PageRequest) (*btcstakingtypes.QueryBTCDelegationsResponse, error) { + var resp *btcstakingtypes.QueryBTCDelegationsResponse + err := c.QueryBTCStaking(func(ctx context.Context, queryClient btcstakingtypes.QueryClient) error { + var err error + req := &btcstakingtypes.QueryBTCDelegationsRequest{ + Status: status, + Pagination: pagination, + } + resp, err = queryClient.BTCDelegations(ctx, req) + return err + }) + + return resp, err +} + +// BTCDelegation queries the BTCStaking module to retrieve delegation by corresponding staking tx hash +func (c *QueryClient) BTCDelegation(stakingTxHashHex string) (*btcstakingtypes.QueryBTCDelegationResponse, error) { + var resp *btcstakingtypes.QueryBTCDelegationResponse + err := c.QueryBTCStaking(func(ctx context.Context, queryClient btcstakingtypes.QueryClient) error { + var err error + req := &btcstakingtypes.QueryBTCDelegationRequest{ + StakingTxHashHex: stakingTxHashHex, + } + resp, err = queryClient.BTCDelegation(ctx, req) + return err + }) + + 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/checkpointing.go b/client/query/checkpointing.go new file mode 100644 index 000000000..58466b5bf --- /dev/null +++ b/client/query/checkpointing.go @@ -0,0 +1,113 @@ +package query + +import ( + "context" + + checkpointingtypes "github.com/babylonlabs-io/babylon/x/checkpointing/types" + "github.com/cosmos/cosmos-sdk/client" + sdkquerytypes "github.com/cosmos/cosmos-sdk/types/query" +) + +// QueryCheckpointing queries the Checkpointing module of the Babylon node +// according to the given function +func (c *QueryClient) QueryCheckpointing(f func(ctx context.Context, queryClient checkpointingtypes.QueryClient) error) error { + ctx, cancel := c.getQueryContext() + defer cancel() + + clientCtx := client.Context{Client: c.RPCClient} + queryClient := checkpointingtypes.NewQueryClient(clientCtx) + + return f(ctx, queryClient) +} + +// RawCheckpoint queries the checkpointing module for the raw checkpoint for an epoch number +func (c *QueryClient) RawCheckpoint(epochNumber uint64) (*checkpointingtypes.QueryRawCheckpointResponse, error) { + var resp *checkpointingtypes.QueryRawCheckpointResponse + err := c.QueryCheckpointing(func(ctx context.Context, queryClient checkpointingtypes.QueryClient) error { + var err error + req := &checkpointingtypes.QueryRawCheckpointRequest{ + EpochNum: epochNumber, + } + resp, err = queryClient.RawCheckpoint(ctx, req) + return err + }) + + return resp, err +} + +// RawCheckpointList queries the checkpointing module for a list of raw checkpoints +func (c *QueryClient) RawCheckpointList(status checkpointingtypes.CheckpointStatus, pagination *sdkquerytypes.PageRequest) (*checkpointingtypes.QueryRawCheckpointListResponse, error) { + var resp *checkpointingtypes.QueryRawCheckpointListResponse + err := c.QueryCheckpointing(func(ctx context.Context, queryClient checkpointingtypes.QueryClient) error { + var err error + req := &checkpointingtypes.QueryRawCheckpointListRequest{ + Status: status, + Pagination: pagination, + } + resp, err = queryClient.RawCheckpointList(ctx, req) + return err + }) + + return resp, err +} + +// BlsPublicKeyList queries the checkpointing module for the list of BLS keys for an epoch +func (c *QueryClient) BlsPublicKeyList(epochNumber uint64, pagination *sdkquerytypes.PageRequest) (*checkpointingtypes.QueryBlsPublicKeyListResponse, error) { + var resp *checkpointingtypes.QueryBlsPublicKeyListResponse + err := c.QueryCheckpointing(func(ctx context.Context, queryClient checkpointingtypes.QueryClient) error { + var err error + req := &checkpointingtypes.QueryBlsPublicKeyListRequest{ + EpochNum: epochNumber, + Pagination: pagination, + } + resp, err = queryClient.BlsPublicKeyList(ctx, req) + return err + }) + + return resp, err +} + +// RawCheckpoints queries the checkpointing module for a set of raw checkpoints +func (c *QueryClient) RawCheckpoints(pagination *sdkquerytypes.PageRequest) (*checkpointingtypes.QueryRawCheckpointsResponse, error) { + var resp *checkpointingtypes.QueryRawCheckpointsResponse + err := c.QueryCheckpointing(func(ctx context.Context, queryClient checkpointingtypes.QueryClient) error { + var err error + req := &checkpointingtypes.QueryRawCheckpointsRequest{ + Pagination: pagination, + } + resp, err = queryClient.RawCheckpoints(ctx, req) + return err + }) + + return resp, err +} + +// EpochStatusCount queries the checkpointing module for the status of the latest `epochCount` epochs` +func (c *QueryClient) EpochStatusCount(epochCount uint64) (*checkpointingtypes.QueryRecentEpochStatusCountResponse, error) { + var resp *checkpointingtypes.QueryRecentEpochStatusCountResponse + err := c.QueryCheckpointing(func(ctx context.Context, queryClient checkpointingtypes.QueryClient) error { + var err error + req := &checkpointingtypes.QueryRecentEpochStatusCountRequest{ + EpochCount: epochCount, + } + resp, err = queryClient.RecentEpochStatusCount(ctx, req) + return err + }) + + return resp, err +} + +// LatestEpochFromStatus queries the checkpointing module for the last checkpoint with a particular status +func (c *QueryClient) LatestEpochFromStatus(status checkpointingtypes.CheckpointStatus) (*checkpointingtypes.QueryLastCheckpointWithStatusResponse, error) { + var resp *checkpointingtypes.QueryLastCheckpointWithStatusResponse + err := c.QueryCheckpointing(func(ctx context.Context, queryClient checkpointingtypes.QueryClient) error { + var err error + req := &checkpointingtypes.QueryLastCheckpointWithStatusRequest{ + Status: status, + } + resp, err = queryClient.LastCheckpointWithStatus(ctx, req) + return err + }) + + return resp, err +} diff --git a/client/query/client.go b/client/query/client.go new file mode 100644 index 000000000..4a41f4fd9 --- /dev/null +++ b/client/query/client.go @@ -0,0 +1,95 @@ +package query + +import ( + "context" + "fmt" + "strconv" + "time" + + "github.com/cosmos/cosmos-sdk/types/query" + + "github.com/babylonlabs-io/babylon/client/config" + rpcclient "github.com/cometbft/cometbft/rpc/client" + "github.com/cosmos/cosmos-sdk/client" + grpctypes "github.com/cosmos/cosmos-sdk/types/grpc" + "google.golang.org/grpc/metadata" +) + +// QueryClient is a client that can only perform queries to a Babylon node +// It only requires `Cfg` to have `Timeout` and `RPCAddr`, but not other fields +// such as keyring, chain ID, etc.. +type QueryClient struct { + RPCClient rpcclient.Client + timeout time.Duration +} + +// New creates a new QueryClient according to the given config +func New(cfg *config.BabylonQueryConfig) (*QueryClient, error) { + if err := cfg.Validate(); err != nil { + return nil, err + } + + tmClient, err := client.NewClientFromNode(cfg.RPCAddr) + if err != nil { + return nil, err + } + + return &QueryClient{ + RPCClient: tmClient, + timeout: cfg.Timeout, + }, nil +} + +// NewWithClient creates a new QueryClient with a given existing rpcClient and timeout +// used by `client/` where `ChainClient` already creates an rpc client +func NewWithClient(rpcClient rpcclient.Client, timeout time.Duration) (*QueryClient, error) { + if timeout <= 0 { + return nil, fmt.Errorf("timeout must be positive") + } + + client := &QueryClient{ + RPCClient: rpcClient, + timeout: timeout, + } + + return client, nil +} + +func (c *QueryClient) Start() error { + return c.RPCClient.Start() +} + +func (c *QueryClient) Stop() error { + return c.RPCClient.Stop() +} + +func (c *QueryClient) IsRunning() bool { + return c.RPCClient.IsRunning() +} + +// getQueryContext returns a context that includes the height and uses the timeout from the config +// (adapted from https://github.com/strangelove-ventures/lens/blob/v0.5.4/client/query/query_options.go#L29-L36) +func (c *QueryClient) getQueryContext() (context.Context, context.CancelFunc) { + defaultOptions := DefaultQueryOptions() + ctx, cancel := context.WithTimeout(context.Background(), c.timeout) + strHeight := strconv.Itoa(int(defaultOptions.Height)) + ctx = metadata.AppendToOutgoingContext(ctx, grpctypes.GRPCBlockHeightHeader, strHeight) + return ctx, cancel +} + +type QueryOptions struct { + Pagination *query.PageRequest + Height int64 +} + +func DefaultQueryOptions() *QueryOptions { + return &QueryOptions{ + Pagination: &query.PageRequest{ + Key: []byte(""), + Offset: 0, + Limit: 1000, + CountTotal: true, + }, + Height: 0, + } +} diff --git a/client/query/epoching.go b/client/query/epoching.go new file mode 100644 index 000000000..ec6dc792e --- /dev/null +++ b/client/query/epoching.go @@ -0,0 +1,95 @@ +package query + +import ( + "context" + + epochingtypes "github.com/babylonlabs-io/babylon/x/epoching/types" + "github.com/cosmos/cosmos-sdk/client" + sdkquerytypes "github.com/cosmos/cosmos-sdk/types/query" +) + +// QueryEpoching queries the Epoching module of the Babylon node +// according to the given function +func (c *QueryClient) QueryEpoching(f func(ctx context.Context, queryClient epochingtypes.QueryClient) error) error { + ctx, cancel := c.getQueryContext() + defer cancel() + + clientCtx := client.Context{Client: c.RPCClient} + queryClient := epochingtypes.NewQueryClient(clientCtx) + + return f(ctx, queryClient) +} + +// EpochingParams queries epoching module's parameters via ChainClient +func (c *QueryClient) EpochingParams() (*epochingtypes.QueryParamsResponse, error) { + var resp *epochingtypes.QueryParamsResponse + err := c.QueryEpoching(func(ctx context.Context, queryClient epochingtypes.QueryClient) error { + var err error + req := &epochingtypes.QueryParamsRequest{} + resp, err = queryClient.Params(ctx, req) + return err + }) + + return resp, err +} + +// CurrentEpoch queries the current epoch number via ChainClient +func (c *QueryClient) CurrentEpoch() (*epochingtypes.QueryCurrentEpochResponse, error) { + var resp *epochingtypes.QueryCurrentEpochResponse + err := c.QueryEpoching(func(ctx context.Context, queryClient epochingtypes.QueryClient) error { + var err error + req := &epochingtypes.QueryCurrentEpochRequest{} + resp, err = queryClient.CurrentEpoch(ctx, req) + return err + }) + + return resp, err +} + +// EpochsInfo queries the epoching module for the maintained epochs +func (c *QueryClient) EpochsInfo(pagination *sdkquerytypes.PageRequest) (*epochingtypes.QueryEpochsInfoResponse, error) { + var resp *epochingtypes.QueryEpochsInfoResponse + err := c.QueryEpoching(func(ctx context.Context, queryClient epochingtypes.QueryClient) error { + var err error + req := &epochingtypes.QueryEpochsInfoRequest{ + Pagination: pagination, + } + resp, err = queryClient.EpochsInfo(ctx, req) + return err + }) + + return resp, err +} + +// LatestEpochMsgs queries the epoching module for the latest messages maintained in its delayed +// staking queue until a specified endEpoch. +func (c *QueryClient) LatestEpochMsgs(endEpoch uint64, epochCount uint64, pagination *sdkquerytypes.PageRequest) (*epochingtypes.QueryLatestEpochMsgsResponse, error) { + var resp *epochingtypes.QueryLatestEpochMsgsResponse + err := c.QueryEpoching(func(ctx context.Context, queryClient epochingtypes.QueryClient) error { + var err error + req := &epochingtypes.QueryLatestEpochMsgsRequest{ + EndEpoch: endEpoch, + EpochCount: epochCount, + Pagination: pagination, + } + resp, err = queryClient.LatestEpochMsgs(ctx, req) + return err + }) + + return resp, err +} + +// DelegationLifecycle queries the epoching module for the lifecycle of a delegator. +func (c *QueryClient) DelegationLifecycle(delegator string) (*epochingtypes.QueryDelegationLifecycleResponse, error) { + var resp *epochingtypes.QueryDelegationLifecycleResponse + err := c.QueryEpoching(func(ctx context.Context, queryClient epochingtypes.QueryClient) error { + var err error + req := &epochingtypes.QueryDelegationLifecycleRequest{ + DelAddr: delegator, + } + resp, err = queryClient.DelegationLifecycle(ctx, req) + return err + }) + + return resp, err +} diff --git a/client/query/finality.go b/client/query/finality.go new file mode 100644 index 000000000..2db05d281 --- /dev/null +++ b/client/query/finality.go @@ -0,0 +1,109 @@ +package query + +import ( + "context" + + finalitytypes "github.com/babylonlabs-io/babylon/x/finality/types" + "github.com/cosmos/cosmos-sdk/client" + sdkquerytypes "github.com/cosmos/cosmos-sdk/types/query" +) + +// QueryFinality queries the Finality module of the Babylon node according to the given function +func (c *QueryClient) QueryFinality(f func(ctx context.Context, queryClient finalitytypes.QueryClient) error) error { + ctx, cancel := c.getQueryContext() + defer cancel() + + clientCtx := client.Context{Client: c.RPCClient} + queryClient := finalitytypes.NewQueryClient(clientCtx) + + return f(ctx, queryClient) +} + +// FinalityParams queries the finality module parameters +func (c *QueryClient) FinalityParams() (*finalitytypes.Params, error) { + var resp *finalitytypes.QueryParamsResponse + err := c.QueryFinality(func(ctx context.Context, queryClient finalitytypes.QueryClient) error { + var err error + req := &finalitytypes.QueryParamsRequest{} + resp, err = queryClient.Params(ctx, req) + return err + }) + + return &resp.Params, err +} + +// VotesAtHeight queries the Finality module to get signature set at a given babylon block height +func (c *QueryClient) VotesAtHeight(height uint64) (*finalitytypes.QueryVotesAtHeightResponse, error) { + var resp *finalitytypes.QueryVotesAtHeightResponse + err := c.QueryFinality(func(ctx context.Context, queryClient finalitytypes.QueryClient) error { + var err error + req := &finalitytypes.QueryVotesAtHeightRequest{ + Height: height, + } + resp, err = queryClient.VotesAtHeight(ctx, req) + return err + }) + + return resp, err +} +func (c *QueryClient) ListPubRandCommit(fpBtcPkHex string, pagination *sdkquerytypes.PageRequest) (*finalitytypes.QueryListPubRandCommitResponse, error) { + var resp *finalitytypes.QueryListPubRandCommitResponse + err := c.QueryFinality(func(ctx context.Context, queryClient finalitytypes.QueryClient) error { + var err error + req := &finalitytypes.QueryListPubRandCommitRequest{ + FpBtcPkHex: fpBtcPkHex, + Pagination: pagination, + } + resp, err = queryClient.ListPubRandCommit(ctx, req) + return err + }) + + return resp, err +} + +// ListBlocks queries the Finality module to get blocks with a given status. +func (c *QueryClient) ListBlocks(status finalitytypes.QueriedBlockStatus, pagination *sdkquerytypes.PageRequest) (*finalitytypes.QueryListBlocksResponse, error) { + var resp *finalitytypes.QueryListBlocksResponse + err := c.QueryFinality(func(ctx context.Context, queryClient finalitytypes.QueryClient) error { + var err error + req := &finalitytypes.QueryListBlocksRequest{ + Status: status, + Pagination: pagination, + } + resp, err = queryClient.ListBlocks(ctx, req) + return err + }) + + return resp, err +} + +// Block queries a block at a given height. +func (c *QueryClient) Block(height uint64) (*finalitytypes.QueryBlockResponse, error) { + var resp *finalitytypes.QueryBlockResponse + err := c.QueryFinality(func(ctx context.Context, queryClient finalitytypes.QueryClient) error { + var err error + req := &finalitytypes.QueryBlockRequest{ + Height: height, + } + resp, err = queryClient.Block(ctx, req) + return err + }) + + return resp, err +} + +// ListEvidences queries the Finality module to get evidences after a given height. +func (c *QueryClient) ListEvidences(startHeight uint64, pagination *sdkquerytypes.PageRequest) (*finalitytypes.QueryListEvidencesResponse, error) { + var resp *finalitytypes.QueryListEvidencesResponse + err := c.QueryFinality(func(ctx context.Context, queryClient finalitytypes.QueryClient) error { + var err error + req := &finalitytypes.QueryListEvidencesRequest{ + StartHeight: startHeight, + Pagination: pagination, + } + resp, err = queryClient.ListEvidences(ctx, req) + return err + }) + + return resp, err +} diff --git a/client/query/incentive.go b/client/query/incentive.go new file mode 100644 index 000000000..6031578c6 --- /dev/null +++ b/client/query/incentive.go @@ -0,0 +1,34 @@ +package query + +import ( + "context" + + incentivetypes "github.com/babylonlabs-io/babylon/x/incentive/types" + "github.com/cosmos/cosmos-sdk/client" +) + +// QueryIncentive queries the Incentive module of the Babylon node +func (c *QueryClient) QueryIncentive(f func(ctx context.Context, queryClient incentivetypes.QueryClient) error) error { + ctx, cancel := c.getQueryContext() + defer cancel() + + clientCtx := client.Context{Client: c.RPCClient} + queryClient := incentivetypes.NewQueryClient(clientCtx) + + return f(ctx, queryClient) +} + +// RewardGauges queries the Incentive module to get all reward gauges +func (c *QueryClient) RewardGauges(address string) (*incentivetypes.QueryRewardGaugesResponse, error) { + var resp *incentivetypes.QueryRewardGaugesResponse + err := c.QueryIncentive(func(ctx context.Context, queryClient incentivetypes.QueryClient) error { + var err error + req := &incentivetypes.QueryRewardGaugesRequest{ + Address: address, + } + resp, err = queryClient.RewardGauges(ctx, req) + return err + }) + + return resp, err +} diff --git a/client/query/monitor.go b/client/query/monitor.go new file mode 100644 index 000000000..d08597e51 --- /dev/null +++ b/client/query/monitor.go @@ -0,0 +1,50 @@ +package query + +import ( + "context" + + monitortypes "github.com/babylonlabs-io/babylon/x/monitor/types" + "github.com/cosmos/cosmos-sdk/client" +) + +// QueryMonitor queries the Monitor module of the Babylon node +// according to the given function +func (c *QueryClient) QueryMonitor(f func(ctx context.Context, queryClient monitortypes.QueryClient) error) error { + ctx, cancel := c.getQueryContext() + defer cancel() + + clientCtx := client.Context{Client: c.RPCClient} + queryClient := monitortypes.NewQueryClient(clientCtx) + + return f(ctx, queryClient) +} + +// EndedEpochBTCHeight queries the tip height of BTC light client at epoch ends +func (c *QueryClient) EndedEpochBTCHeight(epochNum uint64) (*monitortypes.QueryEndedEpochBtcHeightResponse, error) { + var resp *monitortypes.QueryEndedEpochBtcHeightResponse + err := c.QueryMonitor(func(ctx context.Context, queryClient monitortypes.QueryClient) error { + var err error + req := &monitortypes.QueryEndedEpochBtcHeightRequest{ + EpochNum: epochNum, + } + resp, err = queryClient.EndedEpochBtcHeight(ctx, req) + return err + }) + + return resp, err +} + +// ReportedCheckpointBTCHeight queries the tip height of BTC light client when a given checkpoint is reported +func (c *QueryClient) ReportedCheckpointBTCHeight(hashStr string) (*monitortypes.QueryReportedCheckpointBtcHeightResponse, error) { + var resp *monitortypes.QueryReportedCheckpointBtcHeightResponse + err := c.QueryMonitor(func(ctx context.Context, queryClient monitortypes.QueryClient) error { + var err error + req := &monitortypes.QueryReportedCheckpointBtcHeightRequest{ + CkptHash: hashStr, + } + resp, err = queryClient.ReportedCheckpointBtcHeight(ctx, req) + return err + }) + + return resp, err +} diff --git a/client/query/staking.go b/client/query/staking.go new file mode 100644 index 000000000..ae6bbe3ab --- /dev/null +++ b/client/query/staking.go @@ -0,0 +1,33 @@ +package query + +import ( + "context" + + "github.com/cosmos/cosmos-sdk/client" + stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" +) + +// QueryStaking queries the Staking module of the Babylon node +// according to the given function +func (c *QueryClient) QueryStaking(f func(ctx context.Context, queryClient stakingtypes.QueryClient) error) error { + ctx, cancel := c.getQueryContext() + defer cancel() + + clientCtx := client.Context{Client: c.RPCClient} + queryClient := stakingtypes.NewQueryClient(clientCtx) + + return f(ctx, queryClient) +} + +// StakingParams queries btccheckpoint module's parameters via ChainClient +func (c *QueryClient) StakingParams() (*stakingtypes.QueryParamsResponse, error) { + var resp *stakingtypes.QueryParamsResponse + err := c.QueryStaking(func(ctx context.Context, queryClient stakingtypes.QueryClient) error { + var err error + req := &stakingtypes.QueryParamsRequest{} + resp, err = queryClient.Params(ctx, req) + return err + }) + + return resp, err +} diff --git a/client/query/tendermint.go b/client/query/tendermint.go new file mode 100644 index 000000000..cf00304dc --- /dev/null +++ b/client/query/tendermint.go @@ -0,0 +1,60 @@ +package query + +import ( + "context" + "strings" + + coretypes "github.com/cometbft/cometbft/rpc/core/types" +) + +// GetStatus returns the status of the tendermint node +func (c *QueryClient) GetStatus() (*coretypes.ResultStatus, error) { + ctx, cancel := c.getQueryContext() + defer cancel() + + return c.RPCClient.Status(ctx) +} + +// GetBlock returns the tendermint block at a specific height +func (c *QueryClient) GetBlock(height int64) (*coretypes.ResultBlock, error) { + ctx, cancel := c.getQueryContext() + defer cancel() + + return c.RPCClient.Block(ctx, &height) +} + +// BlockSearch searches for blocks satisfying the events specified on the events list +func (c *QueryClient) BlockSearch(events []string, page *int, perPage *int, orderBy string) (*coretypes.ResultBlockSearch, error) { + ctx, cancel := c.getQueryContext() + defer cancel() + + return c.RPCClient.BlockSearch(ctx, strings.Join(events, " AND "), page, perPage, orderBy) +} + +// TxSearch searches for transactions satisfying the events specified on the events list +func (c *QueryClient) TxSearch(events []string, prove bool, page *int, perPage *int, orderBy string) (*coretypes.ResultTxSearch, error) { + ctx, cancel := c.getQueryContext() + defer cancel() + + return c.RPCClient.TxSearch(ctx, strings.Join(events, " AND "), prove, page, perPage, orderBy) +} + +// GetTx returns the transaction with the specified hash +func (c *QueryClient) GetTx(hash []byte) (*coretypes.ResultTx, error) { + ctx, cancel := c.getQueryContext() + defer cancel() + + return c.RPCClient.Tx(ctx, hash, false) +} + +func (c *QueryClient) Subscribe(subscriber, query string, outCapacity ...int) (out <-chan coretypes.ResultEvent, err error) { + return c.RPCClient.Subscribe(context.Background(), subscriber, query, outCapacity...) +} + +func (c *QueryClient) Unsubscribe(subscriber, query string) error { + return c.RPCClient.Unsubscribe(context.Background(), subscriber, query) +} + +func (c *QueryClient) UnsubscribeAll(subscriber string) error { + return c.RPCClient.UnsubscribeAll(context.Background(), subscriber) +} diff --git a/client/query/zoneconcierge.go b/client/query/zoneconcierge.go new file mode 100644 index 000000000..6639d5207 --- /dev/null +++ b/client/query/zoneconcierge.go @@ -0,0 +1,96 @@ +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(chainIds []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{ + ChainIds: chainIds, + } + 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(chainIds []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{ + ChainIds: chainIds, + } + 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(chainID 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{ + ChainId: chainID, + 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(chainIds []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{ + ChainIds: chainIds, + EpochNum: epochNum, + } + resp, err = queryClient.EpochChainsInfo(ctx, req) + return err + }) + + return resp, err +} diff --git a/client/tx/tx.go b/client/tx/tx.go deleted file mode 100644 index 97128e375..000000000 --- a/client/tx/tx.go +++ /dev/null @@ -1,116 +0,0 @@ -package tx - -import ( - "context" - "errors" - "fmt" - - "github.com/cosmos/cosmos-sdk/client" - sdktx "github.com/cosmos/cosmos-sdk/client/tx" - sdk "github.com/cosmos/cosmos-sdk/types" - - "github.com/babylonchain/babylon/types" -) - -func SendMsgToComet(ctx context.Context, clientCtx client.Context, msg sdk.Msg) (*sdk.TxResponse, error) { - return SendMsgsToComet(ctx, clientCtx, []sdk.Msg{msg}) -} - -func SendMsgsToComet(ctx context.Context, clientCtx client.Context, msgs []sdk.Msg) (*sdk.TxResponse, error) { - gasPrice, gasAdjustment := types.MustGetGasSettings(clientCtx.HomeDir, clientCtx.Viper) - txf := sdktx.Factory{}. - WithTxConfig(clientCtx.TxConfig). - WithAccountRetriever(clientCtx.AccountRetriever). - WithKeybase(clientCtx.Keyring). - WithChainID(clientCtx.ChainID). - WithFeePayer(clientCtx.FeePayer). - WithGasPrices(gasPrice). - WithGasAdjustment(gasAdjustment) - - return BroadcastTx(ctx, clientCtx, txf, msgs...) -} - -// BroadcastTx attempts to generate, sign and broadcast a transaction with the -// given set of messages. It will also simulate gas requirements if necessary. -// It will return an error upon failure. -// The code is based on cosmos-sdk: https://github.com/cosmos/cosmos-sdk/blob/7781cdb3d20bc7ebac017452897ce1e6ab3903ef/client/tx/tx.go#L65 -// it treats non-zero response code as errors -func BroadcastTx(ctx context.Context, clientCtx client.Context, txf sdktx.Factory, msgs ...sdk.Msg) (*sdk.TxResponse, error) { - txf, err := prepareFactory(clientCtx, txf) - if err != nil { - return nil, err - } - - _, adjusted, err := sdktx.CalculateGas(clientCtx, txf, msgs...) - if err != nil { - return nil, err - } - - if adjusted <= 0 { - return nil, errors.New("calculated gas should be positive") - } - - txf = txf.WithGas(adjusted) - - tx, err := txf.BuildUnsignedTx(msgs...) - if err != nil { - return nil, err - } - - tx.SetFeeGranter(clientCtx.GetFeeGranterAddress()) - - err = sdktx.Sign(ctx, txf, clientCtx.GetFromName(), tx, true) - if err != nil { - return nil, err - } - - txBytes, err := clientCtx.TxConfig.TxEncoder()(tx.GetTx()) - if err != nil { - return nil, err - } - - // broadcast to a comet node - res, err := clientCtx.BroadcastTx(txBytes) - if err != nil { - return nil, err - } - - // transaction was executed, log the success or failure using the tx response code - // NOTE: error is nil, logic should use the returned error to determine if the - // transaction was successfully executed. - if res.Code != 0 { - _ = clientCtx.PrintProto(res) - return res, fmt.Errorf("transaction failed with code: %d", res.Code) - } - - return res, nil -} - -// prepareFactory ensures the account defined by ctx.GetFromAddress() exists and -// if the account number and/or the account sequence number are zero (not set), -// they will be queried for and set on the provided Factory. A new Factory with -// the updated fields will be returned. -func prepareFactory(clientCtx client.Context, txf sdktx.Factory) (sdktx.Factory, error) { - from := clientCtx.GetFromAddress() - - if err := txf.AccountRetriever().EnsureExists(clientCtx, from); err != nil { - return txf, err - } - - initNum, initSeq := txf.AccountNumber(), txf.Sequence() - if initNum == 0 || initSeq == 0 { - num, seq, err := txf.AccountRetriever().GetAccountNumberSequence(clientCtx, from) - if err != nil { - return txf, err - } - - if initNum == 0 { - txf = txf.WithAccountNumber(num) - } - if initSeq == 0 { - txf = txf.WithSequence(seq) - } - } - - return txf, nil -} diff --git a/cmd/babylond/cmd/cmd_test.go b/cmd/babylond/cmd/cmd_test.go index f00b10994..ddebd4ac7 100644 --- a/cmd/babylond/cmd/cmd_test.go +++ b/cmd/babylond/cmd/cmd_test.go @@ -6,8 +6,8 @@ import ( "github.com/stretchr/testify/require" - "github.com/babylonchain/babylon/app" - "github.com/babylonchain/babylon/cmd/babylond/cmd" + "github.com/babylonlabs-io/babylon/app" + "github.com/babylonlabs-io/babylon/cmd/babylond/cmd" svrcmd "github.com/cosmos/cosmos-sdk/server/cmd" "github.com/cosmos/cosmos-sdk/x/genutil/client/cli" ) diff --git a/cmd/babylond/cmd/create_bls_key.go b/cmd/babylond/cmd/create_bls_key.go index d72c5301d..37e4f4be4 100644 --- a/cmd/babylond/cmd/create_bls_key.go +++ b/cmd/babylond/cmd/create_bls_key.go @@ -12,10 +12,10 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" "github.com/spf13/cobra" - "github.com/babylonchain/babylon/app" - appparams "github.com/babylonchain/babylon/app/params" - "github.com/babylonchain/babylon/crypto/bls12381" - "github.com/babylonchain/babylon/privval" + "github.com/babylonlabs-io/babylon/app" + appparams "github.com/babylonlabs-io/babylon/app/params" + "github.com/babylonlabs-io/babylon/crypto/bls12381" + "github.com/babylonlabs-io/babylon/privval" ) func CreateBlsKeyCmd() *cobra.Command { @@ -60,12 +60,25 @@ func CreateBlsKey(home string, addr sdk.AccAddress) error { nodeCfg := cmtconfig.DefaultConfig() keyPath := filepath.Join(home, nodeCfg.PrivValidatorKeyFile()) statePath := filepath.Join(home, nodeCfg.PrivValidatorStateFile()) - if !cmtos.FileExists(keyPath) { - return errors.New("validator key file does not exist") + + pv, err := LoadWrappedFilePV(keyPath, statePath) + if err != nil { + return err } - pv := privval.LoadWrappedFilePV(keyPath, statePath) + wrappedPV := privval.NewWrappedFilePV(pv.GetValPrivKey(), bls12381.GenPrivKey(), keyPath, statePath) wrappedPV.SetAccAddress(addr) return nil } + +// LoadWrappedFilePV loads the wrapped file private key from the file path. +func LoadWrappedFilePV(keyPath, statePath string) (*privval.WrappedFilePV, error) { + if !cmtos.FileExists(keyPath) { + return nil, errors.New("validator key file does not exist") + } + if !cmtos.FileExists(statePath) { + return nil, errors.New("validator state file does not exist") + } + return privval.LoadWrappedFilePV(keyPath, statePath), nil +} diff --git a/cmd/babylond/cmd/custom_babylon_config.go b/cmd/babylond/cmd/custom_babylon_config.go index c90ec3210..055f6069f 100644 --- a/cmd/babylond/cmd/custom_babylon_config.go +++ b/cmd/babylond/cmd/custom_babylon_config.go @@ -4,7 +4,7 @@ import ( wasmtypes "github.com/CosmWasm/wasmd/x/wasm/types" serverconfig "github.com/cosmos/cosmos-sdk/server/config" - bbn "github.com/babylonchain/babylon/types" + bbn "github.com/babylonlabs-io/babylon/types" ) type BtcConfig struct { diff --git a/cmd/babylond/cmd/flags.go b/cmd/babylond/cmd/flags.go index ee7c61488..65713599a 100644 --- a/cmd/babylond/cmd/flags.go +++ b/cmd/babylond/cmd/flags.go @@ -10,10 +10,10 @@ import ( "github.com/cosmos/cosmos-sdk/client/flags" "github.com/spf13/cobra" - babylonApp "github.com/babylonchain/babylon/app" - btcctypes "github.com/babylonchain/babylon/x/btccheckpoint/types" - btcltypes "github.com/babylonchain/babylon/x/btclightclient/types" - btcstypes "github.com/babylonchain/babylon/x/btcstaking/types" + babylonApp "github.com/babylonlabs-io/babylon/app" + 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" ) const ( @@ -37,10 +37,10 @@ const ( flagCovenantQuorum = "covenant-quorum" flagMaxActiveFinalityProviders = "max-active-finality-providers" flagMinUnbondingTime = "min-unbonding-time" + flagMinUnbondingRate = "min-unbonding-rate" flagSlashingAddress = "slashing-address" flagMinSlashingFee = "min-slashing-fee-sat" flagSlashingRate = "slashing-rate" - flagMinPubRand = "min-pub-rand" flagMinCommissionRate = "min-commission-rate" ) @@ -69,7 +69,7 @@ type GenesisCLIArgs struct { SlashingRate math.LegacyDec MaxActiveFinalityProviders uint32 MinUnbondingTime uint16 - MinPubRand uint64 + MinUnbondingRate math.LegacyDec MinCommissionRate math.LegacyDec } @@ -97,8 +97,7 @@ func addGenesisFlags(cmd *cobra.Command) { cmd.Flags().String(flagSlashingRate, "0.1", "Bitcoin staking slashing rate") cmd.Flags().Uint32(flagMaxActiveFinalityProviders, 100, "Bitcoin staking maximum active finality providers") cmd.Flags().Uint16(flagMinUnbondingTime, 0, "Min timelock on unbonding transaction in btc blocks") - // finality args - cmd.Flags().Uint64(flagMinPubRand, 100, "Bitcoin staking minimum public randomness commit") + cmd.Flags().String(flagMinUnbondingRate, "0.8", "Min amount of btc required in unbonding output expressed as a fraction of staking output") // inflation args cmd.Flags().Float64(flagInflationRateChange, 0.13, "Inflation rate change") cmd.Flags().Float64(flagInflationMax, 0.2, "Maximum inflation") @@ -130,7 +129,7 @@ func parseGenesisFlags(cmd *cobra.Command) *GenesisCLIArgs { slashingRate, _ := cmd.Flags().GetString(flagSlashingRate) maxActiveFinalityProviders, _ := cmd.Flags().GetUint32(flagMaxActiveFinalityProviders) minUnbondingTime, _ := cmd.Flags().GetUint16(flagMinUnbondingTime) - minPubRand, _ := cmd.Flags().GetUint64(flagMinPubRand) + minUnbondingRate, _ := cmd.Flags().GetString(flagMinUnbondingRate) genesisTimeUnix, _ := cmd.Flags().GetInt64(flagGenesisTime) inflationRateChange, _ := cmd.Flags().GetFloat64(flagInflationRateChange) inflationMax, _ := cmd.Flags().GetFloat64(flagInflationMax) @@ -169,7 +168,7 @@ func parseGenesisFlags(cmd *cobra.Command) *GenesisCLIArgs { SlashingRate: math.LegacyMustNewDecFromStr(slashingRate), MaxActiveFinalityProviders: maxActiveFinalityProviders, MinUnbondingTime: minUnbondingTime, - MinPubRand: minPubRand, + MinUnbondingRate: math.LegacyMustNewDecFromStr(minUnbondingRate), GenesisTime: genesisTime, InflationRateChange: inflationRateChange, InflationMax: inflationMax, diff --git a/cmd/babylond/cmd/genaccounts_test.go b/cmd/babylond/cmd/genaccounts_test.go index 0142009a1..0ea1ba566 100644 --- a/cmd/babylond/cmd/genaccounts_test.go +++ b/cmd/babylond/cmd/genaccounts_test.go @@ -3,7 +3,7 @@ package cmd_test import ( "context" "fmt" - "github.com/babylonchain/babylon/app" + "github.com/babylonlabs-io/babylon/app" "testing" "github.com/cosmos/cosmos-sdk/crypto/hd" @@ -22,7 +22,7 @@ import ( "github.com/cosmos/cosmos-sdk/x/genutil" genutiltest "github.com/cosmos/cosmos-sdk/x/genutil/client/testutil" - bbncmd "github.com/babylonchain/babylon/cmd/babylond/cmd" + bbncmd "github.com/babylonlabs-io/babylon/cmd/babylond/cmd" ) var testMbm = module.NewBasicManager(genutil.AppModuleBasic{}) diff --git a/cmd/babylond/cmd/genesis.go b/cmd/babylond/cmd/genesis.go index 27d9d73ac..23a6d7dad 100644 --- a/cmd/babylond/cmd/genesis.go +++ b/cmd/babylond/cmd/genesis.go @@ -7,8 +7,8 @@ import ( sdkmath "cosmossdk.io/math" - btcstakingtypes "github.com/babylonchain/babylon/x/btcstaking/types" - finalitytypes "github.com/babylonchain/babylon/x/finality/types" + btcstakingtypes "github.com/babylonlabs-io/babylon/x/btcstaking/types" + finalitytypes "github.com/babylonlabs-io/babylon/x/finality/types" comettypes "github.com/cometbft/cometbft/types" "github.com/cosmos/cosmos-sdk/client" @@ -29,12 +29,12 @@ import ( stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" "github.com/spf13/cobra" - appparams "github.com/babylonchain/babylon/app/params" - bbn "github.com/babylonchain/babylon/types" - btccheckpointtypes "github.com/babylonchain/babylon/x/btccheckpoint/types" - btclightclienttypes "github.com/babylonchain/babylon/x/btclightclient/types" - checkpointingtypes "github.com/babylonchain/babylon/x/checkpointing/types" - epochingtypes "github.com/babylonchain/babylon/x/epoching/types" + 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" + checkpointingtypes "github.com/babylonlabs-io/babylon/x/checkpointing/types" + epochingtypes "github.com/babylonlabs-io/babylon/x/epoching/types" ) func PrepareGenesisCmd(defaultNodeHome string, mbm module.BasicManager) *cobra.Command { @@ -75,7 +75,7 @@ Example: genesisCliArgs.CovenantPKs, genesisCliArgs.CovenantQuorum, genesisCliArgs.SlashingAddress, genesisCliArgs.MinSlashingTransactionFeeSat, genesisCliArgs.MinCommissionRate, genesisCliArgs.SlashingRate, genesisCliArgs.MaxActiveFinalityProviders, - genesisCliArgs.MinUnbondingTime, genesisCliArgs.MinPubRand, genesisCliArgs.InflationRateChange, + genesisCliArgs.MinUnbondingTime, genesisCliArgs.MinUnbondingRate, genesisCliArgs.InflationRateChange, genesisCliArgs.InflationMin, genesisCliArgs.InflationMax, genesisCliArgs.GoalBonded, genesisCliArgs.BlocksPerYear, genesisCliArgs.GenesisTime, genesisCliArgs.BlockGasLimit, genesisCliArgs.VoteExtensionEnableHeight) } else if network == "mainnet" { @@ -138,7 +138,7 @@ func PrepareGenesis( // btclightclient genesis btclightclientGenState := btclightclienttypes.DefaultGenesis() - btclightclientGenState.BaseBtcHeader = genesisParams.BtclightclientBaseBtcHeader + btclightclientGenState.BtcHeaders = []*btclightclienttypes.BTCHeaderInfo{&genesisParams.BtclightclientBaseBtcHeader} btclightclientGenState.Params = genesisParams.BtclightclientParams genesisState[btclightclienttypes.ModuleName] = clientCtx.Codec.MustMarshalJSON(btclightclientGenState) @@ -154,7 +154,8 @@ func PrepareGenesis( // btcstaking module genesis btcstakingGenState := btcstakingtypes.DefaultGenesis() - btcstakingGenState.Params = genesisParams.BtcstakingParams + // here we can start only from single params, which will be initially labelled version 0 + btcstakingGenState.Params = []*btcstakingtypes.Params{&genesisParams.BtcstakingParams} genesisState[btcstakingtypes.ModuleName] = clientCtx.Codec.MustMarshalJSON(btcstakingGenState) // finality module genesis @@ -240,8 +241,7 @@ type GenesisParams struct { func TestnetGenesisParams(maxActiveValidators uint32, btcConfirmationDepth uint64, btcFinalizationTimeout uint64, checkpointTag string, epochInterval uint64, baseBtcHeaderHex string, baseBtcHeaderHeight uint64, allowedReporters []string, covenantPKs []string, covenantQuorum uint32, slashingAddress string, minSlashingFee int64, - minCommissionRate sdkmath.LegacyDec, slashingRate sdkmath.LegacyDec, maxActiveFinalityProviders uint32, minUnbondingTime uint16, - minPubRand uint64, inflationRateChange float64, + minCommissionRate sdkmath.LegacyDec, slashingRate sdkmath.LegacyDec, maxActiveFinalityProviders uint32, minUnbondingTime uint16, minUnbondingRate sdkmath.LegacyDec, inflationRateChange float64, inflationMin float64, inflationMax float64, goalBonded float64, blocksPerYear uint64, genesisTime time.Time, blockGasLimit int64, voteExtensionEnableHeight int64) GenesisParams { @@ -286,10 +286,15 @@ func TestnetGenesisParams(maxActiveValidators uint32, btcConfirmationDepth uint6 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), )) + genParams.GovParams.ExpeditedMinDeposit = sdk.NewCoins(sdk.NewCoin( + genParams.NativeCoinMetadatas[0].Base, + sdkmath.NewInt(10_000_000_000), + )) genParams.CrisisConstantFee = sdk.NewCoin( genParams.NativeCoinMetadatas[0].Base, @@ -339,12 +344,12 @@ func TestnetGenesisParams(maxActiveValidators uint32, btcConfirmationDepth uint6 genParams.BtcstakingParams.SlashingRate = slashingRate genParams.BtcstakingParams.MaxActiveFinalityProviders = maxActiveFinalityProviders genParams.BtcstakingParams.MinUnbondingTime = uint32(minUnbondingTime) + genParams.BtcstakingParams.MinUnbondingRate = minUnbondingRate if err := genParams.BtcstakingParams.Validate(); err != nil { panic(err) } genParams.FinalityParams = finalitytypes.DefaultParams() - genParams.FinalityParams.MinPubRand = minPubRand if err := genParams.FinalityParams.Validate(); err != nil { panic(err) } diff --git a/cmd/babylond/cmd/add_gen_bls.go b/cmd/babylond/cmd/genhelpers/bls_add.go similarity index 91% rename from cmd/babylond/cmd/add_gen_bls.go rename to cmd/babylond/cmd/genhelpers/bls_add.go index a55e17736..c8ca06a36 100644 --- a/cmd/babylond/cmd/add_gen_bls.go +++ b/cmd/babylond/cmd/genhelpers/bls_add.go @@ -1,4 +1,4 @@ -package cmd +package genhelpers import ( "encoding/json" @@ -13,12 +13,13 @@ import ( stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" "github.com/spf13/cobra" - "github.com/babylonchain/babylon/x/checkpointing/types" + "github.com/babylonlabs-io/babylon/x/checkpointing/types" ) -func AddGenBlsCmd(validator genutiltypes.MessageValidator) *cobra.Command { +// CmdAddBls CLI adds the BLS key file with proof of possession into the genesis state. +func CmdAddBls(validator genutiltypes.MessageValidator) *cobra.Command { cmd := &cobra.Command{ - Use: "add-genesis-bls [genesis_bls_file]", + Use: "add-bls [genesis_bls_file]", Short: "Add a genesis BLS key to genesis.json", Long: `Add a genesis BLS key per validator and update the pregenesis file in place to include their BLS keys in the checkpointing module's genesis state.' diff --git a/cmd/babylond/cmd/add_gen_bls_test.go b/cmd/babylond/cmd/genhelpers/bls_add_test.go similarity index 87% rename from cmd/babylond/cmd/add_gen_bls_test.go rename to cmd/babylond/cmd/genhelpers/bls_add_test.go index f261c2c09..949b5dd14 100644 --- a/cmd/babylond/cmd/add_gen_bls_test.go +++ b/cmd/babylond/cmd/genhelpers/bls_add_test.go @@ -1,4 +1,4 @@ -package cmd_test +package genhelpers_test import ( "context" @@ -8,6 +8,7 @@ import ( dbm "github.com/cosmos/cosmos-db" "github.com/cosmos/cosmos-sdk/server/config" + "github.com/cosmos/cosmos-sdk/types/module" "github.com/cosmos/cosmos-sdk/x/genutil" @@ -29,12 +30,12 @@ import ( "github.com/spf13/viper" "github.com/stretchr/testify/require" - "github.com/babylonchain/babylon/app" - "github.com/babylonchain/babylon/cmd/babylond/cmd" - "github.com/babylonchain/babylon/privval" - "github.com/babylonchain/babylon/testutil/cli" - "github.com/babylonchain/babylon/testutil/datagen" - "github.com/babylonchain/babylon/x/checkpointing/types" + "github.com/babylonlabs-io/babylon/app" + "github.com/babylonlabs-io/babylon/cmd/babylond/cmd/genhelpers" + "github.com/babylonlabs-io/babylon/privval" + "github.com/babylonlabs-io/babylon/testutil/cli" + "github.com/babylonlabs-io/babylon/testutil/datagen" + "github.com/babylonlabs-io/babylon/x/checkpointing/types" ) func newConfig() depinject.Config { @@ -67,7 +68,7 @@ func newConfig() depinject.Config { // test adding genesis BLS keys without gentx // error is expected -func Test_AddGenBlsCmdWithoutGentx(t *testing.T) { +func Test_CmdCreateAddWithoutGentx(t *testing.T) { home := t.TempDir() logger := log.NewNopLogger() cmtcfg, err := genutiltest.CreateDefaultCometConfig(home) @@ -81,12 +82,12 @@ func Test_AddGenBlsCmdWithoutGentx(t *testing.T) { DB: db, InvCheckPeriod: 0, SkipUpgradeHeights: map[int64]bool{}, - AppOpts: app.EmptyAppOptions{}, + AppOpts: app.TmpAppOptions(), }) gentxModule := bbn.BasicModuleManager[genutiltypes.ModuleName].(genutil.AppModuleBasic) appCodec := bbn.AppCodec() - err = genutiltest.ExecInitCmd(testMbm, home, appCodec) + err = genutiltest.ExecInitCmd(module.NewBasicManager(genutil.AppModuleBasic{}), home, appCodec) require.NoError(t, err) serverCtx := server.NewContext(viper.New(), cmtcfg, logger) @@ -104,7 +105,7 @@ func Test_AddGenBlsCmdWithoutGentx(t *testing.T) { genKeyFileName := filepath.Join(home, fmt.Sprintf("gen-bls-%s.json", genKey.ValidatorAddress)) err = tempfile.WriteFileAtomic(genKeyFileName, jsonBytes, 0600) require.NoError(t, err) - addGenBlsCmd := cmd.AddGenBlsCmd(gentxModule.GenTxValidator) + addGenBlsCmd := genhelpers.CmdAddBls(gentxModule.GenTxValidator) addGenBlsCmd.SetArgs( []string{genKeyFileName}, ) @@ -114,7 +115,7 @@ func Test_AddGenBlsCmdWithoutGentx(t *testing.T) { // test adding genesis BLS keys with gentx // error is expected if adding duplicate -func Test_AddGenBlsCmdWithGentx(t *testing.T) { +func Test_CmdAddBlsWithGentx(t *testing.T) { db := dbm.NewMemDB() signer, err := app.SetupTestPrivSigner() require.NoError(t, err) @@ -123,7 +124,7 @@ func Test_AddGenBlsCmdWithGentx(t *testing.T) { DB: db, InvCheckPeriod: 0, SkipUpgradeHeights: map[int64]bool{}, - AppOpts: app.EmptyAppOptions{}, + AppOpts: app.TmpAppOptions(), }) gentxModule := bbn.BasicModuleManager[genutiltypes.ModuleName].(genutil.AppModuleBasic) @@ -144,7 +145,7 @@ func Test_AddGenBlsCmdWithGentx(t *testing.T) { for i := 0; i < cfg.NumValidators; i++ { v := testNetwork.Validators[i] // build and create genesis BLS key - genBlsCmd := cmd.GenBlsCmd() + genBlsCmd := genhelpers.CmdCreateBls() nodeCfg := cmtconfig.DefaultConfig() homeDir := filepath.Join(v.Dir, "simd") nodeCfg.SetRoot(homeDir) @@ -160,7 +161,7 @@ func Test_AddGenBlsCmdWithGentx(t *testing.T) { require.NotNil(t, genKey) // add genesis BLS key to the target context - addBlsCmd := cmd.AddGenBlsCmd(gentxModule.GenTxValidator) + addBlsCmd := genhelpers.CmdAddBls(gentxModule.GenTxValidator) _, err = cli.ExecTestCLICmd(targetCtx, addBlsCmd, []string{genKeyFileName}) require.NoError(t, err) appState, _, err := genutiltypes.GenesisStateFromGenFile(targetGenesisFile) diff --git a/cmd/babylond/cmd/genbls.go b/cmd/babylond/cmd/genhelpers/bls_create.go similarity index 86% rename from cmd/babylond/cmd/genbls.go rename to cmd/babylond/cmd/genhelpers/bls_create.go index b667178b8..ac1ab7882 100644 --- a/cmd/babylond/cmd/genbls.go +++ b/cmd/babylond/cmd/genhelpers/bls_create.go @@ -1,4 +1,4 @@ -package cmd +package genhelpers import ( "errors" @@ -10,13 +10,14 @@ import ( "github.com/cosmos/cosmos-sdk/client/flags" "github.com/spf13/cobra" - "github.com/babylonchain/babylon/app" - "github.com/babylonchain/babylon/privval" + "github.com/babylonlabs-io/babylon/app" + "github.com/babylonlabs-io/babylon/privval" ) -func GenBlsCmd() *cobra.Command { +// CmdCreateBls CLI command to create BLS file with proof of possession. +func CmdCreateBls() *cobra.Command { cmd := &cobra.Command{ - Use: "create-genesis-bls", + Use: "create-bls", Short: "Create genesis BLS key file for the validator", Long: strings.TrimSpace(`genbls will create a BLS key file that consists of {address, bls_pub_key, pop, pub_key} where pop is the proof-of-possession that proves diff --git a/cmd/babylond/cmd/genbls_test.go b/cmd/babylond/cmd/genhelpers/bls_create_test.go similarity index 89% rename from cmd/babylond/cmd/genbls_test.go rename to cmd/babylond/cmd/genhelpers/bls_create_test.go index b79486fb1..c036794ac 100644 --- a/cmd/babylond/cmd/genbls_test.go +++ b/cmd/babylond/cmd/genhelpers/bls_create_test.go @@ -1,4 +1,4 @@ -package cmd_test +package genhelpers_test import ( "bufio" @@ -22,13 +22,13 @@ import ( "github.com/spf13/viper" "github.com/stretchr/testify/require" - "github.com/babylonchain/babylon/app" - "github.com/babylonchain/babylon/cmd/babylond/cmd" - "github.com/babylonchain/babylon/privval" - "github.com/babylonchain/babylon/x/checkpointing/types" + "github.com/babylonlabs-io/babylon/app" + "github.com/babylonlabs-io/babylon/cmd/babylond/cmd/genhelpers" + "github.com/babylonlabs-io/babylon/privval" + "github.com/babylonlabs-io/babylon/x/checkpointing/types" ) -func Test_GenBlsCmd(t *testing.T) { +func Test_CmdCreateBls(t *testing.T) { home := t.TempDir() logger := log.NewNopLogger() cfg, err := genutiltest.CreateDefaultCometConfig(home) @@ -41,7 +41,7 @@ func Test_GenBlsCmd(t *testing.T) { DB: dbm.NewMemDB(), InvCheckPeriod: 0, SkipUpgradeHeights: map[int64]bool{}, - AppOpts: app.EmptyAppOptions{}, + AppOpts: app.TmpAppOptions(), }) err = genutiltest.ExecInitCmd(bbn.BasicModuleManager, home, bbn.AppCodec()) require.NoError(t, err) @@ -55,7 +55,7 @@ func Test_GenBlsCmd(t *testing.T) { ctx := context.Background() ctx = context.WithValue(ctx, server.ServerContextKey, serverCtx) ctx = context.WithValue(ctx, client.ClientContextKey, &clientCtx) - genBlsCmd := cmd.GenBlsCmd() + genBlsCmd := genhelpers.CmdCreateBls() genBlsCmd.SetArgs([]string{fmt.Sprintf("--%s=%s", flags.FlagHome, home)}) // create keyring to get the validator address diff --git a/cmd/babylond/cmd/genhelpers/cmd.go b/cmd/babylond/cmd/genhelpers/cmd.go new file mode 100644 index 000000000..46be23a92 --- /dev/null +++ b/cmd/babylond/cmd/genhelpers/cmd.go @@ -0,0 +1,29 @@ +package genhelpers + +import ( + "github.com/spf13/cobra" + + "github.com/cosmos/cosmos-sdk/client" + genutiltypes "github.com/cosmos/cosmos-sdk/x/genutil/types" +) + +// CmdGenHelpers helpers for manipulating the genesis file. +func CmdGenHelpers(validator genutiltypes.MessageValidator) *cobra.Command { + cmd := &cobra.Command{ + Use: "gen-helpers", + Short: "Useful commands for creating the genesis state", + DisableFlagParsing: true, + SuggestionsMinimumDistance: 2, + RunE: client.ValidateCmd, + } + + cmd.AddCommand( + CmdCreateBls(), + CmdAddBls(validator), + CmdSetFp(), + CmdSetBtcDels(), + CmdSetBtcHeaders(), + ) + + return cmd +} diff --git a/cmd/babylond/cmd/genhelpers/set_btc_delegations.go b/cmd/babylond/cmd/genhelpers/set_btc_delegations.go new file mode 100644 index 000000000..c4b1f2e28 --- /dev/null +++ b/cmd/babylond/cmd/genhelpers/set_btc_delegations.go @@ -0,0 +1,157 @@ +package genhelpers + +import ( + "fmt" + + btcstktypes "github.com/babylonlabs-io/babylon/x/btcstaking/types" + "github.com/cosmos/cosmos-sdk/client" + "github.com/cosmos/cosmos-sdk/server" + "github.com/cosmos/cosmos-sdk/x/genutil" + genutiltypes "github.com/cosmos/cosmos-sdk/x/genutil/types" + + "github.com/spf13/cobra" +) + +// CmdSetBtcDels CLI sets bitcoin delegations into the genesis state. +func CmdSetBtcDels() *cobra.Command { + cmd := &cobra.Command{ + Use: "set-btc-delegations [path/to/btc_delegations.json]", + Short: "Set the BTC delegations from the given json file into the genesis.json", + Long: `Reads BTC delegation structures from the given json file and update the genesis.json file +in place to include the delegations in the btcstaking module's genesis state. +Duplicated BTC delegations are not allowed and it will prompt an error. +`, + Example: `babylond gen-helpers set-btc-delegations path/to/btc_delegations.json +Possible content of 'btc_delegations.json' is +{ + "btc_delegations": [ + { + "babylon_pk": { + "key": "AkCmkLYWjr0/49MCK3lzTqKC1MiPSldXgoqP0EdtV8m1" + }, + "btc_pk": "5ea8d7dfe920f5aecb1f4411b1b3e6684031ecb7a282df65107a615adc562a48", + "pop": { + "btc_sig_type": "BIP340", + "babylon_sig": "gjqXTQdgzC6AX/lnj3T3QV5vV+jtKDKwJOP9jMpZdb90MoIKRGV7j/A6lwbgsnUzbsvd4L19U7/3cOZqYBfQAg==", + "btc_sig": "Gx0VxuXgjiLvdCIIx1eN9JE9mqo+qvIo48cUhTCbM6uTxt59HTJiVGloHE518OXk+vQrNcHB+bZFqX+T5wMS9w==" + }, + "fp_btc_pk_list": [ + "3d6a1db7bffaebed71831fae74d32bf78e97884c41634cc1a80b0ebbffe1c7dd" + ], + "start_height": "127", + "end_height": "10127", + "total_sat": "1000000", + "staking_tx": "AQAAAAF/cxe2A5/IsfYkwiVTA795y/X16NDBpqETC3kiv27AKgAAAABrSDBFAiEA8inc8+grbO6iJbl1VwJjR4Y89dK7ATcEz3XnJPNd37MCIGd0wpfu3Hz4+hjVXatnKCTViUG2SPiD83k/+yhy9bIIASEDXqjX3+kg9a7LH0QRsbPmaEAx7Leigt9lEHphWtxWKkj/////AkBCDwAAAAAAIlEg8eeUnPklLO9pkkhYMkoQFW7gxAmd4W781NwChbc9WSe0mPYpAQAAABl2qRS9MnviWBrF4wvpgMpBhIFGQHnOWYisAAAAAA==", + "staking_output_idx": 0, + "slashing_tx": "AQAAAAES8FBlJfWXZSLzImp6AjfD1bosph2q02QhTIjDo9T8bQAAAAAA/////wKghgEAAAAAABl2qRQBAQEBAQEBAQEBAQEBAQEBAQEBAYisuLcNAAAAAAAiUSD1hd0Q7BOqlMAZY6fqBidPwKe7jLRXtdGcpgQjVIhr8wAAAAA=", + "delegator_sig": "2i6kTpmzn0pJAbY+v5Ktf0yo6YNhucVZC4clg4YVVZKU7dVh9DKEzrichq5C1eFgaRr+YYtEyxtTlVwhyOg2Ag==", + "covenant_sigs": [ + { + "cov_pk": "e76137fda8dff755a0879264c4eb3c3574ab77b6c5589f47b090203e4938d065", + "adaptor_sigs": [ + "Ann3xe0L1gIHWS2+hhHwRDTPz5RoCFzBBte0xkhJ0VRUWDB2a46Pl1miZ9y+jyseZNYcps+DeE1cB/S54oeVQYEA" + ] + } + ], + "unbonding_time": 101, + "btc_undelegation": { + "unbonding_tx": "AgAAAAES8FBlJfWXZSLzImp6AjfD1bosph2q02QhTIjDo9T8bQAAAAAA/////wGsMA8AAAAAACJRIEObJoQoxADSVZ3K8dV0Req4coALcrefxibIBmWItvVDAAAAAA==", + "slashing_tx": "AQAAAAGGZtqTIrJN8TDOMw+bbENzXLECv1Z1E4idjZ2UiHnsbAAAAAAA/////wLehAEAAAAAABl2qRQBAQEBAQEBAQEBAQEBAQEBAQEBAYis5qcNAAAAAAAiUSD1hd0Q7BOqlMAZY6fqBidPwKe7jLRXtdGcpgQjVIhr8wAAAAA=", + "delegator_unbonding_sig": null, + "delegator_slashing_sig": "P6GSaJdbIhEED+k74T1sRYzTYHUhzg8/NDGvwR+sBHXhKsT8O82XRaHyvjFXAVCLK0sa5oxSOTndMmY3SKHNsw==", + "covenant_slashing_sigs": [ + { + "cov_pk": "e76137fda8dff755a0879264c4eb3c3574ab77b6c5589f47b090203e4938d065", + "adaptor_sigs": [ + "AjZrivh6++7Wu7OWFRxLAv2SHPvf0VhZM7pZK7oWP3KoWKdPpBcNotFqjdCQE2TTSshS4qpEuwYMLtMMzYqIOKYA" + ] + } + ], + "covenant_unbonding_sig_list": [ + { + "pk": "e76137fda8dff755a0879264c4eb3c3574ab77b6c5589f47b090203e4938d065", + "sig": "t+zUA4qtNCKREviFUtwWh46QNEov033whhF2i89oF2mEoa55k7Hq68TAY+jiGeeTJU1BM7Q4Qfu8XFuv3c1WAw==" + } + ] + }, + "params_version": 0 + } + ], +} +`, + Args: cobra.ExactArgs(1), + RunE: func(cmd *cobra.Command, args []string) error { + clientCtx := client.GetClientContextFromCmd(cmd) + config := server.GetServerContextFromCmd(cmd).Config + config.SetRoot(clientCtx.HomeDir) + + inputBtcDels, err := getBtcStakingGenStateFromFile(clientCtx.Codec, args[0]) + if err != nil { + return err + } + + genFile := config.GenesisFile() + appState, genDoc, err := genutiltypes.GenesisStateFromGenFile(genFile) + if err != nil { + return fmt.Errorf("failed to unmarshal genesis state: %w", err) + } + btcstkGenState := btcstktypes.GenesisStateFromAppState(clientCtx.Codec, appState) + + genStateBtcDelsByTxHash := make(map[string]struct{}, 0) + for _, del := range btcstkGenState.BtcDelegations { + hash, err := del.GetStakingTxHash() + if err != nil { + return err + } + + key := hash.String() + if _, ok := genStateBtcDelsByTxHash[key]; ok { + return fmt.Errorf("bad genesis state, there is more than one btc delegator with the same staking tx hash %s", key) + } + genStateBtcDelsByTxHash[key] = struct{}{} + } + + genStateFpsByBtcPk, err := mapFinalityProvidersByBtcPk(btcstkGenState.FinalityProviders) + if err != nil { + return fmt.Errorf("bad gen state: %w", err) + } + + newDels := make([]*btcstktypes.BTCDelegation, 0, len(inputBtcDels.BtcDelegations)) + for _, del := range inputBtcDels.BtcDelegations { + if err := del.ValidateBasic(); err != nil { + return fmt.Errorf("failed to validate basic btc delegation: %w", err) + } + + hash, err := del.GetStakingTxHash() + if err != nil { + return err + } + + key := hash.String() + if _, ok := genStateBtcDelsByTxHash[key]; ok { + return fmt.Errorf("error: btc delegation: %+v\nwas already set on genesis, or contains the same staking tx hash %s than another btc delegation", del, key) + } + + for _, fpBTCpk := range del.FpBtcPkList { + fpKey := fpBTCpk.MarshalHex() + if _, ok := genStateFpsByBtcPk[fpKey]; !ok { + return fmt.Errorf("error: btc delegation: %+v\nhas an associated finality provider that is not set on genesis %s", del, fpKey) + } + } + + genStateBtcDelsByTxHash[key] = struct{}{} + newDels = append(newDels, del) + } + btcstkGenState.BtcDelegations = append(btcstkGenState.BtcDelegations, newDels...) + + err = replaceModOnGenesis(clientCtx.Codec, genDoc, appState, btcstktypes.ModuleName, &btcstkGenState) + if err != nil { + return err + } + + return genutil.ExportGenesisFile(genDoc, genFile) + }, + } + + return cmd +} diff --git a/cmd/babylond/cmd/genhelpers/set_btc_delegations_test.go b/cmd/babylond/cmd/genhelpers/set_btc_delegations_test.go new file mode 100644 index 000000000..ccaa5a4bd --- /dev/null +++ b/cmd/babylond/cmd/genhelpers/set_btc_delegations_test.go @@ -0,0 +1,168 @@ +package genhelpers_test + +import ( + "context" + "encoding/hex" + "fmt" + "math/rand" + "path/filepath" + "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/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" +) + +func FuzzCmdSetBtcDels(f *testing.F) { + datagen.AddRandomSeedsToFuzzer(f, 10) + + f.Fuzz(func(t *testing.T, seed int64) { + r, h := rand.New(rand.NewSource(seed)), helper.NewHelper(t) + app := h.App + cdc := app.AppCodec() + home := t.TempDir() + + clientCtx := client.Context{}. + WithCodec(app.AppCodec()). + WithHomeDir(home). + WithTxConfig(app.TxConfig()) + ctx := context.WithValue(context.Background(), client.ClientContextKey, &clientCtx) + + err := genutiltest.ExecInitCmd(app.BasicModuleManager, home, cdc) + require.NoError(t, err) + + qntBtcDels := int(datagen.RandomInt(r, 10)) + 1 + btcDelsToAdd := make([]*btcstktypes.BTCDelegation, qntBtcDels) + + fp, err := datagen.GenRandomFinalityProvider(r) + require.NoError(t, err) + + // write fp to genesis + fpsToAddFilePath := filepath.Join(home, "fpsToAdd.json") + writeFileProto(t, cdc, fpsToAddFilePath, &btcstktypes.GenesisState{ + FinalityProviders: []*btcstktypes.FinalityProvider{fp}, + }) + + cmdSetFp := genhelpers.CmdSetFp() + cmdSetFp.SetArgs([]string{fpsToAddFilePath}) + cmdSetFp.SetContext(ctx) + + // Runs the cmd to write into the genesis + err = cmdSetFp.Execute() + require.NoError(t, err) + + covenantSKs, covenantPKs, covenantQuorum := datagen.GenCovenantCommittee(r) + slashingAddress, err := datagen.GenRandomBTCAddress(r, &chaincfg.RegressionNetParams) + require.NoError(t, err) + + startHeight := datagen.RandomInt(r, 100) + 1 + endHeight := datagen.RandomInt(r, 1000) + startHeight + btcctypes.DefaultParams().CheckpointFinalizationTimeout + 1 + slashingRate := sdkmath.LegacyNewDecWithPrec(int64(datagen.RandomInt(r, 41)+10), 2) + slashingChangeLockTime := uint16(101) + + for i := 0; i < qntBtcDels; i++ { + delSK, _, err := datagen.GenRandomBTCKeyPair(r) + require.NoError(t, err) + + del, err := datagen.GenRandomBTCDelegation( + r, + t, + &chaincfg.RegressionNetParams, + []bbn.BIP340PubKey{*fp.BtcPk}, + delSK, + covenantSKs, + covenantPKs, + covenantQuorum, + slashingAddress.EncodeAddress(), + startHeight, endHeight, 10000, + slashingRate, + slashingChangeLockTime, + ) + require.NoError(t, err) + btcDelsToAdd[i] = del + } + + btcDelsToAddFilePath := filepath.Join(home, "delsToAdd.json") + writeFileProto(t, cdc, btcDelsToAddFilePath, &btcstktypes.GenesisState{ + BtcDelegations: btcDelsToAdd, + }) + + cmdSetBtcDel := genhelpers.CmdSetBtcDels() + cmdSetBtcDel.SetArgs([]string{btcDelsToAddFilePath}) + cmdSetBtcDel.SetContext(ctx) + + // Runs the cmd to write into the genesis + err = cmdSetBtcDel.Execute() + require.NoError(t, err) + + cmtcfg, err := genutiltest.CreateDefaultCometConfig(home) + require.NoError(t, err) + + // Verifies that the new genesis were created + appState, _, err := genutiltypes.GenesisStateFromGenFile(cmtcfg.GenesisFile()) + require.NoError(t, err) + + btcstkGenState := btcstktypes.GenesisStateFromAppState(cdc, appState) + // make sure the same quantity of BTC delegations were created. + require.Equal(t, qntBtcDels, len(btcstkGenState.BtcDelegations)) + + for i := 0; i < qntBtcDels; i++ { + bzAdd, err := btcDelsToAdd[i].Marshal() + require.NoError(t, err) + + bzGen, err := btcstkGenState.BtcDelegations[i].Marshal() + require.NoError(t, err) + + require.Equal(t, hex.EncodeToString(bzAdd), hex.EncodeToString(bzGen)) + } + + // tries to add again, it should error out + btcDel := btcDelsToAdd[0] + + hash, err := btcDel.GetStakingTxHash() + require.NoError(t, err) + key := hash.String() + + err = cmdSetBtcDel.Execute() + require.EqualError(t, err, fmt.Errorf("error: btc delegation: %+v\nwas already set on genesis, or contains the same staking tx hash %s than another btc delegation", btcDel, key).Error()) + + // checks trying to insert a new btc delegation with an finality provider that is not present in genesis. It should error out + notInGenFp, err := datagen.GenRandomFinalityProvider(r) + require.NoError(t, err) + + delSK, _, err := datagen.GenRandomBTCKeyPair(r) + require.NoError(t, err) + + delWithBadFp, err := datagen.GenRandomBTCDelegation( + r, + t, + &chaincfg.RegressionNetParams, + []bbn.BIP340PubKey{*notInGenFp.BtcPk}, + delSK, + covenantSKs, + covenantPKs, + covenantQuorum, + slashingAddress.EncodeAddress(), + startHeight, endHeight, 10000, + slashingRate, + slashingChangeLockTime, + ) + require.NoError(t, err) + + writeFileProto(t, cdc, btcDelsToAddFilePath, &btcstktypes.GenesisState{ + BtcDelegations: []*btcstktypes.BTCDelegation{delWithBadFp}, + }) + + err = cmdSetBtcDel.Execute() + require.EqualError(t, err, fmt.Errorf("error: btc delegation: %+v\nhas an associated finality provider that is not set on genesis %s", delWithBadFp, notInGenFp.BtcPk.MarshalHex()).Error()) + }) +} diff --git a/cmd/babylond/cmd/genhelpers/set_btc_headers.go b/cmd/babylond/cmd/genhelpers/set_btc_headers.go new file mode 100644 index 000000000..db30b2f04 --- /dev/null +++ b/cmd/babylond/cmd/genhelpers/set_btc_headers.go @@ -0,0 +1,124 @@ +package genhelpers + +import ( + "fmt" + "os" + "path/filepath" + + cmtos "github.com/cometbft/cometbft/libs/os" + "github.com/cosmos/cosmos-sdk/client" + "github.com/cosmos/cosmos-sdk/codec" + "github.com/cosmos/cosmos-sdk/server" + "github.com/cosmos/cosmos-sdk/x/genutil" + genutiltypes "github.com/cosmos/cosmos-sdk/x/genutil/types" + + btclighttypes "github.com/babylonlabs-io/babylon/x/btclightclient/types" + + "github.com/spf13/cobra" +) + +// CmdSetBtcHeaders CLI sets bitcoin headers into the genesis state. +func CmdSetBtcHeaders() *cobra.Command { + cmd := &cobra.Command{ + Use: "set-btc-headers [path/to/btc_headers.json]", + Short: "Set the BTC headers from the given json file into the genesis.json", + Long: `Reads BTC Headers structures from the given json file and update the genesis.json file +in place to include the btc headers in the btcstaking module's genesis state. +Duplicated BTC headers are not allowed and it will prompt an error. +`, + Example: `babylond gen-helpers set-btc-headers path/to/btc_headers.json +Possible content of 'btc_headers.json' is +{ + "btc_headers": [ + { + "header": "0100000000000000000000000000000000000000000000000000000000000000000000003ba3edfd7a7b12b27ac72c3e67768f617fc81bc3888a51323a9fb8aa4b1e5e4a45068653ffff7f2002000000", + "hash": "683e86bd5c6d110d91b94b97137ba6bfe02dbbdb8e3dff722a669b5d69d77af6", + "height": "0", + "work": "2" + }, + { + "header": "00000020f67ad7695d9b662a72ff3d8edbbb2de0bfa67b13974bb9910d116d5cbd863e682259b3c6351788d4456e8fbb738dd51fd6aea615f63b10f634021f930c9c34be02150466ffff7f2000000000", + "hash": "6fceca20e50018d9f54632b791144eef4b3f9cb2ced9fa2702c376857a550e03", + "height": "1", + "work": "4" + } + ] +} +`, + Args: cobra.ExactArgs(1), + RunE: func(cmd *cobra.Command, args []string) error { + clientCtx := client.GetClientContextFromCmd(cmd) + config := server.GetServerContextFromCmd(cmd).Config + config.SetRoot(clientCtx.HomeDir) + + inputBtcHeaders, err := getBtcLightGenStateFromFile(clientCtx.Codec, args[0]) + if err != nil { + return err + } + + genFile := config.GenesisFile() + appState, genDoc, err := genutiltypes.GenesisStateFromGenFile(genFile) + if err != nil { + return fmt.Errorf("failed to unmarshal genesis state: %w", err) + } + btclightGenState := btclighttypes.GenesisStateFromAppState(clientCtx.Codec, appState) + + genStateBtcHeaderByHash := make(map[string]struct{}, 0) + for _, btcHeader := range btclightGenState.BtcHeaders { + key := btcHeader.Hash.MarshalHex() + if _, ok := genStateBtcHeaderByHash[key]; ok { + return fmt.Errorf("bad genesis state, there is more than one btc header with the same hash %s", key) + } + genStateBtcHeaderByHash[key] = struct{}{} + } + + newBtcHeaders := make([]*btclighttypes.BTCHeaderInfo, 0, len(inputBtcHeaders.BtcHeaders)) + for _, btcHeader := range inputBtcHeaders.BtcHeaders { + if err := btcHeader.Validate(); err != nil { + return fmt.Errorf("failed to validate basic btc header: %w", err) + } + + key := btcHeader.Hash.MarshalHex() + if _, ok := genStateBtcHeaderByHash[key]; ok { + return fmt.Errorf("error: btc header: %+v\nwas already set on genesis, or contains the same hash %s than another btc header", btcHeader, key) + } + genStateBtcHeaderByHash[key] = struct{}{} + newBtcHeaders = append(newBtcHeaders, btcHeader) + } + btclightGenState.BtcHeaders = append(btclightGenState.BtcHeaders, newBtcHeaders...) + + if err := btclightGenState.Validate(); err != nil { + return err + } + + err = replaceModOnGenesis(clientCtx.Codec, genDoc, appState, btclighttypes.ModuleName, &btclightGenState) + if err != nil { + return err + } + + return genutil.ExportGenesisFile(genDoc, genFile) + }, + } + + return cmd +} + +func getBtcLightGenStateFromFile(cdc codec.Codec, inputFilePath string) (*btclighttypes.GenesisState, error) { + filePath := filepath.Clean(inputFilePath) + if !cmtos.FileExists(filePath) { + return nil, fmt.Errorf("input file %s does not exists", filePath) + } + + bz, err := os.ReadFile(filePath) + if err != nil { + return nil, err + } + + var genState btclighttypes.GenesisState + err = cdc.UnmarshalJSON(bz, &genState) + if err != nil { + return nil, err + } + + return &genState, nil +} diff --git a/cmd/babylond/cmd/genhelpers/set_btc_headers_test.go b/cmd/babylond/cmd/genhelpers/set_btc_headers_test.go new file mode 100644 index 000000000..023c87553 --- /dev/null +++ b/cmd/babylond/cmd/genhelpers/set_btc_headers_test.go @@ -0,0 +1,93 @@ +package genhelpers_test + +import ( + "context" + "encoding/hex" + "fmt" + "math/rand" + "path/filepath" + "testing" + + "github.com/babylonlabs-io/babylon/cmd/babylond/cmd/genhelpers" + "github.com/babylonlabs-io/babylon/testutil/datagen" + "github.com/babylonlabs-io/babylon/testutil/helper" + btclighttypes "github.com/babylonlabs-io/babylon/x/btclightclient/types" + + "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" +) + +func FuzzCmdSetBtcHeaders(f *testing.F) { + datagen.AddRandomSeedsToFuzzer(f, 10) + + f.Fuzz(func(t *testing.T, seed int64) { + r := rand.New(rand.NewSource(seed)) + h := helper.NewHelper(t) + app, home := h.App, t.TempDir() + cdc := app.AppCodec() + + err := genutiltest.ExecInitCmd(app.BasicModuleManager, home, cdc) + require.NoError(t, err) + + cmtcfg, err := genutiltest.CreateDefaultCometConfig(home) + require.NoError(t, err) + + appState, _, err := genutiltypes.GenesisStateFromGenFile(cmtcfg.GenesisFile()) + require.NoError(t, err) + btclightGenState := btclighttypes.GenesisStateFromAppState(cdc, appState) + + qntBtcHeaderInGenesis := len(btclightGenState.BtcHeaders) + require.GreaterOrEqual(t, qntBtcHeaderInGenesis, 1) + last := btclightGenState.BtcHeaders[qntBtcHeaderInGenesis-1] + + qntBtcHeaders := int(datagen.RandomInt(r, 10)) + 1 + btcHeadersToAdd := make([]*btclighttypes.BTCHeaderInfo, qntBtcHeaders) + for i := 0; i < qntBtcHeaders; i++ { + new := datagen.GenRandomBTCHeaderInfoWithParent(r, last) + btcHeadersToAdd[i] = new + last = new + } + + clientCtx := client.Context{}. + WithCodec(app.AppCodec()). + WithHomeDir(home). + WithTxConfig(app.TxConfig()) + ctx := context.WithValue(context.Background(), client.ClientContextKey, &clientCtx) + + btcHeadersToAddFilePath := filepath.Join(home, "btcHeadersToAdd.json") + writeFileProto(t, cdc, btcHeadersToAddFilePath, &btclighttypes.GenesisState{ + BtcHeaders: btcHeadersToAdd, + }) + + cmdSetBtcHeaders := genhelpers.CmdSetBtcHeaders() + cmdSetBtcHeaders.SetArgs([]string{btcHeadersToAddFilePath}) + cmdSetBtcHeaders.SetContext(ctx) + + // Runs the cmd to write into the genesis + err = cmdSetBtcHeaders.Execute() + require.NoError(t, err) + + // reloads appstate + appState, _, err = genutiltypes.GenesisStateFromGenFile(cmtcfg.GenesisFile()) + require.NoError(t, err) + btclightGenState = btclighttypes.GenesisStateFromAppState(cdc, appState) + require.Equal(t, qntBtcHeaders+qntBtcHeaderInGenesis, len(btclightGenState.BtcHeaders)) + + for i := 0; i < qntBtcHeaders; i++ { + bzAdd, err := btcHeadersToAdd[i].Marshal() + require.NoError(t, err) + + bzGen, err := btclightGenState.BtcHeaders[qntBtcHeaderInGenesis+i].Marshal() + require.NoError(t, err) + + require.Equal(t, hex.EncodeToString(bzAdd), hex.EncodeToString(bzGen)) + } + + // tries to add again, it should error out + err = cmdSetBtcHeaders.Execute() + btcHeader := btcHeadersToAdd[0] + require.EqualError(t, err, fmt.Errorf("error: btc header: %+v\nwas already set on genesis, or contains the same hash %s than another btc header", btcHeader, btcHeader.Hash.MarshalHex()).Error()) + }) +} diff --git a/cmd/babylond/cmd/genhelpers/set_finality_providers.go b/cmd/babylond/cmd/genhelpers/set_finality_providers.go new file mode 100644 index 000000000..b5a8cf40f --- /dev/null +++ b/cmd/babylond/cmd/genhelpers/set_finality_providers.go @@ -0,0 +1,160 @@ +package genhelpers + +import ( + "encoding/json" + "fmt" + "os" + "path/filepath" + + btcstktypes "github.com/babylonlabs-io/babylon/x/btcstaking/types" + cmtos "github.com/cometbft/cometbft/libs/os" + "github.com/cosmos/cosmos-sdk/client" + "github.com/cosmos/cosmos-sdk/codec" + "github.com/cosmos/cosmos-sdk/server" + "github.com/cosmos/cosmos-sdk/x/genutil" + genutiltypes "github.com/cosmos/cosmos-sdk/x/genutil/types" + "github.com/cosmos/gogoproto/proto" + "github.com/spf13/cobra" +) + +// CmdSetFp CLI sets finality providers into the genesis state. +func CmdSetFp() *cobra.Command { + cmd := &cobra.Command{ + Use: "set-finality-providers [path/to/finality_providers.json]", + Short: "Set the finality providers from the given json file into the genesis.json", + Long: `Reads finality providers structures from the given json file and update the genesis.json file +in place to include the finality providers in the btcstaking module's genesis state. +Duplicated finality providers are not allowed and it will prompt an error. +`, + Example: `babylond gen-helpers set-finality-providers path/to/finality_providers.json +Possible content of 'finality_providers.json' is +{ + "finality_providers": [ + { + "description": { + "moniker": "val-fp", + "identity": "", + "website": "", + "security_contact": "", + "details": "" + }, + "commission": "0.050000000000000000", + "babylon_pk": { + "key": "A6FTeYaKkvi8cOXSmVF+2n+q58WV/qffI99YucsvrGsk" + }, + "btc_pk": "625057f9828753569c478b1aa826205395222bcdbefafe9653dfdc638d18eadc", + "pop": { + "btc_sig_type": "BIP340", + "babylon_sig": "/RJyVqBEm/PDkQQTDgdPj84MywTu6LUVXDWUlPBgDGo1qsU/Rg+kJhBRwxCEKs8PYmoADcp4FiH2vVyAqRG2UA==", + "btc_sig": "OaLj+w2loH0O88cT2IEdUoV4Swx+RWagk632+mKs5wVRBM63D6uwW+lCLIjxVBfOYQRFzT2D9943k10Whw5a7Q==" + }, + "slashed_babylon_height": "0", + "slashed_btc_height": "0" + } + ] +} +`, + Args: cobra.ExactArgs(1), + RunE: func(cmd *cobra.Command, args []string) error { + clientCtx := client.GetClientContextFromCmd(cmd) + config := server.GetServerContextFromCmd(cmd).Config + config.SetRoot(clientCtx.HomeDir) + + inputFps, err := getBtcStakingGenStateFromFile(clientCtx.Codec, args[0]) + if err != nil { + return err + } + + genFile := config.GenesisFile() + appState, genDoc, err := genutiltypes.GenesisStateFromGenFile(genFile) + if err != nil { + return fmt.Errorf("failed to unmarshal genesis state: %w", err) + } + btcstkGenState := btcstktypes.GenesisStateFromAppState(clientCtx.Codec, appState) + + genStateFpsByBtcPk, err := mapFinalityProvidersByBtcPk(btcstkGenState.FinalityProviders) + if err != nil { + return fmt.Errorf("bad gen state: %w", err) + } + + newFps := make([]*btcstktypes.FinalityProvider, 0, len(inputFps.FinalityProviders)) + for _, fp := range inputFps.FinalityProviders { + if err := fp.ValidateBasic(); err != nil { + return fmt.Errorf("failed to validate basic finality provider: %w", err) + } + + key := fp.BtcPk.MarshalHex() + if _, ok := genStateFpsByBtcPk[key]; ok { + return fmt.Errorf("error: finality provider: %+v\nwas already set on genesis, or contains the same BtcPk %s than another finality provider", fp, key) + } + + // sets the fp to the genstate to avoid having 2 fps with same btc pk in the input + genStateFpsByBtcPk[key] = struct{}{} + newFps = append(newFps, fp) + } + btcstkGenState.FinalityProviders = append(btcstkGenState.FinalityProviders, newFps...) + + err = replaceModOnGenesis(clientCtx.Codec, genDoc, appState, btcstktypes.ModuleName, &btcstkGenState) + if err != nil { + return err + } + + return genutil.ExportGenesisFile(genDoc, genFile) + }, + } + + return cmd +} + +func replaceModOnGenesis( + cdc codec.Codec, + genDoc *genutiltypes.AppGenesis, + appState map[string]json.RawMessage, + modname string, + modGenState proto.Message, +) error { + newModGenState, err := cdc.MarshalJSON(modGenState) + if err != nil { + return fmt.Errorf("failed to marshal %s genesis state: %w", modname, err) + } + appState[modname] = newModGenState + + appStateJSON, err := json.Marshal(appState) + if err != nil { + return fmt.Errorf("failed to marshal application genesis state: %w", err) + } + genDoc.AppState = appStateJSON + return nil +} + +func getBtcStakingGenStateFromFile(cdc codec.Codec, inputFilePath string) (*btcstktypes.GenesisState, error) { + filePath := filepath.Clean(inputFilePath) + if !cmtos.FileExists(filePath) { + return nil, fmt.Errorf("input file %s does not exists", filePath) + } + + bz, err := os.ReadFile(filePath) + if err != nil { + return nil, err + } + + var genState btcstktypes.GenesisState + err = cdc.UnmarshalJSON(bz, &genState) + if err != nil { + return nil, err + } + + return &genState, nil +} + +func mapFinalityProvidersByBtcPk(fps []*btcstktypes.FinalityProvider) (map[string]struct{}, error) { + genStateFpsByBtcPk := make(map[string]struct{}, 0) + for _, fpGen := range fps { + key := fpGen.BtcPk.MarshalHex() + if _, ok := genStateFpsByBtcPk[key]; ok { + return nil, fmt.Errorf("there is more than one finality provider with the same btc key %s", key) + } + genStateFpsByBtcPk[key] = struct{}{} + } + return genStateFpsByBtcPk, nil +} diff --git a/cmd/babylond/cmd/genhelpers/set_finality_providers_test.go b/cmd/babylond/cmd/genhelpers/set_finality_providers_test.go new file mode 100644 index 000000000..bd3776a78 --- /dev/null +++ b/cmd/babylond/cmd/genhelpers/set_finality_providers_test.go @@ -0,0 +1,100 @@ +package genhelpers_test + +import ( + "context" + "encoding/hex" + "fmt" + "math/rand" + "path/filepath" + "testing" + + "github.com/babylonlabs-io/babylon/cmd/babylond/cmd/genhelpers" + "github.com/babylonlabs-io/babylon/testutil/datagen" + "github.com/babylonlabs-io/babylon/testutil/helper" + btcstktypes "github.com/babylonlabs-io/babylon/x/btcstaking/types" + "github.com/cometbft/cometbft/libs/tempfile" + "github.com/cosmos/cosmos-sdk/client" + "github.com/cosmos/cosmos-sdk/codec" + genutiltest "github.com/cosmos/cosmos-sdk/x/genutil/client/testutil" + genutiltypes "github.com/cosmos/cosmos-sdk/x/genutil/types" + "github.com/cosmos/gogoproto/proto" + "github.com/stretchr/testify/require" +) + +func FuzzCmdSetFp(f *testing.F) { + datagen.AddRandomSeedsToFuzzer(f, 10) + + f.Fuzz(func(t *testing.T, seed int64) { + r := rand.New(rand.NewSource(seed)) + + qntFps := int(datagen.RandomInt(r, 10)) + 1 + fpsToAdd := make([]*btcstktypes.FinalityProvider, qntFps) + for i := 0; i < qntFps; i++ { + fp, err := datagen.GenRandomFinalityProvider(r) + require.NoError(t, err) + fpsToAdd[i] = fp + } + + home := t.TempDir() + h := helper.NewHelper(t) + + app := h.App + cdc := app.AppCodec() + + err := genutiltest.ExecInitCmd(app.BasicModuleManager, home, cdc) + require.NoError(t, err) + + clientCtx := client.Context{}. + WithCodec(app.AppCodec()). + WithHomeDir(home). + WithTxConfig(app.TxConfig()) + ctx := context.WithValue(context.Background(), client.ClientContextKey, &clientCtx) + + fpsToAddFilePath := filepath.Join(home, "fpsToAdd.json") + writeFileProto(t, cdc, fpsToAddFilePath, &btcstktypes.GenesisState{ + FinalityProviders: fpsToAdd, + }) + + cmdSetFp := genhelpers.CmdSetFp() + cmdSetFp.SetArgs([]string{fpsToAddFilePath}) + cmdSetFp.SetContext(ctx) + + // Runs the cmd to write into the genesis + err = cmdSetFp.Execute() + require.NoError(t, err) + + cmtcfg, err := genutiltest.CreateDefaultCometConfig(home) + require.NoError(t, err) + + // Verifies that the new genesis were created + appState, _, err := genutiltypes.GenesisStateFromGenFile(cmtcfg.GenesisFile()) + require.NoError(t, err) + + btcstkGenState := btcstktypes.GenesisStateFromAppState(cdc, appState) + // make sure the same quantity of finality providers were created. + require.Equal(t, qntFps, len(btcstkGenState.FinalityProviders)) + + for i := 0; i < qntFps; i++ { + bzAdd, err := fpsToAdd[i].Marshal() + require.NoError(t, err) + + bzGen, err := btcstkGenState.FinalityProviders[i].Marshal() + require.NoError(t, err) + + require.Equal(t, hex.EncodeToString(bzAdd), hex.EncodeToString(bzGen)) + } + + // tries to add again, it should error out + err = cmdSetFp.Execute() + fp := fpsToAdd[0] + require.EqualError(t, err, fmt.Errorf("error: finality provider: %+v\nwas already set on genesis, or contains the same BtcPk %s than another finality provider", fp, fp.BtcPk.MarshalHex()).Error()) + }) +} + +func writeFileProto(t *testing.T, cdc codec.Codec, fpath string, structToWriteInFile proto.Message) { + jsonBytes, err := cdc.MarshalJSON(structToWriteInFile) + require.NoError(t, err) + + err = tempfile.WriteFileAtomic(fpath, jsonBytes, 0600) + require.NoError(t, err) +} diff --git a/cmd/babylond/cmd/root.go b/cmd/babylond/cmd/root.go index 94025ee60..efc9304c1 100644 --- a/cmd/babylond/cmd/root.go +++ b/cmd/babylond/cmd/root.go @@ -8,6 +8,7 @@ import ( confixcmd "cosmossdk.io/tools/confix/cmd" "github.com/CosmWasm/wasmd/x/wasm" wasmkeeper "github.com/CosmWasm/wasmd/x/wasm/keeper" + appkeepers "github.com/babylonlabs-io/babylon/app/keepers" cmtcfg "github.com/cometbft/cometbft/config" cmtcli "github.com/cometbft/cometbft/libs/cli" dbm "github.com/cosmos/cosmos-db" @@ -39,8 +40,9 @@ import ( "github.com/spf13/cast" "github.com/spf13/cobra" - "github.com/babylonchain/babylon/app" - "github.com/babylonchain/babylon/app/params" + "github.com/babylonlabs-io/babylon/app" + "github.com/babylonlabs-io/babylon/app/params" + "github.com/babylonlabs-io/babylon/cmd/babylond/cmd/genhelpers" ) // NewRootCmd creates a new root command for babylond. It is called once in the @@ -186,9 +188,9 @@ func initRootCmd(rootCmd *cobra.Command, txConfig client.TxEncodingConfig, basic AddGenesisAccountCmd(app.DefaultNodeHome), cmtcli.NewCompletionCmd(rootCmd, true), TestnetCmd(basicManager, banktypes.GenesisBalancesIterator{}), + genhelpers.CmdGenHelpers(gentxModule.GenTxValidator), CreateBlsKeyCmd(), - GenBlsCmd(), - AddGenBlsCmd(gentxModule.GenTxValidator), + ModuleSizeCmd(), debug.Cmd(), confixcmd.ConfigCommand(), ) @@ -273,7 +275,7 @@ func newApp(logger log.Logger, db dbm.DB, traceStore io.Writer, appOpts serverty } homeDir := cast.ToString(appOpts.Get(flags.FlagHome)) - privSigner, err := app.InitPrivSigner(homeDir) + privSigner, err := appkeepers.InitPrivSigner(homeDir) if err != nil { panic(err) } @@ -312,7 +314,7 @@ func appExport( return servertypes.ExportedApp{}, errors.New("application home not set") } - privSigner, err := app.InitPrivSigner(homePath) + privSigner, err := appkeepers.InitPrivSigner(homePath) if err != nil { panic(err) } diff --git a/cmd/babylond/cmd/sizes_cmd.go b/cmd/babylond/cmd/sizes_cmd.go new file mode 100644 index 000000000..800c77730 --- /dev/null +++ b/cmd/babylond/cmd/sizes_cmd.go @@ -0,0 +1,178 @@ +package cmd + +import ( + "cmp" + "fmt" + "path/filepath" + "regexp" + "slices" + "strings" + + dbm "github.com/cosmos/cosmos-db" + "github.com/spf13/cobra" + "golang.org/x/exp/maps" +) + +const ( + FlagPrintInterval = "print-interval" +) + +// r is a regular expression that matched the store key prefix +// we cannot use modules names direclty 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]+/") + +func OpenDB(dir string) (dbm.DB, error) { + fmt.Printf("Opening database at: %s\n", dir) + defer fmt.Printf("Opened database at: %s\n", dir) + + dir, err := filepath.Abs(dir) + if err != nil { + return nil, err + } + ext := filepath.Ext(dir) + if !strings.EqualFold(ext, ".db") { + return nil, fmt.Errorf("database directory must end with .db") + } + + directory := filepath.Dir(dir) + filename := filepath.Base(dir) + + name := strings.TrimSuffix(filename, ext) + db, err := dbm.NewGoLevelDB(name, directory, nil) + if err != nil { + return nil, err + } + return db, nil +} + +type ModuleStats struct { + ModuleKey string + NodeCount uint64 + TotalSizeBytes uint64 +} + +type GlobalStats struct { + TotalNodeCount uint64 + TotalSizeBytes uint64 + UnknownStoreKeyCount uint64 + UnknownStoreKeySize uint64 +} + +func extractStoreKey(fullKey string) string { + return r.FindString(fullKey) +} + +func printModuleStats(stats map[string]*ModuleStats, gs *GlobalStats) { + if len(stats) == 0 { + fmt.Printf("No module stats to report\n") + return + } + + statsSlice := maps.Values(stats) + + slices.SortStableFunc(statsSlice, func(a *ModuleStats, b *ModuleStats) int { + // sort from highest to lowest size + return -cmp.Compare(a.TotalSizeBytes, b.TotalSizeBytes) + }) + + fmt.Printf("****************** Printing module stats ******************\n") + fmt.Printf("Total number of nodes in db: %d\n", gs.TotalNodeCount) + fmt.Printf("Total size of database: %d bytes\n", gs.TotalSizeBytes) + fmt.Printf("Total number of unknown storekeys: %d\n", gs.UnknownStoreKeyCount) + fmt.Printf("Total size of unknown storekeys: %d bytes\n", gs.UnknownStoreKeySize) + fmt.Printf("Fraction of unknown storekeys: %.3f\n", float64(gs.UnknownStoreKeySize)/float64(gs.TotalSizeBytes)) + for _, v := range statsSlice { + fmt.Printf("Store key %s:\n", v.ModuleKey) + fmt.Printf("Number of tree state nodes: %d\n", v.NodeCount) + fmt.Printf("Total size of of module storage: %d bytes\n", v.TotalSizeBytes) + fmt.Printf("Fraction of total size: %.3f\n", float64(v.TotalSizeBytes)/float64(gs.TotalSizeBytes)) + } + fmt.Printf("****************** Printed stats for all Babylon modules ******************\n") +} + +func PrintDBStats(db dbm.DB, printInterval int) { + fmt.Printf("****************** Starting to iterate over whole database ******************\n") + storeKeyStats := make(map[string]*ModuleStats) + + gs := GlobalStats{} + + itr, err := db.Iterator(nil, nil) + if err != nil { + panic(err) + } + fmt.Printf("****************** Retrived database iterator ******************\n") + + defer itr.Close() + for ; itr.Valid(); itr.Next() { + gs.TotalNodeCount++ + if gs.TotalNodeCount%uint64(printInterval) == 0 { + printModuleStats(storeKeyStats, &gs) + } + + fullKey := itr.Key() + fullValue := itr.Value() + fullKeyString := string(fullKey) + keyValueSize := uint64(len(fullKey) + len(fullValue)) + extractedStoreKey := extractStoreKey(fullKeyString) + + if extractedStoreKey == "" { + gs.UnknownStoreKeyCount++ + gs.TotalSizeBytes += keyValueSize + gs.UnknownStoreKeySize += keyValueSize + continue + } + + if _, ok := storeKeyStats[extractedStoreKey]; !ok { + storeKeyStats[extractedStoreKey] = &ModuleStats{ + ModuleKey: extractedStoreKey, + } + } + + storeKeyStats[extractedStoreKey].NodeCount++ + storeKeyStats[extractedStoreKey].TotalSizeBytes += keyValueSize + gs.TotalSizeBytes += keyValueSize + } + + if err := itr.Error(); err != nil { + panic(err) + } + fmt.Printf("****************** Finished iterating over whole database ******************\n") + printModuleStats(storeKeyStats, &gs) +} + +func ModuleSizeCmd() *cobra.Command { + cmd := &cobra.Command{ + Use: "module-sizes [path-to-db]", + Short: "print sizes of each module in the database", + Args: cobra.ExactArgs(1), + RunE: func(cmd *cobra.Command, args []string) error { + d, err := cmd.Flags().GetInt(FlagPrintInterval) + + if err != nil { + return err + } + + if d <= 0 { + return fmt.Errorf("print interval must be greater than 0") + } + + pathToDB := args[0] + + db, err := OpenDB(pathToDB) + + if err != nil { + return err + } + defer db.Close() + + PrintDBStats(db, d) + + return nil + }, + } + + cmd.Flags().Int(FlagPrintInterval, 100000, "interval between printing databse stats") + + return cmd +} diff --git a/cmd/babylond/cmd/testnet.go b/cmd/babylond/cmd/testnet.go index 6a9e8e348..aff015cb5 100644 --- a/cmd/babylond/cmd/testnet.go +++ b/cmd/babylond/cmd/testnet.go @@ -11,6 +11,7 @@ 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" @@ -35,12 +36,11 @@ import ( stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" "github.com/spf13/cobra" - "github.com/babylonchain/babylon/app" - appparams "github.com/babylonchain/babylon/app/params" - "github.com/babylonchain/babylon/privval" - "github.com/babylonchain/babylon/testutil/datagen" - bbn "github.com/babylonchain/babylon/types" - checkpointingtypes "github.com/babylonchain/babylon/x/checkpointing/types" + appparams "github.com/babylonlabs-io/babylon/app/params" + "github.com/babylonlabs-io/babylon/privval" + "github.com/babylonlabs-io/babylon/testutil/datagen" + bbn "github.com/babylonlabs-io/babylon/types" + checkpointingtypes "github.com/babylonlabs-io/babylon/x/checkpointing/types" ) var ( @@ -97,8 +97,7 @@ Example: genesisCliArgs.EpochInterval, genesisCliArgs.BaseBtcHeaderHex, genesisCliArgs.BaseBtcHeaderHeight, genesisCliArgs.AllowedReporterAddresses, genesisCliArgs.CovenantPKs, genesisCliArgs.CovenantQuorum, genesisCliArgs.SlashingAddress, genesisCliArgs.MinSlashingTransactionFeeSat, genesisCliArgs.MinCommissionRate, - genesisCliArgs.SlashingRate, genesisCliArgs.MaxActiveFinalityProviders, genesisCliArgs.MinUnbondingTime, - genesisCliArgs.MinPubRand, genesisCliArgs.InflationRateChange, genesisCliArgs.InflationMin, + genesisCliArgs.SlashingRate, genesisCliArgs.MaxActiveFinalityProviders, genesisCliArgs.MinUnbondingTime, genesisCliArgs.MinUnbondingRate, genesisCliArgs.InflationRateChange, genesisCliArgs.InflationMin, genesisCliArgs.InflationMax, genesisCliArgs.GoalBonded, genesisCliArgs.BlocksPerYear, genesisCliArgs.GenesisTime, genesisCliArgs.BlockGasLimit, genesisCliArgs.VoteExtensionEnableHeight) @@ -322,7 +321,7 @@ func InitTestnet( srvconfig.WriteConfigFile(filepath.Join(nodeDir, "config/app.toml"), babylonConfig) // create and save client config - if _, err = app.CreateClientConfig(chainID, keyringBackend, nodeDir); err != nil { + if _, err = appkeepers.CreateClientConfig(chainID, keyringBackend, nodeDir); err != nil { return err } } diff --git a/cmd/babylond/cmd/testnet_test.go b/cmd/babylond/cmd/testnet_test.go index f529bdf7e..f379b1357 100644 --- a/cmd/babylond/cmd/testnet_test.go +++ b/cmd/babylond/cmd/testnet_test.go @@ -17,7 +17,7 @@ import ( "github.com/spf13/viper" "github.com/stretchr/testify/require" - "github.com/babylonchain/babylon/app" + "github.com/babylonlabs-io/babylon/app" ) func Test_TestnetCmd(t *testing.T) { @@ -33,7 +33,7 @@ func Test_TestnetCmd(t *testing.T) { DB: dbm.NewMemDB(), InvCheckPeriod: 0, SkipUpgradeHeights: map[int64]bool{}, - AppOpts: app.EmptyAppOptions{}, + AppOpts: app.TmpAppOptions(), }) err = genutiltest.ExecInitCmd(bbn.BasicModuleManager, home, bbn.AppCodec()) require.NoError(t, err) diff --git a/cmd/babylond/cmd/validate_genesis.go b/cmd/babylond/cmd/validate_genesis.go index 61fba3f17..f9ba0c0fc 100644 --- a/cmd/babylond/cmd/validate_genesis.go +++ b/cmd/babylond/cmd/validate_genesis.go @@ -13,7 +13,7 @@ import ( stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" "github.com/spf13/cobra" - "github.com/babylonchain/babylon/x/checkpointing/types" + "github.com/babylonlabs-io/babylon/x/checkpointing/types" ) const chainUpgradeGuide = "https://github.com/cosmos/cosmos-sdk/blob/a51aa517c46c70df04a06f586c67fb765e45322a/UPGRADING.md" diff --git a/cmd/babylond/cmd/validate_genesis_test.go b/cmd/babylond/cmd/validate_genesis_test.go index 1d39caa13..1248d596d 100644 --- a/cmd/babylond/cmd/validate_genesis_test.go +++ b/cmd/babylond/cmd/validate_genesis_test.go @@ -8,7 +8,7 @@ import ( dbm "github.com/cosmos/cosmos-db" - checkpointingtypes "github.com/babylonchain/babylon/x/checkpointing/types" + checkpointingtypes "github.com/babylonlabs-io/babylon/x/checkpointing/types" "github.com/cosmos/cosmos-sdk/x/genutil" "github.com/spf13/viper" @@ -22,8 +22,8 @@ import ( genutiltest "github.com/cosmos/cosmos-sdk/x/genutil/client/testutil" genutiltypes "github.com/cosmos/cosmos-sdk/x/genutil/types" - "github.com/babylonchain/babylon/app" - "github.com/babylonchain/babylon/cmd/babylond/cmd" + "github.com/babylonlabs-io/babylon/app" + "github.com/babylonlabs-io/babylon/cmd/babylond/cmd" ) func TestCheckCorrespondence(t *testing.T) { @@ -96,7 +96,7 @@ func generateTestGenesisState(t *testing.T, home string, n int) (*app.BabylonApp DB: dbm.NewMemDB(), InvCheckPeriod: 0, SkipUpgradeHeights: map[int64]bool{}, - AppOpts: app.EmptyAppOptions{}, + AppOpts: app.TmpAppOptions(), }) _ = genutiltest.ExecInitCmd(bbn.BasicModuleManager, home, bbn.AppCodec()) diff --git a/cmd/babylond/main.go b/cmd/babylond/main.go index 338f0cb45..7b323f60d 100644 --- a/cmd/babylond/main.go +++ b/cmd/babylond/main.go @@ -4,11 +4,11 @@ import ( "cosmossdk.io/log" "os" - "github.com/babylonchain/babylon/app" - "github.com/babylonchain/babylon/cmd/babylond/cmd" + "github.com/babylonlabs-io/babylon/app" + "github.com/babylonlabs-io/babylon/cmd/babylond/cmd" svrcmd "github.com/cosmos/cosmos-sdk/server/cmd" - "github.com/babylonchain/babylon/app/params" + "github.com/babylonlabs-io/babylon/app/params" ) func main() { diff --git a/contrib/images/Makefile b/contrib/images/Makefile index 3b9d0818e..67e2fc470 100644 --- a/contrib/images/Makefile +++ b/contrib/images/Makefile @@ -3,18 +3,18 @@ RELAYER_TAG := $(shell grep '^ENV RELAYER_TAG' cosmos-relayer/Dockerfile | cut - all: babylond cosmos-relayer babylond: babylond-rmi - docker build --tag babylonchain/babylond -f babylond/Dockerfile \ + docker build --tag babylonlabs-io/babylond -f babylond/Dockerfile \ $(shell git rev-parse --show-toplevel) babylond-rmi: - docker rmi babylonchain/babylond 2>/dev/null; true + docker rmi babylonlabs-io/babylond 2>/dev/null; true cosmos-relayer: cosmos-relayer-rmi - docker build --tag babylonchain/cosmos-relayer:${RELAYER_TAG} -f cosmos-relayer/Dockerfile \ + docker build --tag babylonlabs-io/cosmos-relayer:${RELAYER_TAG} -f cosmos-relayer/Dockerfile \ $(shell git rev-parse --show-toplevel)/contrib/images/cosmos-relayer - docker tag babylonchain/cosmos-relayer:${RELAYER_TAG} babylonchain/cosmos-relayer:latest + docker tag babylonlabs-io/cosmos-relayer:${RELAYER_TAG} babylonlabs-io/cosmos-relayer:latest cosmos-relayer-rmi: - docker rmi babylonchain/cosmos-relayer 2>/dev/null; true + docker rmi babylonlabs-io/cosmos-relayer 2>/dev/null; true .PHONY: all babylond cosmos-relayer babylond-rmi cosmos-relayer-rmi diff --git a/contrib/images/babylond/Dockerfile b/contrib/images/babylond/Dockerfile index 2e8add214..d4e8957fb 100644 --- a/contrib/images/babylond/Dockerfile +++ b/contrib/images/babylond/Dockerfile @@ -15,12 +15,12 @@ ARG COSMOS_BUILD_OPTIONS="" RUN apt-get update && apt-get install -y make git bash gcc curl jq # Build -WORKDIR /go/src/github.com/babylonchain/babylon +WORKDIR /go/src/github.com/babylonlabs-io/babylon # First cache dependencies -COPY go.mod go.sum /go/src/github.com/babylonchain/babylon/ +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/babylonchain/babylon/ +COPY ./ /go/src/github.com/babylonlabs-io/babylon/ # If version is set, then checkout this version RUN if [ -n "${VERSION}" ]; then \ git checkout -f ${VERSION}; \ @@ -38,11 +38,11 @@ RUN addgroup --gid 1137 --system babylon && adduser --uid 1137 --gid 1137 --syst 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/babylonchain/babylond:${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/babylonchain/babylon/go.mod /tmp +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 && \ @@ -51,7 +51,7 @@ RUN WASMVM_VERSION=$(grep github.com/CosmWasm/wasmvm /tmp/go.mod | cut -d' ' -f2 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 -COPY --from=build-env /go/src/github.com/babylonchain/babylon/build/babylond /bin/babylond +COPY --from=build-env /go/src/github.com/babylonlabs-io/babylon/build/babylond /bin/babylond # Set home directory and user WORKDIR /home/babylon diff --git a/crypto/bip322/bip322_test.go b/crypto/bip322/bip322_test.go index 22b4f5a13..bbf4d3697 100644 --- a/crypto/bip322/bip322_test.go +++ b/crypto/bip322/bip322_test.go @@ -6,8 +6,8 @@ import ( "math/rand" "testing" - "github.com/babylonchain/babylon/crypto/bip322" - "github.com/babylonchain/babylon/testutil/datagen" + "github.com/babylonlabs-io/babylon/crypto/bip322" + "github.com/babylonlabs-io/babylon/testutil/datagen" "github.com/btcsuite/btcd/btcec/v2" "github.com/btcsuite/btcd/btcutil" "github.com/btcsuite/btcd/chaincfg" diff --git a/crypto/ecdsa/ecdsa_test.go b/crypto/ecdsa/ecdsa_test.go index 836e49f8a..473eee42c 100644 --- a/crypto/ecdsa/ecdsa_test.go +++ b/crypto/ecdsa/ecdsa_test.go @@ -6,7 +6,7 @@ import ( "encoding/hex" "testing" - "github.com/babylonchain/babylon/crypto/ecdsa" + "github.com/babylonlabs-io/babylon/crypto/ecdsa" "github.com/btcsuite/btcd/btcec/v2" "github.com/stretchr/testify/require" ) diff --git a/crypto/eots/eots.go b/crypto/eots/eots.go index f94e66786..5bb288980 100644 --- a/crypto/eots/eots.go +++ b/crypto/eots/eots.go @@ -6,6 +6,7 @@ import ( "io" "github.com/btcsuite/btcd/btcec/v2" + "github.com/btcsuite/btcd/btcec/v2/schnorr" "github.com/btcsuite/btcd/chaincfg/chainhash" "github.com/decred/dcrd/dcrec/secp256k1/v4" ecdsa_schnorr "github.com/decred/dcrd/dcrec/secp256k1/v4/schnorr" @@ -32,13 +33,13 @@ func PubGen(k *PrivateKey) *PublicKey { // RandGen returns the value to be used as random value when signing, and the associated public value. func RandGen(randSource io.Reader) (*PrivateRand, *PublicRand, error) { - pk, err := KeyGen(randSource) + sk, err := KeyGen(randSource) if err != nil { return nil, nil, err } var j secp256k1.JacobianPoint - pk.PubKey().AsJacobian(&j) - return &pk.Key, &j.X, nil + sk.PubKey().AsJacobian(&j) + return &sk.Key, &j.X, nil } // hash function is used for hashing the message input for all functions of the library. @@ -118,12 +119,23 @@ func signHash(sk *PrivateKey, privateRand *PrivateRand, hash [32]byte) (*Signatu // Verify verifies that the signature is valid for this message, public key and random value. func Verify(pubKey *PublicKey, r *PublicRand, message []byte, sig *Signature) error { h := hash(message) - return verifyHash(pubKey, r, h, sig) + pubkeyBytes := schnorr.SerializePubKey(pubKey) + return verifyHash(pubkeyBytes, r, h, sig) } // Verify verifies that the signature is valid for this hashed message, public key and random value. // Based on unexported schnorrVerify of btcd. -func verifyHash(pubKey *PublicKey, r *PublicRand, hash [32]byte, sig *Signature) error { +func verifyHash(pubKeyBytes []byte, r *PublicRand, hash [32]byte, sig *Signature) error { + // Step 2. + // + // P = lift_x(int(pk)) + // + // Fail if P is not a point on the curve + pubKey, err := schnorr.ParsePubKey(pubKeyBytes) + if err != nil { + return err + } + // Fail if P is not a point on the curve if !pubKey.IsOnCurve() { str := "pubkey point is not on curve" diff --git a/crypto/eots/eots_test.go b/crypto/eots/eots_test.go index 9adc8df8f..4ff6ab156 100644 --- a/crypto/eots/eots_test.go +++ b/crypto/eots/eots_test.go @@ -1,11 +1,15 @@ -package eots +package eots_test import ( "bytes" "crypto/rand" + mathrand "math/rand" "testing" + "github.com/babylonlabs-io/babylon/crypto/eots" + "github.com/babylonlabs-io/babylon/testutil/datagen" "github.com/decred/dcrd/dcrec/secp256k1/v4" + "github.com/stretchr/testify/require" "github.com/vulpine-io/io-test/v1/pkg/iotest" ) @@ -14,64 +18,59 @@ import ( // test compare signatures against btcec func FuzzSignAndVerify(f *testing.F) { - randSource := new(iotest.ReadCloser) + datagen.AddRandomSeedsToFuzzer(f, 10) - sk, err := KeyGen(randSource) - if err != nil { - f.Fatal(err) - } - k, publicK, err := RandGen(rand.Reader) - if err != nil { - f.Fatal(err) - } + f.Fuzz(func(t *testing.T, seed int64) { + r := mathrand.New(mathrand.NewSource(seed)) - for _, seed := range [][]byte{[]byte("hello"), []byte("1234567890!@#$%^&*()")} { - f.Add(seed) - } - f.Fuzz(func(t *testing.T, message []byte) { - sig, err := Sign(sk, k, message) - if err != nil { - t.Fatal(err) - } - err = Verify(PubGen(sk), publicK, message, sig) - if err != nil { - t.Fatal(err) - } + sk, err := eots.KeyGen(r) + require.NoError(t, err) + pk := eots.PubGen(sk) + + sr, pr, err := eots.RandGen(rand.Reader) + require.NoError(t, err) + + msg := datagen.GenRandomByteArray(r, 100) + sig, err := eots.Sign(sk, sr, msg) + require.NoError(t, err) + + err = eots.Verify(pk, pr, msg, sig) + require.NoError(t, err) }) } func TestSignAndInvalidVerify(t *testing.T) { randSource := new(iotest.ReadCloser) - sk, err := KeyGen(randSource) + sk, err := eots.KeyGen(randSource) if err != nil { t.Fatal(err) } - k, publicK, err := RandGen(randSource) + k, publicK, err := eots.RandGen(randSource) if err != nil { t.Fatal(err) } message := []byte("hello") - sig, err := Sign(sk, k, message) + sig, err := eots.Sign(sk, k, message) if err != nil { t.Fatal(err) } invalidK := new(secp256k1.FieldVal).Set(publicK).AddInt(1) - err = Verify(PubGen(sk), invalidK, message, sig) + err = eots.Verify(eots.PubGen(sk), invalidK, message, sig) if err == nil { t.Fatal("Expected verify to fail with wrong k value") } - err = Verify(PubGen(sk), publicK, message, new(Signature)) + err = eots.Verify(eots.PubGen(sk), publicK, message, new(eots.Signature)) if err == nil { t.Fatal("Expected verify to fail with wrong signature for the hash") } messageInvalid := []byte("bye") - err = Verify(PubGen(sk), publicK, messageInvalid, sig) + err = eots.Verify(eots.PubGen(sk), publicK, messageInvalid, sig) if err == nil { t.Fatal("Expected verify to fail with wrong signature for the hash") } @@ -79,11 +78,11 @@ func TestSignAndInvalidVerify(t *testing.T) { func FuzzExtract(f *testing.F) { randSource := new(iotest.ReadCloser) - sk, err := KeyGen(randSource) + sk, err := eots.KeyGen(randSource) if err != nil { f.Fatal(err) } - k, publicK, err := RandGen(rand.Reader) + k, publicK, err := eots.RandGen(rand.Reader) if err != nil { f.Fatal(err) } @@ -102,17 +101,17 @@ func FuzzExtract(f *testing.F) { t.Skip() } - sig1, err := Sign(sk, k, message1) + sig1, err := eots.Sign(sk, k, message1) if err != nil { t.Fatal(err) } - sig2, err := Sign(sk, k, message2) + sig2, err := eots.Sign(sk, k, message2) if err != nil { t.Fatal(err) } - sk2, err := Extract(sk.PubKey(), publicK, message1, sig1, message2, sig2) + sk2, err := eots.Extract(eots.PubGen(sk), publicK, message1, sig1, message2, sig2) if err != nil { t.Fatal(err) } diff --git a/crypto/eots/examples/btc-testnet-txs/main.go b/crypto/eots/examples/btc-testnet-txs/main.go index 2ddec8443..766da8d01 100644 --- a/crypto/eots/examples/btc-testnet-txs/main.go +++ b/crypto/eots/examples/btc-testnet-txs/main.go @@ -8,7 +8,7 @@ import ( "fmt" "os" - "github.com/babylonchain/babylon/crypto/eots" + "github.com/babylonlabs-io/babylon/crypto/eots" "github.com/btcsuite/btcd/btcutil" "github.com/btcsuite/btcd/chaincfg" "github.com/btcsuite/btcd/chaincfg/chainhash" @@ -130,7 +130,10 @@ func generateTx(senderPk *eots.PrivateKey, amount int64, fees int64, rcvAddress recTx.TxIn[0].SignatureScript = scriptSig buf := bytes.NewBuffer(make([]byte, 0, recTx.SerializeSize())) - recTx.Serialize(buf) + err = recTx.Serialize(buf) + if err != nil { + return nil, "", err + } // verify transaction vm, err := txscript.NewEngine(rcvScript, recTx, 0, txscript.StandardVerifyFlags, nil, nil, amount, nil) diff --git a/crypto/schnorr-adaptor-signature/keys_test.go b/crypto/schnorr-adaptor-signature/keys_test.go index dcc1bcdf8..92b8aee7b 100644 --- a/crypto/schnorr-adaptor-signature/keys_test.go +++ b/crypto/schnorr-adaptor-signature/keys_test.go @@ -3,7 +3,7 @@ package schnorr_adaptor_signature_test import ( "testing" - asig "github.com/babylonchain/babylon/crypto/schnorr-adaptor-signature" + asig "github.com/babylonlabs-io/babylon/crypto/schnorr-adaptor-signature" "github.com/stretchr/testify/require" ) diff --git a/crypto/schnorr-adaptor-signature/sig_test.go b/crypto/schnorr-adaptor-signature/sig_test.go index 34ee6cd49..83cb49eba 100644 --- a/crypto/schnorr-adaptor-signature/sig_test.go +++ b/crypto/schnorr-adaptor-signature/sig_test.go @@ -7,7 +7,7 @@ import ( "github.com/btcsuite/btcd/chaincfg/chainhash" "github.com/stretchr/testify/require" - asig "github.com/babylonchain/babylon/crypto/schnorr-adaptor-signature" + asig "github.com/babylonlabs-io/babylon/crypto/schnorr-adaptor-signature" ) func FuzzEncSignAndEncVerify(f *testing.F) { diff --git a/docker-compose.yml b/docker-compose.yml index 8b40cf1fa..b92576e3f 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -3,7 +3,7 @@ version: "3" services: babylondnode0: container_name: babylondnode0 - image: "babylonchain/babylond" + image: "babylonlabs-io/babylond" command: > babylond --home /babylondhome start --log_format 'plain' 2>&1 | tee /babylondhome/babylond.log cap_add: @@ -23,7 +23,7 @@ services: babylondnode1: container_name: babylondnode1 - image: "babylonchain/babylond" + image: "babylonlabs-io/babylond" command: > babylond --home /babylondhome start --log_format 'plain' 2>&1 | tee /babylondhome/babylond.log cap_add: @@ -43,7 +43,7 @@ services: babylondnode2: container_name: babylondnode2 - image: "babylonchain/babylond" + image: "babylonlabs-io/babylond" environment: - LOG=${LOG:-babylond.log} command: > @@ -65,7 +65,7 @@ services: babylondnode3: container_name: babylondnode3 - image: "babylonchain/babylond" + image: "babylonlabs-io/babylond" environment: - LOG=${LOG:-babylond.log} command: > diff --git a/docs/architecture.md b/docs/architecture.md index 0a98a4938..ca2f56160 100644 --- a/docs/architecture.md +++ b/docs/architecture.md @@ -108,7 +108,7 @@ an alarm will be raised by the monitor program. A standalone program that submits Babylon checkpoints to Bitcoin as Bitcoin transactions embedding data -utilising the `OP_RETURN` Bitcoin script code. +utilizing the `OP_RETURN` Bitcoin script code. ### [Vigilante Reporter](https://github.com/babylonchain/vigilante) @@ -187,7 +187,7 @@ finality provider's private keys. ### [Covenant Emulator](https://github.com/babylonchain/covenant-emulator) -A standalone program utilised by the covenant emulation committee members. +A standalone program utilized by the covenant emulation committee members. It emulates [covenant](https://covenants.info) functionality by monitoring for pending staking requests, verifying their contents, and @@ -210,14 +210,14 @@ this function. Most notably: - [Cosmos Relayer](https://github.com/cosmos/relayer): A fully functional relayer written in Go. -- [Babylon Relayer](https://github.com/babylonchain/babylon-relayer/): +- [Babylon Relayer](https://github.com/babylonlabs-io/babylon-relayer/): A wrapper of the Cosmos Relayer that can maintain a one-way IBC connection. It is recommended to be used when the Consumer Zone does not deploy the Babylon smart contract. - [Hermes Relayer](https://github.com/informalsystems/hermes): A fully functional relayer written in Rust. -### [Babylon Contract](https://github.com/babylonchain/babylon-contract) +### [Babylon Contract](https://github.com/babylonlabs-io/babylon-contract) A [CosmWasm](https://cosmwasm.com/) smart contract intended for deployment in a Consumer Zone. diff --git a/docs/run-node.md b/docs/run-node.md index 705bb72f1..fe4cdf534 100644 --- a/docs/run-node.md +++ b/docs/run-node.md @@ -5,9 +5,11 @@ installed. If the repository was only built, then `./build/babylond` should be used in its place. ### Generating the node configuration + The configuration for a single node can be created through the `testnet` command. While the `testnet` command can create an arbitrary number of nodes that communicate on a testnet, here we focus on the setup of a single node. + ```console babylond testnet \ --v 1 \ @@ -18,6 +20,7 @@ babylond testnet \ ``` The flags specify the following: + - `--output-dir `: Specifies that the testnet files should reside under this directory. - `--v `: Leads to the creation of `N` nodes, each one residing under the @@ -27,10 +30,11 @@ The flags specify the following: second one on `192.168.10.3:46656` etc. - `--keyring-backend {os,file,test}`: Specifies the backend to use for the keyring. Available choices include `os`, `file`, and `test`. We use `test` for convenience. -- `--chain-id`: An identifier for the chain. Useful when perrforming operations +- `--chain-id`: An identifier for the chain. Useful when performing operations later. In this case, we generated a single node. If we take a look under `.testnet`: + ```console $ ls .testnet gentxs node0 @@ -40,13 +44,15 @@ The `gentxs` directory contains the genesis transactions. It contains transactions that assign bbn tokens to a single address that is defined for each node. -The `node0` directory contains the the following, +The `node0` directory contains the following, + ```console $ ls .testnet/node0/babylond config data key_seed.json keyring-test ``` A brief description of the contents: + - `config`: Contains the configuration files for the node. - `data`: Contains the database storage for the node. - `key_seed.json`: Seed to generate the keys maintained by the keyring. @@ -57,6 +63,7 @@ A brief description of the contents: The keys for this node can be pointed to by the `node{i}` name. ### Running the node + ```console babylond start --home ./.testnet/node0/babylond ``` @@ -69,13 +76,15 @@ The logs for a particular node can be found under ### Performing queries After building a node and starting it, you can perform queries. + ```console babylond --home .testnet/node{i}/babylond/ --chain-id \ query ``` -For example, in order to get the hashes maintained by the `btcligthclient` +For example, in order to get the hashes maintained by the `btclightclient` module: + ```console $ babylond --home .testnet/node0/babylond/ --chain-id chain-test query btclightclient hashes @@ -89,6 +98,7 @@ pagination: ### Submitting transactions After building a node and running it, one can send transactions as follows: + ```console babylond --home .testnet/node{i}/babylond --chain-id \ --keyring-backend {os,file,test} --fees \ @@ -106,6 +116,7 @@ and `block` means after the transaction has been processed by the next block. For example, in the `btclightclient` module, in order to submit a header, one should: + ```console babylond --home .testnet/node0/babylond --chain-id chain-test \ --keyring-backend test --fees 100bbn \ @@ -122,14 +133,19 @@ 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  +[CometBFT Guidelines](https://docs.cometbft.com/v0.38/core/running-in-production) + ## Testing ```console make test ``` - diff --git a/docs/staking-script.md b/docs/staking-script.md index 41003e6b0..23ff7bc7f 100644 --- a/docs/staking-script.md +++ b/docs/staking-script.md @@ -5,7 +5,7 @@ Babylon's BTC staking protocol turns Bitcoin into a staking asset with the aim to enhance the economic security of the Babylon chain. Bitcoin holders can stake their Bitcoin by locking them using a special transaction on the Bitcoin chain. -The locked Bitcoin contribute to Babylon chain's economic security and generate +The locked Bitcoin contributes to Babylon chain's economic security and generates yields for the Bitcoin stakers. The protocol has the following important properties: @@ -30,20 +30,35 @@ The protocol has the following important properties: 7. (WIP) restakable, meaning that the same bitcoin can be staked to secure multiple PoS chains and earn multiple PoS yields + +In the entire Bitcoin staking process, two parties are involved: one is called +the Bitcoin Staker, and the other is called the Finality Provider. + +- **Bitcoin Staker**: A Bitcoin Staker is an entity identified by `` +in staking scripts. Note that a staking transaction can be funded from +arbitrary UTXO, including those owned by multisig/MPC/threshold accounts. +Thus, `` is not necessarily the address of the source of the fund. +Rather, it is the controller and beneficiary of the stake after its creation. +- **Finality Provider**: A Finality Provider is the an entity that votes +in the finality round to provide security assurance to the PoS chain. + +The Bitcoin staker can choose a specific Finality Provider to delegate +their voting power derived from their locked Bitcoin. + The key to making all these possible is special constructions of BTC transactions using BTC scripts. ## Preliminary Babylon interaction with Bitcoin is heavily based on Bitcoin's -[Taproot upgrade](https://github.com/bitcoin/bips/blob/master/bip-0341.mediawik). +[Taproot upgrade](https://github.com/bitcoin/bips/blob/master/bip-0341.mediawiki). This design choice was made due to the heavy usage of [Schnorr signatures](https://github.com/bitcoin/bips/blob/master/bip-0340.mediawiki) that were introduced through the Taproot upgrade. ## Staking Flow -Following diagram show how different transactions described in following +Following diagram shows how different transactions described in following paragraphs create and spend different bitcoin outputs: ```mermaid @@ -90,9 +105,9 @@ There are three special transaction types recognized by the Babylon chain: ### Staking Transaction -A BTC holder gains voting power by creating a staking transaction. This is a +A BTC Staker gains voting power by creating a staking transaction. This is a Bitcoin transaction that commits a certain amount of to-be-staked bitcoin to -Babylon recognised BTC staking scripts. These scripts lock the stake for a +Babylon recognized BTC staking scripts. These scripts lock the stake for a chosen amount of BTC blocks and enable other features such as unbonding and slashable safety. @@ -100,20 +115,20 @@ The requirements for a valid staking transaction are: - it can contain arbitrary number of inputs - it can contain arbitrary number of outputs. One of those outputs must be -a Taproot output committing to the BTC staking scripts recognized by Babylon. -Henceforth known as `Staking Output`. + a Taproot output committing to the BTC staking scripts recognized by Babylon. + Henceforth known as `Staking Output`. ### Unbonding Transaction -The BTC staker utilises the unbonding transaction when they want to unlock +The BTC staker utilizes the unbonding transaction when they want to unlock their stake before their originally committed timelock has expired. The requirements for a valid unbonding transaction are: - it contains exactly one input which points to staking transaction's `Staking - Output`. +Output`. - it contains exactly one output which must be a Taproot output committing to -the BTC unbonding scripts recognized by Babylon. Henceforth known as `Unbonding + the BTC unbonding scripts recognized by Babylon. Henceforth known as `Unbonding Output`. ### Slashing Transaction @@ -126,13 +141,23 @@ The requirements for a valid slashing transaction are: - it must have exactly one input pointing to either the staking output or the unbonding output - it must have exactly two outputs, the first sending the slashed fraction of -the funds to a burn address specified in the Babylon chain's parameters and the -second sending the remaining funds back to the BTC staker's address. + the funds to a burn address specified in the Babylon chain's parameters and the + second sending the remaining funds to output which can be unlocked by staker + after the timelock - the fee for the slashing transactions must be larger than or equal to the minimal fee specified in Babylon's parameters ## Staking and Unbonding output scripts +In the below scripts, there are three entities, each represented by BTC public +key: + +- `StakerPK` - BTC staker public key +- `FinalityProviderPk` - finality provider public key +- `CovenantPk1..CovenantPkN` - public keys of covenant committee members +There must be no duplicated public keys in created scripts. +For example, `StakerPK` must never be equal to `FinalityProviderPk` + ### Staking output The staking output is a taproot output which can only be spent through a script @@ -157,16 +182,16 @@ The timelock path locks the staker's Bitcoin for a pre-determined number of Bitcoin blocks. It commits to a script of the form: ``` - OP_CHECKSIGVERIFY OP_CHECKSEQUENCEVERIFY + OP_CHECKSIGVERIFY OP_CHECKSEQUENCEVERIFY ``` where: -- `` is the BTC staker's public key.. -- `` is the lockup period denoted in Bitcoin blocks. The -timelock comes into effect after the Bitcoin transaction has been included in a -mined block. In essence, the script denotes that only the staker can unlock the -funds after the timelock has passed. It must be lower than `65535`. +- `` is the BTC staker's public key.. +- `` is the lockup period denoted in Bitcoin blocks. The + timelock comes into effect after the Bitcoin transaction has been included in a + mined block. In essence, the script denotes that only the staker can unlock the + funds after the timelock has passed. It must be lower than `65535`. #### 2. Unbonding path @@ -175,17 +200,17 @@ before the timelock expires. It commits to a script of the form: ``` OP_CHECKSIGVERIFY - OP_CHECKSIGADD OP_CHECKSIGADD ... OP_CHECKSIGADD - OP_GREATERTHANOREQUAL + OP_CHECKSIG OP_CHECKSIGADD ... OP_CHECKSIGADD + OP_NUMEQUAL ``` where: -- `Staker_PK` is the BTC staker's public key +- `StakerPK` is the BTC staker's public key - `CovenantPk1..CovenantPkN` are the lexicographically sorted public keys of the -current covenant committee recognized by the Babylon chain + current covenant committee recognized by the Babylon chain - `CovenantThreshold` is a Babylon parameter specifying the number of how many -covenant committee member signatures are required. + covenant committee member signatures are required. Signatures from a quorum of the covenant committee are required to ensure that this script is not used for on-demand unlocking without the stake going through @@ -193,14 +218,14 @@ an unbonding period. reward all covenant members for their work. #### 3. Slashing path -The slashing path is utilised for punishing finality providers and their +The slashing path is utilized for punishing finality providers and their delegators in the case of double signing. It commits to a script: ``` OP_CHECKSIGVERIFY OP_CHECKSIGVERIFY - OP_CHECKSIGADD OP_CHECKSIGADD ... OP_CHECKSIGADD - OP_GREATERTHANOREQUAL + OP_CHECKSIG OP_CHECKSIGADD ... OP_CHECKSIGADD + OP_NUMEQUAL ``` where: @@ -209,9 +234,9 @@ where: - `FinalityProviderPk` is the BTC public key of the finality provider to which the staker delegates their stake - `CovenantPk1..CovenantPkN` are the lexicographically sorted public keys of the -current covenant committee members recognized by the Babylon chain + current covenant committee members recognized by the Babylon chain - `CovenantThreshold` is a Babylon parameter denoting how many covenant -committee member signatures are required. + committee member signatures are required. This path can only be executed with the collaboration of the BTC staker, finality provider, and covenant committee. @@ -220,8 +245,8 @@ It is used in following way: - for stake to become active, staker must publish pre signed slashing transaction - covenant committee validates such transaction, and publish its own signatures. - the only signature missing to send slashing transaction is finality provider -signature. If finality provider private key leaks due to infractions, anyone can -sign slashing transaction and send slashing transaction to Bitcoin network. + signature. If finality provider private key leaks due to infractions, anyone can + sign slashing transaction and send slashing transaction to Bitcoin network. #### Difference between Unbonding and Slashing Path @@ -230,17 +255,17 @@ The main difference between the unbonding and slashing paths is the existence of This leads to following system wide repercussions: -- for staking request to become active, btc holder needs to provide valid -unbonding transaction in this staking request. This staking request will become -active only when `CovenantThreshold` signatures will be received by Babylon -chain. Lack of `FinalityProviderPk` in unbonding path, means that after -delegation becomes active, staker can send unbodning transaction any time -without asking finality provider for permission. +- for staking request to become active, btc staker needs to provide valid + unbonding transaction in this staking request. This staking request will become + active only when `CovenantThreshold` signatures will be received by Babylon + chain. Lack of `FinalityProviderPk` in unbonding path, means that after + delegation becomes active, staker can send unbonding transaction any time + without asking finality provider for permission. - existence of `FinalityProviderPk` in slashing path, coupled with the fact that -btc holder needs to provide pre-signed slashing transaction which needs to be -signed by covenant committee for delegation request to become active, leads to -situation in which the only signature missing to send slashing transaction to -btc is signature of finality provider. + btc staker needs to provide pre-signed slashing transaction which needs to be + signed by covenant committee for delegation request to become active, leads to + situation in which the only signature missing to send slashing transaction to + btc is signature of finality provider. ### Unbonding output @@ -259,26 +284,26 @@ The timelock path locks the staker's Bitcoin for a pre-determined number of Bitcoin blocks. It commits to a script of the form: ``` - OP_CHECKSIGVERIFY OP_CHECKSEQUENCEVERIFY` + OP_CHECKSIGVERIFY OP_CHECKSEQUENCEVERIFY` ``` where: -- Staker_PK is btc holder public key -- Timelock_Blocks is unbonding time. It must be lower or equal 65535, but larger -than `max(MinUnbondingTime, CheckpointFinalizationTimeout)`. `MinUnbondingTime` -and `CheckpointFinalizationTimeout` are Babylon parameters. +- `` is btc staker public key +- `` is unbonding time. It must be lower or equal 65535, but larger + than `max(MinUnbondingTime, CheckpointFinalizationTimeout)`. `MinUnbondingTime` + and `CheckpointFinalizationTimeout` are Babylon parameters. #### 2. Slashing path -The slashing path is utilised for punishing finality providers and their +The slashing path is utilized for punishing finality providers and their delegators in the case of double signing. It commits to a script: ``` OP_CHECKSIGVERIFY OP_CHECKSIGVERIFY - OP_CHECKSIGADD OP_CHECKSIGADD ... OP_CHECKSIGADD - OP_GREATERTHANOREQUAL + OP_CHECKSIG OP_CHECKSIGADD ... OP_CHECKSIGADD + OP_NUMEQUAL ``` where: @@ -287,9 +312,9 @@ where: - `FinalityProviderPk` is the BTC public key of the finality provider to which the staker delegates their stake - `CovenantPk1..CovenantPkN` are the lexicographically sorted public keys of the -current covenant committee members recognized by the Babylon chain + current covenant committee members recognized by the Babylon chain - `CovenantThreshold` is a Babylon parameter denoting how many covenant -committee member signatures are required. + committee member signatures are required. #### Existence of Slashing path in Unbonding output diff --git a/docs/transaction-impl-spec.md b/docs/transaction-impl-spec.md new file mode 100644 index 000000000..d21a45caf --- /dev/null +++ b/docs/transaction-impl-spec.md @@ -0,0 +1,373 @@ +# Observable Staking Transactions Specification + +## Introduction + +A lock-only network involves users locking their Bitcoin using the self-custodial +Bitcoin Staking script without a Babylon chain operating. +In this document, we precisely define how one can construct +the Bitcoin transactions specified by the Bitcoin Staking protocol. + +## Prerequisites + +- [Scripts doc](staking-script.md) - document which defines how different +Bitcoin Staking scripts look like +- [BIP341](https://github.com/bitcoin/bips/blob/master/bip-0341.mediawiki)- +a document specifying how to spend taproot outputs + +## System parameters + +The lock-only staking system is governed by a set of parameters that specify +what constitutes a valid staking transaction. Based on those, +an observer of the Bitcoin ledger can precisely identify which transactions +are valid staking transactions and whether they should be considered active stake. +These parameters are different depending on the Bitcoin height a transaction is +included in and a constructor of a Bitcoin Staking transaction should take them into +account before propagating a transaction to Bitcoin. +For the rest of the document, we will refer to those parameters as `global_parameters`. + +More details about parameters can be found in the +[parameters spec](https://github.com/babylonchain/networks/tree/main/bbn-test-4/parameters). + +## Taproot outputs + +Taproot outputs are outputs whose locking script is an elliptic curve point `Q` +created as follows: +``` +Q = P + hash(P||m)G +``` +where: +- `P` is the internal public key +- `m` is the root of a Merkle tree whose leaves consist of a version number and a +script + +For Bitcoin Staking transactions, the internal public key is chosen as: + +``` +P = lift_x(0x50929b74c1a04954b78b4b6035e97a5e078a5a0f28ec96d547bfee9ace803ac0) +``` + +This key is described in the +[BIP341](https://github.com/bitcoin/bips/blob/master/bip-0341.mediawiki#constructing-and-spending-taproot-outputs) +specification. + +The use of this key as an internal public key disables spending from taproot output +through the key spending path. +The construction of this key can be found [here](../btcstaking/types.go?plain=1#L27). + +## Observable Staking Transactions + +### Staking transaction + +A staker enters the system through the creation of a staking transaction +which locks Bitcoin in the Bitcoin Staking script. + +#### Requirements + +For the transaction to be considered a valid staking transaction, it must: +- have a taproot output which has the key spending path disabled +and commits to a script tree composed of three scripts:: +timelock script, unbonding script, slashing script. +This output is henceforth known as the `staking_output` and +the value in this output is known as `staking_amount` +- have `OP_RETURN` output which contains: `global_parameters.tag`, + `version`, `staker_pk`,`finality_provider_pk`, `staking_time` +- all the values must be valid for the `global_parameters` which are applicable at +the height in which the staking transaction is included in the BTC ledger. + + +#### OP_RETURN output description + +Data in the OP_RETURN output is described by the following struct: + +```go +type V0OpReturnData struct { + Tag []byte + Version byte + StakerPublicKey []byte + FinalityProviderPublicKey []byte + StakingTime []byte +} +``` +The implementation of the struct can be found [here](../btcstaking/identifiable_staking.go?pain=1#L52) + +Fields description: +- `Tag` - 4 bytes, tag which is used to identify the staking transaction +among other transactions in the Bitcoin ledger. +It is specified in the `global_parameters.Tag` field. +- `Version` - 1 byte, current version of the OP_RETURN output +- `StakerPublicKey` - 32 bytes, staker public key. The same key must be used in +the scripts used to create the taproot output in the staking transaction. +- `FinalityProviderPublicKey` - 32 bytes, finality provider public key. The same key +must be used in the scripts used to create the taproot output in the +staking transaction. +- `StakingTime` - 2 bytes big-endian unsigned number, staking time. +The same timelock time must be used in scripts used to create the taproot +output in the staking transaction. + + +This data is serialized as follows: +``` +SerializedStakingData = Tag || Version || StakerPublicKey || FinalityProviderPublicKey || StakingTime +``` + +To transform this data into OP_RETURN data: + +``` +StakingDataPkScript = 0x6a || 0x47 || SerializedStakingData +``` + +where: +- 0x6a - is byte marker representing OP_RETURN op code +- 0x47 - is byte marker representing OP_DATA_71 op code, which pushed 71 bytes onto the stack + +The final OP_RETURN output will have the following shape: +``` +TxOut { + Value: 0, + PkScript: StakingDataPkScript +} +``` + +Logic creating output from data can be found [here](../btcstaking/identifiable_staking.go?pain=1#L175) + + +#### Staking output description + +Staking output should commit to three scripts: +- `timelock_script` +- `unbonding_script` +- `slashing_script` + +Data needed to create `staking_output`: +- `staker_public_key` - chosen by the user sending the staking transaction. It +will be used in every script. This key needs to be put in the OP_RETURN output +in the staking transaction. +- `finality_provider_public_key` - chosen by the user sending the staking +transaction. It will be used as `` in `slashing_script`. In the +lock-only network there is no slashing, so this key has mostly informative purposes. +This key needs to be put in the OP_RETURN output of the staking transaction. +- `staking_time` - chosen by the user sending the staking transaction. It will +be used as locking time in the `timelock_script`. It must be a valid `uint16` number, +in the range `global_parameters.min_staking_time <= staking_time <= global_parameters.max_staking_time`. +It needs to be put in the OP_RETURN output of the staking transaction. +- `covenant_committee_public_keys` - it can be retrieved from +`global_parameters.covenant_pks`. It is set of covenant committee public keys which +will be put in `unbonding_script` and `slashing_script`. +- `covenant_committee_quorum` - it can be retrieved from +`global_parameters.covenant_quorum`. It is quorum of covenant committee +member required to authorize spending using `unbonding_script` or `slashing_script` +- `staking_amout` - chosen by the user, it will be placed in `staking_output.value` +- `btc_network` - btc network on which staking transactions will take place + +#### Building OP_RETRUN and staking output implementation + +The Babylon staking library exposes the [BuildV0IdentifiableStakingOutputsAndTx](../btcstaking/identifiable_staking.go?plain=1#L231) +function with the following signature: + +```go +func BuildV0IdentifiableStakingOutputsAndTx( + tag []byte, + stakerKey *btcec.PublicKey, + fpKey *btcec.PublicKey, + covenantKeys []*btcec.PublicKey, + covenantQuorum uint32, + stakingTime uint16, + stakingAmount btcutil.Amount, + net *chaincfg.Params, +) (*IdentifiableStakingInfo, *wire.MsgTx, error) +``` + +It enables the caller to create valid outputs to put inside an unfunded and not-signed +staking transaction. + +The suggested way of creating and sending a staking transaction using +[bitcoind](https://github.com/bitcoin/bitcoin) is: +1. create `staker_key` in the bitcoind wallet +2. create unfunded and not signed staking transaction using +the `BuildV0IdentifiableStakingOutputsAndTx` function +3. serialize the unfunded and not signed staking transaction to `staking_transaction_hex` +4. call `bitcoin-cli fundrawtransaction "staking_transaction_hex"` to +retrieve `funded_staking_transaction_hex`. +The bitcoind wallet will automatically choose unspent outputs to fund this transaction. +5. call `bitcoin-cli signrawtransactionwithwallet "funded_staking_transaction_hex"`. +This call will sign all inputs of the transaction and return `signed_staking_transaction_hex`. +6. call `bitcoin-cli sendrawtransaction "signed_staking_transaction_hex"` + +### Unbonding transaction + +The unbonding transaction allows the staker to on-demand unbond their +locked Bitcoin stake prior to its original timelock expiration. + +#### Requirements + +For the transaction to be considered a valid unbonding transaction, it must: +- have exactly one input and one output +- input must be valid a staking output +- output must be a taproot output. This taproot output must have disabled +the key spending path, and committed to script tree composed of two scripts: +the timelock script and the slashing script. This output is henceforth known +as the `unbonding_output` +- timelock in the time lock script must be equal to `global_parameters.unbonding_time` +- value in the unbonding output must be equal to `staking_output.value - global_parameters.unbonding_fee` + +#### Building Unbonding output + +The Babylon Bitcoin staking library exposes +the [BuildUnbondingInfo](../btcstaking/types.go?plain=1#416) +function which builds a valid unbonding output. +It has the following signature: + +```go +func BuildUnbondingInfo( + stakerKey *btcec.PublicKey, + fpKeys []*btcec.PublicKey, + covenantKeys []*btcec.PublicKey, + covenantQuorum uint32, + unbondingTime uint16, + unbondingAmount btcutil.Amount, + net *chaincfg.Params, +) (*UnbondingInfo, error) +``` + +where: +- `stakerKey`- must be the same key as the staker key in `staking_transaction` +- `fpKeys` - must contain one key, which is the same finality provider key used +in `staking_transaction` +- `covenantKeys`- are the same covenant keys as used in `staking_transaction` +- `covenantQuorum` - is the same quorum as used in `staking_transaction` +- `unbondingTime` - is equal to `global_parameters.unbonding_time` +- `unbondingAmount` - is equal to `staking_amount - global_parameters.unbonding_fee` + +## Spending taproot outputs + +To create transactions which spend from taproot outputs, either staking output +or unbonding output, providing signatures satisfying the script is not enough. + +The spender must also provide: +- the whole script which is being spent +- the control block which contains: leaf version, internal public key, and proof of +inclusion of the given script in the script tree + +Given that creating scripts is deterministic for given data, it is possible to +avoid storing scripts by re-building scripts when the need arises. + +### Re-creating script and control block + +To build the script and control block necessary to spend from a staking output through the +timelock script, the following function could be implemented + +```go +import ( + // Babylon btc staking library + "github.com/babylonlabs-io/babylon/btcstaking" +) + +func buildTimelockScriptAndControlBlock( + stakerKey *btcec.PublicKey, + finalityProviderKey *btcec.PublicKey, + covenantKeys []*btcec.PublicKey, + covenantQuorum uint32, + stakingTime uint16, + stakingAmount btcutil.Amount, + netParams *chaincfg.Params, +) ([]byte, []byte, error) { + + stakingInfo, err := btcstaking.BuildStakingInfo( + stakerKey, + []*btcec.PublicKey{finalityProviderKey}, + covenantKeys, + covenantQuorum, + stakingTime, + stakingAmount, + netParams, + ) + + if err != nil { + return nil, nil, err + } + + si, err := stakingInfo.TimeLockPathSpendInfo() + + if err != nil { + return nil, nil, err + } + + scriptBytes := si.RevealedLeaf.Script + + controlBlock := si.ControlBlock + + controlBlockBytes, err := controlBlock.ToBytes() + if err != nil { + return nil, nil, err + } + + return scriptBytes, controlBlockBytes, nil +} + +``` + +The returned script and control block can be used to either build the witness directly +or to put them in a PSBT which can be used by bitcoind to create the witness. + +### Creating PSBT to get signature for given taproot path from Bitcoind + +To avoid creating signatures/witness manually, +Bitcoind's [walletprocesspsbt](https://developer.bitcoin.org/reference/rpc/walletprocesspsbt.html) +can be used. To use this Bitcoind endpoint to get signature/witness the wallet must +maintain one of the keys used in the script. + +Example of creating psbt to sign unbonding transaction using unbonding script from +staking output: + +```go +import ( + "github.com/btcsuite/btcd/btcutil/psbt" +) + +func BuildPsbtForSigningUnbondingTransaciton( + unbondingTx *wire.MsgTx, + stakingOutput *wire.TxOut, + stakerKey *btcec.PublicKey, + spentLeaf *txscript.TapLeaf, + controlBlockBytes []byte, +) (string, error) { + psbtPacket, err := psbt.New( + []*wire.OutPoint{&unbondingTx.TxIn[0].PreviousOutPoint}, + unbondingTx.TxOut, + unbondingTx.Version, + unbondingTx.LockTime, + []uint32{unbondingTx.TxIn[0].Sequence}, + ) + + if err != nil { + return "", fmt.Errorf("failed to create PSBT packet with unbonding transaction: %w", err) + } + + psbtPacket.Inputs[0].SighashType = txscript.SigHashDefault + psbtPacket.Inputs[0].WitnessUtxo = stakingOutput + psbtPacket.Inputs[0].Bip32Derivation = []*psbt.Bip32Derivation{ + { + PubKey: stakerKey.SerializeCompressed(), + }, + } + + psbtPacket.Inputs[0].TaprootLeafScript = []*psbt.TaprootTapLeafScript{ + { + ControlBlock: controlBlockBytes, + Script: spentLeaf.Script, + LeafVersion: spentLeaf.LeafVersion, + }, + } + + return psbtPacket.B64Encode() +} + +``` + +Given that to spend through the unbonding script requires more than the +staker's signature, the `walletprocesspsbt` endpoint will produce a new psbt +with the staker signature attached. + +In the case of a timelock path which requires only the staker's signature, +`walletprocesspsbt` would produce the whole witness required to send the +transaction to the BTC network. diff --git a/go.mod b/go.mod index 3c453131d..e8ba3e373 100644 --- a/go.mod +++ b/go.mod @@ -1,64 +1,70 @@ go 1.21 -module github.com/babylonchain/babylon +module github.com/babylonlabs-io/babylon require ( - github.com/CosmWasm/wasmd v0.50.0 - github.com/btcsuite/btcd v0.24.0 - github.com/cometbft/cometbft v0.38.5 + github.com/CosmWasm/wasmd v0.51.0 + github.com/btcsuite/btcd v0.24.2 + github.com/cometbft/cometbft v0.38.7 github.com/cometbft/cometbft-db v0.9.1 // indirect - // TODO: the current cosmos-sdk version is a non-released version, which is - // to fix the gasLimit problem - // should be replaced by a released version if there's any - github.com/cosmos/cosmos-sdk v0.50.4-0.20240126152601-c4a2fe2b8987 + github.com/cosmos/cosmos-sdk v0.50.6 + 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/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/stretchr/testify v1.8.4 + github.com/stretchr/testify v1.9.0 github.com/supranational/blst v0.3.11 - google.golang.org/genproto v0.0.0-20231211222908-989df2bf70f3 // indirect - google.golang.org/grpc v1.60.1 - google.golang.org/protobuf v1.32.0 + google.golang.org/genproto v0.0.0-20240227224415-6ceb2ff114de // indirect + google.golang.org/grpc v1.63.2 + google.golang.org/protobuf v1.33.0 gopkg.in/yaml.v2 v2.4.0 ) require ( - cosmossdk.io/api v0.7.2 + cosmossdk.io/api v0.7.4 cosmossdk.io/client/v2 v2.0.0-beta.1 + cosmossdk.io/collections v0.4.0 cosmossdk.io/core v0.11.0 cosmossdk.io/depinject v1.0.0-alpha.4 cosmossdk.io/errors v1.0.1 - cosmossdk.io/log v1.3.0 - cosmossdk.io/math v1.2.0 - cosmossdk.io/store v1.0.2 - cosmossdk.io/tools/confix v0.1.0 + cosmossdk.io/log v1.3.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/x/evidence v0.1.0 cosmossdk.io/x/feegrant v0.1.0 - cosmossdk.io/x/tx v0.13.0 - cosmossdk.io/x/upgrade v0.1.0 - github.com/CosmWasm/wasmvm v1.5.2 + cosmossdk.io/x/tx v0.13.3 + cosmossdk.io/x/upgrade v0.1.1 + github.com/CosmWasm/wasmvm/v2 v2.0.1 + github.com/avast/retry-go/v4 v4.5.1 + 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/chaincfg/chainhash v1.1.0 - github.com/cosmos/cosmos-db v1.0.0 - github.com/cosmos/cosmos-proto v1.0.0-beta.3 - github.com/cosmos/gogoproto v1.4.11 + github.com/cosmos/cosmos-db v1.0.2 + github.com/cosmos/cosmos-proto v1.0.0-beta.5 + github.com/cosmos/gogoproto v1.4.12 github.com/cosmos/ibc-go/modules/capability v1.0.0 - github.com/cosmos/ibc-go/v8 v8.0.0 + github.com/cosmos/ibc-go/v8 v8.3.0 github.com/decred/dcrd/dcrec/secp256k1/v4 v4.2.0 github.com/docker/docker v23.0.8+incompatible github.com/golang/mock v1.6.0 - github.com/golang/protobuf v1.5.3 - github.com/hashicorp/go-metrics v0.5.1 + github.com/golang/protobuf v1.5.4 + github.com/hashicorp/go-metrics v0.5.3 github.com/jinzhu/copier v0.3.5 + github.com/jsternberg/zap-logfmt v1.3.0 + github.com/juju/fslock v0.0.0-20160525022230-4d5c94c67b4b github.com/ory/dockertest/v3 v3.9.1 github.com/vulpine-io/io-test v1.0.0 - google.golang.org/genproto/googleapis/api v0.0.0-20231120223509-83a465c0220f + go.uber.org/zap v1.26.0 + golang.org/x/exp v0.0.0-20240404231335-c0f41cb1a7a0 + google.golang.org/genproto/googleapis/api v0.0.0-20240227224415-6ceb2ff114de ) require ( @@ -68,10 +74,10 @@ require ( 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.2.0 // indirect + github.com/cespare/xxhash/v2 v2.3.0 // indirect github.com/cosmos/btcutil v1.0.5 // indirect github.com/cosmos/go-bip39 v1.0.0 - github.com/cosmos/iavl v1.0.0 // indirect + github.com/cosmos/iavl v1.1.2 // 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 @@ -85,11 +91,11 @@ require ( 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.4 // indirect + github.com/golang/snappy v0.0.5-0.20220116011046-fa5810519dcb // indirect github.com/google/btree v1.1.2 // indirect github.com/google/orderedcode v0.0.1 // indirect github.com/gorilla/handlers v1.5.2 // indirect - github.com/gorilla/websocket v1.5.0 // indirect + github.com/gorilla/websocket v1.5.1 // 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 @@ -99,7 +105,7 @@ 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.4 // indirect + github.com/klauspost/compress v1.17.7 // indirect github.com/lib/pq v1.10.7 // indirect github.com/libp2p/go-buffer-pool v0.1.0 // indirect github.com/magiconair/properties v1.8.7 // indirect @@ -107,12 +113,12 @@ require ( github.com/minio/highwayhash v1.0.2 // indirect github.com/mitchellh/mapstructure v1.5.0 // indirect github.com/mtibben/percent v0.2.1 // indirect - github.com/petermattis/goid v0.0.0-20230904192822-1876fd5063bc // indirect + github.com/petermattis/goid v0.0.0-20231207134359-e60b3f734c67 // indirect github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect - github.com/prometheus/client_golang v1.17.0 - github.com/prometheus/client_model v0.5.0 // indirect - github.com/prometheus/common v0.45.0 // indirect - github.com/prometheus/procfs v0.12.0 // indirect + github.com/prometheus/client_golang v1.19.0 + 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/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 @@ -123,21 +129,20 @@ require ( 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.18.0 - golang.org/x/sys v0.16.0 // indirect - golang.org/x/term v0.16.0 // indirect - golang.org/x/text v0.14.0 // indirect + golang.org/x/crypto v0.23.0 + golang.org/x/sys v0.20.0 // indirect + golang.org/x/term v0.20.0 // indirect + golang.org/x/text v0.15.0 // indirect gopkg.in/ini.v1 v1.67.0 // indirect nhooyr.io/websocket v1.8.6 // indirect ) require ( - cloud.google.com/go v0.110.10 // indirect - cloud.google.com/go/compute v1.23.3 // indirect + cloud.google.com/go v0.112.0 // indirect + cloud.google.com/go/compute v1.24.0 // indirect cloud.google.com/go/compute/metadata v0.2.3 // indirect - cloud.google.com/go/iam v1.1.5 // indirect - cloud.google.com/go/storage v1.35.1 // indirect - cosmossdk.io/collections v0.4.0 // indirect + cloud.google.com/go/iam v1.1.6 // indirect + cloud.google.com/go/storage v1.36.0 // indirect cosmossdk.io/x/nft v0.1.0 // indirect github.com/99designs/go-keychain v0.0.0-20191008050251-8e49817e8af4 // indirect github.com/Azure/go-ansiterm v0.0.0-20230124172434-306776ec8161 // indirect @@ -146,20 +151,22 @@ require ( github.com/Microsoft/go-winio v0.6.1 // indirect github.com/Nvveen/Gotty v0.0.0-20120604004816-cd527374f1e5 // indirect github.com/aead/siphash v1.0.1 // indirect - github.com/aws/aws-sdk-go v1.44.224 // indirect + github.com/aws/aws-sdk-go v1.44.312 // indirect github.com/bgentry/go-netrc v0.0.0-20140422174119-9fd32a8b3d3d // indirect - github.com/bits-and-blooms/bitset v1.8.0 // indirect github.com/cenkalti/backoff/v4 v4.2.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/logtags v0.0.0-20230118201751-21c54148d20b // indirect - github.com/cockroachdb/pebble v0.0.0-20231102162011-844f0582c2eb // indirect + github.com/cockroachdb/pebble v1.1.0 // indirect github.com/cockroachdb/redact v1.1.5 // indirect github.com/cockroachdb/tokenbucket v0.0.0-20230807174530-cc333fc44b06 // indirect + github.com/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/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 @@ -168,10 +175,14 @@ require ( github.com/docker/cli v23.0.1+incompatible // indirect github.com/docker/go-connections v0.4.0 // indirect github.com/docker/go-units v0.5.0 // indirect - github.com/emicklei/dot v1.6.0 // indirect + github.com/emicklei/dot v1.6.1 // indirect + github.com/ethereum/c-kzg-4844 v0.4.0 // indirect + github.com/ethereum/go-ethereum v1.13.14 // indirect github.com/fatih/color v1.15.0 // indirect github.com/felixge/httpsnoop v1.0.4 // indirect - github.com/getsentry/sentry-go v0.25.0 // indirect + github.com/getsentry/sentry-go v0.27.0 // indirect + github.com/go-logr/logr v1.4.1 // indirect + 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.0 // indirect @@ -180,16 +191,17 @@ require ( 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.4.0 // 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.0 // indirect github.com/hashicorp/go-cleanhttp v0.5.2 // indirect - github.com/hashicorp/go-getter v1.7.1 // indirect + github.com/hashicorp/go-getter v1.7.3 // 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 github.com/hashicorp/go-version v1.6.0 // indirect github.com/hashicorp/yamux v0.1.1 // indirect + github.com/holiman/uint256 v1.2.4 // indirect github.com/huandu/skiplist v1.2.0 // indirect github.com/iancoleman/strcase v0.3.0 // indirect github.com/imdario/mergo v0.3.13 // indirect @@ -197,12 +209,12 @@ 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.6 // indirect + github.com/linxGnu/grocksdb v1.8.14 // indirect github.com/manifoldco/promptui v0.9.0 // indirect github.com/mattn/go-colorable v0.1.13 // indirect - github.com/matttproud/golang_protobuf_extensions/v2 v2.0.0 // 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/oasisprotocol/curve25519-voi v0.0.0-20230904125328-1f23a7beb09a // indirect github.com/oklog/run v1.1.0 // indirect @@ -210,34 +222,41 @@ require ( 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/rogpeppe/go-internal v1.11.0 // indirect - github.com/rs/zerolog v1.31.0 // indirect + github.com/rogpeppe/go-internal v1.12.0 // indirect + github.com/rs/zerolog v1.32.0 // indirect github.com/sagikazarmark/locafero v0.4.0 // indirect github.com/sagikazarmark/slog-shim v0.1.0 // indirect github.com/sirupsen/logrus v1.9.0 // indirect github.com/sourcegraph/conc v0.3.0 // indirect + github.com/strangelove-ventures/cometbft-client v0.1.0 // indirect + github.com/stretchr/objx v0.5.2 // indirect github.com/tidwall/btree v1.7.0 // indirect + github.com/tyler-smith/go-bip39 v1.1.0 // indirect github.com/ulikunitz/xz v0.5.11 // indirect github.com/xeipuuv/gojsonpointer v0.0.0-20190905194746-02993c407bfb // indirect github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415 // indirect github.com/xeipuuv/gojsonschema v1.2.0 // indirect github.com/zondax/ledger-go v0.14.3 // indirect go.opencensus.io v0.24.0 // indirect + go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.47.0 // indirect + go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.47.0 // indirect + go.opentelemetry.io/otel v1.22.0 // indirect + go.opentelemetry.io/otel/metric v1.22.0 // indirect + go.opentelemetry.io/otel/trace v1.22.0 // indirect go.uber.org/multierr v1.11.0 // indirect - golang.org/x/exp v0.0.0-20231006140011-7918f672742d // indirect - golang.org/x/mod v0.13.0 // indirect - golang.org/x/net v0.20.0 // indirect - golang.org/x/oauth2 v0.15.0 // indirect - golang.org/x/sync v0.5.0 // indirect + golang.org/x/mod v0.17.0 // indirect + golang.org/x/net v0.24.0 // indirect + golang.org/x/oauth2 v0.18.0 // indirect + golang.org/x/sync v0.7.0 // indirect golang.org/x/time v0.5.0 // indirect - golang.org/x/tools v0.14.0 // indirect - golang.org/x/xerrors v0.0.0-20220907171357-04be3eba64a2 // indirect - google.golang.org/api v0.153.0 // indirect + golang.org/x/tools v0.20.0 // indirect + google.golang.org/api v0.162.0 // indirect google.golang.org/appengine v1.6.8 // indirect - google.golang.org/genproto/googleapis/rpc v0.0.0-20231212172506-995d672761c0 // indirect + google.golang.org/genproto/googleapis/rpc v0.0.0-20240401170217-c3f982113cda // indirect gopkg.in/yaml.v3 v3.0.1 // indirect gotest.tools/v3 v3.5.1 // indirect pgregory.net/rapid v1.1.0 // indirect + rsc.io/tmplfunc v0.0.3 // indirect sigs.k8s.io/yaml v1.4.0 // indirect ) @@ -250,6 +269,8 @@ replace ( // 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 + // Downgraded to stable version see: https://github.com/cosmos/cosmos-sdk/pull/14952 github.com/syndtr/goleveldb => github.com/syndtr/goleveldb v1.0.1-0.20210819022825-2ae1ddf74ef7 ) diff --git a/go.sum b/go.sum index 474d59744..8dfff70fa 100644 --- a/go.sum +++ b/go.sum @@ -30,8 +30,8 @@ cloud.google.com/go v0.100.2/go.mod h1:4Xra9TjzAeYHrl5+oeLlzbM2k3mjVhZh4UqTZ//w9 cloud.google.com/go v0.102.0/go.mod h1:oWcCzKlqJ5zgHQt9YsaeTY9KzIvjyy0ArmiBUgpQ+nc= cloud.google.com/go v0.102.1/go.mod h1:XZ77E9qnTEnrgEOvr4xzfdX5TRo7fB4T2F4O6+34hIU= cloud.google.com/go v0.104.0/go.mod h1:OO6xxXdJyvuJPcEPBLN9BJPD+jep5G1+2U5B5gkRYtA= -cloud.google.com/go v0.110.10 h1:LXy9GEO+timppncPIAZoOj3l58LIU9k+kn48AN7IO3Y= -cloud.google.com/go v0.110.10/go.mod h1:v1OoFqYxiBkUrruItNM3eT4lLByNjxmJSV/xDKJNnic= +cloud.google.com/go v0.112.0 h1:tpFCD7hpHFlQ8yPwT3x+QeXqc2T6+n6T+hmABHfDUSM= +cloud.google.com/go v0.112.0/go.mod h1:3jEEVwZ/MHU4djK5t5RHuKOA/GbLddgTdVubX1qnPD4= cloud.google.com/go/aiplatform v1.22.0/go.mod h1:ig5Nct50bZlzV6NvKaTwmplLLddFx0YReh9WfTO5jKw= cloud.google.com/go/aiplatform v1.24.0/go.mod h1:67UUvRBKG6GTayHKV8DBv2RtR1t93YRu5B1P3x99mYY= cloud.google.com/go/analytics v0.11.0/go.mod h1:DjEWCu41bVbYcKyvlws9Er60YE4a//bK6mnhWvQeFNI= @@ -68,8 +68,8 @@ cloud.google.com/go/compute v1.6.0/go.mod h1:T29tfhtVbq1wvAPo0E3+7vhgmkOYeXjhFvz cloud.google.com/go/compute v1.6.1/go.mod h1:g85FgpzFvNULZ+S8AYq87axRKuf2Kh7deLqV/jJ3thU= cloud.google.com/go/compute v1.7.0/go.mod h1:435lt8av5oL9P3fv1OEzSbSUe+ybHXGMPQHHZWZxy9U= cloud.google.com/go/compute v1.10.0/go.mod h1:ER5CLbMxl90o2jtNbGSbtfOpQKR0t15FOtRsugnLrlU= -cloud.google.com/go/compute v1.23.3 h1:6sVlXXBmbd7jNX0Ipq0trII3e4n1/MsADLK6a+aiVlk= -cloud.google.com/go/compute v1.23.3/go.mod h1:VCgBUoMnIVIR0CscqQiPJLAG25E3ZRZMzcFZeQ+h8CI= +cloud.google.com/go/compute v1.24.0 h1:phWcR2eWzRJaL/kOiJwfFsPs4BaKq1j6vnpZrc1YlVg= +cloud.google.com/go/compute v1.24.0/go.mod h1:kw1/T+h/+tK2LJK0wiPPx1intgdAM3j/g3hFDlscY40= cloud.google.com/go/compute/metadata v0.2.3 h1:mg4jlk7mCAj6xXp9UJ4fjI9VUI5rubuGBW5aJ7UnBMY= cloud.google.com/go/compute/metadata v0.2.3/go.mod h1:VAV5nSsACxMJvgaAuX6Pk2AawlZn8kiOGuCv6gTkwuA= cloud.google.com/go/containeranalysis v0.5.1/go.mod h1:1D92jd8gRR/c0fGMlymRgxWD3Qw9C1ff6/T7mLgVL8I= @@ -109,8 +109,8 @@ cloud.google.com/go/gkehub v0.10.0/go.mod h1:UIPwxI0DsrpsVoWpLB0stwKCP+WFVG9+y97 cloud.google.com/go/grafeas v0.2.0/go.mod h1:KhxgtF2hb0P191HlY5besjYm6MqTSTj3LSI+M+ByZHc= cloud.google.com/go/iam v0.3.0/go.mod h1:XzJPvDayI+9zsASAFO68Hk07u3z+f+JrT2xXNdp4bnY= cloud.google.com/go/iam v0.5.0/go.mod h1:wPU9Vt0P4UmCux7mqtRu6jcpPAb74cP1fh50J3QpkUc= -cloud.google.com/go/iam v1.1.5 h1:1jTsCu4bcsNsE4iiqNT5SHwrDRCfRmIaaaVFhRveTJI= -cloud.google.com/go/iam v1.1.5/go.mod h1:rB6P/Ic3mykPbFio+vo7403drjlgvoWfYpJhMXEbzv8= +cloud.google.com/go/iam v1.1.6 h1:bEa06k05IO4f4uJonbB5iAgKTPpABy1ayxaIZV/GHVc= +cloud.google.com/go/iam v1.1.6/go.mod h1:O0zxdPeGBoFdWW3HWmBxJsk0pfvNM/p/qa82rWOGTwI= cloud.google.com/go/language v1.4.0/go.mod h1:F9dRpNFQmJbkaop6g0JhSBXCNlO90e1KWx5iDdxbWic= cloud.google.com/go/language v1.6.0/go.mod h1:6dJ8t3B+lUYfStgls25GusK04NLh3eDLQnWM3mdEbhI= cloud.google.com/go/lifesciences v0.5.0/go.mod h1:3oIKy8ycWGPUyZDR/8RNnTOYevhaMLqh5vLUXs9zvT8= @@ -171,8 +171,8 @@ cloud.google.com/go/storage v1.10.0/go.mod h1:FLPqc6j+Ki4BU591ie1oL6qBQGu2Bl/tZ9 cloud.google.com/go/storage v1.22.1/go.mod h1:S8N1cAStu7BOeFfE8KAQzmyyLkK8p/vmRq6kuBTW58Y= cloud.google.com/go/storage v1.23.0/go.mod h1:vOEEDNFnciUMhBeT6hsJIn3ieU5cFRmzeLgDvXzfIXc= cloud.google.com/go/storage v1.27.0/go.mod h1:x9DOL8TK/ygDUMieqwfhdpQryTeEkhGKMi80i/iqR2s= -cloud.google.com/go/storage v1.35.1 h1:B59ahL//eDfx2IIKFBeT5Atm9wnNmj3+8xG/W4WB//w= -cloud.google.com/go/storage v1.35.1/go.mod h1:M6M/3V/D3KpzMTJyPOR/HU6n2Si5QdaXYEsng2xgOs8= +cloud.google.com/go/storage v1.36.0 h1:P0mOkAcaJxhCTvAkMhxMfrTKiNcub4YmmPBtlhAyTr8= +cloud.google.com/go/storage v1.36.0/go.mod h1:M6M/3V/D3KpzMTJyPOR/HU6n2Si5QdaXYEsng2xgOs8= cloud.google.com/go/talent v1.1.0/go.mod h1:Vl4pt9jiHKvOgF9KoZo6Kob9oV4lwd/ZD5Cto54zDRw= cloud.google.com/go/talent v1.2.0/go.mod h1:MoNF9bhFQbiJ6eFD3uSsg0uBALw4n4gaCaEjBw9zo8g= cloud.google.com/go/videointelligence v1.6.0/go.mod h1:w0DIDlVRKtwPCn/C4iwZIJdvC69yInhW0cfi+p546uU= @@ -184,8 +184,8 @@ cloud.google.com/go/webrisk v1.4.0/go.mod h1:Hn8X6Zr+ziE2aNd8SliSDWpEnSS1u4R9+xX cloud.google.com/go/webrisk v1.5.0/go.mod h1:iPG6fr52Tv7sGk0H6qUFzmL3HHZev1htXuWDEEsqMTg= cloud.google.com/go/workflows v1.6.0/go.mod h1:6t9F5h/unJz41YqfBmqSASJSXccBLtD1Vwf+KmJENM0= cloud.google.com/go/workflows v1.7.0/go.mod h1:JhSrZuVZWuiDfKEFxU0/F1PQjmpnpcoISEXH2bcHC3M= -cosmossdk.io/api v0.7.2 h1:BO3i5fvKMKvfaUiMkCznxViuBEfyWA/k6w2eAF6q1C4= -cosmossdk.io/api v0.7.2/go.mod h1:IcxpYS5fMemZGqyYtErK7OqvdM0C8kdW3dq8Q/XIG38= +cosmossdk.io/api v0.7.4 h1:sPo8wKwCty1lht8kgL3J7YL1voJywP3YWuA5JKkBz30= +cosmossdk.io/api v0.7.4/go.mod h1:IcxpYS5fMemZGqyYtErK7OqvdM0C8kdW3dq8Q/XIG38= cosmossdk.io/client/v2 v2.0.0-beta.1 h1:XkHh1lhrLYIT9zKl7cIOXUXg2hdhtjTPBUfqERNA1/Q= cosmossdk.io/client/v2 v2.0.0-beta.1/go.mod h1:JEUSu9moNZQ4kU3ir1DKD5eU4bllmAexrGWjmb9k8qU= cosmossdk.io/collections v0.4.0 h1:PFmwj2W8szgpD5nOd8GWH6AbYNi1f2J6akWXJ7P5t9s= @@ -196,14 +196,14 @@ cosmossdk.io/depinject v1.0.0-alpha.4 h1:PLNp8ZYAMPTUKyG9IK2hsbciDWqna2z1Wsl98ok cosmossdk.io/depinject v1.0.0-alpha.4/go.mod h1:HeDk7IkR5ckZ3lMGs/o91AVUc7E596vMaOmslGFM3yU= 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.0 h1:L0Z0XstClo2kOU4h3V1iDoE5Ji64sg5HLOogzGg67Oo= -cosmossdk.io/log v1.3.0/go.mod h1:HIDyvWLqZe2ovlWabsDN4aPMpY/nUEquAhgfTf2ZzB8= -cosmossdk.io/math v1.2.0 h1:8gudhTkkD3NxOP2YyyJIYYmt6dQ55ZfJkDOaxXpy7Ig= -cosmossdk.io/math v1.2.0/go.mod h1:l2Gnda87F0su8a/7FEKJfFdJrM0JZRXQaohlgJeyQh0= -cosmossdk.io/store v1.0.2 h1:lSg5BTvJBHUDwswNNyeh4K/CbqiHER73VU4nDNb8uk0= -cosmossdk.io/store v1.0.2/go.mod h1:EFtENTqVTuWwitGW1VwaBct+yDagk7oG/axBMPH+FXs= -cosmossdk.io/tools/confix v0.1.0 h1:2OOZTtQsDT5e7P3FM5xqM0bPfluAxZlAwxqaDmYBE+E= -cosmossdk.io/tools/confix v0.1.0/go.mod h1:TdXKVYs4gEayav5wM+JHT+kTU2J7fozFNqoVaN+8CdY= +cosmossdk.io/log v1.3.1 h1:UZx8nWIkfbbNEWusZqzAx3ZGvu54TZacWib3EzUYmGI= +cosmossdk.io/log v1.3.1/go.mod h1:2/dIomt8mKdk6vl3OWJcPk2be3pGOS8OQaLUM/3/tCM= +cosmossdk.io/math v1.3.0 h1:RC+jryuKeytIiictDslBP9i1fhkVm6ZDmZEoNP316zE= +cosmossdk.io/math v1.3.0/go.mod h1:vnRTxewy+M7BtXBNFybkuhSH4WfedVAAnERHgVFhp3k= +cosmossdk.io/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/x/evidence v0.1.0 h1:J6OEyDl1rbykksdGynzPKG5R/zm6TacwW2fbLTW4nCk= @@ -212,10 +212,10 @@ cosmossdk.io/x/feegrant v0.1.0 h1:c7s3oAq/8/UO0EiN1H5BIjwVntujVTkYs35YPvvrdQk= cosmossdk.io/x/feegrant v0.1.0/go.mod h1:4r+FsViJRpcZif/yhTn+E0E6OFfg4n0Lx+6cCtnZElU= 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/tx v0.13.0 h1:8lzyOh3zONPpZv2uTcUmsv0WTXy6T1/aCVDCqShmpzU= -cosmossdk.io/x/tx v0.13.0/go.mod h1:CpNQtmoqbXa33/DVxWQNx5Dcnbkv2xGUhL7tYQ5wUsY= -cosmossdk.io/x/upgrade v0.1.0 h1:z1ZZG4UL9ICTNbJDYZ6jOnF9GdEK9wyoEFi4BUScHXE= -cosmossdk.io/x/upgrade v0.1.0/go.mod h1:/6jjNGbiPCNtmA1N+rBtP601sr0g4ZXuj3yC6ClPCGY= +cosmossdk.io/x/tx v0.13.3 h1:Ha4mNaHmxBc6RMun9aKuqul8yHiL78EKJQ8g23Zf73g= +cosmossdk.io/x/tx v0.13.3/go.mod h1:I8xaHv0rhUdIvIdptKIqzYy27+n2+zBVaxO6fscFhys= +cosmossdk.io/x/upgrade v0.1.1 h1:aoPe2gNvH+Gwt/Pgq3dOxxQVU3j5P6Xf+DaUJTDZATc= +cosmossdk.io/x/upgrade v0.1.1/go.mod h1:MNLptLPcIFK9CWt7Ra//8WUZAxweyRDNcbs5nkOcQy0= dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU= filippo.io/edwards25519 v1.0.0 h1:0wAIcmJUqRdI8IJ/3eGi5/HwXZWPujYXXlkrQogz0Ek= filippo.io/edwards25519 v1.0.0/go.mod h1:N1IkdkCkiLB6tki+MYJoSx2JTY9NUlxZE7eHn5EwJns= @@ -225,10 +225,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.50.0 h1:NVaGqCSTRfb9UTDHJwT6nQIWcb6VjlQl88iI+u1+qjE= -github.com/CosmWasm/wasmd v0.50.0/go.mod h1:UjmShW4l9YxaMytwJZ7IB7MWzHiynSZP3DdWrG0FRtk= -github.com/CosmWasm/wasmvm v1.5.2 h1:+pKB1Mz9GZVt1vadxB+EDdD1FOz3dMNjIKq/58/lrag= -github.com/CosmWasm/wasmvm v1.5.2/go.mod h1:Q0bSEtlktzh7W2hhEaifrFp1Erx11ckQZmjq8FLCyys= +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.1 h1:0YCQ7MKGNri7NFeRp75erPJXrqyCtH4gdc9jMstyMzk= +github.com/CosmWasm/wasmvm/v2 v2.0.1/go.mod h1:su9lg5qLr7adV95eOfzjZWkGiky8WNaNIHDr7Fpu7Ck= 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= @@ -242,6 +242,10 @@ 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= +github.com/StackExchange/wmi v1.2.1/go.mod h1:rcmrprowKIVzvc+NUiLncP2uuArMWLCbu9SBzvHz7e8= +github.com/VictoriaMetrics/fastcache v1.12.1 h1:i0mICQuojGDL3KblA7wUNlY5lOK6a4bwt3uRKnkZU40= +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= @@ -262,11 +266,13 @@ github.com/armon/consul-api v0.0.0-20180202201655-eb2c6b5be1b6/go.mod h1:grANhF5 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= +github.com/avast/retry-go/v4 v4.5.1 h1:AxIx0HGi4VZ3I02jr78j5lZ3M6x1E0Ivxa6b0pUUh7o= +github.com/avast/retry-go/v4 v4.5.1/go.mod h1:/sipNsvNB3RRuT5iNcb6h73nw3IBmXJ/H3XrCQYSOpc= github.com/aws/aws-lambda-go v1.13.3/go.mod h1:4UKl9IzQMoD+QF79YdCuzCwp8VbmG4VAQwij/eHl5CU= github.com/aws/aws-sdk-go v1.27.0/go.mod h1:KmX6BPdI08NWTb3/sm4ZGu5ShLoqVDhKgpiN924inxo= github.com/aws/aws-sdk-go v1.44.122/go.mod h1:y4AeaBuwd2Lk+GepC1E9v0qOiTws0MIWAX4oIKwKHZo= -github.com/aws/aws-sdk-go v1.44.224 h1:09CiaaF35nRmxrzWZ2uRq5v6Ghg/d2RiPjZnSgtt+RQ= -github.com/aws/aws-sdk-go v1.44.224/go.mod h1:aVsgQcEevwlmQ7qHE9I3h+dtQgpqhFB+i8Phjh7fkwI= +github.com/aws/aws-sdk-go v1.44.312 h1:llrElfzeqG/YOLFFKjg1xNpZCFJ2xraIi3PqSuP+95k= +github.com/aws/aws-sdk-go v1.44.312/go.mod h1:aVsgQcEevwlmQ7qHE9I3h+dtQgpqhFB+i8Phjh7fkwI= github.com/aws/aws-sdk-go-v2 v0.18.0/go.mod h1:JWVYvqSMppoMJC0x5wdwiImzgXTI9FuZwxzkQq9wy+g= github.com/benbjohnson/clock v1.1.0/go.mod h1:J11/hYXuz8f4ySSvYwY0FKfm+ezbsZBKZxNJlLklBHA= github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q= @@ -278,15 +284,15 @@ github.com/bgentry/go-netrc v0.0.0-20140422174119-9fd32a8b3d3d/go.mod h1:6QX/PXZ github.com/bgentry/speakeasy v0.1.0/go.mod h1:+zsyZBPWlz7T6j88CTgSN5bM796AkVf0kBD4zp0CCIs= github.com/bgentry/speakeasy v0.1.1-0.20220910012023-760eaf8b6816 h1:41iFGWnSlI2gVpmOtVTJZNodLdLQLn/KsJqFvXwnd/s= github.com/bgentry/speakeasy v0.1.1-0.20220910012023-760eaf8b6816/go.mod h1:+zsyZBPWlz7T6j88CTgSN5bM796AkVf0kBD4zp0CCIs= -github.com/bits-and-blooms/bitset v1.8.0 h1:FD+XqgOZDUxxZ8hzoBFuV9+cGWY9CslN6d5MS5JVb4c= -github.com/bits-and-blooms/bitset v1.8.0/go.mod h1:7hO7Gc7Pp1vODcmWvKMRA9BNmbv6a/7QIWpPxHddWR8= +github.com/bits-and-blooms/bitset v1.10.0 h1:ePXTeiPEazB5+opbv5fr8umg2R/1NlzgDsyepwsSr88= +github.com/bits-and-blooms/bitset v1.10.0/go.mod h1:7hO7Gc7Pp1vODcmWvKMRA9BNmbv6a/7QIWpPxHddWR8= github.com/boljen/go-bitmap v0.0.0-20151001105940-23cd2fb0ce7d h1:zsO4lp+bjv5XvPTF58Vq+qgmZEYZttJK+CWtSZhKenI= github.com/boljen/go-bitmap v0.0.0-20151001105940-23cd2fb0ce7d/go.mod h1:f1iKL6ZhUWvbk7PdWVmOaak10o86cqMUYEmn1CZNGEI= github.com/btcsuite/btcd v0.20.1-beta/go.mod h1:wVuoA8VJLEcwgqHBwHmzLRazpKxTv13Px/pDuV7OomQ= github.com/btcsuite/btcd v0.22.0-beta.0.20220111032746-97732e52810c/go.mod h1:tjmYdS6MLJ5/s0Fj4DbLgSbDHbEqLJrtnHecBFkdz5M= github.com/btcsuite/btcd v0.23.5-0.20231215221805-96c9fd8078fd/go.mod h1:nm3Bko6zh6bWP60UxwoT5LzdGJsQJaPo6HjduXq9p6A= -github.com/btcsuite/btcd v0.24.0 h1:gL3uHE/IaFj6fcZSu03SvqPMSx7s/dPzfpG/atRwWdo= -github.com/btcsuite/btcd v0.24.0/go.mod h1:K4IDc1593s8jKXIF7yS7yCTSxrknB9z0STzc2j6XgE4= +github.com/btcsuite/btcd v0.24.2 h1:aLmxPguqxza+4ag8R1I2nnJjSu2iFn/kqtHTIImswcY= +github.com/btcsuite/btcd v0.24.2/go.mod h1:5C8ChTkl5ejr3WHj8tkQSCmydiMEPB0ZhQhehpq7Dgg= github.com/btcsuite/btcd/btcec/v2 v2.1.0/go.mod h1:2VzYrv4Gm4apmbVVsSq5bqf1Ec8v56E48Vt0Y/umPgA= github.com/btcsuite/btcd/btcec/v2 v2.1.3/go.mod h1:ctjw4H1kknNJmRN4iP1R7bTQ+v3GJkZBd6mui8ZsAZE= github.com/btcsuite/btcd/btcec/v2 v2.3.2 h1:5n0X6hX0Zk+6omWcihdYvdAlGf2DfasC0GMf7DClJ3U= @@ -324,8 +330,8 @@ github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA 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 h1:DC2CZ1Ep5Y4k3ZQ899DldepgrayRUGE6BBZ/cd9Cj44= -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= @@ -354,6 +360,8 @@ github.com/cncf/xds/go v0.0.0-20210805033703-aa0b78936158/go.mod h1:eXthEFrGJvWH github.com/cncf/xds/go v0.0.0-20210922020428-25de7278fc84/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs= github.com/cncf/xds/go v0.0.0-20211001041855-01bcc9b48dfe/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs= github.com/cncf/xds/go v0.0.0-20211011173535-cb28da3451f1/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs= +github.com/cncf/xds/go v0.0.0-20231128003011-0fa0005c9caa h1:jQCWAUqqlij9Pgj2i/PB79y4KOPYVyFYdROxgaCwdTQ= +github.com/cncf/xds/go v0.0.0-20231128003011-0fa0005c9caa/go.mod h1:x/1Gn8zydmfq8dk6e9PdstVsDgu9RuyIIJqAaF//0IM= github.com/cockroachdb/apd/v2 v2.0.2 h1:weh8u7Cneje73dDh+2tEVLUvyBc89iwepWCD8b8034E= github.com/cockroachdb/apd/v2 v2.0.2/go.mod h1:DDxRlzC2lo3/vSlmSoS7JkqbbrARPuFOGr0B9pvN3Gw= github.com/cockroachdb/datadriven v0.0.0-20190809214429-80d97fb3cbaa/go.mod h1:zn76sxSg3SzpJ0PPJaLDCu+Bu0Lg3sKTORVIj19EIF8= @@ -363,17 +371,21 @@ github.com/cockroachdb/errors v1.11.1 h1:xSEW75zKaKCWzR3OfxXUxgrk/NtT4G1MiOv5lWZ github.com/cockroachdb/errors v1.11.1/go.mod h1:8MUxA3Gi6b25tYlFEBGLf+D8aISL+M4MIpiWMSNRfxw= github.com/cockroachdb/logtags v0.0.0-20230118201751-21c54148d20b h1:r6VH0faHjZeQy818SGhaone5OnYfxFR/+AzdY3sf5aE= github.com/cockroachdb/logtags v0.0.0-20230118201751-21c54148d20b/go.mod h1:Vz9DsVWQQhf3vs21MhPMZpMGSht7O/2vFW2xusFUVOs= -github.com/cockroachdb/pebble v0.0.0-20231102162011-844f0582c2eb h1:6Po+YYKT5B5ZXN0wd2rwFBaebM0LufPf8p4zxOd48Kg= -github.com/cockroachdb/pebble v0.0.0-20231102162011-844f0582c2eb/go.mod h1:acMRUGd/BK8AUmQNK3spUCCGzFLZU2bSST3NMXSq2Kc= +github.com/cockroachdb/pebble v1.1.0 h1:pcFh8CdCIt2kmEpK0OIatq67Ln9uGDYY3d5XnE0LJG4= +github.com/cockroachdb/pebble v1.1.0/go.mod h1:sEHm5NOXxyiAoKWhoFxT8xMgd/f3RA6qUqQ1BXKrh2E= github.com/cockroachdb/redact v1.1.5 h1:u1PMllDkdFfPWaNGMyLD1+so+aq3uUItthCFqzwPJ30= github.com/cockroachdb/redact v1.1.5/go.mod h1:BVNblN9mBWFyMyqK1k3AAiSxhvhfK2oOZZ2lK+dpvRg= github.com/cockroachdb/tokenbucket v0.0.0-20230807174530-cc333fc44b06 h1:zuQyyAKVxetITBuuhv3BI9cMrmStnpT18zmgmTxunpo= github.com/cockroachdb/tokenbucket v0.0.0-20230807174530-cc333fc44b06/go.mod h1:7nc4anLGjupUW/PeY5qiNYsdNXj7zopG+eqsS7To5IQ= github.com/codahale/hdrhistogram v0.0.0-20161010025455-3a0bb77429bd/go.mod h1:sE/e/2PUdi/liOCUjSTXgM1o87ZssimdTWN964YiIeI= -github.com/cometbft/cometbft v0.38.5 h1:4lOcK5VTPrfbLOhNHmPYe6c7eDXHtBdMCQuKbAfFJdU= -github.com/cometbft/cometbft v0.38.5/go.mod h1:0tqKin+KQs8zDwzYD8rPHzSBIDNPuB4NrwwGDNb/hUg= +github.com/cometbft/cometbft v0.38.7 h1:ULhIOJ9+LgSy6nLekhq9ae3juX3NnQUMMPyVdhZV6Hk= +github.com/cometbft/cometbft v0.38.7/go.mod h1:HIyf811dFMI73IE0F7RrnY/Fr+d1+HuJAgtkEpQjCMY= github.com/cometbft/cometbft-db v0.9.1 h1:MIhVX5ja5bXNHF8EYrThkG9F7r9kSfv8BX4LWaxWJ4M= github.com/cometbft/cometbft-db v0.9.1/go.mod h1:iliyWaoV0mRwBJoizElCwwRA9Tf7jZJOURcRZF9m60U= +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= @@ -386,34 +398,42 @@ github.com/coreos/go-systemd/v22 v22.5.0/go.mod h1:Y58oyj3AT4RCenI/lSvhwexgC+NSV 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= github.com/cosmos/btcutil v1.0.5/go.mod h1:IyB7iuqZMJlthe2tkIFL33xPyzbFYP0XVdS8P5lUPis= -github.com/cosmos/cosmos-db v1.0.0 h1:EVcQZ+qYag7W6uorBKFPvX6gRjw6Uq2hIh4hCWjuQ0E= -github.com/cosmos/cosmos-db v1.0.0/go.mod h1:iBvi1TtqaedwLdcrZVYRSSCb6eSy61NLj4UNmdIgs0U= -github.com/cosmos/cosmos-proto v1.0.0-beta.3 h1:VitvZ1lPORTVxkmF2fAp3IiA61xVwArQYKXTdEcpW6o= -github.com/cosmos/cosmos-proto v1.0.0-beta.3/go.mod h1:t8IASdLaAq+bbHbjq4p960BvcTqtwuAxid3b/2rOD6I= -github.com/cosmos/cosmos-sdk v0.50.4-0.20240126152601-c4a2fe2b8987 h1:Pjvcy7wHUoYh253LvNv5Dyx+d3SNkRPsDZH+FytqZ3w= -github.com/cosmos/cosmos-sdk v0.50.4-0.20240126152601-c4a2fe2b8987/go.mod h1:0D9mrUy1eAUMQuvYzf2xvhEPk2ta9w7XH1zcYvyFiuM= +github.com/cosmos/cosmos-db v1.0.2 h1:hwMjozuY1OlJs/uh6vddqnk9j7VamLv+0DBlbEXbAKs= +github.com/cosmos/cosmos-db v1.0.2/go.mod h1:Z8IXcFJ9PqKK6BIsVOB3QXtkKoqUOp1vRvPT39kOXEA= +github.com/cosmos/cosmos-proto v1.0.0-beta.5 h1:eNcayDLpip+zVLRLYafhzLvQlSmyab+RC5W7ZfmxJLA= +github.com/cosmos/cosmos-proto v1.0.0-beta.5/go.mod h1:hQGLpiIUloJBMdQMMWb/4wRApmI9hjHH05nefC0Ojec= +github.com/cosmos/cosmos-sdk v0.50.6 h1:efR3MsvMHX5sxS3be+hOobGk87IzlZbSpsI2x/Vw3hk= +github.com/cosmos/cosmos-sdk v0.50.6/go.mod h1:lVkRY6cdMJ0fG3gp8y4hFrsKZqF4z7y0M2UXFb9Yt40= github.com/cosmos/go-bip39 v1.0.0 h1:pcomnQdrdH22njcAatO0yWojsUnCO3y2tNoV1cb6hHY= github.com/cosmos/go-bip39 v1.0.0/go.mod h1:RNJv0H/pOIVgxw6KS7QeX2a0Uo0aKUlfhZ4xuwvCdJw= github.com/cosmos/gogogateway v1.2.0 h1:Ae/OivNhp8DqBi/sh2A8a1D0y638GpL3tkmLQAiKxTE= github.com/cosmos/gogogateway v1.2.0/go.mod h1:iQpLkGWxYcnCdz5iAdLcRBSw3h7NXeOkZ4GUkT+tbFI= github.com/cosmos/gogoproto v1.4.2/go.mod h1:cLxOsn1ljAHSV527CHOtaIP91kK6cCrZETRBrkzItWU= -github.com/cosmos/gogoproto v1.4.11 h1:LZcMHrx4FjUgrqQSWeaGC1v/TeuVFqSLa43CC6aWR2g= -github.com/cosmos/gogoproto v1.4.11/go.mod h1:/g39Mh8m17X8Q/GDEs5zYTSNaNnInBSohtaxzQnYq1Y= -github.com/cosmos/iavl v1.0.0 h1:bw6t0Mv/mVCJvlMTOPHWLs5uUE3BRBfVWCRelOzl+so= -github.com/cosmos/iavl v1.0.0/go.mod h1:CmTGqMnRnucjxbjduneZXT+0vPgNElYvdefjX2q9tYc= +github.com/cosmos/gogoproto v1.4.12 h1:vB6Lbe/rtnYGjQuFxkPiPYiCybqFT8QvLipDZP8JpFE= +github.com/cosmos/gogoproto v1.4.12/go.mod h1:LnZob1bXRdUoqMMtwYlcR3wjiElmlC+FkjaZRv1/eLY= +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/ibc-go/v8 v8.0.0 h1:QKipnr/NGwc+9L7NZipURvmSIu+nw9jOIWTJuDBqOhg= -github.com/cosmos/ibc-go/v8 v8.0.0/go.mod h1:C6IiJom0F3cIQCD5fKwVPDrDK9j/xTu563AWuOmXois= +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.0 h1:fdW2S7NjZYFhSwmCaFjjyDv80kI1ePOJDQmco4qrnD0= +github.com/cosmos/ibc-go/v8 v8.3.0/go.mod h1:izwHZvn9lKrBn8xWj0aXWut6HKcwHMPD3uyuvOJoPSA= 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/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/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= +github.com/crate-crypto/go-kzg-4844 v0.7.0/go.mod h1:1kMhvPgI0Ky3yIa+9lFySEBUBXkYxeOi8ZF1sYioxhc= github.com/creachadair/atomicfile v0.3.1 h1:yQORkHjSYySh/tv5th1dkKcn02NEW5JleB84sjt+W4Q= github.com/creachadair/atomicfile v0.3.1/go.mod h1:mwfrkRxFKwpNAflYZzytbSwxvbK6fdGRRlp0KEQc0qU= github.com/creachadair/tomledit v0.0.24 h1:5Xjr25R2esu1rKCbQEmjZYlrhFkDspoAbAKb6QKQDhQ= @@ -469,8 +489,8 @@ github.com/eapache/go-resiliency v1.1.0/go.mod h1:kFI+JgMyC7bLPUVY133qvEBtVayf5m github.com/eapache/go-xerial-snappy v0.0.0-20180814174437-776d5712da21/go.mod h1:+020luEh2TKB4/GOp8oxxtq0Daoen/Cii55CzbTV6DU= github.com/eapache/queue v1.1.0/go.mod h1:6eCeP0CKFpHLu8blIFXhExK/dRa7WDZfr6jVFPTqq+I= github.com/edsrzf/mmap-go v1.0.0/go.mod h1:YO35OhQPt3KJa3ryjFM5Bs14WD66h8eGKpfaBNrHW5M= -github.com/emicklei/dot v1.6.0 h1:vUzuoVE8ipzS7QkES4UfxdpCwdU2U97m2Pb2tQCoYRY= -github.com/emicklei/dot v1.6.0/go.mod h1:DeV7GvQtIw4h2u73RKBkkFdvVAz0D9fzeJrgPW6gy/s= +github.com/emicklei/dot v1.6.1 h1:ujpDlBkkwgWUY+qPId5IwapRW/xEoligRSYjioR6DFI= +github.com/emicklei/dot v1.6.1/go.mod h1:DeV7GvQtIw4h2u73RKBkkFdvVAz0D9fzeJrgPW6gy/s= github.com/envoyproxy/go-control-plane v0.6.9/go.mod h1:SBwIajubJHhxtWwsL9s8ss4safvEdbitLhGGK48rN6g= github.com/envoyproxy/go-control-plane v0.9.0/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= @@ -482,6 +502,12 @@ github.com/envoyproxy/go-control-plane v0.9.9-0.20210512163311-63b5d3c536b0/go.m github.com/envoyproxy/go-control-plane v0.9.10-0.20210907150352-cf90f659a021/go.mod h1:AFq3mo9L8Lqqiid3OhADV3RfLJnjiw63cSpi+fDTRC0= github.com/envoyproxy/go-control-plane v0.10.2-0.20220325020618-49ff273808a1/go.mod h1:KJwIaB5Mv44NWtYuAOFCVOjcI94vtpEz2JU/D2v6IjE= github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c= +github.com/envoyproxy/protoc-gen-validate v1.0.4 h1:gVPz/FMfvh57HdSJQyvBtF00j8JU4zdyUgIUNhlgg0A= +github.com/envoyproxy/protoc-gen-validate v1.0.4/go.mod h1:qys6tmnRsYrQqIhm2bvKZH4Blx/1gTIZ2UKVY1M+Yew= +github.com/ethereum/c-kzg-4844 v0.4.0 h1:3MS1s4JtA868KpJxroZoepdV0ZKBp3u/O5HcZ7R3nlY= +github.com/ethereum/c-kzg-4844 v0.4.0/go.mod h1:VewdlzQmpT5QSrVhbBuGoCdFJkpaJlO1aQputP83wc0= +github.com/ethereum/go-ethereum v1.13.14 h1:EwiY3FZP94derMCIam1iW4HFVrSgIcpsu0HwTQtm6CQ= +github.com/ethereum/go-ethereum v1.13.14/go.mod h1:TN8ZiHrdJwSe8Cb6x+p0hs5CxhJZPbqB7hHkaUXcmIU= github.com/fatih/color v1.7.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5KwzbycvMj4= github.com/fatih/color v1.13.0/go.mod h1:kLAiJbzzSOZDVNGyDpeOxJ47H46qBXwg5ILebYFFOfk= github.com/fatih/color v1.15.0 h1:kOqh6YHBtK8aywxGerMG2Eq3H6Qgoqeo13Bk2Mv/nBs= @@ -501,8 +527,10 @@ github.com/fsnotify/fsnotify v1.7.0 h1:8JEhPFa5W2WU7YfeZzPNqzMP6Lwt7L2715Ggo0nos 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/getsentry/sentry-go v0.25.0 h1:q6Eo+hS+yoJlTO3uu/azhQadsD8V+jQn2D8VvX1eOyI= -github.com/getsentry/sentry-go v0.25.0/go.mod h1:lc76E2QywIyW8WuBnwl8Lc4bkmQH4+w1gwTf25trprY= +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= +github.com/getsentry/sentry-go v0.27.0/go.mod h1:lc76E2QywIyW8WuBnwl8Lc4bkmQH4+w1gwTf25trprY= github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04= github.com/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= @@ -526,6 +554,13 @@ github.com/go-logfmt/logfmt v0.4.0/go.mod h1:3RMwSq7FuexP4Kalkev3ejPJsZTpXXBr9+V github.com/go-logfmt/logfmt v0.5.0/go.mod h1:wCYkCAKZfumFQihp8CzCvQ3paCTfi41vtzG1KdI/P7A= github.com/go-logfmt/logfmt v0.6.0 h1:wGYYu3uicYdqXVgoYbvnkrPVXkuLM1p1ifugDMEdRi4= github.com/go-logfmt/logfmt v0.6.0/go.mod h1:WYhtIu8zTZfxdn5+rREduYbwxfcBr/Vr6KEVveWlfTs= +github.com/go-logr/logr v1.2.2/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A= +github.com/go-logr/logr v1.4.1 h1:pKouT5E8xu9zeFC39JXRDukb6JFQPXM5p5I91188VAQ= +github.com/go-logr/logr v1.4.1/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY= +github.com/go-logr/stdr v1.2.2 h1:hSWxHoqTgW2S2qGc0LTAI563KZ5YKYRhT3MFKZMbjag= +github.com/go-logr/stdr v1.2.2/go.mod h1:mMo/vtBO5dYbehREoey6XUKy/eSumjCCveDpRre4VKE= +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-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= @@ -551,16 +586,12 @@ github.com/godbus/dbus v0.0.0-20190726142602-4481cbc300e2 h1:ZpnhV/YsD2/4cESfV5+ 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.1.0/go.mod h1:gf4bu3Q80BeJ6H1S1vYPm8/ELATdvryBaNFGgqEef3s= github.com/gogo/googleapis v1.4.1-0.20201022092350-68b0159b7869/go.mod h1:5YRNX2z1oM5gXdAkurHa942MDgEJyk02w4OecKY87+c= github.com/gogo/googleapis v1.4.1 h1:1Yx4Myt7BxzvUr5ldGSbwYiZG6t9wGBZ+8/fX3Wvtq0= github.com/gogo/googleapis v1.4.1/go.mod h1:2lpHqI5OcWCtVElxXnPt+s8oJvMpySlOyM6xDCrzib4= -github.com/gogo/protobuf v1.1.1/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ= -github.com/gogo/protobuf v1.2.0/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ= -github.com/gogo/protobuf v1.2.1/go.mod h1:hp+jE20tsWTFYpLwKvXlhS1hjn+gTNwPg2I6zVXpSg4= -github.com/gogo/protobuf v1.3.1/go.mod h1:SlYgWuQ5SjCEi6WLHjHCa1yvBfUnHcTbrrZtXPKa29o= -github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q= -github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q= github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q= github.com/golang/glog v1.2.0 h1:uCdmnmatrKCgMBlM4rMuJZWOkPDqdbZPnrMXDY4gI68= github.com/golang/glog v1.2.0/go.mod h1:6AhwSGph0fcJtXVM/PEHPqZlFeoLxhs7/t5UDAwmO+w= @@ -598,12 +629,13 @@ github.com/golang/protobuf v1.4.3/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk= github.com/golang/protobuf v1.5.1/go.mod h1:DopwsBzvsk0Fs44TXzsVbJyPhcCPeIwnvohx4u74HPM= github.com/golang/protobuf v1.5.2/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY= -github.com/golang/protobuf v1.5.3 h1:KhyjKVUg7Usr/dYsdSqoFveMYd5ko72D+zANwlG1mmg= -github.com/golang/protobuf v1.5.3/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY= +github.com/golang/protobuf v1.5.4 h1:i7eJL8qZTpSEXOPTxNKhASYpMn+8e5Q6AdndVa1dWek= +github.com/golang/protobuf v1.5.4/go.mod h1:lnTiLA8Wa4RWRcIUkrtSVa5nRhsEGBg48fD6rSs7xps= github.com/golang/snappy v0.0.0-20180518054509-2e65f85255db/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= github.com/golang/snappy v0.0.3/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= -github.com/golang/snappy v0.0.4 h1:yAGX7huGHXlcLOEtBnF4w7FQwA26wojNCwOYAEhLjQM= github.com/golang/snappy v0.0.4/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= +github.com/golang/snappy v0.0.5-0.20220116011046-fa5810519dcb h1:PBC98N2aIaM3XXiurYmW7fx4GZkL8feAMVq7nEjURHk= +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= @@ -657,11 +689,12 @@ github.com/google/s2a-go v0.1.7 h1:60BLSyTrOV4/haCDW4zb1guZItoSq8foHCXrAnjBo/o= github.com/google/s2a-go v0.1.7/go.mod h1:50CgR4k1jNlWBu4UfS4AcfhVe1r6pdZPygJ3R8F0Qdw= github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510 h1:El6M4kTTCOh6aBiKaUGG7oYTSPP8MxqL4YI3kZKwcP4= github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510/go.mod h1:pupxD2MaaD3pAXIBCelhxNneeOaAeabZDe5s4K6zSpQ= +github.com/google/subcommands v1.2.0/go.mod h1:ZjhPrFU+Olkh9WazFPsl27BQ4UPiG37m3yTrtFlrHVk= github.com/google/uuid v1.0.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/google/uuid v1.1.2/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= -github.com/google/uuid v1.4.0 h1:MtMxsa51/r9yyhkyLsVeVt0B+BGQZzpQiTQ4eHZ8bc4= -github.com/google/uuid v1.4.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= +github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0= +github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/googleapis/enterprise-certificate-proxy v0.0.0-20220520183353-fd19c99a87aa/go.mod h1:17drOmN3MwGY7t0e+Ei9b45FFGA3fBs3x36SsCg1hq8= github.com/googleapis/enterprise-certificate-proxy v0.1.0/go.mod h1:17drOmN3MwGY7t0e+Ei9b45FFGA3fBs3x36SsCg1hq8= github.com/googleapis/enterprise-certificate-proxy v0.2.0/go.mod h1:8C0jb7/mgJe/9KK8Lm7X9ctZC2t60YyIpYEI16jx0Qg= @@ -690,8 +723,9 @@ github.com/gorilla/mux v1.8.1 h1:TuBL49tXwgrFYWhqrNgrUNEY92u81SPhu7sTdzQEiWY= github.com/gorilla/mux v1.8.1/go.mod h1:AKf9I4AEqPTmMytcMc0KkNouC66V3BtZ4qD5fmWSiMQ= 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 h1:PPwGk2jz7EePpoHN/+ClbZu8SPxiqlu12wZP/3sWmnc= 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/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= @@ -709,15 +743,15 @@ 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.1 h1:SWiSWN/42qdpR0MdhaOc/bLR48PLuP1ZQtYLRlM69uY= -github.com/hashicorp/go-getter v1.7.1/go.mod h1:W7TalhMmbPmsSMdNjD0ZskARur/9GJ17cfHTRtXV744= +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-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= github.com/hashicorp/go-immutable-radix v1.3.1 h1:DKHmCUm2hRBK510BaiZlwvpD40f8bJFeZnpfm2KLowc= github.com/hashicorp/go-immutable-radix v1.3.1/go.mod h1:0y9vanUI8NX6FsYoO3zeMjhV/C5i9g4Q3DwcSNZ4P60= -github.com/hashicorp/go-metrics v0.5.1 h1:rfPwUqFU6uZXNvGl4hzjY8LEBsqFVU4si1H9/Hqck/U= -github.com/hashicorp/go-metrics v0.5.1/go.mod h1:KEjodfebIOuBYSAe/bHTm+HChmKSxAOXPBieMLYozDE= +github.com/hashicorp/go-metrics v0.5.3 h1:M5uADWMOGCTUNU1YuC4hfknOeHNaX54LDm4oYSucoNE= +github.com/hashicorp/go-metrics v0.5.3/go.mod h1:KEjodfebIOuBYSAe/bHTm+HChmKSxAOXPBieMLYozDE= github.com/hashicorp/go-msgpack v0.5.3/go.mod h1:ahLV/dePpqEmjfWmKiqvPkv/twdG7iPBM1vqhUKIvfM= github.com/hashicorp/go-multierror v1.0.0/go.mod h1:dHtQlpGsu+cZNNAkkCN/P3hoUDHhCYQXV3UM06sGGrk= github.com/hashicorp/go-plugin v1.5.2 h1:aWv8eimFqWlsEiMrYZdPYl+FdHaBJSN4AWwGWfT1G2Y= @@ -750,6 +784,10 @@ github.com/hashicorp/yamux v0.1.1 h1:yrQxtgseBDrq9Y652vSRDvsKCJKOUD+GzTS4Y0Y8pvE github.com/hashicorp/yamux v0.1.1/go.mod h1:CtWFDAQgb7dxtzFs4tWbplKIe2jSi3+5vKbgIO0SLnQ= github.com/hdevalence/ed25519consensus v0.1.0 h1:jtBwzzcHuTmFrQN6xQZn6CQEO/V9f7HsjsjeEZ6auqU= github.com/hdevalence/ed25519consensus v0.1.0/go.mod h1:w3BHWjwJbFU29IRHL1Iqkw3sus+7FctEyM4RqDxYNzo= +github.com/holiman/bloomfilter/v2 v2.0.3 h1:73e0e/V0tCydx14a0SCYS/EWCxgwLZ18CZcZKVu0fao= +github.com/holiman/bloomfilter/v2 v2.0.3/go.mod h1:zpoh+gs7qcpqrHr3dB55AMiJwo0iURXE7ZOP9L9hSkA= +github.com/holiman/uint256 v1.2.4 h1:jUc4Nk8fm9jZabQuqr2JzednajVmBpC+oiTiXZJEApU= +github.com/holiman/uint256 v1.2.4/go.mod h1:EOMSn4q6Nyt9P6efbI3bueV4e1b3dGlUCXeiRV4ng7E= github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU= github.com/huandu/go-assert v1.1.5 h1:fjemmA7sSfYHJD7CUqs9qTwwfdNAx7/j2/ZlHXzNB3c= github.com/huandu/go-assert v1.1.5/go.mod h1:yOLvuqZwmcHIC5rIzrBhT7D3Q9c3GFnd0JrPVhn/06U= @@ -793,12 +831,14 @@ github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnr github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo= github.com/jstemmer/go-junit-report v0.0.0-20190106144839-af01ea7f8024/go.mod h1:6v2b51hI/fHJwM22ozAgKL4VKDeJcHhJFhtBdhmNjmU= github.com/jstemmer/go-junit-report v0.9.1/go.mod h1:Brl9GWCQeLvo8nXZwPNNblvFj/XSXhF0NWZEnDohbsk= +github.com/jsternberg/zap-logfmt v1.3.0 h1:z1n1AOHVVydOOVuyphbOKyR4NICDQFiJMn1IK5hVQ5Y= +github.com/jsternberg/zap-logfmt v1.3.0/go.mod h1:N3DENp9WNmCZxvkBD/eReWwz1149BK6jEN9cQ4fNwZE= github.com/jtolds/gls v4.20.0+incompatible h1:xdiiI2gbIgH/gLH7ADydsJ1uDOEzR8yvV7C0MuV77Wo= github.com/jtolds/gls v4.20.0+incompatible/go.mod h1:QJZ7F/aHp+rZTRtaJ1ow/lLfFfVYBRgL+9YlvaHOwJU= +github.com/juju/fslock v0.0.0-20160525022230-4d5c94c67b4b h1:FQ7+9fxhyp82ks9vAuyPzG0/vVbWwMwLJ+P6yJI5FN8= +github.com/juju/fslock v0.0.0-20160525022230-4d5c94c67b4b/go.mod h1:HMcgvsgd0Fjj4XXDkbjdmlbI505rUPBs6WBMYg2pXks= github.com/julienschmidt/httprouter v1.2.0/go.mod h1:SYymIcj16QtmaHHD7aYtjjsJG7VTCxuUUipMqKk8s4w= github.com/julienschmidt/httprouter v1.3.0/go.mod h1:JR6WtHb+2LUe8TCKY3cZOxFyyO8IZAc4RVcycCCAKdM= -github.com/kisielk/errcheck v1.1.0/go.mod h1:EZBBE59ingxPouuu3KfxchcWSUPOHkagtvWXihfKN4Q= -github.com/kisielk/errcheck v1.2.0/go.mod h1:/BMXB+zMLi60iA8Vv6Ksmxu/1UDYcXs4uQLJ+jE2L00= github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8= github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= github.com/kkdai/bstream v0.0.0-20161212061736-f391b8402d23 h1:FOOIBWrEkLgmlgGfMuZT83xIwfPDxEI2OHu6xUmJMFE= @@ -807,8 +847,8 @@ github.com/klauspost/compress v1.10.3/go.mod h1:aoV0uJVorq1K+umq18yTdKaF57EivdYs 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.11/go.mod h1:QPwzmACJjUTFsnSHH934V6woptycfrDDJnH7hvFVbGM= -github.com/klauspost/compress v1.17.4 h1:Ej5ixsIri7BrIjBkRZLTo6ghwrEtHFk7ijlczPW4fZ4= -github.com/klauspost/compress v1.17.4/go.mod h1:/dCuZOvVtNoHsyb+cuJD3itjs3NbnF6KH9zAO4BDxPM= +github.com/klauspost/compress v1.17.7 h1:ehO88t2UGzQK66LMdE8tibEd1ErmzZjNEqWkjLAKQQg= +github.com/klauspost/compress v1.17.7/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= @@ -823,6 +863,10 @@ github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= +github.com/kylelemons/godebug v1.1.0 h1:RPNrshWIDI6G2gRW9EHilWtl7Z6Sb1BR0xunSBf0SNc= +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= @@ -831,8 +875,8 @@ github.com/libp2p/go-buffer-pool v0.1.0 h1:oK4mSFcQz7cTQIfqbe4MIj9gLW+mnanjyFtc6 github.com/libp2p/go-buffer-pool v0.1.0/go.mod h1:N+vh8gMqimBzdKkSMVuydVDq+UV5QTWy5HSiZacSbPg= 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.6 h1:O7I6SIGPrypf3f/gmrrLUBQDKfO8uOoYdWf4gLS06tc= -github.com/linxGnu/grocksdb v1.8.6/go.mod h1:xZCIb5Muw+nhbDK4Y5UJuOrin5MceOuiXkVUR7vp4WY= +github.com/linxGnu/grocksdb v1.8.14 h1:HTgyYalNwBSG/1qCQUIott44wU5b2Y9Kr3z7SK5OfGQ= +github.com/linxGnu/grocksdb v1.8.14/go.mod h1:QYiYypR2d4v63Wj1adOOfzglnoII0gLj3PNh4fZkcFA= github.com/lyft/protoc-gen-validate v0.0.13/go.mod h1:XbGvPuh87YZc5TdIa2/I4pLk0QoUACkjt2znoq26NVQ= github.com/magiconair/properties v1.8.0/go.mod h1:PppfXfuXeibc/6YijjN8zIbojt8czPbwD3XqdrwzmxQ= github.com/magiconair/properties v1.8.7 h1:IeQXZAiQcpL9mgcAe1Nu6cX9LLw6ExEHKjN0VQdvPDY= @@ -854,9 +898,9 @@ github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWE github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y= github.com/mattn/go-runewidth v0.0.2/go.mod h1:LwmH8dsx7+W8Uxz3IHJYH5QSwggIsqBzpuz5H//U1FU= github.com/mattn/go-runewidth v0.0.4/go.mod h1:LwmH8dsx7+W8Uxz3IHJYH5QSwggIsqBzpuz5H//U1FU= +github.com/mattn/go-runewidth v0.0.13 h1:lTGmDsbAYt5DmK6OnoV7EuIF1wEIFAcxld6ypU4OSgU= +github.com/mattn/go-runewidth v0.0.13/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w= github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0= -github.com/matttproud/golang_protobuf_extensions/v2 v2.0.0 h1:jWpvCLoY8Z/e3VKvlsiIGKtc+UG6U5vzxaoagmhXfyg= -github.com/matttproud/golang_protobuf_extensions/v2 v2.0.0/go.mod h1:QUyp042oQthUoa9bqDv0ER0wrtXnBruoNd7aNjkbP+k= github.com/miekg/dns v1.0.14/go.mod h1:W1PPwlIAgtquWBMBEV9nkV9Cazfe8ScdGz/Lj7v3Nrg= github.com/minio/highwayhash v1.0.2 h1:Aak5U0nElisjDCfPSG79Tgzkn2gl66NxOMspRrKnA/g= github.com/minio/highwayhash v1.0.2/go.mod h1:BQskDq+xkJ12lmlUUi7U0M5Swg3EWR+dLTk+kldvVxY= @@ -873,6 +917,9 @@ github.com/mitchellh/mapstructure v0.0.0-20160808181253-ca63d7c062ee/go.mod h1:F github.com/mitchellh/mapstructure v1.1.2/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y= github.com/mitchellh/mapstructure v1.5.0 h1:jeMsZIYE/09sWLaz43PL7Gy6RuMjD2eJVyuac5Z2hdY= github.com/mitchellh/mapstructure v1.5.0/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo= +github.com/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= @@ -908,6 +955,8 @@ github.com/oklog/run v1.0.0/go.mod h1:dlhp/R75TPv97u0XWUtDeV/lRKWPKSdTuV0TZvrmrQ github.com/oklog/run v1.1.0 h1:GEenZ1cK0+q0+wsJew9qUg/DyD8k3JzYsZAi5gYi2mA= github.com/oklog/run v1.1.0/go.mod h1:sVPdnTZT1zYwAJeCMu2Th4T21pA3FPOQRfWjQlk7DVU= github.com/olekukonko/tablewriter v0.0.0-20170122224234-a0225b3f23b5/go.mod h1:vsDQFd/mU46D+Z4whnwzcISnGGzXWMclvtLoiIKAKIo= +github.com/olekukonko/tablewriter v0.0.5 h1:P2Ga83D34wi1o9J6Wh1mRuqd4mF/x/lgBS7N7AbDhec= +github.com/olekukonko/tablewriter v0.0.5/go.mod h1:hPp6KlRPjbx+hW8ykQs1w3UBbZlj6HuIJcUGPhkA7kY= github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= github.com/onsi/ginkgo v1.7.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= github.com/onsi/ginkgo v1.12.1/go.mod h1:zj2OWP4+oCPe1qIXoGWkgMRwljMUYCdkwsT2108oapk= @@ -952,8 +1001,8 @@ github.com/pelletier/go-toml/v2 v2.1.0 h1:FnwAJ4oYMvbT/34k9zzHuZNrhlz48GB3/s6at6 github.com/pelletier/go-toml/v2 v2.1.0/go.mod h1:tJU2Z3ZkXwnxa4DPO899bsyIoywizdUvyaeZurnPPDc= 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-20230904192822-1876fd5063bc h1:8bQZVK1X6BJR/6nYUPxQEP+ReTsceJTKizeuwjWOPUA= -github.com/petermattis/goid v0.0.0-20230904192822-1876fd5063bc/go.mod h1:pxMtw7cyUw6B2bRH0ZBANSPg+AoSud1I1iyJHI69jH4= +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/pierrec/lz4 v1.0.2-0.20190131084431-473cd7ce01a1/go.mod h1:3/3N9NVKO0jef7pBehbT1qWhCMrIgbYNnFAZCqQ5LRc= github.com/pierrec/lz4 v2.0.5+incompatible/go.mod h1:pdkljMzZIN41W+lC3N2tnIh5sFi+IEE17M5jbnwPHcY= github.com/pingcap/errors v0.11.4 h1:lFuQV/oaUMGcD2tqt+01ROSmJs75VG1ToEOkZIZ4nE4= @@ -974,47 +1023,51 @@ 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.17.0 h1:rl2sfwZMtSthVU752MqfjQozy7blglC+1SOtjMAMh+Q= -github.com/prometheus/client_golang v1.17.0/go.mod h1:VeL+gMmOAxkS2IqfCq0ZmHSL+LjWfWDUmp1mBz9JgUY= +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_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= github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= github.com/prometheus/client_model v0.1.0/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= github.com/prometheus/client_model v0.2.0/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= -github.com/prometheus/client_model v0.5.0 h1:VQw1hfvPvk3Uv6Qf29VrPF32JB6rtbgI6cYPYQjL0Qw= -github.com/prometheus/client_model v0.5.0/go.mod h1:dTiFglRmd66nLR9Pv9f0mZi7B7fk5Pm3gvsjB5tr+kI= +github.com/prometheus/client_model v0.6.1 h1:ZKSh/rekM+n3CeS952MLRAdFwIKqeY8b62p8ais2e9E= +github.com/prometheus/client_model v0.6.1/go.mod h1:OrxVMOVHjw3lKMa8+x6HeMGkHMQyHDk9E3jmP2AmGiY= github.com/prometheus/common v0.2.0/go.mod h1:TNfzLD0ON7rHzMJeJkieUDPYmFC7Snx/y86RQel1bk4= github.com/prometheus/common v0.4.1/go.mod h1:TNfzLD0ON7rHzMJeJkieUDPYmFC7Snx/y86RQel1bk4= github.com/prometheus/common v0.7.0/go.mod h1:DjGbpBbp5NYNiECxcL/VnbXCCaQpKd3tt26CguLLsqA= 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.45.0 h1:2BGz0eBc2hdMDLnO/8n0jeB3oPrt2D08CekT0lneoxM= -github.com/prometheus/common v0.45.0/go.mod h1:YJmSTw9BoKxJplESWWxlbyttQR4uaEcGyv9MZjVOJsY= +github.com/prometheus/common v0.52.2 h1:LW8Vk7BccEdONfrJBDffQGRtpSzi5CQaRZGtboOO2ck= +github.com/prometheus/common v0.52.2/go.mod h1:lrWtQx+iDfn2mbH5GUzlH9TSHyfZpHkSiG1W7y3sF2Q= 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.12.0 h1:jluTpSng7V9hY0O2R9DzzJHYb2xULk9VTR1V1R/k6Bo= -github.com/prometheus/procfs v0.12.0/go.mod h1:pcuDEFsWDnvcgNzo4EEweacyhjeA9Zk3cnaOZAZEfOo= +github.com/prometheus/procfs v0.13.0 h1:GqzLlQyfsPbaEHaQkO7tbDlriv/4o5Hudv6OXHGKX7o= +github.com/prometheus/procfs v0.13.0/go.mod h1:cd4PFCR54QLnGKPaKGA6l+cfuNXtht43ZKY6tow0Y1g= 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= +github.com/regen-network/protobuf v1.3.3-alpha.regen.1 h1:OHEc+q5iIAXpqiqFKeLpu5NwTIkVXUs48vFMwzqpqY4= +github.com/regen-network/protobuf v1.3.3-alpha.regen.1/go.mod h1:2DjTFR1HhMQhiWC5sZ4OhQ3+NtdbZ6oBDKQwq5Ou+FI= +github.com/rivo/uniseg v0.2.0 h1:S1pD9weZBuJdFmowNwbpi7BJ8TNftyUImj/0WQi72jY= +github.com/rivo/uniseg v0.2.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc= github.com/rogpeppe/fastuuid v0.0.0-20150106093220-6724a57986af/go.mod h1:XWv6SoW27p1b0cqNHllgS5HIMJraePCO15w5zCzIWYg= github.com/rogpeppe/fastuuid v1.2.0/go.mod h1:jVj6XXZzXRy/MSR5jhDC/2q6DgLz+nrA6LYCDYWNEvQ= github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4= github.com/rogpeppe/go-internal v1.9.0/go.mod h1:WtVeX8xhTBvf0smdhujwtBcq4Qrzq/fJaraNFVN+nFs= -github.com/rogpeppe/go-internal v1.11.0 h1:cWPaGQEPrBb5/AsnsZesgZZ9yb1OQ+GOISoDNXVBh4M= -github.com/rogpeppe/go-internal v1.11.0/go.mod h1:ddIwULY96R17DhadqLgMfk9H9tvdUzkipdSkR5nkCZA= +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/xid v1.5.0/go.mod h1:trrq9SKmegXys3aeAKXMUTdJsYXVwGY3RLcfgqegfbg= -github.com/rs/zerolog v1.31.0 h1:FcTR3NnLWW+NnTwwhFWiJSZr4ECLpqCm6QsEnyvbV4A= -github.com/rs/zerolog v1.31.0/go.mod h1:/7mN4D5sKwJLZQ2b/znpjC3/GQWY/xaDXUM0kKWRHss= +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/russross/blackfriday/v2 v2.0.1/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= @@ -1028,6 +1081,8 @@ github.com/sasha-s/go-deadlock v0.3.1 h1:sqv7fDNShgjcaxkO0JNcOAlr8B9+cV5Ey/OB71e github.com/sasha-s/go-deadlock v0.3.1/go.mod h1:F73l+cr82YSh10GxyRI6qZiCgK64VaZjwesgfQ1/iLM= 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/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= github.com/sirupsen/logrus v1.2.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo= github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6MwdIuYE2rE= @@ -1065,14 +1120,17 @@ github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An 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/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= github.com/streadway/amqp v0.0.0-20190827072141-edfb9018d271/go.mod h1:AZpEONHx3DKn8O/DFsRAY58/XVQiIPMTMB1SddzLXVw= github.com/streadway/handy v0.0.0-20190108123426-d5acb3125c2a/go.mod h1:qNTQ5P5JnDBl6z3cMAg/SywNDC5ABu5ApDIw6lUbRmI= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw= -github.com/stretchr/objx v0.5.0 h1:1zr/of2m5FGMsad5YfcqgdqdWrIhu+EBEJRhR1U7z/c= github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo= +github.com/stretchr/objx v0.5.2 h1:xuMeJ0Sdp5ZMRXx/aWO6RZxdr3beISkG5/G/aIRr3pY= +github.com/stretchr/objx v0.5.2/go.mod h1:FRsXN1f5AsAjCGJKqEizvkpNtU+EGNCLh3NxZ/8L+MA= github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= @@ -1085,8 +1143,9 @@ github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO 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 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk= github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= +github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg= +github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= github.com/subosito/gotenv v1.6.0 h1:9NlTDc1FTs4qu0DDq7AEtTPNw6SVm7uBMsUCUjABIf8= github.com/subosito/gotenv v1.6.0/go.mod h1:Dk4QP5c2W3ibzajGcXpNraDfq2IrhjMIvMSWPKKo0FU= github.com/supranational/blst v0.3.11 h1:LyU6FolezeWAhvQk0k6O/d49jqgO52MSDDfYgbeoEm4= @@ -1098,10 +1157,16 @@ github.com/tendermint/go-amino v0.16.0 h1:GyhmgQKvqF82e2oZeuMSp9JTN0N09emoSZlb2l github.com/tendermint/go-amino v0.16.0/go.mod h1:TQU0M1i/ImAo+tYpZi73AU3V/dKeCoMC9Sphe2ZwGME= github.com/tidwall/btree v1.7.0 h1:L1fkJH/AuEh5zBnnBbmTwQ5Lt+bRJ5A8EWecslvo9iI= github.com/tidwall/btree v1.7.0/go.mod h1:twD9XRA5jj9VUQGELzDO4HPQTNJsoWWfYEL+EUQ2cKY= +github.com/tklauser/go-sysconf v0.3.12 h1:0QaGUFOdQaIVdPgfITYzaTegZvdCjmYO52cSFAEVmqU= +github.com/tklauser/go-sysconf v0.3.12/go.mod h1:Ho14jnntGE1fpdOqQEEaiKRpvIavV0hSfmBq8nJbHYI= +github.com/tklauser/numcpus v0.6.1 h1:ng9scYS7az0Bk4OZLvrNXNSAO2Pxr1XXRAPyjhIx+Fk= +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/codec v1.2.11 h1:BMaWp1Bb6fHwEtbplGBGJ498wD+LKlNSl25MjdZY4dU= github.com/ugorji/go/codec v1.2.11/go.mod h1:UNopzCgEMSXjBc6AOMqYvWC1ktqTAfzJZUZgYf6w6lg= @@ -1148,12 +1213,26 @@ go.opencensus.io v0.22.5/go.mod h1:5pWMHQbX5EPX2/62yrJeAkowc+lfs/XD7Uxpq3pI6kk= go.opencensus.io v0.23.0/go.mod h1:XItmlyltB5F7CS4xOC1DcqMoFqwtC6OG2xF7mCv7P7E= go.opencensus.io v0.24.0 h1:y73uSU6J157QMP2kn2r30vwW1A2W2WFwSCGnAVxeaD0= go.opencensus.io v0.24.0/go.mod h1:vNK8G9p7aAivkbmorf4v+7Hgx+Zs0yY+0fOtgBfjQKo= +go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.47.0 h1:UNQQKPfTDe1J81ViolILjTKPr9WetKW6uei2hFgJmFs= +go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.47.0/go.mod h1:r9vWsPS/3AQItv3OSlEJ/E4mbrhUbbw18meOjArPtKQ= +go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.47.0 h1:sv9kVfal0MK0wBMCOGr+HeJm9v803BkJxGrk2au7j08= +go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.47.0/go.mod h1:SK2UL73Zy1quvRPonmOmRDiWk1KBV3LyIeeIxcEApWw= +go.opentelemetry.io/otel v1.22.0 h1:xS7Ku+7yTFvDfDraDIJVpw7XPyuHlB9MCiqqX5mcJ6Y= +go.opentelemetry.io/otel v1.22.0/go.mod h1:eoV4iAi3Ea8LkAEI9+GFT44O6T/D0GWAVFyZVCC6pMI= +go.opentelemetry.io/otel/metric v1.22.0 h1:lypMQnGyJYeuYPhOM/bgjbFM6WE44W1/T45er4d8Hhg= +go.opentelemetry.io/otel/metric v1.22.0/go.mod h1:evJGjVpZv0mQ5QBRJoBF64yMuOf4xCWdXjK8pzFvliY= +go.opentelemetry.io/otel/sdk v1.21.0 h1:FTt8qirL1EysG6sTQRZ5TokkU8d0ugCj8htOgThZXQ8= +go.opentelemetry.io/otel/sdk v1.21.0/go.mod h1:Nna6Yv7PWTdgJHVRD9hIYywQBRx7pbox6nwBnZIxl/E= +go.opentelemetry.io/otel/trace v1.22.0 h1:Hg6pPujv0XG9QaVbGOBVHunyuLcCC3jN7WEhPx83XD0= +go.opentelemetry.io/otel/trace v1.22.0/go.mod h1:RbbHXVqKES9QhzZq/fE5UnOSILqRt40a21sPw2He1xo= go.opentelemetry.io/proto/otlp v0.7.0/go.mod h1:PqfVotwruBrMGOCsRd/89rSnXhoiJIqeYNgFYFoEGnI= go.uber.org/atomic v1.3.2/go.mod h1:gD2HeocX3+yG+ygLZcrzQJaqmWj9AIm7n08wl/qW/PE= go.uber.org/atomic v1.4.0/go.mod h1:gD2HeocX3+yG+ygLZcrzQJaqmWj9AIm7n08wl/qW/PE= go.uber.org/atomic v1.5.0/go.mod h1:sABNBOSYdrvTF6hTgEIbc7YasKWGhgEQZyfxyTvoXHQ= go.uber.org/atomic v1.7.0/go.mod h1:fEN4uk6kAWBTFdckzkM89CLk9XfWZrxpCo0nPH17wJc= go.uber.org/goleak v1.1.10/go.mod h1:8a7PlsEVH3e/a/GLqe5IIrQx6GzcnRmZEufDUTk4A7A= +go.uber.org/goleak v1.2.0 h1:xqgm/S+aQvhWFTtR0XK3Jvg7z8kGV8P4X14IzwN3Eqk= +go.uber.org/goleak v1.2.0/go.mod h1:XJYK+MuIchqpmGmUSAzotztawfKvYLUIgg7guXrwVUo= go.uber.org/multierr v1.1.0/go.mod h1:wR5kodmAFQ0UK8QlbwjlSNy0Z68gJhDJUG5sjR94q/0= go.uber.org/multierr v1.3.0/go.mod h1:VgVr7evmIr6uPjLBxg28wmKNXyqE9akIJ5XnfpiKl+4= go.uber.org/multierr v1.6.0/go.mod h1:cdWPpRnG4AhwMwsgIHip0KRBQjJy5kYEpYjJxpXp9iU= @@ -1163,6 +1242,8 @@ go.uber.org/tools v0.0.0-20190618225709-2cfd321de3ee/go.mod h1:vJERXedbb3MVM5f9E go.uber.org/zap v1.10.0/go.mod h1:vwi/ZaCAaUcBkycHslxD9B2zi4UTXhF60s6SWpuDF0Q= 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= @@ -1180,8 +1261,8 @@ golang.org/x/crypto v0.0.0-20200728195943-123391ffb6de/go.mod h1:LzIPMQfyMNhhGPh golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= golang.org/x/crypto v0.7.0/go.mod h1:pYwdfH91IfpZVANVyUOhSIPZaFoJGxTFbZhFTx+dXZU= golang.org/x/crypto v0.9.0/go.mod h1:yrmDGqONDYtNj3tH8X9dzUun2m2lzPa9ngI6/RUPGR0= -golang.org/x/crypto v0.18.0 h1:PGVlW0xEltQnzFZ55hkuX5+KLyrMYhHld1YHO4AKcdc= -golang.org/x/crypto v0.18.0/go.mod h1:R0j02AL6hcrfOiy9T4ZYp/rcWeMxM3L6QYxlOuEG1mg= +golang.org/x/crypto v0.23.0 h1:dIJU/v2J8Mdglj/8rJ6UUOM3Zc9zLZxVZwwxMooUSAI= +golang.org/x/crypto v0.23.0/go.mod h1:CKFgDieR+mRhux2Lsu27y0fO304Db0wZe70UKqHu0v8= golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190306152737-a1d7652674e8/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190510132918-efd6b22b2522/go.mod h1:ZjyILWgesfNpC6sMxTJOJm9Kp84zZh5NQWvqDGG3Qr8= @@ -1193,8 +1274,8 @@ golang.org/x/exp v0.0.0-20200119233911-0405dc783f0a/go.mod h1:2RIsYlXP63K8oxa1u0 golang.org/x/exp v0.0.0-20200207192155-f17229e696bd/go.mod h1:J/WKrq2StrnmMY6+EHIKF9dgMWnmCNThgcyBT1FY9mM= golang.org/x/exp v0.0.0-20200224162631-6cc2880d07d6/go.mod h1:3jZMyOhIsHpP37uCMkUooju7aAi5cS1Q23tOzKc+0MU= golang.org/x/exp v0.0.0-20200331195152-e8c3332aa8e5/go.mod h1:4M0jN8W1tt0AVLNr8HDosyJCDCDuyL9N9+3m7wDWgKw= -golang.org/x/exp v0.0.0-20231006140011-7918f672742d h1:jtJma62tbqLibJ5sFQz8bKtEM8rJBtfilJ2qTU199MI= -golang.org/x/exp v0.0.0-20231006140011-7918f672742d/go.mod h1:ldy0pHrwJyGW56pPQzzkH36rKxoZW1tw7ZJpeKx+hdo= +golang.org/x/exp v0.0.0-20240404231335-c0f41cb1a7a0 h1:985EYyeCOxTpcgOTJpflJUwOeEz0CQOdPt73OzpE9F8= +golang.org/x/exp v0.0.0-20240404231335-c0f41cb1a7a0/go.mod h1:/lliqkxwWAhPjf5oSOIJup2XcqJaw8RGS6k3TGEc7GI= golang.org/x/image v0.0.0-20190227222117-0694c2d4d067/go.mod h1:kZ7UVZpmo3dzQBMxlp+ypCbDeSB+sBbTgSJuh5dn5js= golang.org/x/image v0.0.0-20190802002840-cff245a6509b/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0= golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= @@ -1222,8 +1303,8 @@ golang.org/x/mod v0.4.1/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.4.2/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4= golang.org/x/mod v0.8.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs= -golang.org/x/mod v0.13.0 h1:I/DsJXRlw/8l/0c24sM9yb0T4z9liZTduXvdAWYiysY= -golang.org/x/mod v0.13.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c= +golang.org/x/mod v0.17.0 h1:zY54UmvipHiNd+pm+m0x9KhZ9hl1/7QNMyxXbc6ICqA= +golang.org/x/mod v0.17.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c= golang.org/x/net v0.0.0-20180719180050-a680a1efc54d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= @@ -1288,8 +1369,8 @@ golang.org/x/net v0.1.0/go.mod h1:Cx3nUiGt4eDBEyega/BKRp+/AlGL8hYe7U9odMt2Cco= golang.org/x/net v0.6.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs= golang.org/x/net v0.8.0/go.mod h1:QVkue5JL9kW//ek3r6jTKnTFis1tRmNAW2P1shuFdJc= golang.org/x/net v0.10.0/go.mod h1:0qNGK6F8kojg2nk9dLZ2mShWaEBan6FAoqfSigmmuDg= -golang.org/x/net v0.20.0 h1:aCL9BSgETF1k+blQaYUBx9hJ9LOGP3gAVemcZlf1Kpo= -golang.org/x/net v0.20.0/go.mod h1:z8BVo6PvndSri0LbOE3hAn0apkU+1YvI6E70E9jsnvY= +golang.org/x/net v0.24.0 h1:1PcaxkF854Fu3+lvBIx5SYn9wRlBzzcnHZSiaFFAb0w= +golang.org/x/net v0.24.0/go.mod h1:2Q7sJY5mzlzWjKtYUEXSlBWCdyaioyXzRB2RtU8KVE8= 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= @@ -1315,8 +1396,8 @@ golang.org/x/oauth2 v0.0.0-20220822191816-0ebed06d0094/go.mod h1:h4gKUeWbJ4rQPri golang.org/x/oauth2 v0.0.0-20220909003341-f21342109be1/go.mod h1:h4gKUeWbJ4rQPri7E0u6Gs4e9Ri2zaLxzw5DI5XGrYg= golang.org/x/oauth2 v0.0.0-20221014153046-6fdb5e3db783/go.mod h1:h4gKUeWbJ4rQPri7E0u6Gs4e9Ri2zaLxzw5DI5XGrYg= golang.org/x/oauth2 v0.1.0/go.mod h1:G9FE4dLTsbXUu90h/Pf85g4w1D+SSAgR+q46nJZ8M4A= -golang.org/x/oauth2 v0.15.0 h1:s8pnnxNVzjWyrvYdFUQq5llS1PX2zhPXmccZv99h7uQ= -golang.org/x/oauth2 v0.15.0/go.mod h1:q48ptWNTY5XWf+JNten23lcvHpLJ0ZSxF5ttTHKVCAM= +golang.org/x/oauth2 v0.18.0 h1:09qnuIAgzdx1XplqJvW6CQqMCtGZykZWcXzPMPUusvI= +golang.org/x/oauth2 v0.18.0/go.mod h1:Wf7knwG0MPoWIMMBgFlEaSUDaKskp0dCfrlJRJXbBi8= 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= @@ -1332,8 +1413,8 @@ golang.org/x/sync v0.0.0-20220601150217-0de741cfad7f/go.mod h1:RxMgew5VJxzue5/jJ golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20220929204114-8fcdb60fdcc0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.1.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.5.0 h1:60k92dhOjHxJkrqnwsfl8KuaHbn/5dl0lUPUklKo3qE= -golang.org/x/sync v0.5.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= +golang.org/x/sync v0.7.0 h1:YsImfSBoP9QPYL0xyKJPq0gcaJdG3rInoqxTWbfQu9M= +golang.org/x/sync v0.7.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= golang.org/x/sys v0.0.0-20180823144017-11551d06cbcc/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= @@ -1440,16 +1521,16 @@ golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.8.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.12.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.16.0 h1:xWw16ngr6ZMtmxDyKyIgsE93KNKz5HKmMa3b8ALHidU= -golang.org/x/sys v0.16.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/sys v0.20.0 h1:Od9JTbYCk261bKm4M/mw7AklTlFYIa0bIp9BgSm1S8Y= +golang.org/x/sys v0.20.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= golang.org/x/term v0.5.0/go.mod h1:jMB1sMXY+tzblOD4FWmEbocvup2/aLOaQEp7JmGp78k= golang.org/x/term v0.6.0/go.mod h1:m6U89DPEgQRMq3DNkDClhWw02AUbt2daBVO4cn4Hv9U= golang.org/x/term v0.8.0/go.mod h1:xPskH00ivmX89bAKVGSKKtLOWNx2+17Eiy94tnKShWo= -golang.org/x/term v0.16.0 h1:m+B6fahuftsE9qjo0VWp2FW0mB3MTJvR0BaMQrq0pmE= -golang.org/x/term v0.16.0/go.mod h1:yn7UURbUtPyrVJPGPq404EukNFxcm/foM+bV/bfcDsY= +golang.org/x/term v0.20.0 h1:VnkxpohqXaOBYJtBmEppKUG6mXpi+4O6purfc2+sMhw= +golang.org/x/term v0.20.0/go.mod h1:8UkIAJTvZgivsXaD6/pH6U9ecQzZ45awqEOzuCvwpFY= 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= @@ -1464,18 +1545,16 @@ golang.org/x/text v0.4.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= golang.org/x/text v0.8.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8= golang.org/x/text v0.9.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8= -golang.org/x/text v0.14.0 h1:ScX5w1eTa3QqT8oi6+ziP7dTV1S2+ALU0bI+0zXKWiQ= -golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU= +golang.org/x/text v0.15.0 h1:h1V/4gjBv8v9cjcR6+AR5+/cIYK5N/WAgiv4xlsEtAk= +golang.org/x/text v0.15.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU= 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= golang.org/x/time v0.0.0-20191024005414-555d28b269f0/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.5.0 h1:o7cqy6amK/52YcAKIPlM3a+Fpj35zvRj2TP+e1xFSfk= golang.org/x/time v0.5.0/go.mod h1:3BpzKBy/shNhVucY/MWOyx10tF3SFh9QdLuxbVysPQM= -golang.org/x/tools v0.0.0-20180221164845-07fd8470d635/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20180828015842-6cd1fcedba52/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= -golang.org/x/tools v0.0.0-20181030221726-6c7e314b6563/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20190226205152-f727befe758c/go.mod h1:9Yl7xja0Znq3iFh3HoIrodX9oNMXvdceNzlUR8zjMvY= golang.org/x/tools v0.0.0-20190311212946-11955173bddd/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= @@ -1535,8 +1614,8 @@ golang.org/x/tools v0.1.4/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= golang.org/x/tools v0.1.5/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc= golang.org/x/tools v0.6.0/go.mod h1:Xwgl3UAJ/d3gWutnCtw505GrjyAbvKui8lOU390QaIU= -golang.org/x/tools v0.14.0 h1:jvNa2pY0M4r62jkRQ6RwEZZyPcymeL9XZMLBbV7U2nc= -golang.org/x/tools v0.14.0/go.mod h1:uYBEerGOWcJyEORxN+Ek8+TT266gXkNlHdJBwexUsBg= +golang.org/x/tools v0.20.0 h1:hz/CVckiOxybQvFw6h7b/q80NTr9IUQb4s1IIzW7KNY= +golang.org/x/tools v0.20.0/go.mod h1:WvitBU7JJf6A4jOdg4S1tviW9bhUxkgeCui/0JHctQg= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= @@ -1595,8 +1674,8 @@ google.golang.org/api v0.96.0/go.mod h1:w7wJQLTM+wvQpNf5JyEcBoxK0RH7EDrh/L4qfsuJ google.golang.org/api v0.97.0/go.mod h1:w7wJQLTM+wvQpNf5JyEcBoxK0RH7EDrh/L4qfsuJ13s= google.golang.org/api v0.98.0/go.mod h1:w7wJQLTM+wvQpNf5JyEcBoxK0RH7EDrh/L4qfsuJ13s= google.golang.org/api v0.100.0/go.mod h1:ZE3Z2+ZOr87Rx7dqFsdRQkRBk36kDtp/h+QpHbB7a70= -google.golang.org/api v0.153.0 h1:N1AwGhielyKFaUqH07/ZSIQR3uNPcV7NVw0vj+j4iR4= -google.golang.org/api v0.153.0/go.mod h1:3qNJX5eOmhiWYc67jRA/3GsDw97UFb5ivv7Y2PrriAY= +google.golang.org/api v0.162.0 h1:Vhs54HkaEpkMBdgGdOT2P6F0csGG/vxDS0hWHJzmmps= +google.golang.org/api v0.162.0/go.mod h1:6SulDkfoBIg4NFmCuZ39XeeAgSHCPecfSUuDyYlAHs0= google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM= 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= @@ -1629,6 +1708,7 @@ google.golang.org/genproto v0.0.0-20200224152610-e50cd9704f63/go.mod h1:55QSHmfG google.golang.org/genproto v0.0.0-20200228133532-8c2c7df3a383/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= google.golang.org/genproto v0.0.0-20200305110556-506484158171/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= google.golang.org/genproto v0.0.0-20200312145019-da6875a35672/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= +google.golang.org/genproto v0.0.0-20200324203455-a04cca1dde73/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= google.golang.org/genproto v0.0.0-20200331122359-1ee6d9798940/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= google.golang.org/genproto v0.0.0-20200423170343-7949de9c1215/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= google.golang.org/genproto v0.0.0-20200430143042-b979b6f78d84/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= @@ -1713,12 +1793,12 @@ google.golang.org/genproto v0.0.0-20221010155953-15ba04fc1c0e/go.mod h1:3526vdqw google.golang.org/genproto v0.0.0-20221014173430-6e2ab493f96b/go.mod h1:1vXfmgAz9N9Jx0QA82PqRVauvCz1SGSz739p0f183jM= google.golang.org/genproto v0.0.0-20221014213838-99cd37c6964a/go.mod h1:1vXfmgAz9N9Jx0QA82PqRVauvCz1SGSz739p0f183jM= google.golang.org/genproto v0.0.0-20221025140454-527a21cfbd71/go.mod h1:9qHF0xnpdSfF6knlcsnpzUu5y+rpwgbvsyGAZPBMg4s= -google.golang.org/genproto v0.0.0-20231211222908-989df2bf70f3 h1:1hfbdAfFbkmpg41000wDVqr7jUpK/Yo+LPnIxxGzmkg= -google.golang.org/genproto v0.0.0-20231211222908-989df2bf70f3/go.mod h1:5RBcpGRxr25RbDzY5w+dmaqpSEvl8Gwl1x2CICf60ic= -google.golang.org/genproto/googleapis/api v0.0.0-20231120223509-83a465c0220f h1:2yNACc1O40tTnrsbk9Cv6oxiW8pxI/pXj0wRtdlYmgY= -google.golang.org/genproto/googleapis/api v0.0.0-20231120223509-83a465c0220f/go.mod h1:Uy9bTZJqmfrw2rIBxgGLnamc78euZULUBrLZ9XTITKI= -google.golang.org/genproto/googleapis/rpc v0.0.0-20231212172506-995d672761c0 h1:/jFB8jK5R3Sq3i/lmeZO0cATSzFfZaJq1J2Euan3XKU= -google.golang.org/genproto/googleapis/rpc v0.0.0-20231212172506-995d672761c0/go.mod h1:FUoWkonphQm3RhTS+kOEhF8h0iDpm4tdXolVCeZ9KKA= +google.golang.org/genproto v0.0.0-20240227224415-6ceb2ff114de h1:F6qOa9AZTYJXOUEr4jDysRDLrm4PHePlge4v4TGAlxY= +google.golang.org/genproto v0.0.0-20240227224415-6ceb2ff114de/go.mod h1:VUhTRKeHn9wwcdrk73nvdC9gF178Tzhmt/qyaFcPLSo= +google.golang.org/genproto/googleapis/api v0.0.0-20240227224415-6ceb2ff114de h1:jFNzHPIeuzhdRwVhbZdiym9q0ory/xY3sA+v2wPg8I0= +google.golang.org/genproto/googleapis/api v0.0.0-20240227224415-6ceb2ff114de/go.mod h1:5iCWqnniDlqZHrd3neWVTOwvh/v6s3232omMecelax8= +google.golang.org/genproto/googleapis/rpc v0.0.0-20240401170217-c3f982113cda h1:LI5DOvAxUPMv/50agcLLoo+AdWc1irS9Rzz4vPuD1V4= +google.golang.org/genproto/googleapis/rpc v0.0.0-20240401170217-c3f982113cda/go.mod h1:WtryC6hu0hhx87FDGxWCDptyssuo68sk10vYjF+T9fY= google.golang.org/grpc v1.17.0/go.mod h1:6QZJwpn2B+Zp71q/5VxRsJ6NXXVCE5NRUHRo+f3cWCs= google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c= google.golang.org/grpc v1.20.0/go.mod h1:chYK+tFQF0nDUGJgXMSgLCQk3phJEuONr2DCgLDdAQM= @@ -1760,8 +1840,8 @@ google.golang.org/grpc v1.48.0/go.mod h1:vN9eftEi1UMyUsIF80+uQXhHjbXYbm0uXoFCACu google.golang.org/grpc v1.49.0/go.mod h1:ZgQEeidpAuNRZ8iRrlBKXZQP1ghovWIVhdJRyCDK+GI= google.golang.org/grpc v1.50.0/go.mod h1:ZgQEeidpAuNRZ8iRrlBKXZQP1ghovWIVhdJRyCDK+GI= google.golang.org/grpc v1.50.1/go.mod h1:ZgQEeidpAuNRZ8iRrlBKXZQP1ghovWIVhdJRyCDK+GI= -google.golang.org/grpc v1.60.1 h1:26+wFr+cNqSGFcOXcabYC0lUVJVRa2Sb2ortSK7VrEU= -google.golang.org/grpc v1.60.1/go.mod h1:OlCHIeLYqSSsLi6i49B5QGdzaMZK9+M7LXN2FKz4eGM= +google.golang.org/grpc v1.63.2 h1:MUeiw1B2maTVZthpU5xvASfTh3LDbxHd6IJ6QQVU+xM= +google.golang.org/grpc v1.63.2/go.mod h1:WAX/8DgncnokcFUldAxq7GeB5DXHDbMF+lLvDomNkRA= google.golang.org/grpc/cmd/protoc-gen-go-grpc v1.1.0/go.mod h1:6Kw0yEErY5E/yWrBtf03jp27GLLJujG4z/JK95pnjjw= google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8= google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0= @@ -1779,8 +1859,8 @@ google.golang.org/protobuf v1.27.1/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQ google.golang.org/protobuf v1.28.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= google.golang.org/protobuf v1.28.1/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= google.golang.org/protobuf v1.30.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= -google.golang.org/protobuf v1.32.0 h1:pPC6BG5ex8PDFnkbrGU3EixyhKcQ2aDuBS36lqK/C7I= -google.golang.org/protobuf v1.32.0/go.mod h1:c6P6GXX6sHbq/GpV6MGZEdwhWPcYBgnhAHhKbcUYpos= +google.golang.org/protobuf v1.33.0 h1:uNO2rsAINq/JlFpSdYEKIZ0uKD/R9cpdv0T+yoGwGmI= +google.golang.org/protobuf v1.33.0/go.mod h1:c6P6GXX6sHbq/GpV6MGZEdwhWPcYBgnhAHhKbcUYpos= 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= @@ -1832,6 +1912,8 @@ rsc.io/binaryregexp v0.2.0/go.mod h1:qTv7/COck+e2FymRvadv62gMdZztPaShugOCi3I+8D8 rsc.io/pdf v0.1.1/go.mod h1:n8OzWcQ6Sp37PL01nO98y4iUCRdTGarVfzxY20ICaU4= rsc.io/quote/v3 v3.1.0/go.mod h1:yEA65RcK8LyAZtP9Kv3t0HmxON59tX3rD+tICJqUlj0= rsc.io/sampler v1.3.0/go.mod h1:T1hPZKmBbMNahiBKFy5HrXp6adAjACjK9JXDnKaTXpA= +rsc.io/tmplfunc v0.0.3 h1:53XFQh69AfOa8Tw0Jm7t+GV7KZhOi6jzsCzTtKbMvzU= +rsc.io/tmplfunc v0.0.3/go.mod h1:AG3sTPzElb1Io3Yg4voV9AGZJuleGAwaVRxL9M49PhA= sigs.k8s.io/yaml v1.1.0/go.mod h1:UJmg0vDUVViEyp3mgSv9WPwZCDxu4rQW1olrI1uml+o= sigs.k8s.io/yaml v1.4.0 h1:Mk1wCc2gy/F0THH0TAp1QYyJNzRm2KCLy3o5ASXVI5E= sigs.k8s.io/yaml v1.4.0/go.mod h1:Ejl7/uTz7PSA4eKMyQCUTnhZYNmLIl+5c2lQPGR2BPY= diff --git a/gosec.json b/gosec.json new file mode 100644 index 000000000..cfa57cbd8 --- /dev/null +++ b/gosec.json @@ -0,0 +1,11 @@ +{ + "global": { + "nosec": "enabled", + "audit": "disabled" + }, + "G104": { + "wire": ["WriteVarString"], + "io": ["WriteString"], + "types": ["RegisterQueryHandlerClient"] + } +} \ No newline at end of file diff --git a/privval/file.go b/privval/file.go index deebd10da..ebfac1314 100644 --- a/privval/file.go +++ b/privval/file.go @@ -17,8 +17,8 @@ import ( "github.com/cosmos/cosmos-sdk/crypto/codec" sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/babylonchain/babylon/crypto/bls12381" - checkpointingtypes "github.com/babylonchain/babylon/x/checkpointing/types" + "github.com/babylonlabs-io/babylon/crypto/bls12381" + checkpointingtypes "github.com/babylonlabs-io/babylon/x/checkpointing/types" ) // copied from github.com/cometbft/cometbft/privval/file.go" @@ -119,6 +119,7 @@ func LoadWrappedFilePVEmptyState(keyFilePath, stateFilePath string) *WrappedFile // If loadState is true, we load from the stateFilePath. Otherwise, we use an empty LastSignState. func loadWrappedFilePV(keyFilePath, stateFilePath string, loadState bool) *WrappedFilePV { + keyFilePath = filepath.Clean(keyFilePath) keyJSONBytes, err := os.ReadFile(keyFilePath) if err != nil { cmtos.Exit(err.Error()) @@ -138,6 +139,7 @@ func loadWrappedFilePV(keyFilePath, stateFilePath string, loadState bool) *Wrapp pvState := privval.FilePVLastSignState{} if loadState { + stateFilePath := filepath.Clean(stateFilePath) stateJSONBytes, err := os.ReadFile(stateFilePath) if err != nil { cmtos.Exit(err.Error()) diff --git a/privval/types.go b/privval/types.go index 17ed68fcf..be2a302f4 100644 --- a/privval/types.go +++ b/privval/types.go @@ -5,8 +5,8 @@ import ( cmtcrypto "github.com/cometbft/cometbft/crypto" - "github.com/babylonchain/babylon/crypto/bls12381" - "github.com/babylonchain/babylon/x/checkpointing/types" + "github.com/babylonlabs-io/babylon/crypto/bls12381" + "github.com/babylonlabs-io/babylon/x/checkpointing/types" ) type ValidatorKeys struct { diff --git a/proto/babylon/btccheckpoint/v1/btccheckpoint.proto b/proto/babylon/btccheckpoint/v1/btccheckpoint.proto index 9dae49c47..70b3b5aeb 100644 --- a/proto/babylon/btccheckpoint/v1/btccheckpoint.proto +++ b/proto/babylon/btccheckpoint/v1/btccheckpoint.proto @@ -3,7 +3,7 @@ package babylon.btccheckpoint.v1; import "gogoproto/gogo.proto"; -option go_package = "github.com/babylonchain/babylon/x/btccheckpoint/types"; +option go_package = "github.com/babylonlabs-io/babylon/x/btccheckpoint/types"; // Consider we have a Merkle tree with following structure: // ROOT @@ -36,16 +36,16 @@ message BTCSpvProof { // Should have exactly 80 bytes bytes confirming_btc_header = 4 [ (gogoproto.customtype) = - "github.com/babylonchain/babylon/types.BTCHeaderBytes" ]; + "github.com/babylonlabs-io/babylon/types.BTCHeaderBytes" ]; } -// Each provided OP_RETURN transaction can be idendtified by hash of block in +// Each provided OP_RETURN transaction can be identified by hash of block in // which transaction was included and transaction index in the block message TransactionKey { uint32 index = 1; bytes hash = 2 [ (gogoproto.customtype) = - "github.com/babylonchain/babylon/types.BTCHeaderHashBytes" ]; + "github.com/babylonlabs-io/babylon/types.BTCHeaderHashBytes" ]; } // Checkpoint can be composed from multiple transactions, so to identify whole @@ -88,20 +88,20 @@ message TransactionInfo { bytes transaction = 2; // 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 - // valideated the proof? + // validated the proof? bytes proof = 3; } // TODO: Determine if we should keep any block number or depth info. -// On one hand it may be usefull to determine if block is stable or not, on +// On one hand it may be useful to determine if block is stable or not, on // other depth/block number info, without context (i.e info about chain) is -// pretty useless and blockshash in enough to retrieve is from lightclient +// pretty useless and blockhash in enough to retrieve is from lightclient 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 transction to payup the reward. + // - 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; @@ -109,7 +109,7 @@ message SubmissionData { } // Data stored in db and indexed by epoch number -// TODO: Add btc blockheight at epooch end, when adding hadnling of epoching +// TODO: Add btc blockheight at epoch end, when adding handling of epoching // callbacks message EpochData { // keys is the list of all received checkpoints during this epoch, sorted by @@ -143,7 +143,7 @@ message BTCCheckpointInfo { // youngest block of best submission bytes best_submission_btc_block_hash = 3 [ (gogoproto.customtype) = - "github.com/babylonchain/babylon/types.BTCHeaderHashBytes" ]; + "github.com/babylonlabs-io/babylon/types.BTCHeaderHashBytes" ]; // the BTC checkpoint transactions of the best submission repeated TransactionInfo best_submission_transactions = 4; // list of vigilantes' addresses of the best submission diff --git a/proto/babylon/btccheckpoint/v1/genesis.proto b/proto/babylon/btccheckpoint/v1/genesis.proto index 49097c360..4d1187126 100644 --- a/proto/babylon/btccheckpoint/v1/genesis.proto +++ b/proto/babylon/btccheckpoint/v1/genesis.proto @@ -4,7 +4,7 @@ package babylon.btccheckpoint.v1; import "gogoproto/gogo.proto"; import "babylon/btccheckpoint/v1/params.proto"; -option go_package = "github.com/babylonchain/babylon/x/btccheckpoint/types"; +option go_package = "github.com/babylonlabs-io/babylon/x/btccheckpoint/types"; // GenesisState defines the btccheckpoint module's genesis state. message GenesisState { Params params = 1 [ (gogoproto.nullable) = false ]; } diff --git a/proto/babylon/btccheckpoint/v1/params.proto b/proto/babylon/btccheckpoint/v1/params.proto index 20ed5e6ee..3315aa03d 100644 --- a/proto/babylon/btccheckpoint/v1/params.proto +++ b/proto/babylon/btccheckpoint/v1/params.proto @@ -3,7 +3,7 @@ package babylon.btccheckpoint.v1; import "gogoproto/gogo.proto"; -option go_package = "github.com/babylonchain/babylon/x/btccheckpoint/types"; +option go_package = "github.com/babylonlabs-io/babylon/x/btccheckpoint/types"; // Params defines the parameters for the module. message Params { diff --git a/proto/babylon/btccheckpoint/v1/query.proto b/proto/babylon/btccheckpoint/v1/query.proto index 2c88f8905..d7ee344ef 100644 --- a/proto/babylon/btccheckpoint/v1/query.proto +++ b/proto/babylon/btccheckpoint/v1/query.proto @@ -2,12 +2,12 @@ syntax = "proto3"; package babylon.btccheckpoint.v1; import "gogoproto/gogo.proto"; +import "cosmos_proto/cosmos.proto"; import "google/api/annotations.proto"; import "cosmos/base/query/v1beta1/pagination.proto"; import "babylon/btccheckpoint/v1/params.proto"; -import "babylon/btccheckpoint/v1/btccheckpoint.proto"; -option go_package = "github.com/babylonchain/babylon/x/btccheckpoint/types"; +option go_package = "github.com/babylonlabs-io/babylon/x/btccheckpoint/types"; // Query defines the gRPC querier service. service Query { @@ -55,7 +55,7 @@ message QueryBtcCheckpointInfoRequest { // QueryBtcCheckpointInfoResponse is response type for the // Query/BtcCheckpointInfo RPC method -message QueryBtcCheckpointInfoResponse { BTCCheckpointInfo info = 1; } +message QueryBtcCheckpointInfoResponse { BTCCheckpointInfoResponse info = 1; } // QueryBtcCheckpointsInfoRequest is request type for the // Query/BtcCheckpointsInfo RPC method @@ -67,7 +67,7 @@ message QueryBtcCheckpointsInfoRequest { // QueryBtcCheckpointsInfoResponse is response type for the // Query/BtcCheckpointsInfo RPC method message QueryBtcCheckpointsInfoResponse { - repeated BTCCheckpointInfo info_list = 1; + repeated BTCCheckpointInfoResponse info_list = 1; // pagination defines the pagination in the response cosmos.base.query.v1beta1.PageResponse pagination = 2; } @@ -77,15 +77,71 @@ message QueryBtcCheckpointsInfoResponse { message QueryEpochSubmissionsRequest { // Number of epoch for which submissions are requested uint64 epoch_num = 1; - - cosmos.base.query.v1beta1.PageRequest pagination = 2; } // QueryEpochSubmissionsResponse defines a response to get all submissions in // given epoch (QueryEpochSubmissionsRequest) message QueryEpochSubmissionsResponse { - // All submissions saved during an epoch. - repeated SubmissionKey keys = 1; + // Keys All submissions transactions key saved during an epoch. + repeated SubmissionKeyResponse keys = 1; +} - cosmos.base.query.v1beta1.PageResponse pagination = 2; +// BTCCheckpointInfoResponse contains all data about best submission of checkpoint for +// given epoch. Best submission is the submission which is deeper in btc ledger. +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; + // 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; + // the BTC checkpoint transactions of the best submission + repeated TransactionInfoResponse best_submission_transactions = 4; + // list of vigilantes' addresses of the best submission + repeated CheckpointAddressesResponse best_submission_vigilante_address_list = 5; +} + +// 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 +message TransactionInfoResponse { + // Index Bitcoin Transaction index in block. + uint32 index = 1; + // Hash BTC Header hash as hex. + string hash = 2; + // transaction is the full transaction data as str hex. + string transaction = 3; + // proof is the Merkle proof that this tx is included in the position in `key` + string proof = 4; +} + +// CheckpointAddressesResponse contains the addresses of the submitter and reporter of a +// given checkpoint +message CheckpointAddressesResponse { + // submitter is the address of the checkpoint submitter to BTC, extracted from + // the checkpoint itself. + string submitter = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"]; + // reporter is the address of the reporter who reported the submissions, + // calculated from submission message MsgInsertBTCSpvProof itself + string reporter = 2 [(cosmos_proto.scalar) = "cosmos.AddressString"]; } + +// 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 +message SubmissionKeyResponse { + // FirstTxBlockHash is the BTCHeaderHashBytes in hex. + string first_tx_block_hash = 1; + uint32 first_tx_index = 2; + + // SecondBlockHash is the BTCHeaderHashBytes in hex. + string second_tx_block_hash = 3; + uint32 second_tx_index = 4; +} \ No newline at end of file diff --git a/proto/babylon/btccheckpoint/v1/tx.proto b/proto/babylon/btccheckpoint/v1/tx.proto index 38fb5a173..9664ea79c 100644 --- a/proto/babylon/btccheckpoint/v1/tx.proto +++ b/proto/babylon/btccheckpoint/v1/tx.proto @@ -7,7 +7,7 @@ import "cosmos/msg/v1/msg.proto"; import "babylon/btccheckpoint/v1/params.proto"; import "gogoproto/gogo.proto"; -option go_package = "github.com/babylonchain/babylon/x/btccheckpoint/types"; +option go_package = "github.com/babylonlabs-io/babylon/x/btccheckpoint/types"; // Msg defines the Msg service. service Msg { diff --git a/proto/babylon/btclightclient/v1/btclightclient.proto b/proto/babylon/btclightclient/v1/btclightclient.proto index f5300706c..d38314f3d 100644 --- a/proto/babylon/btclightclient/v1/btclightclient.proto +++ b/proto/babylon/btclightclient/v1/btclightclient.proto @@ -3,7 +3,7 @@ package babylon.btclightclient.v1; import "gogoproto/gogo.proto"; -option go_package = "github.com/babylonchain/babylon/x/btclightclient/types"; +option go_package = "github.com/babylonlabs-io/babylon/x/btclightclient/types"; // BTCHeaderInfo is a structure that contains all relevant information about a // BTC header @@ -16,10 +16,10 @@ option go_package = "github.com/babylonchain/babylon/x/btclightclient/types"; message BTCHeaderInfo { bytes header = 1 [ (gogoproto.customtype) = - "github.com/babylonchain/babylon/types.BTCHeaderBytes" ]; + "github.com/babylonlabs-io/babylon/types.BTCHeaderBytes" ]; bytes hash = 2 [ (gogoproto.customtype) = - "github.com/babylonchain/babylon/types.BTCHeaderHashBytes" ]; + "github.com/babylonlabs-io/babylon/types.BTCHeaderHashBytes" ]; uint64 height = 3; bytes work = 4 [ (gogoproto.customtype) = "cosmossdk.io/math.Uint" ]; diff --git a/proto/babylon/btclightclient/v1/event.proto b/proto/babylon/btclightclient/v1/event.proto index 4b1a3a0af..4e29ad384 100644 --- a/proto/babylon/btclightclient/v1/event.proto +++ b/proto/babylon/btclightclient/v1/event.proto @@ -3,7 +3,7 @@ package babylon.btclightclient.v1; import "babylon/btclightclient/v1/btclightclient.proto"; -option go_package = "github.com/babylonchain/babylon/x/btclightclient/types"; +option go_package = "github.com/babylonlabs-io/babylon/x/btclightclient/types"; // The header included in the event is the block in the history // of the current mainchain to which we are rolling back to. diff --git a/proto/babylon/btclightclient/v1/genesis.proto b/proto/babylon/btclightclient/v1/genesis.proto index 4de7fce3d..2ed0d830b 100644 --- a/proto/babylon/btclightclient/v1/genesis.proto +++ b/proto/babylon/btclightclient/v1/genesis.proto @@ -5,10 +5,10 @@ import "gogoproto/gogo.proto"; import "babylon/btclightclient/v1/btclightclient.proto"; import "babylon/btclightclient/v1/params.proto"; -option go_package = "github.com/babylonchain/babylon/x/btclightclient/types"; +option go_package = "github.com/babylonlabs-io/babylon/x/btclightclient/types"; // GenesisState defines the btclightclient module's genesis state. message GenesisState { Params params = 1 [(gogoproto.nullable) = false]; - BTCHeaderInfo base_btc_header = 2 [ (gogoproto.nullable) = false ]; + repeated BTCHeaderInfo btc_headers = 2; } diff --git a/proto/babylon/btclightclient/v1/params.proto b/proto/babylon/btclightclient/v1/params.proto index ea0f0c709..7ca7c5757 100644 --- a/proto/babylon/btclightclient/v1/params.proto +++ b/proto/babylon/btclightclient/v1/params.proto @@ -4,7 +4,7 @@ package babylon.btclightclient.v1; import "gogoproto/gogo.proto"; -option go_package = "github.com/babylonchain/babylon/x/btclightclient/types"; +option go_package = "github.com/babylonlabs-io/babylon/x/btclightclient/types"; // Params defines the parameters for the module. message Params { diff --git a/proto/babylon/btclightclient/v1/query.proto b/proto/babylon/btclightclient/v1/query.proto index 146cbf601..51ea46cf1 100644 --- a/proto/babylon/btclightclient/v1/query.proto +++ b/proto/babylon/btclightclient/v1/query.proto @@ -2,12 +2,12 @@ syntax = "proto3"; package babylon.btclightclient.v1; import "gogoproto/gogo.proto"; +import "cosmos_proto/cosmos.proto"; import "google/api/annotations.proto"; import "cosmos/base/query/v1beta1/pagination.proto"; -import "babylon/btclightclient/v1/btclightclient.proto"; import "babylon/btclightclient/v1/params.proto"; -option go_package = "github.com/babylonchain/babylon/x/btclightclient/types"; +option go_package = "github.com/babylonlabs-io/babylon/x/btclightclient/types"; // Query defines the gRPC querier service. service Query { @@ -28,7 +28,7 @@ service Query { // ContainsBytes is a temporary method that // checks whether a hash is maintained by the module. - // See discussion at https://github.com/babylonchain/babylon/pull/132 + // See discussion at https://github.com/babylonlabs-io/babylon/pull/132 // for more details. rpc ContainsBytes(QueryContainsBytesRequest) returns (QueryContainsBytesResponse) { @@ -77,7 +77,7 @@ message QueryHashesRequest { message QueryHashesResponse { repeated bytes hashes = 1 [ (gogoproto.customtype) = - "github.com/babylonchain/babylon/types.BTCHeaderHashBytes" ]; + "github.com/babylonlabs-io/babylon/types.BTCHeaderHashBytes" ]; cosmos.base.query.v1beta1.PageResponse pagination = 2; } @@ -86,7 +86,7 @@ message QueryHashesResponse { message QueryContainsRequest { bytes hash = 1 [ (gogoproto.customtype) = - "github.com/babylonchain/babylon/types.BTCHeaderHashBytes" ]; + "github.com/babylonlabs-io/babylon/types.BTCHeaderHashBytes" ]; } // QueryContainsResponse is response type for the Query/Contains RPC method. @@ -108,7 +108,7 @@ message QueryMainChainRequest { // QueryMainChainResponse is response type for the Query/MainChain RPC method. message QueryMainChainResponse { - repeated BTCHeaderInfo headers = 1; + repeated BTCHeaderInfoResponse headers = 1; cosmos.base.query.v1beta1.PageResponse pagination = 2; } @@ -117,7 +117,7 @@ message QueryMainChainResponse { message QueryTipRequest {} // QueryTipResponse is the response type for the Query/Tip RPC method. -message QueryTipResponse { BTCHeaderInfo header = 1; } +message QueryTipResponse { BTCHeaderInfoResponse header = 1; } // QueryBaseHeaderRequest is the request type for the Query/BaseHeader RPC // method. @@ -125,7 +125,7 @@ message QueryBaseHeaderRequest {} // QueryBaseHeaderResponse is the response type for the Query/BaseHeader RPC // method. -message QueryBaseHeaderResponse { BTCHeaderInfo header = 1; } +message QueryBaseHeaderResponse { BTCHeaderInfoResponse header = 1; } // QueryMainChainDepthRequest is the request type for the Query/MainChainDepth RPC // it contains hex encoded hash of btc block header as parameter @@ -134,3 +134,23 @@ 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; } + +// 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. +message BTCHeaderInfoResponse { + string header_hex = 1; + string hash_hex = 2; + uint64 height = 3; + // Work is the sdkmath.Uint as string. + string work = 4 [ + (cosmos_proto.scalar) = "cosmos.Uint", + (gogoproto.customtype) = "cosmossdk.io/math.Uint", + (gogoproto.nullable) = false + ]; +} diff --git a/proto/babylon/btclightclient/v1/tx.proto b/proto/babylon/btclightclient/v1/tx.proto index 1c884ba87..421508712 100644 --- a/proto/babylon/btclightclient/v1/tx.proto +++ b/proto/babylon/btclightclient/v1/tx.proto @@ -6,7 +6,7 @@ import "cosmos/msg/v1/msg.proto"; import "babylon/btclightclient/v1/params.proto"; import "cosmos_proto/cosmos.proto"; -option go_package = "github.com/babylonchain/babylon/x/btclightclient/types"; +option go_package = "github.com/babylonlabs-io/babylon/x/btclightclient/types"; // Msg defines the Msg service. service Msg { @@ -26,7 +26,7 @@ message MsgInsertHeaders { string signer = 1; repeated bytes headers = 2 [ (gogoproto.customtype) = - "github.com/babylonchain/babylon/types.BTCHeaderBytes" ]; + "github.com/babylonlabs-io/babylon/types.BTCHeaderBytes" ]; } // MsgInsertHeadersResponse defines the response for the InsertHeaders transaction message MsgInsertHeadersResponse {} diff --git a/proto/babylon/btcstaking/v1/btcstaking.proto b/proto/babylon/btcstaking/v1/btcstaking.proto index 89b284156..183694036 100644 --- a/proto/babylon/btcstaking/v1/btcstaking.proto +++ b/proto/babylon/btcstaking/v1/btcstaking.proto @@ -3,28 +3,28 @@ package babylon.btcstaking.v1; import "gogoproto/gogo.proto"; import "cosmos_proto/cosmos.proto"; -import "cosmos/crypto/secp256k1/keys.proto"; import "cosmos/staking/v1beta1/staking.proto"; import "babylon/btcstaking/v1/pop.proto"; -option go_package = "github.com/babylonchain/babylon/x/btcstaking/types"; +option go_package = "github.com/babylonlabs-io/babylon/x/btcstaking/types"; // 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 = 1; + cosmos.staking.v1beta1.Description description = 2; // commission defines the commission rate of the finality provider. - string commission = 2 [ + string commission = 3 [ (cosmos_proto.scalar) = "cosmos.Dec", (gogoproto.customtype) = "cosmossdk.io/math.LegacyDec" ]; - // babylon_pk is the Babylon secp256k1 PK of this finality provider - cosmos.crypto.secp256k1.PubKey babylon_pk = 3; // 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/babylonchain/babylon/types.BIP340PubKey" ]; - // pop is the proof of possession of babylon_pk and btc_pk - ProofOfPossession pop = 5; + 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 @@ -33,13 +33,15 @@ message FinalityProvider { // the finality provider is slashed. // if it's 0 then the finality provider is not slashed uint64 slashed_btc_height = 7; + // sluggish defines whether the finality provider is detected sluggish + bool sluggish = 8; } // FinalityProviderWithMeta wraps the FinalityProvider with metadata. message FinalityProviderWithMeta { // btc_pk is the Bitcoin secp256k1 PK of thisfinality provider // the PK follows encoding in BIP-340 spec - bytes btc_pk = 1 [ (gogoproto.customtype) = "github.com/babylonchain/babylon/types.BIP340PubKey" ]; + bytes btc_pk = 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 @@ -52,22 +54,24 @@ message FinalityProviderWithMeta { // the finality provider is slashed. // if it's 0 then the finality provider is not slashed uint64 slashed_btc_height = 5; + // sluggish defines whether the finality provider is detected sluggish + bool sluggish = 6; } // BTCDelegation defines a BTC delegation message BTCDelegation { - // babylon_pk is the Babylon secp256k1 PK of this BTC delegation - cosmos.crypto.secp256k1.PubKey babylon_pk = 1; + // 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/babylonchain/babylon/types.BIP340PubKey" ]; + 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 - ProofOfPossession pop = 3; + 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/babylonchain/babylon/types.BIP340PubKey" ]; + 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; @@ -88,7 +92,7 @@ message BTCDelegation { // 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/babylonchain/babylon/types.BIP340Signature" ]; + 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. @@ -98,6 +102,8 @@ message BTCDelegation { 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; } // BTCUndelegation contains the information about the early unbonding path of the BTC delegation @@ -115,37 +121,21 @@ message BTCUndelegation { // 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/babylonchain/babylon/types.BIP340Signature" ]; + 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/babylonchain/babylon/types.BIP340Signature" ]; + 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 undelagate message by Babylon + // It must be provided after processing undelegate message by Babylon repeated SignatureInfo covenant_unbonding_sig_list = 6; } - -// BTCUndelegationInfo provides all necessary info about the undeleagation -message BTCUndelegationInfo { - // 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; - // covenant_unbonding_sig_list is the list of signatures on the unbonding tx - // by covenant members - repeated SignatureInfo covenant_unbonding_sig_list = 2; - // 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 = 3; -} - // BTCDelegatorDelegations is a collection of BTC delegations from the same delegator. message BTCDelegatorDelegations { repeated BTCDelegation dels = 1; @@ -175,15 +165,15 @@ enum BTCDelegationStatus { // SignatureInfo is a BIP-340 signature together with its signer's BIP-340 PK message SignatureInfo { - bytes pk = 1 [ (gogoproto.customtype) = "github.com/babylonchain/babylon/types.BIP340PubKey" ]; - bytes sig = 2 [ (gogoproto.customtype) = "github.com/babylonchain/babylon/types.BIP340Signature" ]; + bytes pk = 1 [ (gogoproto.customtype) = "github.com/babylonlabs-io/babylon/types.BIP340PubKey" ]; + bytes sig = 2 [ (gogoproto.customtype) = "github.com/babylonlabs-io/babylon/types.BIP340Signature" ]; } // CovenantAdaptorSignatures is a list adaptor signatures signed by the // covenant with different finality provider's public keys as encryption keys message CovenantAdaptorSignatures { // cov_pk is the public key of the covenant emulator, used as the public key of the adaptor signature - bytes cov_pk = 1 [ (gogoproto.customtype) = "github.com/babylonchain/babylon/types.BIP340PubKey" ]; + bytes cov_pk = 1 [ (gogoproto.customtype) = "github.com/babylonlabs-io/babylon/types.BIP340PubKey" ]; // adaptor_sigs is a list of adaptor signatures, each encrypted by a restaked BTC finality provider's public key repeated bytes adaptor_sigs = 2; } @@ -200,7 +190,7 @@ message SelectiveSlashingEvidence { string staking_tx_hash = 1; // fp_btc_pk is the BTC PK of the finality provider who // launches the selective slashing offence - bytes fp_btc_pk = 2 [ (gogoproto.customtype) = "github.com/babylonchain/babylon/types.BIP340PubKey" ]; + bytes fp_btc_pk = 2 [ (gogoproto.customtype) = "github.com/babylonlabs-io/babylon/types.BIP340PubKey" ]; // recovered_fp_btc_sk is the finality provider's BTC SK recovered from // the covenant adaptor/Schnorr signature pair. It is the consequence // of selective slashing. diff --git a/proto/babylon/btcstaking/v1/events.proto b/proto/babylon/btcstaking/v1/events.proto index 1d9845b4f..a8d4fb3e4 100644 --- a/proto/babylon/btcstaking/v1/events.proto +++ b/proto/babylon/btcstaking/v1/events.proto @@ -4,44 +4,47 @@ package babylon.btcstaking.v1; import "gogoproto/gogo.proto"; import "babylon/btcstaking/v1/btcstaking.proto"; -option go_package = "github.com/babylonchain/babylon/x/btcstaking/types"; +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; } -// EventNewBTCDelegation is the event emitted when a BTC delegation is created -// NOTE: the BTC delegation is not active thus does not have voting power yet -// only after it receives a covenant signature it becomes activated and has voting power -message EventNewBTCDelegation { BTCDelegation btc_del = 1; } - -// EventActivateBTCDelegation is the event emitted when covenant activates a BTC delegation -// such that the BTC delegation starts to have voting power in its timelock period -message EventActivateBTCDelegation { BTCDelegation btc_del = 1; } - -// EventUnbondingBTCDelegation is the event emitted when an unbonding BTC delegation -// receives all signatures needed for becoming unbonded -message EventUnbondedBTCDelegation { - // 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/babylonchain/babylon/types.BIP340PubKey" ]; - // 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 = 2 [ (gogoproto.customtype) = "github.com/babylonchain/babylon/types.BIP340PubKey" ]; +// 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 { // staking_tx_hash is the hash of the staking tx. - // (fp_pks..., del_pk, staking_tx_hash) uniquely identifies a BTC delegation - string staking_tx_hash = 3; - // unbonding_tx_hash is the hash of the unbonding tx. - string unbonding_tx_hash = 4; - // from_state is the last state the BTC delegation was at - BTCDelegationStatus from_state = 5; + // 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; } -// EventSelectiveSlashing is the event emitted when an adversarial +// 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; } + +// 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; + } +} diff --git a/proto/babylon/btcstaking/v1/genesis.proto b/proto/babylon/btcstaking/v1/genesis.proto index 406cba75a..2e5d5966e 100644 --- a/proto/babylon/btcstaking/v1/genesis.proto +++ b/proto/babylon/btcstaking/v1/genesis.proto @@ -3,10 +3,76 @@ 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/babylonchain/babylon/x/btcstaking/types"; +option go_package = "github.com/babylonlabs-io/babylon/x/btcstaking/types"; // GenesisState defines the btcstaking module's genesis state. message GenesisState { - Params params = 1 [(gogoproto.nullable) = false]; + // different versions of params used through the history of the chain + repeated Params params = 1; + // finality_providers all the finality providers registered. + 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. +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; +} + +// BTCDelegator BTC delegator information with the associated finality provider. +message BTCDelegator { + // idx the btc delegator index. + BTCDelegatorDelegationIndex idx = 1; + // fp_btc_pk the finality provider btc public key. + bytes fp_btc_pk = 2 [ (gogoproto.customtype) = "github.com/babylonlabs-io/babylon/types.BIP340PubKey" ]; + // del_btc_pk the delegator btc public key. + bytes del_btc_pk = 3 [ (gogoproto.customtype) = "github.com/babylonlabs-io/babylon/types.BIP340PubKey" ]; +} + +// EventIndex contains the event and its index. +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; + // event the event stored. + EventPowerDistUpdate event = 3; } diff --git a/proto/babylon/btcstaking/v1/incentive.proto b/proto/babylon/btcstaking/v1/incentive.proto index 659b54d98..7dcde01f8 100644 --- a/proto/babylon/btcstaking/v1/incentive.proto +++ b/proto/babylon/btcstaking/v1/incentive.proto @@ -3,12 +3,12 @@ package babylon.btcstaking.v1; import "gogoproto/gogo.proto"; import "cosmos_proto/cosmos.proto"; -import "cosmos/crypto/secp256k1/keys.proto"; -option go_package = "github.com/babylonchain/babylon/x/btcstaking/types"; +option go_package = "github.com/babylonlabs-io/babylon/x/btcstaking/types"; -// RewardDistCache is the cache for reward distribution of finality providers at a height -message RewardDistCache { +// VotingPowerDistCache is the cache for voting power distribution of finality providers +// and their BTC delegations at a height +message VotingPowerDistCache { uint64 total_voting_power = 1; // finality_providers is a list of finality providers' voting power information repeated FinalityProviderDistInfo finality_providers = 2; @@ -18,9 +18,9 @@ message RewardDistCache { 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/babylonchain/babylon/types.BIP340PubKey" ]; - // babylon_pk is the Babylon public key of the finality provider - cosmos.crypto.secp256k1.PubKey babylon_pk = 2; + 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", @@ -32,10 +32,15 @@ message FinalityProviderDistInfo { repeated BTCDelDistInfo btc_dels = 5; } -// BTCDelDistInfo contains the information related to reward distribution for a BTC delegations +// BTCDelDistInfo contains the information related to reward distribution for a BTC delegation message BTCDelDistInfo { - // babylon_pk is the Babylon public key of the BTC delegations - cosmos.crypto.secp256k1.PubKey babylon_pk = 1; + // 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 = 2; + uint64 voting_power = 4; } diff --git a/proto/babylon/btcstaking/v1/params.proto b/proto/babylon/btcstaking/v1/params.proto index b140adecc..5746ffb25 100644 --- a/proto/babylon/btcstaking/v1/params.proto +++ b/proto/babylon/btcstaking/v1/params.proto @@ -4,7 +4,7 @@ package babylon.btcstaking.v1; import "gogoproto/gogo.proto"; import "cosmos_proto/cosmos.proto"; -option go_package = "github.com/babylonchain/babylon/x/btcstaking/types"; +option go_package = "github.com/babylonlabs-io/babylon/x/btcstaking/types"; // Params defines the parameters for the module. message Params { @@ -12,7 +12,7 @@ message Params { // 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/babylonchain/babylon/types.BIP340PubKey" ]; + 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; @@ -39,4 +39,25 @@ message Params { 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; + + // 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", + (gogoproto.customtype) = "cosmossdk.io/math.LegacyDec", + (gogoproto.nullable) = false + ]; +} + +// StoredParams attach information about the version of stored parameters +message StoredParams { + // version of the stored parameters. Each parameters update + // increments version number by 1 + uint32 version = 1; + + // NOTE: Parameters must always be provided + Params params = 2 [(gogoproto.nullable) = false]; } diff --git a/proto/babylon/btcstaking/v1/pop.proto b/proto/babylon/btcstaking/v1/pop.proto index fa3ae87d8..316bb1df7 100644 --- a/proto/babylon/btcstaking/v1/pop.proto +++ b/proto/babylon/btcstaking/v1/pop.proto @@ -1,7 +1,7 @@ syntax = "proto3"; package babylon.btcstaking.v1; -option go_package = "github.com/babylonchain/babylon/x/btcstaking/types"; +option go_package = "github.com/babylonlabs-io/babylon/x/btcstaking/types"; // BTCSigType indicates the type of btc_sig in a pop enum BTCSigType { @@ -14,17 +14,15 @@ enum BTCSigType { ECDSA = 2; } -// ProofOfPossession is the proof of possession that a Babylon secp256k1 -// secret key and a Bitcoin secp256k1 secret key are held by the same +// ProofOfPossessionBTC is the proof of possession that a Babylon +// address and a Bitcoin secp256k1 secret key are held by the same // person -message ProofOfPossession { +message ProofOfPossessionBTC { // btc_sig_type indicates the type of btc_sig in the pop BTCSigType btc_sig_type = 1; - // babylon_sig is the signature generated via sign(sk_babylon, pk_btc) - bytes babylon_sig = 2; - // btc_sig is the signature generated via sign(sk_btc, babylon_sig) + // btc_sig is the signature generated via sign(sk_btc, babylon_staker_address) // the signature follows encoding in either BIP-340 spec or BIP-322 spec - bytes btc_sig = 3; + bytes btc_sig = 2; } // BIP322Sig is a BIP-322 signature together with the address corresponding to diff --git a/proto/babylon/btcstaking/v1/query.proto b/proto/babylon/btcstaking/v1/query.proto index 640258bea..3f9aabe51 100644 --- a/proto/babylon/btcstaking/v1/query.proto +++ b/proto/babylon/btcstaking/v1/query.proto @@ -3,11 +3,14 @@ package babylon.btcstaking.v1; import "gogoproto/gogo.proto"; import "google/api/annotations.proto"; +import "cosmos_proto/cosmos.proto"; +import "cosmos/staking/v1beta1/staking.proto"; import "cosmos/base/query/v1beta1/pagination.proto"; import "babylon/btcstaking/v1/params.proto"; import "babylon/btcstaking/v1/btcstaking.proto"; +import "babylon/btcstaking/v1/pop.proto"; -option go_package = "github.com/babylonchain/babylon/x/btcstaking/types"; +option go_package = "github.com/babylonlabs-io/babylon/x/btcstaking/types"; // Query defines the gRPC querier service. service Query { @@ -15,6 +18,10 @@ service Query { rpc Params(QueryParamsRequest) returns (QueryParamsResponse) { option (google.api.http).get = "/babylon/btcstaking/v1/params"; } + // ParamsByVersion queries the parameters of the module for a specific version of past params. + rpc ParamsByVersion(QueryParamsByVersionRequest) returns (QueryParamsByVersionResponse) { + option (google.api.http).get = "/babylon/btcstaking/v1/params/{version}"; + } // FinalityProviders queries all finality providers rpc FinalityProviders(QueryFinalityProvidersRequest) returns (QueryFinalityProvidersResponse) { @@ -72,6 +79,17 @@ message QueryParamsResponse { Params params = 1 [(gogoproto.nullable) = false]; } +// QueryParamsRequest is request type for the Query/Params RPC method. +message QueryParamsByVersionRequest { + uint32 version = 1; +} + +// QueryParamsResponse is response type for the Query/Params RPC method. +message QueryParamsByVersionResponse { + // params holds all the parameters of this module. + Params params = 1 [(gogoproto.nullable) = false]; +} + // QueryFinalityProvidersRequest is the request type for the // Query/FinalityProviders RPC method. message QueryFinalityProvidersRequest { @@ -83,7 +101,7 @@ message QueryFinalityProvidersRequest { // Query/FinalityProviders RPC method. message QueryFinalityProvidersResponse { // finality_providers contains all the finality providers - repeated FinalityProvider finality_providers = 1; + repeated FinalityProviderResponse finality_providers = 1; // pagination defines the pagination in the response. cosmos.base.query.v1beta1.PageResponse pagination = 2; @@ -99,7 +117,7 @@ message QueryFinalityProviderRequest { // QueryFinalityProviderResponse contains information about a finality provider message QueryFinalityProviderResponse { // finality_provider contains the FinalityProvider - FinalityProvider finality_provider = 1; + FinalityProviderResponse finality_provider = 1; } // QueryBTCDelegationsRequest is the request type for the @@ -116,7 +134,7 @@ message QueryBTCDelegationsRequest { // Query/BTCDelegations RPC method. message QueryBTCDelegationsResponse { // btc_delegations contains all the queried BTC delegations under the given status - repeated BTCDelegation btc_delegations = 1; + repeated BTCDelegationResponse btc_delegations = 1; // pagination defines the pagination in the response. cosmos.base.query.v1beta1.PageResponse pagination = 2; @@ -203,7 +221,7 @@ message QueryFinalityProviderDelegationsRequest { // Query/FinalityProviderDelegations RPC method. message QueryFinalityProviderDelegationsResponse { // btc_delegator_delegations contains all the queried BTC delegations. - repeated BTCDelegatorDelegations btc_delegator_delegations = 1; + repeated BTCDelegatorDelegationsResponse btc_delegator_delegations = 1; // pagination defines the pagination in the response. cosmos.base.query.v1beta1.PageResponse pagination = 2; @@ -219,32 +237,118 @@ message QueryBTCDelegationRequest { // QueryBTCDelegationResponse is response type matching QueryBTCDelegationRequest // and containing BTC delegation information message QueryBTCDelegationResponse { - // btc_pk is the Bitcoin secp256k1 PK of this BTC delegation + // BTCDelegation represents the client needed information of an BTCDelegation. + BTCDelegationResponse btc_delegation = 1; +} + +// BTCDelegationResponse is the client needed information from a BTCDelegation with the current status based on parameters. +message BTCDelegationResponse { + // 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 = 1 [ (gogoproto.customtype) = "github.com/babylonchain/babylon/types.BIP340PubKey" ]; + bytes btc_pk = 2 [ (gogoproto.customtype) = "github.com/babylonlabs-io/babylon/types.BIP340PubKey" ]; // 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 = 2 [ (gogoproto.customtype) = "github.com/babylonchain/babylon/types.BIP340PubKey" ]; + repeated bytes fp_btc_pk_list = 3 [ (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 = 3; + uint64 start_height = 4; // end_height is the end height of the BTC delegation // it is the end BTC height of the timelock - w - uint64 end_height = 4; + uint64 end_height = 5; // total_sat is the total amount of BTC stakes in this delegation // quantified in satoshi - uint64 total_sat = 5; + uint64 total_sat = 6; // staking_tx_hex is the hex string of staking tx - string staking_tx_hex = 6; + string staking_tx_hex = 7; + // slashing_tx_hex is the hex string of slashing tx + string slashing_tx_hex = 8; + // 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; // 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 = 7; + repeated CovenantAdaptorSignatures covenant_sigs = 10; + // staking_output_idx is the index of the staking output in the staking tx + uint32 staking_output_idx = 11; // whether this delegation is active - bool active = 8; + bool active = 12; + // descriptive status of current delegation. + string status_desc = 13; // unbonding_time used in unbonding output timelock path and in slashing transactions // change outputs - uint32 unbonding_time = 9; - // undelegation_info is the undelegation info of this delegation. - BTCUndelegationInfo undelegation_info = 10; + uint32 unbonding_time = 14; + // undelegation_response is the undelegation info of this delegation. + BTCUndelegationResponse undelegation_response = 15; + // params version used to validate delegation + uint32 params_version = 16; +} + +// BTCUndelegationResponse provides all necessary info about the undeleagation +message BTCUndelegationResponse { + // 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. + 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; + // slashingTxHex is the hex string of slashing tx + string slashing_tx_hex = 4; + // 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; + // 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; +} + +// BTCDelegatorDelegationsResponse is a collection of BTC delegations responses from the same delegator. +message BTCDelegatorDelegationsResponse { + repeated BTCDelegationResponse dels = 1; +} + +// FinalityProviderResponse defines a finality provider with voting power information. +message FinalityProviderResponse { + // description defines the description terms for the finality provider. + cosmos.staking.v1beta1.Description description = 1; + // commission defines the commission rate of the finality provider. + string commission = 2 [ + (cosmos_proto.scalar) = "cosmos.Dec", + (gogoproto.customtype) = "cosmossdk.io/math.LegacyDec" + ]; + // addr is the address to receive commission from delegations. + string addr = 3 [(cosmos_proto.scalar) = "cosmos.AddressString"]; + // 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 by the fp addr. + // Essentially is the signature where the BTC SK sigs the fp addr. + 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; + // 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; + // sluggish defines whether the finality provider is detected sluggish + bool sluggish = 10; } diff --git a/proto/babylon/btcstaking/v1/tx.proto b/proto/babylon/btcstaking/v1/tx.proto index 05bc22218..61500d480 100644 --- a/proto/babylon/btcstaking/v1/tx.proto +++ b/proto/babylon/btcstaking/v1/tx.proto @@ -4,13 +4,12 @@ package babylon.btcstaking.v1; import "gogoproto/gogo.proto"; import "cosmos_proto/cosmos.proto"; import "cosmos/msg/v1/msg.proto"; -import "cosmos/crypto/secp256k1/keys.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"; -option go_package = "github.com/babylonchain/babylon/x/btcstaking/types"; +option go_package = "github.com/babylonlabs-io/babylon/x/btcstaking/types"; // Msg defines the Msg service. // TODO: handle unbonding tx with full witness @@ -19,6 +18,8 @@ service Msg { // CreateFinalityProvider creates a new finality provider rpc CreateFinalityProvider(MsgCreateFinalityProvider) returns (MsgCreateFinalityProviderResponse); + // EditFinalityProvider edits an existing finality provider + rpc EditFinalityProvider(MsgEditFinalityProvider) returns (MsgEditFinalityProviderResponse); // CreateBTCDelegation creates a new BTC delegation rpc CreateBTCDelegation(MsgCreateBTCDelegation) returns (MsgCreateBTCDelegationResponse); // AddCovenantSigs handles signatures from a covenant member @@ -34,74 +35,89 @@ service Msg { // MsgCreateFinalityProvider is the message for creating a finality provider message MsgCreateFinalityProvider { - option (cosmos.msg.v1.signer) = "signer"; - - string signer = 1; - - // description defines the description terms for the finality provider. + option (cosmos.msg.v1.signer) = "addr"; + // addr defines the address of the finality provider that will receive + // the commissions to all the delegations. + 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 finality provider. + // commission defines the commission rate of the finality provider string commission = 3 [ (cosmos_proto.scalar) = "cosmos.Dec", (gogoproto.customtype) = "cosmossdk.io/math.LegacyDec" ]; - // babylon_pk is the Babylon secp256k1 PK of this finality provider - cosmos.crypto.secp256k1.PubKey babylon_pk = 4; // btc_pk is the Bitcoin secp256k1 PK of this finality provider // the PK follows encoding in BIP-340 spec - bytes btc_pk = 5 [ (gogoproto.customtype) = "github.com/babylonchain/babylon/types.BIP340PubKey" ]; - // pop is the proof of possession of babylon_pk and btc_pk - ProofOfPossession pop = 6; + bytes btc_pk = 4 [ (gogoproto.customtype) = "github.com/babylonlabs-io/babylon/types.BIP340PubKey" ]; + // pop is the proof of possession of btc_pk over the FP signer address. + ProofOfPossessionBTC pop = 5; } + // MsgCreateFinalityProviderResponse is the response for MsgCreateFinalityProvider message MsgCreateFinalityProviderResponse {} +// MsgEditFinalityProvider is the message for editing an existing finality provider +message MsgEditFinalityProvider { + option (cosmos.msg.v1.signer) = "addr"; + // addr the address of the finality provider that whishes to edit his information. + string addr = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"]; + // btc_pk is the Bitcoin secp256k1 PK of the finality provider to be edited + bytes btc_pk = 2; + // description defines the updated description terms for the finality provider + cosmos.staking.v1beta1.Description description = 3; + // commission defines the updated commission rate of the finality provider + string commission = 4 [ + (cosmos_proto.scalar) = "cosmos.Dec", + (gogoproto.customtype) = "cosmossdk.io/math.LegacyDec" + ]; +} +// MsgEditFinalityProviderResponse is the response for MsgEditFinalityProvider +message MsgEditFinalityProviderResponse {} + // MsgCreateBTCDelegation is the message for creating a BTC delegation message MsgCreateBTCDelegation { - option (cosmos.msg.v1.signer) = "signer"; - - string signer = 1; - // babylon_pk is the Babylon secp256k1 PK of this BTC delegation - cosmos.crypto.secp256k1.PubKey babylon_pk = 2; - // pop is the proof of possession of babylon_pk and btc_pk - ProofOfPossession pop = 3; + option (cosmos.msg.v1.signer) = "staker_addr"; + // staker_addr is the address to receive rewards from BTC delegation. + string staker_addr = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"]; + // pop is the proof of possession of btc_pk by the staker_addr. + ProofOfPossessionBTC pop = 2; // btc_pk is the Bitcoin secp256k1 PK of the BTC delegator - bytes btc_pk = 4 [ (gogoproto.customtype) = "github.com/babylonchain/babylon/types.BIP340PubKey" ]; + bytes btc_pk = 3 [ (gogoproto.customtype) = "github.com/babylonlabs-io/babylon/types.BIP340PubKey" ]; // fp_btc_pk_list is the list of Bitcoin secp256k1 PKs of the finality providers, if there is more than one // finality provider pk it means that delegation is re-staked - repeated bytes fp_btc_pk_list = 5 [ (gogoproto.customtype) = "github.com/babylonchain/babylon/types.BIP340PubKey" ]; + repeated bytes fp_btc_pk_list = 4 [ (gogoproto.customtype) = "github.com/babylonlabs-io/babylon/types.BIP340PubKey" ]; // staking_time is the time lock used in staking transaction - uint32 staking_time = 6; + uint32 staking_time = 5; // staking_value is the amount of satoshis locked in staking output - int64 staking_value = 7; + 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 = 8; + babylon.btccheckpoint.v1.TransactionInfo staking_tx = 7; // slashing_tx is the slashing tx // Note that the tx itself does not contain signatures, which are off-chain. - bytes slashing_tx = 9 [ (gogoproto.customtype) = "BTCSlashingTx" ]; + bytes slashing_tx = 8 [ (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 = 10 [ (gogoproto.customtype) = "github.com/babylonchain/babylon/types.BIP340Signature" ]; + bytes delegator_slashing_sig = 9 [ (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 = 11; + uint32 unbonding_time = 10; // 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 = 12; + bytes unbonding_tx = 11; // 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 = 13; + int64 unbonding_value = 12; // 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 = 14 [ (gogoproto.customtype) = "BTCSlashingTx" ]; + bytes unbonding_slashing_tx = 13 [ (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 = 15 [ (gogoproto.customtype) = "github.com/babylonchain/babylon/types.BIP340Signature" ]; + bytes delegator_unbonding_slashing_sig = 14 [ (gogoproto.customtype) = "github.com/babylonlabs-io/babylon/types.BIP340Signature" ]; } // MsgCreateBTCDelegationResponse is the response for MsgCreateBTCDelegation message MsgCreateBTCDelegationResponse {} @@ -112,7 +128,7 @@ message MsgAddCovenantSigs { string signer = 1; // pk is the BTC public key of the covenant member - bytes pk = 2 [ (gogoproto.customtype) = "github.com/babylonchain/babylon/types.BIP340PubKey" ]; + bytes pk = 2 [ (gogoproto.customtype) = "github.com/babylonlabs-io/babylon/types.BIP340PubKey" ]; // staking_tx_hash is the hash of the staking tx. // It uniquely identifies a BTC delegation string staking_tx_hash = 3; @@ -122,7 +138,7 @@ message MsgAddCovenantSigs { repeated bytes slashing_tx_sigs = 4; // unbonding_tx_sig is the signature of the covenant on the unbonding tx submitted to babylon // the signature follows encoding in BIP-340 spec - bytes unbonding_tx_sig = 5 [ (gogoproto.customtype) = "github.com/babylonchain/babylon/types.BIP340Signature" ]; + bytes unbonding_tx_sig = 5 [ (gogoproto.customtype) = "github.com/babylonlabs-io/babylon/types.BIP340Signature" ]; // slashing_unbonding_tx_sigs is a list of adaptor signatures of the covenant // on slashing tx corresponding to unbonding tx submitted to babylon // the order of sigs should respect the order of finality providers @@ -144,7 +160,7 @@ message MsgBTCUndelegate { 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/babylonchain/babylon/types.BIP340Signature" ]; + bytes unbonding_tx_sig = 3 [ (gogoproto.customtype) = "github.com/babylonlabs-io/babylon/types.BIP340Signature" ]; } // MsgBTCUndelegateResponse is the response for MsgBTCUndelegate message MsgBTCUndelegateResponse {} diff --git a/proto/babylon/checkpointing/v1/bls_key.proto b/proto/babylon/checkpointing/v1/bls_key.proto index 4ea1363c5..912f9dd63 100644 --- a/proto/babylon/checkpointing/v1/bls_key.proto +++ b/proto/babylon/checkpointing/v1/bls_key.proto @@ -3,14 +3,14 @@ package babylon.checkpointing.v1; import "gogoproto/gogo.proto"; -option go_package = "github.com/babylonchain/babylon/x/checkpointing/types"; +option go_package = "github.com/babylonlabs-io/babylon/x/checkpointing/types"; // BlsKey wraps BLS public key with PoP message BlsKey { // pubkey is the BLS public key of a validator bytes pubkey = 1 [ (gogoproto.customtype) = - "github.com/babylonchain/babylon/crypto/bls12381.PublicKey" ]; + "github.com/babylonlabs-io/babylon/crypto/bls12381.PublicKey" ]; // pop is the proof-of-possession of the BLS key ProofOfPossession pop = 2; @@ -26,7 +26,7 @@ message ProofOfPossession { // ed25519_sig) bytes bls_sig = 2 [ (gogoproto.customtype) = - "github.com/babylonchain/babylon/crypto/bls12381.Signature" ]; + "github.com/babylonlabs-io/babylon/crypto/bls12381.Signature" ]; } // ValidatorWithBLSSet defines a set of validators with their BLS public keys @@ -58,5 +58,5 @@ message VoteExtension { // bls_sig is the BLS signature bytes bls_sig = 6 [ (gogoproto.customtype) = - "github.com/babylonchain/babylon/crypto/bls12381.Signature" ]; + "github.com/babylonlabs-io/babylon/crypto/bls12381.Signature" ]; } diff --git a/proto/babylon/checkpointing/v1/checkpoint.proto b/proto/babylon/checkpointing/v1/checkpoint.proto index 208a191d4..309447a7a 100644 --- a/proto/babylon/checkpointing/v1/checkpoint.proto +++ b/proto/babylon/checkpointing/v1/checkpoint.proto @@ -5,7 +5,7 @@ import "google/protobuf/timestamp.proto"; import "gogoproto/gogo.proto"; import "tendermint/abci/types.proto"; -option go_package = "github.com/babylonchain/babylon/x/checkpointing/types"; +option go_package = "github.com/babylonlabs-io/babylon/x/checkpointing/types"; // RawCheckpoint wraps the BLS multi sig with metadata message RawCheckpoint { @@ -22,7 +22,7 @@ message RawCheckpoint { // sigs bytes bls_multi_sig = 4 [ (gogoproto.customtype) = - "github.com/babylonchain/babylon/crypto/bls12381.Signature" ]; + "github.com/babylonlabs-io/babylon/crypto/bls12381.Signature" ]; } // RawCheckpointWithMeta wraps the raw checkpoint with metadata. @@ -35,7 +35,7 @@ message RawCheckpointWithMeta { // bls_aggr_pk defines the aggregated BLS public key bytes bls_aggr_pk = 3 [ (gogoproto.customtype) = - "github.com/babylonchain/babylon/crypto/bls12381.PublicKey" ]; + "github.com/babylonlabs-io/babylon/crypto/bls12381.PublicKey" ]; // power_sum defines the accumulated voting power for the checkpoint uint64 power_sum = 4; // lifecycle defines the lifecycle of this checkpoint, i.e., each state @@ -94,7 +94,7 @@ message BlsSig { bytes block_hash = 2 [ (gogoproto.customtype) = "BlockHash" ]; bytes bls_sig = 3 [ (gogoproto.customtype) = - "github.com/babylonchain/babylon/crypto/bls12381.Signature" ]; + "github.com/babylonlabs-io/babylon/crypto/bls12381.Signature" ]; // can't find cosmos_proto.scalar when compiling due to cosmos v0.45.4 does // not support scalar string signer_address = 4 [(cosmos_proto.scalar) = // "cosmos.AddressString"] diff --git a/proto/babylon/checkpointing/v1/events.proto b/proto/babylon/checkpointing/v1/events.proto index 4e170c058..090888b0a 100644 --- a/proto/babylon/checkpointing/v1/events.proto +++ b/proto/babylon/checkpointing/v1/events.proto @@ -3,7 +3,7 @@ package babylon.checkpointing.v1; import "babylon/checkpointing/v1/checkpoint.proto"; -option go_package = "github.com/babylonchain/babylon/x/checkpointing/types"; +option go_package = "github.com/babylonlabs-io/babylon/x/checkpointing/types"; // EventCheckpointAccumulating is emitted when a checkpoint reaches the // `Accumulating` state. diff --git a/proto/babylon/checkpointing/v1/genesis.proto b/proto/babylon/checkpointing/v1/genesis.proto index dd65d5017..dd96841a2 100644 --- a/proto/babylon/checkpointing/v1/genesis.proto +++ b/proto/babylon/checkpointing/v1/genesis.proto @@ -4,7 +4,7 @@ package babylon.checkpointing.v1; import "cosmos/crypto/ed25519/keys.proto"; import "babylon/checkpointing/v1/bls_key.proto"; -option go_package = "github.com/babylonchain/babylon/x/checkpointing/types"; +option go_package = "github.com/babylonlabs-io/babylon/x/checkpointing/types"; // GenesisState defines the checkpointing module's genesis state. message GenesisState { diff --git a/proto/babylon/checkpointing/v1/query.proto b/proto/babylon/checkpointing/v1/query.proto index b522c9a7e..74c9853f7 100644 --- a/proto/babylon/checkpointing/v1/query.proto +++ b/proto/babylon/checkpointing/v1/query.proto @@ -1,12 +1,14 @@ syntax = "proto3"; package babylon.checkpointing.v1; -import "babylon/checkpointing/v1/bls_key.proto"; -import "cosmos/base/query/v1beta1/pagination.proto"; +import "gogoproto/gogo.proto"; import "google/api/annotations.proto"; +import "google/protobuf/timestamp.proto"; +import "babylon/checkpointing/v1/bls_key.proto"; import "babylon/checkpointing/v1/checkpoint.proto"; +import "cosmos/base/query/v1beta1/pagination.proto"; -option go_package = "github.com/babylonchain/babylon/x/checkpointing/types"; +option go_package = "github.com/babylonlabs-io/babylon/x/checkpointing/types"; // Query defines the gRPC querier service. service Query { @@ -76,7 +78,7 @@ message QueryRawCheckpointListRequest { // Query/RawCheckpoints RPC method. message QueryRawCheckpointListResponse { // the order is going from the newest to oldest based on the epoch number - repeated RawCheckpointWithMeta raw_checkpoints = 1; + repeated RawCheckpointWithMetaResponse raw_checkpoints = 1; // pagination defines the pagination in the response. cosmos.base.query.v1beta1.PageResponse pagination = 2; @@ -91,8 +93,7 @@ message QueryRawCheckpointRequest { // QueryRawCheckpointResponse is the response type for the Query/RawCheckpoint // RPC method. -message QueryRawCheckpointResponse { RawCheckpointWithMeta raw_checkpoint = 1; } - +message QueryRawCheckpointResponse { RawCheckpointWithMetaResponse raw_checkpoint = 1; } // QueryRawCheckpointsRequest is the request type for the Query/RawCheckpoints // RPC method. @@ -105,7 +106,7 @@ message QueryRawCheckpointsRequest { // RPC method. message QueryRawCheckpointsResponse { // the order is going from the newest to oldest based on the epoch number - repeated RawCheckpointWithMeta raw_checkpoints = 1; + repeated RawCheckpointWithMetaResponse raw_checkpoints = 1; // pagination defines the pagination in the response. cosmos.base.query.v1beta1.PageResponse pagination = 2; @@ -161,5 +162,54 @@ message QueryLastCheckpointWithStatusRequest { CheckpointStatus status = 1; } // QueryLastCheckpointWithStatusResponse is the response type for the // Query/LastCheckpointWithStatus RPC method. message QueryLastCheckpointWithStatusResponse { - RawCheckpoint raw_checkpoint = 1; + RawCheckpointResponse raw_checkpoint = 1; +} + +// RawCheckpointResponse wraps the BLS multi sig with metadata +message RawCheckpointResponse { + // epoch_num defines the epoch number the raw checkpoint is for + uint64 epoch_num = 1; + // block_hash_hex defines the 'BlockID.Hash', which is the hash of + // the block that individual BLS sigs are signed on as hex string + string block_hash_hex = 2; + // bitmap defines the bitmap that indicates the signers of the BLS multi sig + bytes bitmap = 3; + // bls_multi_sig defines the multi sig that is aggregated from individual BLS + // sigs + bytes bls_multi_sig = 4 [ + (gogoproto.customtype) = "github.com/babylonlabs-io/babylon/crypto/bls12381.Signature" + ]; +} + +// CheckpointStateUpdateResponse defines a state transition on the checkpoint. +message CheckpointStateUpdateResponse { + // state defines the event of a state transition towards this state + CheckpointStatus state = 1; + // status_desc respresents the description of status enum. + string status_desc = 2; + // block_height is the height of the Babylon block that triggers the state + // update + uint64 block_height = 3; + // block_time is the timestamp in the Babylon block that triggers the state + // update + google.protobuf.Timestamp block_time = 4 [ (gogoproto.stdtime) = true ]; +} + +// RawCheckpointWithMetaResponse wraps the raw checkpoint with metadata. +message RawCheckpointWithMetaResponse { + RawCheckpointResponse ckpt = 1; + // status defines the status of the checkpoint + CheckpointStatus status = 2; + // status_desc respresents the description of status enum. + string status_desc = 3; + // bls_aggr_pk defines the aggregated BLS public key + bytes bls_aggr_pk = 4 + [ (gogoproto.customtype) = + "github.com/babylonlabs-io/babylon/crypto/bls12381.PublicKey" ]; + // power_sum defines the accumulated voting power for the checkpoint + uint64 power_sum = 5; + // lifecycle defines the lifecycle of this checkpoint, i.e., each state + // transition and the time (in both timestamp and block height) of this + // transition. + repeated CheckpointStateUpdateResponse lifecycle = 6; } diff --git a/proto/babylon/checkpointing/v1/tx.proto b/proto/babylon/checkpointing/v1/tx.proto index bfc00666e..14709eee3 100644 --- a/proto/babylon/checkpointing/v1/tx.proto +++ b/proto/babylon/checkpointing/v1/tx.proto @@ -6,7 +6,7 @@ import "babylon/checkpointing/v1/bls_key.proto"; import "cosmos/staking/v1beta1/tx.proto"; import "cosmos/msg/v1/msg.proto"; -option go_package = "github.com/babylonchain/babylon/x/checkpointing/types"; +option go_package = "github.com/babylonlabs-io/babylon/x/checkpointing/types"; // Msg defines the checkpointing Msg service. service Msg { diff --git a/proto/babylon/epoching/v1/epoching.proto b/proto/babylon/epoching/v1/epoching.proto index 59382045e..a7f90c4a1 100644 --- a/proto/babylon/epoching/v1/epoching.proto +++ b/proto/babylon/epoching/v1/epoching.proto @@ -6,7 +6,7 @@ import "gogoproto/gogo.proto"; import "cosmos/staking/v1beta1/tx.proto"; import "cosmos/base/v1beta1/coin.proto"; -option go_package = "github.com/babylonchain/babylon/x/epoching/types"; +option go_package = "github.com/babylonlabs-io/babylon/x/epoching/types"; // Epoch is a structure that contains the metadata of an epoch message Epoch { @@ -22,17 +22,14 @@ message Epoch { // finalised. The last_block_time field is nil in the epoch's beginning, and // is set upon the end of this epoch. google.protobuf.Timestamp last_block_time = 4 [ (gogoproto.stdtime) = true ]; - // app_hash_root is the Merkle root of all AppHashs in this epoch - // It will be used for proving a block is in an epoch - bytes app_hash_root = 5; // 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 - bytes sealer_app_hash = 6; + bytes sealer_app_hash = 5; // 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 - bytes sealer_block_hash = 7; + bytes sealer_block_hash = 6; } // QueuedMessage is a message that can change the validator set and is delayed @@ -57,13 +54,6 @@ message QueuedMessage { } } -// QueuedMessageList is a message that contains a list of staking-related -// messages queued for an epoch -message QueuedMessageList { - uint64 epoch_number = 1; - repeated QueuedMessage msgs = 2; -} - // BondState is the bond state of a validator or delegation enum BondState { // CREATED is when the validator/delegation has been created @@ -78,14 +68,14 @@ enum BondState { REMOVED = 4; } -// ValStateUpdate is a messages that records a state update of a validator +// ValStateUpdate is a message that records a state update of a validator message ValStateUpdate { BondState state = 1; uint64 block_height = 2; google.protobuf.Timestamp block_time = 3 [ (gogoproto.stdtime) = true ]; } -// ValidatorLifecycle is a message that records records the lifecycle of +// ValidatorLifecycle is a message that records the lifecycle of // a validator message ValidatorLifecycle { string val_addr = 1; @@ -102,7 +92,7 @@ message DelegationStateUpdate { google.protobuf.Timestamp block_time = 5 [ (gogoproto.stdtime) = true ]; } -// ValidatorLifecycle is a message that records records the lifecycle of +// ValidatorLifecycle is a message that records the lifecycle of // a delegation message DelegationLifecycle { string del_addr = 1; diff --git a/proto/babylon/epoching/v1/events.proto b/proto/babylon/epoching/v1/events.proto index f41c527e3..79e0dfae2 100644 --- a/proto/babylon/epoching/v1/events.proto +++ b/proto/babylon/epoching/v1/events.proto @@ -3,7 +3,7 @@ package babylon.epoching.v1; import "gogoproto/gogo.proto"; -option go_package = "github.com/babylonchain/babylon/x/epoching/types"; +option go_package = "github.com/babylonlabs-io/babylon/x/epoching/types"; // EventBeginEpoch is the event emitted when an epoch has started message EventBeginEpoch { uint64 epoch_number = 1; } diff --git a/proto/babylon/epoching/v1/genesis.proto b/proto/babylon/epoching/v1/genesis.proto index eea522cba..f9c44d5b5 100644 --- a/proto/babylon/epoching/v1/genesis.proto +++ b/proto/babylon/epoching/v1/genesis.proto @@ -4,7 +4,7 @@ package babylon.epoching.v1; import "gogoproto/gogo.proto"; import "babylon/epoching/v1/params.proto"; -option go_package = "github.com/babylonchain/babylon/x/epoching/types"; +option go_package = "github.com/babylonlabs-io/babylon/x/epoching/types"; // GenesisState defines the epoching module's genesis state. message GenesisState { Params params = 1 [ (gogoproto.nullable) = false ]; } diff --git a/proto/babylon/epoching/v1/params.proto b/proto/babylon/epoching/v1/params.proto index a9ce9a531..b315f37ca 100644 --- a/proto/babylon/epoching/v1/params.proto +++ b/proto/babylon/epoching/v1/params.proto @@ -3,7 +3,7 @@ package babylon.epoching.v1; import "gogoproto/gogo.proto"; -option go_package = "github.com/babylonchain/babylon/x/epoching/types"; +option go_package = "github.com/babylonlabs-io/babylon/x/epoching/types"; // Params defines the parameters for the module. message Params { diff --git a/proto/babylon/epoching/v1/query.proto b/proto/babylon/epoching/v1/query.proto index f78acae35..7243da42c 100644 --- a/proto/babylon/epoching/v1/query.proto +++ b/proto/babylon/epoching/v1/query.proto @@ -2,12 +2,13 @@ syntax = "proto3"; package babylon.epoching.v1; import "gogoproto/gogo.proto"; +import "google/protobuf/timestamp.proto"; import "google/api/annotations.proto"; import "cosmos/base/query/v1beta1/pagination.proto"; import "babylon/epoching/v1/params.proto"; import "babylon/epoching/v1/epoching.proto"; -option go_package = "github.com/babylonchain/babylon/x/epoching/types"; +option go_package = "github.com/babylonlabs-io/babylon/x/epoching/types"; // Query defines the gRPC querier service. service Query { @@ -82,7 +83,7 @@ message QueryParamsResponse { message QueryEpochInfoRequest { uint64 epoch_num = 1; } // QueryEpochInfoRequest is the response type for the Query/EpochInfo method -message QueryEpochInfoResponse { babylon.epoching.v1.Epoch epoch = 1; } +message QueryEpochInfoResponse { EpochResponse epoch = 1; } // QueryEpochInfosRequest is the request type for the Query/EpochInfos method message QueryEpochsInfoRequest { @@ -92,7 +93,7 @@ message QueryEpochsInfoRequest { // QueryEpochsInfoResponse is the response type for the Query/EpochInfos method message QueryEpochsInfoResponse { - repeated babylon.epoching.v1.Epoch epochs = 1; + repeated EpochResponse epochs = 1; // pagination defines the pagination in the response cosmos.base.query.v1beta1.PageResponse pagination = 2; @@ -124,7 +125,7 @@ message QueryEpochMsgsRequest { // method message QueryEpochMsgsResponse { // msgs is the list of messages queued in the current epoch - repeated babylon.epoching.v1.QueuedMessage msgs = 1; + repeated QueuedMessageResponse msgs = 1; // pagination defines the pagination in the response cosmos.base.query.v1beta1.PageResponse pagination = 2; } @@ -144,9 +145,9 @@ message QueryLatestEpochMsgsRequest { // QueryLatestEpochMsgsResponse is the response type for the // Query/LatestEpochMsgs RPC method message QueryLatestEpochMsgsResponse { - // epoch_msg_map is a list of QueuedMessageList + // latest_epoch_msgs is a list of QueuedMessageList // each QueuedMessageList has a field identifying the epoch number - repeated babylon.epoching.v1.QueuedMessageList latest_epoch_msgs = 1; + repeated QueuedMessageList latest_epoch_msgs = 1; cosmos.base.query.v1beta1.PageResponse pagination = 2; } @@ -157,7 +158,10 @@ message QueryValidatorLifecycleRequest { string val_addr = 1; } // QueryValidatorLifecycleResponse is the response type for the // Query/ValidatorLifecycle RPC method -message QueryValidatorLifecycleResponse { ValidatorLifecycle val_life = 1; } +message QueryValidatorLifecycleResponse { + string val_addr = 1; + repeated ValStateUpdateResponse val_life = 2; +} // QueryDelegationLifecycleRequest is the request type for the // Query/DelegationLifecycle RPC method @@ -180,4 +184,59 @@ message QueryEpochValSetResponse { repeated babylon.epoching.v1.Validator validators = 1; int64 total_voting_power = 2; cosmos.base.query.v1beta1.PageResponse pagination = 3; -} \ No newline at end of file +} + +// EpochResponse is a structure that contains the metadata of an epoch +message EpochResponse { + // epoch_number is the number of this epoch + uint64 epoch_number = 1; + // current_epoch_interval is the epoch interval at the time of this epoch + uint64 current_epoch_interval = 2; + // first_block_height is the height of the first block in this epoch + uint64 first_block_height = 3; + // 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. + google.protobuf.Timestamp last_block_time = 4 [ (gogoproto.stdtime) = true ]; + // 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. + string sealer_app_hash_hex = 5; + // 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. + string sealer_block_hash = 6; +} + +// QueuedMessageResponse is a message that can change the validator set and is delayed +// to the end of an epoch +message QueuedMessageResponse { + // tx_id is the ID of the tx that contains the message as hex. + string tx_id = 1; + // msg_id is the original message ID, i.e., hash of the marshaled message as hex. + string msg_id = 2; + // block_height is the height when this msg is submitted to Babylon + uint64 block_height = 3; + // block_time is the timestamp when this msg is submitted to Babylon + google.protobuf.Timestamp block_time = 4 [ (gogoproto.stdtime) = true ]; + // msg is the actual message that is sent by a user and is queued by the + // epoching module as string. + string msg = 5; +} + +// QueuedMessageList is a message that contains a list of staking-related +// messages queued for an epoch +message QueuedMessageList { + uint64 epoch_number = 1; + repeated QueuedMessageResponse msgs = 2; +} + +// ValStateUpdateResponse is a message response that records a state update of a validator. +message ValStateUpdateResponse { + // StateDesc defines the descriptive state. + string state_desc = 1; + uint64 block_height = 2; + google.protobuf.Timestamp block_time = 3 [ (gogoproto.stdtime) = true ]; +} diff --git a/proto/babylon/epoching/v1/tx.proto b/proto/babylon/epoching/v1/tx.proto index 47f24da33..2157dea0c 100644 --- a/proto/babylon/epoching/v1/tx.proto +++ b/proto/babylon/epoching/v1/tx.proto @@ -8,7 +8,7 @@ import "babylon/epoching/v1/params.proto"; import "cosmos_proto/cosmos.proto"; import "cosmos/msg/v1/msg.proto"; -option go_package = "github.com/babylonchain/babylon/x/epoching/types"; +option go_package = "github.com/babylonlabs-io/babylon/x/epoching/types"; // Msg defines the Msg service. service Msg { diff --git a/proto/babylon/finality/v1/events.proto b/proto/babylon/finality/v1/events.proto index 61d7f6d5e..1c2fe0947 100644 --- a/proto/babylon/finality/v1/events.proto +++ b/proto/babylon/finality/v1/events.proto @@ -3,7 +3,7 @@ package babylon.finality.v1; import "babylon/finality/v1/finality.proto"; -option go_package = "github.com/babylonchain/babylon/x/finality/types"; +option go_package = "github.com/babylonlabs-io/babylon/x/finality/types"; // EventSlashedFinalityProvider is the event emitted when a finality provider is slashed // due to signing two conflicting blocks @@ -11,3 +11,17 @@ message EventSlashedFinalityProvider { // evidence is the evidence that the finality provider double signs Evidence evidence = 1; } + +// EventSluggishFinalityProviderDetected is the event emitted when a finality provider is +// detected as sluggish +message EventSluggishFinalityProviderDetected { + // public_key is the BTC public key of the finality provider + string public_key = 1; +} + +// EventSluggishFinalityProviderReverted is the event emitted when a sluggish finality +// provider is no longer considered sluggish +message EventSluggishFinalityProviderReverted { + // public_key is the BTC public key of the finality provider + string public_key = 1; +} diff --git a/proto/babylon/finality/v1/finality.proto b/proto/babylon/finality/v1/finality.proto index 5f2a3d159..f6f56f6d9 100644 --- a/proto/babylon/finality/v1/finality.proto +++ b/proto/babylon/finality/v1/finality.proto @@ -1,7 +1,7 @@ syntax = "proto3"; package babylon.finality.v1; -option go_package = "github.com/babylonchain/babylon/x/finality/types"; +option go_package = "github.com/babylonlabs-io/babylon/x/finality/types"; import "gogoproto/gogo.proto"; @@ -16,15 +16,28 @@ message IndexedBlock { bool finalized = 3; } +// PubRandCommit is a commitment to a series of public randomness +// currently, the commitment is a root of a Merkle tree that includes +// a series of public randomness +message PubRandCommit { + // start_height is the height of the first commitment + uint64 start_height = 1; + // num_pub_rand is the number of committed public randomness + uint64 num_pub_rand = 2; + // commitment is the value of the commitment + // currently, it is the root of the merkle tree constructed by the public randomness + bytes commitment = 3; +} + // Evidence is the evidence that a finality provider has signed finality // signatures with correct public randomness on two conflicting Babylon headers message Evidence { // fp_btc_pk is the BTC PK of the finality provider that casts this vote - bytes fp_btc_pk = 1 [ (gogoproto.customtype) = "github.com/babylonchain/babylon/types.BIP340PubKey" ]; + bytes fp_btc_pk = 1 [ (gogoproto.customtype) = "github.com/babylonlabs-io/babylon/types.BIP340PubKey" ]; // 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/babylonchain/babylon/types.SchnorrPubRand" ]; + 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 @@ -33,8 +46,20 @@ message Evidence { // 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/babylonchain/babylon/types.SchnorrEOTSSig" ]; + 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/babylonchain/babylon/types.SchnorrEOTSSig" ]; + bytes fork_finality_sig = 7 [ (gogoproto.customtype) = "github.com/babylonlabs-io/babylon/types.SchnorrEOTSSig" ]; +} + +// FinalityProviderSigningInfo defines a finality provider's signing info for monitoring their +// liveness activity. +message FinalityProviderSigningInfo { + // fp_btc_pk is the BTC PK of the finality provider that casts this vote + bytes fp_btc_pk = 1 [ (gogoproto.customtype) = "github.com/babylonlabs-io/babylon/types.BIP340PubKey" ]; + // 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; } diff --git a/proto/babylon/finality/v1/genesis.proto b/proto/babylon/finality/v1/genesis.proto index f33e6ed15..4e40c9bd0 100644 --- a/proto/babylon/finality/v1/genesis.proto +++ b/proto/babylon/finality/v1/genesis.proto @@ -3,10 +3,83 @@ package babylon.finality.v1; import "gogoproto/gogo.proto"; import "babylon/finality/v1/params.proto"; +import "babylon/finality/v1/finality.proto"; -option go_package = "github.com/babylonchain/babylon/x/finality/types"; +option go_package = "github.com/babylonlabs-io/babylon/x/finality/types"; // GenesisState defines the finality module's genesis state. message GenesisState { + // params the current params of the state. Params params = 1 [(gogoproto.nullable) = false]; + // indexed_blocks all the btc blocks and if their status are finalized. + repeated IndexedBlock indexed_blocks = 2; + // evidences all the evidences ever registered. + 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. + repeated PublicRandomness public_randomness = 5; + // pub_rand_commit contains all the public randomness commitment ever commited from the finality providers. + repeated PubRandCommitWithPK pub_rand_commit = 6; + // signing_infos represents a map between finality provider public key and their + // signing infos. + repeated SigningInfo signing_infos = 7 [(gogoproto.nullable) = false]; + // missed_blocks represents a map between finality provider public key and their + // missed blocks. + repeated FinalityProviderMissedBlocks missed_blocks = 8 [(gogoproto.nullable) = false]; +} + +// VoteSig the vote of an finality provider +// with the block of the vote, the finality provider btc public key and the vote signature. +message VoteSig { + // block_height is the height of the voted block. + 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" ]; + // finality_sig is the finality signature to this block + // where finality signature is an EOTS signature, i.e. + bytes finality_sig = 3 [ (gogoproto.customtype) = "github.com/babylonlabs-io/babylon/types.SchnorrEOTSSig" ]; +} + +// 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. + 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" ]; + // 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" ]; +} + +// PubRandCommitWithPK is the public randomness commitment with the finality provider's BTC public key +message PubRandCommitWithPK { + // fp_btc_pk is the BTC PK of the finality provider that commits the public randomness + bytes fp_btc_pk = 1 [ (gogoproto.customtype) = "github.com/babylonlabs-io/babylon/types.BIP340PubKey" ]; + // pub_rand_commit is the public randomness commitment + PubRandCommit pub_rand_commit = 2; +} + +// SigningInfo stores finality provider signing info of corresponding BTC public key. +message SigningInfo { + // fp_btc_pk is the BTC PK of the finality provider + bytes fp_btc_pk = 1 [ (gogoproto.customtype) = "github.com/babylonlabs-io/babylon/types.BIP340PubKey" ]; + // fp_signing_info represents the signing info of this finality provider. + FinalityProviderSigningInfo fp_signing_info = 2 [(gogoproto.nullable) = false]; +} + +// FinalityProviderMissedBlocks contains array of missed blocks of corresponding +// BTC public key. +message FinalityProviderMissedBlocks { + // fp_btc_pk is the BTC PK of the finality provider + bytes fp_btc_pk = 1 [ (gogoproto.customtype) = "github.com/babylonlabs-io/babylon/types.BIP340PubKey" ]; + // missed_blocks is an array of missed blocks by the finality provider. + repeated MissedBlock missed_blocks = 2 [(gogoproto.nullable) = false]; +} + +// MissedBlock contains height and missed status as boolean. +message MissedBlock { + // index is the height at which the block was missed. + int64 index = 1; + // missed is the missed status. + bool missed = 2; } diff --git a/proto/babylon/finality/v1/params.proto b/proto/babylon/finality/v1/params.proto index c5dce2cc9..875497283 100644 --- a/proto/babylon/finality/v1/params.proto +++ b/proto/babylon/finality/v1/params.proto @@ -2,14 +2,28 @@ syntax = "proto3"; package babylon.finality.v1; import "gogoproto/gogo.proto"; +import "amino/amino.proto"; +import "cosmos_proto/cosmos.proto"; -option go_package = "github.com/babylonchain/babylon/x/finality/types"; +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; - - // min_pub_rand is the minimum number of public randomness each + // signed_blocks_window defines the size of the sliding window for tracking finality provider liveness + int64 signed_blocks_window = 1; + // 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; + // 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 detected as sluggish + bytes min_signed_per_window = 3 [ + (cosmos_proto.scalar) = "cosmos.Dec", + (gogoproto.customtype) = "cosmossdk.io/math.LegacyDec", + (gogoproto.nullable) = false, + (amino.dont_omitempty) = true + ]; + // min_pub_rand is the minimum number of public randomness each // message should commit - uint64 min_pub_rand = 1; + uint64 min_pub_rand = 4; } diff --git a/proto/babylon/finality/v1/query.proto b/proto/babylon/finality/v1/query.proto index 7c618d127..7b6c9fb0b 100644 --- a/proto/babylon/finality/v1/query.proto +++ b/proto/babylon/finality/v1/query.proto @@ -7,7 +7,7 @@ import "cosmos/base/query/v1beta1/pagination.proto"; import "babylon/finality/v1/params.proto"; import "babylon/finality/v1/finality.proto"; -option go_package = "github.com/babylonchain/babylon/x/finality/types"; +option go_package = "github.com/babylonlabs-io/babylon/x/finality/types"; // Query defines the gRPC querier service. service Query { @@ -17,10 +17,19 @@ service Query { } // 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? rpc ListPublicRandomness(QueryListPublicRandomnessRequest) returns (QueryListPublicRandomnessResponse) { option (google.api.http).get = "/babylon/finality/v1/finality_providers/{fp_btc_pk_hex}/public_randomness_list"; } + // ListPubRandCommit is a range query for public randomness commitments of a given finality provider + rpc ListPubRandCommit(QueryListPubRandCommitRequest) returns (QueryListPubRandCommitResponse) { + option (google.api.http).get = "/babylon/finality/v1/finality_providers/{fp_btc_pk_hex}/pub_rand_commit_list"; + } + // Block queries a block at a given height rpc Block(QueryBlockRequest) returns (QueryBlockResponse) { option (google.api.http).get = "/babylon/finality/v1/blocks/{height}"; @@ -45,6 +54,16 @@ service Query { rpc ListEvidences(QueryListEvidencesRequest) returns (QueryListEvidencesResponse) { option (google.api.http).get = "/babylon/finality/v1/evidences"; } + + // SigningInfo queries the signing info of given finality provider BTC public key + rpc SigningInfo(QuerySigningInfoRequest) returns (QuerySigningInfoResponse) { + option (google.api.http).get = "/babylon/finality/v1/signing_infos/{fp_btc_pk_hex}"; + } + + // SigningInfos queries the signing info of all the active finality providers + rpc SigningInfos(QuerySigningInfosRequest) returns (QuerySigningInfosResponse) { + option (google.api.http).get = "/babylon/finality/v1/signing_infos"; + } } // QueryParamsRequest is request type for the Query/Params RPC method. @@ -71,12 +90,40 @@ message QueryListPublicRandomnessRequest { message QueryListPublicRandomnessResponse { // 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 - map pub_rand_map = 1 [(gogoproto.customtype) = "github.com/babylonchain/babylon/types.SchnorrPubRand" ]; + map pub_rand_map = 1 [(gogoproto.customtype) = "github.com/babylonlabs-io/babylon/types.SchnorrPubRand" ]; // pagination defines the pagination in the response. cosmos.base.query.v1beta1.PageResponse pagination = 2; } +// PubRandCommitResponse is the response type for a public randomness commitment +message PubRandCommitResponse { + // num_pub_rand is the number of committed public randomness + uint64 num_pub_rand = 1; + // commitment is the value of the commitment + bytes commitment = 2; +} + +// QueryListPubRandCommitRequest is the request type for the +// Query/ListPubRandCommit RPC method. +message QueryListPubRandCommitRequest { + // fp_btc_pk_hex is the hex str of Bitcoin secp256k1 PK of the finality provider + string fp_btc_pk_hex = 1; + + // pagination defines an optional pagination for the request. + cosmos.base.query.v1beta1.PageRequest pagination = 2; +} + +// QueryListPubRandCommitResponse is the response type for the +// Query/ListPubRandCommit RPC method. +message QueryListPubRandCommitResponse { + // 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 + map pub_rand_commit_map = 1; + + // pagination defines the pagination in the response. + cosmos.base.query.v1beta1.PageResponse pagination = 2; +} // QueriedBlockStatus is the status of blocks that the querier wants to query. enum QueriedBlockStatus { @@ -134,7 +181,7 @@ message QueryVotesAtHeightRequest { message QueryVotesAtHeightResponse { // 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 - repeated bytes btc_pks = 1 [(gogoproto.customtype) = "github.com/babylonchain/babylon/types.BIP340PubKey"]; + repeated bytes btc_pks = 1 [(gogoproto.customtype) = "github.com/babylonlabs-io/babylon/types.BIP340PubKey"]; } // QueryEvidenceRequest is the request type for the @@ -171,3 +218,32 @@ message QueryListEvidencesResponse { // pagination defines the pagination in the response. cosmos.base.query.v1beta1.PageResponse pagination = 2; } + +// QuerySigningInfoRequest is the request type for the Query/SigningInfo RPC +// method +message QuerySigningInfoRequest { + // fp_btc_pk_hex is the hex str of Bitcoin secp256k1 PK + // (in BIP340 format) of the finality provider + string fp_btc_pk_hex = 1; +} + +// 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]; +} + +// QuerySigningInfosRequest is the request type for the Query/SigningInfos RPC +// method +message QuerySigningInfosRequest { + cosmos.base.query.v1beta1.PageRequest pagination = 1; +} + +// QuerySigningInfosResponse is the response type for the Query/SigningInfos RPC +// method +message QuerySigningInfosResponse { + // info is the signing info of all finality providers with signing info + repeated FinalityProviderSigningInfo fp_signing_infos = 1 [(gogoproto.nullable) = false]; + cosmos.base.query.v1beta1.PageResponse pagination = 2; +} diff --git a/proto/babylon/finality/v1/tx.proto b/proto/babylon/finality/v1/tx.proto index 11a55fe31..fd46f9f3a 100644 --- a/proto/babylon/finality/v1/tx.proto +++ b/proto/babylon/finality/v1/tx.proto @@ -1,9 +1,10 @@ syntax = "proto3"; package babylon.finality.v1; -option go_package = "github.com/babylonchain/babylon/x/finality/types"; +option go_package = "github.com/babylonlabs-io/babylon/x/finality/types"; import "gogoproto/gogo.proto"; +import "tendermint/crypto/proof.proto"; import "cosmos_proto/cosmos.proto"; import "cosmos/msg/v1/msg.proto"; import "babylon/finality/v1/params.proto"; @@ -12,56 +13,63 @@ import "babylon/finality/v1/params.proto"; service Msg { option (cosmos.msg.v1.service) = true; - // AddFinalitySig adds a finality signature to a given block - rpc AddFinalitySig(MsgAddFinalitySig) returns (MsgAddFinalitySigResponse); // CommitPubRandList commits a list of public randomness for EOTS rpc CommitPubRandList(MsgCommitPubRandList) returns (MsgCommitPubRandListResponse); + // AddFinalitySig adds a finality signature to a given block + rpc AddFinalitySig(MsgAddFinalitySig) returns (MsgAddFinalitySigResponse); // TODO: msg for evidence of equivocation. this is not specified yet // UpdateParams updates the finality module parameters. rpc UpdateParams(MsgUpdateParams) returns (MsgUpdateParamsResponse); } +// MsgCommitPubRandList defines a message for committing a list of public randomness for EOTS +message MsgCommitPubRandList { + option (cosmos.msg.v1.signer) = "signer"; + + string signer = 1; + // fp_btc_pk is the BTC PK of the finality provider that commits the public randomness + bytes fp_btc_pk = 2 [ (gogoproto.customtype) = "github.com/babylonlabs-io/babylon/types.BIP340PubKey" ]; + // start_height is the start block height of the list of public randomness + uint64 start_height = 3; + // num_pub_rand is the number of public randomness committed + uint64 num_pub_rand = 4; + // commitment is the commitment of these public randomness + // currently it's the root of the Merkle tree that includes these public randomness + bytes commitment = 5; + // sig is the signature on (start_height || num_pub_rand || commitment) signed by + // SK corresponding to fp_btc_pk. This prevents others to commit public + // randomness on behalf of fp_btc_pk + // TODO: another option is to restrict signer to correspond to fp_btc_pk. This restricts + // the tx submitter to be the holder of fp_btc_pk. Decide this later + bytes sig = 6 [ (gogoproto.customtype) = "github.com/babylonlabs-io/babylon/types.BIP340Signature" ]; +} +// MsgCommitPubRandListResponse is the response to the MsgCommitPubRandList message +message MsgCommitPubRandListResponse{} + // MsgAddFinalitySig defines a message for adding a finality vote message MsgAddFinalitySig { option (cosmos.msg.v1.signer) = "signer"; string signer = 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/babylonchain/babylon/types.BIP340PubKey" ]; + bytes fp_btc_pk = 2 [ (gogoproto.customtype) = "github.com/babylonlabs-io/babylon/types.BIP340PubKey" ]; // block_height is the height of the voted block uint64 block_height = 3; + // pub_rand is the public randomness committed at this height + bytes pub_rand = 4 [ (gogoproto.customtype) = "github.com/babylonlabs-io/babylon/types.SchnorrPubRand" ]; + // proof is the proof that the given public randomness is committed under the commitment + tendermint.crypto.Proof proof = 5; // block_app_hash is the AppHash of the voted block - bytes block_app_hash = 4; + bytes block_app_hash = 6; // finality_sig is the finality signature to this 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 finality_sig = 5 [ (gogoproto.customtype) = "github.com/babylonchain/babylon/types.SchnorrEOTSSig" ]; + bytes finality_sig = 7 [ (gogoproto.customtype) = "github.com/babylonlabs-io/babylon/types.SchnorrEOTSSig" ]; } // MsgAddFinalitySigResponse is the response to the MsgAddFinalitySig message message MsgAddFinalitySigResponse{} -// MsgCommitPubRandList defines a message for committing a list of public randomness for EOTS -message MsgCommitPubRandList { - option (cosmos.msg.v1.signer) = "signer"; - - string signer = 1; - // fp_btc_pk is the BTC PK of the finality provider that commits the public randomness - bytes fp_btc_pk = 2 [ (gogoproto.customtype) = "github.com/babylonchain/babylon/types.BIP340PubKey" ]; - // start_height is the start block height of the list of public randomness - uint64 start_height = 3; - // pub_rand_list is the list of public randomness - repeated bytes pub_rand_list = 4 [ (gogoproto.customtype) = "github.com/babylonchain/babylon/types.SchnorrPubRand" ]; - // sig is the signature on (start_height || pub_rand_list) signed by - // SK corresponding to fp_btc_pk. This prevents others to commit public - // randomness on behalf of fp_btc_pk - // TODO: another option is to restrict signer to correspond to fp_btc_pk. This restricts - // the tx submitter to be the holder of fp_btc_pk. Decide this later - bytes sig = 5 [ (gogoproto.customtype) = "github.com/babylonchain/babylon/types.BIP340Signature" ]; -} -// MsgCommitPubRandListResponse is the response to the MsgCommitPubRandList message -message MsgCommitPubRandListResponse{} - // MsgUpdateParams defines a message for updating finality module parameters. message MsgUpdateParams { option (cosmos.msg.v1.signer) = "authority"; diff --git a/proto/babylon/incentive/genesis.proto b/proto/babylon/incentive/genesis.proto index 04f82d21a..efe84b06f 100644 --- a/proto/babylon/incentive/genesis.proto +++ b/proto/babylon/incentive/genesis.proto @@ -4,7 +4,7 @@ package babylon.incentive; import "gogoproto/gogo.proto"; import "babylon/incentive/params.proto"; -option go_package = "github.com/babylonchain/babylon/x/incentive/types"; +option go_package = "github.com/babylonlabs-io/babylon/x/incentive/types"; // GenesisState defines the incentive module's genesis state. message GenesisState { diff --git a/proto/babylon/incentive/incentive.proto b/proto/babylon/incentive/incentive.proto index ccc4c3a6c..1e606919f 100644 --- a/proto/babylon/incentive/incentive.proto +++ b/proto/babylon/incentive/incentive.proto @@ -4,7 +4,7 @@ package babylon.incentive; import "gogoproto/gogo.proto"; import "cosmos/base/v1beta1/coin.proto"; -option go_package = "github.com/babylonchain/babylon/x/incentive/types"; +option go_package = "github.com/babylonlabs-io/babylon/x/incentive/types"; // Gauge is an object that stores rewards to be distributed // code adapted from https://github.com/osmosis-labs/osmosis/blob/v18.0.0/proto/osmosis/incentives/gauge.proto diff --git a/proto/babylon/incentive/params.proto b/proto/babylon/incentive/params.proto index c576cb9a4..8f5f6d54a 100644 --- a/proto/babylon/incentive/params.proto +++ b/proto/babylon/incentive/params.proto @@ -4,7 +4,7 @@ package babylon.incentive; import "gogoproto/gogo.proto"; import "cosmos_proto/cosmos.proto"; -option go_package = "github.com/babylonchain/babylon/x/incentive/types"; +option go_package = "github.com/babylonlabs-io/babylon/x/incentive/types"; // Params defines the parameters for the module, including portions of rewards // distributed to each type of stakeholder. Note that sum of the portions should diff --git a/proto/babylon/incentive/query.proto b/proto/babylon/incentive/query.proto index 22985e390..f31a511cb 100644 --- a/proto/babylon/incentive/query.proto +++ b/proto/babylon/incentive/query.proto @@ -6,25 +6,25 @@ import "google/api/annotations.proto"; import "babylon/incentive/params.proto"; import "babylon/incentive/incentive.proto"; -option go_package = "github.com/babylonchain/babylon/x/incentive/types"; +option go_package = "github.com/babylonlabs-io/babylon/x/incentive/types"; // Query defines the gRPC querier service. service Query { // Parameters queries the parameters of the module. rpc Params(QueryParamsRequest) returns (QueryParamsResponse) { - option (google.api.http).get = "/babylonchain/babylon/incentive/params"; + option (google.api.http).get = "/babylon/incentive/params"; } // RewardGauge queries the reward gauge of a given stakeholder address rpc RewardGauges(QueryRewardGaugesRequest) returns (QueryRewardGaugesResponse) { - option (google.api.http).get = "/babylonchain/babylon/incentive/address/{address}/reward_gauge"; + option (google.api.http).get = "/babylon/incentive/address/{address}/reward_gauge"; } // BTCStakingGauge queries the BTC staking gauge of a given height rpc BTCStakingGauge(QueryBTCStakingGaugeRequest) returns (QueryBTCStakingGaugeResponse) { - option (google.api.http).get = "/babylonchain/babylon/incentive/btc_staking_gauge/{height}"; + 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 = "/babylonchain/babylon/incentive/btc_timestamping_gauge/{epoch_num}"; + option (google.api.http).get = "/babylon/incentive/btc_timestamping_gauge/{epoch_num}"; } } @@ -72,4 +72,4 @@ message QueryBTCTimestampingGaugeRequest { message QueryBTCTimestampingGaugeResponse { // gauge is the BTC timestamping gauge at the queried epoch Gauge gauge = 1; -} \ No newline at end of file +} diff --git a/proto/babylon/incentive/tx.proto b/proto/babylon/incentive/tx.proto index 965147bd5..13810102e 100644 --- a/proto/babylon/incentive/tx.proto +++ b/proto/babylon/incentive/tx.proto @@ -7,7 +7,7 @@ import "cosmos/msg/v1/msg.proto"; import "cosmos/base/v1beta1/coin.proto"; import "babylon/incentive/params.proto"; -option go_package = "github.com/babylonchain/babylon/x/incentive/types"; +option go_package = "github.com/babylonlabs-io/babylon/x/incentive/types"; // Msg defines the Msg service. service Msg { diff --git a/proto/babylon/monitor/v1/genesis.proto b/proto/babylon/monitor/v1/genesis.proto index 66a259f15..b1e60078d 100644 --- a/proto/babylon/monitor/v1/genesis.proto +++ b/proto/babylon/monitor/v1/genesis.proto @@ -1,7 +1,7 @@ syntax = "proto3"; package babylon.monitor.v1; -option go_package = "github.com/babylonchain/babylon/x/monitor/types"; +option go_package = "github.com/babylonlabs-io/babylon/x/monitor/types"; // GenesisState defines the monitor module's genesis state. message GenesisState {} diff --git a/proto/babylon/monitor/v1/query.proto b/proto/babylon/monitor/v1/query.proto index 622305a34..c77bfc8f2 100644 --- a/proto/babylon/monitor/v1/query.proto +++ b/proto/babylon/monitor/v1/query.proto @@ -3,7 +3,7 @@ package babylon.monitor.v1; import "google/api/annotations.proto"; -option go_package = "github.com/babylonchain/babylon/x/monitor/types"; +option go_package = "github.com/babylonlabs-io/babylon/x/monitor/types"; // Query defines the gRPC querier service. service Query { diff --git a/proto/babylon/zoneconcierge/v1/genesis.proto b/proto/babylon/zoneconcierge/v1/genesis.proto index 468fa02eb..8277e9e8a 100644 --- a/proto/babylon/zoneconcierge/v1/genesis.proto +++ b/proto/babylon/zoneconcierge/v1/genesis.proto @@ -4,7 +4,7 @@ package babylon.zoneconcierge.v1; import "gogoproto/gogo.proto"; import "babylon/zoneconcierge/v1/params.proto"; -option go_package = "github.com/babylonchain/babylon/x/zoneconcierge/types"; +option go_package = "github.com/babylonlabs-io/babylon/x/zoneconcierge/types"; // GenesisState defines the zoneconcierge module's genesis state. message GenesisState { diff --git a/proto/babylon/zoneconcierge/v1/packet.proto b/proto/babylon/zoneconcierge/v1/packet.proto index a9b4ef163..9576b951c 100644 --- a/proto/babylon/zoneconcierge/v1/packet.proto +++ b/proto/babylon/zoneconcierge/v1/packet.proto @@ -7,7 +7,7 @@ import "babylon/btclightclient/v1/btclightclient.proto"; import "babylon/epoching/v1/epoching.proto"; import "babylon/zoneconcierge/v1/zoneconcierge.proto"; -option go_package = "github.com/babylonchain/babylon/x/zoneconcierge/types"; +option go_package = "github.com/babylonlabs-io/babylon/x/zoneconcierge/types"; // ZoneconciergePacketData is the message that defines the IBC packets of // ZoneConcierge diff --git a/proto/babylon/zoneconcierge/v1/params.proto b/proto/babylon/zoneconcierge/v1/params.proto index bb3e23738..48fa6c9e5 100644 --- a/proto/babylon/zoneconcierge/v1/params.proto +++ b/proto/babylon/zoneconcierge/v1/params.proto @@ -3,7 +3,7 @@ package babylon.zoneconcierge.v1; import "gogoproto/gogo.proto"; -option go_package = "github.com/babylonchain/babylon/x/zoneconcierge/types"; +option go_package = "github.com/babylonlabs-io/babylon/x/zoneconcierge/types"; // Params defines the parameters for the module. message Params { diff --git a/proto/babylon/zoneconcierge/v1/query.proto b/proto/babylon/zoneconcierge/v1/query.proto index aa65a805f..690ab0182 100644 --- a/proto/babylon/zoneconcierge/v1/query.proto +++ b/proto/babylon/zoneconcierge/v1/query.proto @@ -10,7 +10,7 @@ import "babylon/epoching/v1/epoching.proto"; import "babylon/zoneconcierge/v1/zoneconcierge.proto"; import "babylon/zoneconcierge/v1/params.proto"; -option go_package = "github.com/babylonchain/babylon/x/zoneconcierge/types"; +option go_package = "github.com/babylonlabs-io/babylon/x/zoneconcierge/types"; // Query defines the gRPC querier service. service Query { diff --git a/proto/babylon/zoneconcierge/v1/tx.proto b/proto/babylon/zoneconcierge/v1/tx.proto index 105a29107..5e94ee9f4 100644 --- a/proto/babylon/zoneconcierge/v1/tx.proto +++ b/proto/babylon/zoneconcierge/v1/tx.proto @@ -7,7 +7,7 @@ import "cosmos_proto/cosmos.proto"; import "cosmos/msg/v1/msg.proto"; import "babylon/zoneconcierge/v1/params.proto"; -option go_package = "github.com/babylonchain/babylon/x/zoneconcierge/types"; +option go_package = "github.com/babylonlabs-io/babylon/x/zoneconcierge/types"; // Msg defines the Msg service. service Msg { diff --git a/proto/babylon/zoneconcierge/v1/zoneconcierge.proto b/proto/babylon/zoneconcierge/v1/zoneconcierge.proto index 7d37d7b30..b6c1dde8c 100644 --- a/proto/babylon/zoneconcierge/v1/zoneconcierge.proto +++ b/proto/babylon/zoneconcierge/v1/zoneconcierge.proto @@ -10,7 +10,7 @@ import "babylon/checkpointing/v1/checkpoint.proto"; import "babylon/epoching/v1/epoching.proto"; import "babylon/btclightclient/v1/btclightclient.proto"; -option go_package = "github.com/babylonchain/babylon/x/zoneconcierge/types"; +option go_package = "github.com/babylonlabs-io/babylon/x/zoneconcierge/types"; // IndexedHeader is the metadata of a CZ header message IndexedHeader { @@ -72,6 +72,16 @@ message ChainInfo { uint64 timestamped_headers_count = 4; } +// ChainInfoWithProof is the chain info with a proof that the latest header in +// the chain info is included in the epoch +message ChainInfoWithProof { + ChainInfo chain_info = 1; + // proof_header_in_epoch is an inclusion proof that the latest_header in chain_info + // is committed to `app_hash` of the sealer header of latest_header.babylon_epoch + // this field is optional + tendermint.crypto.ProofOps proof_header_in_epoch = 2; +} + // FinalizedChainInfo is the information of a CZ that is BTC-finalised message FinalizedChainInfo { // chain_id is the ID of the chain @@ -99,7 +109,7 @@ message FinalizedChainInfo { // - 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 -// - The epoch medatata is committed to the `app_hash` of the sealer header +// - The epoch metadata is committed to the `app_hash` of the sealer header // - The validator set is committed to the `app_hash` of the sealer header message ProofEpochSealed { // validator_set is the validator set of the sealed epoch diff --git a/proto/scripts/protocgen.sh b/proto/scripts/protocgen.sh index 9cbce2e51..a61d0e936 100755 --- a/proto/scripts/protocgen.sh +++ b/proto/scripts/protocgen.sh @@ -16,7 +16,7 @@ done cd .. # move proto files to the right places -cp -r github.com/babylonchain/babylon/* ./ +cp -r github.com/babylonlabs-io/babylon/* ./ rm -rf github.com go mod tidy -compat=1.21 diff --git a/scripts/update_changelog.sh b/scripts/update_changelog.sh new file mode 100755 index 000000000..cb3e3674a --- /dev/null +++ b/scripts/update_changelog.sh @@ -0,0 +1,89 @@ +#!/bin/bash +# This is a wrapper around `github_changelog_generator` (https://github.com/github-changelog-generator) +# to simplify / automate updating of the CHANGELOG.md file. +# +# Originally developed for CosmWasm cw_plus (https://github.com/CosmWasm/cw-plus) repository. +set -o errexit -o pipefail + +ORIGINAL_OPTS=$* +# Requires getopt from util-linux 2.37.4 (brew install gnu-getopt on Mac) +OPTS=$(getopt -l "help,release-branch:,since-tag:,upcoming-tag:,full,token:" -o "hu:ft" -- "$@") || exit 1 + +function print_usage() { + echo -e "Usage: $0 [-h|--help] [-f|--full] [--release-branch ] [--since-tag ] [-u|--upcoming-tag] [-t|--token ] + +-h, --help Display help +-f, --full Process changes since the beginning (by default: since latest git version tag) +--release-branch Limit pull requests to the release branch . +--since-tag Process changes since git version tag (by default: since latest git version tag) +-u, --upcoming-tag Add a title in CHANGELOG for the new changes +--token Pass changelog github token " +} + +function remove_opt() { + ORIGINAL_OPTS=$(echo "$ORIGINAL_OPTS" | sed "s/\\B$1\\b//") +} + +eval set -- "$OPTS" +while true +do +case $1 in + -h|--help) + print_usage + exit 0 + ;; + --since-tag) + shift + TAG="$1" + ;; + -f|--full) + TAG="" + remove_opt $1 + ;; + -u|--upcoming-tag) + remove_opt $1 + shift + UPCOMING_TAG="$1" + remove_opt $1 + ;; + --) + shift + break + ;; +esac +shift +done + +# Get user and repo from ./.git/config +ORIGIN_URL=$(git config --local remote.origin.url) +GITHUB_USER=$(echo $ORIGIN_URL | sed -n 's#.*:\([^\/]*\)\/.*#\1#p') +echo "Github user: $GITHUB_USER" +GITHUB_REPO=$(echo $ORIGIN_URL | sed -n 's#.*/\(.*\)\.git#\1#p') +echo "Github repo: $GITHUB_REPO" + +if [ -z "$TAG" ] +then + # Use latest git version tag + TAG=$(git tag --sort=creatordate | grep -E '^v[0-9]+\.[0-9]+\.[0-9]+' | tail -1) + ORIGINAL_OPTS="$ORIGINAL_OPTS --since-tag $TAG" +fi + +echo "Git version tag: $TAG" + +cp CHANGELOG.md /tmp/CHANGELOG.md.$$ +# Consolidate tag for matching changelog entries +TAG=$(echo "$TAG" | sed -e 's/-\([A-Za-z]*\)[^A-Za-z]*/-\1/' -e 's/-$//') +echo "Consolidated tag: $TAG" +sed -i -n "/^## \\[${TAG}[^]]*\\]/,\$p" CHANGELOG.md + +echo github_changelog_generator -u $GITHUB_USER -p $GITHUB_REPO --base CHANGELOG.md $ORIGINAL_OPTS || cp /tmp/CHANGELOG.md.$$ CHANGELOG.md +github_changelog_generator -u $GITHUB_USER -p $GITHUB_REPO --base CHANGELOG.md $ORIGINAL_OPTS || cp /tmp/CHANGELOG.md.$$ CHANGELOG.md + +if [ -n "$UPCOMING_TAG" ] +then + # Add "upcoming" version tag + TODAY=$(date "+%Y-%m-%d") + sed -i "s+\[Full Changelog\](https://github.com/$GITHUB_USER/$GITHUB_REPO/compare/\(.*\)\.\.\.HEAD)+[Full Changelog](https://github.com/$GITHUB_USER/$GITHUB_REPO/compare/$UPCOMING_TAG...HEAD)\n\n## [$UPCOMING_TAG](https://github.com/$GITHUB_USER/$GITHUB_REPO/tree/$UPCOMING_TAG) ($TODAY)\n\n[Full Changelog](https://github.com/$GITHUB_USER/$GITHUB_REPO/compare/\1...$UPCOMING_TAG)+" CHANGELOG.md +fi + +rm -f /tmp/CHANGELOG.md.$$ diff --git a/test/e2e/README.md b/test/e2e/README.md index d29a6539a..dacd487f7 100644 --- a/test/e2e/README.md +++ b/test/e2e/README.md @@ -9,7 +9,7 @@ approach. ### Wasm contract used for e2e testing -Wasm contract located in `bytecode/babylon_contract.wasm` is compiled from most recent commit `main` branch - https://github.com/babylonchain/babylon-contract +Wasm contract located in `bytecode/babylon_contract.wasm` is compiled from most recent commit `main` branch - https://github.com/babylonlabs-io/babylon-contract This contract uses feature specific to Babylon, through Babylon bindings library. diff --git a/test/e2e/btc_staking_e2e_test.go b/test/e2e/btc_staking_e2e_test.go index ffd19b59e..d4bcf2775 100644 --- a/test/e2e/btc_staking_e2e_test.go +++ b/test/e2e/btc_staking_e2e_test.go @@ -1,6 +1,8 @@ package e2e import ( + "encoding/hex" + "fmt" "math" "math/rand" "time" @@ -9,20 +11,23 @@ import ( "github.com/btcsuite/btcd/btcutil" "github.com/btcsuite/btcd/chaincfg" "github.com/btcsuite/btcd/wire" - "github.com/cosmos/cosmos-sdk/crypto/keys/secp256k1" - sdk "github.com/cosmos/cosmos-sdk/types" "github.com/stretchr/testify/suite" - "github.com/babylonchain/babylon/crypto/eots" - "github.com/babylonchain/babylon/test/e2e/configurer" - "github.com/babylonchain/babylon/test/e2e/initialization" - "github.com/babylonchain/babylon/test/e2e/util" - "github.com/babylonchain/babylon/testutil/datagen" - bbn "github.com/babylonchain/babylon/types" - btcctypes "github.com/babylonchain/babylon/x/btccheckpoint/types" - bstypes "github.com/babylonchain/babylon/x/btcstaking/types" - ftypes "github.com/babylonchain/babylon/x/finality/types" - itypes "github.com/babylonchain/babylon/x/incentive/types" + sdkmath "cosmossdk.io/math" + feegrantcli "cosmossdk.io/x/feegrant/client/cli" + sdk "github.com/cosmos/cosmos-sdk/types" + + "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" + ftypes "github.com/babylonlabs-io/babylon/x/finality/types" + itypes "github.com/babylonlabs-io/babylon/x/incentive/types" ) var ( @@ -30,7 +35,7 @@ var ( net = &chaincfg.SimNetParams // finality provider fpBTCSK, _, _ = datagen.GenRandomBTCKeyPair(r) - fp *bstypes.FinalityProvider + cacheFP *bstypes.FinalityProvider // BTC delegation delBTCSK, delBTCPK, _ = datagen.GenRandomBTCKeyPair(r) // covenant @@ -74,21 +79,7 @@ func (s *BTCStakingTestSuite) Test1CreateFinalityProviderAndDelegation() { nonValidatorNode, err := chainA.GetNodeAtIndex(2) s.NoError(err) - /* - create a random finality provider on Babylon - */ - // NOTE: we use the node's secret key as Babylon secret key for the finality provider - fp, err = datagen.GenRandomFinalityProviderWithBTCBabylonSKs(r, fpBTCSK, nonValidatorNode.SecretKey) - s.NoError(err) - nonValidatorNode.CreateFinalityProvider(fp.BabylonPk, fp.BtcPk, fp.Pop, fp.Description.Moniker, fp.Description.Identity, fp.Description.Website, fp.Description.SecurityContact, fp.Description.Details, fp.Commission) - - // wait for a block so that above txs take effect - nonValidatorNode.WaitForNextBlock() - - // query the existence of finality provider and assert equivalence - actualFps := nonValidatorNode.QueryFinalityProviders() - s.Len(actualFps, 1) - s.Equal(util.Cdc.MustMarshal(fp), util.Cdc.MustMarshal(actualFps[0])) + cacheFP = s.CreateNodeFP(nonValidatorNode) /* create a random BTC delegation under this finality provider @@ -99,85 +90,24 @@ func (s *BTCStakingTestSuite) Test1CreateFinalityProviderAndDelegation() { // minimal required unbonding time unbondingTime := uint16(initialization.BabylonBtcFinalizationPeriod) + 1 - // get covenant BTC PKs - covenantBTCPKs := []*btcec.PublicKey{} - for _, covenantPK := range params.CovenantPks { - covenantBTCPKs = append(covenantBTCPKs, covenantPK.MustToBTCPK()) - } - // NOTE: we use the node's secret key as Babylon secret key for the BTC delegation - delBabylonSK := nonValidatorNode.SecretKey - pop, err := bstypes.NewPoP(delBabylonSK, delBTCSK) + // NOTE: we use the node's address for the BTC delegation + stakerAddr := sdk.MustAccAddressFromBech32(nonValidatorNode.PublicAddress) + pop, err := bstypes.NewPoPBTC(stakerAddr, delBTCSK) s.NoError(err) + // generate staking tx and slashing tx stakingTimeBlocks := uint16(math.MaxUint16) - testStakingInfo := datagen.GenBTCStakingSlashingInfo( - r, - s.T(), - net, - delBTCSK, - []*btcec.PublicKey{fp.BtcPk.MustToBTCPK()}, - covenantBTCPKs, - covenantQuorum, - stakingTimeBlocks, - stakingValue, - params.SlashingAddress, - params.SlashingRate, - unbondingTime, - ) - - stakingMsgTx := testStakingInfo.StakingTx - stakingTxHash := stakingMsgTx.TxHash().String() - stakingSlashingPathInfo, err := testStakingInfo.StakingInfo.SlashingPathSpendInfo() - s.NoError(err) - - // generate proper delegator sig - delegatorSig, err := testStakingInfo.SlashingTx.Sign( - stakingMsgTx, - datagen.StakingOutIdx, - stakingSlashingPathInfo.GetPkScriptPath(), - delBTCSK, - ) - s.NoError(err) + testStakingInfo, stakingTxInfo, testUnbondingInfo, delegatorSig := s.BTCStakingUnbondSlashInfo(nonValidatorNode, params, stakingTimeBlocks, cacheFP) - // submit staking tx to Bitcoin and get inclusion proof - currentBtcTip, err := nonValidatorNode.QueryTip() - s.NoError(err) - blockWithStakingTx := datagen.CreateBlockWithTransaction(r, currentBtcTip.Header.ToBlockHeader(), stakingMsgTx) - nonValidatorNode.InsertHeader(&blockWithStakingTx.HeaderBytes) - // make block k-deep - for i := 0; i < initialization.BabylonBtcConfirmationPeriod; i++ { - nonValidatorNode.InsertNewEmptyBtcHeader(r) - } - stakingTxInfo := btcctypes.NewTransactionInfoFromSpvProof(blockWithStakingTx.SpvProof) - - // generate BTC undelegation stuff - stkTxHash := testStakingInfo.StakingTx.TxHash() - unbondingValue := stakingValue - datagen.UnbondingTxFee // TODO: parameterise fee - testUnbondingInfo := datagen.GenBTCUnbondingSlashingInfo( - r, - s.T(), - net, - delBTCSK, - []*btcec.PublicKey{fp.BtcPk.MustToBTCPK()}, - covenantBTCPKs, - covenantQuorum, - wire.NewOutPoint(&stkTxHash, datagen.StakingOutIdx), - stakingTimeBlocks, - unbondingValue, - params.SlashingAddress, - params.SlashingRate, - unbondingTime, - ) delUnbondingSlashingSig, err := testUnbondingInfo.GenDelSlashingTxSig(delBTCSK) s.NoError(err) // submit the message for creating BTC delegation nonValidatorNode.CreateBTCDelegation( - delBabylonSK.PubKey().(*secp256k1.PubKey), bbn.NewBIP340PubKeyFromBTCPK(delBTCPK), pop, stakingTxInfo, - fp.BtcPk, + cacheFP.BtcPk, stakingTimeBlocks, btcutil.Amount(stakingValue), testStakingInfo.SlashingTx, @@ -185,15 +115,16 @@ func (s *BTCStakingTestSuite) Test1CreateFinalityProviderAndDelegation() { testUnbondingInfo.UnbondingTx, testUnbondingInfo.SlashingTx, uint16(unbondingTime), - btcutil.Amount(unbondingValue), + btcutil.Amount(testUnbondingInfo.UnbondingInfo.UnbondingOutput.Value), delUnbondingSlashingSig, + nonValidatorNode.WalletName, + false, ) // wait for a block so that above txs take effect nonValidatorNode.WaitForNextBlock() - nonValidatorNode.WaitForNextBlock() - pendingDelSet := nonValidatorNode.QueryFinalityProviderDelegations(fp.BtcPk.MarshalHex()) + pendingDelSet := nonValidatorNode.QueryFinalityProviderDelegations(cacheFP.BtcPk.MarshalHex()) s.Len(pendingDelSet, 1) pendingDels := pendingDelSet[0] s.Len(pendingDels.Dels, 1) @@ -201,8 +132,9 @@ func (s *BTCStakingTestSuite) Test1CreateFinalityProviderAndDelegation() { s.Len(pendingDels.Dels[0].CovenantSigs, 0) // check delegation - delegation := nonValidatorNode.QueryBtcDelegation(stakingTxHash) + delegation := nonValidatorNode.QueryBtcDelegation(testStakingInfo.StakingTx.TxHash().String()) s.NotNil(delegation) + s.Equal(delegation.BtcDelegation.StakerAddr, nonValidatorNode.PublicAddress) } // Test2SubmitCovenantSignature is an end-to-end test for user @@ -214,15 +146,18 @@ func (s *BTCStakingTestSuite) Test2SubmitCovenantSignature() { s.NoError(err) // get last BTC delegation - pendingDelsSet := nonValidatorNode.QueryFinalityProviderDelegations(fp.BtcPk.MarshalHex()) + pendingDelsSet := nonValidatorNode.QueryFinalityProviderDelegations(cacheFP.BtcPk.MarshalHex()) s.Len(pendingDelsSet, 1) pendingDels := pendingDelsSet[0] s.Len(pendingDels.Dels, 1) - pendingDel := pendingDels.Dels[0] + 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() @@ -296,10 +231,14 @@ func (s *BTCStakingTestSuite) Test2SubmitCovenantSignature() { nonValidatorNode.WaitForNextBlock() // ensure the BTC delegation has covenant sigs now - activeDelsSet := nonValidatorNode.QueryFinalityProviderDelegations(fp.BtcPk.MarshalHex()) + activeDelsSet := nonValidatorNode.QueryFinalityProviderDelegations(cacheFP.BtcPk.MarshalHex()) s.Len(activeDelsSet, 1) - activeDels := activeDelsSet[0] + + activeDels, err := ParseRespsBTCDelToBTCDel(activeDelsSet[0]) + s.NoError(err) + s.NotNil(activeDels) s.Len(activeDels.Dels, 1) + activeDel := activeDels.Dels[0] s.True(activeDel.HasCovenantQuorums(covenantQuorum)) @@ -336,23 +275,26 @@ func (s *BTCStakingTestSuite) Test3CommitPublicRandomnessAndSubmitFinalitySignat commit a number of public randomness since activatedHeight */ // commit public randomness list - srList, msgCommitPubRandList, err := datagen.GenRandomMsgCommitPubRandList(r, fpBTCSK, activatedHeight, 100) + numPubRand := uint64(100) + randListInfo, msgCommitPubRandList, err := datagen.GenRandomMsgCommitPubRandList(r, fpBTCSK, activatedHeight, numPubRand) s.NoError(err) nonValidatorNode.CommitPubRandList( msgCommitPubRandList.FpBtcPk, msgCommitPubRandList.StartHeight, - msgCommitPubRandList.PubRandList, + msgCommitPubRandList.NumPubRand, + msgCommitPubRandList.Commitment, msgCommitPubRandList.Sig, ) // ensure public randomness list is eventually committed nonValidatorNode.WaitForNextBlock() - var pubRandMap map[uint64]*bbn.SchnorrPubRand + var prCommitMap map[uint64]*ftypes.PubRandCommitResponse s.Eventually(func() bool { - pubRandMap = nonValidatorNode.QueryListPublicRandomness(fp.BtcPk) - return len(pubRandMap) > 0 + prCommitMap = nonValidatorNode.QueryListPubRandCommit(cacheFP.BtcPk) + return len(prCommitMap) > 0 }, time.Minute, time.Second*5) - s.Equal(pubRandMap[activatedHeight].MustMarshal(), msgCommitPubRandList.PubRandList[0].MustMarshal()) + s.Equal(prCommitMap[activatedHeight].NumPubRand, msgCommitPubRandList.NumPubRand) + s.Equal(prCommitMap[activatedHeight].Commitment, msgCommitPubRandList.Commitment) // no reward gauge for finality provider and delegation yet fpBabylonAddr := sdk.AccAddress(nonValidatorNode.SecretKey.PubKey().Address().Bytes()) @@ -370,13 +312,14 @@ func (s *BTCStakingTestSuite) Test3CommitPublicRandomnessAndSubmitFinalitySignat s.NoError(err) appHash := blockToVote.AppHash + idx := 0 msgToSign := append(sdk.Uint64ToBigEndian(activatedHeight), appHash...) // generate EOTS signature - sig, err := eots.Sign(fpBTCSK, srList[0], msgToSign) + sig, err := eots.Sign(fpBTCSK, randListInfo.SRList[idx], msgToSign) s.NoError(err) eotsSig := bbn.NewSchnorrEOTSSigFromModNScalar(sig) // submit finality signature - nonValidatorNode.AddFinalitySig(fp.BtcPk, activatedHeight, appHash, eotsSig) + nonValidatorNode.AddFinalitySig(cacheFP.BtcPk, activatedHeight, &randListInfo.PRList[idx], *randListInfo.ProofList[idx].ToProto(), appHash, eotsSig) // ensure vote is eventually cast nonValidatorNode.WaitForNextBlock() @@ -386,7 +329,7 @@ func (s *BTCStakingTestSuite) Test3CommitPublicRandomnessAndSubmitFinalitySignat return len(votes) > 0 }, time.Minute, time.Second*5) s.Equal(1, len(votes)) - s.Equal(votes[0].MarshalHex(), fp.BtcPk.MarshalHex()) + s.Equal(votes[0].MarshalHex(), cacheFP.BtcPk.MarshalHex()) // once the vote is cast, ensure block is finalised finalizedBlock := nonValidatorNode.QueryIndexedBlock(activatedHeight) s.NotEmpty(finalizedBlock) @@ -478,11 +421,13 @@ func (s *BTCStakingTestSuite) Test5SubmitStakerUnbonding() { // wait for a block so that above txs take effect nonValidatorNode.WaitForNextBlock() - activeDelsSet := nonValidatorNode.QueryFinalityProviderDelegations(fp.BtcPk.MarshalHex()) + activeDelsSet := nonValidatorNode.QueryFinalityProviderDelegations(cacheFP.BtcPk.MarshalHex()) s.Len(activeDelsSet, 1) activeDels := activeDelsSet[0] s.Len(activeDels.Dels, 1) - activeDel := activeDels.Dels[0] + activeDelResp := activeDels.Dels[0] + activeDel, err := ParseRespBTCDelToBTCDel(activeDelResp) + s.NoError(err) s.NotNil(activeDel.CovenantSigs) // staking tx hash @@ -501,11 +446,513 @@ func (s *BTCStakingTestSuite) Test5SubmitStakerUnbonding() { nonValidatorNode.WaitForNextBlock() // Wait for unbonded delegations to be created - var unbondedDels []*bstypes.BTCDelegation + var unbondedDelsResp []*bstypes.BTCDelegationResponse s.Eventually(func() bool { - unbondedDels = nonValidatorNode.QueryUnbondedDelegations() - return len(unbondedDels) > 0 + unbondedDelsResp = nonValidatorNode.QueryUnbondedDelegations() + return len(unbondedDelsResp) > 0 }, time.Minute, time.Second*2) - s.Len(unbondedDels, 1) - s.Equal(stakingTxHash, unbondedDels[0].MustGetStakingTxHash()) + + unbondDel, err := ParseRespBTCDelToBTCDel(unbondedDelsResp[0]) + s.NoError(err) + s.Equal(stakingTxHash, unbondDel.MustGetStakingTxHash()) +} + +// Test6MultisigBTCDelegation is an end-to-end test to create a BTC delegation +// with multisignature. It also utilizes the cacheFP populated at +// Test1CreateFinalityProviderAndDelegation. +func (s *BTCStakingTestSuite) Test6MultisigBTCDelegation() { + chainA := s.configurer.GetChainConfig(0) + chainA.WaitUntilHeight(1) + nonValidatorNode, err := chainA.GetNodeAtIndex(2) + s.NoError(err) + + w1, w2, wMultisig := "multisig-holder-1", "multisig-holder-2", "multisig-2of2" + + nonValidatorNode.KeysAdd(w1) + nonValidatorNode.KeysAdd(w2) + // creates and fund multisig + multisigAddr := nonValidatorNode.KeysAdd(wMultisig, []string{fmt.Sprintf("--multisig=%s,%s", w1, w2), "--multisig-threshold=2"}...) + nonValidatorNode.BankSendFromNode(multisigAddr, "100000ubbn") + + // create a random BTC delegation under the cached 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 multisig address for the BTC delegation + multisigStakerAddr := sdk.MustAccAddressFromBech32(multisigAddr) + pop, err := bstypes.NewPoPBTC(multisigStakerAddr, delBTCSK) + s.NoError(err) + + // generate staking tx and slashing tx + stakingTimeBlocks := uint16(math.MaxUint16) + testStakingInfo, stakingTxInfo, testUnbondingInfo, delegatorSig := s.BTCStakingUnbondSlashInfo(nonValidatorNode, params, stakingTimeBlocks, cacheFP) + + delUnbondingSlashingSig, err := testUnbondingInfo.GenDelSlashingTxSig(delBTCSK) + s.NoError(err) + + // submit the message for only generate the Tx to create BTC delegation + jsonTx := nonValidatorNode.CreateBTCDelegation( + bbn.NewBIP340PubKeyFromBTCPK(delBTCPK), + pop, + stakingTxInfo, + cacheFP.BtcPk, + stakingTimeBlocks, + btcutil.Amount(stakingValue), + testStakingInfo.SlashingTx, + delegatorSig, + testUnbondingInfo.UnbondingTx, + testUnbondingInfo.SlashingTx, + uint16(unbondingTime), + btcutil.Amount(testUnbondingInfo.UnbondingInfo.UnbondingOutput.Value), + delUnbondingSlashingSig, + multisigAddr, + true, + ) + + // write the tx to a file + fullPathTxBTCDelegation := nonValidatorNode.WriteFile("tx.json", jsonTx) + // signs the tx with the 2 wallets and the multisig and broadcast the tx + nonValidatorNode.TxMultisignBroadcast(wMultisig, fullPathTxBTCDelegation, []string{w1, w2}) + + // wait for a block so that above txs take effect + nonValidatorNode.WaitForNextBlock() + + // check delegation with the multisig staker address exists. + delegation := nonValidatorNode.QueryBtcDelegation(testStakingInfo.StakingTx.TxHash().String()) + s.NotNil(delegation) + s.Equal(multisigAddr, delegation.BtcDelegation.StakerAddr) +} + +// Test7BTCDelegationFeeGrant is an end-to-end test to create a BTC delegation +// from a BTC delegator that does not have funds to pay for fees. It also +// utilizes the cacheFP populated at Test1CreateFinalityProviderAndDelegation. +func (s *BTCStakingTestSuite) Test7BTCDelegationFeeGrant() { + chainA := s.configurer.GetChainConfig(0) + chainA.WaitUntilHeight(1) + nonValidatorNode, err := chainA.GetNodeAtIndex(2) + s.NoError(err) + + wGratee, wGranter := "grantee", "granter" + 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)) + + // fund the granter + nonValidatorNode.BankSendFromNode(feePayerAddr.String(), feePayerBalanceBeforeBTCDel.String()) + + // create a random BTC delegation under the cached finality provider + // BTC staking btcStkParams, BTC delegation key pairs and PoP + btcStkParams := nonValidatorNode.QueryBTCStakingParams() + + // minimal required unbonding time + unbondingTime := uint16(initialization.BabylonBtcFinalizationPeriod) + 1 + + // NOTE: we use the grantee staker address for the BTC delegation PoP + pop, err := bstypes.NewPoPBTC(granteeStakerAddr, 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) + + delUnbondingSlashingSig, err := testUnbondingInfo.GenDelSlashingTxSig(delBTCSK) + s.NoError(err) + + // conceive the fee grant from the payer to the staker. + nonValidatorNode.TxFeeGrant(feePayerAddr.String(), granteeStakerAddr.String(), fmt.Sprintf("--from=%s", wGranter)) + // wait for a block to take effect the fee grant tx. + nonValidatorNode.WaitForNextBlock() + + // staker should not have any balance. + stakerBalances, err := nonValidatorNode.QueryBalances(granteeStakerAddr.String()) + s.NoError(err) + s.True(stakerBalances.IsZero()) + + // submit the message to create BTC delegation + nonValidatorNode.CreateBTCDelegation( + bbn.NewBIP340PubKeyFromBTCPK(delBTCPK), + pop, + stakingTxInfo, + cacheFP.BtcPk, + stakingTimeBlocks, + btcutil.Amount(stakingValue), + testStakingInfo.SlashingTx, + delegatorSig, + testUnbondingInfo.UnbondingTx, + testUnbondingInfo.SlashingTx, + uint16(unbondingTime), + btcutil.Amount(testUnbondingInfo.UnbondingInfo.UnbondingOutput.Value), + delUnbondingSlashingSig, + 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 + nonValidatorNode.WaitForNextBlock() + + // check the delegation was success. + delegation := nonValidatorNode.QueryBtcDelegation(testStakingInfo.StakingTx.TxHash().String()) + s.NotNil(delegation) + s.Equal(granteeStakerAddr.String(), delegation.BtcDelegation.StakerAddr) + + // verify the balances after the BTC delegation was submited + // 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 + feePayerBalances, err := nonValidatorNode.QueryBalances(feePayerAddr.String()) + s.NoError(err) + s.Equal(feePayerBalanceBeforeBTCDel.Sub(fees).String(), feePayerBalances.String()) +} + +// Test8BTCDelegationFeeGrantTyped is an end-to-end test to create a BTC delegation +// from a BTC delegator that does not have funds to pay for fees and explore scenarios +// to verify if the feeGrant is respected by the msg type and also spend limits. It also +// utilizes the cacheFP populated at Test1CreateFinalityProviderAndDelegation. +func (s *BTCStakingTestSuite) Test8BTCDelegationFeeGrantTyped() { + chainA := s.configurer.GetChainConfig(0) + chainA.WaitUntilHeight(1) + node, err := chainA.GetNodeAtIndex(2) + s.NoError(err) + + wGratee, wGranter := "staker", "feePayer" + 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)) + + // fund the granter and the staker + node.BankSendFromNode(feePayerAddr.String(), feePayerBalanceBeforeBTCDel.String()) + node.BankSendFromNode(granteeStakerAddr.String(), stakerBalance.String()) + + // create a random BTC delegation under the cached finality provider + // BTC staking btcStkParams, BTC delegation key pairs and PoP + btcStkParams := node.QueryBTCStakingParams() + + // minimal required unbonding time + unbondingTime := uint16(initialization.BabylonBtcFinalizationPeriod) + 1 + + // NOTE: we use the grantee staker address for the BTC delegation PoP + pop, err := bstypes.NewPoPBTC(granteeStakerAddr, 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) + + delUnbondingSlashingSig, err := testUnbondingInfo.GenDelSlashingTxSig(delBTCSK) + s.NoError(err) + + // conceive the fee grant from the payer to the staker only for one specific msg type. + node.TxFeeGrant( + feePayerAddr.String(), granteeStakerAddr.String(), + fmt.Sprintf("--from=%s", wGranter), + fmt.Sprintf("--%s=%s", feegrantcli.FlagSpendLimit, fees.String()), + fmt.Sprintf("--%s=%s", feegrantcli.FlagAllowedMsgs, sdk.MsgTypeURL(&bstypes.MsgCreateBTCDelegation{})), + ) + // wait for a block to take effect the fee grant tx. + node.WaitForNextBlock() + + // tries to create a send transaction putting the freegranter as feepayer, it should FAIL + // since we only gave grant for BTC delegation msgs. + // TODO: Uncomment the next lines when issue: https://github.com/babylonlabs-io/babylon/issues/693 + // is fixed on cosmos-sdk side + // outBuff, errBuff, err := node.BankSendOutput( + // wGratee, node.PublicAddress, stakerBalance.String(), + // fmt.Sprintf("--fee-granter=%s", feePayerAddr.String()), + // ) + // outputStr := outBuff.String() + errBuff.String() + // s.Require().Contains(outputStr, fmt.Sprintf("code: %d", feegrant.ErrMessageNotAllowed.ABCICode())) + // s.Require().Contains(outputStr, feegrant.ErrMessageNotAllowed.Error()) + // s.Nil(err) + + // // staker should not have lost any balance. + // stakerBalances, err := node.QueryBalances(granteeStakerAddr.String()) + // s.Require().NoError(err) + // s.Require().Equal(stakerBalance.String(), stakerBalances.String()) + + // submit the message to create BTC delegation using the fee grant + // but putting as fee more than the spend limit + // it should fail by exceeding the fee limit. + // output := node.CreateBTCDelegation( + // bbn.NewBIP340PubKeyFromBTCPK(delBTCPK), + // pop, + // stakingTxInfo, + // cacheFP.BtcPk, + // stakingTimeBlocks, + // btcutil.Amount(stakingValue), + // testStakingInfo.SlashingTx, + // delegatorSig, + // testUnbondingInfo.UnbondingTx, + // testUnbondingInfo.SlashingTx, + // uint16(unbondingTime), + // btcutil.Amount(testUnbondingInfo.UnbondingInfo.UnbondingOutput.Value), + // delUnbondingSlashingSig, + // wGratee, + // false, + // fmt.Sprintf("--fee-granter=%s", feePayerAddr.String()), + // fmt.Sprintf("--fees=%s", fees.Add(stakerBalance).String()), + // ) + // s.Require().Contains(output, fmt.Sprintf("code: %d", feegrant.ErrFeeLimitExceeded.ABCICode())) + // s.Require().Contains(output, feegrant.ErrFeeLimitExceeded.Error()) + + // submit the message to create BTC delegation using the fee grant at the max of spend limit + node.CreateBTCDelegation( + bbn.NewBIP340PubKeyFromBTCPK(delBTCPK), + pop, + stakingTxInfo, + cacheFP.BtcPk, + stakingTimeBlocks, + btcutil.Amount(stakingValue), + testStakingInfo.SlashingTx, + delegatorSig, + testUnbondingInfo.UnbondingTx, + testUnbondingInfo.SlashingTx, + uint16(unbondingTime), + btcutil.Amount(testUnbondingInfo.UnbondingInfo.UnbondingOutput.Value), + delUnbondingSlashingSig, + 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 + node.WaitForNextBlock() + + // check the delegation was success. + delegation := node.QueryBtcDelegation(testStakingInfo.StakingTx.TxHash().String()) + s.NotNil(delegation) + s.Equal(granteeStakerAddr.String(), delegation.BtcDelegation.StakerAddr) + + // verify the balances after the BTC delegation was submited + // 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 + feePayerBalances, err := node.QueryBalances(feePayerAddr.String()) + s.NoError(err) + s.Equal(feePayerBalanceBeforeBTCDel.Sub(fees).String(), feePayerBalances.String()) +} + +// ParseRespsBTCDelToBTCDel parses an BTC delegation response to BTC Delegation +func ParseRespsBTCDelToBTCDel(resp *bstypes.BTCDelegatorDelegationsResponse) (btcDels *bstypes.BTCDelegatorDelegations, err error) { + if resp == nil { + return nil, nil + } + btcDels = &bstypes.BTCDelegatorDelegations{ + Dels: make([]*bstypes.BTCDelegation, len(resp.Dels)), + } + + for i, delResp := range resp.Dels { + del, err := ParseRespBTCDelToBTCDel(delResp) + if err != nil { + return nil, err + } + btcDels.Dels[i] = del + } + return btcDels, nil +} + +// ParseRespBTCDelToBTCDel parses an BTC delegation response to BTC Delegation +func ParseRespBTCDelToBTCDel(resp *bstypes.BTCDelegationResponse) (btcDel *bstypes.BTCDelegation, err error) { + stakingTx, err := hex.DecodeString(resp.StakingTxHex) + if err != nil { + return nil, err + } + + delSig, err := bbn.NewBIP340SignatureFromHex(resp.DelegatorSlashSigHex) + if err != nil { + return nil, err + } + + slashingTx, err := bstypes.NewBTCSlashingTxFromHex(resp.SlashingTxHex) + if err != nil { + return nil, err + } + + btcDel = &bstypes.BTCDelegation{ + StakerAddr: resp.StakerAddr, + BtcPk: resp.BtcPk, + FpBtcPkList: resp.FpBtcPkList, + StartHeight: resp.StartHeight, + EndHeight: resp.EndHeight, + TotalSat: resp.TotalSat, + StakingTx: stakingTx, + DelegatorSig: delSig, + StakingOutputIdx: resp.StakingOutputIdx, + CovenantSigs: resp.CovenantSigs, + UnbondingTime: resp.UnbondingTime, + SlashingTx: slashingTx, + } + + if resp.UndelegationResponse != nil { + ud := resp.UndelegationResponse + unbondTx, err := hex.DecodeString(ud.UnbondingTxHex) + if err != nil { + return nil, err + } + + slashTx, err := bstypes.NewBTCSlashingTxFromHex(ud.SlashingTxHex) + if err != nil { + return nil, err + } + + delSlashingSig, err := bbn.NewBIP340SignatureFromHex(ud.DelegatorSlashingSigHex) + if err != nil { + return nil, err + } + + btcDel.BtcUndelegation = &bstypes.BTCUndelegation{ + UnbondingTx: unbondTx, + CovenantUnbondingSigList: ud.CovenantUnbondingSigList, + CovenantSlashingSigs: ud.CovenantSlashingSigs, + SlashingTx: slashTx, + DelegatorSlashingSig: delSlashingSig, + } + + if len(ud.DelegatorUnbondingSigHex) > 0 { + delUnbondingSig, err := bbn.NewBIP340SignatureFromHex(ud.DelegatorUnbondingSigHex) + if err != nil { + return nil, err + } + 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) +} + +// CreateNodeFP creates a random finality provider. +func (s *BTCStakingTestSuite) CreateNodeFP(node *chain.NodeConfig) (newFP *bstypes.FinalityProvider) { + // the node is the new FP + nodeAddr, err := sdk.AccAddressFromBech32(node.PublicAddress) + s.NoError(err) + + newFP, err = datagen.GenRandomFinalityProviderWithBTCBabylonSKs(r, fpBTCSK, nodeAddr) + s.NoError(err) + 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 + node.WaitForNextBlock() + + // query the existence of finality provider and assert equivalence + actualFps := node.QueryFinalityProviders() + s.Len(actualFps, 1) + s.equalFinalityProviderResp(newFP, actualFps[0]) + + return newFP +} + +// CovenantBTCPKs returns the covenantBTCPks as slice from parameters +func CovenantBTCPKs(params *bstypes.Params) []*btcec.PublicKey { + // get covenant BTC PKs + covenantBTCPKs := make([]*btcec.PublicKey, len(params.CovenantPks)) + for i, covenantPK := range params.CovenantPks { + covenantBTCPKs[i] = covenantPK.MustToBTCPK() + } + return covenantBTCPKs +} + +// BTCStakingUnbondSlashInfo generate BTC information to create BTC delegation. +func (s *BTCStakingTestSuite) BTCStakingUnbondSlashInfo( + node *chain.NodeConfig, + params *bstypes.Params, + stakingTimeBlocks uint16, + fp *bstypes.FinalityProvider, +) ( + testStakingInfo *datagen.TestStakingSlashingInfo, + stakingTxInfo *btcctypes.TransactionInfo, + testUnbondingInfo *datagen.TestUnbondingSlashingInfo, + delegatorSig *bbn.BIP340Signature, +) { + covenantBTCPKs := CovenantBTCPKs(params) + // minimal required unbonding time + unbondingTime := uint16(initialization.BabylonBtcFinalizationPeriod) + 1 + + testStakingInfo = datagen.GenBTCStakingSlashingInfo( + r, + s.T(), + net, + delBTCSK, + []*btcec.PublicKey{fp.BtcPk.MustToBTCPK()}, + covenantBTCPKs, + covenantQuorum, + stakingTimeBlocks, + stakingValue, + params.SlashingAddress, + 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(r, currentBtcTip.Header.ToBlockHeader(), stakingMsgTx) + node.InsertHeader(&blockWithStakingTx.HeaderBytes) + // make block k-deep + for i := 0; i < initialization.BabylonBtcConfirmationPeriod; i++ { + node.InsertNewEmptyBtcHeader(r) + } + stakingTxInfo = btcctypes.NewTransactionInfoFromSpvProof(blockWithStakingTx.SpvProof) + + // generate BTC undelegation stuff + stkTxHash := testStakingInfo.StakingTx.TxHash() + unbondingValue := stakingValue - datagen.UnbondingTxFee + testUnbondingInfo = datagen.GenBTCUnbondingSlashingInfo( + r, + s.T(), + net, + delBTCSK, + []*btcec.PublicKey{fp.BtcPk.MustToBTCPK()}, + covenantBTCPKs, + covenantQuorum, + wire.NewOutPoint(&stkTxHash, datagen.StakingOutIdx), + stakingTimeBlocks, + unbondingValue, + params.SlashingAddress, + params.SlashingRate, + unbondingTime, + ) + + stakingSlashingPathInfo, err := testStakingInfo.StakingInfo.SlashingPathSpendInfo() + s.NoError(err) + + delegatorSig, err = testStakingInfo.SlashingTx.Sign( + stakingMsgTx, + datagen.StakingOutIdx, + stakingSlashingPathInfo.GetPkScriptPath(), + delBTCSK, + ) + s.NoError(err) + + return testStakingInfo, stakingTxInfo, testUnbondingInfo, delegatorSig } diff --git a/test/e2e/btc_timestamping_e2e_test.go b/test/e2e/btc_timestamping_e2e_test.go index 0f7fb1804..6b8282311 100644 --- a/test/e2e/btc_timestamping_e2e_test.go +++ b/test/e2e/btc_timestamping_e2e_test.go @@ -8,11 +8,11 @@ import ( "strconv" "time" - "github.com/babylonchain/babylon/test/e2e/configurer" - "github.com/babylonchain/babylon/test/e2e/initialization" - bbn "github.com/babylonchain/babylon/types" - ct "github.com/babylonchain/babylon/x/checkpointing/types" - itypes "github.com/babylonchain/babylon/x/incentive/types" + "github.com/babylonlabs-io/babylon/test/e2e/configurer" + "github.com/babylonlabs-io/babylon/test/e2e/initialization" + 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" ) @@ -73,7 +73,7 @@ func (s *BTCTimestampingTestSuite) Test2BTCBaseHeader() { s.NoError(err) baseHeader, err := nonValidatorNode.QueryBtcBaseHeader() s.NoError(err) - s.True(baseHeader.Hash.Eq(hardcodedHeader.Hash())) + s.Equal(baseHeader.HeaderHex, hardcodedHeader.MarshalHex()) s.Equal(hardcodedHeaderHeight, baseHeader.Height) } @@ -94,11 +94,11 @@ func (s *BTCTimestampingTestSuite) Test3SendTx() { s.Equal(tip1.Height+1, tip2.Height) // check that light client properly updates its state - tip1Depth, err := nonValidatorNode.QueryHeaderDepth(tip1.Hash.MarshalHex()) + tip1Depth, err := nonValidatorNode.QueryHeaderDepth(tip1.HashHex) s.NoError(err) s.Equal(tip1Depth, uint64(1)) - tip2Depth, err := nonValidatorNode.QueryHeaderDepth(tip2.Hash.MarshalHex()) + tip2Depth, err := nonValidatorNode.QueryHeaderDepth(tip2.HashHex) s.NoError(err) // tip should have 0 depth s.Equal(tip2Depth, uint64(0)) diff --git a/test/e2e/btc_timestamping_phase2_hermes_test.go b/test/e2e/btc_timestamping_phase2_hermes_test.go index 0029da76e..cfae910f4 100644 --- a/test/e2e/btc_timestamping_phase2_hermes_test.go +++ b/test/e2e/btc_timestamping_phase2_hermes_test.go @@ -3,10 +3,9 @@ package e2e import ( "time" - "github.com/babylonchain/babylon/test/e2e/configurer" - "github.com/babylonchain/babylon/test/e2e/initialization" - ct "github.com/babylonchain/babylon/x/checkpointing/types" - zctypes "github.com/babylonchain/babylon/x/zoneconcierge/types" + "github.com/babylonlabs-io/babylon/test/e2e/configurer" + "github.com/babylonlabs-io/babylon/test/e2e/initialization" + 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" @@ -57,24 +56,45 @@ func (s *BTCTimestampingPhase2HermesTestSuite) Test1IbcCheckpointingPhase2Hermes s.NoError(err) // Validate channel state and kind (Babylon side) - babylonChannelsResp, err := babylonNode.QueryIBCChannels() - s.NoError(err) - s.Len(babylonChannelsResp.Channels, 1) - babylonChannel := babylonChannelsResp.Channels[0] - // channel has to be open and ordered - s.Equal(channeltypes.OPEN, babylonChannel.State) - s.Equal(channeltypes.ORDERED, babylonChannel.Ordering) - // the counterparty has to be the Babylon smart contract - s.Contains(babylonChannel.Counterparty.PortId, "wasm.") - - // Validate channel state (CZ side) - czChannelsResp, err := czNode.QueryIBCChannels() - s.NoError(err) - s.Len(czChannelsResp.Channels, 2) // TODO: why 2 channels? - czChannel := czChannelsResp.Channels[0] - s.Equal(channeltypes.OPEN, czChannel.State) - s.Equal(channeltypes.ORDERED, czChannel.Ordering) - s.Equal(zctypes.PortID, czChannel.Counterparty.PortId) + // 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) // Query checkpoint chain info for the consumer chain listHeaderResp, err := babylonNode.QueryListHeaders(initialization.ChainBID, &query.PageRequest{Limit: 1}) @@ -100,27 +120,28 @@ func (s *BTCTimestampingPhase2HermesTestSuite) Test1IbcCheckpointingPhase2Hermes if err != nil { return false } - s.T().Logf("next sequence send at ZoneConcierge is %d", nextSequenceSendResp.NextSequenceSend) + 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) + 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) + 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 - lastSequence := endEpochNum - for seq := uint64(1); seq < lastSequence; seq++ { + // 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) - s.T().Logf("acknowledgement resp of IBC packet #%d: %v, err: %v", seq, seqResp, err) + 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 index 8bc1e5352..091eabc06 100644 --- a/test/e2e/btc_timestamping_phase2_rly_test.go +++ b/test/e2e/btc_timestamping_phase2_rly_test.go @@ -3,9 +3,9 @@ package e2e import ( "time" - "github.com/babylonchain/babylon/test/e2e/configurer" - "github.com/babylonchain/babylon/test/e2e/initialization" - ct "github.com/babylonchain/babylon/x/checkpointing/types" + "github.com/babylonlabs-io/babylon/test/e2e/configurer" + "github.com/babylonlabs-io/babylon/test/e2e/initialization" + 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" diff --git a/test/e2e/bytecode/README.md b/test/e2e/bytecode/README.md index e0926f743..0655fa11f 100644 --- a/test/e2e/bytecode/README.md +++ b/test/e2e/bytecode/README.md @@ -1 +1 @@ -Contract built from https://github.com/babylonchain/babylon-contract/tree/main/contracts +Contract built from https://github.com/babylonlabs-io/babylon-contract/tree/main/contracts diff --git a/test/e2e/bytecode/babylon_contract.wasm b/test/e2e/bytecode/babylon_contract.wasm index f43c2f174..16075c906 100644 Binary files a/test/e2e/bytecode/babylon_contract.wasm and b/test/e2e/bytecode/babylon_contract.wasm differ diff --git a/test/e2e/bytecode/version.txt b/test/e2e/bytecode/version.txt index 3e53cef7d..fb7a04cff 100644 --- a/test/e2e/bytecode/version.txt +++ b/test/e2e/bytecode/version.txt @@ -1 +1 @@ -535d854ed239020edd3e93cc202a7c1bcbd1a162 +v0.4.0 diff --git a/test/e2e/configurer/base.go b/test/e2e/configurer/base.go index 6744fff94..302fd8ca9 100644 --- a/test/e2e/configurer/base.go +++ b/test/e2e/configurer/base.go @@ -12,12 +12,12 @@ import ( "testing" "time" - "github.com/babylonchain/babylon/test/e2e/configurer/chain" - "github.com/babylonchain/babylon/test/e2e/containers" - "github.com/babylonchain/babylon/test/e2e/initialization" - "github.com/babylonchain/babylon/test/e2e/util" - "github.com/babylonchain/babylon/types" - types2 "github.com/babylonchain/babylon/x/btccheckpoint/types" + "github.com/babylonlabs-io/babylon/test/e2e/configurer/chain" + "github.com/babylonlabs-io/babylon/test/e2e/containers" + "github.com/babylonlabs-io/babylon/test/e2e/initialization" + "github.com/babylonlabs-io/babylon/test/e2e/util" + "github.com/babylonlabs-io/babylon/types" + types2 "github.com/babylonlabs-io/babylon/x/btccheckpoint/types" "github.com/stretchr/testify/require" ) diff --git a/test/e2e/configurer/chain/chain.go b/test/e2e/configurer/chain/chain.go index 4d5e1ec03..a6d92dc3f 100644 --- a/test/e2e/configurer/chain/chain.go +++ b/test/e2e/configurer/chain/chain.go @@ -10,9 +10,9 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" "github.com/stretchr/testify/require" - "github.com/babylonchain/babylon/test/e2e/configurer/config" - "github.com/babylonchain/babylon/test/e2e/containers" - "github.com/babylonchain/babylon/test/e2e/initialization" + "github.com/babylonlabs-io/babylon/test/e2e/configurer/config" + "github.com/babylonlabs-io/babylon/test/e2e/containers" + "github.com/babylonlabs-io/babylon/test/e2e/initialization" ) type Config struct { diff --git a/test/e2e/configurer/chain/commands.go b/test/e2e/configurer/chain/commands.go index 94335bc60..36155d45c 100644 --- a/test/e2e/configurer/chain/commands.go +++ b/test/e2e/configurer/chain/commands.go @@ -1,37 +1,58 @@ package chain import ( + "bytes" "encoding/hex" "encoding/json" "fmt" "math/rand" + "os" + "path/filepath" "regexp" "strings" "time" - txformat "github.com/babylonchain/babylon/btctxformatter" - "github.com/babylonchain/babylon/test/e2e/initialization" - "github.com/babylonchain/babylon/test/e2e/util" - "github.com/babylonchain/babylon/testutil/datagen" - bbn "github.com/babylonchain/babylon/types" - btccheckpointtypes "github.com/babylonchain/babylon/x/btccheckpoint/types" - blc "github.com/babylonchain/babylon/x/btclightclient/types" - cttypes "github.com/babylonchain/babylon/x/checkpointing/types" + txformat "github.com/babylonlabs-io/babylon/btctxformatter" + "github.com/babylonlabs-io/babylon/test/e2e/containers" + "github.com/babylonlabs-io/babylon/test/e2e/initialization" + "github.com/babylonlabs-io/babylon/test/e2e/util" + "github.com/babylonlabs-io/babylon/testutil/datagen" + bbn "github.com/babylonlabs-io/babylon/types" + btccheckpointtypes "github.com/babylonlabs-io/babylon/x/btccheckpoint/types" + blc "github.com/babylonlabs-io/babylon/x/btclightclient/types" + cttypes "github.com/babylonlabs-io/babylon/x/checkpointing/types" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/bech32" sdkquerytypes "github.com/cosmos/cosmos-sdk/types/query" "github.com/stretchr/testify/require" ) +const ( + flagKeyringTest = "--keyring-backend=test" +) + func (n *NodeConfig) GetWallet(walletName string) string { n.LogActionF("retrieving wallet %s", walletName) - cmd := []string{"babylond", "keys", "show", walletName, "--keyring-backend=test"} + cmd := []string{"babylond", "keys", "show", walletName, flagKeyringTest, containers.FlagHome} outBuf, _, err := n.containerManager.ExecCmd(n.t, n.Name, cmd, "") require.NoError(n.t, err) - re := regexp.MustCompile("bbn(.{38})") + re := regexp.MustCompile("bbn(.{39})") + walletAddr := fmt.Sprintf("%s\n", re.FindString(outBuf.String())) + walletAddr = strings.TrimSuffix(walletAddr, "\n") + n.LogActionF("wallet %s found, wallet address - %s", walletName, walletAddr) + return walletAddr +} + +// KeysAdd creates a new key in the keyring +func (n *NodeConfig) KeysAdd(walletName string, overallFlags ...string) string { + n.LogActionF("adding new wallet %s", walletName) + cmd := []string{"babylond", "keys", "add", walletName, flagKeyringTest, containers.FlagHome} + outBuf, _, err := n.containerManager.ExecCmd(n.t, n.Name, append(cmd, overallFlags...), "") + require.NoError(n.t, err) + re := regexp.MustCompile("bbn(.{39})") walletAddr := fmt.Sprintf("%s\n", re.FindString(outBuf.String())) walletAddr = strings.TrimSuffix(walletAddr, "\n") - n.LogActionF("wallet %s found, waller address - %s", walletName, walletAddr) + n.LogActionF("wallet %s created, address - %s", walletName, walletAddr) return walletAddr } @@ -69,12 +90,27 @@ func (n *NodeConfig) FailIBCTransfer(from, recipient, amount string) { n.LogActionF("Failed to send IBC transfer (as expected)") } -func (n *NodeConfig) BankSend(amount string, sendAddress string, receiveAddress string) { - n.LogActionF("bank sending %s from address %s to %s", amount, sendAddress, receiveAddress) - cmd := []string{"babylond", "tx", "bank", "send", sendAddress, receiveAddress, amount, "--from=val"} - _, _, err := n.containerManager.ExecTxCmd(n.t, n.chainId, n.Name, cmd) +func (n *NodeConfig) BankSendFromNode(receiveAddress, amount string) { + n.BankSend(n.WalletName, receiveAddress, amount) +} + +func (n *NodeConfig) BankSend(fromWallet, to, amount string, overallFlags ...string) { + fromAddr := n.GetWallet(fromWallet) + n.LogActionF("bank sending %s from wallet %s to %s", amount, fromWallet, to) + cmd := []string{"babylond", "tx", "bank", "send", fromAddr, to, amount, fmt.Sprintf("--from=%s", fromWallet)} + _, _, err := n.containerManager.ExecTxCmd(n.t, n.chainId, n.Name, append(cmd, overallFlags...)) require.NoError(n.t, err) - n.LogActionF("successfully sent bank sent %s from address %s to %s", amount, sendAddress, receiveAddress) + n.LogActionF("successfully sent bank sent %s from address %s to %s", amount, fromWallet, to) +} + +func (n *NodeConfig) BankSendOutput(fromWallet, to, amount string, overallFlags ...string) (out bytes.Buffer, errBuff bytes.Buffer, err error) { + fromAddr := n.GetWallet(fromWallet) + n.LogActionF("bank sending %s from wallet %s to %s", amount, fromWallet, to) + cmd := []string{ + "babylond", "tx", "bank", "send", fromAddr, to, amount, fmt.Sprintf("--from=%s", fromWallet), + n.FlagChainID(), "-b=sync", "--yes", "--keyring-backend=test", "--log_format=json", "--home=/home/babylon/babylondata", + } + return n.containerManager.ExecCmd(n.t, n.Name, append(cmd, overallFlags...), "") } func (n *NodeConfig) SendHeaderHex(headerHex string) { @@ -86,12 +122,16 @@ func (n *NodeConfig) SendHeaderHex(headerHex string) { } func (n *NodeConfig) InsertNewEmptyBtcHeader(r *rand.Rand) *blc.BTCHeaderInfo { - tip, err := n.QueryTip() + tipResp, err := n.QueryTip() require.NoError(n.t, err) - n.t.Logf("Retrieved current tip of btc headerchain. Height: %d", tip.Height) + n.t.Logf("Retrieved current tip of btc headerchain. Height: %d", tipResp.Height) + + tip, err := ParseBTCHeaderInfoResponseToInfo(tipResp) + require.NoError(n.t, err) + child := datagen.GenRandomValidBTCHeaderInfoWithParent(r, *tip) n.SendHeaderHex(child.Header.MarshalHex()) - n.WaitUntilBtcHeight(tip.Height + 1) + n.WaitUntilBtcHeight(tipResp.Height + 1) return child } @@ -140,13 +180,16 @@ func (n *NodeConfig) FinalizeSealedEpochs(startEpoch uint64, lastEpoch uint64) { for _, checkpoint := range resp.RawCheckpoints { require.Equal(n.t, checkpoint.Status, cttypes.Sealed) - currentBtcTip, err := n.QueryTip() + currentBtcTipResp, err := n.QueryTip() require.NoError(n.t, err) _, submitterAddr, err := bech32.DecodeAndConvert(n.PublicAddress) require.NoError(n.t, err) - btcCheckpoint, err := cttypes.FromRawCkptToBTCCkpt(checkpoint.Ckpt, submitterAddr) + rawCheckpoint, err := checkpoint.Ckpt.ToRawCheckpoint() + require.NoError(n.t, err) + + btcCheckpoint, err := cttypes.FromRawCkptToBTCCkpt(rawCheckpoint, submitterAddr) require.NoError(n.t, err) babylonTagBytes, err := hex.DecodeString(initialization.BabylonOpReturnTag) @@ -160,6 +203,9 @@ func (n *NodeConfig) FinalizeSealedEpochs(startEpoch uint64, lastEpoch uint64) { require.NoError(n.t, err) tx1 := datagen.CreatOpReturnTransaction(r, p1) + currentBtcTip, err := ParseBTCHeaderInfoResponseToInfo(currentBtcTipResp) + require.NoError(n.t, err) + opReturn1 := datagen.CreateBlockWithTransaction(r, currentBtcTip.Header.ToBlockHeader(), tx1) tx2 := datagen.CreatOpReturnTransaction(r, p2) opReturn2 := datagen.CreateBlockWithTransaction(r, opReturn1.HeaderBytes.ToBlockHeader(), tx2) @@ -224,3 +270,118 @@ func (n *NodeConfig) WithdrawReward(sType, from string) { require.NoError(n.t, err) n.LogActionF("successfully withdrawn") } + +// TxMultisigSign sign a tx in a file with one wallet for a multisig address. +func (n *NodeConfig) TxMultisigSign(walletName, multisigAddr, txFileFullPath, fileName string, overallFlags ...string) (fullFilePathInContainer string) { + return n.TxSign(walletName, txFileFullPath, fileName, fmt.Sprintf("--multisig=%s", multisigAddr)) +} + +// TxSign sign a tx in a file with one wallet. +func (n *NodeConfig) TxSign(walletName, txFileFullPath, fileName string, overallFlags ...string) (fullFilePathInContainer string) { + n.LogActionF("wallet %s sign tx file %s", walletName, txFileFullPath) + cmd := []string{ + "babylond", "tx", "sign", txFileFullPath, + fmt.Sprintf("--from=%s", walletName), + n.FlagChainID(), flagKeyringTest, containers.FlagHome, + } + outBuf, _, err := n.containerManager.ExecCmd(n.t, n.Name, append(cmd, overallFlags...), "") + require.NoError(n.t, err) + + return n.WriteFile(fileName, outBuf.String()) +} + +// TxMultisign sign a tx in a file. +func (n *NodeConfig) TxMultisign(walletNameMultisig, txFileFullPath, outputFileName string, signedFiles []string, overallFlags ...string) (signedTxFilePath string) { + n.LogActionF("%s multisig tx file %s", walletNameMultisig, txFileFullPath) + cmd := []string{ + "babylond", "tx", "multisign", txFileFullPath, walletNameMultisig, + n.FlagChainID(), + flagKeyringTest, containers.FlagHome, + } + cmd = append(cmd, signedFiles...) + outBuf, _, err := n.containerManager.ExecCmd(n.t, n.Name, append(cmd, overallFlags...), "") + require.NoError(n.t, err) + + return n.WriteFile(outputFileName, outBuf.String()) +} + +// TxBroadcast broadcast a signed transaction to the chain. +func (n *NodeConfig) TxBroadcast(txSignedFileFullPath string, overallFlags ...string) { + n.LogActionF("broadcast tx file %s", txSignedFileFullPath) + cmd := []string{ + "babylond", "tx", "broadcast", txSignedFileFullPath, + n.FlagChainID(), + } + _, _, err := n.containerManager.ExecCmd(n.t, n.Name, append(cmd, overallFlags...), "") + require.NoError(n.t, err) +} + +// TxFeeGrant creates a fee grant tx. Which the granter is the one that will +// pay the fees for the grantee to submit txs for free. +func (n *NodeConfig) TxFeeGrant(granter, grantee string, overallFlags ...string) { + n.LogActionF("tx fee grant, granter: %s - grantee: %s", granter, grantee) + cmd := []string{ + "babylond", "tx", "feegrant", "grant", granter, grantee, + n.FlagChainID(), + } + _, _, err := n.containerManager.ExecTxCmd(n.t, n.chainId, n.Name, append(cmd, overallFlags...)) + require.NoError(n.t, err) +} + +// TxSignBroadcast signs the tx from the wallet and broadcast to chain. +func (n *NodeConfig) TxSignBroadcast(walletName, txFileFullPath string) { + fileName := fmt.Sprintf("tx-signed-%s.json", walletName) + signedTxToBroadcast := n.TxSign(walletName, txFileFullPath, fileName) + n.TxBroadcast(signedTxToBroadcast) +} + +// TxMultisignBroadcast signs the tx from each wallet and the multisig and broadcast to chain. +func (n *NodeConfig) TxMultisignBroadcast(walletNameMultisig, txFileFullPath string, walleNameSigners []string) { + multisigAddr := n.GetWallet(walletNameMultisig) + + signedFiles := make([]string, len(walleNameSigners)) + for i, wName := range walleNameSigners { + fileName := fmt.Sprintf("tx-signed-%s.json", wName) + signedFiles[i] = n.TxMultisigSign(wName, multisigAddr, txFileFullPath, fileName) + } + + signedTxToBroadcast := n.TxMultisign(walletNameMultisig, txFileFullPath, "tx-multisigned.json", signedFiles) + n.TxBroadcast(signedTxToBroadcast) +} + +// WriteFile writes a new file in the config dir of the node where it is volume mounted to the +// babylon home inside the container and returns the full file path inside the container. +func (n *NodeConfig) WriteFile(fileName, content string) (fullFilePathInContainer string) { + b := bytes.NewBufferString(content) + fileFullPath := filepath.Join(n.ConfigDir, fileName) + + err := os.WriteFile(fileFullPath, b.Bytes(), 0644) + require.NoError(n.t, err) + + return filepath.Join(containers.BabylonHomePath, fileName) +} + +// FlagChainID returns the flag of the chainID. +func (n *NodeConfig) FlagChainID() string { + return fmt.Sprintf("--chain-id=%s", n.chainId) +} + +// ParseBTCHeaderInfoResponseToInfo turns an BTCHeaderInfoResponse back to BTCHeaderInfo. +func ParseBTCHeaderInfoResponseToInfo(r *blc.BTCHeaderInfoResponse) (*blc.BTCHeaderInfo, error) { + header, err := bbn.NewBTCHeaderBytesFromHex(r.HeaderHex) + if err != nil { + return nil, err + } + + hash, err := bbn.NewBTCHeaderHashBytesFromHex(r.HashHex) + if err != nil { + return nil, err + } + + return &blc.BTCHeaderInfo{ + Header: &header, + Hash: &hash, + Height: r.Height, + Work: &r.Work, + }, nil +} diff --git a/test/e2e/configurer/chain/commands_btcstaking.go b/test/e2e/configurer/chain/commands_btcstaking.go index 7397af143..f7586d812 100644 --- a/test/e2e/configurer/chain/commands_btcstaking.go +++ b/test/e2e/configurer/chain/commands_btcstaking.go @@ -2,31 +2,30 @@ package chain import ( "encoding/hex" + "fmt" "strconv" "strings" + "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" sdkmath "cosmossdk.io/math" - "github.com/cosmos/cosmos-sdk/crypto/keys/secp256k1" - "github.com/stretchr/testify/require" + cmtcrypto "github.com/cometbft/cometbft/proto/tendermint/crypto" - asig "github.com/babylonchain/babylon/crypto/schnorr-adaptor-signature" - bbn "github.com/babylonchain/babylon/types" - btcctypes "github.com/babylonchain/babylon/x/btccheckpoint/types" - bstypes "github.com/babylonchain/babylon/x/btcstaking/types" + 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" ) -func (n *NodeConfig) CreateFinalityProvider(babylonPK *secp256k1.PubKey, btcPK *bbn.BIP340PubKey, pop *bstypes.ProofOfPossession, moniker, identity, website, securityContract, details string, commission *sdkmath.LegacyDec) { +func (n *NodeConfig) CreateFinalityProvider(walletAddrOrName string, btcPK *bbn.BIP340PubKey, pop *bstypes.ProofOfPossessionBTC, moniker, identity, website, securityContract, details string, commission *sdkmath.LegacyDec) { n.LogActionF("creating finality provider") - // get babylon PK hex - babylonPKBytes, err := babylonPK.Marshal() - require.NoError(n.t, err) - babylonPKHex := hex.EncodeToString(babylonPKBytes) // get BTC PK hex btcPKHex := btcPK.MarshalHex() // get pop hex @@ -34,7 +33,9 @@ func (n *NodeConfig) CreateFinalityProvider(babylonPK *secp256k1.PubKey, btcPK * require.NoError(n.t, err) cmd := []string{ - "babylond", "tx", "btcstaking", "create-finality-provider", babylonPKHex, btcPKHex, popHex, "--from=val", "--moniker", moniker, "--identity", identity, "--website", website, "--security-contact", securityContract, "--details", details, "--commission-rate", commission.String(), + "babylond", "tx", "btcstaking", "create-finality-provider", btcPKHex, popHex, + fmt.Sprintf("--from=%s", walletAddrOrName), "--moniker", moniker, "--identity", identity, "--website", website, + "--security-contact", securityContract, "--details", details, "--commission-rate", commission.String(), } _, _, err = n.containerManager.ExecTxCmd(n.t, n.chainId, n.Name, cmd) require.NoError(n.t, err) @@ -42,9 +43,8 @@ func (n *NodeConfig) CreateFinalityProvider(babylonPK *secp256k1.PubKey, btcPK * } func (n *NodeConfig) CreateBTCDelegation( - babylonPK *secp256k1.PubKey, btcPk *bbn.BIP340PubKey, - pop *bstypes.ProofOfPossession, + pop *bstypes.ProofOfPossessionBTC, stakingTxInfo *btcctypes.TransactionInfo, fpPK *bbn.BIP340PubKey, stakingTimeBlocks uint16, @@ -56,14 +56,12 @@ func (n *NodeConfig) CreateBTCDelegation( unbondingTime uint16, unbondingValue btcutil.Amount, delUnbondingSlashingSig *bbn.BIP340Signature, -) { + fromWalletName string, + generateOnly bool, + overallFlags ...string, +) (outStr string) { n.LogActionF("creating BTC delegation") - // get babylon PK hex - babylonPKBytes, err := babylonPK.Marshal() - require.NoError(n.t, err) - babylonPKHex := hex.EncodeToString(babylonPKBytes) - btcPkHex := btcPk.MarshalHex() // get pop hex @@ -93,10 +91,23 @@ func (n *NodeConfig) CreateBTCDelegation( unbondingValueStr := sdkmath.NewInt(int64(unbondingValue)).String() delUnbondingSlashingSigHex := delUnbondingSlashingSig.ToHexStr() - cmd := []string{"babylond", "tx", "btcstaking", "create-btc-delegation", babylonPKHex, btcPkHex, popHex, stakingTxInfoHex, fpPKHex, stakingTimeString, stakingValueString, slashingTxHex, delegatorSigHex, unbondingTxHex, unbondingSlashingTxHex, unbondingTimeStr, unbondingValueStr, delUnbondingSlashingSigHex, "--from=val"} - _, _, err = n.containerManager.ExecTxCmd(n.t, n.chainId, n.Name, cmd) + cmd := []string{ + "babylond", "tx", "btcstaking", "create-btc-delegation", + btcPkHex, popHex, stakingTxInfoHex, fpPKHex, stakingTimeString, stakingValueString, slashingTxHex, delegatorSigHex, unbondingTxHex, unbondingSlashingTxHex, unbondingTimeStr, unbondingValueStr, delUnbondingSlashingSigHex, + fmt.Sprintf("--from=%s", fromWalletName), containers.FlagHome, flagKeyringTest, + n.FlagChainID(), "--log_format=json", + } + + if generateOnly { + cmd = append(cmd, "--generate-only") + } else { + cmd = append(cmd, "-b=sync", "--yes") + } + + outBuff, _, err := n.containerManager.ExecCmd(n.t, n.Name, append(cmd, overallFlags...), "") require.NoError(n.t, err) n.LogActionF("successfully created BTC delegation") + return outBuff.String() } func (n *NodeConfig) AddCovenantSigs(covPK *bbn.BIP340PubKey, stakingTxHash string, slashingSigs [][]byte, unbondingSig *bbn.BIP340Signature, unbondingSlashingSigs [][]byte) { @@ -133,7 +144,7 @@ func (n *NodeConfig) AddCovenantSigs(covPK *bbn.BIP340PubKey, stakingTxHash stri n.LogActionF("successfully added covenant signatures") } -func (n *NodeConfig) CommitPubRandList(fpBTCPK *bbn.BIP340PubKey, startHeight uint64, pubRandList []bbn.SchnorrPubRand, sig *bbn.BIP340Signature) { +func (n *NodeConfig) CommitPubRandList(fpBTCPK *bbn.BIP340PubKey, startHeight uint64, numPubrand uint64, commitment []byte, sig *bbn.BIP340Signature) { n.LogActionF("committing public randomness list") cmd := []string{"babylond", "tx", "finality", "commit-pubrand-list"} @@ -146,11 +157,13 @@ func (n *NodeConfig) CommitPubRandList(fpBTCPK *bbn.BIP340PubKey, startHeight ui startHeightStr := strconv.FormatUint(startHeight, 10) cmd = append(cmd, startHeightStr) - // add each pubrand to cmd - for _, pr := range pubRandList { - prHex := pr.ToHexStr() - cmd = append(cmd, prHex) - } + // add num_pub_rand to cmd + numPubRandStr := strconv.FormatUint(numPubrand, 10) + cmd = append(cmd, numPubRandStr) + + // add commitment to cmd + commitmentHex := hex.EncodeToString(commitment) + cmd = append(cmd, commitmentHex) // add sig to cmd sigHex := sig.ToHexStr() @@ -160,23 +173,27 @@ func (n *NodeConfig) CommitPubRandList(fpBTCPK *bbn.BIP340PubKey, startHeight ui cmd = append(cmd, "--from=val") // gas - cmd = append(cmd, "--gas=auto", "--gas-prices=1ubbn", "--gas-adjustment=1.3") + cmd = append(cmd, "--gas=500000") _, _, err := n.containerManager.ExecTxCmd(n.t, n.chainId, n.Name, cmd) require.NoError(n.t, err) n.LogActionF("successfully committed public randomness list") } -func (n *NodeConfig) AddFinalitySig(fpBTCPK *bbn.BIP340PubKey, blockHeight uint64, blockLch []byte, finalitySig *bbn.SchnorrEOTSSig) { +func (n *NodeConfig) AddFinalitySig(fpBTCPK *bbn.BIP340PubKey, blockHeight uint64, pubRand *bbn.SchnorrPubRand, proof cmtcrypto.Proof, appHash []byte, finalitySig *bbn.SchnorrEOTSSig) { n.LogActionF("add finality signature") fpBTCPKHex := fpBTCPK.MarshalHex() blockHeightStr := strconv.FormatUint(blockHeight, 10) - blockLchHex := hex.EncodeToString(blockLch) + pubRandHex := pubRand.MarshalHex() + proofBytes, err := proof.Marshal() + require.NoError(n.t, err) + proofHex := hex.EncodeToString(proofBytes) + appHashHex := hex.EncodeToString(appHash) finalitySigHex := finalitySig.ToHexStr() - cmd := []string{"babylond", "tx", "finality", "add-finality-sig", fpBTCPKHex, blockHeightStr, blockLchHex, finalitySigHex, "--from=val", "--gas=500000"} - _, _, err := n.containerManager.ExecTxCmd(n.t, n.chainId, n.Name, cmd) + cmd := []string{"babylond", "tx", "finality", "add-finality-sig", fpBTCPKHex, blockHeightStr, pubRandHex, proofHex, appHashHex, finalitySigHex, "--from=val", "--gas=500000"} + _, _, err = n.containerManager.ExecTxCmd(n.t, n.chainId, n.Name, cmd) require.NoError(n.t, err) n.LogActionF("successfully added finality signature") } diff --git a/test/e2e/configurer/chain/node.go b/test/e2e/configurer/chain/node.go index 476db4573..f849ac5ab 100644 --- a/test/e2e/configurer/chain/node.go +++ b/test/e2e/configurer/chain/node.go @@ -13,8 +13,8 @@ import ( coretypes "github.com/cometbft/cometbft/rpc/core/types" "github.com/stretchr/testify/require" - "github.com/babylonchain/babylon/test/e2e/containers" - "github.com/babylonchain/babylon/test/e2e/initialization" + "github.com/babylonlabs-io/babylon/test/e2e/containers" + "github.com/babylonlabs-io/babylon/test/e2e/initialization" ) type NodeConfig struct { @@ -141,11 +141,16 @@ func (n *NodeConfig) WaitUntilBtcHeight(height uint64) { } func (n *NodeConfig) WaitForNextBlock() { + n.WaitForNextBlocks(1) +} + +func (n *NodeConfig) WaitForNextBlocks(numberOfBlocks uint64) { latest := n.LatestBlockNumber() + blockToWait := latest + numberOfBlocks n.WaitForCondition(func() bool { newLatest := n.LatestBlockNumber() - return newLatest > latest - }, fmt.Sprintf("Timed out waiting for next block. Current height is: %d", latest)) + return newLatest > blockToWait + }, fmt.Sprintf("Timed out waiting for block %d. Current height is: %d", latest, blockToWait)) } func (n *NodeConfig) extractOperatorAddressIfValidator() error { diff --git a/test/e2e/configurer/chain/queries.go b/test/e2e/configurer/chain/queries.go index 48b5dba6a..ff4ae0302 100644 --- a/test/e2e/configurer/chain/queries.go +++ b/test/e2e/configurer/chain/queries.go @@ -21,12 +21,12 @@ import ( banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" "github.com/stretchr/testify/require" - "github.com/babylonchain/babylon/test/e2e/util" - blc "github.com/babylonchain/babylon/x/btclightclient/types" - ct "github.com/babylonchain/babylon/x/checkpointing/types" - etypes "github.com/babylonchain/babylon/x/epoching/types" - mtypes "github.com/babylonchain/babylon/x/monitor/types" - zctypes "github.com/babylonchain/babylon/x/zoneconcierge/types" + "github.com/babylonlabs-io/babylon/test/e2e/util" + blc "github.com/babylonlabs-io/babylon/x/btclightclient/types" + 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) { @@ -175,7 +175,7 @@ func (n *NodeConfig) QueryListSnapshots() ([]*cmtabcitypes.Snapshot, error) { // return contractsResponse.Contracts, nil // } -func (n *NodeConfig) QueryRawCheckpoint(epoch uint64) (*ct.RawCheckpointWithMeta, error) { +func (n *NodeConfig) QueryRawCheckpoint(epoch uint64) (*ct.RawCheckpointWithMetaResponse, error) { path := fmt.Sprintf("babylon/checkpointing/v1/raw_checkpoint/%d", epoch) bz, err := n.QueryGRPCGateway(path, url.Values{}) require.NoError(n.t, err) @@ -206,7 +206,7 @@ func (n *NodeConfig) QueryRawCheckpoints(pagination *query.PageRequest) (*ct.Que return &checkpointingResponse, nil } -func (n *NodeConfig) QueryBtcBaseHeader() (*blc.BTCHeaderInfo, error) { +func (n *NodeConfig) QueryBtcBaseHeader() (*blc.BTCHeaderInfoResponse, error) { bz, err := n.QueryGRPCGateway("babylon/btclightclient/v1/baseheader", url.Values{}) require.NoError(n.t, err) @@ -218,7 +218,7 @@ func (n *NodeConfig) QueryBtcBaseHeader() (*blc.BTCHeaderInfo, error) { return blcResponse.Header, nil } -func (n *NodeConfig) QueryTip() (*blc.BTCHeaderInfo, error) { +func (n *NodeConfig) QueryTip() (*blc.BTCHeaderInfoResponse, error) { bz, err := n.QueryGRPCGateway("babylon/btclightclient/v1/tip", 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 cb55b0ab3..f7a735c8f 100644 --- a/test/e2e/configurer/chain/queries_btcstaking.go +++ b/test/e2e/configurer/chain/queries_btcstaking.go @@ -4,11 +4,12 @@ import ( "fmt" "net/url" - "github.com/babylonchain/babylon/test/e2e/util" - bbn "github.com/babylonchain/babylon/types" - bstypes "github.com/babylonchain/babylon/x/btcstaking/types" - ftypes "github.com/babylonchain/babylon/x/finality/types" "github.com/stretchr/testify/require" + + "github.com/babylonlabs-io/babylon/test/e2e/util" + bbn "github.com/babylonlabs-io/babylon/types" + bstypes "github.com/babylonlabs-io/babylon/x/btcstaking/types" + ftypes "github.com/babylonlabs-io/babylon/x/finality/types" ) func (n *NodeConfig) QueryBTCStakingParams() *bstypes.Params { @@ -22,7 +23,7 @@ func (n *NodeConfig) QueryBTCStakingParams() *bstypes.Params { return &resp.Params } -func (n *NodeConfig) QueryFinalityProviders() []*bstypes.FinalityProvider { +func (n *NodeConfig) QueryFinalityProviders() []*bstypes.FinalityProviderResponse { bz, err := n.QueryGRPCGateway("/babylon/btcstaking/v1/finality_providers", url.Values{}) require.NoError(n.t, err) @@ -45,7 +46,7 @@ func (n *NodeConfig) QueryActiveFinalityProvidersAtHeight(height uint64) []*bsty return resp.FinalityProviders } -func (n *NodeConfig) QueryFinalityProviderDelegations(fpBTCPK string) []*bstypes.BTCDelegatorDelegations { +func (n *NodeConfig) QueryFinalityProviderDelegations(fpBTCPK string) []*bstypes.BTCDelegatorDelegationsResponse { path := fmt.Sprintf("/babylon/btcstaking/v1/finality_providers/%s/delegations", fpBTCPK) bz, err := n.QueryGRPCGateway(path, url.Values{}) require.NoError(n.t, err) @@ -69,7 +70,18 @@ func (n *NodeConfig) QueryBtcDelegation(stakingTxHash string) *bstypes.QueryBTCD return &resp } -func (n *NodeConfig) QueryUnbondedDelegations() []*bstypes.BTCDelegation { +func (n *NodeConfig) QueryBtcDelegations() *bstypes.QueryBTCDelegationsResponse { + bz, err := n.QueryGRPCGateway("/babylon/btcstaking/v1/btc_delegations", url.Values{}) + require.NoError(n.t, err) + + var resp bstypes.QueryBTCDelegationsResponse + err = util.Cdc.UnmarshalJSON(bz, &resp) + require.NoError(n.t, err) + + return &resp +} + +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) @@ -94,6 +106,7 @@ func (n *NodeConfig) QueryActivatedHeight() uint64 { } // 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{}) @@ -106,6 +119,19 @@ func (n *NodeConfig) QueryListPublicRandomness(fpBTCPK *bbn.BIP340PubKey) map[ui return resp.PubRandMap } +// TODO: pagination support +func (n *NodeConfig) QueryListPubRandCommit(fpBTCPK *bbn.BIP340PubKey) map[uint64]*ftypes.PubRandCommitResponse { + path := fmt.Sprintf("/babylon/finality/v1/finality_providers/%s/pub_rand_commit_list", fpBTCPK.MarshalHex()) + bz, err := n.QueryGRPCGateway(path, url.Values{}) + require.NoError(n.t, err) + + var resp ftypes.QueryListPubRandCommitResponse + err = util.Cdc.UnmarshalJSON(bz, &resp) + require.NoError(n.t, err) + + return resp.PubRandCommitMap +} + func (n *NodeConfig) QueryVotesAtHeight(height uint64) []bbn.BIP340PubKey { path := fmt.Sprintf("/babylon/finality/v1/votes/%d", height) bz, err := n.QueryGRPCGateway(path, url.Values{}) diff --git a/test/e2e/configurer/chain/queries_ibc.go b/test/e2e/configurer/chain/queries_ibc.go index 621f5867c..f5889b229 100644 --- a/test/e2e/configurer/chain/queries_ibc.go +++ b/test/e2e/configurer/chain/queries_ibc.go @@ -4,7 +4,7 @@ import ( "fmt" "net/url" - "github.com/babylonchain/babylon/test/e2e/util" + "github.com/babylonlabs-io/babylon/test/e2e/util" channeltypes "github.com/cosmos/ibc-go/v8/modules/core/04-channel/types" ) diff --git a/test/e2e/configurer/chain/queries_incentive.go b/test/e2e/configurer/chain/queries_incentive.go index 5f8dce124..152c42352 100644 --- a/test/e2e/configurer/chain/queries_incentive.go +++ b/test/e2e/configurer/chain/queries_incentive.go @@ -4,14 +4,14 @@ import ( "fmt" "net/url" - "github.com/babylonchain/babylon/test/e2e/util" - incentivetypes "github.com/babylonchain/babylon/x/incentive/types" + "github.com/babylonlabs-io/babylon/test/e2e/util" + incentivetypes "github.com/babylonlabs-io/babylon/x/incentive/types" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/stretchr/testify/require" ) func (n *NodeConfig) QueryBTCStakingGauge(height uint64) (*incentivetypes.Gauge, error) { - path := fmt.Sprintf("/babylonchain/babylon/incentive/btc_staking_gauge/%d", height) + path := fmt.Sprintf("/babylon/incentive/btc_staking_gauge/%d", height) bz, err := n.QueryGRPCGateway(path, url.Values{}) if err != nil { return nil, err @@ -26,7 +26,7 @@ func (n *NodeConfig) QueryBTCStakingGauge(height uint64) (*incentivetypes.Gauge, } func (n *NodeConfig) QueryIncentiveParams() (*incentivetypes.Params, error) { - path := "/babylonchain/babylon/incentive/params" + path := "/babylon/incentive/params" bz, err := n.QueryGRPCGateway(path, url.Values{}) require.NoError(n.t, err) @@ -39,7 +39,7 @@ func (n *NodeConfig) QueryIncentiveParams() (*incentivetypes.Params, error) { } func (n *NodeConfig) QueryRewardGauge(sAddr sdk.AccAddress) (map[string]*incentivetypes.RewardGauge, error) { - path := fmt.Sprintf("/babylonchain/babylon/incentive/address/%s/reward_gauge", sAddr.String()) + path := fmt.Sprintf("/babylon/incentive/address/%s/reward_gauge", sAddr.String()) bz, err := n.QueryGRPCGateway(path, url.Values{}) if err != nil { return nil, err @@ -53,7 +53,7 @@ func (n *NodeConfig) QueryRewardGauge(sAddr sdk.AccAddress) (map[string]*incenti } func (n *NodeConfig) QueryBTCTimestampingGauge(epoch uint64) (*incentivetypes.Gauge, error) { - path := fmt.Sprintf("/babylonchain/babylon/incentive/btc_timestamping_gauge/%d", epoch) + path := fmt.Sprintf("/babylon/incentive/btc_timestamping_gauge/%d", epoch) bz, err := n.QueryGRPCGateway(path, url.Values{}) if err != nil { return nil, err diff --git a/test/e2e/configurer/current.go b/test/e2e/configurer/current.go index 32572e12e..ca2c26ae6 100644 --- a/test/e2e/configurer/current.go +++ b/test/e2e/configurer/current.go @@ -5,9 +5,9 @@ import ( "testing" "time" - "github.com/babylonchain/babylon/test/e2e/configurer/chain" - "github.com/babylonchain/babylon/test/e2e/containers" - "github.com/babylonchain/babylon/test/e2e/initialization" + "github.com/babylonlabs-io/babylon/test/e2e/configurer/chain" + "github.com/babylonlabs-io/babylon/test/e2e/containers" + "github.com/babylonlabs-io/babylon/test/e2e/initialization" ) type CurrentBranchConfigurer struct { diff --git a/test/e2e/configurer/factory.go b/test/e2e/configurer/factory.go index bcac549e5..a04a834cd 100644 --- a/test/e2e/configurer/factory.go +++ b/test/e2e/configurer/factory.go @@ -3,10 +3,10 @@ package configurer import ( "testing" - "github.com/babylonchain/babylon/test/e2e/configurer/chain" - "github.com/babylonchain/babylon/test/e2e/containers" - "github.com/babylonchain/babylon/test/e2e/initialization" - zctypes "github.com/babylonchain/babylon/x/zoneconcierge/types" + "github.com/babylonlabs-io/babylon/test/e2e/configurer/chain" + "github.com/babylonlabs-io/babylon/test/e2e/containers" + "github.com/babylonlabs-io/babylon/test/e2e/initialization" + zctypes "github.com/babylonlabs-io/babylon/x/zoneconcierge/types" ibctesting "github.com/cosmos/ibc-go/v8/testing" ) diff --git a/test/e2e/containers/config.go b/test/e2e/containers/config.go index f253858fa..9f15dcb1c 100644 --- a/test/e2e/containers/config.go +++ b/test/e2e/containers/config.go @@ -10,11 +10,10 @@ type ImageConfig struct { //nolint:deadcode const ( // name of babylon container produced by running `make localnet-build-env` - BabylonContainerName = "babylonchain/babylond" + BabylonContainerName = "babylonlabs-io/babylond" hermesRelayerRepository = "informalsystems/hermes" - // TODO: Replace with version tag once we have a working version - hermesRelayerTag = "master" + hermesRelayerTag = "v1.8.2" // Built using the `build-cosmos-relayer-docker` target on an Intel (amd64) machine and pushed to ECR cosmosRelayerRepository = "public.ecr.aws/t9e9i3h0/cosmos-relayer" // TODO: Replace with version tag once we have a working version diff --git a/test/e2e/containers/containers.go b/test/e2e/containers/containers.go index 8ce88dbd5..09782d7f1 100644 --- a/test/e2e/containers/containers.go +++ b/test/e2e/containers/containers.go @@ -21,6 +21,8 @@ const ( // The maximum number of times debug logs are printed to console // per CLI command. maxDebugLogsPerCommand = 3 + BabylonHomePath = "/home/babylon/babylondata" + FlagHome = "--home=" + BabylonHomePath ) var errRegex = regexp.MustCompile(`(E|e)rror`) @@ -89,7 +91,7 @@ func (m *Manager) ExecCmd(t *testing.T, containerName string, command []string, errBuf bytes.Buffer ) - ctx, cancel := context.WithTimeout(context.Background(), 3*time.Minute) + ctx, cancel := context.WithTimeout(context.Background(), 5*time.Minute) defer cancel() if m.isDebugLogEnabled { @@ -146,7 +148,7 @@ func (m *Manager) ExecCmd(t *testing.T, containerName string, command []string, return true }, - time.Minute, + 2*time.Minute, 50*time.Millisecond, "tx returned a non-zero code", ) @@ -256,11 +258,11 @@ func (m *Manager) RunNodeResource(chainId string, containerName, valCondifDir st Entrypoint: []string{ "sh", "-c", - "babylond start --home /home/babylon/babylondata", + "babylond start " + FlagHome, }, ExposedPorts: []string{"26656", "26657", "1317", "9090"}, Mounts: []string{ - fmt.Sprintf("%s/:/home/babylon/babylondata", valCondifDir), + fmt.Sprintf("%s/:%s", valCondifDir, BabylonHomePath), fmt.Sprintf("%s/bytecode:/bytecode", pwd), }, } diff --git a/test/e2e/e2e_test.go b/test/e2e/e2e_test.go index 4d94fd0a5..4c877c6c8 100644 --- a/test/e2e/e2e_test.go +++ b/test/e2e/e2e_test.go @@ -21,17 +21,15 @@ func TestBTCTimestampingTestSuite(t *testing.T) { // TestBTCTimestampingPhase2HermesTestSuite tests BTC timestamping phase 2 protocol end-to-end, // with the Hermes relayer -// TODO: Uncomment once we have a working Hermes version / release -//func TestBTCTimestampingPhase2HermesTestSuite(t *testing.T) { -// suite.Run(t, new(BTCTimestampingPhase2HermesTestSuite)) -//} +func TestBTCTimestampingPhase2HermesTestSuite(t *testing.T) { + suite.Run(t, new(BTCTimestampingPhase2HermesTestSuite)) +} // TestBTCTimestampingPhase2RlyTestSuite tests BTC timestamping phase 2 protocol end-to-end, // with the Go relayer -// TODO: Uncomment once we have fix broadcasting of timestamps -// func TestBTCTimestampingPhase2RlyTestSuite(t *testing.T) { -// suite.Run(t, new(BTCTimestampingPhase2RlyTestSuite)) -// } +func TestBTCTimestampingPhase2RlyTestSuite(t *testing.T) { + suite.Run(t, new(BTCTimestampingPhase2RlyTestSuite)) +} // TestBTCStakingTestSuite tests BTC staking protocol end-to-end func TestBTCStakingTestSuite(t *testing.T) { diff --git a/test/e2e/ibc_transfer_e2e_test.go b/test/e2e/ibc_transfer_e2e_test.go index 8f1848c54..c1521a467 100644 --- a/test/e2e/ibc_transfer_e2e_test.go +++ b/test/e2e/ibc_transfer_e2e_test.go @@ -3,8 +3,8 @@ package e2e import ( "time" - "github.com/babylonchain/babylon/test/e2e/configurer" - "github.com/babylonchain/babylon/test/e2e/initialization" + "github.com/babylonlabs-io/babylon/test/e2e/configurer" + "github.com/babylonlabs-io/babylon/test/e2e/initialization" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/stretchr/testify/suite" ) diff --git a/test/e2e/initialization/chain/main.go b/test/e2e/initialization/chain/main.go index 074b7968f..6d22e8e78 100644 --- a/test/e2e/initialization/chain/main.go +++ b/test/e2e/initialization/chain/main.go @@ -7,7 +7,7 @@ import ( "os" "time" - "github.com/babylonchain/babylon/test/e2e/initialization" + "github.com/babylonlabs-io/babylon/test/e2e/initialization" ) func main() { diff --git a/test/e2e/initialization/config.go b/test/e2e/initialization/config.go index 96f39e72e..3e7119ae0 100644 --- a/test/e2e/initialization/config.go +++ b/test/e2e/initialization/config.go @@ -21,13 +21,13 @@ import ( staketypes "github.com/cosmos/cosmos-sdk/x/staking/types" "github.com/cosmos/gogoproto/proto" - "github.com/babylonchain/babylon/privval" - bbn "github.com/babylonchain/babylon/types" - btccheckpointtypes "github.com/babylonchain/babylon/x/btccheckpoint/types" - blctypes "github.com/babylonchain/babylon/x/btclightclient/types" - checkpointingtypes "github.com/babylonchain/babylon/x/checkpointing/types" + "github.com/babylonlabs-io/babylon/privval" + bbn "github.com/babylonlabs-io/babylon/types" + btccheckpointtypes "github.com/babylonlabs-io/babylon/x/btccheckpoint/types" + blctypes "github.com/babylonlabs-io/babylon/x/btclightclient/types" + checkpointingtypes "github.com/babylonlabs-io/babylon/x/checkpointing/types" - "github.com/babylonchain/babylon/test/e2e/util" + "github.com/babylonlabs-io/babylon/test/e2e/util" ) // NodeConfig is a confiuration for the node supplied from the test runner @@ -314,7 +314,7 @@ func updateBtcLightClientGenesis(blcGenState *blctypes.GenesisState) { panic(err) } work := blctypes.CalcWork(&baseBtcHeader) - blcGenState.BaseBtcHeader = *blctypes.NewBTCHeaderInfo(&baseBtcHeader, baseBtcHeader.Hash(), 0, &work) + blcGenState.BtcHeaders = []*blctypes.BTCHeaderInfo{blctypes.NewBTCHeaderInfo(&baseBtcHeader, baseBtcHeader.Hash(), 0, &work)} } func updateBtccheckpointGenesis(btccheckpointGenState *btccheckpointtypes.GenesisState) { @@ -369,7 +369,7 @@ func updateCheckpointingGenesis(c *internalChain) func(*checkpointingtypes.Genes proofOfPossession, err := privval.BuildPoP(node.consensusKey.PrivKey, node.consensusKey.BlsPrivKey) if err != nil { - panic("It should be possible to build proof of possesion from validator private keys") + panic("It should be possible to build proof of possession from validator private keys") } valPubKey, err := cryptocodec.FromCmtPubKeyInterface(node.consensusKey.PubKey) diff --git a/test/e2e/initialization/export.go b/test/e2e/initialization/export.go index 1da2629ba..663250876 100644 --- a/test/e2e/initialization/export.go +++ b/test/e2e/initialization/export.go @@ -16,6 +16,7 @@ type Node struct { ConfigDir string `json:"configDir"` Mnemonic string `json:"mnemonic"` PublicAddress string `json:"publicAddress"` + WalletName string `json:"walletName"` SecretKey cryptotypes.PrivKey PublicKey []byte `json:"publicKey"` PeerId string `json:"peerId"` diff --git a/test/e2e/initialization/init.go b/test/e2e/initialization/init.go index 8dc02cee4..94e8ca3e5 100644 --- a/test/e2e/initialization/init.go +++ b/test/e2e/initialization/init.go @@ -6,8 +6,8 @@ import ( "path/filepath" "time" - "github.com/babylonchain/babylon/app" - "github.com/babylonchain/babylon/test/e2e/util" + appkeepers "github.com/babylonlabs-io/babylon/app/keepers" + "github.com/babylonlabs-io/babylon/test/e2e/util" ) func InitChain(id, dataDir string, nodeConfigs []*NodeConfig, votingPeriod, expeditedVotingPeriod time.Duration, forkHeight int) (*Chain, error) { @@ -42,7 +42,7 @@ func InitChain(id, dataDir string, nodeConfigs []*NodeConfig, votingPeriod, expe } for _, node := range chain.nodes { - _, _ = app.CreateClientConfig(node.chain.chainMeta.Id, "test", node.configDir()) + _, _ = appkeepers.CreateClientConfig(node.chain.chainMeta.Id, "test", node.configDir()) } return chain.export(), nil diff --git a/test/e2e/initialization/init_test.go b/test/e2e/initialization/init_test.go index cdebd2ef1..8d21b1b4d 100644 --- a/test/e2e/initialization/init_test.go +++ b/test/e2e/initialization/init_test.go @@ -13,7 +13,7 @@ import ( "github.com/stretchr/testify/require" - "github.com/babylonchain/babylon/test/e2e/initialization" + "github.com/babylonlabs-io/babylon/test/e2e/initialization" ) const forkHeight = 10 diff --git a/test/e2e/initialization/node.go b/test/e2e/initialization/node.go index 5c0bed9d5..4346e7b31 100644 --- a/test/e2e/initialization/node.go +++ b/test/e2e/initialization/node.go @@ -8,16 +8,12 @@ import ( "path/filepath" "strings" - "cosmossdk.io/log" "cosmossdk.io/math" - wasmkeeper "github.com/CosmWasm/wasmd/x/wasm/keeper" cmtconfig "github.com/cometbft/cometbft/config" cmted25519 "github.com/cometbft/cometbft/crypto/ed25519" cmtos "github.com/cometbft/cometbft/libs/os" "github.com/cometbft/cometbft/p2p" cmttypes "github.com/cometbft/cometbft/types" - dbm "github.com/cosmos/cosmos-db" - "github.com/cosmos/cosmos-sdk/client/flags" sdkcrypto "github.com/cosmos/cosmos-sdk/crypto" cryptocodec "github.com/cosmos/cosmos-sdk/crypto/codec" "github.com/cosmos/cosmos-sdk/crypto/hd" @@ -25,7 +21,6 @@ import ( cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types" "github.com/cosmos/cosmos-sdk/server" srvconfig "github.com/cosmos/cosmos-sdk/server/config" - simsutils "github.com/cosmos/cosmos-sdk/testutil/sims" sdk "github.com/cosmos/cosmos-sdk/types" sdktx "github.com/cosmos/cosmos-sdk/types/tx" sdksigning "github.com/cosmos/cosmos-sdk/types/tx/signing" @@ -36,12 +31,12 @@ import ( "github.com/cosmos/go-bip39" "github.com/spf13/viper" - babylonApp "github.com/babylonchain/babylon/app" - "github.com/babylonchain/babylon/cmd/babylond/cmd" - "github.com/babylonchain/babylon/crypto/bls12381" - "github.com/babylonchain/babylon/privval" - "github.com/babylonchain/babylon/test/e2e/util" - bbn "github.com/babylonchain/babylon/types" + babylonApp "github.com/babylonlabs-io/babylon/app" + "github.com/babylonlabs-io/babylon/cmd/babylond/cmd" + "github.com/babylonlabs-io/babylon/crypto/bls12381" + "github.com/babylonlabs-io/babylon/privval" + "github.com/babylonlabs-io/babylon/test/e2e/util" + bbn "github.com/babylonlabs-io/babylon/types" ) type internalNode struct { @@ -252,6 +247,7 @@ func (n *internalNode) export() *Node { ConfigDir: n.configDir(), Mnemonic: n.mnemonic, PublicAddress: addr.String(), + WalletName: n.keyInfo.Name, SecretKey: n.privateKey, PublicKey: pub.Bytes(), PeerId: n.peerId, @@ -298,28 +294,13 @@ func (n *internalNode) init() error { config.SetRoot(n.configDir()) config.Moniker = n.moniker - appOptions := make(simsutils.AppOptionsMap, 0) - appOptions[flags.FlagHome] = n.configDir() - appOptions["btc-config.network"] = string(bbn.BtcSimnet) - - privSigner := &babylonApp.PrivSigner{WrappedPV: &privval.WrappedFilePV{Key: n.consensusKey}} - // Create a temp app to get the default genesis state - tempApp := babylonApp.NewBabylonApp( - log.NewNopLogger(), - dbm.NewMemDB(), - nil, - true, - map[int64]bool{}, - 0, - privSigner, - appOptions, - []wasmkeeper.Option{}) - appGenesis, err := n.getAppGenesis() if err != nil { return err } + // Create a temp app to get the default genesis state + tempApp := babylonApp.NewTmpBabylonApp() appState, err := json.MarshalIndent(tempApp.DefaultGenesis(), "", " ") if err != nil { return fmt.Errorf("failed to JSON encode app genesis state: %w", err) diff --git a/test/e2e/initialization/node/main.go b/test/e2e/initialization/node/main.go index 7ed274975..3a3a0a858 100644 --- a/test/e2e/initialization/node/main.go +++ b/test/e2e/initialization/node/main.go @@ -7,7 +7,7 @@ import ( "strings" "time" - "github.com/babylonchain/babylon/test/e2e/initialization" + "github.com/babylonlabs-io/babylon/test/e2e/initialization" ) func main() { @@ -63,7 +63,7 @@ func main() { panic("persistent peers are required, separated by commas") } - if err := os.MkdirAll(dataDir, 0o755); err != nil { + if err := os.MkdirAll(dataDir, 0750); err != nil { panic(err) } diff --git a/test/e2e/initialization/util.go b/test/e2e/initialization/util.go index 3346f2b5d..fbcc6714a 100644 --- a/test/e2e/initialization/util.go +++ b/test/e2e/initialization/util.go @@ -6,7 +6,7 @@ import ( "github.com/cosmos/cosmos-sdk/codec/unknownproto" sdktx "github.com/cosmos/cosmos-sdk/types/tx" - "github.com/babylonchain/babylon/test/e2e/util" + "github.com/babylonlabs-io/babylon/test/e2e/util" ) func decodeTx(txBytes []byte) (*sdktx.Tx, error) { diff --git a/test/e2e/scripts/download_release.sh b/test/e2e/scripts/download_release.sh index 77e35985d..060dcb1d3 100755 --- a/test/e2e/scripts/download_release.sh +++ b/test/e2e/scripts/download_release.sh @@ -2,7 +2,7 @@ set -o nounset -o pipefail command -v shellcheck >/dev/null && shellcheck "$0" -OWNER="babylonchain" +OWNER="babylonlabs-io" REPO="babylon-contract" CONTRACT="babylon_contract" OUTPUT_FOLDER="$(dirname "$0")/../bytecode" @@ -20,7 +20,10 @@ GH_TAGS="$GH_REPO/releases/tags/$TAG" AUTH="Authorization: token $GITHUB_API_TOKEN" # Validate token -curl -o /dev/null -sH "$AUTH" $GH_REPO || { echo "Error: Invalid repo, token or network issue!"; exit 1; } +curl -o /dev/null -sH "$AUTH" $GH_REPO || { + echo "Error: Invalid repo, token or network issue!" + exit 1 +} # Read asset tags RESPONSE=$(curl -sH "$AUTH" "$GH_TAGS") diff --git a/test/e2e/util/codec.go b/test/e2e/util/codec.go index fd633f711..3e078ffdc 100644 --- a/test/e2e/util/codec.go +++ b/test/e2e/util/codec.go @@ -1,8 +1,8 @@ package util import ( - "github.com/babylonchain/babylon/app" - "github.com/babylonchain/babylon/app/params" + "github.com/babylonlabs-io/babylon/app" + "github.com/babylonlabs-io/babylon/app/params" "github.com/cosmos/cosmos-sdk/codec" "github.com/cosmos/cosmos-sdk/crypto/keys/ed25519" diff --git a/testutil/datagen/account_balance.go b/testutil/datagen/account_balance.go index 5530ecea5..d748c2939 100644 --- a/testutil/datagen/account_balance.go +++ b/testutil/datagen/account_balance.go @@ -2,7 +2,7 @@ package datagen import ( sdkmath "cosmossdk.io/math" - appparams "github.com/babylonchain/babylon/app/params" + appparams "github.com/babylonlabs-io/babylon/app/params" sec256k1 "github.com/cosmos/cosmos-sdk/crypto/keys/secp256k1" sdk "github.com/cosmos/cosmos-sdk/types" authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" diff --git a/testutil/datagen/btc_address_test.go b/testutil/datagen/btc_address_test.go index b1da6d13e..8a560c66e 100644 --- a/testutil/datagen/btc_address_test.go +++ b/testutil/datagen/btc_address_test.go @@ -4,7 +4,7 @@ import ( "math/rand" "testing" - "github.com/babylonchain/babylon/testutil/datagen" + "github.com/babylonlabs-io/babylon/testutil/datagen" "github.com/btcsuite/btcd/btcutil" "github.com/btcsuite/btcd/chaincfg" "github.com/stretchr/testify/require" diff --git a/testutil/datagen/btc_blockchain.go b/testutil/datagen/btc_blockchain.go index 1beb797cd..3e3ee42ec 100644 --- a/testutil/datagen/btc_blockchain.go +++ b/testutil/datagen/btc_blockchain.go @@ -4,7 +4,7 @@ import ( "math/big" "math/rand" - "github.com/babylonchain/babylon/btctxformatter" + "github.com/babylonlabs-io/babylon/btctxformatter" "github.com/btcsuite/btcd/blockchain" "github.com/btcsuite/btcd/chaincfg" "github.com/btcsuite/btcd/chaincfg/chainhash" diff --git a/testutil/datagen/btc_header_chain.go b/testutil/datagen/btc_header_chain.go index f2d37ed7f..e28421ef3 100644 --- a/testutil/datagen/btc_header_chain.go +++ b/testutil/datagen/btc_header_chain.go @@ -4,8 +4,8 @@ import ( "math/rand" sdkmath "cosmossdk.io/math" - bbn "github.com/babylonchain/babylon/types" - "github.com/babylonchain/babylon/x/btclightclient/types" + bbn "github.com/babylonlabs-io/babylon/types" + "github.com/babylonlabs-io/babylon/x/btclightclient/types" "github.com/btcsuite/btcd/chaincfg" "github.com/btcsuite/btcd/wire" ) @@ -69,10 +69,32 @@ func NewBTCHeaderChainFromParent( } } +func NewBTCHeaderChainFromParentInfoResponse( + r *rand.Rand, + parent *types.BTCHeaderInfoResponse, + length uint32, +) *BTCHeaderPartialChain { + headerBytes, err := bbn.NewBTCHeaderBytesFromHex(parent.HeaderHex) + if err != nil { + panic(err) + } + return NewBTCHeaderChainFromParent( + r, + parent.Height+1, + parent.Work, + headerBytes.ToBlockHeader(), + length, + ) +} + func (c *BTCHeaderPartialChain) GetChainInfo() []*types.BTCHeaderInfo { return ChainToInfoChain(c.Headers, c.initialHeaderHeight, c.inititialHeaderTotalWork) } +func (c *BTCHeaderPartialChain) GetChainInfoResponse() []*types.BTCHeaderInfoResponse { + return ChainToInfoResponseChain(c.Headers, c.initialHeaderHeight, c.inititialHeaderTotalWork) +} + func (c *BTCHeaderPartialChain) ChainToBytes() []bbn.BTCHeaderBytes { chainBytes := make([]bbn.BTCHeaderBytes, 0) for _, header := range c.Headers { diff --git a/testutil/datagen/btc_header_info.go b/testutil/datagen/btc_header_info.go index 7cd54ebf9..91230a1dd 100644 --- a/testutil/datagen/btc_header_info.go +++ b/testutil/datagen/btc_header_info.go @@ -1,17 +1,21 @@ package datagen import ( + "context" "math/big" "math/rand" + "testing" "time" sdkmath "cosmossdk.io/math" - bbn "github.com/babylonchain/babylon/types" - btclightclienttypes "github.com/babylonchain/babylon/x/btclightclient/types" + bbn "github.com/babylonlabs-io/babylon/types" + btclightclientk "github.com/babylonlabs-io/babylon/x/btclightclient/keeper" + btclightclienttypes "github.com/babylonlabs-io/babylon/x/btclightclient/types" "github.com/btcsuite/btcd/blockchain" "github.com/btcsuite/btcd/chaincfg" "github.com/btcsuite/btcd/chaincfg/chainhash" "github.com/btcsuite/btcd/wire" + "github.com/stretchr/testify/require" ) type RetargetInfo struct { @@ -270,6 +274,34 @@ func GenRandomValidChainStartingFrom( return headers } +// GenRandBtcChainInsertingInKeeper generates random BTCHeaderInfo and insert its headers +// into the keeper store. +// this function must not be used at difficulty adjustment boundaries, as then +// difficulty adjustment calculation will fail +func GenRandBtcChainInsertingInKeeper( + t *testing.T, + r *rand.Rand, + k *btclightclientk.Keeper, + ctx context.Context, + initialHeight uint64, + chainLength uint64, +) (*btclightclienttypes.BTCHeaderInfo, *BTCHeaderPartialChain) { + genesisHeader := NewBTCHeaderChainWithLength(r, initialHeight, 0, 1) + genesisHeaderInfo := genesisHeader.GetChainInfo()[0] + k.SetBaseBTCHeader(ctx, *genesisHeaderInfo) + randomChain := NewBTCHeaderChainFromParentInfo( + r, + genesisHeaderInfo, + uint32(chainLength), + ) + err := k.InsertHeaders(ctx, randomChain.ChainToBytes()) + require.NoError(t, err) + tip := k.GetTipInfo(ctx) + randomChainTipInfo := randomChain.GetTipInfo() + require.True(t, tip.Eq(randomChainTipInfo)) + return genesisHeaderInfo, randomChain +} + func ChainToInfoChain( chain []*wire.BlockHeader, initialHeaderNumber uint64, @@ -306,6 +338,42 @@ func ChainToInfoChain( return infoChain } +func ChainToInfoResponseChain( + chain []*wire.BlockHeader, + initialHeaderNumber uint64, + initialHeaderTotalWork sdkmath.Uint, +) []*btclightclienttypes.BTCHeaderInfoResponse { + if len(chain) == 0 { + return []*btclightclienttypes.BTCHeaderInfoResponse{} + } + + infoChain := make([]*btclightclienttypes.BTCHeaderInfoResponse, len(chain)) + + totalDifficulty := initialHeaderTotalWork + + for i, header := range chain { + headerWork := btclightclienttypes.CalcHeaderWork(header) + headerTotalDifficulty := btclightclienttypes.CumulativeWork(headerWork, totalDifficulty) + hash := header.BlockHash() + headerBytes := bbn.NewBTCHeaderBytesFromBlockHeader(header) + headerHash := bbn.NewBTCHeaderHashBytesFromChainhash(&hash) + headerNumber := initialHeaderNumber + uint64(i) + + headerInfoResponse := btclightclienttypes.NewBTCHeaderInfoResponse( + &headerBytes, + &headerHash, + headerNumber, + &headerTotalDifficulty, + ) + + infoChain[i] = headerInfoResponse + + totalDifficulty = headerTotalDifficulty + } + + return infoChain +} + func HeaderToHeaderBytes(headers []*wire.BlockHeader) []bbn.BTCHeaderBytes { headerBytes := make([]bbn.BTCHeaderBytes, len(headers)) for i, header := range headers { diff --git a/testutil/datagen/btc_schnorr.go b/testutil/datagen/btc_schnorr.go index 1eec8d047..3068d0923 100644 --- a/testutil/datagen/btc_schnorr.go +++ b/testutil/datagen/btc_schnorr.go @@ -3,7 +3,7 @@ package datagen import ( "math/rand" - bbn "github.com/babylonchain/babylon/types" + bbn "github.com/babylonlabs-io/babylon/types" "github.com/btcsuite/btcd/btcec/v2" "github.com/decred/dcrd/dcrec/secp256k1/v4" ) diff --git a/testutil/datagen/btc_transaction.go b/testutil/datagen/btc_transaction.go index 9bcdad7f9..ae6a58947 100644 --- a/testutil/datagen/btc_transaction.go +++ b/testutil/datagen/btc_transaction.go @@ -17,9 +17,9 @@ import ( "github.com/btcsuite/btcd/wire" sdk "github.com/cosmos/cosmos-sdk/types" - txformat "github.com/babylonchain/babylon/btctxformatter" - bbn "github.com/babylonchain/babylon/types" - btcctypes "github.com/babylonchain/babylon/x/btccheckpoint/types" + txformat "github.com/babylonlabs-io/babylon/btctxformatter" + bbn "github.com/babylonlabs-io/babylon/types" + btcctypes "github.com/babylonlabs-io/babylon/x/btccheckpoint/types" ) var ( diff --git a/testutil/datagen/btcstaking.go b/testutil/datagen/btcstaking.go index 9bcdcba52..ed2ed828a 100644 --- a/testutil/datagen/btcstaking.go +++ b/testutil/datagen/btcstaking.go @@ -1,25 +1,23 @@ package datagen import ( - "fmt" "math/rand" "testing" sdkmath "cosmossdk.io/math" + sdk "github.com/cosmos/cosmos-sdk/types" "github.com/btcsuite/btcd/btcec/v2" "github.com/btcsuite/btcd/btcutil" "github.com/btcsuite/btcd/chaincfg" "github.com/btcsuite/btcd/txscript" "github.com/btcsuite/btcd/wire" - "github.com/cosmos/cosmos-sdk/crypto/keys/secp256k1" - cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types" stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" "github.com/stretchr/testify/require" - "github.com/babylonchain/babylon/btcstaking" - bbn "github.com/babylonchain/babylon/types" - bstypes "github.com/babylonchain/babylon/x/btcstaking/types" + "github.com/babylonlabs-io/babylon/btcstaking" + bbn "github.com/babylonlabs-io/babylon/types" + bstypes "github.com/babylonlabs-io/babylon/x/btcstaking/types" ) const ( @@ -47,36 +45,35 @@ func CreateNFinalityProviders(r *rand.Rand, t *testing.T, n int) []*bstypes.Fina } func GenRandomFinalityProviderWithBTCSK(r *rand.Rand, btcSK *btcec.PrivateKey) (*bstypes.FinalityProvider, error) { - bbnSK, _, err := GenRandomSecp256k1KeyPair(r) - if err != nil { - return nil, err - } - return GenRandomFinalityProviderWithBTCBabylonSKs(r, btcSK, bbnSK) + return GenRandomFinalityProviderWithBTCBabylonSKs(r, btcSK, GenRandomAccount().GetAddress()) +} + +func GenRandomCommission(r *rand.Rand) sdkmath.LegacyDec { + return sdkmath.LegacyNewDecWithPrec(int64(RandomInt(r, 49)+1), 2) // [1/100, 50/100] +} + +func GenRandomDescription(r *rand.Rand) *stakingtypes.Description { + return &stakingtypes.Description{Moniker: GenRandomHexStr(r, 10)} } -func GenRandomFinalityProviderWithBTCBabylonSKs(r *rand.Rand, btcSK *btcec.PrivateKey, bbnSK cryptotypes.PrivKey) (*bstypes.FinalityProvider, error) { +func GenRandomFinalityProviderWithBTCBabylonSKs(r *rand.Rand, btcSK *btcec.PrivateKey, fpAddr sdk.AccAddress) (*bstypes.FinalityProvider, error) { // commission - commission := sdkmath.LegacyNewDecWithPrec(int64(RandomInt(r, 49)+1), 2) // [1/100, 50/100] + commission := GenRandomCommission(r) // description - description := stakingtypes.Description{Moniker: GenRandomHexStr(r, 10)} + description := GenRandomDescription(r) // key pairs btcPK := btcSK.PubKey() bip340PK := bbn.NewBIP340PubKeyFromBTCPK(btcPK) - bbnPK := bbnSK.PubKey() - secp256k1PK, ok := bbnPK.(*secp256k1.PubKey) - if !ok { - return nil, fmt.Errorf("failed to assert bbnPK to *secp256k1.PubKey") - } // pop - pop, err := bstypes.NewPoP(bbnSK, btcSK) + pop, err := bstypes.NewPoPBTC(fpAddr, btcSK) if err != nil { return nil, err } return &bstypes.FinalityProvider{ - Description: &description, + Description: description, Commission: &commission, - BabylonPk: secp256k1PK, BtcPk: bip340PK, + Addr: fpAddr.String(), Pop: pop, }, nil } @@ -85,55 +82,35 @@ func GenRandomFinalityProviderWithBTCBabylonSKs(r *rand.Rand, btcSK *btcec.Priva func GenRandomBTCDelegation( r *rand.Rand, t *testing.T, + btcNet *chaincfg.Params, fpBTCPKs []bbn.BIP340PubKey, delSK *btcec.PrivateKey, covenantSKs []*btcec.PrivateKey, + covenantPks []*btcec.PublicKey, covenantQuorum uint32, slashingAddress string, startHeight, endHeight, totalSat uint64, slashingRate sdkmath.LegacyDec, slashingChangeLockTime uint16, ) (*bstypes.BTCDelegation, error) { - net := &chaincfg.SimNetParams delPK := delSK.PubKey() delBTCPK := bbn.NewBIP340PubKeyFromBTCPK(delPK) - // list of covenant PKs - covenantBTCPKs := []*btcec.PublicKey{} - for _, covenantSK := range covenantSKs { - covenantBTCPKs = append(covenantBTCPKs, covenantSK.PubKey()) - } - // list of finality provider PKs - fpPKs := []*btcec.PublicKey{} - for _, fpBTCPK := range fpBTCPKs { - fpPK, err := fpBTCPK.ToBTCPK() - if err != nil { - return nil, err - } - fpPKs = append(fpPKs, fpPK) - } - // BTC delegation Babylon key pairs - bbnSK, bbnPK, err := GenRandomSecp256k1KeyPair(r) - if err != nil { - return nil, err - } - secp256k1PK, ok := bbnPK.(*secp256k1.PubKey) - if !ok { - return nil, fmt.Errorf("failed to assert bbnPK to *secp256k1.PubKey") - } - // pop - pop, err := bstypes.NewPoP(bbnSK, delSK) + // list of finality provider PKs + fpPKs, err := bbn.NewBTCPKsFromBIP340PKs(fpBTCPKs) if err != nil { return nil, err } + staker := GenRandomAccount() + // staking/slashing tx stakingSlashingInfo := GenBTCStakingSlashingInfo( r, t, - net, + btcNet, delSK, fpPKs, - covenantBTCPKs, + covenantPks, covenantQuorum, uint16(endHeight-startHeight), int64(totalSat), @@ -145,22 +122,20 @@ func GenRandomBTCDelegation( slashingPathSpendInfo, err := stakingSlashingInfo.StakingInfo.SlashingPathSpendInfo() require.NoError(t, err) - stakingMsgTx := stakingSlashingInfo.StakingTx - - // delegator sig + // delegator pre-signs slashing tx delegatorSig, err := stakingSlashingInfo.SlashingTx.Sign( - stakingMsgTx, + stakingSlashingInfo.StakingTx, StakingOutIdx, slashingPathSpendInfo.GetPkScriptPath(), delSK, ) require.NoError(t, err) - // covenant sigs + // covenant pre-signs slashing tx covenantSigs, err := GenCovenantAdaptorSigs( covenantSKs, fpPKs, - stakingMsgTx, + stakingSlashingInfo.StakingTx, slashingPathSpendInfo.GetPkScriptPath(), stakingSlashingInfo.SlashingTx, ) @@ -169,8 +144,12 @@ func GenRandomBTCDelegation( serializedStakingTx, err := bbn.SerializeBTCTx(stakingSlashingInfo.StakingTx) require.NoError(t, err) w := uint16(100) // TODO: parameterise w + + pop, err := bstypes.NewPoPBTC(sdk.MustAccAddressFromBech32(staker.Address), delSK) + require.NoError(t, err) + del := &bstypes.BTCDelegation{ - BabylonPk: secp256k1PK, + StakerAddr: staker.Address, BtcPk: delBTCPK, Pop: pop, FpBtcPkList: fpBTCPKs, @@ -196,10 +175,10 @@ func GenRandomBTCDelegation( unbondingSlashingInfo := GenBTCUnbondingSlashingInfo( r, t, - net, + btcNet, delSK, fpPKs, - covenantBTCPKs, + covenantPks, covenantQuorum, wire.NewOutPoint(&stkTxHash, StakingOutIdx), w+1, @@ -229,7 +208,7 @@ func GenRandomBTCDelegation( covUnbondingSlashingSigs, covUnbondingSigs, err := unbondingSlashingInfo.GenCovenantSigs( covenantSKs, fpPKs, - stakingMsgTx, + stakingSlashingInfo.StakingTx, unbondingPathSpendInfo.GetPkScriptPath(), ) require.NoError(t, err) diff --git a/testutil/datagen/covenant.go b/testutil/datagen/covenant.go index ae2fd835b..03f2944ac 100644 --- a/testutil/datagen/covenant.go +++ b/testutil/datagen/covenant.go @@ -1,10 +1,10 @@ package datagen import ( - "github.com/babylonchain/babylon/btcstaking" - asig "github.com/babylonchain/babylon/crypto/schnorr-adaptor-signature" - bbn "github.com/babylonchain/babylon/types" - bstypes "github.com/babylonchain/babylon/x/btcstaking/types" + "github.com/babylonlabs-io/babylon/btcstaking" + asig "github.com/babylonlabs-io/babylon/crypto/schnorr-adaptor-signature" + bbn "github.com/babylonlabs-io/babylon/types" + bstypes "github.com/babylonlabs-io/babylon/x/btcstaking/types" "github.com/btcsuite/btcd/btcec/v2" "github.com/btcsuite/btcd/btcec/v2/schnorr" "github.com/btcsuite/btcd/wire" @@ -12,7 +12,7 @@ import ( func GenCovenantAdaptorSigs( covenantSKs []*btcec.PrivateKey, - valPKs []*btcec.PublicKey, + fpPKs []*btcec.PublicKey, fundingTx *wire.MsgTx, pkScriptPath []byte, slashingTx *bstypes.BTCSlashingTx, @@ -23,8 +23,8 @@ func GenCovenantAdaptorSigs( CovPk: bbn.NewBIP340PubKeyFromBTCPK(covenantSK.PubKey()), AdaptorSigs: [][]byte{}, } - for _, valPK := range valPKs { - encKey, err := asig.NewEncryptionKeyFromBTCPK(valPK) + for _, fpPK := range fpPKs { + encKey, err := asig.NewEncryptionKeyFromBTCPK(fpPK) if err != nil { return nil, err } diff --git a/testutil/datagen/epoching.go b/testutil/datagen/epoching.go index 6cec642f1..3e4dc40b3 100644 --- a/testutil/datagen/epoching.go +++ b/testutil/datagen/epoching.go @@ -3,7 +3,7 @@ package datagen import ( "math/rand" - epochingtypes "github.com/babylonchain/babylon/x/epoching/types" + epochingtypes "github.com/babylonlabs-io/babylon/x/epoching/types" ) // getFirstBlockHeight returns the height of the first block of a given epoch and epoch interval diff --git a/testutil/datagen/finality.go b/testutil/datagen/finality.go index 73eae543b..ad6a6f12e 100644 --- a/testutil/datagen/finality.go +++ b/testutil/datagen/finality.go @@ -3,31 +3,49 @@ package datagen import ( "math/rand" - "github.com/babylonchain/babylon/crypto/eots" - bbn "github.com/babylonchain/babylon/types" - ftypes "github.com/babylonchain/babylon/x/finality/types" + "github.com/babylonlabs-io/babylon/crypto/eots" + bbn "github.com/babylonlabs-io/babylon/types" + ftypes "github.com/babylonlabs-io/babylon/x/finality/types" "github.com/btcsuite/btcd/btcec/v2" "github.com/btcsuite/btcd/btcec/v2/schnorr" + "github.com/cometbft/cometbft/crypto/merkle" sdk "github.com/cosmos/cosmos-sdk/types" ) -func GenRandomPubRandList(r *rand.Rand, numPubRand uint64) ([]*eots.PrivateRand, []bbn.SchnorrPubRand, error) { +type RandListInfo struct { + SRList []*eots.PrivateRand + PRList []bbn.SchnorrPubRand + Commitment []byte + ProofList []*merkle.Proof +} + +func GenRandomPubRandList(r *rand.Rand, numPubRand uint64) (*RandListInfo, error) { + // generate a list of secret/public randomness srList := []*eots.PrivateRand{} prList := []bbn.SchnorrPubRand{} for i := uint64(0); i < numPubRand; i++ { eotsSR, eotsPR, err := eots.RandGen(r) if err != nil { - return nil, nil, err + return nil, err } pr := bbn.NewSchnorrPubRandFromFieldVal(eotsPR) srList = append(srList, eotsSR) prList = append(prList, *pr) } - return srList, prList, nil + + prByteList := [][]byte{} + for i := range prList { + prByteList = append(prByteList, prList[i]) + } + + // generate the commitment to these public randomness + commitment, proofList := merkle.ProofsFromByteSlices(prByteList) + + return &RandListInfo{srList, prList, commitment, proofList}, nil } -func GenRandomMsgCommitPubRandList(r *rand.Rand, sk *btcec.PrivateKey, startHeight uint64, numPubRand uint64) ([]*eots.PrivateRand, *ftypes.MsgCommitPubRandList, error) { - srList, prList, err := GenRandomPubRandList(r, numPubRand) +func GenRandomMsgCommitPubRandList(r *rand.Rand, sk *btcec.PrivateKey, startHeight uint64, numPubRand uint64) (*RandListInfo, *ftypes.MsgCommitPubRandList, error) { + randListInfo, err := GenRandomPubRandList(r, numPubRand) if err != nil { return nil, nil, err } @@ -36,7 +54,8 @@ func GenRandomMsgCommitPubRandList(r *rand.Rand, sk *btcec.PrivateKey, startHeig Signer: GenRandomAccount().Address, FpBtcPk: bbn.NewBIP340PubKeyFromBTCPK(sk.PubKey()), StartHeight: startHeight, - PubRandList: prList, + NumPubRand: numPubRand, + Commitment: randListInfo.Commitment, } hash, err := msg.HashToSign() if err != nil { @@ -47,7 +66,36 @@ func GenRandomMsgCommitPubRandList(r *rand.Rand, sk *btcec.PrivateKey, startHeig return nil, nil, err } msg.Sig = bbn.NewBIP340SignatureFromBTCSig(schnorrSig) - return srList, msg, nil + return randListInfo, msg, nil +} + +func NewMsgAddFinalitySig( + signer string, + sk *btcec.PrivateKey, + startHeight uint64, + blockHeight uint64, + randListInfo *RandListInfo, + blockAppHash []byte, +) (*ftypes.MsgAddFinalitySig, error) { + idx := blockHeight - startHeight + + msg := &ftypes.MsgAddFinalitySig{ + Signer: signer, + FpBtcPk: bbn.NewBIP340PubKeyFromBTCPK(sk.PubKey()), + PubRand: &randListInfo.PRList[idx], + Proof: randListInfo.ProofList[idx].ToProto(), + BlockHeight: blockHeight, + BlockAppHash: blockAppHash, + FinalitySig: nil, + } + msgToSign := msg.MsgToSign() + sig, err := eots.Sign(sk, randListInfo.SRList[idx], msgToSign) + if err != nil { + return nil, err + } + msg.FinalitySig = bbn.NewSchnorrEOTSSigFromModNScalar(sig) + + return msg, nil } func GenRandomEvidence(r *rand.Rand, sk *btcec.PrivateKey, height uint64) (*ftypes.Evidence, error) { diff --git a/testutil/datagen/genesiskey.go b/testutil/datagen/genesiskey.go index 3b15e14ad..77bffb8af 100644 --- a/testutil/datagen/genesiskey.go +++ b/testutil/datagen/genesiskey.go @@ -1,6 +1,11 @@ package datagen import ( + "github.com/babylonlabs-io/babylon/app" + appkeepers "github.com/babylonlabs-io/babylon/app/keepers" + "github.com/babylonlabs-io/babylon/crypto/bls12381" + "github.com/babylonlabs-io/babylon/privval" + checkpointingtypes "github.com/babylonlabs-io/babylon/x/checkpointing/types" cmtcrypto "github.com/cometbft/cometbft/crypto" cmted25519 "github.com/cometbft/cometbft/crypto/ed25519" "github.com/cosmos/cosmos-sdk/crypto/codec" @@ -8,11 +13,6 @@ import ( cosmosed "github.com/cosmos/cosmos-sdk/crypto/keys/ed25519" "github.com/cosmos/cosmos-sdk/crypto/keys/secp256k1" sdk "github.com/cosmos/cosmos-sdk/types" - - "github.com/babylonchain/babylon/app" - "github.com/babylonchain/babylon/crypto/bls12381" - "github.com/babylonchain/babylon/privval" - checkpointingtypes "github.com/babylonchain/babylon/x/checkpointing/types" ) type GenesisValidators struct { @@ -88,7 +88,7 @@ func GenesisValidatorSet(numVals int) (*GenesisValidators, error) { // GenesisValidatorSetWithPrivSigner generates a set with `numVals` genesis validators // along with the privSigner, which will be in the 0th position of the return validator set -func GenesisValidatorSetWithPrivSigner(numVals int) (*GenesisValidators, *app.PrivSigner, error) { +func GenesisValidatorSetWithPrivSigner(numVals int) (*GenesisValidators, *appkeepers.PrivSigner, error) { ps, err := app.SetupTestPrivSigner() if err != nil { return nil, nil, err diff --git a/testutil/datagen/incentive.go b/testutil/datagen/incentive.go index 327a746e0..2cd0e10b6 100644 --- a/testutil/datagen/incentive.go +++ b/testutil/datagen/incentive.go @@ -4,10 +4,9 @@ import ( "math/rand" sdkmath "cosmossdk.io/math" - btcctypes "github.com/babylonchain/babylon/x/btccheckpoint/types" - bstypes "github.com/babylonchain/babylon/x/btcstaking/types" - itypes "github.com/babylonchain/babylon/x/incentive/types" - "github.com/cosmos/cosmos-sdk/crypto/keys/secp256k1" + btcctypes "github.com/babylonlabs-io/babylon/x/btccheckpoint/types" + bstypes "github.com/babylonlabs-io/babylon/x/btcstaking/types" + itypes "github.com/babylonlabs-io/babylon/x/incentive/types" sdk "github.com/cosmos/cosmos-sdk/types" ) @@ -77,11 +76,16 @@ func GenRandomGauge(r *rand.Rand) *itypes.Gauge { return itypes.NewGauge(coins...) } -func GenRandomBTCDelDistInfo(r *rand.Rand) *bstypes.BTCDelDistInfo { +func GenRandomBTCDelDistInfo(r *rand.Rand) (*bstypes.BTCDelDistInfo, error) { + btcPK, err := GenRandomBIP340PubKey(r) + if err != nil { + return nil, err + } return &bstypes.BTCDelDistInfo{ - BabylonPk: GenRandomAccount().GetPubKey().(*secp256k1.PubKey), + BtcPk: btcPK, + StakerAddr: GenRandomAccount().Address, VotingPower: RandomInt(r, 1000) + 1, - } + }, nil } func GenRandomFinalityProviderDistInfo(r *rand.Rand) (*bstypes.FinalityProviderDistInfo, error) { @@ -95,15 +99,18 @@ func GenRandomFinalityProviderDistInfo(r *rand.Rand) (*bstypes.FinalityProviderD // add a random number of BTC delegation distribution info numBTCDels := RandomInt(r, 100) + 1 for i := uint64(0); i < numBTCDels; i++ { - btcDelDistInfo := GenRandomBTCDelDistInfo(r) + btcDelDistInfo, err := GenRandomBTCDelDistInfo(r) + if err != nil { + return nil, err + } fpDistInfo.BtcDels = append(fpDistInfo.BtcDels, btcDelDistInfo) fpDistInfo.TotalVotingPower += btcDelDistInfo.VotingPower } return fpDistInfo, nil } -func GenRandomBTCStakingRewardDistCache(r *rand.Rand) (*bstypes.RewardDistCache, error) { - rdc := bstypes.NewRewardDistCache() +func GenRandomVotingPowerDistCache(r *rand.Rand, maxFPs uint32) (*bstypes.VotingPowerDistCache, error) { + dc := bstypes.NewVotingPowerDistCache() // a random number of finality providers numFps := RandomInt(r, 10) + 1 for i := uint64(0); i < numFps; i++ { @@ -111,9 +118,10 @@ func GenRandomBTCStakingRewardDistCache(r *rand.Rand) (*bstypes.RewardDistCache, if err != nil { return nil, err } - rdc.AddFinalityProviderDistInfo(v) + dc.AddFinalityProviderDistInfo(v) } - return rdc, nil + dc.ApplyActiveFinalityProviders(maxFPs) + return dc, nil } func GenRandomCheckpointAddressPair(r *rand.Rand) *btcctypes.CheckpointAddressPair { diff --git a/testutil/datagen/init_val.go b/testutil/datagen/init_val.go index 5870ca8cf..46e883b46 100644 --- a/testutil/datagen/init_val.go +++ b/testutil/datagen/init_val.go @@ -11,8 +11,8 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/go-bip39" - "github.com/babylonchain/babylon/crypto/bls12381" - "github.com/babylonchain/babylon/privval" + "github.com/babylonlabs-io/babylon/crypto/bls12381" + "github.com/babylonlabs-io/babylon/privval" ) // InitializeNodeValidatorFiles creates private validator and p2p configuration files. diff --git a/testutil/datagen/raw_checkpoint.go b/testutil/datagen/raw_checkpoint.go index 88512ab0f..cc6d8d80a 100644 --- a/testutil/datagen/raw_checkpoint.go +++ b/testutil/datagen/raw_checkpoint.go @@ -5,9 +5,9 @@ import ( "github.com/boljen/go-bitmap" - txformat "github.com/babylonchain/babylon/btctxformatter" - "github.com/babylonchain/babylon/crypto/bls12381" - "github.com/babylonchain/babylon/x/checkpointing/types" + txformat "github.com/babylonlabs-io/babylon/btctxformatter" + "github.com/babylonlabs-io/babylon/crypto/bls12381" + "github.com/babylonlabs-io/babylon/x/checkpointing/types" ) const ( diff --git a/testutil/datagen/tendermint.go b/testutil/datagen/tendermint.go index cea24c2e5..c09368739 100644 --- a/testutil/datagen/tendermint.go +++ b/testutil/datagen/tendermint.go @@ -9,7 +9,7 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" ibctmtypes "github.com/cosmos/ibc-go/v8/modules/light-clients/07-tendermint" - zctypes "github.com/babylonchain/babylon/x/zoneconcierge/types" + 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 8c55f9bec..b98429e29 100644 --- a/testutil/datagen/val_set.go +++ b/testutil/datagen/val_set.go @@ -5,9 +5,9 @@ import ( "github.com/cosmos/cosmos-sdk/crypto/keys/secp256k1" sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/babylonchain/babylon/crypto/bls12381" - checkpointingtypes "github.com/babylonchain/babylon/x/checkpointing/types" - epochingtypes "github.com/babylonchain/babylon/x/epoching/types" + "github.com/babylonlabs-io/babylon/crypto/bls12381" + checkpointingtypes "github.com/babylonlabs-io/babylon/x/checkpointing/types" + epochingtypes "github.com/babylonlabs-io/babylon/x/epoching/types" ) func GenRandomValSet(n int) epochingtypes.ValidatorSet { diff --git a/testutil/datagen/vote_ext.go b/testutil/datagen/vote_ext.go index 1f0e35f8d..f33917204 100644 --- a/testutil/datagen/vote_ext.go +++ b/testutil/datagen/vote_ext.go @@ -5,7 +5,7 @@ import ( abci "github.com/cometbft/cometbft/abci/types" - checkpointingtypes "github.com/babylonchain/babylon/x/checkpointing/types" + checkpointingtypes "github.com/babylonlabs-io/babylon/x/checkpointing/types" ) func GenRandomVoteExtension( diff --git a/testutil/helper/gen_blocks.go b/testutil/helper/gen_blocks.go index d19b79756..edb3b54d8 100644 --- a/testutil/helper/gen_blocks.go +++ b/testutil/helper/gen_blocks.go @@ -1,19 +1,58 @@ package helper import ( + "bytes" "fmt" "math/rand" + "sort" + "cosmossdk.io/core/comet" "cosmossdk.io/core/header" abci "github.com/cometbft/cometbft/abci/types" "github.com/cometbft/cometbft/crypto/merkle" cmttypes "github.com/cometbft/cometbft/types" + "github.com/cosmos/cosmos-sdk/baseapp" sdk "github.com/cosmos/cosmos-sdk/types" stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" - "github.com/babylonchain/babylon/testutil/datagen" + "github.com/babylonlabs-io/babylon/testutil/datagen" ) +// adapted from https://github.com/cosmos/cosmos-sdk/blob/v0.50.6/baseapp/abci_utils_test.go +func ExtendedCommitToLastCommit(ec abci.ExtendedCommitInfo) (abci.ExtendedCommitInfo, abci.CommitInfo, comet.BlockInfo) { + // sort the extended commit info + // below are copied from https://github.com/cosmos/cosmos-sdk/blob/v0.50.6/baseapp/abci_utils_test.go + // Since v0.50.5 Cosmos SDK enforces certain order for vote extensions + sort.SliceStable(ec.Votes, func(i, j int) bool { + if ec.Votes[i].Validator.Power == ec.Votes[j].Validator.Power { + return bytes.Compare(ec.Votes[i].Validator.Address, ec.Votes[j].Validator.Address) == -1 + } + return ec.Votes[i].Validator.Power > ec.Votes[j].Validator.Power + }) + + // convert the extended commit info to last commit info + lastCommit := abci.CommitInfo{ + Round: ec.Round, + Votes: make([]abci.VoteInfo, len(ec.Votes)), + } + + for i, vote := range ec.Votes { + lastCommit.Votes[i] = abci.VoteInfo{ + Validator: abci.Validator{ + Address: vote.Validator.Address, + Power: vote.Validator.Power, + }, + } + } + + return ec, lastCommit, baseapp.NewBlockInfo( + nil, + nil, + nil, + lastCommit, + ) +} + func (h *Helper) genAndApplyEmptyBlock() error { prevHeight := h.App.LastBlockHeight() newHeight := prevHeight + 1 @@ -30,7 +69,7 @@ func (h *Helper) genAndApplyEmptyBlock() error { NextValidatorsHash: valhash, } - resp, err := h.App.FinalizeBlock(&abci.RequestFinalizeBlock{ + _, err = h.App.FinalizeBlock(&abci.RequestFinalizeBlock{ Height: newHeader.Height, NextValidatorsHash: newHeader.NextValidatorsHash, Hash: newHeader.Hash(), @@ -39,13 +78,6 @@ func (h *Helper) genAndApplyEmptyBlock() error { return err } - newHeader.AppHash = resp.AppHash - h.Ctx = h.Ctx.WithHeaderInfo(header.Info{ - Height: newHeader.Height, - AppHash: resp.AppHash, - Hash: newHeader.Hash(), - }).WithBlockHeader(*newHeader.ToProto()) - _, err = h.App.Commit() if err != nil { return err @@ -76,10 +108,12 @@ func (h *Helper) ApplyEmptyBlockWithVoteExtension(r *rand.Rand) (sdk.Context, er // 1. get previous vote extensions prevEpoch := epoch.EpochNumber blockHash := datagen.GenRandomBlockHash(r) - extendedVotes, err := h.getExtendedVotesFromValSet(prevEpoch, uint64(prevHeight), blockHash, valSetWithKeys) + extendedVotes, err := h.getExtendedVotesFromValSet(prevEpoch, uint64(prevHeight), blockHash, valSetWithKeys, 0) if err != nil { return emptyCtx, err } + extendedCommitInfo := abci.ExtendedCommitInfo{Votes: extendedVotes} + _, lastCommitInfo, cometInfo := ExtendedCommitToLastCommit(extendedCommitInfo) // 2. create new header valSet, err := h.App.StakingKeeper.GetLastValidators(h.Ctx) @@ -98,12 +132,12 @@ func (h *Helper) ApplyEmptyBlockWithVoteExtension(r *rand.Rand) (sdk.Context, er h.Ctx = h.Ctx.WithHeaderInfo(header.Info{ Height: newHeader.Height, Hash: newHeader.Hash(), - }).WithBlockHeader(*newHeader.ToProto()) + }).WithBlockHeader(*newHeader.ToProto()).WithCometInfo(cometInfo) // 3. prepare proposal with previous BLS sigs blockTxs := [][]byte{} ppRes, err := h.App.PrepareProposal(&abci.RequestPrepareProposal{ - LocalLastCommit: abci.ExtendedCommitInfo{Votes: extendedVotes}, + LocalLastCommit: extendedCommitInfo, Height: newHeight, }) if err != nil { @@ -113,13 +147,17 @@ func (h *Helper) ApplyEmptyBlockWithVoteExtension(r *rand.Rand) (sdk.Context, er if len(ppRes.Txs) > 0 { blockTxs = ppRes.Txs } - _, err = h.App.ProcessProposal(&abci.RequestProcessProposal{ - Txs: ppRes.Txs, - Height: newHeight, + processRes, err := h.App.ProcessProposal(&abci.RequestProcessProposal{ + ProposedLastCommit: lastCommitInfo, + Txs: ppRes.Txs, + Height: newHeight, }) if err != nil { return emptyCtx, err } + if processRes.Status == abci.ResponseProcessProposal_REJECT { + return emptyCtx, fmt.Errorf("rejected proposal") + } // 4. finalize block resp, err := h.App.FinalizeBlock(&abci.RequestFinalizeBlock{ @@ -136,8 +174,7 @@ func (h *Helper) ApplyEmptyBlockWithVoteExtension(r *rand.Rand) (sdk.Context, er h.Ctx = h.Ctx.WithHeaderInfo(header.Info{ Height: newHeader.Height, AppHash: resp.AppHash, - Hash: newHeader.Hash(), - }).WithBlockHeader(*newHeader.ToProto()) + }) _, err = h.App.Commit() if err != nil { @@ -161,10 +198,12 @@ func (h *Helper) ApplyEmptyBlockWithValSet(r *rand.Rand, valSetWithKeys *datagen // 1. get previous vote extensions prevEpoch := epoch.EpochNumber blockHash := datagen.GenRandomBlockHash(r) - extendedVotes, err := h.getExtendedVotesFromValSet(prevEpoch, uint64(prevHeight), blockHash, valSetWithKeys) + extendedVotes, err := h.getExtendedVotesFromValSet(prevEpoch, uint64(prevHeight), blockHash, valSetWithKeys, 0) if err != nil { return emptyCtx, err } + extendedCommitInfo := abci.ExtendedCommitInfo{Votes: extendedVotes} + _, lastCommitInfo, cometInfo := ExtendedCommitToLastCommit(extendedCommitInfo) // 2. create new header valSet, err := h.App.StakingKeeper.GetLastValidators(h.Ctx) @@ -183,7 +222,7 @@ func (h *Helper) ApplyEmptyBlockWithValSet(r *rand.Rand, valSetWithKeys *datagen h.Ctx = h.Ctx.WithHeaderInfo(header.Info{ Height: newHeader.Height, Hash: newHeader.Hash(), - }).WithBlockHeader(*newHeader.ToProto()) + }).WithBlockHeader(*newHeader.ToProto()).WithCometInfo(cometInfo) // 3. prepare proposal with previous BLS sigs blockTxs := [][]byte{} @@ -199,8 +238,9 @@ func (h *Helper) ApplyEmptyBlockWithValSet(r *rand.Rand, valSetWithKeys *datagen blockTxs = ppRes.Txs } processRes, err := h.App.ProcessProposal(&abci.RequestProcessProposal{ - Txs: ppRes.Txs, - Height: newHeight, + ProposedLastCommit: lastCommitInfo, + Txs: ppRes.Txs, + Height: newHeight, }) if err != nil { return emptyCtx, err @@ -235,7 +275,7 @@ func (h *Helper) ApplyEmptyBlockWithValSet(r *rand.Rand, valSetWithKeys *datagen return h.Ctx, nil } -func (h *Helper) ApplyEmptyBlockWithInvalidBLSSig(r *rand.Rand) (sdk.Context, error) { +func (h *Helper) ApplyEmptyBlockWithInvalidVoteExtensions(r *rand.Rand) (sdk.Context, error) { emptyCtx := sdk.Context{} if h.App.LastBlockHeight() == 0 { if err := h.genAndApplyEmptyBlock(); err != nil { @@ -254,6 +294,8 @@ func (h *Helper) ApplyEmptyBlockWithInvalidBLSSig(r *rand.Rand) (sdk.Context, er if err != nil { return emptyCtx, err } + extendedCommitInfo := abci.ExtendedCommitInfo{Votes: extendedVotes} + _, lastCommitInfo, cometInfo := ExtendedCommitToLastCommit(extendedCommitInfo) res, err := h.App.VerifyVoteExtension(&abci.RequestVerifyVoteExtension{ Hash: blockHash, @@ -281,12 +323,12 @@ func (h *Helper) ApplyEmptyBlockWithInvalidBLSSig(r *rand.Rand) (sdk.Context, er h.Ctx = h.Ctx.WithHeaderInfo(header.Info{ Height: newHeader.Height, Hash: newHeader.Hash(), - }).WithBlockHeader(*newHeader.ToProto()) + }).WithBlockHeader(*newHeader.ToProto()).WithCometInfo(cometInfo) // 3. prepare proposal with previous BLS sigs blockTxs := [][]byte{} ppRes, err := h.App.PrepareProposal(&abci.RequestPrepareProposal{ - LocalLastCommit: abci.ExtendedCommitInfo{Votes: extendedVotes}, + LocalLastCommit: extendedCommitInfo, Height: newHeight, }) if err != nil { @@ -297,8 +339,9 @@ func (h *Helper) ApplyEmptyBlockWithInvalidBLSSig(r *rand.Rand) (sdk.Context, er blockTxs = ppRes.Txs } processRes, err := h.App.ProcessProposal(&abci.RequestProcessProposal{ - Txs: ppRes.Txs, - Height: newHeight, + ProposedLastCommit: lastCommitInfo, + Txs: ppRes.Txs, + Height: newHeight, }) if err != nil { return emptyCtx, err @@ -333,7 +376,7 @@ func (h *Helper) ApplyEmptyBlockWithInvalidBLSSig(r *rand.Rand) (sdk.Context, er return h.Ctx, nil } -func (h *Helper) ApplyEmptyBlockWithSomeEmptyVoteExtensions(r *rand.Rand) (sdk.Context, error) { +func (h *Helper) ApplyEmptyBlockWithSomeInvalidVoteExtensions(r *rand.Rand) (sdk.Context, error) { emptyCtx := sdk.Context{} if h.App.LastBlockHeight() == 0 { if err := h.genAndApplyEmptyBlock(); err != nil { @@ -348,10 +391,25 @@ func (h *Helper) ApplyEmptyBlockWithSomeEmptyVoteExtensions(r *rand.Rand) (sdk.C // 1. get previous vote extensions prevEpoch := epoch.EpochNumber blockHash := datagen.GenRandomBlockHash(r) - extendedVotes, err := h.getExtendedVotesFromValSet(prevEpoch, uint64(prevHeight), blockHash, valSetWithKeys) + extendedVotes, err := h.getExtendedVotesFromValSet(prevEpoch, uint64(prevHeight), blockHash, valSetWithKeys, 0) if err != nil { return emptyCtx, err } + extendedCommitInfo := abci.ExtendedCommitInfo{Votes: extendedVotes} + _, lastCommitInfo, cometInfo := ExtendedCommitToLastCommit(extendedCommitInfo) + + if epoch.IsVoteExtensionProposal(h.Ctx) { + // makes a super minority of vote extensions to be invalid, while signatures + // over them are still valid + // In this case the proposal has to be still valid + numInvalidVotes := len(extendedVotes)/3 - 1 + extendedVotes, err = h.getExtendedVotesFromValSet(prevEpoch, uint64(prevHeight), blockHash, valSetWithKeys, numInvalidVotes) + if err != nil { + return emptyCtx, err + } + extendedCommitInfo = abci.ExtendedCommitInfo{Votes: extendedVotes} + _, lastCommitInfo, cometInfo = ExtendedCommitToLastCommit(extendedCommitInfo) + } // 2. create new header valSet, err := h.App.StakingKeeper.GetLastValidators(h.Ctx) @@ -367,25 +425,17 @@ func (h *Helper) ApplyEmptyBlockWithSomeEmptyVoteExtensions(r *rand.Rand) (sdk.C Hash: datagen.GenRandomByteArray(r, 32), }, } + h.Ctx = h.Ctx.WithHeaderInfo(header.Info{ Height: newHeader.Height, Hash: newHeader.Hash(), - }).WithBlockHeader(*newHeader.ToProto()) + }).WithBlockHeader(*newHeader.ToProto()).WithCometInfo(cometInfo) // 3. prepare proposal with previous BLS sigs var blockTxs [][]byte - if epoch.IsVoteExtensionProposal(h.Ctx) { - // nullifies a subset of extended votes - numEmptyVoteExts := len(extendedVotes)/3 - 1 - for i := 0; i < numEmptyVoteExts; i++ { - extendedVotes[i] = abci.ExtendedVoteInfo{ - // generate random vote extension including empty one - VoteExtension: datagen.GenRandomByteArray(r, uint64(r.Intn(10))), - } - } - } + ppRes, err := h.App.PrepareProposal(&abci.RequestPrepareProposal{ - LocalLastCommit: abci.ExtendedCommitInfo{Votes: extendedVotes}, + LocalLastCommit: extendedCommitInfo, Height: newHeight, }) if err != nil { @@ -394,8 +444,9 @@ func (h *Helper) ApplyEmptyBlockWithSomeEmptyVoteExtensions(r *rand.Rand) (sdk.C blockTxs = ppRes.Txs processRes, err := h.App.ProcessProposal(&abci.RequestProcessProposal{ - Txs: blockTxs, - Height: newHeight, + ProposedLastCommit: lastCommitInfo, + Txs: blockTxs, + Height: newHeight, }) if err != nil { return emptyCtx, err diff --git a/testutil/helper/helper.go b/testutil/helper/helper.go index be98fa3d5..6ae1de0d9 100644 --- a/testutil/helper/helper.go +++ b/testutil/helper/helper.go @@ -2,19 +2,21 @@ package helper import ( "bytes" + "fmt" + "sort" "testing" "cosmossdk.io/core/header" + appkeepers "github.com/babylonlabs-io/babylon/app/keepers" + "github.com/babylonlabs-io/babylon/crypto/bls12381" + "github.com/babylonlabs-io/babylon/testutil/datagen" + checkpointingtypes "github.com/babylonlabs-io/babylon/x/checkpointing/types" abci "github.com/cometbft/cometbft/abci/types" cmtproto "github.com/cometbft/cometbft/proto/tendermint/types" "github.com/cosmos/cosmos-sdk/baseapp" cosmosed "github.com/cosmos/cosmos-sdk/crypto/keys/ed25519" protoio "github.com/cosmos/gogoproto/io" - "github.com/babylonchain/babylon/crypto/bls12381" - "github.com/babylonchain/babylon/testutil/datagen" - checkpointingtypes "github.com/babylonchain/babylon/x/checkpointing/types" - "cosmossdk.io/math" "github.com/cosmos/gogoproto/proto" "github.com/stretchr/testify/require" @@ -24,11 +26,11 @@ import ( banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" - "github.com/babylonchain/babylon/app" - appparams "github.com/babylonchain/babylon/app/params" - btcstakingtypes "github.com/babylonchain/babylon/x/btcstaking/types" - "github.com/babylonchain/babylon/x/epoching/keeper" - "github.com/babylonchain/babylon/x/epoching/types" + "github.com/babylonlabs-io/babylon/app" + appparams "github.com/babylonlabs-io/babylon/app/params" + btcstakingtypes "github.com/babylonlabs-io/babylon/x/btcstaking/types" + "github.com/babylonlabs-io/babylon/x/epoching/keeper" + "github.com/babylonlabs-io/babylon/x/epoching/types" ) // Helper is a structure which wraps the entire app and exposes functionalities for testing the epoching module @@ -54,7 +56,7 @@ func NewHelper(t *testing.T) *Helper { // NewHelperWithValSet is same as NewHelper, except that it creates a set of validators // the privSigner is the 0th validator in valSet -func NewHelperWithValSet(t *testing.T, valSet *datagen.GenesisValidators, privSigner *app.PrivSigner) *Helper { +func NewHelperWithValSet(t *testing.T, valSet *datagen.GenesisValidators, privSigner *appkeepers.PrivSigner) *Helper { // generate the genesis account signerPubKey := privSigner.WrappedPV.Key.PubKey acc := authtypes.NewBaseAccount(signerPubKey.Address().Bytes(), &cosmosed.PubKey{Key: signerPubKey.Bytes()}, 0, 0) @@ -90,11 +92,68 @@ func NewHelperWithValSet(t *testing.T, valSet *datagen.GenesisValidators, privSi } } +// NewHelperWithValSetNoSigner is same as NewHelperWithValSet, except that the privSigner is not +// included in the validator set +func NewHelperWithValSetNoSigner(t *testing.T, valSet *datagen.GenesisValidators, privSigner *appkeepers.PrivSigner) *Helper { + // generate the genesis account + signerPubKey := privSigner.WrappedPV.Key.PubKey + acc := authtypes.NewBaseAccount(signerPubKey.Address().Bytes(), &cosmosed.PubKey{Key: signerPubKey.Bytes()}, 0, 0) + privSigner.WrappedPV.Key.DelegatorAddress = acc.Address + // set a random validator address instead of the privSigner's + valSet.Keys[0].ValidatorAddress = datagen.GenRandomValidatorAddress().String() + // ensure the genesis account has a sufficient amount of tokens + balance := banktypes.Balance{ + Address: acc.GetAddress().String(), + Coins: sdk.NewCoins(sdk.NewCoin(appparams.DefaultBondDenom, sdk.DefaultPowerReduction.MulRaw(10000000))), + } + GenAccs := []authtypes.GenesisAccount{acc} + + // setup the app and ctx + app := app.SetupWithGenesisValSet(t, valSet.GetGenesisKeys(), privSigner, GenAccs, balance) + ctx := app.BaseApp.NewContext(false).WithBlockHeight(1).WithHeaderInfo(header.Info{Height: 1}) // NOTE: height is 1 + + // get necessary subsets of the app/keeper + epochingKeeper := app.EpochingKeeper + querier := keeper.Querier{Keeper: epochingKeeper} + queryHelper := baseapp.NewQueryServerTestHelper(ctx, app.InterfaceRegistry()) + types.RegisterQueryServer(queryHelper, querier) + queryClient := types.NewQueryClient(queryHelper) + msgSrvr := keeper.NewMsgServerImpl(epochingKeeper) + + return &Helper{ + t, + ctx, + app, + msgSrvr, + queryClient, + GenAccs, + valSet, + } +} + func (h *Helper) NoError(err error) { require.NoError(h.t, err) } -func (h *Helper) getExtendedVotesFromValSet(epochNum, height uint64, blockHash checkpointingtypes.BlockHash, valSet *datagen.GenesisValidators) ([]abci.ExtendedVoteInfo, error) { +func (h *Helper) Error(err error) { + require.Error(h.t, err) +} + +func (h *Helper) EqualError(err, expected error) { + require.EqualError(h.t, err, expected.Error()) +} + +func (h *Helper) getExtendedVotesFromValSet( + epochNum uint64, + height uint64, + blockHash checkpointingtypes.BlockHash, + valSet *datagen.GenesisValidators, + numInvalidVotes int, +) ([]abci.ExtendedVoteInfo, error) { + if len(valSet.Keys) < numInvalidVotes { + return nil, fmt.Errorf("number of invalid votes is more than the validator set size") + } + valPrivKey := valSet.GetValPrivKeys() blsPrivKeys := valSet.GetBLSPrivKeys() genesisKeys := valSet.GetGenesisKeys() @@ -122,6 +181,10 @@ func (h *Helper) getExtendedVotesFromValSet(epochNum, height uint64, blockHash c Round: int64(0), ChainId: h.App.ChainID(), } + if i < numInvalidVotes { + cve.Extension = []byte("doesn't matter") + } + var cveBuffer bytes.Buffer err = protoio.NewDelimitedWriter(&cveBuffer).WriteMsg(&cve) if err != nil { @@ -153,6 +216,15 @@ func (h *Helper) getExtendedVotesFromValSet(epochNum, height uint64, blockHash c extendedVotes = append(extendedVotes, veInfo) } + // below are copied from https://github.com/cosmos/cosmos-sdk/blob/v0.50.6/baseapp/abci_utils_test.go + // Since v0.50.5 Cosmos SDK enforces certain order for vote extensions + sort.SliceStable(extendedVotes, func(i, j int) bool { + if extendedVotes[i].Validator.Power == extendedVotes[j].Validator.Power { + return bytes.Compare(extendedVotes[i].Validator.Address, extendedVotes[j].Validator.Address) == -1 + } + return extendedVotes[i].Validator.Power > extendedVotes[j].Validator.Power + }) + return extendedVotes, nil } diff --git a/testutil/helper/store.go b/testutil/helper/store.go new file mode 100644 index 000000000..a304932f7 --- /dev/null +++ b/testutil/helper/store.go @@ -0,0 +1,120 @@ +package helper + +import ( + "bytes" + "fmt" + "sync" + + corestore "cosmossdk.io/core/store" + dbm "github.com/cosmos/cosmos-db" + "github.com/cosmos/cosmos-sdk/types/kv" +) + +// DiffKVStores compares two KVstores and returns all the key/value pairs +// that differ from one another. It also skips value comparison for a set of provided prefixes. +func DiffKVStores(a, b corestore.KVStore, prefixesToSkip [][]byte) (diffA, diffB []kv.Pair) { + iterA, err := a.Iterator(nil, nil) + if err != nil { + panic(err) + } + defer iterA.Close() + + iterB, err := b.Iterator(nil, nil) + if err != nil { + panic(err) + } + defer iterB.Close() + + var wg sync.WaitGroup + + wg.Add(1) + kvAs := make([]kv.Pair, 0) + go func() { + defer wg.Done() + kvAs = getKVPairs(iterA, prefixesToSkip) + }() + + wg.Add(1) + kvBs := make([]kv.Pair, 0) + go func() { + defer wg.Done() + kvBs = getKVPairs(iterB, prefixesToSkip) + }() + + wg.Wait() + + if len(kvAs) != len(kvBs) { + fmt.Printf("KV stores are different: %d key/value pairs in store A and %d key/value pairs in store B\n", len(kvAs), len(kvBs)) + } + + return getDiffFromKVPair(kvAs, kvBs) +} + +// getDiffFromKVPair compares two KVstores and returns all the key/value pairs +func getDiffFromKVPair(kvAs, kvBs []kv.Pair) (diffA, diffB []kv.Pair) { + // we assume that kvBs is equal or larger than kvAs + // if not, we swap the two + if len(kvAs) > len(kvBs) { + kvAs, kvBs = kvBs, kvAs + // we need to swap the diffA and diffB as well + defer func() { + diffA, diffB = diffB, diffA + }() + } + + // in case kvAs is empty we can return early + // since there is nothing to compare + // if kvAs == kvBs, then diffA and diffB will be empty + if len(kvAs) == 0 { + return []kv.Pair{}, kvBs + } + + index := make(map[string][]byte, len(kvBs)) + for _, kv := range kvBs { + index[string(kv.Key)] = kv.Value + } + + for _, kvA := range kvAs { + if kvBValue, ok := index[string(kvA.Key)]; !ok { + diffA = append(diffA, kvA) + diffB = append(diffB, kv.Pair{Key: kvA.Key}) // the key is missing from kvB so we append a pair with an empty value + } else if !bytes.Equal(kvA.Value, kvBValue) { + diffA = append(diffA, kvA) + diffB = append(diffB, kv.Pair{Key: kvA.Key, Value: kvBValue}) + } else { + // values are equal, so we remove the key from the index + delete(index, string(kvA.Key)) + } + } + + // add the remaining keys from kvBs + for key, value := range index { + diffA = append(diffA, kv.Pair{Key: []byte(key)}) // the key is missing from kvA so we append a pair with an empty value + diffB = append(diffB, kv.Pair{Key: []byte(key), Value: value}) + } + + return diffA, diffB +} + +func getKVPairs(iter dbm.Iterator, prefixesToSkip [][]byte) (kvs []kv.Pair) { + for iter.Valid() { + key, value := iter.Key(), iter.Value() + + // do not add the KV pair if the key is prefixed to be skipped. + skip := false + for _, prefix := range prefixesToSkip { + if bytes.HasPrefix(key, prefix) { + skip = true + break + } + } + + if !skip { + kvs = append(kvs, kv.Pair{Key: key, Value: value}) + } + + iter.Next() + } + + return kvs +} diff --git a/testutil/keeper/btccheckpoint.go b/testutil/keeper/btccheckpoint.go index 528c059f5..9049041af 100644 --- a/testutil/keeper/btccheckpoint.go +++ b/testutil/keeper/btccheckpoint.go @@ -19,8 +19,8 @@ import ( govtypes "github.com/cosmos/cosmos-sdk/x/gov/types" "github.com/stretchr/testify/require" - "github.com/babylonchain/babylon/x/btccheckpoint/keeper" - btcctypes "github.com/babylonchain/babylon/x/btccheckpoint/types" + "github.com/babylonlabs-io/babylon/x/btccheckpoint/keeper" + btcctypes "github.com/babylonlabs-io/babylon/x/btccheckpoint/types" ) func NewBTCCheckpointKeeper( diff --git a/testutil/keeper/btclightclient.go b/testutil/keeper/btclightclient.go index d4e371894..ebacf965e 100644 --- a/testutil/keeper/btclightclient.go +++ b/testutil/keeper/btclightclient.go @@ -4,10 +4,12 @@ import ( "testing" "cosmossdk.io/core/header" + corestore "cosmossdk.io/core/store" "cosmossdk.io/log" "cosmossdk.io/store" storemetrics "cosmossdk.io/store/metrics" storetypes "cosmossdk.io/store/types" + "github.com/btcsuite/btcd/wire" cmtproto "github.com/cometbft/cometbft/proto/tendermint/types" dbm "github.com/cosmos/cosmos-db" "github.com/cosmos/cosmos-sdk/codec" @@ -18,18 +20,28 @@ import ( govtypes "github.com/cosmos/cosmos-sdk/x/gov/types" "github.com/stretchr/testify/require" - bapp "github.com/babylonchain/babylon/app" - bbn "github.com/babylonchain/babylon/types" - "github.com/babylonchain/babylon/x/btclightclient/keeper" - "github.com/babylonchain/babylon/x/btclightclient/types" + bapp "github.com/babylonlabs-io/babylon/app" + bbn "github.com/babylonlabs-io/babylon/types" + btclightclientk "github.com/babylonlabs-io/babylon/x/btclightclient/keeper" + btclightclientt "github.com/babylonlabs-io/babylon/x/btclightclient/types" ) -func BTCLightClientKeeper(t testing.TB) (*keeper.Keeper, sdk.Context) { - return BTCLightClientKeeperWithCustomParams(t, types.DefaultParams()) +func BTCLightClientKeeper(t testing.TB) (*btclightclientk.Keeper, sdk.Context) { + k, ctx, _ := BTCLightClientKeeperWithCustomParams(t, btclightclientt.DefaultParams()) + return k, ctx } -func BTCLightClientKeeperWithCustomParams(t testing.TB, p types.Params) (*keeper.Keeper, sdk.Context) { - storeKey := storetypes.NewKVStoreKey(types.StoreKey) +// NewBTCHeaderBytesList takes a list of block headers and parses it to BTCHeaderBytes. +func NewBTCHeaderBytesList(chain []*wire.BlockHeader) []bbn.BTCHeaderBytes { + chainBytes := make([]bbn.BTCHeaderBytes, len(chain)) + for i, header := range chain { + chainBytes[i] = bbn.NewBTCHeaderBytesFromBlockHeader(header) + } + return chainBytes +} + +func BTCLightClientKeeperWithCustomParams(t testing.TB, p btclightclientt.Params) (*btclightclientk.Keeper, sdk.Context, corestore.KVStoreService) { + storeKey := storetypes.NewKVStoreKey(btclightclientt.StoreKey) db := dbm.NewMemDB() stateStore := store.NewCommitMultiStore(db, log.NewTestLogger(t), storemetrics.NewNoOpMetrics()) @@ -39,11 +51,12 @@ func BTCLightClientKeeperWithCustomParams(t testing.TB, p types.Params) (*keeper registry := codectypes.NewInterfaceRegistry() cdc := codec.NewProtoCodec(registry) - testCfg := bbn.ParseBtcOptionsFromConfig(bapp.EmptyAppOptions{}) + testCfg := bbn.ParseBtcOptionsFromConfig(bapp.TmpAppOptions()) - k := keeper.NewKeeper( + stServ := runtime.NewKVStoreService(storeKey) + k := btclightclientk.NewKeeper( cdc, - runtime.NewKVStoreService(storeKey), + stServ, testCfg, authtypes.NewModuleAddress(govtypes.ModuleName).String(), ) @@ -55,5 +68,5 @@ func BTCLightClientKeeperWithCustomParams(t testing.TB, p types.Params) (*keeper panic(err) } - return &k, ctx + return &k, ctx, stServ } diff --git a/testutil/keeper/btcstaking.go b/testutil/keeper/btcstaking.go index 58f2af369..fd00fbf7f 100644 --- a/testutil/keeper/btcstaking.go +++ b/testutil/keeper/btcstaking.go @@ -19,14 +19,15 @@ import ( govtypes "github.com/cosmos/cosmos-sdk/x/gov/types" "github.com/stretchr/testify/require" - "github.com/babylonchain/babylon/x/btcstaking/keeper" - "github.com/babylonchain/babylon/x/btcstaking/types" + "github.com/babylonlabs-io/babylon/x/btcstaking/keeper" + "github.com/babylonlabs-io/babylon/x/btcstaking/types" ) func BTCStakingKeeper( t testing.TB, btclcKeeper types.BTCLightClientKeeper, btccKeeper types.BtcCheckpointKeeper, + ckptKeeper types.CheckpointingKeeper, ) (*keeper.Keeper, sdk.Context) { storeKey := storetypes.NewKVStoreKey(types.StoreKey) @@ -43,6 +44,7 @@ func BTCStakingKeeper( runtime.NewKVStoreService(storeKey), btclcKeeper, btccKeeper, + ckptKeeper, &chaincfg.SimNetParams, authtypes.NewModuleAddress(govtypes.ModuleName).String(), ) diff --git a/testutil/keeper/checkpointing.go b/testutil/keeper/checkpointing.go index 9014c328d..f9ec59271 100644 --- a/testutil/keeper/checkpointing.go +++ b/testutil/keeper/checkpointing.go @@ -16,8 +16,8 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" "github.com/stretchr/testify/require" - "github.com/babylonchain/babylon/x/checkpointing/keeper" - "github.com/babylonchain/babylon/x/checkpointing/types" + "github.com/babylonlabs-io/babylon/x/checkpointing/keeper" + "github.com/babylonlabs-io/babylon/x/checkpointing/types" ) func CheckpointingKeeper(t testing.TB, ek types.EpochingKeeper, signer keeper.BlsSigner) (*keeper.Keeper, sdk.Context, *codec.ProtoCodec) { diff --git a/testutil/keeper/epoching.go b/testutil/keeper/epoching.go index 902a11593..716761886 100644 --- a/testutil/keeper/epoching.go +++ b/testutil/keeper/epoching.go @@ -18,8 +18,8 @@ import ( govtypes "github.com/cosmos/cosmos-sdk/x/gov/types" "github.com/stretchr/testify/require" - "github.com/babylonchain/babylon/x/epoching/keeper" - "github.com/babylonchain/babylon/x/epoching/types" + "github.com/babylonlabs-io/babylon/x/epoching/keeper" + "github.com/babylonlabs-io/babylon/x/epoching/types" ) func EpochingKeeper(t testing.TB) (*keeper.Keeper, sdk.Context) { diff --git a/testutil/keeper/finality.go b/testutil/keeper/finality.go index 83b6ce264..fc15a866e 100644 --- a/testutil/keeper/finality.go +++ b/testutil/keeper/finality.go @@ -18,8 +18,8 @@ import ( govtypes "github.com/cosmos/cosmos-sdk/x/gov/types" "github.com/stretchr/testify/require" - "github.com/babylonchain/babylon/x/finality/keeper" - "github.com/babylonchain/babylon/x/finality/types" + "github.com/babylonlabs-io/babylon/x/finality/keeper" + "github.com/babylonlabs-io/babylon/x/finality/types" ) func FinalityKeeper(t testing.TB, bsKeeper types.BTCStakingKeeper, iKeeper types.IncentiveKeeper) (*keeper.Keeper, sdk.Context) { diff --git a/testutil/keeper/incentive.go b/testutil/keeper/incentive.go index f5a23be90..2a6d2017b 100644 --- a/testutil/keeper/incentive.go +++ b/testutil/keeper/incentive.go @@ -18,8 +18,8 @@ import ( govtypes "github.com/cosmos/cosmos-sdk/x/gov/types" "github.com/stretchr/testify/require" - "github.com/babylonchain/babylon/x/incentive/keeper" - "github.com/babylonchain/babylon/x/incentive/types" + "github.com/babylonlabs-io/babylon/x/incentive/keeper" + "github.com/babylonlabs-io/babylon/x/incentive/types" ) func IncentiveKeeper(t testing.TB, bankKeeper types.BankKeeper, accountKeeper types.AccountKeeper, epochingKeeper types.EpochingKeeper) (*keeper.Keeper, sdk.Context) { diff --git a/testutil/keeper/zoneconcierge.go b/testutil/keeper/zoneconcierge.go index 1c5478db4..30ed2679e 100644 --- a/testutil/keeper/zoneconcierge.go +++ b/testutil/keeper/zoneconcierge.go @@ -23,8 +23,8 @@ import ( ibcexported "github.com/cosmos/ibc-go/v8/modules/core/exported" "github.com/stretchr/testify/require" - "github.com/babylonchain/babylon/x/zoneconcierge/keeper" - "github.com/babylonchain/babylon/x/zoneconcierge/types" + "github.com/babylonlabs-io/babylon/x/zoneconcierge/keeper" + "github.com/babylonlabs-io/babylon/x/zoneconcierge/types" ) // zoneconciergeChannelKeeper is a stub of ChannelKeeper diff --git a/testutil/mocks/bls_signer.go b/testutil/mocks/bls_signer.go index 094e5b89c..c59a2fcd7 100644 --- a/testutil/mocks/bls_signer.go +++ b/testutil/mocks/bls_signer.go @@ -7,7 +7,7 @@ package mocks import ( reflect "reflect" - bls12381 "github.com/babylonchain/babylon/crypto/bls12381" + bls12381 "github.com/babylonlabs-io/babylon/crypto/bls12381" crypto "github.com/cometbft/cometbft/crypto" types "github.com/cosmos/cosmos-sdk/types" gomock "github.com/golang/mock/gomock" diff --git a/testutil/mocks/checkpointing_expected_keepers.go b/testutil/mocks/checkpointing_expected_keepers.go index 409a1071b..c4975364a 100644 --- a/testutil/mocks/checkpointing_expected_keepers.go +++ b/testutil/mocks/checkpointing_expected_keepers.go @@ -8,8 +8,8 @@ import ( context "context" reflect "reflect" - types "github.com/babylonchain/babylon/x/checkpointing/types" - types0 "github.com/babylonchain/babylon/x/epoching/types" + types "github.com/babylonlabs-io/babylon/x/checkpointing/types" + types0 "github.com/babylonlabs-io/babylon/x/epoching/types" crypto "github.com/cometbft/cometbft/proto/tendermint/crypto" types1 "github.com/cosmos/cosmos-sdk/types" types2 "github.com/cosmos/cosmos-sdk/x/staking/types" @@ -65,21 +65,6 @@ func (mr *MockEpochingKeeperMockRecorder) EnqueueMsg(ctx, msg interface{}) *gomo return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "EnqueueMsg", reflect.TypeOf((*MockEpochingKeeper)(nil).EnqueueMsg), ctx, msg) } -// GetAppHash mocks base method. -func (m *MockEpochingKeeper) GetAppHash(ctx context.Context, height uint64) ([]byte, error) { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "GetAppHash", ctx, height) - ret0, _ := ret[0].([]byte) - ret1, _ := ret[1].(error) - return ret0, ret1 -} - -// GetAppHash indicates an expected call of GetAppHash. -func (mr *MockEpochingKeeperMockRecorder) GetAppHash(ctx, height interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetAppHash", reflect.TypeOf((*MockEpochingKeeper)(nil).GetAppHash), ctx, height) -} - // GetEpoch mocks base method. func (m *MockEpochingKeeper) GetEpoch(ctx context.Context) *types0.Epoch { m.ctrl.T.Helper() @@ -229,3 +214,17 @@ func (mr *MockCheckpointingHooksMockRecorder) AfterRawCheckpointForgotten(ctx, c mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "AfterRawCheckpointForgotten", reflect.TypeOf((*MockCheckpointingHooks)(nil).AfterRawCheckpointForgotten), ctx, ckpt) } + +// AfterRawCheckpointSealed mocks base method. +func (m *MockCheckpointingHooks) AfterRawCheckpointSealed(ctx context.Context, epoch uint64) error { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "AfterRawCheckpointSealed", ctx, epoch) + ret0, _ := ret[0].(error) + return ret0 +} + +// AfterRawCheckpointSealed indicates an expected call of AfterRawCheckpointSealed. +func (mr *MockCheckpointingHooksMockRecorder) AfterRawCheckpointSealed(ctx, epoch interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "AfterRawCheckpointSealed", reflect.TypeOf((*MockCheckpointingHooks)(nil).AfterRawCheckpointSealed), ctx, epoch) +} diff --git a/testutil/mocks/proposal_keeper.go b/testutil/mocks/proposal_keeper.go new file mode 100644 index 000000000..0afdfeab4 --- /dev/null +++ b/testutil/mocks/proposal_keeper.go @@ -0,0 +1,140 @@ +// Code generated by MockGen. DO NOT EDIT. +// Source: x/checkpointing/proposal_expected_keeper.go + +// Package mocks is a generated GoMock package. +package mocks + +import ( + context "context" + reflect "reflect" + + bls12381 "github.com/babylonlabs-io/babylon/crypto/bls12381" + types "github.com/babylonlabs-io/babylon/x/checkpointing/types" + types0 "github.com/babylonlabs-io/babylon/x/epoching/types" + crypto "github.com/cometbft/cometbft/proto/tendermint/crypto" + types1 "github.com/cosmos/cosmos-sdk/types" + gomock "github.com/golang/mock/gomock" +) + +// MockCheckpointingKeeper is a mock of CheckpointingKeeper interface. +type MockCheckpointingKeeper struct { + ctrl *gomock.Controller + recorder *MockCheckpointingKeeperMockRecorder +} + +// MockCheckpointingKeeperMockRecorder is the mock recorder for MockCheckpointingKeeper. +type MockCheckpointingKeeperMockRecorder struct { + mock *MockCheckpointingKeeper +} + +// NewMockCheckpointingKeeper creates a new mock instance. +func NewMockCheckpointingKeeper(ctrl *gomock.Controller) *MockCheckpointingKeeper { + mock := &MockCheckpointingKeeper{ctrl: ctrl} + mock.recorder = &MockCheckpointingKeeperMockRecorder{mock} + return mock +} + +// EXPECT returns an object that allows the caller to indicate expected use. +func (m *MockCheckpointingKeeper) EXPECT() *MockCheckpointingKeeperMockRecorder { + return m.recorder +} + +// GetBlsPubKey mocks base method. +func (m *MockCheckpointingKeeper) GetBlsPubKey(ctx context.Context, address types1.ValAddress) (bls12381.PublicKey, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "GetBlsPubKey", ctx, address) + ret0, _ := ret[0].(bls12381.PublicKey) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// GetBlsPubKey indicates an expected call of GetBlsPubKey. +func (mr *MockCheckpointingKeeperMockRecorder) GetBlsPubKey(ctx, address interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetBlsPubKey", reflect.TypeOf((*MockCheckpointingKeeper)(nil).GetBlsPubKey), ctx, address) +} + +// GetEpoch mocks base method. +func (m *MockCheckpointingKeeper) GetEpoch(ctx context.Context) *types0.Epoch { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "GetEpoch", ctx) + ret0, _ := ret[0].(*types0.Epoch) + return ret0 +} + +// GetEpoch indicates an expected call of GetEpoch. +func (mr *MockCheckpointingKeeperMockRecorder) GetEpoch(ctx interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetEpoch", reflect.TypeOf((*MockCheckpointingKeeper)(nil).GetEpoch), ctx) +} + +// GetPubKeyByConsAddr mocks base method. +func (m *MockCheckpointingKeeper) GetPubKeyByConsAddr(arg0 context.Context, arg1 types1.ConsAddress) (crypto.PublicKey, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "GetPubKeyByConsAddr", arg0, arg1) + ret0, _ := ret[0].(crypto.PublicKey) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// GetPubKeyByConsAddr indicates an expected call of GetPubKeyByConsAddr. +func (mr *MockCheckpointingKeeperMockRecorder) GetPubKeyByConsAddr(arg0, arg1 interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetPubKeyByConsAddr", reflect.TypeOf((*MockCheckpointingKeeper)(nil).GetPubKeyByConsAddr), arg0, arg1) +} + +// GetTotalVotingPower mocks base method. +func (m *MockCheckpointingKeeper) GetTotalVotingPower(ctx context.Context, epochNumber uint64) int64 { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "GetTotalVotingPower", ctx, epochNumber) + ret0, _ := ret[0].(int64) + return ret0 +} + +// GetTotalVotingPower indicates an expected call of GetTotalVotingPower. +func (mr *MockCheckpointingKeeperMockRecorder) GetTotalVotingPower(ctx, epochNumber interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetTotalVotingPower", reflect.TypeOf((*MockCheckpointingKeeper)(nil).GetTotalVotingPower), ctx, epochNumber) +} + +// GetValidatorSet mocks base method. +func (m *MockCheckpointingKeeper) GetValidatorSet(ctx context.Context, epochNumber uint64) types0.ValidatorSet { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "GetValidatorSet", ctx, epochNumber) + ret0, _ := ret[0].(types0.ValidatorSet) + return ret0 +} + +// GetValidatorSet indicates an expected call of GetValidatorSet. +func (mr *MockCheckpointingKeeperMockRecorder) GetValidatorSet(ctx, epochNumber interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetValidatorSet", reflect.TypeOf((*MockCheckpointingKeeper)(nil).GetValidatorSet), ctx, epochNumber) +} + +// SealCheckpoint mocks base method. +func (m *MockCheckpointingKeeper) SealCheckpoint(ctx context.Context, ckptWithMeta *types.RawCheckpointWithMeta) error { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "SealCheckpoint", ctx, ckptWithMeta) + ret0, _ := ret[0].(error) + return ret0 +} + +// SealCheckpoint indicates an expected call of SealCheckpoint. +func (mr *MockCheckpointingKeeperMockRecorder) SealCheckpoint(ctx, ckptWithMeta interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SealCheckpoint", reflect.TypeOf((*MockCheckpointingKeeper)(nil).SealCheckpoint), ctx, ckptWithMeta) +} + +// VerifyBLSSig mocks base method. +func (m *MockCheckpointingKeeper) VerifyBLSSig(ctx context.Context, sig *types.BlsSig) error { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "VerifyBLSSig", ctx, sig) + ret0, _ := ret[0].(error) + return ret0 +} + +// VerifyBLSSig indicates an expected call of VerifyBLSSig. +func (mr *MockCheckpointingKeeperMockRecorder) VerifyBLSSig(ctx, sig interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "VerifyBLSSig", reflect.TypeOf((*MockCheckpointingKeeper)(nil).VerifyBLSSig), ctx, sig) +} diff --git a/types/btc_config.go b/types/btc_config.go index 078b2a120..21e3cdb17 100644 --- a/types/btc_config.go +++ b/types/btc_config.go @@ -32,7 +32,7 @@ func getParams(opts servertypes.AppOptions) *chaincfg.Params { network, err := cast.ToStringE(valueInterface) if err != nil { - panic("Bitcoin netowrk config should be valid string") + panic("Bitcoin network config should be valid string") } if network == string(BtcMainnet) { diff --git a/types/btc_header_bytes.go b/types/btc_header_bytes.go index af11630c4..a4ff2c741 100644 --- a/types/btc_header_bytes.go +++ b/types/btc_header_bytes.go @@ -5,10 +5,11 @@ import ( "encoding/hex" "encoding/json" "errors" - "github.com/btcsuite/btcd/blockchain" - "github.com/btcsuite/btcd/wire" "math/big" "time" + + "github.com/btcsuite/btcd/blockchain" + "github.com/btcsuite/btcd/wire" ) type BTCHeaderBytes []byte @@ -71,7 +72,7 @@ func (m *BTCHeaderBytes) Unmarshal(data []byte) error { return errors.New("invalid header length") } // Verify that the bytes can be transformed to a *wire.BlockHeader object - _, err := toBlockHeader(data) + _, err := NewBlockHeader(data) if err != nil { return errors.New("bytes do not correspond to a *wire.BlockHeader object") } @@ -116,7 +117,7 @@ func (m *BTCHeaderBytes) Size() int { } func (m BTCHeaderBytes) ToBlockHeader() *wire.BlockHeader { - header, err := toBlockHeader(m) + header, err := NewBlockHeader(m) // There was a parsing error if err != nil { panic("BTCHeaderBytes cannot be converted to a block header object") @@ -172,7 +173,8 @@ func (m *BTCHeaderBytes) Difficulty() *big.Int { return blockchain.CompactToBig(m.Bits()) } -func toBlockHeader(data []byte) (*wire.BlockHeader, error) { +// NewBlockHeader creates a block header from bytes. +func NewBlockHeader(data []byte) (*wire.BlockHeader, error) { // Create an empty header header := &wire.BlockHeader{} diff --git a/types/btc_header_bytes_test.go b/types/btc_header_bytes_test.go index df0b00dcd..7e2eb638e 100644 --- a/types/btc_header_bytes_test.go +++ b/types/btc_header_bytes_test.go @@ -6,8 +6,8 @@ import ( "math/rand" "testing" - "github.com/babylonchain/babylon/testutil/datagen" - "github.com/babylonchain/babylon/types" + "github.com/babylonlabs-io/babylon/testutil/datagen" + "github.com/babylonlabs-io/babylon/types" ) func FuzzBTCHeaderBytesBytesOps(f *testing.F) { diff --git a/types/btc_header_hash_bytes_test.go b/types/btc_header_hash_bytes_test.go index 83305e969..ba7367821 100644 --- a/types/btc_header_hash_bytes_test.go +++ b/types/btc_header_hash_bytes_test.go @@ -6,8 +6,8 @@ import ( "math/rand" "testing" - "github.com/babylonchain/babylon/testutil/datagen" - "github.com/babylonchain/babylon/types" + "github.com/babylonlabs-io/babylon/testutil/datagen" + "github.com/babylonlabs-io/babylon/types" "github.com/btcsuite/btcd/chaincfg/chainhash" ) diff --git a/types/btc_schnorr_eots_test.go b/types/btc_schnorr_eots_test.go index d6fe38575..27e6397f9 100644 --- a/types/btc_schnorr_eots_test.go +++ b/types/btc_schnorr_eots_test.go @@ -4,8 +4,8 @@ import ( "math/rand" "testing" - "github.com/babylonchain/babylon/testutil/datagen" - "github.com/babylonchain/babylon/types" + "github.com/babylonlabs-io/babylon/testutil/datagen" + "github.com/babylonlabs-io/babylon/types" "github.com/btcsuite/btcd/btcec/v2" "github.com/stretchr/testify/require" ) diff --git a/types/btc_schnorr_pk.go b/types/btc_schnorr_pk.go index f297747dd..dfcf1cb19 100644 --- a/types/btc_schnorr_pk.go +++ b/types/btc_schnorr_pk.go @@ -113,19 +113,19 @@ func (pk *BIP340PubKey) Equals(pk2 *BIP340PubKey) bool { } func NewBTCPKsFromBIP340PKs(pks []BIP340PubKey) ([]*btcec.PublicKey, error) { - btcPks := make([]*btcec.PublicKey, 0, len(pks)) - for _, pk := range pks { + btcPks := make([]*btcec.PublicKey, len(pks)) + for i, pk := range pks { btcPK, err := pk.ToBTCPK() if err != nil { return nil, err } - btcPks = append(btcPks, btcPK) + btcPks[i] = btcPK } return btcPks, nil } func NewBIP340PKsFromBTCPKs(btcPKs []*btcec.PublicKey) []BIP340PubKey { - pks := make([]BIP340PubKey, 0, len(btcPKs)) + pks := []BIP340PubKey{} for _, btcPK := range btcPKs { pks = append(pks, *NewBIP340PubKeyFromBTCPK(btcPK)) } diff --git a/types/btc_schnorr_pk_test.go b/types/btc_schnorr_pk_test.go index 6daf60629..3efbb125e 100644 --- a/types/btc_schnorr_pk_test.go +++ b/types/btc_schnorr_pk_test.go @@ -4,8 +4,8 @@ import ( "math/rand" "testing" - "github.com/babylonchain/babylon/testutil/datagen" - "github.com/babylonchain/babylon/types" + "github.com/babylonlabs-io/babylon/testutil/datagen" + "github.com/babylonlabs-io/babylon/types" "github.com/stretchr/testify/require" ) diff --git a/types/btc_schnorr_pub_rand.go b/types/btc_schnorr_pub_rand.go index be92231d2..6cbe4b8d3 100644 --- a/types/btc_schnorr_pub_rand.go +++ b/types/btc_schnorr_pub_rand.go @@ -4,7 +4,9 @@ import ( "encoding/hex" "fmt" + "github.com/babylonlabs-io/babylon/crypto/eots" "github.com/btcsuite/btcd/btcec/v2" + "github.com/decred/dcrd/dcrec/secp256k1/v4" ) type SchnorrPubRand []byte @@ -31,6 +33,13 @@ func NewSchnorrPubRandFromFieldVal(r *btcec.FieldVal) *SchnorrPubRand { return &pr } +func NewPubRandFromPrivRand(sr *eots.PrivateRand) *SchnorrPubRand { + sk := secp256k1.NewPrivateKey(sr) + var j secp256k1.JacobianPoint + sk.PubKey().AsJacobian(&j) + return NewSchnorrPubRandFromFieldVal(&j.X) +} + func (pr SchnorrPubRand) ToFieldVal() *btcec.FieldVal { var r btcec.FieldVal r.SetByteSlice(pr) @@ -45,6 +54,10 @@ func (pr SchnorrPubRand) Marshal() ([]byte, error) { return pr, nil } +func (pr SchnorrPubRand) MarshalHex() string { + return hex.EncodeToString(pr) +} + func (pr SchnorrPubRand) MustMarshal() []byte { prBytes, err := pr.Marshal() if err != nil { diff --git a/types/btc_schnorr_pub_rand_test.go b/types/btc_schnorr_pub_rand_test.go index 06e22387e..a1fc3966c 100644 --- a/types/btc_schnorr_pub_rand_test.go +++ b/types/btc_schnorr_pub_rand_test.go @@ -4,8 +4,8 @@ import ( "math/rand" "testing" - "github.com/babylonchain/babylon/testutil/datagen" - "github.com/babylonchain/babylon/types" + "github.com/babylonlabs-io/babylon/testutil/datagen" + "github.com/babylonlabs-io/babylon/types" "github.com/btcsuite/btcd/btcec/v2" "github.com/stretchr/testify/require" ) diff --git a/types/btc_schnorr_sig_test.go b/types/btc_schnorr_sig_test.go index c8a7f2ad8..68a001937 100644 --- a/types/btc_schnorr_sig_test.go +++ b/types/btc_schnorr_sig_test.go @@ -4,8 +4,8 @@ import ( "math/rand" "testing" - "github.com/babylonchain/babylon/testutil/datagen" - "github.com/babylonchain/babylon/types" + "github.com/babylonlabs-io/babylon/testutil/datagen" + "github.com/babylonlabs-io/babylon/types" "github.com/btcsuite/btcd/btcec/v2/schnorr" "github.com/stretchr/testify/require" ) diff --git a/types/btcutils_test.go b/types/btcutils_test.go index e9890b0a7..7bd100a53 100644 --- a/types/btcutils_test.go +++ b/types/btcutils_test.go @@ -1,7 +1,7 @@ package types_test import ( - "github.com/babylonchain/babylon/types" + "github.com/babylonlabs-io/babylon/types" btcchaincfg "github.com/btcsuite/btcd/chaincfg" "github.com/btcsuite/btcd/wire" "github.com/stretchr/testify/suite" diff --git a/types/retry/retry.go b/types/retry/retry.go index ec0845c15..e193a83a9 100644 --- a/types/retry/retry.go +++ b/types/retry/retry.go @@ -1,13 +1,14 @@ package retry import ( + "crypto/rand" "errors" - "math/rand" + "math/big" "time" - btcctypes "github.com/babylonchain/babylon/x/btccheckpoint/types" - btclctypes "github.com/babylonchain/babylon/x/btclightclient/types" - checkpointingtypes "github.com/babylonchain/babylon/x/checkpointing/types" + 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. @@ -50,6 +51,8 @@ func isExpectedErr(err error) bool { return false } +// Do executes a func with retry +// TODO: check if this is needed, because is not being used. func Do(sleep time.Duration, maxSleepTime time.Duration, retryableFunc func() error) error { if err := retryableFunc(); err != nil { if isUnrecoverableErr(err) { @@ -63,7 +66,10 @@ func Do(sleep time.Duration, maxSleepTime time.Duration, retryableFunc func() er } // Add some randomness to prevent thrashing - jitter := time.Duration(rand.Int63n(int64(sleep))) + jitter, err := randDuration(int64(sleep)) + if err != nil { + return err + } sleep = sleep + jitter/2 if sleep > maxSleepTime { @@ -78,3 +84,11 @@ func Do(sleep time.Duration, maxSleepTime time.Duration, retryableFunc func() er } 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/wasmbinding/bindings/utils.go b/wasmbinding/bindings/utils.go index a4c278cd9..51eb450fa 100644 --- a/wasmbinding/bindings/utils.go +++ b/wasmbinding/bindings/utils.go @@ -1,7 +1,7 @@ package bindings import ( - lcTypes "github.com/babylonchain/babylon/x/btclightclient/types" + lcTypes "github.com/babylonlabs-io/babylon/x/btclightclient/types" ) // AsBtcBlockHeaderInfo translates BTCHeaderInfo to BtcBlockHeaderInfo diff --git a/wasmbinding/test/custom_query_test.go b/wasmbinding/test/custom_query_test.go index c52c84f8b..a21d9c04d 100644 --- a/wasmbinding/test/custom_query_test.go +++ b/wasmbinding/test/custom_query_test.go @@ -10,7 +10,7 @@ import ( "cosmossdk.io/math" "github.com/CosmWasm/wasmd/x/wasm/keeper" - wasmvmtypes "github.com/CosmWasm/wasmvm/types" + wasmvmtypes "github.com/CosmWasm/wasmvm/v2/types" "github.com/cometbft/cometbft/crypto" "github.com/cometbft/cometbft/crypto/ed25519" cmtproto "github.com/cometbft/cometbft/proto/tendermint/types" @@ -19,9 +19,9 @@ import ( minttypes "github.com/cosmos/cosmos-sdk/x/mint/types" "github.com/stretchr/testify/require" - "github.com/babylonchain/babylon/app" - "github.com/babylonchain/babylon/testutil/datagen" - "github.com/babylonchain/babylon/wasmbinding/bindings" + "github.com/babylonlabs-io/babylon/app" + "github.com/babylonlabs-io/babylon/testutil/datagen" + "github.com/babylonlabs-io/babylon/wasmbinding/bindings" ) // TODO consider doing it by enviromental variables as currently it may fail on some @@ -71,14 +71,16 @@ func TestFinalizedEpoch(t *testing.T) { LatestFinalizedEpochInfo: &struct{}{}, } - // There is no finalized epoch yet so we require an error - queryCustomErr(t, ctx, babylonApp, contractAddress, query) - - epoch := babylonApp.EpochingKeeper.IncEpoch(ctx) + // Only epoch 0 is finalised at genesis + resp := bindings.LatestFinalizedEpochInfoResponse{} + queryCustom(t, ctx, babylonApp, contractAddress, query, &resp) + require.Equal(t, resp.EpochInfo.EpochNumber, uint64(0)) + require.Equal(t, resp.EpochInfo.LastBlockHeight, uint64(0)) - _ = babylonApp.ZoneConciergeKeeper.Hooks().AfterRawCheckpointFinalized(ctx, epoch.EpochNumber) + epoch := babylonApp.EpochingKeeper.InitEpoch(ctx) + babylonApp.CheckpointingKeeper.SetCheckpointFinalized(ctx, epoch.EpochNumber) - resp := bindings.LatestFinalizedEpochInfoResponse{} + resp = bindings.LatestFinalizedEpochInfoResponse{} queryCustom(t, ctx, babylonApp, contractAddress, query, &resp) require.Equal(t, resp.EpochInfo.EpochNumber, epoch.EpochNumber) require.Equal(t, resp.EpochInfo.LastBlockHeight, epoch.GetLastBlockHeight()) @@ -327,6 +329,7 @@ func queryCustom( require.NoError(t, err) } +//nolint:unused func queryCustomErr( t *testing.T, ctx sdk.Context, diff --git a/wasmbinding/wasm.go b/wasmbinding/wasm.go index c96ecd884..8896e0ec0 100644 --- a/wasmbinding/wasm.go +++ b/wasmbinding/wasm.go @@ -6,12 +6,12 @@ import ( errorsmod "cosmossdk.io/errors" wasmkeeper "github.com/CosmWasm/wasmd/x/wasm/keeper" - wasmvmtypes "github.com/CosmWasm/wasmvm/types" - bbn "github.com/babylonchain/babylon/types" - "github.com/babylonchain/babylon/wasmbinding/bindings" - lcKeeper "github.com/babylonchain/babylon/x/btclightclient/keeper" - epochingkeeper "github.com/babylonchain/babylon/x/epoching/keeper" - zckeeper "github.com/babylonchain/babylon/x/zoneconcierge/keeper" + wasmvmtypes "github.com/CosmWasm/wasmvm/v2/types" + bbn "github.com/babylonlabs-io/babylon/types" + "github.com/babylonlabs-io/babylon/wasmbinding/bindings" + lcKeeper "github.com/babylonlabs-io/babylon/x/btclightclient/keeper" + epochingkeeper "github.com/babylonlabs-io/babylon/x/epoching/keeper" + zckeeper "github.com/babylonlabs-io/babylon/x/zoneconcierge/keeper" sdk "github.com/cosmos/cosmos-sdk/types" ) @@ -56,12 +56,7 @@ func CustomQuerier(qp *QueryPlugin) func(ctx sdk.Context, request json.RawMessag return bz, nil case contractQuery.LatestFinalizedEpochInfo != nil: - epoch, err := qp.zcKeeper.GetFinalizedEpoch(ctx) - - if err != nil { - return nil, err - } - + epoch := qp.zcKeeper.GetLastFinalizedEpoch(ctx) epochInfo, err := qp.epochingKeeper.GetHistoricalEpoch(ctx, epoch) if err != nil { diff --git a/x/btccheckpoint/abci.go b/x/btccheckpoint/abci.go index 2307557f2..cb5579985 100644 --- a/x/btccheckpoint/abci.go +++ b/x/btccheckpoint/abci.go @@ -2,7 +2,7 @@ package btccheckpoint import ( "context" - "github.com/babylonchain/babylon/x/btccheckpoint/keeper" + "github.com/babylonlabs-io/babylon/x/btccheckpoint/keeper" ) // EndBlocker checks if during block execution btc light client head had been diff --git a/x/btccheckpoint/client/cli/query.go b/x/btccheckpoint/client/cli/query.go index 49a2376cd..43124c93c 100644 --- a/x/btccheckpoint/client/cli/query.go +++ b/x/btccheckpoint/client/cli/query.go @@ -10,7 +10,7 @@ import ( "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/client/flags" - "github.com/babylonchain/babylon/x/btccheckpoint/types" + "github.com/babylonlabs-io/babylon/x/btccheckpoint/types" ) // GetQueryCmd returns the cli query commands for this module @@ -70,24 +70,15 @@ func CmdEpochSubmissions() *cobra.Command { Args: cobra.ExactArgs(1), RunE: func(cmd *cobra.Command, args []string) error { clientCtx := client.GetClientContextFromCmd(cmd) - queryClient := types.NewQueryClient(clientCtx) epochNum, err := strconv.ParseUint(args[0], 10, 64) - - if err != nil { - return err - } - - pageReq, err := client.ReadPageRequest(cmd.Flags()) if err != nil { return err } - params := types.QueryEpochSubmissionsRequest{EpochNum: epochNum, Pagination: pageReq} - - res, err := queryClient.EpochSubmissions(context.Background(), ¶ms) - + req := types.QueryEpochSubmissionsRequest{EpochNum: epochNum} + res, err := queryClient.EpochSubmissions(context.Background(), &req) if err != nil { return err } @@ -97,7 +88,6 @@ func CmdEpochSubmissions() *cobra.Command { } flags.AddQueryFlagsToCmd(cmd) - flags.AddPaginationFlagsToCmd(cmd, "epoch-submissions") return cmd } diff --git a/x/btccheckpoint/client/cli/query_params.go b/x/btccheckpoint/client/cli/query_params.go index 3519dc58a..0dc96de8b 100644 --- a/x/btccheckpoint/client/cli/query_params.go +++ b/x/btccheckpoint/client/cli/query_params.go @@ -3,7 +3,7 @@ package cli import ( "context" - "github.com/babylonchain/babylon/x/btccheckpoint/types" + "github.com/babylonlabs-io/babylon/x/btccheckpoint/types" "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/client/flags" "github.com/spf13/cobra" diff --git a/x/btccheckpoint/client/cli/tx.go b/x/btccheckpoint/client/cli/tx.go index 9d9f5b608..d463dd636 100644 --- a/x/btccheckpoint/client/cli/tx.go +++ b/x/btccheckpoint/client/cli/tx.go @@ -9,7 +9,7 @@ import ( "github.com/cosmos/cosmos-sdk/client/tx" // "github.com/cosmos/cosmos-sdk/client/flags" - "github.com/babylonchain/babylon/x/btccheckpoint/types" + "github.com/babylonlabs-io/babylon/x/btccheckpoint/types" ) // GetTxCmd returns the transaction commands for this module diff --git a/x/btccheckpoint/genesis.go b/x/btccheckpoint/genesis.go index 7b55f84a0..1b66e2251 100644 --- a/x/btccheckpoint/genesis.go +++ b/x/btccheckpoint/genesis.go @@ -2,8 +2,8 @@ package btccheckpoint import ( "context" - "github.com/babylonchain/babylon/x/btccheckpoint/keeper" - "github.com/babylonchain/babylon/x/btccheckpoint/types" + "github.com/babylonlabs-io/babylon/x/btccheckpoint/keeper" + "github.com/babylonlabs-io/babylon/x/btccheckpoint/types" ) // InitGenesis initializes the capability module's state from a provided genesis diff --git a/x/btccheckpoint/genesis_test.go b/x/btccheckpoint/genesis_test.go index 5266094df..62b36760c 100644 --- a/x/btccheckpoint/genesis_test.go +++ b/x/btccheckpoint/genesis_test.go @@ -3,11 +3,11 @@ package btccheckpoint_test import ( "testing" - "github.com/babylonchain/babylon/x/btccheckpoint" + "github.com/babylonlabs-io/babylon/x/btccheckpoint" "github.com/stretchr/testify/require" - simapp "github.com/babylonchain/babylon/app" - "github.com/babylonchain/babylon/x/btccheckpoint/types" + simapp "github.com/babylonlabs-io/babylon/app" + "github.com/babylonlabs-io/babylon/x/btccheckpoint/types" ) func TestExportGenesis(t *testing.T) { diff --git a/x/btccheckpoint/keeper/grpc_query.go b/x/btccheckpoint/keeper/grpc_query.go index d5e155029..2ee4ad676 100644 --- a/x/btccheckpoint/keeper/grpc_query.go +++ b/x/btccheckpoint/keeper/grpc_query.go @@ -5,7 +5,7 @@ import ( "errors" "fmt" - "github.com/babylonchain/babylon/x/btccheckpoint/types" + "github.com/babylonlabs-io/babylon/x/btccheckpoint/types" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/query" "google.golang.org/grpc/codes" @@ -44,21 +44,17 @@ func (k Keeper) BtcCheckpointInfo(c context.Context, req *types.QueryBtcCheckpoi } ctx := sdk.UnwrapSDKContext(c) - checkpointEpoch := req.GetEpochNum() ed := k.GetEpochData(ctx, checkpointEpoch) - ckptInfo, err := k.getCheckpointInfo(ctx, checkpointEpoch, ed) - if err != nil { return nil, fmt.Errorf("failed to get lowest BTC height and hash in keys of epoch %d: %w", req.EpochNum, err) } - resp := &types.QueryBtcCheckpointInfoResponse{ - Info: ckptInfo, - } - return resp, nil + return &types.QueryBtcCheckpointInfoResponse{ + Info: ckptInfo.ToResponse(), + }, nil } func (k Keeper) BtcCheckpointsInfo(ctx context.Context, req *types.QueryBtcCheckpointsInfoRequest) (*types.QueryBtcCheckpointsInfoResponse, error) { @@ -66,105 +62,62 @@ func (k Keeper) BtcCheckpointsInfo(ctx context.Context, req *types.QueryBtcCheck return nil, status.Error(codes.InvalidArgument, "invalid request") } + ckptInfoList := []*types.BTCCheckpointInfoResponse{} epochDataStore := k.epochDataStore(ctx) - - ckptInfoList := []*types.BTCCheckpointInfo{} // iterate over epochDataStore, where key is the epoch number and value is the epoch data pageRes, err := query.Paginate(epochDataStore, req.Pagination, func(key, value []byte) error { - epochNum := sdk.BigEndianToUint64(key) var epochData types.EpochData - k.cdc.MustUnmarshal(value, &epochData) + if err := k.cdc.Unmarshal(value, &epochData); err != nil { + return fmt.Errorf("failed to decode epoch data %+v: %w", value, err) + } + epochNum := sdk.BigEndianToUint64(key) ckptInfo, err := k.getCheckpointInfo(ctx, epochNum, &epochData) - if err != nil { return fmt.Errorf("failed to get lowest BTC height and hash in keys of epoch %d: %w", epochNum, err) } - // append ckpt info - ckptInfoList = append(ckptInfoList, ckptInfo) + // append ckpt info + ckptInfoList = append(ckptInfoList, ckptInfo.ToResponse()) return nil }) if err != nil { return nil, status.Error(codes.Internal, err.Error()) } - resp := &types.QueryBtcCheckpointsInfoResponse{ + return &types.QueryBtcCheckpointsInfoResponse{ InfoList: ckptInfoList, Pagination: pageRes, - } - return resp, nil -} - -func getOffset(pageReq *query.PageRequest) uint64 { - if pageReq == nil { - return 0 - } else { - return pageReq.Offset - } -} - -func buildPageResponse(numOfKeys uint64, pageReq *query.PageRequest) *query.PageResponse { - if pageReq == nil { - return &query.PageResponse{} - } - - if !pageReq.CountTotal { - return &query.PageResponse{} - } - - return &query.PageResponse{Total: numOfKeys} + }, nil } func (k Keeper) EpochSubmissions(c context.Context, req *types.QueryEpochSubmissionsRequest) (*types.QueryEpochSubmissionsResponse, error) { if req == nil { return nil, status.Error(codes.InvalidArgument, "invalid request") } - ctx := sdk.UnwrapSDKContext(c) - checkpointEpoch := req.GetEpochNum() - - _, limit, err := query.ParsePagination(req.Pagination) - - offset := getOffset(req.Pagination) - - if err != nil { - return nil, err - } - - epochData := k.GetEpochData(ctx, checkpointEpoch) - + epoch := req.GetEpochNum() + epochData := k.GetEpochData(ctx, epoch) if epochData == nil || len(epochData.Keys) == 0 { - - return &types.QueryEpochSubmissionsResponse{ - Keys: []*types.SubmissionKey{}, - Pagination: buildPageResponse(0, req.Pagination), - }, nil - } - - numberOfKeys := uint64(len((epochData.Keys))) - - if offset >= numberOfKeys { - // offset larger than number of keys return empty response return &types.QueryEpochSubmissionsResponse{ - Keys: []*types.SubmissionKey{}, - Pagination: buildPageResponse(numberOfKeys, req.Pagination), + Keys: []*types.SubmissionKeyResponse{}, }, nil } - var responseKeys []*types.SubmissionKey - - for i := offset; i < numberOfKeys; i++ { - if len(responseKeys) == limit { - break + submKeysResp := make([]*types.SubmissionKeyResponse, len(epochData.Keys)) + for i, submKey := range epochData.Keys { + skr, err := types.NewSubmissionKeyResponse(*submKey) + if err != nil { + errMsgf := "epoch submission: this error should not happen, check DB corruption and proto files: %v" + k.Logger(ctx).Error(errMsgf, err) + return nil, status.Errorf(codes.Internal, errMsgf, err) } - responseKeys = append(responseKeys, epochData.Keys[i]) + submKeysResp[i] = skr } return &types.QueryEpochSubmissionsResponse{ - Keys: responseKeys, - Pagination: buildPageResponse(numberOfKeys, req.Pagination), + Keys: submKeysResp, }, nil } diff --git a/x/btccheckpoint/keeper/grpc_query_params.go b/x/btccheckpoint/keeper/grpc_query_params.go index 630c5e454..63923bf96 100644 --- a/x/btccheckpoint/keeper/grpc_query_params.go +++ b/x/btccheckpoint/keeper/grpc_query_params.go @@ -3,7 +3,7 @@ package keeper import ( "context" - "github.com/babylonchain/babylon/x/btccheckpoint/types" + "github.com/babylonlabs-io/babylon/x/btccheckpoint/types" sdk "github.com/cosmos/cosmos-sdk/types" "google.golang.org/grpc/codes" "google.golang.org/grpc/status" diff --git a/x/btccheckpoint/keeper/grpc_query_params_test.go b/x/btccheckpoint/keeper/grpc_query_params_test.go index b9db61836..9624ef04a 100644 --- a/x/btccheckpoint/keeper/grpc_query_params_test.go +++ b/x/btccheckpoint/keeper/grpc_query_params_test.go @@ -4,8 +4,8 @@ import ( "math/rand" "testing" - testkeeper "github.com/babylonchain/babylon/testutil/keeper" - "github.com/babylonchain/babylon/x/btccheckpoint/types" + testkeeper "github.com/babylonlabs-io/babylon/testutil/keeper" + "github.com/babylonlabs-io/babylon/x/btccheckpoint/types" "github.com/stretchr/testify/require" ) diff --git a/x/btccheckpoint/keeper/grpc_query_test.go b/x/btccheckpoint/keeper/grpc_query_test.go new file mode 100644 index 000000000..f1b32d76d --- /dev/null +++ b/x/btccheckpoint/keeper/grpc_query_test.go @@ -0,0 +1,71 @@ +package keeper_test + +import ( + "encoding/hex" + "math/rand" + "testing" + "time" + + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/stretchr/testify/require" + + dg "github.com/babylonlabs-io/babylon/testutil/datagen" + "github.com/babylonlabs-io/babylon/x/btccheckpoint/types" +) + +func TestBtcCheckpointInfo(t *testing.T) { + r := rand.New(rand.NewSource(time.Now().Unix())) + epoch := uint64(1) + raw, btcRaw := dg.RandomRawCheckpointDataForEpoch(r, epoch) + + blck1BabylonOpReturnIdx, blck2BabylonOpReturnIdx := uint32(7), uint32(3) + blck1 := dg.CreateBlock(r, 1, 7, blck1BabylonOpReturnIdx, raw.FirstPart) + blck2 := dg.CreateBlock(r, 2, 14, blck2BabylonOpReturnIdx, raw.SecondPart) + + tk := InitTestKeepers(t) + + blockResults := []*dg.BlockCreationResult{blck1, blck2} + proofs := dg.BlockCreationResultToProofs(blockResults) + msg := dg.GenerateMessageWithRandomSubmitter(blockResults) + + tk.BTCLightClient.SetDepth(blck1.HeaderBytes.Hash(), uint64(1)) + tk.BTCLightClient.SetDepth(blck2.HeaderBytes.Hash(), uint64(1)) + + _, err := tk.insertProofMsg(msg) + require.NoErrorf(t, err, "Unexpected message processing error: %v", err) + + // test the GRPC client call. + resp, err := tk.BTCCheckpoint.BtcCheckpointInfo(tk.SdkCtx, &types.QueryBtcCheckpointInfoRequest{EpochNum: epoch}) + require.NoErrorf(t, err, "Unexpected message processing error: %v", err) + + // gather info for verifying with response. + btcInfo := resp.Info + blkHeight, err := tk.BTCLightClient.BlockHeight(tk.Ctx, nil) + require.NoErrorf(t, err, "Unexpected message processing error: %v", err) + + rawSubmission, err := types.ParseSubmission(msg, tk.BTCCheckpoint.GetPowLimit(), tk.BTCCheckpoint.GetExpectedTag(tk.SdkCtx)) + require.NoErrorf(t, err, "Unexpected message processing error: %v", err) + blk1 := rawSubmission.GetFirstBlockHash() + blk2 := rawSubmission.GetSecondBlockHash() + + require.Equal(t, btcInfo.EpochNumber, epoch) + require.Equal(t, btcInfo.BestSubmissionBtcBlockHeight, blkHeight) + require.Equal(t, btcInfo.BestSubmissionBtcBlockHash, blk1.MarshalHex()) + + require.Equal(t, len(btcInfo.BestSubmissionTransactions), 2) + tx0 := btcInfo.BestSubmissionTransactions[0] + require.Equal(t, tx0.Index, blck1BabylonOpReturnIdx) + require.Equal(t, tx0.Hash, blk1.MarshalHex()) + require.Equal(t, tx0.Transaction, blck1.Transactions[blck1BabylonOpReturnIdx]) + require.Equal(t, tx0.Proof, hex.EncodeToString(proofs[0].MerkleNodes)) + + tx1 := btcInfo.BestSubmissionTransactions[1] + require.Equal(t, tx1.Index, blck2BabylonOpReturnIdx) + require.Equal(t, tx1.Hash, blk2.MarshalHex()) + require.Equal(t, tx1.Transaction, blck2.Transactions[blck2BabylonOpReturnIdx]) + require.Equal(t, tx1.Proof, hex.EncodeToString(proofs[1].MerkleNodes)) + + require.Equal(t, len(btcInfo.BestSubmissionVigilanteAddressList), 1) + require.Equal(t, btcInfo.BestSubmissionVigilanteAddressList[0].Reporter, rawSubmission.Reporter.String()) + require.Equal(t, btcInfo.BestSubmissionVigilanteAddressList[0].Submitter, sdk.AccAddress(btcRaw.SubmitterAddress).String()) +} diff --git a/x/btccheckpoint/keeper/hooks.go b/x/btccheckpoint/keeper/hooks.go index 3fd096a46..9dfbef441 100644 --- a/x/btccheckpoint/keeper/hooks.go +++ b/x/btccheckpoint/keeper/hooks.go @@ -2,8 +2,8 @@ package keeper import ( "context" - ltypes "github.com/babylonchain/babylon/x/btclightclient/types" - etypes "github.com/babylonchain/babylon/x/epoching/types" + ltypes "github.com/babylonlabs-io/babylon/x/btclightclient/types" + etypes "github.com/babylonlabs-io/babylon/x/epoching/types" ) // HandledHooks Helper interface to ensure Hooks implements diff --git a/x/btccheckpoint/keeper/incentive.go b/x/btccheckpoint/keeper/incentive.go index 36c17f035..259af1ae4 100644 --- a/x/btccheckpoint/keeper/incentive.go +++ b/x/btccheckpoint/keeper/incentive.go @@ -2,7 +2,7 @@ package keeper import ( "context" - "github.com/babylonchain/babylon/x/btccheckpoint/types" + "github.com/babylonlabs-io/babylon/x/btccheckpoint/types" ) // rewardBTCTimestamping finds the (submitter, reporter) pairs of all submissions at the diff --git a/x/btccheckpoint/keeper/keeper.go b/x/btccheckpoint/keeper/keeper.go index 7f01dad7a..9d345cebd 100644 --- a/x/btccheckpoint/keeper/keeper.go +++ b/x/btccheckpoint/keeper/keeper.go @@ -11,9 +11,9 @@ import ( "cosmossdk.io/log" "cosmossdk.io/store/prefix" - txformat "github.com/babylonchain/babylon/btctxformatter" - bbn "github.com/babylonchain/babylon/types" - "github.com/babylonchain/babylon/x/btccheckpoint/types" + txformat "github.com/babylonlabs-io/babylon/btctxformatter" + bbn "github.com/babylonlabs-io/babylon/types" + "github.com/babylonlabs-io/babylon/x/btccheckpoint/types" "github.com/cosmos/cosmos-sdk/codec" sdk "github.com/cosmos/cosmos-sdk/types" ) diff --git a/x/btccheckpoint/keeper/keeper_test.go b/x/btccheckpoint/keeper/keeper_test.go index 5eed1abd6..5ed112659 100644 --- a/x/btccheckpoint/keeper/keeper_test.go +++ b/x/btccheckpoint/keeper/keeper_test.go @@ -5,8 +5,8 @@ import ( "testing" "time" - "github.com/babylonchain/babylon/testutil/datagen" - "github.com/babylonchain/babylon/x/btccheckpoint/types" + "github.com/babylonlabs-io/babylon/testutil/datagen" + "github.com/babylonlabs-io/babylon/x/btccheckpoint/types" "github.com/stretchr/testify/require" ) diff --git a/x/btccheckpoint/keeper/msg_server.go b/x/btccheckpoint/keeper/msg_server.go index 17480a698..d2cc65310 100644 --- a/x/btccheckpoint/keeper/msg_server.go +++ b/x/btccheckpoint/keeper/msg_server.go @@ -4,7 +4,7 @@ import ( "context" errorsmod "cosmossdk.io/errors" - "github.com/babylonchain/babylon/x/btccheckpoint/types" + "github.com/babylonlabs-io/babylon/x/btccheckpoint/types" sdk "github.com/cosmos/cosmos-sdk/types" govtypes "github.com/cosmos/cosmos-sdk/x/gov/types" ) diff --git a/x/btccheckpoint/keeper/msg_server_test.go b/x/btccheckpoint/keeper/msg_server_test.go index 651eedb7d..c74e939c7 100644 --- a/x/btccheckpoint/keeper/msg_server_test.go +++ b/x/btccheckpoint/keeper/msg_server_test.go @@ -8,11 +8,11 @@ import ( "testing" "time" - dg "github.com/babylonchain/babylon/testutil/datagen" - keepertest "github.com/babylonchain/babylon/testutil/keeper" - bbn "github.com/babylonchain/babylon/types" - bkeeper "github.com/babylonchain/babylon/x/btccheckpoint/keeper" - btcctypes "github.com/babylonchain/babylon/x/btccheckpoint/types" + dg "github.com/babylonlabs-io/babylon/testutil/datagen" + keepertest "github.com/babylonlabs-io/babylon/testutil/keeper" + bbn "github.com/babylonlabs-io/babylon/types" + bkeeper "github.com/babylonlabs-io/babylon/x/btccheckpoint/keeper" + btcctypes "github.com/babylonlabs-io/babylon/x/btccheckpoint/types" "github.com/btcsuite/btcd/chaincfg" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/stretchr/testify/require" diff --git a/x/btccheckpoint/keeper/params.go b/x/btccheckpoint/keeper/params.go index a4333facb..c1fa0d068 100644 --- a/x/btccheckpoint/keeper/params.go +++ b/x/btccheckpoint/keeper/params.go @@ -2,7 +2,7 @@ package keeper import ( "context" - "github.com/babylonchain/babylon/x/btccheckpoint/types" + "github.com/babylonlabs-io/babylon/x/btccheckpoint/types" ) // SetParams sets the x/btccheckpoint module parameters. diff --git a/x/btccheckpoint/keeper/params_test.go b/x/btccheckpoint/keeper/params_test.go index 444e46eb9..08b049012 100644 --- a/x/btccheckpoint/keeper/params_test.go +++ b/x/btccheckpoint/keeper/params_test.go @@ -3,8 +3,8 @@ package keeper_test import ( "testing" - testkeeper "github.com/babylonchain/babylon/testutil/keeper" - "github.com/babylonchain/babylon/x/btccheckpoint/types" + testkeeper "github.com/babylonlabs-io/babylon/testutil/keeper" + "github.com/babylonlabs-io/babylon/x/btccheckpoint/types" "github.com/stretchr/testify/require" ) diff --git a/x/btccheckpoint/keeper/submissions.go b/x/btccheckpoint/keeper/submissions.go index 9bf5d400c..5e3f99b89 100644 --- a/x/btccheckpoint/keeper/submissions.go +++ b/x/btccheckpoint/keeper/submissions.go @@ -7,8 +7,8 @@ import ( "math" "cosmossdk.io/store/prefix" - bbn "github.com/babylonchain/babylon/types" - "github.com/babylonchain/babylon/x/btccheckpoint/types" + bbn "github.com/babylonlabs-io/babylon/types" + "github.com/babylonlabs-io/babylon/x/btccheckpoint/types" ) func (k Keeper) HasSubmission(ctx context.Context, sk types.SubmissionKey) bool { @@ -53,7 +53,7 @@ func (k Keeper) addEpochSubmission( ed := k.GetEpochData(ctx, epochNum) // TODO: SaveEpochData and SaveSubmission should be done in one transaction. - // Not sure cosmos-sdk has facialities to do it. + // Not sure cosmos-sdk has facilities to do it. // Otherwise it is possible to end up with node which updated submission list // but did not save submission itself. @@ -65,8 +65,8 @@ func (k Keeper) addEpochSubmission( } if ed.Status == types.Finalized { - // we already finlized given epoch so we do not need any more submissions - // TODO We should probably compare new submmission with the exisiting submission + // we already finalized given epoch so we do not need any more submissions + // TODO We should probably compare new submission with the existing submission // which finalized the epoch. As it means we finalized epoch with not the best // submission possible return types.ErrEpochAlreadyFinalized @@ -159,8 +159,8 @@ func (k Keeper) GetSubmissionBtcInfo(ctx context.Context, sk types.SubmissionKey // Currently if two submissions of one checkpoint are in the same block, // we pick tx with lower index as the point at which checkpoint happened. // This is in line with the logic that if two submission are in the same block, - // they are esentially happening at the same time, so it does not really matter - // which index pick, and for possibble tie breaks it is better to pick lower one. + // they are essentially happening at the same time, so it does not really matter + // which index pick, and for possible tie breaks it is better to pick lower one. // This means in case when we have: // Checkpoint submission `x` for epoch 5, both tx in same block at height 100, with indexes 1 and 10 // and @@ -190,7 +190,7 @@ func (k Keeper) GetSubmissionBtcInfo(ctx context.Context, sk types.SubmissionKey } func (k Keeper) GetEpochBestSubmissionBtcInfo(ctx context.Context, ed *types.EpochData) *types.SubmissionBtcInfo { - // there are no submissions for this epoch, so transitivly there is no best submission + // there are no submissions for this epoch, so transitively there is no best submission if ed == nil || len(ed.Keys) == 0 { return nil } diff --git a/x/btccheckpoint/module.go b/x/btccheckpoint/module.go index 40db44228..47b73657c 100644 --- a/x/btccheckpoint/module.go +++ b/x/btccheckpoint/module.go @@ -12,9 +12,9 @@ import ( abci "github.com/cometbft/cometbft/abci/types" - "github.com/babylonchain/babylon/x/btccheckpoint/client/cli" - "github.com/babylonchain/babylon/x/btccheckpoint/keeper" - "github.com/babylonchain/babylon/x/btccheckpoint/types" + "github.com/babylonlabs-io/babylon/x/btccheckpoint/client/cli" + "github.com/babylonlabs-io/babylon/x/btccheckpoint/keeper" + "github.com/babylonlabs-io/babylon/x/btccheckpoint/types" "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/codec" cdctypes "github.com/cosmos/cosmos-sdk/codec/types" diff --git a/x/btccheckpoint/types/btccheckpoint.pb.go b/x/btccheckpoint/types/btccheckpoint.pb.go index 23f50d154..4e9ac7678 100644 --- a/x/btccheckpoint/types/btccheckpoint.pb.go +++ b/x/btccheckpoint/types/btccheckpoint.pb.go @@ -5,7 +5,7 @@ package types import ( fmt "fmt" - github_com_babylonchain_babylon_types "github.com/babylonchain/babylon/types" + github_com_babylonlabs_io_babylon_types "github.com/babylonlabs-io/babylon/types" _ "github.com/cosmos/gogoproto/gogoproto" proto "github.com/cosmos/gogoproto/proto" io "io" @@ -90,7 +90,7 @@ type BTCSpvProof struct { MerkleNodes []byte `protobuf:"bytes,3,opt,name=merkle_nodes,json=merkleNodes,proto3" json:"merkle_nodes,omitempty"` // Valid btc header which confirms btc_transaction. // Should have exactly 80 bytes - ConfirmingBtcHeader *github_com_babylonchain_babylon_types.BTCHeaderBytes `protobuf:"bytes,4,opt,name=confirming_btc_header,json=confirmingBtcHeader,proto3,customtype=github.com/babylonchain/babylon/types.BTCHeaderBytes" json:"confirming_btc_header,omitempty"` + ConfirmingBtcHeader *github_com_babylonlabs_io_babylon_types.BTCHeaderBytes `protobuf:"bytes,4,opt,name=confirming_btc_header,json=confirmingBtcHeader,proto3,customtype=github.com/babylonlabs-io/babylon/types.BTCHeaderBytes" json:"confirming_btc_header,omitempty"` } func (m *BTCSpvProof) Reset() { *m = BTCSpvProof{} } @@ -147,11 +147,11 @@ func (m *BTCSpvProof) GetMerkleNodes() []byte { return nil } -// Each provided OP_RETURN transaction can be idendtified by hash of block in +// Each provided OP_RETURN transaction can be identified by hash of block in // which transaction was included and transaction index in the block type TransactionKey struct { - Index uint32 `protobuf:"varint,1,opt,name=index,proto3" json:"index,omitempty"` - Hash *github_com_babylonchain_babylon_types.BTCHeaderHashBytes `protobuf:"bytes,2,opt,name=hash,proto3,customtype=github.com/babylonchain/babylon/types.BTCHeaderHashBytes" json:"hash,omitempty"` + Index uint32 `protobuf:"varint,1,opt,name=index,proto3" json:"index,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"` } func (m *TransactionKey) Reset() { *m = TransactionKey{} } @@ -262,7 +262,7 @@ type TransactionInfo struct { Transaction []byte `protobuf:"bytes,2,opt,name=transaction,proto3" json:"transaction,omitempty"` // 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 - // valideated the proof? + // validated the proof? Proof []byte `protobuf:"bytes,3,opt,name=proof,proto3" json:"proof,omitempty"` } @@ -321,15 +321,15 @@ func (m *TransactionInfo) GetProof() []byte { } // TODO: Determine if we should keep any block number or depth info. -// On one hand it may be usefull to determine if block is stable or not, on +// On one hand it may be useful to determine if block is stable or not, on // other depth/block number info, without context (i.e info about chain) is -// pretty useless and blockshash in enough to retrieve is from lightclient +// pretty useless and blockhash in enough to retrieve is from lightclient type SubmissionData struct { // address of the submitter and reporter VigilanteAddresses *CheckpointAddresses `protobuf:"bytes,1,opt,name=vigilante_addresses,json=vigilanteAddresses,proto3" json:"vigilante_addresses,omitempty"` // txs_info is the two `TransactionInfo`s corresponding to the submission // It is used for - // - recovering address of sender of btc transction to payup the reward. + // - recovering address of sender of btc transaction to payup the reward. // - allowing the ZoneConcierge module to prove the checkpoint is submitted to // BTC TxsInfo []*TransactionInfo `protobuf:"bytes,2,rep,name=txs_info,json=txsInfo,proto3" json:"txs_info,omitempty"` @@ -391,7 +391,7 @@ func (m *SubmissionData) GetEpoch() uint64 { } // Data stored in db and indexed by epoch number -// TODO: Add btc blockheight at epooch end, when adding hadnling of epoching +// TODO: Add btc blockheight at epoch end, when adding handling of epoching // callbacks type EpochData struct { // keys is the list of all received checkpoints during this epoch, sorted by @@ -516,7 +516,7 @@ type BTCCheckpointInfo struct { BestSubmissionBtcBlockHeight uint64 `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_babylonchain_babylon_types.BTCHeaderHashBytes `protobuf:"bytes,3,opt,name=best_submission_btc_block_hash,json=bestSubmissionBtcBlockHash,proto3,customtype=github.com/babylonchain/babylon/types.BTCHeaderHashBytes" json:"best_submission_btc_block_hash,omitempty"` + 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"` // the BTC checkpoint transactions of the best submission BestSubmissionTransactions []*TransactionInfo `protobuf:"bytes,4,rep,name=best_submission_transactions,json=bestSubmissionTransactions,proto3" json:"best_submission_transactions,omitempty"` // list of vigilantes' addresses of the best submission @@ -601,58 +601,58 @@ func init() { } var fileDescriptor_e096cac78d49b0a6 = []byte{ - // 814 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x55, 0xcd, 0x8f, 0x22, 0x45, - 0x14, 0xa7, 0xa0, 0x67, 0x5d, 0x0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f9, 0x1a, - 0xf7, 0x0a, 0xca, 0xf7, 0xbf, 0x68, 0x09, 0xa3, 0xf3, 0xeb, 0xa5, 0x06, 0xde, 0x5c, 0x6a, 0xe0, - 0x8f, 0x4b, 0x0d, 0xfc, 0x78, 0xa5, 0x25, 0xde, 0x5c, 0x69, 0x89, 0xdf, 0xaf, 0xb4, 0xc4, 0xeb, - 0xcf, 0xfe, 0x6d, 0xea, 0xf3, 0xad, 0x0f, 0xa2, 0xdc, 0x02, 0xf7, 0x8e, 0xfc, 0xac, 0x7d, 0xf2, - 0x77, 0x00, 0x00, 0x00, 0xff, 0xff, 0x7b, 0x55, 0x92, 0x5f, 0x36, 0x07, 0x00, 0x00, + // 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,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, 0x77, 0xbc, 0x0d, 0x7d, 0xbd, 0xf6, 0x57, 0x1b, 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, } func (m *BTCSpvProof) Marshal() (dAtA []byte, err error) { @@ -1367,7 +1367,7 @@ func (m *BTCSpvProof) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - var v github_com_babylonchain_babylon_types.BTCHeaderBytes + var v github_com_babylonlabs_io_babylon_types.BTCHeaderBytes m.ConfirmingBtcHeader = &v if err := m.ConfirmingBtcHeader.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err @@ -1471,7 +1471,7 @@ func (m *TransactionKey) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - var v github_com_babylonchain_babylon_types.BTCHeaderHashBytes + var v github_com_babylonlabs_io_babylon_types.BTCHeaderHashBytes m.Hash = &v if err := m.Hash.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err @@ -2192,7 +2192,7 @@ func (m *BTCCheckpointInfo) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - var v github_com_babylonchain_babylon_types.BTCHeaderHashBytes + var v github_com_babylonlabs_io_babylon_types.BTCHeaderHashBytes m.BestSubmissionBtcBlockHash = &v if err := m.BestSubmissionBtcBlockHash.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err diff --git a/x/btccheckpoint/types/btcutils.go b/x/btccheckpoint/types/btcutils.go index 37670301f..b03d476ae 100644 --- a/x/btccheckpoint/types/btcutils.go +++ b/x/btccheckpoint/types/btcutils.go @@ -6,25 +6,13 @@ import ( "fmt" "math/big" - "github.com/babylonchain/babylon/types" + "github.com/babylonlabs-io/babylon/types" "github.com/btcsuite/btcd/blockchain" "github.com/btcsuite/btcd/btcutil" "github.com/btcsuite/btcd/chaincfg/chainhash" "github.com/btcsuite/btcd/txscript" ) -const ( - // 1 byte for OP_RETURN opcode - // 1 byte for OP_DATAXX, or 2 bytes for OP_PUSHDATA1 opcode - // max 80 bytes of application specific data - // This stems from the fact that if data in op_return is less than 75 bytes - // one of OP_DATAXX opcodes is used (https://wiki.bitcoinsv.io/index.php/Pushdata_Opcodes#Opcodes_1-75_.280x01_-_0x4B.29) - // but if data in op_return is between 76 and 80bytes, OP_PUSHDATA1 needs to be used - // in which 1 byte indicates op code itself and 1 byte indicates how many bytes - // are pushed onto stack (https://wiki.bitcoinsv.io/index.php/Pushdata_Opcodes#OP_PUSHDATA1_.2876_or_0x4C.29) - maxOpReturnPkScriptSize = 83 -) - // ParsedProof represent semantically valid: // - Bitcoin Header // - Bitcoin Header hash @@ -204,32 +192,49 @@ func verify(tx *btcutil.Tx, merkleRoot *chainhash.Hash, intermediateNodes []byte return bytes.Equal(current[:], root) } -func ExtractOpReturnData(tx *btcutil.Tx) []byte { +// ExtractStandardOpReturnData extract OP_RETURN data from transaction OP_RETURN +// output. +// If OP_RETURN output is not standard it will be ignored. If there is more than +// one output with OP_RETURN, error will be returned. +func ExtractStandardOpReturnData(tx *btcutil.Tx) ([]byte, error) { msgTx := tx.MsgTx() opReturnData := []byte{} + var opReturnCounter = 0 + for _, output := range msgTx.TxOut { - pkScript := output.PkScript - pkScriptLen := len(pkScript) - // valid op return script will have at least 2 bytes - // - fisrt byte should be OP_RETURN marker - // - second byte should indicate how many bytes there are in opreturn script - if pkScriptLen > 1 && - pkScriptLen <= maxOpReturnPkScriptSize && - pkScript[0] == txscript.OP_RETURN { - - // if this is OP_PUSHDATA1, we need to drop first 3 bytes as those are related + script := output.PkScript + + if !txscript.IsNullData(script) { + // not a standard op_return, we do not care about this output + continue + } + // At this point we know: + // - script is not empty + // - script is valid looking op_return + // - with at most 80bytes of data + opReturnCounter++ + + if opReturnCounter > 1 { + return nil, fmt.Errorf("transaction has more than one OP_RETURN output") + } + + if len(script) == 1 { + // just op_return op code + continue + } + + if script[1] == txscript.OP_PUSHDATA1 { + // we need to drop first 3 bytes as those are related // to script iteslf i.e OP_RETURN + OP_PUSHDATA1 + len of bytes - if pkScript[1] == txscript.OP_PUSHDATA1 { - opReturnData = append(opReturnData, pkScript[3:]...) - } else { - // this should be one of OP_DATAXX opcodes we drop first 2 bytes - opReturnData = append(opReturnData, pkScript[2:]...) - } + opReturnData = append(opReturnData, script[3:]...) + } else { + // this should be one of OP_DATAXX opcodes we drop first 2 bytes + opReturnData = append(opReturnData, script[2:]...) } } - return opReturnData + return opReturnData, nil } func ParseTransaction(bytes []byte) (*btcutil.Tx, error) { @@ -276,7 +281,11 @@ func ParseProof( return nil, fmt.Errorf("header failed validation due to failed proof") } - opReturnData := ExtractOpReturnData(tx) + opReturnData, err := ExtractStandardOpReturnData(tx) + + if err != nil { + return nil, err + } if len(opReturnData) == 0 { return nil, fmt.Errorf("provided transaction should provide op return data") diff --git a/x/btccheckpoint/types/btcutils_test.go b/x/btccheckpoint/types/btcutils_test.go index 576929eea..405b7bde3 100644 --- a/x/btccheckpoint/types/btcutils_test.go +++ b/x/btccheckpoint/types/btcutils_test.go @@ -3,12 +3,19 @@ package types_test import ( "bytes" "encoding/hex" + "math/rand" "testing" + "time" - bbn "github.com/babylonchain/babylon/types" - btcctypes "github.com/babylonchain/babylon/x/btccheckpoint/types" + "github.com/babylonlabs-io/babylon/testutil/datagen" + bbn "github.com/babylonlabs-io/babylon/types" + btcctypes "github.com/babylonlabs-io/babylon/x/btccheckpoint/types" + "github.com/btcsuite/btcd/btcutil" btcchaincfg "github.com/btcsuite/btcd/chaincfg" "github.com/btcsuite/btcd/chaincfg/chainhash" + "github.com/btcsuite/btcd/txscript" + "github.com/btcsuite/btcd/wire" + "github.com/stretchr/testify/require" ) // Sanity test checking mostly btcd code, that we can realy parse bitcoin transaction @@ -164,3 +171,106 @@ func TestParsingCorrectBtcProofs(t *testing.T) { } } } + +func buildOpReturnOutput(t *testing.T, r *rand.Rand, dataLen int) *wire.TxOut { + data := datagen.GenRandomByteArray(r, uint64(dataLen)) + pkscript, err := txscript.NewScriptBuilder().AddOp(txscript.OP_RETURN).AddData(data).Script() + require.NoError(t, err) + + return wire.NewTxOut(0, pkscript) +} + +func TestExtractingOpReturn(t *testing.T) { + tests := []struct { + name string + buildTxFn func(t *testing.T, r *rand.Rand) *btcutil.Tx + expectedDatalen int + returnsErr bool + }{ + { + name: "transaction with 1 op_return output containing 80 bytes of data", + buildTxFn: func(t *testing.T, r *rand.Rand) *btcutil.Tx { + tx := wire.NewMsgTx(wire.TxVersion) + tx.AddTxOut(buildOpReturnOutput(t, r, 80)) + return btcutil.NewTx(tx) + }, + expectedDatalen: 80, + returnsErr: false, + }, + { + name: "transaction with 1 op_return output containing 81 bytes of data", + buildTxFn: func(t *testing.T, r *rand.Rand) *btcutil.Tx { + tx := wire.NewMsgTx(wire.TxVersion) + tx.AddTxOut(buildOpReturnOutput(t, r, 81)) + return btcutil.NewTx(tx) + }, + expectedDatalen: 0, + returnsErr: false, + }, + { + name: "transaction with 1 op_return output containing 0 bytes of data", + buildTxFn: func(t *testing.T, r *rand.Rand) *btcutil.Tx { + tx := wire.NewMsgTx(wire.TxVersion) + tx.AddTxOut(buildOpReturnOutput(t, r, 0)) + return btcutil.NewTx(tx) + }, + expectedDatalen: 0, + returnsErr: false, + }, + { + name: "transaction with 2 op_return outputs", + buildTxFn: func(t *testing.T, r *rand.Rand) *btcutil.Tx { + tx := wire.NewMsgTx(wire.TxVersion) + tx.AddTxOut(buildOpReturnOutput(t, r, 1)) + tx.AddTxOut(buildOpReturnOutput(t, r, 2)) + return btcutil.NewTx(tx) + }, + expectedDatalen: 0, + returnsErr: true, + }, + { + name: "transaction with 1 op_return output containing 80 bytes of data, but with invalid OP_PUSHDATA2 opcode", + buildTxFn: func(t *testing.T, r *rand.Rand) *btcutil.Tx { + tx := wire.NewMsgTx(wire.TxVersion) + output := buildOpReturnOutput(t, r, 80) + // change valid txscript.OP_PUSHDATA1 to invalid txscript.OP_PUSHDATA2. + // This op code is invalid because it pushes less than 255 bytes of data + output.PkScript[1] = txscript.OP_PUSHDATA2 + tx.AddTxOut(output) + return btcutil.NewTx(tx) + }, + expectedDatalen: 0, + returnsErr: false, + }, + { + name: "transaction with 1 op_return output containing 80 bytes of data, but with invalid OP_PUSHDATA4 opcode", + buildTxFn: func(t *testing.T, r *rand.Rand) *btcutil.Tx { + tx := wire.NewMsgTx(wire.TxVersion) + output := buildOpReturnOutput(t, r, 80) + // change valid txscript.OP_PUSHDATA1 to invalid txscript.OP_PUSHDATA2. + // This op code is invalid because it pushes less than 255 bytes of data + output.PkScript[1] = txscript.OP_PUSHDATA4 + tx.AddTxOut(output) + return btcutil.NewTx(tx) + }, + expectedDatalen: 0, + returnsErr: false, + }, + } + + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + r := rand.New(rand.NewSource(time.Now().Unix())) + tx := tt.buildTxFn(t, r) + data, err := btcctypes.ExtractStandardOpReturnData(tx) + if tt.returnsErr { + require.Error(t, err) + require.Nil(t, data) + } else { + require.NoError(t, err) + require.NotNil(t, data) + require.Equal(t, tt.expectedDatalen, len(data)) + } + }) + } +} diff --git a/x/btccheckpoint/types/expected_keepers.go b/x/btccheckpoint/types/expected_keepers.go index 1d9da3675..324fccefc 100644 --- a/x/btccheckpoint/types/expected_keepers.go +++ b/x/btccheckpoint/types/expected_keepers.go @@ -2,8 +2,8 @@ package types import ( "context" - txformat "github.com/babylonchain/babylon/btctxformatter" - bbn "github.com/babylonchain/babylon/types" + txformat "github.com/babylonlabs-io/babylon/btctxformatter" + bbn "github.com/babylonlabs-io/babylon/types" ) type BTCLightClientKeeper interface { diff --git a/x/btccheckpoint/types/genesis.pb.go b/x/btccheckpoint/types/genesis.pb.go index a99ce5d8d..804cc55d5 100644 --- a/x/btccheckpoint/types/genesis.pb.go +++ b/x/btccheckpoint/types/genesis.pb.go @@ -77,7 +77,7 @@ func init() { } var fileDescriptor_9776220697c13f63 = []byte{ - // 205 bytes of a gzipped FileDescriptorProto + // 207 bytes of a gzipped FileDescriptorProto 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x52, 0x4b, 0x4a, 0x4c, 0xaa, 0xcc, 0xc9, 0xcf, 0xd3, 0x4f, 0x2a, 0x49, 0x4e, 0xce, 0x48, 0x4d, 0xce, 0x2e, 0xc8, 0xcf, 0xcc, 0x2b, 0xd1, 0x2f, 0x33, 0xd4, 0x4f, 0x4f, 0xcd, 0x4b, 0x2d, 0xce, 0x2c, 0xd6, 0x2b, 0x28, 0xca, @@ -86,11 +86,11 @@ var fileDescriptor_9776220697c13f63 = []byte{ 0x28, 0x31, 0x17, 0x6a, 0xac, 0x92, 0x1f, 0x17, 0x8f, 0x3b, 0xc4, 0x9e, 0xe0, 0x92, 0xc4, 0x92, 0x54, 0x21, 0x3b, 0x2e, 0x36, 0x88, 0xbc, 0x04, 0xa3, 0x02, 0xa3, 0x06, 0xb7, 0x91, 0x82, 0x1e, 0x2e, 0x7b, 0xf5, 0x02, 0xc0, 0xea, 0x9c, 0x58, 0x4e, 0xdc, 0x93, 0x67, 0x08, 0x82, 0xea, 0x72, - 0xf2, 0x3f, 0xf1, 0x48, 0x8e, 0xf1, 0xc2, 0x23, 0x39, 0xc6, 0x07, 0x8f, 0xe4, 0x18, 0x27, 0x3c, - 0x96, 0x63, 0xb8, 0xf0, 0x58, 0x8e, 0xe1, 0xc6, 0x63, 0x39, 0x86, 0x28, 0xd3, 0xf4, 0xcc, 0x92, - 0x8c, 0xd2, 0x24, 0xbd, 0xe4, 0xfc, 0x5c, 0x7d, 0xa8, 0x99, 0xc9, 0x19, 0x89, 0x99, 0x79, 0x30, - 0x8e, 0x7e, 0x05, 0x9a, 0x53, 0x4b, 0x2a, 0x0b, 0x52, 0x8b, 0x93, 0xd8, 0xc0, 0xee, 0x34, 0x06, - 0x04, 0x00, 0x00, 0xff, 0xff, 0x60, 0x50, 0x97, 0x1e, 0x28, 0x01, 0x00, 0x00, + 0x0a, 0x3c, 0xf1, 0x48, 0x8e, 0xf1, 0xc2, 0x23, 0x39, 0xc6, 0x07, 0x8f, 0xe4, 0x18, 0x27, 0x3c, + 0x96, 0x63, 0xb8, 0xf0, 0x58, 0x8e, 0xe1, 0xc6, 0x63, 0x39, 0x86, 0x28, 0xf3, 0xf4, 0xcc, 0x92, + 0x8c, 0xd2, 0x24, 0xbd, 0xe4, 0xfc, 0x5c, 0x7d, 0xa8, 0x99, 0x39, 0x89, 0x49, 0xc5, 0xba, 0x99, + 0xf9, 0x30, 0xae, 0x7e, 0x05, 0x9a, 0x63, 0x4b, 0x2a, 0x0b, 0x52, 0x8b, 0x93, 0xd8, 0xc0, 0x2e, + 0x35, 0x06, 0x04, 0x00, 0x00, 0xff, 0xff, 0xf5, 0xa9, 0x6b, 0x00, 0x2a, 0x01, 0x00, 0x00, } func (m *GenesisState) Marshal() (dAtA []byte, err error) { diff --git a/x/btccheckpoint/types/genesis_test.go b/x/btccheckpoint/types/genesis_test.go index 068fd4e15..aa5c98b5d 100644 --- a/x/btccheckpoint/types/genesis_test.go +++ b/x/btccheckpoint/types/genesis_test.go @@ -3,7 +3,7 @@ package types_test import ( "testing" - "github.com/babylonchain/babylon/x/btccheckpoint/types" + "github.com/babylonlabs-io/babylon/x/btccheckpoint/types" "github.com/stretchr/testify/require" ) diff --git a/x/btccheckpoint/types/mock_keepers.go b/x/btccheckpoint/types/mock_keepers.go index 3d533d24f..8d58c3dc3 100644 --- a/x/btccheckpoint/types/mock_keepers.go +++ b/x/btccheckpoint/types/mock_keepers.go @@ -4,8 +4,8 @@ import ( "context" "errors" - txformat "github.com/babylonchain/babylon/btctxformatter" - bbn "github.com/babylonchain/babylon/types" + txformat "github.com/babylonlabs-io/babylon/btctxformatter" + bbn "github.com/babylonlabs-io/babylon/types" ) type MockBTCLightClientKeeper struct { diff --git a/x/btccheckpoint/types/msgs.go b/x/btccheckpoint/types/msgs.go index 312f7cc68..ee645c24e 100644 --- a/x/btccheckpoint/types/msgs.go +++ b/x/btccheckpoint/types/msgs.go @@ -5,7 +5,7 @@ import ( fmt "fmt" "math/big" - txformat "github.com/babylonchain/babylon/btctxformatter" + txformat "github.com/babylonlabs-io/babylon/btctxformatter" sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" ) diff --git a/x/btccheckpoint/types/params.go b/x/btccheckpoint/types/params.go index 6a72e6e32..68b62f4b7 100644 --- a/x/btccheckpoint/types/params.go +++ b/x/btccheckpoint/types/params.go @@ -4,7 +4,7 @@ import ( "encoding/hex" "fmt" - txformat "github.com/babylonchain/babylon/btctxformatter" + txformat "github.com/babylonlabs-io/babylon/btctxformatter" ) const ( diff --git a/x/btccheckpoint/types/params.pb.go b/x/btccheckpoint/types/params.pb.go index 4f6d10a6c..a2f432d08 100644 --- a/x/btccheckpoint/types/params.pb.go +++ b/x/btccheckpoint/types/params.pb.go @@ -104,7 +104,7 @@ func init() { } var fileDescriptor_5445a19005ae983c = []byte{ - // 306 bytes of a gzipped FileDescriptorProto + // 308 bytes of a gzipped FileDescriptorProto 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x52, 0x4d, 0x4a, 0x4c, 0xaa, 0xcc, 0xc9, 0xcf, 0xd3, 0x4f, 0x2a, 0x49, 0x4e, 0xce, 0x48, 0x4d, 0xce, 0x2e, 0xc8, 0xcf, 0xcc, 0x2b, 0xd1, 0x2f, 0x33, 0xd4, 0x2f, 0x48, 0x2c, 0x4a, 0xcc, 0x2d, 0xd6, 0x2b, 0x28, 0xca, 0x2f, @@ -119,12 +119,12 @@ var fileDescriptor_5445a19005ae983c = []byte{ 0xa5, 0x20, 0x59, 0x84, 0x0a, 0x37, 0x24, 0x05, 0x21, 0x10, 0x79, 0x21, 0x07, 0x2e, 0x3e, 0x24, 0x23, 0x4a, 0x12, 0xd3, 0x25, 0x98, 0x15, 0x18, 0x35, 0x38, 0x9d, 0x24, 0x3f, 0xdd, 0x93, 0x17, 0xc5, 0xb0, 0xa2, 0x24, 0x31, 0x5d, 0x29, 0x88, 0x17, 0x21, 0x10, 0x92, 0x98, 0x6e, 0xc5, 0xf2, - 0x62, 0x81, 0x3c, 0xa3, 0x93, 0xff, 0x89, 0x47, 0x72, 0x8c, 0x17, 0x1e, 0xc9, 0x31, 0x3e, 0x78, + 0x62, 0x81, 0x3c, 0xa3, 0x53, 0xe0, 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, - 0x99, 0xa6, 0x67, 0x96, 0x64, 0x94, 0x26, 0xe9, 0x25, 0xe7, 0xe7, 0xea, 0x43, 0x03, 0x3d, 0x39, - 0x23, 0x31, 0x33, 0x0f, 0xc6, 0xd1, 0xaf, 0x40, 0x8b, 0xaa, 0x92, 0xca, 0x82, 0xd4, 0xe2, 0x24, - 0x36, 0x70, 0xb8, 0x1b, 0x03, 0x02, 0x00, 0x00, 0xff, 0xff, 0xf7, 0x78, 0xcb, 0x81, 0xd0, 0x01, - 0x00, 0x00, + 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, + 0xd2, 0x01, 0x00, 0x00, } func (this *Params) Equal(that interface{}) bool { diff --git a/x/btccheckpoint/types/params_test.go b/x/btccheckpoint/types/params_test.go index e22e25245..a534b9a0a 100644 --- a/x/btccheckpoint/types/params_test.go +++ b/x/btccheckpoint/types/params_test.go @@ -3,7 +3,7 @@ package types_test import ( "testing" - "github.com/babylonchain/babylon/x/btccheckpoint/types" + "github.com/babylonlabs-io/babylon/x/btccheckpoint/types" "github.com/stretchr/testify/require" ) diff --git a/x/btccheckpoint/types/query.go b/x/btccheckpoint/types/query.go new file mode 100644 index 000000000..e2d51a647 --- /dev/null +++ b/x/btccheckpoint/types/query.go @@ -0,0 +1,62 @@ +package types + +import ( + "encoding/hex" + + "github.com/cosmos/cosmos-sdk/types" + codes "google.golang.org/grpc/codes" + status "google.golang.org/grpc/status" +) + +// ToResponse parses a TransactionInfo into a query response tx info struct. +func (ti *TransactionInfo) ToResponse() *TransactionInfoResponse { + return &TransactionInfoResponse{ + Index: ti.Key.Index, + Hash: ti.Key.Hash.MarshalHex(), + Transaction: hex.EncodeToString(ti.Transaction), + Proof: hex.EncodeToString(ti.Proof), + } +} + +// ToResponse parses a CheckpointAddresses into a query response checkpoint addresses struct. +func (ca *CheckpointAddresses) ToResponse() *CheckpointAddressesResponse { + return &CheckpointAddressesResponse{ + Submitter: types.AccAddress(ca.Submitter).String(), + Reporter: types.AccAddress(ca.Reporter).String(), + } +} + +// NewSubmissionKeyResponse parses a SubmissionKey into a query response submission key struct. +func NewSubmissionKeyResponse(sk SubmissionKey) (skr *SubmissionKeyResponse, err error) { + if len(sk.Key) != 2 { + return nil, status.Errorf(codes.Internal, "bad submission key %+v, does not have 2 keys", sk) + } + + k1, k2 := sk.Key[0], sk.Key[1] + return &SubmissionKeyResponse{ + FirstTxBlockHash: k1.Hash.MarshalHex(), + FirstTxIndex: k1.Index, + SecondTxBlockHash: k2.Hash.MarshalHex(), + SecondTxIndex: k2.Index, + }, nil +} + +// ToResponse parses a BTCCheckpointInfo into a query response for btc checkpoint info struct. +func (b BTCCheckpointInfo) ToResponse() *BTCCheckpointInfoResponse { + bestSubTxs := make([]*TransactionInfoResponse, len(b.BestSubmissionTransactions)) + for i, tx := range b.BestSubmissionTransactions { + bestSubTxs[i] = tx.ToResponse() + } + bestSubVigAddrs := make([]*CheckpointAddressesResponse, len(b.BestSubmissionVigilanteAddressList)) + for i, addrs := range b.BestSubmissionVigilanteAddressList { + bestSubVigAddrs[i] = addrs.ToResponse() + } + + return &BTCCheckpointInfoResponse{ + EpochNumber: b.EpochNumber, + BestSubmissionBtcBlockHeight: b.BestSubmissionBtcBlockHeight, + BestSubmissionBtcBlockHash: b.BestSubmissionBtcBlockHash.MarshalHex(), + BestSubmissionTransactions: bestSubTxs, + BestSubmissionVigilanteAddressList: bestSubVigAddrs, + } +} diff --git a/x/btccheckpoint/types/query.pb.go b/x/btccheckpoint/types/query.pb.go index 65b155490..88a83251e 100644 --- a/x/btccheckpoint/types/query.pb.go +++ b/x/btccheckpoint/types/query.pb.go @@ -6,6 +6,7 @@ package types import ( context "context" fmt "fmt" + _ "github.com/cosmos/cosmos-proto" query "github.com/cosmos/cosmos-sdk/types/query" _ "github.com/cosmos/gogoproto/gogoproto" grpc1 "github.com/cosmos/gogoproto/grpc" @@ -164,7 +165,7 @@ func (m *QueryBtcCheckpointInfoRequest) GetEpochNum() uint64 { // QueryBtcCheckpointInfoResponse is response type for the // Query/BtcCheckpointInfo RPC method type QueryBtcCheckpointInfoResponse struct { - Info *BTCCheckpointInfo `protobuf:"bytes,1,opt,name=info,proto3" json:"info,omitempty"` + Info *BTCCheckpointInfoResponse `protobuf:"bytes,1,opt,name=info,proto3" json:"info,omitempty"` } func (m *QueryBtcCheckpointInfoResponse) Reset() { *m = QueryBtcCheckpointInfoResponse{} } @@ -200,7 +201,7 @@ func (m *QueryBtcCheckpointInfoResponse) XXX_DiscardUnknown() { var xxx_messageInfo_QueryBtcCheckpointInfoResponse proto.InternalMessageInfo -func (m *QueryBtcCheckpointInfoResponse) GetInfo() *BTCCheckpointInfo { +func (m *QueryBtcCheckpointInfoResponse) GetInfo() *BTCCheckpointInfoResponse { if m != nil { return m.Info } @@ -257,7 +258,7 @@ func (m *QueryBtcCheckpointsInfoRequest) GetPagination() *query.PageRequest { // QueryBtcCheckpointsInfoResponse is response type for the // Query/BtcCheckpointsInfo RPC method type QueryBtcCheckpointsInfoResponse struct { - InfoList []*BTCCheckpointInfo `protobuf:"bytes,1,rep,name=info_list,json=infoList,proto3" json:"info_list,omitempty"` + InfoList []*BTCCheckpointInfoResponse `protobuf:"bytes,1,rep,name=info_list,json=infoList,proto3" json:"info_list,omitempty"` // pagination defines the pagination in the response Pagination *query.PageResponse `protobuf:"bytes,2,opt,name=pagination,proto3" json:"pagination,omitempty"` } @@ -295,7 +296,7 @@ func (m *QueryBtcCheckpointsInfoResponse) XXX_DiscardUnknown() { var xxx_messageInfo_QueryBtcCheckpointsInfoResponse proto.InternalMessageInfo -func (m *QueryBtcCheckpointsInfoResponse) GetInfoList() []*BTCCheckpointInfo { +func (m *QueryBtcCheckpointsInfoResponse) GetInfoList() []*BTCCheckpointInfoResponse { if m != nil { return m.InfoList } @@ -313,8 +314,7 @@ func (m *QueryBtcCheckpointsInfoResponse) GetPagination() *query.PageResponse { // given epoch type QueryEpochSubmissionsRequest struct { // Number of epoch for which submissions are requested - EpochNum uint64 `protobuf:"varint,1,opt,name=epoch_num,json=epochNum,proto3" json:"epoch_num,omitempty"` - Pagination *query.PageRequest `protobuf:"bytes,2,opt,name=pagination,proto3" json:"pagination,omitempty"` + EpochNum uint64 `protobuf:"varint,1,opt,name=epoch_num,json=epochNum,proto3" json:"epoch_num,omitempty"` } func (m *QueryEpochSubmissionsRequest) Reset() { *m = QueryEpochSubmissionsRequest{} } @@ -357,19 +357,11 @@ func (m *QueryEpochSubmissionsRequest) GetEpochNum() uint64 { return 0 } -func (m *QueryEpochSubmissionsRequest) GetPagination() *query.PageRequest { - if m != nil { - return m.Pagination - } - return nil -} - // QueryEpochSubmissionsResponse defines a response to get all submissions in // given epoch (QueryEpochSubmissionsRequest) type QueryEpochSubmissionsResponse struct { - // All submissions saved during an epoch. - Keys []*SubmissionKey `protobuf:"bytes,1,rep,name=keys,proto3" json:"keys,omitempty"` - Pagination *query.PageResponse `protobuf:"bytes,2,opt,name=pagination,proto3" json:"pagination,omitempty"` + // Keys All submissions transactions key saved during an epoch. + Keys []*SubmissionKeyResponse `protobuf:"bytes,1,rep,name=keys,proto3" json:"keys,omitempty"` } func (m *QueryEpochSubmissionsResponse) Reset() { *m = QueryEpochSubmissionsResponse{} } @@ -405,20 +397,309 @@ func (m *QueryEpochSubmissionsResponse) XXX_DiscardUnknown() { var xxx_messageInfo_QueryEpochSubmissionsResponse proto.InternalMessageInfo -func (m *QueryEpochSubmissionsResponse) GetKeys() []*SubmissionKey { +func (m *QueryEpochSubmissionsResponse) GetKeys() []*SubmissionKeyResponse { if m != nil { return m.Keys } return nil } -func (m *QueryEpochSubmissionsResponse) GetPagination() *query.PageResponse { +// BTCCheckpointInfoResponse contains all data about best submission of checkpoint for +// given epoch. Best submission is the submission which is deeper in btc ledger. +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"` + // 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"` + // the BTC checkpoint transactions of the best submission + BestSubmissionTransactions []*TransactionInfoResponse `protobuf:"bytes,4,rep,name=best_submission_transactions,json=bestSubmissionTransactions,proto3" json:"best_submission_transactions,omitempty"` + // list of vigilantes' addresses of the best submission + BestSubmissionVigilanteAddressList []*CheckpointAddressesResponse `protobuf:"bytes,5,rep,name=best_submission_vigilante_address_list,json=bestSubmissionVigilanteAddressList,proto3" json:"best_submission_vigilante_address_list,omitempty"` +} + +func (m *BTCCheckpointInfoResponse) Reset() { *m = BTCCheckpointInfoResponse{} } +func (m *BTCCheckpointInfoResponse) String() string { return proto.CompactTextString(m) } +func (*BTCCheckpointInfoResponse) ProtoMessage() {} +func (*BTCCheckpointInfoResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_6b9a2f46ada7d854, []int{8} +} +func (m *BTCCheckpointInfoResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *BTCCheckpointInfoResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_BTCCheckpointInfoResponse.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 *BTCCheckpointInfoResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_BTCCheckpointInfoResponse.Merge(m, src) +} +func (m *BTCCheckpointInfoResponse) XXX_Size() int { + return m.Size() +} +func (m *BTCCheckpointInfoResponse) XXX_DiscardUnknown() { + xxx_messageInfo_BTCCheckpointInfoResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_BTCCheckpointInfoResponse proto.InternalMessageInfo + +func (m *BTCCheckpointInfoResponse) GetEpochNumber() uint64 { if m != nil { - return m.Pagination + return m.EpochNumber + } + return 0 +} + +func (m *BTCCheckpointInfoResponse) GetBestSubmissionBtcBlockHeight() uint64 { + if m != nil { + return m.BestSubmissionBtcBlockHeight + } + return 0 +} + +func (m *BTCCheckpointInfoResponse) GetBestSubmissionBtcBlockHash() string { + if m != nil { + return m.BestSubmissionBtcBlockHash + } + return "" +} + +func (m *BTCCheckpointInfoResponse) GetBestSubmissionTransactions() []*TransactionInfoResponse { + if m != nil { + return m.BestSubmissionTransactions + } + return nil +} + +func (m *BTCCheckpointInfoResponse) GetBestSubmissionVigilanteAddressList() []*CheckpointAddressesResponse { + if m != nil { + return m.BestSubmissionVigilanteAddressList } return nil } +// 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 +type TransactionInfoResponse struct { + // Index Bitcoin Transaction index in block. + Index uint32 `protobuf:"varint,1,opt,name=index,proto3" json:"index,omitempty"` + // Hash BTC Header hash as hex. + Hash string `protobuf:"bytes,2,opt,name=hash,proto3" json:"hash,omitempty"` + // transaction is the full transaction data as str hex. + Transaction string `protobuf:"bytes,3,opt,name=transaction,proto3" json:"transaction,omitempty"` + // proof is the Merkle proof that this tx is included in the position in `key` + Proof string `protobuf:"bytes,4,opt,name=proof,proto3" json:"proof,omitempty"` +} + +func (m *TransactionInfoResponse) Reset() { *m = TransactionInfoResponse{} } +func (m *TransactionInfoResponse) String() string { return proto.CompactTextString(m) } +func (*TransactionInfoResponse) ProtoMessage() {} +func (*TransactionInfoResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_6b9a2f46ada7d854, []int{9} +} +func (m *TransactionInfoResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *TransactionInfoResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_TransactionInfoResponse.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 *TransactionInfoResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_TransactionInfoResponse.Merge(m, src) +} +func (m *TransactionInfoResponse) XXX_Size() int { + return m.Size() +} +func (m *TransactionInfoResponse) XXX_DiscardUnknown() { + xxx_messageInfo_TransactionInfoResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_TransactionInfoResponse proto.InternalMessageInfo + +func (m *TransactionInfoResponse) GetIndex() uint32 { + if m != nil { + return m.Index + } + return 0 +} + +func (m *TransactionInfoResponse) GetHash() string { + if m != nil { + return m.Hash + } + return "" +} + +func (m *TransactionInfoResponse) GetTransaction() string { + if m != nil { + return m.Transaction + } + return "" +} + +func (m *TransactionInfoResponse) GetProof() string { + if m != nil { + return m.Proof + } + return "" +} + +// CheckpointAddressesResponse contains the addresses of the submitter and reporter of a +// given checkpoint +type CheckpointAddressesResponse struct { + // submitter is the address of the checkpoint submitter to BTC, extracted from + // the checkpoint itself. + Submitter string `protobuf:"bytes,1,opt,name=submitter,proto3" json:"submitter,omitempty"` + // reporter is the address of the reporter who reported the submissions, + // calculated from submission message MsgInsertBTCSpvProof itself + Reporter string `protobuf:"bytes,2,opt,name=reporter,proto3" json:"reporter,omitempty"` +} + +func (m *CheckpointAddressesResponse) Reset() { *m = CheckpointAddressesResponse{} } +func (m *CheckpointAddressesResponse) String() string { return proto.CompactTextString(m) } +func (*CheckpointAddressesResponse) ProtoMessage() {} +func (*CheckpointAddressesResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_6b9a2f46ada7d854, []int{10} +} +func (m *CheckpointAddressesResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *CheckpointAddressesResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_CheckpointAddressesResponse.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 *CheckpointAddressesResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_CheckpointAddressesResponse.Merge(m, src) +} +func (m *CheckpointAddressesResponse) XXX_Size() int { + return m.Size() +} +func (m *CheckpointAddressesResponse) XXX_DiscardUnknown() { + xxx_messageInfo_CheckpointAddressesResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_CheckpointAddressesResponse proto.InternalMessageInfo + +func (m *CheckpointAddressesResponse) GetSubmitter() string { + if m != nil { + return m.Submitter + } + return "" +} + +func (m *CheckpointAddressesResponse) GetReporter() string { + if m != nil { + return m.Reporter + } + return "" +} + +// 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 +type SubmissionKeyResponse struct { + // FirstTxBlockHash is the BTCHeaderHashBytes in hex. + FirstTxBlockHash string `protobuf:"bytes,1,opt,name=first_tx_block_hash,json=firstTxBlockHash,proto3" json:"first_tx_block_hash,omitempty"` + FirstTxIndex uint32 `protobuf:"varint,2,opt,name=first_tx_index,json=firstTxIndex,proto3" json:"first_tx_index,omitempty"` + // SecondBlockHash is the BTCHeaderHashBytes in hex. + SecondTxBlockHash string `protobuf:"bytes,3,opt,name=second_tx_block_hash,json=secondTxBlockHash,proto3" json:"second_tx_block_hash,omitempty"` + SecondTxIndex uint32 `protobuf:"varint,4,opt,name=second_tx_index,json=secondTxIndex,proto3" json:"second_tx_index,omitempty"` +} + +func (m *SubmissionKeyResponse) Reset() { *m = SubmissionKeyResponse{} } +func (m *SubmissionKeyResponse) String() string { return proto.CompactTextString(m) } +func (*SubmissionKeyResponse) ProtoMessage() {} +func (*SubmissionKeyResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_6b9a2f46ada7d854, []int{11} +} +func (m *SubmissionKeyResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *SubmissionKeyResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_SubmissionKeyResponse.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 *SubmissionKeyResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_SubmissionKeyResponse.Merge(m, src) +} +func (m *SubmissionKeyResponse) XXX_Size() int { + return m.Size() +} +func (m *SubmissionKeyResponse) XXX_DiscardUnknown() { + xxx_messageInfo_SubmissionKeyResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_SubmissionKeyResponse proto.InternalMessageInfo + +func (m *SubmissionKeyResponse) GetFirstTxBlockHash() string { + if m != nil { + return m.FirstTxBlockHash + } + return "" +} + +func (m *SubmissionKeyResponse) GetFirstTxIndex() uint32 { + if m != nil { + return m.FirstTxIndex + } + return 0 +} + +func (m *SubmissionKeyResponse) GetSecondTxBlockHash() string { + if m != nil { + return m.SecondTxBlockHash + } + return "" +} + +func (m *SubmissionKeyResponse) GetSecondTxIndex() uint32 { + if m != nil { + return m.SecondTxIndex + } + return 0 +} + func init() { proto.RegisterType((*QueryParamsRequest)(nil), "babylon.btccheckpoint.v1.QueryParamsRequest") proto.RegisterType((*QueryParamsResponse)(nil), "babylon.btccheckpoint.v1.QueryParamsResponse") @@ -428,6 +709,10 @@ func init() { proto.RegisterType((*QueryBtcCheckpointsInfoResponse)(nil), "babylon.btccheckpoint.v1.QueryBtcCheckpointsInfoResponse") proto.RegisterType((*QueryEpochSubmissionsRequest)(nil), "babylon.btccheckpoint.v1.QueryEpochSubmissionsRequest") proto.RegisterType((*QueryEpochSubmissionsResponse)(nil), "babylon.btccheckpoint.v1.QueryEpochSubmissionsResponse") + proto.RegisterType((*BTCCheckpointInfoResponse)(nil), "babylon.btccheckpoint.v1.BTCCheckpointInfoResponse") + proto.RegisterType((*TransactionInfoResponse)(nil), "babylon.btccheckpoint.v1.TransactionInfoResponse") + proto.RegisterType((*CheckpointAddressesResponse)(nil), "babylon.btccheckpoint.v1.CheckpointAddressesResponse") + proto.RegisterType((*SubmissionKeyResponse)(nil), "babylon.btccheckpoint.v1.SubmissionKeyResponse") } func init() { @@ -435,46 +720,67 @@ func init() { } var fileDescriptor_6b9a2f46ada7d854 = []byte{ - // 621 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x95, 0x4d, 0x6b, 0x13, 0x4f, - 0x1c, 0xc7, 0x33, 0xf9, 0xa7, 0xa1, 0x9d, 0xff, 0x45, 0xc7, 0x1e, 0xe2, 0xb6, 0x6e, 0xe3, 0x62, - 0x4d, 0xd1, 0x76, 0x97, 0xb4, 0x68, 0x2d, 0x8a, 0x42, 0x8a, 0x4f, 0x28, 0x5a, 0xa3, 0x5e, 0xbc, - 0x94, 0xd9, 0x65, 0xba, 0x59, 0x9a, 0x9d, 0xd9, 0x66, 0x66, 0x83, 0x41, 0xbc, 0xe8, 0x0b, 0x50, - 0xf0, 0x35, 0x78, 0xf3, 0xa8, 0x57, 0xc1, 0x5b, 0x8f, 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00, + // 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, 0x7b, 0xdf, 0x7c, 0xef, 0x65, 0x5f, 0xe0, 0xa6, 0x8f, 0xfd, 0x61, 0x8f, 0x45, + 0x8e, 0x2f, 0x82, 0xa0, 0x4b, 0x82, 0xc3, 0x98, 0xd1, 0x48, 0x38, 0x47, 0x2d, 0xe7, 0xc9, 0x80, + 0x24, 0x43, 0x3b, 0x4e, 0x98, 0x60, 0xa8, 0xaa, 0x51, 0xf6, 0x04, 0xca, 0x3e, 0x6a, 0xd5, 0x2a, + 0x21, 0x0b, 0x99, 0x04, 0x39, 0xe9, 0x2f, 0x85, 0xaf, 0xad, 0x05, 0x8c, 0xf7, 0x19, 0xf7, 0xd4, + 0x81, 0x7a, 0xd0, 0x47, 0x1b, 0x21, 0x63, 0x61, 0x8f, 0x38, 0x38, 0xa6, 0x0e, 0x8e, 0x22, 0x26, + 0xb0, 0xa0, 0x2c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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, } // Reference imports to suppress errors if they are not otherwise used. @@ -896,18 +1202,6 @@ func (m *QueryEpochSubmissionsRequest) MarshalToSizedBuffer(dAtA []byte) (int, e _ = 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.EpochNum != 0 { i = encodeVarintQuery(dAtA, i, uint64(m.EpochNum)) i-- @@ -936,18 +1230,6 @@ func (m *QueryEpochSubmissionsResponse) MarshalToSizedBuffer(dAtA []byte) (int, _ = 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.Keys) > 0 { for iNdEx := len(m.Keys) - 1; iNdEx >= 0; iNdEx-- { { @@ -965,76 +1247,277 @@ func (m *QueryEpochSubmissionsResponse) MarshalToSizedBuffer(dAtA []byte) (int, 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 +func (m *BTCCheckpointInfoResponse) 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 l int - _ = l - return n + return dAtA[:n], nil } -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 *BTCCheckpointInfoResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *QueryBtcCheckpointInfoRequest) Size() (n int) { - if m == nil { - return 0 - } +func (m *BTCCheckpointInfoResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i var l int _ = l - if m.EpochNum != 0 { - n += 1 + sovQuery(uint64(m.EpochNum)) + if len(m.BestSubmissionVigilanteAddressList) > 0 { + for iNdEx := len(m.BestSubmissionVigilanteAddressList) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.BestSubmissionVigilanteAddressList[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x2a + } } - return n -} - -func (m *QueryBtcCheckpointInfoResponse) Size() (n int) { - if m == nil { - return 0 + if len(m.BestSubmissionTransactions) > 0 { + for iNdEx := len(m.BestSubmissionTransactions) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.BestSubmissionTransactions[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x22 + } } - var l int - _ = l - if m.Info != nil { - l = m.Info.Size() - n += 1 + l + sovQuery(uint64(l)) + if len(m.BestSubmissionBtcBlockHash) > 0 { + i -= len(m.BestSubmissionBtcBlockHash) + copy(dAtA[i:], m.BestSubmissionBtcBlockHash) + i = encodeVarintQuery(dAtA, i, uint64(len(m.BestSubmissionBtcBlockHash))) + i-- + dAtA[i] = 0x1a } - return n -} - -func (m *QueryBtcCheckpointsInfoRequest) Size() (n int) { - if m == nil { - return 0 + if m.BestSubmissionBtcBlockHeight != 0 { + i = encodeVarintQuery(dAtA, i, uint64(m.BestSubmissionBtcBlockHeight)) + i-- + dAtA[i] = 0x10 } - var l int - _ = l - if m.Pagination != nil { - l = m.Pagination.Size() - n += 1 + l + sovQuery(uint64(l)) + if m.EpochNumber != 0 { + i = encodeVarintQuery(dAtA, i, uint64(m.EpochNumber)) + i-- + dAtA[i] = 0x8 } - return n + return len(dAtA) - i, nil } -func (m *QueryBtcCheckpointsInfoResponse) Size() (n int) { +func (m *TransactionInfoResponse) 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 *TransactionInfoResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *TransactionInfoResponse) 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 = encodeVarintQuery(dAtA, i, uint64(len(m.Proof))) + i-- + dAtA[i] = 0x22 + } + if len(m.Transaction) > 0 { + i -= len(m.Transaction) + copy(dAtA[i:], m.Transaction) + i = encodeVarintQuery(dAtA, i, uint64(len(m.Transaction))) + i-- + dAtA[i] = 0x1a + } + if len(m.Hash) > 0 { + i -= len(m.Hash) + copy(dAtA[i:], m.Hash) + i = encodeVarintQuery(dAtA, i, uint64(len(m.Hash))) + i-- + dAtA[i] = 0x12 + } + if m.Index != 0 { + i = encodeVarintQuery(dAtA, i, uint64(m.Index)) + i-- + dAtA[i] = 0x8 + } + return len(dAtA) - i, nil +} + +func (m *CheckpointAddressesResponse) 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 *CheckpointAddressesResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *CheckpointAddressesResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Reporter) > 0 { + i -= len(m.Reporter) + copy(dAtA[i:], m.Reporter) + i = encodeVarintQuery(dAtA, i, uint64(len(m.Reporter))) + i-- + dAtA[i] = 0x12 + } + if len(m.Submitter) > 0 { + i -= len(m.Submitter) + copy(dAtA[i:], m.Submitter) + i = encodeVarintQuery(dAtA, i, uint64(len(m.Submitter))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *SubmissionKeyResponse) 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 *SubmissionKeyResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *SubmissionKeyResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.SecondTxIndex != 0 { + i = encodeVarintQuery(dAtA, i, uint64(m.SecondTxIndex)) + i-- + dAtA[i] = 0x20 + } + if len(m.SecondTxBlockHash) > 0 { + i -= len(m.SecondTxBlockHash) + copy(dAtA[i:], m.SecondTxBlockHash) + i = encodeVarintQuery(dAtA, i, uint64(len(m.SecondTxBlockHash))) + i-- + dAtA[i] = 0x1a + } + if m.FirstTxIndex != 0 { + i = encodeVarintQuery(dAtA, i, uint64(m.FirstTxIndex)) + i-- + dAtA[i] = 0x10 + } + if len(m.FirstTxBlockHash) > 0 { + i -= len(m.FirstTxBlockHash) + copy(dAtA[i:], m.FirstTxBlockHash) + i = encodeVarintQuery(dAtA, i, uint64(len(m.FirstTxBlockHash))) + 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 *QueryBtcCheckpointInfoRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.EpochNum != 0 { + n += 1 + sovQuery(uint64(m.EpochNum)) + } + return n +} + +func (m *QueryBtcCheckpointInfoResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.Info != nil { + l = m.Info.Size() + n += 1 + l + sovQuery(uint64(l)) + } + return n +} + +func (m *QueryBtcCheckpointsInfoRequest) 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 *QueryBtcCheckpointsInfoResponse) Size() (n int) { if m == nil { return 0 } @@ -1062,10 +1545,6 @@ func (m *QueryEpochSubmissionsRequest) Size() (n int) { if m.EpochNum != 0 { n += 1 + sovQuery(uint64(m.EpochNum)) } - if m.Pagination != nil { - l = m.Pagination.Size() - n += 1 + l + sovQuery(uint64(l)) - } return n } @@ -1081,10 +1560,101 @@ func (m *QueryEpochSubmissionsResponse) Size() (n int) { n += 1 + l + sovQuery(uint64(l)) } } - if m.Pagination != nil { - l = m.Pagination.Size() + return n +} + +func (m *BTCCheckpointInfoResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.EpochNumber != 0 { + n += 1 + sovQuery(uint64(m.EpochNumber)) + } + if m.BestSubmissionBtcBlockHeight != 0 { + n += 1 + sovQuery(uint64(m.BestSubmissionBtcBlockHeight)) + } + l = len(m.BestSubmissionBtcBlockHash) + if l > 0 { + n += 1 + l + sovQuery(uint64(l)) + } + if len(m.BestSubmissionTransactions) > 0 { + for _, e := range m.BestSubmissionTransactions { + l = e.Size() + n += 1 + l + sovQuery(uint64(l)) + } + } + if len(m.BestSubmissionVigilanteAddressList) > 0 { + for _, e := range m.BestSubmissionVigilanteAddressList { + l = e.Size() + n += 1 + l + sovQuery(uint64(l)) + } + } + return n +} + +func (m *TransactionInfoResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.Index != 0 { + n += 1 + sovQuery(uint64(m.Index)) + } + l = len(m.Hash) + if l > 0 { + n += 1 + l + sovQuery(uint64(l)) + } + l = len(m.Transaction) + if l > 0 { n += 1 + l + sovQuery(uint64(l)) } + l = len(m.Proof) + if l > 0 { + n += 1 + l + sovQuery(uint64(l)) + } + return n +} + +func (m *CheckpointAddressesResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Submitter) + if l > 0 { + n += 1 + l + sovQuery(uint64(l)) + } + l = len(m.Reporter) + if l > 0 { + n += 1 + l + sovQuery(uint64(l)) + } + return n +} + +func (m *SubmissionKeyResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.FirstTxBlockHash) + if l > 0 { + n += 1 + l + sovQuery(uint64(l)) + } + if m.FirstTxIndex != 0 { + n += 1 + sovQuery(uint64(m.FirstTxIndex)) + } + l = len(m.SecondTxBlockHash) + if l > 0 { + n += 1 + l + sovQuery(uint64(l)) + } + if m.SecondTxIndex != 0 { + n += 1 + sovQuery(uint64(m.SecondTxIndex)) + } return n } @@ -1355,7 +1925,7 @@ func (m *QueryBtcCheckpointInfoResponse) Unmarshal(dAtA []byte) error { return io.ErrUnexpectedEOF } if m.Info == nil { - m.Info = &BTCCheckpointInfo{} + m.Info = &BTCCheckpointInfoResponse{} } if err := m.Info.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err @@ -1526,7 +2096,7 @@ func (m *QueryBtcCheckpointsInfoResponse) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.InfoList = append(m.InfoList, &BTCCheckpointInfo{}) + m.InfoList = append(m.InfoList, &BTCCheckpointInfoResponse{}) if err := m.InfoList[len(m.InfoList)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } @@ -1636,42 +2206,6 @@ func (m *QueryEpochSubmissionsRequest) Unmarshal(dAtA []byte) error { 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:]) @@ -1751,14 +2285,134 @@ func (m *QueryEpochSubmissionsResponse) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.Keys = append(m.Keys, &SubmissionKey{}) + m.Keys = append(m.Keys, &SubmissionKeyResponse{}) if err := m.Keys[len(m.Keys)-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 *BTCCheckpointInfoResponse) 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: BTCCheckpointInfoResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: BTCCheckpointInfoResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field EpochNumber", wireType) + } + m.EpochNumber = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.EpochNumber |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } case 2: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field BestSubmissionBtcBlockHeight", wireType) + } + m.BestSubmissionBtcBlockHeight = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.BestSubmissionBtcBlockHeight |= 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 BestSubmissionBtcBlockHash", 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.BestSubmissionBtcBlockHash = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field BestSubmissionTransactions", wireType) } var msglen int for shift := uint(0); ; shift += 7 { @@ -1785,13 +2439,476 @@ func (m *QueryEpochSubmissionsResponse) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - if m.Pagination == nil { - m.Pagination = &query.PageResponse{} + m.BestSubmissionTransactions = append(m.BestSubmissionTransactions, &TransactionInfoResponse{}) + if err := m.BestSubmissionTransactions[len(m.BestSubmissionTransactions)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err } - if err := m.Pagination.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + iNdEx = postIndex + case 5: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field BestSubmissionVigilanteAddressList", 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.BestSubmissionVigilanteAddressList = append(m.BestSubmissionVigilanteAddressList, &CheckpointAddressesResponse{}) + if err := m.BestSubmissionVigilanteAddressList[len(m.BestSubmissionVigilanteAddressList)-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 *TransactionInfoResponse) 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: TransactionInfoResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: TransactionInfoResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Index", wireType) + } + m.Index = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Index |= uint32(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Hash", 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.Hash = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Transaction", 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.Transaction = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Proof", 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.Proof = 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 *CheckpointAddressesResponse) 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: CheckpointAddressesResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: CheckpointAddressesResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Submitter", 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.Submitter = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Reporter", 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.Reporter = 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 *SubmissionKeyResponse) 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: SubmissionKeyResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: SubmissionKeyResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field FirstTxBlockHash", 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.FirstTxBlockHash = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field FirstTxIndex", wireType) + } + m.FirstTxIndex = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.FirstTxIndex |= uint32(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field SecondTxBlockHash", 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.SecondTxBlockHash = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 4: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field SecondTxIndex", wireType) + } + m.SecondTxIndex = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.SecondTxIndex |= uint32(b&0x7F) << shift + if b < 0x80 { + break + } + } default: iNdEx = preIndex skippy, err := skipQuery(dAtA[iNdEx:]) diff --git a/x/btccheckpoint/types/query.pb.gw.go b/x/btccheckpoint/types/query.pb.gw.go index 87a078f9e..c2092a04a 100644 --- a/x/btccheckpoint/types/query.pb.gw.go +++ b/x/btccheckpoint/types/query.pb.gw.go @@ -141,10 +141,6 @@ func local_request_Query_BtcCheckpointsInfo_0(ctx context.Context, marshaler run } -var ( - filter_Query_EpochSubmissions_0 = &utilities.DoubleArray{Encoding: map[string]int{"epoch_num": 0}, Base: []int{1, 1, 0}, Check: []int{0, 1, 2}} -) - func request_Query_EpochSubmissions_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { var protoReq QueryEpochSubmissionsRequest var metadata runtime.ServerMetadata @@ -167,13 +163,6 @@ func request_Query_EpochSubmissions_0(ctx context.Context, marshaler runtime.Mar return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "epoch_num", 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_EpochSubmissions_0); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - msg, err := client.EpochSubmissions(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) return msg, metadata, err @@ -201,13 +190,6 @@ func local_request_Query_EpochSubmissions_0(ctx context.Context, marshaler runti return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "epoch_num", 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_EpochSubmissions_0); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - msg, err := server.EpochSubmissions(ctx, &protoReq) return msg, metadata, err diff --git a/x/btccheckpoint/types/tx.pb.go b/x/btccheckpoint/types/tx.pb.go index f02e60b7d..3e3f75258 100644 --- a/x/btccheckpoint/types/tx.pb.go +++ b/x/btccheckpoint/types/tx.pb.go @@ -229,7 +229,7 @@ func init() { func init() { proto.RegisterFile("babylon/btccheckpoint/v1/tx.proto", fileDescriptor_69a562325f8b35c5) } var fileDescriptor_69a562325f8b35c5 = []byte{ - // 439 bytes of a gzipped FileDescriptorProto + // 441 bytes of a gzipped FileDescriptorProto 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x52, 0x4c, 0x4a, 0x4c, 0xaa, 0xcc, 0xc9, 0xcf, 0xd3, 0x4f, 0x2a, 0x49, 0x4e, 0xce, 0x48, 0x4d, 0xce, 0x2e, 0xc8, 0xcf, 0xcc, 0x2b, 0xd1, 0x2f, 0x33, 0xd4, 0x2f, 0xa9, 0xd0, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0x92, 0x80, @@ -252,12 +252,12 @@ var fileDescriptor_69a562325f8b35c5 = []byte{ 0xcd, 0x69, 0x30, 0x67, 0x1b, 0x7d, 0x67, 0xe4, 0x62, 0xf6, 0x2d, 0x4e, 0x17, 0xaa, 0xe6, 0x12, 0xc4, 0x0c, 0x60, 0x3d, 0xdc, 0xf6, 0x62, 0x0b, 0x0b, 0x29, 0x33, 0xd2, 0xd4, 0xc3, 0x1c, 0x21, 0x94, 0xc3, 0xc5, 0x83, 0x12, 0x6e, 0x9a, 0x78, 0xcd, 0x41, 0x56, 0x2a, 0x65, 0x48, 0xb4, 0x52, - 0x98, 0x6d, 0x52, 0xac, 0x0d, 0xcf, 0x37, 0x68, 0x31, 0x3a, 0xf9, 0x9f, 0x78, 0x24, 0xc7, 0x78, + 0x98, 0x6d, 0x52, 0xac, 0x0d, 0xcf, 0x37, 0x68, 0x31, 0x3a, 0x05, 0x9e, 0x78, 0x24, 0xc7, 0x78, 0xe1, 0x91, 0x1c, 0xe3, 0x83, 0x47, 0x72, 0x8c, 0x13, 0x1e, 0xcb, 0x31, 0x5c, 0x78, 0x2c, 0xc7, - 0x70, 0xe3, 0xb1, 0x1c, 0x43, 0x94, 0x69, 0x7a, 0x66, 0x49, 0x46, 0x69, 0x92, 0x5e, 0x72, 0x7e, - 0xae, 0x3e, 0xd4, 0xf4, 0xe4, 0x8c, 0xc4, 0xcc, 0x3c, 0x18, 0x47, 0xbf, 0x02, 0x2d, 0x1d, 0x97, - 0x54, 0x16, 0xa4, 0x16, 0x27, 0xb1, 0x81, 0x93, 0xab, 0x31, 0x20, 0x00, 0x00, 0xff, 0xff, 0x00, - 0x2e, 0x80, 0x63, 0x8c, 0x03, 0x00, 0x00, + 0x70, 0xe3, 0xb1, 0x1c, 0x43, 0x94, 0x79, 0x7a, 0x66, 0x49, 0x46, 0x69, 0x92, 0x5e, 0x72, 0x7e, + 0xae, 0x3e, 0xd4, 0xf4, 0x9c, 0xc4, 0xa4, 0x62, 0xdd, 0xcc, 0x7c, 0x18, 0x57, 0xbf, 0x02, 0x2d, + 0x25, 0x97, 0x54, 0x16, 0xa4, 0x16, 0x27, 0xb1, 0x81, 0x13, 0xac, 0x31, 0x20, 0x00, 0x00, 0xff, + 0xff, 0x7e, 0xe3, 0x2b, 0xd2, 0x8e, 0x03, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. diff --git a/x/btccheckpoint/types/types.go b/x/btccheckpoint/types/types.go index e825908de..e70846158 100644 --- a/x/btccheckpoint/types/types.go +++ b/x/btccheckpoint/types/types.go @@ -5,8 +5,8 @@ import ( "fmt" "math/big" - "github.com/babylonchain/babylon/btctxformatter" - "github.com/babylonchain/babylon/types" + "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" ) @@ -23,7 +23,7 @@ type RawCheckpointSubmission struct { CheckpointData btctxformatter.RawBtcCheckpoint } -// SubmissionBtcInfo encapsualte important information about submission posistion +// SubmissionBtcInfo encapsulate important information about submission position // on btc ledger type SubmissionBtcInfo struct { SubmissionKey SubmissionKey @@ -133,7 +133,7 @@ func (submission *SubmissionBtcInfo) HappenedAfter(parentEpochSubmission *Submis } // SubmissionDepth return depth of the submission. Due to the fact that submissions -// are splitted between several btc blocks, in Babylon subbmission depth is the depth +// are split between several btc blocks, in Babylon submission depth is the depth // of the youngest btc block func (submission *SubmissionBtcInfo) SubmissionDepth() uint64 { return submission.YoungestBlockDepth diff --git a/x/btclightclient/README.md b/x/btclightclient/README.md index 65609d6f1..7b7134b97 100644 --- a/x/btclightclient/README.md +++ b/x/btclightclient/README.md @@ -115,10 +115,10 @@ which contains the BTC header along with some metadata. message BTCHeaderInfo { bytes header = 1 [ (gogoproto.customtype) = - "github.com/babylonchain/babylon/types.BTCHeaderBytes" ]; + "github.com/babylonlabs-io/babylon/types.BTCHeaderBytes" ]; bytes hash = 2 [ (gogoproto.customtype) = - "github.com/babylonchain/babylon/types.BTCHeaderHashBytes" ]; + "github.com/babylonlabs-io/babylon/types.BTCHeaderHashBytes" ]; uint64 height = 3; bytes work = 4 [ (gogoproto.customtype) = "cosmossdk.io/math.Uint" ]; @@ -153,7 +153,7 @@ message MsgInsertHeaders { string signer = 1; repeated bytes headers = 2 [ (gogoproto.customtype) = - "github.com/babylonchain/babylon/types.BTCHeaderBytes" ]; + "github.com/babylonlabs-io/babylon/types.BTCHeaderBytes" ]; } ``` diff --git a/x/btclightclient/client/cli/query.go b/x/btclightclient/client/cli/query.go index 17faccb2b..fa956d287 100644 --- a/x/btclightclient/client/cli/query.go +++ b/x/btclightclient/client/cli/query.go @@ -4,7 +4,7 @@ import ( "context" "fmt" - "github.com/babylonchain/babylon/x/btclightclient/types" + "github.com/babylonlabs-io/babylon/x/btclightclient/types" "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/client/flags" "github.com/spf13/cobra" diff --git a/x/btclightclient/client/cli/tx.go b/x/btclightclient/client/cli/tx.go index bcf27f541..d2e20d367 100644 --- a/x/btclightclient/client/cli/tx.go +++ b/x/btclightclient/client/cli/tx.go @@ -3,7 +3,7 @@ package cli import ( "fmt" - "github.com/babylonchain/babylon/x/btclightclient/types" + "github.com/babylonlabs-io/babylon/x/btclightclient/types" "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/client/flags" "github.com/cosmos/cosmos-sdk/client/tx" diff --git a/x/btclightclient/genesis.go b/x/btclightclient/genesis.go index d19d9dfee..a87edd838 100644 --- a/x/btclightclient/genesis.go +++ b/x/btclightclient/genesis.go @@ -3,33 +3,28 @@ package btclightclient import ( "context" - "github.com/babylonchain/babylon/x/btclightclient/keeper" - "github.com/babylonchain/babylon/x/btclightclient/types" + "github.com/babylonlabs-io/babylon/x/btclightclient/keeper" + "github.com/babylonlabs-io/babylon/x/btclightclient/types" ) // InitGenesis initializes the capability module's state from a provided genesis // state. -func InitGenesis(ctx context.Context, k keeper.Keeper, genState types.GenesisState) { - if err := genState.Validate(); err != nil { +func InitGenesis(ctx context.Context, k keeper.Keeper, gs types.GenesisState) { + if err := gs.Validate(); err != nil { panic(err) } - k.SetBaseBTCHeader(ctx, genState.BaseBtcHeader) - if err := k.SetParams(ctx, genState.Params); err != nil { + if err := k.SetParams(ctx, gs.Params); err != nil { panic(err) } + + k.InsertHeaderInfos(ctx, gs.BtcHeaders) } // ExportGenesis returns the capability module's exported genesis. func ExportGenesis(ctx context.Context, k keeper.Keeper) *types.GenesisState { - genesis := types.DefaultGenesis() - baseBTCHeader := k.GetBaseBTCHeader(ctx) - if baseBTCHeader == nil { - panic("A base BTC Header has not been set") + return &types.GenesisState{ + Params: k.GetParams(ctx), + BtcHeaders: k.GetMainChainFrom(ctx, 0), } - - genesis.BaseBtcHeader = *baseBTCHeader - genesis.Params = k.GetParams(ctx) - - return genesis } diff --git a/x/btclightclient/genesis_test.go b/x/btclightclient/genesis_test.go index 3f9ca2a2f..98ffd13a4 100644 --- a/x/btclightclient/genesis_test.go +++ b/x/btclightclient/genesis_test.go @@ -1,19 +1,27 @@ package btclightclient_test import ( + "math/rand" "testing" + "time" - keepertest "github.com/babylonchain/babylon/testutil/keeper" - "github.com/babylonchain/babylon/testutil/nullify" - "github.com/babylonchain/babylon/x/btclightclient" - "github.com/babylonchain/babylon/x/btclightclient/types" + "github.com/babylonlabs-io/babylon/testutil/datagen" + thelper "github.com/babylonlabs-io/babylon/testutil/helper" + keepertest "github.com/babylonlabs-io/babylon/testutil/keeper" + "github.com/babylonlabs-io/babylon/testutil/nullify" + "github.com/babylonlabs-io/babylon/x/btclightclient" + "github.com/babylonlabs-io/babylon/x/btclightclient/keeper" + "github.com/babylonlabs-io/babylon/x/btclightclient/types" + "github.com/cometbft/cometbft/crypto/secp256k1" "github.com/stretchr/testify/require" + + sdk "github.com/cosmos/cosmos-sdk/types" ) func TestGenesis(t *testing.T) { baseHeaderInfo := types.SimnetGenesisBlock() genesisState := types.GenesisState{ - BaseBtcHeader: baseHeaderInfo, + BtcHeaders: []*types.BTCHeaderInfo{&baseHeaderInfo}, } k, ctx := keepertest.BTCLightClientKeeper(t) @@ -24,3 +32,67 @@ func TestGenesis(t *testing.T) { nullify.Fill(&genesisState) nullify.Fill(got) } + +func TestImportExport(t *testing.T) { + r := rand.New(rand.NewSource(time.Now().UnixNano())) + sender1 := secp256k1.GenPrivKey() + address1, err := sdk.AccAddressFromHexUnsafe(sender1.PubKey().Address().String()) + require.NoError(t, err) + sender2 := secp256k1.GenPrivKey() + address2, err := sdk.AccAddressFromHexUnsafe(sender2.PubKey().Address().String()) + require.NoError(t, err) + + params := types.NewParams( + // only sender1 and sender2 are allowed to update + []string{address1.String(), address2.String()}, + ) + + k, ctx, stServ := keepertest.BTCLightClientKeeperWithCustomParams(t, params) + srv := keeper.NewMsgServerImpl(*k) + + _, chain := datagen.GenRandBtcChainInsertingInKeeper(t, r, k, ctx, 0, 10) + initTip := chain.GetTipInfo() + + chainExtension := datagen.GenRandomValidChainStartingFrom( + r, + initTip.Height, + initTip.Header.ToBlockHeader(), + nil, + 10, + ) + + // sender 1 is allowed to update, it should succeed + msg := &types.MsgInsertHeaders{Signer: address1.String(), Headers: keepertest.NewBTCHeaderBytesList(chainExtension)} + _, err = srv.InsertHeaders(ctx, msg) + require.NoError(t, err) + + newTip := k.GetTipInfo(ctx) + require.NotNil(t, newTip) + + newChainExt := datagen.GenRandomValidChainStartingFrom( + r, + newTip.Height, + newTip.Header.ToBlockHeader(), + nil, + 10, + ) + + msg1 := &types.MsgInsertHeaders{Signer: address2.String(), Headers: keepertest.NewBTCHeaderBytesList(newChainExt)} + _, err = srv.InsertHeaders(ctx, msg1) + require.NoError(t, err) + + genState := btclightclient.ExportGenesis(ctx, *k) + KvA := stServ.OpenKVStore(ctx) + + kB, ctxb, stServB := keepertest.BTCLightClientKeeperWithCustomParams(t, params) + btclightclient.InitGenesis(ctxb, *kB, *genState) + + infos := kB.GetMainChainFrom(ctxb, 0) + require.Equal(t, len(infos), len(genState.BtcHeaders), "it should have the same amount of headers from before") + + KvB := stServB.OpenKVStore(ctxb) + + 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.") +} diff --git a/x/btclightclient/keeper/base_btc_header.go b/x/btclightclient/keeper/base_btc_header.go index 6c860a512..b1d98710c 100644 --- a/x/btclightclient/keeper/base_btc_header.go +++ b/x/btclightclient/keeper/base_btc_header.go @@ -2,7 +2,7 @@ package keeper import ( "context" - "github.com/babylonchain/babylon/x/btclightclient/types" + "github.com/babylonlabs-io/babylon/x/btclightclient/types" ) func (k Keeper) GetBaseBTCHeader(ctx context.Context) *types.BTCHeaderInfo { diff --git a/x/btclightclient/keeper/base_btc_header_test.go b/x/btclightclient/keeper/base_btc_header_test.go index 8fa2eca7f..b6e94f81b 100644 --- a/x/btclightclient/keeper/base_btc_header_test.go +++ b/x/btclightclient/keeper/base_btc_header_test.go @@ -1,8 +1,8 @@ package keeper_test import ( - "github.com/babylonchain/babylon/testutil/datagen" - "github.com/babylonchain/babylon/testutil/keeper" + "github.com/babylonlabs-io/babylon/testutil/datagen" + "github.com/babylonlabs-io/babylon/testutil/keeper" "math/rand" "testing" ) diff --git a/x/btclightclient/keeper/grpc_query.go b/x/btclightclient/keeper/grpc_query.go index c3230435e..91d3792e8 100644 --- a/x/btclightclient/keeper/grpc_query.go +++ b/x/btclightclient/keeper/grpc_query.go @@ -3,8 +3,8 @@ package keeper import ( "context" - bbn "github.com/babylonchain/babylon/types" - "github.com/babylonchain/babylon/x/btclightclient/types" + bbn "github.com/babylonlabs-io/babylon/types" + "github.com/babylonlabs-io/babylon/x/btclightclient/types" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/query" "google.golang.org/grpc/codes" @@ -77,13 +77,12 @@ func (k Keeper) ContainsBytes(ctx context.Context, req *types.QueryContainsBytes return &types.QueryContainsBytesResponse{Contains: contains}, nil } -func (k Keeper) MainChain(ctx context.Context, req *types.QueryMainChainRequest) (*types.QueryMainChainResponse, error) { +func (k Keeper) MainChain(c context.Context, req *types.QueryMainChainRequest) (*types.QueryMainChainResponse, error) { if req == nil { return nil, status.Error(codes.InvalidArgument, "invalid request") } - sdkCtx := sdk.UnwrapSDKContext(ctx) - + ctx := sdk.UnwrapSDKContext(c) if req.Pagination == nil { req.Pagination = &query.PageRequest{} } @@ -98,7 +97,7 @@ func (k Keeper) MainChain(ctx context.Context, req *types.QueryMainChainRequest) if err != nil { return nil, status.Error(codes.InvalidArgument, "key does not correspond to a header hash") } - keyHeader, err = k.headersState(sdkCtx).GetHeaderByHash(&headerHash) + keyHeader, err = k.headersState(ctx).GetHeaderByHash(&headerHash) if err != nil { return nil, status.Error(codes.InvalidArgument, "header specified by key does not exist") } @@ -108,10 +107,10 @@ func (k Keeper) MainChain(ctx context.Context, req *types.QueryMainChainRequest) var nextKey []byte if req.Pagination.Reverse { var start, end uint64 - baseHeader := k.headersState(sdkCtx).BaseHeader() + baseHeader := k.headersState(ctx).BaseHeader() // The base header is located at the end of the mainchain // which requires starting at the end - mainchain := k.GetMainChainFrom(sdkCtx, 0) + mainchain := k.GetMainChainFrom(ctx, 0) if keyHeader == nil { keyHeader = baseHeader @@ -135,7 +134,7 @@ func (k Keeper) MainChain(ctx context.Context, req *types.QueryMainChainRequest) nextKey = mainchain[end].Hash.MustMarshal() } } else { - tip := k.headersState(sdkCtx).GetTip() + tip := k.headersState(ctx).GetTip() // If there is no starting key, then the starting header is the tip if keyHeader == nil { keyHeader = tip @@ -146,7 +145,7 @@ func (k Keeper) MainChain(ctx context.Context, req *types.QueryMainChainRequest) // -1 because the depth denotes how many headers have been built on top of it depth := startHeaderDepth + req.Pagination.Limit - 1 // Retrieve the mainchain up to the depth - mainchain := k.GetMainChainUpTo(sdkCtx, 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) { return nil, status.Error(codes.InvalidArgument, "header specified by key is not a part of the mainchain") @@ -161,19 +160,17 @@ func (k Keeper) MainChain(ctx context.Context, req *types.QueryMainChainRequest) NextKey: nextKey, } // The headers that we should return start from the depth of the start header - return &types.QueryMainChainResponse{Headers: headers, Pagination: pageRes}, nil + return &types.QueryMainChainResponse{Headers: types.ParseBTCHeadersToResponse(headers), Pagination: pageRes}, nil } -func (k Keeper) Tip(ctx context.Context, req *types.QueryTipRequest) (*types.QueryTipResponse, error) { +func (k Keeper) Tip(c context.Context, req *types.QueryTipRequest) (*types.QueryTipResponse, error) { if req == nil { return nil, status.Error(codes.InvalidArgument, "invalid request") } - sdkCtx := sdk.UnwrapSDKContext(ctx) - - tip := k.headersState(sdkCtx).GetTip() - - return &types.QueryTipResponse{Header: tip}, nil + ctx := sdk.UnwrapSDKContext(c) + tip := k.headersState(ctx).GetTip() + return &types.QueryTipResponse{Header: tip.ToResponse()}, nil } func (k Keeper) BaseHeader(ctx context.Context, req *types.QueryBaseHeaderRequest) (*types.QueryBaseHeaderResponse, error) { @@ -185,7 +182,7 @@ func (k Keeper) BaseHeader(ctx context.Context, req *types.QueryBaseHeaderReques baseHeader := k.headersState(sdkCtx).BaseHeader() - return &types.QueryBaseHeaderResponse{Header: baseHeader}, nil + return &types.QueryBaseHeaderResponse{Header: baseHeader.ToResponse()}, nil } func (k Keeper) HeaderDepth(ctx context.Context, req *types.QueryHeaderDepthRequest) (*types.QueryHeaderDepthResponse, error) { diff --git a/x/btclightclient/keeper/grpc_query_test.go b/x/btclightclient/keeper/grpc_query_test.go index c5ea9e5f4..6a6fed783 100644 --- a/x/btclightclient/keeper/grpc_query_test.go +++ b/x/btclightclient/keeper/grpc_query_test.go @@ -4,12 +4,12 @@ import ( "math/rand" "testing" - "github.com/babylonchain/babylon/testutil/datagen" - bbn "github.com/babylonchain/babylon/types" + "github.com/babylonlabs-io/babylon/testutil/datagen" + bbn "github.com/babylonlabs-io/babylon/types" "github.com/cosmos/cosmos-sdk/types/query" - testkeeper "github.com/babylonchain/babylon/testutil/keeper" - "github.com/babylonchain/babylon/x/btclightclient/types" + keepertest "github.com/babylonlabs-io/babylon/testutil/keeper" + "github.com/babylonlabs-io/babylon/x/btclightclient/types" ) func FuzzHashesQuery(f *testing.F) { @@ -34,7 +34,7 @@ func FuzzHashesQuery(f *testing.F) { datagen.AddRandomSeedsToFuzzer(f, 10) f.Fuzz(func(t *testing.T, seed int64) { r := rand.New(rand.NewSource(seed)) - blcKeeper, ctx := testkeeper.BTCLightClientKeeper(t) + blcKeeper, ctx := keepertest.BTCLightClientKeeper(t) // Test nil request resp, err := blcKeeper.Hashes(ctx, nil) @@ -59,7 +59,7 @@ func FuzzHashesQuery(f *testing.F) { t.Errorf("Invalid key led to a nil error") } - baseHeader, chain := genRandomChain( + baseHeader, chain := datagen.GenRandBtcChainInsertingInKeeper( t, r, blcKeeper, @@ -133,7 +133,7 @@ func FuzzContainsQuery(f *testing.F) { datagen.AddRandomSeedsToFuzzer(f, 10) f.Fuzz(func(t *testing.T, seed int64) { r := rand.New(rand.NewSource(seed)) - blcKeeper, ctx := testkeeper.BTCLightClientKeeper(t) + blcKeeper, ctx := keepertest.BTCLightClientKeeper(t) // Test nil input resp, err := blcKeeper.Contains(ctx, nil) @@ -145,7 +145,7 @@ func FuzzContainsQuery(f *testing.F) { } // Generate a random chain of headers and insert it into storage - _, chain := genRandomChain( + _, chain := datagen.GenRandBtcChainInsertingInKeeper( t, r, blcKeeper, @@ -200,7 +200,7 @@ func FuzzMainChainQuery(f *testing.F) { datagen.AddRandomSeedsToFuzzer(f, 10) f.Fuzz(func(t *testing.T, seed int64) { r := rand.New(rand.NewSource(seed)) - blcKeeper, ctx := testkeeper.BTCLightClientKeeper(t) + blcKeeper, ctx := keepertest.BTCLightClientKeeper(t) // Test nil input resp, err := blcKeeper.MainChain(ctx, nil) @@ -226,7 +226,7 @@ func FuzzMainChainQuery(f *testing.F) { } // Generate a random chain of headers and insert it into storage - base, chain := genRandomChain( + base, chain := datagen.GenRandBtcChainInsertingInKeeper( t, r, blcKeeper, @@ -300,7 +300,7 @@ func FuzzMainChainQuery(f *testing.F) { } if !resp.Headers[i].Eq(mainchain[idx]) { t.Errorf("%t", reverse) - t.Errorf("Response does not match mainchain. Expected %s got %s", mainchain[idx].Hash, resp.Headers[i].Hash) + t.Errorf("Response does not match mainchain. Expected %s got %s", mainchain[idx].Hash, resp.Headers[i].HashHex) } mcIdx += 1 } @@ -327,7 +327,7 @@ func FuzzTipQuery(f *testing.F) { datagen.AddRandomSeedsToFuzzer(f, 10) f.Fuzz(func(t *testing.T, seed int64) { r := rand.New(rand.NewSource(seed)) - blcKeeper, ctx := testkeeper.BTCLightClientKeeper(t) + blcKeeper, ctx := keepertest.BTCLightClientKeeper(t) // Test nil input resp, err := blcKeeper.Tip(ctx, nil) @@ -339,7 +339,7 @@ func FuzzTipQuery(f *testing.F) { } // Generate a random chain of headers and insert it into storage - _, chain := genRandomChain( + _, chain := datagen.GenRandBtcChainInsertingInKeeper( t, r, blcKeeper, @@ -356,7 +356,7 @@ func FuzzTipQuery(f *testing.F) { t.Fatalf("Valid input led to nil response") } if !resp.Header.Eq(chain.GetTipInfo()) { - t.Errorf("Invalid header returned. Expected %s, got %s", chain.GetTipInfo().Hash, resp.Header.Hash) + t.Errorf("Invalid header returned. Expected %s, got %s", chain.GetTipInfo().Hash, resp.Header.HeaderHex) } }) } @@ -373,7 +373,7 @@ func FuzzBaseHeaderQuery(f *testing.F) { datagen.AddRandomSeedsToFuzzer(f, 10) f.Fuzz(func(t *testing.T, seed int64) { r := rand.New(rand.NewSource(seed)) - blcKeeper, ctx := testkeeper.BTCLightClientKeeper(t) + blcKeeper, ctx := keepertest.BTCLightClientKeeper(t) // Test nil input resp, err := blcKeeper.BaseHeader(ctx, nil) @@ -385,7 +385,7 @@ func FuzzBaseHeaderQuery(f *testing.F) { } // Generate a random chain of headers and insert it into storage - base, _ := genRandomChain( + base, _ := datagen.GenRandBtcChainInsertingInKeeper( t, r, blcKeeper, @@ -402,7 +402,7 @@ func FuzzBaseHeaderQuery(f *testing.F) { t.Fatalf("Valid input led to nil response") } if !resp.Header.Eq(base) { - t.Errorf("Invalid header returned. Expected %s, got %s", base.Hash, resp.Header.Hash) + t.Errorf("Invalid header returned. Expected %s, got %s", base.Hash, resp.Header.HashHex) } }) } diff --git a/x/btclightclient/keeper/hooks.go b/x/btclightclient/keeper/hooks.go index 17ff31d24..076b15da0 100644 --- a/x/btclightclient/keeper/hooks.go +++ b/x/btclightclient/keeper/hooks.go @@ -2,7 +2,7 @@ package keeper import ( "context" - "github.com/babylonchain/babylon/x/btclightclient/types" + "github.com/babylonlabs-io/babylon/x/btclightclient/types" ) // Implements BTCLightClientHooks interface diff --git a/x/btclightclient/keeper/keeper.go b/x/btclightclient/keeper/keeper.go index 78e370c6c..64b7508ba 100644 --- a/x/btclightclient/keeper/keeper.go +++ b/x/btclightclient/keeper/keeper.go @@ -5,15 +5,16 @@ import ( "fmt" corestoretypes "cosmossdk.io/core/store" - "cosmossdk.io/log" - bbn "github.com/babylonchain/babylon/types" + + bbn "github.com/babylonlabs-io/babylon/types" "github.com/btcsuite/btcd/chaincfg" "github.com/btcsuite/btcd/wire" - "github.com/babylonchain/babylon/x/btclightclient/types" + "github.com/babylonlabs-io/babylon/x/btclightclient/types" "github.com/cosmos/cosmos-sdk/codec" sdk "github.com/cosmos/cosmos-sdk/types" + proto "github.com/cosmos/gogoproto/proto" ) type ( @@ -47,10 +48,23 @@ func NewKeeper( } } -func (k Keeper) Logger(ctx sdk.Context) log.Logger { +// Logger returns the logger with the key value of the current module. +func (Keeper) Logger(ctx sdk.Context) log.Logger { return ctx.Logger().With("module", fmt.Sprintf("x/%s", types.ModuleName)) } +// emitTypedEventWithLog emits an event and logs if it errors. +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", + "type", evt.String(), + "reason", err.Error(), + ) + } +} + // SetHooks sets the btclightclient hooks func (k *Keeper) SetHooks(bh types.BTCLightClientHooks) *Keeper { if k.hooks != nil { @@ -94,6 +108,14 @@ func (k Keeper) insertHeaders( return nil } +// InsertHeaderInfos inserts multiple headers info at the store. +func (k Keeper) InsertHeaderInfos(ctx context.Context, infos []*types.BTCHeaderInfo) { + hs := k.headersState(ctx) + for _, inf := range infos { + hs.insertHeader(inf) + } +} + func (k Keeper) InsertHeaders(ctx context.Context, headers []bbn.BTCHeaderBytes) error { if len(headers) == 0 { return types.ErrEmptyMessage diff --git a/x/btclightclient/keeper/keeper_test.go b/x/btclightclient/keeper/keeper_test.go index df9d6bb53..90ddeaa96 100644 --- a/x/btclightclient/keeper/keeper_test.go +++ b/x/btclightclient/keeper/keeper_test.go @@ -6,12 +6,12 @@ import ( "testing" sdkmath "cosmossdk.io/math" - bbn "github.com/babylonchain/babylon/types" - "github.com/babylonchain/babylon/x/btclightclient/types" + bbn "github.com/babylonlabs-io/babylon/types" + "github.com/babylonlabs-io/babylon/x/btclightclient/types" "github.com/btcsuite/btcd/chaincfg" - "github.com/babylonchain/babylon/testutil/datagen" - testkeeper "github.com/babylonchain/babylon/testutil/keeper" + "github.com/babylonlabs-io/babylon/testutil/datagen" + keepertest "github.com/babylonlabs-io/babylon/testutil/keeper" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/stretchr/testify/require" ) @@ -32,7 +32,7 @@ func FuzzKeeperMainChainDepth(f *testing.F) { datagen.AddRandomSeedsToFuzzer(f, 10) f.Fuzz(func(t *testing.T, seed int64) { r := rand.New(rand.NewSource(seed)) - blcKeeper, ctx := testkeeper.BTCLightClientKeeper(t) + blcKeeper, ctx := keepertest.BTCLightClientKeeper(t) // Test nil input depth, err := blcKeeper.MainChainDepth(ctx, nil) @@ -53,7 +53,7 @@ func FuzzKeeperMainChainDepth(f *testing.F) { t.Errorf("Non existing header led to a result that is not -1") } - _, chain := genRandomChain( + _, chain := datagen.GenRandBtcChainInsertingInKeeper( t, r, blcKeeper, @@ -85,7 +85,7 @@ func FuzzKeeperBlockHeight(f *testing.F) { datagen.AddRandomSeedsToFuzzer(f, 10) f.Fuzz(func(t *testing.T, seed int64) { r := rand.New(rand.NewSource(seed)) - blcKeeper, ctx := testkeeper.BTCLightClientKeeper(t) + blcKeeper, ctx := keepertest.BTCLightClientKeeper(t) // Test nil input height, err := blcKeeper.BlockHeight(ctx, nil) @@ -106,7 +106,7 @@ func FuzzKeeperBlockHeight(f *testing.F) { t.Errorf("Non existing header led to a result that is not -1") } - _, chain := genRandomChain( + _, chain := datagen.GenRandBtcChainInsertingInKeeper( t, r, blcKeeper, @@ -130,9 +130,9 @@ func FuzzKeeperInsertValidChainExtension(f *testing.F) { datagen.AddRandomSeedsToFuzzer(f, 10) f.Fuzz(func(t *testing.T, seed int64) { r := rand.New(rand.NewSource(seed)) - blcKeeper, ctx := testkeeper.BTCLightClientKeeper(t) + blcKeeper, ctx := keepertest.BTCLightClientKeeper(t) - _, chain := genRandomChain( + _, chain := datagen.GenRandBtcChainInsertingInKeeper( t, r, blcKeeper, @@ -160,7 +160,7 @@ func FuzzKeeperInsertValidChainExtension(f *testing.F) { extendedChainWork := oldTip.Work.Add(*chainExtensionWork) extendedChainHeight := uint64(uint32(oldTip.Height) + newChainLength) - err := blcKeeper.InsertHeaders(ctx, chainToChainBytes(chainToInsert)) + err := blcKeeper.InsertHeaders(ctx, keepertest.NewBTCHeaderBytesList(chainToInsert)) require.NoError(t, err) // updated tip @@ -213,8 +213,8 @@ func FuzzKeeperInsertValidBetterChain(f *testing.F) { datagen.AddRandomSeedsToFuzzer(f, 10) f.Fuzz(func(t *testing.T, seed int64) { r := rand.New(rand.NewSource(seed)) - blcKeeper, ctx := testkeeper.BTCLightClientKeeper(t) - _, chain := genRandomChain( + blcKeeper, ctx := keepertest.BTCLightClientKeeper(t) + _, chain := datagen.GenRandBtcChainInsertingInKeeper( t, r, blcKeeper, @@ -247,7 +247,7 @@ func FuzzKeeperInsertValidBetterChain(f *testing.F) { require.True(t, len(removedBranch) > 0) - err := blcKeeper.InsertHeaders(ctx, chainToChainBytes(chainToInsert)) + err := blcKeeper.InsertHeaders(ctx, keepertest.NewBTCHeaderBytesList(chainToInsert)) require.NoError(t, err) // updated tip @@ -319,8 +319,8 @@ func FuzzKeeperInsertInvalidChain(f *testing.F) { datagen.AddRandomSeedsToFuzzer(f, 10) f.Fuzz(func(t *testing.T, seed int64) { r := rand.New(rand.NewSource(seed)) - blcKeeper, ctx := testkeeper.BTCLightClientKeeper(t) - _, _ = genRandomChain( + blcKeeper, ctx := keepertest.BTCLightClientKeeper(t) + _, _ = datagen.GenRandBtcChainInsertingInKeeper( t, r, blcKeeper, @@ -358,7 +358,7 @@ func FuzzKeeperInsertInvalidChain(f *testing.F) { // bump the nonce, it should fail validation and tip should not change chainToInsert[3].Nonce = chainToInsert[3].Nonce + 1 - errInvalidHeader := blcKeeper.InsertHeaders(ctx, chainToChainBytes(chainToInsert)) + errInvalidHeader := blcKeeper.InsertHeaders(ctx, keepertest.NewBTCHeaderBytesList(chainToInsert)) require.Error(t, errInvalidHeader) newTip := blcKeeper.GetTipInfo(ctx) // tip did not change @@ -374,7 +374,7 @@ func FuzzKeeperInsertInvalidChain(f *testing.F) { nil, 1, ) - errWorseChain := blcKeeper.InsertHeaders(ctx, chainToChainBytes(worseChain)) + errWorseChain := blcKeeper.InsertHeaders(ctx, keepertest.NewBTCHeaderBytesList(worseChain)) require.Error(t, errWorseChain) require.True(t, errors.Is(errWorseChain, types.ErrChainWithNotEnoughWork)) }) @@ -386,7 +386,7 @@ func FuzzKeeperValdateHeaderAtDifficultyAdjustmentBoundaries(f *testing.F) { f.Fuzz(func(t *testing.T, seed int64) { r := rand.New(rand.NewSource(seed)) numBlockPerRetarget := types.BlocksPerRetarget(&chaincfg.SimNetParams) - blcKeeper, ctx := testkeeper.BTCLightClientKeeper(t) + blcKeeper, ctx := keepertest.BTCLightClientKeeper(t) genesisHeader := bbn.NewBTCHeaderBytesFromBlockHeader(&chaincfg.SimNetParams.GenesisBlock.Header) genesisHash := bbn.NewBTCHeaderHashBytesFromChainhash(chaincfg.SimNetParams.GenesisHash) @@ -413,7 +413,7 @@ func FuzzKeeperValdateHeaderAtDifficultyAdjustmentBoundaries(f *testing.F) { require.Error(t, err) randomChainWithoutLastHeader := randomChain.Headers[:len(randomChain.Headers)-1] - chain := chainToChainBytes(randomChainWithoutLastHeader) + chain := keepertest.NewBTCHeaderBytesList(randomChainWithoutLastHeader) // now all headers are valid, and we are below adjustment boundary err = blcKeeper.InsertHeaders(ctx, chain) require.NoError(t, err) diff --git a/x/btclightclient/keeper/msg_server.go b/x/btclightclient/keeper/msg_server.go index cd8fff632..90de17942 100644 --- a/x/btclightclient/keeper/msg_server.go +++ b/x/btclightclient/keeper/msg_server.go @@ -4,7 +4,7 @@ import ( "context" errorsmod "cosmossdk.io/errors" - "github.com/babylonchain/babylon/x/btclightclient/types" + "github.com/babylonlabs-io/babylon/x/btclightclient/types" sdk "github.com/cosmos/cosmos-sdk/types" govtypes "github.com/cosmos/cosmos-sdk/x/gov/types" ) diff --git a/x/btclightclient/keeper/msg_server_test.go b/x/btclightclient/keeper/msg_server_test.go index a3dacb251..343b6859a 100644 --- a/x/btclightclient/keeper/msg_server_test.go +++ b/x/btclightclient/keeper/msg_server_test.go @@ -6,12 +6,12 @@ import ( "testing" "time" - "github.com/babylonchain/babylon/testutil/datagen" + "github.com/babylonlabs-io/babylon/testutil/datagen" "github.com/stretchr/testify/require" - keepertest "github.com/babylonchain/babylon/testutil/keeper" - "github.com/babylonchain/babylon/x/btclightclient/keeper" - "github.com/babylonchain/babylon/x/btclightclient/types" + keepertest "github.com/babylonlabs-io/babylon/testutil/keeper" + "github.com/babylonlabs-io/babylon/x/btclightclient/keeper" + "github.com/babylonlabs-io/babylon/x/btclightclient/types" "github.com/cosmos/cosmos-sdk/crypto/keys/secp256k1" sdk "github.com/cosmos/cosmos-sdk/types" ) @@ -22,7 +22,7 @@ func setupMsgServer(t testing.TB) (types.MsgServer, *keeper.Keeper, context.Cont } func setupMsgServerWithCustomParams(t testing.TB, p types.Params) (types.MsgServer, *keeper.Keeper, context.Context) { - k, ctx := keepertest.BTCLightClientKeeperWithCustomParams(t, p) + k, ctx, _ := keepertest.BTCLightClientKeeperWithCustomParams(t, p) return keeper.NewMsgServerImpl(*k), k, ctx } @@ -38,7 +38,7 @@ func FuzzMsgServerInsertNewTip(f *testing.F) { r := rand.New(rand.NewSource(seed)) srv, blcKeeper, sdkCtx := setupMsgServer(t) ctx := sdk.UnwrapSDKContext(sdkCtx) - _, chain := genRandomChain( + _, chain := datagen.GenRandBtcChainInsertingInKeeper( t, r, blcKeeper, @@ -67,7 +67,7 @@ func FuzzMsgServerInsertNewTip(f *testing.F) { ) chainExtensionWork := chainWork(chainExtension) - msg := &types.MsgInsertHeaders{Signer: address.String(), Headers: chainToChainBytes(chainExtension)} + msg := &types.MsgInsertHeaders{Signer: address.String(), Headers: keepertest.NewBTCHeaderBytesList(chainExtension)} _, err := srv.InsertHeaders(sdkCtx, msg) require.NoError(t, err) @@ -99,7 +99,7 @@ func FuzzMsgServerReorgChain(f *testing.F) { ctx := sdk.UnwrapSDKContext(sdkCtx) chainLength := datagen.RandomInt(r, 50) + 10 - _, chain := genRandomChain( + _, chain := datagen.GenRandBtcChainInsertingInKeeper( t, r, blcKeeper, @@ -134,7 +134,7 @@ func FuzzMsgServerReorgChain(f *testing.F) { uint32(forkChainLen), ) chainExtensionWork := chainWork(chainExtension) - msg := &types.MsgInsertHeaders{Signer: address.String(), Headers: chainToChainBytes(chainExtension)} + msg := &types.MsgInsertHeaders{Signer: address.String(), Headers: keepertest.NewBTCHeaderBytesList(chainExtension)} _, err := srv.InsertHeaders(sdkCtx, msg) require.NoError(t, err) @@ -173,7 +173,7 @@ func TestAllowUpdatesOnlyFromReportesInTheList(t *testing.T) { srv, blcKeeper, sdkCtx := setupMsgServerWithCustomParams(t, params) ctx := sdk.UnwrapSDKContext(sdkCtx) - _, chain := genRandomChain( + _, chain := datagen.GenRandBtcChainInsertingInKeeper( t, r, blcKeeper, @@ -201,7 +201,7 @@ func TestAllowUpdatesOnlyFromReportesInTheList(t *testing.T) { ) // sender 1 is allowed to update, it should succeed - msg := &types.MsgInsertHeaders{Signer: address1.String(), Headers: chainToChainBytes(chainExtension)} + msg := &types.MsgInsertHeaders{Signer: address1.String(), Headers: keepertest.NewBTCHeaderBytesList(chainExtension)} _, err = srv.InsertHeaders(sdkCtx, msg) require.NoError(t, err) @@ -217,13 +217,13 @@ func TestAllowUpdatesOnlyFromReportesInTheList(t *testing.T) { ) // sender 3 is not allowed to update, it should fail - msg1 := &types.MsgInsertHeaders{Signer: address3.String(), Headers: chainToChainBytes(newChainExt)} + msg1 := &types.MsgInsertHeaders{Signer: address3.String(), Headers: keepertest.NewBTCHeaderBytesList(newChainExt)} _, err = srv.InsertHeaders(sdkCtx, msg1) require.Error(t, err) require.ErrorIs(t, err, types.ErrUnauthorizedReporter) // sender 2 is allowed to update, it should succeed - msg1 = &types.MsgInsertHeaders{Signer: address2.String(), Headers: chainToChainBytes(newChainExt)} + msg1 = &types.MsgInsertHeaders{Signer: address2.String(), Headers: keepertest.NewBTCHeaderBytesList(newChainExt)} _, err = srv.InsertHeaders(sdkCtx, msg1) require.NoError(t, err) } diff --git a/x/btclightclient/keeper/params.go b/x/btclightclient/keeper/params.go index bd68dd5d6..4e2847d13 100644 --- a/x/btclightclient/keeper/params.go +++ b/x/btclightclient/keeper/params.go @@ -3,7 +3,7 @@ package keeper import ( "context" - "github.com/babylonchain/babylon/x/btclightclient/types" + "github.com/babylonlabs-io/babylon/x/btclightclient/types" ) // SetParams sets the x/btclightclient module parameters. diff --git a/x/btclightclient/keeper/params_test.go b/x/btclightclient/keeper/params_test.go index 4dc68b70f..15129bd3a 100644 --- a/x/btclightclient/keeper/params_test.go +++ b/x/btclightclient/keeper/params_test.go @@ -3,8 +3,8 @@ package keeper_test import ( "testing" - testkeeper "github.com/babylonchain/babylon/testutil/keeper" - "github.com/babylonchain/babylon/x/btclightclient/types" + testkeeper "github.com/babylonlabs-io/babylon/testutil/keeper" + "github.com/babylonlabs-io/babylon/x/btclightclient/types" "github.com/stretchr/testify/require" ) diff --git a/x/btclightclient/keeper/state.go b/x/btclightclient/keeper/state.go index 27c869cea..55ddb4e71 100644 --- a/x/btclightclient/keeper/state.go +++ b/x/btclightclient/keeper/state.go @@ -8,8 +8,8 @@ import ( "github.com/cosmos/cosmos-sdk/runtime" "cosmossdk.io/store/prefix" - bbn "github.com/babylonchain/babylon/types" - "github.com/babylonchain/babylon/x/btclightclient/types" + bbn "github.com/babylonlabs-io/babylon/types" + "github.com/babylonlabs-io/babylon/x/btclightclient/types" "github.com/cosmos/cosmos-sdk/codec" sdk "github.com/cosmos/cosmos-sdk/types" ) diff --git a/x/btclightclient/keeper/state_test.go b/x/btclightclient/keeper/state_test.go index 296509e62..10d5e34e8 100644 --- a/x/btclightclient/keeper/state_test.go +++ b/x/btclightclient/keeper/state_test.go @@ -4,11 +4,11 @@ import ( "math/rand" "testing" - bbn "github.com/babylonchain/babylon/types" + bbn "github.com/babylonlabs-io/babylon/types" - "github.com/babylonchain/babylon/testutil/datagen" - testkeeper "github.com/babylonchain/babylon/testutil/keeper" - "github.com/babylonchain/babylon/x/btclightclient/types" + "github.com/babylonlabs-io/babylon/testutil/datagen" + keepertest "github.com/babylonlabs-io/babylon/testutil/keeper" + "github.com/babylonlabs-io/babylon/x/btclightclient/types" "github.com/stretchr/testify/require" ) @@ -28,7 +28,7 @@ func FuzzHeadersStateCreateHeader(f *testing.F) { datagen.AddRandomSeedsToFuzzer(f, 10) f.Fuzz(func(t *testing.T, seed int64) { r := rand.New(rand.NewSource(seed)) - blcKeeper, ctx := testkeeper.BTCLightClientKeeper(t) + blcKeeper, ctx := keepertest.BTCLightClientKeeper(t) state := blcKeeper.HeadersState(ctx) // operations no empty state @@ -62,7 +62,7 @@ func FuzzHeadersStateCreateHeader(f *testing.F) { initchainHeight := datagen.RandomInt(r, 50) + 10 // populate the state with random chain - _, chain := genRandomChain( + _, chain := datagen.GenRandBtcChainInsertingInKeeper( t, r, blcKeeper, diff --git a/x/btclightclient/keeper/triggers.go b/x/btclightclient/keeper/triggers.go index 8b9bdaea1..15f91f0b6 100644 --- a/x/btclightclient/keeper/triggers.go +++ b/x/btclightclient/keeper/triggers.go @@ -2,27 +2,27 @@ package keeper import ( "context" - "github.com/babylonchain/babylon/x/btclightclient/types" - sdk "github.com/cosmos/cosmos-sdk/types" + + "github.com/babylonlabs-io/babylon/x/btclightclient/types" ) func (k Keeper) triggerHeaderInserted(ctx context.Context, headerInfo *types.BTCHeaderInfo) { // Trigger AfterBTCHeaderInserted hook k.AfterBTCHeaderInserted(ctx, headerInfo) // Emit HeaderInserted event - sdk.UnwrapSDKContext(ctx).EventManager().EmitTypedEvent(&types.EventBTCHeaderInserted{Header: headerInfo}) //nolint:errcheck + k.emitTypedEventWithLog(ctx, &types.EventBTCHeaderInserted{Header: headerInfo}) } func (k Keeper) triggerRollBack(ctx context.Context, headerInfo *types.BTCHeaderInfo) { // Trigger AfterBTCRollBack hook k.AfterBTCRollBack(ctx, headerInfo) // Emit BTCRollBack event - sdk.UnwrapSDKContext(ctx).EventManager().EmitTypedEvent(&types.EventBTCRollBack{Header: headerInfo}) //nolint:errcheck + k.emitTypedEventWithLog(ctx, &types.EventBTCRollBack{Header: headerInfo}) } func (k Keeper) triggerRollForward(ctx context.Context, headerInfo *types.BTCHeaderInfo) { // Trigger AfterBTCRollForward hook k.AfterBTCRollForward(ctx, headerInfo) // Emit BTCRollForward event - sdk.UnwrapSDKContext(ctx).EventManager().EmitTypedEvent(&types.EventBTCRollForward{Header: headerInfo}) //nolint:errcheck + k.emitTypedEventWithLog(ctx, &types.EventBTCRollForward{Header: headerInfo}) } diff --git a/x/btclightclient/keeper/utils.go b/x/btclightclient/keeper/utils.go index 55d353cbf..9cc340ab4 100644 --- a/x/btclightclient/keeper/utils.go +++ b/x/btclightclient/keeper/utils.go @@ -1,7 +1,7 @@ package keeper import ( - "github.com/babylonchain/babylon/x/btclightclient/types" + "github.com/babylonlabs-io/babylon/x/btclightclient/types" "github.com/cosmos/cosmos-sdk/codec" ) diff --git a/x/btclightclient/keeper/utils_test.go b/x/btclightclient/keeper/utils_test.go index 413918cc3..cbf1a3421 100644 --- a/x/btclightclient/keeper/utils_test.go +++ b/x/btclightclient/keeper/utils_test.go @@ -3,14 +3,11 @@ package keeper_test import ( "context" "math/big" - "math/rand" "testing" sdkmath "cosmossdk.io/math" - "github.com/babylonchain/babylon/testutil/datagen" - bbn "github.com/babylonchain/babylon/types" - "github.com/babylonchain/babylon/x/btclightclient/keeper" - "github.com/babylonchain/babylon/x/btclightclient/types" + "github.com/babylonlabs-io/babylon/x/btclightclient/keeper" + "github.com/babylonlabs-io/babylon/x/btclightclient/types" "github.com/btcsuite/btcd/blockchain" "github.com/btcsuite/btcd/wire" "github.com/stretchr/testify/require" @@ -54,32 +51,6 @@ func allFieldsEqual(a *types.BTCHeaderInfo, b *types.BTCHeaderInfo) bool { return a.Height == b.Height && a.Hash.Eq(b.Hash) && a.Header.Eq(b.Header) && a.Work.Equal(*b.Work) } -// this function must not be used at difficulty adjustment boundaries, as then -// difficulty adjustment calculation will fail -func genRandomChain( - t *testing.T, - r *rand.Rand, - k *keeper.Keeper, - ctx context.Context, - initialHeight uint64, - chainLength uint64, -) (*types.BTCHeaderInfo, *datagen.BTCHeaderPartialChain) { - genesisHeader := datagen.NewBTCHeaderChainWithLength(r, initialHeight, 0, 1) - genesisHeaderInfo := genesisHeader.GetChainInfo()[0] - k.SetBaseBTCHeader(ctx, *genesisHeaderInfo) - randomChain := datagen.NewBTCHeaderChainFromParentInfo( - r, - genesisHeaderInfo, - uint32(chainLength), - ) - err := k.InsertHeaders(ctx, randomChain.ChainToBytes()) - require.NoError(t, err) - tip := k.GetTipInfo(ctx) - randomChainTipInfo := randomChain.GetTipInfo() - require.True(t, allFieldsEqual(tip, randomChainTipInfo)) - return genesisHeaderInfo, randomChain -} - func checkTip( t *testing.T, ctx context.Context, @@ -107,14 +78,6 @@ func checkTip( require.True(t, currentTip.Header.Hash().ToChainhash().IsEqual(&expectedTipHeaderHash)) } -func chainToChainBytes(chain []*wire.BlockHeader) []bbn.BTCHeaderBytes { - chainBytes := make([]bbn.BTCHeaderBytes, len(chain)) - for i, header := range chain { - chainBytes[i] = bbn.NewBTCHeaderBytesFromBlockHeader(header) - } - return chainBytes -} - func chainWork(chain []*wire.BlockHeader) *sdkmath.Uint { totalWork := sdkmath.NewUint(0) for _, header := range chain { diff --git a/x/btclightclient/module.go b/x/btclightclient/module.go index 6c6982d4a..74957909b 100644 --- a/x/btclightclient/module.go +++ b/x/btclightclient/module.go @@ -12,9 +12,9 @@ import ( abci "github.com/cometbft/cometbft/abci/types" - "github.com/babylonchain/babylon/x/btclightclient/client/cli" - "github.com/babylonchain/babylon/x/btclightclient/keeper" - "github.com/babylonchain/babylon/x/btclightclient/types" + "github.com/babylonlabs-io/babylon/x/btclightclient/client/cli" + "github.com/babylonlabs-io/babylon/x/btclightclient/keeper" + "github.com/babylonlabs-io/babylon/x/btclightclient/types" "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/codec" cdctypes "github.com/cosmos/cosmos-sdk/codec/types" diff --git a/x/btclightclient/types/btc_header_info.go b/x/btclightclient/types/btc_header_info.go index bb16a839c..2cfdb00f6 100644 --- a/x/btclightclient/types/btc_header_info.go +++ b/x/btclightclient/types/btc_header_info.go @@ -1,8 +1,11 @@ package types import ( + "errors" + "fmt" + sdkmath "cosmossdk.io/math" - bbn "github.com/babylonchain/babylon/types" + bbn "github.com/babylonlabs-io/babylon/types" ) func NewBTCHeaderInfo(header *bbn.BTCHeaderBytes, headerHash *bbn.BTCHeaderHashBytes, height uint64, work *sdkmath.Uint) *BTCHeaderInfo { @@ -21,3 +24,42 @@ func (m *BTCHeaderInfo) HasParent(parent *BTCHeaderInfo) bool { func (m *BTCHeaderInfo) Eq(other *BTCHeaderInfo) bool { return m.Hash.Eq(other.Hash) } + +// Validate verifies that the information inside the BTCHeaderInfo is valid. +func (m *BTCHeaderInfo) Validate() error { + if m.Header == nil { + return errors.New("header is nil") + } + if m.Hash == nil { + return errors.New("hash is nil") + } + if m.Work == nil { + return errors.New("work is nil") + } + + if m.Work.IsZero() { + return errors.New("work is zero") + } + + btcHeader, err := bbn.NewBlockHeader(*m.Header) + if err != nil { + return err + } + + blkHash := btcHeader.BlockHash() + headerHash := bbn.NewBTCHeaderHashBytesFromChainhash(&blkHash) + if !m.Hash.Eq(&headerHash) { + return fmt.Errorf("BTC header hash is not equal to generated hash from header %s != %s", m.Hash, &headerHash) + } + + return nil +} + +func NewBTCHeaderInfoResponse(header *bbn.BTCHeaderBytes, headerHash *bbn.BTCHeaderHashBytes, height uint64, work *sdkmath.Uint) *BTCHeaderInfoResponse { + return &BTCHeaderInfoResponse{ + HeaderHex: header.MarshalHex(), + HashHex: headerHash.MarshalHex(), + Height: height, + Work: *work, + } +} diff --git a/x/btclightclient/types/btc_header_info_test.go b/x/btclightclient/types/btc_header_info_test.go index 8a9e8d2ea..10bea02f1 100644 --- a/x/btclightclient/types/btc_header_info_test.go +++ b/x/btclightclient/types/btc_header_info_test.go @@ -2,13 +2,17 @@ package types_test import ( "bytes" + "errors" + "fmt" "math/rand" "testing" sdkmath "cosmossdk.io/math" - "github.com/babylonchain/babylon/testutil/datagen" - "github.com/babylonchain/babylon/x/btclightclient/types" + "github.com/babylonlabs-io/babylon/testutil/datagen" + bbn "github.com/babylonlabs-io/babylon/types" + "github.com/babylonlabs-io/babylon/x/btclightclient/types" + "github.com/stretchr/testify/require" ) func FuzzNewHeaderInfo(f *testing.F) { @@ -57,3 +61,88 @@ func FuzzNewHeaderInfo(f *testing.F) { } }) } + +func TestBTCHeaderInfoValidate(t *testing.T) { + r := rand.New(rand.NewSource(120)) + valid := *datagen.GenRandomBTCHeaderInfo(r) + valid2 := *datagen.GenRandomBTCHeaderInfo(r) + zeroUint := sdkmath.ZeroUint() + + tcs := []struct { + title string + info types.BTCHeaderInfo + expectedErr error + }{ + { + "valid", + valid, + nil, + }, + { + "valid2", + valid2, + nil, + }, + { + "invalid: header nil", + types.BTCHeaderInfo{}, + errors.New("header is nil"), + }, + { + "invalid: hash nil", + types.BTCHeaderInfo{ + Header: valid.Header, + }, + errors.New("hash is nil"), + }, + { + "invalid: work nil", + types.BTCHeaderInfo{ + Header: valid.Header, + Hash: valid.Hash, + }, + errors.New("work is nil"), + }, + { + "invalid: work is zero", + types.BTCHeaderInfo{ + Header: valid.Header, + Hash: valid.Hash, + Work: &zeroUint, + Height: valid.Height, + }, + errors.New("work is zero"), + }, + { + "invalid: bad block header", + types.BTCHeaderInfo{ + Header: &bbn.BTCHeaderBytes{byte(1)}, + Hash: valid.Hash, + Work: valid.Work, + Height: valid.Height, + }, + errors.New("unexpected EOF"), + }, + { + "invalid: bad block header", + types.BTCHeaderInfo{ + Header: valid.Header, + Hash: valid2.Hash, + Work: valid.Work, + Height: valid.Height, + }, + fmt.Errorf("BTC header hash is not equal to generated hash from header %s != %s", valid2.Hash, valid.Hash), + }, + } + + for _, tc := range tcs { + t.Run(tc.title, func(t *testing.T) { + actErr := tc.info.Validate() + if tc.expectedErr != nil { + require.EqualError(t, actErr, tc.expectedErr.Error()) + return + } + require.NoError(t, actErr) + }) + } +} diff --git a/x/btclightclient/types/btc_light_client.go b/x/btclightclient/types/btc_light_client.go index dbbd19204..69440383f 100644 --- a/x/btclightclient/types/btc_light_client.go +++ b/x/btclightclient/types/btc_light_client.go @@ -5,7 +5,7 @@ import ( "time" sdkmath "cosmossdk.io/math" - bbn "github.com/babylonchain/babylon/types" + bbn "github.com/babylonlabs-io/babylon/types" "github.com/btcsuite/btcd/blockchain" "github.com/btcsuite/btcd/chaincfg" "github.com/btcsuite/btcd/chaincfg/chainhash" diff --git a/x/btclightclient/types/btclightclient.pb.go b/x/btclightclient/types/btclightclient.pb.go index dd50ff83e..5384959e7 100644 --- a/x/btclightclient/types/btclightclient.pb.go +++ b/x/btclightclient/types/btclightclient.pb.go @@ -6,7 +6,7 @@ package types import ( cosmossdk_io_math "cosmossdk.io/math" fmt "fmt" - github_com_babylonchain_babylon_types "github.com/babylonchain/babylon/types" + github_com_babylonlabs_io_babylon_types "github.com/babylonlabs-io/babylon/types" _ "github.com/cosmos/gogoproto/gogoproto" proto "github.com/cosmos/gogoproto/proto" io "io" @@ -34,10 +34,10 @@ const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package // to the header Bits field // and the total work of the header. type BTCHeaderInfo struct { - Header *github_com_babylonchain_babylon_types.BTCHeaderBytes `protobuf:"bytes,1,opt,name=header,proto3,customtype=github.com/babylonchain/babylon/types.BTCHeaderBytes" json:"header,omitempty"` - Hash *github_com_babylonchain_babylon_types.BTCHeaderHashBytes `protobuf:"bytes,2,opt,name=hash,proto3,customtype=github.com/babylonchain/babylon/types.BTCHeaderHashBytes" json:"hash,omitempty"` - Height uint64 `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"` + 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"` + Work *cosmossdk_io_math.Uint `protobuf:"bytes,4,opt,name=work,proto3,customtype=cosmossdk.io/math.Uint" json:"work,omitempty"` } func (m *BTCHeaderInfo) Reset() { *m = BTCHeaderInfo{} } @@ -89,25 +89,25 @@ func init() { } var fileDescriptor_84bf438d909b681d = []byte{ - // 282 bytes of a gzipped FileDescriptorProto + // 284 bytes of a gzipped FileDescriptorProto 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0xd2, 0x4b, 0x4a, 0x4c, 0xaa, 0xcc, 0xc9, 0xcf, 0xd3, 0x4f, 0x2a, 0x49, 0xce, 0xc9, 0x4c, 0xcf, 0x00, 0x91, 0xa9, 0x79, 0x25, 0xfa, 0x65, 0x86, 0x68, 0x22, 0x7a, 0x05, 0x45, 0xf9, 0x25, 0xf9, 0x42, 0x92, 0x50, 0xf5, 0x7a, 0x68, 0xb2, 0x65, 0x86, 0x52, 0x22, 0xe9, 0xf9, 0xe9, 0xf9, 0x60, 0x55, 0xfa, 0x20, 0x16, 0x44, - 0x83, 0xd2, 0x6f, 0x46, 0x2e, 0x5e, 0xa7, 0x10, 0x67, 0x8f, 0xd4, 0xc4, 0x94, 0xd4, 0x22, 0xcf, - 0xbc, 0xb4, 0x7c, 0xa1, 0x00, 0x2e, 0xb6, 0x0c, 0x30, 0x4f, 0x82, 0x51, 0x81, 0x51, 0x83, 0xc7, - 0xc9, 0xe2, 0xd6, 0x3d, 0x79, 0x93, 0xf4, 0xcc, 0x92, 0x8c, 0xd2, 0x24, 0xbd, 0xe4, 0xfc, 0x5c, - 0x7d, 0xa8, 0x0d, 0xc9, 0x19, 0x89, 0x99, 0x79, 0x30, 0x8e, 0x7e, 0x49, 0x65, 0x41, 0x6a, 0xb1, - 0x1e, 0xdc, 0x20, 0xa7, 0xca, 0x92, 0xd4, 0xe2, 0x20, 0xa8, 0x39, 0x42, 0x01, 0x5c, 0x2c, 0x19, - 0x89, 0xc5, 0x19, 0x12, 0x4c, 0x60, 0xf3, 0x6c, 0x6e, 0xdd, 0x93, 0xb7, 0x20, 0xd1, 0x3c, 0x8f, - 0xc4, 0xe2, 0x0c, 0x88, 0x99, 0x60, 0x93, 0x84, 0xc4, 0x40, 0x6e, 0x04, 0x79, 0x4f, 0x82, 0x59, - 0x81, 0x51, 0x83, 0x25, 0x08, 0xca, 0x13, 0xd2, 0xe3, 0x62, 0x29, 0xcf, 0x2f, 0xca, 0x96, 0x60, - 0x01, 0xdb, 0x24, 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, 0xc0, 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, 0x99, 0x11, 0x72, - 0x61, 0x05, 0x7a, 0x94, 0x80, 0x9d, 0x9c, 0xc4, 0x06, 0x0e, 0x56, 0x63, 0x40, 0x00, 0x00, 0x00, - 0xff, 0xff, 0x13, 0xc6, 0x69, 0x40, 0xb9, 0x01, 0x00, 0x00, + 0x83, 0xd2, 0x7f, 0x46, 0x2e, 0x5e, 0xa7, 0x10, 0x67, 0x8f, 0xd4, 0xc4, 0x94, 0xd4, 0x22, 0xcf, + 0xbc, 0xb4, 0x7c, 0xa1, 0x20, 0x2e, 0xb6, 0x0c, 0x30, 0x4f, 0x82, 0x51, 0x81, 0x51, 0x83, 0xc7, + 0xc9, 0xea, 0xd6, 0x3d, 0x79, 0xb3, 0xf4, 0xcc, 0x92, 0x8c, 0xd2, 0x24, 0xbd, 0xe4, 0xfc, 0x5c, + 0x7d, 0xa8, 0x0d, 0x39, 0x89, 0x49, 0xc5, 0xba, 0x99, 0xf9, 0x30, 0xae, 0x7e, 0x49, 0x65, 0x41, + 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, + 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, } func (m *BTCHeaderInfo) Marshal() (dAtA []byte, err error) { @@ -273,7 +273,7 @@ func (m *BTCHeaderInfo) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - var v github_com_babylonchain_babylon_types.BTCHeaderBytes + var v github_com_babylonlabs_io_babylon_types.BTCHeaderBytes m.Header = &v if err := m.Header.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err @@ -308,7 +308,7 @@ func (m *BTCHeaderInfo) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - var v github_com_babylonchain_babylon_types.BTCHeaderHashBytes + var v github_com_babylonlabs_io_babylon_types.BTCHeaderHashBytes m.Hash = &v if err := m.Hash.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err diff --git a/x/btclightclient/types/event.pb.go b/x/btclightclient/types/event.pb.go index 71f8fcda3..aa0587758 100644 --- a/x/btclightclient/types/event.pb.go +++ b/x/btclightclient/types/event.pb.go @@ -176,7 +176,7 @@ func init() { } var fileDescriptor_519f2d655b639c5a = []byte{ - // 228 bytes of a gzipped FileDescriptorProto + // 230 bytes of a gzipped FileDescriptorProto 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x52, 0x4d, 0x4a, 0x4c, 0xaa, 0xcc, 0xc9, 0xcf, 0xd3, 0x4f, 0x2a, 0x49, 0xce, 0xc9, 0x4c, 0xcf, 0x00, 0x91, 0xa9, 0x79, 0x25, 0xfa, 0x65, 0x86, 0xfa, 0xa9, 0x65, 0xa9, 0x79, 0x25, 0x7a, 0x05, 0x45, 0xf9, 0x25, 0xf9, 0x42, @@ -186,12 +186,12 @@ var fileDescriptor_519f2d655b639c5a = []byte{ 0x05, 0x46, 0x0d, 0x6e, 0x23, 0x0d, 0x3d, 0x9c, 0xf6, 0xe9, 0x39, 0x85, 0x38, 0x7b, 0x80, 0xd5, 0x7a, 0xe6, 0xa5, 0xe5, 0x07, 0x41, 0xf5, 0x29, 0x85, 0x73, 0x09, 0x23, 0x9b, 0xea, 0x96, 0x5f, 0x54, 0x9e, 0x58, 0x94, 0x42, 0x05, 0x83, 0xa3, 0xb8, 0xc4, 0x60, 0x06, 0xc3, 0x64, 0x8b, 0x53, - 0x8b, 0x4a, 0x52, 0xa9, 0x60, 0xb6, 0x53, 0xc0, 0x89, 0x47, 0x72, 0x8c, 0x17, 0x1e, 0xc9, 0x31, + 0x8b, 0x4a, 0x52, 0xa9, 0x60, 0xb6, 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, 0x99, 0xa5, 0x67, 0x96, 0x64, 0x94, 0x26, 0xe9, 0x25, 0xe7, 0xe7, 0xea, 0x43, 0x4d, - 0x4d, 0xce, 0x48, 0xcc, 0xcc, 0x83, 0x71, 0xf4, 0x2b, 0xd0, 0x83, 0xbb, 0xa4, 0xb2, 0x20, 0xb5, - 0x38, 0x89, 0x0d, 0x1c, 0xc6, 0xc6, 0x80, 0x00, 0x00, 0x00, 0xff, 0xff, 0x16, 0x0b, 0x33, 0xea, - 0xd7, 0x01, 0x00, 0x00, + 0x31, 0x44, 0x59, 0xa4, 0x67, 0x96, 0x64, 0x94, 0x26, 0xe9, 0x25, 0xe7, 0xe7, 0xea, 0x43, 0x4d, + 0xcd, 0x49, 0x4c, 0x2a, 0xd6, 0xcd, 0xcc, 0x87, 0x71, 0xf5, 0x2b, 0xd0, 0x03, 0xbc, 0xa4, 0xb2, + 0x20, 0xb5, 0x38, 0x89, 0x0d, 0x1c, 0xca, 0xc6, 0x80, 0x00, 0x00, 0x00, 0xff, 0xff, 0xba, 0x96, + 0x2b, 0x51, 0xd9, 0x01, 0x00, 0x00, } func (m *EventBTCRollBack) Marshal() (dAtA []byte, err error) { diff --git a/x/btclightclient/types/genesis.go b/x/btclightclient/types/genesis.go index 2f5300632..13835fa2b 100644 --- a/x/btclightclient/types/genesis.go +++ b/x/btclightclient/types/genesis.go @@ -1,10 +1,14 @@ package types import ( + "encoding/json" + "errors" "fmt" - bbn "github.com/babylonchain/babylon/types" + bbn "github.com/babylonlabs-io/babylon/types" "github.com/btcsuite/btcd/chaincfg" + + "github.com/cosmos/cosmos-sdk/codec" ) func SimnetGenesisBlock() BTCHeaderInfo { @@ -29,28 +33,56 @@ func DefaultGenesis() *GenesisState { defaultBaseHeader := SimnetGenesisBlock() return &GenesisState{ - BaseBtcHeader: defaultBaseHeader, - Params: DefaultParams(), + BtcHeaders: []*BTCHeaderInfo{&defaultBaseHeader}, + Params: DefaultParams(), } } // Validate performs basic genesis state validation returning an error upon any // failure. func (gs GenesisState) Validate() error { + if err := gs.Params.Validate(); err != nil { + return fmt.Errorf("invalid params in genesis: %w", err) + } + + // Initial btc header serves as de-facto genesis header for the module. + // At least one BTC Header is needed to apply all validation rules to the next headers. + // If we don't have an initial btc header, we cannot validate the rules on the next (as it has no parent). + // All following headers that are to be inserted in chain are going to be validated based on the previous ones. + // (all parent-child relantionships, all difficulty transitions). + if len(gs.BtcHeaders) == 0 { + // if you have no initial header, you can't validate the following ones. + return errors.New("no btc header set on genesis") + } + // We Require that genesis block is difficulty adjustment block, so that we can // properly calculate the difficulty adjustments in the future. // TODO: Even though number of block per re-target depends on the network, in reality it // is always 2016. Maybe we should consider moving it to param, or try to pass // it through - isRetarget := IsRetargetBlock(&gs.BaseBtcHeader, &chaincfg.MainNetParams) - + isRetarget := IsRetargetBlock(gs.BtcHeaders[0], &chaincfg.MainNetParams) if !isRetarget { return fmt.Errorf("genesis block must be a difficulty adjustment block") } - if err := gs.Params.Validate(); err != nil { - return fmt.Errorf("invalid params in genesis: %w", err) + for _, header := range gs.BtcHeaders { + if err := header.Validate(); err != nil { + return err + } } + // TODO: validate headers have proper parent-child relationships and proper proof of work return nil } + +// GenesisStateFromAppState returns x/btclightclient GenesisState given raw application +// genesis state. +func GenesisStateFromAppState(cdc codec.Codec, appState map[string]json.RawMessage) GenesisState { + var genesisState GenesisState + + if appState[ModuleName] != nil { + cdc.MustUnmarshalJSON(appState[ModuleName], &genesisState) + } + + return genesisState +} diff --git a/x/btclightclient/types/genesis.pb.go b/x/btclightclient/types/genesis.pb.go index d3cc8819a..cabb6090e 100644 --- a/x/btclightclient/types/genesis.pb.go +++ b/x/btclightclient/types/genesis.pb.go @@ -25,8 +25,8 @@ const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package // GenesisState defines the btclightclient module's genesis state. type GenesisState struct { - Params Params `protobuf:"bytes,1,opt,name=params,proto3" json:"params"` - BaseBtcHeader BTCHeaderInfo `protobuf:"bytes,2,opt,name=base_btc_header,json=baseBtcHeader,proto3" json:"base_btc_header"` + Params Params `protobuf:"bytes,1,opt,name=params,proto3" json:"params"` + BtcHeaders []*BTCHeaderInfo `protobuf:"bytes,2,rep,name=btc_headers,json=btcHeaders,proto3" json:"btc_headers,omitempty"` } func (m *GenesisState) Reset() { *m = GenesisState{} } @@ -69,11 +69,11 @@ func (m *GenesisState) GetParams() Params { return Params{} } -func (m *GenesisState) GetBaseBtcHeader() BTCHeaderInfo { +func (m *GenesisState) GetBtcHeaders() []*BTCHeaderInfo { if m != nil { - return m.BaseBtcHeader + return m.BtcHeaders } - return BTCHeaderInfo{} + return nil } func init() { @@ -85,24 +85,24 @@ func init() { } var fileDescriptor_4f95902e4096217a = []byte{ - // 260 bytes of a gzipped FileDescriptorProto + // 258 bytes of a gzipped FileDescriptorProto 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x52, 0x4f, 0x4a, 0x4c, 0xaa, 0xcc, 0xc9, 0xcf, 0xd3, 0x4f, 0x2a, 0x49, 0xce, 0xc9, 0x4c, 0xcf, 0x00, 0x91, 0xa9, 0x79, 0x25, 0xfa, 0x65, 0x86, 0xfa, 0xe9, 0xa9, 0x79, 0xa9, 0xc5, 0x99, 0xc5, 0x7a, 0x05, 0x45, 0xf9, 0x25, 0xf9, 0x42, 0x92, 0x50, 0x85, 0x7a, 0xa8, 0x0a, 0xf5, 0xca, 0x0c, 0xa5, 0x44, 0xd2, 0xf3, 0xd3, 0xf3, 0xc1, 0xaa, 0xf4, 0x41, 0x2c, 0x88, 0x06, 0x29, 0x3d, 0xdc, 0x26, 0xa3, 0x19, 0x01, 0x51, - 0xaf, 0x86, 0x5b, 0x7d, 0x41, 0x62, 0x51, 0x62, 0x2e, 0xd4, 0x21, 0x4a, 0xcb, 0x19, 0xb9, 0x78, + 0xaf, 0x86, 0x5b, 0x7d, 0x41, 0x62, 0x51, 0x62, 0x2e, 0xd4, 0x21, 0x4a, 0xb3, 0x18, 0xb9, 0x78, 0xdc, 0x21, 0x4e, 0x0b, 0x2e, 0x49, 0x2c, 0x49, 0x15, 0xb2, 0xe7, 0x62, 0x83, 0x28, 0x90, 0x60, 0x54, 0x60, 0xd4, 0xe0, 0x36, 0x52, 0xd4, 0xc3, 0xe9, 0x54, 0xbd, 0x00, 0xb0, 0x42, 0x27, 0x96, - 0x13, 0xf7, 0xe4, 0x19, 0x82, 0xa0, 0xda, 0x84, 0xc2, 0xb8, 0xf8, 0x93, 0x12, 0x8b, 0x53, 0xe3, - 0x93, 0x4a, 0x92, 0xe3, 0x33, 0x52, 0x13, 0x53, 0x52, 0x8b, 0x24, 0x98, 0xc0, 0x26, 0x69, 0xe0, - 0x31, 0xc9, 0x29, 0xc4, 0xd9, 0x03, 0xac, 0xd6, 0x33, 0x2f, 0x2d, 0x1f, 0x6a, 0x20, 0x2f, 0xc8, - 0x18, 0xa7, 0x92, 0x64, 0x88, 0x84, 0x53, 0xc0, 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, 0x99, 0xa5, 0x67, 0x96, 0x64, 0x94, 0x26, 0xe9, 0x25, 0xe7, 0xe7, 0xea, 0x43, 0xad, - 0x48, 0xce, 0x48, 0xcc, 0xcc, 0x83, 0x71, 0xf4, 0x2b, 0xd0, 0x43, 0xa1, 0xa4, 0xb2, 0x20, 0xb5, - 0x38, 0x89, 0x0d, 0x1c, 0x04, 0xc6, 0x80, 0x00, 0x00, 0x00, 0xff, 0xff, 0xa8, 0x0c, 0x15, 0x34, - 0xb6, 0x01, 0x00, 0x00, + 0x13, 0xf7, 0xe4, 0x19, 0x82, 0xa0, 0xda, 0x84, 0x3c, 0xb9, 0xb8, 0x93, 0x4a, 0x92, 0xe3, 0x33, + 0x52, 0x13, 0x53, 0x52, 0x8b, 0x8a, 0x25, 0x98, 0x14, 0x98, 0x35, 0xb8, 0x8d, 0x34, 0xf0, 0x98, + 0xe2, 0x14, 0xe2, 0xec, 0x01, 0x56, 0xec, 0x99, 0x97, 0x96, 0x1f, 0xc4, 0x95, 0x54, 0x92, 0x0c, + 0xe1, 0x16, 0x3b, 0x05, 0x9d, 0x78, 0x24, 0xc7, 0x78, 0xe1, 0x91, 0x1c, 0xe3, 0x83, 0x47, 0x72, + 0x8c, 0x13, 0x1e, 0xcb, 0x31, 0x5c, 0x78, 0x2c, 0xc7, 0x70, 0xe3, 0xb1, 0x1c, 0x43, 0x94, 0x45, + 0x7a, 0x66, 0x49, 0x46, 0x69, 0x92, 0x5e, 0x72, 0x7e, 0xae, 0x3e, 0xd4, 0xe4, 0x9c, 0xc4, 0xa4, + 0x62, 0xdd, 0xcc, 0x7c, 0x18, 0x57, 0xbf, 0x02, 0xdd, 0xeb, 0x25, 0x95, 0x05, 0xa9, 0xc5, 0x49, + 0x6c, 0x60, 0x7f, 0x1b, 0x03, 0x02, 0x00, 0x00, 0xff, 0xff, 0xbc, 0xe4, 0xd2, 0xd7, 0xab, 0x01, + 0x00, 0x00, } func (m *GenesisState) Marshal() (dAtA []byte, err error) { @@ -125,16 +125,20 @@ func (m *GenesisState) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l - { - size, err := m.BaseBtcHeader.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err + if len(m.BtcHeaders) > 0 { + for iNdEx := len(m.BtcHeaders) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.BtcHeaders[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintGenesis(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 } - i -= size - i = encodeVarintGenesis(dAtA, i, uint64(size)) } - i-- - dAtA[i] = 0x12 { size, err := m.Params.MarshalToSizedBuffer(dAtA[:i]) if err != nil { @@ -167,8 +171,12 @@ func (m *GenesisState) Size() (n int) { _ = l l = m.Params.Size() n += 1 + l + sovGenesis(uint64(l)) - l = m.BaseBtcHeader.Size() - n += 1 + l + sovGenesis(uint64(l)) + if len(m.BtcHeaders) > 0 { + for _, e := range m.BtcHeaders { + l = e.Size() + n += 1 + l + sovGenesis(uint64(l)) + } + } return n } @@ -242,7 +250,7 @@ func (m *GenesisState) Unmarshal(dAtA []byte) error { iNdEx = postIndex case 2: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field BaseBtcHeader", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field BtcHeaders", wireType) } var msglen int for shift := uint(0); ; shift += 7 { @@ -269,7 +277,8 @@ func (m *GenesisState) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - if err := m.BaseBtcHeader.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + m.BtcHeaders = append(m.BtcHeaders, &BTCHeaderInfo{}) + if err := m.BtcHeaders[len(m.BtcHeaders)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } iNdEx = postIndex diff --git a/x/btclightclient/types/genesis_test.go b/x/btclightclient/types/genesis_test.go index 15e458280..3d64269ce 100644 --- a/x/btclightclient/types/genesis_test.go +++ b/x/btclightclient/types/genesis_test.go @@ -3,7 +3,7 @@ package types_test import ( "testing" - "github.com/babylonchain/babylon/x/btclightclient/types" + "github.com/babylonlabs-io/babylon/x/btclightclient/types" "github.com/stretchr/testify/require" ) @@ -19,18 +19,27 @@ func TestGenesisState_Validate(t *testing.T) { valid: true, }, { - desc: "valid genesis state", + desc: "invalid genesis state, no btc header", genState: &types.GenesisState{}, - valid: true, + valid: false, + }, + { + desc: "invalid genesis state", + genState: &types.GenesisState{ + BtcHeaders: []*types.BTCHeaderInfo{&types.BTCHeaderInfo{ + Height: 1, + }}, + }, + valid: false, }, } { t.Run(tc.desc, func(t *testing.T) { err := tc.genState.Validate() if tc.valid { require.NoError(t, err) - } else { - require.Error(t, err) + return } + require.Error(t, err) }) } } diff --git a/x/btclightclient/types/keys.go b/x/btclightclient/types/keys.go index b0844f440..4761c2be8 100644 --- a/x/btclightclient/types/keys.go +++ b/x/btclightclient/types/keys.go @@ -1,7 +1,7 @@ package types import ( - bbn "github.com/babylonchain/babylon/types" + bbn "github.com/babylonlabs-io/babylon/types" sdk "github.com/cosmos/cosmos-sdk/types" ) diff --git a/x/btclightclient/types/keys_test.go b/x/btclightclient/types/keys_test.go index e075a6c4e..e7095b95c 100644 --- a/x/btclightclient/types/keys_test.go +++ b/x/btclightclient/types/keys_test.go @@ -5,9 +5,9 @@ import ( "math/rand" "testing" - "github.com/babylonchain/babylon/testutil/datagen" - bbn "github.com/babylonchain/babylon/types" - "github.com/babylonchain/babylon/x/btclightclient/types" + "github.com/babylonlabs-io/babylon/testutil/datagen" + bbn "github.com/babylonlabs-io/babylon/types" + "github.com/babylonlabs-io/babylon/x/btclightclient/types" sdk "github.com/cosmos/cosmos-sdk/types" ) diff --git a/x/btclightclient/types/msgs.go b/x/btclightclient/types/msgs.go index 038b9ac8c..7b6bfbdd8 100644 --- a/x/btclightclient/types/msgs.go +++ b/x/btclightclient/types/msgs.go @@ -5,7 +5,7 @@ import ( "fmt" "math/big" - bbn "github.com/babylonchain/babylon/types" + bbn "github.com/babylonlabs-io/babylon/types" sdk "github.com/cosmos/cosmos-sdk/types" ) diff --git a/x/btclightclient/types/msgs_test.go b/x/btclightclient/types/msgs_test.go index a55240fa0..9a4766fd8 100644 --- a/x/btclightclient/types/msgs_test.go +++ b/x/btclightclient/types/msgs_test.go @@ -7,9 +7,9 @@ import ( sdkmath "cosmossdk.io/math" - "github.com/babylonchain/babylon/testutil/datagen" - bbn "github.com/babylonchain/babylon/types" - "github.com/babylonchain/babylon/x/btclightclient/types" + "github.com/babylonlabs-io/babylon/testutil/datagen" + bbn "github.com/babylonlabs-io/babylon/types" + "github.com/babylonlabs-io/babylon/x/btclightclient/types" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/stretchr/testify/require" ) diff --git a/x/btclightclient/types/params.pb.go b/x/btclightclient/types/params.pb.go index bdd917254..483235b12 100644 --- a/x/btclightclient/types/params.pb.go +++ b/x/btclightclient/types/params.pb.go @@ -79,7 +79,7 @@ func init() { } var fileDescriptor_1e4c5f7a17079e1f = []byte{ - // 211 bytes of a gzipped FileDescriptorProto + // 213 bytes of a gzipped FileDescriptorProto 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x52, 0x4b, 0x4a, 0x4c, 0xaa, 0xcc, 0xc9, 0xcf, 0xd3, 0x4f, 0x2a, 0x49, 0xce, 0xc9, 0x4c, 0xcf, 0x00, 0x91, 0xa9, 0x79, 0x25, 0xfa, 0x65, 0x86, 0xfa, 0x05, 0x89, 0x45, 0x89, 0xb9, 0xc5, 0x7a, 0x05, 0x45, 0xf9, 0x25, 0xf9, @@ -88,12 +88,12 @@ var fileDescriptor_1e4c5f7a17079e1f = []byte{ 0x5c, 0x92, 0x99, 0x79, 0xc5, 0xa9, 0x45, 0x25, 0xf1, 0x19, 0xa9, 0x89, 0x29, 0xa9, 0x45, 0xc5, 0xf1, 0x89, 0x39, 0x39, 0xf9, 0xe5, 0xf1, 0x39, 0x99, 0xc5, 0x25, 0x12, 0x8c, 0x0a, 0xcc, 0x1a, 0x9c, 0x41, 0x62, 0x10, 0x05, 0x1e, 0x10, 0x79, 0x47, 0x90, 0xb4, 0x4f, 0x66, 0x71, 0x89, 0x15, - 0xcb, 0x8b, 0x05, 0xf2, 0x8c, 0x4e, 0x01, 0x27, 0x1e, 0xc9, 0x31, 0x5e, 0x78, 0x24, 0xc7, 0xf8, + 0xcb, 0x8b, 0x05, 0xf2, 0x8c, 0x4e, 0x41, 0x27, 0x1e, 0xc9, 0x31, 0x5e, 0x78, 0x24, 0xc7, 0xf8, 0xe0, 0x91, 0x1c, 0xe3, 0x84, 0xc7, 0x72, 0x0c, 0x17, 0x1e, 0xcb, 0x31, 0xdc, 0x78, 0x2c, 0xc7, - 0x10, 0x65, 0x96, 0x9e, 0x59, 0x92, 0x51, 0x9a, 0xa4, 0x97, 0x9c, 0x9f, 0xab, 0x0f, 0x75, 0x60, - 0x72, 0x46, 0x62, 0x66, 0x1e, 0x8c, 0xa3, 0x5f, 0x81, 0xee, 0xaf, 0x92, 0xca, 0x82, 0xd4, 0xe2, - 0x24, 0x36, 0xb0, 0x1b, 0x8d, 0x01, 0x01, 0x00, 0x00, 0xff, 0xff, 0x30, 0xe4, 0x07, 0x29, 0xfe, - 0x00, 0x00, 0x00, + 0x10, 0x65, 0x91, 0x9e, 0x59, 0x92, 0x51, 0x9a, 0xa4, 0x97, 0x9c, 0x9f, 0xab, 0x0f, 0x75, 0x60, + 0x4e, 0x62, 0x52, 0xb1, 0x6e, 0x66, 0x3e, 0x8c, 0xab, 0x5f, 0x81, 0xee, 0xb3, 0x92, 0xca, 0x82, + 0xd4, 0xe2, 0x24, 0x36, 0xb0, 0x2b, 0x8d, 0x01, 0x01, 0x00, 0x00, 0xff, 0xff, 0x43, 0x29, 0x40, + 0xa2, 0x00, 0x01, 0x00, 0x00, } func (this *Params) Equal(that interface{}) bool { diff --git a/x/btclightclient/types/querier.go b/x/btclightclient/types/querier.go index a35893026..6636f1eff 100644 --- a/x/btclightclient/types/querier.go +++ b/x/btclightclient/types/querier.go @@ -1,7 +1,7 @@ package types import ( - "github.com/babylonchain/babylon/types" + "github.com/babylonlabs-io/babylon/types" "github.com/cosmos/cosmos-sdk/types/query" ) diff --git a/x/btclightclient/types/querier_test.go b/x/btclightclient/types/querier_test.go index 5a23c0c12..a60c514fd 100644 --- a/x/btclightclient/types/querier_test.go +++ b/x/btclightclient/types/querier_test.go @@ -5,9 +5,9 @@ import ( "math/rand" "testing" - "github.com/babylonchain/babylon/testutil/datagen" - bbn "github.com/babylonchain/babylon/types" - "github.com/babylonchain/babylon/x/btclightclient/types" + "github.com/babylonlabs-io/babylon/testutil/datagen" + bbn "github.com/babylonlabs-io/babylon/types" + "github.com/babylonlabs-io/babylon/x/btclightclient/types" "github.com/cosmos/cosmos-sdk/types/query" ) diff --git a/x/btclightclient/types/query.go b/x/btclightclient/types/query.go new file mode 100644 index 000000000..a0deed675 --- /dev/null +++ b/x/btclightclient/types/query.go @@ -0,0 +1,25 @@ +package types + +// ToResponse parses one BTC Header Info to BTCHeaderInfoResp. +func (b *BTCHeaderInfo) ToResponse() *BTCHeaderInfoResponse { + return &BTCHeaderInfoResponse{ + HeaderHex: b.Header.MarshalHex(), + HashHex: b.Hash.MarshalHex(), + Height: b.Height, + Work: *b.Work, + } +} + +// ParseBTCHeadersToResponse parses the infos into resposes. +func ParseBTCHeadersToResponse(infos []*BTCHeaderInfo) (resp []*BTCHeaderInfoResponse) { + resp = make([]*BTCHeaderInfoResponse, len(infos)) + for i, info := range infos { + resp[i] = info.ToResponse() + } + return resp +} + +// Eq returns true if the hashes are equal. +func (m *BTCHeaderInfoResponse) Eq(other *BTCHeaderInfo) bool { + return m.HashHex == other.Hash.MarshalHex() +} diff --git a/x/btclightclient/types/query.pb.go b/x/btclightclient/types/query.pb.go index 65d640b56..b8eb8bb97 100644 --- a/x/btclightclient/types/query.pb.go +++ b/x/btclightclient/types/query.pb.go @@ -5,8 +5,10 @@ package types import ( context "context" + cosmossdk_io_math "cosmossdk.io/math" fmt "fmt" - github_com_babylonchain_babylon_types "github.com/babylonchain/babylon/types" + github_com_babylonlabs_io_babylon_types "github.com/babylonlabs-io/babylon/types" + _ "github.com/cosmos/cosmos-proto" query "github.com/cosmos/cosmos-sdk/types/query" _ "github.com/cosmos/gogoproto/gogoproto" grpc1 "github.com/cosmos/gogoproto/grpc" @@ -162,8 +164,8 @@ func (m *QueryHashesRequest) GetPagination() *query.PageRequest { // QueryHashesResponse is response type for the Query/Hashes RPC method. type QueryHashesResponse struct { - Hashes []github_com_babylonchain_babylon_types.BTCHeaderHashBytes `protobuf:"bytes,1,rep,name=hashes,proto3,customtype=github.com/babylonchain/babylon/types.BTCHeaderHashBytes" json:"hashes,omitempty"` - Pagination *query.PageResponse `protobuf:"bytes,2,opt,name=pagination,proto3" json:"pagination,omitempty"` + Hashes []github_com_babylonlabs_io_babylon_types.BTCHeaderHashBytes `protobuf:"bytes,1,rep,name=hashes,proto3,customtype=github.com/babylonlabs-io/babylon/types.BTCHeaderHashBytes" json:"hashes,omitempty"` + Pagination *query.PageResponse `protobuf:"bytes,2,opt,name=pagination,proto3" json:"pagination,omitempty"` } func (m *QueryHashesResponse) Reset() { *m = QueryHashesResponse{} } @@ -209,7 +211,7 @@ func (m *QueryHashesResponse) GetPagination() *query.PageResponse { // QueryContainsRequest is request type for the Query/Contains RPC method. // It involves checking whether a hash is maintained by the module. type QueryContainsRequest struct { - Hash *github_com_babylonchain_babylon_types.BTCHeaderHashBytes `protobuf:"bytes,1,opt,name=hash,proto3,customtype=github.com/babylonchain/babylon/types.BTCHeaderHashBytes" json:"hash,omitempty"` + Hash *github_com_babylonlabs_io_babylon_types.BTCHeaderHashBytes `protobuf:"bytes,1,opt,name=hash,proto3,customtype=github.com/babylonlabs-io/babylon/types.BTCHeaderHashBytes" json:"hash,omitempty"` } func (m *QueryContainsRequest) Reset() { *m = QueryContainsRequest{} } @@ -430,8 +432,8 @@ func (m *QueryMainChainRequest) GetPagination() *query.PageRequest { // QueryMainChainResponse is response type for the Query/MainChain RPC method. type QueryMainChainResponse struct { - Headers []*BTCHeaderInfo `protobuf:"bytes,1,rep,name=headers,proto3" json:"headers,omitempty"` - Pagination *query.PageResponse `protobuf:"bytes,2,opt,name=pagination,proto3" json:"pagination,omitempty"` + Headers []*BTCHeaderInfoResponse `protobuf:"bytes,1,rep,name=headers,proto3" json:"headers,omitempty"` + Pagination *query.PageResponse `protobuf:"bytes,2,opt,name=pagination,proto3" json:"pagination,omitempty"` } func (m *QueryMainChainResponse) Reset() { *m = QueryMainChainResponse{} } @@ -467,7 +469,7 @@ func (m *QueryMainChainResponse) XXX_DiscardUnknown() { var xxx_messageInfo_QueryMainChainResponse proto.InternalMessageInfo -func (m *QueryMainChainResponse) GetHeaders() []*BTCHeaderInfo { +func (m *QueryMainChainResponse) GetHeaders() []*BTCHeaderInfoResponse { if m != nil { return m.Headers } @@ -520,7 +522,7 @@ var xxx_messageInfo_QueryTipRequest proto.InternalMessageInfo // QueryTipResponse is the response type for the Query/Tip RPC method. type QueryTipResponse struct { - Header *BTCHeaderInfo `protobuf:"bytes,1,opt,name=header,proto3" json:"header,omitempty"` + Header *BTCHeaderInfoResponse `protobuf:"bytes,1,opt,name=header,proto3" json:"header,omitempty"` } func (m *QueryTipResponse) Reset() { *m = QueryTipResponse{} } @@ -556,7 +558,7 @@ func (m *QueryTipResponse) XXX_DiscardUnknown() { var xxx_messageInfo_QueryTipResponse proto.InternalMessageInfo -func (m *QueryTipResponse) GetHeader() *BTCHeaderInfo { +func (m *QueryTipResponse) GetHeader() *BTCHeaderInfoResponse { if m != nil { return m.Header } @@ -604,7 +606,7 @@ var xxx_messageInfo_QueryBaseHeaderRequest proto.InternalMessageInfo // QueryBaseHeaderResponse is the response type for the Query/BaseHeader RPC // method. type QueryBaseHeaderResponse struct { - Header *BTCHeaderInfo `protobuf:"bytes,1,opt,name=header,proto3" json:"header,omitempty"` + Header *BTCHeaderInfoResponse `protobuf:"bytes,1,opt,name=header,proto3" json:"header,omitempty"` } func (m *QueryBaseHeaderResponse) Reset() { *m = QueryBaseHeaderResponse{} } @@ -640,7 +642,7 @@ func (m *QueryBaseHeaderResponse) XXX_DiscardUnknown() { var xxx_messageInfo_QueryBaseHeaderResponse proto.InternalMessageInfo -func (m *QueryBaseHeaderResponse) GetHeader() *BTCHeaderInfo { +func (m *QueryBaseHeaderResponse) GetHeader() *BTCHeaderInfoResponse { if m != nil { return m.Header } @@ -739,6 +741,76 @@ func (m *QueryHeaderDepthResponse) GetDepth() uint64 { return 0 } +// 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. +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"` + // 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"` +} + +func (m *BTCHeaderInfoResponse) Reset() { *m = BTCHeaderInfoResponse{} } +func (m *BTCHeaderInfoResponse) String() string { return proto.CompactTextString(m) } +func (*BTCHeaderInfoResponse) ProtoMessage() {} +func (*BTCHeaderInfoResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_3961270631e52721, []int{16} +} +func (m *BTCHeaderInfoResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *BTCHeaderInfoResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_BTCHeaderInfoResponse.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 *BTCHeaderInfoResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_BTCHeaderInfoResponse.Merge(m, src) +} +func (m *BTCHeaderInfoResponse) XXX_Size() int { + return m.Size() +} +func (m *BTCHeaderInfoResponse) XXX_DiscardUnknown() { + xxx_messageInfo_BTCHeaderInfoResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_BTCHeaderInfoResponse proto.InternalMessageInfo + +func (m *BTCHeaderInfoResponse) GetHeaderHex() string { + if m != nil { + return m.HeaderHex + } + return "" +} + +func (m *BTCHeaderInfoResponse) GetHashHex() string { + if m != nil { + return m.HashHex + } + return "" +} + +func (m *BTCHeaderInfoResponse) GetHeight() uint64 { + if m != nil { + return m.Height + } + return 0 +} + func init() { proto.RegisterType((*QueryParamsRequest)(nil), "babylon.btclightclient.v1.QueryParamsRequest") proto.RegisterType((*QueryParamsResponse)(nil), "babylon.btclightclient.v1.QueryParamsResponse") @@ -756,6 +828,7 @@ func init() { proto.RegisterType((*QueryBaseHeaderResponse)(nil), "babylon.btclightclient.v1.QueryBaseHeaderResponse") proto.RegisterType((*QueryHeaderDepthRequest)(nil), "babylon.btclightclient.v1.QueryHeaderDepthRequest") proto.RegisterType((*QueryHeaderDepthResponse)(nil), "babylon.btclightclient.v1.QueryHeaderDepthResponse") + proto.RegisterType((*BTCHeaderInfoResponse)(nil), "babylon.btclightclient.v1.BTCHeaderInfoResponse") } func init() { @@ -763,59 +836,65 @@ func init() { } var fileDescriptor_3961270631e52721 = []byte{ - // 823 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x96, 0xcf, 0x4f, 0x13, 0x4d, - 0x18, 0xc7, 0xbb, 0xfc, 0xe8, 0x0b, 0xc3, 0xfb, 0xe6, 0xd5, 0xb1, 0x6a, 0xd9, 0x98, 0x02, 0x8b, - 0x94, 0x02, 0xb2, 0x43, 0x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 0x86, 0x0a, 0x65, 0x65, 0x34, 0x54, 0x38, - 0xfb, 0x62, 0x41, 0x41, 0xa0, 0xbd, 0x57, 0xd0, 0x58, 0xf0, 0xce, 0x62, 0x12, 0xe5, 0xd3, 0x95, - 0x56, 0xea, 0x4a, 0x7c, 0x01, 0xa0, 0x2d, 0x09, 0xb4, 0x39, 0x3c, 0xdb, 0x07, 0x2d, 0x88, 0x06, - 0xfc, 0x45, 0x41, 0xff, 0x85, 0x02, 0x05, 0x5f, 0x8d, 0x6b, 0xd8, 0x19, 0x58, 0xea, 0xb5, 0x01, - 0x55, 0xc0, 0xba, 0x22, 0x58, 0x17, 0x71, 0x2e, 0x06, 0xab, 0xc4, 0xfb, 0xa0, 0xa0, 0xf1, 0x56, - 0xca, 0xe0, 0xc8, 0xe9, 0x74, 0x47, 0x9e, 0x9a, 0x1f, 0x40, 0x01, 0x90, 0x57, 0x04, 0x64, 0x16, - 0x5f, 0xee, 0x03, 0x59, 0xa7, 0x96, 0xfc, 0x9f, 0x81, 0x5f, 0x2b, 0x68, 0xb8, 0x62, 0x39, 0x78, - 0x31, 0xca, 0xa8, 0x1d, 0x42, 0xea, 0x52, 0xac, 0x5a, 0xc0, 0xc9, 0x0a, 0x9c, 0x69, 0x9c, 0xe9, - 0x83, 0xe3, 0x59, 0x0e, 0xfe, 0xa8, 0x20, 0xd4, 0x4e, 0x19, 0x1c, 0x79, 0xf0, 0x9e, 0xac, 0x52, - 0x0b, 0x83, 0x48, 0x80, 0x6e, 0x59, 0xd0, 0xcd, 0xe3, 0xb9, 0x3e, 0x74, 0x7e, 0x64, 0xcb, 0xc4, - 0xc2, 0x9f, 0x15, 0x34, 0xd1, 0x11, 0x3f, 0x38, 0xd2, 0xb2, 0x37, 0xda, 0xd4, 0xd5, 0x81, 0x34, - 0xc0, 0x49, 0x04, 0xe7, 0x02, 0x9e, 0xef, 0xc3, 0x29, 0x32, 0x8f, 0xbc, 0xf0, 0xdf, 0xe3, 0x97, - 0xc5, 0xd2, 0xde, 0x61, 0x46, 0xd9, 0x3f, 0xcc, 0x28, 0x3f, 0x0f, 0x33, 0xca, 0x9b, 0xa3, 0x4c, - 0x62, 0xff, 0x28, 0x93, 0xf8, 0x7e, 0x94, 0x49, 0x3c, 0xba, 0x1e, 0xf5, 0xf9, 0xf0, 0xbc, 0xbb, - 0xb7, 0xf8, 0x9e, 0xa8, 0x26, 0xc5, 0xa7, 0xe2, 0xea, 0x9f, 0x00, 0x00, 0x00, 0xff, 0xff, 0x25, - 0x1e, 0x8e, 0x7d, 0x26, 0x0b, 0x00, 0x00, + // 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, 0xa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, 0xe6, 0xbc, 0x49, 0x57, 0x87, 0x70, 0x6a, 0x8b, 0x66, + 0x5f, 0xaa, 0xe7, 0xf8, 0xab, 0x86, 0xfb, 0xf0, 0xac, 0x4a, 0x1e, 0x9d, 0x55, 0xc9, 0x3f, 0x67, + 0x55, 0xf2, 0xed, 0x79, 0x75, 0xe2, 0xd1, 0x79, 0x75, 0xe2, 0xef, 0xf3, 0xea, 0xc4, 0xa7, 0xb7, + 0x8b, 0xbf, 0x83, 0x8e, 0xfb, 0xab, 0xeb, 0x0f, 0x23, 0xaf, 0xac, 0xbf, 0x7b, 0xb7, 0xfe, 0x0f, + 0x00, 0x00, 0xff, 0xff, 0x10, 0x5c, 0x80, 0x4f, 0xde, 0x0b, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -838,7 +917,7 @@ type QueryClient interface { Contains(ctx context.Context, in *QueryContainsRequest, opts ...grpc.CallOption) (*QueryContainsResponse, error) // ContainsBytes is a temporary method that // checks whether a hash is maintained by the module. - // See discussion at https://github.com/babylonchain/babylon/pull/132 + // See discussion at https://github.com/babylonlabs-io/babylon/pull/132 // for more details. ContainsBytes(ctx context.Context, in *QueryContainsBytesRequest, opts ...grpc.CallOption) (*QueryContainsBytesResponse, error) // MainChain returns the canonical chain @@ -943,7 +1022,7 @@ type QueryServer interface { Contains(context.Context, *QueryContainsRequest) (*QueryContainsResponse, error) // ContainsBytes is a temporary method that // checks whether a hash is maintained by the module. - // See discussion at https://github.com/babylonchain/babylon/pull/132 + // See discussion at https://github.com/babylonlabs-io/babylon/pull/132 // for more details. ContainsBytes(context.Context, *QueryContainsBytesRequest) (*QueryContainsBytesResponse, error) // MainChain returns the canonical chain @@ -1705,6 +1784,58 @@ func (m *QueryHeaderDepthResponse) MarshalToSizedBuffer(dAtA []byte) (int, error return len(dAtA) - i, nil } +func (m *BTCHeaderInfoResponse) 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 *BTCHeaderInfoResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *BTCHeaderInfoResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + { + size := m.Work.Size() + i -= size + if _, err := m.Work.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x22 + if m.Height != 0 { + i = encodeVarintQuery(dAtA, i, uint64(m.Height)) + i-- + dAtA[i] = 0x18 + } + if len(m.HashHex) > 0 { + i -= len(m.HashHex) + copy(dAtA[i:], m.HashHex) + i = encodeVarintQuery(dAtA, i, uint64(len(m.HashHex))) + i-- + dAtA[i] = 0x12 + } + if len(m.HeaderHex) > 0 { + i -= len(m.HeaderHex) + copy(dAtA[i:], m.HeaderHex) + i = encodeVarintQuery(dAtA, i, uint64(len(m.HeaderHex))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + func encodeVarintQuery(dAtA []byte, offset int, v uint64) int { offset -= sovQuery(v) base := offset @@ -1919,6 +2050,28 @@ func (m *QueryHeaderDepthResponse) Size() (n int) { return n } +func (m *BTCHeaderInfoResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.HeaderHex) + if l > 0 { + n += 1 + l + sovQuery(uint64(l)) + } + l = len(m.HashHex) + if l > 0 { + n += 1 + l + sovQuery(uint64(l)) + } + if m.Height != 0 { + n += 1 + sovQuery(uint64(m.Height)) + } + l = m.Work.Size() + n += 1 + l + sovQuery(uint64(l)) + return n +} + func sovQuery(x uint64) (n int) { return (math_bits.Len64(x|1) + 6) / 7 } @@ -2202,7 +2355,7 @@ func (m *QueryHashesResponse) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - var v github_com_babylonchain_babylon_types.BTCHeaderHashBytes + var v github_com_babylonlabs_io_babylon_types.BTCHeaderHashBytes m.Hashes = append(m.Hashes, v) if err := m.Hashes[len(m.Hashes)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err @@ -2323,7 +2476,7 @@ func (m *QueryContainsRequest) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - var v github_com_babylonchain_babylon_types.BTCHeaderHashBytes + var v github_com_babylonlabs_io_babylon_types.BTCHeaderHashBytes m.Hash = &v if err := m.Hash.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err @@ -2718,7 +2871,7 @@ func (m *QueryMainChainResponse) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.Headers = append(m.Headers, &BTCHeaderInfo{}) + m.Headers = append(m.Headers, &BTCHeaderInfoResponse{}) if err := m.Headers[len(m.Headers)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } @@ -2889,7 +3042,7 @@ func (m *QueryTipResponse) Unmarshal(dAtA []byte) error { return io.ErrUnexpectedEOF } if m.Header == nil { - m.Header = &BTCHeaderInfo{} + m.Header = &BTCHeaderInfoResponse{} } if err := m.Header.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err @@ -3025,7 +3178,7 @@ func (m *QueryBaseHeaderResponse) Unmarshal(dAtA []byte) error { return io.ErrUnexpectedEOF } if m.Header == nil { - m.Header = &BTCHeaderInfo{} + m.Header = &BTCHeaderInfoResponse{} } if err := m.Header.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err @@ -3203,6 +3356,173 @@ func (m *QueryHeaderDepthResponse) Unmarshal(dAtA []byte) error { } return nil } +func (m *BTCHeaderInfoResponse) 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: BTCHeaderInfoResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: BTCHeaderInfoResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field HeaderHex", 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.HeaderHex = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field HashHex", 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.HashHex = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 3: + 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 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Work", 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 + } + if err := m.Work.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 skipQuery(dAtA []byte) (n int, err error) { l := len(dAtA) iNdEx := 0 diff --git a/x/btclightclient/types/tx.pb.go b/x/btclightclient/types/tx.pb.go index 3f22f09f1..4527a6b07 100644 --- a/x/btclightclient/types/tx.pb.go +++ b/x/btclightclient/types/tx.pb.go @@ -6,7 +6,7 @@ package types import ( context "context" fmt "fmt" - github_com_babylonchain_babylon_types "github.com/babylonchain/babylon/types" + github_com_babylonlabs_io_babylon_types "github.com/babylonlabs-io/babylon/types" _ "github.com/cosmos/cosmos-proto" _ "github.com/cosmos/cosmos-sdk/types/msgservice" _ "github.com/cosmos/gogoproto/gogoproto" @@ -33,8 +33,8 @@ const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package // MsgInsertHeaders defines the message for multiple incoming header bytes type MsgInsertHeaders struct { - Signer string `protobuf:"bytes,1,opt,name=signer,proto3" json:"signer,omitempty"` - Headers []github_com_babylonchain_babylon_types.BTCHeaderBytes `protobuf:"bytes,2,rep,name=headers,proto3,customtype=github.com/babylonchain/babylon/types.BTCHeaderBytes" json:"headers,omitempty"` + Signer string `protobuf:"bytes,1,opt,name=signer,proto3" json:"signer,omitempty"` + Headers []github_com_babylonlabs_io_babylon_types.BTCHeaderBytes `protobuf:"bytes,2,rep,name=headers,proto3,customtype=github.com/babylonlabs-io/babylon/types.BTCHeaderBytes" json:"headers,omitempty"` } func (m *MsgInsertHeaders) Reset() { *m = MsgInsertHeaders{} } @@ -223,35 +223,35 @@ func init() { } var fileDescriptor_5f638eee60234021 = []byte{ - // 443 bytes of a gzipped FileDescriptorProto + // 445 bytes of a gzipped FileDescriptorProto 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x52, 0x4a, 0x4a, 0x4c, 0xaa, 0xcc, 0xc9, 0xcf, 0xd3, 0x4f, 0x2a, 0x49, 0xce, 0xc9, 0x4c, 0xcf, 0x00, 0x91, 0xa9, 0x79, 0x25, 0xfa, 0x65, 0x86, 0xfa, 0x25, 0x15, 0x7a, 0x05, 0x45, 0xf9, 0x25, 0xf9, 0x42, 0x92, 0x50, 0x35, 0x7a, 0xa8, 0x6a, 0xf4, 0xca, 0x0c, 0xa5, 0x44, 0xd2, 0xf3, 0xd3, 0xf3, 0xc1, 0xaa, 0xf4, 0x41, 0x2c, 0x88, 0x06, 0x29, 0xf1, 0xe4, 0xfc, 0xe2, 0xdc, 0xfc, 0x62, 0xfd, 0xdc, 0xe2, 0x74, 0x90, 0x41, 0xb9, 0xc5, 0xe9, 0x50, 0x09, 0x35, 0xdc, 0xb6, 0x15, 0x24, 0x16, 0x25, 0xe6, 0x16, 0x43, - 0xd5, 0x49, 0x42, 0x0c, 0x88, 0x87, 0x98, 0x0c, 0xe1, 0x40, 0xa4, 0x94, 0xba, 0x19, 0xb9, 0x04, + 0xd5, 0x49, 0x42, 0x0c, 0x88, 0x87, 0x98, 0x0c, 0xe1, 0x40, 0xa4, 0x94, 0x7a, 0x19, 0xb9, 0x04, 0x7c, 0x8b, 0xd3, 0x3d, 0xf3, 0x8a, 0x53, 0x8b, 0x4a, 0x3c, 0x52, 0x13, 0x53, 0x52, 0x8b, 0x8a, 0x85, 0xc4, 0xb8, 0xd8, 0x8a, 0x33, 0xd3, 0xf3, 0x52, 0x8b, 0x24, 0x18, 0x15, 0x18, 0x35, 0x38, - 0x83, 0xa0, 0x3c, 0xa1, 0x20, 0x2e, 0xf6, 0x0c, 0x88, 0x12, 0x09, 0x26, 0x05, 0x66, 0x0d, 0x1e, - 0x27, 0x8b, 0x5b, 0xf7, 0xe4, 0x4d, 0xd2, 0x33, 0x4b, 0x32, 0x4a, 0x93, 0xf4, 0x92, 0xf3, 0x73, - 0xf5, 0xa1, 0xee, 0x49, 0xce, 0x48, 0xcc, 0xcc, 0x83, 0x71, 0xf4, 0x4b, 0x2a, 0x0b, 0x52, 0x8b, - 0xf5, 0x9c, 0x42, 0x9c, 0x21, 0xc6, 0x3b, 0x55, 0x96, 0xa4, 0x16, 0x07, 0xc1, 0x0c, 0xb2, 0xe2, - 0x6e, 0x7a, 0xbe, 0x41, 0x0b, 0x6a, 0x81, 0x92, 0x14, 0x97, 0x04, 0xba, 0x63, 0x82, 0x52, 0x8b, - 0x0b, 0xf2, 0xf3, 0x8a, 0x53, 0x95, 0x66, 0x31, 0x72, 0xf1, 0xfb, 0x16, 0xa7, 0x87, 0x16, 0xa4, - 0x24, 0x96, 0xa4, 0x06, 0x80, 0xbd, 0x27, 0x64, 0xc6, 0xc5, 0x99, 0x58, 0x5a, 0x92, 0x91, 0x5f, - 0x94, 0x59, 0x52, 0x09, 0x71, 0xab, 0x93, 0xc4, 0xa5, 0x2d, 0xba, 0x22, 0x50, 0x2f, 0x3a, 0xa6, - 0xa4, 0x14, 0xa5, 0x16, 0x17, 0x07, 0x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0xf7, 0xe4, 0xcd, 0xd2, 0x33, 0x4b, 0x32, 0x4a, 0x93, 0xf4, 0x92, 0xf3, 0x73, + 0xf5, 0xa1, 0xee, 0xc9, 0x49, 0x4c, 0x2a, 0xd6, 0xcd, 0xcc, 0x87, 0x71, 0xf5, 0x4b, 0x2a, 0x0b, + 0x52, 0x8b, 0xf5, 0x9c, 0x42, 0x9c, 0x21, 0x16, 0x38, 0x55, 0x96, 0xa4, 0x16, 0x07, 0xc1, 0x8c, + 0xb2, 0xe2, 0x6e, 0x7a, 0xbe, 0x41, 0x0b, 0x6a, 0x85, 0x92, 0x14, 0x97, 0x04, 0xba, 0x73, 0x82, + 0x52, 0x8b, 0x0b, 0xf2, 0xf3, 0x8a, 0x53, 0x95, 0x66, 0x31, 0x72, 0xf1, 0xfb, 0x16, 0xa7, 0x87, + 0x16, 0xa4, 0x24, 0x96, 0xa4, 0x06, 0x80, 0x3d, 0x28, 0x64, 0xc6, 0xc5, 0x99, 0x58, 0x5a, 0x92, + 0x91, 0x5f, 0x94, 0x59, 0x52, 0x09, 0x71, 0xad, 0x93, 0xc4, 0xa5, 0x2d, 0xba, 0x22, 0x50, 0x4f, + 0x3a, 0xa6, 0xa4, 0x14, 0xa5, 0x16, 0x17, 0x07, 0x97, 0x14, 0x65, 0xe6, 0xa5, 0x07, 0x21, 0x94, + 0x0a, 0xd9, 0x73, 0xb1, 0x41, 0x82, 0x48, 0x82, 0x49, 0x81, 0x51, 0x83, 0xdb, 0x48, 0x51, 0x0f, + 0x67, 0xac, 0xe8, 0x41, 0xac, 0x72, 0x62, 0x39, 0x71, 0x4f, 0x9e, 0x21, 0x08, 0xaa, 0xcd, 0x8a, + 0x0f, 0xe4, 0x6a, 0x84, 0x81, 0x4a, 0x92, 0x5c, 0xe2, 0x68, 0x6e, 0x83, 0xb9, 0xdb, 0xe8, 0x23, + 0x23, 0x17, 0xb3, 0x6f, 0x71, 0xba, 0x50, 0x31, 0x17, 0x2f, 0x6a, 0x38, 0x6b, 0xe3, 0xb1, 0x14, + 0x3d, 0x14, 0xa4, 0x8c, 0x49, 0x50, 0x0c, 0x0f, 0x32, 0x06, 0xa1, 0x3c, 0x2e, 0x1e, 0x94, 0x00, + 0xd3, 0xc2, 0x6f, 0x0c, 0xb2, 0x5a, 0x29, 0x23, 0xe2, 0xd5, 0xc2, 0x6c, 0x94, 0x62, 0x6d, 0x78, + 0xbe, 0x41, 0x8b, 0xd1, 0x29, 0xe8, 0xc4, 0x23, 0x39, 0xc6, 0x0b, 0x8f, 0xe4, 0x18, 0x1f, 0x3c, + 0x92, 0x63, 0x9c, 0xf0, 0x58, 0x8e, 0xe1, 0xc2, 0x63, 0x39, 0x86, 0x1b, 0x8f, 0xe5, 0x18, 0xa2, + 0x2c, 0x08, 0xa7, 0x97, 0x0a, 0xf4, 0x04, 0x0d, 0x4e, 0x40, 0x49, 0x6c, 0xe0, 0x24, 0x6b, 0x0c, + 0x08, 0x00, 0x00, 0xff, 0xff, 0x7a, 0xa1, 0x1d, 0x4d, 0x65, 0x03, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -663,7 +663,7 @@ func (m *MsgInsertHeaders) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - var v github_com_babylonchain_babylon_types.BTCHeaderBytes + var v github_com_babylonlabs_io_babylon_types.BTCHeaderBytes m.Headers = append(m.Headers, v) if err := m.Headers[len(m.Headers)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err diff --git a/x/btclightclient/types/work.go b/x/btclightclient/types/work.go index b5ef4148a..3dadf9c1d 100644 --- a/x/btclightclient/types/work.go +++ b/x/btclightclient/types/work.go @@ -2,7 +2,7 @@ package types import ( sdkmath "cosmossdk.io/math" - bbn "github.com/babylonchain/babylon/types" + bbn "github.com/babylonlabs-io/babylon/types" "github.com/btcsuite/btcd/blockchain" "github.com/btcsuite/btcd/wire" ) diff --git a/x/btclightclient/types/work_test.go b/x/btclightclient/types/work_test.go index a68410244..efed2a5ce 100644 --- a/x/btclightclient/types/work_test.go +++ b/x/btclightclient/types/work_test.go @@ -2,8 +2,8 @@ package types_test import ( sdkmath "cosmossdk.io/math" - "github.com/babylonchain/babylon/testutil/datagen" - "github.com/babylonchain/babylon/x/btclightclient/types" + "github.com/babylonlabs-io/babylon/testutil/datagen" + "github.com/babylonlabs-io/babylon/x/btclightclient/types" "math/rand" "testing" ) diff --git a/x/btcstaking/README.md b/x/btcstaking/README.md index 473a7eee5..b07b297d5 100644 --- a/x/btcstaking/README.md +++ b/x/btcstaking/README.md @@ -5,7 +5,7 @@ providers and BTC delegations under them. This includes: - handling requests for creating finality providers, - handling requests for creating BTC delegations, -- handlilng requests for submitting signatures of covenant emulators, +- handling requests for submitting signatures of covenant emulators, - handling requests for unbonding BTC delegations, and - proactively refreshing the active set of finality providers and BTC delegations. @@ -23,25 +23,27 @@ providers and BTC delegations under them. This includes: - [Params](#params) - [Messages](#messages) - [MsgCreateFinalityProvider](#msgcreatefinalityprovider) + - [MsgEditFinalityProvider](#msgeditfinalityprovider) - [MsgCreateBTCDelegation](#msgcreatebtcdelegation) - [MsgAddCovenantSigs](#msgaddcovenantsigs) - [MsgBTCUndelegate](#msgbtcundelegate) - [MsgUpdateParams](#msgupdateparams) + - [MsgSelectiveSlashingEvidence](#msgselectiveslashingevidence) - [BeginBlocker](#beginblocker) - [Events](#events) - [Queries](#queries) ## Concepts -Babylon's Bitcoin Staking protocol allows bitcoin holders to *trustlessly* stake +Babylon's Bitcoin Staking protocol allows bitcoin holders to _trustlessly_ stake their bitcoins for providing economic security to the Babylon chain and other -Proof-of-Stake (PoS) blockchains, *without bridging their bitcoins elsewhere*. +Proof-of-Stake (PoS) blockchains, _without bridging their bitcoins elsewhere_. The protocol consists of the following participants: - **BTC staker (aka delegator)** who delegates their bitcoins to a finality provider in order to obtain staking reward. - **Finality provider** who receives bitcoin delegations and participates in the - *finality vote round* on top of the CometBFT consensus. + _finality vote round_ on top of the CometBFT consensus. - **Covenant emulation committee** who serves as the [covenants](https://covenants.info) to enforce spending conditions on bitcoins staked on Babylon. @@ -53,16 +55,16 @@ follows: 1. A finality provider registers itself on the BTC Staking module. 2. A BTC staker delegates some bitcoins to the finality provider. This involves the following steps: - 1. The BTC staker submits a *staking transaction* to Bitcoin. The staking + 1. The BTC staker submits a _staking transaction_ to Bitcoin. The staking transaction locks its bitcoins for a long period of time and specifies slashing conditions. 2. The BTC staker constructs the following transactions (whose specifications can be found [here](../../docs/staking-script.md)): - - a *slashing transaction* that can spend the staking transaction once the + - a _slashing transaction_ that can spend the staking transaction once the finality provider is slashed, - - an *unbonding transaction* that spends the staking transaction to start + - an _unbonding transaction_ that spends the staking transaction to start the early unbonding process, and - - an *unbonding slashing transaction* that can spend the unbonding + - an _unbonding slashing transaction_ that can spend the unbonding transaction once the finality provider is slashed. The BTC staker pre-signs the slashing transaction and unbonding slashing transaction. 3. Once the staking transaction is confirmed on Bitcoin, the BTC staker sends @@ -103,7 +105,7 @@ message Params { // 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/babylonchain/babylon/types.BIP340PubKey" ]; + 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; @@ -129,6 +131,17 @@ message Params { 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; + + // 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", + (gogoproto.customtype) = "cosmossdk.io/math.LegacyDec", + (gogoproto.nullable) = false + ]; } ``` @@ -144,28 +157,29 @@ finality provider. ```protobuf // FinalityProvider defines a finality provider message FinalityProvider { - // description defines the description terms for the finality provider. - cosmos.staking.v1beta1.Description description = 1; - // commission defines the commission rate of the finality provider. - string commission = 2 [ + // 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" - ]; - // babylon_pk is the Babylon secp256k1 PK of this finality provider - cosmos.crypto.secp256k1.PubKey babylon_pk = 3; - // 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/babylonchain/babylon/types.BIP340PubKey" ]; - // pop is the proof of possession of babylon_pk and btc_pk - ProofOfPossession 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; + ]; + // 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; } ``` @@ -181,81 +195,82 @@ identifies a `BTCDelegation` as creating a BTC delegation requires the staker to submit a staking transaction to Bitcoin. ```protobuf - // BTCDelegation defines a BTC delegation message BTCDelegation { - // babylon_pk is the Babylon secp256k1 PK of this BTC delegation - cosmos.crypto.secp256k1.PubKey babylon_pk = 1; - // 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/babylonchain/babylon/types.BIP340PubKey" ]; - // pop is the proof of possession of babylon_pk and btc_pk - ProofOfPossession 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/babylonchain/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/babylonchain/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; + // 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; } // 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/babylonchain/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/babylonchain/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 undelagate 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_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; } ``` @@ -271,7 +286,7 @@ staking transaction hashes of the delegator's BTC delegations. ```protobuf // BTCDelegatorDelegationIndex is a list of staking tx hashes of BTC delegations from the same delegator. message BTCDelegatorDelegationIndex { - repeated bytes staking_tx_hash_list = 1; + repeated bytes staking_tx_hash_list = 1; } ``` @@ -295,7 +310,7 @@ message Params { // 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/babylonchain/babylon/types.BIP340PubKey" ]; + 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; @@ -340,25 +355,45 @@ provider. It is typically submitted by a finality provider via the [finality provider](https://github.com/babylonchain/finality-provider) program. ```protobuf +// MsgCreateFinalityProvider is the message for creating a finality provider message MsgCreateFinalityProvider { - option (cosmos.msg.v1.signer) = "signer"; - - string signer = 1; - - // description defines the description terms for the finality provider. + option (cosmos.msg.v1.signer) = "addr"; + // addr defines the address of the finality provider that will receive + // the commissions to all the delegations. + 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 finality provider. + // commission defines the commission rate of the finality provider string commission = 3 [ (cosmos_proto.scalar) = "cosmos.Dec", (gogoproto.customtype) = "cosmossdk.io/math.LegacyDec" ]; - // babylon_pk is the Babylon secp256k1 PK of this finality provider - cosmos.crypto.secp256k1.PubKey babylon_pk = 4; // btc_pk is the Bitcoin secp256k1 PK of this finality provider // the PK follows encoding in BIP-340 spec - bytes btc_pk = 5 [ (gogoproto.customtype) = "github.com/babylonchain/babylon/types.BIP340PubKey" ]; - // pop is the proof of possession of babylon_pk and btc_pk - ProofOfPossession pop = 6; + bytes btc_pk = 4 [ (gogoproto.customtype) = "github.com/babylonlabs-io/babylon/types.BIP340PubKey" ]; + // pop is the proof of possession of btc_pk over the FP signer address. + ProofOfPossessionBTC pop = 5; +} +``` + +where `Description` is adapted from Cosmos SDK's staking module and is defined +as follows: + +```protobuf +// Description defines a validator description. +message Description { + option (gogoproto.equal) = true; + + // moniker defines a human-readable name for the validator. + string moniker = 1; + // identity defines an optional identity signature (ex. UPort or Keybase). + string identity = 2; + // website defines an optional website link. + string website = 3; + // security_contact defines an optional email for security contact. + string security_contact = 4; + // details define other optional details. + string details = 5; } ``` @@ -366,11 +401,51 @@ Upon `MsgCreateFinalityProvider`, a Babylon node will execute as follows: 1. Verify a [proof of possession](https://rist.tech.cornell.edu/papers/pkreg.pdf) indicating the - ownership of both the Babylon and Bitcoin secret keys. + ownership of the Bitcoin secret keys over the Babylon address. 2. Ensure the given commission rate is at least the `MinCommissionRate` in the parameters and at most 100%. 3. Ensure the finality provider does not exist already. -4. Create a `FinalityProvider` object and save it to finality provider storage. +4. Ensure the finality provider is not slashed. +5. Ensure the finality provider is registered at an epoch that has been BTC-timestamped. +6. Ensure the committed master public randomness is in the correct format. +7. Create a `FinalityProvider` object and save it to finality provider storage. + +### MsgEditFinalityProvider + +The `MsgEditFinalityProvider` message is used for editing the information of an +existing finality provider, including the commission and the description. It +needs to be submitted by using the Babylon account registered in the finality +provider. + +```protobuf +// MsgEditFinalityProvider is the message for editing an existing finality provider +message MsgEditFinalityProvider { + option (cosmos.msg.v1.signer) = "addr"; + // addr the address of the finality provider that whishes to edit his information. + string addr = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"]; + // btc_pk is the Bitcoin secp256k1 PK of the finality provider to be edited + bytes btc_pk = 2; + // description defines the updated description terms for the finality provider + cosmos.staking.v1beta1.Description description = 3; + // commission defines the updated commission rate of the finality provider + string commission = 4 [ + (cosmos_proto.scalar) = "cosmos.Dec", + (gogoproto.customtype) = "cosmossdk.io/math.LegacyDec" + ]; +} +``` + +Upon `MsgEditFinalityProvider`, a Babylon node will execute as follows: + +1. Validate the formats of the description. +2. Ensure the given commission rate is at least the `MinCommissionRate` in the + parameters and at most 100%. +3. Get the finality provider with the given `btc_pk` from the finality provider + storage. +4. Ensure the address `addr` matches to the address in the finality provider. +5. Change the `description` and `commission` in the finality provider to the + values supplied in the message, and write back the finality provider to the + finality provider storage. ### MsgCreateBTCDelegation @@ -381,62 +456,60 @@ staker](https://github.com/babylonchain/btc-staker) program. ```protobuf // MsgCreateBTCDelegation is the message for creating a BTC delegation message MsgCreateBTCDelegation { - option (cosmos.msg.v1.signer) = "signer"; - - string signer = 1; - // babylon_pk is the Babylon secp256k1 PK of this BTC delegation - cosmos.crypto.secp256k1.PubKey babylon_pk = 2; - // pop is the proof of possession of babylon_pk and btc_pk - ProofOfPossession pop = 3; + option (cosmos.msg.v1.signer) = "staker_addr"; + // staker_addr is the address to receive rewards from BTC delegation. + string staker_addr = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"]; + // pop is the proof of possession of btc_pk by the staker_addr. + ProofOfPossessionBTC pop = 2; // btc_pk is the Bitcoin secp256k1 PK of the BTC delegator - bytes btc_pk = 4 [ (gogoproto.customtype) = "github.com/babylonchain/babylon/types.BIP340PubKey" ]; + bytes btc_pk = 3 [ (gogoproto.customtype) = "github.com/babylonlabs-io/babylon/types.BIP340PubKey" ]; // fp_btc_pk_list is the list of Bitcoin secp256k1 PKs of the finality providers, if there is more than one // finality provider pk it means that delegation is re-staked - repeated bytes fp_btc_pk_list = 5 [ (gogoproto.customtype) = "github.com/babylonchain/babylon/types.BIP340PubKey" ]; + repeated bytes fp_btc_pk_list = 4 [ (gogoproto.customtype) = "github.com/babylonlabs-io/babylon/types.BIP340PubKey" ]; // staking_time is the time lock used in staking transaction - uint32 staking_time = 6; + uint32 staking_time = 5; // staking_value is the amount of satoshis locked in staking output - int64 staking_value = 7; + 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 = 8; + babylon.btccheckpoint.v1.TransactionInfo staking_tx = 7; // slashing_tx is the slashing tx // Note that the tx itself does not contain signatures, which are off-chain. - bytes slashing_tx = 9 [ (gogoproto.customtype) = "BTCSlashingTx" ]; + bytes slashing_tx = 8 [ (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 = 10 [ (gogoproto.customtype) = "github.com/babylonchain/babylon/types.BIP340Signature" ]; + bytes delegator_slashing_sig = 9 [ (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 = 11; + uint32 unbonding_time = 10; // 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 = 12; + bytes unbonding_tx = 11; // 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 = 13; + int64 unbonding_value = 12; // 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 = 14 [ (gogoproto.customtype) = "BTCSlashingTx" ]; + bytes unbonding_slashing_tx = 13 [ (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 = 15 [ (gogoproto.customtype) = "github.com/babylonchain/babylon/types.BIP340Signature" ]; + bytes delegator_unbonding_slashing_sig = 14 [ (gogoproto.customtype) = "github.com/babylonlabs-io/babylon/types.BIP340Signature" ]; } ``` Upon `MsgCreateBTCDelegation`, a Babylon node will execute as follows: 1. Ensure the given unbonding time is larger than `max(MinUnbondingTime, - CheckpointFinalizationTimeout)`, where `MinUnbondingTime` and +CheckpointFinalizationTimeout)`, where `MinUnbondingTime` and `CheckpointFinalizationTimeout` are module parameters from BTC Staking module and BTC Checkpoint module, respectively. 2. Verify a [proof of possession](https://rist.tech.cornell.edu/papers/pkreg.pdf) indicating the - ownership of both the Babylon and Bitcoin secret keys. + ownership of the Bitcoin secret key over the Babylon staker address. 3. Ensure the finality providers that the bitcoins are delegated to are known to Babylon. 4. Verify the staking transaction and slashing transaction, including @@ -482,7 +555,7 @@ message MsgAddCovenantSigs { string signer = 1; // pk is the BTC public key of the covenant member - bytes pk = 2 [ (gogoproto.customtype) = "github.com/babylonchain/babylon/types.BIP340PubKey" ]; + bytes pk = 2 [ (gogoproto.customtype) = "github.com/babylonlabs-io/babylon/types.BIP340PubKey" ]; // staking_tx_hash is the hash of the staking tx. // It uniquely identifies a BTC delegation string staking_tx_hash = 3; @@ -492,7 +565,7 @@ message MsgAddCovenantSigs { repeated bytes slashing_tx_sigs = 4; // unbonding_tx_sig is the signature of the covenant on the unbonding tx submitted to babylon // the signature follows encoding in BIP-340 spec - bytes unbonding_tx_sig = 5 [ (gogoproto.customtype) = "github.com/babylonchain/babylon/types.BIP340Signature" ]; + bytes unbonding_tx_sig = 5 [ (gogoproto.customtype) = "github.com/babylonlabs-io/babylon/types.BIP340Signature" ]; // slashing_unbonding_tx_sigs is a list of adaptor signatures of the covenant // on slashing tx corresponding to unbonding tx submitted to babylon // the order of sigs should respect the order of finality providers @@ -518,7 +591,7 @@ Upon `AddCovenantSigs`, a Babylon node will execute as follows: The `MsgBTCUndelegate` message is used for unbonding bitcoins from a given finality provider. It is typically reported by the [BTC staking -tracker](https://github.com/babylonchain/vigilante-private/tree/dev/btcstaking-tracker) +tracker](https://github.com/babylonchain/vigilante/tree/dev/btcstaking-tracker) program which proactively monitors unbonding transactions on Bitcoin. ```protobuf @@ -534,7 +607,7 @@ message MsgBTCUndelegate { 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/babylonchain/babylon/types.BIP340Signature" ]; + bytes unbonding_tx_sig = 3 [ (gogoproto.customtype) = "github.com/babylonlabs-io/babylon/types.BIP340Signature" ]; } ``` @@ -571,19 +644,70 @@ message MsgUpdateParams { } ``` +### MsgSelectiveSlashingEvidence + +The `MsgSelectiveSlashingEvidence` message is used for submitting evidences for +selective slashing offences. In a selective slashing offence, the adversarial +finality provider chooses a victim BTC delegation, signs its slashing +transaction, and decrypts covenant adaptor signatures to the Schnorr signatures +using its secret key, before submitting this slashing transaction to Bitcoin. By +observing a pair of a [Schnorr +signature](https://github.com/bitcoin/bips/blob/master/bip-0340.mediawiki) and +an [adaptor signature](https://bitcoinops.org/en/topics/adaptor-signatures/) +from the covenant committee, anyone can extract the finality provider's secret +key due to the [adaptor signature +properties](../../crypto/schnorr-adaptor-signature/README.md). + +```proto +// MsgSelectiveSlashingEvidence is the message for handling evidence of selective slashing +// launched by a finality provider +message MsgSelectiveSlashingEvidence { + 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; + // recovered_fp_btc_sk is the BTC SK of the finality provider who + // launches the selective slashing offence. The SK is recovered by + // using a covenant adaptor signature and the corresponding Schnorr + // signature + bytes recovered_fp_btc_sk = 3; +} +``` + +Upon `MsgSelectiveSlashingEvidence`, a Babylon node will execute as follows: + +1. Find the BTC delegation with the given staking transaction hash. +2. Ensure the BTC delegation is active or unbonding. +3. Ensure the given secret key corresponds to the finality provider's public + key. +4. At this point, the finality provider must have done selective slashing. Thus, + slash the finality provider and emit an event `EventSelectiveSlashing` about + this. + +The `MsgSelectiveSlashingEvidence` is typically reported by the [BTC staking +tracker](https://github.com/babylonchain/vigilante/tree/dev/btcstaking-tracker) +program. It keeps monitoring for slashing transactions on Bitcoin. Upon each +slashing transaction, it will try to extract the finality provider's secret key. +If successful, it will construct a `MsgSelectiveSlashingEvidence` message and +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 iterating all 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). 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. -The logic is defined at [x/btcstaking/abci.go]((./abci.go)). +The logic is defined at [x/btcstaking/abci.go](./abci.go). ## Events @@ -594,59 +718,44 @@ at `proto/babylon/btcstaking/v1/events.proto`. // EventNewFinalityProvider is the event emitted when a finality provider is created message EventNewFinalityProvider { FinalityProvider fp = 1; } -// EventNewBTCDelegation is the event emitted when a BTC delegation is created -// NOTE: the BTC delegation is not active thus does not have voting power yet -// only after it receives a covenant signature it becomes activated and has voting power -message EventNewBTCDelegation { BTCDelegation btc_del = 1; } - -// EventActivateBTCDelegation is the event emitted when covenant activates a BTC delegation -// such that the BTC delegation starts to have voting power in its timelock period -message EventActivateBTCDelegation { BTCDelegation btc_del = 1; } - -// EventUnbondingBTCDelegation is the event emitted when an unbonding BTC delegation -// receives all signatures needed for becoming unbonded -message EventUnbondedBTCDelegation { - // 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/babylonchain/babylon/types.BIP340PubKey" ]; - // 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 = 2 [ (gogoproto.customtype) = "github.com/babylonchain/babylon/types.BIP340PubKey" ]; +// 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 { // staking_tx_hash is the hash of the staking tx. - // (fp_pks..., del_pk, staking_tx_hash) uniquely identifies a BTC delegation - string staking_tx_hash = 3; - // unbonding_tx_hash is the hash of the unbonding tx. - string unbonding_tx_hash = 4; - // from_state is the last state the BTC delegation was at - BTCDelegationStatus from_state = 5; + // 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; } -// EventSelectiveSlashing is the event emitted when an adversarial +// 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; } -// SelectiveSlashingEvidence is the evidence that the finality provider -// selectively slashed a BTC delegation -// NOTE: it's possible that a slashed finality provider exploits the -// SelectiveSlashingEvidence endpoint while it is actually slashed due to -// equivocation. But such behaviour does not affect the system's security -// or gives any benefit for the adversary -message SelectiveSlashingEvidence { - // staking_tx_hash is the hash of the staking tx. - // It uniquely identifies a BTC delegation - string staking_tx_hash = 1; - // fp_btc_pk is the BTC PK of the finality provider who - // launches the selective slashing offence - bytes fp_btc_pk = 2 [ (gogoproto.customtype) = "github.com/babylonchain/babylon/types.BIP340PubKey" ]; - // recovered_fp_btc_sk is the finality provider's BTC SK recovered from - // the covenant adaptor/Schnorr signature pair. It is the consequence - // of selective slashing. - bytes recovered_fp_btc_sk = 3; + +// 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; + } } ``` @@ -655,4 +764,5 @@ message SelectiveSlashingEvidence { 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). + diff --git a/x/btcstaking/abci.go b/x/btcstaking/abci.go index b81a4cc7c..210f3ad0d 100644 --- a/x/btcstaking/abci.go +++ b/x/btcstaking/abci.go @@ -4,8 +4,8 @@ import ( "context" "time" - "github.com/babylonchain/babylon/x/btcstaking/keeper" - "github.com/babylonchain/babylon/x/btcstaking/types" + "github.com/babylonlabs-io/babylon/x/btcstaking/keeper" + "github.com/babylonlabs-io/babylon/x/btcstaking/types" abci "github.com/cometbft/cometbft/abci/types" "github.com/cosmos/cosmos-sdk/telemetry" ) diff --git a/x/btcstaking/client/cli/query.go b/x/btcstaking/client/cli/query.go index 9d70db427..7f3b19126 100644 --- a/x/btcstaking/client/cli/query.go +++ b/x/btcstaking/client/cli/query.go @@ -6,7 +6,7 @@ import ( "github.com/cosmos/cosmos-sdk/client/flags" - "github.com/babylonchain/babylon/x/btcstaking/types" + "github.com/babylonlabs-io/babylon/x/btcstaking/types" "github.com/cosmos/cosmos-sdk/client" "github.com/spf13/cobra" ) @@ -23,12 +23,70 @@ func GetQueryCmd(queryRoute string) *cobra.Command { } cmd.AddCommand(CmdQueryParams()) + cmd.AddCommand(CmdFinalityProvider()) cmd.AddCommand(CmdFinalityProviders()) cmd.AddCommand(CmdBTCDelegations()) cmd.AddCommand(CmdFinalityProvidersAtHeight()) cmd.AddCommand(CmdFinalityProviderPowerAtHeight()) cmd.AddCommand(CmdActivatedHeight()) cmd.AddCommand(CmdFinalityProviderDelegations()) + cmd.AddCommand(CmdDelegation()) + + return cmd +} + +func CmdFinalityProvider() *cobra.Command { + cmd := &cobra.Command{ + Use: "finality-provider [fp_btc_pk_hex]", + Short: "retrieve a finality provider", + Args: cobra.ExactArgs(1), + RunE: func(cmd *cobra.Command, args []string) error { + clientCtx := client.GetClientContextFromCmd(cmd) + queryClient := types.NewQueryClient(clientCtx) + res, err := queryClient.FinalityProvider( + cmd.Context(), + &types.QueryFinalityProviderRequest{ + FpBtcPkHex: args[0], + }, + ) + if err != nil { + return err + } + + return clientCtx.PrintProto(res) + }, + } + + flags.AddQueryFlagsToCmd(cmd) + + return cmd +} + +func CmdDelegation() *cobra.Command { + cmd := &cobra.Command{ + Use: "delegation [staking_tx_hash_hex]", + Short: "retrieve a BTC delegation", + Args: cobra.ExactArgs(1), + RunE: func(cmd *cobra.Command, args []string) error { + clientCtx := client.GetClientContextFromCmd(cmd) + queryClient := types.NewQueryClient(clientCtx) + + res, err := queryClient.BTCDelegation( + cmd.Context(), + &types.QueryBTCDelegationRequest{ + StakingTxHashHex: args[0], + }, + ) + + if err != nil { + return err + } + + return clientCtx.PrintProto(res) + }, + } + + flags.AddQueryFlagsToCmd(cmd) return cmd } diff --git a/x/btcstaking/client/cli/query_params.go b/x/btcstaking/client/cli/query_params.go index 1672274c1..bec7606ae 100644 --- a/x/btcstaking/client/cli/query_params.go +++ b/x/btcstaking/client/cli/query_params.go @@ -5,7 +5,7 @@ import ( "github.com/cosmos/cosmos-sdk/client/flags" "github.com/spf13/cobra" - "github.com/babylonchain/babylon/x/btcstaking/types" + "github.com/babylonlabs-io/babylon/x/btcstaking/types" ) func CmdQueryParams() *cobra.Command { diff --git a/x/btcstaking/client/cli/tx.go b/x/btcstaking/client/cli/tx.go index 8dc5e51f9..7ce982784 100644 --- a/x/btcstaking/client/cli/tx.go +++ b/x/btcstaking/client/cli/tx.go @@ -9,14 +9,13 @@ import ( "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/client/flags" "github.com/cosmos/cosmos-sdk/client/tx" - "github.com/cosmos/cosmos-sdk/crypto/keys/secp256k1" stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" "github.com/spf13/cobra" - asig "github.com/babylonchain/babylon/crypto/schnorr-adaptor-signature" - bbn "github.com/babylonchain/babylon/types" - btcctypes "github.com/babylonchain/babylon/x/btccheckpoint/types" - "github.com/babylonchain/babylon/x/btcstaking/types" + 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" ) const ( @@ -39,7 +38,8 @@ func GetTxCmd() *cobra.Command { } cmd.AddCommand( - NewCreateFinalityProvicerCmd(), + NewCreateFinalityProviderCmd(), + NewEditFinalityProviderCmd(), NewCreateBTCDelegationCmd(), NewAddCovenantSigsCmd(), NewBTCUndelegateCmd(), @@ -49,10 +49,10 @@ func GetTxCmd() *cobra.Command { return cmd } -func NewCreateFinalityProvicerCmd() *cobra.Command { +func NewCreateFinalityProviderCmd() *cobra.Command { cmd := &cobra.Command{ - Use: "create-finality-provider [babylon_pk] [btc_pk] [pop]", - Args: cobra.ExactArgs(3), + Use: "create-finality-provider [btc_pk] [pop]", + Args: cobra.ExactArgs(2), Short: "Create a finality provider", Long: strings.TrimSpace( `Create a finality provider.`, // TODO: example @@ -85,33 +85,22 @@ func NewCreateFinalityProvicerCmd() *cobra.Command { return err } - // get Babylon PK - babylonPKBytes, err := hex.DecodeString(args[0]) - if err != nil { - return err - } - var babylonPK secp256k1.PubKey - if err := babylonPK.Unmarshal(babylonPKBytes); err != nil { - return err - } - // get BTC PK - btcPK, err := bbn.NewBIP340PubKeyFromHex(args[1]) + btcPK, err := bbn.NewBIP340PubKeyFromHex(args[0]) if err != nil { return err } // get PoP - pop, err := types.NewPoPFromHex(args[2]) + pop, err := types.NewPoPBTCFromHex(args[1]) if err != nil { return err } msg := types.MsgCreateFinalityProvider{ - Signer: clientCtx.FromAddress.String(), + Addr: clientCtx.FromAddress.String(), Description: &description, Commission: &rate, - BabylonPk: &babylonPK, BtcPk: btcPK, Pop: pop, } @@ -133,13 +122,13 @@ func NewCreateFinalityProvicerCmd() *cobra.Command { return cmd } -func NewCreateBTCDelegationCmd() *cobra.Command { +func NewEditFinalityProviderCmd() *cobra.Command { cmd := &cobra.Command{ - Use: "create-btc-delegation [babylon_pk] [btc_pk] [pop] [staking_tx_info] [fp_pk] [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", + Use: "edit-finality-provider [btc_pk]", + Args: cobra.ExactArgs(1), + Short: "Edit an existing finality provider", Long: strings.TrimSpace( - `Create a BTC delegation.`, // TODO: example + `Edit an existing finality provider.`, // TODO: example ), RunE: func(cmd *cobra.Command, args []string) error { clientCtx, err := client.GetClientTxContext(cmd) @@ -147,97 +136,152 @@ func NewCreateBTCDelegationCmd() *cobra.Command { return err } - // get Babylon PK - babylonPKBytes, err := hex.DecodeString(args[0]) + fs := cmd.Flags() + + // get description + moniker, _ := fs.GetString(FlagMoniker) + identity, _ := fs.GetString(FlagIdentity) + website, _ := fs.GetString(FlagWebsite) + security, _ := fs.GetString(FlagSecurityContact) + details, _ := fs.GetString(FlagDetails) + description := stakingtypes.NewDescription( + moniker, + identity, + website, + security, + details, + ) + // get commission + rateStr, _ := fs.GetString(FlagCommissionRate) + rate, err := sdkmath.LegacyNewDecFromStr(rateStr) + if err != nil { + return err + } + + // get BTC PK + btcPK, err := hex.DecodeString(args[1]) if err != nil { return err } - var babylonPK secp256k1.PubKey - if err := babylonPK.Unmarshal(babylonPKBytes); err != nil { + + msg := types.MsgEditFinalityProvider{ + Addr: clientCtx.FromAddress.String(), + BtcPk: btcPK, + Description: &description, + Commission: &rate, + } + + return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), &msg) + }, + } + + fs := cmd.Flags() + fs.String(FlagMoniker, "", "The finality provider's (optional) moniker") + fs.String(FlagWebsite, "", "The finality provider's (optional) website") + fs.String(FlagSecurityContact, "", "The finality provider's (optional) security contact email") + fs.String(FlagDetails, "", "The finality provider's (optional) details") + fs.String(FlagIdentity, "", "The (optional) identity signature (ex. UPort or Keybase)") + fs.String(FlagCommissionRate, "0", "The initial commission rate percentage") + + flags.AddTxFlagsToCmd(cmd) + + return cmd +} + +func NewCreateBTCDelegationCmd() *cobra.Command { + cmd := &cobra.Command{ + Use: "create-btc-delegation [btc_pk] [pop_hex] [staking_tx_info] [fp_pk] [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), + Short: "Create a BTC delegation", + Long: strings.TrimSpace( + `Create a BTC delegation.`, // TODO: example + ), + RunE: func(cmd *cobra.Command, args []string) error { + clientCtx, err := client.GetClientTxContext(cmd) + if err != nil { return err } // staker pk - btcPK, err := bbn.NewBIP340PubKeyFromHex(args[1]) + btcPK, err := bbn.NewBIP340PubKeyFromHex(args[0]) if err != nil { return err } // get PoP - pop, err := types.NewPoPFromHex(args[2]) + pop, err := types.NewPoPBTCFromHex(args[1]) if err != nil { return err } // get staking tx info - stakingTxInfo, err := btcctypes.NewTransactionInfoFromHex(args[3]) + stakingTxInfo, err := btcctypes.NewTransactionInfoFromHex(args[2]) if err != nil { return err } // TODO: Support multiple finality providers // get finality provider PK - fpPK, err := bbn.NewBIP340PubKeyFromHex(args[4]) + fpPK, err := bbn.NewBIP340PubKeyFromHex(args[3]) if err != nil { return err } // get staking time - stakingTime, err := parseLockTime(args[5]) + stakingTime, err := parseLockTime(args[4]) if err != nil { return err } - stakingValue, err := parseBtcAmount(args[6]) + stakingValue, err := parseBtcAmount(args[5]) if err != nil { return err } // get slashing tx - slashingTx, err := types.NewBTCSlashingTxFromHex(args[7]) + slashingTx, err := types.NewBTCSlashingTxFromHex(args[6]) if err != nil { return err } // get delegator sig on slashing tx - delegatorSlashingSig, err := bbn.NewBIP340SignatureFromHex(args[8]) + delegatorSlashingSig, err := bbn.NewBIP340SignatureFromHex(args[7]) if err != nil { return err } // get unbonding tx - _, unbondingTxBytes, err := bbn.NewBTCTxFromHex(args[9]) + _, unbondingTxBytes, err := bbn.NewBTCTxFromHex(args[8]) if err != nil { return err } // get unbonding slashing tx - unbondingSlashingTx, err := types.NewBTCSlashingTxFromHex(args[10]) + unbondingSlashingTx, err := types.NewBTCSlashingTxFromHex(args[9]) if err != nil { return err } // get staking time - unbondingTime, err := parseLockTime(args[11]) + unbondingTime, err := parseLockTime(args[10]) if err != nil { return err } - unbondingValue, err := parseBtcAmount(args[12]) + unbondingValue, err := parseBtcAmount(args[11]) if err != nil { return err } // get delegator sig on unbonding slashing tx - delegatorUnbondingSlashingSig, err := bbn.NewBIP340SignatureFromHex(args[13]) + delegatorUnbondingSlashingSig, err := bbn.NewBIP340SignatureFromHex(args[12]) if err != nil { return err } msg := types.MsgCreateBTCDelegation{ - Signer: clientCtx.FromAddress.String(), - BabylonPk: &babylonPK, + StakerAddr: clientCtx.FromAddress.String(), BtcPk: btcPK, FpBtcPkList: []bbn.BIP340PubKey{*fpPK}, Pop: pop, diff --git a/x/btcstaking/genesis.go b/x/btcstaking/genesis.go index 4131d8bd4..5d37bec53 100644 --- a/x/btcstaking/genesis.go +++ b/x/btcstaking/genesis.go @@ -2,21 +2,26 @@ package btcstaking import ( "context" - "github.com/babylonchain/babylon/x/btcstaking/keeper" - "github.com/babylonchain/babylon/x/btcstaking/types" + + "github.com/babylonlabs-io/babylon/x/btcstaking/keeper" + "github.com/babylonlabs-io/babylon/x/btcstaking/types" ) // InitGenesis initializes the module's state from a provided genesis state. -func InitGenesis(ctx context.Context, k keeper.Keeper, genState types.GenesisState) { - if err := k.SetParams(ctx, genState.Params); err != nil { +func InitGenesis(ctx context.Context, k keeper.Keeper, gs types.GenesisState) { + if err := gs.Validate(); err != nil { + panic(err) + } + if err := k.InitGenesis(ctx, gs); err != nil { panic(err) } } // ExportGenesis returns the module's exported genesis func ExportGenesis(ctx context.Context, k keeper.Keeper) *types.GenesisState { - genesis := types.DefaultGenesis() - genesis.Params = k.GetParams(ctx) - - return genesis + gs, err := k.ExportGenesis(ctx) + if err != nil { + panic(err) + } + return gs } diff --git a/x/btcstaking/genesis_test.go b/x/btcstaking/genesis_test.go index 9b2dd0a14..dc034bdf3 100644 --- a/x/btcstaking/genesis_test.go +++ b/x/btcstaking/genesis_test.go @@ -3,19 +3,20 @@ package btcstaking_test import ( "testing" - keepertest "github.com/babylonchain/babylon/testutil/keeper" - "github.com/babylonchain/babylon/testutil/nullify" - "github.com/babylonchain/babylon/x/btcstaking" - "github.com/babylonchain/babylon/x/btcstaking/types" + keepertest "github.com/babylonlabs-io/babylon/testutil/keeper" + "github.com/babylonlabs-io/babylon/testutil/nullify" + "github.com/babylonlabs-io/babylon/x/btcstaking" + "github.com/babylonlabs-io/babylon/x/btcstaking/types" "github.com/stretchr/testify/require" ) func TestGenesis(t *testing.T) { + p := types.DefaultParams() genesisState := types.GenesisState{ - Params: types.DefaultParams(), + Params: []*types.Params{&p}, } - k, ctx := keepertest.BTCStakingKeeper(t, 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/bench_test.go b/x/btcstaking/keeper/bench_test.go index 1379984bd..27fe36b65 100644 --- a/x/btcstaking/keeper/bench_test.go +++ b/x/btcstaking/keeper/bench_test.go @@ -8,9 +8,10 @@ import ( "testing" "time" - "github.com/babylonchain/babylon/testutil/datagen" - bsmodule "github.com/babylonchain/babylon/x/btcstaking" - "github.com/babylonchain/babylon/x/btcstaking/types" + "github.com/babylonlabs-io/babylon/testutil/datagen" + btclctypes "github.com/babylonlabs-io/babylon/x/btclightclient/types" + bsmodule "github.com/babylonlabs-io/babylon/x/btcstaking" + "github.com/babylonlabs-io/babylon/x/btcstaking/types" "github.com/golang/mock/gomock" ) @@ -22,7 +23,8 @@ func benchBeginBlock(b *testing.B, numFPs int, numDelsUnderFP int) { defer ctrl.Finish() btclcKeeper := types.NewMockBTCLightClientKeeper(ctrl) btccKeeper := types.NewMockBtcCheckpointKeeper(ctrl) - h := NewHelper(b, btclcKeeper, btccKeeper) + ckptKeeper := types.NewMockCheckpointingKeeper(ctrl) + h := NewHelper(b, btclcKeeper, btccKeeper, ckptKeeper) // set all parameters covenantSKs, _ := h.GenAndApplyParams(r) changeAddress, err := datagen.GenRandomBTCAddress(r, h.Net) @@ -34,10 +36,9 @@ func benchBeginBlock(b *testing.B, numFPs int, numDelsUnderFP int) { fp, err := datagen.GenRandomFinalityProvider(r) h.NoError(err) msg := &types.MsgCreateFinalityProvider{ - Signer: datagen.GenRandomAccount().Address, + Addr: fp.Addr, Description: fp.Description, Commission: fp.Commission, - BabylonPk: fp.BabylonPk, BtcPk: fp.BtcPk, Pop: fp.Pop, } @@ -52,7 +53,7 @@ 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 := h.CreateDelegation( + stakingTxHash, _, _, msgCreateBTCDel, actualDel := h.CreateDelegation( r, fp.BtcPk.MustToBTCPK(), changeAddress.EncodeAddress(), @@ -60,8 +61,6 @@ func benchBeginBlock(b *testing.B, numFPs int, numDelsUnderFP int) { 1000, ) // retrieve BTC delegation in DB - actualDel, err := h.BTCStakingKeeper.GetBTCDelegation(h.Ctx, stakingTxHash) - h.NoError(err) btcDelMap[stakingTxHash] = append(btcDelMap[stakingTxHash], actualDel) // generate and insert new covenant signatures // after that, all BTC delegations will have voting power @@ -69,6 +68,9 @@ func benchBeginBlock(b *testing.B, numFPs int, numDelsUnderFP int) { } } + // mock stuff + h.BTCLightClientKeeper.EXPECT().GetTipInfo(gomock.Eq(h.Ctx)).Return(&btclctypes.BTCHeaderInfo{Height: 30}).AnyTimes() + // Start the CPU profiler cpuProfileFile := fmt.Sprintf("/tmp/btcstaking-beginblock-%d-%d-cpu.pprof", numFPs, numDelsUnderFP) f, err := os.Create(cpuProfileFile) diff --git a/x/btcstaking/keeper/btc_delegations.go b/x/btcstaking/keeper/btc_delegations.go index 74a67fa98..4e98d1a81 100644 --- a/x/btcstaking/keeper/btc_delegations.go +++ b/x/btcstaking/keeper/btc_delegations.go @@ -2,12 +2,140 @@ package keeper import ( "context" + "fmt" + "cosmossdk.io/store/prefix" - "github.com/babylonchain/babylon/x/btcstaking/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" "github.com/btcsuite/btcd/chaincfg/chainhash" "github.com/cosmos/cosmos-sdk/runtime" + sdk "github.com/cosmos/cosmos-sdk/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 { + if err := btcDel.ValidateBasic(); err != nil { + return err + } + + // get staking tx hash + stakingTxHash, err := btcDel.GetStakingTxHash() + if err != nil { + return err + } + + // for each finality provider the delegation restakes to, update its index + for _, fpBTCPK := range btcDel.FpBtcPkList { + fpBTCPK := fpBTCPK // remove when update to go1.22 + // get BTC delegation index under this finality provider + btcDelIndex := k.getBTCDelegatorDelegationIndex(ctx, &fpBTCPK, btcDel.BtcPk) + if btcDelIndex == nil { + btcDelIndex = types.NewBTCDelegatorDelegationIndex() + } + // index staking tx hash of this BTC delegation + if err := btcDelIndex.Add(stakingTxHash); err != nil { + return types.ErrInvalidStakingTx.Wrapf(err.Error()) + } + // save the index + k.setBTCDelegatorDelegationIndex(ctx, &fpBTCPK, btcDel.BtcPk, btcDelIndex) + } + + // 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)) + } + + // NOTE: we don't need to record events for pending BTC delegations since these + // do not affect voting power distribution + + // 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) + + return nil +} + +// addCovenantSigsToBTCDelegation adds signatures from a given covenant member +// to the given BTC delegation +func (k Keeper) addCovenantSigsToBTCDelegation( + ctx sdk.Context, + btcDel *types.BTCDelegation, + covPK *bbn.BIP340PubKey, + parsedSlashingAdaptorSignatures []asig.AdaptorSignature, + unbondingTxSig *bbn.BIP340Signature, + parsedUnbondingSlashingAdaptorSignatures []asig.AdaptorSignature, + params *types.Params, +) { + // All is fine add received signatures to the BTC delegation and BtcUndelegation + btcDel.AddCovenantSigs( + covPK, + parsedSlashingAdaptorSignatures, + unbondingTxSig, + parsedUnbondingSlashingAdaptorSignatures, + ) + + k.setBTCDelegation(ctx, btcDel) + + // 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)) + } + + // 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) + } +} + +// 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, +) { + btcDel.BtcUndelegation.DelegatorUnbondingSig = unbondingTxSig + k.setBTCDelegation(ctx, btcDel) + + // 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) + k.addPowerDistUpdateEvent(ctx, btcTip.Height, unbondedEvent) +} + func (k Keeper) setBTCDelegation(ctx context.Context, btcDel *types.BTCDelegation) { store := k.btcDelegationStore(ctx) stakingTxHash := btcDel.MustGetStakingTxHash() @@ -15,6 +143,21 @@ func (k Keeper) setBTCDelegation(ctx context.Context, btcDel *types.BTCDelegatio store.Set(stakingTxHash[:], btcDelBytes) } +// GetBTCDelegation gets the BTC delegation with a given staking tx hash +func (k Keeper) GetBTCDelegation(ctx context.Context, stakingTxHashStr string) (*types.BTCDelegation, error) { + // decode staking tx hash string + stakingTxHash, err := chainhash.NewHashFromStr(stakingTxHashStr) + if err != nil { + return nil, err + } + btcDel := k.getBTCDelegation(ctx, *stakingTxHash) + if btcDel == nil { + return nil, types.ErrBTCDelegationNotFound + } + + return btcDel, nil +} + func (k Keeper) getBTCDelegation(ctx context.Context, stakingTxHash chainhash.Hash) *types.BTCDelegation { store := k.btcDelegationStore(ctx) btcDelBytes := store.Get(stakingTxHash[:]) diff --git a/x/btcstaking/keeper/btc_delegators.go b/x/btcstaking/keeper/btc_delegators.go index fb96905d6..550a899fa 100644 --- a/x/btcstaking/keeper/btc_delegators.go +++ b/x/btcstaking/keeper/btc_delegators.go @@ -2,162 +2,49 @@ package keeper import ( "context" - "fmt" "github.com/cosmos/cosmos-sdk/runtime" "cosmossdk.io/store/prefix" "github.com/btcsuite/btcd/chaincfg/chainhash" - bbn "github.com/babylonchain/babylon/types" - "github.com/babylonchain/babylon/x/btcstaking/types" + bbn "github.com/babylonlabs-io/babylon/types" + "github.com/babylonlabs-io/babylon/x/btcstaking/types" ) -// AddBTCDelegation indexes the given BTC delegation in the BTC delegator store, and saves -// it under BTC delegation store -func (k Keeper) AddBTCDelegation(ctx context.Context, btcDel *types.BTCDelegation) error { - if err := btcDel.ValidateBasic(); err != nil { - return err - } - - // get staking tx hash - stakingTxHash, err := btcDel.GetStakingTxHash() - if err != nil { - return err - } - - // for each finality provider the delegation restakes to, update its index - for _, fpBTCPK := range btcDel.FpBtcPkList { - var btcDelIndex = types.NewBTCDelegatorDelegationIndex() - if k.hasBTCDelegatorDelegations(ctx, &fpBTCPK, btcDel.BtcPk) { - btcDelIndex, err = k.getBTCDelegatorDelegationIndex(ctx, &fpBTCPK, btcDel.BtcPk) - if err != nil { - // this can only be a programming error - panic(fmt.Errorf("failed to get BTC delegations while hasBTCDelegatorDelegations returns true")) - } - } - - // index staking tx hash of this BTC delegation - if err := btcDelIndex.Add(stakingTxHash); err != nil { - return types.ErrInvalidStakingTx.Wrapf(err.Error()) - } - // save the index - store := k.btcDelegatorStore(ctx, &fpBTCPK) - delBTCPKBytes := btcDel.BtcPk.MustMarshal() - btcDelIndexBytes := k.cdc.MustMarshal(btcDelIndex) - store.Set(delBTCPKBytes, btcDelIndexBytes) - } - - // save this BTC delegation - k.setBTCDelegation(ctx, btcDel) - - return nil -} - -// IterateBTCDelegations iterates all BTC delegations under a given finality provider -func (k Keeper) IterateBTCDelegations(ctx context.Context, fpBTCPK *bbn.BIP340PubKey, handler func(btcDel *types.BTCDelegation) bool) { - btcDelIter := k.btcDelegatorStore(ctx, fpBTCPK).Iterator(nil, nil) - defer btcDelIter.Close() - for ; btcDelIter.Valid(); btcDelIter.Next() { - // unmarshal delegator's delegation index - var btcDelIndex types.BTCDelegatorDelegationIndex - k.cdc.MustUnmarshal(btcDelIter.Value(), &btcDelIndex) - // retrieve and process each of the BTC delegation - for _, stakingTxHashBytes := range btcDelIndex.StakingTxHashList { - stakingTxHash, err := chainhash.NewHash(stakingTxHashBytes) - if err != nil { - panic(err) // only programming error is possible - } - btcDel := k.getBTCDelegation(ctx, *stakingTxHash) - shouldContinue := handler(btcDel) - if !shouldContinue { - return - } - } - } -} - -func (k Keeper) IterateBTCDelsKeys(ctx context.Context, handler func(key chainhash.Hash, delegation *types.BTCDelegation) bool) { - deldIter := k.btcDelegationStore(ctx).Iterator(nil, nil) - defer deldIter.Close() - - for ; deldIter.Valid(); deldIter.Next() { - var deld types.BTCDelegation - k.cdc.MustUnmarshal(deldIter.Value(), &deld) - hash, err := chainhash.NewHash(deldIter.Key()) - if err != nil { - panic(err) - } - - shouldContinue := handler(*hash, &deld) - if !shouldContinue { - return - } - } -} - -func (k Keeper) IterateBTCDelegationsHashes(ctx context.Context, fpBTCPK *bbn.BIP340PubKey, handler func(hash chainhash.Hash) bool) { - btcDelIter := k.btcDelegatorStore(ctx, fpBTCPK).Iterator(nil, nil) - defer btcDelIter.Close() - for ; btcDelIter.Valid(); btcDelIter.Next() { - // unmarshal delegator's delegation index - var btcDelIndex types.BTCDelegatorDelegationIndex - k.cdc.MustUnmarshal(btcDelIter.Value(), &btcDelIndex) - // retrieve and process each of the BTC delegation - for _, stakingTxHashBytes := range btcDelIndex.StakingTxHashList { - stakingTxHash, err := chainhash.NewHash(stakingTxHashBytes) - if err != nil { - panic(err) // only programming error is possible - } - - shouldContinue := handler(*stakingTxHash) - - if !shouldContinue { - return - } - } - } -} - -// hasBTCDelegatorDelegations checks if the given BTC delegator has any BTC delegations under a given finality provider -func (k Keeper) hasBTCDelegatorDelegations(ctx context.Context, fpBTCPK *bbn.BIP340PubKey, delBTCPK *bbn.BIP340PubKey) bool { - fpBTCPKBytes := fpBTCPK.MustMarshal() - delBTCPKBytes := delBTCPK.MustMarshal() - - if !k.HasFinalityProvider(ctx, fpBTCPKBytes) { - return false - } - store := k.btcDelegatorStore(ctx, fpBTCPK) - return store.Has(delBTCPKBytes) -} - // getBTCDelegatorDelegationIndex gets the BTC delegation index with a given BTC PK under a given finality provider -func (k Keeper) getBTCDelegatorDelegationIndex(ctx context.Context, fpBTCPK *bbn.BIP340PubKey, delBTCPK *bbn.BIP340PubKey) (*types.BTCDelegatorDelegationIndex, error) { +func (k Keeper) getBTCDelegatorDelegationIndex(ctx context.Context, fpBTCPK *bbn.BIP340PubKey, delBTCPK *bbn.BIP340PubKey) *types.BTCDelegatorDelegationIndex { fpBTCPKBytes := fpBTCPK.MustMarshal() delBTCPKBytes := delBTCPK.MustMarshal() - store := k.btcDelegatorStore(ctx, fpBTCPK) + store := k.btcDelegatorFpStore(ctx, fpBTCPK) // ensure the finality provider exists if !k.HasFinalityProvider(ctx, fpBTCPKBytes) { - return nil, types.ErrFpNotFound + return nil } // ensure BTC delegator exists if !store.Has(delBTCPKBytes) { - return nil, types.ErrBTCDelegatorNotFound + return nil } // get and unmarshal var btcDelIndex types.BTCDelegatorDelegationIndex btcDelIndexBytes := store.Get(delBTCPKBytes) k.cdc.MustUnmarshal(btcDelIndexBytes, &btcDelIndex) - return &btcDelIndex, nil + return &btcDelIndex +} + +func (k Keeper) setBTCDelegatorDelegationIndex(ctx context.Context, fpBTCPK, delBTCPK *bbn.BIP340PubKey, btcDelIndex *types.BTCDelegatorDelegationIndex) { + store := k.btcDelegatorFpStore(ctx, fpBTCPK) + btcDelIndexBytes := k.cdc.MustMarshal(btcDelIndex) + store.Set(*delBTCPK, btcDelIndexBytes) } // getBTCDelegatorDelegations gets the BTC delegations with a given BTC PK under a given finality provider -func (k Keeper) getBTCDelegatorDelegations(ctx context.Context, fpBTCPK *bbn.BIP340PubKey, delBTCPK *bbn.BIP340PubKey) (*types.BTCDelegatorDelegations, error) { - btcDelIndex, err := k.getBTCDelegatorDelegationIndex(ctx, fpBTCPK, delBTCPK) - if err != nil { - return nil, err +func (k Keeper) getBTCDelegatorDelegations(ctx context.Context, fpBTCPK *bbn.BIP340PubKey, delBTCPK *bbn.BIP340PubKey) *types.BTCDelegatorDelegations { + btcDelIndex := k.getBTCDelegatorDelegationIndex(ctx, fpBTCPK, delBTCPK) + if btcDelIndex == nil { + return nil } // get BTC delegation from each staking tx hash btcDels := []*types.BTCDelegation{} @@ -170,32 +57,23 @@ func (k Keeper) getBTCDelegatorDelegations(ctx context.Context, fpBTCPK *bbn.BIP btcDel := k.getBTCDelegation(ctx, *stakingTxHash) btcDels = append(btcDels, btcDel) } - return &types.BTCDelegatorDelegations{Dels: btcDels}, nil -} - -// GetBTCDelegation gets the BTC delegation with a given staking tx hash -func (k Keeper) GetBTCDelegation(ctx context.Context, stakingTxHashStr string) (*types.BTCDelegation, error) { - // decode staking tx hash string - stakingTxHash, err := chainhash.NewHashFromStr(stakingTxHashStr) - if err != nil { - return nil, err - } - - // find BTC delegation from KV store - btcDel := k.getBTCDelegation(ctx, *stakingTxHash) - if btcDel == nil { - return nil, types.ErrBTCDelegationNotFound - } - - return btcDel, nil + return &types.BTCDelegatorDelegations{Dels: btcDels} } -// btcDelegatorStore returns the KVStore of the BTC delegators +// btcDelegatorFpStore returns the KVStore of the BTC delegators // prefix: BTCDelegatorKey || finality provider's Bitcoin secp256k1 PK // key: delegator's Bitcoin secp256k1 PK // value: BTCDelegatorDelegationIndex (a list of BTCDelegations' staking tx hashes) -func (k Keeper) btcDelegatorStore(ctx context.Context, fpBTCPK *bbn.BIP340PubKey) prefix.Store { - storeAdapter := runtime.KVStoreAdapter(k.storeService.OpenKVStore(ctx)) - delegationStore := prefix.NewStore(storeAdapter, types.BTCDelegatorKey) +func (k Keeper) btcDelegatorFpStore(ctx context.Context, fpBTCPK *bbn.BIP340PubKey) prefix.Store { + delegationStore := k.btcDelegatorStore(ctx) return prefix.NewStore(delegationStore, fpBTCPK.MustMarshal()) } + +// btcDelegatorFpStore returns the KVStore of the BTC delegators +// prefix: BTCDelegatorKey +// key: finality provider's Bitcoin secp256k1 PK || delegator's Bitcoin secp256k1 PK +// value: BTCDelegatorDelegationIndex (a list of BTCDelegations' staking tx hashes) +func (k Keeper) btcDelegatorStore(ctx context.Context) prefix.Store { + storeAdapter := runtime.KVStoreAdapter(k.storeService.OpenKVStore(ctx)) + return prefix.NewStore(storeAdapter, types.BTCDelegatorKey) +} diff --git a/x/btcstaking/keeper/btc_height_index.go b/x/btcstaking/keeper/btc_height_index.go index 9ed5e3961..1f7adcc64 100644 --- a/x/btcstaking/keeper/btc_height_index.go +++ b/x/btcstaking/keeper/btc_height_index.go @@ -4,7 +4,7 @@ import ( "context" "cosmossdk.io/store/prefix" - "github.com/babylonchain/babylon/x/btcstaking/types" + "github.com/babylonlabs-io/babylon/x/btcstaking/types" "github.com/cosmos/cosmos-sdk/runtime" sdk "github.com/cosmos/cosmos-sdk/types" ) @@ -21,16 +21,18 @@ func (k Keeper) IndexBTCHeight(ctx context.Context) { store.Set(sdk.Uint64ToBigEndian(babylonHeight), sdk.Uint64ToBigEndian(btcHeight)) } -func (k Keeper) GetBTCHeightAtBabylonHeight(ctx context.Context, babylonHeight uint64) (uint64, error) { +func (k Keeper) GetBTCHeightAtBabylonHeight(ctx context.Context, babylonHeight uint64) uint64 { store := k.btcHeightStore(ctx) btcHeightBytes := store.Get(sdk.Uint64ToBigEndian(babylonHeight)) if len(btcHeightBytes) == 0 { - return 0, types.ErrBTCHeightNotFound + // if the previous height is not indexed (which might happen at genesis), + // use the base header + return k.btclcKeeper.GetBaseBTCHeader(ctx).Height } - return sdk.BigEndianToUint64(btcHeightBytes), nil + return sdk.BigEndianToUint64(btcHeightBytes) } -func (k Keeper) GetCurrentBTCHeight(ctx context.Context) (uint64, error) { +func (k Keeper) GetCurrentBTCHeight(ctx context.Context) uint64 { 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 27fdf2bc9..a40b5d4d3 100644 --- a/x/btcstaking/keeper/btc_height_index_test.go +++ b/x/btcstaking/keeper/btc_height_index_test.go @@ -4,10 +4,10 @@ import ( "math/rand" "testing" - "github.com/babylonchain/babylon/testutil/datagen" - keepertest "github.com/babylonchain/babylon/testutil/keeper" - btclctypes "github.com/babylonchain/babylon/x/btclightclient/types" - "github.com/babylonchain/babylon/x/btcstaking/types" + "github.com/babylonlabs-io/babylon/testutil/datagen" + keepertest "github.com/babylonlabs-io/babylon/testutil/keeper" + btclctypes "github.com/babylonlabs-io/babylon/x/btclightclient/types" + "github.com/babylonlabs-io/babylon/x/btcstaking/types" "github.com/golang/mock/gomock" "github.com/stretchr/testify/require" ) @@ -22,7 +22,7 @@ func FuzzBTCHeightIndex(f *testing.F) { // mock BTC light client btclcKeeper := types.NewMockBTCLightClientKeeper(ctrl) - keeper, ctx := keepertest.BTCStakingKeeper(t, btclcKeeper, nil) + keeper, ctx := keepertest.BTCStakingKeeper(t, btclcKeeper, nil, nil) // randomise Babylon height and BTC height babylonHeight := datagen.RandomInt(r, 100) @@ -32,12 +32,10 @@ func FuzzBTCHeightIndex(f *testing.F) { keeper.IndexBTCHeight(ctx) // assert BTC height - actualBtcHeight, err := keeper.GetBTCHeightAtBabylonHeight(ctx, babylonHeight) - require.NoError(t, err) + actualBtcHeight := keeper.GetBTCHeightAtBabylonHeight(ctx, babylonHeight) require.Equal(t, btcHeight, actualBtcHeight) // assert current BTC height - curBtcHeight, err := keeper.GetCurrentBTCHeight(ctx) - require.NoError(t, err) + curBtcHeight := keeper.GetCurrentBTCHeight(ctx) require.Equal(t, btcHeight, curBtcHeight) }) } diff --git a/x/btcstaking/keeper/finality_providers.go b/x/btcstaking/keeper/finality_providers.go index 01b7e0c77..f590ffc94 100644 --- a/x/btcstaking/keeper/finality_providers.go +++ b/x/btcstaking/keeper/finality_providers.go @@ -4,11 +4,11 @@ import ( "context" "fmt" + "cosmossdk.io/store/prefix" "github.com/cosmos/cosmos-sdk/runtime" sdk "github.com/cosmos/cosmos-sdk/types" - "cosmossdk.io/store/prefix" - "github.com/babylonchain/babylon/x/btcstaking/types" + "github.com/babylonlabs-io/babylon/x/btcstaking/types" ) // SetFinalityProvider adds the given finality provider to KVStore @@ -39,20 +39,52 @@ func (k Keeper) GetFinalityProvider(ctx context.Context, fpBTCPK []byte) (*types // SlashFinalityProvider slashes a finality provider with the given PK // A slashed finality provider will not have voting power func (k Keeper) SlashFinalityProvider(ctx context.Context, fpBTCPK []byte) error { + // ensure finality provider exists fp, err := k.GetFinalityProvider(ctx, fpBTCPK) if err != nil { return err } + + // ensure finality provider is not slashed yet if fp.IsSlashed() { return types.ErrFpAlreadySlashed } + + // set finality provider to be slashed fp.SlashedBabylonHeight = uint64(sdk.UnwrapSDKContext(ctx).HeaderInfo().Height) btcTip := k.btclcKeeper.GetTipInfo(ctx) if btcTip == nil { - panic(fmt.Errorf("failed to get current BTC tip")) + return fmt.Errorf("failed to get current BTC tip") } fp.SlashedBtcHeight = btcTip.Height k.SetFinalityProvider(ctx, fp) + + // record slashed event. The next `BeginBlock` will consume this + // event for updating the finality provider set + powerUpdateEvent := types.NewEventPowerDistUpdateWithSlashedFP(fp.BtcPk) + k.addPowerDistUpdateEvent(ctx, btcTip.Height, powerUpdateEvent) + + return nil +} + +// RevertSluggishFinalityProvider sets the Sluggish flag of the given finality provider +// to false +func (k Keeper) RevertSluggishFinalityProvider(ctx context.Context, fpBTCPK []byte) error { + // ensure finality provider exists + fp, err := k.GetFinalityProvider(ctx, fpBTCPK) + if err != nil { + return err + } + + // ignore the finality provider is already slashed + // or detected as sluggish + if fp.IsSlashed() || fp.IsSluggish() { + return nil + } + + fp.Sluggish = false + k.SetFinalityProvider(ctx, fp) + return nil } diff --git a/x/btcstaking/keeper/genesis.go b/x/btcstaking/keeper/genesis.go new file mode 100644 index 000000000..1e4a59a58 --- /dev/null +++ b/x/btcstaking/keeper/genesis.go @@ -0,0 +1,299 @@ +package keeper + +import ( + "context" + "fmt" + + 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" +) + +// InitGenesis initializes the module's state from a provided genesis state. +func (k Keeper) InitGenesis(ctx context.Context, gs types.GenesisState) error { + // save all past params versions + for _, p := range gs.Params { + params := p + if err := k.SetParams(ctx, *params); err != nil { + return err + } + } + + for _, fp := range gs.FinalityProviders { + k.SetFinalityProvider(ctx, fp) + } + + for _, btcDel := range gs.BtcDelegations { + 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) + } + + for _, del := range gs.BtcDelegators { + k.setBTCDelegatorDelegationIndex(ctx, del.FpBtcPk, del.DelBtcPk, del.Idx) + } + + // Events are generated on block `N` to be processed at block `N+1` + // When ExportGenesis is called the node already stopped at block N. + // In this case the events on the state would refer to the block `N+1` + // Since InitGenesis occurs before BeginBlock, the genesis state would be properly + // stored in the KV store for when BeginBlock process the events. + for _, evt := range gs.Events { + if err := k.setEventIdx(ctx, evt); err != nil { + return err + } + } + + for _, vpCache := range gs.VpDstCache { + k.setVotingPowerDistCache(ctx, vpCache.BlockHeight, vpCache.VpDistribution) + } + + return nil +} + +// ExportGenesis returns the module's exported genesis +func (k Keeper) ExportGenesis(ctx context.Context) (*types.GenesisState, error) { + fps, err := k.finalityProviders(ctx) + if err != nil { + return nil, err + } + + dels, err := k.btcDelegations(ctx) + if err != nil { + 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 + } + + evts, err := k.eventIdxs(ctx) + if err != nil { + 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 +} + +func (k Keeper) finalityProviders(ctx context.Context) ([]*types.FinalityProvider, error) { + fps := make([]*types.FinalityProvider, 0) + iter := k.finalityProviderStore(ctx).Iterator(nil, nil) + defer iter.Close() + + for ; iter.Valid(); iter.Next() { + var fp types.FinalityProvider + if err := fp.Unmarshal(iter.Value()); err != nil { + return nil, err + } + fps = append(fps, &fp) + } + + return fps, nil +} + +func (k Keeper) btcDelegations(ctx context.Context) ([]*types.BTCDelegation, error) { + dels := make([]*types.BTCDelegation, 0) + iter := k.btcDelegationStore(ctx).Iterator(nil, nil) + defer iter.Close() + + for ; iter.Valid(); iter.Next() { + var del types.BTCDelegation + if err := del.Unmarshal(iter.Value()); err != nil { + return nil, err + } + dels = append(dels, &del) + } + + 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() { + blocks = append(blocks, &types.BlockHeightBbnToBtc{ + BlockHeightBbn: sdk.BigEndianToUint64(iter.Key()), + BlockHeightBtc: sdk.BigEndianToUint64(iter.Value()), + }) + } + + return blocks +} + +func (k Keeper) btcDelegators(ctx context.Context) ([]*types.BTCDelegator, error) { + iter := k.btcDelegatorStore(ctx).Iterator(nil, nil) + defer iter.Close() + + dels := make([]*types.BTCDelegator, 0) + for ; iter.Valid(); iter.Next() { + fpBTCPK, delBTCPK, err := parseBIP340PubKeysFromStoreKey(iter.Key()) + if err != nil { + return nil, err + } + var btcDelIndex types.BTCDelegatorDelegationIndex + if err := btcDelIndex.Unmarshal(iter.Value()); err != nil { + return nil, err + } + + dels = append(dels, &types.BTCDelegator{ + Idx: &btcDelIndex, + FpBtcPk: fpBTCPK, + DelBtcPk: delBTCPK, + }) + } + + return dels, nil +} + +// eventIdxs sets an event into the store. +func (k Keeper) eventIdxs( + ctx context.Context, +) ([]*types.EventIndex, error) { + iter := k.powerDistUpdateEventStore(ctx).Iterator(nil, nil) + defer iter.Close() + + evts := make([]*types.EventIndex, 0) + for ; iter.Valid(); iter.Next() { + blkHeight, idx, err := parseUintsFromStoreKey(iter.Key()) + if err != nil { + return nil, err + } + + var evt types.EventPowerDistUpdate + if err := evt.Unmarshal(iter.Value()); err != nil { + return nil, err + } + + evts = append(evts, &types.EventIndex{ + Idx: idx, + BlockHeightBtc: blkHeight, + Event: &evt, + }) + } + + 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)) +} + +// setEventIdx sets an event into the store. +func (k Keeper) setEventIdx( + ctx context.Context, + evt *types.EventIndex, +) error { + store := k.powerDistUpdateEventBtcHeightStore(ctx, evt.BlockHeightBtc) + + bz, err := evt.Event.Marshal() + if err != nil { + return err + } + store.Set(sdk.Uint64ToBigEndian(evt.Idx), bz) + + return nil +} + +// parseUintsFromStoreKey expects to receive a key with +// BigEndianUint64(blkHeight) || BigEndianUint64(Idx) +func parseUintsFromStoreKey(key []byte) (blkHeight, 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 +} + +// parseBIP340PubKeysFromStoreKey expects to receive a key with +// BIP340PubKey(fpBTCPK) || BIP340PubKey(delBTCPK) +func parseBIP340PubKeysFromStoreKey(key []byte) (fpBTCPK, delBTCPK *bbn.BIP340PubKey, err error) { + if len(key) < bbn.BIP340PubKeyLen*2 { + return nil, nil, fmt.Errorf("key not long enough to parse two BIP340PubKey: %s", key) + } + + fpBTCPK, err = bbn.NewBIP340PubKey(key[:bbn.BIP340PubKeyLen]) + if err != nil { + return nil, nil, fmt.Errorf("failed to parse pub key from key %w: %w", bbn.ErrUnmarshal, err) + } + + delBTCPK, err = bbn.NewBIP340PubKey(key[bbn.BIP340PubKeyLen:]) + if err != nil { + return nil, nil, fmt.Errorf("failed to parse pub key from key %w: %w", bbn.ErrUnmarshal, err) + } + + return fpBTCPK, delBTCPK, nil +} diff --git a/x/btcstaking/keeper/genesis_test.go b/x/btcstaking/keeper/genesis_test.go new file mode 100644 index 000000000..f9d5e7d0f --- /dev/null +++ b/x/btcstaking/keeper/genesis_test.go @@ -0,0 +1,176 @@ +package keeper_test + +import ( + "math" + "math/rand" + "strings" + "testing" + + "github.com/babylonlabs-io/babylon/testutil/datagen" + "github.com/babylonlabs-io/babylon/testutil/helper" + btclightclientt "github.com/babylonlabs-io/babylon/x/btclightclient/types" + "github.com/babylonlabs-io/babylon/x/btcstaking/types" + "github.com/stretchr/testify/require" +) + +func TestExportGenesis(t *testing.T) { + r, h := rand.New(rand.NewSource(11)), helper.NewHelper(t) + k, btclcK, btcCheckK, ctx := h.App.BTCStakingKeeper, h.App.BTCLightClientKeeper, h.App.BtcCheckpointKeeper, h.Ctx + numFps := 3 + + fps := datagen.CreateNFinalityProviders(r, t, numFps) + params := k.GetParams(ctx) + wValue := btcCheckK.GetParams(ctx).CheckpointFinalizationTimeout + + chainsHeight := make([]*types.BlockHeightBbnToBtc, 0) + // creates the first as it starts already with an chain height from the helper. + chainsHeight = append(chainsHeight, &types.BlockHeightBbnToBtc{ + 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) + + blkHeight := uint64(r.Int63n(1000)) + math.MaxUint16 + totalDelegations := 0 + + for _, fp := range fps { + btcHead := btclcK.GetTipInfo(ctx) + btcHead.Height = blkHeight + 100 + btclcK.InsertHeaderInfos(ctx, []*btclightclientt.BTCHeaderInfo{ + btcHead, + }) + + // set finality + h.AddFinalityProvider(fp) + + stakingValue := r.Int31n(200000) + 10000 + numDelegations := r.Int31n(10) + delegations := createNDelegationsForFinalityProvider( + r, + t, + fp.BtcPk.MustToBTCPK(), + int64(stakingValue), + 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) + btcDelegations = append(btcDelegations, del) + + // BTC delegators idx + stakingTxHash, err := del.GetStakingTxHash() + h.NoError(err) + + idxDelegatorStk := types.NewBTCDelegatorDelegationIndex() + err = idxDelegatorStk.Add(stakingTxHash) + h.NoError(err) + + btcDelegatorIndex[del.BtcPk.MarshalHex()] = &types.BTCDelegator{ + Idx: &types.BTCDelegatorDelegationIndex{ + StakingTxHashList: idxDelegatorStk.StakingTxHashList, + }, + FpBtcPk: fp.BtcPk, + DelBtcPk: del.BtcPk, + } + + // record event that the BTC delegation will become unbonded at endHeight-w + unbondedEvent := types.NewEventPowerDistUpdateWithBTCDel(&types.EventBTCDelegationStateUpdate{ + StakingTxHash: stakingTxHash.String(), + NewState: types.BTCDelegationStatus_UNBONDED, + }) + + // events + idxEvent := uint64(totalDelegations - 1) + eventsIdx[idxEvent] = &types.EventIndex{ + Idx: idxEvent, + BlockHeightBtc: del.EndHeight - wValue, + Event: unbondedEvent, + } + } + + // sets chain heights + header := ctx.HeaderInfo() + header.Height = int64(blkHeight) + ctx = ctx.WithHeaderInfo(header) + h.Ctx = ctx + + k.IndexBTCHeight(ctx) + chainsHeight = append(chainsHeight, &types.BlockHeightBbnToBtc{ + BlockHeightBbn: blkHeight, + BlockHeightBtc: btcHead.Height, + }) + + blkHeight++ // each fp increase blk height to modify data in state. + } + + gs, err := k.ExportGenesis(ctx) + h.NoError(err) + require.Equal(t, k.GetParams(ctx), *gs.Params[0]) + + // finality providers + correctFps := 0 + for _, fp := range fps { + for _, gsfp := range gs.FinalityProviders { + if !strings.EqualFold(fp.Addr, gsfp.Addr) { + continue + } + require.EqualValues(t, fp, gsfp) + correctFps++ + } + } + require.Equal(t, correctFps, numFps) + + // btc delegations + correctDels := 0 + for _, del := range btcDelegations { + for _, gsdel := range gs.BtcDelegations { + if !strings.EqualFold(del.StakerAddr, gsdel.StakerAddr) { + continue + } + correctDels++ + require.Equal(t, del, gsdel) + } + } + 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) + + // btc delegators + require.Equal(t, totalDelegations, len(gs.BtcDelegators)) + for _, btcDel := range gs.BtcDelegators { + idxBtcDel := btcDelegatorIndex[btcDel.DelBtcPk.MarshalHex()] + require.Equal(t, btcDel, idxBtcDel) + } + + // events + require.Equal(t, totalDelegations, len(gs.Events)) + for _, evt := range gs.Events { + evtIdx := eventsIdx[evt.Idx] + require.Equal(t, evt, evtIdx) + } + + // TODO: vp dst cache +} diff --git a/x/btcstaking/keeper/grpc_query.go b/x/btcstaking/keeper/grpc_query.go index 1ca23dac7..714515ebe 100644 --- a/x/btcstaking/keeper/grpc_query.go +++ b/x/btcstaking/keeper/grpc_query.go @@ -2,7 +2,6 @@ package keeper import ( "context" - "encoding/hex" errorsmod "cosmossdk.io/errors" "github.com/btcsuite/btcd/chaincfg/chainhash" @@ -12,37 +11,43 @@ import ( "google.golang.org/grpc/codes" "google.golang.org/grpc/status" - bbn "github.com/babylonchain/babylon/types" - "github.com/babylonchain/babylon/x/btcstaking/types" + bbn "github.com/babylonlabs-io/babylon/types" + "github.com/babylonlabs-io/babylon/x/btcstaking/types" ) var _ types.QueryServer = Keeper{} // FinalityProviders returns a paginated list of all Babylon maintained finality providers -func (k Keeper) FinalityProviders(ctx context.Context, req *types.QueryFinalityProvidersRequest) (*types.QueryFinalityProvidersResponse, error) { +func (k Keeper) FinalityProviders(c context.Context, req *types.QueryFinalityProvidersRequest) (*types.QueryFinalityProvidersResponse, error) { if req == nil { return nil, status.Error(codes.InvalidArgument, "empty request") } - sdkCtx := sdk.UnwrapSDKContext(ctx) - store := k.finalityProviderStore(sdkCtx) + ctx := sdk.UnwrapSDKContext(c) + store := k.finalityProviderStore(ctx) + currBlockHeight := uint64(ctx.BlockHeight()) - var finalityProviders []*types.FinalityProvider + var fpResp []*types.FinalityProviderResponse pageRes, err := query.Paginate(store, req.Pagination, func(key, value []byte) error { - var finalityProvider types.FinalityProvider - k.cdc.MustUnmarshal(value, &finalityProvider) - finalityProviders = append(finalityProviders, &finalityProvider) + var fp types.FinalityProvider + if err := fp.Unmarshal(value); err != nil { + return err + } + + votingPower := k.GetVotingPower(ctx, key, currBlockHeight) + resp := types.NewFinalityProviderResponse(&fp, currBlockHeight, votingPower) + fpResp = append(fpResp, resp) return nil }) if err != nil { return nil, err } - return &types.QueryFinalityProvidersResponse{FinalityProviders: finalityProviders, Pagination: pageRes}, nil + return &types.QueryFinalityProvidersResponse{FinalityProviders: fpResp, Pagination: pageRes}, nil } // FinalityProvider returns the finality provider with the specified finality provider BTC PK -func (k Keeper) FinalityProvider(ctx context.Context, req *types.QueryFinalityProviderRequest) (*types.QueryFinalityProviderResponse, error) { +func (k Keeper) FinalityProvider(c context.Context, req *types.QueryFinalityProviderRequest) (*types.QueryFinalityProviderResponse, error) { if req == nil { return nil, status.Error(codes.InvalidArgument, "empty request") } @@ -57,15 +62,21 @@ func (k Keeper) FinalityProvider(ctx context.Context, req *types.QueryFinalityPr return nil, err } - sdkCtx := sdk.UnwrapSDKContext(ctx) - - fp, err := k.GetFinalityProvider(sdkCtx, fpPK.MustMarshal()) + key, err := fpPK.Marshal() + if err != nil { + return nil, err + } + ctx := sdk.UnwrapSDKContext(c) + fp, err := k.GetFinalityProvider(ctx, key) if err != nil { return nil, err } - return &types.QueryFinalityProviderResponse{FinalityProvider: fp}, nil + currBlockHeight := uint64(ctx.BlockHeight()) + votingPower := k.GetVotingPower(ctx, key, currBlockHeight) + fpResp := types.NewFinalityProviderResponse(fp, currBlockHeight, votingPower) + return &types.QueryFinalityProviderResponse{FinalityProvider: fpResp}, nil } // BTCDelegations returns all BTC delegations under a given status @@ -82,15 +93,17 @@ func (k Keeper) BTCDelegations(ctx context.Context, req *types.QueryBTCDelegatio wValue := k.btccKeeper.GetParams(ctx).CheckpointFinalizationTimeout store := k.btcDelegationStore(ctx) - var btcDels []*types.BTCDelegation + var btcDels []*types.BTCDelegationResponse pageRes, err := query.FilteredPaginate(store, req.Pagination, func(_ []byte, value []byte, accumulate bool) (bool, error) { var btcDel types.BTCDelegation k.cdc.MustUnmarshal(value, &btcDel) // hit if the queried status is ANY or matches the BTC delegation status - if req.Status == types.BTCDelegationStatus_ANY || btcDel.GetStatus(btcTipHeight, wValue, covenantQuorum) == req.Status { + status := btcDel.GetStatus(btcTipHeight, wValue, covenantQuorum) + if req.Status == types.BTCDelegationStatus_ANY || status == req.Status { if accumulate { - btcDels = append(btcDels, &btcDel) + resp := types.NewBTCDelegationResponse(&btcDel, status) + btcDels = append(btcDels, resp) } return true, nil } @@ -123,7 +136,7 @@ func (k Keeper) FinalityProviderPowerAtHeight(ctx context.Context, req *types.Qu return nil, types.ErrFpNotFound } - store := k.votingPowerStore(ctx, req.Height) + store := k.votingPowerBbnBlockHeightStore(ctx, req.Height) iter := store.ReverseIterator(nil, nil) defer iter.Close() @@ -161,7 +174,7 @@ func (k Keeper) ActiveFinalityProvidersAtHeight(ctx context.Context, req *types. } sdkCtx := sdk.UnwrapSDKContext(ctx) - store := k.votingPowerStore(sdkCtx, req.Height) + store := k.votingPowerBbnBlockHeightStore(sdkCtx, req.Height) var finalityProvidersWithMeta []*types.FinalityProviderWithMeta pageRes, err := query.Paginate(store, req.Pagination, func(key, value []byte) error { @@ -223,21 +236,34 @@ func (k Keeper) FinalityProviderDelegations(ctx context.Context, req *types.Quer } sdkCtx := sdk.UnwrapSDKContext(ctx) - btcDelStore := k.btcDelegatorStore(sdkCtx, fpPK) + btcDelStore := k.btcDelegatorFpStore(sdkCtx, fpPK) - btcDels := []*types.BTCDelegatorDelegations{} + currentWValue := k.btccKeeper.GetParams(ctx).CheckpointFinalizationTimeout + btcHeight := k.btclcKeeper.GetTipInfo(ctx).Height + covenantQuorum := k.GetParams(ctx).CovenantQuorum + + btcDels := []*types.BTCDelegatorDelegationsResponse{} pageRes, err := query.Paginate(btcDelStore, req.Pagination, func(key, value []byte) error { delBTCPK, err := bbn.NewBIP340PubKey(key) if err != nil { return err } - curBTCDels, err := k.getBTCDelegatorDelegations(sdkCtx, fpPK, delBTCPK) - if err != nil { - return err + curBTCDels := k.getBTCDelegatorDelegations(sdkCtx, fpPK, delBTCPK) + + btcDelsResp := make([]*types.BTCDelegationResponse, len(curBTCDels.Dels)) + for i, btcDel := range curBTCDels.Dels { + status := btcDel.GetStatus( + btcHeight, + currentWValue, + covenantQuorum, + ) + btcDelsResp[i] = types.NewBTCDelegationResponse(btcDel, status) } - btcDels = append(btcDels, curBTCDels) + btcDels = append(btcDels, &types.BTCDelegatorDelegationsResponse{ + Dels: btcDelsResp, + }) return nil }) if err != nil { @@ -265,32 +291,14 @@ func (k Keeper) BTCDelegation(ctx context.Context, req *types.QueryBTCDelegation return nil, types.ErrBTCDelegationNotFound } - // check whether it's active - currentTip := k.btclcKeeper.GetTipInfo(ctx) currentWValue := k.btccKeeper.GetParams(ctx).CheckpointFinalizationTimeout - isActive := btcDel.GetStatus( - currentTip.Height, + status := btcDel.GetStatus( + k.btclcKeeper.GetTipInfo(ctx).Height, currentWValue, k.GetParams(ctx).CovenantQuorum, - ) == types.BTCDelegationStatus_ACTIVE - - // get its undelegation info - undelegationInfo := &types.BTCUndelegationInfo{ - UnbondingTx: btcDel.BtcUndelegation.UnbondingTx, - CovenantUnbondingSigList: btcDel.BtcUndelegation.CovenantUnbondingSigList, - CovenantSlashingSigs: btcDel.BtcUndelegation.CovenantSlashingSigs, - } + ) return &types.QueryBTCDelegationResponse{ - BtcPk: btcDel.BtcPk, - FpBtcPkList: btcDel.FpBtcPkList, - StartHeight: btcDel.StartHeight, - EndHeight: btcDel.EndHeight, - TotalSat: btcDel.TotalSat, - StakingTxHex: hex.EncodeToString(btcDel.StakingTx), - CovenantSigs: btcDel.CovenantSigs, - Active: isActive, - UnbondingTime: btcDel.UnbondingTime, - UndelegationInfo: undelegationInfo, + BtcDelegation: types.NewBTCDelegationResponse(btcDel, status), }, nil } diff --git a/x/btcstaking/keeper/grpc_query_test.go b/x/btcstaking/keeper/grpc_query_test.go index 37d4da2b6..af2b03d47 100644 --- a/x/btcstaking/keeper/grpc_query_test.go +++ b/x/btcstaking/keeper/grpc_query_test.go @@ -7,18 +7,17 @@ import ( sdkmath "cosmossdk.io/math" - "github.com/btcsuite/btcd/chaincfg" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/query" "github.com/golang/mock/gomock" "github.com/stretchr/testify/require" - "github.com/babylonchain/babylon/testutil/datagen" - testkeeper "github.com/babylonchain/babylon/testutil/keeper" - bbn "github.com/babylonchain/babylon/types" - btcctypes "github.com/babylonchain/babylon/x/btccheckpoint/types" - btclctypes "github.com/babylonchain/babylon/x/btclightclient/types" - "github.com/babylonchain/babylon/x/btcstaking/types" + "github.com/babylonlabs-io/babylon/testutil/datagen" + testkeeper "github.com/babylonlabs-io/babylon/testutil/keeper" + 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" + "github.com/babylonlabs-io/babylon/x/btcstaking/types" ) func FuzzActivatedHeight(f *testing.F) { @@ -27,7 +26,7 @@ func FuzzActivatedHeight(f *testing.F) { r := rand.New(rand.NewSource(seed)) // Setup keeper and context - keeper, ctx := testkeeper.BTCStakingKeeper(t, nil, nil) + keeper, ctx := testkeeper.BTCStakingKeeper(t, nil, nil, nil) ctx = sdk.UnwrapSDKContext(ctx) // not activated yet @@ -52,7 +51,7 @@ func FuzzFinalityProviders(f *testing.F) { r := rand.New(rand.NewSource(seed)) // Setup keeper and context - keeper, ctx := testkeeper.BTCStakingKeeper(t, nil, nil) + keeper, ctx := testkeeper.BTCStakingKeeper(t, nil, nil, nil) ctx = sdk.UnwrapSDKContext(ctx) // Generate random finality providers and add them to kv store @@ -117,7 +116,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) + keeper, ctx := testkeeper.BTCStakingKeeper(t, nil, nil, nil) ctx = sdk.UnwrapSDKContext(ctx) // Generate random finality providers and add them to kv store @@ -148,7 +147,7 @@ func FuzzFinalityProvider(f *testing.F) { // check keys from map matches those in returned response require.Equal(t, v.BtcPk.MarshalHex(), resp.FinalityProvider.BtcPk.MarshalHex()) - require.Equal(t, v.BabylonPk, resp.FinalityProvider.BabylonPk) + require.Equal(t, v.Addr, resp.FinalityProvider.Addr) } // check some random non-existing guy @@ -173,11 +172,12 @@ 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) + ckptKeeper := types.NewMockCheckpointingKeeper(ctrl) + keeper, ctx := testkeeper.BTCStakingKeeper(t, btclcKeeper, btccKeeper, ckptKeeper) // covenant and slashing addr - covenantSKs, _, covenantQuorum := datagen.GenCovenantCommittee(r) - slashingAddress, err := datagen.GenRandomBTCAddress(r, &chaincfg.SimNetParams) + covenantSKs, covenantPKs, covenantQuorum := datagen.GenCovenantCommittee(r) + slashingAddress, err := datagen.GenRandomBTCAddress(r, net) require.NoError(t, err) slashingChangeLockTime := uint16(101) @@ -212,9 +212,11 @@ func FuzzPendingBTCDelegations(f *testing.F) { btcDel, err := datagen.GenRandomBTCDelegation( r, t, + net, []bbn.BIP340PubKey{*fp.BtcPk}, delSK, covenantSKs, + covenantPKs, covenantQuorum, slashingAddress.EncodeAddress(), startHeight, endHeight, 10000, @@ -273,7 +275,7 @@ func FuzzFinalityProviderPowerAtHeight(f *testing.F) { r := rand.New(rand.NewSource(seed)) // Setup keeper and context - keeper, ctx := testkeeper.BTCStakingKeeper(t, nil, nil) + keeper, ctx := testkeeper.BTCStakingKeeper(t, nil, nil, nil) // random finality provider fp, err := datagen.GenRandomFinalityProvider(r) @@ -296,7 +298,7 @@ func FuzzFinalityProviderPowerAtHeight(f *testing.F) { // case where the voting power store is not updated in // the given height - requestHeight := datagen.RandomIntOtherThan(r, int(randomHeight), 100) + 1 + requestHeight := randomHeight + datagen.RandomInt(r, 10) + 1 req2 := &types.QueryFinalityProviderPowerAtHeightRequest{ FpBtcPkHex: fp.BtcPk.MarshalHex(), Height: requestHeight, @@ -322,7 +324,7 @@ func FuzzFinalityProviderCurrentVotingPower(f *testing.F) { r := rand.New(rand.NewSource(seed)) // Setup keeper and context - keeper, ctx := testkeeper.BTCStakingKeeper(t, nil, nil) + keeper, ctx := testkeeper.BTCStakingKeeper(t, nil, nil, nil) // random finality provider fp, err := datagen.GenRandomFinalityProvider(r) @@ -366,13 +368,20 @@ 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() // Setup keeper and context - keeper, ctx := testkeeper.BTCStakingKeeper(t, nil, nil) + 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() + ckptKeeper := types.NewMockCheckpointingKeeper(ctrl) + keeper, ctx := testkeeper.BTCStakingKeeper(t, btclcKeeper, btccKeeper, ckptKeeper) // covenant and slashing addr - covenantSKs, _, covenantQuorum := datagen.GenCovenantCommittee(r) - slashingAddress, err := datagen.GenRandomBTCAddress(r, &chaincfg.SimNetParams) + covenantSKs, covenantPKs, covenantQuorum := datagen.GenCovenantCommittee(r) + slashingAddress, err := datagen.GenRandomBTCAddress(r, net) require.NoError(t, err) slashingChangeLockTime := uint16(101) @@ -410,9 +419,11 @@ func FuzzActiveFinalityProvidersAtHeight(f *testing.F) { btcDel, err := datagen.GenRandomBTCDelegation( r, t, + net, []bbn.BIP340PubKey{*fpBTCPK}, delSK, covenantSKs, + covenantPKs, covenantQuorum, slashingAddress.EncodeAddress(), 1, 1000, 10000, @@ -485,11 +496,12 @@ func FuzzFinalityProviderDelegations(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) + ckptKeeper := types.NewMockCheckpointingKeeper(ctrl) + keeper, ctx := testkeeper.BTCStakingKeeper(t, btclcKeeper, btccKeeper, ckptKeeper) // covenant and slashing addr - covenantSKs, _, covenantQuorum := datagen.GenCovenantCommittee(r) - slashingAddress, err := datagen.GenRandomBTCAddress(r, &chaincfg.SimNetParams) + covenantSKs, covenantPKs, covenantQuorum := datagen.GenCovenantCommittee(r) + slashingAddress, err := datagen.GenRandomBTCAddress(r, net) require.NoError(t, err) slashingChangeLockTime := uint16(101) @@ -507,6 +519,7 @@ func FuzzFinalityProviderDelegations(f *testing.F) { 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) @@ -516,9 +529,11 @@ func FuzzFinalityProviderDelegations(f *testing.F) { btcDel, err := datagen.GenRandomBTCDelegation( r, t, + net, []bbn.BIP340PubKey{*fp.BtcPk}, delSK, covenantSKs, + covenantPKs, covenantQuorum, slashingAddress.EncodeAddress(), startHeight, endHeight, 10000, @@ -538,12 +553,17 @@ func FuzzFinalityProviderDelegations(f *testing.F) { babylonHeight := datagen.RandomInt(r, 10) + 1 ctx = datagen.WithCtxHeight(ctx, babylonHeight) - btclcKeeper.EXPECT().GetTipInfo(gomock.Any()).Return(&btclctypes.BTCHeaderInfo{Height: startHeight}).Times(1) keeper.IndexBTCHeight(ctx) // 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) + pagination := constructRequestWithLimit(r, limit) // Generate the initial query req := types.QueryFinalityProviderDelegationsRequest{ diff --git a/x/btcstaking/keeper/hooks.go b/x/btcstaking/keeper/hooks.go new file mode 100644 index 000000000..c7283e95a --- /dev/null +++ b/x/btcstaking/keeper/hooks.go @@ -0,0 +1,39 @@ +package keeper + +import ( + "context" + "fmt" + + 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 { + fp, err := h.k.GetFinalityProvider(ctx, fpPk.MustMarshal()) + if err != nil { + return err + } + + if fp.IsSluggish() { + return fmt.Errorf("the finality provider %s is already detected as sluggish", fpPk.MarshalHex()) + } + + fp.Sluggish = true + + h.k.SetFinalityProvider(ctx, fp) + + return nil +} diff --git a/x/btcstaking/keeper/incentive.go b/x/btcstaking/keeper/incentive.go index 7c62d2428..ac65638b9 100644 --- a/x/btcstaking/keeper/incentive.go +++ b/x/btcstaking/keeper/incentive.go @@ -4,37 +4,45 @@ import ( "context" "cosmossdk.io/store/prefix" - "github.com/babylonchain/babylon/x/btcstaking/types" + "github.com/babylonlabs-io/babylon/x/btcstaking/types" "github.com/cosmos/cosmos-sdk/runtime" sdk "github.com/cosmos/cosmos-sdk/types" ) -func (k Keeper) setRewardDistCache(ctx context.Context, height uint64, rdc *types.RewardDistCache) { - store := k.rewardDistCacheStore(ctx) - store.Set(sdk.Uint64ToBigEndian(height), k.cdc.MustMarshal(rdc)) +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) GetRewardDistCache(ctx context.Context, height uint64) (*types.RewardDistCache, error) { - store := k.rewardDistCacheStore(ctx) +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, types.ErrRewardDistCacheNotFound + return nil } - var rdc types.RewardDistCache - k.cdc.MustUnmarshal(rdcBytes, &rdc) - return &rdc, nil + var dc types.VotingPowerDistCache + k.cdc.MustUnmarshal(rdcBytes, &dc) + return &dc } -func (k Keeper) RemoveRewardDistCache(ctx context.Context, height uint64) { - store := k.rewardDistCacheStore(ctx) +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)) } -// rewardDistCacheStore returns the KVStore of the reward distribution cache -// prefix: RewardDistCacheKey +// votingPowerDistCacheStore returns the KVStore of the voting power distribution cache +// prefix: VotingPowerDistCacheKey // key: Babylon block height -// value: RewardDistCache -func (k Keeper) rewardDistCacheStore(ctx context.Context) prefix.Store { +// value: VotingPowerDistCache +func (k Keeper) votingPowerDistCacheStore(ctx context.Context) prefix.Store { storeAdapter := runtime.KVStoreAdapter(k.storeService.OpenKVStore(ctx)) - return prefix.NewStore(storeAdapter, types.RewardDistCacheKey) + return prefix.NewStore(storeAdapter, types.VotingPowerDistCacheKey) } diff --git a/x/btcstaking/keeper/incentive_test.go b/x/btcstaking/keeper/incentive_test.go index 057461e44..ea7d699d5 100644 --- a/x/btcstaking/keeper/incentive_test.go +++ b/x/btcstaking/keeper/incentive_test.go @@ -4,20 +4,15 @@ import ( "math/rand" "testing" - sdkmath "cosmossdk.io/math" - - "github.com/babylonchain/babylon/testutil/datagen" - keepertest "github.com/babylonchain/babylon/testutil/keeper" - bbn "github.com/babylonchain/babylon/types" - btcctypes "github.com/babylonchain/babylon/x/btccheckpoint/types" - btclctypes "github.com/babylonchain/babylon/x/btclightclient/types" - "github.com/babylonchain/babylon/x/btcstaking/types" - "github.com/btcsuite/btcd/chaincfg" "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 FuzzRecordRewardDistCache(f *testing.F) { +func FuzzRecordVotingPowerDistCache(f *testing.F) { datagen.AddRandomSeedsToFuzzer(f, 10) f.Fuzz(func(t *testing.T, seed int64) { @@ -28,75 +23,59 @@ func FuzzRecordRewardDistCache(f *testing.F) { // mock BTC light client and BTC checkpoint modules btclcKeeper := types.NewMockBTCLightClientKeeper(ctrl) btccKeeper := types.NewMockBtcCheckpointKeeper(ctrl) - btccKeeper.EXPECT().GetParams(gomock.Any()).Return(btcctypes.DefaultParams()).AnyTimes() - keeper, ctx := keepertest.BTCStakingKeeper(t, btclcKeeper, btccKeeper) - - // covenant and slashing addr - covenantSKs, _, covenantQuorum := datagen.GenCovenantCommittee(r) - slashingAddress, err := datagen.GenRandomBTCAddress(r, &chaincfg.SimNetParams) - require.NoError(t, err) - slashingChangeLockTime := uint16(101) + ckptKeeper := types.NewMockCheckpointingKeeper(ctrl) + h := NewHelper(t, btclcKeeper, btccKeeper, ckptKeeper) - // 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) + // 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, err := datagen.GenRandomFinalityProvider(r) - require.NoError(t, err) - keeper.SetFinalityProvider(ctx, fp) + _, _, fp := h.CreateFinalityProvider(r) if i < numFpsWithVotingPower { // these finality providers will receive BTC delegations and have voting power - fpsWithVotingPowerMap[fp.BabylonPk.String()] = fp + fpsWithVotingPowerMap[fp.Addr] = fp } } - // for the first numFpsWithVotingPower finality providers, generate a random number of BTC delegations + // 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) - require.NoError(t, err) - btcDel, err := datagen.GenRandomBTCDelegation( + _, _, _, delMsg, del := h.CreateDelegation( r, - t, - []bbn.BIP340PubKey{*fp.BtcPk}, - delSK, - covenantSKs, - covenantQuorum, - slashingAddress.EncodeAddress(), - 1, 1000, stakingValue, - slashingRate, - slashingChangeLockTime, + fp.BtcPk.MustToBTCPK(), + changeAddress.EncodeAddress(), + int64(stakingValue), + 1000, ) - require.NoError(t, err) - err = keeper.AddBTCDelegation(ctx, btcDel) - require.NoError(t, err) + h.CreateCovenantSigs(r, covenantSKs, delMsg, del) } } - // record reward distribution cache + // record voting power distribution cache babylonHeight := datagen.RandomInt(r, 10) + 1 - ctx = datagen.WithCtxHeight(ctx, babylonHeight) - btclcKeeper.EXPECT().GetTipInfo(gomock.Any()).Return(&btclctypes.BTCHeaderInfo{Height: 1}).Times(1) - err = keeper.BeginBlocker(ctx) + 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 reward distribution cache is correct - rdc, err := keeper.GetRewardDistCache(ctx, babylonHeight) + // assert voting power distribution cache is correct + dc, err := h.BTCStakingKeeper.GetVotingPowerDistCache(h.Ctx, babylonHeight) require.NoError(t, err) - require.Equal(t, rdc.TotalVotingPower, numFpsWithVotingPower*numBTCDels*stakingValue) - for _, fpDistInfo := range rdc.FinalityProviders { + require.NotNil(t, dc) + require.Equal(t, dc.TotalVotingPower, numFpsWithVotingPower*numBTCDels*stakingValue) + maxNumFps := h.BTCStakingKeeper.GetParams(h.Ctx).MaxActiveFinalityProviders + activeFPs := dc.GetActiveFinalityProviderSet(maxNumFps) + for _, fpDistInfo := range activeFPs { require.Equal(t, fpDistInfo.TotalVotingPower, numBTCDels*stakingValue) - fp, ok := fpsWithVotingPowerMap[fpDistInfo.BabylonPk.String()] + fp, ok := fpsWithVotingPowerMap[fpDistInfo.Addr] require.True(t, ok) require.Equal(t, fpDistInfo.Commission, fp.Commission) require.Len(t, fpDistInfo.BtcDels, int(numBTCDels)) diff --git a/x/btcstaking/keeper/keeper.go b/x/btcstaking/keeper/keeper.go index 6d3e2c2f3..5a992423a 100644 --- a/x/btcstaking/keeper/keeper.go +++ b/x/btcstaking/keeper/keeper.go @@ -7,11 +7,11 @@ import ( corestoretypes "cosmossdk.io/core/store" "cosmossdk.io/log" - "github.com/babylonchain/babylon/x/btcstaking/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/babylonlabs-io/babylon/x/btcstaking/types" ) type ( @@ -21,6 +21,9 @@ type ( btclcKeeper types.BTCLightClientKeeper btccKeeper types.BtcCheckpointKeeper + ckptKeeper types.CheckpointingKeeper + + hooks types.BtcStakingHooks btcNet *chaincfg.Params // the address capable of executing a MsgUpdateParams message. Typically, this @@ -35,6 +38,7 @@ func NewKeeper( btclcKeeper types.BTCLightClientKeeper, btccKeeper types.BtcCheckpointKeeper, + ckptKeeper types.CheckpointingKeeper, btcNet *chaincfg.Params, authority string, @@ -45,12 +49,26 @@ func NewKeeper( btclcKeeper: btclcKeeper, btccKeeper: btccKeeper, + ckptKeeper: ckptKeeper, + + hooks: nil, 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") + } + + k.hooks = sh + + return k +} + func (k Keeper) Logger(ctx sdk.Context) log.Logger { return ctx.Logger().With("module", fmt.Sprintf("x/%s", types.ModuleName)) } @@ -58,75 +76,17 @@ func (k Keeper) Logger(ctx sdk.Context) log.Logger { // BeginBlocker is invoked upon `BeginBlock` of the system. The function // iterates over all BTC delegations under non-slashed finality providers // to 1) record the voting power table for the current height, and 2) record -// the reward distribution cache used for distributing rewards once the block -// is finalised by finality providers. +// the voting power distribution cache used for computing voting power table +// and distributing rewards once the block is finalised by finality providers. func (k Keeper) BeginBlocker(ctx context.Context) error { + // index BTC height at the current height k.IndexBTCHeight(ctx) - - covenantQuorum := k.GetParams(ctx).CovenantQuorum - btcTipHeight, err := k.GetCurrentBTCHeight(ctx) - if err != nil { - panic(err) // only possible upon programming error - } - wValue := k.btccKeeper.GetParams(ctx).CheckpointFinalizationTimeout - - distInfos := make(map[chainhash.Hash]*types.BTCDelDistInfo) - - k.IterateBTCDelsKeys(ctx, func(key chainhash.Hash, btcDel *types.BTCDelegation) bool { - distInfo := &types.BTCDelDistInfo{ - BabylonPk: btcDel.BabylonPk, - VotingPower: btcDel.VotingPower(btcTipHeight, wValue, covenantQuorum), - } - if distInfo.VotingPower > 0 { - distInfos[key] = distInfo - } - return true - }) - - activeFps := []*types.FinalityProviderWithMeta{} - - rdc := types.NewRewardDistCache() - - k.IterateActiveFPs( - ctx, - func(fp *types.FinalityProvider) bool { - fpDistInfo := types.NewFinalityProviderDistInfo(fp) - - k.IterateBTCDelegationsHashes(ctx, fp.BtcPk, func(hash chainhash.Hash) bool { - distInfo, found := distInfos[hash] - - if !found { - return true - } - - fpDistInfo.AddBTCDistInfo(distInfo) - return true - }) - - if fpDistInfo.TotalVotingPower > 0 { - activeFP := &types.FinalityProviderWithMeta{ - BtcPk: fp.BtcPk, - VotingPower: fpDistInfo.TotalVotingPower, - } - activeFps = append(activeFps, activeFP) - rdc.AddFinalityProviderDistInfo(fpDistInfo) - } - - return true - }, - ) - - // filter out top `MaxActiveFinalityProviders` active finality providers in terms of voting power - activeFps = types.FilterTopNFinalityProviders(activeFps, k.GetParams(ctx).MaxActiveFinalityProviders) - // set voting power table - babylonTipHeight := uint64(sdk.UnwrapSDKContext(ctx).HeaderInfo().Height) - for _, fp := range activeFps { - k.SetVotingPower(ctx, fp.BtcPk.MustMarshal(), babylonTipHeight, fp.VotingPower) - } - - // set the reward distribution cache of the current height - // TODO: only give rewards to top N finality providers and their BTC delegations - k.setRewardDistCache(ctx, uint64(sdk.UnwrapSDKContext(ctx).HeaderInfo().Height), rdc) + // update voting power distribution + k.UpdatePowerDist(ctx) return nil } + +func (k Keeper) GetLastFinalizedEpoch(ctx context.Context) uint64 { + return k.ckptKeeper.GetLastFinalizedEpoch(ctx) +} diff --git a/x/btcstaking/keeper/keeper_test.go b/x/btcstaking/keeper/keeper_test.go index 6cf8e67cc..1ce64721e 100644 --- a/x/btcstaking/keeper/keeper_test.go +++ b/x/btcstaking/keeper/keeper_test.go @@ -1,49 +1,61 @@ package keeper_test import ( - "context" "math/rand" "testing" "cosmossdk.io/core/header" sdkmath "cosmossdk.io/math" - "github.com/babylonchain/babylon/testutil/datagen" - keepertest "github.com/babylonchain/babylon/testutil/keeper" - bbn "github.com/babylonchain/babylon/types" - btcctypes "github.com/babylonchain/babylon/x/btccheckpoint/types" - btclctypes "github.com/babylonchain/babylon/x/btclightclient/types" - "github.com/babylonchain/babylon/x/btcstaking/keeper" - "github.com/babylonchain/babylon/x/btcstaking/types" "github.com/btcsuite/btcd/btcec/v2" "github.com/btcsuite/btcd/chaincfg" "github.com/btcsuite/btcd/wire" - "github.com/cosmos/cosmos-sdk/crypto/keys/secp256k1" + sdk "github.com/cosmos/cosmos-sdk/types" "github.com/golang/mock/gomock" "github.com/stretchr/testify/require" + + "github.com/babylonlabs-io/babylon/testutil/datagen" + keepertest "github.com/babylonlabs-io/babylon/testutil/keeper" + 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" + "github.com/babylonlabs-io/babylon/x/btcstaking/keeper" + "github.com/babylonlabs-io/babylon/x/btcstaking/types" +) + +var ( + net = &chaincfg.SimNetParams ) type Helper struct { t testing.TB - Ctx context.Context + Ctx sdk.Context BTCStakingKeeper *keeper.Keeper BTCLightClientKeeper *types.MockBTCLightClientKeeper BTCCheckpointKeeper *types.MockBtcCheckpointKeeper + CheckpointingKeeper *types.MockCheckpointingKeeper + BTCStakingHooks *types.MockBtcStakingHooks MsgServer types.MsgServer Net *chaincfg.Params } -func NewHelper(t testing.TB, btclcKeeper *types.MockBTCLightClientKeeper, btccKeeper *types.MockBtcCheckpointKeeper) *Helper { - k, ctx := keepertest.BTCStakingKeeper(t, btclcKeeper, btccKeeper) +func NewHelper(t testing.TB, btclcKeeper *types.MockBTCLightClientKeeper, btccKeeper *types.MockBtcCheckpointKeeper, ckptKeeper *types.MockCheckpointingKeeper) *Helper { + k, ctx := keepertest.BTCStakingKeeper(t, btclcKeeper, btccKeeper, ckptKeeper) ctx = ctx.WithHeaderInfo(header.Info{Height: 1}) msgSrvr := keeper.NewMsgServerImpl(*k) + ctrl := gomock.NewController(t) + mockedHooks := types.NewMockBtcStakingHooks(ctrl) + mockedHooks.EXPECT().AfterFinalityProviderActivated(gomock.Any(), gomock.Any()).Return(nil).AnyTimes() + k.SetHooks(mockedHooks) + return &Helper{ t: t, Ctx: ctx, BTCStakingKeeper: k, BTCLightClientKeeper: btclcKeeper, BTCCheckpointKeeper: btccKeeper, + CheckpointingKeeper: ckptKeeper, MsgServer: msgSrvr, Net: &chaincfg.SimNetParams, } @@ -61,11 +73,19 @@ func (h *Helper) GenAndApplyParams(r *rand.Rand) ([]*btcec.PrivateKey, []*btcec. return h.GenAndApplyCustomParams(r, 100, 0) } +func (h *Helper) SetCtxHeight(height uint64) { + h.Ctx = datagen.WithCtxHeight(h.Ctx, height) +} + func (h *Helper) GenAndApplyCustomParams( r *rand.Rand, finalizationTimeout uint64, minUnbondingTime uint32, ) ([]*btcec.PrivateKey, []*btcec.PublicKey) { + // mock base header + baseHeader := btclctypes.SimnetGenesisBlock() + h.BTCLightClientKeeper.EXPECT().GetBaseBTCHeader(gomock.Any()).Return(&baseHeader).AnyTimes() + // mocking stuff for BTC checkpoint keeper h.BTCCheckpointKeeper.EXPECT().GetPowLimit().Return(h.Net.PowLimit).AnyTimes() @@ -88,6 +108,7 @@ func (h *Helper) GenAndApplyCustomParams( SlashingRate: sdkmath.LegacyNewDecWithPrec(int64(datagen.RandomInt(r, 41)+10), 2), MaxActiveFinalityProviders: 100, MinUnbondingTime: minUnbondingTime, + MinUnbondingRate: sdkmath.LegacyMustNewDecFromStr("0.8"), }) h.NoError(err) return covenantSKs, covenantPKs @@ -102,7 +123,7 @@ func CreateFinalityProvider(r *rand.Rand, t *testing.T) *types.FinalityProvider return &types.FinalityProvider{ Description: fp.Description, Commission: fp.Commission, - BabylonPk: fp.BabylonPk, + Addr: fp.Addr, BtcPk: fp.BtcPk, Pop: fp.Pop, } @@ -114,13 +135,13 @@ func (h *Helper) CreateFinalityProvider(r *rand.Rand) (*btcec.PrivateKey, *btcec fp, err := datagen.GenRandomFinalityProviderWithBTCSK(r, fpSK) h.NoError(err) msgNewFp := types.MsgCreateFinalityProvider{ - Signer: datagen.GenRandomAccount().Address, + Addr: fp.Addr, Description: fp.Description, Commission: fp.Commission, - BabylonPk: fp.BabylonPk, BtcPk: fp.BtcPk, Pop: fp.Pop, } + _, err = h.MsgServer.CreateFinalityProvider(h.Ctx, &msgNewFp) h.NoError(err) return fpSK, fpPK, fp @@ -132,6 +153,7 @@ func (h *Helper) CreateDelegationCustom( changeAddress string, stakingValue int64, stakingTime uint16, + unbondingValue int64, unbondingTime uint16, ) (string, *btcec.PrivateKey, *btcec.PublicKey, *types.MsgCreateBTCDelegation, error) { delSK, delPK, err := datagen.GenRandomBTCKeyPair(r) @@ -159,12 +181,10 @@ func (h *Helper) CreateDelegationCustom( stakingTxHash := testStakingInfo.StakingTx.TxHash().String() // random signer - signer := datagen.GenRandomAccount().Address - // random Babylon SK - delBabylonSK, delBabylonPK, err := datagen.GenRandomSecp256k1KeyPair(r) - h.NoError(err) + staker := sdk.MustAccAddressFromBech32(datagen.GenRandomAccount().Address) + // PoP - pop, err := types.NewPoP(delBabylonSK, delSK) + pop, err := types.NewPoPBTC(staker, delSK) h.NoError(err) // generate staking tx info prevBlock, _ := datagen.GenRandomBtcdBlock(r, 0, nil) @@ -176,8 +196,8 @@ func (h *Helper) CreateDelegationCustom( txInfo := btcctypes.NewTransactionInfo(&btcctypes.TransactionKey{Index: 1, Hash: btcHeader.Hash()}, serializedStakingTx, btcHeaderWithProof.SpvProof.MerkleNodes) // mock for testing k-deep stuff - h.BTCLightClientKeeper.EXPECT().GetHeaderByHash(gomock.Any(), gomock.Eq(btcHeader.Hash())).Return(&btclctypes.BTCHeaderInfo{Header: &btcHeader, Height: 10}).AnyTimes() - h.BTCLightClientKeeper.EXPECT().GetTipInfo(gomock.Any()).Return(&btclctypes.BTCHeaderInfo{Height: 30}).AnyTimes() + 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() slashingSpendInfo, err := testStakingInfo.StakingInfo.SlashingPathSpendInfo() h.NoError(err) @@ -200,7 +220,6 @@ func (h *Helper) CreateDelegationCustom( stkTxHash := testStakingInfo.StakingTx.TxHash() stkOutputIdx := uint32(0) - unbondingValue := stakingValue - 1000 testUnbondingInfo := datagen.GenBTCUnbondingSlashingInfo( r, h.t, @@ -225,11 +244,11 @@ func (h *Helper) CreateDelegationCustom( h.NoError(err) // all good, construct and send MsgCreateBTCDelegation message + fpBTCPK := bbn.NewBIP340PubKeyFromBTCPK(fpPK) msgCreateBTCDel := &types.MsgCreateBTCDelegation{ - Signer: signer, - BabylonPk: delBabylonPK.(*secp256k1.PubKey), + StakerAddr: staker.String(), BtcPk: stPk, - FpBtcPkList: []bbn.BIP340PubKey{*bbn.NewBIP340PubKeyFromBTCPK(fpPK)}, + FpBtcPkList: []bbn.BIP340PubKey{*fpBTCPK}, Pop: pop, StakingTime: uint32(stakingTimeBlocks), StakingValue: stakingValue, @@ -244,7 +263,6 @@ func (h *Helper) CreateDelegationCustom( } _, err = h.MsgServer.CreateBTCDelegation(h.Ctx, msgCreateBTCDel) - if err != nil { return "", nil, nil, nil, err } @@ -258,7 +276,7 @@ func (h *Helper) CreateDelegation( changeAddress string, stakingValue int64, stakingTime uint16, -) (string, *btcec.PrivateKey, *btcec.PublicKey, *types.MsgCreateBTCDelegation) { +) (string, *btcec.PrivateKey, *btcec.PublicKey, *types.MsgCreateBTCDelegation, *types.BTCDelegation) { bsParams := h.BTCStakingKeeper.GetParams(h.Ctx) bcParams := h.BTCCheckpointKeeper.GetParams(h.Ctx) @@ -273,12 +291,18 @@ func (h *Helper) CreateDelegation( changeAddress, stakingValue, stakingTime, + stakingValue-1000, uint16(minUnbondingTime)+1, ) h.NoError(err) - return stakingTxHash, delSK, delPK, msgCreateBTCDel + stakingMsgTx, err := bbn.NewBTCTxFromBytes(msgCreateBTCDel.StakingTx.Transaction) + h.NoError(err) + btcDel, err := h.BTCStakingKeeper.GetBTCDelegation(h.Ctx, stakingMsgTx.TxHash().String()) + h.NoError(err) + + return stakingTxHash, delSK, delPK, msgCreateBTCDel, btcDel } func (h *Helper) GenerateCovenantSignaturesMessages( @@ -344,7 +368,7 @@ func (h *Helper) GenerateCovenantSignaturesMessages( for i := 0; i < len(bsParams.CovenantPks); i++ { msgAddCovenantSig := &types.MsgAddCovenantSigs{ - Signer: msgCreateBTCDel.Signer, + Signer: msgCreateBTCDel.StakerAddr, Pk: covenantSlashingTxSigs[i].CovPk, StakingTxHash: stakingTxHash, SlashingTxSigs: covenantSlashingTxSigs[i].AdaptorSigs, @@ -400,7 +424,8 @@ func (h *Helper) GetDelegationAndCheckValues( ) *types.BTCDelegation { actualDel, err := h.BTCStakingKeeper.GetBTCDelegation(h.Ctx, stakingTxHash) h.NoError(err) - require.Equal(h.t, msgCreateBTCDel.BabylonPk, actualDel.BabylonPk) + // 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) diff --git a/x/btcstaking/keeper/msg_server.go b/x/btcstaking/keeper/msg_server.go index 9384e997f..a1617d9ed 100644 --- a/x/btcstaking/keeper/msg_server.go +++ b/x/btcstaking/keeper/msg_server.go @@ -3,15 +3,18 @@ package keeper import ( "context" "fmt" + "strings" + "time" errorsmod "cosmossdk.io/errors" - sdkmath "cosmossdk.io/math" - "github.com/babylonchain/babylon/btcstaking" - bbn "github.com/babylonchain/babylon/types" - "github.com/babylonchain/babylon/x/btcstaking/types" + "github.com/babylonlabs-io/babylon/btcstaking" + bbn "github.com/babylonlabs-io/babylon/types" + "github.com/babylonlabs-io/babylon/x/btcstaking/types" "github.com/btcsuite/btcd/btcec/v2" "github.com/btcsuite/btcd/btcutil" + "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" "google.golang.org/grpc/codes" @@ -49,6 +52,8 @@ func (ms msgServer) UpdateParams(goCtx context.Context, req *types.MsgUpdatePara // CreateFinalityProvider creates a finality provider func (ms msgServer) CreateFinalityProvider(goCtx context.Context, req *types.MsgCreateFinalityProvider) (*types.MsgCreateFinalityProviderResponse, error) { + defer telemetry.ModuleMeasureSince(types.ModuleName, time.Now(), types.MetricsKeyCreateFinalityProvider) + // ensure the finality provider address does not already exist ctx := sdk.UnwrapSDKContext(goCtx) // basic stateless checks @@ -56,16 +61,22 @@ func (ms msgServer) CreateFinalityProvider(goCtx context.Context, req *types.Msg return nil, status.Errorf(codes.InvalidArgument, "%v", err) } + fpAddr, err := sdk.AccAddressFromBech32(req.Addr) + if err != nil { + return nil, status.Errorf(codes.InvalidArgument, "invalid address %s: %v", req.Addr, err) + } + // verify proof of possession - if err := req.Pop.Verify(req.BabylonPk, req.BtcPk, ms.btcNet); err != nil { + if err := req.Pop.Verify(fpAddr, req.BtcPk, ms.btcNet); err != nil { return nil, status.Errorf(codes.InvalidArgument, "invalid proof of possession: %v", err) } - // ensure commission rate is at least the minimum commission rate in parameters + // 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.GT(sdkmath.LegacyOneDec()) { return nil, types.ErrCommissionGTMaxRate } @@ -79,7 +90,7 @@ func (ms msgServer) CreateFinalityProvider(goCtx context.Context, req *types.Msg fp := types.FinalityProvider{ Description: req.Description, Commission: req.Commission, - BabylonPk: req.BabylonPk, + Addr: fpAddr.String(), BtcPk: req.BtcPk, Pop: req.Pop, } @@ -93,20 +104,78 @@ func (ms msgServer) CreateFinalityProvider(goCtx context.Context, req *types.Msg return &types.MsgCreateFinalityProviderResponse{}, nil } +// EditFinalityProvider edits an existing finality provider +func (ms msgServer) EditFinalityProvider(ctx 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 { + return nil, status.Errorf(codes.InvalidArgument, "%v", err) + } + + // 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.GT(sdkmath.LegacyOneDec()) { + return nil, types.ErrCommissionGTMaxRate + } + + // 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) + if err != nil { + return nil, err + } + + fpAddr, err := sdk.AccAddressFromBech32(req.Addr) + if err != nil { + return nil, status.Errorf(codes.InvalidArgument, "invalid address %s: %v", req.Addr, err) + } + + // ensure the signer corresponds to the finality provider's Babylon address + if !strings.EqualFold(fpAddr.String(), fp.Addr) { + return nil, status.Errorf(codes.PermissionDenied, "the signer does not correspond to the finality provider's Babylon address") + } + + // all good, update the finality provider and set back + fp.Description = req.Description + fp.Commission = req.Commission + ms.SetFinalityProvider(ctx, fp) + + return &types.MsgEditFinalityProviderResponse{}, nil +} + +// caluculateMinimumUnbondingValue calculates minimum unbonding value basend on current staking output value +// and params.MinUnbondingRate +func caluculateMinimumUnbondingValue( + stakingOutput *wire.TxOut, + params *types.Params, +) btcutil.Amount { + // this conversions must always succeed, as it is part of our params + minUnbondingRate := params.MinUnbondingRate.MustFloat64() + // Caluclate min unbonding output value based on staking output, use btc native multiplication + minUnbondingOutputValue := btcutil.Amount(stakingOutput.Value).MulF64(minUnbondingRate) + return minUnbondingOutputValue +} + // CreateBTCDelegation creates a BTC delegation // TODO: refactor this handler. It's now too convoluted 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) // basic stateless checks if err := req.ValidateBasic(); err != nil { return nil, status.Errorf(codes.InvalidArgument, "%v", err) } - params := ms.GetParams(ctx) + vp := ms.GetParamsWithVersion(ctx) btccParams := ms.btccKeeper.GetParams(ctx) kValue, wValue := btccParams.BtcConfirmationDepth, btccParams.CheckpointFinalizationTimeout - minUnbondingTime := types.MinimumUnbondingTime(params, btccParams) + minUnbondingTime := types.MinimumUnbondingTime(vp.Params, btccParams) // Check unbonding time (staking time from unbonding tx) is larger than min unbonding time // which is larger value from: @@ -121,15 +190,27 @@ func (ms msgServer) CreateBTCDelegation(goCtx context.Context, req *types.MsgCre // - is smaller than math.MaxUint16 (due to check in req.ValidateBasic()) validatedUnbondingTime := uint16(req.UnbondingTime) + stakerAddr, err := sdk.AccAddressFromBech32(req.StakerAddr) + if err != nil { + return nil, types.ErrInvalidStakingTx.Wrapf("invalid staker addr %s: %v", req.StakerAddr, err) + } + // verify proof of possession - if err := req.Pop.Verify(req.BabylonPk, req.BtcPk, ms.btcNet); err != nil { + if err := req.Pop.Verify(stakerAddr, req.BtcPk, ms.btcNet); err != nil { return nil, types.ErrInvalidProofOfPossession.Wrapf("error while validating proof of posession: %v", err) } - // Ensure all finality providers are known to Babylon + // Ensure all finality providers are known to Babylon, are not slashed, + // and their registered epochs are finalised for _, fpBTCPK := range req.FpBtcPkList { - if !ms.HasFinalityProvider(ctx, fpBTCPK) { - return nil, types.ErrFpNotFound.Wrapf("finality provider pk: %s", fpBTCPK.MarshalHex()) + // get this finality provider + fp, err := ms.GetFinalityProvider(ctx, fpBTCPK) + if err != nil { + return nil, err + } + // ensure the finality provider is not slashed + if fp.IsSlashed() { + return nil, types.ErrFpAlreadySlashed } } @@ -151,7 +232,7 @@ func (ms msgServer) CreateBTCDelegation(goCtx context.Context, req *types.MsgCre if err != nil { return nil, types.ErrInvalidStakingTx.Wrapf("cannot parse finality provider PK list: %v", err) } - covenantPKs, err := bbn.NewBTCPKsFromBIP340PKs(params.CovenantPks) + covenantPKs, err := bbn.NewBTCPKsFromBIP340PKs(vp.Params.CovenantPks) if err != nil { // programming error panic("failed to parse covenant PKs in KVStore") @@ -162,7 +243,7 @@ func (ms msgServer) CreateBTCDelegation(goCtx context.Context, req *types.MsgCre stakerPk, fpPKs, covenantPKs, - params.CovenantQuorum, + vp.Params.CovenantQuorum, uint16(req.StakingTime), btcutil.Amount(req.StakingValue), ms.btcNet, @@ -209,7 +290,7 @@ func (ms msgServer) CreateBTCDelegation(goCtx context.Context, req *types.MsgCre // decode slashing address // TODO: Decode slashing address only once, as it is the same for all BTC delegations - slashingAddr, err := btcutil.DecodeAddress(params.SlashingAddress, ms.btcNet) + slashingAddr, err := btcutil.DecodeAddress(vp.Params.SlashingAddress, ms.btcNet) if err != nil { panic(fmt.Errorf("failed to decode slashing address in genesis: %w", err)) } @@ -219,8 +300,8 @@ func (ms msgServer) CreateBTCDelegation(goCtx context.Context, req *types.MsgCre slashingMsgTx, stakingMsgTx, stakingOutputIdx, - params.MinSlashingTxFeeSat, - params.SlashingRate, + vp.Params.MinSlashingTxFeeSat, + vp.Params.SlashingRate, slashingAddr, stakerPk, validatedUnbondingTime, @@ -236,8 +317,7 @@ func (ms msgServer) CreateBTCDelegation(goCtx context.Context, req *types.MsgCre } err = req.SlashingTx.VerifySignature( - stakingInfo.StakingOutput.PkScript, - stakingInfo.StakingOutput.Value, + stakingInfo.StakingOutput, slashingSpendInfo.GetPkScriptPath(), stakerPk, req.DelegatorSlashingSig, @@ -251,7 +331,7 @@ func (ms msgServer) CreateBTCDelegation(goCtx context.Context, req *types.MsgCre // have voting power only when 1) its corresponding staking tx is k-deep, // and 2) it receives a covenant signature newBTCDel := &types.BTCDelegation{ - BabylonPk: req.BabylonPk, + StakerAddr: stakerAddr.String(), BtcPk: req.BtcPk, Pop: req.Pop, FpBtcPkList: req.FpBtcPkList, @@ -263,8 +343,9 @@ func (ms msgServer) CreateBTCDelegation(goCtx context.Context, req *types.MsgCre SlashingTx: req.SlashingTx, DelegatorSig: req.DelegatorSlashingSig, UnbondingTime: uint32(validatedUnbondingTime), - CovenantSigs: nil, // NOTE: covenant signature will be submitted in a separate msg by covenant - BtcUndelegation: nil, // this will be constructed in below code + CovenantSigs: nil, // NOTE: covenant signature will be submitted in a separate msg by covenant + BtcUndelegation: nil, // this will be constructed in below code + ParamsVersion: vp.Version, // version of the params against delegations was validated } /* @@ -295,7 +376,7 @@ func (ms msgServer) CreateBTCDelegation(goCtx context.Context, req *types.MsgCre newBTCDel.BtcPk.MustToBTCPK(), fpPKs, covenantPKs, - params.CovenantQuorum, + vp.Params.CovenantQuorum, validatedUnbondingTime, btcutil.Amount(req.UnbondingValue), ms.btcNet, @@ -315,9 +396,9 @@ func (ms msgServer) CreateBTCDelegation(goCtx context.Context, req *types.MsgCre unbondingSlashingMsgTx, unbondingMsgTx, unbondingOutputIdx, - params.MinSlashingTxFeeSat, - params.SlashingRate, - params.MustGetSlashingAddress(ms.btcNet), + vp.Params.MinSlashingTxFeeSat, + vp.Params.SlashingRate, + vp.Params.MustGetSlashingAddress(ms.btcNet), stakerPk, validatedUnbondingTime, ms.btcNet, @@ -335,8 +416,7 @@ func (ms msgServer) CreateBTCDelegation(goCtx context.Context, req *types.MsgCre } err = req.UnbondingSlashingTx.VerifySignature( - unbondingInfo.UnbondingOutput.PkScript, - unbondingInfo.UnbondingOutput.Value, + unbondingInfo.UnbondingOutput, unbondingSlashingSpendInfo.GetPkScriptPath(), newBTCDel.BtcPk.MustToBTCPK(), req.DelegatorUnbondingSlashingSig, @@ -345,9 +425,9 @@ func (ms msgServer) CreateBTCDelegation(goCtx context.Context, req *types.MsgCre return nil, types.ErrInvalidSlashingTx.Wrapf("invalid delegator signature: %v", err) } - // Check unbonding tx against staking tx. - // - that input points to the staking tx, staking output + // 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 if unbondingMsgTx.TxOut[0].Value >= stakingMsgTx.TxOut[newBTCDel.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 @@ -357,6 +437,11 @@ func (ms msgServer) CreateBTCDelegation(goCtx context.Context, req *types.MsgCre return nil, types.ErrInvalidUnbondingTx.Wrapf("unbonding tx fee must be larger that 0") } + minUnbondingValue := caluculateMinimumUnbondingValue(stakingMsgTx.TxOut[stakingOutputIdx], &vp.Params) + if btcutil.Amount(unbondingMsgTx.TxOut[0].Value) < minUnbondingValue { + return nil, types.ErrInvalidUnbondingTx.Wrapf("unbonding output value must be at least %s, based on staking output", minUnbondingValue) + } + // all good, add BTC undelegation newBTCDel.BtcUndelegation = &types.BTCUndelegation{ UnbondingTx: req.UnbondingTx, @@ -367,31 +452,43 @@ func (ms msgServer) CreateBTCDelegation(goCtx context.Context, req *types.MsgCre CovenantUnbondingSigList: nil, } + // add this BTC delegation, and emit corresponding events if err := ms.AddBTCDelegation(ctx, newBTCDel); err != nil { - panic(fmt.Errorf("failed to set BTC delegation that has passed verification: %w", err)) + panic(fmt.Errorf("failed to add BTC delegation that has passed verification: %w", err)) } - // notify subscriber - if err := ctx.EventManager().EmitTypedEvent(&types.EventNewBTCDelegation{BtcDel: newBTCDel}); err != nil { - panic(fmt.Errorf("failed to emit EventNewBTCDelegation: %w", err)) + return &types.MsgCreateBTCDelegationResponse{}, nil +} + +func (ms msgServer) getBTCDelWithParams( + ctx context.Context, + stakingTxHash string) (*types.BTCDelegation, *types.Params, error) { + btcDel, err := ms.GetBTCDelegation(ctx, stakingTxHash) + if err != nil { + return nil, nil, err } - return &types.MsgCreateBTCDelegationResponse{}, nil + bsParams := ms.GetParamsByVersion(ctx, btcDel.ParamsVersion) + if bsParams == nil { + panic("params version in BTC delegation is not found") + } + + return btcDel, bsParams, nil } // AddCovenantSig adds signatures from covenants to a BTC delegation // TODO: refactor this handler. Now it's too convoluted func (ms msgServer) AddCovenantSigs(goCtx context.Context, req *types.MsgAddCovenantSigs) (*types.MsgAddCovenantSigsResponse, error) { + defer telemetry.ModuleMeasureSince(types.ModuleName, time.Now(), types.MetricsKeyAddCovenantSigs) + ctx := sdk.UnwrapSDKContext(goCtx) // basic stateless checks if err := req.ValidateBasic(); err != nil { return nil, status.Errorf(codes.InvalidArgument, "%v", err) } - params := ms.GetParams(ctx) + btcDel, params, err := ms.getBTCDelWithParams(ctx, req.StakingTxHash) - // ensure BTC delegation exists - btcDel, err := ms.GetBTCDelegation(ctx, req.StakingTxHash) if err != nil { return nil, err } @@ -411,10 +508,17 @@ func (ms msgServer) AddCovenantSigs(goCtx context.Context, req *types.MsgAddCove return &types.MsgAddCovenantSigsResponse{}, nil } - // Note: we assume the order of adaptor sigs is matched to the - // order of finality providers in the delegation - // TODO: ensure the order for restaking, currently, we only have one finality provider - // one covenant emulator + // ensure BTC delegation is still pending, i.e., not expired + 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 + } + + // Check that the number of covenant sigs and number of the + // finality providers are matched if len(req.SlashingTxSigs) != len(btcDel.FpBtcPkList) { return nil, types.ErrInvalidCovenantSig.Wrapf( "number of covenant signatures: %d, number of finality providers being staked to: %d", @@ -424,7 +528,7 @@ func (ms msgServer) AddCovenantSigs(goCtx context.Context, req *types.MsgAddCove /* Verify each covenant adaptor signature over slashing tx */ - stakingInfo, err := btcDel.GetStakingInfo(¶ms, ms.btcNet) + stakingInfo, err := btcDel.GetStakingInfo(params, ms.btcNet) if err != nil { panic(fmt.Errorf("failed to get staking info from a verified delegation: %w", err)) } @@ -447,10 +551,6 @@ func (ms msgServer) AddCovenantSigs(goCtx context.Context, req *types.MsgAddCove // Check that the number of covenant sigs and number of the // finality providers are matched - // Note: we assume the order of adaptor sigs is matched to the - // order of finality providers in the delegation - // TODO: ensure the order for restaking, currently, we only have one finality provider - // one covenant emulator if len(req.SlashingUnbondingTxSigs) != len(btcDel.FpBtcPkList) { return nil, types.ErrInvalidCovenantSig.Wrapf( "number of covenant signatures: %d, number of finality providers being staked to: %d", @@ -470,10 +570,9 @@ func (ms msgServer) AddCovenantSigs(goCtx context.Context, req *types.MsgAddCove // this fails, it is a programming error panic(err) } - if err := btcstaking.VerifyTransactionSigWithOutputData( + if err := btcstaking.VerifyTransactionSigWithOutput( unbondingMsgTx, - stakingInfo.StakingOutput.PkScript, - stakingInfo.StakingOutput.Value, + stakingInfo.StakingOutput, unbondingSpendInfo.GetPkScriptPath(), req.Pk.MustToBTCPK(), *req.UnbondingTxSig, @@ -485,7 +584,7 @@ func (ms msgServer) AddCovenantSigs(goCtx context.Context, req *types.MsgAddCove verify each adaptor signature on slashing unbonding tx */ unbondingOutput := unbondingMsgTx.TxOut[0] // unbonding tx always have only one output - unbondingInfo, err := btcDel.GetUnbondingInfo(¶ms, ms.btcNet) + unbondingInfo, err := btcDel.GetUnbondingInfo(params, ms.btcNet) if err != nil { panic(err) } @@ -507,20 +606,17 @@ func (ms msgServer) AddCovenantSigs(goCtx context.Context, req *types.MsgAddCove } // All is fine add received signatures to the BTC delegation and BtcUndelegation - btcDel.AddCovenantSigs( + // and emit corresponding events + ms.addCovenantSigsToBTCDelegation( + ctx, + btcDel, req.Pk, parsedSlashingAdaptorSignatures, req.UnbondingTxSig, parsedUnbondingSlashingAdaptorSignatures, + params, ) - ms.setBTCDelegation(ctx, btcDel) - - // notify subscriber - if err := ctx.EventManager().EmitTypedEvent(&types.EventActivateBTCDelegation{BtcDel: btcDel}); err != nil { - panic(fmt.Errorf("failed to emit EventActivateBTCDelegation: %w", err)) - } - return &types.MsgAddCovenantSigsResponse{}, nil } @@ -528,16 +624,16 @@ func (ms msgServer) AddCovenantSigs(goCtx context.Context, req *types.MsgAddCove // this effectively proves that the BTC delegator wants to unbond and Babylon // will consider its BTC delegation unbonded func (ms msgServer) BTCUndelegate(goCtx context.Context, req *types.MsgBTCUndelegate) (*types.MsgBTCUndelegateResponse, error) { + defer telemetry.ModuleMeasureSince(types.ModuleName, time.Now(), types.MetricsKeyBTCUndelegate) + ctx := sdk.UnwrapSDKContext(goCtx) // basic stateless checks if err := req.ValidateBasic(); err != nil { return nil, status.Errorf(codes.InvalidArgument, "%v", err) } - bsParams := ms.GetParams(ctx) + btcDel, bsParams, err := ms.getBTCDelWithParams(ctx, req.StakingTxHash) - // ensure BTC delegation exists - btcDel, err := ms.GetBTCDelegation(ctx, req.StakingTxHash) if err != nil { return nil, err } @@ -554,7 +650,7 @@ func (ms msgServer) BTCUndelegate(goCtx context.Context, req *types.MsgBTCUndele if err != nil { panic(fmt.Errorf("failed to parse unbonding tx from existing delegation with hash %s : %v", req.StakingTxHash, err)) } - stakingInfo, err := btcDel.GetStakingInfo(&bsParams, ms.btcNet) + stakingInfo, err := btcDel.GetStakingInfo(bsParams, ms.btcNet) if err != nil { panic(fmt.Errorf("failed to get staking info from a verified delegation: %w", err)) } @@ -564,10 +660,9 @@ func (ms msgServer) BTCUndelegate(goCtx context.Context, req *types.MsgBTCUndele // this fails, it is a programming error panic(err) } - if err := btcstaking.VerifyTransactionSigWithOutputData( + if err := btcstaking.VerifyTransactionSigWithOutput( unbondingMsgTx, - stakingInfo.StakingOutput.PkScript, - stakingInfo.StakingOutput.Value, + stakingInfo.StakingOutput, unbondingSpendInfo.GetPkScriptPath(), btcDel.BtcPk.MustToBTCPK(), *req.UnbondingTxSig, @@ -577,20 +672,7 @@ func (ms msgServer) BTCUndelegate(goCtx context.Context, req *types.MsgBTCUndele // all good, add the signature to BTC delegation's undelegation // and set back - btcDel.BtcUndelegation.DelegatorUnbondingSig = req.UnbondingTxSig - ms.setBTCDelegation(ctx, btcDel) - - // notify subscriber about this unbonded BTC delegation - event := &types.EventUnbondedBTCDelegation{ - BtcPk: btcDel.BtcPk, - FpBtcPkList: btcDel.FpBtcPkList, - StakingTxHash: req.StakingTxHash, - UnbondingTxHash: unbondingMsgTx.TxHash().String(), - FromState: types.BTCDelegationStatus_ACTIVE, - } - if err := ctx.EventManager().EmitTypedEvent(event); err != nil { - panic(fmt.Errorf("failed to emit EventUnbondedBTCDelegation: %w", err)) - } + ms.btcUndelegate(ctx, btcDel, req.UnbondingTxSig) return &types.MsgBTCUndelegateResponse{}, nil } @@ -598,14 +680,16 @@ func (ms msgServer) BTCUndelegate(goCtx context.Context, req *types.MsgBTCUndele // SelectiveSlashingEvidence handles the evidence that a finality provider has // selectively slashed a BTC delegation func (ms msgServer) SelectiveSlashingEvidence(goCtx context.Context, req *types.MsgSelectiveSlashingEvidence) (*types.MsgSelectiveSlashingEvidenceResponse, error) { + defer telemetry.ModuleMeasureSince(types.ModuleName, time.Now(), types.MetricsKeySelectiveSlashingEvidence) + ctx := sdk.UnwrapSDKContext(goCtx) - bsParams := ms.GetParams(ctx) - // ensure BTC delegation exists - btcDel, err := ms.GetBTCDelegation(ctx, req.StakingTxHash) + btcDel, bsParams, err := ms.getBTCDelWithParams(ctx, req.StakingTxHash) + if err != nil { return nil, err } + // ensure the BTC delegation is active, or its BTC undelegation receives an // unbonding signature from the staker btcTip := ms.btclcKeeper.GetTipInfo(ctx) @@ -625,11 +709,12 @@ func (ms msgServer) SelectiveSlashingEvidence(goCtx context.Context, req *types. return nil, types.ErrFpNotFound.Wrapf("BTC delegation is not staked to the finality provider") } - // ensure the finality provider exists and is not slashed + // ensure the finality provider exists fp, err := ms.GetFinalityProvider(ctx, fpBTCPK.MustMarshal()) if err != nil { panic(types.ErrFpNotFound.Wrapf("failing to find the finality provider with BTC delegations")) } + // ensure the finality provider is not slashed if fp.IsSlashed() { return nil, types.ErrFpAlreadySlashed } diff --git a/x/btcstaking/keeper/msg_server_test.go b/x/btcstaking/keeper/msg_server_test.go index 58b6536dc..24d2b2cec 100644 --- a/x/btcstaking/keeper/msg_server_test.go +++ b/x/btcstaking/keeper/msg_server_test.go @@ -9,18 +9,21 @@ import ( "time" sdkmath "cosmossdk.io/math" - asig "github.com/babylonchain/babylon/crypto/schnorr-adaptor-signature" - "github.com/babylonchain/babylon/testutil/datagen" - testhelper "github.com/babylonchain/babylon/testutil/helper" - bbn "github.com/babylonchain/babylon/types" - btcctypes "github.com/babylonchain/babylon/x/btccheckpoint/types" - "github.com/babylonchain/babylon/x/btcstaking/types" "github.com/btcsuite/btcd/btcec/v2" - "github.com/btcsuite/btcd/chaincfg" "github.com/btcsuite/btcd/wire" - "github.com/cosmos/cosmos-sdk/crypto/keys/secp256k1" + sdk "github.com/cosmos/cosmos-sdk/types" "github.com/golang/mock/gomock" "github.com/stretchr/testify/require" + "google.golang.org/grpc/codes" + "google.golang.org/grpc/status" + + asig "github.com/babylonlabs-io/babylon/crypto/schnorr-adaptor-signature" + "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" ) func FuzzMsgCreateFinalityProvider(f *testing.F) { @@ -28,7 +31,17 @@ func FuzzMsgCreateFinalityProvider(f *testing.F) { f.Fuzz(func(t *testing.T, seed int64) { r := rand.New(rand.NewSource(seed)) - h := NewHelper(t, nil, nil) + ctrl := gomock.NewController(t) + defer ctrl.Finish() + + // mock BTC light client and BTC checkpoint modules + btclcKeeper := types.NewMockBTCLightClientKeeper(ctrl) + btccKeeper := types.NewMockBtcCheckpointKeeper(ctrl) + ckptKeeper := types.NewMockCheckpointingKeeper(ctrl) + h := NewHelper(t, btclcKeeper, btccKeeper, ckptKeeper) + + // set all parameters + h.GenAndApplyParams(r) // generate new finality providers fps := []*types.FinalityProvider{} @@ -36,10 +49,9 @@ func FuzzMsgCreateFinalityProvider(f *testing.F) { fp, err := datagen.GenRandomFinalityProvider(r) require.NoError(t, err) msg := &types.MsgCreateFinalityProvider{ - Signer: datagen.GenRandomAccount().Address, + Addr: fp.Addr, Description: fp.Description, Commission: fp.Commission, - BabylonPk: fp.BabylonPk, BtcPk: fp.BtcPk, Pop: fp.Pop, } @@ -57,10 +69,9 @@ func FuzzMsgCreateFinalityProvider(f *testing.F) { // duplicated finality providers should not pass for _, fp2 := range fps { msg := &types.MsgCreateFinalityProvider{ - Signer: datagen.GenRandomAccount().Address, + Addr: fp2.Addr, Description: fp2.Description, Commission: fp2.Commission, - BabylonPk: fp2.BabylonPk, BtcPk: fp2.BtcPk, Pop: fp2.Pop, } @@ -70,6 +81,58 @@ func FuzzMsgCreateFinalityProvider(f *testing.F) { }) } +func FuzzMsgEditFinalityProvider(f *testing.F) { + datagen.AddRandomSeedsToFuzzer(f, 10) + + 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) + + // generate new finality provider + fp, err := datagen.GenRandomFinalityProvider(r) + require.NoError(t, err) + // insert the finality provider + h.AddFinalityProvider(fp) + // assert the finality providers exist in KVStore + require.True(t, bsKeeper.HasFinalityProvider(h.Ctx, *fp.BtcPk)) + + // updated commission and description + newCommission := datagen.GenRandomCommission(r) + newDescription := datagen.GenRandomDescription(r) + + // scenario 1: editing finality provider should succeed + msg := &types.MsgEditFinalityProvider{ + Addr: fp.Addr, + BtcPk: *fp.BtcPk, + Description: newDescription, + Commission: &newCommission, + } + _, err = msgSrvr.EditFinalityProvider(h.Ctx, msg) + h.NoError(err) + editedFp, err := bsKeeper.GetFinalityProvider(h.Ctx, *fp.BtcPk) + h.NoError(err) + require.Equal(t, newCommission, *editedFp.Commission) + require.Equal(t, newDescription, editedFp.Description) + + // scenario 2: message from an unauthorised signer should fail + newCommission = datagen.GenRandomCommission(r) + newDescription = datagen.GenRandomDescription(r) + invalidAddr := datagen.GenRandomAccount().Address + msg = &types.MsgEditFinalityProvider{ + Addr: invalidAddr, + BtcPk: *fp.BtcPk, + 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")) + errStatus := status.Convert(err) + require.Equal(t, codes.PermissionDenied, errStatus.Code()) + }) +} + func FuzzCreateBTCDelegation(f *testing.F) { datagen.AddRandomSeedsToFuzzer(f, 10) @@ -81,7 +144,8 @@ func FuzzCreateBTCDelegation(f *testing.F) { // mock BTC light client and BTC checkpoint modules btclcKeeper := types.NewMockBTCLightClientKeeper(ctrl) btccKeeper := types.NewMockBtcCheckpointKeeper(ctrl) - h := NewHelper(t, btclcKeeper, btccKeeper) + ckptKeeper := types.NewMockCheckpointingKeeper(ctrl) + h := NewHelper(t, btclcKeeper, btccKeeper, ckptKeeper) // set all parameters h.GenAndApplyParams(r) @@ -94,7 +158,7 @@ func FuzzCreateBTCDelegation(f *testing.F) { // generate and insert new BTC delegation stakingValue := int64(2 * 10e8) - stakingTxHash, _, _, msgCreateBTCDel := h.CreateDelegation( + stakingTxHash, _, _, msgCreateBTCDel, _ := h.CreateDelegation( r, fpPK, changeAddress.EncodeAddress(), @@ -105,7 +169,7 @@ func FuzzCreateBTCDelegation(f *testing.F) { // 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.BabylonPk, actualDel.BabylonPk) + 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) @@ -117,6 +181,71 @@ func FuzzCreateBTCDelegation(f *testing.F) { }) } +func TestProperVersionInDelegation(t *testing.T) { + r := rand.New(rand.NewSource(time.Now().Unix())) + ctrl := gomock.NewController(t) + defer ctrl.Finish() + + // mock BTC light client and BTC checkpoint modules + btclcKeeper := types.NewMockBTCLightClientKeeper(ctrl) + btccKeeper := types.NewMockBtcCheckpointKeeper(ctrl) + ckptKeeper := types.NewMockCheckpointingKeeper(ctrl) + h := NewHelper(t, btclcKeeper, btccKeeper, ckptKeeper) + + // set all parameters + 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) + stakingTxHash, _, _, _, _ := h.CreateDelegation( + r, + fpPK, + changeAddress.EncodeAddress(), + stakingValue, + 1000, + ) + + // ensure consistency between the msg and the BTC delegation in DB + actualDel, err := h.BTCStakingKeeper.GetBTCDelegation(h.Ctx, stakingTxHash) + h.NoError(err) + err = actualDel.ValidateBasic() + h.NoError(err) + // Current version will be `1` as: + // - version `0` is initialized by `NewHelper` + // - version `1` is set by `GenAndApplyParams` + require.Equal(t, uint32(1), actualDel.ParamsVersion) + + customMinUnbondingTime := uint32(2000) + currentParams := h.BTCStakingKeeper.GetParams(h.Ctx) + currentParams.MinUnbondingTime = 2000 + // Update new params + err = h.BTCStakingKeeper.SetParams(h.Ctx, currentParams) + require.NoError(t, err) + // create new delegation + stakingTxHash1, _, _, _, err := h.CreateDelegationCustom( + r, + fpPK, + changeAddress.EncodeAddress(), + stakingValue, + 1000, + stakingValue-1000, + uint16(customMinUnbondingTime)+1, + ) + require.NoError(t, err) + actualDel1, err := h.BTCStakingKeeper.GetBTCDelegation(h.Ctx, stakingTxHash1) + h.NoError(err) + err = actualDel1.ValidateBasic() + h.NoError(err) + // Assert that the new delegation has the updated params version + require.Equal(t, uint32(2), actualDel1.ParamsVersion) +} + func FuzzAddCovenantSigs(f *testing.F) { datagen.AddRandomSeedsToFuzzer(f, 10) @@ -128,7 +257,8 @@ func FuzzAddCovenantSigs(f *testing.F) { // mock BTC light client and BTC checkpoint modules btclcKeeper := types.NewMockBTCLightClientKeeper(ctrl) btccKeeper := types.NewMockBtcCheckpointKeeper(ctrl) - h := NewHelper(t, btclcKeeper, btccKeeper) + ckptKeeper := types.NewMockCheckpointingKeeper(ctrl) + h := NewHelper(t, btclcKeeper, btccKeeper, ckptKeeper) // set all parameters covenantSKs, _ := h.GenAndApplyParams(r) @@ -141,7 +271,7 @@ func FuzzAddCovenantSigs(f *testing.F) { // generate and insert new BTC delegation stakingValue := int64(2 * 10e8) - stakingTxHash, _, _, msgCreateBTCDel := h.CreateDelegation( + stakingTxHash, _, _, msgCreateBTCDel, _ := h.CreateDelegation( r, fpPK, changeAddress.EncodeAddress(), @@ -192,7 +322,8 @@ func FuzzBTCUndelegate(f *testing.F) { // mock BTC light client and BTC checkpoint modules btclcKeeper := types.NewMockBTCLightClientKeeper(ctrl) btccKeeper := types.NewMockBtcCheckpointKeeper(ctrl) - h := NewHelper(t, btclcKeeper, btccKeeper) + ckptKeeper := types.NewMockCheckpointingKeeper(ctrl) + h := NewHelper(t, btclcKeeper, btccKeeper, ckptKeeper) // set all parameters covenantSKs, _ := h.GenAndApplyParams(r) @@ -208,7 +339,7 @@ func FuzzBTCUndelegate(f *testing.F) { // generate and insert new BTC delegation stakingValue := int64(2 * 10e8) - stakingTxHash, delSK, _, msgCreateBTCDel := h.CreateDelegation( + stakingTxHash, delSK, _, msgCreateBTCDel, actualDel := h.CreateDelegation( r, fpPK, changeAddress.EncodeAddress(), @@ -217,8 +348,6 @@ func FuzzBTCUndelegate(f *testing.F) { ) // add covenant signatures to this BTC delegation - actualDel, err := h.BTCStakingKeeper.GetBTCDelegation(h.Ctx, stakingTxHash) - h.NoError(err) h.CreateCovenantSigs(r, covenantSKs, msgCreateBTCDel, actualDel) // ensure the BTC delegation is bonded right now @@ -266,7 +395,8 @@ func FuzzSelectiveSlashing(f *testing.F) { // mock BTC light client and BTC checkpoint modules btclcKeeper := types.NewMockBTCLightClientKeeper(ctrl) btccKeeper := types.NewMockBtcCheckpointKeeper(ctrl) - h := NewHelper(t, btclcKeeper, btccKeeper) + ckptKeeper := types.NewMockCheckpointingKeeper(ctrl) + h := NewHelper(t, btclcKeeper, btccKeeper, ckptKeeper) // set all parameters covenantSKs, _ := h.GenAndApplyParams(r) @@ -281,7 +411,7 @@ func FuzzSelectiveSlashing(f *testing.F) { // generate and insert new BTC delegation stakingValue := int64(2 * 10e8) - stakingTxHash, _, _, msgCreateBTCDel := h.CreateDelegation( + stakingTxHash, _, _, msgCreateBTCDel, actualDel := h.CreateDelegation( r, fpPK, changeAddress.EncodeAddress(), @@ -291,8 +421,6 @@ func FuzzSelectiveSlashing(f *testing.F) { // add covenant signatures to this BTC delegation // so that the BTC delegation becomes bonded - actualDel, err := h.BTCStakingKeeper.GetBTCDelegation(h.Ctx, stakingTxHash) - h.NoError(err) h.CreateCovenantSigs(r, covenantSKs, msgCreateBTCDel, actualDel) // now BTC delegation has all covenant signatures actualDel, err = h.BTCStakingKeeper.GetBTCDelegation(h.Ctx, stakingTxHash) @@ -334,7 +462,8 @@ func FuzzSelectiveSlashing_StakingTx(f *testing.F) { // mock BTC light client and BTC checkpoint modules btclcKeeper := types.NewMockBTCLightClientKeeper(ctrl) btccKeeper := types.NewMockBtcCheckpointKeeper(ctrl) - h := NewHelper(t, btclcKeeper, btccKeeper) + ckptKeeper := types.NewMockCheckpointingKeeper(ctrl) + h := NewHelper(t, btclcKeeper, btccKeeper, ckptKeeper) // set all parameters covenantSKs, _ := h.GenAndApplyParams(r) @@ -349,7 +478,7 @@ func FuzzSelectiveSlashing_StakingTx(f *testing.F) { // generate and insert new BTC delegation stakingValue := int64(2 * 10e8) - stakingTxHash, _, _, msgCreateBTCDel := h.CreateDelegation( + stakingTxHash, _, _, msgCreateBTCDel, actualDel := h.CreateDelegation( r, fpPK, changeAddress.EncodeAddress(), @@ -359,8 +488,6 @@ func FuzzSelectiveSlashing_StakingTx(f *testing.F) { // add covenant signatures to this BTC delegation // so that the BTC delegation becomes bonded - actualDel, err := h.BTCStakingKeeper.GetBTCDelegation(h.Ctx, stakingTxHash) - h.NoError(err) h.CreateCovenantSigs(r, covenantSKs, msgCreateBTCDel, actualDel) // now BTC delegation has all covenant signatures actualDel, err = h.BTCStakingKeeper.GetBTCDelegation(h.Ctx, stakingTxHash) @@ -412,7 +539,8 @@ func TestDoNotAllowDelegationWithoutFinalityProvider(t *testing.T) { btclcKeeper := types.NewMockBTCLightClientKeeper(ctrl) btccKeeper := types.NewMockBtcCheckpointKeeper(ctrl) btccKeeper.EXPECT().GetParams(gomock.Any()).Return(btcctypes.DefaultParams()).AnyTimes() - h := NewHelper(t, btclcKeeper, btccKeeper) + ckptKeeper := types.NewMockCheckpointingKeeper(ctrl) + h := NewHelper(t, btclcKeeper, btccKeeper, ckptKeeper) // set covenant PK to params _, covenantPKs := h.GenAndApplyParams(r) @@ -456,13 +584,12 @@ func TestDoNotAllowDelegationWithoutFinalityProvider(t *testing.T) { stakingMsgTx := testStakingInfo.StakingTx serializedStakingTx, err := bbn.SerializeBTCTx(stakingMsgTx) require.NoError(t, err) - // random signer - signer := datagen.GenRandomAccount().Address // random Babylon SK - delBabylonSK, delBabylonPK, err := datagen.GenRandomSecp256k1KeyPair(r) - require.NoError(t, err) + acc := datagen.GenRandomAccount() + stakerAddr := sdk.MustAccAddressFromBech32(acc.Address) + // PoP - pop, err := types.NewPoP(delBabylonSK, delSK) + pop, err := types.NewPoPBTC(stakerAddr, delSK) require.NoError(t, err) // generate staking tx info prevBlock, _ := datagen.GenRandomBtcdBlock(r, 0, nil) @@ -510,10 +637,10 @@ func TestDoNotAllowDelegationWithoutFinalityProvider(t *testing.T) { h.NoError(err) // all good, construct and send MsgCreateBTCDelegation message + fpBTCPK := bbn.NewBIP340PubKeyFromBTCPK(fpPK) msgCreateBTCDel := &types.MsgCreateBTCDelegation{ - Signer: signer, - BabylonPk: delBabylonPK.(*secp256k1.PubKey), - FpBtcPkList: []bbn.BIP340PubKey{*bbn.NewBIP340PubKeyFromBTCPK(fpPK)}, + StakerAddr: stakerAddr.String(), + FpBtcPkList: []bbn.BIP340PubKey{*fpBTCPK}, BtcPk: bbn.NewBIP340PubKeyFromBTCPK(delSK.PubKey()), Pop: pop, StakingTime: uint32(stakingTimeBlocks), @@ -527,6 +654,7 @@ func TestDoNotAllowDelegationWithoutFinalityProvider(t *testing.T) { UnbondingSlashingTx: testUnbondingInfo.SlashingTx, DelegatorUnbondingSlashingSig: delUnbondingSlashingSig, } + _, err = h.MsgServer.CreateBTCDelegation(h.Ctx, msgCreateBTCDel) require.Error(t, err) require.True(t, errors.Is(err, types.ErrFpNotFound)) @@ -579,7 +707,8 @@ func TestCorrectUnbondingTimeInDelegation(t *testing.T) { // mock BTC light client and BTC checkpoint modules btclcKeeper := types.NewMockBTCLightClientKeeper(ctrl) btccKeeper := types.NewMockBtcCheckpointKeeper(ctrl) - h := NewHelper(t, btclcKeeper, btccKeeper) + ckptKeeper := types.NewMockCheckpointingKeeper(ctrl) + h := NewHelper(t, btclcKeeper, btccKeeper, ckptKeeper) // set all parameters _, _ = h.GenAndApplyCustomParams(r, tt.finalizationTimeout, tt.minUnbondingTime) @@ -598,6 +727,7 @@ func TestCorrectUnbondingTimeInDelegation(t *testing.T) { changeAddress.EncodeAddress(), stakingValue, 1000, + stakingValue-1000, tt.unbondingTimeInDelegation, ) if tt.err != nil { @@ -614,6 +744,78 @@ func TestCorrectUnbondingTimeInDelegation(t *testing.T) { } } +func TestMinimalUnbondingRate(t *testing.T) { + tests := []struct { + name string + stakingValue int64 + unbondingValueInDelegation int64 + err error + }{ + { + name: "successful delegation when unbonding value is >=80% of staking value", + stakingValue: 10000, + unbondingValueInDelegation: 8000, + err: nil, + }, + { + name: "failed delegation when unbonding value is <80% of staking value", + stakingValue: 10000, + unbondingValueInDelegation: 7999, + err: types.ErrInvalidUnbondingTx, + }, + { + name: "failed delegation when unbonding value >= stake value", + stakingValue: 10000, + unbondingValueInDelegation: 10000, + err: types.ErrInvalidUnbondingTx, + }, + } + + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + r := rand.New(rand.NewSource(time.Now().Unix())) + ctrl := gomock.NewController(t) + defer ctrl.Finish() + + // mock BTC light client and BTC checkpoint modules + btclcKeeper := types.NewMockBTCLightClientKeeper(ctrl) + btccKeeper := types.NewMockBtcCheckpointKeeper(ctrl) + ckptKeeper := types.NewMockCheckpointingKeeper(ctrl) + h := NewHelper(t, btclcKeeper, btccKeeper, ckptKeeper) + + // set all parameters, by default minimal unbonding value is 80% of staking value + _, _ = 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 + stakingTxHash, _, _, _, err := h.CreateDelegationCustom( + r, + fpPK, + changeAddress.EncodeAddress(), + tt.stakingValue, + 1000, + tt.unbondingValueInDelegation, + 1000, + ) + if tt.err != nil { + require.Error(t, err) + require.True(t, errors.Is(err, tt.err)) + } else { + require.NoError(t, err) + // Retrieve delegation from keeper + delegation, err := h.BTCStakingKeeper.GetBTCDelegation(h.Ctx, stakingTxHash) + require.NoError(t, err) + require.NotNil(t, delegation) + } + }) + } +} + func createNDelegationsForFinalityProvider( r *rand.Rand, t *testing.T, @@ -624,13 +826,12 @@ func createNDelegationsForFinalityProvider( ) []*types.BTCDelegation { var delegations []*types.BTCDelegation for i := 0; i < numDelegations; i++ { - covenatnSks, _, err := datagen.GenRandomBTCKeyPairs(r, int(quorum)) + covenatnSks, covenantPks, err := datagen.GenRandomBTCKeyPairs(r, int(quorum)) require.NoError(t, err) delSK, _, err := datagen.GenRandomBTCKeyPair(r) require.NoError(t, err) - net := &chaincfg.SimNetParams slashingAddress, err := datagen.GenRandomBTCAddress(r, net) require.NoError(t, err) @@ -639,9 +840,11 @@ func createNDelegationsForFinalityProvider( del, err := datagen.GenRandomBTCDelegation( r, t, + net, []bbn.BIP340PubKey{*bbn.NewBIP340PubKeyFromBTCPK(fpPK)}, delSK, covenatnSks, + covenantPks, quorum, slashingAddress.EncodeAddress(), 0, @@ -668,14 +871,29 @@ func FuzzDeterminismBtcstakingBeginBlocker(f *testing.F) { f.Fuzz(func(t *testing.T, seed int64) { r := rand.New(rand.NewSource(seed)) - valSet, privSigner, err := datagen.GenesisValidatorSetWithPrivSigner(1) + valSet, privSigner, err := datagen.GenesisValidatorSetWithPrivSigner(2) require.NoError(t, err) - var expectedProviderData map[string]*ExpectedProviderData = make(map[string]*ExpectedProviderData) + var expectedProviderData = make(map[string]*ExpectedProviderData) // Create two test apps from the same set of validators h := testhelper.NewHelperWithValSet(t, valSet, privSigner) h1 := testhelper.NewHelperWithValSet(t, valSet, privSigner) + // app hash should be same at the beginning + appHash1 := hex.EncodeToString(h.Ctx.BlockHeader().AppHash) + appHash2 := hex.EncodeToString(h1.Ctx.BlockHeader().AppHash) + require.Equal(t, appHash1, appHash2) + + // Execute block for both apps + h.Ctx, err = h.ApplyEmptyBlockWithVoteExtension(r) + require.NoError(t, err) + h1.Ctx, err = h1.ApplyEmptyBlockWithVoteExtension(r) + require.NoError(t, err) + // Given that there is no transactions and the data in db is the same + // app hash produced by both apps should be the same + appHash1 = hex.EncodeToString(h.Ctx.BlockHeader().AppHash) + appHash2 = hex.EncodeToString(h1.Ctx.BlockHeader().AppHash) + require.Equal(t, appHash1, appHash2) // Default params are the same in both apps covQuorum := h.App.BTCStakingKeeper.GetParams(h.Ctx).CovenantQuorum @@ -720,16 +938,14 @@ func FuzzDeterminismBtcstakingBeginBlocker(f *testing.F) { } // Execute block for both apps - ctx, err := h.ApplyEmptyBlockWithVoteExtension(r) + h.Ctx, err = h.ApplyEmptyBlockWithVoteExtension(r) require.NoError(t, err) - - ctx1, err := h1.ApplyEmptyBlockWithVoteExtension(r) + h1.Ctx, err = h1.ApplyEmptyBlockWithVoteExtension(r) require.NoError(t, err) - // Given that there is no transactions and the data in db is the same // app hash produced by both apps should be the same - appHash1 := hex.EncodeToString(ctx.BlockHeader().AppHash) - appHash2 := hex.EncodeToString(ctx1.BlockHeader().AppHash) + appHash1 = hex.EncodeToString(h.Ctx.BlockHeader().AppHash) + appHash2 = hex.EncodeToString(h1.Ctx.BlockHeader().AppHash) require.Equal(t, appHash1, appHash2) }) } diff --git a/x/btcstaking/keeper/params.go b/x/btcstaking/keeper/params.go index 4859efb28..0f47ba169 100644 --- a/x/btcstaking/keeper/params.go +++ b/x/btcstaking/keeper/params.go @@ -2,34 +2,131 @@ package keeper import ( "context" + "encoding/binary" + "fmt" + "cosmossdk.io/math" - "github.com/babylonchain/babylon/x/btcstaking/types" + "cosmossdk.io/store/prefix" + "github.com/babylonlabs-io/babylon/x/btcstaking/types" + "github.com/cosmos/cosmos-sdk/runtime" ) +// cosmos-sdk does not have utils for uint32 +func uint32ToBytes(v uint32) []byte { + var buf [4]byte + binary.BigEndian.PutUint32(buf[:], v) + return buf[:] +} +func uint32FromBytes(b []byte) (uint32, error) { + if len(b) != 4 { + return 0, fmt.Errorf("invalid uint32 bytes length: %d", len(b)) + } + + return binary.BigEndian.Uint32(b), nil +} + +func mustUint32FromBytes(b []byte) uint32 { + v, err := uint32FromBytes(b) + if err != nil { + panic(err) + } + + return v +} + +func (k Keeper) paramsStore(ctx context.Context) prefix.Store { + storeAdapter := runtime.KVStoreAdapter(k.storeService.OpenKVStore(ctx)) + return prefix.NewStore(storeAdapter, types.ParamsKey) +} + +func (k Keeper) nextParamsVersion(ctx context.Context) uint32 { + paramsStore := k.paramsStore(ctx) + it := paramsStore.ReverseIterator(nil, nil) + defer it.Close() + + if !it.Valid() { + return 0 + } + + return mustUint32FromBytes(it.Key()) + 1 +} + +func (k Keeper) getLastParams(ctx context.Context) *types.StoredParams { + paramsStore := k.paramsStore(ctx) + it := paramsStore.ReverseIterator(nil, nil) + defer it.Close() + + if !it.Valid() { + return nil + } + var sp types.StoredParams + k.cdc.MustUnmarshal(it.Value(), &sp) + return &sp +} + // SetParams sets the x/btcstaking module parameters. func (k Keeper) SetParams(ctx context.Context, p types.Params) error { if err := p.Validate(); err != nil { return err } - store := k.storeService.OpenKVStore(ctx) - bz := k.cdc.MustMarshal(&p) - return store.Set(types.ParamsKey, bz) -} -// GetParams returns the current x/btcstaking module parameters. -func (k Keeper) GetParams(ctx context.Context) (p types.Params) { - store := k.storeService.OpenKVStore(ctx) - bz, err := store.Get(types.ParamsKey) - if err != nil { - panic(err) + nextVersion := k.nextParamsVersion(ctx) + paramsStore := k.paramsStore(ctx) + + sp := types.StoredParams{ + Params: p, + Version: nextVersion, } - if bz == nil { - return p + + paramsStore.Set(uint32ToBytes(nextVersion), k.cdc.MustMarshal(&sp)) + return nil +} + +func (k Keeper) GetAllParams(ctx context.Context) []*types.Params { + paramsStore := k.paramsStore(ctx) + it := paramsStore.Iterator(nil, nil) + defer it.Close() + + var p []*types.Params + for ; it.Valid(); it.Next() { + var sp types.StoredParams + k.cdc.MustUnmarshal(it.Value(), &sp) + p = append(p, &sp.Params) } - k.cdc.MustUnmarshal(bz, &p) + return p } +func (k Keeper) GetParamsByVersion(ctx context.Context, v uint32) *types.Params { + paramsStore := k.paramsStore(ctx) + spBytes := paramsStore.Get(uint32ToBytes(v)) + if len(spBytes) == 0 { + return nil + } + + var sp types.StoredParams + k.cdc.MustUnmarshal(spBytes, &sp) + return &sp.Params +} + +func mustGetLastParams(ctx context.Context, k Keeper) types.StoredParams { + sp := k.getLastParams(ctx) + if sp == nil { + panic("last params not found") + } + + return *sp +} + +// GetParams returns the latest x/btcstaking module parameters. +func (k Keeper) GetParams(ctx context.Context) types.Params { + return mustGetLastParams(ctx, k).Params +} + +func (k Keeper) GetParamsWithVersion(ctx context.Context) types.StoredParams { + return mustGetLastParams(ctx, k) +} + // MinCommissionRate returns the minimal commission rate of finality providers func (k Keeper) MinCommissionRate(ctx context.Context) math.LegacyDec { return k.GetParams(ctx).MinCommissionRate diff --git a/x/btcstaking/keeper/params_test.go b/x/btcstaking/keeper/params_test.go index adf55969b..58f8500f4 100644 --- a/x/btcstaking/keeper/params_test.go +++ b/x/btcstaking/keeper/params_test.go @@ -1,15 +1,18 @@ package keeper_test import ( + "math" + "math/rand" "testing" - testkeeper "github.com/babylonchain/babylon/testutil/keeper" - "github.com/babylonchain/babylon/x/btcstaking/types" + "github.com/babylonlabs-io/babylon/testutil/datagen" + testkeeper "github.com/babylonlabs-io/babylon/testutil/keeper" + "github.com/babylonlabs-io/babylon/x/btcstaking/types" "github.com/stretchr/testify/require" ) func TestGetParams(t *testing.T) { - k, ctx := testkeeper.BTCStakingKeeper(t, nil, nil) + k, ctx := testkeeper.BTCStakingKeeper(t, nil, nil, nil) params := types.DefaultParams() err := k.SetParams(ctx, params) @@ -17,3 +20,74 @@ func TestGetParams(t *testing.T) { require.EqualValues(t, params, k.GetParams(ctx)) } + +func TestGetParamsVersions(t *testing.T) { + k, ctx := testkeeper.BTCStakingKeeper(t, nil, nil, nil) + params := types.DefaultParams() + + pv := k.GetParamsWithVersion(ctx) + + require.EqualValues(t, params, pv.Params) + require.EqualValues(t, uint32(0), pv.Version) + + params1 := types.DefaultParams() + params1.MinSlashingTxFeeSat = 23400 + + err := k.SetParams(ctx, params1) + require.NoError(t, err) + + pv = k.GetParamsWithVersion(ctx) + p := k.GetParams(ctx) + require.EqualValues(t, params1, pv.Params) + require.EqualValues(t, params1, p) + require.EqualValues(t, uint32(1), pv.Version) + + pv0 := k.GetParamsByVersion(ctx, 0) + require.NotNil(t, pv0) + require.EqualValues(t, params, *pv0) + pv1 := k.GetParamsByVersion(ctx, 1) + require.NotNil(t, pv1) + require.EqualValues(t, params1, *pv1) +} + +// Property: All public methods related to params are consistent with each other +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) + numVersionsToGenerate := r.Intn(100) + 1 + params0 := k.GetParams(ctx) + var generatedParams []*types.Params + generatedParams = append(generatedParams, ¶ms0) + + for i := 0; i < numVersionsToGenerate; i++ { + params := types.DefaultParams() + // randomize two parameters so each params are slightly different + params.MinSlashingTxFeeSat = r.Int63() + params.MinUnbondingTime = uint32(r.Intn(math.MaxUint16)) + err := k.SetParams(ctx, params) + require.NoError(t, err) + generatedParams = append(generatedParams, ¶ms) + } + + allParams := k.GetAllParams(ctx) + + require.Equal(t, len(generatedParams), len(allParams)) + + for i := 0; i < len(generatedParams); i++ { + // Check that params from aggregate query are ok + require.EqualValues(t, *generatedParams[i], *allParams[i]) + + // Check retrieval by version is ok + paramByVersion := k.GetParamsByVersion(ctx, uint32(i)) + require.NotNil(t, paramByVersion) + require.EqualValues(t, *generatedParams[i], *paramByVersion) + } + + lastParams := k.GetParams(ctx) + lastVer := k.GetParamsByVersion(ctx, uint32(len(generatedParams)-1)) + require.EqualValues(t, *generatedParams[len(generatedParams)-1], lastParams) + require.EqualValues(t, lastParams, *lastVer) + }) +} diff --git a/x/btcstaking/keeper/power_dist_change.go b/x/btcstaking/keeper/power_dist_change.go new file mode 100644 index 000000000..bde774ce7 --- /dev/null +++ b/x/btcstaking/keeper/power_dist_change.go @@ -0,0 +1,346 @@ +package keeper + +import ( + "context" + "fmt" + "sort" + + "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" +) + +/* 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 + k.recordVotingPowerAndCache(ctx, dc, 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, maxActiveFps) + + // find newly bonded finality providers and execute the hooks + newBondedFinalityProviders := newDc.FindNewActiveFinalityProviders(dc, maxActiveFps) + for _, fp := range newBondedFinalityProviders { + if err := k.hooks.AfterFinalityProviderActivated(ctx, fp.BtcPk); err != nil { + panic(fmt.Errorf("failed to execute after finality provider %s bonded", fp.BtcPk.MarshalHex())) + } + } + + // record voting power and cache for this height + k.recordVotingPowerAndCache(ctx, newDc, maxActiveFps) + // record metrics + k.recordMetrics(newDc, maxActiveFps) +} + +func (k Keeper) recordVotingPowerAndCache(ctx context.Context, dc *types.VotingPowerDistCache, maxActiveFps uint32) { + babylonTipHeight := uint64(sdk.UnwrapSDKContext(ctx).HeaderInfo().Height) + + // set voting power table for this height + for i := uint32(0); i < dc.GetNumActiveFPs(maxActiveFps); i++ { + fp := dc.FinalityProviders[i] + k.SetVotingPower(ctx, fp.BtcPk.MustMarshal(), babylonTipHeight, fp.TotalVotingPower) + + } + + // set the voting power distribution cache of the current height + k.setVotingPowerDistCache(ctx, babylonTipHeight, dc) +} + +func (k Keeper) recordMetrics(dc *types.VotingPowerDistCache, maxActiveFps uint32) { + // number of active FPs + numActiveFPs := int(dc.GetNumActiveFPs(maxActiveFps)) + 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, + maxActiveFps uint32, +) *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{}{} + + /* + filter and classify all events into new/expired BTC delegations and 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 finality provider + for _, fpBTCPK := range btcDel.FpBtcPkList { + 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: + // slashed finality providers + slashedFPs[typedEvent.SlashedFp.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 := 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 recording it + if _, ok := slashedFPs[fpBTCPKHex]; ok { + continue + } + + // 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.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 { + fpDistInfo.AddBTCDel(d) + } + + // add this finality provider to the new cache if it has voting power + if fpDistInfo.TotalVotingPower > 0 { + newDc.AddFinalityProviderDistInfo(fpDistInfo) + } + } + + // filter out the top N finality providers and their total voting power, and + // record them in the new cache + newDc.ApplyActiveFinalityProviders(maxActiveFps) + + 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, + event *types.EventPowerDistUpdate, +) { + store := k.powerDistUpdateEventBtcHeightStore(ctx, btcHeight) + + // get event index + eventIdx := uint64(0) // event index starts from 0 + iter := store.ReverseIterator(nil, nil) + defer iter.Close() + if iter.Valid() { + // if there exists events already, event index will be the subsequent one + eventIdx = sdk.BigEndianToUint64(iter.Key()) + 1 + } + + // key is event index, and value is the event bytes + store.Set(sdk.Uint64ToBigEndian(eventIdx), k.cdc.MustMarshal(event)) +} + +// ClearPowerDistUpdateEvents removes all BTC delegation state update events +// 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) { + store := k.powerDistUpdateEventBtcHeightStore(ctx, btcHeight) + keys := [][]byte{} + + // get all keys + // using an enclosure to ensure iterator is closed right after + // the function is done + func() { + iter := store.Iterator(nil, nil) + defer iter.Close() + for ; iter.Valid(); iter.Next() { + keys = append(keys, iter.Key()) + } + }() + + // remove all keys + for _, key := range keys { + store.Delete(key) + } +} + +// GetAllPowerDistUpdateEvents gets all voting power update events +func (k Keeper) GetAllPowerDistUpdateEvents(ctx context.Context, lastBTCTip uint64, curBTCTip uint64) []*types.EventPowerDistUpdate { + events := []*types.EventPowerDistUpdate{} + for i := lastBTCTip; i <= curBTCTip; i++ { + k.IteratePowerDistUpdateEvents(ctx, i, func(event *types.EventPowerDistUpdate) bool { + events = append(events, event) + return true + }) + } + return events +} + +// 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( + ctx context.Context, + btcHeight uint64, + handleFunc func(event *types.EventPowerDistUpdate) bool, +) { + store := k.powerDistUpdateEventBtcHeightStore(ctx, btcHeight) + iter := store.Iterator(nil, nil) + defer iter.Close() + for ; iter.Valid(); iter.Next() { + var event types.EventPowerDistUpdate + k.cdc.MustUnmarshal(iter.Value(), &event) + shouldContinue := handleFunc(&event) + if !shouldContinue { + break + } + } +} + +// powerDistUpdateEventBtcHeightStore returns the KVStore of events that affect +// voting power distribution +// prefix: PowerDistUpdateKey || BTC height +// key: event index) +// value: BTCDelegationStatus +func (k Keeper) powerDistUpdateEventBtcHeightStore(ctx context.Context, btcHeight uint64) prefix.Store { + store := k.powerDistUpdateEventStore(ctx) + return prefix.NewStore(store, sdk.Uint64ToBigEndian(btcHeight)) +} + +// powerDistUpdateEventStore returns the KVStore of events that affect +// voting power distribution +// prefix: PowerDistUpdateKey +// key: (BTC height || event index) +// value: BTCDelegationStatus +func (k Keeper) powerDistUpdateEventStore(ctx context.Context) prefix.Store { + storeAdapter := runtime.KVStoreAdapter(k.storeService.OpenKVStore(ctx)) + return prefix.NewStore(storeAdapter, types.PowerDistUpdateKey) +} diff --git a/x/btcstaking/keeper/power_dist_change_test.go b/x/btcstaking/keeper/power_dist_change_test.go new file mode 100644 index 000000000..65320c5df --- /dev/null +++ b/x/btcstaking/keeper/power_dist_change_test.go @@ -0,0 +1,247 @@ +package keeper_test + +import ( + "math/rand" + "testing" + + "github.com/babylonlabs-io/babylon/testutil/datagen" + btclctypes "github.com/babylonlabs-io/babylon/x/btclightclient/types" + "github.com/babylonlabs-io/babylon/x/btcstaking/types" + "github.com/btcsuite/btcd/btcec/v2" + "github.com/golang/mock/gomock" + "github.com/stretchr/testify/require" +) + +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) + ckptKeeper := types.NewMockCheckpointingKeeper(ctrl) + h := NewHelper(t, btclcKeeper, btccKeeper, ckptKeeper) + + // 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 := h.CreateDelegation(r, fpPK, changeAddress.EncodeAddress(), stakingValue, 1000) + 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, 100) + for i := 0; i < 10; i++ { + newDc2 := h.BTCStakingKeeper.ProcessAllPowerDistUpdateEvents(h.Ctx, dc, events, 100) + require.Equal(t, newDc, newDc2) + } + }) +} + +func FuzzFinalityProviderEvents(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) + ckptKeeper := types.NewMockCheckpointingKeeper(ctrl) + h := NewHelper(t, btclcKeeper, btccKeeper, ckptKeeper) + + // 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 := h.CreateDelegation( + r, + fpPK, + changeAddress.EncodeAddress(), + stakingValue, + 1000, + ) + // 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) + + // 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 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) + ckptKeeper := types.NewMockCheckpointingKeeper(ctrl) + h := NewHelper(t, btclcKeeper, btccKeeper, ckptKeeper) + + // 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 := h.CreateDelegation( + r, + fpPK, + changeAddress.EncodeAddress(), + stakingValue, + 1000, + ) + + /* + 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 has voting power at the current height + 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) + 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.go b/x/btcstaking/keeper/query.go index 7a46601f8..ae817f28f 100644 --- a/x/btcstaking/keeper/query.go +++ b/x/btcstaking/keeper/query.go @@ -1,7 +1,7 @@ package keeper import ( - "github.com/babylonchain/babylon/x/btcstaking/types" + "github.com/babylonlabs-io/babylon/x/btcstaking/types" ) var _ types.QueryServer = Keeper{} diff --git a/x/btcstaking/keeper/query_params.go b/x/btcstaking/keeper/query_params.go index 1dda6409c..eed444b02 100644 --- a/x/btcstaking/keeper/query_params.go +++ b/x/btcstaking/keeper/query_params.go @@ -3,7 +3,7 @@ package keeper import ( "context" - "github.com/babylonchain/babylon/x/btcstaking/types" + "github.com/babylonlabs-io/babylon/x/btcstaking/types" sdk "github.com/cosmos/cosmos-sdk/types" "google.golang.org/grpc/codes" "google.golang.org/grpc/status" @@ -17,3 +17,18 @@ func (k Keeper) Params(goCtx context.Context, req *types.QueryParamsRequest) (*t return &types.QueryParamsResponse{Params: k.GetParams(ctx)}, nil } + +func (k Keeper) ParamsByVersion(goCtx context.Context, req *types.QueryParamsByVersionRequest) (*types.QueryParamsByVersionResponse, error) { + if req == nil { + return nil, status.Error(codes.InvalidArgument, "invalid request") + } + ctx := sdk.UnwrapSDKContext(goCtx) + + pv := k.GetParamsByVersion(ctx, req.Version) + + if pv == nil { + return nil, types.ErrParamsNotFound.Wrapf("version %d does not exists", req.Version) + } + + return &types.QueryParamsByVersionResponse{Params: *pv}, nil +} diff --git a/x/btcstaking/keeper/query_params_test.go b/x/btcstaking/keeper/query_params_test.go index b4c07587b..6d0239d0b 100644 --- a/x/btcstaking/keeper/query_params_test.go +++ b/x/btcstaking/keeper/query_params_test.go @@ -3,13 +3,13 @@ package keeper_test import ( "testing" - testkeeper "github.com/babylonchain/babylon/testutil/keeper" - "github.com/babylonchain/babylon/x/btcstaking/types" + testkeeper "github.com/babylonlabs-io/babylon/testutil/keeper" + "github.com/babylonlabs-io/babylon/x/btcstaking/types" "github.com/stretchr/testify/require" ) func TestParamsQuery(t *testing.T) { - keeper, ctx := testkeeper.BTCStakingKeeper(t, nil, nil) + keeper, ctx := testkeeper.BTCStakingKeeper(t, nil, nil, nil) params := types.DefaultParams() err := keeper.SetParams(ctx, params) @@ -19,3 +19,47 @@ func TestParamsQuery(t *testing.T) { require.NoError(t, err) require.Equal(t, &types.QueryParamsResponse{Params: params}, response) } + +func TestParamsByVersionQuery(t *testing.T) { + keeper, ctx := testkeeper.BTCStakingKeeper(t, nil, nil, nil) + + // starting with `1` as BTCStakingKeeper creates params with version 0 + params1 := types.DefaultParams() + params1.MinUnbondingTime = 10000 + params2 := types.DefaultParams() + params2.MinUnbondingTime = 20000 + params3 := types.DefaultParams() + params3.MinUnbondingTime = 30000 + + // Check that after update we always return the latest version of params throuh Params query + err := keeper.SetParams(ctx, params1) + require.NoError(t, err) + response, err := keeper.Params(ctx, &types.QueryParamsRequest{}) + require.NoError(t, err) + require.Equal(t, &types.QueryParamsResponse{Params: params1}, response) + + err = keeper.SetParams(ctx, params2) + require.NoError(t, err) + response, err = keeper.Params(ctx, &types.QueryParamsRequest{}) + require.NoError(t, err) + require.Equal(t, &types.QueryParamsResponse{Params: params2}, response) + + err = keeper.SetParams(ctx, params3) + require.NoError(t, err) + response, err = keeper.Params(ctx, &types.QueryParamsRequest{}) + require.NoError(t, err) + require.Equal(t, &types.QueryParamsResponse{Params: params3}, response) + + // Check that each past version is available through ParamsByVersion query + resp0, err := keeper.ParamsByVersion(ctx, &types.QueryParamsByVersionRequest{Version: 1}) + require.NoError(t, err) + require.Equal(t, &types.QueryParamsByVersionResponse{Params: params1}, resp0) + + resp1, err := keeper.ParamsByVersion(ctx, &types.QueryParamsByVersionRequest{Version: 2}) + require.NoError(t, err) + require.Equal(t, &types.QueryParamsByVersionResponse{Params: params2}, resp1) + + resp2, err := keeper.ParamsByVersion(ctx, &types.QueryParamsByVersionRequest{Version: 3}) + require.NoError(t, err) + require.Equal(t, &types.QueryParamsByVersionResponse{Params: params3}, resp2) +} diff --git a/x/btcstaking/keeper/voting_power_table.go b/x/btcstaking/keeper/voting_power_table.go index c5bb04903..f7abc715b 100644 --- a/x/btcstaking/keeper/voting_power_table.go +++ b/x/btcstaking/keeper/voting_power_table.go @@ -7,24 +7,31 @@ import ( "github.com/cosmos/cosmos-sdk/runtime" "cosmossdk.io/store/prefix" - bbn "github.com/babylonchain/babylon/types" - "github.com/babylonchain/babylon/x/btcstaking/types" + bbn "github.com/babylonlabs-io/babylon/types" + "github.com/babylonlabs-io/babylon/x/btcstaking/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) bool) { +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) - if fp.IsSlashed() { - // slashed finality provider is removed from finality provider set - continue - } - shouldContinue := handler(&fp) if !shouldContinue { return @@ -32,9 +39,8 @@ func (k Keeper) IterateActiveFPs(ctx context.Context, handler func(fp *types.Fin } } -// SetVotingPower sets the voting power of a given finality provider at a given Babylon height func (k Keeper) SetVotingPower(ctx context.Context, fpBTCPK []byte, height uint64, power uint64) { - store := k.votingPowerStore(ctx, height) + store := k.votingPowerBbnBlockHeightStore(ctx, height) store.Set(fpBTCPK, sdk.Uint64ToBigEndian(power)) } @@ -43,7 +49,7 @@ func (k Keeper) GetVotingPower(ctx context.Context, fpBTCPK []byte, height uint6 if !k.HasFinalityProvider(ctx, fpBTCPK) { return 0 } - store := k.votingPowerStore(ctx, height) + store := k.votingPowerBbnBlockHeightStore(ctx, height) powerBytes := store.Get(fpBTCPK) if len(powerBytes) == 0 { return 0 @@ -86,7 +92,7 @@ func (k Keeper) GetCurrentVotingPower(ctx context.Context, fpBTCPK []byte) (uint // HasVotingPowerTable checks if the voting power table exists at a given height func (k Keeper) HasVotingPowerTable(ctx context.Context, height uint64) bool { - store := k.votingPowerStore(ctx, height) + store := k.votingPowerBbnBlockHeightStore(ctx, height) iter := store.Iterator(nil, nil) defer iter.Close() return iter.Valid() @@ -94,7 +100,7 @@ func (k Keeper) HasVotingPowerTable(ctx context.Context, height uint64) bool { // GetVotingPowerTable gets the voting power table, i.e., finality provider set at a given height func (k Keeper) GetVotingPowerTable(ctx context.Context, height uint64) map[string]uint64 { - store := k.votingPowerStore(ctx, height) + store := k.votingPowerBbnBlockHeightStore(ctx, height) iter := store.Iterator(nil, nil) defer iter.Close() @@ -142,12 +148,20 @@ func (k Keeper) IsBTCStakingActivated(ctx context.Context) bool { return iter.Valid() } -// votingPowerStore returns the KVStore of the finality providers' voting power +// votingPowerBbnBlockHeightStore returns the KVStore of the finality providers' voting power // prefix: (VotingPowerKey || Babylon block height) // key: Bitcoin secp256k1 PK // value: voting power quantified in Satoshi -func (k Keeper) votingPowerStore(ctx context.Context, height uint64) prefix.Store { - storeAdapter := runtime.KVStoreAdapter(k.storeService.OpenKVStore(ctx)) - votingPowerStore := prefix.NewStore(storeAdapter, types.VotingPowerKey) +func (k Keeper) votingPowerBbnBlockHeightStore(ctx context.Context, height uint64) prefix.Store { + votingPowerStore := k.votingPowerStore(ctx) return prefix.NewStore(votingPowerStore, sdk.Uint64ToBigEndian(height)) } + +// votingPowerStore returns the KVStore of the finality providers' voting power +// prefix: (VotingPowerKey) +// key: Babylon block height || Bitcoin secp256k1 PK +// value: voting power quantified in Satoshi +func (k Keeper) votingPowerStore(ctx context.Context) prefix.Store { + storeAdapter := runtime.KVStoreAdapter(k.storeService.OpenKVStore(ctx)) + return prefix.NewStore(storeAdapter, types.VotingPowerKey) +} diff --git a/x/btcstaking/keeper/voting_power_table_test.go b/x/btcstaking/keeper/voting_power_table_test.go index 6f6ae99ec..a8c743afe 100644 --- a/x/btcstaking/keeper/voting_power_table_test.go +++ b/x/btcstaking/keeper/voting_power_table_test.go @@ -2,17 +2,12 @@ package keeper_test import ( "math/rand" + "sort" "testing" - sdkmath "cosmossdk.io/math" - - "github.com/babylonchain/babylon/testutil/datagen" - keepertest "github.com/babylonchain/babylon/testutil/keeper" - bbn "github.com/babylonchain/babylon/types" - btcctypes "github.com/babylonchain/babylon/x/btccheckpoint/types" - btclctypes "github.com/babylonchain/babylon/x/btclightclient/types" - "github.com/babylonchain/babylon/x/btcstaking/types" - "github.com/btcsuite/btcd/chaincfg" + "github.com/babylonlabs-io/babylon/testutil/datagen" + btclctypes "github.com/babylonlabs-io/babylon/x/btclightclient/types" + "github.com/babylonlabs-io/babylon/x/btcstaking/types" "github.com/golang/mock/gomock" "github.com/stretchr/testify/require" ) @@ -28,29 +23,20 @@ func FuzzVotingPowerTable(f *testing.F) { // mock BTC light client and BTC checkpoint modules btclcKeeper := types.NewMockBTCLightClientKeeper(ctrl) btccKeeper := types.NewMockBtcCheckpointKeeper(ctrl) - btccKeeper.EXPECT().GetParams(gomock.Any()).Return(btcctypes.DefaultParams()).AnyTimes() - keeper, ctx := keepertest.BTCStakingKeeper(t, btclcKeeper, btccKeeper) + ckptKeeper := types.NewMockCheckpointingKeeper(ctrl) + h := NewHelper(t, btclcKeeper, btccKeeper, ckptKeeper) - // covenant and slashing addr - covenantSKs, _, covenantQuorum := datagen.GenCovenantCommittee(r) - slashingAddress, err := datagen.GenRandomBTCAddress(r, &chaincfg.SimNetParams) - 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) + // set all parameters + covenantSKs, _ := h.GenAndApplyParams(r) + changeAddress, err := datagen.GenRandomBTCAddress(r, h.Net) + h.NoError(err) // generate a random batch of finality providers fps := []*types.FinalityProvider{} numFpsWithVotingPower := datagen.RandomInt(r, 10) + 2 numFps := numFpsWithVotingPower + datagen.RandomInt(r, 10) for i := uint64(0); i < numFps; i++ { - fp, err := datagen.GenRandomFinalityProvider(r) - require.NoError(t, err) - keeper.SetFinalityProvider(ctx, fp) + _, _, fp := h.CreateFinalityProvider(r) fps = append(fps, fp) } @@ -59,93 +45,68 @@ 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++ { - delSK, _, err := datagen.GenRandomBTCKeyPair(r) - require.NoError(t, err) - btcDel, err := datagen.GenRandomBTCDelegation( + _, _, _, delMsg, del := h.CreateDelegation( r, - t, - []bbn.BIP340PubKey{*fps[i].BtcPk}, - delSK, - covenantSKs, - covenantQuorum, - slashingAddress.EncodeAddress(), - 1, 1000, stakingValue, - slashingRate, - slashingChangeLockTime, + fps[i].BtcPk.MustToBTCPK(), + changeAddress.EncodeAddress(), + int64(stakingValue), + 1000, ) - require.NoError(t, err) - err = keeper.AddBTCDelegation(ctx, btcDel) - require.NoError(t, err) + h.CreateCovenantSigs(r, covenantSKs, delMsg, del) } } /* - Case 1: BTC height is 0 that is smaller than start height 1. - No finality privater will have voting power + assert the first numFpsWithVotingPower finality providers have voting power */ babylonHeight := datagen.RandomInt(r, 10) + 1 - ctx = datagen.WithCtxHeight(ctx, babylonHeight) - btclcKeeper.EXPECT().GetTipInfo(gomock.Any()).Return(&btclctypes.BTCHeaderInfo{Height: 0}).Times(1) - err = keeper.BeginBlocker(ctx) - require.NoError(t, err) - - for i := uint64(0); i < numFps; i++ { - power := keeper.GetVotingPower(ctx, *fps[i].BtcPk, babylonHeight) - require.Zero(t, power) - } - - /* - Case 2: move to 1st BTC block, then assert the first numFpsWithVotingPower finality providers have voting power - */ - babylonHeight += datagen.RandomInt(r, 10) + 1 - ctx = datagen.WithCtxHeight(ctx, babylonHeight) - btclcKeeper.EXPECT().GetTipInfo(gomock.Any()).Return(&btclctypes.BTCHeaderInfo{Height: 1}).Times(1) - err = keeper.BeginBlocker(ctx) + 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) for i := uint64(0); i < numFpsWithVotingPower; i++ { - power := keeper.GetVotingPower(ctx, *fps[i].BtcPk, babylonHeight) + power := h.BTCStakingKeeper.GetVotingPower(h.Ctx, *fps[i].BtcPk, babylonHeight) require.Equal(t, numBTCDels*stakingValue, power) } for i := numFpsWithVotingPower; i < numFps; i++ { - power := keeper.GetVotingPower(ctx, *fps[i].BtcPk, babylonHeight) + power := h.BTCStakingKeeper.GetVotingPower(h.Ctx, *fps[i].BtcPk, babylonHeight) require.Zero(t, power) } // also, get voting power table and assert consistency - powerTable := keeper.GetVotingPowerTable(ctx, babylonHeight) + powerTable := h.BTCStakingKeeper.GetVotingPowerTable(h.Ctx, babylonHeight) require.NotNil(t, powerTable) for i := uint64(0); i < numFpsWithVotingPower; i++ { - power := keeper.GetVotingPower(ctx, *fps[i].BtcPk, babylonHeight) + power := h.BTCStakingKeeper.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 := keeper.GetBTCStakingActivatedHeight(ctx) + activatedHeight, err := h.BTCStakingKeeper.GetBTCStakingActivatedHeight(h.Ctx) require.NoError(t, err) require.Equal(t, babylonHeight, activatedHeight) /* - Case 3: slash a random finality provider and move on + slash a random finality provider and move on then assert the slashed finality provider does not have voting power */ + // move to next Babylon height + h.BTCLightClientKeeper = btclcKeeper + babylonHeight += 1 + h.SetCtxHeight(babylonHeight) + h.BTCLightClientKeeper.EXPECT().GetTipInfo(gomock.Eq(h.Ctx)).Return(&btclctypes.BTCHeaderInfo{Height: 30}).AnyTimes() // slash a random finality provider slashedIdx := datagen.RandomInt(r, int(numFpsWithVotingPower)) slashedFp := fps[slashedIdx] - // This will be called to get the slashed height - btclcKeeper.EXPECT().GetTipInfo(gomock.Any()).Return(&btclctypes.BTCHeaderInfo{Height: 1}).Times(1) - err = keeper.SlashFinalityProvider(ctx, slashedFp.BtcPk.MustMarshal()) + err = h.BTCStakingKeeper.SlashFinalityProvider(h.Ctx, slashedFp.BtcPk.MustMarshal()) require.NoError(t, err) - // move to later Babylon height and 2nd BTC height - babylonHeight += datagen.RandomInt(r, 10) + 1 - ctx = datagen.WithCtxHeight(ctx, babylonHeight) - btclcKeeper.EXPECT().GetTipInfo(gomock.Any()).Return(&btclctypes.BTCHeaderInfo{Height: 2}).Times(1) // index height and record power table - err = keeper.BeginBlocker(ctx) + err = h.BTCStakingKeeper.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 := keeper.GetVotingPower(ctx, *fps[i].BtcPk, babylonHeight) + power := h.BTCStakingKeeper.GetVotingPower(h.Ctx, *fps[i].BtcPk, babylonHeight) if i == slashedIdx { require.Zero(t, power) } else { @@ -153,15 +114,15 @@ func FuzzVotingPowerTable(f *testing.F) { } } for i := numFpsWithVotingPower; i < numFps; i++ { - power := keeper.GetVotingPower(ctx, *fps[i].BtcPk, babylonHeight) + power := h.BTCStakingKeeper.GetVotingPower(h.Ctx, *fps[i].BtcPk, babylonHeight) require.Zero(t, power) } // also, get voting power table and assert consistency - powerTable = keeper.GetVotingPowerTable(ctx, babylonHeight) + powerTable = h.BTCStakingKeeper.GetVotingPowerTable(h.Ctx, babylonHeight) require.NotNil(t, powerTable) for i := uint64(0); i < numFpsWithVotingPower; i++ { - power := keeper.GetVotingPower(ctx, *fps[i].BtcPk, babylonHeight) + power := h.BTCStakingKeeper.GetVotingPower(h.Ctx, *fps[i].BtcPk, babylonHeight) if i == slashedIdx { require.Zero(t, power) } @@ -169,21 +130,22 @@ func FuzzVotingPowerTable(f *testing.F) { } /* - Case 4: move to 999th BTC block, then assert none of finality providers has voting power (since end height - w < BTC height) + move to 999th BTC block, then assert none of finality providers has voting power (since end height - w < BTC height) */ - babylonHeight += datagen.RandomInt(r, 10) + 1 - ctx = datagen.WithCtxHeight(ctx, babylonHeight) - btclcKeeper.EXPECT().GetTipInfo(gomock.Any()).Return(&btclctypes.BTCHeaderInfo{Height: 999}).Times(1) - err = keeper.BeginBlocker(ctx) + // replace the old mocked keeper + babylonHeight += 1 + h.SetCtxHeight(babylonHeight) + h.BTCLightClientKeeper.EXPECT().GetTipInfo(gomock.Eq(h.Ctx)).Return(&btclctypes.BTCHeaderInfo{Height: 999}).AnyTimes() + err = h.BTCStakingKeeper.BeginBlocker(h.Ctx) require.NoError(t, err) for _, fp := range fps { - power := keeper.GetVotingPower(ctx, *fp.BtcPk, babylonHeight) + power := h.BTCStakingKeeper.GetVotingPower(h.Ctx, *fp.BtcPk, babylonHeight) require.Zero(t, power) } // the activation height should be same as before - activatedHeight2, err := keeper.GetBTCStakingActivatedHeight(ctx) + activatedHeight2, err := h.BTCStakingKeeper.GetBTCStakingActivatedHeight(h.Ctx) require.NoError(t, err) require.Equal(t, activatedHeight, activatedHeight2) }) @@ -200,87 +162,68 @@ func FuzzVotingPowerTable_ActiveFinalityProviders(f *testing.F) { // mock BTC light client and BTC checkpoint modules btclcKeeper := types.NewMockBTCLightClientKeeper(ctrl) btccKeeper := types.NewMockBtcCheckpointKeeper(ctrl) - btccKeeper.EXPECT().GetParams(gomock.Any()).Return(btcctypes.DefaultParams()).AnyTimes() - keeper, ctx := keepertest.BTCStakingKeeper(t, btclcKeeper, btccKeeper) - - // covenant and slashing addr - covenantSKs, _, covenantQuorum := datagen.GenCovenantCommittee(r) - slashingAddress, err := datagen.GenRandomBTCAddress(r, &chaincfg.SimNetParams) - require.NoError(t, err) - slashingChangeLockTime := uint16(101) + ckptKeeper := types.NewMockCheckpointingKeeper(ctrl) + h := NewHelper(t, btclcKeeper, btccKeeper, ckptKeeper) - // 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) + // set all parameters + covenantSKs, _ := h.GenAndApplyParams(r) + changeAddress, err := datagen.GenRandomBTCAddress(r, h.Net) + h.NoError(err) // generate a random batch of finality providers, each with a BTC delegation with random power - fpsWithMeta := []*types.FinalityProviderWithMeta{} + fpsWithMeta := []*types.FinalityProviderDistInfo{} numFps := datagen.RandomInt(r, 300) + 1 for i := uint64(0); i < numFps; i++ { // generate finality provider - fp, err := datagen.GenRandomFinalityProvider(r) - require.NoError(t, err) - keeper.SetFinalityProvider(ctx, fp) + _, _, fp := h.CreateFinalityProvider(r) // delegate to this finality provider stakingValue := datagen.RandomInt(r, 100000) + 100000 - fpBTCPK := fp.BtcPk - delSK, _, err := datagen.GenRandomBTCKeyPair(r) - require.NoError(t, err) - btcDel, err := datagen.GenRandomBTCDelegation( + _, _, _, delMsg, del := h.CreateDelegation( r, - t, - []bbn.BIP340PubKey{*fpBTCPK}, - delSK, - covenantSKs, - covenantQuorum, - slashingAddress.EncodeAddress(), - 1, 1000, stakingValue, // timelock period: 1-1000 - slashingRate, - slashingChangeLockTime, + fp.BtcPk.MustToBTCPK(), + changeAddress.EncodeAddress(), + int64(stakingValue), + 1000, ) - require.NoError(t, err) - err = keeper.AddBTCDelegation(ctx, btcDel) - require.NoError(t, err) + h.CreateCovenantSigs(r, covenantSKs, delMsg, del) // record voting power - fpsWithMeta = append(fpsWithMeta, &types.FinalityProviderWithMeta{ - BtcPk: fp.BtcPk, - VotingPower: stakingValue, + fpsWithMeta = append(fpsWithMeta, &types.FinalityProviderDistInfo{ + BtcPk: fp.BtcPk, + TotalVotingPower: stakingValue, }) } - maxActiveFpsParam := keeper.GetParams(ctx).MaxActiveFinalityProviders + maxActiveFpsParam := h.BTCStakingKeeper.GetParams(h.Ctx).MaxActiveFinalityProviders // get a map of expected active finality providers - expectedActiveFps := types.FilterTopNFinalityProviders(fpsWithMeta, maxActiveFpsParam) + types.SortFinalityProviders(fpsWithMeta) + expectedActiveFps := fpsWithMeta[:min(uint32(len(fpsWithMeta)), maxActiveFpsParam)] expectedActiveFpsMap := map[string]uint64{} for _, fp := range expectedActiveFps { - expectedActiveFpsMap[fp.BtcPk.MarshalHex()] = fp.VotingPower + expectedActiveFpsMap[fp.BtcPk.MarshalHex()] = fp.TotalVotingPower } // record voting power table babylonHeight := datagen.RandomInt(r, 10) + 1 - ctx = datagen.WithCtxHeight(ctx, babylonHeight) - btclcKeeper.EXPECT().GetTipInfo(gomock.Any()).Return(&btclctypes.BTCHeaderInfo{Height: 1}).Times(1) - err = keeper.BeginBlocker(ctx) + 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) // only finality providers in expectedActiveFpsMap have voting power for _, fp := range fpsWithMeta { - power := keeper.GetVotingPower(ctx, fp.BtcPk.MustMarshal(), babylonHeight) + power := h.BTCStakingKeeper.GetVotingPower(h.Ctx, fp.BtcPk.MustMarshal(), babylonHeight) if expectedPower, ok := expectedActiveFpsMap[fp.BtcPk.MarshalHex()]; ok { require.Equal(t, expectedPower, power) } else { - require.Equal(t, uint64(0), power) + require.Zero(t, power) } } // also, get voting power table and assert there is // min(len(expectedActiveFps), MaxActiveFinalityProviders) active finality providers - powerTable := keeper.GetVotingPowerTable(ctx, babylonHeight) + powerTable := h.BTCStakingKeeper.GetVotingPowerTable(h.Ctx, babylonHeight) expectedNumActiveFps := len(expectedActiveFpsMap) if expectedNumActiveFps > int(maxActiveFpsParam) { expectedNumActiveFps = int(maxActiveFpsParam) @@ -304,51 +247,46 @@ func FuzzVotingPowerTable_ActiveFinalityProviderRotation(f *testing.F) { // mock BTC light client and BTC checkpoint modules btclcKeeper := types.NewMockBTCLightClientKeeper(ctrl) btccKeeper := types.NewMockBtcCheckpointKeeper(ctrl) - btccKeeper.EXPECT().GetParams(gomock.Any()).Return(btcctypes.DefaultParams()).AnyTimes() - keeper, ctx := keepertest.BTCStakingKeeper(t, btclcKeeper, btccKeeper) - - // covenant and slashing addr - covenantSKs, _, covenantQuorum := datagen.GenCovenantCommittee(r) - slashingAddress, err := datagen.GenRandomBTCAddress(r, &chaincfg.SimNetParams) - require.NoError(t, err) - slashingChangeLockTime := uint16(101) + ckptKeeper := types.NewMockCheckpointingKeeper(ctrl) + h := NewHelper(t, btclcKeeper, btccKeeper, ckptKeeper) + + // 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) + 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))) - // 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 random batch of finality providers, each with a BTC delegation with random power + /* + Generate a random batch of finality providers, each with a BTC delegation + with random voting power. + Then, assert voting power table + */ fpsWithMeta := []*types.FinalityProviderWithMeta{} - numFps := uint64(200) // there has to be more than `maxActiveFinalityProviders` finality providers for i := uint64(0); i < numFps; i++ { // generate finality provider - fp, err := datagen.GenRandomFinalityProvider(r) - require.NoError(t, err) - keeper.SetFinalityProvider(ctx, fp) + // generate and insert new finality provider + _, fpPK, fp := h.CreateFinalityProvider(r) - // delegate to this finality provider + // create BTC delegation and add covenant signatures to activate it stakingValue := datagen.RandomInt(r, 100000) + 100000 - fpBTCPK := fp.BtcPk - delSK, _, err := datagen.GenRandomBTCKeyPair(r) - require.NoError(t, err) - btcDel, err := datagen.GenRandomBTCDelegation( + _, _, _, delMsg, del := h.CreateDelegation( r, - t, - []bbn.BIP340PubKey{*fpBTCPK}, - delSK, - covenantSKs, - covenantQuorum, - slashingAddress.EncodeAddress(), - 1, 1000, stakingValue, // timelock period: 1-1000 - slashingRate, - slashingChangeLockTime, + fpPK, + changeAddress.EncodeAddress(), + int64(stakingValue), + 1000, ) - require.NoError(t, err) - err = keeper.AddBTCDelegation(ctx, btcDel) - require.NoError(t, err) + h.CreateCovenantSigs(r, covenantSKs, delMsg, del) // record voting power fpsWithMeta = append(fpsWithMeta, &types.FinalityProviderWithMeta{ @@ -359,59 +297,96 @@ func FuzzVotingPowerTable_ActiveFinalityProviderRotation(f *testing.F) { // record voting power table babylonHeight := datagen.RandomInt(r, 10) + 1 - ctx = datagen.WithCtxHeight(ctx, babylonHeight) - btclcKeeper.EXPECT().GetTipInfo(gomock.Any()).Return(&btclctypes.BTCHeaderInfo{Height: 1}).Times(1) - err = keeper.BeginBlocker(ctx) - require.NoError(t, err) + 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) + + // 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) + require.Equal(t, fpsWithMeta[i].VotingPower, votingPower) + } + for i := numActiveFPs; i < int(numFps); i++ { + votingPower := h.BTCStakingKeeper.GetVotingPower(h.Ctx, *fpsWithMeta[i].BtcPk, babylonHeight) + require.Zero(t, votingPower) + } - // get maps of active/inactive finality providers - activeFpsMap := map[string]uint64{} - inactiveFpsMap := map[string]uint64{} - for _, fp := range fpsWithMeta { - power := keeper.GetVotingPower(ctx, fp.BtcPk.MustMarshal(), babylonHeight) - if power > 0 { - activeFpsMap[fp.BtcPk.MarshalHex()] = power - } else { - inactiveFpsMap[fp.BtcPk.MarshalHex()] = power + /* + Delegate more tokens to some existing finality providers + , and create some new finality providers + Then assert voting power table again + */ + // delegate more tokens to some existing finality providers + for i := uint64(0); i < numFps; i++ { + if !datagen.OneInN(r, 2) { + continue } - } - // delegate a huge amount of tokens to one of the inactive finality provider - var activatedFpBTCPK *bbn.BIP340PubKey - for fpBTCPKHex := range inactiveFpsMap { - stakingValue := uint64(10000000) - activatedFpBTCPK, _ = bbn.NewBIP340PubKeyFromHex(fpBTCPKHex) - delSK, _, err := datagen.GenRandomBTCKeyPair(r) - require.NoError(t, err) - btcDel, err := datagen.GenRandomBTCDelegation( + stakingValue := datagen.RandomInt(r, 100000) + 100000 + fpBTCPK := fpsWithMeta[i].BtcPk + _, _, _, delMsg, del := h.CreateDelegation( r, - t, - []bbn.BIP340PubKey{*activatedFpBTCPK}, - delSK, - covenantSKs, - covenantQuorum, - slashingAddress.EncodeAddress(), - 1, 1000, stakingValue, // timelock period: 1-1000 - slashingRate, - slashingChangeLockTime, + fpBTCPK.MustToBTCPK(), + changeAddress.EncodeAddress(), + int64(stakingValue), + 1000, ) - require.NoError(t, err) - err = keeper.AddBTCDelegation(ctx, btcDel) - require.NoError(t, err) + h.CreateCovenantSigs(r, covenantSKs, delMsg, del) + + // accumulate voting power for this finality provider + fpsWithMeta[i].VotingPower += stakingValue break } + // create more finality providers + numNewFps := datagen.RandomInt(r, 20) + 10 + numFps += numNewFps + numActiveFPs = int(min(numFps, uint64(bsParams.MaxActiveFinalityProviders))) + for i := uint64(0); i < numNewFps; i++ { + // generate finality provider + // generate and insert new finality provider + _, fpPK, fp := h.CreateFinalityProvider(r) + + // create BTC delegation and add covenant signatures to activate it + stakingValue := datagen.RandomInt(r, 100000) + 100000 + _, _, _, delMsg, del := h.CreateDelegation( + r, + fpPK, + changeAddress.EncodeAddress(), + int64(stakingValue), + 1000, + ) + h.CreateCovenantSigs(r, covenantSKs, delMsg, del) + + // record voting power + fpsWithMeta = append(fpsWithMeta, &types.FinalityProviderWithMeta{ + BtcPk: fp.BtcPk, + VotingPower: stakingValue, + }) + } // record voting power table babylonHeight += 1 - ctx = datagen.WithCtxHeight(ctx, babylonHeight) - btclcKeeper.EXPECT().GetTipInfo(gomock.Any()).Return(&btclctypes.BTCHeaderInfo{Height: 1}).Times(1) - err = keeper.BeginBlocker(ctx) - require.NoError(t, err) - - // ensure that the activated finality provider now has entered the active finality provider set - // i.e., has voting power - power := keeper.GetVotingPower(ctx, activatedFpBTCPK.MustMarshal(), babylonHeight) - require.Positive(t, power) + 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) + + // 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) + require.Equal(t, fpsWithMeta[i].VotingPower, votingPower) + } + for i := numActiveFPs; i < int(numFps); i++ { + votingPower := h.BTCStakingKeeper.GetVotingPower(h.Ctx, *fpsWithMeta[i].BtcPk, babylonHeight) + require.Zero(t, votingPower) + } }) } diff --git a/x/btcstaking/module.go b/x/btcstaking/module.go index a415eee5a..e8e431b76 100644 --- a/x/btcstaking/module.go +++ b/x/btcstaking/module.go @@ -11,9 +11,9 @@ import ( abci "github.com/cometbft/cometbft/abci/types" - "github.com/babylonchain/babylon/x/btcstaking/client/cli" - "github.com/babylonchain/babylon/x/btcstaking/keeper" - "github.com/babylonchain/babylon/x/btcstaking/types" + "github.com/babylonlabs-io/babylon/x/btcstaking/client/cli" + "github.com/babylonlabs-io/babylon/x/btcstaking/keeper" + "github.com/babylonlabs-io/babylon/x/btcstaking/types" "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/codec" cdctypes "github.com/cosmos/cosmos-sdk/codec/types" diff --git a/x/btcstaking/types/btc_delegation.go b/x/btcstaking/types/btc_delegation.go index c2b1f5833..b17ef18ee 100644 --- a/x/btcstaking/types/btc_delegation.go +++ b/x/btcstaking/types/btc_delegation.go @@ -5,9 +5,11 @@ import ( "fmt" math "math" - "github.com/babylonchain/babylon/btcstaking" - asig "github.com/babylonchain/babylon/crypto/schnorr-adaptor-signature" - bbn "github.com/babylonchain/babylon/types" + 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" @@ -139,8 +141,8 @@ func (d *BTCDelegation) MustGetStakingTxHash() chainhash.Hash { } func (d *BTCDelegation) ValidateBasic() error { - if d.BabylonPk == nil { - return fmt.Errorf("empty Babylon public key") + if _, err := sdk.AccAddressFromBech32(d.StakerAddr); err != nil { + return fmt.Errorf("invalid staker address: %s - %w", d.StakerAddr, err) } if d.BtcPk == nil { return fmt.Errorf("empty BTC public key") @@ -168,9 +170,6 @@ func (d *BTCDelegation) ValidateBasic() error { if _, err := bbn.NewBTCTxFromBytes(d.StakingTx); err != nil { return err } - if err := d.Pop.ValidateBasic(); err != nil { - return err - } return nil } @@ -309,6 +308,23 @@ func (d *BTCDelegation) GetUnbondingInfo(bsParams *Params, btcNet *chaincfg.Para return unbondingInfo, nil } +// TODO: verify to remove, not used in babylon, only for tests +// findFPIdx returns the index of the given finality provider +// among all restaked finality providers +func (d *BTCDelegation) findFPIdx(fpBTCPK *bbn.BIP340PubKey) (int, error) { + for i, pk := range d.FpBtcPkList { + if pk.Equals(fpBTCPK) { + return i, nil + } + } + return 0, fmt.Errorf("the given finality provider's PK is not found in the BTC delegation") +} + +// BuildSlashingTxWithWitness uses the given finality provider's SK to complete +// the signatures on the slashing tx, such that the slashing tx obtains full +// witness and can be submitted to Bitcoin. +// This happens after the finality provider is slashed and its SK is extracted. +// TODO: verify not used func (d *BTCDelegation) BuildSlashingTxWithWitness(bsParams *Params, btcNet *chaincfg.Params, fpSK *btcec.PrivateKey) (*wire.MsgTx, error) { stakingMsgTx, err := bbn.NewBTCTxFromBytes(d.StakingTx) if err != nil { @@ -325,8 +341,13 @@ func (d *BTCDelegation) BuildSlashingTxWithWitness(bsParams *Params, btcNet *cha return nil, fmt.Errorf("could not get slashing spend info: %v", err) } - // TODO: work with restaking - covAdaptorSigs, err := GetOrderedCovenantSignatures(0, d.CovenantSigs, bsParams) + // get the list of covenant signatures encrypted by the given finality provider's PK + fpBTCPK := bbn.NewBIP340PubKeyFromBTCPK(fpSK.PubKey()) + fpIdx, err := d.findFPIdx(fpBTCPK) + if err != nil { + return nil, err + } + covAdaptorSigs, err := GetOrderedCovenantSignatures(fpIdx, d.CovenantSigs, bsParams) if err != nil { return nil, fmt.Errorf("failed to get ordered covenant adaptor signatures: %w", err) } @@ -334,6 +355,7 @@ func (d *BTCDelegation) BuildSlashingTxWithWitness(bsParams *Params, btcNet *cha // assemble witness for slashing tx slashingMsgTxWithWitness, err := d.SlashingTx.BuildSlashingTxWithWitness( fpSK, + d.FpBtcPkList, stakingMsgTx, d.StakingOutputIdx, d.DelegatorSig, @@ -352,6 +374,7 @@ func (d *BTCDelegation) BuildSlashingTxWithWitness(bsParams *Params, btcNet *cha return slashingMsgTxWithWitness, nil } +// TODO: verify to remove, func not used by babylon, used in side car processes. func (d *BTCDelegation) BuildUnbondingSlashingTxWithWitness(bsParams *Params, btcNet *chaincfg.Params, fpSK *btcec.PrivateKey) (*wire.MsgTx, error) { unbondingMsgTx, err := bbn.NewBTCTxFromBytes(d.BtcUndelegation.UnbondingTx) if err != nil { @@ -368,8 +391,14 @@ func (d *BTCDelegation) BuildUnbondingSlashingTxWithWitness(bsParams *Params, bt return nil, fmt.Errorf("could not get unbonding slashing spend info: %v", err) } - // TODO: work with restaking - covAdaptorSigs, err := GetOrderedCovenantSignatures(0, d.BtcUndelegation.CovenantSlashingSigs, bsParams) + // get the list of covenant signatures encrypted by the given finality provider's PK + fpPK := fpSK.PubKey() + fpBTCPK := bbn.NewBIP340PubKeyFromBTCPK(fpPK) + fpIdx, err := d.findFPIdx(fpBTCPK) + if err != nil { + return nil, err + } + covAdaptorSigs, err := GetOrderedCovenantSignatures(fpIdx, d.BtcUndelegation.CovenantSlashingSigs, bsParams) if err != nil { return nil, fmt.Errorf("failed to get ordered covenant adaptor signatures: %w", err) } @@ -377,6 +406,7 @@ func (d *BTCDelegation) BuildUnbondingSlashingTxWithWitness(bsParams *Params, bt // assemble witness for unbonding slashing tx slashingMsgTxWithWitness, err := d.BtcUndelegation.SlashingTx.BuildSlashingTxWithWitness( fpSK, + d.FpBtcPkList, unbondingMsgTx, 0, d.BtcUndelegation.DelegatorSlashingSig, diff --git a/x/btcstaking/types/btc_delegation_test.go b/x/btcstaking/types/btc_delegation_test.go index 92ee43742..a97535c43 100644 --- a/x/btcstaking/types/btc_delegation_test.go +++ b/x/btcstaking/types/btc_delegation_test.go @@ -5,15 +5,15 @@ import ( "testing" sdkmath "cosmossdk.io/math" - bbn "github.com/babylonchain/babylon/types" + bbn "github.com/babylonlabs-io/babylon/types" "github.com/btcsuite/btcd/btcec/v2" "github.com/btcsuite/btcd/chaincfg" "github.com/stretchr/testify/require" - asig "github.com/babylonchain/babylon/crypto/schnorr-adaptor-signature" - btctest "github.com/babylonchain/babylon/testutil/bitcoin" - "github.com/babylonchain/babylon/testutil/datagen" - "github.com/babylonchain/babylon/x/btcstaking/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" + "github.com/babylonlabs-io/babylon/x/btcstaking/types" ) func FuzzBTCDelegation(f *testing.F) { @@ -74,89 +74,90 @@ func FuzzBTCDelegation_SlashingTx(f *testing.F) { r := rand.New(rand.NewSource(seed)) net := &chaincfg.SimNetParams - delSK, delPK, err := datagen.GenRandomBTCKeyPair(r) + delSK, _, err := datagen.GenRandomBTCKeyPair(r) require.NoError(t, err) - delBTCPK := bbn.NewBIP340PubKeyFromBTCPK(delPK) - fpSK, fpPK, err := datagen.GenRandomBTCKeyPair(r) + // restaked to a random number of finality providers + numRestakedFPs := int(datagen.RandomInt(r, 10) + 1) + fpSKs, fpPKs, err := datagen.GenRandomBTCKeyPairs(r, numRestakedFPs) require.NoError(t, err) - fpPKList := []*btcec.PublicKey{fpPK} + fpBTCPKs := bbn.NewBIP340PKsFromBTCPKs(fpPKs) + + // a random finality provider gets slashed + slashedFPIdx := int(datagen.RandomInt(r, numRestakedFPs)) + fpSK := fpSKs[slashedFPIdx] // (3, 5) covenant committee covenantSKs, covenantPKs, err := datagen.GenRandomBTCKeyPairs(r, 5) require.NoError(t, err) covenantQuorum := uint32(3) + bsParams := &types.Params{ + CovenantPks: bbn.NewBIP340PKsFromBTCPKs(covenantPKs), + CovenantQuorum: covenantQuorum, + } stakingTimeBlocks := uint16(5) stakingValue := int64(2 * 10e8) slashingAddress, err := datagen.GenRandomBTCAddress(r, &chaincfg.SimNetParams) 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) - testInfo := datagen.GenBTCStakingSlashingInfo( + unbondingTime := uint16(100) + 1 + slashingChangeLockTime := unbondingTime + + // only the quorum of signers provided the signatures + covenantSigners := covenantSKs[:covenantQuorum] + + // construct the BTC delegation with everything + btcDel, err := datagen.GenRandomBTCDelegation( r, t, - net, + &chaincfg.SimNetParams, + fpBTCPKs, delSK, - fpPKList, + covenantSigners, covenantPKs, covenantQuorum, - stakingTimeBlocks, - stakingValue, slashingAddress.EncodeAddress(), + 1000, + uint64(1000+stakingTimeBlocks), + uint64(stakingValue), slashingRate, slashingChangeLockTime, ) require.NoError(t, err) - stakingTxBytes, err := bbn.SerializeBTCTx(testInfo.StakingTx) + stakingInfo, err := btcDel.GetStakingInfo(bsParams, net) require.NoError(t, err) - // spend info of the slashing tx - slashingSpendInfo, err := testInfo.StakingInfo.SlashingPathSpendInfo() + // TESTING + orderedCovenantPKs := bbn.SortBIP340PKs(bsParams.CovenantPks) + covSigsForFP, err := types.GetOrderedCovenantSignatures(slashedFPIdx, btcDel.CovenantSigs, bsParams) require.NoError(t, err) - // delegator signs the slashing tx - delSig, err := testInfo.SlashingTx.Sign(testInfo.StakingTx, 0, slashingSpendInfo.GetPkScriptPath(), delSK) + fpPK := fpSK.PubKey() + encKey, err := asig.NewEncryptionKeyFromBTCPK(fpPK) require.NoError(t, err) - // covenant signs (using adaptor signature) the slashing tx - covenantSigs, err := datagen.GenCovenantAdaptorSigs(covenantSKs, []*btcec.PublicKey{fpPK}, testInfo.StakingTx, slashingSpendInfo.GetPkScriptPath(), testInfo.SlashingTx) + slashingSpendInfo, err := stakingInfo.SlashingPathSpendInfo() require.NoError(t, err) - covenantSigs = covenantSigs[2:] // discard 2 out of 5 signatures - - // construct the BTC delegation with everything - btcDel := &types.BTCDelegation{ - BabylonPk: nil, // not relevant here - BtcPk: delBTCPK, - Pop: nil, // not relevant here - FpBtcPkList: bbn.NewBIP340PKsFromBTCPKs(fpPKList), - StartHeight: 1000, // not relevant here - EndHeight: uint64(1000 + stakingTimeBlocks), - TotalSat: uint64(stakingValue), - StakingTx: stakingTxBytes, - StakingOutputIdx: 0, - SlashingTx: testInfo.SlashingTx, - DelegatorSig: delSig, - CovenantSigs: covenantSigs, - } - - bsParams := &types.Params{ - CovenantPks: bbn.NewBIP340PKsFromBTCPKs(covenantPKs), - CovenantQuorum: covenantQuorum, + for i := range covSigsForFP { + if covSigsForFP[i] == nil { + continue + } + err := btcDel.SlashingTx.EncVerifyAdaptorSignature( + stakingInfo.StakingOutput, + slashingSpendInfo.GetPkScriptPath(), + orderedCovenantPKs[i].MustToBTCPK(), + encKey, + covSigsForFP[i], + ) + require.NoError(t, err) } - btcNet := &chaincfg.SimNetParams // build slashing tx with witness for spending the staking tx - slashingTxWithWitness, err := btcDel.BuildSlashingTxWithWitness(bsParams, btcNet, fpSK) + slashingTxWithWitness, err := btcDel.BuildSlashingTxWithWitness(bsParams, net, fpSK) require.NoError(t, err) // assert execution - btctest.AssertSlashingTxExecution(t, testInfo.StakingInfo.StakingOutput, slashingTxWithWitness) + btctest.AssertSlashingTxExecution(t, stakingInfo.StakingOutput, slashingTxWithWitness) }) } diff --git a/x/btcstaking/types/btc_slashing_tx.go b/x/btcstaking/types/btc_slashing_tx.go index 6fae8be20..2bd135905 100644 --- a/x/btcstaking/types/btc_slashing_tx.go +++ b/x/btcstaking/types/btc_slashing_tx.go @@ -10,9 +10,9 @@ import ( "github.com/btcsuite/btcd/chaincfg/chainhash" "github.com/btcsuite/btcd/wire" - "github.com/babylonchain/babylon/btcstaking" - asig "github.com/babylonchain/babylon/crypto/schnorr-adaptor-signature" - bbn "github.com/babylonchain/babylon/types" + "github.com/babylonlabs-io/babylon/btcstaking" + asig "github.com/babylonlabs-io/babylon/crypto/schnorr-adaptor-signature" + bbn "github.com/babylonlabs-io/babylon/types" ) type BTCSlashingTx []byte @@ -114,8 +114,7 @@ func (tx *BTCSlashingTx) Sign( // VerifySignature verifies a signature on the slashing tx signed by staker, finality provider, or covenant func (tx *BTCSlashingTx) VerifySignature( - fundingPkScript []byte, - fundingAmount int64, + fundingOut *wire.TxOut, slashingPkScriptPath []byte, pk *btcec.PublicKey, sig *bbn.BIP340Signature, @@ -124,10 +123,9 @@ func (tx *BTCSlashingTx) VerifySignature( if err != nil { return err } - return btcstaking.VerifyTransactionSigWithOutputData( + return btcstaking.VerifyTransactionSigWithOutput( msgTx, - fundingPkScript, - fundingAmount, + fundingOut, slashingPkScriptPath, pk, *sig, @@ -165,8 +163,7 @@ func (tx *BTCSlashingTx) EncSign( // EncVerifyAdaptorSignature verifies an adaptor signature on the slashing tx // with the finality provider's public key as encryption key func (tx *BTCSlashingTx) EncVerifyAdaptorSignature( - stakingPkScript []byte, - stakingAmount int64, + fundingOut *wire.TxOut, slashingPkScriptPath []byte, pk *btcec.PublicKey, encKey *asig.EncryptionKey, @@ -176,10 +173,9 @@ func (tx *BTCSlashingTx) EncVerifyAdaptorSignature( if err != nil { return err } - return btcstaking.EncVerifyTransactionSigWithOutputData( + return btcstaking.EncVerifyTransactionSigWithOutput( msgTx, - stakingPkScript, - stakingAmount, + fundingOut, slashingPkScriptPath, pk, encKey, @@ -211,8 +207,7 @@ func (tx *BTCSlashingTx) ParseEncVerifyAdaptorSignatures( return nil, err } err = tx.EncVerifyAdaptorSignature( - fundingOut.PkScript, - fundingOut.Value, + fundingOut, slashingSpendInfo.GetPkScriptPath(), pk.MustToBTCPK(), encKey, @@ -247,44 +242,80 @@ func (tx *BTCSlashingTx) EncVerifyAdaptorSignatures( } +// findFPIdxInWitness returns the index of the finality provider's signature +// in the witness stack of 1-out-of-n multisig from finality providers +// Note: the signatures are sorted in reverse lexical order since the PKs +// in the staking script are sorted in lexical order and BTC script execution +// is stack based +func findFPIdxInWitness(fpSK *btcec.PrivateKey, fpBTCPKs []bbn.BIP340PubKey) (int, error) { + fpBTCPK := bbn.NewBIP340PubKeyFromBTCPK(fpSK.PubKey()) + sortedFPBTCPKList := bbn.SortBIP340PKs(fpBTCPKs) + for i, pk := range sortedFPBTCPKList { + if pk.Equals(fpBTCPK) { + return i, nil + } + } + return 0, fmt.Errorf("the given finality provider's PK is not found in the BTC delegation") +} + +// BuildSlashingTxWithWitness builds the witness for the slashing tx, including +// - a (covenant_quorum, covenant_committee_size) multisig from covenant committee +// - a (1, num_restaked_finality_providers) multisig from the slashed finality provider +// - 1 Schnorr signature from the staker func (tx *BTCSlashingTx) BuildSlashingTxWithWitness( fpSK *btcec.PrivateKey, + fpBTCPKs []bbn.BIP340PubKey, fundingMsgTx *wire.MsgTx, outputIdx uint32, delegatorSig *bbn.BIP340Signature, covenantSigs []*asig.AdaptorSignature, slashingPathSpendInfo *btcstaking.SpendInfo, ) (*wire.MsgTx, error) { - fpSig, err := tx.Sign(fundingMsgTx, outputIdx, slashingPathSpendInfo.GetPkScriptPath(), fpSK) - if err != nil { - return nil, fmt.Errorf("failed to sign slashing tx for the finality provider: %w", err) - } - + /* + construct covenant committee's part of witness, i.e., + a quorum number of covenant Schnorr signatures + */ // decrypt covenant adaptor signature to Schnorr signature using finality provider's SK, // then marshal decKey, err := asig.NewDecyptionKeyFromBTCSK(fpSK) if err != nil { return nil, fmt.Errorf("failed to get decryption key from BTC SK: %w", err) } - - var covSigs []*schnorr.Signature - for _, covenantSig := range covenantSigs { + // decrypt each covenant adaptor signature to Schnorr signature + covSigs := make([]*schnorr.Signature, len(covenantSigs)) + for i, covenantSig := range covenantSigs { if covenantSig != nil { - covSigs = append(covSigs, covenantSig.Decrypt(decKey)) + covSigs[i] = covenantSig.Decrypt(decKey) } else { - covSigs = append(covSigs, nil) + covSigs[i] = nil } } + /* + construct finality providers' part of witness, i.e., + 1 out of numRestakedFPs signature + */ + fpIdxInWitness, err := findFPIdxInWitness(fpSK, fpBTCPKs) + if err != nil { + return nil, err + } + fpSigs := make([]*schnorr.Signature, len(fpBTCPKs)) + fpSig, err := tx.Sign(fundingMsgTx, outputIdx, slashingPathSpendInfo.GetPkScriptPath(), fpSK) + if err != nil { + return nil, fmt.Errorf("failed to sign slashing tx for the finality provider: %w", err) + } + fpSigs[fpIdxInWitness] = fpSig.MustToBTCSig() + // construct witness witness, err := slashingPathSpendInfo.CreateSlashingPathWitness( covSigs, - []*schnorr.Signature{fpSig.MustToBTCSig()}, // TODO: work with restaking + fpSigs, delegatorSig.MustToBTCSig(), ) if err != nil { return nil, err } + // add witness to slashing tx slashingMsgTxWithWitness, err := tx.ToMsgTx() if err != nil { diff --git a/x/btcstaking/types/btc_slashing_tx_test.go b/x/btcstaking/types/btc_slashing_tx_test.go index 292613426..aa90099ad 100644 --- a/x/btcstaking/types/btc_slashing_tx_test.go +++ b/x/btcstaking/types/btc_slashing_tx_test.go @@ -5,15 +5,113 @@ import ( "testing" sdkmath "cosmossdk.io/math" - btctest "github.com/babylonchain/babylon/testutil/bitcoin" - "github.com/babylonchain/babylon/testutil/datagen" - bbn "github.com/babylonchain/babylon/types" - "github.com/babylonchain/babylon/x/btcstaking/types" - "github.com/btcsuite/btcd/btcec/v2" + 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/stretchr/testify/require" ) +// FuzzSlashingTx_VerifySigAndASig ensures properly generated adaptor signatures and +// the corresponding Schnorr signatures can be verified as valid +func FuzzSlashingTx_VerifySigAndASig(f *testing.F) { + datagen.AddRandomSeedsToFuzzer(f, 10) + + f.Fuzz(func(t *testing.T, seed int64) { + r := rand.New(rand.NewSource(seed)) + + var ( + stakingValue = int64(2 * 10e8) + stakingTimeBlocks = uint16(5) + net = &chaincfg.SimNetParams + ) + + // slashing address and key pairs + slashingAddress, err := datagen.GenRandomBTCAddress(r, net) + require.NoError(t, err) + // 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) + + // restaked to a random number of finality providers + numRestakedFPs := int(datagen.RandomInt(r, 10) + 1) + fpSKs, fpPKs, err := datagen.GenRandomBTCKeyPairs(r, numRestakedFPs) + require.NoError(t, err) + + // use a random fp SK/PK + fpIdx := int(datagen.RandomInt(r, numRestakedFPs)) + fpSK, fpPK := fpSKs[fpIdx], fpPKs[fpIdx] + decKey, err := asig.NewDecyptionKeyFromBTCSK(fpSK) + require.NoError(t, err) + encKey, err := asig.NewEncryptionKeyFromBTCPK(fpPK) + require.NoError(t, err) + + delSK, _, err := datagen.GenRandomBTCKeyPair(r) + require.NoError(t, err) + + // (3, 5) covenant committee + covenantSKs, covenantPKs, err := datagen.GenRandomBTCKeyPairs(r, 5) + require.NoError(t, err) + covenantQuorum := uint32(3) + slashingChangeLockTime := uint16(101) + + // use a random covenant SK/PK + covIdx := int(datagen.RandomInt(r, 5)) + covSK, covPK := covenantSKs[covIdx], covenantPKs[covIdx] + + // generate staking/slashing tx + testStakingInfo := datagen.GenBTCStakingSlashingInfo( + r, + t, + net, + delSK, + fpPKs, + covenantPKs, + covenantQuorum, + stakingTimeBlocks, + stakingValue, + slashingAddress.EncodeAddress(), + slashingRate, + slashingChangeLockTime, + ) + + stakingTx := testStakingInfo.StakingTx + slashingTx := testStakingInfo.SlashingTx + + slashingSpendInfo, err := testStakingInfo.StakingInfo.SlashingPathSpendInfo() + require.NoError(t, err) + slashingPkScriptPath := slashingSpendInfo.GetPkScriptPath() + + // ensure covenant adaptor signature can be correctly generated and verified + covASig, err := slashingTx.EncSign(stakingTx, 0, slashingPkScriptPath, covSK, encKey) + require.NoError(t, err) + err = slashingTx.EncVerifyAdaptorSignature( + testStakingInfo.StakingInfo.StakingOutput, + slashingPkScriptPath, + covPK, + encKey, + covASig, + ) + require.NoError(t, err) + + // decrypt covenant adaptor signature and ensure the resulting Schnorr signature + // can be verified + covSig := covASig.Decrypt(decKey) + err = slashingTx.VerifySignature( + testStakingInfo.StakingInfo.StakingOutput, + slashingPkScriptPath, + covPK, + bbn.NewBIP340SignatureFromBTCSig(covSig), + ) + require.NoError(t, err) + }) +} + func FuzzSlashingTxWithWitness(f *testing.F) { datagen.AddRandomSeedsToFuzzer(f, 10) @@ -25,7 +123,7 @@ func FuzzSlashingTxWithWitness(f *testing.F) { net = &chaincfg.SimNetParams ) - // slashing address and key paris + // slashing address and key pairs slashingAddress, err := datagen.GenRandomBTCAddress(r, net) require.NoError(t, err) // Generate a slashing rate in the range [0.1, 0.50] i.e., 10-50%. @@ -35,16 +133,31 @@ func FuzzSlashingTxWithWitness(f *testing.F) { // this is already covered in FuzzGeneratingValidStakingSlashingTx slashingRate := sdkmath.LegacyNewDecWithPrec(int64(datagen.RandomInt(r, 41)+10), 2) - // TODO: test restaking - fpSK, fpPK, err := datagen.GenRandomBTCKeyPair(r) + // restaked to a random number of finality providers + numRestakedFPs := int(datagen.RandomInt(r, 10) + 1) + fpSKs, fpPKs, err := datagen.GenRandomBTCKeyPairs(r, numRestakedFPs) + require.NoError(t, err) + fpBTCPKs := bbn.NewBIP340PKsFromBTCPKs(fpPKs) + + // a random finality provider gets slashed + fpIdx := int(datagen.RandomInt(r, numRestakedFPs)) + fpSK, fpPK := fpSKs[fpIdx], fpPKs[fpIdx] + encKey, err := asig.NewEncryptionKeyFromBTCPK(fpPK) + require.NoError(t, err) + decKey, err := asig.NewDecyptionKeyFromBTCSK(fpSK) require.NoError(t, err) delSK, _, err := datagen.GenRandomBTCKeyPair(r) require.NoError(t, err) + // (3, 5) covenant committee covenantSKs, covenantPKs, err := datagen.GenRandomBTCKeyPairs(r, 5) require.NoError(t, err) covenantQuorum := uint32(3) + bsParams := types.Params{ + CovenantPks: bbn.NewBIP340PKsFromBTCPKs(covenantPKs), + CovenantQuorum: covenantQuorum, + } slashingChangeLockTime := uint16(101) // generate staking/slashing tx @@ -53,7 +166,7 @@ func FuzzSlashingTxWithWitness(f *testing.F) { t, net, delSK, - []*btcec.PublicKey{fpPK}, + fpPKs, covenantPKs, covenantQuorum, stakingTimeBlocks, @@ -70,28 +183,52 @@ func FuzzSlashingTxWithWitness(f *testing.F) { require.NoError(t, err) slashingPkScriptPath := slashingSpendInfo.GetPkScriptPath() - // sign slashing tx + // delegator signs slashing tx delSig, err := slashingTx.Sign(stakingMsgTx, 0, slashingPkScriptPath, delSK) require.NoError(t, err) + covenantSigners := covenantSKs[:covenantQuorum] + // get covenant Schnorr signatures covenantSigs, err := datagen.GenCovenantAdaptorSigs( - covenantSKs, - []*btcec.PublicKey{fpPK}, + covenantSigners, + fpPKs, stakingMsgTx, slashingPkScriptPath, slashingTx, ) require.NoError(t, err) + covSigsForFP, err := types.GetOrderedCovenantSignatures(fpIdx, covenantSigs, &bsParams) + require.NoError(t, err) - bsParams := types.Params{ - CovenantPks: bbn.NewBIP340PKsFromBTCPKs(covenantPKs), - CovenantQuorum: covenantQuorum, + // ensure all covenant signatures encrypted by the slashed + // finality provider's PK are verified + orderedCovenantPKs := bbn.SortBIP340PKs(bsParams.CovenantPks) + for i := range covSigsForFP { + if covSigsForFP[i] == nil { + continue + } + + err := slashingTx.EncVerifyAdaptorSignature( + testStakingInfo.StakingInfo.StakingOutput, + slashingPkScriptPath, + orderedCovenantPKs[i].MustToBTCPK(), + encKey, + covSigsForFP[i], + ) + require.NoError(t, err, "verifying covenant adaptor sig at %d", i) + + covSchnorrSig := covSigsForFP[i].Decrypt(decKey) + err = slashingTx.VerifySignature( + testStakingInfo.StakingInfo.StakingOutput, + slashingPkScriptPath, + orderedCovenantPKs[i].MustToBTCPK(), + bbn.NewBIP340SignatureFromBTCSig(covSchnorrSig), + ) + require.NoError(t, err, "verifying covenant Schnorr sig at %d", i) } - covSigs, err := types.GetOrderedCovenantSignatures(0, covenantSigs, &bsParams) - require.NoError(t, err) // create slashing tx with witness - slashingMsgTxWithWitness, err := slashingTx.BuildSlashingTxWithWitness(fpSK, stakingMsgTx, 0, delSig, covSigs, slashingSpendInfo) + slashingMsgTxWithWitness, err := slashingTx.BuildSlashingTxWithWitness(fpSK, fpBTCPKs, stakingMsgTx, 0, delSig, covSigsForFP, slashingSpendInfo) require.NoError(t, err) // verify slashing tx with witness diff --git a/x/btcstaking/types/btc_undelegation.go b/x/btcstaking/types/btc_undelegation.go index fdbee5495..177bcbf0e 100644 --- a/x/btcstaking/types/btc_undelegation.go +++ b/x/btcstaking/types/btc_undelegation.go @@ -1,8 +1,8 @@ package types import ( - asig "github.com/babylonchain/babylon/crypto/schnorr-adaptor-signature" - bbn "github.com/babylonchain/babylon/types" + asig "github.com/babylonlabs-io/babylon/crypto/schnorr-adaptor-signature" + bbn "github.com/babylonlabs-io/babylon/types" ) func (ud *BTCUndelegation) HasCovenantQuorumOnSlashing(quorum uint32) bool { diff --git a/x/btcstaking/types/btc_undelegation_test.go b/x/btcstaking/types/btc_undelegation_test.go index 8b62027ed..75b72c7bf 100644 --- a/x/btcstaking/types/btc_undelegation_test.go +++ b/x/btcstaking/types/btc_undelegation_test.go @@ -5,13 +5,12 @@ import ( "testing" sdkmath "cosmossdk.io/math" - btctest "github.com/babylonchain/babylon/testutil/bitcoin" - "github.com/babylonchain/babylon/testutil/datagen" - bbn "github.com/babylonchain/babylon/types" - "github.com/babylonchain/babylon/x/btcstaking/types" - "github.com/btcsuite/btcd/btcec/v2" + 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/wire" "github.com/stretchr/testify/require" ) @@ -25,14 +24,29 @@ func FuzzBTCUndelegation_SlashingTx(f *testing.F) { delSK, _, err := datagen.GenRandomBTCKeyPair(r) require.NoError(t, err) - fpSK, fpPK, err := datagen.GenRandomBTCKeyPair(r) + // restaked to a random number of finality providers + numRestakedFPs := int(datagen.RandomInt(r, 10) + 1) + fpSKs, fpPKs, err := datagen.GenRandomBTCKeyPairs(r, numRestakedFPs) + fpBTCPKs := bbn.NewBIP340PKsFromBTCPKs(fpPKs) + require.NoError(t, err) + + // a random finality provider gets slashed + slashedFPIdx := int(datagen.RandomInt(r, numRestakedFPs)) + fpSK, fpPK := fpSKs[slashedFPIdx], fpPKs[slashedFPIdx] + decKey, err := asig.NewDecyptionKeyFromBTCSK(fpSK) + require.NoError(t, err) + encKey, err := asig.NewEncryptionKeyFromBTCPK(fpPK) require.NoError(t, err) - fpPKList := []*btcec.PublicKey{fpPK} // (3, 5) covenant committee covenantSKs, covenantPKs, err := datagen.GenRandomBTCKeyPairs(r, 5) require.NoError(t, err) covenantQuorum := uint32(3) + bsParams := &types.Params{ + CovenantPks: bbn.NewBIP340PKsFromBTCPKs(covenantPKs), + CovenantQuorum: covenantQuorum, + } + covenantSigners := covenantSKs[:covenantQuorum] stakingTimeBlocks := uint16(5) stakingValue := int64(2 * 10e8) @@ -41,16 +55,17 @@ func FuzzBTCUndelegation_SlashingTx(f *testing.F) { slashingRate := sdkmath.LegacyNewDecWithPrec(int64(datagen.RandomInt(r, 41)+10), 2) unbondingTime := uint16(100) + 1 - unbondingValue := stakingValue - 1000 slashingChangeLockTime := unbondingTime // construct the BTC delegation with everything btcDel, err := datagen.GenRandomBTCDelegation( r, t, - bbn.NewBIP340PKsFromBTCPKs(fpPKList), + &chaincfg.SimNetParams, + fpBTCPKs, delSK, - covenantSKs, + covenantSigners, + covenantPKs, covenantQuorum, slashingAddress.EncodeAddress(), 1000, @@ -61,56 +76,36 @@ func FuzzBTCUndelegation_SlashingTx(f *testing.F) { ) require.NoError(t, err) - stakingTxHash := btcDel.MustGetStakingTxHash() - - testInfo := datagen.GenBTCUnbondingSlashingInfo( - r, - t, - net, - delSK, - fpPKList, - covenantPKs, - covenantQuorum, - wire.NewOutPoint(&stakingTxHash, 0), - unbondingTime, - unbondingValue, - slashingAddress.EncodeAddress(), - slashingRate, - slashingChangeLockTime, - ) - require.NoError(t, err) - - // delegator signs the unbonding slashing tx - delSlashingTxSig, err := testInfo.GenDelSlashingTxSig(delSK) - require.NoError(t, err) - - unbondingTxBytes, err := bbn.SerializeBTCTx(testInfo.UnbondingTx) + unbondingInfo, err := btcDel.GetUnbondingInfo(bsParams, net) require.NoError(t, err) - // spend info of the unbonding slashing tx - unbondingSlashingSpendInfo, err := testInfo.UnbondingInfo.SlashingPathSpendInfo() + // TESTING + orderedCovenantPKs := bbn.SortBIP340PKs(bsParams.CovenantPks) + covSigsForFP, err := types.GetOrderedCovenantSignatures(slashedFPIdx, btcDel.BtcUndelegation.CovenantSlashingSigs, bsParams) require.NoError(t, err) - // covenant signs (using adaptor signature) the slashing tx - covenantSigs, err := datagen.GenCovenantAdaptorSigs( - covenantSKs, - []*btcec.PublicKey{fpPK}, - testInfo.UnbondingTx, - unbondingSlashingSpendInfo.GetPkScriptPath(), - testInfo.SlashingTx, - ) + slashingSpendInfo, err := unbondingInfo.SlashingPathSpendInfo() require.NoError(t, err) - btcDel.BtcUndelegation = &types.BTCUndelegation{ - UnbondingTx: unbondingTxBytes, - SlashingTx: testInfo.SlashingTx, - DelegatorUnbondingSig: nil, // not relevant here - DelegatorSlashingSig: delSlashingTxSig, - CovenantSlashingSigs: covenantSigs, - CovenantUnbondingSigList: nil, // not relevant here - } - - bsParams := &types.Params{ - CovenantPks: bbn.NewBIP340PKsFromBTCPKs(covenantPKs), - CovenantQuorum: covenantQuorum, + for i := range covSigsForFP { + if covSigsForFP[i] == nil { + continue + } + err := btcDel.BtcUndelegation.SlashingTx.EncVerifyAdaptorSignature( + unbondingInfo.UnbondingOutput, + slashingSpendInfo.GetPkScriptPath(), + orderedCovenantPKs[i].MustToBTCPK(), + encKey, + covSigsForFP[i], + ) + require.NoError(t, err) + + covSig := covSigsForFP[i].Decrypt(decKey) + err = btcDel.BtcUndelegation.SlashingTx.VerifySignature( + unbondingInfo.UnbondingOutput, + slashingSpendInfo.GetPkScriptPath(), + orderedCovenantPKs[i].MustToBTCPK(), + bbn.NewBIP340SignatureFromBTCSig(covSig), + ) + require.NoError(t, err) } // build slashing tx with witness for spending the unbonding tx @@ -118,6 +113,6 @@ func FuzzBTCUndelegation_SlashingTx(f *testing.F) { require.NoError(t, err) // assert the execution - btctest.AssertSlashingTxExecution(t, testInfo.UnbondingInfo.UnbondingOutput, unbondingSlashingTxWithWitness) + btctest.AssertSlashingTxExecution(t, unbondingInfo.UnbondingOutput, unbondingSlashingTxWithWitness) }) } diff --git a/x/btcstaking/types/btcstaking.go b/x/btcstaking/types/btcstaking.go index 880755870..f907537f2 100644 --- a/x/btcstaking/types/btcstaking.go +++ b/x/btcstaking/types/btcstaking.go @@ -2,23 +2,29 @@ package types import ( "fmt" - "sort" "cosmossdk.io/math" - asig "github.com/babylonchain/babylon/crypto/schnorr-adaptor-signature" - bbn "github.com/babylonchain/babylon/types" - btcctypes "github.com/babylonchain/babylon/x/btccheckpoint/types" + + sdk "github.com/cosmos/cosmos-sdk/types" + + 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" ) func (fp *FinalityProvider) IsSlashed() bool { return fp.SlashedBabylonHeight > 0 } +func (fp *FinalityProvider) IsSluggish() bool { + return fp.Sluggish +} + func (fp *FinalityProvider) ValidateBasic() error { // ensure fields are non-empty and well-formatted - if fp.BabylonPk == nil { - return fmt.Errorf("empty Babylon public key") + if _, err := sdk.AccAddressFromBech32(fp.Addr); err != nil { + return fmt.Errorf("invalid finality provider address: %s - %w", fp.Addr, err) } if fp.BtcPk == nil { return fmt.Errorf("empty BTC public key") @@ -30,28 +36,18 @@ func (fp *FinalityProvider) ValidateBasic() error { return fmt.Errorf("empty proof of possession") } if err := fp.Pop.ValidateBasic(); err != nil { - return err + return fmt.Errorf("PoP is not valid: %w", err) } return nil } -// FilterTopNFinalityProviders returns the top n finality providers based on VotingPower. -func FilterTopNFinalityProviders(fps []*FinalityProviderWithMeta, n uint32) []*FinalityProviderWithMeta { - numFps := uint32(len(fps)) - - // if the given finality provider set is no bigger than n, no need to do anything - if numFps <= n { - return fps - } - - // Sort the finality providers slice, from higher to lower voting power +// SortFinalityProviders sorts the finality providers slice, +// from higher to lower voting power +func SortFinalityProviders(fps []*FinalityProviderDistInfo) { sort.SliceStable(fps, func(i, j int) bool { - return fps[i].VotingPower > fps[j].VotingPower + return fps[i].TotalVotingPower > fps[j].TotalVotingPower }) - - // Return the top n elements - return fps[:n] } func ExistsDup(btcPKs []bbn.BIP340PubKey) bool { @@ -82,8 +78,10 @@ func NewSignatureInfo(pk *bbn.BIP340PubKey, sig *bbn.BIP340Signature) *Signature // the order of covenant adaptor signatures will follow the reverse lexicographical order // of signing public keys, in order to be used as tx witness func GetOrderedCovenantSignatures(fpIdx int, covSigsList []*CovenantAdaptorSignatures, params *Params) ([]*asig.AdaptorSignature, error) { - // construct the map where key is the covenant PK and value is this - // covenant member's adaptor signature encrypted by the given finality provider's PK + // construct the map where + // - key is the covenant PK, and + // - value is this covenant member's adaptor signature encrypted + // by the given finality provider's PK covSigsMap := map[string]*asig.AdaptorSignature{} for _, covSigs := range covSigsList { // find the adaptor signature at the corresponding finality provider's index diff --git a/x/btcstaking/types/btcstaking.pb.go b/x/btcstaking/types/btcstaking.pb.go index c377002ae..09e42a299 100644 --- a/x/btcstaking/types/btcstaking.pb.go +++ b/x/btcstaking/types/btcstaking.pb.go @@ -6,9 +6,8 @@ package types import ( cosmossdk_io_math "cosmossdk.io/math" fmt "fmt" - github_com_babylonchain_babylon_types "github.com/babylonchain/babylon/types" + github_com_babylonlabs_io_babylon_types "github.com/babylonlabs-io/babylon/types" _ "github.com/cosmos/cosmos-proto" - secp256k1 "github.com/cosmos/cosmos-sdk/crypto/keys/secp256k1" types "github.com/cosmos/cosmos-sdk/x/staking/types" _ "github.com/cosmos/gogoproto/gogoproto" proto "github.com/cosmos/gogoproto/proto" @@ -71,17 +70,18 @@ func (BTCDelegationStatus) EnumDescriptor() ([]byte, []int) { // FinalityProvider defines a finality provider type FinalityProvider struct { + // addr is the bech32 address identifier of the finality provider. + Addr string `protobuf:"bytes,1,opt,name=addr,proto3" json:"addr,omitempty"` // description defines the description terms for the finality provider. - Description *types.Description `protobuf:"bytes,1,opt,name=description,proto3" json:"description,omitempty"` + Description *types.Description `protobuf:"bytes,2,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"` - // babylon_pk is the Babylon secp256k1 PK of this finality provider - BabylonPk *secp256k1.PubKey `protobuf:"bytes,3,opt,name=babylon_pk,json=babylonPk,proto3" json:"babylon_pk,omitempty"` + Commission *cosmossdk_io_math.LegacyDec `protobuf:"bytes,3,opt,name=commission,proto3,customtype=cosmossdk.io/math.LegacyDec" json:"commission,omitempty"` // btc_pk is the Bitcoin secp256k1 PK of this finality provider // the PK follows encoding in BIP-340 spec - BtcPk *github_com_babylonchain_babylon_types.BIP340PubKey `protobuf:"bytes,4,opt,name=btc_pk,json=btcPk,proto3,customtype=github.com/babylonchain/babylon/types.BIP340PubKey" json:"btc_pk,omitempty"` - // pop is the proof of possession of babylon_pk and btc_pk - Pop *ProofOfPossession `protobuf:"bytes,5,opt,name=pop,proto3" json:"pop,omitempty"` + 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, where the BTC + // private key signs the bech32 bbn addr of the finality provider. + 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 @@ -90,6 +90,8 @@ type FinalityProvider struct { // 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"` + // sluggish defines whether the finality provider is detected sluggish + Sluggish bool `protobuf:"varint,8,opt,name=sluggish,proto3" json:"sluggish,omitempty"` } func (m *FinalityProvider) Reset() { *m = FinalityProvider{} } @@ -125,21 +127,21 @@ func (m *FinalityProvider) XXX_DiscardUnknown() { var xxx_messageInfo_FinalityProvider proto.InternalMessageInfo -func (m *FinalityProvider) GetDescription() *types.Description { +func (m *FinalityProvider) GetAddr() string { if m != nil { - return m.Description + return m.Addr } - return nil + return "" } -func (m *FinalityProvider) GetBabylonPk() *secp256k1.PubKey { +func (m *FinalityProvider) GetDescription() *types.Description { if m != nil { - return m.BabylonPk + return m.Description } return nil } -func (m *FinalityProvider) GetPop() *ProofOfPossession { +func (m *FinalityProvider) GetPop() *ProofOfPossessionBTC { if m != nil { return m.Pop } @@ -160,11 +162,18 @@ func (m *FinalityProvider) GetSlashedBtcHeight() uint64 { return 0 } +func (m *FinalityProvider) GetSluggish() bool { + if m != nil { + return m.Sluggish + } + return false +} + // FinalityProviderWithMeta wraps the FinalityProvider with metadata. type FinalityProviderWithMeta struct { // btc_pk is the Bitcoin secp256k1 PK of thisfinality provider // the PK follows encoding in BIP-340 spec - BtcPk *github_com_babylonchain_babylon_types.BIP340PubKey `protobuf:"bytes,1,opt,name=btc_pk,json=btcPk,proto3,customtype=github.com/babylonchain/babylon/types.BIP340PubKey" json:"btc_pk,omitempty"` + 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"` // 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 @@ -177,6 +186,8 @@ type FinalityProviderWithMeta struct { // 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"` + // sluggish defines whether the finality provider is detected sluggish + Sluggish bool `protobuf:"varint,6,opt,name=sluggish,proto3" json:"sluggish,omitempty"` } func (m *FinalityProviderWithMeta) Reset() { *m = FinalityProviderWithMeta{} } @@ -240,20 +251,27 @@ func (m *FinalityProviderWithMeta) GetSlashedBtcHeight() uint64 { return 0 } +func (m *FinalityProviderWithMeta) GetSluggish() bool { + if m != nil { + return m.Sluggish + } + return false +} + // BTCDelegation defines a BTC delegation type BTCDelegation struct { - // babylon_pk is the Babylon secp256k1 PK of this BTC delegation - BabylonPk *secp256k1.PubKey `protobuf:"bytes,1,opt,name=babylon_pk,json=babylonPk,proto3" json:"babylon_pk,omitempty"` + // 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_babylonchain_babylon_types.BIP340PubKey `protobuf:"bytes,2,opt,name=btc_pk,json=btcPk,proto3,customtype=github.com/babylonchain/babylon/types.BIP340PubKey" json:"btc_pk,omitempty"` + 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"` // pop is the proof of possession of babylon_pk and btc_pk - Pop *ProofOfPossession `protobuf:"bytes,3,opt,name=pop,proto3" json:"pop,omitempty"` + Pop *ProofOfPossessionBTC `protobuf:"bytes,3,opt,name=pop,proto3" json:"pop,omitempty"` // 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 - FpBtcPkList []github_com_babylonchain_babylon_types.BIP340PubKey `protobuf:"bytes,4,rep,name=fp_btc_pk_list,json=fpBtcPkList,proto3,customtype=github.com/babylonchain/babylon/types.BIP340PubKey" json:"fp_btc_pk_list,omitempty"` + 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"` // 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"` @@ -274,7 +292,7 @@ type BTCDelegation struct { // 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_babylonchain_babylon_types.BIP340Signature `protobuf:"bytes,11,opt,name=delegator_sig,json=delegatorSig,proto3,customtype=github.com/babylonchain/babylon/types.BIP340Signature" json:"delegator_sig,omitempty"` + 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"` // 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. @@ -284,6 +302,8 @@ type BTCDelegation struct { UnbondingTime uint32 `protobuf:"varint,13,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"` + // 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"` } func (m *BTCDelegation) Reset() { *m = BTCDelegation{} } @@ -319,14 +339,14 @@ func (m *BTCDelegation) XXX_DiscardUnknown() { var xxx_messageInfo_BTCDelegation proto.InternalMessageInfo -func (m *BTCDelegation) GetBabylonPk() *secp256k1.PubKey { +func (m *BTCDelegation) GetStakerAddr() string { if m != nil { - return m.BabylonPk + return m.StakerAddr } - return nil + return "" } -func (m *BTCDelegation) GetPop() *ProofOfPossession { +func (m *BTCDelegation) GetPop() *ProofOfPossessionBTC { if m != nil { return m.Pop } @@ -389,6 +409,13 @@ func (m *BTCDelegation) GetBtcUndelegation() *BTCUndelegation { return nil } +func (m *BTCDelegation) GetParamsVersion() uint32 { + if m != nil { + return m.ParamsVersion + } + return 0 +} + // 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 @@ -404,18 +431,18 @@ type BTCUndelegation struct { // 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_babylonchain_babylon_types.BIP340Signature `protobuf:"bytes,3,opt,name=delegator_unbonding_sig,json=delegatorUnbondingSig,proto3,customtype=github.com/babylonchain/babylon/types.BIP340Signature" json:"delegator_unbonding_sig,omitempty"` + 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_babylonchain_babylon_types.BIP340Signature `protobuf:"bytes,4,opt,name=delegator_slashing_sig,json=delegatorSlashingSig,proto3,customtype=github.com/babylonchain/babylon/types.BIP340Signature" json:"delegator_slashing_sig,omitempty"` + 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"` // 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"` // covenant_unbonding_sig_list is the list of signatures on the unbonding tx // by covenant members - // It must be provided after processing undelagate message by Babylon + // 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"` } @@ -473,75 +500,6 @@ func (m *BTCUndelegation) GetCovenantUnbondingSigList() []*SignatureInfo { return nil } -// BTCUndelegationInfo provides all necessary info about the undeleagation -type BTCUndelegationInfo 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. - UnbondingTx []byte `protobuf:"bytes,1,opt,name=unbonding_tx,json=unbondingTx,proto3" json:"unbonding_tx,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"` - // 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,3,rep,name=covenant_slashing_sigs,json=covenantSlashingSigs,proto3" json:"covenant_slashing_sigs,omitempty"` -} - -func (m *BTCUndelegationInfo) Reset() { *m = BTCUndelegationInfo{} } -func (m *BTCUndelegationInfo) String() string { return proto.CompactTextString(m) } -func (*BTCUndelegationInfo) ProtoMessage() {} -func (*BTCUndelegationInfo) Descriptor() ([]byte, []int) { - return fileDescriptor_3851ae95ccfaf7db, []int{4} -} -func (m *BTCUndelegationInfo) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *BTCUndelegationInfo) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_BTCUndelegationInfo.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 *BTCUndelegationInfo) XXX_Merge(src proto.Message) { - xxx_messageInfo_BTCUndelegationInfo.Merge(m, src) -} -func (m *BTCUndelegationInfo) XXX_Size() int { - return m.Size() -} -func (m *BTCUndelegationInfo) XXX_DiscardUnknown() { - xxx_messageInfo_BTCUndelegationInfo.DiscardUnknown(m) -} - -var xxx_messageInfo_BTCUndelegationInfo proto.InternalMessageInfo - -func (m *BTCUndelegationInfo) GetUnbondingTx() []byte { - if m != nil { - return m.UnbondingTx - } - return nil -} - -func (m *BTCUndelegationInfo) GetCovenantUnbondingSigList() []*SignatureInfo { - if m != nil { - return m.CovenantUnbondingSigList - } - return nil -} - -func (m *BTCUndelegationInfo) GetCovenantSlashingSigs() []*CovenantAdaptorSignatures { - if m != nil { - return m.CovenantSlashingSigs - } - 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"` @@ -551,7 +509,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{5} + return fileDescriptor_3851ae95ccfaf7db, []int{4} } func (m *BTCDelegatorDelegations) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -596,7 +554,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{6} + return fileDescriptor_3851ae95ccfaf7db, []int{5} } func (m *BTCDelegatorDelegationIndex) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -634,15 +592,15 @@ func (m *BTCDelegatorDelegationIndex) GetStakingTxHashList() [][]byte { // SignatureInfo is a BIP-340 signature together with its signer's BIP-340 PK type SignatureInfo struct { - Pk *github_com_babylonchain_babylon_types.BIP340PubKey `protobuf:"bytes,1,opt,name=pk,proto3,customtype=github.com/babylonchain/babylon/types.BIP340PubKey" json:"pk,omitempty"` - Sig *github_com_babylonchain_babylon_types.BIP340Signature `protobuf:"bytes,2,opt,name=sig,proto3,customtype=github.com/babylonchain/babylon/types.BIP340Signature" json:"sig,omitempty"` + Pk *github_com_babylonlabs_io_babylon_types.BIP340PubKey `protobuf:"bytes,1,opt,name=pk,proto3,customtype=github.com/babylonlabs-io/babylon/types.BIP340PubKey" json:"pk,omitempty"` + Sig *github_com_babylonlabs_io_babylon_types.BIP340Signature `protobuf:"bytes,2,opt,name=sig,proto3,customtype=github.com/babylonlabs-io/babylon/types.BIP340Signature" json:"sig,omitempty"` } 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{7} + return fileDescriptor_3851ae95ccfaf7db, []int{6} } func (m *SignatureInfo) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -675,7 +633,7 @@ var xxx_messageInfo_SignatureInfo proto.InternalMessageInfo // covenant with different finality provider's public keys as encryption keys type CovenantAdaptorSignatures struct { // cov_pk is the public key of the covenant emulator, used as the public key of the adaptor signature - CovPk *github_com_babylonchain_babylon_types.BIP340PubKey `protobuf:"bytes,1,opt,name=cov_pk,json=covPk,proto3,customtype=github.com/babylonchain/babylon/types.BIP340PubKey" json:"cov_pk,omitempty"` + CovPk *github_com_babylonlabs_io_babylon_types.BIP340PubKey `protobuf:"bytes,1,opt,name=cov_pk,json=covPk,proto3,customtype=github.com/babylonlabs-io/babylon/types.BIP340PubKey" json:"cov_pk,omitempty"` // adaptor_sigs is a list of adaptor signatures, each encrypted by a restaked BTC finality provider's public key AdaptorSigs [][]byte `protobuf:"bytes,2,rep,name=adaptor_sigs,json=adaptorSigs,proto3" json:"adaptor_sigs,omitempty"` } @@ -684,7 +642,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{8} + return fileDescriptor_3851ae95ccfaf7db, []int{7} } func (m *CovenantAdaptorSignatures) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -732,7 +690,7 @@ type SelectiveSlashingEvidence struct { StakingTxHash string `protobuf:"bytes,1,opt,name=staking_tx_hash,json=stakingTxHash,proto3" json:"staking_tx_hash,omitempty"` // fp_btc_pk is the BTC PK of the finality provider who // launches the selective slashing offence - FpBtcPk *github_com_babylonchain_babylon_types.BIP340PubKey `protobuf:"bytes,2,opt,name=fp_btc_pk,json=fpBtcPk,proto3,customtype=github.com/babylonchain/babylon/types.BIP340PubKey" json:"fp_btc_pk,omitempty"` + 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"` // recovered_fp_btc_sk is the finality provider's BTC SK recovered from // the covenant adaptor/Schnorr signature pair. It is the consequence // of selective slashing. @@ -743,7 +701,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{9} + return fileDescriptor_3851ae95ccfaf7db, []int{8} } func (m *SelectiveSlashingEvidence) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -792,7 +750,6 @@ func init() { proto.RegisterType((*FinalityProviderWithMeta)(nil), "babylon.btcstaking.v1.FinalityProviderWithMeta") proto.RegisterType((*BTCDelegation)(nil), "babylon.btcstaking.v1.BTCDelegation") proto.RegisterType((*BTCUndelegation)(nil), "babylon.btcstaking.v1.BTCUndelegation") - proto.RegisterType((*BTCUndelegationInfo)(nil), "babylon.btcstaking.v1.BTCUndelegationInfo") proto.RegisterType((*BTCDelegatorDelegations)(nil), "babylon.btcstaking.v1.BTCDelegatorDelegations") proto.RegisterType((*BTCDelegatorDelegationIndex)(nil), "babylon.btcstaking.v1.BTCDelegatorDelegationIndex") proto.RegisterType((*SignatureInfo)(nil), "babylon.btcstaking.v1.SignatureInfo") @@ -805,83 +762,83 @@ func init() { } var fileDescriptor_3851ae95ccfaf7db = []byte{ - // 1203 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x57, 0xcb, 0x6e, 0xdb, 0x46, - 0x1b, 0x35, 0x25, 0x59, 0x8e, 0x3e, 0x49, 0x89, 0x32, 0x71, 0x1c, 0x26, 0xc6, 0x6f, 0xfb, 0x57, - 0xd3, 0x40, 0x28, 0x1a, 0x2a, 0x76, 0x2e, 0x68, 0xbb, 0x28, 0x10, 0x59, 0x4e, 0x63, 0x24, 0x71, - 0x54, 0xca, 0x6e, 0xd1, 0x16, 0x28, 0x41, 0x91, 0x23, 0x8a, 0x90, 0xc4, 0x61, 0x39, 0x23, 0x55, - 0x7a, 0x80, 0x02, 0xdd, 0x14, 0xe8, 0xb6, 0xfb, 0x3e, 0x42, 0x9f, 0xa1, 0xc8, 0x32, 0xe8, 0xa6, - 0x85, 0x17, 0x46, 0x91, 0xbc, 0x48, 0x31, 0xc3, 0xe1, 0x45, 0x4e, 0xec, 0x5c, 0xe4, 0x9d, 0x38, - 0xdf, 0xed, 0xcc, 0x39, 0x87, 0x9c, 0x11, 0xdc, 0xe8, 0x98, 0x9d, 0xe9, 0x80, 0x78, 0xf5, 0x0e, - 0xb3, 0x28, 0x33, 0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a, 0xfd, 0x53, 0x81, 0xab, 0x6d, 0x3c, 0xc0, 0x16, 0x73, 0xc7, 0x38, 0x52, 0x7d, - 0x87, 0x5f, 0xae, 0x3c, 0x0b, 0xa3, 0x1b, 0x70, 0xe1, 0x98, 0x0a, 0x02, 0x58, 0x41, 0x2f, 0xcf, - 0x08, 0x80, 0x74, 0x28, 0xc4, 0x67, 0xf6, 0x9c, 0x37, 0x88, 0x25, 0x79, 0x5c, 0xa3, 0x9b, 0x70, - 0x29, 0xc0, 0xdc, 0x8f, 0x01, 0xb6, 0x0d, 0xd9, 0x9d, 0x86, 0xf7, 0xe4, 0x92, 0x5e, 0x89, 0x43, - 0x0f, 0x78, 0x7a, 0xbb, 0xff, 0xd1, 0x8e, 0x78, 0x57, 0x13, 0x1b, 0xb5, 0x99, 0xc9, 0x46, 0x14, - 0x15, 0x61, 0xa9, 0xb5, 0xb3, 0xd7, 0xdc, 0xdd, 0xfb, 0xa2, 0xb2, 0x80, 0x00, 0xf2, 0xf7, 0xb7, - 0xf7, 0x77, 0xbf, 0xda, 0xa9, 0x28, 0xa8, 0x04, 0xe7, 0x0e, 0xf6, 0x1a, 0x4f, 0xf7, 0x9a, 0x3b, - 0xcd, 0x4a, 0x06, 0x2d, 0x41, 0xf6, 0xfe, 0xde, 0x37, 0x95, 0x6c, 0xe3, 0xf1, 0xb3, 0x17, 0x6b, - 0xca, 0xf3, 0x17, 0x6b, 0xca, 0xbf, 0x2f, 0xd6, 0x94, 0x5f, 0x5f, 0xae, 0x2d, 0x3c, 0x7f, 0xb9, - 0xb6, 0xf0, 0xcf, 0xcb, 0xb5, 0x85, 0x6f, 0xdf, 0xb8, 0x99, 0x49, 0xfa, 0x4f, 0x89, 0xd8, 0x59, - 0x27, 0x2f, 0xfe, 0x94, 0xdc, 0xfe, 0x2f, 0x00, 0x00, 0xff, 0xff, 0x72, 0x85, 0x4f, 0x14, 0x71, - 0x0d, 0x00, 0x00, + // 1213 bytes of a gzipped FileDescriptorProto + 0x1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x61, 0xec, 0xb6, 0x8d, 0xbd, 0xa0, + 0x42, 0x50, 0x95, 0x1b, 0xd9, 0x49, 0x99, 0x26, 0x75, 0x38, 0xfa, 0x18, 0xae, 0x0c, 0xdd, 0x36, + 0x73, 0x6d, 0x75, 0x5b, 0x3a, 0x20, 0x7a, 0x4e, 0x8d, 0x25, 0x17, 0x59, 0x5b, 0x74, 0x40, 0xd0, + 0x37, 0x90, 0x97, 0xda, 0x18, 0xba, 0x76, 0xa4, 0x7e, 0xfd, 0x8a, 0x92, 0xda, 0xed, 0x33, 0x1a, + 0xa8, 0xb6, 0x76, 0x0e, 0x62, 0xd1, 0xc6, 0x72, 0x5b, 0x58, 0x71, 0x83, 0x44, 0xf6, 0xb0, 0x8f, + 0x07, 0xdc, 0x1c, 0x11, 0x5f, 0xad, 0xf6, 0xe5, 0x00, 0x39, 0xb0, 0x3e, 0x0f, 0x8c, 0xc5, 0xdf, + 0x52, 0xb0, 0x7c, 0xa2, 0x96, 0x54, 0x53, 0xac, 0xe9, 0x71, 0xb0, 0x9b, 0x8c, 0xcc, 0xb4, 0xe5, + 0xff, 0x90, 0x98, 0x38, 0x0f, 0x89, 0x1c, 0x6e, 0x4c, 0x49, 0x9c, 0x02, 0x48, 0x3a, 0x93, 0x17, + 0xa7, 0xf3, 0x7a, 0x54, 0xfb, 0x60, 0x52, 0x5a, 0xf2, 0xfa, 0x13, 0xac, 0xc6, 0x94, 0x33, 0x69, + 0x59, 0x62, 0xa6, 0x2e, 0x8e, 0xb9, 0x32, 0x95, 0x50, 0x58, 0x59, 0x42, 0x76, 0x60, 0x75, 0x2a, + 0xa5, 0x18, 0x22, 0xd7, 0xe7, 0x3f, 0x50, 0x53, 0x2b, 0x91, 0xa6, 0xa6, 0x30, 0x1c, 0x59, 0xb0, + 0x1e, 0xe1, 0xcc, 0x8c, 0x33, 0x58, 0x30, 0x69, 0x05, 0x76, 0xeb, 0x0c, 0xb0, 0xa8, 0xfa, 0x9e, + 0xdb, 0x61, 0x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 0x91, 0xeb, 0xb1, 0x0c, 0x6f, 0xf6, + 0x3e, 0xd9, 0x85, 0x6b, 0x33, 0x72, 0x6b, 0x0a, 0x2c, 0x86, 0x1c, 0x65, 0x60, 0xa1, 0xb1, 0x5b, + 0xaf, 0xed, 0xd5, 0xbf, 0xca, 0xcf, 0x21, 0x80, 0xf4, 0xf6, 0x4e, 0x6b, 0xef, 0xf9, 0x6e, 0x5e, + 0x43, 0x59, 0x58, 0x3c, 0xa8, 0x57, 0xf7, 0xeb, 0xb5, 0xdd, 0x5a, 0x3e, 0x81, 0x16, 0x20, 0xb9, + 0x5d, 0xff, 0x2e, 0x9f, 0xac, 0xd6, 0x5f, 0xbe, 0xd9, 0xd0, 0x5e, 0xbd, 0xd9, 0xd0, 0xfe, 0x7a, + 0xb3, 0xa1, 0xfd, 0xfa, 0x76, 0x63, 0xee, 0xd5, 0xdb, 0x8d, 0xb9, 0x3f, 0xdf, 0x6e, 0xcc, 0x7d, + 0x7f, 0x8e, 0xeb, 0x8c, 0xe3, 0x9f, 0xfc, 0xea, 0x6e, 0xed, 0xb4, 0xfa, 0xe4, 0x7f, 0xf0, 0x6f, + 0x00, 0x00, 0x00, 0xff, 0xff, 0x12, 0x9b, 0x63, 0xae, 0xab, 0x0c, 0x00, 0x00, } func (m *FinalityProvider) Marshal() (dAtA []byte, err error) { @@ -904,6 +861,16 @@ func (m *FinalityProvider) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l + if m.Sluggish { + i-- + if m.Sluggish { + dAtA[i] = 1 + } else { + dAtA[i] = 0 + } + i-- + dAtA[i] = 0x40 + } if m.SlashedBtcHeight != 0 { i = encodeVarintBtcstaking(dAtA, i, uint64(m.SlashedBtcHeight)) i-- @@ -938,18 +905,6 @@ func (m *FinalityProvider) MarshalToSizedBuffer(dAtA []byte) (int, error) { i-- dAtA[i] = 0x22 } - if m.BabylonPk != nil { - { - size, err := m.BabylonPk.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintBtcstaking(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x1a - } if m.Commission != nil { { size := m.Commission.Size() @@ -960,7 +915,7 @@ func (m *FinalityProvider) MarshalToSizedBuffer(dAtA []byte) (int, error) { i = encodeVarintBtcstaking(dAtA, i, uint64(size)) } i-- - dAtA[i] = 0x12 + dAtA[i] = 0x1a } if m.Description != nil { { @@ -972,6 +927,13 @@ func (m *FinalityProvider) MarshalToSizedBuffer(dAtA []byte) (int, error) { i = encodeVarintBtcstaking(dAtA, i, uint64(size)) } i-- + dAtA[i] = 0x12 + } + if len(m.Addr) > 0 { + i -= len(m.Addr) + copy(dAtA[i:], m.Addr) + i = encodeVarintBtcstaking(dAtA, i, uint64(len(m.Addr))) + i-- dAtA[i] = 0xa } return len(dAtA) - i, nil @@ -997,6 +959,16 @@ func (m *FinalityProviderWithMeta) MarshalToSizedBuffer(dAtA []byte) (int, error _ = i var l int _ = l + if m.Sluggish { + i-- + if m.Sluggish { + dAtA[i] = 1 + } else { + dAtA[i] = 0 + } + i-- + dAtA[i] = 0x30 + } if m.SlashedBtcHeight != 0 { i = encodeVarintBtcstaking(dAtA, i, uint64(m.SlashedBtcHeight)) i-- @@ -1052,6 +1024,11 @@ func (m *BTCDelegation) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l + if m.ParamsVersion != 0 { + i = encodeVarintBtcstaking(dAtA, i, uint64(m.ParamsVersion)) + i-- + dAtA[i] = 0x78 + } if m.BtcUndelegation != nil { { size, err := m.BtcUndelegation.MarshalToSizedBuffer(dAtA[:i]) @@ -1172,15 +1149,10 @@ func (m *BTCDelegation) MarshalToSizedBuffer(dAtA []byte) (int, error) { i-- dAtA[i] = 0x12 } - if m.BabylonPk != nil { - { - size, err := m.BabylonPk.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintBtcstaking(dAtA, i, uint64(size)) - } + if len(m.StakerAddr) > 0 { + i -= len(m.StakerAddr) + copy(dAtA[i:], m.StakerAddr) + i = encodeVarintBtcstaking(dAtA, i, uint64(len(m.StakerAddr))) i-- dAtA[i] = 0xa } @@ -1281,64 +1253,6 @@ func (m *BTCUndelegation) MarshalToSizedBuffer(dAtA []byte) (int, error) { return len(dAtA) - i, nil } -func (m *BTCUndelegationInfo) 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 *BTCUndelegationInfo) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *BTCUndelegationInfo) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if len(m.CovenantSlashingSigs) > 0 { - for iNdEx := len(m.CovenantSlashingSigs) - 1; iNdEx >= 0; iNdEx-- { - { - size, err := m.CovenantSlashingSigs[iNdEx].MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintBtcstaking(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x1a - } - } - if len(m.CovenantUnbondingSigList) > 0 { - for iNdEx := len(m.CovenantUnbondingSigList) - 1; iNdEx >= 0; iNdEx-- { - { - size, err := m.CovenantUnbondingSigList[iNdEx].MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintBtcstaking(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x12 - } - } - if len(m.UnbondingTx) > 0 { - i -= len(m.UnbondingTx) - copy(dAtA[i:], m.UnbondingTx) - i = encodeVarintBtcstaking(dAtA, i, uint64(len(m.UnbondingTx))) - i-- - dAtA[i] = 0xa - } - return len(dAtA) - i, nil -} - func (m *BTCDelegatorDelegations) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) @@ -1565,6 +1479,10 @@ func (m *FinalityProvider) Size() (n int) { } var l int _ = l + l = len(m.Addr) + if l > 0 { + n += 1 + l + sovBtcstaking(uint64(l)) + } if m.Description != nil { l = m.Description.Size() n += 1 + l + sovBtcstaking(uint64(l)) @@ -1573,10 +1491,6 @@ func (m *FinalityProvider) Size() (n int) { l = m.Commission.Size() n += 1 + l + sovBtcstaking(uint64(l)) } - if m.BabylonPk != nil { - l = m.BabylonPk.Size() - n += 1 + l + sovBtcstaking(uint64(l)) - } if m.BtcPk != nil { l = m.BtcPk.Size() n += 1 + l + sovBtcstaking(uint64(l)) @@ -1591,6 +1505,9 @@ func (m *FinalityProvider) Size() (n int) { if m.SlashedBtcHeight != 0 { n += 1 + sovBtcstaking(uint64(m.SlashedBtcHeight)) } + if m.Sluggish { + n += 2 + } return n } @@ -1616,6 +1533,9 @@ func (m *FinalityProviderWithMeta) Size() (n int) { if m.SlashedBtcHeight != 0 { n += 1 + sovBtcstaking(uint64(m.SlashedBtcHeight)) } + if m.Sluggish { + n += 2 + } return n } @@ -1625,8 +1545,8 @@ func (m *BTCDelegation) Size() (n int) { } var l int _ = l - if m.BabylonPk != nil { - l = m.BabylonPk.Size() + l = len(m.StakerAddr) + if l > 0 { n += 1 + l + sovBtcstaking(uint64(l)) } if m.BtcPk != nil { @@ -1680,6 +1600,9 @@ func (m *BTCDelegation) Size() (n int) { l = m.BtcUndelegation.Size() n += 1 + l + sovBtcstaking(uint64(l)) } + if m.ParamsVersion != 0 { + n += 1 + sovBtcstaking(uint64(m.ParamsVersion)) + } return n } @@ -1720,31 +1643,6 @@ func (m *BTCUndelegation) Size() (n int) { return n } -func (m *BTCUndelegationInfo) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = len(m.UnbondingTx) - if l > 0 { - n += 1 + l + sovBtcstaking(uint64(l)) - } - if len(m.CovenantUnbondingSigList) > 0 { - for _, e := range m.CovenantUnbondingSigList { - l = e.Size() - n += 1 + l + sovBtcstaking(uint64(l)) - } - } - if len(m.CovenantSlashingSigs) > 0 { - for _, e := range m.CovenantSlashingSigs { - l = e.Size() - n += 1 + l + sovBtcstaking(uint64(l)) - } - } - return n -} - func (m *BTCDelegatorDelegations) Size() (n int) { if m == nil { return 0 @@ -1869,9 +1767,9 @@ func (m *FinalityProvider) Unmarshal(dAtA []byte) error { switch fieldNum { case 1: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Description", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field Addr", wireType) } - var msglen int + var stringLen uint64 for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowBtcstaking @@ -1881,33 +1779,29 @@ func (m *FinalityProvider) 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 ErrInvalidLengthBtcstaking } - postIndex := iNdEx + msglen + postIndex := iNdEx + intStringLen if postIndex < 0 { return ErrInvalidLengthBtcstaking } if postIndex > l { return io.ErrUnexpectedEOF } - if m.Description == nil { - m.Description = &types.Description{} - } - if err := m.Description.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } + m.Addr = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex case 2: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Commission", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field Description", wireType) } - var stringLen uint64 + var msglen int for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowBtcstaking @@ -1917,33 +1811,33 @@ func (m *FinalityProvider) 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 ErrInvalidLengthBtcstaking } - postIndex := iNdEx + intStringLen + postIndex := iNdEx + msglen if postIndex < 0 { return ErrInvalidLengthBtcstaking } 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 { + if m.Description == nil { + m.Description = &types.Description{} + } + if err := m.Description.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } iNdEx = postIndex case 3: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field BabylonPk", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field Commission", wireType) } - var msglen int + var stringLen uint64 for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowBtcstaking @@ -1953,25 +1847,25 @@ func (m *FinalityProvider) 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 ErrInvalidLengthBtcstaking } - postIndex := iNdEx + msglen + postIndex := iNdEx + intStringLen if postIndex < 0 { return ErrInvalidLengthBtcstaking } if postIndex > l { return io.ErrUnexpectedEOF } - if m.BabylonPk == nil { - m.BabylonPk = &secp256k1.PubKey{} - } - if err := m.BabylonPk.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + var v cosmossdk_io_math.LegacyDec + m.Commission = &v + if err := m.Commission.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } iNdEx = postIndex @@ -2004,7 +1898,7 @@ func (m *FinalityProvider) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - var v github_com_babylonchain_babylon_types.BIP340PubKey + var v github_com_babylonlabs_io_babylon_types.BIP340PubKey m.BtcPk = &v if err := m.BtcPk.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err @@ -2040,7 +1934,7 @@ func (m *FinalityProvider) Unmarshal(dAtA []byte) error { return io.ErrUnexpectedEOF } if m.Pop == nil { - m.Pop = &ProofOfPossession{} + m.Pop = &ProofOfPossessionBTC{} } if err := m.Pop.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err @@ -2084,6 +1978,26 @@ func (m *FinalityProvider) Unmarshal(dAtA []byte) error { break } } + case 8: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Sluggish", wireType) + } + var v int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowBtcstaking + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + v |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + m.Sluggish = bool(v != 0) default: iNdEx = preIndex skippy, err := skipBtcstaking(dAtA[iNdEx:]) @@ -2163,7 +2077,7 @@ func (m *FinalityProviderWithMeta) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - var v github_com_babylonchain_babylon_types.BIP340PubKey + var v github_com_babylonlabs_io_babylon_types.BIP340PubKey m.BtcPk = &v if err := m.BtcPk.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err @@ -2245,6 +2159,26 @@ func (m *FinalityProviderWithMeta) Unmarshal(dAtA []byte) error { break } } + case 6: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Sluggish", wireType) + } + var v int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowBtcstaking + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + v |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + m.Sluggish = bool(v != 0) default: iNdEx = preIndex skippy, err := skipBtcstaking(dAtA[iNdEx:]) @@ -2297,9 +2231,9 @@ func (m *BTCDelegation) Unmarshal(dAtA []byte) error { switch fieldNum { case 1: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field BabylonPk", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field StakerAddr", wireType) } - var msglen int + var stringLen uint64 for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowBtcstaking @@ -2309,27 +2243,23 @@ func (m *BTCDelegation) 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 ErrInvalidLengthBtcstaking } - postIndex := iNdEx + msglen + postIndex := iNdEx + intStringLen if postIndex < 0 { return ErrInvalidLengthBtcstaking } if postIndex > l { return io.ErrUnexpectedEOF } - if m.BabylonPk == nil { - m.BabylonPk = &secp256k1.PubKey{} - } - if err := m.BabylonPk.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } + m.StakerAddr = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex case 2: if wireType != 2 { @@ -2360,7 +2290,7 @@ func (m *BTCDelegation) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - var v github_com_babylonchain_babylon_types.BIP340PubKey + var v github_com_babylonlabs_io_babylon_types.BIP340PubKey m.BtcPk = &v if err := m.BtcPk.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err @@ -2396,7 +2326,7 @@ func (m *BTCDelegation) Unmarshal(dAtA []byte) error { return io.ErrUnexpectedEOF } if m.Pop == nil { - m.Pop = &ProofOfPossession{} + m.Pop = &ProofOfPossessionBTC{} } if err := m.Pop.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err @@ -2431,7 +2361,7 @@ func (m *BTCDelegation) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - var v github_com_babylonchain_babylon_types.BIP340PubKey + var v github_com_babylonlabs_io_babylon_types.BIP340PubKey m.FpBtcPkList = append(m.FpBtcPkList, v) if err := m.FpBtcPkList[len(m.FpBtcPkList)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err @@ -2611,7 +2541,7 @@ func (m *BTCDelegation) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - var v github_com_babylonchain_babylon_types.BIP340Signature + var v github_com_babylonlabs_io_babylon_types.BIP340Signature m.DelegatorSig = &v if err := m.DelegatorSig.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err @@ -2706,6 +2636,25 @@ func (m *BTCDelegation) Unmarshal(dAtA []byte) error { return err } iNdEx = postIndex + case 15: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field ParamsVersion", wireType) + } + m.ParamsVersion = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowBtcstaking + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.ParamsVersion |= uint32(b&0x7F) << shift + if b < 0x80 { + break + } + } default: iNdEx = preIndex skippy, err := skipBtcstaking(dAtA[iNdEx:]) @@ -2854,7 +2803,7 @@ func (m *BTCUndelegation) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - var v github_com_babylonchain_babylon_types.BIP340Signature + var v github_com_babylonlabs_io_babylon_types.BIP340Signature m.DelegatorUnbondingSig = &v if err := m.DelegatorUnbondingSig.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err @@ -2889,7 +2838,7 @@ func (m *BTCUndelegation) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - var v github_com_babylonchain_babylon_types.BIP340Signature + var v github_com_babylonlabs_io_babylon_types.BIP340Signature m.DelegatorSlashingSig = &v if err := m.DelegatorSlashingSig.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err @@ -2984,158 +2933,6 @@ func (m *BTCUndelegation) Unmarshal(dAtA []byte) error { } return nil } -func (m *BTCUndelegationInfo) 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: BTCUndelegationInfo: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: BTCUndelegationInfo: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field UnbondingTx", 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.UnbondingTx = append(m.UnbondingTx[:0], dAtA[iNdEx:postIndex]...) - if m.UnbondingTx == nil { - m.UnbondingTx = []byte{} - } - iNdEx = postIndex - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field CovenantUnbondingSigList", 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 - } - 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 3: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field CovenantSlashingSigs", 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 - } - m.CovenantSlashingSigs = append(m.CovenantSlashingSigs, &CovenantAdaptorSignatures{}) - if err := m.CovenantSlashingSigs[len(m.CovenantSlashingSigs)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - 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 *BTCDelegatorDelegations) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 @@ -3360,7 +3157,7 @@ func (m *SignatureInfo) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - var v github_com_babylonchain_babylon_types.BIP340PubKey + var v github_com_babylonlabs_io_babylon_types.BIP340PubKey m.Pk = &v if err := m.Pk.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err @@ -3395,7 +3192,7 @@ func (m *SignatureInfo) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - var v github_com_babylonchain_babylon_types.BIP340Signature + var v github_com_babylonlabs_io_babylon_types.BIP340Signature m.Sig = &v if err := m.Sig.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err @@ -3480,7 +3277,7 @@ func (m *CovenantAdaptorSignatures) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - var v github_com_babylonchain_babylon_types.BIP340PubKey + var v github_com_babylonlabs_io_babylon_types.BIP340PubKey m.CovPk = &v if err := m.CovPk.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err @@ -3629,7 +3426,7 @@ func (m *SelectiveSlashingEvidence) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - var v github_com_babylonchain_babylon_types.BIP340PubKey + var v github_com_babylonlabs_io_babylon_types.BIP340PubKey m.FpBtcPk = &v if err := m.FpBtcPk.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err diff --git a/x/btcstaking/types/codec.go b/x/btcstaking/types/codec.go index 256b38291..e859ded71 100644 --- a/x/btcstaking/types/codec.go +++ b/x/btcstaking/types/codec.go @@ -9,8 +9,10 @@ import ( func RegisterCodec(cdc *codec.LegacyAmino) { cdc.RegisterConcrete(&MsgCreateFinalityProvider{}, "btcstaking/MsgCreateFinalityProvider", nil) + cdc.RegisterConcrete(&MsgEditFinalityProvider{}, "btcstaking/MsgEditFinalityProvider", nil) cdc.RegisterConcrete(&MsgCreateBTCDelegation{}, "btcstaking/MsgCreateBTCDelegation", nil) cdc.RegisterConcrete(&MsgAddCovenantSigs{}, "btcstaking/MsgAddCovenantSigs", nil) + cdc.RegisterConcrete(&MsgBTCUndelegate{}, "btcstaking/MsgBTCUndelegate", nil) cdc.RegisterConcrete(&MsgUpdateParams{}, "btcstaking/MsgUpdateParams", nil) } @@ -19,8 +21,10 @@ func RegisterInterfaces(registry cdctypes.InterfaceRegistry) { registry.RegisterImplementations( (*sdk.Msg)(nil), &MsgCreateFinalityProvider{}, + &MsgEditFinalityProvider{}, &MsgCreateBTCDelegation{}, &MsgAddCovenantSigs{}, + &MsgBTCUndelegate{}, &MsgUpdateParams{}, ) diff --git a/x/btcstaking/types/errors.go b/x/btcstaking/types/errors.go index 5a66ca43b..5de1421d5 100644 --- a/x/btcstaking/types/errors.go +++ b/x/btcstaking/types/errors.go @@ -6,26 +6,29 @@ 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, 1105, "the BTC staking protocol is not activated yet") - ErrBTCHeightNotFound = errorsmod.Register(ModuleName, 1106, "the BTC height is not found") - ErrReusedStakingTx = errorsmod.Register(ModuleName, 1107, "the BTC staking tx is already used") - ErrInvalidCovenantPK = errorsmod.Register(ModuleName, 1108, "the BTC staking tx specifies a wrong covenant PK") - ErrInvalidStakingTx = errorsmod.Register(ModuleName, 1109, "the BTC staking tx is not valid") - ErrInvalidSlashingTx = errorsmod.Register(ModuleName, 1110, "the BTC slashing tx is not valid") - ErrInvalidCovenantSig = errorsmod.Register(ModuleName, 1111, "the covenant signature is not valid") - ErrCommissionLTMinRate = errorsmod.Register(ModuleName, 1112, "commission cannot be less than min rate") - ErrCommissionGTMaxRate = errorsmod.Register(ModuleName, 1113, "commission cannot be more than one") - ErrInvalidDelegationState = errorsmod.Register(ModuleName, 1114, "Unexpected delegation state") - ErrInvalidUnbondingTx = errorsmod.Register(ModuleName, 1115, "the BTC unbonding tx is not valid") - ErrRewardDistCacheNotFound = errorsmod.Register(ModuleName, 1116, "the reward distribution cache is not found") - ErrEmptyFpList = errorsmod.Register(ModuleName, 1117, "the finality provider list is empty") - ErrInvalidProofOfPossession = errorsmod.Register(ModuleName, 1118, "the proof of possession is not valid") - ErrDuplicatedFp = errorsmod.Register(ModuleName, 1119, "the staking request contains duplicated finality provider public key") - ErrInvalidBTCUndelegateReq = errorsmod.Register(ModuleName, 1120, "invalid undelegation request") - ErrVotingPowerTableNotUpdated = errorsmod.Register(ModuleName, 1121, "voting power table has not been updated") + 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") + ErrFpNotBTCTimestamped = errorsmod.Register(ModuleName, 1105, "the finality provider is not BTC timestamped yet") + 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") ) diff --git a/x/btcstaking/types/events.go b/x/btcstaking/types/events.go new file mode 100644 index 000000000..a87dbf10e --- /dev/null +++ b/x/btcstaking/types/events.go @@ -0,0 +1,23 @@ +package types + +import ( + bbn "github.com/babylonlabs-io/babylon/types" +) + +func NewEventPowerDistUpdateWithBTCDel(ev *EventBTCDelegationStateUpdate) *EventPowerDistUpdate { + return &EventPowerDistUpdate{ + Ev: &EventPowerDistUpdate_BtcDelStateUpdate{ + BtcDelStateUpdate: ev, + }, + } +} + +func NewEventPowerDistUpdateWithSlashedFP(fpBTCPK *bbn.BIP340PubKey) *EventPowerDistUpdate { + return &EventPowerDistUpdate{ + Ev: &EventPowerDistUpdate_SlashedFp{ + SlashedFp: &EventPowerDistUpdate_EventSlashedFinalityProvider{ + Pk: fpBTCPK, + }, + }, + } +} diff --git a/x/btcstaking/types/events.pb.go b/x/btcstaking/types/events.pb.go index d4c7a690d..c945e1f8d 100644 --- a/x/btcstaking/types/events.pb.go +++ b/x/btcstaking/types/events.pb.go @@ -5,7 +5,7 @@ package types import ( fmt "fmt" - github_com_babylonchain_babylon_types "github.com/babylonchain/babylon/types" + github_com_babylonlabs_io_babylon_types "github.com/babylonlabs-io/babylon/types" _ "github.com/cosmos/gogoproto/gogoproto" proto "github.com/cosmos/gogoproto/proto" io "io" @@ -69,25 +69,31 @@ func (m *EventNewFinalityProvider) GetFp() *FinalityProvider { return nil } -// EventNewBTCDelegation is the event emitted when a BTC delegation is created -// NOTE: the BTC delegation is not active thus does not have voting power yet -// only after it receives a covenant signature it becomes activated and has voting power -type EventNewBTCDelegation struct { - BtcDel *BTCDelegation `protobuf:"bytes,1,opt,name=btc_del,json=btcDel,proto3" json:"btc_del,omitempty"` +// 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 +type EventBTCDelegationStateUpdate 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 is the new state of this BTC delegation + NewState BTCDelegationStatus `protobuf:"varint,2,opt,name=new_state,json=newState,proto3,enum=babylon.btcstaking.v1.BTCDelegationStatus" json:"new_state,omitempty"` } -func (m *EventNewBTCDelegation) Reset() { *m = EventNewBTCDelegation{} } -func (m *EventNewBTCDelegation) String() string { return proto.CompactTextString(m) } -func (*EventNewBTCDelegation) ProtoMessage() {} -func (*EventNewBTCDelegation) Descriptor() ([]byte, []int) { +func (m *EventBTCDelegationStateUpdate) Reset() { *m = EventBTCDelegationStateUpdate{} } +func (m *EventBTCDelegationStateUpdate) String() string { return proto.CompactTextString(m) } +func (*EventBTCDelegationStateUpdate) ProtoMessage() {} +func (*EventBTCDelegationStateUpdate) Descriptor() ([]byte, []int) { return fileDescriptor_74118427820fff75, []int{1} } -func (m *EventNewBTCDelegation) XXX_Unmarshal(b []byte) error { +func (m *EventBTCDelegationStateUpdate) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } -func (m *EventNewBTCDelegation) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { +func (m *EventBTCDelegationStateUpdate) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { - return xxx_messageInfo_EventNewBTCDelegation.Marshal(b, m, deterministic) + return xxx_messageInfo_EventBTCDelegationStateUpdate.Marshal(b, m, deterministic) } else { b = b[:cap(b)] n, err := m.MarshalToSizedBuffer(b) @@ -97,43 +103,52 @@ func (m *EventNewBTCDelegation) XXX_Marshal(b []byte, deterministic bool) ([]byt return b[:n], nil } } -func (m *EventNewBTCDelegation) XXX_Merge(src proto.Message) { - xxx_messageInfo_EventNewBTCDelegation.Merge(m, src) +func (m *EventBTCDelegationStateUpdate) XXX_Merge(src proto.Message) { + xxx_messageInfo_EventBTCDelegationStateUpdate.Merge(m, src) } -func (m *EventNewBTCDelegation) XXX_Size() int { +func (m *EventBTCDelegationStateUpdate) XXX_Size() int { return m.Size() } -func (m *EventNewBTCDelegation) XXX_DiscardUnknown() { - xxx_messageInfo_EventNewBTCDelegation.DiscardUnknown(m) +func (m *EventBTCDelegationStateUpdate) XXX_DiscardUnknown() { + xxx_messageInfo_EventBTCDelegationStateUpdate.DiscardUnknown(m) } -var xxx_messageInfo_EventNewBTCDelegation proto.InternalMessageInfo +var xxx_messageInfo_EventBTCDelegationStateUpdate proto.InternalMessageInfo -func (m *EventNewBTCDelegation) GetBtcDel() *BTCDelegation { +func (m *EventBTCDelegationStateUpdate) GetStakingTxHash() string { if m != nil { - return m.BtcDel + return m.StakingTxHash } - return nil + return "" +} + +func (m *EventBTCDelegationStateUpdate) GetNewState() BTCDelegationStatus { + if m != nil { + return m.NewState + } + return BTCDelegationStatus_PENDING } -// EventActivateBTCDelegation is the event emitted when covenant activates a BTC delegation -// such that the BTC delegation starts to have voting power in its timelock period -type EventActivateBTCDelegation struct { - BtcDel *BTCDelegation `protobuf:"bytes,1,opt,name=btc_del,json=btcDel,proto3" json:"btc_del,omitempty"` +// 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. +type EventSelectiveSlashing struct { + // evidence is the evidence of selective slashing + Evidence *SelectiveSlashingEvidence `protobuf:"bytes,1,opt,name=evidence,proto3" json:"evidence,omitempty"` } -func (m *EventActivateBTCDelegation) Reset() { *m = EventActivateBTCDelegation{} } -func (m *EventActivateBTCDelegation) String() string { return proto.CompactTextString(m) } -func (*EventActivateBTCDelegation) ProtoMessage() {} -func (*EventActivateBTCDelegation) Descriptor() ([]byte, []int) { +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} } -func (m *EventActivateBTCDelegation) XXX_Unmarshal(b []byte) error { +func (m *EventSelectiveSlashing) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } -func (m *EventActivateBTCDelegation) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { +func (m *EventSelectiveSlashing) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { - return xxx_messageInfo_EventActivateBTCDelegation.Marshal(b, m, deterministic) + return xxx_messageInfo_EventSelectiveSlashing.Marshal(b, m, deterministic) } else { b = b[:cap(b)] n, err := m.MarshalToSizedBuffer(b) @@ -143,57 +158,48 @@ func (m *EventActivateBTCDelegation) XXX_Marshal(b []byte, deterministic bool) ( return b[:n], nil } } -func (m *EventActivateBTCDelegation) XXX_Merge(src proto.Message) { - xxx_messageInfo_EventActivateBTCDelegation.Merge(m, src) +func (m *EventSelectiveSlashing) XXX_Merge(src proto.Message) { + xxx_messageInfo_EventSelectiveSlashing.Merge(m, src) } -func (m *EventActivateBTCDelegation) XXX_Size() int { +func (m *EventSelectiveSlashing) XXX_Size() int { return m.Size() } -func (m *EventActivateBTCDelegation) XXX_DiscardUnknown() { - xxx_messageInfo_EventActivateBTCDelegation.DiscardUnknown(m) +func (m *EventSelectiveSlashing) XXX_DiscardUnknown() { + xxx_messageInfo_EventSelectiveSlashing.DiscardUnknown(m) } -var xxx_messageInfo_EventActivateBTCDelegation proto.InternalMessageInfo +var xxx_messageInfo_EventSelectiveSlashing proto.InternalMessageInfo -func (m *EventActivateBTCDelegation) GetBtcDel() *BTCDelegation { +func (m *EventSelectiveSlashing) GetEvidence() *SelectiveSlashingEvidence { if m != nil { - return m.BtcDel + return m.Evidence } return nil } -// EventUnbondingBTCDelegation is the event emitted when an unbonding BTC delegation -// receives all signatures needed for becoming unbonded -type EventUnbondedBTCDelegation struct { - // btc_pk is the Bitcoin secp256k1 PK of this BTC delegation - // the PK follows encoding in BIP-340 spec - BtcPk *github_com_babylonchain_babylon_types.BIP340PubKey `protobuf:"bytes,1,opt,name=btc_pk,json=btcPk,proto3,customtype=github.com/babylonchain/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 - // If there is more than 1 PKs, then this means the delegation is restaked - // to multiple finality providers - FpBtcPkList []github_com_babylonchain_babylon_types.BIP340PubKey `protobuf:"bytes,2,rep,name=fp_btc_pk_list,json=fpBtcPkList,proto3,customtype=github.com/babylonchain/babylon/types.BIP340PubKey" json:"fp_btc_pk_list,omitempty"` - // staking_tx_hash is the hash of the staking tx. - // (fp_pks..., del_pk, staking_tx_hash) uniquely identifies a BTC delegation - StakingTxHash string `protobuf:"bytes,3,opt,name=staking_tx_hash,json=stakingTxHash,proto3" json:"staking_tx_hash,omitempty"` - // unbonding_tx_hash is the hash of the unbonding tx. - UnbondingTxHash string `protobuf:"bytes,4,opt,name=unbonding_tx_hash,json=unbondingTxHash,proto3" json:"unbonding_tx_hash,omitempty"` - // from_state is the last state the BTC delegation was at - FromState BTCDelegationStatus `protobuf:"varint,5,opt,name=from_state,json=fromState,proto3,enum=babylon.btcstaking.v1.BTCDelegationStatus" json:"from_state,omitempty"` +// EventPowerDistUpdate is an event that affects voting power distirbution +// of BTC staking protocol +type EventPowerDistUpdate struct { + // ev is the event that affects voting power distribution + // + // Types that are valid to be assigned to Ev: + // *EventPowerDistUpdate_SlashedFp + // *EventPowerDistUpdate_BtcDelStateUpdate + Ev isEventPowerDistUpdate_Ev `protobuf_oneof:"ev"` } -func (m *EventUnbondedBTCDelegation) Reset() { *m = EventUnbondedBTCDelegation{} } -func (m *EventUnbondedBTCDelegation) String() string { return proto.CompactTextString(m) } -func (*EventUnbondedBTCDelegation) ProtoMessage() {} -func (*EventUnbondedBTCDelegation) Descriptor() ([]byte, []int) { +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} } -func (m *EventUnbondedBTCDelegation) XXX_Unmarshal(b []byte) error { +func (m *EventPowerDistUpdate) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } -func (m *EventUnbondedBTCDelegation) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { +func (m *EventPowerDistUpdate) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { - return xxx_messageInfo_EventUnbondedBTCDelegation.Marshal(b, m, deterministic) + return xxx_messageInfo_EventPowerDistUpdate.Marshal(b, m, deterministic) } else { b = b[:cap(b)] n, err := m.MarshalToSizedBuffer(b) @@ -203,59 +209,86 @@ func (m *EventUnbondedBTCDelegation) XXX_Marshal(b []byte, deterministic bool) ( return b[:n], nil } } -func (m *EventUnbondedBTCDelegation) XXX_Merge(src proto.Message) { - xxx_messageInfo_EventUnbondedBTCDelegation.Merge(m, src) +func (m *EventPowerDistUpdate) XXX_Merge(src proto.Message) { + xxx_messageInfo_EventPowerDistUpdate.Merge(m, src) } -func (m *EventUnbondedBTCDelegation) XXX_Size() int { +func (m *EventPowerDistUpdate) XXX_Size() int { return m.Size() } -func (m *EventUnbondedBTCDelegation) XXX_DiscardUnknown() { - xxx_messageInfo_EventUnbondedBTCDelegation.DiscardUnknown(m) +func (m *EventPowerDistUpdate) XXX_DiscardUnknown() { + xxx_messageInfo_EventPowerDistUpdate.DiscardUnknown(m) +} + +var xxx_messageInfo_EventPowerDistUpdate proto.InternalMessageInfo + +type isEventPowerDistUpdate_Ev interface { + isEventPowerDistUpdate_Ev() + MarshalTo([]byte) (int, error) + Size() int +} + +type EventPowerDistUpdate_SlashedFp struct { + SlashedFp *EventPowerDistUpdate_EventSlashedFinalityProvider `protobuf:"bytes,1,opt,name=slashed_fp,json=slashedFp,proto3,oneof" json:"slashed_fp,omitempty"` +} +type EventPowerDistUpdate_BtcDelStateUpdate struct { + BtcDelStateUpdate *EventBTCDelegationStateUpdate `protobuf:"bytes,2,opt,name=btc_del_state_update,json=btcDelStateUpdate,proto3,oneof" json:"btc_del_state_update,omitempty"` } -var xxx_messageInfo_EventUnbondedBTCDelegation proto.InternalMessageInfo +func (*EventPowerDistUpdate_SlashedFp) isEventPowerDistUpdate_Ev() {} +func (*EventPowerDistUpdate_BtcDelStateUpdate) isEventPowerDistUpdate_Ev() {} -func (m *EventUnbondedBTCDelegation) GetStakingTxHash() string { +func (m *EventPowerDistUpdate) GetEv() isEventPowerDistUpdate_Ev { if m != nil { - return m.StakingTxHash + return m.Ev } - return "" + return nil } -func (m *EventUnbondedBTCDelegation) GetUnbondingTxHash() string { - if m != nil { - return m.UnbondingTxHash +func (m *EventPowerDistUpdate) GetSlashedFp() *EventPowerDistUpdate_EventSlashedFinalityProvider { + if x, ok := m.GetEv().(*EventPowerDistUpdate_SlashedFp); ok { + return x.SlashedFp } - return "" + return nil } -func (m *EventUnbondedBTCDelegation) GetFromState() BTCDelegationStatus { - if m != nil { - return m.FromState +func (m *EventPowerDistUpdate) GetBtcDelStateUpdate() *EventBTCDelegationStateUpdate { + if x, ok := m.GetEv().(*EventPowerDistUpdate_BtcDelStateUpdate); ok { + return x.BtcDelStateUpdate } - return BTCDelegationStatus_PENDING + return nil } -// 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. -type EventSelectiveSlashing struct { - // evidence is the evidence of selective slashing - Evidence *SelectiveSlashingEvidence `protobuf:"bytes,1,opt,name=evidence,proto3" json:"evidence,omitempty"` +// XXX_OneofWrappers is for the internal use of the proto package. +func (*EventPowerDistUpdate) XXX_OneofWrappers() []interface{} { + return []interface{}{ + (*EventPowerDistUpdate_SlashedFp)(nil), + (*EventPowerDistUpdate_BtcDelStateUpdate)(nil), + } } -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{4} +// EventSlashedFinalityProvider defines an event that a finality provider +// is slashed +// TODO: unify with existing slashing events +type EventPowerDistUpdate_EventSlashedFinalityProvider struct { + Pk *github_com_babylonlabs_io_babylon_types.BIP340PubKey `protobuf:"bytes,1,opt,name=pk,proto3,customtype=github.com/babylonlabs-io/babylon/types.BIP340PubKey" json:"pk,omitempty"` } -func (m *EventSelectiveSlashing) XXX_Unmarshal(b []byte) error { + +func (m *EventPowerDistUpdate_EventSlashedFinalityProvider) Reset() { + *m = EventPowerDistUpdate_EventSlashedFinalityProvider{} +} +func (m *EventPowerDistUpdate_EventSlashedFinalityProvider) String() string { + return proto.CompactTextString(m) +} +func (*EventPowerDistUpdate_EventSlashedFinalityProvider) ProtoMessage() {} +func (*EventPowerDistUpdate_EventSlashedFinalityProvider) Descriptor() ([]byte, []int) { + return fileDescriptor_74118427820fff75, []int{3, 0} +} +func (m *EventPowerDistUpdate_EventSlashedFinalityProvider) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } -func (m *EventSelectiveSlashing) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { +func (m *EventPowerDistUpdate_EventSlashedFinalityProvider) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { - return xxx_messageInfo_EventSelectiveSlashing.Marshal(b, m, deterministic) + return xxx_messageInfo_EventPowerDistUpdate_EventSlashedFinalityProvider.Marshal(b, m, deterministic) } else { b = b[:cap(b)] n, err := m.MarshalToSizedBuffer(b) @@ -265,31 +298,24 @@ func (m *EventSelectiveSlashing) XXX_Marshal(b []byte, deterministic bool) ([]by return b[:n], nil } } -func (m *EventSelectiveSlashing) XXX_Merge(src proto.Message) { - xxx_messageInfo_EventSelectiveSlashing.Merge(m, src) +func (m *EventPowerDistUpdate_EventSlashedFinalityProvider) XXX_Merge(src proto.Message) { + xxx_messageInfo_EventPowerDistUpdate_EventSlashedFinalityProvider.Merge(m, src) } -func (m *EventSelectiveSlashing) XXX_Size() int { +func (m *EventPowerDistUpdate_EventSlashedFinalityProvider) XXX_Size() int { return m.Size() } -func (m *EventSelectiveSlashing) XXX_DiscardUnknown() { - xxx_messageInfo_EventSelectiveSlashing.DiscardUnknown(m) +func (m *EventPowerDistUpdate_EventSlashedFinalityProvider) XXX_DiscardUnknown() { + xxx_messageInfo_EventPowerDistUpdate_EventSlashedFinalityProvider.DiscardUnknown(m) } -var xxx_messageInfo_EventSelectiveSlashing proto.InternalMessageInfo - -func (m *EventSelectiveSlashing) GetEvidence() *SelectiveSlashingEvidence { - if m != nil { - return m.Evidence - } - return nil -} +var xxx_messageInfo_EventPowerDistUpdate_EventSlashedFinalityProvider proto.InternalMessageInfo func init() { proto.RegisterType((*EventNewFinalityProvider)(nil), "babylon.btcstaking.v1.EventNewFinalityProvider") - proto.RegisterType((*EventNewBTCDelegation)(nil), "babylon.btcstaking.v1.EventNewBTCDelegation") - proto.RegisterType((*EventActivateBTCDelegation)(nil), "babylon.btcstaking.v1.EventActivateBTCDelegation") - proto.RegisterType((*EventUnbondedBTCDelegation)(nil), "babylon.btcstaking.v1.EventUnbondedBTCDelegation") + 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") } func init() { @@ -297,37 +323,37 @@ func init() { } var fileDescriptor_74118427820fff75 = []byte{ - // 469 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x93, 0x41, 0x6f, 0xd3, 0x30, - 0x18, 0x86, 0x9b, 0x8e, 0x0d, 0xe6, 0xc1, 0x26, 0x22, 0x86, 0xa2, 0x1e, 0x42, 0x15, 0xa1, 0x51, - 0xed, 0x90, 0x6c, 0x1d, 0x82, 0x13, 0x07, 0xc2, 0x86, 0x98, 0x28, 0xa8, 0x4a, 0x07, 0x07, 0x76, - 0x88, 0xec, 0xf4, 0x4b, 0x62, 0x35, 0xb3, 0xa3, 0xfa, 0x6b, 0x68, 0xff, 0x05, 0x3f, 0x8b, 0xe3, - 0x8e, 0x88, 0x03, 0x42, 0xed, 0x81, 0xbf, 0x81, 0x92, 0x79, 0xa3, 0x83, 0x55, 0x20, 0xb1, 0x9b, - 0x93, 0x3c, 0xef, 0xf3, 0xc9, 0xaf, 0x63, 0xe2, 0x30, 0xca, 0x26, 0x99, 0x14, 0x1e, 0xc3, 0x48, - 0x21, 0x1d, 0x70, 0x91, 0x78, 0xc5, 0xae, 0x07, 0x05, 0x08, 0x54, 0x6e, 0x3e, 0x94, 0x28, 0xcd, - 0x4d, 0xcd, 0xb8, 0xbf, 0x18, 0xb7, 0xd8, 0x6d, 0xdc, 0x4b, 0x64, 0x22, 0x2b, 0xc2, 0x2b, 0x57, - 0x67, 0x70, 0x63, 0xeb, 0x6a, 0xe1, 0x5c, 0xb4, 0xe2, 0x9c, 0x1e, 0xb1, 0x0e, 0xca, 0x21, 0x6f, - 0xe1, 0xe3, 0x4b, 0x2e, 0x68,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xe0, 0x8e, 0x7e, 0x7d, 0x34, 0x7e, 0x45, - 0x55, 0x6a, 0x6e, 0x93, 0xbb, 0xa3, 0x6a, 0xb3, 0xf3, 0xe4, 0x8d, 0x8a, 0xdc, 0xb8, 0xf8, 0xa0, - 0xd9, 0x43, 0x42, 0xe2, 0xa1, 0x3c, 0x09, 0x15, 0x52, 0x04, 0x6b, 0xb9, 0x69, 0xb4, 0xd6, 0xdb, - 0xdb, 0xff, 0x52, 0x70, 0x0f, 0x29, 0x8e, 0x54, 0xb0, 0x5a, 0xa6, 0xcb, 0x35, 0x38, 0x31, 0xb9, - 0x5f, 0x15, 0xdd, 0x83, 0x0c, 0xca, 0x93, 0x84, 0x5e, 0x46, 0x55, 0xca, 0x45, 0x62, 0x76, 0xc8, - 0x2d, 0x28, 0x7f, 0x23, 0x11, 0x81, 0x3e, 0xc3, 0x9d, 0x05, 0x23, 0xfe, 0xc8, 0x1e, 0xe8, 0x5c, - 0x70, 0x61, 0xf0, 0x3b, 0x9f, 0xa7, 0xb6, 0x71, 0x3a, 0xb5, 0x8d, 0xef, 0x53, 0xdb, 0xf8, 0x34, - 0xb3, 0x6b, 0xa7, 0x33, 0xbb, 0xf6, 0x65, 0x66, 0xd7, 0x3e, 0xfc, 0xb5, 0xe1, 0xf1, 0xfc, 0xbd, - 0xa9, 0xea, 0x66, 0x2b, 0xd5, 0x85, 0xd9, 0xfb, 0x19, 0x00, 0x00, 0xff, 0xff, 0xb8, 0x88, 0x9f, - 0xc0, 0xab, 0x03, 0x00, 0x00, + // 466 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x8c, 0x93, 0xcd, 0x6e, 0xd3, 0x40, + 0x14, 0x85, 0x6d, 0x0b, 0xa1, 0x66, 0xca, 0x8f, 0xb0, 0x02, 0x8a, 0x22, 0x30, 0x95, 0x17, 0xa5, + 0x42, 0xc2, 0x6e, 0xd3, 0x48, 0xb0, 0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, 0x90, 0x2f, 0x30, 0x8f, 0xac, 0x72, 0x14, 0x3c, 0x40, 0x16, 0x54, + 0xc1, 0xd9, 0xcf, 0x85, 0x63, 0x5e, 0x2e, 0x1c, 0xf3, 0xcf, 0xc2, 0x31, 0x2f, 0x96, 0x8e, 0x71, + 0xb9, 0x74, 0x8c, 0x5f, 0x4b, 0xc7, 0xf8, 0x7e, 0x8f, 0xe4, 0xd9, 0xfa, 0x53, 0x50, 0x18, 0xf2, + 0x50, 0xbd, 0x81, 0xe3, 0xbf, 0x01, 0x00, 0x00, 0xff, 0xff, 0xbc, 0x5a, 0xe3, 0x63, 0x7e, 0x03, + 0x00, 0x00, } func (m *EventNewFinalityProvider) Marshal() (dAtA []byte, err error) { @@ -365,7 +391,7 @@ func (m *EventNewFinalityProvider) MarshalToSizedBuffer(dAtA []byte) (int, error return len(dAtA) - i, nil } -func (m *EventNewBTCDelegation) Marshal() (dAtA []byte, err error) { +func (m *EventBTCDelegationStateUpdate) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalToSizedBuffer(dAtA[:size]) @@ -375,32 +401,32 @@ func (m *EventNewBTCDelegation) Marshal() (dAtA []byte, err error) { return dAtA[:n], nil } -func (m *EventNewBTCDelegation) MarshalTo(dAtA []byte) (int, error) { +func (m *EventBTCDelegationStateUpdate) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *EventNewBTCDelegation) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *EventBTCDelegationStateUpdate) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) _ = i var l int _ = l - if m.BtcDel != nil { - { - size, err := m.BtcDel.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintEvents(dAtA, i, uint64(size)) - } + 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 } return len(dAtA) - i, nil } -func (m *EventActivateBTCDelegation) Marshal() (dAtA []byte, err error) { +func (m *EventSelectiveSlashing) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalToSizedBuffer(dAtA[:size]) @@ -410,19 +436,19 @@ func (m *EventActivateBTCDelegation) Marshal() (dAtA []byte, err error) { return dAtA[:n], nil } -func (m *EventActivateBTCDelegation) MarshalTo(dAtA []byte) (int, error) { +func (m *EventSelectiveSlashing) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *EventActivateBTCDelegation) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *EventSelectiveSlashing) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) _ = i var l int _ = l - if m.BtcDel != nil { + if m.Evidence != nil { { - size, err := m.BtcDel.MarshalToSizedBuffer(dAtA[:i]) + size, err := m.Evidence.MarshalToSizedBuffer(dAtA[:i]) if err != nil { return 0, err } @@ -435,7 +461,7 @@ func (m *EventActivateBTCDelegation) MarshalToSizedBuffer(dAtA []byte) (int, err return len(dAtA) - i, nil } -func (m *EventUnbondedBTCDelegation) Marshal() (dAtA []byte, err error) { +func (m *EventPowerDistUpdate) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalToSizedBuffer(dAtA[:size]) @@ -445,56 +471,42 @@ func (m *EventUnbondedBTCDelegation) Marshal() (dAtA []byte, err error) { return dAtA[:n], nil } -func (m *EventUnbondedBTCDelegation) MarshalTo(dAtA []byte) (int, error) { +func (m *EventPowerDistUpdate) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *EventUnbondedBTCDelegation) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *EventPowerDistUpdate) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) _ = i var l int _ = l - if m.FromState != 0 { - i = encodeVarintEvents(dAtA, i, uint64(m.FromState)) - i-- - dAtA[i] = 0x28 - } - if len(m.UnbondingTxHash) > 0 { - i -= len(m.UnbondingTxHash) - copy(dAtA[i:], m.UnbondingTxHash) - i = encodeVarintEvents(dAtA, i, uint64(len(m.UnbondingTxHash))) - i-- - dAtA[i] = 0x22 - } - 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] = 0x1a - } - if len(m.FpBtcPkList) > 0 { - for iNdEx := len(m.FpBtcPkList) - 1; iNdEx >= 0; iNdEx-- { - { - size := m.FpBtcPkList[iNdEx].Size() - i -= size - if _, err := m.FpBtcPkList[iNdEx].MarshalTo(dAtA[i:]); err != nil { - return 0, err - } - i = encodeVarintEvents(dAtA, i, uint64(size)) + if m.Ev != nil { + { + size := m.Ev.Size() + i -= size + if _, err := m.Ev.MarshalTo(dAtA[i:]); err != nil { + return 0, err } - i-- - dAtA[i] = 0x12 } } - if m.BtcPk != nil { + return len(dAtA) - i, nil +} + +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 := m.BtcPk.Size() - i -= size - if _, err := m.BtcPk.MarshalTo(dAtA[i:]); err != nil { + size, err := m.SlashedFp.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { return 0, err } + i -= size i = encodeVarintEvents(dAtA, i, uint64(size)) } i-- @@ -502,8 +514,28 @@ func (m *EventUnbondedBTCDelegation) MarshalToSizedBuffer(dAtA []byte) (int, err } return len(dAtA) - i, nil } +func (m *EventPowerDistUpdate_BtcDelStateUpdate) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} -func (m *EventSelectiveSlashing) Marshal() (dAtA []byte, err error) { +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] = 0x12 + } + 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]) @@ -513,23 +545,23 @@ func (m *EventSelectiveSlashing) Marshal() (dAtA []byte, err error) { return dAtA[:n], nil } -func (m *EventSelectiveSlashing) MarshalTo(dAtA []byte) (int, error) { +func (m *EventPowerDistUpdate_EventSlashedFinalityProvider) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *EventSelectiveSlashing) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *EventPowerDistUpdate_EventSlashedFinalityProvider) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) _ = i var l int _ = l - if m.Evidence != nil { + if m.Pk != nil { { - size, err := m.Evidence.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { + size := m.Pk.Size() + i -= size + if _, err := m.Pk.MarshalTo(dAtA[i:]); err != nil { return 0, err } - i -= size i = encodeVarintEvents(dAtA, i, uint64(size)) } i-- @@ -562,70 +594,79 @@ func (m *EventNewFinalityProvider) Size() (n int) { return n } -func (m *EventNewBTCDelegation) Size() (n int) { +func (m *EventBTCDelegationStateUpdate) Size() (n int) { if m == nil { return 0 } var l int _ = l - if m.BtcDel != nil { - l = m.BtcDel.Size() + 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 *EventActivateBTCDelegation) Size() (n int) { +func (m *EventSelectiveSlashing) Size() (n int) { if m == nil { return 0 } var l int _ = l - if m.BtcDel != nil { - l = m.BtcDel.Size() + if m.Evidence != nil { + l = m.Evidence.Size() n += 1 + l + sovEvents(uint64(l)) } return n } -func (m *EventUnbondedBTCDelegation) Size() (n int) { +func (m *EventPowerDistUpdate) Size() (n int) { if m == nil { return 0 } var l int _ = l - if m.BtcPk != nil { - l = m.BtcPk.Size() - n += 1 + l + sovEvents(uint64(l)) + if m.Ev != nil { + n += m.Ev.Size() } - if len(m.FpBtcPkList) > 0 { - for _, e := range m.FpBtcPkList { - l = e.Size() - n += 1 + l + sovEvents(uint64(l)) - } + return n +} + +func (m *EventPowerDistUpdate_SlashedFp) Size() (n int) { + if m == nil { + return 0 } - l = len(m.StakingTxHash) - if l > 0 { + var l int + _ = l + if m.SlashedFp != nil { + l = m.SlashedFp.Size() n += 1 + l + sovEvents(uint64(l)) } - l = len(m.UnbondingTxHash) - if l > 0 { - n += 1 + l + sovEvents(uint64(l)) + return n +} +func (m *EventPowerDistUpdate_BtcDelStateUpdate) Size() (n int) { + if m == nil { + return 0 } - if m.FromState != 0 { - n += 1 + sovEvents(uint64(m.FromState)) + var l int + _ = l + if m.BtcDelStateUpdate != nil { + l = m.BtcDelStateUpdate.Size() + n += 1 + l + sovEvents(uint64(l)) } return n } - -func (m *EventSelectiveSlashing) Size() (n int) { +func (m *EventPowerDistUpdate_EventSlashedFinalityProvider) Size() (n int) { if m == nil { return 0 } var l int _ = l - if m.Evidence != nil { - l = m.Evidence.Size() + if m.Pk != nil { + l = m.Pk.Size() n += 1 + l + sovEvents(uint64(l)) } return n @@ -723,7 +764,7 @@ func (m *EventNewFinalityProvider) Unmarshal(dAtA []byte) error { } return nil } -func (m *EventNewBTCDelegation) Unmarshal(dAtA []byte) error { +func (m *EventBTCDelegationStateUpdate) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -746,17 +787,17 @@ func (m *EventNewBTCDelegation) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: EventNewBTCDelegation: wiretype end group for non-group") + return fmt.Errorf("proto: EventBTCDelegationStateUpdate: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: EventNewBTCDelegation: illegal tag %d (wire type %d)", fieldNum, wire) + 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 BtcDel", 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 @@ -766,28 +807,43 @@ func (m *EventNewBTCDelegation) 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.BtcDel == nil { - m.BtcDel = &BTCDelegation{} + 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 err := m.BtcDel.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err + 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 + } } - iNdEx = postIndex default: iNdEx = preIndex skippy, err := skipEvents(dAtA[iNdEx:]) @@ -809,7 +865,7 @@ func (m *EventNewBTCDelegation) Unmarshal(dAtA []byte) error { } return nil } -func (m *EventActivateBTCDelegation) Unmarshal(dAtA []byte) error { +func (m *EventSelectiveSlashing) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -832,15 +888,15 @@ func (m *EventActivateBTCDelegation) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: EventActivateBTCDelegation: wiretype end group for non-group") + return fmt.Errorf("proto: EventSelectiveSlashing: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: EventActivateBTCDelegation: illegal tag %d (wire type %d)", fieldNum, wire) + 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 BtcDel", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field Evidence", wireType) } var msglen int for shift := uint(0); ; shift += 7 { @@ -867,10 +923,10 @@ func (m *EventActivateBTCDelegation) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - if m.BtcDel == nil { - m.BtcDel = &BTCDelegation{} + if m.Evidence == nil { + m.Evidence = &SelectiveSlashingEvidence{} } - if err := m.BtcDel.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + if err := m.Evidence.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } iNdEx = postIndex @@ -895,7 +951,7 @@ func (m *EventActivateBTCDelegation) Unmarshal(dAtA []byte) error { } return nil } -func (m *EventUnbondedBTCDelegation) Unmarshal(dAtA []byte) error { +func (m *EventPowerDistUpdate) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -918,17 +974,17 @@ func (m *EventUnbondedBTCDelegation) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: EventUnbondedBTCDelegation: wiretype end group for non-group") + return fmt.Errorf("proto: EventPowerDistUpdate: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: EventUnbondedBTCDelegation: illegal tag %d (wire type %d)", fieldNum, wire) + 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 BtcPk", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field SlashedFp", wireType) } - var byteLen int + var msglen int for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowEvents @@ -938,32 +994,32 @@ func (m *EventUnbondedBTCDelegation) 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 ErrInvalidLengthEvents } - postIndex := iNdEx + byteLen + postIndex := iNdEx + msglen if postIndex < 0 { return ErrInvalidLengthEvents } if postIndex > l { return io.ErrUnexpectedEOF } - var v github_com_babylonchain_babylon_types.BIP340PubKey - m.BtcPk = &v - if err := m.BtcPk.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + 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 FpBtcPkList", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field BtcDelStateUpdate", wireType) } - var byteLen int + var msglen int for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowEvents @@ -973,110 +1029,27 @@ func (m *EventUnbondedBTCDelegation) 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 ErrInvalidLengthEvents } - postIndex := iNdEx + byteLen + postIndex := iNdEx + msglen if postIndex < 0 { return ErrInvalidLengthEvents } if postIndex > l { return io.ErrUnexpectedEOF } - var v github_com_babylonchain_babylon_types.BIP340PubKey - m.FpBtcPkList = append(m.FpBtcPkList, v) - if err := m.FpBtcPkList[len(m.FpBtcPkList)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + v := &EventBTCDelegationStateUpdate{} + if err := v.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } + m.Ev = &EventPowerDistUpdate_BtcDelStateUpdate{v} 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 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 4: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field UnbondingTxHash", 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.UnbondingTxHash = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 5: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field FromState", wireType) - } - m.FromState = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowEvents - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.FromState |= BTCDelegationStatus(b&0x7F) << shift - if b < 0x80 { - break - } - } default: iNdEx = preIndex skippy, err := skipEvents(dAtA[iNdEx:]) @@ -1098,7 +1071,7 @@ func (m *EventUnbondedBTCDelegation) Unmarshal(dAtA []byte) error { } return nil } -func (m *EventSelectiveSlashing) Unmarshal(dAtA []byte) error { +func (m *EventPowerDistUpdate_EventSlashedFinalityProvider) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -1121,17 +1094,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: EventSlashedFinalityProvider: 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: 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 Evidence", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field Pk", wireType) } - var msglen int + var byteLen int for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowEvents @@ -1141,25 +1114,24 @@ func (m *EventSelectiveSlashing) 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 ErrInvalidLengthEvents } - postIndex := iNdEx + msglen + postIndex := iNdEx + byteLen 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 { + 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 diff --git a/x/btcstaking/types/expected_keepers.go b/x/btcstaking/types/expected_keepers.go index 7d5a8a1ed..237879011 100644 --- a/x/btcstaking/types/expected_keepers.go +++ b/x/btcstaking/types/expected_keepers.go @@ -4,12 +4,14 @@ import ( "context" "math/big" - bbn "github.com/babylonchain/babylon/types" - btcctypes "github.com/babylonchain/babylon/x/btccheckpoint/types" - btclctypes "github.com/babylonchain/babylon/x/btclightclient/types" + 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" + etypes "github.com/babylonlabs-io/babylon/x/epoching/types" ) type BTCLightClientKeeper interface { + GetBaseBTCHeader(ctx context.Context) *btclctypes.BTCHeaderInfo GetTipInfo(ctx context.Context) *btclctypes.BTCHeaderInfo GetHeaderByHash(ctx context.Context, hash *bbn.BTCHeaderHashBytes) *btclctypes.BTCHeaderInfo } @@ -18,3 +20,12 @@ type BtcCheckpointKeeper interface { GetPowLimit() *big.Int GetParams(ctx context.Context) (p btcctypes.Params) } + +type CheckpointingKeeper interface { + GetEpoch(ctx context.Context) *etypes.Epoch + GetLastFinalizedEpoch(ctx context.Context) uint64 +} + +type BtcStakingHooks interface { + AfterFinalityProviderActivated(ctx context.Context, fpPk *bbn.BIP340PubKey) error +} diff --git a/x/btcstaking/types/genesis.go b/x/btcstaking/types/genesis.go index ab1a56d77..73ad67db2 100644 --- a/x/btcstaking/types/genesis.go +++ b/x/btcstaking/types/genesis.go @@ -1,16 +1,44 @@ package types +import ( + "encoding/json" + "fmt" + + "github.com/cosmos/cosmos-sdk/codec" +) + // DefaultGenesis returns the default genesis state func DefaultGenesis() *GenesisState { + p := DefaultParams() return &GenesisState{ - - Params: DefaultParams(), + Params: []*Params{&p}, } } // Validate performs basic genesis state validation returning an error upon any // failure. func (gs GenesisState) Validate() error { + if len(gs.Params) == 0 { + return fmt.Errorf("params cannot be empty") + } + + // TODO: add validation to other properties of genstate. + for _, params := range gs.Params { + if err := params.Validate(); err != nil { + return err + } + } + return nil +} + +// GenesisStateFromAppState returns x/btcstaking GenesisState given raw application +// genesis state. +func GenesisStateFromAppState(cdc codec.Codec, appState map[string]json.RawMessage) GenesisState { + var genesisState GenesisState + + if appState[ModuleName] != nil { + cdc.MustUnmarshalJSON(appState[ModuleName], &genesisState) + } - return gs.Params.Validate() + return genesisState } diff --git a/x/btcstaking/types/genesis.pb.go b/x/btcstaking/types/genesis.pb.go index 2ccb1d1d9..3994319ac 100644 --- a/x/btcstaking/types/genesis.pb.go +++ b/x/btcstaking/types/genesis.pb.go @@ -5,6 +5,7 @@ package types import ( fmt "fmt" + github_com_babylonlabs_io_babylon_types "github.com/babylonlabs-io/babylon/types" _ "github.com/cosmos/gogoproto/gogoproto" proto "github.com/cosmos/gogoproto/proto" io "io" @@ -25,7 +26,23 @@ const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package // GenesisState defines the btcstaking module's genesis state. type GenesisState struct { - Params Params `protobuf:"bytes,1,opt,name=params,proto3" json:"params"` + // different versions of params used through the history of the chain + Params []*Params `protobuf:"bytes,1,rep,name=params,proto3" json:"params,omitempty"` + // finality_providers all the finality providers registered. + 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{} } @@ -61,15 +78,351 @@ func (m *GenesisState) XXX_DiscardUnknown() { var xxx_messageInfo_GenesisState proto.InternalMessageInfo -func (m *GenesisState) GetParams() Params { +func (m *GenesisState) GetParams() []*Params { if m != nil { return m.Params } - return Params{} + return nil +} + +func (m *GenesisState) GetFinalityProviders() []*FinalityProvider { + if m != nil { + return m.FinalityProviders + } + return nil +} + +func (m *GenesisState) GetBtcDelegations() []*BTCDelegation { + if m != nil { + return m.BtcDelegations + } + 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 + } + return nil +} + +func (m *GenesisState) GetBtcDelegators() []*BTCDelegator { + if m != nil { + return m.BtcDelegators + } + return nil +} + +func (m *GenesisState) GetEvents() []*EventIndex { + if m != nil { + return m.Events + } + 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"` +} + +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} +} +func (m *BlockHeightBbnToBtc) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *BlockHeightBbnToBtc) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_BlockHeightBbnToBtc.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 *BlockHeightBbnToBtc) XXX_Merge(src proto.Message) { + xxx_messageInfo_BlockHeightBbnToBtc.Merge(m, src) +} +func (m *BlockHeightBbnToBtc) XXX_Size() int { + return m.Size() +} +func (m *BlockHeightBbnToBtc) XXX_DiscardUnknown() { + xxx_messageInfo_BlockHeightBbnToBtc.DiscardUnknown(m) +} + +var xxx_messageInfo_BlockHeightBbnToBtc proto.InternalMessageInfo + +func (m *BlockHeightBbnToBtc) GetBlockHeightBbn() uint64 { + if m != nil { + return m.BlockHeightBbn + } + return 0 +} + +func (m *BlockHeightBbnToBtc) GetBlockHeightBtc() uint64 { + if m != nil { + return m.BlockHeightBtc + } + return 0 +} + +// BTCDelegator BTC delegator information with the associated finality provider. +type BTCDelegator struct { + // idx the btc delegator index. + Idx *BTCDelegatorDelegationIndex `protobuf:"bytes,1,opt,name=idx,proto3" json:"idx,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"` + // del_btc_pk the delegator btc public key. + DelBtcPk *github_com_babylonlabs_io_babylon_types.BIP340PubKey `protobuf:"bytes,3,opt,name=del_btc_pk,json=delBtcPk,proto3,customtype=github.com/babylonlabs-io/babylon/types.BIP340PubKey" json:"del_btc_pk,omitempty"` +} + +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} +} +func (m *BTCDelegator) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *BTCDelegator) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_BTCDelegator.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 *BTCDelegator) XXX_Merge(src proto.Message) { + xxx_messageInfo_BTCDelegator.Merge(m, src) +} +func (m *BTCDelegator) XXX_Size() int { + return m.Size() +} +func (m *BTCDelegator) XXX_DiscardUnknown() { + xxx_messageInfo_BTCDelegator.DiscardUnknown(m) +} + +var xxx_messageInfo_BTCDelegator proto.InternalMessageInfo + +func (m *BTCDelegator) GetIdx() *BTCDelegatorDelegationIndex { + if m != nil { + return m.Idx + } + return nil +} + +// EventIndex contains the event and its index. +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"` + // event the event stored. + Event *EventPowerDistUpdate `protobuf:"bytes,3,opt,name=event,proto3" json:"event,omitempty"` +} + +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} +} +func (m *EventIndex) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *EventIndex) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_EventIndex.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 *EventIndex) XXX_Merge(src proto.Message) { + xxx_messageInfo_EventIndex.Merge(m, src) +} +func (m *EventIndex) XXX_Size() int { + return m.Size() +} +func (m *EventIndex) XXX_DiscardUnknown() { + xxx_messageInfo_EventIndex.DiscardUnknown(m) +} + +var xxx_messageInfo_EventIndex proto.InternalMessageInfo + +func (m *EventIndex) GetIdx() uint64 { + if m != nil { + return m.Idx + } + return 0 +} + +func (m *EventIndex) GetBlockHeightBtc() uint64 { + if m != nil { + return m.BlockHeightBtc + } + return 0 +} + +func (m *EventIndex) GetEvent() *EventPowerDistUpdate { + if m != nil { + return m.Event + } + return nil } 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") } func init() { @@ -77,20 +430,51 @@ func init() { } var fileDescriptor_85d7b95fa5620238 = []byte{ - // 202 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x52, 0x4e, 0x4a, 0x4c, 0xaa, - 0xcc, 0xc9, 0xcf, 0xd3, 0x4f, 0x2a, 0x49, 0x2e, 0x2e, 0x49, 0xcc, 0xce, 0xcc, 0x4b, 0xd7, 0x2f, - 0x33, 0xd4, 0x4f, 0x4f, 0xcd, 0x4b, 0x2d, 0xce, 0x2c, 0xd6, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, - 0x12, 0x85, 0x2a, 0xd2, 0x43, 0x28, 0xd2, 0x2b, 0x33, 0x94, 0x12, 0x49, 0xcf, 0x4f, 0xcf, 0x07, - 0xab, 0xd0, 0x07, 0xb1, 0x20, 0x8a, 0xa5, 0x94, 0xb0, 0x9b, 0x58, 0x90, 0x58, 0x94, 0x98, 0x0b, - 0x35, 0x50, 0xc9, 0x9b, 0x8b, 0xc7, 0x1d, 0x62, 0x43, 0x70, 0x49, 0x62, 0x49, 0xaa, 0x90, 0x35, - 0x17, 0x1b, 0x44, 0x5e, 0x82, 0x51, 0x81, 0x51, 0x83, 0xdb, 0x48, 0x56, 0x0f, 0xab, 0x8d, 0x7a, - 0x01, 0x60, 0x45, 0x4e, 0x2c, 0x27, 0xee, 0xc9, 0x33, 0x04, 0x41, 0xb5, 0x38, 0xf9, 0x9c, 0x78, - 0x24, 0xc7, 0x78, 0xe1, 0x91, 0x1c, 0xe3, 0x83, 0x47, 0x72, 0x8c, 0x13, 0x1e, 0xcb, 0x31, 0x5c, - 0x78, 0x2c, 0xc7, 0x70, 0xe3, 0xb1, 0x1c, 0x43, 0x94, 0x51, 0x7a, 0x66, 0x49, 0x46, 0x69, 0x92, - 0x5e, 0x72, 0x7e, 0xae, 0x3e, 0xd4, 0xc0, 0xe4, 0x8c, 0xc4, 0xcc, 0x3c, 0x18, 0x47, 0xbf, 0x02, - 0xd9, 0x91, 0x25, 0x95, 0x05, 0xa9, 0xc5, 0x49, 0x6c, 0x60, 0x17, 0x1a, 0x03, 0x02, 0x00, 0x00, - 0xff, 0xff, 0x64, 0xf3, 0x4d, 0xdf, 0x19, 0x01, 0x00, 0x00, + // 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, 0x2c, 0x30, 0x68, 0xd2, 0x90, 0xb0, 0xc2, 0xe2, 0x9f, + 0x8d, 0xc6, 0xae, 0x2c, 0x98, 0xe8, 0xd1, 0xb2, 0xa2, 0x68, 0x34, 0x4d, 0xc5, 0x3d, 0x70, 0x69, + 0x3a, 0xed, 0x6c, 0x77, 0xb2, 0x65, 0xa6, 0xe9, 0x0c, 0x95, 0xbd, 0x7a, 0xf5, 0xe2, 0xd1, 0xef, + 0xe0, 0x17, 0xf1, 0xc8, 0xd1, 0x78, 0x30, 0x06, 0xbe, 0x81, 0x9f, 0xc0, 0x74, 0x5a, 0x68, 0xc1, + 0x5d, 0x58, 0x63, 0xbc, 0x75, 0x26, 0xcf, 0xfb, 0x9b, 0xf7, 0x79, 0xe7, 0x99, 0x14, 0xac, 0x21, + 0x1b, 0x0d, 0x7c, 0x46, 0x9b, 0x48, 0x38, 0x5c, 0xd8, 0x7d, 0x42, 0xbd, 0x66, 0xb4, 0xde, 0xf4, + 0x30, 0xc5, 0x9c, 0x70, 0x2d, 0x08, 0x99, 0x60, 0xf0, 0x46, 0x2a, 0xd2, 0x32, 0x91, 0x16, 0xad, + 0x2f, 0x5d, 0xf7, 0x98, 0xc7, 0xa4, 0xa2, 0x19, 0x7f, 0x25, 0xe2, 0xa5, 0xfa, 0x70, 0x62, 0x60, + 0x87, 0xf6, 0x7e, 0x0a, 0x5c, 0xba, 0x33, 0x5c, 0x93, 0xc3, 0x27, 0xba, 0xdb, 0xc3, 0x75, 0x84, + 0x3a, 0x98, 0x0a, 0x12, 0xe1, 0xcb, 0x8f, 0xc4, 0x11, 0xa6, 0x22, 0x3d, 0xb2, 0xfe, 0xab, 0x08, + 0x2a, 0xcf, 0x13, 0x57, 0x6f, 0x85, 0x2d, 0x30, 0x7c, 0x04, 0x4a, 0x49, 0x4f, 0xaa, 0xb2, 0x52, + 0x68, 0x94, 0x5b, 0xcb, 0xda, 0x50, 0x97, 0x9a, 0x21, 0x45, 0x66, 0x2a, 0x86, 0x1d, 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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f, 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, } func (m *GenesisState) Marshal() (dAtA []byte, err error) { @@ -113,48 +497,1302 @@ func (m *GenesisState) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l - { - size, err := m.Params.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err + 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-- { + { + size, err := m.Events[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintGenesis(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x3a + } + } + if len(m.BtcDelegators) > 0 { + for iNdEx := len(m.BtcDelegators) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.BtcDelegators[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintGenesis(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x32 + } + } + if len(m.BlockHeightChains) > 0 { + for iNdEx := len(m.BlockHeightChains) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.BlockHeightChains[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintGenesis(dAtA, i, uint64(size)) + } + i-- + 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-- { + { + size, err := m.BtcDelegations[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintGenesis(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x1a + } + } + 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 = encodeVarintGenesis(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + } + } + if len(m.Params) > 0 { + for iNdEx := len(m.Params) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.Params[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintGenesis(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + } + } + 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) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *BlockHeightBbnToBtc) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *BlockHeightBbnToBtc) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.BlockHeightBtc != 0 { + i = encodeVarintGenesis(dAtA, i, uint64(m.BlockHeightBtc)) + i-- + dAtA[i] = 0x10 + } + if m.BlockHeightBbn != 0 { + i = encodeVarintGenesis(dAtA, i, uint64(m.BlockHeightBbn)) + i-- + dAtA[i] = 0x8 + } + return len(dAtA) - i, nil +} + +func (m *BTCDelegator) 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 *BTCDelegator) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *BTCDelegator) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.DelBtcPk != nil { + { + size := m.DelBtcPk.Size() + i -= size + if _, err := m.DelBtcPk.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintGenesis(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x1a + } + 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.Idx != nil { + { + size, err := m.Idx.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintGenesis(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *EventIndex) 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 *EventIndex) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *EventIndex) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.Event != nil { + { + size, err := m.Event.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintGenesis(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x1a + } + if m.BlockHeightBtc != 0 { + i = encodeVarintGenesis(dAtA, i, uint64(m.BlockHeightBtc)) + i-- + dAtA[i] = 0x10 + } + if m.Idx != 0 { + i = encodeVarintGenesis(dAtA, i, uint64(m.Idx)) + i-- + dAtA[i] = 0x8 + } + 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 + if len(m.Params) > 0 { + for _, e := range m.Params { + l = e.Size() + n += 1 + l + sovGenesis(uint64(l)) + } + } + if len(m.FinalityProviders) > 0 { + for _, e := range m.FinalityProviders { + l = e.Size() + n += 1 + l + sovGenesis(uint64(l)) + } + } + if len(m.BtcDelegations) > 0 { + for _, e := range m.BtcDelegations { + l = e.Size() + 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() + n += 1 + l + sovGenesis(uint64(l)) + } + } + if len(m.BtcDelegators) > 0 { + for _, e := range m.BtcDelegators { + l = e.Size() + n += 1 + l + sovGenesis(uint64(l)) + } + } + if len(m.Events) > 0 { + for _, e := range m.Events { + 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 +} + +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 (m *BlockHeightBbnToBtc) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.BlockHeightBbn != 0 { + n += 1 + sovGenesis(uint64(m.BlockHeightBbn)) + } + if m.BlockHeightBtc != 0 { + n += 1 + sovGenesis(uint64(m.BlockHeightBtc)) + } + return n +} + +func (m *BTCDelegator) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.Idx != nil { + l = m.Idx.Size() + n += 1 + l + sovGenesis(uint64(l)) + } + if m.FpBtcPk != nil { + l = m.FpBtcPk.Size() + n += 1 + l + sovGenesis(uint64(l)) + } + if m.DelBtcPk != nil { + l = m.DelBtcPk.Size() + n += 1 + l + sovGenesis(uint64(l)) + } + return n +} + +func (m *EventIndex) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.Idx != 0 { + n += 1 + sovGenesis(uint64(m.Idx)) + } + if m.BlockHeightBtc != 0 { + n += 1 + sovGenesis(uint64(m.BlockHeightBtc)) + } + if m.Event != nil { + l = m.Event.Size() + 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 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 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.Params = append(m.Params, &Params{}) + if err := m.Params[len(m.Params)-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 FinalityProviders", 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.FinalityProviders = append(m.FinalityProviders, &FinalityProvider{}) + if err := m.FinalityProviders[len(m.FinalityProviders)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field BtcDelegations", 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.BtcDelegations = append(m.BtcDelegations, &BTCDelegation{}) + if err := m.BtcDelegations[len(m.BtcDelegations)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + 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) + } + 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.BlockHeightChains = append(m.BlockHeightChains, &BlockHeightBbnToBtc{}) + if err := m.BlockHeightChains[len(m.BlockHeightChains)-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 BtcDelegators", 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.BtcDelegators = append(m.BtcDelegators, &BTCDelegator{}) + if err := m.BtcDelegators[len(m.BtcDelegators)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 7: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Events", 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.Events = append(m.Events, &EventIndex{}) + if err := m.Events[len(m.Events)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + 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:]) + 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 *BlockHeightBbnToBtc) 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: BlockHeightBbnToBtc: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: BlockHeightBbnToBtc: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field BlockHeightBbn", wireType) + } + m.BlockHeightBbn = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenesis + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.BlockHeightBbn |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 2: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field BlockHeightBtc", wireType) + } + m.BlockHeightBtc = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenesis + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.BlockHeightBtc |= 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 } - i -= size - i = encodeVarintGenesis(dAtA, i, uint64(size)) } - i-- - dAtA[i] = 0xa - 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++ + if iNdEx > l { + return io.ErrUnexpectedEOF } - dAtA[offset] = uint8(v) - return base + return nil } -func (m *GenesisState) Size() (n int) { - if m == nil { - return 0 +func (m *BTCDelegator) 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: BTCDelegator: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: BTCDelegator: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Idx", 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.Idx == nil { + m.Idx = &BTCDelegatorDelegationIndex{} + } + if err := m.Idx.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + 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 != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field DelBtcPk", 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.DelBtcPk = &v + if err := m.DelBtcPk.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 + } } - var l int - _ = l - l = m.Params.Size() - 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)))) + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil } -func (m *GenesisState) Unmarshal(dAtA []byte) error { +func (m *EventIndex) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -177,15 +1815,53 @@ func (m *GenesisState) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: GenesisState: wiretype end group for non-group") + return fmt.Errorf("proto: EventIndex: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: GenesisState: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: EventIndex: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Idx", wireType) + } + m.Idx = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenesis + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Idx |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 2: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field BlockHeightBtc", wireType) + } + m.BlockHeightBtc = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenesis + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.BlockHeightBtc |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 3: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Params", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field Event", wireType) } var msglen int for shift := uint(0); ; shift += 7 { @@ -212,7 +1888,10 @@ func (m *GenesisState) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - if err := m.Params.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + if m.Event == nil { + m.Event = &EventPowerDistUpdate{} + } + if err := m.Event.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } iNdEx = postIndex diff --git a/x/btcstaking/types/genesis_test.go b/x/btcstaking/types/genesis_test.go index 00ee5d73d..8e1720227 100644 --- a/x/btcstaking/types/genesis_test.go +++ b/x/btcstaking/types/genesis_test.go @@ -5,7 +5,7 @@ import ( sdkmath "cosmossdk.io/math" - "github.com/babylonchain/babylon/x/btcstaking/types" + "github.com/babylonlabs-io/babylon/x/btcstaking/types" "github.com/stretchr/testify/require" ) @@ -23,7 +23,7 @@ func TestGenesisState_Validate(t *testing.T) { { desc: "valid genesis state", genState: &types.GenesisState{ - Params: types.Params{ + Params: []*types.Params{&types.Params{ CovenantPks: types.DefaultParams().CovenantPks, CovenantQuorum: types.DefaultParams().CovenantQuorum, SlashingAddress: types.DefaultParams().SlashingAddress, @@ -31,14 +31,15 @@ func TestGenesisState_Validate(t *testing.T) { MinCommissionRate: sdkmath.LegacyMustNewDecFromStr("0.5"), SlashingRate: sdkmath.LegacyMustNewDecFromStr("0.1"), MaxActiveFinalityProviders: 100, - }, + MinUnbondingRate: sdkmath.LegacyMustNewDecFromStr("0.8"), + }}, }, valid: true, }, { desc: "invalid slashing rate in genesis", genState: &types.GenesisState{ - Params: types.Params{ + Params: []*types.Params{&types.Params{ CovenantPks: types.DefaultParams().CovenantPks, CovenantQuorum: types.DefaultParams().CovenantQuorum, SlashingAddress: types.DefaultParams().SlashingAddress, @@ -46,8 +47,25 @@ func TestGenesisState_Validate(t *testing.T) { MinCommissionRate: sdkmath.LegacyMustNewDecFromStr("0.5"), SlashingRate: sdkmath.LegacyZeroDec(), // invalid slashing rate MaxActiveFinalityProviders: 100, + MinUnbondingRate: sdkmath.LegacyMustNewDecFromStr("0.8"), }, - }, + }}, + valid: false, + }, + { + desc: "invalid unbonding value in genesis", + genState: &types.GenesisState{ + Params: []*types.Params{&types.Params{ + CovenantPks: types.DefaultParams().CovenantPks, + CovenantQuorum: types.DefaultParams().CovenantQuorum, + SlashingAddress: types.DefaultParams().SlashingAddress, + MinSlashingTxFeeSat: 500, + MinCommissionRate: sdkmath.LegacyMustNewDecFromStr("0.5"), + SlashingRate: sdkmath.LegacyMustNewDecFromStr("0.1"), + MaxActiveFinalityProviders: 100, + MinUnbondingRate: sdkmath.LegacyZeroDec(), + }, + }}, valid: false, }, } diff --git a/x/btcstaking/types/hooks.go b/x/btcstaking/types/hooks.go new file mode 100644 index 000000000..89307fe1e --- /dev/null +++ b/x/btcstaking/types/hooks.go @@ -0,0 +1,26 @@ +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.go b/x/btcstaking/types/incentive.go index 422c55227..7dd020896 100644 --- a/x/btcstaking/types/incentive.go +++ b/x/btcstaking/types/incentive.go @@ -5,45 +5,98 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" ) -func NewRewardDistCache() *RewardDistCache { - return &RewardDistCache{ +func NewVotingPowerDistCache() *VotingPowerDistCache { + return &VotingPowerDistCache{ TotalVotingPower: 0, FinalityProviders: []*FinalityProviderDistInfo{}, } } -func (rdc *RewardDistCache) AddFinalityProviderDistInfo(v *FinalityProviderDistInfo) { - if v.TotalVotingPower > 0 { - // append finality provider dist info and accumulate voting power - rdc.FinalityProviders = append(rdc.FinalityProviders, v) - rdc.TotalVotingPower += v.TotalVotingPower +func (dc *VotingPowerDistCache) Empty() bool { + return len(dc.FinalityProviders) == 0 +} + +func (dc *VotingPowerDistCache) AddFinalityProviderDistInfo(v *FinalityProviderDistInfo) { + dc.FinalityProviders = append(dc.FinalityProviders, v) +} + +func (dc *VotingPowerDistCache) FindNewActiveFinalityProviders(prevDc *VotingPowerDistCache, maxActiveFPs uint32) []*FinalityProviderDistInfo { + activeFps := dc.GetActiveFinalityProviderSet(maxActiveFPs) + prevActiveFps := prevDc.GetActiveFinalityProviderSet(maxActiveFPs) + newActiveFps := make([]*FinalityProviderDistInfo, 0) + + for pk, fp := range activeFps { + _, exists := prevActiveFps[pk] + if !exists { + newActiveFps = append(newActiveFps, fp) + } } + + return newActiveFps +} + +// ApplyActiveFinalityProviders sorts all finality providers, counts the total voting +// power of top N finality providers, and records them in cache +func (dc *VotingPowerDistCache) ApplyActiveFinalityProviders(maxActiveFPs uint32) { + // reset total voting power + dc.TotalVotingPower = 0 + // sort finality providers + SortFinalityProviders(dc.FinalityProviders) + // calculate voting power of top N finality providers + numActiveFPs := dc.GetNumActiveFPs(maxActiveFPs) + for i := uint32(0); i < numActiveFPs; i++ { + dc.TotalVotingPower += dc.FinalityProviders[i].TotalVotingPower + } +} + +func (dc *VotingPowerDistCache) GetNumActiveFPs(maxActiveFPs uint32) uint32 { + return min(maxActiveFPs, uint32(len(dc.FinalityProviders))) } -// FilterVotedFinalityProviders filters out finality providers that have voted according to a map of given voters -// and update total voted power accordingly -func (rdc *RewardDistCache) FilterVotedFinalityProviders(voterBTCPKs map[string]struct{}) { - filteredFps := []*FinalityProviderDistInfo{} +// GetActiveFinalityProviderSet returns a set of active finality providers +// keyed by the hex string of the finality provider's BTC public key +// i.e., top N of them in terms of voting power +func (dc *VotingPowerDistCache) GetActiveFinalityProviderSet(maxActiveFPs uint32) map[string]*FinalityProviderDistInfo { + numActiveFPs := dc.GetNumActiveFPs(maxActiveFPs) + + activeFps := make(map[string]*FinalityProviderDistInfo) + + for _, fp := range dc.FinalityProviders[:numActiveFPs] { + activeFps[fp.BtcPk.MarshalHex()] = fp + } + + 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(maxActiveFPs uint32, voterBTCPKs map[string]struct{}) *VotingPowerDistCache { + activeFPs := dc.GetActiveFinalityProviderSet(maxActiveFPs) + var filteredFps []*FinalityProviderDistInfo totalVotingPower := uint64(0) - for _, v := range rdc.FinalityProviders { - if _, ok := voterBTCPKs[v.BtcPk.MarshalHex()]; ok { + for k, v := range activeFPs { + if _, ok := voterBTCPKs[k]; ok { filteredFps = append(filteredFps, v) totalVotingPower += v.TotalVotingPower } } - rdc.FinalityProviders = filteredFps - rdc.TotalVotingPower = totalVotingPower + + return &VotingPowerDistCache{ + FinalityProviders: filteredFps, + TotalVotingPower: totalVotingPower, + } } // GetFinalityProviderPortion returns the portion of a finality provider's voting power out of the total voting power -func (rdc *RewardDistCache) GetFinalityProviderPortion(v *FinalityProviderDistInfo) sdkmath.LegacyDec { - return sdkmath.LegacyNewDec(int64(v.TotalVotingPower)).QuoTruncate(sdkmath.LegacyNewDec(int64(rdc.TotalVotingPower))) +func (dc *VotingPowerDistCache) GetFinalityProviderPortion(v *FinalityProviderDistInfo) sdkmath.LegacyDec { + return sdkmath.LegacyNewDec(int64(v.TotalVotingPower)).QuoTruncate(sdkmath.LegacyNewDec(int64(dc.TotalVotingPower))) } func NewFinalityProviderDistInfo(fp *FinalityProvider) *FinalityProviderDistInfo { return &FinalityProviderDistInfo{ BtcPk: fp.BtcPk, - BabylonPk: fp.BabylonPk, + Addr: fp.Addr, Commission: fp.Commission, TotalVotingPower: 0, BtcDels: []*BTCDelDistInfo{}, @@ -51,28 +104,23 @@ func NewFinalityProviderDistInfo(fp *FinalityProvider) *FinalityProviderDistInfo } func (v *FinalityProviderDistInfo) GetAddress() sdk.AccAddress { - return sdk.AccAddress(v.BabylonPk.Address()) + return sdk.MustAccAddressFromBech32(v.Addr) } -func (v *FinalityProviderDistInfo) AddBTCDel(btcDel *BTCDelegation, btcHeight uint64, wValue uint64, covenantQuorum uint32) { +func (v *FinalityProviderDistInfo) AddBTCDel(btcDel *BTCDelegation) { btcDelDistInfo := &BTCDelDistInfo{ - BabylonPk: btcDel.BabylonPk, - VotingPower: btcDel.VotingPower(btcHeight, wValue, covenantQuorum), - } - - if btcDelDistInfo.VotingPower > 0 { - // if this BTC delegation has voting power, append it and accumulate voting power - v.BtcDels = append(v.BtcDels, btcDelDistInfo) - v.TotalVotingPower += btcDelDistInfo.VotingPower + BtcPk: btcDel.BtcPk, + StakerAddr: btcDel.StakerAddr, + StakingTxHash: btcDel.MustGetStakingTxHash().String(), + VotingPower: btcDel.TotalSat, } + v.BtcDels = append(v.BtcDels, btcDelDistInfo) + v.TotalVotingPower += btcDelDistInfo.VotingPower } -func (v *FinalityProviderDistInfo) AddBTCDistInfo(info *BTCDelDistInfo) { - if info.VotingPower > 0 { - // if this BTC delegation has voting power, append it and accumulate voting power - v.BtcDels = append(v.BtcDels, info) - v.TotalVotingPower += info.VotingPower - } +func (v *FinalityProviderDistInfo) AddBTCDelDistInfo(d *BTCDelDistInfo) { + v.BtcDels = append(v.BtcDels, d) + v.TotalVotingPower += d.VotingPower } // GetBTCDelPortion returns the portion of a BTC delegation's voting power out of @@ -82,5 +130,5 @@ func (v *FinalityProviderDistInfo) GetBTCDelPortion(d *BTCDelDistInfo) sdkmath.L } func (d *BTCDelDistInfo) GetAddress() sdk.AccAddress { - return sdk.AccAddress(d.BabylonPk.Address()) + return sdk.MustAccAddressFromBech32(d.StakerAddr) } diff --git a/x/btcstaking/types/incentive.pb.go b/x/btcstaking/types/incentive.pb.go index 2ecf02d12..e1234e074 100644 --- a/x/btcstaking/types/incentive.pb.go +++ b/x/btcstaking/types/incentive.pb.go @@ -6,9 +6,8 @@ package types import ( cosmossdk_io_math "cosmossdk.io/math" fmt "fmt" - github_com_babylonchain_babylon_types "github.com/babylonchain/babylon/types" + github_com_babylonlabs_io_babylon_types "github.com/babylonlabs-io/babylon/types" _ "github.com/cosmos/cosmos-proto" - secp256k1 "github.com/cosmos/cosmos-sdk/crypto/keys/secp256k1" _ "github.com/cosmos/gogoproto/gogoproto" proto "github.com/cosmos/gogoproto/proto" io "io" @@ -27,25 +26,26 @@ var _ = math.Inf // proto package needs to be updated. const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package -// RewardDistCache is the cache for reward distribution of finality providers at a height -type RewardDistCache struct { +// VotingPowerDistCache is the cache for voting power distribution of finality providers +// and their BTC delegations at a height +type VotingPowerDistCache struct { 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"` } -func (m *RewardDistCache) Reset() { *m = RewardDistCache{} } -func (m *RewardDistCache) String() string { return proto.CompactTextString(m) } -func (*RewardDistCache) ProtoMessage() {} -func (*RewardDistCache) Descriptor() ([]byte, []int) { +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 *RewardDistCache) XXX_Unmarshal(b []byte) error { +func (m *VotingPowerDistCache) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } -func (m *RewardDistCache) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { +func (m *VotingPowerDistCache) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { - return xxx_messageInfo_RewardDistCache.Marshal(b, m, deterministic) + return xxx_messageInfo_VotingPowerDistCache.Marshal(b, m, deterministic) } else { b = b[:cap(b)] n, err := m.MarshalToSizedBuffer(b) @@ -55,26 +55,26 @@ func (m *RewardDistCache) XXX_Marshal(b []byte, deterministic bool) ([]byte, err return b[:n], nil } } -func (m *RewardDistCache) XXX_Merge(src proto.Message) { - xxx_messageInfo_RewardDistCache.Merge(m, src) +func (m *VotingPowerDistCache) XXX_Merge(src proto.Message) { + xxx_messageInfo_VotingPowerDistCache.Merge(m, src) } -func (m *RewardDistCache) XXX_Size() int { +func (m *VotingPowerDistCache) XXX_Size() int { return m.Size() } -func (m *RewardDistCache) XXX_DiscardUnknown() { - xxx_messageInfo_RewardDistCache.DiscardUnknown(m) +func (m *VotingPowerDistCache) XXX_DiscardUnknown() { + xxx_messageInfo_VotingPowerDistCache.DiscardUnknown(m) } -var xxx_messageInfo_RewardDistCache proto.InternalMessageInfo +var xxx_messageInfo_VotingPowerDistCache proto.InternalMessageInfo -func (m *RewardDistCache) GetTotalVotingPower() uint64 { +func (m *VotingPowerDistCache) GetTotalVotingPower() uint64 { if m != nil { return m.TotalVotingPower } return 0 } -func (m *RewardDistCache) GetFinalityProviders() []*FinalityProviderDistInfo { +func (m *VotingPowerDistCache) GetFinalityProviders() []*FinalityProviderDistInfo { if m != nil { return m.FinalityProviders } @@ -85,9 +85,9 @@ func (m *RewardDistCache) GetFinalityProviders() []*FinalityProviderDistInfo { 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_babylonchain_babylon_types.BIP340PubKey `protobuf:"bytes,1,opt,name=btc_pk,json=btcPk,proto3,customtype=github.com/babylonchain/babylon/types.BIP340PubKey" json:"btc_pk,omitempty"` - // babylon_pk is the Babylon public key of the finality provider - BabylonPk *secp256k1.PubKey `protobuf:"bytes,2,opt,name=babylon_pk,json=babylonPk,proto3" json:"babylon_pk,omitempty"` + 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 @@ -129,11 +129,11 @@ func (m *FinalityProviderDistInfo) XXX_DiscardUnknown() { var xxx_messageInfo_FinalityProviderDistInfo proto.InternalMessageInfo -func (m *FinalityProviderDistInfo) GetBabylonPk() *secp256k1.PubKey { +func (m *FinalityProviderDistInfo) GetAddr() string { if m != nil { - return m.BabylonPk + return m.Addr } - return nil + return "" } func (m *FinalityProviderDistInfo) GetTotalVotingPower() uint64 { @@ -150,12 +150,17 @@ func (m *FinalityProviderDistInfo) GetBtcDels() []*BTCDelDistInfo { return nil } -// BTCDelDistInfo contains the information related to reward distribution for a BTC delegations +// BTCDelDistInfo contains the information related to reward distribution for a BTC delegation type BTCDelDistInfo struct { - // babylon_pk is the Babylon public key of the BTC delegations - BabylonPk *secp256k1.PubKey `protobuf:"bytes,1,opt,name=babylon_pk,json=babylonPk,proto3" json:"babylon_pk,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,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,2,opt,name=voting_power,json=votingPower,proto3" json:"voting_power,omitempty"` + VotingPower uint64 `protobuf:"varint,4,opt,name=voting_power,json=votingPower,proto3" json:"voting_power,omitempty"` } func (m *BTCDelDistInfo) Reset() { *m = BTCDelDistInfo{} } @@ -191,11 +196,18 @@ func (m *BTCDelDistInfo) XXX_DiscardUnknown() { var xxx_messageInfo_BTCDelDistInfo proto.InternalMessageInfo -func (m *BTCDelDistInfo) GetBabylonPk() *secp256k1.PubKey { +func (m *BTCDelDistInfo) GetStakerAddr() string { if m != nil { - return m.BabylonPk + return m.StakerAddr } - return nil + return "" +} + +func (m *BTCDelDistInfo) GetStakingTxHash() string { + if m != nil { + return m.StakingTxHash + } + return "" } func (m *BTCDelDistInfo) GetVotingPower() uint64 { @@ -206,7 +218,7 @@ func (m *BTCDelDistInfo) GetVotingPower() uint64 { } func init() { - proto.RegisterType((*RewardDistCache)(nil), "babylon.btcstaking.v1.RewardDistCache") + proto.RegisterType((*VotingPowerDistCache)(nil), "babylon.btcstaking.v1.VotingPowerDistCache") proto.RegisterType((*FinalityProviderDistInfo)(nil), "babylon.btcstaking.v1.FinalityProviderDistInfo") proto.RegisterType((*BTCDelDistInfo)(nil), "babylon.btcstaking.v1.BTCDelDistInfo") } @@ -216,41 +228,42 @@ func init() { } var fileDescriptor_ac354c3bd6d7a66b = []byte{ - // 491 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94, 0x93, 0xcb, 0x6e, 0xd3, 0x40, - 0x14, 0x86, 0xe3, 0xf4, 0x02, 0x9d, 0x54, 0x5c, 0x2c, 0x90, 0x4c, 0x91, 0x9c, 0x10, 0xa9, 0x52, - 0x16, 0x74, 0x86, 0xa4, 0xd0, 0x25, 0x42, 0xae, 0x85, 0x54, 0xd1, 0x4a, 0x96, 0x85, 0x58, 0xb0, - 0x20, 0x9a, 0x99, 0x4c, 0x9c, 0x91, 0xed, 0x19, 0xcb, 0x33, 0x75, 0xf1, 0x5b, 0xf0, 0x06, 0xbc, - 0x04, 0x0f, 0xc1, 0xb2, 0x62, 0x85, 0xba, 0xa8, 0x50, 0xb2, 0xe1, 0x31, 0x90, 0xed, 0xa1, 0x37, - 0x11, 0xa1, 0xee, 0x72, 0xf2, 0xff, 0xe7, 0x9c, 0xdf, 0xdf, 0xb1, 0xc1, 0x36, 0xc1, 0xa4, 0x4c, - 0xa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0xb8, 0xad, 0x8f, 0xff, - 0x3d, 0xe4, 0xe7, 0xab, 0x1f, 0x52, 0x7d, 0x55, 0xb2, 0x5e, 0xbf, 0xd6, 0xbb, 0x7f, 0x02, 0x00, - 0x00, 0xff, 0xff, 0xef, 0xcd, 0x33, 0x90, 0x6b, 0x03, 0x00, 0x00, -} - -func (m *RewardDistCache) Marshal() (dAtA []byte, err error) { + // 504 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x93, 0x4f, 0x6f, 0xd3, 0x30, + 0x18, 0xc6, 0x9b, 0xae, 0x1b, 0xe0, 0x8e, 0x7f, 0x56, 0x91, 0xc2, 0x90, 0xb2, 0x52, 0x69, 0xa8, + 0x87, 0x35, 0x61, 0x6c, 0x07, 0xb8, 0x41, 0x16, 0x21, 0x26, 0xfe, 0x45, 0x61, 0xe2, 0xc0, 0x81, + 0xc8, 0x76, 0xdc, 0xc4, 0x6a, 0x12, 0x57, 0xb1, 0x17, 0x9a, 0x6f, 0xc1, 0x87, 0xe0, 0x23, 0xec, + 0x43, 0x70, 0x9c, 0x76, 0x9a, 0x76, 0x98, 0x50, 0x7b, 0xe0, 0x6b, 0xa0, 0x38, 0x81, 0x15, 0xb4, + 0x4a, 0x3d, 0x70, 0xb3, 0xfd, 0x3c, 0xaf, 0xdf, 0xf7, 0xf9, 0x49, 0x2f, 0xd8, 0xc2, 0x08, 0x17, + 0x31, 0x4f, 0x2d, 0x2c, 0x89, 0x90, 0x68, 0xc4, 0xd2, 0xd0, 0xca, 0x77, 0x2c, 0x96, 0x12, 0x9a, + 0x4a, 0x96, 0x53, 0x73, 0x9c, 0x71, 0xc9, 0xe1, 0xbd, 0xda, 0x66, 0x5e, 0xda, 0xcc, 0x7c, 0x67, + 0xa3, 0x13, 0xf2, 0x90, 0x2b, 0x87, 0x55, 0x9e, 0x2a, 0xf3, 0xc6, 0x7d, 0xc2, 0x45, 0xc2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*VotingPowerDistCache) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalToSizedBuffer(dAtA[:size]) @@ -260,12 +273,12 @@ func (m *RewardDistCache) Marshal() (dAtA []byte, err error) { return dAtA[:n], nil } -func (m *RewardDistCache) MarshalTo(dAtA []byte) (int, error) { +func (m *VotingPowerDistCache) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *RewardDistCache) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *VotingPowerDistCache) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) _ = i var l int @@ -343,15 +356,10 @@ func (m *FinalityProviderDistInfo) MarshalToSizedBuffer(dAtA []byte) (int, error i-- dAtA[i] = 0x1a } - if m.BabylonPk != nil { - { - size, err := m.BabylonPk.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintIncentive(dAtA, i, uint64(size)) - } + 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 } @@ -393,15 +401,29 @@ func (m *BTCDelDistInfo) MarshalToSizedBuffer(dAtA []byte) (int, error) { if m.VotingPower != 0 { i = encodeVarintIncentive(dAtA, i, uint64(m.VotingPower)) i-- - dAtA[i] = 0x10 + 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.BabylonPk != nil { + if m.BtcPk != nil { { - size, err := m.BabylonPk.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { + size := m.BtcPk.Size() + i -= size + if _, err := m.BtcPk.MarshalTo(dAtA[i:]); err != nil { return 0, err } - i -= size i = encodeVarintIncentive(dAtA, i, uint64(size)) } i-- @@ -421,7 +443,7 @@ func encodeVarintIncentive(dAtA []byte, offset int, v uint64) int { dAtA[offset] = uint8(v) return base } -func (m *RewardDistCache) Size() (n int) { +func (m *VotingPowerDistCache) Size() (n int) { if m == nil { return 0 } @@ -449,8 +471,8 @@ func (m *FinalityProviderDistInfo) Size() (n int) { l = m.BtcPk.Size() n += 1 + l + sovIncentive(uint64(l)) } - if m.BabylonPk != nil { - l = m.BabylonPk.Size() + l = len(m.Addr) + if l > 0 { n += 1 + l + sovIncentive(uint64(l)) } if m.Commission != nil { @@ -475,8 +497,16 @@ func (m *BTCDelDistInfo) Size() (n int) { } var l int _ = l - if m.BabylonPk != nil { - l = m.BabylonPk.Size() + 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 { @@ -491,7 +521,7 @@ func sovIncentive(x uint64) (n int) { func sozIncentive(x uint64) (n int) { return sovIncentive(uint64((x << 1) ^ uint64((int64(x) >> 63)))) } -func (m *RewardDistCache) Unmarshal(dAtA []byte) error { +func (m *VotingPowerDistCache) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -514,10 +544,10 @@ func (m *RewardDistCache) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: RewardDistCache: wiretype end group for non-group") + return fmt.Errorf("proto: VotingPowerDistCache: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: RewardDistCache: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: VotingPowerDistCache: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: @@ -652,7 +682,7 @@ func (m *FinalityProviderDistInfo) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - var v github_com_babylonchain_babylon_types.BIP340PubKey + var v github_com_babylonlabs_io_babylon_types.BIP340PubKey m.BtcPk = &v if err := m.BtcPk.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err @@ -660,9 +690,9 @@ func (m *FinalityProviderDistInfo) Unmarshal(dAtA []byte) error { iNdEx = postIndex case 2: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field BabylonPk", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field Addr", wireType) } - var msglen int + var stringLen uint64 for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowIncentive @@ -672,27 +702,23 @@ func (m *FinalityProviderDistInfo) 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 ErrInvalidLengthIncentive } - postIndex := iNdEx + msglen + postIndex := iNdEx + intStringLen if postIndex < 0 { return ErrInvalidLengthIncentive } if postIndex > l { return io.ErrUnexpectedEOF } - if m.BabylonPk == nil { - m.BabylonPk = &secp256k1.PubKey{} - } - if err := m.BabylonPk.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } + m.Addr = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex case 3: if wireType != 2 { @@ -835,9 +861,9 @@ func (m *BTCDelDistInfo) Unmarshal(dAtA []byte) error { switch fieldNum { case 1: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field BabylonPk", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field BtcPk", wireType) } - var msglen int + var byteLen int for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowIncentive @@ -847,29 +873,92 @@ func (m *BTCDelDistInfo) 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 ErrInvalidLengthIncentive } - postIndex := iNdEx + msglen + postIndex := iNdEx + byteLen if postIndex < 0 { return ErrInvalidLengthIncentive } if postIndex > l { return io.ErrUnexpectedEOF } - if m.BabylonPk == nil { - m.BabylonPk = &secp256k1.PubKey{} - } - if err := m.BabylonPk.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + 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) } diff --git a/x/btcstaking/types/keys.go b/x/btcstaking/types/keys.go index 4f291ad14..099e808cd 100644 --- a/x/btcstaking/types/keys.go +++ b/x/btcstaking/types/keys.go @@ -15,15 +15,12 @@ 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 - RewardDistCacheKey = []byte{0x07} // key prefix for reward distribution cache + 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 ) - -func KeyPrefix(p string) []byte { - return []byte(p) -} diff --git a/x/btcstaking/types/metrics.go b/x/btcstaking/types/metrics.go new file mode 100644 index 000000000..ab0cc699a --- /dev/null +++ b/x/btcstaking/types/metrics.go @@ -0,0 +1,91 @@ +package types + +import ( + "github.com/cosmos/cosmos-sdk/telemetry" + "github.com/hashicorp/go-metrics" +) + +// 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" +) + +// Metrics for monitoring finality providers and BTC delegations +const ( + // MetricsKeyFinalityProviders is the key of the gauge recording the number + // of {active, inactive} finality providers, and the key of the counter + // recording the number of slashed finality providers + MetricsKeyFinalityProviders = "finality_providers" + // MetricsKeyBTCDelegations is the key of the gauge recording the number of + // {pending, active, unbonded} BTC delegations, and the key of the counter + // recording the number of slashed BTC delegations + MetricsKeyBTCDelegations = "btc_delegations" + // MetricsKeyStakedBitcoins is the key of the gauge recording the total + // amount of Bitcoins staked under active finality providers + MetricsKeyStakedBitcoins = "staked_bitcoins" +) + +// RecordActiveFinalityProviders records the number of active finality providers. +// It is triggered upon recording voting power table. +func RecordActiveFinalityProviders(num int) { + keys := []string{MetricsKeyFinalityProviders, "ACTIVE"} + labels := []metrics.Label{telemetry.NewLabel(telemetry.MetricLabelNameModule, ModuleName)} + telemetry.SetGaugeWithLabels( + keys, + float32(num), + labels, + ) +} + +// RecordInactiveFinalityProviders records the number of inactive finality providers. +// It is triggered upon recording voting power table. +func RecordInactiveFinalityProviders(num int) { + keys := []string{MetricsKeyFinalityProviders, "INACTIVE"} + labels := []metrics.Label{telemetry.NewLabel(telemetry.MetricLabelNameModule, ModuleName)} + telemetry.SetGaugeWithLabels( + keys, + float32(num), + labels, + ) +} + +// RecordNewSlashedFinalityProvider increments the number of slashed finality providers. +// It is triggered upon a finality provider becomes slashed. +func RecordNewSlashedFinalityProvider() { + keys := []string{MetricsKeyFinalityProviders, "SLASHED"} + labels := []metrics.Label{telemetry.NewLabel(telemetry.MetricLabelNameModule, ModuleName)} + telemetry.IncrCounterWithLabels( + keys, + 1, + labels, + ) +} + +// RecordBTCDelegations records the number of BTC delegations under the given status. +// It is triggered upon recording voting power table. +func RecordBTCDelegations(num int, status BTCDelegationStatus) { + keys := []string{MetricsKeyBTCDelegations, status.String()} + labels := []metrics.Label{telemetry.NewLabel(telemetry.MetricLabelNameModule, ModuleName)} + telemetry.SetGaugeWithLabels( + keys, + float32(num), + labels, + ) +} + +// RecordMetricsKeyStakedBitcoins records the amount of Bitcoins staked under +// all active finality providers. +// It is triggered upon recording voting power table. +func RecordMetricsKeyStakedBitcoins(amount float32) { + keys := []string{MetricsKeyStakedBitcoins} + labels := []metrics.Label{telemetry.NewLabel(telemetry.MetricLabelNameModule, ModuleName)} + telemetry.SetGaugeWithLabels( + keys, + amount, + labels, + ) +} diff --git a/x/btcstaking/types/mocked_keepers.go b/x/btcstaking/types/mocked_keepers.go index 3ab694c07..d68d89080 100644 --- a/x/btcstaking/types/mocked_keepers.go +++ b/x/btcstaking/types/mocked_keepers.go @@ -9,9 +9,10 @@ import ( big "math/big" reflect "reflect" - types "github.com/babylonchain/babylon/types" - types0 "github.com/babylonchain/babylon/x/btccheckpoint/types" - types1 "github.com/babylonchain/babylon/x/btclightclient/types" + 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/babylonlabs-io/babylon/x/epoching/types" gomock "github.com/golang/mock/gomock" ) @@ -38,6 +39,20 @@ func (m *MockBTCLightClientKeeper) EXPECT() *MockBTCLightClientKeeperMockRecorde return m.recorder } +// GetBaseBTCHeader mocks base method. +func (m *MockBTCLightClientKeeper) GetBaseBTCHeader(ctx context.Context) *types1.BTCHeaderInfo { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "GetBaseBTCHeader", ctx) + ret0, _ := ret[0].(*types1.BTCHeaderInfo) + return ret0 +} + +// GetBaseBTCHeader indicates an expected call of GetBaseBTCHeader. +func (mr *MockBTCLightClientKeeperMockRecorder) GetBaseBTCHeader(ctx interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetBaseBTCHeader", reflect.TypeOf((*MockBTCLightClientKeeper)(nil).GetBaseBTCHeader), ctx) +} + // GetHeaderByHash mocks base method. func (m *MockBTCLightClientKeeper) GetHeaderByHash(ctx context.Context, hash *types.BTCHeaderHashBytes) *types1.BTCHeaderInfo { m.ctrl.T.Helper() @@ -116,3 +131,91 @@ func (mr *MockBtcCheckpointKeeperMockRecorder) GetPowLimit() *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetPowLimit", reflect.TypeOf((*MockBtcCheckpointKeeper)(nil).GetPowLimit)) } + +// MockCheckpointingKeeper is a mock of CheckpointingKeeper interface. +type MockCheckpointingKeeper struct { + ctrl *gomock.Controller + recorder *MockCheckpointingKeeperMockRecorder +} + +// MockCheckpointingKeeperMockRecorder is the mock recorder for MockCheckpointingKeeper. +type MockCheckpointingKeeperMockRecorder struct { + mock *MockCheckpointingKeeper +} + +// NewMockCheckpointingKeeper creates a new mock instance. +func NewMockCheckpointingKeeper(ctrl *gomock.Controller) *MockCheckpointingKeeper { + mock := &MockCheckpointingKeeper{ctrl: ctrl} + mock.recorder = &MockCheckpointingKeeperMockRecorder{mock} + return mock +} + +// EXPECT returns an object that allows the caller to indicate expected use. +func (m *MockCheckpointingKeeper) EXPECT() *MockCheckpointingKeeperMockRecorder { + return m.recorder +} + +// GetEpoch mocks base method. +func (m *MockCheckpointingKeeper) GetEpoch(ctx context.Context) *types2.Epoch { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "GetEpoch", ctx) + ret0, _ := ret[0].(*types2.Epoch) + return ret0 +} + +// GetEpoch indicates an expected call of GetEpoch. +func (mr *MockCheckpointingKeeperMockRecorder) GetEpoch(ctx interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetEpoch", reflect.TypeOf((*MockCheckpointingKeeper)(nil).GetEpoch), ctx) +} + +// GetLastFinalizedEpoch mocks base method. +func (m *MockCheckpointingKeeper) GetLastFinalizedEpoch(ctx context.Context) uint64 { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "GetLastFinalizedEpoch", ctx) + ret0, _ := ret[0].(uint64) + return ret0 +} + +// GetLastFinalizedEpoch indicates an expected call of GetLastFinalizedEpoch. +func (mr *MockCheckpointingKeeperMockRecorder) GetLastFinalizedEpoch(ctx interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetLastFinalizedEpoch", reflect.TypeOf((*MockCheckpointingKeeper)(nil).GetLastFinalizedEpoch), ctx) +} + +// 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, fpPk *types.BIP340PubKey) error { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "AfterFinalityProviderActivated", ctx, fpPk) + ret0, _ := ret[0].(error) + return ret0 +} + +// AfterFinalityProviderActivated indicates an expected call of AfterFinalityProviderActivated. +func (mr *MockBtcStakingHooksMockRecorder) AfterFinalityProviderActivated(ctx, fpPk interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "AfterFinalityProviderActivated", reflect.TypeOf((*MockBtcStakingHooks)(nil).AfterFinalityProviderActivated), ctx, fpPk) +} diff --git a/x/btcstaking/types/msg.go b/x/btcstaking/types/msg.go index b1d763ff0..e7e3efe46 100644 --- a/x/btcstaking/types/msg.go +++ b/x/btcstaking/types/msg.go @@ -4,8 +4,8 @@ import ( "fmt" math "math" - "github.com/babylonchain/babylon/btcstaking" - bbn "github.com/babylonchain/babylon/types" + "github.com/babylonlabs-io/babylon/btcstaking" + bbn "github.com/babylonlabs-io/babylon/types" "github.com/btcsuite/btcd/chaincfg/chainhash" sdk "github.com/cosmos/cosmos-sdk/types" ) @@ -14,6 +14,7 @@ import ( var ( _ sdk.Msg = &MsgUpdateParams{} _ sdk.Msg = &MsgCreateFinalityProvider{} + _ sdk.Msg = &MsgEditFinalityProvider{} _ sdk.Msg = &MsgCreateBTCDelegation{} _ sdk.Msg = &MsgAddCovenantSigs{} _ sdk.Msg = &MsgBTCUndelegate{} @@ -32,9 +33,6 @@ func (m *MsgCreateFinalityProvider) ValidateBasic() error { if _, err := m.Description.EnsureLength(); err != nil { return err } - if m.BabylonPk == nil { - return fmt.Errorf("empty Babylon public key") - } if m.BtcPk == nil { return fmt.Errorf("empty BTC public key") } @@ -44,10 +42,29 @@ func (m *MsgCreateFinalityProvider) ValidateBasic() error { if m.Pop == nil { return fmt.Errorf("empty proof of possession") } - if _, err := sdk.AccAddressFromBech32(m.Signer); err != nil { + if _, err := sdk.AccAddressFromBech32(m.Addr); err != nil { + return fmt.Errorf("invalid FP addr: %s - %v", m.Addr, err) + } + return m.Pop.ValidateBasic() +} + +func (m *MsgEditFinalityProvider) ValidateBasic() error { + if m.Commission == nil { + return fmt.Errorf("empty commission") + } + if m.Description == nil { + return fmt.Errorf("empty description") + } + if len(m.Description.Moniker) == 0 { + return fmt.Errorf("empty moniker") + } + if _, err := m.Description.EnsureLength(); err != nil { return err } - if err := m.Pop.ValidateBasic(); err != nil { + if len(m.BtcPk) != bbn.BIP340PubKeyLen { + return fmt.Errorf("malformed BTC PK") + } + if _, err := bbn.NewBIP340PubKey(m.BtcPk); err != nil { return err } @@ -55,8 +72,8 @@ func (m *MsgCreateFinalityProvider) ValidateBasic() error { } func (m *MsgCreateBTCDelegation) ValidateBasic() error { - if m.BabylonPk == nil { - return fmt.Errorf("empty Babylon public key") + if _, err := sdk.AccAddressFromBech32(m.StakerAddr); err != nil { + return fmt.Errorf("invalid staker addr %s: %w", m.StakerAddr, err) } if m.Pop == nil { return fmt.Errorf("empty proof of possession") @@ -86,10 +103,6 @@ func (m *MsgCreateBTCDelegation) ValidateBasic() error { return fmt.Errorf("invalid delegator slashing signature: %w", err) } - if _, err := sdk.AccAddressFromBech32(m.Signer); err != nil { - return err - } - // Check staking time is at most uint16 if m.StakingTime > math.MaxUint16 { return ErrInvalidStakingTx.Wrapf("invalid lock time: %d, max: %d", m.StakingTime, math.MaxUint16) diff --git a/x/btcstaking/types/msg_test.go b/x/btcstaking/types/msg_test.go new file mode 100644 index 000000000..ba69fd302 --- /dev/null +++ b/x/btcstaking/types/msg_test.go @@ -0,0 +1,181 @@ +package types_test + +import ( + "fmt" + "math/rand" + "testing" + + "cosmossdk.io/errors" + "github.com/babylonlabs-io/babylon/testutil/datagen" + bbntypes "github.com/babylonlabs-io/babylon/types" + "github.com/babylonlabs-io/babylon/x/btcstaking/types" + sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" + stktypes "github.com/cosmos/cosmos-sdk/x/staking/types" + "github.com/stretchr/testify/require" +) + +func TestMsgCreateFinalityProviderValidateBasic(t *testing.T) { + r := rand.New(rand.NewSource(10)) + randBigMoniker := datagen.GenRandomHexStr(r, 100) + + bigBtcPK := datagen.GenRandomByteArray(r, 100) + + fp, err := datagen.GenRandomFinalityProvider(r) + require.NoError(t, err) + + invalidAddr := "bbnbadaddr" + + tcs := []struct { + title string + msg *types.MsgCreateFinalityProvider + expErr error + }{ + { + "valid: msg create fp", + &types.MsgCreateFinalityProvider{ + Addr: fp.Addr, + Description: fp.Description, + Commission: fp.Commission, + BtcPk: fp.BtcPk, + Pop: fp.Pop, + }, + nil, + }, + { + "invalid: empty commission", + &types.MsgCreateFinalityProvider{ + Addr: fp.Addr, + Description: fp.Description, + Commission: nil, + BtcPk: fp.BtcPk, + Pop: fp.Pop, + }, + fmt.Errorf("empty commission"), + }, + { + "invalid: empty description", + &types.MsgCreateFinalityProvider{ + Addr: fp.Addr, + Description: nil, + Commission: fp.Commission, + BtcPk: fp.BtcPk, + Pop: fp.Pop, + }, + fmt.Errorf("empty description"), + }, + { + "invalid: empty moniker", + &types.MsgCreateFinalityProvider{ + Addr: fp.Addr, + Description: &stktypes.Description{ + Moniker: "", + Identity: fp.Description.Identity, + Website: fp.Description.Website, + SecurityContact: fp.Description.SecurityContact, + Details: fp.Description.Details, + }, + Commission: fp.Commission, + BtcPk: fp.BtcPk, + Pop: fp.Pop, + }, + fmt.Errorf("empty moniker"), + }, + { + "invalid: big moniker", + &types.MsgCreateFinalityProvider{ + Addr: fp.Addr, + Description: &stktypes.Description{ + Moniker: randBigMoniker, + Identity: fp.Description.Identity, + Website: fp.Description.Website, + SecurityContact: fp.Description.SecurityContact, + Details: fp.Description.Details, + }, + Commission: fp.Commission, + BtcPk: fp.BtcPk, + Pop: fp.Pop, + }, + errors.Wrapf(sdkerrors.ErrInvalidRequest, "invalid moniker length; got: %d, max: %d", len(randBigMoniker), stktypes.MaxMonikerLength), + }, + { + "invalid: empty BTC pk", + &types.MsgCreateFinalityProvider{ + Addr: fp.Addr, + Description: fp.Description, + Commission: fp.Commission, + BtcPk: nil, + Pop: fp.Pop, + }, + fmt.Errorf("empty BTC public key"), + }, + { + "invalid: invalid BTC pk", + &types.MsgCreateFinalityProvider{ + Addr: fp.Addr, + Description: fp.Description, + Commission: fp.Commission, + BtcPk: (*bbntypes.BIP340PubKey)(&bigBtcPK), + Pop: fp.Pop, + }, + fmt.Errorf("invalid BTC public key: %v", fmt.Errorf("bad pubkey byte string size (want %v, have %v)", 32, len(bigBtcPK))), + }, + { + "invalid: empty PoP", + &types.MsgCreateFinalityProvider{ + Addr: fp.Addr, + Description: fp.Description, + Commission: fp.Commission, + BtcPk: fp.BtcPk, + Pop: nil, + }, + fmt.Errorf("empty proof of possession"), + }, + { + "invalid: empty PoP", + &types.MsgCreateFinalityProvider{ + Addr: fp.Addr, + Description: fp.Description, + Commission: fp.Commission, + BtcPk: fp.BtcPk, + Pop: nil, + }, + fmt.Errorf("empty proof of possession"), + }, + { + "invalid: bad addr", + &types.MsgCreateFinalityProvider{ + Addr: invalidAddr, + Description: fp.Description, + Commission: fp.Commission, + BtcPk: fp.BtcPk, + Pop: fp.Pop, + }, + fmt.Errorf("invalid FP addr: %s - %v", invalidAddr, fmt.Errorf("decoding bech32 failed: invalid separator index -1")), + }, + { + "invalid: bad PoP empty sig", + &types.MsgCreateFinalityProvider{ + Addr: fp.Addr, + Description: fp.Description, + Commission: fp.Commission, + BtcPk: fp.BtcPk, + Pop: &types.ProofOfPossessionBTC{ + BtcSig: nil, + }, + }, + fmt.Errorf("empty BTC signature"), + }, + } + + for _, tc := range tcs { + tc := tc + t.Run(tc.title, func(t *testing.T) { + actErr := tc.msg.ValidateBasic() + if tc.expErr != nil { + require.EqualError(t, actErr, tc.expErr.Error()) + return + } + require.NoError(t, actErr) + }) + } +} diff --git a/x/btcstaking/types/params.go b/x/btcstaking/types/params.go index 8e923fca7..f3fc1fd92 100644 --- a/x/btcstaking/types/params.go +++ b/x/btcstaking/types/params.go @@ -5,8 +5,8 @@ import ( "math" sdkmath "cosmossdk.io/math" - "github.com/babylonchain/babylon/btcstaking" - bbn "github.com/babylonchain/babylon/types" + "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" @@ -64,6 +64,8 @@ func DefaultParams() Params { // The default minimum unbonding time is 0, which effectively defaults to checkpoint // finalization timeout. MinUnbondingTime: 0, + // By default unbonding value is 0.8 + MinUnbondingRate: sdkmath.LegacyNewDecWithPrec(8, 1), // 8 * 10^{-1} = 0.8 } } @@ -138,10 +140,14 @@ func (p Params) Validate() error { return err } - if !btcstaking.IsSlashingRateValid(p.SlashingRate) { + if !btcstaking.IsRateValid(p.SlashingRate) { return btcstaking.ErrInvalidSlashingRate } + if !btcstaking.IsRateValid(p.MinUnbondingRate) { + return fmt.Errorf("minimum unbonding value is invalid. it should be fraction in range (0, 1) with at 2 decimal places precision") + } + if err := validateMaxActiveFinalityProviders(p.MaxActiveFinalityProviders); err != nil { return err } diff --git a/x/btcstaking/types/params.pb.go b/x/btcstaking/types/params.pb.go index 642dda4e6..097fff47a 100644 --- a/x/btcstaking/types/params.pb.go +++ b/x/btcstaking/types/params.pb.go @@ -6,7 +6,7 @@ package types import ( cosmossdk_io_math "cosmossdk.io/math" fmt "fmt" - github_com_babylonchain_babylon_types "github.com/babylonchain/babylon/types" + 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" @@ -30,7 +30,7 @@ const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package type Params struct { // covenant_pks is the list of public keys held by the covenant committee // each PK follows encoding in BIP-340 spec on Bitcoin - CovenantPks []github_com_babylonchain_babylon_types.BIP340PubKey `protobuf:"bytes,1,rep,name=covenant_pks,json=covenantPks,proto3,customtype=github.com/babylonchain/babylon/types.BIP340PubKey" json:"covenant_pks,omitempty"` + CovenantPks []github_com_babylonlabs_io_babylon_types.BIP340PubKey `protobuf:"bytes,1,rep,name=covenant_pks,json=covenantPks,proto3,customtype=github.com/babylonlabs-io/babylon/types.BIP340PubKey" json:"covenant_pks,omitempty"` // covenant_quorum is the minimum number of signatures needed for the covenant // multisignature CovenantQuorum uint32 `protobuf:"varint,2,opt,name=covenant_quorum,json=covenantQuorum,proto3" json:"covenant_quorum,omitempty"` @@ -50,6 +50,12 @@ type Params struct { MaxActiveFinalityProviders uint32 `protobuf:"varint,7,opt,name=max_active_finality_providers,json=maxActiveFinalityProviders,proto3" json:"max_active_finality_providers,omitempty"` // min_unbonding_time is the minimum time for unbonding transaction timelock in BTC blocks MinUnbondingTime uint32 `protobuf:"varint,8,opt,name=min_unbonding_time,json=minUnbondingTime,proto3" json:"min_unbonding_time,omitempty"` + // 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 + MinUnbondingRate cosmossdk_io_math.LegacyDec `protobuf:"bytes,9,opt,name=min_unbonding_rate,json=minUnbondingRate,proto3,customtype=cosmossdk.io/math.LegacyDec" json:"min_unbonding_rate"` } func (m *Params) Reset() { *m = Params{} } @@ -119,8 +125,65 @@ func (m *Params) GetMinUnbondingTime() uint32 { return 0 } +// StoredParams attach information about the version of stored parameters +type StoredParams struct { + // version of the stored parameters. Each parameters update + // increments version number by 1 + Version uint32 `protobuf:"varint,1,opt,name=version,proto3" json:"version,omitempty"` + // NOTE: Parameters must always be provided + Params Params `protobuf:"bytes,2,opt,name=params,proto3" json:"params"` +} + +func (m *StoredParams) Reset() { *m = StoredParams{} } +func (m *StoredParams) String() string { return proto.CompactTextString(m) } +func (*StoredParams) ProtoMessage() {} +func (*StoredParams) Descriptor() ([]byte, []int) { + return fileDescriptor_8d1392776a3e15b9, []int{1} +} +func (m *StoredParams) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *StoredParams) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_StoredParams.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 *StoredParams) XXX_Merge(src proto.Message) { + xxx_messageInfo_StoredParams.Merge(m, src) +} +func (m *StoredParams) XXX_Size() int { + return m.Size() +} +func (m *StoredParams) XXX_DiscardUnknown() { + xxx_messageInfo_StoredParams.DiscardUnknown(m) +} + +var xxx_messageInfo_StoredParams proto.InternalMessageInfo + +func (m *StoredParams) GetVersion() uint32 { + if m != nil { + return m.Version + } + return 0 +} + +func (m *StoredParams) GetParams() Params { + if m != nil { + return m.Params + } + return Params{} +} + func init() { proto.RegisterType((*Params)(nil), "babylon.btcstaking.v1.Params") + proto.RegisterType((*StoredParams)(nil), "babylon.btcstaking.v1.StoredParams") } func init() { @@ -128,38 +191,42 @@ func init() { } var fileDescriptor_8d1392776a3e15b9 = []byte{ - // 483 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x8c, 0x92, 0x41, 0x6f, 0xd3, 0x3c, - 0x18, 0xc7, 0x93, 0xb7, 0x7d, 0x0b, 0x98, 0x8e, 0x8d, 0x00, 0x22, 0x14, 0x91, 0x56, 0xe3, 0x40, - 0x91, 0x20, 0xa1, 0x6c, 0xe2, 0xc0, 0xad, 0x05, 0x4d, 0x42, 0xec, 0x10, 0xd2, 0x81, 0x04, 0x17, - 0xcb, 0x71, 0xbc, 0xd4, 0x6a, 0x6d, 0x97, 0xd8, 0x89, 0x92, 0x6f, 0x01, 0x37, 0x8e, 0x7c, 0x08, - 0x3e, 0xc4, 0x8e, 0x13, 0x27, 0xb4, 0x43, 0x85, 0xda, 0x2f, 0x82, 0xe2, 0x24, 0x85, 0x1b, 0xdc, - 0xe2, 0xff, 0xf3, 0xf3, 0xcf, 0xf1, 0xe3, 0x07, 0xec, 0x87, 0x28, 0x2c, 0x16, 0x82, 0x7b, 0xa1, - 0xc2, 0x52, 0xa1, 0x39, 0xe5, 0xb1, 0x97, 0x8d, 0xbc, 0x25, 0x4a, 0x10, 0x93, 0xee, 0x32, 0x11, - 0x4a, 0x58, 0xb7, 0x6a, 0xc6, 0xfd, 0xcd, 0xb8, 0xd9, 0xa8, 0x77, 0x33, 0x16, 0xb1, 0xd0, 0x84, - 0x57, 0x7e, 0x55, 0x70, 0xef, 0x0e, 0x16, 0x92, 0x09, 0x09, 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x0c, 0xa9, 0x99, 0x7b, 0x4c, 0x62, 0x84, 0x8b, 0x97, 0x04, 0x07, 0xd7, 0x19, 0xe5, 0x2f, - 0xb6, 0xdb, 0x03, 0xa4, 0x88, 0xf5, 0x0e, 0xec, 0x6c, 0x7f, 0x43, 0xeb, 0x3a, 0x5a, 0x37, 0xfa, - 0x07, 0xdd, 0xf7, 0x6f, 0x8f, 0x41, 0xfd, 0x20, 0xa5, 0xbc, 0xdb, 0x78, 0xb4, 0x77, 0x0c, 0xee, - 0x31, 0x94, 0x43, 0x84, 0x15, 0xcd, 0x08, 0x3c, 0xa5, 0x1c, 0x2d, 0xa8, 0x2a, 0xca, 0x67, 0xcc, - 0x68, 0x44, 0x12, 0x69, 0x5f, 0xd2, 0x4d, 0xec, 0x31, 0x94, 0x8f, 0x35, 0x73, 0x54, 0x23, 0x7e, - 0x43, 0x58, 0x8f, 0x80, 0x55, 0xde, 0x37, 0xe5, 0xa1, 0xe0, 0x91, 0x6e, 0x13, 0x65, 0xc4, 0xbe, - 0xac, 0xf7, 0xed, 0x31, 0xca, 0xdf, 0x36, 0x85, 0x13, 0xca, 0xc8, 0xf3, 0xf6, 0x97, 0xaf, 0x7d, - 0x63, 0x72, 0x7c, 0xb6, 0x76, 0xcc, 0xf3, 0xb5, 0x63, 0xfe, 0x5c, 0x3b, 0xe6, 0xa7, 0x8d, 0x63, - 0x9c, 0x6f, 0x1c, 0xe3, 0xc7, 0xc6, 0x31, 0x3e, 0xfc, 0x75, 0x10, 0xf2, 0x3f, 0x67, 0x56, 0x4f, - 0x45, 0xd8, 0xd1, 0x83, 0x76, 0xf0, 0x2b, 0x00, 0x00, 0xff, 0xff, 0x9a, 0xce, 0xa4, 0xfd, 0xd6, - 0x02, 0x00, 0x00, + // 547 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x9c, 0x53, 0xcb, 0x6e, 0xd3, 0x40, + 0x14, 0x8d, 0x49, 0x48, 0xe9, 0x34, 0xa5, 0x65, 0x00, 0x61, 0x82, 0xea, 0x44, 0x61, 0x41, 0x90, + 0xa8, 0x4d, 0x68, 0x16, 0x08, 0x56, 0x09, 0xa8, 0x12, 0x02, 0xa1, 0xe0, 0x14, 0x16, 0xb0, 0x18, + 0x8d, 0xed, 0xa9, 0x33, 0x4a, 0x66, 0x26, 0x78, 0x26, 0x56, 0xfc, 0x17, 0x2c, 0x59, 0xf2, 0x11, + 0x7c, 0x44, 0x97, 0x15, 0x2b, 0xd4, 0x45, 0x84, 0x92, 0x5f, 0xe0, 0x03, 0x90, 0xc7, 0x76, 0x78, + 0x88, 0x45, 0xd5, 0x9d, 0xef, 0xb9, 0xe7, 0x9e, 0xfb, 0xf0, 0x19, 0xd0, 0xf2, 0xb0, 0x97, 0x4c, + 0x04, 0x77, 0x3c, 0xe5, 0x4b, 0x85, 0xc7, 0x94, 0x87, 0x4e, 0xdc, 0x71, 0xa6, 0x38, 0xc2, 0x4c, + 0xda, 0xd3, 0x48, 0x28, 0x01, 0x6f, 0xe6, 0x1c, 0xfb, 0x37, 0xc7, 0x8e, 0x3b, 0xf5, 0x1b, 0xa1, + 0x08, 0x85, 0x66, 0x38, 0xe9, 0x57, 0x46, 0xae, 0xdf, 0xf6, 0x85, 0x64, 0x42, 0xa2, 0x2c, 0x91, + 0x05, 0x59, 0xaa, 0xf5, 0xb3, 0x02, 0xaa, 0x03, 0x2d, 0x0c, 0x3f, 0x80, 0x9a, 0x2f, 0x62, 0xc2, + 0x31, 0x57, 0x68, 0x3a, 0x96, 0xa6, 0xd1, 0x2c, 0xb7, 0x6b, 0xfd, 0xc7, 0x67, 0x8b, 0x46, 0x37, + 0xa4, 0x6a, 0x34, 0xf3, 0x6c, 0x5f, 0x30, 0x27, 0xef, 0x3b, 0xc1, 0x9e, 0xdc, 0xa7, 0xa2, 0x08, + 0x1d, 0x95, 0x4c, 0x89, 0xb4, 0xfb, 0x2f, 0x06, 0x07, 0xdd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 0x50, 0x95, 0xa4, 0x3f, 0x32, 0xa6, 0x01, 0x89, 0xa4, 0xb9, 0xa1, 0x8f, 0x58, 0x67, 0x78, + 0xde, 0xd3, 0x9c, 0xc3, 0x9c, 0x32, 0x28, 0x18, 0xf0, 0x01, 0x80, 0xe9, 0xbe, 0x33, 0xee, 0x09, + 0x1e, 0xe8, 0x33, 0x51, 0x46, 0xcc, 0x2b, 0xba, 0x6e, 0x97, 0x51, 0xfe, 0xb6, 0x48, 0x1c, 0x51, + 0x46, 0x20, 0xfa, 0x97, 0xad, 0xb7, 0xd9, 0xbc, 0xe8, 0x36, 0x7f, 0x35, 0x48, 0x37, 0x7a, 0x52, + 0xf9, 0xfc, 0xa5, 0x51, 0x6a, 0x11, 0x50, 0x1b, 0x2a, 0x11, 0x91, 0x20, 0xf7, 0x9e, 0x09, 0x36, + 0x62, 0x12, 0xa5, 0xe7, 0x34, 0x0d, 0x3d, 0x59, 0x11, 0xc2, 0xa7, 0xa0, 0x9a, 0x19, 0x5f, 0xfb, + 0x65, 0xeb, 0xd1, 0x9e, 0xfd, 0x5f, 0xe7, 0xdb, 0x99, 0x50, 0xbf, 0x92, 0xce, 0xe8, 0xe6, 0x25, + 0xfd, 0xd7, 0x27, 0x4b, 0xcb, 0x38, 0x5d, 0x5a, 0xc6, 0x8f, 0xa5, 0x65, 0x7c, 0x5a, 0x59, 0xa5, + 0xd3, 0x95, 0x55, 0xfa, 0xbe, 0xb2, 0x4a, 0xef, 0xcf, 0x61, 0xe9, 0xf9, 0x9f, 0xef, 0x4f, 0xfb, + 0xdb, 0xab, 0xea, 0x47, 0x73, 0xf0, 0x2b, 0x00, 0x00, 0xff, 0xff, 0x60, 0x31, 0x6e, 0xa0, 0xa2, + 0x03, 0x00, 0x00, } func (m *Params) Marshal() (dAtA []byte, err error) { @@ -182,6 +249,16 @@ func (m *Params) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l + { + size := m.MinUnbondingRate.Size() + i -= size + if _, err := m.MinUnbondingRate.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintParams(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x4a if m.MinUnbondingTime != 0 { i = encodeVarintParams(dAtA, i, uint64(m.MinUnbondingTime)) i-- @@ -246,6 +323,44 @@ func (m *Params) MarshalToSizedBuffer(dAtA []byte) (int, error) { return len(dAtA) - i, nil } +func (m *StoredParams) 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 *StoredParams) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *StoredParams) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + { + size, err := m.Params.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintParams(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + if m.Version != 0 { + i = encodeVarintParams(dAtA, i, uint64(m.Version)) + i-- + dAtA[i] = 0x8 + } + return len(dAtA) - i, nil +} + func encodeVarintParams(dAtA []byte, offset int, v uint64) int { offset -= sovParams(v) base := offset @@ -289,6 +404,22 @@ func (m *Params) Size() (n int) { if m.MinUnbondingTime != 0 { n += 1 + sovParams(uint64(m.MinUnbondingTime)) } + l = m.MinUnbondingRate.Size() + n += 1 + l + sovParams(uint64(l)) + return n +} + +func (m *StoredParams) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.Version != 0 { + n += 1 + sovParams(uint64(m.Version)) + } + l = m.Params.Size() + n += 1 + l + sovParams(uint64(l)) return n } @@ -356,7 +487,7 @@ func (m *Params) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - var v github_com_babylonchain_babylon_types.BIP340PubKey + var v github_com_babylonlabs_io_babylon_types.BIP340PubKey m.CovenantPks = append(m.CovenantPks, v) if err := m.CovenantPks[len(m.CovenantPks)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err @@ -538,6 +669,142 @@ func (m *Params) Unmarshal(dAtA []byte) error { break } } + case 9: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field MinUnbondingRate", 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.MinUnbondingRate.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipParams(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthParams + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *StoredParams) 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 ErrIntOverflowParams + } + 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: StoredParams: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: StoredParams: 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 ErrIntOverflowParams + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Version |= uint32(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 2: + 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 ErrIntOverflowParams + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthParams + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthParams + } + 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 := skipParams(dAtA[iNdEx:]) diff --git a/x/btcstaking/types/pop.go b/x/btcstaking/types/pop.go index 1c0521661..004b31ca1 100644 --- a/x/btcstaking/types/pop.go +++ b/x/btcstaking/types/pop.go @@ -5,9 +5,9 @@ import ( "encoding/hex" "fmt" - "github.com/babylonchain/babylon/crypto/bip322" - "github.com/babylonchain/babylon/crypto/ecdsa" - bbn "github.com/babylonchain/babylon/types" + "github.com/babylonlabs-io/babylon/crypto/bip322" + "github.com/babylonlabs-io/babylon/crypto/ecdsa" + 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" @@ -15,7 +15,7 @@ import ( "github.com/btcsuite/btcd/txscript" "github.com/btcsuite/btcd/wire" "github.com/cometbft/cometbft/crypto/tmhash" - cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types" + sdk "github.com/cosmos/cosmos-sdk/types" ) type checkStakerKey func(stakerKey *bbn.BIP340PubKey) error @@ -24,29 +24,19 @@ type bip322Sign[A btcutil.Address] func(sg []byte, privKey *btcec.PrivateKey, net *chaincfg.Params) (A, []byte, error) -// NewPoP generates a new proof of possession that sk_Babylon and sk_BTC are held by the same person -// a proof of possession contains two signatures: -// - pop.BabylonSig = sign(sk_Babylon, pk_BTC) -// - pop.BtcSig = schnorr_sign(sk_BTC, pop.BabylonSig) -func NewPoP(babylonSK cryptotypes.PrivKey, btcSK *btcec.PrivateKey) (*ProofOfPossession, error) { - pop := ProofOfPossession{ +// NewPoPBTC generates a new proof of possession that sk_BTC and the address are held by the same person +// a proof of possession contains only one signature +// - pop.BtcSig = schnorr_sign(sk_BTC, bbnAddress) +func NewPoPBTC(addr sdk.AccAddress, btcSK *btcec.PrivateKey) (*ProofOfPossessionBTC, error) { + pop := ProofOfPossessionBTC{ BtcSigType: BTCSigType_BIP340, // by default, we use BIP-340 encoding for BTC signature } - // generate pop.BabylonSig = sign(sk_Babylon, pk_BTC) - btcPK := btcSK.PubKey() - bip340PK := bbn.NewBIP340PubKeyFromBTCPK(btcPK) - babylonSig, err := babylonSK.Sign(*bip340PK) - if err != nil { - return nil, err - } - pop.BabylonSig = babylonSig - - // generate pop.BtcSig = schnorr_sign(sk_BTC, pop.BabylonSig) + // generate pop.BtcSig = schnorr_sign(sk_BTC, hash(bbnAddress)) // NOTE: *schnorr.Sign has to take the hash of the message. - // So we have to hash babylonSig before signing - babylonSigHash := tmhash.Sum(pop.BabylonSig) - btcSig, err := schnorr.Sign(btcSK, babylonSigHash) + // So we have to hash the address before signing + hash := tmhash.Sum(addr.Bytes()) + btcSig, err := schnorr.Sign(btcSK, hash) if err != nil { return nil, err } @@ -58,27 +48,17 @@ func NewPoP(babylonSK cryptotypes.PrivKey, btcSK *btcec.PrivateKey) (*ProofOfPos // NewPoPWithECDSABTCSig generates a new proof of possession where Bitcoin signature is in ECDSA format // a proof of possession contains two signatures: -// - pop.BabylonSig = sign(sk_Babylon, pk_BTC) -// - pop.BtcSig = ecdsa_sign(sk_BTC, pop.BabylonSig) -func NewPoPWithECDSABTCSig(babylonSK cryptotypes.PrivKey, btcSK *btcec.PrivateKey) (*ProofOfPossession, error) { - pop := ProofOfPossession{ +// - pop.BtcSig = ecdsa_sign(sk_BTC, addr) +func NewPoPBTCWithECDSABTCSig(addr sdk.AccAddress, btcSK *btcec.PrivateKey) (*ProofOfPossessionBTC, error) { + pop := ProofOfPossessionBTC{ BtcSigType: BTCSigType_ECDSA, } - // generate pop.BabylonSig = sign(sk_Babylon, pk_BTC) - btcPK := btcSK.PubKey() - bip340PK := bbn.NewBIP340PubKeyFromBTCPK(btcPK) - babylonSig, err := babylonSK.Sign(*bip340PK) - if err != nil { - return nil, err - } - pop.BabylonSig = babylonSig - // generate pop.BtcSig = ecdsa_sign(sk_BTC, pop.BabylonSig) // NOTE: ecdsa.Sign has to take the message as string. - // So we have to hex babylonSig before signing - babylonSigHex := hex.EncodeToString(pop.BabylonSig) - btcSig, err := ecdsa.Sign(btcSK, babylonSigHex) + // So we have to hex addr before signing + addrHex := hex.EncodeToString(addr.Bytes()) + btcSig, err := ecdsa.Sign(btcSK, addrHex) if err != nil { return nil, err } @@ -87,43 +67,37 @@ func NewPoPWithECDSABTCSig(babylonSK cryptotypes.PrivKey, btcSK *btcec.PrivateKe return &pop, nil } -func babylonSigToHexHash(babylonSig []byte) []byte { - babylonSigHash := tmhash.Sum(babylonSig) - babylonSigHashHex := hex.EncodeToString(babylonSigHash) - babylonSigHashHexBytes := []byte(babylonSigHashHex) - return babylonSigHashHexBytes -} - -func newPoPWithBIP322Sig[A btcutil.Address]( - babylonSK cryptotypes.PrivKey, +func newPoPBTCWithBIP322Sig[A btcutil.Address]( + addressToSign sdk.AccAddress, btcSK *btcec.PrivateKey, net *chaincfg.Params, bip322SignFn bip322Sign[A], -) (*ProofOfPossession, error) { - pop := ProofOfPossession{ +) (*ProofOfPossessionBTC, error) { + pop := ProofOfPossessionBTC{ BtcSigType: BTCSigType_BIP322, } - // generate pop.BabylonSig = sign(sk_Babylon, pk_BTC) - btcPK := btcSK.PubKey() - bip340PK := bbn.NewBIP340PubKeyFromBTCPK(btcPK) - babylonSig, err := babylonSK.Sign(*bip340PK) + bip322SigEncoded, err := newBIP322Sig(tmhash.Sum(addressToSign.Bytes()), btcSK, net, bip322SignFn) if err != nil { return nil, err } - pop.BabylonSig = babylonSig + pop.BtcSig = bip322SigEncoded - // TODO: temporary solution for MVP purposes. - // Eventually we need to use tmhash.Sum(pop.BabylonSig) rather than bbnSigHashHexBytes - // ref: https://github.com/babylonchain/babylon/issues/433 - bbnSigHashHexBytes := babylonSigToHexHash(pop.BabylonSig) + return &pop, nil +} + +func newBIP322Sig[A btcutil.Address]( + msgToSign []byte, + btcSK *btcec.PrivateKey, + net *chaincfg.Params, + bip322SignFn bip322Sign[A], +) ([]byte, error) { address, witnessSignture, err := bip322SignFn( - bbnSigHashHexBytes, + msgToSign, btcSK, net, ) - if err != nil { return nil, err } @@ -133,45 +107,32 @@ func newPoPWithBIP322Sig[A btcutil.Address]( Sig: witnessSignture, } - bip322SigEncoded, err := bip322Sig.Marshal() - - if err != nil { - return nil, err - } - pop.BtcSig = bip322SigEncoded - - return &pop, nil + return bip322Sig.Marshal() } -func NewPoPWithBIP322P2WPKHSig( - babylonSK cryptotypes.PrivKey, +// NewPoPBTCWithBIP322P2WPKHSig creates a proof of possession of type BIP322 +// that signs the address with the BTC secret key. +func NewPoPBTCWithBIP322P2WPKHSig( + addr sdk.AccAddress, btcSK *btcec.PrivateKey, net *chaincfg.Params, -) (*ProofOfPossession, error) { - return newPoPWithBIP322Sig(babylonSK, btcSK, net, bip322.SignWithP2WPKHAddress) +) (*ProofOfPossessionBTC, error) { + return newPoPBTCWithBIP322Sig(addr, btcSK, net, bip322.SignWithP2WPKHAddress) } -func NewPoPWithBIP322P2TRBIP86Sig( - babylonSK cryptotypes.PrivKey, - btcSK *btcec.PrivateKey, - net *chaincfg.Params, -) (*ProofOfPossession, error) { - return newPoPWithBIP322Sig(babylonSK, btcSK, net, bip322.SignWithP2TrSpendAddress) -} - -func NewPoPFromHex(popHex string) (*ProofOfPossession, error) { +func NewPoPBTCFromHex(popHex string) (*ProofOfPossessionBTC, error) { popBytes, err := hex.DecodeString(popHex) if err != nil { return nil, err } - var pop ProofOfPossession + var pop ProofOfPossessionBTC if err := pop.Unmarshal(popBytes); err != nil { return nil, err } return &pop, nil } -func (pop *ProofOfPossession) ToHexStr() (string, error) { +func (pop *ProofOfPossessionBTC) ToHexStr() (string, error) { popBytes, err := pop.Marshal() if err != nil { return "", err @@ -179,29 +140,27 @@ func (pop *ProofOfPossession) ToHexStr() (string, error) { return hex.EncodeToString(popBytes), nil } -func (pop *ProofOfPossession) Verify(babylonPK cryptotypes.PubKey, bip340PK *bbn.BIP340PubKey, net *chaincfg.Params) error { +// Verify that the BTC private key corresponding to the bip340PK signed the staker address +func (pop *ProofOfPossessionBTC) Verify(staker sdk.AccAddress, bip340PK *bbn.BIP340PubKey, net *chaincfg.Params) error { switch pop.BtcSigType { case BTCSigType_BIP340: - return pop.VerifyBIP340(babylonPK, bip340PK) + return pop.VerifyBIP340(staker, bip340PK) case BTCSigType_BIP322: - return pop.VerifyBIP322(babylonPK, bip340PK, net) + return pop.VerifyBIP322(staker, bip340PK, net) case BTCSigType_ECDSA: - return pop.VerifyECDSA(babylonPK, bip340PK) + return pop.VerifyECDSA(staker, bip340PK) default: return fmt.Errorf("invalid BTC signature type") } } -// VerifyBIP340 verifies the validity of PoP where Bitcoin signature is in BIP-340 -// 1. verify(sig=sig_btc, pubkey=pk_btc, msg=pop.BabylonSig)? -// 2. verify(sig=pop.BabylonSig, pubkey=pk_babylon, msg=pk_btc)? -func (pop *ProofOfPossession) VerifyBIP340(babylonPK cryptotypes.PubKey, bip340PK *bbn.BIP340PubKey) error { - if pop.BtcSigType != BTCSigType_BIP340 { +// VerifyBIP340 if the BTC signature has signed the hash by the pair of bip340PK. +func VerifyBIP340(sigType BTCSigType, btcSigRaw []byte, bip340PK *bbn.BIP340PubKey, msg []byte) error { + if sigType != BTCSigType_BIP340 { return fmt.Errorf("the Bitcoin signature in this proof of possession is not using BIP-340 encoding") } - // rule 1: verify(sig=sig_btc, pubkey=pk_btc, msg=pop.BabylonSig)? - bip340Sig, err := bbn.NewBIP340Signature(pop.BtcSig) + bip340Sig, err := bbn.NewBIP340Signature(btcSigRaw) if err != nil { return err } @@ -213,21 +172,31 @@ func (pop *ProofOfPossession) VerifyBIP340(babylonPK cryptotypes.PubKey, bip340P if err != nil { return err } + // NOTE: btcSig.Verify has to take hash of the message. // So we have to hash babylonSig before verifying the signature - babylonSigHash := tmhash.Sum(pop.BabylonSig) - if !btcSig.Verify(babylonSigHash, btcPK) { + hash := tmhash.Sum(msg) + if !btcSig.Verify(hash, btcPK) { return fmt.Errorf("failed to verify pop.BtcSig") } - // rule 2: verify(sig=pop.BabylonSig, pubkey=pk_babylon, msg=pk_btc)? - if !babylonPK.VerifySignature(*bip340PK, pop.BabylonSig) { - return fmt.Errorf("failed to verify pop.BabylonSig") - } - return nil } +// VerifyBIP340 verifies the validity of PoP where Bitcoin signature is in BIP-340 +// 1. verify(sig=sig_btc, pubkey=pk_btc, msg=staker_addr)? +func (pop *ProofOfPossessionBTC) VerifyBIP340(stakerAddr sdk.AccAddress, bip340PK *bbn.BIP340PubKey) error { + return VerifyBIP340(pop.BtcSigType, pop.BtcSig, bip340PK, stakerAddr.Bytes()) +} + +func NewPoPBTCWithBIP322P2TRBIP86Sig( + addrToSign sdk.AccAddress, + btcSK *btcec.PrivateKey, + net *chaincfg.Params, +) (*ProofOfPossessionBTC, error) { + return newPoPBTCWithBIP322Sig(addrToSign, btcSK, net, bip322.SignWithP2TrSpendAddress) +} + // isSupportedAddressAndWitness checks whether provided address and witness are // valid for proof of possession verification. // Currently the only supported options are: @@ -361,31 +330,25 @@ func VerifyBIP322SigPop( // VerifyBIP322 verifies the validity of PoP where Bitcoin signature is in BIP-322 // after decoding pop.BtcSig to bip322Sig which contains sig and address, -// 1. verify whether bip322 pop signature where msg=pop.BabylonSig -// 2. verify(sig=pop.BabylonSig, pubkey=babylonPK, msg=bip340PK)? -func (pop *ProofOfPossession) VerifyBIP322(babylonPK cryptotypes.PubKey, bip340PK *bbn.BIP340PubKey, net *chaincfg.Params) error { - if pop.BtcSigType != BTCSigType_BIP322 { +// verify whether bip322 pop signature where msg=signedMsg +func VerifyBIP322(sigType BTCSigType, btcSigRaw []byte, bip340PK *bbn.BIP340PubKey, signedMsg []byte, net *chaincfg.Params) error { + if sigType != BTCSigType_BIP322 { return fmt.Errorf("the Bitcoin signature in this proof of possession is not using BIP-322 encoding") } // unmarshal pop.BtcSig to bip322Sig var bip322Sig BIP322Sig - if err := bip322Sig.Unmarshal(pop.BtcSig); err != nil { + if err := bip322Sig.Unmarshal(btcSigRaw); err != nil { return nil } - // TODO: temporary solution for MVP purposes. - // Eventually we need to use tmhash.Sum(pop.BabylonSig) rather than bbnSigHashHexBytes - // ref: https://github.com/babylonchain/babylon/issues/433 - bbnSigHashHexBytes := babylonSigToHexHash(pop.BabylonSig) - btcKeyBytes, err := bip340PK.Marshal() if err != nil { return err } - // 1. Verify Bip322 proof of possession signature + // Verify Bip322 proof of possession signature if err := VerifyBIP322SigPop( - bbnSigHashHexBytes, + signedMsg, bip322Sig.Address, bip322Sig.Sig, btcKeyBytes, @@ -394,49 +357,74 @@ func (pop *ProofOfPossession) VerifyBIP322(babylonPK cryptotypes.PubKey, bip340P return err } - // rule 2: verify(sig=pop.BabylonSig, pubkey=pk_babylon, msg=pk_btc)? - if !babylonPK.VerifySignature(*bip340PK, pop.BabylonSig) { - return fmt.Errorf("failed to verify pop.BabylonSig") - } + return nil +} +// VerifyBIP322 verifies the validity of PoP where Bitcoin signature is in BIP-322 +// after decoding pop.BtcSig to bip322Sig which contains sig and address, +// 1. verify whether bip322 pop signature where msg=pop.BabylonSig +// 2. verify(sig=pop.BabylonSig, pubkey=babylonPK, msg=bip340PK)? +func (pop *ProofOfPossessionBTC) VerifyBIP322(addr sdk.AccAddress, bip340PK *bbn.BIP340PubKey, net *chaincfg.Params) error { + msg := tmhash.Sum(addr.Bytes()) + if err := VerifyBIP322(pop.BtcSigType, pop.BtcSig, bip340PK, msg, net); err != nil { + return fmt.Errorf("failed to verify possession of babylon sig by the BTC key: %w", err) + } return nil } // VerifyECDSA verifies the validity of PoP where Bitcoin signature is in ECDSA encoding -// 1. verify(sig=sig_btc, pubkey=pk_btc, msg=pop.BabylonSig)? -// 2. verify(sig=pop.BabylonSig, pubkey=pk_babylon, msg=pk_btc)? -func (pop *ProofOfPossession) VerifyECDSA(babylonPK cryptotypes.PubKey, bip340PK *bbn.BIP340PubKey) error { - if pop.BtcSigType != BTCSigType_ECDSA { +// 1. verify(sig=sig_btc, pubkey=pk_btc, msg=msg)? +func VerifyECDSA(sigType BTCSigType, btcSigRaw []byte, bip340PK *bbn.BIP340PubKey, msg []byte) error { + if sigType != BTCSigType_ECDSA { return fmt.Errorf("the Bitcoin signature in this proof of possession is not using ECDSA encoding") } - // rule 1: verify(sig=sig_btc, pubkey=pk_btc, msg=pop.BabylonSig)? + // rule 1: verify(sig=sig_btc, pubkey=pk_btc, msg=msg)? btcPK, err := bip340PK.ToBTCPK() if err != nil { return err } // NOTE: ecdsa.Verify has to take message as a string // So we have to hex BabylonSig before verifying the signature - bbnSigHex := hex.EncodeToString(pop.BabylonSig) - if err := ecdsa.Verify(btcPK, bbnSigHex, pop.BtcSig); err != nil { - return fmt.Errorf("failed to verify pop.BtcSig") - } - - // rule 2: verify(sig=pop.BabylonSig, pubkey=pk_babylon, msg=pk_btc)? - if !babylonPK.VerifySignature(*bip340PK, pop.BabylonSig) { - return fmt.Errorf("failed to verify pop.BabylonSig") + bbnSigHex := hex.EncodeToString(msg) + if err := ecdsa.Verify(btcPK, bbnSigHex, btcSigRaw); err != nil { + return fmt.Errorf("failed to verify btcSigRaw") } return nil } -func (pop *ProofOfPossession) ValidateBasic() error { - if len(pop.BabylonSig) == 0 { - return fmt.Errorf("empty Babylon signature") - } +// VerifyECDSA verifies the validity of PoP where Bitcoin signature is in ECDSA encoding +// 1. verify(sig=sig_btc, pubkey=pk_btc, msg=addr)? +func (pop *ProofOfPossessionBTC) VerifyECDSA(addr sdk.AccAddress, bip340PK *bbn.BIP340PubKey) error { + return VerifyECDSA(pop.BtcSigType, pop.BtcSig, bip340PK, addr.Bytes()) +} + +// ValidateBasic checks if there is a BTC Signature. +func (pop *ProofOfPossessionBTC) ValidateBasic() error { if pop.BtcSig == nil { return fmt.Errorf("empty BTC signature") } - return nil + switch pop.BtcSigType { + case BTCSigType_BIP340: + _, err := bbn.NewBIP340Signature(pop.BtcSig) + if err != nil { + return fmt.Errorf("invalid BTC BIP340 signature: %w", err) + } + return nil + case BTCSigType_BIP322: + var bip322Sig BIP322Sig + if err := bip322Sig.Unmarshal(pop.BtcSig); err != nil { + return fmt.Errorf("invalid BTC BIP322 signature: %w", err) + } + return nil + case BTCSigType_ECDSA: + if len(pop.BtcSig) != 65 { // size of compact signature + return fmt.Errorf("invalid BTC ECDSA signature size") + } + return nil + default: + return fmt.Errorf("invalid BTC signature type") + } } diff --git a/x/btcstaking/types/pop.pb.go b/x/btcstaking/types/pop.pb.go index 672a3f88a..f0d4519ef 100644 --- a/x/btcstaking/types/pop.pb.go +++ b/x/btcstaking/types/pop.pb.go @@ -55,31 +55,29 @@ func (BTCSigType) EnumDescriptor() ([]byte, []int) { return fileDescriptor_9d6ceb088d9e9f3a, []int{0} } -// ProofOfPossession is the proof of possession that a Babylon secp256k1 -// secret key and a Bitcoin secp256k1 secret key are held by the same +// ProofOfPossessionBTC is the proof of possession that a Babylon +// address and a Bitcoin secp256k1 secret key are held by the same // person -type ProofOfPossession struct { +type ProofOfPossessionBTC struct { // btc_sig_type indicates the type of btc_sig in the pop BtcSigType BTCSigType `protobuf:"varint,1,opt,name=btc_sig_type,json=btcSigType,proto3,enum=babylon.btcstaking.v1.BTCSigType" json:"btc_sig_type,omitempty"` - // babylon_sig is the signature generated via sign(sk_babylon, pk_btc) - BabylonSig []byte `protobuf:"bytes,2,opt,name=babylon_sig,json=babylonSig,proto3" json:"babylon_sig,omitempty"` - // btc_sig is the signature generated via sign(sk_btc, babylon_sig) + // btc_sig is the signature generated via sign(sk_btc, babylon_staker_address) // the signature follows encoding in either BIP-340 spec or BIP-322 spec - BtcSig []byte `protobuf:"bytes,3,opt,name=btc_sig,json=btcSig,proto3" json:"btc_sig,omitempty"` + BtcSig []byte `protobuf:"bytes,2,opt,name=btc_sig,json=btcSig,proto3" json:"btc_sig,omitempty"` } -func (m *ProofOfPossession) Reset() { *m = ProofOfPossession{} } -func (m *ProofOfPossession) String() string { return proto.CompactTextString(m) } -func (*ProofOfPossession) ProtoMessage() {} -func (*ProofOfPossession) Descriptor() ([]byte, []int) { +func (m *ProofOfPossessionBTC) Reset() { *m = ProofOfPossessionBTC{} } +func (m *ProofOfPossessionBTC) String() string { return proto.CompactTextString(m) } +func (*ProofOfPossessionBTC) ProtoMessage() {} +func (*ProofOfPossessionBTC) Descriptor() ([]byte, []int) { return fileDescriptor_9d6ceb088d9e9f3a, []int{0} } -func (m *ProofOfPossession) XXX_Unmarshal(b []byte) error { +func (m *ProofOfPossessionBTC) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } -func (m *ProofOfPossession) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { +func (m *ProofOfPossessionBTC) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { - return xxx_messageInfo_ProofOfPossession.Marshal(b, m, deterministic) + return xxx_messageInfo_ProofOfPossessionBTC.Marshal(b, m, deterministic) } else { b = b[:cap(b)] n, err := m.MarshalToSizedBuffer(b) @@ -89,33 +87,26 @@ func (m *ProofOfPossession) XXX_Marshal(b []byte, deterministic bool) ([]byte, e return b[:n], nil } } -func (m *ProofOfPossession) XXX_Merge(src proto.Message) { - xxx_messageInfo_ProofOfPossession.Merge(m, src) +func (m *ProofOfPossessionBTC) XXX_Merge(src proto.Message) { + xxx_messageInfo_ProofOfPossessionBTC.Merge(m, src) } -func (m *ProofOfPossession) XXX_Size() int { +func (m *ProofOfPossessionBTC) XXX_Size() int { return m.Size() } -func (m *ProofOfPossession) XXX_DiscardUnknown() { - xxx_messageInfo_ProofOfPossession.DiscardUnknown(m) +func (m *ProofOfPossessionBTC) XXX_DiscardUnknown() { + xxx_messageInfo_ProofOfPossessionBTC.DiscardUnknown(m) } -var xxx_messageInfo_ProofOfPossession proto.InternalMessageInfo +var xxx_messageInfo_ProofOfPossessionBTC proto.InternalMessageInfo -func (m *ProofOfPossession) GetBtcSigType() BTCSigType { +func (m *ProofOfPossessionBTC) GetBtcSigType() BTCSigType { if m != nil { return m.BtcSigType } return BTCSigType_BIP340 } -func (m *ProofOfPossession) GetBabylonSig() []byte { - if m != nil { - return m.BabylonSig - } - return nil -} - -func (m *ProofOfPossession) GetBtcSig() []byte { +func (m *ProofOfPossessionBTC) GetBtcSig() []byte { if m != nil { return m.BtcSig } @@ -180,36 +171,35 @@ func (m *BIP322Sig) GetSig() []byte { func init() { proto.RegisterEnum("babylon.btcstaking.v1.BTCSigType", BTCSigType_name, BTCSigType_value) - proto.RegisterType((*ProofOfPossession)(nil), "babylon.btcstaking.v1.ProofOfPossession") + proto.RegisterType((*ProofOfPossessionBTC)(nil), "babylon.btcstaking.v1.ProofOfPossessionBTC") proto.RegisterType((*BIP322Sig)(nil), "babylon.btcstaking.v1.BIP322Sig") } func init() { proto.RegisterFile("babylon/btcstaking/v1/pop.proto", fileDescriptor_9d6ceb088d9e9f3a) } var fileDescriptor_9d6ceb088d9e9f3a = []byte{ - // 298 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x6c, 0x90, 0x41, 0x4f, 0xc2, 0x30, - 0x1c, 0xc5, 0x57, 0x88, 0x10, 0xfe, 0x12, 0x33, 0x9b, 0x18, 0x77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0x38, 0x97, 0xe7, 0x0c, 0xa0, 0x2a, 0x83, 0x01, 0x1a, 0x39, 0xe6, 0xf2, 0xc2, 0x75, 0x4a, - 0xcd, 0xb9, 0x8b, 0x70, 0x0b, 0x0e, 0x6e, 0xc7, 0x37, 0xb3, 0x6b, 0xb7, 0x36, 0xba, 0xff, 0x4c, - 0x09, 0xda, 0xa7, 0x04, 0x7d, 0xa7, 0x04, 0xbd, 0x67, 0xc4, 0xd9, 0x67, 0xc4, 0xf9, 0xca, 0x88, - 0xf3, 0xc8, 0x23, 0x69, 0xd6, 0xaf, 0x82, 0x06, 0xea, 0x85, 0xd9, 0xce, 0xc1, 0xda, 0x97, 0x71, - 0x69, 0xd8, 0xdb, 0xdf, 0xa9, 0xf3, 0x95, 0xb4, 0x68, 0x14, 0x53, 0x0f, 0x7f, 0x02, 0x00, 0x00, - 0xff, 0xff, 0x89, 0x18, 0xe3, 0x67, 0x8d, 0x01, 0x00, 0x00, -} - -func (m *ProofOfPossession) Marshal() (dAtA []byte, err error) { + // 287 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x6c, 0x90, 0x31, 0x4b, 0xc3, 0x40, + 0x1c, 0xc5, 0x73, 0x15, 0x5b, 0xfa, 0xa7, 0x48, 0x38, 0x14, 0x3b, 0x9d, 0xb5, 0x53, 0x11, 0xbc, + 0xb3, 0x69, 0xc1, 0xd9, 0x44, 0x07, 0x17, 0x2d, 0x49, 0x26, 0x97, 0x92, 0x4b, 0xd3, 0x78, 0x58, + 0x73, 0x21, 0x77, 0x16, 0xf3, 0x2d, 0xfc, 0x58, 0x8e, 0x1d, 0x1d, 0x25, 0xf9, 0x22, 0x92, 0x9a, + 0x10, 0x07, 0xb7, 0xf7, 0xb8, 0x77, 0xef, 0xf1, 0xff, 0xc1, 0x19, 0x0f, 0x78, 0xbe, 0x91, 0x09, + 0xe3, 0x3a, 0x54, 0x3a, 0x78, 0x11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14, 0xef, 0xee, 0x69, + 0xce, 0x7e, 0x02, 0x00, 0x00, 0xff, 0xff, 0x4c, 0xd5, 0x14, 0x5e, 0x70, 0x01, 0x00, 0x00, +} + +func (m *ProofOfPossessionBTC) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalToSizedBuffer(dAtA[:size]) @@ -219,12 +209,12 @@ func (m *ProofOfPossession) Marshal() (dAtA []byte, err error) { return dAtA[:n], nil } -func (m *ProofOfPossession) MarshalTo(dAtA []byte) (int, error) { +func (m *ProofOfPossessionBTC) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *ProofOfPossession) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *ProofOfPossessionBTC) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) _ = i var l int @@ -234,13 +224,6 @@ func (m *ProofOfPossession) MarshalToSizedBuffer(dAtA []byte) (int, error) { copy(dAtA[i:], m.BtcSig) i = encodeVarintPop(dAtA, i, uint64(len(m.BtcSig))) i-- - dAtA[i] = 0x1a - } - if len(m.BabylonSig) > 0 { - i -= len(m.BabylonSig) - copy(dAtA[i:], m.BabylonSig) - i = encodeVarintPop(dAtA, i, uint64(len(m.BabylonSig))) - i-- dAtA[i] = 0x12 } if m.BtcSigType != 0 { @@ -299,7 +282,7 @@ func encodeVarintPop(dAtA []byte, offset int, v uint64) int { dAtA[offset] = uint8(v) return base } -func (m *ProofOfPossession) Size() (n int) { +func (m *ProofOfPossessionBTC) Size() (n int) { if m == nil { return 0 } @@ -308,10 +291,6 @@ func (m *ProofOfPossession) Size() (n int) { if m.BtcSigType != 0 { n += 1 + sovPop(uint64(m.BtcSigType)) } - l = len(m.BabylonSig) - if l > 0 { - n += 1 + l + sovPop(uint64(l)) - } l = len(m.BtcSig) if l > 0 { n += 1 + l + sovPop(uint64(l)) @@ -342,7 +321,7 @@ func sovPop(x uint64) (n int) { func sozPop(x uint64) (n int) { return sovPop(uint64((x << 1) ^ uint64((int64(x) >> 63)))) } -func (m *ProofOfPossession) Unmarshal(dAtA []byte) error { +func (m *ProofOfPossessionBTC) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -365,10 +344,10 @@ func (m *ProofOfPossession) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: ProofOfPossession: wiretype end group for non-group") + return fmt.Errorf("proto: ProofOfPossessionBTC: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: ProofOfPossession: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: ProofOfPossessionBTC: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: @@ -391,40 +370,6 @@ func (m *ProofOfPossession) Unmarshal(dAtA []byte) error { } } case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field BabylonSig", wireType) - } - var byteLen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowPop - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - byteLen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if byteLen < 0 { - return ErrInvalidLengthPop - } - postIndex := iNdEx + byteLen - if postIndex < 0 { - return ErrInvalidLengthPop - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.BabylonSig = append(m.BabylonSig[:0], dAtA[iNdEx:postIndex]...) - if m.BabylonSig == nil { - m.BabylonSig = []byte{} - } - iNdEx = postIndex - case 3: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field BtcSig", wireType) } diff --git a/x/btcstaking/types/pop_test.go b/x/btcstaking/types/pop_test.go index 34fa89d6f..86bd8ceff 100644 --- a/x/btcstaking/types/pop_test.go +++ b/x/btcstaking/types/pop_test.go @@ -1,53 +1,30 @@ package types_test import ( + "fmt" "math/rand" "testing" - "github.com/babylonchain/babylon/testutil/datagen" - bbn "github.com/babylonchain/babylon/types" - "github.com/babylonchain/babylon/x/btcstaking/types" - "github.com/btcsuite/btcd/btcec/v2" - "github.com/btcsuite/btcd/btcec/v2/schnorr" - "github.com/btcsuite/btcd/chaincfg" - "github.com/cometbft/cometbft/crypto/tmhash" - cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types" "github.com/stretchr/testify/require" + + "github.com/btcsuite/btcd/chaincfg" + + sdk "github.com/cosmos/cosmos-sdk/types" + + "github.com/babylonlabs-io/babylon/testutil/datagen" + bbn "github.com/babylonlabs-io/babylon/types" + "github.com/babylonlabs-io/babylon/x/btcstaking/types" ) var ( net = &chaincfg.TestNet3Params ) -func newInvalidBIP340PoP(r *rand.Rand, babylonSK cryptotypes.PrivKey, btcSK *btcec.PrivateKey) *types.ProofOfPossession { - pop := types.ProofOfPossession{} - - randomNum := datagen.RandomInt(r, 2) // 0 or 1 - - btcPK := btcSK.PubKey() - bip340PK := bbn.NewBIP340PubKeyFromBTCPK(btcPK) - babylonSig, err := babylonSK.Sign(*bip340PK) - if err != nil { - panic(err) - } - - var babylonSigHash []byte - if randomNum == 0 { - pop.BabylonSig = babylonSig // correct sig - babylonSigHash = datagen.GenRandomByteArray(r, 32) // fake sig hash - } else { - pop.BabylonSig = datagen.GenRandomByteArray(r, uint64(len(babylonSig))) // fake sig - babylonSigHash = tmhash.Sum(pop.BabylonSig) // correct sig hash - } - - btcSig, err := schnorr.Sign(btcSK, babylonSigHash) - if err != nil { - panic(err) +func newInvalidBIP340PoP(r *rand.Rand) *types.ProofOfPossessionBTC { + return &types.ProofOfPossessionBTC{ + BtcSigType: types.BTCSigType_BIP340, + BtcSig: datagen.GenRandomByteArray(r, 32), // fake sig hash } - bip340Sig := bbn.NewBIP340SignatureFromBTCSig(btcSig) - pop.BtcSig = bip340Sig.MustMarshal() - - return &pop } func FuzzPoP_BIP340(f *testing.F) { @@ -61,19 +38,17 @@ func FuzzPoP_BIP340(f *testing.F) { require.NoError(t, err) bip340PK := bbn.NewBIP340PubKeyFromBTCPK(btcPK) - // generate Babylon key pair - babylonSK, babylonPK, err := datagen.GenRandomSecp256k1KeyPair(r) - require.NoError(t, err) + accAddr := datagen.GenRandomAccount().GetAddress() // generate and verify PoP, correct case - pop, err := types.NewPoP(babylonSK, btcSK) + pop, err := types.NewPoPBTC(accAddr, btcSK) require.NoError(t, err) - err = pop.VerifyBIP340(babylonPK, bip340PK) + err = pop.VerifyBIP340(accAddr, bip340PK) require.NoError(t, err) // generate and verify PoP, invalid case - invalidPoP := newInvalidBIP340PoP(r, babylonSK, btcSK) - err = invalidPoP.VerifyBIP340(babylonPK, bip340PK) + invalidPoP := newInvalidBIP340PoP(r) + err = invalidPoP.VerifyBIP340(accAddr, bip340PK) require.Error(t, err) }) } @@ -89,14 +64,12 @@ func FuzzPoP_ECDSA(f *testing.F) { require.NoError(t, err) bip340PK := bbn.NewBIP340PubKeyFromBTCPK(btcPK) - // generate Babylon key pair - babylonSK, babylonPK, err := datagen.GenRandomSecp256k1KeyPair(r) - require.NoError(t, err) + accAddr := datagen.GenRandomAccount().GetAddress() // generate and verify PoP, correct case - pop, err := types.NewPoPWithECDSABTCSig(babylonSK, btcSK) + pop, err := types.NewPoPBTCWithECDSABTCSig(accAddr, btcSK) require.NoError(t, err) - err = pop.VerifyECDSA(babylonPK, bip340PK) + err = pop.VerifyECDSA(accAddr, bip340PK) require.NoError(t, err) }) } @@ -112,14 +85,12 @@ func FuzzPoP_BIP322_P2WPKH(f *testing.F) { require.NoError(t, err) bip340PK := bbn.NewBIP340PubKeyFromBTCPK(btcPK) - // generate Babylon key pair - babylonSK, babylonPK, err := datagen.GenRandomSecp256k1KeyPair(r) - require.NoError(t, err) + accAddr := datagen.GenRandomAccount().GetAddress() // generate and verify PoP, correct case - pop, err := types.NewPoPWithBIP322P2WPKHSig(babylonSK, btcSK, net) + pop, err := types.NewPoPBTCWithBIP322P2WPKHSig(accAddr, btcSK, net) require.NoError(t, err) - err = pop.VerifyBIP322(babylonPK, bip340PK, net) + err = pop.VerifyBIP322(accAddr, bip340PK, net) require.NoError(t, err) }) } @@ -135,14 +106,12 @@ func FuzzPoP_BIP322_P2Tr_BIP86(f *testing.F) { require.NoError(t, err) bip340PK := bbn.NewBIP340PubKeyFromBTCPK(btcPK) - // generate Babylon key pair - babylonSK, babylonPK, err := datagen.GenRandomSecp256k1KeyPair(r) - require.NoError(t, err) + accAddr := datagen.GenRandomAccount().GetAddress() // generate and verify PoP, correct case - pop, err := types.NewPoPWithBIP322P2TRBIP86Sig(babylonSK, btcSK, net) + pop, err := types.NewPoPBTCWithBIP322P2TRBIP86Sig(accAddr, btcSK, net) require.NoError(t, err) - err = pop.VerifyBIP322(babylonPK, bip340PK, net) + err = pop.VerifyBIP322(accAddr, bip340PK, net) require.NoError(t, err) }) } @@ -162,24 +131,215 @@ func FuzzPop_ValidBip322SigNotMatchingBip340PubKey(f *testing.F) { require.NoError(t, err) bip340PK1 := bbn.NewBIP340PubKeyFromBTCPK(btcPK1) - // generate Babylon key pair - babylonSK, babylonPK, err := datagen.GenRandomSecp256k1KeyPair(r) - require.NoError(t, err) + accAddr := datagen.GenRandomAccount().GetAddress() // generate valid bip322 P2WPKH pop - pop, err := types.NewPoPWithBIP322P2WPKHSig(babylonSK, btcSK, net) + pop, err := types.NewPoPBTCWithBIP322P2WPKHSig(accAddr, btcSK, net) require.NoError(t, err) // verify bip322 pop with incorrect staker key - err = pop.VerifyBIP322(babylonPK, bip340PK1, net) + err = pop.VerifyBIP322(accAddr, bip340PK1, net) require.Error(t, err) // generate valid bip322 P2Tr pop - pop, err = types.NewPoPWithBIP322P2TRBIP86Sig(babylonSK, btcSK, net) + pop, err = types.NewPoPBTCWithBIP322P2TRBIP86Sig(accAddr, btcSK, net) require.NoError(t, err) // verify bip322 pop with incorrect staker key - err = pop.VerifyBIP322(babylonPK, bip340PK1, net) + err = pop.VerifyBIP322(accAddr, bip340PK1, net) require.Error(t, err) }) } + +func TestPoPBTCValidateBasic(t *testing.T) { + r := rand.New(rand.NewSource(10)) + + btcSK, _, err := datagen.GenRandomBTCKeyPair(r) + require.NoError(t, err) + + addrToSign := sdk.MustAccAddressFromBech32(datagen.GenRandomAccount().Address) + + popBip340, err := types.NewPoPBTC(addrToSign, btcSK) + require.NoError(t, err) + + popBip322, err := types.NewPoPBTCWithBIP322P2WPKHSig(addrToSign, btcSK, &chaincfg.MainNetParams) + require.NoError(t, err) + + popECDSA, err := types.NewPoPBTCWithECDSABTCSig(addrToSign, btcSK) + require.NoError(t, err) + + tcs := []struct { + title string + pop *types.ProofOfPossessionBTC + expErr error + }{ + { + "valid: BIP 340", + popBip340, + nil, + }, + { + "valid: BIP 322", + popBip322, + nil, + }, + { + "valid: ECDSA", + popECDSA, + nil, + }, + { + "invalid: nil sig", + &types.ProofOfPossessionBTC{}, + fmt.Errorf("empty BTC signature"), + }, + { + "invalid: BIP 340 - bad sig", + &types.ProofOfPossessionBTC{ + BtcSigType: types.BTCSigType_BIP340, + BtcSig: popBip322.BtcSig, + }, + fmt.Errorf("invalid BTC BIP340 signature: bytes cannot be converted to a *schnorr.Signature object"), + }, + { + "invalid: BIP 322 - bad sig", + &types.ProofOfPossessionBTC{ + BtcSigType: types.BTCSigType_BIP322, + BtcSig: []byte("ss"), + }, + fmt.Errorf("invalid BTC BIP322 signature: unexpected EOF"), + }, + { + "invalid: ECDSA - bad sig", + &types.ProofOfPossessionBTC{ + BtcSigType: types.BTCSigType_ECDSA, + BtcSig: popBip340.BtcSig, + }, + fmt.Errorf("invalid BTC ECDSA signature size"), + }, + } + + for _, tc := range tcs { + tc := tc + t.Run(tc.title, func(t *testing.T) { + actErr := tc.pop.ValidateBasic() + if tc.expErr != nil { + require.EqualError(t, actErr, tc.expErr.Error()) + return + } + require.NoError(t, actErr) + }) + } +} + +func TestPoPBTCVerify(t *testing.T) { + r := rand.New(rand.NewSource(10)) + + addrToSign := sdk.MustAccAddressFromBech32(datagen.GenRandomAccount().Address) + randomAddr := sdk.MustAccAddressFromBech32(datagen.GenRandomAccount().Address) + + // generate BTC key pair + btcSK, btcPK, err := datagen.GenRandomBTCKeyPair(r) + require.NoError(t, err) + bip340PK := bbn.NewBIP340PubKeyFromBTCPK(btcPK) + + netParams := &chaincfg.MainNetParams + + popBip340, err := types.NewPoPBTC(addrToSign, btcSK) + require.NoError(t, err) + + popBip322, err := types.NewPoPBTCWithBIP322P2WPKHSig(addrToSign, btcSK, netParams) + require.NoError(t, err) + + popECDSA, err := types.NewPoPBTCWithECDSABTCSig(addrToSign, btcSK) + require.NoError(t, err) + + tcs := []struct { + title string + staker sdk.AccAddress + btcPK *bbn.BIP340PubKey + pop *types.ProofOfPossessionBTC + expErr error + }{ + { + "valid: BIP340", + addrToSign, + bip340PK, + popBip340, + nil, + }, + { + "valid: BIP322", + addrToSign, + bip340PK, + popBip322, + nil, + }, + { + "valid: ECDSA", + addrToSign, + bip340PK, + popECDSA, + nil, + }, + { + "invalid: BIP340 - bad addr", + randomAddr, + bip340PK, + popBip340, + fmt.Errorf("failed to verify pop.BtcSig"), + }, + { + "invalid: BIP322 - bad addr", + randomAddr, + bip340PK, + popBip322, + fmt.Errorf("failed to verify possession of babylon sig by the BTC key: signature not empty on failed checksig"), + }, + { + "invalid: ECDSA - bad addr", + randomAddr, + bip340PK, + popECDSA, + fmt.Errorf("failed to verify btcSigRaw"), + }, + { + "invalid: SigType", + nil, + nil, + &types.ProofOfPossessionBTC{ + BtcSigType: types.BTCSigType(123), + }, + fmt.Errorf("invalid BTC signature type"), + }, + { + "invalid: nil sig", + randomAddr, + bip340PK, + &types.ProofOfPossessionBTC{ + 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"), + }, + { + "invalid: nil signed msg", + nil, + bip340PK, + popBip340, + fmt.Errorf("failed to verify pop.BtcSig"), + }, + } + + for _, tc := range tcs { + tc := tc + t.Run(tc.title, func(t *testing.T) { + actErr := tc.pop.Verify(tc.staker, tc.btcPK, netParams) + if tc.expErr != nil { + require.EqualError(t, actErr, tc.expErr.Error()) + return + } + require.NoError(t, actErr) + }) + } +} diff --git a/x/btcstaking/types/query.go b/x/btcstaking/types/query.go new file mode 100644 index 000000000..1caecf29e --- /dev/null +++ b/x/btcstaking/types/query.go @@ -0,0 +1,73 @@ +package types + +import ( + "encoding/hex" +) + +// 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, + StartHeight: btcDel.StartHeight, + EndHeight: btcDel.EndHeight, + TotalSat: btcDel.TotalSat, + StakingTxHex: hex.EncodeToString(btcDel.StakingTx), + DelegatorSlashSigHex: btcDel.DelegatorSig.ToHexStr(), + CovenantSigs: btcDel.CovenantSigs, + StakingOutputIdx: btcDel.StakingOutputIdx, + Active: status == BTCDelegationStatus_ACTIVE, + StatusDesc: status.String(), + UnbondingTime: btcDel.UnbondingTime, + UndelegationResponse: nil, + ParamsVersion: btcDel.ParamsVersion, + } + + if btcDel.SlashingTx != nil { + resp.SlashingTxHex = hex.EncodeToString(*btcDel.SlashingTx) + } + + if btcDel.BtcUndelegation != nil { + resp.UndelegationResponse = btcDel.BtcUndelegation.ToResponse() + } + + return resp +} + +// ToResponse parses an BTCUndelegation into BTCUndelegationResponse. +func (ud *BTCUndelegation) ToResponse() (resp *BTCUndelegationResponse) { + resp = &BTCUndelegationResponse{ + UnbondingTxHex: hex.EncodeToString(ud.UnbondingTx), + CovenantUnbondingSigList: ud.CovenantUnbondingSigList, + CovenantSlashingSigs: ud.CovenantSlashingSigs, + } + + if ud.DelegatorUnbondingSig != nil { + resp.DelegatorUnbondingSigHex = ud.DelegatorUnbondingSig.ToHexStr() + } + if ud.SlashingTx != nil { + resp.SlashingTxHex = ud.SlashingTx.ToHexStr() + } + if ud.DelegatorSlashingSig != nil { + resp.DelegatorSlashingSigHex = ud.DelegatorSlashingSig.ToHexStr() + } + + return resp +} + +// NewFinalityProviderResponse creates a new finality provider response based on the finaliny provider and his voting power. +func NewFinalityProviderResponse(f *FinalityProvider, bbnBlockHeight, votingPower uint64) *FinalityProviderResponse { + return &FinalityProviderResponse{ + Description: f.Description, + Commission: f.Commission, + Addr: f.Addr, + BtcPk: f.BtcPk, + Pop: f.Pop, + SlashedBabylonHeight: f.SlashedBabylonHeight, + SlashedBtcHeight: f.SlashedBtcHeight, + Sluggish: f.Sluggish, + Height: bbnBlockHeight, + VotingPower: votingPower, + } +} diff --git a/x/btcstaking/types/query.pb.go b/x/btcstaking/types/query.pb.go index fb4f4e200..dc710bb9f 100644 --- a/x/btcstaking/types/query.pb.go +++ b/x/btcstaking/types/query.pb.go @@ -5,9 +5,12 @@ package types import ( context "context" + cosmossdk_io_math "cosmossdk.io/math" fmt "fmt" - github_com_babylonchain_babylon_types "github.com/babylonchain/babylon/types" + github_com_babylonlabs_io_babylon_types "github.com/babylonlabs-io/babylon/types" + _ "github.com/cosmos/cosmos-proto" query "github.com/cosmos/cosmos-sdk/types/query" + types "github.com/cosmos/cosmos-sdk/x/staking/types" _ "github.com/cosmos/gogoproto/gogoproto" grpc1 "github.com/cosmos/gogoproto/grpc" proto "github.com/cosmos/gogoproto/proto" @@ -114,6 +117,97 @@ func (m *QueryParamsResponse) GetParams() Params { return Params{} } +// QueryParamsRequest is request type for the Query/Params RPC method. +type QueryParamsByVersionRequest struct { + Version uint32 `protobuf:"varint,1,opt,name=version,proto3" json:"version,omitempty"` +} + +func (m *QueryParamsByVersionRequest) Reset() { *m = QueryParamsByVersionRequest{} } +func (m *QueryParamsByVersionRequest) String() string { return proto.CompactTextString(m) } +func (*QueryParamsByVersionRequest) ProtoMessage() {} +func (*QueryParamsByVersionRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_74d49d26f7429697, []int{2} +} +func (m *QueryParamsByVersionRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryParamsByVersionRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryParamsByVersionRequest.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 *QueryParamsByVersionRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryParamsByVersionRequest.Merge(m, src) +} +func (m *QueryParamsByVersionRequest) XXX_Size() int { + return m.Size() +} +func (m *QueryParamsByVersionRequest) XXX_DiscardUnknown() { + xxx_messageInfo_QueryParamsByVersionRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryParamsByVersionRequest proto.InternalMessageInfo + +func (m *QueryParamsByVersionRequest) GetVersion() uint32 { + if m != nil { + return m.Version + } + return 0 +} + +// QueryParamsResponse is response type for the Query/Params RPC method. +type QueryParamsByVersionResponse struct { + // params holds all the parameters of this module. + Params Params `protobuf:"bytes,1,opt,name=params,proto3" json:"params"` +} + +func (m *QueryParamsByVersionResponse) Reset() { *m = QueryParamsByVersionResponse{} } +func (m *QueryParamsByVersionResponse) String() string { return proto.CompactTextString(m) } +func (*QueryParamsByVersionResponse) ProtoMessage() {} +func (*QueryParamsByVersionResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_74d49d26f7429697, []int{3} +} +func (m *QueryParamsByVersionResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryParamsByVersionResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryParamsByVersionResponse.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 *QueryParamsByVersionResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryParamsByVersionResponse.Merge(m, src) +} +func (m *QueryParamsByVersionResponse) XXX_Size() int { + return m.Size() +} +func (m *QueryParamsByVersionResponse) XXX_DiscardUnknown() { + xxx_messageInfo_QueryParamsByVersionResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryParamsByVersionResponse proto.InternalMessageInfo + +func (m *QueryParamsByVersionResponse) GetParams() Params { + if m != nil { + return m.Params + } + return Params{} +} + // QueryFinalityProvidersRequest is the request type for the // Query/FinalityProviders RPC method. type QueryFinalityProvidersRequest struct { @@ -125,7 +219,7 @@ func (m *QueryFinalityProvidersRequest) Reset() { *m = QueryFinalityProv func (m *QueryFinalityProvidersRequest) String() string { return proto.CompactTextString(m) } func (*QueryFinalityProvidersRequest) ProtoMessage() {} func (*QueryFinalityProvidersRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_74d49d26f7429697, []int{2} + return fileDescriptor_74d49d26f7429697, []int{4} } func (m *QueryFinalityProvidersRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -165,7 +259,7 @@ func (m *QueryFinalityProvidersRequest) GetPagination() *query.PageRequest { // Query/FinalityProviders RPC method. type QueryFinalityProvidersResponse struct { // finality_providers contains all the finality providers - FinalityProviders []*FinalityProvider `protobuf:"bytes,1,rep,name=finality_providers,json=finalityProviders,proto3" json:"finality_providers,omitempty"` + FinalityProviders []*FinalityProviderResponse `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"` } @@ -174,7 +268,7 @@ func (m *QueryFinalityProvidersResponse) Reset() { *m = QueryFinalityPro func (m *QueryFinalityProvidersResponse) String() string { return proto.CompactTextString(m) } func (*QueryFinalityProvidersResponse) ProtoMessage() {} func (*QueryFinalityProvidersResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_74d49d26f7429697, []int{3} + return fileDescriptor_74d49d26f7429697, []int{5} } func (m *QueryFinalityProvidersResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -203,7 +297,7 @@ func (m *QueryFinalityProvidersResponse) XXX_DiscardUnknown() { var xxx_messageInfo_QueryFinalityProvidersResponse proto.InternalMessageInfo -func (m *QueryFinalityProvidersResponse) GetFinalityProviders() []*FinalityProvider { +func (m *QueryFinalityProvidersResponse) GetFinalityProviders() []*FinalityProviderResponse { if m != nil { return m.FinalityProviders } @@ -227,7 +321,7 @@ func (m *QueryFinalityProviderRequest) Reset() { *m = QueryFinalityProvi func (m *QueryFinalityProviderRequest) String() string { return proto.CompactTextString(m) } func (*QueryFinalityProviderRequest) ProtoMessage() {} func (*QueryFinalityProviderRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_74d49d26f7429697, []int{4} + return fileDescriptor_74d49d26f7429697, []int{6} } func (m *QueryFinalityProviderRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -266,14 +360,14 @@ func (m *QueryFinalityProviderRequest) GetFpBtcPkHex() string { // QueryFinalityProviderResponse contains information about a finality provider type QueryFinalityProviderResponse struct { // finality_provider contains the FinalityProvider - FinalityProvider *FinalityProvider `protobuf:"bytes,1,opt,name=finality_provider,json=finalityProvider,proto3" json:"finality_provider,omitempty"` + FinalityProvider *FinalityProviderResponse `protobuf:"bytes,1,opt,name=finality_provider,json=finalityProvider,proto3" json:"finality_provider,omitempty"` } func (m *QueryFinalityProviderResponse) Reset() { *m = QueryFinalityProviderResponse{} } func (m *QueryFinalityProviderResponse) String() string { return proto.CompactTextString(m) } func (*QueryFinalityProviderResponse) ProtoMessage() {} func (*QueryFinalityProviderResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_74d49d26f7429697, []int{5} + return fileDescriptor_74d49d26f7429697, []int{7} } func (m *QueryFinalityProviderResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -302,7 +396,7 @@ func (m *QueryFinalityProviderResponse) XXX_DiscardUnknown() { var xxx_messageInfo_QueryFinalityProviderResponse proto.InternalMessageInfo -func (m *QueryFinalityProviderResponse) GetFinalityProvider() *FinalityProvider { +func (m *QueryFinalityProviderResponse) GetFinalityProvider() *FinalityProviderResponse { if m != nil { return m.FinalityProvider } @@ -322,7 +416,7 @@ func (m *QueryBTCDelegationsRequest) Reset() { *m = QueryBTCDelegationsR func (m *QueryBTCDelegationsRequest) String() string { return proto.CompactTextString(m) } func (*QueryBTCDelegationsRequest) ProtoMessage() {} func (*QueryBTCDelegationsRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_74d49d26f7429697, []int{6} + return fileDescriptor_74d49d26f7429697, []int{8} } func (m *QueryBTCDelegationsRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -369,7 +463,7 @@ func (m *QueryBTCDelegationsRequest) GetPagination() *query.PageRequest { // Query/BTCDelegations RPC method. type QueryBTCDelegationsResponse struct { // btc_delegations contains all the queried BTC delegations under the given status - BtcDelegations []*BTCDelegation `protobuf:"bytes,1,rep,name=btc_delegations,json=btcDelegations,proto3" json:"btc_delegations,omitempty"` + BtcDelegations []*BTCDelegationResponse `protobuf:"bytes,1,rep,name=btc_delegations,json=btcDelegations,proto3" json:"btc_delegations,omitempty"` // pagination defines the pagination in the response. Pagination *query.PageResponse `protobuf:"bytes,2,opt,name=pagination,proto3" json:"pagination,omitempty"` } @@ -378,7 +472,7 @@ func (m *QueryBTCDelegationsResponse) Reset() { *m = QueryBTCDelegations func (m *QueryBTCDelegationsResponse) String() string { return proto.CompactTextString(m) } func (*QueryBTCDelegationsResponse) ProtoMessage() {} func (*QueryBTCDelegationsResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_74d49d26f7429697, []int{7} + return fileDescriptor_74d49d26f7429697, []int{9} } func (m *QueryBTCDelegationsResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -407,7 +501,7 @@ func (m *QueryBTCDelegationsResponse) XXX_DiscardUnknown() { var xxx_messageInfo_QueryBTCDelegationsResponse proto.InternalMessageInfo -func (m *QueryBTCDelegationsResponse) GetBtcDelegations() []*BTCDelegation { +func (m *QueryBTCDelegationsResponse) GetBtcDelegations() []*BTCDelegationResponse { if m != nil { return m.BtcDelegations } @@ -440,7 +534,7 @@ func (m *QueryFinalityProviderPowerAtHeightRequest) String() string { } func (*QueryFinalityProviderPowerAtHeightRequest) ProtoMessage() {} func (*QueryFinalityProviderPowerAtHeightRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_74d49d26f7429697, []int{8} + return fileDescriptor_74d49d26f7429697, []int{10} } func (m *QueryFinalityProviderPowerAtHeightRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -498,7 +592,7 @@ func (m *QueryFinalityProviderPowerAtHeightResponse) String() string { } func (*QueryFinalityProviderPowerAtHeightResponse) ProtoMessage() {} func (*QueryFinalityProviderPowerAtHeightResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_74d49d26f7429697, []int{9} + return fileDescriptor_74d49d26f7429697, []int{11} } func (m *QueryFinalityProviderPowerAtHeightResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -549,7 +643,7 @@ func (m *QueryFinalityProviderCurrentPowerRequest) Reset() { func (m *QueryFinalityProviderCurrentPowerRequest) String() string { return proto.CompactTextString(m) } func (*QueryFinalityProviderCurrentPowerRequest) ProtoMessage() {} func (*QueryFinalityProviderCurrentPowerRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_74d49d26f7429697, []int{10} + return fileDescriptor_74d49d26f7429697, []int{12} } func (m *QueryFinalityProviderCurrentPowerRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -602,7 +696,7 @@ func (m *QueryFinalityProviderCurrentPowerResponse) String() string { } func (*QueryFinalityProviderCurrentPowerResponse) ProtoMessage() {} func (*QueryFinalityProviderCurrentPowerResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_74d49d26f7429697, []int{11} + return fileDescriptor_74d49d26f7429697, []int{13} } func (m *QueryFinalityProviderCurrentPowerResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -662,7 +756,7 @@ func (m *QueryActiveFinalityProvidersAtHeightRequest) String() string { } func (*QueryActiveFinalityProvidersAtHeightRequest) ProtoMessage() {} func (*QueryActiveFinalityProvidersAtHeightRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_74d49d26f7429697, []int{12} + return fileDescriptor_74d49d26f7429697, []int{14} } func (m *QueryActiveFinalityProvidersAtHeightRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -722,7 +816,7 @@ func (m *QueryActiveFinalityProvidersAtHeightResponse) String() string { } func (*QueryActiveFinalityProvidersAtHeightResponse) ProtoMessage() {} func (*QueryActiveFinalityProvidersAtHeightResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_74d49d26f7429697, []int{13} + return fileDescriptor_74d49d26f7429697, []int{15} } func (m *QueryActiveFinalityProvidersAtHeightResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -773,7 +867,7 @@ func (m *QueryActivatedHeightRequest) Reset() { *m = QueryActivatedHeigh func (m *QueryActivatedHeightRequest) String() string { return proto.CompactTextString(m) } func (*QueryActivatedHeightRequest) ProtoMessage() {} func (*QueryActivatedHeightRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_74d49d26f7429697, []int{14} + return fileDescriptor_74d49d26f7429697, []int{16} } func (m *QueryActivatedHeightRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -811,7 +905,7 @@ func (m *QueryActivatedHeightResponse) Reset() { *m = QueryActivatedHeig func (m *QueryActivatedHeightResponse) String() string { return proto.CompactTextString(m) } func (*QueryActivatedHeightResponse) ProtoMessage() {} func (*QueryActivatedHeightResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_74d49d26f7429697, []int{15} + return fileDescriptor_74d49d26f7429697, []int{17} } func (m *QueryActivatedHeightResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -864,7 +958,7 @@ func (m *QueryFinalityProviderDelegationsRequest) Reset() { func (m *QueryFinalityProviderDelegationsRequest) String() string { return proto.CompactTextString(m) } func (*QueryFinalityProviderDelegationsRequest) ProtoMessage() {} func (*QueryFinalityProviderDelegationsRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_74d49d26f7429697, []int{16} + return fileDescriptor_74d49d26f7429697, []int{18} } func (m *QueryFinalityProviderDelegationsRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -911,7 +1005,7 @@ func (m *QueryFinalityProviderDelegationsRequest) GetPagination() *query.PageReq // Query/FinalityProviderDelegations RPC method. type QueryFinalityProviderDelegationsResponse struct { // btc_delegator_delegations contains all the queried BTC delegations. - BtcDelegatorDelegations []*BTCDelegatorDelegations `protobuf:"bytes,1,rep,name=btc_delegator_delegations,json=btcDelegatorDelegations,proto3" json:"btc_delegator_delegations,omitempty"` + 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"` } @@ -922,7 +1016,7 @@ func (m *QueryFinalityProviderDelegationsResponse) Reset() { func (m *QueryFinalityProviderDelegationsResponse) String() string { return proto.CompactTextString(m) } func (*QueryFinalityProviderDelegationsResponse) ProtoMessage() {} func (*QueryFinalityProviderDelegationsResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_74d49d26f7429697, []int{17} + return fileDescriptor_74d49d26f7429697, []int{19} } func (m *QueryFinalityProviderDelegationsResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -951,7 +1045,7 @@ func (m *QueryFinalityProviderDelegationsResponse) XXX_DiscardUnknown() { var xxx_messageInfo_QueryFinalityProviderDelegationsResponse proto.InternalMessageInfo -func (m *QueryFinalityProviderDelegationsResponse) GetBtcDelegatorDelegations() []*BTCDelegatorDelegations { +func (m *QueryFinalityProviderDelegationsResponse) GetBtcDelegatorDelegations() []*BTCDelegatorDelegationsResponse { if m != nil { return m.BtcDelegatorDelegations } @@ -976,7 +1070,7 @@ func (m *QueryBTCDelegationRequest) Reset() { *m = QueryBTCDelegationReq func (m *QueryBTCDelegationRequest) String() string { return proto.CompactTextString(m) } func (*QueryBTCDelegationRequest) ProtoMessage() {} func (*QueryBTCDelegationRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_74d49d26f7429697, []int{18} + return fileDescriptor_74d49d26f7429697, []int{20} } func (m *QueryBTCDelegationRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -1015,48 +1109,108 @@ func (m *QueryBTCDelegationRequest) GetStakingTxHashHex() string { // 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 *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 *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) +} + +var xxx_messageInfo_QueryBTCDelegationResponse proto.InternalMessageInfo + +func (m *QueryBTCDelegationResponse) GetBtcDelegation() *BTCDelegationResponse { + if m != nil { + return m.BtcDelegation + } + 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_babylonchain_babylon_types.BIP340PubKey `protobuf:"bytes,1,opt,name=btc_pk,json=btcPk,proto3,customtype=github.com/babylonchain/babylon/types.BIP340PubKey" json:"btc_pk,omitempty"` + 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_babylonchain_babylon_types.BIP340PubKey `protobuf:"bytes,2,rep,name=fp_btc_pk_list,json=fpBtcPkList,proto3,customtype=github.com/babylonchain/babylon/types.BIP340PubKey" json:"fp_btc_pk_list,omitempty"` + 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,3,opt,name=start_height,json=startHeight,proto3" json:"start_height,omitempty"` + 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,4,opt,name=end_height,json=endHeight,proto3" json:"end_height,omitempty"` + 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,5,opt,name=total_sat,json=totalSat,proto3" json:"total_sat,omitempty"` + 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,6,opt,name=staking_tx_hex,json=stakingTxHex,proto3" json:"staking_tx_hex,omitempty"` + 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,7,rep,name=covenant_sigs,json=covenantSigs,proto3" json:"covenant_sigs,omitempty"` + 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,8,opt,name=active,proto3" json:"active,omitempty"` + 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,9,opt,name=unbonding_time,json=unbondingTime,proto3" json:"unbonding_time,omitempty"` - // undelegation_info is the undelegation info of this delegation. - UndelegationInfo *BTCUndelegationInfo `protobuf:"bytes,10,opt,name=undelegation_info,json=undelegationInfo,proto3" json:"undelegation_info,omitempty"` + 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 *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{19} +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 *QueryBTCDelegationResponse) XXX_Unmarshal(b []byte) error { +func (m *BTCDelegationResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } -func (m *QueryBTCDelegationResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { +func (m *BTCDelegationResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { - return xxx_messageInfo_QueryBTCDelegationResponse.Marshal(b, m, deterministic) + return xxx_messageInfo_BTCDelegationResponse.Marshal(b, m, deterministic) } else { b = b[:cap(b)] n, err := m.MarshalToSizedBuffer(b) @@ -1066,227 +1220,579 @@ func (m *QueryBTCDelegationResponse) XXX_Marshal(b []byte, deterministic bool) ( return b[:n], nil } } -func (m *QueryBTCDelegationResponse) XXX_Merge(src proto.Message) { - xxx_messageInfo_QueryBTCDelegationResponse.Merge(m, src) +func (m *BTCDelegationResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_BTCDelegationResponse.Merge(m, src) } -func (m *QueryBTCDelegationResponse) XXX_Size() int { +func (m *BTCDelegationResponse) XXX_Size() int { return m.Size() } -func (m *QueryBTCDelegationResponse) XXX_DiscardUnknown() { - xxx_messageInfo_QueryBTCDelegationResponse.DiscardUnknown(m) +func (m *BTCDelegationResponse) XXX_DiscardUnknown() { + xxx_messageInfo_BTCDelegationResponse.DiscardUnknown(m) } -var xxx_messageInfo_QueryBTCDelegationResponse proto.InternalMessageInfo +var xxx_messageInfo_BTCDelegationResponse proto.InternalMessageInfo + +func (m *BTCDelegationResponse) GetStakerAddr() string { + if m != nil { + return m.StakerAddr + } + return "" +} -func (m *QueryBTCDelegationResponse) GetStartHeight() uint64 { +func (m *BTCDelegationResponse) GetStartHeight() uint64 { if m != nil { return m.StartHeight } return 0 } -func (m *QueryBTCDelegationResponse) GetEndHeight() uint64 { +func (m *BTCDelegationResponse) GetEndHeight() uint64 { if m != nil { return m.EndHeight } return 0 } -func (m *QueryBTCDelegationResponse) GetTotalSat() uint64 { +func (m *BTCDelegationResponse) GetTotalSat() uint64 { if m != nil { return m.TotalSat } return 0 } -func (m *QueryBTCDelegationResponse) GetStakingTxHex() string { +func (m *BTCDelegationResponse) GetStakingTxHex() string { if m != nil { return m.StakingTxHex } return "" } -func (m *QueryBTCDelegationResponse) GetCovenantSigs() []*CovenantAdaptorSignatures { +func (m *BTCDelegationResponse) GetSlashingTxHex() string { + if m != nil { + return m.SlashingTxHex + } + return "" +} + +func (m *BTCDelegationResponse) GetDelegatorSlashSigHex() string { + if m != nil { + return m.DelegatorSlashSigHex + } + return "" +} + +func (m *BTCDelegationResponse) GetCovenantSigs() []*CovenantAdaptorSignatures { if m != nil { return m.CovenantSigs } return nil } -func (m *QueryBTCDelegationResponse) GetActive() bool { +func (m *BTCDelegationResponse) GetStakingOutputIdx() uint32 { + if m != nil { + return m.StakingOutputIdx + } + return 0 +} + +func (m *BTCDelegationResponse) GetActive() bool { if m != nil { return m.Active } return false } -func (m *QueryBTCDelegationResponse) GetUnbondingTime() uint32 { +func (m *BTCDelegationResponse) GetStatusDesc() string { + if m != nil { + return m.StatusDesc + } + return "" +} + +func (m *BTCDelegationResponse) GetUnbondingTime() uint32 { if m != nil { return m.UnbondingTime } return 0 } -func (m *QueryBTCDelegationResponse) GetUndelegationInfo() *BTCUndelegationInfo { +func (m *BTCDelegationResponse) GetUndelegationResponse() *BTCUndelegationResponse { if m != nil { - return m.UndelegationInfo + return m.UndelegationResponse } return nil } -func init() { - proto.RegisterType((*QueryParamsRequest)(nil), "babylon.btcstaking.v1.QueryParamsRequest") - proto.RegisterType((*QueryParamsResponse)(nil), "babylon.btcstaking.v1.QueryParamsResponse") - 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") +func (m *BTCDelegationResponse) GetParamsVersion() uint32 { + if m != nil { + return m.ParamsVersion + } + return 0 } -func init() { proto.RegisterFile("babylon/btcstaking/v1/query.proto", fileDescriptor_74d49d26f7429697) } - -var fileDescriptor_74d49d26f7429697 = []byte{ - // 1333 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00,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0x68, 0xf5, 0x9c, 0x41, - 0x39, 0xc9, 0x69, 0x0e, 0x31, 0x2d, 0x5b, 0x04, 0xcb, 0x58, 0x25, 0x7a, 0x32, 0x87, 0xb8, 0x64, - 0x3b, 0xa8, 0x77, 0x2e, 0x3a, 0x26, 0x34, 0xa8, 0x88, 0x53, 0x8e, 0x03, 0x7e, 0xa7, 0xd9, 0xad, - 0x28, 0x92, 0x75, 0x7a, 0xbf, 0x46, 0x3d, 0xae, 0xe8, 0x70, 0xac, 0xed, 0xa9, 0xe7, 0x30, 0xdb, - 0xa3, 0xf8, 0x0d, 0x48, 0xf9, 0x4d, 0xd2, 0x68, 0x06, 0xcd, 0x8d, 0xe4, 0xa7, 0xd4, 0x48, 0x02, - 0x54, 0x3f, 0xad, 0x30, 0xf4, 0xe8, 0xc9, 0xf4, 0x80, 0x2e, 0x53, 0x14, 0x13, 0xa6, 0x44, 0xcd, - 0x6b, 0x96, 0x4d, 0xb6, 0x2c, 0xbe, 0x53, 0x74, 0x59, 0xdd, 0xda, 0xa4, 0x6e, 0xd0, 0x14, 0x5f, - 0x03, 0x68, 0x41, 0x95, 0x1d, 0xce, 0xa9, 0x3e, 0x2f, 0x6a, 0x93, 0x17, 0xd5, 0xe7, 0x5e, 0xf2, - 0xa2, 0x16, 0x89, 0x49, 0x65, 0xae, 0x1e, 0xca, 0x54, 0x7e, 0x40, 0x90, 0x8d, 0xeb, 0x24, 0x81, - 0xbc, 0x0b, 0xb8, 0x22, 0x0f, 0x4b, 0x4e, 0x70, 0x9a, 0x46, 0x33, 0x87, 0xe6, 0x46, 0xf2, 0xb3, - 0x31, 0xa0, 0x3a, 0xab, 0xe9, 0x93, 0x95, 0xce, 0xfa, 0xf8, 0x7a, 0x1b, 0x84, 0x41, 0x01, 0x61, - 0x76, 0x57, 0x08, 0xfe, 0x50, 0x6d, 0x18, 0x96, 0xe1, 0x54, 0x24, 0x84, 0x80, 0xab, 0xd3, 0x30, - 0x56, 0x71, 0x4a, 0x06, 0x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- 0x3f, 0x7a, 0x9a, 0x45, 0x8f, 0x9f, 0x66, 0xd1, 0xef, 0x4f, 0xb3, 0xe8, 0xb3, 0x67, 0xd9, 0x81, - 0xc7, 0xcf, 0xb2, 0x03, 0xbf, 0x3c, 0xcb, 0x0e, 0xbc, 0xb7, 0xeb, 0x02, 0xd7, 0x08, 0x37, 0x14, - 0xdb, 0x9c, 0x91, 0x12, 0x7f, 0x2f, 0x5b, 0xfc, 0x2f, 0x00, 0x00, 0xff, 0xff, 0x2c, 0x11, 0x52, - 0x4c, 0x17, 0x14, 0x00, 0x00, +// 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"` } -// Reference imports to suppress errors if they are not otherwise used. -var _ context.Context -var _ grpc.ClientConn +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 (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) +} -// 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_BTCUndelegationResponse 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) - // 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) +func (m *BTCUndelegationResponse) GetUnbondingTxHex() string { + if m != nil { + return m.UnbondingTxHex + } + return "" } -type queryClient struct { - cc grpc1.ClientConn +func (m *BTCUndelegationResponse) GetDelegatorUnbondingSigHex() string { + if m != nil { + return m.DelegatorUnbondingSigHex + } + return "" } -func NewQueryClient(cc grpc1.ClientConn) QueryClient { +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 "" +} + +func (m *BTCUndelegationResponse) GetCovenantSlashingSigs() []*CovenantAdaptorSignatures { + if m != nil { + return m.CovenantSlashingSigs + } + return nil +} + +// 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 *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 (m *BTCDelegatorDelegationsResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +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 (m *BTCDelegatorDelegationsResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_BTCDelegatorDelegationsResponse.Merge(m, src) +} +func (m *BTCDelegatorDelegationsResponse) XXX_Size() int { + return m.Size() +} +func (m *BTCDelegatorDelegationsResponse) XXX_DiscardUnknown() { + xxx_messageInfo_BTCDelegatorDelegationsResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_BTCDelegatorDelegationsResponse proto.InternalMessageInfo + +func (m *BTCDelegatorDelegationsResponse) GetDels() []*BTCDelegationResponse { + if m != nil { + return m.Dels + } + return nil +} + +// 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"` + // sluggish defines whether the finality provider is detected sluggish + Sluggish bool `protobuf:"varint,10,opt,name=sluggish,proto3" json:"sluggish,omitempty"` +} + +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 (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 + } + return nil +} + +func (m *FinalityProviderResponse) GetAddr() string { + if m != nil { + return m.Addr + } + return "" +} + +func (m *FinalityProviderResponse) GetPop() *ProofOfPossessionBTC { + if m != nil { + return m.Pop + } + return nil +} + +func (m *FinalityProviderResponse) GetSlashedBabylonHeight() uint64 { + if m != nil { + return m.SlashedBabylonHeight + } + return 0 +} + +func (m *FinalityProviderResponse) GetSlashedBtcHeight() uint64 { + if m != nil { + return m.SlashedBtcHeight + } + return 0 +} + +func (m *FinalityProviderResponse) GetHeight() uint64 { + if m != nil { + return m.Height + } + return 0 +} + +func (m *FinalityProviderResponse) GetVotingPower() uint64 { + if m != nil { + return m.VotingPower + } + return 0 +} + +func (m *FinalityProviderResponse) GetSluggish() bool { + if m != nil { + return m.Sluggish + } + 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{ + // 1889 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, 0xb1, 0x7f, 0xd9, 0x8e, 0x33, 0xeb, 0x24, 0x8c, 0x1c, 0xdb, 0x09, 0x9b, + 0x4d, 0x9c, 0x87, 0xc5, 0x58,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0x7f, 0x7b, + 0xbb, 0x78, 0xe2, 0x07, 0x43, 0x7c, 0xf0, 0xb5, 0xe3, 0x2e, 0xf9, 0xd7, 0x5f, 0x35, 0xcb, 0xff, + 0xd7, 0x74, 0xe7, 0x7f, 0x01, 0x00, 0x00, 0xff, 0xff, 0x53, 0x66, 0x0a, 0xb8, 0xb5, 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} } @@ -1299,6 +1805,15 @@ func (c *queryClient) Params(ctx context.Context, in *QueryParamsRequest, opts . 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...) @@ -1384,6 +1899,8 @@ func (c *queryClient) BTCDelegation(ctx context.Context, in *QueryBTCDelegationR 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 @@ -1412,6 +1929,9 @@ 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") } @@ -1462,6 +1982,24 @@ func _Query_Params_Handler(srv interface{}, ctx context.Context, dec func(interf 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 { @@ -1632,6 +2170,10 @@ var _Query_serviceDesc = grpc.ServiceDesc{ MethodName: "Params", Handler: _Query_Params_Handler, }, + { + MethodName: "ParamsByVersion", + Handler: _Query_ParamsByVersion_Handler, + }, { MethodName: "FinalityProviders", Handler: _Query_FinalityProviders_Handler, @@ -1729,6 +2271,67 @@ func (m *QueryParamsResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { return len(dAtA) - i, nil } +func (m *QueryParamsByVersionRequest) 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 *QueryParamsByVersionRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryParamsByVersionRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.Version != 0 { + i = encodeVarintQuery(dAtA, i, uint64(m.Version)) + i-- + dAtA[i] = 0x8 + } + return len(dAtA) - i, nil +} + +func (m *QueryParamsByVersionResponse) 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 *QueryParamsByVersionResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryParamsByVersionResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + { + size, err := m.Params.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 *QueryFinalityProvidersRequest) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) @@ -2374,9 +2977,9 @@ func (m *QueryBTCDelegationResponse) MarshalToSizedBuffer(dAtA []byte) (int, err _ = i var l int _ = l - if m.UndelegationInfo != nil { + if m.BtcDelegation != nil { { - size, err := m.UndelegationInfo.MarshalToSizedBuffer(dAtA[:i]) + size, err := m.BtcDelegation.MarshalToSizedBuffer(dAtA[:i]) if err != nil { return 0, err } @@ -2384,12 +2987,61 @@ func (m *QueryBTCDelegationResponse) MarshalToSizedBuffer(dAtA []byte) (int, err i = encodeVarintQuery(dAtA, i, uint64(size)) } i-- - dAtA[i] = 0x52 - } - if m.UnbondingTime != 0 { - i = encodeVarintQuery(dAtA, i, uint64(m.UnbondingTime)) - i-- - dAtA[i] = 0x48 + 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 + } + 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 } if m.Active { i-- @@ -2399,7 +3051,12 @@ func (m *QueryBTCDelegationResponse) MarshalToSizedBuffer(dAtA []byte) (int, err dAtA[i] = 0 } i-- - dAtA[i] = 0x40 + dAtA[i] = 0x60 + } + if m.StakingOutputIdx != 0 { + i = encodeVarintQuery(dAtA, i, uint64(m.StakingOutputIdx)) + i-- + dAtA[i] = 0x58 } if len(m.CovenantSigs) > 0 { for iNdEx := len(m.CovenantSigs) - 1; iNdEx >= 0; iNdEx-- { @@ -2412,30 +3069,44 @@ func (m *QueryBTCDelegationResponse) MarshalToSizedBuffer(dAtA []byte) (int, err i = encodeVarintQuery(dAtA, i, uint64(size)) } i-- - dAtA[i] = 0x3a + dAtA[i] = 0x52 } } + if len(m.DelegatorSlashSigHex) > 0 { + i -= len(m.DelegatorSlashSigHex) + copy(dAtA[i:], m.DelegatorSlashSigHex) + i = encodeVarintQuery(dAtA, i, uint64(len(m.DelegatorSlashSigHex))) + i-- + dAtA[i] = 0x4a + } + 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 + } 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] = 0x32 + dAtA[i] = 0x3a } if m.TotalSat != 0 { i = encodeVarintQuery(dAtA, i, uint64(m.TotalSat)) i-- - dAtA[i] = 0x28 + dAtA[i] = 0x30 } if m.EndHeight != 0 { i = encodeVarintQuery(dAtA, i, uint64(m.EndHeight)) i-- - dAtA[i] = 0x20 + dAtA[i] = 0x28 } if m.StartHeight != 0 { i = encodeVarintQuery(dAtA, i, uint64(m.StartHeight)) i-- - dAtA[i] = 0x18 + dAtA[i] = 0x20 } if len(m.FpBtcPkList) > 0 { for iNdEx := len(m.FpBtcPkList) - 1; iNdEx >= 0; iNdEx-- { @@ -2448,8 +3119,208 @@ func (m *QueryBTCDelegationResponse) MarshalToSizedBuffer(dAtA []byte) (int, err i = encodeVarintQuery(dAtA, i, uint64(size)) } i-- - dAtA[i] = 0x12 + dAtA[i] = 0x1a + } + } + if m.BtcPk != nil { + { + size := m.BtcPk.Size() + i -= size + if _, err := m.BtcPk.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + } + if len(m.StakerAddr) > 0 { + i -= len(m.StakerAddr) + copy(dAtA[i:], m.StakerAddr) + i = encodeVarintQuery(dAtA, i, uint64(len(m.StakerAddr))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *BTCUndelegationResponse) 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 *BTCUndelegationResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *BTCUndelegationResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.CovenantSlashingSigs) > 0 { + for iNdEx := len(m.CovenantSlashingSigs) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.CovenantSlashingSigs[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x32 + } + } + if len(m.DelegatorSlashingSigHex) > 0 { + i -= len(m.DelegatorSlashingSigHex) + copy(dAtA[i:], m.DelegatorSlashingSigHex) + i = encodeVarintQuery(dAtA, i, uint64(len(m.DelegatorSlashingSigHex))) + i-- + dAtA[i] = 0x2a + } + 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 + } + if len(m.CovenantUnbondingSigList) > 0 { + for iNdEx := len(m.CovenantUnbondingSigList) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.CovenantUnbondingSigList[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x1a + } + } + 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) + i = encodeVarintQuery(dAtA, i, uint64(len(m.UnbondingTxHex))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *BTCDelegatorDelegationsResponse) 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 *BTCDelegatorDelegationsResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *BTCDelegatorDelegationsResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Dels) > 0 { + for iNdEx := len(m.Dels) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.Dels[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 *FinalityProviderResponse) 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 *FinalityProviderResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *FinalityProviderResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.Sluggish { + i-- + if m.Sluggish { + dAtA[i] = 1 + } else { + 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 { + i = encodeVarintQuery(dAtA, i, uint64(m.Height)) + i-- + dAtA[i] = 0x40 + } + if m.SlashedBtcHeight != 0 { + i = encodeVarintQuery(dAtA, i, uint64(m.SlashedBtcHeight)) + i-- + dAtA[i] = 0x38 + } + if m.SlashedBabylonHeight != 0 { + i = encodeVarintQuery(dAtA, i, uint64(m.SlashedBabylonHeight)) + i-- + dAtA[i] = 0x30 + } + if m.Pop != nil { + { + size, err := m.Pop.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) } + i-- + dAtA[i] = 0x2a } if m.BtcPk != nil { { @@ -2461,6 +3332,37 @@ func (m *QueryBTCDelegationResponse) MarshalToSizedBuffer(dAtA []byte) (int, err i = encodeVarintQuery(dAtA, i, uint64(size)) } i-- + dAtA[i] = 0x22 + } + if len(m.Addr) > 0 { + i -= len(m.Addr) + copy(dAtA[i:], m.Addr) + i = encodeVarintQuery(dAtA, i, uint64(len(m.Addr))) + i-- + dAtA[i] = 0x1a + } + if m.Commission != nil { + { + size := m.Commission.Size() + i -= size + if _, err := m.Commission.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + } + if m.Description != nil { + { + size, err := m.Description.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 @@ -2497,6 +3399,29 @@ func (m *QueryParamsResponse) Size() (n int) { return n } +func (m *QueryParamsByVersionRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.Version != 0 { + n += 1 + sovQuery(uint64(m.Version)) + } + return n +} + +func (m *QueryParamsByVersionResponse) 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 *QueryFinalityProvidersRequest) Size() (n int) { if m == nil { return 0 @@ -2757,6 +3682,23 @@ func (m *QueryBTCDelegationResponse) Size() (n int) { } 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)) @@ -2780,22 +3722,136 @@ func (m *QueryBTCDelegationResponse) Size() (n int) { if l > 0 { n += 1 + l + sovQuery(uint64(l)) } + l = len(m.SlashingTxHex) + if l > 0 { + n += 1 + l + sovQuery(uint64(l)) + } + l = len(m.DelegatorSlashSigHex) + if l > 0 { + n += 1 + l + sovQuery(uint64(l)) + } if len(m.CovenantSigs) > 0 { for _, e := range m.CovenantSigs { l = e.Size() n += 1 + l + sovQuery(uint64(l)) } } + if m.StakingOutputIdx != 0 { + n += 1 + sovQuery(uint64(m.StakingOutputIdx)) + } if m.Active { n += 2 } - if m.UnbondingTime != 0 { - n += 1 + sovQuery(uint64(m.UnbondingTime)) + l = len(m.StatusDesc) + if l > 0 { + n += 1 + l + sovQuery(uint64(l)) + } + if m.UnbondingTime != 0 { + n += 1 + sovQuery(uint64(m.UnbondingTime)) + } + if m.UndelegationResponse != nil { + l = m.UndelegationResponse.Size() + n += 1 + l + sovQuery(uint64(l)) + } + if m.ParamsVersion != 0 { + n += 2 + sovQuery(uint64(m.ParamsVersion)) + } + return n +} + +func (m *BTCUndelegationResponse) 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) + 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) { + 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 +} + +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) + 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.UndelegationInfo != nil { - l = m.UndelegationInfo.Size() + 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.Sluggish { + n += 2 + } return n } @@ -2938,6 +3994,158 @@ func (m *QueryParamsResponse) Unmarshal(dAtA []byte) error { } 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 @@ -3082,7 +4290,7 @@ func (m *QueryFinalityProvidersResponse) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.FinalityProviders = append(m.FinalityProviders, &FinalityProvider{}) + m.FinalityProviders = append(m.FinalityProviders, &FinalityProviderResponse{}) if err := m.FinalityProviders[len(m.FinalityProviders)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } @@ -3285,7 +4493,7 @@ func (m *QueryFinalityProviderResponse) Unmarshal(dAtA []byte) error { return io.ErrUnexpectedEOF } if m.FinalityProvider == nil { - m.FinalityProvider = &FinalityProvider{} + m.FinalityProvider = &FinalityProviderResponse{} } if err := m.FinalityProvider.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err @@ -3475,7 +4683,7 @@ func (m *QueryBTCDelegationsResponse) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.BtcDelegations = append(m.BtcDelegations, &BTCDelegation{}) + m.BtcDelegations = append(m.BtcDelegations, &BTCDelegationResponse{}) if err := m.BtcDelegations[len(m.BtcDelegations)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } @@ -4397,7 +5605,7 @@ func (m *QueryFinalityProviderDelegationsResponse) Unmarshal(dAtA []byte) error if postIndex > l { return io.ErrUnexpectedEOF } - m.BtcDelegatorDelegations = append(m.BtcDelegatorDelegations, &BTCDelegatorDelegations{}) + m.BtcDelegatorDelegations = append(m.BtcDelegatorDelegations, &BTCDelegatorDelegationsResponse{}) if err := m.BtcDelegatorDelegations[len(m.BtcDelegatorDelegations)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } @@ -4572,9 +5780,9 @@ func (m *QueryBTCDelegationResponse) Unmarshal(dAtA []byte) error { switch fieldNum { case 1: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field BtcPk", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field BtcDelegation", wireType) } - var byteLen int + var msglen int for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowQuery @@ -4584,45 +5792,163 @@ func (m *QueryBTCDelegationResponse) 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 } - var v github_com_babylonchain_babylon_types.BIP340PubKey - m.BtcPk = &v - if err := m.BtcPk.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + if m.BtcDelegation == nil { + m.BtcDelegation = &BTCDelegationResponse{} + } + if err := m.BtcDelegation.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } iNdEx = postIndex - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field FpBtcPkList", wireType) + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err } - 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 (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 *BTCDelegationResponse) 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: BTCDelegationResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: BTCDelegationResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + 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 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.StakerAddr = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + 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 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 + } + 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 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field FpBtcPkList", 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 @@ -4634,13 +5960,13 @@ func (m *QueryBTCDelegationResponse) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - var v github_com_babylonchain_babylon_types.BIP340PubKey + var v github_com_babylonlabs_io_babylon_types.BIP340PubKey m.FpBtcPkList = append(m.FpBtcPkList, v) if err := m.FpBtcPkList[len(m.FpBtcPkList)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } iNdEx = postIndex - case 3: + case 4: if wireType != 0 { return fmt.Errorf("proto: wrong wireType = %d for field StartHeight", wireType) } @@ -4659,7 +5985,7 @@ func (m *QueryBTCDelegationResponse) Unmarshal(dAtA []byte) error { break } } - case 4: + case 5: if wireType != 0 { return fmt.Errorf("proto: wrong wireType = %d for field EndHeight", wireType) } @@ -4678,7 +6004,7 @@ func (m *QueryBTCDelegationResponse) Unmarshal(dAtA []byte) error { break } } - case 5: + case 6: if wireType != 0 { return fmt.Errorf("proto: wrong wireType = %d for field TotalSat", wireType) } @@ -4697,7 +6023,7 @@ func (m *QueryBTCDelegationResponse) Unmarshal(dAtA []byte) error { break } } - case 6: + case 7: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field StakingTxHex", wireType) } @@ -4729,7 +6055,71 @@ func (m *QueryBTCDelegationResponse) Unmarshal(dAtA []byte) error { } m.StakingTxHex = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex - case 7: + case 8: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field SlashingTxHex", 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.SlashingTxHex = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 9: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field DelegatorSlashSigHex", 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.DelegatorSlashSigHex = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 10: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field CovenantSigs", wireType) } @@ -4763,7 +6153,26 @@ func (m *QueryBTCDelegationResponse) Unmarshal(dAtA []byte) error { return err } iNdEx = postIndex - case 8: + case 11: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field StakingOutputIdx", wireType) + } + m.StakingOutputIdx = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.StakingOutputIdx |= uint32(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 12: if wireType != 0 { return fmt.Errorf("proto: wrong wireType = %d for field Active", wireType) } @@ -4783,7 +6192,39 @@ func (m *QueryBTCDelegationResponse) Unmarshal(dAtA []byte) error { } } m.Active = bool(v != 0) - case 9: + case 13: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field StatusDesc", 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.StatusDesc = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 14: if wireType != 0 { return fmt.Errorf("proto: wrong wireType = %d for field UnbondingTime", wireType) } @@ -4802,9 +6243,9 @@ func (m *QueryBTCDelegationResponse) Unmarshal(dAtA []byte) error { break } } - case 10: + case 15: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field UndelegationInfo", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field UndelegationResponse", wireType) } var msglen int for shift := uint(0); ; shift += 7 { @@ -4831,13 +6272,683 @@ func (m *QueryBTCDelegationResponse) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - if m.UndelegationInfo == nil { - m.UndelegationInfo = &BTCUndelegationInfo{} + if m.UndelegationResponse == nil { + m.UndelegationResponse = &BTCUndelegationResponse{} } - if err := m.UndelegationInfo.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + if err := m.UndelegationResponse.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } iNdEx = postIndex + case 16: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field ParamsVersion", wireType) + } + m.ParamsVersion = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.ParamsVersion |= 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 *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 UnbondingTxHex", 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.UnbondingTxHex = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field DelegatorUnbondingSigHex", 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.DelegatorUnbondingSigHex = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field CovenantUnbondingSigList", 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.CovenantUnbondingSigList = append(m.CovenantUnbondingSigList, &SignatureInfo{}) + if err := m.CovenantUnbondingSigList[len(m.CovenantUnbondingSigList)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field SlashingTxHex", 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.SlashingTxHex = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 5: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field DelegatorSlashingSigHex", 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.DelegatorSlashingSigHex = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 6: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field CovenantSlashingSigs", 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.CovenantSlashingSigs = append(m.CovenantSlashingSigs, &CovenantAdaptorSignatures{}) + if err := m.CovenantSlashingSigs[len(m.CovenantSlashingSigs)-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 *BTCDelegatorDelegationsResponse) 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: BTCDelegatorDelegationsResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: BTCDelegatorDelegationsResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Dels", 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.Dels = append(m.Dels, &BTCDelegationResponse{}) + if err := m.Dels[len(m.Dels)-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 *FinalityProviderResponse) 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: FinalityProviderResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: FinalityProviderResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Description", 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.Description == nil { + m.Description = &types.Description{} + } + if err := m.Description.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + 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 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 cosmossdk_io_math.LegacyDec + m.Commission = &v + if err := m.Commission.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 3: + 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 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.Addr = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 4: + 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 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 + } + 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 5: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Pop", 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.Pop == nil { + m.Pop = &ProofOfPossessionBTC{} + } + if err := m.Pop.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 6: + 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 7: + 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 |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 8: + 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 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 Sluggish", 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.Sluggish = bool(v != 0) default: iNdEx = preIndex skippy, err := skipQuery(dAtA[iNdEx:]) diff --git a/x/btcstaking/types/query.pb.gw.go b/x/btcstaking/types/query.pb.gw.go index 01da4f93d..532fbec7f 100644 --- a/x/btcstaking/types/query.pb.gw.go +++ b/x/btcstaking/types/query.pb.gw.go @@ -51,6 +51,60 @@ func local_request_Query_Params_0(ctx context.Context, marshaler runtime.Marshal } +func request_Query_ParamsByVersion_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryParamsByVersionRequest + var metadata runtime.ServerMetadata + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["version"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "version") + } + + protoReq.Version, err = runtime.Uint32(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "version", err) + } + + msg, err := client.ParamsByVersion(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_Query_ParamsByVersion_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryParamsByVersionRequest + var metadata runtime.ServerMetadata + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["version"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "version") + } + + protoReq.Version, err = runtime.Uint32(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "version", err) + } + + msg, err := server.ParamsByVersion(ctx, &protoReq) + return msg, metadata, err + +} + var ( filter_Query_FinalityProviders_0 = &utilities.DoubleArray{Encoding: map[string]int{}, Base: []int(nil), Check: []int(nil)} ) @@ -552,6 +606,29 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv }) + mux.Handle("GET", pattern_Query_ParamsByVersion_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_ParamsByVersion_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_ParamsByVersion_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + mux.Handle("GET", pattern_Query_FinalityProviders_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() @@ -820,6 +897,26 @@ func RegisterQueryHandlerClient(ctx context.Context, mux *runtime.ServeMux, clie }) + mux.Handle("GET", pattern_Query_ParamsByVersion_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_ParamsByVersion_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_ParamsByVersion_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + mux.Handle("GET", pattern_Query_FinalityProviders_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() @@ -1006,6 +1103,8 @@ 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", "btcstaking", "v1", "params"}, "", runtime.AssumeColonVerbOpt(false))) + pattern_Query_ParamsByVersion_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", "params", "version"}, "", runtime.AssumeColonVerbOpt(false))) + pattern_Query_FinalityProviders_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"babylon", "btcstaking", "v1", "finality_providers"}, "", runtime.AssumeColonVerbOpt(false))) 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))) @@ -1028,6 +1127,8 @@ var ( var ( forward_Query_Params_0 = runtime.ForwardResponseMessage + forward_Query_ParamsByVersion_0 = runtime.ForwardResponseMessage + forward_Query_FinalityProviders_0 = runtime.ForwardResponseMessage forward_Query_FinalityProvider_0 = runtime.ForwardResponseMessage diff --git a/x/btcstaking/types/tx.pb.go b/x/btcstaking/types/tx.pb.go index be9cf29ba..316cac6f8 100644 --- a/x/btcstaking/types/tx.pb.go +++ b/x/btcstaking/types/tx.pb.go @@ -7,10 +7,9 @@ import ( context "context" cosmossdk_io_math "cosmossdk.io/math" fmt "fmt" - github_com_babylonchain_babylon_types "github.com/babylonchain/babylon/types" - types1 "github.com/babylonchain/babylon/x/btccheckpoint/types" + 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" - secp256k1 "github.com/cosmos/cosmos-sdk/crypto/keys/secp256k1" _ "github.com/cosmos/cosmos-sdk/types/msgservice" types "github.com/cosmos/cosmos-sdk/x/staking/types" _ "github.com/cosmos/gogoproto/gogoproto" @@ -37,18 +36,18 @@ const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package // MsgCreateFinalityProvider is the message for creating a finality provider type MsgCreateFinalityProvider struct { - Signer string `protobuf:"bytes,1,opt,name=signer,proto3" json:"signer,omitempty"` - // description defines the description terms for the finality provider. + // addr defines the address of the finality provider that will receive + // the commissions to all the delegations. + Addr string `protobuf:"bytes,1,opt,name=addr,proto3" json:"addr,omitempty"` + // description defines the description terms for the finality provider Description *types.Description `protobuf:"bytes,2,opt,name=description,proto3" json:"description,omitempty"` - // commission defines the commission rate of finality provider. + // commission defines the commission rate of the finality provider Commission *cosmossdk_io_math.LegacyDec `protobuf:"bytes,3,opt,name=commission,proto3,customtype=cosmossdk.io/math.LegacyDec" json:"commission,omitempty"` - // babylon_pk is the Babylon secp256k1 PK of this finality provider - BabylonPk *secp256k1.PubKey `protobuf:"bytes,4,opt,name=babylon_pk,json=babylonPk,proto3" json:"babylon_pk,omitempty"` // btc_pk is the Bitcoin secp256k1 PK of this finality provider // the PK follows encoding in BIP-340 spec - BtcPk *github_com_babylonchain_babylon_types.BIP340PubKey `protobuf:"bytes,5,opt,name=btc_pk,json=btcPk,proto3,customtype=github.com/babylonchain/babylon/types.BIP340PubKey" json:"btc_pk,omitempty"` - // pop is the proof of possession of babylon_pk and btc_pk - Pop *ProofOfPossession `protobuf:"bytes,6,opt,name=pop,proto3" json:"pop,omitempty"` + 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 btc_pk over the FP signer address. + Pop *ProofOfPossessionBTC `protobuf:"bytes,5,opt,name=pop,proto3" json:"pop,omitempty"` } func (m *MsgCreateFinalityProvider) Reset() { *m = MsgCreateFinalityProvider{} } @@ -84,9 +83,9 @@ func (m *MsgCreateFinalityProvider) XXX_DiscardUnknown() { var xxx_messageInfo_MsgCreateFinalityProvider proto.InternalMessageInfo -func (m *MsgCreateFinalityProvider) GetSigner() string { +func (m *MsgCreateFinalityProvider) GetAddr() string { if m != nil { - return m.Signer + return m.Addr } return "" } @@ -98,14 +97,7 @@ func (m *MsgCreateFinalityProvider) GetDescription() *types.Description { return nil } -func (m *MsgCreateFinalityProvider) GetBabylonPk() *secp256k1.PubKey { - if m != nil { - return m.BabylonPk - } - return nil -} - -func (m *MsgCreateFinalityProvider) GetPop() *ProofOfPossession { +func (m *MsgCreateFinalityProvider) GetPop() *ProofOfPossessionBTC { if m != nil { return m.Pop } @@ -149,57 +141,159 @@ func (m *MsgCreateFinalityProviderResponse) XXX_DiscardUnknown() { var xxx_messageInfo_MsgCreateFinalityProviderResponse proto.InternalMessageInfo +// MsgEditFinalityProvider is the message for editing an existing finality provider +type MsgEditFinalityProvider struct { + // addr the address of the finality provider that whishes to edit his information. + Addr string `protobuf:"bytes,1,opt,name=addr,proto3" json:"addr,omitempty"` + // btc_pk is the Bitcoin secp256k1 PK of the finality provider to be edited + BtcPk []byte `protobuf:"bytes,2,opt,name=btc_pk,json=btcPk,proto3" json:"btc_pk,omitempty"` + // description defines the updated description terms for the finality provider + Description *types.Description `protobuf:"bytes,3,opt,name=description,proto3" json:"description,omitempty"` + // commission defines the updated commission rate of the finality provider + Commission *cosmossdk_io_math.LegacyDec `protobuf:"bytes,4,opt,name=commission,proto3,customtype=cosmossdk.io/math.LegacyDec" json:"commission,omitempty"` +} + +func (m *MsgEditFinalityProvider) Reset() { *m = MsgEditFinalityProvider{} } +func (m *MsgEditFinalityProvider) String() string { return proto.CompactTextString(m) } +func (*MsgEditFinalityProvider) ProtoMessage() {} +func (*MsgEditFinalityProvider) Descriptor() ([]byte, []int) { + return fileDescriptor_4baddb53e97f38f2, []int{2} +} +func (m *MsgEditFinalityProvider) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgEditFinalityProvider) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgEditFinalityProvider.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 *MsgEditFinalityProvider) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgEditFinalityProvider.Merge(m, src) +} +func (m *MsgEditFinalityProvider) XXX_Size() int { + return m.Size() +} +func (m *MsgEditFinalityProvider) XXX_DiscardUnknown() { + xxx_messageInfo_MsgEditFinalityProvider.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgEditFinalityProvider proto.InternalMessageInfo + +func (m *MsgEditFinalityProvider) GetAddr() string { + if m != nil { + return m.Addr + } + return "" +} + +func (m *MsgEditFinalityProvider) GetBtcPk() []byte { + if m != nil { + return m.BtcPk + } + return nil +} + +func (m *MsgEditFinalityProvider) GetDescription() *types.Description { + if m != nil { + return m.Description + } + return nil +} + +// MsgEditFinalityProviderResponse is the response for MsgEditFinalityProvider +type MsgEditFinalityProviderResponse struct { +} + +func (m *MsgEditFinalityProviderResponse) Reset() { *m = MsgEditFinalityProviderResponse{} } +func (m *MsgEditFinalityProviderResponse) String() string { return proto.CompactTextString(m) } +func (*MsgEditFinalityProviderResponse) ProtoMessage() {} +func (*MsgEditFinalityProviderResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_4baddb53e97f38f2, []int{3} +} +func (m *MsgEditFinalityProviderResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgEditFinalityProviderResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgEditFinalityProviderResponse.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 *MsgEditFinalityProviderResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgEditFinalityProviderResponse.Merge(m, src) +} +func (m *MsgEditFinalityProviderResponse) XXX_Size() int { + return m.Size() +} +func (m *MsgEditFinalityProviderResponse) XXX_DiscardUnknown() { + xxx_messageInfo_MsgEditFinalityProviderResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgEditFinalityProviderResponse proto.InternalMessageInfo + // MsgCreateBTCDelegation is the message for creating a BTC delegation type MsgCreateBTCDelegation struct { - Signer string `protobuf:"bytes,1,opt,name=signer,proto3" json:"signer,omitempty"` - // babylon_pk is the Babylon secp256k1 PK of this BTC delegation - BabylonPk *secp256k1.PubKey `protobuf:"bytes,2,opt,name=babylon_pk,json=babylonPk,proto3" json:"babylon_pk,omitempty"` - // pop is the proof of possession of babylon_pk and btc_pk - Pop *ProofOfPossession `protobuf:"bytes,3,opt,name=pop,proto3" json:"pop,omitempty"` + // 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"` + // pop is the proof of possession of btc_pk by the staker_addr. + Pop *ProofOfPossessionBTC `protobuf:"bytes,2,opt,name=pop,proto3" json:"pop,omitempty"` // btc_pk is the Bitcoin secp256k1 PK of the BTC delegator - BtcPk *github_com_babylonchain_babylon_types.BIP340PubKey `protobuf:"bytes,4,opt,name=btc_pk,json=btcPk,proto3,customtype=github.com/babylonchain/babylon/types.BIP340PubKey" json:"btc_pk,omitempty"` + BtcPk *github_com_babylonlabs_io_babylon_types.BIP340PubKey `protobuf:"bytes,3,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 Bitcoin secp256k1 PKs of the finality providers, if there is more than one // finality provider pk it means that delegation is re-staked - FpBtcPkList []github_com_babylonchain_babylon_types.BIP340PubKey `protobuf:"bytes,5,rep,name=fp_btc_pk_list,json=fpBtcPkList,proto3,customtype=github.com/babylonchain/babylon/types.BIP340PubKey" json:"fp_btc_pk_list,omitempty"` + 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 time lock used in staking transaction - StakingTime uint32 `protobuf:"varint,6,opt,name=staking_time,json=stakingTime,proto3" json:"staking_time,omitempty"` + 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,7,opt,name=staking_value,json=stakingValue,proto3" json:"staking_value,omitempty"` + 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,8,opt,name=staking_tx,json=stakingTx,proto3" json:"staking_tx,omitempty"` + StakingTx *types1.TransactionInfo `protobuf:"bytes,7,opt,name=staking_tx,json=stakingTx,proto3" json:"staking_tx,omitempty"` // slashing_tx is the slashing tx // Note that the tx itself does not contain signatures, which are off-chain. - SlashingTx *BTCSlashingTx `protobuf:"bytes,9,opt,name=slashing_tx,json=slashingTx,proto3,customtype=BTCSlashingTx" json:"slashing_tx,omitempty"` + SlashingTx *BTCSlashingTx `protobuf:"bytes,8,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_babylonchain_babylon_types.BIP340Signature `protobuf:"bytes,10,opt,name=delegator_slashing_sig,json=delegatorSlashingSig,proto3,customtype=github.com/babylonchain/babylon/types.BIP340Signature" json:"delegator_slashing_sig,omitempty"` + 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"` // 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,11,opt,name=unbonding_time,json=unbondingTime,proto3" json:"unbonding_time,omitempty"` + UnbondingTime uint32 `protobuf:"varint,10,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,12,opt,name=unbonding_tx,json=unbondingTx,proto3" json:"unbonding_tx,omitempty"` + UnbondingTx []byte `protobuf:"bytes,11,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,13,opt,name=unbonding_value,json=unbondingValue,proto3" json:"unbonding_value,omitempty"` + UnbondingValue int64 `protobuf:"varint,12,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,14,opt,name=unbonding_slashing_tx,json=unbondingSlashingTx,proto3,customtype=BTCSlashingTx" json:"unbonding_slashing_tx,omitempty"` + UnbondingSlashingTx *BTCSlashingTx `protobuf:"bytes,13,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_babylonchain_babylon_types.BIP340Signature `protobuf:"bytes,15,opt,name=delegator_unbonding_slashing_sig,json=delegatorUnbondingSlashingSig,proto3,customtype=github.com/babylonchain/babylon/types.BIP340Signature" json:"delegator_unbonding_slashing_sig,omitempty"` + 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"` } func (m *MsgCreateBTCDelegation) Reset() { *m = MsgCreateBTCDelegation{} } func (m *MsgCreateBTCDelegation) String() string { return proto.CompactTextString(m) } func (*MsgCreateBTCDelegation) ProtoMessage() {} func (*MsgCreateBTCDelegation) Descriptor() ([]byte, []int) { - return fileDescriptor_4baddb53e97f38f2, []int{2} + return fileDescriptor_4baddb53e97f38f2, []int{4} } func (m *MsgCreateBTCDelegation) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -228,21 +322,14 @@ func (m *MsgCreateBTCDelegation) XXX_DiscardUnknown() { var xxx_messageInfo_MsgCreateBTCDelegation proto.InternalMessageInfo -func (m *MsgCreateBTCDelegation) GetSigner() string { +func (m *MsgCreateBTCDelegation) GetStakerAddr() string { if m != nil { - return m.Signer + return m.StakerAddr } return "" } -func (m *MsgCreateBTCDelegation) GetBabylonPk() *secp256k1.PubKey { - if m != nil { - return m.BabylonPk - } - return nil -} - -func (m *MsgCreateBTCDelegation) GetPop() *ProofOfPossession { +func (m *MsgCreateBTCDelegation) GetPop() *ProofOfPossessionBTC { if m != nil { return m.Pop } @@ -299,7 +386,7 @@ func (m *MsgCreateBTCDelegationResponse) Reset() { *m = MsgCreateBTCDele func (m *MsgCreateBTCDelegationResponse) String() string { return proto.CompactTextString(m) } func (*MsgCreateBTCDelegationResponse) ProtoMessage() {} func (*MsgCreateBTCDelegationResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_4baddb53e97f38f2, []int{3} + return fileDescriptor_4baddb53e97f38f2, []int{5} } func (m *MsgCreateBTCDelegationResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -332,7 +419,7 @@ var xxx_messageInfo_MsgCreateBTCDelegationResponse proto.InternalMessageInfo type MsgAddCovenantSigs struct { Signer string `protobuf:"bytes,1,opt,name=signer,proto3" json:"signer,omitempty"` // pk is the BTC public key of the covenant member - Pk *github_com_babylonchain_babylon_types.BIP340PubKey `protobuf:"bytes,2,opt,name=pk,proto3,customtype=github.com/babylonchain/babylon/types.BIP340PubKey" json:"pk,omitempty"` + Pk *github_com_babylonlabs_io_babylon_types.BIP340PubKey `protobuf:"bytes,2,opt,name=pk,proto3,customtype=github.com/babylonlabs-io/babylon/types.BIP340PubKey" json:"pk,omitempty"` // staking_tx_hash is the hash of the staking tx. // It uniquely identifies a BTC delegation StakingTxHash string `protobuf:"bytes,3,opt,name=staking_tx_hash,json=stakingTxHash,proto3" json:"staking_tx_hash,omitempty"` @@ -342,7 +429,7 @@ type MsgAddCovenantSigs struct { SlashingTxSigs [][]byte `protobuf:"bytes,4,rep,name=slashing_tx_sigs,json=slashingTxSigs,proto3" json:"slashing_tx_sigs,omitempty"` // unbonding_tx_sig is the signature of the covenant on the unbonding tx submitted to babylon // the signature follows encoding in BIP-340 spec - UnbondingTxSig *github_com_babylonchain_babylon_types.BIP340Signature `protobuf:"bytes,5,opt,name=unbonding_tx_sig,json=unbondingTxSig,proto3,customtype=github.com/babylonchain/babylon/types.BIP340Signature" json:"unbonding_tx_sig,omitempty"` + UnbondingTxSig *github_com_babylonlabs_io_babylon_types.BIP340Signature `protobuf:"bytes,5,opt,name=unbonding_tx_sig,json=unbondingTxSig,proto3,customtype=github.com/babylonlabs-io/babylon/types.BIP340Signature" json:"unbonding_tx_sig,omitempty"` // slashing_unbonding_tx_sigs is a list of adaptor signatures of the covenant // on slashing tx corresponding to unbonding tx submitted to babylon // the order of sigs should respect the order of finality providers @@ -354,7 +441,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{4} + return fileDescriptor_4baddb53e97f38f2, []int{6} } func (m *MsgAddCovenantSigs) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -419,7 +506,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{5} + return fileDescriptor_4baddb53e97f38f2, []int{7} } func (m *MsgAddCovenantSigsResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -458,14 +545,14 @@ type MsgBTCUndelegate struct { 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_babylonchain_babylon_types.BIP340Signature `protobuf:"bytes,3,opt,name=unbonding_tx_sig,json=unbondingTxSig,proto3,customtype=github.com/babylonchain/babylon/types.BIP340Signature" json:"unbonding_tx_sig,omitempty"` + 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"` } 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{6} + return fileDescriptor_4baddb53e97f38f2, []int{8} } func (m *MsgBTCUndelegate) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -516,7 +603,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{7} + return fileDescriptor_4baddb53e97f38f2, []int{9} } func (m *MsgBTCUndelegateResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -563,7 +650,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{8} + return fileDescriptor_4baddb53e97f38f2, []int{10} } func (m *MsgSelectiveSlashingEvidence) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -621,7 +708,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{9} + return fileDescriptor_4baddb53e97f38f2, []int{11} } func (m *MsgSelectiveSlashingEvidenceResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -667,7 +754,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{10} + return fileDescriptor_4baddb53e97f38f2, []int{12} } func (m *MsgUpdateParams) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -718,7 +805,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{11} + return fileDescriptor_4baddb53e97f38f2, []int{13} } func (m *MsgUpdateParamsResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -750,6 +837,8 @@ var xxx_messageInfo_MsgUpdateParamsResponse proto.InternalMessageInfo func init() { proto.RegisterType((*MsgCreateFinalityProvider)(nil), "babylon.btcstaking.v1.MsgCreateFinalityProvider") proto.RegisterType((*MsgCreateFinalityProviderResponse)(nil), "babylon.btcstaking.v1.MsgCreateFinalityProviderResponse") + proto.RegisterType((*MsgEditFinalityProvider)(nil), "babylon.btcstaking.v1.MsgEditFinalityProvider") + 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((*MsgAddCovenantSigs)(nil), "babylon.btcstaking.v1.MsgAddCovenantSigs") @@ -765,84 +854,86 @@ func init() { func init() { proto.RegisterFile("babylon/btcstaking/v1/tx.proto", fileDescriptor_4baddb53e97f38f2) } var fileDescriptor_4baddb53e97f38f2 = []byte{ - // 1224 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x57, 0xcf, 0x8f, 0xd3, 0xc6, - 0x17, 0x5f, 0x27, 0x9b, 0xf0, 0xdd, 0x97, 0x4d, 0x76, 0xbf, 0x06, 0x16, 0xaf, 0x0b, 0x49, 0x08, - 0x14, 0x02, 0xea, 0x3a, 0x64, 0x29, 0xa8, 0x05, 0xa9, 0x12, 0xd9, 0x05, 0x81, 0x4a, 0xd4, 0xc8, - 0xc9, 0xf6, 0xd0, 0x1e, 0x22, 0xc7, 0x99, 0x38, 0xa3, 0x24, 0x1e, 0xcb, 0x33, 0x89, 0x12, 0xf5, - 0x52, 0xa1, 0x5e, 0x2b, 0xf5, 0xd4, 0x43, 0x6f, 0xfd, 0x0f, 0x38, 0xf0, 0x27, 0xf4, 0xc0, 0x11, - 0x71, 0xaa, 0xb6, 0xd2, 0xaa, 0x82, 0x4a, 0xfc, 0x05, 0xbd, 0x57, 0xb6, 0xc7, 0x3f, 0x92, 0xc6, - 0x85, 0x65, 0xb9, 0xc5, 0x33, 0x9f, 0xf7, 0x79, 0xef, 0x7d, 0xde, 0x7b, 0x33, 0x13, 0xc8, 0x77, - 0xb4, 0xce, 0x6c, 0x48, 0xcc, 0x4a, 0x87, 0xe9, 0x94, 0x69, 0x03, 0x6c, 0x1a, 0x95, 0x49, 0xb5, - 0xc2, 0xa6, 0x8a, 0x65, 0x13, 0x46, 0xc4, 0xb3, 0x7c, 0x5f, 0x09, 0xf7, 0x95, 0x49, 0x55, 0x3e, - 0x63, 0x10, 0x83, 0xb8, 0x88, 0x8a, 0xf3, 0xcb, 0x03, 0xcb, 0xdb, 0x3a, 0xa1, 0x23, 0x42, 0xdb, - 0xde, 0x86, 0xf7, 0xc1, 0xb7, 0xce, 0x79, 0x5f, 0x95, 0x11, 0x75, 0xf9, 0x47, 0xd4, 0xe0, 0x1b, - 0x25, 0xbe, 0xa1, 0xdb, 0x33, 0x8b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xe5, 0x5b, 0xc7, 0x82, 0x07, 0xce, 0x09, 0x6c, 0x2c, 0x9e, 0x7c, 0xd7, 0xe2, 0x99, - 0x16, 0xa0, 0x72, 0xf5, 0x9d, 0xa1, 0x81, 0x43, 0x0c, 0xd9, 0xf9, 0xa1, 0xbe, 0x1a, 0xcf, 0x31, - 0x07, 0x94, 0x2b, 0xef, 0x08, 0x0c, 0x5c, 0xfd, 0x28, 0xc0, 0x76, 0xfc, 0x74, 0xdd, 0x8c, 0xa7, - 0x8b, 0x35, 0x92, 0xef, 0xbe, 0x87, 0x51, 0x10, 0x4f, 0x0f, 0xd6, 0xe7, 0xe6, 0xe4, 0x4a, 0x3c, - 0x59, 0x14, 0x27, 0x2b, 0xef, 0x86, 0xf3, 0xfd, 0xc8, 0xa9, 0xef, 0xdf, 0x3c, 0xbd, 0x2e, 0xd4, - 0x1e, 0x3f, 0x7f, 0x95, 0x17, 0x5e, 0xbc, 0xca, 0x0b, 0x7f, 0xbe, 0xca, 0x0b, 0x3f, 0xbd, 0xce, - 0xaf, 0xbc, 0x78, 0x9d, 0x5f, 0xf9, 0xfd, 0x75, 0x7e, 0xe5, 0x9b, 0xb7, 0xde, 0x59, 0xd3, 0xe8, - 0xdf, 0x1e, 0xf7, 0xd8, 0xeb, 0xa4, 0xdd, 0xbf, 0x3d, 0x37, 0xff, 0x09, 0x00, 0x00, 0xff, 0xff, - 0x14, 0xbd, 0x7a, 0x11, 0x36, 0x0e, 0x00, 0x00, + // 1263 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x57, 0xcf, 0x6f, 0x13, 0xc7, + 0x17, 0xcf, 0xda, 0x89, 0xf9, 0xe6, 0x39, 0x4e, 0xf2, 0x5d, 0x42, 0xd8, 0x6c, 0xc1, 0x76, 0x0c, + 0x85, 0x40, 0xc9, 0x9a, 0x00, 0xa5, 0x34, 0x51, 0x0f, 0x38, 0x09, 0x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, + 0x3b, 0x7a, 0xfe, 0x5e, 0x4b, 0x66, 0x3a, 0x02, 0x95, 0xd7, 0x8e, 0x0d, 0x0d, 0x1d, 0x62, 0xc8, + 0x0d, 0x1f, 0x2b, 0x57, 0x93, 0x39, 0x86, 0x80, 0x72, 0xf9, 0x98, 0xc0, 0xd0, 0xd5, 0x0f, 0x02, + 0x2c, 0x25, 0x4f, 0xf7, 0xed, 0x64, 0xba, 0x44, 0x23, 0x79, 0xe3, 0x1d, 0x8c, 0xc2, 0x78, 0x76, + 0x61, 0x66, 0x68, 0x4e, 0xaf, 0x24, 0x93, 0xc5, 0x71, 0xb2, 0x72, 0x3c, 0x5c, 0xe0, 0x47, 0x9e, + 0xfa, 0xf6, 0xcd, 0xd3, 0xeb, 0x42, 0xe5, 0xb3, 0xe7, 0xaf, 0xf2, 0xc2, 0x8b, 0x57, 0x79, 0xe1, + 0xf7, 0x57, 0x79, 0xe1, 0xc7, 0xd7, 0xf9, 0x89, 0x17, 0xaf, 0xf3, 0x13, 0xbf, 0xbd, 0xce, 0x4f, + 0x7c, 0x71, 0x8c, 0x9b, 0x73, 0x10, 0xff, 0xbf, 0xc9, 0x0f, 0xde, 0x56, 0x86, 0xff, 0xdf, 0xbc, + 0xfd, 0x4f, 0x00, 0x00, 0x00, 0xff, 0xff, 0x82, 0xd4, 0xb3, 0x90, 0x8b, 0x0f, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -859,6 +950,8 @@ const _ = grpc.SupportPackageIsVersion4 type MsgClient interface { // CreateFinalityProvider creates a new finality provider CreateFinalityProvider(ctx context.Context, in *MsgCreateFinalityProvider, opts ...grpc.CallOption) (*MsgCreateFinalityProviderResponse, error) + // EditFinalityProvider edits an existing finality provider + 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) // AddCovenantSigs handles signatures from a covenant member @@ -889,6 +982,15 @@ func (c *msgClient) CreateFinalityProvider(ctx context.Context, in *MsgCreateFin return out, nil } +func (c *msgClient) EditFinalityProvider(ctx context.Context, in *MsgEditFinalityProvider, opts ...grpc.CallOption) (*MsgEditFinalityProviderResponse, error) { + out := new(MsgEditFinalityProviderResponse) + err := c.cc.Invoke(ctx, "/babylon.btcstaking.v1.Msg/EditFinalityProvider", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + func (c *msgClient) CreateBTCDelegation(ctx context.Context, in *MsgCreateBTCDelegation, opts ...grpc.CallOption) (*MsgCreateBTCDelegationResponse, error) { out := new(MsgCreateBTCDelegationResponse) err := c.cc.Invoke(ctx, "/babylon.btcstaking.v1.Msg/CreateBTCDelegation", in, out, opts...) @@ -938,6 +1040,8 @@ func (c *msgClient) UpdateParams(ctx context.Context, in *MsgUpdateParams, opts type MsgServer interface { // CreateFinalityProvider creates a new finality provider CreateFinalityProvider(context.Context, *MsgCreateFinalityProvider) (*MsgCreateFinalityProviderResponse, error) + // EditFinalityProvider edits an existing finality provider + EditFinalityProvider(context.Context, *MsgEditFinalityProvider) (*MsgEditFinalityProviderResponse, error) // CreateBTCDelegation creates a new BTC delegation CreateBTCDelegation(context.Context, *MsgCreateBTCDelegation) (*MsgCreateBTCDelegationResponse, error) // AddCovenantSigs handles signatures from a covenant member @@ -958,6 +1062,9 @@ type UnimplementedMsgServer struct { func (*UnimplementedMsgServer) CreateFinalityProvider(ctx context.Context, req *MsgCreateFinalityProvider) (*MsgCreateFinalityProviderResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method CreateFinalityProvider not implemented") } +func (*UnimplementedMsgServer) EditFinalityProvider(ctx context.Context, req *MsgEditFinalityProvider) (*MsgEditFinalityProviderResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method EditFinalityProvider not implemented") +} func (*UnimplementedMsgServer) CreateBTCDelegation(ctx context.Context, req *MsgCreateBTCDelegation) (*MsgCreateBTCDelegationResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method CreateBTCDelegation not implemented") } @@ -996,6 +1103,24 @@ func _Msg_CreateFinalityProvider_Handler(srv interface{}, ctx context.Context, d return interceptor(ctx, in, info, handler) } +func _Msg_EditFinalityProvider_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(MsgEditFinalityProvider) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(MsgServer).EditFinalityProvider(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/babylon.btcstaking.v1.Msg/EditFinalityProvider", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(MsgServer).EditFinalityProvider(ctx, req.(*MsgEditFinalityProvider)) + } + return interceptor(ctx, in, info, handler) +} + func _Msg_CreateBTCDelegation_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { in := new(MsgCreateBTCDelegation) if err := dec(in); err != nil { @@ -1094,6 +1219,10 @@ var _Msg_serviceDesc = grpc.ServiceDesc{ MethodName: "CreateFinalityProvider", Handler: _Msg_CreateFinalityProvider_Handler, }, + { + MethodName: "EditFinalityProvider", + Handler: _Msg_EditFinalityProvider_Handler, + }, { MethodName: "CreateBTCDelegation", Handler: _Msg_CreateBTCDelegation_Handler, @@ -1149,7 +1278,7 @@ func (m *MsgCreateFinalityProvider) MarshalToSizedBuffer(dAtA []byte) (int, erro i = encodeVarintTx(dAtA, i, uint64(size)) } i-- - dAtA[i] = 0x32 + dAtA[i] = 0x2a } if m.BtcPk != nil { { @@ -1161,11 +1290,23 @@ func (m *MsgCreateFinalityProvider) MarshalToSizedBuffer(dAtA []byte) (int, erro i = encodeVarintTx(dAtA, i, uint64(size)) } i-- - dAtA[i] = 0x2a + dAtA[i] = 0x22 + } + if m.Commission != nil { + { + size := m.Commission.Size() + i -= size + if _, err := m.Commission.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintTx(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x1a } - if m.BabylonPk != nil { + if m.Description != nil { { - size, err := m.BabylonPk.MarshalToSizedBuffer(dAtA[:i]) + size, err := m.Description.MarshalToSizedBuffer(dAtA[:i]) if err != nil { return 0, err } @@ -1173,8 +1314,61 @@ func (m *MsgCreateFinalityProvider) MarshalToSizedBuffer(dAtA []byte) (int, erro i = encodeVarintTx(dAtA, i, uint64(size)) } i-- - dAtA[i] = 0x22 + dAtA[i] = 0x12 + } + if len(m.Addr) > 0 { + i -= len(m.Addr) + copy(dAtA[i:], m.Addr) + i = encodeVarintTx(dAtA, i, uint64(len(m.Addr))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *MsgCreateFinalityProviderResponse) 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 *MsgCreateFinalityProviderResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgCreateFinalityProviderResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + return len(dAtA) - i, nil +} + +func (m *MsgEditFinalityProvider) 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 *MsgEditFinalityProvider) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgEditFinalityProvider) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l if m.Commission != nil { { size := m.Commission.Size() @@ -1185,7 +1379,7 @@ func (m *MsgCreateFinalityProvider) MarshalToSizedBuffer(dAtA []byte) (int, erro i = encodeVarintTx(dAtA, i, uint64(size)) } i-- - dAtA[i] = 0x1a + dAtA[i] = 0x22 } if m.Description != nil { { @@ -1197,19 +1391,26 @@ func (m *MsgCreateFinalityProvider) MarshalToSizedBuffer(dAtA []byte) (int, erro i = encodeVarintTx(dAtA, i, uint64(size)) } i-- + dAtA[i] = 0x1a + } + if len(m.BtcPk) > 0 { + i -= len(m.BtcPk) + copy(dAtA[i:], m.BtcPk) + i = encodeVarintTx(dAtA, i, uint64(len(m.BtcPk))) + 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))) + if len(m.Addr) > 0 { + i -= len(m.Addr) + copy(dAtA[i:], m.Addr) + i = encodeVarintTx(dAtA, i, uint64(len(m.Addr))) i-- dAtA[i] = 0xa } return len(dAtA) - i, nil } -func (m *MsgCreateFinalityProviderResponse) Marshal() (dAtA []byte, err error) { +func (m *MsgEditFinalityProviderResponse) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalToSizedBuffer(dAtA[:size]) @@ -1219,12 +1420,12 @@ func (m *MsgCreateFinalityProviderResponse) Marshal() (dAtA []byte, err error) { return dAtA[:n], nil } -func (m *MsgCreateFinalityProviderResponse) MarshalTo(dAtA []byte) (int, error) { +func (m *MsgEditFinalityProviderResponse) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *MsgCreateFinalityProviderResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *MsgEditFinalityProviderResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) _ = i var l int @@ -1262,7 +1463,7 @@ func (m *MsgCreateBTCDelegation) MarshalToSizedBuffer(dAtA []byte) (int, error) i = encodeVarintTx(dAtA, i, uint64(size)) } i-- - dAtA[i] = 0x7a + dAtA[i] = 0x72 } if m.UnbondingSlashingTx != nil { { @@ -1274,24 +1475,24 @@ func (m *MsgCreateBTCDelegation) MarshalToSizedBuffer(dAtA []byte) (int, error) i = encodeVarintTx(dAtA, i, uint64(size)) } i-- - dAtA[i] = 0x72 + dAtA[i] = 0x6a } if m.UnbondingValue != 0 { i = encodeVarintTx(dAtA, i, uint64(m.UnbondingValue)) i-- - dAtA[i] = 0x68 + dAtA[i] = 0x60 } 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] = 0x62 + dAtA[i] = 0x5a } if m.UnbondingTime != 0 { i = encodeVarintTx(dAtA, i, uint64(m.UnbondingTime)) i-- - dAtA[i] = 0x58 + dAtA[i] = 0x50 } if m.DelegatorSlashingSig != nil { { @@ -1303,7 +1504,7 @@ func (m *MsgCreateBTCDelegation) MarshalToSizedBuffer(dAtA []byte) (int, error) i = encodeVarintTx(dAtA, i, uint64(size)) } i-- - dAtA[i] = 0x52 + dAtA[i] = 0x4a } if m.SlashingTx != nil { { @@ -1315,7 +1516,7 @@ func (m *MsgCreateBTCDelegation) MarshalToSizedBuffer(dAtA []byte) (int, error) i = encodeVarintTx(dAtA, i, uint64(size)) } i-- - dAtA[i] = 0x4a + dAtA[i] = 0x42 } if m.StakingTx != nil { { @@ -1327,17 +1528,17 @@ func (m *MsgCreateBTCDelegation) MarshalToSizedBuffer(dAtA []byte) (int, error) i = encodeVarintTx(dAtA, i, uint64(size)) } i-- - dAtA[i] = 0x42 + dAtA[i] = 0x3a } if m.StakingValue != 0 { i = encodeVarintTx(dAtA, i, uint64(m.StakingValue)) i-- - dAtA[i] = 0x38 + dAtA[i] = 0x30 } if m.StakingTime != 0 { i = encodeVarintTx(dAtA, i, uint64(m.StakingTime)) i-- - dAtA[i] = 0x30 + dAtA[i] = 0x28 } if len(m.FpBtcPkList) > 0 { for iNdEx := len(m.FpBtcPkList) - 1; iNdEx >= 0; iNdEx-- { @@ -1350,7 +1551,7 @@ func (m *MsgCreateBTCDelegation) MarshalToSizedBuffer(dAtA []byte) (int, error) i = encodeVarintTx(dAtA, i, uint64(size)) } i-- - dAtA[i] = 0x2a + dAtA[i] = 0x22 } } if m.BtcPk != nil { @@ -1363,7 +1564,7 @@ func (m *MsgCreateBTCDelegation) MarshalToSizedBuffer(dAtA []byte) (int, error) i = encodeVarintTx(dAtA, i, uint64(size)) } i-- - dAtA[i] = 0x22 + dAtA[i] = 0x1a } if m.Pop != nil { { @@ -1375,24 +1576,12 @@ func (m *MsgCreateBTCDelegation) MarshalToSizedBuffer(dAtA []byte) (int, error) i = encodeVarintTx(dAtA, i, uint64(size)) } i-- - dAtA[i] = 0x1a - } - if m.BabylonPk != nil { - { - size, err := m.BabylonPk.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintTx(dAtA, i, uint64(size)) - } - 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))) + if len(m.StakerAddr) > 0 { + i -= len(m.StakerAddr) + copy(dAtA[i:], m.StakerAddr) + i = encodeVarintTx(dAtA, i, uint64(len(m.StakerAddr))) i-- dAtA[i] = 0xa } @@ -1743,7 +1932,7 @@ func (m *MsgCreateFinalityProvider) Size() (n int) { } var l int _ = l - l = len(m.Signer) + l = len(m.Addr) if l > 0 { n += 1 + l + sovTx(uint64(l)) } @@ -1755,10 +1944,6 @@ func (m *MsgCreateFinalityProvider) Size() (n int) { l = m.Commission.Size() n += 1 + l + sovTx(uint64(l)) } - if m.BabylonPk != nil { - l = m.BabylonPk.Size() - n += 1 + l + sovTx(uint64(l)) - } if m.BtcPk != nil { l = m.BtcPk.Size() n += 1 + l + sovTx(uint64(l)) @@ -1779,18 +1964,48 @@ func (m *MsgCreateFinalityProviderResponse) Size() (n int) { return n } -func (m *MsgCreateBTCDelegation) Size() (n int) { +func (m *MsgEditFinalityProvider) Size() (n int) { if m == nil { return 0 } var l int _ = l - l = len(m.Signer) + l = len(m.Addr) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + l = len(m.BtcPk) if l > 0 { n += 1 + l + sovTx(uint64(l)) } - if m.BabylonPk != nil { - l = m.BabylonPk.Size() + if m.Description != nil { + l = m.Description.Size() + n += 1 + l + sovTx(uint64(l)) + } + if m.Commission != nil { + l = m.Commission.Size() + n += 1 + l + sovTx(uint64(l)) + } + return n +} + +func (m *MsgEditFinalityProviderResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + return n +} + +func (m *MsgCreateBTCDelegation) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.StakerAddr) + if l > 0 { n += 1 + l + sovTx(uint64(l)) } if m.Pop != nil { @@ -2022,7 +2237,7 @@ func (m *MsgCreateFinalityProvider) Unmarshal(dAtA []byte) error { switch fieldNum { case 1: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Signer", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field Addr", wireType) } var stringLen uint64 for shift := uint(0); ; shift += 7 { @@ -2050,7 +2265,7 @@ func (m *MsgCreateFinalityProvider) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.Signer = string(dAtA[iNdEx:postIndex]) + m.Addr = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex case 2: if wireType != 2 { @@ -2125,42 +2340,6 @@ func (m *MsgCreateFinalityProvider) Unmarshal(dAtA []byte) error { } iNdEx = postIndex case 4: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field BabylonPk", 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.BabylonPk == nil { - m.BabylonPk = &secp256k1.PubKey{} - } - if err := m.BabylonPk.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 5: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field BtcPk", wireType) } @@ -2189,13 +2368,13 @@ func (m *MsgCreateFinalityProvider) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - var v github_com_babylonchain_babylon_types.BIP340PubKey + 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 6: + case 5: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field Pop", wireType) } @@ -2225,7 +2404,7 @@ func (m *MsgCreateFinalityProvider) Unmarshal(dAtA []byte) error { return io.ErrUnexpectedEOF } if m.Pop == nil { - m.Pop = &ProofOfPossession{} + m.Pop = &ProofOfPossessionBTC{} } if err := m.Pop.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err @@ -2302,7 +2481,7 @@ func (m *MsgCreateFinalityProviderResponse) Unmarshal(dAtA []byte) error { } return nil } -func (m *MsgCreateBTCDelegation) Unmarshal(dAtA []byte) error { +func (m *MsgEditFinalityProvider) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -2325,15 +2504,15 @@ func (m *MsgCreateBTCDelegation) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: MsgCreateBTCDelegation: wiretype end group for non-group") + return fmt.Errorf("proto: MsgEditFinalityProvider: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: MsgCreateBTCDelegation: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: MsgEditFinalityProvider: 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) + return fmt.Errorf("proto: wrong wireType = %d for field Addr", wireType) } var stringLen uint64 for shift := uint(0); ; shift += 7 { @@ -2361,11 +2540,45 @@ func (m *MsgCreateBTCDelegation) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.Signer = string(dAtA[iNdEx:postIndex]) + m.Addr = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex case 2: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field BabylonPk", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field BtcPk", 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.BtcPk = append(m.BtcPk[:0], dAtA[iNdEx:postIndex]...) + if m.BtcPk == nil { + m.BtcPk = []byte{} + } + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Description", wireType) } var msglen int for shift := uint(0); ; shift += 7 { @@ -2392,14 +2605,182 @@ func (m *MsgCreateBTCDelegation) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - if m.BabylonPk == nil { - m.BabylonPk = &secp256k1.PubKey{} + if m.Description == nil { + m.Description = &types.Description{} } - if err := m.BabylonPk.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + if err := m.Description.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } iNdEx = postIndex - case 3: + case 4: + 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 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 + } + var v cosmossdk_io_math.LegacyDec + m.Commission = &v + if err := m.Commission.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 *MsgEditFinalityProviderResponse) 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: MsgEditFinalityProviderResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgEditFinalityProviderResponse: 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 *MsgCreateBTCDelegation) 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: MsgCreateBTCDelegation: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgCreateBTCDelegation: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + 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 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.StakerAddr = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field Pop", wireType) } @@ -2429,13 +2810,13 @@ func (m *MsgCreateBTCDelegation) Unmarshal(dAtA []byte) error { return io.ErrUnexpectedEOF } if m.Pop == nil { - m.Pop = &ProofOfPossession{} + m.Pop = &ProofOfPossessionBTC{} } if err := m.Pop.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } iNdEx = postIndex - case 4: + case 3: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field BtcPk", wireType) } @@ -2464,13 +2845,13 @@ func (m *MsgCreateBTCDelegation) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - var v github_com_babylonchain_babylon_types.BIP340PubKey + 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 5: + case 4: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field FpBtcPkList", wireType) } @@ -2499,13 +2880,13 @@ func (m *MsgCreateBTCDelegation) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - var v github_com_babylonchain_babylon_types.BIP340PubKey + var v github_com_babylonlabs_io_babylon_types.BIP340PubKey m.FpBtcPkList = append(m.FpBtcPkList, v) if err := m.FpBtcPkList[len(m.FpBtcPkList)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } iNdEx = postIndex - case 6: + case 5: if wireType != 0 { return fmt.Errorf("proto: wrong wireType = %d for field StakingTime", wireType) } @@ -2524,7 +2905,7 @@ func (m *MsgCreateBTCDelegation) Unmarshal(dAtA []byte) error { break } } - case 7: + case 6: if wireType != 0 { return fmt.Errorf("proto: wrong wireType = %d for field StakingValue", wireType) } @@ -2543,7 +2924,7 @@ func (m *MsgCreateBTCDelegation) Unmarshal(dAtA []byte) error { break } } - case 8: + case 7: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field StakingTx", wireType) } @@ -2579,7 +2960,7 @@ func (m *MsgCreateBTCDelegation) Unmarshal(dAtA []byte) error { return err } iNdEx = postIndex - case 9: + case 8: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field SlashingTx", wireType) } @@ -2614,7 +2995,7 @@ func (m *MsgCreateBTCDelegation) Unmarshal(dAtA []byte) error { return err } iNdEx = postIndex - case 10: + case 9: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field DelegatorSlashingSig", wireType) } @@ -2643,13 +3024,13 @@ func (m *MsgCreateBTCDelegation) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - var v github_com_babylonchain_babylon_types.BIP340Signature + var v github_com_babylonlabs_io_babylon_types.BIP340Signature m.DelegatorSlashingSig = &v if err := m.DelegatorSlashingSig.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } iNdEx = postIndex - case 11: + case 10: if wireType != 0 { return fmt.Errorf("proto: wrong wireType = %d for field UnbondingTime", wireType) } @@ -2668,7 +3049,7 @@ func (m *MsgCreateBTCDelegation) Unmarshal(dAtA []byte) error { break } } - case 12: + case 11: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field UnbondingTx", wireType) } @@ -2702,7 +3083,7 @@ func (m *MsgCreateBTCDelegation) Unmarshal(dAtA []byte) error { m.UnbondingTx = []byte{} } iNdEx = postIndex - case 13: + case 12: if wireType != 0 { return fmt.Errorf("proto: wrong wireType = %d for field UnbondingValue", wireType) } @@ -2721,7 +3102,7 @@ func (m *MsgCreateBTCDelegation) Unmarshal(dAtA []byte) error { break } } - case 14: + case 13: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field UnbondingSlashingTx", wireType) } @@ -2756,7 +3137,7 @@ func (m *MsgCreateBTCDelegation) Unmarshal(dAtA []byte) error { return err } iNdEx = postIndex - case 15: + case 14: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field DelegatorUnbondingSlashingSig", wireType) } @@ -2785,7 +3166,7 @@ func (m *MsgCreateBTCDelegation) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - var v github_com_babylonchain_babylon_types.BIP340Signature + var v github_com_babylonlabs_io_babylon_types.BIP340Signature m.DelegatorUnbondingSlashingSig = &v if err := m.DelegatorUnbondingSlashingSig.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err @@ -2952,7 +3333,7 @@ func (m *MsgAddCovenantSigs) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - var v github_com_babylonchain_babylon_types.BIP340PubKey + var v github_com_babylonlabs_io_babylon_types.BIP340PubKey m.Pk = &v if err := m.Pk.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err @@ -3051,7 +3432,7 @@ func (m *MsgAddCovenantSigs) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - var v github_com_babylonchain_babylon_types.BIP340Signature + var v github_com_babylonlabs_io_babylon_types.BIP340Signature m.UnbondingTxSig = &v if err := m.UnbondingTxSig.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err @@ -3282,7 +3663,7 @@ func (m *MsgBTCUndelegate) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - var v github_com_babylonchain_babylon_types.BIP340Signature + var v github_com_babylonlabs_io_babylon_types.BIP340Signature m.UnbondingTxSig = &v if err := m.UnbondingTxSig.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err diff --git a/x/checkpointing/README.md b/x/checkpointing/README.md index e95bfdc6d..565e5d467 100644 --- a/x/checkpointing/README.md +++ b/x/checkpointing/README.md @@ -102,7 +102,7 @@ message RawCheckpoint { // sigs bytes bls_multi_sig = 4 [ (gogoproto.customtype) = - "github.com/babylonchain/babylon/crypto/bls12381.Signature" ]; + "github.com/babylonlabs-io/babylon/crypto/bls12381.Signature" ]; } // RawCheckpointWithMeta wraps the raw checkpoint with metadata. @@ -115,7 +115,7 @@ message RawCheckpointWithMeta { // bls_aggr_pk defines the aggregated BLS public key bytes bls_aggr_pk = 3 [ (gogoproto.customtype) = - "github.com/babylonchain/babylon/crypto/bls12381.PublicKey" ]; + "github.com/babylonlabs-io/babylon/crypto/bls12381.PublicKey" ]; // power_sum defines the accumulated voting power for the checkpoint uint64 power_sum = 4; // lifecycle defines the lifecycle of this checkpoint, i.e., each state @@ -300,7 +300,7 @@ message VoteExtension { // bls_sig is the BLS signature bytes bls_sig = 6 [ (gogoproto.customtype) = - "github.com/babylonchain/babylon/crypto/bls12381.Signature" ]; + "github.com/babylonlabs-io/babylon/crypto/bls12381.Signature" ]; } ``` diff --git a/x/checkpointing/abci.go b/x/checkpointing/abci.go index 15f5d4db9..760fbf895 100644 --- a/x/checkpointing/abci.go +++ b/x/checkpointing/abci.go @@ -5,9 +5,9 @@ import ( "fmt" "time" - "github.com/babylonchain/babylon/x/checkpointing/types" + "github.com/babylonlabs-io/babylon/x/checkpointing/types" - "github.com/babylonchain/babylon/x/checkpointing/keeper" + "github.com/babylonlabs-io/babylon/x/checkpointing/keeper" "github.com/cosmos/cosmos-sdk/telemetry" ) diff --git a/x/checkpointing/client/cli/query.go b/x/checkpointing/client/cli/query.go index 5b1184ad6..fa5b4d59a 100644 --- a/x/checkpointing/client/cli/query.go +++ b/x/checkpointing/client/cli/query.go @@ -12,7 +12,7 @@ import ( "github.com/cosmos/cosmos-sdk/client" - "github.com/babylonchain/babylon/x/checkpointing/types" + "github.com/babylonlabs-io/babylon/x/checkpointing/types" ) // GetQueryCmd returns the cli query commands for this module @@ -80,12 +80,12 @@ func CmdRawCheckpoint() *cobra.Command { queryClient := types.NewQueryClient(clientCtx) - epoch_num, err := strconv.ParseUint(args[0], 10, 64) + epochNum, err := strconv.ParseUint(args[0], 10, 64) if err != nil { return err } - params := types.NewQueryRawCheckpointRequest(epoch_num) + params := types.NewQueryRawCheckpointRequest(epochNum) res, err := queryClient.RawCheckpoint(context.Background(), params) if err != nil { return err diff --git a/x/checkpointing/client/cli/tx.go b/x/checkpointing/client/cli/tx.go index 371caa21a..8de4578b0 100644 --- a/x/checkpointing/client/cli/tx.go +++ b/x/checkpointing/client/cli/tx.go @@ -9,7 +9,7 @@ import ( "cosmossdk.io/core/address" authcodec "github.com/cosmos/cosmos-sdk/x/auth/codec" - appparams "github.com/babylonchain/babylon/app/params" + appparams "github.com/babylonlabs-io/babylon/app/params" "github.com/cosmos/cosmos-sdk/client/flags" "github.com/cosmos/cosmos-sdk/client/tx" @@ -18,7 +18,7 @@ import ( "github.com/cosmos/cosmos-sdk/client" // "github.com/cosmos/cosmos-sdk/client/flags" - "github.com/babylonchain/babylon/x/checkpointing/types" + "github.com/babylonlabs-io/babylon/x/checkpointing/types" ) // GetTxCmd returns the transaction commands for this module diff --git a/x/checkpointing/client/cli/tx_test.go b/x/checkpointing/client/cli/tx_test.go index 1f35f1106..bee75d842 100644 --- a/x/checkpointing/client/cli/tx_test.go +++ b/x/checkpointing/client/cli/tx_test.go @@ -26,11 +26,11 @@ import ( authcodec "github.com/cosmos/cosmos-sdk/x/auth/codec" "github.com/stretchr/testify/suite" - "github.com/babylonchain/babylon/app" - "github.com/babylonchain/babylon/app/params" - "github.com/babylonchain/babylon/privval" - testutilcli "github.com/babylonchain/babylon/testutil/cli" - checkpointcli "github.com/babylonchain/babylon/x/checkpointing/client/cli" + "github.com/babylonlabs-io/babylon/app" + "github.com/babylonlabs-io/babylon/app/params" + "github.com/babylonlabs-io/babylon/privval" + testutilcli "github.com/babylonlabs-io/babylon/testutil/cli" + checkpointcli "github.com/babylonlabs-io/babylon/x/checkpointing/client/cli" ) type mockCometRPC struct { diff --git a/x/checkpointing/client/cli/utils.go b/x/checkpointing/client/cli/utils.go index 532435bf5..c30ad96dd 100644 --- a/x/checkpointing/client/cli/utils.go +++ b/x/checkpointing/client/cli/utils.go @@ -23,8 +23,8 @@ import ( staketypes "github.com/cosmos/cosmos-sdk/x/staking/types" flag "github.com/spf13/pflag" - "github.com/babylonchain/babylon/privval" - "github.com/babylonchain/babylon/x/checkpointing/types" + "github.com/babylonlabs-io/babylon/privval" + "github.com/babylonlabs-io/babylon/x/checkpointing/types" ) // validator struct to define the fields of the validator @@ -56,7 +56,7 @@ func parseAndValidateValidatorJSON(cdc codec.Codec, path string) (validator, err MinSelfDelegation string `json:"min-self-delegation"` } - contents, err := os.ReadFile(path) + contents, err := os.ReadFile(filepath.Clean(path)) if err != nil { return validator{}, err } diff --git a/x/checkpointing/genesis.go b/x/checkpointing/genesis.go index 1641e7805..b8449d647 100644 --- a/x/checkpointing/genesis.go +++ b/x/checkpointing/genesis.go @@ -2,14 +2,18 @@ package checkpointing import ( "context" - "github.com/babylonchain/babylon/x/checkpointing/keeper" - "github.com/babylonchain/babylon/x/checkpointing/types" + + "github.com/babylonlabs-io/babylon/x/checkpointing/keeper" + "github.com/babylonlabs-io/babylon/x/checkpointing/types" ) // InitGenesis initializes the capability module's state from a provided genesis // state. +// TODO: importing/exporting genesis func InitGenesis(ctx context.Context, k keeper.Keeper, genState types.GenesisState) { k.SetGenBlsKeys(ctx, genState.GenesisKeys) + // set epoch 0 to be finalised at genesis + k.SetLastFinalizedEpoch(ctx, 0) } // ExportGenesis returns the capability module's exported genesis. diff --git a/x/checkpointing/genesis_test.go b/x/checkpointing/genesis_test.go index ba7e05bac..e6e9c18cf 100644 --- a/x/checkpointing/genesis_test.go +++ b/x/checkpointing/genesis_test.go @@ -3,17 +3,17 @@ package checkpointing_test import ( "testing" - "github.com/babylonchain/babylon/crypto/bls12381" - "github.com/babylonchain/babylon/privval" - "github.com/babylonchain/babylon/x/checkpointing" + "github.com/babylonlabs-io/babylon/crypto/bls12381" + "github.com/babylonlabs-io/babylon/privval" + "github.com/babylonlabs-io/babylon/x/checkpointing" "github.com/cometbft/cometbft/crypto/ed25519" cryptocodec "github.com/cosmos/cosmos-sdk/crypto/codec" cosmosed "github.com/cosmos/cosmos-sdk/crypto/keys/ed25519" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/stretchr/testify/require" - simapp "github.com/babylonchain/babylon/app" - "github.com/babylonchain/babylon/x/checkpointing/types" + simapp "github.com/babylonlabs-io/babylon/app" + "github.com/babylonlabs-io/babylon/x/checkpointing/types" ) func TestInitGenesis(t *testing.T) { diff --git a/x/checkpointing/keeper/bls_signer.go b/x/checkpointing/keeper/bls_signer.go index 54e3ba974..8e7eb0ad8 100644 --- a/x/checkpointing/keeper/bls_signer.go +++ b/x/checkpointing/keeper/bls_signer.go @@ -4,8 +4,8 @@ import ( "github.com/cometbft/cometbft/crypto" sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/babylonchain/babylon/crypto/bls12381" - "github.com/babylonchain/babylon/x/checkpointing/types" + "github.com/babylonlabs-io/babylon/crypto/bls12381" + "github.com/babylonlabs-io/babylon/x/checkpointing/types" ) type BlsSigner interface { diff --git a/x/checkpointing/keeper/bls_signer_test.go b/x/checkpointing/keeper/bls_signer_test.go index a6b367238..d11ee3727 100644 --- a/x/checkpointing/keeper/bls_signer_test.go +++ b/x/checkpointing/keeper/bls_signer_test.go @@ -4,8 +4,8 @@ import ( "github.com/cosmos/cosmos-sdk/crypto/keys/ed25519" sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/babylonchain/babylon/crypto/bls12381" - epochingtypes "github.com/babylonchain/babylon/x/epoching/types" + "github.com/babylonlabs-io/babylon/crypto/bls12381" + epochingtypes "github.com/babylonlabs-io/babylon/x/epoching/types" ) var ( diff --git a/x/checkpointing/keeper/ckpt_state.go b/x/checkpointing/keeper/ckpt_state.go index 3cc30b4e2..72bf7a290 100644 --- a/x/checkpointing/keeper/ckpt_state.go +++ b/x/checkpointing/keeper/ckpt_state.go @@ -4,7 +4,7 @@ import ( "context" "cosmossdk.io/store/prefix" storetypes "cosmossdk.io/store/types" - "github.com/babylonchain/babylon/x/checkpointing/types" + "github.com/babylonlabs-io/babylon/x/checkpointing/types" "github.com/cosmos/cosmos-sdk/codec" "github.com/cosmos/cosmos-sdk/runtime" sdk "github.com/cosmos/cosmos-sdk/types" diff --git a/x/checkpointing/keeper/genesis_bls.go b/x/checkpointing/keeper/genesis_bls.go index 71c3cab2e..7c404179e 100644 --- a/x/checkpointing/keeper/genesis_bls.go +++ b/x/checkpointing/keeper/genesis_bls.go @@ -2,7 +2,7 @@ package keeper import ( "context" - "github.com/babylonchain/babylon/x/checkpointing/types" + "github.com/babylonlabs-io/babylon/x/checkpointing/types" sdk "github.com/cosmos/cosmos-sdk/types" ) diff --git a/x/checkpointing/keeper/grpc_query_bls.go b/x/checkpointing/keeper/grpc_query_bls.go index ce9dfe4ac..35efb113f 100644 --- a/x/checkpointing/keeper/grpc_query_bls.go +++ b/x/checkpointing/keeper/grpc_query_bls.go @@ -2,7 +2,7 @@ package keeper import ( "context" - "github.com/babylonchain/babylon/x/checkpointing/types" + "github.com/babylonlabs-io/babylon/x/checkpointing/types" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/jinzhu/copier" "google.golang.org/grpc/codes" diff --git a/x/checkpointing/keeper/grpc_query_bls_test.go b/x/checkpointing/keeper/grpc_query_bls_test.go index 8ec938bd8..d6f74661f 100644 --- a/x/checkpointing/keeper/grpc_query_bls_test.go +++ b/x/checkpointing/keeper/grpc_query_bls_test.go @@ -10,11 +10,11 @@ import ( "github.com/cosmos/cosmos-sdk/types/query" "github.com/stretchr/testify/require" - "github.com/babylonchain/babylon/app" - "github.com/babylonchain/babylon/testutil/datagen" - testhelper "github.com/babylonchain/babylon/testutil/helper" - checkpointingkeeper "github.com/babylonchain/babylon/x/checkpointing/keeper" - "github.com/babylonchain/babylon/x/checkpointing/types" + "github.com/babylonlabs-io/babylon/app" + "github.com/babylonlabs-io/babylon/testutil/datagen" + testhelper "github.com/babylonlabs-io/babylon/testutil/helper" + checkpointingkeeper "github.com/babylonlabs-io/babylon/x/checkpointing/keeper" + "github.com/babylonlabs-io/babylon/x/checkpointing/types" ) // FuzzQueryBLSKeySet does the following checks diff --git a/x/checkpointing/keeper/grpc_query_checkpoint.go b/x/checkpointing/keeper/grpc_query_checkpoint.go index b0b2c28e8..fa56c1843 100644 --- a/x/checkpointing/keeper/grpc_query_checkpoint.go +++ b/x/checkpointing/keeper/grpc_query_checkpoint.go @@ -9,21 +9,21 @@ import ( "google.golang.org/grpc/codes" "google.golang.org/grpc/status" - "github.com/babylonchain/babylon/x/checkpointing/types" + "github.com/babylonlabs-io/babylon/x/checkpointing/types" ) var _ types.QueryServer = Keeper{} // RawCheckpointList returns a list of checkpoint by status in the ascending order of epoch -func (k Keeper) RawCheckpointList(ctx context.Context, req *types.QueryRawCheckpointListRequest) (*types.QueryRawCheckpointListResponse, error) { +func (k Keeper) RawCheckpointList(c context.Context, req *types.QueryRawCheckpointListRequest) (*types.QueryRawCheckpointListResponse, error) { if req == nil { return nil, status.Error(codes.InvalidArgument, "invalid request") } - var checkpointList []*types.RawCheckpointWithMeta + var checkpointList []*types.RawCheckpointWithMetaResponse - sdkCtx := sdk.UnwrapSDKContext(ctx) + ctx := sdk.UnwrapSDKContext(c) - store := k.CheckpointsState(sdkCtx).checkpoints + store := k.CheckpointsState(ctx).checkpoints pageRes, err := query.FilteredPaginate(store, req.Pagination, func(_ []byte, value []byte, accumulate bool) (bool, error) { ckptWithMeta, err := types.BytesToCkptWithMeta(k.cdc, value) if err != nil { @@ -31,7 +31,7 @@ func (k Keeper) RawCheckpointList(ctx context.Context, req *types.QueryRawCheckp } if ckptWithMeta.Status == req.Status { if accumulate { - checkpointList = append(checkpointList, ckptWithMeta) + checkpointList = append(checkpointList, ckptWithMeta.ToResponse()) } return true, nil } @@ -46,19 +46,18 @@ func (k Keeper) RawCheckpointList(ctx context.Context, req *types.QueryRawCheckp } // RawCheckpoint returns a checkpoint by epoch number -func (k Keeper) RawCheckpoint(ctx context.Context, req *types.QueryRawCheckpointRequest) (*types.QueryRawCheckpointResponse, error) { +func (k Keeper) RawCheckpoint(c context.Context, req *types.QueryRawCheckpointRequest) (*types.QueryRawCheckpointResponse, error) { if req == nil { return nil, status.Error(codes.InvalidArgument, "invalid request") } - sdkCtx := sdk.UnwrapSDKContext(ctx) - - ckptWithMeta, err := k.CheckpointsState(sdkCtx).GetRawCkptWithMeta(req.EpochNum) + ctx := sdk.UnwrapSDKContext(c) + ckptWithMeta, err := k.CheckpointsState(ctx).GetRawCkptWithMeta(req.EpochNum) if err != nil { return nil, err } - return &types.QueryRawCheckpointResponse{RawCheckpoint: ckptWithMeta}, nil + return &types.QueryRawCheckpointResponse{RawCheckpoint: ckptWithMeta.ToResponse()}, nil } // RawCheckpoints returns checkpoints for given epoch range specified in pagination params @@ -70,11 +69,11 @@ func (k Keeper) RawCheckpoints(ctx context.Context, req *types.QueryRawCheckpoin sdkCtx := sdk.UnwrapSDKContext(ctx) store := k.CheckpointsState(sdkCtx).checkpoints - var checkpointList []*types.RawCheckpointWithMeta + var checkpointList []*types.RawCheckpointWithMetaResponse pageRes, err := query.Paginate(store, req.Pagination, func(key, value []byte) error { var ckptWithMeta types.RawCheckpointWithMeta k.cdc.MustUnmarshal(value, &ckptWithMeta) - checkpointList = append(checkpointList, &ckptWithMeta) + checkpointList = append(checkpointList, ckptWithMeta.ToResponse()) return nil }) if err != nil { @@ -153,7 +152,7 @@ func (k Keeper) LastCheckpointWithStatus(ctx context.Context, req *types.QueryLa 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}, nil + return &types.QueryLastCheckpointWithStatusResponse{RawCheckpoint: ckpt.Ckpt.ToResponse()}, nil } } return nil, fmt.Errorf("cannot find checkpoint with status %v", req.Status) diff --git a/x/checkpointing/keeper/grpc_query_checkpoint_test.go b/x/checkpointing/keeper/grpc_query_checkpoint_test.go index ef01034a4..9da76a426 100644 --- a/x/checkpointing/keeper/grpc_query_checkpoint_test.go +++ b/x/checkpointing/keeper/grpc_query_checkpoint_test.go @@ -7,18 +7,18 @@ import ( "github.com/cosmos/cosmos-sdk/types/query" - "github.com/babylonchain/babylon/x/checkpointing/keeper" + "github.com/babylonlabs-io/babylon/x/checkpointing/keeper" "github.com/golang/mock/gomock" - "github.com/babylonchain/babylon/testutil/mocks" - "github.com/babylonchain/babylon/x/checkpointing/types" - epochingtypes "github.com/babylonchain/babylon/x/epoching/types" + "github.com/babylonlabs-io/babylon/testutil/mocks" + "github.com/babylonlabs-io/babylon/x/checkpointing/types" + epochingtypes "github.com/babylonlabs-io/babylon/x/epoching/types" "github.com/stretchr/testify/require" - "github.com/babylonchain/babylon/testutil/datagen" - testkeeper "github.com/babylonchain/babylon/testutil/keeper" + "github.com/babylonlabs-io/babylon/testutil/datagen" + testkeeper "github.com/babylonlabs-io/babylon/testutil/keeper" ) func FuzzQueryEpoch(f *testing.F) { @@ -38,7 +38,7 @@ func FuzzQueryEpoch(f *testing.F) { ckptRequest := types.NewQueryRawCheckpointRequest(mockCkptWithMeta.Ckpt.EpochNum) ckptResp, err := ckptKeeper.RawCheckpoint(ctx, ckptRequest) require.NoError(t, err) - require.True(t, ckptResp.RawCheckpoint.Equal(mockCkptWithMeta)) + require.Equal(t, ckptResp.RawCheckpoint, mockCkptWithMeta.ToResponse()) // test querying the status of a given epoch number statusRequest := types.NewQueryEpochStatusRequest(mockCkptWithMeta.Ckpt.EpochNum) @@ -75,7 +75,7 @@ func FuzzQueryRawCheckpoints(f *testing.F) { require.Equal(t, int(pageLimit), len(ckptResp.RawCheckpoints)) require.Nil(t, ckptResp.Pagination.NextKey) for i, ckpt := range ckptResp.RawCheckpoints { - require.Equal(t, checkpoints[i], ckpt) + require.Equal(t, checkpoints[i].ToResponse(), ckpt) } }) } @@ -144,7 +144,7 @@ func FuzzQueryLastCheckpointWithStatus(f *testing.F) { // request the last finalized checkpoint req := types.NewQueryLastCheckpointWithStatus(types.Finalized) expectedResp := &types.QueryLastCheckpointWithStatusResponse{ - RawCheckpoint: checkpoints[int(finalizedEpoch)].Ckpt, + RawCheckpoint: checkpoints[int(finalizedEpoch)].Ckpt.ToResponse(), } resp, err := ckptKeeper.LastCheckpointWithStatus(ctx, req) require.NoError(t, err) @@ -153,7 +153,7 @@ func FuzzQueryLastCheckpointWithStatus(f *testing.F) { // request the last confirmed checkpoint req = types.NewQueryLastCheckpointWithStatus(types.Confirmed) expectedResp = &types.QueryLastCheckpointWithStatusResponse{ - RawCheckpoint: checkpoints[int(finalizedEpoch)].Ckpt, + RawCheckpoint: checkpoints[int(finalizedEpoch)].Ckpt.ToResponse(), } resp, err = ckptKeeper.LastCheckpointWithStatus(ctx, req) require.NoError(t, err) diff --git a/x/checkpointing/keeper/hooks.go b/x/checkpointing/keeper/hooks.go index 4e3adace7..8018c800f 100644 --- a/x/checkpointing/keeper/hooks.go +++ b/x/checkpointing/keeper/hooks.go @@ -2,7 +2,8 @@ package keeper import ( "context" - "github.com/babylonchain/babylon/x/checkpointing/types" + + "github.com/babylonlabs-io/babylon/x/checkpointing/types" sdk "github.com/cosmos/cosmos-sdk/types" ) @@ -17,6 +18,14 @@ func (k Keeper) AfterBlsKeyRegistered(ctx context.Context, valAddr sdk.ValAddres return nil } +// AfterRawCheckpointSealed - call hook if the checkpoint is sealed +func (k Keeper) AfterRawCheckpointSealed(ctx context.Context, epoch uint64) error { + if k.hooks != nil { + return k.hooks.AfterRawCheckpointSealed(ctx, epoch) + } + return nil +} + // AfterRawCheckpointConfirmed - call hook if the checkpoint is confirmed func (k Keeper) AfterRawCheckpointConfirmed(ctx context.Context, epoch uint64) error { if k.hooks != nil { diff --git a/x/checkpointing/keeper/keeper.go b/x/checkpointing/keeper/keeper.go index d5262b4e5..59f9a9c7f 100644 --- a/x/checkpointing/keeper/keeper.go +++ b/x/checkpointing/keeper/keeper.go @@ -7,7 +7,7 @@ import ( corestoretypes "cosmossdk.io/core/store" - txformat "github.com/babylonchain/babylon/btctxformatter" + txformat "github.com/babylonlabs-io/babylon/btctxformatter" "cosmossdk.io/log" "github.com/cosmos/cosmos-sdk/codec" @@ -15,9 +15,9 @@ import ( cmtprotocrypto "github.com/cometbft/cometbft/proto/tendermint/crypto" - "github.com/babylonchain/babylon/crypto/bls12381" - "github.com/babylonchain/babylon/x/checkpointing/types" - epochingtypes "github.com/babylonchain/babylon/x/epoching/types" + "github.com/babylonlabs-io/babylon/crypto/bls12381" + "github.com/babylonlabs-io/babylon/x/checkpointing/types" + epochingtypes "github.com/babylonlabs-io/babylon/x/epoching/types" ) type ( @@ -66,20 +66,30 @@ func (k Keeper) SealCheckpoint(ctx context.Context, ckptWithMeta *types.RawCheck } sdkCtx := sdk.UnwrapSDKContext(ctx) + + // if reaching this line, it means ckptWithMeta is updated, + // and we need to write the updated ckptWithMeta back to KVStore + if err := k.AddRawCheckpoint(ctx, ckptWithMeta); err != nil { + return err + } + // record state update of Sealed ckptWithMeta.RecordStateUpdate(ctx, types.Sealed) - // log in console - k.Logger(sdkCtx).Info(fmt.Sprintf("Checkpointing: checkpoint for epoch %v is Sealed", ckptWithMeta.Ckpt.EpochNum)) // emit event if err := sdkCtx.EventManager().EmitTypedEvent( &types.EventCheckpointSealed{Checkpoint: ckptWithMeta}, ); err != nil { panic(fmt.Errorf("failed to emit checkpoint sealed event for epoch %v", ckptWithMeta.Ckpt.EpochNum)) } + // invoke hook + if err := k.AfterRawCheckpointSealed(ctx, ckptWithMeta.Ckpt.EpochNum); err != nil { + k.Logger(sdkCtx).Error("failed to trigger checkpoint sealed hook for epoch %v: %v", ckptWithMeta.Ckpt.EpochNum, err) + } - // if reaching this line, it means ckptWithMeta is updated, - // and we need to write the updated ckptWithMeta back to KVStore - return k.AddRawCheckpoint(ctx, ckptWithMeta) + // log in console + k.Logger(sdkCtx).Info(fmt.Sprintf("Checkpointing: checkpoint for epoch %v is Sealed", ckptWithMeta.Ckpt.EpochNum)) + + return nil } func (k Keeper) VerifyBLSSig(ctx context.Context, sig *types.BlsSig) error { @@ -297,7 +307,11 @@ func (k Keeper) SetCheckpointConfirmed(ctx context.Context, epoch uint64) { // and records the associated state update in lifecycle 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) + // remember the last finalised epoch + k.SetLastFinalizedEpoch(ctx, epoch) + // emit event err := sdkCtx.EventManager().EmitTypedEvent( &types.EventCheckpointFinalized{Checkpoint: ckpt}, ) @@ -395,3 +409,24 @@ func (k Keeper) GetTotalVotingPower(ctx context.Context, epochNumber uint64) int func (k Keeper) GetPubKeyByConsAddr(ctx context.Context, consAddr sdk.ConsAddress) (cmtprotocrypto.PublicKey, error) { return k.epochingKeeper.GetPubKeyByConsAddr(ctx, consAddr) } + +// GetLastFinalizedEpoch gets the last finalised epoch +func (k Keeper) GetLastFinalizedEpoch(ctx context.Context) uint64 { + store := k.storeService.OpenKVStore(ctx) + epochNumberBytes, err := store.Get(types.LastFinalizedEpochKey) + if err != nil { + // we have set epoch 0 to be finalised at genesis so this can + // only be a programming error + panic(err) + } + return sdk.BigEndianToUint64(epochNumberBytes) +} + +// SetLastFinalizedEpoch sets the last finalised epoch +func (k Keeper) SetLastFinalizedEpoch(ctx context.Context, epochNumber uint64) { + store := k.storeService.OpenKVStore(ctx) + epochNumberBytes := sdk.Uint64ToBigEndian(epochNumber) + if err := store.Set(types.LastFinalizedEpochKey, epochNumberBytes); err != nil { + panic(err) + } +} diff --git a/x/checkpointing/keeper/keeper_test.go b/x/checkpointing/keeper/keeper_test.go index 4dd46f58d..1316f363a 100644 --- a/x/checkpointing/keeper/keeper_test.go +++ b/x/checkpointing/keeper/keeper_test.go @@ -10,12 +10,12 @@ import ( "github.com/golang/mock/gomock" "github.com/stretchr/testify/require" - "github.com/babylonchain/babylon/btctxformatter" - "github.com/babylonchain/babylon/crypto/bls12381" - "github.com/babylonchain/babylon/testutil/datagen" - testkeeper "github.com/babylonchain/babylon/testutil/keeper" - "github.com/babylonchain/babylon/testutil/mocks" - "github.com/babylonchain/babylon/x/checkpointing/types" + "github.com/babylonlabs-io/babylon/btctxformatter" + "github.com/babylonlabs-io/babylon/crypto/bls12381" + "github.com/babylonlabs-io/babylon/testutil/datagen" + testkeeper "github.com/babylonlabs-io/babylon/testutil/keeper" + "github.com/babylonlabs-io/babylon/testutil/mocks" + "github.com/babylonlabs-io/babylon/x/checkpointing/types" ) // FuzzKeeperAddRawCheckpoint checks diff --git a/x/checkpointing/keeper/msg_server.go b/x/checkpointing/keeper/msg_server.go index 04a088763..40c084723 100644 --- a/x/checkpointing/keeper/msg_server.go +++ b/x/checkpointing/keeper/msg_server.go @@ -5,9 +5,9 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" - epochingtypes "github.com/babylonchain/babylon/x/epoching/types" + epochingtypes "github.com/babylonlabs-io/babylon/x/epoching/types" - "github.com/babylonchain/babylon/x/checkpointing/types" + "github.com/babylonlabs-io/babylon/x/checkpointing/types" ) type msgServer struct { diff --git a/x/checkpointing/keeper/msg_server_test.go b/x/checkpointing/keeper/msg_server_test.go index e8b32e471..fffba8d6e 100644 --- a/x/checkpointing/keeper/msg_server_test.go +++ b/x/checkpointing/keeper/msg_server_test.go @@ -11,15 +11,15 @@ import ( stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" "github.com/stretchr/testify/require" - "github.com/babylonchain/babylon/app" - appparams "github.com/babylonchain/babylon/app/params" - "github.com/babylonchain/babylon/crypto/bls12381" - "github.com/babylonchain/babylon/privval" - "github.com/babylonchain/babylon/testutil/datagen" - testhelper "github.com/babylonchain/babylon/testutil/helper" - checkpointingkeeper "github.com/babylonchain/babylon/x/checkpointing/keeper" - "github.com/babylonchain/babylon/x/checkpointing/types" - epochingtypes "github.com/babylonchain/babylon/x/epoching/types" + "github.com/babylonlabs-io/babylon/app" + appparams "github.com/babylonlabs-io/babylon/app/params" + "github.com/babylonlabs-io/babylon/crypto/bls12381" + "github.com/babylonlabs-io/babylon/privval" + "github.com/babylonlabs-io/babylon/testutil/datagen" + testhelper "github.com/babylonlabs-io/babylon/testutil/helper" + checkpointingkeeper "github.com/babylonlabs-io/babylon/x/checkpointing/keeper" + "github.com/babylonlabs-io/babylon/x/checkpointing/types" + epochingtypes "github.com/babylonlabs-io/babylon/x/epoching/types" ) // FuzzWrappedCreateValidator_InsufficientTokens tests adding new validators with zero voting power diff --git a/x/checkpointing/keeper/registration_state.go b/x/checkpointing/keeper/registration_state.go index 4649439e7..968a4d185 100644 --- a/x/checkpointing/keeper/registration_state.go +++ b/x/checkpointing/keeper/registration_state.go @@ -2,10 +2,11 @@ package keeper import ( "context" + "cosmossdk.io/store/prefix" storetypes "cosmossdk.io/store/types" - "github.com/babylonchain/babylon/crypto/bls12381" - "github.com/babylonchain/babylon/x/checkpointing/types" + "github.com/babylonlabs-io/babylon/crypto/bls12381" + "github.com/babylonlabs-io/babylon/x/checkpointing/types" "github.com/cosmos/cosmos-sdk/codec" "github.com/cosmos/cosmos-sdk/runtime" sdk "github.com/cosmos/cosmos-sdk/types" diff --git a/x/checkpointing/keeper/val_bls_set.go b/x/checkpointing/keeper/val_bls_set.go index a3ba8df88..96815405e 100644 --- a/x/checkpointing/keeper/val_bls_set.go +++ b/x/checkpointing/keeper/val_bls_set.go @@ -4,7 +4,7 @@ import ( "context" "cosmossdk.io/store/prefix" "fmt" - "github.com/babylonchain/babylon/x/checkpointing/types" + "github.com/babylonlabs-io/babylon/x/checkpointing/types" "github.com/cosmos/cosmos-sdk/runtime" sdk "github.com/cosmos/cosmos-sdk/types" ) diff --git a/x/checkpointing/keeper/val_bls_set_test.go b/x/checkpointing/keeper/val_bls_set_test.go index 1c4e84292..36f4cf822 100644 --- a/x/checkpointing/keeper/val_bls_set_test.go +++ b/x/checkpointing/keeper/val_bls_set_test.go @@ -9,11 +9,11 @@ import ( "github.com/cosmos/cosmos-sdk/baseapp" "github.com/stretchr/testify/require" - "github.com/babylonchain/babylon/app" - "github.com/babylonchain/babylon/testutil/datagen" - testhelper "github.com/babylonchain/babylon/testutil/helper" - checkpointingkeeper "github.com/babylonchain/babylon/x/checkpointing/keeper" - "github.com/babylonchain/babylon/x/checkpointing/types" + "github.com/babylonlabs-io/babylon/app" + "github.com/babylonlabs-io/babylon/testutil/datagen" + testhelper "github.com/babylonlabs-io/babylon/testutil/helper" + checkpointingkeeper "github.com/babylonlabs-io/babylon/x/checkpointing/keeper" + "github.com/babylonlabs-io/babylon/x/checkpointing/types" ) func FuzzGetValidatorBlsKeySet(f *testing.F) { diff --git a/x/checkpointing/module.go b/x/checkpointing/module.go index 5e4bf3184..ff29c666f 100644 --- a/x/checkpointing/module.go +++ b/x/checkpointing/module.go @@ -2,19 +2,20 @@ package checkpointing import ( "context" - "cosmossdk.io/core/appmodule" "encoding/json" "fmt" + "cosmossdk.io/core/appmodule" + "github.com/gorilla/mux" "github.com/grpc-ecosystem/grpc-gateway/runtime" "github.com/spf13/cobra" abci "github.com/cometbft/cometbft/abci/types" - "github.com/babylonchain/babylon/x/checkpointing/client/cli" - "github.com/babylonchain/babylon/x/checkpointing/keeper" - "github.com/babylonchain/babylon/x/checkpointing/types" + "github.com/babylonlabs-io/babylon/x/checkpointing/client/cli" + "github.com/babylonlabs-io/babylon/x/checkpointing/keeper" + "github.com/babylonlabs-io/babylon/x/checkpointing/types" "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/codec" cdctypes "github.com/cosmos/cosmos-sdk/codec/types" diff --git a/x/checkpointing/proposal.go b/x/checkpointing/proposal.go index 9812099b8..68748c460 100644 --- a/x/checkpointing/proposal.go +++ b/x/checkpointing/proposal.go @@ -1,6 +1,7 @@ package checkpointing import ( + "bytes" "encoding/hex" "fmt" "slices" @@ -12,27 +13,29 @@ import ( abci "github.com/cometbft/cometbft/abci/types" - "github.com/babylonchain/babylon/x/checkpointing/keeper" - ckpttypes "github.com/babylonchain/babylon/x/checkpointing/types" + ckpttypes "github.com/babylonlabs-io/babylon/x/checkpointing/types" ) const defaultInjectedTxIndex = 0 type ProposalHandler struct { logger log.Logger - ckptKeeper *keeper.Keeper - valStore baseapp.ValidatorStore + ckptKeeper CheckpointingKeeper txVerifier baseapp.ProposalTxVerifier defaultPrepareProposalHandler sdk.PrepareProposalHandler defaultProcessProposalHandler sdk.ProcessProposalHandler } -func NewProposalHandler(logger log.Logger, ckptKeeper *keeper.Keeper, mp mempool.Mempool, txVerifier baseapp.ProposalTxVerifier) *ProposalHandler { +func NewProposalHandler( + logger log.Logger, + ckptKeeper CheckpointingKeeper, + mp mempool.Mempool, + txVerifier baseapp.ProposalTxVerifier, +) *ProposalHandler { defaultHandler := baseapp.NewDefaultProposalHandler(mp, txVerifier) return &ProposalHandler{ logger: logger, ckptKeeper: ckptKeeper, - valStore: ckptKeeper, txVerifier: txVerifier, defaultPrepareProposalHandler: defaultHandler.PrepareProposalHandler(), defaultProcessProposalHandler: defaultHandler.ProcessProposalHandler(), @@ -42,7 +45,6 @@ func NewProposalHandler(logger log.Logger, ckptKeeper *keeper.Keeper, mp mempool func (h *ProposalHandler) SetHandlers(bApp *baseapp.BaseApp) { bApp.SetPrepareProposal(h.PrepareProposal()) bApp.SetProcessProposal(h.ProcessProposal()) - bApp.SetPreBlocker(h.PreBlocker()) } // PrepareProposal examines the vote extensions from the previous block, accumulates @@ -75,7 +77,7 @@ func (h *ProposalHandler) PrepareProposal() sdk.PrepareProposalHandler { } // 1. verify the validity of vote extensions (2/3 majority is achieved) - err = baseapp.ValidateVoteExtensions(ctx, h.valStore, req.Height, ctx.ChainID(), req.LocalLastCommit) + err = baseapp.ValidateVoteExtensions(ctx, h.ckptKeeper, req.Height, ctx.ChainID(), req.LocalLastCommit) if err != nil { return proposalRes, fmt.Errorf("invalid vote extensions: %w", err) } @@ -111,7 +113,7 @@ func (h *ProposalHandler) buildCheckpointFromVoteExtensions(ctx sdk.Context, epo return nil, err } ckpt := ckpttypes.NewCheckpointWithMeta(ckpttypes.NewCheckpoint(epoch, prevBlockID), ckpttypes.Accumulating) - validBLSSigs := h.getValidBlsSigs(ctx, extendedVotes) + validBLSSigs := h.getValidBlsSigs(ctx, extendedVotes, prevBlockID) vals := h.ckptKeeper.GetValidatorSet(ctx, epoch) totalPower := h.ckptKeeper.GetTotalVotingPower(ctx, epoch) // TODO: maybe we don't need to verify BLS sigs anymore as they are already @@ -154,7 +156,7 @@ func (h *ProposalHandler) buildCheckpointFromVoteExtensions(ctx sdk.Context, epo return ckpt, nil } -func (h *ProposalHandler) getValidBlsSigs(ctx sdk.Context, extendedVotes []abci.ExtendedVoteInfo) []ckpttypes.BlsSig { +func (h *ProposalHandler) getValidBlsSigs(ctx sdk.Context, extendedVotes []abci.ExtendedVoteInfo, blockHash []byte) []ckpttypes.BlsSig { k := h.ckptKeeper validBLSSigs := make([]ckpttypes.BlsSig, 0, len(extendedVotes)) for _, voteInfo := range extendedVotes { @@ -168,6 +170,14 @@ func (h *ProposalHandler) getValidBlsSigs(ctx sdk.Context, extendedVotes []abci. h.logger.Error("failed to unmarshal vote extension", "err", err) continue } + + if !bytes.Equal(*ve.BlockHash, blockHash) { + h.logger.Error("the BLS sig is signed over unexpected block hash", + "expected", hex.EncodeToString(blockHash), + "got", ve.BlockHash.String()) + continue + } + sig := ve.ToBLSSig() if err := k.VerifyBLSSig(ctx, sig); err != nil { @@ -276,10 +286,10 @@ func (h *ProposalHandler) ProcessProposal() sdk.ProcessProposalHandler { } // 3. verify the validity of the vote extension (2/3 majority is achieved) - err = baseapp.ValidateVoteExtensions(ctx, h.valStore, req.Height, ctx.ChainID(), *injectedCkpt.ExtendedCommitInfo) + err = baseapp.ValidateVoteExtensions(ctx, h.ckptKeeper, req.Height, ctx.ChainID(), *injectedCkpt.ExtendedCommitInfo) if err != nil { // the returned err will lead to panic as something very wrong happened during consensus - return resReject, err + return resReject, nil } // 4. rebuild the checkpoint from vote extensions and compare it with @@ -318,14 +328,14 @@ func (h *ProposalHandler) ProcessProposal() sdk.ProcessProposalHandler { } } -// PreBlocker extracts the checkpoint from the injected tx and stores it in -// the application +// PreBlocker extracts the checkpoint from the injected tx and stores it in the application // no more validation is needed as it is already done in ProcessProposal +// NOTE: this is appended to the existing PreBlocker in BabylonApp at app.go func (h *ProposalHandler) PreBlocker() sdk.PreBlocker { return func(ctx sdk.Context, req *abci.RequestFinalizeBlock) (*sdk.ResponsePreBlock, error) { - k := h.ckptKeeper res := &sdk.ResponsePreBlock{} + k := h.ckptKeeper epoch := k.GetEpoch(ctx) // BLS signatures are sent in the last block of the previous epoch, // so they should be aggregated in the first block of the new epoch diff --git a/x/checkpointing/proposal_expected_keeper.go b/x/checkpointing/proposal_expected_keeper.go new file mode 100644 index 000000000..697ed90d6 --- /dev/null +++ b/x/checkpointing/proposal_expected_keeper.go @@ -0,0 +1,21 @@ +package checkpointing + +import ( + "context" + + "github.com/babylonlabs-io/babylon/crypto/bls12381" + "github.com/babylonlabs-io/babylon/x/checkpointing/types" + epochingtypes "github.com/babylonlabs-io/babylon/x/epoching/types" + cmtprotocrypto "github.com/cometbft/cometbft/proto/tendermint/crypto" + sdk "github.com/cosmos/cosmos-sdk/types" +) + +type CheckpointingKeeper interface { + GetPubKeyByConsAddr(context.Context, sdk.ConsAddress) (cmtprotocrypto.PublicKey, error) + GetEpoch(ctx context.Context) *epochingtypes.Epoch + GetValidatorSet(ctx context.Context, epochNumber uint64) epochingtypes.ValidatorSet + GetTotalVotingPower(ctx context.Context, epochNumber uint64) int64 + GetBlsPubKey(ctx context.Context, address sdk.ValAddress) (bls12381.PublicKey, error) + VerifyBLSSig(ctx context.Context, sig *types.BlsSig) error + SealCheckpoint(ctx context.Context, ckptWithMeta *types.RawCheckpointWithMeta) error +} diff --git a/x/checkpointing/proposal_test.go b/x/checkpointing/proposal_test.go new file mode 100644 index 000000000..afd88afd4 --- /dev/null +++ b/x/checkpointing/proposal_test.go @@ -0,0 +1,513 @@ +package checkpointing_test + +import ( + "bytes" + "fmt" + "math/rand" + "sort" + "testing" + "time" + + "cosmossdk.io/core/header" + "cosmossdk.io/log" + cbftt "github.com/cometbft/cometbft/abci/types" + cmtprotocrypto "github.com/cometbft/cometbft/proto/tendermint/crypto" + tendermintTypes "github.com/cometbft/cometbft/proto/tendermint/types" + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/cosmos-sdk/types/mempool" + protoio "github.com/cosmos/gogoproto/io" + "github.com/cosmos/gogoproto/proto" + "github.com/golang/mock/gomock" + "github.com/stretchr/testify/require" + + "github.com/babylonlabs-io/babylon/crypto/bls12381" + "github.com/babylonlabs-io/babylon/testutil/datagen" + "github.com/babylonlabs-io/babylon/testutil/helper" + "github.com/babylonlabs-io/babylon/testutil/mocks" + "github.com/babylonlabs-io/babylon/x/checkpointing" + checkpointingtypes "github.com/babylonlabs-io/babylon/x/checkpointing/types" + et "github.com/babylonlabs-io/babylon/x/epoching/types" +) + +type TestValidator struct { + Keys *datagen.GenesisKeyWithBLS + Power int64 +} + +func (v *TestValidator) CometValidator() *cbftt.Validator { + return &cbftt.Validator{ + Address: v.Keys.GenesisKey.ValPubkey.Address(), + Power: v.Power, + } +} + +func (v *TestValidator) EpochingValidator() et.Validator { + return et.Validator{ + Addr: v.Keys.GenesisKey.ValPubkey.Address(), + Power: v.Power, + } +} + +func (v *TestValidator) ProtoPubkey() cmtprotocrypto.PublicKey { + validatorPubKey := cmtprotocrypto.PublicKey{ + Sum: &cmtprotocrypto.PublicKey_Ed25519{ + Ed25519: v.Keys.PrivKey.PubKey().Bytes(), + }, + } + return validatorPubKey +} + +func (v *TestValidator) VoteExtension( + bh *checkpointingtypes.BlockHash, + epochNum uint64, +) checkpointingtypes.VoteExtension { + signBytes := checkpointingtypes.GetSignBytes(epochNum, *bh) + // Need valid bls signature for aggregation + bls := bls12381.Sign(v.Keys.PrivateKey, signBytes) + + return checkpointingtypes.VoteExtension{ + Signer: v.Keys.ValidatorAddress, + BlockHash: bh, + EpochNum: epochNum, + Height: 0, + BlsSig: &bls, + } +} + +func (v *TestValidator) SignVoteExtension( + t *testing.T, + bytes []byte, + height int64, + chainId string, +) cbftt.ExtendedVoteInfo { + votExt := genVoteExt(t, + bytes, height, 0, chainId) + signature, err := v.Keys.PrivKey.Sign(votExt) + require.NoError(t, err) + + evi := cbftt.ExtendedVoteInfo{ + Validator: *v.CometValidator(), + VoteExtension: bytes, + ExtensionSignature: signature, + BlockIdFlag: tendermintTypes.BlockIDFlagCommit, + } + + return evi +} + +func (v *TestValidator) ValidatorAddress(t *testing.T) sdk.ValAddress { + valAddress, err := sdk.ValAddressFromBech32(v.Keys.ValidatorAddress) + require.NoError(t, err) + return valAddress +} + +func (v *TestValidator) BlsPubKey() bls12381.PublicKey { + return *v.Keys.BlsKey.Pubkey +} + +func genNTestValidators(t *testing.T, n int) []TestValidator { + if n == 0 { + return []TestValidator{} + } + + keys, err := datagen.GenesisValidatorSet(n) + require.NoError(t, err) + + var vals []TestValidator + for _, key := range keys.Keys { + k := key + vals = append(vals, TestValidator{ + Keys: k, + Power: 100, + }) + } + + // below are copied from https://github.com/cosmos/cosmos-sdk/blob/v0.50.6/baseapp/abci_utils_test.go + // Since v0.50.5 Cosmos SDK enforces certain order for vote extensions + sort.SliceStable(vals, func(i, j int) bool { + if vals[i].Power == vals[j].Power { + valAddress1, err := sdk.ValAddressFromBech32(vals[i].Keys.ValidatorAddress) + require.NoError(t, err) + valAddress2, err := sdk.ValAddressFromBech32(vals[j].Keys.ValidatorAddress) + require.NoError(t, err) + return bytes.Compare(valAddress1, valAddress2) == -1 + } + return vals[i].Power > vals[j].Power + }) + + return vals +} + +func setupSdkCtx(height int64) sdk.Context { + return sdk.Context{}.WithHeaderInfo(header.Info{ + Height: height, + Time: time.Now(), + ChainID: "test", + }).WithConsensusParams(tendermintTypes.ConsensusParams{ + Abci: &tendermintTypes.ABCIParams{ + VoteExtensionsEnableHeight: 1, + }, + }).WithChainID("test") +} + +func firstEpoch() *et.Epoch { + return &et.Epoch{ + EpochNumber: 1, + CurrentEpochInterval: 10, + FirstBlockHeight: 1, + } +} + +type EpochAndCtx struct { + Epoch *et.Epoch + Ctx sdk.Context +} + +func epochAndVoteExtensionCtx() *EpochAndCtx { + epoch := firstEpoch() + ctx := setupSdkCtx(int64(epoch.FirstBlockHeight) + int64(epoch.GetCurrentEpochInterval())) + return &EpochAndCtx{ + Epoch: epoch, + Ctx: ctx, + } +} + +func genVoteExt( + t *testing.T, + ext []byte, + height int64, + round int64, + chainID string, +) []byte { + cve := tendermintTypes.CanonicalVoteExtension{ + Extension: ext, + Height: height, // the vote extension was signed in the previous height + Round: round, + ChainId: chainID, + } + + marshalDelimitedFn := func(msg proto.Message) ([]byte, error) { + var buf bytes.Buffer + if err := protoio.NewDelimitedWriter(&buf).WriteMsg(msg); err != nil { + return nil, err + } + + return buf.Bytes(), nil + } + + extSignBytes, err := marshalDelimitedFn(&cve) + require.NoError(t, err) + return extSignBytes +} + +func requestPrepareProposal(height int64, commitInfo cbftt.ExtendedCommitInfo) *cbftt.RequestPrepareProposal { + return &cbftt.RequestPrepareProposal{ + MaxTxBytes: 10000, + Txs: [][]byte{}, + LocalLastCommit: commitInfo, + Height: height, + } +} + +func randomBlockHash() checkpointingtypes.BlockHash { + r := rand.New(rand.NewSource(time.Now().UnixNano())) + return datagen.GenRandomBlockHash(r) +} + +// TODO There should be one function to verify the checkpoint against the validator set +// but currently there are different implementations in the codebase in checpointing module +// and zonecocierge module +func verifyCheckpoint(validators []TestValidator, rawCkpt *checkpointingtypes.RawCheckpoint) error { + valsCopy := validators + + sort.Slice(valsCopy, func(i, j int) bool { + return sdk.BigEndianToUint64(valsCopy[i].EpochingValidator().Addr) < sdk.BigEndianToUint64(valsCopy[j].EpochingValidator().Addr) + }) + + var validatorWithBls []*checkpointingtypes.ValidatorWithBlsKey + + for _, val := range valsCopy { + validatorWithBls = append(validatorWithBls, &checkpointingtypes.ValidatorWithBlsKey{ + ValidatorAddress: val.Keys.ValidatorAddress, + BlsPubKey: val.BlsPubKey(), + VotingPower: uint64(val.Power), + }) + } + + valSet := &checkpointingtypes.ValidatorWithBlsKeySet{ValSet: validatorWithBls} + // filter validator set that contributes to the signature + signerSet, signerSetPower, err := valSet.FindSubsetWithPowerSum(rawCkpt.Bitmap) + if err != nil { + return err + } + // ensure the signerSet has > 2/3 voting power + if signerSetPower*3 <= valSet.GetTotalPower()*2 { + return fmt.Errorf("failed") + } + // verify BLS multisig + signedMsgBytes := rawCkpt.SignedMsg() + ok, err := bls12381.VerifyMultiSig(*rawCkpt.BlsMultiSig, signerSet.GetBLSKeySet(), signedMsgBytes) + if err != nil { + return err + } + if !ok { + return fmt.Errorf("BLS signature does not match the public key") + } + return nil +} + +type Scenario struct { + TotalPower int64 + ValidatorSet []TestValidator + Extensions []cbftt.ExtendedVoteInfo +} + +type ValidatorsAndExtensions struct { + Vals []TestValidator + Extensions []checkpointingtypes.VoteExtension +} + +func generateNValidatorAndVoteExtensions(t *testing.T, n int, bh *checkpointingtypes.BlockHash, epochNumber uint64) (*ValidatorsAndExtensions, int64) { + validators := genNTestValidators(t, n) + var extensions []checkpointingtypes.VoteExtension + var power int64 + for _, val := range validators { + validator := val + ve := validator.VoteExtension(bh, epochNumber) + extensions = append(extensions, ve) + power += validator.Power + } + + return &ValidatorsAndExtensions{ + Vals: validators, + Extensions: extensions, + }, power +} + +func ToValidatorSet(v []TestValidator) et.ValidatorSet { + var cv []et.Validator + for _, val := range v { + cv = append(cv, val.EpochingValidator()) + } + return et.NewSortedValidatorSet(cv) +} + +func TestPrepareProposalAtVoteExtensionHeight(t *testing.T) { + tests := []struct { + name string + scenarioSetup func(ec *EpochAndCtx, ek *mocks.MockCheckpointingKeeper) *Scenario + expectError bool + }{ + { + name: "Empty vote extension list ", + scenarioSetup: func(ec *EpochAndCtx, ek *mocks.MockCheckpointingKeeper) *Scenario { + bh := randomBlockHash() + validatorAndExtensions, totalPower := generateNValidatorAndVoteExtensions(t, 4, &bh, ec.Epoch.EpochNumber) + return &Scenario{ + TotalPower: totalPower, + ValidatorSet: validatorAndExtensions.Vals, + Extensions: []cbftt.ExtendedVoteInfo{}, + } + }, + expectError: true, + }, + { + name: "List with only empty vote extensions", + scenarioSetup: func(ec *EpochAndCtx, ek *mocks.MockCheckpointingKeeper) *Scenario { + bh := randomBlockHash() + validatorAndExtensions, totalPower := generateNValidatorAndVoteExtensions(t, 4, &bh, ec.Epoch.EpochNumber) + var signedVoteExtensions []cbftt.ExtendedVoteInfo + for i, val := range validatorAndExtensions.Vals { + validator := val + ek.EXPECT().GetPubKeyByConsAddr(gomock.Any(), sdk.ConsAddress(validator.ValidatorAddress(t).Bytes())).Return(validator.ProtoPubkey(), nil).AnyTimes() + ek.EXPECT().VerifyBLSSig(gomock.Any(), validatorAndExtensions.Extensions[i].ToBLSSig()).Return(nil).AnyTimes() + ek.EXPECT().GetBlsPubKey(gomock.Any(), validator.ValidatorAddress(t)).Return(validator.BlsPubKey(), nil).AnyTimes() + // empty vote extension + signedExtension := validator.SignVoteExtension(t, []byte{}, ec.Ctx.HeaderInfo().Height-1, ec.Ctx.ChainID()) + signedVoteExtensions = append(signedVoteExtensions, signedExtension) + } + + return &Scenario{ + TotalPower: totalPower, + ValidatorSet: validatorAndExtensions.Vals, + Extensions: signedVoteExtensions, + } + }, + expectError: true, + }, + { + name: "1/3 of validators provided invalid bls signature", + scenarioSetup: func(ec *EpochAndCtx, ek *mocks.MockCheckpointingKeeper) *Scenario { + bh := randomBlockHash() + // each validator has the same voting power + numValidators := 9 + invalidValidBlsSig := numValidators / 3 + + validatorAndExtensions, totalPower := generateNValidatorAndVoteExtensions(t, numValidators, &bh, ec.Epoch.EpochNumber) + + var signedVoteExtensions []cbftt.ExtendedVoteInfo + for i, val := range validatorAndExtensions.Vals { + validator := val + ek.EXPECT().GetPubKeyByConsAddr(gomock.Any(), sdk.ConsAddress(validator.ValidatorAddress(t).Bytes())).Return(validator.ProtoPubkey(), nil).AnyTimes() + + if i < invalidValidBlsSig { + ek.EXPECT().VerifyBLSSig(gomock.Any(), validatorAndExtensions.Extensions[i].ToBLSSig()).Return(checkpointingtypes.ErrInvalidBlsSignature).AnyTimes() + } else { + ek.EXPECT().VerifyBLSSig(gomock.Any(), validatorAndExtensions.Extensions[i].ToBLSSig()).Return(nil).AnyTimes() + } + ek.EXPECT().GetBlsPubKey(gomock.Any(), validator.ValidatorAddress(t)).Return(validator.BlsPubKey(), nil).AnyTimes() + marshaledExtension, err := validatorAndExtensions.Extensions[i].Marshal() + require.NoError(t, err) + signedExtension := validator.SignVoteExtension(t, marshaledExtension, ec.Ctx.HeaderInfo().Height-1, ec.Ctx.ChainID()) + signedVoteExtensions = append(signedVoteExtensions, signedExtension) + } + + return &Scenario{ + TotalPower: totalPower, + ValidatorSet: validatorAndExtensions.Vals, + Extensions: signedVoteExtensions, + } + }, + expectError: true, + }, + { + name: "less than 1/3 of validators provided invalid bls signature", + scenarioSetup: func(ec *EpochAndCtx, ek *mocks.MockCheckpointingKeeper) *Scenario { + bh := randomBlockHash() + // each validator has the same voting power + numValidators := 9 + invalidBlsSig := numValidators/3 - 1 + + validatorAndExtensions, totalPower := generateNValidatorAndVoteExtensions(t, numValidators, &bh, ec.Epoch.EpochNumber) + + var signedVoteExtensions []cbftt.ExtendedVoteInfo + for i, val := range validatorAndExtensions.Vals { + validator := val + ek.EXPECT().GetPubKeyByConsAddr(gomock.Any(), sdk.ConsAddress(validator.ValidatorAddress(t).Bytes())).Return(validator.ProtoPubkey(), nil).AnyTimes() + + if i < invalidBlsSig { + ek.EXPECT().VerifyBLSSig(gomock.Any(), validatorAndExtensions.Extensions[i].ToBLSSig()).Return(checkpointingtypes.ErrInvalidBlsSignature).AnyTimes() + } else { + ek.EXPECT().VerifyBLSSig(gomock.Any(), validatorAndExtensions.Extensions[i].ToBLSSig()).Return(nil).AnyTimes() + } + ek.EXPECT().GetBlsPubKey(gomock.Any(), validator.ValidatorAddress(t)).Return(validator.BlsPubKey(), nil).AnyTimes() + marshaledExtension, err := validatorAndExtensions.Extensions[i].Marshal() + require.NoError(t, err) + signedExtension := validator.SignVoteExtension(t, marshaledExtension, ec.Ctx.HeaderInfo().Height-1, ec.Ctx.ChainID()) + signedVoteExtensions = append(signedVoteExtensions, signedExtension) + } + + return &Scenario{ + TotalPower: totalPower, + ValidatorSet: validatorAndExtensions.Vals, + Extensions: signedVoteExtensions, + } + }, + expectError: false, + }, + { + name: "2/3 + 1 of validators voted for valid block hash, the rest voted for invalid block hash", + scenarioSetup: func(ec *EpochAndCtx, ek *mocks.MockCheckpointingKeeper) *Scenario { + bh := randomBlockHash() + bh1 := randomBlockHash() + + validatorAndExtensionsValid, totalPowerValid := generateNValidatorAndVoteExtensions(t, 7, &bh, ec.Epoch.EpochNumber) + validatorAndExtensionsInvalid, totalPowerInvalid := generateNValidatorAndVoteExtensions(t, 2, &bh1, ec.Epoch.EpochNumber) + + var allvalidators []TestValidator + allvalidators = append(allvalidators, validatorAndExtensionsValid.Vals...) + allvalidators = append(allvalidators, validatorAndExtensionsInvalid.Vals...) + + var allExtensions []checkpointingtypes.VoteExtension + allExtensions = append(allExtensions, validatorAndExtensionsValid.Extensions...) + allExtensions = append(allExtensions, validatorAndExtensionsInvalid.Extensions...) + + var signedVoteExtensions []cbftt.ExtendedVoteInfo + for i, val := range allvalidators { + validator := val + ek.EXPECT().GetPubKeyByConsAddr(gomock.Any(), sdk.ConsAddress(validator.ValidatorAddress(t).Bytes())).Return(validator.ProtoPubkey(), nil).AnyTimes() + ek.EXPECT().VerifyBLSSig(gomock.Any(), allExtensions[i].ToBLSSig()).Return(nil).AnyTimes() + ek.EXPECT().GetBlsPubKey(gomock.Any(), validator.ValidatorAddress(t)).Return(validator.BlsPubKey(), nil).AnyTimes() + marshaledExtension, err := allExtensions[i].Marshal() + require.NoError(t, err) + signedExtension := validator.SignVoteExtension(t, marshaledExtension, ec.Ctx.HeaderInfo().Height-1, ec.Ctx.ChainID()) + signedVoteExtensions = append(signedVoteExtensions, signedExtension) + } + + return &Scenario{ + TotalPower: totalPowerValid + totalPowerInvalid, + ValidatorSet: allvalidators, + Extensions: signedVoteExtensions, + } + }, + expectError: false, + }, + { + name: "All valid vote extensions", + scenarioSetup: func(ec *EpochAndCtx, ek *mocks.MockCheckpointingKeeper) *Scenario { + bh := randomBlockHash() + validatorAndExtensions, totalPower := generateNValidatorAndVoteExtensions(t, 4, &bh, ec.Epoch.EpochNumber) + + var signedVoteExtensions []cbftt.ExtendedVoteInfo + for i, val := range validatorAndExtensions.Vals { + validator := val + ek.EXPECT().GetPubKeyByConsAddr(gomock.Any(), sdk.ConsAddress(validator.ValidatorAddress(t).Bytes())).Return(validator.ProtoPubkey(), nil).AnyTimes() + ek.EXPECT().VerifyBLSSig(gomock.Any(), validatorAndExtensions.Extensions[i].ToBLSSig()).Return(nil).AnyTimes() + ek.EXPECT().GetBlsPubKey(gomock.Any(), validator.ValidatorAddress(t)).Return(validator.BlsPubKey(), nil).AnyTimes() + marshaledExtension, err := validatorAndExtensions.Extensions[i].Marshal() + require.NoError(t, err) + signedExtension := validator.SignVoteExtension(t, marshaledExtension, ec.Ctx.HeaderInfo().Height-1, ec.Ctx.ChainID()) + signedVoteExtensions = append(signedVoteExtensions, signedExtension) + } + + return &Scenario{ + TotalPower: totalPower, + ValidatorSet: validatorAndExtensions.Vals, + Extensions: signedVoteExtensions, + } + }, + expectError: false, + }, + + // TODO: Add scenarios testing compatibility of prepareProposal, processProposal and preBlocker + } + + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + c := gomock.NewController(t) + ek := mocks.NewMockCheckpointingKeeper(c) + mem := mempool.NoOpMempool{} + ec := epochAndVoteExtensionCtx() + scenario := tt.scenarioSetup(ec, ek) + // Those are true for every scenario + ek.EXPECT().GetEpoch(gomock.Any()).Return(ec.Epoch).AnyTimes() + 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() + + h := checkpointing.NewProposalHandler( + log.NewNopLogger(), + ek, + mem, + nil, + ) + + commitInfo, _, cometInfo := helper.ExtendedCommitToLastCommit(cbftt.ExtendedCommitInfo{Round: 0, Votes: scenario.Extensions}) + scenario.Extensions = commitInfo.Votes + ec.Ctx = ec.Ctx.WithCometInfo(cometInfo) + + req := requestPrepareProposal(ec.Ctx.HeaderInfo().Height, commitInfo) + prop, err := h.PrepareProposal()(ec.Ctx, req) + if tt.expectError { + require.Error(t, err) + } else { + require.NoError(t, err) + require.Len(t, prop.Txs, 1) + var checkpoint checkpointingtypes.InjectedCheckpoint + err := checkpoint.Unmarshal(prop.Txs[0]) + require.NoError(t, err) + err = verifyCheckpoint(scenario.ValidatorSet, checkpoint.Ckpt.Ckpt) + require.NoError(t, err) + } + }) + } +} diff --git a/x/checkpointing/types/bls_key.pb.go b/x/checkpointing/types/bls_key.pb.go index cc2cd6b74..ca65cdc8f 100644 --- a/x/checkpointing/types/bls_key.pb.go +++ b/x/checkpointing/types/bls_key.pb.go @@ -5,7 +5,7 @@ package types import ( fmt "fmt" - github_com_babylonchain_babylon_crypto_bls12381 "github.com/babylonchain/babylon/crypto/bls12381" + github_com_babylonlabs_io_babylon_crypto_bls12381 "github.com/babylonlabs-io/babylon/crypto/bls12381" _ "github.com/cosmos/gogoproto/gogoproto" proto "github.com/cosmos/gogoproto/proto" io "io" @@ -27,7 +27,7 @@ const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package // BlsKey wraps BLS public key with PoP type BlsKey struct { // pubkey is the BLS public key of a validator - Pubkey *github_com_babylonchain_babylon_crypto_bls12381.PublicKey `protobuf:"bytes,1,opt,name=pubkey,proto3,customtype=github.com/babylonchain/babylon/crypto/bls12381.PublicKey" json:"pubkey,omitempty"` + Pubkey *github_com_babylonlabs_io_babylon_crypto_bls12381.PublicKey `protobuf:"bytes,1,opt,name=pubkey,proto3,customtype=github.com/babylonlabs-io/babylon/crypto/bls12381.PublicKey" json:"pubkey,omitempty"` // pop is the proof-of-possession of the BLS key Pop *ProofOfPossession `protobuf:"bytes,2,opt,name=pop,proto3" json:"pop,omitempty"` } @@ -80,7 +80,7 @@ type ProofOfPossession struct { Ed25519Sig []byte `protobuf:"bytes,1,opt,name=ed25519_sig,json=ed25519Sig,proto3" json:"ed25519_sig,omitempty"` // bls_sig is the result of PoP, bls_sig = sign(key = BLS_sk, data = // ed25519_sig) - BlsSig *github_com_babylonchain_babylon_crypto_bls12381.Signature `protobuf:"bytes,2,opt,name=bls_sig,json=blsSig,proto3,customtype=github.com/babylonchain/babylon/crypto/bls12381.Signature" json:"bls_sig,omitempty"` + BlsSig *github_com_babylonlabs_io_babylon_crypto_bls12381.Signature `protobuf:"bytes,2,opt,name=bls_sig,json=blsSig,proto3,customtype=github.com/babylonlabs-io/babylon/crypto/bls12381.Signature" json:"bls_sig,omitempty"` } func (m *ProofOfPossession) Reset() { *m = ProofOfPossession{} } @@ -246,7 +246,7 @@ type VoteExtension struct { // height is the height of the vote extension Height uint64 `protobuf:"varint,5,opt,name=height,proto3" json:"height,omitempty"` // bls_sig is the BLS signature - BlsSig *github_com_babylonchain_babylon_crypto_bls12381.Signature `protobuf:"bytes,6,opt,name=bls_sig,json=blsSig,proto3,customtype=github.com/babylonchain/babylon/crypto/bls12381.Signature" json:"bls_sig,omitempty"` + BlsSig *github_com_babylonlabs_io_babylon_crypto_bls12381.Signature `protobuf:"bytes,6,opt,name=bls_sig,json=blsSig,proto3,customtype=github.com/babylonlabs-io/babylon/crypto/bls12381.Signature" json:"bls_sig,omitempty"` } func (m *VoteExtension) Reset() { *m = VoteExtension{} } @@ -324,40 +324,40 @@ func init() { var fileDescriptor_3a8c0d37ce63f038 = []byte{ // 534 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x93, 0x4f, 0x8b, 0xd3, 0x4e, - 0x18, 0xc7, 0x3b, 0xed, 0xfe, 0xb2, 0xbf, 0x4e, 0xbb, 0xe0, 0x46, 0x59, 0x82, 0x42, 0x5a, 0x7b, - 0x90, 0xc2, 0x6a, 0x42, 0xbb, 0x14, 0xdc, 0xc3, 0x1e, 0x2c, 0x28, 0xc2, 0x82, 0x5b, 0x52, 0xac, - 0xe0, 0x25, 0x66, 0xd2, 0xd9, 0xcc, 0xd0, 0x69, 0x66, 0xc8, 0x4c, 0xe2, 0xe6, 0x05, 0x78, 0x13, - 0xf4, 0x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x6a, 0xa9, 0xdf, 0xc2, 0x4d, + 0x1a, 0x83, 0x1f, 0xba, 0x51, 0x3a, 0x37, 0x36, 0x0a, 0xc8, 0xab, 0x85, 0xf0, 0x22, 0x9d, 0x2b, + 0x9e, 0x90, 0xb2, 0x20, 0x94, 0xc6, 0x95, 0xa2, 0x52, 0xed, 0x7e, 0xbe, 0x7d, 0xed, 0xbf, 0xde, + 0xfe, 0xe8, 0xd5, 0x97, 0x85, 0x89, 0xce, 0x16, 0x26, 0xfa, 0xb6, 0x30, 0xd1, 0xc7, 0xa5, 0x59, + 0x3b, 0x5b, 0x9a, 0xb5, 0xaf, 0x4b, 0xb3, 0xf6, 0xe6, 0xde, 0xdf, 0xed, 0x4f, 0x7f, 0x7b, 0xbf, + 0x32, 0x8f, 0xa9, 0x20, 0x5a, 0xf1, 0x16, 0xf7, 0xbf, 0x07, 0x00, 0x00, 0xff, 0xff, 0x0a, 0x52, + 0xce, 0x8d, 0xe5, 0x03, 0x00, 0x00, } func (m *BlsKey) Marshal() (dAtA []byte, err error) { @@ -774,7 +774,7 @@ func (m *BlsKey) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - var v github_com_babylonchain_babylon_crypto_bls12381.PublicKey + var v github_com_babylonlabs_io_babylon_crypto_bls12381.PublicKey m.Pubkey = &v if err := m.Pubkey.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err @@ -929,7 +929,7 @@ func (m *ProofOfPossession) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - var v github_com_babylonchain_babylon_crypto_bls12381.Signature + var v github_com_babylonlabs_io_babylon_crypto_bls12381.Signature m.BlsSig = &v if err := m.BlsSig.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err @@ -1370,7 +1370,7 @@ func (m *VoteExtension) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - var v github_com_babylonchain_babylon_crypto_bls12381.Signature + var v github_com_babylonlabs_io_babylon_crypto_bls12381.Signature m.BlsSig = &v if err := m.BlsSig.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err diff --git a/x/checkpointing/types/checkpoint.pb.go b/x/checkpointing/types/checkpoint.pb.go index 4d3fdb84c..801ac381d 100644 --- a/x/checkpointing/types/checkpoint.pb.go +++ b/x/checkpointing/types/checkpoint.pb.go @@ -6,7 +6,7 @@ package types import ( bytes "bytes" fmt "fmt" - github_com_babylonchain_babylon_crypto_bls12381 "github.com/babylonchain/babylon/crypto/bls12381" + github_com_babylonlabs_io_babylon_crypto_bls12381 "github.com/babylonlabs-io/babylon/crypto/bls12381" types "github.com/cometbft/cometbft/abci/types" _ "github.com/cosmos/gogoproto/gogoproto" proto "github.com/cosmos/gogoproto/proto" @@ -81,7 +81,7 @@ type RawCheckpoint struct { Bitmap []byte `protobuf:"bytes,3,opt,name=bitmap,proto3" json:"bitmap,omitempty"` // bls_multi_sig defines the multi sig that is aggregated from individual BLS // sigs - BlsMultiSig *github_com_babylonchain_babylon_crypto_bls12381.Signature `protobuf:"bytes,4,opt,name=bls_multi_sig,json=blsMultiSig,proto3,customtype=github.com/babylonchain/babylon/crypto/bls12381.Signature" json:"bls_multi_sig,omitempty"` + BlsMultiSig *github_com_babylonlabs_io_babylon_crypto_bls12381.Signature `protobuf:"bytes,4,opt,name=bls_multi_sig,json=blsMultiSig,proto3,customtype=github.com/babylonlabs-io/babylon/crypto/bls12381.Signature" json:"bls_multi_sig,omitempty"` } func (m *RawCheckpoint) Reset() { *m = RawCheckpoint{} } @@ -137,7 +137,7 @@ type RawCheckpointWithMeta struct { // status defines the status of the checkpoint Status CheckpointStatus `protobuf:"varint,2,opt,name=status,proto3,enum=babylon.checkpointing.v1.CheckpointStatus" json:"status,omitempty"` // bls_aggr_pk defines the aggregated BLS public key - BlsAggrPk *github_com_babylonchain_babylon_crypto_bls12381.PublicKey `protobuf:"bytes,3,opt,name=bls_aggr_pk,json=blsAggrPk,proto3,customtype=github.com/babylonchain/babylon/crypto/bls12381.PublicKey" json:"bls_aggr_pk,omitempty"` + BlsAggrPk *github_com_babylonlabs_io_babylon_crypto_bls12381.PublicKey `protobuf:"bytes,3,opt,name=bls_aggr_pk,json=blsAggrPk,proto3,customtype=github.com/babylonlabs-io/babylon/crypto/bls12381.PublicKey" json:"bls_aggr_pk,omitempty"` // power_sum defines the accumulated voting power for the checkpoint PowerSum uint64 `protobuf:"varint,4,opt,name=power_sum,json=powerSum,proto3" json:"power_sum,omitempty"` // lifecycle defines the lifecycle of this checkpoint, i.e., each state @@ -334,8 +334,8 @@ type BlsSig struct { EpochNum uint64 `protobuf:"varint,1,opt,name=epoch_num,json=epochNum,proto3" json:"epoch_num,omitempty"` // block_hash defines the 'BlockID.Hash', which is the hash of // the block that individual BLS sigs are signed on - BlockHash *BlockHash `protobuf:"bytes,2,opt,name=block_hash,json=blockHash,proto3,customtype=BlockHash" json:"block_hash,omitempty"` - BlsSig *github_com_babylonchain_babylon_crypto_bls12381.Signature `protobuf:"bytes,3,opt,name=bls_sig,json=blsSig,proto3,customtype=github.com/babylonchain/babylon/crypto/bls12381.Signature" json:"bls_sig,omitempty"` + BlockHash *BlockHash `protobuf:"bytes,2,opt,name=block_hash,json=blockHash,proto3,customtype=BlockHash" json:"block_hash,omitempty"` + BlsSig *github_com_babylonlabs_io_babylon_crypto_bls12381.Signature `protobuf:"bytes,3,opt,name=bls_sig,json=blsSig,proto3,customtype=github.com/babylonlabs-io/babylon/crypto/bls12381.Signature" json:"bls_sig,omitempty"` // can't find cosmos_proto.scalar when compiling due to cosmos v0.45.4 does // not support scalar string signer_address = 4 [(cosmos_proto.scalar) = // "cosmos.AddressString"] @@ -414,61 +414,61 @@ func init() { } var fileDescriptor_73996df9c6aabde4 = []byte{ - // 853 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x55, 0x4f, 0x6f, 0xe3, 0x44, - 0x1c, 0x8d, 0x5b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 0x6e, 0x60, 0xc7, 0x59, 0xd4, 0x50, 0x3a, 0xca, - 0x8e, 0x6a, 0xde, 0x90, 0xc0, 0x61, 0x16, 0xc1, 0x77, 0x01, 0x70, 0x42, 0xea, 0xce, 0xec, 0x00, - 0xb1, 0xa0, 0xb1, 0xd6, 0x51, 0x76, 0x36, 0xfb, 0xb5, 0xa7, 0xcf, 0xda, 0x95, 0xbe, 0x40, 0x3f, - 0x47, 0x2c, 0x30, 0x2b, 0xce, 0x62, 0x09, 0x5f, 0x03, 0x65, 0x87, 0xf0, 0x08, 0x25, 0x8d, 0x75, - 0xc1, 0x34, 0x8b, 0x5f, 0x10, 0x81, 0x9a, 0x13, 0x32, 0x3b, 0xca, 0x42, 0x4e, 0x6c, 0x46, 0xfc, - 0x86, 0x2a, 0x37, 0xfa, 0xf8, 0xe9, 0xb3, 0xf6, 0x07, 0x3e, 0xe1, 0x41, 0xe6, 0x68, 0x2e, 0x8d, - 0xf4, 0xc2, 0x08, 0x37, 0x40, 0x24, 0xd6, 0x2f, 0x0c, 0x4c, 0xe7, 0x09, 0xa7, 0xba, 0x13, 0xb2, - 0xdd, 0xee, 0xdd, 0xf7, 0x77, 0x35, 0x8b, 0xf8, 0x31, 0xe2, 0x59, 0x8a, 0xcd, 0xaa, 0x13, 0xb2, - 0x91, 0xd8, 0xd2, 0x22, 0xfe, 0x87, 0xea, 0x1f, 0xdf, 0xb7, 0x95, 0xed, 0x3f, 0xd7, 0xc0, 0xd6, - 0xca, 0xed, 0xbe, 0x24, 0x3c, 0x18, 0x61, 0x8e, 0xe0, 0x47, 0x40, 0x75, 0x67, 0x09, 0x97, 0x17, - 0xac, 0x76, 0xdf, 0xd2, 0x5e, 0x64, 0xba, 0xb6, 0x22, 0x37, 0xa5, 0x08, 0xf6, 0x41, 0x99, 0x71, - 0xc4, 0x33, 0x26, 0x1d, 0xb8, 0xd9, 0xbd, 0xf3, 0x62, 0xf9, 0x52, 0x6b, 0x49, 0x85, 0x59, 0x28, - 0x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xb1, 0x32, 0x27, 0x22, 0x9c, 0x5f, - 0x65, 0x1a, 0xf7, 0x0f, 0xf7, 0x87, 0xe6, 0x68, 0xb0, 0x57, 0x5f, 0xcf, 0x99, 0x06, 0x8d, 0xa7, - 0x24, 0x8d, 0xae, 0x32, 0xf7, 0x87, 0x87, 0xbd, 0x83, 0xe1, 0x83, 0xc1, 0x5e, 0x5d, 0xcd, 0x99, - 0xfb, 0x24, 0x46, 0x21, 0xf9, 0x06, 0x7b, 0x4d, 0xf5, 0xbb, 0x1f, 0x5a, 0xa5, 0xfe, 0xfd, 0x9f, - 0xcf, 0x5a, 0xca, 0x93, 0xb3, 0x96, 0xf2, 0xfb, 0x59, 0x4b, 0x79, 0x7c, 0xde, 0x2a, 0x3d, 0x39, - 0x6f, 0x95, 0x7e, 0x39, 0x6f, 0x95, 0x1e, 0xbc, 0xf7, 0x6f, 0x33, 0x7a, 0xf4, 0xdc, 0x23, 0x24, - 0x9f, 0x03, 0xa7, 0x2c, 0x03, 0x77, 0xf7, 0xef, 0x00, 0x00, 0x00, 0xff, 0xff, 0xc9, 0x97, 0x52, - 0x24, 0xaa, 0x06, 0x00, 0x00, + // 852 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x55, 0xcf, 0x6e, 0x1b, 0x45, + 0x1c, 0xf6, 0x26, 0x1b, 0x53, 0x8f, 0xe3, 0xca, 0x8c, 0x1a, 0x64, 0xb9, 0x92, 0x6d, 0x82, 0x10, + 0xa1, 0xc0, 0xae, 0xe2, 0x1e, 0x40, 0xf4, 0x50, 0x6c, 0xc7, 0x01, 0xab, 0x71, 0x08, 0xbb, 0xb6, + 0x40, 0xbd, 0xac, 0x66, 0x77, 0xc7, 0xeb, 0xc1, 0xb3, 0x3b, 0xab, 0x9d, 0xd9, 0xb4, 0xe6, 0x05, + 0x40, 0x39, 0xf5, 0x05, 0x22, 0x21, 0xf1, 0x02, 0x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e7, + 0xb3, 0x86, 0xf6, 0xf4, 0xac, 0xa1, 0xfd, 0x7e, 0xd6, 0xd0, 0x9e, 0x9c, 0x37, 0x0a, 0x4f, 0xcf, + 0x1b, 0x85, 0x5f, 0xce, 0x1b, 0x85, 0x87, 0x1f, 0xfe, 0xbb, 0x4b, 0x8f, 0x5f, 0x78, 0x8c, 0xd4, + 0xb3, 0xe0, 0x16, 0x55, 0xe8, 0xee, 0xfe, 0x1d, 0x00, 0x00, 0xff, 0xff, 0x96, 0x67, 0xaf, 0xba, + 0xb2, 0x06, 0x00, 0x00, } func (this *RawCheckpoint) Equal(that interface{}) bool { @@ -1157,7 +1157,7 @@ func (m *RawCheckpoint) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - var v github_com_babylonchain_babylon_crypto_bls12381.Signature + var v github_com_babylonlabs_io_babylon_crypto_bls12381.Signature m.BlsMultiSig = &v if err := m.BlsMultiSig.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err @@ -1297,7 +1297,7 @@ func (m *RawCheckpointWithMeta) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - var v github_com_babylonchain_babylon_crypto_bls12381.PublicKey + var v github_com_babylonlabs_io_babylon_crypto_bls12381.PublicKey m.BlsAggrPk = &v if err := m.BlsAggrPk.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err @@ -1735,7 +1735,7 @@ func (m *BlsSig) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - var v github_com_babylonchain_babylon_crypto_bls12381.Signature + var v github_com_babylonlabs_io_babylon_crypto_bls12381.Signature m.BlsSig = &v if err := m.BlsSig.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err diff --git a/x/checkpointing/types/events.pb.go b/x/checkpointing/types/events.pb.go index 10e283497..7c2030c86 100644 --- a/x/checkpointing/types/events.pb.go +++ b/x/checkpointing/types/events.pb.go @@ -368,26 +368,26 @@ func init() { var fileDescriptor_950b7bd81c59f78a = []byte{ // 314 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x52, 0x4d, 0x4a, 0x4c, 0xaa, - 0xcc, 0xc9, 0xcf, 0xd3, 0x4f, 0xce, 0x48, 0x4d, 0xce, 0x2e, 0xc8, 0xcf, 0xcc, 0x2b, 0xc9, 0xcc, - 0x4b, 0xd7, 0x2f, 0x33, 0xd4, 0x4f, 0x2d, 0x4b, 0xcd, 0x2b, 0x29, 0xd6, 0x2b, 0x28, 0xca, 0x2f, - 0xc9, 0x17, 0x92, 0x80, 0x2a, 0xd3, 0x43, 0x51, 0xa6, 0x57, 0x66, 0x28, 0xa5, 0x89, 0xd3, 0x00, - 0x84, 0x00, 0xc4, 0x10, 0xa5, 0x3c, 0x2e, 0x69, 0x57, 0x90, 0xa1, 0xce, 0x70, 0x09, 0xc7, 0xe4, - 0xe4, 0xd2, 0xdc, 0xd2, 0x9c, 0x44, 0x90, 0x16, 0x21, 0x7f, 0x2e, 0x2e, 0x84, 0x16, 0x09, 0x46, - 0x05, 0x46, 0x0d, 0x6e, 0x23, 0x7d, 0x3d, 0x5c, 0x16, 0xeb, 0x05, 0x25, 0x96, 0x23, 0x0c, 0x0a, - 0xcf, 0x2c, 0xc9, 0xf0, 0x4d, 0x2d, 0x49, 0x0c, 0x42, 0x32, 0x42, 0x29, 0x83, 0x4b, 0x14, 0xcd, - 0xbe, 0xe0, 0xd4, 0xc4, 0x9c, 0xd4, 0x14, 0xea, 0xdb, 0x94, 0xcd, 0x25, 0x81, 0x6e, 0x53, 0x69, - 0x52, 0x6e, 0x66, 0x49, 0x09, 0x7d, 0x2c, 0x73, 0xce, 0xcf, 0x4b, 0xcb, 0x2c, 0xca, 0xa5, 0x8f, - 0x65, 0x6e, 0x99, 0x79, 0x89, 0x39, 0x99, 0x55, 0x74, 0xb2, 0x2c, 0xbf, 0x28, 0x3d, 0xbf, 0xa4, - 0x24, 0x35, 0x8f, 0xfa, 0x96, 0xdd, 0x60, 0xe4, 0x92, 0x82, 0xd8, 0x96, 0x9f, 0x97, 0x96, 0x93, - 0x99, 0x0c, 0xd2, 0x89, 0xd0, 0x22, 0x14, 0xc7, 0x25, 0x96, 0x8c, 0x90, 0x88, 0xc7, 0xb0, 0x5b, - 0x9d, 0x48, 0xbb, 0x83, 0x44, 0x93, 0xb1, 0x9a, 0x1f, 0xc5, 0x25, 0x90, 0x93, 0x9f, 0x9c, 0x98, - 0x83, 0x6c, 0x32, 0x13, 0x79, 0xbe, 0xe2, 0x07, 0x1b, 0x84, 0x90, 0x70, 0xf2, 0x3f, 0xf1, 0x48, - 0x8e, 0xf1, 0xc2, 0x23, 0x39, 0xc6, 0x07, 0x8f, 0xe4, 0x18, 0x27, 0x3c, 0x96, 0x63, 0xb8, 0xf0, - 0x58, 0x8e, 0xe1, 0xc6, 0x63, 0x39, 0x86, 0x28, 0xd3, 0xf4, 0xcc, 0x92, 0x8c, 0xd2, 0x24, 0xbd, - 0xe4, 0xfc, 0x5c, 0x7d, 0xa8, 0x2d, 0xc9, 0x19, 0x89, 0x99, 0x79, 0x30, 0x8e, 0x7e, 0x05, 0x5a, - 0x3e, 0x2e, 0xa9, 0x2c, 0x48, 0x2d, 0x4e, 0x62, 0x03, 0x67, 0x60, 0x63, 0x40, 0x00, 0x00, 0x00, - 0xff, 0xff, 0x47, 0xbc, 0x3a, 0x24, 0x2e, 0x04, 0x00, 0x00, + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xbc, 0x93, 0x31, 0x4b, 0x03, 0x31, + 0x18, 0x86, 0x1b, 0x07, 0x87, 0x38, 0x28, 0x85, 0x4a, 0xa9, 0x10, 0xa4, 0x20, 0xea, 0x60, 0x42, + 0x75, 0x70, 0xd6, 0xa2, 0x9b, 0x88, 0x75, 0x10, 0x3a, 0x28, 0x49, 0x4c, 0xef, 0x42, 0x73, 0xc9, +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x7b, 0x0d, 0xfe, 0x2b, 0xbf, 0x0f, 0xb7, 0x94, 0xe1, 0x54, + 0x2d, 0x92, 0xd7, 0xfe, 0xb7, 0xd5, 0xe6, 0x14, 0xe4, 0x82, 0xf3, 0x9b, 0xb7, 0x0c, 0x81, 0x71, + 0x86, 0xc0, 0x7b, 0x86, 0xc0, 0x6b, 0x8e, 0x6a, 0xe3, 0x1c, 0xd5, 0x26, 0x39, 0xaa, 0xf5, 0x4f, + 0x3d, 0x69, 0xfd, 0x84, 0x61, 0x6e, 0x02, 0x32, 0xb7, 0x28, 0xca, 0xe2, 0x23, 0x69, 0x3e, 0x9f, + 0xe4, 0xb9, 0x74, 0xc9, 0x76, 0x14, 0x8a, 0x98, 0xad, 0x4f, 0x4f, 0xf8, 0xe4, 0x23, 0x00, 0x00, + 0xff, 0xff, 0xc6, 0xac, 0x9d, 0x86, 0x30, 0x04, 0x00, 0x00, } func (m *EventCheckpointAccumulating) Marshal() (dAtA []byte, err error) { diff --git a/x/checkpointing/types/expected_keepers.go b/x/checkpointing/types/expected_keepers.go index 329cdb67f..53f15112c 100644 --- a/x/checkpointing/types/expected_keepers.go +++ b/x/checkpointing/types/expected_keepers.go @@ -7,14 +7,13 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" - epochingtypes "github.com/babylonchain/babylon/x/epoching/types" + epochingtypes "github.com/babylonlabs-io/babylon/x/epoching/types" ) // EpochingKeeper defines the expected interface needed to retrieve epoch info type EpochingKeeper interface { GetEpoch(ctx context.Context) *epochingtypes.Epoch EnqueueMsg(ctx context.Context, msg epochingtypes.QueuedMessage) - GetAppHash(ctx context.Context, height uint64) ([]byte, error) GetValidatorSet(ctx context.Context, epochNumer uint64) epochingtypes.ValidatorSet GetTotalVotingPower(ctx context.Context, epochNumber uint64) int64 CheckMsgCreateValidator(ctx context.Context, msg *stakingtypes.MsgCreateValidator) error @@ -30,6 +29,7 @@ type EpochingKeeper interface { // CheckpointingHooks event hooks for raw checkpoint object (noalias) type CheckpointingHooks interface { AfterBlsKeyRegistered(ctx context.Context, valAddr sdk.ValAddress) error // Must be called when a BLS key is registered + AfterRawCheckpointSealed(ctx context.Context, epoch uint64) error // Must be called when a raw checkpoint is SEALED AfterRawCheckpointConfirmed(ctx context.Context, epoch uint64) error // Must be called when a raw checkpoint is CONFIRMED AfterRawCheckpointForgotten(ctx context.Context, ckpt *RawCheckpoint) error // Must be called when a raw checkpoint is FORGOTTEN AfterRawCheckpointFinalized(ctx context.Context, epoch uint64) error // Must be called when a raw checkpoint is FINALIZED diff --git a/x/checkpointing/types/genesis.go b/x/checkpointing/types/genesis.go index 1ab34122e..065cd2268 100644 --- a/x/checkpointing/types/genesis.go +++ b/x/checkpointing/types/genesis.go @@ -4,6 +4,7 @@ import ( "encoding/json" "errors" "os" + "path/filepath" tmjson "github.com/cometbft/cometbft/libs/json" "github.com/cosmos/cosmos-sdk/codec" @@ -11,7 +12,7 @@ import ( cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types" sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/babylonchain/babylon/crypto/bls12381" + "github.com/babylonlabs-io/babylon/crypto/bls12381" ) // DefaultGenesis returns the default Capability genesis state @@ -54,7 +55,7 @@ func NewGenesisKey(delAddr sdk.ValAddress, blsPubKey *bls12381.PublicKey, pop *P } func LoadGenesisKeyFromFile(filePath string) (*GenesisKey, error) { - genBlsJSONBytes, err := os.ReadFile(filePath) + genBlsJSONBytes, err := os.ReadFile(filepath.Clean(filePath)) if err != nil { return nil, err } diff --git a/x/checkpointing/types/genesis.pb.go b/x/checkpointing/types/genesis.pb.go index 380afef3d..78fabad09 100644 --- a/x/checkpointing/types/genesis.pb.go +++ b/x/checkpointing/types/genesis.pb.go @@ -143,28 +143,28 @@ func init() { } var fileDescriptor_bf2c524ebc9800de = []byte{ - // 325 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x74, 0x90, 0xcf, 0x6a, 0x2a, 0x31, - 0x18, 0xc5, 0xcd, 0x15, 0xbc, 0x18, 0x5d, 0xb4, 0xb3, 0x12, 0xa1, 0x61, 0x90, 0x52, 0x84, 0x42, - 0x82, 0x16, 0x17, 0x42, 0x37, 0x75, 0xe3, 0xa2, 0x8b, 0x8a, 0x5d, 0x14, 0xba, 0x91, 0x24, 0x13, - 0xc6, 0x60, 0x9c, 0x0c, 0x93, 0x38, 0x34, 0x6f, 0xd1, 0x67, 0xe9, 0x53, 0x74, 0xe9, 0xb2, 0xcb, - 0xa2, 0x2f, 0x52, 0x66, 0x26, 0xb5, 0xb4, 0x30, 0xab, 0xfc, 0xf9, 0xce, 0xf9, 0xce, 0xe1, 0x07, - 0xaf, 0x18, 0x65, 0x4e, 0xe9, 0x84, 0xf0, 0xb5, 0xe0, 0x9b, 0x54, 0xcb, 0xc4, 0xca, 0x24, 0x26, - 0xf9, 0x88, 0xc4, 0x22, 0x11, 0x46, 0x1a, 0x9c, 0x66, 0xda, 0xea, 0xa0, 0xe7, 0x75, 0xf8, 0x97, - 0x0e, 0xe7, 0xa3, 0x7e, 0xc8, 0xb5, 0xd9, 0x6a, 0x43, 0x78, 0xe6, 0x52, 0xab, 0x89, 0x88, 0xc6, - 0x93, 0xc9, 0x68, 0x4a, 0x36, 0xc2, 0x79, 0x6f, 0xbf, 0x3e, 0x83, 0x29, 0xb3, 0xda, 0x08, 0x57, - 0xe9, 0x06, 0x4f, 0xb0, 0x3b, 0xaf, 0x42, 0x1f, 0x2d, 0xb5, 0x22, 0x98, 0xc3, 0xae, 0x2f, 0x51, - 0x88, 0x4c, 0x0f, 0x84, 0xcd, 0x61, 0x67, 0x7c, 0x89, 0xeb, 0xaa, 0x60, 0xef, 0xbe, 0x17, 0x6e, - 0xd9, 0x89, 0x4f, 0x77, 0x33, 0x78, 0x03, 0x10, 0xfe, 0xcc, 0x82, 0x6b, 0x78, 0x9e, 0x53, 0x25, - 0x23, 0x6a, 0x75, 0xb6, 0xa2, 0x51, 0x94, 0x09, 0x53, 0x2c, 0x07, 0xc3, 0xf6, 0xf2, 0xec, 0x34, - 0xb8, 0xab, 0xfe, 0x83, 0x29, 0xfc, 0xef, 0x5b, 0xf6, 0xfe, 0x85, 0x60, 0xd8, 0x19, 0x87, 0xf5, - 0xf9, 0x33, 0x55, 0x66, 0xb7, 0x58, 0x79, 0x06, 0xb7, 0x10, 0xe6, 0x54, 0xad, 0xd2, 0x1d, 0x2b, - 0xdc, 0xcd, 0xd2, 0x7d, 0x81, 0x2b, 0x5c, 0xb8, 0xc2, 0x85, 0x3d, 0x2e, 0xbc, 0xd8, 0xb1, 0xc2, - 0xda, 0xce, 0xa9, 0x5a, 0x94, 0xfa, 0xd9, 0xc3, 0xfb, 0x01, 0x81, 0xfd, 0x01, 0x81, 0xcf, 0x03, - 0x02, 0xaf, 0x47, 0xd4, 0xd8, 0x1f, 0x51, 0xe3, 0xe3, 0x88, 0x1a, 0xcf, 0x93, 0x58, 0xda, 0xf5, - 0x8e, 0x61, 0xae, 0xb7, 0xc4, 0x77, 0xe1, 0x6b, 0x2a, 0x93, 0xef, 0x07, 0x79, 0xf9, 0x43, 0xda, - 0xba, 0x54, 0x18, 0xd6, 0x2a, 0x29, 0xdf, 0x7c, 0x05, 0x00, 0x00, 0xff, 0xff, 0x1c, 0xab, 0xd1, - 0x3a, 0xf3, 0x01, 0x00, 0x00, + // 327 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x74, 0x90, 0x4f, 0x4b, 0xfb, 0x30, + 0x1c, 0xc6, 0x97, 0xdf, 0x60, 0x3f, 0x96, 0xed, 0xa0, 0x3d, 0x8d, 0x81, 0xa1, 0x0c, 0x91, 0x81, + 0x98, 0xb0, 0xc9, 0x90, 0x81, 0x17, 0x77, 0xd9, 0xc1, 0xcb, 0x9c, 0x07, 0xc1, 0xcb, 0x48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 0x2b, 0x4f, 0xef, 0x16, 0xc2, 0x8c, 0xca, 0x55, 0xb2, 0x63, + 0x85, 0xbb, 0x59, 0xba, 0xcf, 0x70, 0x85, 0x0b, 0x57, 0xb8, 0xb0, 0xc3, 0x85, 0x17, 0x3b, 0x56, + 0x58, 0xdb, 0x19, 0x95, 0x8b, 0x52, 0x3f, 0x7b, 0x78, 0x3f, 0x20, 0xb0, 0x3f, 0x20, 0xf0, 0x79, + 0x40, 0xe0, 0x35, 0x47, 0x8d, 0x7d, 0x8e, 0x1a, 0x1f, 0x39, 0x6a, 0x3c, 0xdf, 0x44, 0xc2, 0xac, + 0x77, 0x0c, 0x07, 0x6a, 0x4b, 0x5c, 0x17, 0x49, 0x99, 0xbe, 0x12, 0xea, 0xfb, 0x49, 0x5e, 0xfe, + 0xb0, 0x36, 0x36, 0xe1, 0x9a, 0xb5, 0x4a, 0xce, 0xd7, 0x5f, 0x01, 0x00, 0x00, 0xff, 0xff, 0x75, + 0xb3, 0x01, 0x5c, 0xf5, 0x01, 0x00, 0x00, } func (m *GenesisState) Marshal() (dAtA []byte, err error) { diff --git a/x/checkpointing/types/hooks.go b/x/checkpointing/types/hooks.go index 3d8008870..1bc63e394 100644 --- a/x/checkpointing/types/hooks.go +++ b/x/checkpointing/types/hooks.go @@ -2,6 +2,7 @@ package types import ( "context" + sdk "github.com/cosmos/cosmos-sdk/types" ) @@ -23,6 +24,15 @@ func (h MultiCheckpointingHooks) AfterBlsKeyRegistered(ctx context.Context, valA return nil } +func (h MultiCheckpointingHooks) AfterRawCheckpointSealed(ctx context.Context, epoch uint64) error { + for i := range h { + if err := h[i].AfterRawCheckpointSealed(ctx, epoch); err != nil { + return err + } + } + return nil +} + func (h MultiCheckpointingHooks) AfterRawCheckpointConfirmed(ctx context.Context, epoch uint64) error { for i := range h { if err := h[i].AfterRawCheckpointConfirmed(ctx, epoch); err != nil { diff --git a/x/checkpointing/types/keys.go b/x/checkpointing/types/keys.go index 735e8c505..1db18fc52 100644 --- a/x/checkpointing/types/keys.go +++ b/x/checkpointing/types/keys.go @@ -1,7 +1,7 @@ package types import ( - "github.com/babylonchain/babylon/crypto/bls12381" + "github.com/babylonlabs-io/babylon/crypto/bls12381" sdk "github.com/cosmos/cosmos-sdk/types" ) @@ -31,6 +31,8 @@ var ( AddrToBlsKeyPrefix = append(RegistrationPrefix, 0x0) // where we save the concrete BLS public keys BlsKeyToAddrPrefix = append(RegistrationPrefix, 0x1) // where we save BLS key set + + LastFinalizedEpochKey = []byte{0x04} // LastFinalizedEpochKey defines the key to store the last finalised epoch ) // CkptsObjectKey defines epoch diff --git a/x/checkpointing/types/msgs.go b/x/checkpointing/types/msgs.go index 4af049c62..869f36578 100644 --- a/x/checkpointing/types/msgs.go +++ b/x/checkpointing/types/msgs.go @@ -9,7 +9,7 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" - "github.com/babylonchain/babylon/crypto/bls12381" + "github.com/babylonlabs-io/babylon/crypto/bls12381" ) var ( diff --git a/x/checkpointing/types/msgs_test.go b/x/checkpointing/types/msgs_test.go index f8191cce7..89301ebbf 100644 --- a/x/checkpointing/types/msgs_test.go +++ b/x/checkpointing/types/msgs_test.go @@ -4,10 +4,10 @@ import ( "testing" sdkmath "cosmossdk.io/math" - appparams "github.com/babylonchain/babylon/app/params" - "github.com/babylonchain/babylon/crypto/bls12381" - "github.com/babylonchain/babylon/privval" - "github.com/babylonchain/babylon/x/checkpointing/types" + appparams "github.com/babylonlabs-io/babylon/app/params" + "github.com/babylonlabs-io/babylon/crypto/bls12381" + "github.com/babylonlabs-io/babylon/privval" + "github.com/babylonlabs-io/babylon/x/checkpointing/types" "github.com/cometbft/cometbft/crypto/ed25519" "github.com/cosmos/cosmos-sdk/codec" codectypes "github.com/cosmos/cosmos-sdk/codec/types" diff --git a/x/checkpointing/types/pop.go b/x/checkpointing/types/pop.go index 6e7586157..c5f14fc03 100644 --- a/x/checkpointing/types/pop.go +++ b/x/checkpointing/types/pop.go @@ -1,7 +1,7 @@ package types import ( - "github.com/babylonchain/babylon/crypto/bls12381" + "github.com/babylonlabs-io/babylon/crypto/bls12381" "github.com/cometbft/cometbft/crypto/ed25519" cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types" ) diff --git a/x/checkpointing/types/pop_test.go b/x/checkpointing/types/pop_test.go index 3bd2aec76..10e03df6a 100644 --- a/x/checkpointing/types/pop_test.go +++ b/x/checkpointing/types/pop_test.go @@ -1,8 +1,8 @@ package types_test import ( - "github.com/babylonchain/babylon/crypto/bls12381" - "github.com/babylonchain/babylon/privval" + "github.com/babylonlabs-io/babylon/crypto/bls12381" + "github.com/babylonlabs-io/babylon/privval" "github.com/cometbft/cometbft/crypto/ed25519" "github.com/cosmos/cosmos-sdk/crypto/codec" "github.com/stretchr/testify/require" diff --git a/x/checkpointing/types/query.go b/x/checkpointing/types/query.go new file mode 100644 index 000000000..b343b9ab5 --- /dev/null +++ b/x/checkpointing/types/query.go @@ -0,0 +1,60 @@ +package types + +import "encoding/hex" + +// ToResponse generates a RawCheckpointResponse struct from RawCheckpoint. +func (r *RawCheckpoint) ToResponse() *RawCheckpointResponse { + return &RawCheckpointResponse{ + EpochNum: r.EpochNum, + BlockHashHex: r.BlockHash.String(), + Bitmap: r.Bitmap, + BlsMultiSig: r.BlsMultiSig, + } +} + +// ToRawCheckpoint generates a RawCheckpoint struct from RawCheckpointResponse. +func (r *RawCheckpointResponse) ToRawCheckpoint() (*RawCheckpoint, error) { + blockHashBz, err := hex.DecodeString(r.BlockHashHex) + if err != nil { + return nil, err + } + blockHash := BlockHash(blockHashBz) + + return &RawCheckpoint{ + EpochNum: r.EpochNum, + BlockHash: &blockHash, + Bitmap: r.Bitmap, + BlsMultiSig: r.BlsMultiSig, + }, nil +} + +// ToResponse generates a RawCheckpointWithMetaResponse struct from RawCheckpointWithMeta. +func (r *RawCheckpointWithMeta) ToResponse() *RawCheckpointWithMetaResponse { + return &RawCheckpointWithMetaResponse{ + Ckpt: r.Ckpt.ToResponse(), + Status: r.Status, + StatusDesc: r.Status.String(), + BlsAggrPk: r.BlsAggrPk, + PowerSum: r.PowerSum, + Lifecycle: NewCheckpointStateUpdateResponse(r.Lifecycle), + } +} + +// ToResponse generates a CheckpointStateUpdateResponse struct from CheckpointStateUpdate. +func (c *CheckpointStateUpdate) ToResponse() *CheckpointStateUpdateResponse { + return &CheckpointStateUpdateResponse{ + State: c.State, + StatusDesc: c.State.String(), + BlockHeight: c.BlockHeight, + BlockTime: c.BlockTime, + } +} + +// NewCheckpointStateUpdateResponse creates a new CheckpointStateUpdateResponse slice from []*CheckpointStateUpdate. +func NewCheckpointStateUpdateResponse(cs []*CheckpointStateUpdate) (resp []*CheckpointStateUpdateResponse) { + resp = make([]*CheckpointStateUpdateResponse, len(cs)) + for i, c := range cs { + resp[i] = c.ToResponse() + } + return resp +} diff --git a/x/checkpointing/types/query.pb.go b/x/checkpointing/types/query.pb.go index 96dcf8fc1..30aef80a1 100644 --- a/x/checkpointing/types/query.pb.go +++ b/x/checkpointing/types/query.pb.go @@ -6,22 +6,28 @@ package types import ( context "context" fmt "fmt" + github_com_babylonlabs_io_babylon_crypto_bls12381 "github.com/babylonlabs-io/babylon/crypto/bls12381" query "github.com/cosmos/cosmos-sdk/types/query" + _ "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. @@ -89,7 +95,7 @@ func (m *QueryRawCheckpointListRequest) GetPagination() *query.PageRequest { // Query/RawCheckpoints RPC method. type QueryRawCheckpointListResponse struct { // the order is going from the newest to oldest based on the epoch number - RawCheckpoints []*RawCheckpointWithMeta `protobuf:"bytes,1,rep,name=raw_checkpoints,json=rawCheckpoints,proto3" json:"raw_checkpoints,omitempty"` + RawCheckpoints []*RawCheckpointWithMetaResponse `protobuf:"bytes,1,rep,name=raw_checkpoints,json=rawCheckpoints,proto3" json:"raw_checkpoints,omitempty"` // pagination defines the pagination in the response. Pagination *query.PageResponse `protobuf:"bytes,2,opt,name=pagination,proto3" json:"pagination,omitempty"` } @@ -127,7 +133,7 @@ func (m *QueryRawCheckpointListResponse) XXX_DiscardUnknown() { var xxx_messageInfo_QueryRawCheckpointListResponse proto.InternalMessageInfo -func (m *QueryRawCheckpointListResponse) GetRawCheckpoints() []*RawCheckpointWithMeta { +func (m *QueryRawCheckpointListResponse) GetRawCheckpoints() []*RawCheckpointWithMetaResponse { if m != nil { return m.RawCheckpoints } @@ -191,7 +197,7 @@ func (m *QueryRawCheckpointRequest) GetEpochNum() uint64 { // QueryRawCheckpointResponse is the response type for the Query/RawCheckpoint // RPC method. type QueryRawCheckpointResponse struct { - RawCheckpoint *RawCheckpointWithMeta `protobuf:"bytes,1,opt,name=raw_checkpoint,json=rawCheckpoint,proto3" json:"raw_checkpoint,omitempty"` + RawCheckpoint *RawCheckpointWithMetaResponse `protobuf:"bytes,1,opt,name=raw_checkpoint,json=rawCheckpoint,proto3" json:"raw_checkpoint,omitempty"` } func (m *QueryRawCheckpointResponse) Reset() { *m = QueryRawCheckpointResponse{} } @@ -227,7 +233,7 @@ func (m *QueryRawCheckpointResponse) XXX_DiscardUnknown() { var xxx_messageInfo_QueryRawCheckpointResponse proto.InternalMessageInfo -func (m *QueryRawCheckpointResponse) GetRawCheckpoint() *RawCheckpointWithMeta { +func (m *QueryRawCheckpointResponse) GetRawCheckpoint() *RawCheckpointWithMetaResponse { if m != nil { return m.RawCheckpoint } @@ -285,7 +291,7 @@ func (m *QueryRawCheckpointsRequest) GetPagination() *query.PageRequest { // RPC method. type QueryRawCheckpointsResponse struct { // the order is going from the newest to oldest based on the epoch number - RawCheckpoints []*RawCheckpointWithMeta `protobuf:"bytes,1,rep,name=raw_checkpoints,json=rawCheckpoints,proto3" json:"raw_checkpoints,omitempty"` + RawCheckpoints []*RawCheckpointWithMetaResponse `protobuf:"bytes,1,rep,name=raw_checkpoints,json=rawCheckpoints,proto3" json:"raw_checkpoints,omitempty"` // pagination defines the pagination in the response. Pagination *query.PageResponse `protobuf:"bytes,2,opt,name=pagination,proto3" json:"pagination,omitempty"` } @@ -323,7 +329,7 @@ func (m *QueryRawCheckpointsResponse) XXX_DiscardUnknown() { var xxx_messageInfo_QueryRawCheckpointsResponse proto.InternalMessageInfo -func (m *QueryRawCheckpointsResponse) GetRawCheckpoints() []*RawCheckpointWithMeta { +func (m *QueryRawCheckpointsResponse) GetRawCheckpoints() []*RawCheckpointWithMetaResponse { if m != nil { return m.RawCheckpoints } @@ -699,7 +705,7 @@ func (m *QueryLastCheckpointWithStatusRequest) GetStatus() CheckpointStatus { // QueryLastCheckpointWithStatusResponse is the response type for the // Query/LastCheckpointWithStatus RPC method. type QueryLastCheckpointWithStatusResponse struct { - RawCheckpoint *RawCheckpoint `protobuf:"bytes,1,opt,name=raw_checkpoint,json=rawCheckpoint,proto3" json:"raw_checkpoint,omitempty"` + RawCheckpoint *RawCheckpointResponse `protobuf:"bytes,1,opt,name=raw_checkpoint,json=rawCheckpoint,proto3" json:"raw_checkpoint,omitempty"` } func (m *QueryLastCheckpointWithStatusResponse) Reset() { *m = QueryLastCheckpointWithStatusResponse{} } @@ -735,13 +741,241 @@ func (m *QueryLastCheckpointWithStatusResponse) XXX_DiscardUnknown() { var xxx_messageInfo_QueryLastCheckpointWithStatusResponse proto.InternalMessageInfo -func (m *QueryLastCheckpointWithStatusResponse) GetRawCheckpoint() *RawCheckpoint { +func (m *QueryLastCheckpointWithStatusResponse) GetRawCheckpoint() *RawCheckpointResponse { if m != nil { return m.RawCheckpoint } return nil } +// RawCheckpointResponse wraps the BLS multi sig with metadata +type RawCheckpointResponse struct { + // epoch_num defines the epoch number the raw checkpoint is for + EpochNum uint64 `protobuf:"varint,1,opt,name=epoch_num,json=epochNum,proto3" json:"epoch_num,omitempty"` + // block_hash_hex defines the 'BlockID.Hash', which is the hash of + // the block that individual BLS sigs are signed on as hex string + BlockHashHex string `protobuf:"bytes,2,opt,name=block_hash_hex,json=blockHashHex,proto3" json:"block_hash_hex,omitempty"` + // bitmap defines the bitmap that indicates the signers of the BLS multi sig + Bitmap []byte `protobuf:"bytes,3,opt,name=bitmap,proto3" json:"bitmap,omitempty"` + // bls_multi_sig defines the multi sig that is aggregated from individual BLS + // sigs + BlsMultiSig *github_com_babylonlabs_io_babylon_crypto_bls12381.Signature `protobuf:"bytes,4,opt,name=bls_multi_sig,json=blsMultiSig,proto3,customtype=github.com/babylonlabs-io/babylon/crypto/bls12381.Signature" json:"bls_multi_sig,omitempty"` +} + +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} +} +func (m *RawCheckpointResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *RawCheckpointResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_RawCheckpointResponse.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 *RawCheckpointResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_RawCheckpointResponse.Merge(m, src) +} +func (m *RawCheckpointResponse) XXX_Size() int { + return m.Size() +} +func (m *RawCheckpointResponse) XXX_DiscardUnknown() { + xxx_messageInfo_RawCheckpointResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_RawCheckpointResponse proto.InternalMessageInfo + +func (m *RawCheckpointResponse) GetEpochNum() uint64 { + if m != nil { + return m.EpochNum + } + return 0 +} + +func (m *RawCheckpointResponse) GetBlockHashHex() string { + if m != nil { + return m.BlockHashHex + } + return "" +} + +func (m *RawCheckpointResponse) GetBitmap() []byte { + if m != nil { + return m.Bitmap + } + return nil +} + +// CheckpointStateUpdateResponse defines a state transition on the checkpoint. +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. + 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 + BlockHeight uint64 `protobuf:"varint,3,opt,name=block_height,json=blockHeight,proto3" json:"block_height,omitempty"` + // block_time is the timestamp in the Babylon block that triggers the state + // update + BlockTime *time.Time `protobuf:"bytes,4,opt,name=block_time,json=blockTime,proto3,stdtime" json:"block_time,omitempty"` +} + +func (m *CheckpointStateUpdateResponse) Reset() { *m = CheckpointStateUpdateResponse{} } +func (m *CheckpointStateUpdateResponse) String() string { return proto.CompactTextString(m) } +func (*CheckpointStateUpdateResponse) ProtoMessage() {} +func (*CheckpointStateUpdateResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_113f1ca5c3c2ca44, []int{15} +} +func (m *CheckpointStateUpdateResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *CheckpointStateUpdateResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_CheckpointStateUpdateResponse.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 *CheckpointStateUpdateResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_CheckpointStateUpdateResponse.Merge(m, src) +} +func (m *CheckpointStateUpdateResponse) XXX_Size() int { + return m.Size() +} +func (m *CheckpointStateUpdateResponse) XXX_DiscardUnknown() { + xxx_messageInfo_CheckpointStateUpdateResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_CheckpointStateUpdateResponse proto.InternalMessageInfo + +func (m *CheckpointStateUpdateResponse) GetState() CheckpointStatus { + if m != nil { + return m.State + } + return Accumulating +} + +func (m *CheckpointStateUpdateResponse) GetStatusDesc() string { + if m != nil { + return m.StatusDesc + } + return "" +} + +func (m *CheckpointStateUpdateResponse) GetBlockHeight() uint64 { + if m != nil { + return m.BlockHeight + } + return 0 +} + +func (m *CheckpointStateUpdateResponse) GetBlockTime() *time.Time { + if m != nil { + return m.BlockTime + } + return nil +} + +// RawCheckpointWithMetaResponse wraps the raw checkpoint with metadata. +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. + 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"` + // power_sum defines the accumulated voting power for the checkpoint + PowerSum uint64 `protobuf:"varint,5,opt,name=power_sum,json=powerSum,proto3" json:"power_sum,omitempty"` + // lifecycle defines the lifecycle of this checkpoint, i.e., each state + // transition and the time (in both timestamp and block height) of this + // transition. + Lifecycle []*CheckpointStateUpdateResponse `protobuf:"bytes,6,rep,name=lifecycle,proto3" json:"lifecycle,omitempty"` +} + +func (m *RawCheckpointWithMetaResponse) Reset() { *m = RawCheckpointWithMetaResponse{} } +func (m *RawCheckpointWithMetaResponse) String() string { return proto.CompactTextString(m) } +func (*RawCheckpointWithMetaResponse) ProtoMessage() {} +func (*RawCheckpointWithMetaResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_113f1ca5c3c2ca44, []int{16} +} +func (m *RawCheckpointWithMetaResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *RawCheckpointWithMetaResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_RawCheckpointWithMetaResponse.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 *RawCheckpointWithMetaResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_RawCheckpointWithMetaResponse.Merge(m, src) +} +func (m *RawCheckpointWithMetaResponse) XXX_Size() int { + return m.Size() +} +func (m *RawCheckpointWithMetaResponse) XXX_DiscardUnknown() { + xxx_messageInfo_RawCheckpointWithMetaResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_RawCheckpointWithMetaResponse proto.InternalMessageInfo + +func (m *RawCheckpointWithMetaResponse) GetCkpt() *RawCheckpointResponse { + if m != nil { + return m.Ckpt + } + return nil +} + +func (m *RawCheckpointWithMetaResponse) GetStatus() CheckpointStatus { + if m != nil { + return m.Status + } + return Accumulating +} + +func (m *RawCheckpointWithMetaResponse) GetStatusDesc() string { + if m != nil { + return m.StatusDesc + } + return "" +} + +func (m *RawCheckpointWithMetaResponse) GetPowerSum() uint64 { + if m != nil { + return m.PowerSum + } + return 0 +} + +func (m *RawCheckpointWithMetaResponse) GetLifecycle() []*CheckpointStateUpdateResponse { + if m != nil { + return m.Lifecycle + } + return nil +} + func init() { proto.RegisterType((*QueryRawCheckpointListRequest)(nil), "babylon.checkpointing.v1.QueryRawCheckpointListRequest") proto.RegisterType((*QueryRawCheckpointListResponse)(nil), "babylon.checkpointing.v1.QueryRawCheckpointListResponse") @@ -758,6 +992,9 @@ func init() { proto.RegisterMapType((map[string]uint64)(nil), "babylon.checkpointing.v1.QueryRecentEpochStatusCountResponse.StatusCountEntry") proto.RegisterType((*QueryLastCheckpointWithStatusRequest)(nil), "babylon.checkpointing.v1.QueryLastCheckpointWithStatusRequest") proto.RegisterType((*QueryLastCheckpointWithStatusResponse)(nil), "babylon.checkpointing.v1.QueryLastCheckpointWithStatusResponse") + proto.RegisterType((*RawCheckpointResponse)(nil), "babylon.checkpointing.v1.RawCheckpointResponse") + proto.RegisterType((*CheckpointStateUpdateResponse)(nil), "babylon.checkpointing.v1.CheckpointStateUpdateResponse") + proto.RegisterType((*RawCheckpointWithMetaResponse)(nil), "babylon.checkpointing.v1.RawCheckpointWithMetaResponse") } func init() { @@ -765,66 +1002,87 @@ func init() { } var fileDescriptor_113f1ca5c3c2ca44 = []byte{ - // 938 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xd4, 0x97, 0xd1, 0x6f, 0xdb, 0x44, - 0x1c, 0xc7, 0x7b, 0x29, 0x9b, 0xe8, 0x2f, 0xac, 0x94, 0xd3, 0xc4, 0x82, 0x3b, 0xc2, 0x64, 0xc6, - 0xd6, 0x0d, 0xcd, 0x56, 0xd2, 0xa6, 0x8d, 0xca, 0x56, 0xa4, 0x4c, 0x85, 0x87, 0x8d, 0x32, 0x8c, - 0x34, 0x10, 0x0f, 0x44, 0x67, 0xf7, 0x94, 0x98, 0x3a, 0xb6, 0x9b, 0x3b, 0x27, 0x44, 0xd3, 0x5e, - 0xe0, 0x1f, 0x40, 0x42, 0xe2, 0x9f, 0xe0, 0x05, 0xde, 0x78, 0x44, 0xf0, 0xc2, 0x03, 0x42, 0x93, - 0x78, 0x41, 0xe2, 0x65, 0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, 0x1b, 0xf1, 0xdd, 0x39, 0x23, - 0x35, 0x72, 0x72, 0xef, 0x3f, 0x05, 0xb2, 0x5a, 0x13, 0xa6, 0x74, 0x7c, 0x27, 0xcf, 0xd4, 0xee, - 0xe8, 0x65, 0x80, 0xff, 0x46, 0x50, 0xca, 0x4a, 0x3e, 0xbc, 0x97, 0x83, 0x94, 0x13, 0xcf, 0xca, - 0xbb, 0x73, 0xeb, 0xa5, 0xa9, 0x3d, 0x61, 0xaa, 0x8e, 0xb7, 0xb3, 0x4d, 0x39, 0x84, 0xf1, 0x66, - 0xfa, 0x6c, 0xcb, 0x4c, 0x6a, 0x7c, 0xf8, 0xdb, 0x49, 0x19, 0x3d, 0x3b, 0x29, 0xa3, 0xe7, 0x27, - 0x65, 0xf4, 0xcd, 0x69, 0x79, 0xe9, 0xd9, 0x69, 0x79, 0xe9, 0xaf, 0xd3, 0xf2, 0xd2, 0x67, 0xb5, - 0x96, 0xcd, 0xdb, 0x81, 0xa9, 0x59, 0x5e, 0x27, 0x5e, 0xdb, 0x6a, 0x13, 0xdb, 0x3d, 0x2b, 0xf4, - 0x65, 0xaa, 0x14, 0x1f, 0xf8, 0x94, 0x99, 0x17, 0xc5, 0x6f, 0xa7, 0xcd, 0x7f, 0x03, 0x00, 0x00, - 0xff, 0xff, 0x27, 0x4c, 0x94, 0xaf, 0x1a, 0x0e, 0x00, 0x00, + // 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, 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xb1, 0xfe, 0x3a, 0x04, 0x5d, 0x19, + 0x53, 0xbe, 0x44, 0x99, 0x5c, 0xdd, 0x97, 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, } // Reference imports to suppress errors if they are not otherwise used. @@ -1665,6 +1923,188 @@ func (m *QueryLastCheckpointWithStatusResponse) MarshalToSizedBuffer(dAtA []byte return len(dAtA) - i, nil } +func (m *RawCheckpointResponse) 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 *RawCheckpointResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *RawCheckpointResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.BlsMultiSig != nil { + { + size := m.BlsMultiSig.Size() + i -= size + if _, err := m.BlsMultiSig.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x22 + } + if len(m.Bitmap) > 0 { + i -= len(m.Bitmap) + copy(dAtA[i:], m.Bitmap) + i = encodeVarintQuery(dAtA, i, uint64(len(m.Bitmap))) + i-- + dAtA[i] = 0x1a + } + if len(m.BlockHashHex) > 0 { + i -= len(m.BlockHashHex) + copy(dAtA[i:], m.BlockHashHex) + i = encodeVarintQuery(dAtA, i, uint64(len(m.BlockHashHex))) + i-- + dAtA[i] = 0x12 + } + if m.EpochNum != 0 { + i = encodeVarintQuery(dAtA, i, uint64(m.EpochNum)) + i-- + dAtA[i] = 0x8 + } + return len(dAtA) - i, nil +} + +func (m *CheckpointStateUpdateResponse) 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 *CheckpointStateUpdateResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *CheckpointStateUpdateResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.BlockTime != nil { + n9, err9 := github_com_cosmos_gogoproto_types.StdTimeMarshalTo(*m.BlockTime, dAtA[i-github_com_cosmos_gogoproto_types.SizeOfStdTime(*m.BlockTime):]) + if err9 != nil { + return 0, err9 + } + i -= n9 + i = encodeVarintQuery(dAtA, i, uint64(n9)) + i-- + dAtA[i] = 0x22 + } + if m.BlockHeight != 0 { + i = encodeVarintQuery(dAtA, i, uint64(m.BlockHeight)) + i-- + dAtA[i] = 0x18 + } + 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] = 0x12 + } + if m.State != 0 { + i = encodeVarintQuery(dAtA, i, uint64(m.State)) + i-- + dAtA[i] = 0x8 + } + return len(dAtA) - i, nil +} + +func (m *RawCheckpointWithMetaResponse) 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 *RawCheckpointWithMetaResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *RawCheckpointWithMetaResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Lifecycle) > 0 { + for iNdEx := len(m.Lifecycle) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.Lifecycle[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x32 + } + } + if m.PowerSum != 0 { + i = encodeVarintQuery(dAtA, i, uint64(m.PowerSum)) + i-- + dAtA[i] = 0x28 + } + if m.BlsAggrPk != nil { + { + size := m.BlsAggrPk.Size() + i -= size + if _, err := m.BlsAggrPk.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x22 + } + 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] = 0x1a + } + if m.Status != 0 { + i = encodeVarintQuery(dAtA, i, uint64(m.Status)) + i-- + dAtA[i] = 0x10 + } + if m.Ckpt != nil { + { + size, err := m.Ckpt.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 @@ -1887,19 +2327,99 @@ func (m *QueryLastCheckpointWithStatusResponse) Size() (n int) { 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 *QueryRawCheckpointListRequest) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { +func (m *RawCheckpointResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.EpochNum != 0 { + n += 1 + sovQuery(uint64(m.EpochNum)) + } + l = len(m.BlockHashHex) + if l > 0 { + n += 1 + l + sovQuery(uint64(l)) + } + l = len(m.Bitmap) + if l > 0 { + n += 1 + l + sovQuery(uint64(l)) + } + if m.BlsMultiSig != nil { + l = m.BlsMultiSig.Size() + n += 1 + l + sovQuery(uint64(l)) + } + return n +} + +func (m *CheckpointStateUpdateResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.State != 0 { + n += 1 + sovQuery(uint64(m.State)) + } + l = len(m.StatusDesc) + if l > 0 { + n += 1 + l + sovQuery(uint64(l)) + } + if m.BlockHeight != 0 { + n += 1 + sovQuery(uint64(m.BlockHeight)) + } + if m.BlockTime != nil { + l = github_com_cosmos_gogoproto_types.SizeOfStdTime(*m.BlockTime) + n += 1 + l + sovQuery(uint64(l)) + } + return n +} + +func (m *RawCheckpointWithMetaResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.Ckpt != nil { + l = m.Ckpt.Size() + n += 1 + l + sovQuery(uint64(l)) + } + if m.Status != 0 { + n += 1 + sovQuery(uint64(m.Status)) + } + l = len(m.StatusDesc) + if l > 0 { + n += 1 + l + sovQuery(uint64(l)) + } + if m.BlsAggrPk != nil { + l = m.BlsAggrPk.Size() + n += 1 + l + sovQuery(uint64(l)) + } + if m.PowerSum != 0 { + n += 1 + sovQuery(uint64(m.PowerSum)) + } + if len(m.Lifecycle) > 0 { + for _, e := range m.Lifecycle { + l = e.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 *QueryRawCheckpointListRequest) 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 } @@ -2056,7 +2576,7 @@ func (m *QueryRawCheckpointListResponse) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.RawCheckpoints = append(m.RawCheckpoints, &RawCheckpointWithMeta{}) + m.RawCheckpoints = append(m.RawCheckpoints, &RawCheckpointWithMetaResponse{}) if err := m.RawCheckpoints[len(m.RawCheckpoints)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } @@ -2246,7 +2766,7 @@ func (m *QueryRawCheckpointResponse) Unmarshal(dAtA []byte) error { return io.ErrUnexpectedEOF } if m.RawCheckpoint == nil { - m.RawCheckpoint = &RawCheckpointWithMeta{} + m.RawCheckpoint = &RawCheckpointWithMetaResponse{} } if err := m.RawCheckpoint.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err @@ -2417,7 +2937,7 @@ func (m *QueryRawCheckpointsResponse) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.RawCheckpoints = append(m.RawCheckpoints, &RawCheckpointWithMeta{}) + m.RawCheckpoints = append(m.RawCheckpoints, &RawCheckpointWithMetaResponse{}) if err := m.RawCheckpoints[len(m.RawCheckpoints)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } @@ -3240,7 +3760,7 @@ func (m *QueryLastCheckpointWithStatusResponse) Unmarshal(dAtA []byte) error { return io.ErrUnexpectedEOF } if m.RawCheckpoint == nil { - m.RawCheckpoint = &RawCheckpoint{} + m.RawCheckpoint = &RawCheckpointResponse{} } if err := m.RawCheckpoint.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err @@ -3267,6 +3787,557 @@ func (m *QueryLastCheckpointWithStatusResponse) Unmarshal(dAtA []byte) error { } return nil } +func (m *RawCheckpointResponse) 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: RawCheckpointResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: RawCheckpointResponse: 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 + } + } + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field BlockHashHex", 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.BlockHashHex = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Bitmap", 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 + } + m.Bitmap = append(m.Bitmap[:0], dAtA[iNdEx:postIndex]...) + if m.Bitmap == nil { + m.Bitmap = []byte{} + } + iNdEx = postIndex + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field BlsMultiSig", 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 + } + var v github_com_babylonlabs_io_babylon_crypto_bls12381.Signature + m.BlsMultiSig = &v + if err := m.BlsMultiSig.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 *CheckpointStateUpdateResponse) 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: CheckpointStateUpdateResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: CheckpointStateUpdateResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field State", wireType) + } + m.State = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.State |= CheckpointStatus(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field StatusDesc", 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.StatusDesc = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 3: + 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 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field BlockTime", 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.BlockTime == nil { + m.BlockTime = new(time.Time) + } + if err := github_com_cosmos_gogoproto_types.StdTimeUnmarshal(m.BlockTime, 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 *RawCheckpointWithMetaResponse) 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: RawCheckpointWithMetaResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: RawCheckpointWithMetaResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Ckpt", 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.Ckpt == nil { + m.Ckpt = &RawCheckpointResponse{} + } + if err := m.Ckpt.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 2: + 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 |= CheckpointStatus(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field StatusDesc", 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.StatusDesc = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field BlsAggrPk", 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 + } + var v github_com_babylonlabs_io_babylon_crypto_bls12381.PublicKey + m.BlsAggrPk = &v + if err := m.BlsAggrPk.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 5: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field PowerSum", wireType) + } + m.PowerSum = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.PowerSum |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 6: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Lifecycle", 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.Lifecycle = append(m.Lifecycle, &CheckpointStateUpdateResponse{}) + if err := m.Lifecycle[len(m.Lifecycle)-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 skipQuery(dAtA []byte) (n int, err error) { l := len(dAtA) iNdEx := 0 diff --git a/x/checkpointing/types/tx.pb.go b/x/checkpointing/types/tx.pb.go index 9a309d96a..7ba7e05c5 100644 --- a/x/checkpointing/types/tx.pb.go +++ b/x/checkpointing/types/tx.pb.go @@ -115,30 +115,30 @@ func init() { func init() { proto.RegisterFile("babylon/checkpointing/v1/tx.proto", fileDescriptor_6b16c54750152c21) } var fileDescriptor_6b16c54750152c21 = []byte{ - // 357 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x9c, 0x92, 0x3d, 0x4b, 0xfb, 0x40, - 0x1c, 0xc7, 0x73, 0xff, 0xf2, 0x77, 0x38, 0xb7, 0x50, 0xb4, 0x66, 0x48, 0x1f, 0x04, 0x91, 0x0e, - 0x77, 0xb4, 0xc5, 0x45, 0xb7, 0x3a, 0x4a, 0x11, 0x3a, 0x28, 0x88, 0x50, 0x2e, 0xe9, 0x71, 0x0d, - 0x79, 0xb8, 0x90, 0xdf, 0x59, 0x9a, 0x4d, 0x9c, 0xc4, 0xc9, 0xd5, 0xad, 0x2f, 0xa1, 0x2f, 0xc3, - 0xb1, 0xa3, 0xa3, 0xb4, 0x43, 0x7d, 0x19, 0xd2, 0x24, 0x45, 0xac, 0xde, 0xe2, 0x76, 0x0f, 0x9f, - 0xdf, 0xf7, 0x81, 0x3b, 0x5c, 0x77, 0x98, 0x93, 0x06, 0x32, 0xa2, 0xee, 0x88, 0xbb, 0x7e, 0x2c, - 0xbd, 0x48, 0x79, 0x91, 0xa0, 0xe3, 0x16, 0x55, 0x13, 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e, - 0xdf, 0xaf, 0x66, 0x4d, 0xd4, 0xbd, 0x7c, 0x5d, 0xd8, 0x68, 0xbe, 0xb0, 0xd1, 0xfb, 0xc2, 0x46, - 0xcf, 0x4b, 0xdb, 0x98, 0x2f, 0x6d, 0xe3, 0x6d, 0x69, 0x1b, 0x37, 0x27, 0xc2, 0x53, 0xa3, 0x3b, - 0x87, 0xb8, 0x32, 0xa4, 0x85, 0x8f, 0x3b, 0x62, 0x5e, 0xb4, 0xd9, 0xd0, 0xc9, 0xd6, 0x4f, 0x51, - 0x69, 0xcc, 0xc1, 0xd9, 0xc9, 0xde, 0xba, 0xf3, 0x19, 0x00, 0x00, 0xff, 0xff, 0xd4, 0x29, 0x9a, - 0x31, 0xa2, 0x02, 0x00, 0x00, + // 360 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x9c, 0x92, 0xbb, 0x4a, 0x2b, 0x41, + 0x18, 0xc7, 0x77, 0x4e, 0x38, 0xa7, 0x98, 0xd3, 0x2d, 0x41, 0xe3, 0x16, 0x9b, 0x8b, 0x20, 0x12, + 0x70, 0x86, 0x24, 0x85, 0xa0, 0x5d, 0x2c, 0x25, 0x85, 0x29, 0x14, 0x44, 0x08, 0x33, 0x9b, 0x61, + 0xb2, 0xec, 0x65, 0x96, 0xfd, 0xc6, 0x90, 0xed, 0xc4, 0x4a, 0xac, 0x6c, 0xed, 0xf2, 0x08, 0x79, + 0x0c, 0xcb, 0x94, 0x96, 0x92, 0x14, 0xf1, 0x31, 0x24, 0xbb, 0x1b, 0xc4, 0xe8, 0x36, 0x76, 0x73, + 0xf9, 0x7d, 0xff, 0x0b, 0x33, 0xb8, 0xce, 0x19, 0x4f, 0x7c, 0x15, 0x52, 0x67, 0x24, 0x1c, 0x2f, + 0x52, 0x6e, 0xa8, 0xdd, 0x50, 0xd2, 0x71, 0x8b, 0xea, 0x09, 0x89, 0x62, 0xa5, 0x95, 0x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44, 0xdd, 0x8b, 0x97, 0x85, 0x8d, 0xe6, 0x0b, 0x1b, 0xbd, 0x2d, + 0x6c, 0xf4, 0xb4, 0xb4, 0x8d, 0xf9, 0xd2, 0x36, 0x5e, 0x97, 0xb6, 0x71, 0x7d, 0x2c, 0x5d, 0x3d, + 0xba, 0xe5, 0xc4, 0x51, 0x01, 0xcd, 0x7d, 0x7c, 0xc6, 0xe1, 0xc8, 0x55, 0x9b, 0x2d, 0x9d, 0x6c, + 0xfd, 0x15, 0x9d, 0x44, 0x02, 0xf8, 0xbf, 0xf4, 0xb5, 0x3b, 0x1f, 0x01, 0x00, 0x00, 0xff, 0xff, + 0x74, 0x07, 0x94, 0x5c, 0xa4, 0x02, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. diff --git a/x/checkpointing/types/types.go b/x/checkpointing/types/types.go index dabec4b71..116728539 100644 --- a/x/checkpointing/types/types.go +++ b/x/checkpointing/types/types.go @@ -11,9 +11,9 @@ import ( "github.com/cosmos/cosmos-sdk/codec" sdk "github.com/cosmos/cosmos-sdk/types" - txformat "github.com/babylonchain/babylon/btctxformatter" - "github.com/babylonchain/babylon/crypto/bls12381" - epochingtypes "github.com/babylonchain/babylon/x/epoching/types" + txformat "github.com/babylonlabs-io/babylon/btctxformatter" + "github.com/babylonlabs-io/babylon/crypto/bls12381" + epochingtypes "github.com/babylonlabs-io/babylon/x/epoching/types" ) const ( diff --git a/x/checkpointing/types/types_test.go b/x/checkpointing/types/types_test.go index 3875024c9..ea0f2a791 100644 --- a/x/checkpointing/types/types_test.go +++ b/x/checkpointing/types/types_test.go @@ -7,9 +7,9 @@ import ( "github.com/stretchr/testify/require" - "github.com/babylonchain/babylon/testutil/datagen" - testkeeper "github.com/babylonchain/babylon/testutil/keeper" - "github.com/babylonchain/babylon/x/checkpointing/types" + "github.com/babylonlabs-io/babylon/testutil/datagen" + testkeeper "github.com/babylonlabs-io/babylon/testutil/keeper" + "github.com/babylonlabs-io/babylon/x/checkpointing/types" ) // a single validator diff --git a/x/checkpointing/types/utils.go b/x/checkpointing/types/utils.go index faef788dd..8a1c4f8e1 100644 --- a/x/checkpointing/types/utils.go +++ b/x/checkpointing/types/utils.go @@ -7,8 +7,8 @@ import ( "github.com/cometbft/cometbft/crypto/tmhash" sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/babylonchain/babylon/btctxformatter" - "github.com/babylonchain/babylon/crypto/bls12381" + "github.com/babylonlabs-io/babylon/btctxformatter" + "github.com/babylonlabs-io/babylon/crypto/bls12381" ) func (m BlsSig) Hash() BlsSigHash { diff --git a/x/checkpointing/types/val_bls_set.go b/x/checkpointing/types/val_bls_set.go index 8db7764e5..9603d4bc5 100644 --- a/x/checkpointing/types/val_bls_set.go +++ b/x/checkpointing/types/val_bls_set.go @@ -3,7 +3,7 @@ package types import ( "fmt" - "github.com/babylonchain/babylon/crypto/bls12381" + "github.com/babylonlabs-io/babylon/crypto/bls12381" "github.com/boljen/go-bitmap" "github.com/cosmos/cosmos-sdk/codec" ) diff --git a/x/checkpointing/vote_ext.go b/x/checkpointing/vote_ext.go index a0a157e9e..6bdd10e1d 100644 --- a/x/checkpointing/vote_ext.go +++ b/x/checkpointing/vote_ext.go @@ -8,8 +8,8 @@ import ( "github.com/cosmos/cosmos-sdk/baseapp" sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/babylonchain/babylon/x/checkpointing/keeper" - ckpttypes "github.com/babylonchain/babylon/x/checkpointing/types" + "github.com/babylonlabs-io/babylon/x/checkpointing/keeper" + ckpttypes "github.com/babylonlabs-io/babylon/x/checkpointing/types" ) // VoteExtensionHandler defines a BLS-based vote extension handlers for Babylon. @@ -31,6 +31,14 @@ func (h *VoteExtensionHandler) SetHandlers(bApp *baseapp.BaseApp) { // ExtendVote sends a BLS signature as a vote extension // the signature is signed over the hash of the last // block of the current epoch +// NOTE: we should not allow empty vote extension to be +// sent as we cannot ensure all the vote extensions will +// be checked by VerifyVoteExtension due to the issue +// https://github.com/cometbft/cometbft/issues/2361 +// therefore, we panic upon any error, otherwise, empty +// vote extension will still be sent, according to +// https://github.com/cosmos/cosmos-sdk/blob/7dbed2fc0c3ed7c285645e21cb1037d8810372ae/baseapp/abci.go#L612 +// TODO: revisit panicking if the CometBFT issue is resolved func (h *VoteExtensionHandler) ExtendVote() sdk.ExtendVoteHandler { return func(ctx sdk.Context, req *abci.RequestExtendVote) (*abci.ResponseExtendVote, error) { k := h.ckptKeeper @@ -49,22 +57,25 @@ func (h *VoteExtensionHandler) ExtendVote() sdk.ExtendVoteHandler { curValSet := k.GetValidatorSet(ctx, epoch.EpochNumber) _, _, err := curValSet.FindValidatorWithIndex(signer) if err != nil { - // not being a validator is not an error - h.logger.Info("the BLS signer is not in the validator set", "signer_address", signer.String()) - return emptyRes, nil + // NOTE: this indicates programmatic error because ExtendVote + // should not be invoked if the validator is not in the + // active set according to: + // https://github.com/cometbft/cometbft/blob/a17290f6905ef714761f12c1f82409b0731e3838/consensus/state.go#L2434 + panic(fmt.Errorf("the BLS signer %s is not in the validator set", signer.String())) } // 2. sign BLS signature blsSig, err := k.SignBLS(epoch.EpochNumber, req.Hash) if err != nil { - // the returned error will lead to panic - return emptyRes, fmt.Errorf("failed to sign BLS signature at epoch %v, height %v", - epoch.EpochNumber, req.Height) + // NOTE: this indicates misconfiguration of the BLS key + panic(fmt.Errorf("failed to sign BLS signature at epoch %v, height %v", + epoch.EpochNumber, req.Height)) } var bhash ckpttypes.BlockHash if err := bhash.Unmarshal(req.Hash); err != nil { - return emptyRes, fmt.Errorf("invalid CometBFT hash") + // NOTE: this indicates programmatic error in CometBFT + panic(fmt.Errorf("invalid CometBFT hash")) } // 3. build vote extension @@ -78,7 +89,9 @@ func (h *VoteExtensionHandler) ExtendVote() sdk.ExtendVoteHandler { } bz, err := ve.Marshal() if err != nil { - return emptyRes, fmt.Errorf("failed to encode vote extension: %w", err) + // NOTE: the returned error will lead to panic + // this indicates programmatic error in building vote extension + panic(fmt.Errorf("failed to encode vote extension: %w", err)) } h.logger.Info("successfully sent BLS signature in vote extension", diff --git a/x/checkpointing/vote_ext_test.go b/x/checkpointing/vote_ext_test.go index 5921447b5..90c57342f 100644 --- a/x/checkpointing/vote_ext_test.go +++ b/x/checkpointing/vote_ext_test.go @@ -4,11 +4,12 @@ import ( "math/rand" "testing" + abci "github.com/cometbft/cometbft/abci/types" "github.com/stretchr/testify/require" - "github.com/babylonchain/babylon/testutil/datagen" - testhelper "github.com/babylonchain/babylon/testutil/helper" - "github.com/babylonchain/babylon/x/checkpointing/types" + "github.com/babylonlabs-io/babylon/testutil/datagen" + testhelper "github.com/babylonlabs-io/babylon/testutil/helper" + "github.com/babylonlabs-io/babylon/x/checkpointing/types" ) // FuzzAddBLSSigVoteExtension_MultipleVals tests adding BLS signatures via VoteExtension @@ -75,9 +76,9 @@ func FuzzAddBLSSigVoteExtension_InsufficientVotingPower(f *testing.F) { }) } -// FuzzAddBLSSigVoteExtension_InvalidBLSSig tests adding BLS signatures -// with invalid BLS signature -func FuzzAddBLSSigVoteExtension_InvalidBLSSig(f *testing.F) { +// FuzzAddBLSSigVoteExtension_InvalidVoteExtensions tests adding BLS signatures +// with invalid BLS signatures +func FuzzAddBLSSigVoteExtension_InvalidVoteExtensions(f *testing.F) { datagen.AddRandomSeedsToFuzzer(f, 10) f.Fuzz(func(t *testing.T, seed int64) { @@ -90,7 +91,7 @@ func FuzzAddBLSSigVoteExtension_InvalidBLSSig(f *testing.F) { interval := ek.GetParams(helper.Ctx).EpochInterval for i := uint64(0); i < interval-1; i++ { - _, err := helper.ApplyEmptyBlockWithInvalidBLSSig(r) + _, err := helper.ApplyEmptyBlockWithInvalidVoteExtensions(r) if i < interval-2 { require.NoError(t, err) } else { @@ -100,9 +101,9 @@ func FuzzAddBLSSigVoteExtension_InvalidBLSSig(f *testing.F) { }) } -// FuzzAddBLSSigVoteExtension_EmptyVoteExtensions tests resilience against -// empty vote extensions -func FuzzAddBLSSigVoteExtension_EmptyVoteExtensions(f *testing.F) { +// FuzzAddBLSSigVoteExtension_SomeInvalidVoteExtensions tests resilience +// of ProcessProposal against invalid vote extensions +func FuzzAddBLSSigVoteExtension_SomeInvalidVoteExtensions(f *testing.F) { datagen.AddRandomSeedsToFuzzer(f, 10) f.Fuzz(func(t *testing.T, seed int64) { @@ -120,11 +121,11 @@ func FuzzAddBLSSigVoteExtension_EmptyVoteExtensions(f *testing.F) { // go to block 10, ensure the checkpoint is finalized interval := ek.GetParams(helper.Ctx).EpochInterval for i := uint64(0); i < interval-2; i++ { - _, err := helper.ApplyEmptyBlockWithSomeEmptyVoteExtensions(r) + _, err := helper.ApplyEmptyBlockWithSomeInvalidVoteExtensions(r) require.NoError(t, err) } // height 11, i.e., 1st block of next epoch - _, err = helper.ApplyEmptyBlockWithSomeEmptyVoteExtensions(r) + _, err = helper.ApplyEmptyBlockWithSomeInvalidVoteExtensions(r) require.NoError(t, err) epoch = ek.GetEpoch(helper.Ctx) @@ -135,3 +136,117 @@ func FuzzAddBLSSigVoteExtension_EmptyVoteExtensions(f *testing.F) { require.Equal(t, types.Sealed, ckpt.Status) }) } + +// FuzzExtendVote_InvalidBlockHash tests the case where the +// block hash for signing is invalid in terms of format +func FuzzExtendVote_InvalidBlockHash(f *testing.F) { + datagen.AddRandomSeedsToFuzzer(f, 10) + + f.Fuzz(func(t *testing.T, seed int64) { + r := rand.New(rand.NewSource(seed)) + // generate the validator set with 10 validators as genesis + genesisValSet, privSigner, err := datagen.GenesisValidatorSetWithPrivSigner(10) + require.NoError(t, err) + helper := testhelper.NewHelperWithValSet(t, genesisValSet, privSigner) + ek := helper.App.EpochingKeeper + + epoch := ek.GetEpoch(helper.Ctx) + require.Equal(t, uint64(1), epoch.EpochNumber) + + // go to block 10, reaching epoch boundary + interval := ek.GetParams(helper.Ctx).EpochInterval + for i := uint64(0); i < interval-2; i++ { + _, err := helper.ApplyEmptyBlockWithVoteExtension(r) + require.NoError(t, err) + } + + req1 := &abci.RequestExtendVote{ + Hash: datagen.GenRandomByteArray(r, datagen.RandomIntOtherThan(r, types.HashSize, 100)), + Height: 10, + } + _, err = helper.App.ExtendVote(helper.Ctx, req1) + require.Error(t, err) + + req2 := &abci.RequestExtendVote{ + Hash: datagen.GenRandomByteArray(r, types.HashSize), + Height: 10, + } + _, err = helper.App.ExtendVote(helper.Ctx, req2) + require.NoError(t, err) + }) +} + +// FuzzExtendVote_EmptyBLSPrivKey tests the case where the +// BLS private key of the private signer is missing +func FuzzExtendVote_EmptyBLSPrivKey(f *testing.F) { + datagen.AddRandomSeedsToFuzzer(f, 10) + + f.Fuzz(func(t *testing.T, seed int64) { + r := rand.New(rand.NewSource(seed)) + // generate the validator set with 10 validators as genesis + genesisValSet, ps, err := datagen.GenesisValidatorSetWithPrivSigner(10) + require.NoError(t, err) + + // set the BLS private key to be nil to trigger panic + ps.WrappedPV.Key.BlsPrivKey = nil + helper := testhelper.NewHelperWithValSet(t, genesisValSet, ps) + ek := helper.App.EpochingKeeper + + epoch := ek.GetEpoch(helper.Ctx) + require.Equal(t, uint64(1), epoch.EpochNumber) + + // go to block 10, reaching epoch boundary + interval := ek.GetParams(helper.Ctx).EpochInterval + for i := uint64(0); i < interval-2; i++ { + _, err := helper.ApplyEmptyBlockWithVoteExtension(r) + require.NoError(t, err) + } + + req := &abci.RequestExtendVote{ + Hash: datagen.GenRandomByteArray(r, types.HashSize), + Height: 10, + } + + // error is expected due to nil BLS private key + _, err = helper.App.ExtendVote(helper.Ctx, req) + require.Error(t, err) + }) +} + +// FuzzExtendVote_NotInValidatorSet tests the case where the +// private signer is not in the validator set +func FuzzExtendVote_NotInValidatorSet(f *testing.F) { + datagen.AddRandomSeedsToFuzzer(f, 10) + + f.Fuzz(func(t *testing.T, seed int64) { + r := rand.New(rand.NewSource(seed)) + // generate the validator set with 10 validators as genesis + genesisValSet, ps, err := datagen.GenesisValidatorSetWithPrivSigner(10) + require.NoError(t, err) + + // the private signer is not included in the validator set + helper := testhelper.NewHelperWithValSetNoSigner(t, genesisValSet, ps) + + ek := helper.App.EpochingKeeper + + epoch := ek.GetEpoch(helper.Ctx) + require.Equal(t, uint64(1), epoch.EpochNumber) + + // go to block 10, reaching epoch boundary + interval := ek.GetParams(helper.Ctx).EpochInterval + for i := uint64(0); i < interval-2; i++ { + _, err := helper.ApplyEmptyBlockWithSomeInvalidVoteExtensions(r) + require.NoError(t, err) + } + + req := &abci.RequestExtendVote{ + Hash: datagen.GenRandomByteArray(r, types.HashSize), + Height: 10, + } + + // error is expected because the BLS signer in not + // in the validator set + _, err = helper.App.ExtendVote(helper.Ctx, req) + require.Error(t, err) + }) +} diff --git a/x/epoching/README.md b/x/epoching/README.md index e557c8df8..0800dc108 100644 --- a/x/epoching/README.md +++ b/x/epoching/README.md @@ -350,7 +350,7 @@ module, and then inserts the message to the epoch message queue storage. ### MsgUpdateParams The `MsgUpdateParams` message is used for updating the module parameters for the -Epoching module. It can only be executed via a govenance proposal. +Epoching module. It can only be executed via a governance proposal. ```protobuf // MsgUpdateParams defines a message for updating Epoching module parameters. diff --git a/x/epoching/abci.go b/x/epoching/abci.go index eecf14390..04097d3aa 100644 --- a/x/epoching/abci.go +++ b/x/epoching/abci.go @@ -5,8 +5,8 @@ import ( "fmt" "time" - "github.com/babylonchain/babylon/x/epoching/keeper" - "github.com/babylonchain/babylon/x/epoching/types" + "github.com/babylonlabs-io/babylon/x/epoching/keeper" + "github.com/babylonlabs-io/babylon/x/epoching/types" abci "github.com/cometbft/cometbft/abci/types" "github.com/cosmos/cosmos-sdk/telemetry" @@ -29,8 +29,6 @@ func BeginBlocker(ctx context.Context, k keeper.Keeper) error { defer telemetry.ModuleMeasureSince(types.ModuleName, time.Now(), telemetry.MetricKeyBeginBlocker) sdkCtx := sdk.UnwrapSDKContext(ctx) - // record the current AppHash - k.RecordAppHash(ctx) // if this block is the first block of the next epoch // note that we haven't incremented the epoch number yet @@ -84,7 +82,7 @@ func EndBlocker(ctx context.Context, k keeper.Keeper) ([]abci.ValidatorUpdate, e epoch := k.GetEpoch(ctx) if epoch.IsLastBlock(ctx) { // finalise this epoch, i.e., record the current header and the Merkle root of all AppHashs in this epoch - if err := k.RecordLastHeaderAndAppHashRoot(ctx); err != nil { + if err := k.RecordLastHeaderTime(ctx); err != nil { return nil, err } // get all msgs in the msg queue diff --git a/x/epoching/client/cli/query.go b/x/epoching/client/cli/query.go index 3818f48cb..80656ce80 100644 --- a/x/epoching/client/cli/query.go +++ b/x/epoching/client/cli/query.go @@ -1,16 +1,14 @@ package cli import ( + "context" "fmt" - // "strings" - - "github.com/spf13/cobra" + "strconv" + "github.com/babylonlabs-io/babylon/x/epoching/types" "github.com/cosmos/cosmos-sdk/client" - // "github.com/cosmos/cosmos-sdk/client/flags" - // sdk "github.com/cosmos/cosmos-sdk/types" - - "github.com/babylonchain/babylon/x/epoching/types" + "github.com/cosmos/cosmos-sdk/client/flags" + "github.com/spf13/cobra" ) // GetQueryCmd returns the cli query commands for this module @@ -24,7 +22,215 @@ func GetQueryCmd(queryRoute string) *cobra.Command { RunE: client.ValidateCmd, } - cmd.AddCommand(CmdQueryParams()) + cmd.AddCommand( + CmdQueryParams(), + CmdQueryEpochInfo(), + CmdQueryEpochsInfo(), + CmdQueryEpochMsgs(), + CmdQueryEpochValidators(), + ) return cmd } + +func CmdQueryParams() *cobra.Command { + cmd := &cobra.Command{ + Use: "params", + Short: "shows the parameters of the module", + Args: cobra.NoArgs, + RunE: func(cmd *cobra.Command, args []string) error { + clientCtx := client.GetClientContextFromCmd(cmd) + + queryClient := types.NewQueryClient(clientCtx) + + res, err := queryClient.Params(context.Background(), &types.QueryParamsRequest{}) + if err != nil { + return err + } + + return clientCtx.PrintProto(res) + }, + } + + flags.AddQueryFlagsToCmd(cmd) + + return cmd +} + +func CmdQueryEpochInfo() *cobra.Command { + cmd := &cobra.Command{ + Use: "epoch [epoch_number]", + Short: "shows the information of the current epoch, or the given epoch if specified", + Args: cobra.MaximumNArgs(1), + RunE: func(cmd *cobra.Command, args []string) error { + clientCtx := client.GetClientContextFromCmd(cmd) + + queryClient := types.NewQueryClient(clientCtx) + + epochNum, err := getEpoch(queryClient, args) + if err != nil { + return err + } + + res, err := queryClient.EpochInfo( + context.Background(), + &types.QueryEpochInfoRequest{ + EpochNum: epochNum, + }, + ) + if err != nil { + return err + } + + return clientCtx.PrintProto(res) + }, + } + + flags.AddQueryFlagsToCmd(cmd) + + return cmd +} + +func CmdQueryEpochsInfo() *cobra.Command { + cmd := &cobra.Command{ + Use: "epochs", + Short: "shows the information of epochs according to the pagination parameters", + Args: cobra.NoArgs, + RunE: func(cmd *cobra.Command, args []string) error { + clientCtx := client.GetClientContextFromCmd(cmd) + + queryClient := types.NewQueryClient(clientCtx) + + pageReq, err := client.ReadPageRequest(cmd.Flags()) + if err != nil { + return err + } + + res, err := queryClient.EpochsInfo( + context.Background(), + &types.QueryEpochsInfoRequest{ + Pagination: pageReq, + }, + ) + if err != nil { + return err + } + + return clientCtx.PrintProto(res) + }, + } + + flags.AddQueryFlagsToCmd(cmd) + flags.AddPaginationFlagsToCmd(cmd, "epochs") + + return cmd +} + +func CmdQueryEpochMsgs() *cobra.Command { + cmd := &cobra.Command{ + Use: "epoch-msgs [epoch_number]", + Short: "shows the messages that will be executed at the end of the current epoch, or the given epoch if specified", + Args: cobra.MaximumNArgs(1), + RunE: func(cmd *cobra.Command, args []string) error { + clientCtx := client.GetClientContextFromCmd(cmd) + + queryClient := types.NewQueryClient(clientCtx) + + epochNum, err := getEpoch(queryClient, args) + if err != nil { + return err + } + + pageReq, err := client.ReadPageRequest(cmd.Flags()) + if err != nil { + return err + } + + res, err := queryClient.EpochMsgs( + context.Background(), + &types.QueryEpochMsgsRequest{ + EpochNum: epochNum, + Pagination: pageReq, + }, + ) + if err != nil { + return err + } + + return clientCtx.PrintProto(res) + }, + } + + flags.AddQueryFlagsToCmd(cmd) + flags.AddPaginationFlagsToCmd(cmd, "epoch-msgs") + + return cmd +} + +func CmdQueryEpochValidators() *cobra.Command { + cmd := &cobra.Command{ + Use: "epoch-validators [epoch_number]", + Short: "shows the validators of the current epoch, or the given epoch if specified", + Args: cobra.MaximumNArgs(1), + RunE: func(cmd *cobra.Command, args []string) error { + clientCtx := client.GetClientContextFromCmd(cmd) + + queryClient := types.NewQueryClient(clientCtx) + + epochNum, err := getEpoch(queryClient, args) + if err != nil { + return err + } + + pageReq, err := client.ReadPageRequest(cmd.Flags()) + if err != nil { + return err + } + + res, err := queryClient.EpochValSet( + context.Background(), + &types.QueryEpochValSetRequest{ + EpochNum: epochNum, + Pagination: pageReq, + }, + ) + if err != nil { + return err + } + + return clientCtx.PrintProto(res) + }, + } + + flags.AddQueryFlagsToCmd(cmd) + flags.AddPaginationFlagsToCmd(cmd, "epoch-validators") + + return cmd +} + +func getEpoch(queryClient types.QueryClient, args []string) (uint64, error) { + var ( + epochNum uint64 + err error + ) + + if len(args) == 0 { + // get the current epoch number + res, err := queryClient.CurrentEpoch( + context.Background(), + &types.QueryCurrentEpochRequest{}, + ) + if err != nil { + return 0, err + } + epochNum = res.CurrentEpoch + } else { + // get the given epoch number + epochNum, err = strconv.ParseUint(args[0], 10, 64) + if err != nil { + return 0, err + } + } + + return epochNum, nil +} diff --git a/x/epoching/client/cli/query_params.go b/x/epoching/client/cli/query_params.go deleted file mode 100644 index d6446d918..000000000 --- a/x/epoching/client/cli/query_params.go +++ /dev/null @@ -1,34 +0,0 @@ -package cli - -import ( - "context" - - "github.com/cosmos/cosmos-sdk/client" - "github.com/cosmos/cosmos-sdk/client/flags" - "github.com/spf13/cobra" - "github.com/babylonchain/babylon/x/epoching/types" -) - -func CmdQueryParams() *cobra.Command { - cmd := &cobra.Command{ - Use: "params", - Short: "shows the parameters of the module", - Args: cobra.NoArgs, - RunE: func(cmd *cobra.Command, args []string) error { - clientCtx := client.GetClientContextFromCmd(cmd) - - queryClient := types.NewQueryClient(clientCtx) - - res, err := queryClient.Params(context.Background(), &types.QueryParamsRequest{}) - if err != nil { - return err - } - - return clientCtx.PrintProto(res) - }, - } - - flags.AddQueryFlagsToCmd(cmd) - - return cmd -} diff --git a/x/epoching/client/cli/tx.go b/x/epoching/client/cli/tx.go index 42923beaf..a3fd11931 100644 --- a/x/epoching/client/cli/tx.go +++ b/x/epoching/client/cli/tx.go @@ -7,8 +7,8 @@ import ( "github.com/spf13/cobra" - "github.com/babylonchain/babylon/app/params" - "github.com/babylonchain/babylon/x/epoching/types" + "github.com/babylonlabs-io/babylon/app/params" + "github.com/babylonlabs-io/babylon/x/epoching/types" "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/client/flags" "github.com/cosmos/cosmos-sdk/client/tx" diff --git a/x/epoching/genesis.go b/x/epoching/genesis.go index efd7b985d..2c96e3694 100644 --- a/x/epoching/genesis.go +++ b/x/epoching/genesis.go @@ -2,8 +2,8 @@ package epoching import ( "context" - "github.com/babylonchain/babylon/x/epoching/keeper" - "github.com/babylonchain/babylon/x/epoching/types" + "github.com/babylonlabs-io/babylon/x/epoching/keeper" + "github.com/babylonlabs-io/babylon/x/epoching/types" ) // InitGenesis initializes the capability module's state from a provided genesis diff --git a/x/epoching/genesis_test.go b/x/epoching/genesis_test.go index ae92a5024..22c4450d9 100644 --- a/x/epoching/genesis_test.go +++ b/x/epoching/genesis_test.go @@ -3,11 +3,11 @@ package epoching_test import ( "testing" - "github.com/babylonchain/babylon/x/epoching" + "github.com/babylonlabs-io/babylon/x/epoching" "github.com/stretchr/testify/require" - simapp "github.com/babylonchain/babylon/app" - "github.com/babylonchain/babylon/x/epoching/types" + simapp "github.com/babylonlabs-io/babylon/app" + "github.com/babylonlabs-io/babylon/x/epoching/types" ) func TestExportGenesis(t *testing.T) { diff --git a/x/epoching/keeper/apphash_chain.go b/x/epoching/keeper/apphash_chain.go deleted file mode 100644 index 3a36b85f4..000000000 --- a/x/epoching/keeper/apphash_chain.go +++ /dev/null @@ -1,122 +0,0 @@ -package keeper - -import ( - "context" - "crypto/sha256" - "fmt" - - errorsmod "cosmossdk.io/errors" - "cosmossdk.io/store/prefix" - "github.com/cometbft/cometbft/crypto/merkle" - cmtcrypto "github.com/cometbft/cometbft/proto/tendermint/crypto" - "github.com/cosmos/cosmos-sdk/runtime" - sdk "github.com/cosmos/cosmos-sdk/types" - - "github.com/babylonchain/babylon/x/epoching/types" -) - -func (k Keeper) setAppHash(ctx context.Context, height uint64, appHash []byte) { - store := k.appHashStore(ctx) - heightBytes := sdk.Uint64ToBigEndian(height) - store.Set(heightBytes, appHash) -} - -// GetAppHash gets the AppHash of the header at the given height -func (k Keeper) GetAppHash(ctx context.Context, height uint64) ([]byte, error) { - store := k.appHashStore(ctx) - heightBytes := sdk.Uint64ToBigEndian(height) - appHash := store.Get(heightBytes) - if appHash == nil { - return nil, errorsmod.Wrapf(types.ErrInvalidHeight, "height %d is not known in DB yet", height) - } - return appHash, nil -} - -// RecordAppHash stores the AppHash of the current header to KVStore -func (k Keeper) RecordAppHash(ctx context.Context) { - sdkCtx := sdk.UnwrapSDKContext(ctx) - height := uint64(sdkCtx.HeaderInfo().Height) - appHash := sdkCtx.HeaderInfo().AppHash - // HACK: the app hash for the first height is set to nil - // instead of the hash of an empty byte slice as intended - // see proposed fix: https://github.com/cosmos/cosmos-sdk/pull/18524 - if height == 1 { - // $ echo -n '' | sha256sum - // e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 - emptyHash := sha256.Sum256([]byte{}) - appHash = emptyHash[:] - } - k.setAppHash(ctx, height, appHash) -} - -// GetAllAppHashesForEpoch fetches all AppHashes in the given epoch -func (k Keeper) GetAllAppHashesForEpoch(ctx context.Context, epoch *types.Epoch) ([][]byte, error) { - // if this epoch is the most recent AND has not ended, then we cannot get all AppHashs for this epoch - if k.GetEpoch(ctx).EpochNumber == epoch.EpochNumber && !epoch.IsLastBlock(sdk.UnwrapSDKContext(ctx)) { - return nil, errorsmod.Wrapf(types.ErrInvalidHeight, "GetAllAppHashesForEpoch can only be invoked when this epoch has ended") - } - - // fetch each AppHash in this epoch - appHashs := [][]byte{} - for i := epoch.FirstBlockHeight; i <= epoch.GetLastBlockHeight(); i++ { - appHash, err := k.GetAppHash(ctx, i) - if err != nil { - return nil, err - } - appHashs = append(appHashs, appHash) - } - - return appHashs, nil -} - -// ProveAppHashInEpoch generates a proof that the given appHash is in a given epoch -func (k Keeper) ProveAppHashInEpoch(ctx context.Context, height uint64, epochNumber uint64) (*cmtcrypto.Proof, error) { - // ensure height is inside this epoch - epoch, err := k.GetHistoricalEpoch(ctx, epochNumber) - if err != nil { - return nil, err - } - if !epoch.WithinBoundary(height) { - return nil, errorsmod.Wrapf(types.ErrInvalidHeight, "the given height %d is not in epoch %d (interval [%d, %d])", height, epoch.EpochNumber, epoch.FirstBlockHeight, epoch.GetLastBlockHeight()) - } - - // calculate index of this height in this epoch - idx := height - epoch.FirstBlockHeight - - // fetch all AppHashs, calculate Merkle tree and proof - appHashs, err := k.GetAllAppHashesForEpoch(ctx, epoch) - if err != nil { - return nil, err - } - _, proofs := merkle.ProofsFromByteSlices(appHashs) - - return proofs[idx].ToProto(), nil -} - -// VerifyAppHashInclusion verifies whether the given appHash is in the Merkle tree w.r.t. the appHashRoot -func VerifyAppHashInclusion(appHash []byte, appHashRoot []byte, proof *cmtcrypto.Proof) error { - if len(appHash) != sha256.Size { - return fmt.Errorf("appHash with length %d is not a Sha256 hash", len(appHash)) - } - if len(appHashRoot) != sha256.Size { - return fmt.Errorf("appHash with length %d is not a Sha256 hash", len(appHashRoot)) - } - if proof == nil { - return fmt.Errorf("proof is nil") - } - - unwrappedProof, err := merkle.ProofFromProto(proof) - if err != nil { - return fmt.Errorf("failed to unwrap proof: %w", err) - } - return unwrappedProof.Verify(appHashRoot, appHash) -} - -// appHashStore returns the KVStore for the AppHash of each header -// prefix: AppHashKey -// key: height -// value: AppHash in bytes -func (k Keeper) appHashStore(ctx context.Context) prefix.Store { - storeAdapter := runtime.KVStoreAdapter(k.storeService.OpenKVStore(ctx)) - return prefix.NewStore(storeAdapter, types.AppHashKey) -} diff --git a/x/epoching/keeper/apphash_chain_test.go b/x/epoching/keeper/apphash_chain_test.go deleted file mode 100644 index 3b4148dd9..000000000 --- a/x/epoching/keeper/apphash_chain_test.go +++ /dev/null @@ -1,50 +0,0 @@ -package keeper_test - -import ( - "math/rand" - "testing" - - "github.com/stretchr/testify/require" - - "github.com/babylonchain/babylon/testutil/datagen" - testhelper "github.com/babylonchain/babylon/testutil/helper" - "github.com/babylonchain/babylon/x/epoching/keeper" -) - -func FuzzAppHashChain(f *testing.F) { - datagen.AddRandomSeedsToFuzzer(f, 10) - - f.Fuzz(func(t *testing.T, seed int64) { - r := rand.New(rand.NewSource(seed)) - var err error - - helper := testhelper.NewHelper(t) - ctx, k := helper.Ctx, helper.App.EpochingKeeper - // ensure that the epoch info is correct at the genesis - epoch := k.GetEpoch(ctx) - require.Equal(t, epoch.EpochNumber, uint64(1)) - require.Equal(t, epoch.FirstBlockHeight, uint64(1)) - - // set a random epoch interval - epochInterval := k.GetParams(ctx).EpochInterval - - // reach the end of the 1st epoch - expectedHeight := epochInterval - 2 - for i := uint64(0); i < expectedHeight; i++ { - ctx, err = helper.ApplyEmptyBlockWithVoteExtension(r) - require.NoError(t, err) - } - // ensure epoch number is 1 - epoch = k.GetEpoch(ctx) - require.Equal(t, uint64(1), epoch.EpochNumber) - - // ensure prover and verifier are correct - randomHeightInEpoch := uint64(r.Intn(int(expectedHeight)) + 1) - randomAppHash, err := k.GetAppHash(ctx, randomHeightInEpoch) - require.NoError(t, err) - proof, err := k.ProveAppHashInEpoch(ctx, randomHeightInEpoch, epoch.EpochNumber) - require.NoError(t, err) - err = keeper.VerifyAppHashInclusion(randomAppHash, epoch.AppHashRoot, proof) - require.NoError(t, err) - }) -} diff --git a/x/epoching/keeper/drop_validator_msg_decorator.go b/x/epoching/keeper/drop_validator_msg_decorator.go index c9f3baa45..c6261b1e3 100644 --- a/x/epoching/keeper/drop_validator_msg_decorator.go +++ b/x/epoching/keeper/drop_validator_msg_decorator.go @@ -1,7 +1,7 @@ package keeper import ( - epochingtypes "github.com/babylonchain/babylon/x/epoching/types" + epochingtypes "github.com/babylonlabs-io/babylon/x/epoching/types" sdk "github.com/cosmos/cosmos-sdk/types" stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" ) diff --git a/x/epoching/keeper/epoch_msg_queue.go b/x/epoching/keeper/epoch_msg_queue.go index 52970fc52..232bef822 100644 --- a/x/epoching/keeper/epoch_msg_queue.go +++ b/x/epoching/keeper/epoch_msg_queue.go @@ -9,7 +9,7 @@ import ( errorsmod "cosmossdk.io/errors" "cosmossdk.io/store/prefix" - "github.com/babylonchain/babylon/x/epoching/types" + "github.com/babylonlabs-io/babylon/x/epoching/types" sdk "github.com/cosmos/cosmos-sdk/types" ) diff --git a/x/epoching/keeper/epoch_msg_queue_test.go b/x/epoching/keeper/epoch_msg_queue_test.go index 22703df73..b7fe5504d 100644 --- a/x/epoching/keeper/epoch_msg_queue_test.go +++ b/x/epoching/keeper/epoch_msg_queue_test.go @@ -4,16 +4,16 @@ import ( "math/rand" "testing" - "github.com/babylonchain/babylon/testutil/datagen" - testhelper "github.com/babylonchain/babylon/testutil/helper" - "github.com/babylonchain/babylon/x/epoching/types" + "github.com/babylonlabs-io/babylon/testutil/datagen" + testhelper "github.com/babylonlabs-io/babylon/testutil/helper" + "github.com/babylonlabs-io/babylon/x/epoching/types" stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/stretchr/testify/require" - appparams "github.com/babylonchain/babylon/app/params" + appparams "github.com/babylonlabs-io/babylon/app/params" ) var ( diff --git a/x/epoching/keeper/epoch_slashed_val_set.go b/x/epoching/keeper/epoch_slashed_val_set.go index a52b89624..1fa73f77e 100644 --- a/x/epoching/keeper/epoch_slashed_val_set.go +++ b/x/epoching/keeper/epoch_slashed_val_set.go @@ -5,7 +5,7 @@ import ( errorsmod "cosmossdk.io/errors" sdkmath "cosmossdk.io/math" "cosmossdk.io/store/prefix" - "github.com/babylonchain/babylon/x/epoching/types" + "github.com/babylonlabs-io/babylon/x/epoching/types" "github.com/cosmos/cosmos-sdk/runtime" sdk "github.com/cosmos/cosmos-sdk/types" ) diff --git a/x/epoching/keeper/epoch_slashed_val_set_test.go b/x/epoching/keeper/epoch_slashed_val_set_test.go index 90ae8ad4b..8231b9bb1 100644 --- a/x/epoching/keeper/epoch_slashed_val_set_test.go +++ b/x/epoching/keeper/epoch_slashed_val_set_test.go @@ -7,13 +7,13 @@ import ( sdkmath "cosmossdk.io/math" - "github.com/babylonchain/babylon/testutil/datagen" - testhelper "github.com/babylonchain/babylon/testutil/helper" + "github.com/babylonlabs-io/babylon/testutil/datagen" + testhelper "github.com/babylonlabs-io/babylon/testutil/helper" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/stretchr/testify/require" - "github.com/babylonchain/babylon/x/epoching/types" + "github.com/babylonlabs-io/babylon/x/epoching/types" ) func FuzzSlashedValSet(f *testing.F) { diff --git a/x/epoching/keeper/epoch_val_set.go b/x/epoching/keeper/epoch_val_set.go index 4095df178..baef32df6 100644 --- a/x/epoching/keeper/epoch_val_set.go +++ b/x/epoching/keeper/epoch_val_set.go @@ -5,7 +5,7 @@ import ( errorsmod "cosmossdk.io/errors" sdkmath "cosmossdk.io/math" "cosmossdk.io/store/prefix" - "github.com/babylonchain/babylon/x/epoching/types" + "github.com/babylonlabs-io/babylon/x/epoching/types" "github.com/cosmos/cosmos-sdk/runtime" sdk "github.com/cosmos/cosmos-sdk/types" ) diff --git a/x/epoching/keeper/epoch_val_set_test.go b/x/epoching/keeper/epoch_val_set_test.go index 8bc1e3b89..32b886bbb 100644 --- a/x/epoching/keeper/epoch_val_set_test.go +++ b/x/epoching/keeper/epoch_val_set_test.go @@ -4,8 +4,8 @@ import ( "math/rand" "testing" - "github.com/babylonchain/babylon/testutil/datagen" - testhelper "github.com/babylonchain/babylon/testutil/helper" + "github.com/babylonlabs-io/babylon/testutil/datagen" + testhelper "github.com/babylonlabs-io/babylon/testutil/helper" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/stretchr/testify/require" diff --git a/x/epoching/keeper/epochs.go b/x/epoching/keeper/epochs.go index 48ff16606..089318d63 100644 --- a/x/epoching/keeper/epochs.go +++ b/x/epoching/keeper/epochs.go @@ -6,11 +6,10 @@ import ( errorsmod "cosmossdk.io/errors" "cosmossdk.io/store/prefix" - "github.com/cometbft/cometbft/crypto/merkle" "github.com/cosmos/cosmos-sdk/runtime" sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/babylonchain/babylon/x/epoching/types" + "github.com/babylonlabs-io/babylon/x/epoching/types" ) func (k Keeper) setEpochInfo(ctx context.Context, epochNumber uint64, epoch *types.Epoch) { @@ -33,7 +32,7 @@ func (k Keeper) getEpochInfo(ctx context.Context, epochNumber uint64) (*types.Ep } // InitEpoch sets the zero epoch number to DB -func (k Keeper) InitEpoch(ctx context.Context) { +func (k Keeper) InitEpoch(ctx context.Context) *types.Epoch { header := sdk.UnwrapSDKContext(ctx).HeaderInfo() if header.Height > 0 { panic("InitEpoch can be invoked only at genesis") @@ -41,6 +40,7 @@ func (k Keeper) InitEpoch(ctx context.Context) { epochInterval := k.GetParams(ctx).EpochInterval epoch := types.NewEpoch(0, epochInterval, 0, &header.Time) k.setEpochInfo(ctx, 0, &epoch) + return &epoch } // GetEpoch fetches the current epoch @@ -60,9 +60,10 @@ func (k Keeper) GetHistoricalEpoch(ctx context.Context, epochNumber uint64) (*ty return epoch, err } -// RecordLastHeaderAndAppHashRoot records the last header and Merkle root of all AppHashs -// for the current epoch, and stores the epoch metadata to KVStore -func (k Keeper) RecordLastHeaderAndAppHashRoot(ctx context.Context) error { +// RecordLastHeaderTime records the last header's timestamp for the current +// epoch, and stores the epoch metadata to KVStore +// The timestamp is used for unbonding delegations once the epoch is timestamped +func (k Keeper) RecordLastHeaderTime(ctx context.Context) error { epoch := k.GetEpoch(ctx) if !epoch.IsLastBlock(ctx) { return errorsmod.Wrapf(types.ErrInvalidHeight, "RecordLastBlockHeader can only be invoked at the last block of an epoch") @@ -70,13 +71,6 @@ func (k Keeper) RecordLastHeaderAndAppHashRoot(ctx context.Context) error { // record last block header header := sdk.UnwrapSDKContext(ctx).HeaderInfo() epoch.LastBlockTime = &header.Time - // calculate and record the Merkle root - appHashes, err := k.GetAllAppHashesForEpoch(ctx, epoch) - if err != nil { - return err - } - appHashRoot := merkle.HashFromByteSlices(appHashes) - epoch.AppHashRoot = appHashRoot // save back to KVStore k.setEpochInfo(ctx, epoch.EpochNumber, epoch) return nil diff --git a/x/epoching/keeper/epochs_test.go b/x/epoching/keeper/epochs_test.go index a4a3dff99..30aaf91c3 100644 --- a/x/epoching/keeper/epochs_test.go +++ b/x/epoching/keeper/epochs_test.go @@ -6,8 +6,8 @@ import ( "github.com/stretchr/testify/require" - "github.com/babylonchain/babylon/testutil/datagen" - testhelper "github.com/babylonchain/babylon/testutil/helper" + "github.com/babylonlabs-io/babylon/testutil/datagen" + testhelper "github.com/babylonlabs-io/babylon/testutil/helper" ) func FuzzEpochs(f *testing.F) { diff --git a/x/epoching/keeper/grpc_query.go b/x/epoching/keeper/grpc_query.go index dfd8f8447..d3ea77434 100644 --- a/x/epoching/keeper/grpc_query.go +++ b/x/epoching/keeper/grpc_query.go @@ -7,7 +7,7 @@ import ( "cosmossdk.io/math" errorsmod "cosmossdk.io/errors" - "github.com/babylonchain/babylon/x/epoching/types" + "github.com/babylonlabs-io/babylon/x/epoching/types" sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" "github.com/cosmos/cosmos-sdk/types/query" @@ -49,10 +49,10 @@ func (k Keeper) EpochInfo(c context.Context, req *types.QueryEpochInfoRequest) ( if err != nil { return nil, err } - resp := &types.QueryEpochInfoResponse{ - Epoch: epoch, - } - return resp, nil + + return &types.QueryEpochInfoResponse{ + Epoch: epoch.ToResponse(), + }, nil } // EpochsInfo handles the QueryEpochsInfoRequest query @@ -60,7 +60,7 @@ func (k Keeper) EpochsInfo(c context.Context, req *types.QueryEpochsInfoRequest) ctx := sdk.UnwrapSDKContext(c) epochInfoStore := k.epochInfoStore(ctx) - epochs := []*types.Epoch{} + epochs := []*types.EpochResponse{} pageRes, err := query.Paginate(epochInfoStore, req.Pagination, func(key, value []byte) error { // unmarshal to epoch metadata var epoch types.Epoch @@ -68,19 +68,17 @@ func (k Keeper) EpochsInfo(c context.Context, req *types.QueryEpochsInfoRequest) return err } // append to epochs list - epochs = append(epochs, &epoch) + epochs = append(epochs, epoch.ToResponse()) return nil }) if err != nil { return nil, status.Error(codes.Internal, err.Error()) } - resp := &types.QueryEpochsInfoResponse{ + return &types.QueryEpochsInfoResponse{ Epochs: epochs, Pagination: pageRes, - } - - return resp, nil + }, nil } // EpochMsgs handles the QueryEpochMsgsRequest query @@ -92,7 +90,7 @@ func (k Keeper) EpochMsgs(c context.Context, req *types.QueryEpochMsgsRequest) ( return nil, types.ErrUnknownEpochNumber } - var msgs []*types.QueuedMessage + var msgs []*types.QueuedMessageResponse epochMsgsStore := k.msgQueueStore(ctx, req.EpochNum) // handle pagination @@ -111,17 +109,17 @@ func (k Keeper) EpochMsgs(c context.Context, req *types.QueryEpochMsgsRequest) ( return errors.New("invalid queue message") } // append to msgs - msgs = append(msgs, queuedMsg) + msgs = append(msgs, queuedMsg.ToResponse()) return nil }) if err != nil { return nil, status.Error(codes.Internal, err.Error()) } - resp := &types.QueryEpochMsgsResponse{ + + return &types.QueryEpochMsgsResponse{ Msgs: msgs, Pagination: pageRes, - } - return resp, nil + }, nil } // LatestEpochMsgs handles the QueryLatestEpochMsgsRequest query @@ -160,9 +158,10 @@ func (k Keeper) LatestEpochMsgs(c context.Context, req *types.QueryLatestEpochMs } if accumulate { + msgs := k.GetEpochMsgs(ctx, epochNumber) msgList := &types.QueuedMessageList{ EpochNumber: epochNumber, - Msgs: k.GetEpochMsgs(ctx, epochNumber), + Msgs: types.NewQueuedMessagesResponse(msgs), } latestEpochMsgs = append(latestEpochMsgs, msgList) } @@ -189,7 +188,8 @@ func (k Keeper) ValidatorLifecycle(c context.Context, req *types.QueryValidatorL } lc := k.GetValLifecycle(ctx, valAddr) return &types.QueryValidatorLifecycleResponse{ - ValLife: lc, + ValAddr: lc.ValAddr, + ValLife: types.NewValsetUpdateResponses(lc.ValLife), }, nil } diff --git a/x/epoching/keeper/grpc_query_test.go b/x/epoching/keeper/grpc_query_test.go index 8e528da99..fa92bb853 100644 --- a/x/epoching/keeper/grpc_query_test.go +++ b/x/epoching/keeper/grpc_query_test.go @@ -1,6 +1,7 @@ package keeper_test import ( + "encoding/hex" "math/rand" "testing" @@ -10,9 +11,9 @@ import ( "github.com/cosmos/cosmos-sdk/types/query" "github.com/stretchr/testify/require" - "github.com/babylonchain/babylon/testutil/datagen" - testhelper "github.com/babylonchain/babylon/testutil/helper" - "github.com/babylonchain/babylon/x/epoching/types" + "github.com/babylonlabs-io/babylon/testutil/datagen" + testhelper "github.com/babylonlabs-io/babylon/testutil/helper" + "github.com/babylonlabs-io/babylon/x/epoching/types" ) // FuzzParamsQuery fuzzes queryClient.Params @@ -151,7 +152,7 @@ func FuzzEpochMsgsQuery(f *testing.F) { // enque a random number of msgs with random txids for i := uint64(0); i < numMsgs; i++ { txid := datagen.GenRandomByteArray(r, 32) - txidsMap[string(txid)] = true + txidsMap[hex.EncodeToString(txid)] = true queuedMsg := types.QueuedMessage{ TxId: txid, Msg: &types.QueuedMessage_MsgDelegate{MsgDelegate: &stakingtypes.MsgDelegate{}}, @@ -170,7 +171,7 @@ func FuzzEpochMsgsQuery(f *testing.F) { require.Equal(t, min(uint64(len(txidsMap)), limit), uint64(len(resp.Msgs))) for idx := range resp.Msgs { - _, ok := txidsMap[string(resp.Msgs[idx].TxId)] + _, ok := txidsMap[resp.Msgs[idx].TxId] require.True(t, ok) } diff --git a/x/epoching/keeper/hooks.go b/x/epoching/keeper/hooks.go index 46cb2a758..525e26640 100644 --- a/x/epoching/keeper/hooks.go +++ b/x/epoching/keeper/hooks.go @@ -4,8 +4,8 @@ import ( "context" "cosmossdk.io/math" - checkpointingtypes "github.com/babylonchain/babylon/x/checkpointing/types" - "github.com/babylonchain/babylon/x/epoching/types" + checkpointingtypes "github.com/babylonlabs-io/babylon/x/checkpointing/types" + "github.com/babylonlabs-io/babylon/x/epoching/types" sdk "github.com/cosmos/cosmos-sdk/types" stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" ) @@ -135,8 +135,8 @@ func (h Hooks) AfterRawCheckpointFinalized(ctx context.Context, epoch uint64) er func (h Hooks) AfterBlsKeyRegistered(ctx context.Context, valAddr sdk.ValAddress) error { return nil } +func (h Hooks) AfterRawCheckpointSealed(ctx context.Context, epoch uint64) error { return nil } func (h Hooks) AfterRawCheckpointConfirmed(ctx context.Context, epoch uint64) error { return nil } - func (h Hooks) AfterRawCheckpointForgotten(ctx context.Context, ckpt *checkpointingtypes.RawCheckpoint) error { return nil } diff --git a/x/epoching/keeper/keeper.go b/x/epoching/keeper/keeper.go index 11741f489..f0eacc6c0 100644 --- a/x/epoching/keeper/keeper.go +++ b/x/epoching/keeper/keeper.go @@ -6,7 +6,7 @@ import ( corestoretypes "cosmossdk.io/core/store" "cosmossdk.io/log" - "github.com/babylonchain/babylon/x/epoching/types" + "github.com/babylonlabs-io/babylon/x/epoching/types" "github.com/cosmos/cosmos-sdk/baseapp" "github.com/cosmos/cosmos-sdk/codec" ) diff --git a/x/epoching/keeper/keeper_test.go b/x/epoching/keeper/keeper_test.go index 80ea94d3b..cb7068120 100644 --- a/x/epoching/keeper/keeper_test.go +++ b/x/epoching/keeper/keeper_test.go @@ -5,8 +5,8 @@ import ( "github.com/stretchr/testify/require" - testhelper "github.com/babylonchain/babylon/testutil/helper" - "github.com/babylonchain/babylon/x/epoching/types" + testhelper "github.com/babylonlabs-io/babylon/testutil/helper" + "github.com/babylonlabs-io/babylon/x/epoching/types" ) func TestParams(t *testing.T) { diff --git a/x/epoching/keeper/lifecycle_delegation.go b/x/epoching/keeper/lifecycle_delegation.go index d00859908..8213c8e15 100644 --- a/x/epoching/keeper/lifecycle_delegation.go +++ b/x/epoching/keeper/lifecycle_delegation.go @@ -4,7 +4,7 @@ import ( "context" "cosmossdk.io/store/prefix" - "github.com/babylonchain/babylon/x/epoching/types" + "github.com/babylonlabs-io/babylon/x/epoching/types" "github.com/cosmos/cosmos-sdk/runtime" sdk "github.com/cosmos/cosmos-sdk/types" ) diff --git a/x/epoching/keeper/lifecycle_validator.go b/x/epoching/keeper/lifecycle_validator.go index 75f6250bf..76026a72e 100644 --- a/x/epoching/keeper/lifecycle_validator.go +++ b/x/epoching/keeper/lifecycle_validator.go @@ -4,7 +4,7 @@ import ( "context" "cosmossdk.io/store/prefix" - "github.com/babylonchain/babylon/x/epoching/types" + "github.com/babylonlabs-io/babylon/x/epoching/types" "github.com/cosmos/cosmos-sdk/runtime" sdk "github.com/cosmos/cosmos-sdk/types" ) diff --git a/x/epoching/keeper/modified_staking.go b/x/epoching/keeper/modified_staking.go index 44c193494..d0b122c11 100644 --- a/x/epoching/keeper/modified_staking.go +++ b/x/epoching/keeper/modified_staking.go @@ -4,7 +4,7 @@ import ( "context" "fmt" - "github.com/babylonchain/babylon/x/epoching/types" + "github.com/babylonlabs-io/babylon/x/epoching/types" abci "github.com/cometbft/cometbft/abci/types" sdk "github.com/cosmos/cosmos-sdk/types" diff --git a/x/epoching/keeper/msg_server.go b/x/epoching/keeper/msg_server.go index 3db5b554d..280abec88 100644 --- a/x/epoching/keeper/msg_server.go +++ b/x/epoching/keeper/msg_server.go @@ -4,7 +4,7 @@ import ( "context" errorsmod "cosmossdk.io/errors" - "github.com/babylonchain/babylon/x/epoching/types" + "github.com/babylonlabs-io/babylon/x/epoching/types" "github.com/cometbft/cometbft/crypto/tmhash" sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" diff --git a/x/epoching/keeper/msg_server_test.go b/x/epoching/keeper/msg_server_test.go index cd1857f9f..2707c0cde 100644 --- a/x/epoching/keeper/msg_server_test.go +++ b/x/epoching/keeper/msg_server_test.go @@ -8,8 +8,8 @@ import ( stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" "github.com/stretchr/testify/require" - testhelper "github.com/babylonchain/babylon/testutil/helper" - "github.com/babylonchain/babylon/x/epoching/types" + testhelper "github.com/babylonlabs-io/babylon/testutil/helper" + "github.com/babylonlabs-io/babylon/x/epoching/types" ) // TODO (fuzz tests): replace the following tests with fuzz ones diff --git a/x/epoching/keeper/params.go b/x/epoching/keeper/params.go index 3f0a67762..38d0c8ea2 100644 --- a/x/epoching/keeper/params.go +++ b/x/epoching/keeper/params.go @@ -2,7 +2,7 @@ package keeper import ( "context" - "github.com/babylonchain/babylon/x/epoching/types" + "github.com/babylonlabs-io/babylon/x/epoching/types" ) // SetParams sets the x/epoching module parameters. diff --git a/x/epoching/keeper/params_test.go b/x/epoching/keeper/params_test.go index 01ff49ae6..1c193b7f0 100644 --- a/x/epoching/keeper/params_test.go +++ b/x/epoching/keeper/params_test.go @@ -3,8 +3,8 @@ package keeper_test import ( "testing" - testkeeper "github.com/babylonchain/babylon/testutil/keeper" - "github.com/babylonchain/babylon/x/epoching/types" + testkeeper "github.com/babylonlabs-io/babylon/testutil/keeper" + "github.com/babylonlabs-io/babylon/x/epoching/types" "github.com/stretchr/testify/require" ) diff --git a/x/epoching/keeper/staking_functions.go b/x/epoching/keeper/staking_functions.go index 577e7c88e..3d9e1935c 100644 --- a/x/epoching/keeper/staking_functions.go +++ b/x/epoching/keeper/staking_functions.go @@ -10,7 +10,7 @@ import ( sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" - "github.com/babylonchain/babylon/x/epoching/types" + "github.com/babylonlabs-io/babylon/x/epoching/types" ) // CheckMsgCreateValidator performs checks on a given `MsgCreateValidator` message diff --git a/x/epoching/module.go b/x/epoching/module.go index f21bdcdcb..06e611eb6 100644 --- a/x/epoching/module.go +++ b/x/epoching/module.go @@ -13,9 +13,9 @@ import ( abci "github.com/cometbft/cometbft/abci/types" - "github.com/babylonchain/babylon/x/epoching/client/cli" - "github.com/babylonchain/babylon/x/epoching/keeper" - "github.com/babylonchain/babylon/x/epoching/types" + "github.com/babylonlabs-io/babylon/x/epoching/client/cli" + "github.com/babylonlabs-io/babylon/x/epoching/keeper" + "github.com/babylonlabs-io/babylon/x/epoching/types" "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/codec" cdctypes "github.com/cosmos/cosmos-sdk/codec/types" diff --git a/x/epoching/types/epoching.pb.go b/x/epoching/types/epoching.pb.go index e63ee0f62..09e4bbfd7 100644 --- a/x/epoching/types/epoching.pb.go +++ b/x/epoching/types/epoching.pb.go @@ -83,17 +83,14 @@ type Epoch struct { // finalised. The last_block_time field is nil in the epoch's beginning, and // is set upon the end of this epoch. LastBlockTime *time.Time `protobuf:"bytes,4,opt,name=last_block_time,json=lastBlockTime,proto3,stdtime" json:"last_block_time,omitempty"` - // app_hash_root is the Merkle root of all AppHashs in this epoch - // It will be used for proving a block is in an epoch - AppHashRoot []byte `protobuf:"bytes,5,opt,name=app_hash_root,json=appHashRoot,proto3" json:"app_hash_root,omitempty"` // 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 - SealerAppHash []byte `protobuf:"bytes,6,opt,name=sealer_app_hash,json=sealerAppHash,proto3" json:"sealer_app_hash,omitempty"` + SealerAppHash []byte `protobuf:"bytes,5,opt,name=sealer_app_hash,json=sealerAppHash,proto3" json:"sealer_app_hash,omitempty"` // 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 - SealerBlockHash []byte `protobuf:"bytes,7,opt,name=sealer_block_hash,json=sealerBlockHash,proto3" json:"sealer_block_hash,omitempty"` + SealerBlockHash []byte `protobuf:"bytes,6,opt,name=sealer_block_hash,json=sealerBlockHash,proto3" json:"sealer_block_hash,omitempty"` } func (m *Epoch) Reset() { *m = Epoch{} } @@ -157,13 +154,6 @@ func (m *Epoch) GetLastBlockTime() *time.Time { return nil } -func (m *Epoch) GetAppHashRoot() []byte { - if m != nil { - return m.AppHashRoot - } - return nil -} - func (m *Epoch) GetSealerAppHash() []byte { if m != nil { return m.SealerAppHash @@ -343,61 +333,7 @@ func (*QueuedMessage) XXX_OneofWrappers() []interface{} { } } -// QueuedMessageList is a message that contains a list of staking-related -// messages queued for an epoch -type QueuedMessageList struct { - EpochNumber uint64 `protobuf:"varint,1,opt,name=epoch_number,json=epochNumber,proto3" json:"epoch_number,omitempty"` - Msgs []*QueuedMessage `protobuf:"bytes,2,rep,name=msgs,proto3" json:"msgs,omitempty"` -} - -func (m *QueuedMessageList) Reset() { *m = QueuedMessageList{} } -func (m *QueuedMessageList) String() string { return proto.CompactTextString(m) } -func (*QueuedMessageList) ProtoMessage() {} -func (*QueuedMessageList) Descriptor() ([]byte, []int) { - return fileDescriptor_2f2f209d5311f84c, []int{2} -} -func (m *QueuedMessageList) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *QueuedMessageList) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_QueuedMessageList.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 *QueuedMessageList) XXX_Merge(src proto.Message) { - xxx_messageInfo_QueuedMessageList.Merge(m, src) -} -func (m *QueuedMessageList) XXX_Size() int { - return m.Size() -} -func (m *QueuedMessageList) XXX_DiscardUnknown() { - xxx_messageInfo_QueuedMessageList.DiscardUnknown(m) -} - -var xxx_messageInfo_QueuedMessageList proto.InternalMessageInfo - -func (m *QueuedMessageList) GetEpochNumber() uint64 { - if m != nil { - return m.EpochNumber - } - return 0 -} - -func (m *QueuedMessageList) GetMsgs() []*QueuedMessage { - if m != nil { - return m.Msgs - } - return nil -} - -// ValStateUpdate is a messages that records a state update of a validator +// ValStateUpdate is a message that records a state update of a validator type ValStateUpdate struct { State BondState `protobuf:"varint,1,opt,name=state,proto3,enum=babylon.epoching.v1.BondState" json:"state,omitempty"` BlockHeight uint64 `protobuf:"varint,2,opt,name=block_height,json=blockHeight,proto3" json:"block_height,omitempty"` @@ -408,7 +344,7 @@ func (m *ValStateUpdate) Reset() { *m = ValStateUpdate{} } func (m *ValStateUpdate) String() string { return proto.CompactTextString(m) } func (*ValStateUpdate) ProtoMessage() {} func (*ValStateUpdate) Descriptor() ([]byte, []int) { - return fileDescriptor_2f2f209d5311f84c, []int{3} + return fileDescriptor_2f2f209d5311f84c, []int{2} } func (m *ValStateUpdate) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -458,7 +394,7 @@ func (m *ValStateUpdate) GetBlockTime() *time.Time { return nil } -// ValidatorLifecycle is a message that records records the lifecycle of +// ValidatorLifecycle is a message that records the lifecycle of // a validator type ValidatorLifecycle struct { ValAddr string `protobuf:"bytes,1,opt,name=val_addr,json=valAddr,proto3" json:"val_addr,omitempty"` @@ -469,7 +405,7 @@ func (m *ValidatorLifecycle) Reset() { *m = ValidatorLifecycle{} } func (m *ValidatorLifecycle) String() string { return proto.CompactTextString(m) } func (*ValidatorLifecycle) ProtoMessage() {} func (*ValidatorLifecycle) Descriptor() ([]byte, []int) { - return fileDescriptor_2f2f209d5311f84c, []int{4} + return fileDescriptor_2f2f209d5311f84c, []int{3} } func (m *ValidatorLifecycle) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -526,7 +462,7 @@ func (m *DelegationStateUpdate) Reset() { *m = DelegationStateUpdate{} } func (m *DelegationStateUpdate) String() string { return proto.CompactTextString(m) } func (*DelegationStateUpdate) ProtoMessage() {} func (*DelegationStateUpdate) Descriptor() ([]byte, []int) { - return fileDescriptor_2f2f209d5311f84c, []int{5} + return fileDescriptor_2f2f209d5311f84c, []int{4} } func (m *DelegationStateUpdate) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -590,7 +526,7 @@ func (m *DelegationStateUpdate) GetBlockTime() *time.Time { return nil } -// ValidatorLifecycle is a message that records records the lifecycle of +// ValidatorLifecycle is a message that records the lifecycle of // a delegation type DelegationLifecycle struct { DelAddr string `protobuf:"bytes,1,opt,name=del_addr,json=delAddr,proto3" json:"del_addr,omitempty"` @@ -601,7 +537,7 @@ func (m *DelegationLifecycle) Reset() { *m = DelegationLifecycle{} } func (m *DelegationLifecycle) String() string { return proto.CompactTextString(m) } func (*DelegationLifecycle) ProtoMessage() {} func (*DelegationLifecycle) Descriptor() ([]byte, []int) { - return fileDescriptor_2f2f209d5311f84c, []int{6} + return fileDescriptor_2f2f209d5311f84c, []int{5} } func (m *DelegationLifecycle) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -656,7 +592,7 @@ func (m *Validator) Reset() { *m = Validator{} } func (m *Validator) String() string { return proto.CompactTextString(m) } func (*Validator) ProtoMessage() {} func (*Validator) Descriptor() ([]byte, []int) { - return fileDescriptor_2f2f209d5311f84c, []int{7} + return fileDescriptor_2f2f209d5311f84c, []int{6} } func (m *Validator) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -703,7 +639,6 @@ func init() { proto.RegisterEnum("babylon.epoching.v1.BondState", BondState_name, BondState_value) proto.RegisterType((*Epoch)(nil), "babylon.epoching.v1.Epoch") proto.RegisterType((*QueuedMessage)(nil), "babylon.epoching.v1.QueuedMessage") - proto.RegisterType((*QueuedMessageList)(nil), "babylon.epoching.v1.QueuedMessageList") proto.RegisterType((*ValStateUpdate)(nil), "babylon.epoching.v1.ValStateUpdate") proto.RegisterType((*ValidatorLifecycle)(nil), "babylon.epoching.v1.ValidatorLifecycle") proto.RegisterType((*DelegationStateUpdate)(nil), "babylon.epoching.v1.DelegationStateUpdate") @@ -716,65 +651,63 @@ func init() { } var fileDescriptor_2f2f209d5311f84c = []byte{ - // 927 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xa4, 0x96, 0xdf, 0x6e, 0xdb, 0x36, - 0x14,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0xd3, 0xb8, 0x65, 0xec, 0x19, 0xfb, 0x65, 0x5c, 0xd3, - 0xb1, 0xb1, 0x0e, 0xa1, 0x23, 0xf8, 0xc4, 0x49, 0xe2, 0x98, 0x32, 0x69, 0xa5, 0x52, 0x9f, 0x49, - 0x1a, 0x4f, 0x49, 0xd0, 0x2a, 0x6a, 0xf1, 0x76, 0x96, 0xd5, 0x86, 0xa7, 0x59, 0x0e, 0x7d, 0x09, - 0xe8, 0xd2, 0x8f, 0x85, 0xb4, 0xec, 0x80, 0x3b, 0x6f, 0xac, 0x09, 0xf5, 0xbd, 0x89, 0x6c, 0x95, - 0x74, 0x45, 0x53, 0x67, 0xfa, 0x2a, 0x31, 0xd2, 0x71, 0x34, 0x82, 0x27, 0x01, 0xc9, 0xc5, 0x8a, - 0x42, 0xab, 0xbc, 0x67, 0xec, 0xd7, 0x7a, 0x3b, 0x66, 0x8a, 0xc8, 0x9c, 0x21, 0x32, 0x5f, 0xcf, - 0x10, 0xf5, 0xcb, 0xef, 0xfe, 0xda, 0x35, 0x70, 0x43, 0x15, 0x6a, 0x2f, 0x95, 0x41, 0x1d, 0x68, - 0x90, 0x28, 0xb2, 0x26, 0x44, 0x4c, 0xac, 0x98, 0x73, 0xd9, 0xaa, 0xec, 0x19, 0xfb, 0x75, 0x5c, - 0x23, 0x51, 0x34, 0x22, 0x62, 0x82, 0x39, 0x97, 0xe8, 0x0b, 0x78, 0x22, 0x28, 0x09, 0x68, 0x6c, - 0xcd, 0xa4, 0xad, 0x35, 0xad, 0x6a, 0xa4, 0xe1, 0xe3, 0x54, 0x8b, 0x0e, 0xe0, 0x69, 0xa6, 0xcb, - 0x9a, 0x50, 0xca, 0x75, 0xad, 0xcc, 0x0c, 0xd2, 0x1e, 0x88, 0x98, 0x74, 0xde, 0x97, 0xa1, 0xf1, - 0x53, 0x42, 0x13, 0xea, 0x9e, 0x51, 0x21, 0x88, 0x47, 0xd1, 0x16, 0x54, 0xe4, 0x95, 0xe5, 0xbb, - 0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+ // 883 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xa4, 0x95, 0xdf, 0x6e, 0xe3, 0x44, + 0x14, 0xc6, 0xe3, 0xfc, 0x6b, 0x73, 0x92, 0x74, 0xc3, 0xb4, 0x8b, 0xb2, 0x15, 0x4a, 0x4b, 0x10, + 0xa8, 0xaa, 0xc0, 0x56, 0x43, 0xb9, 0x05, 0x35, 0x4d, 0x44, 0x2a, 0x6d, 0xb3, 0xc2, 0x6c, 0x7b, + 0xc1, 0x05, 0xd6, 0xd8, 0x9e, 0xda, 0xd6, 0xda, 0x1e, 0xcb, 0x33, 0xce, 0xb6, 0x17, 0xbc, 0xc3, + 0x3e, 0x07, 0xe2, 0x41, 0xb8, 0xdc, 0x4b, 0xee, 0x40, 0xed, 0x83, 0x2c, 0x9a, 0x19, 0xc7, 0x49, + 0x69, 0x94, 0xaa, 0xec, 0x9d, 0xe7, 0x9c, 0xef, 0x7c, 0x73, 0xce, 0x2f, 0x47, 0x13, 0xe8, 0xdb, + 0xd8, 0xbe, 0x09, 0x69, 0x6c, 0x90, 0x84, 0x3a, 0x7e, 0x10, 0x7b, 0xc6, 0xec, 0xa8, 0xf8, 0xd6, + 0x93, 0x94, 0x72, 0x8a, 0xb6, 0x73, 0x8d, 0x5e, 0xc4, 0x67, 0x47, 0xbb, 0x7b, 0x1e, 0xa5, 0x5e, + 0x48, 0x0c, 0x29, 0xb1, 0xb3, 0x2b, 0x83, 0x07, 0x11, 0x61, 0x1c, 0x47, 0x89, 0xaa, 0xda, 0xdd, + 0xf1, 0xa8, 0x47, 0xe5, 0xa7, 0x21, 0xbe, 0xf2, 0xe8, 0x9e, 0x43, 0x59, 0x44, 0x99, 0xc1, 0x38, + 0x7e, 0xa3, 0x6e, 0xb3, 0x09, 0xc7, 0x47, 0x06, 0xbf, 0xce, 0x05, 0xbd, 0x5c, 0x60, 0x63, 0x46, + 0x8a, 0xac, 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6a, 0x89, 0xf9, 0xe1, 0x4a, 0x38, 0x2b, 0xb9, 0x4a, 0x1b, 0x89, 0xfe, 0x3b, 0x68, 0x2c, + 0x5e, 0x09, 0x04, 0xd5, 0xe2, 0xaa, 0x96, 0x29, 0xbf, 0xd1, 0x0e, 0xd4, 0x12, 0xfa, 0x96, 0x28, + 0x90, 0x15, 0x53, 0x1d, 0x0e, 0xa7, 0xd0, 0x28, 0xa8, 0xa3, 0x26, 0x6c, 0x9c, 0x9a, 0xe3, 0x93, + 0xd7, 0xe3, 0x51, 0xa7, 0x84, 0x00, 0xea, 0xc3, 0x57, 0xd3, 0xd1, 0x78, 0xd4, 0xd1, 0x50, 0x1b, + 0x1a, 0x17, 0x53, 0x71, 0x3a, 0x9b, 0xfe, 0xd8, 0x29, 0xa3, 0x16, 0x6c, 0xaa, 0xe3, 0x78, 0xd4, + 0xa9, 0x88, 0x2a, 0x73, 0x7c, 0xfe, 0xea, 0x72, 0x3c, 0xea, 0x54, 0x87, 0x2f, 0xff, 0xbc, 0xed, + 0x69, 0xef, 0x6f, 0x7b, 0xda, 0x3f, 0xb7, 0x3d, 0xed, 0xdd, 0x5d, 0xaf, 0xf4, 0xfe, 0xae, 0x57, + 0xfa, 0xeb, 0xae, 0x57, 0xfa, 0x65, 0xe0, 0x05, 0xdc, 0xcf, 0x6c, 0xdd, 0xa1, 0x91, 0x91, 0xcf, + 0x17, 0x62, 0x9b, 0x7d, 0x13, 0xd0, 0xf9, 0xd1, 0xb8, 0x5e, 0xfc, 0x6f, 0xf3, 0x9b, 0x84, 0x30, + 0xbb, 0x2e, 0x91, 0x7f, 0xfb, 0x6f, 0x00, 0x00, 0x00, 0xff, 0xff, 0x40, 0x5d, 0x2a, 0x76, 0xd8, + 0x07, 0x00, 0x00, } func (m *Epoch) Marshal() (dAtA []byte, err error) { @@ -802,20 +735,13 @@ func (m *Epoch) MarshalToSizedBuffer(dAtA []byte) (int, error) { copy(dAtA[i:], m.SealerBlockHash) i = encodeVarintEpoching(dAtA, i, uint64(len(m.SealerBlockHash))) i-- - dAtA[i] = 0x3a + dAtA[i] = 0x32 } if len(m.SealerAppHash) > 0 { i -= len(m.SealerAppHash) copy(dAtA[i:], m.SealerAppHash) i = encodeVarintEpoching(dAtA, i, uint64(len(m.SealerAppHash))) i-- - dAtA[i] = 0x32 - } - if len(m.AppHashRoot) > 0 { - i -= len(m.AppHashRoot) - copy(dAtA[i:], m.AppHashRoot) - i = encodeVarintEpoching(dAtA, i, uint64(len(m.AppHashRoot))) - i-- dAtA[i] = 0x2a } if m.LastBlockTime != nil { @@ -1012,48 +938,6 @@ func (m *QueuedMessage_MsgCancelUnbondingDelegation) MarshalToSizedBuffer(dAtA [ } return len(dAtA) - i, nil } -func (m *QueuedMessageList) 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 *QueuedMessageList) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *QueuedMessageList) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if len(m.Msgs) > 0 { - for iNdEx := len(m.Msgs) - 1; iNdEx >= 0; iNdEx-- { - { - size, err := m.Msgs[iNdEx].MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintEpoching(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x12 - } - } - if m.EpochNumber != 0 { - i = encodeVarintEpoching(dAtA, i, uint64(m.EpochNumber)) - i-- - dAtA[i] = 0x8 - } - return len(dAtA) - i, nil -} - func (m *ValStateUpdate) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) @@ -1312,10 +1196,6 @@ func (m *Epoch) Size() (n int) { l = github_com_cosmos_gogoproto_types.SizeOfStdTime(*m.LastBlockTime) n += 1 + l + sovEpoching(uint64(l)) } - l = len(m.AppHashRoot) - if l > 0 { - n += 1 + l + sovEpoching(uint64(l)) - } l = len(m.SealerAppHash) if l > 0 { n += 1 + l + sovEpoching(uint64(l)) @@ -1414,24 +1294,6 @@ func (m *QueuedMessage_MsgCancelUnbondingDelegation) Size() (n int) { } return n } -func (m *QueuedMessageList) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if m.EpochNumber != 0 { - n += 1 + sovEpoching(uint64(m.EpochNumber)) - } - if len(m.Msgs) > 0 { - for _, e := range m.Msgs { - l = e.Size() - n += 1 + l + sovEpoching(uint64(l)) - } - } - return n -} - func (m *ValStateUpdate) Size() (n int) { if m == nil { return 0 @@ -1661,40 +1523,6 @@ func (m *Epoch) Unmarshal(dAtA []byte) error { } iNdEx = postIndex case 5: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field AppHashRoot", wireType) - } - var byteLen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowEpoching - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - byteLen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if byteLen < 0 { - return ErrInvalidLengthEpoching - } - postIndex := iNdEx + byteLen - if postIndex < 0 { - return ErrInvalidLengthEpoching - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.AppHashRoot = append(m.AppHashRoot[:0], dAtA[iNdEx:postIndex]...) - if m.AppHashRoot == nil { - m.AppHashRoot = []byte{} - } - iNdEx = postIndex - case 6: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field SealerAppHash", wireType) } @@ -1728,7 +1556,7 @@ func (m *Epoch) Unmarshal(dAtA []byte) error { m.SealerAppHash = []byte{} } iNdEx = postIndex - case 7: + case 6: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field SealerBlockHash", wireType) } @@ -2131,109 +1959,6 @@ func (m *QueuedMessage) Unmarshal(dAtA []byte) error { } return nil } -func (m *QueuedMessageList) 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 ErrIntOverflowEpoching - } - 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: QueuedMessageList: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: QueuedMessageList: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field EpochNumber", wireType) - } - m.EpochNumber = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowEpoching - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.EpochNumber |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Msgs", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowEpoching - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthEpoching - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthEpoching - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Msgs = append(m.Msgs, &QueuedMessage{}) - if err := m.Msgs[len(m.Msgs)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipEpoching(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthEpoching - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} func (m *ValStateUpdate) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 diff --git a/x/epoching/types/epoching_test.go b/x/epoching/types/epoching_test.go index a82e9e303..451f406fb 100644 --- a/x/epoching/types/epoching_test.go +++ b/x/epoching/types/epoching_test.go @@ -1,11 +1,11 @@ package types_test import ( - "github.com/babylonchain/babylon/testutil/datagen" + "github.com/babylonlabs-io/babylon/testutil/datagen" "math/rand" "testing" - "github.com/babylonchain/babylon/x/epoching/types" + "github.com/babylonlabs-io/babylon/x/epoching/types" "github.com/stretchr/testify/require" ) diff --git a/x/epoching/types/events.pb.go b/x/epoching/types/events.pb.go index a1b01c203..bd2c2aef1 100644 --- a/x/epoching/types/events.pb.go +++ b/x/epoching/types/events.pb.go @@ -598,48 +598,48 @@ func init() { proto.RegisterFile("babylon/epoching/v1/events.proto", fileDescrip var fileDescriptor_2f0a2c43c7aaeb43 = []byte{ // 674 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xd4, 0x55, 0xcd, 0x6e, 0xd4, 0x3c, - 0x14, 0x6d, 0xe6, 0xef, 0x53, 0xfd, 0xf5, 0xd7, 0x33, 0x8c, 0x22, 0x2a, 0x86, 0x61, 0xa4, 0x8a, - 0x4a, 0xc0, 0xa4, 0x05, 0x84, 0x10, 0xbb, 0x0e, 0x54, 0x6a, 0x91, 0x40, 0x10, 0xda, 0x22, 0xb1, - 0x89, 0x9c, 0xd8, 0x24, 0x16, 0x89, 0x1d, 0xd9, 0xce, 0xd0, 0x79, 0x0b, 0x5e, 0x80, 0x1d, 0x0f, - 0xc0, 0x4b, 0x20, 0x58, 0x76, 0x89, 0x58, 0x20, 0xd4, 0xae, 0x78, 0x0b, 0x14, 0xe7, 0xa7,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xff, 0xd4, 0xc9, 0xbb, 0x1a, 0x58, 0xaa, 0x3a, 0xd1, + 0x7f, 0xb7, 0x4d, 0xfe, 0xce, 0xce, 0x3d, 0x60, 0x4a, 0x9e, 0x08, 0x8f, 0x38, 0x67, 0xb9, 0xea, + 0x66, 0xfc, 0xde, 0xef, 0xde, 0x46, 0xe0, 0x0a, 0x26, 0x52, 0x51, 0x86, 0x14, 0xe5, 0xec, 0x94, + 0xf4, 0xba, 0x4e, 0x5f, 0xaa, 0x88, 0xf6, 0xce, 0xee, 0x4f, 0xe3, 0xf4, 0xfe, 0x34, 0xff, 0xdc, + 0x9f, 0xd6, 0x69, 0xfd, 0xf9, 0x61, 0x80, 0xe5, 0x6a, 0x7f, 0x1e, 0x20, 0xe6, 0x91, 0x70, 0x97, + 0xb9, 0x9c, 0x61, 0xca, 0xfc, 0xfc, 0x00, 0x53, 0xce, 0xfe, 0xc1, 0xe0, 0xaf, 0x83, 0x79, 0x4f, + 0x90, 0xac, 0x63, 0xf9, 0x25, 0xd6, 0xd0, 0xff, 0xe9, 0x5c, 0x01, 0x6f, 0x65, 0x97, 0xd9, 0xf9, + 0xce, 0xc2, 0xe8, 0xd1, 0xe7, 0xc3, 0x9e, 0x71, 0x70, 0xd8, 0x33, 0xbe, 0x1f, 0xf6, 0x8c, 0xb7, + 0x47, 0xbd, 0xa9, 0x83, 0xa3, 0xde, 0xd4, 0x97, 0xa3, 0xde, 0xd4, 0xcb, 0xf5, 0xca, 0x05, 0x96, + 0xbf, 0x18, 0x21, 0x72, 0xe5, 0x2a, 0xe5, 0x45, 0x68, 0xed, 0x1f, 0x3f, 0x32, 0xfa, 0x2e, 0x73, + 0x5b, 0xfa, 0xd9, 0xb8, 0xfd, 0x33, 0x00, 0x00, 0xff, 0xff, 0x6d, 0x85, 0x55, 0x11, 0x85, 0x06, 0x00, 0x00, } diff --git a/x/epoching/types/genesis.pb.go b/x/epoching/types/genesis.pb.go index 77f300cdf..6120270f5 100644 --- a/x/epoching/types/genesis.pb.go +++ b/x/epoching/types/genesis.pb.go @@ -75,7 +75,7 @@ func init() { func init() { proto.RegisterFile("babylon/epoching/v1/genesis.proto", fileDescriptor_2ef836361c424501) } var fileDescriptor_2ef836361c424501 = []byte{ - // 200 bytes of a gzipped FileDescriptorProto + // 202 bytes of a gzipped FileDescriptorProto 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x52, 0x4c, 0x4a, 0x4c, 0xaa, 0xcc, 0xc9, 0xcf, 0xd3, 0x4f, 0x2d, 0xc8, 0x4f, 0xce, 0xc8, 0xcc, 0x4b, 0xd7, 0x2f, 0x33, 0xd4, 0x4f, 0x4f, 0xcd, 0x4b, 0x2d, 0xce, 0x2c, 0xd6, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0x12, 0x86, @@ -83,12 +83,12 @@ var fileDescriptor_2ef836361c424501 = []byte{ 0x83, 0x58, 0x10, 0xa5, 0x52, 0x0a, 0xd8, 0x4c, 0x2b, 0x48, 0x2c, 0x4a, 0xcc, 0x85, 0x1a, 0xa6, 0xe4, 0xc9, 0xc5, 0xe3, 0x0e, 0x31, 0x3d, 0xb8, 0x24, 0xb1, 0x24, 0x55, 0xc8, 0x92, 0x8b, 0x0d, 0x22, 0x2f, 0xc1, 0xa8, 0xc0, 0xa8, 0xc1, 0x6d, 0x24, 0xad, 0x87, 0xc5, 0x36, 0xbd, 0x00, 0xb0, - 0x12, 0x27, 0x96, 0x13, 0xf7, 0xe4, 0x19, 0x82, 0xa0, 0x1a, 0x9c, 0xbc, 0x4e, 0x3c, 0x92, 0x63, + 0x12, 0x27, 0x96, 0x13, 0xf7, 0xe4, 0x19, 0x82, 0xa0, 0x1a, 0x9c, 0x7c, 0x4e, 0x3c, 0x92, 0x63, 0xbc, 0xf0, 0x48, 0x8e, 0xf1, 0xc1, 0x23, 0x39, 0xc6, 0x09, 0x8f, 0xe5, 0x18, 0x2e, 0x3c, 0x96, - 0x63, 0xb8, 0xf1, 0x58, 0x8e, 0x21, 0xca, 0x20, 0x3d, 0xb3, 0x24, 0xa3, 0x34, 0x49, 0x2f, 0x39, - 0x3f, 0x57, 0x1f, 0x6a, 0x5c, 0x72, 0x46, 0x62, 0x66, 0x1e, 0x8c, 0xa3, 0x5f, 0x81, 0x70, 0x60, - 0x49, 0x65, 0x41, 0x6a, 0x71, 0x12, 0x1b, 0xd8, 0x75, 0xc6, 0x80, 0x00, 0x00, 0x00, 0xff, 0xff, - 0xa9, 0x51, 0x6f, 0x4e, 0x0f, 0x01, 0x00, 0x00, + 0x63, 0xb8, 0xf1, 0x58, 0x8e, 0x21, 0xca, 0x28, 0x3d, 0xb3, 0x24, 0xa3, 0x34, 0x49, 0x2f, 0x39, + 0x3f, 0x57, 0x1f, 0x6a, 0x5c, 0x4e, 0x62, 0x52, 0xb1, 0x6e, 0x66, 0x3e, 0x8c, 0xab, 0x5f, 0x81, + 0x70, 0x62, 0x49, 0x65, 0x41, 0x6a, 0x71, 0x12, 0x1b, 0xd8, 0x7d, 0xc6, 0x80, 0x00, 0x00, 0x00, + 0xff, 0xff, 0x30, 0xa3, 0x4a, 0x33, 0x11, 0x01, 0x00, 0x00, } func (m *GenesisState) Marshal() (dAtA []byte, err error) { diff --git a/x/epoching/types/genesis_test.go b/x/epoching/types/genesis_test.go index 925ae1db6..a974f6572 100644 --- a/x/epoching/types/genesis_test.go +++ b/x/epoching/types/genesis_test.go @@ -3,10 +3,10 @@ package types_test import ( "testing" - "github.com/babylonchain/babylon/app" - "github.com/babylonchain/babylon/testutil/nullify" - "github.com/babylonchain/babylon/x/epoching" - "github.com/babylonchain/babylon/x/epoching/types" + "github.com/babylonlabs-io/babylon/app" + "github.com/babylonlabs-io/babylon/testutil/nullify" + "github.com/babylonlabs-io/babylon/x/epoching" + "github.com/babylonlabs-io/babylon/x/epoching/types" "github.com/stretchr/testify/require" ) diff --git a/x/epoching/types/keys.go b/x/epoching/types/keys.go index 5ec668b83..c6ac89674 100644 --- a/x/epoching/types/keys.go +++ b/x/epoching/types/keys.go @@ -27,8 +27,7 @@ var ( SlashedValidatorSetKey = []byte{0x17} // key prefix for slashed validator set ValidatorLifecycleKey = []byte{0x18} // key prefix for validator life cycle DelegationLifecycleKey = []byte{0x19} // key prefix for delegation life cycle - AppHashKey = []byte{0x20} // key prefix for the app hash - ParamsKey = []byte{0x21} // key prefix for the parameters + ParamsKey = []byte{0x20} // key prefix for the parameters ) func KeyPrefix(p string) []byte { diff --git a/x/epoching/types/msg_test.go b/x/epoching/types/msg_test.go index f5822d564..b94157622 100644 --- a/x/epoching/types/msg_test.go +++ b/x/epoching/types/msg_test.go @@ -5,11 +5,11 @@ import ( "time" sdkmath "cosmossdk.io/math" - appparams "github.com/babylonchain/babylon/app/params" + appparams "github.com/babylonlabs-io/babylon/app/params" "github.com/stretchr/testify/require" - "github.com/babylonchain/babylon/x/epoching/types" + "github.com/babylonlabs-io/babylon/x/epoching/types" "github.com/cosmos/cosmos-sdk/codec" codectypes "github.com/cosmos/cosmos-sdk/codec/types" cryptocodec "github.com/cosmos/cosmos-sdk/crypto/codec" diff --git a/x/epoching/types/params.pb.go b/x/epoching/types/params.pb.go index 21ae0f84b..94aed1d31 100644 --- a/x/epoching/types/params.pb.go +++ b/x/epoching/types/params.pb.go @@ -76,7 +76,7 @@ func init() { func init() { proto.RegisterFile("babylon/epoching/v1/params.proto", fileDescriptor_c9e38cfe55335900) } var fileDescriptor_c9e38cfe55335900 = []byte{ - // 201 bytes of a gzipped FileDescriptorProto + // 203 bytes of a gzipped FileDescriptorProto 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x52, 0x48, 0x4a, 0x4c, 0xaa, 0xcc, 0xc9, 0xcf, 0xd3, 0x4f, 0x2d, 0xc8, 0x4f, 0xce, 0xc8, 0xcc, 0x4b, 0xd7, 0x2f, 0x33, 0xd4, 0x2f, 0x48, 0x2c, 0x4a, 0xcc, 0x2d, 0xd6, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0x12, 0x86, 0xaa, @@ -84,12 +84,12 @@ var fileDescriptor_c9e38cfe55335900 = []byte{ 0x58, 0x10, 0xa5, 0x4a, 0x01, 0x5c, 0x6c, 0x01, 0x60, 0xad, 0x42, 0x0e, 0x5c, 0x7c, 0x60, 0xe5, 0xf1, 0x99, 0x79, 0x25, 0xa9, 0x45, 0x65, 0x89, 0x39, 0x12, 0x8c, 0x0a, 0x8c, 0x1a, 0x2c, 0x4e, 0x92, 0x9f, 0xee, 0xc9, 0x8b, 0x56, 0x26, 0xe6, 0xe6, 0x58, 0x29, 0xa1, 0xca, 0x2b, 0x05, 0xf1, - 0x82, 0x05, 0x3c, 0xa1, 0x7c, 0x2b, 0x96, 0x17, 0x0b, 0xe4, 0x19, 0x9d, 0xbc, 0x4e, 0x3c, 0x92, + 0x82, 0x05, 0x3c, 0xa1, 0x7c, 0x2b, 0x96, 0x17, 0x0b, 0xe4, 0x19, 0x9d, 0x7c, 0x4e, 0x3c, 0x92, 0x63, 0xbc, 0xf0, 0x48, 0x8e, 0xf1, 0xc1, 0x23, 0x39, 0xc6, 0x09, 0x8f, 0xe5, 0x18, 0x2e, 0x3c, - 0x96, 0x63, 0xb8, 0xf1, 0x58, 0x8e, 0x21, 0xca, 0x20, 0x3d, 0xb3, 0x24, 0xa3, 0x34, 0x49, 0x2f, - 0x39, 0x3f, 0x57, 0x1f, 0xea, 0xc2, 0xe4, 0x8c, 0xc4, 0xcc, 0x3c, 0x18, 0x47, 0xbf, 0x02, 0xe1, - 0xa5, 0x92, 0xca, 0x82, 0xd4, 0xe2, 0x24, 0x36, 0xb0, 0x23, 0x8d, 0x01, 0x01, 0x00, 0x00, 0xff, - 0xff, 0xa6, 0x7d, 0x61, 0x54, 0xf3, 0x00, 0x00, 0x00, + 0x96, 0x63, 0xb8, 0xf1, 0x58, 0x8e, 0x21, 0xca, 0x28, 0x3d, 0xb3, 0x24, 0xa3, 0x34, 0x49, 0x2f, + 0x39, 0x3f, 0x57, 0x1f, 0xea, 0xc2, 0x9c, 0xc4, 0xa4, 0x62, 0xdd, 0xcc, 0x7c, 0x18, 0x57, 0xbf, + 0x02, 0xe1, 0xa9, 0x92, 0xca, 0x82, 0xd4, 0xe2, 0x24, 0x36, 0xb0, 0x33, 0x8d, 0x01, 0x01, 0x00, + 0x00, 0xff, 0xff, 0x12, 0xc9, 0x0a, 0x86, 0xf5, 0x00, 0x00, 0x00, } func (this *Params) Equal(that interface{}) bool { diff --git a/x/epoching/types/params_test.go b/x/epoching/types/params_test.go index 83424dd41..c8096638d 100644 --- a/x/epoching/types/params_test.go +++ b/x/epoching/types/params_test.go @@ -3,7 +3,7 @@ package types_test import ( "testing" - "github.com/babylonchain/babylon/x/epoching/types" + "github.com/babylonlabs-io/babylon/x/epoching/types" "github.com/stretchr/testify/require" ) diff --git a/x/epoching/types/query.go b/x/epoching/types/query.go new file mode 100644 index 000000000..7534862c3 --- /dev/null +++ b/x/epoching/types/query.go @@ -0,0 +1,55 @@ +package types + +import ( + "encoding/hex" +) + +// ToResponse parses a Epoch into a query response epoch struct. +func (e *Epoch) ToResponse() *EpochResponse { + return &EpochResponse{ + EpochNumber: e.EpochNumber, + CurrentEpochInterval: e.CurrentEpochInterval, + FirstBlockHeight: e.FirstBlockHeight, + LastBlockTime: e.LastBlockTime, + SealerAppHashHex: hex.EncodeToString(e.SealerAppHash), + SealerBlockHash: hex.EncodeToString(e.SealerBlockHash), + } +} + +// ToResponse parses a QueuedMessage into a query response queued message struct. +func (q *QueuedMessage) ToResponse() *QueuedMessageResponse { + return &QueuedMessageResponse{ + TxId: hex.EncodeToString(q.TxId), + MsgId: hex.EncodeToString(q.MsgId), + BlockHeight: q.BlockHeight, + BlockTime: q.BlockTime, + Msg: q.UnwrapToSdkMsg().String(), + } +} + +// ToResponse parses a ValStateUpdate into a query response valset update struct. +func (v *ValStateUpdate) ToResponse() *ValStateUpdateResponse { + return &ValStateUpdateResponse{ + StateDesc: v.State.String(), + BlockHeight: v.BlockHeight, + BlockTime: v.BlockTime, + } +} + +// NewValsetUpdateResponses parses all the valset updates as response. +func NewValsetUpdateResponses(vs []*ValStateUpdate) []*ValStateUpdateResponse { + resp := make([]*ValStateUpdateResponse, len(vs)) + for i, v := range vs { + resp[i] = v.ToResponse() + } + return resp +} + +// NewQueuedMessagesResponse parses all the queued messages as response. +func NewQueuedMessagesResponse(msgs []*QueuedMessage) []*QueuedMessageResponse { + resp := make([]*QueuedMessageResponse, len(msgs)) + for i, m := range msgs { + resp[i] = m.ToResponse() + } + return resp +} diff --git a/x/epoching/types/query.pb.go b/x/epoching/types/query.pb.go index 59bfc31b9..4d5e795ae 100644 --- a/x/epoching/types/query.pb.go +++ b/x/epoching/types/query.pb.go @@ -10,19 +10,23 @@ import ( _ "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. @@ -160,7 +164,7 @@ func (m *QueryEpochInfoRequest) GetEpochNum() uint64 { // QueryEpochInfoRequest is the response type for the Query/EpochInfo method type QueryEpochInfoResponse struct { - Epoch *Epoch `protobuf:"bytes,1,opt,name=epoch,proto3" json:"epoch,omitempty"` + Epoch *EpochResponse `protobuf:"bytes,1,opt,name=epoch,proto3" json:"epoch,omitempty"` } func (m *QueryEpochInfoResponse) Reset() { *m = QueryEpochInfoResponse{} } @@ -196,7 +200,7 @@ func (m *QueryEpochInfoResponse) XXX_DiscardUnknown() { var xxx_messageInfo_QueryEpochInfoResponse proto.InternalMessageInfo -func (m *QueryEpochInfoResponse) GetEpoch() *Epoch { +func (m *QueryEpochInfoResponse) GetEpoch() *EpochResponse { if m != nil { return m.Epoch } @@ -251,7 +255,7 @@ func (m *QueryEpochsInfoRequest) GetPagination() *query.PageRequest { // QueryEpochsInfoResponse is the response type for the Query/EpochInfos method type QueryEpochsInfoResponse struct { - Epochs []*Epoch `protobuf:"bytes,1,rep,name=epochs,proto3" json:"epochs,omitempty"` + Epochs []*EpochResponse `protobuf:"bytes,1,rep,name=epochs,proto3" json:"epochs,omitempty"` // pagination defines the pagination in the response Pagination *query.PageResponse `protobuf:"bytes,2,opt,name=pagination,proto3" json:"pagination,omitempty"` } @@ -289,7 +293,7 @@ func (m *QueryEpochsInfoResponse) XXX_DiscardUnknown() { var xxx_messageInfo_QueryEpochsInfoResponse proto.InternalMessageInfo -func (m *QueryEpochsInfoResponse) GetEpochs() []*Epoch { +func (m *QueryEpochsInfoResponse) GetEpochs() []*EpochResponse { if m != nil { return m.Epochs } @@ -456,7 +460,7 @@ func (m *QueryEpochMsgsRequest) GetPagination() *query.PageRequest { // method type QueryEpochMsgsResponse struct { // msgs is the list of messages queued in the current epoch - Msgs []*QueuedMessage `protobuf:"bytes,1,rep,name=msgs,proto3" json:"msgs,omitempty"` + Msgs []*QueuedMessageResponse `protobuf:"bytes,1,rep,name=msgs,proto3" json:"msgs,omitempty"` // pagination defines the pagination in the response Pagination *query.PageResponse `protobuf:"bytes,2,opt,name=pagination,proto3" json:"pagination,omitempty"` } @@ -494,7 +498,7 @@ func (m *QueryEpochMsgsResponse) XXX_DiscardUnknown() { var xxx_messageInfo_QueryEpochMsgsResponse proto.InternalMessageInfo -func (m *QueryEpochMsgsResponse) GetMsgs() []*QueuedMessage { +func (m *QueryEpochMsgsResponse) GetMsgs() []*QueuedMessageResponse { if m != nil { return m.Msgs } @@ -576,7 +580,7 @@ func (m *QueryLatestEpochMsgsRequest) GetPagination() *query.PageRequest { // QueryLatestEpochMsgsResponse is the response type for the // Query/LatestEpochMsgs RPC method type QueryLatestEpochMsgsResponse struct { - // epoch_msg_map is a list of QueuedMessageList + // latest_epoch_msgs is a list of QueuedMessageList // each QueuedMessageList has a field identifying the epoch number LatestEpochMsgs []*QueuedMessageList `protobuf:"bytes,1,rep,name=latest_epoch_msgs,json=latestEpochMsgs,proto3" json:"latest_epoch_msgs,omitempty"` Pagination *query.PageResponse `protobuf:"bytes,2,opt,name=pagination,proto3" json:"pagination,omitempty"` @@ -678,7 +682,8 @@ func (m *QueryValidatorLifecycleRequest) GetValAddr() string { // QueryValidatorLifecycleResponse is the response type for the // Query/ValidatorLifecycle RPC method type QueryValidatorLifecycleResponse struct { - ValLife *ValidatorLifecycle `protobuf:"bytes,1,opt,name=val_life,json=valLife,proto3" json:"val_life,omitempty"` + ValAddr string `protobuf:"bytes,1,opt,name=val_addr,json=valAddr,proto3" json:"val_addr,omitempty"` + ValLife []*ValStateUpdateResponse `protobuf:"bytes,2,rep,name=val_life,json=valLife,proto3" json:"val_life,omitempty"` } func (m *QueryValidatorLifecycleResponse) Reset() { *m = QueryValidatorLifecycleResponse{} } @@ -714,7 +719,14 @@ func (m *QueryValidatorLifecycleResponse) XXX_DiscardUnknown() { var xxx_messageInfo_QueryValidatorLifecycleResponse proto.InternalMessageInfo -func (m *QueryValidatorLifecycleResponse) GetValLife() *ValidatorLifecycle { +func (m *QueryValidatorLifecycleResponse) GetValAddr() string { + if m != nil { + return m.ValAddr + } + return "" +} + +func (m *QueryValidatorLifecycleResponse) GetValLife() []*ValStateUpdateResponse { if m != nil { return m.ValLife } @@ -929,6 +941,305 @@ func (m *QueryEpochValSetResponse) GetPagination() *query.PageResponse { return nil } +// EpochResponse is a structure that contains the metadata of an epoch +type EpochResponse struct { + // epoch_number is the number of this epoch + EpochNumber uint64 `protobuf:"varint,1,opt,name=epoch_number,json=epochNumber,proto3" json:"epoch_number,omitempty"` + // current_epoch_interval is the epoch interval at the time of this epoch + CurrentEpochInterval uint64 `protobuf:"varint,2,opt,name=current_epoch_interval,json=currentEpochInterval,proto3" json:"current_epoch_interval,omitempty"` + // first_block_height is the height of the first block in this epoch + FirstBlockHeight uint64 `protobuf:"varint,3,opt,name=first_block_height,json=firstBlockHeight,proto3" json:"first_block_height,omitempty"` + // 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. + LastBlockTime *time.Time `protobuf:"bytes,4,opt,name=last_block_time,json=lastBlockTime,proto3,stdtime" json:"last_block_time,omitempty"` + // 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. + SealerAppHashHex string `protobuf:"bytes,5,opt,name=sealer_app_hash_hex,json=sealerAppHashHex,proto3" json:"sealer_app_hash_hex,omitempty"` + // 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. + SealerBlockHash string `protobuf:"bytes,6,opt,name=sealer_block_hash,json=sealerBlockHash,proto3" json:"sealer_block_hash,omitempty"` +} + +func (m *EpochResponse) Reset() { *m = EpochResponse{} } +func (m *EpochResponse) String() string { return proto.CompactTextString(m) } +func (*EpochResponse) ProtoMessage() {} +func (*EpochResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_1821b530f2ec2711, []int{18} +} +func (m *EpochResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *EpochResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_EpochResponse.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 *EpochResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_EpochResponse.Merge(m, src) +} +func (m *EpochResponse) XXX_Size() int { + return m.Size() +} +func (m *EpochResponse) XXX_DiscardUnknown() { + xxx_messageInfo_EpochResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_EpochResponse proto.InternalMessageInfo + +func (m *EpochResponse) GetEpochNumber() uint64 { + if m != nil { + return m.EpochNumber + } + return 0 +} + +func (m *EpochResponse) GetCurrentEpochInterval() uint64 { + if m != nil { + return m.CurrentEpochInterval + } + return 0 +} + +func (m *EpochResponse) GetFirstBlockHeight() uint64 { + if m != nil { + return m.FirstBlockHeight + } + return 0 +} + +func (m *EpochResponse) GetLastBlockTime() *time.Time { + if m != nil { + return m.LastBlockTime + } + return nil +} + +func (m *EpochResponse) GetSealerAppHashHex() string { + if m != nil { + return m.SealerAppHashHex + } + return "" +} + +func (m *EpochResponse) GetSealerBlockHash() string { + if m != nil { + return m.SealerBlockHash + } + return "" +} + +// QueuedMessageResponse is a message that can change the validator set and is delayed +// to the end of an epoch +type QueuedMessageResponse struct { + // tx_id is the ID of the tx that contains the message as hex. + TxId string `protobuf:"bytes,1,opt,name=tx_id,json=txId,proto3" json:"tx_id,omitempty"` + // msg_id is the original message ID, i.e., hash of the marshaled message as hex. + MsgId string `protobuf:"bytes,2,opt,name=msg_id,json=msgId,proto3" json:"msg_id,omitempty"` + // block_height is the height when this msg is submitted to Babylon + BlockHeight uint64 `protobuf:"varint,3,opt,name=block_height,json=blockHeight,proto3" json:"block_height,omitempty"` + // block_time is the timestamp when this msg is submitted to Babylon + BlockTime *time.Time `protobuf:"bytes,4,opt,name=block_time,json=blockTime,proto3,stdtime" json:"block_time,omitempty"` + // msg is the actual message that is sent by a user and is queued by the + // epoching module as string. + Msg string `protobuf:"bytes,5,opt,name=msg,proto3" json:"msg,omitempty"` +} + +func (m *QueuedMessageResponse) Reset() { *m = QueuedMessageResponse{} } +func (m *QueuedMessageResponse) String() string { return proto.CompactTextString(m) } +func (*QueuedMessageResponse) ProtoMessage() {} +func (*QueuedMessageResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_1821b530f2ec2711, []int{19} +} +func (m *QueuedMessageResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueuedMessageResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueuedMessageResponse.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 *QueuedMessageResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueuedMessageResponse.Merge(m, src) +} +func (m *QueuedMessageResponse) XXX_Size() int { + return m.Size() +} +func (m *QueuedMessageResponse) XXX_DiscardUnknown() { + xxx_messageInfo_QueuedMessageResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_QueuedMessageResponse proto.InternalMessageInfo + +func (m *QueuedMessageResponse) GetTxId() string { + if m != nil { + return m.TxId + } + return "" +} + +func (m *QueuedMessageResponse) GetMsgId() string { + if m != nil { + return m.MsgId + } + return "" +} + +func (m *QueuedMessageResponse) GetBlockHeight() uint64 { + if m != nil { + return m.BlockHeight + } + return 0 +} + +func (m *QueuedMessageResponse) GetBlockTime() *time.Time { + if m != nil { + return m.BlockTime + } + return nil +} + +func (m *QueuedMessageResponse) GetMsg() string { + if m != nil { + return m.Msg + } + return "" +} + +// QueuedMessageList is a message that contains a list of staking-related +// messages queued for an epoch +type QueuedMessageList struct { + EpochNumber uint64 `protobuf:"varint,1,opt,name=epoch_number,json=epochNumber,proto3" json:"epoch_number,omitempty"` + Msgs []*QueuedMessageResponse `protobuf:"bytes,2,rep,name=msgs,proto3" json:"msgs,omitempty"` +} + +func (m *QueuedMessageList) Reset() { *m = QueuedMessageList{} } +func (m *QueuedMessageList) String() string { return proto.CompactTextString(m) } +func (*QueuedMessageList) ProtoMessage() {} +func (*QueuedMessageList) Descriptor() ([]byte, []int) { + return fileDescriptor_1821b530f2ec2711, []int{20} +} +func (m *QueuedMessageList) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueuedMessageList) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueuedMessageList.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 *QueuedMessageList) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueuedMessageList.Merge(m, src) +} +func (m *QueuedMessageList) XXX_Size() int { + return m.Size() +} +func (m *QueuedMessageList) XXX_DiscardUnknown() { + xxx_messageInfo_QueuedMessageList.DiscardUnknown(m) +} + +var xxx_messageInfo_QueuedMessageList proto.InternalMessageInfo + +func (m *QueuedMessageList) GetEpochNumber() uint64 { + if m != nil { + return m.EpochNumber + } + return 0 +} + +func (m *QueuedMessageList) GetMsgs() []*QueuedMessageResponse { + if m != nil { + return m.Msgs + } + return nil +} + +// ValStateUpdateResponse is a message response that records a state update of a validator. +type ValStateUpdateResponse struct { + // StateDesc defines the descriptive state. + StateDesc string `protobuf:"bytes,1,opt,name=state_desc,json=stateDesc,proto3" json:"state_desc,omitempty"` + BlockHeight uint64 `protobuf:"varint,2,opt,name=block_height,json=blockHeight,proto3" json:"block_height,omitempty"` + BlockTime *time.Time `protobuf:"bytes,3,opt,name=block_time,json=blockTime,proto3,stdtime" json:"block_time,omitempty"` +} + +func (m *ValStateUpdateResponse) Reset() { *m = ValStateUpdateResponse{} } +func (m *ValStateUpdateResponse) String() string { return proto.CompactTextString(m) } +func (*ValStateUpdateResponse) ProtoMessage() {} +func (*ValStateUpdateResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_1821b530f2ec2711, []int{21} +} +func (m *ValStateUpdateResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *ValStateUpdateResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_ValStateUpdateResponse.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 *ValStateUpdateResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_ValStateUpdateResponse.Merge(m, src) +} +func (m *ValStateUpdateResponse) XXX_Size() int { + return m.Size() +} +func (m *ValStateUpdateResponse) XXX_DiscardUnknown() { + xxx_messageInfo_ValStateUpdateResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_ValStateUpdateResponse proto.InternalMessageInfo + +func (m *ValStateUpdateResponse) GetStateDesc() string { + if m != nil { + return m.StateDesc + } + return "" +} + +func (m *ValStateUpdateResponse) GetBlockHeight() uint64 { + if m != nil { + return m.BlockHeight + } + return 0 +} + +func (m *ValStateUpdateResponse) GetBlockTime() *time.Time { + if m != nil { + return m.BlockTime + } + return nil +} + func init() { proto.RegisterType((*QueryParamsRequest)(nil), "babylon.epoching.v1.QueryParamsRequest") proto.RegisterType((*QueryParamsResponse)(nil), "babylon.epoching.v1.QueryParamsResponse") @@ -948,79 +1259,103 @@ func init() { proto.RegisterType((*QueryDelegationLifecycleResponse)(nil), "babylon.epoching.v1.QueryDelegationLifecycleResponse") proto.RegisterType((*QueryEpochValSetRequest)(nil), "babylon.epoching.v1.QueryEpochValSetRequest") proto.RegisterType((*QueryEpochValSetResponse)(nil), "babylon.epoching.v1.QueryEpochValSetResponse") + proto.RegisterType((*EpochResponse)(nil), "babylon.epoching.v1.EpochResponse") + proto.RegisterType((*QueuedMessageResponse)(nil), "babylon.epoching.v1.QueuedMessageResponse") + proto.RegisterType((*QueuedMessageList)(nil), "babylon.epoching.v1.QueuedMessageList") + proto.RegisterType((*ValStateUpdateResponse)(nil), "babylon.epoching.v1.ValStateUpdateResponse") } func init() { proto.RegisterFile("babylon/epoching/v1/query.proto", fileDescriptor_1821b530f2ec2711) } var fileDescriptor_1821b530f2ec2711 = []byte{ - // 1071 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff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 0xdf, 0x24, 0x6b, 0x4a, 0xec, 0xce, 0x12, 0xc3, - 0xf5, 0x8e, 0x9e, 0xd6, 0xe3, 0x4c, 0xd1, 0xf6, 0xc9, 0xef, 0x1a, 0x4c, 0x2b, 0xd6, 0x3a, 0x39, - 0x06, 0xa5, 0x58, 0x87, 0xf4, 0x9b, 0x27, 0xf4, 0x92, 0x15, 0xdc, 0xc3, 0x0a, 0x6e, 0x91, 0x75, - 0x65, 0x05, 0x4e, 0xc7, 0x33, 0x5f, 0x42, 0xa6, 0x77, 0xfb, 0xe9, 0x7b, 0x99, 0xca, 0xed, 0x7c, - 0x32, 0xe8, 0x8b, 0xee, 0xd1, 0x26, 0x7d, 0x79, 0x48, 0x6b, 0x89, 0xfa, 0x0e, 0xa2, 0xde, 0x26, - 0x6f, 0x0e, 0xff, 0xb0, 0xbb, 0x13, 0x88, 0x58, 0xbc, 0x71, 0xff, 0xe9, 0x61, 0x59, 0x3b, 0x38, - 0x2c, 0x6b, 0xff, 0x1c, 0x96, 0xb5, 0xef, 0x8e, 0xca, 0x23, 0x07, 0x47, 0xe5, 0x91, 0xbf, 0x8e, - 0xca, 0x23, 0x9f, 0xae, 0xb8, 0x5e, 0xbc, 0x97, 0xd4, 0xcc, 0x3a, 0x6f, 0x64, 0xc1, 0xeb, 0x7b, - 0xd4, 0x0b, 0x3a, 0x99, 0xbe, 0xe8, 0xe6, 0x8a, 0xdb, 0x4d, 0x16, 0xd5, 0xc6, 0xf1, 0x8f, 0xb5, - 0xb5, 0xff, 0x02, 0x00, 0x00, 0xff, 0xff, 0x76, 0x01, 0x0c, 0x73, 0x8a, 0x0e, 0x00, 0x00, + // 1381 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xbc, 0x56, 0x4d, 0x6f, 0xdc, 0x44, + 0x18, 0x8e, 0x37, 0x9b, 0xd0, 0xbc, 0x69, 0x48, 0x3a, 0x69, 0x4b, 0xba, 0x69, 0x37, 0xc5, 0x85, + 0xb6, 0x24, 0x8d, 0xcd, 0x26, 0x29, 0xd0, 0x0f, 0xa8, 0x9a, 0x96, 0x92, 0x48, 0x29, 0x4a, 0x0d, + 0xf4, 0xc0, 0xc5, 0x8c, 0xd7, 0x13, 0xaf, 0x85, 0xbf, 0xea, 0x99, 0x5d, 0x12, 0x95, 0x22, 0x84, + 0x38, 0x72, 0xa8, 0xc4, 0x01, 0x21, 0x24, 0x04, 0xe2, 0xc8, 0x2f, 0x40, 0xe5, 0xc0, 0xb1, 0xc7, + 0x22, 0x2e, 0x9c, 0x00, 0xb5, 0xfc, 0x10, 0xe4, 0x99, 0xf1, 0xae, 0x77, 0x63, 0x77, 0x37, 0x51, + 0xc5, 0x6d, 0xf7, 0xfd, 0x7c, 0xde, 0xe7, 0x9d, 0x19, 0x3f, 0x30, 0x67, 0x61, 0x6b, 0xc7, 0x0b, + 0x03, 0x9d, 0x44, 0x61, 0xbd, 0xe1, 0x06, 0x8e, 0xde, 0xaa, 0xe9, 0x77, 0x9a, 0x24, 0xde, 0xd1, + 0xa2, 0x38, 0x64, 0x21, 0x9a, 0x96, 0x01, 0x5a, 0x1a, 0xa0, 0xb5, 0x6a, 0x95, 0xc3, 0x4e, 0xe8, + 0x84, 0xdc, 0xaf, 0x27, 0xbf, 0x44, 0x68, 0x65, 0xce, 0x09, 0x43, 0xc7, 0x23, 0x3a, 0xff, 0x67, + 0x35, 0xb7, 0x74, 0xe6, 0xfa, 0x84, 0x32, 0xec, 0x47, 0x32, 0xe0, 0xb8, 0x0c, 0xc0, 0x91, 0xab, + 0xe3, 0x20, 0x08, 0x19, 0x66, 0x6e, 0x18, 0x50, 0xe9, 0x9d, 0xaf, 0x87, 0xd4, 0x0f, 0xa9, 0x6e, + 0x61, 0x4a, 0x04, 0x04, 0xbd, 0x55, 0xb3, 0x08, 0xc3, 0x35, 0x3d, 0xc2, 0x8e, 0x1b, 0xf0, 0x60, + 0x19, 0x7b, 0x32, 0x0f, 0x76, 0x84, 0x63, 0xec, 0xa7, 0xd5, 0xd4, 0xbc, 0x88, 0xf6, 0x0c, 0x3c, + 0x46, 0x3d, 0x0c, 0xe8, 0x56, 0xd2, 0x67, 0x93, 0x27, 0x1a, 0xe4, 0x4e, 0x93, 0x50, 0xa6, 0x6e, + 0xc2, 0x74, 0x97, 0x95, 0x46, 0x61, 0x40, 0x09, 0xba, 0x00, 0xa3, 0xa2, 0xc1, 0x8c, 0x72, 0x52, + 0x39, 0x3b, 0xbe, 0x34, 0xab, 0xe5, 0x30, 0xa3, 0x89, 0xa4, 0xd5, 0xf2, 0xc3, 0xbf, 0xe6, 0x86, + 0x0c, 0x99, 0xa0, 0xae, 0xc0, 0x11, 0x5e, 0xf1, 0xed, 0x24, 0x70, 0x3d, 0xd8, 0x0a, 0x65, 0x2b, + 0x34, 0x0b, 0x63, 0x3c, 0xd9, 0x0c, 0x9a, 0x3e, 0x2f, 0x5b, 0x36, 0x0e, 0x70, 0xc3, 0xbb, 0x4d, + 0x5f, 0x35, 0xe0, 0x68, 0x6f, 0x96, 0x84, 0xf2, 0x06, 0x8c, 0xf0, 0x28, 0x89, 0x44, 0xcd, 0x45, + 0xc2, 0xd3, 0xd2, 0x14, 0x43, 0x24, 0xa8, 0x1f, 0x65, 0x6b, 0xd2, 0x2c, 0x94, 0x1b, 0x00, 0x1d, + 0x96, 0x65, 0xe1, 0xd3, 0x9a, 0x58, 0x89, 0x96, 0xac, 0x44, 0x13, 0xa7, 0x42, 0xae, 0x44, 0xdb, + 0xc4, 0x0e, 0x91, 0xb9, 0x46, 0x26, 0x53, 0xfd, 0x5e, 0x81, 0x17, 0x76, 0xb5, 0x90, 0xb8, 0x2f, + 0xc2, 0x28, 0x87, 0x91, 0x50, 0x38, 0x3c, 0x20, 0x70, 0x99, 0x81, 0xde, 0xe9, 0xc2, 0x57, 0xe2, + 0xf8, 0xce, 0xf4, 0xc5, 0x27, 0x8b, 0x64, 0x01, 0x56, 0x60, 0x86, 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0xc1, 0x0f, 0x76, 0x67, 0x03, 0x94, 0xb0, 0xd5, 0x8d, + 0x87, 0x8f, 0xab, 0xca, 0xa3, 0xc7, 0x55, 0xe5, 0x9f, 0xc7, 0x55, 0xe5, 0xfe, 0x93, 0xea, 0xd0, + 0xa3, 0x27, 0xd5, 0xa1, 0x3f, 0x9f, 0x54, 0x87, 0x3e, 0x5c, 0x72, 0x5c, 0xd6, 0x68, 0x5a, 0x5a, + 0x3d, 0xf4, 0xd3, 0xe2, 0x1e, 0xb6, 0xe8, 0xa2, 0x1b, 0xb6, 0x7b, 0x6d, 0x77, 0xba, 0xb1, 0x9d, + 0x88, 0x50, 0x6b, 0x94, 0x7f, 0x45, 0x96, 0xff, 0x0b, 0x00, 0x00, 0xff, 0xff, 0x29, 0x2d, 0xf8, + 0x0c, 0xf5, 0x11, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -1907,15 +2242,24 @@ func (m *QueryValidatorLifecycleResponse) MarshalToSizedBuffer(dAtA []byte) (int _ = i var l int _ = l - if m.ValLife != nil { - { - size, err := m.ValLife.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err + if len(m.ValLife) > 0 { + for iNdEx := len(m.ValLife) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.ValLife[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] = 0x12 } + } + if len(m.ValAddr) > 0 { + i -= len(m.ValAddr) + copy(dAtA[i:], m.ValAddr) + i = encodeVarintQuery(dAtA, i, uint64(len(m.ValAddr))) i-- dAtA[i] = 0xa } @@ -2081,60 +2425,268 @@ func (m *QueryEpochValSetResponse) MarshalToSizedBuffer(dAtA []byte) (int, error 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 +func (m *EpochResponse) 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 l int - _ = l - return n + return dAtA[:n], nil } -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 *EpochResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *QueryEpochInfoRequest) Size() (n int) { - if m == nil { - return 0 - } +func (m *EpochResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i var l int _ = l - if m.EpochNum != 0 { - n += 1 + sovQuery(uint64(m.EpochNum)) + if len(m.SealerBlockHash) > 0 { + i -= len(m.SealerBlockHash) + copy(dAtA[i:], m.SealerBlockHash) + i = encodeVarintQuery(dAtA, i, uint64(len(m.SealerBlockHash))) + i-- + dAtA[i] = 0x32 } - return n + if len(m.SealerAppHashHex) > 0 { + i -= len(m.SealerAppHashHex) + copy(dAtA[i:], m.SealerAppHashHex) + i = encodeVarintQuery(dAtA, i, uint64(len(m.SealerAppHashHex))) + i-- + dAtA[i] = 0x2a + } + if m.LastBlockTime != nil { + n12, err12 := github_com_cosmos_gogoproto_types.StdTimeMarshalTo(*m.LastBlockTime, dAtA[i-github_com_cosmos_gogoproto_types.SizeOfStdTime(*m.LastBlockTime):]) + if err12 != nil { + return 0, err12 + } + i -= n12 + i = encodeVarintQuery(dAtA, i, uint64(n12)) + i-- + dAtA[i] = 0x22 + } + if m.FirstBlockHeight != 0 { + i = encodeVarintQuery(dAtA, i, uint64(m.FirstBlockHeight)) + i-- + dAtA[i] = 0x18 + } + if m.CurrentEpochInterval != 0 { + i = encodeVarintQuery(dAtA, i, uint64(m.CurrentEpochInterval)) + i-- + dAtA[i] = 0x10 + } + if m.EpochNumber != 0 { + i = encodeVarintQuery(dAtA, i, uint64(m.EpochNumber)) + i-- + dAtA[i] = 0x8 + } + return len(dAtA) - i, nil } -func (m *QueryEpochInfoResponse) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if m.Epoch != nil { - l = m.Epoch.Size() - n += 1 + l + sovQuery(uint64(l)) +func (m *QueuedMessageResponse) 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 *QueuedMessageResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueuedMessageResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Msg) > 0 { + i -= len(m.Msg) + copy(dAtA[i:], m.Msg) + i = encodeVarintQuery(dAtA, i, uint64(len(m.Msg))) + i-- + dAtA[i] = 0x2a + } + if m.BlockTime != nil { + n13, err13 := github_com_cosmos_gogoproto_types.StdTimeMarshalTo(*m.BlockTime, dAtA[i-github_com_cosmos_gogoproto_types.SizeOfStdTime(*m.BlockTime):]) + if err13 != nil { + return 0, err13 + } + i -= n13 + i = encodeVarintQuery(dAtA, i, uint64(n13)) + i-- + dAtA[i] = 0x22 + } + if m.BlockHeight != 0 { + i = encodeVarintQuery(dAtA, i, uint64(m.BlockHeight)) + i-- + dAtA[i] = 0x18 + } + if len(m.MsgId) > 0 { + i -= len(m.MsgId) + copy(dAtA[i:], m.MsgId) + i = encodeVarintQuery(dAtA, i, uint64(len(m.MsgId))) + i-- + dAtA[i] = 0x12 + } + if len(m.TxId) > 0 { + i -= len(m.TxId) + copy(dAtA[i:], m.TxId) + i = encodeVarintQuery(dAtA, i, uint64(len(m.TxId))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *QueuedMessageList) 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 *QueuedMessageList) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueuedMessageList) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Msgs) > 0 { + for iNdEx := len(m.Msgs) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.Msgs[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + } + } + if m.EpochNumber != 0 { + i = encodeVarintQuery(dAtA, i, uint64(m.EpochNumber)) + i-- + dAtA[i] = 0x8 + } + return len(dAtA) - i, nil +} + +func (m *ValStateUpdateResponse) 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 *ValStateUpdateResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *ValStateUpdateResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.BlockTime != nil { + n14, err14 := github_com_cosmos_gogoproto_types.StdTimeMarshalTo(*m.BlockTime, dAtA[i-github_com_cosmos_gogoproto_types.SizeOfStdTime(*m.BlockTime):]) + if err14 != nil { + return 0, err14 + } + i -= n14 + i = encodeVarintQuery(dAtA, i, uint64(n14)) + i-- + dAtA[i] = 0x1a + } + if m.BlockHeight != 0 { + i = encodeVarintQuery(dAtA, i, uint64(m.BlockHeight)) + i-- + dAtA[i] = 0x10 + } + if len(m.StateDesc) > 0 { + i -= len(m.StateDesc) + copy(dAtA[i:], m.StateDesc) + i = encodeVarintQuery(dAtA, i, uint64(len(m.StateDesc))) + 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 *QueryEpochInfoRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.EpochNum != 0 { + n += 1 + sovQuery(uint64(m.EpochNum)) + } + return n +} + +func (m *QueryEpochInfoResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.Epoch != nil { + l = m.Epoch.Size() + n += 1 + l + sovQuery(uint64(l)) + } + return n } func (m *QueryEpochsInfoRequest) Size() (n int) { @@ -2285,10 +2837,16 @@ func (m *QueryValidatorLifecycleResponse) Size() (n int) { } var l int _ = l - if m.ValLife != nil { - l = m.ValLife.Size() + l = len(m.ValAddr) + if l > 0 { n += 1 + l + sovQuery(uint64(l)) } + if len(m.ValLife) > 0 { + for _, e := range m.ValLife { + l = e.Size() + n += 1 + l + sovQuery(uint64(l)) + } + } return n } @@ -2356,6 +2914,102 @@ func (m *QueryEpochValSetResponse) Size() (n int) { return n } +func (m *EpochResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.EpochNumber != 0 { + n += 1 + sovQuery(uint64(m.EpochNumber)) + } + if m.CurrentEpochInterval != 0 { + n += 1 + sovQuery(uint64(m.CurrentEpochInterval)) + } + if m.FirstBlockHeight != 0 { + n += 1 + sovQuery(uint64(m.FirstBlockHeight)) + } + if m.LastBlockTime != nil { + l = github_com_cosmos_gogoproto_types.SizeOfStdTime(*m.LastBlockTime) + n += 1 + l + sovQuery(uint64(l)) + } + l = len(m.SealerAppHashHex) + if l > 0 { + n += 1 + l + sovQuery(uint64(l)) + } + l = len(m.SealerBlockHash) + if l > 0 { + n += 1 + l + sovQuery(uint64(l)) + } + return n +} + +func (m *QueuedMessageResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.TxId) + if l > 0 { + n += 1 + l + sovQuery(uint64(l)) + } + l = len(m.MsgId) + if l > 0 { + n += 1 + l + sovQuery(uint64(l)) + } + if m.BlockHeight != 0 { + n += 1 + sovQuery(uint64(m.BlockHeight)) + } + if m.BlockTime != nil { + l = github_com_cosmos_gogoproto_types.SizeOfStdTime(*m.BlockTime) + n += 1 + l + sovQuery(uint64(l)) + } + l = len(m.Msg) + if l > 0 { + n += 1 + l + sovQuery(uint64(l)) + } + return n +} + +func (m *QueuedMessageList) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.EpochNumber != 0 { + n += 1 + sovQuery(uint64(m.EpochNumber)) + } + if len(m.Msgs) > 0 { + for _, e := range m.Msgs { + l = e.Size() + n += 1 + l + sovQuery(uint64(l)) + } + } + return n +} + +func (m *ValStateUpdateResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.StateDesc) + if l > 0 { + n += 1 + l + sovQuery(uint64(l)) + } + if m.BlockHeight != 0 { + n += 1 + sovQuery(uint64(m.BlockHeight)) + } + if m.BlockTime != nil { + l = github_com_cosmos_gogoproto_types.SizeOfStdTime(*m.BlockTime) + n += 1 + l + sovQuery(uint64(l)) + } + return n +} + func sovQuery(x uint64) (n int) { return (math_bits.Len64(x|1) + 6) / 7 } @@ -2623,7 +3277,7 @@ func (m *QueryEpochInfoResponse) Unmarshal(dAtA []byte) error { return io.ErrUnexpectedEOF } if m.Epoch == nil { - m.Epoch = &Epoch{} + m.Epoch = &EpochResponse{} } if err := m.Epoch.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err @@ -2794,7 +3448,7 @@ func (m *QueryEpochsInfoResponse) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.Epochs = append(m.Epochs, &Epoch{}) + m.Epochs = append(m.Epochs, &EpochResponse{}) if err := m.Epochs[len(m.Epochs)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } @@ -3157,7 +3811,7 @@ func (m *QueryEpochMsgsResponse) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.Msgs = append(m.Msgs, &QueuedMessage{}) + m.Msgs = append(m.Msgs, &QueuedMessageResponse{}) if err := m.Msgs[len(m.Msgs)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } @@ -3575,6 +4229,38 @@ func (m *QueryValidatorLifecycleResponse) Unmarshal(dAtA []byte) error { } switch fieldNum { case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ValAddr", 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.ValAddr = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field ValLife", wireType) } @@ -3603,10 +4289,8 @@ func (m *QueryValidatorLifecycleResponse) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - if m.ValLife == nil { - m.ValLife = &ValidatorLifecycle{} - } - if err := m.ValLife.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + m.ValLife = append(m.ValLife, &ValStateUpdateResponse{}) + if err := m.ValLife[len(m.ValLife)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } iNdEx = postIndex @@ -4043,6 +4727,654 @@ func (m *QueryEpochValSetResponse) Unmarshal(dAtA []byte) error { } return nil } +func (m *EpochResponse) 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: EpochResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: EpochResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field EpochNumber", wireType) + } + m.EpochNumber = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.EpochNumber |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 2: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field CurrentEpochInterval", wireType) + } + m.CurrentEpochInterval = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.CurrentEpochInterval |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 3: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field FirstBlockHeight", wireType) + } + m.FirstBlockHeight = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.FirstBlockHeight |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field LastBlockTime", 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.LastBlockTime == nil { + m.LastBlockTime = new(time.Time) + } + if err := github_com_cosmos_gogoproto_types.StdTimeUnmarshal(m.LastBlockTime, dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 5: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field SealerAppHashHex", 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.SealerAppHashHex = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 6: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field SealerBlockHash", 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.SealerBlockHash = 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 *QueuedMessageResponse) 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: QueuedMessageResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueuedMessageResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field TxId", 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.TxId = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field MsgId", 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.MsgId = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 3: + 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 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field BlockTime", 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.BlockTime == nil { + m.BlockTime = new(time.Time) + } + if err := github_com_cosmos_gogoproto_types.StdTimeUnmarshal(m.BlockTime, dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 5: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Msg", 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.Msg = 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 *QueuedMessageList) 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: QueuedMessageList: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueuedMessageList: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field EpochNumber", wireType) + } + m.EpochNumber = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.EpochNumber |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Msgs", 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.Msgs = append(m.Msgs, &QueuedMessageResponse{}) + if err := m.Msgs[len(m.Msgs)-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 *ValStateUpdateResponse) 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: ValStateUpdateResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: ValStateUpdateResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field StateDesc", 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.StateDesc = 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 BlockTime", 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.BlockTime == nil { + m.BlockTime = new(time.Time) + } + if err := github_com_cosmos_gogoproto_types.StdTimeUnmarshal(m.BlockTime, 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 diff --git a/x/epoching/types/tx.pb.go b/x/epoching/types/tx.pb.go index fd16d4af4..71db40e2d 100644 --- a/x/epoching/types/tx.pb.go +++ b/x/epoching/types/tx.pb.go @@ -453,44 +453,44 @@ func init() { func init() { proto.RegisterFile("babylon/epoching/v1/tx.proto", fileDescriptor_a5fc8fed8f4e58b6) } var fileDescriptor_a5fc8fed8f4e58b6 = []byte{ - // 585 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x9c, 0x94, 0x4f, 0x6f, 0x12, 0x41, - 0x18, 0xc6, 0x77, 0x6d, 0x6d, 0xd2, 0x57, 0x63, 0x75, 0x25, 0x16, 0x56, 0xb2, 0x20, 0x68, 0x54, - 0xb4, 0xbb, 0x52, 0xb5, 0x6a, 0xe3, 0x41, 0xd1, 0x78, 0x30, 0x21, 0x31, 0x98, 0xc6, 0xc4, 0xc4, - 0x98, 0x59, 0x76, 0x32, 0x6c, 0x60, 0x67, 0xd6, 0x9d, 0x69, 0x53, 0x4e, 0x36, 0x9e, 0x3c, 0x7a, - 0xf0, 0x6c, 0xfa, 0x11, 0x7a, 0xf0, 0x43, 0xf4, 0xd8, 0x78, 0xf2, 0x64, 0x0c, 0x1c, 0xea, 0x07, - 0xf0, 0x03, 0x18, 0xf6, 0x2f, 0x02, 0x0b, 0xe8, 0x8d, 0xe1, 0x7d, 0xde, 0xe7, 0xf9, 0xc1, 0x3e, - 0x3b, 0x90, 0x37, 0x91, 0xd9, 0xed, 0x30, 0x6a, 0x60, 0x97, 0x35, 0x5b, 0x36, 0x25, 0xc6, 0x4e, - 0xd5, 0x10, 0xbb, 0xba, 0xeb, 0x31, 0xc1,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0xf2, 0xfd, 0x19, 0xe6, 0xa9, 0x9b, 0xea, 0xa3, 0xff, 0xdd, 0x8c, 0x01, 0x4d, - 0x38, 0xfd, 0x57, 0x73, 0x2f, 0xa7, 0x39, 0x0e, 0xab, 0xd4, 0x9b, 0xf3, 0xa8, 0xa2, 0x0c, 0xf5, - 0xe4, 0xde, 0xf1, 0x41, 0x45, 0xae, 0x3d, 0x3f, 0xec, 0x69, 0xf2, 0x51, 0x4f, 0x93, 0x7f, 0xf6, - 0x34, 0xf9, 0x53, 0x5f, 0x93, 0x8e, 0xfa, 0x9a, 0xf4, 0xbd, 0xaf, 0x49, 0xaf, 0x6f, 0x11, 0x5b, - 0xb4, 0xb6, 0x4d, 0xbd, 0xc9, 0x1c, 0x23, 0x34, 0x6e, 0xb6, 0x90, 0x4d, 0xa3, 0x83, 0xb1, 0x9b, - 0x5c, 0xfa, 0xa2, 0xeb, 0x62, 0x6e, 0x2e, 0xf9, 0xb7, 0xf7, 0xed, 0x3f, 0x01, 0x00, 0x00, 0xff, - 0xff, 0xdf, 0xdb, 0xcd, 0x7f, 0x7f, 0x06, 0x00, 0x00, + // 586 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x9c, 0x94, 0xc1, 0x8e, 0xd2, 0x40, + 0x1c, 0xc6, 0x5b, 0x77, 0xdd, 0x64, 0x47, 0xe3, 0x6a, 0x25, 0x2e, 0x54, 0x52, 0x10, 0x34, 0x2a, + 0x4a, 0x1b, 0x50, 0x57, 0xdd, 0x78, 0x50, 0x34, 0x9e, 0x24, 0x31, 0x98, 0x8d, 0x89, 0x89, 0x31, + 0x53, 0x3a, 0x19, 0x1a, 0xe8, 0x4c, 0xed, 0xcc, 0x6e, 0x96, 0x93, 0x1b, 0x4f, 0x1e, 0x3d, 0x78, + 0x36, 0xfb, 0x08, 0x7b, 0xf0, 0x21, 0xf6, 0xb8, 0xf1, 0xe4, 0xc9, 0x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x6a, 0x2c, 0x28, 0x8c, 0x42, 0x95, 0xf7, 0xe0, + 0xc2, 0x64, 0xd1, 0x6f, 0xce, 0x71, 0x49, 0xa4, 0x6a, 0x6d, 0x61, 0x69, 0x1c, 0xb9, 0x27, 0x83, + 0x4b, 0x29, 0xcd, 0xd6, 0xe7, 0xb8, 0x8d, 0xe9, 0xd5, 0x8d, 0xff, 0xd3, 0xc7, 0x08, 0x5f, 0x65, + 0x50, 0x9c, 0x5b, 0xe5, 0x07, 0x73, 0xcc, 0x53, 0x37, 0xd5, 0xc7, 0x27, 0xdd, 0x8c, 0x01, 0x4d, + 0x70, 0xf6, 0x9f, 0xe6, 0x5e, 0x4d, 0x73, 0x1c, 0x55, 0xa9, 0xb7, 0x17, 0x51, 0x45, 0x19, 0xea, + 0xe9, 0xbd, 0xe3, 0x83, 0x8a, 0xdc, 0x78, 0x71, 0x38, 0xd0, 0xe4, 0xa3, 0x81, 0x26, 0xff, 0x1a, + 0x68, 0xf2, 0xe7, 0xa1, 0x26, 0x1d, 0x0d, 0x35, 0xe9, 0xc7, 0x50, 0x93, 0xde, 0xd4, 0xb1, 0xcd, + 0x3b, 0xdb, 0xa6, 0xde, 0xa6, 0x8e, 0x21, 0x8c, 0x7b, 0xd0, 0x64, 0x55, 0x9b, 0x46, 0x47, 0x63, + 0x37, 0xb9, 0xf6, 0x79, 0xdf, 0x45, 0xcc, 0x5c, 0x09, 0xee, 0xef, 0x3b, 0x7f, 0x03, 0x00, 0x00, + 0xff, 0xff, 0xdc, 0x26, 0x42, 0x47, 0x81, 0x06, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. diff --git a/x/epoching/types/validator_test.go b/x/epoching/types/validator_test.go index d885c0d32..ba6468dc9 100644 --- a/x/epoching/types/validator_test.go +++ b/x/epoching/types/validator_test.go @@ -3,7 +3,7 @@ package types_test import ( "testing" - "github.com/babylonchain/babylon/testutil/datagen" + "github.com/babylonlabs-io/babylon/testutil/datagen" "github.com/stretchr/testify/require" ) diff --git a/x/finality/README.md b/x/finality/README.md index b0bd37c2c..aae159c08 100644 --- a/x/finality/README.md +++ b/x/finality/README.md @@ -9,10 +9,9 @@ The Finality module is responsible for handling finality votes, maintaining the finalization status of blocks, and identifying equivocating finality providers in the finalization rounds. This includes: -- handling requests for committing EOTS public randomness from finality - providers; - handling requests for submitting finality votes from finality providers; -- maintaining the finalization status of blocks; and +- maintaining the finalization status of blocks; +- identifying sluggish finality providers; and - maintaining equivocation evidences of culpable finality providers. ## Table of contents @@ -20,13 +19,10 @@ in the finalization rounds. This includes: - [Table of contents](#table-of-contents) - [Concepts](#concepts) - [States](#states) - - [Parameters](#parameters) - - [Public randomness](#public-randomness) - [Finality votes](#finality-votes) - [Indexed blocks with finalization status](#indexed-blocks-with-finalization-status) - [Equivocation evidences](#equivocation-evidences) - [Messages](#messages) - - [MsgCommitPubRandList](#msgcommitpubrandlist) - [MsgAddFinalitySig](#msgaddfinalitysig) - [MsgUpdateParams](#msgupdateparams) - [EndBlocker](#endblocker) @@ -79,17 +75,21 @@ adversarial finality providers. **Interaction between finality providers and the Finality module.** In order to 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 the Finality module as follows: - -- **Committing EOTS public randomness.** The finality provider proactively - commits 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. -- **Submitting EOTS signatures.** Upon a new block, if the finality provider has - committed an EOTS public randomness at this height, then it submits an EOTS - signature w.r.t. the committed EOTS public randomness to the Finality module. +needs to interact with Babylon as follows: + +- **Committing EOTS master public randomness.** The finality provider needs to + generate a pair of EOTS master secret/public randomness, and commit the master + public randomness when registering itself to Babylon. The EOTS master + secret/public randomness allows to derive a EOTS secret/public randomness + deterministically for each given height, respectively. Babylon further + requires the epoch of the finality provider registration to be finalized by + BTC timestamping before the registered finality provider can submit finality + signatures. This ensures that each finality provider has a unique public + randomness for each height, and that if the finality provider submits two + finality signatures over two conflicting blocks, anyone can extract the + finality provider's secret key using EOTS. +- **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 known EOTS signatures on conflicting blocks from this finality provider. If yes, then this constitutes an equivocation, and the Finality module will save @@ -106,39 +106,6 @@ transactions to the Bitcoin network. The Finality module maintains the following KV stores. -### Parameters - -The [parameter storage](./keeper/params.go) maintains the Finality module's -parameters. The Finality module's parameters are represented as a `Params` -[object](../../proto/babylon/finality/v1/params.proto) defined as follows: - -```protobuf -// Params defines the parameters for the module. -message Params { - option (gogoproto.goproto_stringer) = false; - - // min_pub_rand is the minimum number of public randomness each - // message should commit - uint64 min_pub_rand = 1; -} -``` - -### Public randomness - -The [public randomness storage](./keeper/public_randomness.go) maintains the -list of EOTS public randomness 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 `SchnorrPubRand` -[object](../../types/btc_schnorr_pub_rand.go) representing the EOTS public -randomness that this finality provider commits at this height. The -`SchnorrPubRand` is a point on the secp256k1 curve, and is defined as a 32-byte -array in the implementation. - -```go -type SchnorrPubRand []byte -const SchnorrPubRandLen = 32 -``` - ### Finality votes The [finality vote storage](./keeper/votes.go) maintains the finality votes of @@ -147,9 +114,9 @@ finality provider's Bitcoin secp256k1 public key, and the value is a `SchnorrEOTSSig` [object](../../types/btc_schnorr_eots.go) representing an EOTS signature. Here, the EOTS signature is signed over a block's height and `AppHash` by the finality provider, using the private randomness corresponding -to the EOTS public randomness it commits to at the block's height. The EOTS -signature serves as a finality vote on this block from this finality provider. -It is a 32-byte scalar and is defined as a 32-byte array in the implementation. +to the EOTS public randomness derived using the block height. The EOTS signature +serves as a finality vote on this block from this finality provider. It is a +32-byte scalar and is defined as a 32-byte array in the implementation. ```go type SchnorrEOTSSig []byte @@ -191,12 +158,13 @@ secp256k1 secret key, as per EOTS's extractability property. // Evidence is the evidence that a finality provider has signed finality // signatures with correct public randomness on two conflicting Babylon headers message Evidence { - // fp_btc_pk is the BTC Pk of the finality provider that casts this vote - bytes fp_btc_pk = 1 [ (gogoproto.customtype) = "github.com/babylonchain/babylon/types.BIP340PubKey" ]; + // fp_btc_pk is the BTC PK of the finality provider that casts this vote + bytes fp_btc_pk = 1 [ (gogoproto.customtype) = "github.com/babylonlabs-io/babylon/types.BIP340PubKey" ]; // 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/babylonchain/babylon/types.SchnorrPubRand" ]; + // master_pub_rand is the master public randomness the finality provider has committed to + // encoded as a base58 string + string master_pub_rand = 3; // 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 @@ -205,59 +173,72 @@ message Evidence { // 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/babylonchain/babylon/types.SchnorrEOTSSig" ]; + 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/babylonchain/babylon/types.SchnorrEOTSSig" ]; + bytes fork_finality_sig = 7 [ (gogoproto.customtype) = "github.com/babylonlabs-io/babylon/types.SchnorrEOTSSig" ]; } ``` -## Messages +### Signing info tracker -The Finality module handles the following messages from finality providers. The -message formats are defined at -[proto/babylon/finality/v1/tx.proto](../../proto/babylon/finality/v1/tx.proto). -The message handlers are defined at -[x/finality/keeper/msg_server.go](./keeper/msg_server.go). +Information about finality providers' voting histories is tracked through +`FinalityProviderSigningInfo`. It is indexed in the store as follows: -### MsgCommitPubRandList +- `FinalityProviderSigningTracker: BTCPublicKey -> ProtoBuffer + (FinalityProviderSigningInfo)` -The `MsgCommitPubRandList` message is used for committing 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. +- FinalityProviderMissedBlockBitmap: `BTCPublicKey -> VarInt(didMiss)` (varint + is a number encoding format) -```protobuf -// MsgCommitPubRandList defines a message for committing a list of public randomness for EOTS -message MsgCommitPubRandList { - option (cosmos.msg.v1.signer) = "signer"; +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). - string signer = 1; - // fp_btc_pk is the BTC PK of the finality provider that commits the public randomness - bytes fp_btc_pk = 2 [ (gogoproto.customtype) = "github.com/babylonchain/babylon/types.BIP340PubKey" ]; - // start_height is the start block height of the list of public randomness - uint64 start_height = 3; - // pub_rand_list is the list of public randomness - repeated bytes pub_rand_list = 4 [ (gogoproto.customtype) = "github.com/babylonchain/babylon/types.SchnorrPubRand" ]; - // sig is the signature on (start_height || pub_rand_list) signed by - // SK corresponding to fp_btc_pk. This prevents others to commit public - // randomness on behalf of fp_btc_pk - // TODO: another option is to restrict signer to correspond to fp_btc_pk. This restricts - // the tx submitter to be the holder of fp_btc_pk. Decide this later - bytes sig = 5 [ (gogoproto.customtype) = "github.com/babylonchain/babylon/types.BIP340Signature" ]; +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. + +The information stored for tracking finality provider liveness is as follows: + +```protobuf +// FinalityProviderSigningInfo defines a finality provider's signing info +// for monitoring their liveness activity. +message FinalityProviderSigningInfo { + // fp_btc_pk is the BTC PK of the finality provider that casts this finality + // signature + bytes fp_btc_pk = 1 [ (gogoproto.customtype) = "github.com/babylonlabs-io/babylon/types.BIP340PubKey" ]; + // 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; } ``` -Upon `MsgCommitPubRandList`, a Babylon node will execute as follows: +Note that the value of `missed_blocks_counter` in the +`FinalityProviderSigningInfo` is the same as the summed value of the +corresponding missed block bitmap. This is to avoid unnecessary bitmap reads. +Also note that the judgement of whether a finality signature is `missed` or not +is irreversible. + +The two maps will be updated upon `BeginBlock` which will be described in a +later section. -1. Ensure the message contains at least `MinPubRand` number of EOTS public - randomness, where `MinPubRand` is defined in the module parameters. -2. Ensure the finality provider has been registered in Babylon. -3. Ensure the list of EOTS public randomness does not overlap with existing EOTS - public randomness that this finality provider previously committed before. -4. Verify the Schnorr signature over the list of public randomness signed by the - finality provider. -5. Store the list of EOTS public randomness to the public randomness storage. +## Messages + +The Finality module handles the following messages from finality providers. The +message formats are defined at +[proto/babylon/finality/v1/tx.proto](../../proto/babylon/finality/v1/tx.proto). +The message handlers are defined at +[x/finality/keeper/msg_server.go](./keeper/msg_server.go). ### MsgAddFinalitySig @@ -273,7 +254,7 @@ message MsgAddFinalitySig { string signer = 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/babylonchain/babylon/types.BIP340PubKey" ]; + bytes fp_btc_pk = 2 [ (gogoproto.customtype) = "github.com/babylonlabs-io/babylon/types.BIP340PubKey" ]; // block_height is the height of the voted block uint64 block_height = 3; // block_app_hash is the AppHash of the voted block @@ -282,7 +263,7 @@ message MsgAddFinalitySig { // 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 finality_sig = 5 [ (gogoproto.customtype) = "github.com/babylonchain/babylon/types.SchnorrEOTSSig" ]; + bytes finality_sig = 5 [ (gogoproto.customtype) = "github.com/babylonlabs-io/babylon/types.SchnorrEOTSSig" ]; } ``` @@ -290,18 +271,20 @@ Upon `MsgAddFinalitySig`, a Babylon node will execute as follows: 1. Ensure the finality provider has been registered in Babylon and is not slashed. -2. Ensure the finality provider has voting power at this height. -3. Ensure the finality provider has not previously casted the same vote. -4. Ensure the finality provider has a committed EOTS public randomness at this - height. -5. Verify the EOTS signature w.r.t. the committed EOTS public randomness. -6. If the voted block's `AppHash` is different from the canonical block at the +2. Ensure the epoch that the finality provider is registered has been finalized + by BTC timestamping. +3. Ensure the finality provider has voting power at this height. +4. Ensure the finality provider has not previously casted the same vote. +5. Derive the EOTS public randomness using the committed EOTS master public + randomness and the block height. +6. Verify the EOTS signature w.r.t. the derived EOTS public randomness. +7. If the voted block's `AppHash` is different from the canonical block at the same height known by the Babylon node, then this means the finality provider has voted for a fork. Babylon node buffers this finality vote to the evidence storage. If the finality provider has also voted for the block at the same height, then this finality provider is slashed, i.e., its voting power is removed, equivocation evidence is recorded, and a slashing event is emitted. -7. If the voted block's `AppHash` is same as that of the canonical block at the +8. If the voted block's `AppHash` is same as that of the canonical block at the same height, then this means the finality provider has voted for the canonical block, and the Babylon node will store this finality vote to the finality vote storage. If the finality provider has also voted for a fork @@ -355,11 +338,12 @@ 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. ## Events -The Finality module defines the `EventSlashedFinalityProvider` event. It is -emitted when a finality provider is slashed due to equivocation. +The Finality module defines the following events. ```protobuf // EventSlashedFinalityProvider is the event emitted when a finality provider is slashed @@ -368,6 +352,21 @@ message EventSlashedFinalityProvider { // evidence is the evidence that the finality provider double signs Evidence evidence = 1; } + +// EventSluggishFinalityProviderDetected is the event emitted when a finality provider is +// detected as sluggish +message EventSluggishFinalityProviderDetected { +// public_key is the BTC public key of the finality provider +string public_key = 1; +} + +// EventSluggishFinalityProviderReverted is the event emitted when a sluggish finality +// provider is no longer considered sluggish +message EventSluggishFinalityProviderReverted { +// public_key is the BTC public key of the finality provider +string public_key = 1; +} + ``` ## Queries diff --git a/x/finality/abci.go b/x/finality/abci.go index facf59d75..93ef8852a 100644 --- a/x/finality/abci.go +++ b/x/finality/abci.go @@ -4,10 +4,12 @@ import ( "context" "time" - "github.com/babylonchain/babylon/x/finality/keeper" - "github.com/babylonchain/babylon/x/finality/types" abci "github.com/cometbft/cometbft/abci/types" "github.com/cosmos/cosmos-sdk/telemetry" + sdk "github.com/cosmos/cosmos-sdk/types" + + "github.com/babylonlabs-io/babylon/x/finality/keeper" + "github.com/babylonlabs-io/babylon/x/finality/types" ) func BeginBlocker(ctx context.Context, k keeper.Keeper) error { @@ -25,6 +27,17 @@ func EndBlocker(ctx context.Context, k keeper.Keeper) ([]abci.ValidatorUpdate, e k.IndexBlock(ctx) // tally all non-finalised blocks k.TallyBlocks(ctx) + + // detect sluggish finality providers if there are any + // heightToExamine is determined by the current height - params.FinalitySigTimeout + // which indicates that finality providers have up to `params.FinalitySigTimeout` blocks + // to send votes on the height to be examined as whether `missed` or not (1 or 0 of a + // bit in a bit array of size params.SignedBlocksWindow) + // once this height is judged as `missed`, the judgement is irreversible + heightToExamine := sdk.UnwrapSDKContext(ctx).HeaderInfo().Height - k.GetParams(ctx).FinalitySigTimeout + if heightToExamine >= 1 { + k.HandleLiveness(ctx, heightToExamine) + } } return []abci.ValidatorUpdate{}, nil diff --git a/x/finality/client/cli/query.go b/x/finality/client/cli/query.go index 7198e450f..da6ef9361 100644 --- a/x/finality/client/cli/query.go +++ b/x/finality/client/cli/query.go @@ -9,7 +9,7 @@ import ( "github.com/cosmos/cosmos-sdk/client" "github.com/spf13/cobra" - "github.com/babylonchain/babylon/x/finality/types" + "github.com/babylonlabs-io/babylon/x/finality/types" ) const ( @@ -30,6 +30,7 @@ func GetQueryCmd(queryRoute string) *cobra.Command { cmd.AddCommand(CmdQueryParams()) cmd.AddCommand(CmdListPublicRandomness()) + cmd.AddCommand(CmdListPubRandCommit()) cmd.AddCommand(CmdBlock()) cmd.AddCommand(CmdListBlocks()) cmd.AddCommand(CmdVotesAtHeight()) @@ -100,6 +101,39 @@ func CmdListPublicRandomness() *cobra.Command { return cmd } +func CmdListPubRandCommit() *cobra.Command { + cmd := &cobra.Command{ + Use: "list-pub-rand-commit [fp_btc_pk_hex]", + Short: "list public randomness commitment 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) + + pageReq, err := client.ReadPageRequest(cmd.Flags()) + if err != nil { + return err + } + + res, err := queryClient.ListPubRandCommit(cmd.Context(), &types.QueryListPubRandCommitRequest{ + FpBtcPkHex: args[0], + Pagination: pageReq, + }) + if err != nil { + return err + } + + return clientCtx.PrintProto(res) + }, + } + + flags.AddQueryFlagsToCmd(cmd) + flags.AddPaginationFlagsToCmd(cmd, "list-pub-rand-commit") + + return cmd +} + func CmdListBlocks() *cobra.Command { cmd := &cobra.Command{ Use: "list-blocks", diff --git a/x/finality/client/cli/query_params.go b/x/finality/client/cli/query_params.go index 16ff79e70..ea616d06b 100644 --- a/x/finality/client/cli/query_params.go +++ b/x/finality/client/cli/query_params.go @@ -5,7 +5,7 @@ import ( "github.com/cosmos/cosmos-sdk/client/flags" "github.com/spf13/cobra" - "github.com/babylonchain/babylon/x/finality/types" + "github.com/babylonlabs-io/babylon/x/finality/types" ) func CmdQueryParams() *cobra.Command { diff --git a/x/finality/client/cli/tx.go b/x/finality/client/cli/tx.go index bf4b4178b..384d87448 100644 --- a/x/finality/client/cli/tx.go +++ b/x/finality/client/cli/tx.go @@ -6,8 +6,9 @@ import ( "strconv" "strings" - bbn "github.com/babylonchain/babylon/types" - "github.com/babylonchain/babylon/x/finality/types" + bbn "github.com/babylonlabs-io/babylon/types" + "github.com/babylonlabs-io/babylon/x/finality/types" + cmtcrypto "github.com/cometbft/cometbft/proto/tendermint/crypto" "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/client/flags" "github.com/cosmos/cosmos-sdk/client/tx" @@ -34,8 +35,8 @@ func GetTxCmd() *cobra.Command { func NewCommitPubRandListCmd() *cobra.Command { cmd := &cobra.Command{ - Use: "commit-pubrand-list [fp_btc_pk] [start_height] [pub_rand1] [pub_rand2] ... [sig]", - Args: cobra.MinimumNArgs(4), + Use: "commit-pubrand-list [fp_btc_pk] [start_height] [num_pub_rand] [commitment] [sig]", + Args: cobra.ExactArgs(5), Short: "Commit a list of public randomness", Long: strings.TrimSpace( `Commit a list of public randomness.`, // TODO: example @@ -58,28 +59,28 @@ func NewCommitPubRandListCmd() *cobra.Command { return err } - // get signature - sig, err := bbn.NewBIP340SignatureFromHex(args[len(args)-1]) + numPubRand, err := strconv.ParseUint(args[2], 10, 64) if err != nil { return err } - // get pub rand list - pubRandHexList := args[2 : len(args)-1] - pubRandList := []bbn.SchnorrPubRand{} - for _, prHex := range pubRandHexList { - pr, err := bbn.NewSchnorrPubRandFromHex(prHex) - if err != nil { - return err - } - pubRandList = append(pubRandList, *pr) + commitment, err := hex.DecodeString(args[3]) + if err != nil { + return err + } + + // get signature + sig, err := bbn.NewBIP340SignatureFromHex(args[4]) + if err != nil { + return err } msg := types.MsgCommitPubRandList{ Signer: clientCtx.FromAddress.String(), FpBtcPk: fpBTCPK, StartHeight: startHeight, - PubRandList: pubRandList, + NumPubRand: numPubRand, + Commitment: commitment, Sig: sig, } @@ -94,8 +95,8 @@ func NewCommitPubRandListCmd() *cobra.Command { func NewAddFinalitySigCmd() *cobra.Command { cmd := &cobra.Command{ - Use: "add-finality-sig [fp_btc_pk] [block_height] [block_app_hash] [finality_sig]", - Args: cobra.ExactArgs(4), + Use: "add-finality-sig [fp_btc_pk] [block_height] [pub_rand] [proof] [block_app_hash] [finality_sig]", + Args: cobra.ExactArgs(6), Short: "Add a finality signature", Long: strings.TrimSpace( `Add a finality signature.`, // TODO: example @@ -118,14 +119,30 @@ func NewAddFinalitySigCmd() *cobra.Command { return err } - // get block last commit hash - blockLch, err := hex.DecodeString(args[2]) + // get public randomness + pubRand, err := bbn.NewSchnorrPubRandFromHex(args[2]) + if err != nil { + return err + } + + // get proof + proofBytes, err := hex.DecodeString(args[3]) + if err != nil { + return err + } + var proof cmtcrypto.Proof + if err := clientCtx.Codec.Unmarshal(proofBytes, &proof); err != nil { + return err + } + + // get block app hash + appHash, err := hex.DecodeString(args[4]) if err != nil { return err } // get finality signature - finalitySig, err := bbn.NewSchnorrEOTSSigFromHex(args[3]) + finalitySig, err := bbn.NewSchnorrEOTSSigFromHex(args[5]) if err != nil { return err } @@ -134,7 +151,9 @@ func NewAddFinalitySigCmd() *cobra.Command { Signer: clientCtx.FromAddress.String(), FpBtcPk: fpBTCPK, BlockHeight: blockHeight, - BlockAppHash: blockLch, + PubRand: pubRand, + Proof: &proof, + BlockAppHash: appHash, FinalitySig: finalitySig, } diff --git a/x/finality/genesis.go b/x/finality/genesis.go index 6f771fb4b..43018ece9 100644 --- a/x/finality/genesis.go +++ b/x/finality/genesis.go @@ -2,21 +2,27 @@ package finality import ( "context" - "github.com/babylonchain/babylon/x/finality/keeper" - "github.com/babylonchain/babylon/x/finality/types" + + "github.com/babylonlabs-io/babylon/x/finality/keeper" + "github.com/babylonlabs-io/babylon/x/finality/types" ) // InitGenesis initializes the module's state from a provided genesis state. -func InitGenesis(ctx context.Context, k keeper.Keeper, genState types.GenesisState) { - if err := k.SetParams(ctx, genState.Params); err != nil { +func InitGenesis(ctx context.Context, k keeper.Keeper, gs types.GenesisState) { + if err := gs.Validate(); err != nil { + panic(err) + } + + if err := k.InitGenesis(ctx, gs); err != nil { panic(err) } } // ExportGenesis returns the module's exported genesis func ExportGenesis(ctx context.Context, k keeper.Keeper) *types.GenesisState { - genesis := types.DefaultGenesis() - genesis.Params = k.GetParams(ctx) - - return genesis + gs, err := k.ExportGenesis(ctx) + if err != nil { + panic(err) + } + return gs } diff --git a/x/finality/genesis_test.go b/x/finality/genesis_test.go index e99999e4e..f66eb3555 100644 --- a/x/finality/genesis_test.go +++ b/x/finality/genesis_test.go @@ -3,10 +3,10 @@ package finality_test import ( "testing" - keepertest "github.com/babylonchain/babylon/testutil/keeper" - "github.com/babylonchain/babylon/testutil/nullify" - "github.com/babylonchain/babylon/x/finality" - "github.com/babylonchain/babylon/x/finality/types" + keepertest "github.com/babylonlabs-io/babylon/testutil/keeper" + "github.com/babylonlabs-io/babylon/testutil/nullify" + "github.com/babylonlabs-io/babylon/x/finality" + "github.com/babylonlabs-io/babylon/x/finality/types" "github.com/stretchr/testify/require" ) diff --git a/x/finality/keeper/evidence.go b/x/finality/keeper/evidence.go index 0d9f610ad..4a18c7d69 100644 --- a/x/finality/keeper/evidence.go +++ b/x/finality/keeper/evidence.go @@ -4,27 +4,27 @@ import ( "context" "cosmossdk.io/store/prefix" - bbn "github.com/babylonchain/babylon/types" - "github.com/babylonchain/babylon/x/finality/types" + bbn "github.com/babylonlabs-io/babylon/types" + "github.com/babylonlabs-io/babylon/x/finality/types" "github.com/cosmos/cosmos-sdk/runtime" sdk "github.com/cosmos/cosmos-sdk/types" ) func (k Keeper) SetEvidence(ctx context.Context, evidence *types.Evidence) { - store := k.evidenceStore(ctx, evidence.FpBtcPk) + store := k.evidenceFpStore(ctx, evidence.FpBtcPk) store.Set(sdk.Uint64ToBigEndian(evidence.BlockHeight), k.cdc.MustMarshal(evidence)) } func (k Keeper) HasEvidence(ctx context.Context, fpBtcPK *bbn.BIP340PubKey, height uint64) bool { - store := k.evidenceStore(ctx, fpBtcPK) - return store.Has(fpBtcPK.MustMarshal()) + store := k.evidenceFpStore(ctx, fpBtcPK) + return store.Has(sdk.Uint64ToBigEndian(height)) } func (k Keeper) GetEvidence(ctx context.Context, fpBtcPK *bbn.BIP340PubKey, height uint64) (*types.Evidence, error) { if uint64(sdk.UnwrapSDKContext(ctx).HeaderInfo().Height) < height { return nil, types.ErrHeightTooHigh } - store := k.evidenceStore(ctx, fpBtcPK) + store := k.evidenceFpStore(ctx, fpBtcPK) evidenceBytes := store.Get(sdk.Uint64ToBigEndian(height)) if len(evidenceBytes) == 0 { return nil, types.ErrEvidenceNotFound @@ -40,7 +40,7 @@ func (k Keeper) GetEvidence(ctx context.Context, fpBtcPK *bbn.BIP340PubKey, heig // an evidence, which happens when the finality provider signed a fork block // but hasn't signed the canonical block yet. func (k Keeper) GetFirstSlashableEvidence(ctx context.Context, fpBtcPK *bbn.BIP340PubKey) *types.Evidence { - store := k.evidenceStore(ctx, fpBtcPK) + store := k.evidenceFpStore(ctx, fpBtcPK) iter := store.Iterator(nil, nil) defer iter.Close() for ; iter.Valid(); iter.Next() { @@ -54,12 +54,20 @@ func (k Keeper) GetFirstSlashableEvidence(ctx context.Context, fpBtcPK *bbn.BIP3 return nil } -// evidenceStore returns the KVStore of the evidences +// evidenceFpStore returns the KVStore of the evidences // prefix: EvidenceKey // key: (finality provider PK || height) // value: Evidence -func (k Keeper) evidenceStore(ctx context.Context, fpBTCPK *bbn.BIP340PubKey) prefix.Store { - storeAdapter := runtime.KVStoreAdapter(k.storeService.OpenKVStore(ctx)) - eStore := prefix.NewStore(storeAdapter, types.EvidenceKey) +func (k Keeper) evidenceFpStore(ctx context.Context, fpBTCPK *bbn.BIP340PubKey) prefix.Store { + eStore := k.evidenceStore(ctx) return prefix.NewStore(eStore, fpBTCPK.MustMarshal()) } + +// evidenceStore returns the KVStore of the evidences +// prefix: EvidenceKey +// key: (prefix) +// value: Evidence +func (k Keeper) evidenceStore(ctx context.Context) prefix.Store { + storeAdapter := runtime.KVStoreAdapter(k.storeService.OpenKVStore(ctx)) + return prefix.NewStore(storeAdapter, types.EvidenceKey) +} diff --git a/x/finality/keeper/genesis.go b/x/finality/keeper/genesis.go new file mode 100644 index 000000000..1c41be585 --- /dev/null +++ b/x/finality/keeper/genesis.go @@ -0,0 +1,274 @@ +package keeper + +import ( + "context" + "fmt" + + sdk "github.com/cosmos/cosmos-sdk/types" + + btcstk "github.com/babylonlabs-io/babylon/btcstaking" + bbn "github.com/babylonlabs-io/babylon/types" + "github.com/babylonlabs-io/babylon/x/finality/types" +) + +// InitGenesis initializes the keeper state from a provided initial genesis state. +func (k Keeper) InitGenesis(ctx context.Context, gs types.GenesisState) error { + for _, idxBlock := range gs.IndexedBlocks { + k.SetBlock(ctx, idxBlock) + } + + for _, evidence := range gs.Evidences { + k.SetEvidence(ctx, evidence) + } + + for _, voteSig := range gs.VoteSigs { + k.SetSig(ctx, voteSig.BlockHeight, voteSig.FpBtcPk, voteSig.FinalitySig) + } + + for _, pubRand := range gs.PublicRandomness { + k.SetPubRand(ctx, pubRand.FpBtcPk, pubRand.BlockHeight, *pubRand.PubRand) + } + + for _, prc := range gs.PubRandCommit { + k.SetPubRandCommit(ctx, prc.FpBtcPk, prc.PubRandCommit) + } + + for _, info := range gs.SigningInfos { + err := k.FinalityProviderSigningTracker.Set(ctx, info.FpBtcPk.MustMarshal(), info.FpSigningInfo) + if err != nil { + return err + } + } + + for _, array := range gs.MissedBlocks { + for _, missed := range array.MissedBlocks { + if err := k.SetMissedBlockBitmapValue(ctx, array.FpBtcPk, missed.Index, missed.Missed); err != nil { + return err + } + } + } + + return k.SetParams(ctx, gs.Params) +} + +// ExportGenesis returns the keeper state into a exported genesis state. +func (k Keeper) ExportGenesis(ctx context.Context) (*types.GenesisState, error) { + blocks, err := k.blocks(ctx) + if err != nil { + return nil, err + } + + evidences, err := k.evidences(ctx) + if err != nil { + return nil, err + } + + voteSigs, err := k.voteSigs(ctx) + if err != nil { + return nil, err + } + + pubRandomness, err := k.publicRandomness(ctx) + if err != nil { + return nil, err + } + + prCommit, err := k.exportPubRandCommit(ctx) + if err != nil { + return nil, err + } + + signingInfos, missedBlocks, err := k.signingInfosAndMissedBlock(ctx) + if err != nil { + return nil, err + } + + return &types.GenesisState{ + Params: k.GetParams(ctx), + IndexedBlocks: blocks, + Evidences: evidences, + VoteSigs: voteSigs, + PublicRandomness: pubRandomness, + PubRandCommit: prCommit, + SigningInfos: signingInfos, + MissedBlocks: missedBlocks, + }, nil +} + +// blocks loads all blocks stored. +// This function has high resource consumption and should be only used on export genesis. +func (k Keeper) blocks(ctx context.Context) ([]*types.IndexedBlock, error) { + blocks := make([]*types.IndexedBlock, 0) + + iter := k.blockStore(ctx).Iterator(nil, nil) + defer iter.Close() + + for ; iter.Valid(); iter.Next() { + var blk types.IndexedBlock + if err := k.cdc.Unmarshal(iter.Value(), &blk); err != nil { + return nil, err + } + blocks = append(blocks, &blk) + } + + return blocks, nil +} + +// evidences loads all evidences stored. +// This function has high resource consumption and should be only used on export genesis. +func (k Keeper) evidences(ctx context.Context) (evidences []*types.Evidence, err error) { + evidences = make([]*types.Evidence, 0) + + iter := k.evidenceStore(ctx).Iterator(nil, nil) + defer iter.Close() + + for ; iter.Valid(); iter.Next() { + var evd types.Evidence + if err := k.cdc.Unmarshal(iter.Value(), &evd); err != nil { + return nil, err + } + evidences = append(evidences, &evd) + } + + return evidences, nil +} + +// voteSigs iterates over all votes on the store, parses the height and the finality provider +// public key from the iterator key and the finality signature from the iterator value. +// This function has high resource consumption and should be only used on export genesis. +func (k Keeper) voteSigs(ctx context.Context) ([]*types.VoteSig, error) { + store := k.voteStore(ctx) + iter := store.Iterator(nil, nil) + defer iter.Close() + + voteSigs := make([]*types.VoteSig, 0) + for ; iter.Valid(); iter.Next() { + // key contains the height and the fp + blkHeight, fpBTCPK, err := btcstk.ParseBlkHeightAndPubKeyFromStoreKey(iter.Key()) + if err != nil { + return nil, err + } + finalitySig, err := bbn.NewSchnorrEOTSSig(iter.Value()) + if err != nil { + return nil, err + } + + voteSigs = append(voteSigs, &types.VoteSig{ + BlockHeight: blkHeight, + FpBtcPk: fpBTCPK, + FinalitySig: finalitySig, + }) + } + + 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. +// 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) + iter := store.Iterator(nil, nil) + defer iter.Close() + + commtRandoms := make([]*types.PublicRandomness, 0) + for ; iter.Valid(); iter.Next() { + // key contains the fp and the block height + fpBTCPK, blkHeight, err := parsePubKeyAndBlkHeightFromStoreKey(iter.Key()) + if err != nil { + return nil, err + } + pubRand, err := bbn.NewSchnorrPubRand(iter.Value()) + if err != nil { + return nil, err + } + + commtRandoms = append(commtRandoms, &types.PublicRandomness{ + BlockHeight: blkHeight, + FpBtcPk: fpBTCPK, + PubRand: pubRand, + }) + } + + return commtRandoms, nil +} + +// exportPubRandCommit iterates over all public randomness commitment on the store, +// parses the finality provider public key and the height from the iterator key +// and the commitment from the iterator value. +// This function has high resource consumption and should be only used on export genesis. +func (k Keeper) exportPubRandCommit(ctx context.Context) ([]*types.PubRandCommitWithPK, error) { + store := k.pubRandCommitStore(ctx) + iter := store.Iterator(nil, nil) + defer iter.Close() + + commtRandoms := make([]*types.PubRandCommitWithPK, 0) + for ; iter.Valid(); iter.Next() { + // key contains the fp and the block height + fpBTCPK, _, err := parsePubKeyAndBlkHeightFromStoreKey(iter.Key()) + if err != nil { + return nil, err + } + var prc types.PubRandCommit + k.cdc.MustUnmarshal(iter.Value(), &prc) + + commtRandoms = append(commtRandoms, &types.PubRandCommitWithPK{ + FpBtcPk: fpBTCPK, + PubRandCommit: &prc, + }) + } + + return commtRandoms, nil +} + +func (k Keeper) signingInfosAndMissedBlock(ctx context.Context) ([]types.SigningInfo, []types.FinalityProviderMissedBlocks, error) { + signingInfos := make([]types.SigningInfo, 0) + missedBlocks := make([]types.FinalityProviderMissedBlocks, 0) + err := k.FinalityProviderSigningTracker.Walk(ctx, nil, func(fpPkBytes []byte, info types.FinalityProviderSigningInfo) (stop bool, err error) { + fpPk, err := bbn.NewBIP340PubKey(fpPkBytes) + if err != nil { + return true, err + } + + signingInfos = append(signingInfos, types.SigningInfo{ + FpBtcPk: fpPk, + FpSigningInfo: info, + }) + + localMissedBlocks, err := k.GetFinalityProviderMissedBlocks(ctx, fpPk) + if err != nil { + return true, err + } + + missedBlocks = append(missedBlocks, types.FinalityProviderMissedBlocks{ + FpBtcPk: fpPk, + MissedBlocks: localMissedBlocks, + }) + + return false, nil + }) + if err != nil { + return nil, nil, err + } + + return signingInfos, missedBlocks, nil +} + +// parsePubKeyAndBlkHeightFromStoreKey expects to receive a key with +// BIP340PubKey(fpBTCPK) || BigEndianUint64(blkHeight) +func parsePubKeyAndBlkHeightFromStoreKey(key []byte) (fpBTCPK *bbn.BIP340PubKey, blkHeight uint64, err error) { + sizeBigEndian := 8 + keyLen := len(key) + if keyLen < sizeBigEndian+1 { + return nil, 0, fmt.Errorf("key not long enough to parse BIP340PubKey and block height: %s", key) + } + + startKeyHeight := keyLen - sizeBigEndian + fpBTCPK, err = bbn.NewBIP340PubKey(key[:startKeyHeight]) + if err != nil { + return nil, 0, fmt.Errorf("failed to parse pub key from key %w: %w", bbn.ErrUnmarshal, err) + } + + blkHeight = sdk.BigEndianToUint64(key[startKeyHeight:]) + return fpBTCPK, blkHeight, nil +} diff --git a/x/finality/keeper/genesis_test.go b/x/finality/keeper/genesis_test.go new file mode 100644 index 000000000..cdad29119 --- /dev/null +++ b/x/finality/keeper/genesis_test.go @@ -0,0 +1,132 @@ +package keeper_test + +import ( + "math/rand" + "testing" + + "github.com/stretchr/testify/require" + + "github.com/babylonlabs-io/babylon/testutil/datagen" + keepertest "github.com/babylonlabs-io/babylon/testutil/keeper" + bbn "github.com/babylonlabs-io/babylon/types" + "github.com/babylonlabs-io/babylon/x/finality/types" +) + +func FuzzTestExportGenesis(f *testing.F) { + datagen.AddRandomSeedsToFuzzer(f, 10) + f.Fuzz(func(t *testing.T, seed int64) { + r := rand.New(rand.NewSource(seed)) + k, ctx := keepertest.FinalityKeeper(t, nil, nil) + + btcSK, btcPK, err := datagen.GenRandomBTCKeyPair(r) + require.NoError(t, err) + + fpBTCPK := bbn.NewBIP340PubKeyFromBTCPK(btcPK) + blkHeight, startHeight, numPubRand := uint64(1), uint64(0), uint64(5) + + randListInfo, _, err := datagen.GenRandomMsgCommitPubRandList(r, btcSK, startHeight, numPubRand) + require.NoError(t, err) + + blockHash := datagen.GenRandomByteArray(r, 32) + signer := datagen.GenRandomAccount().Address + msgAddFinalitySig, err := datagen.NewMsgAddFinalitySig(signer, btcSK, startHeight, blkHeight, randListInfo, blockHash) + require.NoError(t, err) + + allVotes := make([]*types.VoteSig, numPubRand) + 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{ + FpBtcPk: fpBTCPK, + BlockHeight: blkHeight, + FinalitySig: msgAddFinalitySig.FinalitySig, + } + k.SetSig(ctx, vt.BlockHeight, vt.FpBtcPk, vt.FinalitySig) + allVotes[i] = vt + + // Blocks + blk := &types.IndexedBlock{ + Height: blkHeight, + AppHash: blockHash, + Finalized: i%2 == 0, + } + k.SetBlock(ctx, blk) + allBlocks[i] = blk + + // Evidences + evidence := &types.Evidence{ + FpBtcPk: fpBTCPK, + BlockHeight: blkHeight, + PubRand: &randListInfo.PRList[i], + ForkAppHash: msgAddFinalitySig.BlockAppHash, + ForkFinalitySig: msgAddFinalitySig.FinalitySig, + CanonicalAppHash: blockHash, + CanonicalFinalitySig: msgAddFinalitySig.FinalitySig, + } + k.SetEvidence(ctx, evidence) + allEvidences[i] = evidence + + // public randomness + pubRand := randListInfo.PRList[i] + k.SetPubRand(ctx, fpBTCPK, blkHeight, pubRand) + randomness := &types.PublicRandomness{ + BlockHeight: blkHeight, + FpBtcPk: fpBTCPK, + PubRand: &pubRand, + } + allPublicRandomness[i] = randomness + + // updates the block everytime to make sure something is different. + blkHeight++ + } + + prc := &types.PubRandCommit{ + StartHeight: startHeight, + NumPubRand: numPubRand, + Commitment: randListInfo.Commitment, + } + k.SetPubRandCommit(ctx, fpBTCPK, prc) + + numSigningInfo := datagen.RandomInt(r, 100) + 10 + fpSigningInfos := map[string]*types.FinalityProviderSigningInfo{} + fpPks := make([]string, 0) + for i := uint64(0); i < numSigningInfo; i++ { + // random key pair + fpPk, err := datagen.GenRandomBIP340PubKey(r) + require.NoError(t, err) + fpPks = append(fpPks, fpPk.MarshalHex()) + + // random height and missed block counter + height := int64(datagen.RandomInt(r, 100) + 1) + missedBlockCounter := int64(datagen.RandomInt(r, 100) + 1) + + // create signing info and add it to map and finality keeper + signingInfo := types.NewFinalityProviderSigningInfo(fpPk, height, missedBlockCounter) + err = k.FinalityProviderSigningTracker.Set(ctx, fpPk.MustMarshal(), signingInfo) + require.NoError(t, err) + fpSigningInfos[fpPk.MarshalHex()] = &signingInfo + } + + require.Equal(t, len(allVotes), int(numPubRand)) + require.Equal(t, len(allBlocks), int(numPubRand)) + require.Equal(t, len(allEvidences), int(numPubRand)) + require.Equal(t, len(allPublicRandomness), int(numPubRand)) + + gs, err := k.ExportGenesis(ctx) + require.NoError(t, err) + require.Equal(t, k.GetParams(ctx), gs.Params) + + require.Equal(t, allVotes, gs.VoteSigs) + require.Equal(t, allBlocks, gs.IndexedBlocks) + require.Equal(t, allEvidences, gs.Evidences) + require.Equal(t, allPublicRandomness, gs.PublicRandomness) + require.Equal(t, prc, gs.PubRandCommit[0].PubRandCommit) + require.Equal(t, len(fpPks), len(gs.SigningInfos)) + for _, info := range gs.SigningInfos { + require.Equal(t, fpSigningInfos[info.FpBtcPk.MarshalHex()].MissedBlocksCounter, info.FpSigningInfo.MissedBlocksCounter) + require.Equal(t, fpSigningInfos[info.FpBtcPk.MarshalHex()].StartHeight, info.FpSigningInfo.StartHeight) + } + }) +} diff --git a/x/finality/keeper/grpc_query.go b/x/finality/keeper/grpc_query.go index f6cd86d56..1478f8f26 100644 --- a/x/finality/keeper/grpc_query.go +++ b/x/finality/keeper/grpc_query.go @@ -3,6 +3,7 @@ package keeper import ( "context" "fmt" + "github.com/cosmos/cosmos-sdk/runtime" "cosmossdk.io/store/prefix" @@ -11,14 +12,15 @@ import ( "google.golang.org/grpc/codes" "google.golang.org/grpc/status" - bbn "github.com/babylonchain/babylon/types" - "github.com/babylonchain/babylon/x/finality/types" + bbn "github.com/babylonlabs-io/babylon/types" + "github.com/babylonlabs-io/babylon/x/finality/types" ) var _ types.QueryServer = Keeper{} // 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") @@ -30,7 +32,7 @@ func (k Keeper) ListPublicRandomness(ctx context.Context, req *types.QueryListPu } sdkCtx := sdk.UnwrapSDKContext(ctx) - store := k.pubRandStore(sdkCtx, fpBTCPK) + store := k.pubRandFpStore(sdkCtx, fpBTCPK) pubRandMap := map[uint64]*bbn.SchnorrPubRand{} pageRes, err := query.Paginate(store, req.Pagination, func(key, value []byte) error { height := sdk.BigEndianToUint64(key) @@ -52,6 +54,39 @@ func (k Keeper) ListPublicRandomness(ctx context.Context, req *types.QueryListPu return resp, nil } +// ListPubRandCommit returns a list of public randomness commitment by a given +// finality provider +func (k Keeper) ListPubRandCommit(ctx context.Context, req *types.QueryListPubRandCommitRequest) (*types.QueryListPubRandCommitResponse, 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) + } + + sdkCtx := sdk.UnwrapSDKContext(ctx) + store := k.pubRandCommitFpStore(sdkCtx, fpBTCPK) + pubRandCommitMap := map[uint64]*types.PubRandCommitResponse{} + pageRes, err := query.Paginate(store, req.Pagination, func(key, value []byte) error { + height := sdk.BigEndianToUint64(key) + var prCommit types.PubRandCommit + k.cdc.MustUnmarshal(value, &prCommit) + pubRandCommitMap[height] = prCommit.ToResponse() + return nil + }) + if err != nil { + return nil, status.Error(codes.Internal, err.Error()) + } + + resp := &types.QueryListPubRandCommitResponse{ + PubRandCommitMap: pubRandCommitMap, + Pagination: pageRes, + } + return resp, nil +} + func (k Keeper) Block(ctx context.Context, req *types.QueryBlockRequest) (*types.QueryBlockResponse, error) { if req == nil { return nil, status.Error(codes.InvalidArgument, "empty request") @@ -190,3 +225,51 @@ func (k Keeper) ListEvidences(ctx context.Context, req *types.QueryListEvidences } return resp, nil } + +// SigningInfo returns signing-info of a specific finality provider. +func (k Keeper) SigningInfo(ctx context.Context, req *types.QuerySigningInfoRequest) (*types.QuerySigningInfoResponse, error) { + if req == nil { + return nil, status.Errorf(codes.InvalidArgument, "empty request") + } + + if req.FpBtcPkHex == "" { + return nil, status.Errorf(codes.InvalidArgument, "empty finality provider public key") + } + + fpPk, err := bbn.NewBIP340PubKeyFromHex(req.FpBtcPkHex) + if err != nil { + return nil, status.Errorf(codes.InvalidArgument, "invalid finality provider public key") + } + + signingInfo, err := k.FinalityProviderSigningTracker.Get(ctx, fpPk.MustMarshal()) + if err != nil { + return nil, status.Errorf(codes.NotFound, "SigningInfo not found for the finality provider %s", req.FpBtcPkHex) + } + + return &types.QuerySigningInfoResponse{FpSigningInfo: signingInfo}, nil +} + +// SigningInfos returns signing-infos of all finality providers. +func (k Keeper) SigningInfos(ctx context.Context, req *types.QuerySigningInfosRequest) (*types.QuerySigningInfosResponse, error) { + if req == nil { + return nil, status.Errorf(codes.InvalidArgument, "empty request") + } + + store := k.storeService.OpenKVStore(ctx) + var signInfos []types.FinalityProviderSigningInfo + + signingInfoStore := prefix.NewStore(runtime.KVStoreAdapter(store), types.FinalityProviderSigningInfoKeyPrefix) + pageRes, err := query.Paginate(signingInfoStore, req.Pagination, func(key, value []byte) error { + var info types.FinalityProviderSigningInfo + err := k.cdc.Unmarshal(value, &info) + if err != nil { + return err + } + signInfos = append(signInfos, info) + return nil + }) + if err != nil { + return nil, err + } + return &types.QuerySigningInfosResponse{FpSigningInfos: signInfos, Pagination: pageRes}, nil +} diff --git a/x/finality/keeper/grpc_query_test.go b/x/finality/keeper/grpc_query_test.go index d9f6c1430..d8d878696 100644 --- a/x/finality/keeper/grpc_query_test.go +++ b/x/finality/keeper/grpc_query_test.go @@ -1,58 +1,23 @@ package keeper_test import ( + "fmt" "math/rand" "testing" + "github.com/btcsuite/btcd/btcec/v2/schnorr" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/query" + "github.com/golang/mock/gomock" "github.com/stretchr/testify/require" - "github.com/babylonchain/babylon/testutil/datagen" - testkeeper "github.com/babylonchain/babylon/testutil/keeper" - bbn "github.com/babylonchain/babylon/types" - "github.com/babylonchain/babylon/x/finality/types" + "github.com/babylonlabs-io/babylon/testutil/datagen" + testkeeper "github.com/babylonlabs-io/babylon/testutil/keeper" + bbn "github.com/babylonlabs-io/babylon/types" + "github.com/babylonlabs-io/babylon/x/finality/keeper" + "github.com/babylonlabs-io/babylon/x/finality/types" ) -func FuzzListPublicRandomness(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) - ctx = sdk.UnwrapSDKContext(ctx) - - // add a random list of EOTS public randomness - fpBTCPK, err := datagen.GenRandomBIP340PubKey(r) - require.NoError(t, err) - startHeight := datagen.RandomInt(r, 100) - numPubRand := datagen.RandomInt(r, 1000) + 2 - _, prList, err := datagen.GenRandomPubRandList(r, numPubRand) - require.NoError(t, err) - keeper.SetPubRandList(ctx, fpBTCPK, startHeight, prList) - - // perform a query to pubrand list and assert consistency - // NOTE: pagination is already tested in Cosmos SDK so we don't test it here again, - // instead only ensure it takes effect - limit := datagen.RandomInt(r, int(numPubRand)-1) + 1 - req := &types.QueryListPublicRandomnessRequest{ - FpBtcPkHex: fpBTCPK.MarshalHex(), - Pagination: &query.PageRequest{ - Limit: limit, - }, - } - resp, err := keeper.ListPublicRandomness(ctx, req) - require.NoError(t, err) - require.Equal(t, int(limit), len(resp.PubRandMap)) // check if pagination takes effect - for i := startHeight; i < startHeight+limit; i++ { - expectedPR := prList[i-startHeight] - actualPR := resp.PubRandMap[i] - require.Equal(t, expectedPR.MustMarshal(), actualPR.MustMarshal()) - } - }) -} - func FuzzBlock(f *testing.F) { datagen.AddRandomSeedsToFuzzer(f, 10) f.Fuzz(func(t *testing.T, seed int64) { @@ -217,6 +182,78 @@ func FuzzVotesAtHeight(f *testing.F) { }) } +func FuzzListPubRandCommit(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 + bsKeeper := types.NewMockBTCStakingKeeper(ctrl) + fKeeper, ctx := testkeeper.FinalityKeeper(t, bsKeeper, nil) + ctx = sdk.UnwrapSDKContext(ctx) + ms := keeper.NewMsgServerImpl(*fKeeper) + + // set random BTC SK PK + sk, _, err := datagen.GenRandomBTCKeyPair(r) + bip340PK := bbn.NewBIP340PubKeyFromBTCPK(sk.PubKey()) + require.NoError(t, err) + + // register finality provider + fp, err := datagen.GenRandomFinalityProviderWithBTCSK(r, sk) + require.NoError(t, err) + bsKeeper.EXPECT().GetFinalityProvider(gomock.Any(), gomock.Eq(bip340PK.MustMarshal())).Return(fp, nil).AnyTimes() + bsKeeper.EXPECT().HasFinalityProvider(gomock.Any(), gomock.Eq(bip340PK.MustMarshal())).Return(true).AnyTimes() + + numPrCommitList := datagen.RandomInt(r, 10) + 1 + prCommitList := []*types.PubRandCommit{} + + // set a list of random public randomness commitment + startHeight := datagen.RandomInt(r, 10) + 1 + for i := uint64(0); i < numPrCommitList; i++ { + numPubRand := datagen.RandomInt(r, 10) + 100 + randListInfo, err := datagen.GenRandomPubRandList(r, numPubRand) + require.NoError(t, err) + prCommit := &types.PubRandCommit{ + StartHeight: startHeight, + NumPubRand: numPubRand, + Commitment: randListInfo.Commitment, + } + msg := &types.MsgCommitPubRandList{ + Signer: datagen.GenRandomAccount().Address, + FpBtcPk: bip340PK, + StartHeight: startHeight, + NumPubRand: numPubRand, + Commitment: prCommit.Commitment, + } + hash, err := msg.HashToSign() + require.NoError(t, err) + schnorrSig, err := schnorr.Sign(sk, hash) + require.NoError(t, err) + msg.Sig = bbn.NewBIP340SignatureFromBTCSig(schnorrSig) + _, err = ms.CommitPubRandList(ctx, msg) + require.NoError(t, err) + + prCommitList = append(prCommitList, prCommit) + + startHeight += numPubRand + } + + resp, err := fKeeper.ListPubRandCommit(ctx, &types.QueryListPubRandCommitRequest{ + FpBtcPkHex: bip340PK.MarshalHex(), + }) + require.NoError(t, err) + + for _, prCommit := range prCommitList { + prCommitResp, ok := resp.PubRandCommitMap[prCommit.StartHeight] + require.True(t, ok) + require.Equal(t, prCommitResp.NumPubRand, prCommit.NumPubRand) + require.Equal(t, prCommitResp.Commitment, prCommit.Commitment) + } + }) +} + func FuzzQueryEvidence(f *testing.F) { datagen.AddRandomSeedsToFuzzer(f, 10) f.Fuzz(func(t *testing.T, seed int64) { @@ -327,3 +364,73 @@ func FuzzListEvidences(f *testing.F) { } }) } + +func FuzzSigningInfo(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 + fKeeper, ctx := testkeeper.FinalityKeeper(t, nil, nil) + ctx = sdk.UnwrapSDKContext(ctx) + + // generate a random list of signing info + numSigningInfo := datagen.RandomInt(r, 100) + 10 + + fpSigningInfos := map[string]*types.FinalityProviderSigningInfo{} + fpPks := make([]string, 0) + for i := uint64(0); i < numSigningInfo; i++ { + // random key pair + fpPk, err := datagen.GenRandomBIP340PubKey(r) + require.NoError(t, err) + fpPks = append(fpPks, fpPk.MarshalHex()) + + // random height and missed block counter + height := int64(datagen.RandomInt(r, 100) + 1) + missedBlockCounter := int64(datagen.RandomInt(r, 100) + 1) + + // create signing info and add it to map and finality keeper + signingInfo := types.NewFinalityProviderSigningInfo(fpPk, height, missedBlockCounter) + err = fKeeper.FinalityProviderSigningTracker.Set(ctx, fpPk.MustMarshal(), signingInfo) + require.NoError(t, err) + fpSigningInfos[fpPk.MarshalHex()] = &signingInfo + } + + // perform queries for signing info of a given finality provider + for i := uint64(0); i < numSigningInfo; i++ { + fpPk := fpPks[i] + 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()) + } + + // perform a query for signing info of non-exist finality provider + nonExistFpPk, err := datagen.GenRandomBIP340PubKey(r) + require.NoError(t, err) + require.NoError(t, err) + invalidReq := &types.QuerySigningInfoRequest{FpBtcPkHex: nonExistFpPk.MarshalHex()} + _, err = fKeeper.SigningInfo(ctx, invalidReq) + require.Contains(t, err.Error(), fmt.Sprintf("SigningInfo not found for the finality provider %s", nonExistFpPk.MarshalHex())) + + // perform a query for signing infos of all the finality providers + limit := datagen.RandomInt(r, int(numSigningInfo)) + 1 + req := &types.QuerySigningInfosRequest{ + Pagination: &query.PageRequest{ + CountTotal: true, + Limit: limit, + }, + } + resp, err := fKeeper.SigningInfos(ctx, req) + require.NoError(t, err) + require.LessOrEqual(t, len(resp.FpSigningInfos), 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) + } + }) +} diff --git a/x/finality/keeper/hooks.go b/x/finality/keeper/hooks.go new file mode 100644 index 000000000..ba2140001 --- /dev/null +++ b/x/finality/keeper/hooks.go @@ -0,0 +1,41 @@ +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/indexed_blocks.go b/x/finality/keeper/indexed_blocks.go index fd7fc0771..00d3bd649 100644 --- a/x/finality/keeper/indexed_blocks.go +++ b/x/finality/keeper/indexed_blocks.go @@ -4,7 +4,7 @@ import ( "context" "cosmossdk.io/store/prefix" - "github.com/babylonchain/babylon/x/finality/types" + "github.com/babylonlabs-io/babylon/x/finality/types" "github.com/cosmos/cosmos-sdk/runtime" sdk "github.com/cosmos/cosmos-sdk/types" ) @@ -19,6 +19,9 @@ func (k Keeper) IndexBlock(ctx context.Context) { Finalized: false, } k.SetBlock(ctx, ib) + + // record the block height + types.RecordLastHeight(uint64(headerInfo.Height)) } func (k Keeper) SetBlock(ctx context.Context, block *types.IndexedBlock) { diff --git a/x/finality/keeper/keeper.go b/x/finality/keeper/keeper.go index ebea17422..fe185a569 100644 --- a/x/finality/keeper/keeper.go +++ b/x/finality/keeper/keeper.go @@ -1,15 +1,16 @@ package keeper import ( + "context" "fmt" + "cosmossdk.io/collections" corestoretypes "cosmossdk.io/core/store" - "cosmossdk.io/log" "github.com/cosmos/cosmos-sdk/codec" sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/babylonchain/babylon/x/finality/types" + "github.com/babylonlabs-io/babylon/x/finality/types" ) type ( @@ -22,26 +23,63 @@ type ( // the address capable of executing a MsgUpdateParams message. Typically, this // 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 + FinalityProviderMissedBlockBitmap collections.Map[collections.Pair[[]byte, uint64], []byte] } ) func NewKeeper( cdc codec.BinaryCodec, storeService corestoretypes.KVStoreService, - btctakingKeeper types.BTCStakingKeeper, + btcstakingKeeper types.BTCStakingKeeper, incentiveKeeper types.IncentiveKeeper, authority string, ) Keeper { + sb := collections.NewSchemaBuilder(storeService) return Keeper{ cdc: cdc, storeService: storeService, - BTCStakingKeeper: btctakingKeeper, + BTCStakingKeeper: btcstakingKeeper, IncentiveKeeper: incentiveKeeper, authority: authority, + FinalityProviderSigningTracker: collections.NewMap( + sb, + types.FinalityProviderSigningInfoKeyPrefix, + "finality_provider_signing_info", + collections.BytesKey, + codec.CollValue[types.FinalityProviderSigningInfo](cdc), + ), + FinalityProviderMissedBlockBitmap: collections.NewMap( + sb, + types.FinalityProviderMissedBlockBitmapKeyPrefix, + "finality_provider_missed_block_bitmap", + collections.PairKeyCodec(collections.BytesKey, collections.Uint64Key), + collections.BytesValue, + ), + } +} + +// 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 + + return k } func (k Keeper) Logger(ctx sdk.Context) log.Logger { return ctx.Logger().With("module", fmt.Sprintf("x/%s", types.ModuleName)) } + +func (k Keeper) GetLastFinalizedEpoch(ctx context.Context) uint64 { + return k.BTCStakingKeeper.GetLastFinalizedEpoch(ctx) +} diff --git a/x/finality/keeper/liveness.go b/x/finality/keeper/liveness.go new file mode 100644 index 000000000..59cf453cc --- /dev/null +++ b/x/finality/keeper/liveness.go @@ -0,0 +1,202 @@ +package keeper + +import ( + "context" + "fmt" + + sdk "github.com/cosmos/cosmos-sdk/types" + + "github.com/babylonlabs-io/babylon/types" + finalitytypes "github.com/babylonlabs-io/babylon/x/finality/types" +) + +// HandleLiveness handles liveness of each active finality provider for a given height +// including identifying 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)) + // get all the voters for the height + voterBTCPKs := k.GetVoters(ctx, uint64(height)) + + // Iterate over all the finality providers which *should* have signed this block + // store whether or not they have actually signed it, identify sluggish + // ones, and apply punishment (TBD) + for fpPkHex := range fpSet { + fpPk, err := types.NewBIP340PubKeyFromHex(fpPkHex) + if err != nil { + panic(fmt.Errorf("invalid finality provider public key %s: %w", fpPkHex, err)) + } + + _, ok := voterBTCPKs[fpPkHex] + missed := !ok + + err = k.HandleFinalityProviderLiveness(ctx, fpPk, missed, height) + if err != nil { + panic(fmt.Errorf("failed to handle liveness of finality provider %s: %w", fpPkHex, err)) + } + } +} + +// HandleFinalityProviderLiveness updates the voting history of the given finality provider and +// detect sluggish the finality provider if the number of missed block is reached to the threshold in a +// sliding window +func (k Keeper) HandleFinalityProviderLiveness(ctx context.Context, fpPk *types.BIP340PubKey, missed bool, height int64) error { + params := k.GetParams(ctx) + fp, err := k.BTCStakingKeeper.GetFinalityProvider(ctx, fpPk.MustMarshal()) + if err != nil { + return err + } + + // don't update missed blocks when finality provider is already detected slashed + if fp.IsSlashed() { + return nil + } + + updated, signInfo, err := k.updateSigningInfo(ctx, fpPk, missed, height) + if err != nil { + return err + } + + signedBlocksWindow := params.SignedBlocksWindow + minSignedPerWindow := params.MinSignedPerWindowInt() + + sdkCtx := sdk.UnwrapSDKContext(ctx) + if missed { + k.Logger(sdkCtx).Debug( + "absent finality provider", + "height", height, + "public_key", fpPk.MarshalHex(), + "missed", signInfo.MissedBlocksCounter, + "threshold", minSignedPerWindow, + ) + } + + minHeight := signInfo.StartHeight + signedBlocksWindow + maxMissed := signedBlocksWindow - minSignedPerWindow + + // if we are past the minimum height and the finality provider has missed too many blocks, punish them + if height > minHeight && signInfo.MissedBlocksCounter > maxMissed { + updated = true + + k.Logger(sdkCtx).Info( + "detected sluggish finality provider", + "height", height, + "public_key", fpPk.MarshalHex(), + "missed_count", signInfo.MissedBlocksCounter, + "threshold", minSignedPerWindow, + "window_size", signedBlocksWindow, + ) + + // Inactivity detected + err = k.hooks.AfterSluggishFinalityProviderDetected(ctx, fpPk) + if err != nil { + return err + } + + if err := sdkCtx.EventManager().EmitTypedEvent( + finalitytypes.NewEventSluggishFinalityProviderDetected(fpPk), + ); err != nil { + panic(fmt.Errorf("failed to emit sluggish finality provider detected event for height %d: %w", height, err)) + } + + finalitytypes.IncrementSluggishFinalityProviderCounter() + } else if fp.IsSluggish() { + updated = true + + k.Logger(sdkCtx).Info( + "reverted sluggish finality provider", + "height", height, + "public_key", fpPk.MarshalHex(), + ) + + // change the sluggish flag of the finality provider to false + err = k.BTCStakingKeeper.RevertSluggishFinalityProvider(ctx, fpPk.MustMarshal()) + if err != nil { + return fmt.Errorf("failed to revert sluggish finality provider %s: %w", fpPk.MarshalHex(), err) + } + + if err := sdkCtx.EventManager().EmitTypedEvent( + finalitytypes.NewEventSluggishFinalityProviderReverted(fpPk), + ); err != nil { + panic(fmt.Errorf("failed to emit sluggish finality provider reverted event for height %d: %w", height, err)) + } + + finalitytypes.DecrementSluggishFinalityProviderCounter() + } + + // Set the updated signing info + if updated { + return k.FinalityProviderSigningTracker.Set(ctx, fpPk.MustMarshal(), *signInfo) + } + + return nil +} + +func (k Keeper) updateSigningInfo( + ctx context.Context, + fpPk *types.BIP340PubKey, + missed bool, + height int64, +) (bool, *finalitytypes.FinalityProviderSigningInfo, error) { + params := k.GetParams(ctx) + // fetch signing info + signInfo, err := k.FinalityProviderSigningTracker.Get(ctx, fpPk.MustMarshal()) + if err != nil { + return false, nil, err + } + + signedBlocksWindow := params.SignedBlocksWindow + + // Compute the relative index, so we count the blocks the finality provider *should* + // have signed. We will also use the 0-value default signing info if not present. + // The index is in the range [0, SignedBlocksWindow) + // and is used to see if a finality provider signed a block at the given height, which + // is represented by a bit in the bitmap. + // The finality provider start height should get mapped to index 0, so we computed index as: + // (height - startHeight) % signedBlocksWindow + // + // NOTE: There is subtle different behavior between genesis finality provider and non-genesis + // finality providers. + // A genesis finality provider will start at index 0, whereas a non-genesis finality provider's + // startHeight will be the block they become active for, but the first block they vote on will be + // one later. (And thus their first vote is at index 1) + if signInfo.StartHeight > height { + return false, nil, fmt.Errorf("invalid state, the finality provider signing info has start height %d, which is greater than the current height %d", + signInfo.StartHeight, height) + } + index := (height - signInfo.StartHeight) % signedBlocksWindow + + // determine if the finality provider signed the previous block + previous, err := k.GetMissedBlockBitmapValue(ctx, fpPk, index) + if err != nil { + return false, nil, fmt.Errorf("failed to get the finality provider's bitmap value: %w", err) + } + + modifiedSignInfo := false + switch { + case !previous && missed: + // Bitmap value has changed from not missed to missed, so we flip the bit + // and increment the counter. + if err := k.SetMissedBlockBitmapValue(ctx, fpPk, index, true); err != nil { + return false, nil, err + } + + signInfo.IncrementMissedBlocksCounter() + modifiedSignInfo = true + + case previous && !missed: + // Bitmap value has changed from missed to not missed, so we flip the bit + // and decrement the counter. + if err := k.SetMissedBlockBitmapValue(ctx, fpPk, index, false); err != nil { + return false, nil, err + } + + signInfo.DecrementMissedBlocksCounter() + modifiedSignInfo = true + + default: + // bitmap value at this index has not changed, no need to update counter + } + + return modifiedSignInfo, &signInfo, nil +} diff --git a/x/finality/keeper/liveness_test.go b/x/finality/keeper/liveness_test.go new file mode 100644 index 000000000..da92702e5 --- /dev/null +++ b/x/finality/keeper/liveness_test.go @@ -0,0 +1,90 @@ +package keeper_test + +import ( + "math/rand" + "testing" + + "github.com/golang/mock/gomock" + "github.com/stretchr/testify/require" + + "github.com/babylonlabs-io/babylon/testutil/datagen" + keepertest "github.com/babylonlabs-io/babylon/testutil/keeper" + bstypes "github.com/babylonlabs-io/babylon/x/btcstaking/types" + "github.com/babylonlabs-io/babylon/x/finality/types" +) + +func FuzzHandleLiveness(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) + bsKeeper.EXPECT().GetParams(gomock.Any()).Return(bstypes.Params{MaxActiveFinalityProviders: 100}).AnyTimes() + iKeeper := types.NewMockIncentiveKeeper(ctrl) + fKeeper, ctx := keepertest.FinalityKeeper(t, bsKeeper, iKeeper) + + 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) + bsKeeper.EXPECT().GetFinalityProvider(gomock.Any(), fpPk.MustMarshal()).Return(&bstypes.FinalityProvider{Sluggish: false}, nil).AnyTimes() + signingInfo := types.NewFinalityProviderSigningInfo( + fpPk, + 1, + 0, + ) + err = fKeeper.FinalityProviderSigningTracker.Set(ctx, fpPk.MustMarshal(), signingInfo) + require.NoError(t, err) + + // activate BTC staking protocol at a random height + activatedHeight := int64(datagen.RandomInt(r, 10) + 1) + + // for signed blocks, mark the finality provider as having signed + height := activatedHeight + for ; height < activatedHeight+params.SignedBlocksWindow; height++ { + err := fKeeper.HandleFinalityProviderLiveness(ctx, fpPk, false, height) + require.NoError(t, err) + } + signingInfo, err = fKeeper.FinalityProviderSigningTracker.Get(ctx, fpPk.MustMarshal()) + require.NoError(t, err) + require.Equal(t, int64(0), signingInfo.MissedBlocksCounter) + + minSignedPerWindow := params.MinSignedPerWindowInt() + maxMissed := params.SignedBlocksWindow - minSignedPerWindow + // for blocks up to the inactivity boundary, mark the finality provider as having not signed + sluggishDetectedHeight := height + maxMissed + 1 + for ; height < sluggishDetectedHeight; height++ { + err := fKeeper.HandleFinalityProviderLiveness(ctx, fpPk, true, height) + require.NoError(t, err) + signingInfo, err = fKeeper.FinalityProviderSigningTracker.Get(ctx, fpPk.MustMarshal()) + require.NoError(t, err) + if height < sluggishDetectedHeight-1 { + require.GreaterOrEqual(t, maxMissed, signingInfo.MissedBlocksCounter) + } else { + require.Less(t, maxMissed, signingInfo.MissedBlocksCounter) + } + } + + // perform heights that not missed, expect the sluggish is reverted + bsKeeper.EXPECT().RevertSluggishFinalityProvider(gomock.Any(), fpPk.MustMarshal()).Return(nil).AnyTimes() + sluggishRevertedHeight := height + maxMissed + for ; height < sluggishRevertedHeight; height++ { + err := fKeeper.HandleFinalityProviderLiveness(ctx, fpPk, false, height) + require.NoError(t, err) + signingInfo, err = fKeeper.FinalityProviderSigningTracker.Get(ctx, fpPk.MustMarshal()) + require.NoError(t, err) + if height < sluggishRevertedHeight-1 { + require.Less(t, maxMissed, signingInfo.MissedBlocksCounter) + } else { + // the sluggish fp is reverted + require.Equal(t, maxMissed, signingInfo.MissedBlocksCounter) + } + } + }) +} diff --git a/x/finality/keeper/msg_server.go b/x/finality/keeper/msg_server.go index 6b3ced4a7..3576f7cd1 100644 --- a/x/finality/keeper/msg_server.go +++ b/x/finality/keeper/msg_server.go @@ -4,12 +4,13 @@ import ( "bytes" "context" "fmt" + "time" errorsmod "cosmossdk.io/errors" - "github.com/babylonchain/babylon/crypto/eots" - bbn "github.com/babylonchain/babylon/types" - bstypes "github.com/babylonchain/babylon/x/btcstaking/types" - "github.com/babylonchain/babylon/x/finality/types" + bbn "github.com/babylonlabs-io/babylon/types" + bstypes "github.com/babylonlabs-io/babylon/x/btcstaking/types" + "github.com/babylonlabs-io/babylon/x/finality/types" + "github.com/cosmos/cosmos-sdk/telemetry" sdk "github.com/cosmos/cosmos-sdk/types" govtypes "github.com/cosmos/cosmos-sdk/x/gov/types" ) @@ -45,6 +46,8 @@ func (ms msgServer) UpdateParams(goCtx context.Context, req *types.MsgUpdatePara // AddFinalitySig adds a new vote to a given block func (ms msgServer) AddFinalitySig(goCtx context.Context, req *types.MsgAddFinalitySig) (*types.MsgAddFinalitySigResponse, error) { + defer telemetry.ModuleMeasureSince(types.ModuleName, time.Now(), types.MetricsKeyAddFinalitySig) + ctx := sdk.UnwrapSDKContext(goCtx) // ensure the finality provider exists @@ -93,20 +96,19 @@ func (ms msgServer) AddFinalitySig(goCtx context.Context, req *types.MsgAddFinal return &types.MsgAddFinalitySigResponse{}, nil } - // ensure the finality provider has committed public randomness - pubRand, err := ms.GetPubRand(ctx, fpPK, req.BlockHeight) + // find the public randomness commitment for this height from this finality provider + prCommit, err := ms.GetPubRandCommitForHeight(ctx, req.FpBtcPk, req.BlockHeight) if err != nil { - return nil, types.ErrPubRandNotFound + return nil, err } - // verify EOTS signature w.r.t. public randomness - fpBTCPK, err := fpPK.ToBTCPK() - if err != nil { + // verify the finality signature message w.r.t. the public randomness commitment + // including the public randomness inclusion proof and the finality signature + if err := types.VerifyFinalitySig(req, prCommit); err != nil { return nil, err } - if err := eots.Verify(fpBTCPK, pubRand.ToFieldVal(), req.MsgToSign(), req.FinalitySig.ToModNScalar()); err != nil { - return nil, types.ErrInvalidFinalitySig.Wrapf("the EOTS signature is invalid: %v", err) - } + // the public randomness is good, set the public randomness + ms.SetPubRand(ctx, req.FpBtcPk, req.BlockHeight, *req.PubRand) // verify whether the voted block is a fork or not indexedBlock, err := ms.GetBlock(ctx, req.BlockHeight) @@ -120,7 +122,7 @@ func (ms msgServer) AddFinalitySig(goCtx context.Context, req *types.MsgAddFinal evidence := &types.Evidence{ FpBtcPk: req.FpBtcPk, BlockHeight: req.BlockHeight, - PubRand: pubRand, + PubRand: req.PubRand, CanonicalAppHash: indexedBlock.AppHash, CanonicalFinalitySig: nil, ForkAppHash: req.BlockAppHash, @@ -174,14 +176,17 @@ func (ms msgServer) AddFinalitySig(goCtx context.Context, req *types.MsgAddFinal // CommitPubRandList commits a list of EOTS public randomness func (ms msgServer) CommitPubRandList(goCtx context.Context, req *types.MsgCommitPubRandList) (*types.MsgCommitPubRandListResponse, error) { + defer telemetry.ModuleMeasureSince(types.ModuleName, time.Now(), types.MetricsKeyCommitPubRandList) + ctx := sdk.UnwrapSDKContext(goCtx) // ensure the request contains enough number of public randomness minPubRand := ms.GetParams(ctx).MinPubRand - givenPubRand := len(req.PubRandList) - if uint64(givenPubRand) < minPubRand { - return nil, types.ErrTooFewPubRand.Wrapf("required minimum: %d, actual: %d", minPubRand, givenPubRand) + givenNumPubRand := req.NumPubRand + if givenNumPubRand < minPubRand { + return nil, types.ErrTooFewPubRand.Wrapf("required minimum: %d, actual: %d", minPubRand, givenNumPubRand) } + // TODO: ensure log_2(givenNumPubRand) is an integer? // ensure the finality provider is registered if req.FpBtcPk == nil { @@ -192,29 +197,36 @@ func (ms msgServer) CommitPubRandList(goCtx context.Context, req *types.MsgCommi return nil, bstypes.ErrFpNotFound.Wrapf("the finality provider with BTC PK %v is not registered", fpBTCPKBytes) } + // verify signature over the public randomness commitment + if err := req.VerifySig(); err != nil { + return nil, types.ErrInvalidPubRand.Wrapf("invalid signature over the public randomness list: %v", err) + } + + prCommit := &types.PubRandCommit{ + StartHeight: req.StartHeight, + NumPubRand: req.NumPubRand, + Commitment: req.Commitment, + } + + // get last public randomness commitment + // TODO: allow committing public randomness earlier than existing ones? + lastPrCommit := ms.GetLastPubRandCommit(ctx, req.FpBtcPk) + // this finality provider has not commit any public randomness, // commit the given public randomness list and return - if ms.IsFirstPubRand(ctx, req.FpBtcPk) { - ms.SetPubRandList(ctx, req.FpBtcPk, req.StartHeight, req.PubRandList) + if lastPrCommit == nil { + ms.SetPubRandCommit(ctx, req.FpBtcPk, prCommit) return &types.MsgCommitPubRandListResponse{}, nil } // ensure height and req.StartHeight do not overlap, i.e., height < req.StartHeight - height, _, err := ms.GetLastPubRand(ctx, req.FpBtcPk) - if err != nil { - return nil, err - } - if height >= req.StartHeight { - return nil, types.ErrInvalidPubRand.Wrapf("the start height (%d) has overlap with the height of the highest public randomness (%d)", req.StartHeight, height) - } - - // verify signature over the list - if err := req.VerifySig(); err != nil { - return nil, types.ErrInvalidPubRand.Wrapf("invalid signature over the public randomness list: %v", err) + lastPrHeightCommitted := lastPrCommit.EndHeight() + if req.StartHeight <= lastPrCommit.EndHeight() { + return nil, types.ErrInvalidPubRand.Wrapf("the start height (%d) has overlap with the height of the highest public randomness committed (%d)", req.StartHeight, lastPrHeightCommitted) } // all good, commit the given public randomness list - ms.SetPubRandList(ctx, req.FpBtcPk, req.StartHeight, req.PubRandList) + ms.SetPubRandCommit(ctx, req.FpBtcPk, prCommit) return &types.MsgCommitPubRandListResponse{}, nil } diff --git a/x/finality/keeper/msg_server_test.go b/x/finality/keeper/msg_server_test.go index eab9337bb..231ef895e 100644 --- a/x/finality/keeper/msg_server_test.go +++ b/x/finality/keeper/msg_server_test.go @@ -4,14 +4,15 @@ import ( "context" "math/rand" "testing" + "time" "cosmossdk.io/core/header" - "github.com/babylonchain/babylon/testutil/datagen" - keepertest "github.com/babylonchain/babylon/testutil/keeper" - bbn "github.com/babylonchain/babylon/types" - bstypes "github.com/babylonchain/babylon/x/btcstaking/types" - "github.com/babylonchain/babylon/x/finality/keeper" - "github.com/babylonchain/babylon/x/finality/types" + "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" "github.com/golang/mock/gomock" "github.com/stretchr/testify/require" ) @@ -72,10 +73,8 @@ func FuzzCommitPubRandList(f *testing.F) { _, err = ms.CommitPubRandList(ctx, msg) require.NoError(t, err) // query last public randomness and assert - actualHeight, actualPubRand, err := fKeeper.GetLastPubRand(ctx, fpBTCPK) - require.NoError(t, err) - require.Equal(t, startHeight+numPubRand-1, actualHeight) - require.Equal(t, msg.PubRandList[len(msg.PubRandList)-1].MustMarshal(), actualPubRand.MustMarshal()) + lastPrCommit := fKeeper.GetLastPubRandCommit(ctx, fpBTCPK) + require.NotNil(t, lastPrCommit) // Case 4: commit a pubrand list with overlap of the existing pubrand in KVStore and it should fail overlappedStartHeight := startHeight + numPubRand - 1 - datagen.RandomInt(r, 5) @@ -90,11 +89,6 @@ func FuzzCommitPubRandList(f *testing.F) { require.NoError(t, err) _, err = ms.CommitPubRandList(ctx, msg) require.NoError(t, err) - // query last public randomness and assert - actualHeight, actualPubRand, err = fKeeper.GetLastPubRand(ctx, fpBTCPK) - require.NoError(t, err) - require.Equal(t, nonOverlappedStartHeight+numPubRand-1, actualHeight) - require.Equal(t, msg.PubRandList[len(msg.PubRandList)-1].MustMarshal(), actualPubRand.MustMarshal()) }) } @@ -122,17 +116,16 @@ func FuzzAddFinalitySig(f *testing.F) { // commit some public randomness startHeight := uint64(0) numPubRand := uint64(200) - srList, msgCommitPubRandList, err := datagen.GenRandomMsgCommitPubRandList(r, btcSK, startHeight, numPubRand) + 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 := uint64(1) - sr, _ := srList[startHeight+blockHeight], msgCommitPubRandList.PubRandList[startHeight+blockHeight] - blockHash := datagen.GenRandomByteArray(r, 32) + blockHeight := startHeight + uint64(1) + blockAppHash := datagen.GenRandomByteArray(r, 32) signer := datagen.GenRandomAccount().Address - msg, err := types.NewMsgAddFinalitySig(signer, btcSK, sr, blockHeight, blockHash) + msg, err := datagen.NewMsgAddFinalitySig(signer, btcSK, startHeight, blockHeight, randListInfo, blockAppHash) require.NoError(t, err) // Case 1: fail if the finality provider does not have voting power @@ -156,7 +149,7 @@ func FuzzAddFinalitySig(f *testing.F) { // 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: blockHash}) + ctx = ctx.WithHeaderInfo(header.Info{Height: int64(blockHeight), AppHash: blockAppHash}) fKeeper.IndexBlock(ctx) bsKeeper.EXPECT().GetFinalityProvider(gomock.Any(), gomock.Eq(fpBTCPKBytes)).Return(fp, nil).Times(1) // add vote and it should work @@ -174,8 +167,8 @@ func FuzzAddFinalitySig(f *testing.F) { require.NotNil(t, resp) // Case 5: the finality provider is slashed if it votes for a fork - blockHash2 := datagen.GenRandomByteArray(r, 32) - msg2, err := types.NewMsgAddFinalitySig(signer, btcSK, sr, blockHeight, blockHash2) + blockAppHash2 := datagen.GenRandomByteArray(r, 32) + msg2, err := datagen.NewMsgAddFinalitySig(signer, btcSK, startHeight, blockHeight, randListInfo, blockAppHash2) require.NoError(t, err) bsKeeper.EXPECT().GetFinalityProvider(gomock.Any(), gomock.Eq(fpBTCPKBytes)).Return(fp, nil).Times(1) // mock slashing interface @@ -202,10 +195,80 @@ func FuzzAddFinalitySig(f *testing.F) { require.True(t, btcSK.Key.Equals(&btcSK2.Key) || btcSK.Key.Negate().Equals(&btcSK2.Key)) require.Equal(t, btcSK.PubKey().SerializeCompressed()[1:], btcSK2.PubKey().SerializeCompressed()[1:]) - // Case 6: slashed finality proivder cannot vote + // Case 6: slashed finality provider cannot vote fp.SlashedBabylonHeight = blockHeight bsKeeper.EXPECT().GetFinalityProvider(gomock.Any(), gomock.Eq(fpBTCPKBytes)).Return(fp, nil).Times(1) _, err = ms.AddFinalitySig(ctx, msg) require.Equal(t, bstypes.ErrFpAlreadySlashed, err) }) } + +func TestVoteForConflictingHashShouldRetrieveEvidenceAndSlash(t *testing.T) { + r := rand.New(rand.NewSource(time.Now().UnixNano())) + ctrl := gomock.NewController(t) + defer ctrl.Finish() + bsKeeper := types.NewMockBTCStakingKeeper(ctrl) + fKeeper, ctx := keepertest.FinalityKeeper(t, bsKeeper, nil) + 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() + // 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) + // set a block height of 1 and some random list + blockHeight := startHeight + uint64(1) + + // generate two random hashes, one for the canonical block and + // one for a fork block + canonicalHash := datagen.GenRandomByteArray(r, 32) + forkHash := datagen.GenRandomByteArray(r, 32) + signer := datagen.GenRandomAccount().Address + require.NoError(t, err) + // (1) Set a canonical hash at height 1 + ctx = ctx.WithHeaderInfo(header.Info{Height: int64(blockHeight), AppHash: canonicalHash}) + fKeeper.IndexBlock(ctx) + // (2) Vote for a different block at height 1, this will make us have + // some "evidence" + 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() + bsKeeper.EXPECT().GetFinalityProvider(gomock.Any(), + gomock.Eq(fpBTCPKBytes)).Return(fp, nil).Times(1) + _, err = ms.AddFinalitySig(ctx, msg1) + require.NoError(t, err) + // (3) Now vote for the canonical block at height 1. This should slash Finality provider + 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() + bsKeeper.EXPECT().GetFinalityProvider(gomock.Any(), + gomock.Eq(fpBTCPKBytes)).Return(fp, nil).Times(1) + bsKeeper.EXPECT().SlashFinalityProvider(gomock.Any(), + gomock.Eq(fpBTCPKBytes)).Return(nil).Times(1) + _, err = ms.AddFinalitySig(ctx, msg) + require.NoError(t, err) + sig, err := fKeeper.GetSig(ctx, blockHeight, fpBTCPK) + require.NoError(t, err) + require.Equal(t, msg.FinalitySig.MustMarshal(), + sig.MustMarshal()) +} diff --git a/x/finality/keeper/params.go b/x/finality/keeper/params.go index 2b0d78a79..7ee128b5f 100644 --- a/x/finality/keeper/params.go +++ b/x/finality/keeper/params.go @@ -2,7 +2,8 @@ package keeper import ( "context" - "github.com/babylonchain/babylon/x/finality/types" + + "github.com/babylonlabs-io/babylon/x/finality/types" ) // SetParams sets the x/finality module parameters. diff --git a/x/finality/keeper/params_test.go b/x/finality/keeper/params_test.go index b34d260d5..649fd3eda 100644 --- a/x/finality/keeper/params_test.go +++ b/x/finality/keeper/params_test.go @@ -3,8 +3,8 @@ package keeper_test import ( "testing" - testkeeper "github.com/babylonchain/babylon/testutil/keeper" - "github.com/babylonchain/babylon/x/finality/types" + testkeeper "github.com/babylonlabs-io/babylon/testutil/keeper" + "github.com/babylonlabs-io/babylon/x/finality/types" "github.com/stretchr/testify/require" ) diff --git a/x/finality/keeper/public_randomness.go b/x/finality/keeper/public_randomness.go index d83abdf36..68cb87e84 100644 --- a/x/finality/keeper/public_randomness.go +++ b/x/finality/keeper/public_randomness.go @@ -7,35 +7,91 @@ import ( "github.com/cosmos/cosmos-sdk/runtime" "cosmossdk.io/store/prefix" - bbn "github.com/babylonchain/babylon/types" - "github.com/babylonchain/babylon/x/finality/types" + bbn "github.com/babylonlabs-io/babylon/types" + "github.com/babylonlabs-io/babylon/x/finality/types" sdk "github.com/cosmos/cosmos-sdk/types" ) -// SetPubRandList sets a list of public randomness starting from a given startHeight -// for a given finality provider -func (k Keeper) SetPubRandList(ctx context.Context, fpBtcPK *bbn.BIP340PubKey, startHeight uint64, pubRandList []bbn.SchnorrPubRand) { - sdkCtx := sdk.UnwrapSDKContext(ctx) - cacheCtx, writeCache := sdkCtx.CacheContext() - - // write to a KV store cache - store := k.pubRandStore(cacheCtx, fpBtcPK) - for i, pr := range pubRandList { - height := startHeight + uint64(i) - store.Set(sdk.Uint64ToBigEndian(height), pr) +/* + Public randomness commitment storage +*/ + +// GetPubRandCommitForHeight finds the public randomness commitment that includes the given +// height for the given finality provider +func (k Keeper) GetPubRandCommitForHeight(ctx context.Context, fpBtcPK *bbn.BIP340PubKey, height uint64) (*types.PubRandCommit, error) { + store := k.pubRandCommitFpStore(ctx, fpBtcPK) + iter := store.ReverseIterator(nil, nil) + defer iter.Close() + + var prCommit types.PubRandCommit + for ; iter.Valid(); iter.Next() { + k.cdc.MustUnmarshal(iter.Value(), &prCommit) + if prCommit.IsInRange(height) { + return &prCommit, nil + } + } + return nil, types.ErrPubRandNotFound +} + +// SetPubRandCommit adds the given public randomness commitment for the given public key +func (k Keeper) SetPubRandCommit(ctx context.Context, fpBtcPK *bbn.BIP340PubKey, prCommit *types.PubRandCommit) { + store := k.pubRandCommitFpStore(ctx, fpBtcPK) + prcBytes := k.cdc.MustMarshal(prCommit) + store.Set(sdk.Uint64ToBigEndian(prCommit.StartHeight), prcBytes) +} + +// GetLastPubRandCommit retrieves the last public randomness commitment of the given finality provider +func (k Keeper) GetLastPubRandCommit(ctx context.Context, fpBtcPK *bbn.BIP340PubKey) *types.PubRandCommit { + store := k.pubRandCommitFpStore(ctx, fpBtcPK) + iter := store.ReverseIterator(nil, nil) + defer iter.Close() + + if !iter.Valid() { + // this finality provider does not commit any randomness + return nil } - // atomically write the new public randomness back to KV store - writeCache() + var prCommit types.PubRandCommit + k.cdc.MustUnmarshal(iter.Value(), &prCommit) + return &prCommit +} + +// pubRandCommitFpStore returns the KVStore of the commitment of public randomness +// prefix: PubRandKey +// key: (finality provider PK || block height of the commitment) +// value: PubRandCommit +func (k Keeper) pubRandCommitFpStore(ctx context.Context, fpBtcPK *bbn.BIP340PubKey) prefix.Store { + store := k.pubRandCommitStore(ctx) + return prefix.NewStore(store, fpBtcPK.MustMarshal()) +} + +// pubRandCommitStore returns the KVStore of the public randomness commitments +// prefix: PubRandKey +// key: (prefix) +// value: PubRandCommit +func (k Keeper) pubRandCommitStore(ctx context.Context) prefix.Store { + storeAdapter := runtime.KVStoreAdapter(k.storeService.OpenKVStore(ctx)) + return prefix.NewStore(storeAdapter, types.PubRandCommitKey) +} + +/* + Public randomness storage + TODO: remove public randomness storage? +*/ + +// SetPubRand sets a public randomness at a given height for a given finality provider +func (k Keeper) SetPubRand(ctx context.Context, fpBtcPK *bbn.BIP340PubKey, height uint64, pubRand bbn.SchnorrPubRand) { + store := k.pubRandFpStore(ctx, fpBtcPK) + store.Set(sdk.Uint64ToBigEndian(height), pubRand) } func (k Keeper) HasPubRand(ctx context.Context, fpBtcPK *bbn.BIP340PubKey, height uint64) bool { - store := k.pubRandStore(ctx, fpBtcPK) + store := k.pubRandFpStore(ctx, fpBtcPK) return store.Has(sdk.Uint64ToBigEndian(height)) } func (k Keeper) GetPubRand(ctx context.Context, fpBtcPK *bbn.BIP340PubKey, height uint64) (*bbn.SchnorrPubRand, error) { - store := k.pubRandStore(ctx, fpBtcPK) + store := k.pubRandFpStore(ctx, fpBtcPK) prBytes := store.Get(sdk.Uint64ToBigEndian(height)) if len(prBytes) == 0 { return nil, types.ErrPubRandNotFound @@ -43,18 +99,11 @@ func (k Keeper) GetPubRand(ctx context.Context, fpBtcPK *bbn.BIP340PubKey, heigh return bbn.NewSchnorrPubRand(prBytes) } -func (k Keeper) IsFirstPubRand(ctx context.Context, fpBtcPK *bbn.BIP340PubKey) bool { - store := k.pubRandStore(ctx, fpBtcPK) - iter := store.ReverseIterator(nil, nil) - - // if the iterator is not valid, then this finality provider does not commit any randomness - return !iter.Valid() -} - // GetLastPubRand retrieves the last public randomness committed by the given finality provider func (k Keeper) GetLastPubRand(ctx context.Context, fpBtcPK *bbn.BIP340PubKey) (uint64, *bbn.SchnorrPubRand, error) { - store := k.pubRandStore(ctx, fpBtcPK) + store := k.pubRandFpStore(ctx, fpBtcPK) iter := store.ReverseIterator(nil, nil) + defer iter.Close() if !iter.Valid() { // this finality provider does not commit any randomness @@ -70,12 +119,20 @@ func (k Keeper) GetLastPubRand(ctx context.Context, fpBtcPK *bbn.BIP340PubKey) ( return height, pubRand, nil } +// pubRandFpStore returns the KVStore of the public randomness +// prefix: PubRandKey +// key: (finality provider PK || block height) +// value: PublicRandomness +func (k Keeper) pubRandFpStore(ctx context.Context, fpBtcPK *bbn.BIP340PubKey) prefix.Store { + prefixedStore := k.pubRandStore(ctx) + return prefix.NewStore(prefixedStore, fpBtcPK.MustMarshal()) +} + // pubRandStore returns the KVStore of the public randomness // prefix: PubRandKey -// key: (finality provider || PK block height) +// key: (prefix) // value: PublicRandomness -func (k Keeper) pubRandStore(ctx context.Context, fpBtcPK *bbn.BIP340PubKey) prefix.Store { +func (k Keeper) pubRandStore(ctx context.Context) prefix.Store { storeAdapter := runtime.KVStoreAdapter(k.storeService.OpenKVStore(ctx)) - prefixedStore := prefix.NewStore(storeAdapter, types.PubRandKey) - return prefix.NewStore(prefixedStore, fpBtcPK.MustMarshal()) + return prefix.NewStore(storeAdapter, types.PubRandKey) } diff --git a/x/finality/keeper/public_randomness_bench_test.go b/x/finality/keeper/public_randomness_bench_test.go deleted file mode 100644 index 3c72a9d6d..000000000 --- a/x/finality/keeper/public_randomness_bench_test.go +++ /dev/null @@ -1,69 +0,0 @@ -package keeper_test - -import ( - "fmt" - "math/rand" - "os" - "runtime/pprof" - "testing" - "time" - - "github.com/babylonchain/babylon/testutil/datagen" - keepertest "github.com/babylonchain/babylon/testutil/keeper" - bbn "github.com/babylonchain/babylon/types" - "github.com/babylonchain/babylon/x/finality/keeper" - "github.com/babylonchain/babylon/x/finality/types" - "github.com/golang/mock/gomock" - "github.com/stretchr/testify/require" -) - -func benchmarkCommitPubRandList(b *testing.B, numPubRand uint64) { - r := rand.New(rand.NewSource(time.Now().Unix())) - ctrl := gomock.NewController(b) - defer ctrl.Finish() - - bsKeeper := types.NewMockBTCStakingKeeper(ctrl) - fKeeper, ctx := keepertest.FinalityKeeper(b, bsKeeper, nil) - ms := keeper.NewMsgServerImpl(*fKeeper) - - // create a random finality provider - btcSK, btcPK, err := datagen.GenRandomBTCKeyPair(r) - require.NoError(b, err) - fpBTCPK := bbn.NewBIP340PubKeyFromBTCPK(btcPK) - fpBTCPKBytes := fpBTCPK.MustMarshal() - - // register the finality provider - bsKeeper.EXPECT().HasFinalityProvider(gomock.Any(), gomock.Eq(fpBTCPKBytes)).Return(true).AnyTimes() - - // Start the CPU profiler - cpuProfileFile := fmt.Sprintf("/tmp/finality-commit-pub-rand-%d-cpu.pprof", numPubRand) - f, err := os.Create(cpuProfileFile) - if err != nil { - b.Fatal(err) - } - defer f.Close() - if err := pprof.StartCPUProfile(f); err != nil { - b.Fatal(err) - } - defer pprof.StopCPUProfile() - - // Reset timer before the benchmark loop starts - b.ResetTimer() - - for i := 0; i < b.N; i++ { - b.StopTimer() - - startHeight := 1 + numPubRand*uint64(i) - _, msg, err := datagen.GenRandomMsgCommitPubRandList(r, btcSK, startHeight, numPubRand) - require.NoError(b, err) - - b.StartTimer() - - _, err = ms.CommitPubRandList(ctx, msg) - require.NoError(b, err) - } -} - -func BenchmarkCommitPubRandList_100(b *testing.B) { benchmarkCommitPubRandList(b, 100) } -func BenchmarkCommitPubRandList_1000(b *testing.B) { benchmarkCommitPubRandList(b, 1000) } -func BenchmarkCommitPubRandList_10000(b *testing.B) { benchmarkCommitPubRandList(b, 10000) } diff --git a/x/finality/keeper/query.go b/x/finality/keeper/query.go index 8d23eb5b1..43483804f 100644 --- a/x/finality/keeper/query.go +++ b/x/finality/keeper/query.go @@ -1,7 +1,7 @@ package keeper import ( - "github.com/babylonchain/babylon/x/finality/types" + "github.com/babylonlabs-io/babylon/x/finality/types" ) var _ types.QueryServer = Keeper{} diff --git a/x/finality/keeper/query_params.go b/x/finality/keeper/query_params.go index 6d3d896f0..a24021da4 100644 --- a/x/finality/keeper/query_params.go +++ b/x/finality/keeper/query_params.go @@ -3,7 +3,7 @@ package keeper import ( "context" - "github.com/babylonchain/babylon/x/finality/types" + "github.com/babylonlabs-io/babylon/x/finality/types" sdk "github.com/cosmos/cosmos-sdk/types" "google.golang.org/grpc/codes" "google.golang.org/grpc/status" diff --git a/x/finality/keeper/query_params_test.go b/x/finality/keeper/query_params_test.go index 857747a54..2bdbfcc07 100644 --- a/x/finality/keeper/query_params_test.go +++ b/x/finality/keeper/query_params_test.go @@ -3,8 +3,8 @@ package keeper_test import ( "testing" - testkeeper "github.com/babylonchain/babylon/testutil/keeper" - "github.com/babylonchain/babylon/x/finality/types" + testkeeper "github.com/babylonlabs-io/babylon/testutil/keeper" + "github.com/babylonlabs-io/babylon/x/finality/types" "github.com/stretchr/testify/require" ) diff --git a/x/finality/keeper/signing_info.go b/x/finality/keeper/signing_info.go new file mode 100644 index 000000000..85fb5f605 --- /dev/null +++ b/x/finality/keeper/signing_info.go @@ -0,0 +1,149 @@ +package keeper + +import ( + "context" + "errors" + + "cosmossdk.io/collections" + errorsmod "cosmossdk.io/errors" + "github.com/bits-and-blooms/bitset" + + bbntypes "github.com/babylonlabs-io/babylon/types" + finalitytypes "github.com/babylonlabs-io/babylon/x/finality/types" +) + +// GetMissedBlockBitmapValue returns true if a finality provider missed signing +// a block at the given index and false otherwise. The index provided is assumed +// to be the index in the range [0, SignedBlocksWindow), which represents the bitmap +// where each bit represents a height, and is determined by the finality provider's +// IndexOffset modulo SignedBlocksWindow. This index is used to fetch the chunk +// in the bitmap and the relative bit in that chunk. +func (k Keeper) GetMissedBlockBitmapValue(ctx context.Context, fpPk *bbntypes.BIP340PubKey, index int64) (bool, error) { + // get the chunk or "word" in the logical bitmap + chunkIndex := index / finalitytypes.MissedBlockBitmapChunkSize + + bs := bitset.New(uint(finalitytypes.MissedBlockBitmapChunkSize)) + chunk, err := k.getMissedBlockBitmapChunk(ctx, fpPk, chunkIndex) + if err != nil { + return false, errorsmod.Wrapf(err, "failed to get bitmap chunk; index: %d", index) + } + + if chunk != nil { + if err := bs.UnmarshalBinary(chunk); err != nil { + return false, errorsmod.Wrapf(err, "failed to decode bitmap chunk; index: %d", index) + } + } + + // get the bit position in the chunk of the logical bitmap, where Test() + // checks if the bit is set. + bitIndex := index % finalitytypes.MissedBlockBitmapChunkSize + return bs.Test(uint(bitIndex)), nil +} + +// SetMissedBlockBitmapValue sets, i.e. flips, a bit in the finality provider's missed +// block bitmap. When missed=true, the bit is set, otherwise it set to zero. The +// index provided is assumed to be the index in the range [0, SignedBlocksWindow), +// which represents the bitmap where each bit represents a height, and is +// determined by the finality provider's IndexOffset modulo SignedBlocksWindow. This +// index is used to fetch the chunk in the bitmap and the relative bit in that +// chunk. +func (k Keeper) SetMissedBlockBitmapValue(ctx context.Context, fpPk *bbntypes.BIP340PubKey, index int64, missed bool) error { + // get the chunk or "word" in the logical bitmap + chunkIndex := index / finalitytypes.MissedBlockBitmapChunkSize + + bs := bitset.New(uint(finalitytypes.MissedBlockBitmapChunkSize)) + chunk, err := k.getMissedBlockBitmapChunk(ctx, fpPk, chunkIndex) + if err != nil { + return errorsmod.Wrapf(err, "failed to get bitmap chunk; index: %d", index) + } + + if chunk != nil { + if err := bs.UnmarshalBinary(chunk); err != nil { + return errorsmod.Wrapf(err, "failed to decode bitmap chunk; index: %d", index) + } + } + + // get the bit position in the chunk of the logical bitmap + bitIndex := uint(index % finalitytypes.MissedBlockBitmapChunkSize) + if missed { + bs.Set(bitIndex) + } else { + bs.Clear(bitIndex) + } + + updatedChunk, err := bs.MarshalBinary() + if err != nil { + return errorsmod.Wrapf(err, "failed to encode bitmap chunk; index: %d", index) + } + + return k.SetMissedBlockBitmapChunk(ctx, fpPk, chunkIndex, updatedChunk) +} + +// GetFinalityProviderMissedBlocks returns array of missed blocks for given finality provider. +// Adapted from +// https://github.com/cosmos/cosmos-sdk/blob/f499bbf2138b171d6e5396a37df7699952e76bf3/x/slashing/keeper/signing_info.go#L224 +func (k Keeper) GetFinalityProviderMissedBlocks(ctx context.Context, fpPk *bbntypes.BIP340PubKey) ([]finalitytypes.MissedBlock, error) { + signedBlocksWindow := k.GetParams(ctx).SignedBlocksWindow + + missedBlocks := make([]finalitytypes.MissedBlock, 0, signedBlocksWindow) + err := k.IterateMissedBlockBitmap(ctx, fpPk, func(index int64, missed bool) (stop bool) { + if missed { + missedBlocks = append(missedBlocks, finalitytypes.MissedBlock{Index: index, Missed: missed}) + } + + return false + }) + + return missedBlocks, err +} + +// IterateMissedBlockBitmap iterates over a finality provider's signed blocks window +// bitmap and performs a callback function on each index, i.e. block height, in +// the range [0, SignedBlocksWindow). +// Note: A callback will only be executed over all bitmap chunks that exist in +// state. +// Adapted from +// https://github.com/cosmos/cosmos-sdk/blob/f499bbf2138b171d6e5396a37df7699952e76bf3/x/slashing/keeper/signing_info.go#L202 +func (k Keeper) IterateMissedBlockBitmap(ctx context.Context, fpPk *bbntypes.BIP340PubKey, cb func(index int64, missed bool) (stop bool)) error { + var index int64 + rng := collections.NewPrefixedPairRange[[]byte, uint64](fpPk.MustMarshal()) + return k.FinalityProviderMissedBlockBitmap.Walk(ctx, rng, func(key collections.Pair[[]byte, uint64], value []byte) (bool, error) { + bs := bitset.New(uint(finalitytypes.MissedBlockBitmapChunkSize)) + + if err := bs.UnmarshalBinary(value); err != nil { + return true, errorsmod.Wrapf(err, "failed to decode bitmap chunk; index: %v", key) + } + + for i := uint(0); i < finalitytypes.MissedBlockBitmapChunkSize; i++ { + // execute the callback, where Test() returns true if the bit is set + if cb(index, bs.Test(i)) { + break + } + + index++ + } + return false, nil + }) +} + +// DeleteMissedBlockBitmap removes a finality provider's missed block bitmap from state. +func (k Keeper) DeleteMissedBlockBitmap(ctx context.Context, fpPk *bbntypes.BIP340PubKey) error { + rng := collections.NewPrefixedPairRange[[]byte, uint64](fpPk.MustMarshal()) + return k.FinalityProviderMissedBlockBitmap.Clear(ctx, rng) +} + +// SetMissedBlockBitmapChunk sets the bitmap chunk at the given chunk index for +// a finality provider's missed block signing window. +func (k Keeper) SetMissedBlockBitmapChunk(ctx context.Context, fpPk *bbntypes.BIP340PubKey, chunkIndex int64, chunk []byte) error { + return k.FinalityProviderMissedBlockBitmap.Set(ctx, collections.Join(fpPk.MustMarshal(), uint64(chunkIndex)), chunk) +} + +// getMissedBlockBitmapChunk gets the bitmap chunk at the given chunk index for +// a finality provider's missed block signing window. +func (k Keeper) getMissedBlockBitmapChunk(ctx context.Context, fpPk *bbntypes.BIP340PubKey, chunkIndex int64) ([]byte, error) { + chunk, err := k.FinalityProviderMissedBlockBitmap.Get(ctx, collections.Join(fpPk.MustMarshal(), uint64(chunkIndex))) + if err != nil && !errors.Is(err, collections.ErrNotFound) { + return nil, err + } + return chunk, nil +} diff --git a/x/finality/keeper/tallying.go b/x/finality/keeper/tallying.go index 68c1a4f0d..9af4c6fec 100644 --- a/x/finality/keeper/tallying.go +++ b/x/finality/keeper/tallying.go @@ -4,7 +4,7 @@ import ( "context" "fmt" - "github.com/babylonchain/babylon/x/finality/types" + "github.com/babylonlabs-io/babylon/x/finality/types" sdk "github.com/cosmos/cosmos-sdk/types" ) @@ -82,18 +82,21 @@ func (k Keeper) finalizeBlock(ctx context.Context, block *types.IndexedBlock, vo 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 reward distribution cache - rdc, err := k.BTCStakingKeeper.GetRewardDistCache(ctx, block.Height) + // 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 { - // failing to get a reward distribution cache before distributing reward is a programming error + // failing to get a voting power distribution cache before distributing reward is a programming error panic(err) } // filter out voted finality providers - rdc.FilterVotedFinalityProviders(voterBTCPKs) + maxActiveFPs := k.BTCStakingKeeper.GetParams(ctx).MaxActiveFinalityProviders + filteredDc := dc.FilterVotedDistCache(maxActiveFPs, voterBTCPKs) // reward voted finality providers - k.IncentiveKeeper.RewardBTCStaking(ctx, block.Height, rdc) + k.IncentiveKeeper.RewardBTCStaking(ctx, block.Height, filteredDc) // remove reward distribution cache afterwards - k.BTCStakingKeeper.RemoveRewardDistCache(ctx, block.Height) + k.BTCStakingKeeper.RemoveVotingPowerDistCache(ctx, block.Height) + // record the last finalized height metric + types.RecordLastFinalizedHeight(block.Height) } // tally checks whether a block with the given finality provider set and votes reaches a quorum or not diff --git a/x/finality/keeper/tallying_bench_test.go b/x/finality/keeper/tallying_bench_test.go index 6155d58a8..abe4c38ca 100644 --- a/x/finality/keeper/tallying_bench_test.go +++ b/x/finality/keeper/tallying_bench_test.go @@ -8,11 +8,11 @@ import ( "testing" "time" - "github.com/babylonchain/babylon/testutil/datagen" - keepertest "github.com/babylonchain/babylon/testutil/keeper" - bbn "github.com/babylonchain/babylon/types" - bstypes "github.com/babylonchain/babylon/x/btcstaking/types" - "github.com/babylonchain/babylon/x/finality/types" + "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" "github.com/golang/mock/gomock" "github.com/stretchr/testify/require" ) @@ -42,9 +42,9 @@ func benchmarkTallyBlocks(b *testing.B, numFPs int) { bsKeeper.EXPECT().GetVotingPowerTable(gomock.Any(), gomock.Any()).Return(fpSet).AnyTimes() // TODO: test incentive - bsKeeper.EXPECT().GetRewardDistCache(gomock.Any(), gomock.Any()).Return(bstypes.NewRewardDistCache(), nil).AnyTimes() + 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().RemoveRewardDistCache(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 aa4af547a..881985136 100644 --- a/x/finality/keeper/tallying_test.go +++ b/x/finality/keeper/tallying_test.go @@ -5,12 +5,12 @@ import ( "math/rand" "testing" - "github.com/babylonchain/babylon/testutil/datagen" - keepertest "github.com/babylonchain/babylon/testutil/keeper" - bbn "github.com/babylonchain/babylon/types" - bstypes "github.com/babylonchain/babylon/x/btcstaking/types" - "github.com/babylonchain/babylon/x/finality/keeper" - "github.com/babylonchain/babylon/x/finality/types" + "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" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/golang/mock/gomock" "github.com/stretchr/testify/require" @@ -97,6 +97,7 @@ 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) fKeeper, ctx := keepertest.FinalityKeeper(t, bsKeeper, iKeeper) @@ -124,9 +125,9 @@ func FuzzTallying_FinalizingSomeBlocks(f *testing.F) { } } // we don't test incentive in this function - bsKeeper.EXPECT().GetRewardDistCache(gomock.Any(), gomock.Any()).Return(bstypes.NewRewardDistCache(), nil).Times(int(numWithQCs)) + 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().RemoveRewardDistCache(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) diff --git a/x/finality/keeper/votes.go b/x/finality/keeper/votes.go index 44bd6352b..8014fa751 100644 --- a/x/finality/keeper/votes.go +++ b/x/finality/keeper/votes.go @@ -7,18 +7,18 @@ import ( "github.com/cosmos/cosmos-sdk/runtime" "cosmossdk.io/store/prefix" - bbn "github.com/babylonchain/babylon/types" - "github.com/babylonchain/babylon/x/finality/types" + bbn "github.com/babylonlabs-io/babylon/types" + "github.com/babylonlabs-io/babylon/x/finality/types" sdk "github.com/cosmos/cosmos-sdk/types" ) func (k Keeper) SetSig(ctx context.Context, height uint64, fpBtcPK *bbn.BIP340PubKey, sig *bbn.SchnorrEOTSSig) { - store := k.voteStore(ctx, height) + store := k.voteHeightStore(ctx, height) store.Set(fpBtcPK.MustMarshal(), sig.MustMarshal()) } func (k Keeper) HasSig(ctx context.Context, height uint64, fpBtcPK *bbn.BIP340PubKey) bool { - store := k.voteStore(ctx, height) + store := k.voteHeightStore(ctx, height) return store.Has(fpBtcPK.MustMarshal()) } @@ -26,7 +26,7 @@ func (k Keeper) GetSig(ctx context.Context, height uint64, fpBtcPK *bbn.BIP340Pu if uint64(sdk.UnwrapSDKContext(ctx).HeaderInfo().Height) < height { return nil, types.ErrHeightTooHigh } - store := k.voteStore(ctx, height) + store := k.voteHeightStore(ctx, height) sigBytes := store.Get(fpBtcPK.MustMarshal()) if len(sigBytes) == 0 { return nil, types.ErrVoteNotFound @@ -40,7 +40,7 @@ func (k Keeper) GetSig(ctx context.Context, height uint64, fpBtcPK *bbn.BIP340Pu // GetSigSet gets all EOTS signatures at a given height func (k Keeper) GetSigSet(ctx context.Context, height uint64) map[string]*bbn.SchnorrEOTSSig { - store := k.voteStore(ctx, height) + store := k.voteHeightStore(ctx, height) iter := store.Iterator(nil, nil) defer iter.Close() @@ -68,7 +68,7 @@ func (k Keeper) GetSigSet(ctx context.Context, height uint64) map[string]*bbn.Sc // GetVoters gets returns a map of voters' BTC PKs to the given height func (k Keeper) GetVoters(ctx context.Context, height uint64) map[string]struct{} { - store := k.voteStore(ctx, height) + store := k.voteHeightStore(ctx, height) iter := store.Iterator(nil, nil) defer iter.Close() @@ -90,12 +90,20 @@ func (k Keeper) GetVoters(ctx context.Context, height uint64) map[string]struct{ return voterBTCPKs } -// voteStore returns the KVStore of the votes +// voteHeightStore returns the KVStore of the votes // prefix: VoteKey // key: (block height || finality provider PK) // value: EOTS sig -func (k Keeper) voteStore(ctx context.Context, height uint64) prefix.Store { - storeAdapter := runtime.KVStoreAdapter(k.storeService.OpenKVStore(ctx)) - prefixedStore := prefix.NewStore(storeAdapter, types.VoteKey) +func (k Keeper) voteHeightStore(ctx context.Context, height uint64) prefix.Store { + prefixedStore := k.voteStore(ctx) return prefix.NewStore(prefixedStore, sdk.Uint64ToBigEndian(height)) } + +// voteStore returns the KVStore of the votes +// prefix: VoteKey +// key: (prefix) +// value: EOTS sig +func (k Keeper) voteStore(ctx context.Context) prefix.Store { + storeAdapter := runtime.KVStoreAdapter(k.storeService.OpenKVStore(ctx)) + return prefix.NewStore(storeAdapter, types.VoteKey) +} diff --git a/x/finality/keeper/votes_bench_test.go b/x/finality/keeper/votes_bench_test.go index c22a6cba4..2f78a75c4 100644 --- a/x/finality/keeper/votes_bench_test.go +++ b/x/finality/keeper/votes_bench_test.go @@ -8,11 +8,11 @@ import ( "time" "cosmossdk.io/core/header" - "github.com/babylonchain/babylon/testutil/datagen" - keepertest "github.com/babylonchain/babylon/testutil/keeper" - bbn "github.com/babylonchain/babylon/types" - "github.com/babylonchain/babylon/x/finality/keeper" - "github.com/babylonchain/babylon/x/finality/types" + "github.com/babylonlabs-io/babylon/testutil/datagen" + keepertest "github.com/babylonlabs-io/babylon/testutil/keeper" + bbn "github.com/babylonlabs-io/babylon/types" + "github.com/babylonlabs-io/babylon/x/finality/keeper" + "github.com/babylonlabs-io/babylon/x/finality/types" "github.com/golang/mock/gomock" "github.com/stretchr/testify/require" ) @@ -42,7 +42,7 @@ func benchmarkAddFinalitySig(b *testing.B) { // commit enough public randomness // TODO: generalise commit public randomness to allow arbitrary benchtime - srList, msg, err := datagen.GenRandomMsgCommitPubRandList(r, btcSK, 0, 100000) + randListInfo, msg, err := datagen.GenRandomMsgCommitPubRandList(r, btcSK, 0, 100000) require.NoError(b, err) _, err = ms.CommitPubRandList(ctx, msg) require.NoError(b, err) @@ -68,10 +68,9 @@ func benchmarkAddFinalitySig(b *testing.B) { height := uint64(i) // generate a vote - sr := srList[height] blockHash := datagen.GenRandomByteArray(r, 32) signer := datagen.GenRandomAccount().Address - msg, err := types.NewMsgAddFinalitySig(signer, btcSK, sr, height, blockHash) + msg, err := datagen.NewMsgAddFinalitySig(signer, btcSK, 0, height, randListInfo, blockHash) require.NoError(b, err) ctx = ctx.WithHeaderInfo(header.Info{Height: int64(height), AppHash: blockHash}) diff --git a/x/finality/module.go b/x/finality/module.go index 81a1f8df0..1ab4e359e 100644 --- a/x/finality/module.go +++ b/x/finality/module.go @@ -11,9 +11,9 @@ import ( abci "github.com/cometbft/cometbft/abci/types" - "github.com/babylonchain/babylon/x/finality/client/cli" - "github.com/babylonchain/babylon/x/finality/keeper" - "github.com/babylonchain/babylon/x/finality/types" + "github.com/babylonlabs-io/babylon/x/finality/client/cli" + "github.com/babylonlabs-io/babylon/x/finality/keeper" + "github.com/babylonlabs-io/babylon/x/finality/types" "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/codec" cdctypes "github.com/cosmos/cosmos-sdk/codec/types" diff --git a/x/finality/types/codec.go b/x/finality/types/codec.go index 04f766fa3..2e978d134 100644 --- a/x/finality/types/codec.go +++ b/x/finality/types/codec.go @@ -8,8 +8,8 @@ import ( ) func RegisterCodec(cdc *codec.LegacyAmino) { - cdc.RegisterConcrete(&MsgAddFinalitySig{}, "finality/MsgAddFinalitySig", nil) cdc.RegisterConcrete(&MsgCommitPubRandList{}, "finality/MsgCommitPubRandList", nil) + cdc.RegisterConcrete(&MsgAddFinalitySig{}, "finality/MsgAddFinalitySig", nil) cdc.RegisterConcrete(&MsgUpdateParams{}, "finality/MsgUpdateParams", nil) } @@ -17,8 +17,8 @@ func RegisterInterfaces(registry cdctypes.InterfaceRegistry) { // Register messages registry.RegisterImplementations( (*sdk.Msg)(nil), - &MsgAddFinalitySig{}, &MsgCommitPubRandList{}, + &MsgAddFinalitySig{}, &MsgUpdateParams{}, ) diff --git a/x/finality/types/errors.go b/x/finality/types/errors.go index b39e4ff37..ee10b27fb 100644 --- a/x/finality/types/errors.go +++ b/x/finality/types/errors.go @@ -6,14 +6,15 @@ import ( // x/finality module sentinel errors var ( - ErrBlockNotFound = errorsmod.Register(ModuleName, 1100, "Block is not found") - ErrVoteNotFound = errorsmod.Register(ModuleName, 1101, "vote is not found") - ErrHeightTooHigh = errorsmod.Register(ModuleName, 1102, "the chain has not reached the given height yet") - ErrPubRandNotFound = errorsmod.Register(ModuleName, 1103, "public randomness is not found") - ErrNoPubRandYet = errorsmod.Register(ModuleName, 1104, "the finality provider has not committed any public randomness yet") - ErrTooFewPubRand = errorsmod.Register(ModuleName, 1105, "the request contains too few public randomness") - 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") + ErrBlockNotFound = errorsmod.Register(ModuleName, 1100, "Block is not found") + ErrVoteNotFound = errorsmod.Register(ModuleName, 1101, "vote is not found") + ErrHeightTooHigh = errorsmod.Register(ModuleName, 1102, "the chain has not reached the given height yet") + ErrPubRandNotFound = errorsmod.Register(ModuleName, 1103, "public randomness is not found") + ErrPubRandCommitNotFound = errorsmod.Register(ModuleName, 1104, "public randomness commitment is not found") + ErrNoPubRandYet = errorsmod.Register(ModuleName, 1105, "the finality provider has not committed any public randomness yet") + ErrTooFewPubRand = errorsmod.Register(ModuleName, 1106, "the request contains too few public randomness") + ErrInvalidPubRand = errorsmod.Register(ModuleName, 1107, "the public randomness list is invalid") + ErrEvidenceNotFound = errorsmod.Register(ModuleName, 1108, "evidence is not found") + ErrInvalidFinalitySig = errorsmod.Register(ModuleName, 1109, "finality signature is not valid") + ErrNoSlashableEvidence = errorsmod.Register(ModuleName, 1110, "there is no slashable evidence") ) diff --git a/x/finality/types/events.go b/x/finality/types/events.go index 6d452f5d0..6c6f400ca 100644 --- a/x/finality/types/events.go +++ b/x/finality/types/events.go @@ -1,7 +1,17 @@ package types +import "github.com/babylonlabs-io/babylon/types" + func NewEventSlashedFinalityProvider(evidence *Evidence) *EventSlashedFinalityProvider { return &EventSlashedFinalityProvider{ Evidence: evidence, } } + +func NewEventSluggishFinalityProviderDetected(fpPk *types.BIP340PubKey) *EventSluggishFinalityProviderDetected { + return &EventSluggishFinalityProviderDetected{PublicKey: fpPk.MarshalHex()} +} + +func NewEventSluggishFinalityProviderReverted(fpPk *types.BIP340PubKey) *EventSluggishFinalityProviderReverted { + return &EventSluggishFinalityProviderReverted{PublicKey: fpPk.MarshalHex()} +} diff --git a/x/finality/types/events.pb.go b/x/finality/types/events.pb.go index 2a19e5f20..b6d9a35f6 100644 --- a/x/finality/types/events.pb.go +++ b/x/finality/types/events.pb.go @@ -69,14 +69,110 @@ func (m *EventSlashedFinalityProvider) GetEvidence() *Evidence { return nil } +// EventSluggishFinalityProviderDetected is the event emitted when a finality provider is +// detected as sluggish +type EventSluggishFinalityProviderDetected struct { + // public_key is the BTC public key of the finality provider + PublicKey string `protobuf:"bytes,1,opt,name=public_key,json=publicKey,proto3" json:"public_key,omitempty"` +} + +func (m *EventSluggishFinalityProviderDetected) Reset() { *m = EventSluggishFinalityProviderDetected{} } +func (m *EventSluggishFinalityProviderDetected) String() string { return proto.CompactTextString(m) } +func (*EventSluggishFinalityProviderDetected) ProtoMessage() {} +func (*EventSluggishFinalityProviderDetected) Descriptor() ([]byte, []int) { + return fileDescriptor_c34c03aae5e3e6bf, []int{1} +} +func (m *EventSluggishFinalityProviderDetected) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *EventSluggishFinalityProviderDetected) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_EventSluggishFinalityProviderDetected.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 *EventSluggishFinalityProviderDetected) XXX_Merge(src proto.Message) { + xxx_messageInfo_EventSluggishFinalityProviderDetected.Merge(m, src) +} +func (m *EventSluggishFinalityProviderDetected) XXX_Size() int { + return m.Size() +} +func (m *EventSluggishFinalityProviderDetected) XXX_DiscardUnknown() { + xxx_messageInfo_EventSluggishFinalityProviderDetected.DiscardUnknown(m) +} + +var xxx_messageInfo_EventSluggishFinalityProviderDetected proto.InternalMessageInfo + +func (m *EventSluggishFinalityProviderDetected) GetPublicKey() string { + if m != nil { + return m.PublicKey + } + return "" +} + +// EventSluggishFinalityProviderReverted is the event emitted when a sluggish finality +// provider is no longer considered sluggish +type EventSluggishFinalityProviderReverted struct { + // public_key is the BTC public key of the finality provider + PublicKey string `protobuf:"bytes,1,opt,name=public_key,json=publicKey,proto3" json:"public_key,omitempty"` +} + +func (m *EventSluggishFinalityProviderReverted) Reset() { *m = EventSluggishFinalityProviderReverted{} } +func (m *EventSluggishFinalityProviderReverted) String() string { return proto.CompactTextString(m) } +func (*EventSluggishFinalityProviderReverted) ProtoMessage() {} +func (*EventSluggishFinalityProviderReverted) Descriptor() ([]byte, []int) { + return fileDescriptor_c34c03aae5e3e6bf, []int{2} +} +func (m *EventSluggishFinalityProviderReverted) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *EventSluggishFinalityProviderReverted) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_EventSluggishFinalityProviderReverted.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 *EventSluggishFinalityProviderReverted) XXX_Merge(src proto.Message) { + xxx_messageInfo_EventSluggishFinalityProviderReverted.Merge(m, src) +} +func (m *EventSluggishFinalityProviderReverted) XXX_Size() int { + return m.Size() +} +func (m *EventSluggishFinalityProviderReverted) XXX_DiscardUnknown() { + xxx_messageInfo_EventSluggishFinalityProviderReverted.DiscardUnknown(m) +} + +var xxx_messageInfo_EventSluggishFinalityProviderReverted proto.InternalMessageInfo + +func (m *EventSluggishFinalityProviderReverted) GetPublicKey() string { + if m != nil { + return m.PublicKey + } + return "" +} + func init() { proto.RegisterType((*EventSlashedFinalityProvider)(nil), "babylon.finality.v1.EventSlashedFinalityProvider") + proto.RegisterType((*EventSluggishFinalityProviderDetected)(nil), "babylon.finality.v1.EventSluggishFinalityProviderDetected") + proto.RegisterType((*EventSluggishFinalityProviderReverted)(nil), "babylon.finality.v1.EventSluggishFinalityProviderReverted") } func init() { proto.RegisterFile("babylon/finality/v1/events.proto", fileDescriptor_c34c03aae5e3e6bf) } var fileDescriptor_c34c03aae5e3e6bf = []byte{ - // 193 bytes of a gzipped FileDescriptorProto + // 252 bytes of a gzipped FileDescriptorProto 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x52, 0x48, 0x4a, 0x4c, 0xaa, 0xcc, 0xc9, 0xcf, 0xd3, 0x4f, 0xcb, 0xcc, 0x4b, 0xcc, 0xc9, 0x2c, 0xa9, 0xd4, 0x2f, 0x33, 0xd4, 0x4f, 0x2d, 0x4b, 0xcd, 0x2b, 0x29, 0xd6, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0x12, 0x86, 0xaa, @@ -84,12 +180,15 @@ var fileDescriptor_c34c03aae5e3e6bf = []byte{ 0x92, 0x4b, 0xc6, 0x15, 0x64, 0x50, 0x70, 0x4e, 0x62, 0x71, 0x46, 0x6a, 0x8a, 0x1b, 0x54, 0x36, 0xa0, 0x28, 0xbf, 0x2c, 0x33, 0x25, 0xb5, 0x48, 0xc8, 0x92, 0x8b, 0x23, 0x15, 0xc4, 0xca, 0x4b, 0x4e, 0x95, 0x60, 0x54, 0x60, 0xd4, 0xe0, 0x36, 0x92, 0xd5, 0xc3, 0x62, 0x97, 0x9e, 0x2b, 0x54, - 0x51, 0x10, 0x5c, 0xb9, 0x93, 0xd7, 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, 0xa4, 0x67, 0x96, 0x64, 0x94, 0x26, 0xe9, 0x25, 0xe7, 0xe7, 0xea, 0x43, 0x0d, 0x4b, 0xce, - 0x48, 0xcc, 0xcc, 0x83, 0x71, 0xf4, 0x2b, 0x10, 0x4e, 0x2e, 0xa9, 0x2c, 0x48, 0x2d, 0x4e, 0x62, - 0x03, 0xbb, 0xd6, 0x18, 0x10, 0x00, 0x00, 0xff, 0xff, 0xa3, 0x4e, 0xb5, 0x88, 0x0a, 0x01, 0x00, - 0x00, + 0x51, 0x10, 0x5c, 0xb9, 0x92, 0x1b, 0x97, 0x2a, 0xd4, 0xe8, 0xd2, 0xf4, 0xf4, 0xcc, 0xe2, 0x0c, + 0x74, 0xb3, 0x5d, 0x52, 0x4b, 0x52, 0x93, 0x4b, 0x52, 0x53, 0x84, 0x64, 0xb9, 0xb8, 0x0a, 0x4a, + 0x93, 0x72, 0x32, 0x93, 0xe3, 0xb3, 0x53, 0x2b, 0xc1, 0xb6, 0x70, 0x06, 0x71, 0x42, 0x44, 0xbc, + 0x53, 0x2b, 0x09, 0x9a, 0x13, 0x94, 0x5a, 0x96, 0x5a, 0x44, 0xd8, 0x1c, 0x27, 0x9f, 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, 0x32, 0x4a, 0xcf, 0x2c, 0xc9, 0x28, 0x4d, 0xd2, + 0x4b, 0xce, 0xcf, 0xd5, 0x87, 0x7a, 0x2e, 0x27, 0x31, 0xa9, 0x58, 0x37, 0x33, 0x1f, 0xc6, 0xd5, + 0xaf, 0x40, 0x04, 0x62, 0x49, 0x65, 0x41, 0x6a, 0x71, 0x12, 0x1b, 0x38, 0xfc, 0x8c, 0x01, 0x01, + 0x00, 0x00, 0xff, 0xff, 0x58, 0x3c, 0x4f, 0x58, 0x9c, 0x01, 0x00, 0x00, } func (m *EventSlashedFinalityProvider) Marshal() (dAtA []byte, err error) { @@ -127,6 +226,66 @@ func (m *EventSlashedFinalityProvider) MarshalToSizedBuffer(dAtA []byte) (int, e return len(dAtA) - i, nil } +func (m *EventSluggishFinalityProviderDetected) 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 *EventSluggishFinalityProviderDetected) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *EventSluggishFinalityProviderDetected) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.PublicKey) > 0 { + i -= len(m.PublicKey) + copy(dAtA[i:], m.PublicKey) + i = encodeVarintEvents(dAtA, i, uint64(len(m.PublicKey))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *EventSluggishFinalityProviderReverted) 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 *EventSluggishFinalityProviderReverted) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *EventSluggishFinalityProviderReverted) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.PublicKey) > 0 { + i -= len(m.PublicKey) + copy(dAtA[i:], m.PublicKey) + i = encodeVarintEvents(dAtA, i, uint64(len(m.PublicKey))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + func encodeVarintEvents(dAtA []byte, offset int, v uint64) int { offset -= sovEvents(v) base := offset @@ -151,6 +310,32 @@ func (m *EventSlashedFinalityProvider) Size() (n int) { return n } +func (m *EventSluggishFinalityProviderDetected) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.PublicKey) + if l > 0 { + n += 1 + l + sovEvents(uint64(l)) + } + return n +} + +func (m *EventSluggishFinalityProviderReverted) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.PublicKey) + if l > 0 { + n += 1 + l + sovEvents(uint64(l)) + } + return n +} + func sovEvents(x uint64) (n int) { return (math_bits.Len64(x|1) + 6) / 7 } @@ -243,6 +428,170 @@ func (m *EventSlashedFinalityProvider) Unmarshal(dAtA []byte) error { } return nil } +func (m *EventSluggishFinalityProviderDetected) 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: EventSluggishFinalityProviderDetected: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: EventSluggishFinalityProviderDetected: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field PublicKey", 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.PublicKey = 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 *EventSluggishFinalityProviderReverted) 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: EventSluggishFinalityProviderReverted: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: EventSluggishFinalityProviderReverted: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field PublicKey", 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.PublicKey = 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 skipEvents(dAtA []byte) (n int, err error) { l := len(dAtA) iNdEx := 0 diff --git a/x/finality/types/expected_keepers.go b/x/finality/types/expected_keepers.go index d13913622..f4d6e58d9 100644 --- a/x/finality/types/expected_keepers.go +++ b/x/finality/types/expected_keepers.go @@ -3,21 +3,33 @@ package types import ( "context" - bstypes "github.com/babylonchain/babylon/x/btcstaking/types" + bbn "github.com/babylonlabs-io/babylon/types" + bstypes "github.com/babylonlabs-io/babylon/x/btcstaking/types" ) type BTCStakingKeeper interface { + GetParams(ctx context.Context) bstypes.Params GetFinalityProvider(ctx context.Context, fpBTCPK []byte) (*bstypes.FinalityProvider, error) HasFinalityProvider(ctx context.Context, fpBTCPK []byte) bool SlashFinalityProvider(ctx context.Context, fpBTCPK []byte) 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) - GetRewardDistCache(ctx context.Context, height uint64) (*bstypes.RewardDistCache, error) - RemoveRewardDistCache(ctx context.Context, height uint64) + GetVotingPowerDistCache(ctx context.Context, height uint64) (*bstypes.VotingPowerDistCache, error) + RemoveVotingPowerDistCache(ctx context.Context, height uint64) + GetLastFinalizedEpoch(ctx context.Context) uint64 + RevertSluggishFinalityProvider(ctx context.Context, fpBTCPK []byte) error } // IncentiveKeeper defines the expected interface needed to distribute rewards. type IncentiveKeeper interface { - RewardBTCStaking(ctx context.Context, height uint64, rdc *bstypes.RewardDistCache) + 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 } diff --git a/x/finality/types/finality.go b/x/finality/types/finality.go index 5e1380d1d..1338273cf 100644 --- a/x/finality/types/finality.go +++ b/x/finality/types/finality.go @@ -4,11 +4,41 @@ import ( "bytes" "fmt" - "github.com/babylonchain/babylon/crypto/eots" + "github.com/babylonlabs-io/babylon/crypto/eots" "github.com/btcsuite/btcd/btcec/v2" sdk "github.com/cosmos/cosmos-sdk/types" ) +func (c *PubRandCommit) IsInRange(height uint64) bool { + start, end := c.Range() + return start <= height && height <= end +} + +func (c *PubRandCommit) GetIndex(height uint64) (uint64, error) { + start, end := c.Range() + if start <= height && height <= end { + return height - start, nil + } + return 0, ErrPubRandNotFound.Wrapf("the given height (%d) is not in range [%d, %d]", height, start, end) +} + +func (c *PubRandCommit) EndHeight() uint64 { + return c.StartHeight + c.NumPubRand - 1 +} + +// Range() returns the range of the heights that a public randomness is committed +// both values are inclusive +func (c *PubRandCommit) Range() (uint64, uint64) { + return c.StartHeight, c.EndHeight() +} + +func (c *PubRandCommit) ToResponse() *PubRandCommitResponse { + return &PubRandCommitResponse{ + NumPubRand: c.NumPubRand, + Commitment: c.Commitment, + } +} + // msgToSignForVote returns the message for an EOTS signature // The EOTS signature on a block will be (blockHeight || blockHash) func msgToSignForVote(blockHeight uint64, blockHash []byte) []byte { diff --git a/x/finality/types/finality.pb.go b/x/finality/types/finality.pb.go index 7f1ebb971..8d2eb5f4b 100644 --- a/x/finality/types/finality.pb.go +++ b/x/finality/types/finality.pb.go @@ -5,7 +5,7 @@ package types import ( fmt "fmt" - github_com_babylonchain_babylon_types "github.com/babylonchain/babylon/types" + github_com_babylonlabs_io_babylon_types "github.com/babylonlabs-io/babylon/types" _ "github.com/cosmos/gogoproto/gogoproto" proto "github.com/cosmos/gogoproto/proto" io "io" @@ -89,15 +89,82 @@ func (m *IndexedBlock) GetFinalized() bool { return false } +// PubRandCommit is a commitment to a series of public randomness +// currently, the commitment is a root of a Merkle tree that includes +// a series of public randomness +type PubRandCommit struct { + // start_height is the height of the first commitment + StartHeight uint64 `protobuf:"varint,1,opt,name=start_height,json=startHeight,proto3" json:"start_height,omitempty"` + // num_pub_rand is the number of committed public randomness + NumPubRand uint64 `protobuf:"varint,2,opt,name=num_pub_rand,json=numPubRand,proto3" json:"num_pub_rand,omitempty"` + // commitment is the value of the commitment + // currently, it is the root of the merkle tree constructed by the public randomness + Commitment []byte `protobuf:"bytes,3,opt,name=commitment,proto3" json:"commitment,omitempty"` +} + +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} +} +func (m *PubRandCommit) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *PubRandCommit) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_PubRandCommit.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 *PubRandCommit) XXX_Merge(src proto.Message) { + xxx_messageInfo_PubRandCommit.Merge(m, src) +} +func (m *PubRandCommit) XXX_Size() int { + return m.Size() +} +func (m *PubRandCommit) XXX_DiscardUnknown() { + xxx_messageInfo_PubRandCommit.DiscardUnknown(m) +} + +var xxx_messageInfo_PubRandCommit proto.InternalMessageInfo + +func (m *PubRandCommit) GetStartHeight() uint64 { + if m != nil { + return m.StartHeight + } + return 0 +} + +func (m *PubRandCommit) GetNumPubRand() uint64 { + if m != nil { + return m.NumPubRand + } + return 0 +} + +func (m *PubRandCommit) GetCommitment() []byte { + if m != nil { + return m.Commitment + } + return nil +} + // Evidence is the evidence that a finality provider has signed finality // signatures with correct public randomness on two conflicting Babylon headers type Evidence struct { // fp_btc_pk is the BTC PK of the finality provider that casts this vote - FpBtcPk *github_com_babylonchain_babylon_types.BIP340PubKey `protobuf:"bytes,1,opt,name=fp_btc_pk,json=fpBtcPk,proto3,customtype=github.com/babylonchain/babylon/types.BIP340PubKey" json:"fp_btc_pk,omitempty"` + FpBtcPk *github_com_babylonlabs_io_babylon_types.BIP340PubKey `protobuf:"bytes,1,opt,name=fp_btc_pk,json=fpBtcPk,proto3,customtype=github.com/babylonlabs-io/babylon/types.BIP340PubKey" json:"fp_btc_pk,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_babylonchain_babylon_types.SchnorrPubRand `protobuf:"bytes,3,opt,name=pub_rand,json=pubRand,proto3,customtype=github.com/babylonchain/babylon/types.SchnorrPubRand" json:"pub_rand,omitempty"` + 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 @@ -106,17 +173,17 @@ type Evidence struct { // 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_babylonchain_babylon_types.SchnorrEOTSSig `protobuf:"bytes,6,opt,name=canonical_finality_sig,json=canonicalFinalitySig,proto3,customtype=github.com/babylonchain/babylon/types.SchnorrEOTSSig" json:"canonical_finality_sig,omitempty"` + 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_babylonchain_babylon_types.SchnorrEOTSSig `protobuf:"bytes,7,opt,name=fork_finality_sig,json=forkFinalitySig,proto3,customtype=github.com/babylonchain/babylon/types.SchnorrEOTSSig" json:"fork_finality_sig,omitempty"` + 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 *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{1} + return fileDescriptor_ca5b87e52e3e6d02, []int{2} } func (m *Evidence) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -166,9 +233,70 @@ func (m *Evidence) GetForkAppHash() []byte { return nil } +// FinalityProviderSigningInfo defines a finality provider's signing info for monitoring their +// liveness activity. +type FinalityProviderSigningInfo struct { + // 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,1,opt,name=fp_btc_pk,json=fpBtcPk,proto3,customtype=github.com/babylonlabs-io/babylon/types.BIP340PubKey" json:"fp_btc_pk,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"` +} + +func (m *FinalityProviderSigningInfo) Reset() { *m = FinalityProviderSigningInfo{} } +func (m *FinalityProviderSigningInfo) String() string { return proto.CompactTextString(m) } +func (*FinalityProviderSigningInfo) ProtoMessage() {} +func (*FinalityProviderSigningInfo) Descriptor() ([]byte, []int) { + return fileDescriptor_ca5b87e52e3e6d02, []int{3} +} +func (m *FinalityProviderSigningInfo) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *FinalityProviderSigningInfo) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_FinalityProviderSigningInfo.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 *FinalityProviderSigningInfo) XXX_Merge(src proto.Message) { + xxx_messageInfo_FinalityProviderSigningInfo.Merge(m, src) +} +func (m *FinalityProviderSigningInfo) XXX_Size() int { + return m.Size() +} +func (m *FinalityProviderSigningInfo) XXX_DiscardUnknown() { + xxx_messageInfo_FinalityProviderSigningInfo.DiscardUnknown(m) +} + +var xxx_messageInfo_FinalityProviderSigningInfo proto.InternalMessageInfo + +func (m *FinalityProviderSigningInfo) GetStartHeight() int64 { + if m != nil { + return m.StartHeight + } + return 0 +} + +func (m *FinalityProviderSigningInfo) GetMissedBlocksCounter() int64 { + if m != nil { + return m.MissedBlocksCounter + } + return 0 +} + func init() { proto.RegisterType((*IndexedBlock)(nil), "babylon.finality.v1.IndexedBlock") + proto.RegisterType((*PubRandCommit)(nil), "babylon.finality.v1.PubRandCommit") proto.RegisterType((*Evidence)(nil), "babylon.finality.v1.Evidence") + proto.RegisterType((*FinalityProviderSigningInfo)(nil), "babylon.finality.v1.FinalityProviderSigningInfo") } func init() { @@ -176,34 +304,41 @@ func init() { } var fileDescriptor_ca5b87e52e3e6d02 = []byte{ - // 424 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xa4, 0x92, 0x4f, 0x6f, 0xd3, 0x30, - 0x18, 0x87, 0x9b, 0x6d, 0xb4, 0x9d, 0x17, 0x04, 0x98, 0x69, 0x2a, 0x08, 0x65, 0xa5, 0xa7, 0x1e, - 0x50, 0xb3, 0xb1, 0x09, 0x71, 0x25, 0xd2, 0xd0, 0x06, 0x07, 0x2a, 0x87, 0x13, 0x17, 0xcb, 0x76, - 0xdc, 0xd8, 0x6a, 0xb1, 0xad, 0xfc, 0xa9, 0x16, 0x3e, 0x05, 0x1f, 0x8b, 0xe3, 0x8e, 0x68, 0x87, - 0x0a, 0xb5, 0xdf, 0x03, 0xa1, 0x38, 0x69, 0x02, 0x27, 0x10, 0xbb, 0xbd, 0x7e, 0xfd, 0xd3, 0xfb, - 0x3c, 0x7a, 0x6d, 0x30, 0xa2, 0x84, 0x16, 0x0b, 0xad, 0xfc, 0x99, 0x54, 0x64, 0x21, 0xb3, 0xc2, - 0x5f, 0x9e, 0x36, 0xf5, 0xc4, 0x24, 0x3a, 0xd3, 0xf0, 0x71, 0x9d, 0x99, 0x34, 0xfd, 0xe5, 0xe9, - 0xd3, 0xc3, 0x58, 0xc7, 0xda, 0xde, 0xfb, 0x65, 0x55, 0x45, 0x47, 0x18, 0xb8, 0x57, 0x2a, 0xe2, - 0xd7, 0x3c, 0x0a, 0x16, 0x9a, 0xcd, 0xe1, 0x11, 0xe8, 0x0a, 0x2e, 0x63, 0x91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x1b, 0x3c, 0x28, 0x9b, 0xdb, 0x8c, 0x02, 0x47, 0xed, 0xc4, 0xed, 0xd3, - 0xe1, 0x54, 0xc6, 0x83, 0xee, 0x7f, 0x4a, 0x5f, 0x7c, 0xf8, 0x18, 0x86, 0x32, 0x46, 0x87, 0xcd, - 0xdc, 0xb7, 0xf5, 0xd8, 0x50, 0xc6, 0x30, 0x02, 0x8f, 0xac, 0xd3, 0x1f, 0xa8, 0xde, 0x1d, 0x51, - 0x0f, 0xca, 0x91, 0xbf, 0x51, 0x82, 0x77, 0xdf, 0xd6, 0x9e, 0x73, 0xb3, 0xf6, 0x9c, 0x1f, 0x6b, - 0xcf, 0xf9, 0xba, 0xf1, 0x3a, 0x37, 0x1b, 0xaf, 0xf3, 0x7d, 0xe3, 0x75, 0x3e, 0x9d, 0xfc, 0x0d, - 0x70, 0xdd, 0x7e, 0x72, 0xcb, 0xa2, 0x5d, 0xfb, 0x69, 0xcf, 0x7e, 0x05, 0x00, 0x00, 0xff, 0xff, - 0xac, 0x30, 0x4b, 0x66, 0x05, 0x03, 0x00, 0x00, + // 539 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xb4, 0x54, 0x4d, 0x6f, 0xd3, 0x30, + 0x18, 0x6e, 0x68, 0x69, 0x3b, 0x37, 0x13, 0x90, 0x8d, 0xa9, 0x7c, 0x28, 0x2b, 0x39, 0xf5, 0x00, + 0x2d, 0xfb, 0x10, 0x42, 0xdc, 0xc8, 0x34, 0xb4, 0x0a, 0x24, 0xaa, 0x74, 0x5c, 0xb8, 0x58, 0x4e, + 0xe2, 0x24, 0x56, 0x1b, 0xdb, 0x8a, 0x9d, 0x6a, 0xe5, 0x07, 0x70, 0xe6, 0x67, 0x21, 0x4e, 0x3b, + 0xa2, 0x1d, 0x26, 0xd4, 0xfe, 0x11, 0x14, 0xe7, 0xa3, 0xeb, 0x09, 0x04, 0xda, 0x2d, 0x7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x42, 0x4a, 0x68, 0x38, 0xa2, + 0x01, 0xbb, 0xbd, 0x6c, 0x6c, 0x64, 0x3c, 0xcb, 0x46, 0x7d, 0x33, 0xe3, 0x87, 0xe0, 0x61, 0x4c, + 0x84, 0xc0, 0x3e, 0x54, 0x89, 0x11, 0xd0, 0x63, 0x29, 0x95, 0x38, 0x51, 0x41, 0xa9, 0x3b, 0x3b, + 0x79, 0x53, 0xfd, 0x94, 0xe2, 0x24, 0x6f, 0xd9, 0x1f, 0xbe, 0x2f, 0x4d, 0xed, 0x72, 0x69, 0x6a, + 0xbf, 0x96, 0xa6, 0xf6, 0x6d, 0x65, 0xd6, 0x2e, 0x57, 0x66, 0xed, 0xe7, 0xca, 0xac, 0x7d, 0x3e, + 0xfc, 0xb3, 0xde, 0x8b, 0xf5, 0x8b, 0xa1, 0xa4, 0xbb, 0x4d, 0xf5, 0x02, 0x1c, 0xfd, 0x0e, 0x00, + 0x00, 0xff, 0xff, 0xb1, 0x31, 0x31, 0x81, 0x52, 0x04, 0x00, 0x00, } func (m *IndexedBlock) Marshal() (dAtA []byte, err error) { @@ -251,6 +386,46 @@ func (m *IndexedBlock) MarshalToSizedBuffer(dAtA []byte) (int, error) { return len(dAtA) - i, nil } +func (m *PubRandCommit) 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 *PubRandCommit) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *PubRandCommit) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Commitment) > 0 { + i -= len(m.Commitment) + copy(dAtA[i:], m.Commitment) + i = encodeVarintFinality(dAtA, i, uint64(len(m.Commitment))) + i-- + dAtA[i] = 0x1a + } + if m.NumPubRand != 0 { + i = encodeVarintFinality(dAtA, i, uint64(m.NumPubRand)) + i-- + dAtA[i] = 0x10 + } + if m.StartHeight != 0 { + i = encodeVarintFinality(dAtA, i, uint64(m.StartHeight)) + i-- + dAtA[i] = 0x8 + } + return len(dAtA) - i, nil +} + func (m *Evidence) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) @@ -341,6 +516,51 @@ func (m *Evidence) MarshalToSizedBuffer(dAtA []byte) (int, error) { return len(dAtA) - i, nil } +func (m *FinalityProviderSigningInfo) 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 *FinalityProviderSigningInfo) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *FinalityProviderSigningInfo) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.MissedBlocksCounter != 0 { + i = encodeVarintFinality(dAtA, i, uint64(m.MissedBlocksCounter)) + i-- + dAtA[i] = 0x18 + } + if m.StartHeight != 0 { + i = encodeVarintFinality(dAtA, i, uint64(m.StartHeight)) + i-- + dAtA[i] = 0x10 + } + if m.FpBtcPk != nil { + { + size := m.FpBtcPk.Size() + i -= size + if _, err := m.FpBtcPk.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintFinality(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + func encodeVarintFinality(dAtA []byte, offset int, v uint64) int { offset -= sovFinality(v) base := offset @@ -371,6 +591,25 @@ func (m *IndexedBlock) Size() (n int) { return n } +func (m *PubRandCommit) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.StartHeight != 0 { + n += 1 + sovFinality(uint64(m.StartHeight)) + } + if m.NumPubRand != 0 { + n += 1 + sovFinality(uint64(m.NumPubRand)) + } + l = len(m.Commitment) + if l > 0 { + n += 1 + l + sovFinality(uint64(l)) + } + return n +} + func (m *Evidence) Size() (n int) { if m == nil { return 0 @@ -407,6 +646,25 @@ func (m *Evidence) Size() (n int) { return n } +func (m *FinalityProviderSigningInfo) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.FpBtcPk != nil { + l = m.FpBtcPk.Size() + n += 1 + l + sovFinality(uint64(l)) + } + if m.StartHeight != 0 { + n += 1 + sovFinality(uint64(m.StartHeight)) + } + if m.MissedBlocksCounter != 0 { + n += 1 + sovFinality(uint64(m.MissedBlocksCounter)) + } + return n +} + func sovFinality(x uint64) (n int) { return (math_bits.Len64(x|1) + 6) / 7 } @@ -536,6 +794,128 @@ func (m *IndexedBlock) Unmarshal(dAtA []byte) error { } return nil } +func (m *PubRandCommit) 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: PubRandCommit: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: PubRandCommit: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + 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 ErrIntOverflowFinality + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.StartHeight |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 2: + 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 ErrIntOverflowFinality + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.NumPubRand |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Commitment", 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.Commitment = append(m.Commitment[:0], dAtA[iNdEx:postIndex]...) + if m.Commitment == nil { + m.Commitment = []byte{} + } + iNdEx = postIndex + 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 *Evidence) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 @@ -594,7 +974,7 @@ func (m *Evidence) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - var v github_com_babylonchain_babylon_types.BIP340PubKey + var v github_com_babylonlabs_io_babylon_types.BIP340PubKey m.FpBtcPk = &v if err := m.FpBtcPk.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err @@ -648,7 +1028,7 @@ func (m *Evidence) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - var v github_com_babylonchain_babylon_types.SchnorrPubRand + var v github_com_babylonlabs_io_babylon_types.SchnorrPubRand m.PubRand = &v if err := m.PubRand.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err @@ -751,7 +1131,7 @@ func (m *Evidence) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - var v github_com_babylonchain_babylon_types.SchnorrEOTSSig + var v github_com_babylonlabs_io_babylon_types.SchnorrEOTSSig m.CanonicalFinalitySig = &v if err := m.CanonicalFinalitySig.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err @@ -786,7 +1166,7 @@ func (m *Evidence) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - var v github_com_babylonchain_babylon_types.SchnorrEOTSSig + var v github_com_babylonlabs_io_babylon_types.SchnorrEOTSSig m.ForkFinalitySig = &v if err := m.ForkFinalitySig.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err @@ -813,6 +1193,129 @@ func (m *Evidence) Unmarshal(dAtA []byte) error { } return nil } +func (m *FinalityProviderSigningInfo) 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: FinalityProviderSigningInfo: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: FinalityProviderSigningInfo: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + 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 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.FpBtcPk = &v + if err := m.FpBtcPk.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + 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 ErrIntOverflowFinality + } + 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 ErrIntOverflowFinality + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.MissedBlocksCounter |= int64(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 skipFinality(dAtA []byte) (n int, err error) { l := len(dAtA) iNdEx := 0 diff --git a/x/finality/types/genesis.go b/x/finality/types/genesis.go index 9d633ecd7..cd58e53e4 100644 --- a/x/finality/types/genesis.go +++ b/x/finality/types/genesis.go @@ -10,5 +10,6 @@ func DefaultGenesis() *GenesisState { // Validate performs basic genesis state validation returning an error upon any // failure. func (gs GenesisState) Validate() error { + // TODO: add validate to IndexedBlocks, Evidences, VoteSigs, PublicRandomness return gs.Params.Validate() } diff --git a/x/finality/types/genesis.pb.go b/x/finality/types/genesis.pb.go index 59249a222..6707ca5ab 100644 --- a/x/finality/types/genesis.pb.go +++ b/x/finality/types/genesis.pb.go @@ -5,6 +5,7 @@ package types import ( fmt "fmt" + github_com_babylonlabs_io_babylon_types "github.com/babylonlabs-io/babylon/types" _ "github.com/cosmos/gogoproto/gogoproto" proto "github.com/cosmos/gogoproto/proto" io "io" @@ -25,7 +26,24 @@ const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package // GenesisState defines the finality module's genesis state. type GenesisState struct { + // params the current params of the state. Params Params `protobuf:"bytes,1,opt,name=params,proto3" json:"params"` + // indexed_blocks all the btc blocks and if their status are finalized. + IndexedBlocks []*IndexedBlock `protobuf:"bytes,2,rep,name=indexed_blocks,json=indexedBlocks,proto3" json:"indexed_blocks,omitempty"` + // evidences all the evidences ever registered. + 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. + 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. + 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. + SigningInfos []SigningInfo `protobuf:"bytes,7,rep,name=signing_infos,json=signingInfos,proto3" json:"signing_infos"` + // 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"` } func (m *GenesisState) Reset() { *m = GenesisState{} } @@ -68,27 +86,415 @@ func (m *GenesisState) GetParams() Params { return Params{} } +func (m *GenesisState) GetIndexedBlocks() []*IndexedBlock { + if m != nil { + return m.IndexedBlocks + } + return nil +} + +func (m *GenesisState) GetEvidences() []*Evidence { + if m != nil { + return m.Evidences + } + return nil +} + +func (m *GenesisState) GetVoteSigs() []*VoteSig { + if m != nil { + return m.VoteSigs + } + return nil +} + +func (m *GenesisState) GetPublicRandomness() []*PublicRandomness { + if m != nil { + return m.PublicRandomness + } + return nil +} + +func (m *GenesisState) GetPubRandCommit() []*PubRandCommitWithPK { + if m != nil { + return m.PubRandCommit + } + return nil +} + +func (m *GenesisState) GetSigningInfos() []SigningInfo { + if m != nil { + return m.SigningInfos + } + return nil +} + +func (m *GenesisState) GetMissedBlocks() []FinalityProviderMissedBlocks { + if m != nil { + return m.MissedBlocks + } + 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 { + // block_height is the height of the voted block. + 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"` + // finality_sig is the finality signature to this block + // where finality signature is an EOTS signature, i.e. + FinalitySig *github_com_babylonlabs_io_babylon_types.SchnorrEOTSSig `protobuf:"bytes,3,opt,name=finality_sig,json=finalitySig,proto3,customtype=github.com/babylonlabs-io/babylon/types.SchnorrEOTSSig" json:"finality_sig,omitempty"` +} + +func (m *VoteSig) Reset() { *m = VoteSig{} } +func (m *VoteSig) String() string { return proto.CompactTextString(m) } +func (*VoteSig) ProtoMessage() {} +func (*VoteSig) Descriptor() ([]byte, []int) { + return fileDescriptor_52dc577f74d797d1, []int{1} +} +func (m *VoteSig) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *VoteSig) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_VoteSig.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 *VoteSig) XXX_Merge(src proto.Message) { + xxx_messageInfo_VoteSig.Merge(m, src) +} +func (m *VoteSig) XXX_Size() int { + return m.Size() +} +func (m *VoteSig) XXX_DiscardUnknown() { + xxx_messageInfo_VoteSig.DiscardUnknown(m) +} + +var xxx_messageInfo_VoteSig proto.InternalMessageInfo + +func (m *VoteSig) GetBlockHeight() uint64 { + if m != nil { + return m.BlockHeight + } + return 0 +} + +// 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. + 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"` + // 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"` +} + +func (m *PublicRandomness) Reset() { *m = PublicRandomness{} } +func (m *PublicRandomness) String() string { return proto.CompactTextString(m) } +func (*PublicRandomness) ProtoMessage() {} +func (*PublicRandomness) Descriptor() ([]byte, []int) { + return fileDescriptor_52dc577f74d797d1, []int{2} +} +func (m *PublicRandomness) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *PublicRandomness) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_PublicRandomness.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 *PublicRandomness) XXX_Merge(src proto.Message) { + xxx_messageInfo_PublicRandomness.Merge(m, src) +} +func (m *PublicRandomness) XXX_Size() int { + return m.Size() +} +func (m *PublicRandomness) XXX_DiscardUnknown() { + xxx_messageInfo_PublicRandomness.DiscardUnknown(m) +} + +var xxx_messageInfo_PublicRandomness proto.InternalMessageInfo + +func (m *PublicRandomness) GetBlockHeight() uint64 { + if m != nil { + return m.BlockHeight + } + return 0 +} + +// PubRandCommitWithPK is the public randomness commitment with the finality provider's BTC public key +type PubRandCommitWithPK struct { + // fp_btc_pk is the BTC PK of the finality provider that commits the public randomness + FpBtcPk *github_com_babylonlabs_io_babylon_types.BIP340PubKey `protobuf:"bytes,1,opt,name=fp_btc_pk,json=fpBtcPk,proto3,customtype=github.com/babylonlabs-io/babylon/types.BIP340PubKey" json:"fp_btc_pk,omitempty"` + // pub_rand_commit is the public randomness commitment + PubRandCommit *PubRandCommit `protobuf:"bytes,2,opt,name=pub_rand_commit,json=pubRandCommit,proto3" json:"pub_rand_commit,omitempty"` +} + +func (m *PubRandCommitWithPK) Reset() { *m = PubRandCommitWithPK{} } +func (m *PubRandCommitWithPK) String() string { return proto.CompactTextString(m) } +func (*PubRandCommitWithPK) ProtoMessage() {} +func (*PubRandCommitWithPK) Descriptor() ([]byte, []int) { + return fileDescriptor_52dc577f74d797d1, []int{3} +} +func (m *PubRandCommitWithPK) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *PubRandCommitWithPK) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_PubRandCommitWithPK.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 *PubRandCommitWithPK) XXX_Merge(src proto.Message) { + xxx_messageInfo_PubRandCommitWithPK.Merge(m, src) +} +func (m *PubRandCommitWithPK) XXX_Size() int { + return m.Size() +} +func (m *PubRandCommitWithPK) XXX_DiscardUnknown() { + xxx_messageInfo_PubRandCommitWithPK.DiscardUnknown(m) +} + +var xxx_messageInfo_PubRandCommitWithPK proto.InternalMessageInfo + +func (m *PubRandCommitWithPK) GetPubRandCommit() *PubRandCommit { + if m != nil { + return m.PubRandCommit + } + return nil +} + +// SigningInfo stores finality provider signing info of corresponding BTC public key. +type SigningInfo struct { + // fp_btc_pk is the BTC PK of the finality provider + FpBtcPk *github_com_babylonlabs_io_babylon_types.BIP340PubKey `protobuf:"bytes,1,opt,name=fp_btc_pk,json=fpBtcPk,proto3,customtype=github.com/babylonlabs-io/babylon/types.BIP340PubKey" json:"fp_btc_pk,omitempty"` + // fp_signing_info represents the signing info of this finality provider. + FpSigningInfo FinalityProviderSigningInfo `protobuf:"bytes,2,opt,name=fp_signing_info,json=fpSigningInfo,proto3" json:"fp_signing_info"` +} + +func (m *SigningInfo) Reset() { *m = SigningInfo{} } +func (m *SigningInfo) String() string { return proto.CompactTextString(m) } +func (*SigningInfo) ProtoMessage() {} +func (*SigningInfo) Descriptor() ([]byte, []int) { + return fileDescriptor_52dc577f74d797d1, []int{4} +} +func (m *SigningInfo) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *SigningInfo) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_SigningInfo.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 *SigningInfo) XXX_Merge(src proto.Message) { + xxx_messageInfo_SigningInfo.Merge(m, src) +} +func (m *SigningInfo) XXX_Size() int { + return m.Size() +} +func (m *SigningInfo) XXX_DiscardUnknown() { + xxx_messageInfo_SigningInfo.DiscardUnknown(m) +} + +var xxx_messageInfo_SigningInfo proto.InternalMessageInfo + +func (m *SigningInfo) GetFpSigningInfo() FinalityProviderSigningInfo { + if m != nil { + return m.FpSigningInfo + } + return FinalityProviderSigningInfo{} +} + +// FinalityProviderMissedBlocks contains array of missed blocks of corresponding +// BTC public key. +type FinalityProviderMissedBlocks struct { + // fp_btc_pk is the BTC PK of the finality provider + FpBtcPk *github_com_babylonlabs_io_babylon_types.BIP340PubKey `protobuf:"bytes,1,opt,name=fp_btc_pk,json=fpBtcPk,proto3,customtype=github.com/babylonlabs-io/babylon/types.BIP340PubKey" json:"fp_btc_pk,omitempty"` + // missed_blocks is an array of missed blocks by the finality provider. + MissedBlocks []MissedBlock `protobuf:"bytes,2,rep,name=missed_blocks,json=missedBlocks,proto3" json:"missed_blocks"` +} + +func (m *FinalityProviderMissedBlocks) Reset() { *m = FinalityProviderMissedBlocks{} } +func (m *FinalityProviderMissedBlocks) String() string { return proto.CompactTextString(m) } +func (*FinalityProviderMissedBlocks) ProtoMessage() {} +func (*FinalityProviderMissedBlocks) Descriptor() ([]byte, []int) { + return fileDescriptor_52dc577f74d797d1, []int{5} +} +func (m *FinalityProviderMissedBlocks) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *FinalityProviderMissedBlocks) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_FinalityProviderMissedBlocks.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 *FinalityProviderMissedBlocks) XXX_Merge(src proto.Message) { + xxx_messageInfo_FinalityProviderMissedBlocks.Merge(m, src) +} +func (m *FinalityProviderMissedBlocks) XXX_Size() int { + return m.Size() +} +func (m *FinalityProviderMissedBlocks) XXX_DiscardUnknown() { + xxx_messageInfo_FinalityProviderMissedBlocks.DiscardUnknown(m) +} + +var xxx_messageInfo_FinalityProviderMissedBlocks proto.InternalMessageInfo + +func (m *FinalityProviderMissedBlocks) GetMissedBlocks() []MissedBlock { + if m != nil { + return m.MissedBlocks + } + return nil +} + +// MissedBlock contains height and missed status as boolean. +type MissedBlock struct { + // index is the height at which the block was missed. + Index int64 `protobuf:"varint,1,opt,name=index,proto3" json:"index,omitempty"` + // missed is the missed status. + Missed bool `protobuf:"varint,2,opt,name=missed,proto3" json:"missed,omitempty"` +} + +func (m *MissedBlock) Reset() { *m = MissedBlock{} } +func (m *MissedBlock) String() string { return proto.CompactTextString(m) } +func (*MissedBlock) ProtoMessage() {} +func (*MissedBlock) Descriptor() ([]byte, []int) { + return fileDescriptor_52dc577f74d797d1, []int{6} +} +func (m *MissedBlock) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MissedBlock) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MissedBlock.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 *MissedBlock) XXX_Merge(src proto.Message) { + xxx_messageInfo_MissedBlock.Merge(m, src) +} +func (m *MissedBlock) XXX_Size() int { + return m.Size() +} +func (m *MissedBlock) XXX_DiscardUnknown() { + xxx_messageInfo_MissedBlock.DiscardUnknown(m) +} + +var xxx_messageInfo_MissedBlock proto.InternalMessageInfo + +func (m *MissedBlock) GetIndex() int64 { + if m != nil { + return m.Index + } + return 0 +} + +func (m *MissedBlock) GetMissed() bool { + if m != nil { + return m.Missed + } + return false +} + func init() { proto.RegisterType((*GenesisState)(nil), "babylon.finality.v1.GenesisState") + proto.RegisterType((*VoteSig)(nil), "babylon.finality.v1.VoteSig") + proto.RegisterType((*PublicRandomness)(nil), "babylon.finality.v1.PublicRandomness") + proto.RegisterType((*PubRandCommitWithPK)(nil), "babylon.finality.v1.PubRandCommitWithPK") + proto.RegisterType((*SigningInfo)(nil), "babylon.finality.v1.SigningInfo") + proto.RegisterType((*FinalityProviderMissedBlocks)(nil), "babylon.finality.v1.FinalityProviderMissedBlocks") + proto.RegisterType((*MissedBlock)(nil), "babylon.finality.v1.MissedBlock") } func init() { proto.RegisterFile("babylon/finality/v1/genesis.proto", fileDescriptor_52dc577f74d797d1) } var fileDescriptor_52dc577f74d797d1 = []byte{ - // 200 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x52, 0x4c, 0x4a, 0x4c, 0xaa, - 0xcc, 0xc9, 0xcf, 0xd3, 0x4f, 0xcb, 0xcc, 0x4b, 0xcc, 0xc9, 0x2c, 0xa9, 0xd4, 0x2f, 0x33, 0xd4, - 0x4f, 0x4f, 0xcd, 0x4b, 0x2d, 0xce, 0x2c, 0xd6, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0x12, 0x86, - 0x2a, 0xd1, 0x83, 0x29, 0xd1, 0x2b, 0x33, 0x94, 0x12, 0x49, 0xcf, 0x4f, 0xcf, 0x07, 0xcb, 0xeb, - 0x83, 0x58, 0x10, 0xa5, 0x52, 0x0a, 0xd8, 0x4c, 0x2b, 0x48, 0x2c, 0x4a, 0xcc, 0x85, 0x1a, 0xa6, - 0xe4, 0xc9, 0xc5, 0xe3, 0x0e, 0x31, 0x3d, 0xb8, 0x24, 0xb1, 0x24, 0x55, 0xc8, 0x92, 0x8b, 0x0d, - 0x22, 0x2f, 0xc1, 0xa8, 0xc0, 0xa8, 0xc1, 0x6d, 0x24, 0xad, 0x87, 0xc5, 0x36, 0xbd, 0x00, 0xb0, - 0x12, 0x27, 0x96, 0x13, 0xf7, 0xe4, 0x19, 0x82, 0xa0, 0x1a, 0x9c, 0xbc, 0x4e, 0x3c, 0x92, 0x63, - 0xbc, 0xf0, 0x48, 0x8e, 0xf1, 0xc1, 0x23, 0x39, 0xc6, 0x09, 0x8f, 0xe5, 0x18, 0x2e, 0x3c, 0x96, - 0x63, 0xb8, 0xf1, 0x58, 0x8e, 0x21, 0xca, 0x20, 0x3d, 0xb3, 0x24, 0xa3, 0x34, 0x49, 0x2f, 0x39, - 0x3f, 0x57, 0x1f, 0x6a, 0x5c, 0x72, 0x46, 0x62, 0x66, 0x1e, 0x8c, 0xa3, 0x5f, 0x81, 0x70, 0x60, - 0x49, 0x65, 0x41, 0x6a, 0x71, 0x12, 0x1b, 0xd8, 0x75, 0xc6, 0x80, 0x00, 0x00, 0x00, 0xff, 0xff, - 0x58, 0x11, 0xae, 0xb4, 0x0f, 0x01, 0x00, 0x00, + // 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, 0x33, 0x63, 0xb0, 0x6a, + 0x1a, 0xe6, 0xa0, 0x4b, 0xbd, 0xba, 0x4d, 0x3c, 0xa3, 0x4b, 0xf8, 0xa0, 0xde, 0x5f, 0xaf, 0x3b, + 0xd8, 0xc3, 0x8c, 0x30, 0xd5, 0x0f, 0x28, 0xa7, 0x70, 0x21, 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, 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, } func (m *GenesisState) Marshal() (dAtA []byte, err error) { @@ -111,48 +517,1415 @@ func (m *GenesisState) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l + if len(m.MissedBlocks) > 0 { + for iNdEx := len(m.MissedBlocks) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.MissedBlocks[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.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 = encodeVarintGenesis(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x3a + } + } + if len(m.PubRandCommit) > 0 { + for iNdEx := len(m.PubRandCommit) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.PubRandCommit[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintGenesis(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x32 + } + } + if len(m.PublicRandomness) > 0 { + for iNdEx := len(m.PublicRandomness) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.PublicRandomness[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintGenesis(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x2a + } + } + if len(m.VoteSigs) > 0 { + for iNdEx := len(m.VoteSigs) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.VoteSigs[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.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 = encodeVarintGenesis(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x1a + } + } + if len(m.IndexedBlocks) > 0 { + for iNdEx := len(m.IndexedBlocks) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.IndexedBlocks[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintGenesis(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + } + } { size, err := m.Params.MarshalToSizedBuffer(dAtA[:i]) if err != nil { return 0, err } - i -= size - i = encodeVarintGenesis(dAtA, i, uint64(size)) + i -= size + i = encodeVarintGenesis(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + return len(dAtA) - i, nil +} + +func (m *VoteSig) 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 *VoteSig) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *VoteSig) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.FinalitySig != nil { + { + size := m.FinalitySig.Size() + i -= size + if _, err := m.FinalitySig.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintGenesis(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x1a + } + 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 *PublicRandomness) 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 *PublicRandomness) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *PublicRandomness) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.PubRand != nil { + { + size := m.PubRand.Size() + i -= size + if _, err := m.PubRand.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintGenesis(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x1a + } + 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 *PubRandCommitWithPK) 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 *PubRandCommitWithPK) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *PubRandCommitWithPK) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.PubRandCommit != nil { + { + size, err := m.PubRandCommit.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintGenesis(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + } + 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] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *SigningInfo) 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 *SigningInfo) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *SigningInfo) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + { + size, err := m.FpSigningInfo.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintGenesis(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + 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] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *FinalityProviderMissedBlocks) 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 *FinalityProviderMissedBlocks) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *FinalityProviderMissedBlocks) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.MissedBlocks) > 0 { + for iNdEx := len(m.MissedBlocks) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.MissedBlocks[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintGenesis(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + } + } + 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] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *MissedBlock) 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 *MissedBlock) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MissedBlock) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.Missed { + i-- + if m.Missed { + dAtA[i] = 1 + } else { + dAtA[i] = 0 + } + i-- + dAtA[i] = 0x10 + } + if m.Index != 0 { + i = encodeVarintGenesis(dAtA, i, uint64(m.Index)) + i-- + dAtA[i] = 0x8 + } + 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 = m.Params.Size() + n += 1 + l + sovGenesis(uint64(l)) + if len(m.IndexedBlocks) > 0 { + for _, e := range m.IndexedBlocks { + l = e.Size() + n += 1 + l + sovGenesis(uint64(l)) + } + } + if len(m.Evidences) > 0 { + for _, e := range m.Evidences { + l = e.Size() + n += 1 + l + sovGenesis(uint64(l)) + } + } + if len(m.VoteSigs) > 0 { + for _, e := range m.VoteSigs { + l = e.Size() + n += 1 + l + sovGenesis(uint64(l)) + } + } + if len(m.PublicRandomness) > 0 { + for _, e := range m.PublicRandomness { + l = e.Size() + n += 1 + l + sovGenesis(uint64(l)) + } + } + if len(m.PubRandCommit) > 0 { + for _, e := range m.PubRandCommit { + l = e.Size() + n += 1 + l + sovGenesis(uint64(l)) + } + } + if len(m.SigningInfos) > 0 { + for _, e := range m.SigningInfos { + l = e.Size() + n += 1 + l + sovGenesis(uint64(l)) + } + } + if len(m.MissedBlocks) > 0 { + for _, e := range m.MissedBlocks { + l = e.Size() + n += 1 + l + sovGenesis(uint64(l)) + } + } + return n +} + +func (m *VoteSig) 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.FinalitySig != nil { + l = m.FinalitySig.Size() + n += 1 + l + sovGenesis(uint64(l)) + } + return n +} + +func (m *PublicRandomness) 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.PubRand != nil { + l = m.PubRand.Size() + n += 1 + l + sovGenesis(uint64(l)) + } + return n +} + +func (m *PubRandCommitWithPK) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.FpBtcPk != nil { + l = m.FpBtcPk.Size() + n += 1 + l + sovGenesis(uint64(l)) + } + if m.PubRandCommit != nil { + l = m.PubRandCommit.Size() + n += 1 + l + sovGenesis(uint64(l)) + } + return n +} + +func (m *SigningInfo) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.FpBtcPk != nil { + l = m.FpBtcPk.Size() + n += 1 + l + sovGenesis(uint64(l)) + } + l = m.FpSigningInfo.Size() + n += 1 + l + sovGenesis(uint64(l)) + return n +} + +func (m *FinalityProviderMissedBlocks) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.FpBtcPk != nil { + l = m.FpBtcPk.Size() + n += 1 + l + sovGenesis(uint64(l)) + } + if len(m.MissedBlocks) > 0 { + for _, e := range m.MissedBlocks { + l = e.Size() + n += 1 + l + sovGenesis(uint64(l)) + } + } + return n +} + +func (m *MissedBlock) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.Index != 0 { + n += 1 + sovGenesis(uint64(m.Index)) + } + if m.Missed { + n += 2 + } + 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 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 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 err := m.Params.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field IndexedBlocks", 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.IndexedBlocks = append(m.IndexedBlocks, &IndexedBlock{}) + if err := m.IndexedBlocks[len(m.IndexedBlocks)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Evidences", 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.Evidences = append(m.Evidences, &Evidence{}) + if err := m.Evidences[len(m.Evidences)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field VoteSigs", 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.VoteSigs = append(m.VoteSigs, &VoteSig{}) + if err := m.VoteSigs[len(m.VoteSigs)-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 PublicRandomness", 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.PublicRandomness = append(m.PublicRandomness, &PublicRandomness{}) + if err := m.PublicRandomness[len(m.PublicRandomness)-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 PubRandCommit", 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.PubRandCommit = append(m.PubRandCommit, &PubRandCommitWithPK{}) + if err := m.PubRandCommit[len(m.PubRandCommit)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 7: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field SigningInfos", 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.SigningInfos = append(m.SigningInfos, SigningInfo{}) + if err := m.SigningInfos[len(m.SigningInfos)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 8: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field MissedBlocks", 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.MissedBlocks = append(m.MissedBlocks, FinalityProviderMissedBlocks{}) + if err := m.MissedBlocks[len(m.MissedBlocks)-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 *VoteSig) 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: VoteSig: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: VoteSig: 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 != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field FinalitySig", 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.SchnorrEOTSSig + m.FinalitySig = &v + if err := m.FinalitySig.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 *PublicRandomness) 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: PublicRandomness: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: PublicRandomness: 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 != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field PubRand", 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.SchnorrPubRand + m.PubRand = &v + if err := m.PubRand.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 *PubRandCommitWithPK) 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: PubRandCommitWithPK: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: PubRandCommitWithPK: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + 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 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field PubRandCommit", 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.PubRandCommit == nil { + m.PubRandCommit = &PubRandCommit{} + } + if err := m.PubRandCommit.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 + } } - i-- - dAtA[i] = 0xa - 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++ + if iNdEx > l { + return io.ErrUnexpectedEOF } - dAtA[offset] = uint8(v) - return base + return nil } -func (m *GenesisState) Size() (n int) { - if m == nil { - return 0 +func (m *SigningInfo) 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: SigningInfo: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: SigningInfo: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + 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 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field FpSigningInfo", 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 err := m.FpSigningInfo.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 + } } - var l int - _ = l - l = m.Params.Size() - 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)))) + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil } -func (m *GenesisState) Unmarshal(dAtA []byte) error { +func (m *FinalityProviderMissedBlocks) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -175,15 +1948,50 @@ func (m *GenesisState) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: GenesisState: wiretype end group for non-group") + return fmt.Errorf("proto: FinalityProviderMissedBlocks: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: GenesisState: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: FinalityProviderMissedBlocks: 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) + 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 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field MissedBlocks", wireType) } var msglen int for shift := uint(0); ; shift += 7 { @@ -210,7 +2018,8 @@ func (m *GenesisState) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - if err := m.Params.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + m.MissedBlocks = append(m.MissedBlocks, MissedBlock{}) + if err := m.MissedBlocks[len(m.MissedBlocks)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } iNdEx = postIndex @@ -235,6 +2044,95 @@ func (m *GenesisState) Unmarshal(dAtA []byte) error { } return nil } +func (m *MissedBlock) 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: MissedBlock: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MissedBlock: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Index", wireType) + } + m.Index = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenesis + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Index |= int64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 2: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Missed", wireType) + } + var v int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenesis + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + v |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + m.Missed = bool(v != 0) + 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/genesis_test.go b/x/finality/types/genesis_test.go index 97dbf25c2..3b1969ff6 100644 --- a/x/finality/types/genesis_test.go +++ b/x/finality/types/genesis_test.go @@ -3,8 +3,9 @@ package types_test import ( "testing" - "github.com/babylonchain/babylon/x/finality/types" "github.com/stretchr/testify/require" + + "github.com/babylonlabs-io/babylon/x/finality/types" ) func TestGenesisState_Validate(t *testing.T) { @@ -19,13 +20,13 @@ func TestGenesisState_Validate(t *testing.T) { valid: true, }, { - desc: "valid genesis state", + desc: "invalid genesis state", genState: &types.GenesisState{ Params: types.Params{ MinPubRand: 200, }, }, - valid: true, + valid: false, }, } for _, tc := range tests { diff --git a/x/finality/types/hooks.go b/x/finality/types/hooks.go new file mode 100644 index 000000000..d87591ab8 --- /dev/null +++ b/x/finality/types/hooks.go @@ -0,0 +1,26 @@ +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 0a5ce2e40..055de21d4 100644 --- a/x/finality/types/keys.go +++ b/x/finality/types/keys.go @@ -1,5 +1,12 @@ package types +import ( + "cosmossdk.io/collections" + "github.com/cosmos/cosmos-sdk/types/address" + + "github.com/babylonlabs-io/babylon/types" +) + const ( // ModuleName defines the module name ModuleName = "finality" @@ -12,17 +19,45 @@ const ( // MemStoreKey defines the in-memory store key MemStoreKey = "mem_finality" + + // MissedBlockBitmapChunkSize defines the chunk size, in number of bits, of a + // finality provider missed block bitmap. Chunks are used to reduce the storage and + // write overhead of IAVL nodes. The total size of the bitmap is roughly in + // the range [0, SignedBlocksWindow) where each bit represents a block. A + // finality provider's IndexOffset modulo the SignedBlocksWindow is used to retrieve + // the chunk in that bitmap range. Once the chunk is retrieved, the same index + // is used to check or flip a bit, where if a bit is set, it indicates the + // finality provider missed that block. + // + // For a bitmap of N items, i.e. a finality provider's signed block window, the amount + // of write complexity per write with a factor of f being the overhead of + // IAVL being un-optimized, i.e. 2-4, is as follows: + // + // ChunkSize + (f * 256 ) + 256 * log_2(N / ChunkSize) + // + // As for the storage overhead, with the same factor f, it is as follows: + // (N - 256) + (N / ChunkSize) * (512 * f) + MissedBlockBitmapChunkSize = 1024 // 2^10 bits ) var ( - BlockKey = []byte{0x01} // key prefix for blocks - VoteKey = []byte{0x02} // key prefix for votes - PubRandKey = []byte{0x03} // key prefix for public randomness - ParamsKey = []byte{0x04} // key prefix for the parameters - EvidenceKey = []byte{0x05} // key prefix for evidences - NextHeightToFinalizeKey = []byte{0x06} // key prefix for next height to finalise + BlockKey = []byte{0x01} // key prefix for blocks + VoteKey = []byte{0x02} // key prefix for votes + PubRandKey = []byte{0x03} // key prefix for public randomness + PubRandCommitKey = []byte{0x04} // key prefix for commitment of public randomness + ParamsKey = []byte{0x05} // key prefix for the parameters + EvidenceKey = []byte{0x06} // key prefix for evidences + 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 ) -func KeyPrefix(p string) []byte { - return []byte(p) +// FinalityProviderSigningInfoKey - stored by finality provider public key in BIP340 +func FinalityProviderSigningInfoKey(pk *types.BIP340PubKey) []byte { + return append(FinalityProviderSigningInfoKeyPrefix, address.MustLengthPrefix(pk.MustMarshal())...) +} + +// FinalityProviderMissedBlockBitmapKey - stored by finality provider public key in BIP340 +func FinalityProviderMissedBlockBitmapKey(pk *types.BIP340PubKey) []byte { + return append(FinalityProviderMissedBlockBitmapKeyPrefix, address.MustLengthPrefix(pk.MustMarshal())...) } diff --git a/x/finality/types/metrics.go b/x/finality/types/metrics.go new file mode 100644 index 000000000..2c8d89ae2 --- /dev/null +++ b/x/finality/types/metrics.go @@ -0,0 +1,76 @@ +package types + +import ( + "github.com/cosmos/cosmos-sdk/telemetry" + "github.com/hashicorp/go-metrics" +) + +// performance oriented metrics measuring the execution time of each message +const ( + MetricsKeyCommitPubRandList = "commit_pub_rand_list" + MetricsKeyAddFinalitySig = "add_finality_sig" +) + +const ( + /* Metrics for monitoring block finalization status */ + + // MetricsKeyLastHeight is the key of the gauge recording the last height + // of the ledger + MetricsKeyLastHeight = "last_height" + // MetricsKeyLastFinalizedHeight is the key of the gauge recording the + // last height finalized by finality providers + MetricsKeyLastFinalizedHeight = "last_finalized_height" + + /* Metrics for monitoring finality provider liveness */ + + // MetricsKeySluggishFinalityProviderCounter is the number of finality providers + // that are being labeled as sluggish + MetricsKeySluggishFinalityProviderCounter = "sluggish_finality_provider_counter" +) + +// RecordLastHeight records the last height. It is triggered upon `IndexBlock` +func RecordLastHeight(height uint64) { + keys := []string{MetricsKeyLastHeight} + labels := []metrics.Label{telemetry.NewLabel(telemetry.MetricLabelNameModule, ModuleName)} + telemetry.SetGaugeWithLabels( + keys, + float32(height), + labels, + ) +} + +// RecordLastFinalizedHeight records the last finalized height. It is triggered upon +// finalizing a block becomes finalized +func RecordLastFinalizedHeight(height uint64) { + keys := []string{MetricsKeyLastFinalizedHeight} + labels := []metrics.Label{telemetry.NewLabel(telemetry.MetricLabelNameModule, ModuleName)} + telemetry.SetGaugeWithLabels( + keys, + float32(height), + labels, + ) +} + +// IncrementSluggishFinalityProviderCounter increments the counter for the sluggish +// finality providers +func IncrementSluggishFinalityProviderCounter() { + keys := []string{MetricsKeySluggishFinalityProviderCounter} + labels := []metrics.Label{telemetry.NewLabel(telemetry.MetricLabelNameModule, ModuleName)} + telemetry.IncrCounterWithLabels( + keys, + 1, + labels, + ) +} + +// DecrementSluggishFinalityProviderCounter increments the counter for the sluggish +// finality providers +func DecrementSluggishFinalityProviderCounter() { + keys := []string{MetricsKeySluggishFinalityProviderCounter} + labels := []metrics.Label{telemetry.NewLabel(telemetry.MetricLabelNameModule, ModuleName)} + telemetry.IncrCounterWithLabels( + keys, + -1, + labels, + ) +} diff --git a/x/finality/types/mocked_keepers.go b/x/finality/types/mocked_keepers.go index fc73bf710..c546a68da 100644 --- a/x/finality/types/mocked_keepers.go +++ b/x/finality/types/mocked_keepers.go @@ -8,7 +8,8 @@ import ( context "context" reflect "reflect" - types "github.com/babylonchain/babylon/x/btcstaking/types" + types "github.com/babylonlabs-io/babylon/types" + types0 "github.com/babylonlabs-io/babylon/x/btcstaking/types" gomock "github.com/golang/mock/gomock" ) @@ -51,10 +52,10 @@ func (mr *MockBTCStakingKeeperMockRecorder) GetBTCStakingActivatedHeight(ctx int } // GetFinalityProvider mocks base method. -func (m *MockBTCStakingKeeper) GetFinalityProvider(ctx context.Context, fpBTCPK []byte) (*types.FinalityProvider, error) { +func (m *MockBTCStakingKeeper) GetFinalityProvider(ctx context.Context, fpBTCPK []byte) (*types0.FinalityProvider, error) { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "GetFinalityProvider", ctx, fpBTCPK) - ret0, _ := ret[0].(*types.FinalityProvider) + ret0, _ := ret[0].(*types0.FinalityProvider) ret1, _ := ret[1].(error) return ret0, ret1 } @@ -65,19 +66,32 @@ func (mr *MockBTCStakingKeeperMockRecorder) GetFinalityProvider(ctx, fpBTCPK int return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetFinalityProvider", reflect.TypeOf((*MockBTCStakingKeeper)(nil).GetFinalityProvider), ctx, fpBTCPK) } -// GetRewardDistCache mocks base method. -func (m *MockBTCStakingKeeper) GetRewardDistCache(ctx context.Context, height uint64) (*types.RewardDistCache, error) { +// GetLastFinalizedEpoch mocks base method. +func (m *MockBTCStakingKeeper) GetLastFinalizedEpoch(ctx context.Context) uint64 { m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "GetRewardDistCache", ctx, height) - ret0, _ := ret[0].(*types.RewardDistCache) - ret1, _ := ret[1].(error) - return ret0, ret1 + ret := m.ctrl.Call(m, "GetLastFinalizedEpoch", ctx) + ret0, _ := ret[0].(uint64) + return ret0 } -// GetRewardDistCache indicates an expected call of GetRewardDistCache. -func (mr *MockBTCStakingKeeperMockRecorder) GetRewardDistCache(ctx, height interface{}) *gomock.Call { +// GetLastFinalizedEpoch indicates an expected call of GetLastFinalizedEpoch. +func (mr *MockBTCStakingKeeperMockRecorder) GetLastFinalizedEpoch(ctx interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetRewardDistCache", reflect.TypeOf((*MockBTCStakingKeeper)(nil).GetRewardDistCache), ctx, height) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetLastFinalizedEpoch", reflect.TypeOf((*MockBTCStakingKeeper)(nil).GetLastFinalizedEpoch), ctx) +} + +// GetParams mocks base method. +func (m *MockBTCStakingKeeper) GetParams(ctx context.Context) types0.Params { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "GetParams", ctx) + ret0, _ := ret[0].(types0.Params) + return ret0 +} + +// 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, "GetParams", reflect.TypeOf((*MockBTCStakingKeeper)(nil).GetParams), ctx) } // GetVotingPower mocks base method. @@ -94,6 +108,21 @@ func (mr *MockBTCStakingKeeperMockRecorder) GetVotingPower(ctx, fpBTCPK, height return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetVotingPower", reflect.TypeOf((*MockBTCStakingKeeper)(nil).GetVotingPower), ctx, fpBTCPK, height) } +// GetVotingPowerDistCache mocks base method. +func (m *MockBTCStakingKeeper) GetVotingPowerDistCache(ctx context.Context, height uint64) (*types0.VotingPowerDistCache, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "GetVotingPowerDistCache", ctx, height) + ret0, _ := ret[0].(*types0.VotingPowerDistCache) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// GetVotingPowerDistCache indicates an expected call of GetVotingPowerDistCache. +func (mr *MockBTCStakingKeeperMockRecorder) GetVotingPowerDistCache(ctx, height interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetVotingPowerDistCache", reflect.TypeOf((*MockBTCStakingKeeper)(nil).GetVotingPowerDistCache), ctx, height) +} + // GetVotingPowerTable mocks base method. func (m *MockBTCStakingKeeper) GetVotingPowerTable(ctx context.Context, height uint64) map[string]uint64 { m.ctrl.T.Helper() @@ -122,16 +151,30 @@ func (mr *MockBTCStakingKeeperMockRecorder) HasFinalityProvider(ctx, fpBTCPK int return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "HasFinalityProvider", reflect.TypeOf((*MockBTCStakingKeeper)(nil).HasFinalityProvider), ctx, fpBTCPK) } -// RemoveRewardDistCache mocks base method. -func (m *MockBTCStakingKeeper) RemoveRewardDistCache(ctx context.Context, height uint64) { +// RemoveVotingPowerDistCache mocks base method. +func (m *MockBTCStakingKeeper) RemoveVotingPowerDistCache(ctx context.Context, height uint64) { m.ctrl.T.Helper() - m.ctrl.Call(m, "RemoveRewardDistCache", ctx, height) + m.ctrl.Call(m, "RemoveVotingPowerDistCache", ctx, height) } -// RemoveRewardDistCache indicates an expected call of RemoveRewardDistCache. -func (mr *MockBTCStakingKeeperMockRecorder) RemoveRewardDistCache(ctx, height interface{}) *gomock.Call { +// RemoveVotingPowerDistCache indicates an expected call of RemoveVotingPowerDistCache. +func (mr *MockBTCStakingKeeperMockRecorder) RemoveVotingPowerDistCache(ctx, height interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "RemoveRewardDistCache", reflect.TypeOf((*MockBTCStakingKeeper)(nil).RemoveRewardDistCache), ctx, height) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "RemoveVotingPowerDistCache", reflect.TypeOf((*MockBTCStakingKeeper)(nil).RemoveVotingPowerDistCache), ctx, height) +} + +// RevertSluggishFinalityProvider mocks base method. +func (m *MockBTCStakingKeeper) RevertSluggishFinalityProvider(ctx context.Context, fpBTCPK []byte) error { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "RevertSluggishFinalityProvider", ctx, fpBTCPK) + ret0, _ := ret[0].(error) + return ret0 +} + +// RevertSluggishFinalityProvider indicates an expected call of RevertSluggishFinalityProvider. +func (mr *MockBTCStakingKeeperMockRecorder) RevertSluggishFinalityProvider(ctx, fpBTCPK interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "RevertSluggishFinalityProvider", reflect.TypeOf((*MockBTCStakingKeeper)(nil).RevertSluggishFinalityProvider), ctx, fpBTCPK) } // SlashFinalityProvider mocks base method. @@ -172,13 +215,87 @@ func (m *MockIncentiveKeeper) EXPECT() *MockIncentiveKeeperMockRecorder { } // RewardBTCStaking mocks base method. -func (m *MockIncentiveKeeper) RewardBTCStaking(ctx context.Context, height uint64, rdc *types.RewardDistCache) { +func (m *MockIncentiveKeeper) RewardBTCStaking(ctx context.Context, height uint64, filteredDc *types0.VotingPowerDistCache) { m.ctrl.T.Helper() - m.ctrl.Call(m, "RewardBTCStaking", ctx, height, rdc) + m.ctrl.Call(m, "RewardBTCStaking", ctx, height, filteredDc) } // RewardBTCStaking indicates an expected call of RewardBTCStaking. -func (mr *MockIncentiveKeeperMockRecorder) RewardBTCStaking(ctx, height, rdc interface{}) *gomock.Call { +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 { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "AfterFinalityProviderActivated", ctx, btcPk) + ret0, _ := ret[0].(error) + return ret0 +} + +// AfterFinalityProviderActivated indicates an expected call of AfterFinalityProviderActivated. +func (mr *MockBtcStakingHooksMockRecorder) AfterFinalityProviderActivated(ctx, btcPk 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 +} + +// AfterSluggishFinalityProviderDetected mocks base method. +func (m *MockFinalityHooks) AfterSluggishFinalityProviderDetected(ctx context.Context, btcPk *types.BIP340PubKey) error { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "AfterSluggishFinalityProviderDetected", ctx, btcPk) + ret0, _ := ret[0].(error) + return ret0 +} + +// AfterSluggishFinalityProviderDetected indicates an expected call of AfterSluggishFinalityProviderDetected. +func (mr *MockFinalityHooksMockRecorder) AfterSluggishFinalityProviderDetected(ctx, btcPk interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "RewardBTCStaking", reflect.TypeOf((*MockIncentiveKeeper)(nil).RewardBTCStaking), ctx, height, rdc) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "AfterSluggishFinalityProviderDetected", reflect.TypeOf((*MockFinalityHooks)(nil).AfterSluggishFinalityProviderDetected), ctx, btcPk) } diff --git a/x/finality/types/msg.go b/x/finality/types/msg.go index af941426f..a92b1bbc9 100644 --- a/x/finality/types/msg.go +++ b/x/finality/types/msg.go @@ -1,11 +1,10 @@ package types import ( - "fmt" + fmt "fmt" - "github.com/babylonchain/babylon/crypto/eots" - bbn "github.com/babylonchain/babylon/types" - "github.com/btcsuite/btcd/btcec/v2" + "github.com/babylonlabs-io/babylon/crypto/eots" + "github.com/cometbft/cometbft/crypto/merkle" "github.com/cometbft/cometbft/crypto/tmhash" sdk "github.com/cosmos/cosmos-sdk/types" ) @@ -17,48 +16,54 @@ var ( _ sdk.Msg = &MsgCommitPubRandList{} ) -func NewMsgAddFinalitySig(signer string, sk *btcec.PrivateKey, sr *eots.PrivateRand, blockHeight uint64, blockHash []byte) (*MsgAddFinalitySig, error) { - msg := &MsgAddFinalitySig{ - Signer: signer, - FpBtcPk: bbn.NewBIP340PubKeyFromBTCPK(sk.PubKey()), - BlockHeight: blockHeight, - BlockAppHash: blockHash, - } - msgToSign := msg.MsgToSign() - sig, err := eots.Sign(sk, sr, msgToSign) - if err != nil { - return nil, err - } - msg.FinalitySig = bbn.NewSchnorrEOTSSigFromModNScalar(sig) - - return msg, nil -} - func (m *MsgAddFinalitySig) MsgToSign() []byte { return msgToSignForVote(m.BlockHeight, m.BlockAppHash) } -func (m *MsgAddFinalitySig) VerifyEOTSSig(pubRand *bbn.SchnorrPubRand) error { +// 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 +// - verifying the finality signature w.r.t. the given block height/hash +func VerifyFinalitySig(m *MsgAddFinalitySig, prCommit *PubRandCommit) error { + // verify the index of the public randomness + heightOfProof := prCommit.StartHeight + uint64(m.Proof.Index) + if m.BlockHeight != heightOfProof { + return ErrInvalidFinalitySig.Wrapf("the inclusion proof (for height %d) does not correspond to the given height (%d) in the message", heightOfProof, m.BlockHeight) + } + // verify the total number of randomness is same as in the commit + if uint64(m.Proof.Total) != prCommit.NumPubRand { + return ErrInvalidFinalitySig.Wrapf("the total number of public randomnesses in the proof (%d) does not match the number of public randomnesses committed (%d)", m.Proof.Total, prCommit.NumPubRand) + } + // verify the proof of inclusion for this public randomness + unwrappedProof, err := merkle.ProofFromProto(m.Proof) + if err != nil { + return ErrInvalidFinalitySig.Wrapf("failed to unwrap proof: %v", err) + } + if err := unwrappedProof.Verify(prCommit.Commitment, *m.PubRand); err != nil { + return ErrInvalidFinalitySig.Wrapf("the inclusion proof of the public randomness is invalid: %v", err) + } + + // public randomness is good, verify finality signature msgToSign := m.MsgToSign() pk, err := m.FpBtcPk.ToBTCPK() if err != nil { return err } - - return eots.Verify(pk, pubRand.ToFieldVal(), msgToSign, m.FinalitySig.ToModNScalar()) + return eots.Verify(pk, m.PubRand.ToFieldVal(), msgToSign, m.FinalitySig.ToModNScalar()) } -// HashToSign returns a 32-byte hash of (start_height || pub_rand_list) +// HashToSign returns a 32-byte hash of (start_height || num_pub_rand || commitment) // The signature in MsgCommitPubRandList will be on this hash func (m *MsgCommitPubRandList) HashToSign() ([]byte, error) { hasher := tmhash.New() if _, err := hasher.Write(sdk.Uint64ToBigEndian(m.StartHeight)); err != nil { return nil, err } - for _, pr := range m.PubRandList { - if _, err := hasher.Write(pr.MustMarshal()); err != nil { - return nil, err - } + if _, err := hasher.Write(sdk.Uint64ToBigEndian(m.NumPubRand)); err != nil { + return nil, err + } + if _, err := hasher.Write(m.Commitment); err != nil { + return nil, err } return hasher.Sum(nil), nil } diff --git a/x/finality/types/msg_test.go b/x/finality/types/msg_test.go index 9dafd9d14..349185828 100644 --- a/x/finality/types/msg_test.go +++ b/x/finality/types/msg_test.go @@ -4,10 +4,9 @@ import ( "math/rand" "testing" - "github.com/babylonchain/babylon/crypto/eots" - "github.com/babylonchain/babylon/testutil/datagen" - bbn "github.com/babylonchain/babylon/types" - "github.com/babylonchain/babylon/x/finality/types" + "github.com/babylonlabs-io/babylon/crypto/eots" + "github.com/babylonlabs-io/babylon/testutil/datagen" + "github.com/babylonlabs-io/babylon/x/finality/types" "github.com/stretchr/testify/require" ) @@ -19,17 +18,27 @@ func FuzzMsgAddFinalitySig(f *testing.F) { sk, err := eots.KeyGen(r) require.NoError(t, err) - sr, pr, err := eots.RandGen(r) + + numPubRand := uint64(100) + randListInfo, err := datagen.GenRandomPubRandList(r, numPubRand) require.NoError(t, err) - blockHeight := datagen.RandomInt(r, 10) + + startHeight := datagen.RandomInt(r, 10) + blockHeight := startHeight + datagen.RandomInt(r, 10) blockHash := datagen.GenRandomByteArray(r, 32) signer := datagen.GenRandomAccount().Address - msg, err := types.NewMsgAddFinalitySig(signer, sk, sr, blockHeight, blockHash) + msg, err := datagen.NewMsgAddFinalitySig(signer, sk, startHeight, blockHeight, randListInfo, blockHash) require.NoError(t, err) - // verify msg's EOTS sig against the given public randomness - err = msg.VerifyEOTSSig(bbn.NewSchnorrPubRandFromFieldVal(pr)) + prCommit := &types.PubRandCommit{ + StartHeight: startHeight, + NumPubRand: numPubRand, + Commitment: randListInfo.Commitment, + } + + // verify the finality signature message + err = types.VerifyFinalitySig(msg, prCommit) require.NoError(t, err) }) } diff --git a/x/finality/types/params.go b/x/finality/types/params.go index de592797b..a936e17a5 100644 --- a/x/finality/types/params.go +++ b/x/finality/types/params.go @@ -2,21 +2,32 @@ package types import ( "fmt" + + "cosmossdk.io/math" paramtypes "github.com/cosmos/cosmos-sdk/x/params/types" "gopkg.in/yaml.v2" ) -var _ paramtypes.ParamSet = (*Params)(nil) +// Default parameter namespace +const ( + DefaultSignedBlocksWindow = int64(100) + DefaultMinPubRand = 100 + DefaultFinalitySigTimeout = 3 +) -// ParamKeyTable the param key table for launch module -func ParamKeyTable() paramtypes.KeyTable { - return paramtypes.NewKeyTable().RegisterParamSet(&Params{}) -} +var ( + DefaultMinSignedPerWindow = math.LegacyNewDecWithPrec(5, 1) +) + +var _ paramtypes.ParamSet = (*Params)(nil) // DefaultParams returns a default set of parameters func DefaultParams() Params { return Params{ - MinPubRand: 100, + FinalitySigTimeout: DefaultFinalitySigTimeout, + SignedBlocksWindow: DefaultSignedBlocksWindow, + MinSignedPerWindow: DefaultMinSignedPerWindow, + MinPubRand: DefaultMinPubRand, } } @@ -32,16 +43,84 @@ func validateMinPubRand(minPubRand uint64) error { return nil } -// Validate validates the set of params +// String implements the Stringer interface. +func (p Params) String() string { + out, _ := yaml.Marshal(p) + return string(out) +} + +// Validate validates the params func (p Params) Validate() error { + if err := validateSignedBlocksWindow(p.SignedBlocksWindow); err != nil { + return err + } + + if err := validateFinalitySigTimeout(p.FinalitySigTimeout); err != nil { + return err + } + + if err := validateMinSignedPerWindow(p.MinSignedPerWindow); err != nil { + return err + } + if err := validateMinPubRand(p.MinPubRand); err != nil { return err } + return nil } -// String implements the Stringer interface. -func (p Params) String() string { - out, _ := yaml.Marshal(p) - return string(out) +func validateSignedBlocksWindow(i interface{}) error { + v, ok := i.(int64) + if !ok { + return fmt.Errorf("invalid parameter type: %T", i) + } + + if v <= 0 { + return fmt.Errorf("signed blocks window must be positive: %d", v) + } + + return nil +} + +func validateFinalitySigTimeout(i interface{}) error { + v, ok := i.(int64) + if !ok { + return fmt.Errorf("invalid parameter type: %T", i) + } + + if v <= 0 { + return fmt.Errorf("finality vote delay must be positive: %d", v) + } + + return nil +} + +func validateMinSignedPerWindow(i interface{}) error { + v, ok := i.(math.LegacyDec) + if !ok { + return fmt.Errorf("invalid parameter type: %T", i) + } + + if v.IsNil() { + return fmt.Errorf("min signed per window cannot be nil: %s", v) + } + if v.IsNegative() { + return fmt.Errorf("min signed per window cannot be negative: %s", v) + } + if v.GT(math.LegacyOneDec()) { + return fmt.Errorf("min signed per window too large: %s", v) + } + + return nil +} + +// MinSignedPerWindowInt returns min signed per window as an integer (vs the decimal in the param) +func (p *Params) MinSignedPerWindowInt() int64 { + signedBlocksWindow := p.SignedBlocksWindow + minSignedPerWindow := p.MinSignedPerWindow + + // NOTE: RoundInt64 will never panic as minSignedPerWindow is + // less than 1. + return minSignedPerWindow.MulInt64(signedBlocksWindow).RoundInt64() } diff --git a/x/finality/types/params.pb.go b/x/finality/types/params.pb.go index fe81592df..cec13955b 100644 --- a/x/finality/types/params.pb.go +++ b/x/finality/types/params.pb.go @@ -4,7 +4,10 @@ package types import ( + cosmossdk_io_math "cosmossdk.io/math" fmt "fmt" + _ "github.com/cosmos/cosmos-proto" + _ "github.com/cosmos/cosmos-sdk/types/tx/amino" _ "github.com/cosmos/gogoproto/gogoproto" proto "github.com/cosmos/gogoproto/proto" io "io" @@ -25,9 +28,17 @@ const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package // Params defines the parameters for the module. type Params struct { + // 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"` + // 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"` + // 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 detected as sluggish + 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"` // min_pub_rand is the minimum number of public randomness each // message should commit - MinPubRand uint64 `protobuf:"varint,1,opt,name=min_pub_rand,json=minPubRand,proto3" json:"min_pub_rand,omitempty"` + MinPubRand uint64 `protobuf:"varint,4,opt,name=min_pub_rand,json=minPubRand,proto3" json:"min_pub_rand,omitempty"` } func (m *Params) Reset() { *m = Params{} } @@ -62,6 +73,20 @@ func (m *Params) XXX_DiscardUnknown() { var xxx_messageInfo_Params proto.InternalMessageInfo +func (m *Params) GetSignedBlocksWindow() int64 { + if m != nil { + return m.SignedBlocksWindow + } + return 0 +} + +func (m *Params) GetFinalitySigTimeout() int64 { + if m != nil { + return m.FinalitySigTimeout + } + return 0 +} + func (m *Params) GetMinPubRand() uint64 { if m != nil { return m.MinPubRand @@ -76,19 +101,30 @@ func init() { func init() { proto.RegisterFile("babylon/finality/v1/params.proto", fileDescriptor_25539c9a61c72ee9) } var fileDescriptor_25539c9a61c72ee9 = []byte{ - // 192 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x52, 0x48, 0x4a, 0x4c, 0xaa, - 0xcc, 0xc9, 0xcf, 0xd3, 0x4f, 0xcb, 0xcc, 0x4b, 0xcc, 0xc9, 0x2c, 0xa9, 0xd4, 0x2f, 0x33, 0xd4, - 0x2f, 0x48, 0x2c, 0x4a, 0xcc, 0x2d, 0xd6, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0x12, 0x86, 0xaa, - 0xd0, 0x83, 0xa9, 0xd0, 0x2b, 0x33, 0x94, 0x12, 0x49, 0xcf, 0x4f, 0xcf, 0x07, 0xcb, 0xeb, 0x83, - 0x58, 0x10, 0xa5, 0x4a, 0x06, 0x5c, 0x6c, 0x01, 0x60, 0xad, 0x42, 0x0a, 0x5c, 0x3c, 0xb9, 0x99, - 0x79, 0xf1, 0x05, 0xa5, 0x49, 0xf1, 0x45, 0x89, 0x79, 0x29, 0x12, 0x8c, 0x0a, 0x8c, 0x1a, 0x2c, - 0x41, 0x5c, 0xb9, 0x99, 0x79, 0x01, 0xa5, 0x49, 0x41, 0x89, 0x79, 0x29, 0x56, 0x2c, 0x33, 0x16, - 0xc8, 0x33, 0x38, 0x79, 0x9d, 0x78, 0x24, 0xc7, 0x78, 0xe1, 0x91, 0x1c, 0xe3, 0x83, 0x47, 0x72, - 0x8c, 0x13, 0x1e, 0xcb, 0x31, 0x5c, 0x78, 0x2c, 0xc7, 0x70, 0xe3, 0xb1, 0x1c, 0x43, 0x94, 0x41, - 0x7a, 0x66, 0x49, 0x46, 0x69, 0x92, 0x5e, 0x72, 0x7e, 0xae, 0x3e, 0xd4, 0x05, 0xc9, 0x19, 0x89, - 0x99, 0x79, 0x30, 0x8e, 0x7e, 0x05, 0xc2, 0xc9, 0x25, 0x95, 0x05, 0xa9, 0xc5, 0x49, 0x6c, 0x60, - 0x47, 0x18, 0x03, 0x02, 0x00, 0x00, 0xff, 0xff, 0xc1, 0x3d, 0x78, 0xb7, 0xd3, 0x00, 0x00, 0x00, + // 361 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x44, 0x91, 0x31, 0x6b, 0xe3, 0x30, + 0x14, 0xc7, 0xad, 0x4b, 0xc8, 0x60, 0xb2, 0x9c, 0x2f, 0x07, 0xb9, 0x1c, 0x38, 0xe6, 0xa6, 0x70, + 0x10, 0xab, 0x69, 0xa1, 0x43, 0xc7, 0x90, 0x31, 0x43, 0x70, 0x0a, 0x85, 0x2e, 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e, 0x5f, 0x9d, 0x51, 0x85, 0x4b, 0x17, 0x24, 0xe6, 0x24, 0x5b, 0xb8, 0x53, 0x16, + 0x91, 0xa0, 0x98, 0xb0, 0xe0, 0xe5, 0x79, 0x68, 0x56, 0x4f, 0x98, 0xb0, 0xe0, 0xf1, 0xe3, 0xe9, + 0x3f, 0xf2, 0x2c, 0x0e, 0x62, 0x5e, 0xde, 0x39, 0x63, 0x69, 0x15, 0xce, 0x31, 0xdb, 0x47, 0xab, + 0x24, 0xa7, 0x7e, 0x4a, 0x44, 0xd8, 0x6d, 0x3a, 0x68, 0xd0, 0xf4, 0x4c, 0x0e, 0x62, 0x96, 0x53, + 0x8f, 0x88, 0xf0, 0xa2, 0x79, 0xff, 0xd0, 0x37, 0xc6, 0xd3, 0xcd, 0xde, 0x46, 0xdb, 0xbd, 0x8d, + 0xde, 0xf7, 0x36, 0xba, 0x3b, 0xd8, 0xc6, 0xf6, 0x60, 0x1b, 0xaf, 0x07, 0xdb, 0xb8, 0x3e, 0x8d, + 0x20, 0x5b, 0xe4, 0xd4, 0x0d, 0x24, 0xc7, 0xd5, 0xfc, 0x63, 0x42, 0xd5, 0x10, 0x64, 0x5d, 0xe2, + 0xdb, 0xef, 0x2f, 0xcb, 0x8a, 0x84, 0x29, 0xda, 0x2a, 0xc7, 0x7a, 0xf6, 0x15, 0x00, 0x00, 0xff, + 0xff, 0xda, 0x3a, 0x9d, 0x97, 0xd3, 0x01, 0x00, 0x00, } func (m *Params) Marshal() (dAtA []byte, err error) { @@ -114,6 +150,26 @@ func (m *Params) MarshalToSizedBuffer(dAtA []byte) (int, error) { if m.MinPubRand != 0 { i = encodeVarintParams(dAtA, i, uint64(m.MinPubRand)) i-- + dAtA[i] = 0x20 + } + { + size := m.MinSignedPerWindow.Size() + i -= size + if _, err := m.MinSignedPerWindow.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintParams(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x1a + if m.FinalitySigTimeout != 0 { + i = encodeVarintParams(dAtA, i, uint64(m.FinalitySigTimeout)) + i-- + dAtA[i] = 0x10 + } + if m.SignedBlocksWindow != 0 { + i = encodeVarintParams(dAtA, i, uint64(m.SignedBlocksWindow)) + i-- dAtA[i] = 0x8 } return len(dAtA) - i, nil @@ -136,6 +192,14 @@ func (m *Params) Size() (n int) { } var l int _ = l + if m.SignedBlocksWindow != 0 { + n += 1 + sovParams(uint64(m.SignedBlocksWindow)) + } + if m.FinalitySigTimeout != 0 { + n += 1 + sovParams(uint64(m.FinalitySigTimeout)) + } + l = m.MinSignedPerWindow.Size() + n += 1 + l + sovParams(uint64(l)) if m.MinPubRand != 0 { n += 1 + sovParams(uint64(m.MinPubRand)) } @@ -178,6 +242,77 @@ func (m *Params) Unmarshal(dAtA []byte) error { } switch fieldNum { case 1: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field SignedBlocksWindow", wireType) + } + m.SignedBlocksWindow = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowParams + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.SignedBlocksWindow |= int64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 2: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field FinalitySigTimeout", wireType) + } + m.FinalitySigTimeout = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowParams + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.FinalitySigTimeout |= int64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field MinSignedPerWindow", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowParams + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthParams + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthParams + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.MinSignedPerWindow.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 4: if wireType != 0 { return fmt.Errorf("proto: wrong wireType = %d for field MinPubRand", wireType) } diff --git a/x/finality/types/query.pb.go b/x/finality/types/query.pb.go index a4b12e2ea..a0f7f3271 100644 --- a/x/finality/types/query.pb.go +++ b/x/finality/types/query.pb.go @@ -6,7 +6,7 @@ package types import ( context "context" fmt "fmt" - github_com_babylonchain_babylon_types "github.com/babylonchain/babylon/types" + github_com_babylonlabs_io_babylon_types "github.com/babylonlabs-io/babylon/types" query "github.com/cosmos/cosmos-sdk/types/query" _ "github.com/cosmos/gogoproto/gogoproto" grpc1 "github.com/cosmos/gogoproto/grpc" @@ -207,7 +207,7 @@ func (m *QueryListPublicRandomnessRequest) GetPagination() *query.PageRequest { 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_babylonchain_babylon_types.SchnorrPubRand `protobuf:"bytes,1,rep,name=pub_rand_map,json=pubRandMap,proto3,customtype=github.com/babylonchain/babylon/types.SchnorrPubRand" json:"pub_rand_map,omitempty" protobuf_key:"varint,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"` + 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"` } @@ -252,6 +252,174 @@ func (m *QueryListPublicRandomnessResponse) GetPagination() *query.PageResponse return nil } +// 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"` +} + +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{4} +} +func (m *PubRandCommitResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *PubRandCommitResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_PubRandCommitResponse.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 *PubRandCommitResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_PubRandCommitResponse.Merge(m, src) +} +func (m *PubRandCommitResponse) XXX_Size() int { + return m.Size() +} +func (m *PubRandCommitResponse) XXX_DiscardUnknown() { + xxx_messageInfo_PubRandCommitResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_PubRandCommitResponse proto.InternalMessageInfo + +func (m *PubRandCommitResponse) GetNumPubRand() uint64 { + if m != nil { + return m.NumPubRand + } + return 0 +} + +func (m *PubRandCommitResponse) GetCommitment() []byte { + if m != nil { + return m.Commitment + } + return nil +} + +// 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{5} +} +func (m *QueryListPubRandCommitRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryListPubRandCommitRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryListPubRandCommitRequest.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 *QueryListPubRandCommitRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryListPubRandCommitRequest.Merge(m, src) +} +func (m *QueryListPubRandCommitRequest) XXX_Size() int { + return m.Size() +} +func (m *QueryListPubRandCommitRequest) XXX_DiscardUnknown() { + xxx_messageInfo_QueryListPubRandCommitRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryListPubRandCommitRequest proto.InternalMessageInfo + +func (m *QueryListPubRandCommitRequest) GetFpBtcPkHex() string { + if m != nil { + return m.FpBtcPkHex + } + return "" +} + +func (m *QueryListPubRandCommitRequest) GetPagination() *query.PageRequest { + if m != nil { + return m.Pagination + } + return nil +} + +// 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{6} +} +func (m *QueryListPubRandCommitResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryListPubRandCommitResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryListPubRandCommitResponse.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 *QueryListPubRandCommitResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryListPubRandCommitResponse.Merge(m, src) +} +func (m *QueryListPubRandCommitResponse) XXX_Size() int { + return m.Size() +} +func (m *QueryListPubRandCommitResponse) XXX_DiscardUnknown() { + xxx_messageInfo_QueryListPubRandCommitResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryListPubRandCommitResponse proto.InternalMessageInfo + +func (m *QueryListPubRandCommitResponse) GetPubRandCommitMap() map[uint64]*PubRandCommitResponse { + if m != nil { + return m.PubRandCommitMap + } + return nil +} + +func (m *QueryListPubRandCommitResponse) GetPagination() *query.PageResponse { + if m != nil { + return m.Pagination + } + return nil +} + // QueryBlockRequest is the request type for the // Query/Block RPC method. type QueryBlockRequest struct { @@ -263,7 +431,7 @@ 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{4} + return fileDescriptor_32bddab77af6fdae, []int{7} } func (m *QueryBlockRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -310,7 +478,7 @@ 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{5} + return fileDescriptor_32bddab77af6fdae, []int{8} } func (m *QueryBlockResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -359,7 +527,7 @@ 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{6} + return fileDescriptor_32bddab77af6fdae, []int{9} } func (m *QueryListBlocksRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -415,7 +583,7 @@ 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{7} + return fileDescriptor_32bddab77af6fdae, []int{10} } func (m *QueryListBlocksResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -469,7 +637,7 @@ func (m *QueryVotesAtHeightRequest) Reset() { *m = QueryVotesAtHeightReq func (m *QueryVotesAtHeightRequest) String() string { return proto.CompactTextString(m) } func (*QueryVotesAtHeightRequest) ProtoMessage() {} func (*QueryVotesAtHeightRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_32bddab77af6fdae, []int{8} + return fileDescriptor_32bddab77af6fdae, []int{11} } func (m *QueryVotesAtHeightRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -510,14 +678,14 @@ func (m *QueryVotesAtHeightRequest) GetHeight() uint64 { 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_babylonchain_babylon_types.BIP340PubKey `protobuf:"bytes,1,rep,name=btc_pks,json=btcPks,proto3,customtype=github.com/babylonchain/babylon/types.BIP340PubKey" json:"btc_pks,omitempty"` + 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 *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{9} + return fileDescriptor_32bddab77af6fdae, []int{12} } func (m *QueryVotesAtHeightResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -558,7 +726,7 @@ 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{10} + return fileDescriptor_32bddab77af6fdae, []int{13} } func (m *QueryEvidenceRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -604,7 +772,7 @@ 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{11} + return fileDescriptor_32bddab77af6fdae, []int{14} } func (m *QueryEvidenceResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -654,7 +822,7 @@ func (m *QueryListEvidencesRequest) Reset() { *m = QueryListEvidencesReq func (m *QueryListEvidencesRequest) String() string { return proto.CompactTextString(m) } func (*QueryListEvidencesRequest) ProtoMessage() {} func (*QueryListEvidencesRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_32bddab77af6fdae, []int{12} + return fileDescriptor_32bddab77af6fdae, []int{15} } func (m *QueryListEvidencesRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -710,7 +878,7 @@ func (m *QueryListEvidencesResponse) Reset() { *m = QueryListEvidencesRe func (m *QueryListEvidencesResponse) String() string { return proto.CompactTextString(m) } func (*QueryListEvidencesResponse) ProtoMessage() {} func (*QueryListEvidencesResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_32bddab77af6fdae, []int{13} + return fileDescriptor_32bddab77af6fdae, []int{16} } func (m *QueryListEvidencesResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -753,13 +921,213 @@ func (m *QueryListEvidencesResponse) GetPagination() *query.PageResponse { return nil } +// 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 (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{17} +} +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 + } +} +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) +} + +var xxx_messageInfo_QuerySigningInfoRequest proto.InternalMessageInfo + +func (m *QuerySigningInfoRequest) GetFpBtcPkHex() string { + if m != nil { + return m.FpBtcPkHex + } + return "" +} + +// 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"` +} + +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{18} +} +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 nil, err + } + return b[:n], 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) +} + +var xxx_messageInfo_QuerySigningInfoResponse proto.InternalMessageInfo + +func (m *QuerySigningInfoResponse) GetFpSigningInfo() FinalityProviderSigningInfo { + if m != nil { + return m.FpSigningInfo + } + return FinalityProviderSigningInfo{} +} + +// 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 *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{19} +} +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 + } + return b[:n], 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) +} + +var xxx_messageInfo_QuerySigningInfosRequest proto.InternalMessageInfo + +func (m *QuerySigningInfosRequest) GetPagination() *query.PageRequest { + 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"` +} + +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{20} +} +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 + } +} +func (m *QuerySigningInfosResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_QuerySigningInfosResponse.Merge(m, src) +} +func (m *QuerySigningInfosResponse) XXX_Size() int { + return m.Size() +} +func (m *QuerySigningInfosResponse) XXX_DiscardUnknown() { + xxx_messageInfo_QuerySigningInfosResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_QuerySigningInfosResponse proto.InternalMessageInfo + +func (m *QuerySigningInfosResponse) GetFpSigningInfos() []FinalityProviderSigningInfo { + if m != nil { + return m.FpSigningInfos + } + return nil +} + +func (m *QuerySigningInfosResponse) GetPagination() *query.PageResponse { + if m != nil { + return m.Pagination + } + return nil +} + 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_babylonchain_babylon_types.SchnorrPubRand)(nil), "babylon.finality.v1.QueryListPublicRandomnessResponse.PubRandMapEntry") + 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") @@ -770,77 +1138,99 @@ func init() { 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 init() { proto.RegisterFile("babylon/finality/v1/query.proto", fileDescriptor_32bddab77af6fdae) } var fileDescriptor_32bddab77af6fdae = []byte{ - // 1028 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x56, 0xcf, 0x6f, 0x1b, 0x45, - 0x14, 0xce, 0x38, 0x8d, 0x9b, 0xbc, 0xc4, 0x90, 0x4e, 0x4d, 0x09, 0x2e, 0x75, 0x9c, 0x2d, 0x24, - 0x21, 0xa9, 0x76, 0x1b, 0xa7, 0x94, 0x16, 0x84, 0x4a, 0x2c, 0x12, 0x12, 0x68, 0x5d, 0xb3, 0x95, - 0x2a, 0xd1, 0x8b, 0x35, 0x6b, 0x4f, 0xec, 0x55, 0xec, 0x9d, 0xed, 0xee, 0xac, 0x15, 0xab, 0xaa, - 0x84, 0x38, 0xf4, 0x04, 0x12, 0x12, 0x17, 0x2e, 0x3d, 0xd0, 0x2b, 0xff, 0x48, 0x8f, 0x91, 0xb8, - 0xa0, 0x4a, 0x44, 0x28, 0xe1, 0xc6, 0x3f, 0x81, 0x76, 0x66, 0xd6, 0x8e, 0xc3, 0xfa, 0x47, 0xab, - 0xdc, 0xbc, 0x33, 0xef, 0xc7, 0xf7, 0xbe, 0xf7, 0xe6, 0x7b, 0x86, 0x79, 0x8b, 0x58, 0xed, 0x06, - 0x73, 0x8c, 0x5d, 0xdb, 0x21, 0x0d, 0x9b, 0xb7, 0x8d, 0xd6, 0x9a, 0xf1, 0x38, 0xa0, 0x5e, 0x5b, - 0x77, 0x3d, 0xc6, 0x19, 0xbe, 0xa8, 0x0c, 0xf4, 0xc8, 0x40, 0x6f, 0xad, 0x65, 0xd2, 0x35, 0x56, - 0x63, 0xe2, 0xde,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af, 0x0e, 0xe6, 0xa9, 0x47, 0xfc, 0x33, 0xd7, - 0x46, 0x33, 0x1e, 0xa9, 0xef, 0x4a, 0x6f, 0x9f, 0x23, 0x48, 0xf5, 0xa8, 0x1d, 0xd6, 0xfb, 0x27, - 0x89, 0xd3, 0xd2, 0x8c, 0x31, 0xb2, 0xbd, 0xc2, 0xb5, 0x2a, 0x70, 0x7d, 0x88, 0xaf, 0xc6, 0xe2, - 0x6a, 0x85, 0x3e, 0x5d, 0xba, 0x7e, 0x47, 0x30, 0x19, 0x3d, 0x63, 0xfc, 0x51, 0xff, 0x54, 0xa7, - 0x24, 0x34, 0xb3, 0x32, 0x8a, 0xa9, 0x02, 0xb4, 0x2d, 0x00, 0x15, 0xf0, 0x17, 0x6f, 0x3a, 0x73, - 0x91, 0xba, 0xe0, 0x5f, 0x11, 0xa4, 0x7a, 0x34, 0x6b, 0x10, 0x9b, 0x71, 0x2a, 0x3b, 0x88, 0xcd, - 0x58, 0x31, 0xd4, 0x16, 0x05, 0xf8, 0x1c, 0xce, 0xc6, 0x82, 0xef, 0xe8, 0x5e, 0xe1, 0xeb, 0x97, - 0x47, 0x59, 0x74, 0x70, 0x94, 0x45, 0x7f, 0x1f, 0x65, 0xd1, 0xcf, 0xc7, 0xd9, 0xb1, 0x83, 0xe3, - 0xec, 0xd8, 0x9f, 0xc7, 0xd9, 0xb1, 0x47, 0xd7, 0x87, 0x6d, 0xb0, 0xfd, 0x6e, 0x48, 0xb1, 0xcc, - 0xac, 0xa4, 0xf8, 0xb7, 0xbd, 0xfe, 0x5f, 0x00, 0x00, 0x00, 0xff, 0xff, 0xdc, 0x08, 0x51, 0x06, - 0x4b, 0x0c, 0x00, 0x00, + // 1318 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xbc, 0x58, 0xdf, 0x6f, 0xdb, 0x54, + 0x14, 0xee, 0xcd, 0xd6, 0x6c, 0x3b, 0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, 0x2d, 0x4c, 0xff, 0x67, 0xb3, 0xf8, 0x6f, 0x00, 0x00, 0x00, 0xff, 0xff, 0x1a, 0x6c, + 0x72, 0x7b, 0x91, 0x12, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -858,7 +1248,13 @@ 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 @@ -869,6 +1265,10 @@ type QueryClient interface { 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) } type queryClient struct { @@ -897,6 +1297,15 @@ func (c *queryClient) ListPublicRandomness(ctx context.Context, in *QueryListPub return out, nil } +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 (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...) @@ -942,12 +1351,36 @@ func (c *queryClient) ListEvidences(ctx context.Context, in *QueryListEvidencesR return out, 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 + } + return out, 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 +} + // 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 @@ -958,6 +1391,10 @@ type QueryServer interface { 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) } // UnimplementedQueryServer can be embedded to have forward compatible implementations. @@ -970,6 +1407,9 @@ func (*UnimplementedQueryServer) Params(ctx context.Context, req *QueryParamsReq 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") } @@ -985,7 +1425,13 @@ func (*UnimplementedQueryServer) Evidence(ctx context.Context, req *QueryEvidenc 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 RegisterQueryServer(s grpc1.Server, srv QueryServer) { s.RegisterService(&_Query_serviceDesc, srv) } @@ -1026,6 +1472,24 @@ func _Query_ListPublicRandomness_Handler(srv interface{}, ctx context.Context, d return interceptor(ctx, in, info, handler) } +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) +} + 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 { @@ -1116,6 +1580,42 @@ func _Query_ListEvidences_Handler(srv interface{}, ctx context.Context, dec func 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), @@ -1128,6 +1628,10 @@ var _Query_serviceDesc = grpc.ServiceDesc{ MethodName: "ListPublicRandomness", Handler: _Query_ListPublicRandomness_Handler, }, + { + MethodName: "ListPubRandCommit", + Handler: _Query_ListPubRandCommit_Handler, + }, { MethodName: "Block", Handler: _Query_Block_Handler, @@ -1148,6 +1652,14 @@ var _Query_serviceDesc = grpc.ServiceDesc{ 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", @@ -1310,6 +1822,142 @@ func (m *QueryListPublicRandomnessResponse) MarshalToSizedBuffer(dAtA []byte) (i 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 *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.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 { + { + 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 +} + func (m *QueryBlockRequest) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) @@ -1681,76 +2329,282 @@ func (m *QueryListEvidencesResponse) MarshalToSizedBuffer(dAtA []byte) (int, err 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 +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 } - var l int - _ = l - return n + return dAtA[:n], nil } -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 *QuerySigningInfoRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *QueryListPublicRandomnessRequest) Size() (n int) { - if m == nil { - return 0 - } +func (m *QuerySigningInfoRequest) 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.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 *QueryListPublicRandomnessResponse) Size() (n int) { - if m == nil { - return 0 +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 - 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)) + { + size, err := m.FpSigningInfo.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) } - if m.Pagination != nil { - l = m.Pagination.Size() - n += 1 + l + sovQuery(uint64(l)) + 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.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 + } + } + 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 *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)) + } + 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 } @@ -1903,6 +2757,62 @@ func (m *QueryListEvidencesResponse) Size() (n int) { 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 *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 *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.FpSigningInfos) > 0 { + for _, e := range m.FpSigningInfos { + 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 } @@ -2219,10 +3129,10 @@ func (m *QueryListPublicRandomnessResponse) Unmarshal(dAtA []byte) error { return io.ErrUnexpectedEOF } if m.PubRandMap == nil { - m.PubRandMap = make(map[uint64]*github_com_babylonchain_babylon_types.SchnorrPubRand) + m.PubRandMap = make(map[uint64]*github_com_babylonlabs_io_babylon_types.SchnorrPubRand) } var mapkey uint64 - var mapvalue1 github_com_babylonchain_babylon_types.SchnorrPubRand + var mapvalue1 github_com_babylonlabs_io_babylon_types.SchnorrPubRand var mapvalue = &mapvalue1 for iNdEx < postIndex { entryPreIndex := iNdEx @@ -2303,7 +3213,7 @@ func (m *QueryListPublicRandomnessResponse) Unmarshal(dAtA []byte) error { iNdEx += skippy } } - m.PubRandMap[mapkey] = ((*github_com_babylonchain_babylon_types.SchnorrPubRand)(mapvalue)) + m.PubRandMap[mapkey] = ((*github_com_babylonlabs_io_babylon_types.SchnorrPubRand)(mapvalue)) iNdEx = postIndex case 2: if wireType != 2 { @@ -2340,7 +3250,878 @@ func (m *QueryListPublicRandomnessResponse) Unmarshal(dAtA []byte) error { if err := m.Pagination.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } - 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 *PubRandCommitResponse) 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: PubRandCommitResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + 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 Commitment", 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 + } + m.Commitment = append(m.Commitment[:0], dAtA[iNdEx:postIndex]...) + if m.Commitment == nil { + m.Commitment = []byte{} + } + 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 *QueryListPubRandCommitRequest) 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: QueryListPubRandCommitRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryListPubRandCommitRequest: 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 *QueryListPubRandCommitResponse) 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: 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 + } + } + m.PubRandCommitMap[mapkey] = 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:]) + 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 *QueryBlockRequest) 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: QueryBlockRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + 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 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 *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 Block", 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.Block == nil { + m.Block = &IndexedBlock{} + } + if err := m.Block.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 *QueryListBlocksRequest) 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: QueryListBlocksRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryListBlocksRequest: 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) + } + 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 *QueryListBlocksResponse) 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: 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 + } + } + 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 { + 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 *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) + } + 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:]) @@ -2362,7 +4143,7 @@ func (m *QueryListPublicRandomnessResponse) Unmarshal(dAtA []byte) error { } return nil } -func (m *QueryBlockRequest) Unmarshal(dAtA []byte) error { +func (m *QueryVotesAtHeightResponse) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -2385,17 +4166,17 @@ 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: QueryVotesAtHeightResponse: 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: QueryVotesAtHeightResponse: 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 BtcPks", wireType) } - m.Height = 0 + var byteLen int for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowQuery @@ -2405,11 +4186,27 @@ func (m *QueryBlockRequest) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - m.Height |= uint64(b&0x7F) << shift + 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 + } + 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 default: iNdEx = preIndex skippy, err := skipQuery(dAtA[iNdEx:]) @@ -2431,7 +4228,7 @@ func (m *QueryBlockRequest) Unmarshal(dAtA []byte) error { } return nil } -func (m *QueryBlockResponse) Unmarshal(dAtA []byte) error { +func (m *QueryEvidenceRequest) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -2454,17 +4251,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: QueryEvidenceRequest: 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: QueryEvidenceRequest: 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 FpBtcPkHex", wireType) } - var msglen int + var stringLen uint64 for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowQuery @@ -2474,27 +4271,23 @@ func (m *QueryBlockResponse) 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.Block == nil { - m.Block = &IndexedBlock{} - } - if err := m.Block.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } + m.FpBtcPkHex = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex default: iNdEx = preIndex @@ -2517,7 +4310,7 @@ func (m *QueryBlockResponse) Unmarshal(dAtA []byte) error { } return nil } -func (m *QueryListBlocksRequest) Unmarshal(dAtA []byte) error { +func (m *QueryEvidenceResponse) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -2540,34 +4333,15 @@ 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: QueryEvidenceResponse: 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: QueryEvidenceResponse: 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 Evidence", wireType) } var msglen int for shift := uint(0); ; shift += 7 { @@ -2594,10 +4368,10 @@ func (m *QueryListBlocksRequest) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - if m.Pagination == nil { - m.Pagination = &query.PageRequest{} + if m.Evidence == nil { + m.Evidence = &Evidence{} } - if err := m.Pagination.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + if err := m.Evidence.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } iNdEx = postIndex @@ -2622,7 +4396,7 @@ func (m *QueryListBlocksRequest) Unmarshal(dAtA []byte) error { } return nil } -func (m *QueryListBlocksResponse) Unmarshal(dAtA []byte) error { +func (m *QueryListEvidencesRequest) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -2645,17 +4419,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: QueryListEvidencesRequest: 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: QueryListEvidencesRequest: 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) + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field StartHeight", wireType) } - var msglen int + m.StartHeight = 0 for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowQuery @@ -2665,26 +4439,11 @@ func (m *QueryListBlocksResponse) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - msglen |= int(b&0x7F) << shift + m.StartHeight |= uint64(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.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 { return fmt.Errorf("proto: wrong wireType = %d for field Pagination", wireType) @@ -2715,7 +4474,7 @@ func (m *QueryListBlocksResponse) Unmarshal(dAtA []byte) error { 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 @@ -2742,7 +4501,7 @@ func (m *QueryListBlocksResponse) Unmarshal(dAtA []byte) error { } return nil } -func (m *QueryVotesAtHeightRequest) Unmarshal(dAtA []byte) error { +func (m *QueryListEvidencesResponse) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -2765,17 +4524,17 @@ func (m *QueryVotesAtHeightRequest) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: QueryVotesAtHeightRequest: wiretype end group for non-group") + return fmt.Errorf("proto: QueryListEvidencesResponse: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: QueryVotesAtHeightRequest: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: QueryListEvidencesResponse: 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 Evidences", wireType) } - m.Height = 0 + var msglen int for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowQuery @@ -2785,66 +4544,31 @@ func (m *QueryVotesAtHeightRequest) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - m.Height |= uint64(b&0x7F) << shift + msglen |= 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 { + if msglen < 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 + 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.Evidences = append(m.Evidences, &Evidence{}) + if err := m.Evidences[len(m.Evidences)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err } - } - 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 2: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field BtcPks", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field Pagination", wireType) } - var byteLen int + var msglen int for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowQuery @@ -2854,24 +4578,25 @@ func (m *QueryVotesAtHeightResponse) 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 } - var v github_com_babylonchain_babylon_types.BIP340PubKey - m.BtcPks = append(m.BtcPks, v) - if err := m.BtcPks[len(m.BtcPks)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + if m.Pagination == nil { + m.Pagination = &query.PageResponse{} + } + if err := m.Pagination.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } iNdEx = postIndex @@ -2896,7 +4621,7 @@ func (m *QueryVotesAtHeightResponse) Unmarshal(dAtA []byte) error { } return nil } -func (m *QueryEvidenceRequest) Unmarshal(dAtA []byte) error { +func (m *QuerySigningInfoRequest) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -2919,10 +4644,10 @@ func (m *QueryEvidenceRequest) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: QueryEvidenceRequest: wiretype end group for non-group") + return fmt.Errorf("proto: QuerySigningInfoRequest: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: QueryEvidenceRequest: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: QuerySigningInfoRequest: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: @@ -2978,7 +4703,7 @@ func (m *QueryEvidenceRequest) Unmarshal(dAtA []byte) error { } return nil } -func (m *QueryEvidenceResponse) Unmarshal(dAtA []byte) error { +func (m *QuerySigningInfoResponse) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -3001,15 +4726,15 @@ func (m *QueryEvidenceResponse) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: QueryEvidenceResponse: wiretype end group for non-group") + return fmt.Errorf("proto: QuerySigningInfoResponse: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: QueryEvidenceResponse: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: QuerySigningInfoResponse: 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 FpSigningInfo", wireType) } var msglen int for shift := uint(0); ; shift += 7 { @@ -3036,10 +4761,7 @@ func (m *QueryEvidenceResponse) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - if m.Evidence == nil { - m.Evidence = &Evidence{} - } - if err := m.Evidence.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + if err := m.FpSigningInfo.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } iNdEx = postIndex @@ -3064,7 +4786,7 @@ func (m *QueryEvidenceResponse) Unmarshal(dAtA []byte) error { } return nil } -func (m *QueryListEvidencesRequest) Unmarshal(dAtA []byte) error { +func (m *QuerySigningInfosRequest) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -3087,32 +4809,13 @@ func (m *QueryListEvidencesRequest) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: QueryListEvidencesRequest: wiretype end group for non-group") + return fmt.Errorf("proto: QuerySigningInfosRequest: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: QueryListEvidencesRequest: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: QuerySigningInfosRequest: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: - 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 |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - case 2: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field Pagination", wireType) } @@ -3169,7 +4872,7 @@ func (m *QueryListEvidencesRequest) Unmarshal(dAtA []byte) error { } return nil } -func (m *QueryListEvidencesResponse) Unmarshal(dAtA []byte) error { +func (m *QuerySigningInfosResponse) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -3192,15 +4895,15 @@ func (m *QueryListEvidencesResponse) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: QueryListEvidencesResponse: wiretype end group for non-group") + return fmt.Errorf("proto: QuerySigningInfosResponse: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: QueryListEvidencesResponse: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: QuerySigningInfosResponse: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Evidences", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field FpSigningInfos", wireType) } var msglen int for shift := uint(0); ; shift += 7 { @@ -3227,8 +4930,8 @@ func (m *QueryListEvidencesResponse) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.Evidences = append(m.Evidences, &Evidence{}) - if err := m.Evidences[len(m.Evidences)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + m.FpSigningInfos = append(m.FpSigningInfos, FinalityProviderSigningInfo{}) + if err := m.FpSigningInfos[len(m.FpSigningInfos)-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 1d001a7a0..6211809d2 100644 --- a/x/finality/types/query.pb.gw.go +++ b/x/finality/types/query.pb.gw.go @@ -123,6 +123,78 @@ func local_request_Query_ListPublicRandomness_0(ctx context.Context, marshaler r } +var ( + filter_Query_ListPubRandCommit_0 = &utilities.DoubleArray{Encoding: map[string]int{"fp_btc_pk_hex": 0}, Base: []int{1, 1, 0}, Check: []int{0, 1, 2}} +) + +func request_Query_ListPubRandCommit_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryListPubRandCommitRequest + 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) + } + + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_ListPubRandCommit_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + msg, err := client.ListPubRandCommit(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_Query_ListPubRandCommit_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryListPubRandCommitRequest + 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) + } + + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_ListPubRandCommit_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + msg, err := server.ListPubRandCommit(ctx, &protoReq) + return msg, metadata, err + +} + func request_Query_Block_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { var protoReq QueryBlockRequest var metadata runtime.ServerMetadata @@ -357,6 +429,96 @@ func local_request_Query_ListEvidences_0(ctx context.Context, marshaler runtime. } +func request_Query_SigningInfo_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QuerySigningInfoRequest + 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.SigningInfo(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_Query_SigningInfo_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QuerySigningInfoRequest + 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.SigningInfo(ctx, &protoReq) + return msg, metadata, err + +} + +var ( + filter_Query_SigningInfos_0 = &utilities.DoubleArray{Encoding: map[string]int{}, Base: []int(nil), Check: []int(nil)} +) + +func request_Query_SigningInfos_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QuerySigningInfosRequest + 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_SigningInfos_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + msg, err := client.SigningInfos(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_Query_SigningInfos_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QuerySigningInfosRequest + 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_SigningInfos_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + msg, err := server.SigningInfos(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. @@ -409,6 +571,29 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv }) + mux.Handle("GET", pattern_Query_ListPubRandCommit_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_ListPubRandCommit_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_ListPubRandCommit_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + mux.Handle("GET", pattern_Query_Block_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() @@ -524,6 +709,52 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv }) + mux.Handle("GET", pattern_Query_SigningInfo_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_SigningInfo_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_SigningInfo_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("GET", pattern_Query_SigningInfos_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_SigningInfos_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_SigningInfos_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + return nil } @@ -605,6 +836,26 @@ func RegisterQueryHandlerClient(ctx context.Context, mux *runtime.ServeMux, clie }) + mux.Handle("GET", pattern_Query_ListPubRandCommit_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_ListPubRandCommit_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_ListPubRandCommit_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + mux.Handle("GET", pattern_Query_Block_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() @@ -705,6 +956,46 @@ func RegisterQueryHandlerClient(ctx context.Context, mux *runtime.ServeMux, clie }) + mux.Handle("GET", pattern_Query_SigningInfo_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_SigningInfo_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_SigningInfo_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("GET", pattern_Query_SigningInfos_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_SigningInfos_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_SigningInfos_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + return nil } @@ -713,6 +1004,8 @@ var ( 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))) + pattern_Query_Block_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", "blocks", "height"}, "", runtime.AssumeColonVerbOpt(false))) pattern_Query_ListBlocks_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"babylon", "finality", "v1", "blocks"}, "", runtime.AssumeColonVerbOpt(false))) @@ -722,6 +1015,10 @@ var ( pattern_Query_Evidence_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", "evidence"}, "", runtime.AssumeColonVerbOpt(false))) pattern_Query_ListEvidences_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"babylon", "finality", "v1", "evidences"}, "", runtime.AssumeColonVerbOpt(false))) + + pattern_Query_SigningInfo_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", "signing_infos", "fp_btc_pk_hex"}, "", runtime.AssumeColonVerbOpt(false))) + + pattern_Query_SigningInfos_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"babylon", "finality", "v1", "signing_infos"}, "", runtime.AssumeColonVerbOpt(false))) ) var ( @@ -729,6 +1026,8 @@ var ( forward_Query_ListPublicRandomness_0 = runtime.ForwardResponseMessage + forward_Query_ListPubRandCommit_0 = runtime.ForwardResponseMessage + forward_Query_Block_0 = runtime.ForwardResponseMessage forward_Query_ListBlocks_0 = runtime.ForwardResponseMessage @@ -738,4 +1037,8 @@ var ( forward_Query_Evidence_0 = runtime.ForwardResponseMessage forward_Query_ListEvidences_0 = runtime.ForwardResponseMessage + + forward_Query_SigningInfo_0 = runtime.ForwardResponseMessage + + forward_Query_SigningInfos_0 = runtime.ForwardResponseMessage ) diff --git a/x/finality/types/signing_info.go b/x/finality/types/signing_info.go new file mode 100644 index 000000000..72cbe4cd1 --- /dev/null +++ b/x/finality/types/signing_info.go @@ -0,0 +1,28 @@ +package types + +import ( + bbntypes "github.com/babylonlabs-io/babylon/types" +) + +// NewFinalityProviderSigningInfo creates a new FinalityProviderSigningInfo instance +func NewFinalityProviderSigningInfo( + fpPk *bbntypes.BIP340PubKey, startHeight, missedBlocksCounter int64, +) FinalityProviderSigningInfo { + return FinalityProviderSigningInfo{ + FpBtcPk: fpPk, + StartHeight: startHeight, + MissedBlocksCounter: missedBlocksCounter, + } +} + +func (si *FinalityProviderSigningInfo) IncrementMissedBlocksCounter() { + si.MissedBlocksCounter++ +} + +func (si *FinalityProviderSigningInfo) DecrementMissedBlocksCounter() { + si.MissedBlocksCounter-- +} + +func (si *FinalityProviderSigningInfo) ResetMissedBlocksCounter() { + si.MissedBlocksCounter = 0 +} diff --git a/x/finality/types/tx.pb.go b/x/finality/types/tx.pb.go index 0579dbfd0..a4768d48e 100644 --- a/x/finality/types/tx.pb.go +++ b/x/finality/types/tx.pb.go @@ -6,7 +6,8 @@ package types import ( context "context" fmt "fmt" - github_com_babylonchain_babylon_types "github.com/babylonchain/babylon/types" + github_com_babylonlabs_io_babylon_types "github.com/babylonlabs-io/babylon/types" + crypto "github.com/cometbft/cometbft/proto/tendermint/crypto" _ "github.com/cosmos/cosmos-proto" _ "github.com/cosmos/cosmos-sdk/types/msgservice" _ "github.com/cosmos/gogoproto/gogoproto" @@ -31,34 +32,38 @@ var _ = math.Inf // proto package needs to be updated. const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package -// MsgAddFinalitySig defines a message for adding a finality vote -type MsgAddFinalitySig struct { +// MsgCommitPubRandList defines a message for committing a list of public randomness for EOTS +type MsgCommitPubRandList struct { Signer string `protobuf:"bytes,1,opt,name=signer,proto3" json:"signer,omitempty"` - // fp_btc_pk is the BTC PK of the finality provider that casts this vote - FpBtcPk *github_com_babylonchain_babylon_types.BIP340PubKey `protobuf:"bytes,2,opt,name=fp_btc_pk,json=fpBtcPk,proto3,customtype=github.com/babylonchain/babylon/types.BIP340PubKey" json:"fp_btc_pk,omitempty"` - // block_height is the height of the voted block - BlockHeight uint64 `protobuf:"varint,3,opt,name=block_height,json=blockHeight,proto3" json:"block_height,omitempty"` - // block_app_hash is the AppHash of the voted block - BlockAppHash []byte `protobuf:"bytes,4,opt,name=block_app_hash,json=blockAppHash,proto3" json:"block_app_hash,omitempty"` - // finality_sig is the finality signature to this 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 - FinalitySig *github_com_babylonchain_babylon_types.SchnorrEOTSSig `protobuf:"bytes,5,opt,name=finality_sig,json=finalitySig,proto3,customtype=github.com/babylonchain/babylon/types.SchnorrEOTSSig" json:"finality_sig,omitempty"` + // fp_btc_pk is the BTC PK of the finality provider that commits the public randomness + 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"` + // start_height is the start block height of the list of public randomness + StartHeight uint64 `protobuf:"varint,3,opt,name=start_height,json=startHeight,proto3" json:"start_height,omitempty"` + // num_pub_rand is the number of public randomness committed + NumPubRand uint64 `protobuf:"varint,4,opt,name=num_pub_rand,json=numPubRand,proto3" json:"num_pub_rand,omitempty"` + // commitment is the commitment of these public randomness + // currently it's the root of the Merkle tree that includes these public randomness + Commitment []byte `protobuf:"bytes,5,opt,name=commitment,proto3" json:"commitment,omitempty"` + // sig is the signature on (start_height || num_pub_rand || commitment) signed by + // SK corresponding to fp_btc_pk. This prevents others to commit public + // randomness on behalf of fp_btc_pk + // TODO: another option is to restrict signer to correspond to fp_btc_pk. This restricts + // the tx submitter to be the holder of fp_btc_pk. Decide this later + Sig *github_com_babylonlabs_io_babylon_types.BIP340Signature `protobuf:"bytes,6,opt,name=sig,proto3,customtype=github.com/babylonlabs-io/babylon/types.BIP340Signature" json:"sig,omitempty"` } -func (m *MsgAddFinalitySig) Reset() { *m = MsgAddFinalitySig{} } -func (m *MsgAddFinalitySig) String() string { return proto.CompactTextString(m) } -func (*MsgAddFinalitySig) ProtoMessage() {} -func (*MsgAddFinalitySig) Descriptor() ([]byte, []int) { +func (m *MsgCommitPubRandList) Reset() { *m = MsgCommitPubRandList{} } +func (m *MsgCommitPubRandList) String() string { return proto.CompactTextString(m) } +func (*MsgCommitPubRandList) ProtoMessage() {} +func (*MsgCommitPubRandList) Descriptor() ([]byte, []int) { return fileDescriptor_2dd6da066b6baf1d, []int{0} } -func (m *MsgAddFinalitySig) XXX_Unmarshal(b []byte) error { +func (m *MsgCommitPubRandList) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } -func (m *MsgAddFinalitySig) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { +func (m *MsgCommitPubRandList) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { - return xxx_messageInfo_MsgAddFinalitySig.Marshal(b, m, deterministic) + return xxx_messageInfo_MsgCommitPubRandList.Marshal(b, m, deterministic) } else { b = b[:cap(b)] n, err := m.MarshalToSizedBuffer(b) @@ -68,55 +73,62 @@ func (m *MsgAddFinalitySig) XXX_Marshal(b []byte, deterministic bool) ([]byte, e return b[:n], nil } } -func (m *MsgAddFinalitySig) XXX_Merge(src proto.Message) { - xxx_messageInfo_MsgAddFinalitySig.Merge(m, src) +func (m *MsgCommitPubRandList) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgCommitPubRandList.Merge(m, src) } -func (m *MsgAddFinalitySig) XXX_Size() int { +func (m *MsgCommitPubRandList) XXX_Size() int { return m.Size() } -func (m *MsgAddFinalitySig) XXX_DiscardUnknown() { - xxx_messageInfo_MsgAddFinalitySig.DiscardUnknown(m) +func (m *MsgCommitPubRandList) XXX_DiscardUnknown() { + xxx_messageInfo_MsgCommitPubRandList.DiscardUnknown(m) } -var xxx_messageInfo_MsgAddFinalitySig proto.InternalMessageInfo +var xxx_messageInfo_MsgCommitPubRandList proto.InternalMessageInfo -func (m *MsgAddFinalitySig) GetSigner() string { +func (m *MsgCommitPubRandList) GetSigner() string { if m != nil { return m.Signer } return "" } -func (m *MsgAddFinalitySig) GetBlockHeight() uint64 { +func (m *MsgCommitPubRandList) GetStartHeight() uint64 { if m != nil { - return m.BlockHeight + return m.StartHeight } return 0 } -func (m *MsgAddFinalitySig) GetBlockAppHash() []byte { +func (m *MsgCommitPubRandList) GetNumPubRand() uint64 { if m != nil { - return m.BlockAppHash + return m.NumPubRand + } + return 0 +} + +func (m *MsgCommitPubRandList) GetCommitment() []byte { + if m != nil { + return m.Commitment } return nil } -// MsgAddFinalitySigResponse is the response to the MsgAddFinalitySig message -type MsgAddFinalitySigResponse struct { +// MsgCommitPubRandListResponse is the response to the MsgCommitPubRandList message +type MsgCommitPubRandListResponse struct { } -func (m *MsgAddFinalitySigResponse) Reset() { *m = MsgAddFinalitySigResponse{} } -func (m *MsgAddFinalitySigResponse) String() string { return proto.CompactTextString(m) } -func (*MsgAddFinalitySigResponse) ProtoMessage() {} -func (*MsgAddFinalitySigResponse) Descriptor() ([]byte, []int) { +func (m *MsgCommitPubRandListResponse) Reset() { *m = MsgCommitPubRandListResponse{} } +func (m *MsgCommitPubRandListResponse) String() string { return proto.CompactTextString(m) } +func (*MsgCommitPubRandListResponse) ProtoMessage() {} +func (*MsgCommitPubRandListResponse) Descriptor() ([]byte, []int) { return fileDescriptor_2dd6da066b6baf1d, []int{1} } -func (m *MsgAddFinalitySigResponse) XXX_Unmarshal(b []byte) error { +func (m *MsgCommitPubRandListResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } -func (m *MsgAddFinalitySigResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { +func (m *MsgCommitPubRandListResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { - return xxx_messageInfo_MsgAddFinalitySigResponse.Marshal(b, m, deterministic) + return xxx_messageInfo_MsgCommitPubRandListResponse.Marshal(b, m, deterministic) } else { b = b[:cap(b)] n, err := m.MarshalToSizedBuffer(b) @@ -126,47 +138,50 @@ func (m *MsgAddFinalitySigResponse) XXX_Marshal(b []byte, deterministic bool) ([ return b[:n], nil } } -func (m *MsgAddFinalitySigResponse) XXX_Merge(src proto.Message) { - xxx_messageInfo_MsgAddFinalitySigResponse.Merge(m, src) +func (m *MsgCommitPubRandListResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgCommitPubRandListResponse.Merge(m, src) } -func (m *MsgAddFinalitySigResponse) XXX_Size() int { +func (m *MsgCommitPubRandListResponse) XXX_Size() int { return m.Size() } -func (m *MsgAddFinalitySigResponse) XXX_DiscardUnknown() { - xxx_messageInfo_MsgAddFinalitySigResponse.DiscardUnknown(m) +func (m *MsgCommitPubRandListResponse) XXX_DiscardUnknown() { + xxx_messageInfo_MsgCommitPubRandListResponse.DiscardUnknown(m) } -var xxx_messageInfo_MsgAddFinalitySigResponse proto.InternalMessageInfo +var xxx_messageInfo_MsgCommitPubRandListResponse proto.InternalMessageInfo -// MsgCommitPubRandList defines a message for committing a list of public randomness for EOTS -type MsgCommitPubRandList struct { +// MsgAddFinalitySig defines a message for adding a finality vote +type MsgAddFinalitySig struct { Signer string `protobuf:"bytes,1,opt,name=signer,proto3" json:"signer,omitempty"` - // fp_btc_pk is the BTC PK of the finality provider that commits the public randomness - FpBtcPk *github_com_babylonchain_babylon_types.BIP340PubKey `protobuf:"bytes,2,opt,name=fp_btc_pk,json=fpBtcPk,proto3,customtype=github.com/babylonchain/babylon/types.BIP340PubKey" json:"fp_btc_pk,omitempty"` - // start_height is the start block height of the list of public randomness - StartHeight uint64 `protobuf:"varint,3,opt,name=start_height,json=startHeight,proto3" json:"start_height,omitempty"` - // pub_rand_list is the list of public randomness - PubRandList []github_com_babylonchain_babylon_types.SchnorrPubRand `protobuf:"bytes,4,rep,name=pub_rand_list,json=pubRandList,proto3,customtype=github.com/babylonchain/babylon/types.SchnorrPubRand" json:"pub_rand_list,omitempty"` - // sig is the signature on (start_height || pub_rand_list) signed by - // SK corresponding to fp_btc_pk. This prevents others to commit public - // randomness on behalf of fp_btc_pk - // TODO: another option is to restrict signer to correspond to fp_btc_pk. This restricts - // the tx submitter to be the holder of fp_btc_pk. Decide this later - Sig *github_com_babylonchain_babylon_types.BIP340Signature `protobuf:"bytes,5,opt,name=sig,proto3,customtype=github.com/babylonchain/babylon/types.BIP340Signature" json:"sig,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"` + // block_height is the height of the voted block + BlockHeight uint64 `protobuf:"varint,3,opt,name=block_height,json=blockHeight,proto3" json:"block_height,omitempty"` + // pub_rand is the public randomness committed at this height + PubRand *github_com_babylonlabs_io_babylon_types.SchnorrPubRand `protobuf:"bytes,4,opt,name=pub_rand,json=pubRand,proto3,customtype=github.com/babylonlabs-io/babylon/types.SchnorrPubRand" json:"pub_rand,omitempty"` + // proof is the proof that the given public randomness is committed under the commitment + Proof *crypto.Proof `protobuf:"bytes,5,opt,name=proof,proto3" json:"proof,omitempty"` + // block_app_hash is the AppHash of the voted block + BlockAppHash []byte `protobuf:"bytes,6,opt,name=block_app_hash,json=blockAppHash,proto3" json:"block_app_hash,omitempty"` + // finality_sig is the finality signature to this 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 + FinalitySig *github_com_babylonlabs_io_babylon_types.SchnorrEOTSSig `protobuf:"bytes,7,opt,name=finality_sig,json=finalitySig,proto3,customtype=github.com/babylonlabs-io/babylon/types.SchnorrEOTSSig" json:"finality_sig,omitempty"` } -func (m *MsgCommitPubRandList) Reset() { *m = MsgCommitPubRandList{} } -func (m *MsgCommitPubRandList) String() string { return proto.CompactTextString(m) } -func (*MsgCommitPubRandList) ProtoMessage() {} -func (*MsgCommitPubRandList) Descriptor() ([]byte, []int) { +func (m *MsgAddFinalitySig) Reset() { *m = MsgAddFinalitySig{} } +func (m *MsgAddFinalitySig) String() string { return proto.CompactTextString(m) } +func (*MsgAddFinalitySig) ProtoMessage() {} +func (*MsgAddFinalitySig) Descriptor() ([]byte, []int) { return fileDescriptor_2dd6da066b6baf1d, []int{2} } -func (m *MsgCommitPubRandList) XXX_Unmarshal(b []byte) error { +func (m *MsgAddFinalitySig) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } -func (m *MsgCommitPubRandList) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { +func (m *MsgAddFinalitySig) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { - return xxx_messageInfo_MsgCommitPubRandList.Marshal(b, m, deterministic) + return xxx_messageInfo_MsgAddFinalitySig.Marshal(b, m, deterministic) } else { b = b[:cap(b)] n, err := m.MarshalToSizedBuffer(b) @@ -176,48 +191,62 @@ func (m *MsgCommitPubRandList) XXX_Marshal(b []byte, deterministic bool) ([]byte return b[:n], nil } } -func (m *MsgCommitPubRandList) XXX_Merge(src proto.Message) { - xxx_messageInfo_MsgCommitPubRandList.Merge(m, src) +func (m *MsgAddFinalitySig) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgAddFinalitySig.Merge(m, src) } -func (m *MsgCommitPubRandList) XXX_Size() int { +func (m *MsgAddFinalitySig) XXX_Size() int { return m.Size() } -func (m *MsgCommitPubRandList) XXX_DiscardUnknown() { - xxx_messageInfo_MsgCommitPubRandList.DiscardUnknown(m) +func (m *MsgAddFinalitySig) XXX_DiscardUnknown() { + xxx_messageInfo_MsgAddFinalitySig.DiscardUnknown(m) } -var xxx_messageInfo_MsgCommitPubRandList proto.InternalMessageInfo +var xxx_messageInfo_MsgAddFinalitySig proto.InternalMessageInfo -func (m *MsgCommitPubRandList) GetSigner() string { +func (m *MsgAddFinalitySig) GetSigner() string { if m != nil { return m.Signer } return "" } -func (m *MsgCommitPubRandList) GetStartHeight() uint64 { +func (m *MsgAddFinalitySig) GetBlockHeight() uint64 { if m != nil { - return m.StartHeight + return m.BlockHeight } return 0 } -// MsgCommitPubRandListResponse is the response to the MsgCommitPubRandList message -type MsgCommitPubRandListResponse struct { +func (m *MsgAddFinalitySig) GetProof() *crypto.Proof { + if m != nil { + return m.Proof + } + return nil } -func (m *MsgCommitPubRandListResponse) Reset() { *m = MsgCommitPubRandListResponse{} } -func (m *MsgCommitPubRandListResponse) String() string { return proto.CompactTextString(m) } -func (*MsgCommitPubRandListResponse) ProtoMessage() {} -func (*MsgCommitPubRandListResponse) Descriptor() ([]byte, []int) { +func (m *MsgAddFinalitySig) GetBlockAppHash() []byte { + if m != nil { + return m.BlockAppHash + } + return nil +} + +// MsgAddFinalitySigResponse is the response to the MsgAddFinalitySig message +type MsgAddFinalitySigResponse struct { +} + +func (m *MsgAddFinalitySigResponse) Reset() { *m = MsgAddFinalitySigResponse{} } +func (m *MsgAddFinalitySigResponse) String() string { return proto.CompactTextString(m) } +func (*MsgAddFinalitySigResponse) ProtoMessage() {} +func (*MsgAddFinalitySigResponse) Descriptor() ([]byte, []int) { return fileDescriptor_2dd6da066b6baf1d, []int{3} } -func (m *MsgCommitPubRandListResponse) XXX_Unmarshal(b []byte) error { +func (m *MsgAddFinalitySigResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } -func (m *MsgCommitPubRandListResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { +func (m *MsgAddFinalitySigResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { - return xxx_messageInfo_MsgCommitPubRandListResponse.Marshal(b, m, deterministic) + return xxx_messageInfo_MsgAddFinalitySigResponse.Marshal(b, m, deterministic) } else { b = b[:cap(b)] n, err := m.MarshalToSizedBuffer(b) @@ -227,17 +256,17 @@ func (m *MsgCommitPubRandListResponse) XXX_Marshal(b []byte, deterministic bool) return b[:n], nil } } -func (m *MsgCommitPubRandListResponse) XXX_Merge(src proto.Message) { - xxx_messageInfo_MsgCommitPubRandListResponse.Merge(m, src) +func (m *MsgAddFinalitySigResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgAddFinalitySigResponse.Merge(m, src) } -func (m *MsgCommitPubRandListResponse) XXX_Size() int { +func (m *MsgAddFinalitySigResponse) XXX_Size() int { return m.Size() } -func (m *MsgCommitPubRandListResponse) XXX_DiscardUnknown() { - xxx_messageInfo_MsgCommitPubRandListResponse.DiscardUnknown(m) +func (m *MsgAddFinalitySigResponse) XXX_DiscardUnknown() { + xxx_messageInfo_MsgAddFinalitySigResponse.DiscardUnknown(m) } -var xxx_messageInfo_MsgCommitPubRandListResponse proto.InternalMessageInfo +var xxx_messageInfo_MsgAddFinalitySigResponse proto.InternalMessageInfo // MsgUpdateParams defines a message for updating finality module parameters. type MsgUpdateParams struct { @@ -337,10 +366,10 @@ func (m *MsgUpdateParamsResponse) XXX_DiscardUnknown() { var xxx_messageInfo_MsgUpdateParamsResponse proto.InternalMessageInfo func init() { - proto.RegisterType((*MsgAddFinalitySig)(nil), "babylon.finality.v1.MsgAddFinalitySig") - proto.RegisterType((*MsgAddFinalitySigResponse)(nil), "babylon.finality.v1.MsgAddFinalitySigResponse") proto.RegisterType((*MsgCommitPubRandList)(nil), "babylon.finality.v1.MsgCommitPubRandList") proto.RegisterType((*MsgCommitPubRandListResponse)(nil), "babylon.finality.v1.MsgCommitPubRandListResponse") + proto.RegisterType((*MsgAddFinalitySig)(nil), "babylon.finality.v1.MsgAddFinalitySig") + proto.RegisterType((*MsgAddFinalitySigResponse)(nil), "babylon.finality.v1.MsgAddFinalitySigResponse") proto.RegisterType((*MsgUpdateParams)(nil), "babylon.finality.v1.MsgUpdateParams") proto.RegisterType((*MsgUpdateParamsResponse)(nil), "babylon.finality.v1.MsgUpdateParamsResponse") } @@ -348,48 +377,52 @@ func init() { func init() { proto.RegisterFile("babylon/finality/v1/tx.proto", fileDescriptor_2dd6da066b6baf1d) } var fileDescriptor_2dd6da066b6baf1d = []byte{ - // 644 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xbc, 0x54, 0xcd, 0x6e, 0xd3, 0x4c, - 0x14, 0x8d, 0x93, 0xb4, 0x9f, 0x3a, 0xc9, 0x57, 0x54, 0x53, 0x51, 0x37, 0xad, 0x9c, 0x10, 0x55, - 0xa8, 0x54, 0x60, 0xf7, 0x8f, 0x8a, 0x76, 0xd7, 0x20, 0x50, 0xa1, 0x44, 0x44, 0x0e, 0x6c, 0x00, - 0xc9, 0x1a, 0xff, 0x64, 0x3c, 0x6a, 0xec, 0x19, 0x3c, 0x93, 0xaa, 0xd9, 0x21, 0x9e, 0x80, 0x05, - 0x0f, 0x52, 0x21, 0x1e, 0xa2, 0x1b, 0xa4, 0x8a, 0x15, 0xaa, 0x44, 0x84, 0xda, 0x45, 0x5f, 0x03, - 0xc5, 0x1e, 0x37, 0x6d, 0x92, 0x8a, 0xc0, 0x82, 0x9d, 0xef, 0x9c, 0x33, 0xf7, 0xdc, 0x7b, 0xe6, - 0x5e, 0x83, 0x79, 0x0b, 0x5a, 0xed, 0x26, 0x09, 0xf4, 0x06, 0x0e, 0x60, 0x13, 0xf3, 0xb6, 0xbe, - 0xbf, 0xa2, 0xf3, 0x03, 0x8d, 0x86, 0x84, 0x13, 0xf9, 0xa6, 0x40, 0xb5, 0x04, 0xd5, 0xf6, 0x57, - 0x0a, 0xd3, 0x88, 0x20, 0x12, 0xe1, 0x7a, 0xf7, 0x2b, 0xa6, 0x16, 0x66, 0x6d, 0xc2, 0x7c, 0xc2, - 0xcc, 0x18, 0x88, 0x03, 0x01, 0xcd, 0xc4, 0x91, 0xee, 0x33, 0xd4, 0xcd, 0xee, 0x33, 0x24, 0x80, - 0xd2, 0x30, 0x71, 0x0a, 0x43, 0xe8, 0x8b, 0xab, 0xe5, 0xcf, 0x69, 0x30, 0x55, 0x65, 0x68, 0xdb, - 0x71, 0x9e, 0x08, 0x4a, 0x1d, 0x23, 0xf9, 0x16, 0x18, 0x67, 0x18, 0x05, 0x6e, 0xa8, 0x48, 0x25, - 0x69, 0x71, 0xc2, 0x10, 0x91, 0x6c, 0x80, 0x89, 0x06, 0x35, 0x2d, 0x6e, 0x9b, 0x74, 0x4f, 0x49, - 0x97, 0xa4, 0xc5, 0x7c, 0x65, 0xe3, 0xa4, 0x53, 0x5c, 0x45, 0x98, 0x7b, 0x2d, 0x4b, 0xb3, 0x89, - 0xaf, 0x0b, 0x45, 0xdb, 0x83, 0x38, 0x48, 0x02, 0x9d, 0xb7, 0xa9, 0xcb, 0xb4, 0xca, 0xd3, 0xda, - 0xda, 0xfa, 0x72, 0xad, 0x65, 0xed, 0xba, 0x6d, 0xe3, 0xbf, 0x06, 0xad, 0x70, 0xbb, 0xb6, 0x27, - 0xdf, 0x06, 0x79, 0xab, 0x49, 0xec, 0x3d, 0xd3, 0x73, 0x31, 0xf2, 0xb8, 0x92, 0x29, 0x49, 0x8b, - 0x59, 0x23, 0x17, 0x9d, 0xed, 0x44, 0x47, 0xf2, 0x02, 0x98, 0x8c, 0x29, 0x90, 0x52, 0xd3, 0x83, - 0xcc, 0x53, 0xb2, 0x5d, 0x6d, 0x23, 0xbe, 0xb8, 0x4d, 0xe9, 0x0e, 0x64, 0x9e, 0xfc, 0x06, 0xe4, - 0x93, 0x36, 0x4d, 0x86, 0x91, 0x32, 0x16, 0xd5, 0xf7, 0xf0, 0xa4, 0x53, 0x5c, 0x1f, 0xad, 0xbe, - 0xba, 0xed, 0x05, 0x24, 0x0c, 0x1f, 0xbf, 0x78, 0x59, 0xaf, 0x63, 0x64, 0xe4, 0x1a, 0x3d, 0x47, - 0xb6, 0x72, 0x1f, 0xce, 0x0f, 0x97, 0x84, 0x0d, 0xe5, 0x39, 0x30, 0x3b, 0xe0, 0x99, 0xe1, 0x32, - 0x4a, 0x02, 0xe6, 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xed, 0xe1, 0x9d, 0xa1, 0x7a, 0x03, 0xb3, - 0x57, 0xd0, 0x46, 0xe3, 0x25, 0x8a, 0xf2, 0x3b, 0x30, 0x35, 0x38, 0x9f, 0x77, 0xaf, 0x4b, 0x32, - 0x40, 0x2d, 0xac, 0x8c, 0x4c, 0xbd, 0x90, 0xb4, 0x40, 0xfe, 0xca, 0x93, 0x2c, 0x5c, 0x97, 0xe2, - 0x32, 0xab, 0x70, 0x6f, 0x14, 0x56, 0xa2, 0x51, 0x18, 0x7b, 0x7f, 0x7e, 0xb8, 0x24, 0x55, 0x9e, - 0x1d, 0x9d, 0xaa, 0xd2, 0xf1, 0xa9, 0x2a, 0xfd, 0x3c, 0x55, 0xa5, 0x8f, 0x67, 0x6a, 0xea, 0xf8, - 0x4c, 0x4d, 0x7d, 0x3f, 0x53, 0x53, 0xaf, 0x97, 0x7f, 0x37, 0x84, 0x07, 0xbd, 0x3f, 0x65, 0x34, - 0x8f, 0xd6, 0x78, 0xf4, 0x9b, 0x5c, 0xfb, 0x15, 0x00, 0x00, 0xff, 0xff, 0x01, 0xd6, 0x89, 0xb4, - 0xc7, 0x05, 0x00, 0x00, + // 714 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xbc, 0x54, 0x4f, 0x4f, 0x13, 0x4f, + 0x18, 0xee, 0x52, 0x28, 0x3f, 0xa6, 0x0d, 0xbf, 0xb0, 0x12, 0x59, 0x0a, 0x6e, 0x6b, 0x43, 0x0c, + 0x12, 0xd9, 0x95, 0x42, 0x50, 0xf1, 0x44, 0x8d, 0x06, 0x23, 0x8d, 0xcd, 0x16, 0x2e, 0x26, 0x66, + 0xb3, 0xff, 0x3a, 0x3b, 0xa1, 0xbb, 0x33, 0xce, 0xcc, 0x12, 0x7a, 0x33, 0x7e, 0x02, 0x0f, 0x7e, + 0x10, 0x0e, 0x5e, 0x3d, 0x9a, 0x70, 0x31, 0x21, 0x9e, 0x0c, 0x87, 0xc6, 0xc0, 0x81, 0xaf, 0x61, + 0xba, 0x3b, 0xa5, 0x14, 0x4a, 0xac, 0x1e, 0xbc, 0xed, 0xbc, 0xef, 0xf3, 0xce, 0xf3, 0xec, 0xfb, + 0xbc, 0xef, 0x80, 0x79, 0xdb, 0xb2, 0x5b, 0x4d, 0x1c, 0xea, 0x0d, 0x14, 0x5a, 0x4d, 0xc4, 0x5b, + 0xfa, 0xfe, 0x8a, 0xce, 0x0f, 0x34, 0x42, 0x31, 0xc7, 0xf2, 0x2d, 0x91, 0xd5, 0xba, 0x59, 0x6d, + 0x7f, 0x25, 0x3f, 0x0d, 0x31, 0xc4, 0x71, 0x5e, 0xef, 0x7c, 0x25, 0xd0, 0xfc, 0x1d, 0xee, 0x85, + 0xae, 0x47, 0x03, 0x14, 0x72, 0xdd, 0xa1, 0x2d, 0xc2, 0xb1, 0x4e, 0x28, 0xc6, 0x0d, 0x91, 0x9e, + 0x75, 0x30, 0x0b, 0x30, 0x33, 0x93, 0xba, 0xe4, 0x20, 0x52, 0x33, 0xc9, 0x49, 0x0f, 0x18, 0xec, + 0x90, 0x07, 0x0c, 0x8a, 0x44, 0x71, 0x90, 0x36, 0x62, 0x51, 0x2b, 0x10, 0xa5, 0xa5, 0xaf, 0x23, + 0x60, 0xba, 0xca, 0xe0, 0x33, 0x1c, 0x04, 0x88, 0xd7, 0x22, 0xdb, 0xb0, 0x42, 0x77, 0x1b, 0x31, + 0x2e, 0xdf, 0x06, 0x19, 0x86, 0x60, 0xe8, 0x51, 0x45, 0x2a, 0x4a, 0x8b, 0x13, 0x86, 0x38, 0xc9, + 0x3b, 0x60, 0xa2, 0x41, 0x4c, 0x9b, 0x3b, 0x26, 0xd9, 0x53, 0x46, 0x8a, 0xd2, 0x62, 0xae, 0xf2, + 0xf8, 0xa4, 0x5d, 0x58, 0x83, 0x88, 0xfb, 0x91, 0xad, 0x39, 0x38, 0xd0, 0x05, 0x69, 0xd3, 0xb2, + 0x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x98, + 0xbc, 0xb2, 0x05, 0xf7, 0x6e, 0xba, 0xa4, 0x1f, 0x97, 0xd7, 0x86, 0xc3, 0x5d, 0x30, 0xd9, 0x20, + 0xd7, 0x67, 0xc9, 0xc2, 0x4d, 0xf5, 0x97, 0x51, 0xf9, 0x07, 0xc3, 0xa0, 0xba, 0x1c, 0xf9, 0xb1, + 0xf7, 0xe7, 0x87, 0x4b, 0x52, 0x65, 0xfb, 0xe8, 0x54, 0x95, 0x8e, 0x4f, 0x55, 0xe9, 0xe7, 0xa9, + 0x2a, 0x7d, 0x3c, 0x53, 0x53, 0xc7, 0x67, 0x6a, 0xea, 0xc7, 0x99, 0x9a, 0x7a, 0x53, 0xfe, 0xfd, + 0x28, 0x1e, 0xf4, 0x9e, 0xe7, 0x78, 0x2a, 0xed, 0x4c, 0xfc, 0x36, 0xaf, 0xfe, 0x0a, 0x00, 0x00, + 0xff, 0xff, 0x0a, 0x87, 0xfa, 0xed, 0x5b, 0x06, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -404,10 +437,10 @@ const _ = grpc.SupportPackageIsVersion4 // // For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream. type MsgClient interface { - // AddFinalitySig adds a finality signature to a given block - AddFinalitySig(ctx context.Context, in *MsgAddFinalitySig, opts ...grpc.CallOption) (*MsgAddFinalitySigResponse, error) // CommitPubRandList commits a list of public randomness for EOTS CommitPubRandList(ctx context.Context, in *MsgCommitPubRandList, opts ...grpc.CallOption) (*MsgCommitPubRandListResponse, error) + // AddFinalitySig adds a finality signature to a given block + AddFinalitySig(ctx context.Context, in *MsgAddFinalitySig, opts ...grpc.CallOption) (*MsgAddFinalitySigResponse, error) // TODO: msg for evidence of equivocation. this is not specified yet // UpdateParams updates the finality module parameters. UpdateParams(ctx context.Context, in *MsgUpdateParams, opts ...grpc.CallOption) (*MsgUpdateParamsResponse, error) @@ -421,18 +454,18 @@ func NewMsgClient(cc grpc1.ClientConn) MsgClient { return &msgClient{cc} } -func (c *msgClient) AddFinalitySig(ctx context.Context, in *MsgAddFinalitySig, opts ...grpc.CallOption) (*MsgAddFinalitySigResponse, error) { - out := new(MsgAddFinalitySigResponse) - err := c.cc.Invoke(ctx, "/babylon.finality.v1.Msg/AddFinalitySig", in, out, opts...) +func (c *msgClient) CommitPubRandList(ctx context.Context, in *MsgCommitPubRandList, opts ...grpc.CallOption) (*MsgCommitPubRandListResponse, error) { + out := new(MsgCommitPubRandListResponse) + err := c.cc.Invoke(ctx, "/babylon.finality.v1.Msg/CommitPubRandList", in, out, opts...) if err != nil { return nil, err } return out, nil } -func (c *msgClient) CommitPubRandList(ctx context.Context, in *MsgCommitPubRandList, opts ...grpc.CallOption) (*MsgCommitPubRandListResponse, error) { - out := new(MsgCommitPubRandListResponse) - err := c.cc.Invoke(ctx, "/babylon.finality.v1.Msg/CommitPubRandList", in, out, opts...) +func (c *msgClient) AddFinalitySig(ctx context.Context, in *MsgAddFinalitySig, opts ...grpc.CallOption) (*MsgAddFinalitySigResponse, error) { + out := new(MsgAddFinalitySigResponse) + err := c.cc.Invoke(ctx, "/babylon.finality.v1.Msg/AddFinalitySig", in, out, opts...) if err != nil { return nil, err } @@ -450,10 +483,10 @@ func (c *msgClient) UpdateParams(ctx context.Context, in *MsgUpdateParams, opts // MsgServer is the server API for Msg service. type MsgServer interface { - // AddFinalitySig adds a finality signature to a given block - AddFinalitySig(context.Context, *MsgAddFinalitySig) (*MsgAddFinalitySigResponse, error) // CommitPubRandList commits a list of public randomness for EOTS CommitPubRandList(context.Context, *MsgCommitPubRandList) (*MsgCommitPubRandListResponse, error) + // AddFinalitySig adds a finality signature to a given block + AddFinalitySig(context.Context, *MsgAddFinalitySig) (*MsgAddFinalitySigResponse, error) // TODO: msg for evidence of equivocation. this is not specified yet // UpdateParams updates the finality module parameters. UpdateParams(context.Context, *MsgUpdateParams) (*MsgUpdateParamsResponse, error) @@ -463,12 +496,12 @@ type MsgServer interface { type UnimplementedMsgServer struct { } -func (*UnimplementedMsgServer) AddFinalitySig(ctx context.Context, req *MsgAddFinalitySig) (*MsgAddFinalitySigResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method AddFinalitySig not implemented") -} func (*UnimplementedMsgServer) CommitPubRandList(ctx context.Context, req *MsgCommitPubRandList) (*MsgCommitPubRandListResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method CommitPubRandList not implemented") } +func (*UnimplementedMsgServer) AddFinalitySig(ctx context.Context, req *MsgAddFinalitySig) (*MsgAddFinalitySigResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method AddFinalitySig not implemented") +} func (*UnimplementedMsgServer) UpdateParams(ctx context.Context, req *MsgUpdateParams) (*MsgUpdateParamsResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method UpdateParams not implemented") } @@ -477,38 +510,38 @@ func RegisterMsgServer(s grpc1.Server, srv MsgServer) { s.RegisterService(&_Msg_serviceDesc, srv) } -func _Msg_AddFinalitySig_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(MsgAddFinalitySig) +func _Msg_CommitPubRandList_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(MsgCommitPubRandList) if err := dec(in); err != nil { return nil, err } if interceptor == nil { - return srv.(MsgServer).AddFinalitySig(ctx, in) + return srv.(MsgServer).CommitPubRandList(ctx, in) } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: "/babylon.finality.v1.Msg/AddFinalitySig", + FullMethod: "/babylon.finality.v1.Msg/CommitPubRandList", } handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(MsgServer).AddFinalitySig(ctx, req.(*MsgAddFinalitySig)) + return srv.(MsgServer).CommitPubRandList(ctx, req.(*MsgCommitPubRandList)) } return interceptor(ctx, in, info, handler) } -func _Msg_CommitPubRandList_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(MsgCommitPubRandList) +func _Msg_AddFinalitySig_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(MsgAddFinalitySig) if err := dec(in); err != nil { return nil, err } if interceptor == nil { - return srv.(MsgServer).CommitPubRandList(ctx, in) + return srv.(MsgServer).AddFinalitySig(ctx, in) } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: "/babylon.finality.v1.Msg/CommitPubRandList", + FullMethod: "/babylon.finality.v1.Msg/AddFinalitySig", } handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(MsgServer).CommitPubRandList(ctx, req.(*MsgCommitPubRandList)) + return srv.(MsgServer).AddFinalitySig(ctx, req.(*MsgAddFinalitySig)) } return interceptor(ctx, in, info, handler) } @@ -535,14 +568,14 @@ var _Msg_serviceDesc = grpc.ServiceDesc{ ServiceName: "babylon.finality.v1.Msg", HandlerType: (*MsgServer)(nil), Methods: []grpc.MethodDesc{ - { - MethodName: "AddFinalitySig", - Handler: _Msg_AddFinalitySig_Handler, - }, { MethodName: "CommitPubRandList", Handler: _Msg_CommitPubRandList_Handler, }, + { + MethodName: "AddFinalitySig", + Handler: _Msg_AddFinalitySig_Handler, + }, { MethodName: "UpdateParams", Handler: _Msg_UpdateParams_Handler, @@ -552,7 +585,7 @@ var _Msg_serviceDesc = grpc.ServiceDesc{ Metadata: "babylon/finality/v1/tx.proto", } -func (m *MsgAddFinalitySig) Marshal() (dAtA []byte, err error) { +func (m *MsgCommitPubRandList) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalToSizedBuffer(dAtA[:size]) @@ -562,37 +595,42 @@ func (m *MsgAddFinalitySig) Marshal() (dAtA []byte, err error) { return dAtA[:n], nil } -func (m *MsgAddFinalitySig) MarshalTo(dAtA []byte) (int, error) { +func (m *MsgCommitPubRandList) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *MsgAddFinalitySig) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *MsgCommitPubRandList) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) _ = i var l int _ = l - if m.FinalitySig != nil { + if m.Sig != nil { { - size := m.FinalitySig.Size() + size := m.Sig.Size() i -= size - if _, err := m.FinalitySig.MarshalTo(dAtA[i:]); err != nil { + if _, err := m.Sig.MarshalTo(dAtA[i:]); err != nil { return 0, err } i = encodeVarintTx(dAtA, i, uint64(size)) } i-- + dAtA[i] = 0x32 + } + if len(m.Commitment) > 0 { + i -= len(m.Commitment) + copy(dAtA[i:], m.Commitment) + i = encodeVarintTx(dAtA, i, uint64(len(m.Commitment))) + i-- dAtA[i] = 0x2a } - if len(m.BlockAppHash) > 0 { - i -= len(m.BlockAppHash) - copy(dAtA[i:], m.BlockAppHash) - i = encodeVarintTx(dAtA, i, uint64(len(m.BlockAppHash))) + if m.NumPubRand != 0 { + i = encodeVarintTx(dAtA, i, uint64(m.NumPubRand)) i-- - dAtA[i] = 0x22 + dAtA[i] = 0x20 } - if m.BlockHeight != 0 { - i = encodeVarintTx(dAtA, i, uint64(m.BlockHeight)) + if m.StartHeight != 0 { + i = encodeVarintTx(dAtA, i, uint64(m.StartHeight)) i-- dAtA[i] = 0x18 } @@ -618,7 +656,7 @@ func (m *MsgAddFinalitySig) MarshalToSizedBuffer(dAtA []byte) (int, error) { return len(dAtA) - i, nil } -func (m *MsgAddFinalitySigResponse) Marshal() (dAtA []byte, err error) { +func (m *MsgCommitPubRandListResponse) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalToSizedBuffer(dAtA[:size]) @@ -628,12 +666,12 @@ func (m *MsgAddFinalitySigResponse) Marshal() (dAtA []byte, err error) { return dAtA[:n], nil } -func (m *MsgAddFinalitySigResponse) MarshalTo(dAtA []byte) (int, error) { +func (m *MsgCommitPubRandListResponse) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *MsgAddFinalitySigResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *MsgCommitPubRandListResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) _ = i var l int @@ -641,7 +679,7 @@ func (m *MsgAddFinalitySigResponse) MarshalToSizedBuffer(dAtA []byte) (int, erro return len(dAtA) - i, nil } -func (m *MsgCommitPubRandList) Marshal() (dAtA []byte, err error) { +func (m *MsgAddFinalitySig) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalToSizedBuffer(dAtA[:size]) @@ -651,44 +689,61 @@ func (m *MsgCommitPubRandList) Marshal() (dAtA []byte, err error) { return dAtA[:n], nil } -func (m *MsgCommitPubRandList) MarshalTo(dAtA []byte) (int, error) { +func (m *MsgAddFinalitySig) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *MsgCommitPubRandList) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *MsgAddFinalitySig) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) _ = i var l int _ = l - if m.Sig != nil { + if m.FinalitySig != nil { { - size := m.Sig.Size() + size := m.FinalitySig.Size() i -= size - if _, err := m.Sig.MarshalTo(dAtA[i:]); err != nil { + if _, err := m.FinalitySig.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintTx(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x3a + } + if len(m.BlockAppHash) > 0 { + i -= len(m.BlockAppHash) + copy(dAtA[i:], m.BlockAppHash) + i = encodeVarintTx(dAtA, i, uint64(len(m.BlockAppHash))) + i-- + dAtA[i] = 0x32 + } + if m.Proof != nil { + { + size, err := m.Proof.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { return 0, err } + i -= size i = encodeVarintTx(dAtA, i, uint64(size)) } i-- dAtA[i] = 0x2a } - if len(m.PubRandList) > 0 { - for iNdEx := len(m.PubRandList) - 1; iNdEx >= 0; iNdEx-- { - { - size := m.PubRandList[iNdEx].Size() - i -= size - if _, err := m.PubRandList[iNdEx].MarshalTo(dAtA[i:]); err != nil { - return 0, err - } - i = encodeVarintTx(dAtA, i, uint64(size)) + if m.PubRand != nil { + { + size := m.PubRand.Size() + i -= size + if _, err := m.PubRand.MarshalTo(dAtA[i:]); err != nil { + return 0, err } - i-- - dAtA[i] = 0x22 + i = encodeVarintTx(dAtA, i, uint64(size)) } + i-- + dAtA[i] = 0x22 } - if m.StartHeight != 0 { - i = encodeVarintTx(dAtA, i, uint64(m.StartHeight)) + if m.BlockHeight != 0 { + i = encodeVarintTx(dAtA, i, uint64(m.BlockHeight)) i-- dAtA[i] = 0x18 } @@ -714,7 +769,7 @@ func (m *MsgCommitPubRandList) MarshalToSizedBuffer(dAtA []byte) (int, error) { return len(dAtA) - i, nil } -func (m *MsgCommitPubRandListResponse) Marshal() (dAtA []byte, err error) { +func (m *MsgAddFinalitySigResponse) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalToSizedBuffer(dAtA[:size]) @@ -724,12 +779,12 @@ func (m *MsgCommitPubRandListResponse) Marshal() (dAtA []byte, err error) { return dAtA[:n], nil } -func (m *MsgCommitPubRandListResponse) MarshalTo(dAtA []byte) (int, error) { +func (m *MsgAddFinalitySigResponse) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *MsgCommitPubRandListResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *MsgAddFinalitySigResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) _ = i var l int @@ -811,7 +866,7 @@ func encodeVarintTx(dAtA []byte, offset int, v uint64) int { dAtA[offset] = uint8(v) return base } -func (m *MsgAddFinalitySig) Size() (n int) { +func (m *MsgCommitPubRandList) Size() (n int) { if m == nil { return 0 } @@ -825,21 +880,24 @@ func (m *MsgAddFinalitySig) Size() (n int) { l = m.FpBtcPk.Size() n += 1 + l + sovTx(uint64(l)) } - if m.BlockHeight != 0 { - n += 1 + sovTx(uint64(m.BlockHeight)) + if m.StartHeight != 0 { + n += 1 + sovTx(uint64(m.StartHeight)) } - l = len(m.BlockAppHash) + if m.NumPubRand != 0 { + n += 1 + sovTx(uint64(m.NumPubRand)) + } + l = len(m.Commitment) if l > 0 { n += 1 + l + sovTx(uint64(l)) } - if m.FinalitySig != nil { - l = m.FinalitySig.Size() + if m.Sig != nil { + l = m.Sig.Size() n += 1 + l + sovTx(uint64(l)) } return n } -func (m *MsgAddFinalitySigResponse) Size() (n int) { +func (m *MsgCommitPubRandListResponse) Size() (n int) { if m == nil { return 0 } @@ -848,7 +906,7 @@ func (m *MsgAddFinalitySigResponse) Size() (n int) { return n } -func (m *MsgCommitPubRandList) Size() (n int) { +func (m *MsgAddFinalitySig) Size() (n int) { if m == nil { return 0 } @@ -862,23 +920,29 @@ func (m *MsgCommitPubRandList) Size() (n int) { l = m.FpBtcPk.Size() n += 1 + l + sovTx(uint64(l)) } - if m.StartHeight != 0 { - n += 1 + sovTx(uint64(m.StartHeight)) + if m.BlockHeight != 0 { + n += 1 + sovTx(uint64(m.BlockHeight)) } - if len(m.PubRandList) > 0 { - for _, e := range m.PubRandList { - l = e.Size() - n += 1 + l + sovTx(uint64(l)) - } + if m.PubRand != nil { + l = m.PubRand.Size() + n += 1 + l + sovTx(uint64(l)) } - if m.Sig != nil { - l = m.Sig.Size() + if m.Proof != nil { + l = m.Proof.Size() + n += 1 + l + sovTx(uint64(l)) + } + l = len(m.BlockAppHash) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + if m.FinalitySig != nil { + l = m.FinalitySig.Size() n += 1 + l + sovTx(uint64(l)) } return n } -func (m *MsgCommitPubRandListResponse) Size() (n int) { +func (m *MsgAddFinalitySigResponse) Size() (n int) { if m == nil { return 0 } @@ -917,7 +981,7 @@ func sovTx(x uint64) (n int) { func sozTx(x uint64) (n int) { return sovTx(uint64((x << 1) ^ uint64((int64(x) >> 63)))) } -func (m *MsgAddFinalitySig) Unmarshal(dAtA []byte) error { +func (m *MsgCommitPubRandList) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -940,10 +1004,10 @@ func (m *MsgAddFinalitySig) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: MsgAddFinalitySig: wiretype end group for non-group") + return fmt.Errorf("proto: MsgCommitPubRandList: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: MsgAddFinalitySig: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: MsgCommitPubRandList: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: @@ -1007,7 +1071,7 @@ func (m *MsgAddFinalitySig) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - var v github_com_babylonchain_babylon_types.BIP340PubKey + var v github_com_babylonlabs_io_babylon_types.BIP340PubKey m.FpBtcPk = &v if err := m.FpBtcPk.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err @@ -1015,9 +1079,9 @@ func (m *MsgAddFinalitySig) Unmarshal(dAtA []byte) error { iNdEx = postIndex case 3: if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field BlockHeight", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field StartHeight", wireType) } - m.BlockHeight = 0 + m.StartHeight = 0 for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowTx @@ -1027,14 +1091,33 @@ func (m *MsgAddFinalitySig) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - m.BlockHeight |= uint64(b&0x7F) << shift + m.StartHeight |= uint64(b&0x7F) << shift if b < 0x80 { break } } case 4: + 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 ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.NumPubRand |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 5: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field BlockAppHash", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field Commitment", wireType) } var byteLen int for shift := uint(0); ; shift += 7 { @@ -1061,14 +1144,14 @@ func (m *MsgAddFinalitySig) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.BlockAppHash = append(m.BlockAppHash[:0], dAtA[iNdEx:postIndex]...) - if m.BlockAppHash == nil { - m.BlockAppHash = []byte{} + m.Commitment = append(m.Commitment[:0], dAtA[iNdEx:postIndex]...) + if m.Commitment == nil { + m.Commitment = []byte{} } iNdEx = postIndex - case 5: + case 6: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field FinalitySig", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field Sig", wireType) } var byteLen int for shift := uint(0); ; shift += 7 { @@ -1095,9 +1178,9 @@ func (m *MsgAddFinalitySig) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - var v github_com_babylonchain_babylon_types.SchnorrEOTSSig - m.FinalitySig = &v - if err := m.FinalitySig.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + var v github_com_babylonlabs_io_babylon_types.BIP340Signature + m.Sig = &v + if err := m.Sig.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } iNdEx = postIndex @@ -1122,7 +1205,7 @@ func (m *MsgAddFinalitySig) Unmarshal(dAtA []byte) error { } return nil } -func (m *MsgAddFinalitySigResponse) Unmarshal(dAtA []byte) error { +func (m *MsgCommitPubRandListResponse) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -1145,10 +1228,10 @@ func (m *MsgAddFinalitySigResponse) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: MsgAddFinalitySigResponse: wiretype end group for non-group") + return fmt.Errorf("proto: MsgCommitPubRandListResponse: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: MsgAddFinalitySigResponse: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: MsgCommitPubRandListResponse: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { default: @@ -1172,7 +1255,7 @@ func (m *MsgAddFinalitySigResponse) Unmarshal(dAtA []byte) error { } return nil } -func (m *MsgCommitPubRandList) Unmarshal(dAtA []byte) error { +func (m *MsgAddFinalitySig) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -1195,10 +1278,10 @@ func (m *MsgCommitPubRandList) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: MsgCommitPubRandList: wiretype end group for non-group") + return fmt.Errorf("proto: MsgAddFinalitySig: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: MsgCommitPubRandList: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: MsgAddFinalitySig: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: @@ -1262,7 +1345,7 @@ func (m *MsgCommitPubRandList) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - var v github_com_babylonchain_babylon_types.BIP340PubKey + var v github_com_babylonlabs_io_babylon_types.BIP340PubKey m.FpBtcPk = &v if err := m.FpBtcPk.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err @@ -1270,9 +1353,9 @@ func (m *MsgCommitPubRandList) Unmarshal(dAtA []byte) error { iNdEx = postIndex case 3: if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field StartHeight", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field BlockHeight", wireType) } - m.StartHeight = 0 + m.BlockHeight = 0 for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowTx @@ -1282,14 +1365,14 @@ func (m *MsgCommitPubRandList) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - m.StartHeight |= uint64(b&0x7F) << shift + m.BlockHeight |= uint64(b&0x7F) << shift if b < 0x80 { break } } case 4: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field PubRandList", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field PubRand", wireType) } var byteLen int for shift := uint(0); ; shift += 7 { @@ -1316,15 +1399,51 @@ func (m *MsgCommitPubRandList) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - var v github_com_babylonchain_babylon_types.SchnorrPubRand - m.PubRandList = append(m.PubRandList, v) - if err := m.PubRandList[len(m.PubRandList)-1].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 case 5: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Sig", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field Proof", 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.Proof == nil { + m.Proof = &crypto.Proof{} + } + if err := m.Proof.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 6: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field BlockAppHash", wireType) } var byteLen int for shift := uint(0); ; shift += 7 { @@ -1351,9 +1470,43 @@ func (m *MsgCommitPubRandList) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - var v github_com_babylonchain_babylon_types.BIP340Signature - m.Sig = &v - if err := m.Sig.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + m.BlockAppHash = append(m.BlockAppHash[:0], dAtA[iNdEx:postIndex]...) + if m.BlockAppHash == nil { + m.BlockAppHash = []byte{} + } + iNdEx = postIndex + case 7: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field FinalitySig", 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 + } + var v github_com_babylonlabs_io_babylon_types.SchnorrEOTSSig + m.FinalitySig = &v + if err := m.FinalitySig.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } iNdEx = postIndex @@ -1378,7 +1531,7 @@ func (m *MsgCommitPubRandList) Unmarshal(dAtA []byte) error { } return nil } -func (m *MsgCommitPubRandListResponse) Unmarshal(dAtA []byte) error { +func (m *MsgAddFinalitySigResponse) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -1401,10 +1554,10 @@ func (m *MsgCommitPubRandListResponse) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: MsgCommitPubRandListResponse: wiretype end group for non-group") + return fmt.Errorf("proto: MsgAddFinalitySigResponse: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: MsgCommitPubRandListResponse: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: MsgAddFinalitySigResponse: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { default: diff --git a/x/incentive/abci.go b/x/incentive/abci.go index 66cdb7da9..7967e1f43 100644 --- a/x/incentive/abci.go +++ b/x/incentive/abci.go @@ -4,8 +4,8 @@ import ( "context" "time" - "github.com/babylonchain/babylon/x/incentive/keeper" - "github.com/babylonchain/babylon/x/incentive/types" + "github.com/babylonlabs-io/babylon/x/incentive/keeper" + "github.com/babylonlabs-io/babylon/x/incentive/types" abci "github.com/cometbft/cometbft/abci/types" "github.com/cosmos/cosmos-sdk/telemetry" sdk "github.com/cosmos/cosmos-sdk/types" diff --git a/x/incentive/client/cli/query.go b/x/incentive/client/cli/query.go index de89a08d9..7831a6d71 100644 --- a/x/incentive/client/cli/query.go +++ b/x/incentive/client/cli/query.go @@ -4,7 +4,7 @@ import ( "fmt" "strconv" - "github.com/babylonchain/babylon/x/incentive/types" + "github.com/babylonlabs-io/babylon/x/incentive/types" "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/client/flags" "github.com/spf13/cobra" diff --git a/x/incentive/client/cli/query_params.go b/x/incentive/client/cli/query_params.go index f6c20a168..377f02715 100644 --- a/x/incentive/client/cli/query_params.go +++ b/x/incentive/client/cli/query_params.go @@ -5,7 +5,7 @@ import ( "github.com/cosmos/cosmos-sdk/client/flags" "github.com/spf13/cobra" - "github.com/babylonchain/babylon/x/incentive/types" + "github.com/babylonlabs-io/babylon/x/incentive/types" ) func CmdQueryParams() *cobra.Command { diff --git a/x/incentive/client/cli/tx.go b/x/incentive/client/cli/tx.go index d039820c2..b3f12788d 100644 --- a/x/incentive/client/cli/tx.go +++ b/x/incentive/client/cli/tx.go @@ -4,7 +4,7 @@ import ( "fmt" "github.com/spf13/cobra" - "github.com/babylonchain/babylon/x/incentive/types" + "github.com/babylonlabs-io/babylon/x/incentive/types" "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/client/flags" "github.com/cosmos/cosmos-sdk/client/tx" diff --git a/x/incentive/genesis.go b/x/incentive/genesis.go index 1122dbdba..a078143ca 100644 --- a/x/incentive/genesis.go +++ b/x/incentive/genesis.go @@ -2,8 +2,8 @@ package incentive import ( "context" - "github.com/babylonchain/babylon/x/incentive/keeper" - "github.com/babylonchain/babylon/x/incentive/types" + "github.com/babylonlabs-io/babylon/x/incentive/keeper" + "github.com/babylonlabs-io/babylon/x/incentive/types" ) // InitGenesis initializes the module's state from a provided genesis state. diff --git a/x/incentive/genesis_test.go b/x/incentive/genesis_test.go index bb3f7e509..7bd9ca000 100644 --- a/x/incentive/genesis_test.go +++ b/x/incentive/genesis_test.go @@ -3,10 +3,10 @@ package incentive_test import ( "testing" - keepertest "github.com/babylonchain/babylon/testutil/keeper" - "github.com/babylonchain/babylon/testutil/nullify" - "github.com/babylonchain/babylon/x/incentive" - "github.com/babylonchain/babylon/x/incentive/types" + keepertest "github.com/babylonlabs-io/babylon/testutil/keeper" + "github.com/babylonlabs-io/babylon/testutil/nullify" + "github.com/babylonlabs-io/babylon/x/incentive" + "github.com/babylonlabs-io/babylon/x/incentive/types" "github.com/stretchr/testify/require" ) diff --git a/x/incentive/keeper/btc_staking_gauge.go b/x/incentive/keeper/btc_staking_gauge.go index b3067ab65..4992ef782 100644 --- a/x/incentive/keeper/btc_staking_gauge.go +++ b/x/incentive/keeper/btc_staking_gauge.go @@ -4,25 +4,25 @@ import ( "context" "cosmossdk.io/store/prefix" - bstypes "github.com/babylonchain/babylon/x/btcstaking/types" - "github.com/babylonchain/babylon/x/incentive/types" + bstypes "github.com/babylonlabs-io/babylon/x/btcstaking/types" + "github.com/babylonlabs-io/babylon/x/incentive/types" "github.com/cosmos/cosmos-sdk/runtime" sdk "github.com/cosmos/cosmos-sdk/types" ) // RewardBTCStaking distributes rewards to finality providers/delegations at a given height according -// to the reward distribution cache +// 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, rdc *bstypes.RewardDistCache) { +func (k Keeper) RewardBTCStaking(ctx context.Context, height uint64, filteredDc *bstypes.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 rdc.FinalityProviders { + for _, fp := range filteredDc.FinalityProviders { // get coins that will be allocated to the finality provider and its BTC delegations - fpPortion := rdc.GetFinalityProviderPortion(fp) + fpPortion := filteredDc.GetFinalityProviderPortion(fp) coinsForFpsAndDels := gauge.GetCoinsPortion(fpPortion) // reward the finality provider with commission coinsForCommission := types.GetCoinsPortion(coinsForFpsAndDels, *fp.Commission) diff --git a/x/incentive/keeper/btc_staking_gauge_test.go b/x/incentive/keeper/btc_staking_gauge_test.go index e467829c1..957886b93 100644 --- a/x/incentive/keeper/btc_staking_gauge_test.go +++ b/x/incentive/keeper/btc_staking_gauge_test.go @@ -4,9 +4,9 @@ import ( "math/rand" "testing" - "github.com/babylonchain/babylon/testutil/datagen" - testkeeper "github.com/babylonchain/babylon/testutil/keeper" - "github.com/babylonchain/babylon/x/incentive/types" + "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" @@ -32,8 +32,8 @@ func FuzzRewardBTCStaking(f *testing.F) { gauge := datagen.GenRandomGauge(r) keeper.SetBTCStakingGauge(ctx, height, gauge) - // generate a random reward distribution cache - rdc, err := datagen.GenRandomBTCStakingRewardDistCache(r) + // generate a random voting power distribution cache + dc, err := datagen.GenRandomVotingPowerDistCache(r, 100) require.NoError(t, err) // expected values @@ -41,8 +41,8 @@ func FuzzRewardBTCStaking(f *testing.F) { fpRewardMap := map[string]sdk.Coins{} // key: address, value: reward btcDelRewardMap := map[string]sdk.Coins{} // key: address, value: reward - for _, fp := range rdc.FinalityProviders { - fpPortion := rdc.GetFinalityProviderPortion(fp) + for _, fp := range dc.FinalityProviders { + fpPortion := dc.GetFinalityProviderPortion(fp) coinsForFpsAndDels := gauge.GetCoinsPortion(fpPortion) coinsForCommission := types.GetCoinsPortion(coinsForFpsAndDels, *fp.Commission) if coinsForCommission.IsAllPositive() { @@ -61,7 +61,7 @@ func FuzzRewardBTCStaking(f *testing.F) { } // distribute rewards in the gauge to finality providers/delegations - keeper.RewardBTCStaking(ctx, height, rdc) + keeper.RewardBTCStaking(ctx, height, dc) // assert consistency between reward map and reward gauge for addrStr, reward := range fpRewardMap { diff --git a/x/incentive/keeper/btc_timestamping_gauge.go b/x/incentive/keeper/btc_timestamping_gauge.go index 96e5b28a7..d4ed4f01d 100644 --- a/x/incentive/keeper/btc_timestamping_gauge.go +++ b/x/incentive/keeper/btc_timestamping_gauge.go @@ -4,8 +4,8 @@ import ( "context" "cosmossdk.io/math" "cosmossdk.io/store/prefix" - btcctypes "github.com/babylonchain/babylon/x/btccheckpoint/types" - "github.com/babylonchain/babylon/x/incentive/types" + 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" ) diff --git a/x/incentive/keeper/btc_timestamping_gauge_test.go b/x/incentive/keeper/btc_timestamping_gauge_test.go index 3b42cae19..84d962b65 100644 --- a/x/incentive/keeper/btc_timestamping_gauge_test.go +++ b/x/incentive/keeper/btc_timestamping_gauge_test.go @@ -5,9 +5,9 @@ import ( "testing" "cosmossdk.io/math" - "github.com/babylonchain/babylon/testutil/datagen" - testkeeper "github.com/babylonchain/babylon/testutil/keeper" - "github.com/babylonchain/babylon/x/incentive/types" + "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" diff --git a/x/incentive/keeper/grpc_query.go b/x/incentive/keeper/grpc_query.go index 341359b7d..3f1274d3b 100644 --- a/x/incentive/keeper/grpc_query.go +++ b/x/incentive/keeper/grpc_query.go @@ -3,7 +3,7 @@ package keeper import ( "context" - "github.com/babylonchain/babylon/x/incentive/types" + "github.com/babylonlabs-io/babylon/x/incentive/types" sdk "github.com/cosmos/cosmos-sdk/types" "google.golang.org/grpc/codes" "google.golang.org/grpc/status" diff --git a/x/incentive/keeper/grpc_query_test.go b/x/incentive/keeper/grpc_query_test.go index 9d609f307..048a7ad55 100644 --- a/x/incentive/keeper/grpc_query_test.go +++ b/x/incentive/keeper/grpc_query_test.go @@ -4,9 +4,9 @@ import ( "math/rand" "testing" - "github.com/babylonchain/babylon/testutil/datagen" - testkeeper "github.com/babylonchain/babylon/testutil/keeper" - "github.com/babylonchain/babylon/x/incentive/types" + "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/stretchr/testify/require" ) diff --git a/x/incentive/keeper/intercept_fee_collector.go b/x/incentive/keeper/intercept_fee_collector.go index 88500e558..05cc6c5be 100644 --- a/x/incentive/keeper/intercept_fee_collector.go +++ b/x/incentive/keeper/intercept_fee_collector.go @@ -2,7 +2,7 @@ package keeper import ( "context" - "github.com/babylonchain/babylon/x/incentive/types" + "github.com/babylonlabs-io/babylon/x/incentive/types" ) // HandleCoinsInFeeCollector intercepts a portion of coins in fee collector, and distributes diff --git a/x/incentive/keeper/intercept_fee_collector_test.go b/x/incentive/keeper/intercept_fee_collector_test.go index 189be6ba1..2f583caa2 100644 --- a/x/incentive/keeper/intercept_fee_collector_test.go +++ b/x/incentive/keeper/intercept_fee_collector_test.go @@ -6,10 +6,10 @@ import ( sdkmath "cosmossdk.io/math" - "github.com/babylonchain/babylon/testutil/datagen" - testkeeper "github.com/babylonchain/babylon/testutil/keeper" - epochingtypes "github.com/babylonchain/babylon/x/epoching/types" - "github.com/babylonchain/babylon/x/incentive/types" + "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" "github.com/golang/mock/gomock" diff --git a/x/incentive/keeper/keeper.go b/x/incentive/keeper/keeper.go index 4d931f4fe..9929989cd 100644 --- a/x/incentive/keeper/keeper.go +++ b/x/incentive/keeper/keeper.go @@ -5,7 +5,7 @@ import ( "fmt" "cosmossdk.io/log" - "github.com/babylonchain/babylon/x/incentive/types" + "github.com/babylonlabs-io/babylon/x/incentive/types" "github.com/cosmos/cosmos-sdk/codec" sdk "github.com/cosmos/cosmos-sdk/types" ) diff --git a/x/incentive/keeper/msg_server.go b/x/incentive/keeper/msg_server.go index 3d9ff5399..5dfe5833e 100644 --- a/x/incentive/keeper/msg_server.go +++ b/x/incentive/keeper/msg_server.go @@ -4,7 +4,7 @@ import ( "context" errorsmod "cosmossdk.io/errors" - "github.com/babylonchain/babylon/x/incentive/types" + "github.com/babylonlabs-io/babylon/x/incentive/types" sdk "github.com/cosmos/cosmos-sdk/types" govtypes "github.com/cosmos/cosmos-sdk/x/gov/types" "google.golang.org/grpc/codes" diff --git a/x/incentive/keeper/msg_server_test.go b/x/incentive/keeper/msg_server_test.go index 5b68ded8d..78a0783a9 100644 --- a/x/incentive/keeper/msg_server_test.go +++ b/x/incentive/keeper/msg_server_test.go @@ -5,10 +5,10 @@ import ( "math/rand" "testing" - "github.com/babylonchain/babylon/testutil/datagen" - testkeeper "github.com/babylonchain/babylon/testutil/keeper" - "github.com/babylonchain/babylon/x/incentive/keeper" - "github.com/babylonchain/babylon/x/incentive/types" + "github.com/babylonlabs-io/babylon/testutil/datagen" + testkeeper "github.com/babylonlabs-io/babylon/testutil/keeper" + "github.com/babylonlabs-io/babylon/x/incentive/keeper" + "github.com/babylonlabs-io/babylon/x/incentive/types" "github.com/golang/mock/gomock" "github.com/stretchr/testify/require" ) diff --git a/x/incentive/keeper/params.go b/x/incentive/keeper/params.go index 4e8c80e72..aac26aec0 100644 --- a/x/incentive/keeper/params.go +++ b/x/incentive/keeper/params.go @@ -2,7 +2,7 @@ package keeper import ( "context" - "github.com/babylonchain/babylon/x/incentive/types" + "github.com/babylonlabs-io/babylon/x/incentive/types" ) // SetParams sets the x/incentive module parameters. diff --git a/x/incentive/keeper/params_test.go b/x/incentive/keeper/params_test.go index e2ee0a1da..e6196521a 100644 --- a/x/incentive/keeper/params_test.go +++ b/x/incentive/keeper/params_test.go @@ -3,8 +3,8 @@ package keeper_test import ( "testing" - testkeeper "github.com/babylonchain/babylon/testutil/keeper" - "github.com/babylonchain/babylon/x/incentive/types" + testkeeper "github.com/babylonlabs-io/babylon/testutil/keeper" + "github.com/babylonlabs-io/babylon/x/incentive/types" "github.com/stretchr/testify/require" ) diff --git a/x/incentive/keeper/query_params.go b/x/incentive/keeper/query_params.go index b58c8c1ec..18b4fe8f4 100644 --- a/x/incentive/keeper/query_params.go +++ b/x/incentive/keeper/query_params.go @@ -3,7 +3,7 @@ package keeper import ( "context" - "github.com/babylonchain/babylon/x/incentive/types" + "github.com/babylonlabs-io/babylon/x/incentive/types" sdk "github.com/cosmos/cosmos-sdk/types" "google.golang.org/grpc/codes" "google.golang.org/grpc/status" diff --git a/x/incentive/keeper/query_params_test.go b/x/incentive/keeper/query_params_test.go index c98188c76..ec943cc99 100644 --- a/x/incentive/keeper/query_params_test.go +++ b/x/incentive/keeper/query_params_test.go @@ -3,8 +3,8 @@ package keeper_test import ( "testing" - testkeeper "github.com/babylonchain/babylon/testutil/keeper" - "github.com/babylonchain/babylon/x/incentive/types" + testkeeper "github.com/babylonlabs-io/babylon/testutil/keeper" + "github.com/babylonlabs-io/babylon/x/incentive/types" "github.com/stretchr/testify/require" ) diff --git a/x/incentive/keeper/reward_gauge.go b/x/incentive/keeper/reward_gauge.go index d06cbf3fd..57c598150 100644 --- a/x/incentive/keeper/reward_gauge.go +++ b/x/incentive/keeper/reward_gauge.go @@ -3,7 +3,7 @@ package keeper import ( "context" "cosmossdk.io/store/prefix" - "github.com/babylonchain/babylon/x/incentive/types" + "github.com/babylonlabs-io/babylon/x/incentive/types" "github.com/cosmos/cosmos-sdk/runtime" sdk "github.com/cosmos/cosmos-sdk/types" ) diff --git a/x/incentive/keeper/reward_gauge_test.go b/x/incentive/keeper/reward_gauge_test.go index 74a840c13..53bf8f34b 100644 --- a/x/incentive/keeper/reward_gauge_test.go +++ b/x/incentive/keeper/reward_gauge_test.go @@ -3,7 +3,7 @@ package keeper_test import ( "testing" - "github.com/babylonchain/babylon/x/incentive/types" + "github.com/babylonlabs-io/babylon/x/incentive/types" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/stretchr/testify/require" ) diff --git a/x/incentive/module.go b/x/incentive/module.go index 862daf4ff..254a95231 100644 --- a/x/incentive/module.go +++ b/x/incentive/module.go @@ -6,9 +6,9 @@ import ( "encoding/json" "fmt" - "github.com/babylonchain/babylon/x/incentive/client/cli" - "github.com/babylonchain/babylon/x/incentive/keeper" - "github.com/babylonchain/babylon/x/incentive/types" + "github.com/babylonlabs-io/babylon/x/incentive/client/cli" + "github.com/babylonlabs-io/babylon/x/incentive/keeper" + "github.com/babylonlabs-io/babylon/x/incentive/types" abci "github.com/cometbft/cometbft/abci/types" "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/codec" diff --git a/x/incentive/types/expected_keepers.go b/x/incentive/types/expected_keepers.go index a8000ec2d..434a96c0d 100644 --- a/x/incentive/types/expected_keepers.go +++ b/x/incentive/types/expected_keepers.go @@ -2,7 +2,7 @@ package types import ( "context" - epochingtypes "github.com/babylonchain/babylon/x/epoching/types" + epochingtypes "github.com/babylonlabs-io/babylon/x/epoching/types" sdk "github.com/cosmos/cosmos-sdk/types" ) diff --git a/x/incentive/types/genesis.pb.go b/x/incentive/types/genesis.pb.go index d2c7b135c..223029c7b 100644 --- a/x/incentive/types/genesis.pb.go +++ b/x/incentive/types/genesis.pb.go @@ -75,7 +75,7 @@ func init() { func init() { proto.RegisterFile("babylon/incentive/genesis.proto", fileDescriptor_41d5400dc6b4b931) } var fileDescriptor_41d5400dc6b4b931 = []byte{ - // 195 bytes of a gzipped FileDescriptorProto + // 197 bytes of a gzipped FileDescriptorProto 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x92, 0x4f, 0x4a, 0x4c, 0xaa, 0xcc, 0xc9, 0xcf, 0xd3, 0xcf, 0xcc, 0x4b, 0x4e, 0xcd, 0x2b, 0xc9, 0x2c, 0x4b, 0xd5, 0x4f, 0x4f, 0xcd, 0x4b, 0x2d, 0xce, 0x2c, 0xd6, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0x12, 0x84, 0x2a, 0xd0, @@ -83,12 +83,12 @@ var fileDescriptor_41d5400dc6b4b931 = []byte{ 0x72, 0x98, 0x26, 0x15, 0x24, 0x16, 0x25, 0xe6, 0x42, 0x0d, 0x52, 0x72, 0xe7, 0xe2, 0x71, 0x87, 0x98, 0x1c, 0x5c, 0x92, 0x58, 0x92, 0x2a, 0x64, 0xce, 0xc5, 0x06, 0x91, 0x97, 0x60, 0x54, 0x60, 0xd4, 0xe0, 0x36, 0x92, 0xd4, 0xc3, 0xb0, 0x49, 0x2f, 0x00, 0xac, 0xc0, 0x89, 0xe5, 0xc4, 0x3d, - 0x79, 0x86, 0x20, 0xa8, 0x72, 0x27, 0xef, 0x13, 0x8f, 0xe4, 0x18, 0x2f, 0x3c, 0x92, 0x63, 0x7c, + 0x79, 0x86, 0x20, 0xa8, 0x72, 0x27, 0xdf, 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, 0x32, 0x4c, 0xcf, 0x2c, 0xc9, 0x28, 0x4d, 0xd2, 0x4b, 0xce, 0xcf, 0xd5, 0x87, 0x1a, 0x96, - 0x9c, 0x91, 0x98, 0x99, 0x07, 0xe3, 0xe8, 0x57, 0x20, 0x39, 0xae, 0xa4, 0xb2, 0x20, 0xb5, 0x38, - 0x89, 0x0d, 0xec, 0x38, 0x63, 0x40, 0x00, 0x00, 0x00, 0xff, 0xff, 0x8c, 0xa1, 0x97, 0x7e, 0x08, - 0x01, 0x00, 0x00, + 0x88, 0x32, 0x4e, 0xcf, 0x2c, 0xc9, 0x28, 0x4d, 0xd2, 0x4b, 0xce, 0xcf, 0xd5, 0x87, 0x1a, 0x96, + 0x93, 0x98, 0x54, 0xac, 0x9b, 0x99, 0x0f, 0xe3, 0xea, 0x57, 0x20, 0x39, 0xaf, 0xa4, 0xb2, 0x20, + 0xb5, 0x38, 0x89, 0x0d, 0xec, 0x3c, 0x63, 0x40, 0x00, 0x00, 0x00, 0xff, 0xff, 0x33, 0x58, 0xf9, + 0x93, 0x0a, 0x01, 0x00, 0x00, } func (m *GenesisState) Marshal() (dAtA []byte, err error) { diff --git a/x/incentive/types/genesis_test.go b/x/incentive/types/genesis_test.go index 230e2c670..8f30abae3 100644 --- a/x/incentive/types/genesis_test.go +++ b/x/incentive/types/genesis_test.go @@ -3,7 +3,7 @@ package types_test import ( "testing" - "github.com/babylonchain/babylon/x/incentive/types" + "github.com/babylonlabs-io/babylon/x/incentive/types" "github.com/stretchr/testify/require" ) diff --git a/x/incentive/types/incentive.pb.go b/x/incentive/types/incentive.pb.go index 304f85dba..98d972e2e 100644 --- a/x/incentive/types/incentive.pb.go +++ b/x/incentive/types/incentive.pb.go @@ -138,7 +138,7 @@ func init() { func init() { proto.RegisterFile("babylon/incentive/incentive.proto", fileDescriptor_3954bc4942045a7a) } var fileDescriptor_3954bc4942045a7a = []byte{ - // 269 bytes of a gzipped FileDescriptorProto + // 271 bytes of a gzipped FileDescriptorProto 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x52, 0x4c, 0x4a, 0x4c, 0xaa, 0xcc, 0xc9, 0xcf, 0xd3, 0xcf, 0xcc, 0x4b, 0x4e, 0xcd, 0x2b, 0xc9, 0x2c, 0x4b, 0x45, 0xb0, 0xf4, 0x0a, 0x8a, 0xf2, 0x4b, 0xf2, 0x85, 0x04, 0xa1, 0x4a, 0xf4, 0xe0, 0x12, 0x52, 0x22, 0xe9, 0xf9, @@ -151,11 +151,11 @@ var fileDescriptor_3954bc4942045a7a = []byte{ 0xa8, 0x2d, 0x10, 0x4a, 0xb7, 0x38, 0x25, 0x5b, 0xbf, 0xa4, 0xb2, 0x20, 0xb5, 0x18, 0xac, 0xa1, 0x38, 0x08, 0x62, 0xb2, 0xd2, 0x33, 0x46, 0x2e, 0xee, 0xa0, 0xd4, 0xf2, 0xc4, 0xa2, 0x14, 0x7a, 0x59, 0x29, 0x54, 0xc2, 0xc5, 0x5f, 0x9e, 0x59, 0x92, 0x91, 0x52, 0x94, 0x58, 0x9e, 0x17, 0x0f, - 0xb1, 0x8c, 0x89, 0xfa, 0x96, 0xf1, 0xc1, 0xed, 0x00, 0xf3, 0x9d, 0xbc, 0x4f, 0x3c, 0x92, 0x63, + 0xb1, 0x8c, 0x89, 0xfa, 0x96, 0xf1, 0xc1, 0xed, 0x00, 0xf3, 0x9d, 0x7c, 0x4f, 0x3c, 0x92, 0x63, 0xbc, 0xf0, 0x48, 0x8e, 0xf1, 0xc1, 0x23, 0x39, 0xc6, 0x09, 0x8f, 0xe5, 0x18, 0x2e, 0x3c, 0x96, - 0x63, 0xb8, 0xf1, 0x58, 0x8e, 0x21, 0xca, 0x10, 0xc9, 0x4c, 0x68, 0x14, 0x26, 0x67, 0x24, 0x66, - 0xe6, 0xc1, 0x38, 0xfa, 0x15, 0x48, 0x91, 0x0e, 0xb6, 0x22, 0x89, 0x0d, 0x1c, 0x51, 0xc6, 0x80, - 0x00, 0x00, 0x00, 0xff, 0xff, 0xdc, 0x83, 0xc5, 0xfb, 0x16, 0x02, 0x00, 0x00, + 0x63, 0xb8, 0xf1, 0x58, 0x8e, 0x21, 0xca, 0x18, 0xc9, 0x4c, 0x68, 0x14, 0xe6, 0x24, 0x26, 0x15, + 0xeb, 0x66, 0xe6, 0xc3, 0xb8, 0xfa, 0x15, 0x48, 0xd1, 0x0e, 0xb6, 0x24, 0x89, 0x0d, 0x1c, 0x55, + 0xc6, 0x80, 0x00, 0x00, 0x00, 0xff, 0xff, 0xd1, 0xc1, 0x22, 0xfc, 0x18, 0x02, 0x00, 0x00, } func (m *Gauge) Marshal() (dAtA []byte, err error) { diff --git a/x/incentive/types/mocked_keepers.go b/x/incentive/types/mocked_keepers.go index 833bbb50d..b0e07c0e9 100644 --- a/x/incentive/types/mocked_keepers.go +++ b/x/incentive/types/mocked_keepers.go @@ -8,7 +8,7 @@ import ( context "context" reflect "reflect" - types "github.com/babylonchain/babylon/x/epoching/types" + types "github.com/babylonlabs-io/babylon/x/epoching/types" types0 "github.com/cosmos/cosmos-sdk/types" gomock "github.com/golang/mock/gomock" ) diff --git a/x/incentive/types/params.pb.go b/x/incentive/types/params.pb.go index a0062b8d6..ac7b99865 100644 --- a/x/incentive/types/params.pb.go +++ b/x/incentive/types/params.pb.go @@ -79,7 +79,7 @@ func init() { func init() { proto.RegisterFile("babylon/incentive/params.proto", fileDescriptor_c42276168f0adf4b) } var fileDescriptor_c42276168f0adf4b = []byte{ - // 294 bytes of a gzipped FileDescriptorProto + // 296 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, @@ -93,12 +93,12 @@ var fileDescriptor_c42276168f0adf4b = []byte{ 0x31, 0x4a, 0x28, 0x86, 0x4b, 0xa0, 0x28, 0x15, 0x64, 0x2e, 0x92, 0xf1, 0x4c, 0xe4, 0x1a, 0xcf, 0x0f, 0x33, 0x0a, 0x66, 0x7a, 0x22, 0x97, 0x70, 0x52, 0x49, 0x72, 0x7c, 0x71, 0x49, 0x62, 0x76, 0x66, 0x5e, 0x3a, 0xdc, 0x02, 0x66, 0x72, 0x2d, 0x10, 0x4c, 0x2a, 0x49, 0x0e, 0x86, 0x18, 0x06, - 0xb5, 0xc2, 0x8a, 0x65, 0xc6, 0x02, 0x79, 0x06, 0x27, 0xef, 0x13, 0x8f, 0xe4, 0x18, 0x2f, 0x3c, + 0xb5, 0xc2, 0x8a, 0x65, 0xc6, 0x02, 0x79, 0x06, 0x27, 0xdf, 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, 0x32, 0x4c, 0xcf, 0x2c, 0xc9, 0x28, 0x4d, 0xd2, 0x4b, 0xce, 0xcf, 0xd5, - 0x87, 0x46, 0x4d, 0x72, 0x46, 0x62, 0x66, 0x1e, 0x8c, 0xa3, 0x5f, 0x81, 0x14, 0x93, 0x25, 0x95, - 0x05, 0xa9, 0xc5, 0x49, 0x6c, 0xe0, 0x58, 0x30, 0x06, 0x04, 0x00, 0x00, 0xff, 0xff, 0x55, 0x13, - 0x48, 0x09, 0xeb, 0x01, 0x00, 0x00, + 0x3c, 0x96, 0x63, 0x88, 0x32, 0x4e, 0xcf, 0x2c, 0xc9, 0x28, 0x4d, 0xd2, 0x4b, 0xce, 0xcf, 0xd5, + 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, } func (m *Params) Marshal() (dAtA []byte, err error) { diff --git a/x/incentive/types/query.pb.go b/x/incentive/types/query.pb.go index bacf7178d..a0829633e 100644 --- a/x/incentive/types/query.pb.go +++ b/x/incentive/types/query.pb.go @@ -404,46 +404,46 @@ func init() { func init() { proto.RegisterFile("babylon/incentive/query.proto", fileDescriptor_e1a59cc0c7c44135) } var fileDescriptor_e1a59cc0c7c44135 = []byte{ - // 615 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x9c, 0x94, 0x4f, 0x6f, 0xd3, 0x30, - 0x18, 0xc6, 0xeb, 0x6e, 0x2d, 0xcc, 0x1b, 0x82, 0x99, 0x0a, 0x65, 0xd9, 0x08, 0x5d, 0x24, 0xa6, - 0x4a, 0xa0, 0x44, 0x74, 0x45, 0xa0, 0x09, 0x0d, 0x54, 0xfe, 0x49, 0x20, 0x55, 0x90, 0xed, 0xc4, - 0xa5, 0x72, 0x53, 0x2b, 0x8d, 0xd6, 0xc4, 0x59, 0xe2, 0x0c, 0x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 0xff, 0xff, 0x0b, - 0x2f, 0x3f, 0xc6, 0x6c, 0x06, 0x00, 0x00, + // 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, 0x98, 0x10, 0x24, 0x7c, 0x10, 0x94, 0xbb, 0x73, + 0xe4, 0x36, 0x76, 0x69, 0xd9, 0xce, 0xef, 0xfb, 0xbc, 0xcf, 0xfb, 0xcb, 0xf9, 0x71, 0xc0, 0x4d, + 0x0b, 0x59, 0xa3, 0x21, 0xf1, 0x0c, 0xc7, 0xeb, 0x61, 0x8f, 0x3a, 0x07, 0xd8, 0xd8, 0x8f, 0x70, + 0x30, 0xd2, 0xfd, 0x80, 0x50, 0x02, 0xd7, 0x45, 0x5b, 0x9f, 0xb7, 0x95, 0x92, 0x4d, 0x6c, 0xc2, + 0xba, 0xc6, 0xec, 0xc4, 0x85, 0xca, 0x86, 0x4d, 0x88, 0x3d, 0xc4, 0x06, 0xf2, 0x1d, 0x03, 0x79, + 0x1e, 0xa1, 0x88, 0x3a, 0xc4, 0x0b, 0x45, 0x57, 0x5d, 0xdc, 0xe2, 0xa3, 0x00, 0xb9, 0x71, 0xbf, + 0xb6, 0xd8, 0x9f, 0x9f, 0xb8, 0x44, 0x2b, 0x01, 0xf8, 0x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x74, 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, } // Reference imports to suppress errors if they are not otherwise used. diff --git a/x/incentive/types/query.pb.gw.go b/x/incentive/types/query.pb.gw.go index 5b8468f06..584a8f9c2 100644 --- a/x/incentive/types/query.pb.gw.go +++ b/x/incentive/types/query.pb.gw.go @@ -436,13 +436,13 @@ 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{"babylonchain", "babylon", "incentive", "params"}, "", runtime.AssumeColonVerbOpt(false))) + pattern_Query_Params_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"babylon", "incentive", "params"}, "", runtime.AssumeColonVerbOpt(false))) - pattern_Query_RewardGauges_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 1, 0, 4, 1, 5, 3, 2, 4}, []string{"babylonchain", "babylon", "incentive", "address", "reward_gauge"}, "", runtime.AssumeColonVerbOpt(false))) + 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, 2, 3, 1, 0, 4, 1, 5, 4}, []string{"babylonchain", "babylon", "incentive", "btc_staking_gauge", "height"}, "", 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, 2, 3, 1, 0, 4, 1, 5, 4}, []string{"babylonchain", "babylon", "incentive", "btc_timestamping_gauge", "epoch_num"}, "", 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 ( diff --git a/x/incentive/types/tx.pb.go b/x/incentive/types/tx.pb.go index dece25fd3..6d52b0959 100644 --- a/x/incentive/types/tx.pb.go +++ b/x/incentive/types/tx.pb.go @@ -241,37 +241,37 @@ func init() { func init() { proto.RegisterFile("babylon/incentive/tx.proto", fileDescriptor_b4de6776d39a3a22) } var fileDescriptor_b4de6776d39a3a22 = []byte{ - // 467 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x8c, 0x53, 0x4f, 0x6b, 0xd4, 0x40, - 0x1c, 0xdd, 0xb1, 0x7f, 0xa4, 0x63, 0xa9, 0x74, 0x28, 0x34, 0x9b, 0x43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0xe1, 0xcd, 0xaf, 0x17, 0x39, 0xfe, 0xf0, 0xdf, 0x9c, - 0x56, 0xdf, 0x5f, 0xf9, 0x74, 0x71, 0x32, 0x04, 0xf1, 0xb3, 0xd3, 0x59, 0x00, 0xce, 0x66, 0x01, - 0xf8, 0x3d, 0x0b, 0xc0, 0x97, 0x79, 0xd0, 0x3b, 0x9b, 0x07, 0xbd, 0x1f, 0xf3, 0xa0, 0xf7, 0x66, - 0xb4, 0xb0, 0x4f, 0x27, 0x9b, 0x15, 0x84, 0x8b, 0xb6, 0xc0, 0xc7, 0x8b, 0x9f, 0x90, 0x59, 0x6f, - 0xba, 0xda, 0xfc, 0x53, 0x1f, 0xfe, 0x09, 0x00, 0x00, 0xff, 0xff, 0xc7, 0x73, 0x0d, 0x40, 0x64, - 0x03, 0x00, 0x00, + // 469 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x8c, 0x53, 0xcf, 0x6b, 0x13, 0x41, + 0x14, 0xce, 0xd8, 0x1f, 0xd2, 0xb1, 0x54, 0x3a, 0x14, 0xba, 0xd9, 0xc3, 0xb6, 0x2c, 0x1e, 0x42, + 0x30, 0x3b, 0xa6, 0x05, 0x85, 0xde, 0x8c, 0xe7, 0xa0, 0xac, 0x88, 0xe0, 0x41, 0x99, 0xcd, 0x0e, + 0x93, 0xc1, 0xee, 0xce, 0xb2, 0x6f, 0x9a, 0x36, 0x17, 0x11, 0xff, 0x02, 0xf1, 0xcf, 0xf0, 0xd4, + 0x83, 0x7f, 0x44, 0x8f, 0xa5, 0x27, 0x4f, 0x2a, 0xc9, 0xa1, 0xff, 0x86, 0xcc, 0xce, 0x6c, 0x1b, + 0xbb, 0x05, 0x7b, 0x9a, 0x79, 0xf9, 0xbe, 0xf9, 0xde, 0xf7, 0xbe, 0x97, 0xc5, 0x7e, 0xc2, 0x92, + 0xe9, 0xa1, 0xca, 0xa9, 0xcc, 0x47, 0x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03, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. diff --git a/x/monitor/client/cli/query.go b/x/monitor/client/cli/query.go index 50e9b2a2e..31b0bc1e2 100644 --- a/x/monitor/client/cli/query.go +++ b/x/monitor/client/cli/query.go @@ -7,7 +7,7 @@ import ( "github.com/cosmos/cosmos-sdk/client" - "github.com/babylonchain/babylon/x/monitor/types" + "github.com/babylonlabs-io/babylon/x/monitor/types" ) // GetQueryCmd returns the cli query commands for this module diff --git a/x/monitor/client/cli/tx.go b/x/monitor/client/cli/tx.go index c1836f6e7..4d55ca102 100644 --- a/x/monitor/client/cli/tx.go +++ b/x/monitor/client/cli/tx.go @@ -7,7 +7,7 @@ import ( "github.com/cosmos/cosmos-sdk/client" - "github.com/babylonchain/babylon/x/monitor/types" + "github.com/babylonlabs-io/babylon/x/monitor/types" ) // GetTxCmd returns the transaction commands for this module diff --git a/x/monitor/genesis.go b/x/monitor/genesis.go index b786d9685..df03d8cce 100644 --- a/x/monitor/genesis.go +++ b/x/monitor/genesis.go @@ -2,8 +2,8 @@ package monitor import ( "context" - "github.com/babylonchain/babylon/x/monitor/keeper" - "github.com/babylonchain/babylon/x/monitor/types" + "github.com/babylonlabs-io/babylon/x/monitor/keeper" + "github.com/babylonlabs-io/babylon/x/monitor/types" ) // InitGenesis initializes the capability module's state from a provided genesis diff --git a/x/monitor/genesis_test.go b/x/monitor/genesis_test.go index db95adb13..fbb1b2b00 100644 --- a/x/monitor/genesis_test.go +++ b/x/monitor/genesis_test.go @@ -3,11 +3,11 @@ package monitor_test import ( "testing" - "github.com/babylonchain/babylon/x/monitor" + "github.com/babylonlabs-io/babylon/x/monitor" "github.com/stretchr/testify/require" - simapp "github.com/babylonchain/babylon/app" - "github.com/babylonchain/babylon/x/monitor/types" + simapp "github.com/babylonlabs-io/babylon/app" + "github.com/babylonlabs-io/babylon/x/monitor/types" ) func TestExportGenesis(t *testing.T) { diff --git a/x/monitor/keeper/grpc_query.go b/x/monitor/keeper/grpc_query.go index 6a38d7a90..422194296 100644 --- a/x/monitor/keeper/grpc_query.go +++ b/x/monitor/keeper/grpc_query.go @@ -3,7 +3,7 @@ package keeper import ( "context" - "github.com/babylonchain/babylon/x/monitor/types" + "github.com/babylonlabs-io/babylon/x/monitor/types" sdk "github.com/cosmos/cosmos-sdk/types" "google.golang.org/grpc/codes" "google.golang.org/grpc/status" diff --git a/x/monitor/keeper/grpc_query_test.go b/x/monitor/keeper/grpc_query_test.go index 6f33b8fe7..53ea0862f 100644 --- a/x/monitor/keeper/grpc_query_test.go +++ b/x/monitor/keeper/grpc_query_test.go @@ -8,13 +8,13 @@ import ( "github.com/golang/mock/gomock" "github.com/stretchr/testify/require" - "github.com/babylonchain/babylon/app" - "github.com/babylonchain/babylon/btctxformatter" - "github.com/babylonchain/babylon/testutil/datagen" - "github.com/babylonchain/babylon/testutil/mocks" - ckpttypes "github.com/babylonchain/babylon/x/checkpointing/types" - types2 "github.com/babylonchain/babylon/x/epoching/types" - "github.com/babylonchain/babylon/x/monitor/types" + "github.com/babylonlabs-io/babylon/app" + "github.com/babylonlabs-io/babylon/btctxformatter" + "github.com/babylonlabs-io/babylon/testutil/datagen" + "github.com/babylonlabs-io/babylon/testutil/mocks" + ckpttypes "github.com/babylonlabs-io/babylon/x/checkpointing/types" + types2 "github.com/babylonlabs-io/babylon/x/epoching/types" + "github.com/babylonlabs-io/babylon/x/monitor/types" ) func FuzzQueryEndedEpochBtcHeight(f *testing.F) { diff --git a/x/monitor/keeper/hooks.go b/x/monitor/keeper/hooks.go index c343cd254..8a0a3d492 100644 --- a/x/monitor/keeper/hooks.go +++ b/x/monitor/keeper/hooks.go @@ -2,8 +2,9 @@ package keeper import ( "context" - checkpointingtypes "github.com/babylonchain/babylon/x/checkpointing/types" - etypes "github.com/babylonchain/babylon/x/epoching/types" + + checkpointingtypes "github.com/babylonlabs-io/babylon/x/checkpointing/types" + etypes "github.com/babylonlabs-io/babylon/x/epoching/types" sdk "github.com/cosmos/cosmos-sdk/types" ) @@ -31,6 +32,9 @@ func (h Hooks) BeforeSlashThreshold(ctx context.Context, valSet etypes.Validator func (h Hooks) AfterBlsKeyRegistered(ctx context.Context, valAddr sdk.ValAddress) error { return nil } +func (h Hooks) AfterRawCheckpointSealed(ctx context.Context, epoch uint64) error { + return nil +} func (h Hooks) AfterRawCheckpointConfirmed(ctx context.Context, epoch uint64) error { return nil } diff --git a/x/monitor/keeper/keeper.go b/x/monitor/keeper/keeper.go index 9bd40ab8b..c7ada1120 100644 --- a/x/monitor/keeper/keeper.go +++ b/x/monitor/keeper/keeper.go @@ -5,10 +5,10 @@ import ( corestoretypes "cosmossdk.io/core/store" "fmt" - ckpttypes "github.com/babylonchain/babylon/x/checkpointing/types" + ckpttypes "github.com/babylonlabs-io/babylon/x/checkpointing/types" "cosmossdk.io/log" - "github.com/babylonchain/babylon/x/monitor/types" + "github.com/babylonlabs-io/babylon/x/monitor/types" "github.com/cosmos/cosmos-sdk/codec" sdk "github.com/cosmos/cosmos-sdk/types" ) diff --git a/x/monitor/module.go b/x/monitor/module.go index b4674ff00..40586622e 100644 --- a/x/monitor/module.go +++ b/x/monitor/module.go @@ -12,9 +12,9 @@ import ( abci "github.com/cometbft/cometbft/abci/types" - "github.com/babylonchain/babylon/x/monitor/client/cli" - "github.com/babylonchain/babylon/x/monitor/keeper" - "github.com/babylonchain/babylon/x/monitor/types" + "github.com/babylonlabs-io/babylon/x/monitor/client/cli" + "github.com/babylonlabs-io/babylon/x/monitor/keeper" + "github.com/babylonlabs-io/babylon/x/monitor/types" "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/codec" cdctypes "github.com/cosmos/cosmos-sdk/codec/types" diff --git a/x/monitor/types/expected_keepers.go b/x/monitor/types/expected_keepers.go index 0150c8dc2..d63fffa07 100644 --- a/x/monitor/types/expected_keepers.go +++ b/x/monitor/types/expected_keepers.go @@ -2,7 +2,7 @@ package types import ( "context" - lc "github.com/babylonchain/babylon/x/btclightclient/types" + lc "github.com/babylonlabs-io/babylon/x/btclightclient/types" ) type BTCLightClientKeeper interface { diff --git a/x/monitor/types/genesis.pb.go b/x/monitor/types/genesis.pb.go index 8e2be0c21..2de642697 100644 --- a/x/monitor/types/genesis.pb.go +++ b/x/monitor/types/genesis.pb.go @@ -66,16 +66,17 @@ func init() { func init() { proto.RegisterFile("babylon/monitor/v1/genesis.proto", fileDescriptor_fb844fd916189e7b) } var fileDescriptor_fb844fd916189e7b = []byte{ - // 144 bytes of a gzipped FileDescriptorProto + // 146 bytes of a gzipped FileDescriptorProto 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x52, 0x48, 0x4a, 0x4c, 0xaa, 0xcc, 0xc9, 0xcf, 0xd3, 0xcf, 0xcd, 0xcf, 0xcb, 0x2c, 0xc9, 0x2f, 0xd2, 0x2f, 0x33, 0xd4, 0x4f, 0x4f, 0xcd, 0x4b, 0x2d, 0xce, 0x2c, 0xd6, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0x12, 0x82, 0xaa, 0xd0, 0x83, 0xaa, 0xd0, 0x2b, 0x33, 0x54, 0xe2, 0xe3, 0xe2, 0x71, 0x87, 0x28, 0x0a, 0x2e, 0x49, - 0x2c, 0x49, 0x75, 0xf2, 0x3c, 0xf1, 0x48, 0x8e, 0xf1, 0xc2, 0x23, 0x39, 0xc6, 0x07, 0x8f, 0xe4, - 0x18, 0x27, 0x3c, 0x96, 0x63, 0xb8, 0xf0, 0x58, 0x8e, 0xe1, 0xc6, 0x63, 0x39, 0x86, 0x28, 0xfd, - 0xf4, 0xcc, 0x92, 0x8c, 0xd2, 0x24, 0xbd, 0xe4, 0xfc, 0x5c, 0x7d, 0xa8, 0x41, 0xc9, 0x19, 0x89, - 0x99, 0x79, 0x30, 0x8e, 0x7e, 0x05, 0xdc, 0xe6, 0x92, 0xca, 0x82, 0xd4, 0xe2, 0x24, 0x36, 0xb0, - 0xad, 0xc6, 0x80, 0x00, 0x00, 0x00, 0xff, 0xff, 0xb7, 0x9f, 0x6b, 0xe2, 0x99, 0x00, 0x00, 0x00, + 0x2c, 0x49, 0x75, 0xf2, 0x3e, 0xf1, 0x48, 0x8e, 0xf1, 0xc2, 0x23, 0x39, 0xc6, 0x07, 0x8f, 0xe4, + 0x18, 0x27, 0x3c, 0x96, 0x63, 0xb8, 0xf0, 0x58, 0x8e, 0xe1, 0xc6, 0x63, 0x39, 0x86, 0x28, 0xc3, + 0xf4, 0xcc, 0x92, 0x8c, 0xd2, 0x24, 0xbd, 0xe4, 0xfc, 0x5c, 0x7d, 0xa8, 0x41, 0x39, 0x89, 0x49, + 0xc5, 0xba, 0x99, 0xf9, 0x30, 0xae, 0x7e, 0x05, 0xdc, 0xee, 0x92, 0xca, 0x82, 0xd4, 0xe2, 0x24, + 0x36, 0xb0, 0xbd, 0xc6, 0x80, 0x00, 0x00, 0x00, 0xff, 0xff, 0xcc, 0x4f, 0x6b, 0xc3, 0x9b, 0x00, + 0x00, 0x00, } func (m *GenesisState) Marshal() (dAtA []byte, err error) { diff --git a/x/monitor/types/genesis_test.go b/x/monitor/types/genesis_test.go index 5c5092312..73008eb98 100644 --- a/x/monitor/types/genesis_test.go +++ b/x/monitor/types/genesis_test.go @@ -3,7 +3,7 @@ package types_test import ( "testing" - "github.com/babylonchain/babylon/x/monitor/types" + "github.com/babylonlabs-io/babylon/x/monitor/types" "github.com/stretchr/testify/require" ) diff --git a/x/monitor/types/keys.go b/x/monitor/types/keys.go index 1f65b3c03..ccd101ec8 100644 --- a/x/monitor/types/keys.go +++ b/x/monitor/types/keys.go @@ -2,7 +2,7 @@ package types import ( "fmt" - "github.com/babylonchain/babylon/x/checkpointing/types" + "github.com/babylonlabs-io/babylon/x/checkpointing/types" sdk "github.com/cosmos/cosmos-sdk/types" ) diff --git a/x/monitor/types/query.pb.go b/x/monitor/types/query.pb.go index 210128e1c..321e6d2de 100644 --- a/x/monitor/types/query.pb.go +++ b/x/monitor/types/query.pb.go @@ -229,33 +229,33 @@ func init() { func init() { proto.RegisterFile("babylon/monitor/v1/query.proto", fileDescriptor_a8aafb034c55a8f2) } var fileDescriptor_a8aafb034c55a8f2 = []byte{ - // 404 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xa4, 0x93, 0x4f, 0x8b, 0xd3, 0x40, - 0x18, 0xc6, 0x1b, 0xff, 0xd1, 0xce, 0x71, 0x14, 0x94, 0x56, 0x62, 0xc9, 0x41, 0x0b, 0x62, 0x86, - 0x5a, 0x3d, 0x29, 0x1e, 0x5a, 0x2a, 0x15, 0x44, 0x30, 0x37, 0xbd, 0x84, 0xc9, 0x74, 0xc8, 0x0c, - 0x4d, 0x66, 0xa6, 0x99, 0x49, 0xb1, 0x94, 0x5e, 0x3c, 0x7a, 0x12, 0xfc, 0x22, 0x7e, 0x0c, 0x2f, - 0x42, 0xc1, 0x8b, 0xc7, 0xa5, 0xdd, 0x0f, 0xb2, 0x64, 0x9a, 0xcd, 0x65, 0xd3, 0x2d, 0xbb, 0x7b, - 0xcc, 0xfb, 0xe6, 0xf9, 0xcd, 0xfb, 0xbc, 0xcf, 0x0c, 0x70, 0x23, 0x1c, 0x2d, 0x13, 0x29, 0x50, - 0x2a, 0x05, 0x37, 0x32, 0x43, 0x8b, 0x3e, 0x9a, 0xe7, 0x34, 0x5b, 0xfa, 0x2a, 0x93, 0x46, 0x42, - 0x58, 0xf6, 0xfd, 0xb2, 0xef, 0x2f, 0xfa, 0xed, 0xc7, 0xb1, 0x94, 0x71, 0x42, 0x11, 0x56, 0x1c, - 0x61, 0x21, 0xa4, 0xc1, 0x86, 0x4b, 0xa1, 0xf7, 0x0a, 0xef, 0x1d, 0x78, 0xf2, 0xb9, 0x00, 0x8c, - 0xc5, 0x94, 0x4e, 0xc7, 0x4a, 0x12, 0x36, 0x34, 0x64, 0x42, 0x79, 0xcc, 0x4c, 0x40, 0xe7, 0x39, - 0xd5, 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0xf0, 0x67, 0xeb, 0x3a, 0x9b, 0xad, 0xeb, 0x9c, 0x6c, - 0x5d, 0xe7, 0xe7, 0xce, 0x6d, 0x6c, 0x76, 0x6e, 0xe3, 0xff, 0xce, 0x6d, 0x7c, 0x45, 0x31, 0x37, - 0x2c, 0x8f, 0x7c, 0x22, 0xd3, 0x73, 0x20, 0x61, 0x98, 0x8b, 0x8a, 0xfe, 0xad, 0xe2, 0x9b, 0xa5, - 0xa2, 0x3a, 0xba, 0x67, 0x1f, 0xc9, 0xe0, 0x2c, 0x00, 0x00, 0xff, 0xff, 0xf9, 0x12, 0xa1, 0x9a, - 0x78, 0x03, 0x00, 0x00, + // 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,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, 0x4a, + 0x74, 0x03, 0x7f, 0x39, 0xa0, 0x73, 0xc1, 0x6e, 0xe0, 0xcb, 0xa3, 0x53, 0x9c, 0x4e, 0xa6, 0xfd, + 0xea, 0x6a, 0xe4, 0xd2, 0xca, 0xd0, 0x5a, 0xe9, 0xc3, 0xa7, 0x75, 0x56, 0x48, 0x45, 0xd4, 0x68, + 0x5d, 0xc5, 0xbf, 0x19, 0xbd, 0xfd, 0xb9, 0x73, 0x9d, 0xed, 0xce, 0x75, 0xfe, 0xee, 0x5c, 0xe7, + 0xdb, 0xde, 0x6d, 0x6c, 0xf7, 0x6e, 0xe3, 0xcf, 0xde, 0x6d, 0x7c, 0x1a, 0xc4, 0xdc, 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, } // Reference imports to suppress errors if they are not otherwise used. diff --git a/x/zoneconcierge/README.md b/x/zoneconcierge/README.md index e7040567b..f873f4030 100644 --- a/x/zoneconcierge/README.md +++ b/x/zoneconcierge/README.md @@ -5,7 +5,7 @@ headers from other PoS blockchains. These BTC timestamps allow PoS blockchains integrating with Babylon to achieve Bitcoin security, i.e., forking the PoS blockchain is as hard as forking Bitcoin. The Zone Concierge module leverages the IBC protocol to receive PoS blockchains' headers and provide them with -succint and provable information about their timestamps. +succinct and provable information about their timestamps. There are two phases of integration for a PoS blockchain: @@ -472,7 +472,7 @@ for different use cases, e.g., BTC-assisted unbonding. The phase 2 integration does not require any change to the PoS blockchain's code. Rather, it only needs to deploy a [Babylon -contract](https://github.com/babylonchain/babylon-contract) on the PoS +contract](https://github.com/babylonlabs-io/babylon-contract) on the PoS blockchain, and start an IBC relayer between Babylon and the Babylon contract on the PoS blockchain. The Babylon contract can be deployed to a blockchain supporting [CosmWasm](https://github.com/CosmWasm/cosmwasm) smart contracts, diff --git a/x/zoneconcierge/abci.go b/x/zoneconcierge/abci.go index 7ea1514bb..a0989f678 100644 --- a/x/zoneconcierge/abci.go +++ b/x/zoneconcierge/abci.go @@ -4,8 +4,8 @@ import ( "context" "time" - "github.com/babylonchain/babylon/x/zoneconcierge/keeper" - "github.com/babylonchain/babylon/x/zoneconcierge/types" + "github.com/babylonlabs-io/babylon/x/zoneconcierge/keeper" + "github.com/babylonlabs-io/babylon/x/zoneconcierge/types" abci "github.com/cometbft/cometbft/abci/types" "github.com/cosmos/cosmos-sdk/telemetry" ) diff --git a/x/zoneconcierge/client/cli/query.go b/x/zoneconcierge/client/cli/query.go index 2b0c5ad9c..ca0f1b682 100644 --- a/x/zoneconcierge/client/cli/query.go +++ b/x/zoneconcierge/client/cli/query.go @@ -9,7 +9,7 @@ import ( "github.com/cosmos/cosmos-sdk/client" - "github.com/babylonchain/babylon/x/zoneconcierge/types" + "github.com/babylonlabs-io/babylon/x/zoneconcierge/types" ) // GetQueryCmd returns the cli query commands for this module diff --git a/x/zoneconcierge/client/cli/tx.go b/x/zoneconcierge/client/cli/tx.go index 9ba77b787..23bd93b94 100644 --- a/x/zoneconcierge/client/cli/tx.go +++ b/x/zoneconcierge/client/cli/tx.go @@ -6,7 +6,7 @@ import ( "github.com/cosmos/cosmos-sdk/client" // "github.com/cosmos/cosmos-sdk/client/flags" - "github.com/babylonchain/babylon/x/zoneconcierge/types" + "github.com/babylonlabs-io/babylon/x/zoneconcierge/types" ) // GetTxCmd returns the transaction commands for this module diff --git a/x/zoneconcierge/genesis.go b/x/zoneconcierge/genesis.go index 6cdc963bf..84771473c 100644 --- a/x/zoneconcierge/genesis.go +++ b/x/zoneconcierge/genesis.go @@ -2,8 +2,8 @@ package zoneconcierge import ( "context" - "github.com/babylonchain/babylon/x/zoneconcierge/keeper" - "github.com/babylonchain/babylon/x/zoneconcierge/types" + "github.com/babylonlabs-io/babylon/x/zoneconcierge/keeper" + "github.com/babylonlabs-io/babylon/x/zoneconcierge/types" sdk "github.com/cosmos/cosmos-sdk/types" ) diff --git a/x/zoneconcierge/genesis_test.go b/x/zoneconcierge/genesis_test.go index 59ae3107d..e4b3181e9 100644 --- a/x/zoneconcierge/genesis_test.go +++ b/x/zoneconcierge/genesis_test.go @@ -3,10 +3,10 @@ package zoneconcierge_test import ( "testing" - keepertest "github.com/babylonchain/babylon/testutil/keeper" - "github.com/babylonchain/babylon/testutil/nullify" - "github.com/babylonchain/babylon/x/zoneconcierge" - "github.com/babylonchain/babylon/x/zoneconcierge/types" + keepertest "github.com/babylonlabs-io/babylon/testutil/keeper" + "github.com/babylonlabs-io/babylon/testutil/nullify" + "github.com/babylonlabs-io/babylon/x/zoneconcierge" + "github.com/babylonlabs-io/babylon/x/zoneconcierge/types" "github.com/stretchr/testify/require" ) diff --git a/x/zoneconcierge/keeper/canonical_chain_indexer.go b/x/zoneconcierge/keeper/canonical_chain_indexer.go index 2348ba387..52d89b965 100644 --- a/x/zoneconcierge/keeper/canonical_chain_indexer.go +++ b/x/zoneconcierge/keeper/canonical_chain_indexer.go @@ -7,7 +7,7 @@ import ( sdkerrors "cosmossdk.io/errors" "cosmossdk.io/store/prefix" - "github.com/babylonchain/babylon/x/zoneconcierge/types" + "github.com/babylonlabs-io/babylon/x/zoneconcierge/types" sdk "github.com/cosmos/cosmos-sdk/types" ) diff --git a/x/zoneconcierge/keeper/canonical_chain_indexer_test.go b/x/zoneconcierge/keeper/canonical_chain_indexer_test.go index 1b1f929ff..af484b32c 100644 --- a/x/zoneconcierge/keeper/canonical_chain_indexer_test.go +++ b/x/zoneconcierge/keeper/canonical_chain_indexer_test.go @@ -4,8 +4,8 @@ import ( "math/rand" "testing" - "github.com/babylonchain/babylon/app" - "github.com/babylonchain/babylon/testutil/datagen" + "github.com/babylonlabs-io/babylon/app" + "github.com/babylonlabs-io/babylon/testutil/datagen" "github.com/stretchr/testify/require" ) diff --git a/x/zoneconcierge/keeper/chain_info_indexer.go b/x/zoneconcierge/keeper/chain_info_indexer.go index e7e7d06bd..a3ae402d1 100644 --- a/x/zoneconcierge/keeper/chain_info_indexer.go +++ b/x/zoneconcierge/keeper/chain_info_indexer.go @@ -7,7 +7,7 @@ import ( errorsmod "cosmossdk.io/errors" "cosmossdk.io/store/prefix" - "github.com/babylonchain/babylon/x/zoneconcierge/types" + "github.com/babylonlabs-io/babylon/x/zoneconcierge/types" ) func (k Keeper) setChainInfo(ctx context.Context, chainInfo *types.ChainInfo) { diff --git a/x/zoneconcierge/keeper/epoch_chain_info_indexer.go b/x/zoneconcierge/keeper/epoch_chain_info_indexer.go index b5d1e9496..5584b008e 100644 --- a/x/zoneconcierge/keeper/epoch_chain_info_indexer.go +++ b/x/zoneconcierge/keeper/epoch_chain_info_indexer.go @@ -2,16 +2,18 @@ package keeper import ( "context" + "fmt" + "cosmossdk.io/store/prefix" "github.com/cosmos/cosmos-sdk/runtime" sdk "github.com/cosmos/cosmos-sdk/types" - bbn "github.com/babylonchain/babylon/types" - "github.com/babylonchain/babylon/x/zoneconcierge/types" + bbn "github.com/babylonlabs-io/babylon/types" + "github.com/babylonlabs-io/babylon/x/zoneconcierge/types" ) // GetEpochChainInfo gets the latest chain info of a given epoch for a given chain ID -func (k Keeper) GetEpochChainInfo(ctx context.Context, chainID string, epochNumber uint64) (*types.ChainInfo, error) { +func (k Keeper) GetEpochChainInfo(ctx context.Context, chainID string, epochNumber uint64) (*types.ChainInfoWithProof, error) { if !k.EpochChainInfoExists(ctx, chainID, epochNumber) { return nil, types.ErrEpochChainInfoNotFound } @@ -19,11 +21,16 @@ func (k Keeper) GetEpochChainInfo(ctx context.Context, chainID string, epochNumb store := k.epochChainInfoStore(ctx, chainID) epochNumberBytes := sdk.Uint64ToBigEndian(epochNumber) epochChainInfoBytes := store.Get(epochNumberBytes) - var chainInfo types.ChainInfo + var chainInfo types.ChainInfoWithProof k.cdc.MustUnmarshal(epochChainInfoBytes, &chainInfo) return &chainInfo, nil } +func (k Keeper) setEpochChainInfo(ctx context.Context, chainID string, epochNumber uint64, chainInfo *types.ChainInfoWithProof) { + store := k.epochChainInfoStore(ctx, chainID) + store.Set(sdk.Uint64ToBigEndian(epochNumber), k.cdc.MustMarshal(chainInfo)) +} + // EpochChainInfoExists checks if the latest chain info exists of a given epoch for a given chain ID func (k Keeper) EpochChainInfoExists(ctx context.Context, chainID string, epochNumber uint64) bool { store := k.epochChainInfoStore(ctx, chainID) @@ -36,10 +43,11 @@ func (k Keeper) GetEpochHeaders(ctx context.Context, chainID string, epochNumber headers := []*types.IndexedHeader{} // find the last timestamped header of this chain in the epoch - epochChainInfo, err := k.GetEpochChainInfo(ctx, chainID, epochNumber) + epochChainInfoWithProof, err := k.GetEpochChainInfo(ctx, chainID, epochNumber) if err != nil { return nil, err } + epochChainInfo := epochChainInfoWithProof.ChainInfo // it's possible that this epoch's snapshot is not updated for many epochs // this implies that this epoch does not timestamp any header for this chain at all if epochChainInfo.LatestHeader.BabylonEpoch < epochNumber { @@ -79,15 +87,50 @@ func (k Keeper) recordEpochChainInfo(ctx context.Context, chainID string, epochN k.Logger(sdk.UnwrapSDKContext(ctx)).Debug("chain info does not exist yet, nothing to record") return } + chainInfoWithProof := &types.ChainInfoWithProof{ + ChainInfo: chainInfo, + ProofHeaderInEpoch: nil, + } + // NOTE: we can record epoch chain info without ancestor since IBC connection can be established at any height - store := k.epochChainInfoStore(ctx, chainID) - store.Set(sdk.Uint64ToBigEndian(epochNumber), k.cdc.MustMarshal(chainInfo)) + k.setEpochChainInfo(ctx, chainID, epochNumber, chainInfoWithProof) +} + +// recordEpochChainInfo records the chain info for a given epoch number of given chain ID +// where the latest chain info is retrieved from the chain info indexer +func (k Keeper) recordEpochChainInfoProofs(ctx context.Context, epochNumber uint64) { + curEpoch := k.GetEpoch(ctx) + chainIDs := k.GetAllChainIDs(ctx) + + // save all inclusion proofs + for _, chainID := range chainIDs { + // retrieve chain info with empty proof + chainInfo, err := k.GetEpochChainInfo(ctx, chainID, epochNumber) + if err != nil { + panic(err) // only programming error + } + + lastHeaderInEpoch := chainInfo.ChainInfo.LatestHeader + if lastHeaderInEpoch.BabylonEpoch == curEpoch.EpochNumber { + // get proofCZHeaderInEpoch + proofCZHeaderInEpoch, err := k.ProveCZHeaderInEpoch(ctx, lastHeaderInEpoch, curEpoch) + if err != nil { + // only programming error is possible here + panic(fmt.Errorf("failed to generate proofCZHeaderInEpoch for chain %s: %w", chainID, err)) + } + + chainInfo.ProofHeaderInEpoch = proofCZHeaderInEpoch + + // set chain info with proof back + k.setEpochChainInfo(ctx, chainID, epochNumber, chainInfo) + } + } } // epochChainInfoStore stores each epoch's latest ChainInfo for a CZ // prefix: EpochChainInfoKey || chainID // key: epochNumber -// value: ChainInfo +// value: ChainInfoWithProof func (k Keeper) epochChainInfoStore(ctx context.Context, chainID string) prefix.Store { storeAdapter := runtime.KVStoreAdapter(k.storeService.OpenKVStore(ctx)) epochChainInfoStore := prefix.NewStore(storeAdapter, types.EpochChainInfoKey) diff --git a/x/zoneconcierge/keeper/epoch_chain_info_indexer_test.go b/x/zoneconcierge/keeper/epoch_chain_info_indexer_test.go index cf22dd09e..59dc52c50 100644 --- a/x/zoneconcierge/keeper/epoch_chain_info_indexer_test.go +++ b/x/zoneconcierge/keeper/epoch_chain_info_indexer_test.go @@ -7,8 +7,8 @@ import ( ibctmtypes "github.com/cosmos/ibc-go/v8/modules/light-clients/07-tendermint" "github.com/stretchr/testify/require" - "github.com/babylonchain/babylon/app" - "github.com/babylonchain/babylon/testutil/datagen" + "github.com/babylonlabs-io/babylon/app" + "github.com/babylonlabs-io/babylon/testutil/datagen" ) func FuzzEpochChainInfoIndexer(f *testing.F) { @@ -39,7 +39,8 @@ func FuzzEpochChainInfoIndexer(f *testing.F) { hooks.AfterEpochEnds(ctx, epochNum) // check if the chain info of this epoch is recorded or not - chainInfo, err := zcKeeper.GetEpochChainInfo(ctx, czChainID, epochNum) + chainInfoWithProof, err := zcKeeper.GetEpochChainInfo(ctx, czChainID, epochNum) + chainInfo := chainInfoWithProof.ChainInfo require.NoError(t, err) require.Equal(t, numHeaders-1, chainInfo.LatestHeader.Height) require.Equal(t, numHeaders, chainInfo.TimestampedHeadersCount) diff --git a/x/zoneconcierge/keeper/epochs.go b/x/zoneconcierge/keeper/epochs.go index ad0a478d0..6c3bfac89 100644 --- a/x/zoneconcierge/keeper/epochs.go +++ b/x/zoneconcierge/keeper/epochs.go @@ -3,8 +3,10 @@ package keeper import ( "context" - epochingtypes "github.com/babylonchain/babylon/x/epoching/types" - "github.com/babylonchain/babylon/x/zoneconcierge/types" + "cosmossdk.io/store/prefix" + epochingtypes "github.com/babylonlabs-io/babylon/x/epoching/types" + "github.com/babylonlabs-io/babylon/x/zoneconcierge/types" + "github.com/cosmos/cosmos-sdk/runtime" sdk "github.com/cosmos/cosmos-sdk/types" ) @@ -37,34 +39,41 @@ func (k Keeper) setLastSentSegment(ctx context.Context, segment *types.BTCChainS } } -// GetFinalizedEpoch gets the last finalised epoch -// used upon querying the last BTC-finalised chain info for CZs -func (k Keeper) GetFinalizedEpoch(ctx context.Context) (uint64, error) { - store := k.storeService.OpenKVStore(ctx) - has, err := store.Has(types.FinalizedEpochKey) - if err != nil { - panic(err) - } - if !has { - return 0, types.ErrFinalizedEpochNotFound - } - epochNumberBytes, err := store.Get(types.FinalizedEpochKey) +func (k Keeper) GetLastFinalizedEpoch(ctx context.Context) uint64 { + return k.checkpointingKeeper.GetLastFinalizedEpoch(ctx) +} + +func (k Keeper) GetEpoch(ctx context.Context) *epochingtypes.Epoch { + return k.epochingKeeper.GetEpoch(ctx) +} + +func (k Keeper) recordSealedEpochProof(ctx context.Context, epochNum uint64) { + // proof that the epoch is sealed + proofEpochSealed, err := k.ProveEpochSealed(ctx, epochNum) if err != nil { - panic(err) + panic(err) // only programming error } - return sdk.BigEndianToUint64(epochNumberBytes), nil + + store := k.sealedEpochProofStore(ctx) + store.Set(sdk.Uint64ToBigEndian(epochNum), k.cdc.MustMarshal(proofEpochSealed)) } -// setFinalizedEpoch sets the last finalised epoch -// called upon each AfterRawCheckpointFinalized hook invocation -func (k Keeper) setFinalizedEpoch(ctx context.Context, epochNumber uint64) { - store := k.storeService.OpenKVStore(ctx) - epochNumberBytes := sdk.Uint64ToBigEndian(epochNumber) - if err := store.Set(types.FinalizedEpochKey, epochNumberBytes); err != nil { - panic(err) +func (k Keeper) getSealedEpochProof(ctx context.Context, epochNum uint64) *types.ProofEpochSealed { + store := k.sealedEpochProofStore(ctx) + proofBytes := store.Get(sdk.Uint64ToBigEndian(epochNum)) + if len(proofBytes) == 0 { + return nil } + var proof types.ProofEpochSealed + k.cdc.MustUnmarshal(proofBytes, &proof) + return &proof } -func (k Keeper) GetEpoch(ctx context.Context) *epochingtypes.Epoch { - return k.epochingKeeper.GetEpoch(ctx) +// sealedEpochProofStore stores the proof that each epoch is sealed +// prefix: SealedEpochProofKey +// key: epochNumber +// value: ChainInfoWithProof +func (k Keeper) sealedEpochProofStore(ctx context.Context) prefix.Store { + storeAdapter := runtime.KVStoreAdapter(k.storeService.OpenKVStore(ctx)) + return prefix.NewStore(storeAdapter, types.SealedEpochProofKey) } diff --git a/x/zoneconcierge/keeper/fork_indexer.go b/x/zoneconcierge/keeper/fork_indexer.go index 2ec7e6ba3..68d98243f 100644 --- a/x/zoneconcierge/keeper/fork_indexer.go +++ b/x/zoneconcierge/keeper/fork_indexer.go @@ -7,7 +7,7 @@ import ( sdkerrors "cosmossdk.io/errors" "cosmossdk.io/store/prefix" - "github.com/babylonchain/babylon/x/zoneconcierge/types" + "github.com/babylonlabs-io/babylon/x/zoneconcierge/types" sdk "github.com/cosmos/cosmos-sdk/types" ) diff --git a/x/zoneconcierge/keeper/fork_indexer_test.go b/x/zoneconcierge/keeper/fork_indexer_test.go index 8195f6b01..c1ef1a522 100644 --- a/x/zoneconcierge/keeper/fork_indexer_test.go +++ b/x/zoneconcierge/keeper/fork_indexer_test.go @@ -4,8 +4,8 @@ import ( "math/rand" "testing" - "github.com/babylonchain/babylon/app" - "github.com/babylonchain/babylon/testutil/datagen" + "github.com/babylonlabs-io/babylon/app" + "github.com/babylonlabs-io/babylon/testutil/datagen" "github.com/stretchr/testify/require" ) diff --git a/x/zoneconcierge/keeper/grpc_query.go b/x/zoneconcierge/keeper/grpc_query.go index 657915801..5cb71dfca 100644 --- a/x/zoneconcierge/keeper/grpc_query.go +++ b/x/zoneconcierge/keeper/grpc_query.go @@ -3,8 +3,8 @@ package keeper import ( "context" - bbntypes "github.com/babylonchain/babylon/types" - "github.com/babylonchain/babylon/x/zoneconcierge/types" + bbntypes "github.com/babylonlabs-io/babylon/types" + "github.com/babylonlabs-io/babylon/x/zoneconcierge/types" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/query" "google.golang.org/grpc/codes" @@ -146,12 +146,12 @@ func (k Keeper) EpochChainsInfo(c context.Context, req *types.QueryEpochChainsIn } // find the chain info of the given epoch - chainInfo, err := k.GetEpochChainInfo(ctx, chainID, req.EpochNum) + chainInfoWithProof, err := k.GetEpochChainInfo(ctx, chainID, req.EpochNum) if err != nil { return nil, err } - chainsInfo = append(chainsInfo, chainInfo) + chainsInfo = append(chainsInfo, chainInfoWithProof.ChainInfo) } resp := &types.QueryEpochChainsInfoResponse{ChainsInfo: chainsInfo} @@ -238,11 +238,7 @@ func (k Keeper) FinalizedChainsInfo(c context.Context, req *types.QueryFinalized resp := &types.QueryFinalizedChainsInfoResponse{FinalizedChainsInfo: []*types.FinalizedChainInfo{}} // find the last finalised epoch - lastFinalizedEpoch, err := k.GetFinalizedEpoch(ctx) - if err != nil { - return nil, err - } - + lastFinalizedEpoch := k.GetLastFinalizedEpoch(ctx) for _, chainID := range req.ChainIds { // check if chain ID is valid if !k.HasChainInfo(ctx, chainID) { @@ -258,10 +254,11 @@ func (k Keeper) FinalizedChainsInfo(c context.Context, req *types.QueryFinalized } // find the chain info in the last finalised epoch - chainInfo, err := k.GetEpochChainInfo(ctx, chainID, lastFinalizedEpoch) + chainInfoWithProof, err := k.GetEpochChainInfo(ctx, chainID, lastFinalizedEpoch) if err != nil { return nil, err } + chainInfo := chainInfoWithProof.ChainInfo // set finalizedEpoch as the earliest epoch that snapshots this chain info. // it's possible that the chain info's epoch is way before the last finalised epoch @@ -320,16 +317,13 @@ func (k Keeper) FinalizedChainInfoUntilHeight(c context.Context, req *types.Quer resp := &types.QueryFinalizedChainInfoUntilHeightResponse{} // find the last finalised epoch - lastFinalizedEpoch, err := k.GetFinalizedEpoch(ctx) - if err != nil { - return nil, err - } - + lastFinalizedEpoch := k.GetLastFinalizedEpoch(ctx) // find the chain info in the last finalised epoch - chainInfo, err := k.GetEpochChainInfo(ctx, req.ChainId, lastFinalizedEpoch) + chainInfoWithProof, err := k.GetEpochChainInfo(ctx, req.ChainId, lastFinalizedEpoch) if err != nil { return nil, err } + chainInfo := chainInfoWithProof.ChainInfo // set finalizedEpoch as the earliest epoch that snapshots this chain info. // it's possible that the chain info's epoch is way before the last finalised epoch @@ -370,11 +364,11 @@ func (k Keeper) FinalizedChainInfoUntilHeight(c context.Context, req *types.Quer } // assign the finalizedEpoch, and retrieve epoch info, raw ckpt and submission key finalizedEpoch = closestHeader.BabylonEpoch - chainInfo, err = k.GetEpochChainInfo(ctx, req.ChainId, finalizedEpoch) + chainInfoWithProof, err := k.GetEpochChainInfo(ctx, req.ChainId, finalizedEpoch) if err != nil { return nil, err } - resp.FinalizedChainInfo = chainInfo + resp.FinalizedChainInfo = chainInfoWithProof.ChainInfo resp.EpochInfo, err = k.epochingKeeper.GetHistoricalEpoch(ctx, finalizedEpoch) if err != nil { return nil, err diff --git a/x/zoneconcierge/keeper/grpc_query_test.go b/x/zoneconcierge/keeper/grpc_query_test.go index ba6dbf6e5..4885659e9 100644 --- a/x/zoneconcierge/keeper/grpc_query_test.go +++ b/x/zoneconcierge/keeper/grpc_query_test.go @@ -4,18 +4,18 @@ import ( "math/rand" "testing" - "github.com/babylonchain/babylon/app" - btclightclienttypes "github.com/babylonchain/babylon/x/btclightclient/types" + "github.com/babylonlabs-io/babylon/app" + btclightclienttypes "github.com/babylonlabs-io/babylon/x/btclightclient/types" "github.com/cosmos/cosmos-sdk/types/query" ibctmtypes "github.com/cosmos/ibc-go/v8/modules/light-clients/07-tendermint" "github.com/golang/mock/gomock" "github.com/stretchr/testify/require" - "github.com/babylonchain/babylon/testutil/datagen" - testkeeper "github.com/babylonchain/babylon/testutil/keeper" - btcctypes "github.com/babylonchain/babylon/x/btccheckpoint/types" - checkpointingtypes "github.com/babylonchain/babylon/x/checkpointing/types" - zctypes "github.com/babylonchain/babylon/x/zoneconcierge/types" + "github.com/babylonlabs-io/babylon/testutil/datagen" + testkeeper "github.com/babylonlabs-io/babylon/testutil/keeper" + btcctypes "github.com/babylonlabs-io/babylon/x/btccheckpoint/types" + checkpointingtypes "github.com/babylonlabs-io/babylon/x/checkpointing/types" + zctypes "github.com/babylonlabs-io/babylon/x/zoneconcierge/types" ) type chainInfo struct { @@ -424,6 +424,7 @@ func FuzzFinalizedChainInfo(f *testing.F) { hooks.AfterEpochEnds(ctx, epoch.EpochNumber) err := hooks.AfterRawCheckpointFinalized(ctx, epoch.EpochNumber) require.NoError(t, err) + checkpointingKeeper.EXPECT().GetLastFinalizedEpoch(gomock.Any()).Return(epoch.EpochNumber).AnyTimes() // check if the chain info of this epoch is recorded or not resp, err := zcKeeper.FinalizedChainsInfo(ctx, &zctypes.QueryFinalizedChainsInfoRequest{ChainIds: chainIDs, Prove: true}) diff --git a/x/zoneconcierge/keeper/header_handler.go b/x/zoneconcierge/keeper/header_handler.go index 3bfdd046e..e4bfa635d 100644 --- a/x/zoneconcierge/keeper/header_handler.go +++ b/x/zoneconcierge/keeper/header_handler.go @@ -6,7 +6,7 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/babylonchain/babylon/x/zoneconcierge/types" + "github.com/babylonlabs-io/babylon/x/zoneconcierge/types" ) // HandleHeaderWithValidCommit handles a CZ header with a valid QC diff --git a/x/zoneconcierge/keeper/hooks.go b/x/zoneconcierge/keeper/hooks.go index f48a82c96..8621183dc 100644 --- a/x/zoneconcierge/keeper/hooks.go +++ b/x/zoneconcierge/keeper/hooks.go @@ -5,9 +5,9 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" - checkpointingtypes "github.com/babylonchain/babylon/x/checkpointing/types" - epochingtypes "github.com/babylonchain/babylon/x/epoching/types" - "github.com/babylonchain/babylon/x/zoneconcierge/types" + checkpointingtypes "github.com/babylonlabs-io/babylon/x/checkpointing/types" + epochingtypes "github.com/babylonlabs-io/babylon/x/epoching/types" + "github.com/babylonlabs-io/babylon/x/zoneconcierge/types" ) type Hooks struct { @@ -20,26 +20,28 @@ var _ epochingtypes.EpochingHooks = Hooks{} func (k Keeper) Hooks() Hooks { return Hooks{k} } -// AfterEpochEnds is triggered upon an epoch has ended func (h Hooks) AfterEpochEnds(ctx context.Context, epoch uint64) { // upon an epoch has ended, index the current chain info for each CZ + // TODO: do this together when epoch is sealed? for _, chainID := range h.k.GetAllChainIDs(ctx) { h.k.recordEpochChainInfo(ctx, chainID, epoch) } } +func (h Hooks) AfterRawCheckpointSealed(ctx context.Context, epoch uint64) error { + // upon a raw checkpoint is sealed, index the current chain info for each consumer, + // and generate/save the proof that the epoch is sealed + h.k.recordEpochChainInfoProofs(ctx, epoch) + h.k.recordSealedEpochProof(ctx, epoch) + return nil +} + // AfterRawCheckpointFinalized is triggered upon an epoch has been finalised func (h Hooks) AfterRawCheckpointFinalized(ctx context.Context, epoch uint64) error { - // upon an epoch has been finalised, update the last finalised epoch - h.k.setFinalizedEpoch(ctx, epoch) - headersToBroadcast := h.k.getHeadersToBroadcast(ctx) // send BTC timestamp to all open channels with ZoneConcierge - // TODO: BroadcastBTCTimestamps is non-deterministic due to generating proofs - // which are affected by pruning. Re-enable after improving BroadcastBTCTimestamps - // methods - // h.k.BroadcastBTCTimestamps(ctx, epoch, headersToBroadcast) + h.k.BroadcastBTCTimestamps(ctx, epoch, headersToBroadcast) // Update the last broadcasted segment h.k.setLastSentSegment(ctx, &types.BTCChainSegment{ @@ -52,12 +54,12 @@ func (h Hooks) AfterRawCheckpointFinalized(ctx context.Context, epoch uint64) er func (h Hooks) AfterBlsKeyRegistered(ctx context.Context, valAddr sdk.ValAddress) error { return nil } func (h Hooks) AfterRawCheckpointConfirmed(ctx context.Context, epoch uint64) error { return nil } - func (h Hooks) AfterRawCheckpointForgotten(ctx context.Context, ckpt *checkpointingtypes.RawCheckpoint) error { return nil } func (h Hooks) AfterRawCheckpointBlsSigVerified(ctx context.Context, ckpt *checkpointingtypes.RawCheckpoint) error { return nil } + func (h Hooks) AfterEpochBegins(ctx context.Context, epoch uint64) {} func (h Hooks) BeforeSlashThreshold(ctx context.Context, valSet epochingtypes.ValidatorSet) {} diff --git a/x/zoneconcierge/keeper/ibc_header_decorator.go b/x/zoneconcierge/keeper/ibc_header_decorator.go index 1e8967be2..930f33e6e 100644 --- a/x/zoneconcierge/keeper/ibc_header_decorator.go +++ b/x/zoneconcierge/keeper/ibc_header_decorator.go @@ -6,7 +6,7 @@ import ( clienttypes "github.com/cosmos/ibc-go/v8/modules/core/02-client/types" //nolint:staticcheck ibctmtypes "github.com/cosmos/ibc-go/v8/modules/light-clients/07-tendermint" - "github.com/babylonchain/babylon/x/zoneconcierge/types" + "github.com/babylonlabs-io/babylon/x/zoneconcierge/types" ) var _ sdk.PostDecorator = &IBCHeaderDecorator{} diff --git a/x/zoneconcierge/keeper/ibc_packet.go b/x/zoneconcierge/keeper/ibc_packet.go index 266e8fd35..c4f6bbc03 100644 --- a/x/zoneconcierge/keeper/ibc_packet.go +++ b/x/zoneconcierge/keeper/ibc_packet.go @@ -8,7 +8,7 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" errorsmod "cosmossdk.io/errors" - "github.com/babylonchain/babylon/x/zoneconcierge/types" + "github.com/babylonlabs-io/babylon/x/zoneconcierge/types" "github.com/cosmos/cosmos-sdk/telemetry" clienttypes "github.com/cosmos/ibc-go/v8/modules/core/02-client/types" //nolint:staticcheck channeltypes "github.com/cosmos/ibc-go/v8/modules/core/04-channel/types" diff --git a/x/zoneconcierge/keeper/ibc_packet_btc_timestamp.go b/x/zoneconcierge/keeper/ibc_packet_btc_timestamp.go index 219025023..7df7c61ad 100644 --- a/x/zoneconcierge/keeper/ibc_packet_btc_timestamp.go +++ b/x/zoneconcierge/keeper/ibc_packet_btc_timestamp.go @@ -8,12 +8,12 @@ import ( channeltypes "github.com/cosmos/ibc-go/v8/modules/core/04-channel/types" ibctmtypes "github.com/cosmos/ibc-go/v8/modules/light-clients/07-tendermint" - bbn "github.com/babylonchain/babylon/types" - btcctypes "github.com/babylonchain/babylon/x/btccheckpoint/types" - btclctypes "github.com/babylonchain/babylon/x/btclightclient/types" - checkpointingtypes "github.com/babylonchain/babylon/x/checkpointing/types" - epochingtypes "github.com/babylonchain/babylon/x/epoching/types" - "github.com/babylonchain/babylon/x/zoneconcierge/types" + 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" + checkpointingtypes "github.com/babylonlabs-io/babylon/x/checkpointing/types" + epochingtypes "github.com/babylonlabs-io/babylon/x/epoching/types" + "github.com/babylonlabs-io/babylon/x/zoneconcierge/types" ) // finalizedInfo is a private struct that stores metadata and proofs @@ -48,12 +48,19 @@ func (k Keeper) getChainID(ctx context.Context, channel channeltypes.IdentifiedC func (k Keeper) getFinalizedInfo( ctx context.Context, epochNum uint64, - headersToBroadcast []*btclctypes.BTCHeaderInfo) (*finalizedInfo, error) { + headersToBroadcast []*btclctypes.BTCHeaderInfo, +) (*finalizedInfo, error) { finalizedEpochInfo, err := k.epochingKeeper.GetHistoricalEpoch(ctx, epochNum) if err != nil { return nil, err } + // get proof that the epoch is sealed + proofEpochSealed := k.getSealedEpochProof(ctx, epochNum) + if proofEpochSealed == nil { + panic(err) // only programming error + } + // assign raw checkpoint rawCheckpoint, err := k.checkpointingKeeper.GetRawCheckpoint(ctx, epochNum) if err != nil { @@ -68,12 +75,6 @@ func (k Keeper) getFinalizedInfo( } btcSubmissionKey := &bestSubmissionBtcInfo.SubmissionKey - // proof that the epoch is sealed - proofEpochSealed, err := k.ProveEpochSealed(ctx, epochNum) - if err != nil { - return nil, err - } - // proof that the epoch's checkpoint is submitted to BTC // i.e., the two `TransactionInfo`s for the checkpoint proofEpochSubmitted, err := k.ProveEpochSubmitted(ctx, btcSubmissionKey) @@ -122,9 +123,9 @@ func (k Keeper) createBTCTimestamp( // NOTE: it's possible that this chain does not have chain info at the moment // In this case, skip sending BTC timestamp for this chain at this epoch epochNum := finalizedInfo.EpochInfo.EpochNumber - finalizedChainInfo, err := k.GetEpochChainInfo(ctx, chainID, epochNum) + epochChainInfo, err := k.GetEpochChainInfo(ctx, chainID, epochNum) if err != nil { - return nil, fmt.Errorf("no finalizedChainInfo for chain %s at epoch %d", chainID, epochNum) + return nil, fmt.Errorf("no epochChainInfo for chain %s at epoch %d", chainID, epochNum) } // construct BTC timestamp from everything @@ -144,15 +145,10 @@ func (k Keeper) createBTCTimestamp( // if there is a CZ header checkpointed in this finalised epoch, // add this CZ header and corresponding proofs to the BTC timestamp - if finalizedChainInfo.LatestHeader.BabylonEpoch == epochNum { - // get proofCZHeaderInEpoch - proofCZHeaderInEpoch, err := k.ProveCZHeaderInEpoch(ctx, finalizedChainInfo.LatestHeader, finalizedInfo.EpochInfo) - if err != nil { - return nil, fmt.Errorf("failed to generate proofCZHeaderInEpoch for chain %s: %w", chainID, err) - } - - btcTimestamp.Header = finalizedChainInfo.LatestHeader - btcTimestamp.Proof.ProofCzHeaderInEpoch = proofCZHeaderInEpoch + epochOfHeader := epochChainInfo.ChainInfo.LatestHeader.BabylonEpoch + if epochOfHeader == epochNum { + btcTimestamp.Header = epochChainInfo.ChainInfo.LatestHeader + btcTimestamp.Proof.ProofCzHeaderInEpoch = epochChainInfo.ProofHeaderInEpoch } return btcTimestamp, nil diff --git a/x/zoneconcierge/keeper/ibc_packet_btc_timestamp_test.go b/x/zoneconcierge/keeper/ibc_packet_btc_timestamp_test.go index 531657d26..7a2d1a7c6 100644 --- a/x/zoneconcierge/keeper/ibc_packet_btc_timestamp_test.go +++ b/x/zoneconcierge/keeper/ibc_packet_btc_timestamp_test.go @@ -5,10 +5,10 @@ import ( "math/rand" "testing" - "github.com/babylonchain/babylon/app" - "github.com/babylonchain/babylon/testutil/datagen" - btclckeeper "github.com/babylonchain/babylon/x/btclightclient/keeper" - btclctypes "github.com/babylonchain/babylon/x/btclightclient/types" + "github.com/babylonlabs-io/babylon/app" + "github.com/babylonlabs-io/babylon/testutil/datagen" + btclckeeper "github.com/babylonlabs-io/babylon/x/btclightclient/keeper" + btclctypes "github.com/babylonlabs-io/babylon/x/btclightclient/types" "github.com/stretchr/testify/require" ) diff --git a/x/zoneconcierge/keeper/keeper.go b/x/zoneconcierge/keeper/keeper.go index b34290f6e..82fee2b40 100644 --- a/x/zoneconcierge/keeper/keeper.go +++ b/x/zoneconcierge/keeper/keeper.go @@ -6,7 +6,7 @@ import ( corestoretypes "cosmossdk.io/core/store" "cosmossdk.io/log" storetypes "cosmossdk.io/store/types" - "github.com/babylonchain/babylon/x/zoneconcierge/types" + "github.com/babylonlabs-io/babylon/x/zoneconcierge/types" "github.com/cosmos/cosmos-sdk/codec" sdk "github.com/cosmos/cosmos-sdk/types" capabilitytypes "github.com/cosmos/ibc-go/modules/capability/types" diff --git a/x/zoneconcierge/keeper/keeper_test.go b/x/zoneconcierge/keeper/keeper_test.go index 51b04f56d..1d5392735 100644 --- a/x/zoneconcierge/keeper/keeper_test.go +++ b/x/zoneconcierge/keeper/keeper_test.go @@ -6,8 +6,8 @@ import ( ibctmtypes "github.com/cosmos/ibc-go/v8/modules/light-clients/07-tendermint" - "github.com/babylonchain/babylon/testutil/datagen" - zckeeper "github.com/babylonchain/babylon/x/zoneconcierge/keeper" + "github.com/babylonlabs-io/babylon/testutil/datagen" + zckeeper "github.com/babylonlabs-io/babylon/x/zoneconcierge/keeper" ) // SimulateNewHeaders generates a non-zero number of canonical headers diff --git a/x/zoneconcierge/keeper/msg_server.go b/x/zoneconcierge/keeper/msg_server.go index dee48dd04..26d5e9c96 100644 --- a/x/zoneconcierge/keeper/msg_server.go +++ b/x/zoneconcierge/keeper/msg_server.go @@ -4,7 +4,7 @@ import ( "context" errorsmod "cosmossdk.io/errors" - "github.com/babylonchain/babylon/x/zoneconcierge/types" + "github.com/babylonlabs-io/babylon/x/zoneconcierge/types" sdk "github.com/cosmos/cosmos-sdk/types" govtypes "github.com/cosmos/cosmos-sdk/x/gov/types" ) diff --git a/x/zoneconcierge/keeper/params.go b/x/zoneconcierge/keeper/params.go index 04989eea9..f9661e57d 100644 --- a/x/zoneconcierge/keeper/params.go +++ b/x/zoneconcierge/keeper/params.go @@ -2,7 +2,7 @@ package keeper import ( "context" - "github.com/babylonchain/babylon/x/zoneconcierge/types" + "github.com/babylonlabs-io/babylon/x/zoneconcierge/types" ) // SetParams sets the x/zoneconcierge module parameters. diff --git a/x/zoneconcierge/keeper/params_test.go b/x/zoneconcierge/keeper/params_test.go index b8f8f772d..a35f8116f 100644 --- a/x/zoneconcierge/keeper/params_test.go +++ b/x/zoneconcierge/keeper/params_test.go @@ -3,8 +3,8 @@ package keeper_test import ( "testing" - testkeeper "github.com/babylonchain/babylon/testutil/keeper" - "github.com/babylonchain/babylon/x/zoneconcierge/types" + testkeeper "github.com/babylonlabs-io/babylon/testutil/keeper" + "github.com/babylonlabs-io/babylon/x/zoneconcierge/types" "github.com/stretchr/testify/require" ) diff --git a/x/zoneconcierge/keeper/proof_btc_timestamp.go b/x/zoneconcierge/keeper/proof_btc_timestamp.go index 8f6b52368..248fe6b1a 100644 --- a/x/zoneconcierge/keeper/proof_btc_timestamp.go +++ b/x/zoneconcierge/keeper/proof_btc_timestamp.go @@ -6,10 +6,10 @@ import ( cmtcrypto "github.com/cometbft/cometbft/proto/tendermint/crypto" - btcctypes "github.com/babylonchain/babylon/x/btccheckpoint/types" - checkpointingtypes "github.com/babylonchain/babylon/x/checkpointing/types" - epochingtypes "github.com/babylonchain/babylon/x/epoching/types" - "github.com/babylonchain/babylon/x/zoneconcierge/types" + btcctypes "github.com/babylonlabs-io/babylon/x/btccheckpoint/types" + checkpointingtypes "github.com/babylonlabs-io/babylon/x/checkpointing/types" + epochingtypes "github.com/babylonlabs-io/babylon/x/epoching/types" + "github.com/babylonlabs-io/babylon/x/zoneconcierge/types" ) func (k Keeper) ProveCZHeaderInEpoch(_ context.Context, header *types.IndexedHeader, epoch *epochingtypes.Epoch) (*cmtcrypto.ProofOps, error) { diff --git a/x/zoneconcierge/keeper/proof_btc_timestamp_test.go b/x/zoneconcierge/keeper/proof_btc_timestamp_test.go index 48190e086..d58d3d666 100644 --- a/x/zoneconcierge/keeper/proof_btc_timestamp_test.go +++ b/x/zoneconcierge/keeper/proof_btc_timestamp_test.go @@ -12,13 +12,13 @@ import ( "github.com/btcsuite/btcd/chaincfg" "github.com/btcsuite/btcd/wire" - "github.com/babylonchain/babylon/crypto/bls12381" - "github.com/babylonchain/babylon/testutil/datagen" - testhelper "github.com/babylonchain/babylon/testutil/helper" - testkeeper "github.com/babylonchain/babylon/testutil/keeper" - btcctypes "github.com/babylonchain/babylon/x/btccheckpoint/types" - checkpointingtypes "github.com/babylonchain/babylon/x/checkpointing/types" - zctypes "github.com/babylonchain/babylon/x/zoneconcierge/types" + "github.com/babylonlabs-io/babylon/crypto/bls12381" + "github.com/babylonlabs-io/babylon/testutil/datagen" + testhelper "github.com/babylonlabs-io/babylon/testutil/helper" + testkeeper "github.com/babylonlabs-io/babylon/testutil/keeper" + btcctypes "github.com/babylonlabs-io/babylon/x/btccheckpoint/types" + checkpointingtypes "github.com/babylonlabs-io/babylon/x/checkpointing/types" + zctypes "github.com/babylonlabs-io/babylon/x/zoneconcierge/types" ) func FuzzProofCZHeaderInEpoch(f *testing.F) { diff --git a/x/zoneconcierge/module.go b/x/zoneconcierge/module.go index 20ab32932..5fcc64a16 100644 --- a/x/zoneconcierge/module.go +++ b/x/zoneconcierge/module.go @@ -11,9 +11,9 @@ import ( abci "github.com/cometbft/cometbft/abci/types" - "github.com/babylonchain/babylon/x/zoneconcierge/client/cli" - "github.com/babylonchain/babylon/x/zoneconcierge/keeper" - "github.com/babylonchain/babylon/x/zoneconcierge/types" + "github.com/babylonlabs-io/babylon/x/zoneconcierge/client/cli" + "github.com/babylonlabs-io/babylon/x/zoneconcierge/keeper" + "github.com/babylonlabs-io/babylon/x/zoneconcierge/types" "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/codec" cdctypes "github.com/cosmos/cosmos-sdk/codec/types" diff --git a/x/zoneconcierge/module_ibc.go b/x/zoneconcierge/module_ibc.go index cee536d91..1484bc322 100644 --- a/x/zoneconcierge/module_ibc.go +++ b/x/zoneconcierge/module_ibc.go @@ -2,8 +2,8 @@ package zoneconcierge import ( errorsmod "cosmossdk.io/errors" - "github.com/babylonchain/babylon/x/zoneconcierge/keeper" - "github.com/babylonchain/babylon/x/zoneconcierge/types" + "github.com/babylonlabs-io/babylon/x/zoneconcierge/keeper" + "github.com/babylonlabs-io/babylon/x/zoneconcierge/types" sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" capabilitytypes "github.com/cosmos/ibc-go/modules/capability/types" diff --git a/x/zoneconcierge/types/btc_timestamp.go b/x/zoneconcierge/types/btc_timestamp.go index 6d520a61e..c1cde804e 100644 --- a/x/zoneconcierge/types/btc_timestamp.go +++ b/x/zoneconcierge/types/btc_timestamp.go @@ -10,13 +10,13 @@ import ( cmtcrypto "github.com/cometbft/cometbft/proto/tendermint/crypto" sdk "github.com/cosmos/cosmos-sdk/types" - txformat "github.com/babylonchain/babylon/btctxformatter" - "github.com/babylonchain/babylon/crypto/bls12381" - bbn "github.com/babylonchain/babylon/types" - btcctypes "github.com/babylonchain/babylon/x/btccheckpoint/types" - btclckeeper "github.com/babylonchain/babylon/x/btclightclient/keeper" - checkpointingtypes "github.com/babylonchain/babylon/x/checkpointing/types" - epochingtypes "github.com/babylonchain/babylon/x/epoching/types" + txformat "github.com/babylonlabs-io/babylon/btctxformatter" + "github.com/babylonlabs-io/babylon/crypto/bls12381" + bbn "github.com/babylonlabs-io/babylon/types" + btcctypes "github.com/babylonlabs-io/babylon/x/btccheckpoint/types" + btclckeeper "github.com/babylonlabs-io/babylon/x/btclightclient/keeper" + checkpointingtypes "github.com/babylonlabs-io/babylon/x/checkpointing/types" + epochingtypes "github.com/babylonlabs-io/babylon/x/epoching/types" ) func GetCZHeaderKey(chainID string, height uint64) []byte { diff --git a/x/zoneconcierge/types/btc_timestamp_test.go b/x/zoneconcierge/types/btc_timestamp_test.go index 2f513329d..24033ed88 100644 --- a/x/zoneconcierge/types/btc_timestamp_test.go +++ b/x/zoneconcierge/types/btc_timestamp_test.go @@ -10,13 +10,13 @@ import ( "github.com/btcsuite/btcd/wire" "github.com/stretchr/testify/require" - txformat "github.com/babylonchain/babylon/btctxformatter" - "github.com/babylonchain/babylon/crypto/bls12381" - "github.com/babylonchain/babylon/testutil/datagen" - testhelper "github.com/babylonchain/babylon/testutil/helper" - btcctypes "github.com/babylonchain/babylon/x/btccheckpoint/types" - checkpointingtypes "github.com/babylonchain/babylon/x/checkpointing/types" - "github.com/babylonchain/babylon/x/zoneconcierge/types" + txformat "github.com/babylonlabs-io/babylon/btctxformatter" + "github.com/babylonlabs-io/babylon/crypto/bls12381" + "github.com/babylonlabs-io/babylon/testutil/datagen" + testhelper "github.com/babylonlabs-io/babylon/testutil/helper" + btcctypes "github.com/babylonlabs-io/babylon/x/btccheckpoint/types" + checkpointingtypes "github.com/babylonlabs-io/babylon/x/checkpointing/types" + "github.com/babylonlabs-io/babylon/x/zoneconcierge/types" ) func signBLSWithBitmap(blsSKs []bls12381.PrivateKey, bm bitmap.Bitmap, msg []byte) (bls12381.Signature, error) { diff --git a/x/zoneconcierge/types/errors.go b/x/zoneconcierge/types/errors.go index f37cae374..8d033faf5 100644 --- a/x/zoneconcierge/types/errors.go +++ b/x/zoneconcierge/types/errors.go @@ -12,9 +12,8 @@ var ( ErrChainInfoNotFound = errorsmod.Register(ModuleName, 1104, "no chain info exists") ErrEpochChainInfoNotFound = errorsmod.Register(ModuleName, 1105, "no chain info exists at this epoch") ErrEpochHeadersNotFound = errorsmod.Register(ModuleName, 1106, "no timestamped header exists at this epoch") - ErrFinalizedEpochNotFound = errorsmod.Register(ModuleName, 1107, "cannot find a finalized epoch") - ErrInvalidProofEpochSealed = errorsmod.Register(ModuleName, 1108, "invalid ProofEpochSealed") - ErrInvalidMerkleProof = errorsmod.Register(ModuleName, 1109, "invalid Merkle inclusion proof") - ErrInvalidChainInfo = errorsmod.Register(ModuleName, 1110, "invalid chain info") - ErrInvalidChainIDs = errorsmod.Register(ModuleName, 1111, "chain ids contain duplicates or empty strings") + ErrInvalidProofEpochSealed = errorsmod.Register(ModuleName, 1107, "invalid ProofEpochSealed") + ErrInvalidMerkleProof = errorsmod.Register(ModuleName, 1108, "invalid Merkle inclusion proof") + ErrInvalidChainInfo = errorsmod.Register(ModuleName, 1109, "invalid chain info") + ErrInvalidChainIDs = errorsmod.Register(ModuleName, 1110, "chain ids contain duplicates or empty strings") ) diff --git a/x/zoneconcierge/types/expected_keepers.go b/x/zoneconcierge/types/expected_keepers.go index 303c584ce..574a0b7fd 100644 --- a/x/zoneconcierge/types/expected_keepers.go +++ b/x/zoneconcierge/types/expected_keepers.go @@ -3,13 +3,13 @@ package types import ( "context" - bbn "github.com/babylonchain/babylon/types" + bbn "github.com/babylonlabs-io/babylon/types" clienttypes "github.com/cosmos/ibc-go/v8/modules/core/02-client/types" //nolint:staticcheck - btcctypes "github.com/babylonchain/babylon/x/btccheckpoint/types" - btclctypes "github.com/babylonchain/babylon/x/btclightclient/types" - checkpointingtypes "github.com/babylonchain/babylon/x/checkpointing/types" - epochingtypes "github.com/babylonchain/babylon/x/epoching/types" + 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" + epochingtypes "github.com/babylonlabs-io/babylon/x/epoching/types" ctypes "github.com/cometbft/cometbft/rpc/core/types" sdk "github.com/cosmos/cosmos-sdk/types" capabilitytypes "github.com/cosmos/ibc-go/modules/capability/types" @@ -97,6 +97,7 @@ type BtcCheckpointKeeper interface { type CheckpointingKeeper interface { GetBLSPubKeySet(ctx context.Context, epochNumber uint64) ([]*checkpointingtypes.ValidatorWithBlsKey, error) GetRawCheckpoint(ctx context.Context, epochNumber uint64) (*checkpointingtypes.RawCheckpointWithMeta, error) + GetLastFinalizedEpoch(ctx context.Context) uint64 } type EpochingKeeper interface { diff --git a/x/zoneconcierge/types/genesis.pb.go b/x/zoneconcierge/types/genesis.pb.go index 1eed06657..a0ae3e52e 100644 --- a/x/zoneconcierge/types/genesis.pb.go +++ b/x/zoneconcierge/types/genesis.pb.go @@ -85,7 +85,7 @@ func init() { } var fileDescriptor_56f290ad7c2c7dc7 = []byte{ - // 228 bytes of a gzipped FileDescriptorProto + // 230 bytes of a gzipped FileDescriptorProto 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x52, 0x4b, 0x4a, 0x4c, 0xaa, 0xcc, 0xc9, 0xcf, 0xd3, 0xaf, 0xca, 0xcf, 0x4b, 0x4d, 0xce, 0xcf, 0x4b, 0xce, 0x4c, 0x2d, 0x4a, 0x4f, 0xd5, 0x2f, 0x33, 0xd4, 0x4f, 0x4f, 0xcd, 0x4b, 0x2d, 0xce, 0x2c, 0xd6, 0x2b, 0x28, 0xca, @@ -95,12 +95,12 @@ var fileDescriptor_56f290ad7c2c7dc7 = []byte{ 0x54, 0x21, 0x71, 0x2e, 0xf6, 0x82, 0xfc, 0xa2, 0x92, 0xf8, 0xcc, 0x14, 0x09, 0x46, 0x05, 0x46, 0x0d, 0xce, 0x20, 0x36, 0x10, 0xd7, 0x33, 0x45, 0xc8, 0x8e, 0x8b, 0x0d, 0xa2, 0x51, 0x82, 0x49, 0x81, 0x51, 0x83, 0xdb, 0x48, 0x41, 0x0f, 0x97, 0x83, 0xf4, 0x02, 0xc0, 0xea, 0x9c, 0x58, 0x4e, - 0xdc, 0x93, 0x67, 0x08, 0x82, 0xea, 0x72, 0xf2, 0x3f, 0xf1, 0x48, 0x8e, 0xf1, 0xc2, 0x23, 0x39, + 0xdc, 0x93, 0x67, 0x08, 0x82, 0xea, 0x72, 0x0a, 0x3c, 0xf1, 0x48, 0x8e, 0xf1, 0xc2, 0x23, 0x39, 0xc6, 0x07, 0x8f, 0xe4, 0x18, 0x27, 0x3c, 0x96, 0x63, 0xb8, 0xf0, 0x58, 0x8e, 0xe1, 0xc6, 0x63, - 0x39, 0x86, 0x28, 0xd3, 0xf4, 0xcc, 0x92, 0x8c, 0xd2, 0x24, 0xbd, 0xe4, 0xfc, 0x5c, 0x7d, 0xa8, - 0x99, 0xc9, 0x19, 0x89, 0x99, 0x79, 0x30, 0x8e, 0x7e, 0x05, 0x9a, 0x1f, 0x4a, 0x2a, 0x0b, 0x52, - 0x8b, 0x93, 0xd8, 0xc0, 0x1e, 0x30, 0x06, 0x04, 0x00, 0x00, 0xff, 0xff, 0x6c, 0xb2, 0x6d, 0xbb, - 0x41, 0x01, 0x00, 0x00, + 0x39, 0x86, 0x28, 0xf3, 0xf4, 0xcc, 0x92, 0x8c, 0xd2, 0x24, 0xbd, 0xe4, 0xfc, 0x5c, 0x7d, 0xa8, + 0x99, 0x39, 0x89, 0x49, 0xc5, 0xba, 0x99, 0xf9, 0x30, 0xae, 0x7e, 0x05, 0x9a, 0x2f, 0x4a, 0x2a, + 0x0b, 0x52, 0x8b, 0x93, 0xd8, 0xc0, 0x5e, 0x30, 0x06, 0x04, 0x00, 0x00, 0xff, 0xff, 0xe6, 0x70, + 0xce, 0xb1, 0x43, 0x01, 0x00, 0x00, } func (m *GenesisState) Marshal() (dAtA []byte, err error) { diff --git a/x/zoneconcierge/types/genesis_test.go b/x/zoneconcierge/types/genesis_test.go index 0902eb6d7..859e66e14 100644 --- a/x/zoneconcierge/types/genesis_test.go +++ b/x/zoneconcierge/types/genesis_test.go @@ -3,7 +3,7 @@ package types_test import ( "testing" - "github.com/babylonchain/babylon/x/zoneconcierge/types" + "github.com/babylonlabs-io/babylon/x/zoneconcierge/types" "github.com/stretchr/testify/require" ) diff --git a/x/zoneconcierge/types/keys.go b/x/zoneconcierge/types/keys.go index bafe72112..1c0e0df57 100644 --- a/x/zoneconcierge/types/keys.go +++ b/x/zoneconcierge/types/keys.go @@ -33,9 +33,9 @@ var ( CanonicalChainKey = []byte{0x13} // CanonicalChainKey defines the key to store the canonical chain for each CZ in store ForkKey = []byte{0x14} // ForkKey defines the key to store the forks for each CZ in store EpochChainInfoKey = []byte{0x15} // EpochChainInfoKey defines the key to store each epoch's latests chain info for each CZ in store - FinalizedEpochKey = []byte{0x16} // FinalizedEpochKey defines the key to store the last finalised epoch - LastSentBTCSegmentKey = []byte{0x17} // LastSentBTCSegmentKey is key holding last btc light client segment sent to other cosmos zones - ParamsKey = []byte{0x18} // key prefix for the parameters + LastSentBTCSegmentKey = []byte{0x16} // LastSentBTCSegmentKey is key holding last btc light client segment sent to other cosmos zones + ParamsKey = []byte{0x17} // key prefix for the parameters + SealedEpochProofKey = []byte{0x18} // key prefix for proof of sealed epochs ) func KeyPrefix(p string) []byte { diff --git a/x/zoneconcierge/types/mocked_keepers.go b/x/zoneconcierge/types/mocked_keepers.go index 16f242bc4..2daa01fae 100644 --- a/x/zoneconcierge/types/mocked_keepers.go +++ b/x/zoneconcierge/types/mocked_keepers.go @@ -8,11 +8,11 @@ import ( context "context" reflect "reflect" - types "github.com/babylonchain/babylon/types" - types0 "github.com/babylonchain/babylon/x/btccheckpoint/types" - types1 "github.com/babylonchain/babylon/x/btclightclient/types" - types2 "github.com/babylonchain/babylon/x/checkpointing/types" - types3 "github.com/babylonchain/babylon/x/epoching/types" + 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/babylonlabs-io/babylon/x/checkpointing/types" + types3 "github.com/babylonlabs-io/babylon/x/epoching/types" coretypes "github.com/cometbft/cometbft/rpc/core/types" types4 "github.com/cosmos/cosmos-sdk/types" types5 "github.com/cosmos/ibc-go/modules/capability/types" @@ -721,6 +721,20 @@ func (mr *MockCheckpointingKeeperMockRecorder) GetBLSPubKeySet(ctx, epochNumber return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetBLSPubKeySet", reflect.TypeOf((*MockCheckpointingKeeper)(nil).GetBLSPubKeySet), ctx, epochNumber) } +// GetLastFinalizedEpoch mocks base method. +func (m *MockCheckpointingKeeper) GetLastFinalizedEpoch(ctx context.Context) uint64 { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "GetLastFinalizedEpoch", ctx) + ret0, _ := ret[0].(uint64) + return ret0 +} + +// GetLastFinalizedEpoch indicates an expected call of GetLastFinalizedEpoch. +func (mr *MockCheckpointingKeeperMockRecorder) GetLastFinalizedEpoch(ctx interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetLastFinalizedEpoch", reflect.TypeOf((*MockCheckpointingKeeper)(nil).GetLastFinalizedEpoch), ctx) +} + // GetRawCheckpoint mocks base method. func (m *MockCheckpointingKeeper) GetRawCheckpoint(ctx context.Context, epochNumber uint64) (*types2.RawCheckpointWithMeta, error) { m.ctrl.T.Helper() diff --git a/x/zoneconcierge/types/packet.pb.go b/x/zoneconcierge/types/packet.pb.go index 6e123e938..1ca32360f 100644 --- a/x/zoneconcierge/types/packet.pb.go +++ b/x/zoneconcierge/types/packet.pb.go @@ -5,10 +5,10 @@ package types import ( fmt "fmt" - types3 "github.com/babylonchain/babylon/x/btccheckpoint/types" - types "github.com/babylonchain/babylon/x/btclightclient/types" - types2 "github.com/babylonchain/babylon/x/checkpointing/types" - types1 "github.com/babylonchain/babylon/x/epoching/types" + types3 "github.com/babylonlabs-io/babylon/x/btccheckpoint/types" + types "github.com/babylonlabs-io/babylon/x/btclightclient/types" + types2 "github.com/babylonlabs-io/babylon/x/checkpointing/types" + types1 "github.com/babylonlabs-io/babylon/x/epoching/types" proto "github.com/cosmos/gogoproto/proto" io "io" math "math" @@ -211,37 +211,37 @@ func init() { } var fileDescriptor_be12e124c5c4fdb9 = []byte{ - // 471 bytes of a gzipped FileDescriptorProto + // 474 bytes of a gzipped FileDescriptorProto 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x74, 0x92, 0x4f, 0x6f, 0xd3, 0x30, 0x18, 0xc6, 0x1b, 0xca, 0x2a, 0x70, 0x37, 0x84, 0x7c, 0x21, 0xda, 0x21, 0x9a, 0x2a, 0x01, 0x45, - 0x9a, 0x1c, 0x65, 0x88, 0x03, 0x27, 0xa4, 0x96, 0x3f, 0xab, 0x10, 0x30, 0x85, 0x71, 0xd9, 0xa5, - 0xb2, 0xdd, 0xb7, 0x8d, 0xd5, 0xd6, 0x8e, 0x12, 0xaf, 0x5b, 0xf7, 0x29, 0xf8, 0x52, 0x48, 0x1c, - 0x77, 0xe4, 0x88, 0xda, 0x2f, 0x82, 0xec, 0xfc, 0x69, 0x52, 0x94, 0x4b, 0xe4, 0xf7, 0xc9, 0xcf, - 0x8f, 0xfd, 0x3e, 0x7e, 0xd1, 0x73, 0x46, 0xd9, 0x7a, 0xa1, 0xa4, 0x7f, 0xa7, 0x24, 0x70, 0x25, + 0x1a, 0x8e, 0x32, 0x0e, 0x88, 0x13, 0x52, 0xcb, 0x9f, 0x55, 0x08, 0x34, 0xc2, 0xb8, 0xec, 0x52, + 0xd9, 0xee, 0xdb, 0xc6, 0x6a, 0x6b,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9, 0xf5, 0x5a, 0xf7, 0x5b, 0xaf, 0xf5, 0x67, 0xeb, 0xb5, 0xae, 0xde, 0xcc, - 0x84, 0x8e, 0xae, 0x19, 0xe1, 0x6a, 0xe9, 0xe7, 0xee, 0xdc, 0xec, 0x2e, 0x0a, 0xff, 0x76, 0x6f, - 0x3a, 0xf5, 0x3a, 0x86, 0x94, 0x75, 0xec, 0x4c, 0xbe, 0xfe, 0x17, 0x00, 0x00, 0xff, 0xff, 0x31, - 0xea, 0x29, 0xbc, 0xb1, 0x03, 0x00, 0x00, + 0x9b, 0x63, 0xa4, 0x86, 0x91, 0x55, 0x70, 0x78, 0x5c, 0x18, 0x30, 0xcd, 0x79, 0x04, 0x7c, 0x1e, + 0x2b, 0x21, 0xb5, 0x31, 0xa8, 0x09, 0x99, 0xcf, 0xe1, 0xab, 0x82, 0xbe, 0xfb, 0x23, 0xe4, 0xcc, + 0xd0, 0xf7, 0x50, 0x52, 0x31, 0x5e, 0x88, 0x59, 0x64, 0xbe, 0x50, 0x3a, 0x57, 0x94, 0x9c, 0xef, + 0x15, 0x3c, 0xc4, 0x8a, 0x47, 0xb9, 0x6b, 0xb1, 0xce, 0x99, 0xe3, 0xc6, 0x6e, 0xeb, 0x7d, 0x59, + 0xba, 0x97, 0xa0, 0x67, 0x17, 0x55, 0xf9, 0xcc, 0x26, 0xf2, 0x81, 0x6a, 0x8a, 0xbf, 0xa2, 0x03, + 0xa6, 0xf9, 0x58, 0x8b, 0x25, 0xa4, 0x9a, 0x2e, 0x63, 0xd7, 0x39, 0x72, 0xfa, 0xdd, 0x93, 0x17, + 0xa4, 0x29, 0x27, 0x32, 0x38, 0x1f, 0x9e, 0x17, 0xf4, 0x69, 0x2b, 0xdc, 0x67, 0x9a, 0x97, 0xf5, + 0xe0, 0x11, 0xea, 0x64, 0x71, 0xf7, 0x7e, 0xb7, 0xd1, 0x7e, 0x15, 0xc5, 0xef, 0x51, 0x27, 0x02, + 0x3a, 0x81, 0x24, 0x3f, 0x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6, 0x6b, 0x5d, 0xbc, 0x9d, + 0x09, 0x1d, 0x5d, 0x32, 0xc2, 0xd5, 0xd2, 0xcf, 0xdd, 0x17, 0x94, 0xa5, 0xaf, 0x85, 0x2a, 0x4a, + 0xff, 0x7a, 0x67, 0x3e, 0xf5, 0x3a, 0x86, 0x94, 0x75, 0xec, 0x54, 0xbe, 0xf9, 0x1f, 0x00, 0x00, + 0xff, 0xff, 0x7d, 0x8d, 0x6b, 0xdb, 0xb3, 0x03, 0x00, 0x00, } func (m *ZoneconciergePacketData) Marshal() (dAtA []byte, err error) { diff --git a/x/zoneconcierge/types/params.pb.go b/x/zoneconcierge/types/params.pb.go index ac4b27c33..732cfcecd 100644 --- a/x/zoneconcierge/types/params.pb.go +++ b/x/zoneconcierge/types/params.pb.go @@ -79,7 +79,7 @@ func init() { } var fileDescriptor_c0696c936eb15fe4 = []byte{ - // 227 bytes of a gzipped FileDescriptorProto + // 229 bytes of a gzipped FileDescriptorProto 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x52, 0x4d, 0x4a, 0x4c, 0xaa, 0xcc, 0xc9, 0xcf, 0xd3, 0xaf, 0xca, 0xcf, 0x4b, 0x4d, 0xce, 0xcf, 0x4b, 0xce, 0x4c, 0x2d, 0x4a, 0x4f, 0xd5, 0x2f, 0x33, 0xd4, 0x2f, 0x48, 0x2c, 0x4a, 0xcc, 0x2d, 0xd6, 0x2b, 0x28, 0xca, 0x2f, @@ -89,12 +89,12 @@ var fileDescriptor_c0696c936eb15fe4 = []byte{ 0xe6, 0xa6, 0xe6, 0x97, 0x96, 0xc4, 0x17, 0x83, 0x0c, 0x49, 0x29, 0x96, 0x60, 0x54, 0x60, 0xd4, 0xe0, 0x75, 0x52, 0xfd, 0x74, 0x4f, 0x5e, 0xb1, 0x32, 0x31, 0x37, 0xc7, 0x4a, 0x09, 0xb7, 0x5a, 0xa5, 0x20, 0xf1, 0xcc, 0xa4, 0xe4, 0x00, 0xb0, 0x5c, 0x08, 0x44, 0x2a, 0x18, 0x22, 0x63, 0xc5, - 0xf2, 0x62, 0x81, 0x3c, 0xa3, 0x93, 0xff, 0x89, 0x47, 0x72, 0x8c, 0x17, 0x1e, 0xc9, 0x31, 0x3e, + 0xf2, 0x62, 0x81, 0x3c, 0xa3, 0x53, 0xe0, 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, 0x99, 0xa6, 0x67, 0x96, 0x64, 0x94, 0x26, 0xe9, 0x25, 0xe7, 0xe7, 0xea, 0x43, 0x3d, 0x92, - 0x9c, 0x91, 0x98, 0x99, 0x07, 0xe3, 0xe8, 0x57, 0xa0, 0x79, 0xbf, 0xa4, 0xb2, 0x20, 0xb5, 0x38, - 0x89, 0x0d, 0xec, 0x17, 0x63, 0x40, 0x00, 0x00, 0x00, 0xff, 0xff, 0x2d, 0xf3, 0xe4, 0xef, 0x24, - 0x01, 0x00, 0x00, + 0x44, 0x99, 0xa7, 0x67, 0x96, 0x64, 0x94, 0x26, 0xe9, 0x25, 0xe7, 0xe7, 0xea, 0x43, 0x3d, 0x92, + 0x93, 0x98, 0x54, 0xac, 0x9b, 0x99, 0x0f, 0xe3, 0xea, 0x57, 0xa0, 0x05, 0x40, 0x49, 0x65, 0x41, + 0x6a, 0x71, 0x12, 0x1b, 0xd8, 0x37, 0xc6, 0x80, 0x00, 0x00, 0x00, 0xff, 0xff, 0x2d, 0x2b, 0x77, + 0x59, 0x26, 0x01, 0x00, 0x00, } func (this *Params) Equal(that interface{}) bool { diff --git a/x/zoneconcierge/types/params_test.go b/x/zoneconcierge/types/params_test.go index c4be306d0..863b9cb39 100644 --- a/x/zoneconcierge/types/params_test.go +++ b/x/zoneconcierge/types/params_test.go @@ -3,7 +3,7 @@ package types_test import ( "testing" - "github.com/babylonchain/babylon/x/zoneconcierge/types" + "github.com/babylonlabs-io/babylon/x/zoneconcierge/types" "github.com/stretchr/testify/require" ) diff --git a/x/zoneconcierge/types/query.pb.go b/x/zoneconcierge/types/query.pb.go index 64d219deb..c2f8f49dd 100644 --- a/x/zoneconcierge/types/query.pb.go +++ b/x/zoneconcierge/types/query.pb.go @@ -6,9 +6,9 @@ package types import ( context "context" fmt "fmt" - types2 "github.com/babylonchain/babylon/x/btccheckpoint/types" - types1 "github.com/babylonchain/babylon/x/checkpointing/types" - types "github.com/babylonchain/babylon/x/epoching/types" + types2 "github.com/babylonlabs-io/babylon/x/btccheckpoint/types" + types1 "github.com/babylonlabs-io/babylon/x/checkpointing/types" + types "github.com/babylonlabs-io/babylon/x/epoching/types" query "github.com/cosmos/cosmos-sdk/types/query" _ "github.com/cosmos/gogoproto/gogoproto" grpc1 "github.com/cosmos/gogoproto/grpc" @@ -1012,81 +1012,81 @@ func init() { } var fileDescriptor_cd665af90102da38 = []byte{ - // 1176 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x57, 0xcf, 0x6f, 0xdc, 0x44, - 0x14, 0x8e, 0xf3, 0xab, 0xc9, 0x5b, 0x0a, 0xd5, 0x24, 0x2d, 0x8b, 0xdb, 0x6e, 0x22, 0x43, 0x69, - 0x5a, 0x12, 0x9b, 0x4d, 0x49, 0xab, 0x72, 0xa0, 0x6a, 0x52, 0x92, 0x46, 0x45, 0xa5, 0x35, 0x04, - 0x24, 0x2e, 0xc6, 0xf6, 0xce, 0x7a, 0xad, 0x64, 0x3d, 0x5b, 0xdb, 0xbb, 0xed, 0x36, 0x84, 0x03, - 0xea, 0x1d, 0x24, 0x2e, 0x88, 0x13, 0x27, 0x0e, 0x1c, 0x7a, 0xe3, 0x4f, 0x40, 0xea, 0x81, 0x43, - 0x25, 0x2e, 0x9c, 0x10, 0x4a, 0xf8,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 0x00, 0x00, + // 1182 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x57, 0xcf, 0x6f, 0x1b, 0xc5, + 0x17, 0xcf, 0xe6, 0x57, 0x93, 0xe7, 0x6f, 0xbf, 0x54, 0x93, 0xb4, 0x98, 0x6d, 0xeb, 0x44, 0x0b, + 0xa5, 0x69, 0x49, 0x76, 0x71, 0x4a, 0x1b, 0x95, 0x03, 0x55, 0x93, 0x92, 0x34, 0x2a, 0xaa, 0x9a, + 0x85, 0x80, 0xc4, 0xc5, 0xec, 0xae, 0xc7, 0xf6, 0x2a, 0xf1, 0x8e, 0xbb, 0xb3, 0x76, 0xeb, 0x86, + 0x70, 0x40, 0xbd, 0x83, 0xc4, 0x05, 0x71, 0xe2, 0xc4, 0x81, 0x43, 0x6f, 0xfc, 0x09, 0x48, 0x3d, + 0x70, 0xa8, 0xc4, 0x85, 0x13, 0x42, 0x09, 0xff, 0x06, 0x12, 0xda, 0x99, 0x59, 0x7b, 0x7f, 0xda, + 0xeb, 0x90, 0x9b, 0x67, 0xf6, 0xbd, 0xcf, 0xe7, 0xf3, 0xde, 0xbc, 0x99, 0xf7, 0x0c, 0x6f, 0x99, + 0x86, 0xd9, 0xdd, 0x27, 0x8e, 0xf6, 0x8c, 0x38, 0xd8, 0x22, 0x8e, 0x65, 0x63, 0xb7, 0x8e, 0xb5, + 0x4e, 0x59, 0x7b, 0xdc, 0xc6, 0x6e, 0x57, 0x6d, 0xb9, 0xc4, 0x23, 0xa8, 0x28, 0xac, 0xd4, 0x88, + 0x95, 0xda, 0x29, 0xcb, 0xf3, 0x75, 0x52, 0x27, 0xcc, 0x48, 0xf3, 0x7f, 0x71, 0x7b, 0xf9, 0x52, + 0x9d, 0x90, 0xfa, 0x3e, 0xd6, 0x8c, 0x96, 0xad, 0x19, 0x8e, 0x43, 0x3c, 0xc3, 0xb3, 0x89, 0x43, + 0xc5, 0x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0x79, 0xf9, 0xde, 0x7f, 0x03, 0x11, 0x51, 0xee, 0xb0, 0x28, 0x1f, 0xa0, 0xed, 0xdc, 0x51, 0xa6, + 0xbc, 0x9c, 0x3e, 0x62, 0xef, 0xe5, 0x5c, 0xdf, 0x79, 0x79, 0x54, 0x92, 0x5e, 0x1d, 0x95, 0xa4, + 0xbf, 0x8e, 0x4a, 0xd2, 0xb7, 0xc7, 0xa5, 0xb1, 0x57, 0xc7, 0xa5, 0xb1, 0x3f, 0x8e, 0x4b, 0x63, + 0x9f, 0xaf, 0xd5, 0x6d, 0xaf, 0xd1, 0x36, 0x55, 0x8b, 0x34, 0x03, 0xba, 0x7d, 0xc3, 0xa4, 0x2b, + 0x36, 0xe9, 0xb1, 0x3f, 0x8d, 0xf1, 0x7b, 0xdd, 0x16, 0xa6, 0xe6, 0x34, 0xfb, 0x4b, 0x7d, 0xe3, + 0xdf, 0x00, 0x00, 0x00, 0xff, 0xff, 0x09, 0x4f, 0xa5, 0xb2, 0xc6, 0x10, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. diff --git a/x/zoneconcierge/types/tx.pb.go b/x/zoneconcierge/types/tx.pb.go index 032e66afa..d9f617164 100644 --- a/x/zoneconcierge/types/tx.pb.go +++ b/x/zoneconcierge/types/tx.pb.go @@ -135,7 +135,7 @@ func init() { func init() { proto.RegisterFile("babylon/zoneconcierge/v1/tx.proto", fileDescriptor_35e2112d987e4e18) } var fileDescriptor_35e2112d987e4e18 = []byte{ - // 331 bytes of a gzipped FileDescriptorProto + // 333 bytes of a gzipped FileDescriptorProto 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x52, 0x4c, 0x4a, 0x4c, 0xaa, 0xcc, 0xc9, 0xcf, 0xd3, 0xaf, 0xca, 0xcf, 0x4b, 0x4d, 0xce, 0xcf, 0x4b, 0xce, 0x4c, 0x2d, 0x4a, 0x4f, 0xd5, 0x2f, 0x33, 0xd4, 0x2f, 0xa9, 0xd0, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0x92, 0x80, @@ -151,12 +151,12 @@ var fileDescriptor_35e2112d987e4e18 = []byte{ 0x93, 0x67, 0x08, 0x82, 0xea, 0xb2, 0xe2, 0x6b, 0x7a, 0xbe, 0x41, 0x0b, 0x61, 0x9e, 0x92, 0x24, 0x97, 0x38, 0x9a, 0xd3, 0x82, 0x52, 0x8b, 0x0b, 0xf2, 0xf3, 0x8a, 0x53, 0x8d, 0xaa, 0xb8, 0x98, 0x7d, 0x8b, 0xd3, 0x85, 0x72, 0xb8, 0x78, 0x50, 0x5c, 0xae, 0x89, 0xdb, 0x46, 0x34, 0x93, 0xa4, - 0x0c, 0x89, 0x56, 0x0a, 0xb3, 0x54, 0x8a, 0xb5, 0xe1, 0xf9, 0x06, 0x2d, 0x46, 0x27, 0xff, 0x13, + 0x0c, 0x89, 0x56, 0x0a, 0xb3, 0x54, 0x8a, 0xb5, 0xe1, 0xf9, 0x06, 0x2d, 0x46, 0xa7, 0xc0, 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, 0x32, 0x4d, 0xcf, 0x2c, 0xc9, 0x28, 0x4d, - 0xd2, 0x4b, 0xce, 0xcf, 0xd5, 0x87, 0x9a, 0x9e, 0x9c, 0x91, 0x98, 0x99, 0x07, 0xe3, 0xe8, 0x57, - 0xa0, 0xc5, 0x46, 0x49, 0x65, 0x41, 0x6a, 0x71, 0x12, 0x1b, 0x38, 0x2a, 0x8c, 0x01, 0x01, 0x00, - 0x00, 0xff, 0xff, 0x05, 0xf5, 0x03, 0x87, 0x3a, 0x02, 0x00, 0x00, + 0x0b, 0x8f, 0xe5, 0x18, 0x6e, 0x3c, 0x96, 0x63, 0x88, 0x32, 0x4f, 0xcf, 0x2c, 0xc9, 0x28, 0x4d, + 0xd2, 0x4b, 0xce, 0xcf, 0xd5, 0x87, 0x9a, 0x9e, 0x93, 0x98, 0x54, 0xac, 0x9b, 0x99, 0x0f, 0xe3, + 0xea, 0x57, 0xa0, 0xc5, 0x47, 0x49, 0x65, 0x41, 0x6a, 0x71, 0x12, 0x1b, 0x38, 0x32, 0x8c, 0x01, + 0x01, 0x00, 0x00, 0xff, 0xff, 0x55, 0x48, 0x49, 0xed, 0x3c, 0x02, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. diff --git a/x/zoneconcierge/types/zoneconcierge.pb.go b/x/zoneconcierge/types/zoneconcierge.pb.go index a6b9473e3..8e3d792b7 100644 --- a/x/zoneconcierge/types/zoneconcierge.pb.go +++ b/x/zoneconcierge/types/zoneconcierge.pb.go @@ -5,10 +5,10 @@ package types import ( fmt "fmt" - types2 "github.com/babylonchain/babylon/x/btccheckpoint/types" - types3 "github.com/babylonchain/babylon/x/btclightclient/types" - types1 "github.com/babylonchain/babylon/x/checkpointing/types" - types "github.com/babylonchain/babylon/x/epoching/types" + types2 "github.com/babylonlabs-io/babylon/x/btccheckpoint/types" + types3 "github.com/babylonlabs-io/babylon/x/btclightclient/types" + types1 "github.com/babylonlabs-io/babylon/x/checkpointing/types" + types "github.com/babylonlabs-io/babylon/x/epoching/types" crypto "github.com/cometbft/cometbft/proto/tendermint/crypto" _ "github.com/cosmos/gogoproto/gogoproto" proto "github.com/cosmos/gogoproto/proto" @@ -284,6 +284,63 @@ func (m *ChainInfo) GetTimestampedHeadersCount() uint64 { return 0 } +// ChainInfoWithProof is the chain info with a proof that the latest header in +// the chain info is included in the epoch +type ChainInfoWithProof struct { + ChainInfo *ChainInfo `protobuf:"bytes,1,opt,name=chain_info,json=chainInfo,proto3" json:"chain_info,omitempty"` + // proof_header_in_epoch is an inclusion proof that the latest_header in chain_info + // is committed to `app_hash` of the sealer header of latest_header.babylon_epoch + // this field is optional + ProofHeaderInEpoch *crypto.ProofOps `protobuf:"bytes,2,opt,name=proof_header_in_epoch,json=proofHeaderInEpoch,proto3" json:"proof_header_in_epoch,omitempty"` +} + +func (m *ChainInfoWithProof) Reset() { *m = ChainInfoWithProof{} } +func (m *ChainInfoWithProof) String() string { return proto.CompactTextString(m) } +func (*ChainInfoWithProof) ProtoMessage() {} +func (*ChainInfoWithProof) Descriptor() ([]byte, []int) { + return fileDescriptor_ab886e1868e5c5cd, []int{3} +} +func (m *ChainInfoWithProof) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *ChainInfoWithProof) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_ChainInfoWithProof.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 *ChainInfoWithProof) XXX_Merge(src proto.Message) { + xxx_messageInfo_ChainInfoWithProof.Merge(m, src) +} +func (m *ChainInfoWithProof) XXX_Size() int { + return m.Size() +} +func (m *ChainInfoWithProof) XXX_DiscardUnknown() { + xxx_messageInfo_ChainInfoWithProof.DiscardUnknown(m) +} + +var xxx_messageInfo_ChainInfoWithProof proto.InternalMessageInfo + +func (m *ChainInfoWithProof) GetChainInfo() *ChainInfo { + if m != nil { + return m.ChainInfo + } + return nil +} + +func (m *ChainInfoWithProof) GetProofHeaderInEpoch() *crypto.ProofOps { + if m != nil { + return m.ProofHeaderInEpoch + } + return nil +} + // FinalizedChainInfo is the information of a CZ that is BTC-finalised type FinalizedChainInfo struct { // chain_id is the ID of the chain @@ -305,7 +362,7 @@ func (m *FinalizedChainInfo) Reset() { *m = FinalizedChainInfo{} } func (m *FinalizedChainInfo) String() string { return proto.CompactTextString(m) } func (*FinalizedChainInfo) ProtoMessage() {} func (*FinalizedChainInfo) Descriptor() ([]byte, []int) { - return fileDescriptor_ab886e1868e5c5cd, []int{3} + return fileDescriptor_ab886e1868e5c5cd, []int{4} } func (m *FinalizedChainInfo) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -384,7 +441,7 @@ func (m *FinalizedChainInfo) GetProof() *ProofFinalizedChainInfo { // - 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 -// - The epoch medatata is committed to the `app_hash` of the sealer header +// - The epoch metadata is committed to the `app_hash` of the sealer header // - The validator set is committed to the `app_hash` of the sealer header type ProofEpochSealed struct { // validator_set is the validator set of the sealed epoch @@ -403,7 +460,7 @@ func (m *ProofEpochSealed) Reset() { *m = ProofEpochSealed{} } func (m *ProofEpochSealed) String() string { return proto.CompactTextString(m) } func (*ProofEpochSealed) ProtoMessage() {} func (*ProofEpochSealed) Descriptor() ([]byte, []int) { - return fileDescriptor_ab886e1868e5c5cd, []int{4} + return fileDescriptor_ab886e1868e5c5cd, []int{5} } func (m *ProofEpochSealed) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -471,7 +528,7 @@ func (m *ProofFinalizedChainInfo) Reset() { *m = ProofFinalizedChainInfo func (m *ProofFinalizedChainInfo) String() string { return proto.CompactTextString(m) } func (*ProofFinalizedChainInfo) ProtoMessage() {} func (*ProofFinalizedChainInfo) Descriptor() ([]byte, []int) { - return fileDescriptor_ab886e1868e5c5cd, []int{5} + return fileDescriptor_ab886e1868e5c5cd, []int{6} } func (m *ProofFinalizedChainInfo) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -530,7 +587,7 @@ func (m *BTCChainSegment) Reset() { *m = BTCChainSegment{} } func (m *BTCChainSegment) String() string { return proto.CompactTextString(m) } func (*BTCChainSegment) ProtoMessage() {} func (*BTCChainSegment) Descriptor() ([]byte, []int) { - return fileDescriptor_ab886e1868e5c5cd, []int{6} + return fileDescriptor_ab886e1868e5c5cd, []int{7} } func (m *BTCChainSegment) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -570,6 +627,7 @@ func init() { proto.RegisterType((*IndexedHeader)(nil), "babylon.zoneconcierge.v1.IndexedHeader") proto.RegisterType((*Forks)(nil), "babylon.zoneconcierge.v1.Forks") proto.RegisterType((*ChainInfo)(nil), "babylon.zoneconcierge.v1.ChainInfo") + proto.RegisterType((*ChainInfoWithProof)(nil), "babylon.zoneconcierge.v1.ChainInfoWithProof") proto.RegisterType((*FinalizedChainInfo)(nil), "babylon.zoneconcierge.v1.FinalizedChainInfo") proto.RegisterType((*ProofEpochSealed)(nil), "babylon.zoneconcierge.v1.ProofEpochSealed") proto.RegisterType((*ProofFinalizedChainInfo)(nil), "babylon.zoneconcierge.v1.ProofFinalizedChainInfo") @@ -581,65 +639,68 @@ func init() { } var fileDescriptor_ab886e1868e5c5cd = []byte{ - // 928 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94, 0x56, 0xdf, 0x6e, 0x1b, 0xc5, - 0x17, 0xce, 0xc6, 0x4e, 0xd2, 0x1c, 0xc7, 0x6d, 0x7e, 0x93, 0xf4, 0xd7, 0x6d, 0x10, 0x8e, 0xe5, - 0x4a, 0xc5, 0x45, 0xb0, 0x96, 0x0d, 0x5c, 0xc0, 0x1d, 0xb6, 0x5a, 0x9a, 0x82, 0x28, 0x5a, 0xbb, - 0x05, 0x21, 0xd0, 0x6a, 0xff, 0x8c, 0x77, 0x57, 0x59, 0xef, 0x58, 0xbb, 0x13, 0x37, 0xce, 0x53, - 0xf4, 0x2d, 0xb8, 0xe6, 0x01, 0xb8, 0xe7, 0xb2, 0x97, 0xdc, 0x81, 0x92, 0x57, 0xe0, 0x86, 0x3b, - 0x34, 0x67, 0x66, 0xd6, 0xbb, 0x8d, 0x4c, 0xe0, 0x26, 0xda, 0x99, 0xf9, 0xce, 0x77, 0xbe, 0xf9, - 0xce, 0x99, 0xe3, 0xc0, 0x07, 0x9e, 0xeb, 0x2d, 0x13, 0x96, 0xf6, 0x2e, 0x58, 0x4a, 0x7d, 0x96,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 0xf3, 0x94, 0x7f, 0xa3, 0x16, 0x7d, 0x6b, 0x38, 0x19, - 0x69, 0x37, 0xa6, 0xcc, 0x06, 0x8f, 0xfb, 0x6a, 0x78, 0x0c, 0x9f, 0xff, 0x7a, 0xd9, 0x32, 0xde, - 0x5c, 0xb6, 0x8c, 0x3f, 0x2e, 0x5b, 0xc6, 0xeb, 0xab, 0xd6, 0xc6, 0x9b, 0xab, 0xd6, 0xc6, 0x6f, - 0x57, 0xad, 0x8d, 0xef, 0x3f, 0x09, 0x63, 0x1e, 0x9d, 0x79, 0x96, 0xcf, 0x66, 0x3d, 0xc5, 0x8c, - 0x53, 0x42, 0x2f, 0x7a, 0xe7, 0x6f, 0xfd, 0x87, 0xc1, 0x97, 0x73, 0x9a, 0x7b, 0xdb, 0xf8, 0xe3, - 0xf4, 0xd1, 0xdf, 0x01, 0x00, 0x00, 0xff, 0xff, 0x76, 0x46, 0x5d, 0x86, 0x87, 0x08, 0x00, 0x00, + // 968 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94, 0x56, 0xdd, 0x6e, 0x1b, 0x45, + 0x14, 0xce, 0xc6, 0x4e, 0xd2, 0x1c, 0xc7, 0x6d, 0x98, 0xa4, 0xd4, 0x0d, 0xc2, 0xb1, 0x5c, 0xa9, + 0xb8, 0x88, 0xae, 0x65, 0x83, 0x84, 0xe0, 0x0e, 0x5b, 0x2d, 0x4d, 0x41, 0xfc, 0xac, 0xdd, 0x82, + 0x10, 0x68, 0xb5, 0x3f, 0x63, 0xef, 0x2a, 0xeb, 0x1d, 0x6b, 0x67, 0xe2, 0xc6, 0x79, 0x8a, 0xbe, + 0x05, 0xdc, 0xf2, 0x00, 0xdc, 0x73, 0xd9, 0x4b, 0xee, 0x40, 0xc9, 0x2b, 0x70, 0xc3, 0x1d, 0x9a, + 0x33, 0x33, 0xeb, 0x75, 0x22, 0x93, 0x70, 0x13, 0xed, 0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e, 0xc5, 0x54, 0x74, 0xc5, 0x7e, 0x32, 0xa3, 0xac, 0x3d, 0xcb, 0x66, 0x11, 0x82, 0x86, 0x7a, + 0xdb, 0x3e, 0x5a, 0xdd, 0x69, 0xc3, 0xcc, 0x4b, 0xb9, 0x17, 0x88, 0x98, 0xa9, 0xbe, 0xd8, 0x2b, + 0xf8, 0x36, 0x5e, 0x9a, 0x3f, 0xc2, 0x9d, 0xde, 0xb0, 0x8f, 0xea, 0x0c, 0xe8, 0x78, 0x42, 0x53, + 0x41, 0x8e, 0xa0, 0x22, 0x1b, 0xdb, 0x6c, 0x75, 0xd5, 0x21, 0xad, 0x62, 0x9c, 0xe2, 0xcf, 0xe9, + 0xac, 0x63, 0xf7, 0x86, 0x7d, 0xa3, 0xc6, 0x88, 0x39, 0xe0, 0x8b, 0x40, 0xef, 0xb9, 0xde, 0xb7, + 0xbf, 0x9f, 0xd7, 0xad, 0x37, 0xe7, 0x75, 0xeb, 0xaf, 0xf3, 0xba, 0xf5, 0xfa, 0xa2, 0xbe, 0xf6, + 0xe6, 0xa2, 0xbe, 0xf6, 0xc7, 0x45, 0x7d, 0xed, 0x87, 0x8f, 0xc7, 0xb1, 0x88, 0x4e, 0x7c, 0x3b, + 0x60, 0x93, 0xb6, 0xf6, 0x9c, 0x78, 0x3e, 0x7f, 0x1c, 0x33, 0x73, 0x6c, 0x9f, 0x5e, 0xfa, 0x77, + 0x48, 0xcc, 0xa7, 0x94, 0xfb, 0x9b, 0xf8, 0x4b, 0xfa, 0xe1, 0xbf, 0x01, 0x00, 0x00, 0xff, 0xff, + 0xa3, 0x29, 0xc3, 0x31, 0x34, 0x09, 0x00, 0x00, } func (m *IndexedHeader) Marshal() (dAtA []byte, err error) { @@ -814,6 +875,53 @@ func (m *ChainInfo) MarshalToSizedBuffer(dAtA []byte) (int, error) { return len(dAtA) - i, nil } +func (m *ChainInfoWithProof) 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 *ChainInfoWithProof) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *ChainInfoWithProof) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.ProofHeaderInEpoch != nil { + { + size, err := m.ProofHeaderInEpoch.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintZoneconcierge(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + } + if m.ChainInfo != nil { + { + size, err := m.ChainInfo.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintZoneconcierge(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + func (m *FinalizedChainInfo) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) @@ -1151,6 +1259,23 @@ func (m *ChainInfo) Size() (n int) { return n } +func (m *ChainInfoWithProof) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.ChainInfo != nil { + l = m.ChainInfo.Size() + n += 1 + l + sovZoneconcierge(uint64(l)) + } + if m.ProofHeaderInEpoch != nil { + l = m.ProofHeaderInEpoch.Size() + n += 1 + l + sovZoneconcierge(uint64(l)) + } + return n +} + func (m *FinalizedChainInfo) Size() (n int) { if m == nil { return 0 @@ -1785,6 +1910,128 @@ func (m *ChainInfo) Unmarshal(dAtA []byte) error { } return nil } +func (m *ChainInfoWithProof) 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 ErrIntOverflowZoneconcierge + } + 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: ChainInfoWithProof: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: ChainInfoWithProof: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ChainInfo", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowZoneconcierge + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthZoneconcierge + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthZoneconcierge + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.ChainInfo == nil { + m.ChainInfo = &ChainInfo{} + } + if err := m.ChainInfo.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ProofHeaderInEpoch", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowZoneconcierge + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthZoneconcierge + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthZoneconcierge + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.ProofHeaderInEpoch == nil { + m.ProofHeaderInEpoch = &crypto.ProofOps{} + } + if err := m.ProofHeaderInEpoch.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipZoneconcierge(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthZoneconcierge + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} func (m *FinalizedChainInfo) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0