Skip to content

Commit

Permalink
Problem: no legacy evm param after multi upgrades (#1371)
Browse files Browse the repository at this point in the history
* Problem: no legacy evm param after multi upgrades

* rm redudant skip confirm

* add missing check

* update deps

* v3 is pinging v4

* update doc

* longer ci
  • Loading branch information
mmsqe committed Apr 8, 2024
1 parent 6a16d57 commit 1aea999
Show file tree
Hide file tree
Showing 13 changed files with 128 additions and 61 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ jobs:
sed -i.bak "/$(echo $filename | sed 's/\//\\\//g')/d" coverage.txt
done
if: steps.changed-files.outputs.any_changed == 'true'
- uses: codecov/codecov-action@v3
- uses: codecov/codecov-action@v4
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: ./coverage.txt,./memiavl/coverage.txt,./store/coverage.txt,./versiondb/coverage.txt
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
golangci:
name: Run golangci-lint
runs-on: macos-latest
timeout-minutes: 40
timeout-minutes: 60
steps:
- uses: actions/setup-go@v3
with:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ jobs:
go tool covdata textfmt -i=integration_tests/coverage -o profile.txt
- name: Upload coverage report
if: steps.changed-files.outputs.only_changed == 'false'
uses: codecov/codecov-action@v3
uses: codecov/codecov-action@v4
with:
token: ${{ secrets.CODECOV_TOKEN }}
file: ./profile.txt
Expand Down
11 changes: 10 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,17 @@
# Changelog

*April 8, 2024*

## v1.2.0-rc1

### Bug Fixes

* (rpc) [#1371](https://github.com/crypto-org-chain/cronos/pull/1371) Add param keytable in evm for old upgrade.


*April 2, 2024*

## v1.2.0
## v1.2.0-rc0

### Bug Fixes

Expand Down
3 changes: 2 additions & 1 deletion app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ import (
ethermint "github.com/evmos/ethermint/types"
"github.com/evmos/ethermint/x/evm"
evmkeeper "github.com/evmos/ethermint/x/evm/keeper"
v0evmtypes "github.com/evmos/ethermint/x/evm/migrations/v0/types"
evmtypes "github.com/evmos/ethermint/x/evm/types"
"github.com/evmos/ethermint/x/feemarket"
feemarketkeeper "github.com/evmos/ethermint/x/feemarket/keeper"
Expand Down Expand Up @@ -1168,7 +1169,7 @@ func initParamsKeeper(appCodec codec.BinaryCodec, legacyAmino *codec.LegacyAmino
paramsKeeper.Subspace(ibcexported.ModuleName)
paramsKeeper.Subspace(icacontrollertypes.SubModuleName)
paramsKeeper.Subspace(icaauthtypes.ModuleName)
paramsKeeper.Subspace(evmtypes.ModuleName)
paramsKeeper.Subspace(evmtypes.ModuleName).WithKeyTable(v0evmtypes.ParamKeyTable()) //nolint: staticcheck
paramsKeeper.Subspace(feemarkettypes.ModuleName).WithKeyTable(feemarkettypes.ParamKeyTable())
if !skipGravity {
paramsKeeper.Subspace(gravitytypes.ModuleName)
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ replace (
// TODO: remove it: https://github.com/cosmos/cosmos-sdk/issues/13134
github.com/dgrijalva/jwt-go => github.com/golang-jwt/jwt/v4 v4.4.2
github.com/ethereum/go-ethereum => github.com/crypto-org-chain/go-ethereum v1.10.20-0.20231207063621-43cf32d91c3e
github.com/evmos/ethermint => github.com/crypto-org-chain/ethermint v0.6.1-0.20240402062856-028760ed329f
github.com/evmos/ethermint => github.com/crypto-org-chain/ethermint v0.6.1-0.20240408020015-27de4edabc79
// Fix upstream GHSA-h395-qcrw-5vmq and GHSA-3vp4-m3rf-835h vulnerabilities.
// TODO Remove it: https://github.com/cosmos/cosmos-sdk/issues/10409
github.com/gin-gonic/gin => github.com/gin-gonic/gin v1.9.0
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -488,8 +488,8 @@ github.com/crypto-org-chain/cometbft-db v0.0.0-20231011055109-57922ac52a63 h1:R1
github.com/crypto-org-chain/cometbft-db v0.0.0-20231011055109-57922ac52a63/go.mod h1:rocwIfnS+kA060x64gkSIRvWB9StSppIkJuo5MWzL24=
github.com/crypto-org-chain/cosmos-sdk v0.46.0-beta2.0.20240228013111-9bd1e035ed1d h1:ihUBUAEwQYHZEqf7lXrJithNCUJTjB8q3oSQA6Nevco=
github.com/crypto-org-chain/cosmos-sdk v0.46.0-beta2.0.20240228013111-9bd1e035ed1d/go.mod h1:cmAawe8FV/52oPKbgeHLt4UpNkrNu8R5KD+kw0kxJFc=
github.com/crypto-org-chain/ethermint v0.6.1-0.20240402062856-028760ed329f h1:JZ/mnxsQXWaCLgIZHveHJaSB53RK7WCb1NTkMztqavk=
github.com/crypto-org-chain/ethermint v0.6.1-0.20240402062856-028760ed329f/go.mod h1:zJYmx1D+tDggzvXmdJ0/I62TeIykdCMfJBjBxOcniAU=
github.com/crypto-org-chain/ethermint v0.6.1-0.20240408020015-27de4edabc79 h1:X5QvqiJjeBlCXjC6b5kpIL/vo2Honp/crZbCPafFBhA=
github.com/crypto-org-chain/ethermint v0.6.1-0.20240408020015-27de4edabc79/go.mod h1:zJYmx1D+tDggzvXmdJ0/I62TeIykdCMfJBjBxOcniAU=
github.com/crypto-org-chain/go-ethereum v1.10.20-0.20231207063621-43cf32d91c3e h1:vnyepPQ/m25+19xcTuBUdRxmltZ/EjVWNqEjhg7Ummk=
github.com/crypto-org-chain/go-ethereum v1.10.20-0.20231207063621-43cf32d91c3e/go.mod h1:+a8pUj1tOyJ2RinsNQD4326YS+leSoKGiG/uVVb0x6Y=
github.com/crypto-org-chain/gravity-bridge/module/v2 v2.0.1-0.20230825054824-75403cd90c6e h1:rSTc35OBjjCBx47rHPWBCIHNGPbMnEj8f7fNcK2TjVI=
Expand Down
4 changes: 2 additions & 2 deletions gomod2nix.toml
Original file line number Diff line number Diff line change
Expand Up @@ -216,8 +216,8 @@ schema = 3
hash = "sha256-lDIqRLUrXYCb9mmFBY/+WW+ee69+IkxOgqjHVyo4ij0="
replaced = "github.com/crypto-org-chain/go-ethereum"
[mod."github.com/evmos/ethermint"]
version = "v0.6.1-0.20240402062856-028760ed329f"
hash = "sha256-beJ+wpYSJ5OW8u72RsoEUo4PvECMtRnMXis8bDw6qgE="
version = "v0.6.1-0.20240408020015-27de4edabc79"
hash = "sha256-kzUbVz9+KPFFoauHmSgywEvhPeKtU2EinyxPTVrqsWE="
replaced = "github.com/crypto-org-chain/ethermint"
[mod."github.com/felixge/httpsnoop"]
version = "v1.0.2"
Expand Down
41 changes: 26 additions & 15 deletions integration_tests/configs/cosmovisor.jsonnet
Original file line number Diff line number Diff line change
Expand Up @@ -8,30 +8,41 @@ config {
'iavl-lazy-loading':: super['iavl-lazy-loading'],
},
genesis+: {
consensus_params+: {
block+: {
max_gas: '60000000',
},
},
app_state+: {
bank+: {
send_enabled+: [
{
denom: 'stake',
enabled: true,
},
{
denom: 'basetcro',
enabled: false,
},
],
params: {
send_enabled: [
{
denom: 'stake',
enabled: true,
},
{
denom: 'basetcro',
enabled: false,
},
],
},
},
feemarket+: {
params+: {
no_base_fee: false,
base_fee:: super.base_fee,
},
},
gov: {
voting_params: {
voting_period: '10s',
},
deposit_params: {
max_deposit_period: '10s',
min_deposit: [
{
denom: 'basetcro',
amount: '1',
},
],
},
},
},
},
},
Expand Down
12 changes: 11 additions & 1 deletion integration_tests/configs/upgrade-test-package.nix
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
let
pkgs = import ../../nix { };
fetchFlake0 = repo: rev: (pkgs.flake-compat {
src = {
outPath = builtins.fetchTarball "https://github.com/${repo}/archive/${rev}.tar.gz";
inherit rev;
shortRev = builtins.substring 0 7 rev;
};
}).defaultNix;
# v1.0.15
released0 = (fetchFlake0 "crypto-org-chain/cronos" "1f5e2618362303d91f621b47cbc1115cf4fa0195").default;
fetchFlake = repo: rev: (pkgs.flake-compat {
src = {
outPath = builtins.fetchTarball "https://github.com/${repo}/archive/${rev}.tar.gz";
Expand All @@ -12,6 +21,7 @@ let
current = pkgs.callPackage ../../. { };
in
pkgs.linkFarm "upgrade-test-package" [
{ name = "genesis"; path = released; }
{ name = "genesis"; path = released0; }
{ name = "v1.1.0"; path = released; }
{ name = "v1.2"; path = current; }
]
13 changes: 10 additions & 3 deletions integration_tests/cosmoscli.py
Original file line number Diff line number Diff line change
Expand Up @@ -1061,8 +1061,16 @@ def set_delegate_keys(self, val_addr, acc_addr, eth_addr, signature, **kwargs):
def query_gravity_params(self):
return self.query_params("gravity")

def query_params(self, module="cronos"):
return json.loads(self.raw("query", module, "params", home=self.data_dir))
def query_params(self, module="cronos", **kwargs):
return json.loads(
self.raw(
"query",
module,
"params",
home=self.data_dir,
**kwargs,
)
)

def query_signer_set_txs(self):
return json.loads(
Expand Down Expand Up @@ -1798,7 +1806,6 @@ def event_query_tx_for(self, hash):
"query",
"event-query-tx-for",
hash,
"-y",
home=self.data_dir,
stderr=subprocess.DEVNULL,
)
Expand Down
2 changes: 2 additions & 0 deletions integration_tests/test_gov_update_params.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ def test_evm_update_param(cronos, tmp_path):
approve_proposal(cronos, rsp)
print("check params have been updated now")
p = cli.query_params("evm")["params"]
assert not p["chain_config"]["merge_netsplit_block"]
assert not p["chain_config"]["shanghai_time"]
invalid_msg = "invalid opcode: PUSH0"
with pytest.raises(ValueError) as e_info:
contract.caller.randomTokenId()
Expand Down
91 changes: 59 additions & 32 deletions integration_tests/test_upgrade.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
deploy_contract,
edit_ini_sections,
get_consensus_params,
get_send_enable,
send_transaction,
wait_for_block,
wait_for_new_blocks,
Expand Down Expand Up @@ -97,22 +98,70 @@ def exec(c, tmp_path_factory):
{"denom": "basetcro", "enabled": False},
{"denom": "stake", "enabled": True},
]
p = cli.query_bank_send()
p = get_send_enable(port)
assert sorted(p, key=lambda x: x["denom"]) == send_enable

# export genesis from old version
c.supervisorctl("stop", "all")
migrate = tmp_path_factory.mktemp("migrate")
file_path0 = Path(migrate / "old.json")
cli.export(output_document=str(file_path0))
with open(file_path0, "w") as fp:
json.dump(json.loads(cli.export()), fp)
fp.flush()

c.supervisorctl("start", "cronos_777-1-node0", "cronos_777-1-node1")
wait_for_port(ports.evmrpc_port(c.base_port(0)))
wait_for_new_blocks(cli, 1)

height = cli.block_height()
target_height = height + 15
print("upgrade height", target_height)
target_height0 = height + 15
print("upgrade v1.1 height", target_height0)

def do_upgrade(plan_name, target, mode=None):
rsp = cli.gov_propose_legacy(
"community",
"software-upgrade",
{
"name": plan_name,
"title": "upgrade test",
"description": "ditto",
"upgrade-height": target,
"deposit": "10000basetcro",
},
mode=mode,
)
assert rsp["code"] == 0, rsp["raw_log"]
approve_proposal(c, rsp)

# update cli chain binary
c.chain_binary = (
Path(c.chain_binary).parent.parent.parent / f"{plan_name}/bin/cronosd"
)
# block should pass the target height
wait_for_block(c.cosmos_cli(), target + 2, timeout=480)
wait_for_port(ports.rpc_port(c.base_port(0)))

do_upgrade("v1.1.0", target_height0, "block")
cli = c.cosmos_cli()

# test migrate keystore
cli.migrate_keystore()

# check basic tx works
wait_for_port(ports.evmrpc_port(c.base_port(0)))
receipt = send_transaction(
c.w3,
{
"to": ADDRS["community"],
"value": 1000,
"maxFeePerGas": 10000000000000,
"maxPriorityFeePerGas": 10000,
},
)
assert receipt.status == 1
height = cli.block_height()
target_height1 = height + 15
print("upgrade v1.2 height", target_height1)

w3 = c.w3
random_contract = deploy_contract(
Expand All @@ -131,34 +180,7 @@ def exec(c, tmp_path_factory):
)
print("old values", old_height, old_balance, old_base_fee)

plan_name = "v1.2"
rsp = cli.gov_propose_legacy(
"community",
"software-upgrade",
{
"name": plan_name,
"title": "upgrade test",
"description": "ditto",
"upgrade-height": target_height,
"deposit": "10000basetcro",
},
mode=None,
)
assert rsp["code"] == 0, rsp["raw_log"]
approve_proposal(c, rsp, event_query_tx=True)

# update cli chain binary
c.chain_binary = (
Path(c.chain_binary).parent.parent.parent / f"{plan_name}/bin/cronosd"
)
cli = c.cosmos_cli()

# block should pass the target height
wait_for_block(cli, target_height + 2, timeout=480)
wait_for_port(ports.rpc_port(c.base_port(0)))

# test migrate keystore
cli.migrate_keystore()
do_upgrade("v1.2", target_height1)

# check basic tx works
wait_for_port(ports.evmrpc_port(c.base_port(0)))
Expand Down Expand Up @@ -203,6 +225,11 @@ def exec(c, tmp_path_factory):
max_callback_gas = cli.query_params()["max_callback_gas"]
assert max_callback_gas == "50000", max_callback_gas

e = cli.query_params("evm", height=target_height0 - 1)["params"]["evm_denom"]
assert e == "basetcro", e
e = cli.query_params("evm", height=target_height1 - 1)["params"]["evm_denom"]
assert e == "basetcro", e

# update the genesis time = current time + 5 secs
newtime = datetime.utcnow() + timedelta(seconds=5)
newtime = newtime.replace(tzinfo=None).isoformat("T") + "Z"
Expand Down

0 comments on commit 1aea999

Please sign in to comment.