Skip to content

Commit

Permalink
Support WASM stargate queries (backport #309) (#314)
Browse files Browse the repository at this point in the history
Co-authored-by: nghuyenthevinh2000 <[email protected]>
  • Loading branch information
mergify[bot] and nghuyenthevinh2000 authored Aug 2, 2023
1 parent 38f351e commit 8fe36c0
Show file tree
Hide file tree
Showing 25 changed files with 327 additions and 94 deletions.
5 changes: 3 additions & 2 deletions .github/workflows/codeql.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ on:
- "**.go"

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
group: ci-${{ github.ref }}-codeql
cancel-in-progress: true

jobs:
Expand All @@ -29,7 +29,8 @@ jobs:
uses: actions/checkout@v3
- uses: actions/setup-go@v4
with:
go-version: 1.18
go-version: "1.20"
check-latest: true
# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@v2
Expand Down
24 changes: 10 additions & 14 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -1,30 +1,26 @@
name: Lint
# Lint runs golangci-lint over the entire Gaia repository
# This workflow is run on every pull request and push to main
# The `golangci` job will pass without running if no *.{go, mod, sum} files have been modified.
on:
pull_request:
push:
branches:
- main
- master
- "release/*"
- "release/**"
pull_request:
permissions:
contents: read
jobs:
golangci:
name: golangci-lint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: technote-space/get-diff-action@v6
- uses: actions/setup-go@v4
with:
PATTERNS: |
**/**.go
go.mod
go.sum
- uses: golangci/golangci-lint-action@v3
go-version: "1.20"
check-latest: true
- uses: actions/checkout@v3
- name: golangci-lint
uses: golangci/golangci-lint-action@v3
with:
# Required: the version of golangci-lint is required and must be specified without patch version: we always use the latest patch version.
version: v1.51.2
args: --timeout 10m
github-token: ${{ secrets.github_token }}
if: "env.GIT_DIFF != ''"
27 changes: 18 additions & 9 deletions .github/workflows/sims.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,12 @@ on:
push:
branches:
- main
- master
- "release/*"

- "release/**"
permissions:
contents: read
concurrency:
group: ci-${{ github.ref }}-sims
cancel-in-progress: true
jobs:
cleanup-runs:
runs-on: ubuntu-latest
Expand All @@ -25,7 +28,8 @@ jobs:
- uses: actions/checkout@v3
- uses: actions/setup-go@v4
with:
go-version: 1.18
go-version: "1.20"
check-latest: true
- name: Display go version
run: go version
- run: make build
Expand All @@ -36,7 +40,8 @@ jobs:
steps:
- uses: actions/setup-go@v4
with:
go-version: 1.18
go-version: "1.20"
check-latest: true
- name: Display go version
run: go version
- name: Install runsim
Expand All @@ -53,7 +58,8 @@ jobs:
- uses: actions/checkout@v3
- uses: actions/setup-go@v4
with:
go-version: 1.18
go-version: "1.20"
check-latest: true
- name: Display go version
run: go version
- uses: technote-space/get-diff-action@v6
Expand All @@ -79,7 +85,8 @@ jobs:
- uses: actions/checkout@v3
- uses: actions/setup-go@v4
with:
go-version: 1.18
go-version: "1.20"
check-latest: true
- name: Display go version
run: go version
- uses: technote-space/get-diff-action@v6
Expand Down Expand Up @@ -107,7 +114,8 @@ jobs:
- uses: actions/checkout@v3
- uses: actions/setup-go@v4
with:
go-version: 1.18
go-version: "1.20"
check-latest: true
- name: Display go version
run: go version
- uses: technote-space/get-diff-action@v6
Expand Down Expand Up @@ -135,7 +143,8 @@ jobs:
- uses: actions/checkout@v3
- uses: actions/setup-go@v4
with:
go-version: 1.18
go-version: "1.20"
check-latest: true
- name: Display go version
run: go version
- uses: technote-space/get-diff-action@v6
Expand Down
17 changes: 12 additions & 5 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,12 @@ on:
push:
branches:
- main
- master
- "release/*"
- "release/**"
permissions:
contents: read
concurrency:
group: ci-${{ github.ref }}-test
cancel-in-progress: true
jobs:
cleanup-runs:
runs-on: ubuntu-latest
Expand All @@ -20,7 +24,8 @@ jobs:
steps:
- uses: actions/setup-go@v4
with:
go-version: 1.18
go-version: "1.20"
check-latest: true
- uses: actions/checkout@v3
- name: build
run: |
Expand All @@ -36,7 +41,8 @@ jobs:
- uses: actions/checkout@v3
- uses: actions/setup-go@v4
with:
go-version: 1.18
go-version: "1.20"
check-latest: true
- uses: technote-space/get-diff-action@v6
id: git_diff
with:
Expand All @@ -63,7 +69,8 @@ jobs:
- uses: actions/checkout@v3
- uses: actions/setup-go@v4
with:
go-version: 1.18
go-version: "1.20"
check-latest: true
- uses: technote-space/get-diff-action@v6
id: git_diff
with:
Expand Down
9 changes: 4 additions & 5 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
# syntax=docker/dockerfile:1

ARG source=./
ARG GO_VERSION="1.18"
ARG ALPINE_VERSION="3.17"
ARG GO_VERSION="1.20"
ARG BUILDPLATFORM=linux/amd64
ARG BASE_IMAGE="golang:${GO_VERSION}-alpine${ALPINE_VERSION}"
ARG BASE_IMAGE="golang:${GO_VERSION}-alpine"
FROM --platform=${BUILDPLATFORM} ${BASE_IMAGE} as base

###############################################################################
Expand Down Expand Up @@ -36,7 +35,7 @@ RUN set -eux &&\
# install mimalloc for musl
WORKDIR ${GOPATH}/src/mimalloc
RUN set -eux &&\
git clone --depth 1 --branch v2.0.9 \
git clone --depth 1 --branch v2.1.2 \
https://github.com/microsoft/mimalloc . &&\
mkdir -p build &&\
cd build &&\
Expand Down Expand Up @@ -103,7 +102,7 @@ RUN --mount=type=cache,target=/root/.cache/go-build \

################################################################################

FROM alpine:${ALPINE_VERSION} as terra-core
FROM alpine as terra-core

RUN apk update && apk add wget lz4 aria2 curl jq gawk coreutils "zlib>1.2.12-r2" "libssl1.1>1.1.1q-r0"

Expand Down
11 changes: 6 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ The easiest way to get started is by downloading a pre-built binary for your ope

**Step 1. Install Golang**

Go v1.18 is required for Terra Core.
Go v1.20 is required for Terra Core.

If you haven't already, install Golang by following the [official docs](https://golang.org/doc/install). Make sure that your `GOPATH` and `GOBIN` environment variables are properly set up.

Expand Down Expand Up @@ -53,10 +53,11 @@ If terrad is installed correctly, the following information is returned:
```bash
name: terra
server_name: terrad
version: 1.0.5
commit: 8bb56e9919ecf5234a3239a6a351b509451f9d5d
build_tags: netgo,ledger
go: go version go1.18.1 linux/amd64
version: <version>
commit: <git commit hash>
..
...
....
```

## `terrad`
Expand Down
4 changes: 2 additions & 2 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ import (

// upgrades
"github.com/classic-terra/core/v2/app/upgrades"
v1 "github.com/classic-terra/core/v2/app/upgrades/v1"
forks "github.com/classic-terra/core/v2/app/upgrades/forks"
v2 "github.com/classic-terra/core/v2/app/upgrades/v2"
v3 "github.com/classic-terra/core/v2/app/upgrades/v3"
v4 "github.com/classic-terra/core/v2/app/upgrades/v4"
Expand All @@ -71,7 +71,7 @@ var (
Upgrades = []upgrades.Upgrade{v2.Upgrade, v3.Upgrade, v4.Upgrade}

// Forks defines forks to be applied to the network
Forks = []upgrades.Fork{v1.DisableSwapFork, v1.IbcEnableFork, v1.VersionMapEnableFork}
Forks = []upgrades.Fork{forks.DisableSwapFork, forks.IbcEnableFork, forks.VersionMapEnableFork}
)

// Verify app interface at compile time
Expand Down
1 change: 1 addition & 0 deletions app/keepers/keepers.go
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,7 @@ func NewAppKeepers(
// the second slice will add custom querier and message handler decorator
// this order must be uphold else error will be thrown
wasmOpts = append(wasmOpts, terrawasm.RegisterCustomPlugins(&appKeepers.MarketKeeper, &appKeepers.OracleKeeper, &appKeepers.TreasuryKeeper)...)
wasmOpts = append(wasmOpts, terrawasm.RegisterStargateQueries(*bApp.GRPCQueryRouter(), appCodec)...)

appKeepers.WasmKeeper = wasmkeeper.NewKeeper(
appCodec,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package v1
package forks

import (
"github.com/classic-terra/core/v2/app/upgrades"
Expand Down
2 changes: 1 addition & 1 deletion app/upgrades/v1/forks.go → app/upgrades/forks/forks.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package v1
package forks

import (
"fmt"
Expand Down
2 changes: 1 addition & 1 deletion contrib/terra-operator/Dockerfile.core
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# docker build . -t cosmwasm/wasmd:latest
# docker run --rm -it cosmwasm/wasmd:latest /bin/sh
FROM golang:1.18-alpine3.17 AS go-builder
FROM golang:1.20-alpine AS go-builder
ARG source=.

# this comes from standard alpine nightly file
Expand Down
2 changes: 1 addition & 1 deletion contrib/updates/Dockerfile.cosmovisor
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM golang:1.18-alpine3.17
FROM golang:1.20-alpine

RUN set -eux; apk add --no-cache ca-certificates build-base;

Expand Down
14 changes: 7 additions & 7 deletions custom/auth/legacy/v040/migrate.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import (

// convertBaseAccount converts a 0.39 BaseAccount to a 0.40 BaseAccount.
func convertBaseAccount(old *v039auth.BaseAccount) *v040auth.BaseAccount {
var any *codectypes.Any
var pubKey *codectypes.Any

// If the old genesis had a pubkey, we pack it inside an Any. Or else, we
// just leave it nil.
Expand All @@ -31,15 +31,15 @@ func convertBaseAccount(old *v039auth.BaseAccount) *v040auth.BaseAccount {
}

var err error
any, err = codectypes.NewAnyWithValue(pk)
pubKey, err = codectypes.NewAnyWithValue(pk)
if err != nil {
panic(err)
}
}

return &v040auth.BaseAccount{
Address: old.Address.String(),
PubKey: any,
PubKey: pubKey,
AccountNumber: old.AccountNumber,
Sequence: old.Sequence,
}
Expand Down Expand Up @@ -143,14 +143,14 @@ func Migrate(authGenState v039auth.GenesisState) *v040auth.GenesisState {
}

// Convert v0.40 accounts into Anys.
anys := make([]*codectypes.Any, len(v040Accounts))
accounts := make([]*codectypes.Any, len(v040Accounts))
for i, v040Account := range v040Accounts {
any, err := codectypes.NewAnyWithValue(v040Account)
account, err := codectypes.NewAnyWithValue(v040Account)
if err != nil {
panic(err)
}

anys[i] = any
accounts[i] = account
}

return &v040auth.GenesisState{
Expand All @@ -161,6 +161,6 @@ func Migrate(authGenState v039auth.GenesisState) *v040auth.GenesisState {
SigVerifyCostED25519: authGenState.Params.SigVerifyCostED25519,
SigVerifyCostSecp256k1: authGenState.Params.SigVerifyCostSecp256k1,
},
Accounts: anys,
Accounts: accounts,
}
}
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
go 1.18
go 1.20

module github.com/classic-terra/core/v2

Expand Down
Loading

0 comments on commit 8fe36c0

Please sign in to comment.