Keydonix / uniswap-oracle

A general purpose price feed oracle built on Uniswap v2 that uses merkle proofs under the hood.
The Unlicense
256 stars 58 forks source link

REN/WETH sushiswap price fetch error #31

Open r2moon opened 2 years ago

r2moon commented 2 years ago

I tried to get REN(https://etherscan.io/token/0x408e41876cccdc0f92210600ef50372656052a38) price in WETH(https://etherscan.io/token/0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2).

Sushi Factory: https://etherscan.io/address/0xc0aee478e3658e2610c5f7a4a2e1777ce9e4f2ac

I got Returned error: execution reverted: invalid extension node error

The other tokens on sushiswap are working correctly, This is very wierd.

MicahZoltu commented 2 years ago

Is there anything special or out of the ordinary about the REN:ETH Uniswap pool such as little to no trading history?

IIRC, there is a known issue where it won't correctly validate a proof for a non-existent value. This can happen if no one has traded on the market yet (or maybe 2 trades are necessary, I forget).

r2moon commented 2 years ago

REN:ETH Uniswap price work, but has lower liquidity than sushiswap.

According to CMC market result, uniswap volume is around 800k, and sushiswap volume is 3 mm.

you can check details here, https://coinmarketcap.com/currencies/ren/markets/

Here is token txs on sushiswap REN/ETN pool https://etherscan.io/address/0x611CDe65deA90918c0078ac0400A72B0D25B9bb1#tokentxns

MicahZoltu commented 2 years ago

Are you using the SDK to generate the proof?

r2moon commented 2 years ago

Yes

MicahZoltu commented 2 years ago

Can you share the proof here?

r2moon commented 2 years ago

this is proof for block #13263820

**0x0000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000021e0000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc200000000000000000000000000000000000000000000000000000000000000c00000000000000000000000000000000000000000000000000000000000000320000000000000000000000000000000000000000000000000000000000000116000000000000000000000000000000000000000000000000000000000000016800000000000000000000000000000000000000000000000000000000000001c200000000000000000000000000000000000000000000000000000000000000224f90221a0706c8fe3354f7e6d1dc721c28f203d4189d6095cc737d69811003008ab19c3c0a01dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347945a0b54d5dc17e0aadc383d2db43b0a0d3e029c4ca02d2a182271287cf3621dd905561bdc83cfb94ff47cf3d75268b55a4406befe23a0b841cb266199c8e8801e0cb4921620ec886a9005ad7bc041d2635e819bd3badfa04b466bc1d2e6484b4b5aa181d4f82aac2a66f36e5405491101abc034a2654509b90100802a014241a71670c0808702a03018042104096128c8016000991d106c026011150d48f058da1c004000588210e1911d420080023a812108c402cd6a82203008014004488118018808c21188d82040208216b2cd0c6012216bc2e2c48a4434a05a000a200b626c28803050000381ccc803841ec4880264ccc0280570142c6cda988008801f04051291410e0217026004211101b9c3200a49000a0842899401209205c01d0988222428a18281f09c8102da412081a00241000060320c158a10a8d050010249004056200082004010119e008303e816292012a85e308760e1246812982c2c8a850300080012040d3286880a481002a1c10062689048010306d0018720740b804b8a9c83ca63cc8401c9c380837e99d0846148bba799d883010a08846765746888676f312e31362e38856c696e7578a0fcaf464c2f07c6f29caa7e37ba97d049e65d8cbe9a363979687ff22a5bb64b2b882a49bd21b43ecaca8517c5924047000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e09f90e06f90211a07911d642363a74a5f1a100948ed5ef6b8d333d9f61220c4c80514e52a55868f4a0dd686768c2bc5f3fc89400a22943bdce7f8fb9b4998239df5a27bf99eb819aa0a0512b98822fb1adfaeaa9f5e256afce6a1267117cafb34de351aa2165e47eaedea0ded6ca5b941fc6b4e1d79cd8c4f9d39e5a61f4a8d9f3c6b1114182ebcaa79155a0cd780214b92ba809417915024eb0e7cbc2f9ff5cca2056a09500ea3033b4db4ba080dd16e20784c7f25f631524541efd85e14f35378d84e27d81421d6f9e4ad1daa07b42b51cb83de0575e76847ec000ba434f87b83a714b778d8a5dbd54da8db6c2a05c7da4b2d83828de9fdd7edb9f9e77cca190cd672270df326b1a41f7aa76fceea0dc62a42886489fdd55464607279b3b35a4ec2dd76ff14f1dc4fd0ab99f41b5f9a0b4c571523bc917397dfbd5396efccfab7a47c38141a23bf3cfa8f78b01fac3eba059d622bae5c2c208347cb2d182e66d5a6e1153c4f5963469b74829f67475d626a008d8d3e6b2505a79f97026950c676bebdce1368b3597c960ffdf618f546cc749a0fa6574b832e225525db7eae3f7317eb6396ed2ca8708eebe8590dcca2ca80683a05526a94c29727ec584657323e91ff809afb968f3d40c4977df677ff6d32711efa0b6ac8fb97e68aec51cabc1649a01a40cff419214ffc90b1ef96fb522dc13469aa0b9b445e3620b4b9556a9a6244bb9d27686e02d3c97c3920fc99dc02ea237b8b980f90211a0e4487f19484104e6fde313b87a408f6045f8fbd42f14e78d28fd68250ecbecbda075b03e592f01d91ede53c4d1c1a590dfd5f97aa5d4a6a6f5c578bdf23f264590a0025acd62626f5f5885766b0379f113c16f9c7742cd95c56bf5d86b8d23fe5c03a0b8f096d8c778f8a76f92c943451bdc23311c4586bea919b36ab71526807c8e11a08954e07ef4e517b156d19743b65debd1bbe9f08bf71efaf7753764be426c323ba00f69916ec23f1e4340d9b40b74c87c8307174836096ae34fbaab71310e1e5445a0639ac1d2c2e1fdec98d05ee8eca216b4ce45bb60ae1c660447583f7a8ddc3ddfa0da698aee1aaebe712f713b30d403707d4877185585dcb306927c28163cd352c8a045a5dc43a0518a026c2706ffc03c5bc35ce5995bb61710888dc0e392c626d13ea0034230a3e0449b672b370902f9950925a9e7b70f231c167dd0989dfd36dafa5ea073206a1ecb5cafed47f4a0210afc30497d0a56b5cd9a1755d24befa5562e85f4a0db8745a7f1abe180edd55e719dc61e4a199d17ac54f49011324206e0d58ba25aa0ba22d61dcc543d47a775f5c72ee86a0e0b2d952725d6e93ca235338927054ed7a0c80429ee2d5b1fff0508df7b4f167b765afbfebfd23e7169f039df2075762072a020a73abce60e604286862436e592e46abdd345e4f0aa710405425bf4f82f7f1ba045811af6319c982bc1e098b07af9b56bee8278d0eed5bc457afedf4068d6550e80f90211a0b57e4303e093c6dada116ec27a16296440335878206f78ecf789100bc0fa5d71a07484f1db4cfb782aa22e06c33b1519bdab5527a0065d688ac692400f6a3684d2a081b755a9ef0c527d6e7b5f4c051e34677aeb4f8df7185a66a44819aae150be21a00210c51fd536bf89210965c3b0203c971883ad8578fb9a034fb5259451f5acd2a09aa977c5c078e8dc4fa1a776f5082e1baeacbbdb6655c71c0e141931b556aad2a0f6c548a6af503082f68484324e904e70553aaef490f31beec1e32cb6f4b02a07a065dc08a0e8579fb37c68661d87494be3015a68ca1f7fa9ff3e15a2421f382926a0d0b84d15542812c40121ed7e9f9b5839d7d2a75b339c0b51a4ef7201d923a30ea0ddfbe1e1b8fee53b2adfbbafe822a9d769c24b3509d0b5ccee09c4f4001307a7a09272d13091df70710f4de19f07d8b49c972e27395481635d289ff4cb52946c58a087e2ec6818129317bb343848ec7785702e7ef916389df48022a9fe436bde8fc9a0d5f0fbdfbdd87e318b369212978caa8ca7348383ae7d064832a3f6ff23f7c865a08e2832affac5cfbd5c1f342f543cc854e14d354030a965dad0827372a89722e0a08ad3a6dd679d789dddc7c10b2d2d30f0f8c7d6e991edab1b03c502e09bfffa8fa06bb9561d1a54ace048ac0e0879ef2f0e99d383046b43f0d340bb641018aefa75a07a023c640abc14300346e271ce016ca0b4a837d8a87f49fe6f1daf1498690b8380f90211a0bfd778ca38928201c4ce41b3aed12e675b5b37b3f9dfd3335d3a0f225e0bfd70a08b9ac58a5c5bf5d29a1bce3b0c5e1ee208da89fb9f99e9cede66902545c7d01da0d44c3e171045ae1d56785f988ef77f65e4c51352c61c0d6f0c1bf01704024b8ea04767fe83a0a9b52f702fd1c3da64ac0d3367557eab877f65f5db20376d015e05a0436c67d62e1a1d1e00f20c96ee04cd519558b46b42de0bb350ff6db0c6090f4da0c30db729a6b2c4708578e2ab53ef7c75a7ed42e6a63baff56d41ab4ef1f03f4aa09889ae2a54a7191ae87d6b061e8ce2538d62927ca4cf7b4a271c057b2d337a32a026c1cf596f726910317bdf6b3adfdeefc282c711d7be0de367551069cb3516fea0250286765248cb19b0fb8c412e10353a2ec50267b7cb04d955feaf10bf21bc6ca0fd4aebc288e95b5451b4f06d7708daff0e165e4169a5b195b3f0ed5b79b828d8a0f773e95b621a62a596f19c43b99ff34ed3c0aa82b2335b39f7c2596bcbb7883fa0c5a014c25fbd9fc7a70b0cdd8560e98a524fabf5099f458c01ead4e9e5ba3309a09857c6ba46725ee2ac4e1d9980f1248e6195a0e554f425485c80c974078cc1c4a058f14f76c02fd5988fdc58709a7c95f991873dd9b36e7a62d6208b3e97210092a0eae5d42fb600a6dc6c8ed069c639d4ee4de69e858c27ea8dbd3588ef333fa233a068425e81624b21fce3632ff15db8e80f4fa6a6ccaa20427b15d2fd407878b00f80f90211a01a73dbb2e1fb1ff436dbd2fd19c434082199a6b5e4843c43cf93c1118762c695a0cfdf4299306ccf711d139b7174b324a610384a613b4502ed9453d9b477f42193a020063d413bec945db892b23010e690402424e2982c3be1f95df122d641f71beca0e5a3faf59ca594806ff37585c740896c33ee2eb918d6db0066005d3d83a60f5ba0d2f218200ba876c27dbcaf0e0934bee42ede2d279ee35b57e287291f95b695d1a05fbae2088f932dde6501ec0b658bd208f86ca2ad6d7de41a873763ef1bc513d2a001c33e30a3f3977f5cbf6ed3059ba47b7fdd6ddc8424fe46097f361f827b57e8a053201cb5da48b36d7f82d84361b38e6067f34cc1d122b8b47143cf233ff8169ea070a476e27ce5a9d6986b48129bf0c2b1e3c96d2952a0b1ae68c9941118656d4aa0d0bad9b88528c033c18d431f0dbd02af5c18450ffc1200e44c9290ffd0a1f8b4a0371535c8e657c34f97954e74a71f5ccd56eedcdaa44712036cb0ac0255258394a08b8716c100ada0f693fcade904439032a7eb9a58cb5fba32a240b02cb6269cb2a0ad6ce0edce9d965ce371fec6081b1b945c7a51b30499a1949fd2fff49490fd35a05a412de5f1b7b96c1b6cb38a5a1a0e5f88b2a82e91cc281fa9ab22b7238a63bfa09c46c9688b9cc170220b0e15048103f3726338eb7927b3096a7c02d7dca97d8fa0de03ef34590c5b02cbd9613b6ca34bdde2a39dffd787006fa258fcf8068af14a80f90211a041642d3ccae217ede672bc2cd3b1076e3cfde40e7ed963066c42e4e585181819a0280af7997dff4bcb1b9fa31e15a198ffbc2f906dc946a7873fc5072ca9e078a1a041a8adddec0cc131a89ad571d28897bd3b27fd0520331f105de37f2dd8cbceafa0933a94b36b415f5c9c0bfd34970e0369a5a28f02d07dc74c06ce88684dfdba29a0c183905ba126e974c270de76497096b793dddd8365e37f0faefbe5b1c795ed61a05250f041f67fa76ff2ed675b9c83954d9ede8433651b8967ac5aa07e54c9db9da0ab462a7d4633c0e6448293d43c1856a438e22ff0cf87e9d280d616026e55ebeaa0a3d1eb3a6ab90592eb809174bfc5213a0b84945e39aedef344c02e2fd1529c52a0d9f045a36a6616a4d1dbc974e429ff1045846566b3377caa8b50263d2e414ec9a0cf8006299bab2065963e2490324b8b3fa3193e38fff7502a1edca50b932ab603a0fff766f61d14da6db97e19c989c797cf3001884c7c2e3a778c9c9b7face4615ba0d2cf78c73609ee078c8feda2128202a47a18b5be7ebce5cdc563c5588d578007a0ce6218f7ee2c790b6c6b837b03e96ce5496bd8ec6ff01d16fc118390a5386be5a0f5ce5eb932c9a6167f64faba0487fde3b341956a4e865bfc385d57f4b9cc0350a04b21a58cad5cca2e93f4c952528d8726ecc5ee688e22e801374f5e83b0074bf3a0282ff9b0dcff22a66e18147ac65da6c6060bd92bd9fb8b97dafb0881c25dbc7b80f8d18080a0aa99cdfc97bf3e5d588fd2c0c3b3663cb0aef9eb5b44f1f7f3e30bc9e4cac7aca0f82ecf4788ebfa030da0e21c19244468905192fdf1408a01cff34f287cd43281a0d81789cc5790425ff0e6780b1c7950cd98811b7a0530e05abaa9eec84c5ea7358080a02ff9c309d21b29a00e1307beccf3e68b499cb48ad819456eebb4e735519ce72c808080a09b1663be3cb10ed73fb67db0176215c6f75292eba2ffceb92aa1d738d8e1a6cb8080a01ab9d1179143d0d94eb07fc5283249e3ad801daecac0867a613b91aac0df04e68080f851808080a0e0eaacfd7031c8741a35e7cdb508cd4aac2464bb806643d99f329fef9c8a0528808080808080a09f297972ab61708fad301497f6b1bf520fe73211aaba5dc0d88e1ef2d669834f808080808080f8669d204be3b937da5d888e489f3e2bdaa67a77a40fb3c277b5cc9fa64e83c0b846f8440180a09d547dbd3eb6e85a65730f6ba16b072eee8cf04f7dfef084821295ae3b20c66da0cd82e2d9daddbf51cbce8d5429a0996e16fc670c4056566f19cf8864ad45a746000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000004e2f904dff90211a029f41909cffa92a752e3032c96dc01451ad772ee8edf878fce6068e0e54ac0e2a0b9e853def97e9143b0e6fe7ad406c6afdc4f1c48e6422e4bd532bcd975f5cea5a01b90751c924a0fdee65e4628b30a229cbd762b30fa119ff773574fbda0ef4968a02c7bccbd5689d424f645d684f60045d410d46f29c3b7af21f287abe3e74c33f0a05cfddfaaa1a580cdbd27252eb86a59f7f38ca9a31a7cb0cb436bccada2f64e48a09c492afb53f4528b2f52c9af0f91dfbcb35cbf708cf2782c239a59ec4d5da1ffa07cb5ccdb7000634098ae57a84733b6ce2d1599d0c1ae3cb3f72f8db20ee691b2a08fd4fbe23ff81a95e63a19a85564d13990c7ecb040286d1d9c79790c1fa848b4a03a410baf02c4f2b23abcadc5de069dd4aaadd59a793d15a7d8fe58a9b16c4c5ba0eb48dbd4b138fa59c1c07342c393a8c4e6a819291933f6e2bd4c23178f9ac90ba0681e333bf7ce37fe43511b37bc7bdf04379a340e126850c39aab339dcddf0b63a0ad219e459c41bc991dc1f186ccd9705758d82ad30c79ca95c87902793467a5e2a0d60dbc9b84eae5dc2fd94c0f3fb367f399987ff2ab43ca441c4c96a827ff3996a0cc6da13d383569ac68f9b31e9e5c3d47ac8d233eb4a109ae6a23c73ac4bf5f88a0a84f928d146533cd72567797412186e090daeed728217989aa7a8ae5aac82eada05cb2773a2e18e4d68ea6b050a0b639b711dc6905710f90356aa2a4c8df5ef7a280f90211a0e71d918ccbb59add0c74a34d442e92643c494cde42255823e2ee1c50b48d01d9a07891a3149d16e8aab944532cfbed4c25a90a1b9c06b4f2e08525f40c5e755e57a0070d76b70b7929a2eac38741e7891349cccee59cca62c9ad997c3af199ffdf25a04120aee71a24eb72d4d46e0cb77399dcac0d2a5f8918c9cf2f0b068b70ddb578a09abdba3139a026a63d39d0d3e5408099687e5664ee257d3025f29b7ce6f66cd0a08968c0f1ac4313aa0206fdbfd6266dbb281b4f87bd61689eecc0052461c90c8da0a1f046ccf5e6cff079f8e54b7b3d71a2be24d23ecfe003c1749585ce5c77eb73a04aab0ad3a92396696d97fca4f4c7120605096fb33570cfad8ad5fd6d4bb1f370a036f12372e629c451a5e73d4595a3b8a2a7d757069fea176b7c6179894e59ab10a0ecd52ae64c8135da60c5b3949870a5ccfb27348a0e070ad065f2c50dead904d1a02ab321310a85c9fac63f681eaedb34dc6cd69227c422439f3aefd16dfc009475a0ddf5e20c10a9b40909f5fff417bce7383b3009a067c60e2d8faf26c92656ee0ca0a608066e0be9444eeb172a79351c002965cd6d96db0d504ebe5f7474da914cb9a0055d93ff28440ec0632a73dfa08bbb3d87e34c65ed4ecaeaba057b7d1668c518a09ad30dabf74679c1aac7c0b833d1202e860b9bdfdf8923b72a5004b9b9071f9ca0b7ea0eb01a65adefd082951c431a4d39b5ad8264344f519cfd72d94785f7125e80f87180808080a00a6cdeb223d59cf5eda38d4b852787199727357ee74d09be97e399d9b2d3d1278080808080808080a01cb20c64eee559ea5cb718661b43b388e0c2a816f8238e893726ce45a6e84d0a80a0389a3db5ac5c64bcaa93e54ba319bd33b7f23a024f05706833a2570d0e521ff780f8429f37a9fe364faab93b216da50a3214154f22a0a2b415b23a84c8169e8b636ee3a1a06148b9e8000000000069e6371f367bcf0f01000000063cda4660555d5a2ea19c0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000566f90563f90211a029f41909cffa92a752e3032c96dc01451ad772ee8edf878fce6068e0e54ac0e2a0b9e853def97e9143b0e6fe7ad406c6afdc4f1c48e6422e4bd532bcd975f5cea5a01b90751c924a0fdee65e4628b30a229cbd762b30fa119ff773574fbda0ef4968a02c7bccbd5689d424f645d684f60045d410d46f29c3b7af21f287abe3e74c33f0a05cfddfaaa1a580cdbd27252eb86a59f7f38ca9a31a7cb0cb436bccada2f64e48a09c492afb53f4528b2f52c9af0f91dfbcb35cbf708cf2782c239a59ec4d5da1ffa07cb5ccdb7000634098ae57a84733b6ce2d1599d0c1ae3cb3f72f8db20ee691b2a08fd4fbe23ff81a95e63a19a85564d13990c7ecb040286d1d9c79790c1fa848b4a03a410baf02c4f2b23abcadc5de069dd4aaadd59a793d15a7d8fe58a9b16c4c5ba0eb48dbd4b138fa59c1c07342c393a8c4e6a819291933f6e2bd4c23178f9ac90ba0681e333bf7ce37fe43511b37bc7bdf04379a340e126850c39aab339dcddf0b63a0ad219e459c41bc991dc1f186ccd9705758d82ad30c79ca95c87902793467a5e2a0d60dbc9b84eae5dc2fd94c0f3fb367f399987ff2ab43ca441c4c96a827ff3996a0cc6da13d383569ac68f9b31e9e5c3d47ac8d233eb4a109ae6a23c73ac4bf5f88a0a84f928d146533cd72567797412186e090daeed728217989aa7a8ae5aac82eada05cb2773a2e18e4d68ea6b050a0b639b711dc6905710f90356aa2a4c8df5ef7a280f90211a06a02d45be9029a9e1615a389383fe632911c55e05a723101428848c8d42f8590a0422e960c4102bff0336fd436ad33651daa48fcd09e786ab0d66f571fa98ce0bba0688f1d26ad0558a24ff41d951c27147c471924b54099f91f4eb65f3a1674a8d7a0850977173e6c37b0a842baf72b55511b35f5448f4e49dbc7da88f7d3728c6421a00f14e44c97b829652a33a97cb693ee1c8f1af85ad0edbc233e8096e89ffde0b9a0b842075c5c78a854c95c06ad42dc0472cf4ce4a2d6fec4f316ee63f3980399b2a035eab520928240420a2bb9733f0a7090a7d8278fbb9accc28de10a471e82d08ea04fffc9c0b91115ec9e949c07a7390b6dff33ef3be1b2c94ecb6d9c6d51a3c0f4a0809ee7b2ebe82d1ee8113bf73036a7e7910eab07a371362d793904b0efef9fa0a0527472c40a58a6d11887e1da5b0e77f905c5268ce88fc9e68962906cf36b7b8da034904a2ad75cf8dac178c45c269164378c568b543eeef84fa9cc2d3165595ea2a000442b7bd2ad5846683fcd4a629abd604f8f6ed989f691070ca51fa1952ef0b6a03172a79c3e0e3cafcb67ab6e8f49ec1be2acdb51e4a53380e3c9160e385f59d0a06bbaf4319636ef3ce306b88127e605dbd743ea573eeeeff51eae978898b2bdeba09af890cfbdac54f32c80e96240f99f7511a8128470d7288f266d99b6fd629f98a0c3f0df14bc8c778a5fcc6197e47f2522e38be9780aaae292f8f143148e9b6dc780f89180a0b41478a27cdf9f36aefe6fc6019a9f4d311ae3945f53f78d2513bf97e43b34d98080a00c57bd9a80d4d9e003d11ce3fca5416ccd3eaec4f51ae62d084589c18a5fdf2a8080a0745f3d58af667945cb406b61ba8e6568618ffa764b75ae51985743ac4a0c731080a00a753439ec29145148e411b506547150f093fca45e3a72b605eb3e64d93472ab80808080808080e215a0288613ab0d7c281596775b9ed657542d42287bd6ad8436e327d3fe42a5e09d20f8518080a0ffb7b9688bdb21ac3910722d220fe55c29182f60e4d5e3c6f199cdbf2e1d781b80a074b75c602959d835556bf118c6ce84c96331860685d0fec444576e4e40c9aebc808080808080808080808080f19e30171b6c0c960b71a7020d9f60077f6af931a8bbf590da0223dacf75c7af9190376a306bb221ca220a3e8a37c0a795b000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000587f90584f90211a029f41909cffa92a752e3032c96dc01451ad772ee8edf878fce6068e0e54ac0e2a0b9e853def97e9143b0e6fe7ad406c6afdc4f1c48e6422e4bd532bcd975f5cea5a01b90751c924a0fdee65e4628b30a229cbd762b30fa119ff773574fbda0ef4968a02c7bccbd5689d424f645d684f60045d410d46f29c3b7af21f287abe3e74c33f0a05cfddfaaa1a580cdbd27252eb86a59f7f38ca9a31a7cb0cb436bccada2f64e48a09c492afb53f4528b2f52c9af0f91dfbcb35cbf708cf2782c239a59ec4d5da1ffa07cb5ccdb7000634098ae57a84733b6ce2d1599d0c1ae3cb3f72f8db20ee691b2a08fd4fbe23ff81a95e63a19a85564d13990c7ecb040286d1d9c79790c1fa848b4a03a410baf02c4f2b23abcadc5de069dd4aaadd59a793d15a7d8fe58a9b16c4c5ba0eb48dbd4b138fa59c1c07342c393a8c4e6a819291933f6e2bd4c23178f9ac90ba0681e333bf7ce37fe43511b37bc7bdf04379a340e126850c39aab339dcddf0b63a0ad219e459c41bc991dc1f186ccd9705758d82ad30c79ca95c87902793467a5e2a0d60dbc9b84eae5dc2fd94c0f3fb367f399987ff2ab43ca441c4c96a827ff3996a0cc6da13d383569ac68f9b31e9e5c3d47ac8d233eb4a109ae6a23c73ac4bf5f88a0a84f928d146533cd72567797412186e090daeed728217989aa7a8ae5aac82eada05cb2773a2e18e4d68ea6b050a0b639b711dc6905710f90356aa2a4c8df5ef7a280f90211a0e50f0440b4c3a01874584a7593714a481bbc08459a7f27a5976df207ffd0a77fa0bf5d4aa183f77f466c0e941b80d78521146cdcc7fd3f91e267104f6705310749a05e87b69e3b8b91fa1e8e97493d743fa6e62b81e5c55469fd23f4dd1c6e762399a01b95082d631a428173793a0a39ac84011422a3250c37de367399e6eea2334c2ea0daf05d0e6994b5637088f7829538ff4b9766057b14e76d6e95c6de5e6d0d4d77a08a4590730b5d435501a5c179f9fc10c2a6988bf207d0337429947091022e7f2ba0b8643465402d690e255bd6fe9a30c03eaf37f2d82d9bf9935457876f899338dda054a91425f65ebdc087a3b437ad5b8d8de19f9b0b109fb5f95805192c283cea1ca0d126ce770abc6ed63cd98f59429c575aea19dfb939a67b04d4357956bcbc6aeea090704942fd8472011b3ab85c5ac76f5c2bda36f6918344af2612e5ea07a477caa00691b5274348fcc06dd17f85573d37e96937a5736d754a89d71fcb0a9c68f7b2a0be53ceb88f60aa58a79dc3693b07619ae39b29123bcd0967cffd5227421bd242a05b6adae30909400ff1a79be1278ee0f49c154af880fd19e4ff51379b6e5e8fd7a06cbcf5f97b359373effb1f14d8bf5db45937e5ce36bb64ebe1efdbe025568a0ba00c821cd0bb61b96156ae063de6205368ab33bdad578cd7c6acf76376363214c2a06948ba4efd30a5cb096356d7bc1d3cbe3e5429d1210f0efa446eae29a3cddd5f80f8d18080808080a0472b0c1b54d79f87a35b057707870279635de2e4c7aa750a69376121b737285fa0277b7f43572034affcd4ed1112fe8ccbdb7609c1d644c97c69a0e2d294c37e83a0f79fe47882cad9cbdbc664cba466a15fd2401ef74dc394bd04cdea47e1fbeb1e80a0bfd887dcbcf009c9f455ae404d59966721eb0188e9024a523fdac2f76c3cdb78a06c863c977fb363e20a7b401e92a383586fd7a82d836594abfb61b14723eca6f480a0207889a3713783453d9f97d62624bc5dfe7dc8c96a0d748fd744c1ac479c8bbf80808080f85180808080808080808080a0dabc8e80d2ef00765f0a45a0b97ae0108c6026b713a5f4e46ed2ddca9418718780a0f15f4b89b9eaeac2193f6748d7f3079d2ff0e1e8f643b0bd1fbffea302c5a7b480808080f59f207bb8d6351c1cf70c95a316cc6a92839c986682d98bc35f958f4883f9d2a8949317d665bf162cd9e9a473fc30781356834edc6600000000000000000000000000000000000000000000000000**

MicahZoltu commented 2 years ago

Hmm, a proof should be an object with 4 items in it. Perhaps you mean this is the data field for the transaction that is validating the proof?

interface Proof {
    readonly block: Uint8Array
    readonly accountProofNodesRlp: Uint8Array
    readonly reserveAndTimestampProofNodesRlp: Uint8Array
    readonly priceAccumulatorProofNodesRlp: Uint8Array
}
r2moon commented 2 years ago

We fork this, and upgraded solidity version to 0.8.7 Do you think this issue is related with solc version?

MicahZoltu commented 2 years ago

We fork this, and upgraded solidity version to 0.8.7 Do you think this issue is related with solc version?

It is possible, but it seems unlikely to be the source of the problem. A large amount of the code here is Yul, rather than Solidity, which means there is little room for optimizations by Solidity that could result in bytecode changes between versions.

r2moon commented 2 years ago

@MicahZoltu what is the purpose of this line? https://github.com/Keydonix/uniswap-oracle/blob/master/contracts/source/MerklePatriciaVerifier.sol#L57 I removed this line, and it returns correct price.

MicahZoltu commented 2 years ago

It has been a while since I have looked closely at this code, but I think that by removing that line you are allowing for invalid proofs. I believe in this scenario it means you have an extension node (length 2) in the proof, but the extension node doesn't actually have any extension.

There are two possibilities here:

  1. the proof is malformed in some way
  2. there is a bug in the proof validation code

Do you have the ability to generate the proof from a secondary source so we can see if both generate the same proof? For example, if you are generating the proof from Geth, can you generate it from Nethermind as well and compare the two? If they are the same, then we can blame it on a library bug.

If it is a library bug, I recommend caution at just removing that line. It is possible that removing it could allow invalid proofs to be validated and really we need to fix something else to correctly fix whatever the bug is.

The one problem here is that this code is only weakly maintained, so I'm not sure when (if ever) I'll get a chance to dig in on this deeply if it does turn out to be a bug in the library.

r2moon commented 2 years ago

@MicahZoltu Are you able to review our codebase?

MicahZoltu commented 2 years ago

If you can send me a link to a GitHub or GitLab repository where you are using the SDK I can check it out and make sure everything looks like it is being used correctly. I can't dedicate time to a full review or debugging session though. 😢

r2moon commented 2 years ago

@MicahZoltu Our code is private repo right now. Is it possible to chat using telegram or discord? thank you.

MicahZoltu commented 2 years ago

Micah#1337 on Discord

r2moon commented 2 years ago

@MicahZoltu sent request

davidinsuomi commented 1 year ago

Hi, we are facing similar issue, any update for "invalid extension node" error?

MicahZoltu commented 1 year ago

I don't believe we ever got to the bottom of this problem. Is your code that uses the library publicly available?

davidinsuomi commented 1 year ago

Yes, our code is publicly available at this link: MerklePatriciaVerifier.sol. We are using your library for Merkle Patricia Trie proof functionality.

We have deployed the test contract on the Goerli testnet, and you can find it here: Test Contract on Goerli.

For most of the time, it goes smoothly. However, we have encountered the "invalid extension node" error in some of our tests.

For your reference, here is a sample simulation that demonstrates the issue: Simulation Link.

We have obtained the proof data through the following command:

curl https://eth-goerli.g.alchemy.com/v2/demo \
  -X POST \
  -H "Content-Type: application/json" \
  -d '{"jsonrpc":"2.0","method":"eth_getProof","params":["0x76a43ef7cc3b49736951759494d2aee8cae1cdec",["0x5eab23faf5d36216321f982a2eb86f459814ef8f0067ef6e5e7fcabc0bf4d540"], "0x9312FB"],"id":1}'

the proof data is successfully verified through this repository: Verification Repo.

it seems there is a bug in the proof validation code. We appreciate any insights or assistance you can provide in resolving this problem.

MicahZoltu commented 1 year ago

There are a couple known edge cases that we never handled because they didn't come up in the Uniswap scenario, and this may be what you are running into if you are using it for other contracts.

One is that it doesn't support validation of unset/0 values. If you have a proof that some value is unset/0, then verification will incorrectly fail.

The other I only vaguely remember, but I think it had something to do with extension paths not being processed correctly in some cases. Quickly reading back over the docs for MPTs, I think the problem might be that I move the path pointer forward here: https://github.com/Keydonix/uniswap-oracle/blob/339c7521e2b42c752e842560fc941aed25fe2d6a/contracts/source/MerklePatriciaVerifier.sol#L51 and then below I check to see if there are still nibbles remaining in the path: https://github.com/Keydonix/uniswap-oracle/blob/339c7521e2b42c752e842560fc941aed25fe2d6a/contracts/source/MerklePatriciaVerifier.sol#L57

However, you could end up in a situation where the nibbles that are walked in the first call take us to the end of the path and there is nothing left to walk through, thus the function will return 0. A fix that you may want to try is to change the first line above to:

uint8 nibblesToTravers = _nibblesToTraverse(Rlp.toData(currentNodeList[0]), nibblePath, pathPtr);
pathPtr += nibblesToTraverse;

And then change the second line linked above to:

require(nibblesToTraverse != 0, "invalid extension node");
davidinsuomi commented 1 year ago

The proof succeeded after implementing the modifications you recommended. Thank you for your assistance

MicahZoltu commented 1 year ago

Glad to hear it! I recommend taking some time to verify that the suggested change is the correct behavior. I think it is, but I haven't looked at this code for a very long time so my confidence is low.