Skip to content

Commit

Permalink
Merge branch 'cosmos/v0.44.x' of https://github.com/forbole/bdjuno in…
Browse files Browse the repository at this point in the history
…to chains/emoney/mainnet
  • Loading branch information
MonikaCat committed Mar 20, 2023
2 parents e4b22e2 + 26aba2e commit ebd2a0d
Show file tree
Hide file tree
Showing 111 changed files with 1,473 additions and 393 deletions.
17 changes: 13 additions & 4 deletions .github/workflows/docker-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,19 +33,28 @@ jobs:
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: Determine Dockerfile to use
run: |
if [[ -f Dockerfile.cosmwasm ]]; then
export DOCKERFILE=Dockerfile.cosmwasm
else
export DOCKERFILE=Dockerfile.default
fi
echo "DOCKERFILE=${DOCKERFILE}" >> $GITHUB_ENV
-
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_TOKEN }}
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
-
name: Build and push
uses: docker/build-push-action@v3
uses: docker/build-push-action@v4
with:
context: .
file: "./${{ env.DOCKERFILE }}"
push: true
tags: ${{ steps.prep.outputs.tags }}
tags: ${{ steps.prep.outputs.tags }}
2 changes: 1 addition & 1 deletion .github/workflows/lint-pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,6 @@ jobs:
main:
runs-on: ubuntu-latest
steps:
- uses: amannn/action-semantic-pull-request@v4.5.0
- uses: amannn/action-semantic-pull-request@v5.2.0
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
6 changes: 3 additions & 3 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,15 @@ jobs:
timeout-minutes: 6
steps:
- uses: actions/checkout@v3
- uses: technote-space/[email protected].0
- uses: technote-space/[email protected].2
with:
SUFFIX_FILTER: |
.go
.mod
.sum
- uses: golangci/golangci-lint-action@v3.2.0
- uses: golangci/golangci-lint-action@v3.4.0
with:
version: v1.28
version: v1.50.1
args: --timeout 10m
github-token: ${{ secrets.GITHUB_TOKEN }}
if: "env.GIT_DIFF != ''"
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ jobs:
- name: Checkout
uses: actions/checkout@v3
- name: Setup Go
uses: actions/setup-go@v3
uses: actions/setup-go@v4
with:
go-version: 1.17
- name: Test & Create coverage report
Expand Down
33 changes: 33 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,36 @@
## Unreleased
### Changes

#### CI
- ([\#508](https://github.com/forbole/bdjuno/pull/508)) Upgrade workflow golangci version to v1.50.1

#### 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
- ([\#523](https://github.com/forbole/bdjuno/pull/523)) Update proposal snapshots handling on block

#### 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
Expand Down
22 changes: 22 additions & 0 deletions Dockerfile.cosmwasm
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@


FROM golang:1.18-alpine AS builder
RUN apk update && apk add --no-cache make git
WORKDIR /go/src/github.com/forbole/bdjuno
COPY . ./

RUN apk update && apk add --no-cache ca-certificates build-base git
ADD https://github.com/CosmWasm/wasmvm/releases/download/v1.1.1/libwasmvm_muslc.aarch64.a /lib/libwasmvm_muslc.aarch64.a
ADD https://github.com/CosmWasm/wasmvm/releases/download/v1.1.1/libwasmvm_muslc.x86_64.a /lib/libwasmvm_muslc.x86_64.a
RUN sha256sum /lib/libwasmvm_muslc.aarch64.a | grep 9ecb037336bd56076573dc18c26631a9d2099a7f2b40dc04b6cae31ffb4c8f9a
RUN sha256sum /lib/libwasmvm_muslc.x86_64.a | grep 6e4de7ba9bad4ae9679c7f9ecf7e283dd0160e71567c6a7be6ae47c81ebe7f32
## Copy the library you want to the final location that will be found by the linker flag `-lwasmvm_muslc`
RUN cp /lib/libwasmvm_muslc.$(uname -m).a /lib/libwasmvm_muslc.a
RUN go mod download
RUN LINK_STATICALLY=true BUILD_TAGS="muslc" make build

FROM alpine:latest
RUN apk update && apk add --no-cache ca-certificates build-base
WORKDIR /bdjuno
COPY --from=builder /go/src/github.com/forbole/bdjuno/build/bdjuno /usr/bin/bdjuno
CMD [ "bdjuno" ]
4 changes: 2 additions & 2 deletions Dockerfile → Dockerfile.default
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM golang:1.16-alpine AS builder
FROM golang:1.18-alpine AS builder
RUN apk update && apk add --no-cache make git
WORKDIR /go/src/github.com/forbole/bdjuno
COPY . ./
Expand All @@ -8,4 +8,4 @@ RUN make build
FROM alpine:latest
WORKDIR /bdjuno
COPY --from=builder /go/src/github.com/forbole/bdjuno/build/bdjuno /usr/bin/bdjuno
CMD [ "bdjuno" ]
CMD [ "bdjuno" ]
8 changes: 8 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,14 @@ LD_FLAGS = -X github.com/forbole/juno/v3/cmd.Version=$(VERSION) \
-X github.com/forbole/juno/v3/cmd.Commit=$(COMMIT)
BUILD_FLAGS := -ldflags '$(LD_FLAGS)'

ifeq ($(LINK_STATICALLY),true)
LD_FLAGS += -linkmode=external -extldflags "-Wl,-z,muldefs -static"
endif

build_tags += $(BUILD_TAGS)
build_tags := $(strip $(build_tags))

BUILD_FLAGS := -ldflags '$(LD_FLAGS)' -tags "$(build_tags)"

###############################################################################
### Build ###
Expand Down
2 changes: 1 addition & 1 deletion cmd/migrate/v3/migrate.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ func migrateConfig() (Config, error) {
}

if cfg.Actions == nil {
cfg.Actions = actions.NewConfig(3000, nil)
cfg.Actions = actions.NewConfig("127.0.0.1", 3000, nil)
}

return cfg, nil
Expand Down
20 changes: 20 additions & 0 deletions cmd/parse/bank/cmd.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package bank

import (
parsecmdtypes "github.com/forbole/juno/v3/cmd/parse/types"
"github.com/spf13/cobra"
)

// NewBankCmd returns the Cobra command allowing to fix various things related to the x/bank module
func NewBankCmd(parseConfig *parsecmdtypes.Config) *cobra.Command {
cmd := &cobra.Command{
Use: "bank",
Short: "Fix things related to the x/bank module",
}

cmd.AddCommand(
supplyCmd(parseConfig),
)

return cmd
}
46 changes: 46 additions & 0 deletions cmd/parse/bank/supply.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
package bank

import (
"fmt"

modulestypes "github.com/forbole/bdjuno/v3/modules/types"

parsecmdtypes "github.com/forbole/juno/v3/cmd/parse/types"
"github.com/forbole/juno/v3/types/config"
"github.com/spf13/cobra"

"github.com/forbole/bdjuno/v3/database"
"github.com/forbole/bdjuno/v3/modules/bank"
)

// supplyCmd returns the Cobra command allowing to refresh x/bank total supply
func supplyCmd(parseConfig *parsecmdtypes.Config) *cobra.Command {
return &cobra.Command{
Use: "supply",
Short: "Refresh total supply",
RunE: func(cmd *cobra.Command, args []string) error {
parseCtx, err := parsecmdtypes.GetParserContext(config.Cfg, parseConfig)
if err != nil {
return err
}

sources, err := modulestypes.BuildSources(config.Cfg.Node, parseCtx.EncodingConfig)
if err != nil {
return err
}

// Get the database
db := database.Cast(parseCtx.Database)

// Build bank module
bankModule := bank.NewModule(nil, sources.BankSource, parseCtx.EncodingConfig.Marshaler, db)

err = bankModule.UpdateSupply()
if err != nil {
return fmt.Errorf("error while getting latest bank supply: %s", err)
}

return nil
},
}
}
20 changes: 20 additions & 0 deletions cmd/parse/distribution/cmd.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package distribution

import (
parsecmdtypes "github.com/forbole/juno/v3/cmd/parse/types"
"github.com/spf13/cobra"
)

// NewDistributionCmd returns the Cobra command allowing to fix various things related to the x/distribution module
func NewDistributionCmd(parseConfig *parsecmdtypes.Config) *cobra.Command {
cmd := &cobra.Command{
Use: "distribution",
Short: "Fix things related to the x/distribution module",
}

cmd.AddCommand(
communityPoolCmd(parseConfig),
)

return cmd
}
45 changes: 45 additions & 0 deletions cmd/parse/distribution/communitypool.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
package distribution

import (
"fmt"

parsecmdtypes "github.com/forbole/juno/v3/cmd/parse/types"
"github.com/forbole/juno/v3/types/config"
"github.com/spf13/cobra"

"github.com/forbole/bdjuno/v3/database"
"github.com/forbole/bdjuno/v3/modules/distribution"
modulestypes "github.com/forbole/bdjuno/v3/modules/types"
)

// communityPoolCmd returns the Cobra command allowing to refresh community pool
func communityPoolCmd(parseConfig *parsecmdtypes.Config) *cobra.Command {
return &cobra.Command{
Use: "community-pool",
Short: "Refresh community pool",
RunE: func(cmd *cobra.Command, args []string) error {
parseCtx, err := parsecmdtypes.GetParserContext(config.Cfg, parseConfig)
if err != nil {
return err
}

sources, err := modulestypes.BuildSources(config.Cfg.Node, parseCtx.EncodingConfig)
if err != nil {
return err
}

// Get the database
db := database.Cast(parseCtx.Database)

// Build distribution module
distrModule := distribution.NewModule(sources.DistrSource, parseCtx.EncodingConfig.Marshaler, db)

err = distrModule.GetLatestCommunityPool()
if err != nil {
return fmt.Errorf("error while updating community pool: %s", err)
}

return nil
},
}
}
5 changes: 3 additions & 2 deletions cmd/parse/gov/proposal.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"encoding/hex"
"fmt"
"strconv"
"time"

modulestypes "github.com/forbole/bdjuno/v3/modules/types"
"github.com/rs/zerolog/log"
Expand Down Expand Up @@ -52,7 +53,7 @@ func proposalCmd(parseConfig *parsecmdtypes.Config) *cobra.Command {
distrModule := distribution.NewModule(sources.DistrSource, parseCtx.EncodingConfig.Marshaler, db)
mintModule := mint.NewModule(sources.MintSource, parseCtx.EncodingConfig.Marshaler, db)
slashingModule := slashing.NewModule(sources.SlashingSource, parseCtx.EncodingConfig.Marshaler, db)
stakingModule := staking.NewModule(sources.StakingSource, slashingModule, parseCtx.EncodingConfig.Marshaler, db)
stakingModule := staking.NewModule(sources.StakingSource, parseCtx.EncodingConfig.Marshaler, db)

// Build the gov module
govModule := gov.NewModule(sources.GovSource, nil, distrModule, mintModule, slashingModule, stakingModule, parseCtx.EncodingConfig.Marshaler, db)
Expand All @@ -78,7 +79,7 @@ func proposalCmd(parseConfig *parsecmdtypes.Config) *cobra.Command {
return fmt.Errorf("error while getting chain latest block height: %s", err)
}

err = govModule.UpdateProposal(height, proposalID)
err = govModule.UpdateProposal(height, time.Now(), proposalID)
if err != nil {
return err
}
Expand Down
20 changes: 20 additions & 0 deletions cmd/parse/mint/cmd.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package mint

import (
parsecmdtypes "github.com/forbole/juno/v3/cmd/parse/types"
"github.com/spf13/cobra"
)

// NewMintCmd returns the Cobra command allowing to fix various things related to the x/mint module
func NewMintCmd(parseConfig *parsecmdtypes.Config) *cobra.Command {
cmd := &cobra.Command{
Use: "mint",
Short: "Fix things related to the x/mint module",
}

cmd.AddCommand(
inflationCmd(parseConfig),
)

return cmd
}
45 changes: 45 additions & 0 deletions cmd/parse/mint/inflation.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
package mint

import (
"fmt"

parsecmdtypes "github.com/forbole/juno/v3/cmd/parse/types"
"github.com/forbole/juno/v3/types/config"
"github.com/spf13/cobra"

"github.com/forbole/bdjuno/v3/database"
"github.com/forbole/bdjuno/v3/modules/mint"
modulestypes "github.com/forbole/bdjuno/v3/modules/types"
)

// inflationCmd returns the Cobra command allowing to refresh x/mint inflation
func inflationCmd(parseConfig *parsecmdtypes.Config) *cobra.Command {
return &cobra.Command{
Use: "inflation",
Short: "Refresh inflation",
RunE: func(cmd *cobra.Command, args []string) error {
parseCtx, err := parsecmdtypes.GetParserContext(config.Cfg, parseConfig)
if err != nil {
return err
}

sources, err := modulestypes.BuildSources(config.Cfg.Node, parseCtx.EncodingConfig)
if err != nil {
return err
}

// Get the database
db := database.Cast(parseCtx.Database)

// Build mint module
mintModule := mint.NewModule(sources.MintSource, parseCtx.EncodingConfig.Marshaler, db)

err = mintModule.UpdateInflation()
if err != nil {
return fmt.Errorf("error while updating inflation: %s", err)
}

return nil
},
}
}
Loading

0 comments on commit ebd2a0d

Please sign in to comment.