Skip to content

Commit

Permalink
Unfork CosmosSDK, CometBFT, ibc-go (#539) (#541)
Browse files Browse the repository at this point in the history
Co-authored-by: Khanh Hoa <[email protected]>
Co-authored-by: Tuan Tran <[email protected]>
Co-authored-by: Tuan Tran <[email protected]>
Co-authored-by: tnv1 <[email protected]>
Co-authored-by: Tien Nguyen <[email protected]>
Co-authored-by: Hoa Nguyen <[email protected]>
Co-authored-by: StrathCole <[email protected]>
  • Loading branch information
8 people authored Feb 10, 2025
1 parent 79f2a5e commit e24a658
Show file tree
Hide file tree
Showing 59 changed files with 4,424 additions and 749 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/codeql.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ jobs:
uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version: "1.20"
go-version: "1.22"
check-latest: true
# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/e2e.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
name: Setup Go
uses: actions/setup-go@v4
with:
go-version: '1.20.4'
go-version: '1.22'
-
name: Check out repository code
uses: actions/checkout@v4
Expand Down
22 changes: 11 additions & 11 deletions .github/workflows/interchain.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
- name: Setup Go
uses: actions/setup-go@v4
with:
go-version: '1.20'
go-version: '1.22'
- name: Check out repository code
uses: actions/checkout@v4
- name: Set up Docker Buildx
Expand All @@ -36,10 +36,10 @@ jobs:
runs-on: ubuntu-latest
needs: build-image
steps:
- name: Set up Go 1.20
- name: Set up Go 1.22
uses: actions/setup-go@v4
with:
go-version: "1.20"
go-version: "1.22"
check-latest: true

- name: checkout code
Expand All @@ -51,10 +51,10 @@ jobs:
runs-on: ubuntu-latest
needs: build-image
steps:
- name: Set up Go 1.20
- name: Set up Go 1.22
uses: actions/setup-go@v4
with:
go-version: "1.20"
go-version: "1.22"
check-latest: true

- name: checkout code
Expand All @@ -66,10 +66,10 @@ jobs:
runs-on: ubuntu-latest
needs: build-image
steps:
- name: Set up Go 1.20
- name: Set up Go 1.22
uses: actions/setup-go@v4
with:
go-version: "1.20"
go-version: "1.22"
check-latest: true

- name: checkout code
Expand All @@ -81,10 +81,10 @@ jobs:
runs-on: ubuntu-latest
needs: build-image
steps:
- name: Set up Go 1.20
- name: Set up Go 1.22
uses: actions/setup-go@v4
with:
go-version: "1.20"
go-version: "1.22"
check-latest: true

- name: checkout code
Expand All @@ -96,10 +96,10 @@ jobs:
runs-on: ubuntu-latest
needs: build-image
steps:
- name: Set up Go 1.20
- name: Set up Go 1.22
uses: actions/setup-go@v4
with:
go-version: "1.20"
go-version: "1.22"
check-latest: true

- name: checkout code
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,13 @@ jobs:
steps:
- uses: actions/setup-go@v5
with:
go-version: "1.20"
go-version: "1.22"
check-latest: true
- uses: actions/checkout@v4
- name: golangci-lint
uses: golangci/golangci-lint-action@v4
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
version: v1.60.1
args: --timeout 10m
github-token: ${{ secrets.github_token }}
12 changes: 6 additions & 6 deletions .github/workflows/sims.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ jobs:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version: "1.20"
go-version: "1.22"
check-latest: true
- name: Display go version
run: go version
Expand All @@ -40,7 +40,7 @@ jobs:
steps:
- uses: actions/setup-go@v5
with:
go-version: "1.20"
go-version: "1.22"
check-latest: true
- name: Display go version
run: go version
Expand All @@ -58,7 +58,7 @@ jobs:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version: "1.20"
go-version: "1.22"
check-latest: true
- name: Display go version
run: go version
Expand All @@ -85,7 +85,7 @@ jobs:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version: "1.20"
go-version: "1.22"
check-latest: true
- name: Display go version
run: go version
Expand Down Expand Up @@ -114,7 +114,7 @@ jobs:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version: "1.20"
go-version: "1.22"
check-latest: true
- name: Display go version
run: go version
Expand Down Expand Up @@ -143,7 +143,7 @@ jobs:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version: "1.20"
go-version: "1.22"
check-latest: true
- name: Display go version
run: go version
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ jobs:
steps:
- uses: actions/setup-go@v5
with:
go-version: "1.20"
go-version: "1.22"
check-latest: true
- uses: actions/checkout@v4
- name: build
Expand All @@ -41,7 +41,7 @@ jobs:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version: "1.20"
go-version: "1.22"
check-latest: true
- uses: technote-space/get-diff-action@v6
id: git_diff
Expand Down Expand Up @@ -69,7 +69,7 @@ jobs:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version: "1.20"
go-version: "1.22"
check-latest: true
- uses: technote-space/get-diff-action@v6
id: git_diff
Expand Down
10 changes: 7 additions & 3 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@ linters:
- gofumpt
- gosec
- gosimple
- govet
# - govet
- ineffassign
- misspell
- nakedret
- nolintlint
# - nolintlint
- staticcheck
- revive
- stylecheck
Expand Down Expand Up @@ -60,4 +60,8 @@ linters-settings:
allow-unused: false
allow-leading-space: true
require-explanation: false
require-specific: false
require-specific: false
revive:
rules:
- name: unused-parameter
disabled: true
12 changes: 6 additions & 6 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
# syntax=docker/dockerfile:1

ARG source=./
ARG GO_VERSION="1.20"
ARG GO_VERSION="1.22.12"
ARG BUILDPLATFORM=linux/amd64
ARG BASE_IMAGE="golang:${GO_VERSION}-alpine3.18"
FROM --platform=${BUILDPLATFORM} ${BASE_IMAGE} as base
ARG BASE_IMAGE="golang:${GO_VERSION}-alpine3.20"
FROM --platform=${BUILDPLATFORM} ${BASE_IMAGE} AS base

###############################################################################
# Builder
###############################################################################

FROM base as builder-stage-1
FROM base AS builder-stage-1

ARG source
ARG GIT_COMMIT
Expand Down Expand Up @@ -70,7 +70,7 @@ RUN set -eux &&\

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

FROM builder-stage-1 as builder-stage-2
FROM builder-stage-1 AS builder-stage-2

ARG source
ARG GOOS=linux \
Expand Down Expand Up @@ -102,7 +102,7 @@ RUN --mount=type=cache,target=/root/.cache/go-build \

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

FROM alpine 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" libssl3

Expand Down
3 changes: 3 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -272,6 +272,9 @@ ictest-ibc-pfm: ictest-build
ictest-ibc-pfm-terra: ictest-build
@cd tests/interchaintest && go test -race -v -run TestTerraPFM .

ictest-oracle: ictest-build
@cd tests/interchaintest && go test -race -v -run TestOracle .

ictest-build:
@DOCKER_BUILDKIT=1 docker build -t core:local -f ictest.Dockerfile .

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ The easiest way to get started is by downloading a pre-built binary for your ope

**Step 1. Install Golang**

Go v1.20 is required for Terra Core.
Go v1.22 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
40 changes: 36 additions & 4 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import (
"github.com/rakyll/statik/fs"
"github.com/spf13/cast"

appmempool "github.com/classic-terra/core/v3/app/mempool"
dbm "github.com/cometbft/cometbft-db"
abci "github.com/cometbft/cometbft/abci/types"
tmjson "github.com/cometbft/cometbft/libs/json"
Expand All @@ -33,7 +34,6 @@ import (
servertypes "github.com/cosmos/cosmos-sdk/server/types"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/types/module"
"github.com/cosmos/cosmos-sdk/version"
"github.com/cosmos/cosmos-sdk/x/auth/ante"
authtx "github.com/cosmos/cosmos-sdk/x/auth/tx"
authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
Expand All @@ -43,6 +43,7 @@ import (

"github.com/classic-terra/core/v3/app/keepers"
terraappparams "github.com/classic-terra/core/v3/app/params"
customserver "github.com/classic-terra/core/v3/server"

// upgrades
"github.com/classic-terra/core/v3/app/upgrades"
Expand All @@ -61,6 +62,8 @@ import (

// v9 had been used by tax2gas and has to be skipped
v10_1 "github.com/classic-terra/core/v3/app/upgrades/v10_1"
v11 "github.com/classic-terra/core/v3/app/upgrades/v11"
v11_1 "github.com/classic-terra/core/v3/app/upgrades/v11_1"

customante "github.com/classic-terra/core/v3/custom/auth/ante"
custompost "github.com/classic-terra/core/v3/custom/auth/post"
Expand Down Expand Up @@ -95,6 +98,8 @@ var (
v8_2.Upgrade,
v8_3.Upgrade,
v10_1.Upgrade,
v11.Upgrade,
v11_1.Upgrade,
}

// Forks defines forks to be applied to the network
Expand Down Expand Up @@ -142,7 +147,7 @@ func init() {

// NewTerraApp returns a reference to an initialized TerraApp.
func NewTerraApp(
logger log.Logger, db dbm.DB, traceStore io.Writer, loadLatest bool, skipUpgradeHeights map[int64]bool,
logger log.Logger, db dbm.DB, _ io.Writer, loadLatest bool, skipUpgradeHeights map[int64]bool,
homePath string, encodingConfig terraappparams.EncodingConfig, appOpts servertypes.AppOptions,
wasmOpts []wasmkeeper.Option, baseAppOptions ...func(*baseapp.BaseApp),
) *TerraApp {
Expand All @@ -152,10 +157,29 @@ func NewTerraApp(
txConfig := encodingConfig.TxConfig

invCheckPeriod := cast.ToUint(appOpts.Get(server.FlagInvCheckPeriod))
iavlCacheSize := cast.ToInt(appOpts.Get(server.FlagIAVLCacheSize))
iavlDisableFastNode := cast.ToBool(appOpts.Get(server.FlagDisableIAVLFastNode))

// option for cosmos sdk
baseAppOptions = append(baseAppOptions, baseapp.SetIAVLCacheSize(iavlCacheSize))
baseAppOptions = append(baseAppOptions, baseapp.SetIAVLDisableFastNode(iavlDisableFastNode))

// option for mempool
baseAppOptions = append(baseAppOptions, func(app *baseapp.BaseApp) {
var mempool *appmempool.FifoMempool
if maxTxs := cast.ToInt(appOpts.Get(server.FlagMempoolMaxTxs)); maxTxs > 0 {
mempool = appmempool.NewFifoMempool(appmempool.FifoMaxTxOpt(maxTxs))
} else {
mempool = appmempool.NewFifoMempool()
}
handler := baseapp.NewDefaultProposalHandler(mempool, app)
app.SetMempool(mempool)
app.SetTxEncoder(txConfig.TxEncoder())
app.SetPrepareProposal(handler.PrepareProposalHandler())
app.SetProcessProposal(handler.ProcessProposalHandler())
})

bApp := baseapp.NewBaseApp(appName, logger, db, txConfig.TxDecoder(), baseAppOptions...)
bApp.SetCommitMultiStoreTracer(traceStore)
bApp.SetVersion(version.Version)
bApp.SetInterfaceRegistry(interfaceRegistry)

app := &TerraApp{
Expand Down Expand Up @@ -406,6 +430,9 @@ func (app *TerraApp) RegisterAPIRoutes(apiSvr *api.Server, apiConfig config.APIC
if apiConfig.Swagger {
RegisterSwaggerAPI(apiSvr.Router)
}

// Apply custom middleware
apiSvr.Router.Use(customserver.BlockHeightMiddleware)
}

// RegisterTxService implements the Application.RegisterTxService method.
Expand Down Expand Up @@ -478,3 +505,8 @@ func (app *TerraApp) setupUpgradeHandlers() {
)
}
}

// GetTxConfig for testing
func (app *TerraApp) GetTxConfig() client.TxConfig {
return app.txConfig
}
24 changes: 24 additions & 0 deletions app/helper/helper.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package helper

import (
oracleexported "github.com/classic-terra/core/v3/x/oracle/exported"
sdk "github.com/cosmos/cosmos-sdk/types"
)

func IsOracleTx(msgs []sdk.Msg) bool {
if len(msgs) == 0 {
return false
}
for _, msg := range msgs {
switch msg.(type) {
case *oracleexported.MsgAggregateExchangeRatePrevote:
continue
case *oracleexported.MsgAggregateExchangeRateVote:
continue
default:
return false
}
}

return true
}
Loading

0 comments on commit e24a658

Please sign in to comment.