diff --git a/.gitignore b/.gitignore index e086cbf5..13572454 100644 --- a/.gitignore +++ b/.gitignore @@ -31,3 +31,7 @@ __pycache__ .utxo_data/ .timestamps_data/ .arguments*.json + +corelib +*.svg +*.txt diff --git a/packages/client/tests/data/full_169.json b/packages/client/tests/data/full_169.json index e068725f..fd682454 100644 --- a/packages/client/tests/data/full_169.json +++ b/packages/client/tests/data/full_169.json @@ -79,7 +79,7 @@ "cached": false }, "block_height": 9, - "median_time_past": 1231715347, + "median_time_past": 1231471428, "is_coinbase": true }, "witness": [] @@ -123,4 +123,4 @@ 1231731025 ] } -} +} \ No newline at end of file diff --git a/packages/client/tests/data/full_757738.json b/packages/client/tests/data/full_757738.json index 41f36311..d2f61b7e 100644 --- a/packages/client/tests/data/full_757738.json +++ b/packages/client/tests/data/full_757738.json @@ -94,7 +94,7 @@ "cached": false }, "block_height": 757660, - "median_time_past": 1665248564, + "median_time_past": 1665208251, "is_coinbase": false }, "witness": [ @@ -135,7 +135,7 @@ "cached": false }, "block_height": 757699, - "median_time_past": 1665248564, + "median_time_past": 1665233797, "is_coinbase": false }, "witness": [ @@ -181,7 +181,7 @@ "cached": false }, "block_height": 756675, - "median_time_past": 1665248564, + "median_time_past": 1664691125, "is_coinbase": false }, "witness": [] @@ -217,7 +217,7 @@ "cached": false }, "block_height": 757589, - "median_time_past": 1665248564, + "median_time_past": 1665176617, "is_coinbase": false }, "witness": [] @@ -253,7 +253,7 @@ "cached": false }, "block_height": 757688, - "median_time_past": 1665248564, + "median_time_past": 1665227303, "is_coinbase": false }, "witness": [] @@ -289,7 +289,7 @@ "cached": false }, "block_height": 757732, - "median_time_past": 1665248564, + "median_time_past": 1665244999, "is_coinbase": false }, "witness": [ @@ -340,7 +340,7 @@ "cached": false }, "block_height": 757735, - "median_time_past": 1665248564, + "median_time_past": 1665245937, "is_coinbase": false }, "witness": [ @@ -360,7 +360,7 @@ "cached": false }, "block_height": 757701, - "median_time_past": 1665248564, + "median_time_past": 1665233980, "is_coinbase": false }, "witness": [ @@ -399,7 +399,7 @@ "cached": false }, "block_height": 757445, - "median_time_past": 1665248564, + "median_time_past": 1665102619, "is_coinbase": false }, "witness": [ @@ -438,7 +438,7 @@ "cached": false }, "block_height": 757737, - "median_time_past": 1665248564, + "median_time_past": 1665248544, "is_coinbase": false }, "witness": [ @@ -480,7 +480,7 @@ "cached": false }, "block_height": 757735, - "median_time_past": 1665248564, + "median_time_past": 1665245937, "is_coinbase": false }, "witness": [ @@ -519,7 +519,7 @@ "cached": false }, "block_height": 757735, - "median_time_past": 1665248564, + "median_time_past": 1665245937, "is_coinbase": false }, "witness": [ @@ -558,7 +558,7 @@ "cached": false }, "block_height": 757395, - "median_time_past": 1665248564, + "median_time_past": 1665075678, "is_coinbase": false }, "witness": [ @@ -604,7 +604,7 @@ "cached": false }, "block_height": 757735, - "median_time_past": 1665248564, + "median_time_past": 1665245937, "is_coinbase": false }, "witness": [ @@ -643,7 +643,7 @@ "cached": false }, "block_height": 757732, - "median_time_past": 1665248564, + "median_time_past": 1665244999, "is_coinbase": false }, "witness": [ @@ -742,7 +742,7 @@ "cached": false }, "block_height": 757735, - "median_time_past": 1665248564, + "median_time_past": 1665245937, "is_coinbase": false }, "witness": [ @@ -776,7 +776,7 @@ "cached": false }, "block_height": 757737, - "median_time_past": 1665248564, + "median_time_past": 1665248544, "is_coinbase": false }, "witness": [ @@ -827,7 +827,7 @@ "cached": false }, "block_height": 757410, - "median_time_past": 1665248564, + "median_time_past": 1665083173, "is_coinbase": false }, "witness": [ @@ -849,7 +849,7 @@ "cached": false }, "block_height": 757598, - "median_time_past": 1665248564, + "median_time_past": 1665180740, "is_coinbase": false }, "witness": [ @@ -871,7 +871,7 @@ "cached": false }, "block_height": 757598, - "median_time_past": 1665248564, + "median_time_past": 1665180740, "is_coinbase": false }, "witness": [ @@ -893,7 +893,7 @@ "cached": false }, "block_height": 757598, - "median_time_past": 1665248564, + "median_time_past": 1665180740, "is_coinbase": false }, "witness": [ @@ -934,7 +934,7 @@ "cached": false }, "block_height": 756818, - "median_time_past": 1665248564, + "median_time_past": 1664770197, "is_coinbase": false }, "witness": [ @@ -954,7 +954,7 @@ "cached": false }, "block_height": 757690, - "median_time_past": 1665248564, + "median_time_past": 1665229191, "is_coinbase": false }, "witness": [ @@ -993,7 +993,7 @@ "cached": false }, "block_height": 757688, - "median_time_past": 1665248564, + "median_time_past": 1665227303, "is_coinbase": false }, "witness": [ @@ -1013,7 +1013,7 @@ "cached": false }, "block_height": 757736, - "median_time_past": 1665248564, + "median_time_past": 1665247316, "is_coinbase": false }, "witness": [ @@ -1047,7 +1047,7 @@ "cached": false }, "block_height": 757713, - "median_time_past": 1665248564, + "median_time_past": 1665239821, "is_coinbase": false }, "witness": [ @@ -1086,7 +1086,7 @@ "cached": false }, "block_height": 757731, - "median_time_past": 1665248564, + "median_time_past": 1665244854, "is_coinbase": false }, "witness": [ @@ -1200,7 +1200,7 @@ "cached": false }, "block_height": 757730, - "median_time_past": 1665248564, + "median_time_past": 1665244798, "is_coinbase": false }, "witness": [ @@ -1239,7 +1239,7 @@ "cached": false }, "block_height": 757714, - "median_time_past": 1665248564, + "median_time_past": 1665239866, "is_coinbase": false }, "witness": [ @@ -1290,7 +1290,7 @@ "cached": false }, "block_height": 757567, - "median_time_past": 1665248564, + "median_time_past": 1665162446, "is_coinbase": false }, "witness": [] @@ -1321,7 +1321,7 @@ "cached": false }, "block_height": 757731, - "median_time_past": 1665248564, + "median_time_past": 1665244854, "is_coinbase": false }, "witness": [ @@ -1341,7 +1341,7 @@ "cached": false }, "block_height": 757734, - "median_time_past": 1665248564, + "median_time_past": 1665245458, "is_coinbase": false }, "witness": [ @@ -1380,7 +1380,7 @@ "cached": false }, "block_height": 757663, - "median_time_past": 1665248564, + "median_time_past": 1665211477, "is_coinbase": false }, "witness": [ @@ -1419,7 +1419,7 @@ "cached": false }, "block_height": 757734, - "median_time_past": 1665248564, + "median_time_past": 1665245458, "is_coinbase": false }, "witness": [] @@ -1455,7 +1455,7 @@ "cached": false }, "block_height": 757735, - "median_time_past": 1665248564, + "median_time_past": 1665245937, "is_coinbase": false }, "witness": [ @@ -1475,7 +1475,7 @@ "cached": false }, "block_height": 757735, - "median_time_past": 1665248564, + "median_time_past": 1665245937, "is_coinbase": false }, "witness": [ @@ -1495,7 +1495,7 @@ "cached": false }, "block_height": 757735, - "median_time_past": 1665248564, + "median_time_past": 1665245937, "is_coinbase": false }, "witness": [ @@ -1529,7 +1529,7 @@ "cached": false }, "block_height": 757735, - "median_time_past": 1665248564, + "median_time_past": 1665245937, "is_coinbase": false }, "witness": [ @@ -1568,7 +1568,7 @@ "cached": false }, "block_height": 757407, - "median_time_past": 1665248564, + "median_time_past": 1665082390, "is_coinbase": false }, "witness": [ @@ -1588,7 +1588,7 @@ "cached": false }, "block_height": 757735, - "median_time_past": 1665248564, + "median_time_past": 1665245937, "is_coinbase": false }, "witness": [ @@ -1627,7 +1627,7 @@ "cached": false }, "block_height": 757737, - "median_time_past": 1665248564, + "median_time_past": 1665248544, "is_coinbase": false }, "witness": [ @@ -1661,7 +1661,7 @@ "cached": false }, "block_height": 757737, - "median_time_past": 1665248564, + "median_time_past": 1665248544, "is_coinbase": false }, "witness": [ @@ -1700,7 +1700,7 @@ "cached": false }, "block_height": 756916, - "median_time_past": 1665248564, + "median_time_past": 1664827239, "is_coinbase": false }, "witness": [ @@ -1734,7 +1734,7 @@ "cached": false }, "block_height": 748467, - "median_time_past": 1665248564, + "median_time_past": 1659914047, "is_coinbase": false }, "witness": [ @@ -1773,7 +1773,7 @@ "cached": false }, "block_height": 755815, - "median_time_past": 1665248564, + "median_time_past": 1664209392, "is_coinbase": false }, "witness": [ @@ -1817,7 +1817,7 @@ "cached": false }, "block_height": 757737, - "median_time_past": 1665248564, + "median_time_past": 1665248544, "is_coinbase": false }, "witness": [ @@ -1837,7 +1837,7 @@ "cached": false }, "block_height": 757717, - "median_time_past": 1665248564, + "median_time_past": 1665241008, "is_coinbase": false }, "witness": [ @@ -1871,7 +1871,7 @@ "cached": false }, "block_height": 757737, - "median_time_past": 1665248564, + "median_time_past": 1665248544, "is_coinbase": false }, "witness": [ @@ -1905,7 +1905,7 @@ "cached": false }, "block_height": 757712, - "median_time_past": 1665248564, + "median_time_past": 1665239259, "is_coinbase": false }, "witness": [ @@ -1944,7 +1944,7 @@ "cached": false }, "block_height": 757736, - "median_time_past": 1665248564, + "median_time_past": 1665247316, "is_coinbase": false }, "witness": [ @@ -1983,7 +1983,7 @@ "cached": false }, "block_height": 757692, - "median_time_past": 1665248564, + "median_time_past": 1665229539, "is_coinbase": false }, "witness": [ @@ -2022,7 +2022,7 @@ "cached": false }, "block_height": 757544, - "median_time_past": 1665248564, + "median_time_past": 1665154061, "is_coinbase": false }, "witness": [] @@ -2039,7 +2039,7 @@ "cached": false }, "block_height": 757735, - "median_time_past": 1665248564, + "median_time_past": 1665245937, "is_coinbase": false }, "witness": [] @@ -2070,7 +2070,7 @@ "cached": false }, "block_height": 757732, - "median_time_past": 1665248564, + "median_time_past": 1665244999, "is_coinbase": false }, "witness": [ @@ -2090,7 +2090,7 @@ "cached": false }, "block_height": 757703, - "median_time_past": 1665248564, + "median_time_past": 1665234821, "is_coinbase": false }, "witness": [ @@ -2110,7 +2110,7 @@ "cached": false }, "block_height": 757730, - "median_time_past": 1665248564, + "median_time_past": 1665244798, "is_coinbase": false }, "witness": [ @@ -2130,7 +2130,7 @@ "cached": false }, "block_height": 757730, - "median_time_past": 1665248564, + "median_time_past": 1665244798, "is_coinbase": false }, "witness": [ @@ -2150,7 +2150,7 @@ "cached": false }, "block_height": 757731, - "median_time_past": 1665248564, + "median_time_past": 1665244854, "is_coinbase": false }, "witness": [ @@ -2170,7 +2170,7 @@ "cached": false }, "block_height": 757731, - "median_time_past": 1665248564, + "median_time_past": 1665244854, "is_coinbase": false }, "witness": [ @@ -2244,7 +2244,7 @@ "cached": false }, "block_height": 757732, - "median_time_past": 1665248564, + "median_time_past": 1665244999, "is_coinbase": false }, "witness": [ @@ -2283,7 +2283,7 @@ "cached": false }, "block_height": 757732, - "median_time_past": 1665248564, + "median_time_past": 1665244999, "is_coinbase": false }, "witness": [ @@ -2322,7 +2322,7 @@ "cached": false }, "block_height": 757607, - "median_time_past": 1665248564, + "median_time_past": 1665184822, "is_coinbase": false }, "witness": [ @@ -2356,7 +2356,7 @@ "cached": false }, "block_height": 757154, - "median_time_past": 1665248564, + "median_time_past": 1664943071, "is_coinbase": false }, "witness": [ @@ -2379,7 +2379,7 @@ "cached": false }, "block_height": 757519, - "median_time_past": 1665248564, + "median_time_past": 1665144931, "is_coinbase": false }, "witness": [ @@ -2421,7 +2421,7 @@ "cached": false }, "block_height": 757737, - "median_time_past": 1665248564, + "median_time_past": 1665248544, "is_coinbase": false }, "witness": [] @@ -2438,7 +2438,7 @@ "cached": false }, "block_height": 755835, - "median_time_past": 1665248564, + "median_time_past": 1664223418, "is_coinbase": false }, "witness": [] @@ -2474,7 +2474,7 @@ "cached": false }, "block_height": 757703, - "median_time_past": 1665248564, + "median_time_past": 1665234821, "is_coinbase": false }, "witness": [ @@ -2513,7 +2513,7 @@ "cached": false }, "block_height": 757659, - "median_time_past": 1665248564, + "median_time_past": 1665207672, "is_coinbase": false }, "witness": [ @@ -2533,7 +2533,7 @@ "cached": false }, "block_height": 757333, - "median_time_past": 1665248564, + "median_time_past": 1665037199, "is_coinbase": false }, "witness": [ @@ -2572,7 +2572,7 @@ "cached": false }, "block_height": 756293, - "median_time_past": 1665248564, + "median_time_past": 1664501322, "is_coinbase": false }, "witness": [ @@ -2606,7 +2606,7 @@ "cached": false }, "block_height": 757548, - "median_time_past": 1665248564, + "median_time_past": 1665154785, "is_coinbase": false }, "witness": [ @@ -2626,7 +2626,7 @@ "cached": false }, "block_height": 757698, - "median_time_past": 1665248564, + "median_time_past": 1665233756, "is_coinbase": false }, "witness": [ @@ -2646,7 +2646,7 @@ "cached": false }, "block_height": 755893, - "median_time_past": 1665248564, + "median_time_past": 1664261545, "is_coinbase": false }, "witness": [ @@ -2666,7 +2666,7 @@ "cached": false }, "block_height": 757599, - "median_time_past": 1665248564, + "median_time_past": 1665180968, "is_coinbase": false }, "witness": [ @@ -2705,7 +2705,7 @@ "cached": false }, "block_height": 757728, - "median_time_past": 1665248564, + "median_time_past": 1665244370, "is_coinbase": false }, "witness": [ @@ -2746,7 +2746,7 @@ "cached": false }, "block_height": 757735, - "median_time_past": 1665248564, + "median_time_past": 1665245937, "is_coinbase": false }, "witness": [ @@ -2821,7 +2821,7 @@ "cached": false }, "block_height": 757735, - "median_time_past": 1665248564, + "median_time_past": 1665245937, "is_coinbase": false }, "witness": [] @@ -2857,7 +2857,7 @@ "cached": false }, "block_height": 757732, - "median_time_past": 1665248564, + "median_time_past": 1665244999, "is_coinbase": false }, "witness": [] @@ -2874,7 +2874,7 @@ "cached": false }, "block_height": 757732, - "median_time_past": 1665248564, + "median_time_past": 1665244999, "is_coinbase": false }, "witness": [] @@ -2910,7 +2910,7 @@ "cached": false }, "block_height": 757731, - "median_time_past": 1665248564, + "median_time_past": 1665244854, "is_coinbase": false }, "witness": [ @@ -2932,7 +2932,7 @@ "cached": false }, "block_height": 757732, - "median_time_past": 1665248564, + "median_time_past": 1665244999, "is_coinbase": false }, "witness": [ @@ -2968,7 +2968,7 @@ "cached": false }, "block_height": 725621, - "median_time_past": 1665248564, + "median_time_past": 1646241753, "is_coinbase": false }, "witness": [ @@ -3009,7 +3009,7 @@ "cached": false }, "block_height": 756789, - "median_time_past": 1665248564, + "median_time_past": 1664753392, "is_coinbase": false }, "witness": [] @@ -3026,7 +3026,7 @@ "cached": false }, "block_height": 757435, - "median_time_past": 1665248564, + "median_time_past": 1665097058, "is_coinbase": false }, "witness": [] @@ -3043,7 +3043,7 @@ "cached": false }, "block_height": 756797, - "median_time_past": 1665248564, + "median_time_past": 1664759545, "is_coinbase": false }, "witness": [] @@ -3060,7 +3060,7 @@ "cached": false }, "block_height": 757737, - "median_time_past": 1665248564, + "median_time_past": 1665248544, "is_coinbase": false }, "witness": [] @@ -3091,7 +3091,7 @@ "cached": false }, "block_height": 757737, - "median_time_past": 1665248564, + "median_time_past": 1665248544, "is_coinbase": false }, "witness": [ @@ -3135,4 +3135,4 @@ 1665249955 ] } -} +} \ No newline at end of file diff --git a/packages/client/tests/data/light_150012.json b/packages/client/tests/data/light_150012.json index a4979e1d..784b2ff8 100644 --- a/packages/client/tests/data/light_150012.json +++ b/packages/client/tests/data/light_150012.json @@ -53,4 +53,4 @@ 1319128988 ] } -} +} \ No newline at end of file diff --git a/packages/client/tests/data/light_169.json b/packages/client/tests/data/light_169.json index aed94478..01fc67f1 100644 --- a/packages/client/tests/data/light_169.json +++ b/packages/client/tests/data/light_169.json @@ -53,4 +53,4 @@ 1231731025 ] } -} +} \ No newline at end of file diff --git a/packages/client/tests/data/light_2015.json b/packages/client/tests/data/light_2015.json index 3c75807a..fef8113c 100644 --- a/packages/client/tests/data/light_2015.json +++ b/packages/client/tests/data/light_2015.json @@ -53,4 +53,4 @@ 1233063531 ] } -} +} \ No newline at end of file diff --git a/packages/client/tests/data/light_209999.json b/packages/client/tests/data/light_209999.json index ba6dc36e..27b819dc 100644 --- a/packages/client/tests/data/light_209999.json +++ b/packages/client/tests/data/light_209999.json @@ -53,4 +53,4 @@ 1354116278 ] } -} +} \ No newline at end of file diff --git a/packages/client/tests/data/light_24834.json b/packages/client/tests/data/light_24834.json index daf4a02c..1d841132 100644 --- a/packages/client/tests/data/light_24834.json +++ b/packages/client/tests/data/light_24834.json @@ -53,4 +53,4 @@ 1255321278 ] } -} +} \ No newline at end of file diff --git a/packages/client/tests/data/light_32255.json b/packages/client/tests/data/light_32255.json index f26d80ed..49e13238 100644 --- a/packages/client/tests/data/light_32255.json +++ b/packages/client/tests/data/light_32255.json @@ -53,4 +53,4 @@ 1262153464 ] } -} +} \ No newline at end of file diff --git a/packages/client/tests/data/light_403199.json b/packages/client/tests/data/light_403199.json index 1e88365f..bc120db5 100644 --- a/packages/client/tests/data/light_403199.json +++ b/packages/client/tests/data/light_403199.json @@ -53,4 +53,4 @@ 1458292068 ] } -} +} \ No newline at end of file diff --git a/packages/client/tests/data/light_478557.json b/packages/client/tests/data/light_478557.json index 8d04f3f9..317a3518 100644 --- a/packages/client/tests/data/light_478557.json +++ b/packages/client/tests/data/light_478557.json @@ -53,4 +53,4 @@ 1501593374 ] } -} +} \ No newline at end of file diff --git a/packages/client/tests/data/light_481823.json b/packages/client/tests/data/light_481823.json index 4340d44c..3e0432ef 100644 --- a/packages/client/tests/data/light_481823.json +++ b/packages/client/tests/data/light_481823.json @@ -53,4 +53,4 @@ 1503539857 ] } -} +} \ No newline at end of file diff --git a/packages/client/tests/data/light_489888.json b/packages/client/tests/data/light_489888.json index c5a0ab80..079da1f2 100644 --- a/packages/client/tests/data/light_489888.json +++ b/packages/client/tests/data/light_489888.json @@ -53,4 +53,4 @@ 1508040630 ] } -} +} \ No newline at end of file diff --git a/packages/client/tests/data/light_491406.json b/packages/client/tests/data/light_491406.json index b1bb4884..810d92bf 100644 --- a/packages/client/tests/data/light_491406.json +++ b/packages/client/tests/data/light_491406.json @@ -53,4 +53,4 @@ 1508808039 ] } -} +} \ No newline at end of file diff --git a/packages/client/tests/data/light_57042.json b/packages/client/tests/data/light_57042.json index b397f901..ed7710ac 100644 --- a/packages/client/tests/data/light_57042.json +++ b/packages/client/tests/data/light_57042.json @@ -53,4 +53,4 @@ 1274552191 ] } -} +} \ No newline at end of file diff --git a/packages/client/tests/data/light_629999.json b/packages/client/tests/data/light_629999.json index 3575e825..2732e284 100644 --- a/packages/client/tests/data/light_629999.json +++ b/packages/client/tests/data/light_629999.json @@ -53,4 +53,4 @@ 1589225023 ] } -} +} \ No newline at end of file diff --git a/packages/client/tests/data/light_709631.json b/packages/client/tests/data/light_709631.json index bbb0b71e..0b0852b4 100644 --- a/packages/client/tests/data/light_709631.json +++ b/packages/client/tests/data/light_709631.json @@ -53,4 +53,4 @@ 1636866927 ] } -} +} \ No newline at end of file diff --git a/packages/client/tests/data/light_72575.json b/packages/client/tests/data/light_72575.json index 117c5008..f89f73bb 100644 --- a/packages/client/tests/data/light_72575.json +++ b/packages/client/tests/data/light_72575.json @@ -53,4 +53,4 @@ 1281037595 ] } -} +} \ No newline at end of file diff --git a/packages/client/tests/data/light_757738.json b/packages/client/tests/data/light_757738.json index 4a44e877..713fdd08 100644 --- a/packages/client/tests/data/light_757738.json +++ b/packages/client/tests/data/light_757738.json @@ -53,4 +53,4 @@ 1665249955 ] } -} +} \ No newline at end of file diff --git a/packages/client/tests/data/light_757752.json b/packages/client/tests/data/light_757752.json index 812e8afb..9466aeb4 100644 --- a/packages/client/tests/data/light_757752.json +++ b/packages/client/tests/data/light_757752.json @@ -53,4 +53,4 @@ 1665258359 ] } -} +} \ No newline at end of file diff --git a/packages/client/tests/data/light_774627.json b/packages/client/tests/data/light_774627.json index 5875b810..0c48d921 100644 --- a/packages/client/tests/data/light_774627.json +++ b/packages/client/tests/data/light_774627.json @@ -53,4 +53,4 @@ 1675283913 ] } -} +} \ No newline at end of file diff --git a/packages/client/tests/data/light_839999.json b/packages/client/tests/data/light_839999.json index e900f76e..99b73bda 100644 --- a/packages/client/tests/data/light_839999.json +++ b/packages/client/tests/data/light_839999.json @@ -53,4 +53,4 @@ 1713571767 ] } -} +} \ No newline at end of file diff --git a/packages/client/tests/data/utreexo_169.json b/packages/client/tests/data/utreexo_169.json index 21357c40..e60c0c93 100644 --- a/packages/client/tests/data/utreexo_169.json +++ b/packages/client/tests/data/utreexo_169.json @@ -79,7 +79,7 @@ "cached": false }, "block_height": 9, - "median_time_past": 1231715347, + "median_time_past": 1231471428, "is_coinbase": true }, "witness": [] @@ -128,52 +128,68 @@ "roots": [ { "variant_id": 0, - "value": 2882110455212537199150847329139189370180884308630448423664876534647800285570 + "value": 2243729579132454921815355740493841076889575709816526684999662912394274975584 }, null, null, { "variant_id": 0, - "value": 3573318442823628698688744447509424720428330103349195003605624165773098457985 + "value": 2261147245204776368334862529741319780868768593345793617211117537122266238577 }, null, { "variant_id": 0, - "value": 2141436581899952417387992733190474614487735583759172096923723055693475913058 + "value": 1478944086323777945936459676941601959769102822055825304629072181687547875531 }, null, { "variant_id": 0, - "value": 1109945577787676694122063075523725670234208220203995252138303594406433041212 + "value": 619721724166206394862378867028287088626965757449429663146230416403718619093 }, null ] }, - "proofs": [], + "proofs": [ + { + "proof": [ + 274817076080541397502696906861536371115695596063526833550058573072108749115, + 1259176147345751145191111662219840526356501226618672639406065326898135902264, + 1848169735107995159136156318494866770346290350559572574934907975254450481704, + 2706681913355105973250866982294192611208835262570818334870601840808848384459, + 2214630919606246947408368640763197246751208900324012684012261556337212626757, + 1101985322418033002091130704802558308187225122297992534396475623983004812420, + 2729277592763167786852222424289031376235136104897643593004420518718352940231 + ], + "leaf_index": 8 + } + ], "expected": { "roots": [ - null, - null, { "variant_id": 0, - "value": 326045437641316698641304080517766751717151378713665098310018006040532820721 + "value": 2843980787531725946792369479988202437986876451050335501296002525043057800822 }, { "variant_id": 0, - "value": 3573318442823628698688744447509424720428330103349195003605624165773098457985 + "value": 3259667504329439104864108759538360061214302036282299607930636468007761714215 + }, + null, + { + "variant_id": 0, + "value": 2261147245204776368334862529741319780868768593345793617211117537122266238577 }, null, { "variant_id": 0, - "value": 2141436581899952417387992733190474614487735583759172096923723055693475913058 + "value": 1478944086323777945936459676941601959769102822055825304629072181687547875531 }, null, { "variant_id": 0, - "value": 2978354394154730692122824012135342169421706156188058452831198718128334603047 + "value": 1597678775304253472610727607736636075835427473969519327752899884098801800240 }, null ] } } -} +} \ No newline at end of file diff --git a/packages/consensus/src/types/utxo_set.cairo b/packages/consensus/src/types/utxo_set.cairo index 6686d2da..f784c1c6 100644 --- a/packages/consensus/src/types/utxo_set.cairo +++ b/packages/consensus/src/types/utxo_set.cairo @@ -149,11 +149,9 @@ mod tests { fn test_not_include_unspendable_utxo() { let mut utxo_set: UtxoSet = Default::default(); utxo_set.add(dummy_outpoint(0, false)).unwrap(); - let _ = utxo_set.add(dummy_unspendable_outpoint(0, false)); - + utxo_set.add(dummy_unspendable_outpoint(0, false)).unwrap(); utxo_set.add(dummy_outpoint(1, true)).unwrap(); utxo_set.add(dummy_unspendable_outpoint(1, true)).unwrap(); - utxo_set.add(dummy_outpoint(2, false)).unwrap(); utxo_set.add(dummy_unspendable_outpoint(2, false)).unwrap(); diff --git a/packages/consensus/src/validation/locktime.cairo b/packages/consensus/src/validation/locktime.cairo index 1d7c3882..01b401b5 100644 --- a/packages/consensus/src/validation/locktime.cairo +++ b/packages/consensus/src/validation/locktime.cairo @@ -71,13 +71,6 @@ pub fn validate_relative_locktime( let value = sequence & SEQUENCE_LOCKTIME_MASK; if (sequence & SEQUENCE_LOCKTIME_TYPE_FLAG) != 0 { - // TODO: use the median from prev_timestamps of the initial chain state - // Note that this has to be provided by the script + at the point where - // we update local cache or Utreexo roots. - // - // Why is it not mentioned here - // https://learnmeabitcoin.com/technical/transaction/input/sequence/ ? - // // Time-based relative lock-times are measured from the // smallest allowed timestamp of the block containing the // txout being spent, which is the median time past of the diff --git a/packages/utils/src/lib.cairo b/packages/utils/src/lib.cairo index b3ee1c2a..d2f2164c 100644 --- a/packages/utils/src/lib.cairo +++ b/packages/utils/src/lib.cairo @@ -10,5 +10,5 @@ pub mod sort; // pub mod sha256; pub use core::sha256; -// #[cfg(target: 'test')] +#[cfg(target: 'test')] pub mod hex; diff --git a/packages/utreexo/src/vanilla/state.cairo b/packages/utreexo/src/vanilla/state.cairo index 02414662..637442a5 100644 --- a/packages/utreexo/src/vanilla/state.cairo +++ b/packages/utreexo/src/vanilla/state.cairo @@ -31,20 +31,22 @@ pub impl UtreexoStateImpl of UtreexoStateTrait { self: @UtreexoState, hashes_to_add: Span, hashes_to_delete: Span, - proofs: Span + mut proofs: Span ) -> Result { - let mut proof_idx = 0; let mut inner_result = Result::Ok(()); let mut state = *self; for hash in hashes_to_delete { - let proof = proofs[proof_idx]; - let inner_result = self.verify(*hash, proof); - if inner_result.is_err() { + if let Option::Some(proof) = proofs.pop_front() { + inner_result = self.verify(*hash, proof); + if inner_result.is_err() { + break; + } + state = state.delete(proof); + } else { + inner_result = Result::Err(format!("Missing proof for leaf {}", hash)); break; } - state = state.delete(proof); - proof_idx += 1; }; inner_result?; diff --git a/scripts/data/generate_data.py b/scripts/data/generate_data.py index 1f8fe911..a2071c61 100755 --- a/scripts/data/generate_data.py +++ b/scripts/data/generate_data.py @@ -3,7 +3,6 @@ import argparse import json import os -import sys import time from decimal import Decimal, getcontext from pathlib import Path @@ -22,7 +21,6 @@ DEFAULT_URL = "https://bitcoin-mainnet.public.blastapi.io" FAST = False - RETRIES = 3 DELAY = 2 @@ -54,12 +52,6 @@ def request_rpc(method: str, params: list): ) -def compute_median_time_past(prev_timestamps): - """Compute the Median Time Past (MTP) from the previous timestamps.""" - sorted_timestamps = sorted(prev_timestamps) - return sorted_timestamps[len(sorted_timestamps) // 2] - - def fetch_chain_state_fast(block_height: int): """Fetches chain state at the end of a specific block with given height.""" block_hash = request_rpc("getblockhash", [block_height]) @@ -71,8 +63,7 @@ def fetch_chain_state_fast(block_height: int): head["epoch_start_time"] = 1231006505 else: head["epoch_start_time"] = int(data["epoch_start_time"]) - # Compute median_time_past from prev_timestamps - head["median_time_past"] = compute_median_time_past(head["prev_timestamps"]) + return head @@ -98,7 +89,6 @@ def fetch_chain_state(block_height: int): ) prev_timestamps.insert(0, int(prev_header["time"])) head["prev_timestamps"] = prev_timestamps - head["median_time_past"] = compute_median_time_past(prev_timestamps) # In order to init epoch start we need to query block header at epoch start if block_height < 2016: @@ -109,29 +99,6 @@ def fetch_chain_state(block_height: int): return head -def next_chain_state(head: dict, blocks: list): - """Computes resulting chain state given the initial chain state - and all blocks that were applied to it. - """ - block_height = head["height"] + len(blocks) - next_head = blocks[-1] - - # We need to recalculate the prev_timestamps field given the previous chain state - # and all the blocks we applied to it - prev_timestamps = head["prev_timestamps"] + list(map(lambda x: x["time"], blocks)) - next_head["prev_timestamps"] = prev_timestamps[-11:] - next_head["median_time_past"] = compute_median_time_past( - next_head["prev_timestamps"] - ) - - # Update epoch start time if necessary - if head["height"] // 2016 != block_height // 2016: - next_head["epoch_start_time"] = get_epoch_start_time(block_height) - else: - next_head["epoch_start_time"] = head["epoch_start_time"] - return next_head - - def get_epoch_start_time(block_height: int) -> int: """Computes the corresponding epoch start time given the current block height.""" epoch_start_block_height = (block_height // 2016) * 2016 @@ -168,7 +135,7 @@ def bits_to_target(bits: str) -> int: return mantissa << (8 * (exponent - 3)) -def fetch_block(block_hash: str, fast: bool, current_chain_state: dict): +def fetch_block(block_hash: str, fast: bool): """Downloads block with transactions (and referred UTXOs) from RPC given the block hash.""" block = request_rpc("getblock", [block_hash, 2]) @@ -179,41 +146,36 @@ def fetch_block(block_hash: str, fast: bool, current_chain_state: dict): ) block["data"] = { - tx["txid"]: resolve_transaction( - tx, previous_outputs, current_chain_state["median_time_past"] - ) + tx["txid"]: resolve_transaction(tx, previous_outputs) for tx in tqdm(block["tx"], "Resolving transactions") } return block -def resolve_transaction( - transaction: dict, previous_outputs: dict, median_time_past: int -): +def resolve_transaction(transaction: dict, previous_outputs: dict): """Resolves transaction inputs and formats the content according to the Cairo type.""" return { "version": transaction["version"], "is_segwit": transaction["hex"][8:12] == "0001", "inputs": [ - resolve_input(input, previous_outputs, median_time_past) - for input in transaction["vin"] + resolve_input(input, previous_outputs) for input in transaction["vin"] ], "outputs": [format_output(output) for output in transaction["vout"]], "lock_time": transaction["locktime"], } -def resolve_input(input: dict, previous_outputs: dict, median_time_past: int): +def resolve_input(input: dict, previous_outputs: dict): """Resolves referenced UTXO and formats the transaction inputs according to the Cairo type.""" if input.get("coinbase"): return format_coinbase_input(input) else: if previous_outputs: previous_output = format_outpoint( - previous_outputs[(input["txid"], input["vout"])], median_time_past + previous_outputs[(input["txid"], input["vout"])] ) else: - previous_output = resolve_outpoint(input, median_time_past) + previous_output = resolve_outpoint(input) return { "script": f'0x{input["scriptSig"]["hex"]}', "sequence": input["sequence"], @@ -222,7 +184,7 @@ def resolve_input(input: dict, previous_outputs: dict, median_time_past: int): } -def format_outpoint(previous_output, median_time_past): +def format_outpoint(previous_output): """Formats output according to the Cairo type.""" return { "txid": previous_output["txid"], @@ -233,12 +195,13 @@ def format_outpoint(previous_output, median_time_past): "cached": False, }, "block_height": int(previous_output["block_height"]), - "median_time_past": median_time_past, + # Note that BigQuery dataset uses "median_timestamp" instead of "median_time_past" + "median_time_past": int(previous_output["median_timestamp"]), "is_coinbase": previous_output["is_coinbase"], } -def resolve_outpoint(input: dict, median_time_past: int): +def resolve_outpoint(input: dict): """Fetches transaction and block header for the referenced output, formats resulting outpoint according to the Cairo type. """ @@ -249,7 +212,7 @@ def resolve_outpoint(input: dict, median_time_past: int): "vout": input["vout"], "data": format_output(tx["vout"][input["vout"]]), "block_height": block["height"], - "median_time_past": median_time_past, + "median_time_past": block["mediantime"], "is_coinbase": tx["vin"][0].get("coinbase") is not None, } @@ -322,7 +285,7 @@ def format_header(header: dict): } -def apply_chain_state(current_state: dict, new_block: dict) -> dict: +def next_chain_state(current_state: dict, new_block: dict) -> dict: """Computes the next chain state given the current state and a new block.""" next_state = new_block.copy() @@ -331,14 +294,9 @@ def apply_chain_state(current_state: dict, new_block: dict) -> dict: new_block["time"] ] - # Compute new median time past - next_state["median_time_past"] = compute_median_time_past( - next_state["prev_timestamps"] - ) - # Update epoch start time - if current_state["height"] // 2016 != next_state["height"] // 2016: - next_state["epoch_start_time"] = get_epoch_start_time(next_state["height"]) + if new_block["height"] % 2016 == 0: + next_state["epoch_start_time"] = new_block["time"] else: next_state["epoch_start_time"] = current_state["epoch_start_time"] @@ -394,7 +352,7 @@ def generate_data( if mode == "light": block = fetch_block_header(next_block_hash) elif mode in ["full", "utreexo"]: - block = fetch_block(next_block_hash, fast, chain_state) + block = fetch_block(next_block_hash, fast) # Build UTXO set and mark outputs spent within the same block (span). # Also set "cached" flag for the inputs that spend those UTXOs. @@ -424,7 +382,7 @@ def generate_data( blocks.append(block) prev_chain_state = chain_state - chain_state = apply_chain_state(chain_state, block) + chain_state = next_chain_state(chain_state, block) next_block_hash = block["nextblockhash"] block_formatter = ( diff --git a/scripts/data/generate_utreexo_data.py b/scripts/data/generate_utreexo_data.py index 9ee60ef0..fcb398c5 100644 --- a/scripts/data/generate_utreexo_data.py +++ b/scripts/data/generate_utreexo_data.py @@ -147,9 +147,8 @@ def apply_blocks(self, blocks: list) -> dict: for i, (txid, tx) in enumerate(block["data"].items()): self.handle_txout( tx["outputs"], - block["hash"], block["height"], - block["time"], + block["mediantime"], txid, i == 0, ) @@ -177,23 +176,17 @@ def handle_txin(self, inputs: list) -> list: is_coinbase=outpoint["is_coinbase"], ) - # Try to remove OutPoint from accumulator and get proof - try: - proof, leaf_index = self.utreexo.delete(outpoint.hash()) - proofs.append( - {"proof": list(map(format_node, proof)), "leaf_index": leaf_index} - ) - except Exception as e: - print(f"Warning: Failed to delete leaf from Utreexo: {e}") - # If the leaf doesn't exist, we'll skip it and continue processing - continue + # Remove OutPoint from accumulator and get proof + proof, leaf_index = self.utreexo.delete(outpoint.hash()) + proofs.append( + {"proof": list(map(format_node, proof)), "leaf_index": leaf_index} + ) return proofs def handle_txout( self, outputs: list, - block_hash: str, block_height: int, median_time_past: int, txid: str, diff --git a/scripts/data/integration_tests.sh b/scripts/data/integration_tests.sh index 453f2fcd..8028713e 100755 --- a/scripts/data/integration_tests.sh +++ b/scripts/data/integration_tests.sh @@ -1,19 +1,5 @@ #!/usr/bin/env bash -# Detect the operating system -if [[ "$OSTYPE" == "darwin"* ]]; then - # macOS - if command -v gsed >/dev/null 2>&1; then - SED_CMD="gsed" - else - echo "GNU sed (gsed) not found. Please install it using Homebrew: brew install gnu-sed" >&2 - exit 1 - fi -else - # Assume Linux or other Unix-like OS - SED_CMD="sed" -fi - GREEN='\033[0;32m' RED='\033[1;31m' RESET='\033[0m' # No Color @@ -50,7 +36,19 @@ ignored_files=( "tests/data/full_489888.json", #cairo-run dies, to be investigated "tests/data/full_491406.json", #cairo-run dies, to be investigated "tests/data/full_629999.json", #cairo-run dies, to be investigated - "tests/data/full_709631.json" #cairo-run dies, to be investigated + "tests/data/full_709631.json", #cairo-run dies, to be investigated + "tests/data/full_774627.json", # Couldn't compute operand op1. Unknown value for memory cell 1:131082 + "tests/data/full_839999.json", # Couldn't compute operand op1. Unknown value for memory cell 1:262154 + "tests/data/full_116927.json", # Run panicked with [108217864776563 ('blocks'), ]. + "tests/data/full_150012.json", # Run panicked with [108217864776563 ('blocks'), ]. + "tests/data/full_2015.json", # Run panicked with [108217864776563 ('blocks'), ]. + "tests/data/full_24834.json", # Run panicked with [108217864776563 ('blocks'), ]. + "tests/data/full_32255.json", # Run panicked with [108217864776563 ('blocks'), ]. + "tests/data/full_478557.json", # Run panicked with [108217864776563 ('blocks'), ]. + "tests/data/full_57042.json", # Run panicked with [108217864776563 ('blocks'), ]. + "tests/data/full_72575.json", # Run panicked with [108217864776563 ('blocks'), ]. + "tests/data/full_757752.json", # Run panicked with [108217864776563 ('blocks'), ]. + "tests/data/utreexo_169.json", # Unexpected root (TODO: create issue) # "tests/data/full_478557.json", #runs on server ) ignored="${ignored_files[@]}" @@ -59,7 +57,7 @@ ignored="${ignored_files[@]}" if [[ $fullonly -eq 1 && ${#test_files[@]} -eq 0 ]]; then test_files=("tests/data"/full*) elif [[ ${#test_files[@]} -eq 0 ]]; then - test_files=("tests/data"/light*) + test_files=("tests/data"/*) fi if [[ $execute_scripts -eq 1 ]]; then @@ -78,8 +76,8 @@ for test_file in "${test_files[@]}"; do arguments_file=".arguments-$(basename "$test_file")" python ../../scripts/data/format_args.py --input_file ${test_file} $([[ $execute_scripts -eq 1 ]] && echo "--execute_script") > $arguments_file output=$(scarb cairo-run --no-build --function test --arguments-file $arguments_file) - gas_spent=$(echo $output | grep -o 'gas_spent=[0-9]*' | $SED_CMD 's/gas_spent=//') - + gas_spent=$(echo "$output" | grep -o 'gas_spent=[0-9]*' | awk -F= '{sum += $2} END {print sum}') + if [[ "$nocapture" -eq 1 ]]; then echo -e "\n$output" fi @@ -87,7 +85,7 @@ for test_file in "${test_files[@]}"; do if [[ "$output" == *"FAIL"* ]]; then echo -e "${RED} fail ${RESET}(gas usage est.: $gas_spent)" num_fail=$((num_fail + 1)) - error=$(echo $output | grep -o "error='[^']*'" | $SED_CMD "s/error=//") + error=$(echo $output | grep -o "error='[^']*'" | sed "s/error=//") failures+="\t$test_file — Panicked with $error\n" elif [[ "$output" == *"OK"* ]]; then echo -e "${GREEN} ok ${RESET}(gas usage est.: $gas_spent)" @@ -96,7 +94,7 @@ for test_file in "${test_files[@]}"; do else echo -e "${RED} fail ${RESET}(gas usage est.: 0)" num_fail=$((num_fail + 1)) - error=$(echo "$output" | $SED_CMD '1d' | $SED_CMD ':a;N;$!ba;s/\n/ /g' | $SED_CMD 's/[[:space:]]\+/ /g') #spellchecker:disable-line + error=$(echo "$output" | sed '1d' | tr '\n' ' ' | sed 's/[[:space:]]\+/ /g') #spellchecker:disable-line failures+="\t$test_file — $error\n" fi fi diff --git a/scripts/data/regenerate_tests.sh b/scripts/data/regenerate_tests.sh index be38c6f4..bc9018fe 100755 --- a/scripts/data/regenerate_tests.sh +++ b/scripts/data/regenerate_tests.sh @@ -79,16 +79,16 @@ generate_test() { } for test_case in "${light_test_cases[@]}"; do - echo "Generating test data: light mode, chain state @ $test_case, single block" + echo -e "\nGenerating test data: light mode, chain state @ $test_case, single block" generate_test "light" $test_case done for test_case in "${full_test_cases[@]}"; do - echo "Generating test data: full mode, chain state @ $test_case, single block" + echo -e "\nGenerating test data: full mode, chain state @ $test_case, single block" generate_test "full" $test_case done for test_case in "${utreexo_test_cases[@]}"; do - echo "Generating test data: utreexo mode, chain state @ $test_case, single block" + echo -e "\nGenerating test data: utreexo mode, chain state @ $test_case, single block" generate_test "utreexo" 0 $(($test_case+1)) done