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: no plan for testnet to update default max_callback_gas param #1252

Merged
merged 11 commits into from
Dec 7, 2023
Merged
Show file tree
Hide file tree
Changes from 3 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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
- [#1247](https://github.com/crypto-org-chain/cronos/pull/1247) Update ethermint to develop, go-ethereum to `v1.11.2`.
- [#1235](https://github.com/crypto-org-chain/cronos/pull/1235) Add channel detail in ica packet callback.
- [#1251](https://github.com/crypto-org-chain/cronos/pull/1251) Adjust require gas for submitMsgs in ica precompile.
- [#1252](https://github.com/crypto-org-chain/cronos/pull/1252) Add plan `v1.1.0-testnet` to update default max_callback_gas param.

### Improvements

Expand Down
14 changes: 14 additions & 0 deletions app/upgrades.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@
clientkeeper "github.com/cosmos/ibc-go/v7/modules/core/02-client/keeper"
"github.com/cosmos/ibc-go/v7/modules/core/exported"
ibctmmigrations "github.com/cosmos/ibc-go/v7/modules/light-clients/07-tendermint/migrations"
cronosparamstypes "github.com/crypto-org-chain/cronos/v2/x/cronos/types"

Check failure on line 31 in app/upgrades.go

View workflow job for this annotation

GitHub Actions / Run golangci-lint

ST1019: package "github.com/crypto-org-chain/cronos/v2/x/cronos/types" is being imported more than once (stylecheck)
cronostypes "github.com/crypto-org-chain/cronos/v2/x/cronos/types"

Check failure on line 32 in app/upgrades.go

View workflow job for this annotation

GitHub Actions / Run golangci-lint

ST1019(related information): other import of "github.com/crypto-org-chain/cronos/v2/x/cronos/types" (stylecheck)
icaauthtypes "github.com/crypto-org-chain/cronos/v2/x/icaauth/types"
v0evmtypes "github.com/evmos/ethermint/x/evm/migrations/v0/types"
evmtypes "github.com/evmos/ethermint/x/evm/types"
Expand Down Expand Up @@ -117,6 +118,19 @@
app.ConsensusParamsKeeper.Set(ctx, consParams)
return m, nil
})

testnetPlanName := "v1.1.0-testnet"
app.UpgradeKeeper.SetUpgradeHandler(testnetPlanName, func(ctx sdk.Context, _ upgradetypes.Plan, fromVM module.VersionMap) (module.VersionMap, error) {
m, err := app.mm.RunMigrations(ctx, app.configurator, fromVM)
if err != nil {
return m, err
}
params := app.CronosKeeper.GetParams(ctx)
params.MaxCallbackGas = cronosparamstypes.MaxCallbackGasDefaultValue
app.CronosKeeper.SetParams(ctx, params)
Fixed Show fixed Hide fixed
return m, nil

Check warning on line 131 in app/upgrades.go

View check run for this annotation

Codecov / codecov/patch

app/upgrades.go#L124-L131

Added lines #L124 - L131 were not covered by tests
})

upgradeInfo, err := app.UpgradeKeeper.ReadUpgradeInfoFromDisk()
if err != nil {
panic(fmt.Sprintf("failed to read upgrade info from disk %s", err))
Expand Down
48 changes: 46 additions & 2 deletions integration_tests/test_ica.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,16 @@
from pystarport import cluster

from .ibc_utils import (
deploy_contract,
funds_ica,
gen_send_msg,
parse_events_rpc,
prepare_network,
register_acc,
wait_for_check_channel_ready,
wait_for_check_tx,
)
from .utils import CONTRACTS, wait_for_fn


@pytest.fixture(scope="module")
Expand All @@ -33,10 +36,49 @@ def test_ica(ibc, tmp_path):
cli_controller = ibc.cronos.cosmos_cli()
ica_address, channel_id = register_acc(cli_controller, connid)
balance = funds_ica(cli_host, ica_address)
num_txs = len(cli_host.query_all_txs(ica_address)["txs"])
to = cli_host.address("signer2")
amount = 1000
denom = "basecro"
jsonfile = CONTRACTS["TestICA"]
tcontract = deploy_contract(ibc.cronos.w3, jsonfile)
memo = {"src_callback": {"address": tcontract.address}}

def generated_tx_packet(msg_num):
# generate a transaction to send to host chain
m = gen_send_msg(ica_address, to, denom, amount)
msgs = []
for i in range(msg_num):
msgs.append(m)
data = json.dumps(msgs)
packet = cli_controller.ica_generate_packet_data(data, json.dumps(memo))
return packet

def send_tx(msg_num, gas="200000"):
num_txs = len(cli_host.query_all_txs(ica_address)["txs"])
generated_tx = json.dumps(generated_tx_packet(msg_num))
# submit transaction on host chain on behalf of interchain account
rsp = cli_controller.ica_ctrl_send_tx(
connid,
generated_tx,
gas=gas,
from_="signer2",
)
assert rsp["code"] == 0, rsp["raw_log"]
wait_for_check_tx(cli_host, ica_address, num_txs)

msg_num = 10
send_tx(msg_num)
balance -= amount * msg_num
assert cli_host.balance(ica_address, denom=denom) == balance

def check_for_ack():
criteria = "message.action=/ibc.core.channel.v1.MsgAcknowledgement"
return cli_controller.tx_search(criteria)["txs"]

txs = wait_for_fn("ack change", check_for_ack)
events = parse_events_rpc(txs[0]["events"])
err = events.get("ibc_src_callback")["callback_error"]
assert "sender is not authenticated" in err, err

def generated_tx_txt(msg_num):
# generate a transaction to send to host chain
Expand All @@ -56,6 +98,7 @@ def generated_tx_txt(msg_num):
no_timeout = 60

def submit_msgs(msg_num, timeout_in_s=no_timeout, gas="200000"):
num_txs = len(cli_host.query_all_txs(ica_address)["txs"])
# submit transaction on host chain on behalf of interchain account
rsp = cli_controller.icaauth_submit_tx(
connid,
Expand All @@ -80,5 +123,6 @@ def submit_msgs(msg_num, timeout_in_s=no_timeout, gas="200000"):
# submit normal txs should work
msg_num = 2
submit_msgs(msg_num)
balance -= amount * msg_num
# check if the funds are reduced in interchain account
assert cli_host.balance(ica_address, denom=denom) == balance - amount * msg_num
assert cli_host.balance(ica_address, denom=denom) == balance
78 changes: 0 additions & 78 deletions integration_tests/test_ica_ctrl.py

This file was deleted.

2 changes: 1 addition & 1 deletion integration_tests/test_upgrade.py
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ def test_cosmovisor_upgrade(custom_cronos: Cronos, tmp_path_factory):

rsp = cli.query_params("icaauth")
assert rsp["params"]["min_timeout_duration"] == "3600s", rsp
assert cli.query_params()["max_callback_gas"] == "300000", rsp
assert cli.query_params()["max_callback_gas"] == "50000", rsp

# migrate to sdk v0.47
custom_cronos.supervisorctl("stop", "all")
Expand Down
2 changes: 1 addition & 1 deletion x/cronos/types/params.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ var (
const (
IbcCroDenomDefaultValue = "ibc/6B5A664BF0AF4F71B2F0BAA33141E2F1321242FBD5D19762F541EC971ACB0865"
IbcTimeoutDefaultValue = uint64(86400000000000) // 1 day
MaxCallbackGasDefaultValue = uint64(300000)
MaxCallbackGasDefaultValue = uint64(50000)
)

// ParamKeyTable returns the parameter key table.
Expand Down
Loading