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

Test exceeds #15

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
40 changes: 18 additions & 22 deletions integration_tests/test_basic.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
from pystarport import cluster, ports

from .cosmoscli import CosmosCLI
from .utils import (

Check failure on line 15 in integration_tests/test_basic.py

View workflow job for this annotation

GitHub Actions / Lint python

./integration_tests/test_basic.py:15:1: F401 '.utils.send_txs' imported but unused
ADDRS,
CONTRACTS,
KEYS,
Expand All @@ -27,6 +27,7 @@
modify_command_in_supervisor_config,
send_transaction,
send_txs,
send_txs2,
submit_any_proposal,
wait_for_block,
wait_for_new_blocks,
Expand Down Expand Up @@ -168,7 +169,7 @@
)
txhash_1 = greeter.deploy(w3)["transactionHash"].hex()

assert w3.eth.get_balance(ADDRS["community"]) == initial_balance + tx_value

Check failure on line 172 in integration_tests/test_basic.py

View workflow job for this annotation

GitHub Actions / integration_tests

test_tx_inclusion[True-0] ValueError: {'code': -32000, 'message': '\ngithub.com/evmos/ethermint/app/ante.EthGasConsumeDecorator.AnteHandle\n\tgithub.com/evmos/ethermint/app/ante/eth.go:226\ngithub.com/cosmos/cosmos-sdk/types.ChainAnteDecorators.func1\n\tgithub.com/cosmos/cosmos-sdk/types/handler.go:49\ngithub.com/evmos/ethermint/app/ante.CanTransferDecorator.AnteHandle\n\tgithub.com/evmos/ethermint/app/ante/eth.go:307\ngithub.com/cosmos/cosmos-sdk/types.ChainAnteDecorators.func1\n\tgithub.com/cosmos/cosmos-sdk/types/handler.go:49\ngithub.com/evmos/ethermint/app/ante.EthAccountVerificationDecorator.AnteHandle\n\tgithub.com/evmos/ethermint/app/ante/eth.go:102\ngithub.com/cosmos/cosmos-sdk/types.ChainAnteDecorators.func1\n\tgithub.com/cosmos/cosmos-sdk/types/handler.go:49\ngithub.com/evmos/ethermint/app/ante.EthSigVerificationDecorator.AnteHandle\n\tgithub.com/evmos/ethermint/app/ante/sigverify.go:54\ngithub.com/cosmos/cosmos-sdk/types.ChainAnteDecorators.func1\n\tgithub.com/cosmos/cosmos-sdk/types/handler.go:49\ngithub.com/evmos/ethermint/app/ante.EthValidateBasicDecorator.AnteHandle\n\tgithub.com/evmos/ethermint/app/ante/setup.go:202\ngithub.com/cosmos/cosmos-sdk/types.ChainAnteDecorators.func1\n\tgithub.com/cosmos/cosmos-sdk/types/handler.go:49\ngithub.com/evmos/ethermint/app/ante.EthMinGasPriceDecorator.AnteHandle\n\tgithub.com/evmos/ethermint/app/ante/fees.go:133\ngithub.com/cosmos/cosmos-sdk/types.ChainAnteDecorators.func1\n\tgithub.com/cosmos/cosmos-sdk/types/handler.go:49\ngithub.com/evmos/ethermint/app/ante.EthMempoolFeeDecorator.AnteHandle\n\tgithub.com/evmos/ethermint/app/ante/fees.go:192\ngithub.com/cosmos/cosmos-sdk/types.ChainAnteDecorators.func1\n\tgithub.com/cosmos/cosmos-sdk/types/handler.go:49\ngithub.com/evmos/ethermint/app/ante.EthSetupContextDecorator.AnteHandle\n\tgithub.com/evmos/ethermint/app/ante/setup.go:60\ngithub.com/cosmos/cosmos-sdk/types.ChainAnteDecorators.func1\n\tgithub.com/cosmos/cosmos-sdk/types/handler.go:49\ngithub.com/evmos/ethermint/app/ante.NewAnteHandler.func1\n\tgithub.com/evmos/ethermint/app/ante/ante.go:90\ngithub.com/crypto-org-chain/cronos/v2/app/ante.NewAnteHandler.func1\n\tgithub.com/crypto-org-chain/cronos/v2/app/ante/ante.go:52\ngithub.com/cosmos/cosmos-sdk/baseapp.(*BaseApp).runTx\n\tgithub.com/cosmos/cosmos-sdk/baseapp/baseapp.go:698\ngithub.com/cosmos/cosmos-sdk/baseapp.(*BaseApp).CheckTx\n\tgithub.com/cosmos/cosmos-sdk/baseapp/abci.go:387\ngithub.com/cometbft/cometbft/abci/client.(*localClient).CheckTxSync\n\tgithub.com/cometbft/cometbft/abci/client/local_client.go:251\ngithub.com/cometbft/cometbft/proxy.(*appConnMempool).CheckTxSync\n\tgithub.com/cometbft/cometbft/proxy/app_conn.go:159\ngithub.com/cometbft/cometbft/mempool/v1.(*TxMempool).CheckTx\n\tgithub.com/cometbft/cometbft/mempool/v1/mempool.go:222\ngithub.com/cometbft/cometbft/rpc/core.BroadcastTxSync\n\tgithub.com/cometbft/cometbft/rpc/core/mempool.go:35\ngithub.com/cometbft/cometbft/rpc/client/local.(*Local).BroadcastTxSync\n\tgithub.com/cometbft/cometbft/rpc/client/local/local.go:99\ngithub.com/cosmos/cosmos-sdk/client.Context.BroadcastTxSync\n\tgithub.com/cosmos/cosmos-sdk/client/broadcast.go:89\ngithub.com/cosmos/cosmos-sdk/client.Context.BroadcastTx\n\tgithub.com/cosmos/cosmos-sdk/client/broadcast.go:26\ngithub.com/evmos/ethermint/rpc/backend.(*Backend).SendRawTransaction\n\tgithub.com/evmos/ethermint/rpc/backend/call_tx.go:167\ngithub.com/evmos/ethermint/rpc/namespaces/ethereum/eth.(*PublicAPI).SendRawTransaction\n\tgithub.com/evmos/ethermint/rpc/namespaces/ethereum/eth/api.go:230\nreflect.Value.call\n\treflect/value.go:586\ntx gas (289275000) exceeds block gas limit (81500000): out of gas: out of gas'}

# Wait 5 more block (sometimes not enough blocks can not work)
wait_for_block(
Expand Down Expand Up @@ -785,8 +786,9 @@
origin_cmd = None


@pytest.mark.parametrize("max_gas_wanted", [80000000, 40000000, 25000000, 500000])
@pytest.mark.parametrize("max_gas_wanted", [0])
def test_tx_inclusion(cronos, max_gas_wanted):
# def test_tx_inclusion(cronos):

Check failure on line 791 in integration_tests/test_basic.py

View workflow job for this annotation

GitHub Actions / Lint python

./integration_tests/test_basic.py:791:1: BLK100 Black would make changes.

Check failure on line 791 in integration_tests/test_basic.py

View workflow job for this annotation

GitHub Actions / Lint python

./integration_tests/test_basic.py:791:1: E115 expected an indented block (comment)
"""
- send multiple heavy transactions at the same time.
- check they are included in consecutively blocks without failure.
Expand All @@ -809,27 +811,21 @@

w3 = cronos.w3
cli = cronos.cosmos_cli()
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)
to = ADDRS["validator"]
params = {"gas": tx_gas_limit}
_, sended_hash_set = send_txs(w3, cli, to, list(KEYS.values())[0:4], params)
block_nums = [
w3.eth.wait_for_transaction_receipt(h).blockNumber for h in sended_hash_set
]
block_nums.sort()
print(f"all block numbers: {block_nums}")
# the transactions should be included according to max_gas_wanted
if max_tx_in_block == 1:
for block_num, next_block_num in zip(block_nums, block_nums[1:]):
assert next_block_num == block_num + 1
else:
for num in block_nums[1:max_tx_in_block]:
assert num == block_nums[0]
for num in block_nums[max_tx_in_block:]:
assert num == block_nums[0] + 1
tx_gas_limit = 289275000
contract = deploy_contract(
w3,
CONTRACTS["TestMessageCall"],
key=KEYS["community"],
)
iterations = 13000
tx = contract.functions.test(iterations).build_transaction()
print("estimate_gas", w3.eth.estimate_gas(tx))
tx["gas"] = tx_gas_limit
_, sended_hash_set = send_txs2(w3, cli, list(KEYS.values())[0:4], tx)
for h in sended_hash_set:
res = w3.eth.wait_for_transaction_receipt(h)
print("res:", h.hex(), res["blockNumber"], res["cumulativeGasUsed"], res["gasUsed"], res["status"])

Check failure on line 827 in integration_tests/test_basic.py

View workflow job for this annotation

GitHub Actions / Lint python

./integration_tests/test_basic.py:827:89: E501 line too long (107 > 88 characters)
time.sleep(30)


def test_replay_protection(cronos):
Expand Down
21 changes: 18 additions & 3 deletions integration_tests/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,10 @@
Account.enable_unaudited_hdwallet_features()
ACCOUNTS = {
"validator": Account.from_mnemonic(os.getenv("VALIDATOR1_MNEMONIC")),
"validator2": Account.from_mnemonic(os.getenv("VALIDATOR2_MNEMONIC")),
# "validator2": Account.from_mnemonic(os.getenv("VALIDATOR2_MNEMONIC")),
"community": Account.from_mnemonic(os.getenv("COMMUNITY_MNEMONIC")),
"signer1": Account.from_mnemonic(os.getenv("SIGNER1_MNEMONIC")),
"signer2": Account.from_mnemonic(os.getenv("SIGNER2_MNEMONIC")),
# "signer1": Account.from_mnemonic(os.getenv("SIGNER1_MNEMONIC")),
# "signer2": Account.from_mnemonic(os.getenv("SIGNER2_MNEMONIC")),
}
KEYS = {name: account.key for name, account in ACCOUNTS.items()}
ADDRS = {name: account.address for name, account in ACCOUNTS.items()}
Expand Down Expand Up @@ -590,8 +590,23 @@

return block_num_0, sended_hash_set

def send_txs2(w3, cli, keys, tx):

Check failure on line 593 in integration_tests/utils.py

View workflow job for this annotation

GitHub Actions / Lint python

./integration_tests/utils.py:593:1: BLK100 Black would make changes.

Check failure on line 593 in integration_tests/utils.py

View workflow job for this annotation

GitHub Actions / Lint python

./integration_tests/utils.py:593:1: E302 expected 2 blank lines, found 1
# use different sender accounts to be able be send concurrently
raw_transactions = []
for key_from in keys:
signed = sign_transaction(w3, tx, key_from)
raw_transactions.append(signed.rawTransaction)

# wait block update
block_num_0 = wait_for_new_blocks(cli, 1, sleep=0.1)
print(f"block number start: {block_num_0}")

# send transactions
sended_hash_set = send_raw_transactions(w3, raw_transactions)

return block_num_0, sended_hash_set

def multiple_send_to_cosmos(gcontract, tcontract, w3, recipient, amount, keys):

Check failure on line 609 in integration_tests/utils.py

View workflow job for this annotation

GitHub Actions / Lint python

./integration_tests/utils.py:609:1: E302 expected 2 blank lines, found 1
# use different sender accounts to be able be send concurrently
raw_transactions = []
for key_from in keys:
Expand Down
2 changes: 1 addition & 1 deletion scripts/run-integration-tests
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@ cd ../integration_tests/contracts
HUSKY_SKIP_INSTALL=1 npm install
npm run typechain
cd ..
nix-shell --run "pytest -vv -s"
nix-shell --run "pytest -v -s test_basic.py::test_tx_inclusion"
Loading