diff --git a/example_chain/eth_test_helpers.go b/example_chain/eth_test_helpers.go index 5673837..ca7b20b 100644 --- a/example_chain/eth_test_helpers.go +++ b/example_chain/eth_test_helpers.go @@ -48,7 +48,7 @@ var DefaultConsensusParams = &tmproto.ConsensusParams{ } // EthDefaultConsensusParams defines the default Tendermint consensus params used in -// EvmosApp testing. +// evmOS app testing. var EthDefaultConsensusParams = &cmtypes.ConsensusParams{ Block: cmtypes.BlockParams{ MaxBytes: 200000, @@ -66,7 +66,7 @@ var EthDefaultConsensusParams = &cmtypes.ConsensusParams{ }, } -// EthSetup initializes a new EvmosApp. A Nop logger is set in EvmosApp. +// EthSetup initializes a new evmOS application. A Nop logger is set in ExampleChain. func EthSetup(isCheckTx bool, patchGenesis func(*ExampleChain, simapp.GenesisState) simapp.GenesisState) *ExampleChain { return EthSetupWithDB(isCheckTx, patchGenesis, dbm.NewMemDB()) } diff --git a/example_chain/test_helpers.go b/example_chain/test_helpers.go index 0f645d3..28461ef 100644 --- a/example_chain/test_helpers.go +++ b/example_chain/test_helpers.go @@ -9,16 +9,14 @@ import ( "os" "testing" + "cosmossdk.io/math" dbm "github.com/cometbft/cometbft-db" abci "github.com/cometbft/cometbft/abci/types" tmjson "github.com/cometbft/cometbft/libs/json" "github.com/cometbft/cometbft/libs/log" tmproto "github.com/cometbft/cometbft/proto/tendermint/types" tmtypes "github.com/cometbft/cometbft/types" - "github.com/stretchr/testify/require" - - "cosmossdk.io/math" - + "github.com/cosmos/cosmos-sdk/baseapp" bam "github.com/cosmos/cosmos-sdk/baseapp" "github.com/cosmos/cosmos-sdk/client/flags" "github.com/cosmos/cosmos-sdk/crypto/keys/secp256k1" @@ -33,6 +31,8 @@ import ( authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" minttypes "github.com/cosmos/cosmos-sdk/x/mint/types" + ibctesting "github.com/cosmos/ibc-go/v7/testing" + "github.com/stretchr/testify/require" ) // SetupOptions defines arguments that are passed into `Simapp` constructor. @@ -249,3 +249,19 @@ func NewTestNetworkFixture() network.TestFixture { }, } } + +// SetupTestingApp initializes the IBC-go testing application +// need to keep this design to comply with the ibctesting SetupTestingApp func +// and be able to set the chainID for the tests properly +func SetupTestingApp(chainID string) func() (ibctesting.TestingApp, map[string]json.RawMessage) { + return func() (ibctesting.TestingApp, map[string]json.RawMessage) { + db := dbm.NewMemDB() + app := NewExampleApp( + log.NewNopLogger(), + db, nil, true, + simtestutil.NewAppOptionsWithFlagHome(DefaultNodeHome), + baseapp.SetChainID(chainID), + ) + return app, NewDefaultGenesisState() + } +} diff --git a/go.work.sum b/go.work.sum index 0a4a2c1..e289492 100644 --- a/go.work.sum +++ b/go.work.sum @@ -409,7 +409,12 @@ github.com/charithe/durationcheck v0.0.9 h1:mPP4ucLrf/rKZiIG/a9IPXHGlh8p4CzgpyTy github.com/charithe/durationcheck v0.0.9/go.mod h1:SSbRIBVfMjCi/kEB6K65XEA83D6prSM8ap1UCpNKtgg= github.com/chavacava/garif v0.0.0-20220630083739-93517212f375 h1:E7LT642ysztPWE0dfz43cWOvMiF42DyTRC+eZIaO4yI= github.com/chavacava/garif v0.0.0-20220630083739-93517212f375/go.mod h1:4m1Rv7xfuwWPNKXlThldNuJvutYM6J95wNuuVmn55To= +github.com/checkpoint-restore/go-criu/v5 v5.3.0/go.mod h1:E/eQpaFtUKGOOSEBZgmKAcn+zUUwWxqcaKZlF54wK8E= github.com/cheggaaa/pb v1.0.27 h1:wIkZHkNfC7R6GI5w7l/PdAdzXzlrbcI3p8OAlnkTsnc= +github.com/chromedp/cdproto v0.0.0-20230802225258-3cf4e6d46a89/go.mod h1:GKljq0VrfU4D5yc+2qA6OVr8pmO/MBbPEWqWQ/oqGEs= +github.com/chromedp/chromedp v0.9.2/go.mod h1:LkSXJKONWTCHAfQasKFUZI+mxqS4tZqhmtGzzhLsnLs= +github.com/chromedp/sysutil v1.0.0/go.mod h1:kgWmDdq8fTzXYcKIBqIYvRRTnYb9aNS9moAV0xufSww= +github.com/cilium/ebpf v0.7.0/go.mod h1:/oI2+1shJiTGAMgl6/RgJr36Eo1jzrRcAWbcXO2usCA= github.com/circonus-labs/circonus-gometrics v2.3.1+incompatible h1:C29Ae4G5GtYyYMm1aztcyj/J5ckgJm2zwdDajFbx1NY= github.com/circonus-labs/circonusllhist v0.1.3 h1:TJH+oke8D16535+jHExHj4nQvzlZrj7ug5D7I/orNUA= github.com/clbanning/mxj v1.8.4 h1:HuhwZtbyvyOw+3Z1AowPkU87JkJUSv751ELWaiTpj8I= @@ -428,6 +433,7 @@ github.com/codegangsta/inject v0.0.0-20150114235600-33e0aa1cb7c0 h1:sDMmm+q/3+Bu github.com/codegangsta/inject v0.0.0-20150114235600-33e0aa1cb7c0/go.mod h1:4Zcjuz89kmFXt9morQgcfYZAYZ5n8WHjt81YYWIwtTM= github.com/consensys/gnark-crypto v0.4.1-0.20210426202927-39ac3d4b3f1f h1:C43yEtQ6NIf4ftFXD/V55gnGFgPbMQobd//YlnLjUJ8= github.com/consensys/gnark-crypto v0.4.1-0.20210426202927-39ac3d4b3f1f/go.mod h1:815PAHg3wvysy0SyIqanF8gZ0Y1wjk/hrDHD/iT88+Q= +github.com/containerd/console v1.0.3/go.mod h1:7LqA/THxQ86k76b8c/EMSiaJ3h1eZkMkXar0TQ1gf3U= github.com/containerd/containerd v1.6.8 h1:h4dOFDwzHmqFEP754PgfgTeVXFnLiRc6kiqC7tplDJs= github.com/containerd/containerd v1.6.8/go.mod h1:By6p5KqPK0/7/CgO/A6t/Gz+CUYUu2zf1hUaaymVXB0= github.com/containerd/typeurl v1.0.2 h1:Chlt8zIieDbzQFzXzAeBEF92KhExuE4p9p92/QmY7aY= @@ -505,8 +511,6 @@ github.com/fzipp/gocyclo v0.6.0 h1:lsblElZG7d3ALtGMx9fmxeTKZaLLpU8mET09yN4BBLo= github.com/fzipp/gocyclo v0.6.0/go.mod h1:rXPyn8fnlpa0R2csP/31uerbiVBugk5whMdlyaLkLoA= github.com/garslo/gogen v0.0.0-20170306192744-1d203ffc1f61 h1:IZqZOB2fydHte3kUgxrzK5E1fW7RQGeDwE8F/ZZnUYc= github.com/garslo/gogen v0.0.0-20170306192744-1d203ffc1f61/go.mod h1:Q0X6pkwTILDlzrGEckF6HKjXe48EgsY/l7K7vhY4MW8= -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/ghemawat/stream v0.0.0-20171120220530-696b145b53b9 h1:r5GgOLGbza2wVHRzK7aAj6lWZjfbAwiu/RDCVOKjRyM= github.com/ghemawat/stream v0.0.0-20171120220530-696b145b53b9/go.mod h1:106OIgooyS7OzLDOpUGgm9fA3bQENb/cFSyyBmMoJDs= github.com/ghodss/yaml v1.0.0 h1:wQHKEahhL6wmXdzwWG11gIVCkOv05bNOh+Rxn0yngAk= @@ -545,6 +549,7 @@ github.com/go-zookeeper/zk v1.0.2/go.mod h1:nOB03cncLtlp4t+UAkGSV+9beXP/akpekBwL github.com/gobwas/glob v0.2.3 h1:A4xDbljILXROh+kObIiy5kIaPYD8e96x1tgBhUI5J+Y= github.com/gobwas/glob v0.2.3/go.mod h1:d3Ez4x06l9bZtSvzIay5+Yzi0fmZzPgnTbPcKjJAkT8= github.com/godbus/dbus/v5 v5.0.4 h1:9349emZab16e7zQvpmsbtjc18ykshndd8y2PG3sgJbA= +github.com/godbus/dbus/v5 v5.0.6/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA= github.com/gofrs/flock v0.8.1 h1:+gYjHKf32LDeiEEFhQaotPbLuUXjY5ZqxKgXy7n59aw= github.com/gofrs/flock v0.8.1/go.mod h1:F1TvTiK9OcQqauNUHlbJvyl9Qa1QvF/gOUDKA14jxHU= github.com/gofrs/uuid v4.3.0+incompatible h1:CaSVZxm5B+7o45rtab4jC2G37WGYX1zQfuU2i6DSvnc= @@ -631,6 +636,7 @@ github.com/hudl/fargo v1.4.0/go.mod h1:9Ai6uvFy5fQNq6VPKtg+Ceq1+eTY4nKUlR2JElEOc github.com/hydrogen18/memlistener v1.0.0 h1:JR7eDj8HD6eXrc5fWLbSUnfcQFL06PYvCc0DKQnWfaU= github.com/hydrogen18/memlistener v1.0.0/go.mod h1:qEIFzExnS6016fRpRfxrExeVn2gbClQA99gQhnIcdhE= github.com/ianlancetaylor/demangle v0.0.0-20200824232613-28f6c0f3b639 h1:mV02weKRL81bEnm8A0HT1/CAelMQDBuQIfLw8n+d6xI= +github.com/ianlancetaylor/demangle v0.0.0-20240312041847-bd984b5ce465/go.mod h1:gx7rwoVhcfuVKG5uya9Hs3Sxj7EIvldVofAWIUtGouw= github.com/imdario/mergo v0.3.13 h1:lFzP57bqS/wsqKssCGmtLAb8A0wKjLGrve2q3PPVcBk= github.com/imdario/mergo v0.3.13/go.mod h1:4lJ1jqUDcsbIECGy0RUJAXNIhg+6ocWgb1ALK2O4oXg= github.com/influxdata/influxdb v1.8.3 h1:WEypI1BQFTT4teLM+1qkEcvUi0dAvopAI/ir0vAiBg8= @@ -759,12 +765,14 @@ github.com/mitchellh/gox v0.4.0 h1:lfGJxY7ToLJQjHHwi0EX6uYBdK78egf954SQl13PQJc= github.com/mitchellh/iochan v1.0.0 h1:C+X3KsSTLFVBr/tK1eYN/vs4rJcvsiLU338UhYPJWeY= github.com/moby/buildkit v0.10.4 h1:FvC+buO8isGpUFZ1abdSLdGHZVqg9sqI4BbFL8tlzP4= github.com/moby/buildkit v0.10.4/go.mod h1:Yajz9vt1Zw5q9Pp4pdb3TCSUXJBIroIQGQ3TTs/sLug= +github.com/moby/sys/mountinfo v0.5.0/go.mod h1:3bMD3Rg+zkqx8MRYPi7Pyb0Ie97QEBmdxbhnCLlSvSU= github.com/moby/term v0.0.0-20221205130635-1aeaba878587 h1:HfkjXDfhgVaN5rmueG8cL8KKeFNecRCXFhaJ2qZ5SKA= github.com/moby/term v0.0.0-20221205130635-1aeaba878587/go.mod h1:8FzsFHVUBGZdbDsJw/ot+X+d5HLUbvklYLJ9uGfcI3Y= github.com/moricho/tparallel v0.2.1 h1:95FytivzT6rYzdJLdtfn6m1bfFJylOJK41+lgv/EHf4= github.com/moricho/tparallel v0.2.1/go.mod h1:fXEIZxG2vdfl0ZF8b42f5a78EhjjD5mX8qUplsoSU4k= github.com/morikuni/aec v1.0.0 h1:nP9CBfwrvYnBRgY6qfDQkygYDmYwOilePFkwzv4dU8A= github.com/morikuni/aec v1.0.0/go.mod h1:BbKIizmSmc5MMPqRYbxO4ZU0S0+P200+tUnFx7PXmsc= +github.com/mrunalp/fileutils v0.5.1/go.mod h1:M1WthSahJixYnrXQl/DFQuteStB1weuxD2QJNHXfbSQ= github.com/mschoch/smat v0.2.0 h1:8imxQsjDm8yFEAVBe7azKmKSgzSkZXDuKkSq9374khM= github.com/mschoch/smat v0.2.0/go.mod h1:kc9mz7DoBKqDyiRL7VZN8KvXQMWeTaVnttLRXOlotKw= github.com/mwitkow/grpc-proxy v0.0.0-20181017164139-0f1106ef9c76 h1:0xuRacu/Zr+jX+KyLLPPktbwXqyOvnOPUQmMLzX1jxU= @@ -795,6 +803,8 @@ github.com/oklog/oklog v0.3.2 h1:wVfs8F+in6nTBMkA7CbRw+zZMIB7nNM825cM1wuzoTk= github.com/oklog/run v1.0.0 h1:Ru7dDtJNOyC66gQ5dQmaCa0qIsAUFY3sFpK1Xk8igrw= github.com/oklog/ulid v1.3.1 h1:EGfNDEx6MqHz8B3uNV6QAib1UR2Lm97sHi3ocA6ESJ4= github.com/op/go-logging v0.0.0-20160315200505-970db520ece7 h1:lDH9UUVJtmYCjyT0CI4q8xvlXPxeZ0gYCVvWbmPlp88= +github.com/opencontainers/runtime-spec v1.0.3-0.20210326190908-1c3f411f0417/go.mod h1:jwyrGlmzljRJv/Fgzds9SsS/C5hL+LL3ko9hs6T5lQ0= +github.com/opencontainers/selinux v1.10.0/go.mod h1:2i0OySw99QjzBBQByd1Gr9gSjvuho1lHsJxIJ3gGbJI= github.com/opentracing-contrib/go-observer v0.0.0-20170622124052-a52f23424492 h1:lM6RxxfUMrYL/f8bWEUqdXrANWtrL7Nndbm9iFN0DlU= github.com/opentracing/basictracer-go v1.0.0 h1:YyUAhaEfjoWXclZVJ9sGoNct7j4TVk7lZWlQw5UXuoo= github.com/opentracing/opentracing-go v1.2.0 h1:uEJPy/1a5RIPAJ0Ov+OIO8OxWu77jEv+1B0VhjKrZUs= @@ -903,6 +913,7 @@ github.com/satori/go.uuid v1.2.0/go.mod h1:dA0hQrYB0VpLJoorglMZABFdXlWrHn1NEOzdh github.com/schollz/closestmatch v2.1.0+incompatible h1:Uel2GXEpJqOWBrlyI+oY9LTiyyjYS17cCYRqP13/SHk= github.com/schollz/closestmatch v2.1.0+incompatible/go.mod h1:RtP1ddjLong6gTkbtmuhtR2uUrrJOpYzYRvbcPAid+g= github.com/sean-/seed v0.0.0-20170313163322-e2103e2c3529 h1:nn5Wsu0esKSJiIVhscUtVbo7ada43DJhG55ua/hjS5I= +github.com/seccomp/libseccomp-golang v0.9.2-0.20220502022130-f33da4d89646/go.mod h1:JA8cRccbGaA1s33RQf7Y1+q9gHmZX1yB/z9WDN1C6fg= github.com/securego/gosec/v2 v2.13.1 h1:7mU32qn2dyC81MH9L2kefnQyRMUarfDER3iQyMHcjYM= github.com/securego/gosec/v2 v2.13.1/go.mod h1:EO1sImBMBWFjOTFzMWfTRrZW6M15gm60ljzrmy/wtHo= github.com/sergi/go-diff v1.1.0 h1:we8PVUC3FE2uYfodKH/nBHMSetSfHDR6scGdBi+erh0= @@ -934,8 +945,6 @@ github.com/spf13/jwalterweatherman v1.1.0 h1:ue6voC5bR5F8YxI5S67j9i582FU4Qvo2bmq github.com/spf13/jwalterweatherman v1.1.0/go.mod h1:aNWZUN0dPAAO/Ljvb5BEdw96iTZ0EXowPYD95IqWIGo= github.com/ssgreg/nlreturn/v2 v2.2.1 h1:X4XDI7jstt3ySqGU86YGAURbxw3oTDPK9sPEi6YEwQ0= github.com/ssgreg/nlreturn/v2 v2.2.1/go.mod h1:E/iiPB78hV7Szg2YfRgyIrk1AD6JVMTRkkxBiELzh2I= -github.com/status-im/keycard-go v0.2.0 h1:QDLFswOQu1r5jsycloeQh3bVU8n/NatHHaZobtDnDzA= -github.com/status-im/keycard-go v0.2.0/go.mod h1:wlp8ZLbsmrF6g6WjugPAx+IzoLrkdf9+mHxBEeo3Hbg= github.com/stbenjam/no-sprintf-host-port v0.1.1 h1:tYugd/yrm1O0dV+ThCbaKZh195Dfm07ysF0U6JQXczc= github.com/stbenjam/no-sprintf-host-port v0.1.1/go.mod h1:TLhvtIvONRzdmkFiio4O8LHsN9N74I+PhRquPsxpL0I= github.com/streadway/amqp v1.0.0 h1:kuuDrUJFZL1QYL9hUNuCxNObNzB0bV/ZG5jV3RWAQgo= @@ -944,6 +953,7 @@ github.com/streadway/handy v0.0.0-20200128134331-0f66f006fb2e h1:mOtuXaRAbVZsxAH github.com/streadway/handy v0.0.0-20200128134331-0f66f006fb2e/go.mod h1:qNTQ5P5JnDBl6z3cMAg/SywNDC5ABu5ApDIw6lUbRmI= github.com/supranational/blst v0.3.8-0.20220526154634-513d2456b344 h1:m+8fKfQwCAy1QjzINvKe/pYtLjo2dl59x2w9YSEJxuY= github.com/supranational/blst v0.3.8-0.20220526154634-513d2456b344/go.mod h1:jZJtfjgudtNl4en1tzwPIV3KjUnQUvG3/j+w+fVonLw= +github.com/syndtr/gocapability v0.0.0-20200815063812-42c35b437635/go.mod h1:hkRG7XYTFWNJGYcbNJQlaLq0fg1yr4J4t/NcTQtrfww= github.com/tdakkota/asciicheck v0.1.1 h1:PKzG7JUTUmVspQTDqtkX9eSiLGossXTybutHwTXuO0A= github.com/tdakkota/asciicheck v0.1.1/go.mod h1:yHp0ai0Z9gUljN3o0xMhYJnH/IcvkdTBOX2fmJ93JEM= github.com/tdewolff/minify/v2 v2.12.4 h1:kejsHQMM17n6/gwdw53qsi6lg0TGddZADVyQOz1KMdE= @@ -986,6 +996,8 @@ github.com/valyala/histogram v1.2.0 h1:wyYGAZZt3CpwUiIb9AU/Zbllg1llXyrtApRS815OL github.com/valyala/histogram v1.2.0/go.mod h1:Hb4kBwb4UxsaNbbbh+RRz8ZR6pdodR57tzWUS3BUzXY= github.com/vektra/mockery/v2 v2.14.0 h1:KZ1p5Hrn8tiY+LErRMr14HHle6khxo+JKOXLBW/yfqs= github.com/vektra/mockery/v2 v2.14.0/go.mod h1:bnD1T8tExSgPD1ripLkDbr60JA9VtQeu12P3wgLZd7M= +github.com/vishvananda/netlink v1.1.0/go.mod h1:cTgwzPIzzgDAYoQrMm0EdrjRUBkTqKYppBueQtXaqoE= +github.com/vishvananda/netns v0.0.0-20191106174202-0a2b9b5464df/go.mod h1:JP3t17pCcGlemwknint6hfoeCVQrEMVwxRLRjXpq+BU= github.com/vmihailenco/msgpack/v5 v5.3.5 h1:5gO0H1iULLWGhs2H5tbAHIZTV8/cYafcFOr9znI5mJU= github.com/vmihailenco/msgpack/v5 v5.3.5/go.mod h1:7xyJ9e+0+9SaZT0Wt1RGleJXzli6Q/V5KbhBonMG9jc= github.com/vmihailenco/tagparser/v2 v2.0.0 h1:y09buUbR+b5aycVFQs/g70pqKVZNBmxwAhO7/IwNM9g= @@ -1035,6 +1047,7 @@ golang.org/x/mobile v0.0.0-20190719004257-d2bd2a29d028 h1:4+4C/Iv2U4fMZBiMCc98MG golang.org/x/mobile v0.0.0-20190719004257-d2bd2a29d028/go.mod h1:E/iHnbuqvinMTCcRqshq8CkpyQDoeVncDDYHnLhea+o= golang.org/x/perf v0.0.0-20230113213139-801c7ef9e5c5 h1:ObuXPmIgI4ZMyQLIz48cJYgSyWdjUXc2SZAdyJMwEAU= golang.org/x/perf v0.0.0-20230113213139-801c7ef9e5c5/go.mod h1:UBKtEnL8aqnd+0JHqZ+2qoMDwtuy6cYhhKNoHLBiTQc= +golang.org/x/telemetry v0.0.0-20240228155512-f48c80bd79b2/go.mod h1:TeRTkGYfJXctD9OcfyVLyj2J3IxLnKwHJR8f4D8a3YE= gonum.org/v1/gonum v0.8.2 h1:CCXrcPKiGGotvnN6jfUsKk4rRqm7q09/YbKb5xCEvtM= gonum.org/v1/gonum v0.8.2/go.mod h1:oe/vMfY3deqTw+1EZJhuvEW2iwGF1bW9wwu7XCu0+v0= google.golang.org/appengine v1.6.8 h1:IhEN5q69dyKagZPYMSdIjS2HqprW324FRQZJcGqPAsM= diff --git a/precompiles/distribution/utils_test.go b/precompiles/distribution/utils_test.go index 1b3b8d2..be99eeb 100644 --- a/precompiles/distribution/utils_test.go +++ b/precompiles/distribution/utils_test.go @@ -33,13 +33,13 @@ import ( evmtypes "github.com/evmos/os/x/evm/types" ) -// SetupWithGenesisValSet initializes a new EvmosApp with a validator set and genesis accounts +// SetupWithGenesisValSet initializes a new evmOS application with a validator set and genesis accounts // that also act as delegators. For simplicity, each validator is bonded with a delegation // of one consensus engine unit (10^6) in the default token of the simapp from first genesis // account. A Nop logger is set in SimApp. func (s *PrecompileTestSuite) SetupWithGenesisValSet(valSet *tmtypes.ValidatorSet, genAccs []authtypes.GenesisAccount, balances ...banktypes.Balance) { appI, genesisState := example_app.SetupTestingApp(cmn.DefaultChainID)() - app, ok := appI.(*evmosapp.Evmos) + app, ok := appI.(*example_app.ExampleChain) s.Require().True(ok) // set genesis accounts @@ -239,7 +239,7 @@ func (s *PrecompileTestSuite) prepareStakingRewards(stkRs ...stakingRewards) { s.Require().NoError(err) // end block to bond validator and increase block height - sdkstaking.EndBlocker(s.ctx, s.app.StakingKeeper.Keeper) + sdkstaking.EndBlocker(s.ctx, s.app.StakingKeeper) // allocate rewards to validator (of these 50% will be paid out to the delegator) allocatedRewards := sdk.NewDecCoins(sdk.NewDecCoin(s.bondDenom, r.RewardAmt.Mul(math.NewInt(2)))) s.app.DistrKeeper.AllocateTokensToValidator(s.ctx, r.Validator, allocatedRewards) diff --git a/precompiles/ics20/utils_test.go b/precompiles/ics20/utils_test.go index e552700..95bdf0a 100644 --- a/precompiles/ics20/utils_test.go +++ b/precompiles/ics20/utils_test.go @@ -75,13 +75,13 @@ var ( } ) -// SetupWithGenesisValSet initializes a new EvmosApp with a validator set and genesis accounts +// SetupWithGenesisValSet initializes a new evmOS app with a validator set and genesis accounts // that also act as delegators. For simplicity, each validator is bonded with a delegation // of one consensus engine unit (10^6) in the default token of the simapp from first genesis // account. A Nop logger is set in SimApp. func (s *PrecompileTestSuite) SetupWithGenesisValSet(valSet *tmtypes.ValidatorSet, genAccs []authtypes.GenesisAccount, balances ...banktypes.Balance) { appI, genesisState := example_app.SetupTestingApp(cmn.DefaultChainID)() - app, ok := appI.(*evmosapp.Evmos) + app, ok := appI.(*example_app.ExampleChain) s.Require().True(ok) // set genesis accounts @@ -251,7 +251,7 @@ func (s *PrecompileTestSuite) NewTestChainWithValSet(coord *ibctesting.Coordinat txConfig := s.app.GetTxConfig() // Create StateDB - s.stateDB = statedb.New(s.ctx, s.app.EvmKeeper, statedb.NewEmptyTxConfig(common.BytesToHash(s.ctx.HeaderHash().Bytes()))) + s.stateDB = statedb.New(s.ctx, s.app.EVMKeeper, statedb.NewEmptyTxConfig(common.BytesToHash(s.ctx.HeaderHash().Bytes()))) // bond denom stakingParams := s.app.StakingKeeper.GetParams(s.ctx) @@ -260,19 +260,19 @@ func (s *PrecompileTestSuite) NewTestChainWithValSet(coord *ibctesting.Coordinat err := s.app.StakingKeeper.SetParams(s.ctx, stakingParams) s.Require().NoError(err) - s.ethSigner = ethtypes.LatestSignerForChainID(s.app.EvmKeeper.ChainID()) + s.ethSigner = ethtypes.LatestSignerForChainID(s.app.EVMKeeper.ChainID()) // Setting up the fee market to 0 so the transactions don't fail in IBC testing s.app.FeeMarketKeeper.SetBaseFee(s.ctx, big.NewInt(0)) s.app.FeeMarketKeeper.SetBlockGasWanted(s.ctx, 0) s.app.FeeMarketKeeper.SetTransientBlockGasWanted(s.ctx, 0) - precompile, err := ics20.NewPrecompile(s.app.StakingKeeper, s.app.TransferKeeper, s.app.IBCKeeper.ChannelKeeper, s.app.AuthzKeeper) + precompile, err := ics20.NewPrecompile(*s.app.StakingKeeper, s.app.TransferKeeper, s.app.IBCKeeper.ChannelKeeper, s.app.AuthzKeeper) s.Require().NoError(err) s.precompile = precompile queryHelperEvm := baseapp.NewQueryServerTestHelper(s.ctx, s.app.InterfaceRegistry()) - evmtypes.RegisterQueryServer(queryHelperEvm, s.app.EvmKeeper) + evmtypes.RegisterQueryServer(queryHelperEvm, s.app.EVMKeeper) s.queryClientEVM = evmtypes.NewQueryClient(queryHelperEvm) // create an account to send transactions from @@ -394,9 +394,9 @@ func (s *PrecompileTestSuite) setupIBCTest() { s.coordinator.CommitNBlocks(s.chainB, 2) s.app = s.chainA.App.(*example_app.ExampleChain) - evmParams := s.app.EvmKeeper.GetParams(s.chainA.GetContext()) + evmParams := s.app.EVMKeeper.GetParams(s.chainA.GetContext()) evmParams.EvmDenom = evmosutil.ExampleAttoDenom - err := s.app.EvmKeeper.SetParams(s.chainA.GetContext(), evmParams) + err := s.app.EVMKeeper.SetParams(s.chainA.GetContext(), evmParams) s.Require().NoError(err) // Set block proposer once, so its carried over on the ibc-go-testing suite @@ -408,7 +408,7 @@ func (s *PrecompileTestSuite) setupIBCTest() { err = s.app.StakingKeeper.SetValidatorByConsAddr(s.chainA.GetContext(), validators[0]) s.Require().NoError(err) - _, err = s.app.EvmKeeper.GetCoinbaseAddress(s.chainA.GetContext(), sdk.ConsAddress(s.chainA.CurrentHeader.ProposerAddress)) + _, err = s.app.EVMKeeper.GetCoinbaseAddress(s.chainA.GetContext(), sdk.ConsAddress(s.chainA.CurrentHeader.ProposerAddress)) s.Require().NoError(err) // Mint coins locked on the evmos account generated with secp. @@ -497,21 +497,20 @@ func (s *PrecompileTestSuite) setupAllocationsForTesting() { } } -// TODO upstream this change to evmos (adding gasPrice) // DeployContract deploys a contract with the provided private key, // compiled contract data and constructor arguments func DeployContract( ctx sdk.Context, - evmosApp *example_app.ExampleChain, + exampleApp *example_app.ExampleChain, priv cryptotypes.PrivKey, gasPrice *big.Int, queryClientEvm evmtypes.QueryClient, contract evmtypes.CompiledContract, constructorArgs ...interface{}, ) (common.Address, error) { - chainID := evmosApp.EvmKeeper.ChainID() + chainID := exampleApp.EVMKeeper.ChainID() from := common.BytesToAddress(priv.PubKey().Address().Bytes()) - nonce := evmosApp.EvmKeeper.GetNonce(ctx, from) + nonce := exampleApp.EVMKeeper.GetNonce(ctx, from) ctorArgs, err := contract.ABI.Pack("", constructorArgs...) if err != nil { @@ -528,7 +527,7 @@ func DeployContract( ChainID: chainID, Nonce: nonce, GasLimit: gas, - GasFeeCap: evmosApp.FeeMarketKeeper.GetBaseFee(ctx), + GasFeeCap: exampleApp.FeeMarketKeeper.GetBaseFee(ctx), GasTipCap: big.NewInt(1), GasPrice: gasPrice, Input: data, @@ -536,12 +535,12 @@ func DeployContract( }) msgEthereumTx.From = from.String() - res, err := chainutil.DeliverEthTx(evmosApp, priv, msgEthereumTx) + res, err := chainutil.DeliverEthTx(exampleApp, priv, msgEthereumTx) if err != nil { return common.Address{}, err } - if _, err := chainutil.CheckEthTxResponse(res, evmosApp.AppCodec()); err != nil { + if _, err := chainutil.CheckEthTxResponse(res, exampleApp.AppCodec()); err != nil { return common.Address{}, err } diff --git a/precompiles/staking/utils_test.go b/precompiles/staking/utils_test.go index 7ce4e53..c379862 100644 --- a/precompiles/staking/utils_test.go +++ b/precompiles/staking/utils_test.go @@ -49,13 +49,13 @@ import ( // stipend to pay EVM tx fees var accountGasCoverage = sdk.NewCoins(sdk.NewCoin(evmosutil.ExampleAttoDenom, math.NewInt(1e16))) -// SetupWithGenesisValSet initializes a new EvmosApp with a validator set and genesis accounts +// SetupWithGenesisValSet initializes a new evmOS app with a validator set and genesis accounts // that also act as delegators. For simplicity, each validator is bonded with a delegation // of one consensus engine unit (10^6) in the default token of the simapp from first genesis // account. A Nop logger is set in SimApp. func (s *PrecompileTestSuite) SetupWithGenesisValSet(valSet *tmtypes.ValidatorSet, genAccs []authtypes.GenesisAccount, balances ...banktypes.Balance) { appI, genesisState := example_app.SetupTestingApp(cmn.DefaultChainID)() - app, ok := appI.(*evmosapp.Evmos) + app, ok := appI.(*example_app.ExampleChain) s.Require().True(ok) // set genesis accounts @@ -183,7 +183,7 @@ func (s *PrecompileTestSuite) DoSetupTest() { s.SetupWithGenesisValSet(valSet, []authtypes.GenesisAccount{baseAcc}, balance) // Create StateDB - s.stateDB = statedb.New(s.ctx, s.app.EvmKeeper, statedb.NewEmptyTxConfig(common.BytesToHash(s.ctx.HeaderHash().Bytes()))) + s.stateDB = statedb.New(s.ctx, s.app.EVMKeeper, statedb.NewEmptyTxConfig(common.BytesToHash(s.ctx.HeaderHash().Bytes()))) // bond denom stakingParams := s.app.StakingKeeper.GetParams(s.ctx) @@ -192,9 +192,9 @@ func (s *PrecompileTestSuite) DoSetupTest() { err := s.app.StakingKeeper.SetParams(s.ctx, stakingParams) s.Require().NoError(err) - s.ethSigner = ethtypes.LatestSignerForChainID(s.app.EvmKeeper.ChainID()) + s.ethSigner = ethtypes.LatestSignerForChainID(s.app.EVMKeeper.ChainID()) - precompile, err := staking.NewPrecompile(s.app.StakingKeeper, s.app.AuthzKeeper) + precompile, err := staking.NewPrecompile(*s.app.StakingKeeper, s.app.AuthzKeeper) s.Require().NoError(err) s.precompile = precompile @@ -206,7 +206,7 @@ func (s *PrecompileTestSuite) DoSetupTest() { s.Require().NoError(err) queryHelperEvm := baseapp.NewQueryServerTestHelper(s.ctx, s.app.InterfaceRegistry()) - evmtypes.RegisterQueryServer(queryHelperEvm, s.app.EvmKeeper) + evmtypes.RegisterQueryServer(queryHelperEvm, s.app.EVMKeeper) s.queryClientEVM = evmtypes.NewQueryClient(queryHelperEvm) } @@ -535,40 +535,6 @@ func (s *PrecompileTestSuite) CheckValidatorOutput(valOut staking.ValidatorInfo) Expect(valOut.DelegatorShares).To(Equal(big.NewInt(1e18)), "expected different delegator shares") } -// setupVestingAccount is a helper function used in integraiton tests to setup a vesting account -// using the TestVestingSchedule. Also, funds the account with extra funds to pay for transaction fees -func (s *PrecompileTestSuite) setupVestingAccount(funder, vestAcc sdk.AccAddress) *vestingtypes.ClawbackVestingAccount { - vestingAmtTotal := evmosutil.TestVestingSchedule.TotalVestingCoins - - vestingStart := s.ctx.BlockTime() - baseAccount := authtypes.NewBaseAccountWithAddress(vestAcc.Bytes()) - clawbackAccount := vestingtypes.NewClawbackVestingAccount( - baseAccount, - funder, - vestingAmtTotal, - vestingStart, - evmosutil.TestVestingSchedule.LockupPeriods, - evmosutil.TestVestingSchedule.VestingPeriods, - ) - - err := evmosutil.FundAccount(s.ctx, s.app.BankKeeper, clawbackAccount.GetAddress(), vestingAmtTotal) - Expect(err).To(BeNil()) - acc := s.app.AccountKeeper.NewAccount(s.ctx, clawbackAccount) - s.app.AccountKeeper.SetAccount(s.ctx, acc) - - // Check all coins are locked up - lockedUp := clawbackAccount.GetLockedUpCoins(s.ctx.BlockTime()) - Expect(vestingAmtTotal).To(Equal(lockedUp)) - - // Grant gas stipend to cover EVM fees - err = evmosutil.FundAccount(s.ctx, s.app.BankKeeper, clawbackAccount.GetAddress(), accountGasCoverage) - Expect(err).To(BeNil()) - granteeBalance := s.app.BankKeeper.GetBalance(s.ctx, clawbackAccount.GetAddress(), s.bondDenom) - Expect(granteeBalance).To(Equal(accountGasCoverage[0].Add(vestingAmtTotal[0]))) - - return clawbackAccount -} - // Generate the Base64 encoded PubKey associated with a PrivKey generated with // the ed25519 algorithm used in Tendermint nodes. func GenerateBase64PubKey() string { diff --git a/testutil/integration/os/network/network.go b/testutil/integration/os/network/network.go index 8d504e9..1538cbf 100644 --- a/testutil/integration/os/network/network.go +++ b/testutil/integration/os/network/network.go @@ -121,8 +121,8 @@ func (n *IntegrationNetwork) configureAndInitChain() error { delegations := createDelegations(valSet.Validators, genAccounts[0].GetAddress()) - // Create a new EvmosApp with the following params - evmosApp := createExampleApp(n.cfg.chainID) + // Create a new evmOS app with the following params + exampleApp := createExampleApp(n.cfg.chainID) stakingParams := StakingCustomGenesisState{ denom: n.cfg.denom, @@ -138,7 +138,7 @@ func (n *IntegrationNetwork) configureAndInitChain() error { // Configure Genesis state genesisState := newDefaultGenesisState( - evmosApp, + exampleApp, defaultGenesisParams{ genAccounts: genAccounts, staking: stakingParams, @@ -148,7 +148,7 @@ func (n *IntegrationNetwork) configureAndInitChain() error { // modify genesis state if there're any custom genesis state // for specific modules - genesisState, err = customizeGenesis(evmosApp, n.cfg.customGenesisState, genesisState) + genesisState, err = customizeGenesis(exampleApp, n.cfg.customGenesisState, genesisState) if err != nil { return err } @@ -161,7 +161,7 @@ func (n *IntegrationNetwork) configureAndInitChain() error { consensusParams := example_app.DefaultConsensusParams now := time.Now() - evmosApp.InitChain( + exampleApp.InitChain( abcitypes.RequestInitChain{ Time: now, ChainId: n.cfg.chainID, @@ -171,23 +171,23 @@ func (n *IntegrationNetwork) configureAndInitChain() error { }, ) // Commit genesis changes - evmosApp.Commit() + exampleApp.Commit() header := tmproto.Header{ ChainID: n.cfg.chainID, - Height: evmosApp.LastBlockHeight() + 1, + Height: exampleApp.LastBlockHeight() + 1, Time: now, - AppHash: evmosApp.LastCommitID().Hash, + AppHash: exampleApp.LastCommitID().Hash, ValidatorsHash: valSet.Hash(), NextValidatorsHash: valSet.Hash(), ProposerAddress: valSet.Proposer.Address, } - evmosApp.BeginBlock(abcitypes.RequestBeginBlock{Header: header}) + exampleApp.BeginBlock(abcitypes.RequestBeginBlock{Header: header}) // Set networks global parameters - n.app = evmosApp + n.app = exampleApp // TODO - this might not be the best way to initialize the context - n.ctx = evmosApp.BaseApp.NewContext(false, header) + n.ctx = exampleApp.BaseApp.NewContext(false, header) n.ctx = n.ctx.WithConsensusParams(consensusParams) n.ctx = n.ctx.WithBlockGasMeter(sdktypes.NewInfiniteGasMeter()) @@ -215,7 +215,7 @@ func (n *IntegrationNetwork) configureAndInitChain() error { Symbol: "EVMOS", Display: n.cfg.denom, } - evmosApp.BankKeeper.SetDenomMetaData(n.ctx, evmosMetadata) + exampleApp.BankKeeper.SetDenomMetaData(n.ctx, evmosMetadata) return nil } diff --git a/testutil/integration/os/network/setup.go b/testutil/integration/os/network/setup.go index 0942698..cc711d1 100644 --- a/testutil/integration/os/network/setup.go +++ b/testutil/integration/os/network/setup.go @@ -171,7 +171,7 @@ type StakingCustomGenesisState struct { } // setDefaultStakingGenesisState sets the staking genesis state -func setDefaultStakingGenesisState(evmosApp *example_app.ExampleChain, genesisState simapp.GenesisState, overwriteParams StakingCustomGenesisState) simapp.GenesisState { +func setDefaultStakingGenesisState(exampleApp *example_app.ExampleChain, genesisState simapp.GenesisState, overwriteParams StakingCustomGenesisState) simapp.GenesisState { // Set staking params stakingParams := stakingtypes.DefaultParams() stakingParams.BondDenom = overwriteParams.denom @@ -181,7 +181,7 @@ func setDefaultStakingGenesisState(evmosApp *example_app.ExampleChain, genesisSt overwriteParams.validators, overwriteParams.delegations, ) - genesisState[stakingtypes.ModuleName] = evmosApp.AppCodec().MustMarshalJSON(stakingGenesis) + genesisState[stakingtypes.ModuleName] = exampleApp.AppCodec().MustMarshalJSON(stakingGenesis) return genesisState } @@ -192,7 +192,7 @@ type BankCustomGenesisState struct { // setDefaultBankGenesisState sets the bank genesis state func setDefaultBankGenesisState( - evmosApp *example_app.ExampleChain, + exampleApp *example_app.ExampleChain, genesisState simapp.GenesisState, overwriteParams BankCustomGenesisState, ) simapp.GenesisState { @@ -203,13 +203,13 @@ func setDefaultBankGenesisState( []banktypes.Metadata{}, []banktypes.SendEnabled{}, ) - genesisState[banktypes.ModuleName] = evmosApp.AppCodec().MustMarshalJSON(bankGenesis) + genesisState[banktypes.ModuleName] = exampleApp.AppCodec().MustMarshalJSON(bankGenesis) return genesisState } // genSetupFn is the type for the module genesis setup functions type genSetupFn func( - evmosApp *example_app.ExampleChain, + exampleApp *example_app.ExampleChain, genesisState simapp.GenesisState, customGenesis interface{}, ) (simapp.GenesisState, error) @@ -225,7 +225,7 @@ type defaultGenesisParams struct { // genStateSetter is a generic function to set module-specific genesis state func genStateSetter[T proto.Message](moduleName string) genSetupFn { return func( - evmosApp *example_app.ExampleChain, + exampleApp *example_app.ExampleChain, genesisState simapp.GenesisState, customGenesis interface{}, ) (simapp.GenesisState, error) { @@ -234,7 +234,7 @@ func genStateSetter[T proto.Message](moduleName string) genSetupFn { return nil, fmt.Errorf("invalid type %T for %s module genesis state", customGenesis, moduleName) } - genesisState[moduleName] = evmosApp.AppCodec().MustMarshalJSON(moduleGenesis) + genesisState[moduleName] = exampleApp.AppCodec().MustMarshalJSON(moduleGenesis) return genesisState, nil } } @@ -251,43 +251,43 @@ var genesisSetupFunctions = map[string]genSetupFn{ // setDefaultAuthGenesisState sets the default auth genesis state func setDefaultAuthGenesisState( - evmosApp *example_app.ExampleChain, + exampleApp *example_app.ExampleChain, genesisState simapp.GenesisState, genAccs []authtypes.GenesisAccount, ) simapp.GenesisState { defaultAuthGen := authtypes.NewGenesisState(authtypes.DefaultParams(), genAccs) - genesisState[authtypes.ModuleName] = evmosApp.AppCodec().MustMarshalJSON(defaultAuthGen) + genesisState[authtypes.ModuleName] = exampleApp.AppCodec().MustMarshalJSON(defaultAuthGen) return genesisState } // setDefaultGovGenesisState sets the default gov genesis state -func setDefaultGovGenesisState(evmosApp *example_app.ExampleChain, genesisState simapp.GenesisState) simapp.GenesisState { +func setDefaultGovGenesisState(exampleApp *example_app.ExampleChain, genesisState simapp.GenesisState) simapp.GenesisState { govGen := govtypesv1.DefaultGenesisState() updatedParams := govGen.Params // set 'aevmos' as deposit denom updatedParams.MinDeposit = sdktypes.NewCoins(sdktypes.NewCoin(testutil.ExampleAttoDenom, sdkmath.NewInt(1e18))) govGen.Params = updatedParams - genesisState[govtypes.ModuleName] = evmosApp.AppCodec().MustMarshalJSON(govGen) + genesisState[govtypes.ModuleName] = exampleApp.AppCodec().MustMarshalJSON(govGen) return genesisState } // TODO: remove Evmos specific stuff -func setDefaultErc20GenesisState(evmosApp *example_app.ExampleChain, genesisState simapp.GenesisState) simapp.GenesisState { +func setDefaultErc20GenesisState(exampleApp *example_app.ExampleChain, genesisState simapp.GenesisState) simapp.GenesisState { erc20Gen := erc20types.DefaultGenesisState() - genesisState[erc20types.ModuleName] = evmosApp.AppCodec().MustMarshalJSON(erc20Gen) + genesisState[erc20types.ModuleName] = exampleApp.AppCodec().MustMarshalJSON(erc20Gen) return genesisState } // defaultAuthGenesisState sets the default genesis state // for the testing setup -func newDefaultGenesisState(evmosApp *example_app.ExampleChain, params defaultGenesisParams) simapp.GenesisState { +func newDefaultGenesisState(exampleApp *example_app.ExampleChain, params defaultGenesisParams) simapp.GenesisState { genesisState := example_app.NewDefaultGenesisState() - genesisState = setDefaultAuthGenesisState(evmosApp, genesisState, params.genAccounts) - genesisState = setDefaultStakingGenesisState(evmosApp, genesisState, params.staking) - genesisState = setDefaultBankGenesisState(evmosApp, genesisState, params.bank) - genesisState = setDefaultGovGenesisState(evmosApp, genesisState) - genesisState = setDefaultErc20GenesisState(evmosApp, genesisState) + genesisState = setDefaultAuthGenesisState(exampleApp, genesisState, params.genAccounts) + genesisState = setDefaultStakingGenesisState(exampleApp, genesisState, params.staking) + genesisState = setDefaultBankGenesisState(exampleApp, genesisState, params.bank) + genesisState = setDefaultGovGenesisState(exampleApp, genesisState) + genesisState = setDefaultErc20GenesisState(exampleApp, genesisState) return genesisState } @@ -295,14 +295,14 @@ func newDefaultGenesisState(evmosApp *example_app.ExampleChain, params defaultGe // customizeGenesis modifies genesis state if there're any custom genesis state // for specific modules func customizeGenesis( - evmosApp *example_app.ExampleChain, + exampleApp *example_app.ExampleChain, customGen CustomGenesisState, genesisState simapp.GenesisState, ) (simapp.GenesisState, error) { var err error for mod, modGenState := range customGen { if fn, found := genesisSetupFunctions[mod]; found { - genesisState, err = fn(evmosApp, genesisState, modGenState) + genesisState, err = fn(exampleApp, genesisState, modGenState) if err != nil { return genesisState, err }