Skip to content

Commit

Permalink
Merge pull request #179 from decentrio/trinity/sdk50
Browse files Browse the repository at this point in the history
feat: Bridge module and upgrade sdk50
  • Loading branch information
jiujiteiro authored Nov 15, 2024
2 parents ba80c0e + 4823ac3 commit fd75b67
Show file tree
Hide file tree
Showing 357 changed files with 55,164 additions and 85,634 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/codeql.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ jobs:
uses: actions/checkout@v3
- uses: actions/setup-go@v4
with:
go-version: 1.20.2
go-version: 1.22
# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@v2
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/goreleaser.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: 1.20
go-version: 1.22
check-latest: true
- name: release dry run
run: make release-dry-run
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,12 @@ jobs:
steps:
- uses: actions/setup-go@v4
with:
go-version: '1.20'
go-version: '1.22.2'
cache: false
- uses: actions/checkout@v3
- name: golangci-lint
uses: golangci/golangci-lint-action@v3
with:
# Optional: version of golangci-lint to use in form of v1.2 or v1.2.3 or `latest` to use the latest version
version: v1.52.2
version: v1.57.1

2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ jobs:
test:
strategy:
matrix:
go-version: [1.19.x, 1.20.x]
go-version: [1.22.x]
os: [ubuntu-latest, macos-latest]
runs-on: ${{ matrix.os }}
steps:
Expand Down
1 change: 0 additions & 1 deletion .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ run:
linters:
disable-all: true
enable:
- depguard
- dogsled
- errcheck
- exportloopref
Expand Down
51 changes: 16 additions & 35 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
PACKAGES_NOSIMULATION=$(shell go list ./... | grep -v '/simulation')
VERSION ?= $(shell echo $(shell git describe --tags --always) | sed 's/^v//')
TMVERSION := $(shell go list -m github.com/tendermint/tendermint | sed 's:.* ::')
TMVERSION := $(shell go list -m github.com/cometbft/cometbft | sed 's:.* ::')
EVM_DENOM := ario
COMMIT := $(shell git log -1 --format='%H')
LEDGER_ENABLED ?= true
BINDIR ?= $(GOPATH)/bin
Expand Down Expand Up @@ -63,7 +64,8 @@ ldflags = -X github.com/cosmos/cosmos-sdk/version.Name=realio-network \
-X github.com/cosmos/cosmos-sdk/version.AppName=$(REALIO_BINARY) \
-X github.com/cosmos/cosmos-sdk/version.Version=$(VERSION) \
-X github.com/cosmos/cosmos-sdk/version.Commit=$(COMMIT) \
-X github.com/tendermint/tendermint/version.TMCoreSemVer=$(TMVERSION)
-X github.com/cometbft/cometbft/version.TMCoreSemVer=$(TMVERSION) \
-X github.com/evmos/os/x/evm/types.DefaultEVMDenom=$(EVM_DENOM)

# DB backend selection
ifeq (cleveldb,$(findstring cleveldb,$(COSMOS_BUILD_OPTIONS)))
Expand Down Expand Up @@ -192,7 +194,7 @@ localnet-show-logstream:
###############################################################################

PACKAGE_NAME:=github.com/realiotech/realio-network
GOLANG_CROSS_VERSION = v1.20
GOLANG_CROSS_VERSION = v1.22
GOPATH ?= '$(HOME)/go'
release-dry-run:
docker run \
Expand All @@ -204,7 +206,7 @@ release-dry-run:
-v ${GOPATH}/pkg:/go/pkg \
-w /go/src/$(PACKAGE_NAME) \
ghcr.io/goreleaser/goreleaser-cross:${GOLANG_CROSS_VERSION} \
--rm-dist --skip-validate --skip-publish --snapshot
--clean --skip=validate --skip=publish --snapshot

release:
@if [ ! -f ".release-env" ]; then \
Expand All @@ -220,7 +222,7 @@ release:
-v `pwd`:/go/src/$(PACKAGE_NAME) \
-w /go/src/$(PACKAGE_NAME) \
ghcr.io/goreleaser/goreleaser-cross:${GOLANG_CROSS_VERSION} \
release --rm-dist --skip-validate
release --clean --skip=validate

.PHONY: release-dry-run release

Expand All @@ -240,30 +242,9 @@ endif
### Protobuf ###
###############################################################################

# ------
# NOTE: Link to the tendermintdev/sdk-proto-gen docker images:
# https://hub.docker.com/r/tendermintdev/sdk-proto-gen/tags
#
protoVer=v0.7
protoImageName=tendermintdev/sdk-proto-gen:$(protoVer)
protoImage=$(DOCKER) run --network host --rm -v $(CURDIR):/workspace --workdir /workspace $(protoImageName)
# ------
# NOTE: cosmos/proto-builder image is needed because clang-format is not installed
# on the tendermintdev/sdk-proto-gen docker image.
# Link to the cosmos/proto-builder docker images:
# https://github.com/cosmos/cosmos-sdk/pkgs/container/proto-builder
#
protoCosmosVer=0.11.2
protoCosmosName=ghcr.io/cosmos/proto-builder:$(protoCosmosVer)
protoCosmosImage=$(DOCKER) run --network host --rm -v $(CURDIR):/workspace --workdir /workspace $(protoCosmosName)
# ------
# NOTE: Link to the yoheimuta/protolint docker images:
# https://hub.docker.com/r/yoheimuta/protolint/tags
#
protolintVer=0.42.2
protolintName=yoheimuta/protolint:$(protolintVer)
protolintImage=$(DOCKER) run --network host --rm -v $(CURDIR):/workspace --workdir /workspace $(protolintName)

protoVer=0.14.0
protoImageName=ghcr.io/cosmos/proto-builder:$(protoVer)
protoImage=$(DOCKER) run --rm -v $(CURDIR):/workspace --workdir /workspace --user 0 $(protoImageName)

# ------
# NOTE: If you are experiencing problems running these commands, try deleting
Expand All @@ -280,25 +261,25 @@ proto-swagger-gen:
@echo "Downloading Protobuf dependencies"
# @make proto-download-deps
@echo "Generating Protobuf Swagger"
$(protoCosmosImage) sh ./scripts/protoc-swagger-gen.sh
$(protoImage) sh ./scripts/protoc-swagger-gen.sh

proto-format:
@echo "Formatting Protobuf files"
$(protoCosmosImage) find ./ -name *.proto -exec clang-format -i {} \;
$(protoImage) find ./ -name *.proto -exec clang-format -i {} \;

# NOTE: The linter configuration lives in .protolint.yaml
proto-lint:
@echo "Linting Protobuf files"
$(protolintImage) lint ./proto
$(protoImage) lint ./proto

proto-check-breaking:
@echo "Checking Protobuf files for breaking changes"
$(protoImage) buf breaking --against $(HTTPS_GIT)#branch=main


TM_URL = https://raw.githubusercontent.com/tendermint/tendermint/v0.34.12/proto/tendermint
TM_URL = https://raw.githubusercontent.com/cometbft/cometbft/v0.38.11/proto/tendermint
GOGO_PROTO_URL = https://raw.githubusercontent.com/regen-network/protobuf/cosmos
COSMOS_SDK_URL = https://raw.githubusercontent.com/cosmos/cosmos-sdk/v0.44.0
COSMOS_SDK_URL = https://raw.githubusercontent.com/cosmos/cosmos-sdk/v0.50.9
COSMOS_PROTO_URL = https://raw.githubusercontent.com/regen-network/cosmos-proto/master

TM_CRYPTO_TYPES = third_party/proto/tendermint/crypto
Expand All @@ -319,7 +300,7 @@ proto-update-deps:
## Importing of tendermint protobuf definitions currently requires the
## use of `sed` in order to build properly with cosmos-sdk's proto file layout
## (which is the standard Buf.build FILE_LAYOUT)
## Issue link: https://github.com/tendermint/tendermint/issues/5021
## Issue link: https://github.com/cometbft/cometbft/issues/5021
@mkdir -p $(TM_ABCI_TYPES)
@curl -sSL $(TM_URL)/abci/types.proto > $(TM_ABCI_TYPES)/types.proto

Expand Down
12 changes: 4 additions & 8 deletions app/ante/ante.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@ import (
sdk "github.com/cosmos/cosmos-sdk/types"
errortypes "github.com/cosmos/cosmos-sdk/types/errors"
authante "github.com/cosmos/cosmos-sdk/x/auth/ante"

ethante "github.com/evmos/ethermint/app/ante"
)

// NewAnteHandler returns an ante handler responsible for attempting to route an
Expand All @@ -20,19 +18,17 @@ func NewAnteHandler(options HandlerOptions) sdk.AnteHandler {
) (newCtx sdk.Context, err error) {
var anteHandler sdk.AnteHandler

defer ethante.Recover(ctx.Logger(), &err)

txWithExtensions, ok := tx.(authante.HasExtensionOptionsTx)
if ok {
opts := txWithExtensions.GetExtensionOptions()
if len(opts) > 0 {
switch typeURL := opts[0].GetTypeUrl(); typeURL {
case "/ethermint.evm.v1.ExtensionOptionsEthereumTx":
case "/os.evm.v1.ExtensionOptionsEthereumTx":
// handle as *evmtypes.MsgEthereumTx
anteHandler = newEthAnteHandler(options)
case "/ethermint.types.v1.ExtensionOptionsWeb3Tx":
// handle as normal Cosmos SDK tx, except signature is checked for EIP712 representation
anteHandler = newLegacyCosmosAnteHandlerEip712(options)
case "/os.types.v1.ExtensionOptionDynamicFeeTx":
// cosmos-sdk tx with dynamic fee extension
anteHandler = newCosmosAnteHandler(options)
default:
return ctx, errorsmod.Wrapf(
errortypes.ErrUnknownExtensionOptions,
Expand Down
34 changes: 22 additions & 12 deletions app/ante/antes_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@ import (
"fmt"
"time"

abci "github.com/cometbft/cometbft/abci/types"
sdk "github.com/cosmos/cosmos-sdk/types"
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
sdkvesting "github.com/cosmos/cosmos-sdk/x/auth/vesting/types"
"github.com/cosmos/cosmos-sdk/x/authz"
banktypes "github.com/cosmos/cosmos-sdk/x/bank/types"
evmtypes "github.com/evmos/ethermint/x/evm/types"
abci "github.com/tendermint/tendermint/abci/types"
evmtypes "github.com/evmos/os/x/evm/types"
)

func (suite *AnteTestSuite) TestRejectMsgsInAuthz() {
Expand Down Expand Up @@ -63,7 +63,7 @@ func (suite *AnteTestSuite) TestRejectMsgsInAuthz() {
banktypes.NewMsgSend(
testAddresses[0],
testAddresses[3],
sdk.NewCoins(sdk.NewInt64Coin(evmtypes.DefaultEVMDenom, 100e6)),
sdk.NewCoins(sdk.NewInt64Coin(sdk.DefaultBondDenom, 100e6)),
),
&evmtypes.MsgEthereumTx{},
},
Expand Down Expand Up @@ -94,7 +94,7 @@ func (suite *AnteTestSuite) TestRejectMsgsInAuthz() {
banktypes.NewMsgSend(
testAddresses[0],
testAddresses[3],
sdk.NewCoins(sdk.NewInt64Coin(evmtypes.DefaultEVMDenom, 100e6)),
sdk.NewCoins(sdk.NewInt64Coin(sdk.DefaultBondDenom, 100e6)),
),
},
),
Expand All @@ -111,7 +111,7 @@ func (suite *AnteTestSuite) TestRejectMsgsInAuthz() {
banktypes.NewMsgSend(
testAddresses[0],
testAddresses[3],
sdk.NewCoins(sdk.NewInt64Coin(evmtypes.DefaultEVMDenom, 100e6)),
sdk.NewCoins(sdk.NewInt64Coin(sdk.DefaultBondDenom, 100e6)),
),
},
),
Expand All @@ -122,7 +122,7 @@ func (suite *AnteTestSuite) TestRejectMsgsInAuthz() {
banktypes.NewMsgSend(
testAddresses[0],
testAddresses[3],
sdk.NewCoins(sdk.NewInt64Coin(evmtypes.DefaultEVMDenom, 100e6)),
sdk.NewCoins(sdk.NewInt64Coin(sdk.DefaultBondDenom, 100e6)),
),
},
),
Expand Down Expand Up @@ -150,20 +150,30 @@ func (suite *AnteTestSuite) TestRejectMsgsInAuthz() {
bz, err := txEncoder(tx)
suite.Require().NoError(err)

resCheckTx := suite.app.CheckTx(
abci.RequestCheckTx{
resCheckTx, err := suite.app.CheckTx(
&abci.RequestCheckTx{
Tx: bz,
Type: abci.CheckTxType_New,
},
)
suite.Require().NoError(err)
suite.Require().Equal(resCheckTx.Code, tc.expectedCode, resCheckTx.Log)

resDeliverTx := suite.app.DeliverTx(
abci.RequestDeliverTx{
Tx: bz,
header := suite.ctx.BlockHeader()
blockRes, err := suite.app.FinalizeBlock(
&abci.RequestFinalizeBlock{
Height: 1,
Txs: [][]byte{bz},
Hash: header.AppHash,
NextValidatorsHash: header.NextValidatorsHash,
ProposerAddress: header.ProposerAddress,
Time: header.Time.Add(time.Second),
},
)
suite.Require().Equal(resDeliverTx.Code, tc.expectedCode, resDeliverTx.Log)
suite.Require().NoError(err)
suite.Require().Len(blockRes.TxResults, 1)
txRes := blockRes.TxResults[0]
suite.Require().Equal(txRes.Code, tc.expectedCode, txRes.Log)
})
}
}
14 changes: 7 additions & 7 deletions app/ante/authz_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import (
banktypes "github.com/cosmos/cosmos-sdk/x/bank/types"
stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types"

evmtypes "github.com/evmos/ethermint/x/evm/types"
evmtypes "github.com/evmos/os/x/evm/types"

"github.com/realiotech/realio-network/app/ante"
)
Expand Down Expand Up @@ -48,7 +48,7 @@ func TestAuthzLimiterDecorator(t *testing.T) {
banktypes.NewMsgSend(
testAddresses[0],
testAddresses[1],
sdk.NewCoins(sdk.NewInt64Coin(evmtypes.DefaultEVMDenom, 100e6)),
sdk.NewCoins(sdk.NewInt64Coin(sdk.DefaultBondDenom, 100e6)),
),
},
false,
Expand Down Expand Up @@ -130,7 +130,7 @@ func TestAuthzLimiterDecorator(t *testing.T) {
[]sdk.Msg{banktypes.NewMsgSend(
testAddresses[0],
testAddresses[3],
sdk.NewCoins(sdk.NewInt64Coin(evmtypes.DefaultEVMDenom, 100e6)),
sdk.NewCoins(sdk.NewInt64Coin(sdk.DefaultBondDenom, 100e6)),
)}),
},
false,
Expand Down Expand Up @@ -164,7 +164,7 @@ func TestAuthzLimiterDecorator(t *testing.T) {
banktypes.NewMsgSend(
testAddresses[0],
testAddresses[3],
sdk.NewCoins(sdk.NewInt64Coin(evmtypes.DefaultEVMDenom, 100e6)),
sdk.NewCoins(sdk.NewInt64Coin(sdk.DefaultBondDenom, 100e6)),
),
&evmtypes.MsgEthereumTx{},
},
Expand Down Expand Up @@ -215,7 +215,7 @@ func TestAuthzLimiterDecorator(t *testing.T) {
banktypes.NewMsgSend(
testAddresses[0],
testAddresses[3],
sdk.NewCoins(sdk.NewInt64Coin(evmtypes.DefaultEVMDenom, 100e6)),
sdk.NewCoins(sdk.NewInt64Coin(sdk.DefaultBondDenom, 100e6)),
),
},
),
Expand All @@ -233,7 +233,7 @@ func TestAuthzLimiterDecorator(t *testing.T) {
banktypes.NewMsgSend(
testAddresses[0],
testAddresses[3],
sdk.NewCoins(sdk.NewInt64Coin(evmtypes.DefaultEVMDenom, 100e6)),
sdk.NewCoins(sdk.NewInt64Coin(sdk.DefaultBondDenom, 100e6)),
),
},
),
Expand All @@ -244,7 +244,7 @@ func TestAuthzLimiterDecorator(t *testing.T) {
banktypes.NewMsgSend(
testAddresses[0],
testAddresses[3],
sdk.NewCoins(sdk.NewInt64Coin(evmtypes.DefaultEVMDenom, 100e6)),
sdk.NewCoins(sdk.NewInt64Coin(sdk.DefaultBondDenom, 100e6)),
),
},
),
Expand Down
Loading

0 comments on commit fd75b67

Please sign in to comment.