Skip to content

Commit

Permalink
imp(all): Bump to latest state on Evmos main (b72a32d76) (#60)
Browse files Browse the repository at this point in the history
  • Loading branch information
MalteHerrmann authored Nov 27, 2024
1 parent bf18711 commit aa55561
Show file tree
Hide file tree
Showing 310 changed files with 19,915 additions and 8,973 deletions.
5 changes: 2 additions & 3 deletions .clconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,8 @@
"OS": "os",
"PR": "pr",
"RPC": "rpc",
"SDK": "sdk",
"evmOS": "evmos"
"SDK": "sdk"
},
"legacy_version": null,
"target_repo": "https://github.com/evmos/os"
}
}
2 changes: 1 addition & 1 deletion .github/workflows/bsr-push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: bufbuild/buf-setup-action@v1.41.0
- uses: bufbuild/buf-setup-action@v1.47.2
# Push evmOS protos to the Buf Schema Registry
- uses: bufbuild/[email protected]
with:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ jobs:
go.mod
go.sum
*.toml
- uses: golangci/[email protected].0
- uses: golangci/[email protected].1
with:
# Required: the version of golangci-lint is required and must be specified without patch version: we always use the latest patch version.
version: latest
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/proto.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ jobs:
timeout-minutes: 5
steps:
- uses: actions/checkout@v4
- uses: bufbuild/buf-setup-action@v1.41.0
- uses: bufbuild/buf-setup-action@v1.47.2
- uses: bufbuild/buf-lint-action@v1
with:
input: "proto"
Expand All @@ -41,7 +41,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: bufbuild/buf-setup-action@v1.41.0
- uses: bufbuild/buf-setup-action@v1.47.2
- uses: bufbuild/buf-breaking-action@v1
with:
input: "proto"
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/super-linter.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ jobs:
PROTOBUF_CONFIG_FILE: .protolint.yml
VALIDATE_NATURAL_LANGUAGE: false
VALIDATE_OPENAPI: false
VALIDATE_JAVASCRIPT_STANDARD: false
VALIDATE_JSCPD: false
VALIDATE_GO: false
VALIDATE_GO_MODULES: false
Expand Down
3 changes: 1 addition & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ jobs:
run: |
make test-unit-cover
if: env.GIT_DIFF
- uses: codecov/codecov-action@v4
- uses: codecov/codecov-action@v5
with:
file: ./coverage.txt
# We were getting a 500 error on codecov servers
Expand All @@ -60,7 +60,6 @@ jobs:
uses: actions/setup-python@v5
with:
python-version: "3.11"
cache: "pip" # caching pip dependencies
if: env.GIT_DIFF
- name: Install Pytest
run: |
Expand Down
3 changes: 1 addition & 2 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ linters:
- misspell
- nakedret
- prealloc
- exportloopref
- copyloopvar
- staticcheck
- stylecheck
- typecheck
Expand All @@ -33,7 +33,6 @@ linters:
- unused
- nolintlint
- asciicheck
- exportloopref
- gofumpt
- gomodguard

Expand Down
26 changes: 13 additions & 13 deletions .mergify.yml
Original file line number Diff line number Diff line change
@@ -1,21 +1,17 @@
queue_rules:
- name: default
conditions:
- "#approved-reviews-by>1"

pull_request_rules:
- name: automerge to main with label "automerge" and branch protection passing
conditions:
queue_conditions:
- "#approved-reviews-by>1"
- base=main
- label=automerge
actions:
queue:
name: default
method: squash
commit_message_template: |
{{ title }} (#{{ number }})
{{ body }}
merge_conditions:
- "#approved-reviews-by>1"
merge_method: squash
commit_message_template: |
{{ title }} (#{{ number }})
{{ body }}
pull_request_rules:
- name: backport patches to v6.0.x branch
conditions:
- base=main
Expand Down Expand Up @@ -48,3 +44,7 @@ pull_request_rules:
backport:
branches:
- release/v3.0.x
- name: refactored queue action rule
conditions: []
actions:
queue:
7 changes: 4 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,15 @@ This changelog was created using the `clu` binary

### Improvements

- (all) [#60](https://github.com/evmos/os/pull/60) Apply latest changes from Evmos repo (f943af3b to b72a32d76).
- (cli) [#55](https://github.com/evmos/os/pull/55) Add missing list key types subcommand.
- (cli) [#54](https://github.com/evmos/os/pull/54) Align debug CLI commands with Cosmos SDK plus other minor clean up.
- (cli) [#53](https://github.com/evmos/os/pull/53) Enable specifying default key type for adding keys.
- (ante) [#52](https://github.com/evmos/os/pull/52) Refactor ante handlers to be easier to use in partner chains.
- (all) [#48](https://github.com/evmos/os/pull/48) Move latest changes from evmOS main (f943af3b incl. SDK v50).
- (all) [#43](https://github.com/evmos/os/pull/43) Update with latest evmOS main changes (2b7a8e2).
- (all) [#48](https://github.com/evmos/os/pull/48) Move latest changes from Evmos main (f943af3b incl. SDK v50).
- (all) [#43](https://github.com/evmos/os/pull/43) Update with latest Evmos main changes (2b7a8e2).
- (tests) [#41](https://github.com/evmos/os/pull/41) Add Solidity and Ledger tests.
- (all) [#37](https://github.com/evmos/os/pull/37) Add EVM, feemarket and precompiles from evmOS.
- (all) [#37](https://github.com/evmos/os/pull/37) Add EVM, feemarket and precompiles from Evmos.
- (all) [#38](https://github.com/evmos/os/pull/38) Add readme.
- (all) [#30](https://github.com/evmos/os/pull/30) Add example chain implementation and ante handlers.
- (ci) [#35](https://github.com/evmos/os/pull/35) Disable dependabot temporarily.
Expand Down
6 changes: 3 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,9 @@ test-unit-cover: TEST_PACKAGES=$(PACKAGES_UNIT)

run-tests:
ifneq (,$(shell which tparse 2>/dev/null))
go test -mod=readonly -json $(ARGS) $(EXTRA_ARGS) $(TEST_PACKAGES) | tparse
go test -tags=test -mod=readonly -json $(ARGS) $(EXTRA_ARGS) $(TEST_PACKAGES) | tparse
else
go test -mod=readonly $(ARGS) $(EXTRA_ARGS) $(TEST_PACKAGES)
go test -tags=test -mod=readonly $(ARGS) $(EXTRA_ARGS) $(TEST_PACKAGES)
endif

test-scripts:
Expand All @@ -70,7 +70,7 @@ test-solidity:
.PHONY: run-tests test test-all $(TEST_TARGETS)

benchmark:
@go test -mod=readonly -bench=. $(PACKAGES_NOSIMULATION)
@go test -tags=test -mod=readonly -bench=. $(PACKAGES_NOSIMULATION)

.PHONY: benchmark

Expand Down
31 changes: 18 additions & 13 deletions ante/cosmos/authz_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ import (
ethtypes "github.com/ethereum/go-ethereum/core/types"
cosmosante "github.com/evmos/os/ante/cosmos"
"github.com/evmos/os/testutil"
testconstants "github.com/evmos/os/testutil/constants"
"github.com/evmos/os/testutil/integration/common/factory"
"github.com/evmos/os/testutil/integration/os/network"
utiltx "github.com/evmos/os/testutil/tx"
Expand All @@ -31,6 +30,7 @@ func TestAuthzLimiterDecorator(t *testing.T) {
testPrivKeys, testAddresses, err := generatePrivKeyAddressPairs(5)
require.NoError(t, err)

evmDenom := evmtypes.GetEVMCoinDenom()
distantFuture := time.Date(9000, 1, 1, 0, 0, 0, 0, time.UTC)

validator := sdk.ValAddress(testAddresses[4])
Expand All @@ -57,7 +57,7 @@ func TestAuthzLimiterDecorator(t *testing.T) {
banktypes.NewMsgSend(
testAddresses[0],
testAddresses[1],
sdk.NewCoins(sdk.NewInt64Coin(testconstants.ExampleAttoDenom, 100e6)),
sdk.NewCoins(sdk.NewInt64Coin(evmDenom, 100e6)),
),
},
false,
Expand Down Expand Up @@ -139,7 +139,7 @@ func TestAuthzLimiterDecorator(t *testing.T) {
[]sdk.Msg{banktypes.NewMsgSend(
testAddresses[0],
testAddresses[3],
sdk.NewCoins(sdk.NewInt64Coin(testconstants.ExampleAttoDenom, 100e6)),
sdk.NewCoins(sdk.NewInt64Coin(evmDenom, 100e6)),
)}),
},
false,
Expand Down Expand Up @@ -173,7 +173,7 @@ func TestAuthzLimiterDecorator(t *testing.T) {
banktypes.NewMsgSend(
testAddresses[0],
testAddresses[3],
sdk.NewCoins(sdk.NewInt64Coin(testconstants.ExampleAttoDenom, 100e6)),
sdk.NewCoins(sdk.NewInt64Coin(evmDenom, 100e6)),
),
&evmtypes.MsgEthereumTx{},
},
Expand Down Expand Up @@ -224,7 +224,7 @@ func TestAuthzLimiterDecorator(t *testing.T) {
banktypes.NewMsgSend(
testAddresses[0],
testAddresses[3],
sdk.NewCoins(sdk.NewInt64Coin(testconstants.ExampleAttoDenom, 100e6)),
sdk.NewCoins(sdk.NewInt64Coin(evmDenom, 100e6)),
),
},
),
Expand All @@ -242,7 +242,7 @@ func TestAuthzLimiterDecorator(t *testing.T) {
banktypes.NewMsgSend(
testAddresses[0],
testAddresses[3],
sdk.NewCoins(sdk.NewInt64Coin(testconstants.ExampleAttoDenom, 100e6)),
sdk.NewCoins(sdk.NewInt64Coin(evmDenom, 100e6)),
),
},
),
Expand All @@ -253,7 +253,7 @@ func TestAuthzLimiterDecorator(t *testing.T) {
banktypes.NewMsgSend(
testAddresses[0],
testAddresses[3],
sdk.NewCoins(sdk.NewInt64Coin(testconstants.ExampleAttoDenom, 100e6)),
sdk.NewCoins(sdk.NewInt64Coin(evmDenom, 100e6)),
),
},
),
Expand Down Expand Up @@ -288,13 +288,18 @@ func (suite *AnteTestSuite) TestRejectMsgsInAuthz() {
distantFuture := time.Date(9000, 1, 1, 0, 0, 0, 0, time.UTC)

nw := suite.GetNetwork()
evmDenom := evmtypes.GetEVMCoinDenom()

baseFeeRes, err := nw.GetEvmClient().BaseFee(nw.GetContext(), &evmtypes.QueryBaseFeeRequest{})
suite.Require().NoError(err, "failed to get base fee")

// create a dummy MsgEthereumTx for the test
// otherwise throws error that cannot unpack tx data
msgEthereumTx := evmtypes.NewTx(&evmtypes.EvmTxArgs{
ChainID: nw.GetEIP155ChainID(),
Nonce: 0,
GasLimit: gasLimit,
GasFeeCap: nw.App.FeeMarketKeeper.GetBaseFee(nw.GetContext()),
GasFeeCap: baseFeeRes.BaseFee.BigInt(),
GasTipCap: big.NewInt(1),
Input: nil,
Accesses: &ethtypes.AccessList{},
Expand Down Expand Up @@ -344,7 +349,7 @@ func (suite *AnteTestSuite) TestRejectMsgsInAuthz() {
banktypes.NewMsgSend(
testAddresses[0],
testAddresses[3],
sdk.NewCoins(sdk.NewInt64Coin(testconstants.ExampleAttoDenom, 100e6)),
sdk.NewCoins(sdk.NewInt64Coin(evmDenom, 100e6)),
),
msgEthereumTx,
},
Expand Down Expand Up @@ -375,7 +380,7 @@ func (suite *AnteTestSuite) TestRejectMsgsInAuthz() {
banktypes.NewMsgSend(
testAddresses[0],
testAddresses[3],
sdk.NewCoins(sdk.NewInt64Coin(testconstants.ExampleAttoDenom, 100e6)),
sdk.NewCoins(sdk.NewInt64Coin(evmDenom, 100e6)),
),
},
),
Expand All @@ -392,7 +397,7 @@ func (suite *AnteTestSuite) TestRejectMsgsInAuthz() {
banktypes.NewMsgSend(
testAddresses[0],
testAddresses[3],
sdk.NewCoins(sdk.NewInt64Coin(testconstants.ExampleAttoDenom, 100e6)),
sdk.NewCoins(sdk.NewInt64Coin(evmDenom, 100e6)),
),
},
),
Expand All @@ -403,7 +408,7 @@ func (suite *AnteTestSuite) TestRejectMsgsInAuthz() {
banktypes.NewMsgSend(
testAddresses[0],
testAddresses[3],
sdk.NewCoins(sdk.NewInt64Coin(testconstants.ExampleAttoDenom, 100e6)),
sdk.NewCoins(sdk.NewInt64Coin(evmDenom, 100e6)),
),
},
),
Expand All @@ -424,7 +429,7 @@ func (suite *AnteTestSuite) TestRejectMsgsInAuthz() {
priv := suite.GetKeyring().GetPrivKey(0)

if tc.isEIP712 {
coinAmount := sdk.NewCoin(testconstants.ExampleAttoDenom, math.NewInt(20))
coinAmount := sdk.NewCoin(evmDenom, math.NewInt(20))
fees := sdk.NewCoins(coinAmount)
cosmosTxArgs := utiltx.CosmosTxArgs{
TxCfg: suite.GetClientCtx().TxConfig,
Expand Down
12 changes: 6 additions & 6 deletions ante/cosmos/min_gas_price.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import (
sdk "github.com/cosmos/cosmos-sdk/types"
errortypes "github.com/cosmos/cosmos-sdk/types/errors"
anteinterfaces "github.com/evmos/os/ante/interfaces"
evmtypes "github.com/evmos/os/x/evm/types"
)

// MinGasPriceDecorator will check if the transaction's fee is at least as large
Expand All @@ -22,14 +23,14 @@ import (
// If fee is high enough, then call next AnteHandler
// CONTRACT: Tx must implement FeeTx to use MinGasPriceDecorator
type MinGasPriceDecorator struct {
feesKeeper anteinterfaces.FeeMarketKeeper
evmKeeper anteinterfaces.EVMKeeper
feemarketKeeper anteinterfaces.FeeMarketKeeper
evmKeeper anteinterfaces.EVMKeeper
}

// NewMinGasPriceDecorator creates a new MinGasPriceDecorator instance used only for
// Cosmos transactions.
func NewMinGasPriceDecorator(fk anteinterfaces.FeeMarketKeeper, ek anteinterfaces.EVMKeeper) MinGasPriceDecorator {
return MinGasPriceDecorator{feesKeeper: fk, evmKeeper: ek}
return MinGasPriceDecorator{feemarketKeeper: fk, evmKeeper: ek}
}

func (mpd MinGasPriceDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, simulate bool, next sdk.AnteHandler) (newCtx sdk.Context, err error) {
Expand All @@ -38,11 +39,10 @@ func (mpd MinGasPriceDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, simulate
return ctx, errorsmod.Wrapf(errortypes.ErrInvalidType, "invalid transaction type %T, expected sdk.FeeTx", tx)
}

minGasPrice := mpd.feesKeeper.GetParams(ctx).MinGasPrice
minGasPrice := mpd.feemarketKeeper.GetParams(ctx).MinGasPrice

feeCoins := feeTx.GetFee()
evmParams := mpd.evmKeeper.GetParams(ctx)
evmDenom := evmParams.GetEvmDenom()
evmDenom := evmtypes.GetEVMCoinDenom()

// only allow user to pass in aevmos and stake native token as transaction fees
// allow use stake native tokens for fees is just for unit tests to pass
Expand Down
15 changes: 12 additions & 3 deletions ante/evm/01_setup_ctx.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,25 +28,34 @@ func NewEthSetUpContextDecorator(evmKeeper anteinterfaces.EVMKeeper) EthSetupCon
}

func (esc EthSetupContextDecorator) AnteHandle(ctx sdktypes.Context, tx sdktypes.Tx, simulate bool, next sdktypes.AnteHandler) (newCtx sdktypes.Context, err error) {
newCtx, err = SetupContext(ctx, tx, esc.evmKeeper)
newCtx, err = SetupContextAndResetTransientGas(ctx, tx, esc.evmKeeper)
if err != nil {
return ctx, err
}
return next(newCtx, tx, simulate)
}

func SetupContext(ctx sdktypes.Context, tx sdktypes.Tx, evmKeeper anteinterfaces.EVMKeeper) (sdktypes.Context, error) {
// SetupContextAndResetTransientGas modifies the context to be used in the
// execution of the ante handler associated with an EVM transaction. Previous
// gas consumed is reset in the transient store.
func SetupContextAndResetTransientGas(ctx sdktypes.Context, tx sdktypes.Tx, evmKeeper anteinterfaces.EVMKeeper) (sdktypes.Context, error) {
// all transactions must implement GasTx
_, ok := tx.(authante.GasTx)
if !ok {
return ctx, errorsmod.Wrapf(errortypes.ErrInvalidType, "invalid transaction type %T, expected GasTx", tx)
}

// We need to set up an empty gas config so that the gas is consistent with Ethereum.
// To have gas consumption consistent with Ethereum, we need to:
// 1. Set an empty gas config for both KV and transient store.
// 2. Set an infinite gas meter.
newCtx := evmante.BuildEvmExecutionCtx(ctx).
WithGasMeter(storetypes.NewInfiniteGasMeter())

// Reset transient gas used to prepare the execution of current cosmos tx.
// Transient gas-used is necessary to sum the gas-used of cosmos tx, when it contains multiple eth msgs.
//
// TODO: add more context here to explain why gas used is reset. Not clear
// from docstring.
evmKeeper.ResetTransientGasUsed(ctx)

return newCtx, nil
Expand Down
2 changes: 1 addition & 1 deletion ante/evm/01_setup_ctx_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import (
func (suite *AnteTestSuite) TestEthSetupContextDecorator() {
dec := evmante.NewEthSetUpContextDecorator(suite.GetNetwork().App.EVMKeeper)
ethContractCreationTxParams := &evmtypes.EvmTxArgs{
ChainID: suite.GetNetwork().App.EVMKeeper.ChainID(),
ChainID: evmtypes.GetEthChainConfig().ChainID,
Nonce: 1,
Amount: big.NewInt(10),
GasLimit: 1000,
Expand Down
Loading

0 comments on commit aa55561

Please sign in to comment.