diff --git a/.github/ISSUE_TEMPLATE/e2e_test_case_template.yaml b/.github/ISSUE_TEMPLATE/e2e_test_case_template.yaml index 0d887583..386e2c53 100644 --- a/.github/ISSUE_TEMPLATE/e2e_test_case_template.yaml +++ b/.github/ISSUE_TEMPLATE/e2e_test_case_template.yaml @@ -70,6 +70,10 @@ body: - "full node sync" - "base layer disconnection" - "sequencer rotation" + - "light client" + - "zero fee relay" + - "IRO" + - "eibc client" validations: required: true diff --git a/Makefile b/Makefile index ed42214e..e47045d5 100644 --- a/Makefile +++ b/Makefile @@ -14,6 +14,18 @@ e2e-test: clean-e2e e2e-test-ibc-success-evm: clean-e2e cd tests && go test -timeout=45m -race -v -run TestIBCTransferSuccess_EVM . +e2e-test-one-sqc-rotation-success-evm: clean-e2e + cd tests && go test -timeout=45m -race -v -run Test_SqcRotation_OneSqc_Success_EVM . + +e2e-test-light-client-same-chain-id: clean-e2e + cd tests && go test -timeout=45m -race -v -run TestIBCTransferRA_3rdSameChainID_EVM . + +e2e-test-light-client-hub-3rd: clean-e2e + cd tests && go test -timeout=45m -race -v -run TestIBCTransferBetweenHub3rd_EVM . + +e2e-test-light-client-same-chain-id-no-light-client: clean-e2e + cd tests && go test -timeout=45m -race -v -run TestIBCTransfer_NoLightClient_EVM . + e2e-test-spinup: clean-e2e cd tests && go test -timeout=45m -race -v -run TestSpinUp . @@ -87,7 +99,7 @@ e2e-test-eibc-timeout-evm: clean-e2e cd tests && go test -timeout=45m -race -v -run TestEIBCTimeoutDymToRollapp_EVM . e2e-test-eibc-timeout_and_fulfill-evm: clean-e2e - cd tests && go test -timeout=45m -race -v -run TestEIBCTimeoutFulFillDymToRollapp_Evm . + cd tests && go test -timeout=45m -race -v -run TestEIBCTimeoutFulFillDymToRollapp_EVM . e2e-test-transfer-multi-hop-evm: clean-e2e cd tests && go test -timeout=45m -race -v -run TestIBCTransferMultiHop_EVM . @@ -244,6 +256,12 @@ e2e-test-fullnode-disconnect-block-sync-evm: clean-e2e e2e-test-seq-rotation-mul-seq-evm: clean-e2e cd tests && go test -timeout=30m -race -v -run Test_SeqRotation_MulSeq_EVM . + +e2e-test-sequencer-rotation-noseq-da-evm: clean-e2e + cd tests && go test -timeout=30m -race -v -run Test_SeqRotation_NoSeq_DA_EVM . + +e2e-test-sequencer-rotation-noseq-p2p-evm: clean-e2e + cd tests && go test -timeout=30m -race -v -run Test_SeqRotation_NoSeq_P2P_EVM . # Executes IBC tests via rollup-e2e-testing e2e-test-ibc-success-wasm: clean-e2e diff --git a/clean.sh b/clean.sh index 4e6bb1cb..0f5164a8 100644 --- a/clean.sh +++ b/clean.sh @@ -5,5 +5,7 @@ rm -rf /tmp/rollapp* rm -rf /tmp/dym* rm -rf /tmp/sequencer* rm -rf /tmp/celes* +rm -rf /tmp/gaia* +rm -rf /tmp/new_rollapp* echo "Clean success!!" diff --git a/go.mod b/go.mod index 189765b6..299d84ec 100644 --- a/go.mod +++ b/go.mod @@ -10,9 +10,9 @@ replace ( require ( github.com/decentrio/e2e-testing-live v0.0.0-20240718080249-ee255229c869 - github.com/decentrio/rollup-e2e-testing v0.0.0-20240822112829-42feba8c484e - github.com/dymensionxyz/dymension/v3 v3.1.0-rc03.0.20240717194206-54c0fca5fada - github.com/dymensionxyz/dymint v1.2.0-rc01 + github.com/decentrio/rollup-e2e-testing v0.0.0-20240925065439-bea0cdea5436 + github.com/dymensionxyz/dymension/v3 v3.1.0-rc03.0.20240911123104-4782bc4e587f + github.com/dymensionxyz/dymint v1.2.0-rc01.0.20240919105350-66f9b353655d ) require ( @@ -30,14 +30,14 @@ require ( cosmossdk.io/simapp v0.0.0-20230608160436-666c345ad23d // indirect github.com/99designs/keyring v1.2.2 // indirect github.com/BurntSushi/toml v1.3.2 // indirect - github.com/DataDog/zstd v1.5.2 // indirect + github.com/DataDog/zstd v1.5.5 // indirect github.com/StackExchange/wmi v0.0.0-20180116203802-5d049714c4a6 // indirect github.com/avast/retry-go/v4 v4.5.0 // indirect github.com/cockroachdb/pebble v1.1.0 // indirect github.com/cockroachdb/tokenbucket v0.0.0-20230807174530-cc333fc44b06 // indirect github.com/cometbft/cometbft v0.37.5 // indirect github.com/cosmos/go-bip39 v1.0.0 // indirect - github.com/cosmos/gogoproto v1.4.11 // indirect + github.com/cosmos/gogoproto v1.5.0 // indirect github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect github.com/docker/docker v24.0.7+incompatible github.com/docker/go-connections v0.4.0 // indirect @@ -72,8 +72,8 @@ require ( cloud.google.com/go/compute/metadata v0.2.3 // indirect cloud.google.com/go/iam v1.1.6 // indirect cloud.google.com/go/storage v1.38.0 // indirect - cosmossdk.io/api v0.3.1 // indirect - cosmossdk.io/core v0.6.1 // indirect + cosmossdk.io/api v0.7.0 // indirect + cosmossdk.io/core v0.10.0 // indirect cosmossdk.io/depinject v1.0.0-alpha.4 // indirect cosmossdk.io/errors v1.0.1 // indirect cosmossdk.io/log v1.3.1 // indirect @@ -88,9 +88,12 @@ require ( github.com/bgentry/go-netrc v0.0.0-20140422174119-9fd32a8b3d3d // indirect github.com/bgentry/speakeasy v0.1.1-0.20220910012023-760eaf8b6816 // indirect github.com/btcsuite/btcd/btcec/v2 v2.3.3 // indirect - github.com/celestiaorg/celestia-openrpc v0.4.0-rc.1 // indirect + github.com/celestiaorg/celestia-openrpc v0.4.1-0.20240828130104-089b92870cb6 // indirect + github.com/celestiaorg/go-header v0.4.1 // indirect + github.com/celestiaorg/go-square v1.0.1 // indirect + github.com/celestiaorg/go-square/merkle v0.0.0-20240429192549-dea967e1533b // indirect github.com/celestiaorg/merkletree v0.0.0-20210714075610-a84dc3ddbbe4 // indirect - github.com/celestiaorg/nmt v0.20.0 // indirect + github.com/celestiaorg/nmt v0.21.0 // indirect github.com/celestiaorg/rsmt2d v0.11.0 // indirect github.com/cenkalti/backoff/v4 v4.2.1 // indirect github.com/cespare/xxhash v1.1.0 // indirect @@ -123,8 +126,8 @@ require ( github.com/docker/go-units v0.5.0 // indirect github.com/dustin/go-humanize v1.0.1 // indirect github.com/dvsekhvalnov/jose2go v1.6.0 // indirect - github.com/dymensionxyz/cosmosclient v0.4.2-beta.0.20240421130646-b8980ec7aade // indirect github.com/dymensionxyz/gerr-cosmos v1.0.0 // indirect + github.com/dymensionxyz/sdk-utils v0.2.8 // indirect github.com/ethereum/go-ethereum v1.12.0 // indirect github.com/felixge/httpsnoop v1.0.4 // indirect github.com/fsnotify/fsnotify v1.7.0 // indirect @@ -161,13 +164,16 @@ require ( github.com/hashicorp/go-immutable-radix v1.3.1 // indirect github.com/hashicorp/go-safetemp v1.0.0 // indirect github.com/hashicorp/go-version v1.6.0 // indirect - github.com/hashicorp/golang-lru v0.5.5-0.20210104140557-80c98217689d // indirect + github.com/hashicorp/golang-lru v1.0.2 // indirect + github.com/hashicorp/golang-lru/v2 v2.0.7 // indirect github.com/hashicorp/hcl v1.0.0 // indirect github.com/hdevalence/ed25519consensus v0.1.0 // indirect github.com/holiman/uint256 v1.2.2 // indirect github.com/huandu/skiplist v1.2.0 // indirect github.com/improbable-eng/grpc-web v0.15.0 // indirect github.com/inconshreveable/mousetrap v1.1.0 // indirect + github.com/ipfs/go-cid v0.4.1 // indirect + github.com/ipfs/go-log/v2 v2.5.1 // indirect github.com/jmespath/go-jmespath v0.4.0 // indirect github.com/jmhodges/levigo v1.0.0 // indirect github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51 // indirect @@ -179,6 +185,8 @@ require ( github.com/lib/pq v1.10.7 // indirect github.com/libp2p/go-buffer-pool v0.1.0 // indirect github.com/libp2p/go-libp2p v0.33.1 // indirect + github.com/libp2p/go-libp2p-pubsub v0.10.1 // indirect + github.com/libp2p/go-msgio v0.3.0 // indirect github.com/linxGnu/grocksdb v1.8.12 // indirect github.com/magiconair/properties v1.8.7 // indirect github.com/manifoldco/promptui v0.9.0 // indirect @@ -186,10 +194,20 @@ require ( github.com/mattn/go-isatty v0.0.20 // indirect github.com/mimoo/StrobeGo v0.0.0-20220103164710-9a04d6ca976b // indirect github.com/minio/highwayhash v1.0.2 // indirect + github.com/minio/sha256-simd v1.0.1 // indirect github.com/mitchellh/go-homedir v1.1.0 // indirect github.com/mitchellh/go-testing-interface v1.14.1 // indirect github.com/mitchellh/mapstructure v1.5.0 // indirect + github.com/mr-tron/base58 v1.2.0 // indirect github.com/mtibben/percent v0.2.1 // indirect + github.com/multiformats/go-base32 v0.1.0 // indirect + github.com/multiformats/go-base36 v0.2.0 // indirect + github.com/multiformats/go-multiaddr v0.12.2 // indirect + github.com/multiformats/go-multibase v0.2.0 // indirect + github.com/multiformats/go-multicodec v0.9.0 // indirect + github.com/multiformats/go-multihash v0.2.3 // indirect + github.com/multiformats/go-multistream v0.5.0 // indirect + github.com/multiformats/go-varint v0.0.7 // indirect github.com/opencontainers/go-digest v1.0.0 // indirect github.com/opencontainers/image-spec v1.1.0-rc2 // indirect github.com/petermattis/goid v0.0.0-20230518223814-80aa455d8761 // indirect @@ -202,10 +220,11 @@ require ( github.com/rakyll/statik v0.1.7 // indirect github.com/rcrowley/go-metrics v0.0.0-20201227073835-cf1acfcdf475 // indirect github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec // indirect - github.com/rogpeppe/go-internal v1.11.0 // indirect + github.com/rogpeppe/go-internal v1.12.0 // indirect github.com/rs/cors v1.9.0 // indirect github.com/rs/zerolog v1.32.0 // indirect github.com/sasha-s/go-deadlock v0.3.1 // indirect + github.com/spaolacci/murmur3 v1.1.0 // indirect github.com/spf13/afero v1.11.0 // indirect github.com/spf13/cast v1.6.0 // indirect github.com/spf13/pflag v1.0.5 // indirect @@ -241,6 +260,7 @@ require ( google.golang.org/genproto/googleapis/rpc v0.0.0-20240318140521-94a12d6c2237 // indirect google.golang.org/protobuf v1.33.0 // indirect gopkg.in/ini.v1 v1.67.0 // indirect + lukechampine.com/blake3 v1.2.1 // indirect lukechampine.com/uint128 v1.2.0 // indirect modernc.org/cc/v3 v3.40.0 // indirect modernc.org/ccgo/v3 v3.16.13 // indirect @@ -256,8 +276,16 @@ require ( ) replace ( + // for collections + cosmossdk.io/api => cosmossdk.io/api v0.3.1 + github.com/cosmos/gogoproto => github.com/cosmos/gogoproto v1.4.10 + github.com/dymensionxyz/cosmosclient => github.com/dymensionxyz/cosmosclient v0.4.2-beta.0.20240421130646-b8980ec7aade github.com/gogo/protobuf => github.com/regen-network/protobuf v1.3.3-alpha.regen.1 + github.com/multiformats/go-multiaddr => github.com/multiformats/go-multiaddr v0.10.0 + + github.com/osmosis-labs/osmosis/osmomath => github.com/dymensionxyz/osmosis/osmomath v0.0.6-dymension-v0.1.0.20240820121212-c0e21fa21e43 + github.com/osmosis-labs/osmosis/v15 => github.com/dymensionxyz/osmosis/v15 v15.2.1-0.20240820121212-c0e21fa21e43 github.com/tendermint/tendermint => github.com/cometbft/cometbft v0.34.28 // stick with compatible version or x/exp in v0.47.x line diff --git a/go.sum b/go.sum index 9686da82..349dba73 100644 --- a/go.sum +++ b/go.sum @@ -517,12 +517,10 @@ cloud.google.com/go/workflows v1.7.0/go.mod h1:JhSrZuVZWuiDfKEFxU0/F1PQjmpnpcoIS cloud.google.com/go/workflows v1.8.0/go.mod h1:ysGhmEajwZxGn1OhGOGKsTXc5PyxOc0vfKf5Af+to4M= cloud.google.com/go/workflows v1.9.0/go.mod h1:ZGkj1aFIOd9c8Gerkjjq7OW7I5+l6cSvT3ujaO/WwSA= cloud.google.com/go/workflows v1.10.0/go.mod h1:fZ8LmRmZQWacon9UCX1r/g/DfAXx5VcPALq2CxzdePw= -code.cloudfoundry.org/go-diodes v0.0.0-20220725190411-383eb6634c40 h1:wzkYwwcf4uMGcDpn48WAbq8GtoqDny49tdQ4zJVAsmo= -code.cloudfoundry.org/go-diodes v0.0.0-20220725190411-383eb6634c40/go.mod h1:Nx9ASXN4nIlRDEXv+qXE3dpuhnTnO28Lxl/bMUd6BMc= cosmossdk.io/api v0.3.1 h1:NNiOclKRR0AOlO4KIqeaG6PS6kswOMhHD0ir0SscNXE= cosmossdk.io/api v0.3.1/go.mod h1:DfHfMkiNA2Uhy8fj0JJlOCYOBp4eWUUJ1te5zBGNyIw= -cosmossdk.io/core v0.6.1 h1:OBy7TI2W+/gyn2z40vVvruK3di+cAluinA6cybFbE7s= -cosmossdk.io/core v0.6.1/go.mod h1:g3MMBCBXtxbDWBURDVnJE7XML4BG5qENhs0gzkcpuFA= +cosmossdk.io/core v0.10.0 h1:NP28Ol9YyRODmZLJg2ko/mUl40hMegeMzhJnG+XPkcY= +cosmossdk.io/core v0.10.0/go.mod h1:MygXNld9DvMgYY4yE76DM/mdZpgfeyRjy6FPjEEehlY= cosmossdk.io/depinject v1.0.0-alpha.4 h1:PLNp8ZYAMPTUKyG9IK2hsbciDWqna2z1Wsl98okJopc= cosmossdk.io/depinject v1.0.0-alpha.4/go.mod h1:HeDk7IkR5ckZ3lMGs/o91AVUc7E596vMaOmslGFM3yU= cosmossdk.io/errors v1.0.1 h1:bzu+Kcr0kS/1DuPBtUFdWjzLqyUuCiyHjyJB6srBV/0= @@ -551,9 +549,11 @@ github.com/BurntSushi/toml v1.3.2/go.mod h1:CxXYINrC8qIiEnFrOxCa7Jy5BFHlXnUU2pbi github.com/ChainSafe/go-schnorrkel v1.0.0 h1:3aDA67lAykLaG1y3AOjs88dMxC88PgUuHRrLeDnvGIM= github.com/ChainSafe/go-schnorrkel v1.0.0/go.mod h1:dpzHYVxLZcp8pjlV+O+UR8K0Hp/z7vcchBSbMBEhCw4= github.com/DataDog/datadog-go v3.2.0+incompatible/go.mod h1:LButxg5PwREeZtORoXG3tL4fMGNddJ+vMq1mwgfaqoQ= -github.com/DataDog/zstd v1.5.2 h1:vUG4lAyuPCXO0TLbXvPv7EB7cNK1QV/luu55UHLrrn8= -github.com/DataDog/zstd v1.5.2/go.mod h1:g4AWEaM3yOg3HYfnJ3YIawPnVdXJh9QME85blwSAmyw= +github.com/DataDog/zstd v1.5.5 h1:oWf5W7GtOLgp6bciQYDmhHHjdhYkALu6S/5Ni9ZgSvQ= +github.com/DataDog/zstd v1.5.5/go.mod h1:g4AWEaM3yOg3HYfnJ3YIawPnVdXJh9QME85blwSAmyw= github.com/JohnCGriffin/overflow v0.0.0-20211019200055-46fa312c352c/go.mod h1:X0CRv0ky0k6m906ixxpzmDRLvX58TFUKS2eePweuyxk= +github.com/Jorropo/jsync v1.0.1 h1:6HgRolFZnsdfzRUj+ImB9og1JYOxQoReSywkHOGSaUU= +github.com/Jorropo/jsync v1.0.1/go.mod h1:jCOZj3vrBCri3bSU3ErUYvevKlnbssrXeCivybS5ABQ= github.com/Knetic/govaluate v3.0.1-0.20171022003610-9aa49832a739+incompatible/go.mod h1:r7JcOSlj0wfOMncg0iLm8Leh48TZaKVeNIfJntJ2wa0= github.com/Microsoft/go-winio v0.6.1 h1:9/kr64B9VUZrLm5YYwbGtUJnMgqWVOdUAXu6Migciow= github.com/Microsoft/go-winio v0.6.1/go.mod h1:LRdKpFKfdobln8UmuiYcKPot9D2v6svN5+sAH+4kjUM= @@ -574,8 +574,6 @@ github.com/Workiva/go-datastructures v1.0.53/go.mod h1:1yZL+zfsztete+ePzZz/Zb1/t github.com/adlio/schema v1.3.3 h1:oBJn8I02PyTB466pZO1UZEn1TV5XLlifBSyMrmHl/1I= github.com/adlio/schema v1.3.3/go.mod h1:1EsRssiv9/Ce2CMzq5DoL7RiMshhuigQxrR4DMV9fHg= github.com/afex/hystrix-go v0.0.0-20180502004556-fa1af6a1f4f5/go.mod h1:SkGFH1ia65gfNATL8TAiHDNxPzPdmEL5uirI2Uyuz6c= -github.com/agl/ed25519 v0.0.0-20170116200512-5312a6153412 h1:w1UutsfOrms1J05zt7ISrnJIXKzwaspym5BTKGx93EI= -github.com/agl/ed25519 v0.0.0-20170116200512-5312a6153412/go.mod h1:WPjqKcmVOxf0XSf3YxCJs6N6AOSrOx3obionmG7T0y0= github.com/ajstarks/deck v0.0.0-20200831202436-30c9fc6549a9/go.mod h1:JynElWSGnm/4RlzPXRlREEwqTHAN3T56Bv2ITsFT3gY= github.com/ajstarks/deck/generate v0.0.0-20210309230005-c3f852c02e19/go.mod h1:T13YZdzov6OU0A1+RfKZiZN9ca6VeKdBdyDV+BY97Tk= github.com/ajstarks/svgo v0.0.0-20180226025133-644b8db467af/go.mod h1:K08gAheRH3/J6wwsYMMT4xOr94bZjxIelGM0+d/wbFw= @@ -618,7 +616,6 @@ github.com/bgentry/go-netrc v0.0.0-20140422174119-9fd32a8b3d3d/go.mod h1:6QX/PXZ github.com/bgentry/speakeasy v0.1.0/go.mod h1:+zsyZBPWlz7T6j88CTgSN5bM796AkVf0kBD4zp0CCIs= github.com/bgentry/speakeasy v0.1.1-0.20220910012023-760eaf8b6816 h1:41iFGWnSlI2gVpmOtVTJZNodLdLQLn/KsJqFvXwnd/s= github.com/bgentry/speakeasy v0.1.1-0.20220910012023-760eaf8b6816/go.mod h1:+zsyZBPWlz7T6j88CTgSN5bM796AkVf0kBD4zp0CCIs= -github.com/blang/semver v3.5.1+incompatible h1:cQNTCjp13qL8KC3Nbxr/y2Bqb63oX6wdnnjpJbkM4JQ= github.com/blang/semver/v4 v4.0.0 h1:1PFHFE6yCCTv8C1TeyNNarDzntLi7wMI5i/pzqYIsAM= github.com/blang/semver/v4 v4.0.0/go.mod h1:IbckMUScFkM3pff0VJDNKRiT6TG/YpiHIM2yvyW5YoQ= github.com/boombuler/barcode v1.0.0/go.mod h1:paBWMcWSl3LHKBqUq+rly7CNSldXjb2rDl3JlRe0mD8= @@ -634,16 +631,20 @@ github.com/btcsuite/btcd/chaincfg/chainhash v1.0.1/go.mod h1:7SFka0XMvUgj3hfZtyd github.com/bufbuild/protocompile v0.4.0 h1:LbFKd2XowZvQ/kajzguUp2DC9UEIQhIq77fZZlaQsNA= github.com/bufbuild/protocompile v0.4.0/go.mod h1:3v93+mbWn/v3xzN+31nwkJfrEpAUwp+BagBSZWx+TP8= github.com/casbin/casbin/v2 v2.1.2/go.mod h1:YcPU1XXisHhLzuxH9coDNf2FbKpjGlbCg3n9yuLkIJQ= -github.com/celestiaorg/celestia-openrpc v0.4.0-rc.1 h1:CLhcfNP4496pg0aptcgHJubNXoY97PMHF0sDWx4HRrg= -github.com/celestiaorg/celestia-openrpc v0.4.0-rc.1/go.mod h1:+2xwD+PBy76D2XOAwDbkuNVUSAvwUFV54cQqMFBA1s0= +github.com/celestiaorg/celestia-openrpc v0.4.1-0.20240828130104-089b92870cb6 h1:CL3ESQnOsFnErzKCMMhi9m/zmerrKTZM03ZT8zEdjuA= +github.com/celestiaorg/celestia-openrpc v0.4.1-0.20240828130104-089b92870cb6/go.mod h1:I0b//K7q/RP1g6gtnQ1xi//ocGwrql4gcQeJEOhDifw= github.com/celestiaorg/go-fraud v0.2.0 h1:aaq2JiW0gTnhEdac3l51UCqSyJ4+VjFGTTpN83V4q7I= github.com/celestiaorg/go-fraud v0.2.0/go.mod h1:lNY1i4K6kUeeE60Z2VK8WXd+qXb8KRzfBhvwPkK6aUc= github.com/celestiaorg/go-header v0.4.1 h1:bjbUcKDnhrJJ9EoE7vtPpgleNLVjc2S+cB4/qe8nQmo= github.com/celestiaorg/go-header v0.4.1/go.mod h1:H8xhnDLDLbkpwmWPhCaZyTnIV3dlVxBHPnxNXS2Qu6c= +github.com/celestiaorg/go-square v1.0.1 h1:LEG1zrw4i03VBMElQF8GAbKYgh1bT1uGzWxasU2ePuo= +github.com/celestiaorg/go-square v1.0.1/go.mod h1:XMv5SGCeGSkynW2OOsedugaW/rQlvzxGzWGxTKsyYOU= +github.com/celestiaorg/go-square/merkle v0.0.0-20240429192549-dea967e1533b h1:jo6M4RJnr33sQC/TTraP5gA6ZgbFO/QqzX8e/lIQC7Q= +github.com/celestiaorg/go-square/merkle v0.0.0-20240429192549-dea967e1533b/go.mod h1:86qIYnEhmn/hfW+xvw98NOI3zGaDEB3x8JGjYo2FqLs= github.com/celestiaorg/merkletree v0.0.0-20210714075610-a84dc3ddbbe4 h1:CJdIpo8n5MFP2MwK0gSRcOVlDlFdQJO1p+FqdxYzmvc= github.com/celestiaorg/merkletree v0.0.0-20210714075610-a84dc3ddbbe4/go.mod h1:fzuHnhzj1pUygGz+1ZkB3uQbEUL4htqCGJ4Qs2LwMZA= -github.com/celestiaorg/nmt v0.20.0 h1:9i7ultZ8Wv5ytt8ZRaxKQ5KOOMo4A2K2T/aPGjIlSas= -github.com/celestiaorg/nmt v0.20.0/go.mod h1:Oz15Ub6YPez9uJV0heoU4WpFctxazuIhKyUtaYNio7E= +github.com/celestiaorg/nmt v0.21.0 h1:81MBqxNn3orByoiCtdNVjwi5WsLgMkzHwP02ZMhTBHM= +github.com/celestiaorg/nmt v0.21.0/go.mod h1:ia/EpCk0enD5yO5frcxoNoFToz2Ghtk2i+blmCRjIY8= github.com/celestiaorg/rsmt2d v0.11.0 h1:lcto/637WyTEZR3dLRoNvyuExfnUbxvdvKi3qz/2V4k= github.com/celestiaorg/rsmt2d v0.11.0/go.mod h1:6Y580I3gVr0+OVFfW6m2JTwnCCmvW3WfbwSLfuT+HCA= github.com/cenkalti/backoff v2.2.1+incompatible h1:tNowT99t7UNflLxfYYSlKYsBpXdEet03Pg2g16Swow4= @@ -716,8 +717,8 @@ github.com/confio/ics23/go v0.9.0 h1:cWs+wdbS2KRPZezoaaj+qBleXgUk5WOQFMP3CQFGTr4 github.com/confio/ics23/go v0.9.0/go.mod h1:4LPZ2NYqnYIVRklaozjNR1FScgDJ2s5Xrp+e/mYVRak= github.com/containerd/cgroups v1.1.0 h1:v8rEWFl6EoqHB+swVNjVoCJE8o3jX7e8nqBGPLaDFBM= github.com/containerd/cgroups v1.1.0/go.mod h1:6ppBcbh/NOOUU+dMKrykgaBnK9lCIBxHqJDGwsa1mIw= -github.com/containerd/continuity v0.4.1 h1:wQnVrjIyQ8vhU2sgOiL5T07jo+ouqc2bnKsv5/EqGhU= -github.com/containerd/continuity v0.4.1/go.mod h1:F6PTNCKepoxEaXLQp3wDAjygEnImnZ/7o4JzpodfroQ= +github.com/containerd/continuity v0.3.0 h1:nisirsYROK15TAMVukJOUyGJjz4BNQJBVsNvAXZJ/eg= +github.com/containerd/continuity v0.3.0/go.mod h1:wJEAIwKOm/pBZuBd0JmeTvnLquTB1Ag8espWhkykbPM= github.com/coreos/etcd v3.3.10+incompatible/go.mod h1:uF7uidLiAD3TWHmW31ZFd/JWoc32PjwdhPthX9715RE= github.com/coreos/go-etcd v2.0.0+incompatible/go.mod h1:Jez6KQU2B/sWsbdaef3ED8NzMklzPG4d5KIOhIy30Tk= github.com/coreos/go-semver v0.2.0/go.mod h1:nnelYz7RCh+5ahJtPPxZlU+153eP4D4r3EedlOD2RNk= @@ -758,6 +759,8 @@ github.com/creachadair/taskgroup v0.4.2 h1:jsBLdAJE42asreGss2xZGZ8fJra7WtwnHWeJF github.com/creachadair/taskgroup v0.4.2/go.mod h1:qiXUOSrbwAY3u0JPGTzObbE3yf9hcXHDKBZ2ZjpCbgM= 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/cskr/pubsub v1.0.2 h1:vlOzMhl6PFn60gRlTQQsIfVwaPB/B/8MziK8FhEPt/0= +github.com/cskr/pubsub v1.0.2/go.mod h1:/8MzYXk/NJAz782G8RPkFzXTZVu63VotefPnR9TIRis= github.com/danieljoos/wincred v1.1.2 h1:QLdCxFs1/Yl4zduvBdcHB8goaYk9RARS2SgLLRuAyr0= github.com/danieljoos/wincred v1.1.2/go.mod h1:GijpziifJoIBfYh+S7BbkdUTU4LfM+QnGqR5Vl2tAx0= github.com/danwt/gerr v1.0.0 h1:v3Do0h1r+uctQQVYJfOTCo8uigp8oIaY4OL/wUU8LzI= @@ -770,8 +773,8 @@ github.com/davidlazar/go-crypto v0.0.0-20200604182044-b73af7476f6c h1:pFUpOrbxDR github.com/davidlazar/go-crypto v0.0.0-20200604182044-b73af7476f6c/go.mod h1:6UhI8N9EjYm1c2odKpFpAYeR8dsBeM7PtzQhRgxRr9U= github.com/decentrio/e2e-testing-live v0.0.0-20240718080249-ee255229c869 h1:qWpUYGOsrSC+1Vmd2TjhbsSpntvvx9PsX3AoeMunFxc= github.com/decentrio/e2e-testing-live v0.0.0-20240718080249-ee255229c869/go.mod h1:HZNYnPwmSxkwTPjSD5yolauc1Vx1ZzKL4FFMxTq4H5Y= -github.com/decentrio/rollup-e2e-testing v0.0.0-20240822112829-42feba8c484e h1:q4A/P+eXO7f0A2Tkn61W+Cr7He4dz7iLcxcrA6k7FAA= -github.com/decentrio/rollup-e2e-testing v0.0.0-20240822112829-42feba8c484e/go.mod h1:QmBrZgZplhtgHRWC0Z7LC7TDsKuC8sDyQvZyXXaqw/c= +github.com/decentrio/rollup-e2e-testing v0.0.0-20240925065439-bea0cdea5436 h1:6RhXRXX88ADn3xlL1FS6ybzZQuX4TOIA1JOdSWxyGuU= +github.com/decentrio/rollup-e2e-testing v0.0.0-20240925065439-bea0cdea5436/go.mod h1:QmBrZgZplhtgHRWC0Z7LC7TDsKuC8sDyQvZyXXaqw/c= github.com/deckarep/golang-set v1.8.0 h1:sk9/l/KqpunDwP7pSjUg0keiOOLEnOBHzykLrsPppp4= github.com/deckarep/golang-set v1.8.0/go.mod h1:5nI87KwE7wgsBU1F4GKAw2Qod7p5kyS383rP6+o6qqo= github.com/deckarep/golang-set/v2 v2.1.0 h1:g47V4Or+DUdzbs8FxCCmgb6VYd+ptPAngjM6dtGktsI= @@ -780,8 +783,6 @@ github.com/decred/base58 v1.0.4 h1:QJC6B0E0rXOPA8U/kw2rP+qiRJsUaE2Er+pYb3siUeA= github.com/decred/base58 v1.0.4/go.mod h1:jJswKPEdvpFpvf7dsDvFZyLT22xZ9lWqEByX38oGd9E= github.com/decred/dcrd/crypto/blake256 v1.0.1 h1:7PltbUIQB7u/FfZ39+DGa/ShuMyJ5ilcvdfma9wOH6Y= github.com/decred/dcrd/crypto/blake256 v1.0.1/go.mod h1:2OfgNZ5wDpcsFmHmCK5gZTPcCXqlm2ArzUIkw9czNJo= -github.com/decred/dcrd/dcrec/edwards v1.0.0 h1:UDcPNzclKiJlWqV3x1Fl8xMCJrolo4PB4X9t8LwKDWU= -github.com/decred/dcrd/dcrec/edwards v1.0.0/go.mod h1:HblVh1OfMt7xSxUL1ufjToaEvpbjpWvvTAUx4yem8BI= github.com/decred/dcrd/dcrec/secp256k1/v4 v4.2.0 h1:8UrgZ3GkP4i/CLijOJx79Yu+etlyjdBU4sfcs2WYQMs= github.com/decred/dcrd/dcrec/secp256k1/v4 v4.2.0/go.mod h1:v57UDF4pDQJcEfFUCRop3lJL149eHGSe9Jvczhzjo/0= github.com/desertbit/timer v0.0.0-20180107155436-c41aec40b27f h1:U5y3Y5UE0w7amNe7Z5G/twsBW0KEalRQXZzf8ufSh9I= @@ -818,14 +819,16 @@ github.com/dvsekhvalnov/jose2go v1.6.0 h1:Y9gnSnP4qEI0+/uQkHvFXeD2PLPJeXEL+ySMEA github.com/dvsekhvalnov/jose2go v1.6.0/go.mod h1:QsHjhyTlD/lAVqn/NSbVZmSCGeDehTB/mPZadG+mhXU= github.com/dymensionxyz/cosmosclient v0.4.2-beta.0.20240421130646-b8980ec7aade h1:LHbwDuI4hPNGSA+gWQz4ev0xt8p+ztPLEcZWR7e5YzA= github.com/dymensionxyz/cosmosclient v0.4.2-beta.0.20240421130646-b8980ec7aade/go.mod h1:UxhLdtWOWg7l6+5Hpkm39Khd23wcr5H62YxM04rMbh8= -github.com/dymensionxyz/dymension/v3 v3.1.0-rc03.0.20240717194206-54c0fca5fada h1:icRxU53BU7JtUspdTwo3Gwl0U/q8DsQwmXx4sUGowFc= -github.com/dymensionxyz/dymension/v3 v3.1.0-rc03.0.20240717194206-54c0fca5fada/go.mod h1:a/kNkXs3uPwYrn+P139a9zh+8r1rVpPFuPi7gn08Gck= -github.com/dymensionxyz/dymint v1.2.0-rc01 h1:zFHUXmy/07Bs7/qSRzGnGdRipgCm4GGAsoxF1+OCwS8= -github.com/dymensionxyz/dymint v1.2.0-rc01/go.mod h1:8ECqxpdco6NOSBTJCcbcUeBGTQClc+JQnHmyc5+3vKU= +github.com/dymensionxyz/dymension/v3 v3.1.0-rc03.0.20240911123104-4782bc4e587f h1:uYJurcggZdL+2si81VsmW4nzGwmhumFZ+Rml+peiPOs= +github.com/dymensionxyz/dymension/v3 v3.1.0-rc03.0.20240911123104-4782bc4e587f/go.mod h1:olFkQFRpTe6LHqZlTBN+gGaKkUYcF3q0GValXRJ0xSc= +github.com/dymensionxyz/dymint v1.2.0-rc01.0.20240919105350-66f9b353655d h1:YZ49Dd17SA//VBTKVncav7DhV5VE6M9n4a9Slm/hQeM= +github.com/dymensionxyz/dymint v1.2.0-rc01.0.20240919105350-66f9b353655d/go.mod h1:eEUBqDHi7EiO3CK1Fqct5joa5UeNzcEDJnXzvXuP5oA= github.com/dymensionxyz/ethermint v0.22.0-dymension-v0.4.1.0.20240625101522-b1506ae83050 h1:1mtlo6bDOdBihHWbDpOaai0NMC/4xHCkCHGCqdLT8WM= github.com/dymensionxyz/ethermint v0.22.0-dymension-v0.4.1.0.20240625101522-b1506ae83050/go.mod h1:aokD0im7cUMMtR/khzNsmcGtINtxCpBfcgRvJdmLymA= github.com/dymensionxyz/gerr-cosmos v1.0.0 h1:oi91rgOkpJWr41oX9JOyjvvBnhGY54tj513x8VlDAEc= github.com/dymensionxyz/gerr-cosmos v1.0.0/go.mod h1:n+0olxPogzWqFKba45mCpvrHLGmeS8W9UZjggHnWk6c= +github.com/dymensionxyz/sdk-utils v0.2.8 h1:ZX5NSLd0DyGVUqucHnyI14zkeYaD7hVn7v44MQOYFUU= +github.com/dymensionxyz/sdk-utils v0.2.8/go.mod h1:it9owYOpnIe17+ftTATQNDN4z+mBQx20/2Jm8SK15Rk= github.com/eapache/go-resiliency v1.1.0/go.mod h1:kFI+JgMyC7bLPUVY133qvEBtVayf5mFgVsvEsIPBvNs= github.com/eapache/go-xerial-snappy v0.0.0-20180814174437-776d5712da21/go.mod h1:+020luEh2TKB4/GOp8oxxtq0Daoen/Cii55CzbTV6DU= github.com/eapache/queue v1.1.0/go.mod h1:6eCeP0CKFpHLu8blIFXhExK/dRa7WDZfr6jVFPTqq+I= @@ -854,8 +857,8 @@ github.com/fatih/color v1.7.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5Kwzbycv github.com/felixge/httpsnoop v1.0.1/go.mod h1:m8KPJKqk1gH5J9DgRY2ASl2lWCfGKXixSwevea8zH2U= github.com/felixge/httpsnoop v1.0.4 h1:NFTV2Zj1bL4mc9sqWACXbQFVBBg2W3GPvqp8/ESS2Wg= github.com/felixge/httpsnoop v1.0.4/go.mod h1:m8KPJKqk1gH5J9DgRY2ASl2lWCfGKXixSwevea8zH2U= -github.com/filecoin-project/go-jsonrpc v0.3.1 h1:qwvAUc5VwAkooquKJmfz9R2+F8znhiqcNHYjEp/NM10= -github.com/filecoin-project/go-jsonrpc v0.3.1/go.mod h1:jBSvPTl8V1N7gSTuCR4bis8wnQnIjHbRPpROol6iQKM= +github.com/filecoin-project/go-jsonrpc v0.5.0 h1:6PZghgMaM9wSjlhxkDD+YgZ+oucBUIkJOfVc7SdQBTE= +github.com/filecoin-project/go-jsonrpc v0.5.0/go.mod h1:/n/niXcS4ZQua6i37LcVbY1TmlJR0UIK9mDFQq2ICek= github.com/fjl/memsize v0.0.0-20190710130421-bcb5799ab5e5 h1:FtmdgXiUlNeRsoNMFlKLDt+S+6hbjVMEW6RGQ7aUf7c= github.com/fjl/memsize v0.0.0-20190710130421-bcb5799ab5e5/go.mod h1:VvhXpOYNQvB+uIk2RvXzuaQtkQJzzIx6lSBe1xv7hi0= github.com/flynn/noise v1.1.0 h1:KjPQoQCEFdZDiP03phOvGi11+SVVhBG2wOWAorLsstg= @@ -1155,10 +1158,10 @@ github.com/hashicorp/go-version v1.6.0/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09 github.com/hashicorp/go.net v0.0.1/go.mod h1:hjKkEWcCURg++eb33jQU7oqQcI9XDCnUzHA0oac0k90= github.com/hashicorp/golang-lru v0.5.0/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8= github.com/hashicorp/golang-lru v0.5.1/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8= -github.com/hashicorp/golang-lru v0.5.5-0.20210104140557-80c98217689d h1:dg1dEPuWpEqDnvIw251EVy4zlP8gWbsGj4BsUKCRpYs= -github.com/hashicorp/golang-lru v0.5.5-0.20210104140557-80c98217689d/go.mod h1:iADmTwqILo4mZ8BN3D2Q6+9jd8WM5uGBxy+E8yxSoD4= -github.com/hashicorp/golang-lru/v2 v2.0.5 h1:wW7h1TG88eUIJ2i69gaE3uNVtEPIagzhGvHgwfx2Vm4= -github.com/hashicorp/golang-lru/v2 v2.0.5/go.mod h1:QeFd9opnmA6QUJc5vARoKUSoFhyfM2/ZepoAG6RGpeM= +github.com/hashicorp/golang-lru v1.0.2 h1:dV3g9Z/unq5DpblPpw+Oqcv4dU/1omnb4Ok8iPY6p1c= +github.com/hashicorp/golang-lru v1.0.2/go.mod h1:iADmTwqILo4mZ8BN3D2Q6+9jd8WM5uGBxy+E8yxSoD4= +github.com/hashicorp/golang-lru/v2 v2.0.7 h1:a+bsQ5rvGLjzHuww6tVxozPZFVghXaHOwFs4luLUK2k= +github.com/hashicorp/golang-lru/v2 v2.0.7/go.mod h1:QeFd9opnmA6QUJc5vARoKUSoFhyfM2/ZepoAG6RGpeM= github.com/hashicorp/hcl v1.0.0 h1:0Anlzjpi4vEasTeNFn2mLJgTSwt0+6sfsiTG8qcWGx4= github.com/hashicorp/hcl v1.0.0/go.mod h1:E5yfLk+7swimpb2L/Alb/PJmXilQ/rhwaUYs4T20WEQ= github.com/hashicorp/logutils v1.0.0/go.mod h1:QIAnNjmIWmVIIkWDTG1z5v++HQmx9WQRO+LraFDTW64= @@ -1192,18 +1195,40 @@ github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANyt github.com/inconshreveable/mousetrap v1.1.0 h1:wN+x4NVGpMsO7ErUn/mUI3vEoE6Jt13X2s0bqwp9tc8= github.com/inconshreveable/mousetrap v1.1.0/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw= github.com/influxdata/influxdb1-client v0.0.0-20191209144304-8bf82d3c094d/go.mod h1:qj24IKcXYK6Iy9ceXlo3Tc+vtHo9lIhSX5JddghvEPo= -github.com/ipfs/boxo v0.10.0 h1:tdDAxq8jrsbRkYoF+5Rcqyeb91hgWe2hp7iLu7ORZLY= -github.com/ipfs/boxo v0.10.0/go.mod h1:Fg+BnfxZ0RPzR0nOodzdIq3A7KgoWAOWsEIImrIQdBM= +github.com/ipfs/bbloom v0.0.4 h1:Gi+8EGJ2y5qiD5FbsbpX/TMNcJw8gSqr7eyjHa4Fhvs= +github.com/ipfs/bbloom v0.0.4/go.mod h1:cS9YprKXpoZ9lT0n/Mw/a6/aFV6DTjTLYHeA+gyqMG0= +github.com/ipfs/boxo v0.18.0 h1:MOL9/AgoV3e7jlVMInicaSdbgralfqSsbkc31dZ9tmw= +github.com/ipfs/boxo v0.18.0/go.mod h1:pIZgTWdm3k3pLF9Uq6MB8JEcW07UDwNJjlXW1HELW80= +github.com/ipfs/go-block-format v0.2.0 h1:ZqrkxBA2ICbDRbK8KJs/u0O3dlp6gmAuuXUJNiW1Ycs= +github.com/ipfs/go-block-format v0.2.0/go.mod h1:+jpL11nFx5A/SPpsoBn6Bzkra/zaArfSmsknbPMYgzM= github.com/ipfs/go-cid v0.4.1 h1:A/T3qGvxi4kpKWWcPC/PgbvDA2bjVLO7n4UeVwnbs/s= github.com/ipfs/go-cid v0.4.1/go.mod h1:uQHwDeX4c6CtyrFwdqyhpNcxVewur1M7l7fNU7LKwZk= github.com/ipfs/go-datastore v0.6.0 h1:JKyz+Gvz1QEZw0LsX1IBn+JFCJQH4SJVFtM4uWU0Myk= github.com/ipfs/go-datastore v0.6.0/go.mod h1:rt5M3nNbSO/8q1t4LNkLyUwRs8HupMeN/8O4Vn9YAT8= +github.com/ipfs/go-ds-leveldb v0.5.0 h1:s++MEBbD3ZKc9/8/njrn4flZLnCuY9I79v94gBUNumo= +github.com/ipfs/go-ds-leveldb v0.5.0/go.mod h1:d3XG9RUDzQ6V4SHi8+Xgj9j1XuEk1z82lquxrVbml/Q= +github.com/ipfs/go-ipfs-delay v0.0.1 h1:r/UXYyRcddO6thwOnhiznIAiSvxMECGgtv35Xs1IeRQ= +github.com/ipfs/go-ipfs-delay v0.0.1/go.mod h1:8SP1YXK1M1kXuc4KJZINY3TQQ03J2rwBG9QfXmbRPrw= +github.com/ipfs/go-ipfs-pq v0.0.3 h1:YpoHVJB+jzK15mr/xsWC574tyDLkezVrDNeaalQBsTE= +github.com/ipfs/go-ipfs-pq v0.0.3/go.mod h1:btNw5hsHBpRcSSgZtiNm/SLj5gYIZ18AKtv3kERkRb4= +github.com/ipfs/go-ipfs-util v0.0.3 h1:2RFdGez6bu2ZlZdI+rWfIdbQb1KudQp3VGwPtdNCmE0= +github.com/ipfs/go-ipfs-util v0.0.3/go.mod h1:LHzG1a0Ig4G+iZ26UUOMjHd+lfM84LZCrn17xAKWBvs= +github.com/ipfs/go-ipld-format v0.6.0 h1:VEJlA2kQ3LqFSIm5Vu6eIlSxD/Ze90xtc4Meten1F5U= +github.com/ipfs/go-ipld-format v0.6.0/go.mod h1:g4QVMTn3marU3qXchwjpKPKgJv+zF+OlaKMyhJ4LHPg= +github.com/ipfs/go-ipld-legacy v0.2.1 h1:mDFtrBpmU7b//LzLSypVrXsD8QxkEWxu5qVxN99/+tk= +github.com/ipfs/go-ipld-legacy v0.2.1/go.mod h1:782MOUghNzMO2DER0FlBR94mllfdCJCkTtDtPM51otM= github.com/ipfs/go-log v1.0.5 h1:2dOuUCB1Z7uoczMWgAyDck5JLb72zHzrMnGnCNNbvY8= github.com/ipfs/go-log v1.0.5/go.mod h1:j0b8ZoR+7+R99LD9jZ6+AJsrzkPbSXbZfGakb5JPtIo= github.com/ipfs/go-log/v2 v2.5.1 h1:1XdUzF7048prq4aBjDQQ4SL5RxftpRGdXhNRwKSAlcY= github.com/ipfs/go-log/v2 v2.5.1/go.mod h1:prSpmC1Gpllc9UYWxDiZDreBYw7zp4Iqp1kOLU9U5UI= -github.com/ipld/go-ipld-prime v0.20.0 h1:Ud3VwE9ClxpO2LkCYP7vWPc0Fo+dYdYzgxUJZ3uRG4g= -github.com/ipld/go-ipld-prime v0.20.0/go.mod h1:PzqZ/ZR981eKbgdr3y2DJYeD/8bgMawdGVlJDE8kK+M= +github.com/ipfs/go-metrics-interface v0.0.1 h1:j+cpbjYvu4R8zbleSs36gvB7jR+wsL2fGD6n0jO4kdg= +github.com/ipfs/go-metrics-interface v0.0.1/go.mod h1:6s6euYU4zowdslK0GKHmqaIZ3j/b/tL7HTWtJ4VPgWY= +github.com/ipfs/go-peertaskqueue v0.8.1 h1:YhxAs1+wxb5jk7RvS0LHdyiILpNmRIRnZVztekOF0pg= +github.com/ipfs/go-peertaskqueue v0.8.1/go.mod h1:Oxxd3eaK279FxeydSPPVGHzbwVeHjatZ2GA8XD+KbPU= +github.com/ipld/go-codec-dagpb v1.6.0 h1:9nYazfyu9B1p3NAgfVdpRco3Fs2nFC72DqVsMj6rOcc= +github.com/ipld/go-codec-dagpb v1.6.0/go.mod h1:ANzFhfP2uMJxRBr8CE+WQWs5UsNa0pYtmKZ+agnUw9s= +github.com/ipld/go-ipld-prime v0.21.0 h1:n4JmcpOlPDIxBcY037SVfpd1G+Sj1nKZah0m6QH9C2E= +github.com/ipld/go-ipld-prime v0.21.0/go.mod h1:3RLqy//ERg/y5oShXXdx5YIp50cFGOanyMctpPjsvxQ= github.com/jackpal/go-nat-pmp v1.0.2 h1:KzKSgb7qkJvOUTqYl9/Hg/me3pWgBmERKrTGD7BdWus= github.com/jackpal/go-nat-pmp v1.0.2/go.mod h1:QPH045xvCAeXUZOxsnwmrtiCoxIr9eob+4orBN1SBKc= github.com/jbenet/go-temp-err-catcher v0.1.0 h1:zpb3ZH6wIE8Shj2sKS+khgRvf7T7RABoLk/+KKHggpk= @@ -1288,12 +1313,14 @@ github.com/libp2p/go-libp2p-kad-dht v0.25.2 h1:FOIk9gHoe4YRWXTu8SY9Z1d0RILol0Trt github.com/libp2p/go-libp2p-kad-dht v0.25.2/go.mod h1:6za56ncRHYXX4Nc2vn8z7CZK0P4QiMcrn77acKLM2Oo= github.com/libp2p/go-libp2p-kbucket v0.6.3 h1:p507271wWzpy2f1XxPzCQG9NiN6R6lHL9GiSErbQQo0= github.com/libp2p/go-libp2p-kbucket v0.6.3/go.mod h1:RCseT7AH6eJWxxk2ol03xtP9pEHetYSPXOaJnOiD8i0= -github.com/libp2p/go-libp2p-pubsub v0.9.3 h1:ihcz9oIBMaCK9kcx+yHWm3mLAFBMAUsM4ux42aikDxo= -github.com/libp2p/go-libp2p-pubsub v0.9.3/go.mod h1:RYA7aM9jIic5VV47WXu4GkcRxRhrdElWf8xtyli+Dzc= +github.com/libp2p/go-libp2p-pubsub v0.10.1 h1:/RqOZpEtAolsr8/9CC8KqROJSOZeu7lK7fPftn4MwNg= +github.com/libp2p/go-libp2p-pubsub v0.10.1/go.mod h1:1OxbaT/pFRO5h+Dpze8hdHQ63R0ke55XTs6b6NwLLkw= github.com/libp2p/go-libp2p-record v0.2.0 h1:oiNUOCWno2BFuxt3my4i1frNrt7PerzB3queqa1NkQ0= github.com/libp2p/go-libp2p-record v0.2.0/go.mod h1:I+3zMkvvg5m2OcSdoL0KPljyJyvNDFGKX7QdlpYUcwk= -github.com/libp2p/go-libp2p-routing-helpers v0.7.2 h1:xJMFyhQ3Iuqnk9Q2dYE1eUTzsah7NLw3Qs2zjUV78T0= -github.com/libp2p/go-libp2p-routing-helpers v0.7.2/go.mod h1:cN4mJAD/7zfPKXBcs9ze31JGYAZgzdABEm+q/hkswb8= +github.com/libp2p/go-libp2p-routing-helpers v0.7.3 h1:u1LGzAMVRK9Nqq5aYDVOiq/HaB93U9WWczBzGyAC5ZY= +github.com/libp2p/go-libp2p-routing-helpers v0.7.3/go.mod h1:cN4mJAD/7zfPKXBcs9ze31JGYAZgzdABEm+q/hkswb8= +github.com/libp2p/go-libp2p-testing v0.12.0 h1:EPvBb4kKMWO29qP4mZGyhVzUyR25dvfUIK5WDu6iPUA= +github.com/libp2p/go-libp2p-testing v0.12.0/go.mod h1:KcGDRXyN7sQCllucn1cOOS+Dmm7ujhfEyXQL5lvkcPg= github.com/libp2p/go-msgio v0.3.0 h1:mf3Z8B1xcFN314sWX+2vOTShIE0Mmn2TXn3YCUQGNj0= github.com/libp2p/go-msgio v0.3.0/go.mod h1:nyRM819GmVaF9LX3l03RMh10QdOroF++NBbxAb0mmDM= github.com/libp2p/go-nat v0.2.0 h1:Tyz+bUFAYqGyJ/ppPPymMGbIgNRH+WqC5QrT5fKrrGk= @@ -1325,6 +1352,7 @@ github.com/mattn/go-colorable v0.1.13/go.mod h1:7S9/ev0klgBDR4GtXTXX8a3vIGJpMovk github.com/mattn/go-isatty v0.0.3/go.mod h1:M+lRXTBqGeGNdLjl/ufCoiOlB5xdOkqRJdNxMWT7Zi4= github.com/mattn/go-isatty v0.0.4/go.mod h1:M+lRXTBqGeGNdLjl/ufCoiOlB5xdOkqRJdNxMWT7Zi4= github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU= +github.com/mattn/go-isatty v0.0.14/go.mod h1:7GGIvUiUoEMVVmxf/4nioHXj79iQHKdU27kJ6hsGG94= github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM= github.com/mattn/go-isatty v0.0.19/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y= github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY= @@ -1368,8 +1396,8 @@ github.com/mitchellh/mapstructure v1.5.0 h1:jeMsZIYE/09sWLaz43PL7Gy6RuMjD2eJVyua github.com/mitchellh/mapstructure v1.5.0/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo= github.com/mitchellh/pointerstructure v1.2.0 h1:O+i9nHnXS3l/9Wu7r4NrEdwA2VFTicjUEN1uBnDo34A= github.com/mitchellh/pointerstructure v1.2.0/go.mod h1:BRAsLI5zgXmw97Lf6s25bs8ohIXc3tViBH44KcwB2g4= -github.com/moby/term v0.5.0 h1:xt8Q1nalod/v7BqbG21f8mQPqH+xAaC9C3N3wfWbVP0= -github.com/moby/term v0.5.0/go.mod h1:8FzsFHVUBGZdbDsJw/ot+X+d5HLUbvklYLJ9uGfcI3Y= +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/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd h1:TRLaZ9cD/w8PVh93nsPXa1VrQ6jlwL5oN8l14QlcNfg= github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= @@ -1387,8 +1415,8 @@ github.com/multiformats/go-base32 v0.1.0 h1:pVx9xoSPqEIQG8o+UbAe7DNi51oej1NtK+aG github.com/multiformats/go-base32 v0.1.0/go.mod h1:Kj3tFY6zNr+ABYMqeUNeGvkIC/UYgtWibDcT0rExnbI= github.com/multiformats/go-base36 v0.2.0 h1:lFsAbNOGeKtuKozrtBsAkSVhv1p9D0/qedU9rQyccr0= github.com/multiformats/go-base36 v0.2.0/go.mod h1:qvnKE++v+2MWCfePClUEjE78Z7P2a1UV0xHgWc0hkp4= -github.com/multiformats/go-multiaddr v0.12.2 h1:9G9sTY/wCYajKa9lyfWPmpZAwe6oV+Wb1zcmMS1HG24= -github.com/multiformats/go-multiaddr v0.12.2/go.mod h1:GKyaTYjZRdcUhyOetrxTk9z0cW+jA/YrnqTOvKgi44M= +github.com/multiformats/go-multiaddr v0.10.0 h1:onErs0qLf3P2oRqrYk1fAMcfrWaJb58pYY43SkEF78w= +github.com/multiformats/go-multiaddr v0.10.0/go.mod h1:jLEZsA61rwWNZQTHHnqq2HNa+4os/Hz54eqiRnsRqYQ= github.com/multiformats/go-multiaddr-dns v0.3.1 h1:QgQgR+LQVt3NPTjbrLLpsaT2ufAA2y0Mkk+QRVJbW3A= github.com/multiformats/go-multiaddr-dns v0.3.1/go.mod h1:G/245BRQ6FJGmryJCrOuTdB37AMA5AMOVuO6NY3JwTk= github.com/multiformats/go-multiaddr-fmt v0.1.0 h1:WLEFClPycPkp4fnIzoFoV9FVd49/eQsuaL3/CWe167E= @@ -1441,8 +1469,8 @@ github.com/opencontainers/go-digest v1.0.0 h1:apOUWs51W5PlhuyGyz9FCeeBIOUDA/6nW8 github.com/opencontainers/go-digest v1.0.0/go.mod h1:0JzlMkj0TRzQZfJkVvzbP0HBR3IKzErnv2BNG4W4MAM= github.com/opencontainers/image-spec v1.1.0-rc2 h1:2zx/Stx4Wc5pIPDvIxHXvXtQFW/7XWJGmnM7r3wg034= github.com/opencontainers/image-spec v1.1.0-rc2/go.mod h1:3OVijpioIKYWTqjiG0zfF6wvoJ4fAXGbjdZuI2NgsRQ= -github.com/opencontainers/runc v1.1.7 h1:y2EZDS8sNng4Ksf0GUYNhKbTShZJPJg1FiXJNH/uoCk= -github.com/opencontainers/runc v1.1.7/go.mod h1:CbUumNnWCuTGFukNXahoo/RFBZvDAgRh/smNYNOhA50= +github.com/opencontainers/runc v1.1.5 h1:L44KXEpKmfWDcS02aeGm8QNTFXTo2D+8MYGDIJ/GDEs= +github.com/opencontainers/runc v1.1.5/go.mod h1:1J5XiS+vdZ3wCyZybsuxXZWGrgSr8fFJHLXuG2PsnNg= github.com/opencontainers/runtime-spec v1.2.0 h1:z97+pHb3uELt/yiAWD691HNHQIF07bE7dzrbT927iTk= github.com/opencontainers/runtime-spec v1.2.0/go.mod h1:jwyrGlmzljRJv/Fgzds9SsS/C5hL+LL3ko9hs6T5lQ0= github.com/opentracing-contrib/go-observer v0.0.0-20170622124052-a52f23424492/go.mod h1:Ngi6UdF0k5OKD5t5wlmGhe/EDKPoUM3BXZSSfIuJbis= @@ -1553,8 +1581,8 @@ github.com/rogpeppe/fastuuid v1.2.0/go.mod h1:jVj6XXZzXRy/MSR5jhDC/2q6DgLz+nrA6L github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4= github.com/rogpeppe/go-internal v1.6.1/go.mod h1:xXDCJY+GAPziupqXw64V24skbSoqbTEfhy4qGm1nDQc= github.com/rogpeppe/go-internal v1.9.0/go.mod h1:WtVeX8xhTBvf0smdhujwtBcq4Qrzq/fJaraNFVN+nFs= -github.com/rogpeppe/go-internal v1.11.0 h1:cWPaGQEPrBb5/AsnsZesgZZ9yb1OQ+GOISoDNXVBh4M= -github.com/rogpeppe/go-internal v1.11.0/go.mod h1:ddIwULY96R17DhadqLgMfk9H9tvdUzkipdSkR5nkCZA= +github.com/rogpeppe/go-internal v1.12.0 h1:exVL4IDcn6na9z1rAb56Vxr+CgyK3nn3O+epU5NdKM8= +github.com/rogpeppe/go-internal v1.12.0/go.mod h1:E+RYuTGaKKdloAfM02xzb0FW3Paa99yedzYV+kq4uf4= github.com/rs/cors v1.7.0/go.mod h1:gFx+x8UowdsKA9AchylcLynDq+nNFfI8FkUZdN/jGCU= github.com/rs/cors v1.9.0 h1:l9HGsTsHJcvW14Nk7J9KFz8bzeAWXn3CG6bgt7LsrAE= github.com/rs/cors v1.9.0/go.mod h1:XyqrcTp5zjWr1wsJ8PIRZssZ8b/WMcMf71DJnit4EMU= @@ -1681,6 +1709,8 @@ github.com/urfave/cli/v2 v2.17.2-0.20221006022127-8f469abc00aa h1:5SqCsI/2Qya2bC github.com/urfave/cli/v2 v2.17.2-0.20221006022127-8f469abc00aa/go.mod h1:1CNUng3PtjQMtRzJO4FMXBQvkGtuYRxxiR9xMa7jMwI= github.com/vedhavyas/go-subkey v1.0.3 h1:iKR33BB/akKmcR2PMlXPBeeODjWLM90EL98OrOGs8CA= github.com/vedhavyas/go-subkey v1.0.3/go.mod h1:CloUaFQSSTdWnINfBRFjVMkWXZANW+nd8+TI5jYcl6Y= +github.com/whyrusleeping/chunker v0.0.0-20181014151217-fe64bd25879f h1:jQa4QT2UP9WYv2nzyawpKMOCl+Z/jW7djv2/J50lj9E= +github.com/whyrusleeping/chunker v0.0.0-20181014151217-fe64bd25879f/go.mod h1:p9UJB6dDgdPgMJZs7UjUOdulKyRr9fqkS+6JKAInPy8= github.com/whyrusleeping/go-keyspace v0.0.0-20160322163242-5b898ac5add1 h1:EKhdznlJHPMoKr0XTrX+IlJs1LH3lyx2nfr1dOlZ79k= github.com/whyrusleeping/go-keyspace v0.0.0-20160322163242-5b898ac5add1/go.mod h1:8UvriyWtv5Q5EOgjHaSseUEdkQfvwFv1I/In/O2M9gc= github.com/xiang90/probing v0.0.0-20190116061207-43a291ad63a2/go.mod h1:UETIi67q53MR2AWcXfiuqkDkRtnGDLqkBTpCHuJHxtU= @@ -1744,6 +1774,7 @@ go.uber.org/dig v1.17.1/go.mod h1:Us0rSJiThwCv2GteUN0Q7OKvU7n5J4dxZ9JKUXozFdE= go.uber.org/fx v1.20.1 h1:zVwVQGS8zYvhh9Xxcu4w1M6ESyeMzebzj2NbSayZ4Mk= go.uber.org/fx v1.20.1/go.mod h1:iSYNbHf2y55acNCwCXKx7LbWb5WG1Bnue5RDXz1OREg= go.uber.org/goleak v1.1.10/go.mod h1:8a7PlsEVH3e/a/GLqe5IIrQx6GzcnRmZEufDUTk4A7A= +go.uber.org/goleak v1.1.11-0.20210813005559-691160354723/go.mod h1:cwTWslyiVhfpKIDGSZEM2HlOvcqm+tG4zioyIeLoqMQ= go.uber.org/goleak v1.3.0 h1:2K3zAYmnTNqV73imy9J1T3WC+gmCePx2hEGkimedGto= go.uber.org/goleak v1.3.0/go.mod h1:CoHD4mav9JJNrW/WLlf7HGZPjdw8EucARQHekz1X6bE= go.uber.org/mock v0.4.0 h1:VcM4ZOtdbR4f6VXfiOpwpVJDL6lCReaZ6mw31wqh7KU= @@ -1757,6 +1788,7 @@ go.uber.org/tools v0.0.0-20190618225709-2cfd321de3ee/go.mod h1:vJERXedbb3MVM5f9E go.uber.org/zap v1.10.0/go.mod h1:vwi/ZaCAaUcBkycHslxD9B2zi4UTXhF60s6SWpuDF0Q= go.uber.org/zap v1.13.0/go.mod h1:zwrFLgMcdUuIBviXEYEH1YKNaOBnKXsx2IPda5bBwHM= go.uber.org/zap v1.18.1/go.mod h1:xg/QME4nWcxGxrpdeYfq7UvYrLh66cuVKdrbD1XF/NI= +go.uber.org/zap v1.19.1/go.mod h1:j3DNczoxDZroyBnOT1L/Q79cfUMGZxlv/9dzN7SM1rI= go.uber.org/zap v1.27.0 h1:aJMhYGrd5QSmlpLMr2MftRKl7t8J8PTZPA732ud/XR8= go.uber.org/zap v1.27.0/go.mod h1:GB2qFLM7cTU87MWRP2mPIjqfIDnGu+VIO4V/SdhGo2E= golang.org/x/crypto v0.0.0-20180904163835-0709b304e793/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= @@ -2168,8 +2200,8 @@ gonum.org/v1/gonum v0.0.0-20180816165407-929014505bf4/go.mod h1:Y+Yx5eoAFn32cQvJ gonum.org/v1/gonum v0.8.2/go.mod h1:oe/vMfY3deqTw+1EZJhuvEW2iwGF1bW9wwu7XCu0+v0= gonum.org/v1/gonum v0.9.3/go.mod h1:TZumC3NeyVQskjXqmyWt4S3bINhy7B4eYwW69EbyX+0= gonum.org/v1/gonum v0.11.0/go.mod h1:fSG4YDCxxUZQJ7rKsQrj0gMOg00Il0Z96/qMA4bVQhA= -gonum.org/v1/gonum v0.13.0 h1:a0T3bh+7fhRyqeNbiC3qVHYmkiQgit3wnNan/2c0HMM= -gonum.org/v1/gonum v0.13.0/go.mod h1:/WPYRckkfWrhWefxyYTfrTtQR0KH4iyHNuzxqXAKyAU= +gonum.org/v1/gonum v0.14.0 h1:2NiG67LD1tEH0D7kM+ps2V+fXmsAnpUeec7n8tcr4S0= +gonum.org/v1/gonum v0.14.0/go.mod h1:AoWeoz0becf9QMWtE8iWXNXc27fK4fNeHNf/oMejGfU= gonum.org/v1/netlib v0.0.0-20190313105609-8cb42192e0e0/go.mod h1:wa6Ws7BG/ESfp6dHfk7C6KdzKA7wR7u/rKwOGE66zvw= gonum.org/v1/plot v0.0.0-20190515093506-e2840ee46a6b/go.mod h1:Wt8AAjI+ypCyYX3nZBvf6cAIx93T+c/OS2HFAYskSZc= gonum.org/v1/plot v0.9.0/go.mod h1:3Pcqqmp6RHvJI72kgb8fThyUnav364FOsdDo2aGW5lY= diff --git a/live-tests/eibc_3rd_token_test.go b/live-tests/eibc_3rd_token_test.go index 784c1aca..b165aaee 100644 --- a/live-tests/eibc_3rd_token_test.go +++ b/live-tests/eibc_3rd_token_test.go @@ -173,7 +173,7 @@ func TestEIBC_3rd_Token_RolY_Live(t *testing.T) { // get eIbc event encoding := encodingConfig() - eibcEvents, err := getEIbcEventsWithinBlockRange(ctx, &hub, 20, false, encoding.InterfaceRegistry) + eibcEvents, err := getEIbcEventsWithinBlockRange(ctx, &hub, 30, false, encoding.InterfaceRegistry) require.NoError(t, err) for i, eibcEvent := range eibcEvents { fmt.Println(i, "EIBC Event:", eibcEvent) @@ -184,7 +184,7 @@ func TestEIBC_3rd_Token_RolY_Live(t *testing.T) { re := regexp.MustCompile(`^\d+`) if re.ReplaceAllString(eibcEvent.Price, "") == mochaIBCDenom && eibcEvent.PacketStatus == "PENDING" { fmt.Println("EIBC Event:", eibcEvent) - _, err := cosmos.FullfillDemandOrder(&hub, eibcEvent.ID, marketMaker.Address, dymFee) + _, err := cosmos.FullfillDemandOrder(&hub, eibcEvent.OrderId, marketMaker.Address, dymFee) require.NoError(t, err) } } @@ -331,7 +331,7 @@ func TestEIBC_3rd_Token_Timeout_RolY_Live(t *testing.T) { // get eIbc event encoding := encodingConfig() - eibcEvents, err := getEIbcEventsWithinBlockRange(ctx, &hub, 20, false, encoding.InterfaceRegistry) + eibcEvents, err := getEIbcEventsWithinBlockRange(ctx, &hub, 30, false, encoding.InterfaceRegistry) require.NoError(t, err) for i, eibcEvent := range eibcEvents { fmt.Println(i, "EIBC Event:", eibcEvent) @@ -342,7 +342,7 @@ func TestEIBC_3rd_Token_Timeout_RolY_Live(t *testing.T) { re := regexp.MustCompile(`^\d+`) if re.ReplaceAllString(eibcEvent.Price, "") == mochaIBCDenom && eibcEvent.PacketStatus == "PENDING" { fmt.Println("EIBC Event:", eibcEvent) - _, err := cosmos.FullfillDemandOrder(&hub, eibcEvent.ID, marketMaker.Address, dymFee) + _, err := cosmos.FullfillDemandOrder(&hub, eibcEvent.OrderId, marketMaker.Address, dymFee) require.NoError(t, err) } } diff --git a/live-tests/eibc_demand_order_ignored_test.go b/live-tests/eibc_demand_order_ignored_test.go index a3bc079d..e5114c83 100644 --- a/live-tests/eibc_demand_order_ignored_test.go +++ b/live-tests/eibc_demand_order_ignored_test.go @@ -80,6 +80,6 @@ func TestEIBC_Demand_Order_Ignored_RolX_Live(t *testing.T) { require.NoError(t, err) encoding := encodingConfig() - _, err = getEIbcEventsWithinBlockRange(ctx, &hub, 10, false, encoding.InterfaceRegistry) + _, err = getEIbcEventsWithinBlockRange(ctx, &hub, 30, false, encoding.InterfaceRegistry) require.Error(t, err, "There wasn't a single 'eibc' event registered within the specified block range on the hub") } diff --git a/live-tests/eibc_fulfillment_test.go b/live-tests/eibc_fulfillment_test.go index f3295b48..a0009b4a 100644 --- a/live-tests/eibc_fulfillment_test.go +++ b/live-tests/eibc_fulfillment_test.go @@ -123,7 +123,6 @@ func TestEIBCFulfillRolX_Live(t *testing.T) { cosmos.SendIBCTransfer(rollappX, channelIDRollappXDym, rollappXUser.Address, transferDataRollAppXToHub, rolxFee, options) require.NoError(t, err) - // Check non-fulfill testutil.AssertBalance(t, ctx, dymensionUser, rollappXIBCDenom, hub.GrpcAddr, math.ZeroInt()) @@ -138,9 +137,9 @@ func TestEIBCFulfillRolX_Live(t *testing.T) { // fulfill demand orders from rollapp 1 for _, eibcEvent := range eibcEvents { re := regexp.MustCompile(`^\d+`) - if re.ReplaceAllString(eibcEvent.Price, "") == rollappXIBCDenom && eibcEvent.PacketStatus == "PENDING"{ + if re.ReplaceAllString(eibcEvent.Price, "") == rollappXIBCDenom && eibcEvent.PacketStatus == "PENDING" { fmt.Println("EIBC Event:", eibcEvent) - _, err := cosmos.FullfillDemandOrder(&hub, eibcEvent.ID, marketMaker.Address, dymFee) + _, err := cosmos.FullfillDemandOrder(&hub, eibcEvent.OrderId, marketMaker.Address, dymFee) require.NoError(t, err) } } diff --git a/live-tests/eibc_invalid_fee_test.go b/live-tests/eibc_invalid_fee_test.go index e3d06d51..fcdb15c7 100644 --- a/live-tests/eibc_invalid_fee_test.go +++ b/live-tests/eibc_invalid_fee_test.go @@ -106,7 +106,7 @@ func TestEIBC_Invalid_Fee_RolX_Live(t *testing.T) { fmt.Println(rollappXHeight) encoding := encodingConfig() - eibcEvents, err := getEIbcEventsWithinBlockRange(ctx, &hub, 40, false, encoding.InterfaceRegistry) + eibcEvents, err := getEIbcEventsWithinBlockRange(ctx, &hub, 30, false, encoding.InterfaceRegistry) require.NoError(t, err) for i, eibcEvent := range eibcEvents { fmt.Println(i, "EIBC Event:", eibcEvent) diff --git a/live-tests/eibc_no_memo_test.go b/live-tests/eibc_no_memo_test.go index 63da88e0..2bb73e3f 100644 --- a/live-tests/eibc_no_memo_test.go +++ b/live-tests/eibc_no_memo_test.go @@ -74,7 +74,7 @@ func TestEIBC_No_Memo_RolX_Live(t *testing.T) { require.NoError(t, err) encoding := encodingConfig() - eibcEvents, _ := getEIbcEventsWithinBlockRange(ctx, &hub, 20, false, encoding.InterfaceRegistry) + eibcEvents, _ := getEIbcEventsWithinBlockRange(ctx, &hub, 30, false, encoding.InterfaceRegistry) require.Equal(t, len(eibcEvents), 0) } diff --git a/live-tests/setup.go b/live-tests/setup.go index e39dcb4b..f3f73532 100644 --- a/live-tests/setup.go +++ b/live-tests/setup.go @@ -88,7 +88,7 @@ func encodingConfig() *util.TestEncodingConfig { } func getEibcEventFromTx(t *testing.T, dymension *cosmos.CosmosChain, txResp types.TxResponse) *dymensiontesting.EibcEvent { - const evType = "eibc" + const evType = "dymensionxyz.dymension.eibc.EventDemandOrderFulfilled" events := txResp.Events var ( @@ -100,10 +100,10 @@ func getEibcEventFromTx(t *testing.T, dymension *cosmos.CosmosChain, txResp type ) eibcEvent := new(dymensiontesting.EibcEvent) - eibcEvent.ID = id + eibcEvent.OrderId = id eibcEvent.Price = price eibcEvent.Fee = fee - checkFulfilled, err := strconv.ParseBool(isFulfilled) + checkFulfilled, err := strconv.ParseBool(isFulfilled) if err != nil { require.NoError(t, err) return nil diff --git a/tests/admc_test.go b/tests/admc_test.go index 6304e94a..3cf4452e 100644 --- a/tests/admc_test.go +++ b/tests/admc_test.go @@ -34,7 +34,8 @@ func TestADMC_Originates_HubtoRA_EVM(t *testing.T) { dymintTomlOverrides["settlement_gas_prices"] = "0adym" dymintTomlOverrides["max_idle_time"] = "3s" dymintTomlOverrides["max_proof_time"] = "500ms" - dymintTomlOverrides["batch_submit_max_time"] = "100s" + dymintTomlOverrides["batch_submit_time"] = "50s" + dymintTomlOverrides["p2p_blocksync_enabled"] = "false" configFileOverrides["config/dymint.toml"] = dymintTomlOverrides // Create chain factory with dymension @@ -109,7 +110,7 @@ func TestADMC_Originates_HubtoRA_EVM(t *testing.T) { // This can be used to write to the block database which will index all block data e.g. txs, msgs, events, etc. // BlockDatabaseFile: test.DefaultBlockDatabaseFilepath(), - }, nil, "", nil) + }, nil, "", nil, false, 780) require.NoError(t, err) CreateChannel(ctx, t, r, eRep, dymension.CosmosChain, rollapp1.CosmosChain, ibcPath) @@ -141,6 +142,9 @@ func TestADMC_Originates_HubtoRA_EVM(t *testing.T) { _, err = rollapp1.SendIBCTransfer(ctx, channel.ChannelID, rollappUserAddr, transferData, ibc.TransferOptions{}) require.NoError(t, err) + err = testutil.WaitForBlocks(ctx, 10, dymension, rollapp1) + require.NoError(t, err) + rollappHeight, err := rollapp1.GetNode().Height(ctx) require.NoError(t, err) @@ -152,6 +156,14 @@ func TestADMC_Originates_HubtoRA_EVM(t *testing.T) { require.NoError(t, err) require.True(t, isFinalized) + txhash, err := dymension.GetNode().FinalizePacketsUntilHeight(ctx, dymensionUserAddr, rollapp1.GetChainID(), fmt.Sprint(rollappHeight)) + require.NoError(t, err) + + fmt.Println(txhash) + + err = testutil.WaitForBlocks(ctx, 10, dymension, rollapp1) + require.NoError(t, err) + // Get the IBC denom for urax on Hub rollappTokenDenom := transfertypes.GetPrefixedDenom(channel.Counterparty.PortID, channel.Counterparty.ChannelID, rollapp1.Config().Denom) rollappIBCDenom := transfertypes.ParseDenomTrace(rollappTokenDenom).IBCDenom() @@ -182,6 +194,8 @@ func TestADMC_Originates_HubtoRA_EVM(t *testing.T) { require.Equal(t, "urax", resp.Metadatas[0].Base) testutil.AssertBalance(t, ctx, rollapp1, rollappUserAddr, rollapp1.Config().Denom, walletAmount.Sub(bridgingFee)) + // Run invariant check + CheckInvariant(t, ctx, dymension, dymensionUser.KeyName()) } func TestADMC_Migrate_Empty_User_Memo_EVM(t *testing.T) { @@ -199,7 +213,8 @@ func TestADMC_Migrate_Empty_User_Memo_EVM(t *testing.T) { dymintTomlOverrides["settlement_gas_prices"] = "0adym" dymintTomlOverrides["max_idle_time"] = "3s" dymintTomlOverrides["max_proof_time"] = "500ms" - dymintTomlOverrides["batch_submit_max_time"] = "100s" + dymintTomlOverrides["batch_submit_time"] = "50s" + dymintTomlOverrides["p2p_blocksync_enabled"] = "false" configFileOverrides["config/dymint.toml"] = dymintTomlOverrides // Create chain factory with dymension @@ -274,7 +289,7 @@ func TestADMC_Migrate_Empty_User_Memo_EVM(t *testing.T) { // This can be used to write to the block database which will index all block data e.g. txs, msgs, events, etc. // BlockDatabaseFile: test.DefaultBlockDatabaseFilepath(), - }, nil, "", nil) + }, nil, "", nil, false, 780) require.NoError(t, err) CreateChannel(ctx, t, r, eRep, dymension.CosmosChain, rollapp1.CosmosChain, ibcPath) @@ -299,7 +314,7 @@ func TestADMC_Migrate_Empty_User_Memo_EVM(t *testing.T) { resp, err := dymension.GetNode().QueryAllDenomMetadata(ctx) require.NoError(t, err) - require.Equal(t, 2, len(resp.Metadatas)) + require.Equal(t, 1, len(resp.Metadatas)) // Send a normal ibc tx from RA -> Hub transferData := ibc.WalletData{ @@ -310,6 +325,9 @@ func TestADMC_Migrate_Empty_User_Memo_EVM(t *testing.T) { _, err = rollapp1.SendIBCTransfer(ctx, channel.ChannelID, rollappUserAddr, transferData, ibc.TransferOptions{}) require.NoError(t, err) + err = testutil.WaitForBlocks(ctx, 10, dymension, rollapp1) + require.NoError(t, err) + rollappHeight, err := rollapp1.GetNode().Height(ctx) require.NoError(t, err) @@ -321,6 +339,14 @@ func TestADMC_Migrate_Empty_User_Memo_EVM(t *testing.T) { require.NoError(t, err) require.True(t, isFinalized) + txhash, err := dymension.GetNode().FinalizePacketsUntilHeight(ctx, dymensionUserAddr, rollapp1.GetChainID(), fmt.Sprint(rollappHeight)) + require.NoError(t, err) + + fmt.Println(txhash) + + err = testutil.WaitForBlocks(ctx, 10, dymension, rollapp1) + require.NoError(t, err) + resp, err = dymension.GetNode().QueryAllDenomMetadata(ctx) require.NoError(t, err) require.Equal(t, 2, len(resp.Metadatas)) @@ -386,6 +412,9 @@ func TestADMC_Migrate_Empty_User_Memo_EVM(t *testing.T) { _, err = rollapp1.SendIBCTransfer(ctx, channel.ChannelID, rollappUserAddr, transferData, ibc.TransferOptions{}) require.NoError(t, err) + err = testutil.WaitForBlocks(ctx, 10, dymension, rollapp1) + require.NoError(t, err) + rollappHeight, err = rollapp1.GetNode().Height(ctx) require.NoError(t, err) @@ -397,12 +426,22 @@ func TestADMC_Migrate_Empty_User_Memo_EVM(t *testing.T) { require.NoError(t, err) require.True(t, isFinalized) + txhash, err = dymension.GetNode().FinalizePacketsUntilHeight(ctx, dymensionUserAddr, rollapp1.GetChainID(), fmt.Sprint(rollappHeight)) + require.NoError(t, err) + + fmt.Println(txhash) + + err = testutil.WaitForBlocks(ctx, 10, dymension, rollapp1) + require.NoError(t, err) + resp, err = dymension.GetNode().QueryAllDenomMetadata(ctx) require.NoError(t, err) require.Equal(t, 2, len(resp.Metadatas)) // Minus 0.1% of transfer amount for bridge fee testutil.AssertBalance(t, ctx, dymension, dymensionUserAddr, rollappIBCDenom, transferAmount.Sub(bridgingFee).Add(transferAmount).Sub(bridgingFee)) + // Run invariant check + CheckInvariant(t, ctx, dymension, dymensionUser.KeyName()) } func TestADMC_Migrate_With_User_Memo_EVM(t *testing.T) { @@ -420,7 +459,8 @@ func TestADMC_Migrate_With_User_Memo_EVM(t *testing.T) { dymintTomlOverrides["settlement_gas_prices"] = "0adym" dymintTomlOverrides["max_idle_time"] = "3s" dymintTomlOverrides["max_proof_time"] = "500ms" - dymintTomlOverrides["batch_submit_max_time"] = "100s" + dymintTomlOverrides["batch_submit_time"] = "50s" + dymintTomlOverrides["p2p_blocksync_enabled"] = "false" configFileOverrides["config/dymint.toml"] = dymintTomlOverrides // Create chain factory with dymension @@ -495,7 +535,7 @@ func TestADMC_Migrate_With_User_Memo_EVM(t *testing.T) { // This can be used to write to the block database which will index all block data e.g. txs, msgs, events, etc. // BlockDatabaseFile: test.DefaultBlockDatabaseFilepath(), - }, nil, "", nil) + }, nil, "", nil, false, 780) require.NoError(t, err) CreateChannel(ctx, t, r, eRep, dymension.CosmosChain, rollapp1.CosmosChain, ibcPath) @@ -520,7 +560,7 @@ func TestADMC_Migrate_With_User_Memo_EVM(t *testing.T) { resp, err := dymension.GetNode().QueryAllDenomMetadata(ctx) require.NoError(t, err) - require.Equal(t, 2, len(resp.Metadatas)) + require.Equal(t, 1, len(resp.Metadatas)) // Send a normal ibc tx from RA -> Hub transferData := ibc.WalletData{ @@ -531,6 +571,9 @@ func TestADMC_Migrate_With_User_Memo_EVM(t *testing.T) { _, err = rollapp1.SendIBCTransfer(ctx, channel.ChannelID, rollappUserAddr, transferData, ibc.TransferOptions{}) require.NoError(t, err) + err = testutil.WaitForBlocks(ctx, 10, dymension, rollapp1) + require.NoError(t, err) + rollappHeight, err := rollapp1.GetNode().Height(ctx) require.NoError(t, err) @@ -542,6 +585,14 @@ func TestADMC_Migrate_With_User_Memo_EVM(t *testing.T) { require.NoError(t, err) require.True(t, isFinalized) + txhash, err := dymension.GetNode().FinalizePacketsUntilHeight(ctx, dymensionUserAddr, rollapp1.GetChainID(), fmt.Sprint(rollappHeight)) + require.NoError(t, err) + + fmt.Println(txhash) + + err = testutil.WaitForBlocks(ctx, 10, dymension, rollapp1) + require.NoError(t, err) + resp, err = dymension.GetNode().QueryAllDenomMetadata(ctx) require.NoError(t, err) require.Equal(t, 2, len(resp.Metadatas)) @@ -616,6 +667,9 @@ func TestADMC_Migrate_With_User_Memo_EVM(t *testing.T) { _, err = rollapp1.SendIBCTransfer(ctx, channel.ChannelID, rollappUserAddr, transferData, ibc.TransferOptions{Memo: memo}) require.NoError(t, err) + err = testutil.WaitForBlocks(ctx, 10, dymension, rollapp1) + require.NoError(t, err) + rollappHeight, err = rollapp1.GetNode().Height(ctx) require.NoError(t, err) @@ -627,6 +681,14 @@ func TestADMC_Migrate_With_User_Memo_EVM(t *testing.T) { require.NoError(t, err) require.True(t, isFinalized) + txhash, err = dymension.GetNode().FinalizePacketsUntilHeight(ctx, dymensionUserAddr, rollapp1.GetChainID(), fmt.Sprint(rollappHeight)) + require.NoError(t, err) + + fmt.Println(txhash) + + err = testutil.WaitForBlocks(ctx, 10, dymension, rollapp1) + require.NoError(t, err) + resp, err = dymension.GetNode().QueryAllDenomMetadata(ctx) require.NoError(t, err) require.Equal(t, 2, len(resp.Metadatas)) @@ -649,7 +711,8 @@ func TestADMC_Originates_HubtoRA_Wasm(t *testing.T) { dymintTomlOverrides["settlement_gas_prices"] = "0adym" dymintTomlOverrides["max_idle_time"] = "3s" dymintTomlOverrides["max_proof_time"] = "500ms" - dymintTomlOverrides["batch_submit_max_time"] = "100s" + dymintTomlOverrides["batch_submit_time"] = "50s" + dymintTomlOverrides["p2p_blocksync_enabled"] = "false" configFileOverrides["config/dymint.toml"] = dymintTomlOverrides // Create chain factory with dymension @@ -724,7 +787,7 @@ func TestADMC_Originates_HubtoRA_Wasm(t *testing.T) { // This can be used to write to the block database which will index all block data e.g. txs, msgs, events, etc. // BlockDatabaseFile: test.DefaultBlockDatabaseFilepath(), - }, nil, "", nil) + }, nil, "", nil, false, 780) require.NoError(t, err) CreateChannel(ctx, t, r, eRep, dymension.CosmosChain, rollapp1.CosmosChain, ibcPath) @@ -756,6 +819,9 @@ func TestADMC_Originates_HubtoRA_Wasm(t *testing.T) { _, err = rollapp1.SendIBCTransfer(ctx, channel.ChannelID, rollappUserAddr, transferData, ibc.TransferOptions{}) require.NoError(t, err) + err = testutil.WaitForBlocks(ctx, 10, dymension, rollapp1) + require.NoError(t, err) + rollappHeight, err := rollapp1.GetNode().Height(ctx) require.NoError(t, err) @@ -767,6 +833,14 @@ func TestADMC_Originates_HubtoRA_Wasm(t *testing.T) { require.NoError(t, err) require.True(t, isFinalized) + txhash, err := dymension.GetNode().FinalizePacketsUntilHeight(ctx, dymensionUserAddr, rollapp1.GetChainID(), fmt.Sprint(rollappHeight)) + require.NoError(t, err) + + fmt.Println(txhash) + + err = testutil.WaitForBlocks(ctx, 10, dymension, rollapp1) + require.NoError(t, err) + // Get the IBC denom for urax on Hub rollappTokenDenom := transfertypes.GetPrefixedDenom(channel.Counterparty.PortID, channel.Counterparty.ChannelID, rollapp1.Config().Denom) rollappIBCDenom := transfertypes.ParseDenomTrace(rollappTokenDenom).IBCDenom() @@ -797,6 +871,8 @@ func TestADMC_Originates_HubtoRA_Wasm(t *testing.T) { require.Equal(t, "urax", resp.Metadatas[0].Base) testutil.AssertBalance(t, ctx, rollapp1, rollappUserAddr, rollapp1.Config().Denom, walletAmount.Sub(bridgingFee)) + // Run invariant check + CheckInvariant(t, ctx, dymension, dymensionUser.KeyName()) } func TestADMC_Migrate_Empty_User_Memo_Wasm(t *testing.T) { @@ -814,7 +890,8 @@ func TestADMC_Migrate_Empty_User_Memo_Wasm(t *testing.T) { dymintTomlOverrides["settlement_gas_prices"] = "0adym" dymintTomlOverrides["max_idle_time"] = "3s" dymintTomlOverrides["max_proof_time"] = "500ms" - dymintTomlOverrides["batch_submit_max_time"] = "100s" + dymintTomlOverrides["batch_submit_time"] = "50s" + dymintTomlOverrides["p2p_blocksync_enabled"] = "false" configFileOverrides["config/dymint.toml"] = dymintTomlOverrides // Create chain factory with dymension @@ -889,7 +966,7 @@ func TestADMC_Migrate_Empty_User_Memo_Wasm(t *testing.T) { // This can be used to write to the block database which will index all block data e.g. txs, msgs, events, etc. // BlockDatabaseFile: test.DefaultBlockDatabaseFilepath(), - }, nil, "", nil) + }, nil, "", nil, false, 780) require.NoError(t, err) CreateChannel(ctx, t, r, eRep, dymension.CosmosChain, rollapp1.CosmosChain, ibcPath) @@ -914,7 +991,7 @@ func TestADMC_Migrate_Empty_User_Memo_Wasm(t *testing.T) { resp, err := dymension.GetNode().QueryAllDenomMetadata(ctx) require.NoError(t, err) - require.Equal(t, 2, len(resp.Metadatas)) + require.Equal(t, 1, len(resp.Metadatas)) // Send a normal ibc tx from RA -> Hub transferData := ibc.WalletData{ @@ -925,6 +1002,9 @@ func TestADMC_Migrate_Empty_User_Memo_Wasm(t *testing.T) { _, err = rollapp1.SendIBCTransfer(ctx, channel.ChannelID, rollappUserAddr, transferData, ibc.TransferOptions{}) require.NoError(t, err) + err = testutil.WaitForBlocks(ctx, 10, dymension, rollapp1) + require.NoError(t, err) + rollappHeight, err := rollapp1.GetNode().Height(ctx) require.NoError(t, err) @@ -936,6 +1016,14 @@ func TestADMC_Migrate_Empty_User_Memo_Wasm(t *testing.T) { require.NoError(t, err) require.True(t, isFinalized) + txhash, err := dymension.GetNode().FinalizePacketsUntilHeight(ctx, dymensionUserAddr, rollapp1.GetChainID(), fmt.Sprint(rollappHeight)) + require.NoError(t, err) + + fmt.Println(txhash) + + err = testutil.WaitForBlocks(ctx, 10, dymension, rollapp1) + require.NoError(t, err) + resp, err = dymension.GetNode().QueryAllDenomMetadata(ctx) require.NoError(t, err) require.Equal(t, 2, len(resp.Metadatas)) @@ -998,6 +1086,9 @@ func TestADMC_Migrate_Empty_User_Memo_Wasm(t *testing.T) { _, err = rollapp1.SendIBCTransfer(ctx, channel.ChannelID, rollappUserAddr, transferData, ibc.TransferOptions{}) require.NoError(t, err) + err = testutil.WaitForBlocks(ctx, 10, dymension, rollapp1) + require.NoError(t, err) + rollappHeight, err = rollapp1.GetNode().Height(ctx) require.NoError(t, err) @@ -1009,12 +1100,20 @@ func TestADMC_Migrate_Empty_User_Memo_Wasm(t *testing.T) { require.NoError(t, err) require.True(t, isFinalized) + _, err = dymension.GetNode().FinalizePacketsUntilHeight(ctx, dymensionUserAddr, rollapp1.GetChainID(), fmt.Sprint(rollappHeight)) + require.NoError(t, err) + + err = testutil.WaitForBlocks(ctx, 10, dymension, rollapp1) + require.NoError(t, err) + resp, err = dymension.GetNode().QueryAllDenomMetadata(ctx) require.NoError(t, err) require.Equal(t, 2, len(resp.Metadatas)) // Minus 0.1% of transfer amount for bridge fee testutil.AssertBalance(t, ctx, dymension, dymensionUserAddr, rollappIBCDenom, transferAmount.Sub(bridgingFee).Add(transferAmount).Sub(bridgingFee)) + // Run invariant check + CheckInvariant(t, ctx, dymension, dymensionUser.KeyName()) } func TestADMC_Migrate_With_User_Memo_Wasm(t *testing.T) { @@ -1032,7 +1131,8 @@ func TestADMC_Migrate_With_User_Memo_Wasm(t *testing.T) { dymintTomlOverrides["settlement_gas_prices"] = "0adym" dymintTomlOverrides["max_idle_time"] = "3s" dymintTomlOverrides["max_proof_time"] = "500ms" - dymintTomlOverrides["batch_submit_max_time"] = "100s" + dymintTomlOverrides["batch_submit_time"] = "50s" + dymintTomlOverrides["p2p_blocksync_enabled"] = "false" configFileOverrides["config/dymint.toml"] = dymintTomlOverrides // Create chain factory with dymension @@ -1107,7 +1207,7 @@ func TestADMC_Migrate_With_User_Memo_Wasm(t *testing.T) { // This can be used to write to the block database which will index all block data e.g. txs, msgs, events, etc. // BlockDatabaseFile: test.DefaultBlockDatabaseFilepath(), - }, nil, "", nil) + }, nil, "", nil, false, 780) require.NoError(t, err) CreateChannel(ctx, t, r, eRep, dymension.CosmosChain, rollapp1.CosmosChain, ibcPath) @@ -1132,7 +1232,7 @@ func TestADMC_Migrate_With_User_Memo_Wasm(t *testing.T) { resp, err := dymension.GetNode().QueryAllDenomMetadata(ctx) require.NoError(t, err) - require.Equal(t, 2, len(resp.Metadatas)) + require.Equal(t, 1, len(resp.Metadatas)) // Send a normal ibc tx from RA -> Hub transferData := ibc.WalletData{ @@ -1143,6 +1243,9 @@ func TestADMC_Migrate_With_User_Memo_Wasm(t *testing.T) { _, err = rollapp1.SendIBCTransfer(ctx, channel.ChannelID, rollappUserAddr, transferData, ibc.TransferOptions{}) require.NoError(t, err) + err = testutil.WaitForBlocks(ctx, 10, dymension, rollapp1) + require.NoError(t, err) + rollappHeight, err := rollapp1.GetNode().Height(ctx) require.NoError(t, err) @@ -1154,6 +1257,12 @@ func TestADMC_Migrate_With_User_Memo_Wasm(t *testing.T) { require.NoError(t, err) require.True(t, isFinalized) + _, err = dymension.GetNode().FinalizePacketsUntilHeight(ctx, dymensionUserAddr, rollapp1.GetChainID(), fmt.Sprint(rollappHeight)) + require.NoError(t, err) + + err = testutil.WaitForBlocks(ctx, 10, dymension, rollapp1) + require.NoError(t, err) + // Get the IBC denom for urax on Hub rollappTokenDenom := transfertypes.GetPrefixedDenom(channel.Counterparty.PortID, channel.Counterparty.ChannelID, rollapp1.Config().Denom) rollappIBCDenom := transfertypes.ParseDenomTrace(rollappTokenDenom).IBCDenom() @@ -1223,6 +1332,9 @@ func TestADMC_Migrate_With_User_Memo_Wasm(t *testing.T) { _, err = rollapp1.SendIBCTransfer(ctx, channel.ChannelID, rollappUserAddr, transferData, ibc.TransferOptions{Memo: memo}) require.NoError(t, err) + err = testutil.WaitForBlocks(ctx, 10, dymension, rollapp1) + require.NoError(t, err) + rollappHeight, err = rollapp1.GetNode().Height(ctx) require.NoError(t, err) @@ -1234,12 +1346,20 @@ func TestADMC_Migrate_With_User_Memo_Wasm(t *testing.T) { require.NoError(t, err) require.True(t, isFinalized) + _, err = dymension.GetNode().FinalizePacketsUntilHeight(ctx, dymensionUserAddr, rollapp1.GetChainID(), fmt.Sprint(rollappHeight)) + require.NoError(t, err) + + err = testutil.WaitForBlocks(ctx, 10, dymension, rollapp1) + require.NoError(t, err) + resp, err = dymension.GetNode().QueryAllDenomMetadata(ctx) require.NoError(t, err) require.Equal(t, 2, len(resp.Metadatas)) testutil.AssertBalance(t, ctx, dymension, dymensionUserAddr, rollappIBCDenom, transferAmount.Sub(bridgingFee).Add(transferAmount).Sub(bridgingFee)) + // Run invariant check + CheckInvariant(t, ctx, dymension, dymensionUser.KeyName()) } func TestADMC_MetaData_NotFound_EVM(t *testing.T) { @@ -1257,12 +1377,13 @@ func TestADMC_MetaData_NotFound_EVM(t *testing.T) { dymintTomlOverrides["settlement_gas_prices"] = "0adym" dymintTomlOverrides["max_idle_time"] = "3s" dymintTomlOverrides["max_proof_time"] = "500ms" - dymintTomlOverrides["batch_submit_max_time"] = "100s" + dymintTomlOverrides["batch_submit_time"] = "50s" + dymintTomlOverrides["p2p_blocksync_enabled"] = "false" configFileOverrides["config/dymint.toml"] = dymintTomlOverrides modifyGenesisKV := append( - dymModifyGenesisKV, + dymensionGenesisKV, []cosmos.GenesisKV{ { Key: "app_state.bank.denom_metadata", @@ -1359,7 +1480,7 @@ func TestADMC_MetaData_NotFound_EVM(t *testing.T) { // This can be used to write to the block database which will index all block data e.g. txs, msgs, events, etc. // BlockDatabaseFile: test.DefaultBlockDatabaseFilepath(), - }, nil, "", nil) + }, nil, "", nil, false, 780) require.NoError(t, err) CreateChannel(ctx, t, r, eRep, dymension.CosmosChain, rollapp1.CosmosChain, ibcPath) @@ -1391,6 +1512,9 @@ func TestADMC_MetaData_NotFound_EVM(t *testing.T) { _, err = rollapp1.SendIBCTransfer(ctx, channel.ChannelID, rollappUserAddr, transferData, ibc.TransferOptions{}) require.NoError(t, err) + err = testutil.WaitForBlocks(ctx, 10, dymension, rollapp1) + require.NoError(t, err) + rollappHeight, err := rollapp1.GetNode().Height(ctx) require.NoError(t, err) @@ -1402,6 +1526,12 @@ func TestADMC_MetaData_NotFound_EVM(t *testing.T) { require.NoError(t, err) require.True(t, isFinalized) + _, err = dymension.GetNode().FinalizePacketsUntilHeight(ctx, dymensionUserAddr, rollapp1.GetChainID(), fmt.Sprint(rollappHeight)) + require.NoError(t, err) + + err = testutil.WaitForBlocks(ctx, 10, dymension, rollapp1) + require.NoError(t, err) + // Get the IBC denom for urax on Hub rollappTokenDenom := transfertypes.GetPrefixedDenom(channel.Counterparty.PortID, channel.Counterparty.ChannelID, rollapp1.Config().Denom) rollappIBCDenom := transfertypes.ParseDenomTrace(rollappTokenDenom).IBCDenom() @@ -1435,6 +1565,8 @@ func TestADMC_MetaData_NotFound_EVM(t *testing.T) { err = testutil.WaitForBlocks(ctx, 10, dymension, rollapp1) require.NoError(t, err) testutil.AssertBalance(t, ctx, rollapp1, rollappUserAddr, rollapp1.Config().Denom, walletAmount.Sub(bridgingFee)) + // Run invariant check + CheckInvariant(t, ctx, dymension, dymensionUser.KeyName()) } func TestADMC_MetaData_NotFound_Wasm(t *testing.T) { @@ -1452,12 +1584,13 @@ func TestADMC_MetaData_NotFound_Wasm(t *testing.T) { dymintTomlOverrides["settlement_gas_prices"] = "0adym" dymintTomlOverrides["max_idle_time"] = "3s" dymintTomlOverrides["max_proof_time"] = "500ms" - dymintTomlOverrides["batch_submit_max_time"] = "100s" + dymintTomlOverrides["batch_submit_time"] = "50s" + dymintTomlOverrides["p2p_blocksync_enabled"] = "false" configFileOverrides["config/dymint.toml"] = dymintTomlOverrides modifyGenesisKV := append( - dymModifyGenesisKV, + dymensionGenesisKV, []cosmos.GenesisKV{ { Key: "app_state.bank.denom_metadata", @@ -1554,7 +1687,7 @@ func TestADMC_MetaData_NotFound_Wasm(t *testing.T) { // This can be used to write to the block database which will index all block data e.g. txs, msgs, events, etc. // BlockDatabaseFile: test.DefaultBlockDatabaseFilepath(), - }, nil, "", nil) + }, nil, "", nil, false, 780) require.NoError(t, err) CreateChannel(ctx, t, r, eRep, dymension.CosmosChain, rollapp1.CosmosChain, ibcPath) @@ -1586,6 +1719,9 @@ func TestADMC_MetaData_NotFound_Wasm(t *testing.T) { _, err = rollapp1.SendIBCTransfer(ctx, channel.ChannelID, rollappUserAddr, transferData, ibc.TransferOptions{}) require.NoError(t, err) + err = testutil.WaitForBlocks(ctx, 10, dymension, rollapp1) + require.NoError(t, err) + rollappHeight, err := rollapp1.GetNode().Height(ctx) require.NoError(t, err) @@ -1597,6 +1733,12 @@ func TestADMC_MetaData_NotFound_Wasm(t *testing.T) { require.NoError(t, err) require.True(t, isFinalized) + _, err = dymension.GetNode().FinalizePacketsUntilHeight(ctx, dymensionUserAddr, rollapp1.GetChainID(), fmt.Sprint(rollappHeight)) + require.NoError(t, err) + + err = testutil.WaitForBlocks(ctx, 10, dymension, rollapp1) + require.NoError(t, err) + // Get the IBC denom for urax on Hub rollappTokenDenom := transfertypes.GetPrefixedDenom(channel.Counterparty.PortID, channel.Counterparty.ChannelID, rollapp1.Config().Denom) rollappIBCDenom := transfertypes.ParseDenomTrace(rollappTokenDenom).IBCDenom() @@ -1630,4 +1772,6 @@ func TestADMC_MetaData_NotFound_Wasm(t *testing.T) { err = testutil.WaitForBlocks(ctx, 10, dymension, rollapp1) require.NoError(t, err) testutil.AssertBalance(t, ctx, rollapp1, rollappUserAddr, rollapp1.Config().Denom, walletAmount.Sub(bridgingFee)) + // Run invariant check + CheckInvariant(t, ctx, dymension, dymensionUser.KeyName()) } diff --git a/tests/automated_denommetadata_test.go b/tests/automated_denommetadata_test.go index 3320c732..9a35ed64 100644 --- a/tests/automated_denommetadata_test.go +++ b/tests/automated_denommetadata_test.go @@ -36,14 +36,14 @@ func TestADMC_Hub_to_RA_reserved_EVM(t *testing.T) { gas_price_rollapp1 := "0adym" maxIdleTime1 := "10s" maxProofTime := "500ms" - configFileOverrides1 := overridesDymintToml(settlement_layer_rollapp1, settlement_node_address, rollapp1_id, gas_price_rollapp1, maxIdleTime1, maxProofTime, "100s") + configFileOverrides1 := overridesDymintToml(settlement_layer_rollapp1, settlement_node_address, rollapp1_id, gas_price_rollapp1, maxIdleTime1, maxProofTime, "50s") // setup config for rollapp 2 settlement_layer_rollapp2 := "dymension" rollapp2_id := "decentrio_12345-1" gas_price_rollapp2 := "0adym" maxIdleTime2 := "1s" - configFileOverrides2 := overridesDymintToml(settlement_layer_rollapp2, settlement_node_address, rollapp2_id, gas_price_rollapp2, maxIdleTime2, maxProofTime, "100s") + configFileOverrides2 := overridesDymintToml(settlement_layer_rollapp2, settlement_node_address, rollapp2_id, gas_price_rollapp2, maxIdleTime2, maxProofTime, "50s") // Create chain factory with dymension numHubVals := 1 @@ -174,7 +174,7 @@ func TestADMC_Hub_to_RA_reserved_EVM(t *testing.T) { // This can be used to write to the block database which will index all block data e.g. txs, msgs, events, etc. // BlockDatabaseFile: test.DefaultBlockDatabaseFilepath(), - }, nil, "", nil) + }, nil, "", nil, false, 780) require.NoError(t, err) CreateChannel(ctx, t, r1, eRep, dymension.CosmosChain, rollapp1.CosmosChain, ibcPath) @@ -248,6 +248,9 @@ func TestADMC_Hub_to_RA_reserved_EVM(t *testing.T) { _, err = rollapp1.SendIBCTransfer(ctx, channsRollApp1[0].ChannelID, rollapp1UserAddr, transferData, ibc.TransferOptions{}) require.NoError(t, err) + err = testutil.WaitForBlocks(ctx, 10, dymension, rollapp1) + require.NoError(t, err) + rollappHeight, err := rollapp1.GetNode().Height(ctx) require.NoError(t, err) @@ -259,6 +262,12 @@ func TestADMC_Hub_to_RA_reserved_EVM(t *testing.T) { require.NoError(t, err) require.True(t, isFinalized) + _, err = dymension.GetNode().FinalizePacketsUntilHeight(ctx, dymensionUserAddr, rollapp1.GetChainID(), fmt.Sprint(rollappHeight)) + require.NoError(t, err) + + err = testutil.WaitForBlocks(ctx, 10, dymension, rollapp1) + require.NoError(t, err) + transferData = ibc.WalletData{ Address: dymensionUserAddr, Denom: gaia.Config().Denom, @@ -335,6 +344,8 @@ func TestADMC_Hub_to_RA_reserved_EVM(t *testing.T) { } }, ) + // Run invariant check + CheckInvariant(t, ctx, dymension, dymensionUser.KeyName()) } // TestADMC_Hub_to_RA_3rd_Party_EVM send IBC transfer for a non-existing denom from hub to rollapp successfully @@ -352,14 +363,7 @@ func TestADMC_Hub_to_RA_3rd_Party_EVM(t *testing.T) { gas_price_rollapp1 := "0adym" maxIdleTime1 := "10s" maxProofTime := "500ms" - configFileOverrides1 := overridesDymintToml(settlement_layer_rollapp1, settlement_node_address, rollapp1_id, gas_price_rollapp1, maxIdleTime1, maxProofTime, "100s") - - // setup config for rollapp 2 - settlement_layer_rollapp2 := "dymension" - rollapp2_id := "decentrio_12345-1" - gas_price_rollapp2 := "0adym" - maxIdleTime2 := "1s" - configFileOverrides2 := overridesDymintToml(settlement_layer_rollapp2, settlement_node_address, rollapp2_id, gas_price_rollapp2, maxIdleTime2, maxProofTime, "100s") + configFileOverrides1 := overridesDymintToml(settlement_layer_rollapp1, settlement_node_address, rollapp1_id, gas_price_rollapp1, maxIdleTime1, maxProofTime, "50s") // Create chain factory with dymension numHubVals := 1 @@ -391,28 +395,6 @@ func TestADMC_Hub_to_RA_3rd_Party_EVM(t *testing.T) { NumValidators: &numRollAppVals, NumFullNodes: &numRollAppFn, }, - { - Name: "rollapp2", - ChainConfig: ibc.ChainConfig{ - Type: "rollapp-dym", - Name: "rollapp-temp2", - ChainID: "decentrio_12345-1", - Images: []ibc.DockerImage{rollappEVMImage}, - Bin: "rollappd", - Bech32Prefix: "ethm", - Denom: "urax", - CoinType: "60", - GasPrices: "0.0urax", - GasAdjustment: 1.1, - TrustingPeriod: "112h", - EncodingConfig: encodingConfig(), - NoHostMount: false, - ModifyGenesis: modifyRollappEVMGenesis(rollappEVMGenesisKV), - ConfigFileOverrides: configFileOverrides2, - }, - NumValidators: &numRollAppVals, - NumFullNodes: &numRollAppFn, - }, { Name: "dymension-hub", ChainConfig: dymensionConfig, @@ -433,9 +415,8 @@ func TestADMC_Hub_to_RA_3rd_Party_EVM(t *testing.T) { require.NoError(t, err) rollapp1 := chains[0].(*dym_rollapp.DymRollApp) - rollapp2 := chains[1].(*dym_rollapp.DymRollApp) - dymension := chains[2].(*dym_hub.DymHub) - gaia := chains[3].(*cosmos.CosmosChain) + dymension := chains[1].(*dym_hub.DymHub) + gaia := chains[2].(*cosmos.CosmosChain) // Relayer Factory client, network := test.DockerSetup(t) @@ -443,10 +424,6 @@ func TestADMC_Hub_to_RA_3rd_Party_EVM(t *testing.T) { r1 := test.NewBuiltinRelayerFactory(ibc.CosmosRly, zaptest.NewLogger(t), relayer.CustomDockerImage(RelayerMainRepo, relayerVersion, "100:1000"), relayer.ImagePull(pullRelayerImage), ).Build(t, client, "relayer1", network) - // relayer for rollapp 2 - r2 := test.NewBuiltinRelayerFactory(ibc.CosmosRly, zaptest.NewLogger(t), - relayer.CustomDockerImage(RelayerMainRepo, relayerVersion, "100:1000"), relayer.ImagePull(pullRelayerImage), - ).Build(t, client, "relayer2", network) r3 := test.NewBuiltinRelayerFactory( ibc.CosmosRly, @@ -455,10 +432,9 @@ func TestADMC_Hub_to_RA_3rd_Party_EVM(t *testing.T) { ).Build(t, client, "relayer3", network) ic := test.NewSetup(). - AddRollUp(dymension, rollapp1, rollapp2). + AddRollUp(dymension, rollapp1). AddChain(gaia). AddRelayer(r1, "relayer1"). - AddRelayer(r2, "relayer2"). AddRelayer(r3, "relayer3"). AddLink(test.InterchainLink{ Chain1: dymension, @@ -466,12 +442,6 @@ func TestADMC_Hub_to_RA_3rd_Party_EVM(t *testing.T) { Relayer: r1, Path: ibcPath, }). - AddLink(test.InterchainLink{ - Chain1: dymension, - Chain2: rollapp2, - Relayer: r2, - Path: ibcPath, - }). AddLink(test.InterchainLink{ Chain1: dymension, Chain2: gaia, @@ -490,11 +460,10 @@ func TestADMC_Hub_to_RA_3rd_Party_EVM(t *testing.T) { // This can be used to write to the block database which will index all block data e.g. txs, msgs, events, etc. // BlockDatabaseFile: test.DefaultBlockDatabaseFilepath(), - }, nil, "", nil) + }, nil, "", nil, false, 780) require.NoError(t, err) CreateChannel(ctx, t, r1, eRep, dymension.CosmosChain, rollapp1.CosmosChain, ibcPath) - CreateChannel(ctx, t, r2, eRep, dymension.CosmosChain, rollapp2.CosmosChain, ibcPath) CreateChannel(ctx, t, r3, eRep, dymension.CosmosChain, gaia, ibcPath) // Create some user accounts on both chains @@ -516,22 +485,15 @@ func TestADMC_Hub_to_RA_3rd_Party_EVM(t *testing.T) { dymChannels, err := r1.GetChannels(ctx, eRep, dymension.Config().ChainID) require.NoError(t, err) - require.Equal(t, 3, len(dymChannels)) + require.Equal(t, 2, len(dymChannels)) channsRollApp1, err := r1.GetChannels(ctx, eRep, rollapp1.GetChainID()) require.NoError(t, err) require.Len(t, channsRollApp1, 1) - channsRollApp2, err := r2.GetChannels(ctx, eRep, rollapp2.GetChainID()) - require.NoError(t, err) - require.Len(t, channsRollApp2, 1) - gaiaChannels, err := r3.GetChannels(ctx, eRep, gaia.GetChainID()) require.NoError(t, err) - require.Len(t, dymChannels, 3) - require.Len(t, gaiaChannels, 1) - channDymGaia := gaiaChannels[0].Counterparty require.NotEmpty(t, channDymGaia.ChannelID) @@ -541,8 +503,6 @@ func TestADMC_Hub_to_RA_3rd_Party_EVM(t *testing.T) { // Start relayer err = r1.StartRelayer(ctx, eRep, ibcPath) require.NoError(t, err) - err = r2.StartRelayer(ctx, eRep, ibcPath) - require.NoError(t, err) err = r3.StartRelayer(ctx, eRep, ibcPath) require.NoError(t, err) @@ -559,6 +519,9 @@ func TestADMC_Hub_to_RA_3rd_Party_EVM(t *testing.T) { _, err = rollapp1.SendIBCTransfer(ctx, channsRollApp1[0].ChannelID, rollapp1UserAddr, transferData, ibc.TransferOptions{}) require.NoError(t, err) + err = testutil.WaitForBlocks(ctx, 10, dymension, rollapp1) + require.NoError(t, err) + rollappHeight, err := rollapp1.GetNode().Height(ctx) require.NoError(t, err) @@ -570,6 +533,12 @@ func TestADMC_Hub_to_RA_3rd_Party_EVM(t *testing.T) { require.NoError(t, err) require.True(t, isFinalized) + _, err = dymension.GetNode().FinalizePacketsUntilHeight(ctx, dymensionUserAddr, rollapp1.GetChainID(), fmt.Sprint(rollappHeight)) + require.NoError(t, err) + + err = testutil.WaitForBlocks(ctx, 10, dymension, rollapp1) + require.NoError(t, err) + transferData = ibc.WalletData{ Address: dymensionUserAddr, Denom: gaia.Config().Denom, @@ -624,17 +593,15 @@ func TestADMC_Hub_to_RA_3rd_Party_EVM(t *testing.T) { t.Logf("an error occurred while stopping the relayer: %s", err) } - err = r2.StopRelayer(ctx, eRep) - if err != nil { - t.Logf("an error occurred while stopping the relayer: %s", err) - } - err = r3.StopRelayer(ctx, eRep) if err != nil { t.Logf("an error occurred while stopping the relayer: %s", err) } }, ) + + // Run invariant check + CheckInvariant(t, ctx, dymension, dymensionUser.KeyName()) } // TestADMC_Hub_to_RA_reserved_Wasm send IBC transfer for a non-existing denom from hub to rollapp with setting {"transferinject":{}} in the memo @@ -653,14 +620,14 @@ func TestADMC_Hub_to_RA_reserved_Wasm(t *testing.T) { gas_price_rollapp1 := "0adym" maxIdleTime1 := "10s" maxProofTime := "500ms" - configFileOverrides1 := overridesDymintToml(settlement_layer_rollapp1, settlement_node_address, rollapp1_id, gas_price_rollapp1, maxIdleTime1, maxProofTime, "100s") + configFileOverrides1 := overridesDymintToml(settlement_layer_rollapp1, settlement_node_address, rollapp1_id, gas_price_rollapp1, maxIdleTime1, maxProofTime, "50s") // setup config for rollapp 2 settlement_layer_rollapp2 := "dymension" rollapp2_id := "decentrio_12345-1" gas_price_rollapp2 := "0adym" maxIdleTime2 := "3s" - configFileOverrides2 := overridesDymintToml(settlement_layer_rollapp2, settlement_node_address, rollapp2_id, gas_price_rollapp2, maxIdleTime2, maxProofTime, "100s") + configFileOverrides2 := overridesDymintToml(settlement_layer_rollapp2, settlement_node_address, rollapp2_id, gas_price_rollapp2, maxIdleTime2, maxProofTime, "50s") // Create chain factory with dymension numHubVals := 1 @@ -791,7 +758,7 @@ func TestADMC_Hub_to_RA_reserved_Wasm(t *testing.T) { // This can be used to write to the block database which will index all block data e.g. txs, msgs, events, etc. // BlockDatabaseFile: test.DefaultBlockDatabaseFilepath(), - }, nil, "", nil) + }, nil, "", nil, false, 780) require.NoError(t, err) CreateChannel(ctx, t, r1, eRep, dymension.CosmosChain, rollapp1.CosmosChain, ibcPath) @@ -865,6 +832,9 @@ func TestADMC_Hub_to_RA_reserved_Wasm(t *testing.T) { _, err = rollapp1.SendIBCTransfer(ctx, channsRollApp1[0].ChannelID, rollapp1UserAddr, transferData, ibc.TransferOptions{}) require.NoError(t, err) + err = testutil.WaitForBlocks(ctx, 10, dymension, rollapp1) + require.NoError(t, err) + rollappHeight, err := rollapp1.GetNode().Height(ctx) require.NoError(t, err) @@ -876,6 +846,12 @@ func TestADMC_Hub_to_RA_reserved_Wasm(t *testing.T) { require.NoError(t, err) require.True(t, isFinalized) + _, err = dymension.GetNode().FinalizePacketsUntilHeight(ctx, dymensionUserAddr, rollapp1.GetChainID(), fmt.Sprint(rollappHeight)) + require.NoError(t, err) + + err = testutil.WaitForBlocks(ctx, 10, dymension, rollapp1) + require.NoError(t, err) + transferData = ibc.WalletData{ Address: dymensionUserAddr, Denom: gaia.Config().Denom, @@ -951,6 +927,8 @@ func TestADMC_Hub_to_RA_reserved_Wasm(t *testing.T) { } }, ) + // Run invariant check + CheckInvariant(t, ctx, dymension, dymensionUser.KeyName()) } // TestADMC_Hub_to_RA_3rd_Party_Wasm send IBC transfer for a non-existing denom from hub to rollapp successfully @@ -968,14 +946,14 @@ func TestADMC_Hub_to_RA_3rd_Party_Wasm(t *testing.T) { gas_price_rollapp1 := "0adym" maxIdleTime1 := "10s" maxProofTime := "500ms" - configFileOverrides1 := overridesDymintToml(settlement_layer_rollapp1, settlement_node_address, rollapp1_id, gas_price_rollapp1, maxIdleTime1, maxProofTime, "100s") + configFileOverrides1 := overridesDymintToml(settlement_layer_rollapp1, settlement_node_address, rollapp1_id, gas_price_rollapp1, maxIdleTime1, maxProofTime, "50s") // setup config for rollapp 2 settlement_layer_rollapp2 := "dymension" rollapp2_id := "decentrio_12345-1" gas_price_rollapp2 := "0adym" maxIdleTime2 := "3s" - configFileOverrides2 := overridesDymintToml(settlement_layer_rollapp2, settlement_node_address, rollapp2_id, gas_price_rollapp2, maxIdleTime2, maxProofTime, "100s") + configFileOverrides2 := overridesDymintToml(settlement_layer_rollapp2, settlement_node_address, rollapp2_id, gas_price_rollapp2, maxIdleTime2, maxProofTime, "50s") // Create chain factory with dymension numHubVals := 1 @@ -1106,7 +1084,7 @@ func TestADMC_Hub_to_RA_3rd_Party_Wasm(t *testing.T) { // This can be used to write to the block database which will index all block data e.g. txs, msgs, events, etc. // BlockDatabaseFile: test.DefaultBlockDatabaseFilepath(), - }, nil, "", nil) + }, nil, "", nil, false, 780) require.NoError(t, err) CreateChannel(ctx, t, r1, eRep, dymension.CosmosChain, rollapp1.CosmosChain, ibcPath) @@ -1175,6 +1153,9 @@ func TestADMC_Hub_to_RA_3rd_Party_Wasm(t *testing.T) { _, err = rollapp1.SendIBCTransfer(ctx, channsRollApp1[0].ChannelID, rollapp1UserAddr, transferData, ibc.TransferOptions{}) require.NoError(t, err) + err = testutil.WaitForBlocks(ctx, 10, dymension, rollapp1) + require.NoError(t, err) + rollappHeight, err := rollapp1.GetNode().Height(ctx) require.NoError(t, err) @@ -1186,6 +1167,12 @@ func TestADMC_Hub_to_RA_3rd_Party_Wasm(t *testing.T) { require.NoError(t, err) require.True(t, isFinalized) + _, err = dymension.GetNode().FinalizePacketsUntilHeight(ctx, dymensionUserAddr, rollapp1.GetChainID(), fmt.Sprint(rollappHeight)) + require.NoError(t, err) + + err = testutil.WaitForBlocks(ctx, 10, dymension, rollapp1) + require.NoError(t, err) + transferData = ibc.WalletData{ Address: dymensionUserAddr, Denom: gaia.Config().Denom, @@ -1251,6 +1238,8 @@ func TestADMC_Hub_to_RA_3rd_Party_Wasm(t *testing.T) { } }, ) + // Run invariant check + CheckInvariant(t, ctx, dymension, dymensionUser.KeyName()) } type floatAmountWalletData struct { @@ -1275,7 +1264,8 @@ func TestADMC_Hub_to_RA_Migrate_Dym_EVM(t *testing.T) { dymintTomlOverrides["settlement_gas_prices"] = "0adym" dymintTomlOverrides["max_idle_time"] = "3s" dymintTomlOverrides["max_proof_time"] = "500ms" - dymintTomlOverrides["batch_submit_max_time"] = "100s" + dymintTomlOverrides["batch_submit_time"] = "50s" + dymintTomlOverrides["p2p_blocksync_enabled"] = "false" configFileOverrides["config/dymint.toml"] = dymintTomlOverrides // Create chain factory with dymension @@ -1350,7 +1340,7 @@ func TestADMC_Hub_to_RA_Migrate_Dym_EVM(t *testing.T) { // This can be used to write to the block database which will index all block data e.g. txs, msgs, events, etc. // BlockDatabaseFile: test.DefaultBlockDatabaseFilepath(), - }, nil, "", nil) + }, nil, "", nil, false, 780) require.NoError(t, err) CreateChannel(ctx, t, r, eRep, dymension.CosmosChain, rollapp1.CosmosChain, ibcPath) @@ -1382,6 +1372,9 @@ func TestADMC_Hub_to_RA_Migrate_Dym_EVM(t *testing.T) { _, err = rollapp1.SendIBCTransfer(ctx, channel.ChannelID, rollappUserAddr, transferData, ibc.TransferOptions{}) require.NoError(t, err) + err = testutil.WaitForBlocks(ctx, 10, dymension, rollapp1) + require.NoError(t, err) + rollappHeight, err := rollapp1.GetNode().Height(ctx) require.NoError(t, err) @@ -1393,6 +1386,12 @@ func TestADMC_Hub_to_RA_Migrate_Dym_EVM(t *testing.T) { require.NoError(t, err) require.True(t, isFinalized) + _, err = dymension.GetNode().FinalizePacketsUntilHeight(ctx, dymensionUserAddr, rollapp1.GetChainID(), fmt.Sprint(rollappHeight)) + require.NoError(t, err) + + err = testutil.WaitForBlocks(ctx, 10, dymension, rollapp1) + require.NoError(t, err) + // Get the IBC denom for urax on Hub rollappTokenDenom := transfertypes.GetPrefixedDenom(channel.Counterparty.PortID, channel.Counterparty.ChannelID, rollapp1.Config().Denom) rollappIBCDenom := transfertypes.ParseDenomTrace(rollappTokenDenom).IBCDenom() @@ -1447,6 +1446,8 @@ func TestADMC_Hub_to_RA_Migrate_Dym_EVM(t *testing.T) { } }, ) + // Run invariant check + CheckInvariant(t, ctx, dymension, dymensionUser.KeyName()) } // TestADMC_Hub_to_RA_Migrate_Dym_Wasm send IBC transfer DYM hub to rollapp successfully @@ -1465,7 +1466,8 @@ func TestADMC_Hub_to_RA_Migrate_Dym_Wasm(t *testing.T) { dymintTomlOverrides["settlement_gas_prices"] = "0adym" dymintTomlOverrides["max_idle_time"] = "3s" dymintTomlOverrides["max_proof_time"] = "500ms" - dymintTomlOverrides["batch_submit_max_time"] = "100s" + dymintTomlOverrides["batch_submit_time"] = "50s" + dymintTomlOverrides["p2p_blocksync_enabled"] = "false" configFileOverrides["config/dymint.toml"] = dymintTomlOverrides // Create chain factory with dymension @@ -1540,7 +1542,7 @@ func TestADMC_Hub_to_RA_Migrate_Dym_Wasm(t *testing.T) { // This can be used to write to the block database which will index all block data e.g. txs, msgs, events, etc. // BlockDatabaseFile: test.DefaultBlockDatabaseFilepath(), - }, nil, "", nil) + }, nil, "", nil, false, 780) require.NoError(t, err) CreateChannel(ctx, t, r, eRep, dymension.CosmosChain, rollapp1.CosmosChain, ibcPath) @@ -1572,6 +1574,9 @@ func TestADMC_Hub_to_RA_Migrate_Dym_Wasm(t *testing.T) { _, err = rollapp1.SendIBCTransfer(ctx, channel.ChannelID, rollappUserAddr, transferData, ibc.TransferOptions{}) require.NoError(t, err) + err = testutil.WaitForBlocks(ctx, 10, dymension, rollapp1) + require.NoError(t, err) + rollappHeight, err := rollapp1.GetNode().Height(ctx) require.NoError(t, err) @@ -1583,6 +1588,12 @@ func TestADMC_Hub_to_RA_Migrate_Dym_Wasm(t *testing.T) { require.NoError(t, err) require.True(t, isFinalized) + _, err = dymension.GetNode().FinalizePacketsUntilHeight(ctx, dymensionUserAddr, rollapp1.GetChainID(), fmt.Sprint(rollappHeight)) + require.NoError(t, err) + + err = testutil.WaitForBlocks(ctx, 10, dymension, rollapp1) + require.NoError(t, err) + // Get the IBC denom for urax on Hub rollappTokenDenom := transfertypes.GetPrefixedDenom(channel.Counterparty.PortID, channel.Counterparty.ChannelID, rollapp1.Config().Denom) rollappIBCDenom := transfertypes.ParseDenomTrace(rollappTokenDenom).IBCDenom() @@ -1634,4 +1645,6 @@ func TestADMC_Hub_to_RA_Migrate_Dym_Wasm(t *testing.T) { } }, ) + // Run invariant check + CheckInvariant(t, ctx, dymension, dymensionUser.KeyName()) } diff --git a/tests/bridging_fee_test.go b/tests/bridging_fee_test.go index e42d045a..62c93242 100644 --- a/tests/bridging_fee_test.go +++ b/tests/bridging_fee_test.go @@ -85,7 +85,7 @@ func Test_Non_Rollappchain_Unaffected_EVM(t *testing.T) { // This can be used to write to the block database which will index all block data e.g. txs, msgs, events, etc. // BlockDatabaseFile: test.DefaultBlockDatabaseFilepath(), - }, nil, "", nil) + }, nil, "", nil, false, 780) require.NoError(t, err) CreateChannel(ctx, t, r, eRep, dymension.CosmosChain, gaia1, ibcPath) @@ -157,6 +157,8 @@ func Test_Non_Rollappchain_Unaffected_EVM(t *testing.T) { testutil.AssertBalance(t, ctx, dymension, dymensionUserAddr, dymension.Config().Denom, dymensionOrigBal.Sub(transferData.Amount)) testutil.AssertBalance(t, ctx, gaia1, gaiaUserAddr, dymensionIBCDenom, transferAmount) + // Run invariant check + CheckInvariant(t, ctx, dymension, dymensionUser.KeyName()) } // TestChangeBridgeFeeParam_EVM create a prop to change bridge fee and after prop passed, transfer from rollapp to hub should have the new bridge fee. @@ -174,7 +176,7 @@ func TestChangeBridgeFeeParam_EVM(t *testing.T) { gas_price_rollapp1 := "0adym" maxIdleTime1 := "10s" maxProofTime := "500ms" - configFileOverrides1 := overridesDymintToml(settlement_layer_rollapp1, settlement_node_address, rollapp1_id, gas_price_rollapp1, maxIdleTime1, maxProofTime, "100s") + configFileOverrides1 := overridesDymintToml(settlement_layer_rollapp1, settlement_node_address, rollapp1_id, gas_price_rollapp1, maxIdleTime1, maxProofTime, "50s") extraFlags := map[string]interface{}{"genesis-accounts-path": true} @@ -183,18 +185,8 @@ func TestChangeBridgeFeeParam_EVM(t *testing.T) { rollapp2_id := "decentrio_12345-1" gas_price_rollapp2 := "0adym" maxIdleTime2 := "1s" - configFileOverrides2 := overridesDymintToml(settlement_layer_rollapp2, settlement_node_address, rollapp2_id, gas_price_rollapp2, maxIdleTime2, maxProofTime, "100s") - - // Custom dymension epoch for faster disconnection - modifyGenesisKV := append( - dymModifyGenesisKV, - []cosmos.GenesisKV{ - { - Key: "app_state.rollapp.params.dispute_period_in_blocks", - Value: fmt.Sprint(BLOCK_FINALITY_PERIOD), - }, - }..., - ) + configFileOverrides2 := overridesDymintToml(settlement_layer_rollapp2, settlement_node_address, rollapp2_id, gas_price_rollapp2, maxIdleTime2, maxProofTime, "50s") + // Create chain factory with dymension numHubVals := 1 numHubFullNodes := 1 @@ -261,7 +253,7 @@ func TestChangeBridgeFeeParam_EVM(t *testing.T) { GasAdjustment: 1.1, TrustingPeriod: "112h", NoHostMount: false, - ModifyGenesis: modifyDymensionGenesis(modifyGenesisKV), + ModifyGenesis: modifyDymensionGenesis(dymensionGenesisKV), ConfigFileOverrides: nil, }, NumValidators: &numHubVals, @@ -315,7 +307,7 @@ func TestChangeBridgeFeeParam_EVM(t *testing.T) { // This can be used to write to the block database which will index all block data e.g. txs, msgs, events, etc. // BlockDatabaseFile: test.DefaultBlockDatabaseFilepath(), - }, nil, "", nil) + }, nil, "", nil, false, 780) require.NoError(t, err) CreateChannel(ctx, t, r1, eRep, dymension.CosmosChain, rollapp1.CosmosChain, ibcPath) @@ -358,6 +350,9 @@ func TestChangeBridgeFeeParam_EVM(t *testing.T) { _, err = rollapp1.SendIBCTransfer(ctx, channel.Counterparty.ChannelID, rollappUserAddr, transferData, ibc.TransferOptions{}) require.NoError(t, err) + err = testutil.WaitForBlocks(ctx, 10, dymension, rollapp1) + require.NoError(t, err) + rollappHeight, err := rollapp1.GetNode().Height(ctx) require.NoError(t, err) @@ -369,6 +364,12 @@ func TestChangeBridgeFeeParam_EVM(t *testing.T) { require.NoError(t, err) require.True(t, isFinalized) + _, err = dymension.GetNode().FinalizePacketsUntilHeight(ctx, dymensionUserAddr, rollapp1.GetChainID(), fmt.Sprint(rollappHeight)) + require.NoError(t, err) + + err = testutil.WaitForBlocks(ctx, 10, dymension, rollapp1) + require.NoError(t, err) + // Minus 0.1% of transfer amount for bridge fee testutil.AssertBalance(t, ctx, dymension, dymensionUserAddr, rollappIBCDenom, transferAmount.Sub(bridgingFee)) @@ -399,6 +400,9 @@ func TestChangeBridgeFeeParam_EVM(t *testing.T) { _, err = rollapp1.SendIBCTransfer(ctx, channel.Counterparty.ChannelID, rollappUserAddr, transferData, ibc.TransferOptions{}) require.NoError(t, err) + err = testutil.WaitForBlocks(ctx, 10, dymension, rollapp1) + require.NoError(t, err) + rollappHeight, err = rollapp1.GetNode().Height(ctx) require.NoError(t, err) @@ -410,5 +414,13 @@ func TestChangeBridgeFeeParam_EVM(t *testing.T) { require.NoError(t, err) require.True(t, isFinalized) + _, err = dymension.GetNode().FinalizePacketsUntilHeight(ctx, dymensionUserAddr, rollapp1.GetChainID(), fmt.Sprint(rollappHeight)) + require.NoError(t, err) + + err = testutil.WaitForBlocks(ctx, 10, dymension, rollapp1) + require.NoError(t, err) + testutil.AssertBalance(t, ctx, dymension, dymensionUserAddr, rollappIBCDenom, transferAmount.Sub(bridgingFee).Add(transferAmount)) + // Run invariant check + CheckInvariant(t, ctx, dymension, dymensionUser.KeyName()) } diff --git a/tests/canonical_light_client_test.go b/tests/canonical_light_client_test.go new file mode 100644 index 00000000..9415c5c5 --- /dev/null +++ b/tests/canonical_light_client_test.go @@ -0,0 +1,737 @@ +package tests + +import ( + "context" + "fmt" + "testing" + + transfertypes "github.com/cosmos/ibc-go/v7/modules/apps/transfer/types" + "github.com/stretchr/testify/require" + "go.uber.org/zap/zaptest" + + test "github.com/decentrio/rollup-e2e-testing" + "github.com/decentrio/rollup-e2e-testing/cosmos" + "github.com/decentrio/rollup-e2e-testing/cosmos/hub/dym_hub" + "github.com/decentrio/rollup-e2e-testing/cosmos/rollapp/dym_rollapp" + "github.com/decentrio/rollup-e2e-testing/ibc" + "github.com/decentrio/rollup-e2e-testing/relayer" + "github.com/decentrio/rollup-e2e-testing/testreporter" + "github.com/decentrio/rollup-e2e-testing/testutil" +) + +func TestIBCTransferBetweenHub3rd_EVM(t *testing.T) { + if testing.Short() { + t.Skip() + } + + ctx := context.Background() + + configFileOverrides := make(map[string]any) + dymintTomlOverrides := make(testutil.Toml) + dymintTomlOverrides["settlement_layer"] = "dymension" + dymintTomlOverrides["settlement_node_address"] = fmt.Sprintf("http://dymension_100-1-val-0-%s:26657", t.Name()) + dymintTomlOverrides["rollapp_id"] = "rollappevm_1234-1" + dymintTomlOverrides["settlement_gas_prices"] = "0adym" + dymintTomlOverrides["max_idle_time"] = "3s" + dymintTomlOverrides["max_proof_time"] = "500ms" + dymintTomlOverrides["batch_submit_time"] = "50s" + dymintTomlOverrides["p2p_blocksync_enabled"] = "false" + + configFileOverrides["config/dymint.toml"] = dymintTomlOverrides + + // Create chain factory with dymension + numHubVals := 1 + numHubFullNodes := 1 + numRollAppFn := 0 + numRollAppVals := 1 + numVals := 1 + numFullNodes := 0 + + cf := test.NewBuiltinChainFactory(zaptest.NewLogger(t), []*test.ChainSpec{ + { + Name: "rollapp1", + ChainConfig: ibc.ChainConfig{ + Type: "rollapp-dym", + Name: "rollapp-test", + ChainID: "rollappevm_1234-1", + Images: []ibc.DockerImage{rollappEVMImage}, + Bin: "rollappd", + Bech32Prefix: "ethm", + Denom: "urax", + CoinType: "60", + GasPrices: "0.0urax", + GasAdjustment: 1.1, + TrustingPeriod: "112h", + EncodingConfig: encodingConfig(), + NoHostMount: false, + ModifyGenesis: modifyRollappEVMGenesis(rollappEVMGenesisKV), + ConfigFileOverrides: configFileOverrides, + }, + NumValidators: &numRollAppVals, + NumFullNodes: &numRollAppFn, + }, + { + Name: "dymension-hub", + ChainConfig: dymensionConfig, + NumValidators: &numHubVals, + NumFullNodes: &numHubFullNodes, + }, + { + Name: "gaia-1", + Version: "v14.2.0", + ChainConfig: gaiaConfig, + NumValidators: &numVals, + NumFullNodes: &numFullNodes, + }, + }) + chains, err := cf.Chains(t.Name()) + require.NoError(t, err) + + rollapp1 := chains[0].(*dym_rollapp.DymRollApp) + dymension := chains[1].(*dym_hub.DymHub) + gaia := chains[2].(*cosmos.CosmosChain) + + // Relayer Factory + client, network := test.DockerSetup(t) + + r2 := test.NewBuiltinRelayerFactory( + ibc.CosmosRly, + zaptest.NewLogger(t), + relayer.CustomDockerImage(RelayerMainRepo, relayerVersion, "100:1000"), relayer.ImagePull(pullRelayerImage), + ).Build(t, client, "relayer2", network) + + ic := test.NewSetup(). + AddRollUp(dymension, rollapp1). + AddChain(gaia). + AddRelayer(r2, "relayer2"). + AddLink(test.InterchainLink{ + Chain1: dymension, + Chain2: gaia, + Relayer: r2, + Path: anotherIbcPath, + }) + + rep := testreporter.NewNopReporter() + eRep := rep.RelayerExecReporter(t) + + err = ic.Build(ctx, eRep, test.InterchainBuildOptions{ + TestName: t.Name(), + Client: client, + NetworkID: network, + SkipPathCreation: true, + // This can be used to write to the block database which will index all block data e.g. txs, msgs, events, etc. + // BlockDatabaseFile: test.DefaultBlockDatabaseFilepath(), + }, nil, "", nil, false, 780) + require.NoError(t, err) + + t.Cleanup(func() { + _ = ic.Close() + }) + + // create ibc path between dymension and gaia + CreateChannel(ctx, t, r2, eRep, dymension.CosmosChain, gaia, anotherIbcPath) + + gaiaChan, err := r2.GetChannels(ctx, eRep, gaia.GetChainID()) + require.NoError(t, err) + require.Len(t, gaiaChan, 1) + + dymGaiaChan := gaiaChan[0].Counterparty + require.NotEmpty(t, dymGaiaChan.ChannelID) + + gaiaDymChan := gaiaChan[0] + require.NotEmpty(t, gaiaDymChan.ChannelID) + + // Start the relayer and set the cleanup function. + err = r2.StartRelayer(ctx, eRep, anotherIbcPath) + require.NoError(t, err) + + t.Cleanup( + func() { + err = r2.StopRelayer(ctx, eRep) + if err != nil { + t.Logf("an error occurred while stopping the relayer2: %s", err) + } + }, + ) + + // Create some user accounts on both chains + users := test.GetAndFundTestUsers(t, ctx, t.Name(), walletAmount, dymension, gaia) + + // Get our Bech32 encoded user addresses + dymensionUser, gaiaUser := users[0], users[1] + + dymensionUserAddr := dymensionUser.FormattedAddress() + gaiaUserAddr := gaiaUser.FormattedAddress() + + // Get original account balances + dymensionOrigBal, err := dymension.GetBalance(ctx, dymensionUserAddr, dymension.Config().Denom) + require.NoError(t, err) + require.Equal(t, walletAmount, dymensionOrigBal) + + gaiaOrigBal, err := gaia.GetBalance(ctx, gaiaUserAddr, gaia.Config().Denom) + require.NoError(t, err) + require.Equal(t, walletAmount, gaiaOrigBal) + + t.Run("canonial client gaia<->dym", func(t *testing.T) { + + firstHopDenom := transfertypes.GetPrefixedDenom(dymGaiaChan.PortID, dymGaiaChan.ChannelID, gaia.Config().Denom) + secondHopDenom := transfertypes.GetPrefixedDenom(gaiaDymChan.PortID, gaiaDymChan.ChannelID, dymension.Config().Denom) + + firstHopDenomTrace := transfertypes.ParseDenomTrace(firstHopDenom) + secondHopDenomTrace := transfertypes.ParseDenomTrace(secondHopDenom) + + firstHopIBCDenom := firstHopDenomTrace.IBCDenom() + secondHopIBCDenom := secondHopDenomTrace.IBCDenom() + + // Send packet from gaia -> dym + transfer := ibc.WalletData{ + Address: dymensionUserAddr, + Denom: gaia.Config().Denom, + Amount: transferAmount, + } + + transferTx, err := gaia.SendIBCTransfer(ctx, gaiaDymChan.ChannelID, gaiaUser.KeyName(), transfer, ibc.TransferOptions{}) + require.NoError(t, err) + err = transferTx.Validate() + require.NoError(t, err) + + // wait until dymension receive transferAmount + err = testutil.WaitForBlocks(ctx, 10, dymension, gaia) + require.NoError(t, err) + + testutil.AssertBalance(t, ctx, gaia, gaiaUserAddr, gaia.Config().Denom, walletAmount.Sub(transferAmount)) + testutil.AssertBalance(t, ctx, dymension, dymensionUserAddr, firstHopIBCDenom, transferAmount) + + // Send back packet from dym -> gaia + transfer = ibc.WalletData{ + Address: gaiaUserAddr, + Denom: dymension.Config().Denom, + Amount: transferAmount, + } + + transferTx, err = dymension.SendIBCTransfer(ctx, dymGaiaChan.ChannelID, dymensionUser.KeyName(), transfer, ibc.TransferOptions{}) + require.NoError(t, err) + err = transferTx.Validate() + require.NoError(t, err) + + // wait until gaia receive transferAmount + err = testutil.WaitForBlocks(ctx, 10, gaia, dymension) + require.NoError(t, err) + + testutil.AssertBalance(t, ctx, gaia, gaiaUserAddr, secondHopIBCDenom, transferAmount) + testutil.AssertBalance(t, ctx, dymension, dymensionUserAddr, dymension.Config().Denom, walletAmount.Sub(transferAmount)) + + }) +} + +// TestIBCTransferRA3rdSameChainID_EVM create vanilla cosmos chain with the same chain-id as an existing rollapp and test IBC transfer between them +func TestIBCTransferRA_3rdSameChainID_EVM(t *testing.T) { + if testing.Short() { + t.Skip() + } + + ctx := context.Background() + + configFileOverrides := make(map[string]any) + dymintTomlOverrides := make(testutil.Toml) + dymintTomlOverrides["settlement_layer"] = "dymension" + dymintTomlOverrides["settlement_node_address"] = fmt.Sprintf("http://dymension_100-1-val-0-%s:26657", t.Name()) + dymintTomlOverrides["rollapp_id"] = "rollappevm_1234-1" + dymintTomlOverrides["settlement_gas_prices"] = "0adym" + dymintTomlOverrides["max_idle_time"] = "3s" + dymintTomlOverrides["max_proof_time"] = "500ms" + dymintTomlOverrides["batch_submit_time"] = "50s" + dymintTomlOverrides["p2p_blocksync_enabled"] = "false" + + configFileOverrides["config/dymint.toml"] = dymintTomlOverrides + + // add modify gaia config so that it has the same chain-id as rollapp1 + gaiaConfig := gaiaConfig.Clone() + gaiaConfig.ChainID = "rollappevm_1234-1" + + // Create chain factory with dymension + numHubVals := 1 + numHubFullNodes := 1 + numRollAppFn := 0 + numRollAppVals := 1 + numVals := 1 + numFullNodes := 0 + cf := test.NewBuiltinChainFactory(zaptest.NewLogger(t), []*test.ChainSpec{ + { + Name: "rollapp1", + ChainConfig: ibc.ChainConfig{ + Type: "rollapp-dym", + Name: "rollapp-test", + ChainID: "rollappevm_1234-1", + Images: []ibc.DockerImage{rollappEVMImage}, + Bin: "rollappd", + Bech32Prefix: "ethm", + Denom: "urax", + CoinType: "60", + GasPrices: "0.0urax", + GasAdjustment: 1.1, + TrustingPeriod: "112h", + EncodingConfig: encodingConfig(), + NoHostMount: false, + ModifyGenesis: modifyRollappEVMGenesis(rollappEVMGenesisKV), + ConfigFileOverrides: configFileOverrides, + }, + NumValidators: &numRollAppVals, + NumFullNodes: &numRollAppFn, + }, + { + Name: "dymension-hub", + ChainConfig: dymensionConfig, + NumValidators: &numHubVals, + NumFullNodes: &numHubFullNodes, + }, + { + Name: "gaia-1", + Version: "v14.2.0", + ChainConfig: gaiaConfig, + NumValidators: &numVals, + NumFullNodes: &numFullNodes, + }, + }) + chains, err := cf.Chains(t.Name()) + require.NoError(t, err) + + rollapp1 := chains[0].(*dym_rollapp.DymRollApp) + dymension := chains[1].(*dym_hub.DymHub) + gaia := chains[2].(*cosmos.CosmosChain) + + // Relayer Factory + client, network := test.DockerSetup(t) + r := test.NewBuiltinRelayerFactory( + ibc.CosmosRly, + zaptest.NewLogger(t), + relayer.CustomDockerImage(RelayerMainRepo, relayerVersion, "100:1000"), relayer.ImagePull(pullRelayerImage), + ).Build(t, client, "relayer", network) + + r2 := test.NewBuiltinRelayerFactory( + ibc.CosmosRly, + zaptest.NewLogger(t), + relayer.CustomDockerImage(RelayerMainRepo, relayerVersion, "100:1000"), relayer.ImagePull(pullRelayerImage), + ).Build(t, client, "relayer2", network) + + ic := test.NewSetup(). + AddRollUp(dymension, rollapp1). + AddChain(gaia). + AddRelayer(r, "relayer"). + AddRelayer(r2, "relayer2"). + AddLink(test.InterchainLink{ + Chain1: dymension, + Chain2: rollapp1, + Relayer: r, + Path: ibcPath, + }). + AddLink(test.InterchainLink{ + Chain1: dymension, + Chain2: gaia, + Relayer: r2, + Path: anotherIbcPath, + }) + + rep := testreporter.NewNopReporter() + eRep := rep.RelayerExecReporter(t) + + err = ic.Build(ctx, eRep, test.InterchainBuildOptions{ + TestName: t.Name(), + Client: client, + NetworkID: network, + SkipPathCreation: true, + // This can be used to write to the block database which will index all block data e.g. txs, msgs, events, etc. + // BlockDatabaseFile: test.DefaultBlockDatabaseFilepath(), + }, nil, "", nil, false, 780) + require.NoError(t, err) + + t.Cleanup(func() { + _ = ic.Close() + }) + + // create ibc path between dymension and gaia, and between dymension and rollapp1 + CreateChannel(ctx, t, r, eRep, dymension.CosmosChain, rollapp1.CosmosChain, ibcPath) + CreateChannel(ctx, t, r2, eRep, dymension.CosmosChain, gaia, anotherIbcPath) + + // get rollapp -> dym channel + rollappChan, err := r.GetChannels(ctx, eRep, rollapp1.GetChainID()) + require.NoError(t, err) + require.Len(t, rollappChan, 1) + + rollappDymChan := rollappChan[0] + require.NotEmpty(t, rollappDymChan.ChannelID) + + dymRollappChan := rollappChan[0].Counterparty + require.NotEmpty(t, dymRollappChan.ChannelID) + + // Get gaia -> dym channel + gaiaChan, err := r2.GetChannels(ctx, eRep, gaia.GetChainID()) + require.NoError(t, err) + require.Len(t, gaiaChan, 1) + + dymGaiaChan := gaiaChan[0].Counterparty + require.NotEmpty(t, dymGaiaChan.ChannelID) + + gaiaDymChan := gaiaChan[0] + require.NotEmpty(t, gaiaDymChan.ChannelID) + + // Start the relayer and set the cleanup function. + err = r.StartRelayer(ctx, eRep, ibcPath) + require.NoError(t, err) + err = r2.StartRelayer(ctx, eRep, anotherIbcPath) + require.NoError(t, err) + + t.Cleanup( + func() { + err = r.StopRelayer(ctx, eRep) + if err != nil { + t.Logf("an error occurred while stopping the relayer: %s", err) + } + err = r2.StopRelayer(ctx, eRep) + if err != nil { + t.Logf("an error occurred while stopping the relayer2: %s", err) + } + }, + ) + + // Create some user accounts on both chains + users := test.GetAndFundTestUsers(t, ctx, t.Name(), walletAmount, dymension, gaia, rollapp1) + + // Get our Bech32 encoded user addresses + dymensionUser, gaiaUser, rollappUser := users[0], users[1], users[2] + + dymensionUserAddr := dymensionUser.FormattedAddress() + gaiaUserAddr := gaiaUser.FormattedAddress() + rollappUserAddr := rollappUser.FormattedAddress() + + // Get original account balances + dymensionOrigBal, err := dymension.GetBalance(ctx, dymensionUserAddr, dymension.Config().Denom) + require.NoError(t, err) + require.Equal(t, walletAmount, dymensionOrigBal) + + gaiaOrigBal, err := gaia.GetBalance(ctx, gaiaUserAddr, gaia.Config().Denom) + require.NoError(t, err) + require.Equal(t, walletAmount, gaiaOrigBal) + + rollappOrigBal, err := rollapp1.GetBalance(ctx, rollappUserAddr, rollapp1.Config().Denom) + require.NoError(t, err) + require.Equal(t, walletAmount, rollappOrigBal) + + t.Run("canonial client test gaia<->dym and rollapp<->dym", func(t *testing.T) { + + // sending between gaia and dymension + firstHopDenom := transfertypes.GetPrefixedDenom(dymGaiaChan.PortID, dymGaiaChan.ChannelID, gaia.Config().Denom) + secondHopDenom := transfertypes.GetPrefixedDenom(gaiaDymChan.PortID, gaiaDymChan.ChannelID, dymension.Config().Denom) + + firstHopDenomTrace := transfertypes.ParseDenomTrace(firstHopDenom) + secondHopDenomTrace := transfertypes.ParseDenomTrace(secondHopDenom) + + firstHopIBCDenom := firstHopDenomTrace.IBCDenom() + secondHopIBCDenom := secondHopDenomTrace.IBCDenom() + + // Send packet from gaia -> dym + transfer := ibc.WalletData{ + Address: dymensionUserAddr, + Denom: gaia.Config().Denom, + Amount: transferAmount, + } + + transferTx, err := gaia.SendIBCTransfer(ctx, gaiaDymChan.ChannelID, gaiaUser.KeyName(), transfer, ibc.TransferOptions{}) + require.NoError(t, err) + err = transferTx.Validate() + require.NoError(t, err) + + // wait until dymension receive transferAmount + err = testutil.WaitForBlocks(ctx, 10, dymension, gaia) + require.NoError(t, err) + + testutil.AssertBalance(t, ctx, gaia, gaiaUserAddr, gaia.Config().Denom, walletAmount.Sub(transferAmount)) + testutil.AssertBalance(t, ctx, dymension, dymensionUserAddr, firstHopIBCDenom, transferAmount) + + // Send back packet from dym -> gaia + transfer = ibc.WalletData{ + Address: gaiaUserAddr, + Denom: dymension.Config().Denom, + Amount: transferAmount, + } + + transferTx, err = dymension.SendIBCTransfer(ctx, dymGaiaChan.ChannelID, dymensionUser.KeyName(), transfer, ibc.TransferOptions{}) + require.NoError(t, err) + err = transferTx.Validate() + require.NoError(t, err) + + // wait until gaia receive transferAmount + err = testutil.WaitForBlocks(ctx, 10, gaia, dymension) + require.NoError(t, err) + + testutil.AssertBalance(t, ctx, dymension, dymensionUserAddr, dymension.Config().Denom, walletAmount.Sub(transferAmount)) + testutil.AssertBalance(t, ctx, gaia, gaiaUserAddr, secondHopIBCDenom, transferAmount) + + // sending between rollapp and dymension + firstHopDenom = transfertypes.GetPrefixedDenom(dymRollappChan.PortID, dymRollappChan.ChannelID, rollapp1.Config().Denom) + secondHopDenom = transfertypes.GetPrefixedDenom(rollappDymChan.PortID, rollappDymChan.ChannelID, dymension.Config().Denom) + + firstHopDenomTrace = transfertypes.ParseDenomTrace(firstHopDenom) + secondHopDenomTrace = transfertypes.ParseDenomTrace(secondHopDenom) + + firstHopIBCDenom = firstHopDenomTrace.IBCDenom() + secondHopIBCDenom = secondHopDenomTrace.IBCDenom() + + // Send packet from rollapp -> dym + transfer = ibc.WalletData{ + Address: dymensionUserAddr, + Denom: rollapp1.Config().Denom, + Amount: transferAmount, + } + + _, err = rollapp1.SendIBCTransfer(ctx, rollappDymChan.ChannelID, rollappUser.KeyName(), transfer, ibc.TransferOptions{}) + require.NoError(t, err) + + err = testutil.WaitForBlocks(ctx, 10, dymension) + require.NoError(t, err) + + // wait until dymension receive transferAmount when rollapp finalized + rollappHeight, err := rollapp1.GetNode().Height(ctx) + require.NoError(t, err) + + isFinalized, err := dymension.WaitUntilRollappHeightIsFinalized(ctx, rollapp1.GetNode().Chain.GetChainID(), rollappHeight, 600) + require.NoError(t, err) + require.True(t, isFinalized) + + txhash, err := dymension.GetNode().FinalizePacketsUntilHeight(ctx, dymensionUserAddr, rollapp1.GetChainID(), fmt.Sprint(rollappHeight)) + require.NoError(t, err) + fmt.Println(txhash) + + testutil.AssertBalance(t, ctx, rollapp1, rollappUserAddr, rollapp1.Config().Denom, walletAmount.Sub(transferAmount)) + testutil.AssertBalance(t, ctx, dymension, dymensionUserAddr, firstHopIBCDenom, transferAmount.Sub(bridgingFee)) + + // Send back packet from dym -> rollapp + transfer = ibc.WalletData{ + Address: rollappUserAddr, + Denom: dymension.Config().Denom, + Amount: transferAmount, + } + + _, err = dymension.SendIBCTransfer(ctx, dymRollappChan.ChannelID, dymensionUser.KeyName(), transfer, ibc.TransferOptions{}) + require.NoError(t, err) + + // wait until rollapp receive transferAmount + err = testutil.WaitForBlocks(ctx, 10, rollapp1, dymension) + require.NoError(t, err) + + testutil.AssertBalance(t, ctx, dymension, dymensionUserAddr, dymension.Config().Denom, walletAmount.Sub(transferAmount).Sub(transferAmount)) + erc20MAcc, err := rollapp1.Validators[0].QueryModuleAccount(ctx, "erc20") + require.NoError(t, err) + erc20MAccAddr := erc20MAcc.Account.BaseAccount.Address + testutil.AssertBalance(t, ctx, rollapp1, erc20MAccAddr, secondHopIBCDenom, transferAmount) + + // Run invariant check + CheckInvariant(t, ctx, dymension, dymensionUser.KeyName()) + }) +} + +func TestIBCTransfer_NoLightClient_EVM(t *testing.T) { + if testing.Short() { + t.Skip() + } + + ctx := context.Background() + + configFileOverrides := make(map[string]any) + dymintTomlOverrides := make(testutil.Toml) + dymintTomlOverrides["settlement_layer"] = "dymension" + dymintTomlOverrides["settlement_node_address"] = fmt.Sprintf("http://dymension_100-1-val-0-%s:26657", t.Name()) + dymintTomlOverrides["rollapp_id"] = "rollappevm_1234-1" + dymintTomlOverrides["settlement_gas_prices"] = "0adym" + dymintTomlOverrides["max_idle_time"] = "3s" + dymintTomlOverrides["max_proof_time"] = "500ms" + dymintTomlOverrides["batch_submit_time"] = "50s" + dymintTomlOverrides["p2p_blocksync_enabled"] = "false" + + configFileOverrides["config/dymint.toml"] = dymintTomlOverrides + + // add modify gaia config so that it has the same chain-id as rollapp1 + gaiaConfig := gaiaConfig.Clone() + gaiaConfig.ChainID = "rollappevm_1234-1" + + // Create chain factory with dymension + numHubVals := 1 + numHubFullNodes := 1 + numRollAppFn := 0 + numRollAppVals := 1 + numVals := 1 + numFullNodes := 0 + cf := test.NewBuiltinChainFactory(zaptest.NewLogger(t), []*test.ChainSpec{ + { + Name: "rollapp1", + ChainConfig: ibc.ChainConfig{ + Type: "rollapp-dym", + Name: "rollapp-test", + ChainID: "rollappevm_1234-1", + Images: []ibc.DockerImage{rollappEVMImage}, + Bin: "rollappd", + Bech32Prefix: "ethm", + Denom: "urax", + CoinType: "60", + GasPrices: "0.0urax", + GasAdjustment: 1.1, + TrustingPeriod: "112h", + EncodingConfig: encodingConfig(), + NoHostMount: false, + ModifyGenesis: modifyRollappEVMGenesis(rollappEVMGenesisKV), + ConfigFileOverrides: configFileOverrides, + }, + NumValidators: &numRollAppVals, + NumFullNodes: &numRollAppFn, + }, + { + Name: "dymension-hub", + ChainConfig: dymensionConfig, + NumValidators: &numHubVals, + NumFullNodes: &numHubFullNodes, + }, + { + Name: "gaia-1", + Version: "v14.2.0", + ChainConfig: gaiaConfig, + NumValidators: &numVals, + NumFullNodes: &numFullNodes, + }, + }) + chains, err := cf.Chains(t.Name()) + require.NoError(t, err) + + rollapp1 := chains[0].(*dym_rollapp.DymRollApp) + dymension := chains[1].(*dym_hub.DymHub) + gaia := chains[2].(*cosmos.CosmosChain) + + // Relayer Factory + client, network := test.DockerSetup(t) + r := test.NewBuiltinRelayerFactory( + ibc.CosmosRly, + zaptest.NewLogger(t), + relayer.CustomDockerImage(RelayerMainRepo, relayerVersion, "100:1000"), relayer.ImagePull(pullRelayerImage), + ).Build(t, client, "relayer", network) + + ic := test.NewSetup(). + AddRollUp(dymension, rollapp1). + AddChain(gaia). + AddRelayer(r, "relayer"). + AddLink(test.InterchainLink{ + Chain1: dymension, + Chain2: gaia, + Relayer: r, + Path: ibcPath, + }) + + rep := testreporter.NewNopReporter() + eRep := rep.RelayerExecReporter(t) + + err = ic.Build(ctx, eRep, test.InterchainBuildOptions{ + TestName: t.Name(), + Client: client, + NetworkID: network, + SkipPathCreation: true, + // This can be used to write to the block database which will index all block data e.g. txs, msgs, events, etc. + // BlockDatabaseFile: test.DefaultBlockDatabaseFilepath(), + }, nil, "", nil, false, 780) + require.NoError(t, err) + + t.Cleanup(func() { + _ = ic.Close() + }) + + // create ibc path between dymension and gaia, and between dymension and rollapp1 + CreateChannel(ctx, t, r, eRep, dymension.CosmosChain, gaia, ibcPath) + + // Get gaia -> dym channel + gaiaChan, err := r.GetChannels(ctx, eRep, gaia.GetChainID()) + require.NoError(t, err) + require.Len(t, gaiaChan, 1) + + dymGaiaChan := gaiaChan[0].Counterparty + require.NotEmpty(t, dymGaiaChan.ChannelID) + + gaiaDymChan := gaiaChan[0] + + // Start the relayer and set the cleanup function. + err = r.StartRelayer(ctx, eRep, ibcPath) + require.NoError(t, err) + + // Create some user accounts on both chains + users := test.GetAndFundTestUsers(t, ctx, t.Name(), walletAmount, dymension, gaia, rollapp1) + + // Get our Bech32 encoded user addresses + dymensionUser, gaiaUser, rollappUser := users[0], users[1], users[2] + + dymensionUserAddr := dymensionUser.FormattedAddress() + gaiaUserAddr := gaiaUser.FormattedAddress() + rollappUserAddr := rollappUser.FormattedAddress() + + // Get original account balances + dymensionOrigBal, err := dymension.GetBalance(ctx, dymensionUserAddr, dymension.Config().Denom) + require.NoError(t, err) + require.Equal(t, walletAmount, dymensionOrigBal) + + gaiaOrigBal, err := gaia.GetBalance(ctx, gaiaUserAddr, gaia.Config().Denom) + require.NoError(t, err) + require.Equal(t, walletAmount, gaiaOrigBal) + + rollappOrigBal, err := rollapp1.GetBalance(ctx, rollappUserAddr, rollapp1.Config().Denom) + require.NoError(t, err) + require.Equal(t, walletAmount, rollappOrigBal) + + t.Run("canonial client test gaia<->dym", func(t *testing.T) { + + // sending between gaia and dymension + firstHopDenom := transfertypes.GetPrefixedDenom(dymGaiaChan.PortID, dymGaiaChan.ChannelID, gaia.Config().Denom) + secondHopDenom := transfertypes.GetPrefixedDenom(gaiaDymChan.PortID, gaiaDymChan.ChannelID, dymension.Config().Denom) + + firstHopDenomTrace := transfertypes.ParseDenomTrace(firstHopDenom) + secondHopDenomTrace := transfertypes.ParseDenomTrace(secondHopDenom) + + firstHopIBCDenom := firstHopDenomTrace.IBCDenom() + secondHopIBCDenom := secondHopDenomTrace.IBCDenom() + + // Send packet from gaia -> dym + transfer := ibc.WalletData{ + Address: dymensionUserAddr, + Denom: gaia.Config().Denom, + Amount: transferAmount, + } + + transferTx, err := gaia.SendIBCTransfer(ctx, gaiaDymChan.ChannelID, gaiaUser.KeyName(), transfer, ibc.TransferOptions{}) + require.NoError(t, err) + err = transferTx.Validate() + require.NoError(t, err) + + // wait until dymension receive transferAmount + err = testutil.WaitForBlocks(ctx, 10, dymension, gaia) + require.NoError(t, err) + + testutil.AssertBalance(t, ctx, gaia, gaiaUserAddr, gaia.Config().Denom, walletAmount.Sub(transferAmount)) + testutil.AssertBalance(t, ctx, dymension, dymensionUserAddr, firstHopIBCDenom, transferAmount) + + // Send back packet from dym -> gaia + transfer = ibc.WalletData{ + Address: gaiaUserAddr, + Denom: dymension.Config().Denom, + Amount: transferAmount, + } + + transferTx, err = dymension.SendIBCTransfer(ctx, dymGaiaChan.ChannelID, dymensionUser.KeyName(), transfer, ibc.TransferOptions{}) + require.NoError(t, err) + err = transferTx.Validate() + require.NoError(t, err) + + // wait until gaia receive transferAmount + err = testutil.WaitForBlocks(ctx, 10, gaia, dymension) + require.NoError(t, err) + + testutil.AssertBalance(t, ctx, dymension, dymensionUserAddr, dymension.Config().Denom, walletAmount.Sub(transferAmount)) + testutil.AssertBalance(t, ctx, gaia, gaiaUserAddr, secondHopIBCDenom, transferAmount) + + // Run invariant check + CheckInvariant(t, ctx, dymension, dymensionUser.KeyName()) + }) +} diff --git a/tests/data/metadata_sequencer1.json b/tests/data/metadata_sequencer1.json new file mode 100644 index 00000000..2378b534 --- /dev/null +++ b/tests/data/metadata_sequencer1.json @@ -0,0 +1,14 @@ +{ + "moniker": "sequencer1111", + "details": "This is a description of the Rollapp.", + "p2p_seeds": ["seed1"], + "rpcs": ["https://rpc.wpd.evm.rollapp.noisnemyd.xyz:443", "https://rpc.wpd.wasm.rollapp.noisnemyd.xyz:443"], + "evm_rpcs": ["https://rpc.wpd.evm.evm.noisnemyd.xyz:443"], + "rest_api_urls": ["https://api.wpd.evm.rollapp.noisnemyd.xyz:443"], + "explorer_url": "explorer_url", + "genesis_urls": ["genesis"], + "contact_details":{}, + "extra_data": [], + "snapshots": [], + "gas_price": "0" + } \ No newline at end of file diff --git a/tests/data/native_denom.json b/tests/data/native_denom.json new file mode 100644 index 00000000..d832ef49 --- /dev/null +++ b/tests/data/native_denom.json @@ -0,0 +1,5 @@ +{ + "display": "RAX", + "base": "urax", + "exponent": 18 +} diff --git a/tests/disconnection_test.go b/tests/disconnection_test.go index 686985b2..6809a051 100644 --- a/tests/disconnection_test.go +++ b/tests/disconnection_test.go @@ -121,11 +121,13 @@ func TestDisconnection_EVM(t *testing.T) { dymintTomlOverrides["settlement_gas_prices"] = "0adym" dymintTomlOverrides["max_idle_time"] = "3s" dymintTomlOverrides["max_proof_time"] = "500ms" - dymintTomlOverrides["batch_submit_max_time"] = "5s" + dymintTomlOverrides["batch_submit_time"] = "50s" + dymintTomlOverrides["batch_submit_bytes"] = "1000" dymintTomlOverrides["block_batch_max_size_bytes"] = "1000" - dymintTomlOverrides["max_supported_batch_skew"] = "1" + dymintTomlOverrides["max_batch_skew"] = "1" dymintTomlOverrides["batch_acceptance_attempts"] = "1" dymintTomlOverrides["batch_acceptance_timeout"] = "5s" + dymintTomlOverrides["p2p_blocksync_enabled"] = "false" configFileOverrides["config/dymint.toml"] = dymintTomlOverrides // Create chain factory with dymension @@ -189,7 +191,7 @@ func TestDisconnection_EVM(t *testing.T) { // This can be used to write to the block database which will index all block data e.g. txs, msgs, events, etc. // BlockDatabaseFile: test.DefaultBlockDatabaseFilepath(), - }, nil, "", nil) + }, nil, "", nil, false, 780) require.NoError(t, err) // Wait for rollapp finalized @@ -246,11 +248,13 @@ func TestDisconnection_Wasm(t *testing.T) { dymintTomlOverrides["settlement_gas_prices"] = "0adym" dymintTomlOverrides["max_idle_time"] = "3s" dymintTomlOverrides["max_proof_time"] = "500ms" - dymintTomlOverrides["batch_submit_max_time"] = "5s" + dymintTomlOverrides["batch_submit_time"] = "50s" + dymintTomlOverrides["batch_submit_bytes"] = "1000" dymintTomlOverrides["block_batch_max_size_bytes"] = "1000" - dymintTomlOverrides["max_supported_batch_skew"] = "1" + dymintTomlOverrides["max_batch_skew"] = "1" dymintTomlOverrides["batch_acceptance_attempts"] = "1" dymintTomlOverrides["batch_acceptance_timeout"] = "5s" + dymintTomlOverrides["p2p_blocksync_enabled"] = "false" configFileOverrides["config/dymint.toml"] = dymintTomlOverrides // Create chain factory with dymension @@ -314,7 +318,7 @@ func TestDisconnection_Wasm(t *testing.T) { // This can be used to write to the block database which will index all block data e.g. txs, msgs, events, etc. // BlockDatabaseFile: test.DefaultBlockDatabaseFilepath(), - }, nil, "", nil) + }, nil, "", nil, false, 780) require.NoError(t, err) // Wait for rollapp finalized diff --git a/tests/eibc_ack_error_test.go b/tests/eibc_ack_error_test.go index 735e7ddf..4a38be71 100644 --- a/tests/eibc_ack_error_test.go +++ b/tests/eibc_ack_error_test.go @@ -47,18 +47,8 @@ func TestEIBC_AckError_Dym_EVM(t *testing.T) { rollapp2_id := "decentrio_12345-1" gas_price_rollapp2 := "0adym" maxIdleTime2 := "1s" - configFileOverrides2 := overridesDymintToml(settlement_layer_rollapp2, settlement_node_address, rollapp2_id, gas_price_rollapp2, maxIdleTime2, maxProofTime, "100s") + configFileOverrides2 := overridesDymintToml(settlement_layer_rollapp2, settlement_node_address, rollapp2_id, gas_price_rollapp2, maxIdleTime2, maxProofTime, "50s") - // Custom dymension epoch for faster disconnection - modifyGenesisKV := append( - dymModifyGenesisKV, - []cosmos.GenesisKV{ - { - Key: "app_state.rollapp.params.dispute_period_in_blocks", - Value: fmt.Sprint(BLOCK_FINALITY_PERIOD), - }, - }..., - ) // Create chain factory with dymension numHubVals := 1 numHubFullNodes := 1 @@ -125,7 +115,7 @@ func TestEIBC_AckError_Dym_EVM(t *testing.T) { GasAdjustment: 1.1, TrustingPeriod: "112h", NoHostMount: false, - ModifyGenesis: modifyDymensionGenesis(modifyGenesisKV), + ModifyGenesis: modifyDymensionGenesis(dymensionGenesisKV), ConfigFileOverrides: nil, }, NumValidators: &numHubVals, @@ -179,7 +169,7 @@ func TestEIBC_AckError_Dym_EVM(t *testing.T) { // This can be used to write to the block database which will index all block data e.g. txs, msgs, events, etc. // BlockDatabaseFile: test.DefaultBlockDatabaseFilepath(), - }, nil, "", nil) + }, nil, "", nil, false, 780) require.NoError(t, err) CreateChannel(ctx, t, r1, eRep, dymension.CosmosChain, rollapp1.CosmosChain, ibcPath) @@ -248,6 +238,9 @@ func TestEIBC_AckError_Dym_EVM(t *testing.T) { _, err = rollapp1.SendIBCTransfer(ctx, channRollApp1Dym.ChannelID, rollappUserAddr, transferData, ibc.TransferOptions{}) require.NoError(t, err) + err = testutil.WaitForBlocks(ctx, 10, dymension, rollapp1) + require.NoError(t, err) + rollappHeight, err := rollapp1.GetNode().Height(ctx) require.NoError(t, err) @@ -259,6 +252,12 @@ func TestEIBC_AckError_Dym_EVM(t *testing.T) { require.NoError(t, err) require.True(t, isFinalized) + _, err = dymension.GetNode().FinalizePacketsUntilHeight(ctx, dymensionUserAddr, rollapp1.GetChainID(), fmt.Sprint(rollappHeight)) + require.NoError(t, err) + + err = testutil.WaitForBlocks(ctx, 10, dymension, rollapp1) + require.NoError(t, err) + // Send a normal ibc tx from RA2 -> Hub transferData = ibc.WalletData{ Address: dymensionUserAddr, @@ -269,6 +268,9 @@ func TestEIBC_AckError_Dym_EVM(t *testing.T) { _, err = rollapp2.SendIBCTransfer(ctx, channRollApp2Dym.ChannelID, rollapp2UserAddr, transferData, ibc.TransferOptions{}) require.NoError(t, err) + err = testutil.WaitForBlocks(ctx, 10, dymension, rollapp2) + require.NoError(t, err) + rollappHeight, err = rollapp2.GetNode().Height(ctx) require.NoError(t, err) @@ -280,6 +282,12 @@ func TestEIBC_AckError_Dym_EVM(t *testing.T) { require.NoError(t, err) require.True(t, isFinalized) + _, err = dymension.GetNode().FinalizePacketsUntilHeight(ctx, dymensionUserAddr, rollapp2.GetChainID(), fmt.Sprint(rollappHeight)) + require.NoError(t, err) + + err = testutil.WaitForBlocks(ctx, 10, dymension, rollapp2) + require.NoError(t, err) + // Get the IBC denom for adym on rollapp dymensionTokenDenom := transfertypes.GetPrefixedDenom(channDymRollApp1.PortID, channDymRollApp1.ChannelID, dymension.Config().Denom) dymensionIBCDenom := transfertypes.ParseDenomTrace(dymensionTokenDenom).IBCDenom() @@ -300,14 +308,6 @@ func TestEIBC_AckError_Dym_EVM(t *testing.T) { err = testutil.WaitForBlocks(ctx, 3, dymension, rollapp1) require.NoError(t, err) - rollappHeight, err := rollapp1.GetNode().Height(ctx) - require.NoError(t, err) - - // wait until the packet is finalized - isFinalized, err := dymension.WaitUntilRollappHeightIsFinalized(ctx, rollapp1.GetChainID(), rollappHeight, 300) - require.NoError(t, err) - require.True(t, isFinalized) - testutil.AssertBalance(t, ctx, dymension, dymensionUserAddr, dymension.Config().Denom, walletAmount.Sub(transferData.Amount)) erc20MAcc, err := rollapp1.Validators[0].QueryModuleAccount(ctx, "erc20") require.NoError(t, err) @@ -355,7 +355,17 @@ func TestEIBC_AckError_Dym_EVM(t *testing.T) { require.True(t, balance.Equal(zeroBal), fmt.Sprintf("Value mismatch. Expected %s, actual %s", zeroBal, balance)) // catch ACK errors - rollappHeight, err = rollapp1.Height(ctx) + err = testutil.WaitForBlocks(ctx, 10, dymension) + require.NoError(t, err) + + rollappHeight, err = rollapp1.GetNode().Height(ctx) + require.NoError(t, err) + + isFinalized, err = dymension.WaitUntilRollappHeightIsFinalized(ctx, rollapp1.GetChainID(), rollappHeight, 300) + require.NoError(t, err) + require.True(t, isFinalized) + + _, err = dymension.GetNode().FinalizePacketsUntilHeight(ctx, dymensionUserAddr, rollapp1.GetChainID(), fmt.Sprint(rollappHeight)) require.NoError(t, err) ack, err := testutil.PollForAck(ctx, rollapp1, rollappHeight, rollappHeight+80, ibcTx.Packet) @@ -379,9 +389,10 @@ func TestEIBC_AckError_Dym_EVM(t *testing.T) { require.NoError(t, err) // get eIbc event - eibcEvents, err := getEIbcEventsWithinBlockRange(ctx, dymension, 30, false) + eibcEvents, err := getEIbcEventsWithinBlockRange(ctx, dymension, 10, false) require.NoError(t, err) - require.Equal(t, eibcEvents[len(eibcEvents)-1].PacketStatus, "PENDING") + fmt.Println(eibcEvents) + require.Equal(t, eibcEvents[0].PacketStatus, "PENDING") // Get the balance of dymensionUserAddr and marketMakerAddr before fulfill the demand order dymensionUserBalance, err := dymension.GetBalance(ctx, dymensionUserAddr, dymension.Config().Denom) @@ -390,7 +401,7 @@ func TestEIBC_AckError_Dym_EVM(t *testing.T) { require.NoError(t, err) // fulfill demand order - txhash, err := dymension.FullfillDemandOrder(ctx, eibcEvents[len(eibcEvents)-1].ID, marketMakerAddr, eibcFee) + txhash, err := dymension.FullfillDemandOrder(ctx, eibcEvents[0].OrderId, marketMakerAddr, eibcFee) require.NoError(t, err) fmt.Println(txhash) // eibcEvent := getEibcEventFromTx(t, dymension, txhash) @@ -399,7 +410,7 @@ func TestEIBC_AckError_Dym_EVM(t *testing.T) { // } // wait a few blocks and verify sender received funds on the hub - err = testutil.WaitForBlocks(ctx, 5, dymension) + err = testutil.WaitForBlocks(ctx, 10, dymension) require.NoError(t, err) // verify funds minus fee were added to receiver's address @@ -414,11 +425,20 @@ func TestEIBC_AckError_Dym_EVM(t *testing.T) { expMmBalanceDymDenom := marketMakerBalance.Sub((transferAmountWithoutFee.Sub(bridgingFee))) require.True(t, balance.Equal(expMmBalanceDymDenom), fmt.Sprintf("Value mismatch. Expected %s, actual %s", expMmBalanceDymDenom, balance)) + rollappHeight, err = rollapp1.Height(ctx) + require.NoError(t, err) + // wait until packet finalization, mm balance should be the same due to the ack error isFinalized, err = dymension.WaitUntilRollappHeightIsFinalized(ctx, rollapp1.GetChainID(), rollappHeight, 300) require.NoError(t, err) require.True(t, isFinalized) + _, err = dymension.GetNode().FinalizePacketsUntilHeight(ctx, dymensionUserAddr, rollapp1.GetChainID(), fmt.Sprint(rollappHeight)) + require.NoError(t, err) + + err = testutil.WaitForBlocks(ctx, 10, dymension, rollapp1) + require.NoError(t, err) + balance, err = dymension.GetBalance(ctx, marketMakerAddr, dymension.Config().Denom) require.NoError(t, err) fmt.Println("Balance of marketMakerAddr after packet finalization:", balance) @@ -437,6 +457,8 @@ func TestEIBC_AckError_Dym_EVM(t *testing.T) { } }, ) + // Run invariant check + CheckInvariant(t, ctx, dymension, dymensionUser.KeyName()) } func TestEIBC_AckError_RA_Token_EVM(t *testing.T) { @@ -453,7 +475,7 @@ func TestEIBC_AckError_RA_Token_EVM(t *testing.T) { gas_price_rollapp1 := "0adym" maxIdleTime1 := "10s" maxProofTime := "500ms" - configFileOverrides1 := overridesDymintToml(settlement_layer_rollapp1, settlement_node_address, rollapp1_id, gas_price_rollapp1, maxIdleTime1, maxProofTime, "100s") + configFileOverrides1 := overridesDymintToml(settlement_layer_rollapp1, settlement_node_address, rollapp1_id, gas_price_rollapp1, maxIdleTime1, maxProofTime, "50s") extraFlags := map[string]interface{}{"genesis-accounts-path": true} @@ -462,18 +484,8 @@ func TestEIBC_AckError_RA_Token_EVM(t *testing.T) { rollapp2_id := "decentrio_12345-1" gas_price_rollapp2 := "0adym" maxIdleTime2 := "1s" - configFileOverrides2 := overridesDymintToml(settlement_layer_rollapp2, settlement_node_address, rollapp2_id, gas_price_rollapp2, maxIdleTime2, maxProofTime, "100s") + configFileOverrides2 := overridesDymintToml(settlement_layer_rollapp2, settlement_node_address, rollapp2_id, gas_price_rollapp2, maxIdleTime2, maxProofTime, "50s") - // Custom dymension epoch for faster disconnection - modifyGenesisKV := append( - dymModifyGenesisKV, - []cosmos.GenesisKV{ - { - Key: "app_state.rollapp.params.dispute_period_in_blocks", - Value: fmt.Sprint(BLOCK_FINALITY_PERIOD), - }, - }..., - ) // Create chain factory with dymension numHubVals := 1 numHubFullNodes := 1 @@ -540,7 +552,7 @@ func TestEIBC_AckError_RA_Token_EVM(t *testing.T) { GasAdjustment: 1.1, TrustingPeriod: "112h", NoHostMount: false, - ModifyGenesis: modifyDymensionGenesis(modifyGenesisKV), + ModifyGenesis: modifyDymensionGenesis(dymensionGenesisKV), ConfigFileOverrides: nil, }, NumValidators: &numHubVals, @@ -594,7 +606,7 @@ func TestEIBC_AckError_RA_Token_EVM(t *testing.T) { // This can be used to write to the block database which will index all block data e.g. txs, msgs, events, etc. // BlockDatabaseFile: test.DefaultBlockDatabaseFilepath(), - }, nil, "", nil) + }, nil, "", nil, false, 780) require.NoError(t, err) CreateChannel(ctx, t, r1, eRep, dymension.CosmosChain, rollapp1.CosmosChain, ibcPath) @@ -666,6 +678,9 @@ func TestEIBC_AckError_RA_Token_EVM(t *testing.T) { _, err = rollapp1.SendIBCTransfer(ctx, channRollApp1Dym.ChannelID, rollappUserAddr, transferData, ibc.TransferOptions{}) require.NoError(t, err) + err = testutil.WaitForBlocks(ctx, 10, dymension, rollapp1) + require.NoError(t, err) + rollappHeight, err := rollapp1.GetNode().Height(ctx) require.NoError(t, err) @@ -677,6 +692,38 @@ func TestEIBC_AckError_RA_Token_EVM(t *testing.T) { require.NoError(t, err) require.True(t, isFinalized) + _, err = dymension.GetNode().FinalizePacketsUntilHeight(ctx, dymensionUserAddr, rollapp1.GetChainID(), fmt.Sprint(rollappHeight)) + require.NoError(t, err) + + valAddr, err := dymension.Validators[0].AccountKeyBech32(ctx, "validator") + require.NoError(t, err) + + transferData = ibc.WalletData{ + Address: valAddr, + Denom: rollapp1.Config().Denom, + Amount: bigTransferAmount, + } + + _, err = rollapp1.SendIBCTransfer(ctx, channRollApp1Dym.ChannelID, rollappUserAddr, transferData, ibc.TransferOptions{}) + require.NoError(t, err) + + err = testutil.WaitForBlocks(ctx, 10, dymension, rollapp1) + require.NoError(t, err) + + rollappHeight, err = rollapp1.GetNode().Height(ctx) + require.NoError(t, err) + + // wait until the packet is finalized + isFinalized, err = dymension.WaitUntilRollappHeightIsFinalized(ctx, rollapp1.GetChainID(), rollappHeight, 300) + require.NoError(t, err) + require.True(t, isFinalized) + + _, err = dymension.GetNode().FinalizePacketsUntilHeight(ctx, dymensionUserAddr, rollapp1.GetChainID(), fmt.Sprint(rollappHeight)) + require.NoError(t, err) + + err = testutil.WaitForBlocks(ctx, 10, dymension, rollapp1) + require.NoError(t, err) + var options ibc.TransferOptions t.Run("Demand order is created upon AckError for rollapp token", func(t *testing.T) { @@ -689,10 +736,13 @@ func TestEIBC_AckError_RA_Token_EVM(t *testing.T) { // market maker needs to have funds on the hub first to be able to fulfill upcoming demand order err = dymension.Validators[0].SendFunds(ctx, "validator", transferData) require.NoError(t, err) + + err = testutil.WaitForBlocks(ctx, 10, dymension, rollapp1) + require.NoError(t, err) + testutil.AssertBalance(t, ctx, dymension, marketMakerAddr, rollappIBCDenom, transferAmount) - // end of preconditions - // + // end of preconditions // prop to disable ibc transfer on rollapp receiveEnableParams := json.RawMessage(`false`) _, err = dymension.GetNode().ParamChangeProposal(ctx, dymensionUser.KeyName(), @@ -734,17 +784,27 @@ func TestEIBC_AckError_RA_Token_EVM(t *testing.T) { require.True(t, balance.Equal(transferAmount.Sub(bridgingFee)), fmt.Sprintf("Value mismatch. Expected %s, actual %s", transferAmount.Sub(bridgingFee), balance)) // catch ACK errors - rollapp1Height, err := rollapp1.Height(ctx) + err = testutil.WaitForBlocks(ctx, 10, dymension) + require.NoError(t, err) + + rollappHeight, err = rollapp1.GetNode().Height(ctx) + require.NoError(t, err) + + isFinalized, err = dymension.WaitUntilRollappHeightIsFinalized(ctx, rollapp1.GetChainID(), rollappHeight, 300) + require.NoError(t, err) + require.True(t, isFinalized) + + _, err = dymension.GetNode().FinalizePacketsUntilHeight(ctx, dymensionUserAddr, rollapp1.GetChainID(), fmt.Sprint(rollappHeight)) require.NoError(t, err) - ack, err := testutil.PollForAck(ctx, rollapp1, rollapp1Height, rollapp1Height+30, ibcTx.Packet) + ack, err := testutil.PollForAck(ctx, rollapp1, rollappHeight, rollappHeight+30, ibcTx.Packet) require.NoError(t, err) // Make sure that the ack contains error require.True(t, bytes.Contains(ack.Acknowledgement, []byte("error"))) // We transfered once to enable ibc-transfer from dym to rollapp - testutil.AssertBalance(t, ctx, rollapp1, rollappUserAddr, rollapp1.Config().Denom, walletAmount.Sub(transferData.Amount)) + testutil.AssertBalance(t, ctx, rollapp1, rollappUserAddr, rollapp1.Config().Denom, walletAmount.Sub(transferData.Amount).Sub(bigTransferAmount)) // At the moment, the ack returned and the demand order status became "finalized" // We will execute the ibc transfer again and try to fulfill the demand order @@ -752,12 +812,13 @@ func TestEIBC_AckError_RA_Token_EVM(t *testing.T) { require.NoError(t, err) // get eIbc event - eibcEvents, err := getEIbcEventsWithinBlockRange(ctx, dymension, 30, false) + eibcEvents, err := getEIbcEventsWithinBlockRange(ctx, dymension, 10, false) require.NoError(t, err) - require.Equal(t, eibcEvents[len(eibcEvents)-1].PacketStatus, "PENDING") + fmt.Println(eibcEvents) + require.Equal(t, eibcEvents[0].PacketStatus, "PENDING") // fulfill demand order - txhash, err := dymension.FullfillDemandOrder(ctx, eibcEvents[len(eibcEvents)-1].ID, marketMakerAddr, eibcFee) + txhash, err := dymension.FullfillDemandOrder(ctx, eibcEvents[0].OrderId, marketMakerAddr, eibcFee) require.NoError(t, err) fmt.Println(txhash) // eibcEvent := getEibcEventFromTx(t, dymension, txhash) @@ -766,7 +827,7 @@ func TestEIBC_AckError_RA_Token_EVM(t *testing.T) { // } // wait a few blocks and verify sender received funds on the hub - err = testutil.WaitForBlocks(ctx, 5, dymension) + err = testutil.WaitForBlocks(ctx, 10, dymension) require.NoError(t, err) // verify funds minus fee were added to receiver's address @@ -788,6 +849,13 @@ func TestEIBC_AckError_RA_Token_EVM(t *testing.T) { isFinalized, err := dymension.WaitUntilRollappHeightIsFinalized(ctx, rollapp1.GetChainID(), rollappHeight, 300) require.NoError(t, err) require.True(t, isFinalized) + + _, err = dymension.GetNode().FinalizePacketsUntilHeight(ctx, dymensionUserAddr, rollapp1.GetChainID(), fmt.Sprint(rollappHeight)) + require.NoError(t, err) + + err = testutil.WaitForBlocks(ctx, 10, dymension, rollapp1) + require.NoError(t, err) + balance, err = dymension.GetBalance(ctx, marketMakerAddr, rollappIBCDenom) require.NoError(t, err) fmt.Println("Balance of marketMakerAddr after packet finalization:", balance) @@ -795,8 +863,10 @@ func TestEIBC_AckError_RA_Token_EVM(t *testing.T) { // wait for a few blocks and check if the fund returns to rollapp testutil.WaitForBlocks(ctx, 20, rollapp1) - testutil.AssertBalance(t, ctx, rollapp1, rollappUserAddr, rollapp1.Config().Denom, walletAmount.Sub(transferAmount)) + testutil.AssertBalance(t, ctx, rollapp1, rollappUserAddr, rollapp1.Config().Denom, walletAmount.Sub(transferAmount).Sub(bigTransferAmount)) }) + // Run invariant check + CheckInvariant(t, ctx, dymension, dymensionUser.KeyName()) } func TestEIBC_AckError_3rd_Party_Token_EVM(t *testing.T) { @@ -813,7 +883,7 @@ func TestEIBC_AckError_3rd_Party_Token_EVM(t *testing.T) { gas_price_rollapp1 := "0adym" maxIdleTime1 := "10s" maxProofTime := "500ms" - configFileOverrides1 := overridesDymintToml(settlement_layer_rollapp1, settlement_node_address, rollapp1_id, gas_price_rollapp1, maxIdleTime1, maxProofTime, "100s") + configFileOverrides1 := overridesDymintToml(settlement_layer_rollapp1, settlement_node_address, rollapp1_id, gas_price_rollapp1, maxIdleTime1, maxProofTime, "50s") extraFlags := map[string]interface{}{"genesis-accounts-path": true} @@ -822,18 +892,8 @@ func TestEIBC_AckError_3rd_Party_Token_EVM(t *testing.T) { rollapp2_id := "decentrio_12345-1" gas_price_rollapp2 := "0adym" maxIdleTime2 := "1s" - configFileOverrides2 := overridesDymintToml(settlement_layer_rollapp2, settlement_node_address, rollapp2_id, gas_price_rollapp2, maxIdleTime2, maxProofTime, "100s") + configFileOverrides2 := overridesDymintToml(settlement_layer_rollapp2, settlement_node_address, rollapp2_id, gas_price_rollapp2, maxIdleTime2, maxProofTime, "50s") - // Custom dymension epoch for faster disconnection - modifyGenesisKV := append( - dymModifyGenesisKV, - []cosmos.GenesisKV{ - { - Key: "app_state.rollapp.params.dispute_period_in_blocks", - Value: fmt.Sprint(BLOCK_FINALITY_PERIOD), - }, - }..., - ) // Create chain factory with dymension numHubVals := 1 numHubFullNodes := 1 @@ -900,7 +960,7 @@ func TestEIBC_AckError_3rd_Party_Token_EVM(t *testing.T) { GasAdjustment: 1.1, TrustingPeriod: "112h", NoHostMount: false, - ModifyGenesis: modifyDymensionGenesis(modifyGenesisKV), + ModifyGenesis: modifyDymensionGenesis(dymensionGenesisKV), ConfigFileOverrides: nil, }, NumValidators: &numHubVals, @@ -954,7 +1014,7 @@ func TestEIBC_AckError_3rd_Party_Token_EVM(t *testing.T) { // This can be used to write to the block database which will index all block data e.g. txs, msgs, events, etc. // BlockDatabaseFile: test.DefaultBlockDatabaseFilepath(), - }, nil, "", nil) + }, nil, "", nil, false, 780) require.NoError(t, err) CreateChannel(ctx, t, r1, eRep, dymension.CosmosChain, rollapp1.CosmosChain, ibcPath) @@ -1037,6 +1097,9 @@ func TestEIBC_AckError_3rd_Party_Token_EVM(t *testing.T) { _, err = rollapp1.SendIBCTransfer(ctx, channRollApp1Dym.ChannelID, rollapp1UserAddr, transferData, ibc.TransferOptions{}) require.NoError(t, err) + err = testutil.WaitForBlocks(ctx, 10, dymension, rollapp1) + require.NoError(t, err) + rollappHeight, err := rollapp1.GetNode().Height(ctx) require.NoError(t, err) @@ -1048,6 +1111,41 @@ func TestEIBC_AckError_3rd_Party_Token_EVM(t *testing.T) { require.NoError(t, err) require.True(t, isFinalized) + _, err = dymension.GetNode().FinalizePacketsUntilHeight(ctx, dymensionUserAddr, rollapp1.GetChainID(), fmt.Sprint(rollappHeight)) + require.NoError(t, err) + + err = testutil.WaitForBlocks(ctx, 10, dymension, rollapp1) + require.NoError(t, err) + + valAddr, err := dymension.Validators[0].AccountKeyBech32(ctx, "validator") + require.NoError(t, err) + + transferData = ibc.WalletData{ + Address: valAddr, + Denom: rollapp2.Config().Denom, + Amount: bigTransferAmount, + } + + _, err = rollapp2.SendIBCTransfer(ctx, channRollApp2Dym.ChannelID, rollapp2UserAddr, transferData, ibc.TransferOptions{}) + require.NoError(t, err) + + err = testutil.WaitForBlocks(ctx, 10, dymension, rollapp2) + require.NoError(t, err) + + rollappHeight, err = rollapp2.GetNode().Height(ctx) + require.NoError(t, err) + + // wait until the packet is finalized + isFinalized, err = dymension.WaitUntilRollappHeightIsFinalized(ctx, rollapp2.GetChainID(), rollappHeight, 300) + require.NoError(t, err) + require.True(t, isFinalized) + + _, err = dymension.GetNode().FinalizePacketsUntilHeight(ctx, dymensionUserAddr, rollapp2.GetChainID(), fmt.Sprint(rollappHeight)) + require.NoError(t, err) + + err = testutil.WaitForBlocks(ctx, 10, dymension, rollapp2) + require.NoError(t, err) + var options ibc.TransferOptions // register ibc denom on rollapp1 @@ -1103,6 +1201,10 @@ func TestEIBC_AckError_3rd_Party_Token_EVM(t *testing.T) { // market maker needs to have funds on the hub first to be able to fulfill upcoming demand order err = dymension.Validators[0].SendFunds(ctx, "validator", transferData) require.NoError(t, err) + + err = testutil.WaitForBlocks(ctx, 20, dymension, rollapp1) + require.NoError(t, err) + testutil.AssertBalance(t, ctx, dymension, marketMakerAddr, thirdPartyDenom, transferAmount) // user from rollapp1 should have funds to be able to make the ibc transfer transaction transferData = ibc.WalletData{ @@ -1117,14 +1219,6 @@ func TestEIBC_AckError_3rd_Party_Token_EVM(t *testing.T) { err = testutil.WaitForBlocks(ctx, 3, dymension, rollapp1) require.NoError(t, err) - rollappHeight, err := rollapp1.GetNode().Height(ctx) - require.NoError(t, err) - - // wait until the packet is finalized - isFinalized, err := dymension.WaitUntilRollappHeightIsFinalized(ctx, rollapp1.GetChainID(), rollappHeight, 300) - require.NoError(t, err) - require.True(t, isFinalized) - erc20MAcc, err := rollapp1.Validators[0].QueryModuleAccount(ctx, "erc20") require.NoError(t, err) erc20MAccAddr := erc20MAcc.Account.BaseAccount.Address @@ -1172,10 +1266,20 @@ func TestEIBC_AckError_3rd_Party_Token_EVM(t *testing.T) { require.True(t, balance.Equal(zeroBal), fmt.Sprintf("Value mismatch. Expected %s, actual %s", zeroBal, balance)) // catch ACK errors - rollapp1Height, err := rollapp1.Height(ctx) + err = testutil.WaitForBlocks(ctx, 10, dymension) require.NoError(t, err) - ack, err := testutil.PollForAck(ctx, rollapp1, rollapp1Height, rollapp1Height+30, ibcTx.Packet) + rollappHeight, err = rollapp1.GetNode().Height(ctx) + require.NoError(t, err) + + isFinalized, err = dymension.WaitUntilRollappHeightIsFinalized(ctx, rollapp1.GetChainID(), rollappHeight, 300) + require.NoError(t, err) + require.True(t, isFinalized) + + _, err = dymension.GetNode().FinalizePacketsUntilHeight(ctx, dymensionUserAddr, rollapp1.GetChainID(), fmt.Sprint(rollappHeight)) + require.NoError(t, err) + + ack, err := testutil.PollForAck(ctx, rollapp1, rollappHeight, rollappHeight+30, ibcTx.Packet) require.NoError(t, err) // Make sure that the ack contains error @@ -1189,12 +1293,13 @@ func TestEIBC_AckError_3rd_Party_Token_EVM(t *testing.T) { require.NoError(t, err) // get eIbc event - eibcEvents, err := getEIbcEventsWithinBlockRange(ctx, dymension, 30, false) + eibcEvents, err := getEIbcEventsWithinBlockRange(ctx, dymension, 10, false) require.NoError(t, err) - require.Equal(t, eibcEvents[len(eibcEvents)-1].PacketStatus, "PENDING") + fmt.Println(eibcEvents) + require.Equal(t, eibcEvents[0].PacketStatus, "PENDING") // fulfill demand order - txhash, err := dymension.FullfillDemandOrder(ctx, eibcEvents[len(eibcEvents)-1].ID, marketMakerAddr, eibcFee) + txhash, err := dymension.FullfillDemandOrder(ctx, eibcEvents[0].OrderId, marketMakerAddr, eibcFee) require.NoError(t, err) fmt.Println(txhash) // eibcEvent := getEibcEventFromTx(t, dymension, txhash) @@ -1203,7 +1308,7 @@ func TestEIBC_AckError_3rd_Party_Token_EVM(t *testing.T) { // } // wait a few blocks and verify sender received funds on the hub - err = testutil.WaitForBlocks(ctx, 5, dymension) + err = testutil.WaitForBlocks(ctx, 10, dymension) require.NoError(t, err) // verify funds minus fee were added to receiver's address @@ -1225,6 +1330,13 @@ func TestEIBC_AckError_3rd_Party_Token_EVM(t *testing.T) { isFinalized, err = dymension.WaitUntilRollappHeightIsFinalized(ctx, rollapp1.GetChainID(), rollappHeight, 300) require.NoError(t, err) require.True(t, isFinalized) + + _, err = dymension.GetNode().FinalizePacketsUntilHeight(ctx, dymensionUserAddr, rollapp1.GetChainID(), fmt.Sprint(rollappHeight)) + require.NoError(t, err) + + err = testutil.WaitForBlocks(ctx, 10, dymension, rollapp1) + require.NoError(t, err) + balance, err = dymension.GetBalance(ctx, marketMakerAddr, thirdPartyDenom) require.NoError(t, err) fmt.Println("Balance of marketMakerAddr after packet finalization:", balance) @@ -1234,6 +1346,8 @@ func TestEIBC_AckError_3rd_Party_Token_EVM(t *testing.T) { testutil.WaitForBlocks(ctx, 20, rollapp1) testutil.AssertBalance(t, ctx, rollapp1, rollapp1UserAddr, rollapp1.Config().Denom, walletAmount.Sub(transferAmount)) }) + // Run invariant check + CheckInvariant(t, ctx, dymension, dymensionUser.KeyName()) } func TestEIBC_AckError_Dym_Wasm(t *testing.T) { @@ -1259,18 +1373,8 @@ func TestEIBC_AckError_Dym_Wasm(t *testing.T) { rollapp2_id := "decentrio_12345-1" gas_price_rollapp2 := "0adym" maxIdleTime2 := "1s" - configFileOverrides2 := overridesDymintToml(settlement_layer_rollapp2, settlement_node_address, rollapp2_id, gas_price_rollapp2, maxIdleTime2, maxProofTime, "100s") + configFileOverrides2 := overridesDymintToml(settlement_layer_rollapp2, settlement_node_address, rollapp2_id, gas_price_rollapp2, maxIdleTime2, maxProofTime, "50s") - // Custom dymension epoch for faster disconnection - modifyGenesisKV := append( - dymModifyGenesisKV, - []cosmos.GenesisKV{ - { - Key: "app_state.rollapp.params.dispute_period_in_blocks", - Value: fmt.Sprint(BLOCK_FINALITY_PERIOD), - }, - }..., - ) // Create chain factory with dymension numHubVals := 1 numHubFullNodes := 1 @@ -1337,7 +1441,7 @@ func TestEIBC_AckError_Dym_Wasm(t *testing.T) { GasAdjustment: 1.1, TrustingPeriod: "112h", NoHostMount: false, - ModifyGenesis: modifyDymensionGenesis(modifyGenesisKV), + ModifyGenesis: modifyDymensionGenesis(dymensionGenesisKV), ConfigFileOverrides: nil, }, NumValidators: &numHubVals, @@ -1391,7 +1495,7 @@ func TestEIBC_AckError_Dym_Wasm(t *testing.T) { // This can be used to write to the block database which will index all block data e.g. txs, msgs, events, etc. // BlockDatabaseFile: test.DefaultBlockDatabaseFilepath(), - }, nil, "", nil) + }, nil, "", nil, false, 780) require.NoError(t, err) CreateChannel(ctx, t, r1, eRep, dymension.CosmosChain, rollapp1.CosmosChain, ibcPath) @@ -1459,6 +1563,9 @@ func TestEIBC_AckError_Dym_Wasm(t *testing.T) { _, err = rollapp1.SendIBCTransfer(ctx, channRollApp1Dym.ChannelID, rollappUserAddr, transferData, ibc.TransferOptions{}) require.NoError(t, err) + err = testutil.WaitForBlocks(ctx, 10, dymension, rollapp1) + require.NoError(t, err) + rollappHeight, err := rollapp1.GetNode().Height(ctx) require.NoError(t, err) @@ -1470,6 +1577,12 @@ func TestEIBC_AckError_Dym_Wasm(t *testing.T) { require.NoError(t, err) require.True(t, isFinalized) + _, err = dymension.GetNode().FinalizePacketsUntilHeight(ctx, dymensionUserAddr, rollapp1.GetChainID(), fmt.Sprint(rollappHeight)) + require.NoError(t, err) + + err = testutil.WaitForBlocks(ctx, 10, dymension, rollapp1) + require.NoError(t, err) + // Send a normal ibc tx from RA2 -> Hub transferData = ibc.WalletData{ Address: dymensionUserAddr, @@ -1480,6 +1593,9 @@ func TestEIBC_AckError_Dym_Wasm(t *testing.T) { _, err = rollapp2.SendIBCTransfer(ctx, channRollApp2Dym.ChannelID, rollapp2UserAddr, transferData, ibc.TransferOptions{}) require.NoError(t, err) + err = testutil.WaitForBlocks(ctx, 10, dymension, rollapp2) + require.NoError(t, err) + rollappHeight, err = rollapp2.GetNode().Height(ctx) require.NoError(t, err) @@ -1491,6 +1607,12 @@ func TestEIBC_AckError_Dym_Wasm(t *testing.T) { require.NoError(t, err) require.True(t, isFinalized) + _, err = dymension.GetNode().FinalizePacketsUntilHeight(ctx, dymensionUserAddr, rollapp2.GetChainID(), fmt.Sprint(rollappHeight)) + require.NoError(t, err) + + err = testutil.WaitForBlocks(ctx, 10, dymension, rollapp2) + require.NoError(t, err) + // Get the IBC denom for adym on rollapp dymensionTokenDenom := transfertypes.GetPrefixedDenom(channDymRollApp1.PortID, channDymRollApp1.ChannelID, dymension.Config().Denom) dymensionIBCDenom := transfertypes.ParseDenomTrace(dymensionTokenDenom).IBCDenom() @@ -1511,14 +1633,6 @@ func TestEIBC_AckError_Dym_Wasm(t *testing.T) { err = testutil.WaitForBlocks(ctx, 3, dymension, rollapp1) require.NoError(t, err) - rollappHeight, err := rollapp1.GetNode().Height(ctx) - require.NoError(t, err) - - // wait until the packet is finalized - isFinalized, err := dymension.WaitUntilRollappHeightIsFinalized(ctx, rollapp1.GetChainID(), rollappHeight, 300) - require.NoError(t, err) - require.True(t, isFinalized) - testutil.AssertBalance(t, ctx, dymension, dymensionUserAddr, dymension.Config().Denom, walletAmount.Sub(transferData.Amount)) testutil.AssertBalance(t, ctx, rollapp1, rollappUserAddr, dymensionIBCDenom, transferAmount) @@ -1561,10 +1675,21 @@ func TestEIBC_AckError_Dym_Wasm(t *testing.T) { require.True(t, balance.Equal(zeroBal), fmt.Sprintf("Value mismatch. Expected %s, actual %s", zeroBal, balance)) // catch ACK errors + err = testutil.WaitForBlocks(ctx, 10, dymension) + require.NoError(t, err) + rollappHeight, err = rollapp1.Height(ctx) require.NoError(t, err) - ack, err := testutil.PollForAck(ctx, rollapp1, rollappHeight, rollappHeight+80, ibcTx.Packet) + // wait until the packet is finalized + isFinalized, err = dymension.WaitUntilRollappHeightIsFinalized(ctx, rollapp1.GetChainID(), rollappHeight, 300) + require.NoError(t, err) + require.True(t, isFinalized) + + _, err = dymension.GetNode().FinalizePacketsUntilHeight(ctx, dymensionUserAddr, rollapp1.GetChainID(), fmt.Sprint(rollappHeight)) + require.NoError(t, err) + + ack, err := testutil.PollForAck(ctx, rollapp1, rollappHeight, rollappHeight+30, ibcTx.Packet) require.NoError(t, err) // Make sure that the ack contains error @@ -1578,8 +1703,9 @@ func TestEIBC_AckError_Dym_Wasm(t *testing.T) { require.NoError(t, err) // get eIbc event - eibcEvents, err := getEIbcEventsWithinBlockRange(ctx, dymension, 30, false) + eibcEvents, err := getEIbcEventsWithinBlockRange(ctx, dymension, 10, false) require.NoError(t, err) + fmt.Println(eibcEvents) require.Equal(t, eibcEvents[len(eibcEvents)-1].PacketStatus, "PENDING") // Get the balance of dymensionUserAddr and marketMakerAddr before fulfill the demand order @@ -1589,7 +1715,7 @@ func TestEIBC_AckError_Dym_Wasm(t *testing.T) { require.NoError(t, err) // fulfill demand order - txhash, err := dymension.FullfillDemandOrder(ctx, eibcEvents[len(eibcEvents)-1].ID, marketMakerAddr, eibcFee) + txhash, err := dymension.FullfillDemandOrder(ctx, eibcEvents[len(eibcEvents)-1].OrderId, marketMakerAddr, eibcFee) require.NoError(t, err) fmt.Println(txhash) // eibcEvent := getEibcEventFromTx(t, dymension, txhash) @@ -1598,7 +1724,7 @@ func TestEIBC_AckError_Dym_Wasm(t *testing.T) { // } // wait a few blocks and verify sender received funds on the hub - err = testutil.WaitForBlocks(ctx, 5, dymension) + err = testutil.WaitForBlocks(ctx, 10, dymension) require.NoError(t, err) // verify funds minus fee were added to receiver's address @@ -1613,10 +1739,20 @@ func TestEIBC_AckError_Dym_Wasm(t *testing.T) { expMmBalanceDymDenom := marketMakerBalance.Sub((transferAmountWithoutFee.Sub(bridgingFee))) require.True(t, balance.Equal(expMmBalanceDymDenom), fmt.Sprintf("Value mismatch. Expected %s, actual %s", expMmBalanceDymDenom, balance)) + rollappHeight, err = rollapp1.Height(ctx) + require.NoError(t, err) + // wait until packet finalization, mm balance should be the same due to the ack error isFinalized, err = dymension.WaitUntilRollappHeightIsFinalized(ctx, rollapp1.GetChainID(), rollappHeight, 300) require.NoError(t, err) require.True(t, isFinalized) + + _, err = dymension.GetNode().FinalizePacketsUntilHeight(ctx, dymensionUserAddr, rollapp1.GetChainID(), fmt.Sprint(rollappHeight)) + require.NoError(t, err) + + err = testutil.WaitForBlocks(ctx, 10, dymension, rollapp1) + require.NoError(t, err) + balance, err = dymension.GetBalance(ctx, marketMakerAddr, dymension.Config().Denom) require.NoError(t, err) fmt.Println("Balance of marketMakerAddr after packet finalization:", balance) @@ -1635,6 +1771,8 @@ func TestEIBC_AckError_Dym_Wasm(t *testing.T) { } }, ) + // Run invariant check + CheckInvariant(t, ctx, dymension, dymensionUser.KeyName()) } func TestEIBC_AckError_RA_Token_Wasm(t *testing.T) { @@ -1651,7 +1789,7 @@ func TestEIBC_AckError_RA_Token_Wasm(t *testing.T) { gas_price_rollapp1 := "0adym" maxIdleTime1 := "10s" maxProofTime := "500ms" - configFileOverrides1 := overridesDymintToml(settlement_layer_rollapp1, settlement_node_address, rollapp1_id, gas_price_rollapp1, maxIdleTime1, maxProofTime, "100s") + configFileOverrides1 := overridesDymintToml(settlement_layer_rollapp1, settlement_node_address, rollapp1_id, gas_price_rollapp1, maxIdleTime1, maxProofTime, "50s") extraFlags := map[string]interface{}{"genesis-accounts-path": true} @@ -1660,18 +1798,8 @@ func TestEIBC_AckError_RA_Token_Wasm(t *testing.T) { rollapp2_id := "decentrio_12345-1" gas_price_rollapp2 := "0adym" maxIdleTime2 := "1s" - configFileOverrides2 := overridesDymintToml(settlement_layer_rollapp2, settlement_node_address, rollapp2_id, gas_price_rollapp2, maxIdleTime2, maxProofTime, "100s") + configFileOverrides2 := overridesDymintToml(settlement_layer_rollapp2, settlement_node_address, rollapp2_id, gas_price_rollapp2, maxIdleTime2, maxProofTime, "50s") - // Custom dymension epoch for faster disconnection - modifyGenesisKV := append( - dymModifyGenesisKV, - []cosmos.GenesisKV{ - { - Key: "app_state.rollapp.params.dispute_period_in_blocks", - Value: fmt.Sprint(BLOCK_FINALITY_PERIOD), - }, - }..., - ) // Create chain factory with dymension numHubVals := 1 numHubFullNodes := 1 @@ -1738,7 +1866,7 @@ func TestEIBC_AckError_RA_Token_Wasm(t *testing.T) { GasAdjustment: 1.1, TrustingPeriod: "112h", NoHostMount: false, - ModifyGenesis: modifyDymensionGenesis(modifyGenesisKV), + ModifyGenesis: modifyDymensionGenesis(dymensionGenesisKV), ConfigFileOverrides: nil, }, NumValidators: &numHubVals, @@ -1792,7 +1920,7 @@ func TestEIBC_AckError_RA_Token_Wasm(t *testing.T) { // This can be used to write to the block database which will index all block data e.g. txs, msgs, events, etc. // BlockDatabaseFile: test.DefaultBlockDatabaseFilepath(), - }, nil, "", nil) + }, nil, "", nil, false, 780) require.NoError(t, err) CreateChannel(ctx, t, r1, eRep, dymension.CosmosChain, rollapp1.CosmosChain, ibcPath) @@ -1864,6 +1992,9 @@ func TestEIBC_AckError_RA_Token_Wasm(t *testing.T) { _, err = rollapp1.SendIBCTransfer(ctx, channRollApp1Dym.ChannelID, rollappUserAddr, transferData, ibc.TransferOptions{}) require.NoError(t, err) + err = testutil.WaitForBlocks(ctx, 10, dymension, rollapp1) + require.NoError(t, err) + rollappHeight, err := rollapp1.GetNode().Height(ctx) require.NoError(t, err) @@ -1875,6 +2006,38 @@ func TestEIBC_AckError_RA_Token_Wasm(t *testing.T) { require.NoError(t, err) require.True(t, isFinalized) + _, err = dymension.GetNode().FinalizePacketsUntilHeight(ctx, dymensionUserAddr, rollapp1.GetChainID(), fmt.Sprint(rollappHeight)) + require.NoError(t, err) + + valAddr, err := dymension.Validators[0].AccountKeyBech32(ctx, "validator") + require.NoError(t, err) + + transferData = ibc.WalletData{ + Address: valAddr, + Denom: rollapp1.Config().Denom, + Amount: bigTransferAmount, + } + + _, err = rollapp1.SendIBCTransfer(ctx, channRollApp1Dym.ChannelID, rollappUserAddr, transferData, ibc.TransferOptions{}) + require.NoError(t, err) + + err = testutil.WaitForBlocks(ctx, 10, dymension, rollapp1) + require.NoError(t, err) + + rollappHeight, err = rollapp1.GetNode().Height(ctx) + require.NoError(t, err) + + // wait until the packet is finalized + isFinalized, err = dymension.WaitUntilRollappHeightIsFinalized(ctx, rollapp1.GetChainID(), rollappHeight, 300) + require.NoError(t, err) + require.True(t, isFinalized) + + _, err = dymension.GetNode().FinalizePacketsUntilHeight(ctx, dymensionUserAddr, rollapp1.GetChainID(), fmt.Sprint(rollappHeight)) + require.NoError(t, err) + + err = testutil.WaitForBlocks(ctx, 10, dymension, rollapp1) + require.NoError(t, err) + var options ibc.TransferOptions t.Run("Demand order is created upon AckError for rollapp token", func(t *testing.T) { @@ -1887,6 +2050,10 @@ func TestEIBC_AckError_RA_Token_Wasm(t *testing.T) { // market maker needs to have funds on the hub first to be able to fulfill upcoming demand order err = dymension.Validators[0].SendFunds(ctx, "validator", transferData) require.NoError(t, err) + + err = testutil.WaitForBlocks(ctx, 10, dymension, rollapp1) + require.NoError(t, err) + testutil.AssertBalance(t, ctx, dymension, marketMakerAddr, rollappIBCDenom, transferAmount) // end of preconditions @@ -1929,17 +2096,27 @@ func TestEIBC_AckError_RA_Token_Wasm(t *testing.T) { require.True(t, balance.Equal(transferAmount.Sub(bridgingFee)), fmt.Sprintf("Value mismatch. Expected %s, actual %s", transferAmount.Sub(bridgingFee), balance)) // catch ACK errors - rollapp1Height, err := rollapp1.Height(ctx) + err = testutil.WaitForBlocks(ctx, 10, dymension) + require.NoError(t, err) + + rollappHeight, err = rollapp1.GetNode().Height(ctx) require.NoError(t, err) - ack, err := testutil.PollForAck(ctx, rollapp1, rollapp1Height, rollapp1Height+30, ibcTx.Packet) + isFinalized, err = dymension.WaitUntilRollappHeightIsFinalized(ctx, rollapp1.GetChainID(), rollappHeight, 300) + require.NoError(t, err) + require.True(t, isFinalized) + + _, err = dymension.GetNode().FinalizePacketsUntilHeight(ctx, dymensionUserAddr, rollapp1.GetChainID(), fmt.Sprint(rollappHeight)) + require.NoError(t, err) + + ack, err := testutil.PollForAck(ctx, rollapp1, rollappHeight, rollappHeight+30, ibcTx.Packet) require.NoError(t, err) // Make sure that the ack contains error require.True(t, bytes.Contains(ack.Acknowledgement, []byte("error"))) // We transfered once to enable ibc-transfer from dym to rollapp - testutil.AssertBalance(t, ctx, rollapp1, rollappUserAddr, rollapp1.Config().Denom, walletAmount.Sub(transferData.Amount)) + testutil.AssertBalance(t, ctx, rollapp1, rollappUserAddr, rollapp1.Config().Denom, walletAmount.Sub(transferData.Amount).Sub(bigTransferAmount)) // At the moment, the ack returned and the demand order status became "finalized" // We will execute the ibc transfer again and try to fulfill the demand order @@ -1947,12 +2124,13 @@ func TestEIBC_AckError_RA_Token_Wasm(t *testing.T) { require.NoError(t, err) // get eIbc event - eibcEvents, err := getEIbcEventsWithinBlockRange(ctx, dymension, 30, false) + eibcEvents, err := getEIbcEventsWithinBlockRange(ctx, dymension, 10, false) require.NoError(t, err) + fmt.Println(eibcEvents) require.Equal(t, eibcEvents[len(eibcEvents)-1].PacketStatus, "PENDING") // fulfill demand order - txhash, err := dymension.FullfillDemandOrder(ctx, eibcEvents[len(eibcEvents)-1].ID, marketMakerAddr, eibcFee) + txhash, err := dymension.FullfillDemandOrder(ctx, eibcEvents[len(eibcEvents)-1].OrderId, marketMakerAddr, eibcFee) require.NoError(t, err) fmt.Println(txhash) // eibcEvent := getEibcEventFromTx(t, dymension, txhash) @@ -1961,7 +2139,7 @@ func TestEIBC_AckError_RA_Token_Wasm(t *testing.T) { // } // wait a few blocks and verify sender received funds on the hub - err = testutil.WaitForBlocks(ctx, 5, dymension) + err = testutil.WaitForBlocks(ctx, 10, dymension) require.NoError(t, err) // verify funds minus fee were added to receiver's address @@ -1983,6 +2161,13 @@ func TestEIBC_AckError_RA_Token_Wasm(t *testing.T) { isFinalized, err := dymension.WaitUntilRollappHeightIsFinalized(ctx, rollapp1.GetChainID(), rollappHeight, 300) require.NoError(t, err) require.True(t, isFinalized) + + _, err = dymension.GetNode().FinalizePacketsUntilHeight(ctx, dymensionUserAddr, rollapp1.GetChainID(), fmt.Sprint(rollappHeight)) + require.NoError(t, err) + + err = testutil.WaitForBlocks(ctx, 10, dymension, rollapp1) + require.NoError(t, err) + balance, err = dymension.GetBalance(ctx, marketMakerAddr, rollappIBCDenom) require.NoError(t, err) fmt.Println("Balance of marketMakerAddr after packet finalization:", balance) @@ -1990,8 +2175,10 @@ func TestEIBC_AckError_RA_Token_Wasm(t *testing.T) { // wait for a few blocks and check if the fund returns to rollapp testutil.WaitForBlocks(ctx, 20, rollapp1) - testutil.AssertBalance(t, ctx, rollapp1, rollappUserAddr, rollapp1.Config().Denom, walletAmount.Sub(transferAmount)) + testutil.AssertBalance(t, ctx, rollapp1, rollappUserAddr, rollapp1.Config().Denom, walletAmount.Sub(transferAmount).Sub(bigTransferAmount)) }) + // Run invariant check + CheckInvariant(t, ctx, dymension, dymensionUser.KeyName()) } func TestEIBC_AckError_3rd_Party_Token_Wasm(t *testing.T) { @@ -2008,7 +2195,7 @@ func TestEIBC_AckError_3rd_Party_Token_Wasm(t *testing.T) { gas_price_rollapp1 := "0adym" maxIdleTime1 := "10s" maxProofTime := "500ms" - configFileOverrides1 := overridesDymintToml(settlement_layer_rollapp1, settlement_node_address, rollapp1_id, gas_price_rollapp1, maxIdleTime1, maxProofTime, "100s") + configFileOverrides1 := overridesDymintToml(settlement_layer_rollapp1, settlement_node_address, rollapp1_id, gas_price_rollapp1, maxIdleTime1, maxProofTime, "50s") extraFlags := map[string]interface{}{"genesis-accounts-path": true} @@ -2017,18 +2204,8 @@ func TestEIBC_AckError_3rd_Party_Token_Wasm(t *testing.T) { rollapp2_id := "decentrio_12345-1" gas_price_rollapp2 := "0adym" maxIdleTime2 := "1s" - configFileOverrides2 := overridesDymintToml(settlement_layer_rollapp2, settlement_node_address, rollapp2_id, gas_price_rollapp2, maxIdleTime2, maxProofTime, "100s") + configFileOverrides2 := overridesDymintToml(settlement_layer_rollapp2, settlement_node_address, rollapp2_id, gas_price_rollapp2, maxIdleTime2, maxProofTime, "50s") - // Custom dymension epoch for faster disconnection - modifyGenesisKV := append( - dymModifyGenesisKV, - []cosmos.GenesisKV{ - { - Key: "app_state.rollapp.params.dispute_period_in_blocks", - Value: fmt.Sprint(BLOCK_FINALITY_PERIOD), - }, - }..., - ) // Create chain factory with dymension numHubVals := 1 numHubFullNodes := 1 @@ -2095,7 +2272,7 @@ func TestEIBC_AckError_3rd_Party_Token_Wasm(t *testing.T) { GasAdjustment: 1.1, TrustingPeriod: "112h", NoHostMount: false, - ModifyGenesis: modifyDymensionGenesis(modifyGenesisKV), + ModifyGenesis: modifyDymensionGenesis(dymensionGenesisKV), ConfigFileOverrides: nil, }, NumValidators: &numHubVals, @@ -2149,7 +2326,7 @@ func TestEIBC_AckError_3rd_Party_Token_Wasm(t *testing.T) { // This can be used to write to the block database which will index all block data e.g. txs, msgs, events, etc. // BlockDatabaseFile: test.DefaultBlockDatabaseFilepath(), - }, nil, "", nil) + }, nil, "", nil, false, 780) require.NoError(t, err) CreateChannel(ctx, t, r1, eRep, dymension.CosmosChain, rollapp1.CosmosChain, ibcPath) @@ -2232,6 +2409,9 @@ func TestEIBC_AckError_3rd_Party_Token_Wasm(t *testing.T) { _, err = rollapp1.SendIBCTransfer(ctx, channRollApp1Dym.ChannelID, rollapp1UserAddr, transferData, ibc.TransferOptions{}) require.NoError(t, err) + err = testutil.WaitForBlocks(ctx, 10, dymension, rollapp1) + require.NoError(t, err) + rollappHeight, err := rollapp1.GetNode().Height(ctx) require.NoError(t, err) @@ -2243,6 +2423,41 @@ func TestEIBC_AckError_3rd_Party_Token_Wasm(t *testing.T) { require.NoError(t, err) require.True(t, isFinalized) + _, err = dymension.GetNode().FinalizePacketsUntilHeight(ctx, dymensionUserAddr, rollapp1.GetChainID(), fmt.Sprint(rollappHeight)) + require.NoError(t, err) + + err = testutil.WaitForBlocks(ctx, 10, dymension, rollapp1) + require.NoError(t, err) + + valAddr, err := dymension.Validators[0].AccountKeyBech32(ctx, "validator") + require.NoError(t, err) + + transferData = ibc.WalletData{ + Address: valAddr, + Denom: rollapp2.Config().Denom, + Amount: bigTransferAmount, + } + + _, err = rollapp2.SendIBCTransfer(ctx, channRollApp2Dym.ChannelID, rollapp2UserAddr, transferData, ibc.TransferOptions{}) + require.NoError(t, err) + + err = testutil.WaitForBlocks(ctx, 10, dymension, rollapp2) + require.NoError(t, err) + + rollappHeight, err = rollapp2.GetNode().Height(ctx) + require.NoError(t, err) + + // wait until the packet is finalized + isFinalized, err = dymension.WaitUntilRollappHeightIsFinalized(ctx, rollapp2.GetChainID(), rollappHeight, 300) + require.NoError(t, err) + require.True(t, isFinalized) + + _, err = dymension.GetNode().FinalizePacketsUntilHeight(ctx, dymensionUserAddr, rollapp2.GetChainID(), fmt.Sprint(rollappHeight)) + require.NoError(t, err) + + err = testutil.WaitForBlocks(ctx, 10, dymension, rollapp2) + require.NoError(t, err) + var options ibc.TransferOptions t.Run("Demand order is created upon AckError for rollapp token", func(t *testing.T) { @@ -2255,6 +2470,10 @@ func TestEIBC_AckError_3rd_Party_Token_Wasm(t *testing.T) { // market maker needs to have funds on the hub first to be able to fulfill upcoming demand order err = dymension.Validators[0].SendFunds(ctx, "validator", transferData) require.NoError(t, err) + + err = testutil.WaitForBlocks(ctx, 20, dymension, rollapp1) + require.NoError(t, err) + testutil.AssertBalance(t, ctx, dymension, marketMakerAddr, thirdPartyDenom, transferAmount) // user from rollapp1 should have funds to be able to make the ibc transfer transaction transferData = ibc.WalletData{ @@ -2277,6 +2496,9 @@ func TestEIBC_AckError_3rd_Party_Token_Wasm(t *testing.T) { require.NoError(t, err) require.True(t, isFinalized) + err = testutil.WaitForBlocks(ctx, 10, dymension, rollapp1) + require.NoError(t, err) + testutil.AssertBalance(t, ctx, rollapp1, rollapp1UserAddr, thirdPartyIBCDenomOnRA, transferAmount) // end of preconditions @@ -2319,10 +2541,20 @@ func TestEIBC_AckError_3rd_Party_Token_Wasm(t *testing.T) { require.True(t, balance.Equal(zeroBal), fmt.Sprintf("Value mismatch. Expected %s, actual %s", zeroBal, balance)) // catch ACK errors - rollapp1Height, err := rollapp1.Height(ctx) + err = testutil.WaitForBlocks(ctx, 10, dymension) require.NoError(t, err) - ack, err := testutil.PollForAck(ctx, rollapp1, rollapp1Height, rollapp1Height+30, ibcTx.Packet) + rollappHeight, err = rollapp1.GetNode().Height(ctx) + require.NoError(t, err) + + isFinalized, err = dymension.WaitUntilRollappHeightIsFinalized(ctx, rollapp1.GetChainID(), rollappHeight, 300) + require.NoError(t, err) + require.True(t, isFinalized) + + _, err = dymension.GetNode().FinalizePacketsUntilHeight(ctx, dymensionUserAddr, rollapp1.GetChainID(), fmt.Sprint(rollappHeight)) + require.NoError(t, err) + + ack, err := testutil.PollForAck(ctx, rollapp1, rollappHeight, rollappHeight+30, ibcTx.Packet) require.NoError(t, err) // Make sure that the ack contains error @@ -2336,12 +2568,13 @@ func TestEIBC_AckError_3rd_Party_Token_Wasm(t *testing.T) { require.NoError(t, err) // get eIbc event - eibcEvents, err := getEIbcEventsWithinBlockRange(ctx, dymension, 30, false) + eibcEvents, err := getEIbcEventsWithinBlockRange(ctx, dymension, 10, false) require.NoError(t, err) + fmt.Println(eibcEvents) require.Equal(t, eibcEvents[len(eibcEvents)-1].PacketStatus, "PENDING") // fulfill demand order - txhash, err := dymension.FullfillDemandOrder(ctx, eibcEvents[len(eibcEvents)-1].ID, marketMakerAddr, eibcFee) + txhash, err := dymension.FullfillDemandOrder(ctx, eibcEvents[len(eibcEvents)-1].OrderId, marketMakerAddr, eibcFee) require.NoError(t, err) fmt.Println(txhash) // eibcEvent := getEibcEventFromTx(t, dymension, txhash) @@ -2350,7 +2583,7 @@ func TestEIBC_AckError_3rd_Party_Token_Wasm(t *testing.T) { // } // wait a few blocks and verify sender received funds on the hub - err = testutil.WaitForBlocks(ctx, 5, dymension) + err = testutil.WaitForBlocks(ctx, 10, dymension) require.NoError(t, err) // verify funds minus fee were added to receiver's address @@ -2372,6 +2605,13 @@ func TestEIBC_AckError_3rd_Party_Token_Wasm(t *testing.T) { isFinalized, err = dymension.WaitUntilRollappHeightIsFinalized(ctx, rollapp1.GetChainID(), rollappHeight, 300) require.NoError(t, err) require.True(t, isFinalized) + + _, err = dymension.GetNode().FinalizePacketsUntilHeight(ctx, dymensionUserAddr, rollapp1.GetChainID(), fmt.Sprint(rollappHeight)) + require.NoError(t, err) + + err = testutil.WaitForBlocks(ctx, 10, dymension, rollapp1) + require.NoError(t, err) + balance, err = dymension.GetBalance(ctx, marketMakerAddr, thirdPartyDenom) require.NoError(t, err) fmt.Println("Balance of marketMakerAddr after packet finalization:", balance) @@ -2381,4 +2621,6 @@ func TestEIBC_AckError_3rd_Party_Token_Wasm(t *testing.T) { testutil.WaitForBlocks(ctx, 20, rollapp1) testutil.AssertBalance(t, ctx, rollapp1, rollapp1UserAddr, rollapp1.Config().Denom, walletAmount.Sub(transferAmount)) }) + // Run invariant check + CheckInvariant(t, ctx, dymension, dymensionUser.KeyName()) } diff --git a/tests/eibc_corrupted_memo_test.go b/tests/eibc_corrupted_memo_test.go index fc1563ce..2fd34ad7 100644 --- a/tests/eibc_corrupted_memo_test.go +++ b/tests/eibc_corrupted_memo_test.go @@ -8,7 +8,6 @@ import ( "cosmossdk.io/math" transfertypes "github.com/cosmos/ibc-go/v7/modules/apps/transfer/types" test "github.com/decentrio/rollup-e2e-testing" - "github.com/decentrio/rollup-e2e-testing/cosmos" "github.com/decentrio/rollup-e2e-testing/cosmos/hub/dym_hub" "github.com/decentrio/rollup-e2e-testing/cosmos/rollapp/dym_rollapp" "github.com/decentrio/rollup-e2e-testing/ibc" @@ -37,18 +36,11 @@ func TestEIBCCorruptedMemoNegative_EVM(t *testing.T) { dymintTomlOverrides["settlement_gas_prices"] = "0adym" dymintTomlOverrides["max_idle_time"] = "3s" dymintTomlOverrides["max_proof_time"] = "500ms" - dymintTomlOverrides["batch_submit_max_time"] = "100s" + dymintTomlOverrides["batch_submit_time"] = "50s" + dymintTomlOverrides["p2p_blocksync_enabled"] = "false" configFileOverrides["config/dymint.toml"] = dymintTomlOverrides - modifyGenesisKV := append( - dymensionGenesisKV, - cosmos.GenesisKV{ - Key: "app_state.rollapp.params.dispute_period_in_blocks", - Value: fmt.Sprint(BLOCK_FINALITY_PERIOD), - }, - ) - // Create chain factory with dymension numHubVals := 1 numHubFullNodes := 1 @@ -93,7 +85,7 @@ func TestEIBCCorruptedMemoNegative_EVM(t *testing.T) { GasAdjustment: 1.1, TrustingPeriod: "112h", NoHostMount: false, - ModifyGenesis: modifyDymensionGenesis(modifyGenesisKV), + ModifyGenesis: modifyDymensionGenesis(dymensionGenesisKV), ConfigFileOverrides: nil, }, NumValidators: &numHubVals, @@ -135,7 +127,7 @@ func TestEIBCCorruptedMemoNegative_EVM(t *testing.T) { // This can be used to write to the block database which will index all block data e.g. txs, msgs, events, etc. // BlockDatabaseFile: test.DefaultBlockDatabaseFilepath(), - }, nil, "", nil) + }, nil, "", nil, false, 780) require.NoError(t, err) CreateChannel(ctx, t, r, eRep, dymension.CosmosChain, rollapp1.CosmosChain, ibcPath) @@ -175,6 +167,9 @@ func TestEIBCCorruptedMemoNegative_EVM(t *testing.T) { _, err = rollapp1.SendIBCTransfer(ctx, channel.ChannelID, rollappUserAddr, transferData, ibc.TransferOptions{}) require.NoError(t, err) + err = testutil.WaitForBlocks(ctx, 10, dymension, rollapp1) + require.NoError(t, err) + rollappHeight, err := rollapp1.GetNode().Height(ctx) require.NoError(t, err) @@ -186,6 +181,12 @@ func TestEIBCCorruptedMemoNegative_EVM(t *testing.T) { require.NoError(t, err) require.True(t, isFinalized) + _, err = dymension.GetNode().FinalizePacketsUntilHeight(ctx, dymensionUserAddr, rollapp1.GetChainID(), fmt.Sprint(rollappHeight)) + require.NoError(t, err) + + err = testutil.WaitForBlocks(ctx, 10, dymension, rollapp1) + require.NoError(t, err) + // Get the IBC denom for urax on Hub rollappTokenDenom := transfertypes.GetPrefixedDenom(channel.Counterparty.PortID, channel.Counterparty.ChannelID, rollapp1.Config().Denom) rollappIBCDenom := transfertypes.ParseDenomTrace(rollappTokenDenom).IBCDenom() @@ -227,9 +228,9 @@ func TestEIBCCorruptedMemoNegative_EVM(t *testing.T) { require.NoError(t, err) // get eIbc events - eibcEvents, _ := getEIbcEventsWithinBlockRange(ctx, dymension, 30, false) + eibcEvents, _ := getEIbcEventsWithinBlockRange(ctx, dymension, 45, false) fmt.Println(eibcEvents) - require.True(t, len(eibcEvents) == 2) // verify 1 EIBC event was registered on the hub + require.True(t, len(eibcEvents) == 1) // verify 1 EIBC event was registered on the hub rollappHeight, err = rollapp1.GetNode().Height(ctx) require.NoError(t, err) @@ -238,6 +239,12 @@ func TestEIBCCorruptedMemoNegative_EVM(t *testing.T) { require.NoError(t, err) require.True(t, isFinalized) + _, err = dymension.GetNode().FinalizePacketsUntilHeight(ctx, dymensionUserAddr, rollapp1.GetChainID(), fmt.Sprint(rollappHeight)) + require.NoError(t, err) + + err = testutil.WaitForBlocks(ctx, 10, dymension, rollapp1) + require.NoError(t, err) + testutil.AssertBalance(t, ctx, dymension, dymensionUserAddr, rollappIBCDenom, transferAmount.Sub(bridgingFee).MulRaw(2)) testutil.AssertBalance(t, ctx, dymension, dymensionUserAddr2, rollappIBCDenom, zeroBal) testutil.AssertBalance(t, ctx, dymension, dymensionUserAddr3, rollappIBCDenom, zeroBal) @@ -251,4 +258,7 @@ func TestEIBCCorruptedMemoNegative_EVM(t *testing.T) { }, ) + // Run invariant check + CheckInvariant(t, ctx, dymension, dymensionUser.KeyName()) + } diff --git a/tests/eibc_fee_market_test.go b/tests/eibc_fee_market_test.go index 21cdf1a0..d6d843b4 100644 --- a/tests/eibc_fee_market_test.go +++ b/tests/eibc_fee_market_test.go @@ -35,14 +35,14 @@ func TestEIBCFulfillAlreadyFulfilledDemand_EVM(t *testing.T) { gas_price_rollapp1 := "0adym" maxIdleTime1 := "10s" maxProofTime := "500ms" - configFileOverrides1 := overridesDymintToml(settlement_layer_rollapp1, settlement_node_address, rollapp1_id, gas_price_rollapp1, maxIdleTime1, maxProofTime, "100s") + configFileOverrides1 := overridesDymintToml(settlement_layer_rollapp1, settlement_node_address, rollapp1_id, gas_price_rollapp1, maxIdleTime1, maxProofTime, "50s") // setup config for rollapp 2 settlement_layer_rollapp2 := "dymension" rollapp2_id := "decentrio_12345-1" gas_price_rollapp2 := "0adym" maxIdleTime2 := "1s" - configFileOverrides2 := overridesDymintToml(settlement_layer_rollapp2, settlement_node_address, rollapp2_id, gas_price_rollapp2, maxIdleTime2, maxProofTime, "100s") + configFileOverrides2 := overridesDymintToml(settlement_layer_rollapp2, settlement_node_address, rollapp2_id, gas_price_rollapp2, maxIdleTime2, maxProofTime, "50s") // Create chain factory with dymension numHubVals := 1 @@ -151,7 +151,7 @@ func TestEIBCFulfillAlreadyFulfilledDemand_EVM(t *testing.T) { // This can be used to write to the block database which will index all block data e.g. txs, msgs, events, etc. // BlockDatabaseFile: test.DefaultBlockDatabaseFilepath(), - }, nil, "", nil) + }, nil, "", nil, false, 780) require.NoError(t, err) CreateChannel(ctx, t, r1, eRep, dymension.CosmosChain, rollapp1.CosmosChain, ibcPath) @@ -202,6 +202,9 @@ func TestEIBCFulfillAlreadyFulfilledDemand_EVM(t *testing.T) { _, err = rollapp1.SendIBCTransfer(ctx, dymChannel_ra1[0].ChannelID, rollappUserAddr, transferData, ibc.TransferOptions{}) require.NoError(t, err) + err = testutil.WaitForBlocks(ctx, 10, dymension, rollapp1) + require.NoError(t, err) + rollappHeight, err := rollapp1.GetNode().Height(ctx) require.NoError(t, err) @@ -210,6 +213,12 @@ func TestEIBCFulfillAlreadyFulfilledDemand_EVM(t *testing.T) { require.NoError(t, err) require.True(t, isFinalized) + _, err = dymension.GetNode().FinalizePacketsUntilHeight(ctx, dymensionUserAddr, rollapp1.GetChainID(), fmt.Sprint(rollappHeight)) + require.NoError(t, err) + + err = testutil.WaitForBlocks(ctx, 10, dymension, rollapp1) + require.NoError(t, err) + transferDataRollapp1 := ibc.WalletData{ Address: marketMakerAddr, Denom: rollapp1.Config().Denom, @@ -224,6 +233,10 @@ func TestEIBCFulfillAlreadyFulfilledDemand_EVM(t *testing.T) { // market maker needs to have funds on the hub first to be able to fulfill incoming demand order _, err = rollapp1.SendIBCTransfer(ctx, dymChannel_ra1[0].ChannelID, rollappUserAddr, transferDataRollapp1, options) require.NoError(t, err) + + err = testutil.WaitForBlocks(ctx, 10, dymension, rollapp1) + require.NoError(t, err) + rollappHeight, err = rollapp1.GetNode().Height(ctx) require.NoError(t, err) @@ -232,6 +245,12 @@ func TestEIBCFulfillAlreadyFulfilledDemand_EVM(t *testing.T) { require.NoError(t, err) require.True(t, isFinalized) + _, err = dymension.GetNode().FinalizePacketsUntilHeight(ctx, dymensionUserAddr, rollapp1.GetChainID(), fmt.Sprint(rollappHeight)) + require.NoError(t, err) + + err = testutil.WaitForBlocks(ctx, 10, dymension, rollapp1) + require.NoError(t, err) + // Minus 0.1% of transfer amount for bridge fee expMmBalanceRollappDenom := (bigTransferAmount.Sub(bigBridgingFee)) balance, err := dymension.GetBalance(ctx, marketMakerAddr, rollappIBCDenom) @@ -251,15 +270,14 @@ func TestEIBCFulfillAlreadyFulfilledDemand_EVM(t *testing.T) { _, err = rollapp1.SendIBCTransfer(ctx, dymChannel_ra1[0].ChannelID, rollappUserAddr, transferDataRollapp1, options) require.NoError(t, err) - rollappHeight, err = rollapp1.GetNode().Height(ctx) - require.NoError(t, err) + balance, err = dymension.GetBalance(ctx, dymensionUserAddr, rollappIBCDenom) require.NoError(t, err) fmt.Println("Balance of dymensionUserAddr right after sending eIBC transfer from rollapp 1 to dym hub:", balance) require.True(t, balance.Equal(transferAmount.Sub(bridgingFee)), fmt.Sprintf("Value mismatch. Expected %s, actual %s", transferAmount.Sub(bridgingFee), balance)) // get eIbc event - eibcEvents, err := getEIbcEventsWithinBlockRange(ctx, dymension, 30, false) + eibcEvents, err := getEIbcEventsWithinBlockRange(ctx, dymension, 10, false) require.NoError(t, err) for i, eibcEvent := range eibcEvents { fmt.Println(i, "EIBC Event:", eibcEvent) @@ -272,9 +290,9 @@ func TestEIBCFulfillAlreadyFulfilledDemand_EVM(t *testing.T) { re := regexp.MustCompile(`^\d+`) if re.ReplaceAllString(eibcEvent.Fee, "") == rollappIBCDenom && eibcEvent.PacketStatus == "PENDING" { fmt.Println("EIBC Event:", eibcEvent) - txhash, err := dymension.FullfillDemandOrder(ctx, eibcEvent.ID, marketMakerAddr, eibcFee) + txhash, err := dymension.FullfillDemandOrder(ctx, eibcEvent.OrderId, marketMakerAddr, eibcFee) require.NoError(t, err) - demand_order_id = eibcEvent.ID + demand_order_id = eibcEvent.OrderId fmt.Println(txhash) // eibcEvent := getEibcEventFromTx(t, dymension, txhash) // if eibcEvent != nil { @@ -292,7 +310,7 @@ func TestEIBCFulfillAlreadyFulfilledDemand_EVM(t *testing.T) { res, err := dymension.GetTransaction(txhash) require.NoError(t, err) require.Equal(t, uint32(10), res.Code) - + // require.True(t, (res.Code == uint32(10)) || (res.Code == uint32(5))) // wait a few blocks and verify sender received funds on the hub err = testutil.WaitForBlocks(ctx, 5, dymension) require.NoError(t, err) @@ -303,22 +321,24 @@ func TestEIBCFulfillAlreadyFulfilledDemand_EVM(t *testing.T) { fmt.Println("Balance of dymensionUserAddr after fulfilling the order:", balance) require.True(t, balance.Equal(transferAmountWithoutFee.Add(transferAmount.Sub(bridgingFee)).Sub(bridgingFee)), fmt.Sprintf("Value mismatch. Expected %s, actual %s", transferAmountWithoutFee.Add(transferAmount.Sub(bridgingFee)).Sub(bridgingFee), balance)) - // verify correct funds were deducted from market maker's wallet address - balance, err = dymension.GetBalance(ctx, marketMakerAddr, rollappIBCDenom) + rollappHeight, err = rollapp1.GetNode().Height(ctx) require.NoError(t, err) - fmt.Println("Balance of marketMakerAddr after fulfilling the order:", balance) - expMmBalanceRollappDenom = expMmBalanceRollappDenom.Sub((transferAmount)).Add(eibcFee).Add(bridgingFee) - require.True(t, balance.Equal(expMmBalanceRollappDenom), fmt.Sprintf("Value mismatch. Expected %s, actual %s", expMmBalanceRollappDenom, balance)) // wait until packet finalization and verify funds + fee were added to market maker's wallet address isFinalized, err = dymension.WaitUntilRollappHeightIsFinalized(ctx, rollapp1.GetChainID(), rollappHeight, 200) require.NoError(t, err) require.True(t, isFinalized) + + _, err = dymension.GetNode().FinalizePacketsUntilHeight(ctx, dymensionUserAddr, rollapp1.GetChainID(), fmt.Sprint(rollappHeight)) + require.NoError(t, err) + + err = testutil.WaitForBlocks(ctx, 10, dymension, rollapp1) + require.NoError(t, err) + balance, err = dymension.GetBalance(ctx, marketMakerAddr, rollappIBCDenom) require.NoError(t, err) fmt.Println("Balance of marketMakerAddr after packet finalization:", balance) - expMmBalanceRollappDenom = expMmBalanceRollappDenom.Add(transferDataRollapp1.Amount) - expMmBalanceRollappDenom = expMmBalanceRollappDenom.Sub(bridgingFee) + expMmBalanceRollappDenom = expMmBalanceRollappDenom.Add(eibcFee) require.True(t, balance.Equal(expMmBalanceRollappDenom), fmt.Sprintf("Value mismatch. Expected %s, actual %s", expMmBalanceRollappDenom, balance)) t.Cleanup( @@ -333,6 +353,8 @@ func TestEIBCFulfillAlreadyFulfilledDemand_EVM(t *testing.T) { } }, ) + // Run invariant check + CheckInvariant(t, ctx, dymension, dymensionUser.KeyName()) } // TestEIBCFulfillAlreadyFulfilledDemand_Wasm attempts to change the amount of an order that already got fulfilled @@ -350,14 +372,14 @@ func TestEIBCAlreadyFulfilledDemand_Wasm(t *testing.T) { gas_price_rollapp1 := "0adym" maxIdleTime1 := "10s" maxProofTime := "500ms" - configFileOverrides1 := overridesDymintToml(settlement_layer_rollapp1, settlement_node_address, rollapp1_id, gas_price_rollapp1, maxIdleTime1, maxProofTime, "100s") + configFileOverrides1 := overridesDymintToml(settlement_layer_rollapp1, settlement_node_address, rollapp1_id, gas_price_rollapp1, maxIdleTime1, maxProofTime, "50s") // setup config for rollapp 2 settlement_layer_rollapp2 := "dymension" rollapp2_id := "decentrio_12345-1" gas_price_rollapp2 := "0adym" maxIdleTime2 := "3s" - configFileOverrides2 := overridesDymintToml(settlement_layer_rollapp2, settlement_node_address, rollapp2_id, gas_price_rollapp2, maxIdleTime2, maxProofTime, "100s") + configFileOverrides2 := overridesDymintToml(settlement_layer_rollapp2, settlement_node_address, rollapp2_id, gas_price_rollapp2, maxIdleTime2, maxProofTime, "50s") // Create chain factory with dymension numHubVals := 1 @@ -466,7 +488,7 @@ func TestEIBCAlreadyFulfilledDemand_Wasm(t *testing.T) { // This can be used to write to the block database which will index all block data e.g. txs, msgs, events, etc. // BlockDatabaseFile: test.DefaultBlockDatabaseFilepath(), - }, nil, "", nil) + }, nil, "", nil, false, 780) require.NoError(t, err) CreateChannel(ctx, t, r1, eRep, dymension.CosmosChain, rollapp1.CosmosChain, ibcPath) @@ -517,6 +539,9 @@ func TestEIBCAlreadyFulfilledDemand_Wasm(t *testing.T) { _, err = rollapp1.SendIBCTransfer(ctx, dymChannel_ra1[0].ChannelID, rollappUserAddr, transferData, ibc.TransferOptions{}) require.NoError(t, err) + err = testutil.WaitForBlocks(ctx, 10, dymension, rollapp1) + require.NoError(t, err) + rollappHeight, err := rollapp1.GetNode().Height(ctx) require.NoError(t, err) @@ -525,6 +550,12 @@ func TestEIBCAlreadyFulfilledDemand_Wasm(t *testing.T) { require.NoError(t, err) require.True(t, isFinalized) + _, err = dymension.GetNode().FinalizePacketsUntilHeight(ctx, dymensionUserAddr, rollapp1.GetChainID(), fmt.Sprint(rollappHeight)) + require.NoError(t, err) + + err = testutil.WaitForBlocks(ctx, 10, dymension, rollapp1) + require.NoError(t, err) + transferDataRollapp1 := ibc.WalletData{ Address: marketMakerAddr, Denom: rollapp1.Config().Denom, @@ -539,6 +570,10 @@ func TestEIBCAlreadyFulfilledDemand_Wasm(t *testing.T) { // market maker needs to have funds on the hub first to be able to fulfill incoming demand order _, err = rollapp1.SendIBCTransfer(ctx, dymChannel_ra1[0].ChannelID, rollappUserAddr, transferDataRollapp1, options) require.NoError(t, err) + + err = testutil.WaitForBlocks(ctx, 10, dymension, rollapp1) + require.NoError(t, err) + rollappHeight, err = rollapp1.GetNode().Height(ctx) require.NoError(t, err) @@ -547,6 +582,12 @@ func TestEIBCAlreadyFulfilledDemand_Wasm(t *testing.T) { require.NoError(t, err) require.True(t, isFinalized) + _, err = dymension.GetNode().FinalizePacketsUntilHeight(ctx, dymensionUserAddr, rollapp1.GetChainID(), fmt.Sprint(rollappHeight)) + require.NoError(t, err) + + err = testutil.WaitForBlocks(ctx, 10, dymension, rollapp1) + require.NoError(t, err) + // Minus 0.1% of transfer amount for bridge fee expMmBalanceRollappDenom := (bigTransferAmount.Sub(bigBridgingFee)) balance, err := dymension.GetBalance(ctx, marketMakerAddr, rollappIBCDenom) @@ -566,15 +607,14 @@ func TestEIBCAlreadyFulfilledDemand_Wasm(t *testing.T) { _, err = rollapp1.SendIBCTransfer(ctx, dymChannel_ra1[0].ChannelID, rollappUserAddr, transferDataRollapp1, options) require.NoError(t, err) - rollappHeight, err = rollapp1.GetNode().Height(ctx) - require.NoError(t, err) + balance, err = dymension.GetBalance(ctx, dymensionUserAddr, rollappIBCDenom) require.NoError(t, err) fmt.Println("Balance of dymensionUserAddr right after sending eIBC transfer from rollapp 1 to dym hub:", balance) require.True(t, balance.Equal(transferAmount.Sub(bridgingFee)), fmt.Sprintf("Value mismatch. Expected %s, actual %s", transferAmount.Sub(bridgingFee), balance)) // get eIbc event - eibcEvents, err := getEIbcEventsWithinBlockRange(ctx, dymension, 30, false) + eibcEvents, err := getEIbcEventsWithinBlockRange(ctx, dymension, 10, false) require.NoError(t, err) for i, eibcEvent := range eibcEvents { fmt.Println(i, "EIBC Event:", eibcEvent) @@ -587,9 +627,9 @@ func TestEIBCAlreadyFulfilledDemand_Wasm(t *testing.T) { re := regexp.MustCompile(`^\d+`) if re.ReplaceAllString(eibcEvent.Fee, "") == rollappIBCDenom && eibcEvent.PacketStatus == "PENDING" { fmt.Println("EIBC Event:", eibcEvent) - txhash, err := dymension.FullfillDemandOrder(ctx, eibcEvent.ID, marketMakerAddr, eibcFee) + txhash, err := dymension.FullfillDemandOrder(ctx, eibcEvent.OrderId, marketMakerAddr, eibcFee) require.NoError(t, err) - demand_order_id = eibcEvent.ID + demand_order_id = eibcEvent.OrderId fmt.Println(txhash) // eibcEvent := getEibcEventFromTx(t, dymension, txhash) // if eibcEvent != nil { @@ -618,22 +658,21 @@ func TestEIBCAlreadyFulfilledDemand_Wasm(t *testing.T) { fmt.Println("Balance of dymensionUserAddr after fulfilling the order:", balance) require.True(t, balance.Equal(transferAmountWithoutFee.Add(transferAmount.Sub(bridgingFee)).Sub(bridgingFee)), fmt.Sprintf("Value mismatch. Expected %s, actual %s", transferAmountWithoutFee.Add(transferAmount.Sub(bridgingFee)).Sub(bridgingFee), balance)) - // verify correct funds were deducted from market maker's wallet address - balance, err = dymension.GetBalance(ctx, marketMakerAddr, rollappIBCDenom) + // wait until packet finalization and verify funds + fee were added to market maker's wallet address + rollappHeight, err = rollapp1.GetNode().Height(ctx) require.NoError(t, err) - fmt.Println("Balance of marketMakerAddr after fulfilling the order:", balance) - expMmBalanceRollappDenom = expMmBalanceRollappDenom.Sub((transferAmount)).Add(eibcFee).Add(bridgingFee) - require.True(t, balance.Equal(expMmBalanceRollappDenom), fmt.Sprintf("Value mismatch. Expected %s, actual %s", expMmBalanceRollappDenom, balance)) - // wait until packet finalization and verify funds + fee were added to market maker's wallet address isFinalized, err = dymension.WaitUntilRollappHeightIsFinalized(ctx, rollapp1.GetChainID(), rollappHeight, 200) require.NoError(t, err) require.True(t, isFinalized) + + _, err = dymension.GetNode().FinalizePacketsUntilHeight(ctx, dymensionUserAddr, rollapp1.GetChainID(), fmt.Sprint(rollappHeight)) + require.NoError(t, err) + balance, err = dymension.GetBalance(ctx, marketMakerAddr, rollappIBCDenom) require.NoError(t, err) fmt.Println("Balance of marketMakerAddr after packet finalization:", balance) - expMmBalanceRollappDenom = expMmBalanceRollappDenom.Add(transferDataRollapp1.Amount) - expMmBalanceRollappDenom = expMmBalanceRollappDenom.Sub(bridgingFee) + expMmBalanceRollappDenom = expMmBalanceRollappDenom.Add(eibcFee) require.True(t, balance.Equal(expMmBalanceRollappDenom), fmt.Sprintf("Value mismatch. Expected %s, actual %s", expMmBalanceRollappDenom, balance)) t.Cleanup( @@ -648,6 +687,8 @@ func TestEIBCAlreadyFulfilledDemand_Wasm(t *testing.T) { } }, ) + // Run invariant check + CheckInvariant(t, ctx, dymension, dymensionUser.KeyName()) } // TestEIBCUnallowedSigner_EVM attempts to change the amount of an order with an unallowed signer @@ -665,14 +706,14 @@ func TestEIBCUnallowedSigner_EVM(t *testing.T) { gas_price_rollapp1 := "0adym" maxIdleTime1 := "10s" maxProofTime := "500ms" - configFileOverrides1 := overridesDymintToml(settlement_layer_rollapp1, settlement_node_address, rollapp1_id, gas_price_rollapp1, maxIdleTime1, maxProofTime, "100s") + configFileOverrides1 := overridesDymintToml(settlement_layer_rollapp1, settlement_node_address, rollapp1_id, gas_price_rollapp1, maxIdleTime1, maxProofTime, "50s") // setup config for rollapp 2 settlement_layer_rollapp2 := "dymension" rollapp2_id := "decentrio_12345-1" gas_price_rollapp2 := "0adym" maxIdleTime2 := "1s" - configFileOverrides2 := overridesDymintToml(settlement_layer_rollapp2, settlement_node_address, rollapp2_id, gas_price_rollapp2, maxIdleTime2, maxProofTime, "100s") + configFileOverrides2 := overridesDymintToml(settlement_layer_rollapp2, settlement_node_address, rollapp2_id, gas_price_rollapp2, maxIdleTime2, maxProofTime, "50s") // Create chain factory with dymension numHubVals := 1 @@ -781,7 +822,7 @@ func TestEIBCUnallowedSigner_EVM(t *testing.T) { // This can be used to write to the block database which will index all block data e.g. txs, msgs, events, etc. // BlockDatabaseFile: test.DefaultBlockDatabaseFilepath(), - }, nil, "", nil) + }, nil, "", nil, false, 780) require.NoError(t, err) CreateChannel(ctx, t, r1, eRep, dymension.CosmosChain, rollapp1.CosmosChain, ibcPath) @@ -845,6 +886,10 @@ func TestEIBCUnallowedSigner_EVM(t *testing.T) { // market maker needs to have funds on the hub first to be able to fulfill incoming demand order _, err = rollapp1.SendIBCTransfer(ctx, dymChannel_ra1[0].ChannelID, rollappUserAddr, transferDataRollapp1, options) require.NoError(t, err) + + err = testutil.WaitForBlocks(ctx, 10, dymension, rollapp1) + require.NoError(t, err) + rollappHeight, err := rollapp1.GetNode().Height(ctx) require.NoError(t, err) @@ -853,6 +898,12 @@ func TestEIBCUnallowedSigner_EVM(t *testing.T) { require.NoError(t, err) require.True(t, isFinalized) + _, err = dymension.GetNode().FinalizePacketsUntilHeight(ctx, dymensionUserAddr, rollapp1.GetChainID(), fmt.Sprint(rollappHeight)) + require.NoError(t, err) + + err = testutil.WaitForBlocks(ctx, 10, dymension, rollapp1) + require.NoError(t, err) + // Minus 0.1% of transfer amount for bridge fee expMmBalanceRollappDenom := (bigTransferAmount.Sub(bigBridgingFee)) balance, err := dymension.GetBalance(ctx, marketMakerAddr, rollappIBCDenom) @@ -874,7 +925,7 @@ func TestEIBCUnallowedSigner_EVM(t *testing.T) { require.NoError(t, err) // get eIbc event - eibcEvents, err := getEIbcEventsWithinBlockRange(ctx, dymension, 30, false) + eibcEvents, err := getEIbcEventsWithinBlockRange(ctx, dymension, 10, false) require.NoError(t, err) for i, eibcEvent := range eibcEvents { @@ -887,7 +938,7 @@ func TestEIBCUnallowedSigner_EVM(t *testing.T) { if re.ReplaceAllString(eibcEvent.Fee, "") == rollappIBCDenom && eibcEvent.PacketStatus == "PENDING" { fmt.Println("EIBC Event:", eibcEvent) // attempt to update the fee amount required by demand order with an unallowed signer - txhash, err := dymension.UpdateDemandOrder(ctx, eibcEvent.ID, marketMakerAddr, eibcFee.MulRaw(2)) + txhash, err := dymension.UpdateDemandOrder(ctx, eibcEvent.OrderId, marketMakerAddr, eibcFee.MulRaw(2)) require.NoError(t, err) res, err := dymension.GetTransaction(txhash) require.NoError(t, err) @@ -907,6 +958,8 @@ func TestEIBCUnallowedSigner_EVM(t *testing.T) { } }, ) + // Run invariant check + CheckInvariant(t, ctx, dymension, dymensionUser.KeyName()) } // TestEIBCUnallowedSigner_Wasm attempts to change the amount of an order with an unallowed signer @@ -924,14 +977,14 @@ func TestEIBCUnallowedSigner_Wasm(t *testing.T) { gas_price_rollapp1 := "0adym" maxIdleTime1 := "10s" maxProofTime := "500ms" - configFileOverrides1 := overridesDymintToml(settlement_layer_rollapp1, settlement_node_address, rollapp1_id, gas_price_rollapp1, maxIdleTime1, maxProofTime, "100s") + configFileOverrides1 := overridesDymintToml(settlement_layer_rollapp1, settlement_node_address, rollapp1_id, gas_price_rollapp1, maxIdleTime1, maxProofTime, "50s") // setup config for rollapp 2 settlement_layer_rollapp2 := "dymension" rollapp2_id := "decentrio_12345-1" gas_price_rollapp2 := "0adym" maxIdleTime2 := "3s" - configFileOverrides2 := overridesDymintToml(settlement_layer_rollapp2, settlement_node_address, rollapp2_id, gas_price_rollapp2, maxIdleTime2, maxProofTime, "100s") + configFileOverrides2 := overridesDymintToml(settlement_layer_rollapp2, settlement_node_address, rollapp2_id, gas_price_rollapp2, maxIdleTime2, maxProofTime, "50s") // Create chain factory with dymension numHubVals := 1 @@ -1040,7 +1093,7 @@ func TestEIBCUnallowedSigner_Wasm(t *testing.T) { // This can be used to write to the block database which will index all block data e.g. txs, msgs, events, etc. // BlockDatabaseFile: test.DefaultBlockDatabaseFilepath(), - }, nil, "", nil) + }, nil, "", nil, false, 780) require.NoError(t, err) CreateChannel(ctx, t, r1, eRep, dymension.CosmosChain, rollapp1.CosmosChain, ibcPath) @@ -1104,6 +1157,10 @@ func TestEIBCUnallowedSigner_Wasm(t *testing.T) { // market maker needs to have funds on the hub first to be able to fulfill incoming demand order _, err = rollapp1.SendIBCTransfer(ctx, dymChannel_ra1[0].ChannelID, rollappUserAddr, transferDataRollapp1, options) require.NoError(t, err) + + err = testutil.WaitForBlocks(ctx, 10, dymension, rollapp1) + require.NoError(t, err) + rollappHeight, err := rollapp1.GetNode().Height(ctx) require.NoError(t, err) @@ -1112,6 +1169,12 @@ func TestEIBCUnallowedSigner_Wasm(t *testing.T) { require.NoError(t, err) require.True(t, isFinalized) + _, err = dymension.GetNode().FinalizePacketsUntilHeight(ctx, dymensionUserAddr, rollapp1.GetChainID(), fmt.Sprint(rollappHeight)) + require.NoError(t, err) + + err = testutil.WaitForBlocks(ctx, 10, dymension, rollapp1) + require.NoError(t, err) + // Minus 0.1% of transfer amount for bridge fee expMmBalanceRollappDenom := (bigTransferAmount.Sub(bigBridgingFee)) balance, err := dymension.GetBalance(ctx, marketMakerAddr, rollappIBCDenom) @@ -1131,11 +1194,9 @@ func TestEIBCUnallowedSigner_Wasm(t *testing.T) { _, err = rollapp1.SendIBCTransfer(ctx, dymChannel_ra1[0].ChannelID, rollappUserAddr, transferDataRollapp1, options) require.NoError(t, err) - balance, err = dymension.GetBalance(ctx, dymensionUserAddr, rollappIBCDenom) - require.NoError(t, err) // get eIbc event - eibcEvents, err := getEIbcEventsWithinBlockRange(ctx, dymension, 30, false) + eibcEvents, err := getEIbcEventsWithinBlockRange(ctx, dymension, 10, false) require.NoError(t, err) for i, eibcEvent := range eibcEvents { @@ -1147,7 +1208,7 @@ func TestEIBCUnallowedSigner_Wasm(t *testing.T) { if re.ReplaceAllString(eibcEvent.Fee, "") == rollappIBCDenom && eibcEvent.PacketStatus == "PENDING" { fmt.Println("EIBC Event:", eibcEvent) // attempt to update the fee amount required by demand order with an unallowed signer - txhash, err := dymension.UpdateDemandOrder(ctx, eibcEvent.ID, marketMakerAddr, eibcFee.MulRaw(2)) + txhash, err := dymension.UpdateDemandOrder(ctx, eibcEvent.OrderId, marketMakerAddr, eibcFee.MulRaw(2)) require.NoError(t, err) res, err := dymension.GetTransaction(txhash) require.NoError(t, err) @@ -1167,4 +1228,6 @@ func TestEIBCUnallowedSigner_Wasm(t *testing.T) { } }, ) + // Run invariant check + CheckInvariant(t, ctx, dymension, dymensionUser.KeyName()) } diff --git a/tests/eibc_fee_test.go b/tests/eibc_fee_test.go index 34a031e8..b725ddd4 100644 --- a/tests/eibc_fee_test.go +++ b/tests/eibc_fee_test.go @@ -8,7 +8,6 @@ import ( "cosmossdk.io/math" transfertypes "github.com/cosmos/ibc-go/v7/modules/apps/transfer/types" test "github.com/decentrio/rollup-e2e-testing" - "github.com/decentrio/rollup-e2e-testing/cosmos" "github.com/decentrio/rollup-e2e-testing/cosmos/hub/dym_hub" "github.com/decentrio/rollup-e2e-testing/cosmos/rollapp/dym_rollapp" "github.com/decentrio/rollup-e2e-testing/ibc" @@ -37,18 +36,11 @@ func TestEIBCFeeTooHigh_EVM(t *testing.T) { dymintTomlOverrides["settlement_gas_prices"] = "0adym" dymintTomlOverrides["max_idle_time"] = "3s" dymintTomlOverrides["max_proof_time"] = "500ms" - dymintTomlOverrides["batch_submit_max_time"] = "100s" + dymintTomlOverrides["batch_submit_time"] = "50s" + dymintTomlOverrides["p2p_blocksync_enabled"] = "false" configFileOverrides["config/dymint.toml"] = dymintTomlOverrides - modifyGenesisKV := append( - dymensionGenesisKV, - cosmos.GenesisKV{ - Key: "app_state.rollapp.params.dispute_period_in_blocks", - Value: fmt.Sprint(BLOCK_FINALITY_PERIOD), - }, - ) - // Create chain factory with dymension numHubVals := 1 numHubFullNodes := 1 @@ -93,7 +85,7 @@ func TestEIBCFeeTooHigh_EVM(t *testing.T) { GasAdjustment: 1.1, TrustingPeriod: "112h", NoHostMount: false, - ModifyGenesis: modifyDymensionGenesis(modifyGenesisKV), + ModifyGenesis: modifyDymensionGenesis(dymensionGenesisKV), ConfigFileOverrides: nil, }, NumValidators: &numHubVals, @@ -135,7 +127,7 @@ func TestEIBCFeeTooHigh_EVM(t *testing.T) { // This can be used to write to the block database which will index all block data e.g. txs, msgs, events, etc. // BlockDatabaseFile: test.DefaultBlockDatabaseFilepath(), - }, nil, "", nil) + }, nil, "", nil, false, 780) require.NoError(t, err) CreateChannel(ctx, t, r, eRep, dymension.CosmosChain, rollapp1.CosmosChain, ibcPath) @@ -173,6 +165,9 @@ func TestEIBCFeeTooHigh_EVM(t *testing.T) { _, err = rollapp1.SendIBCTransfer(ctx, channel.Counterparty.ChannelID, rollappUserAddr, transferData, ibc.TransferOptions{}) require.NoError(t, err) + err = testutil.WaitForBlocks(ctx, 10, dymension, rollapp1) + require.NoError(t, err) + rollappHeight, err := rollapp1.GetNode().Height(ctx) require.NoError(t, err) @@ -184,6 +179,12 @@ func TestEIBCFeeTooHigh_EVM(t *testing.T) { require.NoError(t, err) require.True(t, isFinalized) + _, err = dymension.GetNode().FinalizePacketsUntilHeight(ctx, dymensionUserAddr, rollapp1.GetChainID(), fmt.Sprint(rollappHeight)) + require.NoError(t, err) + + err = testutil.WaitForBlocks(ctx, 10, dymension, rollapp1) + require.NoError(t, err) + // Get the IBC denom for urax on Hub rollappTokenDenom := transfertypes.GetPrefixedDenom(channel.Counterparty.PortID, channel.Counterparty.ChannelID, rollapp1.Config().Denom) rollappIBCDenom := transfertypes.ParseDenomTrace(rollappTokenDenom).IBCDenom() @@ -202,20 +203,28 @@ func TestEIBCFeeTooHigh_EVM(t *testing.T) { _, err = rollapp1.SendIBCTransfer(ctx, channel.ChannelID, rollappUserAddr, transferData, options) require.NoError(t, err) - rollappHeight, err = rollapp1.GetNode().Height(ctx) - require.NoError(t, err) // balance right after sending IBC transfer testutil.AssertBalance(t, ctx, rollapp1, rollappUserAddr, rollapp1.Config().Denom, walletAmount.Sub(transferData.Amount).Sub(transferData.Amount)) testutil.AssertBalance(t, ctx, dymension, dymensionUserAddr, rollappIBCDenom, transferData.Amount.Sub(bridgingFee)) // get eIbc event eibcEvents, _ := getEIbcEventsWithinBlockRange(ctx, dymension, 30, false) - require.True(t, len(eibcEvents) == 1) // verify there were no eibc events registered on the hub + fmt.Println(eibcEvents) + require.True(t, len(eibcEvents) == 0) // verify there were no eibc events registered on the hub + + rollappHeight, err = rollapp1.GetNode().Height(ctx) + require.NoError(t, err) isFinalized, err = dymension.WaitUntilRollappHeightIsFinalized(ctx, rollapp1.GetChainID(), rollappHeight, 300) require.NoError(t, err) require.True(t, isFinalized) + _, err = dymension.GetNode().FinalizePacketsUntilHeight(ctx, dymensionUserAddr, rollapp1.GetChainID(), fmt.Sprint(rollappHeight)) + require.NoError(t, err) + + err = testutil.WaitForBlocks(ctx, 10, dymension, rollapp1) + require.NoError(t, err) + testutil.AssertBalance(t, ctx, rollapp1, rollappUserAddr, rollapp1.Config().Denom, walletAmount.Sub(transferData.Amount)) testutil.AssertBalance(t, ctx, dymension, dymensionUserAddr, rollappIBCDenom, transferData.Amount.Sub(bridgingFee)) @@ -227,4 +236,6 @@ func TestEIBCFeeTooHigh_EVM(t *testing.T) { } }, ) + // Run invariant check + CheckInvariant(t, ctx, dymension, dymensionUser.KeyName()) } diff --git a/tests/eibc_feemarket_test.go b/tests/eibc_feemarket_test.go index 12ec7431..b491ad42 100644 --- a/tests/eibc_feemarket_test.go +++ b/tests/eibc_feemarket_test.go @@ -11,7 +11,6 @@ import ( "go.uber.org/zap/zaptest" test "github.com/decentrio/rollup-e2e-testing" - "github.com/decentrio/rollup-e2e-testing/cosmos" "github.com/decentrio/rollup-e2e-testing/cosmos/hub/dym_hub" "github.com/decentrio/rollup-e2e-testing/cosmos/rollapp/dym_rollapp" "github.com/decentrio/rollup-e2e-testing/ibc" @@ -34,22 +33,14 @@ func TestEIBC_Fee_Market_Success_EVM(t *testing.T) { gas_price_rollapp1 := "0adym" maxIdleTime1 := "10s" maxProofTime := "500ms" - configFileOverrides1 := overridesDymintToml(settlement_layer_rollapp1, settlement_node_address, rollapp1_id, gas_price_rollapp1, maxIdleTime1, maxProofTime, "30s") + configFileOverrides1 := overridesDymintToml(settlement_layer_rollapp1, settlement_node_address, rollapp1_id, gas_price_rollapp1, maxIdleTime1, maxProofTime, "50s") // setup config for rollapp 2 settlement_layer_rollapp2 := "dymension" rollapp2_id := "decentrio_12345-1" gas_price_rollapp2 := "0adym" maxIdleTime2 := "1s" - configFileOverrides2 := overridesDymintToml(settlement_layer_rollapp2, settlement_node_address, rollapp2_id, gas_price_rollapp2, maxIdleTime2, maxProofTime, "30s") - - modifyGenesisKV := append( - dymensionGenesisKV, - cosmos.GenesisKV{ - Key: "app_state.rollapp.params.dispute_period_in_blocks", - Value: fmt.Sprint(50), - }, - ) + configFileOverrides2 := overridesDymintToml(settlement_layer_rollapp2, settlement_node_address, rollapp2_id, gas_price_rollapp2, maxIdleTime2, maxProofTime, "50s") // Create chain factory with dymension numHubVals := 1 @@ -117,7 +108,7 @@ func TestEIBC_Fee_Market_Success_EVM(t *testing.T) { GasAdjustment: 1.1, TrustingPeriod: "112h", NoHostMount: false, - ModifyGenesis: modifyDymensionGenesis(modifyGenesisKV), + ModifyGenesis: modifyDymensionGenesis(dymensionGenesisKV), ConfigFileOverrides: nil, }, NumValidators: &numHubVals, @@ -172,7 +163,7 @@ func TestEIBC_Fee_Market_Success_EVM(t *testing.T) { // This can be used to write to the block database which will index all block data e.g. txs, msgs, events, etc. // BlockDatabaseFile: test.DefaultBlockDatabaseFilepath(), - }, nil, "", nil) + }, nil, "", nil, false, 780) require.NoError(t, err) CreateChannel(ctx, t, r1, eRep, dymension.CosmosChain, rollapp1.CosmosChain, ibcPath) @@ -218,6 +209,9 @@ func TestEIBC_Fee_Market_Success_EVM(t *testing.T) { _, err = rollapp1.SendIBCTransfer(ctx, dymChannel[0].Counterparty.ChannelID, rollappUserAddr, transferData, ibc.TransferOptions{}) require.NoError(t, err) + err = testutil.WaitForBlocks(ctx, 10, dymension, rollapp1) + require.NoError(t, err) + rollappHeight, err := rollapp1.GetNode().Height(ctx) require.NoError(t, err) @@ -229,6 +223,12 @@ func TestEIBC_Fee_Market_Success_EVM(t *testing.T) { require.NoError(t, err) require.True(t, isFinalized) + _, err = dymension.GetNode().FinalizePacketsUntilHeight(ctx, dymensionUserAddr, rollapp1.GetChainID(), fmt.Sprint(rollappHeight)) + require.NoError(t, err) + + err = testutil.WaitForBlocks(ctx, 10, dymension, rollapp1) + require.NoError(t, err) + // Get the IBC denom for urax on Hub rollappTokenDenom := transfertypes.GetPrefixedDenom(dymChannel[0].Counterparty.PortID, dymChannel[0].Counterparty.ChannelID, rollapp1.Config().Denom) rollappIBCDenom := transfertypes.ParseDenomTrace(rollappTokenDenom).IBCDenom() @@ -254,9 +254,6 @@ func TestEIBC_Fee_Market_Success_EVM(t *testing.T) { _, err = rollapp1.SendIBCTransfer(ctx, dymChannel[0].ChannelID, rollappUserAddr, transferData, options) require.NoError(t, err) - rollappHeight, err = rollapp1.GetNode().Height(ctx) - require.NoError(t, err) - balance, err = dymension.GetBalance(ctx, dymensionUserAddr, rollappIBCDenom) require.NoError(t, err) @@ -264,18 +261,18 @@ func TestEIBC_Fee_Market_Success_EVM(t *testing.T) { require.True(t, balance.Equal(zeroBal), fmt.Sprintf("Value mismatch. Expected %s, actual %s", zeroBal, balance)) // get eIbc event - eibcEvents, err := getEIbcEventsWithinBlockRange(ctx, dymension, 5, false) + eibcEvents, err := getEIbcEventsWithinBlockRange(ctx, dymension, 10, false) require.NoError(t, err) - fmt.Println("Event:", eibcEvents[1]) + fmt.Println("Event:", eibcEvents[0]) - _, err = dymension.UpdateDemandOrder(ctx, eibcEvents[1].ID, dymensionUserAddr, math.NewInt(100_000)) + _, err = dymension.UpdateDemandOrder(ctx, eibcEvents[0].OrderId, dymensionUserAddr, eibcFee) require.NoError(t, err) err = testutil.WaitForBlocks(ctx, 5, dymension) require.NoError(t, err) // fulfill demand order - txhash, err := dymension.FullfillDemandOrder(ctx, eibcEvents[1].ID, marketMakerAddr, math.NewInt(100_000)) + txhash, err := dymension.FullfillDemandOrder(ctx, eibcEvents[0].OrderId, marketMakerAddr, eibcFee) require.NoError(t, err) fmt.Println(txhash) // eibcEvent := getEibcEventFromTx(t, dymension, txhash) @@ -291,23 +288,26 @@ func TestEIBC_Fee_Market_Success_EVM(t *testing.T) { balance, err = dymension.GetBalance(ctx, dymensionUserAddr, rollappIBCDenom) require.NoError(t, err) fmt.Println("Balance of dymensionUserAddr after fulfilling the order:", balance) - require.True(t, balance.Equal(transferAmount.Sub(bridgingFee).SubRaw(100_000)), fmt.Sprintf("Value mismatch. Expected %s, actual %s", transferAmount.Sub(bridgingFee).SubRaw(100_000), balance)) - // verify funds were deducted from market maker's wallet address - balance, err = dymension.GetBalance(ctx, marketMakerAddr, rollappIBCDenom) + require.True(t, balance.Equal(transferAmount.Sub(bridgingFee).Sub(eibcFee)), fmt.Sprintf("Value mismatch. Expected %s, actual %s", transferAmount.Sub(bridgingFee).SubRaw(100_000), balance)) + + rollappHeight, err = rollapp1.GetNode().Height(ctx) require.NoError(t, err) - fmt.Println("Balance of marketMakerAddr after fulfilling the order:", balance) - expMmBalanceRollappDenom = expMmBalanceRollappDenom.Sub(transferAmount.SubRaw(100_000)).Add(bridgingFee) - require.True(t, balance.Equal(expMmBalanceRollappDenom), fmt.Sprintf("Value mismatch. Expected %s, actual %s", expMmBalanceRollappDenom, balance)) - // wait until packet finalization and verify funds + fee were added to market maker's wallet address + + // wait until the packet is finalized isFinalized, err = dymension.WaitUntilRollappHeightIsFinalized(ctx, rollapp1.GetChainID(), rollappHeight, 300) require.NoError(t, err) require.True(t, isFinalized) + + _, err = dymension.GetNode().FinalizePacketsUntilHeight(ctx, dymensionUserAddr, rollapp1.GetChainID(), fmt.Sprint(rollappHeight)) + require.NoError(t, err) + + // verify funds were deducted from market maker's wallet address balance, err = dymension.GetBalance(ctx, marketMakerAddr, rollappIBCDenom) require.NoError(t, err) - fmt.Println("Balance of marketMakerAddr after packet finalization:", balance) - expMmBalanceRollappDenom = expMmBalanceRollappDenom.Add(transferData.Amount) - expMmBalanceRollappDenom = expMmBalanceRollappDenom.Sub(bridgingFee) + fmt.Println("Balance of marketMakerAddr after fulfilling the order:", balance) + expMmBalanceRollappDenom = expMmBalanceRollappDenom.Add(eibcFee) require.True(t, balance.Equal(expMmBalanceRollappDenom), fmt.Sprintf("Value mismatch. Expected %s, actual %s", expMmBalanceRollappDenom, balance)) + // wait until packet finalization and verify funds + fee were added to market maker's wallet address t.Cleanup( func() { @@ -317,6 +317,8 @@ func TestEIBC_Fee_Market_Success_EVM(t *testing.T) { } }, ) + // Run invariant check + CheckInvariant(t, ctx, dymension, dymensionUser.KeyName()) } func TestEIBC_Fee_Market_Success_Wasm(t *testing.T) { @@ -333,22 +335,14 @@ func TestEIBC_Fee_Market_Success_Wasm(t *testing.T) { gas_price_rollapp1 := "0adym" maxIdleTime1 := "10s" maxProofTime := "500ms" - configFileOverrides1 := overridesDymintToml(settlement_layer_rollapp1, settlement_node_address, rollapp1_id, gas_price_rollapp1, maxIdleTime1, maxProofTime, "30s") + configFileOverrides1 := overridesDymintToml(settlement_layer_rollapp1, settlement_node_address, rollapp1_id, gas_price_rollapp1, maxIdleTime1, maxProofTime, "50s") // setup config for rollapp 2 settlement_layer_rollapp2 := "dymension" rollapp2_id := "decentrio_12345-1" gas_price_rollapp2 := "0adym" maxIdleTime2 := "1s" - configFileOverrides2 := overridesDymintToml(settlement_layer_rollapp2, settlement_node_address, rollapp2_id, gas_price_rollapp2, maxIdleTime2, maxProofTime, "30s") - - modifyGenesisKV := append( - dymensionGenesisKV, - cosmos.GenesisKV{ - Key: "app_state.rollapp.params.dispute_period_in_blocks", - Value: fmt.Sprint(BLOCK_FINALITY_PERIOD), - }, - ) + configFileOverrides2 := overridesDymintToml(settlement_layer_rollapp2, settlement_node_address, rollapp2_id, gas_price_rollapp2, maxIdleTime2, maxProofTime, "50s") // Create chain factory with dymension numHubVals := 1 @@ -416,7 +410,7 @@ func TestEIBC_Fee_Market_Success_Wasm(t *testing.T) { GasAdjustment: 1.1, TrustingPeriod: "112h", NoHostMount: false, - ModifyGenesis: modifyDymensionGenesis(modifyGenesisKV), + ModifyGenesis: modifyDymensionGenesis(dymensionGenesisKV), ConfigFileOverrides: nil, }, NumValidators: &numHubVals, @@ -471,7 +465,7 @@ func TestEIBC_Fee_Market_Success_Wasm(t *testing.T) { // This can be used to write to the block database which will index all block data e.g. txs, msgs, events, etc. // BlockDatabaseFile: test.DefaultBlockDatabaseFilepath(), - }, nil, "", nil) + }, nil, "", nil, false, 780) require.NoError(t, err) CreateChannel(ctx, t, r1, eRep, dymension.CosmosChain, rollapp1.CosmosChain, ibcPath) @@ -495,7 +489,6 @@ func TestEIBC_Fee_Market_Success_Wasm(t *testing.T) { multiplier := math.NewInt(10) eibcFee := transferAmount.Quo(multiplier) // transferAmount * 0.1 - transferAmountWithoutFee := transferAmount.Sub(eibcFee) dymChannels, err := r1.GetChannels(ctx, eRep, dymension.Config().ChainID) require.NoError(t, err) @@ -531,6 +524,9 @@ func TestEIBC_Fee_Market_Success_Wasm(t *testing.T) { _, err = rollapp1.SendIBCTransfer(ctx, channsRollApp1[0].ChannelID, rollappUserAddr, transferData, ibc.TransferOptions{}) require.NoError(t, err) + err = testutil.WaitForBlocks(ctx, 10, dymension, rollapp1) + require.NoError(t, err) + rollappHeight, err := rollapp1.GetNode().Height(ctx) require.NoError(t, err) @@ -539,6 +535,12 @@ func TestEIBC_Fee_Market_Success_Wasm(t *testing.T) { require.NoError(t, err) require.True(t, isFinalized) + _, err = dymension.GetNode().FinalizePacketsUntilHeight(ctx, dymensionUserAddr, rollapp1.GetChainID(), fmt.Sprint(rollappHeight)) + require.NoError(t, err) + + err = testutil.WaitForBlocks(ctx, 10, dymension, rollapp1) + require.NoError(t, err) + // Get the IBC denom for urax on Hub rollappTokenDenom := transfertypes.GetPrefixedDenom(channsRollApp1[0].PortID, channsRollApp1[0].ChannelID, rollapp1.Config().Denom) rollappIBCDenom := transfertypes.ParseDenomTrace(rollappTokenDenom).IBCDenom() @@ -565,9 +567,6 @@ func TestEIBC_Fee_Market_Success_Wasm(t *testing.T) { _, err = rollapp1.SendIBCTransfer(ctx, channsRollApp1[0].ChannelID, rollappUserAddr, transferData, options) require.NoError(t, err) - rollappHeight, err = rollapp1.GetNode().Height(ctx) - require.NoError(t, err) - balance, err = dymension.GetBalance(ctx, dymensionUserAddr, rollappIBCDenom) require.NoError(t, err) @@ -577,16 +576,16 @@ func TestEIBC_Fee_Market_Success_Wasm(t *testing.T) { // get eIbc event eibcEvents, err := getEIbcEventsWithinBlockRange(ctx, dymension, 10, false) require.NoError(t, err) - fmt.Println("Event:", eibcEvents[1]) + fmt.Println("Event:", eibcEvents[0]) - _, err = dymension.UpdateDemandOrder(ctx, eibcEvents[1].ID, dymensionUserAddr, eibcFee.MulRaw(2)) + _, err = dymension.UpdateDemandOrder(ctx, eibcEvents[0].OrderId, dymensionUserAddr, eibcFee.MulRaw(2)) require.NoError(t, err) err = testutil.WaitForBlocks(ctx, 5, dymension) require.NoError(t, err) // fulfill demand order - txhash, err := dymension.FullfillDemandOrder(ctx, eibcEvents[1].ID, marketMakerAddr, eibcFee.MulRaw(2)) + txhash, err := dymension.FullfillDemandOrder(ctx, eibcEvents[0].OrderId, marketMakerAddr, eibcFee.MulRaw(2)) require.NoError(t, err) fmt.Println(txhash) // eibcEvent := getEibcEventFromTx(t, dymension, txhash) @@ -602,22 +601,28 @@ func TestEIBC_Fee_Market_Success_Wasm(t *testing.T) { balance, err = dymension.GetBalance(ctx, dymensionUserAddr, rollappIBCDenom) require.NoError(t, err) fmt.Println("Balance of dymensionUserAddr after fulfilling the order:", balance) + + transferAmountWithoutFee := transferAmount.Sub(eibcFee) require.True(t, balance.Equal(transferAmountWithoutFee.Sub(bridgingFee).Sub(eibcFee)), fmt.Sprintf("Value mismatch. Expected %s, actual %s", transferAmountWithoutFee.Sub(bridgingFee).Sub(eibcFee), balance)) - // verify funds were deducted from market maker's wallet address - balance, err = dymension.GetBalance(ctx, marketMakerAddr, rollappIBCDenom) - require.NoError(t, err) - fmt.Println("Balance of marketMakerAddr after fulfilling the order:", balance) - expMmBalanceRollappDenom = expMmBalanceRollappDenom.Sub(transferAmount.Sub(eibcFee.MulRaw(2))).Add(bridgingFee) - require.True(t, balance.Equal(expMmBalanceRollappDenom), fmt.Sprintf("Value mismatch. Expected %s, actual %s", expMmBalanceRollappDenom, balance)) + // wait until packet finalization and verify funds + fee were added to market maker's wallet address + rollappHeight, err = rollapp1.GetNode().Height(ctx) + require.NoError(t, err) + isFinalized, err = dymension.WaitUntilRollappHeightIsFinalized(ctx, rollapp1.GetChainID(), rollappHeight, 300) require.NoError(t, err) require.True(t, isFinalized) + + _, err = dymension.GetNode().FinalizePacketsUntilHeight(ctx, dymensionUserAddr, rollapp1.GetChainID(), fmt.Sprint(rollappHeight)) + require.NoError(t, err) + + err = testutil.WaitForBlocks(ctx, 10, dymension, rollapp1) + require.NoError(t, err) + balance, err = dymension.GetBalance(ctx, marketMakerAddr, rollappIBCDenom) require.NoError(t, err) fmt.Println("Balance of marketMakerAddr after packet finalization:", balance) - expMmBalanceRollappDenom = expMmBalanceRollappDenom.Add(transferData.Amount) - expMmBalanceRollappDenom = expMmBalanceRollappDenom.Sub(bridgingFee) + expMmBalanceRollappDenom = expMmBalanceRollappDenom.Add(eibcFee.MulRaw(2)) require.True(t, balance.Equal(expMmBalanceRollappDenom), fmt.Sprintf("Value mismatch. Expected %s, actual %s", expMmBalanceRollappDenom, balance)) t.Cleanup( @@ -628,6 +633,8 @@ func TestEIBC_Fee_Market_Success_Wasm(t *testing.T) { } }, ) + // Run invariant check + CheckInvariant(t, ctx, dymension, dymensionUser.KeyName()) } func TestEIBC_Fee_Market_Auto_Created_EVM(t *testing.T) { @@ -644,22 +651,14 @@ func TestEIBC_Fee_Market_Auto_Created_EVM(t *testing.T) { gas_price_rollapp1 := "0adym" maxIdleTime1 := "10s" maxProofTime := "500ms" - configFileOverrides1 := overridesDymintToml(settlement_layer_rollapp1, settlement_node_address, rollapp1_id, gas_price_rollapp1, maxIdleTime1, maxProofTime, "30s") + configFileOverrides1 := overridesDymintToml(settlement_layer_rollapp1, settlement_node_address, rollapp1_id, gas_price_rollapp1, maxIdleTime1, maxProofTime, "50s") // setup config for rollapp 2 settlement_layer_rollapp2 := "dymension" rollapp2_id := "decentrio_12345-1" gas_price_rollapp2 := "0adym" maxIdleTime2 := "1s" - configFileOverrides2 := overridesDymintToml(settlement_layer_rollapp2, settlement_node_address, rollapp2_id, gas_price_rollapp2, maxIdleTime2, maxProofTime, "30s") - - modifyGenesisKV := append( - dymensionGenesisKV, - cosmos.GenesisKV{ - Key: "app_state.rollapp.params.dispute_period_in_blocks", - Value: fmt.Sprint(50), - }, - ) + configFileOverrides2 := overridesDymintToml(settlement_layer_rollapp2, settlement_node_address, rollapp2_id, gas_price_rollapp2, maxIdleTime2, maxProofTime, "50s") // Create chain factory with dymension numHubVals := 1 @@ -727,7 +726,7 @@ func TestEIBC_Fee_Market_Auto_Created_EVM(t *testing.T) { GasAdjustment: 1.1, TrustingPeriod: "112h", NoHostMount: false, - ModifyGenesis: modifyDymensionGenesis(modifyGenesisKV), + ModifyGenesis: modifyDymensionGenesis(dymensionGenesisKV), ConfigFileOverrides: nil, }, NumValidators: &numHubVals, @@ -782,7 +781,7 @@ func TestEIBC_Fee_Market_Auto_Created_EVM(t *testing.T) { // This can be used to write to the block database which will index all block data e.g. txs, msgs, events, etc. // BlockDatabaseFile: test.DefaultBlockDatabaseFilepath(), - }, nil, "", nil) + }, nil, "", nil, false, 780) require.NoError(t, err) CreateChannel(ctx, t, r1, eRep, dymension.CosmosChain, rollapp1.CosmosChain, ibcPath) @@ -830,6 +829,9 @@ func TestEIBC_Fee_Market_Auto_Created_EVM(t *testing.T) { _, err = rollapp1.SendIBCTransfer(ctx, dymChannel[0].Counterparty.ChannelID, rollappUserAddr, transferData, ibc.TransferOptions{}) require.NoError(t, err) + err = testutil.WaitForBlocks(ctx, 10, dymension, rollapp1) + require.NoError(t, err) + rollappHeight, err := rollapp1.GetNode().Height(ctx) require.NoError(t, err) @@ -841,6 +843,12 @@ func TestEIBC_Fee_Market_Auto_Created_EVM(t *testing.T) { require.NoError(t, err) require.True(t, isFinalized) + _, err = dymension.GetNode().FinalizePacketsUntilHeight(ctx, dymensionUserAddr, rollapp1.GetChainID(), fmt.Sprint(rollappHeight)) + require.NoError(t, err) + + err = testutil.WaitForBlocks(ctx, 10, dymension, rollapp1) + require.NoError(t, err) + // Get the IBC denom for urax on Hub rollappTokenDenom := transfertypes.GetPrefixedDenom(dymChannel[0].Counterparty.PortID, dymChannel[0].Counterparty.ChannelID, rollapp1.Config().Denom) rollappIBCDenom := transfertypes.ParseDenomTrace(rollappTokenDenom).IBCDenom() @@ -862,9 +870,6 @@ func TestEIBC_Fee_Market_Auto_Created_EVM(t *testing.T) { _, err = rollapp1.SendIBCTransfer(ctx, dymChannel[0].ChannelID, rollappUserAddr, transferData, ibc.TransferOptions{}) require.NoError(t, err) - rollappHeight, err = rollapp1.GetNode().Height(ctx) - require.NoError(t, err) - balance, err = dymension.GetBalance(ctx, dymensionUserAddr, rollappIBCDenom) require.NoError(t, err) @@ -874,16 +879,16 @@ func TestEIBC_Fee_Market_Auto_Created_EVM(t *testing.T) { // get eIbc event eibcEvents, err := getEIbcEventsWithinBlockRange(ctx, dymension, 10, false) require.NoError(t, err) - fmt.Println("Event:", eibcEvents[1]) + fmt.Println("Event:", eibcEvents[0]) - _, err = dymension.UpdateDemandOrder(ctx, eibcEvents[1].ID, dymensionUserAddr, eibcFee) + _, err = dymension.UpdateDemandOrder(ctx, eibcEvents[0].OrderId, dymensionUserAddr, eibcFee) require.NoError(t, err) err = testutil.WaitForBlocks(ctx, 5, dymension) require.NoError(t, err) // fulfill demand order - txhash, err := dymension.FullfillDemandOrder(ctx, eibcEvents[1].ID, marketMakerAddr, eibcFee) + txhash, err := dymension.FullfillDemandOrder(ctx, eibcEvents[0].OrderId, marketMakerAddr, eibcFee) require.NoError(t, err) fmt.Println(txhash) // eibcEvent := getEibcEventFromTx(t, dymension, txhash) @@ -901,20 +906,22 @@ func TestEIBC_Fee_Market_Auto_Created_EVM(t *testing.T) { fmt.Println("Balance of dymensionUserAddr after fulfilling the order:", balance) require.True(t, balance.Equal(transferAmount.Sub(bridgingFee).Sub(eibcFee)), fmt.Sprintf("Value mismatch. Expected %s, actual %s", transferAmount.Sub(bridgingFee).Sub(eibcFee), balance)) // verify funds were deducted from market maker's wallet address - balance, err = dymension.GetBalance(ctx, marketMakerAddr, rollappIBCDenom) + + rollappHeight, err = rollapp1.GetNode().Height(ctx) require.NoError(t, err) - fmt.Println("Balance of marketMakerAddr after fulfilling the order:", balance) - expMmBalanceRollappDenom = expMmBalanceRollappDenom.Sub(transferAmount.Sub(eibcFee)).Add(bridgingFee) - require.True(t, balance.Equal(expMmBalanceRollappDenom), fmt.Sprintf("Value mismatch. Expected %s, actual %s", expMmBalanceRollappDenom, balance)) - // wait until packet finalization and verify funds + fee were added to market maker's wallet address + + // wait until the packet is finalized isFinalized, err = dymension.WaitUntilRollappHeightIsFinalized(ctx, rollapp1.GetChainID(), rollappHeight, 300) require.NoError(t, err) require.True(t, isFinalized) + + _, err = dymension.GetNode().FinalizePacketsUntilHeight(ctx, dymensionUserAddr, rollapp1.GetChainID(), fmt.Sprint(rollappHeight)) + require.NoError(t, err) + balance, err = dymension.GetBalance(ctx, marketMakerAddr, rollappIBCDenom) require.NoError(t, err) - fmt.Println("Balance of marketMakerAddr after packet finalization:", balance) - expMmBalanceRollappDenom = expMmBalanceRollappDenom.Add(transferData.Amount) - expMmBalanceRollappDenom = expMmBalanceRollappDenom.Sub(bridgingFee) + fmt.Println("Balance of marketMakerAddr after fulfilling the order:", balance) + expMmBalanceRollappDenom = expMmBalanceRollappDenom.Add(eibcFee) require.True(t, balance.Equal(expMmBalanceRollappDenom), fmt.Sprintf("Value mismatch. Expected %s, actual %s", expMmBalanceRollappDenom, balance)) t.Cleanup( @@ -925,6 +932,9 @@ func TestEIBC_Fee_Market_Auto_Created_EVM(t *testing.T) { } }, ) + + // Run invariant check + CheckInvariant(t, ctx, dymension, dymensionUser.KeyName()) } func TestEIBC_Fee_Market_Auto_Created_Wasm(t *testing.T) { @@ -941,22 +951,14 @@ func TestEIBC_Fee_Market_Auto_Created_Wasm(t *testing.T) { gas_price_rollapp1 := "0adym" maxIdleTime1 := "10s" maxProofTime := "500ms" - configFileOverrides1 := overridesDymintToml(settlement_layer_rollapp1, settlement_node_address, rollapp1_id, gas_price_rollapp1, maxIdleTime1, maxProofTime, "30s") + configFileOverrides1 := overridesDymintToml(settlement_layer_rollapp1, settlement_node_address, rollapp1_id, gas_price_rollapp1, maxIdleTime1, maxProofTime, "50s") // setup config for rollapp 2 settlement_layer_rollapp2 := "dymension" rollapp2_id := "decentrio_12345-1" gas_price_rollapp2 := "0adym" maxIdleTime2 := "1s" - configFileOverrides2 := overridesDymintToml(settlement_layer_rollapp2, settlement_node_address, rollapp2_id, gas_price_rollapp2, maxIdleTime2, maxProofTime, "30s") - - modifyGenesisKV := append( - dymensionGenesisKV, - cosmos.GenesisKV{ - Key: "app_state.rollapp.params.dispute_period_in_blocks", - Value: fmt.Sprint(BLOCK_FINALITY_PERIOD), - }, - ) + configFileOverrides2 := overridesDymintToml(settlement_layer_rollapp2, settlement_node_address, rollapp2_id, gas_price_rollapp2, maxIdleTime2, maxProofTime, "50s") // Create chain factory with dymension numHubVals := 1 @@ -1024,7 +1026,7 @@ func TestEIBC_Fee_Market_Auto_Created_Wasm(t *testing.T) { GasAdjustment: 1.1, TrustingPeriod: "112h", NoHostMount: false, - ModifyGenesis: modifyDymensionGenesis(modifyGenesisKV), + ModifyGenesis: modifyDymensionGenesis(dymensionGenesisKV), ConfigFileOverrides: nil, }, NumValidators: &numHubVals, @@ -1079,7 +1081,7 @@ func TestEIBC_Fee_Market_Auto_Created_Wasm(t *testing.T) { // This can be used to write to the block database which will index all block data e.g. txs, msgs, events, etc. // BlockDatabaseFile: test.DefaultBlockDatabaseFilepath(), - }, nil, "", nil) + }, nil, "", nil, false, 780) require.NoError(t, err) CreateChannel(ctx, t, r1, eRep, dymension.CosmosChain, rollapp1.CosmosChain, ibcPath) @@ -1139,6 +1141,9 @@ func TestEIBC_Fee_Market_Auto_Created_Wasm(t *testing.T) { _, err = rollapp1.SendIBCTransfer(ctx, channsRollApp1[0].ChannelID, rollappUserAddr, transferData, ibc.TransferOptions{}) require.NoError(t, err) + err = testutil.WaitForBlocks(ctx, 10, dymension, rollapp1) + require.NoError(t, err) + rollappHeight, err := rollapp1.GetNode().Height(ctx) require.NoError(t, err) @@ -1147,6 +1152,12 @@ func TestEIBC_Fee_Market_Auto_Created_Wasm(t *testing.T) { require.NoError(t, err) require.True(t, isFinalized) + _, err = dymension.GetNode().FinalizePacketsUntilHeight(ctx, dymensionUserAddr, rollapp1.GetChainID(), fmt.Sprint(rollappHeight)) + require.NoError(t, err) + + err = testutil.WaitForBlocks(ctx, 10, dymension, rollapp1) + require.NoError(t, err) + // Get the IBC denom for urax on Hub rollappTokenDenom := transfertypes.GetPrefixedDenom(channsRollApp1[0].PortID, channsRollApp1[0].ChannelID, rollapp1.Config().Denom) rollappIBCDenom := transfertypes.ParseDenomTrace(rollappTokenDenom).IBCDenom() @@ -1168,9 +1179,6 @@ func TestEIBC_Fee_Market_Auto_Created_Wasm(t *testing.T) { _, err = rollapp1.SendIBCTransfer(ctx, channsRollApp1[0].ChannelID, rollappUserAddr, transferData, ibc.TransferOptions{}) require.NoError(t, err) - rollappHeight, err = rollapp1.GetNode().Height(ctx) - require.NoError(t, err) - balance, err = dymension.GetBalance(ctx, dymensionUserAddr, rollappIBCDenom) require.NoError(t, err) @@ -1178,18 +1186,18 @@ func TestEIBC_Fee_Market_Auto_Created_Wasm(t *testing.T) { require.True(t, balance.Equal(zeroBal), fmt.Sprintf("Value mismatch. Expected %s, actual %s", zeroBal, balance)) // get eIbc event - eibcEvents, err := getEIbcEventsWithinBlockRange(ctx, dymension, 10, false) + eibcEvents, err := getEIbcEventsWithinBlockRange(ctx, dymension, 5, false) require.NoError(t, err) - fmt.Println("Event:", eibcEvents[1]) + fmt.Println("Event:", eibcEvents[0]) - _, err = dymension.UpdateDemandOrder(ctx, eibcEvents[1].ID, dymensionUserAddr, eibcFee.MulRaw(2)) + _, err = dymension.UpdateDemandOrder(ctx, eibcEvents[0].OrderId, dymensionUserAddr, eibcFee.MulRaw(2)) require.NoError(t, err) err = testutil.WaitForBlocks(ctx, 5, dymension) require.NoError(t, err) // fulfill demand order - txhash, err := dymension.FullfillDemandOrder(ctx, eibcEvents[1].ID, marketMakerAddr, eibcFee.MulRaw(2)) + txhash, err := dymension.FullfillDemandOrder(ctx, eibcEvents[0].OrderId, marketMakerAddr, eibcFee.MulRaw(2)) require.NoError(t, err) fmt.Println(txhash) // eibcEvent := getEibcEventFromTx(t, dymension, txhash) @@ -1206,21 +1214,22 @@ func TestEIBC_Fee_Market_Auto_Created_Wasm(t *testing.T) { require.NoError(t, err) fmt.Println("Balance of dymensionUserAddr after fulfilling the order:", balance) require.True(t, balance.Equal(transferAmountWithoutFee.Sub(bridgingFee).Sub(eibcFee)), fmt.Sprintf("Value mismatch. Expected %s, actual %s", transferAmountWithoutFee.Sub(bridgingFee).Sub(eibcFee), balance)) - // verify funds were deducted from market maker's wallet address - balance, err = dymension.GetBalance(ctx, marketMakerAddr, rollappIBCDenom) - require.NoError(t, err) - fmt.Println("Balance of marketMakerAddr after fulfilling the order:", balance) - expMmBalanceRollappDenom = expMmBalanceRollappDenom.Sub(transferAmountWithoutFee.Sub(eibcFee)).Add(bridgingFee) - require.True(t, balance.Equal(expMmBalanceRollappDenom), fmt.Sprintf("Value mismatch. Expected %s, actual %s", expMmBalanceRollappDenom, balance)) + // wait until packet finalization and verify funds + fee were added to market maker's wallet address + rollappHeight, err = rollapp1.GetNode().Height(ctx) + require.NoError(t, err) + isFinalized, err = dymension.WaitUntilRollappHeightIsFinalized(ctx, rollapp1.GetChainID(), rollappHeight, 300) require.NoError(t, err) require.True(t, isFinalized) + + _, err = dymension.GetNode().FinalizePacketsUntilHeight(ctx, dymensionUserAddr, rollapp1.GetChainID(), fmt.Sprint(rollappHeight)) + require.NoError(t, err) + balance, err = dymension.GetBalance(ctx, marketMakerAddr, rollappIBCDenom) require.NoError(t, err) fmt.Println("Balance of marketMakerAddr after packet finalization:", balance) - expMmBalanceRollappDenom = expMmBalanceRollappDenom.Add(transferData.Amount) - expMmBalanceRollappDenom = expMmBalanceRollappDenom.Sub(bridgingFee) + expMmBalanceRollappDenom = expMmBalanceRollappDenom.Add(eibcFee.MulRaw(2)) require.True(t, balance.Equal(expMmBalanceRollappDenom), fmt.Sprintf("Value mismatch. Expected %s, actual %s", expMmBalanceRollappDenom, balance)) t.Cleanup( @@ -1231,6 +1240,8 @@ func TestEIBC_Fee_Market_Auto_Created_Wasm(t *testing.T) { } }, ) + // Run invariant check + CheckInvariant(t, ctx, dymension, dymensionUser.KeyName()) } func TestEIBCUpdateOnAckErrAndTimeout_EVM(t *testing.T) { @@ -1248,17 +1259,11 @@ func TestEIBCUpdateOnAckErrAndTimeout_EVM(t *testing.T) { dymintTomlOverrides["settlement_gas_prices"] = "0adym" dymintTomlOverrides["max_idle_time"] = "3s" dymintTomlOverrides["max_proof_time"] = "500ms" - dymintTomlOverrides["batch_submit_max_time"] = "100s" + dymintTomlOverrides["batch_submit_time"] = "50s" + dymintTomlOverrides["p2p_blocksync_enabled"] = "false" configFileOverrides["config/dymint.toml"] = dymintTomlOverrides - modifyGenesisKV := append( - dymensionGenesisKV, - cosmos.GenesisKV{ - Key: "app_state.rollapp.params.dispute_period_in_blocks", - Value: fmt.Sprint(BLOCK_FINALITY_PERIOD), - }, - ) // Create chain factory with dymension numHubVals := 1 numHubFullNodes := 1 @@ -1303,7 +1308,7 @@ func TestEIBCUpdateOnAckErrAndTimeout_EVM(t *testing.T) { GasAdjustment: 1.1, TrustingPeriod: "112h", NoHostMount: false, - ModifyGenesis: modifyDymensionGenesis(modifyGenesisKV), + ModifyGenesis: modifyDymensionGenesis(dymensionGenesisKV), ConfigFileOverrides: nil, }, NumValidators: &numHubVals, @@ -1344,7 +1349,7 @@ func TestEIBCUpdateOnAckErrAndTimeout_EVM(t *testing.T) { // This can be used to write to the block database which will index all block data e.g. txs, msgs, events, etc. // BlockDatabaseFile: test.DefaultBlockDatabaseFilepath(), - }, nil, "", nil) + }, nil, "", nil, false, 780) require.NoError(t, err) CreateChannel(ctx, t, r, eRep, dymension.CosmosChain, rollapp1.CosmosChain, ibcPath) @@ -1383,6 +1388,9 @@ func TestEIBCUpdateOnAckErrAndTimeout_EVM(t *testing.T) { _, err = rollapp1.SendIBCTransfer(ctx, channel.ChannelID, rollappUserAddr, transferData, ibc.TransferOptions{}) require.NoError(t, err) + err = testutil.WaitForBlocks(ctx, 10, dymension, rollapp1) + require.NoError(t, err) + rollappHeight, err := rollapp1.GetNode().Height(ctx) require.NoError(t, err) @@ -1394,6 +1402,12 @@ func TestEIBCUpdateOnAckErrAndTimeout_EVM(t *testing.T) { require.NoError(t, err) require.True(t, isFinalized) + _, err = dymension.GetNode().FinalizePacketsUntilHeight(ctx, dymensionUserAddr, rollapp1.GetChainID(), fmt.Sprint(rollappHeight)) + require.NoError(t, err) + + err = testutil.WaitForBlocks(ctx, 50, dymension, rollapp1) + require.NoError(t, err) + // Compose an IBC transfer and send from hub to rollapp // global eibc fee in case of auto created orders is 0.0015 numerator := math.NewInt(15) @@ -1419,8 +1433,6 @@ func TestEIBCUpdateOnAckErrAndTimeout_EVM(t *testing.T) { _, err = dymension.SendIBCTransfer(ctx, channel.ChannelID, dymensionUserAddr, transferData, options) require.NoError(t, err) - rollappHeight, err = rollapp1.GetNode().Height(ctx) - require.NoError(t, err) // Get the IBC denom for dymension on roll app dymensionTokenDenom := transfertypes.GetPrefixedDenom(channel.Counterparty.PortID, channel.Counterparty.ChannelID, dymension.Config().Denom) dymensionIBCDenom := transfertypes.ParseDenomTrace(dymensionTokenDenom).IBCDenom() @@ -1435,18 +1447,18 @@ func TestEIBCUpdateOnAckErrAndTimeout_EVM(t *testing.T) { require.NoError(t, err) // get eibc event - eibcEvents, err := getEIbcEventsWithinBlockRange(ctx, dymension, 20, false) + eibcEvents, err := getEIbcEventsWithinBlockRange(ctx, dymension, 60, true) require.NoError(t, err) - fmt.Println("Event:", eibcEvents[0]) + fmt.Println(eibcEvents) require.Equal(t, eibcEvents[0].Price, fmt.Sprintf("%s%s", transferAmountWithoutFee, dymension.Config().Denom)) require.Equal(t, eibcEvents[0].Fee, fmt.Sprintf("%s%s", globalEIbcFee, dymension.Config().Denom)) // modify demand order with new fee - _, err = dymension.UpdateDemandOrder(ctx, eibcEvents[0].ID, dymensionUserAddr, globalEIbcFee.Mul(math.NewInt(2))) + _, err = dymension.UpdateDemandOrder(ctx, eibcEvents[0].OrderId, dymensionUserAddr, globalEIbcFee.Mul(math.NewInt(2))) require.NoError(t, err) // fulfill demand order - txhash, err := dymension.FullfillDemandOrder(ctx, eibcEvents[0].ID, marketMakerAddr, globalEIbcFee.Mul(math.NewInt(2))) + txhash, err := dymension.FullfillDemandOrder(ctx, eibcEvents[0].OrderId, marketMakerAddr, globalEIbcFee.Mul(math.NewInt(2))) require.NoError(t, err) fmt.Println(txhash) // eibcEvent := getEibcEventFromTx(t, dymension, txhash) @@ -1470,18 +1482,7 @@ func TestEIBCUpdateOnAckErrAndTimeout_EVM(t *testing.T) { balance, err = dymension.GetBalance(ctx, marketMakerAddr, dymension.Config().Denom) require.NoError(t, err) fmt.Println("Balance of marketMakerAddr after fulfilling the order:", balance) - expBalanceMarketMaker := walletAmount.Sub((transferAmountWithoutFeeUpdated)) - require.True(t, balance.Equal(expBalanceMarketMaker), fmt.Sprintf("Value mismatch. Expected %s, actual %s", expBalanceMarketMaker, balance)) - - // wait until packet finalization and verify funds (incl. fee) were added to market maker's wallet address - isFinalized, err = dymension.WaitUntilRollappHeightIsFinalized(ctx, rollapp1.GetChainID(), rollappHeight, 300) - require.NoError(t, err) - require.True(t, isFinalized) - - balance, err = dymension.GetBalance(ctx, marketMakerAddr, dymension.Config().Denom) - require.NoError(t, err) - fmt.Println("Balance of marketMakerAddr after packet finalization:", balance) - expBalanceMarketMaker = expBalanceMarketMaker.Add(transferData.Amount) + expBalanceMarketMaker := walletAmount.Add(globalEIbcFee.Mul(math.NewInt(2))).Sub(transferAmount) require.True(t, balance.Equal(expBalanceMarketMaker), fmt.Sprintf("Value mismatch. Expected %s, actual %s", expBalanceMarketMaker, balance)) t.Cleanup( @@ -1492,6 +1493,9 @@ func TestEIBCUpdateOnAckErrAndTimeout_EVM(t *testing.T) { } }, ) + + // Run invariant check + CheckInvariant(t, ctx, dymension, dymensionUser.KeyName()) } func TestEIBCUpdateOnAckErrAndTimeout_Wasm(t *testing.T) { @@ -1502,26 +1506,26 @@ func TestEIBCUpdateOnAckErrAndTimeout_Wasm(t *testing.T) { ctx := context.Background() // setup config for rollapp 1 - settlement_layer_rollapp1 := "dymension" - settlement_node_address := fmt.Sprintf("http://dymension_100-1-val-0-%s:26657", t.Name()) - rollapp1_id := "rollappwasm_1234-1" - gas_price_rollapp1 := "0adym" - maxIdleTime1 := "10s" - maxProofTime := "500ms" - configFileOverrides1 := overridesDymintToml(settlement_layer_rollapp1, settlement_node_address, rollapp1_id, gas_price_rollapp1, maxIdleTime1, maxProofTime, "100s") - modifyGenesisKV := append( - dymensionGenesisKV, - cosmos.GenesisKV{ - Key: "app_state.rollapp.params.dispute_period_in_blocks", - Value: fmt.Sprint(BLOCK_FINALITY_PERIOD), - }, - ) + configFileOverrides := make(map[string]any) + dymintTomlOverrides := make(testutil.Toml) + dymintTomlOverrides["settlement_layer"] = "dymension" + dymintTomlOverrides["settlement_node_address"] = fmt.Sprintf("http://dymension_100-1-val-0-%s:26657", t.Name()) + dymintTomlOverrides["rollapp_id"] = "rollappwasm_1234-1" + dymintTomlOverrides["settlement_gas_prices"] = "0adym" + dymintTomlOverrides["max_idle_time"] = "3s" + dymintTomlOverrides["max_proof_time"] = "500ms" + dymintTomlOverrides["batch_submit_time"] = "50s" + dymintTomlOverrides["p2p_blocksync_enabled"] = "false" + + configFileOverrides["config/dymint.toml"] = dymintTomlOverrides + // Create chain factory with dymension numHubVals := 1 numHubFullNodes := 1 numRollAppFn := 0 numRollAppVals := 1 + cf := test.NewBuiltinChainFactory(zaptest.NewLogger(t), []*test.ChainSpec{ { Name: "rollapp1", @@ -1540,7 +1544,7 @@ func TestEIBCUpdateOnAckErrAndTimeout_Wasm(t *testing.T) { EncodingConfig: encodingConfig(), NoHostMount: false, ModifyGenesis: modifyRollappWasmGenesis(rollappWasmGenesisKV), - ConfigFileOverrides: configFileOverrides1, + ConfigFileOverrides: configFileOverrides, }, NumValidators: &numRollAppVals, NumFullNodes: &numRollAppFn, @@ -1561,7 +1565,7 @@ func TestEIBCUpdateOnAckErrAndTimeout_Wasm(t *testing.T) { GasAdjustment: 1.1, TrustingPeriod: "112h", NoHostMount: false, - ModifyGenesis: modifyDymensionGenesis(modifyGenesisKV), + ModifyGenesis: modifyDymensionGenesis(dymensionGenesisKV), ConfigFileOverrides: nil, }, NumValidators: &numHubVals, @@ -1602,7 +1606,7 @@ func TestEIBCUpdateOnAckErrAndTimeout_Wasm(t *testing.T) { // This can be used to write to the block database which will index all block data e.g. txs, msgs, events, etc. // BlockDatabaseFile: test.DefaultBlockDatabaseFilepath(), - }, nil, "", nil) + }, nil, "", nil, false, 780) require.NoError(t, err) CreateChannel(ctx, t, r, eRep, dymension.CosmosChain, rollapp1.CosmosChain, ibcPath) @@ -1641,6 +1645,9 @@ func TestEIBCUpdateOnAckErrAndTimeout_Wasm(t *testing.T) { _, err = rollapp1.SendIBCTransfer(ctx, channel.ChannelID, rollappUserAddr, transferData, ibc.TransferOptions{}) require.NoError(t, err) + err = testutil.WaitForBlocks(ctx, 10, dymension, rollapp1) + require.NoError(t, err) + rollappHeight, err := rollapp1.GetNode().Height(ctx) require.NoError(t, err) @@ -1652,6 +1659,12 @@ func TestEIBCUpdateOnAckErrAndTimeout_Wasm(t *testing.T) { require.NoError(t, err) require.True(t, isFinalized) + _, err = dymension.GetNode().FinalizePacketsUntilHeight(ctx, dymensionUserAddr, rollapp1.GetChainID(), fmt.Sprint(rollappHeight)) + require.NoError(t, err) + + err = testutil.WaitForBlocks(ctx, 30, dymension, rollapp1) + require.NoError(t, err) + // Compose an IBC transfer and send from hub to rollapp // global eibc fee in case of auto created orders is 0.0015 numerator := math.NewInt(15) @@ -1677,8 +1690,6 @@ func TestEIBCUpdateOnAckErrAndTimeout_Wasm(t *testing.T) { _, err = dymension.SendIBCTransfer(ctx, channel.ChannelID, dymensionUserAddr, transferData, options) require.NoError(t, err) - rollappHeight, err = rollapp1.GetNode().Height(ctx) - require.NoError(t, err) // Get the IBC denom for dymension on roll app dymensionTokenDenom := transfertypes.GetPrefixedDenom(channel.Counterparty.PortID, channel.Counterparty.ChannelID, dymension.Config().Denom) dymensionIBCDenom := transfertypes.ParseDenomTrace(dymensionTokenDenom).IBCDenom() @@ -1693,18 +1704,18 @@ func TestEIBCUpdateOnAckErrAndTimeout_Wasm(t *testing.T) { require.NoError(t, err) // get eibc event - eibcEvents, err := getEIbcEventsWithinBlockRange(ctx, dymension, 20, false) + eibcEvents, err := getEIbcEventsWithinBlockRange(ctx, dymension, 60, true) require.NoError(t, err) - fmt.Println("Event:", eibcEvents[0]) + fmt.Println("Event:", eibcEvents) require.Equal(t, eibcEvents[0].Price, fmt.Sprintf("%s%s", transferAmountWithoutFee, dymension.Config().Denom)) require.Equal(t, eibcEvents[0].Fee, fmt.Sprintf("%s%s", globalEIbcFee, dymension.Config().Denom)) // modify demand order with new fee - _, err = dymension.UpdateDemandOrder(ctx, eibcEvents[0].ID, dymensionUserAddr, globalEIbcFee.Mul(math.NewInt(2))) + _, err = dymension.UpdateDemandOrder(ctx, eibcEvents[0].OrderId, dymensionUserAddr, globalEIbcFee.Mul(math.NewInt(2))) require.NoError(t, err) // fulfill demand order - txhash, err := dymension.FullfillDemandOrder(ctx, eibcEvents[0].ID, marketMakerAddr, globalEIbcFee.Mul(math.NewInt(2))) + txhash, err := dymension.FullfillDemandOrder(ctx, eibcEvents[0].OrderId, marketMakerAddr, globalEIbcFee.Mul(math.NewInt(2))) require.NoError(t, err) fmt.Println(txhash) // eibcEvent := getEibcEventFromTx(t, dymension, txhash) @@ -1724,22 +1735,24 @@ func TestEIBCUpdateOnAckErrAndTimeout_Wasm(t *testing.T) { expBalance := walletAmount.Sub(transferData.Amount).Add(transferAmountWithoutFeeUpdated) require.True(t, balance.Equal(expBalance), fmt.Sprintf("Value mismatch. Expected %s, actual %s", expBalance, balance)) - // verify funds were deducted from market maker's wallet address - balance, err = dymension.GetBalance(ctx, marketMakerAddr, dymension.Config().Denom) + // wait until packet finalization and verify funds (incl. fee) were added to market maker's wallet address + rollappHeight, err = rollapp1.GetNode().Height(ctx) require.NoError(t, err) - fmt.Println("Balance of marketMakerAddr after fulfilling the order:", balance) - expBalanceMarketMaker := walletAmount.Sub((transferAmountWithoutFeeUpdated)) - require.True(t, balance.Equal(expBalanceMarketMaker), fmt.Sprintf("Value mismatch. Expected %s, actual %s", expBalanceMarketMaker, balance)) - // wait until packet finalization and verify funds (incl. fee) were added to market maker's wallet address isFinalized, err = dymension.WaitUntilRollappHeightIsFinalized(ctx, rollapp1.GetChainID(), rollappHeight, 300) require.NoError(t, err) require.True(t, isFinalized) + _, err = dymension.GetNode().FinalizePacketsUntilHeight(ctx, dymensionUserAddr, rollapp1.GetChainID(), fmt.Sprint(rollappHeight)) + require.NoError(t, err) + + err = testutil.WaitForBlocks(ctx, 10, dymension, rollapp1) + require.NoError(t, err) + balance, err = dymension.GetBalance(ctx, marketMakerAddr, dymension.Config().Denom) require.NoError(t, err) fmt.Println("Balance of marketMakerAddr after packet finalization:", balance) - expBalanceMarketMaker = expBalanceMarketMaker.Add(transferData.Amount) + expBalanceMarketMaker := walletAmount.Add(globalEIbcFee.Mul(math.NewInt(2))) require.True(t, balance.Equal(expBalanceMarketMaker), fmt.Sprintf("Value mismatch. Expected %s, actual %s", expBalanceMarketMaker, balance)) t.Cleanup( @@ -1750,6 +1763,8 @@ func TestEIBCUpdateOnAckErrAndTimeout_Wasm(t *testing.T) { } }, ) + // Run invariant check + CheckInvariant(t, ctx, dymension, dymensionUser.KeyName()) } func TestEIBCUpdateOnTimeout_Unallowed_EVM(t *testing.T) { @@ -1767,17 +1782,11 @@ func TestEIBCUpdateOnTimeout_Unallowed_EVM(t *testing.T) { dymintTomlOverrides["settlement_gas_prices"] = "0adym" dymintTomlOverrides["max_idle_time"] = "3s" dymintTomlOverrides["max_proof_time"] = "500ms" - dymintTomlOverrides["batch_submit_max_time"] = "100s" + dymintTomlOverrides["batch_submit_time"] = "10s" + dymintTomlOverrides["p2p_blocksync_enabled"] = "false" configFileOverrides["config/dymint.toml"] = dymintTomlOverrides - modifyGenesisKV := append( - dymensionGenesisKV, - cosmos.GenesisKV{ - Key: "app_state.rollapp.params.dispute_period_in_blocks", - Value: fmt.Sprint(BLOCK_FINALITY_PERIOD), - }, - ) // Create chain factory with dymension numHubVals := 1 numHubFullNodes := 1 @@ -1822,7 +1831,7 @@ func TestEIBCUpdateOnTimeout_Unallowed_EVM(t *testing.T) { GasAdjustment: 1.1, TrustingPeriod: "112h", NoHostMount: false, - ModifyGenesis: modifyDymensionGenesis(modifyGenesisKV), + ModifyGenesis: modifyDymensionGenesis(dymensionGenesisKV), ConfigFileOverrides: nil, }, NumValidators: &numHubVals, @@ -1863,7 +1872,7 @@ func TestEIBCUpdateOnTimeout_Unallowed_EVM(t *testing.T) { // This can be used to write to the block database which will index all block data e.g. txs, msgs, events, etc. // BlockDatabaseFile: test.DefaultBlockDatabaseFilepath(), - }, nil, "", nil) + }, nil, "", nil, false, 780) require.NoError(t, err) CreateChannel(ctx, t, r, eRep, dymension.CosmosChain, rollapp1.CosmosChain, ibcPath) @@ -1902,6 +1911,9 @@ func TestEIBCUpdateOnTimeout_Unallowed_EVM(t *testing.T) { _, err = rollapp1.SendIBCTransfer(ctx, channel.ChannelID, rollappUserAddr, transferData, ibc.TransferOptions{}) require.NoError(t, err) + err = testutil.WaitForBlocks(ctx, 10, dymension, rollapp1) + require.NoError(t, err) + rollappHeight, err := rollapp1.GetNode().Height(ctx) require.NoError(t, err) @@ -1913,6 +1925,12 @@ func TestEIBCUpdateOnTimeout_Unallowed_EVM(t *testing.T) { require.NoError(t, err) require.True(t, isFinalized) + _, err = dymension.GetNode().FinalizePacketsUntilHeight(ctx, dymensionUserAddr, rollapp1.GetChainID(), fmt.Sprint(rollappHeight)) + require.NoError(t, err) + + err = testutil.WaitForBlocks(ctx, 10, dymension, rollapp1) + require.NoError(t, err) + // Compose an IBC transfer and send from hub to rollapp // global eibc fee in case of auto created orders is 0.0015 numerator := math.NewInt(15) @@ -1937,8 +1955,6 @@ func TestEIBCUpdateOnTimeout_Unallowed_EVM(t *testing.T) { _, err = dymension.SendIBCTransfer(ctx, channel.ChannelID, dymensionUserAddr, transferData, options) require.NoError(t, err) - rollappHeight, err = rollapp1.GetNode().Height(ctx) - require.NoError(t, err) // Get the IBC denom for dymension on roll app dymensionTokenDenom := transfertypes.GetPrefixedDenom(channel.Counterparty.PortID, channel.Counterparty.ChannelID, dymension.Config().Denom) dymensionIBCDenom := transfertypes.ParseDenomTrace(dymensionTokenDenom).IBCDenom() @@ -1953,19 +1969,19 @@ func TestEIBCUpdateOnTimeout_Unallowed_EVM(t *testing.T) { require.NoError(t, err) // get eibc event - eibcEvents, err := getEIbcEventsWithinBlockRange(ctx, dymension, 20, false) + eibcEvents, err := getEIbcEventsWithinBlockRange(ctx, dymension, 60, false) require.NoError(t, err) - fmt.Println("Event:", eibcEvents[0]) + fmt.Println("Event:", eibcEvents) require.Equal(t, eibcEvents[0].Price, fmt.Sprintf("%s%s", transferAmountWithoutFee, dymension.Config().Denom)) require.Equal(t, eibcEvents[0].Fee, fmt.Sprintf("%s%s", globalEIbcFee, dymension.Config().Denom)) // modify demand order with new fee - txhash, err := dymension.UpdateDemandOrder(ctx, eibcEvents[0].ID, marketMakerAddr, globalEIbcFee.Mul(math.NewInt(2))) + txhash, err := dymension.UpdateDemandOrder(ctx, eibcEvents[0].OrderId, marketMakerAddr, globalEIbcFee.Mul(math.NewInt(2))) require.NoError(t, err) res, err := dymension.GetTransaction(txhash) require.NoError(t, err) - require.Equal(t, uint32(4), res.Code) + require.True(t, (res.Code == uint32(4)) || (res.Code == uint32(5))) t.Cleanup( func() { @@ -1975,6 +1991,8 @@ func TestEIBCUpdateOnTimeout_Unallowed_EVM(t *testing.T) { } }, ) + // Run invariant check + CheckInvariant(t, ctx, dymension, dymensionUser.KeyName()) } func TestEIBCUpdateOnTimeout_Unallowed_Wasm(t *testing.T) { @@ -1985,26 +2003,26 @@ func TestEIBCUpdateOnTimeout_Unallowed_Wasm(t *testing.T) { ctx := context.Background() // setup config for rollapp 1 - settlement_layer_rollapp1 := "dymension" - settlement_node_address := fmt.Sprintf("http://dymension_100-1-val-0-%s:26657", t.Name()) - rollapp1_id := "rollappwasm_1234-1" - gas_price_rollapp1 := "0adym" - maxIdleTime1 := "10s" - maxProofTime := "500ms" - configFileOverrides1 := overridesDymintToml(settlement_layer_rollapp1, settlement_node_address, rollapp1_id, gas_price_rollapp1, maxIdleTime1, maxProofTime, "100s") - modifyGenesisKV := append( - dymensionGenesisKV, - cosmos.GenesisKV{ - Key: "app_state.rollapp.params.dispute_period_in_blocks", - Value: fmt.Sprint(BLOCK_FINALITY_PERIOD), - }, - ) + configFileOverrides := make(map[string]any) + dymintTomlOverrides := make(testutil.Toml) + dymintTomlOverrides["settlement_layer"] = "dymension" + dymintTomlOverrides["settlement_node_address"] = fmt.Sprintf("http://dymension_100-1-val-0-%s:26657", t.Name()) + dymintTomlOverrides["rollapp_id"] = "rollappwasm_1234-1" + dymintTomlOverrides["settlement_gas_prices"] = "0adym" + dymintTomlOverrides["max_idle_time"] = "3s" + dymintTomlOverrides["max_proof_time"] = "500ms" + dymintTomlOverrides["batch_submit_time"] = "50s" + dymintTomlOverrides["p2p_blocksync_enabled"] = "false" + + configFileOverrides["config/dymint.toml"] = dymintTomlOverrides + // Create chain factory with dymension numHubVals := 1 numHubFullNodes := 1 numRollAppFn := 0 numRollAppVals := 1 + cf := test.NewBuiltinChainFactory(zaptest.NewLogger(t), []*test.ChainSpec{ { Name: "rollapp1", @@ -2023,7 +2041,7 @@ func TestEIBCUpdateOnTimeout_Unallowed_Wasm(t *testing.T) { EncodingConfig: encodingConfig(), NoHostMount: false, ModifyGenesis: modifyRollappWasmGenesis(rollappWasmGenesisKV), - ConfigFileOverrides: configFileOverrides1, + ConfigFileOverrides: configFileOverrides, }, NumValidators: &numRollAppVals, NumFullNodes: &numRollAppFn, @@ -2044,7 +2062,7 @@ func TestEIBCUpdateOnTimeout_Unallowed_Wasm(t *testing.T) { GasAdjustment: 1.1, TrustingPeriod: "112h", NoHostMount: false, - ModifyGenesis: modifyDymensionGenesis(modifyGenesisKV), + ModifyGenesis: modifyDymensionGenesis(dymensionGenesisKV), ConfigFileOverrides: nil, }, NumValidators: &numHubVals, @@ -2085,7 +2103,7 @@ func TestEIBCUpdateOnTimeout_Unallowed_Wasm(t *testing.T) { // This can be used to write to the block database which will index all block data e.g. txs, msgs, events, etc. // BlockDatabaseFile: test.DefaultBlockDatabaseFilepath(), - }, nil, "", nil) + }, nil, "", nil, false, 780) require.NoError(t, err) CreateChannel(ctx, t, r, eRep, dymension.CosmosChain, rollapp1.CosmosChain, ibcPath) @@ -2124,6 +2142,9 @@ func TestEIBCUpdateOnTimeout_Unallowed_Wasm(t *testing.T) { _, err = rollapp1.SendIBCTransfer(ctx, channel.ChannelID, rollappUserAddr, transferData, ibc.TransferOptions{}) require.NoError(t, err) + err = testutil.WaitForBlocks(ctx, 10, dymension, rollapp1) + require.NoError(t, err) + rollappHeight, err := rollapp1.GetNode().Height(ctx) require.NoError(t, err) @@ -2135,6 +2156,12 @@ func TestEIBCUpdateOnTimeout_Unallowed_Wasm(t *testing.T) { require.NoError(t, err) require.True(t, isFinalized) + _, err = dymension.GetNode().FinalizePacketsUntilHeight(ctx, dymensionUserAddr, rollapp1.GetChainID(), fmt.Sprint(rollappHeight)) + require.NoError(t, err) + + err = testutil.WaitForBlocks(ctx, 50, dymension, rollapp1) + require.NoError(t, err) + // Compose an IBC transfer and send from hub to rollapp // global eibc fee in case of auto created orders is 0.0015 numerator := math.NewInt(15) @@ -2159,8 +2186,6 @@ func TestEIBCUpdateOnTimeout_Unallowed_Wasm(t *testing.T) { _, err = dymension.SendIBCTransfer(ctx, channel.ChannelID, dymensionUserAddr, transferData, options) require.NoError(t, err) - rollappHeight, err = rollapp1.GetNode().Height(ctx) - require.NoError(t, err) // Get the IBC denom for dymension on roll app dymensionTokenDenom := transfertypes.GetPrefixedDenom(channel.Counterparty.PortID, channel.Counterparty.ChannelID, dymension.Config().Denom) dymensionIBCDenom := transfertypes.ParseDenomTrace(dymensionTokenDenom).IBCDenom() @@ -2175,19 +2200,19 @@ func TestEIBCUpdateOnTimeout_Unallowed_Wasm(t *testing.T) { require.NoError(t, err) // get eibc event - eibcEvents, err := getEIbcEventsWithinBlockRange(ctx, dymension, 20, false) + eibcEvents, err := getEIbcEventsWithinBlockRange(ctx, dymension, 80, false) require.NoError(t, err) - fmt.Println("Event:", eibcEvents[0]) + fmt.Println("Event:", eibcEvents) require.Equal(t, eibcEvents[0].Price, fmt.Sprintf("%s%s", transferAmountWithoutFee, dymension.Config().Denom)) require.Equal(t, eibcEvents[0].Fee, fmt.Sprintf("%s%s", globalEIbcFee, dymension.Config().Denom)) // modify demand order with new fee - txhash, err := dymension.UpdateDemandOrder(ctx, eibcEvents[0].ID, marketMakerAddr, globalEIbcFee.Mul(math.NewInt(2))) + txhash, err := dymension.UpdateDemandOrder(ctx, eibcEvents[0].OrderId, marketMakerAddr, globalEIbcFee.Mul(math.NewInt(2))) require.NoError(t, err) res, err := dymension.GetTransaction(txhash) require.NoError(t, err) - require.Equal(t, uint32(4), res.Code) + require.True(t, (res.Code == uint32(4)) || (res.Code == uint32(5))) t.Cleanup( func() { @@ -2197,4 +2222,6 @@ func TestEIBCUpdateOnTimeout_Unallowed_Wasm(t *testing.T) { } }, ) + // Run invariant check + CheckInvariant(t, ctx, dymension, dymensionUser.KeyName()) } diff --git a/tests/eibc_fulfillment_test.go b/tests/eibc_fulfillment_test.go index 2655bcfa..1e8f5016 100644 --- a/tests/eibc_fulfillment_test.go +++ b/tests/eibc_fulfillment_test.go @@ -4,7 +4,6 @@ import ( "context" "fmt" "regexp" - "strconv" "testing" "cosmossdk.io/math" @@ -13,11 +12,9 @@ import ( "go.uber.org/zap/zaptest" test "github.com/decentrio/rollup-e2e-testing" - "github.com/decentrio/rollup-e2e-testing/blockdb" "github.com/decentrio/rollup-e2e-testing/cosmos" "github.com/decentrio/rollup-e2e-testing/cosmos/hub/dym_hub" "github.com/decentrio/rollup-e2e-testing/cosmos/rollapp/dym_rollapp" - dymensiontesting "github.com/decentrio/rollup-e2e-testing/dymension" "github.com/decentrio/rollup-e2e-testing/ibc" "github.com/decentrio/rollup-e2e-testing/relayer" "github.com/decentrio/rollup-e2e-testing/testreporter" @@ -39,22 +36,14 @@ func TestEIBCFulfillOnOneRollApp_EVM(t *testing.T) { gas_price_rollapp1 := "0adym" maxIdleTime1 := "10s" maxProofTime := "500ms" - configFileOverrides1 := overridesDymintToml(settlement_layer_rollapp1, settlement_node_address, rollapp1_id, gas_price_rollapp1, maxIdleTime1, maxProofTime, "100s") + configFileOverrides1 := overridesDymintToml(settlement_layer_rollapp1, settlement_node_address, rollapp1_id, gas_price_rollapp1, maxIdleTime1, maxProofTime, "50s") // setup config for rollapp 2 settlement_layer_rollapp2 := "dymension" rollapp2_id := "decentrio_12345-1" gas_price_rollapp2 := "0adym" maxIdleTime2 := "1s" - configFileOverrides2 := overridesDymintToml(settlement_layer_rollapp2, settlement_node_address, rollapp2_id, gas_price_rollapp2, maxIdleTime2, maxProofTime, "100s") - - modifyGenesisKV := append( - dymensionGenesisKV, - cosmos.GenesisKV{ - Key: "app_state.rollapp.params.dispute_period_in_blocks", - Value: fmt.Sprint(BLOCK_FINALITY_PERIOD), - }, - ) + configFileOverrides2 := overridesDymintToml(settlement_layer_rollapp2, settlement_node_address, rollapp2_id, gas_price_rollapp2, maxIdleTime2, maxProofTime, "50s") // Create chain factory with dymension numHubVals := 1 @@ -122,7 +111,7 @@ func TestEIBCFulfillOnOneRollApp_EVM(t *testing.T) { GasAdjustment: 1.1, TrustingPeriod: "112h", NoHostMount: false, - ModifyGenesis: modifyDymensionGenesis(modifyGenesisKV), + ModifyGenesis: modifyDymensionGenesis(dymensionGenesisKV), ConfigFileOverrides: nil, }, NumValidators: &numHubVals, @@ -179,7 +168,7 @@ func TestEIBCFulfillOnOneRollApp_EVM(t *testing.T) { // This can be used to write to the block database which will index all block data e.g. txs, msgs, events, etc. // BlockDatabaseFile: test.DefaultBlockDatabaseFilepath(), - }, nil, "", nil) + }, nil, "", nil, false, 780) require.NoError(t, err) CreateChannel(ctx, t, r1, eRep, dymension.CosmosChain, rollapp1.CosmosChain, ibcPath) @@ -245,10 +234,10 @@ func TestEIBCFulfillOnOneRollApp_EVM(t *testing.T) { _, err = rollapp2.SendIBCTransfer(ctx, dymChannel_ra2[0].ChannelID, rollapp2UserAddr, transferData, ibc.TransferOptions{}) require.NoError(t, err) - rollappHeight, err := rollapp1.GetNode().Height(ctx) + err = testutil.WaitForBlocks(ctx, 10, dymension, rollapp1) require.NoError(t, err) - rollapp2Height, err := rollapp2.GetNode().Height(ctx) + rollappHeight, err := rollapp1.GetNode().Height(ctx) require.NoError(t, err) // wait until the packet is finalized @@ -256,10 +245,22 @@ func TestEIBCFulfillOnOneRollApp_EVM(t *testing.T) { require.NoError(t, err) require.True(t, isFinalized) + rollapp2Height, err := rollapp2.GetNode().Height(ctx) + require.NoError(t, err) + isFinalized, err = dymension.WaitUntilRollappHeightIsFinalized(ctx, rollapp2.GetChainID(), rollapp2Height, 300) require.NoError(t, err) require.True(t, isFinalized) + _, err = dymension.GetNode().FinalizePacketsUntilHeight(ctx, dymensionUserAddr, rollapp1.GetChainID(), fmt.Sprint(rollappHeight)) + require.NoError(t, err) + + _, err = dymension.GetNode().FinalizePacketsUntilHeight(ctx, dymensionUserAddr, rollapp2.GetChainID(), fmt.Sprint(rollapp2Height)) + require.NoError(t, err) + + err = testutil.WaitForBlocks(ctx, 10, dymension, rollapp1) + require.NoError(t, err) + transferDataRollapp1 := ibc.WalletData{ Address: marketMakerAddr, Denom: rollapp1.Config().Denom, @@ -278,6 +279,10 @@ func TestEIBCFulfillOnOneRollApp_EVM(t *testing.T) { // market maker needs to have funds on the hub first to be able to fulfill incoming demand order _, err = rollapp1.SendIBCTransfer(ctx, dymChannel_ra1[0].ChannelID, rollappUserAddr, transferDataRollapp1, options) require.NoError(t, err) + + err = testutil.WaitForBlocks(ctx, 10, dymension, rollapp1) + require.NoError(t, err) + rollappHeight, err = rollapp1.GetNode().Height(ctx) require.NoError(t, err) @@ -286,6 +291,12 @@ func TestEIBCFulfillOnOneRollApp_EVM(t *testing.T) { require.NoError(t, err) require.True(t, isFinalized) + _, err = dymension.GetNode().FinalizePacketsUntilHeight(ctx, dymensionUserAddr, rollapp1.GetChainID(), fmt.Sprint(rollappHeight)) + require.NoError(t, err) + + err = testutil.WaitForBlocks(ctx, 10, dymension, rollapp1) + require.NoError(t, err) + // Minus 0.1% of transfer amount for bridge fee expMmBalanceRollappDenom := (bigTransferAmount.Sub(bigBridgingFee)) balance, err := dymension.GetBalance(ctx, marketMakerAddr, rollappIBCDenom) @@ -318,15 +329,14 @@ func TestEIBCFulfillOnOneRollApp_EVM(t *testing.T) { _, err = rollapp1.SendIBCTransfer(ctx, dymChannel_ra1[0].ChannelID, rollappUserAddr, transferDataRollapp1, options) require.NoError(t, err) - rollappHeight, err = rollapp1.GetNode().Height(ctx) - require.NoError(t, err) + balance, err = dymension.GetBalance(ctx, dymensionUserAddr, rollappIBCDenom) require.NoError(t, err) fmt.Println("Balance of dymensionUserAddr right after sending eIBC transfer from rollapp 1 to dym hub:", balance) require.True(t, balance.Equal(transferAmount.Sub(bridgingFee)), fmt.Sprintf("Value mismatch. Expected %s, actual %s", transferAmount.Sub(bridgingFee), balance)) // get eIbc event - eibcEvents, err := getEIbcEventsWithinBlockRange(ctx, dymension, 30, false) + eibcEvents, err := getEIbcEventsWithinBlockRange(ctx, dymension, 10, false) require.NoError(t, err) for i, eibcEvent := range eibcEvents { fmt.Println(i, "EIBC Event:", eibcEvent) @@ -338,7 +348,7 @@ func TestEIBCFulfillOnOneRollApp_EVM(t *testing.T) { re := regexp.MustCompile(`^\d+`) if re.ReplaceAllString(eibcEvent.Price, "") == rollappIBCDenom && eibcEvent.PacketStatus == "PENDING" { fmt.Println("EIBC Event:", eibcEvent) - txhash, err := dymension.FullfillDemandOrder(ctx, eibcEvent.ID, marketMakerAddr, eibcFee) + txhash, err := dymension.FullfillDemandOrder(ctx, eibcEvent.OrderId, marketMakerAddr, eibcFee) require.NoError(t, err) fmt.Println(txhash) // eibcEvent := getEibcEventFromTx(t, dymension, txhash) @@ -361,26 +371,37 @@ func TestEIBCFulfillOnOneRollApp_EVM(t *testing.T) { fmt.Println("Balance of dymensionUserAddr after fulfilling the order:", balance) require.True(t, balance.Equal(transferAmountWithoutFee.Add(transferAmount.Sub(bridgingFee)).Sub(bridgingFee)), fmt.Sprintf("Value mismatch. Expected %s, actual %s", transferAmountWithoutFee.Add(transferAmount.Sub(bridgingFee)).Sub(bridgingFee), balance)) - // verify correct funds were deducted from market maker's wallet address - balance, err = dymension.GetBalance(ctx, marketMakerAddr, rollappIBCDenom) + rollappHeight, err = rollapp1.GetNode().Height(ctx) require.NoError(t, err) - fmt.Println("Balance of marketMakerAddr after fulfilling the order:", balance) - expMmBalanceRollappDenom = expMmBalanceRollappDenom.Sub((transferAmount)).Add(eibcFee).Add(bridgingFee) - require.True(t, balance.Equal(expMmBalanceRollappDenom), fmt.Sprintf("Value mismatch. Expected %s, actual %s", expMmBalanceRollappDenom, balance)) - // wait until packet finalization and verify funds + fee were added to market maker's wallet address - isFinalized, err = dymension.WaitUntilRollappHeightIsFinalized(ctx, rollapp1.GetChainID(), rollappHeight, 200) + // wait until the packet is finalized on Rollapps + isFinalized, err = dymension.WaitUntilRollappHeightIsFinalized(ctx, rollapp1.GetChainID(), rollappHeight, 300) require.NoError(t, err) require.True(t, isFinalized) + + _, err = dymension.GetNode().FinalizePacketsUntilHeight(ctx, dymensionUserAddr, rollapp1.GetChainID(), fmt.Sprint(rollappHeight)) + require.NoError(t, err) + + rollappHeight, err = rollapp2.GetNode().Height(ctx) + require.NoError(t, err) + + // wait until the packet is finalized on Rollapps + isFinalized, err = dymension.WaitUntilRollappHeightIsFinalized(ctx, rollapp2.GetChainID(), rollappHeight, 300) + require.NoError(t, err) + require.True(t, isFinalized) + + _, err = dymension.GetNode().FinalizePacketsUntilHeight(ctx, dymensionUserAddr, rollapp2.GetChainID(), fmt.Sprint(rollappHeight)) + require.NoError(t, err) + + // verify correct funds were deducted from market maker's wallet address balance, err = dymension.GetBalance(ctx, marketMakerAddr, rollappIBCDenom) require.NoError(t, err) - fmt.Println("Balance of marketMakerAddr after packet finalization:", balance) - expMmBalanceRollappDenom = expMmBalanceRollappDenom.Add(transferDataRollapp1.Amount) - expMmBalanceRollappDenom = expMmBalanceRollappDenom.Sub(bridgingFee) + fmt.Println("Balance of marketMakerAddr after fulfilling the order:", balance) + expMmBalanceRollappDenom = expMmBalanceRollappDenom.Add(eibcFee) require.True(t, balance.Equal(expMmBalanceRollappDenom), fmt.Sprintf("Value mismatch. Expected %s, actual %s", expMmBalanceRollappDenom, balance)) // user should have received funds upon grace period of IBC packet from rollapp 2 - err = testutil.WaitForBlocks(ctx, 30, rollapp2) + err = testutil.WaitForBlocks(ctx, 10, rollapp2) require.NoError(t, err) balance, err = dymension.GetBalance(ctx, dymensionUserAddr, rollapp2IBCDenom) require.NoError(t, err) @@ -408,6 +429,9 @@ func TestEIBCFulfillOnOneRollApp_EVM(t *testing.T) { } }, ) + + // Run invariant check + CheckInvariant(t, ctx, dymension, dymensionUser.KeyName()) } // TestEIBCFulfillOnOneRollApp tests the case where we have 2 rollapps running, we have pending eIBC packets from both rollapps. one of the packets is fulfilled by the market maker, the other packet is not fulfilled. The test verifies that the funds are transferred correctly and the market maker's balance is updated correctly (after grace period). @@ -425,22 +449,14 @@ func TestEIBCFulfillOnOneRollApp_Wasm(t *testing.T) { gas_price_rollapp1 := "0adym" maxIdleTime1 := "10s" maxProofTime := "500ms" - configFileOverrides1 := overridesDymintToml(settlement_layer_rollapp1, settlement_node_address, rollapp1_id, gas_price_rollapp1, maxIdleTime1, maxProofTime, "100s") + configFileOverrides1 := overridesDymintToml(settlement_layer_rollapp1, settlement_node_address, rollapp1_id, gas_price_rollapp1, maxIdleTime1, maxProofTime, "50s") // setup config for rollapp 2 settlement_layer_rollapp2 := "dymension" rollapp2_id := "decentrio_12345-1" gas_price_rollapp2 := "0adym" maxIdleTime2 := "1s" - configFileOverrides2 := overridesDymintToml(settlement_layer_rollapp2, settlement_node_address, rollapp2_id, gas_price_rollapp2, maxIdleTime2, maxProofTime, "100s") - - modifyGenesisKV := append( - dymensionGenesisKV, - cosmos.GenesisKV{ - Key: "app_state.rollapp.params.dispute_period_in_blocks", - Value: fmt.Sprint(BLOCK_FINALITY_PERIOD), - }, - ) + configFileOverrides2 := overridesDymintToml(settlement_layer_rollapp2, settlement_node_address, rollapp2_id, gas_price_rollapp2, maxIdleTime2, maxProofTime, "50s") // Create chain factory with dymension numHubVals := 1 @@ -508,7 +524,7 @@ func TestEIBCFulfillOnOneRollApp_Wasm(t *testing.T) { GasAdjustment: 1.1, TrustingPeriod: "112h", NoHostMount: false, - ModifyGenesis: modifyDymensionGenesis(modifyGenesisKV), + ModifyGenesis: modifyDymensionGenesis(dymensionGenesisKV), ConfigFileOverrides: nil, }, NumValidators: &numHubVals, @@ -565,7 +581,7 @@ func TestEIBCFulfillOnOneRollApp_Wasm(t *testing.T) { // This can be used to write to the block database which will index all block data e.g. txs, msgs, events, etc. // BlockDatabaseFile: test.DefaultBlockDatabaseFilepath(), - }, nil, "", nil) + }, nil, "", nil, false, 780) require.NoError(t, err) CreateChannel(ctx, t, r1, eRep, dymension.CosmosChain, rollapp1.CosmosChain, ibcPath) @@ -631,6 +647,9 @@ func TestEIBCFulfillOnOneRollApp_Wasm(t *testing.T) { _, err = rollapp2.SendIBCTransfer(ctx, dymChannel_ra2[0].ChannelID, rollapp2UserAddr, transferData, ibc.TransferOptions{}) require.NoError(t, err) + err = testutil.WaitForBlocks(ctx, 10, dymension, rollapp1) + require.NoError(t, err) + rollappHeight, err := rollapp1.GetNode().Height(ctx) require.NoError(t, err) @@ -646,6 +665,15 @@ func TestEIBCFulfillOnOneRollApp_Wasm(t *testing.T) { require.NoError(t, err) require.True(t, isFinalized) + _, err = dymension.GetNode().FinalizePacketsUntilHeight(ctx, dymensionUserAddr, rollapp1.GetChainID(), fmt.Sprint(rollappHeight)) + require.NoError(t, err) + + _, err = dymension.GetNode().FinalizePacketsUntilHeight(ctx, dymensionUserAddr, rollapp2.GetChainID(), fmt.Sprint(rollapp2Height)) + require.NoError(t, err) + + err = testutil.WaitForBlocks(ctx, 10, dymension, rollapp1) + require.NoError(t, err) + transferDataRollapp1 := ibc.WalletData{ Address: marketMakerAddr, Denom: rollapp1.Config().Denom, @@ -664,6 +692,10 @@ func TestEIBCFulfillOnOneRollApp_Wasm(t *testing.T) { // market maker needs to have funds on the hub first to be able to fulfill incoming demand order _, err = rollapp1.SendIBCTransfer(ctx, dymChannel_ra1[0].ChannelID, rollappUserAddr, transferDataRollapp1, options) require.NoError(t, err) + + err = testutil.WaitForBlocks(ctx, 10, dymension, rollapp1) + require.NoError(t, err) + rollappHeight, err = rollapp1.GetNode().Height(ctx) require.NoError(t, err) @@ -672,6 +704,12 @@ func TestEIBCFulfillOnOneRollApp_Wasm(t *testing.T) { require.NoError(t, err) require.True(t, isFinalized) + _, err = dymension.GetNode().FinalizePacketsUntilHeight(ctx, dymensionUserAddr, rollapp1.GetChainID(), fmt.Sprint(rollappHeight)) + require.NoError(t, err) + + err = testutil.WaitForBlocks(ctx, 10, dymension, rollapp1) + require.NoError(t, err) + // Minus 0.1% of transfer amount for bridge fee expMmBalanceRollappDenom := (bigTransferAmount.Sub(bigBridgingFee)) balance, err := dymension.GetBalance(ctx, marketMakerAddr, rollappIBCDenom) @@ -704,15 +742,14 @@ func TestEIBCFulfillOnOneRollApp_Wasm(t *testing.T) { _, err = rollapp1.SendIBCTransfer(ctx, dymChannel_ra1[0].ChannelID, rollappUserAddr, transferDataRollapp1, options) require.NoError(t, err) - rollappHeight, err = rollapp1.GetNode().Height(ctx) - require.NoError(t, err) + balance, err = dymension.GetBalance(ctx, dymensionUserAddr, rollappIBCDenom) require.NoError(t, err) fmt.Println("Balance of dymensionUserAddr right after sending eIBC transfer:", balance) require.True(t, balance.Equal(transferAmount.Sub(bridgingFee)), fmt.Sprintf("Value mismatch. Expected %s, actual %s", transferAmount.Sub(bridgingFee), balance)) // get eIbc event - eibcEvents, err := getEIbcEventsWithinBlockRange(ctx, dymension, 30, false) + eibcEvents, err := getEIbcEventsWithinBlockRange(ctx, dymension, 10, false) require.NoError(t, err) for i, eibcEvent := range eibcEvents { fmt.Println(i, "EIBC Event:", eibcEvent) @@ -723,7 +760,7 @@ func TestEIBCFulfillOnOneRollApp_Wasm(t *testing.T) { for _, eibcEvent := range eibcEvents { re := regexp.MustCompile(`^\d+`) if re.ReplaceAllString(eibcEvent.Price, "") == rollappIBCDenom && eibcEvent.PacketStatus == "PENDING" { - _, err := dymension.FullfillDemandOrder(ctx, eibcEvent.ID, marketMakerAddr, eibcFee) + _, err := dymension.FullfillDemandOrder(ctx, eibcEvent.OrderId, marketMakerAddr, eibcFee) require.NoError(t, err) // eibcEvent := getEibcEventFromTx(t, dymension, txhash) // if eibcEvent != nil { @@ -753,9 +790,19 @@ func TestEIBCFulfillOnOneRollApp_Wasm(t *testing.T) { require.True(t, balance.Equal(expMmBalanceRollappDenom), fmt.Sprintf("Value mismatch. Expected %s, actual %s", expMmBalanceRollappDenom, balance)) // wait until packet finalization and verify funds + fee were added to market maker's wallet address + rollappHeight, err = rollapp1.GetNode().Height(ctx) + require.NoError(t, err) + isFinalized, err = dymension.WaitUntilRollappHeightIsFinalized(ctx, rollapp1.GetChainID(), rollappHeight, 200) require.NoError(t, err) require.True(t, isFinalized) + + _, err = dymension.GetNode().FinalizePacketsUntilHeight(ctx, dymensionUserAddr, rollapp1.GetChainID(), fmt.Sprint(rollappHeight)) + require.NoError(t, err) + + err = testutil.WaitForBlocks(ctx, 10, dymension, rollapp1) + require.NoError(t, err) + balance, err = dymension.GetBalance(ctx, marketMakerAddr, rollappIBCDenom) require.NoError(t, err) fmt.Println("Balance of marketMakerAddr after packet finalization:", balance) @@ -764,8 +811,19 @@ func TestEIBCFulfillOnOneRollApp_Wasm(t *testing.T) { require.True(t, balance.Equal(expMmBalanceRollappDenom), fmt.Sprintf("Value mismatch. Expected %s, actual %s", expMmBalanceRollappDenom, balance)) // user should have received funds upon grace period of IBC packet from rollapp 2 - err = testutil.WaitForBlocks(ctx, 30, rollapp2) + rollappHeight, err = rollapp2.GetNode().Height(ctx) + require.NoError(t, err) + + isFinalized, err = dymension.WaitUntilRollappHeightIsFinalized(ctx, rollapp2.GetChainID(), rollappHeight, 300) require.NoError(t, err) + require.True(t, isFinalized) + + _, err = dymension.GetNode().FinalizePacketsUntilHeight(ctx, dymensionUserAddr, rollapp2.GetChainID(), fmt.Sprint(rollappHeight)) + require.NoError(t, err) + + err = testutil.WaitForBlocks(ctx, 10, dymension, rollapp2) + require.NoError(t, err) + balance, err = dymension.GetBalance(ctx, dymensionUserAddr, rollapp2IBCDenom) require.NoError(t, err) fmt.Println("Balance of dymensionUserAddr for rollapp 2 ibc denom after grace period:", balance) @@ -792,6 +850,9 @@ func TestEIBCFulfillOnOneRollApp_Wasm(t *testing.T) { } }, ) + + // Run invariant check + CheckInvariant(t, ctx, dymension, dymensionUser.KeyName()) } // This test case verifies the system's behavior when an eIBC packet sent from the rollapp to the hub @@ -810,22 +871,14 @@ func TestEIBCFulfillment_EVM(t *testing.T) { gas_price_rollapp1 := "0adym" maxIdleTime1 := "10s" maxProofTime := "500ms" - configFileOverrides1 := overridesDymintToml(settlement_layer_rollapp1, settlement_node_address, rollapp1_id, gas_price_rollapp1, maxIdleTime1, maxProofTime, "100s") + configFileOverrides1 := overridesDymintToml(settlement_layer_rollapp1, settlement_node_address, rollapp1_id, gas_price_rollapp1, maxIdleTime1, maxProofTime, "50s") // setup config for rollapp 2 settlement_layer_rollapp2 := "dymension" rollapp2_id := "decentrio_12345-1" gas_price_rollapp2 := "0adym" maxIdleTime2 := "1s" - configFileOverrides2 := overridesDymintToml(settlement_layer_rollapp2, settlement_node_address, rollapp2_id, gas_price_rollapp2, maxIdleTime2, maxProofTime, "100s") - - modifyGenesisKV := append( - dymensionGenesisKV, - cosmos.GenesisKV{ - Key: "app_state.rollapp.params.dispute_period_in_blocks", - Value: fmt.Sprint(BLOCK_FINALITY_PERIOD), - }, - ) + configFileOverrides2 := overridesDymintToml(settlement_layer_rollapp2, settlement_node_address, rollapp2_id, gas_price_rollapp2, maxIdleTime2, maxProofTime, "50s") // Create chain factory with dymension numHubVals := 1 @@ -893,7 +946,7 @@ func TestEIBCFulfillment_EVM(t *testing.T) { GasAdjustment: 1.1, TrustingPeriod: "112h", NoHostMount: false, - ModifyGenesis: modifyDymensionGenesis(modifyGenesisKV), + ModifyGenesis: modifyDymensionGenesis(dymensionGenesisKV), ConfigFileOverrides: nil, }, NumValidators: &numHubVals, @@ -948,7 +1001,7 @@ func TestEIBCFulfillment_EVM(t *testing.T) { // This can be used to write to the block database which will index all block data e.g. txs, msgs, events, etc. // BlockDatabaseFile: test.DefaultBlockDatabaseFilepath(), - }, nil, "", nil) + }, nil, "", nil, false, 780) require.NoError(t, err) CreateChannel(ctx, t, r1, eRep, dymension.CosmosChain, rollapp1.CosmosChain, ibcPath) @@ -997,6 +1050,9 @@ func TestEIBCFulfillment_EVM(t *testing.T) { _, err = rollapp1.SendIBCTransfer(ctx, dymChannel[0].Counterparty.ChannelID, rollappUserAddr, transferData, ibc.TransferOptions{}) require.NoError(t, err) + err = testutil.WaitForBlocks(ctx, 10, dymension, rollapp1) + require.NoError(t, err) + rollappHeight, err := rollapp1.GetNode().Height(ctx) require.NoError(t, err) @@ -1008,6 +1064,12 @@ func TestEIBCFulfillment_EVM(t *testing.T) { require.NoError(t, err) require.True(t, isFinalized) + _, err = dymension.GetNode().FinalizePacketsUntilHeight(ctx, dymensionUserAddr, rollapp1.GetChainID(), fmt.Sprint(rollappHeight)) + require.NoError(t, err) + + err = testutil.WaitForBlocks(ctx, 30, dymension, rollapp1) + require.NoError(t, err) + // Get the IBC denom for urax on Hub rollappTokenDenom := transfertypes.GetPrefixedDenom(dymChannel[0].Counterparty.PortID, dymChannel[0].Counterparty.ChannelID, rollapp1.Config().Denom) rollappIBCDenom := transfertypes.ParseDenomTrace(rollappTokenDenom).IBCDenom() @@ -1033,9 +1095,6 @@ func TestEIBCFulfillment_EVM(t *testing.T) { _, err = rollapp1.SendIBCTransfer(ctx, dymChannel[0].ChannelID, rollappUserAddr, transferData, options) require.NoError(t, err) - rollappHeight, err = rollapp1.GetNode().Height(ctx) - require.NoError(t, err) - balance, err = dymension.GetBalance(ctx, dymensionUserAddr, rollappIBCDenom) require.NoError(t, err) @@ -1043,12 +1102,12 @@ func TestEIBCFulfillment_EVM(t *testing.T) { require.True(t, balance.Equal(zeroBal), fmt.Sprintf("Value mismatch. Expected %s, actual %s", zeroBal, balance)) // get eIbc event - eibcEvents, err := getEIbcEventsWithinBlockRange(ctx, dymension, 30, false) + eibcEvents, err := getEIbcEventsWithinBlockRange(ctx, dymension, 10, false) require.NoError(t, err) - fmt.Println("Event:", eibcEvents[1]) + fmt.Println("Event:", eibcEvents) // fulfill demand order - txhash, err := dymension.FullfillDemandOrder(ctx, eibcEvents[1].ID, marketMakerAddr, eibcFee) + txhash, err := dymension.FullfillDemandOrder(ctx, eibcEvents[0].OrderId, marketMakerAddr, eibcFee) require.NoError(t, err) fmt.Println(txhash) // eibcEvent := getEibcEventFromTx(t, dymension, txhash) @@ -1065,21 +1124,22 @@ func TestEIBCFulfillment_EVM(t *testing.T) { require.NoError(t, err) fmt.Println("Balance of dymensionUserAddr after fulfilling the order:", balance) require.True(t, balance.Equal(transferAmountWithoutFee.Sub(bridgingFee)), fmt.Sprintf("Value mismatch. Expected %s, actual %s", transferAmountWithoutFee.Sub(bridgingFee), balance)) + // verify funds were deducted from market maker's wallet address - balance, err = dymension.GetBalance(ctx, marketMakerAddr, rollappIBCDenom) + rollappHeight, err = rollapp1.GetNode().Height(ctx) require.NoError(t, err) - fmt.Println("Balance of marketMakerAddr after fulfilling the order:", balance) - expMmBalanceRollappDenom = expMmBalanceRollappDenom.Sub((transferAmountWithoutFee)).Add(bridgingFee) - require.True(t, balance.Equal(expMmBalanceRollappDenom), fmt.Sprintf("Value mismatch. Expected %s, actual %s", expMmBalanceRollappDenom, balance)) - // wait until packet finalization and verify funds + fee were added to market maker's wallet address + isFinalized, err = dymension.WaitUntilRollappHeightIsFinalized(ctx, rollapp1.GetChainID(), rollappHeight, 300) require.NoError(t, err) require.True(t, isFinalized) + + _, err = dymension.GetNode().FinalizePacketsUntilHeight(ctx, dymensionUserAddr, rollapp1.GetChainID(), fmt.Sprint(rollappHeight)) + require.NoError(t, err) + balance, err = dymension.GetBalance(ctx, marketMakerAddr, rollappIBCDenom) require.NoError(t, err) - fmt.Println("Balance of marketMakerAddr after packet finalization:", balance) - expMmBalanceRollappDenom = expMmBalanceRollappDenom.Add(transferData.Amount) - expMmBalanceRollappDenom = expMmBalanceRollappDenom.Sub(bridgingFee) + fmt.Println("Balance of marketMakerAddr after fulfilling the order:", balance) + expMmBalanceRollappDenom = expMmBalanceRollappDenom.Add(eibcFee) require.True(t, balance.Equal(expMmBalanceRollappDenom), fmt.Sprintf("Value mismatch. Expected %s, actual %s", expMmBalanceRollappDenom, balance)) t.Cleanup( @@ -1090,6 +1150,9 @@ func TestEIBCFulfillment_EVM(t *testing.T) { } }, ) + + // Run invariant check + CheckInvariant(t, ctx, dymension, dymensionUser.KeyName()) } func TestEIBCFulfillment_Wasm(t *testing.T) { @@ -1106,22 +1169,14 @@ func TestEIBCFulfillment_Wasm(t *testing.T) { gas_price_rollapp1 := "0adym" maxIdleTime1 := "10s" maxProofTime := "500ms" - configFileOverrides1 := overridesDymintToml(settlement_layer_rollapp1, settlement_node_address, rollapp1_id, gas_price_rollapp1, maxIdleTime1, maxProofTime, "100s") + configFileOverrides1 := overridesDymintToml(settlement_layer_rollapp1, settlement_node_address, rollapp1_id, gas_price_rollapp1, maxIdleTime1, maxProofTime, "50s") // setup config for rollapp 2 settlement_layer_rollapp2 := "dymension" rollapp2_id := "decentrio_12345-1" gas_price_rollapp2 := "0adym" maxIdleTime2 := "1s" - configFileOverrides2 := overridesDymintToml(settlement_layer_rollapp2, settlement_node_address, rollapp2_id, gas_price_rollapp2, maxIdleTime2, maxProofTime, "100s") - - modifyGenesisKV := append( - dymensionGenesisKV, - cosmos.GenesisKV{ - Key: "app_state.rollapp.params.dispute_period_in_blocks", - Value: fmt.Sprint(BLOCK_FINALITY_PERIOD), - }, - ) + configFileOverrides2 := overridesDymintToml(settlement_layer_rollapp2, settlement_node_address, rollapp2_id, gas_price_rollapp2, maxIdleTime2, maxProofTime, "50s") // Create chain factory with dymension numHubVals := 1 @@ -1189,7 +1244,7 @@ func TestEIBCFulfillment_Wasm(t *testing.T) { GasAdjustment: 1.1, TrustingPeriod: "112h", NoHostMount: false, - ModifyGenesis: modifyDymensionGenesis(modifyGenesisKV), + ModifyGenesis: modifyDymensionGenesis(dymensionGenesisKV), ConfigFileOverrides: nil, }, NumValidators: &numHubVals, @@ -1244,7 +1299,7 @@ func TestEIBCFulfillment_Wasm(t *testing.T) { // This can be used to write to the block database which will index all block data e.g. txs, msgs, events, etc. // BlockDatabaseFile: test.DefaultBlockDatabaseFilepath(), - }, nil, "", nil) + }, nil, "", nil, false, 780) require.NoError(t, err) CreateChannel(ctx, t, r1, eRep, dymension.CosmosChain, rollapp1.CosmosChain, ibcPath) @@ -1304,6 +1359,9 @@ func TestEIBCFulfillment_Wasm(t *testing.T) { _, err = rollapp1.SendIBCTransfer(ctx, channsRollApp1[0].ChannelID, rollappUserAddr, transferData, ibc.TransferOptions{}) require.NoError(t, err) + err = testutil.WaitForBlocks(ctx, 10, dymension, rollapp1) + require.NoError(t, err) + rollappHeight, err := rollapp1.GetNode().Height(ctx) require.NoError(t, err) @@ -1312,6 +1370,12 @@ func TestEIBCFulfillment_Wasm(t *testing.T) { require.NoError(t, err) require.True(t, isFinalized) + _, err = dymension.GetNode().FinalizePacketsUntilHeight(ctx, dymensionUserAddr, rollapp1.GetChainID(), fmt.Sprint(rollappHeight)) + require.NoError(t, err) + + err = testutil.WaitForBlocks(ctx, 10, dymension, rollapp1) + require.NoError(t, err) + // Get the IBC denom for urax on Hub rollappTokenDenom := transfertypes.GetPrefixedDenom(channsRollApp1[0].PortID, channsRollApp1[0].ChannelID, rollapp1.Config().Denom) rollappIBCDenom := transfertypes.ParseDenomTrace(rollappTokenDenom).IBCDenom() @@ -1338,9 +1402,6 @@ func TestEIBCFulfillment_Wasm(t *testing.T) { _, err = rollapp1.SendIBCTransfer(ctx, channsRollApp1[0].ChannelID, rollappUserAddr, transferData, options) require.NoError(t, err) - rollappHeight, err = rollapp1.GetNode().Height(ctx) - require.NoError(t, err) - balance, err = dymension.GetBalance(ctx, dymensionUserAddr, rollappIBCDenom) require.NoError(t, err) @@ -1348,12 +1409,12 @@ func TestEIBCFulfillment_Wasm(t *testing.T) { require.True(t, balance.Equal(zeroBal), fmt.Sprintf("Value mismatch. Expected %s, actual %s", zeroBal, balance)) // get eIbc event - eibcEvents, err := getEIbcEventsWithinBlockRange(ctx, dymension, 30, false) + eibcEvents, err := getEIbcEventsWithinBlockRange(ctx, dymension, 10, false) require.NoError(t, err) - fmt.Println("Event:", eibcEvents[1]) + fmt.Println("Event:", eibcEvents[0]) // fulfill demand order - txhash, err := dymension.FullfillDemandOrder(ctx, eibcEvents[1].ID, marketMakerAddr, eibcFee) + txhash, err := dymension.FullfillDemandOrder(ctx, eibcEvents[0].OrderId, marketMakerAddr, eibcFee) require.NoError(t, err) fmt.Println(txhash) // eibcEvent := getEibcEventFromTx(t, dymension, txhash) @@ -1370,21 +1431,22 @@ func TestEIBCFulfillment_Wasm(t *testing.T) { require.NoError(t, err) fmt.Println("Balance of dymensionUserAddr after fulfilling the order:", balance) require.True(t, balance.Equal(transferAmountWithoutFee.Sub(bridgingFee)), fmt.Sprintf("Value mismatch. Expected %s, actual %s", transferAmountWithoutFee.Sub(bridgingFee), balance)) - // verify funds were deducted from market maker's wallet address - balance, err = dymension.GetBalance(ctx, marketMakerAddr, rollappIBCDenom) - require.NoError(t, err) - fmt.Println("Balance of marketMakerAddr after fulfilling the order:", balance) - expMmBalanceRollappDenom = expMmBalanceRollappDenom.Sub((transferAmountWithoutFee)).Add(bridgingFee) - require.True(t, balance.Equal(expMmBalanceRollappDenom), fmt.Sprintf("Value mismatch. Expected %s, actual %s", expMmBalanceRollappDenom, balance)) + // wait until packet finalization and verify funds + fee were added to market maker's wallet address + rollappHeight, err = rollapp1.GetNode().Height(ctx) + require.NoError(t, err) + isFinalized, err = dymension.WaitUntilRollappHeightIsFinalized(ctx, rollapp1.GetChainID(), rollappHeight, 300) require.NoError(t, err) require.True(t, isFinalized) + + _, err = dymension.GetNode().FinalizePacketsUntilHeight(ctx, dymensionUserAddr, rollapp1.GetChainID(), fmt.Sprint(rollappHeight)) + require.NoError(t, err) + balance, err = dymension.GetBalance(ctx, marketMakerAddr, rollappIBCDenom) require.NoError(t, err) fmt.Println("Balance of marketMakerAddr after packet finalization:", balance) - expMmBalanceRollappDenom = expMmBalanceRollappDenom.Add(transferData.Amount) - expMmBalanceRollappDenom = expMmBalanceRollappDenom.Sub(bridgingFee) + expMmBalanceRollappDenom = expMmBalanceRollappDenom.Add(eibcFee) require.True(t, balance.Equal(expMmBalanceRollappDenom), fmt.Sprintf("Value mismatch. Expected %s, actual %s", expMmBalanceRollappDenom, balance)) t.Cleanup( @@ -1395,6 +1457,9 @@ func TestEIBCFulfillment_Wasm(t *testing.T) { } }, ) + + // Run invariant check + CheckInvariant(t, ctx, dymension, dymensionUser.KeyName()) } func TestEIBCFulfillment_two_rollapps_EVM(t *testing.T) { @@ -1411,22 +1476,14 @@ func TestEIBCFulfillment_two_rollapps_EVM(t *testing.T) { gas_price_rollapp1 := "0adym" maxIdleTime1 := "10s" maxProofTime := "500ms" - configFileOverrides1 := overridesDymintToml(settlement_layer_rollapp1, settlement_node_address, rollapp1_id, gas_price_rollapp1, maxIdleTime1, maxProofTime, "100s") + configFileOverrides1 := overridesDymintToml(settlement_layer_rollapp1, settlement_node_address, rollapp1_id, gas_price_rollapp1, maxIdleTime1, maxProofTime, "50s") // setup config for rollapp 2 settlement_layer_rollapp2 := "dymension" rollapp2_id := "decentrio_12345-1" gas_price_rollapp2 := "0adym" maxIdleTime2 := "1s" - configFileOverrides2 := overridesDymintToml(settlement_layer_rollapp2, settlement_node_address, rollapp2_id, gas_price_rollapp2, maxIdleTime2, maxProofTime, "100s") - - modifyGenesisKV := append( - dymensionGenesisKV, - cosmos.GenesisKV{ - Key: "app_state.rollapp.params.dispute_period_in_blocks", - Value: fmt.Sprint(BLOCK_FINALITY_PERIOD), - }, - ) + configFileOverrides2 := overridesDymintToml(settlement_layer_rollapp2, settlement_node_address, rollapp2_id, gas_price_rollapp2, maxIdleTime2, maxProofTime, "50s") // Create chain factory with dymension numHubVals := 1 @@ -1494,7 +1551,7 @@ func TestEIBCFulfillment_two_rollapps_EVM(t *testing.T) { GasAdjustment: 1.1, TrustingPeriod: "112h", NoHostMount: false, - ModifyGenesis: modifyDymensionGenesis(modifyGenesisKV), + ModifyGenesis: modifyDymensionGenesis(dymensionGenesisKV), ConfigFileOverrides: nil, }, NumValidators: &numHubVals, @@ -1551,7 +1608,7 @@ func TestEIBCFulfillment_two_rollapps_EVM(t *testing.T) { // This can be used to write to the block database which will index all block data e.g. txs, msgs, events, etc. // BlockDatabaseFile: test.DefaultBlockDatabaseFilepath(), - }, nil, "", nil) + }, nil, "", nil, false, 780) require.NoError(t, err) CreateChannel(ctx, t, r1, eRep, dymension.CosmosChain, rollapp1.CosmosChain, ibcPath) @@ -1621,10 +1678,10 @@ func TestEIBCFulfillment_two_rollapps_EVM(t *testing.T) { _, err = rollapp2.SendIBCTransfer(ctx, dymChannel_ra2[0].ChannelID, rollapp2UserAddr, transferData, ibc.TransferOptions{}) require.NoError(t, err) - rollappHeight, err := rollapp1.GetNode().Height(ctx) + err = testutil.WaitForBlocks(ctx, 10, dymension, rollapp1) require.NoError(t, err) - rollapp2Height, err := rollapp2.GetNode().Height(ctx) + rollappHeight, err := rollapp1.GetNode().Height(ctx) require.NoError(t, err) // wait until the packet is finalized @@ -1632,10 +1689,21 @@ func TestEIBCFulfillment_two_rollapps_EVM(t *testing.T) { require.NoError(t, err) require.True(t, isFinalized) + rollapp2Height, err := rollapp2.GetNode().Height(ctx) + require.NoError(t, err) + isFinalized, err = dymension.WaitUntilRollappHeightIsFinalized(ctx, rollapp2.GetChainID(), rollapp2Height, 300) require.NoError(t, err) require.True(t, isFinalized) + _, err = dymension.GetNode().FinalizePacketsUntilHeight(ctx, dymensionUserAddr, rollapp1.GetChainID(), fmt.Sprint(rollappHeight)) + require.NoError(t, err) + _, err = dymension.GetNode().FinalizePacketsUntilHeight(ctx, dymensionUserAddr, rollapp2.GetChainID(), fmt.Sprint(rollapp2Height)) + require.NoError(t, err) + + err = testutil.WaitForBlocks(ctx, 10, dymension, rollapp1) + require.NoError(t, err) + // Get the IBC denom for urax on Hub rollappTokenDenom := transfertypes.GetPrefixedDenom(dymChannel_ra1[0].Counterparty.PortID, dymChannel_ra1[0].Counterparty.ChannelID, rollapp1.Config().Denom) rollappIBCDenom := transfertypes.ParseDenomTrace(rollappTokenDenom).IBCDenom() @@ -1686,20 +1754,6 @@ func TestEIBCFulfillment_two_rollapps_EVM(t *testing.T) { fmt.Println("Balance of dymensionUserAddr right after sending eIBC transfer from rollapp 2 to dym hub:", balance) require.True(t, balance.Equal(zeroBalance), fmt.Sprintf("Value mismatch. Expected %s, actual %s", zeroBalance, balance)) - // get eIbc event - eibcEvents, err := getEIbcEventsWithinBlockRange(ctx, dymension, 5, false) - require.NoError(t, err) - require.Equal(t, eibcEvents[len(eibcEvents)-1].PacketStatus, "PENDING") - - // fulfill demand order 1 - txhash, err := dymension.FullfillDemandOrder(ctx, eibcEvents[len(eibcEvents)-1].ID, marketMakerAddr, eibcFee) - require.NoError(t, err) - fmt.Println(txhash) - eibcEvent := getEibcEventFromTx(t, dymension, txhash) - if eibcEvent != nil { - fmt.Println("After order fulfillment:", eibcEvent) - } - _, err = rollapp1.SendIBCTransfer(ctx, dymChannel_ra1[0].ChannelID, rollappUserAddr, transferDataRollapp1, options) require.NoError(t, err) @@ -1709,15 +1763,19 @@ func TestEIBCFulfillment_two_rollapps_EVM(t *testing.T) { require.True(t, balance.Equal(zeroBalance), fmt.Sprintf("Value mismatch. Expected %s, actual %s", zeroBalance, balance)) // get eIbc event - eibcEvents, err = getEIbcEventsWithinBlockRange(ctx, dymension, 5, false) + eibcEvents, err := getEIbcEventsWithinBlockRange(ctx, dymension, 10, false) + fmt.Println(eibcEvents) require.NoError(t, err) - require.Equal(t, eibcEvents[len(eibcEvents)-1].PacketStatus, "PENDING") + require.Equal(t, "PENDING", eibcEvents[0].PacketStatus) + require.Equal(t, "PENDING", eibcEvents[1].PacketStatus) // fulfill demand order 2 - txhash, err = dymension.FullfillDemandOrder(ctx, eibcEvents[len(eibcEvents)-1].ID, marketMakerAddr, eibcFee) + _, err = dymension.FullfillDemandOrder(ctx, eibcEvents[1].OrderId, marketMakerAddr, eibcFee) require.NoError(t, err) - fmt.Println(txhash) - eibcEvent = getEibcEventFromTx(t, dymension, txhash) + txhash, err := dymension.FullfillDemandOrder(ctx, eibcEvents[0].OrderId, marketMakerAddr, eibcFee) + require.NoError(t, err) + + eibcEvent := getEibcEventFromTx(t, dymension, txhash) if eibcEvent != nil { fmt.Println("After order fulfillment:", eibcEvent) } @@ -1731,20 +1789,39 @@ func TestEIBCFulfillment_two_rollapps_EVM(t *testing.T) { require.NoError(t, err) fmt.Println("Balance of dymensionUserAddr after fulfilling the order:", balance) require.True(t, balance.Equal(transferAmountWithoutFee.Sub(bridgingFee)), fmt.Sprintf("Value mismatch. Expected %s, actual %s", transferAmountWithoutFee.Sub(bridgingFee), balance)) + balance, err = dymension.GetBalance(ctx, dymensionUserAddr, rollapp2IBCDenom) require.NoError(t, err) fmt.Println("Balance for ibc denom from rollapp 2 of dymensionUserAddr after fulfilling the order:", balance) require.True(t, balance.Equal(transferAmountWithoutFee.Sub(bridgingFee)), fmt.Sprintf("Value mismatch. Expected %s, actual %s", transferAmountWithoutFee.Sub(bridgingFee), balance)) - // wait until packet finalization and verify funds + fee were added to market maker's wallet address - isFinalized, err = dymension.WaitUntilRollappHeightIsFinalized(ctx, rollapp1.GetChainID(), rollappHeight, 200) + // verify funds were deducted from market maker's wallet address + rollappHeight, err = rollapp1.GetNode().Height(ctx) + require.NoError(t, err) + + // wait until the packet is finalized + isFinalized, err = dymension.WaitUntilRollappHeightIsFinalized(ctx, rollapp1.GetChainID(), rollappHeight, 300) require.NoError(t, err) require.True(t, isFinalized) - // verify funds were deducted from market maker's wallet address + + rollapp2Height, err = rollapp2.GetNode().Height(ctx) + require.NoError(t, err) + + // wait until the packet is finalized + isFinalized, err = dymension.WaitUntilRollappHeightIsFinalized(ctx, rollapp2.GetChainID(), rollapp2Height, 300) + require.NoError(t, err) + require.True(t, isFinalized) + + _, err = dymension.GetNode().FinalizePacketsUntilHeight(ctx, dymensionUserAddr, rollapp1.GetChainID(), fmt.Sprint(rollappHeight)) + require.NoError(t, err) + + _, err = dymension.GetNode().FinalizePacketsUntilHeight(ctx, dymensionUserAddr, rollapp2.GetChainID(), fmt.Sprint(rollapp2Height)) + require.NoError(t, err) + balance, err = dymension.GetBalance(ctx, marketMakerAddr, rollappIBCDenom) require.NoError(t, err) fmt.Println("Balance of marketMakerAddr after fulfilling the order:", balance) - expMmBalanceRollappDenom = expMmBalanceRollappDenom.Sub((transferAmountWithoutFee)).Add(bridgingFee) + expMmBalanceRollappDenom = expMmBalanceRollappDenom.Add(eibcFee) require.True(t, balance.Equal(expMmBalanceRollappDenom), fmt.Sprintf("Value mismatch. Expected %s, actual %s", expMmBalanceRollappDenom, balance)) balance, err = dymension.GetBalance(ctx, marketMakerAddr, rollapp2IBCDenom) @@ -1764,6 +1841,9 @@ func TestEIBCFulfillment_two_rollapps_EVM(t *testing.T) { } }, ) + + // Run invariant check + CheckInvariant(t, ctx, dymension, dymensionUser.KeyName()) } // This test case verifies the system's behavior when an eIBC packet sent from the rollapp to the hub @@ -1782,21 +1862,14 @@ func TestEIBCFulfillment_ThirdParty_EVM(t *testing.T) { gas_price_rollapp1 := "0adym" maxIdleTime1 := "10s" maxProofTime := "500ms" - configFileOverrides1 := overridesDymintToml(settlement_layer_rollapp1, settlement_node_address, rollapp1_id, gas_price_rollapp1, maxIdleTime1, maxProofTime, "100s") + configFileOverrides1 := overridesDymintToml(settlement_layer_rollapp1, settlement_node_address, rollapp1_id, gas_price_rollapp1, maxIdleTime1, maxProofTime, "50s") // setup config for rollapp 2 settlement_layer_rollapp2 := "dymension" rollapp2_id := "decentrio_12345-1" gas_price_rollapp2 := "0adym" maxIdleTime2 := "1s" - configFileOverrides2 := overridesDymintToml(settlement_layer_rollapp2, settlement_node_address, rollapp2_id, gas_price_rollapp2, maxIdleTime2, maxProofTime, "100s") - modifyGenesisKV := append( - dymensionGenesisKV, - cosmos.GenesisKV{ - Key: "app_state.rollapp.params.dispute_period_in_blocks", - Value: fmt.Sprint(BLOCK_FINALITY_PERIOD), - }, - ) + configFileOverrides2 := overridesDymintToml(settlement_layer_rollapp2, settlement_node_address, rollapp2_id, gas_price_rollapp2, maxIdleTime2, maxProofTime, "50s") // Disable erc20 modifyRollappGeneisKV := append( @@ -1875,7 +1948,7 @@ func TestEIBCFulfillment_ThirdParty_EVM(t *testing.T) { GasAdjustment: 1.1, TrustingPeriod: "112h", NoHostMount: false, - ModifyGenesis: modifyDymensionGenesis(modifyGenesisKV), + ModifyGenesis: modifyDymensionGenesis(dymensionGenesisKV), ConfigFileOverrides: nil, }, NumValidators: &numHubVals, @@ -1952,7 +2025,7 @@ func TestEIBCFulfillment_ThirdParty_EVM(t *testing.T) { // This can be used to write to the block database which will index all block data e.g. txs, msgs, events, etc. // BlockDatabaseFile: test.DefaultBlockDatabaseFilepath(), - }, nil, "", nil) + }, nil, "", nil, false, 780) require.NoError(t, err) CreateChannel(ctx, t, r1, eRep, dymension.CosmosChain, rollapp1.CosmosChain, ibcPath) @@ -2025,6 +2098,9 @@ func TestEIBCFulfillment_ThirdParty_EVM(t *testing.T) { _, err = rollapp1.SendIBCTransfer(ctx, channsRollApp1[0].ChannelID, rollapp1UserAddr, transferData, ibc.TransferOptions{}) require.NoError(t, err) + err = testutil.WaitForBlocks(ctx, 10, dymension, rollapp1) + require.NoError(t, err) + rollappHeight, err := rollapp1.GetNode().Height(ctx) require.NoError(t, err) @@ -2033,6 +2109,12 @@ func TestEIBCFulfillment_ThirdParty_EVM(t *testing.T) { require.NoError(t, err) require.True(t, isFinalized) + _, err = dymension.GetNode().FinalizePacketsUntilHeight(ctx, dymensionUserAddr, rollapp1.GetChainID(), fmt.Sprint(rollappHeight)) + require.NoError(t, err) + + err = testutil.WaitForBlocks(ctx, 10, dymension, rollapp1) + require.NoError(t, err) + transferData = ibc.WalletData{ Address: dymensionUserAddr, Denom: gaia.Config().Denom, @@ -2085,6 +2167,9 @@ func TestEIBCFulfillment_ThirdParty_EVM(t *testing.T) { _, err = rollapp1.SendIBCTransfer(ctx, channsRollApp1[0].ChannelID, rollapp1UserAddr, transferData, options) require.NoError(t, err) + err = testutil.WaitForBlocks(ctx, 10, dymension, rollapp1) + require.NoError(t, err) + rollappHeight, err = rollapp1.GetNode().Height(ctx) require.NoError(t, err) @@ -2093,6 +2178,12 @@ func TestEIBCFulfillment_ThirdParty_EVM(t *testing.T) { require.NoError(t, err) require.True(t, isFinalized) + _, err = dymension.GetNode().FinalizePacketsUntilHeight(ctx, dymensionUserAddr, rollapp1.GetChainID(), fmt.Sprint(rollappHeight)) + require.NoError(t, err) + + err = testutil.WaitForBlocks(ctx, 10, dymension, rollapp1) + require.NoError(t, err) + // Minus 0.1% of transfer amount for bridge fee expBalance := transferData.Amount.Sub(transferData.Amount.Quo(math.NewInt(1000))) balance, err = dymension.GetBalance(ctx, marketMakerAddr, gaiaIBCDenom) @@ -2111,16 +2202,13 @@ func TestEIBCFulfillment_ThirdParty_EVM(t *testing.T) { _, err = rollapp1.SendIBCTransfer(ctx, channsRollApp1[0].ChannelID, rollapp1UserAddr, transferData, options) require.NoError(t, err) - rollappHeight, err = rollapp1.GetNode().Height(ctx) - require.NoError(t, err) - // get eIbc event - eibcEvents, err := getEIbcEventsWithinBlockRange(ctx, dymension, 30, false) + eibcEvents, err := getEIbcEventsWithinBlockRange(ctx, dymension, 10, false) require.NoError(t, err) - fmt.Println("Event:", eibcEvents[1]) + fmt.Println("Event:", eibcEvents[0]) // fulfill demand order - txhash, err := dymension.FullfillDemandOrder(ctx, eibcEvents[1].ID, marketMakerAddr, eibcFee) + txhash, err := dymension.FullfillDemandOrder(ctx, eibcEvents[0].OrderId, marketMakerAddr, eibcFee) require.NoError(t, err) fmt.Println(txhash) // eibcEvent := getEibcEventFromTx(t, dymension, txhash) @@ -2138,21 +2226,24 @@ func TestEIBCFulfillment_ThirdParty_EVM(t *testing.T) { fmt.Println("Balance of dymensionUserAddr after fulfilling the order:", balance) require.True(t, balance.Equal(transferAmountWithoutFee.Sub(bridgingFee)), fmt.Sprintf("Value mismatch. Expected %s, actual %s", transferAmountWithoutFee.Sub(bridgingFee), balance)) - // verify funds were deducted from market maker's wallet address - balance, err = dymension.GetBalance(ctx, marketMakerAddr, gaiaIBCDenom) + rollappHeight, err = rollapp1.GetNode().Height(ctx) require.NoError(t, err) - fmt.Println("Balance of marketMakerAddr after fulfilling the order:", balance) - expMmBalance := transferAmount.Sub((transferAmountWithoutFee)) - require.True(t, balance.Equal(expMmBalance), fmt.Sprintf("Value mismatch. Expected %s, actual %s", expMmBalance, balance)) // wait until packet finalization and verify funds + fee were added to market maker's wallet address isFinalized, err = dymension.WaitUntilRollappHeightIsFinalized(ctx, rollapp1.GetChainID(), rollappHeight, 300) require.NoError(t, err) require.True(t, isFinalized) + + _, err = dymension.GetNode().FinalizePacketsUntilHeight(ctx, dymensionUserAddr, rollapp1.GetChainID(), fmt.Sprint(rollappHeight)) + require.NoError(t, err) + + err = testutil.WaitForBlocks(ctx, 10, dymension, rollapp1) + require.NoError(t, err) + balance, err = dymension.GetBalance(ctx, marketMakerAddr, gaiaIBCDenom) require.NoError(t, err) fmt.Println("Balance of marketMakerAddr after packet finalization:", balance) - expMmBalance = expMmBalance.Add(transferData.Amount).Sub(bridgingFee) + expMmBalance := transferAmount.Add(eibcFee).Sub(bridgingFee) require.True(t, balance.Equal(expMmBalance), fmt.Sprintf("Value mismatch. Expected %s, actual %s", expMmBalance, balance)) t.Cleanup( @@ -2173,6 +2264,8 @@ func TestEIBCFulfillment_ThirdParty_EVM(t *testing.T) { } }, ) + // Run invariant check + CheckInvariant(t, ctx, dymension, dymensionUser.KeyName()) } // This test case verifies the system's behavior when an eIBC packet sent from the rollapp to the hub @@ -2191,22 +2284,14 @@ func TestEIBCFulfillment_ThirdParty_Wasm(t *testing.T) { gas_price_rollapp1 := "0adym" maxIdleTime1 := "10s" maxProofTime := "500ms" - configFileOverrides1 := overridesDymintToml(settlement_layer_rollapp1, settlement_node_address, rollapp1_id, gas_price_rollapp1, maxIdleTime1, maxProofTime, "100s") + configFileOverrides1 := overridesDymintToml(settlement_layer_rollapp1, settlement_node_address, rollapp1_id, gas_price_rollapp1, maxIdleTime1, maxProofTime, "50s") // setup config for rollapp 2 settlement_layer_rollapp2 := "dymension" rollapp2_id := "decentrio_12345-1" gas_price_rollapp2 := "0adym" maxIdleTime2 := "1s" - configFileOverrides2 := overridesDymintToml(settlement_layer_rollapp2, settlement_node_address, rollapp2_id, gas_price_rollapp2, maxIdleTime2, maxProofTime, "100s") - - modifyGenesisKV := append( - dymensionGenesisKV, - cosmos.GenesisKV{ - Key: "app_state.rollapp.params.dispute_period_in_blocks", - Value: fmt.Sprint(BLOCK_FINALITY_PERIOD), - }, - ) + configFileOverrides2 := overridesDymintToml(settlement_layer_rollapp2, settlement_node_address, rollapp2_id, gas_price_rollapp2, maxIdleTime2, maxProofTime, "50s") // Create chain factory with dymension numHubVals := 1 @@ -2276,7 +2361,7 @@ func TestEIBCFulfillment_ThirdParty_Wasm(t *testing.T) { GasAdjustment: 1.1, TrustingPeriod: "112h", NoHostMount: false, - ModifyGenesis: modifyDymensionGenesis(modifyGenesisKV), + ModifyGenesis: modifyDymensionGenesis(dymensionGenesisKV), ConfigFileOverrides: nil, }, NumValidators: &numHubVals, @@ -2353,7 +2438,7 @@ func TestEIBCFulfillment_ThirdParty_Wasm(t *testing.T) { // This can be used to write to the block database which will index all block data e.g. txs, msgs, events, etc. // BlockDatabaseFile: test.DefaultBlockDatabaseFilepath(), - }, nil, "", nil) + }, nil, "", nil, false, 780) require.NoError(t, err) CreateChannel(ctx, t, r1, eRep, dymension.CosmosChain, rollapp1.CosmosChain, ibcPath) @@ -2427,6 +2512,9 @@ func TestEIBCFulfillment_ThirdParty_Wasm(t *testing.T) { _, err = rollapp1.SendIBCTransfer(ctx, channsRollApp1[0].ChannelID, rollapp1UserAddr, transferData, ibc.TransferOptions{}) require.NoError(t, err) + err = testutil.WaitForBlocks(ctx, 10, dymension, rollapp1) + require.NoError(t, err) + rollappHeight, err := rollapp1.GetNode().Height(ctx) require.NoError(t, err) @@ -2435,6 +2523,12 @@ func TestEIBCFulfillment_ThirdParty_Wasm(t *testing.T) { require.NoError(t, err) require.True(t, isFinalized) + _, err = dymension.GetNode().FinalizePacketsUntilHeight(ctx, dymensionUserAddr, rollapp1.GetChainID(), fmt.Sprint(rollappHeight)) + require.NoError(t, err) + + err = testutil.WaitForBlocks(ctx, 10, dymension, rollapp1) + require.NoError(t, err) + transferData = ibc.WalletData{ Address: dymensionUserAddr, Denom: gaia.Config().Denom, @@ -2487,6 +2581,9 @@ func TestEIBCFulfillment_ThirdParty_Wasm(t *testing.T) { _, err = rollapp1.SendIBCTransfer(ctx, channsRollApp1[0].ChannelID, rollapp1UserAddr, transferData, options) require.NoError(t, err) + err = testutil.WaitForBlocks(ctx, 10, dymension, rollapp1) + require.NoError(t, err) + rollappHeight, err = rollapp1.GetNode().Height(ctx) require.NoError(t, err) @@ -2495,6 +2592,12 @@ func TestEIBCFulfillment_ThirdParty_Wasm(t *testing.T) { require.NoError(t, err) require.True(t, isFinalized) + _, err = dymension.GetNode().FinalizePacketsUntilHeight(ctx, dymensionUserAddr, rollapp1.GetChainID(), fmt.Sprint(rollappHeight)) + require.NoError(t, err) + + err = testutil.WaitForBlocks(ctx, 10, dymension, rollapp1) + require.NoError(t, err) + balance, err = dymension.GetBalance(ctx, marketMakerAddr, gaiaIBCDenom) require.NoError(t, err) @@ -2514,16 +2617,13 @@ func TestEIBCFulfillment_ThirdParty_Wasm(t *testing.T) { _, err = rollapp1.SendIBCTransfer(ctx, channsRollApp1[0].ChannelID, rollapp1UserAddr, transferData, options) require.NoError(t, err) - rollappHeight, err = rollapp1.GetNode().Height(ctx) - require.NoError(t, err) - // get eIbc event - eibcEvents, err := getEIbcEventsWithinBlockRange(ctx, dymension, 30, false) + eibcEvents, err := getEIbcEventsWithinBlockRange(ctx, dymension, 10, false) require.NoError(t, err) - fmt.Println("Event:", eibcEvents[1]) + fmt.Println("Event:", eibcEvents[0]) // fulfill demand order - txhash, err := dymension.FullfillDemandOrder(ctx, eibcEvents[1].ID, marketMakerAddr, eibcFee) + txhash, err := dymension.FullfillDemandOrder(ctx, eibcEvents[0].OrderId, marketMakerAddr, eibcFee) require.NoError(t, err) fmt.Println(txhash) // eibcEvent := getEibcEventFromTx(t, dymension, txhash) @@ -2541,21 +2641,21 @@ func TestEIBCFulfillment_ThirdParty_Wasm(t *testing.T) { fmt.Println("Balance of dymensionUserAddr after fulfilling the order:", balance) require.True(t, balance.Equal(transferAmountWithoutFee.Sub(bridgingFee)), fmt.Sprintf("Value mismatch. Expected %s, actual %s", transferAmountWithoutFee.Sub(bridgingFee), balance)) - // verify funds were deducted from market maker's wallet address - balance, err = dymension.GetBalance(ctx, marketMakerAddr, gaiaIBCDenom) + // wait until packet finalization and verify funds + fee were added to market maker's wallet address + rollappHeight, err = rollapp1.GetNode().Height(ctx) require.NoError(t, err) - fmt.Println("Balance of marketMakerAddr after fulfilling the order:", balance) - expMmBalance := transferAmount.Sub((transferAmountWithoutFee)) - require.True(t, balance.Equal(expMmBalance), fmt.Sprintf("Value mismatch. Expected %s, actual %s", expMmBalance, balance)) - // wait until packet finalization and verify funds + fee were added to market maker's wallet address isFinalized, err = dymension.WaitUntilRollappHeightIsFinalized(ctx, rollapp1.GetChainID(), rollappHeight, 300) require.NoError(t, err) require.True(t, isFinalized) + + _, err = dymension.GetNode().FinalizePacketsUntilHeight(ctx, dymensionUserAddr, rollapp1.GetChainID(), fmt.Sprint(rollappHeight)) + require.NoError(t, err) + balance, err = dymension.GetBalance(ctx, marketMakerAddr, gaiaIBCDenom) require.NoError(t, err) fmt.Println("Balance of marketMakerAddr after packet finalization:", balance) - expMmBalance = expMmBalance.Add(transferData.Amount).Sub(bridgingFee) + expMmBalance := transferAmount.Add(eibcFee).Sub(bridgingFee) require.True(t, balance.Equal(expMmBalance), fmt.Sprintf("Value mismatch. Expected %s, actual %s", expMmBalance, balance)) t.Cleanup( @@ -2576,6 +2676,8 @@ func TestEIBCFulfillment_ThirdParty_Wasm(t *testing.T) { } }, ) + // Run invariant check + CheckInvariant(t, ctx, dymension, dymensionUser.KeyName()) } func TestEIBCFulfillment_ignore_hub_to_RA_EVM(t *testing.T) { @@ -2592,22 +2694,14 @@ func TestEIBCFulfillment_ignore_hub_to_RA_EVM(t *testing.T) { gas_price_rollapp1 := "0adym" maxIdleTime1 := "10s" maxProofTime := "500ms" - configFileOverrides1 := overridesDymintToml(settlement_layer_rollapp1, settlement_node_address, rollapp1_id, gas_price_rollapp1, maxIdleTime1, maxProofTime, "100s") + configFileOverrides1 := overridesDymintToml(settlement_layer_rollapp1, settlement_node_address, rollapp1_id, gas_price_rollapp1, maxIdleTime1, maxProofTime, "50s") // setup config for rollapp 2 settlement_layer_rollapp2 := "dymension" rollapp2_id := "decentrio_12345-1" gas_price_rollapp2 := "0adym" maxIdleTime2 := "1s" - configFileOverrides2 := overridesDymintToml(settlement_layer_rollapp2, settlement_node_address, rollapp2_id, gas_price_rollapp2, maxIdleTime2, maxProofTime, "100s") - - modifyGenesisKV := append( - dymensionGenesisKV, - cosmos.GenesisKV{ - Key: "app_state.rollapp.params.dispute_period_in_blocks", - Value: fmt.Sprint(BLOCK_FINALITY_PERIOD), - }, - ) + configFileOverrides2 := overridesDymintToml(settlement_layer_rollapp2, settlement_node_address, rollapp2_id, gas_price_rollapp2, maxIdleTime2, maxProofTime, "50s") // Create chain factory with dymension numHubVals := 1 @@ -2675,7 +2769,7 @@ func TestEIBCFulfillment_ignore_hub_to_RA_EVM(t *testing.T) { GasAdjustment: 1.1, TrustingPeriod: "112h", NoHostMount: false, - ModifyGenesis: modifyDymensionGenesis(modifyGenesisKV), + ModifyGenesis: modifyDymensionGenesis(dymensionGenesisKV), ConfigFileOverrides: nil, }, NumValidators: &numHubVals, @@ -2731,7 +2825,7 @@ func TestEIBCFulfillment_ignore_hub_to_RA_EVM(t *testing.T) { SkipPathCreation: true, // This can be used to write to the block database which will index all block data e.g. txs, msgs, events, etc. - }, nil, "", nil) + }, nil, "", nil, false, 780) require.NoError(t, err) CreateChannel(ctx, t, r1, eRep, dymension.CosmosChain, rollapp1.CosmosChain, ibcPath) @@ -2792,6 +2886,9 @@ func TestEIBCFulfillment_ignore_hub_to_RA_EVM(t *testing.T) { _, err = rollapp1.SendIBCTransfer(ctx, dymChannel_ra1[0].ChannelID, rollappUserAddr, transferData, ibc.TransferOptions{}) require.NoError(t, err) + err = testutil.WaitForBlocks(ctx, 10, dymension, rollapp1) + require.NoError(t, err) + rollappHeight, err := rollapp1.GetNode().Height(ctx) require.NoError(t, err) @@ -2800,6 +2897,12 @@ func TestEIBCFulfillment_ignore_hub_to_RA_EVM(t *testing.T) { require.NoError(t, err) require.True(t, isFinalized) + _, err = dymension.GetNode().FinalizePacketsUntilHeight(ctx, dymensionUserAddr, rollapp1.GetChainID(), fmt.Sprint(rollappHeight)) + require.NoError(t, err) + + err = testutil.WaitForBlocks(ctx, 10, dymension, rollapp1) + require.NoError(t, err) + transferDataRollapp1 := ibc.WalletData{ Address: rollappUserAddr, Denom: dymension.Config().Denom, @@ -2815,7 +2918,7 @@ func TestEIBCFulfillment_ignore_hub_to_RA_EVM(t *testing.T) { require.NoError(t, err) // get eIbc event - _, err = getEIbcEventsWithinBlockRange(ctx, dymension, 10, false) + _, err = getEIbcEventsWithinBlockRange(ctx, dymension, 30, false) // expect no eibc events created as ibc transfer from hub to rollapp is ignored require.Error(t, err, "There wasn't a single 'eibc' event registered within the specified block range on the hub") @@ -2831,6 +2934,8 @@ func TestEIBCFulfillment_ignore_hub_to_RA_EVM(t *testing.T) { } }, ) + // Run invariant check + CheckInvariant(t, ctx, dymension, dymensionUser.KeyName()) } func TestEIBCFulfillment_ignore_hub_to_RA_Wasm(t *testing.T) { @@ -2847,21 +2952,14 @@ func TestEIBCFulfillment_ignore_hub_to_RA_Wasm(t *testing.T) { gas_price_rollapp1 := "0adym" maxIdleTime1 := "10s" maxProofTime := "500ms" - configFileOverrides1 := overridesDymintToml(settlement_layer_rollapp1, settlement_node_address, rollapp1_id, gas_price_rollapp1, maxIdleTime1, maxProofTime, "100s") + configFileOverrides1 := overridesDymintToml(settlement_layer_rollapp1, settlement_node_address, rollapp1_id, gas_price_rollapp1, maxIdleTime1, maxProofTime, "50s") // setup config for rollapp 2 settlement_layer_rollapp2 := "dymension" rollapp2_id := "decentrio_12345-1" gas_price_rollapp2 := "0adym" maxIdleTime2 := "1s" - configFileOverrides2 := overridesDymintToml(settlement_layer_rollapp2, settlement_node_address, rollapp2_id, gas_price_rollapp2, maxIdleTime2, maxProofTime, "100s") - modifyGenesisKV := append( - dymensionGenesisKV, - cosmos.GenesisKV{ - Key: "app_state.rollapp.params.dispute_period_in_blocks", - Value: fmt.Sprint(BLOCK_FINALITY_PERIOD), - }, - ) + configFileOverrides2 := overridesDymintToml(settlement_layer_rollapp2, settlement_node_address, rollapp2_id, gas_price_rollapp2, maxIdleTime2, maxProofTime, "50s") // Create chain factory with dymension numHubVals := 1 @@ -2929,7 +3027,7 @@ func TestEIBCFulfillment_ignore_hub_to_RA_Wasm(t *testing.T) { GasAdjustment: 1.1, TrustingPeriod: "112h", NoHostMount: false, - ModifyGenesis: modifyDymensionGenesis(modifyGenesisKV), + ModifyGenesis: modifyDymensionGenesis(dymensionGenesisKV), ConfigFileOverrides: nil, }, NumValidators: &numHubVals, @@ -2986,7 +3084,7 @@ func TestEIBCFulfillment_ignore_hub_to_RA_Wasm(t *testing.T) { // This can be used to write to the block database which will index all block data e.g. txs, msgs, events, etc. // BlockDatabaseFile: test.DefaultBlockDatabaseFilepath(), - }, nil, "", nil) + }, nil, "", nil, false, 780) require.NoError(t, err) CreateChannel(ctx, t, r1, eRep, dymension.CosmosChain, rollapp1.CosmosChain, ibcPath) @@ -3045,6 +3143,9 @@ func TestEIBCFulfillment_ignore_hub_to_RA_Wasm(t *testing.T) { _, err = rollapp1.SendIBCTransfer(ctx, dymChannel_ra1[0].ChannelID, rollappUserAddr, transferData, ibc.TransferOptions{}) require.NoError(t, err) + err = testutil.WaitForBlocks(ctx, 10, dymension, rollapp1) + require.NoError(t, err) + rollappHeight, err := rollapp1.GetNode().Height(ctx) require.NoError(t, err) @@ -3054,6 +3155,9 @@ func TestEIBCFulfillment_ignore_hub_to_RA_Wasm(t *testing.T) { require.True(t, isFinalized) // end of preconditions + _, err = dymension.GetNode().FinalizePacketsUntilHeight(ctx, dymensionUserAddr, rollapp1.GetChainID(), fmt.Sprint(rollappHeight)) + require.NoError(t, err) + err = testutil.WaitForBlocks(ctx, 10, dymension, rollapp1) require.NoError(t, err) @@ -3072,7 +3176,7 @@ func TestEIBCFulfillment_ignore_hub_to_RA_Wasm(t *testing.T) { require.NoError(t, err) // get eIbc event - _, err = getEIbcEventsWithinBlockRange(ctx, dymension, 10, false) + _, err = getEIbcEventsWithinBlockRange(ctx, dymension, 30, false) // expect no eibc events created as ibc transfer from hub to rollapp is ignored require.Error(t, err, "There wasn't a single 'eibc' event registered within the specified block range on the hub") @@ -3088,110 +3192,7 @@ func TestEIBCFulfillment_ignore_hub_to_RA_Wasm(t *testing.T) { } }, ) -} - -func getEibcEventFromTx(t *testing.T, dymension *dym_hub.DymHub, txhash string) *dymensiontesting.EibcEvent { - txResp, err := dymension.GetTransaction(txhash) - if err != nil { - require.NoError(t, err) - return nil - } - - const evType = "eibc" - events := txResp.Events - - var ( - id, _ = cosmos.AttributeValue(events, evType, "id") - price, _ = cosmos.AttributeValue(events, evType, "price") - fee, _ = cosmos.AttributeValue(events, evType, "fee") - isFulfilled, _ = cosmos.AttributeValue(events, evType, "is_fulfilled") - packetStatus, _ = cosmos.AttributeValue(events, evType, "packet_status") - ) - - eibcEvent := new(dymensiontesting.EibcEvent) - eibcEvent.ID = id - eibcEvent.Price = price - eibcEvent.Fee = fee - println("check datra is fulfilled: ", isFulfilled) - eibcEvent.IsFulfilled, err = strconv.ParseBool(isFulfilled) - if err != nil { - require.NoError(t, err) - return nil - } - eibcEvent.PacketStatus = packetStatus - - return eibcEvent -} - -func getEIbcEventsWithinBlockRange( - ctx context.Context, - dymension *dym_hub.DymHub, - blockRange int64, - breakOnFirstOccurence bool, -) ([]dymensiontesting.EibcEvent, error) { - var eibcEventsArray []dymensiontesting.EibcEvent - - height, err := dymension.Height(ctx) - if err != nil { - return nil, fmt.Errorf("failed to get Dymension height: %w", err) - } - fmt.Printf("Dymension height: %d\n", height) - - err = testutil.WaitForBlocks(ctx, int(blockRange), dymension) - if err != nil { - return nil, fmt.Errorf("error waiting for blocks: %w", err) - } - - eibcEvents, err := getEventsOfType(dymension.CosmosChain, height-5, height+blockRange, "eibc", breakOnFirstOccurence) - if err != nil { - return nil, fmt.Errorf("error getting events of type 'eibc': %w", err) - } - - if len(eibcEvents) == 0 { - return nil, fmt.Errorf("There wasn't a single 'eibc' event registered within the specified block range on the hub") - } - - for _, event := range eibcEvents { - eibcEvent, err := dymensiontesting.MapToEibcEvent(event) - if err != nil { - return nil, fmt.Errorf("error mapping to EibcEvent: %w", err) - } - eibcEventsArray = append(eibcEventsArray, eibcEvent) - } - - return eibcEventsArray, nil -} - -func getEventsOfType(chain *cosmos.CosmosChain, startHeight int64, endHeight int64, eventType string, breakOnFirstOccurence bool) ([]blockdb.Event, error) { - var eventTypeArray []blockdb.Event - shouldReturn := false - - for height := startHeight; height <= endHeight && !shouldReturn; height++ { - txs, err := chain.FindTxs(context.Background(), height) - if err != nil { - return nil, fmt.Errorf("error fetching transactions at height %d: %w", height, err) - } - - for _, tx := range txs { - for _, event := range tx.Events { - if event.Type == eventType { - eventTypeArray = append(eventTypeArray, event) - if breakOnFirstOccurence { - shouldReturn = true - fmt.Printf("%s event found on block height: %d", eventType, height) - break - } - } - } - if shouldReturn { - break - } - } - } - - return eventTypeArray, nil -} -func BuildEIbcMemo(eibcFee math.Int) string { - return fmt.Sprintf(`{"eibc": {"fee": "%s"}}`, eibcFee.String()) + // Run invariant check + CheckInvariant(t, ctx, dymension, dymensionUser.KeyName()) } diff --git a/tests/eibc_invariant_test.go b/tests/eibc_invariant_test.go index 1e591860..f53c1837 100644 --- a/tests/eibc_invariant_test.go +++ b/tests/eibc_invariant_test.go @@ -34,22 +34,11 @@ func TestEIBCInvariant_EVM(t *testing.T) { gas_price_rollapp1 := "0adym" maxIdleTime1 := "10s" maxProofTime := "500ms" - configFileOverrides1 := overridesDymintToml(settlement_layer_rollapp1, settlement_node_address, rollapp1_id, gas_price_rollapp1, maxIdleTime1, maxProofTime, "100s") - - // setup config for rollapp 2 - settlement_layer_rollapp2 := "dymension" - rollapp2_id := "decentrio_12345-1" - gas_price_rollapp2 := "0adym" - maxIdleTime2 := "1s" - configFileOverrides2 := overridesDymintToml(settlement_layer_rollapp2, settlement_node_address, rollapp2_id, gas_price_rollapp2, maxIdleTime2, maxProofTime, "100s") + configFileOverrides1 := overridesDymintToml(settlement_layer_rollapp1, settlement_node_address, rollapp1_id, gas_price_rollapp1, maxIdleTime1, maxProofTime, "50s") const EPOCH_IDENTIFIER string = "minute" modifyGenesisKV := append( dymensionGenesisKV, - cosmos.GenesisKV{ - Key: "app_state.rollapp.params.dispute_period_in_blocks", - Value: fmt.Sprint(BLOCK_FINALITY_PERIOD), - }, cosmos.GenesisKV{ Key: "app_state.delayedack.params.epoch_identifier", Value: EPOCH_IDENTIFIER, @@ -84,28 +73,6 @@ func TestEIBCInvariant_EVM(t *testing.T) { NumValidators: &numRollAppVals, NumFullNodes: &numRollAppFn, }, - { - Name: "rollapp2", - ChainConfig: ibc.ChainConfig{ - Type: "rollapp-dym", - Name: "rollapp-temp2", - ChainID: "decentrio_12345-1", - Images: []ibc.DockerImage{rollappEVMImage}, - Bin: "rollappd", - Bech32Prefix: "ethm", - Denom: "urax", - CoinType: "60", - GasPrices: "0.0urax", - GasAdjustment: 1.1, - TrustingPeriod: "112h", - EncodingConfig: encodingConfig(), - NoHostMount: false, - ModifyGenesis: modifyRollappEVMGenesis(rollappEVMGenesisKV), - ConfigFileOverrides: configFileOverrides2, - }, - NumValidators: &numRollAppVals, - NumFullNodes: &numRollAppFn, - }, { Name: "dymension-hub", ChainConfig: ibc.ChainConfig{ @@ -135,8 +102,7 @@ func TestEIBCInvariant_EVM(t *testing.T) { require.NoError(t, err) rollapp1 := chains[0].(*dym_rollapp.DymRollApp) - rollapp2 := chains[1].(*dym_rollapp.DymRollApp) - dymension := chains[2].(*dym_hub.DymHub) + dymension := chains[1].(*dym_hub.DymHub) // Relayer Factory client, network := test.DockerSetup(t) @@ -144,26 +110,15 @@ func TestEIBCInvariant_EVM(t *testing.T) { r1 := test.NewBuiltinRelayerFactory(ibc.CosmosRly, zaptest.NewLogger(t), relayer.CustomDockerImage(RelayerMainRepo, relayerVersion, "100:1000"), relayer.ImagePull(pullRelayerImage), ).Build(t, client, "relayer1", network) - // relayer for rollapp 2 - r2 := test.NewBuiltinRelayerFactory(ibc.CosmosRly, zaptest.NewLogger(t), - relayer.CustomDockerImage(RelayerMainRepo, relayerVersion, "100:1000"), relayer.ImagePull(pullRelayerImage), - ).Build(t, client, "relayer2", network) ic := test.NewSetup(). - AddRollUp(dymension, rollapp1, rollapp2). + AddRollUp(dymension, rollapp1). AddRelayer(r1, "relayer1"). - AddRelayer(r2, "relayer2"). AddLink(test.InterchainLink{ Chain1: dymension, Chain2: rollapp1, Relayer: r1, Path: ibcPath, - }). - AddLink(test.InterchainLink{ - Chain1: dymension, - Chain2: rollapp2, - Relayer: r2, - Path: anotherIbcPath, }) rep := testreporter.NewNopReporter() @@ -177,32 +132,29 @@ func TestEIBCInvariant_EVM(t *testing.T) { // This can be used to write to the block database which will index all block data e.g. txs, msgs, events, etc. // BlockDatabaseFile: test.DefaultBlockDatabaseFilepath(), - }, nil, "", nil) + }, nil, "", nil, false, 780) require.NoError(t, err) CreateChannel(ctx, t, r1, eRep, dymension.CosmosChain, rollapp1.CosmosChain, ibcPath) - CreateChannel(ctx, t, r2, eRep, dymension.CosmosChain, rollapp2.CosmosChain, anotherIbcPath) // Create some user accounts on both chains - users := test.GetAndFundTestUsers(t, ctx, t.Name(), walletAmount, dymension, dymension, rollapp1, rollapp2) + users := test.GetAndFundTestUsers(t, ctx, t.Name(), walletAmount, dymension, dymension, rollapp1) // Wait a few blocks for relayer to start and for user accounts to be created err = testutil.WaitForBlocks(ctx, 5, dymension, rollapp1) require.NoError(t, err) // Get our Bech32 encoded user addresses - dymensionUser, marketMaker, rollappUser, rollapp2User := users[0], users[1], users[2], users[3] + dymensionUser, marketMaker, rollappUser := users[0], users[1], users[2] dymensionUserAddr := dymensionUser.FormattedAddress() marketMakerAddr := marketMaker.FormattedAddress() rollappUserAddr := rollappUser.FormattedAddress() - rollapp2UserAddr := rollapp2User.FormattedAddress() // Assert the accounts were funded testutil.AssertBalance(t, ctx, dymension, dymensionUserAddr, dymension.Config().Denom, walletAmount) testutil.AssertBalance(t, ctx, dymension, marketMakerAddr, dymension.Config().Denom, walletAmount) testutil.AssertBalance(t, ctx, rollapp1, rollappUserAddr, rollapp1.Config().Denom, walletAmount) - testutil.AssertBalance(t, ctx, rollapp2, rollapp2UserAddr, rollapp2.Config().Denom, walletAmount) multiplier := math.NewInt(10) @@ -212,25 +164,15 @@ func TestEIBCInvariant_EVM(t *testing.T) { dymChannels, err := r1.GetChannels(ctx, eRep, dymension.Config().ChainID) require.NoError(t, err) - dymRA2Channels, err := r2.GetChannels(ctx, eRep, dymension.Config().ChainID) - require.NoError(t, err) - channsRollApp1, err := r1.GetChannels(ctx, eRep, rollapp1.GetChainID()) require.NoError(t, err) - channsRollApp2, err := r2.GetChannels(ctx, eRep, rollapp2.GetChainID()) - require.NoError(t, err) - require.Len(t, channsRollApp1, 1) - require.Len(t, channsRollApp2, 1) - require.Len(t, dymChannels, 2) - require.Len(t, dymRA2Channels, 2) + require.Len(t, dymChannels, 1) // Start relayer err = r1.StartRelayer(ctx, eRep, ibcPath) require.NoError(t, err) - err = r2.StartRelayer(ctx, eRep, anotherIbcPath) - require.NoError(t, err) err = testutil.WaitForBlocks(ctx, 5, dymension, rollapp1) require.NoError(t, err) @@ -256,6 +198,10 @@ func TestEIBCInvariant_EVM(t *testing.T) { // this `normal`` transfer also enable ibc transfer _, err = rollapp1.SendIBCTransfer(ctx, channsRollApp1[0].ChannelID, rollappUserAddr, transferData, options) require.NoError(t, err) + + err = testutil.WaitForBlocks(ctx, 10, dymension, rollapp1) + require.NoError(t, err) + rollappHeight, err := rollapp1.GetNode().Height(ctx) require.NoError(t, err) @@ -264,6 +210,12 @@ func TestEIBCInvariant_EVM(t *testing.T) { require.NoError(t, err) require.True(t, isFinalized) + _, err = dymension.GetNode().FinalizePacketsUntilHeight(ctx, dymensionUserAddr, rollapp1.GetChainID(), fmt.Sprint(rollappHeight)) + require.NoError(t, err) + + err = testutil.WaitForBlocks(ctx, 30, dymension) + require.NoError(t, err) + // Minus 0.1% of transfer amount for bridge fee expMmBalanceRollappDenom := transferData.Amount.Sub(transferData.Amount.Quo(math.NewInt(1000))) balance, err := dymension.GetBalance(ctx, marketMakerAddr, rollappIBCDenom) @@ -287,32 +239,31 @@ func TestEIBCInvariant_EVM(t *testing.T) { require.NoError(t, err) } - rollappHeight, err = rollapp1.GetNode().Height(ctx) - require.NoError(t, err) - balance, err = dymension.GetBalance(ctx, dymensionUserAddr, rollappIBCDenom) require.NoError(t, err) fmt.Println("Balance of dymensionUserAddr right after sending eIBC transfer:", balance) require.True(t, balance.Equal(zeroBal), fmt.Sprintf("Value mismatch. Expected %s, actual %s", zeroBal, balance)) // get eIbc event - eibcEvents, err := getEIbcEventsWithinBlockRange(ctx, dymension, 30, false) + eibcEvents, err := getEIbcEventsWithinBlockRange(ctx, dymension, 10, false) require.NoError(t, err) // fulfill 2 demand order - _, err = dymension.FullfillDemandOrder(ctx, eibcEvents[1].ID, marketMakerAddr, eibcFee) + tx, err := dymension.FullfillDemandOrder(ctx, eibcEvents[1].OrderId, marketMakerAddr, eibcFee) require.NoError(t, err) // eibcEvent := getEibcEventFromTx(t, dymension, txhash) // if eibcEvent != nil { // fmt.Println("After order fulfillment:", eibcEvent) // } + fmt.Println(tx) - _, err = dymension.FullfillDemandOrder(ctx, eibcEvents[2].ID, marketMakerAddr, eibcFee) + tx, err = dymension.FullfillDemandOrder(ctx, eibcEvents[2].OrderId, marketMakerAddr, eibcFee) require.NoError(t, err) // eibcEvent = getEibcEventFromTx(t, dymension, txhash) // if eibcEvent != nil { // fmt.Println("After order fulfillment:", eibcEvent) // } + fmt.Println(tx) for i, e := range eibcEvents { fmt.Println("Event", i, ":", e) @@ -333,10 +284,21 @@ func TestEIBCInvariant_EVM(t *testing.T) { fmt.Println("Balance of marketMakerAddr after fulfilling the order:", balance) expMmBalanceRollappDenom = expMmBalanceRollappDenom.Sub(transferAmountWithoutFee.MulRaw(2)).Add(bridgingFee.MulRaw(2)) require.True(t, balance.Equal(expMmBalanceRollappDenom), fmt.Sprintf("Value mismatch. Expected %s, actual %s", expMmBalanceRollappDenom, balance)) + // wait until packet finalization and verify funds + fee were added to market maker's wallet address + rollappHeight, err = rollapp1.GetNode().Height(ctx) + require.NoError(t, err) + isFinalized, err = dymension.WaitUntilRollappHeightIsFinalized(ctx, rollapp1.GetChainID(), rollappHeight, 300) require.NoError(t, err) require.True(t, isFinalized) + + _, err = dymension.GetNode().FinalizePacketsUntilHeight(ctx, dymensionUserAddr, rollapp1.GetChainID(), fmt.Sprint(rollappHeight)) + require.NoError(t, err) + + err = testutil.WaitForBlocks(ctx, 10, dymension, rollapp1) + require.NoError(t, err) + balance, err = dymension.GetBalance(ctx, marketMakerAddr, rollappIBCDenom) require.NoError(t, err) fmt.Println("Balance of marketMakerAddr after packet finalization:", balance) @@ -386,26 +348,26 @@ func TestEIBCInvariant_Wasm(t *testing.T) { gas_price_rollapp1 := "0adym" maxIdleTime1 := "10s" maxProofTime := "500ms" - configFileOverrides1 := overridesDymintToml(settlement_layer_rollapp1, settlement_node_address, rollapp1_id, gas_price_rollapp1, maxIdleTime1, maxProofTime, "100s") + configFileOverrides1 := overridesDymintToml(settlement_layer_rollapp1, settlement_node_address, rollapp1_id, gas_price_rollapp1, maxIdleTime1, maxProofTime, "50s") // setup config for rollapp 2 settlement_layer_rollapp2 := "dymension" rollapp2_id := "decentrio_12345-1" gas_price_rollapp2 := "0adym" maxIdleTime2 := "1s" - configFileOverrides2 := overridesDymintToml(settlement_layer_rollapp2, settlement_node_address, rollapp2_id, gas_price_rollapp2, maxIdleTime2, maxProofTime, "100s") + configFileOverrides2 := overridesDymintToml(settlement_layer_rollapp2, settlement_node_address, rollapp2_id, gas_price_rollapp2, maxIdleTime2, maxProofTime, "50s") const EPOCH_IDENTIFIER string = "minute" modifyGenesisKV := append( dymensionGenesisKV, - cosmos.GenesisKV{ - Key: "app_state.rollapp.params.dispute_period_in_blocks", - Value: fmt.Sprint(BLOCK_FINALITY_PERIOD), - }, cosmos.GenesisKV{ Key: "app_state.delayedack.params.epoch_identifier", Value: EPOCH_IDENTIFIER, }, + cosmos.GenesisKV{ + Key: "app_state.rollapp.params.dispute_period_in_blocks", + Value: fmt.Sprint(100), + }, ) // Create chain factory with dymension @@ -529,7 +491,7 @@ func TestEIBCInvariant_Wasm(t *testing.T) { // This can be used to write to the block database which will index all block data e.g. txs, msgs, events, etc. // BlockDatabaseFile: test.DefaultBlockDatabaseFilepath(), - }, nil, "", nil) + }, nil, "", nil, false, 780) require.NoError(t, err) CreateChannel(ctx, t, r1, eRep, dymension.CosmosChain, rollapp1.CosmosChain, ibcPath) @@ -605,6 +567,10 @@ func TestEIBCInvariant_Wasm(t *testing.T) { // market maker needs to have funds on the hub first to be able to fulfill upcoming demand order _, err = rollapp1.SendIBCTransfer(ctx, channsRollApp1[0].ChannelID, rollappUserAddr, transferData, options) require.NoError(t, err) + + err = testutil.WaitForBlocks(ctx, 10, dymension, rollapp1) + require.NoError(t, err) + rollappHeight, err := rollapp1.GetNode().Height(ctx) require.NoError(t, err) @@ -613,6 +579,12 @@ func TestEIBCInvariant_Wasm(t *testing.T) { require.NoError(t, err) require.True(t, isFinalized) + _, err = dymension.GetNode().FinalizePacketsUntilHeight(ctx, dymensionUserAddr, rollapp1.GetChainID(), fmt.Sprint(rollappHeight)) + require.NoError(t, err) + + err = testutil.WaitForBlocks(ctx, 10, dymension, rollapp1) + require.NoError(t, err) + // Minus 0.1% of transfer amount for bridge fee expMmBalanceRollappDenom := transferData.Amount.Sub(bridgingFee.MulRaw(10)) balance, err := dymension.GetBalance(ctx, marketMakerAddr, rollappIBCDenom) @@ -636,26 +608,25 @@ func TestEIBCInvariant_Wasm(t *testing.T) { require.NoError(t, err) } - rollappHeight, err = rollapp1.GetNode().Height(ctx) - require.NoError(t, err) balance, err = dymension.GetBalance(ctx, dymensionUserAddr, rollappIBCDenom) require.NoError(t, err) fmt.Println("Balance of dymensionUserAddr right after sending eIBC transfer:", balance) require.True(t, balance.Equal(zeroBal), fmt.Sprintf("Value mismatch. Expected %s, actual %s", zeroBal, balance)) // get eIbc event - eibcEvents, err := getEIbcEventsWithinBlockRange(ctx, dymension, 30, false) + eibcEvents, err := getEIbcEventsWithinBlockRange(ctx, dymension, 10, false) require.NoError(t, err) + fmt.Println(eibcEvents) // fulfill 2 demand order - _, err = dymension.FullfillDemandOrder(ctx, eibcEvents[1].ID, marketMakerAddr, eibcFee) + _, err = dymension.FullfillDemandOrder(ctx, eibcEvents[1].OrderId, marketMakerAddr, eibcFee) require.NoError(t, err) // eibcEvent := getEibcEventFromTx(t, dymension, txhash) // if eibcEvent != nil { // fmt.Println("After order fulfillment:", eibcEvent) // } - _, err = dymension.FullfillDemandOrder(ctx, eibcEvents[2].ID, marketMakerAddr, eibcFee) + _, err = dymension.FullfillDemandOrder(ctx, eibcEvents[2].OrderId, marketMakerAddr, eibcFee) require.NoError(t, err) // eibcEvent = getEibcEventFromTx(t, dymension, txhash) // if eibcEvent != nil { @@ -671,21 +642,22 @@ func TestEIBCInvariant_Wasm(t *testing.T) { require.NoError(t, err) fmt.Println("Balance of dymensionUserAddr after fulfilling the order:", balance) require.True(t, balance.Equal(transferAmountWithoutFee.Sub(bridgingFee).Mul(math.NewInt(2))), fmt.Sprintf("Value mismatch. Expected %s, actual %s", transferAmountWithoutFee.Sub(bridgingFee).Mul(math.NewInt(2)), balance)) - // verify funds were deducted from market maker's wallet address - balance, err = dymension.GetBalance(ctx, marketMakerAddr, rollappIBCDenom) - require.NoError(t, err) - fmt.Println("Balance of marketMakerAddr after fulfilling the order:", balance) - expMmBalanceRollappDenom = expMmBalanceRollappDenom.Sub(transferAmountWithoutFee.MulRaw(2)).Add(bridgingFee.MulRaw(2)) - require.True(t, balance.Equal(expMmBalanceRollappDenom), fmt.Sprintf("Value mismatch. Expected %s, actual %s", expMmBalanceRollappDenom, balance)) + // wait until packet finalization and verify funds + fee were added to market maker's wallet address + rollappHeight, err = rollapp1.GetNode().Height(ctx) + require.NoError(t, err) + isFinalized, err = dymension.WaitUntilRollappHeightIsFinalized(ctx, rollapp1.GetChainID(), rollappHeight, 300) require.NoError(t, err) require.True(t, isFinalized) + + _, err = dymension.GetNode().FinalizePacketsUntilHeight(ctx, dymensionUserAddr, rollapp1.GetChainID(), fmt.Sprint(rollappHeight)) + require.NoError(t, err) + balance, err = dymension.GetBalance(ctx, marketMakerAddr, rollappIBCDenom) require.NoError(t, err) fmt.Println("Balance of marketMakerAddr after packet finalization:", balance) - expMmBalanceRollappDenom = expMmBalanceRollappDenom.Add(transferData.Amount.MulRaw(2)) - expMmBalanceRollappDenom = expMmBalanceRollappDenom.Sub(bridgingFee.MulRaw(2)) + expMmBalanceRollappDenom = expMmBalanceRollappDenom.Add(eibcFee.MulRaw(2)) require.True(t, balance.Equal(expMmBalanceRollappDenom), fmt.Sprintf("Value mismatch. Expected %s, actual %s", expMmBalanceRollappDenom, balance)) // Send 2 ibc transfer diff --git a/tests/eibc_nobalance_test.go b/tests/eibc_nobalance_test.go index 820cc932..0b6f818a 100644 --- a/tests/eibc_nobalance_test.go +++ b/tests/eibc_nobalance_test.go @@ -8,7 +8,6 @@ import ( "cosmossdk.io/math" transfertypes "github.com/cosmos/ibc-go/v7/modules/apps/transfer/types" test "github.com/decentrio/rollup-e2e-testing" - "github.com/decentrio/rollup-e2e-testing/cosmos" "github.com/decentrio/rollup-e2e-testing/cosmos/hub/dym_hub" "github.com/decentrio/rollup-e2e-testing/cosmos/rollapp/dym_rollapp" "github.com/decentrio/rollup-e2e-testing/ibc" @@ -38,18 +37,11 @@ func TestEIBCNoBalanceToFulfillOrder_EVM(t *testing.T) { dymintTomlOverrides["settlement_gas_prices"] = "0adym" dymintTomlOverrides["max_idle_time"] = "3s" dymintTomlOverrides["max_proof_time"] = "500ms" - dymintTomlOverrides["batch_submit_max_time"] = "100s" + dymintTomlOverrides["batch_submit_time"] = "50s" + dymintTomlOverrides["p2p_blocksync_enabled"] = "false" configFileOverrides["config/dymint.toml"] = dymintTomlOverrides - modifyGenesisKV := append( - dymensionGenesisKV, - cosmos.GenesisKV{ - Key: "app_state.rollapp.params.dispute_period_in_blocks", - Value: fmt.Sprint(BLOCK_FINALITY_PERIOD), - }, - ) - // Create chain factory with dymension numHubVals := 1 numHubFullNodes := 1 @@ -94,7 +86,7 @@ func TestEIBCNoBalanceToFulfillOrder_EVM(t *testing.T) { GasAdjustment: 1.1, TrustingPeriod: "112h", NoHostMount: false, - ModifyGenesis: modifyDymensionGenesis(modifyGenesisKV), + ModifyGenesis: modifyDymensionGenesis(dymensionGenesisKV), ConfigFileOverrides: nil, }, NumValidators: &numHubVals, @@ -136,7 +128,7 @@ func TestEIBCNoBalanceToFulfillOrder_EVM(t *testing.T) { // This can be used to write to the block database which will index all block data e.g. txs, msgs, events, etc. // BlockDatabaseFile: test.DefaultBlockDatabaseFilepath(), - }, nil, "", nil) + }, nil, "", nil, false, 780) require.NoError(t, err) CreateChannel(ctx, t, r, eRep, dymension.CosmosChain, rollapp1.CosmosChain, ibcPath) @@ -186,31 +178,34 @@ func TestEIBCNoBalanceToFulfillOrder_EVM(t *testing.T) { _, err = rollapp1.SendIBCTransfer(ctx, channel.Counterparty.ChannelID, rollappUserAddr, transferData, options) require.NoError(t, err) - rollappHeight, err := rollapp1.GetNode().Height(ctx) - require.NoError(t, err) - // verify funds balance right after sending the IBC transfer testutil.AssertBalance(t, ctx, dymension, dymensionUserAddr, rollappIBCDenom, zeroBal) testutil.AssertBalance(t, ctx, rollapp1, rollappUserAddr, rollapp1.Config().Denom, walletAmount.Sub(transferData.Amount)) // get eIbc event - eibcEvents, err := getEIbcEventsWithinBlockRange(ctx, dymension, 30, false) + eibcEvents, err := getEIbcEventsWithinBlockRange(ctx, dymension, 10, false) require.NoError(t, err) fmt.Println("Event:", eibcEvents[0]) // attempt to fulfill demand order without having required denom balance - txhash, err := dymension.FullfillDemandOrder(ctx, eibcEvents[0].ID, marketMakerAddr, eibcFee) + txhash, err := dymension.FullfillDemandOrder(ctx, eibcEvents[0].OrderId, marketMakerAddr, eibcFee) require.NoError(t, err) fmt.Println(txhash) txData, err := dymension.GetTransaction(txhash) require.NoError(t, err) require.Contains(t, txData.RawLog, "insufficient funds") // verify that the transaction failed + rollappHeight, err := rollapp1.GetNode().Height(ctx) + require.NoError(t, err) + // wait until packet finalization isFinalized, err := dymension.WaitUntilRollappHeightIsFinalized(ctx, rollapp1.GetChainID(), rollappHeight, 300) require.NoError(t, err) require.True(t, isFinalized) + _, err = dymension.GetNode().FinalizePacketsUntilHeight(ctx, dymensionUserAddr, rollapp1.GetChainID(), fmt.Sprint(rollappHeight)) + require.NoError(t, err) + // verify funds were transferred to dymensionUserAddr testutil.AssertBalance(t, ctx, dymension, marketMakerAddr, rollappIBCDenom, zeroBal) // Minus 0.1% of transfer amount for bridge fee @@ -224,4 +219,7 @@ func TestEIBCNoBalanceToFulfillOrder_EVM(t *testing.T) { } }, ) + + // Run invariant check + CheckInvariant(t, ctx, dymension, dymensionUser.KeyName()) } diff --git a/tests/eibc_not_fulfillment_test.go b/tests/eibc_not_fulfillment_test.go index efe68fa8..9144e1bd 100644 --- a/tests/eibc_not_fulfillment_test.go +++ b/tests/eibc_not_fulfillment_test.go @@ -11,7 +11,6 @@ import ( "go.uber.org/zap/zaptest" test "github.com/decentrio/rollup-e2e-testing" - "github.com/decentrio/rollup-e2e-testing/cosmos" "github.com/decentrio/rollup-e2e-testing/cosmos/hub/dym_hub" "github.com/decentrio/rollup-e2e-testing/cosmos/rollapp/dym_rollapp" "github.com/decentrio/rollup-e2e-testing/ibc" @@ -36,22 +35,14 @@ func TestEIBCNotFulfillment_EVM(t *testing.T) { gas_price_rollapp1 := "0adym" maxIdleTime1 := "3s" maxProofTime := "500ms" - configFileOverrides1 := overridesDymintToml(settlement_layer_rollapp1, settlement_node_address, rollapp1_id, gas_price_rollapp1, maxIdleTime1, maxProofTime, "100s") + configFileOverrides1 := overridesDymintToml(settlement_layer_rollapp1, settlement_node_address, rollapp1_id, gas_price_rollapp1, maxIdleTime1, maxProofTime, "50s") // setup config for rollapp 2 settlement_layer_rollapp2 := "dymension" rollapp2_id := "decentrio_12345-1" gas_price_rollapp2 := "0adym" maxIdleTime2 := "3s" - configFileOverrides2 := overridesDymintToml(settlement_layer_rollapp2, settlement_node_address, rollapp2_id, gas_price_rollapp2, maxIdleTime2, maxProofTime, "100s") - - modifyGenesisKV := append( - dymensionGenesisKV, - cosmos.GenesisKV{ - Key: "app_state.rollapp.params.dispute_period_in_blocks", - Value: fmt.Sprint(BLOCK_FINALITY_PERIOD), - }, - ) + configFileOverrides2 := overridesDymintToml(settlement_layer_rollapp2, settlement_node_address, rollapp2_id, gas_price_rollapp2, maxIdleTime2, maxProofTime, "50s") // Create chain factory with dymension numHubVals := 1 @@ -119,7 +110,7 @@ func TestEIBCNotFulfillment_EVM(t *testing.T) { GasAdjustment: 1.1, TrustingPeriod: "112h", NoHostMount: false, - ModifyGenesis: modifyDymensionGenesis(modifyGenesisKV), + ModifyGenesis: modifyDymensionGenesis(dymensionGenesisKV), ConfigFileOverrides: nil, }, NumValidators: &numHubVals, @@ -174,7 +165,7 @@ func TestEIBCNotFulfillment_EVM(t *testing.T) { // This can be used to write to the block database which will index all block data e.g. txs, msgs, events, etc. // BlockDatabaseFile: test.DefaultBlockDatabaseFilepath(), - }, nil, "", nil) + }, nil, "", nil, false, 780) require.NoError(t, err) CreateChannel(ctx, t, r1, eRep, dymension.CosmosChain, rollapp1.CosmosChain, ibcPath) @@ -230,6 +221,9 @@ func TestEIBCNotFulfillment_EVM(t *testing.T) { _, err = rollapp1.SendIBCTransfer(ctx, channsRollApp1[0].ChannelID, rollappUserAddr, transferData, ibc.TransferOptions{}) require.NoError(t, err) + err = testutil.WaitForBlocks(ctx, 10, dymension, rollapp1) + require.NoError(t, err) + rollappHeight, err := rollapp1.GetNode().Height(ctx) require.NoError(t, err) @@ -241,6 +235,12 @@ func TestEIBCNotFulfillment_EVM(t *testing.T) { require.NoError(t, err) require.True(t, isFinalized) + _, err = dymension.GetNode().FinalizePacketsUntilHeight(ctx, dymensionUserAddr, rollapp1.GetChainID(), fmt.Sprint(rollappHeight)) + require.NoError(t, err) + + err = testutil.WaitForBlocks(ctx, 30, dymension, rollapp1) + require.NoError(t, err) + // Get the IBC denom for urax on Hub rollappTokenDenom := transfertypes.GetPrefixedDenom(channsRollApp1[0].Counterparty.PortID, channsRollApp1[0].Counterparty.ChannelID, rollapp1.Config().Denom) rollappIBCDenom := transfertypes.ParseDenomTrace(rollappTokenDenom).IBCDenom() @@ -263,18 +263,11 @@ func TestEIBCNotFulfillment_EVM(t *testing.T) { fmt.Println("Balance of dymensionUserAddr right after sending eIBC transfer:", balance) require.True(t, balance.Equal(transferData.Amount.Sub(bridgingFee)), fmt.Sprintf("Value mismatch. Expected %s, actual %s", transferData.Amount.Sub(bridgingFee), balance)) - rollappHeight, err = rollapp1.GetNode().Height(ctx) - require.NoError(t, err) - // get eIbc event - eibcEvents, err := getEIbcEventsWithinBlockRange(ctx, dymension, 30, false) + eibcEvents, err := getEIbcEventsWithinBlockRange(ctx, dymension, 10, false) require.NoError(t, err) fmt.Println("Event:", eibcEvents[0]) - // wait a few blocks and verify sender received funds on the hub - err = testutil.WaitForBlocks(ctx, 5, dymension) - require.NoError(t, err) - resp, err := dymension.QueryEIBCDemandOrders(ctx, "PENDING") require.NoError(t, err) require.Equal(t, 1, len(resp.DemandOrders)) @@ -283,10 +276,18 @@ func TestEIBCNotFulfillment_EVM(t *testing.T) { balance, err = dymension.GetBalance(ctx, dymensionUserAddr, rollappIBCDenom) require.NoError(t, err) require.True(t, balance.Equal(transferData.Amount.Sub(bridgingFee)), fmt.Sprintf("Value mismatch. Expected %s, actual %s", transferData.Amount.Sub(bridgingFee), balance)) + // wait until packet finalization and verify funds + rollappHeight, err = rollapp1.GetNode().Height(ctx) + require.NoError(t, err) + isFinalized, err = dymension.WaitUntilRollappHeightIsFinalized(ctx, rollapp1.GetChainID(), rollappHeight, 300) require.NoError(t, err) require.True(t, isFinalized) + + _, err = dymension.GetNode().FinalizePacketsUntilHeight(ctx, dymensionUserAddr, rollapp1.GetChainID(), fmt.Sprint(rollappHeight)) + require.NoError(t, err) + balance, err = dymension.GetBalance(ctx, dymensionUserAddr, rollappIBCDenom) require.NoError(t, err) @@ -301,6 +302,8 @@ func TestEIBCNotFulfillment_EVM(t *testing.T) { } }, ) + // Run invariant check + CheckInvariant(t, ctx, dymension, dymensionUser.KeyName()) } func TestEIBCNotFulfillment_Wasm(t *testing.T) { @@ -317,22 +320,14 @@ func TestEIBCNotFulfillment_Wasm(t *testing.T) { gas_price_rollapp1 := "0adym" maxIdleTime1 := "3s" maxProofTime := "500ms" - configFileOverrides1 := overridesDymintToml(settlement_layer_rollapp1, settlement_node_address, rollapp1_id, gas_price_rollapp1, maxIdleTime1, maxProofTime, "100s") + configFileOverrides1 := overridesDymintToml(settlement_layer_rollapp1, settlement_node_address, rollapp1_id, gas_price_rollapp1, maxIdleTime1, maxProofTime, "50s") // setup config for rollapp 2 settlement_layer_rollapp2 := "dymension" rollapp2_id := "decentrio_12345-1" gas_price_rollapp2 := "0adym" maxIdleTime2 := "3s" - configFileOverrides2 := overridesDymintToml(settlement_layer_rollapp2, settlement_node_address, rollapp2_id, gas_price_rollapp2, maxIdleTime2, maxProofTime, "100s") - - modifyGenesisKV := append( - dymensionGenesisKV, - cosmos.GenesisKV{ - Key: "app_state.rollapp.params.dispute_period_in_blocks", - Value: fmt.Sprint(BLOCK_FINALITY_PERIOD), - }, - ) + configFileOverrides2 := overridesDymintToml(settlement_layer_rollapp2, settlement_node_address, rollapp2_id, gas_price_rollapp2, maxIdleTime2, maxProofTime, "50s") // Create chain factory with dymension numHubVals := 1 @@ -400,7 +395,7 @@ func TestEIBCNotFulfillment_Wasm(t *testing.T) { GasAdjustment: 1.1, TrustingPeriod: "112h", NoHostMount: false, - ModifyGenesis: modifyDymensionGenesis(modifyGenesisKV), + ModifyGenesis: modifyDymensionGenesis(dymensionGenesisKV), ConfigFileOverrides: nil, }, NumValidators: &numHubVals, @@ -455,7 +450,7 @@ func TestEIBCNotFulfillment_Wasm(t *testing.T) { // This can be used to write to the block database which will index all block data e.g. txs, msgs, events, etc. // BlockDatabaseFile: test.DefaultBlockDatabaseFilepath(), - }, nil, "", nil) + }, nil, "", nil, false, 780) require.NoError(t, err) CreateChannel(ctx, t, r1, eRep, dymension.CosmosChain, rollapp1.CosmosChain, ibcPath) @@ -511,6 +506,9 @@ func TestEIBCNotFulfillment_Wasm(t *testing.T) { _, err = rollapp1.SendIBCTransfer(ctx, channsRollApp1[0].ChannelID, rollappUserAddr, transferData, ibc.TransferOptions{}) require.NoError(t, err) + err = testutil.WaitForBlocks(ctx, 10, dymension, rollapp1) + require.NoError(t, err) + rollappHeight, err := rollapp1.GetNode().Height(ctx) require.NoError(t, err) @@ -522,6 +520,12 @@ func TestEIBCNotFulfillment_Wasm(t *testing.T) { require.NoError(t, err) require.True(t, isFinalized) + _, err = dymension.GetNode().FinalizePacketsUntilHeight(ctx, dymensionUserAddr, rollapp1.GetChainID(), fmt.Sprint(rollappHeight)) + require.NoError(t, err) + + err = testutil.WaitForBlocks(ctx, 30, dymension, rollapp1) + require.NoError(t, err) + // Get the IBC denom for urax on Hub rollappTokenDenom := transfertypes.GetPrefixedDenom(channsRollApp1[0].Counterparty.PortID, channsRollApp1[0].Counterparty.ChannelID, rollapp1.Config().Denom) rollappIBCDenom := transfertypes.ParseDenomTrace(rollappTokenDenom).IBCDenom() @@ -537,15 +541,14 @@ func TestEIBCNotFulfillment_Wasm(t *testing.T) { options.Memo = BuildEIbcMemo(eibcFee) _, err = rollapp1.SendIBCTransfer(ctx, channsRollApp1[0].ChannelID, rollappUserAddr, transferData, options) require.NoError(t, err) - rollappHeight, err = rollapp1.GetNode().Height(ctx) - require.NoError(t, err) + balance, err := dymension.GetBalance(ctx, dymensionUserAddr, rollappIBCDenom) require.NoError(t, err) fmt.Println("Balance of dymensionUserAddr right after sending eIBC transfer:", balance) require.True(t, balance.Equal(transferData.Amount.Sub(bridgingFee)), fmt.Sprintf("Value mismatch. Expected %s, actual %s", transferData.Amount.Sub(bridgingFee), balance)) // get eIbc event - eibcEvents, err := getEIbcEventsWithinBlockRange(ctx, dymension, 30, false) + eibcEvents, err := getEIbcEventsWithinBlockRange(ctx, dymension, 10, false) require.NoError(t, err) fmt.Println("Event:", eibcEvents[0]) @@ -562,9 +565,17 @@ func TestEIBCNotFulfillment_Wasm(t *testing.T) { require.NoError(t, err) require.True(t, balance.Equal(transferData.Amount.Sub(bridgingFee)), fmt.Sprintf("Value mismatch. Expected %s, actual %s", transferData.Amount.Sub(bridgingFee), balance)) // wait until packet finalization and verify funds + + rollappHeight, err = rollapp1.GetNode().Height(ctx) + require.NoError(t, err) + isFinalized, err = dymension.WaitUntilRollappHeightIsFinalized(ctx, rollapp1.GetChainID(), rollappHeight, 300) require.NoError(t, err) require.True(t, isFinalized) + + _, err = dymension.GetNode().FinalizePacketsUntilHeight(ctx, dymensionUserAddr, rollapp1.GetChainID(), fmt.Sprint(rollappHeight)) + require.NoError(t, err) + balance, err = dymension.GetBalance(ctx, dymensionUserAddr, rollappIBCDenom) require.NoError(t, err) @@ -579,4 +590,7 @@ func TestEIBCNotFulfillment_Wasm(t *testing.T) { } }, ) + + // Run invariant check + CheckInvariant(t, ctx, dymension, dymensionUser.KeyName()) } diff --git a/tests/eibc_pfm_test.go b/tests/eibc_pfm_test.go index 26518838..c4720267 100644 --- a/tests/eibc_pfm_test.go +++ b/tests/eibc_pfm_test.go @@ -12,7 +12,6 @@ import ( transfertypes "github.com/cosmos/ibc-go/v7/modules/apps/transfer/types" test "github.com/decentrio/rollup-e2e-testing" - "github.com/decentrio/rollup-e2e-testing/cosmos" "github.com/decentrio/rollup-e2e-testing/cosmos/hub/dym_hub" "github.com/decentrio/rollup-e2e-testing/cosmos/rollapp/dym_rollapp" "github.com/decentrio/rollup-e2e-testing/ibc" @@ -37,28 +36,20 @@ func TestEIBCPFM_EVM(t *testing.T) { gas_price_rollapp1 := "0adym" maxIdleTime1 := "10s" maxProofTime := "500ms" - configFileOverrides1 := overridesDymintToml(settlement_layer_rollapp1, settlement_node_address, rollapp1_id, gas_price_rollapp1, maxIdleTime1, maxProofTime, "100s") + configFileOverrides1 := overridesDymintToml(settlement_layer_rollapp1, settlement_node_address, rollapp1_id, gas_price_rollapp1, maxIdleTime1, maxProofTime, "50s") // setup config for rollapp 2 settlement_layer_rollapp2 := "dymension" rollapp2_id := "decentrio_12345-1" gas_price_rollapp2 := "0adym" maxIdleTime2 := "1s" - configFileOverrides2 := overridesDymintToml(settlement_layer_rollapp2, settlement_node_address, rollapp2_id, gas_price_rollapp2, maxIdleTime2, maxProofTime, "100s") + configFileOverrides2 := overridesDymintToml(settlement_layer_rollapp2, settlement_node_address, rollapp2_id, gas_price_rollapp2, maxIdleTime2, maxProofTime, "50s") // Create chain factory with dymension numHubVals := 1 numHubFullNodes := 1 numRollAppFn := 0 numRollAppVals := 1 - modifyGenesisKV := append( - dymensionGenesisKV, - cosmos.GenesisKV{ - Key: "app_state.rollapp.params.dispute_period_in_blocks", - Value: fmt.Sprint(BLOCK_FINALITY_PERIOD), - }, - ) - cf := test.NewBuiltinChainFactory(zaptest.NewLogger(t), []*test.ChainSpec{ { Name: "rollapp1", @@ -120,7 +111,7 @@ func TestEIBCPFM_EVM(t *testing.T) { GasAdjustment: 1.1, TrustingPeriod: "112h", NoHostMount: false, - ModifyGenesis: modifyDymensionGenesis(modifyGenesisKV), + ModifyGenesis: modifyDymensionGenesis(dymensionGenesisKV), ConfigFileOverrides: nil, }, NumValidators: &numHubVals, @@ -175,7 +166,7 @@ func TestEIBCPFM_EVM(t *testing.T) { // This can be used to write to the block database which will index all block data e.g. txs, msgs, events, etc. // BlockDatabaseFile: test.DefaultBlockDatabaseFilepath(), - }, nil, "", nil) + }, nil, "", nil, false, 780) require.NoError(t, err) CreateChannel(ctx, t, r1, eRep, dymension.CosmosChain, rollapp1.CosmosChain, ibcPath) @@ -277,13 +268,23 @@ func TestEIBCPFM_EVM(t *testing.T) { rollapp1Height, err := rollapp1.Height(ctx) require.NoError(t, err) + ack, err := testutil.PollForAck(ctx, rollapp1, rollapp1Height, rollapp1Height+30, tx.Packet) require.NoError(t, err) + rollapp1Height, err = rollapp1.Height(ctx) + require.NoError(t, err) + isFinalized, err := dymension.WaitUntilRollappHeightIsFinalized(ctx, rollapp1.GetChainID(), rollapp1Height, 300) require.NoError(t, err) require.True(t, isFinalized) + _, err = dymension.GetNode().FinalizePacketsUntilHeight(ctx, dymensionUserAddr, rollapp1.GetChainID(), fmt.Sprint(rollapp1Height)) + require.NoError(t, err) + + err = testutil.WaitForBlocks(ctx, 10, dymension, rollapp1) + require.NoError(t, err) + // Make sure the ack contains error require.True(t, bytes.Contains(ack.Acknowledgement, []byte("error"))) @@ -300,6 +301,8 @@ func TestEIBCPFM_EVM(t *testing.T) { testutil.AssertBalance(t, ctx, dymension, dymensionUserAddr, firstHopIBCDenom, zeroBal) testutil.AssertBalance(t, ctx, rollapp2, rollapp2UserAddr, secondHopIBCDenom, zeroBal) + // Run invariant check + CheckInvariant(t, ctx, dymension, dymensionUser.KeyName()) } func TestEIBCPFM_Wasm(t *testing.T) { @@ -316,14 +319,14 @@ func TestEIBCPFM_Wasm(t *testing.T) { gas_price_rollapp1 := "0adym" maxIdleTime1 := "10s" maxProofTime := "500ms" - configFileOverrides1 := overridesDymintToml(settlement_layer_rollapp1, settlement_node_address, rollapp1_id, gas_price_rollapp1, maxIdleTime1, maxProofTime, "100s") + configFileOverrides1 := overridesDymintToml(settlement_layer_rollapp1, settlement_node_address, rollapp1_id, gas_price_rollapp1, maxIdleTime1, maxProofTime, "50s") // setup config for rollapp 2 settlement_layer_rollapp2 := "dymension" rollapp2_id := "decentrio_12345-1" gas_price_rollapp2 := "0adym" maxIdleTime2 := "1s" - configFileOverrides2 := overridesDymintToml(settlement_layer_rollapp2, settlement_node_address, rollapp2_id, gas_price_rollapp2, maxIdleTime2, maxProofTime, "100s") + configFileOverrides2 := overridesDymintToml(settlement_layer_rollapp2, settlement_node_address, rollapp2_id, gas_price_rollapp2, maxIdleTime2, maxProofTime, "50s") // Create chain factory with dymension numHubVals := 1 @@ -331,14 +334,6 @@ func TestEIBCPFM_Wasm(t *testing.T) { numRollAppFn := 0 numRollAppVals := 1 - modifyGenesisKV := append( - dymensionGenesisKV, - cosmos.GenesisKV{ - Key: "app_state.rollapp.params.dispute_period_in_blocks", - Value: fmt.Sprint(BLOCK_FINALITY_PERIOD), - }, - ) - cf := test.NewBuiltinChainFactory(zaptest.NewLogger(t), []*test.ChainSpec{ { Name: "rollapp1", @@ -400,7 +395,7 @@ func TestEIBCPFM_Wasm(t *testing.T) { GasAdjustment: 1.1, TrustingPeriod: "112h", NoHostMount: false, - ModifyGenesis: modifyDymensionGenesis(modifyGenesisKV), + ModifyGenesis: modifyDymensionGenesis(dymensionGenesisKV), ConfigFileOverrides: nil, }, NumValidators: &numHubVals, @@ -454,7 +449,7 @@ func TestEIBCPFM_Wasm(t *testing.T) { SkipPathCreation: true, // This can be used to write to the block database which will index all block data e.g. txs, msgs, events, etc. - }, nil, "", nil) + }, nil, "", nil, false, 780) require.NoError(t, err) CreateChannel(ctx, t, r1, eRep, dymension.CosmosChain, rollapp1.CosmosChain, ibcPath) @@ -556,13 +551,23 @@ func TestEIBCPFM_Wasm(t *testing.T) { rollapp1Height, err := rollapp1.Height(ctx) require.NoError(t, err) + ack, err := testutil.PollForAck(ctx, rollapp1, rollapp1Height, rollapp1Height+30, tx.Packet) require.NoError(t, err) + rollapp1Height, err = rollapp1.Height(ctx) + require.NoError(t, err) + isFinalized, err := dymension.WaitUntilRollappHeightIsFinalized(ctx, rollapp1.GetChainID(), rollapp1Height, 300) require.NoError(t, err) require.True(t, isFinalized) + _, err = dymension.GetNode().FinalizePacketsUntilHeight(ctx, dymensionUserAddr, rollapp1.GetChainID(), fmt.Sprint(rollapp1Height)) + require.NoError(t, err) + + err = testutil.WaitForBlocks(ctx, 10, dymension, rollapp1) + require.NoError(t, err) + // Make sure the ack contains error require.True(t, bytes.Contains(ack.Acknowledgement, []byte("error"))) @@ -579,4 +584,6 @@ func TestEIBCPFM_Wasm(t *testing.T) { testutil.AssertBalance(t, ctx, dymension, dymensionUserAddr, firstHopIBCDenom, zeroBal) testutil.AssertBalance(t, ctx, rollapp2, rollapp2UserAddr, secondHopIBCDenom, zeroBal) + // Run invariant check + CheckInvariant(t, ctx, dymension, dymensionUser.KeyName()) } diff --git a/tests/eibc_timeout_test.go b/tests/eibc_timeout_test.go index 1b62d5f4..44b1adef 100644 --- a/tests/eibc_timeout_test.go +++ b/tests/eibc_timeout_test.go @@ -37,17 +37,11 @@ func TestEIBCTimeoutDymToRollapp_EVM(t *testing.T) { dymintTomlOverrides["settlement_gas_prices"] = "0adym" dymintTomlOverrides["max_idle_time"] = "3s" dymintTomlOverrides["max_proof_time"] = "500ms" - dymintTomlOverrides["batch_submit_max_time"] = "100s" + dymintTomlOverrides["batch_submit_time"] = "50s" + dymintTomlOverrides["p2p_blocksync_enabled"] = "false" configFileOverrides["config/dymint.toml"] = dymintTomlOverrides - modifyGenesisKV := append( - dymensionGenesisKV, - cosmos.GenesisKV{ - Key: "app_state.rollapp.params.dispute_period_in_blocks", - Value: fmt.Sprint(BLOCK_FINALITY_PERIOD), - }, - ) // Create chain factory with dymension numHubVals := 1 numHubFullNodes := 1 @@ -92,7 +86,7 @@ func TestEIBCTimeoutDymToRollapp_EVM(t *testing.T) { GasAdjustment: 1.1, TrustingPeriod: "112h", NoHostMount: false, - ModifyGenesis: modifyDymensionGenesis(modifyGenesisKV), + ModifyGenesis: modifyDymensionGenesis(dymensionGenesisKV), ConfigFileOverrides: nil, }, NumValidators: &numHubVals, @@ -133,7 +127,7 @@ func TestEIBCTimeoutDymToRollapp_EVM(t *testing.T) { // This can be used to write to the block database which will index all block data e.g. txs, msgs, events, etc. // BlockDatabaseFile: test.DefaultBlockDatabaseFilepath(), - }, nil, "", nil) + }, nil, "", nil, false, 780) require.NoError(t, err) CreateChannel(ctx, t, r, eRep, dymension.CosmosChain, rollapp1.CosmosChain, ibcPath) @@ -172,6 +166,9 @@ func TestEIBCTimeoutDymToRollapp_EVM(t *testing.T) { _, err = rollapp1.SendIBCTransfer(ctx, channel.ChannelID, rollappUserAddr, transferData, ibc.TransferOptions{}) require.NoError(t, err) + err = testutil.WaitForBlocks(ctx, 10, dymension, rollapp1) + require.NoError(t, err) + rollappHeight, err := rollapp1.GetNode().Height(ctx) require.NoError(t, err) @@ -183,6 +180,12 @@ func TestEIBCTimeoutDymToRollapp_EVM(t *testing.T) { require.NoError(t, err) require.True(t, isFinalized) + _, err = dymension.GetNode().FinalizePacketsUntilHeight(ctx, dymensionUserAddr, rollapp1.GetChainID(), fmt.Sprint(rollappHeight)) + require.NoError(t, err) + + err = testutil.WaitForBlocks(ctx, 50, dymension, rollapp1) + require.NoError(t, err) + // Compose an IBC transfer and send from hub to rollapp // global eibc fee in case of auto created orders is 0.0015 numerator := math.NewInt(15) @@ -207,8 +210,6 @@ func TestEIBCTimeoutDymToRollapp_EVM(t *testing.T) { _, err = dymension.SendIBCTransfer(ctx, channel.ChannelID, dymensionUserAddr, transferData, options) require.NoError(t, err) - rollappHeight, err = rollapp1.GetNode().Height(ctx) - require.NoError(t, err) // Get the IBC denom for dymension on roll app dymensionTokenDenom := transfertypes.GetPrefixedDenom(channel.Counterparty.PortID, channel.Counterparty.ChannelID, dymension.Config().Denom) dymensionIBCDenom := transfertypes.ParseDenomTrace(dymensionTokenDenom).IBCDenom() @@ -223,14 +224,14 @@ func TestEIBCTimeoutDymToRollapp_EVM(t *testing.T) { require.NoError(t, err) // get eibc event - eibcEvents, err := getEIbcEventsWithinBlockRange(ctx, dymension, 20, false) + eibcEvents, err := getEIbcEventsWithinBlockRange(ctx, dymension, 10, false) require.NoError(t, err) fmt.Println("Event:", eibcEvents[0]) require.Equal(t, eibcEvents[0].Price, fmt.Sprintf("%s%s", transferAmountWithoutFee, dymension.Config().Denom)) require.Equal(t, eibcEvents[0].Fee, fmt.Sprintf("%s%s", globalEIbcFee, dymension.Config().Denom)) // fulfill demand order - txhash, err := dymension.FullfillDemandOrder(ctx, eibcEvents[0].ID, marketMakerAddr, globalEIbcFee) + txhash, err := dymension.FullfillDemandOrder(ctx, eibcEvents[0].OrderId, marketMakerAddr, globalEIbcFee) require.NoError(t, err) fmt.Println(txhash) // eibcEvent := getEibcEventFromTx(t, dymension, txhash) @@ -240,7 +241,7 @@ func TestEIBCTimeoutDymToRollapp_EVM(t *testing.T) { // require.True(t, eibcEvent.IsFulfilled) // wait a few blocks and verify sender received funds on the dymension - err = testutil.WaitForBlocks(ctx, 5, dymension) + err = testutil.WaitForBlocks(ctx, 1, dymension) require.NoError(t, err) // verify funds minus fee were added to receiver's address @@ -250,22 +251,27 @@ func TestEIBCTimeoutDymToRollapp_EVM(t *testing.T) { expBalance := walletAmount.Sub(transferData.Amount).Add(transferAmountWithoutFee) require.True(t, balance.Equal(expBalance), fmt.Sprintf("Value mismatch. Expected %s, actual %s", expBalance, balance)) - // verify funds were deducted from market maker's wallet address - balance, err = dymension.GetBalance(ctx, marketMakerAddr, dymension.Config().Denom) + // wait until packet finalization and verify funds (incl. fee) were added to market maker's wallet address + err = testutil.WaitForBlocks(ctx, 10, dymension) + require.NoError(t, err) + + rollappHeight, err = rollapp1.GetNode().Height(ctx) require.NoError(t, err) - fmt.Println("Balance of marketMakerAddr after fulfilling the order:", balance) - expBalanceMarketMaker := walletAmount.Sub((transferAmountWithoutFee)) - require.True(t, balance.Equal(expBalanceMarketMaker), fmt.Sprintf("Value mismatch. Expected %s, actual %s", expBalanceMarketMaker, balance)) - // wait until packet finalization and verify funds (incl. fee) were added to market maker's wallet address isFinalized, err = dymension.WaitUntilRollappHeightIsFinalized(ctx, rollapp1.GetChainID(), rollappHeight, 300) require.NoError(t, err) require.True(t, isFinalized) + _, err = dymension.GetNode().FinalizePacketsUntilHeight(ctx, dymensionUserAddr, rollapp1.GetChainID(), fmt.Sprint(rollappHeight)) + require.NoError(t, err) + + err = testutil.WaitForBlocks(ctx, 10, dymension) + require.NoError(t, err) + balance, err = dymension.GetBalance(ctx, marketMakerAddr, dymension.Config().Denom) require.NoError(t, err) fmt.Println("Balance of marketMakerAddr after packet finalization:", balance) - expBalanceMarketMaker = expBalanceMarketMaker.Add(transferData.Amount) + expBalanceMarketMaker := walletAmount.Add(globalEIbcFee) require.True(t, balance.Equal(expBalanceMarketMaker), fmt.Sprintf("Value mismatch. Expected %s, actual %s", expBalanceMarketMaker, balance)) t.Cleanup( @@ -276,6 +282,9 @@ func TestEIBCTimeoutDymToRollapp_EVM(t *testing.T) { } }, ) + + // Run invariant check + CheckInvariant(t, ctx, dymension, dymensionUser.KeyName()) } // TestEIBCTimeoutFulFillDymToRollapp test send 3rd party IBC denom from dymension to rollapp with timeout @@ -288,28 +297,33 @@ func TestEIBCTimeoutFulFillDymToRollapp_EVM(t *testing.T) { ctx := context.Background() // setup config for rollapp 1 - settlement_layer_rollapp1 := "dymension" - settlement_node_address := fmt.Sprintf("http://dymension_100-1-val-0-%s:26657", t.Name()) - rollapp1_id := "rollappevm_1234-1" - gas_price_rollapp1 := "0adym" - maxIdleTime1 := "10s" - maxProofTime := "500ms" - configFileOverrides1 := overridesDymintToml(settlement_layer_rollapp1, settlement_node_address, rollapp1_id, gas_price_rollapp1, maxIdleTime1, maxProofTime, "100s") + configFileOverrides1 := make(map[string]any) + dymintTomlOverrides1 := make(testutil.Toml) + dymintTomlOverrides1["settlement_layer"] = "dymension" + dymintTomlOverrides1["settlement_node_address"] = fmt.Sprintf("http://dymension_100-1-val-0-%s:26657", t.Name()) + dymintTomlOverrides1["rollapp_id"] = "rollappevm_1234-1" + dymintTomlOverrides1["settlement_gas_prices"] = "0adym" + dymintTomlOverrides1["max_idle_time"] = "3s" + dymintTomlOverrides1["max_proof_time"] = "500ms" + dymintTomlOverrides1["batch_submit_time"] = "50s" + dymintTomlOverrides1["p2p_blocksync_enabled"] = "false" + + configFileOverrides1["config/dymint.toml"] = dymintTomlOverrides1 // setup config for rollapp 2 - settlement_layer_rollapp2 := "dymension" - rollapp2_id := "decentrio_12345-1" - gas_price_rollapp2 := "0adym" - maxIdleTime2 := "1s" - configFileOverrides2 := overridesDymintToml(settlement_layer_rollapp2, settlement_node_address, rollapp2_id, gas_price_rollapp2, maxIdleTime2, maxProofTime, "100s") + configFileOverrides2 := make(map[string]any) + dymintTomlOverrides2 := make(testutil.Toml) + dymintTomlOverrides2["settlement_layer"] = "dymension" + dymintTomlOverrides2["settlement_node_address"] = fmt.Sprintf("http://dymension_100-1-val-0-%s:26657", t.Name()) + dymintTomlOverrides2["rollapp_id"] = "decentrio_12345-1" + dymintTomlOverrides2["settlement_gas_prices"] = "0adym" + dymintTomlOverrides2["max_idle_time"] = "3s" + dymintTomlOverrides2["max_proof_time"] = "500ms" + dymintTomlOverrides2["batch_submit_time"] = "50s" + dymintTomlOverrides2["p2p_blocksync_enabled"] = "false" + + configFileOverrides2["config/dymint.toml"] = dymintTomlOverrides2 - modifyGenesisKV := append( - dymensionGenesisKV, - cosmos.GenesisKV{ - Key: "app_state.rollapp.params.dispute_period_in_blocks", - Value: fmt.Sprint(BLOCK_FINALITY_PERIOD), - }, - ) // Create chain factory with dymension numHubVals := 1 numHubFullNodes := 1 @@ -378,7 +392,7 @@ func TestEIBCTimeoutFulFillDymToRollapp_EVM(t *testing.T) { GasAdjustment: 1.1, TrustingPeriod: "112h", NoHostMount: false, - ModifyGenesis: modifyDymensionGenesis(modifyGenesisKV), + ModifyGenesis: modifyDymensionGenesis(dymensionGenesisKV), ConfigFileOverrides: nil, }, NumValidators: &numHubVals, @@ -407,10 +421,6 @@ func TestEIBCTimeoutFulFillDymToRollapp_EVM(t *testing.T) { r := test.NewBuiltinRelayerFactory(ibc.CosmosRly, zaptest.NewLogger(t), relayer.CustomDockerImage(RelayerMainRepo, relayerVersion, "100:1000"), relayer.ImagePull(pullRelayerImage), ).Build(t, client, "relayer", network) - // relayer for rollapp 2 - r2 := test.NewBuiltinRelayerFactory(ibc.CosmosRly, zaptest.NewLogger(t), - relayer.CustomDockerImage(RelayerMainRepo, relayerVersion, "100:1000"), relayer.ImagePull(pullRelayerImage), - ).Build(t, client, "relayer2", network) // relayer for rollapp gaia r3 := test.NewBuiltinRelayerFactory( ibc.CosmosRly, @@ -423,7 +433,6 @@ func TestEIBCTimeoutFulFillDymToRollapp_EVM(t *testing.T) { AddRollUp(dymension, rollapp1, rollapp2). AddChain(gaia). AddRelayer(r, "relayer"). - AddRelayer(r2, "relayer2"). AddRelayer(r3, "relayer3"). AddLink(test.InterchainLink{ Chain1: dymension, @@ -431,12 +440,6 @@ func TestEIBCTimeoutFulFillDymToRollapp_EVM(t *testing.T) { Relayer: r, Path: ibcPath, }). - AddLink(test.InterchainLink{ - Chain1: dymension, - Chain2: rollapp2, - Relayer: r2, - Path: anotherIbcPath, - }). AddLink(test.InterchainLink{ Chain1: dymension, Chain2: gaia, @@ -455,16 +458,15 @@ func TestEIBCTimeoutFulFillDymToRollapp_EVM(t *testing.T) { // This can be used to write to the block database which will index all block data e.g. txs, msgs, events, etc. // BlockDatabaseFile: test.DefaultBlockDatabaseFilepath(), - }, nil, "", nil) + }, nil, "", nil, false, 780) require.NoError(t, err) CreateChannel(ctx, t, r, eRep, dymension.CosmosChain, rollapp1.CosmosChain, ibcPath) - CreateChannel(ctx, t, r2, eRep, dymension.CosmosChain, rollapp2.CosmosChain, anotherIbcPath) CreateChannel(ctx, t, r3, eRep, dymension.CosmosChain, gaia, ibcPath) channsDym, err := r.GetChannels(ctx, eRep, dymension.GetChainID()) require.NoError(t, err) - require.Len(t, channsDym, 3) + require.Len(t, channsDym, 2) rollAppChan, err := r.GetChannels(ctx, eRep, rollapp1.GetChainID()) require.NoError(t, err) @@ -490,9 +492,6 @@ func TestEIBCTimeoutFulFillDymToRollapp_EVM(t *testing.T) { err = r.StartRelayer(ctx, eRep, ibcPath) require.NoError(t, err) - err = r2.StartRelayer(ctx, eRep, anotherIbcPath) - require.NoError(t, err) - err = r3.StartRelayer(ctx, eRep, ibcPath) require.NoError(t, err) @@ -502,10 +501,6 @@ func TestEIBCTimeoutFulFillDymToRollapp_EVM(t *testing.T) { if err != nil { t.Logf("an error occurred while stopping the relayer: %s", err) } - err = r2.StopRelayer(ctx, eRep) - if err != nil { - t.Logf("an error occurred while stopping the relayer: %s", err) - } err = r3.StopRelayer(ctx, eRep) if err != nil { t.Logf("an error occurred while stopping the relayer2: %s", err) @@ -546,6 +541,9 @@ func TestEIBCTimeoutFulFillDymToRollapp_EVM(t *testing.T) { _, err = rollapp1.SendIBCTransfer(ctx, rollappDymChan.ChannelID, rollappUserAddr, transferData, ibc.TransferOptions{}) require.NoError(t, err) + err = testutil.WaitForBlocks(ctx, 10, dymension, rollapp1) + require.NoError(t, err) + rollappHeight, err := rollapp1.GetNode().Height(ctx) require.NoError(t, err) @@ -557,6 +555,12 @@ func TestEIBCTimeoutFulFillDymToRollapp_EVM(t *testing.T) { require.NoError(t, err) require.True(t, isFinalized) + _, err = dymension.GetNode().FinalizePacketsUntilHeight(ctx, dymensionUserAddr, rollapp1.GetChainID(), fmt.Sprint(rollappHeight)) + require.NoError(t, err) + + err = testutil.WaitForBlocks(ctx, 10, dymension, rollapp1) + require.NoError(t, err) + // Set a short timeout for IBC transfer options := ibc.TransferOptions{ Timeout: &ibc.IBCTimeout{ @@ -589,7 +593,7 @@ func TestEIBCTimeoutFulFillDymToRollapp_EVM(t *testing.T) { gaiaTokenDenom := transfertypes.GetPrefixedDenom(dymGaiaChan.PortID, dymGaiaChan.ChannelID, gaia.Config().Denom) gaiaIBCDenom := transfertypes.ParseDenomTrace(gaiaTokenDenom).IBCDenom() - err = testutil.WaitForBlocks(ctx, 5, dymension, rollapp1, gaia) + err = testutil.WaitForBlocks(ctx, 50, dymension, rollapp1) require.NoError(t, err) testutil.AssertBalance(t, ctx, dymension, dymensionUserAddr, gaiaIBCDenom, gaiaToDymTransferData.Amount) @@ -602,8 +606,7 @@ func TestEIBCTimeoutFulFillDymToRollapp_EVM(t *testing.T) { // Compose an IBC transfer and send from dym -> rollapp _, err = dymension.SendIBCTransfer(ctx, dymRollAppChan.ChannelID, dymensionUserAddr, dymToRollAppTransferData, options) require.NoError(t, err) - rollappHeight, err = rollapp1.GetNode().Height(ctx) - require.NoError(t, err) + // Assert balance was updated on the dym testutil.AssertBalance(t, ctx, dymension, dymensionUserAddr, gaiaIBCDenom, zeroBal) // Get the IBC denom of 3rd party token on roll app @@ -617,14 +620,14 @@ func TestEIBCTimeoutFulFillDymToRollapp_EVM(t *testing.T) { require.NoError(t, err) // get eibc event - eibcEvents, err := getEIbcEventsWithinBlockRange(ctx, dymension, 30, false) + eibcEvents, err := getEIbcEventsWithinBlockRange(ctx, dymension, 10, false) require.NoError(t, err) fmt.Println("Event:", eibcEvents[0]) require.Equal(t, eibcEvents[0].Price, fmt.Sprintf("%s%s", transferAmountWithoutFee, gaiaIBCDenom)) require.Equal(t, eibcEvents[0].Fee, fmt.Sprintf("%s%s", globalEIbcFee, gaiaIBCDenom)) // fulfill demand order - txhash, err := dymension.FullfillDemandOrder(ctx, eibcEvents[0].ID, marketMakerAddr, globalEIbcFee) + txhash, err := dymension.FullfillDemandOrder(ctx, eibcEvents[0].OrderId, marketMakerAddr, globalEIbcFee) require.NoError(t, err) fmt.Println(txhash) // eibcEvent := getEibcEventFromTx(t, dymension, txhash) @@ -634,7 +637,7 @@ func TestEIBCTimeoutFulFillDymToRollapp_EVM(t *testing.T) { // require.True(t, eibcEvent.IsFulfilled) // wait a few blocks and verify sender received funds on the dymension - err = testutil.WaitForBlocks(ctx, 3, dymension) + err = testutil.WaitForBlocks(ctx, 5, dymension) require.NoError(t, err) // verify funds minus fee were added to receiver's address @@ -643,21 +646,28 @@ func TestEIBCTimeoutFulFillDymToRollapp_EVM(t *testing.T) { fmt.Println("Balance of dymensionUserAddr after fulfilling the order:", balance) expBalance := gaiaToDymTransferData.Amount.Sub(dymToRollAppTransferData.Amount).Add(transferAmountWithoutFee) require.True(t, balance.Equal(expBalance), fmt.Sprintf("Value mismatch. Expected %s, actual %s", expBalance, balance)) - // verify funds were deducted from market maker's wallet address - balance, err = dymension.GetBalance(ctx, marketMakerAddr, gaiaIBCDenom) - require.NoError(t, err) - fmt.Println("Balance of marketMakerAddr after fulfilling the order:", balance) - expBalanceMarketMaker := gaiaToMMTransferData.Amount.Sub(transferAmountWithoutFee) - require.True(t, balance.Equal(expBalanceMarketMaker), fmt.Sprintf("Value mismatch. Expected %s, actual %s", expBalanceMarketMaker, balance)) + // wait until packet finalization and verify funds (incl. fee) were added to market maker's wallet address + err = testutil.WaitForBlocks(ctx, 10, dymension) + require.NoError(t, err) + + rollappHeight, err = rollapp1.GetNode().Height(ctx) + require.NoError(t, err) + isFinalized, err = dymension.WaitUntilRollappHeightIsFinalized(ctx, rollapp1.GetChainID(), rollappHeight, 300) require.NoError(t, err) require.True(t, isFinalized) + _, err = dymension.GetNode().FinalizePacketsUntilHeight(ctx, dymensionUserAddr, rollapp1.GetChainID(), fmt.Sprint(rollappHeight)) + require.NoError(t, err) + + err = testutil.WaitForBlocks(ctx, 10, dymension) + require.NoError(t, err) + balance, err = dymension.GetBalance(ctx, marketMakerAddr, gaiaIBCDenom) require.NoError(t, err) fmt.Println("Balance of marketMakerAddr after packet finalization:", balance) - expBalanceMarketMaker = expBalanceMarketMaker.Add(dymToRollAppTransferData.Amount) + expBalanceMarketMaker := transferAmount.Add(globalEIbcFee) require.True(t, balance.Equal(expBalanceMarketMaker), fmt.Sprintf("Value mismatch. Expected %s, actual %s", expBalanceMarketMaker, balance)) t.Cleanup( @@ -672,6 +682,9 @@ func TestEIBCTimeoutFulFillDymToRollapp_EVM(t *testing.T) { resp, err := dymension.GetNode().QueryPacketCommitments(ctx, "transfer", dymRollAppChan.ChannelID) require.NoError(t, err) require.Equal(t, len(resp.Commitments) == 0, true, "packet commitments still exist") + + // Run invariant check + CheckInvariant(t, ctx, dymension, dymensionUser.KeyName()) } func TestEIBCTimeoutFulFillDymToRollapp_Wasm(t *testing.T) { @@ -688,22 +701,14 @@ func TestEIBCTimeoutFulFillDymToRollapp_Wasm(t *testing.T) { gas_price_rollapp1 := "0adym" maxIdleTime1 := "10s" maxProofTime := "500ms" - configFileOverrides1 := overridesDymintToml(settlement_layer_rollapp1, settlement_node_address, rollapp1_id, gas_price_rollapp1, maxIdleTime1, maxProofTime, "100s") + configFileOverrides1 := overridesDymintToml(settlement_layer_rollapp1, settlement_node_address, rollapp1_id, gas_price_rollapp1, maxIdleTime1, maxProofTime, "50s") // setup config for rollapp 2 settlement_layer_rollapp2 := "dymension" rollapp2_id := "decentrio_12345-1" gas_price_rollapp2 := "0adym" maxIdleTime2 := "1s" - configFileOverrides2 := overridesDymintToml(settlement_layer_rollapp2, settlement_node_address, rollapp2_id, gas_price_rollapp2, maxIdleTime2, maxProofTime, "100s") - - modifyGenesisKV := append( - dymensionGenesisKV, - cosmos.GenesisKV{ - Key: "app_state.rollapp.params.dispute_period_in_blocks", - Value: fmt.Sprint(BLOCK_FINALITY_PERIOD), - }, - ) + configFileOverrides2 := overridesDymintToml(settlement_layer_rollapp2, settlement_node_address, rollapp2_id, gas_price_rollapp2, maxIdleTime2, maxProofTime, "50s") // Create chain factory with dymension numHubVals := 1 @@ -773,7 +778,7 @@ func TestEIBCTimeoutFulFillDymToRollapp_Wasm(t *testing.T) { GasAdjustment: 1.1, TrustingPeriod: "112h", NoHostMount: false, - ModifyGenesis: modifyDymensionGenesis(modifyGenesisKV), + ModifyGenesis: modifyDymensionGenesis(dymensionGenesisKV), ConfigFileOverrides: nil, }, NumValidators: &numHubVals, @@ -849,7 +854,7 @@ func TestEIBCTimeoutFulFillDymToRollapp_Wasm(t *testing.T) { SkipPathCreation: true, // This can be used to write to the block database which will index all block data e.g. txs, msgs, events, etc. - }, nil, "", nil) + }, nil, "", nil, false, 780) require.NoError(t, err) CreateChannel(ctx, t, r, eRep, dymension.CosmosChain, rollapp1.CosmosChain, ibcPath) @@ -947,6 +952,9 @@ func TestEIBCTimeoutFulFillDymToRollapp_Wasm(t *testing.T) { _, err = rollapp1.SendIBCTransfer(ctx, rollappDymChan.ChannelID, rollappUserAddr, transferData, ibc.TransferOptions{}) require.NoError(t, err) + err = testutil.WaitForBlocks(ctx, 10, dymension, rollapp1) + require.NoError(t, err) + rollappHeight, err := rollapp1.GetNode().Height(ctx) require.NoError(t, err) @@ -958,6 +966,9 @@ func TestEIBCTimeoutFulFillDymToRollapp_Wasm(t *testing.T) { require.NoError(t, err) require.True(t, isFinalized) + _, err = dymension.GetNode().FinalizePacketsUntilHeight(ctx, dymensionUserAddr, rollapp1.GetChainID(), fmt.Sprint(rollappHeight)) + require.NoError(t, err) + gaiaToDymTransferData := ibc.WalletData{ Address: dymensionUserAddr, Denom: gaia.Config().Denom, @@ -993,8 +1004,6 @@ func TestEIBCTimeoutFulFillDymToRollapp_Wasm(t *testing.T) { Amount: transferAmount, } - rollappHeight, err = rollapp1.GetNode().Height(ctx) - require.NoError(t, err) // Get the IBC denom of 3rd party token on roll app before sending the transaction to make sure demand order is fulfilled dymensionTokenDenom := transfertypes.GetPrefixedDenom(rollappDymChan.PortID, rollappDymChan.ChannelID, gaiaIBCDenom) dymensionIBCDenom := transfertypes.ParseDenomTrace(dymensionTokenDenom).IBCDenom() @@ -1007,11 +1016,11 @@ func TestEIBCTimeoutFulFillDymToRollapp_Wasm(t *testing.T) { testutil.AssertBalance(t, ctx, rollapp1, rollappUserAddr, dymensionIBCDenom, zeroBal) // get eibc event - eibcEvents, err := getEIbcEventsWithinBlockRange(ctx, dymension, 30, false) + eibcEvents, err := getEIbcEventsWithinBlockRange(ctx, dymension, 10, false) require.NoError(t, err) // fulfill demand order - txhash, err := dymension.FullfillDemandOrder(ctx, eibcEvents[0].ID, marketMakerAddr, globalEIbcFee) + txhash, err := dymension.FullfillDemandOrder(ctx, eibcEvents[0].OrderId, marketMakerAddr, globalEIbcFee) // Pushing event assertion later in the test so that fulfill demand order can always be fulfilled fmt.Println("Event:", eibcEvents[0]) require.Equal(t, eibcEvents[0].Price, fmt.Sprintf("%s%s", transferAmountWithoutFee, gaiaIBCDenom)) @@ -1026,7 +1035,7 @@ func TestEIBCTimeoutFulFillDymToRollapp_Wasm(t *testing.T) { // require.True(t, eibcEvent.IsFulfilled) // wait a few blocks and verify sender received funds on the dymension - err = testutil.WaitForBlocks(ctx, 3, dymension) + err = testutil.WaitForBlocks(ctx, 5, dymension) require.NoError(t, err) // verify funds minus fee were added to receiver's address @@ -1035,21 +1044,25 @@ func TestEIBCTimeoutFulFillDymToRollapp_Wasm(t *testing.T) { fmt.Println("Balance of dymensionUserAddr after fulfilling the order:", balance) expBalance := gaiaToDymTransferData.Amount.Sub(dymToRollAppTransferData.Amount).Add(transferAmountWithoutFee) require.True(t, balance.Equal(expBalance), fmt.Sprintf("Value mismatch. Expected %s, actual %s", expBalance, balance)) - // verify funds were deducted from market maker's wallet address - balance, err = dymension.GetBalance(ctx, marketMakerAddr, gaiaIBCDenom) - require.NoError(t, err) - fmt.Println("Balance of marketMakerAddr after fulfilling the order:", balance) - expBalanceMarketMaker := gaiaToMMTransferData.Amount.Sub(transferAmountWithoutFee) - require.True(t, balance.Equal(expBalanceMarketMaker), fmt.Sprintf("Value mismatch. Expected %s, actual %s", expBalanceMarketMaker, balance)) + // wait until packet finalization and verify funds (incl. fee) were added to market maker's wallet address + rollappHeight, err = rollapp1.GetNode().Height(ctx) + require.NoError(t, err) + isFinalized, err = dymension.WaitUntilRollappHeightIsFinalized(ctx, rollapp1.GetChainID(), rollappHeight, 300) require.NoError(t, err) require.True(t, isFinalized) + _, err = dymension.GetNode().FinalizePacketsUntilHeight(ctx, dymensionUserAddr, rollapp1.GetChainID(), fmt.Sprint(rollappHeight)) + require.NoError(t, err) + + err = testutil.WaitForBlocks(ctx, 5, dymension) + require.NoError(t, err) + balance, err = dymension.GetBalance(ctx, marketMakerAddr, gaiaIBCDenom) require.NoError(t, err) fmt.Println("Balance of marketMakerAddr after packet finalization:", balance) - expBalanceMarketMaker = expBalanceMarketMaker.Add(dymToRollAppTransferData.Amount) + expBalanceMarketMaker := gaiaToMMTransferData.Amount.Add(globalEIbcFee) require.True(t, balance.Equal(expBalanceMarketMaker), fmt.Sprintf("Value mismatch. Expected %s, actual %s", expBalanceMarketMaker, balance)) t.Cleanup( @@ -1064,4 +1077,7 @@ func TestEIBCTimeoutFulFillDymToRollapp_Wasm(t *testing.T) { resp, err := dymension.GetNode().QueryPacketCommitments(ctx, "transfer", dymRollAppChan.ChannelID) require.NoError(t, err) require.Equal(t, len(resp.Commitments) == 0, true, "packet commitments still exist") + + // Run invariant check + CheckInvariant(t, ctx, dymension, dymensionUser.KeyName()) } diff --git a/tests/erc20_ibc_transfer_test.go b/tests/erc20_ibc_transfer_test.go index 090894f1..ca485a00 100644 --- a/tests/erc20_ibc_transfer_test.go +++ b/tests/erc20_ibc_transfer_test.go @@ -37,7 +37,7 @@ func TestERC20HubToRollAppWithoutRegister_EVM(t *testing.T) { gas_price_rollapp1 := "0adym" maxIdleTime1 := "3s" maxProofTime := "500ms" - configFileOverrides := overridesDymintToml(settlement_layer_rollapp1, settlement_node_address, rollapp1_id, gas_price_rollapp1, maxIdleTime1, maxProofTime, "100s") + configFileOverrides := overridesDymintToml(settlement_layer_rollapp1, settlement_node_address, rollapp1_id, gas_price_rollapp1, maxIdleTime1, maxProofTime, "50s") // Create chain factory with dymension numHubVals := 1 @@ -45,21 +45,6 @@ func TestERC20HubToRollAppWithoutRegister_EVM(t *testing.T) { numRollAppFn := 0 numRollAppVals := 1 - // Enable erc20 - modifyRollappGeneisKV := append( - rollappEVMGenesisKV, - cosmos.GenesisKV{ - Key: "app_state.erc20.params.enable_erc20", - Value: true, - }, - ) - modifyGenesisKV := append( - dymensionGenesisKV, - cosmos.GenesisKV{ - Key: "app_state.rollapp.params.dispute_period_in_blocks", - Value: fmt.Sprint(BLOCK_FINALITY_PERIOD), - }, - ) cf := test.NewBuiltinChainFactory(zaptest.NewLogger(t), []*test.ChainSpec{ { Name: "rollapp1", @@ -77,7 +62,7 @@ func TestERC20HubToRollAppWithoutRegister_EVM(t *testing.T) { TrustingPeriod: "112h", EncodingConfig: encodingConfig(), NoHostMount: false, - ModifyGenesis: modifyRollappEVMGenesis(modifyRollappGeneisKV), + ModifyGenesis: modifyRollappEVMGenesis(rollappEVMGenesisKV), ConfigFileOverrides: configFileOverrides, }, NumValidators: &numRollAppVals, @@ -99,7 +84,7 @@ func TestERC20HubToRollAppWithoutRegister_EVM(t *testing.T) { GasAdjustment: 1.1, TrustingPeriod: "112h", NoHostMount: false, - ModifyGenesis: modifyDymensionGenesis(modifyGenesisKV), + ModifyGenesis: modifyDymensionGenesis(dymensionGenesisKV), ConfigFileOverrides: nil, }, NumValidators: &numHubVals, @@ -142,7 +127,7 @@ func TestERC20HubToRollAppWithoutRegister_EVM(t *testing.T) { // This can be used to write to the block database which will index all block data e.g. txs, msgs, events, etc. // BlockDatabaseFile: test.DefaultBlockDatabaseFilepath(), - }, nil, "", nil) + }, nil, "", nil, false, 780) require.NoError(t, err) CreateChannel(ctx, t, r1, eRep, dymension.CosmosChain, rollapp1.CosmosChain, ibcPath) @@ -183,9 +168,6 @@ func TestERC20HubToRollAppWithoutRegister_EVM(t *testing.T) { _, err = rollapp1.SendIBCTransfer(ctx, channel.ChannelID, rollappUserAddr, transferData, ibc.TransferOptions{}) require.NoError(t, err) - rollappHeight, err := rollapp1.GetNode().Height(ctx) - require.NoError(t, err) - // get eIbc event eibcEvents, err := getEIbcEventsWithinBlockRange(ctx, dymension, 10, false) require.NoError(t, err) @@ -198,11 +180,17 @@ func TestERC20HubToRollAppWithoutRegister_EVM(t *testing.T) { // Assert balance was updated on the hub testutil.AssertBalance(t, ctx, rollapp1, rollappUserAddr, rollapp1.Config().Denom, walletAmount.Sub(transferData.Amount)) + rollappHeight, err := rollapp1.GetNode().Height(ctx) + require.NoError(t, err) + // wait until the packet is finalized isFinalized, err := dymension.WaitUntilRollappHeightIsFinalized(ctx, rollapp1.GetChainID(), rollappHeight, 300) require.NoError(t, err) require.True(t, isFinalized) + _, err = dymension.GetNode().FinalizePacketsUntilHeight(ctx, dymensionUserAddr, rollapp1.GetChainID(), fmt.Sprint(rollappHeight)) + require.NoError(t, err) + transferData = ibc.WalletData{ Address: rollappUserAddr, Denom: dymension.Config().Denom, @@ -234,6 +222,10 @@ func TestERC20HubToRollAppWithoutRegister_EVM(t *testing.T) { isFinalized, err = dymension.WaitUntilRollappHeightIsFinalized(ctx, rollapp1.GetChainID(), rollappHeight, 300) require.NoError(t, err) require.True(t, isFinalized) + + err = testutil.WaitForBlocks(ctx, 10, dymension, rollapp1) + require.NoError(t, err) + erc20MAcc, err := rollapp1.Validators[0].QueryModuleAccount(ctx, "erc20") require.NoError(t, err) erc20MAccAddr := erc20MAcc.Account.BaseAccount.Address @@ -251,6 +243,9 @@ func TestERC20HubToRollAppWithoutRegister_EVM(t *testing.T) { } }, ) + + // Run invariant check + CheckInvariant(t, ctx, dymension, dymensionUser.KeyName()) } func TestERC20RollAppToHubWithRegister_EVM(t *testing.T) { @@ -261,13 +256,18 @@ func TestERC20RollAppToHubWithRegister_EVM(t *testing.T) { ctx := context.Background() // setup config for rollapp - settlement_layer_rollapp1 := "dymension" - settlement_node_address := fmt.Sprintf("http://dymension_100-1-val-0-%s:26657", t.Name()) - rollapp1_id := "rollappevm_1234-1" - gas_price_rollapp1 := "0adym" - maxIdleTime1 := "3s" - maxProofTime := "500ms" - configFileOverrides := overridesDymintToml(settlement_layer_rollapp1, settlement_node_address, rollapp1_id, gas_price_rollapp1, maxIdleTime1, maxProofTime, "100s") + configFileOverrides := make(map[string]any) + dymintTomlOverrides := make(testutil.Toml) + dymintTomlOverrides["settlement_layer"] = "dymension" + dymintTomlOverrides["settlement_node_address"] = fmt.Sprintf("http://dymension_100-1-val-0-%s:26657", t.Name()) + dymintTomlOverrides["rollapp_id"] = "rollappevm_1234-1" + dymintTomlOverrides["settlement_gas_prices"] = "0adym" + dymintTomlOverrides["max_idle_time"] = "3s" + dymintTomlOverrides["max_proof_time"] = "500ms" + dymintTomlOverrides["batch_submit_time"] = "50s" + dymintTomlOverrides["p2p_blocksync_enabled"] = "false" + + configFileOverrides["config/dymint.toml"] = dymintTomlOverrides // Create chain factory with dymension numHubVals := 1 @@ -275,21 +275,6 @@ func TestERC20RollAppToHubWithRegister_EVM(t *testing.T) { numRollAppFn := 0 numRollAppVals := 1 - // Enable erc20 - modifyRollappGeneisKV := append( - rollappEVMGenesisKV, - cosmos.GenesisKV{ - Key: "app_state.erc20.params.enable_erc20", - Value: true, - }, - ) - modifyGenesisKV := append( - dymensionGenesisKV, - cosmos.GenesisKV{ - Key: "app_state.rollapp.params.dispute_period_in_blocks", - Value: fmt.Sprint(BLOCK_FINALITY_PERIOD), - }, - ) cf := test.NewBuiltinChainFactory(zaptest.NewLogger(t), []*test.ChainSpec{ { Name: "rollapp1", @@ -307,7 +292,7 @@ func TestERC20RollAppToHubWithRegister_EVM(t *testing.T) { TrustingPeriod: "112h", EncodingConfig: encodingConfig(), NoHostMount: false, - ModifyGenesis: modifyRollappEVMGenesis(modifyRollappGeneisKV), + ModifyGenesis: modifyRollappEVMGenesis(rollappEVMGenesisKV), ConfigFileOverrides: configFileOverrides, }, NumValidators: &numRollAppVals, @@ -329,7 +314,7 @@ func TestERC20RollAppToHubWithRegister_EVM(t *testing.T) { GasAdjustment: 1.1, TrustingPeriod: "112h", NoHostMount: false, - ModifyGenesis: modifyDymensionGenesis(modifyGenesisKV), + ModifyGenesis: modifyDymensionGenesis(dymensionGenesisKV), ConfigFileOverrides: nil, }, NumValidators: &numHubVals, @@ -371,7 +356,7 @@ func TestERC20RollAppToHubWithRegister_EVM(t *testing.T) { // This can be used to write to the block database which will index all block data e.g. txs, msgs, events, etc. // BlockDatabaseFile: test.DefaultBlockDatabaseFilepath(), - }, nil, "", nil) + }, nil, "", nil, false, 780) require.NoError(t, err) CreateChannel(ctx, t, r1, eRep, dymension.CosmosChain, rollapp1.CosmosChain, ibcPath) @@ -406,6 +391,9 @@ func TestERC20RollAppToHubWithRegister_EVM(t *testing.T) { _, err = rollapp1.SendIBCTransfer(ctx, channel.ChannelID, rollappUserAddr, transferData, ibc.TransferOptions{}) require.NoError(t, err) + err = testutil.WaitForBlocks(ctx, 10, dymension, rollapp1) + require.NoError(t, err) + rollappHeight, err := rollapp1.GetNode().Height(ctx) require.NoError(t, err) @@ -417,6 +405,12 @@ func TestERC20RollAppToHubWithRegister_EVM(t *testing.T) { require.NoError(t, err) require.True(t, isFinalized) + _, err = dymension.GetNode().FinalizePacketsUntilHeight(ctx, dymensionUserAddr, rollapp1.GetChainID(), fmt.Sprint(rollappHeight)) + require.NoError(t, err) + + err = testutil.WaitForBlocks(ctx, 10, dymension, rollapp1) + require.NoError(t, err) + // Compose an IBC transfer and send from dymension -> rollapp transferData = ibc.WalletData{ Address: rollappUserAddr, @@ -498,7 +492,7 @@ func TestERC20RollAppToHubWithRegister_EVM(t *testing.T) { require.NotNil(t, tokenPair) // convert erc20 - _, err = rollapp1.GetNode().ConvertErc20(ctx, rollappUser.KeyName(), tokenPair.Erc20Address, transferAmount.String(), rollappUserAddr, rollappUserAddr, rollapp1_id) + _, err = rollapp1.GetNode().ConvertErc20(ctx, rollappUser.KeyName(), tokenPair.Erc20Address, transferAmount.String(), rollappUserAddr, rollappUserAddr, rollapp1.Config().ChainID) require.NoError(t, err, "can not convert erc20 to cosmos coin") err = testutil.WaitForBlocks(ctx, 5, dymension, rollapp1) @@ -517,6 +511,10 @@ func TestERC20RollAppToHubWithRegister_EVM(t *testing.T) { // Compose an IBC transfer and send from rollapp -> Hub _, err = rollapp1.SendIBCTransfer(ctx, channel.ChannelID, rollappUserAddr, transferData, ibc.TransferOptions{}) require.NoError(t, err) + + err = testutil.WaitForBlocks(ctx, 10, dymension, rollapp1) + require.NoError(t, err) + rollappHeight, err = rollapp1.GetNode().Height(ctx) require.NoError(t, err) testutil.AssertBalance(t, ctx, rollapp1, rollappUserAddr, dymensionIBCDenom, zeroBal) @@ -525,6 +523,13 @@ func TestERC20RollAppToHubWithRegister_EVM(t *testing.T) { isFinalized, err = dymension.WaitUntilRollappHeightIsFinalized(ctx, rollapp1.GetChainID(), rollappHeight, 300) require.NoError(t, err) require.True(t, isFinalized) + + _, err = dymension.GetNode().FinalizePacketsUntilHeight(ctx, dymensionUserAddr, rollapp1.GetChainID(), fmt.Sprint(rollappHeight)) + require.NoError(t, err) + + err = testutil.WaitForBlocks(ctx, 10, dymension, rollapp1) + require.NoError(t, err) + // check balance on dym and rollapp after transfer testutil.AssertBalance(t, ctx, rollapp1, rollappUserAddr, dymensionIBCDenom, zeroBal) testutil.AssertBalance(t, ctx, dymension, dymensionUserAddr, dymension.Config().Denom, walletAmount.Sub(bridgeFee)) @@ -537,4 +542,7 @@ func TestERC20RollAppToHubWithRegister_EVM(t *testing.T) { } }, ) + + // Run invariant check + CheckInvariant(t, ctx, dymension, dymensionUser.KeyName()) } diff --git a/tests/frozen_test.go b/tests/frozen_test.go index 4ecad76f..af80d7a1 100644 --- a/tests/frozen_test.go +++ b/tests/frozen_test.go @@ -22,14 +22,6 @@ import ( "github.com/decentrio/rollup-e2e-testing/testutil" ) -var dymModifyGenesisKV = append( - dymensionGenesisKV, - cosmos.GenesisKV{ - Key: "app_state.rollapp.params.dispute_period_in_blocks", - Value: "20", - }, -) - var extraFlags = map[string]interface{}{"genesis-accounts-path": true} // TestRollAppFreeze ensure upon freeze gov proposal passed, no updates can be made to the rollapp and not IBC txs are passing. @@ -47,14 +39,14 @@ func TestRollAppFreeze_EVM(t *testing.T) { gas_price_rollapp1 := "0adym" maxIdleTime1 := "3s" maxProofTime := "500ms" - configFileOverrides1 := overridesDymintToml(settlement_layer_rollapp1, settlement_node_address, rollapp1_id, gas_price_rollapp1, maxIdleTime1, maxProofTime, "100s") + configFileOverrides1 := overridesDymintToml(settlement_layer_rollapp1, settlement_node_address, rollapp1_id, gas_price_rollapp1, maxIdleTime1, maxProofTime, "50s") // setup config for rollapp 2 settlement_layer_rollapp2 := "dymension" rollapp2_id := "decentrio_12345-1" gas_price_rollapp2 := "0adym" maxIdleTime2 := "3s" - configFileOverrides2 := overridesDymintToml(settlement_layer_rollapp2, settlement_node_address, rollapp2_id, gas_price_rollapp2, maxIdleTime2, maxProofTime, "100s") + configFileOverrides2 := overridesDymintToml(settlement_layer_rollapp2, settlement_node_address, rollapp2_id, gas_price_rollapp2, maxIdleTime2, maxProofTime, "50s") // Create chain factory with dymension numHubVals := 1 @@ -123,7 +115,7 @@ func TestRollAppFreeze_EVM(t *testing.T) { GasAdjustment: 1.1, TrustingPeriod: "112h", NoHostMount: false, - ModifyGenesis: modifyDymensionGenesis(dymModifyGenesisKV), + ModifyGenesis: modifyDymensionGenesis(dymensionGenesisKV), ConfigFileOverrides: nil, }, NumValidators: &numHubVals, @@ -180,7 +172,7 @@ func TestRollAppFreeze_EVM(t *testing.T) { // This can be used to write to the block database which will index all block data e.g. txs, msgs, events, etc. // BlockDatabaseFile: test.DefaultBlockDatabaseFilepath(), - }, nil, "", nil) + }, nil, "", nil, false, 780) require.NoError(t, err) CreateChannel(ctx, t, r1, eRep, dymension.CosmosChain, rollapp1.CosmosChain, ibcPath) @@ -260,6 +252,9 @@ func TestRollAppFreeze_EVM(t *testing.T) { _, err = rollapp1.SendIBCTransfer(ctx, channsRollApp1Dym.ChannelID, rollappUserAddr, transferData, ibc.TransferOptions{}) require.NoError(t, err) + err = testutil.WaitForBlocks(ctx, 10, dymension, rollapp1) + require.NoError(t, err) + rollappHeight, err := rollapp1.GetNode().Height(ctx) require.NoError(t, err) @@ -271,6 +266,9 @@ func TestRollAppFreeze_EVM(t *testing.T) { require.NoError(t, err) require.True(t, isFinalized) + _, err = dymension.GetNode().FinalizePacketsUntilHeight(ctx, dymensionUserAddr, rollapp1.GetChainID(), fmt.Sprint(rollappHeight)) + require.NoError(t, err) + oldLatestIndex, err := dymension.GetNode().QueryLatestStateIndex(ctx, rollapp1.Config().ChainID) require.NoError(t, err) @@ -363,8 +361,8 @@ func TestRollAppFreeze_EVM(t *testing.T) { _, err = rollapp1.SendIBCTransfer(ctx, channsRollApp1Dym.ChannelID, rollappUserAddr, transferData, ibc.TransferOptions{}) require.NoError(t, err) - // Wait a few blocks - err = testutil.WaitForBlocks(ctx, 20, dymension) + err = testutil.WaitForBlocks(ctx, 30, dymension) + require.NoError(t, err) // Get updated dym hub ibc denom balance dymUserUpdateBal, err := dymension.GetBalance(ctx, dymensionUserAddr, rollapp1IbcDenom) @@ -372,6 +370,9 @@ func TestRollAppFreeze_EVM(t *testing.T) { // IBC balance should not change require.Equal(t, dymUserOriginBal, dymUserUpdateBal, "dym hub still get transfer from frozen rollapp") + + // Run invariant check + CheckInvariant(t, ctx, dymension, dymensionUser.KeyName()) } // TestRollAppFreeze ensure upon freeze gov proposal passed, no updates can be made to the rollapp and not IBC txs are passing. @@ -389,14 +390,14 @@ func TestRollAppFreeze_Wasm(t *testing.T) { gas_price_rollapp1 := "0adym" maxIdleTime1 := "3s" maxProofTime := "500ms" - configFileOverrides1 := overridesDymintToml(settlement_layer_rollapp1, settlement_node_address, rollapp1_id, gas_price_rollapp1, maxIdleTime1, maxProofTime, "100s") + configFileOverrides1 := overridesDymintToml(settlement_layer_rollapp1, settlement_node_address, rollapp1_id, gas_price_rollapp1, maxIdleTime1, maxProofTime, "50s") // setup config for rollapp 2 settlement_layer_rollapp2 := "dymension" rollapp2_id := "decentrio_12345-1" gas_price_rollapp2 := "0adym" maxIdleTime2 := "3s" - configFileOverrides2 := overridesDymintToml(settlement_layer_rollapp2, settlement_node_address, rollapp2_id, gas_price_rollapp2, maxIdleTime2, maxProofTime, "100s") + configFileOverrides2 := overridesDymintToml(settlement_layer_rollapp2, settlement_node_address, rollapp2_id, gas_price_rollapp2, maxIdleTime2, maxProofTime, "50s") // Create chain factory with dymension numHubVals := 1 @@ -464,7 +465,7 @@ func TestRollAppFreeze_Wasm(t *testing.T) { GasAdjustment: 1.1, TrustingPeriod: "112h", NoHostMount: false, - ModifyGenesis: modifyDymensionGenesis(dymModifyGenesisKV), + ModifyGenesis: modifyDymensionGenesis(dymensionGenesisKV), ConfigFileOverrides: nil, }, NumValidators: &numHubVals, @@ -521,7 +522,7 @@ func TestRollAppFreeze_Wasm(t *testing.T) { // This can be used to write to the block database which will index all block data e.g. txs, msgs, events, etc. // BlockDatabaseFile: test.DefaultBlockDatabaseFilepath(), - }, nil, "", nil) + }, nil, "", nil, false, 780) require.NoError(t, err) CreateChannel(ctx, t, r1, eRep, dymension.CosmosChain, rollapp1.CosmosChain, ibcPath) @@ -606,6 +607,9 @@ func TestRollAppFreeze_Wasm(t *testing.T) { _, err = rollapp1.SendIBCTransfer(ctx, channsRollApp1Dym.ChannelID, rollappUserAddr, transferData, ibc.TransferOptions{}) require.NoError(t, err) + err = testutil.WaitForBlocks(ctx, 10, dymension, rollapp1) + require.NoError(t, err) + rollappHeight, err := rollapp1.GetNode().Height(ctx) require.NoError(t, err) @@ -617,6 +621,9 @@ func TestRollAppFreeze_Wasm(t *testing.T) { require.NoError(t, err) require.True(t, isFinalized) + _, err = dymension.GetNode().FinalizePacketsUntilHeight(ctx, dymensionUserAddr, rollapp1.GetChainID(), fmt.Sprint(rollappHeight)) + require.NoError(t, err) + oldLatestIndex, err := dymension.GetNode().QueryLatestStateIndex(ctx, rollapp1.Config().ChainID) require.NoError(t, err) @@ -731,6 +738,9 @@ func TestRollAppFreeze_Wasm(t *testing.T) { _, err = rollapp1.SendIBCTransfer(ctx, channsRollApp1Dym.ChannelID, rollappUserAddr, transferData, ibc.TransferOptions{}) require.NoError(t, err) + err = testutil.WaitForBlocks(ctx, 10, dymension, rollapp1) + require.NoError(t, err) + // Wait a few blocks err = testutil.WaitForBlocks(ctx, 20, dymension) @@ -740,6 +750,8 @@ func TestRollAppFreeze_Wasm(t *testing.T) { // IBC balance should not change require.Equal(t, dymUserOriginBal, dymUserUpdateBal, "dym hub still get transfer from frozen rollapp") + // Run invariant check + CheckInvariant(t, ctx, dymension, dymensionUser.KeyName()) } // TestOtherRollappNotAffected_EVM ensure upon freeze gov proposal passed, no updates can be made to the rollapp and not IBC txs are passing and other rollapp works fine. @@ -757,14 +769,14 @@ func TestOtherRollappNotAffected_EVM(t *testing.T) { gas_price_rollapp1 := "0adym" maxIdleTime1 := "10s" maxProofTime := "500ms" - configFileOverrides1 := overridesDymintToml(settlement_layer_rollapp1, settlement_node_address, rollapp1_id, gas_price_rollapp1, maxIdleTime1, maxProofTime, "100s") + configFileOverrides1 := overridesDymintToml(settlement_layer_rollapp1, settlement_node_address, rollapp1_id, gas_price_rollapp1, maxIdleTime1, maxProofTime, "50s") // setup config for rollapp 2 settlement_layer_rollapp2 := "dymension" rollapp2_id := "decentrio_12345-1" gas_price_rollapp2 := "0adym" maxIdleTime2 := "1s" - configFileOverrides2 := overridesDymintToml(settlement_layer_rollapp2, settlement_node_address, rollapp2_id, gas_price_rollapp2, maxIdleTime2, maxProofTime, "100s") + configFileOverrides2 := overridesDymintToml(settlement_layer_rollapp2, settlement_node_address, rollapp2_id, gas_price_rollapp2, maxIdleTime2, maxProofTime, "50s") // Create chain factory with dymension numHubVals := 1 @@ -832,7 +844,7 @@ func TestOtherRollappNotAffected_EVM(t *testing.T) { GasAdjustment: 1.1, TrustingPeriod: "112h", NoHostMount: false, - ModifyGenesis: modifyDymensionGenesis(dymModifyGenesisKV), + ModifyGenesis: modifyDymensionGenesis(dymensionGenesisKV), ConfigFileOverrides: nil, }, NumValidators: &numHubVals, @@ -888,7 +900,7 @@ func TestOtherRollappNotAffected_EVM(t *testing.T) { // This can be used to write to the block database which will index all block data e.g. txs, msgs, events, etc. // BlockDatabaseFile: test.DefaultBlockDatabaseFilepath(), - }, nil, "", nil) + }, nil, "", nil, false, 780) require.NoError(t, err) CreateChannel(ctx, t, r, eRep, dymension.CosmosChain, rollapp1.CosmosChain, ibcPath) @@ -991,6 +1003,9 @@ func TestOtherRollappNotAffected_EVM(t *testing.T) { _, err = rollapp2.SendIBCTransfer(ctx, channsRollApp2Dym.ChannelID, rollapp2UserAddr, transferData, ibc.TransferOptions{}) require.NoError(t, err) + err = testutil.WaitForBlocks(ctx, 10, dymension, rollapp1) + require.NoError(t, err) + rollappHeight, err := rollapp1.GetNode().Height(ctx) require.NoError(t, err) @@ -1006,6 +1021,11 @@ func TestOtherRollappNotAffected_EVM(t *testing.T) { require.NoError(t, err) require.True(t, isFinalized) + _, err = dymension.GetNode().FinalizePacketsUntilHeight(ctx, dymensionUserAddr, rollapp1.GetChainID(), fmt.Sprint(rollappHeight)) + require.NoError(t, err) + _, err = dymension.GetNode().FinalizePacketsUntilHeight(ctx, dymensionUserAddr, rollapp2.GetChainID(), fmt.Sprint(rollapp2Height)) + require.NoError(t, err) + oldLatestIndex, err := dymension.GetNode().QueryLatestStateIndex(ctx, rollapp1.Config().ChainID) require.NoError(t, err) @@ -1105,7 +1125,7 @@ func TestOtherRollappNotAffected_EVM(t *testing.T) { require.NoError(t, err) // Wait a few blocks - err = testutil.WaitForBlocks(ctx, 20, dymension) + err = testutil.WaitForBlocks(ctx, 30, dymension) // Get updated dym hub ibc denom balance dymUserUpdateBal, err := dymension.GetBalance(ctx, dymensionUserAddr, rollapp1IbcDenom) @@ -1116,6 +1136,8 @@ func TestOtherRollappNotAffected_EVM(t *testing.T) { // Check other rollapp state index still increase rollapp2IndexLater, err := dymension.GetNode().QueryLatestStateIndex(ctx, rollapp2.Config().ChainID) + fmt.Println(rollapp2IndexLater.StateIndex.Index) + fmt.Println(rollapp2Index.StateIndex.Index) require.NoError(t, err) require.True(t, rollapp2IndexLater.StateIndex.Index > rollapp2Index.StateIndex.Index, "Another rollapp got freeze") @@ -1154,6 +1176,8 @@ func TestOtherRollappNotAffected_EVM(t *testing.T) { require.NoError(t, err) require.NotEmpty(t, tx.TxHash, "tx is nil") + testutil.WaitForBlocks(ctx, 10, dymension, rollapp2) + rollappHeight, err = rollapp2.Height(ctx) require.NoError(t, err) @@ -1162,11 +1186,18 @@ func TestOtherRollappNotAffected_EVM(t *testing.T) { require.NoError(t, err) require.True(t, isFinalized) + _, err = dymension.GetNode().FinalizePacketsUntilHeight(ctx, dymensionUserAddr, rollapp2.GetChainID(), fmt.Sprint(rollapp2Height)) + require.NoError(t, err) + + testutil.WaitForBlocks(ctx, 10, dymension, rollapp2) + // Get updated dym hub ibc denom balance dymUserUpdateBal2, err := dymension.GetBalance(ctx, dymensionUserAddr, rollapp2IbcDenom) require.NoError(t, err) require.Equal(t, true, dymUserUpdateBal2.Equal(dymUserOriginBal2.Add(transferAmount).Sub(bridgingFee)), "dym hub balance did not change") + // Run invariant check + CheckInvariant(t, ctx, dymension, dymensionUser.KeyName()) } // TestOtherRollappNotAffected_Wasm ensure upon freeze gov proposal passed, no updates can be made to the rollapp and not IBC txs are passing and other rollapp works fine. @@ -1185,7 +1216,8 @@ func TestOtherRollappNotAffected_Wasm(t *testing.T) { dymintTomlOverrides["settlement_gas_prices"] = "0adym" dymintTomlOverrides["max_idle_time"] = "3s" dymintTomlOverrides["max_proof_time"] = "500ms" - dymintTomlOverrides["batch_submit_max_time"] = "100s" + dymintTomlOverrides["batch_submit_time"] = "50s" + dymintTomlOverrides["p2p_blocksync_enabled"] = "false" configFileOverrides["config/dymint.toml"] = dymintTomlOverrides @@ -1197,7 +1229,8 @@ func TestOtherRollappNotAffected_Wasm(t *testing.T) { dymintTomlOverrides2["settlement_gas_prices"] = "0adym" dymintTomlOverrides2["max_proof_time"] = "500ms" dymintTomlOverrides2["max_idle_time"] = "3s" - dymintTomlOverrides2["batch_submit_max_time"] = "100s" + dymintTomlOverrides2["batch_submit_time"] = "50s" + dymintTomlOverrides2["p2p_blocksync_enabled"] = "false" configFileOverrides2["config/dymint.toml"] = dymintTomlOverrides2 // Create chain factory with dymension @@ -1266,7 +1299,7 @@ func TestOtherRollappNotAffected_Wasm(t *testing.T) { GasAdjustment: 1.1, TrustingPeriod: "112h", NoHostMount: false, - ModifyGenesis: modifyDymensionGenesis(dymModifyGenesisKV), + ModifyGenesis: modifyDymensionGenesis(dymensionGenesisKV), ConfigFileOverrides: nil, }, NumValidators: &numHubVals, @@ -1322,7 +1355,7 @@ func TestOtherRollappNotAffected_Wasm(t *testing.T) { // This can be used to write to the block database which will index all block data e.g. txs, msgs, events, etc. // BlockDatabaseFile: test.DefaultBlockDatabaseFilepath(), - }, nil, "", nil) + }, nil, "", nil, false, 780) require.NoError(t, err) CreateChannel(ctx, t, r, eRep, dymension.CosmosChain, rollapp1.CosmosChain, ibcPath) @@ -1425,6 +1458,9 @@ func TestOtherRollappNotAffected_Wasm(t *testing.T) { _, err = rollapp2.SendIBCTransfer(ctx, channsRollApp2Dym.ChannelID, rollapp2UserAddr, transferData, ibc.TransferOptions{}) require.NoError(t, err) + err = testutil.WaitForBlocks(ctx, 10, dymension, rollapp1) + require.NoError(t, err) + rollappHeight, err := rollapp1.GetNode().Height(ctx) require.NoError(t, err) @@ -1440,6 +1476,12 @@ func TestOtherRollappNotAffected_Wasm(t *testing.T) { require.NoError(t, err) require.True(t, isFinalized) + _, err = dymension.GetNode().FinalizePacketsUntilHeight(ctx, dymensionUserAddr, rollapp1.GetChainID(), fmt.Sprint(rollappHeight)) + require.NoError(t, err) + + _, err = dymension.GetNode().FinalizePacketsUntilHeight(ctx, dymensionUserAddr, rollapp2.GetChainID(), fmt.Sprint(rollapp2Height)) + require.NoError(t, err) + oldLatestIndex, err := dymension.GetNode().QueryLatestStateIndex(ctx, rollapp1.Config().ChainID) require.NoError(t, err) @@ -1591,6 +1633,8 @@ func TestOtherRollappNotAffected_Wasm(t *testing.T) { require.NoError(t, err) require.NotEmpty(t, tx.TxHash, "tx is nil") + testutil.WaitForBlocks(ctx, 10, dymension) + rollapp2Height, err = rollapp2.Height(ctx) require.NoError(t, err) @@ -1599,12 +1643,17 @@ func TestOtherRollappNotAffected_Wasm(t *testing.T) { require.NoError(t, err) require.True(t, isFinalized) + _, err = dymension.GetNode().FinalizePacketsUntilHeight(ctx, dymensionUserAddr, rollapp2.GetChainID(), fmt.Sprint(rollapp2Height)) + require.NoError(t, err) + // Get updated dym hub ibc denom balance dymUserUpdateBal2, err := dymension.GetBalance(ctx, dymensionUserAddr, rollapp2IbcDenom) require.NoError(t, err) // Minus 0.1% for bridge fee require.Equal(t, true, dymUserUpdateBal2.Equal(dymUserOriginBal2.Add(transferAmount.Sub(transferAmount.Quo(math.NewInt(1000))))), "dym hub balance did not change") + // Run invariant check + CheckInvariant(t, ctx, dymension, dymensionUser.KeyName()) } // TestPacketRollbacked_EVM ensure upon freeze gov proposal passed, ibc-transfer that not yet finalized's packets will be reverted. @@ -1622,7 +1671,7 @@ func TestPacketRollbacked_EVM(t *testing.T) { gas_price_rollapp1 := "0adym" maxIdleTime1 := "3s" maxProofTime := "500ms" - configFileOverrides1 := overridesDymintToml(settlement_layer_rollapp1, settlement_node_address, rollapp1_id, gas_price_rollapp1, maxIdleTime1, maxProofTime, "30s") + configFileOverrides1 := overridesDymintToml(settlement_layer_rollapp1, settlement_node_address, rollapp1_id, gas_price_rollapp1, maxIdleTime1, maxProofTime, "50s") // Create chain factory with dymension numHubVals := 1 @@ -1668,7 +1717,7 @@ func TestPacketRollbacked_EVM(t *testing.T) { GasAdjustment: 1.1, TrustingPeriod: "112h", NoHostMount: false, - ModifyGenesis: modifyDymensionGenesis(dymModifyGenesisKV), + ModifyGenesis: modifyDymensionGenesis(dymensionGenesisKV), ConfigFileOverrides: nil, }, NumValidators: &numHubVals, @@ -1712,7 +1761,7 @@ func TestPacketRollbacked_EVM(t *testing.T) { // This can be used to write to the block database which will index all block data e.g. txs, msgs, events, etc. // BlockDatabaseFile: test.DefaultBlockDatabaseFilepath(), - }, nil, "", nil) + }, nil, "", nil, false, 780) require.NoError(t, err) CreateChannel(ctx, t, r, eRep, dymension.CosmosChain, rollapp1.CosmosChain, ibcPath) @@ -1765,6 +1814,9 @@ func TestPacketRollbacked_EVM(t *testing.T) { _, err = rollapp1.SendIBCTransfer(ctx, channsRollApp1Dym.ChannelID, rollapp1UserAddr, transferData, ibc.TransferOptions{}) require.NoError(t, err) + err = testutil.WaitForBlocks(ctx, 10, dymension, rollapp1) + require.NoError(t, err) + rollappHeight, err := rollapp1.GetNode().Height(ctx) require.NoError(t, err) @@ -1773,6 +1825,9 @@ func TestPacketRollbacked_EVM(t *testing.T) { require.NoError(t, err) require.True(t, isFinalized) + _, err = dymension.GetNode().FinalizePacketsUntilHeight(ctx, dymensionUserAddr, rollapp1.GetChainID(), fmt.Sprint(rollappHeight)) + require.NoError(t, err) + // Confirm previous ibc transfers were successful (dymension -> rollapp1) // Get the IBC denom rollapp1IbcDenom := GetIBCDenom(channsRollApp1Dym.Counterparty.PortID, channsRollApp1Dym.Counterparty.ChannelID, rollapp1.Config().Denom) @@ -1885,9 +1940,20 @@ func TestPacketRollbacked_EVM(t *testing.T) { // SEND IBC transfer right before vote dymUserOriginBal, err := dymension.GetBalance(ctx, dymensionUserAddr, dymension.Config().Denom) + require.NoError(t, err) _, err = dymension.SendIBCTransfer(ctx, channDymRollApp1.ChannelID, dymensionUserAddr, transferDataFromDym, ibc.TransferOptions{}) require.NoError(t, err) + err = testutil.WaitForBlocks(ctx, 10, dymension) + require.NoError(t, err) + + rollappHeight, err = rollapp1.GetNode().Height(ctx) + require.NoError(t, err) + + isFinalized, err = dymension.WaitUntilRollappHeightIsFinalized(ctx, rollapp1.GetChainID(), rollappHeight, 600) + require.NoError(t, err) + require.True(t, isFinalized) + // Submit fraud proposal propTx, err := dymension.SubmitFraudProposal(ctx, dymensionUser.KeyName(), rollapp1.Config().ChainID, fraudHeight, sequencerAddr, rollapp1ClientOnDym, submitFraudStr, submitFraudStr, deposit) require.NoError(t, err) @@ -1902,9 +1968,18 @@ func TestPacketRollbacked_EVM(t *testing.T) { require.NoError(t, err, "proposal status did not change to passed") latestIndex, err := dymension.GetNode().QueryLatestStateIndex(ctx, rollapp1.Config().ChainID) - testutil.WaitForBlocks(ctx, 10, dymension, rollapp1) + require.NoError(t, err) + + _, err = dymension.GetNode().FinalizePacketsUntilHeight(ctx, dymensionUserAddr, rollapp1.GetChainID(), fmt.Sprint(rollappHeight)) + require.NoError(t, err) + + err = testutil.WaitForBlocks(ctx, 10, dymension) + require.NoError(t, err) + // after Grace period, the latest index should be the same lalatestIndex, err := dymension.GetNode().QueryLatestStateIndex(ctx, rollapp1.Config().ChainID) + require.NoError(t, err) + require.Equal(t, latestIndex, lalatestIndex, "rollapp state index still increment after grace period. Rerun") // Check if rollapp1 has frozen or not @@ -1918,7 +1993,10 @@ func TestPacketRollbacked_EVM(t *testing.T) { // After rollapp frozen, fund should return dymUserUpdateBal, err := dymension.GetBalance(ctx, dymensionUserAddr, dymension.Config().Denom) + require.NoError(t, err) require.Equal(t, dymUserOriginBal, dymUserUpdateBal, "funds aren't sent back to sender") + // Run invariant check + CheckInvariant(t, ctx, dymension, dymensionUser.KeyName()) } // TestPacketRollbacked_Wasm ensure upon freeze gov proposal passed, ibc-transfer that not yet finalized's packets will be reverted. @@ -1936,7 +2014,7 @@ func TestPacketRollbacked_Wasm(t *testing.T) { gas_price_rollapp1 := "0adym" maxIdleTime1 := "3s" maxProofTime := "500ms" - configFileOverrides1 := overridesDymintToml(settlement_layer_rollapp1, settlement_node_address, rollapp1_id, gas_price_rollapp1, maxIdleTime1, maxProofTime, "30s") + configFileOverrides1 := overridesDymintToml(settlement_layer_rollapp1, settlement_node_address, rollapp1_id, gas_price_rollapp1, maxIdleTime1, maxProofTime, "50s") // Create chain factory with dymension numHubVals := 1 @@ -1982,7 +2060,7 @@ func TestPacketRollbacked_Wasm(t *testing.T) { GasAdjustment: 1.1, TrustingPeriod: "112h", NoHostMount: false, - ModifyGenesis: modifyDymensionGenesis(dymModifyGenesisKV), + ModifyGenesis: modifyDymensionGenesis(dymensionGenesisKV), ConfigFileOverrides: nil, }, NumValidators: &numHubVals, @@ -2026,7 +2104,7 @@ func TestPacketRollbacked_Wasm(t *testing.T) { // This can be used to write to the block database which will index all block data e.g. txs, msgs, events, etc. // BlockDatabaseFile: test.DefaultBlockDatabaseFilepath(), - }, nil, "", nil) + }, nil, "", nil, false, 780) require.NoError(t, err) CreateChannel(ctx, t, r, eRep, dymension.CosmosChain, rollapp1.CosmosChain, ibcPath) @@ -2093,6 +2171,9 @@ func TestPacketRollbacked_Wasm(t *testing.T) { _, err = rollapp1.SendIBCTransfer(ctx, channsRollApp1Dym.ChannelID, rollapp1UserAddr, transferData, ibc.TransferOptions{}) require.NoError(t, err) + err = testutil.WaitForBlocks(ctx, 10, dymension, rollapp1) + require.NoError(t, err) + rollappHeight, err := rollapp1.GetNode().Height(ctx) require.NoError(t, err) @@ -2101,6 +2182,9 @@ func TestPacketRollbacked_Wasm(t *testing.T) { require.NoError(t, err) require.True(t, isFinalized) + _, err = dymension.GetNode().FinalizePacketsUntilHeight(ctx, dymensionUserAddr, rollapp1.GetChainID(), fmt.Sprint(rollappHeight)) + require.NoError(t, err) + // Confirm previous ibc transfers were successful (dymension -> rollapp1) // Get the IBC denom rollapp1IbcDenom := GetIBCDenom(channsRollApp1Dym.Counterparty.PortID, channsRollApp1Dym.Counterparty.ChannelID, rollapp1.Config().Denom) @@ -2216,6 +2300,16 @@ func TestPacketRollbacked_Wasm(t *testing.T) { _, err = dymension.SendIBCTransfer(ctx, channDymRollApp1.ChannelID, dymensionUserAddr, transferDataFromDym, ibc.TransferOptions{}) require.NoError(t, err) + err = testutil.WaitForBlocks(ctx, 10, dymension) + require.NoError(t, err) + + rollappHeight, err = rollapp1.GetNode().Height(ctx) + require.NoError(t, err) + + isFinalized, err = dymension.WaitUntilRollappHeightIsFinalized(ctx, rollapp1.GetChainID(), rollappHeight, 300) + require.NoError(t, err) + require.True(t, isFinalized) + // Submit fraud proposal propTx, err := dymension.SubmitFraudProposal(ctx, dymensionUser.KeyName(), rollapp1.Config().ChainID, fraudHeight, sequencerAddr, rollapp1ClientOnDym, submitFraudStr, submitFraudStr, deposit) require.NoError(t, err) @@ -2231,7 +2325,11 @@ func TestPacketRollbacked_Wasm(t *testing.T) { latestIndex, err := dymension.GetNode().QueryLatestStateIndex(ctx, rollapp1.Config().ChainID) - testutil.WaitForBlocks(ctx, 10, dymension, rollapp1) + _, err = dymension.GetNode().FinalizePacketsUntilHeight(ctx, dymensionUserAddr, rollapp1.GetChainID(), fmt.Sprint(rollappHeight)) + require.NoError(t, err) + + err = testutil.WaitForBlocks(ctx, 10, dymension) + require.NoError(t, err) // after Grace period, the latest index should be the same lalatestIndex, err := dymension.GetNode().QueryLatestStateIndex(ctx, rollapp1.Config().ChainID) @@ -2248,7 +2346,11 @@ func TestPacketRollbacked_Wasm(t *testing.T) { // After rollapp frozen, fund should return dymUserUpdateBal, err := dymension.GetBalance(ctx, dymensionUserAddr, dymension.Config().Denom) + require.NoError(t, err) require.Equal(t, dymUserOriginBal, dymUserUpdateBal, "funds aren't sent back to sender") + + // Run invariant check + CheckInvariant(t, ctx, dymension, dymensionUser.KeyName()) } // TestRollAppFreezeNoBrokenInvariants_EVM ensure upon freeze gov proposal passed, no updates can be made to the rollapp evm. No invariants broken. @@ -2266,14 +2368,14 @@ func TestRollAppFreezeNoBrokenInvariants_EVM(t *testing.T) { gas_price_rollapp1 := "0adym" maxIdleTime1 := "3s" maxProofTime := "500ms" - configFileOverrides1 := overridesDymintToml(settlement_layer_rollapp1, settlement_node_address, rollapp1_id, gas_price_rollapp1, maxIdleTime1, maxProofTime, "100s") + configFileOverrides1 := overridesDymintToml(settlement_layer_rollapp1, settlement_node_address, rollapp1_id, gas_price_rollapp1, maxIdleTime1, maxProofTime, "50s") // setup config for rollapp 2 settlement_layer_rollapp2 := "dymension" rollapp2_id := "decentrio_12345-1" gas_price_rollapp2 := "0adym" maxIdleTime2 := "3s" - configFileOverrides2 := overridesDymintToml(settlement_layer_rollapp2, settlement_node_address, rollapp2_id, gas_price_rollapp2, maxIdleTime2, maxProofTime, "100s") + configFileOverrides2 := overridesDymintToml(settlement_layer_rollapp2, settlement_node_address, rollapp2_id, gas_price_rollapp2, maxIdleTime2, maxProofTime, "50s") // Create chain factory with dymension numHubVals := 1 @@ -2341,7 +2443,7 @@ func TestRollAppFreezeNoBrokenInvariants_EVM(t *testing.T) { GasAdjustment: 1.1, TrustingPeriod: "112h", NoHostMount: false, - ModifyGenesis: modifyDymensionGenesis(dymModifyGenesisKV), + ModifyGenesis: modifyDymensionGenesis(dymensionGenesisKV), ConfigFileOverrides: nil, }, NumValidators: &numHubVals, @@ -2397,7 +2499,7 @@ func TestRollAppFreezeNoBrokenInvariants_EVM(t *testing.T) { // This can be used to write to the block database which will index all block data e.g. txs, msgs, events, etc. // BlockDatabaseFile: test.DefaultBlockDatabaseFilepath(), - }, nil, "", nil) + }, nil, "", nil, false, 780) require.NoError(t, err) CreateChannel(ctx, t, r, eRep, dymension.CosmosChain, rollapp1.CosmosChain, ibcPath) @@ -2500,6 +2602,9 @@ func TestRollAppFreezeNoBrokenInvariants_EVM(t *testing.T) { _, err = rollapp2.SendIBCTransfer(ctx, channsRollApp2Dym.ChannelID, rollapp2UserAddr, transferData, ibc.TransferOptions{}) require.NoError(t, err) + err = testutil.WaitForBlocks(ctx, 10, dymension, rollapp1) + require.NoError(t, err) + rollappHeight, err := rollapp1.GetNode().Height(ctx) require.NoError(t, err) @@ -2515,6 +2620,12 @@ func TestRollAppFreezeNoBrokenInvariants_EVM(t *testing.T) { require.NoError(t, err) require.True(t, isFinalized) + _, err = dymension.GetNode().FinalizePacketsUntilHeight(ctx, dymensionUserAddr, rollapp1.GetChainID(), fmt.Sprint(rollappHeight)) + require.NoError(t, err) + + _, err = dymension.GetNode().FinalizePacketsUntilHeight(ctx, dymensionUserAddr, rollapp2.GetChainID(), fmt.Sprint(rollapp2Height)) + require.NoError(t, err) + oldLatestIndex, err := dymension.GetNode().QueryLatestStateIndex(ctx, rollapp1.Config().ChainID) require.NoError(t, err) @@ -2584,6 +2695,9 @@ func TestRollAppFreezeNoBrokenInvariants_EVM(t *testing.T) { // Run invariant check _, err = dymension.GetNode().CrisisInvariant(ctx, dymensionUser.KeyName(), "rollapp", "block-height-to-finalization-queue") require.NoError(t, err) + + // Run invariant check + CheckInvariant(t, ctx, dymension, dymensionUser.KeyName()) } // TestRollAppFreezeNoBrokenInvariants_Wasm ensure upon freeze gov proposal passed, no updates can be made to the rollapp wasm. No invariants broken. @@ -2601,14 +2715,14 @@ func TestRollAppFreezeNoBrokenInvariants_Wasm(t *testing.T) { gas_price_rollapp1 := "0adym" maxIdleTime1 := "3s" maxProofTime := "500ms" - configFileOverrides1 := overridesDymintToml(settlement_layer_rollapp1, settlement_node_address, rollapp1_id, gas_price_rollapp1, maxIdleTime1, maxProofTime, "100s") + configFileOverrides1 := overridesDymintToml(settlement_layer_rollapp1, settlement_node_address, rollapp1_id, gas_price_rollapp1, maxIdleTime1, maxProofTime, "50s") // setup config for rollapp 2 settlement_layer_rollapp2 := "dymension" rollapp2_id := "decentrio_12345-1" gas_price_rollapp2 := "0adym" maxIdleTime2 := "3s" - configFileOverrides2 := overridesDymintToml(settlement_layer_rollapp2, settlement_node_address, rollapp2_id, gas_price_rollapp2, maxIdleTime2, maxProofTime, "100s") + configFileOverrides2 := overridesDymintToml(settlement_layer_rollapp2, settlement_node_address, rollapp2_id, gas_price_rollapp2, maxIdleTime2, maxProofTime, "50s") // Create chain factory with dymension numHubVals := 1 @@ -2676,7 +2790,7 @@ func TestRollAppFreezeNoBrokenInvariants_Wasm(t *testing.T) { GasAdjustment: 1.1, TrustingPeriod: "112h", NoHostMount: false, - ModifyGenesis: modifyDymensionGenesis(dymModifyGenesisKV), + ModifyGenesis: modifyDymensionGenesis(dymensionGenesisKV), ConfigFileOverrides: nil, }, NumValidators: &numHubVals, @@ -2732,7 +2846,7 @@ func TestRollAppFreezeNoBrokenInvariants_Wasm(t *testing.T) { // This can be used to write to the block database which will index all block data e.g. txs, msgs, events, etc. // BlockDatabaseFile: test.DefaultBlockDatabaseFilepath(), - }, nil, "", nil) + }, nil, "", nil, false, 780) require.NoError(t, err) CreateChannel(ctx, t, r, eRep, dymension.CosmosChain, rollapp1.CosmosChain, ibcPath) @@ -2835,6 +2949,9 @@ func TestRollAppFreezeNoBrokenInvariants_Wasm(t *testing.T) { _, err = rollapp2.SendIBCTransfer(ctx, channsRollApp2Dym.ChannelID, rollapp2UserAddr, transferData, ibc.TransferOptions{}) require.NoError(t, err) + err = testutil.WaitForBlocks(ctx, 10, dymension, rollapp1) + require.NoError(t, err) + rollappHeight, err := rollapp1.GetNode().Height(ctx) require.NoError(t, err) @@ -2850,6 +2967,12 @@ func TestRollAppFreezeNoBrokenInvariants_Wasm(t *testing.T) { require.NoError(t, err) require.True(t, isFinalized) + _, err = dymension.GetNode().FinalizePacketsUntilHeight(ctx, dymensionUserAddr, rollapp1.GetChainID(), fmt.Sprint(rollappHeight)) + require.NoError(t, err) + + _, err = dymension.GetNode().FinalizePacketsUntilHeight(ctx, dymensionUserAddr, rollapp2.GetChainID(), fmt.Sprint(rollapp2Height)) + require.NoError(t, err) + oldLatestIndex, err := dymension.GetNode().QueryLatestStateIndex(ctx, rollapp1.Config().ChainID) require.NoError(t, err) @@ -2919,6 +3042,9 @@ func TestRollAppFreezeNoBrokenInvariants_Wasm(t *testing.T) { // Run invariant check _, err = dymension.GetNode().CrisisInvariant(ctx, dymensionUser.KeyName(), "rollapp", "block-height-to-finalization-queue") require.NoError(t, err) + + // Run invariant check + CheckInvariant(t, ctx, dymension, dymensionUser.KeyName()) } // TestRollAppSqcSlashedJailed_EVM ensure upon freeze gov proposal passed, Sequencer should be slashed with all the bond and jailed. Inability to register a new sequencer @@ -2936,14 +3062,14 @@ func TestRollAppSqcSlashedJailed_EVM(t *testing.T) { gas_price_rollapp1 := "0adym" maxIdleTime1 := "3s" maxProofTime := "500ms" - configFileOverrides1 := overridesDymintToml(settlement_layer_rollapp1, settlement_node_address, rollapp1_id, gas_price_rollapp1, maxIdleTime1, maxProofTime, "100s") + configFileOverrides1 := overridesDymintToml(settlement_layer_rollapp1, settlement_node_address, rollapp1_id, gas_price_rollapp1, maxIdleTime1, maxProofTime, "50s") // setup config for rollapp 2 settlement_layer_rollapp2 := "dymension" rollapp2_id := "decentrio_12345-1" gas_price_rollapp2 := "0adym" maxIdleTime2 := "3s" - configFileOverrides2 := overridesDymintToml(settlement_layer_rollapp2, settlement_node_address, rollapp2_id, gas_price_rollapp2, maxIdleTime2, maxProofTime, "100s") + configFileOverrides2 := overridesDymintToml(settlement_layer_rollapp2, settlement_node_address, rollapp2_id, gas_price_rollapp2, maxIdleTime2, maxProofTime, "50s") // Create chain factory with dymension numHubVals := 1 @@ -3011,7 +3137,7 @@ func TestRollAppSqcSlashedJailed_EVM(t *testing.T) { GasAdjustment: 1.1, TrustingPeriod: "112h", NoHostMount: false, - ModifyGenesis: modifyDymensionGenesis(dymModifyGenesisKV), + ModifyGenesis: modifyDymensionGenesis(dymensionGenesisKV), ConfigFileOverrides: nil, }, NumValidators: &numHubVals, @@ -3067,7 +3193,7 @@ func TestRollAppSqcSlashedJailed_EVM(t *testing.T) { // This can be used to write to the block database which will index all block data e.g. txs, msgs, events, etc. // BlockDatabaseFile: test.DefaultBlockDatabaseFilepath(), - }, nil, "", nil) + }, nil, "", nil, false, 780) require.NoError(t, err) CreateChannel(ctx, t, r, eRep, dymension.CosmosChain, rollapp1.CosmosChain, ibcPath) @@ -3172,6 +3298,9 @@ func TestRollAppSqcSlashedJailed_EVM(t *testing.T) { _, err = rollapp2.SendIBCTransfer(ctx, channsRollApp2Dym.ChannelID, rollapp2UserAddr, transferData, ibc.TransferOptions{}) require.NoError(t, err) + err = testutil.WaitForBlocks(ctx, 10, dymension, rollapp1) + require.NoError(t, err) + rollappHeight, err := rollapp1.GetNode().Height(ctx) require.NoError(t, err) @@ -3187,6 +3316,12 @@ func TestRollAppSqcSlashedJailed_EVM(t *testing.T) { require.NoError(t, err) require.True(t, isFinalized) + _, err = dymension.GetNode().FinalizePacketsUntilHeight(ctx, dymensionUserAddr, rollapp1.GetChainID(), fmt.Sprint(rollappHeight)) + require.NoError(t, err) + + _, err = dymension.GetNode().FinalizePacketsUntilHeight(ctx, dymensionUserAddr, rollapp2.GetChainID(), fmt.Sprint(rollapp2Height)) + require.NoError(t, err) + // Confirm previous ibc transfers were successful (dymension -> rollapp1) // Get the IBC denom rollapp1IbcDenom := GetIBCDenom(channsRollApp1Dym.Counterparty.PortID, channsRollApp1Dym.Counterparty.ChannelID, rollapp1.Config().Denom) @@ -3328,6 +3463,9 @@ func TestRollAppSqcSlashedJailed_EVM(t *testing.T) { require.Equal(t, true, sequencerStatus.Sequencers[0].Jailed, "sequencer should have been jailed") require.Equal(t, false, sequencerStatus.Sequencers[0].Tokens.AmountOf("adym").IsPositive(), "sequencer should have been slashed and have zero bond") + // Run invariant check + CheckInvariant(t, ctx, dymension, dymensionUser.KeyName()) + // TODO: Make sure we can not register a new sequencer } @@ -3346,14 +3484,14 @@ func TestRollAppSqcSlashedJailed_Wasm(t *testing.T) { gas_price_rollapp1 := "0adym" maxIdleTime1 := "3s" maxProofTime := "500ms" - configFileOverrides1 := overridesDymintToml(settlement_layer_rollapp1, settlement_node_address, rollapp1_id, gas_price_rollapp1, maxIdleTime1, maxProofTime, "100s") + configFileOverrides1 := overridesDymintToml(settlement_layer_rollapp1, settlement_node_address, rollapp1_id, gas_price_rollapp1, maxIdleTime1, maxProofTime, "50s") // setup config for rollapp 2 settlement_layer_rollapp2 := "dymension" rollapp2_id := "decentrio_12345-1" gas_price_rollapp2 := "0adym" maxIdleTime2 := "3s" - configFileOverrides2 := overridesDymintToml(settlement_layer_rollapp2, settlement_node_address, rollapp2_id, gas_price_rollapp2, maxIdleTime2, maxProofTime, "100s") + configFileOverrides2 := overridesDymintToml(settlement_layer_rollapp2, settlement_node_address, rollapp2_id, gas_price_rollapp2, maxIdleTime2, maxProofTime, "50s") // Create chain factory with dymension numHubVals := 1 @@ -3421,7 +3559,7 @@ func TestRollAppSqcSlashedJailed_Wasm(t *testing.T) { GasAdjustment: 1.1, TrustingPeriod: "112h", NoHostMount: false, - ModifyGenesis: modifyDymensionGenesis(dymModifyGenesisKV), + ModifyGenesis: modifyDymensionGenesis(dymensionGenesisKV), ConfigFileOverrides: nil, }, NumValidators: &numHubVals, @@ -3477,7 +3615,7 @@ func TestRollAppSqcSlashedJailed_Wasm(t *testing.T) { // This can be used to write to the block database which will index all block data e.g. txs, msgs, events, etc. // BlockDatabaseFile: test.DefaultBlockDatabaseFilepath(), - }, nil, "", nil) + }, nil, "", nil, false, 780) require.NoError(t, err) CreateChannel(ctx, t, r, eRep, dymension.CosmosChain, rollapp1.CosmosChain, ibcPath) @@ -3582,6 +3720,9 @@ func TestRollAppSqcSlashedJailed_Wasm(t *testing.T) { _, err = rollapp2.SendIBCTransfer(ctx, channsRollApp2Dym.ChannelID, rollapp2UserAddr, transferData, ibc.TransferOptions{}) require.NoError(t, err) + err = testutil.WaitForBlocks(ctx, 10, dymension, rollapp1) + require.NoError(t, err) + rollappHeight, err := rollapp1.GetNode().Height(ctx) require.NoError(t, err) @@ -3597,6 +3738,11 @@ func TestRollAppSqcSlashedJailed_Wasm(t *testing.T) { require.NoError(t, err) require.True(t, isFinalized) + _, err = dymension.GetNode().FinalizePacketsUntilHeight(ctx, dymensionUserAddr, rollapp1.GetChainID(), fmt.Sprint(rollappHeight)) + require.NoError(t, err) + + _, err = dymension.GetNode().FinalizePacketsUntilHeight(ctx, dymensionUserAddr, rollapp2.GetChainID(), fmt.Sprint(rollapp2Height)) + require.NoError(t, err) // Confirm previous ibc transfers were successful (dymension -> rollapp1) // Get the IBC denom rollapp1IbcDenom := GetIBCDenom(channsRollApp1Dym.Counterparty.PortID, channsRollApp1Dym.Counterparty.ChannelID, rollapp1.Config().Denom) @@ -3738,6 +3884,8 @@ func TestRollAppSqcSlashedJailed_Wasm(t *testing.T) { require.Equal(t, true, sequencerStatus.Sequencers[0].Jailed, "sequencer should have been jailed") require.Equal(t, false, sequencerStatus.Sequencers[0].Tokens.AmountOf("adym").IsPositive(), "sequencer should have been slashed and have zero bond") + // Run invariant check + CheckInvariant(t, ctx, dymension, dymensionUser.KeyName()) // TODO: Make sure we can not register a new sequencer } @@ -3761,7 +3909,7 @@ func TestRollAppFreezeStateNotProgressing_EVM(t *testing.T) { gas_price_rollapp1 := "0adym" maxIdleTime1 := "3s" maxProofTime := "500ms" - configFileOverrides := overridesDymintToml(settlement_layer_rollapp, settlement_node_address, rollapp1_id, gas_price_rollapp1, maxIdleTime1, maxProofTime, "100s") + configFileOverrides := overridesDymintToml(settlement_layer_rollapp, settlement_node_address, rollapp1_id, gas_price_rollapp1, maxIdleTime1, maxProofTime, "50s") // Create chain factory with dymension numHubVals := 1 @@ -3807,7 +3955,7 @@ func TestRollAppFreezeStateNotProgressing_EVM(t *testing.T) { GasAdjustment: 1.1, TrustingPeriod: "112h", NoHostMount: false, - ModifyGenesis: modifyDymensionGenesis(dymModifyGenesisKV), + ModifyGenesis: modifyDymensionGenesis(dymensionGenesisKV), ConfigFileOverrides: nil, }, NumValidators: &numHubVals, @@ -3851,7 +3999,7 @@ func TestRollAppFreezeStateNotProgressing_EVM(t *testing.T) { // This can be used to write to the block database which will index all block data e.g. txs, msgs, events, etc. // BlockDatabaseFile: test.DefaultBlockDatabaseFilepath(), - }, nil, "", nil) + }, nil, "", nil, false, 780) require.NoError(t, err) CreateChannel(ctx, t, r, eRep, dymension.CosmosChain, rollapp1.CosmosChain, ibcPath) @@ -3918,6 +4066,9 @@ func TestRollAppFreezeStateNotProgressing_EVM(t *testing.T) { _, err = rollapp1.SendIBCTransfer(ctx, channsRollApp1Dym.ChannelID, rollapp1UserAddr, transferData, ibc.TransferOptions{}) require.NoError(t, err) + err = testutil.WaitForBlocks(ctx, 10, dymension, rollapp1) + require.NoError(t, err) + rollappHeight, err := rollapp1.GetNode().Height(ctx) require.NoError(t, err) @@ -3929,6 +4080,9 @@ func TestRollAppFreezeStateNotProgressing_EVM(t *testing.T) { require.NoError(t, err) require.True(t, isFinalized) + _, err = dymension.GetNode().FinalizePacketsUntilHeight(ctx, dymensionUserAddr, rollapp1.GetChainID(), fmt.Sprint(rollappHeight)) + require.NoError(t, err) + // Confirm previous ibc transfers were successful (dymension -> rollapp1) // Get the IBC denom rollappIbcDenom := GetIBCDenom(channsRollApp1Dym.Counterparty.PortID, channsRollApp1Dym.Counterparty.ChannelID, rollapp1.Config().Denom) @@ -3981,7 +4135,7 @@ func TestRollAppFreezeStateNotProgressing_EVM(t *testing.T) { require.Equal(t, true, dymUserRollapp1bal.Equal(transferAmount.Sub(bridgingFee)), "dym hub balance changed") // get eIbc event - eibcEvents, err := getEIbcEventsWithinBlockRange(ctx, dymension, 10, false) + eibcEvents, err := getEIbcEventsWithinBlockRange(ctx, dymension, 30, false) require.NoError(t, err) for i, eibcEvent := range eibcEvents { @@ -4066,6 +4220,8 @@ func TestRollAppFreezeStateNotProgressing_EVM(t *testing.T) { // Check rollapp1 state index not increment require.NoError(t, err) require.Equal(t, fmt.Sprint(targetIndex), latestIndex.StateIndex.Index, "rollapp state index still increment") + // Run invariant check + CheckInvariant(t, ctx, dymension, dymensionUser.KeyName()) } func TestRollAppFreezeStateNotProgressing_Wasm(t *testing.T) { @@ -4082,7 +4238,7 @@ func TestRollAppFreezeStateNotProgressing_Wasm(t *testing.T) { gas_price_rollapp1 := "0adym" maxIdleTime1 := "3s" maxProofTime := "500ms" - configFileOverrides := overridesDymintToml(settlement_layer_rollapp1, settlement_node_address, rollapp1_id, gas_price_rollapp1, maxIdleTime1, maxProofTime, "100s") + configFileOverrides := overridesDymintToml(settlement_layer_rollapp1, settlement_node_address, rollapp1_id, gas_price_rollapp1, maxIdleTime1, maxProofTime, "50s") // Create chain factory with dymension numHubVals := 1 @@ -4128,7 +4284,7 @@ func TestRollAppFreezeStateNotProgressing_Wasm(t *testing.T) { GasAdjustment: 1.1, TrustingPeriod: "112h", NoHostMount: false, - ModifyGenesis: modifyDymensionGenesis(dymModifyGenesisKV), + ModifyGenesis: modifyDymensionGenesis(dymensionGenesisKV), ConfigFileOverrides: nil, }, NumValidators: &numHubVals, @@ -4172,7 +4328,7 @@ func TestRollAppFreezeStateNotProgressing_Wasm(t *testing.T) { // This can be used to write to the block database which will index all block data e.g. txs, msgs, events, etc. // BlockDatabaseFile: test.DefaultBlockDatabaseFilepath(), - }, nil, "", nil) + }, nil, "", nil, false, 780) require.NoError(t, err) CreateChannel(ctx, t, r, eRep, dymension.CosmosChain, rollapp1.CosmosChain, ibcPath) @@ -4239,6 +4395,9 @@ func TestRollAppFreezeStateNotProgressing_Wasm(t *testing.T) { _, err = rollapp1.SendIBCTransfer(ctx, channsRollApp1Dym.ChannelID, rollapp1UserAddr, transferData, ibc.TransferOptions{}) require.NoError(t, err) + err = testutil.WaitForBlocks(ctx, 10, dymension, rollapp1) + require.NoError(t, err) + rollappHeight, err := rollapp1.GetNode().Height(ctx) require.NoError(t, err) @@ -4250,6 +4409,9 @@ func TestRollAppFreezeStateNotProgressing_Wasm(t *testing.T) { require.NoError(t, err) require.True(t, isFinalized) + _, err = dymension.GetNode().FinalizePacketsUntilHeight(ctx, dymensionUserAddr, rollapp1.GetChainID(), fmt.Sprint(rollappHeight)) + require.NoError(t, err) + // Confirm previous ibc transfers were successful (dymension -> rollapp1) // Get the IBC denom rollappIbcDenom := GetIBCDenom(channsRollApp1Dym.Counterparty.PortID, channsRollApp1Dym.Counterparty.ChannelID, rollapp1.Config().Denom) @@ -4302,7 +4464,7 @@ func TestRollAppFreezeStateNotProgressing_Wasm(t *testing.T) { require.Equal(t, true, dymUserRollapp1bal.Equal(transferAmount.Sub(bridgingFee)), "dym hub balance changed") // get eIbc event - eibcEvents, err := getEIbcEventsWithinBlockRange(ctx, dymension, 10, false) + eibcEvents, err := getEIbcEventsWithinBlockRange(ctx, dymension, 30, false) require.NoError(t, err) for i, eibcEvent := range eibcEvents { @@ -4387,6 +4549,8 @@ func TestRollAppFreezeStateNotProgressing_Wasm(t *testing.T) { // Check rollapp1 state index not increment require.NoError(t, err) require.Equal(t, fmt.Sprint(targetIndex), latestIndex.StateIndex.Index, "rollapp state index still increment") + // Run invariant check + CheckInvariant(t, ctx, dymension, dymensionUser.KeyName()) } func TestRollAppFreezeEibcPending_EVM(t *testing.T) { @@ -4403,7 +4567,7 @@ func TestRollAppFreezeEibcPending_EVM(t *testing.T) { gas_price_rollapp1 := "0adym" maxIdleTime1 := "3s" maxProofTime := "500ms" - configFileOverrides := overridesDymintToml(settlement_layer_rollapp, settlement_node_address, rollapp1_id, gas_price_rollapp1, maxIdleTime1, maxProofTime, "100s") + configFileOverrides := overridesDymintToml(settlement_layer_rollapp, settlement_node_address, rollapp1_id, gas_price_rollapp1, maxIdleTime1, maxProofTime, "50s") // Create chain factory with dymension numHubVals := 1 @@ -4449,7 +4613,7 @@ func TestRollAppFreezeEibcPending_EVM(t *testing.T) { GasAdjustment: 1.1, TrustingPeriod: "112h", NoHostMount: false, - ModifyGenesis: modifyDymensionGenesis(dymModifyGenesisKV), + ModifyGenesis: modifyDymensionGenesis(dymensionGenesisKV), ConfigFileOverrides: nil, }, NumValidators: &numHubVals, @@ -4493,7 +4657,7 @@ func TestRollAppFreezeEibcPending_EVM(t *testing.T) { // This can be used to write to the block database which will index all block data e.g. txs, msgs, events, etc. // BlockDatabaseFile: test.DefaultBlockDatabaseFilepath(), - }, nil, "", nil) + }, nil, "", nil, false, 780) require.NoError(t, err) CreateChannel(ctx, t, r, eRep, dymension.CosmosChain, rollapp1.CosmosChain, ibcPath) @@ -4560,6 +4724,9 @@ func TestRollAppFreezeEibcPending_EVM(t *testing.T) { _, err = rollapp1.SendIBCTransfer(ctx, channsRollApp1Dym.ChannelID, rollapp1UserAddr, transferData, ibc.TransferOptions{}) require.NoError(t, err) + err = testutil.WaitForBlocks(ctx, 10, dymension, rollapp1) + require.NoError(t, err) + rollappHeight, err := rollapp1.GetNode().Height(ctx) require.NoError(t, err) @@ -4571,6 +4738,9 @@ func TestRollAppFreezeEibcPending_EVM(t *testing.T) { require.NoError(t, err) require.True(t, isFinalized) + _, err = dymension.GetNode().FinalizePacketsUntilHeight(ctx, dymensionUserAddr, rollapp1.GetChainID(), fmt.Sprint(rollappHeight)) + require.NoError(t, err) + // Confirm previous ibc transfers were successful (dymension -> rollapp1) // Get the IBC denom rollappIbcDenom := GetIBCDenom(channsRollApp1Dym.Counterparty.PortID, channsRollApp1Dym.Counterparty.ChannelID, rollapp1.Config().Denom) @@ -4623,7 +4793,7 @@ func TestRollAppFreezeEibcPending_EVM(t *testing.T) { require.Equal(t, true, dymUserRollapp1bal.Equal(transferAmount.Sub(bridgingFee)), "dym hub balance changed") // get eIbc event - eibcEvents, err := getEIbcEventsWithinBlockRange(ctx, dymension, 10, false) + eibcEvents, err := getEIbcEventsWithinBlockRange(ctx, dymension, 30, false) require.NoError(t, err) for i, eibcEvent := range eibcEvents { @@ -4700,7 +4870,7 @@ func TestRollAppFreezeEibcPending_EVM(t *testing.T) { latestIndex, err := dymension.GetNode().QueryLatestStateIndex(ctx, rollapp1.Config().ChainID) require.NoError(t, err) - testutil.WaitForBlocks(ctx, 30, dymension, rollapp1) + testutil.WaitForBlocks(ctx, 10, dymension, rollapp1) // after Grace period, the latest index should be the same lalatestIndex, err := dymension.GetNode().QueryLatestStateIndex(ctx, rollapp1.Config().ChainID) require.NoError(t, err) @@ -4729,6 +4899,8 @@ func TestRollAppFreezeEibcPending_EVM(t *testing.T) { balanceOfDymUserAddr, err := dymension.GetBalance(ctx, dymensionUserAddr, rollappIbcDenom) require.NoError(t, err) require.Equal(t, (transferAmount.Sub(bridgingFee)), balanceOfDymUserAddr) + // Run invariant check + CheckInvariant(t, ctx, dymension, dymensionUser.KeyName()) } func TestRollAppFreezeEibcPending_Wasm(t *testing.T) { @@ -4745,7 +4917,7 @@ func TestRollAppFreezeEibcPending_Wasm(t *testing.T) { gas_price_rollapp1 := "0adym" maxIdleTime1 := "3s" maxProofTime := "500ms" - configFileOverrides := overridesDymintToml(settlement_layer_rollapp1, settlement_node_address, rollapp1_id, gas_price_rollapp1, maxIdleTime1, maxProofTime, "100s") + configFileOverrides := overridesDymintToml(settlement_layer_rollapp1, settlement_node_address, rollapp1_id, gas_price_rollapp1, maxIdleTime1, maxProofTime, "50s") // Create chain factory with dymension numHubVals := 1 @@ -4791,7 +4963,7 @@ func TestRollAppFreezeEibcPending_Wasm(t *testing.T) { GasAdjustment: 1.1, TrustingPeriod: "112h", NoHostMount: false, - ModifyGenesis: modifyDymensionGenesis(dymModifyGenesisKV), + ModifyGenesis: modifyDymensionGenesis(dymensionGenesisKV), ConfigFileOverrides: nil, }, NumValidators: &numHubVals, @@ -4835,7 +5007,7 @@ func TestRollAppFreezeEibcPending_Wasm(t *testing.T) { // This can be used to write to the block database which will index all block data e.g. txs, msgs, events, etc. // BlockDatabaseFile: test.DefaultBlockDatabaseFilepath(), - }, nil, "", nil) + }, nil, "", nil, false, 780) require.NoError(t, err) CreateChannel(ctx, t, r, eRep, dymension.CosmosChain, rollapp1.CosmosChain, ibcPath) @@ -4902,6 +5074,9 @@ func TestRollAppFreezeEibcPending_Wasm(t *testing.T) { _, err = rollapp1.SendIBCTransfer(ctx, channsRollApp1Dym.ChannelID, rollapp1UserAddr, transferData, ibc.TransferOptions{}) require.NoError(t, err) + err = testutil.WaitForBlocks(ctx, 10, dymension, rollapp1) + require.NoError(t, err) + rollappHeight, err := rollapp1.GetNode().Height(ctx) require.NoError(t, err) @@ -4913,6 +5088,9 @@ func TestRollAppFreezeEibcPending_Wasm(t *testing.T) { require.NoError(t, err) require.True(t, isFinalized) + _, err = dymension.GetNode().FinalizePacketsUntilHeight(ctx, dymensionUserAddr, rollapp1.GetChainID(), fmt.Sprint(rollappHeight)) + require.NoError(t, err) + // Confirm previous ibc transfers were successful (dymension -> rollapp1) // Get the IBC denom rollappIbcDenom := GetIBCDenom(channsRollApp1Dym.Counterparty.PortID, channsRollApp1Dym.Counterparty.ChannelID, rollapp1.Config().Denom) @@ -4965,7 +5143,7 @@ func TestRollAppFreezeEibcPending_Wasm(t *testing.T) { require.Equal(t, true, dymUserRollapp1bal.Equal(transferAmount.Sub(bridgingFee)), "dym hub balance changed") // get eIbc event - eibcEvents, err := getEIbcEventsWithinBlockRange(ctx, dymension, 10, false) + eibcEvents, err := getEIbcEventsWithinBlockRange(ctx, dymension, 30, false) require.NoError(t, err) for i, eibcEvent := range eibcEvents { @@ -5042,7 +5220,7 @@ func TestRollAppFreezeEibcPending_Wasm(t *testing.T) { latestIndex, err := dymension.GetNode().QueryLatestStateIndex(ctx, rollapp1.Config().ChainID) require.NoError(t, err) - testutil.WaitForBlocks(ctx, 30, dymension, rollapp1) + testutil.WaitForBlocks(ctx, 10, dymension, rollapp1) // after Grace period, the latest index should be the same lalatestIndex, err := dymension.GetNode().QueryLatestStateIndex(ctx, rollapp1.Config().ChainID) require.NoError(t, err) @@ -5071,4 +5249,7 @@ func TestRollAppFreezeEibcPending_Wasm(t *testing.T) { balanceOfDymUserAddr, err := dymension.GetBalance(ctx, dymensionUserAddr, rollappIbcDenom) require.NoError(t, err) require.Equal(t, (transferAmount.Sub(bridgingFee)), balanceOfDymUserAddr) + + // Run invariant check + CheckInvariant(t, ctx, dymension, dymensionUser.KeyName()) } diff --git a/tests/fullnode_sync_block_sync_test.go b/tests/fullnode_sync_block_sync_test.go index 57c76786..c4f6ed79 100644 --- a/tests/fullnode_sync_block_sync_test.go +++ b/tests/fullnode_sync_block_sync_test.go @@ -15,6 +15,7 @@ import ( "go.uber.org/zap/zaptest" test "github.com/decentrio/rollup-e2e-testing" + "github.com/decentrio/rollup-e2e-testing/cosmos" "github.com/decentrio/rollup-e2e-testing/cosmos/hub/celes_hub" "github.com/decentrio/rollup-e2e-testing/cosmos/hub/dym_hub" "github.com/decentrio/rollup-e2e-testing/cosmos/rollapp/dym_rollapp" @@ -42,13 +43,11 @@ func TestSync_BlockSync_EVM(t *testing.T) { dymintTomlOverrides["settlement_gas_prices"] = "0adym" dymintTomlOverrides["max_idle_time"] = "3s" dymintTomlOverrides["max_proof_time"] = "500ms" - dymintTomlOverrides["batch_submit_max_time"] = "3600s" - dymintTomlOverrides["block_time"] = "20ms" + dymintTomlOverrides["batch_submit_time"] = "3600s" + dymintTomlOverrides["block_time"] = "200ms" dymintTomlOverrides["p2p_gossip_cache_size"] = "1" dymintTomlOverrides["p2p_blocksync_enabled"] = "true" dymintTomlOverrides["p2p_blocksync_block_request_interval"] = 10 - dymintTomlOverrides["da_layer"] = "grpc" - dymintTomlOverrides["da_config"] = "{\"host\":\"host.docker.internal\",\"port\": 7980}" configFileOverrides1 := make(map[string]any) configTomlOverrides1 := make(testutil.Toml) @@ -59,6 +58,14 @@ func TestSync_BlockSync_EVM(t *testing.T) { configFileOverrides1["config/config.toml"] = configTomlOverrides1 + modifyEVMGenesisKV := append( + rollappEVMGenesisKV, + cosmos.GenesisKV{ + Key: "app_state.rollappparams.params.da", + Value: "celestia", + }, + ) + numHubVals := 1 numHubFullNodes := 1 numCelestiaFn := 0 @@ -66,12 +73,12 @@ func TestSync_BlockSync_EVM(t *testing.T) { numRollAppVals := 1 nodeStore := "/home/celestia/light" p2pNetwork := "mocha-4" - coreIp := "celestia-testnet-consensus.itrocket.net" + coreIp := "mocha-4-consensus.mesa.newmetric.xyz" url := "https://api-mocha.celenium.io/v1/block/count" headerKey := "User-Agent" headerValue := "Apidog/1.0.0 (https://apidog.com)" - rpcEndpoint := "http://celestia-testnet-consensus.itrocket.net:26657" + rpcEndpoint := "http://rpc-mocha.pops.one:26657" cf := test.NewBuiltinChainFactory(zaptest.NewLogger(t), []*test.ChainSpec{ { @@ -121,7 +128,7 @@ func TestSync_BlockSync_EVM(t *testing.T) { Client: client, NetworkID: network, SkipPathCreation: true, - }, nil, "", nil) + }, nil, "", nil, true, 780) require.NoError(t, err) validator, err := celestia.Validators[0].AccountKeyBech32(ctx, "validator") @@ -180,7 +187,7 @@ func TestSync_BlockSync_EVM(t *testing.T) { // Create an exec instance execConfig := types.ExecConfig{ - Cmd: strslice.StrSlice([]string{"celestia", "light", "start", "--node.store", nodeStore, "--gateway", "--core.ip", coreIp, "--p2p.network", p2pNetwork, "--keyring.accname", "validator"}), // Replace with your command and arguments + Cmd: strslice.StrSlice([]string{"celestia", "light", "start", "--node.store", nodeStore, "--gateway", "--core.ip", coreIp, "--p2p.network", p2pNetwork, "--keyring.keyname", "validator"}), // Replace with your command and arguments } execIDResp, err := client.ContainerExecCreate(ctx, containerID, execConfig) @@ -208,10 +215,11 @@ func TestSync_BlockSync_EVM(t *testing.T) { celestia_namespace_id, err := RandomHex(10) require.NoError(t, err) println("check namespace: ", celestia_namespace_id) + da_config := fmt.Sprintf("{\"base_url\": \"http://test-val-0-%s:26658\", \"timeout\": 60000000000, \"gas_prices\":1.0, \"gas_adjustment\": 1.3, \"namespace_id\": \"%s\", \"auth_token\":\"%s\"}", t.Name(), celestia_namespace_id, celestia_token) configFileOverrides := make(map[string]any) - dymintTomlOverrides["da_layer"] = "grpc" - dymintTomlOverrides["da_config"] = "{\"host\":\"host.docker.internal\",\"port\": 7980}" + dymintTomlOverrides["namespace_id"] = celestia_namespace_id + dymintTomlOverrides["da_config"] = da_config configFileOverrides["config/dymint.toml"] = dymintTomlOverrides cf = test.NewBuiltinChainFactory(zaptest.NewLogger(t), []*test.ChainSpec{ @@ -231,7 +239,7 @@ func TestSync_BlockSync_EVM(t *testing.T) { TrustingPeriod: "112h", EncodingConfig: encodingConfig(), NoHostMount: false, - ModifyGenesis: modifyRollappEVMGenesis(rollappEVMGenesisKV), + ModifyGenesis: modifyRollappEVMGenesis(modifyEVMGenesisKV), ConfigFileOverrides: configFileOverrides, }, NumValidators: &numRollAppVals, @@ -255,15 +263,16 @@ func TestSync_BlockSync_EVM(t *testing.T) { ic = test.NewSetup(). AddRollUp(dymension, rollapp1) - _ = ic.Build(ctx, eRep, test.InterchainBuildOptions{ + err = ic.Build(ctx, eRep, test.InterchainBuildOptions{ TestName: t.Name(), Client: client, NetworkID: network, SkipPathCreation: true, - }, nil, "", nil) + }, nil, "", nil, true, 780) + require.NoError(t, err) // require.Error(t, err) - containerID = fmt.Sprintf("rollappevm_1234-1-val-0-%s", t.Name()) + containerID = fmt.Sprintf("ra-rollappevm_1234-1-val-0-%s", t.Name()) // Get the container details containerJSON, err := client.ContainerInspect(context.Background(), containerID) @@ -318,11 +327,9 @@ func TestSync_BlockSync_EVM(t *testing.T) { for scanner.Scan() { lines = append(lines, scanner.Text()) } - da_layer := "celestia" + for i, line := range lines { - if strings.HasPrefix(line, "da_layer =") { - lines[i] = fmt.Sprintf("da_layer = \"%s\"", da_layer) - } else if strings.HasPrefix(line, "namespace_id =") { + if strings.HasPrefix(line, "namespace_id =") { lines[i] = fmt.Sprintf("namespace_id = \"%s\"", celestia_namespace_id) } else if strings.HasPrefix(line, "da_config =") { lines[i] = fmt.Sprintf("da_config = \"{\\\"base_url\\\": \\\"http://test-val-0-%s:26658\\\", \\\"timeout\\\": 60000000000, \\\"gas_prices\\\":1.0, \\\"gas_adjustment\\\": 1.3, \\\"namespace_id\\\": \\\"%s\\\", \\\"auth_token\\\":\\\"%s\\\"}\"", t.Name(), celestia_namespace_id, celestia_token) @@ -383,13 +390,11 @@ func TestSync_BlockSync_fn_disconnect_EVM(t *testing.T) { dymintTomlOverrides["settlement_gas_prices"] = "0adym" dymintTomlOverrides["max_idle_time"] = "3s" dymintTomlOverrides["max_proof_time"] = "500ms" - dymintTomlOverrides["batch_submit_max_time"] = "3600s" - dymintTomlOverrides["block_time"] = "20ms" + dymintTomlOverrides["batch_submit_time"] = "3600s" + dymintTomlOverrides["block_time"] = "200ms" dymintTomlOverrides["p2p_gossip_cache_size"] = "1" dymintTomlOverrides["p2p_blocksync_enabled"] = "true" dymintTomlOverrides["p2p_blocksync_block_request_interval"] = 10 - dymintTomlOverrides["da_layer"] = "grpc" - dymintTomlOverrides["da_config"] = "{\"host\":\"host.docker.internal\",\"port\": 7980}" configFileOverrides1 := make(map[string]any) configTomlOverrides1 := make(testutil.Toml) @@ -400,6 +405,14 @@ func TestSync_BlockSync_fn_disconnect_EVM(t *testing.T) { configFileOverrides1["config/config.toml"] = configTomlOverrides1 + modifyEVMGenesisKV := append( + rollappEVMGenesisKV, + cosmos.GenesisKV{ + Key: "app_state.rollappparams.params.da", + Value: "celestia", + }, + ) + numHubVals := 1 numHubFullNodes := 1 numCelestiaFn := 0 @@ -407,12 +420,12 @@ func TestSync_BlockSync_fn_disconnect_EVM(t *testing.T) { numRollAppVals := 1 nodeStore := "/home/celestia/light" p2pNetwork := "mocha-4" - coreIp := "celestia-testnet-consensus.itrocket.net" + coreIp := "mocha-4-consensus.mesa.newmetric.xyz" url := "https://api-mocha.celenium.io/v1/block/count" headerKey := "User-Agent" headerValue := "Apidog/1.0.0 (https://apidog.com)" - rpcEndpoint := "http://celestia-testnet-consensus.itrocket.net:26657" + rpcEndpoint := "http://rpc-mocha.pops.one:26657" cf := test.NewBuiltinChainFactory(zaptest.NewLogger(t), []*test.ChainSpec{ { @@ -462,7 +475,7 @@ func TestSync_BlockSync_fn_disconnect_EVM(t *testing.T) { Client: client, NetworkID: network, SkipPathCreation: true, - }, nil, "", nil) + }, nil, "", nil, true, 780) require.NoError(t, err) validator, err := celestia.Validators[0].AccountKeyBech32(ctx, "validator") @@ -521,7 +534,7 @@ func TestSync_BlockSync_fn_disconnect_EVM(t *testing.T) { // Create an exec instance execConfig := types.ExecConfig{ - Cmd: strslice.StrSlice([]string{"celestia", "light", "start", "--node.store", nodeStore, "--gateway", "--core.ip", coreIp, "--p2p.network", p2pNetwork, "--keyring.accname", "validator"}), + Cmd: strslice.StrSlice([]string{"celestia", "light", "start", "--node.store", nodeStore, "--gateway", "--core.ip", coreIp, "--p2p.network", p2pNetwork, "--keyring.keyname", "validator"}), } execIDResp, err := client.ContainerExecCreate(ctx, containerID, execConfig) @@ -549,10 +562,11 @@ func TestSync_BlockSync_fn_disconnect_EVM(t *testing.T) { celestia_namespace_id, err := RandomHex(10) require.NoError(t, err) println("check namespace: ", celestia_namespace_id) + da_config := fmt.Sprintf("{\"base_url\": \"http://test-val-0-%s:26658\", \"timeout\": 60000000000, \"gas_prices\":1.0, \"gas_adjustment\": 1.3, \"namespace_id\": \"%s\", \"auth_token\":\"%s\"}", t.Name(), celestia_namespace_id, celestia_token) configFileOverrides := make(map[string]any) - dymintTomlOverrides["da_layer"] = "grpc" - dymintTomlOverrides["da_config"] = "{\"host\":\"host.docker.internal\",\"port\": 7980}" + dymintTomlOverrides["namespace_id"] = celestia_namespace_id + dymintTomlOverrides["da_config"] = da_config configFileOverrides["config/dymint.toml"] = dymintTomlOverrides cf = test.NewBuiltinChainFactory(zaptest.NewLogger(t), []*test.ChainSpec{ @@ -572,7 +586,7 @@ func TestSync_BlockSync_fn_disconnect_EVM(t *testing.T) { TrustingPeriod: "112h", EncodingConfig: encodingConfig(), NoHostMount: false, - ModifyGenesis: modifyRollappEVMGenesis(rollappEVMGenesisKV), + ModifyGenesis: modifyRollappEVMGenesis(modifyEVMGenesisKV), ConfigFileOverrides: configFileOverrides, }, NumValidators: &numRollAppVals, @@ -601,10 +615,10 @@ func TestSync_BlockSync_fn_disconnect_EVM(t *testing.T) { Client: client, NetworkID: network, SkipPathCreation: true, - }, nil, "", nil) - require.Error(t, err) + }, nil, "", nil, true, 780) + require.NoError(t, err) - containerID = fmt.Sprintf("rollappevm_1234-1-val-0-%s", t.Name()) + containerID = fmt.Sprintf("ra-rollappevm_1234-1-val-0-%s", t.Name()) // Get the container details containerJSON, err := client.ContainerInspect(context.Background(), containerID) @@ -650,38 +664,35 @@ func TestSync_BlockSync_fn_disconnect_EVM(t *testing.T) { _, err = file.Write([]byte(output)) require.NoError(t, err) - // update dymint.toml for full node to connect with Celestia DA - fnHomeDir := strings.Split(rollapp1.FullNodes[0].HomeDir(), "/") - fnFolderName := fnHomeDir[len(fnHomeDir)-1] + // // update dymint.toml for full node to connect with Celestia DA + // fnHomeDir := strings.Split(rollapp1.FullNodes[0].HomeDir(), "/") + // fnFolderName := fnHomeDir[len(fnHomeDir)-1] - file, err = os.Open(fmt.Sprintf("/tmp/%s/config/dymint.toml", fnFolderName)) - require.NoError(t, err) - defer file.Close() + // file, err = os.Open(fmt.Sprintf("/tmp/%s/config/dymint.toml", fnFolderName)) + // require.NoError(t, err) + // defer file.Close() - lines = []string{} - scanner = bufio.NewScanner(file) - for scanner.Scan() { - lines = append(lines, scanner.Text()) - } + // lines = []string{} + // scanner = bufio.NewScanner(file) + // for scanner.Scan() { + // lines = append(lines, scanner.Text()) + // } - da_layer := "celestia" - for i, line := range lines { - if strings.HasPrefix(line, "da_layer =") { - lines[i] = fmt.Sprintf("da_layer = \"%s\"", da_layer) - } else if strings.HasPrefix(line, "namespace_id =") { - lines[i] = fmt.Sprintf("namespace_id = \"%s\"", celestia_namespace_id) - } else if strings.HasPrefix(line, "da_config =") { - lines[i] = fmt.Sprintf("da_config = \"{\\\"base_url\\\": \\\"http://test-val-0-%s:26658\\\", \\\"timeout\\\": 60000000000, \\\"gas_prices\\\":1.0, \\\"gas_adjustment\\\": 1.3, \\\"namespace_id\\\": \\\"%s\\\", \\\"auth_token\\\":\\\"%s\\\"}\"", t.Name(), celestia_namespace_id, celestia_token) - } - } + // for i, line := range lines { + // if strings.HasPrefix(line, "namespace_id =") { + // lines[i] = fmt.Sprintf("namespace_id = \"%s\"", celestia_namespace_id) + // } else if strings.HasPrefix(line, "da_config =") { + // lines[i] = fmt.Sprintf("da_config = \"{\\\"base_url\\\": \\\"http://test-val-0-%s:26658\\\", \\\"timeout\\\": 60000000000, \\\"gas_prices\\\":1.0, \\\"gas_adjustment\\\": 1.3, \\\"namespace_id\\\": \\\"%s\\\", \\\"auth_token\\\":\\\"%s\\\"}\"", t.Name(), celestia_namespace_id, celestia_token) + // } + // } - output = strings.Join(lines, "\n") - file, err = os.Create(fmt.Sprintf("/tmp/%s/config/dymint.toml", fnFolderName)) - require.NoError(t, err) - defer file.Close() + // output = strings.Join(lines, "\n") + // file, err = os.Create(fmt.Sprintf("/tmp/%s/config/dymint.toml", fnFolderName)) + // require.NoError(t, err) + // defer file.Close() - _, err = file.Write([]byte(output)) - require.NoError(t, err) + // _, err = file.Write([]byte(output)) + // require.NoError(t, err) err = rollapp1.FullNodes[0].StopContainer(ctx) require.NoError(t, err) @@ -714,7 +725,7 @@ func TestSync_BlockSync_fn_disconnect_EVM(t *testing.T) { require.NoError(t, err) // Wait for few blocks before starting the full node - err = testutil.WaitForBlocks(ctx, 10, dymension) + err = testutil.WaitForBlocks(ctx, 30, dymension) require.NoError(t, err) err = rollapp1.FullNodes[0].StartContainer(ctx) diff --git a/tests/fullnode_sync_gossip_test.go b/tests/fullnode_sync_gossip_test.go index dbca76c9..9a7a8a38 100644 --- a/tests/fullnode_sync_gossip_test.go +++ b/tests/fullnode_sync_gossip_test.go @@ -9,6 +9,7 @@ import ( "testing" "time" + "github.com/decentrio/rollup-e2e-testing/cosmos" "github.com/decentrio/rollup-e2e-testing/relayer" "github.com/docker/docker/api/types" "github.com/docker/docker/api/types/strslice" @@ -39,10 +40,11 @@ func TestSync_Celes_Rt_Gossip_EVM(t *testing.T) { dymintTomlOverrides["settlement_node_address"] = fmt.Sprintf("http://dymension_100-1-val-0-%s:26657", t.Name()) dymintTomlOverrides["rollapp_id"] = "rollappevm_1234-1" dymintTomlOverrides["settlement_gas_prices"] = "0adym" - dymintTomlOverrides["max_idle_time"] = "200ms" + dymintTomlOverrides["max_idle_time"] = "250ms" dymintTomlOverrides["max_proof_time"] = "150ms" - dymintTomlOverrides["batch_submit_max_time"] = "5s" - dymintTomlOverrides["block_time"] = "190ms" + dymintTomlOverrides["batch_submit_time"] = "5s" + dymintTomlOverrides["block_time"] = "200ms" + dymintTomlOverrides["p2p_blocksync_enabled"] = "true" configFileOverrides1 := make(map[string]any) configTomlOverrides1 := make(testutil.Toml) @@ -53,6 +55,14 @@ func TestSync_Celes_Rt_Gossip_EVM(t *testing.T) { configFileOverrides1["config/config.toml"] = configTomlOverrides1 + modifyEVMGenesisKV := append( + rollappEVMGenesisKV, + cosmos.GenesisKV{ + Key: "app_state.rollappparams.params.da", + Value: "celestia", + }, + ) + numHubVals := 1 numHubFullNodes := 1 numCelestiaFn := 0 @@ -60,12 +70,12 @@ func TestSync_Celes_Rt_Gossip_EVM(t *testing.T) { numRollAppVals := 1 nodeStore := "/home/celestia/light" p2pNetwork := "mocha-4" - coreIp := "celestia-testnet-consensus.itrocket.net" + coreIp := "mocha-4-consensus.mesa.newmetric.xyz" url := "https://api-mocha.celenium.io/v1/block/count" headerKey := "User-Agent" headerValue := "Apidog/1.0.0 (https://apidog.com)" - rpcEndpoint := "http://celestia-testnet-consensus.itrocket.net:26657" + rpcEndpoint := "http://rpc-mocha.pops.one:26657" cf := test.NewBuiltinChainFactory(zaptest.NewLogger(t), []*test.ChainSpec{ { @@ -115,16 +125,16 @@ func TestSync_Celes_Rt_Gossip_EVM(t *testing.T) { Client: client, NetworkID: network, SkipPathCreation: true, - }, nil, "", nil) + }, nil, "", nil, true, 780) require.NoError(t, err) - // validator, err := celestia.Validators[0].AccountKeyBech32(ctx, "validator") - // require.NoError(t, err) + validator, err := celestia.Validators[0].AccountKeyBech32(ctx, "validator") + require.NoError(t, err) // Get fund for submit blob - // GetFaucet("http://18.184.170.181:3000/api/get-tia", validator) - // err = testutil.WaitForBlocks(ctx, 10, celestia) - // require.NoError(t, err) + GetFaucet("http://18.184.170.181:3000/api/get-tia", validator) + err = testutil.WaitForBlocks(ctx, 10, celestia) + require.NoError(t, err) err = celestia.GetNode().InitCelestiaDaLightNode(ctx, nodeStore, p2pNetwork, nil) require.NoError(t, err) @@ -174,7 +184,7 @@ func TestSync_Celes_Rt_Gossip_EVM(t *testing.T) { // Create an exec instance execConfig := types.ExecConfig{ - Cmd: strslice.StrSlice([]string{"celestia", "light", "start", "--node.store", nodeStore, "--gateway", "--core.ip", coreIp, "--p2p.network", p2pNetwork, "--keyring.accname", "validator"}), // Replace with your command and arguments + Cmd: strslice.StrSlice([]string{"celestia", "light", "start", "--node.store", nodeStore, "--gateway", "--core.ip", coreIp, "--p2p.network", p2pNetwork, "--keyring.keyname", "validator"}), // Replace with your command and arguments } execIDResp, err := client.ContainerExecCreate(ctx, containerID, execConfig) @@ -205,7 +215,6 @@ func TestSync_Celes_Rt_Gossip_EVM(t *testing.T) { da_config := fmt.Sprintf("{\"base_url\": \"http://test-val-0-%s:26658\", \"timeout\": 60000000000, \"gas_prices\":1.0, \"gas_adjustment\": 1.3, \"namespace_id\": \"%s\", \"auth_token\":\"%s\"}", t.Name(), celestia_namespace_id, celestia_token) configFileOverrides := make(map[string]any) - dymintTomlOverrides["da_layer"] = "celestia" dymintTomlOverrides["namespace_id"] = celestia_namespace_id dymintTomlOverrides["da_config"] = da_config configFileOverrides["config/dymint.toml"] = dymintTomlOverrides @@ -227,7 +236,7 @@ func TestSync_Celes_Rt_Gossip_EVM(t *testing.T) { TrustingPeriod: "112h", EncodingConfig: encodingConfig(), NoHostMount: false, - ModifyGenesis: modifyRollappEVMGenesis(rollappEVMGenesisKV), + ModifyGenesis: modifyRollappEVMGenesis(modifyEVMGenesisKV), ConfigFileOverrides: configFileOverrides, }, NumValidators: &numRollAppVals, @@ -256,10 +265,10 @@ func TestSync_Celes_Rt_Gossip_EVM(t *testing.T) { Client: client, NetworkID: network, SkipPathCreation: true, - }, nil, "", nil) + }, nil, "", nil, true, 780) require.NoError(t, err) - containerID = fmt.Sprintf("rollappevm_1234-1-val-0-%s", t.Name()) + containerID = fmt.Sprintf("ra-rollappevm_1234-1-val-0-%s", t.Name()) // Get the container details containerJSON, err := client.ContainerInspect(context.Background(), containerID) @@ -315,9 +324,10 @@ func TestSync_Celes_Rt_Gossip_EVM(t *testing.T) { rollappHeight, err := rollapp1.Validators[0].Height(ctx) require.NoError(t, err) - isFinalized, err := dymension.WaitUntilRollappHeightIsFinalized(ctx, rollapp1.GetChainID(), rollappHeight, 300) + isFinalized, err := dymension.WaitUntilRollappHeightIsFinalized(ctx, rollapp1.GetChainID(), rollappHeight, 500) require.NoError(t, err) require.True(t, isFinalized) + valHeight, err := rollapp1.Validators[0].Height(ctx) require.NoError(t, err) @@ -353,10 +363,11 @@ func TestSync_Celes_Rt_Gossip_Wasm(t *testing.T) { dymintTomlOverrides["settlement_node_address"] = fmt.Sprintf("http://dymension_100-1-val-0-%s:26657", t.Name()) dymintTomlOverrides["rollapp_id"] = "rollappwasm_1234-1" dymintTomlOverrides["settlement_gas_prices"] = "0adym" - dymintTomlOverrides["max_idle_time"] = "200ms" + dymintTomlOverrides["max_idle_time"] = "250ms" dymintTomlOverrides["max_proof_time"] = "150ms" - dymintTomlOverrides["batch_submit_max_time"] = "80s" - dymintTomlOverrides["block_time"] = "190ms" + dymintTomlOverrides["batch_submit_time"] = "5s" + dymintTomlOverrides["block_time"] = "200ms" + dymintTomlOverrides["p2p_blocksync_enabled"] = "true" configFileOverrides1 := make(map[string]any) configTomlOverrides1 := make(testutil.Toml) @@ -367,6 +378,14 @@ func TestSync_Celes_Rt_Gossip_Wasm(t *testing.T) { configFileOverrides1["config/config.toml"] = configTomlOverrides1 + modifyWasmGenesisKV := append( + rollappWasmGenesisKV, + cosmos.GenesisKV{ + Key: "app_state.rollappparams.params.da", + Value: "celestia", + }, + ) + numHubVals := 1 numHubFullNodes := 1 numRollAppFn := 1 @@ -374,12 +393,12 @@ func TestSync_Celes_Rt_Gossip_Wasm(t *testing.T) { numCelestiaFn := 0 nodeStore := "/home/celestia/light" p2pNetwork := "mocha-4" - coreIp := "celestia-testnet-consensus.itrocket.net" + coreIp := "mocha-4-consensus.mesa.newmetric.xyz" url := "https://api-mocha.celenium.io/v1/block/count" headerKey := "User-Agent" headerValue := "Apidog/1.0.0 (https://apidog.com)" - rpcEndpoint := "http://celestia-testnet-consensus.itrocket.net:26657" + rpcEndpoint := "http://rpc-mocha.pops.one:26657" cf := test.NewBuiltinChainFactory(zaptest.NewLogger(t), []*test.ChainSpec{ { @@ -429,16 +448,16 @@ func TestSync_Celes_Rt_Gossip_Wasm(t *testing.T) { Client: client, NetworkID: network, SkipPathCreation: true, - }, nil, "", nil) + }, nil, "", nil, true, 780) require.NoError(t, err) - // validator, err := celestia.Validators[0].AccountKeyBech32(ctx, "validator") - // require.NoError(t, err) + validator, err := celestia.Validators[0].AccountKeyBech32(ctx, "validator") + require.NoError(t, err) // Get fund for submit blob - // GetFaucet("http://18.184.170.181:3000/api/get-tia", validator) - // err = testutil.WaitForBlocks(ctx, 10, celestia) - // require.NoError(t, err) + GetFaucet("http://18.184.170.181:3000/api/get-tia", validator) + err = testutil.WaitForBlocks(ctx, 10, celestia) + require.NoError(t, err) err = celestia.GetNode().InitCelestiaDaLightNode(ctx, nodeStore, p2pNetwork, nil) require.NoError(t, err) @@ -490,7 +509,7 @@ func TestSync_Celes_Rt_Gossip_Wasm(t *testing.T) { // Create an exec instance execConfig := types.ExecConfig{ - Cmd: strslice.StrSlice([]string{"celestia", "light", "start", "--node.store", nodeStore, "--gateway", "--core.ip", coreIp, "--p2p.network", p2pNetwork, "--keyring.accname", "validator"}), // Replace with your command and arguments + Cmd: strslice.StrSlice([]string{"celestia", "light", "start", "--node.store", nodeStore, "--gateway", "--core.ip", coreIp, "--p2p.network", p2pNetwork, "--keyring.keyname", "validator"}), // Replace with your command and arguments } execIDResp, err := client.ContainerExecCreate(ctx, containerID, execConfig) @@ -521,7 +540,6 @@ func TestSync_Celes_Rt_Gossip_Wasm(t *testing.T) { da_config := fmt.Sprintf("{\"base_url\": \"http://test-val-0-%s:26658\", \"timeout\": 60000000000, \"gas_prices\":1.0, \"gas_adjustment\": 1.3, \"namespace_id\": \"%s\", \"auth_token\":\"%s\"}", t.Name(), celestia_namespace_id, celestia_token) configFileOverrides := make(map[string]any) - dymintTomlOverrides["da_layer"] = "celestia" dymintTomlOverrides["namespace_id"] = celestia_namespace_id dymintTomlOverrides["da_config"] = da_config configFileOverrides["config/dymint.toml"] = dymintTomlOverrides @@ -543,7 +561,7 @@ func TestSync_Celes_Rt_Gossip_Wasm(t *testing.T) { TrustingPeriod: "112h", EncodingConfig: encodingConfig(), NoHostMount: false, - ModifyGenesis: modifyRollappWasmGenesis(rollappWasmGenesisKV), + ModifyGenesis: modifyRollappWasmGenesis(modifyWasmGenesisKV), ConfigFileOverrides: configFileOverrides, }, NumValidators: &numRollAppVals, @@ -583,25 +601,78 @@ func TestSync_Celes_Rt_Gossip_Wasm(t *testing.T) { Client: client, NetworkID: network, SkipPathCreation: true, - }, nil, "", nil) + }, nil, "", nil, true, 780) + require.NoError(t, err) + + containerID = fmt.Sprintf("ra-rollappwasm_1234-1-val-0-%s", t.Name()) + + // Get the container details + containerJSON, err := client.ContainerInspect(context.Background(), containerID) + require.NoError(t, err) + + // Extract the IP address from the network settings + // If the container is using a custom network, the IP might be under a specific network name + var ipAddress string + for _, network := range containerJSON.NetworkSettings.Networks { + ipAddress = network.IPAddress + break // Assuming we only need the IP from the first network + } + + nodeId, err := rollapp1.Validators[0].GetNodeId(ctx) + require.NoError(t, err) + nodeId = strings.TrimRight(nodeId, "\n") + p2p_bootstrap_node := fmt.Sprintf("/ip4/%s/tcp/26656/p2p/%s", ipAddress, nodeId) + + rollapp1HomeDir := strings.Split(rollapp1.HomeDir(), "/") + rollapp1FolderName := rollapp1HomeDir[len(rollapp1HomeDir)-1] + + file, err = os.Open(fmt.Sprintf("/tmp/%s/config/dymint.toml", rollapp1FolderName)) + require.NoError(t, err) + defer file.Close() + + lines = []string{} + scanner = bufio.NewScanner(file) + for scanner.Scan() { + lines = append(lines, scanner.Text()) + } + + for i, line := range lines { + if strings.HasPrefix(line, "p2p_bootstrap_nodes =") { + lines[i] = fmt.Sprintf("p2p_bootstrap_nodes = \"%s\"", p2p_bootstrap_node) + } + } + + output = strings.Join(lines, "\n") + file, err = os.Create(fmt.Sprintf("/tmp/%s/config/dymint.toml", rollapp1FolderName)) + require.NoError(t, err) + defer file.Close() + + _, err = file.Write([]byte(output)) + require.NoError(t, err) + + // Start full node + err = rollapp1.FullNodes[0].StopContainer(ctx) + require.NoError(t, err) + + _ = rollapp1.FullNodes[0].StartContainer(ctx) + + time.Sleep(30 * time.Second) + + rollappHeight, err := rollapp1.Validators[0].Height(ctx) require.NoError(t, err) - rollappHeight, err := rollapp1.GetNode().Height(ctx) + isFinalized, err := dymension.WaitUntilRollappHeightIsFinalized(ctx, rollapp1.GetChainID(), rollappHeight, 500) require.NoError(t, err) + require.True(t, isFinalized) - // wait until the packet is finalized - isFinalized, err := dymension.WaitUntilRollappHeightIsFinalized(ctx, rollapp1.GetChainID(), rollappHeight, 180) - require.Error(t, err) - require.False(t, isFinalized) + valHeight, err := rollapp1.Validators[0].Height(ctx) + require.NoError(t, err) - // Poll until full node is sync + //Poll until full node is sync err = testutil.WaitForCondition( time.Minute*50, time.Second*5, // each epoch is 5 seconds func() (bool, error) { - valHeight, err := rollapp1.Validators[0].Height(ctx) - require.NoError(t, err) - fullnodeHeight, err := rollapp1.FullNodes[0].Height(ctx) require.NoError(t, err) @@ -629,10 +700,11 @@ func TestSync_Sqc_Disconnect_Gossip_EVM(t *testing.T) { dymintTomlOverrides["settlement_node_address"] = fmt.Sprintf("http://dymension_100-1-val-0-%s:26657", t.Name()) dymintTomlOverrides["rollapp_id"] = "rollappevm_1234-1" dymintTomlOverrides["settlement_gas_prices"] = "0adym" - dymintTomlOverrides["max_idle_time"] = "200ms" + dymintTomlOverrides["max_idle_time"] = "250ms" dymintTomlOverrides["max_proof_time"] = "150ms" - dymintTomlOverrides["batch_submit_max_time"] = "5s" - dymintTomlOverrides["block_time"] = "190ms" + dymintTomlOverrides["batch_submit_time"] = "5s" + dymintTomlOverrides["block_time"] = "200ms" + dymintTomlOverrides["p2p_blocksync_enabled"] = "true" configFileOverrides1 := make(map[string]any) configTomlOverrides1 := make(testutil.Toml) @@ -643,6 +715,14 @@ func TestSync_Sqc_Disconnect_Gossip_EVM(t *testing.T) { configFileOverrides1["config/config.toml"] = configTomlOverrides1 + modifyEVMGenesisKV := append( + rollappEVMGenesisKV, + cosmos.GenesisKV{ + Key: "app_state.rollappparams.params.da", + Value: "celestia", + }, + ) + numHubVals := 1 numHubFullNodes := 1 numCelestiaFn := 0 @@ -650,12 +730,12 @@ func TestSync_Sqc_Disconnect_Gossip_EVM(t *testing.T) { numRollAppVals := 1 nodeStore := "/home/celestia/light" p2pNetwork := "mocha-4" - coreIp := "celestia-testnet-consensus.itrocket.net" + coreIp := "mocha-4-consensus.mesa.newmetric.xyz" url := "https://api-mocha.celenium.io/v1/block/count" headerKey := "User-Agent" headerValue := "Apidog/1.0.0 (https://apidog.com)" - rpcEndpoint := "http://celestia-testnet-consensus.itrocket.net:26657" + rpcEndpoint := "http://rpc-mocha.pops.one:26657" cf := test.NewBuiltinChainFactory(zaptest.NewLogger(t), []*test.ChainSpec{ { @@ -705,16 +785,16 @@ func TestSync_Sqc_Disconnect_Gossip_EVM(t *testing.T) { Client: client, NetworkID: network, SkipPathCreation: true, - }, nil, "", nil) + }, nil, "", nil, true, 780) require.NoError(t, err) - // validator, err := celestia.Validators[0].AccountKeyBech32(ctx, "validator") - // require.NoError(t, err) + validator, err := celestia.Validators[0].AccountKeyBech32(ctx, "validator") + require.NoError(t, err) // Get fund for submit blob - // GetFaucet("http://18.184.170.181:3000/api/get-tia", validator) - // err = testutil.WaitForBlocks(ctx, 10, celestia) - // require.NoError(t, err) + GetFaucet("http://18.184.170.181:3000/api/get-tia", validator) + err = testutil.WaitForBlocks(ctx, 10, celestia) + require.NoError(t, err) err = celestia.GetNode().InitCelestiaDaLightNode(ctx, nodeStore, p2pNetwork, nil) require.NoError(t, err) @@ -764,7 +844,7 @@ func TestSync_Sqc_Disconnect_Gossip_EVM(t *testing.T) { // Create an exec instance execConfig := types.ExecConfig{ - Cmd: strslice.StrSlice([]string{"celestia", "light", "start", "--node.store", nodeStore, "--gateway", "--core.ip", coreIp, "--p2p.network", p2pNetwork, "--keyring.accname", "validator"}), // Replace with your command and arguments + Cmd: strslice.StrSlice([]string{"celestia", "light", "start", "--node.store", nodeStore, "--gateway", "--core.ip", coreIp, "--p2p.network", p2pNetwork, "--keyring.keyname", "validator"}), // Replace with your command and arguments } execIDResp, err := client.ContainerExecCreate(ctx, containerID, execConfig) @@ -795,7 +875,6 @@ func TestSync_Sqc_Disconnect_Gossip_EVM(t *testing.T) { da_config := fmt.Sprintf("{\"base_url\": \"http://test-val-0-%s:26658\", \"timeout\": 60000000000, \"gas_prices\":1.0, \"gas_adjustment\": 1.3, \"namespace_id\": \"%s\", \"auth_token\":\"%s\"}", t.Name(), celestia_namespace_id, celestia_token) configFileOverrides := make(map[string]any) - dymintTomlOverrides["da_layer"] = "celestia" dymintTomlOverrides["namespace_id"] = celestia_namespace_id dymintTomlOverrides["da_config"] = da_config configFileOverrides["config/dymint.toml"] = dymintTomlOverrides @@ -817,7 +896,7 @@ func TestSync_Sqc_Disconnect_Gossip_EVM(t *testing.T) { TrustingPeriod: "112h", EncodingConfig: encodingConfig(), NoHostMount: false, - ModifyGenesis: modifyRollappEVMGenesis(rollappEVMGenesisKV), + ModifyGenesis: modifyRollappEVMGenesis(modifyEVMGenesisKV), ConfigFileOverrides: configFileOverrides, }, NumValidators: &numRollAppVals, @@ -846,10 +925,10 @@ func TestSync_Sqc_Disconnect_Gossip_EVM(t *testing.T) { Client: client, NetworkID: network, SkipPathCreation: true, - }, nil, "", nil) + }, nil, "", nil, true, 780) require.NoError(t, err) - containerID = fmt.Sprintf("rollappevm_1234-1-val-0-%s", t.Name()) + containerID = fmt.Sprintf("ra-rollappevm_1234-1-val-0-%s", t.Name()) // Get the container details containerJSON, err := client.ContainerInspect(context.Background(), containerID) @@ -899,8 +978,7 @@ func TestSync_Sqc_Disconnect_Gossip_EVM(t *testing.T) { err = rollapp1.FullNodes[0].StopContainer(ctx) require.NoError(t, err) - err = rollapp1.FullNodes[0].StartContainer(ctx) - require.NoError(t, err) + _ = rollapp1.FullNodes[0].StartContainer(ctx) rollappHeight, err := rollapp1.Validators[0].Height(ctx) require.NoError(t, err) @@ -908,6 +986,7 @@ func TestSync_Sqc_Disconnect_Gossip_EVM(t *testing.T) { isFinalized, err := dymension.WaitUntilRollappHeightIsFinalized(ctx, rollapp1.GetChainID(), rollappHeight, 300) require.NoError(t, err) require.True(t, isFinalized) + valHeight, err := rollapp1.Validators[0].Height(ctx) require.NoError(t, err) @@ -932,15 +1011,11 @@ func TestSync_Sqc_Disconnect_Gossip_EVM(t *testing.T) { err = rollapp1.Validators[0].StopContainer(ctx) require.NoError(t, err) - err = testutil.WaitForBlocks(ctx, 10, celestia) + err = testutil.WaitForBlocks(ctx, 30, celestia) require.NoError(t, err) - err = rollapp1.Validators[0].StartContainer(ctx) - require.NoError(t, err) + _ = rollapp1.Validators[0].StartContainer(ctx) - isFinalized, err = dymension.WaitUntilRollappHeightIsFinalized(ctx, rollapp1.GetChainID(), rollappHeight, 300) - require.NoError(t, err) - require.True(t, isFinalized) valHeight, err = rollapp1.Validators[0].Height(ctx) require.NoError(t, err) @@ -976,10 +1051,11 @@ func TestSync_Sqc_Disconnect_Gossip_Wasm(t *testing.T) { dymintTomlOverrides["settlement_node_address"] = fmt.Sprintf("http://dymension_100-1-val-0-%s:26657", t.Name()) dymintTomlOverrides["rollapp_id"] = "rollappwasm_1234-1" dymintTomlOverrides["settlement_gas_prices"] = "0adym" - dymintTomlOverrides["max_idle_time"] = "200ms" + dymintTomlOverrides["max_idle_time"] = "250ms" dymintTomlOverrides["max_proof_time"] = "150ms" - dymintTomlOverrides["batch_submit_max_time"] = "5s" - dymintTomlOverrides["block_time"] = "190ms" + dymintTomlOverrides["batch_submit_time"] = "5s" + dymintTomlOverrides["block_time"] = "200ms" + dymintTomlOverrides["p2p_blocksync_enabled"] = "true" configFileOverrides1 := make(map[string]any) configTomlOverrides1 := make(testutil.Toml) @@ -990,6 +1066,14 @@ func TestSync_Sqc_Disconnect_Gossip_Wasm(t *testing.T) { configFileOverrides1["config/config.toml"] = configTomlOverrides1 + modifyWasmGenesisKV := append( + rollappWasmGenesisKV, + cosmos.GenesisKV{ + Key: "app_state.rollappparams.params.da", + Value: "celestia", + }, + ) + numHubVals := 1 numHubFullNodes := 1 numCelestiaFn := 0 @@ -997,12 +1081,12 @@ func TestSync_Sqc_Disconnect_Gossip_Wasm(t *testing.T) { numRollAppVals := 1 nodeStore := "/home/celestia/light" p2pNetwork := "mocha-4" - coreIp := "celestia-testnet-consensus.itrocket.net" + coreIp := "mocha-4-consensus.mesa.newmetric.xyz" url := "https://api-mocha.celenium.io/v1/block/count" headerKey := "User-Agent" headerValue := "Apidog/1.0.0 (https://apidog.com)" - rpcEndpoint := "http://celestia-testnet-consensus.itrocket.net:26657" + rpcEndpoint := "http://rpc-mocha.pops.one:26657" cf := test.NewBuiltinChainFactory(zaptest.NewLogger(t), []*test.ChainSpec{ { @@ -1052,16 +1136,16 @@ func TestSync_Sqc_Disconnect_Gossip_Wasm(t *testing.T) { Client: client, NetworkID: network, SkipPathCreation: true, - }, nil, "", nil) + }, nil, "", nil, true, 780) require.NoError(t, err) - // validator, err := celestia.Validators[0].AccountKeyBech32(ctx, "validator") - // require.NoError(t, err) + validator, err := celestia.Validators[0].AccountKeyBech32(ctx, "validator") + require.NoError(t, err) // Get fund for submit blob - // GetFaucet("http://18.184.170.181:3000/api/get-tia", validator) - // err = testutil.WaitForBlocks(ctx, 10, celestia) - // require.NoError(t, err) + GetFaucet("http://18.184.170.181:3000/api/get-tia", validator) + err = testutil.WaitForBlocks(ctx, 10, celestia) + require.NoError(t, err) err = celestia.GetNode().InitCelestiaDaLightNode(ctx, nodeStore, p2pNetwork, nil) require.NoError(t, err) @@ -1111,7 +1195,7 @@ func TestSync_Sqc_Disconnect_Gossip_Wasm(t *testing.T) { // Create an exec instance execConfig := types.ExecConfig{ - Cmd: strslice.StrSlice([]string{"celestia", "light", "start", "--node.store", nodeStore, "--gateway", "--core.ip", coreIp, "--p2p.network", p2pNetwork, "--keyring.accname", "validator"}), // Replace with your command and arguments + Cmd: strslice.StrSlice([]string{"celestia", "light", "start", "--node.store", nodeStore, "--gateway", "--core.ip", coreIp, "--p2p.network", p2pNetwork, "--keyring.keyname", "validator"}), // Replace with your command and arguments } execIDResp, err := client.ContainerExecCreate(ctx, containerID, execConfig) @@ -1142,7 +1226,6 @@ func TestSync_Sqc_Disconnect_Gossip_Wasm(t *testing.T) { da_config := fmt.Sprintf("{\"base_url\": \"http://test-val-0-%s:26658\", \"timeout\": 60000000000, \"gas_prices\":1.0, \"gas_adjustment\": 1.3, \"namespace_id\": \"%s\", \"auth_token\":\"%s\"}", t.Name(), celestia_namespace_id, celestia_token) configFileOverrides := make(map[string]any) - dymintTomlOverrides["da_layer"] = "celestia" dymintTomlOverrides["namespace_id"] = celestia_namespace_id dymintTomlOverrides["da_config"] = da_config configFileOverrides["config/dymint.toml"] = dymintTomlOverrides @@ -1164,7 +1247,7 @@ func TestSync_Sqc_Disconnect_Gossip_Wasm(t *testing.T) { TrustingPeriod: "112h", EncodingConfig: encodingConfig(), NoHostMount: false, - ModifyGenesis: modifyRollappWasmGenesis(rollappWasmGenesisKV), + ModifyGenesis: modifyRollappWasmGenesis(modifyWasmGenesisKV), ConfigFileOverrides: configFileOverrides, }, NumValidators: &numRollAppVals, @@ -1193,10 +1276,10 @@ func TestSync_Sqc_Disconnect_Gossip_Wasm(t *testing.T) { Client: client, NetworkID: network, SkipPathCreation: true, - }, nil, "", nil) + }, nil, "", nil, true, 780) require.NoError(t, err) - containerID = fmt.Sprintf("rollappevm_1234-1-val-0-%s", t.Name()) + containerID = fmt.Sprintf("ra-rollappwasm_1234-1-val-0-%s", t.Name()) // Get the container details containerJSON, err := client.ContainerInspect(context.Background(), containerID) @@ -1246,8 +1329,7 @@ func TestSync_Sqc_Disconnect_Gossip_Wasm(t *testing.T) { err = rollapp1.FullNodes[0].StopContainer(ctx) require.NoError(t, err) - err = rollapp1.FullNodes[0].StartContainer(ctx) - require.NoError(t, err) + _ = rollapp1.FullNodes[0].StartContainer(ctx) rollappHeight, err := rollapp1.Validators[0].Height(ctx) require.NoError(t, err) @@ -1255,6 +1337,7 @@ func TestSync_Sqc_Disconnect_Gossip_Wasm(t *testing.T) { isFinalized, err := dymension.WaitUntilRollappHeightIsFinalized(ctx, rollapp1.GetChainID(), rollappHeight, 300) require.NoError(t, err) require.True(t, isFinalized) + valHeight, err := rollapp1.Validators[0].Height(ctx) require.NoError(t, err) @@ -1279,15 +1362,11 @@ func TestSync_Sqc_Disconnect_Gossip_Wasm(t *testing.T) { err = rollapp1.Validators[0].StopContainer(ctx) require.NoError(t, err) - err = testutil.WaitForBlocks(ctx, 10, celestia) + err = testutil.WaitForBlocks(ctx, 30, celestia) require.NoError(t, err) - err = rollapp1.Validators[0].StartContainer(ctx) - require.NoError(t, err) + _ = rollapp1.Validators[0].StartContainer(ctx) - isFinalized, err = dymension.WaitUntilRollappHeightIsFinalized(ctx, rollapp1.GetChainID(), rollappHeight, 300) - require.NoError(t, err) - require.True(t, isFinalized) valHeight, err = rollapp1.Validators[0].Height(ctx) require.NoError(t, err) @@ -1323,10 +1402,11 @@ func TestSync_Fullnode_Disconnect_Gossip_EVM(t *testing.T) { dymintTomlOverrides["settlement_node_address"] = fmt.Sprintf("http://dymension_100-1-val-0-%s:26657", t.Name()) dymintTomlOverrides["rollapp_id"] = "rollappevm_1234-1" dymintTomlOverrides["settlement_gas_prices"] = "0adym" - dymintTomlOverrides["max_idle_time"] = "200ms" + dymintTomlOverrides["max_idle_time"] = "250ms" dymintTomlOverrides["max_proof_time"] = "150ms" - dymintTomlOverrides["batch_submit_max_time"] = "5s" - dymintTomlOverrides["block_time"] = "190ms" + dymintTomlOverrides["batch_submit_time"] = "5s" + dymintTomlOverrides["block_time"] = "200ms" + dymintTomlOverrides["p2p_blocksync_enabled"] = "true" configFileOverrides1 := make(map[string]any) configTomlOverrides1 := make(testutil.Toml) @@ -1337,6 +1417,14 @@ func TestSync_Fullnode_Disconnect_Gossip_EVM(t *testing.T) { configFileOverrides1["config/config.toml"] = configTomlOverrides1 + modifyEVMGenesisKV := append( + rollappEVMGenesisKV, + cosmos.GenesisKV{ + Key: "app_state.rollappparams.params.da", + Value: "celestia", + }, + ) + numHubVals := 1 numHubFullNodes := 1 numCelestiaFn := 0 @@ -1344,12 +1432,12 @@ func TestSync_Fullnode_Disconnect_Gossip_EVM(t *testing.T) { numRollAppVals := 1 nodeStore := "/home/celestia/light" p2pNetwork := "mocha-4" - coreIp := "celestia-testnet-consensus.itrocket.net" + coreIp := "mocha-4-consensus.mesa.newmetric.xyz" url := "https://api-mocha.celenium.io/v1/block/count" headerKey := "User-Agent" headerValue := "Apidog/1.0.0 (https://apidog.com)" - rpcEndpoint := "http://celestia-testnet-consensus.itrocket.net:26657" + rpcEndpoint := "http://rpc-mocha.pops.one:26657" cf := test.NewBuiltinChainFactory(zaptest.NewLogger(t), []*test.ChainSpec{ { @@ -1399,16 +1487,16 @@ func TestSync_Fullnode_Disconnect_Gossip_EVM(t *testing.T) { Client: client, NetworkID: network, SkipPathCreation: true, - }, nil, "", nil) + }, nil, "", nil, true, 780) require.NoError(t, err) - // validator, err := celestia.Validators[0].AccountKeyBech32(ctx, "validator") - // require.NoError(t, err) + validator, err := celestia.Validators[0].AccountKeyBech32(ctx, "validator") + require.NoError(t, err) // Get fund for submit blob - // GetFaucet("http://18.184.170.181:3000/api/get-tia", validator) - // err = testutil.WaitForBlocks(ctx, 10, celestia) - // require.NoError(t, err) + GetFaucet("http://18.184.170.181:3000/api/get-tia", validator) + err = testutil.WaitForBlocks(ctx, 10, celestia) + require.NoError(t, err) err = celestia.GetNode().InitCelestiaDaLightNode(ctx, nodeStore, p2pNetwork, nil) require.NoError(t, err) @@ -1458,7 +1546,7 @@ func TestSync_Fullnode_Disconnect_Gossip_EVM(t *testing.T) { // Create an exec instance execConfig := types.ExecConfig{ - Cmd: strslice.StrSlice([]string{"celestia", "light", "start", "--node.store", nodeStore, "--gateway", "--core.ip", coreIp, "--p2p.network", p2pNetwork, "--keyring.accname", "validator"}), // Replace with your command and arguments + Cmd: strslice.StrSlice([]string{"celestia", "light", "start", "--node.store", nodeStore, "--gateway", "--core.ip", coreIp, "--p2p.network", p2pNetwork, "--keyring.keyname", "validator"}), // Replace with your command and arguments } execIDResp, err := client.ContainerExecCreate(ctx, containerID, execConfig) @@ -1489,7 +1577,6 @@ func TestSync_Fullnode_Disconnect_Gossip_EVM(t *testing.T) { da_config := fmt.Sprintf("{\"base_url\": \"http://test-val-0-%s:26658\", \"timeout\": 60000000000, \"gas_prices\":1.0, \"gas_adjustment\": 1.3, \"namespace_id\": \"%s\", \"auth_token\":\"%s\"}", t.Name(), celestia_namespace_id, celestia_token) configFileOverrides := make(map[string]any) - dymintTomlOverrides["da_layer"] = "celestia" dymintTomlOverrides["namespace_id"] = celestia_namespace_id dymintTomlOverrides["da_config"] = da_config configFileOverrides["config/dymint.toml"] = dymintTomlOverrides @@ -1511,7 +1598,7 @@ func TestSync_Fullnode_Disconnect_Gossip_EVM(t *testing.T) { TrustingPeriod: "112h", EncodingConfig: encodingConfig(), NoHostMount: false, - ModifyGenesis: modifyRollappEVMGenesis(rollappEVMGenesisKV), + ModifyGenesis: modifyRollappEVMGenesis(modifyEVMGenesisKV), ConfigFileOverrides: configFileOverrides, }, NumValidators: &numRollAppVals, @@ -1540,10 +1627,10 @@ func TestSync_Fullnode_Disconnect_Gossip_EVM(t *testing.T) { Client: client, NetworkID: network, SkipPathCreation: true, - }, nil, "", nil) + }, nil, "", nil, true, 780) require.NoError(t, err) - containerID = fmt.Sprintf("rollappevm_1234-1-val-0-%s", t.Name()) + containerID = fmt.Sprintf("ra-rollappevm_1234-1-val-0-%s", t.Name()) // Get the container details containerJSON, err := client.ContainerInspect(context.Background(), containerID) @@ -1599,9 +1686,10 @@ func TestSync_Fullnode_Disconnect_Gossip_EVM(t *testing.T) { rollappHeight, err := rollapp1.Validators[0].Height(ctx) require.NoError(t, err) - isFinalized, err := dymension.WaitUntilRollappHeightIsFinalized(ctx, rollapp1.GetChainID(), rollappHeight, 300) + isFinalized, err := dymension.WaitUntilRollappHeightIsFinalized(ctx, rollapp1.GetChainID(), rollappHeight, 500) require.NoError(t, err) require.True(t, isFinalized) + valHeight, err := rollapp1.Validators[0].Height(ctx) require.NoError(t, err) @@ -1629,8 +1717,7 @@ func TestSync_Fullnode_Disconnect_Gossip_EVM(t *testing.T) { err = testutil.WaitForBlocks(ctx, 30, celestia) require.NoError(t, err) - err = rollapp1.FullNodes[0].StartContainer(ctx) - require.NoError(t, err) + _ = rollapp1.FullNodes[0].StartContainer(ctx) valHeight, err = rollapp1.Validators[0].Height(ctx) require.NoError(t, err) @@ -1667,10 +1754,11 @@ func TestSync_Fullnode_Disconnect_Gossip_Wasm(t *testing.T) { dymintTomlOverrides["settlement_node_address"] = fmt.Sprintf("http://dymension_100-1-val-0-%s:26657", t.Name()) dymintTomlOverrides["rollapp_id"] = "rollappwasm_1234-1" dymintTomlOverrides["settlement_gas_prices"] = "0adym" - dymintTomlOverrides["max_idle_time"] = "200ms" + dymintTomlOverrides["max_idle_time"] = "250ms" dymintTomlOverrides["max_proof_time"] = "150ms" - dymintTomlOverrides["batch_submit_max_time"] = "5s" - dymintTomlOverrides["block_time"] = "190ms" + dymintTomlOverrides["batch_submit_time"] = "5s" + dymintTomlOverrides["block_time"] = "200ms" + dymintTomlOverrides["p2p_blocksync_enabled"] = "true" configFileOverrides1 := make(map[string]any) configTomlOverrides1 := make(testutil.Toml) @@ -1681,6 +1769,14 @@ func TestSync_Fullnode_Disconnect_Gossip_Wasm(t *testing.T) { configFileOverrides1["config/config.toml"] = configTomlOverrides1 + modifyWasmGenesisKV := append( + rollappWasmGenesisKV, + cosmos.GenesisKV{ + Key: "app_state.rollappparams.params.da", + Value: "celestia", + }, + ) + numHubVals := 1 numHubFullNodes := 1 numCelestiaFn := 0 @@ -1688,12 +1784,12 @@ func TestSync_Fullnode_Disconnect_Gossip_Wasm(t *testing.T) { numRollAppVals := 1 nodeStore := "/home/celestia/light" p2pNetwork := "mocha-4" - coreIp := "celestia-testnet-consensus.itrocket.net" + coreIp := "mocha-4-consensus.mesa.newmetric.xyz" url := "https://api-mocha.celenium.io/v1/block/count" headerKey := "User-Agent" headerValue := "Apidog/1.0.0 (https://apidog.com)" - rpcEndpoint := "http://celestia-testnet-consensus.itrocket.net:26657" + rpcEndpoint := "http://rpc-mocha.pops.one:26657" cf := test.NewBuiltinChainFactory(zaptest.NewLogger(t), []*test.ChainSpec{ { @@ -1743,16 +1839,16 @@ func TestSync_Fullnode_Disconnect_Gossip_Wasm(t *testing.T) { Client: client, NetworkID: network, SkipPathCreation: true, - }, nil, "", nil) + }, nil, "", nil, true, 780) require.NoError(t, err) - // validator, err := celestia.Validators[0].AccountKeyBech32(ctx, "validator") - // require.NoError(t, err) + validator, err := celestia.Validators[0].AccountKeyBech32(ctx, "validator") + require.NoError(t, err) // Get fund for submit blob - // GetFaucet("http://18.184.170.181:3000/api/get-tia", validator) - // err = testutil.WaitForBlocks(ctx, 10, celestia) - // require.NoError(t, err) + GetFaucet("http://18.184.170.181:3000/api/get-tia", validator) + err = testutil.WaitForBlocks(ctx, 10, celestia) + require.NoError(t, err) err = celestia.GetNode().InitCelestiaDaLightNode(ctx, nodeStore, p2pNetwork, nil) require.NoError(t, err) @@ -1802,7 +1898,7 @@ func TestSync_Fullnode_Disconnect_Gossip_Wasm(t *testing.T) { // Create an exec instance execConfig := types.ExecConfig{ - Cmd: strslice.StrSlice([]string{"celestia", "light", "start", "--node.store", nodeStore, "--gateway", "--core.ip", coreIp, "--p2p.network", p2pNetwork, "--keyring.accname", "validator"}), // Replace with your command and arguments + Cmd: strslice.StrSlice([]string{"celestia", "light", "start", "--node.store", nodeStore, "--gateway", "--core.ip", coreIp, "--p2p.network", p2pNetwork, "--keyring.keyname", "validator"}), // Replace with your command and arguments } execIDResp, err := client.ContainerExecCreate(ctx, containerID, execConfig) @@ -1833,7 +1929,6 @@ func TestSync_Fullnode_Disconnect_Gossip_Wasm(t *testing.T) { da_config := fmt.Sprintf("{\"base_url\": \"http://test-val-0-%s:26658\", \"timeout\": 60000000000, \"gas_prices\":1.0, \"gas_adjustment\": 1.3, \"namespace_id\": \"%s\", \"auth_token\":\"%s\"}", t.Name(), celestia_namespace_id, celestia_token) configFileOverrides := make(map[string]any) - dymintTomlOverrides["da_layer"] = "celestia" dymintTomlOverrides["namespace_id"] = celestia_namespace_id dymintTomlOverrides["da_config"] = da_config configFileOverrides["config/dymint.toml"] = dymintTomlOverrides @@ -1855,7 +1950,7 @@ func TestSync_Fullnode_Disconnect_Gossip_Wasm(t *testing.T) { TrustingPeriod: "112h", EncodingConfig: encodingConfig(), NoHostMount: false, - ModifyGenesis: modifyRollappWasmGenesis(rollappWasmGenesisKV), + ModifyGenesis: modifyRollappWasmGenesis(modifyWasmGenesisKV), ConfigFileOverrides: configFileOverrides, }, NumValidators: &numRollAppVals, @@ -1884,10 +1979,10 @@ func TestSync_Fullnode_Disconnect_Gossip_Wasm(t *testing.T) { Client: client, NetworkID: network, SkipPathCreation: true, - }, nil, "", nil) + }, nil, "", nil, true, 780) require.NoError(t, err) - containerID = fmt.Sprintf("rollappevm_1234-1-val-0-%s", t.Name()) + containerID = fmt.Sprintf("ra-rollappwasm_1234-1-val-0-%s", t.Name()) // Get the container details containerJSON, err := client.ContainerInspect(context.Background(), containerID) @@ -1943,9 +2038,10 @@ func TestSync_Fullnode_Disconnect_Gossip_Wasm(t *testing.T) { rollappHeight, err := rollapp1.Validators[0].Height(ctx) require.NoError(t, err) - isFinalized, err := dymension.WaitUntilRollappHeightIsFinalized(ctx, rollapp1.GetChainID(), rollappHeight, 300) + isFinalized, err := dymension.WaitUntilRollappHeightIsFinalized(ctx, rollapp1.GetChainID(), rollappHeight, 500) require.NoError(t, err) require.True(t, isFinalized) + valHeight, err := rollapp1.Validators[0].Height(ctx) require.NoError(t, err) @@ -1973,8 +2069,7 @@ func TestSync_Fullnode_Disconnect_Gossip_Wasm(t *testing.T) { err = testutil.WaitForBlocks(ctx, 30, celestia) require.NoError(t, err) - err = rollapp1.FullNodes[0].StartContainer(ctx) - require.NoError(t, err) + _ = rollapp1.FullNodes[0].StartContainer(ctx) valHeight, err = rollapp1.Validators[0].Height(ctx) require.NoError(t, err) diff --git a/tests/fullnode_sync_test.go b/tests/fullnode_sync_test.go index c05e82b2..fb0575db 100644 --- a/tests/fullnode_sync_test.go +++ b/tests/fullnode_sync_test.go @@ -15,6 +15,7 @@ import ( "go.uber.org/zap/zaptest" test "github.com/decentrio/rollup-e2e-testing" + "github.com/decentrio/rollup-e2e-testing/cosmos" "github.com/decentrio/rollup-e2e-testing/cosmos/hub/celes_hub" "github.com/decentrio/rollup-e2e-testing/cosmos/hub/dym_hub" "github.com/decentrio/rollup-e2e-testing/cosmos/rollapp/dym_rollapp" @@ -68,7 +69,7 @@ func TestFullnodeSync_EVM(t *testing.T) { gas_price_rollapp1 := "0adym" maxIdleTime1 := "5s" maxProofTime := "500ms" - configFileOverrides := overridesDymintToml(settlement_layer_rollapp1, settlement_node_address, rollapp1_id, gas_price_rollapp1, maxIdleTime1, maxProofTime, "20s", true) + configFileOverrides := overridesDymintToml(settlement_layer_rollapp1, settlement_node_address, rollapp1_id, gas_price_rollapp1, maxIdleTime1, maxProofTime, "50s", true) // Create chain factory with dymension numHubVals := 1 @@ -76,6 +77,14 @@ func TestFullnodeSync_EVM(t *testing.T) { numRollAppVals := 1 numRollAppFn := 1 + modifyEVMGenesisKV := append( + rollappEVMGenesisKV, + cosmos.GenesisKV{ + Key: "app_state.rollappparams.params.da", + Value: "grpc", + }, + ) + cf := test.NewBuiltinChainFactory(zaptest.NewLogger(t), []*test.ChainSpec{ { Name: "rollapp1", @@ -93,7 +102,7 @@ func TestFullnodeSync_EVM(t *testing.T) { TrustingPeriod: "112h", EncodingConfig: encodingConfig(), NoHostMount: false, - ModifyGenesis: modifyRollappEVMGenesis(rollappEVMGenesisKV), + ModifyGenesis: modifyRollappEVMGenesis(modifyEVMGenesisKV), ConfigFileOverrides: configFileOverrides, }, NumValidators: &numRollAppVals, @@ -131,7 +140,7 @@ func TestFullnodeSync_EVM(t *testing.T) { // This can be used to write to the block database which will index all block data e.g. txs, msgs, events, etc. // BlockDatabaseFile: test.DefaultBlockDatabaseFilepath(), - }, nil, "", nil) + }, nil, "", nil, false, 780) require.NoError(t, err) // Wait for rollapp finalized @@ -191,9 +200,12 @@ func TestFullnodeSync_Wasm(t *testing.T) { dymintTomlOverrides["node_address"] = fmt.Sprintf("http://dymension_100-1-val-0-%s:26657", t.Name()) dymintTomlOverrides["rollapp_id"] = "rollappwasm_1234-1" dymintTomlOverrides["gas_prices"] = "0adym" - dymintTomlOverrides["empty_blocks_max_time"] = "3s" - dymintTomlOverrides["da_layer"] = "grpc" + dymintTomlOverrides["m"] = "0adym" + dymintTomlOverrides["max_idle_time"] = "3s" + dymintTomlOverrides["max_proof_time"] = "500ms" + dymintTomlOverrides["batch_submit_time"] = "50s" dymintTomlOverrides["da_config"] = "{\"host\":\"host.docker.internal\",\"port\": 7980}" + dymintTomlOverrides["p2p_blocksync_enabled"] = "false" configFileOverrides["config/dymint.toml"] = dymintTomlOverrides // Create chain factory with dymension @@ -202,6 +214,14 @@ func TestFullnodeSync_Wasm(t *testing.T) { numRollAppVals := 1 numRollAppFn := 1 + modifyWasmGenesisKV := append( + rollappWasmGenesisKV, + cosmos.GenesisKV{ + Key: "app_state.rollappparams.params.da", + Value: "grpc", + }, + ) + cf := test.NewBuiltinChainFactory(zaptest.NewLogger(t), []*test.ChainSpec{ { Name: "rollapp1", @@ -219,7 +239,7 @@ func TestFullnodeSync_Wasm(t *testing.T) { TrustingPeriod: "112h", EncodingConfig: encodingConfig(), NoHostMount: false, - ModifyGenesis: nil, + ModifyGenesis: modifyRollappWasmGenesis(modifyWasmGenesisKV), ConfigFileOverrides: configFileOverrides, }, NumValidators: &numRollAppVals, @@ -257,7 +277,7 @@ func TestFullnodeSync_Wasm(t *testing.T) { // This can be used to write to the block database which will index all block data e.g. txs, msgs, events, etc. // BlockDatabaseFile: test.DefaultBlockDatabaseFilepath(), - }, nil, "", nil) + }, nil, "", nil, false, 780) require.NoError(t, err) // Wait for rollapp finalized @@ -316,7 +336,8 @@ func TestFullnodeSync_Celestia_EVM(t *testing.T) { dymintTomlOverrides["settlement_gas_prices"] = "0adym" dymintTomlOverrides["max_idle_time"] = "3s" dymintTomlOverrides["max_proof_time"] = "500ms" - dymintTomlOverrides["batch_submit_max_time"] = "80s" + dymintTomlOverrides["batch_submit_time"] = "50s" + dymintTomlOverrides["p2p_blocksync_enabled"] = "false" configFileOverrides1 := make(map[string]any) configTomlOverrides1 := make(testutil.Toml) @@ -327,6 +348,14 @@ func TestFullnodeSync_Celestia_EVM(t *testing.T) { configFileOverrides1["config/config.toml"] = configTomlOverrides1 + modifyEVMGenesisKV := append( + rollappEVMGenesisKV, + cosmos.GenesisKV{ + Key: "app_state.rollappparams.params.da", + Value: "celestia", + }, + ) + // Create chain factory with dymension numHubVals := 1 numHubFullNodes := 1 @@ -335,14 +364,14 @@ func TestFullnodeSync_Celestia_EVM(t *testing.T) { numRollAppVals := 1 nodeStore := "/home/celestia/light" p2pNetwork := "mocha-4" - coreIp := "celestia-testnet-consensus.itrocket.net" + coreIp := "mocha-4-consensus.mesa.newmetric.xyz" // trustedHash := "\"A62DD37EDF3DFF5A7383C6B5AA2AC619D1F8C8FEB7BA07730E50BBAAC8F2FF0C\"" // sampleFrom := 2395649 url := "https://api-mocha.celenium.io/v1/block/count" headerKey := "User-Agent" headerValue := "Apidog/1.0.0 (https://apidog.com)" - rpcEndpoint := "http://celestia-testnet-consensus.itrocket.net:26657" + rpcEndpoint := "http://rpc-mocha.pops.one:26657" cf := test.NewBuiltinChainFactory(zaptest.NewLogger(t), []*test.ChainSpec{ { @@ -387,7 +416,7 @@ func TestFullnodeSync_Celestia_EVM(t *testing.T) { rep := testreporter.NewNopReporter() eRep := rep.RelayerExecReporter(t) - _ = ic.Build(ctx, eRep, test.InterchainBuildOptions{ + err = ic.Build(ctx, eRep, test.InterchainBuildOptions{ TestName: t.Name(), Client: client, NetworkID: network, @@ -395,22 +424,21 @@ func TestFullnodeSync_Celestia_EVM(t *testing.T) { // This can be used to write to the block database which will index all block data e.g. txs, msgs, events, etc. // BlockDatabaseFile: test.DefaultBlockDatabaseFilepath(), - }, nil, "", nil) - // require.NoError(t, err) + }, nil, "", nil, true, 780) + require.NoError(t, err) - // validator, err := celestia.Validators[0].AccountKeyBech32(ctx, "validator") - // require.NoError(t, err) + validator, err := celestia.Validators[0].AccountKeyBech32(ctx, "validator") + require.NoError(t, err) // Get fund for submit blob - // GetFaucet("http://18.184.170.181:3000/api/get-tia", validator) - // err = testutil.WaitForBlocks(ctx, 10, celestia) - // require.NoError(t, err) + GetFaucet("http://18.184.170.181:3000/api/get-tia", validator) + + time.Sleep(30 * time.Second) err = celestia.GetNode().InitCelestiaDaLightNode(ctx, nodeStore, p2pNetwork, nil) require.NoError(t, err) - err = testutil.WaitForBlocks(ctx, 3, celestia) - require.NoError(t, err) + time.Sleep(30 * time.Second) file, err := os.Open("/tmp/celestia/light/config.toml") require.NoError(t, err) @@ -454,7 +482,7 @@ func TestFullnodeSync_Celestia_EVM(t *testing.T) { // Create an exec instance execConfig := types.ExecConfig{ - Cmd: strslice.StrSlice([]string{"celestia", "light", "start", "--node.store", nodeStore, "--gateway", "--core.ip", coreIp, "--p2p.network", p2pNetwork, "--keyring.accname", "validator"}), // Replace with your command and arguments + Cmd: strslice.StrSlice([]string{"celestia", "light", "start", "--node.store", nodeStore, "--gateway", "--core.ip", coreIp, "--p2p.network", p2pNetwork, "--keyring.keyname", "validator"}), // Replace with your command and arguments } execIDResp, err := client.ContainerExecCreate(ctx, containerID, execConfig) @@ -473,8 +501,7 @@ func TestFullnodeSync_Celestia_EVM(t *testing.T) { panic(err) } - err = testutil.WaitForBlocks(ctx, 10, celestia) - require.NoError(t, err) + time.Sleep(30 * time.Second) celestia_token, err := celestia.GetNode().GetAuthTokenCelestiaDaLight(ctx, p2pNetwork, nodeStore) require.NoError(t, err) @@ -485,7 +512,6 @@ func TestFullnodeSync_Celestia_EVM(t *testing.T) { da_config := fmt.Sprintf("{\"base_url\": \"http://test-val-0-%s:26658\", \"timeout\": 60000000000, \"gas_prices\":1.0, \"gas_adjustment\": 1.3, \"namespace_id\": \"%s\", \"auth_token\":\"%s\"}", t.Name(), celestia_namespace_id, celestia_token) configFileOverrides := make(map[string]any) - dymintTomlOverrides["da_layer"] = "celestia" dymintTomlOverrides["namespace_id"] = celestia_namespace_id dymintTomlOverrides["da_config"] = da_config configFileOverrides["config/dymint.toml"] = dymintTomlOverrides @@ -507,7 +533,7 @@ func TestFullnodeSync_Celestia_EVM(t *testing.T) { TrustingPeriod: "112h", EncodingConfig: encodingConfig(), NoHostMount: false, - ModifyGenesis: modifyRollappEVMGenesis(rollappEVMGenesisKV), + ModifyGenesis: modifyRollappEVMGenesis(modifyEVMGenesisKV), ConfigFileOverrides: configFileOverrides, }, NumValidators: &numRollAppVals, @@ -539,7 +565,7 @@ func TestFullnodeSync_Celestia_EVM(t *testing.T) { // This can be used to write to the block database which will index all block data e.g. txs, msgs, events, etc. // BlockDatabaseFile: test.DefaultBlockDatabaseFilepath(), - }, nil, "", nil) + }, nil, "", nil, false, 780) require.NoError(t, err) rollappHeight, err := rollapp1.Validators[0].Height(ctx) @@ -585,7 +611,8 @@ func TestFullnodeSync_Celestia_Wasm(t *testing.T) { dymintTomlOverrides["settlement_gas_prices"] = "0adym" dymintTomlOverrides["max_idle_time"] = "3s" dymintTomlOverrides["max_proof_time"] = "500ms" - dymintTomlOverrides["batch_submit_max_time"] = "80s" + dymintTomlOverrides["batch_submit_time"] = "50s" + dymintTomlOverrides["p2p_blocksync_enabled"] = "false" configFileOverrides1 := make(map[string]any) configTomlOverrides1 := make(testutil.Toml) @@ -596,6 +623,14 @@ func TestFullnodeSync_Celestia_Wasm(t *testing.T) { configFileOverrides1["config/config.toml"] = configTomlOverrides1 + modifyWasmGenesisKV := append( + rollappWasmGenesisKV, + cosmos.GenesisKV{ + Key: "app_state.rollappparams.params.da", + Value: "celestia", + }, + ) + // Create chain factory with dymension numHubVals := 1 numHubFullNodes := 1 @@ -604,14 +639,14 @@ func TestFullnodeSync_Celestia_Wasm(t *testing.T) { numRollAppVals := 1 nodeStore := "/home/celestia/light" p2pNetwork := "mocha-4" - coreIp := "celestia-testnet-consensus.itrocket.net" + coreIp := "mocha-4-consensus.mesa.newmetric.xyz" // trustedHash := "\"A62DD37EDF3DFF5A7383C6B5AA2AC619D1F8C8FEB7BA07730E50BBAAC8F2FF0C\"" // sampleFrom := 2395649 url := "https://api-mocha.celenium.io/v1/block/count" headerKey := "User-Agent" headerValue := "Apidog/1.0.0 (https://apidog.com)" - rpcEndpoint := "http://celestia-testnet-consensus.itrocket.net:26657" + rpcEndpoint := "http://rpc-mocha.pops.one:26657" cf := test.NewBuiltinChainFactory(zaptest.NewLogger(t), []*test.ChainSpec{ { @@ -656,7 +691,7 @@ func TestFullnodeSync_Celestia_Wasm(t *testing.T) { rep := testreporter.NewNopReporter() eRep := rep.RelayerExecReporter(t) - _ = ic.Build(ctx, eRep, test.InterchainBuildOptions{ + err = ic.Build(ctx, eRep, test.InterchainBuildOptions{ TestName: t.Name(), Client: client, NetworkID: network, @@ -664,16 +699,16 @@ func TestFullnodeSync_Celestia_Wasm(t *testing.T) { // This can be used to write to the block database which will index all block data e.g. txs, msgs, events, etc. // BlockDatabaseFile: test.DefaultBlockDatabaseFilepath(), - }, nil, "", nil) - // require.NoError(t, err) + }, nil, "", nil, true, 780) + require.NoError(t, err) - // validator, err := celestia.Validators[0].AccountKeyBech32(ctx, "validator") - // require.NoError(t, err) + validator, err := celestia.Validators[0].AccountKeyBech32(ctx, "validator") + require.NoError(t, err) // Get fund for submit blob - // GetFaucet("http://18.184.170.181:3000/api/get-tia", validator) - // err = testutil.WaitForBlocks(ctx, 10, celestia) - // require.NoError(t, err) + GetFaucet("http://18.184.170.181:3000/api/get-tia", validator) + err = testutil.WaitForBlocks(ctx, 10, celestia) + require.NoError(t, err) err = celestia.GetNode().InitCelestiaDaLightNode(ctx, nodeStore, p2pNetwork, nil) require.NoError(t, err) @@ -723,7 +758,7 @@ func TestFullnodeSync_Celestia_Wasm(t *testing.T) { // Create an exec instance execConfig := types.ExecConfig{ - Cmd: strslice.StrSlice([]string{"celestia", "light", "start", "--node.store", nodeStore, "--gateway", "--core.ip", coreIp, "--p2p.network", p2pNetwork, "--keyring.accname", "validator"}), // Replace with your command and arguments + Cmd: strslice.StrSlice([]string{"celestia", "light", "start", "--node.store", nodeStore, "--gateway", "--core.ip", coreIp, "--p2p.network", p2pNetwork, "--keyring.keyname", "validator"}), // Replace with your command and arguments } execIDResp, err := client.ContainerExecCreate(ctx, containerID, execConfig) @@ -754,7 +789,6 @@ func TestFullnodeSync_Celestia_Wasm(t *testing.T) { da_config := fmt.Sprintf("{\"base_url\": \"http://test-val-0-%s:26658\", \"timeout\": 60000000000, \"gas_prices\":1.0, \"gas_adjustment\": 1.3, \"namespace_id\": \"%s\", \"auth_token\":\"%s\"}", t.Name(), celestia_namespace_id, celestia_token) configFileOverrides := make(map[string]any) - dymintTomlOverrides["da_layer"] = "celestia" dymintTomlOverrides["namespace_id"] = celestia_namespace_id dymintTomlOverrides["da_config"] = da_config configFileOverrides["config/dymint.toml"] = dymintTomlOverrides @@ -776,7 +810,7 @@ func TestFullnodeSync_Celestia_Wasm(t *testing.T) { TrustingPeriod: "112h", EncodingConfig: encodingConfig(), NoHostMount: false, - ModifyGenesis: nil, + ModifyGenesis: modifyRollappWasmGenesis(modifyWasmGenesisKV), ConfigFileOverrides: configFileOverrides, }, NumValidators: &numRollAppVals, @@ -808,7 +842,7 @@ func TestFullnodeSync_Celestia_Wasm(t *testing.T) { // This can be used to write to the block database which will index all block data e.g. txs, msgs, events, etc. // BlockDatabaseFile: test.DefaultBlockDatabaseFilepath(), - }, nil, "", nil) + }, nil, "", nil, true, 780) require.NoError(t, err) rollappHeight, err := rollapp1.Validators[0].Height(ctx) diff --git a/tests/genesis_transfer_test.go b/tests/genesis_transfer_test.go index ef29a13c..cd858718 100644 --- a/tests/genesis_transfer_test.go +++ b/tests/genesis_transfer_test.go @@ -1,634 +1,644 @@ package tests -import ( - "context" - "fmt" - "testing" - - transfertypes "github.com/cosmos/ibc-go/v7/modules/apps/transfer/types" - "github.com/stretchr/testify/require" - "go.uber.org/zap/zaptest" - - test "github.com/decentrio/rollup-e2e-testing" - "github.com/decentrio/rollup-e2e-testing/cosmos/hub/dym_hub" - "github.com/decentrio/rollup-e2e-testing/cosmos/rollapp/dym_rollapp" - "github.com/decentrio/rollup-e2e-testing/ibc" - "github.com/decentrio/rollup-e2e-testing/relayer" - "github.com/decentrio/rollup-e2e-testing/testreporter" - "github.com/decentrio/rollup-e2e-testing/testutil" -) +// import ( +// "context" +// "fmt" +// "testing" + +// transfertypes "github.com/cosmos/ibc-go/v7/modules/apps/transfer/types" +// "github.com/stretchr/testify/require" +// "go.uber.org/zap/zaptest" + +// test "github.com/decentrio/rollup-e2e-testing" +// "github.com/decentrio/rollup-e2e-testing/cosmos/hub/dym_hub" +// "github.com/decentrio/rollup-e2e-testing/cosmos/rollapp/dym_rollapp" +// "github.com/decentrio/rollup-e2e-testing/ibc" +// "github.com/decentrio/rollup-e2e-testing/relayer" +// "github.com/decentrio/rollup-e2e-testing/testreporter" +// "github.com/decentrio/rollup-e2e-testing/testutil" +// ) // TestGenesisTransfer_EVM -func TestGenesisTransferBridgeBlocking_EVM(t *testing.T) { - if testing.Short() { - t.Skip() - } - - ctx := context.Background() - - configFileOverrides := make(map[string]any) - dymintTomlOverrides := make(testutil.Toml) - dymintTomlOverrides["settlement_layer"] = "dymension" - dymintTomlOverrides["settlement_node_address"] = fmt.Sprintf("http://dymension_100-1-val-0-%s:26657", t.Name()) - dymintTomlOverrides["rollapp_id"] = "rollappevm_1234-1" - dymintTomlOverrides["settlement_gas_prices"] = "0adym" - dymintTomlOverrides["max_idle_time"] = "3s" - dymintTomlOverrides["max_proof_time"] = "500ms" - dymintTomlOverrides["batch_submit_max_time"] = "100s" - - configFileOverrides["config/dymint.toml"] = dymintTomlOverrides - // Create chain factory with dymension - numHubVals := 1 - numHubFullNodes := 1 - numRollAppFn := 0 - numRollAppVals := 1 - - cf := test.NewBuiltinChainFactory(zaptest.NewLogger(t), []*test.ChainSpec{ - { - Name: "rollapp1", - ChainConfig: ibc.ChainConfig{ - Type: "rollapp-dym", - Name: "rollapp-temp", - ChainID: "rollappevm_1234-1", - Images: []ibc.DockerImage{rollappEVMImage}, - Bin: "rollappd", - Bech32Prefix: "ethm", - Denom: "urax", - CoinType: "60", - GasPrices: "0.0urax", - GasAdjustment: 1.1, - TrustingPeriod: "112h", - EncodingConfig: encodingConfig(), - NoHostMount: false, - ModifyGenesis: modifyRollappEVMGenesis(rollappEVMGenesisKV), - ConfigFileOverrides: configFileOverrides, - }, - NumValidators: &numRollAppVals, - NumFullNodes: &numRollAppFn, - }, - { - Name: "dymension-hub", - ChainConfig: dymensionConfig, - NumValidators: &numHubVals, - NumFullNodes: &numHubFullNodes, - }, - }) - - // Get chains from the chain factory - chains, err := cf.Chains(t.Name()) - require.NoError(t, err) - - rollapp1 := chains[0].(*dym_rollapp.DymRollApp) - dymension := chains[1].(*dym_hub.DymHub) - - // Relayer Factory - client, network := test.DockerSetup(t) - - r := test.NewBuiltinRelayerFactory(ibc.CosmosRly, zaptest.NewLogger(t), - relayer.CustomDockerImage(RelayerMainRepo, relayerVersion, "100:1000"), relayer.ImagePull(pullRelayerImage), - ).Build(t, client, "relayer", network) - - ic := test.NewSetup(). - AddRollUp(dymension, rollapp1). - AddRelayer(r, "relayer"). - AddLink(test.InterchainLink{ - Chain1: dymension, - Chain2: rollapp1, - Relayer: r, - Path: ibcPath, - }) - - rep := testreporter.NewNopReporter() - eRep := rep.RelayerExecReporter(t) - - err = ic.Build(ctx, eRep, test.InterchainBuildOptions{ - TestName: t.Name(), - Client: client, - NetworkID: network, - SkipPathCreation: true, - - // This can be used to write to the block database which will index all block data e.g. txs, msgs, events, etc. - // BlockDatabaseFile: test.DefaultBlockDatabaseFilepath(), - }, nil, "", nil) - require.NoError(t, err) - - CreateChannel(ctx, t, r, eRep, dymension.CosmosChain, rollapp1.CosmosChain, ibcPath) - - // Create some user accounts on both chains - users := test.GetAndFundTestUsers(t, ctx, t.Name(), walletAmount, dymension, rollapp1) - - // Get our Bech32 encoded user addresses - dymensionUser, rollappUser := users[0], users[1] - - dymensionUserAddr := dymensionUser.FormattedAddress() - rollappUserAddr := rollappUser.FormattedAddress() - - channel, err := ibc.GetTransferChannel(ctx, r, eRep, dymension.Config().ChainID, rollapp1.Config().ChainID) - require.NoError(t, err) - - err = r.StartRelayer(ctx, eRep, ibcPath) - require.NoError(t, err) - - // Send a normal ibc tx from RA -> Hub - transferData := ibc.WalletData{ - Address: dymensionUserAddr, - Denom: rollapp1.Config().Denom, - Amount: transferAmount, - } - _, err = rollapp1.SendIBCTransfer(ctx, channel.ChannelID, rollappUserAddr, transferData, ibc.TransferOptions{}) - require.Error(t, err) - - // Compose an IBC transfer and send from dymension -> rollapp - transferData = ibc.WalletData{ - Address: rollappUserAddr, - Denom: dymension.Config().Denom, - Amount: transferAmount, - } - - // Compose an IBC transfer and send from Hub -> rollapp - _, err = dymension.SendIBCTransfer(ctx, channel.ChannelID, dymensionUserAddr, transferData, ibc.TransferOptions{}) - require.Error(t, err) - - err = testutil.WaitForBlocks(ctx, 10, dymension, rollapp1) - require.NoError(t, err) - - // Get the IBC denom - dymensionTokenDenom := transfertypes.GetPrefixedDenom(channel.Counterparty.PortID, channel.Counterparty.ChannelID, dymension.Config().Denom) - dymensionIBCDenom := transfertypes.ParseDenomTrace(dymensionTokenDenom).IBCDenom() - - // Get the IBC denom for urax on Hub - rollappTokenDenom := transfertypes.GetPrefixedDenom(channel.Counterparty.PortID, channel.Counterparty.ChannelID, rollapp1.Config().Denom) - rollappIBCDenom := transfertypes.ParseDenomTrace(rollappTokenDenom).IBCDenom() - - // after a while, refund token - testutil.AssertBalance(t, ctx, dymension, dymensionUserAddr, dymension.Config().Denom, walletAmount) - testutil.AssertBalance(t, ctx, dymension, dymensionUserAddr, rollappIBCDenom, zeroBal) - - testutil.AssertBalance(t, ctx, rollapp1, rollappUserAddr, rollapp1.Config().Denom, walletAmount) - testutil.AssertBalance(t, ctx, rollapp1, rollappUserAddr, dymensionIBCDenom, zeroBal) -} - -func TestGenesisTransferBridgeBlocking_Wasm(t *testing.T) { - if testing.Short() { - t.Skip() - } - - ctx := context.Background() - - configFileOverrides := make(map[string]any) - dymintTomlOverrides := make(testutil.Toml) - dymintTomlOverrides["settlement_layer"] = "dymension" - dymintTomlOverrides["settlement_node_address"] = fmt.Sprintf("http://dymension_100-1-val-0-%s:26657", t.Name()) - dymintTomlOverrides["rollapp_id"] = "rollappwasm_1234-1" - dymintTomlOverrides["settlement_gas_prices"] = "0adym" - dymintTomlOverrides["max_idle_time"] = "3s" - dymintTomlOverrides["max_proof_time"] = "500ms" - dymintTomlOverrides["batch_submit_max_time"] = "100s" - - configFileOverrides["config/dymint.toml"] = dymintTomlOverrides - // Create chain factory with dymension - numHubVals := 1 - numHubFullNodes := 1 - numRollAppFn := 0 - numRollAppVals := 1 - - cf := test.NewBuiltinChainFactory(zaptest.NewLogger(t), []*test.ChainSpec{ - { - Name: "rollapp1", - ChainConfig: ibc.ChainConfig{ - Type: "rollapp-dym", - Name: "rollapp-temp", - ChainID: "rollappwasm_1234-1", - Images: []ibc.DockerImage{rollappWasmImage}, - Bin: "rollappd", - Bech32Prefix: "rol", - Denom: "urax", - CoinType: "118", - GasPrices: "0.0urax", - GasAdjustment: 1.1, - TrustingPeriod: "112h", - EncodingConfig: encodingConfig(), - NoHostMount: false, - ModifyGenesis: modifyRollappWasmGenesis(rollappWasmGenesisKV), - ConfigFileOverrides: configFileOverrides, - }, - NumValidators: &numRollAppVals, - NumFullNodes: &numRollAppFn, - }, - { - Name: "dymension-hub", - ChainConfig: dymensionConfig, - NumValidators: &numHubVals, - NumFullNodes: &numHubFullNodes, - }, - }) - - // Get chains from the chain factory - chains, err := cf.Chains(t.Name()) - require.NoError(t, err) - - rollapp1 := chains[0].(*dym_rollapp.DymRollApp) - dymension := chains[1].(*dym_hub.DymHub) - - // Relayer Factory - client, network := test.DockerSetup(t) - - r := test.NewBuiltinRelayerFactory(ibc.CosmosRly, zaptest.NewLogger(t), - relayer.CustomDockerImage(RelayerMainRepo, relayerVersion, "100:1000"), relayer.ImagePull(pullRelayerImage), - ).Build(t, client, "relayer", network) - - ic := test.NewSetup(). - AddRollUp(dymension, rollapp1). - AddRelayer(r, "relayer"). - AddLink(test.InterchainLink{ - Chain1: dymension, - Chain2: rollapp1, - Relayer: r, - Path: ibcPath, - }) - - rep := testreporter.NewNopReporter() - eRep := rep.RelayerExecReporter(t) - - err = ic.Build(ctx, eRep, test.InterchainBuildOptions{ - TestName: t.Name(), - Client: client, - NetworkID: network, - SkipPathCreation: true, - - // This can be used to write to the block database which will index all block data e.g. txs, msgs, events, etc. - // BlockDatabaseFile: test.DefaultBlockDatabaseFilepath(), - }, nil, "", nil) - require.NoError(t, err) - - CreateChannel(ctx, t, r, eRep, dymension.CosmosChain, rollapp1.CosmosChain, ibcPath) - - // Create some user accounts on both chains - users := test.GetAndFundTestUsers(t, ctx, t.Name(), walletAmount, dymension, rollapp1) - - // Get our Bech32 encoded user addresses - dymensionUser, rollappUser := users[0], users[1] - - dymensionUserAddr := dymensionUser.FormattedAddress() - rollappUserAddr := rollappUser.FormattedAddress() - - channel, err := ibc.GetTransferChannel(ctx, r, eRep, dymension.Config().ChainID, rollapp1.Config().ChainID) - require.NoError(t, err) - - err = r.StartRelayer(ctx, eRep, ibcPath) - require.NoError(t, err) - - // Send a normal ibc tx from RA -> Hub - transferData := ibc.WalletData{ - Address: dymensionUserAddr, - Denom: rollapp1.Config().Denom, - Amount: transferAmount, - } - _, err = rollapp1.SendIBCTransfer(ctx, channel.ChannelID, rollappUserAddr, transferData, ibc.TransferOptions{}) - require.Error(t, err) - - // Compose an IBC transfer and send from dymension -> rollapp - transferData = ibc.WalletData{ - Address: rollappUserAddr, - Denom: dymension.Config().Denom, - Amount: transferAmount, - } - - // Compose an IBC transfer and send from Hub -> rollapp - _, err = dymension.SendIBCTransfer(ctx, channel.ChannelID, dymensionUserAddr, transferData, ibc.TransferOptions{}) - require.Error(t, err) - - err = testutil.WaitForBlocks(ctx, 10, dymension, rollapp1) - require.NoError(t, err) - - // Get the IBC denom - dymensionTokenDenom := transfertypes.GetPrefixedDenom(channel.Counterparty.PortID, channel.Counterparty.ChannelID, dymension.Config().Denom) - dymensionIBCDenom := transfertypes.ParseDenomTrace(dymensionTokenDenom).IBCDenom() - - // Get the IBC denom for urax on Hub - rollappTokenDenom := transfertypes.GetPrefixedDenom(channel.Counterparty.PortID, channel.Counterparty.ChannelID, rollapp1.Config().Denom) - rollappIBCDenom := transfertypes.ParseDenomTrace(rollappTokenDenom).IBCDenom() - - // after a while, refund token - testutil.AssertBalance(t, ctx, dymension, dymensionUserAddr, dymension.Config().Denom, walletAmount) - testutil.AssertBalance(t, ctx, dymension, dymensionUserAddr, rollappIBCDenom, zeroBal) - - testutil.AssertBalance(t, ctx, rollapp1, rollappUserAddr, rollapp1.Config().Denom, walletAmount) - testutil.AssertBalance(t, ctx, rollapp1, rollappUserAddr, dymensionIBCDenom, zeroBal) -} - -func TestGenesisTransferConnectionBlock_EVM(t *testing.T) { - if testing.Short() { - t.Skip() - } - - ctx := context.Background() - - configFileOverrides := make(map[string]any) - dymintTomlOverrides := make(testutil.Toml) - dymintTomlOverrides["settlement_layer"] = "dymension" - dymintTomlOverrides["settlement_node_address"] = fmt.Sprintf("http://dymension_100-1-val-0-%s:26657", t.Name()) - dymintTomlOverrides["rollapp_id"] = "rollappevm_1234-1" - dymintTomlOverrides["settlement_gas_prices"] = "0adym" - dymintTomlOverrides["max_idle_time"] = "3s" - dymintTomlOverrides["max_proof_time"] = "500ms" - dymintTomlOverrides["batch_submit_max_time"] = "100s" - - configFileOverrides["config/dymint.toml"] = dymintTomlOverrides - // Create chain factory with dymension - numHubVals := 1 - numHubFullNodes := 1 - numRollAppFn := 0 - numRollAppVals := 1 - - cf := test.NewBuiltinChainFactory(zaptest.NewLogger(t), []*test.ChainSpec{ - { - Name: "rollapp1", - ChainConfig: ibc.ChainConfig{ - Type: "rollapp-dym", - Name: "rollapp-temp", - ChainID: "rollappevm_1234-1", - Images: []ibc.DockerImage{rollappEVMImage}, - Bin: "rollappd", - Bech32Prefix: "ethm", - Denom: "urax", - CoinType: "60", - GasPrices: "0.0urax", - GasAdjustment: 1.1, - TrustingPeriod: "112h", - EncodingConfig: encodingConfig(), - NoHostMount: false, - ModifyGenesis: modifyRollappEVMGenesis(rollappEVMGenesisKV), - ConfigFileOverrides: configFileOverrides, - }, - NumValidators: &numRollAppVals, - NumFullNodes: &numRollAppFn, - }, - { - Name: "dymension-hub", - ChainConfig: dymensionConfig, - NumValidators: &numHubVals, - NumFullNodes: &numHubFullNodes, - }, - }) - - // Get chains from the chain factory - chains, err := cf.Chains(t.Name()) - require.NoError(t, err) - - rollapp1 := chains[0].(*dym_rollapp.DymRollApp) - dymension := chains[1].(*dym_hub.DymHub) - - // Relayer Factory - client, network := test.DockerSetup(t) - - r := test.NewBuiltinRelayerFactory(ibc.CosmosRly, zaptest.NewLogger(t), - relayer.CustomDockerImage(RelayerMainRepo, relayerVersion, "100:1000"), relayer.ImagePull(pullRelayerImage), - ).Build(t, client, "relayer", network) - - ic := test.NewSetup(). - AddRollUp(dymension, rollapp1). - AddRelayer(r, "relayer"). - AddLink(test.InterchainLink{ - Chain1: dymension, - Chain2: rollapp1, - Relayer: r, - Path: ibcPath, - }) - - rep := testreporter.NewNopReporter() - eRep := rep.RelayerExecReporter(t) - - err = ic.Build(ctx, eRep, test.InterchainBuildOptions{ - TestName: t.Name(), - Client: client, - NetworkID: network, - SkipPathCreation: true, - - // This can be used to write to the block database which will index all block data e.g. txs, msgs, events, etc. - // BlockDatabaseFile: test.DefaultBlockDatabaseFilepath(), - }, nil, "", nil) - require.NoError(t, err) - - CreateChannel(ctx, t, r, eRep, dymension.CosmosChain, rollapp1.CosmosChain, ibcPath) - - // Create some user accounts on both chains - users := test.GetAndFundTestUsers(t, ctx, t.Name(), walletAmount, dymension, rollapp1) - - // Get our Bech32 encoded user addresses - dymensionUser, rollappUser := users[0], users[1] - - dymensionUserAddr := dymensionUser.FormattedAddress() - rollappUserAddr := rollappUser.FormattedAddress() - - channel, err := ibc.GetTransferChannel(ctx, r, eRep, dymension.Config().ChainID, rollapp1.Config().ChainID) - require.NoError(t, err) - - err = r.StartRelayer(ctx, eRep, ibcPath) - require.NoError(t, err) - - err = testutil.WaitForBlocks(ctx, 10, dymension, rollapp1) - require.NoError(t, err) - - // Send a normal ibc tx from RA -> Hub - transferData := ibc.WalletData{ - Address: dymensionUserAddr, - Denom: rollapp1.Config().Denom, - Amount: transferAmount, - } - _, err = rollapp1.SendIBCTransfer(ctx, channel.ChannelID, rollappUserAddr, transferData, ibc.TransferOptions{}) - require.NoError(t, err) - - rollappHeight, err := rollapp1.GetNode().Height(ctx) - require.NoError(t, err) - - // Assert balance was updated on the hub - testutil.AssertBalance(t, ctx, rollapp1, rollappUserAddr, rollapp1.Config().Denom, walletAmount.Sub(transferData.Amount)) - - // wait until the packet is finalized - isFinalized, err := dymension.WaitUntilRollappHeightIsFinalized(ctx, rollapp1.GetChainID(), rollappHeight, 300) - require.NoError(t, err) - require.True(t, isFinalized) - - // Get the IBC denom for urax on Hub - rollappTokenDenom := transfertypes.GetPrefixedDenom(channel.Counterparty.PortID, channel.Counterparty.ChannelID, rollapp1.Config().Denom) - rollappIBCDenom := transfertypes.ParseDenomTrace(rollappTokenDenom).IBCDenom() - - // Minus 0.1% of transfer amount for bridge fee - testutil.AssertBalance(t, ctx, dymension, dymensionUserAddr, rollappIBCDenom, transferAmount.Sub(bridgingFee)) - - // Try to open a connection with the relayer with RA as chainA - err = r.GeneratePath(ctx, eRep, rollapp1.Config().ChainID, dymension.Config().ChainID, "demo-dymension") - require.NoError(t, err) - - err = r.CreateClients(ctx, eRep, "demo-dymension", ibc.DefaultClientOpts()) - require.NoError(t, err) - - err = testutil.WaitForBlocks(ctx, 20, rollapp1, dymension) - require.NoError(t, err) - - err = r.CreateConnectionsWithNumberOfRetries(ctx, eRep, "demo-dymension", "3") - require.NoError(t, err) - - connections, err := r.GetConnections(ctx, eRep, dymension.Config().ChainID) - require.NoError(t, err) - require.Equal(t, 2, len(connections)) -} - -func TestGenesisTransferConnectionBlock_Wasm(t *testing.T) { - if testing.Short() { - t.Skip() - } - - ctx := context.Background() - - configFileOverrides := make(map[string]any) - dymintTomlOverrides := make(testutil.Toml) - dymintTomlOverrides["settlement_layer"] = "dymension" - dymintTomlOverrides["settlement_node_address"] = fmt.Sprintf("http://dymension_100-1-val-0-%s:26657", t.Name()) - dymintTomlOverrides["rollapp_id"] = "rollappwasm_1234-1" - dymintTomlOverrides["settlement_gas_prices"] = "0adym" - dymintTomlOverrides["max_idle_time"] = "3s" - dymintTomlOverrides["max_proof_time"] = "500ms" - dymintTomlOverrides["batch_submit_max_time"] = "100s" - - configFileOverrides["config/dymint.toml"] = dymintTomlOverrides - // Create chain factory with dymension - numHubVals := 1 - numHubFullNodes := 1 - numRollAppFn := 0 - numRollAppVals := 1 - - cf := test.NewBuiltinChainFactory(zaptest.NewLogger(t), []*test.ChainSpec{ - { - Name: "rollapp1", - ChainConfig: ibc.ChainConfig{ - Type: "rollapp-dym", - Name: "rollapp-temp", - ChainID: "rollappwasm_1234-1", - Images: []ibc.DockerImage{rollappWasmImage}, - Bin: "rollappd", - Bech32Prefix: "rol", - Denom: "urax", - CoinType: "118", - GasPrices: "0.0urax", - GasAdjustment: 1.1, - TrustingPeriod: "112h", - EncodingConfig: encodingConfig(), - NoHostMount: false, - ModifyGenesis: modifyRollappWasmGenesis(rollappWasmGenesisKV), - ConfigFileOverrides: configFileOverrides, - }, - NumValidators: &numRollAppVals, - NumFullNodes: &numRollAppFn, - }, - { - Name: "dymension-hub", - ChainConfig: dymensionConfig, - NumValidators: &numHubVals, - NumFullNodes: &numHubFullNodes, - }, - }) - - // Get chains from the chain factory - chains, err := cf.Chains(t.Name()) - require.NoError(t, err) - - rollapp1 := chains[0].(*dym_rollapp.DymRollApp) - dymension := chains[1].(*dym_hub.DymHub) - - // Relayer Factory - client, network := test.DockerSetup(t) - - r := test.NewBuiltinRelayerFactory(ibc.CosmosRly, zaptest.NewLogger(t), - relayer.CustomDockerImage(RelayerMainRepo, relayerVersion, "100:1000"), relayer.ImagePull(pullRelayerImage), - ).Build(t, client, "relayer", network) - - ic := test.NewSetup(). - AddRollUp(dymension, rollapp1). - AddRelayer(r, "relayer"). - AddLink(test.InterchainLink{ - Chain1: dymension, - Chain2: rollapp1, - Relayer: r, - Path: ibcPath, - }) - - rep := testreporter.NewNopReporter() - eRep := rep.RelayerExecReporter(t) - - err = ic.Build(ctx, eRep, test.InterchainBuildOptions{ - TestName: t.Name(), - Client: client, - NetworkID: network, - SkipPathCreation: true, - - // This can be used to write to the block database which will index all block data e.g. txs, msgs, events, etc. - // BlockDatabaseFile: test.DefaultBlockDatabaseFilepath(), - }, nil, "", nil) - require.NoError(t, err) - - CreateChannel(ctx, t, r, eRep, dymension.CosmosChain, rollapp1.CosmosChain, ibcPath) - - // Create some user accounts on both chains - users := test.GetAndFundTestUsers(t, ctx, t.Name(), walletAmount, dymension, rollapp1) - - // Get our Bech32 encoded user addresses - dymensionUser, rollappUser := users[0], users[1] - - dymensionUserAddr := dymensionUser.FormattedAddress() - rollappUserAddr := rollappUser.FormattedAddress() - - channel, err := ibc.GetTransferChannel(ctx, r, eRep, dymension.Config().ChainID, rollapp1.Config().ChainID) - require.NoError(t, err) - - err = r.StartRelayer(ctx, eRep, ibcPath) - require.NoError(t, err) - - err = testutil.WaitForBlocks(ctx, 10, dymension, rollapp1) - require.NoError(t, err) - - // Send a normal ibc tx from RA -> Hub - transferData := ibc.WalletData{ - Address: dymensionUserAddr, - Denom: rollapp1.Config().Denom, - Amount: transferAmount, - } - _, err = rollapp1.SendIBCTransfer(ctx, channel.ChannelID, rollappUserAddr, transferData, ibc.TransferOptions{}) - require.NoError(t, err) - - rollappHeight, err := rollapp1.GetNode().Height(ctx) - require.NoError(t, err) - - // Assert balance was updated on the hub - testutil.AssertBalance(t, ctx, rollapp1, rollappUserAddr, rollapp1.Config().Denom, walletAmount.Sub(transferData.Amount)) - - // wait until the packet is finalized - isFinalized, err := dymension.WaitUntilRollappHeightIsFinalized(ctx, rollapp1.GetChainID(), rollappHeight, 300) - require.NoError(t, err) - require.True(t, isFinalized) - - // Get the IBC denom for urax on Hub - rollappTokenDenom := transfertypes.GetPrefixedDenom(channel.Counterparty.PortID, channel.Counterparty.ChannelID, rollapp1.Config().Denom) - rollappIBCDenom := transfertypes.ParseDenomTrace(rollappTokenDenom).IBCDenom() - - // Minus 0.1% of transfer amount for bridge fee - testutil.AssertBalance(t, ctx, dymension, dymensionUserAddr, rollappIBCDenom, transferAmount.Sub(bridgingFee)) - - // Try to open a connection with the relayer with RA as chainA - err = r.GeneratePath(ctx, eRep, rollapp1.Config().ChainID, dymension.Config().ChainID, "demo-dymension") - require.NoError(t, err) - - err = r.CreateClients(ctx, eRep, "demo-dymension", ibc.DefaultClientOpts()) - require.NoError(t, err) - - err = testutil.WaitForBlocks(ctx, 20, rollapp1, dymension) - require.NoError(t, err) - - err = r.CreateConnectionsWithNumberOfRetries(ctx, eRep, "demo-dymension", "3") - require.NoError(t, err) +// func TestGenesisTransferBridgeBlocking_EVM(t *testing.T) { +// if testing.Short() { +// t.Skip() +// } + +// ctx := context.Background() + +// configFileOverrides := make(map[string]any) +// dymintTomlOverrides := make(testutil.Toml) +// dymintTomlOverrides["settlement_layer"] = "dymension" +// dymintTomlOverrides["settlement_node_address"] = fmt.Sprintf("http://dymension_100-1-val-0-%s:26657", t.Name()) +// dymintTomlOverrides["rollapp_id"] = "rollappevm_1234-1" +// dymintTomlOverrides["settlement_gas_prices"] = "0adym" +// dymintTomlOverrides["max_idle_time"] = "3s" +// dymintTomlOverrides["max_proof_time"] = "500ms" +// dymintTomlOverrides["batch_submit_time"] = "50s" +// dymintTomlOverrides["p2p_blocksync_enabled"] = "false" + +// configFileOverrides["config/dymint.toml"] = dymintTomlOverrides +// // Create chain factory with dymension +// numHubVals := 1 +// numHubFullNodes := 1 +// numRollAppFn := 0 +// numRollAppVals := 1 + +// cf := test.NewBuiltinChainFactory(zaptest.NewLogger(t), []*test.ChainSpec{ +// { +// Name: "rollapp1", +// ChainConfig: ibc.ChainConfig{ +// Type: "rollapp-dym", +// Name: "rollapp-temp", +// ChainID: "rollappevm_1234-1", +// Images: []ibc.DockerImage{rollappEVMImage}, +// Bin: "rollappd", +// Bech32Prefix: "ethm", +// Denom: "urax", +// CoinType: "60", +// GasPrices: "0.0urax", +// GasAdjustment: 1.1, +// TrustingPeriod: "112h", +// EncodingConfig: encodingConfig(), +// NoHostMount: false, +// ModifyGenesis: modifyRollappEVMGenesis(rollappEVMGenesisKV), +// ConfigFileOverrides: configFileOverrides, +// }, +// NumValidators: &numRollAppVals, +// NumFullNodes: &numRollAppFn, +// }, +// { +// Name: "dymension-hub", +// ChainConfig: dymensionConfig, +// NumValidators: &numHubVals, +// NumFullNodes: &numHubFullNodes, +// }, +// }) + +// // Get chains from the chain factory +// chains, err := cf.Chains(t.Name()) +// require.NoError(t, err) + +// rollapp1 := chains[0].(*dym_rollapp.DymRollApp) +// dymension := chains[1].(*dym_hub.DymHub) + +// // Relayer Factory +// client, network := test.DockerSetup(t) + +// r := test.NewBuiltinRelayerFactory(ibc.CosmosRly, zaptest.NewLogger(t), +// relayer.CustomDockerImage(RelayerMainRepo, relayerVersion, "100:1000"), relayer.ImagePull(pullRelayerImage), +// ).Build(t, client, "relayer", network) + +// ic := test.NewSetup(). +// AddRollUp(dymension, rollapp1). +// AddRelayer(r, "relayer"). +// AddLink(test.InterchainLink{ +// Chain1: dymension, +// Chain2: rollapp1, +// Relayer: r, +// Path: ibcPath, +// }) + +// rep := testreporter.NewNopReporter() +// eRep := rep.RelayerExecReporter(t) + +// err = ic.Build(ctx, eRep, test.InterchainBuildOptions{ +// TestName: t.Name(), +// Client: client, +// NetworkID: network, +// SkipPathCreation: true, + +// // This can be used to write to the block database which will index all block data e.g. txs, msgs, events, etc. +// // BlockDatabaseFile: test.DefaultBlockDatabaseFilepath(), +// }, nil, "", nil) +// require.NoError(t, err) + +// CreateChannel(ctx, t, r, eRep, dymension.CosmosChain, rollapp1.CosmosChain, ibcPath) + +// // Create some user accounts on both chains +// users := test.GetAndFundTestUsers(t, ctx, t.Name(), walletAmount, dymension, rollapp1) + +// // Get our Bech32 encoded user addresses +// dymensionUser, rollappUser := users[0], users[1] + +// dymensionUserAddr := dymensionUser.FormattedAddress() +// rollappUserAddr := rollappUser.FormattedAddress() + +// channel, err := ibc.GetTransferChannel(ctx, r, eRep, dymension.Config().ChainID, rollapp1.Config().ChainID) +// require.NoError(t, err) + +// err = r.StartRelayer(ctx, eRep, ibcPath) +// require.NoError(t, err) + +// // Send a normal ibc tx from RA -> Hub +// transferData := ibc.WalletData{ +// Address: dymensionUserAddr, +// Denom: rollapp1.Config().Denom, +// Amount: transferAmount, +// } +// _, err = rollapp1.SendIBCTransfer(ctx, channel.ChannelID, rollappUserAddr, transferData, ibc.TransferOptions{}) +// require.Error(t, err) + +// // Compose an IBC transfer and send from dymension -> rollapp +// transferData = ibc.WalletData{ +// Address: rollappUserAddr, +// Denom: dymension.Config().Denom, +// Amount: transferAmount, +// } + +// // Compose an IBC transfer and send from Hub -> rollapp +// _, err = dymension.SendIBCTransfer(ctx, channel.ChannelID, dymensionUserAddr, transferData, ibc.TransferOptions{}) +// require.Error(t, err) + +// err = testutil.WaitForBlocks(ctx, 10, dymension, rollapp1) +// require.NoError(t, err) + +// // Get the IBC denom +// dymensionTokenDenom := transfertypes.GetPrefixedDenom(channel.Counterparty.PortID, channel.Counterparty.ChannelID, dymension.Config().Denom) +// dymensionIBCDenom := transfertypes.ParseDenomTrace(dymensionTokenDenom).IBCDenom() + +// // Get the IBC denom for urax on Hub +// rollappTokenDenom := transfertypes.GetPrefixedDenom(channel.Counterparty.PortID, channel.Counterparty.ChannelID, rollapp1.Config().Denom) +// rollappIBCDenom := transfertypes.ParseDenomTrace(rollappTokenDenom).IBCDenom() + +// // after a while, refund token +// testutil.AssertBalance(t, ctx, dymension, dymensionUserAddr, dymension.Config().Denom, walletAmount) +// testutil.AssertBalance(t, ctx, dymension, dymensionUserAddr, rollappIBCDenom, zeroBal) + +// testutil.AssertBalance(t, ctx, rollapp1, rollappUserAddr, rollapp1.Config().Denom, walletAmount) +// testutil.AssertBalance(t, ctx, rollapp1, rollappUserAddr, dymensionIBCDenom, zeroBal) +// } + +// func TestGenesisTransferBridgeBlocking_Wasm(t *testing.T) { +// if testing.Short() { +// t.Skip() +// } + +// ctx := context.Background() + +// configFileOverrides := make(map[string]any) +// dymintTomlOverrides := make(testutil.Toml) +// dymintTomlOverrides["settlement_layer"] = "dymension" +// dymintTomlOverrides["settlement_node_address"] = fmt.Sprintf("http://dymension_100-1-val-0-%s:26657", t.Name()) +// dymintTomlOverrides["rollapp_id"] = "rollappwasm_1234-1" +// dymintTomlOverrides["settlement_gas_prices"] = "0adym" +// dymintTomlOverrides["max_idle_time"] = "3s" +// dymintTomlOverrides["max_proof_time"] = "500ms" +// dymintTomlOverrides["batch_submit_time"] = "50s" +// dymintTomlOverrides["p2p_blocksync_enabled"] = "false" + +// configFileOverrides["config/dymint.toml"] = dymintTomlOverrides +// // Create chain factory with dymension +// numHubVals := 1 +// numHubFullNodes := 1 +// numRollAppFn := 0 +// numRollAppVals := 1 + +// cf := test.NewBuiltinChainFactory(zaptest.NewLogger(t), []*test.ChainSpec{ +// { +// Name: "rollapp1", +// ChainConfig: ibc.ChainConfig{ +// Type: "rollapp-dym", +// Name: "rollapp-temp", +// ChainID: "rollappwasm_1234-1", +// Images: []ibc.DockerImage{rollappWasmImage}, +// Bin: "rollappd", +// Bech32Prefix: "rol", +// Denom: "urax", +// CoinType: "118", +// GasPrices: "0.0urax", +// GasAdjustment: 1.1, +// TrustingPeriod: "112h", +// EncodingConfig: encodingConfig(), +// NoHostMount: false, +// ModifyGenesis: modifyRollappWasmGenesis(rollappWasmGenesisKV), +// ConfigFileOverrides: configFileOverrides, +// }, +// NumValidators: &numRollAppVals, +// NumFullNodes: &numRollAppFn, +// }, +// { +// Name: "dymension-hub", +// ChainConfig: dymensionConfig, +// NumValidators: &numHubVals, +// NumFullNodes: &numHubFullNodes, +// }, +// }) + +// // Get chains from the chain factory +// chains, err := cf.Chains(t.Name()) +// require.NoError(t, err) + +// rollapp1 := chains[0].(*dym_rollapp.DymRollApp) +// dymension := chains[1].(*dym_hub.DymHub) + +// // Relayer Factory +// client, network := test.DockerSetup(t) + +// r := test.NewBuiltinRelayerFactory(ibc.CosmosRly, zaptest.NewLogger(t), +// relayer.CustomDockerImage(RelayerMainRepo, relayerVersion, "100:1000"), relayer.ImagePull(pullRelayerImage), +// ).Build(t, client, "relayer", network) + +// ic := test.NewSetup(). +// AddRollUp(dymension, rollapp1). +// AddRelayer(r, "relayer"). +// AddLink(test.InterchainLink{ +// Chain1: dymension, +// Chain2: rollapp1, +// Relayer: r, +// Path: ibcPath, +// }) + +// rep := testreporter.NewNopReporter() +// eRep := rep.RelayerExecReporter(t) + +// err = ic.Build(ctx, eRep, test.InterchainBuildOptions{ +// TestName: t.Name(), +// Client: client, +// NetworkID: network, +// SkipPathCreation: true, + +// // This can be used to write to the block database which will index all block data e.g. txs, msgs, events, etc. +// // BlockDatabaseFile: test.DefaultBlockDatabaseFilepath(), +// }, nil, "", nil) +// require.NoError(t, err) + +// CreateChannel(ctx, t, r, eRep, dymension.CosmosChain, rollapp1.CosmosChain, ibcPath) + +// // Create some user accounts on both chains +// users := test.GetAndFundTestUsers(t, ctx, t.Name(), walletAmount, dymension, rollapp1) + +// // Get our Bech32 encoded user addresses +// dymensionUser, rollappUser := users[0], users[1] + +// dymensionUserAddr := dymensionUser.FormattedAddress() +// rollappUserAddr := rollappUser.FormattedAddress() + +// channel, err := ibc.GetTransferChannel(ctx, r, eRep, dymension.Config().ChainID, rollapp1.Config().ChainID) +// require.NoError(t, err) + +// err = r.StartRelayer(ctx, eRep, ibcPath) +// require.NoError(t, err) + +// // Send a normal ibc tx from RA -> Hub +// transferData := ibc.WalletData{ +// Address: dymensionUserAddr, +// Denom: rollapp1.Config().Denom, +// Amount: transferAmount, +// } +// _, err = rollapp1.SendIBCTransfer(ctx, channel.ChannelID, rollappUserAddr, transferData, ibc.TransferOptions{}) +// require.Error(t, err) + +// // Compose an IBC transfer and send from dymension -> rollapp +// transferData = ibc.WalletData{ +// Address: rollappUserAddr, +// Denom: dymension.Config().Denom, +// Amount: transferAmount, +// } + +// // Compose an IBC transfer and send from Hub -> rollapp +// _, err = dymension.SendIBCTransfer(ctx, channel.ChannelID, dymensionUserAddr, transferData, ibc.TransferOptions{}) +// require.Error(t, err) + +// err = testutil.WaitForBlocks(ctx, 10, dymension, rollapp1) +// require.NoError(t, err) + +// // Get the IBC denom +// dymensionTokenDenom := transfertypes.GetPrefixedDenom(channel.Counterparty.PortID, channel.Counterparty.ChannelID, dymension.Config().Denom) +// dymensionIBCDenom := transfertypes.ParseDenomTrace(dymensionTokenDenom).IBCDenom() + +// // Get the IBC denom for urax on Hub +// rollappTokenDenom := transfertypes.GetPrefixedDenom(channel.Counterparty.PortID, channel.Counterparty.ChannelID, rollapp1.Config().Denom) +// rollappIBCDenom := transfertypes.ParseDenomTrace(rollappTokenDenom).IBCDenom() + +// // after a while, refund token +// testutil.AssertBalance(t, ctx, dymension, dymensionUserAddr, dymension.Config().Denom, walletAmount) +// testutil.AssertBalance(t, ctx, dymension, dymensionUserAddr, rollappIBCDenom, zeroBal) + +// testutil.AssertBalance(t, ctx, rollapp1, rollappUserAddr, rollapp1.Config().Denom, walletAmount) +// testutil.AssertBalance(t, ctx, rollapp1, rollappUserAddr, dymensionIBCDenom, zeroBal) +// } + +// func TestGenesisTransferConnectionBlock_EVM(t *testing.T) { +// if testing.Short() { +// t.Skip() +// } + +// ctx := context.Background() + +// configFileOverrides := make(map[string]any) +// dymintTomlOverrides := make(testutil.Toml) +// dymintTomlOverrides["settlement_layer"] = "dymension" +// dymintTomlOverrides["settlement_node_address"] = fmt.Sprintf("http://dymension_100-1-val-0-%s:26657", t.Name()) +// dymintTomlOverrides["rollapp_id"] = "rollappevm_1234-1" +// dymintTomlOverrides["settlement_gas_prices"] = "0adym" +// dymintTomlOverrides["max_idle_time"] = "3s" +// dymintTomlOverrides["max_proof_time"] = "500ms" +// dymintTomlOverrides["batch_submit_time"] = "50s" +// dymintTomlOverrides["p2p_blocksync_enabled"] = "false" + +// configFileOverrides["config/dymint.toml"] = dymintTomlOverrides +// // Create chain factory with dymension +// numHubVals := 1 +// numHubFullNodes := 1 +// numRollAppFn := 0 +// numRollAppVals := 1 + +// cf := test.NewBuiltinChainFactory(zaptest.NewLogger(t), []*test.ChainSpec{ +// { +// Name: "rollapp1", +// ChainConfig: ibc.ChainConfig{ +// Type: "rollapp-dym", +// Name: "rollapp-temp", +// ChainID: "rollappevm_1234-1", +// Images: []ibc.DockerImage{rollappEVMImage}, +// Bin: "rollappd", +// Bech32Prefix: "ethm", +// Denom: "urax", +// CoinType: "60", +// GasPrices: "0.0urax", +// GasAdjustment: 1.1, +// TrustingPeriod: "112h", +// EncodingConfig: encodingConfig(), +// NoHostMount: false, +// ModifyGenesis: modifyRollappEVMGenesis(rollappEVMGenesisKV), +// ConfigFileOverrides: configFileOverrides, +// }, +// NumValidators: &numRollAppVals, +// NumFullNodes: &numRollAppFn, +// }, +// { +// Name: "dymension-hub", +// ChainConfig: dymensionConfig, +// NumValidators: &numHubVals, +// NumFullNodes: &numHubFullNodes, +// }, +// }) + +// // Get chains from the chain factory +// chains, err := cf.Chains(t.Name()) +// require.NoError(t, err) + +// rollapp1 := chains[0].(*dym_rollapp.DymRollApp) +// dymension := chains[1].(*dym_hub.DymHub) + +// // Relayer Factory +// client, network := test.DockerSetup(t) + +// r := test.NewBuiltinRelayerFactory(ibc.CosmosRly, zaptest.NewLogger(t), +// relayer.CustomDockerImage(RelayerMainRepo, relayerVersion, "100:1000"), relayer.ImagePull(pullRelayerImage), +// ).Build(t, client, "relayer", network) + +// ic := test.NewSetup(). +// AddRollUp(dymension, rollapp1). +// AddRelayer(r, "relayer"). +// AddLink(test.InterchainLink{ +// Chain1: dymension, +// Chain2: rollapp1, +// Relayer: r, +// Path: ibcPath, +// }) + +// rep := testreporter.NewNopReporter() +// eRep := rep.RelayerExecReporter(t) + +// err = ic.Build(ctx, eRep, test.InterchainBuildOptions{ +// TestName: t.Name(), +// Client: client, +// NetworkID: network, +// SkipPathCreation: true, + +// // This can be used to write to the block database which will index all block data e.g. txs, msgs, events, etc. +// // BlockDatabaseFile: test.DefaultBlockDatabaseFilepath(), +// }, nil, "", nil) +// require.NoError(t, err) + +// CreateChannel(ctx, t, r, eRep, dymension.CosmosChain, rollapp1.CosmosChain, ibcPath) + +// // Create some user accounts on both chains +// users := test.GetAndFundTestUsers(t, ctx, t.Name(), walletAmount, dymension, rollapp1) + +// // Get our Bech32 encoded user addresses +// dymensionUser, rollappUser := users[0], users[1] + +// dymensionUserAddr := dymensionUser.FormattedAddress() +// rollappUserAddr := rollappUser.FormattedAddress() + +// channel, err := ibc.GetTransferChannel(ctx, r, eRep, dymension.Config().ChainID, rollapp1.Config().ChainID) +// require.NoError(t, err) + +// err = r.StartRelayer(ctx, eRep, ibcPath) +// require.NoError(t, err) + +// err = testutil.WaitForBlocks(ctx, 10, dymension, rollapp1) +// require.NoError(t, err) + +// // Send a normal ibc tx from RA -> Hub +// transferData := ibc.WalletData{ +// Address: dymensionUserAddr, +// Denom: rollapp1.Config().Denom, +// Amount: transferAmount, +// } +// _, err = rollapp1.SendIBCTransfer(ctx, channel.ChannelID, rollappUserAddr, transferData, ibc.TransferOptions{}) +// require.NoError(t, err) + +// rollappHeight, err := rollapp1.GetNode().Height(ctx) +// require.NoError(t, err) + +// // Assert balance was updated on the hub +// testutil.AssertBalance(t, ctx, rollapp1, rollappUserAddr, rollapp1.Config().Denom, walletAmount.Sub(transferData.Amount)) + +// // wait until the packet is finalized +// isFinalized, err := dymension.WaitUntilRollappHeightIsFinalized(ctx, rollapp1.GetChainID(), rollappHeight, 300) +// require.NoError(t, err) +// require.True(t, isFinalized) + +// err = testutil.WaitForBlocks(ctx, 10, dymension, rollapp1) +// require.NoError(t, err) + +// // Get the IBC denom for urax on Hub +// rollappTokenDenom := transfertypes.GetPrefixedDenom(channel.Counterparty.PortID, channel.Counterparty.ChannelID, rollapp1.Config().Denom) +// rollappIBCDenom := transfertypes.ParseDenomTrace(rollappTokenDenom).IBCDenom() + +// // Minus 0.1% of transfer amount for bridge fee +// testutil.AssertBalance(t, ctx, dymension, dymensionUserAddr, rollappIBCDenom, transferAmount.Sub(bridgingFee)) + +// // Try to open a connection with the relayer with RA as chainA +// err = r.GeneratePath(ctx, eRep, rollapp1.Config().ChainID, dymension.Config().ChainID, "demo-dymension") +// require.NoError(t, err) + +// err = r.CreateClients(ctx, eRep, "demo-dymension", ibc.DefaultClientOpts()) +// require.NoError(t, err) + +// err = testutil.WaitForBlocks(ctx, 20, rollapp1, dymension) +// require.NoError(t, err) + +// err = r.CreateConnectionsWithNumberOfRetries(ctx, eRep, "demo-dymension", "3") +// require.NoError(t, err) + +// connections, err := r.GetConnections(ctx, eRep, dymension.Config().ChainID) +// require.NoError(t, err) +// require.Equal(t, 2, len(connections)) +// } + +// func TestGenesisTransferConnectionBlock_Wasm(t *testing.T) { +// if testing.Short() { +// t.Skip() +// } + +// ctx := context.Background() + +// configFileOverrides := make(map[string]any) +// dymintTomlOverrides := make(testutil.Toml) +// dymintTomlOverrides["settlement_layer"] = "dymension" +// dymintTomlOverrides["settlement_node_address"] = fmt.Sprintf("http://dymension_100-1-val-0-%s:26657", t.Name()) +// dymintTomlOverrides["rollapp_id"] = "rollappwasm_1234-1" +// dymintTomlOverrides["settlement_gas_prices"] = "0adym" +// dymintTomlOverrides["max_idle_time"] = "3s" +// dymintTomlOverrides["max_proof_time"] = "500ms" +// dymintTomlOverrides["batch_submit_time"] = "50s" +// dymintTomlOverrides["p2p_blocksync_enabled"] = "false" + +// configFileOverrides["config/dymint.toml"] = dymintTomlOverrides +// // Create chain factory with dymension +// numHubVals := 1 +// numHubFullNodes := 1 +// numRollAppFn := 0 +// numRollAppVals := 1 + +// cf := test.NewBuiltinChainFactory(zaptest.NewLogger(t), []*test.ChainSpec{ +// { +// Name: "rollapp1", +// ChainConfig: ibc.ChainConfig{ +// Type: "rollapp-dym", +// Name: "rollapp-temp", +// ChainID: "rollappwasm_1234-1", +// Images: []ibc.DockerImage{rollappWasmImage}, +// Bin: "rollappd", +// Bech32Prefix: "rol", +// Denom: "urax", +// CoinType: "118", +// GasPrices: "0.0urax", +// GasAdjustment: 1.1, +// TrustingPeriod: "112h", +// EncodingConfig: encodingConfig(), +// NoHostMount: false, +// ModifyGenesis: modifyRollappWasmGenesis(rollappWasmGenesisKV), +// ConfigFileOverrides: configFileOverrides, +// }, +// NumValidators: &numRollAppVals, +// NumFullNodes: &numRollAppFn, +// }, +// { +// Name: "dymension-hub", +// ChainConfig: dymensionConfig, +// NumValidators: &numHubVals, +// NumFullNodes: &numHubFullNodes, +// }, +// }) + +// // Get chains from the chain factory +// chains, err := cf.Chains(t.Name()) +// require.NoError(t, err) + +// rollapp1 := chains[0].(*dym_rollapp.DymRollApp) +// dymension := chains[1].(*dym_hub.DymHub) + +// // Relayer Factory +// client, network := test.DockerSetup(t) + +// r := test.NewBuiltinRelayerFactory(ibc.CosmosRly, zaptest.NewLogger(t), +// relayer.CustomDockerImage(RelayerMainRepo, relayerVersion, "100:1000"), relayer.ImagePull(pullRelayerImage), +// ).Build(t, client, "relayer", network) + +// ic := test.NewSetup(). +// AddRollUp(dymension, rollapp1). +// AddRelayer(r, "relayer"). +// AddLink(test.InterchainLink{ +// Chain1: dymension, +// Chain2: rollapp1, +// Relayer: r, +// Path: ibcPath, +// }) + +// rep := testreporter.NewNopReporter() +// eRep := rep.RelayerExecReporter(t) + +// err = ic.Build(ctx, eRep, test.InterchainBuildOptions{ +// TestName: t.Name(), +// Client: client, +// NetworkID: network, +// SkipPathCreation: true, + +// // This can be used to write to the block database which will index all block data e.g. txs, msgs, events, etc. +// // BlockDatabaseFile: test.DefaultBlockDatabaseFilepath(), +// }, nil, "", nil) +// require.NoError(t, err) + +// CreateChannel(ctx, t, r, eRep, dymension.CosmosChain, rollapp1.CosmosChain, ibcPath) + +// // Create some user accounts on both chains +// users := test.GetAndFundTestUsers(t, ctx, t.Name(), walletAmount, dymension, rollapp1) + +// // Get our Bech32 encoded user addresses +// dymensionUser, rollappUser := users[0], users[1] + +// dymensionUserAddr := dymensionUser.FormattedAddress() +// rollappUserAddr := rollappUser.FormattedAddress() + +// channel, err := ibc.GetTransferChannel(ctx, r, eRep, dymension.Config().ChainID, rollapp1.Config().ChainID) +// require.NoError(t, err) + +// err = r.StartRelayer(ctx, eRep, ibcPath) +// require.NoError(t, err) + +// err = testutil.WaitForBlocks(ctx, 10, dymension, rollapp1) +// require.NoError(t, err) + +// // Send a normal ibc tx from RA -> Hub +// transferData := ibc.WalletData{ +// Address: dymensionUserAddr, +// Denom: rollapp1.Config().Denom, +// Amount: transferAmount, +// } +// _, err = rollapp1.SendIBCTransfer(ctx, channel.ChannelID, rollappUserAddr, transferData, ibc.TransferOptions{}) +// require.NoError(t, err) + +// rollappHeight, err := rollapp1.GetNode().Height(ctx) +// require.NoError(t, err) + +// // Assert balance was updated on the hub +// testutil.AssertBalance(t, ctx, rollapp1, rollappUserAddr, rollapp1.Config().Denom, walletAmount.Sub(transferData.Amount)) + +// // wait until the packet is finalized +// isFinalized, err := dymension.WaitUntilRollappHeightIsFinalized(ctx, rollapp1.GetChainID(), rollappHeight, 300) +// require.NoError(t, err) +// require.True(t, isFinalized) + +// err = testutil.WaitForBlocks(ctx, 10, dymension, rollapp1) +// require.NoError(t, err) + +// // Get the IBC denom for urax on Hub +// rollappTokenDenom := transfertypes.GetPrefixedDenom(channel.Counterparty.PortID, channel.Counterparty.ChannelID, rollapp1.Config().Denom) +// rollappIBCDenom := transfertypes.ParseDenomTrace(rollappTokenDenom).IBCDenom() + +// // Minus 0.1% of transfer amount for bridge fee +// testutil.AssertBalance(t, ctx, dymension, dymensionUserAddr, rollappIBCDenom, transferAmount.Sub(bridgingFee)) + +// // Try to open a connection with the relayer with RA as chainA +// err = r.GeneratePath(ctx, eRep, rollapp1.Config().ChainID, dymension.Config().ChainID, "demo-dymension") +// require.NoError(t, err) + +// err = r.CreateClients(ctx, eRep, "demo-dymension", ibc.DefaultClientOpts()) +// require.NoError(t, err) - connections, err := r.GetConnections(ctx, eRep, dymension.Config().ChainID) - require.NoError(t, err) - require.Equal(t, 2, len(connections)) -} +// err = testutil.WaitForBlocks(ctx, 20, rollapp1, dymension) +// require.NoError(t, err) + +// err = r.CreateConnectionsWithNumberOfRetries(ctx, eRep, "demo-dymension", "3") +// require.NoError(t, err) + +// connections, err := r.GetConnections(ctx, eRep, dymension.Config().ChainID) +// require.NoError(t, err) +// require.Equal(t, 2, len(connections)) +// } diff --git a/tests/hardfork_test.go b/tests/hardfork_test.go index c1fc54b7..50cbff00 100644 --- a/tests/hardfork_test.go +++ b/tests/hardfork_test.go @@ -36,15 +36,7 @@ func TestHardFork_EVM(t *testing.T) { gas_price_rollapp1 := "0adym" maxIdleTime1 := "3s" maxProofTime := "500ms" - configFileOverrides := overridesDymintToml(settlement_layer_rollapp, settlement_node_address, rollapp1_id, gas_price_rollapp1, maxIdleTime1, maxProofTime, "100s") - - modifyGenesisKV := append( - dymensionGenesisKV, - cosmos.GenesisKV{ - Key: "app_state.rollapp.params.dispute_period_in_blocks", - Value: fmt.Sprint(BLOCK_FINALITY_PERIOD), - }, - ) + configFileOverrides := overridesDymintToml(settlement_layer_rollapp, settlement_node_address, rollapp1_id, gas_price_rollapp1, maxIdleTime1, maxProofTime, "50s") // Create chain factory with dymension numHubVals := 1 @@ -90,7 +82,7 @@ func TestHardFork_EVM(t *testing.T) { GasAdjustment: 1.1, TrustingPeriod: "112h", NoHostMount: false, - ModifyGenesis: modifyDymensionGenesis(modifyGenesisKV), + ModifyGenesis: modifyDymensionGenesis(dymensionGenesisKV), ConfigFileOverrides: nil, }, NumValidators: &numHubVals, @@ -134,7 +126,7 @@ func TestHardFork_EVM(t *testing.T) { // This can be used to write to the block database which will index all block data e.g. txs, msgs, events, etc. // BlockDatabaseFile: test.DefaultBlockDatabaseFilepath(), - }, nil, "", nil) + }, nil, "", nil, false, 780) require.NoError(t, err) CreateChannel(ctx, t, r, eRep, dymension.CosmosChain, rollapp1.CosmosChain, ibcPath) @@ -201,6 +193,9 @@ func TestHardFork_EVM(t *testing.T) { _, err = rollapp1.SendIBCTransfer(ctx, channsRollApp1Dym.ChannelID, rollapp1UserAddr, transferData, ibc.TransferOptions{}) require.NoError(t, err) + err = testutil.WaitForBlocks(ctx, 10, dymension, rollapp1) + require.NoError(t, err) + rollappHeight, err := rollapp1.GetNode().Height(ctx) require.NoError(t, err) @@ -212,6 +207,12 @@ func TestHardFork_EVM(t *testing.T) { require.NoError(t, err) require.True(t, isFinalized) + _, err = dymension.GetNode().FinalizePacketsUntilHeight(ctx, dymensionUserAddr, rollapp1.GetChainID(), fmt.Sprint(rollappHeight)) + require.NoError(t, err) + + err = testutil.WaitForBlocks(ctx, 10, dymension, rollapp1) + require.NoError(t, err) + // Get the IBC denom for urax on Hub rollappIbcDenom := GetIBCDenom(channsRollApp1Dym.Counterparty.PortID, channsRollApp1Dym.Counterparty.ChannelID, rollapp1.Config().Denom) @@ -266,7 +267,7 @@ func TestHardFork_EVM(t *testing.T) { testutil.AssertBalance(t, ctx, dymension, dymensionUserAddr, rollappIbcDenom, transferAmount.Sub(bridgingFee)) // get eIbc event - eibcEvents, err := getEIbcEventsWithinBlockRange(ctx, dymension, 30, false) + eibcEvents, err := getEIbcEventsWithinBlockRange(ctx, dymension, 10, false) require.NoError(t, err) for i, eibcEvent := range eibcEvents { @@ -373,7 +374,7 @@ func TestHardFork_EVM(t *testing.T) { // setup config for rollapp 1 new_rollapp_id := "rollappevm_1234-2" - configFileOverrides = overridesDymintToml(settlement_layer_rollapp, settlement_node_address, new_rollapp_id, gas_price_rollapp1, maxIdleTime1, maxProofTime, "100s") + configFileOverrides = overridesDymintToml(settlement_layer_rollapp, settlement_node_address, new_rollapp_id, gas_price_rollapp1, maxIdleTime1, maxProofTime, "50s") cf = test.NewBuiltinChainFactory(zaptest.NewLogger(t), []*test.ChainSpec{ { @@ -433,7 +434,7 @@ func TestHardFork_EVM(t *testing.T) { // This can be used to write to the block database which will index all block data e.g. txs, msgs, events, etc. // BlockDatabaseFile: test.DefaultBlockDatabaseFilepath(), - }, dymension, new_rollapp_id, []byte(genesis)) + }, dymension, new_rollapp_id, []byte(genesis), false, 780) require.NoError(t, err) CreateChannel(ctx, t, r2, eRep, dymension.CosmosChain, newRollApp.CosmosChain, anotherIbcPath) @@ -494,6 +495,9 @@ func TestHardFork_EVM(t *testing.T) { require.NoError(t, err) require.True(t, isFinalized) + err = testutil.WaitForBlocks(ctx, 10, dymension, rollapp1) + require.NoError(t, err) + // Get the IBC denom for urax on Hub newRollAppIbcDenom := GetIBCDenom(channsNewRollAppDym.Counterparty.PortID, channsNewRollAppDym.Counterparty.ChannelID, newRollApp.Config().Denom) @@ -545,11 +549,16 @@ func TestHardFork_EVM(t *testing.T) { require.NoError(t, err) require.True(t, isFinalized) + err = testutil.WaitForBlocks(ctx, 10, dymension, rollapp1) + require.NoError(t, err) + multiplier = math.NewInt(1000) bridgeFee := transferAmount.Quo(multiplier) // check assets balance testutil.AssertBalance(t, ctx, newRollApp, newRollAppUserAddr, newRollApp.Config().Denom, newRollAppBalanceBefore.Sub(transferDataFromNewRollApp.Amount)) testutil.AssertBalance(t, ctx, dymension, dymensionUserAddr, newRollAppIbcDenom, transferAmount.Add(transferAmount).Sub(bridgeFee).Sub(bridgeFee)) + // Run invariant check + CheckInvariant(t, ctx, dymension, dymensionUser.KeyName()) } func TestHardFork_Wasm(t *testing.T) { @@ -567,15 +576,7 @@ func TestHardFork_Wasm(t *testing.T) { maxIdleTime1 := "3s" maxProofTime := "500ms" - modifyGenesisKV := append( - dymensionGenesisKV, - cosmos.GenesisKV{ - Key: "app_state.rollapp.params.dispute_period_in_blocks", - Value: fmt.Sprint(BLOCK_FINALITY_PERIOD), - }, - ) - - configFileOverrides := overridesDymintToml(settlement_layer_rollapp, settlement_node_address, rollapp1_id, gas_price_rollapp1, maxIdleTime1, maxProofTime, "100s") + configFileOverrides := overridesDymintToml(settlement_layer_rollapp, settlement_node_address, rollapp1_id, gas_price_rollapp1, maxIdleTime1, maxProofTime, "50s") // Create chain factory with dymension numHubVals := 1 @@ -621,7 +622,7 @@ func TestHardFork_Wasm(t *testing.T) { GasAdjustment: 1.1, TrustingPeriod: "112h", NoHostMount: false, - ModifyGenesis: modifyDymensionGenesis(modifyGenesisKV), + ModifyGenesis: modifyDymensionGenesis(dymensionGenesisKV), ConfigFileOverrides: nil, }, NumValidators: &numHubVals, @@ -665,7 +666,7 @@ func TestHardFork_Wasm(t *testing.T) { // This can be used to write to the block database which will index all block data e.g. txs, msgs, events, etc. // BlockDatabaseFile: test.DefaultBlockDatabaseFilepath(), - }, nil, "", nil) + }, nil, "", nil, false, 780) require.NoError(t, err) CreateChannel(ctx, t, r, eRep, dymension.CosmosChain, rollapp1.CosmosChain, ibcPath) @@ -732,6 +733,9 @@ func TestHardFork_Wasm(t *testing.T) { _, err = rollapp1.SendIBCTransfer(ctx, channsRollApp1Dym.ChannelID, rollapp1UserAddr, transferData, ibc.TransferOptions{}) require.NoError(t, err) + err = testutil.WaitForBlocks(ctx, 10, dymension, rollapp1) + require.NoError(t, err) + rollappHeight, err := rollapp1.GetNode().Height(ctx) require.NoError(t, err) @@ -743,6 +747,12 @@ func TestHardFork_Wasm(t *testing.T) { require.NoError(t, err) require.True(t, isFinalized) + _, err = dymension.GetNode().FinalizePacketsUntilHeight(ctx, dymensionUserAddr, rollapp1.GetChainID(), fmt.Sprint(rollappHeight)) + require.NoError(t, err) + + err = testutil.WaitForBlocks(ctx, 10, dymension, rollapp1) + require.NoError(t, err) + // Get the IBC denom for urax on Hub rollappIbcDenom := GetIBCDenom(channsRollApp1Dym.Counterparty.PortID, channsRollApp1Dym.Counterparty.ChannelID, rollapp1.Config().Denom) @@ -797,7 +807,7 @@ func TestHardFork_Wasm(t *testing.T) { testutil.AssertBalance(t, ctx, dymension, dymensionUserAddr, rollappIbcDenom, transferAmount.Sub(bridgingFee)) // get eIbc event - eibcEvents, err := getEIbcEventsWithinBlockRange(ctx, dymension, 30, false) + eibcEvents, err := getEIbcEventsWithinBlockRange(ctx, dymension, 10, false) require.NoError(t, err) for i, eibcEvent := range eibcEvents { @@ -904,7 +914,7 @@ func TestHardFork_Wasm(t *testing.T) { // setup config for rollapp 1 new_rollapp_id := "rollappwasm_1234-2" - configFileOverrides = overridesDymintToml(settlement_layer_rollapp, settlement_node_address, new_rollapp_id, gas_price_rollapp1, maxIdleTime1, maxProofTime, "100s") + configFileOverrides = overridesDymintToml(settlement_layer_rollapp, settlement_node_address, new_rollapp_id, gas_price_rollapp1, maxIdleTime1, maxProofTime, "50s") cf = test.NewBuiltinChainFactory(zaptest.NewLogger(t), []*test.ChainSpec{ { @@ -964,7 +974,7 @@ func TestHardFork_Wasm(t *testing.T) { // This can be used to write to the block database which will index all block data e.g. txs, msgs, events, etc. // BlockDatabaseFile: test.DefaultBlockDatabaseFilepath(), - }, dymension, new_rollapp_id, []byte(genesis)) + }, dymension, new_rollapp_id, []byte(genesis), false, 780) require.NoError(t, err) CreateChannel(ctx, t, r2, eRep, dymension.CosmosChain, newRollApp.CosmosChain, anotherIbcPath) @@ -1025,6 +1035,9 @@ func TestHardFork_Wasm(t *testing.T) { require.NoError(t, err) require.True(t, isFinalized) + err = testutil.WaitForBlocks(ctx, 10, dymension, rollapp1) + require.NoError(t, err) + // Get the IBC denom newRollAppIbcDenom := GetIBCDenom(channsNewRollAppDym.Counterparty.PortID, channsNewRollAppDym.Counterparty.ChannelID, newRollApp.Config().Denom) // Minus 0.1% of transfer amount for bridge fee @@ -1072,11 +1085,16 @@ func TestHardFork_Wasm(t *testing.T) { require.NoError(t, err) require.True(t, isFinalized) + err = testutil.WaitForBlocks(ctx, 10, dymension, rollapp1) + require.NoError(t, err) + multiplier = math.NewInt(1000) bridgeFee := transferAmount.Quo(multiplier) // check assets balance testutil.AssertBalance(t, ctx, newRollApp, newRollAppUserAddr, newRollApp.Config().Denom, newRollAppBalanceBefore.Sub(transferDataFromNewRollApp.Amount)) testutil.AssertBalance(t, ctx, dymension, dymensionUserAddr, newRollAppIbcDenom, transferAmount.Add(transferAmount).Sub(bridgeFee).Sub(bridgeFee)) + // Run invariant check + CheckInvariant(t, ctx, dymension, dymensionUser.KeyName()) } func TestHardForkRecoverIbcClient_EVM(t *testing.T) { @@ -1093,18 +1111,7 @@ func TestHardForkRecoverIbcClient_EVM(t *testing.T) { gas_price_rollapp1 := "0adym" maxIdleTime1 := "3s" maxProofTime := "500ms" - configFileOverrides := overridesDymintToml(settlement_layer_rollapp, settlement_node_address, rollapp1_id, gas_price_rollapp1, maxIdleTime1, maxProofTime, "100s") - - // Custom dymension epoch for faster disconnection - modifyGenesisKV := append( - dymModifyGenesisKV, - []cosmos.GenesisKV{ - { - Key: "app_state.rollapp.params.dispute_period_in_blocks", - Value: fmt.Sprint(BLOCK_FINALITY_PERIOD), - }, - }..., - ) + configFileOverrides := overridesDymintToml(settlement_layer_rollapp, settlement_node_address, rollapp1_id, gas_price_rollapp1, maxIdleTime1, maxProofTime, "50s") // Create chain factory with dymension numHubVals := 1 @@ -1150,7 +1157,7 @@ func TestHardForkRecoverIbcClient_EVM(t *testing.T) { GasAdjustment: 1.1, TrustingPeriod: "112h", NoHostMount: false, - ModifyGenesis: modifyDymensionGenesis(modifyGenesisKV), + ModifyGenesis: modifyDymensionGenesis(dymensionGenesisKV), ConfigFileOverrides: nil, }, NumValidators: &numHubVals, @@ -1194,7 +1201,7 @@ func TestHardForkRecoverIbcClient_EVM(t *testing.T) { // This can be used to write to the block database which will index all block data e.g. txs, msgs, events, etc. // BlockDatabaseFile: test.DefaultBlockDatabaseFilepath(), - }, nil, "", nil) + }, nil, "", nil, false, 780) require.NoError(t, err) CreateChannel(ctx, t, r, eRep, dymension.CosmosChain, rollapp1.CosmosChain, ibcPath) @@ -1261,6 +1268,9 @@ func TestHardForkRecoverIbcClient_EVM(t *testing.T) { _, err = rollapp1.SendIBCTransfer(ctx, channsRollApp1Dym.ChannelID, rollapp1UserAddr, transferData, ibc.TransferOptions{}) require.NoError(t, err) + err = testutil.WaitForBlocks(ctx, 10, dymension, rollapp1) + require.NoError(t, err) + rollappHeight, err := rollapp1.GetNode().Height(ctx) require.NoError(t, err) @@ -1272,6 +1282,12 @@ func TestHardForkRecoverIbcClient_EVM(t *testing.T) { require.NoError(t, err) require.True(t, isFinalized) + _, err = dymension.GetNode().FinalizePacketsUntilHeight(ctx, dymensionUserAddr, rollapp1.GetChainID(), fmt.Sprint(rollappHeight)) + require.NoError(t, err) + + err = testutil.WaitForBlocks(ctx, 10, dymension, rollapp1) + require.NoError(t, err) + // Get the IBC denom for urax on Hub rollappIbcDenom := GetIBCDenom(channsRollApp1Dym.Counterparty.PortID, channsRollApp1Dym.Counterparty.ChannelID, rollapp1.Config().Denom) @@ -1327,7 +1343,7 @@ func TestHardForkRecoverIbcClient_EVM(t *testing.T) { testutil.AssertBalance(t, ctx, dymension, dymensionUserAddr, rollappIbcDenom, transferAmount.Sub(bridgingFee)) // get eIbc event - eibcEvents, err := getEIbcEventsWithinBlockRange(ctx, dymension, 30, false) + eibcEvents, err := getEIbcEventsWithinBlockRange(ctx, dymension, 10, false) require.NoError(t, err) for i, eibcEvent := range eibcEvents { @@ -1398,7 +1414,9 @@ func TestHardForkRecoverIbcClient_EVM(t *testing.T) { latestIndex, err := dymension.GetNode().QueryLatestStateIndex(ctx, rollapp1.Config().ChainID) require.NoError(t, err) - testutil.WaitForBlocks(ctx, 30, dymension, rollapp1) + + testutil.WaitForBlocks(ctx, 50, dymension) + // after Grace period, the latest index should be the same lalatestIndex, err := dymension.GetNode().QueryLatestStateIndex(ctx, rollapp1.Config().ChainID) require.NoError(t, err) @@ -1412,9 +1430,11 @@ func TestHardForkRecoverIbcClient_EVM(t *testing.T) { // Check rollapp1 state index not increment require.NoError(t, err) require.Equal(t, fmt.Sprint(targetIndex), latestIndex.StateIndex.Index, "rollapp state index still increment") + // stop all nodes and override genesis with new state err = rollapp1.StopAllNodes(ctx) require.NoError(t, err) + // get the latest hight was finalized rollappState, err := dymension.QueryRollappState(ctx, rollapp1.Config().ChainID, true) require.NoError(t, err) @@ -1434,7 +1454,7 @@ func TestHardForkRecoverIbcClient_EVM(t *testing.T) { // setup config for rollapp 1 new_rollapp_id := "rollappevm_1234-2" - configFileOverrides = overridesDymintToml(settlement_layer_rollapp, settlement_node_address, new_rollapp_id, gas_price_rollapp1, maxIdleTime1, maxProofTime, "100s") + configFileOverrides = overridesDymintToml(settlement_layer_rollapp, settlement_node_address, new_rollapp_id, gas_price_rollapp1, maxIdleTime1, maxProofTime, "50s") cf = test.NewBuiltinChainFactory(zaptest.NewLogger(t), []*test.ChainSpec{ { @@ -1494,7 +1514,7 @@ func TestHardForkRecoverIbcClient_EVM(t *testing.T) { // This can be used to write to the block database which will index all block data e.g. txs, msgs, events, etc. // BlockDatabaseFile: test.DefaultBlockDatabaseFilepath(), - }, dymension, new_rollapp_id, []byte(genesis)) + }, dymension, new_rollapp_id, []byte(genesis), false, 780) require.NoError(t, err) CreateChannel(ctx, t, r2, eRep, dymension.CosmosChain, newRollApp.CosmosChain, anotherIbcPath) @@ -1556,6 +1576,9 @@ func TestHardForkRecoverIbcClient_EVM(t *testing.T) { require.NoError(t, err) require.True(t, isFinalized) + err = testutil.WaitForBlocks(ctx, 10, dymension, rollapp1) + require.NoError(t, err) + // Get the IBC denom for urax on Hub newRollAppIbcDenom := GetIBCDenom(channsNewRollAppDym.Counterparty.PortID, channsNewRollAppDym.Counterparty.ChannelID, newRollApp.Config().Denom) @@ -1627,9 +1650,14 @@ func TestHardForkRecoverIbcClient_EVM(t *testing.T) { require.NoError(t, err) require.True(t, isFinalized) + err = testutil.WaitForBlocks(ctx, 10, dymension, rollapp1) + require.NoError(t, err) + multiplier = math.NewInt(1000) bridgeFee := transferAmount.Quo(multiplier) // check assets balance testutil.AssertBalance(t, ctx, newRollApp, newRollAppUserAddr, newRollApp.Config().Denom, newRollAppBalanceBefore.Sub(transferDataFromNewRollApp.Amount)) testutil.AssertBalance(t, ctx, dymension, dymensionUserAddr, newRollAppIbcDenom, transferAmount.Add(transferAmount).Sub(bridgeFee).Sub(bridgeFee)) + // Run invariant check + CheckInvariant(t, ctx, dymension, dymensionUser.KeyName()) } diff --git a/tests/ibc_finalize_block_test.go b/tests/ibc_finalize_block_test.go index 1d9f37f2..69d5a22e 100644 --- a/tests/ibc_finalize_block_test.go +++ b/tests/ibc_finalize_block_test.go @@ -35,7 +35,7 @@ func TestDymFinalizeBlock_OnRecvPacket_EVM(t *testing.T) { gas_price_rollapp1 := "0adym" maxIdleTime1 := "3s" maxProofTime := "500ms" - configFileOverrides := overridesDymintToml(settlement_layer_rollapp1, settlement_node_address, rollapp1_id, gas_price_rollapp1, maxIdleTime1, maxProofTime, "30s") + configFileOverrides := overridesDymintToml(settlement_layer_rollapp1, settlement_node_address, rollapp1_id, gas_price_rollapp1, maxIdleTime1, maxProofTime, "50s") modifyGenesisKV := append( rollappEVMGenesisKV, @@ -114,7 +114,7 @@ func TestDymFinalizeBlock_OnRecvPacket_EVM(t *testing.T) { // This can be used to write to the block database which will index all block data e.g. txs, msgs, events, etc. // BlockDatabaseFile: test.DefaultBlockDatabaseFilepath(), - }, nil, "", nil) + }, nil, "", nil, false, 780) require.NoError(t, err) CreateChannel(ctx, t, r, eRep, dymension.CosmosChain, rollapp1.CosmosChain, ibcPath) @@ -159,6 +159,9 @@ func TestDymFinalizeBlock_OnRecvPacket_EVM(t *testing.T) { _, err = rollapp1.SendIBCTransfer(ctx, rollappDymChannel.ChannelID, rollappUserAddr, transferData, ibc.TransferOptions{}) require.NoError(t, err) + err = testutil.WaitForBlocks(ctx, 10, dymension, rollapp1) + require.NoError(t, err) + rollappHeight, err := rollapp1.GetNode().Height(ctx) require.NoError(t, err) @@ -170,6 +173,9 @@ func TestDymFinalizeBlock_OnRecvPacket_EVM(t *testing.T) { require.NoError(t, err) require.True(t, isFinalized) + _, err = dymension.GetNode().FinalizePacketsUntilHeight(ctx, dymensionUserAddr, rollapp1.GetChainID(), fmt.Sprint(rollappHeight)) + require.NoError(t, err) + // Get the IBC denom dymensionTokenDenom := transfertypes.GetPrefixedDenom(channel.Counterparty.PortID, channel.Counterparty.ChannelID, dymension.Config().Denom) dymensionIBCDenom := transfertypes.ParseDenomTrace(dymensionTokenDenom).IBCDenom() @@ -194,12 +200,26 @@ func TestDymFinalizeBlock_OnRecvPacket_EVM(t *testing.T) { // Make sure that the ack contains error require.True(t, bytes.Contains(ack.Acknowledgement, []byte("error"))) - err = testutil.WaitForBlocks(ctx, 50, dymension, rollapp1) + err = testutil.WaitForBlocks(ctx, 10, dymension, rollapp1) + require.NoError(t, err) + + rollappHeight, err = rollapp1.GetNode().Height(ctx) + require.NoError(t, err) + + // wait until the packet is finalized + isFinalized, err = dymension.WaitUntilRollappHeightIsFinalized(ctx, rollapp1.GetChainID(), rollappHeight, 300) + require.NoError(t, err) + require.True(t, isFinalized) + + _, err = dymension.GetNode().FinalizePacketsUntilHeight(ctx, dymensionUserAddr, rollapp1.GetChainID(), fmt.Sprint(rollappHeight)) require.NoError(t, err) testutil.AssertBalance(t, ctx, dymension, dymensionUserAddr, dymension.Config().Denom, walletAmount) testutil.AssertBalance(t, ctx, rollapp1, rollappUserAddr, rollapp1.Config().Denom, walletAmount.Sub(transferData.Amount)) testutil.AssertBalance(t, ctx, rollapp1, rollappUserAddr, dymensionIBCDenom, zeroBal) + + // Run invariant check + CheckInvariant(t, ctx, dymension, dymensionUser.KeyName()) } // This test case verifies the system's behavior when an IBC packet sent from the rollapp to the dym and fail on ack. @@ -218,7 +238,7 @@ func TestDymFinalizeBlock_OnAckPacket_EVM(t *testing.T) { gas_price_rollapp1 := "0adym" maxIdleTime1 := "3s" maxProofTime := "500ms" - configFileOverrides := overridesDymintToml(settlement_layer_rollapp1, settlement_node_address, rollapp1_id, gas_price_rollapp1, maxIdleTime1, maxProofTime, "100s") + configFileOverrides := overridesDymintToml(settlement_layer_rollapp1, settlement_node_address, rollapp1_id, gas_price_rollapp1, maxIdleTime1, maxProofTime, "50s") // Create chain factory with dymension numHubVals := 1 @@ -316,7 +336,7 @@ func TestDymFinalizeBlock_OnAckPacket_EVM(t *testing.T) { // This can be used to write to the block database which will index all block data e.g. txs, msgs, events, etc. // BlockDatabaseFile: test.DefaultBlockDatabaseFilepath(), - }, nil, "", nil) + }, nil, "", nil, false, 780) require.NoError(t, err) // Create some user accounts on both chains @@ -371,6 +391,9 @@ func TestDymFinalizeBlock_OnAckPacket_EVM(t *testing.T) { _, err = rollapp1.SendIBCTransfer(ctx, channel0.ChannelID, rollappUserAddr, transferData, ibc.TransferOptions{}) require.NoError(t, err) + err = testutil.WaitForBlocks(ctx, 10, dymension, rollapp1) + require.NoError(t, err) + rollappHeight, err := rollapp1.GetNode().Height(ctx) require.NoError(t, err) @@ -382,6 +405,9 @@ func TestDymFinalizeBlock_OnAckPacket_EVM(t *testing.T) { require.NoError(t, err) require.True(t, isFinalized) + _, err = dymension.GetNode().FinalizePacketsUntilHeight(ctx, dymensionUserAddr, rollapp1.GetChainID(), fmt.Sprint(rollappHeight)) + require.NoError(t, err) + transferData = ibc.WalletData{ Address: rollappUserAddr, Denom: dymension.Config().Denom, @@ -401,6 +427,9 @@ func TestDymFinalizeBlock_OnAckPacket_EVM(t *testing.T) { // Make sure that the ack contains error require.True(t, bytes.Contains(ack.Acknowledgement, []byte("error"))) + + // Run invariant check + CheckInvariant(t, ctx, dymension, dymensionUser.KeyName()) } // This test case verifies the system's behavior when an IBC packet sent from the rollapp to the dym and timeout. @@ -418,7 +447,7 @@ func TestDymFinalizeBlock_OnTimeOutPacket_EVM(t *testing.T) { gas_price_rollapp1 := "0adym" maxIdleTime1 := "3s" maxProofTime := "500ms" - configFileOverrides := overridesDymintToml(settlement_layer_rollapp1, settlement_node_address, rollapp1_id, gas_price_rollapp1, maxIdleTime1, maxProofTime, "30s") + configFileOverrides := overridesDymintToml(settlement_layer_rollapp1, settlement_node_address, rollapp1_id, gas_price_rollapp1, maxIdleTime1, maxProofTime, "50s") // Create chain factory with dymension numHubVals := 1 @@ -492,7 +521,7 @@ func TestDymFinalizeBlock_OnTimeOutPacket_EVM(t *testing.T) { // This can be used to write to the block database which will index all block data e.g. txs, msgs, events, etc. // BlockDatabaseFile: test.DefaultBlockDatabaseFilepath(), - }, nil, "", nil) + }, nil, "", nil, false, 780) require.NoError(t, err) CreateChannel(ctx, t, r, eRep, dymension.CosmosChain, rollapp1.CosmosChain, ibcPath) @@ -541,6 +570,9 @@ func TestDymFinalizeBlock_OnTimeOutPacket_EVM(t *testing.T) { _, err = rollapp1.SendIBCTransfer(ctx, rollappDymchannel.ChannelID, rollappUserAddr, transferData, ibc.TransferOptions{}) require.NoError(t, err) + err = testutil.WaitForBlocks(ctx, 10, dymension, rollapp1) + require.NoError(t, err) + rollappHeight, err := rollapp1.GetNode().Height(ctx) require.NoError(t, err) @@ -552,6 +584,9 @@ func TestDymFinalizeBlock_OnTimeOutPacket_EVM(t *testing.T) { require.NoError(t, err) require.True(t, isFinalized) + _, err = dymension.GetNode().FinalizePacketsUntilHeight(ctx, dymensionUserAddr, rollapp1.GetChainID(), fmt.Sprint(rollappHeight)) + require.NoError(t, err) + // Get the IBC denom dymensionTokenDenom := transfertypes.GetPrefixedDenom(channel.Counterparty.PortID, channel.Counterparty.ChannelID, dymension.Config().Denom) dymensionIBCDenom := transfertypes.ParseDenomTrace(dymensionTokenDenom).IBCDenom() @@ -567,8 +602,6 @@ func TestDymFinalizeBlock_OnTimeOutPacket_EVM(t *testing.T) { // Compose an IBC transfer and send from rollapp -> dymension ibcTx, err := dymension.SendIBCTransfer(ctx, channel.ChannelID, dymensionUserAddr, transferData, ibc.TransferOptions{Timeout: testutil.ImmediatelyTimeout()}) require.NoError(t, err) - // Assert balance was updated on the rollapp - testutil.AssertBalance(t, ctx, dymension, dymensionUserAddr, dymension.Config().Denom, walletAmount.Sub(transferData.Amount)) got, err := testutil.PollForTimeout(ctx, dymension, dymensionHeight, dymensionHeight+30, ibcTx.Packet) require.NoError(t, err) @@ -576,12 +609,26 @@ func TestDymFinalizeBlock_OnTimeOutPacket_EVM(t *testing.T) { // Make sure that we got the packet timeout require.Equal(t, got.Packet.SourceChannel, channel.ChannelID) - err = testutil.WaitForBlocks(ctx, 50, dymension, rollapp1) + err = testutil.WaitForBlocks(ctx, 10, dymension, rollapp1) + require.NoError(t, err) + + rollappHeight, err = rollapp1.GetNode().Height(ctx) + require.NoError(t, err) + + // wait until the packet is finalized + isFinalized, err = dymension.WaitUntilRollappHeightIsFinalized(ctx, rollapp1.GetChainID(), rollappHeight, 300) + require.NoError(t, err) + require.True(t, isFinalized) + + _, err = dymension.GetNode().FinalizePacketsUntilHeight(ctx, dymensionUserAddr, rollapp1.GetChainID(), fmt.Sprint(rollappHeight)) require.NoError(t, err) testutil.AssertBalance(t, ctx, dymension, dymensionUserAddr, dymension.Config().Denom, walletAmount) testutil.AssertBalance(t, ctx, rollapp1, rollappUserAddr, rollapp1.Config().Denom, walletAmount.Sub(transferData.Amount)) testutil.AssertBalance(t, ctx, rollapp1, rollappUserAddr, dymensionIBCDenom, zeroBal) + + // Run invariant check + CheckInvariant(t, ctx, dymension, dymensionUser.KeyName()) } // This test case verifies the system's behavior when an IBC packet sent from the rollapp to the dym and ack failed. @@ -600,7 +647,7 @@ func TestDymFinalizeBlock_OnRecvPacket_Wasm(t *testing.T) { gas_price_rollapp1 := "0adym" maxIdleTime1 := "3s" maxProofTime := "500ms" - configFileOverrides := overridesDymintToml(settlement_layer_rollapp1, settlement_node_address, rollapp1_id, gas_price_rollapp1, maxIdleTime1, maxProofTime, "30s") + configFileOverrides := overridesDymintToml(settlement_layer_rollapp1, settlement_node_address, rollapp1_id, gas_price_rollapp1, maxIdleTime1, maxProofTime, "50s") modifyGenesisKV := append( rollappWasmGenesisKV, @@ -680,7 +727,7 @@ func TestDymFinalizeBlock_OnRecvPacket_Wasm(t *testing.T) { // This can be used to write to the block database which will index all block data e.g. txs, msgs, events, etc. // BlockDatabaseFile: test.DefaultBlockDatabaseFilepath(), - }, nil, "", nil) + }, nil, "", nil, false, 780) require.NoError(t, err) CreateChannel(ctx, t, r, eRep, dymension.CosmosChain, rollapp1.CosmosChain, ibcPath) @@ -729,6 +776,9 @@ func TestDymFinalizeBlock_OnRecvPacket_Wasm(t *testing.T) { _, err = rollapp1.SendIBCTransfer(ctx, rollappDymChannel.ChannelID, rollappUserAddr, transferData, ibc.TransferOptions{}) require.NoError(t, err) + err = testutil.WaitForBlocks(ctx, 10, dymension, rollapp1) + require.NoError(t, err) + rollappHeight, err := rollapp1.GetNode().Height(ctx) require.NoError(t, err) @@ -739,6 +789,10 @@ func TestDymFinalizeBlock_OnRecvPacket_Wasm(t *testing.T) { isFinalized, err := dymension.WaitUntilRollappHeightIsFinalized(ctx, rollapp1.GetChainID(), rollappHeight, 300) require.NoError(t, err) require.True(t, isFinalized) + + _, err = dymension.GetNode().FinalizePacketsUntilHeight(ctx, dymensionUserAddr, rollapp1.GetChainID(), fmt.Sprint(rollappHeight)) + require.NoError(t, err) + // Get the IBC denom dymensionTokenDenom := transfertypes.GetPrefixedDenom(channel.Counterparty.PortID, channel.Counterparty.ChannelID, dymension.Config().Denom) dymensionIBCDenom := transfertypes.ParseDenomTrace(dymensionTokenDenom).IBCDenom() @@ -764,12 +818,26 @@ func TestDymFinalizeBlock_OnRecvPacket_Wasm(t *testing.T) { // Make sure that the ack contains error require.True(t, bytes.Contains(ack.Acknowledgement, []byte("error"))) - err = testutil.WaitForBlocks(ctx, 50, dymension, rollapp1) + err = testutil.WaitForBlocks(ctx, 10, dymension, rollapp1) + require.NoError(t, err) + + rollappHeight, err = rollapp1.GetNode().Height(ctx) + require.NoError(t, err) + + // wait until the packet is finalized + isFinalized, err = dymension.WaitUntilRollappHeightIsFinalized(ctx, rollapp1.GetChainID(), rollappHeight, 300) + require.NoError(t, err) + require.True(t, isFinalized) + + _, err = dymension.GetNode().FinalizePacketsUntilHeight(ctx, dymensionUserAddr, rollapp1.GetChainID(), fmt.Sprint(rollappHeight)) require.NoError(t, err) testutil.AssertBalance(t, ctx, dymension, dymensionUserAddr, dymension.Config().Denom, walletAmount) testutil.AssertBalance(t, ctx, rollapp1, rollappUserAddr, rollapp1.Config().Denom, walletAmount.Sub(transferData.Amount)) testutil.AssertBalance(t, ctx, rollapp1, rollappUserAddr, dymensionIBCDenom, zeroBal) + + // Run invariant check + CheckInvariant(t, ctx, dymension, dymensionUser.KeyName()) } // This test case verifies the system's behavior when an IBC packet sent from the rollapp to the dym and fail on ack. @@ -788,7 +856,7 @@ func TestDymFinalizeBlock_OnAckPacket_Wasm(t *testing.T) { gas_price_rollapp1 := "0adym" maxIdleTime1 := "3s" maxProofTime := "500ms" - configFileOverrides := overridesDymintToml(settlement_layer_rollapp1, settlement_node_address, rollapp1_id, gas_price_rollapp1, maxIdleTime1, maxProofTime, "100s") + configFileOverrides := overridesDymintToml(settlement_layer_rollapp1, settlement_node_address, rollapp1_id, gas_price_rollapp1, maxIdleTime1, maxProofTime, "50s") // Create chain factory with dymension numHubVals := 1 @@ -886,7 +954,7 @@ func TestDymFinalizeBlock_OnAckPacket_Wasm(t *testing.T) { // This can be used to write to the block database which will index all block data e.g. txs, msgs, events, etc. // BlockDatabaseFile: test.DefaultBlockDatabaseFilepath(), - }, nil, "", nil) + }, nil, "", nil, false, 780) require.NoError(t, err) // Create some user accounts on both chains @@ -941,6 +1009,9 @@ func TestDymFinalizeBlock_OnAckPacket_Wasm(t *testing.T) { _, err = rollapp1.SendIBCTransfer(ctx, channel0.ChannelID, rollappUserAddr, transferData, ibc.TransferOptions{}) require.NoError(t, err) + err = testutil.WaitForBlocks(ctx, 10, dymension, rollapp1) + require.NoError(t, err) + rollappHeight, err := rollapp1.GetNode().Height(ctx) require.NoError(t, err) @@ -952,6 +1023,9 @@ func TestDymFinalizeBlock_OnAckPacket_Wasm(t *testing.T) { require.NoError(t, err) require.True(t, isFinalized) + _, err = dymension.GetNode().FinalizePacketsUntilHeight(ctx, dymensionUserAddr, rollapp1.GetChainID(), fmt.Sprint(rollappHeight)) + require.NoError(t, err) + transferData = ibc.WalletData{ Address: rollappUserAddr, Denom: dymension.Config().Denom, @@ -972,6 +1046,9 @@ func TestDymFinalizeBlock_OnAckPacket_Wasm(t *testing.T) { // Make sure that the ack contains error require.True(t, bytes.Contains(ack.Acknowledgement, []byte("error"))) + + // Run invariant check + CheckInvariant(t, ctx, dymension, dymensionUser.KeyName()) } // This test case verifies the system's behavior when an IBC packet sent from the rollapp to the dym and timeout. @@ -989,7 +1066,7 @@ func TestDymFinalizeBlock_OnTimeOutPacket_Wasm(t *testing.T) { gas_price_rollapp1 := "0adym" maxIdleTime1 := "3s" maxProofTime := "500ms" - configFileOverrides := overridesDymintToml(settlement_layer_rollapp1, settlement_node_address, rollapp1_id, gas_price_rollapp1, maxIdleTime1, maxProofTime, "30s") + configFileOverrides := overridesDymintToml(settlement_layer_rollapp1, settlement_node_address, rollapp1_id, gas_price_rollapp1, maxIdleTime1, maxProofTime, "50s") // Create chain factory with dymension numHubVals := 1 @@ -1063,7 +1140,7 @@ func TestDymFinalizeBlock_OnTimeOutPacket_Wasm(t *testing.T) { // This can be used to write to the block database which will index all block data e.g. txs, msgs, events, etc. // BlockDatabaseFile: test.DefaultBlockDatabaseFilepath(), - }, nil, "", nil) + }, nil, "", nil, false, 780) require.NoError(t, err) CreateChannel(ctx, t, r, eRep, dymension.CosmosChain, rollapp1.CosmosChain, ibcPath) @@ -1109,6 +1186,9 @@ func TestDymFinalizeBlock_OnTimeOutPacket_Wasm(t *testing.T) { _, err = rollapp1.SendIBCTransfer(ctx, channel.Counterparty.ChannelID, rollappUserAddr, transferData, ibc.TransferOptions{}) require.NoError(t, err) + err = testutil.WaitForBlocks(ctx, 10, dymension, rollapp1) + require.NoError(t, err) + rollappHeight, err := rollapp1.GetNode().Height(ctx) require.NoError(t, err) @@ -1119,6 +1199,10 @@ func TestDymFinalizeBlock_OnTimeOutPacket_Wasm(t *testing.T) { isFinalized, err := dymension.WaitUntilRollappHeightIsFinalized(ctx, rollapp1.GetChainID(), rollappHeight, 300) require.NoError(t, err) require.True(t, isFinalized) + + _, err = dymension.GetNode().FinalizePacketsUntilHeight(ctx, dymensionUserAddr, rollapp1.GetChainID(), fmt.Sprint(rollappHeight)) + require.NoError(t, err) + // Get the IBC denom dymensionTokenDenom := transfertypes.GetPrefixedDenom(channel.Counterparty.PortID, channel.Counterparty.ChannelID, dymension.Config().Denom) dymensionIBCDenom := transfertypes.ParseDenomTrace(dymensionTokenDenom).IBCDenom() @@ -1143,10 +1227,24 @@ func TestDymFinalizeBlock_OnTimeOutPacket_Wasm(t *testing.T) { // Make sure that we got the packet timeout require.Equal(t, got.Packet.SourceChannel, channel.ChannelID) - err = testutil.WaitForBlocks(ctx, 50, dymension, rollapp1) + err = testutil.WaitForBlocks(ctx, 10, dymension, rollapp1) + require.NoError(t, err) + + rollappHeight, err = rollapp1.GetNode().Height(ctx) + require.NoError(t, err) + + // wait until the packet is finalized + isFinalized, err = dymension.WaitUntilRollappHeightIsFinalized(ctx, rollapp1.GetChainID(), rollappHeight, 300) + require.NoError(t, err) + require.True(t, isFinalized) + + _, err = dymension.GetNode().FinalizePacketsUntilHeight(ctx, dymensionUserAddr, rollapp1.GetChainID(), fmt.Sprint(rollappHeight)) require.NoError(t, err) testutil.AssertBalance(t, ctx, dymension, dymensionUserAddr, dymension.Config().Denom, walletAmount) testutil.AssertBalance(t, ctx, rollapp1, rollappUserAddr, rollapp1.Config().Denom, walletAmount.Sub(transferData.Amount)) testutil.AssertBalance(t, ctx, rollapp1, rollappUserAddr, dymensionIBCDenom, zeroBal) + + // Run invariant check + CheckInvariant(t, ctx, dymension, dymensionUser.KeyName()) } diff --git a/tests/ibc_grace_period_test.go b/tests/ibc_grace_period_test.go index 9f1f85dc..840bf4e9 100644 --- a/tests/ibc_grace_period_test.go +++ b/tests/ibc_grace_period_test.go @@ -35,22 +35,14 @@ func TestIBCGracePeriodCompliance_EVM(t *testing.T) { gas_price_rollapp1 := "0adym" maxIdleTime1 := "3s" maxProofTime := "500ms" - configFileOverrides1 := overridesDymintToml(settlement_layer_rollapp1, settlement_node_address, rollapp1_id, gas_price_rollapp1, maxIdleTime1, maxProofTime, "100s") + configFileOverrides1 := overridesDymintToml(settlement_layer_rollapp1, settlement_node_address, rollapp1_id, gas_price_rollapp1, maxIdleTime1, maxProofTime, "50s") // setup config for rollapp 2 settlement_layer_rollapp2 := "dymension" rollapp2_id := "decentrio_12345-1" gas_price_rollapp2 := "0adym" maxIdleTime2 := "3s" - configFileOverrides2 := overridesDymintToml(settlement_layer_rollapp2, settlement_node_address, rollapp2_id, gas_price_rollapp2, maxIdleTime2, maxProofTime, "100s") - - modifyGenesisKV := append( - dymensionGenesisKV, - cosmos.GenesisKV{ - Key: "app_state.rollapp.params.dispute_period_in_blocks", - Value: fmt.Sprint(BLOCK_FINALITY_PERIOD), - }, - ) + configFileOverrides2 := overridesDymintToml(settlement_layer_rollapp2, settlement_node_address, rollapp2_id, gas_price_rollapp2, maxIdleTime2, maxProofTime, "50s") // Create chain factory with dymension numHubVals := 1 @@ -118,7 +110,7 @@ func TestIBCGracePeriodCompliance_EVM(t *testing.T) { GasAdjustment: 1.1, TrustingPeriod: "112h", NoHostMount: false, - ModifyGenesis: modifyDymensionGenesis(modifyGenesisKV), + ModifyGenesis: modifyDymensionGenesis(dymensionGenesisKV), ConfigFileOverrides: nil, }, NumValidators: &numHubVals, @@ -172,7 +164,7 @@ func TestIBCGracePeriodCompliance_EVM(t *testing.T) { SkipPathCreation: true, // This can be used to write to the block database which will index all block data e.g. txs, msgs, events, etc. - }, nil, "", nil) + }, nil, "", nil, false, 780) require.NoError(t, err) CreateChannel(ctx, t, r1, eRep, dymension.CosmosChain, rollapp1.CosmosChain, ibcPath) @@ -218,6 +210,9 @@ func TestIBCGracePeriodCompliance_EVM(t *testing.T) { _, err = rollapp1.SendIBCTransfer(ctx, dymChannel[0].ChannelID, rollapp1UserAddr, transferData, ibc.TransferOptions{}) require.NoError(t, err) + err = testutil.WaitForBlocks(ctx, 10, dymension, rollapp1) + require.NoError(t, err) + rollappHeight, err := rollapp1.GetNode().Height(ctx) require.NoError(t, err) @@ -229,6 +224,12 @@ func TestIBCGracePeriodCompliance_EVM(t *testing.T) { require.NoError(t, err) require.True(t, isFinalized) + _, err = dymension.GetNode().FinalizePacketsUntilHeight(ctx, dymensionUserAddr, rollapp1.GetChainID(), fmt.Sprint(rollappHeight)) + require.NoError(t, err) + + err = testutil.WaitForBlocks(ctx, 10, dymension, rollapp1) + require.NoError(t, err) + // Get the IBC denom for urax on Hub rollappTokenDenom := transfertypes.GetPrefixedDenom(dymChannel[0].Counterparty.PortID, dymChannel[0].Counterparty.ChannelID, rollapp1.Config().Denom) rollappIBCDenom := transfertypes.ParseDenomTrace(rollappTokenDenom).IBCDenom() @@ -267,6 +268,9 @@ func TestIBCGracePeriodCompliance_EVM(t *testing.T) { _, err = rollapp1.SendIBCTransfer(ctx, dymChannel[0].ChannelID, rollapp1UserAddr, transferData, ibc.TransferOptions{}) require.NoError(t, err) + err = testutil.WaitForBlocks(ctx, 10, dymension, rollapp1) + require.NoError(t, err) + rollappHeight, err = rollapp1.GetNode().Height(ctx) require.NoError(t, err) @@ -288,6 +292,12 @@ func TestIBCGracePeriodCompliance_EVM(t *testing.T) { require.NoError(t, err) require.True(t, isFinalized) + _, err = dymension.GetNode().FinalizePacketsUntilHeight(ctx, dymensionUserAddr, rollapp1.GetChainID(), fmt.Sprint(rollappHeight)) + require.NoError(t, err) + + err = testutil.WaitForBlocks(ctx, 40, dymension, rollapp1) + require.NoError(t, err) + // Minus 0.1% of transfer amount for bridge fee testutil.AssertBalance(t, ctx, dymension, dymensionUserAddr, rollappIBCDenom, transferAmount.Add(transferAmount).Sub(bridgingFee).Sub(bridgingFee)) @@ -307,6 +317,9 @@ func TestIBCGracePeriodCompliance_EVM(t *testing.T) { } }, ) + + // Run invariant check + CheckInvariant(t, ctx, dymension, dymensionUser.KeyName()) } // TestIBCGracePeriodCompliance ensures that the grace period for transaction finalization is correctly enforced on hub and rollapp. @@ -324,22 +337,14 @@ func TestIBCGracePeriodCompliance_Wasm(t *testing.T) { gas_price_rollapp1 := "0adym" maxIdleTime1 := "3s" maxProofTime := "500ms" - configFileOverrides1 := overridesDymintToml(settlement_layer_rollapp1, settlement_node_address, rollapp1_id, gas_price_rollapp1, maxIdleTime1, maxProofTime, "100s") + configFileOverrides1 := overridesDymintToml(settlement_layer_rollapp1, settlement_node_address, rollapp1_id, gas_price_rollapp1, maxIdleTime1, maxProofTime, "50s") // setup config for rollapp 2 settlement_layer_rollapp2 := "dymension" rollapp2_id := "decentrio_12345-1" gas_price_rollapp2 := "0adym" maxIdleTime2 := "3s" - configFileOverrides2 := overridesDymintToml(settlement_layer_rollapp2, settlement_node_address, rollapp2_id, gas_price_rollapp2, maxIdleTime2, maxProofTime, "100s") - - modifyGenesisKV := append( - dymensionGenesisKV, - cosmos.GenesisKV{ - Key: "app_state.rollapp.params.dispute_period_in_blocks", - Value: fmt.Sprint(BLOCK_FINALITY_PERIOD), - }, - ) + configFileOverrides2 := overridesDymintToml(settlement_layer_rollapp2, settlement_node_address, rollapp2_id, gas_price_rollapp2, maxIdleTime2, maxProofTime, "50s") // Create chain factory with dymension numHubVals := 1 @@ -407,7 +412,7 @@ func TestIBCGracePeriodCompliance_Wasm(t *testing.T) { GasAdjustment: 1.1, TrustingPeriod: "112h", NoHostMount: false, - ModifyGenesis: modifyDymensionGenesis(modifyGenesisKV), + ModifyGenesis: modifyDymensionGenesis(dymensionGenesisKV), ConfigFileOverrides: nil, }, NumValidators: &numHubVals, @@ -462,7 +467,7 @@ func TestIBCGracePeriodCompliance_Wasm(t *testing.T) { // This can be used to write to the block database which will index all block data e.g. txs, msgs, events, etc. // BlockDatabaseFile: test.DefaultBlockDatabaseFilepath(), - }, nil, "", nil) + }, nil, "", nil, false, 780) require.NoError(t, err) CreateChannel(ctx, t, r1, eRep, dymension.CosmosChain, rollapp1.CosmosChain, ibcPath) @@ -514,6 +519,9 @@ func TestIBCGracePeriodCompliance_Wasm(t *testing.T) { _, err = rollapp1.SendIBCTransfer(ctx, dymChannel[0].ChannelID, rollapp1UserAddr, transferData, ibc.TransferOptions{}) require.NoError(t, err) + err = testutil.WaitForBlocks(ctx, 10, dymension, rollapp1) + require.NoError(t, err) + rollappHeight, err := rollapp1.GetNode().Height(ctx) require.NoError(t, err) @@ -525,6 +533,12 @@ func TestIBCGracePeriodCompliance_Wasm(t *testing.T) { require.NoError(t, err) require.True(t, isFinalized) + _, err = dymension.GetNode().FinalizePacketsUntilHeight(ctx, dymensionUserAddr, rollapp1.GetChainID(), fmt.Sprint(rollappHeight)) + require.NoError(t, err) + + err = testutil.WaitForBlocks(ctx, 30, dymension, rollapp1) + require.NoError(t, err) + // Get the IBC denom for urax on Hub rollappTokenDenom := transfertypes.GetPrefixedDenom(dymChannel[0].Counterparty.PortID, dymChannel[0].Counterparty.ChannelID, rollapp1.Config().Denom) rollappIBCDenom := transfertypes.ParseDenomTrace(rollappTokenDenom).IBCDenom() @@ -553,6 +567,9 @@ func TestIBCGracePeriodCompliance_Wasm(t *testing.T) { _, err = rollapp1.SendIBCTransfer(ctx, dymChannel[0].ChannelID, rollapp1UserAddr, transferData, ibc.TransferOptions{}) require.NoError(t, err) + err = testutil.WaitForBlocks(ctx, 10, dymension, rollapp1) + require.NoError(t, err) + rollappHeight, err = rollapp1.GetNode().Height(ctx) require.NoError(t, err) @@ -574,6 +591,12 @@ func TestIBCGracePeriodCompliance_Wasm(t *testing.T) { require.NoError(t, err) require.True(t, isFinalized) + _, err = dymension.GetNode().FinalizePacketsUntilHeight(ctx, dymensionUserAddr, rollapp1.GetChainID(), fmt.Sprint(rollappHeight)) + require.NoError(t, err) + + err = testutil.WaitForBlocks(ctx, 30, dymension, rollapp1) + require.NoError(t, err) + // Minus 0.1% of transfer amount for bridge fee testutil.AssertBalance(t, ctx, dymension, dymensionUserAddr, rollappIBCDenom, transferAmount.Add(transferAmount).Sub(bridgingFee).Sub(bridgingFee)) @@ -593,6 +616,8 @@ func TestIBCGracePeriodCompliance_Wasm(t *testing.T) { } }, ) + // Run invariant check + CheckInvariant(t, ctx, dymension, dymensionUser.KeyName()) } func TestDelayedAck_NoFinalizedStates_EVM(t *testing.T) { @@ -609,14 +634,14 @@ func TestDelayedAck_NoFinalizedStates_EVM(t *testing.T) { gas_price_rollapp1 := "0adym" maxIdleTime1 := "3s" maxProofTime := "500ms" - configFileOverrides1 := overridesDymintToml(settlement_layer_rollapp1, settlement_node_address, rollapp1_id, gas_price_rollapp1, maxIdleTime1, maxProofTime, "30s") + configFileOverrides1 := overridesDymintToml(settlement_layer_rollapp1, settlement_node_address, rollapp1_id, gas_price_rollapp1, maxIdleTime1, maxProofTime, "50s") // setup config for rollapp 2 settlement_layer_rollapp2 := "dymension" rollapp2_id := "decentrio_12345-1" gas_price_rollapp2 := "0adym" maxIdleTime2 := "3s" - configFileOverrides2 := overridesDymintToml(settlement_layer_rollapp2, settlement_node_address, rollapp2_id, gas_price_rollapp2, maxIdleTime2, maxProofTime, "30s") + configFileOverrides2 := overridesDymintToml(settlement_layer_rollapp2, settlement_node_address, rollapp2_id, gas_price_rollapp2, maxIdleTime2, maxProofTime, "50s") // Increase dispute blocks modifyGenesisKV := append( @@ -748,7 +773,7 @@ func TestDelayedAck_NoFinalizedStates_EVM(t *testing.T) { // This can be used to write to the block database which will index all block data e.g. txs, msgs, events, etc. // BlockDatabaseFile: test.DefaultBlockDatabaseFilepath(), - }, nil, "", nil) + }, nil, "", nil, false, 780) require.NoError(t, err) CreateChannel(ctx, t, r1, eRep, dymension.CosmosChain, rollapp1.CosmosChain, ibcPath) @@ -826,6 +851,12 @@ func TestDelayedAck_NoFinalizedStates_EVM(t *testing.T) { require.NoError(t, err) require.True(t, isFinalized) + _, err = dymension.GetNode().FinalizePacketsUntilHeight(ctx, dymensionUserAddr, rollapp1.GetChainID(), fmt.Sprint(rollappHeight)) + require.NoError(t, err) + + err = testutil.WaitForBlocks(ctx, 10, dymension, rollapp1) + require.NoError(t, err) + // Assert balance was updated on the Hub testutil.AssertBalance(t, ctx, rollapp1, rollapp1UserAddr, rollapp1.Config().Denom, walletAmount.Sub(transferData.Amount)) // Minus 0.1% of transfer amount for bridge fee @@ -847,6 +878,9 @@ func TestDelayedAck_NoFinalizedStates_EVM(t *testing.T) { } }, ) + + // Run invariant check + CheckInvariant(t, ctx, dymension, dymensionUser.KeyName()) } func TestDelayedAck_NoFinalizedStates_Wasm(t *testing.T) { @@ -863,14 +897,14 @@ func TestDelayedAck_NoFinalizedStates_Wasm(t *testing.T) { gas_price_rollapp1 := "0adym" maxIdleTime1 := "3s" maxProofTime := "500ms" - configFileOverrides1 := overridesDymintToml(settlement_layer_rollapp1, settlement_node_address, rollapp1_id, gas_price_rollapp1, maxIdleTime1, maxProofTime, "30s") + configFileOverrides1 := overridesDymintToml(settlement_layer_rollapp1, settlement_node_address, rollapp1_id, gas_price_rollapp1, maxIdleTime1, maxProofTime, "50s") // setup config for rollapp 2 settlement_layer_rollapp2 := "dymension" rollapp2_id := "decentrio_12345-1" gas_price_rollapp2 := "0adym" maxIdleTime2 := "3s" - configFileOverrides2 := overridesDymintToml(settlement_layer_rollapp2, settlement_node_address, rollapp2_id, gas_price_rollapp2, maxIdleTime2, maxProofTime, "30s") + configFileOverrides2 := overridesDymintToml(settlement_layer_rollapp2, settlement_node_address, rollapp2_id, gas_price_rollapp2, maxIdleTime2, maxProofTime, "50s") // Increase dispute blocks modifyGenesisKV := append( @@ -1002,7 +1036,7 @@ func TestDelayedAck_NoFinalizedStates_Wasm(t *testing.T) { // This can be used to write to the block database which will index all block data e.g. txs, msgs, events, etc. // BlockDatabaseFile: test.DefaultBlockDatabaseFilepath(), - }, nil, "", nil) + }, nil, "", nil, false, 780) require.NoError(t, err) CreateChannel(ctx, t, r1, eRep, dymension.CosmosChain, rollapp1.CosmosChain, ibcPath) @@ -1048,6 +1082,9 @@ func TestDelayedAck_NoFinalizedStates_Wasm(t *testing.T) { _, err = rollapp1.SendIBCTransfer(ctx, dymChannel[0].ChannelID, rollapp1UserAddr, transferData, ibc.TransferOptions{}) require.NoError(t, err) + err = testutil.WaitForBlocks(ctx, 10, dymension, rollapp1) + require.NoError(t, err) + rollappHeight, err := rollapp1.GetNode().Height(ctx) require.NoError(t, err) @@ -1080,6 +1117,12 @@ func TestDelayedAck_NoFinalizedStates_Wasm(t *testing.T) { require.NoError(t, err) require.True(t, isFinalized) + _, err = dymension.GetNode().FinalizePacketsUntilHeight(ctx, dymensionUserAddr, rollapp1.GetChainID(), fmt.Sprint(rollappHeight)) + require.NoError(t, err) + + err = testutil.WaitForBlocks(ctx, 10, dymension, rollapp1) + require.NoError(t, err) + // Assert balance was updated on the Hub testutil.AssertBalance(t, ctx, rollapp1, rollapp1UserAddr, rollapp1.Config().Denom, walletAmount.Sub(transferData.Amount)) testutil.AssertBalance(t, ctx, dymension, dymensionUserAddr, rollappIBCDenom, transferAmount.Sub(bridgingFee)) @@ -1100,6 +1143,9 @@ func TestDelayedAck_NoFinalizedStates_Wasm(t *testing.T) { } }, ) + + // Run invariant check + CheckInvariant(t, ctx, dymension, dymensionUser.KeyName()) } func TestDelayedAck_RelayerDown_EVM(t *testing.T) { @@ -1116,23 +1162,14 @@ func TestDelayedAck_RelayerDown_EVM(t *testing.T) { gas_price_rollapp1 := "0adym" maxIdleTime1 := "3s" maxProofTime := "500ms" - configFileOverrides1 := overridesDymintToml(settlement_layer_rollapp1, settlement_node_address, rollapp1_id, gas_price_rollapp1, maxIdleTime1, maxProofTime, "100s") + configFileOverrides1 := overridesDymintToml(settlement_layer_rollapp1, settlement_node_address, rollapp1_id, gas_price_rollapp1, maxIdleTime1, maxProofTime, "50s") // setup config for rollapp 2 settlement_layer_rollapp2 := "dymension" rollapp2_id := "decentrio_12345-1" gas_price_rollapp2 := "0adym" maxIdleTime2 := "3s" - configFileOverrides2 := overridesDymintToml(settlement_layer_rollapp2, settlement_node_address, rollapp2_id, gas_price_rollapp2, maxIdleTime2, maxProofTime, "100s") - - // Increase dispute blocks - modifyGenesisKV := append( - dymensionGenesisKV, - cosmos.GenesisKV{ - Key: "app_state.rollapp.params.dispute_period_in_blocks", - Value: fmt.Sprint(BLOCK_FINALITY_PERIOD), - }, - ) + configFileOverrides2 := overridesDymintToml(settlement_layer_rollapp2, settlement_node_address, rollapp2_id, gas_price_rollapp2, maxIdleTime2, maxProofTime, "50s") // Create chain factory with dymension numHubVals := 1 @@ -1200,7 +1237,7 @@ func TestDelayedAck_RelayerDown_EVM(t *testing.T) { GasAdjustment: 1.1, TrustingPeriod: "112h", NoHostMount: false, - ModifyGenesis: modifyDymensionGenesis(modifyGenesisKV), + ModifyGenesis: modifyDymensionGenesis(dymensionGenesisKV), ConfigFileOverrides: nil, }, NumValidators: &numHubVals, @@ -1255,7 +1292,7 @@ func TestDelayedAck_RelayerDown_EVM(t *testing.T) { // This can be used to write to the block database which will index all block data e.g. txs, msgs, events, etc. // BlockDatabaseFile: test.DefaultBlockDatabaseFilepath(), - }, nil, "", nil) + }, nil, "", nil, false, 780) require.NoError(t, err) CreateChannel(ctx, t, r1, eRep, dymension.CosmosChain, rollapp1.CosmosChain, ibcPath) @@ -1311,6 +1348,9 @@ func TestDelayedAck_RelayerDown_EVM(t *testing.T) { _, err = rollapp1.SendIBCTransfer(ctx, dymChannel[0].ChannelID, rollapp1UserAddr, transferData, ibc.TransferOptions{}) require.NoError(t, err) + err = testutil.WaitForBlocks(ctx, 10, dymension, rollapp1) + require.NoError(t, err) + rollappHeight, err := rollapp1.GetNode().Height(ctx) require.NoError(t, err) @@ -1322,6 +1362,12 @@ func TestDelayedAck_RelayerDown_EVM(t *testing.T) { require.NoError(t, err) require.True(t, isFinalized) + _, err = dymension.GetNode().FinalizePacketsUntilHeight(ctx, dymensionUserAddr, rollapp1.GetChainID(), fmt.Sprint(rollappHeight)) + require.NoError(t, err) + + err = testutil.WaitForBlocks(ctx, 30, dymension, rollapp1) + require.NoError(t, err) + // Get the IBC denom for urax on Hub rollappTokenDenom := transfertypes.GetPrefixedDenom(dymChannel[0].Counterparty.PortID, dymChannel[0].Counterparty.ChannelID, rollapp1.Config().Denom) rollappIBCDenom := transfertypes.ParseDenomTrace(rollappTokenDenom).IBCDenom() @@ -1374,6 +1420,9 @@ func TestDelayedAck_RelayerDown_EVM(t *testing.T) { require.NoError(t, err) require.True(t, isFinalized) + err = testutil.WaitForBlocks(ctx, 10, dymension, rollapp1) + require.NoError(t, err) + t.Log("rollapp1UserAddr:", rollapp1UserAddr) t.Log("dymIBCDenom:", dymIBCDenom) @@ -1407,6 +1456,9 @@ func TestDelayedAck_RelayerDown_EVM(t *testing.T) { } }, ) + + // Run invariant check + CheckInvariant(t, ctx, dymension, dymensionUser.KeyName()) } func TestDelayedAck_RelayerDown_Wasm(t *testing.T) { @@ -1423,23 +1475,14 @@ func TestDelayedAck_RelayerDown_Wasm(t *testing.T) { gas_price_rollapp1 := "0adym" maxIdleTime1 := "3s" maxProofTime := "500ms" - configFileOverrides1 := overridesDymintToml(settlement_layer_rollapp1, settlement_node_address, rollapp1_id, gas_price_rollapp1, maxIdleTime1, maxProofTime, "100s") + configFileOverrides1 := overridesDymintToml(settlement_layer_rollapp1, settlement_node_address, rollapp1_id, gas_price_rollapp1, maxIdleTime1, maxProofTime, "50s") // setup config for rollapp 2 settlement_layer_rollapp2 := "dymension" rollapp2_id := "decentrio_12345-1" gas_price_rollapp2 := "0adym" maxIdleTime2 := "3s" - configFileOverrides2 := overridesDymintToml(settlement_layer_rollapp2, settlement_node_address, rollapp2_id, gas_price_rollapp2, maxIdleTime2, maxProofTime, "100s") - - // Increase dispute blocks - modifyGenesisKV := append( - dymensionGenesisKV, - cosmos.GenesisKV{ - Key: "app_state.rollapp.params.dispute_period_in_blocks", - Value: fmt.Sprint(BLOCK_FINALITY_PERIOD), - }, - ) + configFileOverrides2 := overridesDymintToml(settlement_layer_rollapp2, settlement_node_address, rollapp2_id, gas_price_rollapp2, maxIdleTime2, maxProofTime, "50s") // Create chain factory with dymension numHubVals := 1 @@ -1507,7 +1550,7 @@ func TestDelayedAck_RelayerDown_Wasm(t *testing.T) { GasAdjustment: 1.1, TrustingPeriod: "112h", NoHostMount: false, - ModifyGenesis: modifyDymensionGenesis(modifyGenesisKV), + ModifyGenesis: modifyDymensionGenesis(dymensionGenesisKV), ConfigFileOverrides: nil, }, NumValidators: &numHubVals, @@ -1562,7 +1605,7 @@ func TestDelayedAck_RelayerDown_Wasm(t *testing.T) { // This can be used to write to the block database which will index all block data e.g. txs, msgs, events, etc. // BlockDatabaseFile: test.DefaultBlockDatabaseFilepath(), - }, nil, "", nil) + }, nil, "", nil, false, 780) require.NoError(t, err) CreateChannel(ctx, t, r1, eRep, dymension.CosmosChain, rollapp1.CosmosChain, ibcPath) @@ -1611,6 +1654,9 @@ func TestDelayedAck_RelayerDown_Wasm(t *testing.T) { _, err = rollapp1.SendIBCTransfer(ctx, dymChannel[0].ChannelID, rollapp1UserAddr, transferData, ibc.TransferOptions{}) require.NoError(t, err) + err = testutil.WaitForBlocks(ctx, 10, dymension, rollapp1) + require.NoError(t, err) + rollappHeight, err := rollapp1.GetNode().Height(ctx) require.NoError(t, err) @@ -1622,6 +1668,12 @@ func TestDelayedAck_RelayerDown_Wasm(t *testing.T) { require.NoError(t, err) require.True(t, isFinalized) + _, err = dymension.GetNode().FinalizePacketsUntilHeight(ctx, dymensionUserAddr, rollapp1.GetChainID(), fmt.Sprint(rollappHeight)) + require.NoError(t, err) + + err = testutil.WaitForBlocks(ctx, 30, dymension, rollapp1) + require.NoError(t, err) + // Get the IBC denom for urax on Hub rollappTokenDenom := transfertypes.GetPrefixedDenom(dymChannel[0].Counterparty.PortID, dymChannel[0].Counterparty.ChannelID, rollapp1.Config().Denom) rollappIBCDenom := transfertypes.ParseDenomTrace(rollappTokenDenom).IBCDenom() @@ -1674,6 +1726,9 @@ func TestDelayedAck_RelayerDown_Wasm(t *testing.T) { require.NoError(t, err) require.True(t, isFinalized) + err = testutil.WaitForBlocks(ctx, 10, dymension, rollapp1) + require.NoError(t, err) + t.Log("rollapp1UserAddr:", rollapp1UserAddr) t.Log("dymIBCDenom:", dymIBCDenom) // Assert balance was updated on rollapp @@ -1701,4 +1756,7 @@ func TestDelayedAck_RelayerDown_Wasm(t *testing.T) { } }, ) + + // Run invariant check + CheckInvariant(t, ctx, dymension, dymensionUser.KeyName()) } diff --git a/tests/ibc_pfm_test.go b/tests/ibc_pfm_test.go index a0d81891..358d92d8 100644 --- a/tests/ibc_pfm_test.go +++ b/tests/ibc_pfm_test.go @@ -36,7 +36,7 @@ package tests // dymintTomlOverrides["settlement_gas_prices"] = "0adym" // dymintTomlOverrides["max_idle_time"] = "3s" // dymintTomlOverrides["max_proof_time"] = "500ms" -// dymintTomlOverrides["batch_submit_max_time"] = "100s" +// dymintTomlOverrides["batch_submit_time"] = "50s" // configFileOverrides["config/dymint.toml"] = dymintTomlOverrides // // Create chain factory with dymension @@ -286,7 +286,7 @@ package tests // dymintTomlOverrides["settlement_gas_prices"] = "0adym" // dymintTomlOverrides["max_idle_time"] = "3s" // dymintTomlOverrides["max_proof_time"] = "500ms" -// dymintTomlOverrides["batch_submit_max_time"] = "100s" +// dymintTomlOverrides["batch_submit_time"] = "50s" // configFileOverrides["config/dymint.toml"] = dymintTomlOverrides // // Create chain factory with dymension @@ -536,7 +536,7 @@ package tests // dymintTomlOverrides["settlement_gas_prices"] = "0adym" // dymintTomlOverrides["max_idle_time"] = "3s" // dymintTomlOverrides["max_proof_time"] = "500ms" -// dymintTomlOverrides["batch_submit_max_time"] = "100s" +// dymintTomlOverrides["batch_submit_time"] = "50s" // configFileOverrides["config/dymint.toml"] = dymintTomlOverrides // // Create chain factory with dymension @@ -782,7 +782,7 @@ package tests // dymintTomlOverrides["settlement_gas_prices"] = "0adym" // dymintTomlOverrides["max_idle_time"] = "3s" // dymintTomlOverrides["max_proof_time"] = "500ms" -// dymintTomlOverrides["batch_submit_max_time"] = "100s" +// dymintTomlOverrides["batch_submit_time"] = "50s" // configFileOverrides["config/dymint.toml"] = dymintTomlOverrides // // Create chain factory with dymension diff --git a/tests/ibc_pfm_with_grace_period_test.go b/tests/ibc_pfm_with_grace_period_test.go index 1616b409..8efb369d 100644 --- a/tests/ibc_pfm_with_grace_period_test.go +++ b/tests/ibc_pfm_with_grace_period_test.go @@ -37,7 +37,7 @@ package tests // dymintTomlOverrides["settlement_gas_prices"] = "0adym" // dymintTomlOverrides["max_idle_time"] = "3s" // dymintTomlOverrides["max_proof_time"] = "500ms" -// dymintTomlOverrides["batch_submit_max_time"] = "100s" +// dymintTomlOverrides["batch_submit_time"] = "50s" // modifyGenesisKV := append( // dymensionGenesisKV, @@ -332,7 +332,7 @@ package tests // dymintTomlOverrides["settlement_gas_prices"] = "0adym" // dymintTomlOverrides["max_idle_time"] = "3s" // dymintTomlOverrides["max_proof_time"] = "500ms" -// dymintTomlOverrides["batch_submit_max_time"] = "100s" +// dymintTomlOverrides["batch_submit_time"] = "50s" // modifyGenesisKV := append(dymensionGenesisKV, // cosmos.GenesisKV{ @@ -625,14 +625,14 @@ package tests // gas_price_rollapp1 := "0adym" // maxIdleTime1 := "3s" // maxProofTime := "500ms" -// configFileOverrides1 := overridesDymintToml(settlement_layer_rollapp1, settlement_node_address, rollapp1_id, gas_price_rollapp1, maxIdleTime1, maxProofTime, "100s") +// configFileOverrides1 := overridesDymintToml(settlement_layer_rollapp1, settlement_node_address, rollapp1_id, gas_price_rollapp1, maxIdleTime1, maxProofTime,"50s") // // setup config for rollapp 2 // settlement_layer_rollapp2 := "dymension" // rollapp2_id := "decentrio_12345-1" // gas_price_rollapp2 := "0adym" // maxIdleTime2 := "3s" -// configFileOverrides2 := overridesDymintToml(settlement_layer_rollapp2, settlement_node_address, rollapp2_id, gas_price_rollapp2, maxIdleTime2, maxProofTime, "100s") +// configFileOverrides2 := overridesDymintToml(settlement_layer_rollapp2, settlement_node_address, rollapp2_id, gas_price_rollapp2, maxIdleTime2, maxProofTime,"50s") // // Create chain factory with dymension // numHubVals := 1 @@ -981,14 +981,14 @@ package tests // gas_price_rollapp1 := "0adym" // maxIdleTime1 := "3s" // maxProofTime := "500ms" -// configFileOverrides1 := overridesDymintToml(settlement_layer_rollapp1, settlement_node_address, rollapp1_id, gas_price_rollapp1, maxIdleTime1, maxProofTime, "100s") +// configFileOverrides1 := overridesDymintToml(settlement_layer_rollapp1, settlement_node_address, rollapp1_id, gas_price_rollapp1, maxIdleTime1, maxProofTime,"50s") // // setup config for rollapp 2 // settlement_layer_rollapp2 := "dymension" // rollapp2_id := "decentrio_12345-1" // gas_price_rollapp2 := "0adym" // maxIdleTime2 := "3s" -// configFileOverrides2 := overridesDymintToml(settlement_layer_rollapp2, settlement_node_address, rollapp2_id, gas_price_rollapp2, maxIdleTime2, maxProofTime, "100s") +// configFileOverrides2 := overridesDymintToml(settlement_layer_rollapp2, settlement_node_address, rollapp2_id, gas_price_rollapp2, maxIdleTime2, maxProofTime,"50s") // modifyGenesisKV := append(dymensionGenesisKV, // cosmos.GenesisKV{ diff --git a/tests/ibc_timeout_test.go b/tests/ibc_timeout_test.go index fd03924c..0a551d5b 100644 --- a/tests/ibc_timeout_test.go +++ b/tests/ibc_timeout_test.go @@ -8,7 +8,6 @@ import ( transfertypes "github.com/cosmos/ibc-go/v7/modules/apps/transfer/types" test "github.com/decentrio/rollup-e2e-testing" - "github.com/decentrio/rollup-e2e-testing/cosmos" "github.com/decentrio/rollup-e2e-testing/cosmos/hub/dym_hub" "github.com/decentrio/rollup-e2e-testing/cosmos/rollapp/dym_rollapp" "github.com/decentrio/rollup-e2e-testing/ibc" @@ -37,18 +36,11 @@ func TestIBCTransferTimeout_EVM(t *testing.T) { dymintTomlOverrides["settlement_gas_prices"] = "0adym" dymintTomlOverrides["max_idle_time"] = "3s" dymintTomlOverrides["max_proof_time"] = "500ms" - dymintTomlOverrides["batch_submit_max_time"] = "30s" + dymintTomlOverrides["batch_submit_time"] = "50s" + dymintTomlOverrides["p2p_blocksync_enabled"] = "false" configFileOverrides["config/dymint.toml"] = dymintTomlOverrides - modifyGenesisKV := append( - dymensionGenesisKV, - cosmos.GenesisKV{ - Key: "app_state.rollapp.params.dispute_period_in_blocks", - Value: fmt.Sprint(10), - }, - ) - // Create chain factory with dymension numHubVals := 1 numHubFullNodes := 1 @@ -93,7 +85,7 @@ func TestIBCTransferTimeout_EVM(t *testing.T) { GasAdjustment: 1.1, TrustingPeriod: "112h", NoHostMount: false, - ModifyGenesis: modifyDymensionGenesis(modifyGenesisKV), + ModifyGenesis: modifyDymensionGenesis(dymensionGenesisKV), ConfigFileOverrides: nil, }, NumValidators: &numHubVals, @@ -134,7 +126,7 @@ func TestIBCTransferTimeout_EVM(t *testing.T) { // This can be used to write to the block database which will index all block data e.g. txs, msgs, events, etc. // BlockDatabaseFile: test.DefaultBlockDatabaseFilepath(), - }, nil, "", nil) + }, nil, "", nil, false, 780) require.NoError(t, err) CreateChannel(ctx, t, r, eRep, dymension.CosmosChain, rollapp1.CosmosChain, ibcPath) @@ -171,6 +163,9 @@ func TestIBCTransferTimeout_EVM(t *testing.T) { _, err = rollapp1.SendIBCTransfer(ctx, channel.ChannelID, rollappUserAddr, transferData, ibc.TransferOptions{}) require.NoError(t, err) + err = testutil.WaitForBlocks(ctx, 10, dymension, rollapp1) + require.NoError(t, err) + rollappHeight, err := rollapp1.GetNode().Height(ctx) require.NoError(t, err) @@ -182,6 +177,9 @@ func TestIBCTransferTimeout_EVM(t *testing.T) { require.NoError(t, err) require.True(t, isFinalized) + _, err = dymension.GetNode().FinalizePacketsUntilHeight(ctx, dymensionUserAddr, rollapp1.GetChainID(), fmt.Sprint(rollappHeight)) + require.NoError(t, err) + transferData = ibc.WalletData{ Address: dymensionUserAddr, Denom: rollapp1.Config().Denom, @@ -198,24 +196,24 @@ func TestIBCTransferTimeout_EVM(t *testing.T) { _, err = rollapp1.SendIBCTransfer(ctx, channel.ChannelID, rollappUserAddr, transferData, options) require.NoError(t, err) - rollappHeight, err = rollapp1.GetNode().Height(ctx) + err = testutil.WaitForBlocks(ctx, 10, dymension, rollapp1) require.NoError(t, err) - // Assert balance was updated on the rollapp - testutil.AssertBalance(t, ctx, rollapp1, rollappUserAddr, rollapp1.Config().Denom, walletAmount.Sub(transferData.Amount).Sub(transferData.Amount)) + rollappHeight, err = rollapp1.GetNode().Height(ctx) + require.NoError(t, err) // wait until the packet is finalized isFinalized, err = dymension.WaitUntilRollappHeightIsFinalized(ctx, rollapp1.GetChainID(), rollappHeight, 300) require.NoError(t, err) require.True(t, isFinalized) + _, err = dymension.GetNode().FinalizePacketsUntilHeight(ctx, dymensionUserAddr, rollapp1.GetChainID(), fmt.Sprint(rollappHeight)) + require.NoError(t, err) + // Get the IBC denom for urax on Hub rollappTokenDenom := transfertypes.GetPrefixedDenom(channel.Counterparty.PortID, channel.Counterparty.ChannelID, rollapp1.Config().Denom) rollappIBCDenom := transfertypes.ParseDenomTrace(rollappTokenDenom).IBCDenom() - err = testutil.WaitForBlocks(ctx, 30, dymension, rollapp1) - require.NoError(t, err) - // Assert funds were returned to the sender after the timeout has occured testutil.AssertBalance(t, ctx, rollapp1, rollappUserAddr, rollapp1.Config().Denom, walletAmount.Sub(transferData.Amount)) testutil.AssertBalance(t, ctx, dymension, dymensionUserAddr, rollappIBCDenom, transferAmount.Sub(bridgingFee)) @@ -244,6 +242,9 @@ func TestIBCTransferTimeout_EVM(t *testing.T) { // According to delayedack module, we need the rollapp to have finalizedHeight > ibcClientLatestHeight // in order to trigger ibc timeout or else it will trigger callback + err = testutil.WaitForBlocks(ctx, 10, dymension, rollapp1) + require.NoError(t, err) + rollappHeight, err = rollapp1.GetNode().Height(ctx) require.NoError(t, err) @@ -252,7 +253,10 @@ func TestIBCTransferTimeout_EVM(t *testing.T) { require.NoError(t, err) require.True(t, isFinalized) - err = testutil.WaitForBlocks(ctx, 30, dymension, rollapp1) + _, err = dymension.GetNode().FinalizePacketsUntilHeight(ctx, dymensionUserAddr, rollapp1.GetChainID(), fmt.Sprint(rollappHeight)) + require.NoError(t, err) + + err = testutil.WaitForBlocks(ctx, 10, dymension, rollapp1) require.NoError(t, err) // Assert funds were returned to the sender after the timeout has occured @@ -267,6 +271,9 @@ func TestIBCTransferTimeout_EVM(t *testing.T) { } }, ) + + // Run invariant check + CheckInvariant(t, ctx, dymension, dymensionUser.KeyName()) } // This test case verifies the system's behavior when an IBC packet sent from the rollapp to the hub times out. @@ -285,18 +292,11 @@ func TestIBCTransferTimeout_Wasm(t *testing.T) { dymintTomlOverrides["settlement_gas_prices"] = "0adym" dymintTomlOverrides["max_idle_time"] = "3s" dymintTomlOverrides["max_proof_time"] = "500ms" - dymintTomlOverrides["batch_submit_max_time"] = "30s" + dymintTomlOverrides["batch_submit_time"] = "20s" + dymintTomlOverrides["p2p_blocksync_enabled"] = "false" configFileOverrides["config/dymint.toml"] = dymintTomlOverrides - modifyGenesisKV := append( - dymensionGenesisKV, - cosmos.GenesisKV{ - Key: "app_state.rollapp.params.dispute_period_in_blocks", - Value: fmt.Sprint(10), - }, - ) - // Create chain factory with dymension numHubVals := 1 numHubFullNodes := 1 @@ -341,7 +341,7 @@ func TestIBCTransferTimeout_Wasm(t *testing.T) { GasAdjustment: 1.1, TrustingPeriod: "112h", NoHostMount: false, - ModifyGenesis: modifyDymensionGenesis(modifyGenesisKV), + ModifyGenesis: modifyDymensionGenesis(dymensionGenesisKV), ConfigFileOverrides: nil, }, NumValidators: &numHubVals, @@ -382,7 +382,7 @@ func TestIBCTransferTimeout_Wasm(t *testing.T) { // This can be used to write to the block database which will index all block data e.g. txs, msgs, events, etc. // BlockDatabaseFile: test.DefaultBlockDatabaseFilepath(), - }, nil, "", nil) + }, nil, "", nil, false, 780) require.NoError(t, err) CreateChannel(ctx, t, r, eRep, dymension.CosmosChain, rollapp1.CosmosChain, ibcPath) @@ -419,6 +419,9 @@ func TestIBCTransferTimeout_Wasm(t *testing.T) { _, err = rollapp1.SendIBCTransfer(ctx, channel.ChannelID, rollappUserAddr, transferData, ibc.TransferOptions{}) require.NoError(t, err) + err = testutil.WaitForBlocks(ctx, 10, dymension, rollapp1) + require.NoError(t, err) + rollappHeight, err := rollapp1.GetNode().Height(ctx) require.NoError(t, err) @@ -430,6 +433,9 @@ func TestIBCTransferTimeout_Wasm(t *testing.T) { require.NoError(t, err) require.True(t, isFinalized) + _, err = dymension.GetNode().FinalizePacketsUntilHeight(ctx, dymensionUserAddr, rollapp1.GetChainID(), fmt.Sprint(rollappHeight)) + require.NoError(t, err) + transferData = ibc.WalletData{ Address: dymensionUserAddr, Denom: rollapp1.Config().Denom, @@ -448,6 +454,9 @@ func TestIBCTransferTimeout_Wasm(t *testing.T) { // Assert balance was updated on the rollapp testutil.AssertBalance(t, ctx, rollapp1, rollappUserAddr, rollapp1.Config().Denom, walletAmount.Sub(transferData.Amount).Sub(transferData.Amount)) + err = testutil.WaitForBlocks(ctx, 10, dymension, rollapp1) + require.NoError(t, err) + rollappHeight, err = rollapp1.GetNode().Height(ctx) require.NoError(t, err) @@ -456,13 +465,13 @@ func TestIBCTransferTimeout_Wasm(t *testing.T) { require.NoError(t, err) require.True(t, isFinalized) + _, err = dymension.GetNode().FinalizePacketsUntilHeight(ctx, dymensionUserAddr, rollapp1.GetChainID(), fmt.Sprint(rollappHeight)) + require.NoError(t, err) + // Get the IBC denom for urax on Hub rollappTokenDenom := transfertypes.GetPrefixedDenom(channel.Counterparty.PortID, channel.Counterparty.ChannelID, rollapp1.Config().Denom) rollappIBCDenom := transfertypes.ParseDenomTrace(rollappTokenDenom).IBCDenom() - err = testutil.WaitForBlocks(ctx, 40, dymension, rollapp1) - require.NoError(t, err) - // Assert funds were returned to the sender after the timeout has occured testutil.AssertBalance(t, ctx, rollapp1, rollappUserAddr, rollapp1.Config().Denom, walletAmount.Sub(transferData.Amount)) testutil.AssertBalance(t, ctx, dymension, dymensionUserAddr, rollappIBCDenom, transferAmount.Sub(bridgingFee)) @@ -491,6 +500,9 @@ func TestIBCTransferTimeout_Wasm(t *testing.T) { // According to delayedack module, we need the rollapp to have finalizedHeight > ibcClientLatestHeight // in order to trigger ibc timeout or else it will trigger callback + err = testutil.WaitForBlocks(ctx, 10, dymension, rollapp1) + require.NoError(t, err) + rollappHeight, err = rollapp1.GetNode().Height(ctx) require.NoError(t, err) @@ -499,10 +511,16 @@ func TestIBCTransferTimeout_Wasm(t *testing.T) { require.NoError(t, err) require.True(t, isFinalized) - err = testutil.WaitForBlocks(ctx, 30, dymension, rollapp1) + _, err = dymension.GetNode().FinalizePacketsUntilHeight(ctx, dymensionUserAddr, rollapp1.GetChainID(), fmt.Sprint(rollappHeight)) + require.NoError(t, err) + + err = testutil.WaitForBlocks(ctx, 10, dymension, rollapp1) require.NoError(t, err) // Assert funds were returned to the sender after the timeout has occured testutil.AssertBalance(t, ctx, rollapp1, rollappUserAddr, dymensionIBCDenom, zeroBal) testutil.AssertBalance(t, ctx, dymension, dymensionUserAddr, dymension.Config().Denom, walletAmount) + + // Run invariant check + CheckInvariant(t, ctx, dymension, dymensionUser.KeyName()) } diff --git a/tests/ibc_transfer_test.go b/tests/ibc_transfer_test.go index af810bc6..c0a89679 100644 --- a/tests/ibc_transfer_test.go +++ b/tests/ibc_transfer_test.go @@ -33,7 +33,8 @@ func TestSpinUp(t *testing.T) { dymintTomlOverrides["settlement_gas_prices"] = "0adym" dymintTomlOverrides["max_idle_time"] = "3s" dymintTomlOverrides["max_proof_time"] = "500ms" - dymintTomlOverrides["batch_submit_max_time"] = "100s" + dymintTomlOverrides["batch_submit_time"] = "50s" + dymintTomlOverrides["p2p_blocksync_enabled"] = "false" configFileOverrides["config/dymint.toml"] = dymintTomlOverrides // Create chain factory with dymension @@ -97,7 +98,7 @@ func TestSpinUp(t *testing.T) { // This can be used to write to the block database which will index all block data e.g. txs, msgs, events, etc. // BlockDatabaseFile: test.DefaultBlockDatabaseFilepath(), - }, nil, "", nil) + }, nil, "", nil, false, 780) require.NoError(t, err) } @@ -117,7 +118,8 @@ func TestIBCTransferSuccess_EVM(t *testing.T) { dymintTomlOverrides["settlement_gas_prices"] = "0adym" dymintTomlOverrides["max_idle_time"] = "3s" dymintTomlOverrides["max_proof_time"] = "500ms" - dymintTomlOverrides["batch_submit_max_time"] = "100s" + dymintTomlOverrides["batch_submit_time"] = "50s" + dymintTomlOverrides["p2p_blocksync_enabled"] = "false" configFileOverrides["config/dymint.toml"] = dymintTomlOverrides // Create chain factory with dymension @@ -192,7 +194,7 @@ func TestIBCTransferSuccess_EVM(t *testing.T) { // This can be used to write to the block database which will index all block data e.g. txs, msgs, events, etc. // BlockDatabaseFile: test.DefaultBlockDatabaseFilepath(), - }, nil, "", nil) + }, nil, "", nil, false, 780) require.NoError(t, err) CreateChannel(ctx, t, r, eRep, dymension.CosmosChain, rollapp1.CosmosChain, ibcPath) @@ -224,6 +226,9 @@ func TestIBCTransferSuccess_EVM(t *testing.T) { _, err = rollapp1.SendIBCTransfer(ctx, channel.ChannelID, rollappUserAddr, transferData, ibc.TransferOptions{}) require.NoError(t, err) + err = testutil.WaitForBlocks(ctx, 10, dymension, rollapp1) + require.NoError(t, err) + rollappHeight, err := rollapp1.GetNode().Height(ctx) require.NoError(t, err) @@ -235,6 +240,14 @@ func TestIBCTransferSuccess_EVM(t *testing.T) { require.NoError(t, err) require.True(t, isFinalized) + txhash, err := dymension.GetNode().FinalizePacketsUntilHeight(ctx, dymensionUserAddr, rollapp1.GetChainID(), fmt.Sprint(rollappHeight)) + require.NoError(t, err) + + fmt.Println(txhash) + + err = testutil.WaitForBlocks(ctx, 5, dymension, rollapp1) + require.NoError(t, err) + // Get the IBC denom for urax on Hub rollappTokenDenom := transfertypes.GetPrefixedDenom(channel.Counterparty.PortID, channel.Counterparty.ChannelID, rollapp1.Config().Denom) rollappIBCDenom := transfertypes.ParseDenomTrace(rollappTokenDenom).IBCDenom() @@ -272,6 +285,9 @@ func TestIBCTransferSuccess_EVM(t *testing.T) { require.NoError(t, err) erc20MAccAddr := erc20MAcc.Account.BaseAccount.Address testutil.AssertBalance(t, ctx, rollapp1, erc20MAccAddr, dymensionIBCDenom, transferData.Amount) + + // Run invariant check + CheckInvariant(t, ctx, dymension, dymensionUser.KeyName()) } // TestIBCTransferSuccess ensure that the transfer between Hub and Rollapp is accurate. @@ -290,7 +306,7 @@ func TestIBCTransferSuccess_Wasm(t *testing.T) { dymintTomlOverrides["settlement_gas_prices"] = "0adym" dymintTomlOverrides["max_idle_time"] = "3s" dymintTomlOverrides["max_proof_time"] = "500ms" - dymintTomlOverrides["batch_submit_max_time"] = "100s" + dymintTomlOverrides["batch_submit_time"] = "50s" configFileOverrides["config/dymint.toml"] = dymintTomlOverrides // Create chain factory with dymension @@ -365,7 +381,7 @@ func TestIBCTransferSuccess_Wasm(t *testing.T) { // This can be used to write to the block database which will index all block data e.g. txs, msgs, events, etc. // BlockDatabaseFile: test.DefaultBlockDatabaseFilepath(), - }, nil, "", nil) + }, nil, "", nil, false, 780) require.NoError(t, err) CreateChannel(ctx, t, r, eRep, dymension.CosmosChain, rollapp1.CosmosChain, ibcPath) @@ -399,6 +415,9 @@ func TestIBCTransferSuccess_Wasm(t *testing.T) { _, err = rollapp1.SendIBCTransfer(ctx, channel.ChannelID, rollappUserAddr, transferData, ibc.TransferOptions{}) require.NoError(t, err) + err = testutil.WaitForBlocks(ctx, 10, dymension, rollapp1) + require.NoError(t, err) + rollappHeight, err := rollapp1.GetNode().Height(ctx) require.NoError(t, err) @@ -410,6 +429,12 @@ func TestIBCTransferSuccess_Wasm(t *testing.T) { require.NoError(t, err) require.True(t, isFinalized) + _, err = dymension.GetNode().FinalizePacketsUntilHeight(ctx, dymensionUserAddr, rollapp1.GetChainID(), fmt.Sprint(rollappHeight)) + require.NoError(t, err) + + err = testutil.WaitForBlocks(ctx, 10, dymension, rollapp1) + require.NoError(t, err) + // Get the IBC denom for urax on Hub rollappTokenDenom := transfertypes.GetPrefixedDenom(channel.Counterparty.PortID, channel.Counterparty.ChannelID, rollapp1.Config().Denom) rollappIBCDenom := transfertypes.ParseDenomTrace(rollappTokenDenom).IBCDenom() @@ -443,6 +468,9 @@ func TestIBCTransferSuccess_Wasm(t *testing.T) { testutil.AssertBalance(t, ctx, dymension, dymensionUserAddr, dymension.Config().Denom, dymensionOrigBal.Sub(transferData.Amount)) testutil.AssertBalance(t, ctx, rollapp1, rollappUserAddr, dymensionIBCDenom, transferAmount) + + // Run invariant check + CheckInvariant(t, ctx, dymension, dymensionUser.KeyName()) } // TestGenesisIBCTransferWithReservedMemo_EVM ensure that after the genesis transfer phase for rollapp is completed, transfer memo contain a reserved name field cannot be used. @@ -461,7 +489,7 @@ func TestGenesisIBCTransferReservedMemo_EVM(t *testing.T) { dymintTomlOverrides["settlement_gas_prices"] = "0adym" dymintTomlOverrides["max_idle_time"] = "3s" dymintTomlOverrides["max_proof_time"] = "500ms" - dymintTomlOverrides["batch_submit_max_time"] = "100s" + dymintTomlOverrides["batch_submit_time"] = "50s" configFileOverrides["config/dymint.toml"] = dymintTomlOverrides // Create chain factory with dymension @@ -536,7 +564,7 @@ func TestGenesisIBCTransferReservedMemo_EVM(t *testing.T) { // This can be used to write to the block database which will index all block data e.g. txs, msgs, events, etc. // BlockDatabaseFile: test.DefaultBlockDatabaseFilepath(), - }, nil, "", nil) + }, nil, "", nil, false, 780) require.NoError(t, err) CreateChannel(ctx, t, r, eRep, dymension.CosmosChain, rollapp1.CosmosChain, ibcPath) @@ -568,6 +596,9 @@ func TestGenesisIBCTransferReservedMemo_EVM(t *testing.T) { _, err = rollapp1.SendIBCTransfer(ctx, channel.ChannelID, rollappUserAddr, transferData, ibc.TransferOptions{}) require.NoError(t, err) + err = testutil.WaitForBlocks(ctx, 10, dymension, rollapp1) + require.NoError(t, err) + rollappHeight, err := rollapp1.GetNode().Height(ctx) require.NoError(t, err) @@ -579,6 +610,12 @@ func TestGenesisIBCTransferReservedMemo_EVM(t *testing.T) { require.NoError(t, err) require.True(t, isFinalized) + _, err = dymension.GetNode().FinalizePacketsUntilHeight(ctx, dymensionUserAddr, rollapp1.GetChainID(), fmt.Sprint(rollappHeight)) + require.NoError(t, err) + + err = testutil.WaitForBlocks(ctx, 10, dymension, rollapp1) + require.NoError(t, err) + // Get the IBC denom for urax on Hub rollappTokenDenom := transfertypes.GetPrefixedDenom(channel.Counterparty.PortID, channel.Counterparty.ChannelID, rollapp1.Config().Denom) rollappIBCDenom := transfertypes.ParseDenomTrace(rollappTokenDenom).IBCDenom() @@ -592,13 +629,27 @@ func TestGenesisIBCTransferReservedMemo_EVM(t *testing.T) { }) require.ErrorContains(t, err, "cannot use transfer genesis memo: unauthorized") + err = testutil.WaitForBlocks(ctx, 10, dymension, rollapp1) + require.NoError(t, err) + + rollappHeight, err = rollapp1.GetNode().Height(ctx) + require.NoError(t, err) + // wait until the packet is finalized isFinalized, err = dymension.WaitUntilRollappHeightIsFinalized(ctx, rollapp1.GetChainID(), rollappHeight, 300) require.NoError(t, err) require.True(t, isFinalized) + _, err = dymension.GetNode().FinalizePacketsUntilHeight(ctx, dymensionUserAddr, rollapp1.GetChainID(), fmt.Sprint(rollappHeight)) + require.NoError(t, err) + + err = testutil.WaitForBlocks(ctx, 10, dymension, rollapp1) + require.NoError(t, err) + // Assert fund was not transferred testutil.AssertBalance(t, ctx, rollapp1, rollappUserAddr, rollapp1.Config().Denom, walletAmount.Sub(transferData.Amount)) + // Run invariant check + CheckInvariant(t, ctx, dymension, dymensionUser.KeyName()) } // TestGenesisIBCTransferWithReservedMemo_Wasm ensure that after the genesis transfer phase for rollapp is completed, transfer memo contain a reserved name field cannot be used. @@ -617,7 +668,8 @@ func TestGenesisIBCTransferReservedMemo_Wasm(t *testing.T) { dymintTomlOverrides["settlement_gas_prices"] = "0adym" dymintTomlOverrides["max_idle_time"] = "3s" dymintTomlOverrides["max_proof_time"] = "500ms" - dymintTomlOverrides["batch_submit_max_time"] = "100s" + dymintTomlOverrides["p2p_blocksync_enabled"] = "false" + dymintTomlOverrides["batch_submit_time"] = "50s" configFileOverrides["config/dymint.toml"] = dymintTomlOverrides // Create chain factory with dymension @@ -692,7 +744,7 @@ func TestGenesisIBCTransferReservedMemo_Wasm(t *testing.T) { // This can be used to write to the block database which will index all block data e.g. txs, msgs, events, etc. // BlockDatabaseFile: test.DefaultBlockDatabaseFilepath(), - }, nil, "", nil) + }, nil, "", nil, false, 780) require.NoError(t, err) CreateChannel(ctx, t, r, eRep, dymension.CosmosChain, rollapp1.CosmosChain, ibcPath) @@ -724,6 +776,9 @@ func TestGenesisIBCTransferReservedMemo_Wasm(t *testing.T) { _, err = rollapp1.SendIBCTransfer(ctx, channel.ChannelID, rollappUserAddr, transferData, ibc.TransferOptions{}) require.NoError(t, err) + err = testutil.WaitForBlocks(ctx, 10, dymension, rollapp1) + require.NoError(t, err) + rollappHeight, err := rollapp1.GetNode().Height(ctx) require.NoError(t, err) @@ -735,6 +790,12 @@ func TestGenesisIBCTransferReservedMemo_Wasm(t *testing.T) { require.NoError(t, err) require.True(t, isFinalized) + _, err = dymension.GetNode().FinalizePacketsUntilHeight(ctx, dymensionUserAddr, rollapp1.GetChainID(), fmt.Sprint(rollappHeight)) + require.NoError(t, err) + + err = testutil.WaitForBlocks(ctx, 10, dymension, rollapp1) + require.NoError(t, err) + // Get the IBC denom for urax on Hub rollappTokenDenom := transfertypes.GetPrefixedDenom(channel.Counterparty.PortID, channel.Counterparty.ChannelID, rollapp1.Config().Denom) rollappIBCDenom := transfertypes.ParseDenomTrace(rollappTokenDenom).IBCDenom() @@ -748,11 +809,26 @@ func TestGenesisIBCTransferReservedMemo_Wasm(t *testing.T) { }) require.ErrorContains(t, err, "cannot use transfer genesis memo: unauthorized") + err = testutil.WaitForBlocks(ctx, 10, dymension, rollapp1) + require.NoError(t, err) + + rollappHeight, err = rollapp1.GetNode().Height(ctx) + require.NoError(t, err) + // wait until the packet is finalized isFinalized, err = dymension.WaitUntilRollappHeightIsFinalized(ctx, rollapp1.GetChainID(), rollappHeight, 300) require.NoError(t, err) require.True(t, isFinalized) + _, err = dymension.GetNode().FinalizePacketsUntilHeight(ctx, dymensionUserAddr, rollapp1.GetChainID(), fmt.Sprint(rollappHeight)) + require.NoError(t, err) + + err = testutil.WaitForBlocks(ctx, 10, dymension, rollapp1) + require.NoError(t, err) + // Assert fund was not transferred testutil.AssertBalance(t, ctx, rollapp1, rollappUserAddr, rollapp1.Config().Denom, walletAmount.Sub(transferData.Amount)) + + // Run invariant check + CheckInvariant(t, ctx, dymension, dymensionUser.KeyName()) } diff --git a/tests/rollapp_invariant_test.go b/tests/rollapp_invariant_test.go index 353aaabf..dd862717 100644 --- a/tests/rollapp_invariant_test.go +++ b/tests/rollapp_invariant_test.go @@ -6,7 +6,6 @@ import ( "testing" test "github.com/decentrio/rollup-e2e-testing" - "github.com/decentrio/rollup-e2e-testing/cosmos" "github.com/decentrio/rollup-e2e-testing/cosmos/hub/dym_hub" "github.com/decentrio/rollup-e2e-testing/cosmos/rollapp/dym_rollapp" "github.com/decentrio/rollup-e2e-testing/ibc" @@ -31,22 +30,14 @@ func TestRollappInvariant_EVM(t *testing.T) { gas_price_rollapp1 := "0adym" maxIdleTime1 := "3s" maxProofTime := "500ms" - configFileOverrides1 := overridesDymintToml(settlement_layer_rollapp1, settlement_node_address, rollapp1_id, gas_price_rollapp1, maxIdleTime1, maxProofTime, "100s") + configFileOverrides1 := overridesDymintToml(settlement_layer_rollapp1, settlement_node_address, rollapp1_id, gas_price_rollapp1, maxIdleTime1, maxProofTime, "50s") // setup config for rollapp 2 settlement_layer_rollapp2 := "dymension" rollapp2_id := "decentrio_12345-1" gas_price_rollapp2 := "0adym" maxIdleTime2 := "3s" - configFileOverrides2 := overridesDymintToml(settlement_layer_rollapp2, settlement_node_address, rollapp2_id, gas_price_rollapp2, maxIdleTime2, maxProofTime, "100s") - - modifyGenesisKV := append( - dymensionGenesisKV, - cosmos.GenesisKV{ - Key: "app_state.rollapp.params.dispute_period_in_blocks", - Value: fmt.Sprint(BLOCK_FINALITY_PERIOD), - }, - ) + configFileOverrides2 := overridesDymintToml(settlement_layer_rollapp2, settlement_node_address, rollapp2_id, gas_price_rollapp2, maxIdleTime2, maxProofTime, "50s") // Create chain factory with dymension numHubVals := 1 @@ -114,7 +105,7 @@ func TestRollappInvariant_EVM(t *testing.T) { GasAdjustment: 1.1, TrustingPeriod: "112h", NoHostMount: false, - ModifyGenesis: modifyDymensionGenesis(modifyGenesisKV), + ModifyGenesis: modifyDymensionGenesis(dymensionGenesisKV), ConfigFileOverrides: nil, }, NumValidators: &numHubVals, @@ -169,7 +160,7 @@ func TestRollappInvariant_EVM(t *testing.T) { // This can be used to write to the block database which will index all block data e.g. txs, msgs, events, etc. // BlockDatabaseFile: test.DefaultBlockDatabaseFilepath(), - }, nil, "", nil) + }, nil, "", nil, false, 780) require.NoError(t, err) CreateChannel(ctx, t, r1, eRep, dymension.CosmosChain, rollapp1.CosmosChain, ibcPath) @@ -294,22 +285,14 @@ func TestRollappInvariant_Wasm(t *testing.T) { gas_price_rollapp1 := "0adym" maxIdleTime1 := "3s" maxProofTime := "500ms" - configFileOverrides1 := overridesDymintToml(settlement_layer_rollapp1, settlement_node_address, rollapp1_id, gas_price_rollapp1, maxIdleTime1, maxProofTime, "100s") + configFileOverrides1 := overridesDymintToml(settlement_layer_rollapp1, settlement_node_address, rollapp1_id, gas_price_rollapp1, maxIdleTime1, maxProofTime, "50s") // setup config for rollapp 2 settlement_layer_rollapp2 := "dymension" rollapp2_id := "decentrio_12345-1" gas_price_rollapp2 := "0adym" maxIdleTime2 := "3s" - configFileOverrides2 := overridesDymintToml(settlement_layer_rollapp2, settlement_node_address, rollapp2_id, gas_price_rollapp2, maxIdleTime2, maxProofTime, "100s") - - modifyGenesisKV := append( - dymensionGenesisKV, - cosmos.GenesisKV{ - Key: "app_state.rollapp.params.dispute_period_in_blocks", - Value: fmt.Sprint(BLOCK_FINALITY_PERIOD), - }, - ) + configFileOverrides2 := overridesDymintToml(settlement_layer_rollapp2, settlement_node_address, rollapp2_id, gas_price_rollapp2, maxIdleTime2, maxProofTime, "50s") // Create chain factory with dymension numHubVals := 1 @@ -377,7 +360,7 @@ func TestRollappInvariant_Wasm(t *testing.T) { GasAdjustment: 1.1, TrustingPeriod: "112h", NoHostMount: false, - ModifyGenesis: modifyDymensionGenesis(modifyGenesisKV), + ModifyGenesis: modifyDymensionGenesis(dymensionGenesisKV), ConfigFileOverrides: nil, }, NumValidators: &numHubVals, @@ -432,7 +415,7 @@ func TestRollappInvariant_Wasm(t *testing.T) { // This can be used to write to the block database which will index all block data e.g. txs, msgs, events, etc. // BlockDatabaseFile: test.DefaultBlockDatabaseFilepath(), - }, nil, "", nil) + }, nil, "", nil, false, 780) require.NoError(t, err) CreateChannel(ctx, t, r1, eRep, dymension.CosmosChain, rollapp1.CosmosChain, ibcPath) diff --git a/tests/rollapp_upgrade_test.go b/tests/rollapp_upgrade_test.go index a2124c9f..d425d6ba 100644 --- a/tests/rollapp_upgrade_test.go +++ b/tests/rollapp_upgrade_test.go @@ -35,7 +35,8 @@ func TestRollappUpgradeNonStateBreaking_EVM(t *testing.T) { dymintTomlOverrides["settlement_gas_prices"] = "0adym" dymintTomlOverrides["max_idle_time"] = "3s" dymintTomlOverrides["max_proof_time"] = "500ms" - dymintTomlOverrides["batch_submit_max_time"] = "100s" + dymintTomlOverrides["batch_submit_time"] = "50s" + dymintTomlOverrides["p2p_blocksync_enabled"] = "false" configFileOverrides["config/dymint.toml"] = dymintTomlOverrides // Create chain factory with dymension @@ -110,7 +111,7 @@ func TestRollappUpgradeNonStateBreaking_EVM(t *testing.T) { // This can be used to write to the block database which will index all block data e.g. txs, msgs, events, etc. // BlockDatabaseFile: test.DefaultBlockDatabaseFilepath(), - }, nil, "", nil) + }, nil, "", nil, false, 780) require.NoError(t, err) CreateChannel(ctx, t, r, eRep, dymension.CosmosChain, rollapp1.CosmosChain, ibcPath) @@ -151,6 +152,9 @@ func TestRollappUpgradeNonStateBreaking_EVM(t *testing.T) { _, err = rollapp1.SendIBCTransfer(ctx, channel.ChannelID, rollappUserAddr, transferData, ibc.TransferOptions{}) require.NoError(t, err) + err = testutil.WaitForBlocks(ctx, 10, dymension, rollapp1) + require.NoError(t, err) + rollappHeight, err := rollapp1.GetNode().Height(ctx) require.NoError(t, err) @@ -162,6 +166,9 @@ func TestRollappUpgradeNonStateBreaking_EVM(t *testing.T) { require.NoError(t, err) require.True(t, isFinalized) + _, err = dymension.GetNode().FinalizePacketsUntilHeight(ctx, dymensionUserAddr, rollapp1.GetChainID(), fmt.Sprint(rollappHeight)) + require.NoError(t, err) + // Switch to a new binary err = rollapp1.StopAllNodes(ctx) require.NoError(t, err, "error stopping node(s)") @@ -205,6 +212,9 @@ func TestRollappUpgradeNonStateBreaking_EVM(t *testing.T) { _, err = rollapp1.SendIBCTransfer(ctx, channel.ChannelID, rollappUserAddr, transferData, ibc.TransferOptions{}) require.NoError(t, err) + err = testutil.WaitForBlocks(ctx, 10, dymension, rollapp1) + require.NoError(t, err) + rollappHeight, err = rollapp1.GetNode().Height(ctx) require.NoError(t, err) @@ -216,6 +226,12 @@ func TestRollappUpgradeNonStateBreaking_EVM(t *testing.T) { require.NoError(t, err) require.True(t, isFinalized) + _, err = dymension.GetNode().FinalizePacketsUntilHeight(ctx, dymensionUserAddr, rollapp1.GetChainID(), fmt.Sprint(rollappHeight)) + require.NoError(t, err) + + err = testutil.WaitForBlocks(ctx, 10, dymension, rollapp1) + require.NoError(t, err) + // Get the IBC denom for urax on Hub rollappTokenDenom := transfertypes.GetPrefixedDenom(channel.Counterparty.PortID, channel.Counterparty.ChannelID, rollapp1.Config().Denom) rollappIBCDenom := transfertypes.ParseDenomTrace(rollappTokenDenom).IBCDenom() @@ -224,6 +240,8 @@ func TestRollappUpgradeNonStateBreaking_EVM(t *testing.T) { testutil.AssertBalance(t, ctx, rollapp1, rollappUserAddr, rollapp1.Config().Denom, walletAmount.Sub(transferData.Amount).Sub(transferAmount)) // minus 0.1% of transfer amount for bridge fee testutil.AssertBalance(t, ctx, dymension, dymensionUserAddr, rollappIBCDenom, (transferAmount.Sub(bridgingFee)).MulRaw(2)) + // Run invariant check + CheckInvariant(t, ctx, dymension, dymensionUser.KeyName()) } func TestRollappUpgradeNonStateBreaking_Wasm(t *testing.T) { @@ -241,7 +259,8 @@ func TestRollappUpgradeNonStateBreaking_Wasm(t *testing.T) { dymintTomlOverrides["settlement_gas_prices"] = "0adym" dymintTomlOverrides["max_idle_time"] = "3s" dymintTomlOverrides["max_proof_time"] = "500ms" - dymintTomlOverrides["batch_submit_max_time"] = "100s" + dymintTomlOverrides["batch_submit_time"] = "50s" + dymintTomlOverrides["p2p_blocksync_enabled"] = "false" configFileOverrides["config/dymint.toml"] = dymintTomlOverrides // Create chain factory with dymension @@ -316,7 +335,7 @@ func TestRollappUpgradeNonStateBreaking_Wasm(t *testing.T) { // This can be used to write to the block database which will index all block data e.g. txs, msgs, events, etc. // BlockDatabaseFile: test.DefaultBlockDatabaseFilepath(), - }, nil, "", nil) + }, nil, "", nil, false, 780) require.NoError(t, err) CreateChannel(ctx, t, r, eRep, dymension.CosmosChain, rollapp1.CosmosChain, ibcPath) @@ -357,6 +376,9 @@ func TestRollappUpgradeNonStateBreaking_Wasm(t *testing.T) { _, err = rollapp1.SendIBCTransfer(ctx, channel.ChannelID, rollappUserAddr, transferData, ibc.TransferOptions{}) require.NoError(t, err) + err = testutil.WaitForBlocks(ctx, 10, dymension, rollapp1) + require.NoError(t, err) + rollappHeight, err := rollapp1.GetNode().Height(ctx) require.NoError(t, err) @@ -368,6 +390,9 @@ func TestRollappUpgradeNonStateBreaking_Wasm(t *testing.T) { require.NoError(t, err) require.True(t, isFinalized) + _, err = dymension.GetNode().FinalizePacketsUntilHeight(ctx, dymensionUserAddr, rollapp1.GetChainID(), fmt.Sprint(rollappHeight)) + require.NoError(t, err) + // Switch to a new binary err = rollapp1.StopAllNodes(ctx) require.NoError(t, err, "error stopping node(s)") @@ -393,6 +418,9 @@ func TestRollappUpgradeNonStateBreaking_Wasm(t *testing.T) { _, err = rollapp1.SendIBCTransfer(ctx, channel.ChannelID, rollappUserAddr, transferData, ibc.TransferOptions{}) require.NoError(t, err) + err = testutil.WaitForBlocks(ctx, 10, dymension, rollapp1) + require.NoError(t, err) + rollappHeight, err = rollapp1.GetNode().Height(ctx) require.NoError(t, err) @@ -404,6 +432,12 @@ func TestRollappUpgradeNonStateBreaking_Wasm(t *testing.T) { require.NoError(t, err) require.True(t, isFinalized) + _, err = dymension.GetNode().FinalizePacketsUntilHeight(ctx, dymensionUserAddr, rollapp1.GetChainID(), fmt.Sprint(rollappHeight)) + require.NoError(t, err) + + err = testutil.WaitForBlocks(ctx, 10, dymension, rollapp1) + require.NoError(t, err) + // Get the IBC denom for urax on Hub rollappTokenDenom := transfertypes.GetPrefixedDenom(channel.Counterparty.PortID, channel.Counterparty.ChannelID, rollapp1.Config().Denom) rollappIBCDenom := transfertypes.ParseDenomTrace(rollappTokenDenom).IBCDenom() @@ -433,6 +467,9 @@ func TestRollappUpgradeNonStateBreaking_Wasm(t *testing.T) { testutil.AssertBalance(t, ctx, dymension, dymensionUserAddr, dymension.Config().Denom, walletAmount.Sub(transferData.Amount)) testutil.AssertBalance(t, ctx, rollapp1, rollappUserAddr, dymensionIBCDenom, transferAmount) + + // Run invariant check + CheckInvariant(t, ctx, dymension, dymensionUser.KeyName()) } func TestRollapp_EVM_Upgrade(t *testing.T) { @@ -450,7 +487,8 @@ func TestRollapp_EVM_Upgrade(t *testing.T) { dymintTomlOverrides["settlement_gas_prices"] = "0adym" dymintTomlOverrides["max_idle_time"] = "3s" dymintTomlOverrides["max_proof_time"] = "500ms" - dymintTomlOverrides["batch_submit_max_time"] = "100s" + dymintTomlOverrides["batch_submit_time"] = "50s" + dymintTomlOverrides["p2p_blocksync_enabled"] = "false" configFileOverrides["config/dymint.toml"] = dymintTomlOverrides // Create chain factory with dymension @@ -531,7 +569,7 @@ func TestRollapp_EVM_Upgrade(t *testing.T) { // This can be used to write to the block database which will index all block data e.g. txs, msgs, events, etc. // BlockDatabaseFile: test.DefaultBlockDatabaseFilepath(), - }, nil, "", nil) + }, nil, "", nil, false, 780) require.NoError(t, err) CreateChannel(ctx, t, r, eRep, dymension.CosmosChain, rollapp1.CosmosChain, ibcPath) @@ -664,6 +702,9 @@ func TestRollapp_EVM_Upgrade(t *testing.T) { _, err = rollapp1.SendIBCTransfer(ctx, channel.ChannelID, rollappUserAddr, transferData, ibc.TransferOptions{}) require.NoError(t, err) + err = testutil.WaitForBlocks(ctx, 10, dymension, rollapp1) + require.NoError(t, err) + rollappHeight, err := rollapp1.GetNode().Height(ctx) require.NoError(t, err) @@ -678,6 +719,12 @@ func TestRollapp_EVM_Upgrade(t *testing.T) { require.NoError(t, err) require.True(t, isFinalized) + _, err = dymension.GetNode().FinalizePacketsUntilHeight(ctx, dymensionUserAddr, rollapp1.GetChainID(), fmt.Sprint(rollappHeight)) + require.NoError(t, err) + + err = testutil.WaitForBlocks(ctx, 10, dymension, rollapp1) + require.NoError(t, err) + // Get the IBC denom for urax on Hub rollappTokenDenom := transfertypes.GetPrefixedDenom(channel.Counterparty.PortID, channel.Counterparty.ChannelID, rollapp1.Config().Denom) rollappIBCDenom := transfertypes.ParseDenomTrace(rollappTokenDenom).IBCDenom() @@ -685,6 +732,8 @@ func TestRollapp_EVM_Upgrade(t *testing.T) { // Assert funds were returned to the sender after the timeout has occured testutil.AssertBalance(t, ctx, rollapp1, rollappUserAddr, rollapp1.Config().Denom, walletAmount.Sub(transferData.Amount)) testutil.AssertBalance(t, ctx, dymension, dymensionUserAddr, rollappIBCDenom, transferAmount.Sub(bridgingFee)) + // Run invariant check + CheckInvariant(t, ctx, dymension, dymensionUser.KeyName()) } func TestRollapp_Wasm_Upgrade(t *testing.T) { @@ -702,7 +751,8 @@ func TestRollapp_Wasm_Upgrade(t *testing.T) { dymintTomlOverrides["settlement_gas_prices"] = "0adym" dymintTomlOverrides["max_idle_time"] = "3s" dymintTomlOverrides["max_proof_time"] = "500ms" - dymintTomlOverrides["batch_submit_max_time"] = "100s" + dymintTomlOverrides["batch_submit_time"] = "50s" + dymintTomlOverrides["p2p_blocksync_enabled"] = "false" configFileOverrides["config/dymint.toml"] = dymintTomlOverrides // Create chain factory with dymension @@ -783,7 +833,7 @@ func TestRollapp_Wasm_Upgrade(t *testing.T) { // This can be used to write to the block database which will index all block data e.g. txs, msgs, events, etc. // BlockDatabaseFile: test.DefaultBlockDatabaseFilepath(), - }, nil, "", nil) + }, nil, "", nil, false, 780) require.NoError(t, err) CreateChannel(ctx, t, r, eRep, dymension.CosmosChain, rollapp1.CosmosChain, ibcPath) @@ -916,6 +966,9 @@ func TestRollapp_Wasm_Upgrade(t *testing.T) { _, err = rollapp1.SendIBCTransfer(ctx, channel.ChannelID, rollappUserAddr, transferData, ibc.TransferOptions{}) require.NoError(t, err) + err = testutil.WaitForBlocks(ctx, 10, dymension, rollapp1) + require.NoError(t, err) + rollappHeight, err := rollapp1.GetNode().Height(ctx) require.NoError(t, err) @@ -930,6 +983,12 @@ func TestRollapp_Wasm_Upgrade(t *testing.T) { require.NoError(t, err) require.True(t, isFinalized) + _, err = dymension.GetNode().FinalizePacketsUntilHeight(ctx, dymensionUserAddr, rollapp1.GetChainID(), fmt.Sprint(rollappHeight)) + require.NoError(t, err) + + err = testutil.WaitForBlocks(ctx, 10, dymension, rollapp1) + require.NoError(t, err) + // Get the IBC denom for urax on Hub rollappTokenDenom := transfertypes.GetPrefixedDenom(channel.Counterparty.PortID, channel.Counterparty.ChannelID, rollapp1.Config().Denom) rollappIBCDenom := transfertypes.ParseDenomTrace(rollappTokenDenom).IBCDenom() @@ -937,4 +996,6 @@ func TestRollapp_Wasm_Upgrade(t *testing.T) { // Assert funds were returned to the sender after the timeout has occured testutil.AssertBalance(t, ctx, rollapp1, rollappUserAddr, rollapp1.Config().Denom, walletAmount.Sub(transferData.Amount)) testutil.AssertBalance(t, ctx, dymension, dymensionUserAddr, rollappIBCDenom, transferAmount.Sub(bridgingFee)) + // Run invariant check + CheckInvariant(t, ctx, dymension, dymensionUser.KeyName()) } diff --git a/tests/sequencer_invariant_test.go b/tests/sequencer_invariant_test.go index f286e782..b5b0a97a 100644 --- a/tests/sequencer_invariant_test.go +++ b/tests/sequencer_invariant_test.go @@ -6,7 +6,6 @@ import ( "testing" test "github.com/decentrio/rollup-e2e-testing" - "github.com/decentrio/rollup-e2e-testing/cosmos" "github.com/decentrio/rollup-e2e-testing/cosmos/hub/dym_hub" "github.com/decentrio/rollup-e2e-testing/cosmos/rollapp/dym_rollapp" "github.com/decentrio/rollup-e2e-testing/ibc" @@ -31,22 +30,14 @@ func TestSequencerInvariant_EVM(t *testing.T) { gas_price_rollapp1 := "0adym" maxIdleTime1 := "3s" maxProofTime := "500ms" - configFileOverrides1 := overridesDymintToml(settlement_layer_rollapp1, settlement_node_address, rollapp1_id, gas_price_rollapp1, maxIdleTime1, maxProofTime, "100s") + configFileOverrides1 := overridesDymintToml(settlement_layer_rollapp1, settlement_node_address, rollapp1_id, gas_price_rollapp1, maxIdleTime1, maxProofTime, "50s") // setup config for rollapp 2 settlement_layer_rollapp2 := "dymension" rollapp2_id := "decentrio_12345-1" gas_price_rollapp2 := "0adym" maxIdleTime2 := "3s" - configFileOverrides2 := overridesDymintToml(settlement_layer_rollapp2, settlement_node_address, rollapp2_id, gas_price_rollapp2, maxIdleTime2, maxProofTime, "100s") - - modifyGenesisKV := append( - dymensionGenesisKV, - cosmos.GenesisKV{ - Key: "app_state.rollapp.params.dispute_period_in_blocks", - Value: fmt.Sprint(BLOCK_FINALITY_PERIOD), - }, - ) + configFileOverrides2 := overridesDymintToml(settlement_layer_rollapp2, settlement_node_address, rollapp2_id, gas_price_rollapp2, maxIdleTime2, maxProofTime, "50s") // Create chain factory with dymension numHubVals := 1 @@ -114,7 +105,7 @@ func TestSequencerInvariant_EVM(t *testing.T) { GasAdjustment: 1.1, TrustingPeriod: "112h", NoHostMount: false, - ModifyGenesis: modifyDymensionGenesis(modifyGenesisKV), + ModifyGenesis: modifyDymensionGenesis(dymensionGenesisKV), ConfigFileOverrides: nil, }, NumValidators: &numHubVals, @@ -169,7 +160,7 @@ func TestSequencerInvariant_EVM(t *testing.T) { // This can be used to write to the block database which will index all block data e.g. txs, msgs, events, etc. // BlockDatabaseFile: test.DefaultBlockDatabaseFilepath(), - }, nil, "", nil) + }, nil, "", nil, false, 780) require.NoError(t, err) _, _, err = rollapp1.GetNode().ExecInit(ctx, "sequencer1", "/var/cosmos-chain/sequencer1") @@ -297,22 +288,14 @@ func TestSequencerInvariant_Wasm(t *testing.T) { gas_price_rollapp1 := "0adym" maxIdleTime1 := "3s" maxProofTime := "500ms" - configFileOverrides1 := overridesDymintToml(settlement_layer_rollapp1, settlement_node_address, rollapp1_id, gas_price_rollapp1, maxIdleTime1, maxProofTime, "100s") + configFileOverrides1 := overridesDymintToml(settlement_layer_rollapp1, settlement_node_address, rollapp1_id, gas_price_rollapp1, maxIdleTime1, maxProofTime, "50s") // setup config for rollapp 2 settlement_layer_rollapp2 := "dymension" rollapp2_id := "decentrio_12345-1" gas_price_rollapp2 := "0adym" maxIdleTime2 := "3s" - configFileOverrides2 := overridesDymintToml(settlement_layer_rollapp2, settlement_node_address, rollapp2_id, gas_price_rollapp2, maxIdleTime2, maxProofTime, "100s") - - modifyGenesisKV := append( - dymensionGenesisKV, - cosmos.GenesisKV{ - Key: "app_state.rollapp.params.dispute_period_in_blocks", - Value: fmt.Sprint(BLOCK_FINALITY_PERIOD), - }, - ) + configFileOverrides2 := overridesDymintToml(settlement_layer_rollapp2, settlement_node_address, rollapp2_id, gas_price_rollapp2, maxIdleTime2, maxProofTime, "50s") // Create chain factory with dymension numHubVals := 1 @@ -380,7 +363,7 @@ func TestSequencerInvariant_Wasm(t *testing.T) { GasAdjustment: 1.1, TrustingPeriod: "112h", NoHostMount: false, - ModifyGenesis: modifyDymensionGenesis(modifyGenesisKV), + ModifyGenesis: modifyDymensionGenesis(dymensionGenesisKV), ConfigFileOverrides: nil, }, NumValidators: &numHubVals, @@ -435,7 +418,7 @@ func TestSequencerInvariant_Wasm(t *testing.T) { // This can be used to write to the block database which will index all block data e.g. txs, msgs, events, etc. // BlockDatabaseFile: test.DefaultBlockDatabaseFilepath(), - }, nil, "", nil) + }, nil, "", nil, false, 780) require.NoError(t, err) _, _, err = rollapp1.GetNode().ExecInit(ctx, "sequencer1", "/var/cosmos-chain/sequencer1") diff --git a/tests/sequencer_rotation_test.go b/tests/sequencer_rotation_test.go index 0a948ef1..ec9c40c2 100644 --- a/tests/sequencer_rotation_test.go +++ b/tests/sequencer_rotation_test.go @@ -1,22 +1,1168 @@ package tests import ( + "bufio" "context" "fmt" + "os" + "strings" "testing" + "time" + "cosmossdk.io/math" + transfertypes "github.com/cosmos/ibc-go/v7/modules/apps/transfer/types" "github.com/stretchr/testify/require" "go.uber.org/zap/zaptest" test "github.com/decentrio/rollup-e2e-testing" + "github.com/decentrio/rollup-e2e-testing/cosmos" "github.com/decentrio/rollup-e2e-testing/cosmos/hub/dym_hub" "github.com/decentrio/rollup-e2e-testing/cosmos/rollapp/dym_rollapp" "github.com/decentrio/rollup-e2e-testing/ibc" + "github.com/decentrio/rollup-e2e-testing/relayer" "github.com/decentrio/rollup-e2e-testing/testreporter" "github.com/decentrio/rollup-e2e-testing/testutil" - "github.com/decentrio/rollup-e2e-testing/relayer" ) +func Test_SeqRotation_NoSeq_DA_EVM(t *testing.T) { + if testing.Short() { + t.Skip() + } + + ctx := context.Background() + + go StartDA() + + // setup config for rollapp 1 + settlement_layer_rollapp1 := "dymension" + settlement_node_address := fmt.Sprintf("http://dymension_100-1-val-0-%s:26657", t.Name()) + rollapp1_id := "rollappevm_1234-1" + gas_price_rollapp1 := "0adym" + maxIdleTime1 := "3s" + maxProofTime := "500ms" + configFileOverrides := overridesDymintToml(settlement_layer_rollapp1, settlement_node_address, rollapp1_id, gas_price_rollapp1, maxIdleTime1, maxProofTime, "20s", false) + + // Create chain factory with dymension + numHubVals := 1 + numHubFullNodes := 1 + numRollAppVals := 1 + numRollAppFn := 0 + + cf := test.NewBuiltinChainFactory(zaptest.NewLogger(t), []*test.ChainSpec{ + { + Name: "rollapp1", + ChainConfig: ibc.ChainConfig{ + Type: "rollapp-dym", + Name: "rollapp-temp", + ChainID: "rollappevm_1234-1", + Images: []ibc.DockerImage{rollappEVMImage}, + Bin: "rollappd", + Bech32Prefix: "ethm", + Denom: "urax", + CoinType: "60", + GasPrices: "0.0urax", + GasAdjustment: 1.1, + TrustingPeriod: "112h", + EncodingConfig: encodingConfig(), + NoHostMount: false, + ModifyGenesis: modifyRollappEVMGenesis(rollappEVMGenesisKV), + ConfigFileOverrides: configFileOverrides, + }, + NumValidators: &numRollAppVals, + NumFullNodes: &numRollAppFn, + }, + { + Name: "dymension-hub", + ChainConfig: dymensionConfig, + NumValidators: &numHubVals, + NumFullNodes: &numHubFullNodes, + }, + }) + + // Get chains from the chain factory + chains, err := cf.Chains(t.Name()) + require.NoError(t, err) + + rollapp1 := chains[0].(*dym_rollapp.DymRollApp) + dymension := chains[1].(*dym_hub.DymHub) + + // Relayer Factory + client, network := test.DockerSetup(t) + + // relayer for rollapp 1 + r := test.NewBuiltinRelayerFactory(ibc.CosmosRly, zaptest.NewLogger(t), + relayer.CustomDockerImage(RelayerMainRepo, relayerVersion, "100:1000"), relayer.ImagePull(pullRelayerImage), + ).Build(t, client, "relayer", network) + + ic := test.NewSetup(). + AddRollUp(dymension, rollapp1). + AddRelayer(r, "relayer"). + AddLink(test.InterchainLink{ + Chain1: dymension, + Chain2: rollapp1, + Relayer: r, + Path: ibcPath, + }) + + rep := testreporter.NewNopReporter() + eRep := rep.RelayerExecReporter(t) + + err = ic.Build(ctx, eRep, test.InterchainBuildOptions{ + TestName: t.Name(), + Client: client, + NetworkID: network, + SkipPathCreation: true, + }, nil, "", nil, true, 780) + require.NoError(t, err) + + // Check IBC Transfer before switch + CreateChannel(ctx, t, r, eRep, dymension.CosmosChain, rollapp1.CosmosChain, ibcPath) + + // Create some user accounts on both chains + users := test.GetAndFundTestUsers(t, ctx, t.Name(), walletAmount, dymension, rollapp1) + + // Get our Bech32 encoded user addresses + dymensionUser, rollappUser := users[0], users[1] + + dymensionUserAddr := dymensionUser.FormattedAddress() + rollappUserAddr := rollappUser.FormattedAddress() + + channel, err := ibc.GetTransferChannel(ctx, r, eRep, dymension.Config().ChainID, rollapp1.Config().ChainID) + require.NoError(t, err) + + err = r.StartRelayer(ctx, eRep, ibcPath) + require.NoError(t, err) + + err = testutil.WaitForBlocks(ctx, 10, dymension, rollapp1) + require.NoError(t, err) + + // Send a normal ibc tx from RA -> Hub + transferData := ibc.WalletData{ + Address: dymensionUserAddr, + Denom: rollapp1.Config().Denom, + Amount: transferAmount, + } + + // Compose an IBC transfer and send from rollapp -> Hub + _, err = rollapp1.SendIBCTransfer(ctx, channel.ChannelID, rollappUserAddr, transferData, ibc.TransferOptions{}) + require.NoError(t, err) + + err = testutil.WaitForBlocks(ctx, 10, dymension, rollapp1) + require.NoError(t, err) + + rollappHeight, err := rollapp1.GetNode().Height(ctx) + require.NoError(t, err) + + // Assert balance was updated on the hub + testutil.AssertBalance(t, ctx, rollapp1, rollappUserAddr, rollapp1.Config().Denom, walletAmount.Sub(transferData.Amount)) + + // wait until the packet is finalized + isFinalized, err := dymension.WaitUntilRollappHeightIsFinalized(ctx, rollapp1.GetChainID(), rollappHeight, 300) + require.NoError(t, err) + require.True(t, isFinalized) + + _, err = dymension.GetNode().FinalizePacketsUntilHeight(ctx, dymensionUserAddr, rollapp1.GetChainID(), fmt.Sprint(rollappHeight)) + require.NoError(t, err) + + // Get the IBC denom for urax on Hub + rollappTokenDenom := transfertypes.GetPrefixedDenom(channel.Counterparty.PortID, channel.Counterparty.ChannelID, rollapp1.Config().Denom) + rollappIBCDenom := transfertypes.ParseDenomTrace(rollappTokenDenom).IBCDenom() + + testutil.AssertBalance(t, ctx, dymension, dymensionUserAddr, rollappIBCDenom, transferAmount.Sub(bridgingFee)) + + // Get original account balances + dymensionOrigBal, err := dymension.GetBalance(ctx, dymensionUserAddr, dymension.Config().Denom) + require.NoError(t, err) + + // Compose an IBC transfer and send from dymension -> rollapp + transferData = ibc.WalletData{ + Address: rollappUserAddr, + Denom: dymension.Config().Denom, + Amount: transferAmount, + } + + // Compose an IBC transfer and send from Hub -> rollapp + _, err = dymension.SendIBCTransfer(ctx, channel.ChannelID, dymensionUserAddr, transferData, ibc.TransferOptions{}) + require.NoError(t, err) + + // Assert balance was updated on the hub + testutil.AssertBalance(t, ctx, dymension, dymensionUserAddr, dymension.Config().Denom, dymensionOrigBal.Sub(transferData.Amount)) + + err = testutil.WaitForBlocks(ctx, 10, dymension, rollapp1) + require.NoError(t, err) + + // Get the IBC denom + dymensionTokenDenom := transfertypes.GetPrefixedDenom(channel.Counterparty.PortID, channel.Counterparty.ChannelID, dymension.Config().Denom) + dymensionIBCDenom := transfertypes.ParseDenomTrace(dymensionTokenDenom).IBCDenom() + + testutil.AssertBalance(t, ctx, dymension, dymensionUserAddr, dymension.Config().Denom, dymensionOrigBal.Sub(transferData.Amount)) + erc20MAcc, err := rollapp1.Validators[0].QueryModuleAccount(ctx, "erc20") + require.NoError(t, err) + erc20MAccAddr := erc20MAcc.Account.BaseAccount.Address + testutil.AssertBalance(t, ctx, rollapp1, erc20MAccAddr, dymensionIBCDenom, transferData.Amount) + + // Unbond sequencer1 + err = dymension.Unbond(ctx, "sequencer", rollapp1.GetSequencerKeyDir()) + require.NoError(t, err) + + seqAddr, err := dymension.AccountKeyBech32WithKeyDir(ctx, "sequencer", rollapp1.GetSequencerKeyDir()) + require.NoError(t, err) + + queryGetSequencerResponse, err := dymension.QueryShowSequencer(ctx, seqAddr) + require.NoError(t, err) + require.Equal(t, "OPERATING_STATUS_BONDED", queryGetSequencerResponse.Sequencer.Status) + + err = testutil.WaitForBlocks(ctx, 10, dymension, rollapp1) + require.NoError(t, err) + + time.Sleep(180 * time.Second) + + // Chain halted + err = testutil.WaitForBlocks(ctx, 5, dymension, rollapp1) + require.Error(t, err) + + queryGetSequencerResponse, err = dymension.QueryShowSequencer(ctx, seqAddr) + require.NoError(t, err) + require.Equal(t, "OPERATING_STATUS_UNBONDING", queryGetSequencerResponse.Sequencer.Status) + + lastBlock, err := rollapp1.Height(ctx) + require.NoError(t, err) + + // create 1 more sequencer + _, _, err = rollapp1.GetNode().ExecInit(ctx, "sequencer1", "/var/cosmos-chain/sequencer1") + require.NoError(t, err) + + cmd := append([]string{rollapp1.Validators[0].Chain.Config().Bin}, "dymint", "show-sequencer", "--home", "/var/cosmos-chain/sequencer1") + pub1, _, err := rollapp1.GetNode().Exec(ctx, cmd, nil) + require.NoError(t, err) + + // Create some user accounts on both chains + users = test.GetAndFundTestUsers(t, ctx, t.Name(), walletAmount, dymension) + + // Wait a few blocks for relayer to start and for user accounts to be created + err = testutil.WaitForBlocks(ctx, 5, dymension, rollapp1) + require.NoError(t, err) + + sequencer1 := users[0] + + command := []string{"dymd", "tx", "sequencer", "create-sequencer", string(pub1), rollapp1.Config().ChainID, rollapp1.GetSequencerKeyDir() + "/metadata_sequencer.json", "1000000000adym", + "--broadcast-mode", "async"} + + _, err = dymension.Validators[0].ExecTx(ctx, sequencer1.KeyName(), command...) + require.NoError(t, err) + + res, err := dymension.QueryShowSequencerByRollapp(ctx, rollapp1.Config().ChainID) + require.NoError(t, err) + require.Equal(t, len(res.Sequencers), 2, "should have 2 sequences") + + afterBlock, err := rollapp1.Height(ctx) + require.NoError(t, err) + require.True(t, afterBlock > lastBlock) + + // Compose an IBC transfer and send from rollapp -> Hub + _, err = rollapp1.SendIBCTransfer(ctx, channel.ChannelID, rollappUserAddr, transferData, ibc.TransferOptions{}) + require.NoError(t, err) + + err = testutil.WaitForBlocks(ctx, 10, dymension, rollapp1) + require.NoError(t, err) + + // Check IBC after switch + rollappHeight, err = rollapp1.GetNode().Height(ctx) + require.NoError(t, err) + + // Assert balance was updated on the hub + testutil.AssertBalance(t, ctx, rollapp1, rollappUserAddr, rollapp1.Config().Denom, walletAmount.Sub(transferData.Amount)) + + // wait until the packet is finalized + isFinalized, err = dymension.WaitUntilRollappHeightIsFinalized(ctx, rollapp1.GetChainID(), rollappHeight, 300) + require.NoError(t, err) + require.True(t, isFinalized) + + _, err = dymension.GetNode().FinalizePacketsUntilHeight(ctx, dymensionUserAddr, rollapp1.GetChainID(), fmt.Sprint(rollappHeight)) + require.NoError(t, err) + + // Get the IBC denom for urax on Hub + rollappTokenDenom = transfertypes.GetPrefixedDenom(channel.Counterparty.PortID, channel.Counterparty.ChannelID, rollapp1.Config().Denom) + rollappIBCDenom = transfertypes.ParseDenomTrace(rollappTokenDenom).IBCDenom() + + testutil.AssertBalance(t, ctx, dymension, dymensionUserAddr, rollappIBCDenom, transferAmount.Sub(bridgingFee)) + + // Get original account balances + dymensionOrigBal, err = dymension.GetBalance(ctx, dymensionUserAddr, dymension.Config().Denom) + require.NoError(t, err) + + // Compose an IBC transfer and send from dymension -> rollapp + transferData = ibc.WalletData{ + Address: rollappUserAddr, + Denom: dymension.Config().Denom, + Amount: transferAmount, + } + + // Compose an IBC transfer and send from Hub -> rollapp + _, err = dymension.SendIBCTransfer(ctx, channel.ChannelID, dymensionUserAddr, transferData, ibc.TransferOptions{}) + require.NoError(t, err) + + // Assert balance was updated on the hub + testutil.AssertBalance(t, ctx, dymension, dymensionUserAddr, dymension.Config().Denom, dymensionOrigBal.Sub(transferData.Amount)) + + err = testutil.WaitForBlocks(ctx, 10, dymension, rollapp1) + require.NoError(t, err) + + // Get the IBC denom + dymensionTokenDenom = transfertypes.GetPrefixedDenom(channel.Counterparty.PortID, channel.Counterparty.ChannelID, dymension.Config().Denom) + dymensionIBCDenom = transfertypes.ParseDenomTrace(dymensionTokenDenom).IBCDenom() + + testutil.AssertBalance(t, ctx, dymension, dymensionUserAddr, dymension.Config().Denom, dymensionOrigBal.Sub(transferData.Amount)) + erc20MAcc, err = rollapp1.Validators[0].QueryModuleAccount(ctx, "erc20") + require.NoError(t, err) + erc20MAccAddr = erc20MAcc.Account.BaseAccount.Address + testutil.AssertBalance(t, ctx, rollapp1, erc20MAccAddr, dymensionIBCDenom, transferData.Amount) +} + +func Test_SeqRotation_NoSeq_P2P_EVM(t *testing.T) { + if testing.Short() { + t.Skip() + } + + ctx := context.Background() + + // setup config for rollapp 1 + dymintTomlOverrides := make(testutil.Toml) + dymintTomlOverrides["settlement_layer"] = "dymension" + dymintTomlOverrides["settlement_node_address"] = fmt.Sprintf("http://dymension_100-1-val-0-%s:26657", t.Name()) + dymintTomlOverrides["rollapp_id"] = "rollappevm_1234-1" + dymintTomlOverrides["settlement_gas_prices"] = "0adym" + dymintTomlOverrides["max_idle_time"] = "3s" + dymintTomlOverrides["max_proof_time"] = "500ms" + dymintTomlOverrides["batch_submit_time"] = "50s" + dymintTomlOverrides["p2p_blocksync_enabled"] = "true" + + configFileOverrides := make(map[string]any) + configFileOverrides["config/dymint.toml"] = dymintTomlOverrides + + modifyHubGenesisKV := append( + dymensionGenesisKV, + cosmos.GenesisKV{ + Key: "app_state.sequencer.params.unbonding_time", + Value: "300s", + }, + cosmos.GenesisKV{ + Key: "app_state.staking.params.unbonding_time", + Value: "300s", + }, + ) + + modifyRAGenesisKV := append( + rollappEVMGenesisKV, + cosmos.GenesisKV{ + Key: "app_state.sequencers.params.unbonding_time", + Value: "300s", + }, + cosmos.GenesisKV{ + Key: "app_state.staking.params.unbonding_time", + Value: "300s", + }, + ) + + // Create chain factory with dymension + numHubVals := 1 + numHubFullNodes := 1 + numRollAppVals := 1 + numRollAppFn := 1 + + cf := test.NewBuiltinChainFactory(zaptest.NewLogger(t), []*test.ChainSpec{ + { + Name: "rollapp1", + ChainConfig: ibc.ChainConfig{ + Type: "rollapp-dym", + Name: "rollapp-temp", + ChainID: "rollappevm_1234-1", + Images: []ibc.DockerImage{rollappEVMImage}, + Bin: "rollappd", + Bech32Prefix: "ethm", + Denom: "urax", + CoinType: "60", + GasPrices: "0.0urax", + GasAdjustment: 1.1, + TrustingPeriod: "112h", + EncodingConfig: encodingConfig(), + NoHostMount: false, + ModifyGenesis: modifyRollappEVMGenesis(modifyRAGenesisKV), + ConfigFileOverrides: configFileOverrides, + }, + NumValidators: &numRollAppVals, + NumFullNodes: &numRollAppFn, + }, + { + Name: "dymension-hub", + ChainConfig: ibc.ChainConfig{ + Type: "hub-dym", + Name: "dymension", + ChainID: "dymension_100-1", + Images: []ibc.DockerImage{dymensionImage}, + Bin: "dymd", + Bech32Prefix: "dym", + Denom: "adym", + CoinType: "60", + GasPrices: "0.0adym", + EncodingConfig: encodingConfig(), + GasAdjustment: 1.1, + TrustingPeriod: "112h", + NoHostMount: false, + ModifyGenesis: modifyDymensionGenesis(modifyHubGenesisKV), + ConfigFileOverrides: nil, + }, + NumValidators: &numHubVals, + NumFullNodes: &numHubFullNodes, + }, + }) + + // Get chains from the chain factory + chains, err := cf.Chains(t.Name()) + require.NoError(t, err) + + rollapp1 := chains[0].(*dym_rollapp.DymRollApp) + dymension := chains[1].(*dym_hub.DymHub) + + // Relayer Factory + client, network := test.DockerSetup(t) + + // relayer for rollapp 1 + r := test.NewBuiltinRelayerFactory(ibc.CosmosRly, zaptest.NewLogger(t), + relayer.CustomDockerImage(RelayerMainRepo, relayerVersion, "100:1000"), relayer.ImagePull(pullRelayerImage), + ).Build(t, client, "relayer", network) + + ic := test.NewSetup(). + AddRollUp(dymension, rollapp1). + AddRelayer(r, "relayer"). + AddLink(test.InterchainLink{ + Chain1: dymension, + Chain2: rollapp1, + Relayer: r, + Path: ibcPath, + }) + + rep := testreporter.NewNopReporter() + eRep := rep.RelayerExecReporter(t) + + err = ic.Build(ctx, eRep, test.InterchainBuildOptions{ + TestName: t.Name(), + Client: client, + NetworkID: network, + SkipPathCreation: true, + }, nil, "", nil, true, 195) + require.NoError(t, err) + + containerID := fmt.Sprintf("ra-rollappevm_1234-1-val-0-%s", t.Name()) + + // Get the container details + containerJSON, err := client.ContainerInspect(context.Background(), containerID) + require.NoError(t, err) + + // Extract the IP address from the network settings + // If the container is using a custom network, the IP might be under a specific network name + var ipAddress string + for _, network := range containerJSON.NetworkSettings.Networks { + ipAddress = network.IPAddress + break // Assuming we only need the IP from the first network + } + + nodeId, err := rollapp1.Validators[0].GetNodeId(ctx) + require.NoError(t, err) + nodeId = strings.TrimRight(nodeId, "\n") + p2p_bootstrap_node := fmt.Sprintf("/ip4/%s/tcp/26656/p2p/%s", ipAddress, nodeId) + + rollapp1HomeDir := strings.Split(rollapp1.HomeDir(), "/") + rollapp1FolderName := rollapp1HomeDir[len(rollapp1HomeDir)-1] + + file, err := os.Open(fmt.Sprintf("/tmp/%s/config/dymint.toml", rollapp1FolderName)) + require.NoError(t, err) + defer file.Close() + + lines := []string{} + scanner := bufio.NewScanner(file) + for scanner.Scan() { + lines = append(lines, scanner.Text()) + } + + for i, line := range lines { + if strings.HasPrefix(line, "p2p_bootstrap_nodes =") { + lines[i] = fmt.Sprintf("p2p_bootstrap_nodes = \"%s\"", p2p_bootstrap_node) + } + } + + output := strings.Join(lines, "\n") + file, err = os.Create(fmt.Sprintf("/tmp/%s/config/dymint.toml", rollapp1FolderName)) + require.NoError(t, err) + defer file.Close() + + _, err = file.Write([]byte(output)) + require.NoError(t, err) + + // Start full node + err = rollapp1.FullNodes[0].StopContainer(ctx) + require.NoError(t, err) + + err = rollapp1.FullNodes[0].StartContainer(ctx) + require.NoError(t, err) + + addrDym, _ := r.GetWallet(dymension.GetChainID()) + err = dymension.GetNode().SendFunds(ctx, "faucet", ibc.WalletData{ + Address: addrDym.FormattedAddress(), + Amount: math.NewInt(10_000_000_000_000), + Denom: dymension.Config().Denom, + }) + require.NoError(t, err) + + addrRA, _ := r.GetWallet(rollapp1.GetChainID()) + err = rollapp1.GetNode().SendFunds(ctx, "faucet", ibc.WalletData{ + Address: addrRA.FormattedAddress(), + Amount: math.NewInt(10_000_000_000_000), + Denom: rollapp1.Config().Denom, + }) + require.NoError(t, err) + + // Check IBC Transfer before switch + CreateChannel(ctx, t, r, eRep, dymension.CosmosChain, rollapp1.CosmosChain, ibcPath) + + // Create some user accounts on both chains + users := test.GetAndFundTestUsers(t, ctx, t.Name(), walletAmount, dymension, rollapp1) + + // Get our Bech32 encoded user addresses + dymensionUser, rollappUser := users[0], users[1] + + dymensionUserAddr := dymensionUser.FormattedAddress() + rollappUserAddr := rollappUser.FormattedAddress() + + channel, err := ibc.GetTransferChannel(ctx, r, eRep, dymension.Config().ChainID, rollapp1.Config().ChainID) + require.NoError(t, err) + + err = r.StartRelayer(ctx, eRep, ibcPath) + require.NoError(t, err) + + err = testutil.WaitForBlocks(ctx, 10, dymension, rollapp1) + require.NoError(t, err) + + // Send a normal ibc tx from RA -> Hub + transferData := ibc.WalletData{ + Address: dymensionUserAddr, + Denom: rollapp1.Config().Denom, + Amount: transferAmount, + } + + // Compose an IBC transfer and send from rollapp -> Hub + _, err = rollapp1.SendIBCTransfer(ctx, channel.ChannelID, rollappUserAddr, transferData, ibc.TransferOptions{}) + require.NoError(t, err) + + err = testutil.WaitForBlocks(ctx, 10, dymension, rollapp1) + require.NoError(t, err) + + rollappHeight, err := rollapp1.GetNode().Height(ctx) + require.NoError(t, err) + + // Assert balance was updated on the hub + testutil.AssertBalance(t, ctx, rollapp1, rollappUserAddr, rollapp1.Config().Denom, walletAmount.Sub(transferData.Amount)) + + // wait until the packet is finalized + isFinalized, err := dymension.WaitUntilRollappHeightIsFinalized(ctx, rollapp1.GetChainID(), rollappHeight, 300) + require.NoError(t, err) + require.True(t, isFinalized) + + _, err = dymension.GetNode().FinalizePacketsUntilHeight(ctx, dymensionUserAddr, rollapp1.GetChainID(), fmt.Sprint(rollappHeight)) + require.NoError(t, err) + + err = testutil.WaitForBlocks(ctx, 10, dymension, rollapp1) + require.NoError(t, err) + + // Get the IBC denom for urax on Hub + rollappTokenDenom := transfertypes.GetPrefixedDenom(channel.Counterparty.PortID, channel.Counterparty.ChannelID, rollapp1.Config().Denom) + rollappIBCDenom := transfertypes.ParseDenomTrace(rollappTokenDenom).IBCDenom() + + testutil.AssertBalance(t, ctx, dymension, dymensionUserAddr, rollappIBCDenom, transferAmount.Sub(bridgingFee)) + + // Get original account balances + dymensionOrigBal, err := dymension.GetBalance(ctx, dymensionUserAddr, dymension.Config().Denom) + require.NoError(t, err) + + // Compose an IBC transfer and send from dymension -> rollapp + transferData = ibc.WalletData{ + Address: rollappUserAddr, + Denom: dymension.Config().Denom, + Amount: transferAmount, + } + + // Compose an IBC transfer and send from Hub -> rollapp + _, err = dymension.SendIBCTransfer(ctx, channel.ChannelID, dymensionUserAddr, transferData, ibc.TransferOptions{}) + require.NoError(t, err) + + // Assert balance was updated on the hub + testutil.AssertBalance(t, ctx, dymension, dymensionUserAddr, dymension.Config().Denom, dymensionOrigBal.Sub(transferData.Amount)) + + err = testutil.WaitForBlocks(ctx, 10, dymension, rollapp1) + require.NoError(t, err) + + // Get the IBC denom + dymensionTokenDenom := transfertypes.GetPrefixedDenom(channel.Counterparty.PortID, channel.Counterparty.ChannelID, dymension.Config().Denom) + dymensionIBCDenom := transfertypes.ParseDenomTrace(dymensionTokenDenom).IBCDenom() + + testutil.AssertBalance(t, ctx, dymension, dymensionUserAddr, dymension.Config().Denom, dymensionOrigBal.Sub(transferData.Amount)) + erc20MAcc, err := rollapp1.Validators[0].QueryModuleAccount(ctx, "erc20") + require.NoError(t, err) + erc20MAccAddr := erc20MAcc.Account.BaseAccount.Address + testutil.AssertBalance(t, ctx, rollapp1, erc20MAccAddr, dymensionIBCDenom, transferData.Amount) + + // Unbond sequencer1 + err = dymension.Unbond(ctx, "sequencer", rollapp1.GetSequencerKeyDir()) + require.NoError(t, err) + + seqAddr, err := dymension.AccountKeyBech32WithKeyDir(ctx, "sequencer", rollapp1.GetSequencerKeyDir()) + require.NoError(t, err) + + queryGetSequencerResponse, err := dymension.QueryShowSequencer(ctx, seqAddr) + require.NoError(t, err) + require.Equal(t, "OPERATING_STATUS_BONDED", queryGetSequencerResponse.Sequencer.Status) + + err = testutil.WaitForBlocks(ctx, 10, dymension, rollapp1) + require.NoError(t, err) + + lastBlock, err := rollapp1.Height(ctx) + require.NoError(t, err) + + time.Sleep(180 * time.Second) + + queryGetSequencerResponse, err = dymension.QueryShowSequencer(ctx, seqAddr) + require.NoError(t, err) + require.Equal(t, "OPERATING_STATUS_UNBONDING", queryGetSequencerResponse.Sequencer.Status) + + // Chain halted + err = testutil.WaitForBlocks(ctx, 5, dymension, rollapp1) + require.Error(t, err) + + time.Sleep(300 * time.Second) + + queryGetSequencerResponse, err = dymension.QueryShowSequencer(ctx, seqAddr) + require.NoError(t, err) + require.Equal(t, "OPERATING_STATUS_UNBONDED", queryGetSequencerResponse.Sequencer.Status) + + cmd := append([]string{rollapp1.FullNodes[0].Chain.Config().Bin}, "dymint", "show-sequencer", "--home", rollapp1.FullNodes[0].HomeDir()) + pub1, _, err := rollapp1.GetNode().Exec(ctx, cmd, nil) + require.NoError(t, err) + + err = dymension.GetNode().CreateKeyWithKeyDir(ctx, "sequencer", rollapp1.GetNode().HomeDir()) + require.NoError(t, err) + + sequencer, err := dymension.AccountKeyBech32WithKeyDir(ctx, "sequencer", rollapp1.GetNode().HomeDir()) + require.NoError(t, err) + + fund := ibc.WalletData{ + Address: sequencer, + Denom: dymension.Config().Denom, + Amount: math.NewInt(10_000_000_000_000).MulRaw(100_000_000), + } + err = dymension.SendFunds(ctx, "faucet", fund) + require.NoError(t, err) + + // Wait a few blocks for relayer to start and for user accounts to be created + err = testutil.WaitForBlocks(ctx, 5, dymension) + require.NoError(t, err) + + command := []string{"sequencer", "create-sequencer", string(pub1), rollapp1.Config().ChainID, "1000000000adym", rollapp1.GetSequencerKeyDir() + "/metadata_sequencer1.json", + "--broadcast-mode", "async", "--keyring-dir", rollapp1.GetNode().HomeDir() + "/sequencer_keys"} + + _, err = dymension.FullNodes[0].ExecTx(ctx, "sequencer", command...) + require.NoError(t, err) + + res, err := dymension.QueryShowSequencerByRollapp(ctx, rollapp1.Config().ChainID) + require.NoError(t, err) + require.Equal(t, len(res.Sequencers), 2, "should have 2 sequences") + + err = rollapp1.StopAllNodes(ctx) + require.NoError(t, err) + + _ = rollapp1.StartAllNodes(ctx) + + time.Sleep(30 * time.Second) + + afterBlock, err := rollapp1.Height(ctx) + require.NoError(t, err) + require.True(t, afterBlock > lastBlock) + + // Compose an IBC transfer and send from rollapp -> Hub + _, err = rollapp1.SendIBCTransfer(ctx, channel.ChannelID, rollappUserAddr, transferData, ibc.TransferOptions{}) + require.NoError(t, err) + + err = testutil.WaitForBlocks(ctx, 10, dymension, rollapp1) + require.NoError(t, err) + + // Check IBC after switch + rollappHeight, err = rollapp1.GetNode().Height(ctx) + require.NoError(t, err) + + // Assert balance was updated on the hub + testutil.AssertBalance(t, ctx, rollapp1, rollappUserAddr, rollapp1.Config().Denom, walletAmount.Sub(transferData.Amount)) + + // wait until the packet is finalized + isFinalized, err = dymension.WaitUntilRollappHeightIsFinalized(ctx, rollapp1.GetChainID(), rollappHeight, 300) + require.NoError(t, err) + require.True(t, isFinalized) + + _, err = dymension.GetNode().FinalizePacketsUntilHeight(ctx, dymensionUserAddr, rollapp1.GetChainID(), fmt.Sprint(rollappHeight)) + require.NoError(t, err) + + err = testutil.WaitForBlocks(ctx, 10, dymension, rollapp1) + require.NoError(t, err) + + // Get the IBC denom for urax on Hub + rollappTokenDenom = transfertypes.GetPrefixedDenom(channel.Counterparty.PortID, channel.Counterparty.ChannelID, rollapp1.Config().Denom) + rollappIBCDenom = transfertypes.ParseDenomTrace(rollappTokenDenom).IBCDenom() + + testutil.AssertBalance(t, ctx, dymension, dymensionUserAddr, rollappIBCDenom, transferAmount.Sub(bridgingFee)) + + // Get original account balances + dymensionOrigBal, err = dymension.GetBalance(ctx, dymensionUserAddr, dymension.Config().Denom) + require.NoError(t, err) + + // Compose an IBC transfer and send from dymension -> rollapp + transferData = ibc.WalletData{ + Address: rollappUserAddr, + Denom: dymension.Config().Denom, + Amount: transferAmount, + } + + // Compose an IBC transfer and send from Hub -> rollapp + _, err = dymension.SendIBCTransfer(ctx, channel.ChannelID, dymensionUserAddr, transferData, ibc.TransferOptions{}) + require.NoError(t, err) + + // Assert balance was updated on the hub + testutil.AssertBalance(t, ctx, dymension, dymensionUserAddr, dymension.Config().Denom, dymensionOrigBal.Sub(transferData.Amount)) + + err = testutil.WaitForBlocks(ctx, 10, dymension, rollapp1) + require.NoError(t, err) + + // Get the IBC denom + dymensionTokenDenom = transfertypes.GetPrefixedDenom(channel.Counterparty.PortID, channel.Counterparty.ChannelID, dymension.Config().Denom) + dymensionIBCDenom = transfertypes.ParseDenomTrace(dymensionTokenDenom).IBCDenom() + + testutil.AssertBalance(t, ctx, dymension, dymensionUserAddr, dymension.Config().Denom, dymensionOrigBal.Sub(transferData.Amount)) + erc20MAcc, err = rollapp1.Validators[0].QueryModuleAccount(ctx, "erc20") + require.NoError(t, err) + erc20MAccAddr = erc20MAcc.Account.BaseAccount.Address + testutil.AssertBalance(t, ctx, rollapp1, erc20MAccAddr, dymensionIBCDenom, transferData.Amount) +} + +func Test_SqcRotation_OneSqc_Success_EVM(t *testing.T) { + if testing.Short() { + t.Skip() + } + + ctx := context.Background() + + // setup config for rollapp 1 + dymintTomlOverrides := make(testutil.Toml) + dymintTomlOverrides["settlement_layer"] = "dymension" + dymintTomlOverrides["settlement_node_address"] = fmt.Sprintf("http://dymension_100-1-val-0-%s:26657", t.Name()) + dymintTomlOverrides["rollapp_id"] = "rollappevm_1234-1" + dymintTomlOverrides["settlement_gas_prices"] = "0adym" + dymintTomlOverrides["max_idle_time"] = "3s" + dymintTomlOverrides["max_proof_time"] = "500ms" + dymintTomlOverrides["batch_submit_time"] = "50s" + dymintTomlOverrides["p2p_blocksync_enabled"] = "true" + + configFileOverrides := make(map[string]any) + configFileOverrides["config/dymint.toml"] = dymintTomlOverrides + + modifyHubGenesisKV := append( + dymensionGenesisKV, + cosmos.GenesisKV{ + Key: "app_state.sequencer.params.unbonding_time", + Value: "300s", + }, + cosmos.GenesisKV{ + Key: "app_state.staking.params.unbonding_time", + Value: "300s", + }, + ) + + modifyRAGenesisKV := append( + rollappEVMGenesisKV, + cosmos.GenesisKV{ + Key: "app_state.sequencers.params.unbonding_time", + Value: "300s", + }, + cosmos.GenesisKV{ + Key: "app_state.staking.params.unbonding_time", + Value: "300s", + }, + ) + + // Create chain factory with dymension + numHubVals := 1 + numHubFullNodes := 1 + numRollAppVals := 1 + numRollAppFn := 1 + + cf := test.NewBuiltinChainFactory(zaptest.NewLogger(t), []*test.ChainSpec{ + { + Name: "rollapp1", + ChainConfig: ibc.ChainConfig{ + Type: "rollapp-dym", + Name: "rollapp-temp", + ChainID: "rollappevm_1234-1", + Images: []ibc.DockerImage{rollappEVMImage}, + Bin: "rollappd", + Bech32Prefix: "ethm", + Denom: "urax", + CoinType: "60", + GasPrices: "0.0urax", + GasAdjustment: 1.1, + TrustingPeriod: "112h", + EncodingConfig: encodingConfig(), + NoHostMount: false, + ModifyGenesis: modifyRollappEVMGenesis(modifyRAGenesisKV), + ConfigFileOverrides: configFileOverrides, + }, + NumValidators: &numRollAppVals, + NumFullNodes: &numRollAppFn, + }, + { + Name: "dymension-hub", + ChainConfig: ibc.ChainConfig{ + Type: "hub-dym", + Name: "dymension", + ChainID: "dymension_100-1", + Images: []ibc.DockerImage{dymensionImage}, + Bin: "dymd", + Bech32Prefix: "dym", + Denom: "adym", + CoinType: "60", + GasPrices: "0.0adym", + EncodingConfig: encodingConfig(), + GasAdjustment: 1.1, + TrustingPeriod: "112h", + NoHostMount: false, + ModifyGenesis: modifyDymensionGenesis(modifyHubGenesisKV), + ConfigFileOverrides: nil, + }, + NumValidators: &numHubVals, + NumFullNodes: &numHubFullNodes, + }, + }) + + // Get chains from the chain factory + chains, err := cf.Chains(t.Name()) + require.NoError(t, err) + + rollapp1 := chains[0].(*dym_rollapp.DymRollApp) + dymension := chains[1].(*dym_hub.DymHub) + + // Relayer Factory + client, network := test.DockerSetup(t) + + // relayer for rollapp 1 + r := test.NewBuiltinRelayerFactory(ibc.CosmosRly, zaptest.NewLogger(t), + relayer.CustomDockerImage(RelayerMainRepo, relayerVersion, "100:1000"), relayer.ImagePull(pullRelayerImage), + ).Build(t, client, "relayer", network) + + ic := test.NewSetup(). + AddRollUp(dymension, rollapp1). + AddRelayer(r, "relayer"). + AddLink(test.InterchainLink{ + Chain1: dymension, + Chain2: rollapp1, + Relayer: r, + Path: ibcPath, + }) + + rep := testreporter.NewNopReporter() + eRep := rep.RelayerExecReporter(t) + + err = ic.Build(ctx, eRep, test.InterchainBuildOptions{ + TestName: t.Name(), + Client: client, + NetworkID: network, + SkipPathCreation: true, + }, nil, "", nil, true, 195) + require.NoError(t, err) + + containerID := fmt.Sprintf("ra-rollappevm_1234-1-val-0-%s", t.Name()) + + // Get the container details + containerJSON, err := client.ContainerInspect(context.Background(), containerID) + require.NoError(t, err) + + // Extract the IP address from the network settings + // If the container is using a custom network, the IP might be under a specific network name + var ipAddress string + for _, network := range containerJSON.NetworkSettings.Networks { + ipAddress = network.IPAddress + break // Assuming we only need the IP from the first network + } + + nodeId, err := rollapp1.Validators[0].GetNodeId(ctx) + require.NoError(t, err) + nodeId = strings.TrimRight(nodeId, "\n") + p2p_bootstrap_node := fmt.Sprintf("/ip4/%s/tcp/26656/p2p/%s", ipAddress, nodeId) + + rollapp1HomeDir := strings.Split(rollapp1.HomeDir(), "/") + rollapp1FolderName := rollapp1HomeDir[len(rollapp1HomeDir)-1] + + file, err := os.Open(fmt.Sprintf("/tmp/%s/config/dymint.toml", rollapp1FolderName)) + require.NoError(t, err) + defer file.Close() + + lines := []string{} + scanner := bufio.NewScanner(file) + for scanner.Scan() { + lines = append(lines, scanner.Text()) + } + + for i, line := range lines { + if strings.HasPrefix(line, "p2p_bootstrap_nodes =") { + lines[i] = fmt.Sprintf("p2p_bootstrap_nodes = \"%s\"", p2p_bootstrap_node) + } + } + + output := strings.Join(lines, "\n") + file, err = os.Create(fmt.Sprintf("/tmp/%s/config/dymint.toml", rollapp1FolderName)) + require.NoError(t, err) + defer file.Close() + + _, err = file.Write([]byte(output)) + require.NoError(t, err) + + // Start full node + err = rollapp1.FullNodes[0].StopContainer(ctx) + require.NoError(t, err) + + err = rollapp1.FullNodes[0].StartContainer(ctx) + require.NoError(t, err) + + addrDym, _ := r.GetWallet(dymension.GetChainID()) + err = dymension.GetNode().SendFunds(ctx, "faucet", ibc.WalletData{ + Address: addrDym.FormattedAddress(), + Amount: math.NewInt(10_000_000_000_000), + Denom: dymension.Config().Denom, + }) + require.NoError(t, err) + + addrRA, _ := r.GetWallet(rollapp1.GetChainID()) + err = rollapp1.GetNode().SendFunds(ctx, "faucet", ibc.WalletData{ + Address: addrRA.FormattedAddress(), + Amount: math.NewInt(10_000_000_000_000), + Denom: rollapp1.Config().Denom, + }) + require.NoError(t, err) + + // Check IBC Transfer before switch + CreateChannel(ctx, t, r, eRep, dymension.CosmosChain, rollapp1.CosmosChain, ibcPath) + + // Create some user accounts on both chains + // users := test.GetAndFundTestUsers(t, ctx, t.Name(), walletAmount, dymension, rollapp1) + + cmd := append([]string{rollapp1.FullNodes[0].Chain.Config().Bin}, "dymint", "show-sequencer", "--home", rollapp1.FullNodes[0].HomeDir()) + pub1, _, err := rollapp1.GetNode().Exec(ctx, cmd, nil) + require.NoError(t, err) + + err = dymension.GetNode().CreateKeyWithKeyDir(ctx, "sequencer", rollapp1.GetNode().HomeDir()) + require.NoError(t, err) + + sequencer, err := dymension.AccountKeyBech32WithKeyDir(ctx, "sequencer", rollapp1.GetNode().HomeDir()) + require.NoError(t, err) + + fund := ibc.WalletData{ + Address: sequencer, + Denom: dymension.Config().Denom, + Amount: math.NewInt(10_000_000_000_000).MulRaw(100_000_000), + } + err = dymension.SendFunds(ctx, "faucet", fund) + require.NoError(t, err) + + // Wait a few blocks for relayer to start and for user accounts to be created + err = testutil.WaitForBlocks(ctx, 5, dymension) + require.NoError(t, err) + + command := []string{"sequencer", "create-sequencer", string(pub1), rollapp1.Config().ChainID, "1000000000adym", rollapp1.GetSequencerKeyDir() + "/metadata_sequencer1.json", + "--broadcast-mode", "async", "--keyring-dir", rollapp1.GetNode().HomeDir() + "/sequencer_keys"} + + _, err = dymension.FullNodes[0].ExecTx(ctx, "sequencer", command...) + require.NoError(t, err) + + res, err := dymension.QueryShowSequencerByRollapp(ctx, rollapp1.Config().ChainID) + require.NoError(t, err) + require.Equal(t, len(res.Sequencers), 2, "should have 2 sequences") + + // Get our Bech32 encoded user addresses + // dymensionUser, rollappUser := users[0], users[1] + + // dymensionUserAddr := dymensionUser.FormattedAddress() + // rollappUserAddr := rollappUser.FormattedAddress() + + // channel, err := ibc.GetTransferChannel(ctx, r, eRep, dymension.Config().ChainID, rollapp1.Config().ChainID) + // require.NoError(t, err) + + err = r.StartRelayer(ctx, eRep, ibcPath) + require.NoError(t, err) + + err = testutil.WaitForBlocks(ctx, 10, dymension, rollapp1) + require.NoError(t, err) + + // // Send a normal ibc tx from RA -> Hub + // transferData := ibc.WalletData{ + // Address: dymensionUserAddr, + // Denom: rollapp1.Config().Denom, + // Amount: transferAmount, + // } + + // // Compose an IBC transfer and send from rollapp -> Hub + // _, err = rollapp1.SendIBCTransfer(ctx, channel.ChannelID, rollappUserAddr, transferData, ibc.TransferOptions{}) + // require.NoError(t, err) + + // rollappHeight, err := rollapp1.GetNode().Height(ctx) + // require.NoError(t, err) + + // // Assert balance was updated on the hub + // testutil.AssertBalance(t, ctx, rollapp1, rollappUserAddr, rollapp1.Config().Denom, walletAmount.Sub(transferData.Amount)) + + // // wait until the packet is finalized + // isFinalized, err := dymension.WaitUntilRollappHeightIsFinalized(ctx, rollapp1.GetChainID(), rollappHeight, 300) + // require.NoError(t, err) + // require.True(t, isFinalized) + + // // Get the IBC denom for urax on Hub + // rollappTokenDenom := transfertypes.GetPrefixedDenom(channel.Counterparty.PortID, channel.Counterparty.ChannelID, rollapp1.Config().Denom) + // rollappIBCDenom := transfertypes.ParseDenomTrace(rollappTokenDenom).IBCDenom() + + // testutil.AssertBalance(t, ctx, dymension, dymensionUserAddr, rollappIBCDenom, transferAmount.Sub(bridgingFee)) + + // // Get original account balances + // dymensionOrigBal, err := dymension.GetBalance(ctx, dymensionUserAddr, dymension.Config().Denom) + // require.NoError(t, err) + + // // Compose an IBC transfer and send from dymension -> rollapp + // transferData = ibc.WalletData{ + // Address: rollappUserAddr, + // Denom: dymension.Config().Denom, + // Amount: transferAmount, + // } + + // // Compose an IBC transfer and send from Hub -> rollapp + // _, err = dymension.SendIBCTransfer(ctx, channel.ChannelID, dymensionUserAddr, transferData, ibc.TransferOptions{}) + // require.NoError(t, err) + + // // Assert balance was updated on the hub + // testutil.AssertBalance(t, ctx, dymension, dymensionUserAddr, dymension.Config().Denom, dymensionOrigBal.Sub(transferData.Amount)) + + // err = testutil.WaitForBlocks(ctx, 10, dymension, rollapp1) + // require.NoError(t, err) + + // // Get the IBC denom + // dymensionTokenDenom := transfertypes.GetPrefixedDenom(channel.Counterparty.PortID, channel.Counterparty.ChannelID, dymension.Config().Denom) + // dymensionIBCDenom := transfertypes.ParseDenomTrace(dymensionTokenDenom).IBCDenom() + + // testutil.AssertBalance(t, ctx, dymension, dymensionUserAddr, dymension.Config().Denom, dymensionOrigBal.Sub(transferData.Amount)) + // erc20MAcc, err := rollapp1.Validators[0].QueryModuleAccount(ctx, "erc20") + // require.NoError(t, err) + // erc20MAccAddr := erc20MAcc.Account.BaseAccount.Address + // testutil.AssertBalance(t, ctx, rollapp1, erc20MAccAddr, dymensionIBCDenom, transferData.Amount) + + // Unbond sequencer1 + err = dymension.Unbond(ctx, "sequencer", rollapp1.GetSequencerKeyDir()) + require.NoError(t, err) + + seqAddr, err := dymension.AccountKeyBech32WithKeyDir(ctx, "sequencer", rollapp1.GetSequencerKeyDir()) + require.NoError(t, err) + + queryGetSequencerResponse, err := dymension.QueryShowSequencer(ctx, seqAddr) + require.NoError(t, err) + require.Equal(t, "OPERATING_STATUS_BONDED", queryGetSequencerResponse.Sequencer.Status) + + err = testutil.WaitForBlocks(ctx, 10, dymension, rollapp1) + require.NoError(t, err) + + lastBlock, err := rollapp1.Height(ctx) + require.NoError(t, err) + + time.Sleep(180 * time.Second) + + queryGetSequencerResponse, err = dymension.QueryShowSequencer(ctx, seqAddr) + require.NoError(t, err) + require.Equal(t, "OPERATING_STATUS_UNBONDING", queryGetSequencerResponse.Sequencer.Status) + + // Chain halted + err = testutil.WaitForBlocks(ctx, 5, dymension, rollapp1) + require.Error(t, err) + + time.Sleep(300 * time.Second) + + queryGetSequencerResponse, err = dymension.QueryShowSequencer(ctx, seqAddr) + require.NoError(t, err) + require.Equal(t, "OPERATING_STATUS_UNBONDED", queryGetSequencerResponse.Sequencer.Status) + + err = rollapp1.StopAllNodes(ctx) + require.NoError(t, err) + + _ = rollapp1.StartAllNodes(ctx) + + time.Sleep(30 * time.Second) + + afterBlock, err := rollapp1.Height(ctx) + require.NoError(t, err) + require.True(t, afterBlock > lastBlock) + + // // Compose an IBC transfer and send from rollapp -> Hub + // _, err = rollapp1.SendIBCTransfer(ctx, channel.ChannelID, rollappUserAddr, transferData, ibc.TransferOptions{}) + // require.NoError(t, err) + + // // Check IBC after switch + // rollappHeight, err = rollapp1.GetNode().Height(ctx) + // require.NoError(t, err) + + // // Assert balance was updated on the hub + // testutil.AssertBalance(t, ctx, rollapp1, rollappUserAddr, rollapp1.Config().Denom, walletAmount.Sub(transferData.Amount)) + + // // wait until the packet is finalized + // isFinalized, err = dymension.WaitUntilRollappHeightIsFinalized(ctx, rollapp1.GetChainID(), rollappHeight, 300) + // require.NoError(t, err) + // require.True(t, isFinalized) + + // // Get the IBC denom for urax on Hub + // rollappTokenDenom = transfertypes.GetPrefixedDenom(channel.Counterparty.PortID, channel.Counterparty.ChannelID, rollapp1.Config().Denom) + // rollappIBCDenom = transfertypes.ParseDenomTrace(rollappTokenDenom).IBCDenom() + + // testutil.AssertBalance(t, ctx, dymension, dymensionUserAddr, rollappIBCDenom, transferAmount.Sub(bridgingFee)) + + // // Get original account balances + // dymensionOrigBal, err = dymension.GetBalance(ctx, dymensionUserAddr, dymension.Config().Denom) + // require.NoError(t, err) + + // // Compose an IBC transfer and send from dymension -> rollapp + // transferData = ibc.WalletData{ + // Address: rollappUserAddr, + // Denom: dymension.Config().Denom, + // Amount: transferAmount, + // } + + // // Compose an IBC transfer and send from Hub -> rollapp + // _, err = dymension.SendIBCTransfer(ctx, channel.ChannelID, dymensionUserAddr, transferData, ibc.TransferOptions{}) + // require.NoError(t, err) + + // // Assert balance was updated on the hub + // testutil.AssertBalance(t, ctx, dymension, dymensionUserAddr, dymension.Config().Denom, dymensionOrigBal.Sub(transferData.Amount)) + + // err = testutil.WaitForBlocks(ctx, 10, dymension, rollapp1) + // require.NoError(t, err) + + // // Get the IBC denom + // dymensionTokenDenom = transfertypes.GetPrefixedDenom(channel.Counterparty.PortID, channel.Counterparty.ChannelID, dymension.Config().Denom) + // dymensionIBCDenom = transfertypes.ParseDenomTrace(dymensionTokenDenom).IBCDenom() + + // testutil.AssertBalance(t, ctx, dymension, dymensionUserAddr, dymension.Config().Denom, dymensionOrigBal.Sub(transferData.Amount)) + // erc20MAcc, err = rollapp1.Validators[0].QueryModuleAccount(ctx, "erc20") + // require.NoError(t, err) + // erc20MAccAddr = erc20MAcc.Account.BaseAccount.Address + // testutil.AssertBalance(t, ctx, rollapp1, erc20MAccAddr, dymensionIBCDenom, transferData.Amount) +} + func Test_SeqRotation_MulSeq_EVM(t *testing.T) { if testing.Short() { t.Skip() @@ -98,7 +1244,7 @@ func Test_SeqRotation_MulSeq_EVM(t *testing.T) { Client: client, NetworkID: network, SkipPathCreation: true, - }, nil, "", nil) + }, nil, "", nil, true, 195) require.Error(t, err) // create 3 sequencers @@ -129,13 +1275,13 @@ func Test_SeqRotation_MulSeq_EVM(t *testing.T) { marketMakerAddr := marketMaker.FormattedAddress() rollappUserAddr := rollappUser.FormattedAddress() - command := []string{"dymd", "tx", "sequencer", "create-sequencer", string(pub1), rollapp1.Config().ChainID, rollapp1.GetSequencerKeyDir()+"/metadata_sequencer.json", "1000000000adym", + command := []string{"dymd", "tx", "sequencer", "create-sequencer", string(pub1), rollapp1.Config().ChainID, rollapp1.GetSequencerKeyDir() + "/metadata_sequencer.json", "1000000000adym", "--broadcast-mode", "async"} _, err = dymension.Validators[1].ExecTx(ctx, sequencer1.KeyName(), command...) require.NoError(t, err) - command = []string{"dymd", "tx", "sequencer", "create-sequencer", string(pub2), rollapp1.Config().ChainID, rollapp1.GetSequencerKeyDir()+"/metadata_sequencer.json", "1100000000adym", + command = []string{"dymd", "tx", "sequencer", "create-sequencer", string(pub2), rollapp1.Config().ChainID, rollapp1.GetSequencerKeyDir() + "/metadata_sequencer.json", "1100000000adym", "--broadcast-mode", "async"} _, err = dymension.Validators[2].ExecTx(ctx, sequencer2.KeyName(), command...) diff --git a/tests/sequencer_test.go b/tests/sequencer_test.go index 6e2d922f..c9d52e81 100644 --- a/tests/sequencer_test.go +++ b/tests/sequencer_test.go @@ -16,6 +16,7 @@ import ( "github.com/docker/docker/api/types/strslice" test "github.com/decentrio/rollup-e2e-testing" + "github.com/decentrio/rollup-e2e-testing/cosmos" "github.com/decentrio/rollup-e2e-testing/cosmos/hub/celes_hub" "github.com/decentrio/rollup-e2e-testing/cosmos/hub/dym_hub" "github.com/decentrio/rollup-e2e-testing/cosmos/rollapp/dym_rollapp" @@ -41,7 +42,8 @@ func TestSequencerCelestia_EVM(t *testing.T) { dymintTomlOverrides["settlement_gas_prices"] = "0adym" dymintTomlOverrides["max_idle_time"] = "3s" dymintTomlOverrides["max_proof_time"] = "500ms" - dymintTomlOverrides["batch_submit_max_time"] = "80s" + dymintTomlOverrides["batch_submit_time"] = "50s" + dymintTomlOverrides["p2p_blocksync_enabled"] = "false" configFileOverrides1 := make(map[string]any) configTomlOverrides1 := make(testutil.Toml) @@ -59,14 +61,22 @@ func TestSequencerCelestia_EVM(t *testing.T) { numRollAppVals := 1 nodeStore := "/home/celestia/light" p2pNetwork := "mocha-4" - coreIp := "celestia-testnet-consensus.itrocket.net" + coreIp := "mocha-4-consensus.mesa.newmetric.xyz" // trustedHash := "\"017428B113893E854767E626BC9CF860BDF49C2AC2DF56F3C1B6582B2597AC6E\"" // sampleFrom := 2423882 + modifyEVMGenesisKV := append( + rollappEVMGenesisKV, + cosmos.GenesisKV{ + Key: "app_state.rollappparams.params.da", + Value: "celestia", + }, + ) + url := "https://api-mocha.celenium.io/v1/block/count" headerKey := "User-Agent" headerValue := "Apidog/1.0.0 (https://apidog.com)" - rpcEndpoint := "http://celestia-testnet-consensus.itrocket.net:26657" + rpcEndpoint := "http://rpc-mocha.pops.one:26657" cf := test.NewBuiltinChainFactory(zaptest.NewLogger(t), []*test.ChainSpec{ { @@ -119,14 +129,16 @@ func TestSequencerCelestia_EVM(t *testing.T) { // This can be used to write to the block database which will index all block data e.g. txs, msgs, events, etc. // BlockDatabaseFile: test.DefaultBlockDatabaseFilepath(), - }, nil, "", nil) + }, nil, "", nil, false, 780) require.NoError(t, err) validator, err := celestia.GetNode().AccountKeyBech32(ctx, "validator") require.NoError(t, err) // Get fund for submit blob GetFaucet("http://18.184.170.181:3000/api/get-tia", validator) + err = testutil.WaitForBlocks(ctx, 8, celestia) + require.NoError(t, err) err = celestia.GetNode().InitCelestiaDaLightNode(ctx, nodeStore, p2pNetwork, nil) require.NoError(t, err) @@ -178,7 +190,7 @@ func TestSequencerCelestia_EVM(t *testing.T) { // Create an exec instance execConfig := types.ExecConfig{ - Cmd: strslice.StrSlice([]string{"celestia", "light", "start", "--node.store", nodeStore, "--gateway", "--core.ip", coreIp, "--p2p.network", p2pNetwork, "--keyring.accname", "validator"}), // Replace with your command and arguments + Cmd: strslice.StrSlice([]string{"celestia", "light", "start", "--node.store", nodeStore, "--gateway", "--core.ip", coreIp, "--p2p.network", p2pNetwork, "--keyring.keyname", "validator"}), // Replace with your command and arguments } execIDResp, err := client.ContainerExecCreate(ctx, containerID, execConfig) @@ -212,7 +224,6 @@ func TestSequencerCelestia_EVM(t *testing.T) { da_config := fmt.Sprintf("{\"base_url\": \"http://test-val-0-%s:26658\", \"timeout\": 60000000000, \"gas_prices\":1.0, \"gas_adjustment\": 1.3, \"namespace_id\": \"%s\", \"auth_token\":\"%s\"}", t.Name(), celestia_namespace_id, celestia_token) configFileOverrides := make(map[string]any) - dymintTomlOverrides["da_layer"] = "celestia" dymintTomlOverrides["namespace_id"] = celestia_namespace_id dymintTomlOverrides["da_config"] = da_config configFileOverrides["config/dymint.toml"] = dymintTomlOverrides @@ -234,7 +245,7 @@ func TestSequencerCelestia_EVM(t *testing.T) { TrustingPeriod: "112h", EncodingConfig: encodingConfig(), NoHostMount: false, - ModifyGenesis: modifyRollappEVMGenesis(rollappEVMGenesisKV), + ModifyGenesis: modifyRollappEVMGenesis(modifyEVMGenesisKV), ConfigFileOverrides: configFileOverrides, }, NumValidators: &numRollAppVals, @@ -266,7 +277,7 @@ func TestSequencerCelestia_EVM(t *testing.T) { // This can be used to write to the block database which will index all block data e.g. txs, msgs, events, etc. // BlockDatabaseFile: test.DefaultBlockDatabaseFilepath(), - }, nil, "", nil) + }, nil, "", nil, false, 780) require.NoError(t, err) celestia.StopAllNodes(ctx) @@ -318,7 +329,8 @@ func TestSequencerHubDisconnection_EVM(t *testing.T) { dymintTomlOverrides["settlement_gas_prices"] = "0adym" dymintTomlOverrides["max_idle_time"] = "3s" dymintTomlOverrides["max_proof_time"] = "500ms" - dymintTomlOverrides["batch_submit_max_time"] = "30s" + dymintTomlOverrides["batch_submit_time"] = "50s" + dymintTomlOverrides["p2p_blocksync_enabled"] = "false" configFileOverrides1 := make(map[string]any) configTomlOverrides1 := make(testutil.Toml) @@ -329,6 +341,14 @@ func TestSequencerHubDisconnection_EVM(t *testing.T) { configFileOverrides1["config/config.toml"] = configTomlOverrides1 + modifyEVMGenesisKV := append( + rollappEVMGenesisKV, + cosmos.GenesisKV{ + Key: "app_state.rollappparams.params.da", + Value: "celestia", + }, + ) + // Create chain factory with dymension numHubVals := 1 numHubFullNodes := 1 @@ -336,14 +356,14 @@ func TestSequencerHubDisconnection_EVM(t *testing.T) { numRollAppVals := 1 nodeStore := "/home/celestia/light" p2pNetwork := "mocha-4" - coreIp := "celestia-testnet-consensus.itrocket.net" + coreIp := "mocha-4-consensus.mesa.newmetric.xyz" // trustedHash := "\"017428B113893E854767E626BC9CF860BDF49C2AC2DF56F3C1B6582B2597AC6E\"" // sampleFrom := 2423882 url := "https://api-mocha.celenium.io/v1/block/count" headerKey := "User-Agent" headerValue := "Apidog/1.0.0 (https://apidog.com)" - rpcEndpoint := "http://celestia-testnet-consensus.itrocket.net:26657" + rpcEndpoint := "http://rpc-mocha.pops.one:26657" cf := test.NewBuiltinChainFactory(zaptest.NewLogger(t), []*test.ChainSpec{ { @@ -396,7 +416,7 @@ func TestSequencerHubDisconnection_EVM(t *testing.T) { // This can be used to write to the block database which will index all block data e.g. txs, msgs, events, etc. // BlockDatabaseFile: test.DefaultBlockDatabaseFilepath(), - }, nil, "", nil) + }, nil, "", nil, false, 780) require.NoError(t, err) validator, err := celestia.GetNode().AccountKeyBech32(ctx, "validator") @@ -456,7 +476,7 @@ func TestSequencerHubDisconnection_EVM(t *testing.T) { // Create an exec instance execConfig := types.ExecConfig{ - Cmd: strslice.StrSlice([]string{"celestia", "light", "start", "--node.store", nodeStore, "--gateway", "--core.ip", coreIp, "--p2p.network", p2pNetwork, "--keyring.accname", "validator"}), // Replace with your command and arguments + Cmd: strslice.StrSlice([]string{"celestia", "light", "start", "--node.store", nodeStore, "--gateway", "--core.ip", coreIp, "--p2p.network", p2pNetwork, "--keyring.keyname", "validator"}), // Replace with your command and arguments } execIDResp, err := client.ContainerExecCreate(ctx, containerID, execConfig) @@ -490,7 +510,6 @@ func TestSequencerHubDisconnection_EVM(t *testing.T) { da_config := fmt.Sprintf("{\"base_url\": \"http://test-val-0-%s:26658\", \"timeout\": 60000000000, \"gas_prices\":1.0, \"gas_adjustment\": 1.3, \"namespace_id\": \"%s\", \"auth_token\":\"%s\"}", t.Name(), celestia_namespace_id, celestia_token) configFileOverrides := make(map[string]any) - dymintTomlOverrides["da_layer"] = "celestia" dymintTomlOverrides["namespace_id"] = celestia_namespace_id dymintTomlOverrides["da_config"] = da_config configFileOverrides["config/dymint.toml"] = dymintTomlOverrides @@ -512,7 +531,7 @@ func TestSequencerHubDisconnection_EVM(t *testing.T) { TrustingPeriod: "112h", EncodingConfig: encodingConfig(), NoHostMount: false, - ModifyGenesis: modifyRollappEVMGenesis(rollappEVMGenesisKV), + ModifyGenesis: modifyRollappEVMGenesis(modifyEVMGenesisKV), ConfigFileOverrides: configFileOverrides, }, NumValidators: &numRollAppVals, @@ -555,7 +574,7 @@ func TestSequencerHubDisconnection_EVM(t *testing.T) { // This can be used to write to the block database which will index all block data e.g. txs, msgs, events, etc. // BlockDatabaseFile: test.DefaultBlockDatabaseFilepath(), - }, nil, "", nil) + }, nil, "", nil, false, 780) require.NoError(t, err) rollappHeight, err := rollapp1.GetNode().Height(ctx) diff --git a/tests/setup.go b/tests/setup.go index d9449723..57b40ded 100644 --- a/tests/setup.go +++ b/tests/setup.go @@ -8,6 +8,7 @@ import ( "io" "net/http" "os" + "strconv" "testing" "time" @@ -16,7 +17,10 @@ import ( "cosmossdk.io/math" util "github.com/cosmos/cosmos-sdk/types/module/testutil" + "github.com/decentrio/rollup-e2e-testing/blockdb" "github.com/decentrio/rollup-e2e-testing/cosmos" + "github.com/decentrio/rollup-e2e-testing/cosmos/hub/dym_hub" + dymensiontesting "github.com/decentrio/rollup-e2e-testing/dymension" "github.com/decentrio/rollup-e2e-testing/ibc" "github.com/decentrio/rollup-e2e-testing/testreporter" "github.com/decentrio/rollup-e2e-testing/testutil" @@ -80,9 +84,13 @@ type ForwardMetadata struct { } const ( - ibcPath = "dymension-demo" - anotherIbcPath = "dymension-demo2" - BLOCK_FINALITY_PERIOD = 30 + ibcPath = "dymension-demo" + anotherIbcPath = "dymension-demo2" + BLOCK_FINALITY_PERIOD = 50 + EventDemandOrderCreated = "dymensionxyz.dymension.eibc.EventDemandOrderCreated" + EventDemandOrderFulfilled = "dymensionxyz.dymension.eibc.EventDemandOrderFulfilled" + EventDemandOrderFeeUpdated = "dymensionxyz.dymension.eibc.EventDemandOrderFeeUpdated" + EventDemandOrderPacketStatusUpdated = "dymensionxyz.dymension.eibc.EventDemandOrderPacketStatusUpdated" ) var ( @@ -182,11 +190,26 @@ var ( GasAdjustment: 2, TrustingPeriod: "112h", NoHostMount: false, - ModifyGenesis: nil, + ModifyGenesis: cosmos.ModifyGenesis(gaiaGenesisKV), ConfigFileOverrides: nil, } + gaiaGenesisKV = []cosmos.GenesisKV{ + { + Key: "app_state.staking.params.unbonding_time", + Value: "1200s", + }, + } + rollappEVMGenesisKV = []cosmos.GenesisKV{ + { + Key: "app_state.sequencers.params.unbonding_time", + Value: "1200s", + }, + { + Key: "app_state.staking.params.unbonding_time", + Value: "1200s", + }, { Key: "app_state.mint.params.mint_denom", Value: "urax", @@ -255,6 +278,14 @@ var ( } rollappWasmGenesisKV = []cosmos.GenesisKV{ + { + Key: "app_state.sequencers.params.unbonding_time", + Value: "1200s", + }, + { + Key: "app_state.staking.params.unbonding_time", + Value: "1200s", + }, // Bank denom metadata { Key: "app_state.bank.denom_metadata", @@ -283,6 +314,22 @@ var ( } dymensionGenesisKV = []cosmos.GenesisKV{ + { + Key: "app_state.sequencer.params.notice_period", + Value: "180s", + }, + { + Key: "app_state.rollapp.params.dispute_period_in_blocks", + Value: fmt.Sprint(BLOCK_FINALITY_PERIOD), + }, + { + Key: "app_state.sequencer.params.unbonding_time", + Value: "1200s", + }, + { + Key: "app_state.staking.params.unbonding_time", + Value: "1200s", + }, // gov params { Key: "app_state.gov.params.voting_period", @@ -611,7 +658,7 @@ type rollappParam struct { // require.Equal(t, string(deployerWhitelistParams), newParams.Value) // } -func overridesDymintToml(settlemenLayer, nodeAddress, rollappId, gasPrices, maxIdleTime, maxProofTime, batchSubmitMaxTime string, optionalConfigs ...bool) map[string]any { +func overridesDymintToml(settlemenLayer, nodeAddress, rollappId, gasPrices, maxIdleTime, maxProofTime, batch_submit_time string, optionalConfigs ...bool) map[string]any { configFileOverrides := make(map[string]any) dymintTomlOverrides := make(testutil.Toml) @@ -624,7 +671,6 @@ func overridesDymintToml(settlemenLayer, nodeAddress, rollappId, gasPrices, maxI } if includeDaGrpcLayer { - dymintTomlOverrides["da_layer"] = "grpc" dymintTomlOverrides["da_config"] = "{\"host\":\"host.docker.internal\",\"port\": 7980}" } @@ -634,7 +680,8 @@ func overridesDymintToml(settlemenLayer, nodeAddress, rollappId, gasPrices, maxI dymintTomlOverrides["settlement_gas_prices"] = gasPrices dymintTomlOverrides["max_idle_time"] = maxIdleTime dymintTomlOverrides["max_proof_time"] = maxProofTime - dymintTomlOverrides["batch_submit_max_time"] = batchSubmitMaxTime + dymintTomlOverrides["p2p_blocksync_enabled"] = "false" + dymintTomlOverrides["batch_submit_time"] = batch_submit_time configFileOverrides["config/dymint.toml"] = dymintTomlOverrides @@ -648,13 +695,13 @@ func CreateChannel(ctx context.Context, t *testing.T, r ibc.Relayer, eRep *testr err = r.CreateClients(ctx, eRep, ibcPath, ibc.DefaultClientOpts()) require.NoError(t, err) - err = testutil.WaitForBlocks(ctx, 20, chainA, chainB) + err = testutil.WaitForBlocks(ctx, 5, chainA, chainB) require.NoError(t, err) err = r.CreateConnections(ctx, eRep, ibcPath) require.NoError(t, err) - err = testutil.WaitForBlocks(ctx, 10, chainA, chainB) + err = testutil.WaitForBlocks(ctx, 5, chainA, chainB) require.NoError(t, err) err = r.CreateChannel(ctx, eRep, ibcPath, ibc.DefaultChannelOpts()) @@ -829,3 +876,161 @@ func GetLatestBlockHeight(url, headerKey, headerValue string) (string, error) { } return string(body), nil } + +func getEibcEventFromTx(t *testing.T, dymension *dym_hub.DymHub, txhash string) *dymensiontesting.EibcEvent { + txResp, err := dymension.GetTransaction(txhash) + if err != nil { + require.NoError(t, err) + return nil + } + + events := txResp.Events + + var ( + id, _ = cosmos.AttributeValue(events, EventDemandOrderFulfilled, "order_id") + price, _ = cosmos.AttributeValue(events, EventDemandOrderFulfilled, "price") + fee, _ = cosmos.AttributeValue(events, EventDemandOrderFulfilled, "fee") + isFulfilled, _ = cosmos.AttributeValue(events, EventDemandOrderFulfilled, "is_fulfilled") + packetStatus, _ = cosmos.AttributeValue(events, EventDemandOrderFulfilled, "packet_status") + ) + + eibcEvent := new(dymensiontesting.EibcEvent) + eibcEvent.OrderId = id + eibcEvent.Price = price + eibcEvent.Fee = fee + eibcEvent.IsFulfilled, err = strconv.ParseBool(isFulfilled) + if err != nil { + require.NoError(t, err) + return nil + } + eibcEvent.PacketStatus = packetStatus + + return eibcEvent +} + +func getEIbcEventsWithinBlockRange( + ctx context.Context, + dymension *dym_hub.DymHub, + blockRange int64, + breakOnFirstOccurence bool, +) ([]dymensiontesting.EibcEvent, error) { + var eibcEventsArray []dymensiontesting.EibcEvent + + height, err := dymension.Height(ctx) + if err != nil { + return nil, fmt.Errorf("failed to get Dymension height: %w", err) + } + fmt.Printf("Dymension height: %d\n", height) + + eibcEvents, err := getEibcEventsOfType(dymension.CosmosChain, height-10, height+blockRange, breakOnFirstOccurence) + if err != nil { + return nil, fmt.Errorf("error getting events of type 'eibc': %w", err) + } + + if len(eibcEvents) == 0 { + return nil, fmt.Errorf("There wasn't a single 'eibc' event registered within the specified block range on the hub") + } + + for _, event := range eibcEvents { + eibcEvent, err := dymensiontesting.MapToEibcEvent(event) + if err != nil { + println("go to here man") + return nil, fmt.Errorf("error mapping to EibcEvent: %w", err) + } + eibcEventsArray = append(eibcEventsArray, eibcEvent) + } + + return eibcEventsArray, nil +} + +func areSlicesEqual(slice1, slice2 []blockdb.EventAttribute) bool { + if len(slice1) != len(slice2) { + return false + } + + for i := range slice1 { + if slice1[i] != slice2[i] { + return false + } + } + + return true +} + +func contains(slice []blockdb.Event, item blockdb.Event) bool { + for _, v := range slice { + if areSlicesEqual(v.Attributes, item.Attributes) { + return true + } + } + return false +} + +func getEibcEventsOfType(chain *cosmos.CosmosChain, startHeight int64, endHeight int64, breakOnFirstOccurence bool) ([]blockdb.Event, error) { + var eventTypeArray []blockdb.Event + shouldReturn := false + + for height := startHeight; height <= endHeight && !shouldReturn; height++ { + err := testutil.WaitForBlocks(context.Background(), 1, chain) + if err != nil { + return nil, fmt.Errorf("error waiting for blocks: %w", err) + } + + txs, err := chain.FindTxs(context.Background(), height) + if err != nil { + return nil, fmt.Errorf("error fetching transactions at height %d: %w", height, err) + } + + for _, tx := range txs { + for _, event := range tx.Events { + if event.Type == EventDemandOrderCreated { + if !contains(eventTypeArray, event) { + eventTypeArray = append(eventTypeArray, event) + } + if breakOnFirstOccurence { + shouldReturn = true + fmt.Printf("%s event found on block height: %d", event.Type, height) + break + } + } + } + if shouldReturn { + break + } + } + } + + return eventTypeArray, nil +} + +func BuildEIbcMemo(eibcFee math.Int) string { + return fmt.Sprintf(`{"eibc": {"fee": "%s"}}`, eibcFee.String()) +} +func CheckInvariant(t *testing.T, ctx context.Context, dymension *dym_hub.DymHub, keyName string) { + _, err := dymension.GetNode().CrisisInvariant(ctx, keyName, "eibc", "demand-order-count") + require.NoError(t, err) + + _, err = dymension.GetNode().CrisisInvariant(ctx, keyName, "eibc", "underlying-packet-exist") + require.NoError(t, err) + + _, err = dymension.GetNode().CrisisInvariant(ctx, keyName, "rollapp", "rollapp-state-index") + require.NoError(t, err) + + _, err = dymension.GetNode().CrisisInvariant(ctx, keyName, "rollapp", "rollapp-count") + require.NoError(t, err) + + _, err = dymension.GetNode().CrisisInvariant(ctx, keyName, "rollapp", "block-height-to-finalization-queue") + require.NoError(t, err) + + _, err = dymension.GetNode().CrisisInvariant(ctx, keyName, "rollapp", "rollapp-by-eip155-key") + require.NoError(t, err) + + _, err = dymension.GetNode().CrisisInvariant(ctx, keyName, "rollapp", "rollapp-finalized-state") + require.NoError(t, err) + + _, err = dymension.GetNode().CrisisInvariant(ctx, keyName, "sequencer", "sequencers-count") + require.NoError(t, err) + + _, err = dymension.GetNode().CrisisInvariant(ctx, keyName, "sequencer", "sequencers-per-rollapp") + require.NoError(t, err) +} diff --git a/tests/tx_batch_finalization_test.go b/tests/tx_batch_finalization_test.go index 35273e6d..5e9e8744 100644 --- a/tests/tx_batch_finalization_test.go +++ b/tests/tx_batch_finalization_test.go @@ -7,7 +7,6 @@ import ( "time" test "github.com/decentrio/rollup-e2e-testing" - "github.com/decentrio/rollup-e2e-testing/cosmos" "github.com/decentrio/rollup-e2e-testing/cosmos/hub/dym_hub" "github.com/decentrio/rollup-e2e-testing/cosmos/rollapp/dym_rollapp" dymensiontypes "github.com/decentrio/rollup-e2e-testing/dymension" @@ -42,15 +41,8 @@ func TestBatchFinalization_EVM(t *testing.T) { dymintTomlOverrides["settlement_gas_prices"] = "0adym" dymintTomlOverrides["max_idle_time"] = "3s" dymintTomlOverrides["max_proof_time"] = "500ms" - dymintTomlOverrides["batch_submit_max_time"] = "100s" - - modifyGenesisKV := append( - dymensionGenesisKV, - cosmos.GenesisKV{ - Key: "app_state.rollapp.params.dispute_period_in_blocks", - Value: fmt.Sprint(BLOCK_FINALITY_PERIOD), - }, - ) + dymintTomlOverrides["batch_submit_time"] = "50s" + dymintTomlOverrides["p2p_blocksync_enabled"] = "false" configFileOverrides["config/dymint.toml"] = dymintTomlOverrides // Create chain factory with dymension @@ -97,7 +89,7 @@ func TestBatchFinalization_EVM(t *testing.T) { GasAdjustment: 1.1, TrustingPeriod: "112h", NoHostMount: false, - ModifyGenesis: modifyDymensionGenesis(modifyGenesisKV), + ModifyGenesis: modifyDymensionGenesis(dymensionGenesisKV), ConfigFileOverrides: nil, }, NumValidators: &numHubVals, @@ -129,7 +121,7 @@ func TestBatchFinalization_EVM(t *testing.T) { // This can be used to write to the block database which will index all block data e.g. txs, msgs, events, etc. // BlockDatabaseFile: test.DefaultBlockDatabaseFilepath(), - }, nil, "", nil) + }, nil, "", nil, false, 780) require.NoError(t, err) // Create some user accounts on both chains @@ -180,15 +172,8 @@ func TestBatchFinalization_Wasm(t *testing.T) { dymintTomlOverrides["settlement_gas_prices"] = "0adym" dymintTomlOverrides["max_idle_time"] = "3s" dymintTomlOverrides["max_proof_time"] = "500ms" - dymintTomlOverrides["batch_submit_max_time"] = "100s" - - modifyGenesisKV := append( - dymensionGenesisKV, - cosmos.GenesisKV{ - Key: "app_state.rollapp.params.dispute_period_in_blocks", - Value: fmt.Sprint(BLOCK_FINALITY_PERIOD), - }, - ) + dymintTomlOverrides["batch_submit_time"] = "50s" + dymintTomlOverrides["p2p_blocksync_enabled"] = "false" configFileOverrides["config/dymint.toml"] = dymintTomlOverrides // Create chain factory with dymension @@ -235,7 +220,7 @@ func TestBatchFinalization_Wasm(t *testing.T) { GasAdjustment: 1.1, TrustingPeriod: "112h", NoHostMount: false, - ModifyGenesis: modifyDymensionGenesis(modifyGenesisKV), + ModifyGenesis: modifyDymensionGenesis(dymensionGenesisKV), ConfigFileOverrides: nil, }, NumValidators: &numHubVals, @@ -267,7 +252,7 @@ func TestBatchFinalization_Wasm(t *testing.T) { // This can be used to write to the block database which will index all block data e.g. txs, msgs, events, etc. // BlockDatabaseFile: test.DefaultBlockDatabaseFilepath(), - }, nil, "", nil) + }, nil, "", nil, false, 780) require.NoError(t, err) // Create some user accounts on both chains @@ -301,6 +286,9 @@ func TestBatchFinalization_Wasm(t *testing.T) { require.True(t, (currentFinalizedRollappDymHeight > BLOCK_FINALITY_PERIOD) && (lastFinalizedRollappHeight > rollappHeight), fmt.Sprintf("Mismatch in batch finalization check. Current finalization hub height: %d. Dispute period: %d. Last finalized rollapp height: %d. Rollapp height asserted: %d", currentFinalizedRollappDymHeight, BLOCK_FINALITY_PERIOD, lastFinalizedRollappHeight, rollappHeight)) + + // Run invariant check + CheckInvariant(t, ctx, dymension, dymensionUser.KeyName()) } func IsAnyRollappStateFinalized(ctx context.Context, dymension *dym_hub.DymHub, rollappChainID string, timeoutSecs int) (bool, error) { diff --git a/tests/upgrade_hub_test.go b/tests/upgrade_hub_test.go index 7b0554dd..34d2cb32 100644 --- a/tests/upgrade_hub_test.go +++ b/tests/upgrade_hub_test.go @@ -49,14 +49,14 @@ func TestHubUpgrade(t *testing.T) { gas_price_rollapp1 := "0adym" maxIdleTime1 := "10s" maxProofTime := "500ms" - configFileOverrides1 := overridesDymintToml(settlement_layer_rollapp1, settlement_node_address, rollapp1_id, gas_price_rollapp1, maxIdleTime1, maxProofTime, "100s") + configFileOverrides1 := overridesDymintToml(settlement_layer_rollapp1, settlement_node_address, rollapp1_id, gas_price_rollapp1, maxIdleTime1, maxProofTime, "50s") // setup config for rollapp 2 settlement_layer_rollapp2 := "dymension" rollapp2_id := "decentrio_12345-1" gas_price_rollapp2 := "0adym" maxIdleTime2 := "1s" - configFileOverrides2 := overridesDymintToml(settlement_layer_rollapp2, settlement_node_address, rollapp2_id, gas_price_rollapp2, maxIdleTime2, maxProofTime, "100s") + configFileOverrides2 := overridesDymintToml(settlement_layer_rollapp2, settlement_node_address, rollapp2_id, gas_price_rollapp2, maxIdleTime2, maxProofTime, "50s") // Create chain factory with dymension numHubVals := 1 numHubFullNodes := 0 @@ -179,7 +179,7 @@ func TestHubUpgrade(t *testing.T) { // This can be used to write to the block database which will index all block data e.g. txs, msgs, events, etc. // BlockDatabaseFile: test.DefaultBlockDatabaseFilepath(), - }, nil, "", nil) + }, nil, "", nil, false, 780) require.NoError(t, err) // err = dymension.StopAllNodes(ctx) @@ -357,6 +357,9 @@ func TestHubUpgrade(t *testing.T) { require.NoError(t, err) require.True(t, isFinalized) + err = testutil.WaitForBlocks(ctx, 10, dymension, rollapp1) + require.NoError(t, err) + // Get the IBC denom dymensionTokenDenom1 := transfertypes.GetPrefixedDenom(channDymRollApp1.PortID, channDymRollApp1.ChannelID, dymension.Config().Denom) dymensionIBCDenom1 := transfertypes.ParseDenomTrace(dymensionTokenDenom1).IBCDenom() @@ -386,6 +389,10 @@ func TestHubUpgrade(t *testing.T) { } _, err = rollapp1.SendIBCTransfer(ctx, channRollApp1Dym.ChannelID, rollappUser1Addr, transferData, options) require.NoError(t, err) + + err = testutil.WaitForBlocks(ctx, 10, dymension, rollapp1) + require.NoError(t, err) + rollapp1Height, err = rollapp1.GetNode().Height(ctx) require.NoError(t, err) @@ -394,6 +401,12 @@ func TestHubUpgrade(t *testing.T) { require.NoError(t, err) require.True(t, isFinalized) + _, err = dymension.GetNode().FinalizePacketsUntilHeight(ctx, dymensionUser1Addr, rollapp1.GetChainID(), fmt.Sprint(rollapp1Height)) + require.NoError(t, err) + + err = testutil.WaitForBlocks(ctx, 10, dymension, rollapp1) + require.NoError(t, err) + expMmBalanceRollapp1Denom := transferData.Amount balance, err := dymension.GetBalance(ctx, marketMaker1Addr, rollapp1IBCDenom) require.NoError(t, err) @@ -409,6 +422,9 @@ func TestHubUpgrade(t *testing.T) { _, err = rollapp1.SendIBCTransfer(ctx, channRollApp1Dym.ChannelID, rollappUser1Addr, transferData, options) require.NoError(t, err) + err = testutil.WaitForBlocks(ctx, 10, dymension, rollapp1) + require.NoError(t, err) + rollapp1Height, err = rollapp1.GetNode().Height(ctx) require.NoError(t, err) zeroBalance := math.NewInt(0) @@ -422,7 +438,7 @@ func TestHubUpgrade(t *testing.T) { require.NoError(t, err) fmt.Println("Events:", eibcEvents) - _, err = dymension.FullfillDemandOrder(ctx, eibcEvents[len(eibcEvents)-1].ID, marketMaker1Addr, eibcFee) + _, err = dymension.FullfillDemandOrder(ctx, eibcEvents[len(eibcEvents)-1].OrderId, marketMaker1Addr, eibcFee) require.NoError(t, err) // eibcEvent := getEibcEventFromTx(t, dymension, txhash) // if eibcEvent != nil { @@ -450,6 +466,13 @@ func TestHubUpgrade(t *testing.T) { isFinalized, err = dymension.WaitUntilRollappHeightIsFinalized(ctx, rollapp1.GetChainID(), rollapp1Height, 300) require.NoError(t, err) require.True(t, isFinalized) + + _, err = dymension.GetNode().FinalizePacketsUntilHeight(ctx, dymensionUser1Addr, rollapp1.GetChainID(), fmt.Sprint(rollapp1Height)) + require.NoError(t, err) + + err = testutil.WaitForBlocks(ctx, 10, dymension, rollapp1) + require.NoError(t, err) + balance, err = dymension.GetBalance(ctx, marketMaker1Addr, rollapp1IBCDenom) require.NoError(t, err) fmt.Println("Balance of marketMaker1Addr after packet finalization:", balance) @@ -477,6 +500,9 @@ func TestHubUpgrade(t *testing.T) { require.NoError(t, err) require.True(t, isFinalized) + err = testutil.WaitForBlocks(ctx, 10, dymension, rollapp1) + require.NoError(t, err) + // Get the IBC denom dymensionTokenDenom2 := transfertypes.GetPrefixedDenom(channRollApp2Dym.PortID, channRollApp2Dym.ChannelID, dymension.Config().Denom) dymensionIBCDenom2 := transfertypes.ParseDenomTrace(dymensionTokenDenom2).IBCDenom() @@ -499,6 +525,10 @@ func TestHubUpgrade(t *testing.T) { } _, err = rollapp2.SendIBCTransfer(ctx, channRollApp2Dym.ChannelID, rollappUser2Addr, transferData, options) require.NoError(t, err) + + err = testutil.WaitForBlocks(ctx, 10, dymension, rollapp2) + require.NoError(t, err) + rollapp2Height, err = rollapp2.GetNode().Height(ctx) require.NoError(t, err) @@ -507,6 +537,12 @@ func TestHubUpgrade(t *testing.T) { require.NoError(t, err) require.True(t, isFinalized) + _, err = dymension.GetNode().FinalizePacketsUntilHeight(ctx, marketMaker2Addr, rollapp2.GetChainID(), fmt.Sprint(rollapp2Height)) + require.NoError(t, err) + + err = testutil.WaitForBlocks(ctx, 10, dymension, rollapp2) + require.NoError(t, err) + expMmBalanceRollapp2Denom := transferData.Amount balance, err = dymension.GetBalance(ctx, marketMaker2Addr, rollapp2IBCDenom) require.NoError(t, err) @@ -522,6 +558,9 @@ func TestHubUpgrade(t *testing.T) { _, err = rollapp2.SendIBCTransfer(ctx, channRollApp2Dym.ChannelID, rollappUser2Addr, transferData, options) require.NoError(t, err) + err = testutil.WaitForBlocks(ctx, 10, dymension, rollapp2) + require.NoError(t, err) + rollapp2Height, err = rollapp2.GetNode().Height(ctx) require.NoError(t, err) balance, err = dymension.GetBalance(ctx, dymensionUser2Addr, rollapp2IBCDenom) @@ -534,7 +573,7 @@ func TestHubUpgrade(t *testing.T) { require.NoError(t, err) fmt.Println("Events:", eibcEvents) - _, err = dymension.FullfillDemandOrder(ctx, eibcEvents[len(eibcEvents)-1].ID, marketMaker2Addr, eibcFee) + _, err = dymension.FullfillDemandOrder(ctx, eibcEvents[len(eibcEvents)-1].OrderId, marketMaker2Addr, eibcFee) require.NoError(t, err) // eibcEvent = getEibcEventFromTx(t, dymension, txhash) // if eibcEvent != nil { @@ -562,6 +601,13 @@ func TestHubUpgrade(t *testing.T) { isFinalized, err = dymension.WaitUntilRollappHeightIsFinalized(ctx, rollapp2.GetChainID(), rollapp2Height, 300) require.NoError(t, err) require.True(t, isFinalized) + + _, err = dymension.GetNode().FinalizePacketsUntilHeight(ctx, dymensionUser2Addr, rollapp2.GetChainID(), fmt.Sprint(rollapp2Height)) + require.NoError(t, err) + + err = testutil.WaitForBlocks(ctx, 10, dymension, rollapp2) + require.NoError(t, err) + balance, err = dymension.GetBalance(ctx, marketMaker2Addr, rollapp2IBCDenom) require.NoError(t, err) fmt.Println("Balance of marketMaker2Addr after packet finalization:", balance) @@ -588,4 +634,7 @@ func TestHubUpgrade(t *testing.T) { } }, ) + + // Run invariant check + CheckInvariant(t, ctx, dymension, dymensionUser1.KeyName()) }