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 10 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
7 changes: 6 additions & 1 deletion integration_tests/configs/default.jsonnet
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
validators: [{
coins: '1000000000000000000stake,10000000000000000000000basetcro',
staked: '1000000000000000000stake',
gas_prices: '10000000000000basetcro',
mnemonic: '${VALIDATOR1_MNEMONIC}',
client_config: {
'broadcast-mode': 'sync',
Expand All @@ -42,6 +43,7 @@
}, {
coins: '1000000000000000000stake,10000000000000000000000basetcro',
staked: '1000000000000000000stake',
gas_prices: '10000000000000basetcro',
mnemonic: '${VALIDATOR2_MNEMONIC}',
client_config: {
'broadcast-mode': 'sync',
Expand Down Expand Up @@ -101,7 +103,10 @@
feemarket: {
params: {
no_base_fee: false,
base_fee: '100000000000',
base_fee_change_denominator: '300',
elasticity_multiplier: '4',
base_fee: '10000000000000',
min_gas_price: '10000000000000'
mmsqe marked this conversation as resolved.
Show resolved Hide resolved
},
},
},
Expand Down
2 changes: 1 addition & 1 deletion integration_tests/configs/ibc.jsonnet
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ config {
},
extension_options: [{
type: 'ethermint_dynamic_fee',
value: '1000000',
value: '10000000000000',
}],
},
{
Expand Down
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:],
},
}
48 changes: 37 additions & 11 deletions integration_tests/cosmoscli.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
from pystarport.utils import build_cli_args_safe, format_doc_string, interact

# the default initial base fee used by integration tests
DEFAULT_GAS_PRICE = "100000000000basetcro"
DEFAULT_GAS_PRICE = "10000000000000basetcro"
DEFAULT_GAS = "250000"


Expand Down 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 @@ -1204,10 +1204,7 @@ def build_evm_tx(self, raw_tx: str, **kwargs):
)

def transfer_tokens(self, from_, to, amount, **kwargs):
default_kwargs = {
"gas": "auto",
"gas_adjustment": "1.5",
}
default_kwargs = self.get_default_kwargs()
rsp = json.loads(
self.raw(
"tx",
Expand All @@ -1233,6 +1230,7 @@ def icaauth_register_account(self, connid, **kwargs):
"node": self.node_rpc,
"chain_id": self.chain_id,
"keyring_backend": "test",
"gas_prices": DEFAULT_GAS_PRICE,
}
rsp = json.loads(
self.raw(
Expand All @@ -1254,6 +1252,7 @@ def icaauth_submit_tx(self, connid, tx, timeout_duration="1h", **kwargs):
"node": self.node_rpc,
"chain_id": self.chain_id,
"keyring_backend": "test",
"gas_prices": DEFAULT_GAS_PRICE,
}
rsp = json.loads(
self.raw(
Expand All @@ -1278,6 +1277,7 @@ def ica_ctrl_send_tx(self, connid, tx, timeout_in_ns=None, **kwargs):
"node": self.node_rpc,
"chain_id": self.chain_id,
"keyring_backend": "test",
"gas_prices": DEFAULT_GAS_PRICE,
}
rsp = json.loads(
self.raw(
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
53 changes: 37 additions & 16 deletions integration_tests/ibc_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
from .utils import (
ADDRS,
CONTRACTS,
DEFAULT_GAS_PRICE,
deploy_contract,
eth_to_bech32,
parse_events,
Expand Down Expand Up @@ -134,6 +135,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 +151,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 = 500000
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 @@ -281,7 +296,7 @@ def check_balance_change():
gas = int(tx["gas_wanted"])
# the effective fee is decided by the max_priority_fee (base fee is zero)
# rather than the normal gas price
assert fee == gas * 1000000
assert fee == gas * DEFAULT_GAS_PRICE

# check duplicate OnRecvPacket events
criteria = "message.action=/ibc.core.channel.v1.MsgRecvPacket"
Expand Down Expand Up @@ -318,17 +333,19 @@ def ibc_incentivized_transfer(ibc):
assert old_amt_receiver_base == 1000000000000000000000
src_channel = "channel-0"
dst_channel = "channel-0"
gas_prices = DEFAULT_GAS_PRICE
rsp = chains[0].ibc_transfer(
sender,
receiver,
f"{amount}{base_denom}",
src_channel,
1,
"0basecro",
gas_prices=f"{gas_prices}{base_denom}",
)
assert rsp["code"] == 0, rsp["raw_log"]
src_chain = ibc.cronos.cosmos_cli()
rsp = src_chain.event_query_tx_for(rsp["txhash"])
old_amt_sender_base -= int(rsp["gas_wanted"]) * gas_prices
evt = parse_events(rsp["logs"])["send_packet"]
print("packet event", evt)
packet_seq = int(evt["packet_sequence"])
Expand All @@ -341,9 +358,10 @@ def ibc_incentivized_transfer(ibc):
ack_fee=fee,
timeout_fee=fee,
from_=sender,
gas_prices=f"{gas_prices}{base_denom}",
)
assert rsp["code"] == 0, rsp["raw_log"]
rsp = src_chain.event_query_tx_for(rsp["txhash"])
old_amt_sender_base -= int(rsp["gas_wanted"]) * gas_prices
# fee is locked
assert chains[0].balance(sender, fee_denom) == old_amt_sender_fee - 30

Expand All @@ -359,10 +377,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 +406,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
assert chains[1].balance(receiver, "basecro") == old_amt_receiver_base - fee_amount
return amount

Expand Down Expand Up @@ -424,7 +444,7 @@ def cronos_transfer_source_tokens(ibc):
# send to ibc
tx = contract.functions.send_to_ibc_v2(
chainmain_receiver, amount, 0, b""
).build_transaction({"from": ADDRS["validator"]})
).build_transaction({"from": ADDRS["validator"], "gasPrice": DEFAULT_GAS_PRICE})
txreceipt = send_transaction(w3, tx)
assert txreceipt.status == 1, "should success"

Expand All @@ -445,7 +465,7 @@ def check_chainmain_balance_change():

# check legacy send to ibc
tx = contract.functions.send_to_ibc(chainmain_receiver, 1).build_transaction(
{"from": ADDRS["validator"]}
{"from": ADDRS["validator"], "gasPrice": DEFAULT_GAS_PRICE}
)
txreceipt = send_transaction(w3, tx)
assert txreceipt.status == 0, "should fail"
Expand All @@ -461,8 +481,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 All @@ -489,6 +510,7 @@ def cronos_transfer_source_tokens_with_proxy(ibc):
w3,
CONTRACTS["TestCRC20Proxy"],
(contract.address, True),
gas_price=DEFAULT_GAS_PRICE,
)

print("proxycrc20 contract deployed at address: ", proxycrc20.address)
Expand Down Expand Up @@ -516,7 +538,7 @@ def cronos_transfer_source_tokens_with_proxy(ibc):

# First we need to approve the proxy contract to move asset
tx = contract.functions.approve(proxycrc20.address, amount).build_transaction(
{"from": sender}
{"from": sender, "gasPrice": DEFAULT_GAS_PRICE}
)
txreceipt = send_transaction(w3, tx)
assert txreceipt.status == 1, "should success"
Expand All @@ -531,7 +553,7 @@ def cronos_transfer_source_tokens_with_proxy(ibc):
# send to ibc
tx = proxycrc20.functions.send_to_ibc(
chainmain_receiver, amount, 0, b""
).build_transaction({"from": sender})
).build_transaction({"from": sender, "gasPrice": DEFAULT_GAS_PRICE})
txreceipt = send_transaction(w3, tx)
print(txreceipt)
assert txreceipt.status == 1, "should success"
Expand Down Expand Up @@ -562,8 +584,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 +670,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
Loading
Loading