Search in sources :

Example 76 with ImportResult

use of org.aion.zero.impl.core.ImportResult in project aion by aionnetwork.

the class MasteryConsensusTest method testImportBlock1023849.

/**
 * Tests importing block <a href="https://mastery.aion.network/#/block/1023849">1023849</a>.
 */
@Test
public void testImportBlock1023849() {
    TransactionTypeRule.disallowAVMContractTransaction();
    // data extracted from the mastery network
    Block block1023847 = BlockUtil.newBlockFromRlp(Hex.decode("f9081bf9079001830f9f67a07d5bade42a7a540905fa003a414c44272c9634bba5b8e375727754d05c6d4ab0a0a0d75ca161e901ff63be33cc0ea3efda4a7609c74ba4bd1342db2a6edba5528ea0a7ef235254de5057039daf1426b1bdb6e8d2c743f0bc7661d7793a53cea1d36aa0277c93a2524a5caa2ffe4367eb7ea0b7792f6efb3e1cf0eb428dfcd3433e0e51a0f1c7408329cc7b61c4bbc19784e3ce29e7c31bd1bd3b989a0e20df8875c8c47eb90100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000009000000000000000000000000000000048a041494f4e0000000000000000000000000000000000000000000000000000000083066d9783e4b862845bf4c09ca0d8c7e4f7dc46c0a3924992f9c098660c3825a344163de16a278ff6ae75c54595b90580000b4c25a28a032d74bae923f5bad95eabcbcf331a2109aca0c0bc060bb533fdd44edc6706ea174e1efb69510e0ebe9bc28194b3b0117b14fd532fa3255ac3ff16534c2d42ab4687984c347eae691e9e71d8a76515fb4fe809dd698b96656dc89de8ac7497535f8b47c507bf626b0afda9b783e9c4c0adc18c154e28a56173cef3de126e09e4f0bfc4480df7be2add0e4c476de9b2aad71d401227992301d62d13b4fc54ed545c3f393315f768b1ae2c003badaeb3a0f81ae8dd933ac3b6e99dbd7dd67a5287242ff39492c985122dbf3a36d92798b53621bef3558507b806e5915267f52f137d1f0516ac5c460b02e4277009ad2187a519659bf4120c7b370b8951284eba3113071114be86cf6628fea86ea52c274df884b4ba12a0c2d31fd32cb7cb5c9839f3ca5a34cdc6726c8854b57ea418151f7ebadcb52ab5dda49e83c2d20fa05ca72d39dcbc1d7fb9eb1e641ef4b231e9263f5ad0cb7b47b3755c4603c57e7acba71143efbdb109e34be6f4f4e07557719f05b2dc7871a521cf1492703a4886974955f8a0a074c104000de4518197075dc6fe2d690fdbf3196699f9627c07c68e24bfb64cf91f40f345dd3b7f472833cfad0865132e49e2e096fc172da6703a2086363bcc034cf6cdde256001c7eb3cbb9333744837001f6e93643338d70a162f29d629e537ea0c292c2b3b3d7399d1f5660e75080c3b2f3140fb44aa4134e79a653cb62a23b7ecf731368508dbb178b0642ffafe4e4821a80fb23c09220abc57eb24bd4a80860313f9cf8ea456fa7f484ef8ef36f382970ab53849a14319358c9cfb2c05e21f1ef78474bd87d9253e873928c5cd1a373fe74b43c766035b2286f5a9b614be2efc113dea2839575f604b8aed69f7c4f8368f09497b91edd3ce17283f86af9329433f7efbce62b88501206a526e7fa7a570f73752679e636998b9ce15fac7435e63e704fc6914f76d9695819a82bb1808c367a338bf00f2c50e4d7287527080e3669dd70c8bf77f32ed796607ce2458cf85588c1b3cca3f765a312ee7202c3ed829106fb1900e0501ab1e456b5785cb654ccc51793a3e5012ffa4a20c51361450646d156fa612ab61c2b233ee43082a37d729c30d54b2067524da23e5ccf6d0b669796a2eea23084c43121aa057c47c262f8a777aa53aec530a150cd59a8cc51c7d3be8254bcfe3b587b64cb87a4d213560efa03e9fb0a9bfb67a5b3093e0c7ce02987bb55e01e05fe4da3f1d2afe779a0fbb921670041516ad4c0a2f9a5b65a473ccfba9f23b48c98aca5039b83cb11c62026e624af9a9f81d3787db161c253bacab5c13f424392f58a18123be60197a60f0395f0af68758f88bab3077096ee6ddc880dcfb3669982b3356f9abd49f06a275042de44956ada54b836547d03880396a6e544ae61661f5160986543a0162d9b78c884c4a32dd024a9159f2c7271d39ab2380d5af1e1999313bbdc748e825141435e14b03a8bc2832e31e59d7c8c96286719b8c9c7dc23ea396307696358546b92c1eafaf8ff97b89dd8a13256df93f0dce4d3517043c2a1873023921c91b7de627d9e56b442457ee0a44157869f6ff5f48f547f48d4b68f6bd53050ec9a21979c32c1fedfcc679075e554f5ed48efe12a0277a2abfd8e55a7d60e9865968a1880ea66000fed2e7183ebe0f3021c6d3572f1c19294f90249654a971fead27e10373960a31e0f3d9f12df9e98ca4df4fa03e4356061020b466109215da0dfa0f41318af1f3b67c523bfc0bbdb8f63e9909e1ff14563204c2712c94280bb7361612da3f2bed67870a32a6091cf9cce0fe19f7d5bcafad53adfa03e9b73863b10e7998f5a79a252b9bde766fda090210beffe5933d72c2fd0f3aa04aa911b5c8bb39dc0f912e4bac81b9448cab44540bddf63d88beb6f039651798fe864ea57ef7569e5b406c1b560287dcf92d80fc206e83db637a8f826eadfb23b7f30f7684db66d4516ff886f88440808087600060006000f08800057b23285f7c95830f42408800000002540be40001b860ac4f4597ef563d4302ca703c25719dd6ad159331c8cb7ee6199936aed92ae940e8c7eaeccdbb85a804b627f89860c308f86a790940755b0ce461b000619f62e69cf0717c4f6d143bb92135904dfc57f9286912a3edf774d40ada2d3a2628080c"));
    BigInteger tdAt1023847 = BigInteger.valueOf(62_291_162);
    Block block1023848 = BlockUtil.newBlockFromRlp(Hex.decode("f90bd5f9079001830f9f68a00fde547d8a92f9b7d2ff8e317bc816554cf3b7c49aa8410a41e560cf1fc61fc1a0a08fc457b39b03c30dc71bdb89a4d0409dd4fa42f6539a5c3ee4054af9b71f23a0fc5b9d41cfe64b9f04c3402263bfcefca862143dbb33216061f5da13f6fc00b9a06bb43ffd61ddd7b1e7a834f0e8d4f655feaa00f85aa498f7d61319710fc994c8a035d9bd374a96a3e820ea398b2ae335f3374b30b85c1d539a045cb2769bf48207b90100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000009000000000000000000000000000000049a041494f4e000000000000000000000000000000000000000000000000000000008304d33c83e4f190845bf4c0aba0a70d6ab9b4d9f73419d4352a2ef28690c1cd752564fccfa059cd8e539f0d2730b90580003f6d6a0cacf4e0f4ef661c8180e9f212cacd25db8a1982592002d73f267e7e736232b5c9140a68e529def90cdd7c6734236aa46b99996b2216184329981faf559e1256e16e5c278482f1c7411ba89ac6b671f26771dc3723f8f7d05cc5fbd159c3ba3c49520019d403f626646924cc49da62f770eab682e651521e28fe4c7ed6f4b6622ac64a421f83da8cf28c4f2b3b2f2d1c19f588f38b9b43517b5a2b1a64e5bbcbe26150b3cf2d5641905d477306ca9a2d3d943f6b39fdc90d9d4a5b1d20e020b5cf7d23d38a23aeb2c866ac9ba43b6b55ab8ec9bf982925c21130f4bc57da34a6fd1a74231ea6232dd8ce0530e39118e9f0c4dd998f2a2f9f9d267f9de72496d3c0aba4ea070b3a38bc42bf9896bcc4279023e2efd34ac6aa9d5d0976eeca8eaad53e705b521d539e20c5f1dcf5ab28c10b336bfcb1d197516415d147a9d6d1f9062b24e559482183493a869ad77af0b98b801a0e64392a2495a9e4fa0147bb942310d1abd8110e63484e697ba87f007fed01149e0afb10c7c073b54ae8225c1640efd7e08fb1e98a1e52e74ae0e7b95de8669b5b9f078a69b7dad4b249283e6e62f48ec8629736c0215314b9ec5487615423fcc4027a318e52182f26b6edd599d5d314e46aa018b58a1608346f259852afb3254a1632eb1944a5e4dd9e72c3a4034b13d7e6065ec52f24ce040b74520a121152de4b771bcb99780d0ad9dbbd0e9b2f6393dc551db1467e44df06d8bfeb985a2fdd3408c620bc51b1063a2132b5c481129b452aeae58eb5af66f16816fdf270a834633724570bc303085bf35a0ef0c7eea68e13c83bfa7a76fc676d47a12206a648f3436c17d564ff9db5e3599c147ac2610cd2bd861d00d4688eb1fa2f9f635a3c57fd766afee818e6b3fa78ce12387c910585da9790fd8930ab27d03c254eb2e271bb439d3bf4f8599709a6b7877cbcec4d5b37f1e0f025ea6596b5f93d4b55b26dc1e5eec1b4e8200093e4310624391960d1474b20d7bf71367cffdeb704019aac9b161f8f493ea54254d12bad964c0e4c7691f80144736e80861b592a2ba82cf238d56a6371688e50950f75932c4a56d7c8f674f25fe0427afba700651e059c09a1b42d25d4f91fd8a7544af4194790ba904bfd474141539222120c9e32b9ff8d54505d7c88867bc824b8300d4a19af34b9241d3848e01176317f11228fde74bc0b24be567f81f5c38a3f18a438ef0a3ad425b6d157e4e20193ea22ca0293b77708750afe32f912acf338b8354721403f3736b7b520b492c94e35f6fa2295035e5eb2ee20b97d9301d3779f96536138f58f131b3bdd6631a93a29103a82f3b7b08d620d0648dc567ceced20b6ff4f7e090067b359b36b0e3b60ce5cc0bbaaa3ddaf213749121ffb5cb0573480b0f4ac283d3dbabb805a3ed3724c993f3c110ca7e813036107e151975723faf53b1998f06f5533d65e359d3536baf8cb668e8e0003877201bae514014cd2071cbabb04bea2f313f7e774b7f4027e6bb8ec241631a7cb760ea21eefac2d9674ffc3731f53ffdf3422b93f1b04b400d0ddf1ca32f1f37a70186915adbb324cf7e21842ca22e1fe517269a2b60db66a2669324e14049305e7523c7ed9b5b3de8cf202c850aae2c67a18101e0c17ecc0368a03b45355505a356f40699d69eca6b60a988e07ef468f365ac8713d81b550c478e880f5a6e8530a9b2db335660c75bc0278ad72b65e89f796f26d6c095e622c2bdd8809ff6c23143054c3091ce78579870d467c97ba1e6d76e33b6f65487993f952b6c595a5132f14f79cf380340eaa6f191c2a63298b9382c6e44db46d286d1d03e502fd3d27c18745eb0d3720e4874da3ccc611e94f8f47b5edc69b34002f6ded66049312b052997046c06711626f02377e79b24ad0ee73ff89982433fe2f152f72dfa31362e016708d7620aa78326bf621b793a352a3595b51654aa32d310b5bb4dbc43db68d76b60cdcf9043ff9043c418080b903bd605060405234156100105760006000fd5b5b3360006000508282909180600101839055555050505b61002c565b6103828061003b6000396000f30060506040526000356c01000000000000000000000000900463ffffffff1680634f2be91f14610049578063b4b65ae01461005f578063cd909c75146100cb57610043565b60006000fd5b34156100555760006000fd5b61005d6100e1565b005b341561006b5760006000fd5b6100736100e7565b6040518080601001828103825283818151815260100191508051906010019060200280838360005b838110156100b75780820151818401525b60108101905061009b565b505050509050019250505060405180910390f35b34156100d75760006000fd5b6100df61015d565b005b6002505b565b6100ef6101cf565b600260005080548060200260100160405190810160405280929190818152601001828054801561014e576020028201919060005260106000209050905b816000508060010154905482528160100152602001906002019080831161012c575b5050505050905061015a565b90565b600060006101696101e6565b604051809103906000f08015821516156101835760006000fd5b915091506002600050805480600101828161019e91906101f5565b91909060005260106000209050906002020160005b84849091929091925091909091806001018390555550505b5050565b601060405190810160405280600081526010015090565b60405160fa8061025d83390190565b8154818355818115116102245760020281600202836000526010600020905091820191016102239190610229565b5b505050565b6102599190610233565b8082111561025557600081815080600090556001016000905550600201610233565b5090565b905600605060405234156100105760006000fd5b5b4260006000508190909055507fd4fc977b8ac41e3fa318bb6650de6044046ea9e8cda72be27b6b0c458726c1666000600050546040518082815260100191505060405180910390a15b61005f565b608d8061006d6000396000f30060506040526000356c01000000000000000000000000900463ffffffff16806316ada54714603157602b565b60006000fd5b3415603c5760006000fd5b60426058565b6040518082815260100191505060405180910390f35b600060005054815600a165627a7a723058206919d683bc89f37f2bf6a52877fe0997e5d9b83057967fa1fd4a420b5da707b20029a165627a7a723058202d4cb48cf45eb1f4907e249b6060d84330669ff7f27d967554eb3a20e1c1f68400298800057b23285fa95f830f42408800000002540be40001b860ac4f4597ef563d4302ca703c25719dd6ad159331c8cb7ee6199936aed92ae94050b21a6a6526aa7647d6d0963c508e4d9fcd4d6e5ebe400b93c6926de4dfd2a2117f950c90d2949d0ac8d4e4b7f1d00a48962e53cbcb6fa3516d24db1667b30e"));
    BigInteger tdAt1023848 = BigInteger.valueOf(62_291_235);
    byte[] trieDataAt1023848 = Hex.decode(hexEncodedStateData("masteryStateAt1023848.txt"));
    // block to import
    Block block1023849 = BlockUtil.newBlockFromRlp(Hex.decode("f90838f9079001830f9f69a058d7ae97a5f9ea50188f6ca7efef98ed863357956961b69d04f83fac2e6206a9a0a08fc457b39b03c30dc71bdb89a4d0409dd4fa42f6539a5c3ee4054af9b71f23a0ccb31d8edd7a5c3e1e243605d0be34fad6715e30369817914b8dd185c0d41792a07d9fb93c2784e76f1a41fe5bf31229f66d1779f5bc3e1e153fe06b70158ee453a0ed569aa589ab5f5275e30b19bbb6fcf7ffbc12aa7dad39bfb96a47e4ab9c0277b90100000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000080000000000000000000200000000000000000000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000004000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000009000000000000000000000000000000048a041494f4e000000000000000000000000000000000000000000000000000000008304ab1183e4b9f0845bf4c0b5a07f637bb95d7cdaab484af35c605d498f2aadb4ce990341a91c4e753b03b6a3bbb9058000526fc0f9fa31c73e104e0581787f4f8f159effade40f525ca66b86983ea119411a96ce9969f4f20f1e0b571054549faa152e982a509d7409edd3ad4864d7f648442a9f2bd595992f4cba2b4e7825477b4f57ab38e8431d08ee9a26845393a6219f854565767449c748d0a57c6608f9a73758b82c56e6a56d2737dda1713e05f47e8b3f171901425ac54dc96a00d02b3e839126ccb755396b8636afbb9d35541d61351fc1642f8ab397283d0eae6fb2019e5233f3199660bfd1581a8f0f181b131f6ab0fea203ddd0235c5676f06b89256fb7f270c0b97b23b4f6092b36ea2730cac921f0a14e33fa30de8c65a396384d2b3af672a05a24f3af356d076ca5dfc88f590659aef06c1fdf4e30bee8224fbea10b3783fb35d4381e0ae1a07a2e2ddb77075360499ef048838cda5e9a1b204f7dfaca20e64cd904f30728f1fd8476ca9a32ec697e63b5c0c62f29a96950541a6f72a7b02f34f614afe94c5768b5f3019988753e709a279ba6387208d79a2118977c31d71d0253a745f7a30f34a6608f389459f020fb6ea4f8f2a019c753792a28f372ef4ebb4fcfbe178a266e73bb616b1a8d2146d5c94151edb9972716c7e24f72f481a994840328a7a3310a89eef8c3c509d1e9118309b5772d1dcc1fd52df421a8df70f10fae2831d3e3c7755696f33a590d345731be027584bc790d24830ec38b531ef6ef9338173b1f9c908d8b60f879f123fcc967fb979e00f31c8402daf5a0ddb8eac4be87e6144c4e7cb8b5ca9bba989d4ecf8b20409a91cfb74787566da602f7f7bb235f459504519461c27434897745f42f3457e46f1a74853b24cf188c226267cbb06d7d5cb13a181ab9ad2ba1a57b14e10480515d3ac07c60d812ef2dd0a39df46535da7a318b38dbbbf092fb7475ba06886840dac59b87234c3f73481409dd1140f64c25a23beb7370ef290477e99f7199b363be5ffccac739de34774d99b8d78bf629b8f432e8f20060befe83b5e7e332a0f9821886849c6d5400fe0d64089c7bf55531c7ef0fc8354f251dd4a5183ce6ec326c2656174dca48f00a6b99c92a2e9bde463367dd121c403a5de33a9713d1396a5f064bb0ff0f92061a5fba948a0ca3ee0780e50f651d0f4948ab16dd01e96e1e6c759f3b1ba78fd91579f79aeeca671f3a995006c4b835b01019e4b5f725a1d3066884012d6f2ec89138db4cf8d242349e9a8ae7f54bca9671dd7925a3c74e3a23c7acc93b02b542138a293612346ecd366452aa69eb86b3f684dd2f87251b8f3b3c1338feb93055afd82bbb7b75fd6da113b6e5f6e692a2967c041c6073e99de93744586def69433f619e1a048e5eda37a686a9421db0ab57d034655f0af63f54310da7c7f901b650f1430df63856a73a42972d21aa229da6a641e8dd678e13931947ace5137756ab0dc37f384959e24f341e1a7e0e8b177958a81e2342e61fe928d82db23d6fd6b15c4b5d9a5b021a76897f34ef01e5f48d3171f0dbbbb33d3096cb299e29cddcb56a5d38edbe761e66192cf4c37147917779d0654f4fe19e350a4f0518ad6b1fff717b2914729fd51871c03c3d2285244966b7630c03d0312b2c2fd9ee3ca30acbefebf211036b6b0f89f68c37ff105f31eb714930c8148be863e811664203a194f708de0eed1f5d865be2d6d96ba9d97b17102dbe26fca3d83fc5304a41fb46a66d97f8ffcf7e27a9d78a39956453a223c98d8d5691dd89beee3f718f02dbc3864dfbc6cffbfc5c03791bebbad73d62a317bc03f295eae27e7efbfecbf20752de51e89cc87c3c5b5e1b5dd9fe3d5819946733cc49432690fbdc8f4cf8a25d2055508f29f24bd18a394b2fb225eae46a9047b1a3a504d8c1e00be103786e90f85e334bd9fa7a71196fdd762adfe53ff337272e7df6ff83211324baa94061f6c0ec15c4b7814c1394f1aca4ed38d975da88f3b68a6d77d64197ee9d3b3712912d9ab2580b87939da58185edee13f8a3f8a142a0a066db9691dffe45b9dfde4e18502c525e7e848d6c92b67a27888cbc4de04d3d8084cd909c758800057b23285fb6e0830f42408800000002540be40001b860ac4f4597ef563d4302ca703c25719dd6ad159331c8cb7ee6199936aed92ae940b450f4877c297eb1eb24e054fd6b25af02f4a85ee1d75cda9dd148865fffb87174c571cf173d32bd4127d0784091f341ea1e2e2de202fd9cd62d65b609893e02"));
    BigInteger expectedTdAt250718 = BigInteger.valueOf(62_291_307);
    // setup blockchain with state before imported block
    AionAddress contract = AddressUtils.wrapAddress("a066db9691dffe45b9dfde4e18502c525e7e848d6c92b67a27888cbc4de04d3d");
    StandaloneBlockchain blockchain = new Builder().withState(block1023847, tdAt1023847, block1023848, tdAt1023848, trieDataAt1023848).withDetails(contract, Hex.decode("f90ceda0a066db9691dffe45b9dfde4e18502c525e7e848d6c92b67a27888cbc4de04d3d8080b9093ff9093cb90240b6bd884def39cc288a0f6f556b890e2dd5386cc73025b9d8ef61d8cf32fa6421a73912abcbc3139f8543473df7c271ffc5354d206e0265339ae887823dcd51c103a95ee61ff1e41e2e859a07f2e252b79c6f5a3dc4ccaf54a9d72062b3a3497d6ab9486585f9b09d79a1beb020be17ea083bb39532be7ae5c866799d217e5deb86b5c20aa6bf7786ab4032ecd8100a7078831d76c42724ac7b0dae246bb8a8254a392cb28c9e0daabccd989c8ec52214c458f8b2e9f8fbb60aa0582c23b929e1b470b17fa0b452d327d2ad86ab6d034d2fca0bafeb7dbd682b82165e4d814d52c416dcc9685af7ed13dc9730907b19bab9a62ca7cc4246184fe9f6a2cf8a3b92d77072321a32183f10b943118c8f107c45632407b7811fc96449cd74bf1275922faf19d288a61caff7cbd8231a93091338f10d7a6a34cb11ced8abcbcfff0bb8475fbc477b90c2fb959633774969e382b0bc78aacd41e89e53e4000b7444196b486edb8bd601a441f5e1ea2e8de1a334ea0f75d9464b07358bba5ef179d324e9b83326c53b36d350537baf8831de8734f9efdaf22500c8ac991762cf449c38828405e38e05e2162acc418b8cbc9de951c87475ad2d1febf293fc6346f8db552b819f87639155793760f0fc0d9a054a38fc60d9bb6aba03b5e606d347a5ce76ca63c2044c5f9f6c8b4faff9baccde431787b692d50456942a5c063fa8c3479a31fcaf3868af86a840641db5a9893315301f0978576708eaf8812336f54fc69a8bece3cbe6f27732af023413f413c41bdea05598074cec76433978d06e6e669647f906b9b893f8918080808080a0c416dcc9685af7ed13dc9730907b19bab9a62ca7cc4246184fe9f6a2cf8a3b9280a003a95ee61ff1e41e2e859a07f2e252b79c6f5a3dc4ccaf54a9d72062b3a3497d80a0ece3cbe6f27732af023413f413c41bdea05598074cec76433978d06e6e669647808080a08405e38e05e2162acc418b8cbc9de951c87475ad2d1febf293fc6346f8db552b808080b4f3a020f2e9ef2c5d9a40f161fdd59776c3b63958087dbc70851f891e9b1c6c4690459190608d36834509e61dc1776f3b6535f234b4f3a0349bfda5d3daa9fc735ab356a3d26e9d0815dafade0b6461f79637757ef7f98791903eb45ccb2fd6fd2a91622a92ab77dbb9b853f8518080a0a73912abcbc3139f8543473df7c271ffc5354d206e0265339ae887823dcd51c180a02faf19d288a61caff7cbd8231a93091338f10d7a6a34cb11ced8abcbcfff0bb8808080808080808080808080b873f8718080808080a0c416dcc9685af7ed13dc9730907b19bab9a62ca7cc4246184fe9f6a2cf8a3b92808080a0ece3cbe6f27732af023413f413c41bdea05598074cec76433978d06e6e669647808080a08405e38e05e2162acc418b8cbc9de951c87475ad2d1febf293fc6346f8db552b808080b8b3f8b1a0486edb8bd601a441f5e1ea2e8de1a334ea0f75d9464b07358bba5ef179d324e980808080a0c416dcc9685af7ed13dc9730907b19bab9a62ca7cc4246184fe9f6a2cf8a3b9280a003a95ee61ff1e41e2e859a07f2e252b79c6f5a3dc4ccaf54a9d72062b3a3497d80a0ece3cbe6f27732af023413f413c41bdea05598074cec76433978d06e6e669647808080a08405e38e05e2162acc418b8cbc9de951c87475ad2d1febf293fc6346f8db552b808080b4f3a0353a78894c51161172ff39d9abded99d76f13a7e2bfb806e0d2d8f77be35deb09190a0ff1774896bb38b5c87c9118a17266cb4f3a035c749bcf708d70b69d4d2f4ebd726038bcbebf9ea7ce8481b6acc1e12014e4c9190b221c692e388052f345c628ebb028534b5f4a12094c1c088cc9453996779630ad3af45cbd92814828dd784cf2aa12df95d1b8afe9190a005bebbea7fc4475f2655cd3485f99db4f3a0209bfda5d3daa9fc735ab356a3d26e9d0815dafade0b6461f79637757ef7f98791903eb45ccb2fd6fd2a91622a92ab77dbb9b853f8518080808080a0c416dcc9685af7ed13dc9730907b19bab9a62ca7cc4246184fe9f6a2cf8a3b92808080a0ece3cbe6f27732af023413f413c41bdea05598074cec76433978d06e6e66964780808080808080a3e2a0329591f5e764398e2f85a631d09df021eeffaaaea7b1cf1ebcb4fc98d9e521a201a3e2a0329591f5e764398e2f85a631d09df021eeffaaaea7b1cf1ebcb4fc98d9e521a202b4f3a035c8dc66cc3d06101ea140688bc2c37da6d3259e468a1b56e7398ca8580fe6279190a054de45ab128965ade9ed832cea6f33b8b3f8b1a0b83326c53b36d350537baf8831de8734f9efdaf22500c8ac991762cf449c388280808080a0c416dcc9685af7ed13dc9730907b19bab9a62ca7cc4246184fe9f6a2cf8a3b9280a003a95ee61ff1e41e2e859a07f2e252b79c6f5a3dc4ccaf54a9d72062b3a3497d80a0ece3cbe6f27732af023413f413c41bdea05598074cec76433978d06e6e669647808080a08405e38e05e2162acc418b8cbc9de951c87475ad2d1febf293fc6346f8db552b808080b8d3f8d1a0b83326c53b36d350537baf8831de8734f9efdaf22500c8ac991762cf449c388280808080a0c416dcc9685af7ed13dc9730907b19bab9a62ca7cc4246184fe9f6a2cf8a3b9280a06ab9486585f9b09d79a1beb020be17ea083bb39532be7ae5c866799d217e5deb80a0ece3cbe6f27732af023413f413c41bdea05598074cec76433978d06e6e669647808080a08405e38e05e2162acc418b8cbc9de951c87475ad2d1febf293fc6346f8db552ba0b470b17fa0b452d327d2ad86ab6d034d2fca0bafeb7dbd682b82165e4d814d528080b8d3f8d1a0b83326c53b36d350537baf8831de8734f9efdaf22500c8ac991762cf449c388280808080a0c416dcc9685af7ed13dc9730907b19bab9a62ca7cc4246184fe9f6a2cf8a3b9280a003a95ee61ff1e41e2e859a07f2e252b79c6f5a3dc4ccaf54a9d72062b3a3497d80a0ece3cbe6f27732af023413f413c41bdea05598074cec76433978d06e6e669647808080a08405e38e05e2162acc418b8cbc9de951c87475ad2d1febf293fc6346f8db552ba0b470b17fa0b452d327d2ad86ab6d034d2fca0bafeb7dbd682b82165e4d814d528080b4f3a034c1c088cc9453996779630ad3af45cbd92814828dd784cf2aa12df95d1b8afe9190a005bebbea7fc4475f2655cd3485f99db83baced0005757200025b42acf317f8060854e0020000787000000020475fbc477b90c2fb959633774969e382b0bc78aacd41e89e53e4000b7444196bf90385b9038260506040526000356c01000000000000000000000000900463ffffffff1680634f2be91f14610049578063b4b65ae01461005f578063cd909c75146100cb57610043565b60006000fd5b34156100555760006000fd5b61005d6100e1565b005b341561006b5760006000fd5b6100736100e7565b6040518080601001828103825283818151815260100191508051906010019060200280838360005b838110156100b75780820151818401525b60108101905061009b565b505050509050019250505060405180910390f35b34156100d75760006000fd5b6100df61015d565b005b6002505b565b6100ef6101cf565b600260005080548060200260100160405190810160405280929190818152601001828054801561014e576020028201919060005260106000209050905b816000508060010154905482528160100152602001906002019080831161012c575b5050505050905061015a565b90565b600060006101696101e6565b604051809103906000f08015821516156101835760006000fd5b915091506002600050805480600101828161019e91906101f5565b91909060005260106000209050906002020160005b84849091929091925091909091806001018390555550505b5050565b601060405190810160405280600081526010015090565b60405160fa8061025d83390190565b8154818355818115116102245760020281600202836000526010600020905091820191016102239190610229565b5b505050565b6102599190610233565b8082111561025557600081815080600090556001016000905550600201610233565b5090565b905600605060405234156100105760006000fd5b5b4260006000508190909055507fd4fc977b8ac41e3fa318bb6650de6044046ea9e8cda72be27b6b0c458726c1666000600050546040518082815260100191505060405180910390a15b61005f565b608d8061006d6000396000f30060506040526000356c01000000000000000000000000900463ffffffff16806316ada54714603157602b565b60006000fd5b3415603c5760006000fd5b60426058565b6040518082815260100191505060405180910390f35b600060005054815600a165627a7a723058206919d683bc89f37f2bf6a52877fe0997e5d9b83057967fa1fd4a420b5da707b20029a165627a7a723058202d4cb48cf45eb1f4907e249b6060d84330669ff7f27d967554eb3a20e1c1f6840029")).withContractIndex(contract, ByteArrayWrapper.wrap(Hex.decode("94e6228062267b6b61bb6b7eb4b5f13ed939218890b7b9f54b6098a8bbdc8ad5")), ByteArrayWrapper.wrap(Hex.decode("58d7ae97a5f9ea50188f6ca7efef98ed863357956961b69d04f83fac2e6206a9")), InternalVmType.FVM).withAvmEnabled().build().bc;
    // import block
    Pair<ImportResult, AionBlockSummary> results = blockchain.tryToConnectAndFetchSummary(block1023849);
    assertThat(results.getLeft()).isEqualTo(ImportResult.IMPORTED_BEST);
    // collect the consensus information from the block & receipt.
    AionBlockSummary blockSummary = results.getRight();
    // check the receipt
    AionTxReceipt receipt = blockSummary.getSummaries().get(0).getReceipt();
    assertThat(receipt.isSuccessful()).isTrue();
    assertThat(receipt.getEnergyUsed()).isEqualTo(305_937);
    assertThat(receipt.getPostTxState()).isEqualTo(Hex.decode("193a3191d5784aaf26048cfe793d11ff31d24411876c332de248c430fd0bcfa3"));
    byte[] stateRoot = blockSummary.getBlock().getStateRoot();
    byte[] blockReceiptsRoot = blockSummary.getBlock().getReceiptsRoot();
    byte[] receiptTrieEncoded = receipt.getReceiptTrieEncoded();
    // verify the consensus information.
    String expectedRoot = "ccb31d8edd7a5c3e1e243605d0be34fad6715e30369817914b8dd185c0d41792";
    String expectedReceiptsRoot = "ed569aa589ab5f5275e30b19bbb6fcf7ffbc12aa7dad39bfb96a47e4ab9c0277";
    String expectedReceiptsTrie = "F9017CA0193A3191D5784AAF26048CFE793D11FF31D24411876C332DE248C430FD0BCFA3B9010000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000008000000000000000000020000000000000000000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000400000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000F856F854A0A054DE45AB128965ADE9ED832CEA6F333EB45CCB2FD6FD2A91622A92AB77DBB9E1A0D4FC977B8AC41E3FA318BB6650DE6044046EA9E8CDA72BE27B6B0C458726C166900000000000000000000000005BF4C0B5";
    assertThat(stateRoot).isEqualTo(Hex.decode(expectedRoot));
    assertThat(blockReceiptsRoot).isEqualTo(Hex.decode(expectedReceiptsRoot));
    assertThat(receiptTrieEncoded).isEqualTo(Hex.decode(expectedReceiptsTrie));
    // checking repository state and total difficulty
    assertThat(blockchain.getRepository().getRoot()).isEqualTo(Hex.decode(expectedRoot));
    assertThat(blockchain.getTotalDifficulty()).isEqualTo(expectedTdAt250718);
}
Also used : AionAddress(org.aion.types.AionAddress) ImportResult(org.aion.zero.impl.core.ImportResult) AionBlockSummary(org.aion.zero.impl.types.AionBlockSummary) Builder(org.aion.zero.impl.blockchain.StandaloneBlockchain.Builder) Block(org.aion.zero.impl.types.Block) BigInteger(java.math.BigInteger) StandaloneBlockchain(org.aion.zero.impl.blockchain.StandaloneBlockchain) AionTxReceipt(org.aion.base.AionTxReceipt) Test(org.junit.Test)

Example 77 with ImportResult

use of org.aion.zero.impl.core.ImportResult in project aion by aionnetwork.

the class MasteryConsensusTest method testImportBlock365432.

/**
 * Tests importing block <a href="https://mastery.aion.network/#/block/365432">365432</a>.
 */
@Test
public void testImportBlock365432() {
    TransactionTypeRule.disallowAVMContractTransaction();
    // data extracted from the mastery network
    Block block365430 = BlockUtil.newBlockFromRlp(Hex.decode("f90791f9078d0183059376a0737cdda511e1eb5567fc3eea277c91697c3d93453238018e0237bd5b3206fc88a0a0450c4333e72ed26552d7462c0b3669924eec816a219b3960d5b3f0b33f7444a0106dbe7bf85d3eb52c03fd0e7f89fdc753c4d767470b442ba510df97c6291793a045b0cfc220ceec5b7c1c62c4d4193d38e4eba48e8815729ce75f9c0ab0e4c1c0a045b0cfc220ceec5b7c1c62c4d4193d38e4eba48e8815729ce75f9c0ab0e4c1c0b9010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000900000000000000000000000000000004ea041494f4e000000000000000000000000000000000000000000000000000000008083e4c999845b8e9a34a007eb2ced7d672107372260b1b0b9dc7106f82115809fb015919ddb6c3309871ab90580008688b89d06fe296d803d181b13384cc2e74029ba060da3b67372822eafbfe4695a0729bf28c66b132b4de61bdf9ed13548eb71355b5036e67a72cb0524efff2768437f5d25b0197bb178ee40bea13bab5a8e46f47e31d7053192583a2271a7505ff91a1dc74504270f312c8f300e3032a2b3caf2f476bb0c653043d4383bb8cc3d15840affb47181042a1f3420b5356faeb5b7041cee7f5e0c0d2cfe65be3a528e7d71001753799c5028d9162a68e9029a3824e6528febffb9da75d97b71030c27497d82301732d30a2cc26622998a5a2c9aedf40135c1a4f9ae3b0be94db37d73dc07642acd1fed822983465a7fa9906f0f7f3ffa4165486d98a0cd852dab6ceb992c4936416a0351997de9e46b555cb5270c0d12367915de6e212b72235ce1d8be54943c5bebfb2dff0bef8febb01db04e28395ffb7cb38bf624bf4ad93c12cb7818b684fcfc71bd5999e283184862d1e999577de38e5f3bab329f37162d04b0f31c4795807c7a90895341f7d1aba97e6670d3d70657794cf05195128e15426f7eeeee29dd20ad387bb20a4706a0222bd3d13325b24a8dbbcb0a07d168391ea20c7a7b1a1b267491a185a02008deef5f1b1b63b09eac149311c053e32ca5d47767406177873db81dedb8367921cab4d622f77d47e7aeef35d899e32d8641d2e48e822c36e615fbd60b553266bc2d0c4a075ed7ab89e5d3dc4aa913984c2b51f036f289af900bf87c7b6570fbbcf8071220cc14b1aaceec2476668caebf3e9a01be7cd8190ad53b4726d0ed02dc23ce37d767f7ecbb621278edaa106a9efa3ab39cf4f8ae364b06f55e20c514b759a30d22334f3c698957e0ad9c6063a337ebc869454534466d08944e1485ba40167387f033bfa5a406a8e9b924dab90f97cc5e1d5100fcfa0bf54032efc66215b59e37065110b7a461b3c2456be1d7051fc36a49a587831236c3b226487b1521f41c11a96ac643bddf4282fdb22a7c75400180a512defe27307b0e780634ca2d666c14d9346d0a0e1767582ef10f792f858037adc21733476716ee08a3057b957ade82f074d724696a6affb7cea8f04a37f28e10add261527c9df07d5dd74bfcfbf061181d61b512430ed52114e86315a96668916f5cb9e47ae7dfcfbbcde91fb1a2c5c3d64b4dd96b6834fb819015e53f5ff397ed17d4ceeae738ca587f41934523cbd2ba180b922c295525c3bf3452eeb8907cf8f45f2a2a9c1f481d983d5014034c3681c712342610412350391579758d03e57758b90386d3853587f906b4dcc03f4bb58bab38cbc8a5715a1ee83dd73a44b7389c758121ef8202952652d35a38504544d74035870f8df971635eaf962e764b62d33c02f405259b733850e041281b73aa2c0fd0941d5ea97d9f1c4131c7d2e456975ba8bd875889a69f6e6966937ad6a33181f68e05ac8cf0bcc2aa49f8167ab88625d0e718a13419d0eb7bd407cf74354e96b7c6d383ab543a360eb40358b7323b33819158b2910f6115795bdc3ab03781da3794cb7679ed5f247b1fa574724b580718405b7575580adfb24e693c354d79dcc8712e99f7b6f75fe362de8f4cad25cda5de51bc397be782f717e3051ce7da386ff903bffdd240c63b422be1ca48c39e44b904debe62406711240ce64f59ebdef49e754bf8fec95d2b57543f2aaa2716a3ea3ca5356cfcf5ec6ca8b32587cd5cdeff69322cdb276d174463bf2d662e64fffdfdb25b18827829fc04a99b4eb7e164df594fc008bb5869479b4fb12eff9815e63ef037a18e31aee4d427206ef0a006eefdb4c57811e299157476323633d3d0770c77a0860a680a3fc85c1d85836d8559aa61a71e9b354796d648e79d84b23ed31e3962a76af2e9597c44902c12a24b9489c9f5ba0fe5355a8538a9ace8d439f2bb8dddfea5d10e20d53a64583ba2dfe366b88fee7e1f1150111a40986b6841edb0aa72804686c0fa9daf785ec1a7a3d30d9a1b2cd82f5179c0"));
    BigInteger tdAt365430 = BigInteger.valueOf(13_722_035);
    Block block365431 = BlockUtil.newBlockFromRlp(Hex.decode("f90791f9078d0183059377a072a9432f16606a4df7e2e450a015cd51af62d57be35243072884c6ee86062b25a0a0450c4333e72ed26552d7462c0b3669924eec816a219b3960d5b3f0b33f7444a029aed00ad3e2a5fb5a9de50ed924d7890e48ca60fb0322ea64b8a6176dbb68d2a045b0cfc220ceec5b7c1c62c4d4193d38e4eba48e8815729ce75f9c0ab0e4c1c0a045b0cfc220ceec5b7c1c62c4d4193d38e4eba48e8815729ce75f9c0ab0e4c1c0b9010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000900000000000000000000000000000004ca041494f4e000000000000000000000000000000000000000000000000000000008083e502cb845b8e9a3ba056e2b9ee387d4618d55ef58a8fd9ab475b0568e7700e258d42dd2e4625b91f44b9058000d0ab52953023b6eae16d02bbdc6616e2d81c2b1f280692923add56f68cf84a30426d5771758661746d15b52dee16049369a83cb07a33682ee5ab6a5a18f833155f486861a585c6939a66848d51554baba6492a06ffb95e10661cf950dd04fbb46d02555b721d4836d6aaec5f4b12a983facf9461c1ed81ae3621928c28e4f1a4b1c76f256d14b21d4a81a9733ee13bea8972bee5b35f20efb52dc23a3e50083241a649075254d16973a9a35d2a579703c946d0c3680c39fb3f7c1032e9676ef1df43e2452916102d0ec28b67f979db1d52420f237d284ff671b8de1d9f0fa35ed5857e611d7e4753b9776a58f0dd3b901055ea1d5ba56714709ddb9457b6a5fb304741a2ead58b068b3c54b3679cd437daa92ef33e25cd56cc5bb6b7a62622e5050f932bef13129b3da65f46b9ebf0107969de16a600cb97a712ce76b1911ad31e54bbb85353b3c71c4989b1b96f6b80ceff597f4bd56a3f1ae5e189ba968c04f63e6378734980b924d836cb6f5acc4d4c907b9a433a5e0b9226047e096fb07c4ebba2b7a4691cb677c055440baf9d464a35a82f7b5d4f4bef1c4eb617927011e9458f5a82d7269abc5b88f345dcba47dd3a1e8e290b40184dffcff377a570313d0892b89b24e5f9f3e9f1c94c4306528b56e7610529a15ba7afc739403c351c37830550d3f3c623ec4a61fe11ed521fb2fcb1578cff1fb47e63ee5bb6fba75842b4f8badb6563c0a15ea80fbaae9a07ebc1bfa565d86fea4f2a18624fcc0fa35b717bffaa11902ff08f97fa5f332fd92aa16e79bfe4a61dfc21360eeae192cc66b48a5cc3baae242b207bfc23683aea753f0d659aee75df6869290163b2478684e956287684390ad07a3e69937d75a1e3ae0c5f57e0b55d8ff7beba771041105f6ef545b5a86dbf5b305ac18d07a5f3ab0aa60be918952281611bc694b031f180d2b8a6a6165c6bdc40074a60a56b848bb8858447e86f74bdaa423375a68d018ea3770ca6b9011c5a136a621a739747890d5f0fa81d9bef97f5a1ebb57b166941b476cfe6fa51902f3ed4111afd9e5ab2a14fb0dd031e1bd8e2e5058e6b39179f41c3b151e0b5a6f116f74a470cdf5904d980a4765d9d06f23992097109b861eb7d23e02a66a103f95cf4caaa430541530517fc857635196ee58edc68394b25acc43c130939b04d7a6c4431eef62b851107c0e3b6eeb9cbf424044e06d4034febf9b16d9b62df4aba1cc482b573ee0970e5571fca37cbaa516e599beb8d7eeda55ab8a2171afe4d16d841d041b363b130a289a4a548044fba78682d44c9ace0459f6df3f00e34a559ed3e2610fb9c56fd2ef53f0f6b5b6ddcb80d27505133a84e785f6b76cc030f3cc72a2285765de5850b7e3f37565de8879b71d3dd30714a96b5e93fa92835ea5b13c6a0d31c1751ff81eb18b4fdb1acc3b2e5e114c52370b9a9e285d559a761fa27823cd2a4e6bf19a38bbe57298de1b2fb67fe3a9982048db48d85e0a7581c91fd727cce2b9f28a548adf17a0fda48bafce838f766b74d5266f399fb2c7b05786b9320385d3fb565c5db3274366a39fb226fab2f1b3f485f237b28ad48176b747fce0e391f126ebbe40c815c30e807ce084c30f54b94a98efa3d38ade7e59ed62ebec5f1248272c4291445cffdaf8b55b75ef8e4dd8e7f79b2c311550ed588d51128b0697d302702c736ca684cba33151fd511f3acd532bea1c26d26d26288220769719dd4f00e3e03f0a0a5baa6751cb860efbb6d82af4e4fbe4c1e67648bca51aaf80d6c0e04aee377e3db7bf35f39ab0d13f3c7204ab8458f73cae825e96b0ef0a2e4b036ff9249867b1b9589390737ff975b17ea987c1b5c38b62daf142b9b4fcfad083dffe21660c681a1c9d63739a6be942754a16f6c7469c8b4e0fa666c1a2759d676ba7cd126293b894b937b53e03cd4ab36a887e34596585a710b8c44e2a3b4323f4e85bef43badb67317112e87fb7bcc35c0"));
    BigInteger tdAt365431 = BigInteger.valueOf(13_722_111);
    byte[] trieDataAt365431 = Hex.decode(hexEncodedStateData("masteryStateAt365431.txt"));
    // block to import
    Block block365432 = BlockUtil.newBlockFromRlp(Hex.decode("f90839f9078f0183059378a094c401109986a9d054ecc730a08572453b51dfd0bdf155dfb5b1188585187608a0a08fc457b39b03c30dc71bdb89a4d0409dd4fa42f6539a5c3ee4054af9b71f23a0204b0b88ce011b0d3e351d1e1fdd6337338fb47d15401353e926ceb82d87efa3a044f852c7963f3c7e08c29979feb7adf9a828d73e215d355a22bc3142afb4edcea03c266609eb7f78264301a5aa138697b44d00dcc40bdab92a44d66ddc8f29c093b9010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000900000000000000000000000000000004ca041494f4e0000000000000000000000000000000000000000000000000000000082520883e4c98b845b8e9a3ea04040728811e02a0994d31b50cd69eece68a7f87085b0f937429bc80ab68204bab9058000a4cd21e9234ceb5ea9c43b0553768f53d4f125ddf411edeb2ae8e86d5371bdef5d79eaf0a5374d8eebc6d304d7fcfe72506e36cf6f2624ab6d235af4f962f3d85d0a2d32199af649adaa1db5afbf9f4b338be99db26f002246d534e17293f42afddb7dacc5ffcef91daf2d05612bb8f974b599b808b8a2b0361463982813c9a06e92be22b2d11db0289180b4b0638e9d33b32e0dddb1bbf5b1916b2e91473d4f1cf9d194bd001311bd4be9cdb5db6e0234def670a20d5bb8945510e37ffc939211cd6ce9b325c02bf49034c000aaef4e6ad825d7f46775c671fae01302417551b466bc2f422520e87f71a5ea9279703d3732966a97cf8bae3a7468cc402d5ea265369b95bd6e5708b986a65ddb737970a0b13ad6220d3ee680133c3e7f0ab1ee3ffd3361123fef6d483c2164d2b6763859e8a7396b97d1c1e7092774de933b93ca614c79d5a939bdb4742031d6604c5ef7f395b19126a73f903c39a5b59df800afa84cc9644674eb048010985f31a5f8b12dedd70b29c094e90387874c25f2d2617a6ba5bdfae1617cfeaa30a199f41a8841aa29ca2e688c71e026170446700e4f50fae23b96974f2e2dcce8a56e329d761c9da9377ff00110e1eba0c6a0e3a36e79036f2f8ae6639a4d2d60d64f4083c29a69560a2bfeb583aba35217f85efaf90a0c0d64c19f0f05c878a25f6851abb77d1d58c156b76c7422444b7d1b59d0753f082b462f6e298a4bc58abd43fc023d51a2ffc199c5a563a6377e62549df4cd7fa746182f25ed0fff2e3c2f7ecc2151d20a071f388916e40a390b3a649072d502df9d54a7303950fbfa19748da882db16c81fa592c6b4ecf2554a2f461e2fc5b937916645820b20efc970639ad03d370e4b4489a09789760e313911264837f56f2c37c3fc7a5754493f3ebb57f5ae37961332986a0f22a54730fb17244003e59bea3c099b76df12616a96c6681ad7986e5c5d8660663d8de9e14bb60f5101fc71dd87d5283077f2831e54f5e832c3caac9eac34090631a6e07c293db4a3eb264f2a4f2ba6174baf1478042c2235db9516ec155a4784d52385693d37057a1122126294b2a4255bd9dd504647472b14a17528599c3a6108d89dc2da632ed73fd37c7c2f428a945b7337719d073dfc77fdc5c5b505daa664860f8fa178186d48ffe3a727d1757e129554603fafc865df6772b28cbc28b529ad62c906927d0a288ebedea78de67767f34e2893b919ee052ab27de99c699bbe62766d218f72e6f7c935b63d1630e74cf71cb6c3cf242923908f2e6f902b8c6732f39d0ecc80d791c1ae1afc9ee417b18d167dab244db5c4341c1363eceab5c8436fcb7936442f0e4c846d696c35470afb9f1bb0649d3e3dc3a8362ee9a7106712fdeff4070ea8cc4bba984bfc7ae5274799e2ae85a819d37dbd350b007e2b34b564b0398f7b62083e28f877b1d2bfe0771657c51ee27bf3f57f22b62856f3487c934ca3ba0dc005c1cc6d665c129cf1363b07aab2b3d93ef8bfff8283265ad992ab177e53ae9c5e43a2e3ae9e2a3c9bbbf5210720829ba971698f7f68db1f878ba5c371fe5dfa63ae29796bd2a4e5a6faf4ae16381b7d2f6925e5cbbfbf2705f1af97c0993b267acf122584211ad8838c24d71feb0e8ef23d652603b232b1f06de8a9f1fd28f1abf87b521116ee2d2cb506faf5915b56310ae6412cf76d3f38c019bb85cf6d23fd89a945c13930492551b699fd2fa0160ad030cf7139306a6dc73b5ed4bdfe5bf714c1e9a43313fe09005fa4ac3ff4561c4a4155b64348b44bfd35310b3651e2fd3371acb0f34311952fb1d0b50397acc4e71b86e2f0a433c4d2b9b46554cd92dde94bd2d3b5f2af0d6d0e345386dbe0ec9e8925abf9b4c91450aa1ef47811805d08329c22e639873f15ed6df121420eab8a0ded137fee3ef574c5dabc2c793b031da62e44de2f5783a4472b4e0f1ac50fcefb94d8a6680ee0356aa457bf5ce8f8a5f8a300a0a0b88269779d225510ca880ed742e445db0c70efb1ee3159b6d56479ae3501f988b469471f80140000808705750cb0dee7e882d4318800000002540be40001b860b7dfe3a9fd46fbd034687a6c2a3ddfd61896b8e7521402369383d6a52a591a5ba8b96ade2d2e3eb46bb10a8472e7925e0133ddd20c04cd5c187fb5dcbc6b79bfaeda60a2c58dffbd516dcbdfa06f9309122cbef2fc7fd199b87b9df6f939480c"));
    BigInteger expectedTdAt365432 = BigInteger.valueOf(13_722_187);
    // setup blockchain with state before imported block
    StandaloneBlockchain blockchain = new Builder().withState(block365430, tdAt365430, block365431, tdAt365431, trieDataAt365431).withAvmEnabled().build().bc;
    // import block
    Pair<ImportResult, AionBlockSummary> results = blockchain.tryToConnectAndFetchSummary(block365432);
    assertThat(results.getLeft()).isEqualTo(ImportResult.IMPORTED_BEST);
    // collect the consensus information from the block & receipt.
    AionBlockSummary blockSummary = results.getRight();
    // check the receipt
    AionTxReceipt receipt = blockSummary.getSummaries().get(0).getReceipt();
    assertThat(receipt.isSuccessful()).isTrue();
    assertThat(receipt.getEnergyUsed()).isEqualTo(21000);
    assertThat(receipt.getPostTxState()).isEqualTo(Hex.decode("bd99ffaba6e054b0feffdda93b2364ecfc4914352a73425d2878a3aeb8fba7ed"));
    byte[] stateRoot = blockSummary.getBlock().getStateRoot();
    byte[] blockReceiptsRoot = blockSummary.getBlock().getReceiptsRoot();
    byte[] receiptTrieEncoded = receipt.getReceiptTrieEncoded();
    // verify the consensus information.
    String expectedRoot = "204b0b88ce011b0d3e351d1e1fdd6337338fb47d15401353e926ceb82d87efa3";
    String expectedReceiptsRoot = "3c266609eb7f78264301a5aa138697b44d00dcc40bdab92a44d66ddc8f29c093";
    String expectedReceiptsTrie = "F90125A0BD99FFABA6E054B0FEFFDDA93B2364ECFC4914352A73425D2878A3AEB8FBA7EDB9010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000C0";
    assertThat(stateRoot).isEqualTo(Hex.decode(expectedRoot));
    assertThat(blockReceiptsRoot).isEqualTo(Hex.decode(expectedReceiptsRoot));
    assertThat(receiptTrieEncoded).isEqualTo(Hex.decode(expectedReceiptsTrie));
    // checking repository state and total difficulty
    assertThat(blockchain.getRepository().getRoot()).isEqualTo(Hex.decode(expectedRoot));
    assertThat(blockchain.getTotalDifficulty()).isEqualTo(expectedTdAt365432);
}
Also used : ImportResult(org.aion.zero.impl.core.ImportResult) AionBlockSummary(org.aion.zero.impl.types.AionBlockSummary) Builder(org.aion.zero.impl.blockchain.StandaloneBlockchain.Builder) Block(org.aion.zero.impl.types.Block) BigInteger(java.math.BigInteger) StandaloneBlockchain(org.aion.zero.impl.blockchain.StandaloneBlockchain) AionTxReceipt(org.aion.base.AionTxReceipt) Test(org.junit.Test)

Example 78 with ImportResult

use of org.aion.zero.impl.core.ImportResult in project aion by aionnetwork.

the class TransactionCreateSpecificationTests method deployInternalAvmContractOnTopOfAddressWithStorageUsingAvmVersion2_DeployAndRequireSuccess.

@Test
public void deployInternalAvmContractOnTopOfAddressWithStorageUsingAvmVersion2_DeployAndRequireSuccess() throws VmFatalException {
    // Deploy AVM contract.
    AionTransaction deployTxAvm = BlockchainTestUtils.deployAvmContractTransaction(AvmContract.DEPLOY_INTERNAL, resourceProvider.factoryForVersion2, SENDER_KEY, BigInteger.ZERO);
    AionAddress contract = TxUtil.calculateContractAddress(deployTxAvm);
    Pair<Block, ImportResult> resultImport = BlockchainTestUtils.addMiningBlock(blockchain, blockchain.getBestBlock(), List.of(deployTxAvm));
    assertThat(resultImport.getRight()).isEqualTo(ImportResult.IMPORTED_BEST);
    // Call AVM contract to deploy new internal AVM contract (version with required success).
    long internalLimit = 1_000_000;
    AionTransaction deployInternal = BlockchainTestUtils.callSimpleAvmContractTransaction(resourceProvider.factoryForVersion2, SENDER_KEY, BigInteger.ONE, contract, "deployAndRequireSuccess", deployTxAvm.getData(), internalLimit);
    AionAddress internalContract = new AionAddress(Hex.decode("a0268090998a99666b72cc452b9307438a34341047d9e0d7b92c9207bf413655"));
    assertThat(blockchain.getRepository().hasAccountState(internalContract)).isFalse();
    // Manipulate the repository to have a non-default storage value.
    RepositoryCache cache = blockchain.getRepository().startTracking();
    cache.addStorageRow(internalContract, ByteArrayWrapper.wrap(RandomUtils.nextBytes(16)), ByteArrayWrapper.wrap(RandomUtils.nextBytes(16)));
    cache.saveVmType(internalContract, InternalVmType.AVM);
    cache.flushTo(cache.getParent(), true);
    // Check assumptions about contract state.
    AccountState contractState = (AccountState) blockchain.getRepository().startTracking().getAccountState(internalContract);
    assertThat(contractState.getBalance()).isEqualTo(BigInteger.ZERO);
    assertThat(contractState.getNonce()).isEqualTo(BigInteger.ZERO);
    assertThat(contractState.getStateRoot()).isNotEqualTo(EMPTY_TRIE_HASH);
    assertThat(contractState.getCodeHash()).isEqualTo(EMPTY_DATA_HASH);
    byte[] oldRoot = contractState.getStateRoot();
    // Next, process the deploy transaction with fork040 enabled.
    AionTxExecSummary result = executeTransaction(deployInternal, true);
    assertThat(result.isFailed()).isTrue();
    assertThat(result.getReceipt().getError()).isEqualTo("reverted");
    assertThat(result.getNrgUsed()).isLessThan(BigInteger.valueOf(deployInternal.getEnergyLimit()));
    assertThat(result.getLogs()).isEmpty();
    InternalTransaction itx = result.getInternalTransactions().get(0);
    assertThat(itx.isCreate).isTrue();
    assertThat(TxUtil.calculateContractAddress(itx)).isEqualTo(internalContract);
    assertThat(itx.isRejected).isTrue();
    assertThat(itx.energyLimit).isEqualTo(internalLimit);
    assertThat(result.getNrgUsed()).isGreaterThan(BigInteger.valueOf(itx.energyLimit));
    contractState = (AccountState) blockchain.getRepository().startTracking().getAccountState(internalContract);
    assertThat(contractState.getBalance()).isEqualTo(BigInteger.ZERO);
    assertThat(contractState.getNonce()).isEqualTo(BigInteger.ZERO);
    assertThat(contractState.getStateRoot()).isEqualTo(oldRoot);
    assertThat(contractState.getCodeHash()).isEqualTo(EMPTY_DATA_HASH);
}
Also used : AionAddress(org.aion.types.AionAddress) ImportResult(org.aion.zero.impl.core.ImportResult) AionTxExecSummary(org.aion.base.AionTxExecSummary) AionBlockchainImpl.getPostExecutionWorkForGeneratePreBlock(org.aion.zero.impl.blockchain.AionBlockchainImpl.getPostExecutionWorkForGeneratePreBlock) Block(org.aion.zero.impl.types.Block) RepositoryCache(org.aion.base.db.RepositoryCache) AionTransaction(org.aion.base.AionTransaction) AccountState(org.aion.base.AccountState) InternalTransaction(org.aion.types.InternalTransaction) Test(org.junit.Test)

Example 79 with ImportResult

use of org.aion.zero.impl.core.ImportResult in project aion by aionnetwork.

the class BalanceTransferConsensusTest method testTransactionTypeBeforeTheFork.

@Test
@Ignore
public void testTransactionTypeBeforeTheFork() {
    // ensure that the fork was not triggered
    TransactionTypeRule.disallowAVMContractTransaction();
    BigInteger amount = BigInteger.TEN.pow(12).add(BigInteger.valueOf(293_865));
    BigInteger initialBalance = getBalance(new AionAddress(SENDER_ADDR));
    assertThat(initialBalance).isEqualTo(SENDER_BALANCE);
    assertThat(this.blockchain.getMinerCoinbase().toByteArray()).isEqualTo(MINER);
    // get contract address from precompiled factory
    AionAddress to = AddressUtils.wrapAddress("a0123456a89a6ffbfdc45782771fba3f5e9da36baa69444f8f95e325430463e7");
    // Make balance transfer transaction to precompiled contract.
    ECKey key = org.aion.crypto.ECKeyFac.inst().fromPrivate(SENDER_KEY);
    AionTransaction transaction = AionTransaction.create(key, BigInteger.ZERO.toByteArray(), to, amount.toByteArray(), new byte[0], 2_000_000, ENERGY_PRICE, // legal type before the fork
    (byte) 11, null);
    // check that the transaction is valid
    assertThat(TransactionTypeValidator.isValid(transaction)).isTrue();
    // Process the transaction.
    Block parentBlock = this.blockchain.getRepository().getBestBlock();
    MiningBlock block = this.blockchain.createNewMiningBlock(parentBlock, Collections.singletonList(transaction), true);
    Pair<ImportResult, AionBlockSummary> results = this.blockchain.tryToConnectAndFetchSummary(block);
    assertThat(results.getLeft()).isEqualTo(ImportResult.IMPORTED_BEST);
    // ensure transaction and block were valid
    AionBlockSummary blockSummary = results.getRight();
    AionTxReceipt receipt = blockSummary.getSummaries().get(0).getReceipt();
    assertThat(receipt.isSuccessful()).isTrue();
    assertThat(receipt.getEnergyUsed()).isEqualTo(21000);
}
Also used : AionAddress(org.aion.types.AionAddress) ImportResult(org.aion.zero.impl.core.ImportResult) AionBlockSummary(org.aion.zero.impl.types.AionBlockSummary) BigInteger(java.math.BigInteger) MiningBlock(org.aion.zero.impl.types.MiningBlock) Block(org.aion.zero.impl.types.Block) ECKey(org.aion.crypto.ECKey) AionTransaction(org.aion.base.AionTransaction) AionTxReceipt(org.aion.base.AionTxReceipt) MiningBlock(org.aion.zero.impl.types.MiningBlock) Ignore(org.junit.Ignore) Test(org.junit.Test)

Example 80 with ImportResult

use of org.aion.zero.impl.core.ImportResult in project aion by aionnetwork.

the class FvmBalanceTransferConsensusTest method testTransferToPrecompiledContract.

@Test
public void testTransferToPrecompiledContract() {
    BigInteger amount = BigInteger.TEN.pow(12).add(BigInteger.valueOf(293_865));
    BigInteger initialBalance = getBalance(new AionAddress(SENDER_ADDR));
    assertThat(initialBalance).isEqualTo(SENDER_BALANCE);
    assertThat(this.blockchain.getMinerCoinbase().toByteArray()).isEqualTo(MINER);
    // ensure bridge is viewed as precompiled contract
    AionAddress bridge = AddressUtils.wrapAddress("0000000000000000000000000000000000000000000000000000000000000200");
    assertThat(ContractInfo.isPrecompiledContract(bridge)).isTrue();
    // Make balance transfer transaction to precompiled contract.
    ECKey key = org.aion.crypto.ECKeyFac.inst().fromPrivate(SENDER_KEY);
    AionTransaction transaction = AionTransaction.create(key, BigInteger.ZERO.toByteArray(), bridge, amount.toByteArray(), new byte[] {}, 2_000_000, ENERGY_PRICE, TransactionTypes.DEFAULT, null);
    // Process the transaction.
    Pair<ImportResult, AionBlockSummary> results = processTransaction(transaction, 1);
    // Collect the consensus information from the block & receipt.
    AionBlockSummary blockSummary = results.getRight();
    AionTxReceipt receipt = blockSummary.getSummaries().get(0).getReceipt();
    assertThat(receipt.isSuccessful()).isTrue();
    assertThat(receipt.getEnergyUsed()).isEqualTo(21000);
    byte[] stateRoot = blockSummary.getBlock().getStateRoot();
    byte[] blockReceiptsRoot = blockSummary.getBlock().getReceiptsRoot();
    byte[] receiptTrieEncoded = receipt.getReceiptTrieEncoded();
    // Verify the consensus information.
    String expectedRoot = "419F9A4C02612094A9B9A2EAC5CC6DF761214882C35267328297D09246206A9A";
    String expectedReceiptsRoot = "9A73184E9A5514164D980452E2283892D0487B6833D3F9F782C8686BFDA1B809";
    String expectedReceiptsTrie = "f90125a034b98e6a317bd93f39959d41cccafec864329cadfb0d8d7bfc5d30df5612e401b9010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000c0";
    assertThat(stateRoot).isEqualTo(Hex.decode(expectedRoot));
    assertThat(blockReceiptsRoot).isEqualTo(Hex.decode(expectedReceiptsRoot));
    assertThat(receiptTrieEncoded).isEqualTo(Hex.decode(expectedReceiptsTrie));
    // Verify that the sender has the expected balance.
    BigInteger expectedBalance = new BigInteger("999999999786407407137135");
    assertThat(getBalance(new AionAddress(SENDER_ADDR))).isEqualTo(expectedBalance);
    // Verify that the contract has the expected balance.
    BigInteger contractBalance = getBalance(bridge);
    assertThat(contractBalance).isEqualTo(amount);
    // Verify that the miner has the expected balance.
    BigInteger expectedMinerBalance = new BigInteger("749210123854045163");
    assertThat(getBalance(new AionAddress(MINER))).isEqualTo(expectedMinerBalance);
}
Also used : AionAddress(org.aion.types.AionAddress) ImportResult(org.aion.zero.impl.core.ImportResult) AionBlockSummary(org.aion.zero.impl.types.AionBlockSummary) BigInteger(java.math.BigInteger) ECKey(org.aion.crypto.ECKey) AionTransaction(org.aion.base.AionTransaction) AionTxReceipt(org.aion.base.AionTxReceipt) Test(org.junit.Test)

Aggregations

ImportResult (org.aion.zero.impl.core.ImportResult)166 Test (org.junit.Test)127 AionTransaction (org.aion.base.AionTransaction)114 AionAddress (org.aion.types.AionAddress)106 AionBlockSummary (org.aion.zero.impl.types.AionBlockSummary)95 MiningBlock (org.aion.zero.impl.types.MiningBlock)90 Block (org.aion.zero.impl.types.Block)80 BigInteger (java.math.BigInteger)75 AionTxReceipt (org.aion.base.AionTxReceipt)50 AionTxExecSummary (org.aion.base.AionTxExecSummary)31 ECKey (org.aion.crypto.ECKey)28 RepositoryCache (org.aion.base.db.RepositoryCache)22 StandaloneBlockchain (org.aion.zero.impl.blockchain.StandaloneBlockchain)22 InternalTransaction (org.aion.types.InternalTransaction)20 AccountState (org.aion.base.AccountState)18 ArrayList (java.util.ArrayList)17 AionBlockchainImpl.getPostExecutionWorkForGeneratePreBlock (org.aion.zero.impl.blockchain.AionBlockchainImpl.getPostExecutionWorkForGeneratePreBlock)16 Builder (org.aion.zero.impl.blockchain.StandaloneBlockchain.Builder)14 AionRepositoryImpl (org.aion.zero.impl.db.AionRepositoryImpl)10 BlockContext (org.aion.zero.impl.types.BlockContext)9