From 1bc1eef6344fba33105b018216d7af5f04550cd8 Mon Sep 17 00:00:00 2001 From: Chih Cheng Liang Date: Thu, 14 Sep 2023 08:57:45 +0800 Subject: [PATCH] [MPTWG] Deadcode round (#1590) ### Description Remove dead code in MPTWG to improve readability. ### Issue Link ### Type of change Bug fix (non-breaking change which fixes an issue) (wait CI update in #1591) --- mpt-witness-generator/go.mod | 6 +- mpt-witness-generator/go.sum | 25 +- ...gen_witness_from_infura_blockchain_test.go | 190 -------------- .../gen_witness_from_local_blockchain_test.go | 245 ------------------ .../witness/gen_witness_transactions_test.go | 21 -- mpt-witness-generator/witness/leaf.go | 5 - .../witness/modified_extension_node.go | 38 --- mpt-witness-generator/witness/util.go | 28 -- 8 files changed, 19 insertions(+), 539 deletions(-) diff --git a/mpt-witness-generator/go.mod b/mpt-witness-generator/go.mod index e7a910f810..ce4ba3832e 100644 --- a/mpt-witness-generator/go.mod +++ b/mpt-witness-generator/go.mod @@ -3,8 +3,6 @@ module github.com/privacy-scaling-explorations/mpt-witness-generator go 1.16 require ( - github.com/VictoriaMetrics/fastcache v1.6.0 // indirect - github.com/ethereum/go-ethereum v1.10.8 // indirect - github.com/holiman/uint256 v1.2.0 // indirect - golang.org/x/crypto v0.0.0-20210322153248-0c34fe9e7dc2 // indirect + github.com/ethereum/go-ethereum v1.10.8 + golang.org/x/crypto v0.0.0-20210322153248-0c34fe9e7dc2 ) diff --git a/mpt-witness-generator/go.sum b/mpt-witness-generator/go.sum index 5a8c30548f..950942ce26 100644 --- a/mpt-witness-generator/go.sum +++ b/mpt-witness-generator/go.sum @@ -43,6 +43,7 @@ github.com/aead/siphash v1.0.1/go.mod h1:Nywa3cDsYNNK3gaciGTWPwHt0wlpNV15vwmswBA github.com/ajstarks/svgo v0.0.0-20180226025133-644b8db467af/go.mod h1:K08gAheRH3/J6wwsYMMT4xOr94bZjxIelGM0+d/wbFw= github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc= github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0= +github.com/allegro/bigcache v1.2.1-0.20190218064605-e24eb225f156 h1:eMwmnE/GDgah4HI848JfFxHt+iPb26b4zyfspmqY0/8= github.com/allegro/bigcache v1.2.1-0.20190218064605-e24eb225f156/go.mod h1:Cb/ax3seSYIx7SuZdm2G2xzfwmv3TPSk2ucNfQESPXM= github.com/andreyvit/diff v0.0.0-20170406064948-c7f18ee00883/go.mod h1:rCTlJbsFo29Kk6CurOXKm700vrz8f0KW0JNfpkRJY/8= github.com/apache/arrow/go/arrow v0.0.0-20191024131854-af6fa24be0db/go.mod h1:VTxUBvSJ3s3eHAg65PNgrsn5BtqCRPdmyXh6rAfdxN0= @@ -87,8 +88,8 @@ github.com/cyberdelia/templates v0.0.0-20141128023046-ca7fffd4298c/go.mod h1:GyV github.com/dave/jennifer v1.2.0/go.mod h1:fIb+770HOpJ2fmN9EPPKOqm1vMGhB+TwXKMZhrIygKg= github.com/davecgh/go-spew v0.0.0-20171005155431-ecdeabc65495/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= -github.com/deckarep/golang-set v0.0.0-20180603214616-504e848d77ea h1:j4317fAZh7X6GqbFowYdYdI0L9bwxL07jyPZIdepyZ0= github.com/deckarep/golang-set v0.0.0-20180603214616-504e848d77ea/go.mod h1:93vsz/8Wt4joVM7c2AVqh+YRMiUSc14yDtF28KmMOgQ= github.com/deepmap/oapi-codegen v1.6.0/go.mod h1:ryDa9AgbELGeB+YEXE1dR53yAjHwFvE9iAUlWl9Al3M= github.com/deepmap/oapi-codegen v1.8.2/go.mod h1:YLgSKSDv/bZQB7N4ws6luhozi3cEdRktEqrX88CvjIw= @@ -99,7 +100,6 @@ github.com/dlclark/regexp2 v1.2.0/go.mod h1:2pZnwuY/m+8K6iRw6wQdMtk+rH5tNGR1i55k github.com/docker/docker v1.4.2-0.20180625184442-8e610b2b55bf/go.mod h1:eEKB0N0r5NX/I1kEveEz05bcu8tLC/8azJZsviup8Sk= github.com/dop251/goja v0.0.0-20200721192441-a695b0cdd498/go.mod h1:Mw6PkjjMXWbTj+nnj4s3QPXq1jaT0s5pC0iFD4+BOAA= github.com/eclipse/paho.mqtt.golang v1.2.0/go.mod h1:H9keYFcgq3Qr5OUJm/JZI/i6U7joQ8SYLhZwfeOo6Ts= -github.com/edsrzf/mmap-go v1.0.0 h1:CEBF7HpRnUCSJgGUb5h1Gm7e3VkmVDrR8lvWVLtrOFw= github.com/edsrzf/mmap-go v1.0.0/go.mod h1:YO35OhQPt3KJa3ryjFM5Bs14WD66h8eGKpfaBNrHW5M= github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c= @@ -109,6 +109,7 @@ github.com/fatih/color v1.7.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5Kwzbycv github.com/fjl/memsize v0.0.0-20190710130421-bcb5799ab5e5/go.mod h1:VvhXpOYNQvB+uIk2RvXzuaQtkQJzzIx6lSBe1xv7hi0= github.com/fogleman/gg v1.2.1-0.20190220221249-0403632d5b90/go.mod h1:R/bRT+9gY/C5z7JzPU0zXsXHKM4/ayA+zqcVNZzPa1k= github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo= +github.com/fsnotify/fsnotify v1.4.9 h1:hsms1Qyu0jgnwNXIxa+/V/PDsU6CfLf6CNO8H7IWoS4= github.com/fsnotify/fsnotify v1.4.9/go.mod h1:znqG4EE+3YCdAaPaxE2ZRY/06pZUdp0tY4IgpuI1SZQ= github.com/gballet/go-libpcsclite v0.0.0-20190607065134-2772fd86a8ff/go.mod h1:x7DCsMOv1taUwEWCzT4cmDeAkigA5/QCwUodaVOe8Ww= github.com/getkin/kin-openapi v0.53.0/go.mod h1:7Yn5whZr5kJi6t+kShccXS8ae1APpYTW6yheSwk8Yi4= @@ -119,8 +120,10 @@ github.com/glycerine/goconvey v0.0.0-20190410193231-58a59202ab31/go.mod h1:Ogl1T github.com/go-chi/chi/v5 v5.0.0/go.mod h1:BBug9lr0cqtdAhsu6R4AAdvufI0/XBzAQSsUqJpoZOs= github.com/go-gl/glfw v0.0.0-20190409004039-e6da0acd62b1/go.mod h1:vR7hzQXu2zJy9AVAgeJqvqgH9Q5CA+iKCZ2gyEVpxRU= github.com/go-gl/glfw/v3.3/glfw v0.0.0-20191125211704-12ad95a8df72/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8= +github.com/go-kit/kit v0.8.0 h1:Wz+5lgoB0kkuqLEc6NVmwRknTKP6dTGbSqvhZtBI/j0= github.com/go-kit/kit v0.8.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as= github.com/go-logfmt/logfmt v0.3.0/go.mod h1:Qt1PoO58o5twSAckw1HlFXLmHsOX5/0LbT9GBnD5lWE= +github.com/go-logfmt/logfmt v0.4.0 h1:MP4Eh7ZCb31lleYCFuwm0oe4/YGak+5l1vA2NOE80nA= github.com/go-logfmt/logfmt v0.4.0/go.mod h1:3RMwSq7FuexP4Kalkev3ejPJsZTpXXBr9+V4qmtdjCk= github.com/go-ole/go-ole v1.2.1 h1:2lOsA72HgjxAuMlKpFiCbHTvu44PIVkZ5hqm3RSdI/E= github.com/go-ole/go-ole v1.2.1/go.mod h1:7FAglXiTm7HKlQRDeOQ6ZNUHidzCWXuZWq/1dTyBNF8= @@ -176,16 +179,13 @@ github.com/googleapis/gax-go/v2 v2.0.4/go.mod h1:0Wqv26UfaUD9n4G6kQubkQ+KchISgw+ github.com/googleapis/gax-go/v2 v2.0.5/go.mod h1:DWXyrwAJ9X0FpwwEdw+IPEYBICEFu5mhpdKc/us6bOk= github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY= github.com/gorilla/mux v1.8.0/go.mod h1:DVbg23sWSpFRCP0SfiEN6jmj59UnW/n46BH5rLB71So= -github.com/gorilla/websocket v1.4.2 h1:+/TMaTYc4QFitKJxsQ7Yye35DkWvkdLcvGKqM+x0Ufc= github.com/gorilla/websocket v1.4.2/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE= github.com/graph-gophers/graphql-go v0.0.0-20201113091052-beb923fada29/go.mod h1:9CQHMSxwO4MprSdzoIEobiHpoLtHm77vfxsvsIN5Vuc= github.com/hashicorp/golang-lru v0.5.0/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8= github.com/hashicorp/golang-lru v0.5.1/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8= -github.com/hashicorp/golang-lru v0.5.5-0.20210104140557-80c98217689d h1:dg1dEPuWpEqDnvIw251EVy4zlP8gWbsGj4BsUKCRpYs= github.com/hashicorp/golang-lru v0.5.5-0.20210104140557-80c98217689d/go.mod h1:iADmTwqILo4mZ8BN3D2Q6+9jd8WM5uGBxy+E8yxSoD4= github.com/holiman/bloomfilter/v2 v2.0.3 h1:73e0e/V0tCydx14a0SCYS/EWCxgwLZ18CZcZKVu0fao= github.com/holiman/bloomfilter/v2 v2.0.3/go.mod h1:zpoh+gs7qcpqrHr3dB55AMiJwo0iURXE7ZOP9L9hSkA= -github.com/holiman/uint256 v1.2.0 h1:gpSYcPLWGv4sG43I2mVLiDZCNDh/EpGjSk8tmtxitHM= github.com/holiman/uint256 v1.2.0/go.mod h1:y4ga/t+u+Xwd7CpDgZESaRcWy0I7XMlTMA25ApIH5Jw= github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU= github.com/huin/goupnp v1.0.2/go.mod h1:0dxJBVBHqTMjIUMkESDTNgOOx/Mw5wYIfyFmdzSamkM= @@ -214,7 +214,6 @@ github.com/jstemmer/go-junit-report v0.0.0-20190106144839-af01ea7f8024/go.mod h1 github.com/jstemmer/go-junit-report v0.9.1/go.mod h1:Brl9GWCQeLvo8nXZwPNNblvFj/XSXhF0NWZEnDohbsk= github.com/jsternberg/zap-logfmt v1.0.0/go.mod h1:uvPs/4X51zdkcm5jXl5SYoN+4RK21K8mysFmDaM/h+o= github.com/jtolds/gls v4.20.0+incompatible/go.mod h1:QJZ7F/aHp+rZTRtaJ1ow/lLfFfVYBRgL+9YlvaHOwJU= -github.com/julienschmidt/httprouter v1.2.0 h1:TDTW5Yz1mjftljbcKqRcrYhd4XeOoI98t+9HbQbYf7g= github.com/julienschmidt/httprouter v1.2.0/go.mod h1:SYymIcj16QtmaHHD7aYtjjsJG7VTCxuUUipMqKk8s4w= github.com/jung-kurt/gofpdf v1.0.3-0.20190309125859-24315acbbda5/go.mod h1:7Id9E/uU8ce6rXgefFLlgrJj/GYY22cpxn+r32jIOes= github.com/jwilder/encoding v0.0.0-20170811194829-b4e1701a28ef/go.mod h1:Ct9fl0F6iIOGgxJ5npU/IUOhOhqlVrGjyIZc8/MagT0= @@ -227,6 +226,7 @@ github.com/klauspost/cpuid v0.0.0-20170728055534-ae7887de9fa5/go.mod h1:Pj4uuM52 github.com/klauspost/crc32 v0.0.0-20161016154125-cb6bfca970f6/go.mod h1:+ZoRqAPRLkC4NPOvfYeR5KNOrY6TD+/sAC3HXPZgDYg= github.com/klauspost/pgzip v1.0.2-0.20170402124221-0bf5dcad4ada/go.mod h1:Ch1tH69qFZu15pkjo5kYi6mth2Zzwzt50oCQKQE9RUs= github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= +github.com/kr/logfmt v0.0.0-20140226030751-b84e30acd515 h1:T+h1c/A9Gawja4Y9mFVWj2vyii2bbUNDw3kt9VxK2EY= github.com/kr/logfmt v0.0.0-20140226030751-b84e30acd515/go.mod h1:+0opPa2QZZtGFBFZlji/RkVcI2GknAs/DXo4wKdlNEc= github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= @@ -235,7 +235,6 @@ github.com/kylelemons/godebug v1.1.0/go.mod h1:9/0rRGxNHcop5bhtWyNeEfOS8JIWk580+ github.com/labstack/echo/v4 v4.2.1/go.mod h1:AA49e0DZ8kk5jTOOCKNuPR6oTnBS0dYiM4FW1e6jwpg= github.com/labstack/gommon v0.3.0/go.mod h1:MULnywXg0yavhxWKc+lOruYdAhDwPK9wf0OL7NoOu+k= github.com/leanovate/gopter v0.2.9/go.mod h1:U2L/78B+KVFIx2VmW6onHJQzXtFb+p5y3y2Sh+Jxxv8= -github.com/lib/pq v1.0.0 h1:X5PMW56eZitiTeO7tKzZxFCSpbFZJtkMMooicw2us9A= github.com/lib/pq v1.0.0/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo= github.com/mailru/easyjson v0.0.0-20190614124828-94de47d64c63/go.mod h1:C1wdFJiN94OJF2b5HbByQZoLdCWB1Yqtg26g4irojpc= github.com/mailru/easyjson v0.0.0-20190626092158-b2ccc519800e/go.mod h1:C1wdFJiN94OJF2b5HbByQZoLdCWB1Yqtg26g4irojpc= @@ -262,6 +261,7 @@ github.com/mschoch/smat v0.0.0-20160514031455-90eadee771ae/go.mod h1:qAyveg+e4CE github.com/mwitkow/go-conntrack v0.0.0-20161129095857-cc309e4a2223/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U= github.com/naoina/go-stringutil v0.1.0/go.mod h1:XJ2SJL9jCtBh+P9q5btrd/Ylo8XwT/h1USek5+NqSA0= github.com/naoina/toml v0.1.2-0.20170918210437-9fafd6967416/go.mod h1:NBIhNtsFMo3G2szEBne+bO4gS192HuIYRqfvOWb4i1E= +github.com/nxadm/tail v1.4.4 h1:DQuhQpB1tVlglWS2hLQ5OV6B5r8aGxSrPc5Qo6uTN78= github.com/nxadm/tail v1.4.4/go.mod h1:kenIhsEOeOJmVchQTgglprH7qJGnHDVpk1VPCcaMI8A= github.com/oklog/ulid v1.3.1/go.mod h1:CirwcVhetQ6Lv90oh/F+FBtV6XMibvdAFo93nm5qn4U= github.com/olekukonko/tablewriter v0.0.5 h1:P2Ga83D34wi1o9J6Wh1mRuqd4mF/x/lgBS7N7AbDhec= @@ -269,9 +269,11 @@ github.com/olekukonko/tablewriter v0.0.5/go.mod h1:hPp6KlRPjbx+hW8ykQs1w3UBbZlj6 github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= github.com/onsi/ginkgo v1.7.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= github.com/onsi/ginkgo v1.12.1/go.mod h1:zj2OWP4+oCPe1qIXoGWkgMRwljMUYCdkwsT2108oapk= +github.com/onsi/ginkgo v1.14.0 h1:2mOpI4JVVPBN+WQRa0WKH2eXR+Ey+uK4n7Zj0aYpIQA= github.com/onsi/ginkgo v1.14.0/go.mod h1:iSB4RoI2tjJc9BBv4NKIKWKya62Rps+oPG/Lv9klQyY= github.com/onsi/gomega v1.4.3/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1CpauHY= github.com/onsi/gomega v1.7.1/go.mod h1:XdKZgCCFLUoM/7CFJVPcG8C1xQ1AJ0vpAezJrB7JYyY= +github.com/onsi/gomega v1.10.1 h1:o0+MgICZLuZ7xjH7Vx6zS/zcu93/BEp1VwkIW1mEXCE= github.com/onsi/gomega v1.10.1/go.mod h1:iN09h71vgCQne3DLsj+A5owkum+a2tYe+TOCB1ybHNo= github.com/opentracing/opentracing-go v1.0.2/go.mod h1:UkNAQd3GIcIGf0SeVgPpRdFStlNbqXla1AfSYxPUl2o= github.com/opentracing/opentracing-go v1.0.3-0.20180606204148-bd9c31933947/go.mod h1:UkNAQd3GIcIGf0SeVgPpRdFStlNbqXla1AfSYxPUl2o= @@ -281,12 +283,12 @@ github.com/peterh/liner v1.0.1-0.20180619022028-8c1271fcf47f/go.mod h1:xIteQHvHu github.com/peterh/liner v1.1.1-0.20190123174540-a2c9a5303de7/go.mod h1:CRroGNssyjTd/qIG2FyxByd2S8JEAZXBl4qUrZf8GS0= github.com/philhofer/fwd v1.0.0/go.mod h1:gk3iGcWd9+svBvR0sR+KPcfE+RNWozjowpeBVG3ZVNU= github.com/pierrec/lz4 v2.0.5+incompatible/go.mod h1:pdkljMzZIN41W+lC3N2tnIh5sFi+IEE17M5jbnwPHcY= -github.com/pkg/errors v0.8.0 h1:WdK/asTD0HN+q6hsWO3/vpuAkAr+tw6aNJNDFFf0+qw= github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pkg/term v0.0.0-20180730021639-bffc007b7fd5/go.mod h1:eCbImbZ95eXtAUIbLAuAVnBnwf83mjf6QIVH8SHYwqQ= +github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/prometheus/client_golang v0.9.1/go.mod h1:7SWBe2y4D6OKWSNQJUaRYU/AaXPKyh/dDVn+NZz0KFw= github.com/prometheus/client_golang v1.0.0/go.mod h1:db9x61etRT2tGnBNRi70OPL5FsnadC4Ky3P0J6CfImo= @@ -326,6 +328,7 @@ github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXf github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA= +github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY= github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/syndtr/goleveldb v1.0.1-0.20210305035536-64b5b1c73954 h1:xQdMZ1WLrgkkvOZ/LDQxjVxMLdby7osSh4ZEVa5sIjs= github.com/syndtr/goleveldb v1.0.1-0.20210305035536-64b5b1c73954/go.mod h1:u2MKkTVTVJWe5D1rCvame8WqhBd88EuIwODJZ1VHCPM= @@ -410,6 +413,7 @@ golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwY golang.org/x/net v0.0.0-20210119194325-5f4716e94777/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= golang.org/x/net v0.0.0-20210220033124-5f55cee0dc0d/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= +golang.org/x/net v0.0.0-20210805182204-aaa1db679c0d h1:20cMwl2fHAzkJMEA+8J4JgqBQcQGzbisXo31MIeenXI= golang.org/x/net v0.0.0-20210805182204-aaa1db679c0d/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= @@ -471,6 +475,7 @@ golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk= golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.4/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.5/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= +golang.org/x/text v0.3.6 h1:aRYxNxv6iGQlyVaZmk6ZgYEDa+Jg18DxebPSrd6bg1M= golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= @@ -506,6 +511,7 @@ golang.org/x/tools v0.1.0/go.mod h1:xkSsbof2nBLbhDlRMhhhyNLN/zl3eTqcnHD5viDpcZ0= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 h1:go1bK/D/BFZV2I8cIQd1NKEZ+0owSTG1fDTci4IqFcE= golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= gonum.org/v1/gonum v0.0.0-20180816165407-929014505bf4/go.mod h1:Y+Yx5eoAFn32cQvJDxZx5Dpnq+c3wtXuadVZAcxbbBo= gonum.org/v1/gonum v0.0.0-20181121035319-3f7ecaa7e8ca/go.mod h1:Y+Yx5eoAFn32cQvJDxZx5Dpnq+c3wtXuadVZAcxbbBo= @@ -557,6 +563,7 @@ gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI= gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys= gopkg.in/natefinch/npipe.v2 v2.0.0-20160621034901-c1b8fa8bdcce/go.mod h1:5AcXVHNjg+BDxry382+8OKon8SEWiKktQR07RKPsv1c= gopkg.in/olebedev/go-duktape.v3 v3.0.0-20200619000410-60c24ae608a6/go.mod h1:uAJfkITjFhyEEuUfm7bsmCZRbW5WRq8s9EY8HZ6hCns= +gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 h1:uRGJdciOHaEIrze2W8Q3AKkepLTh2hOroT7a+7czfdQ= gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWDmTeBkI65Dw0HsyUHuEVlX15mw= gopkg.in/urfave/cli.v1 v1.20.0/go.mod h1:vuBzUtMdQeixQj8LVd+/98pzhxNGQoyuPBlsXHOQNO0= gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= @@ -565,7 +572,9 @@ gopkg.in/yaml.v2 v2.2.3/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.3.0/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY= gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ= +gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c h1:dUUwHk2QECo/6vqA44rthZ8ie2QXMNeKRTHCNY2nXvo= gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gotest.tools v2.2.0+incompatible/go.mod h1:DsYFclhRJ6vuDpmuTbkuFWG+y2sxOXAzmJt81HFBacw= honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= diff --git a/mpt-witness-generator/witness/gen_witness_from_infura_blockchain_test.go b/mpt-witness-generator/witness/gen_witness_from_infura_blockchain_test.go index 93e72ff8e3..a74695d24c 100644 --- a/mpt-witness-generator/witness/gen_witness_from_infura_blockchain_test.go +++ b/mpt-witness-generator/witness/gen_witness_from_infura_blockchain_test.go @@ -2079,196 +2079,6 @@ func TestLeafWithMoreNibbles(t *testing.T) { oracle.PreventHashingInSecureTrie = false } -// Note: this requires MockProver with config param 11 -/* -func TestNonHashedBranchInBranch(t *testing.T) { - blockNum := 0 - blockNumberParent := big.NewInt(int64(blockNum)) - blockHeaderParent := oracle.PrefetchBlock(blockNumberParent, true, nil) - database := state.NewDatabase(blockHeaderParent) - statedb, _ := state.New(blockHeaderParent.Root, database, nil) - addr := common.HexToAddress("0x50efbf12580138bc623c95757286df4e24eb81c9") - - statedb.DisableLoadingRemoteAccounts() - - statedb.CreateAccount(addr) - - oracle.PreventHashingInSecureTrie = true // to store the unchanged key - - val1 := common.BigToHash(big.NewInt(int64(1))) - - key1Hex := "0x1000000000000000000000000000000000000000000000000000000000000000" - key2Hex := "0x2000000000000000000000000000000000000000000000000000000000000000" - key1 := common.HexToHash(key1Hex) - key2 := common.HexToHash(key2Hex) - fmt.Println(key2) - - statedb.SetState(addr, key2, val1) - - iters := 57 // making the last branch shorter than 32 bytes - for i := 0; i < iters; i++ { - fmt.Println("====") - fmt.Println(key1) - - statedb.SetState(addr, key1, val1) - - if i == iters - 1 { - break - } - - key1Hex = replaceAtIndex(key1Hex, 49, i + 3) // 49 is 1, 50 is 2, ... - key1 = common.HexToHash(key1Hex) - } - - statedb.IntermediateRoot(false) - - val := common.BigToHash(big.NewInt(int64(17))) - trieMod := TrieModification{ - Type: StorageChanged, - Key: key1, - Value: val, - Address: addr, - } - trieModifications := []TrieModification{trieMod} - - GenerateProof("NonHashedBranchInBranch", trieModifications, statedb) - - oracle.PreventHashingInSecureTrie = false -} - -func replaceAtIndex(in string, r rune, i int) string { - out := []rune(in) - out[i] = r - return string(out) -} - -// Note: this requires MockProver with config param 11 -func TestNonHashedExtensionNodeInBranch(t *testing.T) { - blockNum := 0 - blockNumberParent := big.NewInt(int64(blockNum)) - blockHeaderParent := oracle.PrefetchBlock(blockNumberParent, true, nil) - database := state.NewDatabase(blockHeaderParent) - statedb, _ := state.New(blockHeaderParent.Root, database, nil) - addr := common.HexToAddress("0x50efbf12580138bc623c95757286df4e24eb81c9") - - statedb.DisableLoadingRemoteAccounts() - - statedb.CreateAccount(addr) - - oracle.PreventHashingInSecureTrie = true // to store the unchanged key - - val1 := common.BigToHash(big.NewInt(int64(1))) - - key1Hex := "0x1000000000000000000000000000000000000000000000000000000000000000" - key2Hex := "0x2000000000000000000000000000000000000000000000000000000000000000" - key1 := common.HexToHash(key1Hex) - key2 := common.HexToHash(key2Hex) - fmt.Println(key2) - - statedb.SetState(addr, key2, val1) - - iters := 58 // make the extension node shorter than 32 - for i := 0; i < iters; i++ { - statedb.SetState(addr, key1, val1) - - if i == iters - 1 { - break - } - - makeExtension := false - if i == iters - 2 { - makeExtension = true - } - - if !makeExtension { - key1Hex = replaceAtIndex(key1Hex, 49, i + 3) - } else { - key1Hex = replaceAtIndex(key1Hex, 49, i + 1 + 3) - } - - key1 = common.HexToHash(key1Hex) - } - - statedb.IntermediateRoot(false) - - val := common.BigToHash(big.NewInt(int64(17))) - trieMod := TrieModification{ - Type: StorageChanged, - Key: key1, - Value: val, - Address: addr, - } - trieModifications := []TrieModification{trieMod} - - GenerateProof("NonHashedExtensionNodeInBranch", trieModifications, statedb) - - oracle.PreventHashingInSecureTrie = false -} - -// Note: this requires MockProver with config param 11 -func TestNonHashedExtensionNodeInBranchTwoNibbles(t *testing.T) { - blockNum := 0 - blockNumberParent := big.NewInt(int64(blockNum)) - blockHeaderParent := oracle.PrefetchBlock(blockNumberParent, true, nil) - database := state.NewDatabase(blockHeaderParent) - statedb, _ := state.New(blockHeaderParent.Root, database, nil) - addr := common.HexToAddress("0x50efbf12580138bc623c95757286df4e24eb81c9") - - statedb.DisableLoadingRemoteAccounts() - - statedb.CreateAccount(addr) - - oracle.PreventHashingInSecureTrie = true // to store the unchanged key - - val1 := common.BigToHash(big.NewInt(int64(1))) - - key1Hex := "0x1000000000000000000000000000000000000000000000000000000000000000" - key2Hex := "0x2000000000000000000000000000000000000000000000000000000000000000" - key1 := common.HexToHash(key1Hex) - key2 := common.HexToHash(key2Hex) - fmt.Println(key2) - - statedb.SetState(addr, key2, val1) - - iters := 58 // make the extension node shorter than 32 - for i := 0; i < iters; i++ { - statedb.SetState(addr, key1, val1) - - if i == iters - 1 { - break - } - - makeExtension := false - if i == iters - 2 { - makeExtension = true - } - - if !makeExtension { - key1Hex = replaceAtIndex(key1Hex, 49, i + 3) - } else { - key1Hex = replaceAtIndex(key1Hex, 49, i + 2 + 3) // +2 to have two nibbles - } - - key1 = common.HexToHash(key1Hex) - } - - statedb.IntermediateRoot(false) - - val := common.BigToHash(big.NewInt(int64(17))) - trieMod := TrieModification{ - Type: StorageChanged, - Key: key1, - Value: val, - Address: addr, - } - trieModifications := []TrieModification{trieMod} - - GenerateProof("NonHashedExtensionNodeInBranchTwoNibbles", trieModifications, statedb) - - oracle.PreventHashingInSecureTrie = false -} -*/ - func TestBranchAfterExtNode(t *testing.T) { blockNum := 0 blockNumberParent := big.NewInt(int64(blockNum)) diff --git a/mpt-witness-generator/witness/gen_witness_from_local_blockchain_test.go b/mpt-witness-generator/witness/gen_witness_from_local_blockchain_test.go index aab3b97734..8b9345b1a4 100644 --- a/mpt-witness-generator/witness/gen_witness_from_local_blockchain_test.go +++ b/mpt-witness-generator/witness/gen_witness_from_local_blockchain_test.go @@ -232,45 +232,6 @@ func TestAccountBranchPlaceholderInFirstLevel(t *testing.T) { database := state.NewDatabase(blockHeaderParent) statedb, _ := state.New(blockHeaderParent.Root, database, nil) - /* - for i := 0; i < 100000; i++ { - h := fmt.Sprintf("0xa21%d", i) - addr := common.HexToAddress(h) - - oracle.PrefetchAccount(statedb.Db.BlockNumber, addr, nil) - proof1, _, _, _, err := statedb.GetProof(addr) - check(err) - - statedb.CreateAccount(addr) - statedb.IntermediateRoot(false) - - // addrHash1 := crypto.Keccak256Hash(addr.Bytes()) - // addrHash1[31] = (addrHash1[31] + 1) % 255 // just some change - - // oracle.PrefetchAccount(statedb.Db.BlockNumber, addr1, nil) - // proof11, _, _, err := statedb.GetProofByHash(common.BytesToHash(addrHash1.Bytes())) - - statedb.CreateAccount(addr) - statedb.IntermediateRoot(false) - - proof2, _, _, _, err := statedb.GetProof(addr) - check(err) - if len(proof1) + 1 == len(proof2) && len(proof1) == 1 { - elems, _, err := rlp.SplitList(proof1[len(proof1)-1]) - if err != nil { - fmt.Println("decode error", err) - } - switch c, _ := rlp.CountValues(elems); c { - case 2: - fmt.Println("2") - case 17: - default: - fmt.Println("invalid number of list elements") - } - } - } - */ - h := fmt.Sprintf("0xab%d", 0) addr := common.HexToAddress(h) // Implicitly create account such that the account from the first level will be @@ -607,209 +568,3 @@ func TestExtNodeInsertedBefore6After1FirstLevel(t *testing.T) { ExtNodeInserted(key1, key2, key3, "ExtNodeInsertedBefore6After1FirstLevel") } - -/* -func TestExtNodeDeletedBefore6After1FirstLevel(t *testing.T) { - key1 := common.HexToHash("0x1234561000000000000000000000000000000000000000000000000000000000") - // key1 bytes: [1 * 16 + 2, 3 * 16 + 4, 5 * 16 + 6, 1 * 16, 0, ..., 0] - - key2 := common.HexToHash("0x1234563000000000000000000000000000000000000000000000000000000000") - // key2 bytes: [1 * 16 + 2, 3 * 16 + 4, 5 * 16 + 6, 3 * 16, 0, ..., 0] - // We now have an extension node with nibbles: [1, 2, 3, 4, 5, 6]. - - key3 := common.HexToHash("0x1234400000000000000000000000000000000000000000000000000000000000") - - ExtNodeDeleted(key1, key2, key3, "ExtNodeDeletedBefore6After1FirstLevel") -} - -func TestExtNodeInsertedBefore6After2FirstLevel(t *testing.T) { - key1 := common.HexToHash("0x1234561000000000000000000000000000000000000000000000000000000000") - // key1 bytes: [1 * 16 + 2, 3 * 16 + 4, 5 * 16 + 6, 1 * 16, 0, ..., 0] - - key2 := common.HexToHash("0x1234563000000000000000000000000000000000000000000000000000000000") - // key2 bytes: [1 * 16 + 2, 3 * 16 + 4, 5 * 16 + 6, 3 * 16, 0, ..., 0] - - key3 := common.HexToHash("0x1235400000000000000000000000000000000000000000000000000000000000") - // key3 bytes: [1 * 16 + 2, 3 * 16 + 5, 4 * 16 + 0, 0, ..., 0] - - ExtNodeInserted(key1, key2, key3, "ExtNodeInsertedBefore6After2FirstLevel") -} - -func TestExtNodeInsertedBefore6After4FirstLevel(t *testing.T) { - key1 := common.HexToHash("0x1234561000000000000000000000000000000000000000000000000000000000") - // key1 bytes: [1 * 16 + 2, 3 * 16 + 4, 5 * 16 + 6, 1 * 16, 0, ..., 0] - - key2 := common.HexToHash("0x1234563000000000000000000000000000000000000000000000000000000000") - // key2 bytes: [1 * 16 + 2, 3 * 16 + 4, 5 * 16 + 6, 3 * 16, 0, ..., 0] - - key3 := common.HexToHash("0x1635400000000000000000000000000000000000000000000000000000000000") - - ExtNodeInserted(key1, key2, key3, "ExtNodeInsertedBefore6After4FirstLevel") -} - -func TestExtNodeInsertedBefore5After3FirstLevel(t *testing.T) { - key1 := common.HexToHash("0x2345610000000000000000000000000000000000000000000000000000000000") - key2 := common.HexToHash("0x2345630000000000000000000000000000000000000000000000000000000000") - key3 := common.HexToHash("0x2635400000000000000000000000000000000000000000000000000000000000") - - ExtNodeInserted(key1, key2, key3, "ExtNodeInsertedBefore5After3FirstLevel") -} - -func TestExtNodeInsertedBefore5After2FirstLevel(t *testing.T) { - key1 := common.HexToHash("0x2345610000000000000000000000000000000000000000000000000000000000") - key2 := common.HexToHash("0x2345630000000000000000000000000000000000000000000000000000000000") - key3 := common.HexToHash("0x2335400000000000000000000000000000000000000000000000000000000000") - - ExtNodeInserted(key1, key2, key3, "ExtNodeInsertedBefore5After2FirstLevel") -} - -func TestExtNodeInsertedBefore5After1FirstLevel(t *testing.T) { - key1 := common.HexToHash("0x2345610000000000000000000000000000000000000000000000000000000000") - key2 := common.HexToHash("0x2345630000000000000000000000000000000000000000000000000000000000") - key3 := common.HexToHash("0x2343540000000000000000000000000000000000000000000000000000000000") - - ExtNodeInserted(key1, key2, key3, "ExtNodeInsertedBefore5After1FirstLevel") -} - -func TestExtNodeInsertedBefore4After1(t *testing.T) { - oracle.NodeUrl = oracle.LocalUrl - - blockNum := 0 - blockNumberParent := big.NewInt(int64(blockNum)) - blockHeaderParent := oracle.PrefetchBlock(blockNumberParent, true, nil) - database := state.NewDatabase(blockHeaderParent) - statedb, _ := state.New(blockHeaderParent.Root, database, nil) - addr := common.HexToAddress("0x50efbf12580138bc623c95757286df4e24eb81c9") - - statedb.DisableLoadingRemoteAccounts() - - statedb.CreateAccount(addr) - - oracle.PreventHashingInSecureTrie = true // to store the unchanged key - - val0 := common.BigToHash(big.NewInt(int64(1))) - key0 := common.HexToHash("0x1000000000000000000000000000000000000000000000000000000000000000") - statedb.SetState(addr, key0, val0) - - key00 := common.HexToHash("0x0000000000000000000000000000000000000000000000000000000000000000") - statedb.SetState(addr, key00, val0) - - key1 := common.HexToHash("0x1234561000000000000000000000000000000000000000000000000000000000") - // key1 bytes: [1 * 16 + 2, 3 * 16 + 4, 5 * 16 + 6, 1 * 16, 0, ..., 0] - - // make the value long to have a hashed branch - v1 := common.FromHex("0xbbefaa12580138bc263c95757826df4e24eb81c9aaaaaaaaaaaaaaaaaaaaaaaa") - val1 := common.BytesToHash(v1) - // val1 := common.BigToHash(big.NewInt(int64(1))) - statedb.SetState(addr, key1, val1) - - key2 := common.HexToHash("0x1234563000000000000000000000000000000000000000000000000000000000") - // key2 bytes: [1 * 16 + 2, 3 * 16 + 4, 5 * 16 + 6, 3 * 16, 0, ..., 0] - - // We now have an extension node with nibbles: [3, 4, 5, 6]. - - statedb.SetState(addr, key2, val1) - statedb.IntermediateRoot(false) - - key3 := common.HexToHash("0x1234400000000000000000000000000000000000000000000000000000000000") - // After adding key3 we will have an extension node with nibbles [3, 4] - // and another one with nibbles [5, 6]. - - v1 = common.FromHex("0xbb") - val := common.BytesToHash(v1) - trieMod := TrieModification{ - Type: StorageMod, - Key: key3, - Value: val, - Address: addr, - } - trieModifications := []TrieModification{trieMod} - - prepareWitness("ExtNodeInsertedBefore4After1", trieModifications, statedb) - - oracle.PreventHashingInSecureTrie = false -} - -func TestExtNodeDeletedBefore4After1(t *testing.T) { - oracle.NodeUrl = oracle.LocalUrl - - blockNum := 0 - blockNumberParent := big.NewInt(int64(blockNum)) - blockHeaderParent := oracle.PrefetchBlock(blockNumberParent, true, nil) - database := state.NewDatabase(blockHeaderParent) - statedb, _ := state.New(blockHeaderParent.Root, database, nil) - addr := common.HexToAddress("0x50efbf12580138bc623c95757286df4e24eb81c9") - - statedb.DisableLoadingRemoteAccounts() - - statedb.CreateAccount(addr) - - oracle.PreventHashingInSecureTrie = true // to store the unchanged key - - val0 := common.BigToHash(big.NewInt(int64(1))) - key0 := common.HexToHash("0x1000000000000000000000000000000000000000000000000000000000000000") - statedb.SetState(addr, key0, val0) - - key00 := common.HexToHash("0x0000000000000000000000000000000000000000000000000000000000000000") - statedb.SetState(addr, key00, val0) - - key1 := common.HexToHash("0x1234561000000000000000000000000000000000000000000000000000000000") - - // make the value long to have a hashed branch - v1 := common.FromHex("0xbbefaa12580138bc263c95757826df4e24eb81c9aaaaaaaaaaaaaaaaaaaaaaaa") - val1 := common.BytesToHash(v1) - statedb.SetState(addr, key1, val1) - - key2 := common.HexToHash("0x1234563000000000000000000000000000000000000000000000000000000000") - statedb.SetState(addr, key2, val1) - - key3 := common.HexToHash("0x1234400000000000000000000000000000000000000000000000000000000000") - statedb.SetState(addr, key3, val1) - statedb.IntermediateRoot(false) - - val := common.Hash{} // empty value deletes the key - trieMod := TrieModification{ - Type: StorageMod, - Key: key3, - Value: val, - Address: addr, - } - trieModifications := []TrieModification{trieMod} - - prepareWitness("ExtNodeDeletedBefore4After1", trieModifications, statedb) - - oracle.PreventHashingInSecureTrie = false -} - -func TestExtNodeInNewBranchFirstLevel(t *testing.T) { - key1 := common.HexToHash("0x2345610000000000000000000000000000000000000000000000000000000000") - key2 := common.HexToHash("0x2345630000000000000000000000000000000000000000000000000000000000") - key3 := common.HexToHash("0x6354000000000000000000000000000000000000000000000000000000000000") - - ExtNodeInserted(key1, key2, key3, "ExtNodeInsertedInNewBranchFirstLevel") -} - -func TestExtNodeDeletedBranchDeletedFirstLevel(t *testing.T) { - key1 := common.HexToHash("0x2345610000000000000000000000000000000000000000000000000000000000") - key2 := common.HexToHash("0x2345630000000000000000000000000000000000000000000000000000000000") - key3 := common.HexToHash("0x6354000000000000000000000000000000000000000000000000000000000000") - - ExtNodeDeleted(key1, key2, key3, "ExtNodeDeletedBranchDeletedFirstLevel") -} - -func TestExtNodeInsertedExtShortIsBranchFirstLevel(t *testing.T) { - key1 := common.HexToHash("0x2345610000000000000000000000000000000000000000000000000000000000") - key2 := common.HexToHash("0x2345630000000000000000000000000000000000000000000000000000000000") - key3 := common.HexToHash("0x2345100000000000000000000000000000000000000000000000000000000000") - - ExtNodeInserted(key1, key2, key3, "ExtNodeInsertedExtShortIsBranchFirstLevel") -} - -func TestExtNodeDeletedExtShortIsBranchFirstLevel(t *testing.T) { - key1 := common.HexToHash("0x2345610000000000000000000000000000000000000000000000000000000000") - key2 := common.HexToHash("0x2345630000000000000000000000000000000000000000000000000000000000") - key3 := common.HexToHash("0x2345100000000000000000000000000000000000000000000000000000000000") - - ExtNodeDeleted(key1, key2, key3, "ExtNodeInsertedExtShortIsBranchFirstLevel") -} -*/ diff --git a/mpt-witness-generator/witness/gen_witness_transactions_test.go b/mpt-witness-generator/witness/gen_witness_transactions_test.go index 442885246c..51c10cd6dd 100644 --- a/mpt-witness-generator/witness/gen_witness_transactions_test.go +++ b/mpt-witness-generator/witness/gen_witness_transactions_test.go @@ -15,22 +15,6 @@ import ( "github.com/privacy-scaling-explorations/mpt-witness-generator/types" ) -func createTransaction(ind int) *types.Transaction { - key, _ := crypto.GenerateKey() - signer := types.LatestSigner(params.TestChainConfig) - - amount := math.BigPow(2, int64(ind)) - price := big.NewInt(300000) - data := make([]byte, 100) - tx := types.NewTransaction(uint64(ind), common.Address{}, amount, 123457, price, data) - signedTx, err := types.SignTx(tx, signer, key) - if err != nil { - panic(err) - } - - return signedTx -} - func TestTransactions(t *testing.T) { t.Skip("failing test") txs := make([]*types.Transaction, 70) @@ -54,11 +38,6 @@ func TestTransactions(t *testing.T) { stackTrie.UpdateAndGetProofs(db, types.Transactions(txs)) - /* - rowsTransactions, toBeHashedAcc, _ := - convertProofToWitness(statedb, addr, accountProof, accountProof1, aExtNibbles1, aExtNibbles2, accountAddr, aNode, true, tMod.Type == NonExistingAccount, false, isShorterProofLastLeaf) - */ - fmt.Println("===") } diff --git a/mpt-witness-generator/witness/leaf.go b/mpt-witness-generator/witness/leaf.go index 39f36be95e..b22ae4c85d 100644 --- a/mpt-witness-generator/witness/leaf.go +++ b/mpt-witness-generator/witness/leaf.go @@ -446,11 +446,6 @@ func prepareStorageLeafInfo(row []byte, valueIsZero, isPlaceholder bool) ([]byte setValue(keyLen, offset) } else { // [196,130,32,0,1] - /* - keyLen := row[1] - 128 - copy(key, row[:keyLen+2]) - copy(value, row[keyLen+2:]) - */ keyRlpLen = 1 keyLen := row[1] - 128 keyRlp = row[:keyRlpLen] diff --git a/mpt-witness-generator/witness/modified_extension_node.go b/mpt-witness-generator/witness/modified_extension_node.go index ad4d0073de..19b357828d 100644 --- a/mpt-witness-generator/witness/modified_extension_node.go +++ b/mpt-witness-generator/witness/modified_extension_node.go @@ -41,11 +41,6 @@ func prepareModExtensionNode(statedb *state.StateDB, addr common.Address, rows * extNodeSelectors = append(extNodeSelectors, 24) _, extListRlpBytesS, extValuesS := prepareExtensions(extNibbles, extensionNodeInd, longExtNode, longExtNode) - /* - b := []byte{249, 1, 49, 128} // We don't really need a branch info (only extension node). - longNode := prepareBranchNode(b, b, longExtNode, longExtNode, extListRlpBytes, extValues, - key[keyIndex], key[keyIndex], branchC16, branchC1, false, false, true, false, false) - */ var extRows [][]byte // We need to prove the old extension node is in S proof (when ext. node inserted). @@ -61,7 +56,6 @@ func prepareModExtensionNode(statedb *state.StateDB, addr common.Address, rows * longNibbles := getExtensionNodeNibbles(longExtNode) ind := byte(keyIndex) + byte(numberOfNibbles) // where the old and new extension nodes start to be different - // diffNibble := oldNibbles[ind] longExtNodeKey := make([]byte, len(key)) copy(longExtNodeKey, key) // We would like to retrieve the shortened extension node from the trie via GetProof or @@ -91,13 +85,6 @@ func prepareModExtensionNode(statedb *state.StateDB, addr common.Address, rows * } var shortExtNode []byte - /* - extNodeSelectors1 := make([]byte, rowLen) - emptyExtRows := prepareEmptyExtensionRows(false, true) - extensionRowS1 := emptyExtRows[0] - extensionRowC1 := emptyExtRows[1] - */ - var extListRlpBytesC []byte var extValuesC [][]byte @@ -141,38 +128,13 @@ func prepareModExtensionNode(statedb *state.StateDB, addr common.Address, rows * // Enable `prepareExtensionRows` call: extNibbles = append(extNibbles, nibbles) - /* - var numberOfNibbles1 byte - numberOfNibbles1, extensionRowS1, extensionRowC1 = - prepareExtensionRows(extNibbles, extensionNodeInd + 1, shortExtNode, shortExtNode, false, true) - */ - _, extListRlpBytesC, extValuesC = prepareExtensions(extNibbles, extensionNodeInd+1, shortExtNode, shortExtNode) - /* - shortNode = prepareBranchNode(b, b, shortExtNode, shortExtNode, extListRlpBytes, extValues, - key[keyIndex], key[keyIndex], branchC16, branchC1, false, false, true, false, false) - - setExtNodeSelectors(extNodeSelectors1, shortExtNode, int(numberOfNibbles1), branchC16) - */ - // extNodeSelectors1 = append(extNodeSelectors1, 25) - } /* else { - if len1 > len2 { - // Needed only for len1 > len2 - (*rows)[len(*rows)-branchRows-9][driftedPos] = longNibbles[numberOfNibbles] - } - extNodeSelectors1 = append(extNodeSelectors1, 25) } - */ // The shortened extension node is needed as a witness to be able to check in a circuit // that the shortened extension node and newly added leaf (that causes newly inserted // extension node) are the only nodes in the newly inserted extension node. - /* - *rows = append(*rows, extNodeSelectors1) - *rows = append(*rows, extensionRowS1) - *rows = append(*rows, extensionRowC1) - */ listRlpBytes := [2][]byte{extListRlpBytesS, extListRlpBytesC} modExtensionNode := ModExtensionNode{ diff --git a/mpt-witness-generator/witness/util.go b/mpt-witness-generator/witness/util.go index 171a223dd7..f2adbb53d3 100644 --- a/mpt-witness-generator/witness/util.go +++ b/mpt-witness-generator/witness/util.go @@ -6,7 +6,6 @@ import ( "log" "os" "path/filepath" - "strconv" ) func check(err error) { @@ -15,33 +14,6 @@ func check(err error) { } } -func MatrixToJson(rows [][]byte) string { - // Had some problems with json.Marshal, so I just prepare json manually. - json := "[" - for i := 0; i < len(rows); i++ { - json += listToJson(rows[i]) - if i != len(rows)-1 { - json += "," - } - } - json += "]" - - return json -} - -func listToJson(row []byte) string { - json := "[" - for j := 0; j < len(row); j++ { - json += strconv.Itoa(int(row[j])) - if j != len(row)-1 { - json += "," - } - } - json += "]" - - return json -} - func StoreNodes(testName string, nodes []Node) { name := testName + ".json" path := "../generated_witnesses/" + name