Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Bridge module and upgrade sdk50 #179

Merged
merged 55 commits into from
Nov 15, 2024
Merged
Show file tree
Hide file tree
Changes from 45 commits
Commits
Show all changes
55 commits
Select commit Hold shift + click to select a range
efc7974
remove multistaking module in app
trinitys7 Oct 1, 2024
b720f8e
Migrate realio network to sdk 50
trinitys7 Oct 4, 2024
ef4f39d
Fix all tests
trinitys7 Oct 8, 2024
2c58c9e
Add migration for asset module
trinitys7 Oct 8, 2024
d722f6b
Use latest multistaking version
trinitys7 Oct 14, 2024
3439a57
Separate legacy params and params
trinitys7 Oct 14, 2024
2f338d7
remove multistaking upgrade
trinitys7 Oct 14, 2024
b39bf2c
Draft bridge module
trinitys7 Oct 15, 2024
426fa58
Add upgrade handler
trinitys7 Oct 16, 2024
9df76b1
Fix ci
trinitys7 Oct 16, 2024
7ecb16e
Add unit test for bridge module
trinitys7 Oct 17, 2024
5f409a9
Rename
trinitys7 Oct 18, 2024
02e5c13
fix redundant code
trinitys7 Oct 18, 2024
dde0bab
lint
trinitys7 Oct 18, 2024
dc78498
Merge pull request #16 from decentrio/feat/bridge-module
trinitys7 Oct 18, 2024
ea841b6
upgrade handler
lacsomot Oct 18, 2024
2108721
cli
lacsomot Oct 18, 2024
af95502
nits
likesToEatFish Oct 21, 2024
64fedbf
Finish all fix for upgrade sdk50
trinitys7 Oct 21, 2024
09e9116
cli
lacsomot Oct 23, 2024
a081554
use tempdir
lacsomot Oct 23, 2024
4b47750
minor fix in app
lacsomot Oct 23, 2024
9bef0f2
nit
lacsomot Oct 23, 2024
78d395f
delete ethermint store content
catShaark Oct 23, 2024
45a9c2b
update upgrade handler
catShaark Oct 25, 2024
e1e2f26
Upgrade and replacing evm success
trinitys7 Oct 25, 2024
723c49a
realio crypto
trinitys7 Oct 25, 2024
fae2236
fix evmos pubkeys
trinitys7 Oct 25, 2024
7498d28
update with current commit
trinitys7 Oct 25, 2024
a733c75
Add mock Erc20 keeper
trinitys7 Oct 25, 2024
43aeb2b
Remove unused functions
trinitys7 Oct 25, 2024
ce7041b
Add codec for EthAccount
trinitys7 Oct 25, 2024
6cb7a84
Use sdk.AccountI
trinitys7 Oct 25, 2024
03bfffe
Generate proto for PubKey and EthAccount
trinitys7 Oct 25, 2024
4bfba55
Update query
trinitys7 Oct 25, 2024
77836aa
Fix tests
trinitys7 Oct 28, 2024
cfa1391
lint
trinitys7 Oct 28, 2024
54e03be
remove redudant file in crypto
trinitys7 Oct 28, 2024
c2ed002
lint
trinitys7 Oct 29, 2024
94b78ad
Remove upgrade module when calling begin blocker
trinitys7 Oct 29, 2024
ce49ddc
Update third party proto and swagger
trinitys7 Oct 30, 2024
0da4fb6
nit
trinitys7 Oct 30, 2024
45f0757
remove nolint
neitdung Oct 30, 2024
c92be0c
nit
trinitys7 Oct 31, 2024
f4cb184
remove params subspace on bridge module
trinitys7 Oct 31, 2024
7d48adc
nit
trinitys7 Nov 1, 2024
d573c2b
lint
trinitys7 Nov 1, 2024
6b89d71
lint
lacsomot Nov 4, 2024
ff11ac9
Add precompile and update evm param
trinitys7 Nov 4, 2024
8356719
Modify mint params in upgrade
trinitys7 Nov 5, 2024
b152550
Fix ante logic and remove precompiles
trinitys7 Nov 5, 2024
a9b9109
Change permissionless to permissioned in evm params
trinitys7 Nov 8, 2024
4c4f46e
Remove call policy and lint
trinitys7 Nov 9, 2024
d0decd4
Update bridge params for testnet
trinitys7 Nov 15, 2024
4823ac3
Update release scripts
trinitys7 Nov 15, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
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
45 changes: 13 additions & 32 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 @@ -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
33 changes: 27 additions & 6 deletions app/ante/ante.go
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
package ante

import (
"fmt"
"runtime/debug"

errorsmod "cosmossdk.io/errors"
log "cosmossdk.io/log"
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,18 +22,18 @@ func NewAnteHandler(options HandlerOptions) sdk.AnteHandler {
) (newCtx sdk.Context, err error) {
var anteHandler sdk.AnteHandler

defer ethante.Recover(ctx.Logger(), &err)
defer Recover(ctx.Logger(), &err)
trinitys7 marked this conversation as resolved.
Show resolved Hide resolved

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
case "/os.types.v1.ExtensionOptionDynamicFeeTx":
trinitys7 marked this conversation as resolved.
Show resolved Hide resolved
// cosmos-sdk tx with dynamic fee extension
anteHandler = newLegacyCosmosAnteHandlerEip712(options)
default:
return ctx, errorsmod.Wrapf(
Expand All @@ -55,3 +57,22 @@ func NewAnteHandler(options HandlerOptions) sdk.AnteHandler {
return anteHandler(ctx, tx, sim)
}
}

func Recover(logger log.Logger, err *error) {
if r := recover(); r != nil {
*err = errorsmod.Wrapf(errortypes.ErrPanic, "%v", r)

if e, ok := r.(error); ok {
logger.Error(
"ante handler panicked",
"error", e,
"stack trace", string(debug.Stack()),
)
} else {
logger.Error(
"ante handler panicked",
"recover", fmt.Sprintf("%v", r),
)
}
}
}
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