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

Problem: ethermint recent fixes not included in main branch #404

Merged
merged 2 commits into from
Mar 25, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,7 @@ HTTPS_GIT := https://github.com/crypto-org-chain/cronos.git
DOCKER := $(shell which docker)
DOCKER_BUF := $(DOCKER) run --rm -v $(CURDIR):/workspace --workdir /workspace bufbuild/buf

containerProtoVer=v0.2
containerProtoVer=v0.3
containerProtoImage=tendermintdev/sdk-proto-gen:$(containerProtoVer)
containerProtoGen=cosmos-sdk-proto-gen-$(containerProtoVer)
containerProtoGenSwagger=cosmos-sdk-proto-gen-swagger-$(containerProtoVer)
Expand All @@ -288,11 +288,11 @@ proto-all: proto-format proto-lint proto-gen

proto-gen:
@echo "Generating Protobuf files"
$(DOCKER) run --rm -v $(CURDIR):/workspace --workdir /workspace tendermintdev/sdk-proto-gen sh ./scripts/protocgen.sh
$(DOCKER) run --rm -v $(CURDIR):/workspace --workdir /workspace $(containerProtoImage) sh ./scripts/protocgen.sh

proto-swagger-gen:
@echo "Generating Protobuf Swagger"
$(DOCKER) run --rm -v $(CURDIR):/workspace --workdir /workspace tendermintdev/sdk-proto-gen sh ./scripts/protoc-swagger-gen.sh
$(DOCKER) run --rm -v $(CURDIR):/workspace --workdir /workspace $(containerProtoImage) sh ./scripts/protoc-swagger-gen.sh

proto-format:
@echo "Formatting Protobuf files"
Expand Down
2 changes: 2 additions & 0 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -677,6 +677,7 @@ func New(

// use Ethermint's custom AnteHandler

maxGasWanted := cast.ToUint64(appOpts.Get(srvflags.EVMMaxTxGasWanted))
options := evmante.HandlerOptions{
AccountKeeper: app.AccountKeeper,
BankKeeper: app.BankKeeper,
Expand All @@ -686,6 +687,7 @@ func New(
FeeMarketKeeper: app.FeeMarketKeeper,
SignModeHandler: encodingConfig.TxConfig.SignModeHandler(),
SigGasConsumer: evmante.DefaultSigVerificationGasConsumer,
MaxTxGasWanted: maxGasWanted,
}

if err := options.Validate(); err != nil {
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ replace (
// See https://github.com/tecbot/gorocksdb/pull/216
github.com/tecbot/gorocksdb => github.com/cosmos/gorocksdb v1.1.1

github.com/tharsis/ethermint => github.com/crypto-org-chain/ethermint v0.10.0-alpha1-cronos-7
github.com/tharsis/ethermint => github.com/crypto-org-chain/ethermint v0.10.0-alpha1-cronos-8
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.


google.golang.org/grpc => google.golang.org/grpc v1.33.2
)
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -246,8 +246,8 @@ github.com/cpuguy83/go-md2man/v2 v2.0.0/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsr
github.com/cpuguy83/go-md2man/v2 v2.0.1/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o=
github.com/creack/pty v1.1.7/go.mod h1:lj5s0c3V2DBrqTV7llrYr5NG6My20zk30Fl46Y7DoTY=
github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E=
github.com/crypto-org-chain/ethermint v0.10.0-alpha1-cronos-7 h1:UOIcfRJDMJ4yuVDKe2kb085iY+YoWEFxrXhY7ao00xo=
github.com/crypto-org-chain/ethermint v0.10.0-alpha1-cronos-7/go.mod h1:3CXBYpzlUtEn6OCr1WFw/951MBEeojZW3hcqPCv5ktw=
github.com/crypto-org-chain/ethermint v0.10.0-alpha1-cronos-8 h1:+1FLhY/C+mKUPqKNqtq81tCIorCFcqLZZflHebRDnIc=
github.com/crypto-org-chain/ethermint v0.10.0-alpha1-cronos-8/go.mod h1:3CXBYpzlUtEn6OCr1WFw/951MBEeojZW3hcqPCv5ktw=
github.com/crypto-org-chain/ibc-go/v2 v2.2.0-hooks2 h1:elj+Tb/3O9GA3pv62zkc1B0P8hl1WHmF6vF8PInEJm4=
github.com/crypto-org-chain/ibc-go/v2 v2.2.0-hooks2/go.mod h1:rAHRlBcRiHPP/JszN+08SJx3pegww9bcVncIb9QLx7I=
github.com/crypto-org-chain/keyring v1.1.6-fixes h1:AUFSu56NY6XobY6XfRoDx6v3loiOrHK5MNUm32GEjwA=
Expand Down
6 changes: 3 additions & 3 deletions gomod2nix.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3668,13 +3668,13 @@
sha256 = "1sgjf2vaq554ybc0cwkzn17cz2ibzph2rq0dgaw21c2hym09437x"

["github.com/tharsis/ethermint"]
sumVersion = "v0.10.0-alpha1-cronos-7"
sumVersion = "v0.10.0-alpha1-cronos-8"
vendorPath = "github.com/crypto-org-chain/ethermint"
["github.com/tharsis/ethermint".fetch]
type = "git"
url = "https://github.com/crypto-org-chain/ethermint"
rev = "a50901f33ac94ff846ab4dfe19076d09179e189f"
sha256 = "0r6vf7k7l7jw5jhdhy18ivpmqnyd94jsr4dqd8gzvlf8q2zpn39z"
rev = "f4db90bb0575d2ffbe4e2f141c75b7cd638354a9"
sha256 = "15gv5hkcf5958rp69m49nxx7kagwpgicn1ry6b6mf23skwxys091"

["github.com/tidwall/gjson"]
sumVersion = "v1.6.7"
Expand Down
46 changes: 41 additions & 5 deletions integration_tests/test_basic.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,10 @@
contract_address,
contract_path,
deploy_contract,
modify_command_in_supervisor_config,
send_transaction,
sign_transaction,
supervisorctl,
wait_for_block,
wait_for_port,
)
Expand Down Expand Up @@ -600,14 +602,26 @@ def test_contract(cronos):
assert "world" == greeter_call_result


def test_tx_inclusion(cronos):
@pytest.mark.parametrize("max_gas_wanted", [80000000, 40000000, 25000000, 500000])
def test_tx_inclusion(cronos, max_gas_wanted):
"""
- send multiple heavy transactions at the same time.
- check they are included in consecutively blocks without failure.

test against different max-gas-wanted configuration.
"""
modify_command_in_supervisor_config(
cronos.base_dir / "tasks.ini",
lambda cmd: f"{cmd} --evm.max-tx-gas-wanted {max_gas_wanted}",
)
supervisorctl(cronos.base_dir / "../tasks.ini", "update")
wait_for_port(ports.evmrpc_port(cronos.base_port(0)))

w3 = cronos.w3
# bigger than block_gas_limit/2, so at most one tx in a block
block_gas_limit = 81500000
tx_gas_limit = 80000000
max_tx_in_block = block_gas_limit // min(max_gas_wanted, tx_gas_limit)
print("max_tx_in_block", max_tx_in_block)
amount = 1000
# use different sender accounts to be able be send concurrently
signed_txs = []
Expand All @@ -631,6 +645,28 @@ def test_tx_inclusion(cronos):
w3.eth.wait_for_transaction_receipt(signed.hash) for signed in signed_txs
]

# the transactions should be included in differnt but consecutive blocks
for receipt, next_receipt in zip(receipts, receipts[1:]):
assert next_receipt.blockNumber == receipt.blockNumber + 1
# the transactions should be included according to max_gas_wanted
if max_tx_in_block == 1:
for receipt, next_receipt in zip(receipts, receipts[1:]):
assert next_receipt.blockNumber == receipt.blockNumber + 1
elif max_tx_in_block == 2:
assert receipts[0].blockNumber == receipts[1].blockNumber
assert (
receipts[2].blockNumber
== receipts[3].blockNumber
== receipts[0].blockNumber + 1
)
elif max_tx_in_block == 3:
assert (
receipts[0].blockNumber
== receipts[1].blockNumber
== receipts[2].blockNumber
)
assert receipts[3].blockNumber == receipts[0].blockNumber + 1
else:
assert (
receipts[0].blockNumber
== receipts[1].blockNumber
== receipts[2].blockNumber
== receipts[3].blockNumber
)
15 changes: 15 additions & 0 deletions integration_tests/test_filters.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
from web3 import Web3

from .utils import ADDRS, sign_transaction


def test_pending_transaction_filter(cluster):
w3: Web3 = cluster.w3
flt = w3.eth.filter("pending")
assert flt.get_new_entries() == []

signed = sign_transaction(w3, {"to": ADDRS["community"], "value": 1000})
txhash = w3.eth.send_raw_transaction(signed.rawTransaction)
receipt = w3.eth.wait_for_transaction_receipt(txhash)
assert receipt.status == 1
assert flt.get_new_entries() == [txhash]
14 changes: 14 additions & 0 deletions integration_tests/utils.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import configparser
import json
import os
import re
import socket
import subprocess
import sys
Expand Down Expand Up @@ -379,3 +380,16 @@ def transfer(self, value):
)
receipt = send_transaction(self.w3, transaction, self.private_key)
return receipt


def modify_command_in_supervisor_config(ini: Path, fn, **kwargs):
"replace the first node with the instrumented binary"
ini.write_text(
re.sub(
r"^command = (cronosd .*$)",
lambda m: f"command = {fn(m.group(1))}",
ini.read_text(),
flags=re.M,
**kwargs,
)
)