From 7b8c64ee35e5082a952403ffaf31141cb5d5d4d1 Mon Sep 17 00:00:00 2001 From: HuangYi Date: Wed, 18 May 2022 13:18:18 +0800 Subject: [PATCH 01/11] Add cli rollback command it's useful in app-hash mismatch situation. --- CHANGELOG.md | 4 ++++ go.mod | 14 ++++++++------ go.sum | 31 ++++++++++++------------------- server/util.go | 1 + 4 files changed, 25 insertions(+), 25 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index aa86a5dda8..2109efc1c2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -38,6 +38,10 @@ Ref: https://keepachangelog.com/en/1.0.0/ ## Unreleased +### Improvements + +- (cli) []() Add rollback command. + ## [v0.15.0] - 2022-05-09 ### State Machine Breaking diff --git a/go.mod b/go.mod index b7b16f117a..6512fccf21 100644 --- a/go.mod +++ b/go.mod @@ -28,11 +28,11 @@ require ( github.com/spf13/viper v1.11.0 github.com/status-im/keycard-go v0.0.0-20200402102358-957c09536969 github.com/stretchr/testify v1.7.1 - github.com/tendermint/tendermint v0.34.19 + github.com/tendermint/tendermint v0.34.20-0.20220517115723-e6f071164839 github.com/tendermint/tm-db v0.6.7 github.com/tyler-smith/go-bip39 v1.1.0 google.golang.org/genproto v0.0.0-20220414192740-2d67ff6cf2b4 - google.golang.org/grpc v1.45.0 + google.golang.org/grpc v1.46.2 google.golang.org/protobuf v1.28.0 gopkg.in/yaml.v2 v2.4.0 ) @@ -69,10 +69,10 @@ require ( github.com/dvsekhvalnov/jose2go v0.0.0-20200901110807-248326c1351b // indirect github.com/edsrzf/mmap-go v1.0.0 // indirect github.com/felixge/httpsnoop v1.0.1 // indirect - github.com/fsnotify/fsnotify v1.5.1 // indirect + github.com/fsnotify/fsnotify v1.5.4 // indirect github.com/gballet/go-libpcsclite v0.0.0-20190607065134-2772fd86a8ff // indirect github.com/go-kit/kit v0.12.0 // indirect - github.com/go-kit/log v0.2.0 // indirect + github.com/go-kit/log v0.2.1 // indirect github.com/go-logfmt/logfmt v0.5.1 // indirect github.com/go-ole/go-ole v1.2.1 // indirect github.com/go-playground/validator/v10 v10.4.1 // indirect @@ -100,7 +100,7 @@ require ( github.com/jmhodges/levigo v1.0.0 // indirect github.com/keybase/go-keychain v0.0.0-20190712205309-48d3d31d256d // indirect github.com/klauspost/compress v1.13.6 // indirect - github.com/lib/pq v1.10.4 // indirect + github.com/lib/pq v1.10.6 // indirect github.com/libp2p/go-buffer-pool v0.0.2 // indirect github.com/magiconair/properties v1.8.6 // indirect github.com/mattn/go-isatty v0.0.14 // indirect @@ -116,7 +116,7 @@ require ( github.com/pelletier/go-toml/v2 v2.0.0-beta.8 // indirect github.com/petermattis/goid v0.0.0-20180202154549-b0b1615b78e5 // indirect github.com/pmezard/go-difflib v1.0.0 // indirect - github.com/prometheus/client_golang v1.12.1 // indirect + github.com/prometheus/client_golang v1.12.2 // indirect github.com/prometheus/client_model v0.2.0 // indirect github.com/prometheus/common v0.32.1 // indirect github.com/prometheus/procfs v0.7.3 // indirect @@ -158,3 +158,5 @@ replace ( github.com/gogo/protobuf => github.com/regen-network/protobuf v1.3.3-alpha.regen.1 google.golang.org/grpc => google.golang.org/grpc v1.33.2 ) + +replace github.com/cosmos/cosmos-sdk => github.com/crypto-org-chain/cosmos-sdk v0.44.4-0.20220518050709-bd4ca739c699 diff --git a/go.sum b/go.sum index 3696cacf1e..b45b52a05f 100644 --- a/go.sum +++ b/go.sum @@ -169,7 +169,6 @@ github.com/bgentry/speakeasy v0.1.0 h1:ByYyxL9InA1OWqxJqqp2A5pYHUrCiAL6K3J+LKSsQ github.com/bgentry/speakeasy v0.1.0/go.mod h1:+zsyZBPWlz7T6j88CTgSN5bM796AkVf0kBD4zp0CCIs= github.com/bits-and-blooms/bitset v1.2.0/go.mod h1:gIdJ4wp64HaoK2YrL1Q5/N7Y16edYb8uY+O0FJTyyDA= github.com/bketelsen/crypt v0.0.3-0.20200106085610-5cbc8cc4026c/go.mod h1:MKsuJmJgSg28kpZDP6UIiPt0e0Oz0kqKNGyRaWEPv84= -github.com/bketelsen/crypt v0.0.4/go.mod h1:aI6NrJ0pMGgvZKL1iVgXLnfIFJtfV+bKCoqOes/6LfM= github.com/bmizerany/pat v0.0.0-20170815010413-6226ea591a40/go.mod h1:8rLXio+WjiTceGBHIoTvn60HIbs7Hm7bcHjyrSqYB9c= github.com/boltdb/bolt v1.3.1/go.mod h1:clJnj/oiGkjum5o1McbSZDSLxVThjynRyGBgiAx27Ps= github.com/btcsuite/btcd v0.0.0-20171128150713-2e60448ffcc6/go.mod h1:Dmm/EzmjnCiweXmzRIAiUWCInVmPgjkzgv5k4tVyXiQ= @@ -254,9 +253,6 @@ github.com/coreos/pkg v0.0.0-20160727233714-3ac0863d7acf/go.mod h1:E3G3o1h8I7cfc github.com/coreos/pkg v0.0.0-20180928190104-399ea9e2e55f/go.mod h1:E3G3o1h8I7cfcXa63jLwjI0eiQQMgzzUDFVpN/nH/eA= github.com/cosmos/btcutil v1.0.4 h1:n7C2ngKXo7UC9gNyMNLbzqz7Asuf+7Qv4gnX/rOdQ44= github.com/cosmos/btcutil v1.0.4/go.mod h1:Ffqc8Hn6TJUdDgHBwIZLtrLQC1KdJ9jGJl/TvgUaxbU= -github.com/cosmos/cosmos-sdk v0.45.1/go.mod h1:XXS/asyCqWNWkx2rW6pSuen+EVcpAFxq6khrhnZgHaQ= -github.com/cosmos/cosmos-sdk v0.45.4 h1:eStDAhJdMY8n5arbBRe+OwpNeBSunxSBHp1g55ulfdA= -github.com/cosmos/cosmos-sdk v0.45.4/go.mod h1:WOqtDxN3eCCmnYLVla10xG7lEXkFjpTaqm2a2WasgCc= github.com/cosmos/go-bip39 v0.0.0-20180819234021-555e2067c45d/go.mod h1:tSxLoYXyBmiFeKpvmq4dzayMdCjCnu8uqmCysIGBT2Y= github.com/cosmos/go-bip39 v1.0.0 h1:pcomnQdrdH22njcAatO0yWojsUnCO3y2tNoV1cb6hHY= github.com/cosmos/go-bip39 v1.0.0/go.mod h1:RNJv0H/pOIVgxw6KS7QeX2a0Uo0aKUlfhZ4xuwvCdJw= @@ -278,6 +274,8 @@ github.com/cpuguy83/go-md2man/v2 v2.0.0/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsr github.com/cpuguy83/go-md2man/v2 v2.0.1/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o= github.com/creack/pty v1.1.7/go.mod h1:lj5s0c3V2DBrqTV7llrYr5NG6My20zk30Fl46Y7DoTY= github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E= +github.com/crypto-org-chain/cosmos-sdk v0.44.4-0.20220518050709-bd4ca739c699 h1:ktGdNahHd9qCoUxboMajlZ9HexLfPvW2QsciQia8fL8= +github.com/crypto-org-chain/cosmos-sdk v0.44.4-0.20220518050709-bd4ca739c699/go.mod h1:YkIkmgbvtkoaWjW7NDSVzzdKZRwCiwqt5PbJzXyJ+qM= github.com/cyberdelia/templates v0.0.0-20141128023046-ca7fffd4298c/go.mod h1:GyV+0YP4qX0UQ7r2MoYZ+AvYDp12OF5yg4q8rGnyNh4= github.com/cyphar/filepath-securejoin v0.2.2/go.mod h1:FpkQEhXnPnOthhzymB7CGsFk2G9VLXONKD9G7QGMM+4= github.com/danieljoos/wincred v1.0.2 h1:zf4bhty2iLuwgjgpraD2E9UbvO+fe54XXGJbOwe23fU= @@ -367,8 +365,9 @@ github.com/franela/goreq v0.0.0-20171204163338-bcd34c9993f8/go.mod h1:ZhphrRTfi2 github.com/frankban/quicktest v1.11.3/go.mod h1:wRf/ReqHper53s+kmmSZizM8NamnL3IM0I9ntUbOk+k= github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo= github.com/fsnotify/fsnotify v1.4.9/go.mod h1:znqG4EE+3YCdAaPaxE2ZRY/06pZUdp0tY4IgpuI1SZQ= -github.com/fsnotify/fsnotify v1.5.1 h1:mZcQUHVQUQWoPXXtuf9yuEXKudkV2sx1E06UadKWpgI= github.com/fsnotify/fsnotify v1.5.1/go.mod h1:T3375wBYaZdLLcVNkcVbzGHY7f1l/uK5T5Ai1i3InKU= +github.com/fsnotify/fsnotify v1.5.4 h1:jRbGcIw6P2Meqdwuo0H1p6JVLbL5DHKAKlYndzMwVZI= +github.com/fsnotify/fsnotify v1.5.4/go.mod h1:OVB6XrOHzAwXMpEM7uPOzcehqUV2UqJxmVXmkdnm1bU= github.com/gballet/go-libpcsclite v0.0.0-20190607065134-2772fd86a8ff h1:tY80oXqGNY4FhTFhk+o9oFHGINQ/+vhlm8HFzi6znCI= github.com/gballet/go-libpcsclite v0.0.0-20190607065134-2772fd86a8ff/go.mod h1:x7DCsMOv1taUwEWCzT4cmDeAkigA5/QCwUodaVOe8Ww= github.com/getkin/kin-openapi v0.53.0/go.mod h1:7Yn5whZr5kJi6t+kShccXS8ae1APpYTW6yheSwk8Yi4= @@ -391,8 +390,9 @@ github.com/go-kit/kit v0.10.0/go.mod h1:xUsJbQ/Fp4kEt7AFgCuvyX4a71u8h9jB8tj/ORgO github.com/go-kit/kit v0.12.0 h1:e4o3o3IsBfAKQh5Qbbiqyfu97Ku7jrO/JbohvztANh4= github.com/go-kit/kit v0.12.0/go.mod h1:lHd+EkCZPIwYItmGDDRdhinkzX2A1sj+M9biaEaizzs= github.com/go-kit/log v0.1.0/go.mod h1:zbhenjAZHb184qTLMA9ZjW7ThYL0H2mk7Q6pNt4vbaY= -github.com/go-kit/log v0.2.0 h1:7i2K3eKTos3Vc0enKCfnVcgHh2olr/MyfboYq7cAcFw= github.com/go-kit/log v0.2.0/go.mod h1:NwTd00d/i8cPZ3xOwwiv2PO5MOcx78fFErGNcVmBjv0= +github.com/go-kit/log v0.2.1 h1:MRVx0/zhvdseW+Gza6N9rVzU/IVzaeE1SFI4raAhmBU= +github.com/go-kit/log v0.2.1/go.mod h1:NwTd00d/i8cPZ3xOwwiv2PO5MOcx78fFErGNcVmBjv0= github.com/go-logfmt/logfmt v0.3.0/go.mod h1:Qt1PoO58o5twSAckw1HlFXLmHsOX5/0LbT9GBnD5lWE= github.com/go-logfmt/logfmt v0.4.0/go.mod h1:3RMwSq7FuexP4Kalkev3ejPJsZTpXXBr9+V4qmtdjCk= github.com/go-logfmt/logfmt v0.5.0/go.mod h1:wCYkCAKZfumFQihp8CzCvQ3paCTfi41vtzG1KdI/P7A= @@ -733,8 +733,9 @@ github.com/leodido/go-urn v1.2.0/go.mod h1:+8+nEpDfqqsY+g338gtMEUOtuK+4dEMhiQEgx github.com/lib/pq v1.0.0/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo= github.com/lib/pq v1.2.0/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo= github.com/lib/pq v1.10.2/go.mod h1:AlVN5x4E4T544tWzH6hKfbfQvm3HdbOxrmggDNAPY9o= -github.com/lib/pq v1.10.4 h1:SO9z7FRPzA03QhHKJrH5BXA6HU1rS4V2nIVrrNC1iYk= github.com/lib/pq v1.10.4/go.mod h1:AlVN5x4E4T544tWzH6hKfbfQvm3HdbOxrmggDNAPY9o= +github.com/lib/pq v1.10.6 h1:jbk+ZieJ0D7EVGJYpL9QTz7/YW6UHbmdnZWYyK5cdBs= +github.com/lib/pq v1.10.6/go.mod h1:AlVN5x4E4T544tWzH6hKfbfQvm3HdbOxrmggDNAPY9o= github.com/libp2p/go-buffer-pool v0.0.2 h1:QNK2iAFa8gjAe1SPz6mHSMuCcjs+X1wlHzeOSqcmlfs= github.com/libp2p/go-buffer-pool v0.0.2/go.mod h1:MvaB6xw5vOrDl8rYZGLFdKAuk/hRoRZd1Vi32+RXyFM= github.com/lightstep/lightstep-tracer-common/golang/gogo v0.0.0-20190605223551-bc2310a04743/go.mod h1:qklhhLq1aX+mtWk9cPHPzaBjWImj5ULL6C7HFJtXQMM= @@ -908,7 +909,6 @@ github.com/paulbellamy/ratecounter v0.2.0/go.mod h1:Hfx1hDpSGoqxkVVpBi/IlYD7kChl github.com/pborman/uuid v0.0.0-20170112150404-1b00554d8222/go.mod h1:VyrYX9gd7irzKovcSS6BIIEwPRkP2Wm2m9ufcdFSJ34= github.com/pborman/uuid v1.2.0/go.mod h1:X/NO0urCmaxf9VXbdlT7C2Yzkj2IKimNn4k+gtPdI/k= github.com/pelletier/go-toml v1.2.0/go.mod h1:5z9KED0ma1S8pY6P1sdut58dfprrGBbd/94hg7ilaic= -github.com/pelletier/go-toml v1.9.3/go.mod h1:u1nR/EPcESfeI/szUZKdtJ0xRNbUoANCkoOuaOx1Y+c= github.com/pelletier/go-toml v1.9.4 h1:tjENF6MfZAg8e4ZmZTeWaWiT2vXtsoO6+iuOjFhECwM= github.com/pelletier/go-toml v1.9.4/go.mod h1:u1nR/EPcESfeI/szUZKdtJ0xRNbUoANCkoOuaOx1Y+c= github.com/pelletier/go-toml/v2 v2.0.0-beta.8 h1:dy81yyLYJDwMTifq24Oi/IslOslRrDSb3jwDggjz3Z0= @@ -945,8 +945,8 @@ github.com/prometheus/client_golang v1.4.0/go.mod h1:e9GMxYsXl05ICDXkRhurwBS4Q3O github.com/prometheus/client_golang v1.7.1/go.mod h1:PY5Wy2awLA44sXw4AOSfFBetzPP4j5+D6mVACh+pe2M= github.com/prometheus/client_golang v1.8.0/go.mod h1:O9VU6huf47PktckDQfMTX0Y8tY0/7TSWwj+ITvv0TnM= github.com/prometheus/client_golang v1.11.0/go.mod h1:Z6t4BnS23TR94PD6BsDNk8yVqroYurpAkEiz0P2BEV0= -github.com/prometheus/client_golang v1.12.1 h1:ZiaPsmm9uiBeaSMRznKsCDNtPCS0T3JVDGF+06gjBzk= -github.com/prometheus/client_golang v1.12.1/go.mod h1:3Z9XVyYiZYEO+YQWt3RD2R3jrbd179Rt297l4aS6nDY= +github.com/prometheus/client_golang v1.12.2 h1:51L9cDoUHVrXx4zWYlcLQIZ+d+VXHgqnYKkIuq4g/34= +github.com/prometheus/client_golang v1.12.2/go.mod h1:3Z9XVyYiZYEO+YQWt3RD2R3jrbd179Rt297l4aS6nDY= github.com/prometheus/client_model v0.0.0-20180712105110-5c3871d89910/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo= github.com/prometheus/client_model v0.0.0-20190115171406-56726106282f/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo= github.com/prometheus/client_model v0.0.0-20190129233127-fd36f4220a90/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= @@ -1047,14 +1047,12 @@ github.com/spf13/afero v1.6.0/go.mod h1:Ai8FlHk4v/PARR026UzYexafAt9roJ7LcLMAmO6Z github.com/spf13/afero v1.8.2 h1:xehSyVa0YnHWsJ49JFljMpg1HX19V6NDZ1fkm1Xznbo= github.com/spf13/afero v1.8.2/go.mod h1:CtAatgMJh6bJEIs48Ay/FOnkljP3WeGUG0MC1RfAqwo= github.com/spf13/cast v1.3.0/go.mod h1:Qx5cxh0v+4UWYiBimWS+eyWzqEqokIECu5etghLkUJE= -github.com/spf13/cast v1.3.1/go.mod h1:Qx5cxh0v+4UWYiBimWS+eyWzqEqokIECu5etghLkUJE= github.com/spf13/cast v1.4.1 h1:s0hze+J0196ZfEMTs80N7UlFt0BDuQ7Q+JDnHiMWKdA= github.com/spf13/cast v1.4.1/go.mod h1:Qx5cxh0v+4UWYiBimWS+eyWzqEqokIECu5etghLkUJE= github.com/spf13/cobra v0.0.3/go.mod h1:1l0Ry5zgKvJasoi3XT1TypsSe7PqH0Sj9dhYf7v3XqQ= github.com/spf13/cobra v0.0.5/go.mod h1:3K3wKZymM7VvHMDS9+Akkh4K60UwM26emMESw8tLCHU= github.com/spf13/cobra v1.0.0/go.mod h1:/6GTrnGXV9HjY+aR4k0oJ5tcvakLuG6EuKReYlHNrgE= github.com/spf13/cobra v1.1.1/go.mod h1:WnodtKOvamDL/PwE2M4iKs8aMDBZ5Q5klgD3qfVJQMI= -github.com/spf13/cobra v1.2.1/go.mod h1:ExllRjgxM/piMAM+3tAZvg8fsklGAf3tPfi+i8t68Nk= github.com/spf13/cobra v1.3.0/go.mod h1:BrRVncBjOJa/eUcVVm9CE+oC6as8k+VYr4NY7WCi9V4= github.com/spf13/cobra v1.4.0 h1:y+wJpx64xcgO1V+RcnwW0LEHxTKRi2ZDPSBjWnrg88Q= github.com/spf13/cobra v1.4.0/go.mod h1:Wo4iy3BUC+X2Fybo0PDqwJIv3dNRiZLHQymsfxlB84g= @@ -1069,7 +1067,6 @@ github.com/spf13/viper v1.3.2/go.mod h1:ZiWeW+zYFKm7srdB9IoDzzZXaJaI5eL9QjNiN/DM github.com/spf13/viper v1.4.0/go.mod h1:PTJ7Z/lr49W6bUbkmS1V3by4uWynFiR9p7+dSq/yZzE= github.com/spf13/viper v1.7.0/go.mod h1:8WkrPz2fc9jxqZNCJI/76HCieCp4Q8HaLFoCha5qpdg= github.com/spf13/viper v1.7.1/go.mod h1:8WkrPz2fc9jxqZNCJI/76HCieCp4Q8HaLFoCha5qpdg= -github.com/spf13/viper v1.8.1/go.mod h1:o0Pch8wJ9BVSWGQMbra6iw0oQ5oktSIBaujf1rJH9Ns= github.com/spf13/viper v1.10.0/go.mod h1:SoyBPwAtKDzypXNDFKN5kzH7ppppbGZtls1UpIy5AsM= github.com/spf13/viper v1.10.1/go.mod h1:IGlFPqhNAPKRxohIzWpI5QEy4kuI7tcl5WvR+8qy1rU= github.com/spf13/viper v1.11.0 h1:7OX/1FS6n7jHD1zGrZTM7WtY13ZELRyosK4k93oPr44= @@ -1112,8 +1109,8 @@ github.com/tendermint/crypto v0.0.0-20191022145703-50d29ede1e15/go.mod h1:z4YtwM github.com/tendermint/go-amino v0.16.0 h1:GyhmgQKvqF82e2oZeuMSp9JTN0N09emoSZlb2lyGa2E= github.com/tendermint/go-amino v0.16.0/go.mod h1:TQU0M1i/ImAo+tYpZi73AU3V/dKeCoMC9Sphe2ZwGME= github.com/tendermint/tendermint v0.34.14/go.mod h1:FrwVm3TvsVicI9Z7FlucHV6Znfd5KBc/Lpp69cCwtk0= -github.com/tendermint/tendermint v0.34.19 h1:y0P1qI5wSa9IRuhKnTDA6IUcOrLi1hXJuALR+R7HFEk= -github.com/tendermint/tendermint v0.34.19/go.mod h1:R5+wgIwSxMdKQcmOaeudL0Cjkr3HDkhpcdum6VeU3R4= +github.com/tendermint/tendermint v0.34.20-0.20220517115723-e6f071164839 h1:84fLknaRpFmZ33teqQSKq5tksqPDk90vhbz53Ngp4a8= +github.com/tendermint/tendermint v0.34.20-0.20220517115723-e6f071164839/go.mod h1:Rlthqx2Hq440neL9pfBGV1TJGqqTqT++bvkL1yvpytY= github.com/tendermint/tm-db v0.6.4/go.mod h1:dptYhIpJ2M5kUuenLr+Yyf3zQOv1SgBZcl8/BmWlMBw= github.com/tendermint/tm-db v0.6.6/go.mod h1:wP8d49A85B7/erz/r4YbKssKw6ylsO/hKtFk7E1aWZI= github.com/tendermint/tm-db v0.6.7 h1:fE00Cbl0jayAoqlExN6oyQJ7fR/ZtoVOmvPJ//+shu8= @@ -1362,7 +1359,6 @@ golang.org/x/oauth2 v0.0.0-20201208152858-08078c50e5b5/go.mod h1:KelEdhl1UZF7XfJ golang.org/x/oauth2 v0.0.0-20210218202405-ba52d332ba99/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= golang.org/x/oauth2 v0.0.0-20210220000619-9bb904979d93/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= golang.org/x/oauth2 v0.0.0-20210313182246-cd4f82c27b84/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= -golang.org/x/oauth2 v0.0.0-20210402161424-2e8d93401602/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= golang.org/x/oauth2 v0.0.0-20210514164344-f6687ab2804c/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= golang.org/x/oauth2 v0.0.0-20210628180205-a41e5a781914/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= golang.org/x/oauth2 v0.0.0-20210805134026-6f1e6394065a/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= @@ -1623,7 +1619,6 @@ google.golang.org/api v0.36.0/go.mod h1:+z5ficQTmoYpPn8LCUNVpK5I7hwkpjbcgqA7I34q google.golang.org/api v0.40.0/go.mod h1:fYKFpnQN0DsDSKRVRcQSDQNtqWPfM9i+zNPxepjRCQ8= google.golang.org/api v0.41.0/go.mod h1:RkxM5lITDfTzmyKFPt+wGrCJbVfniCr2ool8kTBzRTU= google.golang.org/api v0.43.0/go.mod h1:nQsDGjRXMo4lvh5hP0TKqF244gqhGcr/YSIykhUk/94= -google.golang.org/api v0.44.0/go.mod h1:EBOGZqzyhtvMDoxwS97ctnh0zUmYY6CxqXsc1AvkYD8= google.golang.org/api v0.47.0/go.mod h1:Wbvgpq1HddcWVtzsVLyfLp8lDg6AA241LmgIL59tHXo= google.golang.org/api v0.48.0/go.mod h1:71Pr1vy+TAZRPkPs/xlCf5SsU8WjuAWv1Pfjbtukyy4= google.golang.org/api v0.50.0/go.mod h1:4bNT5pAuq5ji4SRZm+5QIkjny9JAyVD/3gaSihNefaw= @@ -1722,7 +1717,6 @@ google.golang.org/genproto v0.0.0-20211203200212-54befc351ae9/go.mod h1:5CzLGKJ6 google.golang.org/genproto v0.0.0-20211206160659-862468c7d6e0/go.mod h1:5CzLGKJ67TSI2B9POpiiyGha0AjJvZIUgRMt1dSmuhc= google.golang.org/genproto v0.0.0-20211208223120-3a66f561d7aa/go.mod h1:5CzLGKJ67TSI2B9POpiiyGha0AjJvZIUgRMt1dSmuhc= google.golang.org/genproto v0.0.0-20211221195035-429b39de9b1c/go.mod h1:5CzLGKJ67TSI2B9POpiiyGha0AjJvZIUgRMt1dSmuhc= -google.golang.org/genproto v0.0.0-20211223182754-3ac035c7e7cb/go.mod h1:5CzLGKJ67TSI2B9POpiiyGha0AjJvZIUgRMt1dSmuhc= google.golang.org/genproto v0.0.0-20220126215142-9970aeb2e350/go.mod h1:5CzLGKJ67TSI2B9POpiiyGha0AjJvZIUgRMt1dSmuhc= google.golang.org/genproto v0.0.0-20220207164111-0872dc986b00/go.mod h1:5CzLGKJ67TSI2B9POpiiyGha0AjJvZIUgRMt1dSmuhc= google.golang.org/genproto v0.0.0-20220218161850-94dd64e39d7c/go.mod h1:kGP+zUP2Ddo0ayMi4YuN7C3WZyJvGLZRh8Z5wnAqvEI= @@ -1765,7 +1759,6 @@ gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI= gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys= gopkg.in/gcfg.v1 v1.2.3/go.mod h1:yesOnuUOFQAhST5vPY4nbZsb/huCgGGXlipJsBn0b3o= gopkg.in/ini.v1 v1.51.0/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k= -gopkg.in/ini.v1 v1.62.0/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k= gopkg.in/ini.v1 v1.66.2/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k= gopkg.in/ini.v1 v1.66.4 h1:SsAcf+mM7mRZo2nJNGt8mZCjG8ZRaNGMURJw7BsIST4= gopkg.in/ini.v1 v1.66.4/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k= diff --git a/server/util.go b/server/util.go index b4f9d607b0..0f9566b3da 100644 --- a/server/util.go +++ b/server/util.go @@ -41,6 +41,7 @@ func AddCommands(rootCmd *cobra.Command, defaultNodeHome string, appCreator type tendermintCmd, sdkserver.ExportCmd(appExport, defaultNodeHome), version.NewVersionCommand(), + sdkserver.NewRollbackCmd(appCreator, defaultNodeHome), ) } From 440a7f1e599e4400fedba7d3cec14972f3ca8af2 Mon Sep 17 00:00:00 2001 From: yihuang Date: Wed, 18 May 2022 13:20:29 +0800 Subject: [PATCH 02/11] Update CHANGELOG.md --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2109efc1c2..0e1bc91612 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -40,7 +40,7 @@ Ref: https://keepachangelog.com/en/1.0.0/ ### Improvements -- (cli) []() Add rollback command. +* (cli) [tharsis#1086](https://github.com/tharsis/ethermint/pull/1086) Add rollback command. ## [v0.15.0] - 2022-05-09 From f6a2c073490bf46242c5c2d29f8d62c3a9af0430 Mon Sep 17 00:00:00 2001 From: Vladislav Varadinov Date: Tue, 29 Nov 2022 10:16:26 +0200 Subject: [PATCH 03/11] (refactor): removed old sim tests logic --- Makefile | 35 --- app/app.go | 36 --- app/simulation_test.go | 355 ------------------------------ app/utils.go | 108 +-------- app/utils_test.go | 111 ---------- x/evm/module.go | 12 +- x/evm/simulation/decoder.go | 31 --- x/evm/simulation/decoder_test.go | 47 ---- x/evm/simulation/genesis.go | 61 ----- x/evm/simulation/genesis_test.go | 50 ----- x/evm/simulation/operations.go | 300 ------------------------- x/evm/simulation/params.go | 41 ---- x/evm/simulation/params_test.go | 44 ---- x/feemarket/module.go | 2 - x/feemarket/simulation/genesis.go | 25 --- 15 files changed, 4 insertions(+), 1254 deletions(-) delete mode 100644 app/simulation_test.go delete mode 100644 app/utils_test.go delete mode 100644 x/evm/simulation/decoder.go delete mode 100644 x/evm/simulation/decoder_test.go delete mode 100644 x/evm/simulation/genesis.go delete mode 100644 x/evm/simulation/genesis_test.go delete mode 100644 x/evm/simulation/operations.go delete mode 100644 x/evm/simulation/params.go delete mode 100644 x/evm/simulation/params_test.go delete mode 100644 x/feemarket/simulation/genesis.go diff --git a/Makefile b/Makefile index 25b8f92cc2..aea5f82087 100755 --- a/Makefile +++ b/Makefile @@ -337,41 +337,6 @@ test-solidity: .PHONY: run-tests test test-all test-import test-rpc test-contract test-solidity $(TEST_TARGETS) -test-sim-nondeterminism: - @echo "Running non-determinism test..." - @go test -mod=readonly $(SIMAPP) -run TestAppStateDeterminism -Enabled=true \ - -NumBlocks=100 -BlockSize=200 -Commit=true -Period=0 -v -timeout 24h - -test-sim-random-genesis-fast: - @echo "Running random genesis simulation..." - @go test -mod=readonly $(SIMAPP) -run TestFullAppSimulation \ - -Enabled=true -NumBlocks=100 -BlockSize=200 -Commit=true -Seed=99 -Period=5 -v -timeout 24h - -test-sim-import-export: runsim - @echo "Running application import/export simulation. This may take several minutes..." - @$(BINDIR)/runsim -Jobs=4 -SimAppPkg=$(SIMAPP) -ExitOnFail 50 5 TestAppImportExport - -test-sim-after-import: runsim - @echo "Running application simulation-after-import. This may take several minutes..." - @$(BINDIR)/runsim -Jobs=4 -SimAppPkg=$(SIMAPP) -ExitOnFail 50 5 TestAppSimulationAfterImport - -test-sim-random-genesis-multi-seed: runsim - @echo "Running multi-seed custom genesis simulation..." - @$(BINDIR)/runsim -SimAppPkg=$(SIMAPP) -ExitOnFail 400 5 TestFullAppSimulation - -test-sim-multi-seed-long: runsim - @echo "Running long multi-seed application simulation. This may take awhile!" - @$(BINDIR)/runsim -Jobs=4 -SimAppPkg=$(SIMAPP) -ExitOnFail 500 50 TestFullAppSimulation - -test-sim-multi-seed-short: runsim - @echo "Running short multi-seed application simulation. This may take awhile!" - @$(BINDIR)/runsim -Jobs=4 -SimAppPkg=$(SIMAPP) -ExitOnFail 50 10 TestFullAppSimulation - -test-sim-benchmark-invariants: - @echo "Running simulation invariant benchmarks..." - @go test -mod=readonly $(SIMAPP) -benchmem -bench=BenchmarkInvariants -run=^$ \ - -Enabled=true -NumBlocks=1000 -BlockSize=200 \ - -Period=1 -Commit=true -Seed=57 -v -timeout 24h .PHONY: \ test-sim-nondeterminism \ diff --git a/app/app.go b/app/app.go index 43120044a4..365d806e57 100644 --- a/app/app.go +++ b/app/app.go @@ -175,8 +175,6 @@ var ( } ) -var _ simapp.App = (*EthermintApp)(nil) - // var _ server.Application (*EthermintApp)(nil) // EthermintApp implements an extended ABCI application. It is an application @@ -226,9 +224,6 @@ type EthermintApp struct { // the module manager mm *module.Manager - // simulation manager - sm *module.SimulationManager - // the configurator configurator module.Configurator } @@ -531,32 +526,6 @@ func NewEthermintApp( // add test gRPC service for testing gRPC queries in isolation // testdata.RegisterTestServiceServer(app.GRPCQueryRouter(), testdata.TestServiceImpl{}) - // create the simulation manager and define the order of the modules for deterministic simulations - - // NOTE: this is not required apps that don't use the simulator for fuzz testing - // transactions - app.sm = module.NewSimulationManager( - // Use custom RandomGenesisAccounts so that auth module could create random EthAccounts in genesis state when genesis.json not specified - auth.NewAppModule(appCodec, app.AccountKeeper, RandomGenesisAccounts), - bank.NewAppModule(appCodec, app.BankKeeper, app.AccountKeeper), - capability.NewAppModule(appCodec, *app.CapabilityKeeper), - gov.NewAppModule(appCodec, app.GovKeeper, app.AccountKeeper, app.BankKeeper), - mint.NewAppModule(appCodec, app.MintKeeper, app.AccountKeeper), - staking.NewAppModule(appCodec, app.StakingKeeper, app.AccountKeeper, app.BankKeeper), - distr.NewAppModule(appCodec, app.DistrKeeper, app.AccountKeeper, app.BankKeeper, app.StakingKeeper), - slashing.NewAppModule(appCodec, app.SlashingKeeper, app.AccountKeeper, app.BankKeeper, app.StakingKeeper), - params.NewAppModule(app.ParamsKeeper), - evidence.NewAppModule(app.EvidenceKeeper), - feegrantmodule.NewAppModule(appCodec, app.AccountKeeper, app.BankKeeper, app.FeeGrantKeeper, app.interfaceRegistry), - authzmodule.NewAppModule(appCodec, app.AuthzKeeper, app.AccountKeeper, app.BankKeeper, app.interfaceRegistry), - ibc.NewAppModule(app.IBCKeeper), - transferModule, - evm.NewAppModule(app.EvmKeeper, app.AccountKeeper), - feemarket.NewAppModule(app.FeeMarketKeeper), - ) - - app.sm.RegisterStoreDecoders() - // initialize stores app.MountKVStores(keys) app.MountTransientStores(tkeys) @@ -699,11 +668,6 @@ func (app *EthermintApp) GetSubspace(moduleName string) paramstypes.Subspace { return subspace } -// SimulationManager implements the SimulationApp interface -func (app *EthermintApp) SimulationManager() *module.SimulationManager { - return app.sm -} - // RegisterAPIRoutes registers all application module routes with the provided // API server. func (app *EthermintApp) RegisterAPIRoutes(apiSvr *api.Server, apiConfig config.APIConfig) { diff --git a/app/simulation_test.go b/app/simulation_test.go deleted file mode 100644 index 98ef022290..0000000000 --- a/app/simulation_test.go +++ /dev/null @@ -1,355 +0,0 @@ -package app - -// TODO: COsmos SDK fix for the simulator issue for custom keys -import ( - "encoding/json" - "fmt" - "math/rand" - "os" - "testing" - - "github.com/stretchr/testify/require" - - "github.com/cosmos/cosmos-sdk/baseapp" - "github.com/cosmos/cosmos-sdk/simapp" - "github.com/cosmos/cosmos-sdk/simapp/params" - "github.com/cosmos/cosmos-sdk/store" - sdk "github.com/cosmos/cosmos-sdk/types" - authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" - banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" - capabilitytypes "github.com/cosmos/cosmos-sdk/x/capability/types" - distrtypes "github.com/cosmos/cosmos-sdk/x/distribution/types" - evidencetypes "github.com/cosmos/cosmos-sdk/x/evidence/types" - govtypes "github.com/cosmos/cosmos-sdk/x/gov/types" - minttypes "github.com/cosmos/cosmos-sdk/x/mint/types" - paramtypes "github.com/cosmos/cosmos-sdk/x/params/types" - "github.com/cosmos/cosmos-sdk/x/simulation" - slashingtypes "github.com/cosmos/cosmos-sdk/x/slashing/types" - stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" - ibctransfertypes "github.com/cosmos/ibc-go/v3/modules/apps/transfer/types" - ibchost "github.com/cosmos/ibc-go/v3/modules/core/24-host" - abci "github.com/tendermint/tendermint/abci/types" - "github.com/tendermint/tendermint/libs/log" - tmproto "github.com/tendermint/tendermint/proto/tendermint/types" - dbm "github.com/tendermint/tm-db" - evmenc "github.com/tharsis/ethermint/encoding" -) - -// MakeEncodingConfig creates the EncodingConfig -func MakeEncodingConfig() params.EncodingConfig { - return evmenc.MakeConfig(ModuleBasics) -} - -func init() { - simapp.GetSimulatorFlags() -} - -const SimAppChainID = "simulation_777-1" - -type storeKeysPrefixes struct { - A sdk.StoreKey - B sdk.StoreKey - Prefixes [][]byte -} - -// fauxMerkleModeOpt returns a BaseApp option to use a dbStoreAdapter instead of -// an IAVLStore for faster simulation speed. -func fauxMerkleModeOpt(bapp *baseapp.BaseApp) { - bapp.SetFauxMerkleMode() -} - -// interBlockCacheOpt returns a BaseApp option function that sets the persistent -// inter-block write-through cache. -func interBlockCacheOpt() func(*baseapp.BaseApp) { - return baseapp.SetInterBlockCache(store.NewCommitKVStoreCacheManager()) -} - -func TestFullAppSimulation(t *testing.T) { - config, db, dir, logger, skip, err := simapp.SetupSimulation("leveldb-app-sim", "Simulation") - if skip { - t.Skip("skipping application simulation") - } - require.NoError(t, err, "simulation setup failed") - - config.ChainID = SimAppChainID - - defer func() { - db.Close() - require.NoError(t, os.RemoveAll(dir)) - }() - - app := NewEthermintApp(logger, db, nil, true, map[int64]bool{}, DefaultNodeHome, simapp.FlagPeriodValue, MakeEncodingConfig(), simapp.EmptyAppOptions{}, fauxMerkleModeOpt) - require.Equal(t, appName, app.Name()) - - // run randomized simulation - _, simParams, simErr := simulation.SimulateFromSeed( - t, - os.Stdout, - app.BaseApp, - StateFn(app.AppCodec(), app.SimulationManager()), - RandomAccounts, // Replace with own random account function if using keys other than secp256k1 - simapp.SimulationOperations(app, app.AppCodec(), config), - app.ModuleAccountAddrs(), - config, - app.AppCodec(), - ) - - // export state and simParams before the simulation error is checked - err = simapp.CheckExportSimulation(app, config, simParams) - require.NoError(t, err) - require.NoError(t, simErr) - - if config.Commit { - simapp.PrintStats(db) - } -} - -func TestAppImportExport(t *testing.T) { - config, db, dir, logger, skip, err := simapp.SetupSimulation("leveldb-app-sim", "Simulation") - if skip { - t.Skip("skipping application import/export simulation") - } - require.NoError(t, err, "simulation setup failed") - - config.ChainID = SimAppChainID - - defer func() { - db.Close() - require.NoError(t, os.RemoveAll(dir)) - }() - - app := NewEthermintApp(logger, db, nil, true, map[int64]bool{}, DefaultNodeHome, simapp.FlagPeriodValue, MakeEncodingConfig(), simapp.EmptyAppOptions{}, fauxMerkleModeOpt) - require.Equal(t, appName, app.Name()) - - // Run randomized simulation - _, simParams, simErr := simulation.SimulateFromSeed( - t, - os.Stdout, - app.BaseApp, - StateFn(app.AppCodec(), app.SimulationManager()), - RandomAccounts, // Replace with own random account function if using keys other than secp256k1 - simapp.SimulationOperations(app, app.AppCodec(), config), - app.ModuleAccountAddrs(), - config, - app.AppCodec(), - ) - - // export state and simParams before the simulation error is checked - err = simapp.CheckExportSimulation(app, config, simParams) - require.NoError(t, err) - require.NoError(t, simErr) - - if config.Commit { - simapp.PrintStats(db) - } - - fmt.Printf("exporting genesis...\n") - - exported, err := app.ExportAppStateAndValidators(false, []string{}) - require.NoError(t, err) - - fmt.Printf("importing genesis...\n") - - // nolint: dogsled - _, newDB, newDir, _, _, err := simapp.SetupSimulation("leveldb-app-sim-2", "Simulation-2") - require.NoError(t, err, "simulation setup failed") - - defer func() { - newDB.Close() - require.NoError(t, os.RemoveAll(newDir)) - }() - - newApp := NewEthermintApp(log.NewNopLogger(), newDB, nil, true, map[int64]bool{}, DefaultNodeHome, simapp.FlagPeriodValue, MakeEncodingConfig(), simapp.EmptyAppOptions{}, fauxMerkleModeOpt) - require.Equal(t, appName, newApp.Name()) - - var genesisState simapp.GenesisState - err = json.Unmarshal(exported.AppState, &genesisState) - require.NoError(t, err) - - ctxA := app.NewContext(true, tmproto.Header{Height: app.LastBlockHeight(), ChainID: SimAppChainID}) - ctxB := newApp.NewContext(true, tmproto.Header{Height: app.LastBlockHeight(), ChainID: SimAppChainID}) - newApp.mm.InitGenesis(ctxB, app.AppCodec(), genesisState) - newApp.StoreConsensusParams(ctxB, exported.ConsensusParams) - - fmt.Printf("comparing stores...\n") - - storeKeysPrefixes := []storeKeysPrefixes{ - {app.keys[authtypes.StoreKey], newApp.keys[authtypes.StoreKey], [][]byte{}}, - { - app.keys[stakingtypes.StoreKey], newApp.keys[stakingtypes.StoreKey], - [][]byte{ - stakingtypes.UnbondingQueueKey, stakingtypes.RedelegationQueueKey, stakingtypes.ValidatorQueueKey, - stakingtypes.HistoricalInfoKey, - }, - }, // ordering may change but it doesn't matter - {app.keys[slashingtypes.StoreKey], newApp.keys[slashingtypes.StoreKey], [][]byte{}}, - {app.keys[minttypes.StoreKey], newApp.keys[minttypes.StoreKey], [][]byte{}}, - {app.keys[distrtypes.StoreKey], newApp.keys[distrtypes.StoreKey], [][]byte{}}, - {app.keys[banktypes.StoreKey], newApp.keys[banktypes.StoreKey], [][]byte{banktypes.BalancesPrefix}}, - {app.keys[paramtypes.StoreKey], newApp.keys[paramtypes.StoreKey], [][]byte{}}, - {app.keys[govtypes.StoreKey], newApp.keys[govtypes.StoreKey], [][]byte{}}, - {app.keys[evidencetypes.StoreKey], newApp.keys[evidencetypes.StoreKey], [][]byte{}}, - {app.keys[capabilitytypes.StoreKey], newApp.keys[capabilitytypes.StoreKey], [][]byte{}}, - {app.keys[ibchost.StoreKey], newApp.keys[ibchost.StoreKey], [][]byte{}}, - {app.keys[ibctransfertypes.StoreKey], newApp.keys[ibctransfertypes.StoreKey], [][]byte{}}, - } - - for _, skp := range storeKeysPrefixes { - storeA := ctxA.KVStore(skp.A) - storeB := ctxB.KVStore(skp.B) - - failedKVAs, failedKVBs := sdk.DiffKVStores(storeA, storeB, skp.Prefixes) - require.Equal(t, len(failedKVAs), len(failedKVBs), "unequal sets of key-values to compare") - - fmt.Printf("compared %d different key/value pairs between %s and %s\n", len(failedKVAs), skp.A, skp.B) - require.Equal(t, len(failedKVAs), 0, simapp.GetSimulationLog(skp.A.Name(), app.SimulationManager().StoreDecoders, failedKVAs, failedKVBs)) - } -} - -func TestAppSimulationAfterImport(t *testing.T) { - config, db, dir, logger, skip, err := simapp.SetupSimulation("leveldb-app-sim", "Simulation") - if skip { - t.Skip("skipping application simulation after import") - } - require.NoError(t, err, "simulation setup failed") - - config.ChainID = SimAppChainID - - defer func() { - db.Close() - require.NoError(t, os.RemoveAll(dir)) - }() - - app := NewEthermintApp(logger, db, nil, true, map[int64]bool{}, DefaultNodeHome, simapp.FlagPeriodValue, MakeEncodingConfig(), simapp.EmptyAppOptions{}, fauxMerkleModeOpt) - require.Equal(t, appName, app.Name()) - - // Run randomized simulation - stopEarly, simParams, simErr := simulation.SimulateFromSeed( - t, - os.Stdout, - app.BaseApp, - StateFn(app.AppCodec(), app.SimulationManager()), - RandomAccounts, // Replace with own random account function if using keys other than secp256k1 - simapp.SimulationOperations(app, app.AppCodec(), config), - app.ModuleAccountAddrs(), - config, - app.AppCodec(), - ) - - // export state and simParams before the simulation error is checked - err = simapp.CheckExportSimulation(app, config, simParams) - require.NoError(t, err) - require.NoError(t, simErr) - - if config.Commit { - simapp.PrintStats(db) - } - - if stopEarly { - fmt.Println("can't export or import a zero-validator genesis, exiting test...") - return - } - - fmt.Printf("exporting genesis...\n") - - exported, err := app.ExportAppStateAndValidators(true, []string{}) - require.NoError(t, err) - - fmt.Printf("importing genesis...\n") - - _, newDB, newDir, _, _, err := simapp.SetupSimulation("leveldb-app-sim-2", "Simulation-2") - require.NoError(t, err, "simulation setup failed") - - defer func() { - newDB.Close() - require.NoError(t, os.RemoveAll(newDir)) - }() - - newApp := NewEthermintApp(log.NewNopLogger(), newDB, nil, true, map[int64]bool{}, DefaultNodeHome, simapp.FlagPeriodValue, MakeEncodingConfig(), simapp.EmptyAppOptions{}, fauxMerkleModeOpt) - require.Equal(t, appName, newApp.Name()) - - newApp.InitChain(abci.RequestInitChain{ - ChainId: SimAppChainID, - AppStateBytes: exported.AppState, - }) - - _, _, err = simulation.SimulateFromSeed( - t, - os.Stdout, - newApp.BaseApp, - StateFn(app.AppCodec(), app.SimulationManager()), - RandomAccounts, // Replace with own random account function if using keys other than secp256k1 - simapp.SimulationOperations(newApp, newApp.AppCodec(), config), - app.ModuleAccountAddrs(), - config, - app.AppCodec(), - ) - require.NoError(t, err) -} - -// TODO: Make another test for the fuzzer itself, which just has noOp txs -// and doesn't depend on the application. -func TestAppStateDeterminism(t *testing.T) { - if !simapp.FlagEnabledValue { - t.Skip("skipping application simulation") - } - - config := simapp.NewConfigFromFlags() - config.InitialBlockHeight = 1 - config.ExportParamsPath = "" - config.OnOperation = false - config.AllInvariants = false - config.ChainID = SimAppChainID - - numSeeds := 3 - numTimesToRunPerSeed := 5 - appHashList := make([]json.RawMessage, numTimesToRunPerSeed) - - for i := 0; i < numSeeds; i++ { - config.Seed = rand.Int63() - - for j := 0; j < numTimesToRunPerSeed; j++ { - var logger log.Logger - if simapp.FlagVerboseValue { - logger = log.TestingLogger() - } else { - logger = log.NewNopLogger() - } - - db := dbm.NewMemDB() - app := NewEthermintApp(logger, db, nil, true, map[int64]bool{}, DefaultNodeHome, simapp.FlagPeriodValue, MakeEncodingConfig(), simapp.EmptyAppOptions{}, interBlockCacheOpt()) - - fmt.Printf( - "running non-determinism simulation; seed %d: %d/%d, attempt: %d/%d\n", - config.Seed, i+1, numSeeds, j+1, numTimesToRunPerSeed, - ) - - _, _, err := simulation.SimulateFromSeed( - t, - os.Stdout, - app.BaseApp, - StateFn(app.AppCodec(), app.SimulationManager()), - RandomAccounts, // Replace with own random account function if using keys other than secp256k1 - simapp.SimulationOperations(app, app.AppCodec(), config), - app.ModuleAccountAddrs(), - config, - app.AppCodec(), - ) - require.NoError(t, err) - - if config.Commit { - simapp.PrintStats(db) - } - - appHash := app.LastCommitID().Hash - appHashList[j] = appHash - - if j != 0 { - require.Equal( - t, string(appHashList[0]), string(appHashList[j]), - "non-determinism in seed %d: %d/%d, attempt: %d/%d\n", config.Seed, i+1, numSeeds, j+1, numTimesToRunPerSeed, - ) - } - } - } -} diff --git a/app/utils.go b/app/utils.go index 95fb576fc9..9d8fa8b2fa 100644 --- a/app/utils.go +++ b/app/utils.go @@ -2,31 +2,15 @@ package app import ( "encoding/json" - "math/rand" "time" - "github.com/cosmos/cosmos-sdk/codec" - "github.com/cosmos/cosmos-sdk/crypto/keys/secp256k1" "github.com/cosmos/cosmos-sdk/simapp" - "github.com/cosmos/cosmos-sdk/types/module" - authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" - stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" - - "github.com/tharsis/ethermint/encoding" - ethermint "github.com/tharsis/ethermint/types" - evmtypes "github.com/tharsis/ethermint/x/evm/types" - - "github.com/cosmos/cosmos-sdk/crypto/keys/ed25519" - sdk "github.com/cosmos/cosmos-sdk/types" - simtypes "github.com/cosmos/cosmos-sdk/types/simulation" - "github.com/ethereum/go-ethereum/common" - "github.com/ethereum/go-ethereum/crypto" abci "github.com/tendermint/tendermint/abci/types" "github.com/tendermint/tendermint/libs/log" tmproto "github.com/tendermint/tendermint/proto/tendermint/types" tmtypes "github.com/tendermint/tendermint/types" dbm "github.com/tendermint/tm-db" - "github.com/tharsis/ethermint/crypto/ethsecp256k1" + "github.com/tharsis/ethermint/encoding" ) // DefaultConsensusParams defines the default Tendermint consensus params used in @@ -77,93 +61,3 @@ func Setup(isCheckTx bool, patchGenesis func(*EthermintApp, simapp.GenesisState) return app } - -// RandomGenesisAccounts is used by the auth module to create random genesis accounts in simulation when a genesis.json is not specified. -// In contrast, the default auth module's RandomGenesisAccounts implementation creates only base accounts and vestings accounts. -func RandomGenesisAccounts(simState *module.SimulationState) authtypes.GenesisAccounts { - emptyCodeHash := crypto.Keccak256(nil) - genesisAccs := make(authtypes.GenesisAccounts, len(simState.Accounts)) - for i, acc := range simState.Accounts { - bacc := authtypes.NewBaseAccountWithAddress(acc.Address) - - ethacc := ðermint.EthAccount{ - BaseAccount: bacc, - CodeHash: common.BytesToHash(emptyCodeHash).String(), - } - genesisAccs[i] = ethacc - } - - return genesisAccs -} - -// RandomAccounts creates random accounts with an ethsecp256k1 private key -// TODO: replace secp256k1.GenPrivKeyFromSecret() with similar function in go-ethereum -func RandomAccounts(r *rand.Rand, n int) []simtypes.Account { - accs := make([]simtypes.Account, n) - - for i := 0; i < n; i++ { - // don't need that much entropy for simulation - privkeySeed := make([]byte, 15) - _, _ = r.Read(privkeySeed) - - prv := secp256k1.GenPrivKeyFromSecret(privkeySeed) - ethPrv := ðsecp256k1.PrivKey{} - _ = ethPrv.UnmarshalAmino(prv.Bytes()) // UnmarshalAmino simply copies the bytes and assigns them to ethPrv.Key - accs[i].PrivKey = ethPrv - accs[i].PubKey = accs[i].PrivKey.PubKey() - accs[i].Address = sdk.AccAddress(accs[i].PubKey.Address()) - - accs[i].ConsKey = ed25519.GenPrivKeyFromSecret(privkeySeed) - } - - return accs -} - -// StateFn returns the initial application state using a genesis or the simulation parameters. -// It is a wrapper of simapp.AppStateFn to replace evm param EvmDenom with staking param BondDenom. -func StateFn(cdc codec.JSONCodec, simManager *module.SimulationManager) simtypes.AppStateFn { - return func(r *rand.Rand, accs []simtypes.Account, config simtypes.Config, - ) (appState json.RawMessage, simAccs []simtypes.Account, chainID string, genesisTimestamp time.Time) { - appStateFn := simapp.AppStateFn(cdc, simManager) - appState, simAccs, chainID, genesisTimestamp = appStateFn(r, accs, config) - - rawState := make(map[string]json.RawMessage) - err := json.Unmarshal(appState, &rawState) - if err != nil { - panic(err) - } - - stakingStateBz, ok := rawState[stakingtypes.ModuleName] - if !ok { - panic("staking genesis state is missing") - } - - stakingState := new(stakingtypes.GenesisState) - cdc.MustUnmarshalJSON(stakingStateBz, stakingState) - - // we should get the BondDenom and make it the evmdenom. - // thus simulation accounts could have positive amount of gas token. - bondDenom := stakingState.Params.BondDenom - - evmStateBz, ok := rawState[evmtypes.ModuleName] - if !ok { - panic("staking genesis state is missing") - } - - evmState := new(evmtypes.GenesisState) - cdc.MustUnmarshalJSON(evmStateBz, evmState) - - // we should replace the EvmDenom with BondDenom - evmState.Params.EvmDenom = bondDenom - - // change appState back - rawState[evmtypes.ModuleName] = cdc.MustMarshalJSON(evmState) - - // replace appstate - appState, err = json.Marshal(rawState) - if err != nil { - panic(err) - } - return appState, simAccs, chainID, genesisTimestamp - } -} diff --git a/app/utils_test.go b/app/utils_test.go deleted file mode 100644 index 6029e059af..0000000000 --- a/app/utils_test.go +++ /dev/null @@ -1,111 +0,0 @@ -package app - -import ( - "encoding/json" - "math/rand" - "os" - "testing" - - "github.com/stretchr/testify/require" - - "github.com/cosmos/cosmos-sdk/types/module" - "github.com/cosmos/cosmos-sdk/x/auth" - authkeeper "github.com/cosmos/cosmos-sdk/x/auth/keeper" - authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" - paramstypes "github.com/cosmos/cosmos-sdk/x/params/types" - stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" - evmtypes "github.com/tharsis/ethermint/x/evm/types" - - "github.com/tharsis/ethermint/crypto/ethsecp256k1" - ethermint "github.com/tharsis/ethermint/types" - - "github.com/cosmos/cosmos-sdk/simapp" - sdk "github.com/cosmos/cosmos-sdk/types" -) - -var maxTestingAccounts = 100 -var seed = int64(233) - -func TestRandomGenesisAccounts(t *testing.T) { - r := rand.New(rand.NewSource(seed)) - accs := RandomAccounts(r, rand.Intn(maxTestingAccounts)) - - encodingConfig := MakeEncodingConfig() - appCodec := encodingConfig.Marshaler - cdc := encodingConfig.Amino - - paramsKeeper := initParamsKeeper(appCodec, cdc, sdk.NewKVStoreKey(paramstypes.StoreKey), sdk.NewTransientStoreKey(paramstypes.StoreKey)) - subSpace, find := paramsKeeper.GetSubspace(authtypes.ModuleName) - require.True(t, find) - accountKeeper := authkeeper.NewAccountKeeper( - appCodec, sdk.NewKVStoreKey(authtypes.StoreKey), subSpace, ethermint.ProtoAccount, maccPerms, - ) - authModule := auth.NewAppModule(appCodec, accountKeeper, RandomGenesisAccounts) - - genesisState := simapp.NewDefaultGenesisState(appCodec) - simState := &module.SimulationState{Accounts: accs, Cdc: appCodec, Rand: r, GenState: genesisState} - authModule.GenerateGenesisState(simState) - - authStateBz, find := genesisState[authtypes.ModuleName] - require.True(t, find) - - authState := new(authtypes.GenesisState) - appCodec.MustUnmarshalJSON(authStateBz, authState) - accounts, err := authtypes.UnpackAccounts(authState.Accounts) - require.NoError(t, err) - for _, acc := range accounts { - _, ok := acc.(ethermint.EthAccountI) - require.True(t, ok) - } -} - -func TestStateFn(t *testing.T) { - config, db, dir, logger, skip, err := simapp.SetupSimulation("leveldb-app-sim", "Simulation") - if skip { - t.Skip("skipping AppStateFn testing") - } - require.NoError(t, err, "simulation setup failed") - - config.ChainID = SimAppChainID - config.Commit = true - - defer func() { - db.Close() - require.NoError(t, os.RemoveAll(dir)) - }() - - app := NewEthermintApp(logger, db, nil, true, map[int64]bool{}, DefaultNodeHome, simapp.FlagPeriodValue, MakeEncodingConfig(), simapp.EmptyAppOptions{}, fauxMerkleModeOpt) - require.Equal(t, appName, app.Name()) - - appStateFn := StateFn(app.AppCodec(), app.SimulationManager()) - r := rand.New(rand.NewSource(seed)) - accounts := RandomAccounts(r, rand.Intn(maxTestingAccounts)) - appState, _, _, _ := appStateFn(r, accounts, config) - - rawState := make(map[string]json.RawMessage) - err = json.Unmarshal(appState, &rawState) - require.NoError(t, err) - - stakingStateBz, ok := rawState[stakingtypes.ModuleName] - require.True(t, ok) - - stakingState := new(stakingtypes.GenesisState) - app.AppCodec().MustUnmarshalJSON(stakingStateBz, stakingState) - bondDenom := stakingState.Params.BondDenom - - evmStateBz, ok := rawState[evmtypes.ModuleName] - require.True(t, ok) - - evmState := new(evmtypes.GenesisState) - app.AppCodec().MustUnmarshalJSON(evmStateBz, evmState) - require.Equal(t, bondDenom, evmState.Params.EvmDenom) -} - -func TestRandomAccounts(t *testing.T) { - r := rand.New(rand.NewSource(seed)) - accounts := RandomAccounts(r, rand.Intn(maxTestingAccounts)) - for _, acc := range accounts { - _, ok := acc.PrivKey.(*ethsecp256k1.PrivKey) - require.True(t, ok) - } -} diff --git a/x/evm/module.go b/x/evm/module.go index 1335b263fc..b9b92c0b9c 100644 --- a/x/evm/module.go +++ b/x/evm/module.go @@ -21,7 +21,6 @@ import ( "github.com/tharsis/ethermint/x/evm/client/cli" "github.com/tharsis/ethermint/x/evm/keeper" - "github.com/tharsis/ethermint/x/evm/simulation" "github.com/tharsis/ethermint/x/evm/types" ) @@ -170,12 +169,11 @@ func (am AppModule) ExportGenesis(ctx sdk.Context, cdc codec.JSONCodec) json.Raw // RandomizedParams creates randomized evm param changes for the simulator. func (AppModule) RandomizedParams(r *rand.Rand) []simtypes.ParamChange { - return simulation.ParamChanges(r) + return nil } // RegisterStoreDecoder registers a decoder for evm module's types func (am AppModule) RegisterStoreDecoder(sdr sdk.StoreDecoderRegistry) { - sdr[types.StoreKey] = simulation.NewDecodeStore() } // ProposalContents doesn't return any content functions for governance proposals. @@ -184,13 +182,9 @@ func (AppModule) ProposalContents(simState module.SimulationState) []simtypes.We } // GenerateGenesisState creates a randomized GenState of the evm module. -func (AppModule) GenerateGenesisState(simState *module.SimulationState) { - simulation.RandomizedGenState(simState) -} +func (AppModule) GenerateGenesisState(simState *module.SimulationState) {} // WeightedOperations returns the all the evm module operations with their respective weights. func (am AppModule) WeightedOperations(simState module.SimulationState) []simtypes.WeightedOperation { - return simulation.WeightedOperations( - simState.AppParams, simState.Cdc, am.ak, am.keeper, - ) + return nil } diff --git a/x/evm/simulation/decoder.go b/x/evm/simulation/decoder.go deleted file mode 100644 index 5f646851b0..0000000000 --- a/x/evm/simulation/decoder.go +++ /dev/null @@ -1,31 +0,0 @@ -package simulation - -import ( - "bytes" - "fmt" - - "github.com/cosmos/cosmos-sdk/types/kv" - "github.com/ethereum/go-ethereum/common" - "github.com/tharsis/ethermint/x/evm/types" -) - -// NewDecodeStore returns a decoder function closure that unmarshals the KVPair's -// value to the corresponding EVM type. -func NewDecodeStore() func(kvA, kvB kv.Pair) string { - return func(kvA, kvB kv.Pair) string { - switch { - case bytes.Equal(kvA.Key[:1], types.KeyPrefixStorage): - storageA := common.BytesToHash(kvA.Value).Hex() - storageB := common.BytesToHash(kvB.Value).Hex() - - return fmt.Sprintf("%v\n%v", storageA, storageB) - case bytes.Equal(kvA.Key[:1], types.KeyPrefixCode): - codeHashA := common.Bytes2Hex(kvA.Value) - codeHashB := common.Bytes2Hex(kvB.Value) - - return fmt.Sprintf("%v\n%v", codeHashA, codeHashB) - default: - panic(fmt.Sprintf("invalid evm key prefix %X", kvA.Key[:1])) - } - } -} diff --git a/x/evm/simulation/decoder_test.go b/x/evm/simulation/decoder_test.go deleted file mode 100644 index 2dbd85c66b..0000000000 --- a/x/evm/simulation/decoder_test.go +++ /dev/null @@ -1,47 +0,0 @@ -package simulation - -import ( - "fmt" - "testing" - - "github.com/stretchr/testify/require" - - "github.com/cosmos/cosmos-sdk/types/kv" - "github.com/ethereum/go-ethereum/common" - "github.com/tharsis/ethermint/x/evm/types" -) - -// TestDecodeStore tests that evm simulation decoder decodes the key value pairs as expected. -func TestDecodeStore(t *testing.T) { - dec := NewDecodeStore() - - hash := common.BytesToHash([]byte("hash")) - code := common.Bytes2Hex([]byte{1, 2, 3}) - - kvPairs := kv.Pairs{ - Pairs: []kv.Pair{ - {Key: types.KeyPrefixCode, Value: common.FromHex(code)}, - {Key: types.KeyPrefixStorage, Value: hash.Bytes()}, - }, - } - - tests := []struct { - name string - expectedLog string - }{ - {"Code", fmt.Sprintf("%v\n%v", code, code)}, - {"Storage", fmt.Sprintf("%v\n%v", hash, hash)}, - {"other", ""}, - } - for i, tt := range tests { - i, tt := i, tt - t.Run(tt.name, func(t *testing.T) { - switch i { - case len(tests) - 1: - require.Panics(t, func() { dec(kvPairs.Pairs[i], kvPairs.Pairs[i]) }, tt.name) - default: - require.Equal(t, tt.expectedLog, dec(kvPairs.Pairs[i], kvPairs.Pairs[i]), tt.name) - } - }) - } -} diff --git a/x/evm/simulation/genesis.go b/x/evm/simulation/genesis.go deleted file mode 100644 index 73110b89d7..0000000000 --- a/x/evm/simulation/genesis.go +++ /dev/null @@ -1,61 +0,0 @@ -package simulation - -import ( - "encoding/json" - "fmt" - "math/rand" - - "github.com/cosmos/cosmos-sdk/types/module" - - "github.com/tharsis/ethermint/x/evm/types" -) - -const ( - extraEIPsKey = "extra_eips" -) - -// GenExtraEIPs defines a set of extra EIPs with 50% probability -func GenExtraEIPs(r *rand.Rand) []int64 { - var extraEIPs []int64 - // 50% chance of having extra EIPs - if r.Intn(2) == 0 { - extraEIPs = []int64{1344, 1884, 2200, 2929, 3198, 3529} - } - return extraEIPs -} - -// GenEnableCreate enables the EnableCreate param with 80% probability -func GenEnableCreate(r *rand.Rand) bool { - // 80% chance of enabling create contract - enableCreate := r.Intn(100) < 80 - return enableCreate -} - -// GenEnableCall enables the EnableCall param with 80% probability -func GenEnableCall(r *rand.Rand) bool { - // 80% chance of enabling evm account transfer and calling contract - enableCall := r.Intn(100) < 80 - return enableCall -} - -// RandomizedGenState generates a random GenesisState for the EVM module -func RandomizedGenState(simState *module.SimulationState) { - // evm params - var extraEIPs []int64 - - simState.AppParams.GetOrGenerate( - simState.Cdc, extraEIPsKey, &extraEIPs, simState.Rand, - func(r *rand.Rand) { extraEIPs = GenExtraEIPs(r) }, - ) - - params := types.NewParams(types.DefaultEVMDenom, true, true, types.DefaultChainConfig(), extraEIPs...) - evmGenesis := types.NewGenesisState(params, []types.GenesisAccount{}) - - bz, err := json.MarshalIndent(evmGenesis, "", " ") - if err != nil { - panic(err) - } - fmt.Printf("Selected randomly generated %s parameters:\n%s\n", types.ModuleName, bz) - - simState.GenState[types.ModuleName] = simState.Cdc.MustMarshalJSON(evmGenesis) -} diff --git a/x/evm/simulation/genesis_test.go b/x/evm/simulation/genesis_test.go deleted file mode 100644 index b45e35396d..0000000000 --- a/x/evm/simulation/genesis_test.go +++ /dev/null @@ -1,50 +0,0 @@ -package simulation_test - -import ( - "encoding/json" - "math/rand" - "testing" - - "github.com/stretchr/testify/require" - - "github.com/cosmos/cosmos-sdk/codec" - codectypes "github.com/cosmos/cosmos-sdk/codec/types" - "github.com/cosmos/cosmos-sdk/types/module" - simtypes "github.com/cosmos/cosmos-sdk/types/simulation" - "github.com/tharsis/ethermint/x/evm/simulation" - "github.com/tharsis/ethermint/x/evm/types" -) - -// TestRandomizedGenState tests the normal scenario of applying RandomizedGenState. -// Abonormal scenarios are not tested here. -func TestRandomizedGenState(t *testing.T) { - registry := codectypes.NewInterfaceRegistry() - types.RegisterInterfaces(registry) - cdc := codec.NewProtoCodec(registry) - - s := rand.NewSource(1) - r := rand.New(s) - - simState := module.SimulationState{ - AppParams: make(simtypes.AppParams), - Cdc: cdc, - Rand: r, - NumBonded: 3, - Accounts: simtypes.RandomAccounts(r, 3), - InitialStake: 1000, - GenState: make(map[string]json.RawMessage), - } - - simulation.RandomizedGenState(&simState) - - var evmGenesis types.GenesisState - simState.Cdc.MustUnmarshalJSON(simState.GenState[types.ModuleName], &evmGenesis) - - require.Equal(t, true, evmGenesis.Params.GetEnableCreate()) - require.Equal(t, true, evmGenesis.Params.GetEnableCall()) - require.Equal(t, types.DefaultEVMDenom, evmGenesis.Params.GetEvmDenom()) - require.Equal(t, simulation.GenExtraEIPs(r), evmGenesis.Params.GetExtraEIPs()) - require.Equal(t, types.DefaultChainConfig(), evmGenesis.Params.GetChainConfig()) - - require.Equal(t, len(evmGenesis.Accounts), 0) -} diff --git a/x/evm/simulation/operations.go b/x/evm/simulation/operations.go deleted file mode 100644 index d0ad101c70..0000000000 --- a/x/evm/simulation/operations.go +++ /dev/null @@ -1,300 +0,0 @@ -package simulation - -import ( - "encoding/json" - "fmt" - "math/big" - "math/rand" - "time" - - "github.com/cosmos/cosmos-sdk/baseapp" - "github.com/cosmos/cosmos-sdk/codec" - codectypes "github.com/cosmos/cosmos-sdk/codec/types" - sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/cosmos/cosmos-sdk/types/module" - simtypes "github.com/cosmos/cosmos-sdk/types/simulation" - sdktx "github.com/cosmos/cosmos-sdk/types/tx" - "github.com/cosmos/cosmos-sdk/x/auth/tx" - "github.com/cosmos/cosmos-sdk/x/simulation" - "github.com/ethereum/go-ethereum/common" - "github.com/ethereum/go-ethereum/common/hexutil" - ethtypes "github.com/ethereum/go-ethereum/core/types" - - "github.com/cosmos/cosmos-sdk/client" - cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types" - "github.com/cosmos/cosmos-sdk/x/auth/signing" - "github.com/ethereum/go-ethereum/crypto" - "github.com/tharsis/ethermint/encoding" - "github.com/tharsis/ethermint/tests" - "github.com/tharsis/ethermint/x/evm/keeper" - "github.com/tharsis/ethermint/x/evm/types" -) - -const ( - /* #nosec */ - OpWeightMsgEthSimpleTransfer = "op_weight_msg_eth_simple_transfer" - /* #nosec */ - OpWeightMsgEthCreateContract = "op_weight_msg_eth_create_contract" - /* #nosec */ - OpWeightMsgEthCallContract = "op_weight_msg_eth_call_contract" -) - -const ( - WeightMsgEthSimpleTransfer = 50 - WeightMsgEthCreateContract = 50 -) - -var ErrNoEnoughBalance = fmt.Errorf("no enough balance") - -var maxWaitSeconds = 10 - -type simulateContext struct { - context sdk.Context - bapp *baseapp.BaseApp - rand *rand.Rand - keeper *keeper.Keeper -} - -// WeightedOperations generate Two kinds of operations: SimulateEthSimpleTransfer, SimulateEthCreateContract. -// Contract call operations work as the future operations of SimulateEthCreateContract. -func WeightedOperations( - appParams simtypes.AppParams, cdc codec.JSONCodec, ak types.AccountKeeper, k *keeper.Keeper, -) simulation.WeightedOperations { - var ( - weightMsgEthSimpleTransfer int - weightMsgEthCreateContract int - ) - - appParams.GetOrGenerate(cdc, OpWeightMsgEthSimpleTransfer, &weightMsgEthSimpleTransfer, nil, - func(_ *rand.Rand) { - weightMsgEthSimpleTransfer = WeightMsgEthSimpleTransfer - }, - ) - - appParams.GetOrGenerate(cdc, OpWeightMsgEthCreateContract, &weightMsgEthCreateContract, nil, - func(_ *rand.Rand) { - weightMsgEthCreateContract = WeightMsgEthCreateContract - }, - ) - - return simulation.WeightedOperations{ - simulation.NewWeightedOperation( - weightMsgEthSimpleTransfer, - SimulateEthSimpleTransfer(ak, k), - ), - simulation.NewWeightedOperation( - weightMsgEthCreateContract, - SimulateEthCreateContract(ak, k), - ), - } -} - -// SimulateEthSimpleTransfer simulate simple eth account transferring gas token. -// It randomly choose sender, recipient and transferable amount. -// Other tx details like nonce, gasprice, gaslimit are calculated to get valid value. -func SimulateEthSimpleTransfer(ak types.AccountKeeper, k *keeper.Keeper) simtypes.Operation { - return func( - r *rand.Rand, bapp *baseapp.BaseApp, ctx sdk.Context, accs []simtypes.Account, chainID string, - ) (simtypes.OperationMsg, []simtypes.FutureOperation, error) { - simAccount, _ := simtypes.RandomAcc(r, accs) - var recipient simtypes.Account - if r.Intn(2) == 1 { - recipient, _ = simtypes.RandomAcc(r, accs) - } else { - recipient = simtypes.RandomAccounts(r, 1)[0] - } - from := common.BytesToAddress(simAccount.Address) - to := common.BytesToAddress(recipient.Address) - - simulateContext := &simulateContext{ctx, bapp, r, k} - - return SimulateEthTx(simulateContext, &from, &to, nil, (*hexutil.Bytes)(&[]byte{}), simAccount.PrivKey, nil) - } -} - -// SimulateEthCreateContract simulate create an ERC20 contract. -// It makes operationSimulateEthCallContract the future operations of SimulateEthCreateContract to ensure valid contract call. -func SimulateEthCreateContract(ak types.AccountKeeper, k *keeper.Keeper) simtypes.Operation { - return func( - r *rand.Rand, bapp *baseapp.BaseApp, ctx sdk.Context, accs []simtypes.Account, chainID string, - ) (simtypes.OperationMsg, []simtypes.FutureOperation, error) { - simAccount, _ := simtypes.RandomAcc(r, accs) - - from := common.BytesToAddress(simAccount.Address) - nonce := k.GetNonce(ctx, from) - - ctorArgs, err := types.ERC20Contract.ABI.Pack("", from, sdk.NewIntWithDecimal(1000, 18).BigInt()) - if err != nil { - return simtypes.NoOpMsg(types.ModuleName, types.TypeMsgEthereumTx, "can not pack owner and supply"), nil, err - } - data := types.ERC20Contract.Bin - data = append(data, ctorArgs...) - - simulateContext := &simulateContext{ctx, bapp, r, k} - - fops := make([]simtypes.FutureOperation, 1) - whenCall := ctx.BlockHeader().Time.Add(time.Duration(r.Intn(maxWaitSeconds)+1) * time.Second) - contractAddr := crypto.CreateAddress(from, nonce) - var tokenReceipient simtypes.Account - if r.Intn(2) == 1 { - tokenReceipient, _ = simtypes.RandomAcc(r, accs) - } else { - tokenReceipient = simtypes.RandomAccounts(r, 1)[0] - } - receipientAddr := common.BytesToAddress(tokenReceipient.Address) - fops[0] = simtypes.FutureOperation{ - BlockTime: whenCall, - Op: operationSimulateEthCallContract(k, &contractAddr, &receipientAddr, nil), - } - return SimulateEthTx(simulateContext, &from, nil, nil, (*hexutil.Bytes)(&data), simAccount.PrivKey, fops) - } -} - -// operationSimulateEthCallContract simulate calling an contract. -// It is always calling an ERC20 contract. -func operationSimulateEthCallContract(k *keeper.Keeper, contractAddr, to *common.Address, amount *big.Int) simtypes.Operation { - return func( - r *rand.Rand, bapp *baseapp.BaseApp, ctx sdk.Context, accs []simtypes.Account, chainID string, - ) (simtypes.OperationMsg, []simtypes.FutureOperation, error) { - simAccount, _ := simtypes.RandomAcc(r, accs) - - from := common.BytesToAddress(simAccount.Address) - - ctorArgs, err := types.ERC20Contract.ABI.Pack("transfer", to, amount) - if err != nil { - return simtypes.NoOpMsg(types.ModuleName, types.TypeMsgEthereumTx, "can not pack method and args"), nil, err - } - data := types.ERC20Contract.Bin - data = append(data, ctorArgs...) - - simulateContext := &simulateContext{ctx, bapp, r, k} - - return SimulateEthTx(simulateContext, &from, contractAddr, nil, (*hexutil.Bytes)(&data), simAccount.PrivKey, nil) - } -} - -// SimulateEthTx creates valid ethereum tx and pack it as cosmos tx, and deliver it. -func SimulateEthTx( - ctx *simulateContext, from, to *common.Address, amount *big.Int, data *hexutil.Bytes, prv cryptotypes.PrivKey, fops []simtypes.FutureOperation, -) (simtypes.OperationMsg, []simtypes.FutureOperation, error) { - ethTx, err := CreateRandomValidEthTx(ctx, from, nil, nil, data) - if err == ErrNoEnoughBalance { - return simtypes.NoOpMsg(types.ModuleName, types.TypeMsgEthereumTx, "no enough balance"), nil, nil - } - if err != nil { - return simtypes.NoOpMsg(types.ModuleName, types.TypeMsgEthereumTx, "can not create valid eth tx"), nil, err - } - - txConfig := encoding.MakeConfig(module.NewBasicManager()).TxConfig - txBuilder := txConfig.NewTxBuilder() - signedTx, err := GetSignedTx(ctx, txBuilder, ethTx, prv) - if err != nil { - return simtypes.NoOpMsg(types.ModuleName, types.TypeMsgEthereumTx, "can not sign ethereum tx"), nil, err - } - - _, _, err = ctx.bapp.Deliver(txConfig.TxEncoder(), signedTx) - if err != nil { - return simtypes.NoOpMsg(types.ModuleName, types.TypeMsgEthereumTx, "failed to deliver tx"), nil, err - } - - return simtypes.OperationMsg{}, fops, nil -} - -// CreateRandomValidEthTx create the ethereum tx with valid random values -func CreateRandomValidEthTx(ctx *simulateContext, from, to *common.Address, amount *big.Int, data *hexutil.Bytes) (ethTx *types.MsgEthereumTx, err error) { - gasCap := ctx.rand.Uint64() - estimateGas, err := EstimateGas(ctx, from, to, data, gasCap) - if err != nil { - return nil, err - } - // we suppose that gasLimit should be larger than estimateGas to ensure tx validity - gasLimit := estimateGas + uint64(ctx.rand.Intn(int(sdktx.MaxGasWanted-estimateGas))) - ethChainID := ctx.keeper.ChainID() - chainConfig := ctx.keeper.GetParams(ctx.context).ChainConfig.EthereumConfig(ethChainID) - gasPrice := ctx.keeper.GetBaseFee(ctx.context, chainConfig) - gasFeeCap := new(big.Int).Add(gasPrice, big.NewInt(int64(ctx.rand.Int()))) - gasTipCap := big.NewInt(int64(ctx.rand.Int())) - nonce := ctx.keeper.GetNonce(ctx.context, *from) - - if amount == nil { - amount, err = RandomTransferableAmount(ctx, *from, estimateGas, gasFeeCap) - if err != nil { - return nil, err - } - } - - ethTx = types.NewTx(ethChainID, nonce, to, amount, gasLimit, gasPrice, gasFeeCap, gasTipCap, *data, nil) - ethTx.From = from.String() - return ethTx, nil -} - -// EstimateGas estimates the gas used by quering the keeper. -func EstimateGas(ctx *simulateContext, from, to *common.Address, data *hexutil.Bytes, gasCap uint64) (gas uint64, err error) { - args, err := json.Marshal(&types.TransactionArgs{To: to, From: from, Data: data}) - if err != nil { - return 0, err - } - - res, err := ctx.keeper.EstimateGas(sdk.WrapSDKContext(ctx.context), &types.EthCallRequest{ - Args: args, - GasCap: gasCap, - }) - if err != nil { - return 0, err - } - return res.Gas, nil -} - -// RandomTransferableAmount generates a random valid transferable amount. -// Transferable amount is between the range [0, spendable), spendable = balance - gasFeeCap * GasLimit. -func RandomTransferableAmount(ctx *simulateContext, address common.Address, estimateGas uint64, gasFeeCap *big.Int) (amount *big.Int, err error) { - balance := ctx.keeper.GetBalance(ctx.context, address) - feeLimit := new(big.Int).Mul(gasFeeCap, big.NewInt(int64(estimateGas))) - if (feeLimit.Cmp(balance)) > 0 { - return nil, ErrNoEnoughBalance - } - spendable := new(big.Int).Sub(balance, feeLimit) - if spendable.Cmp(big.NewInt(0)) == 0 { - amount = new(big.Int).Set(spendable) - return amount, nil - } - simAmount, err := simtypes.RandPositiveInt(ctx.rand, sdk.NewIntFromBigInt(spendable)) - if err != nil { - return nil, err - } - amount = simAmount.BigInt() - return amount, nil -} - -// GetSignedTx sign the ethereum tx and packs it as a signing.Tx . -func GetSignedTx(ctx *simulateContext, txBuilder client.TxBuilder, msg *types.MsgEthereumTx, prv cryptotypes.PrivKey) (signedTx signing.Tx, err error) { - builder, ok := txBuilder.(tx.ExtensionOptionsTxBuilder) - if !ok { - return nil, fmt.Errorf("can not initiate ExtensionOptionsTxBuilder") - } - option, err := codectypes.NewAnyWithValue(&types.ExtensionOptionsEthereumTx{}) - if err != nil { - return nil, err - } - builder.SetExtensionOptions(option) - - if err := msg.Sign(ethtypes.LatestSignerForChainID(ctx.keeper.ChainID()), tests.NewSigner(prv)); err != nil { - return nil, err - } - - if err = builder.SetMsgs(msg); err != nil { - return nil, err - } - - txData, err := types.UnpackTxData(msg.Data) - if err != nil { - return nil, err - } - - fees := sdk.NewCoins(sdk.NewCoin(ctx.keeper.GetParams(ctx.context).EvmDenom, sdk.NewIntFromBigInt(txData.Fee()))) - builder.SetFeeAmount(fees) - builder.SetGasLimit(msg.GetGas()) - - signedTx = builder.GetTx() - return signedTx, nil -} diff --git a/x/evm/simulation/params.go b/x/evm/simulation/params.go deleted file mode 100644 index e7b9914374..0000000000 --- a/x/evm/simulation/params.go +++ /dev/null @@ -1,41 +0,0 @@ -package simulation - -// DONTCOVER - -import ( - "fmt" - "math/rand" - - amino "github.com/cosmos/cosmos-sdk/codec" - simtypes "github.com/cosmos/cosmos-sdk/types/simulation" - "github.com/cosmos/cosmos-sdk/x/simulation" - "github.com/tharsis/ethermint/x/evm/types" -) - -// ParamChanges defines the parameters that can be modified by param change proposals -// on the simulation. -func ParamChanges(r *rand.Rand) []simtypes.ParamChange { - return []simtypes.ParamChange{ - simulation.NewSimParamChange(types.ModuleName, string(types.ParamStoreKeyExtraEIPs), - func(r *rand.Rand) string { - extraEIPs := GenExtraEIPs(r) - amino := amino.NewLegacyAmino() - bz, err := amino.MarshalJSON(extraEIPs) - if err != nil { - panic(err) - } - return string(bz) - }, - ), - simulation.NewSimParamChange(types.ModuleName, string(types.ParamStoreKeyEnableCreate), - func(r *rand.Rand) string { - return fmt.Sprintf("%v", GenEnableCreate(r)) - }, - ), - simulation.NewSimParamChange(types.ModuleName, string(types.ParamStoreKeyEnableCall), - func(r *rand.Rand) string { - return fmt.Sprintf("%v", GenEnableCall(r)) - }, - ), - } -} diff --git a/x/evm/simulation/params_test.go b/x/evm/simulation/params_test.go deleted file mode 100644 index a67d0c9d21..0000000000 --- a/x/evm/simulation/params_test.go +++ /dev/null @@ -1,44 +0,0 @@ -package simulation_test - -import ( - "encoding/json" - "fmt" - "math/rand" - "testing" - - "github.com/stretchr/testify/require" - - "github.com/tharsis/ethermint/x/evm/simulation" -) - -// TestParamChanges tests the paramChanges are generated as expected. -func TestParamChanges(t *testing.T) { - s := rand.NewSource(1) - r := rand.New(s) - - extraEIPs := simulation.GenExtraEIPs(r) - bz, err := json.Marshal(extraEIPs) - require.NoError(t, err) - - expected := []struct { - composedKey string - key string - simValue string - subspace string - }{ - {"evm/EnableExtraEIPs", "EnableExtraEIPs", string(bz), "evm"}, - {"evm/EnableCreate", "EnableCreate", fmt.Sprintf("%v", simulation.GenEnableCreate(r)), "evm"}, - {"evm/EnableCall", "EnableCall", fmt.Sprintf("%v", simulation.GenEnableCall(r)), "evm"}, - } - - paramChanges := simulation.ParamChanges(r) - - require.Len(t, paramChanges, 3) - - for i, p := range paramChanges { - require.Equal(t, expected[i].composedKey, p.ComposedKey()) - require.Equal(t, expected[i].key, p.Key()) - require.Equal(t, expected[i].simValue, p.SimValue()(r)) - require.Equal(t, expected[i].subspace, p.Subspace()) - } -} diff --git a/x/feemarket/module.go b/x/feemarket/module.go index 71e0c6d0d7..d5cee8e800 100644 --- a/x/feemarket/module.go +++ b/x/feemarket/module.go @@ -21,7 +21,6 @@ import ( "github.com/tharsis/ethermint/x/feemarket/client/cli" "github.com/tharsis/ethermint/x/feemarket/keeper" - "github.com/tharsis/ethermint/x/feemarket/simulation" "github.com/tharsis/ethermint/x/feemarket/types" ) @@ -182,7 +181,6 @@ func (AppModule) ProposalContents(simState module.SimulationState) []simtypes.We // GenerateGenesisState creates a randomized GenState of the fee market module. func (AppModule) GenerateGenesisState(simState *module.SimulationState) { - simulation.RandomizedGenState(simState) } // WeightedOperations returns the all the fee market module operations with their respective weights. diff --git a/x/feemarket/simulation/genesis.go b/x/feemarket/simulation/genesis.go deleted file mode 100644 index b5b5c0ec7f..0000000000 --- a/x/feemarket/simulation/genesis.go +++ /dev/null @@ -1,25 +0,0 @@ -package simulation - -import ( - "encoding/json" - "fmt" - - "github.com/cosmos/cosmos-sdk/types/module" - - "github.com/tharsis/ethermint/x/feemarket/types" -) - -// RandomizedGenState generates a random GenesisState for nft -func RandomizedGenState(simState *module.SimulationState) { - params := types.NewParams(simState.Rand.Uint32()%2 == 0, simState.Rand.Uint32(), simState.Rand.Uint32(), simState.Rand.Uint64(), simState.Rand.Int63()) - blockGas := simState.Rand.Uint64() - feemarketGenesis := types.NewGenesisState(params, blockGas) - - bz, err := json.MarshalIndent(feemarketGenesis, "", " ") - if err != nil { - panic(err) - } - fmt.Printf("Selected randomly generated %s parameters:\n%s\n", types.ModuleName, bz) - - simState.GenState[types.ModuleName] = simState.Cdc.MustMarshalJSON(feemarketGenesis) -} From b9ada2b1404636be69adea4d7b02768de491bc5f Mon Sep 17 00:00:00 2001 From: Vladislav Varadinov Date: Tue, 29 Nov 2022 10:23:31 +0200 Subject: [PATCH 04/11] (fix): removed tests from CI --- .github/workflows/test.yml | 81 -------------------------------------- 1 file changed, 81 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index d682346e3a..e8b5e56fd1 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -76,7 +76,6 @@ jobs: run: | make test-import if: env.GIT_DIFF - test-rpc: runs-on: ubuntu-latest timeout-minutes: 15 @@ -118,83 +117,3 @@ jobs: run: | make test-integration if: env.GIT_DIFF - - test-sim-nondeterminism: - runs-on: ubuntu-latest - timeout-minutes: 25 - steps: - - uses: actions/setup-go@v3 - with: - go-version: 1.17 - check-latest: true - - uses: actions/checkout@v3 - - uses: technote-space/get-diff-action@v6.0.1 - with: - PATTERNS: | - **/**.go - go.mod - go.sum - - name: Test simulation nondeterminism - run: | - make test-sim-nondeterminism - if: env.GIT_DIFF - - test-sim-random-genesis-fast: - runs-on: ubuntu-latest - timeout-minutes: 25 - steps: - - uses: actions/setup-go@v3 - with: - go-version: 1.17 - check-latest: true - - uses: actions/checkout@v3 - - uses: technote-space/get-diff-action@v6.0.1 - with: - PATTERNS: | - **/**.go - go.mod - go.sum - - name: Test simulation with random genesis - run: | - make test-sim-random-genesis-fast - if: env.GIT_DIFF - - test-sim-import-export: - runs-on: ubuntu-latest - timeout-minutes: 25 - steps: - - uses: actions/setup-go@v3 - with: - go-version: 1.17 - check-latest: true - - uses: actions/checkout@v3 - - uses: technote-space/get-diff-action@v6.0.1 - with: - PATTERNS: | - **/**.go - go.mod - go.sum - - name: Simulation of import and export genesis - run: | - make test-sim-import-export - if: env.GIT_DIFF - - test-sim-after-import: - runs-on: ubuntu-latest - timeout-minutes: 25 - steps: - - uses: actions/setup-go@v3 - with: - go-version: 1.17 - check-latest: true - - uses: actions/checkout@v3 - - uses: technote-space/get-diff-action@v6.0.1 - with: - PATTERNS: | - **/**.go - go.mod - go.sum - - name: Test simulation after import - run: | - make test-sim-after-import - if: env.GIT_DIFF \ No newline at end of file From e1bf308d2c3b73abec12fdacd6e4af95e769c3e5 Mon Sep 17 00:00:00 2001 From: Vladislav Varadinov Date: Tue, 29 Nov 2022 10:47:26 +0200 Subject: [PATCH 05/11] (fix): fix test.yml --- .github/workflows/test.yml | 79 ++++++++++++++++++++++---------------- 1 file changed, 46 insertions(+), 33 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index e8b5e56fd1..0124b0106d 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -15,34 +15,18 @@ jobs: GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}" if: "!startsWith(github.ref, 'refs/tags/') && github.ref != 'refs/heads/main'" - install-tparse: - runs-on: ubuntu-latest - steps: - - uses: actions/setup-go@v3 - with: - go-version: 1.17 - check-latest: true - - name: Display Go Version - run: go version - - name: Install tparse - run: | - export GO111MODULE="on" && go get github.com/mfridman/tparse@latest - - uses: actions/cache@v3 - with: - path: ~/go/bin - key: ${{ runner.os }}-go-tparse-binary - test-unit-cover: runs-on: ubuntu-latest steps: - uses: actions/setup-go@v3 with: - go-version: 1.17 + go-version: 1.19 check-latest: true - uses: actions/checkout@v3 - - uses: technote-space/get-diff-action@v6.0.1 + - uses: technote-space/get-diff-action@v6.1.1 with: PATTERNS: | + **/**.sol **/**.go go.mod go.sum @@ -62,10 +46,10 @@ jobs: steps: - uses: actions/setup-go@v3 with: - go-version: 1.17 + go-version: 1.19 check-latest: true - uses: actions/checkout@v3 - - uses: technote-space/get-diff-action@v6.0.1 + - uses: technote-space/get-diff-action@v6.1.1 id: git_diff with: PATTERNS: | @@ -76,16 +60,17 @@ jobs: run: | make test-import if: env.GIT_DIFF + test-rpc: runs-on: ubuntu-latest timeout-minutes: 15 steps: - uses: actions/setup-go@v3 with: - go-version: 1.17 + go-version: 1.19 check-latest: true - uses: actions/checkout@v3 - - uses: technote-space/get-diff-action@v6.0.1 + - uses: technote-space/get-diff-action@v6.1.1 with: PATTERNS: | **/**.sol @@ -97,23 +82,51 @@ jobs: make test-rpc if: env.GIT_DIFF - test-e2e: + integration_tests: runs-on: ubuntu-latest - timeout-minutes: 15 steps: - - uses: actions/setup-go@v3 + - uses: actions/checkout@v2 + - uses: cachix/install-nix-action@v18 + - uses: cachix/cachix-action@v12 with: - go-version: 1.17 - check-latest: true - - uses: actions/checkout@v3 - - uses: technote-space/get-diff-action@v6.0.1 + name: ethermint + signingKey: "${{ secrets.CACHIX_SIGNING_KEY }}" + - uses: technote-space/get-diff-action@v6.1.1 with: PATTERNS: | **/**.sol **/**.go go.mod go.sum - - name: Test e2e - run: | - make test-integration + tests/integration_tests/** + - name: Run integration tests + run: make run-integration-tests if: env.GIT_DIFF + - name: 'Tar debug files' + if: failure() + run: tar cfz debug_files.tar.gz -C /tmp/pytest-of-runner . + - uses: actions/upload-artifact@v3 + if: failure() + with: + name: debug-files + path: debug_files.tar.gz + if-no-files-found: ignore + + upload-cache: + if: github.event_name == 'push' + needs: ["integration_tests"] + strategy: + matrix: + os: [macos-latest] + runs-on: ${{ matrix.os }} + steps: + - uses: actions/checkout@v2 + - uses: cachix/install-nix-action@v18 + - uses: cachix/cachix-action@v12 + with: + name: ethermint + signingKey: "${{ secrets.CACHIX_SIGNING_KEY }}" + - name: 'instantiate integration test env' + run: nix-store -r $(nix-instantiate tests/integration_tests/shell.nix) + + From 9df4ea2d50c1914d64bf9c6bf3d0fb15c76c2b13 Mon Sep 17 00:00:00 2001 From: Vladislav Varadinov Date: Tue, 29 Nov 2022 10:53:20 +0200 Subject: [PATCH 06/11] (fix): format and lint --- app/ante/signverify_test.go | 1 - 1 file changed, 1 deletion(-) diff --git a/app/ante/signverify_test.go b/app/ante/signverify_test.go index 526c2867b3..6dd8b2dd2b 100644 --- a/app/ante/signverify_test.go +++ b/app/ante/signverify_test.go @@ -10,7 +10,6 @@ import ( evmtypes "github.com/evmos/ethermint/x/evm/types" ) - func (suite AnteTestSuite) TestEthSigVerificationDecorator() { addr, privKey := tests.NewAddrKey() From 0eee343c4c24909acce087127335f53f07bce39d Mon Sep 17 00:00:00 2001 From: Vladislav Varadinov Date: Tue, 29 Nov 2022 10:59:39 +0200 Subject: [PATCH 07/11] (fix): fix linter issue --- .github/workflows/test.yml | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 0124b0106d..29777f742a 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -114,10 +114,10 @@ jobs: upload-cache: if: github.event_name == 'push' - needs: ["integration_tests"] + needs: [ "integration_tests" ] strategy: matrix: - os: [macos-latest] + os: [ macos-latest ] runs-on: ${{ matrix.os }} steps: - uses: actions/checkout@v2 @@ -128,5 +128,3 @@ jobs: signingKey: "${{ secrets.CACHIX_SIGNING_KEY }}" - name: 'instantiate integration test env' run: nix-store -r $(nix-instantiate tests/integration_tests/shell.nix) - - From 44d43ce1fee4a5a3c40eac9c607cc2cc4c5a3117 Mon Sep 17 00:00:00 2001 From: Vladislav Varadinov Date: Tue, 29 Nov 2022 11:05:10 +0200 Subject: [PATCH 08/11] (fix): fix linter issues v2 --- .github/workflows/test.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 29777f742a..efbe0ccebe 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -114,10 +114,10 @@ jobs: upload-cache: if: github.event_name == 'push' - needs: [ "integration_tests" ] + needs: ["integration_tests"] strategy: matrix: - os: [ macos-latest ] + os: [macos-latest] runs-on: ${{ matrix.os }} steps: - uses: actions/checkout@v2 From a62b7e4acc53a73c02706a31cf42ed347da7d225 Mon Sep 17 00:00:00 2001 From: Vladislav Varadinov Date: Tue, 29 Nov 2022 11:19:32 +0200 Subject: [PATCH 09/11] (fix): linter --- .github/workflows/test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index efbe0ccebe..4510e5e5e2 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -127,4 +127,4 @@ jobs: name: ethermint signingKey: "${{ secrets.CACHIX_SIGNING_KEY }}" - name: 'instantiate integration test env' - run: nix-store -r $(nix-instantiate tests/integration_tests/shell.nix) + run: nix-store -r "$(nix-instantiate tests/integration_tests/shell.nix)" From c40dfe48829545e102ce20626aee7a59efb30ed6 Mon Sep 17 00:00:00 2001 From: Vladislav Varadinov Date: Tue, 29 Nov 2022 12:19:47 +0200 Subject: [PATCH 10/11] (fix): removed sim-test references --- Makefile | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/Makefile b/Makefile index 4904132906..2d698c74bc 100644 --- a/Makefile +++ b/Makefile @@ -344,16 +344,6 @@ test-solidity: .PHONY: run-tests test test-all test-import test-rpc test-contract test-solidity $(TEST_TARGETS) -.PHONY: \ -test-sim-nondeterminism \ -test-sim-custom-genesis-fast \ -test-sim-import-export \ -test-sim-after-import \ -test-sim-custom-genesis-multi-seed \ -test-sim-multi-seed-short \ -test-sim-multi-seed-long \ -test-sim-benchmark-invariants - benchmark: @go test -mod=readonly -bench=. $(PACKAGES_NOSIMULATION) .PHONY: benchmark From 76a5df7c066694175270a994f2f04d9528f2c293 Mon Sep 17 00:00:00 2001 From: Vladislav Varadinov Date: Tue, 29 Nov 2022 13:28:47 +0200 Subject: [PATCH 11/11] Applied changes from code review --- x/evm/module.go | 16 ++++++++-------- x/feemarket/module.go | 16 ++++++++-------- 2 files changed, 16 insertions(+), 16 deletions(-) diff --git a/x/evm/module.go b/x/evm/module.go index 6a15afba4d..43161fab9b 100644 --- a/x/evm/module.go +++ b/x/evm/module.go @@ -64,7 +64,7 @@ func (AppModuleBasic) ValidateGenesis(cdc codec.JSONCodec, _ client.TxEncodingCo // RegisterRESTRoutes performs a no-op as the EVM module doesn't expose REST // endpoints -func (AppModuleBasic) RegisterRESTRoutes(clientCtx client.Context, rtr *mux.Router) { +func (AppModuleBasic) RegisterRESTRoutes(_ client.Context, _ *mux.Router) { } func (b AppModuleBasic) RegisterGRPCGatewayRoutes(c client.Context, serveMux *runtime.ServeMux) { @@ -113,7 +113,7 @@ func (AppModule) Name() string { // RegisterInvariants interface for registering invariants. Performs a no-op // as the evm module doesn't expose invariants. -func (am AppModule) RegisterInvariants(ir sdk.InvariantRegistry) { +func (am AppModule) RegisterInvariants(_ sdk.InvariantRegistry) { } // RegisterServices registers a GRPC query service to respond to the @@ -133,7 +133,7 @@ func (AppModule) QuerierRoute() string { return types.RouterKey } // LegacyQuerierHandler returns nil as the evm module doesn't expose a legacy // Querier. -func (am AppModule) LegacyQuerierHandler(legacyQuerierCdc *codec.LegacyAmino) sdk.Querier { +func (am AppModule) LegacyQuerierHandler(_ *codec.LegacyAmino) sdk.Querier { return nil } @@ -166,24 +166,24 @@ func (am AppModule) ExportGenesis(ctx sdk.Context, cdc codec.JSONCodec) json.Raw } // RandomizedParams creates randomized evm param changes for the simulator. -func (AppModule) RandomizedParams(r *rand.Rand) []simtypes.ParamChange { +func (AppModule) RandomizedParams(_ *rand.Rand) []simtypes.ParamChange { return nil } // RegisterStoreDecoder registers a decoder for evm module's types -func (am AppModule) RegisterStoreDecoder(sdr sdk.StoreDecoderRegistry) { +func (am AppModule) RegisterStoreDecoder(_ sdk.StoreDecoderRegistry) { } // ProposalContents doesn't return any content functions for governance proposals. -func (AppModule) ProposalContents(simState module.SimulationState) []simtypes.WeightedProposalContent { +func (AppModule) ProposalContents(_ module.SimulationState) []simtypes.WeightedProposalContent { return nil } // GenerateGenesisState creates a randomized GenState of the evm module. -func (AppModule) GenerateGenesisState(simState *module.SimulationState) { +func (AppModule) GenerateGenesisState(_ *module.SimulationState) { } // WeightedOperations returns the all the evm module operations with their respective weights. -func (am AppModule) WeightedOperations(simState module.SimulationState) []simtypes.WeightedOperation { +func (am AppModule) WeightedOperations(_ module.SimulationState) []simtypes.WeightedOperation { return nil } diff --git a/x/feemarket/module.go b/x/feemarket/module.go index e99c7598e8..226584b9e2 100644 --- a/x/feemarket/module.go +++ b/x/feemarket/module.go @@ -64,7 +64,7 @@ func (AppModuleBasic) ValidateGenesis(cdc codec.JSONCodec, _ client.TxEncodingCo // RegisterRESTRoutes performs a no-op as the EVM module doesn't expose REST // endpoints -func (AppModuleBasic) RegisterRESTRoutes(clientCtx client.Context, rtr *mux.Router) { +func (AppModuleBasic) RegisterRESTRoutes(_ client.Context, _ *mux.Router) { } func (b AppModuleBasic) RegisterGRPCGatewayRoutes(c client.Context, serveMux *runtime.ServeMux) { @@ -109,7 +109,7 @@ func (AppModule) Name() string { // RegisterInvariants interface for registering invariants. Performs a no-op // as the fee market module doesn't expose invariants. -func (am AppModule) RegisterInvariants(ir sdk.InvariantRegistry) {} +func (am AppModule) RegisterInvariants(_ sdk.InvariantRegistry) {} // RegisterServices registers the GRPC query service and migrator service to respond to the // module-specific GRPC queries and handle the upgrade store migration for the module. @@ -127,7 +127,7 @@ func (AppModule) QuerierRoute() string { return types.RouterKey } // LegacyQuerierHandler returns nil as the fee market module doesn't expose a legacy // Querier. -func (am AppModule) LegacyQuerierHandler(legacyQuerierCdc *codec.LegacyAmino) sdk.Querier { +func (am AppModule) LegacyQuerierHandler(_ *codec.LegacyAmino) sdk.Querier { return nil } @@ -161,23 +161,23 @@ func (am AppModule) ExportGenesis(ctx sdk.Context, cdc codec.JSONCodec) json.Raw } // RandomizedParams creates randomized fee market param changes for the simulator. -func (AppModule) RandomizedParams(r *rand.Rand) []simtypes.ParamChange { +func (AppModule) RandomizedParams(_ *rand.Rand) []simtypes.ParamChange { return nil } // RegisterStoreDecoder registers a decoder for fee market module's types -func (am AppModule) RegisterStoreDecoder(sdr sdk.StoreDecoderRegistry) {} +func (am AppModule) RegisterStoreDecoder(_ sdk.StoreDecoderRegistry) {} // ProposalContents doesn't return any content functions for governance proposals. -func (AppModule) ProposalContents(simState module.SimulationState) []simtypes.WeightedProposalContent { +func (AppModule) ProposalContents(_ module.SimulationState) []simtypes.WeightedProposalContent { return nil } // GenerateGenesisState creates a randomized GenState of the fee market module. -func (AppModule) GenerateGenesisState(simState *module.SimulationState) { +func (AppModule) GenerateGenesisState(_ *module.SimulationState) { } // WeightedOperations returns the all the fee market module operations with their respective weights. -func (am AppModule) WeightedOperations(simState module.SimulationState) []simtypes.WeightedOperation { +func (am AppModule) WeightedOperations(_ module.SimulationState) []simtypes.WeightedOperation { return nil }