Skip to content

Commit a984d4f

Browse files
authored
Merge pull request #164 from xpladev/release/v1.7.x
v1.7
2 parents bb718ae + 75c8ed9 commit a984d4f

File tree

112 files changed

+171711
-41400
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

112 files changed

+171711
-41400
lines changed

.github/workflows/go.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ jobs:
1313

1414
strategy:
1515
matrix:
16-
go-version: [1.21.x]
16+
go-version: [1.23.x]
1717

1818
steps:
1919
- uses: actions/checkout@v3

.github/workflows/integration-test.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ jobs:
2424
- name: Set up Go
2525
uses: actions/setup-go@v3
2626
with:
27-
go-version: 1.20.x
27+
go-version: 1.23.x
2828

2929
- name: End-to-end test
3030
run: cd tests/e2e && go test

Dockerfile

+4-4
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,12 @@
77
# docker run --rm -it --env-file=path/to/.env --name xpla-localnet xpladev/xpla
88

99
### BUILD
10-
FROM golang:1.20-alpine3.17 AS build
10+
FROM golang:1.23-alpine AS build
1111

1212
# Create appuser.
1313
RUN adduser -D -g '' valiuser
1414
# Install required binaries
15-
RUN apk add --update --no-cache zip git make cmake build-base linux-headers musl-dev libc-dev
15+
RUN apk add --update --no-cache zip git make cmake build-base linux-headers musl-dev libc-dev binutils-gold
1616

1717
WORKDIR /
1818
RUN git clone --depth 1 https://github.com/microsoft/mimalloc; cd mimalloc; mkdir build; cd build; cmake ..; make -j$(nproc); make install
@@ -23,11 +23,11 @@ WORKDIR /workspace
2323
# Copy source files
2424
COPY . .
2525
# Download dependencies and CosmWasm libwasmvm if found.
26-
RUN set -eux; \
26+
RUN set -eux; \
2727
export ARCH=$(uname -m); \
2828
WASM_VERSION=$(go list -mod=readonly -m all | grep github.com/CosmWasm/wasmvm | awk '{print $2}'); \
2929
if [ ! -z "${WASM_VERSION}" ]; then \
30-
wget -O /lib/libwasmvm_muslc.a https://github.com/CosmWasm/wasmvm/releases/download/${WASM_VERSION}/libwasmvm_muslc.${ARCH}.a; \
30+
wget -O /lib/libwasmvm_muslc.${ARCH}.a https://github.com/CosmWasm/wasmvm/releases/download/${WASM_VERSION}/libwasmvm_muslc.${ARCH}.a; \
3131
fi; \
3232
go mod download;
3333

Makefile

+20-7
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,9 @@ APPNAME := xplad
1717
LEDGER_ENABLED ?= true
1818
TM_VERSION := $(shell go list -m github.com/cometbft/cometbft | sed 's:.* ::') # grab everything after the space in "github.com/cometbft/cometbft v0.34.7"
1919
BUILDDIR ?= $(CURDIR)/build
20-
GO_VERSION ?= "1.19"
20+
GO_SYSTEM_VERSION = $(shell go version | cut -c 14- | cut -d' ' -f1 | cut -d'.' -f1-2)
21+
REQUIRE_GO_VERSION = 1.23
22+
GO_VERSION ?= "$(REQUIRE_GO_VERSION)"
2123

2224
# for dockerized protobuf tools
2325
DOCKER := $(shell which docker)
@@ -35,7 +37,7 @@ ifeq ($(LEDGER_ENABLED),true)
3537
ifeq ($(GCCEXE),)
3638
$(error gcc.exe not installed for ledger support, please install or set LEDGER_ENABLED=false)
3739
else
38-
build_tags += ledger
40+
build_tags += ledger cgo
3941
endif
4042
else
4143
UNAME_S = $(shell uname -s)
@@ -46,7 +48,7 @@ ifeq ($(LEDGER_ENABLED),true)
4648
ifeq ($(GCC),)
4749
$(error gcc not installed for ledger support, please install or set LEDGER_ENABLED=false)
4850
else
49-
build_tags += ledger
51+
build_tags += ledger cgo
5052
endif
5153
endif
5254
endif
@@ -87,14 +89,20 @@ ifeq (,$(findstring nostrip,$(CUSTOM_BUILD_OPTIONS)))
8789
BUILD_FLAGS += -trimpath
8890
endif
8991

92+
check_version:
93+
ifneq ($(GO_SYSTEM_VERSION),$(REQUIRE_GO_VERSION))
94+
@echo "ERROR: Go version $(REQUIRE_GO_VERSION) is required for $(VERSION) of xpla, but system has $(GO_SYSTEM_VERSION)."
95+
exit 1
96+
endif
97+
9098
all: install
9199

92100
.PHONY: install
93-
install: go.sum
101+
install: check_version go.sum
94102
go install -mod=readonly $(BUILD_FLAGS) ./cmd/xplad
95103

96104
.PHONY: build
97-
build: go.sum
105+
build: check_version go.sum
98106
go build -mod=readonly $(BUILD_FLAGS) -o build/xplad ./cmd/xplad
99107

100108
build-release: build/linux/amd64 build/linux/arm64
@@ -141,7 +149,8 @@ build-release-arm64: go.sum $(BUILDDIR)/
141149

142150
.PHONY: test
143151
test: go.sum
144-
go test -short ./...
152+
go clean -testcache
153+
go test -short -p 1 ./...
145154

146155
go.sum: go.mod
147156
@go mod verify
@@ -150,7 +159,7 @@ go.sum: go.mod
150159
###############################################################################
151160
### Protobuf ###
152161
###############################################################################
153-
PROTO_VERSION=0.11.6
162+
PROTO_VERSION=0.13.0
154163
PROTO_BUILDER_IMAGE=ghcr.io/cosmos/proto-builder:$(PROTO_VERSION)
155164
PROTO_FORMATTER_IMAGE=$(DOCKER) run --rm -v $(CURDIR):/workspace --workdir /workspace --user 0 $(PROTO_BUILDER_IMAGE)
156165

@@ -170,3 +179,7 @@ proto-swagger-gen:
170179

171180
proto-lint:
172181
$(PROTO_FORMATTER_IMAGE) buf lint --error-format=json
182+
183+
proto-update-deps:
184+
@echo "Updating Protobuf dependencies"
185+
$(DOCKER) run --rm -v $(CURDIR)/proto:/workspace --workdir /workspace $(PROTO_BUILDER_IMAGE) buf mod update

ante/ante.go

+32-34
Original file line numberDiff line numberDiff line change
@@ -4,53 +4,52 @@ import (
44
"fmt"
55
"runtime/debug"
66

7+
ibcante "github.com/cosmos/ibc-go/v8/modules/core/ante"
8+
ibckeeper "github.com/cosmos/ibc-go/v8/modules/core/keeper"
9+
10+
corestoretypes "cosmossdk.io/core/store"
711
errorsmod "cosmossdk.io/errors"
8-
tmlog "github.com/cometbft/cometbft/libs/log"
12+
tmlog "cosmossdk.io/log"
13+
//storetypes "cosmossdk.io/store/types"
14+
txsigning "cosmossdk.io/x/tx/signing"
15+
16+
wasmkeeper "github.com/CosmWasm/wasmd/x/wasm/keeper"
17+
wasmtypes "github.com/CosmWasm/wasmd/x/wasm/types"
918
"github.com/cosmos/cosmos-sdk/codec"
10-
storetypes "github.com/cosmos/cosmos-sdk/store/types"
1119
sdk "github.com/cosmos/cosmos-sdk/types"
1220
errortypes "github.com/cosmos/cosmos-sdk/types/errors"
1321
authante "github.com/cosmos/cosmos-sdk/x/auth/ante"
14-
authsigning "github.com/cosmos/cosmos-sdk/x/auth/signing"
15-
vestingtypes "github.com/cosmos/cosmos-sdk/x/auth/vesting/types"
16-
ibcante "github.com/cosmos/ibc-go/v7/modules/core/ante"
17-
ibckeeper "github.com/cosmos/ibc-go/v7/modules/core/keeper"
18-
19-
wasmkeeper "github.com/CosmWasm/wasmd/x/wasm/keeper"
20-
wasmTypes "github.com/CosmWasm/wasmd/x/wasm/types"
2122

2223
evmante "github.com/xpladev/ethermint/app/ante"
2324
evmtypes "github.com/xpladev/ethermint/x/evm/types"
2425

2526
volunteerante "github.com/xpladev/xpla/x/volunteer/ante"
2627
)
2728

28-
// HandlerOptions extend the SDK's AnteHandler opts by requiring the IBC
29+
// HandlerOptions extend the SDK's AnteHandler options by requiring the IBC
2930
// channel keeper.
3031
type HandlerOptions struct {
31-
Cdc codec.BinaryCodec
32-
AccountKeeper evmtypes.AccountKeeper
33-
BankKeeper evmtypes.BankKeeper
34-
IBCKeeper *ibckeeper.Keeper
35-
EvmKeeper evmante.EVMKeeper
36-
FeegrantKeeper authante.FeegrantKeeper
37-
VolunteerKeeper volunteerante.VolunteerKeeper
3832
ExtensionOptionChecker authante.ExtensionOptionChecker
39-
SignModeHandler authsigning.SignModeHandler
33+
FeegrantKeeper authante.FeegrantKeeper
34+
SignModeHandler *txsigning.HandlerMap
4035
SigGasConsumer authante.SignatureVerificationGasConsumer
41-
FeeMarketKeeper evmante.FeeMarketKeeper
42-
MaxTxGasWanted uint64
43-
TxFeeChecker authante.TxFeeChecker
44-
45-
BypassMinFeeMsgTypes []string
46-
TxCounterStoreKey storetypes.StoreKey
47-
WasmKeeper *wasmkeeper.Keeper
48-
WasmConfig wasmTypes.WasmConfig
36+
37+
AccountKeeper evmtypes.AccountKeeper
38+
BankKeeper evmtypes.BankKeeper
39+
Codec codec.BinaryCodec
40+
IBCKeeper *ibckeeper.Keeper
41+
EvmKeeper evmante.EVMKeeper
42+
VolunteerKeeper volunteerante.VolunteerKeeper
43+
BypassMinFeeMsgTypes []string
44+
FeeMarketKeeper evmante.FeeMarketKeeper
45+
MaxTxGasWanted uint64
46+
TxFeeChecker authante.TxFeeChecker
47+
TXCounterStoreService corestoretypes.KVStoreService
48+
WasmConfig *wasmtypes.WasmConfig
4949
}
5050

5151
var disabledAuthzMsgs = []string{
5252
sdk.MsgTypeURL(&evmtypes.MsgEthereumTx{}),
53-
sdk.MsgTypeURL(&vestingtypes.MsgCreateVestingAccount{}),
5453
}
5554

5655
// NewAnteHandler returns an 'AnteHandler' that will run actions before a tx is sent to a module's handler.
@@ -62,7 +61,7 @@ func NewAnteHandler(opts HandlerOptions) (sdk.AnteHandler, error) {
6261
return nil, errorsmod.Wrap(errortypes.ErrLogic, "bank keeper is required for AnteHandler")
6362
}
6463
if opts.SignModeHandler == nil {
65-
return nil, errorsmod.Wrap(errortypes.ErrLogic, "sign mode handler is required for ante builder")
64+
return nil, errorsmod.Wrap(errortypes.ErrLogic, "sign mode handler is required for AnteHandler")
6665
}
6766
if opts.IBCKeeper == nil {
6867
return nil, errorsmod.Wrap(errortypes.ErrLogic, "IBC keeper is required for AnteHandler")
@@ -74,7 +73,7 @@ func NewAnteHandler(opts HandlerOptions) (sdk.AnteHandler, error) {
7473
return nil, errorsmod.Wrap(errortypes.ErrLogic, "Feegrant keeper is required for AnteHandler")
7574
}
7675
if opts.FeeMarketKeeper == nil {
77-
return nil, errorsmod.Wrap(errortypes.ErrLogic, "Feemarket keeper is required for AnteHandler")
76+
return nil, errorsmod.Wrap(errortypes.ErrLogic, "FeeMarket keeper is required for AnteHandler")
7877
}
7978
if opts.VolunteerKeeper == nil {
8079
return nil, errorsmod.Wrap(errortypes.ErrLogic, "staking keeper is required for AnteHandler")
@@ -125,7 +124,7 @@ func NewAnteHandler(opts HandlerOptions) (sdk.AnteHandler, error) {
125124
}
126125

127126
func newCosmosAnteHandler(opts HandlerOptions) sdk.AnteHandler {
128-
var sigGasConsumer = opts.SigGasConsumer
127+
sigGasConsumer := opts.SigGasConsumer
129128
if sigGasConsumer == nil {
130129
sigGasConsumer = SigVerificationGasConsumer
131130
}
@@ -136,10 +135,9 @@ func newCosmosAnteHandler(opts HandlerOptions) sdk.AnteHandler {
136135
evmante.NewAuthzLimiterDecorator(disabledAuthzMsgs),
137136
volunteerante.NewRejectDelegateVolunteerValidatorDecorator(opts.VolunteerKeeper),
138137
authante.NewSetUpContextDecorator(), // second decorator. SetUpContext must be called before other decorators
139-
authante.NewExtensionOptionsDecorator(opts.ExtensionOptionChecker),
140138
wasmkeeper.NewLimitSimulationGasDecorator(opts.WasmConfig.SimulationGasLimit),
141-
wasmkeeper.NewCountTXDecorator(opts.TxCounterStoreKey),
142-
wasmkeeper.NewGasRegisterDecorator(opts.WasmKeeper.GetGasRegister()),
139+
wasmkeeper.NewCountTXDecorator(opts.TXCounterStoreService),
140+
authante.NewExtensionOptionsDecorator(opts.ExtensionOptionChecker),
143141
NewMinGasPriceDecorator(opts.FeeMarketKeeper, opts.EvmKeeper, opts.BypassMinFeeMsgTypes),
144142
authante.NewValidateBasicDecorator(),
145143
authante.NewTxTimeoutHeightDecorator(),
@@ -150,7 +148,7 @@ func newCosmosAnteHandler(opts HandlerOptions) sdk.AnteHandler {
150148
authante.NewValidateSigCountDecorator(opts.AccountKeeper),
151149
authante.NewSigGasConsumeDecorator(opts.AccountKeeper, sigGasConsumer),
152150
authante.NewSigVerificationDecorator(opts.AccountKeeper, opts.SignModeHandler),
153-
authante.NewIncrementSequenceDecorator(opts.AccountKeeper), // innermost AnteDecorator
151+
authante.NewIncrementSequenceDecorator(opts.AccountKeeper),
154152
ibcante.NewRedundantRelayDecorator(opts.IBCKeeper),
155153
evmante.NewGasWantedDecorator(opts.EvmKeeper, opts.FeeMarketKeeper),
156154
}

ante/ante_test.go

+10-6
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import (
1313
sdk "github.com/cosmos/cosmos-sdk/types"
1414
moduletestutil "github.com/cosmos/cosmos-sdk/types/module/testutil"
1515
"github.com/cosmos/cosmos-sdk/types/tx/signing"
16-
xauthsigning "github.com/cosmos/cosmos-sdk/x/auth/signing"
16+
authsigning "github.com/cosmos/cosmos-sdk/x/auth/signing"
1717
"github.com/stretchr/testify/suite"
1818

1919
xplaapp "github.com/xpladev/xpla/app"
@@ -40,7 +40,7 @@ func (s *IntegrationTestSuite) SetupTest() {
4040

4141
app := xplahelpers.Setup(s.T(), chainId)
4242

43-
ctx := app.BaseApp.NewContext(false, tmproto.Header{
43+
ctx := app.BaseApp.NewUncachedContext(false, tmproto.Header{
4444
ChainID: chainId,
4545
Height: 1,
4646
})
@@ -54,13 +54,16 @@ func (s *IntegrationTestSuite) SetupTest() {
5454
s.clientCtx = client.Context{}.WithTxConfig(encodingConfig.TxConfig)
5555
}
5656

57-
func (s *IntegrationTestSuite) CreateTestTx(privs []cryptotypes.PrivKey, accNums []uint64, accSeqs []uint64, chainID string) (xauthsigning.Tx, error) {
57+
func (s *IntegrationTestSuite) CreateTestTx(privs []cryptotypes.PrivKey, accNums []uint64, accSeqs []uint64, chainID string) (authsigning.Tx, error) {
5858
var sigsV2 []signing.SignatureV2
59+
defaultSignMode, err := authsigning.APISignModeToInternal(s.clientCtx.TxConfig.SignModeHandler().DefaultMode())
60+
s.Require().NoError(err)
61+
5962
for i, priv := range privs {
6063
sigV2 := signing.SignatureV2{
6164
PubKey: priv.PubKey(),
6265
Data: &signing.SingleSignatureData{
63-
SignMode: s.clientCtx.TxConfig.SignModeHandler().DefaultMode(),
66+
SignMode: defaultSignMode,
6467
Signature: nil,
6568
},
6669
Sequence: accSeqs[i],
@@ -75,13 +78,14 @@ func (s *IntegrationTestSuite) CreateTestTx(privs []cryptotypes.PrivKey, accNums
7578

7679
sigsV2 = []signing.SignatureV2{}
7780
for i, priv := range privs {
78-
signerData := xauthsigning.SignerData{
81+
signerData := authsigning.SignerData{
7982
ChainID: chainID,
8083
AccountNumber: accNums[i],
8184
Sequence: accSeqs[i],
8285
}
8386
sigV2, err := tx.SignWithPrivKey(
84-
s.clientCtx.TxConfig.SignModeHandler().DefaultMode(),
87+
s.ctx,
88+
defaultSignMode,
8589
signerData,
8690
s.txBuilder,
8791
priv,

ante/fee.go

+6-3
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@ package ante
33
import (
44
"math/big"
55

6+
errorsmod "cosmossdk.io/errors"
7+
sdkmath "cosmossdk.io/math"
8+
69
tmstrings "github.com/cometbft/cometbft/libs/strings"
710
sdk "github.com/cosmos/cosmos-sdk/types"
811
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
@@ -31,7 +34,7 @@ func NewMinGasPriceDecorator(fk ethermintante.FeeMarketKeeper, ek ethermintante.
3134
func (mpd MinGasPriceDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, simulate bool, next sdk.AnteHandler) (newCtx sdk.Context, err error) {
3235
feeTx, ok := tx.(sdk.FeeTx)
3336
if !ok {
34-
return ctx, sdkerrors.Wrap(sdkerrors.ErrTxDecode, "Tx must be a FeeTx")
37+
return ctx, errorsmod.Wrap(sdkerrors.ErrTxDecode, "Tx must be a FeeTx")
3538
}
3639

3740
minGasPrice := mpd.feesKeeper.GetParams(ctx).MinGasPrice
@@ -57,7 +60,7 @@ func (mpd MinGasPriceDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, simulate
5760

5861
// Determine the required fees by multiplying each required minimum gas
5962
// price by the gas limit, where fee = ceil(minGasPrice * gasLimit).
60-
gasLimit := sdk.NewDecFromBigInt(new(big.Int).SetUint64(gas))
63+
gasLimit := sdkmath.LegacyNewDecFromBigInt(new(big.Int).SetUint64(gas))
6164

6265
for _, gp := range minGasPrices {
6366
fee := gp.Amount.Mul(gasLimit).Ceil().RoundInt()
@@ -67,7 +70,7 @@ func (mpd MinGasPriceDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, simulate
6770
}
6871

6972
if !feeCoins.IsAnyGTE(requiredFees) {
70-
return ctx, sdkerrors.Wrapf(sdkerrors.ErrInsufficientFee, "provided fee < minimum global fee (%s < %s). Please increase the gas price.", feeCoins, requiredFees)
73+
return ctx, errorsmod.Wrapf(sdkerrors.ErrInsufficientFee, "provided fee < minimum global fee (%s < %s). Please increase the gas price.", feeCoins, requiredFees)
7174
}
7275

7376
return next(ctx, tx, simulate)

ante/fee_test.go

+8-5
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,24 @@
11
package ante_test
22

33
import (
4+
sdkmath "cosmossdk.io/math"
5+
46
cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types"
57
"github.com/cosmos/cosmos-sdk/testutil/testdata"
68
sdk "github.com/cosmos/cosmos-sdk/types"
7-
ibcclienttypes "github.com/cosmos/ibc-go/v7/modules/core/02-client/types"
8-
ibcchanneltypes "github.com/cosmos/ibc-go/v7/modules/core/04-channel/types"
9+
10+
ibcclienttypes "github.com/cosmos/ibc-go/v8/modules/core/02-client/types"
11+
ibcchanneltypes "github.com/cosmos/ibc-go/v8/modules/core/04-channel/types"
12+
913
feemarkettypes "github.com/xpladev/ethermint/x/feemarket/types"
1014

1115
"github.com/xpladev/xpla/ante"
1216
)
1317

1418
func (s *IntegrationTestSuite) TestMinGasPriceDecorator() {
15-
s.SetupTest()
1619
s.txBuilder = s.clientCtx.TxConfig.NewTxBuilder()
1720

18-
s.app.FeeMarketKeeper.SetParams(s.ctx, feemarkettypes.NewParams(true, 8, 2, 0, 0, sdk.NewDec(200), sdk.MustNewDecFromStr("1.5")))
21+
s.app.FeeMarketKeeper.SetParams(s.ctx, feemarkettypes.NewParams(true, 8, 2, 0, 0, sdkmath.LegacyNewDec(200), sdkmath.LegacyMustNewDecFromStr("1.5")))
1922

2023
mpd := ante.NewMinGasPriceDecorator(
2124
s.app.FeeMarketKeeper,
@@ -40,7 +43,7 @@ func (s *IntegrationTestSuite) TestMinGasPriceDecorator() {
4043
s.Require().NoError(err)
4144

4245
// Set high gas price so standard test fee fails
43-
feeAmt := sdk.NewDecCoinFromDec("uatom", sdk.NewDec(200).Quo(sdk.NewDec(100000)))
46+
feeAmt := sdk.NewDecCoinFromDec("uatom", sdkmath.LegacyNewDec(200).Quo(sdkmath.LegacyNewDec(100000)))
4447
minGasPrice := []sdk.DecCoin{feeAmt}
4548
s.ctx = s.ctx.WithMinGasPrices(minGasPrice).WithIsCheckTx(true)
4649

0 commit comments

Comments
 (0)