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: min_gas_price related change is not tested #1264

Merged
merged 26 commits into from
Dec 22, 2023
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
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
timeout-minutes: 240
strategy:
matrix:
tests: [unmarked, ibc, ibc_rly_evm, ibc_rly_gas, ibc_timeout, ibc_update_client, ica, gov, upgrade, slow]
tests: [unmarked, ibc, ibc_rly_evm, ibc_rly_gas, ibc_timeout, ibc_update_client, ica, gov, upgrade, slow, gas]
env:
TESTS_TO_RUN: ${{ matrix.tests }}
steps:
Expand Down
4 changes: 2 additions & 2 deletions integration_tests/configs/ibc.jsonnet
Original file line number Diff line number Diff line change
Expand Up @@ -143,8 +143,8 @@ config {
chains: [
{
id: 'cronos_777-1',
max_gas: 500000,
gas_multiplier: 4,
max_gas: 1000000,
gas_multiplier: 1.1,
address_type: {
derivation: 'ethermint',
proto_type: {
Expand Down
6 changes: 0 additions & 6 deletions integration_tests/configs/ibc_rly.jsonnet
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,4 @@ ibc {
for i in std.range(1, 2)
],
},
relayer+: {
chains: [super.chains[0] {
max_gas: 1000000,
gas_multiplier: 1.1,
}] + super.chains[1:],
},
}
mmsqe marked this conversation as resolved.
Show resolved Hide resolved
11 changes: 11 additions & 0 deletions integration_tests/configs/ibc_timeout.jsonnet
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@ local ibc = import 'ibc.jsonnet';

ibc {
'cronos_777-1'+: {
key_name: 'signer3',
accounts: super.accounts + [{
name: 'signer3',
coins: '0basetcro',
mnemonic: '${SIGNER3_MNEMONIC}',
}],
genesis+: {
app_state+: {
cronos+: {
Expand All @@ -12,4 +18,9 @@ ibc {
},
},
},
relayer+: {
chains: [super.chains[0] {
fee_granter: 'crc16z0herz998946wr659lr84c8c556da55dc34hh', //signer1
}] + super.chains[1:],
},
}
21 changes: 21 additions & 0 deletions integration_tests/configs/min_gas_price.jsonnet
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
local config = import 'default.jsonnet';

config {
'cronos_777-1'+: {
validators: [validator {
gas_prices: '10000000000000basetcro',
} for validator in super.validators],
genesis+: {
app_state+: {
feemarket+: {
params+: {
base_fee_change_denominator: '3',
elasticity_multiplier: '4',
base_fee: '10000000000000',
min_gas_price: '10000000000000',
},
},
},
},
},
}
13 changes: 13 additions & 0 deletions integration_tests/configs/min_gas_price_eq.jsonnet
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
local config = import 'min_gas_price_lte.jsonnet';

config {
'cronos_777-1'+: {
genesis+: {
consensus_params+: {
block+: {
max_gas: '84000000',
},
},
},
},
}
16 changes: 16 additions & 0 deletions integration_tests/configs/min_gas_price_lte.jsonnet
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
local config = import 'min_gas_price.jsonnet';

config {
'cronos_777-1'+: {
genesis+: {
app_state+: {
feemarket+: {
params+: {
base_fee_change_denominator: '300',
elasticity_multiplier: '4000',
},
},
},
},
},
}
38 changes: 32 additions & 6 deletions integration_tests/cosmoscli.py
Original file line number Diff line number Diff line change
Expand Up @@ -823,9 +823,11 @@ def ibc_transfer(
amount,
channel, # src channel
target_version, # chain version number of target chain
fee,
i=0,
**kwargs,
):
default_kwargs = {
"home": self.data_dir,
}
return json.loads(
self.raw(
"tx",
Expand All @@ -835,18 +837,16 @@ def ibc_transfer(
channel,
to,
amount,
"--fees",
fee,
"-y",
# FIXME https://github.com/cosmos/cosmos-sdk/issues/8059
"--absolute-timeouts",
from_=from_,
home=self.data_dir,
node=self.node_rpc,
keyring_backend="test",
chain_id=self.chain_id,
packet_timeout_height=f"{target_version}-10000000000",
packet_timeout_timestamp=0,
**(default_kwargs | kwargs),
)
)

Expand Down Expand Up @@ -1535,7 +1535,7 @@ def pay_packet_fee(self, port_id, channel_id, packet_seq, **kwargs):
default_kwargs = {
"home": self.data_dir,
}
return json.loads(
rsp = json.loads(
self.raw(
"tx",
"ibc-fee",
Expand All @@ -1547,6 +1547,9 @@ def pay_packet_fee(self, port_id, channel_id, packet_seq, **kwargs):
**(default_kwargs | kwargs),
)
)
if rsp["code"] == 0:
rsp = self.event_query_tx_for(rsp["txhash"])
return rsp

def query_grant(self, granter, grantee):
"query grant details by granter and grantee addresses"
Expand All @@ -1561,6 +1564,29 @@ def query_grant(self, granter, grantee):
)
)

def grant(self, granter, grantee, limit, **kwargs):
default_kwargs = self.get_default_kwargs()
rsp = json.loads(
self.raw(
"tx",
"feegrant",
"grant",
granter,
grantee,
"--period",
"60",
"--period-limit",
limit,
"-y",
home=self.data_dir,
stderr=subprocess.DEVNULL,
**(default_kwargs | kwargs),
)
)
if rsp["code"] == 0:
rsp = self.event_query_tx_for(rsp["txhash"])
return rsp

def query_batches(self):
"query all gravity batches"
return json.loads(
Expand Down
37 changes: 26 additions & 11 deletions integration_tests/ibc_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@ def prepare_network(
incentivized=True,
is_relay=True,
connection_only=False,
grantee=None,
relayer=cluster.Relayer.HERMES.value,
):
print("incentivized", incentivized)
Expand All @@ -149,6 +150,19 @@ def prepare_network(
Path(__file__).parent / file,
relayer=relayer,
) as cronos:
if grantee:
cli = cronos.cosmos_cli()
granter_addr = cli.address("signer1")
grantee_addr = cli.address(grantee)
max_gas = 1000000
gas_price = 10000000000000000
limit = f"{max_gas*gas_price*2}basetcro"
rsp = cli.grant(granter_addr, grantee_addr, limit)
assert rsp["code"] == 0, rsp["raw_log"]
grant_detail = cli.query_grant(granter_addr, grantee_addr)
assert grant_detail["granter"] == granter_addr
assert grant_detail["grantee"] == grantee_addr

chainmain = Chainmain(cronos.base_dir.parent / "chainmain-1")
# wait for grpc ready
wait_for_port(ports.grpc_port(chainmain.base_port(0))) # chainmain grpc
Expand Down Expand Up @@ -324,7 +338,7 @@ def ibc_incentivized_transfer(ibc):
f"{amount}{base_denom}",
src_channel,
1,
"0basecro",
fees="0basecro",
)
assert rsp["code"] == 0, rsp["raw_log"]
src_chain = ibc.cronos.cosmos_cli()
Expand All @@ -343,7 +357,6 @@ def ibc_incentivized_transfer(ibc):
from_=sender,
)
assert rsp["code"] == 0, rsp["raw_log"]
rsp = src_chain.event_query_tx_for(rsp["txhash"])
# fee is locked
assert chains[0].balance(sender, fee_denom) == old_amt_sender_fee - 30

Expand All @@ -359,10 +372,11 @@ def check_fee():
wait_for_fn("wait for relayer to receive the fee", check_fee)

# timeout fee is refunded
assert get_balances(ibc.cronos, sender) == [
actual = get_balances(ibc.cronos, sender)
assert actual == [
{"denom": base_denom, "amount": f"{old_amt_sender_base - amount}"},
{"denom": fee_denom, "amount": f"{old_amt_sender_fee - 20}"},
]
], actual
path = f"transfer/{dst_channel}/{base_denom}"
denom_hash = hashlib.sha256(path.encode()).hexdigest().upper()
assert json.loads(
Expand All @@ -387,15 +401,16 @@ def check_fee():
f"{amount}ibc/{denom_hash}",
dst_channel,
1,
f"{fee_amount}basecro",
fees=f"{fee_amount}basecro",
)
assert rsp["code"] == 0, rsp["raw_log"]

def check_balance_change():
return chains[0].balance(sender, base_denom) != old_amt_sender_base - amount

wait_for_fn("balance change", check_balance_change)
assert chains[0].balance(sender, base_denom) == old_amt_sender_base
actual = chains[0].balance(sender, base_denom)
assert actual == old_amt_sender_base, actual
assert chains[1].balance(receiver, "basecro") == old_amt_receiver_base - fee_amount
return amount

Expand Down Expand Up @@ -461,8 +476,9 @@ def check_chainmain_balance_change():
cronos_receiver = eth_to_bech32(ADDRS["signer2"])

coin = "1000" + dest_denom
fees = "100000000basecro"
rsp = chainmain_cli.ibc_transfer(
chainmain_receiver, cronos_receiver, coin, "channel-0", 1, "100000000basecro"
chainmain_receiver, cronos_receiver, coin, "channel-0", 1, fees=fees
)
assert rsp["code"] == 0, rsp["raw_log"]

Expand Down Expand Up @@ -562,8 +578,9 @@ def check_chainmain_balance_change():
cronos_receiver = eth_to_bech32(ADDRS["signer2"])

coin = f"{amount}{dest_denom}"
fees = "100000000basecro"
rsp = chainmain_cli.ibc_transfer(
chainmain_receiver, cronos_receiver, coin, "channel-0", 1, "100000000basecro"
chainmain_receiver, cronos_receiver, coin, "channel-0", 1, fees=fees
)
assert rsp["code"] == 0, rsp["raw_log"]

Expand Down Expand Up @@ -647,9 +664,7 @@ def check_status():

def register_acc(cli, connid):
print("register ica account")
rsp = cli.icaauth_register_account(
connid, from_="signer2", gas="400000", fees="100000000basetcro"
)
rsp = cli.icaauth_register_account(connid, from_="signer2", gas="400000")
_, channel_id = assert_channel_open_init(rsp)
wait_for_check_channel_ready(cli, connid, channel_id)

Expand Down
4 changes: 4 additions & 0 deletions integration_tests/test_basic.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
from pystarport import cluster, ports

from .cosmoscli import CosmosCLI
from .network import Geth
from .utils import (
ADDRS,
CONTRACTS,
Expand Down Expand Up @@ -42,6 +43,9 @@ def test_basic(cluster):
def test_send_transaction(cluster):
"test eth_sendTransaction api"
w3 = cluster.w3
# wait 1s to avoid unlock error
if isinstance(cluster, Geth):
time.sleep(1)
txhash = w3.eth.send_transaction(
{
"from": ADDRS["validator"],
Expand Down
4 changes: 4 additions & 0 deletions integration_tests/test_eip1559.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
import pytest

from .utils import ADDRS, KEYS, send_transaction, w3_wait_for_block

pytestmark = pytest.mark.gas


def adjust_base_fee(parent_fee, gas_limit, gas_used):
"spec: https://eips.ethereum.org/EIPS/eip-1559#specification"
Expand Down
7 changes: 4 additions & 3 deletions integration_tests/test_ibc.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@ def test_cronos_transfer_tokens(ibc):
f"{src_amount}{src_denom}",
)
assert rsp["code"] == 0, rsp["raw_log"]

new_dst_balance = 0

def check_balance_change():
Expand Down Expand Up @@ -96,7 +95,6 @@ def test_cronos_transfer_tokens_acknowledgement_error(ibc):
f"{src_amount}{src_denom}",
)
assert rsp["code"] == 0, rsp["raw_log"]

new_src_balance = 0

def check_balance_change():
Expand All @@ -123,7 +121,10 @@ def test_cro_bridge_contract(ibc):
w3 = ibc.cronos.w3
contract = deploy_contract(w3, CONTRACTS["CroBridge"])
tx = contract.functions.send_cro_to_crypto_org(dst_addr).build_transaction(
{"from": ADDRS["signer2"], "value": src_amount}
{
"from": ADDRS["signer2"],
"value": src_amount,
}
)
receipt = send_transaction(w3, tx)
assert receipt.status == 1
mmsqe marked this conversation as resolved.
Show resolved Hide resolved
Expand Down
2 changes: 1 addition & 1 deletion integration_tests/test_ibc_timeout.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ def ibc(request, tmp_path_factory):
"prepare-network"
name = "ibc_timeout"
path = tmp_path_factory.mktemp(name)
yield from prepare_network(path, name)
yield from prepare_network(path, name, grantee="signer3")


def test_ibc(ibc):
Expand Down
Loading
Loading