Skip to content

Commit

Permalink
fork upgrade
Browse files Browse the repository at this point in the history
  • Loading branch information
mmsqe committed Apr 1, 2024
1 parent 82a8b9e commit 9d060fc
Show file tree
Hide file tree
Showing 9 changed files with 69 additions and 7 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@

- [#1363](https://github.com/crypto-org-chain/cronos/pull/1363) Update ethermint to fix a panic on overflow and patch gasUsed in the RPC API.

### State Machine Breaking

* [#1366](https://github.com/crypto-org-chain/ethermint/pull/1366) Keep behavior of random opcode as before.


*March 26, 2024*

## v1.1.1
Expand Down
1 change: 1 addition & 0 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -542,6 +542,7 @@ func New(
},
},
allKeys,
RandomOpcodeForkEnabled,
)

var gravityKeeper gravitykeeper.Keeper
Expand Down
11 changes: 11 additions & 0 deletions app/forks.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,14 @@ func BeginBlockForks(ctx sdk.Context, app *App) {
}
}
}

// TODO decide the fork heights

Check failure on line 34 in app/forks.go

View workflow job for this annotation

GitHub Actions / Run golangci-lint

ST1022: comment on exported var RandomOpcodeForkHeights should be of the form "RandomOpcodeForkHeights ..." (stylecheck)
var RandomOpcodeForkHeights = map[string]int64{
"cronosmainnet_25-1": 18,
"tempcronosmainnet_28-1": 18,
"cronostestnet_338-1": 18,
}

func RandomOpcodeForkEnabled(ctx sdk.Context) bool {
return ctx.BlockHeight() >= RandomOpcodeForkHeights[ctx.ChainID()]

Check warning on line 42 in app/forks.go

View check run for this annotation

Codecov / codecov/patch

app/forks.go#L41-L42

Added lines #L41 - L42 were not covered by tests
}
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.20240326012741-6263a240556c
github.com/evmos/ethermint => github.com/mmsqe/ethermint v0.6.5-0.20240331073601-ade0cb7b783d
// 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,6 @@ 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.20240326012741-6263a240556c h1:3VKwgmkb/CnjHT8v6bwMl70ferUVLcrefEpQc9Q8/F0=
github.com/crypto-org-chain/ethermint v0.6.1-0.20240326012741-6263a240556c/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 Expand Up @@ -1165,6 +1163,8 @@ github.com/mitchellh/pointerstructure v1.2.0 h1:O+i9nHnXS3l/9Wu7r4NrEdwA2VFTicjU
github.com/mitchellh/pointerstructure v1.2.0/go.mod h1:BRAsLI5zgXmw97Lf6s25bs8ohIXc3tViBH44KcwB2g4=
github.com/mitchellh/reflectwalk v1.0.0/go.mod h1:mSTlrgnPZtwu0c4WaC2kGObEpuNDbx0jmZXqmk4esnw=
github.com/mitchellh/reflectwalk v1.0.1/go.mod h1:mSTlrgnPZtwu0c4WaC2kGObEpuNDbx0jmZXqmk4esnw=
github.com/mmsqe/ethermint v0.6.5-0.20240331073601-ade0cb7b783d h1:exXMTi3+Do+stu1pYYIx88rqcO053QGw/rfjk66DLKE=
github.com/mmsqe/ethermint v0.6.5-0.20240331073601-ade0cb7b783d/go.mod h1:zJYmx1D+tDggzvXmdJ0/I62TeIykdCMfJBjBxOcniAU=
github.com/moby/sys/mountinfo v0.5.0/go.mod h1:3bMD3Rg+zkqx8MRYPi7Pyb0Ie97QEBmdxbhnCLlSvSU=
github.com/moby/term v0.0.0-20201216013528-df9cb8a40635/go.mod h1:FBS0z0QWA44HXygs7VXDUOGoN/1TV3RuWkLO04am3wc=
github.com/moby/term v0.0.0-20210619224110-3f7ff695adc6/go.mod h1:E2VnQOmVuvZB6UYnnDB0qG5Nq/1tD9acaOpo6xmt0Kw=
Expand Down
6 changes: 3 additions & 3 deletions gomod2nix.toml
Original file line number Diff line number Diff line change
Expand Up @@ -216,9 +216,9 @@ 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.20240326012741-6263a240556c"
hash = "sha256-MgvJ9Z0zl+oZtMmbSAlqaibQvzKqEvM1016uF9GEHXI="
replaced = "github.com/crypto-org-chain/ethermint"
version = "v0.6.5-0.20240331073601-ade0cb7b783d"
hash = "sha256-RnkjCBsqTgeyy/S/vtgJn/VtH4H8hVTtTLR1rCIOFJw="
replaced = "github.com/mmsqe/ethermint"
[mod."github.com/felixge/httpsnoop"]
version = "v1.0.2"
hash = "sha256-hj6FZQ1fDAV+1wGIViAt8XaAkWZ1I5vJzgjIJa7XRBA="
Expand Down
9 changes: 9 additions & 0 deletions integration_tests/configs/fork.jsonnet
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
local default = import 'default.jsonnet';

{
'cronosmainnet_25-1': default['cronos_777-1'] {
'app-config'+: {
chain_id: 'cronosmainnet_25-1',
},
},
}
3 changes: 2 additions & 1 deletion integration_tests/network.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,7 @@ def setup_custom_cronos(
chain_binary=None,
wait_port=True,
relayer=cluster.Relayer.HERMES.value,
chain_id="cronos_777-1",
):
cmd = [
"pystarport",
Expand Down Expand Up @@ -186,7 +187,7 @@ def setup_custom_cronos(
if wait_port:
wait_for_port(ports.evmrpc_port(base_port))
wait_for_port(ports.evmrpc_ws_port(base_port))
yield Cronos(path / "cronos_777-1", chain_binary=chain_binary or "cronosd")
yield Cronos(path / chain_id, chain_binary=chain_binary or "cronosd")
finally:
os.killpg(os.getpgid(proc.pid), signal.SIGTERM)
# proc.terminate()
Expand Down
35 changes: 35 additions & 0 deletions integration_tests/test_fork.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
from pathlib import Path

import pytest

from .network import setup_custom_cronos
from .utils import CONTRACTS, deploy_contract, wait_for_new_blocks

pytestmark = pytest.mark.upgrade


@pytest.fixture(scope="module")
def custom_cronos(tmp_path_factory):
yield from setup_custom_cronos(
tmp_path_factory.mktemp("fork"),
27100,
Path(__file__).parent / "configs/fork.jsonnet",
chain_id="cronosmainnet_25-1",
)


def test_slash_fork(custom_cronos):
w3 = custom_cronos.w3
cli = custom_cronos.cosmos_cli()
random_contract = deploy_contract(
w3,
CONTRACTS["Random"],
)
with pytest.raises(ValueError) as e_info:
res = random_contract.caller.randomTokenId()
assert "invalid memory address or nil pointer dereference" in str(e_info.value)
deploy_contract(w3, CONTRACTS["Greeter"])
wait_for_new_blocks(cli, 3)
deploy_contract(w3, CONTRACTS["Greeter"])
res = random_contract.caller.randomTokenId()
assert res > 0, res

0 comments on commit 9d060fc

Please sign in to comment.