diff --git a/.github/workflows/dependencies.yml b/.github/workflows/dependencies.yml new file mode 100644 index 00000000..c7f3aa8a --- /dev/null +++ b/.github/workflows/dependencies.yml @@ -0,0 +1,28 @@ +name: "Dependency Review" +on: pull_request + +permissions: + contents: read + +jobs: + dependency-review: + runs-on: ubuntu-latest + steps: + - uses: actions/setup-go@v3 + with: + go-version: 1.19 + check-latest: true + - name: "Checkout Repository" + uses: actions/checkout@v3 + - uses: technote-space/get-diff-action@v6.1.1 + with: + PATTERNS: | + **/**.go + go.mod + go.sum + - name: "Dependency Review" + uses: actions/dependency-review-action@v3 + if: env.GIT_DIFF + - name: "Go vulnerability check" + run: make vulncheck + if: env.GIT_DIFF diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 9456bb5c..f9c1d988 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -32,7 +32,7 @@ jobs: args: --timeout 10m github-token: ${{ secrets.github_token }} # Check only if there are differences in the source code - if: "env.GIT_DIFF" + if: env.GIT_DIFF markdown-lint: name: Run markdown-lint runs-on: ubuntu-latest diff --git a/CHANGELOG.md b/CHANGELOG.md index 98dc0747..3d28f95e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -36,11 +36,10 @@ Ref: https://keepachangelog.com/en/1.0.0/ # Changelog -## [v0.20.0-rc3] - 2022-11-30 +## [v0.20.0-rc3] - 2022-12-02 ### State Machine Breaking -* (deps) [#1419](https://github.com/evmos/ethermint/pull/1419) Add ics23 patch for dragonberry and bump iavl to v0.19.4 * (deps) [#1361](https://github.com/evmos/ethermint/pull/1361) Bump ibc-go to [`v5.1.0`](https://github.com/cosmos/ibc-go/releases/tag/v5.1.0) * (evm) [\#1272](https://github.com/evmos/ethermint/pull/1272) Implement modular interface for the EVM. * (deps) [#1168](https://github.com/evmos/ethermint/pull/1168) Upgrade Cosmos SDK to [`v0.46.6`](https://github.com/cosmos/cosmos-sdk/releases/tag/v0.46.6). @@ -51,15 +50,18 @@ Ref: https://keepachangelog.com/en/1.0.0/ * (ante) [1460](https://github.com/evmos/ethermint/pull/1460) Add KV Gas config on ethereum Txs. * (eth) [#1459](https://github.com/evmos/ethermint/pull/1459) Added support for messages with optional types omitted on eip712. * (geth) [#1413](https://github.com/evmos/ethermint/pull/1413) Update go-ethereum version to [`v1.10.26`](https://github.com/ethereum/go-ethereum/releases/tag/v1.10.26). +* (deps) [#1419](https://github.com/evmos/ethermint/pull/1419) Add ics23 patch for dragonberry and bump iavl to v0.19.4 ### API Breaking +* (ante) [#1521](https://github.com/evmos/ethermint/pull/1521) Deprecate support for legacy EIP-712 signature verification implementation via AnteHandler decorator. * (ante) [#1214](https://github.com/evmos/ethermint/pull/1214) Set mempool priority to EVM transactions. * (evm) [#1405](https://github.com/evmos/ethermint/pull/1405) Add parameter `chainID` to evm keeper's `EVMConfig` method, so caller can choose to not use the cached `eip155ChainID`. ### Features -- (app) [#1501](https://github.com/evmos/ethermint/pull/1501) Set default File store listener for application from [ADR38](https://docs.cosmos.network/v0.47/architecture/adr-038-state-listening) +* (ci) [#1528](https://github.com/evmos/ethermint/pull/1528) Add Golang dependency vulnerability checker. +* (app) [#1501](https://github.com/evmos/ethermint/pull/1501) Set default File store listener for application from [ADR38](https://docs.cosmos.network/v0.47/architecture/adr-038-state-listening) ### Improvements diff --git a/Makefile b/Makefile index 2d698c74..e9cc5663 100644 --- a/Makefile +++ b/Makefile @@ -155,7 +155,7 @@ clean: all: build -build-all: tools build lint test +build-all: tools build lint test vulncheck .PHONY: distclean clean build-all @@ -273,6 +273,10 @@ go.sum: go.mod go mod verify go mod tidy +vulncheck: $(BUILDDIR)/ + GOBIN=$(BUILDDIR) go install golang.org/x/vuln/cmd/govulncheck@latest + $(BUILDDIR)/govulncheck ./... + ############################################################################### ### Documentation ### ############################################################################### diff --git a/app/ante/ante.go b/app/ante/ante.go index 88bb9d0e..c3a4b1bf 100644 --- a/app/ante/ante.go +++ b/app/ante/ante.go @@ -46,8 +46,8 @@ func NewAnteHandler(options HandlerOptions) (sdk.AnteHandler, error) { // 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 = newCosmosAnteHandlerEip712(options) + // Deprecated: Handle as normal Cosmos SDK tx, except signature is checked for Legacy EIP712 representation + anteHandler = NewLegacyCosmosAnteHandlerEip712(options) case "/ethermint.types.v1.ExtensionOptionDynamicFeeTx": // cosmos-sdk tx with dynamic fee extension anteHandler = newCosmosAnteHandler(options) diff --git a/app/ante/eip712.go b/app/ante/eip712.go index 96f6e373..c773ba40 100644 --- a/app/ante/eip712.go +++ b/app/ante/eip712.go @@ -13,6 +13,7 @@ import ( authante "github.com/cosmos/cosmos-sdk/x/auth/ante" "github.com/cosmos/cosmos-sdk/x/auth/migrations/legacytx" authsigning "github.com/cosmos/cosmos-sdk/x/auth/signing" + ibcante "github.com/cosmos/ibc-go/v5/modules/core/ante" ethcrypto "github.com/ethereum/go-ethereum/crypto" "github.com/ethereum/go-ethereum/crypto/secp256k1" @@ -32,19 +33,47 @@ func init() { ethermintCodec = codec.NewProtoCodec(registry) } -// Eip712SigVerificationDecorator Verify all signatures for a tx and return an error if any are invalid. Note, -// the Eip712SigVerificationDecorator decorator will not get executed on ReCheck. +// Deprecated: NewLegacyCosmosAnteHandlerEip712 creates an AnteHandler to process legacy EIP-712 +// transactions, as defined by the presence of an ExtensionOptionsWeb3Tx extension. +func NewLegacyCosmosAnteHandlerEip712(options HandlerOptions) sdk.AnteHandler { + return sdk.ChainAnteDecorators( + RejectMessagesDecorator{}, // reject MsgEthereumTxs + authante.NewSetUpContextDecorator(), + authante.NewValidateBasicDecorator(), + authante.NewTxTimeoutHeightDecorator(), + NewMinGasPriceDecorator(options.FeeMarketKeeper, options.EvmKeeper), + authante.NewValidateMemoDecorator(options.AccountKeeper), + authante.NewConsumeGasForTxSizeDecorator(options.AccountKeeper), + authante.NewDeductFeeDecorator(options.AccountKeeper, options.BankKeeper, options.FeegrantKeeper, options.TxFeeChecker), + // SetPubKeyDecorator must be called before all signature verification decorators + authante.NewSetPubKeyDecorator(options.AccountKeeper), + authante.NewValidateSigCountDecorator(options.AccountKeeper), + authante.NewSigGasConsumeDecorator(options.AccountKeeper, options.SigGasConsumer), + // Note: signature verification uses EIP instead of the cosmos signature validator + NewLegacyEip712SigVerificationDecorator(options.AccountKeeper, options.SignModeHandler), + authante.NewIncrementSequenceDecorator(options.AccountKeeper), + ibcante.NewRedundantRelayDecorator(options.IBCKeeper), + NewGasWantedDecorator(options.EvmKeeper, options.FeeMarketKeeper), + ) +} + +// Deprecated: LegacyEip712SigVerificationDecorator Verify all signatures for a tx and return an error if any are invalid. Note, +// the LegacyEip712SigVerificationDecorator decorator will not get executed on ReCheck. +// NOTE: As of v0.20.0, EIP-712 signature verification is handled by the ethsecp256k1 public key (see ethsecp256k1.go) // // CONTRACT: Pubkeys are set in context for all signers before this decorator runs // CONTRACT: Tx must implement SigVerifiableTx interface -type Eip712SigVerificationDecorator struct { +type LegacyEip712SigVerificationDecorator struct { ak evmtypes.AccountKeeper signModeHandler authsigning.SignModeHandler } -// NewEip712SigVerificationDecorator creates a new Eip712SigVerificationDecorator -func NewEip712SigVerificationDecorator(ak evmtypes.AccountKeeper, signModeHandler authsigning.SignModeHandler) Eip712SigVerificationDecorator { - return Eip712SigVerificationDecorator{ +// Deprecated: NewLegacyEip712SigVerificationDecorator creates a new LegacyEip712SigVerificationDecorator +func NewLegacyEip712SigVerificationDecorator( + ak evmtypes.AccountKeeper, + signModeHandler authsigning.SignModeHandler, +) LegacyEip712SigVerificationDecorator { + return LegacyEip712SigVerificationDecorator{ ak: ak, signModeHandler: signModeHandler, } @@ -52,7 +81,7 @@ func NewEip712SigVerificationDecorator(ak evmtypes.AccountKeeper, signModeHandle // AnteHandle handles validation of EIP712 signed cosmos txs. // it is not run on RecheckTx -func (svd Eip712SigVerificationDecorator) AnteHandle(ctx sdk.Context, +func (svd LegacyEip712SigVerificationDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, simulate bool, next sdk.AnteHandler, diff --git a/app/ante/eth_test.go b/app/ante/eth_test.go index 1f591845..6d42310c 100644 --- a/app/ante/eth_test.go +++ b/app/ante/eth_test.go @@ -9,6 +9,7 @@ import ( "github.com/evmos/ethermint/app/ante" "github.com/evmos/ethermint/server/config" "github.com/evmos/ethermint/tests" + ethermint "github.com/evmos/ethermint/types" "github.com/evmos/ethermint/x/evm/statedb" evmtypes "github.com/evmos/ethermint/x/evm/types" @@ -180,6 +181,9 @@ func (suite AnteTestSuite) TestEthGasConsumeDecorator() { tx2.From = addr.Hex() tx2Priority := int64(1) + tx3GasLimit := ethermint.BlockGasLimit(suite.ctx) + uint64(1) + tx3 := evmtypes.NewTxContract(suite.app.EvmKeeper.ChainID(), 1, big.NewInt(10), tx3GasLimit, gasPrice, nil, nil, nil, ðtypes.AccessList{{Address: addr, StorageKeys: nil}}) + dynamicFeeTx := evmtypes.NewTxContract(suite.app.EvmKeeper.ChainID(), 1, big.NewInt(10), tx2GasLimit, nil, // gasPrice new(big.Int).Add(baseFee, big.NewInt(evmtypes.DefaultPriorityReduction.Int64()*2)), // gasFeeCap @@ -216,6 +220,14 @@ func (suite AnteTestSuite) TestEthGasConsumeDecorator() { false, false, 0, }, + { + "gas limit above block gas limit", + tx3, + math.MaxUint64, + func() {}, + false, false, + 0, + }, { "not enough balance for fees", tx2, diff --git a/app/ante/handler_options.go b/app/ante/handler_options.go index 96387aa6..cacf2896 100644 --- a/app/ante/handler_options.go +++ b/app/ante/handler_options.go @@ -87,27 +87,3 @@ func newCosmosAnteHandler(options HandlerOptions) sdk.AnteHandler { NewGasWantedDecorator(options.EvmKeeper, options.FeeMarketKeeper), ) } - -func newCosmosAnteHandlerEip712(options HandlerOptions) sdk.AnteHandler { - return sdk.ChainAnteDecorators( - RejectMessagesDecorator{}, // reject MsgEthereumTxs - ante.NewSetUpContextDecorator(), - // NOTE: extensions option decorator removed - // ante.NewRejectExtensionOptionsDecorator(), - ante.NewValidateBasicDecorator(), - ante.NewTxTimeoutHeightDecorator(), - NewMinGasPriceDecorator(options.FeeMarketKeeper, options.EvmKeeper), - ante.NewValidateMemoDecorator(options.AccountKeeper), - ante.NewConsumeGasForTxSizeDecorator(options.AccountKeeper), - ante.NewDeductFeeDecorator(options.AccountKeeper, options.BankKeeper, options.FeegrantKeeper, options.TxFeeChecker), - // SetPubKeyDecorator must be called before all signature verification decorators - ante.NewSetPubKeyDecorator(options.AccountKeeper), - ante.NewValidateSigCountDecorator(options.AccountKeeper), - ante.NewSigGasConsumeDecorator(options.AccountKeeper, options.SigGasConsumer), - // Note: signature verification uses EIP instead of the cosmos signature validator - NewEip712SigVerificationDecorator(options.AccountKeeper, options.SignModeHandler), - ante.NewIncrementSequenceDecorator(options.AccountKeeper), - ibcante.NewRedundantRelayDecorator(options.IBCKeeper), - NewGasWantedDecorator(options.EvmKeeper, options.FeeMarketKeeper), - ) -} diff --git a/cmd/ethermintd/flags.go b/cmd/ethermintd/flags.go index ed835f59..ea2b661f 100644 --- a/cmd/ethermintd/flags.go +++ b/cmd/ethermintd/flags.go @@ -8,9 +8,7 @@ import ( "github.com/evmos/ethermint/version" ) -const ( - flagLong = "long" -) +const flagLong = "long" func init() { infoCmd.Flags().Bool(flagLong, false, "Print full information") diff --git a/default.nix b/default.nix index c319aeaf..9b621609 100644 --- a/default.nix +++ b/default.nix @@ -3,7 +3,7 @@ , rev ? "dirty" }: let - version = "v0.17.1"; + version = "v0.20.0-rc2"; pname = "ethermintd"; tags = [ "netgo" ]; ldflags = lib.concatStringsSep "\n" ([ diff --git a/go.mod b/go.mod index 5d32bc62..16e4a358 100644 --- a/go.mod +++ b/go.mod @@ -8,7 +8,7 @@ require ( github.com/armon/go-metrics v0.4.1 github.com/btcsuite/btcd v0.22.1 github.com/btcsuite/btcutil v1.0.3-0.20201208143702-a53e38424cce - github.com/cosmos/cosmos-proto v1.0.0-alpha8 + github.com/cosmos/cosmos-proto v1.0.0-beta.1 github.com/cosmos/cosmos-sdk v0.46.6 github.com/cosmos/go-bip39 v1.0.0 github.com/cosmos/gogoproto v1.4.3 diff --git a/go.sum b/go.sum index 5fa85f45..710f7af4 100644 --- a/go.sum +++ b/go.sum @@ -226,8 +226,8 @@ github.com/coreos/go-systemd/v22 v22.3.3-0.20220203105225-a9a7ef127534/go.mod h1 github.com/coreos/pkg v0.0.0-20160727233714-3ac0863d7acf/go.mod h1:E3G3o1h8I7cfcXa63jLwjI0eiQQMgzzUDFVpN/nH/eA= github.com/cosmos/btcutil v1.0.4 h1:n7C2ngKXo7UC9gNyMNLbzqz7Asuf+7Qv4gnX/rOdQ44= github.com/cosmos/btcutil v1.0.4/go.mod h1:Ffqc8Hn6TJUdDgHBwIZLtrLQC1KdJ9jGJl/TvgUaxbU= -github.com/cosmos/cosmos-proto v1.0.0-alpha8 h1:d3pCRuMYYvGA5bM0ZbbjKn+AoQD4A7dyNG2wzwWalUw= -github.com/cosmos/cosmos-proto v1.0.0-alpha8/go.mod h1:6/p+Bc4O8JKeZqe0VqUGTX31eoYqemTT4C1hLCWsO7I= +github.com/cosmos/cosmos-proto v1.0.0-beta.1 h1:iDL5qh++NoXxG8hSy93FdYJut4XfgbShIocllGaXx/0= +github.com/cosmos/cosmos-proto v1.0.0-beta.1/go.mod h1:8k2GNZghi5sDRFw/scPL8gMSowT1vDA+5ouxL8GjaUE= github.com/cosmos/cosmos-sdk v0.46.6 h1:K9EZsqOZ2jQX3bIQUpn7Hk/YCoaJWRLU56PzvpX8INk= github.com/cosmos/cosmos-sdk v0.46.6/go.mod h1:JNklMfXo7MhDF1j/jxZCmDyOYyqhVoKB22e8p1ATEqA= github.com/cosmos/cosmos-sdk/ics23/go v0.8.0 h1:iKclrn3YEOwk4jQHT2ulgzuXyxmzmPczUalMwW4XH9k= diff --git a/gomod2nix.toml b/gomod2nix.toml index 650e3d13..f09b5bae 100644 --- a/gomod2nix.toml +++ b/gomod2nix.toml @@ -94,8 +94,8 @@ schema = 3 version = "v1.0.4" hash = "sha256-JvcBXBdjdmnaW/nyf/tw/uaOAGn1b78yxrtl2/Rs3kA=" [mod."github.com/cosmos/cosmos-proto"] - version = "v1.0.0-alpha8" - hash = "sha256-iXzXoS5Kfh5DBy+PhdFWraDWXda/3M4j7j4VECjv4CA=" + version = "v1.0.0-beta.1" + hash = "sha256-oATkuj+fM5eBn+ywO+w/tL0AFSIEkx0J3Yz+VhVe0QA=" [mod."github.com/cosmos/cosmos-sdk"] version = "v0.46.6" hash = "sha256-H1VZxZUWXhpXiY3A9smLp09MEGpXmh+XvX6YUiXPcpQ=" diff --git a/tests/integration_tests/README.md b/tests/integration_tests/README.md index d321b7fb..df4c2b8a 100644 --- a/tests/integration_tests/README.md +++ b/tests/integration_tests/README.md @@ -44,12 +44,11 @@ pytest -s -vv If you're changing anything on the ethermint rpc, rerun the first command. - ## Caching You can enable Binary Cache to speed up the tests: ``` -$ nix-env -iA cachix -f https://cachix.org/api/v1/install -$ cachix use ethermint -``` \ No newline at end of file +nix-env -iA cachix -f https://cachix.org/api/v1/install +cachix use ethermint +``` diff --git a/tests/integration_tests/hardhat/package-lock.json b/tests/integration_tests/hardhat/package-lock.json index f114b4a0..bce890d4 100644 --- a/tests/integration_tests/hardhat/package-lock.json +++ b/tests/integration_tests/hardhat/package-lock.json @@ -13491,9 +13491,12 @@ } }, "node_modules/minimist": { - "version": "1.2.6", - "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.6.tgz", - "integrity": "sha512-Jsjnk4bw3YJqYzbdyBiNsPWHPfO++UGG749Cxs6peCu5Xg4nrena6OVxOYxrQTqww0Jmwt+Ref8rggumkTLz9Q==" + "version": "1.2.7", + "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.7.tgz", + "integrity": "sha512-bzfL1YUZsP41gmu/qjrEk0Q6i2ix/cVeAhbCbqH9u3zYutS1cLg00qhrD0M2MVdCcx4Sc0UpP2eBWo9rotpq6g==", + "funding": { + "url": "https://github.com/sponsors/ljharb" + } }, "node_modules/mkdirp": { "version": "0.5.6", @@ -25791,9 +25794,9 @@ } }, "minimist": { - "version": "1.2.6", - "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.6.tgz", - "integrity": "sha512-Jsjnk4bw3YJqYzbdyBiNsPWHPfO++UGG749Cxs6peCu5Xg4nrena6OVxOYxrQTqww0Jmwt+Ref8rggumkTLz9Q==" + "version": "1.2.7", + "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.7.tgz", + "integrity": "sha512-bzfL1YUZsP41gmu/qjrEk0Q6i2ix/cVeAhbCbqH9u3zYutS1cLg00qhrD0M2MVdCcx4Sc0UpP2eBWo9rotpq6g==" }, "mkdirp": { "version": "0.5.6", diff --git a/tests/integration_tests/test_filters.py b/tests/integration_tests/test_filters.py index 659acc86..b20f807e 100644 --- a/tests/integration_tests/test_filters.py +++ b/tests/integration_tests/test_filters.py @@ -9,6 +9,7 @@ from .utils import ( deploy_contract, send_successful_transaction, send_transaction, + w3_wait_for_new_blocks, ) # Smart contract names @@ -21,6 +22,35 @@ CHANGE_GREETING_TOPIC = Web3.keccak(text="ChangeGreeting(address,string)") TRANSFER_TOPIC = Web3.keccak(text="Transfer(address,address,uint256)") +def test_get_logs_by_topic(cluster): + w3: Web3 = cluster.w3 + + contract, _ = deploy_contract(w3, CONTRACTS["Greeter"]) + + topic = Web3.keccak(text="ChangeGreeting(address,string)") + + # with tx + tx = contract.functions.setGreeting("world").build_transaction() + receipt = send_transaction(w3, tx) + assert receipt.status == 1 + + # The getLogs method under the hood works as a filter + # with the specified topics and a block range. + # If the block range is not specified, it defaults + # to fromBlock: "latest", toBlock: "latest". + # Then, if we make a getLogs call within the same block that the tx + # happened, we will get a log in the result. However, if we make the call + # one or more blocks later, the result will be an empty array. + logs = w3.eth.get_logs({"topics": [topic.hex()]}) + + assert len(logs) == 1 + assert logs[0]["address"] == contract.address + + w3_wait_for_new_blocks(w3, 2) + logs = w3.eth.get_logs({"topics": [topic.hex()]}) + assert len(logs) == 0 + + def test_pending_transaction_filter(cluster): w3: Web3 = cluster.w3 flt = w3.eth.filter("pending") diff --git a/tests/integration_tests/test_gas.py b/tests/integration_tests/test_gas.py old mode 100755 new mode 100644 index 223f681d..e35ae96c --- a/tests/integration_tests/test_gas.py +++ b/tests/integration_tests/test_gas.py @@ -1,4 +1,13 @@ -from .utils import ADDRS, CONTRACTS, KEYS, deploy_contract, send_transaction +import pytest + +from .utils import ( + ADDRS, + CONTRACTS, + KEYS, + deploy_contract, + send_transaction, + w3_wait_for_new_blocks, +) def test_gas_eth_tx(geth, ethermint): @@ -21,12 +30,10 @@ def test_gas_eth_tx(geth, ethermint): def test_gas_deployment(geth, ethermint): # deploy an identical contract on geth and ethermint # ensure that the gasUsed is equivalent - _, geth_contract_receipt = deploy_contract( - geth.w3, - CONTRACTS["TestERC20A"]) + _, geth_contract_receipt = deploy_contract(geth.w3, CONTRACTS["TestERC20A"]) _, ethermint_contract_receipt = deploy_contract( - ethermint.w3, - CONTRACTS["TestERC20A"]) + ethermint.w3, CONTRACTS["TestERC20A"] + ) assert geth_contract_receipt.gasUsed == ethermint_contract_receipt.gasUsed @@ -35,28 +42,65 @@ def test_gas_call(geth, ethermint): # deploy an identical contract on geth and ethermint # ensure that the contract has a function which consumes non-trivial gas - geth_contract, _ = deploy_contract( - geth.w3, - CONTRACTS["BurnGas"]) - ethermint_contract, _ = deploy_contract( - ethermint.w3, - CONTRACTS["BurnGas"]) + geth_contract, _ = deploy_contract(geth.w3, CONTRACTS["BurnGas"]) + ethermint_contract, _ = deploy_contract(ethermint.w3, CONTRACTS["BurnGas"]) # call the contract and get tx receipt for geth geth_gas_price = geth.w3.eth.gas_price - geth_txhash = (geth_contract.functions - .burnGas(function_input) - .transact({'from': ADDRS["validator"], "gasPrice": geth_gas_price})) + geth_txhash = geth_contract.functions.burnGas(function_input).transact( + {"from": ADDRS["validator"], "gasPrice": geth_gas_price} + ) geth_call_receipt = geth.w3.eth.wait_for_transaction_receipt(geth_txhash) # repeat the above for ethermint ethermint_gas_price = ethermint.w3.eth.gas_price - ethermint_txhash = (ethermint_contract.functions - .burnGas(function_input) - .transact({'from': ADDRS["validator"], - "gasPrice": ethermint_gas_price})) - ethermint_call_receipt = (ethermint.w3. - eth.wait_for_transaction_receipt(ethermint_txhash)) + ethermint_txhash = ethermint_contract.functions.burnGas(function_input).transact( + {"from": ADDRS["validator"], "gasPrice": ethermint_gas_price} + ) + ethermint_call_receipt = ethermint.w3.eth.wait_for_transaction_receipt( + ethermint_txhash + ) # ensure that the gasUsed is equivalent assert geth_call_receipt.gasUsed == ethermint_call_receipt.gasUsed + + +def test_block_gas_limit(ethermint): + tx_value = 10 + + # get the block gas limit from the latest block + w3_wait_for_new_blocks(ethermint.w3, 5) + block = ethermint.w3.eth.get_block("latest") + exceeded_gas_limit = block.gasLimit + 100 + + # send a transaction exceeding the block gas limit + ethermint_gas_price = ethermint.w3.eth.gas_price + tx = { + "to": ADDRS["community"], + "value": tx_value, + "gas": exceeded_gas_limit, + "gasPrice": ethermint_gas_price, + } + + # expect an error due to the block gas limit + with pytest.raises(Exception): + send_transaction(ethermint.w3, tx, KEYS["validator"]) + + # deploy a contract on ethermint + ethermint_contract, _ = deploy_contract(ethermint.w3, CONTRACTS["BurnGas"]) + + # expect an error on contract call due to block gas limit + with pytest.raises(Exception): + ethermint_txhash = ethermint_contract.functions.burnGas( + exceeded_gas_limit + ).transact( + { + "from": ADDRS["validator"], + "gas": exceeded_gas_limit, + "gasPrice": ethermint_gas_price, + } + ) + (ethermint.w3.eth.wait_for_transaction_receipt(ethermint_txhash)) + + + return diff --git a/tests/solidity/yarn.lock b/tests/solidity/yarn.lock index 5548bbd2..9d311442 100644 --- a/tests/solidity/yarn.lock +++ b/tests/solidity/yarn.lock @@ -6255,9 +6255,9 @@ decamelize@^4.0.0: integrity sha512-9iE1PgSik9HeIIw2JO94IidnE3eBoQrFJ3w7sFuzSX4DpmZ3v5sZpUiV5Swcf6mQEF+Y0ru8Neo+p+nyh2J+hQ== decode-uri-component@^0.2.0: - version "0.2.0" - resolved "https://registry.yarnpkg.com/decode-uri-component/-/decode-uri-component-0.2.0.tgz#eb3913333458775cb84cd1a1fae062106bb87545" - integrity sha1-6zkTMzRYd1y4TNGh+uBiEGu4dUU= + version "0.2.2" + resolved "https://registry.yarnpkg.com/decode-uri-component/-/decode-uri-component-0.2.2.tgz#e69dbe25d37941171dd540e024c444cd5188e1e9" + integrity sha512-FqUYQ+8o158GyGTrMFJms9qh3CqTKvAqgqsTnkLI8sKu0028orqBhxNMFkFen0zGyg6epACD32pjVk58ngIErQ== decompress-response@^3.2.0, decompress-response@^3.3.0: version "3.3.0" diff --git a/x/evm/keeper/state_transition.go b/x/evm/keeper/state_transition.go index 3103a45c..2179ee55 100644 --- a/x/evm/keeper/state_transition.go +++ b/x/evm/keeper/state_transition.go @@ -72,6 +72,11 @@ func (k *Keeper) TxConfig(ctx sdk.Context, txHash common.Hash) statedb.TxConfig // (ChainConfig and module Params). It additionally sets the validator operator address as the // coinbase address to make it available for the COINBASE opcode, even though there is no // beneficiary of the coinbase transaction (since we're not mining). +// +// NOTE: the RANDOM opcode is currently not supported since it requires +// RANDAO implementation. See https://github.com/evmos/ethermint/pull/1520#pullrequestreview-1200504697 +// for more information. + func (k *Keeper) NewEVM( ctx sdk.Context, msg core.Message, @@ -89,6 +94,7 @@ func (k *Keeper) NewEVM( Time: big.NewInt(ctx.BlockHeader().Time.Unix()), Difficulty: big.NewInt(0), // unused. Only required in PoW context BaseFee: cfg.BaseFee, + Random: nil, // not supported } txCtx := core.NewEVMTxContext(msg) diff --git a/x/feemarket/spec/01_concepts.md b/x/feemarket/spec/01_concepts.md index 12071d7b..2d9c963b 100644 --- a/x/feemarket/spec/01_concepts.md +++ b/x/feemarket/spec/01_concepts.md @@ -72,4 +72,4 @@ The comparison of transaction gas price and the lower bound is implemented throu ::: tip If the base fee decreases to a value below the global `MinGasPrice`, it is set to the `MinGasPrice`. This is implemented, so that the base fee can't drop to gas prices that wouldn't allow transactions to be accepted in the mempool, because of a higher `MinGasPrice`. -::: \ No newline at end of file +:::