diff --git a/.github/workflows/gravity.yml b/.github/workflows/gravity.yml new file mode 100644 index 00000000..0bb5b7f0 --- /dev/null +++ b/.github/workflows/gravity.yml @@ -0,0 +1,65 @@ +# This file contains tests for the Gravity bridge cosmos module, they verify that the module +# has been imported correctly and functions properly +name: Gravity tests + +on: + push: + branches: [master, main, dev] + pull_request: + branches: [master, main, dev] + +jobs: + happy-path: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - name: Run all up happy-path test + run: tests/gravity/all-up-test.sh + validator-out: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - name: Run all up test with a validator out + run: tests/gravity/all-up-test.sh VALIDATOR_OUT + valset-stress: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - name: Run all up valset stress test + run: tests/gravity/all-up-test.sh VALSET_STRESS + batch-stress: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - name: Run all up batch stress test + run: tests/gravity/all-up-test.sh BATCH_STRESS + v2-happy-path: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - name: Run all up batch stress test + run: tests/gravity/all-up-test.sh V2_HAPPY_PATH +# valset-rewards: +# runs-on: ubuntu-latest +# steps: +# - uses: actions/checkout@v2 +# - name: Run all up batch stress test +# run: tests/gravity/all-up-test.sh VALSET_REWARDS + orchestrator-keys: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - name: Run all up batch stress test + run: tests/gravity/all-up-test.sh ORCHESTRATOR_KEYS + evidence: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - name: Run all up batch stress test + run: tests/gravity/all-up-test.sh EVIDENCE + txcancel: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - name: Run all up batch stress test + run: tests/gravity/all-up-test.sh TXCANCEL diff --git a/tests/gravity/all-up-test.sh b/tests/gravity/all-up-test.sh new file mode 100755 index 00000000..b2e91593 --- /dev/null +++ b/tests/gravity/all-up-test.sh @@ -0,0 +1,28 @@ +#!/bin/bash +set -eux +# the directory of this script, useful for allowing this script +# to be run with any PWD +DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" + +result=$( docker images -q onomy-base ) + +# builds the container containing various system deps +# also builds Peggy once in order to cache Go deps, this container +# must be rebuilt every time you run this test if you want a faster +# solution use start chains and then run tests +bash $DIR/build-container.sh + +# Remove existing container instance +set +e +docker rm -f onomy_all_up_test_instance +set -e + +NODES=3 +set +u +TEST_TYPE=$1 +set -u + +echo "starting test $TEST_TYPE" +# Run new test container instance +docker run --name onomy_all_up_test_instance --cap-add=NET_ADMIN -t onomy-base /bin/bash /onomy/tests/gravity/container-scripts/all-up-test-internal.sh $NODES $TEST_TYPE +echo "test $TEST_TYPE completed successfully" \ No newline at end of file diff --git a/tests/gravity/assets/ETHGenesis.json b/tests/gravity/assets/ETHGenesis.json new file mode 100644 index 00000000..5e193d0f --- /dev/null +++ b/tests/gravity/assets/ETHGenesis.json @@ -0,0 +1,21 @@ +{ + "config": { + "chainId": 15, + "homesteadBlock": 0, + "eip150Block": 0, + "eip155Block": 0, + "eip158Block": 0, + "byzantiumBlock": 0, + "constantinopleBlock": 0, + "petersburgBlock": 0, + "istanbulBlock": 0, + "berlinBlock": 0 + }, + "difficulty": "0x400", + "gasLimit": "0xB71B00", + "alloc": { + "0xBf660843528035a5A4921534E156a27e64B231fE": { + "balance": "0x1337000000000000000000" + } + } +} \ No newline at end of file diff --git a/tests/gravity/assets/eth_keys.json b/tests/gravity/assets/eth_keys.json new file mode 100644 index 00000000..6f0af1a2 --- /dev/null +++ b/tests/gravity/assets/eth_keys.json @@ -0,0 +1,201 @@ +[ + "0xac9d114a392478a299799e671d0725afa4aeddbcd1364e2a66b52e2667bbaba1", + "0xb8662f35f9de8720424e82b232e8c98d15399490adae9ca993f5ef1dc4883690", + "0x48272026a3c1ece26790da944a030fbb6efa2bd3ceb94b05db8e48e4d1b43794", + "0x178051bb81da9fc2ce0e1f0d10df45234b4035c55925335a3de7791f32bffeaf", + "0x8dac94e66d77f9fc542eb41fee9fc47eb0b5034404cba1e0c1308f4179e05b20", + "0x5baafba052252ecd89123f76047e45e3c127e387b60a1f1047694cf22f9068d8", + "0xe5c33f4c9bd354c774c67299ecfc98cd4e4832b0e3e3fd2b531b472434d0af4e", + "0xbf3b66c2cb1458e7b1b3779cd77c8d115528d49704aa70508c2520882437afd8", + "0xf693ad26a41bf18a28f0c986819283454d9fe3f8abf5789f0fba062a565029c2", + "0x53c1ddbbc8d782ff05e3b391b1f4f96d56171daf8bd34e13e4cce6375f252cf8", + "0x4a071e4681544a3348775ecd6187f8bd322f9aa25aaa232f3f6aecf32c6bc58d", + "0x3df2848e1b79a28cfc946c912adb5e415ced709b19dc56c46430c873197d9a58", + "0x03a9b94426b5fd1b2578263dc940ad595c87ee3644610de76c6063a7b268ba72", + "0x3a9228a26b3f48e68b981e95ad72924251fd4e827eea0b26c1d29f9858cf856e", + "0xbf2ec7e45309eb3a2ebe33d160c1f416eacbc58ee65e8daa1bf22e2a57e0f39d", + "0x559271679ecf423bab66505675071d887be71fd878ca35e8655a6f95584cebc1", + "0xcd2e382928b617d8bde97bc685f009dc3367651476d21c014ca31c9e6ffbed79", + "0x2ce3764ee199f6e98969c8dda22d501f5d76554456baae0610bdcebbdc8a7da7", + "0xfb699acbe41bbed570638144508889466fd1b1d2361827d908a73025e8019b93", + "0x26f48ac3b55fb632e8666d96180d71594095f1255793ccb80ddcf595869dc1e0", + "0xb3907533267decb97a1b2533e01b1245c45ff504712c0406c9e5c38a947381ec", + "0x60334afa53c280975b9998461ff03d4e5cab1ef23b2eb7163afdf4c0092efbd9", + "0xc13567364e7a63de9b57e99e6a2194e5b7deaed43c8854bf50378cdeb97cd169", + "0x5b54f5b4fbe652fea3c1c5ec9c3b99e3dd9d2aa8c373585acccab4279d6b818b", + "0x02e188852ae4e63e824bc65c5b8ab60c37dbbc8b48305e17a29b42217c725978", + "0x3d7760dd10ca6c4f869e6c75aa16d7e9e4e983e4226a5f7d9fafd542b590b472", + "0xc544548259f1fe3a8a844e03bef3e85864e8e2d48b4f7cc9160507f40a60c3b9", + "0xadc715fa584f96fa84c79ec7bd3ca5b735487da38587f7df27f64715cf10c595", + "0xed90ffe1d64ab80b09ef895a8996285c5cdff58376ca6c6453758cb68cee1877", + "0x58b1d91d1bd28fec62d030caa6425beecee2329fe9eee049aafa861291385cfd", + "0xf079426bccb09b2f4fbdf4e58658cb043748b0e7dbeb1cfebf96c33167813e1f", + "0x6bd2ad725a0f163d2f13670bb26fccae94d0b7c4144b87387a4791133eead05d", + "0xac1384b1a131c6dee55ad3a4ad6ff23870613285a1282b0020b87e902f194502", + "0x7c39cf8db868477418a65d0b9d07cc40f2b020928e09bc166c5142d3f9cdf7b9", + "0xfb6fda484f076a391676890d0c6a7f3b2f464c7b0d1d97d3af2b1ae51bf16bbf", + "0xe8b5a1978b532a9833f2a48f4c7fa70cdf9b43bbdebe084d2f8940e748bc1e47", + "0x4a73fed334232cbf67875f2d4fd01e3a9d71465d8526574b6d329df98680b820", + "0xb481336a7ab3428ed19b98b313e56047581421d9c952c85020412552cc3e8215", + "0xa387c5c77240ff583b4d9fb5f4637817c6d9bc5450ca7e413f271cff32818e13", + "0xae6f4a56e2052e1633d7deccdfaba6a8db869c0bd1feecc417d4fdd2cba799b4", + "0xc28a7219135e69fcf324413f295b9361d93f10c42cce3ed292fcf377416e75e2", + "0x34ccc9af8d8f0bca0b6da17792d02752c5030e32cbabc37be2ef1141744b8e5c", + "0x91ee72c8c44cd282cd107063085da443d7129c75d7a7a454576ea7e5b44fd769", + "0x461bd51856dae104ba6895cf5d4c7a2ae92679aee4c9b7839989a1c98d130afa", + "0x8bdab2408ab356206ffe2c3b96dcf612d9fbc7377870d84e4e856c82582ff09e", + "0x94547fb24ceeb734e50cec2355acd53ab3310677be2079a1fdb3c73d65d5b4a8", + "0x97d758b02cf8efea64acd59d8234bc46286bd51624aec41913dd7de4adb6b322", + "0x2c370460601498e586344da8b18cb48d4320023d7b63532d086ffee6460138b8", + "0x00ed37a118d61835673ba5b8f1105e04d325da91395a7f7b31d7a0a7e7672ac5", + "0xe599da64f1b5a84d81f4d16d555c3b201613eb14fed77f9fc17db52716e97eae", + "0x9044f8297afe0017d594bdbb8a7c813adc65dd31d4585d24e1ea2d71c4f3d3ff", + "0x3b53072547f8be99987fe18cd6de4a14491c93a85afa1626baca2f786fc844be", + "0x4e6d11c40ce798068ec0130de6617428155d122e557f9375aec6bc3dabd01900", + "0xa69967928551932e720c4cd4c62e8acfdd705cc931098f07e437106aae896cfc", + "0xedefdc9b4a8cb7cd0c0a3d824a6d96f9a5105fc520ff2321666c5447890f50d1", + "0xfed30998073f79c678ce8d8dcf8c6ff43cd517fdc5e8d12b9979119e95c827d7", + "0xcc298112178100fd520874febc03ba7af0c605258b0b2ccd4948c77bf605fdbe", + "0x553c1e87a23a79e936ae60c89e21e97c9e535af0bec5eab75b17dc67a2cbefc7", + "0xa892237c5d472d4d1c918c739d1df2ef8439b89e5bc19eca0d44d5b14dab2005", + "0x57b3ed99eca42f7c18132d552fbd6d7259be2b064ffb654aacbf0065c2b71399", + "0x20af9cbbde61374c4f2546618b3d4c96002833da3f43f7382aed69fa37edba6b", + "0x7af433febc0cd985a59fb940439eebc62d9275df2e0096e06f2e5e6424722afe", + "0xd315d161d49a7078d61ed1b38f96acb2005561ad08ebba5e9d2a922795bdb3f7", + "0xe39d02695a134211b9ff60846399cf1b6fce6f5492c0202c3efd49777257345b", + "0x3cf0d04509a296935a830ebebe7d85d52de6748e242d0fd8982e887d70897943", + "0x96985a3bb60909010031d76c2d43a742745481383f383d2940edf2a67f9cc483", + "0x41ddb33515bd501a35c087949971a56b6f2abaadfb7feae7792839e15f6494cb", + "0x38b36cc5c3a26277af4b6b00836cc2fb79e486ca9fbfc13eecb4fdc3170ef6e2", + "0x20186b262f114bd8e949a929626929654246708effde90977efec7de5ee83a91", + "0xac3855aa4fb365f90b1de9517578c8ebe810aa779827ec596d62391c25cab28a", + "0x25660b4b2e7ec1dda0587b5904a969e94570caaa4c8e8406d0d0f478be5ac455", + "0x687700623cf47fd798dee4616af90d21eda7a5ef9c44564cc9f635edaf4a96af", + "0xcd088f12123e19cb8f13e5031042179206987b48137bb42fbd7d97d9f3ca28ee", + "0x2ac89f94f14b9a1bbbc870f208295ebd70d7ff07377e9e0c9f47066a2efb9a9c", + "0xfb18ea4d8c3771a4173b82a07aaf1266c9f08c6f7e8bc6d1137c3f3c02e1fd1e", + "0x1f2b8fe47a08d286efdc293a5e377929db49ccf8417608ba9113a256b3863d39", + "0x002ae2f484ced6ef5cf126f1a8013ad873d02d6d2baf8f9b2e2a5b25cf5e8a61", + "0x0285822146ccc11bbcdb0ba8827273fafc6db9136b26858b478278c58ef55fd2", + "0xd3349fc6c6c10b8590825712caeeab6c77f58fb16fa5fc17e1c23ee52abba4a3", + "0x3f9ad0488bbee87bcdd7cb405fcb7e60d83b55deb577169a73a018e034efd0ae", + "0x55429911262d352bc2e59e36868b349b329a964cf9b58f8f537c210b397b406e", + "0x75906715089b05e95b2e1c294ec20fa8dedf9a907c20cd61a7db535dd969e001", + "0x8f2a1b1e6c7072c2b3b497ca4f0adc47810d1ecad7183e58bed39601c571d528", + "0x9724b63a22b6ce1389e6768957ab56ede9c2097f93912e679c0797d432fd593d", + "0xbc59791e54c309a7a5dd8e86847c7a87d2a9851a5b3b8a4cf20f1c2a0eefbca6", + "0x1716c199b8d8358d364c5e8a8e7d8322166d86e0c946e9af0b50f2c08240fc8b", + "0xaa29a62cf0df6b2dfe82c674269a917a164e7ee25644a65b1cdd1dd7f5a269ab", + "0xa7f2fa40d12e92e19de5cb2478260d7e7c00a167519619f28c2c0b07653004b2", + "0x981699769216ceed7473e7b7d7f3dcc28be0dbe68dbcb108c3d2fc22f6152169", + "0xd40c3bd1771888fc997652bbbf309f570d7c0923fe46ca01aea328ea5ae2c516", + "0x8440038b4677db1adf953e4f06c9b3716dcbca8cb2aa1ebdd38d3c12e184d2d5", + "0x676d183f77f4fe677f14d1ea090d87b5cef525844a858afb25b74c3ab6e080e6", + "0x112d751c883aa85bc915f89a35d14b1a20f63c3e04b465d54c507a6ee1889f83", + "0xbb5024688923bdaa03838a2d2723f049994801f6181e576db9e24a82f051d135", + "0x73d56607746e9506fd0e8a852cbacb8987e04de7871631d33c38e51b52ca887c", + "0xf58dae6a6cfd07f8c840475b04e59f893764a163c2c54b74db5c93c89a0f881b", + "0xf55f8af243f323aec6a5491deab0dd2a07ddda956bcb5f895a8fc6533bacf4a6", + "0x1a1e5971864e38f7847525aeae3f784de1c5392711bccbfd797f98b9537d689e", + "0xba743bc52365f790bcedfdd12dc933d585a1039a72951e870b108f81e7009fcd", + "0xe83f0b3eb4980d9e5d48680dd8443c8c3c356bf0c09013149c2638701b3dc9b9", + "0xd22e88482b310a1070cf156ade97b076767d5d3787017e1952ff2d247d756f3a", + "0x1bd93870002495736ad044a903693a265db4e3d32c5f26fc46b061cc115ab30f", + "0x0b8bacf6c39ca3c4deb095485be447856a31ea8594bff80727710592379d0e2c", + "0xfb450b4178041775efaca54a2804f59cb921ded089cf0423441e38ce9b7f1d6d", + "0xcc4438dbfdfe749c6c74bd09988696116caee400a016249319baf7f41d2ee224", + "0x663e3f6579c5fa9f45c5a6af6015e355b090678cc3714e5945ecf3f95c30fef1", + "0x79dac03248e671c00438101ac21ff047c12ff7dbcf4d4966cf513d3f5dd3fab2", + "0xc1776c66b7ac89d4000bd175f333d6943bb75b6a7ad588af0f5bfb37af461ba2", + "0xfbb98ad239be3a24e4c71bfa80095849527cdda0f9efcb59c13f8f031888de33", + "0x484a1d82cbbe899d912d3e1d5873231405b712508ed521f59a7c95c4c916008b", + "0xecb5d252318f0c01cfc09d4bc7cdb5f0fe6ca08392eab1df7830bcbfc85273a0", + "0xbec28cc5a06f8fd6e08d8447fe7f6c761a46444cfb2cbd2be0b6a6caf9f88c98", + "0x35864c27a7072e87cac587ebd3ffc36b2a92f648a116694357424003543c73ed", + "0xafec3eb1b8dd3cf16402ea7ca8fc7159f8ecf53282bfeefe52d14da42c768129", + "0x77d29e8e7f21a2a76de0c3d6f6c5e157f7a4d459e138f13021215d6119da9b7c", + "0xba2fabc438d71ef2675adaad2798f3ea0fcb9950f787c609694ce0ba78d48e77", + "0x8019b056740e7b45ecdd1377d9895c355312435000d0c9d09111062ea1c38284", + "0x979ff0e7a1eaca8ecd50cb15dc429ee0ec735f169c0bad3653c2082eb009a670", + "0x4c6fca6c1ddc8665059e45bb451f8be84fb66b95873b5a9ea1040e4088bee7d3", + "0xca8e18a524d16aeacd9b3c8acbdd302b4d2fd48854e3a31f1b6c465b33943851", + "0x78a24a701a163b2349b55adda48e27002fedabee22b32821d3f899cad52ccf96", + "0xaa3b462f1c6baf2d807ddcc3e3c349843dc95614fe016c3e4ed661f9743102b7", + "0xd4bcc17dc25802c763e53b50b2e8689024202270d17919d4ce8120fcce563527", + "0x554c646965c4055950e20dff26d8acf3a7199e0f558968efea80a6e24b30f2c4", + "0x03a62624a782069d8ff3efab123cbd9e24f411e80cb83e1c3c8b626cebf4396c", + "0x58db7df0dbfea2fb4c20c3000d853e6aa7f87473c7972a471b1331c8d8885431", + "0x17e67efe19c40d72f363d11b96655cc3fade9ceb31f0b90c1a22d30e31ccb02b", + "0x970c1300957fadf37260132188211afca87f9f25a8249041d220e30c52de31f7", + "0xacb7aaef2ae96ec0731dbe6fcfd6d4e44906ccbc844fd6719f3a0ce35e423f30", + "0x0a0e18871d7fd7d8b9d5ce27d6c739178dc893859db6b480cc7ea4d8495f406d", + "0x98af8bdab5f70d8d38c4f0c9b72f120c8cc8162062f9c9ce9138d469550b05fb", + "0xc2c9941744b53340e110ff7281600e08b53679a558986f30327c1311abb643f5", + "0x11fe14b0e30cbbd237f4cc0913c3f3b000cb7fb6088cf4df769cb5dc46590993", + "0x08e64ff6f6df16a82f7c0cc610360b522cb5e3b951bee6a73b46c99cc213416c", + "0x39f86f6ca1c7872ee692e2f3903f4ffc1258814f2fd07ccdd0128093e199d8b2", + "0xc65693734cab13b95d3d2eddf65cfd6e857f188dd3b7e553a59d2f6a948bfc2c", + "0x760869bf28ee9da7d4eb80499724dc80f3b5793c52a6ce49e0e2d7b2227f3125", + "0xfecb901ab00952fa6510559480cc4f8de9c5860ac9686be7bea3c498c0227a67", + "0xd7a08eac538b1988785dcf2cb25cc1a504def678e6347187b7a75aaf7d96c24b", + "0x3cb7cf1fca3fb31306bcda196290cc13465f0c71d63947b9dd53bc02dfeb60e7", + "0x1ec5b2618df9c964fe1a5dd9b0f5a2c0c4cd1906e0c5d2ec4e60aca215cb35fa", + "0x0fe769ea304fa44426c3279546f9731d14032843b7cfaa228cae5dfeb9c9df77", + "0xa20168393e315a8ea853bbacba79c62c830099f1a5f9ed90ce4c60cb75cf334a", + "0xaf0b5ce48250030bca8d674ff4ba1778214e5e110e9983960fa7cf69b89ba98f", + "0x9f5993af880fc6c43bb74b3728f83b5b1d5003b774254109a26d31047d9eae83", + "0x2f6fe14979fb3c401d58d6263ff112de7b1a768579ab7daca958944ab1fbf01c", + "0xb81e80263820da1ffb6b4a61e59fe3e009d0fa1ffdfa9ba116154e0d34acb4db", + "0x37a27a2397eb20aa40e9dba81a549e942199abb068b8f5fc1d4b591d85df108b", + "0x6504351746a539b8603371f5d46e5ea02593b7fd9c72ee27ea96dd99e5b57d92", + "0x230d0fe29f27f5097a11b9dec4c51a9efa83bf15045caff13a404c31620f428e", + "0x0703ca06c8b9ce2ad516409f58a016d62ced3fb97b42a7d42380fd51ff70771b", + "0x38e481951bd6fd46567d2affdbb87f621c44bfd7f3caec25fe85ea9e16a569d6", + "0xf4e1946dbbabc449a168ec6e3836078c658bd0d3af37349ad15cf530be1d25cc", + "0x5e648deda9d8b4f4d932e03c9f76eeb80cdaba39cf8d19fb8b055bfc2bc6e0e1", + "0xbb86c8d4413ca49d4af29142237ff2d03c955d6fb7018d02fa3ee1b6f1fae10c", + "0x421d9d030803d93846cccf23671abd61a8258ba71c1eb50a3683ee9c6b947583", + "0xe2fa161f46ffafd914d057e16702a9ed1742deb4a11cefe00e4cddbe134638b7", + "0x7b1f1d306c70a4b46e54b76ed5c2fb5708a2db60b5aecbff90660448ca8f6afa", + "0x03fd365ef7e412ce03cfe6312d54d4bb86cba0ffd5af0bc017e73184e68d5fff", + "0x599eede2c406a050c10d696545bdfcbe4a4101b115ff60d9f1bfca1f797ddee1", + "0xd5f595e8c0a836aa9d5a38373f09fbeb330a72fe61351dcfa8afa7aac1c80f6b", + "0xc627fd51ef25d29d838a29db8c5fd3da9becf643897b235ca722d518a0b3ebd2", + "0x4e836845962b0430920c84c0006b333d1f5e9ec4bc010febd26b0e60cc249494", + "0xae7a67e6a6a6cae62102b1811ecb8bd40b49ad8d58b26ec74ee7a7c4045ca65f", + "0xc32c0d0ba244dbc7834764422c02eaad8d2fbf5a9a1a46e25b8b4d969db3b998", + "0xb4fbb630636278942771b94ecb3ac83e67c58c5311d605e7dd30cf9a1bbc94a6", + "0x7ff8edf930b1f6be231bc28434f998a329882fcc55668e02aea069468d052bb6", + "0x201b5debf196471f17700852146fcab73b9a80d4f506245793e8257e5450a0af", + "0xf625dd0c8a65a44c0d902acbc6ee2b1e63f7586fbad798fab379eab65e19b1df", + "0xaf06aa376a45096d8cba65db4f99e33939b2eca80ce02e9e43be0a408347dc32", + "0xa68018b7615f327f54fa57e396a9f9f156779eacb005e6dfb1b446aad6716e3a", + "0x90b73ae2c16f1fd378a0943d4bdcf0eda91474e15ba4753f6d9e547e022d00bb", + "0xfedd24f8b2114e7a940e1c1a95aa577d8aa98fd14e487ca50e9b40ee826906af", + "0x619bf67a9ef7d99b4432f6d24bad598cbc7d19b38037d8ad6a9912c41769a20c", + "0xd66ecfed725d9d9d4f4b492bc7f27b638ec339fcaa3591690c0cb8dbf9ab1680", + "0xae7161d305bd2dc249957d0cce1ab4ce44a7ea0d938940f51394a77e3d776f16", + "0x449da9a34ec940bf7d7e5d4a9a67171af59e7163d4785ef034faf399ced6ca85", + "0xee9efec61748274e4ab8c7b0af175ced6cc0d8ae3152b2b1f3f2f5d570cadbef", + "0x72925394fd54e4c0cbada9359d0270fb0ed57b70c8cd9051b44a25c3dc48ea47", + "0xb04884562dacd7bd3f740b080149b54d298b2fe183320ad1965eaa283d8381f4", + "0xc38b6c1dcd14f2abc52dd5c8a7bc60362666cb0f554e433302a2854312e66044", + "0x5e826e7118d836a2ec262b2667c8683a49d33bc003fd3201bc235c93b8d41967", + "0x979ac4d6adb28f5cdd8b768dfda08767bb5e800e73597b4b96cc6c337a590ebc", + "0xe36a9652dff52ec2b4f47998c3321758988ca8b6d3b741f5f6c4f3acfbba646a", + "0x1e007f0edb46a0dcfa75357223851705858d310f33e4cbc48bd8091a4142141f", + "0xcfda52d158e317aaaafaa09f62fd4fe4d350bb76db1953a0d665e26e05e1eb9f", + "0xeaf565ed89369e04c8b0be5474fd7ae25bee7dff72b75708a1baeb398c8fc07e", + "0x9fadf4b52b09d8a5f00b8915b8e3928f2fe56962833e9452d3d4f1a02da3d522", + "0xf9ba6945bd37e4d9a44aaa0893a46645202e41c2e327c4a8548f091b557ff620", + "0x5083c3fba7fb4ccd9aea61b494cb3ef0912fb9af8b4258888352f16ceb4a1846", + "0x7e6bec2457f690a463395b8e5fc0824fccb33ee92dbd7a4a2efa309ffb188546", + "0x89d1152959280d067ef8fc62f3c7d87954386b4f75ae6e7088b1abcf465d100b", + "0xb0f87f7fda2e15c6fb9fdfb54b3fdda22e128a6446d6eb276added115d9c124c", + "0xec9e1a57d83c3f6545369a1cd6f08c2a7b39d2c0f1dc9042b688e03139dfb5cc", + "0x3557df0c516662bee0380d0a932d815d998548d9942698c288db00bb7e012a14", + "0x7cd01db372d8031fd62cbbf5b93353689a7c49e34975d1846e69cb850e06a6c3", + "0x3aa00b9a00086376b6a55f601ad407c701f8f9ffff02f67b7088db93f01509b1", + "0x1bbc33ab2282b2187dccbbc5ae2de138a89f7050a069d6dc0d6fb76aa24f14b2", + "0xb7d09b2750dbb6a0d0090129e19a7b73a393e0cfbd55e6d33f3e5440fc3e43c6" +] \ No newline at end of file diff --git a/tests/gravity/build-container.sh b/tests/gravity/build-container.sh new file mode 100755 index 00000000..48a7fd37 --- /dev/null +++ b/tests/gravity/build-container.sh @@ -0,0 +1,16 @@ +#!/bin/bash +set -eux + +# this directy of this script +DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" +DOCKERFOLDER=$DIR/dockerfile +REPOFOLDER=$DIR/../.. + +# change our directory sot hat the git arcive command works as expected +pushd $REPOFOLDER + +#docker system prune -a -f +# Build base container +git archive --format=tar.gz -o $DOCKERFOLDER/onomy.tar.gz --prefix=onomy/ HEAD +pushd $DOCKERFOLDER +docker build -t onomy-base . diff --git a/tests/gravity/container-scripts/all-up-test-internal.sh b/tests/gravity/container-scripts/all-up-test-internal.sh new file mode 100644 index 00000000..25e277b1 --- /dev/null +++ b/tests/gravity/container-scripts/all-up-test-internal.sh @@ -0,0 +1,16 @@ +#!/bin/bash +# the script run inside the container for all-up-test.sh +NODES=$1 +TEST_TYPE=$2 +set -eux + +bash /onomy/tests/gravity/container-scripts/setup-validators.sh $NODES + +bash /onomy/tests/gravity/container-scripts/run-testnet.sh $NODES & + +sleep 30 + +# deploy the ethereum contracts +DEPLOY_CONTRACTS=1 RUST_BACKTRACE=full CHAIN_BINARY=onomyd ADDRESS_PREFIX=onomy RUST_LOG=INFO test-runner + +bash /onomy/tests/gravity/container-scripts/integration-tests.sh $NODES $TEST_TYPE \ No newline at end of file diff --git a/tests/gravity/container-scripts/integration-tests.sh b/tests/gravity/container-scripts/integration-tests.sh new file mode 100755 index 00000000..25c60445 --- /dev/null +++ b/tests/gravity/container-scripts/integration-tests.sh @@ -0,0 +1,18 @@ +#!/bin/bash +NODES=$1 +TEST_TYPE=$2 +set -eu + +FILE=/contracts +if test -f "$FILE"; then +echo "Contracts already deployed, running tests" +else +echo "Testnet is not started yet, please wait before running tests" +exit 0 +fi + +set +e +killall -9 test-runner +set -e + +RUST_BACKTRACE=full CHAIN_BINARY=onomyd ADDRESS_PREFIX=onomy STAKING_TOKEN=ualtg TEST_TYPE=$TEST_TYPE RUST_LOG=INFO test-runner diff --git a/tests/gravity/container-scripts/reload-code.sh b/tests/gravity/container-scripts/reload-code.sh new file mode 100755 index 00000000..62efd124 --- /dev/null +++ b/tests/gravity/container-scripts/reload-code.sh @@ -0,0 +1,30 @@ +#!/bin/bash +# Number of validators to start +NODES=$1 +# what test to execute +TEST_TYPE=$2 +set -eux + +# Stop any currently running peggy and eth processes +pkill peggyd || true # allowed to fail +pkill geth || true # allowed to fail + +# Wipe filesystem changes +for i in $(seq 1 $NODES); +do + rm -rf "/validator$i" +done + + +cd /onomy/ +export PATH=$PATH:/usr/local/go/bin +make install +tests/gravity/container-scripts/setup-validators.sh $NODES +tests/gravity/container-scripts/run-testnet.sh $NODES + +# deploy the ethereum contracts +DEPLOY_CONTRACTS=1 RUST_BACKTRACE=full TEST_TYPE=$TEST_TYPE RUST_LOG=INFO test-runner + +# This keeps the script open to prevent Docker from stopping the container +# immediately if the nodes are killed by a different process +read -p "Press Return to Close..." \ No newline at end of file diff --git a/tests/gravity/container-scripts/run-eth.sh b/tests/gravity/container-scripts/run-eth.sh new file mode 100644 index 00000000..701ab70d --- /dev/null +++ b/tests/gravity/container-scripts/run-eth.sh @@ -0,0 +1,18 @@ +#!/bin/bash +# Starts the Ethereum testnet chain in the background + +# init the genesis block +geth --identity "OnomyTestnet" \ +--nodiscover \ +--networkid 15 init /onomy/tests/gravity/assets/ETHGenesis.json + +# etherbase is where rewards get sent +# private key for this address is 0xb1bab011e03a9862664706fc3bbaa1b16651528e5f0e7fbfcbfdd8be302a13e7 +geth --identity "OnomyTestnet" --nodiscover \ +--networkid 15 \ +--mine \ +--http \ +--miner.threads=1 \ +--nousb \ +--verbosity=5 \ +--miner.etherbase=0xBf660843528035a5A4921534E156a27e64B231fE &> /geth.log \ No newline at end of file diff --git a/tests/gravity/container-scripts/run-testnet.sh b/tests/gravity/container-scripts/run-testnet.sh new file mode 100755 index 00000000..ba6864a9 --- /dev/null +++ b/tests/gravity/container-scripts/run-testnet.sh @@ -0,0 +1,43 @@ +#!/bin/bash +set -eux +# your gaiad binary name +BIN=onomyd + +NODES=$1 + +for i in $(seq 1 $NODES); +do +# add this ip for loopback dialing +ip addr add 7.7.7.$i/32 dev eth0 || true # allowed to fail + +GAIA_HOME="--home /validator$i" +# this implicitly caps us at ~6000 nodes for this sim +# note that we start on 26656 the idea here is that the first +# node (node 1) is at the expected contact address from the gentx +# faciliating automated peer exchange +if [[ "$i" -eq 1 ]]; then +# node one gets localhost so we can easily shunt these ports +# to the docker host +RPC_ADDRESS="--rpc.laddr tcp://0.0.0.0:26657" +GRPC_ADDRESS="--grpc.address 0.0.0.0:9090" +else +# move these to another port and address, not becuase they will +# be used there, but instead to prevent them from causing problems +# you also can't duplicate the port selection against localhost +# for reasons that are not clear to me right now. +RPC_ADDRESS="--rpc.laddr tcp://7.7.7.$i:26658" +GRPC_ADDRESS="--grpc.address 7.7.7.$i:9091" +fi +LISTEN_ADDRESS="--address tcp://7.7.7.$i:26655" +P2P_ADDRESS="--p2p.laddr tcp://7.7.7.$i:26656" +LOG_LEVEL="--log_level error" +ARGS="$GAIA_HOME $LISTEN_ADDRESS $RPC_ADDRESS $GRPC_ADDRESS $LOG_LEVEL $P2P_ADDRESS" +$BIN $ARGS start > /validator$i/logs & +done + +# let the cosmos chain settle before starting eth as it +# consumes a lot of processing power +sleep 10 + +bash /onomy/tests/gravity/container-scripts/run-eth.sh & +sleep 10 diff --git a/tests/gravity/container-scripts/setup-validators.sh b/tests/gravity/container-scripts/setup-validators.sh new file mode 100755 index 00000000..bdc89059 --- /dev/null +++ b/tests/gravity/container-scripts/setup-validators.sh @@ -0,0 +1,84 @@ +#!/bin/bash +set -eux +# your gaiad binary name +BIN=onomyd + +CHAIN_ID="gravity-test" + +NODES=$1 + +ALLOCATION="10000000000ualtg,10000000000footoken" + +# first we start a genesis.json with validator 1 +# validator 1 will also collect the gentx's once gnerated +STARTING_VALIDATOR=1 +STARTING_VALIDATOR_HOME="--home /validator$STARTING_VALIDATOR" +# todo add git hash to chain name +$BIN init $STARTING_VALIDATOR_HOME --chain-id=$CHAIN_ID validator1 + + +## Modify generated genesis.json to our liking by editing fields using jq +## we could keep a hardcoded genesis file around but that would prevent us from +## testing the generated one with the default values provided by the module. + +# add in denom metadata for both native tokens +jq '.app_state.bank.denom_metadata += [{"base": "footoken", display: "mfootoken", "description": "A non-staking test token", "denom_units": [{"denom": "footoken", "exponent": 0}, {"denom": "mfootoken", "exponent": 6}]}, {"base": "ualtg", display: "altg", "description": "A staking test token", "denom_units": [{"denom": "ualtg", "exponent": 0}, {"denom": "altg", "exponent": 6}]}]' /validator$STARTING_VALIDATOR/config/genesis.json > /edited-genesis.json +# rename base denom to ualtg +sed -i 's/stake/ualtg/g' /edited-genesis.json + +mv /edited-genesis.json /genesis.json + + +# Sets up an arbitrary number of validators on a single machine by manipulating +# the --home parameter on gaiad +for i in $(seq 1 $NODES); +do +GAIA_HOME="--home /validator$i" +GENTX_HOME="--home-client /validator$i" +ARGS="$GAIA_HOME --keyring-backend test" + +# Generate a validator key, orchestrator key, and eth key for each validator +$BIN keys add $ARGS validator$i 2>> /validator-phrases +$BIN keys add $ARGS orchestrator$i 2>> /orchestrator-phrases +$BIN eth_keys add >> /validator-eth-keys + +VALIDATOR_KEY=$($BIN keys show validator$i -a $ARGS) +ORCHESTRATOR_KEY=$($BIN keys show orchestrator$i -a $ARGS) +# move the genesis in +mkdir -p /validator$i/config/ +mv /genesis.json /validator$i/config/genesis.json +$BIN add-genesis-account $ARGS $VALIDATOR_KEY $ALLOCATION +$BIN add-genesis-account $ARGS $ORCHESTRATOR_KEY $ALLOCATION +# move the genesis back out +mv /validator$i/config/genesis.json /genesis.json +done + + +for i in $(seq 1 $NODES); +do +cp /genesis.json /validator$i/config/genesis.json +GAIA_HOME="--home /validator$i" +ARGS="$GAIA_HOME --keyring-backend test" +ORCHESTRATOR_KEY=$($BIN keys show orchestrator$i -a $ARGS) +ETHEREUM_KEY=$(grep address /validator-eth-keys | sed -n "$i"p | sed 's/.*://') +# the /8 containing 7.7.7.7 is assigned to the DOD and never routable on the public internet +# we're using it in private to prevent gaia from blacklisting it as unroutable +# and allow local pex +$BIN gentx $ARGS $GAIA_HOME --moniker validator$i --chain-id=$CHAIN_ID --ip 7.7.7.$i validator$i 500000000ualtg $ETHEREUM_KEY $ORCHESTRATOR_KEY +# obviously we don't need to copy validator1's gentx to itself +if [ $i -gt 1 ]; then +cp /validator$i/config/gentx/* /validator1/config/gentx/ +fi +done + + +$BIN collect-gentxs $STARTING_VALIDATOR_HOME +GENTXS=$(ls /validator1/config/gentx | wc -l) +cp /validator1/config/genesis.json /genesis.json +echo "Collected $GENTXS gentx" + +# put the now final genesis.json into the correct folders +for i in $(seq 1 $NODES); +do +cp /genesis.json /validator$i/config/genesis.json +done diff --git a/tests/gravity/dockerfile/Dockerfile b/tests/gravity/dockerfile/Dockerfile new file mode 100644 index 00000000..edbaab61 --- /dev/null +++ b/tests/gravity/dockerfile/Dockerfile @@ -0,0 +1,21 @@ +FROM fedora:33 +ENV GOPATH=/go +ENV PATH=$PATH:/go/bin +RUN dnf install -y git make gcc gcc-c++ which iproute iputils procps-ng vim-minimal tmux net-tools htop tar jq npm openssl-devel perl golang rust cargo +ADD https://gethstore.blob.core.windows.net/builds/geth-linux-amd64-1.10.3-991384a7.tar.gz /geth/ +RUN cd /geth && tar -xvf * && mv /geth/**/geth /usr/bin/geth +# this is the Gravity bridge release, update it along with your go.mod entry +# FIXME replace the urls to the onomy repo +ADD https://github.com/onomyprotocol/cosmos-gravity-bridge/releases/download/v0.0.0-20210915184851/test-runner /usr/bin/test-runner +RUN chmod +x /usr/bin/test-runner +ADD https://github.com/onomyprotocol/cosmos-gravity-bridge/releases/download/v0.0.0-20210915184851/Gravity.json /solidity/Gravity.json +ADD https://github.com/onomyprotocol/cosmos-gravity-bridge/releases/download/v0.0.0-20210915184851/TestERC20A.json /solidity/TestERC20A.json +ADD https://github.com/onomyprotocol/cosmos-gravity-bridge/releases/download/v0.0.0-20210915184851/TestERC20B.json /solidity/TestERC20B.json +ADD https://github.com/onomyprotocol/cosmos-gravity-bridge/releases/download/v0.0.0-20210915184851/TestERC20C.json /solidity/TestERC20C.json +ADD https://github.com/onomyprotocol/cosmos-gravity-bridge/releases/download/v0.0.0-20210915184851/contract-deployer /solidity/contract-deployer +RUN chmod +x /solidity/contract-deployer +# the actual source code for this repo, this **only** includes checked in files! +# this is a bit of a pain but it does speed things up a lot +ADD onomy.tar.gz / +# build steps for all codebases in this repo, must be below the add statement +RUN pushd /onomy/ && PATH=$PATH:/usr/local/go/bin GOPROXY=https://proxy.golang.org PATH=$PATH:/usr/local/go/bin make install \ No newline at end of file diff --git a/tests/gravity/run-all-tests.sh b/tests/gravity/run-all-tests.sh new file mode 100644 index 00000000..3fed62c7 --- /dev/null +++ b/tests/gravity/run-all-tests.sh @@ -0,0 +1,17 @@ +#!/bin/bash +set -eux +# the directory of this script, useful for allowing this script +# to be run with any PWD +DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" +cd $DIR +bash all-up-test.sh +bash all-up-test.sh VALIDATOR_OUT +bash all-up-test.sh VALSET_STRESS +bash all-up-test.sh BATCH_STRESS +bash all-up-test.sh HAPPY_PATH_V2 +# bash all-up-test.sh VALSET_REWARDS +bash all-up-test.sh ORCHESTRATOR_KEYS +bash all-up-test.sh EVIDENCE +bash all-up-test.sh TXCANCEL + +echo "All tests succeeded!" \ No newline at end of file diff --git a/tests/gravity/run-tests.sh b/tests/gravity/run-tests.sh new file mode 100755 index 00000000..8dad0ead --- /dev/null +++ b/tests/gravity/run-tests.sh @@ -0,0 +1,6 @@ +#!/bin/bash +TEST_TYPE=$1 +set -eu + +# Run test entry point script +docker exec onomy_test_instance /bin/sh -c "pushd /onomy/ && tests/gravity/container-scripts/integration-tests.sh 1 $TEST_TYPE" \ No newline at end of file diff --git a/tests/gravity/start-chains.sh b/tests/gravity/start-chains.sh new file mode 100755 index 00000000..60299ac2 --- /dev/null +++ b/tests/gravity/start-chains.sh @@ -0,0 +1,18 @@ +#!/bin/bash +set -eux + +# the directory of this script, useful for allowing this script +# to be run with any PWD +DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" + +# Remove existing container instance +set +e +docker rm -f onomy_test_instance +set -e + +NODES=3 + +pushd $DIR/../ + +# Run new test container instance +docker run --name onomy_test_instance --mount type=bind,source="$(pwd)"/,target=/onomy --cap-add=NET_ADMIN -p 9090:9090 -p 26657:26657 -p 1317:1317 -p 8545:8545 -it onomy-base /bin/bash /onomy/tests/gravity/container-scripts/reload-code.sh $NODES \ No newline at end of file