Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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 @@ -7,6 +7,7 @@
### Bug Fixes

- [#761](https://github.com/crypto-org-chain/cronos/pull/761) Fix non-deterministic evm execution result when there are concurrent grpc queries.
- [#]() Add `v1.0.0` upgrade plan for dry-run and mainnet upgrade, which clears the `extra_eips` parameter.
Comment thread
yihuang marked this conversation as resolved.
Outdated

*Nov 4, 2022*

Expand Down
22 changes: 19 additions & 3 deletions app/upgrades.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,27 @@ import (
)

func (app *App) RegisterUpgradeHandlers(experimental bool) {
planName := "v0.9.0"
app.UpgradeKeeper.SetUpgradeHandler(planName, func(ctx sdk.Context, _ upgradetypes.Plan, fromVM module.VersionMap) (module.VersionMap, error) {
// `v0.9.0` is only used for testnet upgrade, skipped for dry-run and mainnet upgrade.
planNameTestnet := "v0.9.0"
app.UpgradeKeeper.SetUpgradeHandler(planNameTestnet, func(ctx sdk.Context, _ upgradetypes.Plan, fromVM module.VersionMap) (module.VersionMap, error) {
return app.mm.RunMigrations(ctx, app.configurator, fromVM)
})

// dry-run and mainnet will use `v1.0.0` upgrade plan directly, which will clears the `extra_eips` parameters.
planNameMainnet := "v1.0.0"
app.UpgradeKeeper.SetUpgradeHandler(planNameMainnet, 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
}
// clear extra_eips from evm parameters
// Ref: https://github.com/crypto-org-chain/cronos/issues/755
params := app.EvmKeeper.GetParams(ctx)
params.ExtraEIPs = []int64{}
app.EvmKeeper.SetParams(ctx, params)
return m, nil
})

gravityPlanName := "v0.8.0-gravity-alpha3"
if experimental {
app.UpgradeKeeper.SetUpgradeHandler(gravityPlanName, func(ctx sdk.Context, _ upgradetypes.Plan, fromVM module.VersionMap) (module.VersionMap, error) {
Expand All @@ -30,7 +46,7 @@ func (app *App) RegisterUpgradeHandlers(experimental bool) {
}

if !app.UpgradeKeeper.IsSkipHeight(upgradeInfo.Height) {
if upgradeInfo.Name == planName {
if upgradeInfo.Name == planNameTestnet || upgradeInfo.Name == planNameMainnet {
storeUpgrades := storetypes.StoreUpgrades{
Added: []string{ibcfeetypes.StoreKey},
}
Expand Down
11 changes: 11 additions & 0 deletions integration_tests/configs/cosmovisor.jsonnet
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,17 @@ config {
},
genesis+: {
app_state+: {
evm+: {
params+: {
// emulate the environment on production network
extra_eips: [
'2929',
'2200',
'1884',
'1344',
],
},
},
feemarket+: {
params+: {
no_base_fee: false,
Expand Down
2 changes: 1 addition & 1 deletion integration_tests/configs/upgrade-test-package.nix
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,5 @@ let
in
pkgs.linkFarm "upgrade-test-package" [
{ name = "genesis"; path = released; }
{ name = "v0.9.0"; path = current; }
{ name = "v1.0.0"; path = current; }
]
14 changes: 14 additions & 0 deletions integration_tests/cosmoscli.py
Original file line number Diff line number Diff line change
Expand Up @@ -1363,3 +1363,17 @@ def pay_packet_fee(self, port_id, channel_id, packet_seq, **kwargs):
**(default_kwargs | kwargs),
)
)

def evm_params(self, **kwargs):
default_kwargs = {
"node": self.node_rpc,
"output": "json",
}
return json.loads(
self.raw(
"q",
"evm",
"params",
**(default_kwargs | kwargs),
)
)
26 changes: 24 additions & 2 deletions integration_tests/test_upgrade.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,9 +98,19 @@ def test_cosmovisor_upgrade(custom_cronos: Cronos):
old_height = w3.eth.block_number
old_balance = w3.eth.get_balance(ADDRS["validator"], block_identifier=old_height)
old_base_fee = w3.eth.get_block(old_height).baseFeePerGas
old_erc20_balance = contract.caller(block_identifier=old_height).balanceOf(
ADDRS["validator"]
)
print("old values", old_height, old_balance, old_base_fee)

plan_name = "v0.9.0"
# estimateGas for an erc20 transfer tx
old_gas = (
contract.functions.transfer(ADDRS["community"], 100)
.buildTransaction({"from": ADDRS["validator"]})
.gas
Comment thread
mmsqe marked this conversation as resolved.
Outdated
)

plan_name = "v1.0.0"
rsp = cli.gov_propose_v0_7(
"community",
"software-upgrade",
Expand Down Expand Up @@ -163,4 +173,16 @@ def test_cosmovisor_upgrade(custom_cronos: Cronos):
assert old_base_fee == w3.eth.get_block(old_height).baseFeePerGas

# check eth_call works on older blocks
contract.caller(block_identifier=target_height - 2).balanceOf(ADDRS["validator"])
assert old_erc20_balance == contract.caller(block_identifier=old_height).balanceOf(
ADDRS["validator"]
)

print("evm params", cli.evm_params())
Comment thread
yihuang marked this conversation as resolved.
Outdated

# check the gas cost is lower after upgrade
assert (
old_gas - 3700
== contract.functions.transfer(ADDRS["community"], 100)
.buildTransaction({"from": ADDRS["validator"]})
.gas
Comment thread
mmsqe marked this conversation as resolved.
Outdated
)