From 7b68375a05752b0bce99c26c07102ab2bfdfdbe2 Mon Sep 17 00:00:00 2001 From: Filip Djokic Date: Mon, 5 Dec 2022 11:30:10 +0100 Subject: [PATCH 1/6] Pull upstream changes --- .github/workflows/docker-build.yml | 51 +++++++ .github/workflows/lint-pr.yml | 16 +++ CHANGELOG.md | 129 ++++++++++++++++++ database/types/staking_validators.go | 2 + database/types/upgrade.go | 4 +- modules/actions/types/worker.go | 11 +- .../handle_periodic_operations.go | 10 +- modules/staking/utils_staking_pool.go | 3 +- types/config/config.go | 1 + 9 files changed, 212 insertions(+), 15 deletions(-) create mode 100644 .github/workflows/docker-build.yml create mode 100644 .github/workflows/lint-pr.yml create mode 100644 CHANGELOG.md diff --git a/.github/workflows/docker-build.yml b/.github/workflows/docker-build.yml new file mode 100644 index 000000000..2196187e7 --- /dev/null +++ b/.github/workflows/docker-build.yml @@ -0,0 +1,51 @@ +name: docker-build + +on: + push: + branches: + - chains/*/* + +jobs: + docker: + runs-on: ubuntu-latest + steps: + - + name: Checkout + uses: actions/checkout@v3 + with: + fetch-depth: 0 + - + name: Set bdjuno chain_name + shell: bash + run: echo "CHAIN_NAME=$(echo ${GITHUB_REF#refs/heads/} | sed 's/\//_/g')" >> $GITHUB_ENV + - + name: Set bdjuno version + shell: bash + run: echo "GITHUB_VERSION=$(git describe --tags)" >> $GITHUB_ENV + - + name: Prepare tags + id: prep + run: | + DOCKER_IMAGE=${{ secrets.DOCKERHUB_BDJUNO_REPO }} + CHAIN_NAME="${{env.CHAIN_NAME}}" + VERSION="${{env.GITHUB_VERSION}}" + TAGS="${DOCKER_IMAGE}:${CHAIN_NAME}-${VERSION}" + echo ::set-output name=version::${VERSION} + echo ::set-output name=tags::${TAGS} + echo ::set-output name=created::$(date -u +'%Y-%m-%dT%H:%M:%SZ') + - + name: Set up Docker Buildx + uses: docker/setup-buildx-action@v2 + - + name: Login to DockerHub + uses: docker/login-action@v2 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_PASSWORD }} + - + name: Build and push + uses: docker/build-push-action@v3 + with: + context: . + push: true + tags: ${{ steps.prep.outputs.tags }} diff --git a/.github/workflows/lint-pr.yml b/.github/workflows/lint-pr.yml new file mode 100644 index 000000000..e4a92bb8c --- /dev/null +++ b/.github/workflows/lint-pr.yml @@ -0,0 +1,16 @@ +name: "Lint PR" + +on: + pull_request_target: + types: + - opened + - edited + - synchronize + +jobs: + main: + runs-on: ubuntu-latest + steps: + - uses: amannn/action-semantic-pull-request@v5.0.2 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} \ No newline at end of file diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 000000000..5965cde8a --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,129 @@ +## Unreleased +### Changes + +#### Parse Command +- ([\#492](https://github.com/forbole/bdjuno/pull/492)) Add parse command for periodic tasks: `x/bank` total supply, `x/distribution` community pool, `x/mint` inflation, `pricefeed` token price and price history, `x/staking` staking pool + +#### Upgrade Module +- ([\#467](https://github.com/forbole/bdjuno/pull/467)) Store software upgrade plan and refresh data at upgrade height + +#### Staking Module +- ([\#443](https://github.com/forbole/bdjuno/pull/443)) Remove tombstone status from staking module(already stored in slashing module) +- ([\#455](https://github.com/forbole/bdjuno/pull/455)) Added `unbonding_tokens` and `staked_not_bonded_tokens` values to staking pool table + +#### Gov Module +- ([\#461](https://github.com/forbole/bdjuno/pull/461)) Parse `x/gov` genesis with `genesisDoc.InitialHeight` instead of the hard-coded height 1 +- ([\#465](https://github.com/forbole/bdjuno/pull/465)) Get open proposal ids in deposit or voting period by block time instead of current time +- ([\#489](https://github.com/forbole/bdjuno/pull/489)) Remove block height foreign key from proposal_vote and proposal_deposit tables and add column timestamp +- ([\#499](https://github.com/forbole/bdjuno/pull/499)) Check if proposal has passed voting end time before marking it invalid + +#### Daily refetch +- ([\#454](https://github.com/forbole/bdjuno/pull/454)) Added `daily refetch` module to refetch missing blocks every day + +#### Hasura +- ([\#473](https://github.com/forbole/bdjuno/pull/473)) Improved Hasura permissions +- ([\#491](https://github.com/forbole/bdjuno/pull/491)) Add host address to Hasura actions + +### Dependencies +- ([\#462](https://github.com/forbole/bdjuno/pull/462)) Updated Juno to `v3.4.0` + +## Version v3.2.0 +### Changes +#### Mint module +- ([\#432](https://github.com/forbole/bdjuno/pull/432)) Update inflation rate when mint param change proposal is passed + +#### Gov module +- ([\#401](https://github.com/forbole/bdjuno/pull/401)) Update the proposal status to the latest in `bdjuno parse gov proposal [id]` command +- ([\#430](https://github.com/forbole/bdjuno/pull/430)) Update the proposals that have invalid status but can still be in voting or deposit periods + +### Dependencies +- ([\#440](https://github.com/forbole/bdjuno/pull/440)) Updated Juno to `v3.3.0` + +## Version v3.1.0 +### Dependencies +- Updated Juno to `v3.2.0` + +### Changes +#### Hasura +- ([\#395](https://github.com/forbole/bdjuno/pull/395)) Remove time label from Hasura Prometheus monitoring + +#### Bank module +- ([\#410](https://github.com/forbole/bdjuno/pull/410)) Change total supply query from only 1 page to all pages + +## Version v3.0.1 +### Dependencies +- Updated Juno to `v3.1.1` + +## Version v3.0.0 +### Notes +This version introduces breaking changes to `transaction` and `message` PostgreSQL tables. It implements PostgreSQL table partitioning to fix slow data retrieval from database that stores large amount of transactions and messages. Read more details about [migrating to v3.0.0](https://docs.bigdipper.live/cosmos-based/parser/migrations/v2.0.0) + +### New features +#### CLI +- ([\#356](https://github.com/forbole/bdjuno/pull/356)) Implemented `migrate` command to perform easy migration to higher BDJuno versions +- ([\#356](https://github.com/forbole/bdjuno/pull/356)) Updated `parse-genesis` command to parse genesis file without accessing the node + +#### Database +- ([\#356](https://github.com/forbole/bdjuno/pull/356)) Added PostgreSQL table partition to `transaction` and `message` table +- ([\#356](https://github.com/forbole/bdjuno/pull/356)) Created new `messages_by_address` function + +### Changes +#### Hasura +- ([\#377](https://github.com/forbole/bdjuno/pull/377)) Updated Hasura metadata +- ([\#381](https://github.com/forbole/bdjuno/pull/381)) Hasura actions are now a module + +### Dependencies +- ([\#356](https://github.com/forbole/bdjuno/pull/356)) Updated Juno to `v3.0.0` + +## Version v2.0.0 +### Notes +This version introduces breaking changes to certain address-specific data that is no longer periodically parsed from the node and stored in the database. Instead, the data is now obtained directly from the node when needed using Hasura Actions. Read more details about [migrating to v2.0.0](https://docs.bigdipper.live/cosmos-based/parser/migrations/v2.0.0) + +### New features +#### CLI +- ([\#257](https://github.com/forbole/bdjuno/pull/257)) Added `parse-genesis` command to parse the genesis file +- ([\#228](https://github.com/forbole/bdjuno/pull/228)) ([\#248](https://github.com/forbole/bdjuno/pull/248)) Added `fix` command: + - `auth`: fix vesting accounts details + - `blocks`: fix missing blocks and transactions from given start height + - `gov`: fix proposal with given proposal ID + - `staking`: fix validators info at the latest height + +#### Hasura Actions +- ([\#329](https://github.com/forbole/bdjuno/pull/329)) Implemented Hasura Actions service to replace periodic queries. If you are using GraphQL queries on your application, you should updated the old queries to use the below new actions instead. + Here's a list of data acquired through Hasura Actions: + - Of a certain address/delegator: + - Account balance (`action_account_balance`) + - Delegation rewards (`action_delegation_reward`) + - Delegator withdraw address (`action_delegator_withdraw_address`) + - Delegations (`action_delegation`) + - Total delegations amount (`action_delegation_total`) + - Unbonding delegations (`action_unbonding_delegation`) + - Total unbonding delegations amount (`action_unbonding_delegation_total`) + - Redelegations (`action_redelegation`) + - Of a certain validator: + - Commission amount (`action_validator_commission_amount`) + - Delegations to this validator (`action_validator_delegations`) + - Redelegations from this validator (`action_validator_redelegations_from`) + - Unbonding delegations (`action_validator_unbonding_delegations`) +- ([\#352](https://github.com/forbole/bdjuno/pull/352)) Added prometheus monitoring to hasura actions + +#### Local node support +- Added the support for `node.type = "local"` for parsing a static local node without the usage gRPC queries: [config reference](https://docs.bigdipper.live/cosmos-based/parser/config/config#node). + +#### Modules +- ([\#232](https://github.com/forbole/bdjuno/pull/232)) Updated the `x/auth` module support to handle and store `vesting accounts` and `vesting periods` inside the database. +- ([\#276](https://github.com/forbole/bdjuno/pull/276)) Added the support for the `x/feegrant` module (v0.44.x) + +### Changes + +#### CLI +- ([\#351](https://github.com/forbole/bdjuno/pull/351)) Fixed version display for `bdjuno version` cmd + +#### Database +- ([\#300](https://github.com/forbole/bdjuno/pull/300)) Changed `bonded_tokens` and `not_bonded_tokens` type inside `staking_pool` table to `TEXT` to avoid value overflow +- ([\#275](https://github.com/forbole/bdjuno/pull/275)) Added `tombstoned` column inside `validator_status` table +- ([\#232](https://github.com/forbole/bdjuno/pull/232)) Added `vesting_account` and `vesting_period` table +- ([\#276](https://github.com/forbole/bdjuno/pull/276)) Added `fee_grant_allowance` table (v0.44.x) + +#### Modules +- ([\#353](https://github.com/forbole/bdjuno/pull/353)) Removed the support for the `history` module \ No newline at end of file diff --git a/database/types/staking_validators.go b/database/types/staking_validators.go index 82861ad57..f9f60c32f 100644 --- a/database/types/staking_validators.go +++ b/database/types/staking_validators.go @@ -237,6 +237,8 @@ func (v ValidatorVotingPowerRow) Equal(w ValidatorVotingPowerRow) bool { // ValidatorStatusRow represents a single row of the validator_status table type ValidatorStatusRow struct { + Status int `db:"status"` + Jailed bool `db:"jailed"` ConsAddress string `db:"validator_address"` Status int `db:"status"` Height int64 `db:"height"` diff --git a/database/types/upgrade.go b/database/types/upgrade.go index 6cab3c096..c3abc7407 100644 --- a/database/types/upgrade.go +++ b/database/types/upgrade.go @@ -1,10 +1,10 @@ package types type SoftwareUpgradePlanRow struct { - PlanName string `db:"plan_name"` - Info string `db:"info"` ProposalID uint64 `db:"proposal_id"` + PlanName string `db:"plan_name"` UpgradeHeight int64 `db:"upgrade_height"` + Info string `db:"info"` Height int64 `db:"height"` } diff --git a/modules/actions/types/worker.go b/modules/actions/types/worker.go index 6ae9b864d..2b170c1be 100644 --- a/modules/actions/types/worker.go +++ b/modules/actions/types/worker.go @@ -95,16 +95,7 @@ func (w *ActionsWorker) handleError(writer http.ResponseWriter, path string, err // Start starts the worker func (w *ActionsWorker) Start(host string, port uint) { - server := &http.Server{ - Addr: fmt.Sprintf(":%d", port), - Handler: w.mux, - ReadTimeout: time.Second * 30, - ReadHeaderTimeout: time.Second * 5, - WriteTimeout: time.Second * 30, - IdleTimeout: time.Second * 30, - } - - err := server.ListenAndServe() + err := http.ListenAndServe(fmt.Sprintf("%s:%d", host, port), w.mux) if err != nil { panic(err) } diff --git a/modules/daily_refetch/handle_periodic_operations.go b/modules/daily_refetch/handle_periodic_operations.go index 36fdd5771..ef730d8ab 100644 --- a/modules/daily_refetch/handle_periodic_operations.go +++ b/modules/daily_refetch/handle_periodic_operations.go @@ -4,11 +4,13 @@ import ( "fmt" "time" - parsecmdtypes "github.com/forbole/juno/v3/cmd/parse/types" "github.com/forbole/juno/v3/parser" "github.com/forbole/juno/v3/types/config" + "github.com/go-co-op/gocron" "github.com/rs/zerolog/log" + + parsecmdtypes "github.com/forbole/juno/v3/cmd/parse/types" ) func (m *Module) RegisterPeriodicOperations(scheduler *gocron.Scheduler) error { @@ -38,7 +40,7 @@ func (m *Module) refetchMissingBlocks() error { if err != nil { return fmt.Errorf("error while getting block height from a day ago: %s", err) } - startHeight := blockHeightDayAgo.Height + var startHeight int64 = blockHeightDayAgo.Height missingBlocks := m.database.GetMissingBlocks(startHeight, latestBlock) @@ -65,4 +67,8 @@ func (m *Module) refetchMissingBlocks() error { } return nil +<<<<<<< HEAD +======= + +>>>>>>> 6823035056a955f797182700c6aeebb0f3a06864 } diff --git a/modules/staking/utils_staking_pool.go b/modules/staking/utils_staking_pool.go index 7819b9512..9164ff6ed 100644 --- a/modules/staking/utils_staking_pool.go +++ b/modules/staking/utils_staking_pool.go @@ -20,7 +20,8 @@ func (m *Module) GetStakingPool(height int64) (*types.Pool, error) { return nil, fmt.Errorf("error while getting validators list: %s", err) } - unbondingTokens := sdk.NewInt(0) + var unbondingTokens = sdk.NewInt(0) + for _, validator := range validatorsList { // get list of all unbonding delegations for each validator unbondingDelegations := m.getTotalUnbondingDelegationsFromValidator(height, validator.GetOperator()) diff --git a/types/config/config.go b/types/config/config.go index fb7127182..f77800ac5 100644 --- a/types/config/config.go +++ b/types/config/config.go @@ -13,6 +13,7 @@ import ( type Config struct { ActionsConfig *actions.Config `yaml:"actions"` JunoConfig junoconfig.Config `yaml:"-,inline"` + ActionsConfig *actions.Config `yaml:"actions"` } // NewConfig returns a new Config instance From 23498e83c68f1bad1aa7fb3dadc56a693c2bcf6d Mon Sep 17 00:00:00 2001 From: Filip Djokic Date: Mon, 5 Dec 2022 11:33:33 +0100 Subject: [PATCH 2/6] Remove unwanted upstream files --- .github/workflows/docker-build.yml | 51 ------------------------------ .github/workflows/lint-pr.yml | 16 ---------- 2 files changed, 67 deletions(-) delete mode 100644 .github/workflows/docker-build.yml delete mode 100644 .github/workflows/lint-pr.yml diff --git a/.github/workflows/docker-build.yml b/.github/workflows/docker-build.yml deleted file mode 100644 index 2196187e7..000000000 --- a/.github/workflows/docker-build.yml +++ /dev/null @@ -1,51 +0,0 @@ -name: docker-build - -on: - push: - branches: - - chains/*/* - -jobs: - docker: - runs-on: ubuntu-latest - steps: - - - name: Checkout - uses: actions/checkout@v3 - with: - fetch-depth: 0 - - - name: Set bdjuno chain_name - shell: bash - run: echo "CHAIN_NAME=$(echo ${GITHUB_REF#refs/heads/} | sed 's/\//_/g')" >> $GITHUB_ENV - - - name: Set bdjuno version - shell: bash - run: echo "GITHUB_VERSION=$(git describe --tags)" >> $GITHUB_ENV - - - name: Prepare tags - id: prep - run: | - DOCKER_IMAGE=${{ secrets.DOCKERHUB_BDJUNO_REPO }} - CHAIN_NAME="${{env.CHAIN_NAME}}" - VERSION="${{env.GITHUB_VERSION}}" - TAGS="${DOCKER_IMAGE}:${CHAIN_NAME}-${VERSION}" - echo ::set-output name=version::${VERSION} - echo ::set-output name=tags::${TAGS} - echo ::set-output name=created::$(date -u +'%Y-%m-%dT%H:%M:%SZ') - - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v2 - - - name: Login to DockerHub - uses: docker/login-action@v2 - with: - username: ${{ secrets.DOCKERHUB_USERNAME }} - password: ${{ secrets.DOCKERHUB_PASSWORD }} - - - name: Build and push - uses: docker/build-push-action@v3 - with: - context: . - push: true - tags: ${{ steps.prep.outputs.tags }} diff --git a/.github/workflows/lint-pr.yml b/.github/workflows/lint-pr.yml deleted file mode 100644 index e4a92bb8c..000000000 --- a/.github/workflows/lint-pr.yml +++ /dev/null @@ -1,16 +0,0 @@ -name: "Lint PR" - -on: - pull_request_target: - types: - - opened - - edited - - synchronize - -jobs: - main: - runs-on: ubuntu-latest - steps: - - uses: amannn/action-semantic-pull-request@v5.0.2 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} \ No newline at end of file From 333a48c615b96f0742c2579640a695aa9d2ae7cf Mon Sep 17 00:00:00 2001 From: Filip Djokic Date: Mon, 5 Dec 2022 11:35:46 +0100 Subject: [PATCH 3/6] Fix typo --- modules/daily_refetch/handle_periodic_operations.go | 4 ---- 1 file changed, 4 deletions(-) diff --git a/modules/daily_refetch/handle_periodic_operations.go b/modules/daily_refetch/handle_periodic_operations.go index ef730d8ab..54be4b40e 100644 --- a/modules/daily_refetch/handle_periodic_operations.go +++ b/modules/daily_refetch/handle_periodic_operations.go @@ -67,8 +67,4 @@ func (m *Module) refetchMissingBlocks() error { } return nil -<<<<<<< HEAD -======= - ->>>>>>> 6823035056a955f797182700c6aeebb0f3a06864 } From f93bf3c5f17013ff92d906d4026804247a786961 Mon Sep 17 00:00:00 2001 From: Filip Djokic Date: Wed, 7 Dec 2022 14:10:14 +0100 Subject: [PATCH 4/6] Fix proposal parsing issue --- database/types/staking_validators.go | 2 -- go.mod | 4 ++-- go.sum | 8 ++++---- modules/gov/handle_msg.go | 7 +++++++ types/config/config.go | 1 - 5 files changed, 13 insertions(+), 9 deletions(-) diff --git a/database/types/staking_validators.go b/database/types/staking_validators.go index f9f60c32f..82861ad57 100644 --- a/database/types/staking_validators.go +++ b/database/types/staking_validators.go @@ -237,8 +237,6 @@ func (v ValidatorVotingPowerRow) Equal(w ValidatorVotingPowerRow) bool { // ValidatorStatusRow represents a single row of the validator_status table type ValidatorStatusRow struct { - Status int `db:"status"` - Jailed bool `db:"jailed"` ConsAddress string `db:"validator_address"` Status int `db:"status"` Height int64 `db:"height"` diff --git a/go.mod b/go.mod index cd7699cd6..0aeb90922 100644 --- a/go.mod +++ b/go.mod @@ -3,9 +3,9 @@ module github.com/forbole/bdjuno/v3 go 1.18 require ( - github.com/cheqd/cheqd-node v0.7.3 + github.com/cheqd/cheqd-node v0.6.9 github.com/cosmos/cosmos-sdk v0.45.9 - github.com/cosmos/gaia/v7 v7.1.0 + github.com/cosmos/gaia/v7 v7.0.2 github.com/forbole/juno/v3 v3.4.0 github.com/go-co-op/gocron v1.18.0 github.com/gogo/protobuf v1.3.3 diff --git a/go.sum b/go.sum index 71978f9b9..2cdc936ef 100644 --- a/go.sum +++ b/go.sum @@ -111,8 +111,8 @@ github.com/cespare/xxhash v1.1.0/go.mod h1:XrSqR1VqqWfGrhpAt58auRo0WTKS1nRRg3ghf github.com/cespare/xxhash/v2 v2.1.1/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= github.com/cespare/xxhash/v2 v2.1.2 h1:YRXhKfTDauu4ajMg1TPgFO5jnlC2HCbmLXMcTG5cbYE= github.com/cespare/xxhash/v2 v2.1.2/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= -github.com/cheqd/cheqd-node v0.7.3 h1:ELllyb+4HCCEsBnAEruQeJD292jP2CcfTlmXDTZI2vA= -github.com/cheqd/cheqd-node v0.7.3/go.mod h1:QssvmpF/YRCxb8mkxAAZOuGq5wbnkYdQlDu0LILQNV0= +github.com/cheqd/cheqd-node v0.6.9 h1:Yv1Ga0J6EVibgesYEgSHWB7+5aKZit2ZNjBvb+1g13c= +github.com/cheqd/cheqd-node v0.6.9/go.mod h1:qleVcKI+Dgj2e1Dug1wRriOrjytlrz2YKh5BrSP0quE= github.com/cheqd/cosmos-sdk v0.45.9-cheqd-tag h1:K1eIYxqaQ5aFSVAnPNOeU12U0B3mStYN0vrawMoUkCY= github.com/cheqd/cosmos-sdk v0.45.9-cheqd-tag/go.mod h1:Z5M4TX7PsHNHlF/1XanI2DIpORQ+Q/st7oaeufEjnvU= github.com/chzyer/logex v1.1.10/go.mod h1:+Ywpsq7O8HXn0nuIou7OrIPyXbp3wmkHB+jjWRnGsAI= @@ -140,8 +140,8 @@ github.com/cosmos/btcutil v1.0.4 h1:n7C2ngKXo7UC9gNyMNLbzqz7Asuf+7Qv4gnX/rOdQ44= github.com/cosmos/btcutil v1.0.4/go.mod h1:Ffqc8Hn6TJUdDgHBwIZLtrLQC1KdJ9jGJl/TvgUaxbU= github.com/cosmos/cosmos-sdk/ics23/go v0.8.0 h1:iKclrn3YEOwk4jQHT2ulgzuXyxmzmPczUalMwW4XH9k= github.com/cosmos/cosmos-sdk/ics23/go v0.8.0/go.mod h1:2a4dBq88TUoqoWAU5eu0lGvpFP3wWDPgdHPargtyw30= -github.com/cosmos/gaia/v7 v7.1.0 h1:vS8AlJaI+tcODc+lsxGDZVxfVR329x06fEbXXjedidw= -github.com/cosmos/gaia/v7 v7.1.0/go.mod h1:NYNOpx24P02rjsSdZxirTlYI+H9R/DCfpDmRm4PND1w= +github.com/cosmos/gaia/v7 v7.0.2 h1:tn4wZk6jt0uqDL7z/V2Bs6NVd+gtsX+4BsQ94wPB8xw= +github.com/cosmos/gaia/v7 v7.0.2/go.mod h1:RDJGBlI+gGnWjYAy6LFM/Dtor5ZSo0Z/BYm3HA+/RWE= github.com/cosmos/go-bip39 v0.0.0-20180819234021-555e2067c45d/go.mod h1:tSxLoYXyBmiFeKpvmq4dzayMdCjCnu8uqmCysIGBT2Y= github.com/cosmos/go-bip39 v1.0.0 h1:pcomnQdrdH22njcAatO0yWojsUnCO3y2tNoV1cb6hHY= github.com/cosmos/go-bip39 v1.0.0/go.mod h1:RNJv0H/pOIVgxw6KS7QeX2a0Uo0aKUlfhZ4xuwvCdJw= diff --git a/modules/gov/handle_msg.go b/modules/gov/handle_msg.go index ce5c72a71..8acf841a4 100644 --- a/modules/gov/handle_msg.go +++ b/modules/gov/handle_msg.go @@ -57,6 +57,13 @@ func (m *Module) handleMsgSubmitProposal(tx *juno.Tx, index int, msg *govtypes.M return fmt.Errorf("error while getting proposal: %s", err) } + // Unpack the content + var content govtypes.Content + err = m.cdc.UnpackAny(proposal.Content, &content) + if err != nil { + return fmt.Errorf("error while unpacking proposal content: %s", err) + } + // Store the proposal proposalObj := types.NewProposal( proposal.ProposalId, diff --git a/types/config/config.go b/types/config/config.go index f77800ac5..f36154ed3 100644 --- a/types/config/config.go +++ b/types/config/config.go @@ -11,7 +11,6 @@ import ( // Config represents the BDJuno configuration type Config struct { - ActionsConfig *actions.Config `yaml:"actions"` JunoConfig junoconfig.Config `yaml:"-,inline"` ActionsConfig *actions.Config `yaml:"actions"` } From 0781211c50c8e9c741157f45f65368fe417a6332 Mon Sep 17 00:00:00 2001 From: Filip Djokic Date: Wed, 7 Dec 2022 14:15:51 +0100 Subject: [PATCH 5/6] Run gofumpt --- database/gov.go | 1 - database/gov_test.go | 113 +++++++++++++------------- modules/gov/handle_msg.go | 3 +- modules/staking/utils_staking_pool.go | 4 +- 4 files changed, 59 insertions(+), 62 deletions(-) diff --git a/database/gov.go b/database/gov.go index 426af410b..a489414fa 100644 --- a/database/gov.go +++ b/database/gov.go @@ -403,7 +403,6 @@ WHERE proposal_validator_status_snapshot.height <= excluded.height` // SaveSoftwareUpgradePlan allows to save the given software upgrade plan with its proposal id func (db *Db) SaveSoftwareUpgradePlan(proposalID uint64, plan upgradetypes.Plan, height int64) error { - stmt := ` INSERT INTO software_upgrade_plan(proposal_id, plan_name, upgrade_height, info, height) VALUES ($1, $2, $3, $4, $5) diff --git a/database/gov_test.go b/database/gov_test.go index 63fd0faa5..2b2fd52ce 100644 --- a/database/gov_test.go +++ b/database/gov_test.go @@ -84,10 +84,10 @@ func (suite *DbTestSuite) getProposalRow(id int) types.Proposal { proposalType, govtypes.NewTextProposal(title, description), govtypes.StatusPassed.String(), - time.Date(2020, 1, 1, 00, 00, 00, 000, time.UTC), - time.Date(2020, 1, 1, 01, 00, 00, 000, time.UTC), - time.Date(2020, 1, 1, 02, 00, 00, 000, time.UTC), - time.Date(2020, 1, 1, 03, 00, 00, 000, time.UTC), + time.Date(2020, 1, 1, 0o0, 0o0, 0o0, 0o00, time.UTC), + time.Date(2020, 1, 1, 0o1, 0o0, 0o0, 0o00, time.UTC), + time.Date(2020, 1, 1, 0o2, 0o0, 0o0, 0o00, time.UTC), + time.Date(2020, 1, 1, 0o3, 0o0, 0o0, 0o00, time.UTC), proposer.String(), ) @@ -123,10 +123,10 @@ func (suite *DbTestSuite) TestBigDipperDb_SaveProposals() { "proposalType", content1, govtypes.StatusDepositPeriod.String(), - time.Date(2020, 1, 1, 00, 00, 00, 000, time.UTC), - time.Date(2020, 1, 1, 01, 00, 00, 000, time.UTC), - time.Date(2020, 1, 1, 02, 00, 00, 000, time.UTC), - time.Date(2020, 1, 1, 03, 00, 00, 000, time.UTC), + time.Date(2020, 1, 1, 0o0, 0o0, 0o0, 0o00, time.UTC), + time.Date(2020, 1, 1, 0o1, 0o0, 0o0, 0o00, time.UTC), + time.Date(2020, 1, 1, 0o2, 0o0, 0o0, 0o00, time.UTC), + time.Date(2020, 1, 1, 0o3, 0o0, 0o0, 0o00, time.UTC), proposer1.String(), ), types.NewProposal( @@ -135,10 +135,10 @@ func (suite *DbTestSuite) TestBigDipperDb_SaveProposals() { "proposalType1", content2, govtypes.StatusPassed.String(), - time.Date(2020, 1, 2, 00, 00, 00, 000, time.UTC), - time.Date(2020, 1, 2, 01, 00, 00, 000, time.UTC), - time.Date(2020, 1, 2, 02, 00, 00, 000, time.UTC), - time.Date(2020, 1, 2, 03, 00, 00, 000, time.UTC), + time.Date(2020, 1, 2, 0o0, 0o0, 0o0, 0o00, time.UTC), + time.Date(2020, 1, 2, 0o1, 0o0, 0o0, 0o00, time.UTC), + time.Date(2020, 1, 2, 0o2, 0o0, 0o0, 0o00, time.UTC), + time.Date(2020, 1, 2, 0o3, 0o0, 0o0, 0o00, time.UTC), proposer2.String(), ), } @@ -158,10 +158,10 @@ func (suite *DbTestSuite) TestBigDipperDb_SaveProposals() { "title", "description", suite.encodeProposalContent(content1), - time.Date(2020, 1, 1, 00, 00, 00, 000, time.UTC), - time.Date(2020, 1, 1, 01, 00, 00, 000, time.UTC), - time.Date(2020, 1, 1, 02, 00, 00, 000, time.UTC), - time.Date(2020, 1, 1, 03, 00, 00, 000, time.UTC), + time.Date(2020, 1, 1, 0o0, 0o0, 0o0, 0o00, time.UTC), + time.Date(2020, 1, 1, 0o1, 0o0, 0o0, 0o00, time.UTC), + time.Date(2020, 1, 1, 0o2, 0o0, 0o0, 0o00, time.UTC), + time.Date(2020, 1, 1, 0o3, 0o0, 0o0, 0o00, time.UTC), proposer1.String(), govtypes.StatusDepositPeriod.String(), ), @@ -172,10 +172,10 @@ func (suite *DbTestSuite) TestBigDipperDb_SaveProposals() { "title1", "description1", suite.encodeProposalContent(content2), - time.Date(2020, 1, 2, 00, 00, 00, 000, time.UTC), - time.Date(2020, 1, 2, 01, 00, 00, 000, time.UTC), - time.Date(2020, 1, 2, 02, 00, 00, 000, time.UTC), - time.Date(2020, 1, 2, 03, 00, 00, 000, time.UTC), + time.Date(2020, 1, 2, 0o0, 0o0, 0o0, 0o00, time.UTC), + time.Date(2020, 1, 2, 0o1, 0o0, 0o0, 0o00, time.UTC), + time.Date(2020, 1, 2, 0o2, 0o0, 0o0, 0o00, time.UTC), + time.Date(2020, 1, 2, 0o3, 0o0, 0o0, 0o00, time.UTC), proposer2.String(), govtypes.StatusPassed.String(), ), @@ -194,10 +194,10 @@ func (suite *DbTestSuite) TestBigDipperDb_GetProposal() { "proposalType", content, govtypes.StatusDepositPeriod.String(), - time.Date(2020, 1, 1, 00, 00, 00, 000, time.UTC), - time.Date(2020, 1, 1, 01, 00, 00, 000, time.UTC), - time.Date(2020, 1, 1, 02, 00, 00, 000, time.UTC), - time.Date(2020, 1, 1, 03, 00, 00, 000, time.UTC), + time.Date(2020, 1, 1, 0o0, 0o0, 0o0, 0o00, time.UTC), + time.Date(2020, 1, 1, 0o1, 0o0, 0o0, 0o00, time.UTC), + time.Date(2020, 1, 1, 0o2, 0o0, 0o0, 0o00, time.UTC), + time.Date(2020, 1, 1, 0o3, 0o0, 0o0, 0o00, time.UTC), proposer.String(), ) input := []types.Proposal{proposal} @@ -223,10 +223,10 @@ func (suite *DbTestSuite) TestBigDipperDb_GetOpenProposalsIds() { "proposalType1", content2, types.ProposalStatusInvalid, - time.Date(2020, 1, 2, 00, 00, 00, 000, time.UTC), - time.Date(2020, 1, 2, 01, 00, 00, 000, time.UTC), - time.Date(2020, 1, 2, 02, 00, 00, 000, time.UTC), - time.Date(2020, 1, 2, 03, 00, 00, 000, time.UTC), + time.Date(2020, 1, 2, 0o0, 0o0, 0o0, 0o00, time.UTC), + time.Date(2020, 1, 2, 0o1, 0o0, 0o0, 0o00, time.UTC), + time.Date(2020, 1, 2, 0o2, 0o0, 0o0, 0o00, time.UTC), + time.Date(2020, 1, 2, 0o3, 0o0, 0o0, 0o00, time.UTC), proposer2.String(), ) @@ -237,10 +237,10 @@ func (suite *DbTestSuite) TestBigDipperDb_GetOpenProposalsIds() { "proposalType", content1, govtypes.StatusVotingPeriod.String(), - time.Date(2020, 1, 1, 00, 00, 00, 000, time.UTC), - time.Date(2020, 1, 1, 01, 00, 00, 000, time.UTC), - time.Date(2020, 1, 1, 02, 00, 00, 000, time.UTC), - time.Date(2020, 1, 1, 03, 00, 00, 000, time.UTC), + time.Date(2020, 1, 1, 0o0, 0o0, 0o0, 0o00, time.UTC), + time.Date(2020, 1, 1, 0o1, 0o0, 0o0, 0o00, time.UTC), + time.Date(2020, 1, 1, 0o2, 0o0, 0o0, 0o00, time.UTC), + time.Date(2020, 1, 1, 0o3, 0o0, 0o0, 0o00, time.UTC), proposer1.String(), ), types.NewProposal( @@ -249,10 +249,10 @@ func (suite *DbTestSuite) TestBigDipperDb_GetOpenProposalsIds() { "proposalType", content1, govtypes.StatusDepositPeriod.String(), - time.Date(2020, 1, 1, 00, 00, 00, 000, time.UTC), - time.Date(2020, 1, 1, 01, 00, 00, 000, time.UTC), - time.Date(2020, 1, 1, 02, 00, 00, 000, time.UTC), - time.Date(2020, 1, 1, 03, 00, 00, 000, time.UTC), + time.Date(2020, 1, 1, 0o0, 0o0, 0o0, 0o00, time.UTC), + time.Date(2020, 1, 1, 0o1, 0o0, 0o0, 0o00, time.UTC), + time.Date(2020, 1, 1, 0o2, 0o0, 0o0, 0o00, time.UTC), + time.Date(2020, 1, 1, 0o3, 0o0, 0o0, 0o00, time.UTC), proposer1.String(), ), types.NewProposal( @@ -261,10 +261,10 @@ func (suite *DbTestSuite) TestBigDipperDb_GetOpenProposalsIds() { "proposalType1", content2, govtypes.StatusPassed.String(), - time.Date(2020, 1, 2, 00, 00, 00, 000, time.UTC), - time.Date(2020, 1, 2, 01, 00, 00, 000, time.UTC), - time.Date(2020, 1, 2, 02, 00, 00, 000, time.UTC), - time.Date(2020, 1, 2, 03, 00, 00, 000, time.UTC), + time.Date(2020, 1, 2, 0o0, 0o0, 0o0, 0o00, time.UTC), + time.Date(2020, 1, 2, 0o1, 0o0, 0o0, 0o00, time.UTC), + time.Date(2020, 1, 2, 0o2, 0o0, 0o0, 0o00, time.UTC), + time.Date(2020, 1, 2, 0o3, 0o0, 0o0, 0o00, time.UTC), proposer2.String(), ), types.NewProposal( @@ -273,10 +273,10 @@ func (suite *DbTestSuite) TestBigDipperDb_GetOpenProposalsIds() { "proposalType1", content2, govtypes.StatusRejected.String(), - time.Date(2020, 1, 2, 00, 00, 00, 000, time.UTC), - time.Date(2020, 1, 2, 01, 00, 00, 000, time.UTC), - time.Date(2020, 1, 2, 02, 00, 00, 000, time.UTC), - time.Date(2020, 1, 2, 03, 00, 00, 000, time.UTC), + time.Date(2020, 1, 2, 0o0, 0o0, 0o0, 0o00, time.UTC), + time.Date(2020, 1, 2, 0o1, 0o0, 0o0, 0o00, time.UTC), + time.Date(2020, 1, 2, 0o2, 0o0, 0o0, 0o00, time.UTC), + time.Date(2020, 1, 2, 0o3, 0o0, 0o0, 0o00, time.UTC), proposer2.String(), ), invalidProposal, @@ -299,8 +299,8 @@ func (suite *DbTestSuite) TestBigDipperDb_UpdateProposal() { update := types.NewProposalUpdate( proposal.ProposalID, govtypes.StatusPassed.String(), - time.Date(2020, 1, 1, 00, 00, 00, 000, time.UTC), - time.Date(2020, 1, 1, 01, 00, 00, 000, time.UTC), + time.Date(2020, 1, 1, 0o0, 0o0, 0o0, 0o00, time.UTC), + time.Date(2020, 1, 1, 0o1, 0o0, 0o0, 0o00, time.UTC), ) err = suite.database.UpdateProposal(update) @@ -315,8 +315,8 @@ func (suite *DbTestSuite) TestBigDipperDb_UpdateProposal() { suite.encodeProposalContent(proposal.Content), proposal.SubmitTime, proposal.DepositEndTime, - time.Date(2020, 1, 1, 00, 00, 00, 000, time.UTC), - time.Date(2020, 1, 1, 01, 00, 00, 000, time.UTC), + time.Date(2020, 1, 1, 0o0, 0o0, 0o0, 0o00, time.UTC), + time.Date(2020, 1, 1, 0o1, 0o0, 0o0, 0o00, time.UTC), proposer.String(), govtypes.StatusPassed.String(), ) @@ -348,9 +348,9 @@ func (suite *DbTestSuite) TestBigDipperDb_SaveDeposits() { depositor3 := suite.getAccount("cosmos1gyds87lg3m52hex9yqta2mtwzw89pfukx3jl7g") amount3 := sdk.NewCoins(sdk.NewCoin("desmos", sdk.NewInt(50000))) - timestamp1 := time.Date(2020, 1, 1, 15, 00, 00, 000, time.UTC) - timestamp2 := time.Date(2020, 1, 1, 16, 00, 00, 000, time.UTC) - timestamp3 := time.Date(2020, 1, 1, 17, 00, 00, 000, time.UTC) + timestamp1 := time.Date(2020, 1, 1, 15, 0o0, 0o0, 0o00, time.UTC) + timestamp2 := time.Date(2020, 1, 1, 16, 0o0, 0o0, 0o00, time.UTC) + timestamp3 := time.Date(2020, 1, 1, 17, 0o0, 0o0, 0o00, time.UTC) deposit := []types.Deposit{ types.NewDeposit(proposal.ProposalID, depositor.String(), amount, timestamp1, 10), @@ -414,7 +414,7 @@ func (suite *DbTestSuite) TestBigDipperDb_SaveVote() { proposal := suite.getProposalRow(1) voter := suite.getAccount("cosmos1z4hfrxvlgl4s8u4n5ngjcw8kdqrcv43599amxs") - timestamp := time.Date(2020, 1, 1, 15, 00, 00, 000, time.UTC) + timestamp := time.Date(2020, 1, 1, 15, 0o0, 0o0, 0o00, time.UTC) vote := types.NewVote(1, voter.String(), govtypes.OptionYes, timestamp, 1) err := suite.database.SaveVote(vote) @@ -639,7 +639,7 @@ func (suite *DbTestSuite) TestBigDipperDb_SaveProposalValidatorsStatusesSnapshot // ---------------------------------------------------------------------------------------------------------------- // Save snapshots - var snapshots = []types.ProposalValidatorStatusSnapshot{ + snapshots := []types.ProposalValidatorStatusSnapshot{ types.NewProposalValidatorStatusSnapshot( 1, validator1.GetConsAddr(), @@ -838,7 +838,7 @@ func (suite *DbTestSuite) TestBigDipperDb_SaveSoftwareUpgradePlan() { // ---------------------------------------------------------------------------------------------------------------- // Save software upgrade plan at height 10 with upgrade height at 100 - var plan = upgradetypes.Plan{ + plan := upgradetypes.Plan{ Name: "name", Height: 100, Info: "info", @@ -917,7 +917,7 @@ func (suite *DbTestSuite) TestBigDipperDb_DeleteSoftwareUpgradePlan() { _ = suite.getProposalRow(1) // Save software upgrade plan at height 10 with upgrade height at 100 - var plan = upgradetypes.Plan{ + plan := upgradetypes.Plan{ Name: "name", Height: 100, Info: "info", @@ -934,14 +934,13 @@ func (suite *DbTestSuite) TestBigDipperDb_DeleteSoftwareUpgradePlan() { err = suite.database.Sqlx.Select(&rows, `SELECT * FROM software_upgrade_plan`) suite.Require().NoError(err) suite.Require().Len(rows, 0) - } func (suite *DbTestSuite) TestBigDipperDb_CheckSoftwareUpgradePlan() { _ = suite.getProposalRow(1) // Save software upgrade plan at height 10 with upgrade height at 100 - var plan = upgradetypes.Plan{ + plan := upgradetypes.Plan{ Name: "name", // the Height here is the upgrade height Height: 100, diff --git a/modules/gov/handle_msg.go b/modules/gov/handle_msg.go index 8acf841a4..0397c020e 100644 --- a/modules/gov/handle_msg.go +++ b/modules/gov/handle_msg.go @@ -2,9 +2,8 @@ package gov import ( "fmt" - "time" - "strconv" + "time" "github.com/forbole/bdjuno/v3/types" diff --git a/modules/staking/utils_staking_pool.go b/modules/staking/utils_staking_pool.go index 9164ff6ed..96b2c92fb 100644 --- a/modules/staking/utils_staking_pool.go +++ b/modules/staking/utils_staking_pool.go @@ -20,7 +20,7 @@ func (m *Module) GetStakingPool(height int64) (*types.Pool, error) { return nil, fmt.Errorf("error while getting validators list: %s", err) } - var unbondingTokens = sdk.NewInt(0) + unbondingTokens := sdk.NewInt(0) for _, validator := range validatorsList { // get list of all unbonding delegations for each validator @@ -45,7 +45,7 @@ func (m *Module) GetStakingPool(height int64) (*types.Pool, error) { func (m *Module) getTotalUnbondingDelegationsFromValidator(height int64, valOperatorAddress string) []stakingtypes.UnbondingDelegation { var unbondingDelegations []stakingtypes.UnbondingDelegation var nextKey []byte - var stop = false + stop := false for !stop { res, err := m.source.GetUnbondingDelegationsFromValidator(height, valOperatorAddress, From fb0b8e57df98e771d8422d2aa7b3b2a91fce392a Mon Sep 17 00:00:00 2001 From: Filip Djokic Date: Wed, 7 Dec 2022 14:40:00 +0100 Subject: [PATCH 6/6] Fix linting issues --- modules/actions/types/worker.go | 11 ++++++++++- modules/daily_refetch/handle_periodic_operations.go | 2 +- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/modules/actions/types/worker.go b/modules/actions/types/worker.go index 2b170c1be..6ae9b864d 100644 --- a/modules/actions/types/worker.go +++ b/modules/actions/types/worker.go @@ -95,7 +95,16 @@ func (w *ActionsWorker) handleError(writer http.ResponseWriter, path string, err // Start starts the worker func (w *ActionsWorker) Start(host string, port uint) { - err := http.ListenAndServe(fmt.Sprintf("%s:%d", host, port), w.mux) + server := &http.Server{ + Addr: fmt.Sprintf(":%d", port), + Handler: w.mux, + ReadTimeout: time.Second * 30, + ReadHeaderTimeout: time.Second * 5, + WriteTimeout: time.Second * 30, + IdleTimeout: time.Second * 30, + } + + err := server.ListenAndServe() if err != nil { panic(err) } diff --git a/modules/daily_refetch/handle_periodic_operations.go b/modules/daily_refetch/handle_periodic_operations.go index 54be4b40e..b54489e6e 100644 --- a/modules/daily_refetch/handle_periodic_operations.go +++ b/modules/daily_refetch/handle_periodic_operations.go @@ -40,7 +40,7 @@ func (m *Module) refetchMissingBlocks() error { if err != nil { return fmt.Errorf("error while getting block height from a day ago: %s", err) } - var startHeight int64 = blockHeightDayAgo.Height + startHeight := blockHeightDayAgo.Height missingBlocks := m.database.GetMissingBlocks(startHeight, latestBlock)