erigon-pulse/cmd/sentinel/decode/main.go

85 lines
54 KiB
Go
Raw Normal View History

/*
Copyright 2022 Erigon-Lightclient contributors
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package main
import (
"bytes"
"encoding/hex"
"fmt"
"io"
"strings"
"github.com/golang/snappy"
"github.com/ledgerwatch/erigon/cl/cltypes"
)
var (
// Hex encoded.
metadataV1Response = "10ff060000734e6150705901140000a43afc0e0b000000000000000000000000002000"
metadataV2Response = "11ff060000734e6150705901150000b3a056ea0000000000000000000000000000000000"
finalityUpdateResponse = "4a26c58bc804ff060000734e61507059014c020083eec0dbdf664c00000000004de90600000000001781be17c85df24278e5a08c2cebbab21dcd60593574c231f47075262425fb7e613fae1212348abcbb15ed2e6e99b1ce5d93c8013eb66009d824721f0a068db1be1d557934252345e99093d8e6b227b4ee19423a35d984a56489bfcb57d2647b80664c00000000009b480200000000003c68b551600735c179abfbd5c74341a8d524365217e70c031d13acc22b003e4938e9d045749e349689d211972dca6c9792a364f309b5c202f25d87b45b3f55b07feaab3b47760bb2436849a855b52e08a61be89156b90d5080f5719b9989274b34630200000000000000000000000000000000000000000000000000000000004165581604f4b02f5dc241254fdde469a55c8ec1ba3a431486f187227a7d7339ac7a41b9c769bd31b1f1b1d22163f4d61a5f54bdaee0c136ec3fddb84e6d7ffddd55a8a16926d19569039f7af4feb2ff5b4d78bb7d8e3378008d32ae06db97ef0055e5bc3b4060c2a667378780d589571cb7fe0af24cb59a2245bfbcc73728645f17cfe000a126a583ceffd3fa2362fbad8368cbfdf9b197e2d7ab8af059a924ffffbfffffffffffff5f7fffffffffffffffffffffdffffffefffffffffffffffffffffffffffffbfdfefffffbfffff7fff9dfbfffffffffffffffffffffffff817d6d9bd4199e2c7296c91a574e5082af3a28ad831793265a28181ac5795f61e93575902ef7668c12ebc3f151949ae017052f8eb5ef7a89901fa07a0b24816fa6ffd207e973106bc5a207124ca49401d8f0f3d325c9feedcb5edb7e0e386d2ee0664c0000000000"
optimisticUpdateResponse = "4a26c58b9802ff060000734e61507059011c010082d6f5f3ff794c0000000000a49a0200000000009a768d1014238eee34b812ac38d4d5fac898baa2b0051fa1ab70f3e8845f3489070bfacdbd9c1578d50d7a9fd74e1f5fc3cf73a0f46cf08b63fe1c8cbbfbfdc4c2ab947c8bc9de93febc896aeca3a83267ad5554a80bd981eb3bbaf6be29c401ffffffffffffffffffdf7fffdffffffffffefeffffffffffffffffffffffffe7fffffffffffffbfffffffffffffffffffffdffbf7fffbfffffffffbfffffffffb41efa9795abfddb166a4d660fae5ca7af3702653112bf180f477693e99869ead8a86a252e9351cf649b0eff14f584a80a144a988a04641cde878990e48d68a5fc5c61d3faea46493a3920744adad1948429cb282650618b290a0294894a4820007a4c0000000000"
lightClientUpdate = `
4a26c58b98c601ff060000734e61507059011c6300ee4a181a9a894b00000000004b270200000000009c5a0bdaccb36e887ced8d9aad5984fef9252fe1ce434e860b560d350e21763dff741b693fbf0a5e34d1c40add7ca39309f305ca38d773627cccf7b4598cda971263b1e67052b9a025967d4738d11ac3ce0ce85ee9f065cf7e2ee01b65e06e729302ecccbe366133b41dc26bbf0f93af9f38c5adf027649d4b778dd6535763ab37c24c21434d2fa73becc1b956c986918cf7978039b1a8084cb860c42700a218fde22b9b92b030ac592ccdd9e218cef2b4284b5a1caa871ad63c14f79cebf05684a83051327b814c5b9ff6725c935532ee0fa3d9c32e0a221cd290179d0c34ffcab45a5568ab1af565a06555c335c7a3914c97952ad40d3d7fb8527993ad53f8bab927cfa0e1ee040776a5bf7449bf4442005eeac74c9cf56601265dc088b43da2d5bc85f62acd887afea2af10bbddcca594577fdc1d5fd73733118afc1e175396a397fe7c84177eed0abcf94e30d555a3b12f479c4e105514535513bf77e8315d623949412a6b76df9fbe884d96ccec7799995d4f121cf1fa14fdd5afaeb8eeae048c35401abc72252498a8189c16d75ef7b03a5c41ad2b8b6dfbc79aeb2ca3e2e401e05014aaa527585d26e3189ecd93290f0647d4c13d5e2bb927c42eb2accc9026e1a5f194ebdb93b4a37e69a730a7c406a51b7a5ae0a535dca37c6fefad95add3d256e047c9dd8f176559f690066364dce49105ef35d8740c8a3c6e0cabf4e3c38590ad726c8409fde0af495d54b9700f5ca7231352072f734f9d8eba6df97f378e3a9b598dc7b7f9472cc051f97caaf55f84216bf371405675580bcf74a416410bc04ad1e4cd1775043c4c3bf0f49976c963c3ac76a7f5112043c5c9359c3518cbff4ddbb4d408b6083e2c68d4a7ec9ec6f4f0d94dcf596d5bec9b1dd5651ed6294c67daabe6739a587eb8f3918d22fdf41bde5bcf4efe8f31567d2e67b1f6eadf7bebcee2a9d02f515130ccbedf3e0f9476f03acca58e539b333272a27ded0e93ee9349f41e578c663aa38f70867bc4a5676b432de4588490b1445ce7e2a91ae7c9323e7159b0bb3696ca854ddb101f9e2fc6a86b1e004bcf02c41718b20c1fd6b09fc165c7d658e63caee714fe2259968c28231302d003ba442c61e3eac43efdea5693c9059545963f91fbe18a4727ac7b25f132021f66fa31040185b303774a2b2d3f8b76029b1dd851c282a4954c8a161672ee678c2d4fef5a0951b18499159106bbde719380ac8afe80fde3bef5fbae4a02bf4cc2eacdc4522b03cbf36245ad8d6ea4085c330b5b8e39d1ade5d1e27df7120eae23dfce74a14106a3ed0c43a2d359d365643705affab325a205ef31b05e6b53d3fb286a73a8eebe9697d495a4e9123285be4394db9a206fb780e4c444399c605c9816c81dd330c9510ff8d1c61d8ea28518e88d839fec1a8b2a7a0eab8f78bcd0fe03b8adfd2979a0445ea890f06202f1d7967568f14b6417fb431a62c551e934a69b72b81f1b2ca056c0a392e597dbdb5f9b270bdbcfda63eee2aaad060bd35dc1e88b56a4f2a84534de067f2f4858f52ac55f5e62c342805afbd44ee8ca2372f31835c02b16dd4f76b0f18338eea8c277048570625d36341e8cbc64d523b39b7e023b9f1205eba711dc6eff35869671c5b10f9b8dd99e382bdefcafa1c3c79471a0c0357c627cb0191d7a6aa8d75312dd1adb989fc575a04b54fb06296097507e7b5b2907d780b7244fedbc8b1b805b2712e9c7cfb2798747ff810abb52ba595c5abbddcd6f7da03042c757cf9bba7b967a03aaea5a85b3e1a3d2d5fdbcba4276970c13bb76d2aaf7d8c36874d993b3d24900d064386ca8ab3bc1e0218f3881ea159f22972d98a3f08d9f691c79d5c68eff8079a768345df7910c3ea81c5ddcebe7a6e51b99e896dceec2d5e23cd85c01704be74ded5a38a3cb88267d330d38d2a71c1639370afa46d045ac053fb2206668814b1b62baa15709c8dbed2ba7a8ce55e1887d79a66d22d19fe08f2649f0d1cba7b6d4466150333851a58fb5cbe941e3d37ef2b8df847b8e6b1078c7b6268fbf8d2609eac2e1b2490ddf7e2a5879f7561423184d03ba612ff1a608ae2323802eb59ef455b4a2ce34a99013b1c15b2fe653ad3f434b0591cbe439e00f8a3e9b1247dd2ec709cd1d13d84df911ba86ed7de9f2579a74b0a1fcb814f9e51c0f1135e5aaf439103c821d3cb112c7229fd45b97a97c3bb72e75024473ed0013d207c41f66a66ca7b71a5b8ebf94c42115754fcf48a4d0ccf87f7ef15757ada72d86fe83f0bcef7d46ecb0b1caf2d3da6d5ddc630af0865f925c016bee387b515ec02221bd4fe73e819cbefcfbe0aeefb2d529f614579c427b793ea506cedb364ddbfc1ae3ab076db030906b1c646d193a12a492e7d5b9a14d4530d8879fe42c8cda581c040459a1891e72e026cd07ae8b134c58f601d4e7867177913e92968353ac2734b41774dddf7d4bc0aac3eb47ddff0135251a1369bd4e8605828ef68f0cda3054a818814493ed2b9e4c50f6e2a935aa43e185f3689f2623fd302b30144e36c7af6fa080f43e3c6035bd4d5628b4e6cfb2f985103b8254c49481683207471a9e8e1e749fb986185014adb14825e3d6ac375558dbce8caf3543e506169cd103c2bf84cf5b63b0f6afcd20db81afe5d7924767eb3b290381f9549f465f98b38d00fd3f362f7033fe408c150842f641b73e5167dfdafc94da93f998cce95d7d4544b4a3895faef75e305458814d365aeaac1855bb5ee4266ef1298e488951090425c7a5382f398997510c35f4aa2c29ca08fc328eb7bc1bad4fa5806fbe97961d3825182986882cf3230de8a45
bfb33f6066f491662036b99432cdae25f4bcc696271cfce9d824d0cdc7356b1cfb2ed7239a9bd6b52e39ab0bb6578b4a3aff8177b72080acff91f8fd62e2eb191c83b2c1af5b327c230f3685b10db915f3a74fb5c87f4ac8dffe6467d35f900a0bfcf002755c5bca9e68c8e2e5a588a534b9256ee02b6cfa06efe2cabc689705537e9a20e9dd8f948eed6af3fc185a3a236bfba427ddb9ae09e74ba623d1c68838b0667f4bb68bd98f2954561f80df9226465a2521d2f65d43119ab1dc30441913c4399a661a668a1d3cda51423c47fd8146a1925a5aefe91488260d1e6ae0d64a0c9157c7e830b34cd3512bcc93114a692538fc5ddb5bb0cb55ec1b3f644ba194a55b52d10393cbe028c3e2458997897748b4e5ef3227d225de0fd34fac292a86e2ac25694fb591bbb43692ee9d084a5ab84dee6d5eade4b7a291572b67677f1b8c5339f5c039012de2cce7cf69e1498122771df642609ebe2c73574c40543469c9d8bc50aa9cde7925574dd6ab3e4a160705c45effd749fbd6d70a2890c47ad2610ca2520ecc1c5f11020b3482b2a583932e96d51f95601c7d217922b18c3bba6c789e6325509c8a9716d8192c9c494ba1b83742f61c1162f5981f719735965c63cdcfc44ad98f57c9f42cd5ff9eaf97f3551744572cb73fd042ffb6cafdd82640d203605a9be2cfbfd5680ffc0832254682ab6e2909bf6ac38b73ba50ccc51d7dd9b85437421dabd6c6a1d446e85b4994862cb82dcc16a9d80b66a2ffe8e44242d4bcd83c82d6000a5daefc7de283cf8476696dcc116fc65356e8f7d59bb977f63a1782cd5f5b1359cf7aeaf5b7d17e4cfa94c202ad1bf16753e85acdf3bde8450a765ffc14fd64d553bee5b101a95c228a34ca00fcf02c34d1ab3ca0f0dd8a4b2355d65d9fbb2fe95a3c4e473310624a4f50f13ced5b93eba74b1e3585fa45d31bf27f1946d504b5e3f69a943ea71637b38a9d01d91a9dfe173412e87c19a4a6b7bc64b6587877cba019f84af03afba6740f1e6f5560fa7b158f051cab5b2650264403bd7f2ed75b4c900e396303f9d6d1ae72861cfc622ad475dd26ec4b27d82f1f7ce188e4f3c6a4c00f04ea2e13b7bef05665dc03b038a4adbef9549f948c164d4a110490dd3f42f661c57e4810af23437bfc9b2ab3b73ccb412b387105bbeb0bd5d96c98eefaedcb32dd191023724d127c80b1e11663466c9bf11eb87b2dee6e33c3f5a4459df59ad3eeaf6392e4aa9eaba530efd30d3473a183b5f5bba150aea34ec03ca0bcca994878024a1639b4359f535203b148c1054aeac6ab8069a3356da17f9c73335e67d86fa7c525ca7d953d9198ee96553ac2189e80f90ea210d54a4cbfca879e7cfd6c8bd4b6c97c0f16564e4c52f567e9fc5da6bbe1b45240d7b69c22cc6287f10a87ea6eb943903dc4920c1385bb79b1a6b7a937cc6e7fa3dd4e6cce7dea83b093852203782e7b99fe42ef98cd04beb4590c5e6ebae4775996e29f7df83d500f997fc330e1e03f70b42d478d26aa4ae7afa83f75c66577ee56a82364576038f702b0f851eb4090fa493a86e08f93ddf5e32a87c741d295575dbf5fc3c4694ac602a4f360dca0269c43f708aa9cd4d4aba69548157b17fdbb452f0681c89510f44a9d4a2e4d971b605f461f5388fb391e4ba75afdc0847df64006aa52ce222bccf72b791b8acdb3e30f8e35e618e125072a9f801bb03f09ab15f7d0169d663bbd91139a6c0c7e9d4c10281526455d19a415f8717839066dd48d41b543a4c8c5875ee840d1c3ab317d4ff93cbb45a1ae56cdaedb1838f2fad7db1a7af040219d9c670293ed59190b6ca7d628985bae1c8c481f566ee0d1a2f3d6d923b26aea4455a86df53f44d6e5130dacc372c73611f195b56cb968397e9c92a6f053045000cb5387e3c15e2cbca2ea7b7a5b0a408dc99128f7fada876315f295e3bd185a4812adba3f590b6002d3553189f017ac7929d9791743e33cd7f30b96e2da85f80945f01805c37eab8cf8a83ec1723aad43eaa10caaee097fa8edee3fa06fd8464623995b5a1e2213bb020099956000c360a39919ad22a7646c2fc3cacf7e9a76f736ad7bddc73a548d9149a3676756fed8f0071677931ed188a02db24233f1c984bcc499f06ce478848f0f1ed73e748afcc4b17b58c00a0bb4c11c73f9045761810c5158aadd2a3139e029fa509afff1071be33c634e182c55b6c0d1a47fa123b34cbef60ffbdb872e1a81dca8450297df8f6044cf2a51bbd67abd863ae33513684c134901373043106163a86a906873305688ff9d4ccae9dbae07979ba98c0d3a9d76881955a60001b4f28aafeeffa7f575639e9c41be96ad02924aef613100a66fe4a57999797584bc0f63b4af130909a0ec14813add1615fea7709fefb8d99566384c34a6f2fd327c29d014fdc6cddbd76fe45af90882f226b5823556b79705f0041a78991718e1a226b5a3342ecc491f9a935d1cbaf49c703a3a092043c38898ad824b982ad0d8e43497f07e5b5fa0783b686ed9aa66f5ffd12304cbe7abcc2dfb92d3482623ef33c487011327c21c9bbae811d2ca347264f20e005f66fd51eba9874a33016d1981bbf92ac9bb68c82082ae70cd50984022cd380e4f22b7f3676d4b542b8b5290211b3b9ffca83279eb7fed9621f306f3321b115179328372ff5c2db52127c8f8e13d879620ff8bd30c8aec862198edeafdbfa7a077cf12ac1656413f476fb139eafd0d04d7ba3db9dfe36c45ad88b2dc5011cb5cb241ed68e50cd3135979995b768b0989c4fce85efdb724af4ce6fb5210496303174d8d230638743fbae52d92e9d36f5ad59e144fd3d2eac467c83ac033e441586e515a6f5803ddc0ecd2223012ef2f4f9eadab10afe917c58d4
1025577823730542cbca710419fcaee72cf93dc38096ed5fdbfafbf0ac43f26fc722d99fef326dbaba97a5997fdb60676a46257958f89dd1228c7f45d6c8cf8c54a673aacd28254d8524f16227131cc4b127576749bf4a63da1a491b8a43a0021c7e9d911f66356607c01c69ee1ff69415137a6ab27657d5bd647b5a17e2015c0f165a475386269379d60c790963c82c1b044815867aa1a1a6a8994e6c525176da66439e0ccfb21208def4408fc46de528ef9b875fc260acdc66f698f9a3801c28e46dba1e0899a520c90101f539aa62ff397531a7639f76868f632b56b9b315059a888d57a1d53c9a462d79947ec364335f3ca9598239150a6f8800b7184091c43c4dc66f3c20d03c36d2f1065b712b90c91659a85c0e6bad4535b85b02dce6f6c5f6638ab45910e88e2e9f1645405cac5360530cd965c043cc508efe4f0b576146a45f9e6c32c2d628581b92ef65c33980afc392bbeba65729b6c2e6081e058cd0bb4f2798762874d32ba5293167eb6dbf1582e34b83db053c902aed6e919e264ee89dda7d7a2799c7a7ee5974f2e1c04377820d2e7c7bdc1ed5e65d4d19e3b6b295e0fe8a6345bc04ff6ae844937414099b0fb7a039e3e5b6ec6d71ae97a222435beb0844a420c4234215e543bb608672ecbc7cd36e95ad63adcb2f0b551cd65eba2856b301be3f6a16f5190f8db38e830382b1f21f6fcd8c25f0a548452ac52766223996f6f006cf952ac2a83ad8f6924987a9b91cd8f458c63d00ba45cbb7d15af20b9d1a686bf0957eb57f0385c44fb1db692df652cd7ef1eb7ca8bc7a9aa82b7c4dcdc064dd2b2e7a2cdf9085cc3073f0ca08933915077e2110fbf44ef995aeed4e96960f713ed4283f50cb3e60ab79e6d22a76dfc91d0473e5ed1d2e97887c9a851654a0134b641918a7fa25139c0d88e97a3e9f43f596f820896f4cc298e608153769950b426e9fd41e804ca19712027ef67f72d1c62a0c086af6f528e518d5bb9e5fdb16123738dbae3b16caa038337c299ae7e9ae25287a3cd723cce95cfaa2b4a0a5c9d3d558fa9706083290271f11832c514fcb3e5abd4edc006b5c94a6c2e56f3fad7fe32651bf3b7acc0cbd3f19bfa6d06d812155793f2bd341ea75b61a393cffc2eafb687e4507962bcdbaf79633cd929e5a619547a1034734a7f56e8ccc5af25f1172cc8cb41b7be207215e8b557d394edcbecb58062ad1685472e0da4cd08ab990ea2361c4c73f2dc650fe9c03b97714c8aac4cd9957623bd564c8211b3919c2e9a9d8a910a2f01e232aa58c6b9b2fa000992f2661a32c8f1b52a3369f250ff571d1120f6edb0fc49a16dfec11e4e3b609f2f8f6883fc68a3e3b7bd9198bba2fdcc186bac432c47d1aca9db916f41e84dd12c4cc25ed1a9734eb2caac663ab4d893c28a9904b65f242be46c1bafa20c29f252bd4e01ef947548620889cfc748ee1f97e3691e7b2e73b50d1f510e86c7b4716b80bd49ab0099c840088f710aa1a95d71489e27b046088e1520352fb14e579d89c64ba4716aef0e3a00d015f7b294ff48a4f6e157d1ba803d4311e3ed2329cf411936babf16e3c0ab29c58fcbd137291bada2f5b9ecc1b566cdd4f5bd839bad5fb0aae874add53b1b095979202aa1cd4ae259c60efbf055893714433cad23bd3da89cc5626e3fda055f1d95583f705855ac443caec9a0a133fd8175ef451b172ca2ec13924d416498ab47c893c23c17a73a89549dc3c67b1e58b623abc09bdf60937f3ea6098954d5350408342b5cbdf8c5fb3c2d93360fcce243d532433a2e3e3ac652588df74e93fda2a6bbd1b150efb21fb32c79d4bda01c8330d8f6110858ca67c20c4e7157570a8975b1b4ebf3f2e9277fb8b0a92c19b33ff8f9239dfa40b5ebe3081dc56d3f5ccf925a240672ed63b272e2a3e450ebe5498376d8b94af1cc003eab6eefe20edfcf0f405826d8af894ad2925ab4bdc906db3886d30a99163f9798e8860daf01208f33beaf880574dd3b7a4e9c8bcd374a9c4d0db91138ec87bb64895dca7b861e15a96e15a0fd3b9c4832d8af6193c14dc91937781babcc16b5efbbbbde7f27f6d1372e046279aa951ff6c5a390be1d15869eb939f575913ea8828575e07f8a26352407f570440011f1279d93b03b974aa7442fdc4cbc5986f49428d84c2edd7635948ea65cbbf16319d093e1ea759bd7ebe1a423604663fbcb2a7b3e7915b25807dffb1c72d1f38c2cb8dff632ff4e9c7ef822221fd07ec0b1487811eefc610a52ebc97b8b714f18526ae8d1e1e01732788d37b57143bca0d31b529a125c305795dc861abd55475cc869d60c275da2358edae60d0a3c7b34b725fb5268a5f2bef20a35fa45879a862ca18a4f7831877022211bc937a33e1e932c391e0f0b004a3eb3e4790d3a4a034d58d4fbf3c111c48ab23ca8f9454b98978ab8cfab854c5259e4200ff602bd6d5193c22e1db012504d6b678c53d660c80a77db4c8aa41a298632fc61756c1395f971611112d5fc5dd27b2594fb0e76fbb82bcde07f4696702346e7628aacfa96fdcb1ea0c1b06c0c1fa83767e8d23c932079dbe8b9fe8318196a6bb1aaf0574c46bd52c11e71016288fc14b585a1204e51eccd8e4313e454ccfce90ee28750a1e829518a4eb9d71a580ac69a8ee310f5bd29b768685baf034e00d8179045f922828251770c308861580fdb4a14561db70b537f2e676f521783e870a9cdebcbd1bbd758c469d17c564c1e7a449bc386333971968cd04c5cb7e87193bc48222ba36422f80d3384163a82d3ae19f22cf30b6a107d43564f6768a6b6fb770492fa8b4b30169d4c0a4fda8b26d48c3dd3468304589d7f892ccf15e869f439439b739019ea370bad5097f0a7811d07f11c8041221fab
1b7d81a087fb330fcb3fc85c8508796cca2d235b3dac0e93a95bb1ff57b6157a2a27fb559e89211b8151ba05aaada37868931284479d560740ea56502e20d8244ab6196d02ea6449f019374d189d44cc7909bb88bed4e679471dc069389654ea024557255ebc1784b21c0b62d65191327f78bf439749e3698a1186287e1ca7a8159b535a251ed57b5757885546c6e2fda4fae3a08d76aaf81aae6b83a4a958422434ad2d8617168c2ce252f0134453e7d50067101235c1385c47e4cf289ca440db02ab4f251135c0371847e555d291302d4f13c6c16e84dbc33967a15e6519e410c5d565a92a94a8ab4dff764bc0deac3c84dc910cedc32143efa9a37bbd52a1bb293cd3038c314709d24013ceaddca1b3726c5f660c51d977454d743a247eaadcedde5a61ca081658dc4dd4a62d5da15603839ac2a713409fcc9f81e0e76aabad741a843c0c1828baff28b1dddda33e283dac4ae3c13f40806ac2617deac466ddab9f948baa49f440e82a08955a544098cb089425f27bfa83b4f87c07344365c5e00aa49eb88ed3b2940e6ebe314202bdb1ba62ccce608e5df144a194c13b0ec7686d0bd954e60aab31cadceaab6646218c53db38d1843ccf72550068fe7b841974e84f498d8ddf81b13c2ca6e5df81580ae648189e6e6b0376aea04d3412c9c5fc894fd3fae5af9bedb94376b2a8bfde57f0d6af4644792cb6eaeb7a0bdce2c69e7a43253ff5397f4f9fee3f56be603ba2288307830af2d8da5c4342f04517db0bb36859676dfee6e1927e3643a9bbc74c9c1af296314b6f15ab5e140f8f2e21497ea0718841d18e227af3993493420c02faa60f40505d9421b03c117d94a27c71520cfff8c06b19717998e696dbcb0f424b99fbe91369e7bf9f79b63c30a141faf544ea765351f38b3bc8a5b89b8b4601780bb0a9b0ca7ddb817f04aa94e860d8e0eeceaa198f7c1a589fc3472f3f676ca541a7a4b2ae263d9b65de9fc90696606993a327d7898bb323adc769c0f018ec6b68d7d0b985c02536f4c10288909c3698504efe45c1929598b314f1c79d8abf6b063bdbd849044e68c263821421c521939f910354326b2d699c9f9e4d05d7beaef207b47722133666a209432eb176eb3e25bdfbae5ad0af8bc6bf2bc295e022b98da13e895d1d6a0063958d0e266abdcd4af6dd0472720eb5985e84de76fe4832c10eb0f52a6aa2e5a0a4e46845e81117f01f7b7099e24746e7981eb10ef1f862257f15f06e75973ab934c8e5782f2f9265ea00eb28db18300026731c8f11c76dde4d22433fc56c58ac2484444f4bfe0a44cdaf4f7ec694890ecd4da6d630f04d7c97db736afa90c84c9f61542d56ecbd4bd280993079b889ad63175a8ea4a05abca86944b0d47a8f9910c8435570a7da4b45e51a098156a69f225c0a404b88c5f3d39262d5c285ba89e7f98645d3b19a86be201dcc524b2cf997dcd1afacf6212c7ea9983901f8d79d01104b36c7b3b8cb7af4e86388c8ce05c3dd1c7be1241cee9294167dfb9959ab265b3eef7e42d7bc08c83b980a767175ef8c626760a523187cc6e2f7864079c4466d4c2cc072cb08f769c07db8b00ded909ae5e4fd85ea33007d2a18c813c514b76fc37e3f2e0c441c983d7e547522f3875d46ce76ce833676dae72c21bc4ae4471dc58d1febf01e3afc8d4b3836ce531826d200e27e506a6518aa7354bb51567eac3ff2cd981c972699b11e389a126bffbe7a8c6ddc9261ad7cb9a8284a5bb078777bb2575045151cfe55973ced116ab766ec02828ca9cc740636ffaa2b2a786cfae50418177c07b94118591e37caba9245d5e6d0a3e2c4448de622f69580b499ad0d33316673cf9218db03f8dadcc5e3dcfa31834dd2b114dba119471e524aaef4478d0d9bd06814e95ebff91c65dd6bdd642da0d206bcfde5f696f2880d63ad24163d145097f5c644d9bacbcc56bd0ec6ee29a7838f1fbf550cd84f339babd93916278e479318aa88aba81f9df7b5db55dd1c3be91768d04d7b0b19b0de4c86b16fd1f50bba90acfd6d87b712fd16c8b0c58f0a5c89adc3fa69c3a9ddab79423fa84c7a48dff204b601599afd92ef91b7159f3cf4a21e22f0554e9727f27e959a619b38a3fbcd31da2d0cf63ca44d8f35003dad879a9336a3206a7c093e4f542c65ca1cadf1757d444574d307b38297808270a8183b23651a445b9a7957aefc34328b0f7369c0d2ddbe1a597cb7b96cf9fd7f35557d882b7f1acfcd80533a42f66d1d885d312bb79be7d1c9153289f5689cf0c7e2de16d1c6fb0ae9f7c4e173d992775f6fccc359918cabc157ba2c09faf19f0221b14745ecfd6a8fc91f9489101e6d3860d09014e32c18782a45d5b6f571613ee786bfb47069e1fe80f31ddf7b7d3ce47161a40fb31a35fb3a025042dfa5d293b466af4257eb7902a700f84023e89ea1908488a2f2aca0d9bc6eaadcc58068c591876be0dc3d31e89b1a7c464c083a671031cdb042d0099f0e93fd196ba56296df4895ad6751ada453fccd7bfcfd5b809a585500f83133c67b7c3d1ee7ca2a042443f6f6c4f3293a020c9393f10530829f87df267b95bfd1164d1a6731792ca933993f4e17aead8f333026380c96bfb2ba279aafbd7abaea2f81f929cb33be334a42f6249ecb3e218d90b8cde303a9bf5bd990dcff36caea5d658d663cad3c2235700a62f8036838c18caa0bfab1a93a52ba4eaa8ee9c3341bbb5d73b39461ad94116d842578f10079f659f55e65d357c38ad90289813a4b85888bd894ca71e1c64e1301143e8474211cc8bfc586d6583587e0da00b61b39923ed426e87c8090cd27a74acc956b604bb35a50b8818a98bf135b55157d1fc0f456c7460a0e140183f5f9fee8397ade4913fc7c2eb4e
3210bef566bdb494788e2393f2c177c8920b4f4420e03ca6798153e0bf14cb84ec921e6b853814c7278fdd142f6600cb0f73b0550b62aee42c5657b77000199ffcbf5c77494ec55e1fd95b397a94acc1fcde967b99e3d7dd60770343a5a2e3c9b4a3344f01079f874bf3e353657ce19d70bc56581b09d72e85c0577d2ea8843b1b5ac4894dc13c047cce11a3f87a246c0a8e13accb2f08bf29d90a4fa15721149db25a35609c6c07a2bd35e5b89cbe26b7e67d78bb59c4687b72960c33b6b28735238904e680e983851c96559b8740cbb9ce0f66ef2c22f324e95efa5f2a484c48ac799910c799dab98ee25913ad2a07740f78c8ce97cab9a0e0e2ec0a02a48d966ed5dec566dac051b412208575d74af99fe03b5bcfaf85ec4ac329b7893b276fadf71d9861d329a5b400fc604bd7382674734e1e54522f82e9f18f47e01c3f2afbf3ba5d9c9cb4d2dd5975ad47e984e4ae57256912a9cdd3ee9989f62a9cfc2a2de1aab7a8209c1b05dc5f45e87e5e1d76657900bc5b79e090ba4ed2216d3ba0a8aeda2f5fa15b71a345b9781196c85f6c27dadad883f51d7f86d64d793c7d15394b6ac87acb7c0c04e52030bd7341c6bd094cb6fdee4f5df16bcf39b89d758e5b1be88bad403b168a1d6925fa608f26e2d1e838754c2dc7ef098645326a3c7c17f05209b72b0afd485f0910709919c30fb2d5ac14560486ef7922dfe0f3d71f66a0eb0208c03a67a50bc07b64b86cf8003aed9638b367cba6626c3756caa217397b4bfaabfb42c29a591c3a3c8839e49020db1719fc46097ea462ce480586bf55eb91894b1df1ce5e2e1b0e9f621cc5e50c1f55f4df14a80351405eee2b9a00b888c888587f54277a160a8f4479a0c5b5d63971edc2826e766bdb4eedec181806b70fa6297a8a970c26c5ed8b648fc04529a86aaffa6813c37c046a1b836e1040ed867c8c780e15cd11d25ea07501eb51d14e502c9fdcdc70502583d41007a227805b45633972a3bd91af4c451497dc537ee08adc92fecdfc1807b3f65e8bac1f33b68ea7b9f836a27a7bfad9d9000108b53b4285c7abff484cb2db692ccb0aebff520a48886470bc0f5d7c292e6dec20d46e74b39117e44cf74a93890998259d92fa045b9d274cc2f1dea275cba4a9ca85cf59014bccfedca8311d658bdb3bbf2b4722a5964a0ac583c40db60119a6271518ba32cce83f04b807af8298740b6ac9b2a8e6f126e564f7c3fa0f45089226d8310f543c49eac84da56c35a5e0975dc3796ee5c5c89ff3bc7f1ca605a58cea3a42ee2155ef1d0da1f2320c06438ceeca998a99b8534dcdde36c66d555d19a73cca5ea6f9ee7a8b0d724f3979d535ec81d552a620ee5f513705c50f4709e07680f55bb52f95e5a1dca1e83e1ca4929fb54a134b047903bde08c1a2c9574b159490e17aedcd6ae86a483ebeb3d7a0615f85526fee59381e6e2fd1cc226f7c66fc0ca9f0606dbaf92cada9d8615788b813e25175af4e5b07c9d7366587c0360e8ef68b1c5d7d83c355e239e3c4d1cd7394508356454aa9a8628b1aa4c039b3a72af453ffcab7ff1f0bca1d1f72e6d0168268b75b2988f8c11a220e03cf05a2a6b9f395be58aef7b9e4e8a9b5d2a90bd66386f5dc7ebc613654f2effcf6e6b7a98cb6613236764f672f045f74f266977c6113a29038b1a5fc3fa4f250c6ebfcde8709bd6be1a11ea26119857b7ed23dd89a7abd50104bf72e62125fba76560a5439c6873554192004bd6a0e9058cc086040a82e3593d2027eb4ac4c6fa981e14b74c7c47008f5da1753e5fac89f410f028beaa4c64d1391d7e0c9cb92749a8122771089458668a88d34c3a98b2c29567490b0f0017422ca50bdc90233e46a5f2d050a9053803bfffdd579e1942c5612078aef1eb6dd2549952fef61318888f2dce77f0ea1ec1ce7f9e86124d284f03ab8e01c8009879945745bc2071ff8756819dc7f3de77cac02ea81b99a093286661ceefd005094cc6a43968ff34f77df86fa7970b1054180f7b5ce12b301e2ddf2e7565ed665e7f2dff667ba89f59fb1c0fa8be80d9b613a67feeae936147293046be12d8a2351ae9cd0d38c02a36f1018fb8b957d1ccd12466e2d29f4a339acb88b04daa5061f10fa4400fc01f5e700cfc57c7bb8451732c0c12de5f7857e3a9a71461e55ab2a7fe4ab9607eb9edfa67fb7a7506d89341cc46ad8f816c2d5ff8323aa83920302a668e417463c566818555416c80133f10392504a2761c616853a0da4921688bb2c87f6d81051c48ce6abae2a3294963265f3b339079652f986ddd6134c3cc5bdc0e91853de84297f5dad9fdea32f291f1b83077df25b03c899e8265fd0a8edf5afe669f58e5ecca2560e4e48ce3872dc7392ad24192c1d68a181a063f52c864be653f8d42b77bc6bc3706cb506acb77c53b6f8b6c5ce47f16a1513d68bf98104e2ace80a06961f034507b715e69a50c5cdf25c937ebd9932b90cd743d39516663018814c8307524e078aa3f366c9054d8c248b5baa228ded524e618ea56e867c5520d7031d3a50cde46aa8cde794e9f138e6e0b9d4649ce66b500fce187c156b982a416549faea3a320cff6b8372674331e4b552792d1f1f9364312fcea8adfe22daa3651ebdaf4739f2f1d419bfaf3fdabc5a6488aa5d87ce73bd1871a4a331db837dd673d8b785dcbe58b490a5f323d94373db8421be68fc92cbb72a3fa1bc797643ce1804a525751f5822d9d4cc547a66fd4dc82cbbc73fae317ca4b6cf92746cfc881b9da6368f38b35f764c827112080c187abaa69e13e81c0f85ed44d6e894f461bfba85a7fd35c220618705e0f143e3827d3e4747a9deadc66d777b68bc35dd4b81c7c4c9773b656983ba34fc7a06739f1b1ab393d9
8654f8385139c01b198242f8fa23b5c7b1806114ad7ba5d65ef71ee66143d60770df60d9a54b1536aa67488cd471cfd6a09eeac061da9e85a106e6b041881cc4a5c020000000000000000000000000000000000000000000000000000000000ecef3cbbdb84cdf004d2638f2b644d355544fa18aba30c48f8b6396e770919d48d38d1863bc3e3009228f49eb91a69b72a8400f3ece13ed0ac56902f2ba8be8ea35fff320987bc775921d24e952133635a156139aee630042dca5ad1b4f630fc1f225ce6e726f94144d3701b22166365dfb4d47d73e4b29bcddeac830c5391e40df56a5778fa664155529e0b7667fa007a41b82b58f990c73296197ce603d3f8fffffffffffffff7fffffffdfffffffffffffffffffffffffff7ffbfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff808fd644cb30a5f62dfd042cab8a48c23d314a775f8df5161911024253713d248c301a820305aa8d42bd3bfd864ee48c14ca94ce1f738f8cd5529b2d47b7d02f3c6a912b9f7c428e03296e7679d40b994b5aceb635dc9bdeb1bf3ab54928955c9b894b0000000000
`
)
func decodeTestResponses(data string, result cltypes.ObjectSSZ, prefixBytes uint8) {
msg, err := hex.DecodeString(data)
if err != nil {
fmt.Printf("unable to decode string into byte slice: %v", err)
return
}
fmt.Printf("Hex Packet: %x\n", msg)
// Get the size of the object.
ln := result.SizeSSZ()
fmt.Printf("size: %d\n", ln)
// Read first six bytes.
r := bytes.NewReader(msg)
r.Read(make([]byte, prefixBytes))
// Now we can construct the snappy reader.
sr := snappy.NewReader(r)
decompressed := make([]byte, ln)
// Do the snappy decompression.
if _, err := io.ReadFull(sr, decompressed); err != nil {
fmt.Printf("unable to decompress data: %v\n", err)
return
}
// Unmarshal into our result object.
err = result.UnmarshalSSZ(decompressed)
if err != nil {
fmt.Printf("unable to unmarshall data: %v\n", err)
return
}
fmt.Printf("decoded object: %+v\n", result)
}
func main() {
decodeTestResponses(metadataV1Response, &cltypes.MetadataV1{}, 1)
decodeTestResponses(metadataV2Response, &cltypes.MetadataV2{}, 1) // Doesn't work.
decodeTestResponses(finalityUpdateResponse, &cltypes.LightClientFinalityUpdate{}, 6)
decodeTestResponses(optimisticUpdateResponse, &cltypes.LightClientOptimisticUpdate{}, 6)
decodeTestResponses(strings.ReplaceAll(lightClientUpdate, "\n", ""), &cltypes.LightClientUpdate{}, 7)
}