├── .gitignore ├── Cargo.lock ├── Cargo.toml ├── README.md ├── src ├── embedding.rs ├── lib.rs └── tree.rs └── tests ├── embedding_test.rs └── tree_test.rs /.gitignore: -------------------------------------------------------------------------------- 1 | /target 2 | -------------------------------------------------------------------------------- /Cargo.lock: -------------------------------------------------------------------------------- 1 | # This file is automatically @generated by Cargo. 2 | # It is not intended for manual editing. 3 | version = 3 4 | 5 | [[package]] 6 | name = "alloy-primitives" 7 | version = "0.8.19" 8 | source = "registry+https://github.com/rust-lang/crates.io-index" 9 | checksum = "ec878088ec6283ce1e90d280316aadd3d6ce3de06ff63d68953c855e7e447e92" 10 | dependencies = [ 11 | "alloy-rlp", 12 | "bytes", 13 | "cfg-if", 14 | "const-hex", 15 | "derive_more", 16 | "foldhash", 17 | "hashbrown", 18 | "indexmap", 19 | "itoa", 20 | "k256", 21 | "keccak-asm", 22 | "paste", 23 | "proptest", 24 | "rand", 25 | "ruint", 26 | "rustc-hash", 27 | "serde", 28 | "sha3", 29 | "tiny-keccak", 30 | ] 31 | 32 | [[package]] 33 | name = "alloy-rlp" 34 | version = "0.3.11" 35 | source = "registry+https://github.com/rust-lang/crates.io-index" 36 | checksum = "3d6c1d995bff8d011f7cd6c81820d51825e6e06d6db73914c1630ecf544d83d6" 37 | dependencies = [ 38 | "arrayvec", 39 | "bytes", 40 | ] 41 | 42 | [[package]] 43 | name = "ark-ff" 44 | version = "0.3.0" 45 | source = "registry+https://github.com/rust-lang/crates.io-index" 46 | checksum = "6b3235cc41ee7a12aaaf2c575a2ad7b46713a8a50bda2fc3b003a04845c05dd6" 47 | dependencies = [ 48 | "ark-ff-asm 0.3.0", 49 | "ark-ff-macros 0.3.0", 50 | "ark-serialize 0.3.0", 51 | "ark-std 0.3.0", 52 | "derivative", 53 | "num-bigint", 54 | "num-traits", 55 | "paste", 56 | "rustc_version 0.3.3", 57 | "zeroize", 58 | ] 59 | 60 | [[package]] 61 | name = "ark-ff" 62 | version = "0.4.2" 63 | source = "registry+https://github.com/rust-lang/crates.io-index" 64 | checksum = "ec847af850f44ad29048935519032c33da8aa03340876d351dfab5660d2966ba" 65 | dependencies = [ 66 | "ark-ff-asm 0.4.2", 67 | "ark-ff-macros 0.4.2", 68 | "ark-serialize 0.4.2", 69 | "ark-std 0.4.0", 70 | "derivative", 71 | "digest 0.10.7", 72 | "itertools", 73 | "num-bigint", 74 | "num-traits", 75 | "paste", 76 | "rustc_version 0.4.1", 77 | "zeroize", 78 | ] 79 | 80 | [[package]] 81 | name = "ark-ff-asm" 82 | version = "0.3.0" 83 | source = "registry+https://github.com/rust-lang/crates.io-index" 84 | checksum = "db02d390bf6643fb404d3d22d31aee1c4bc4459600aef9113833d17e786c6e44" 85 | dependencies = [ 86 | "quote", 87 | "syn 1.0.109", 88 | ] 89 | 90 | [[package]] 91 | name = "ark-ff-asm" 92 | version = "0.4.2" 93 | source = "registry+https://github.com/rust-lang/crates.io-index" 94 | checksum = "3ed4aa4fe255d0bc6d79373f7e31d2ea147bcf486cba1be5ba7ea85abdb92348" 95 | dependencies = [ 96 | "quote", 97 | "syn 1.0.109", 98 | ] 99 | 100 | [[package]] 101 | name = "ark-ff-macros" 102 | version = "0.3.0" 103 | source = "registry+https://github.com/rust-lang/crates.io-index" 104 | checksum = "db2fd794a08ccb318058009eefdf15bcaaaaf6f8161eb3345f907222bac38b20" 105 | dependencies = [ 106 | "num-bigint", 107 | "num-traits", 108 | "quote", 109 | "syn 1.0.109", 110 | ] 111 | 112 | [[package]] 113 | name = "ark-ff-macros" 114 | version = "0.4.2" 115 | source = "registry+https://github.com/rust-lang/crates.io-index" 116 | checksum = "7abe79b0e4288889c4574159ab790824d0033b9fdcb2a112a3182fac2e514565" 117 | dependencies = [ 118 | "num-bigint", 119 | "num-traits", 120 | "proc-macro2", 121 | "quote", 122 | "syn 1.0.109", 123 | ] 124 | 125 | [[package]] 126 | name = "ark-serialize" 127 | version = "0.3.0" 128 | source = "registry+https://github.com/rust-lang/crates.io-index" 129 | checksum = "1d6c2b318ee6e10f8c2853e73a83adc0ccb88995aa978d8a3408d492ab2ee671" 130 | dependencies = [ 131 | "ark-std 0.3.0", 132 | "digest 0.9.0", 133 | ] 134 | 135 | [[package]] 136 | name = "ark-serialize" 137 | version = "0.4.2" 138 | source = "registry+https://github.com/rust-lang/crates.io-index" 139 | checksum = "adb7b85a02b83d2f22f89bd5cac66c9c89474240cb6207cb1efc16d098e822a5" 140 | dependencies = [ 141 | "ark-std 0.4.0", 142 | "digest 0.10.7", 143 | "num-bigint", 144 | ] 145 | 146 | [[package]] 147 | name = "ark-std" 148 | version = "0.3.0" 149 | source = "registry+https://github.com/rust-lang/crates.io-index" 150 | checksum = "1df2c09229cbc5a028b1d70e00fdb2acee28b1055dfb5ca73eea49c5a25c4e7c" 151 | dependencies = [ 152 | "num-traits", 153 | "rand", 154 | ] 155 | 156 | [[package]] 157 | name = "ark-std" 158 | version = "0.4.0" 159 | source = "registry+https://github.com/rust-lang/crates.io-index" 160 | checksum = "94893f1e0c6eeab764ade8dc4c0db24caf4fe7cbbaafc0eba0a9030f447b5185" 161 | dependencies = [ 162 | "num-traits", 163 | "rand", 164 | ] 165 | 166 | [[package]] 167 | name = "arrayref" 168 | version = "0.3.9" 169 | source = "registry+https://github.com/rust-lang/crates.io-index" 170 | checksum = "76a2e8124351fda1ef8aaaa3bbd7ebbcb486bbcd4225aca0aa0d84bb2db8fecb" 171 | 172 | [[package]] 173 | name = "arrayvec" 174 | version = "0.7.6" 175 | source = "registry+https://github.com/rust-lang/crates.io-index" 176 | checksum = "7c02d123df017efcdfbd739ef81735b36c5ba83ec3c59c80a9d7ecc718f92e50" 177 | 178 | [[package]] 179 | name = "auto_impl" 180 | version = "1.2.1" 181 | source = "registry+https://github.com/rust-lang/crates.io-index" 182 | checksum = "e12882f59de5360c748c4cbf569a042d5fb0eb515f7bea9c1f470b47f6ffbd73" 183 | dependencies = [ 184 | "proc-macro2", 185 | "quote", 186 | "syn 2.0.96", 187 | ] 188 | 189 | [[package]] 190 | name = "autocfg" 191 | version = "1.4.0" 192 | source = "registry+https://github.com/rust-lang/crates.io-index" 193 | checksum = "ace50bade8e6234aa140d9a2f552bbee1db4d353f69b8217bc503490fc1a9f26" 194 | 195 | [[package]] 196 | name = "base16ct" 197 | version = "0.2.0" 198 | source = "registry+https://github.com/rust-lang/crates.io-index" 199 | checksum = "4c7f02d4ea65f2c1853089ffd8d2787bdbc63de2f0d29dedbcf8ccdfa0ccd4cf" 200 | 201 | [[package]] 202 | name = "base64ct" 203 | version = "1.6.0" 204 | source = "registry+https://github.com/rust-lang/crates.io-index" 205 | checksum = "8c3c1a368f70d6cf7302d78f8f7093da241fb8e8807c05cc9e51a125895a6d5b" 206 | 207 | [[package]] 208 | name = "bit-set" 209 | version = "0.5.3" 210 | source = "registry+https://github.com/rust-lang/crates.io-index" 211 | checksum = "0700ddab506f33b20a03b13996eccd309a48e5ff77d0d95926aa0210fb4e95f1" 212 | dependencies = [ 213 | "bit-vec", 214 | ] 215 | 216 | [[package]] 217 | name = "bit-vec" 218 | version = "0.6.3" 219 | source = "registry+https://github.com/rust-lang/crates.io-index" 220 | checksum = "349f9b6a179ed607305526ca489b34ad0a41aed5f7980fa90eb03160b69598fb" 221 | 222 | [[package]] 223 | name = "bitflags" 224 | version = "2.8.0" 225 | source = "registry+https://github.com/rust-lang/crates.io-index" 226 | checksum = "8f68f53c83ab957f72c32642f3868eec03eb974d1fb82e453128456482613d36" 227 | 228 | [[package]] 229 | name = "bitvec" 230 | version = "1.0.1" 231 | source = "registry+https://github.com/rust-lang/crates.io-index" 232 | checksum = "1bc2832c24239b0141d5674bb9174f9d68a8b5b3f2753311927c172ca46f7e9c" 233 | dependencies = [ 234 | "funty", 235 | "radium", 236 | "tap", 237 | "wyz", 238 | ] 239 | 240 | [[package]] 241 | name = "blake3" 242 | version = "1.5.5" 243 | source = "registry+https://github.com/rust-lang/crates.io-index" 244 | checksum = "b8ee0c1824c4dea5b5f81736aff91bae041d2c07ee1192bec91054e10e3e601e" 245 | dependencies = [ 246 | "arrayref", 247 | "arrayvec", 248 | "cc", 249 | "cfg-if", 250 | "constant_time_eq", 251 | ] 252 | 253 | [[package]] 254 | name = "block-buffer" 255 | version = "0.10.4" 256 | source = "registry+https://github.com/rust-lang/crates.io-index" 257 | checksum = "3078c7629b62d3f0439517fa394996acacc5cbc91c5a20d8c658e77abd503a71" 258 | dependencies = [ 259 | "generic-array", 260 | ] 261 | 262 | [[package]] 263 | name = "byte-slice-cast" 264 | version = "1.2.2" 265 | source = "registry+https://github.com/rust-lang/crates.io-index" 266 | checksum = "c3ac9f8b63eca6fd385229b3675f6cc0dc5c8a5c8a54a59d4f52ffd670d87b0c" 267 | 268 | [[package]] 269 | name = "byteorder" 270 | version = "1.5.0" 271 | source = "registry+https://github.com/rust-lang/crates.io-index" 272 | checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b" 273 | 274 | [[package]] 275 | name = "bytes" 276 | version = "1.9.0" 277 | source = "registry+https://github.com/rust-lang/crates.io-index" 278 | checksum = "325918d6fe32f23b19878fe4b34794ae41fc19ddbe53b10571a4874d44ffd39b" 279 | dependencies = [ 280 | "serde", 281 | ] 282 | 283 | [[package]] 284 | name = "cc" 285 | version = "1.2.10" 286 | source = "registry+https://github.com/rust-lang/crates.io-index" 287 | checksum = "13208fcbb66eaeffe09b99fffbe1af420f00a7b35aa99ad683dfc1aa76145229" 288 | dependencies = [ 289 | "shlex", 290 | ] 291 | 292 | [[package]] 293 | name = "cfg-if" 294 | version = "1.0.0" 295 | source = "registry+https://github.com/rust-lang/crates.io-index" 296 | checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" 297 | 298 | [[package]] 299 | name = "const-hex" 300 | version = "1.14.0" 301 | source = "registry+https://github.com/rust-lang/crates.io-index" 302 | checksum = "4b0485bab839b018a8f1723fc5391819fea5f8f0f32288ef8a735fd096b6160c" 303 | dependencies = [ 304 | "cfg-if", 305 | "cpufeatures", 306 | "hex", 307 | "proptest", 308 | "serde", 309 | ] 310 | 311 | [[package]] 312 | name = "const-oid" 313 | version = "0.9.6" 314 | source = "registry+https://github.com/rust-lang/crates.io-index" 315 | checksum = "c2459377285ad874054d797f3ccebf984978aa39129f6eafde5cdc8315b612f8" 316 | 317 | [[package]] 318 | name = "constant_time_eq" 319 | version = "0.3.1" 320 | source = "registry+https://github.com/rust-lang/crates.io-index" 321 | checksum = "7c74b8349d32d297c9134b8c88677813a227df8f779daa29bfc29c183fe3dca6" 322 | 323 | [[package]] 324 | name = "cpufeatures" 325 | version = "0.2.16" 326 | source = "registry+https://github.com/rust-lang/crates.io-index" 327 | checksum = "16b80225097f2e5ae4e7179dd2266824648f3e2f49d9134d584b76389d31c4c3" 328 | dependencies = [ 329 | "libc", 330 | ] 331 | 332 | [[package]] 333 | name = "crunchy" 334 | version = "0.2.3" 335 | source = "registry+https://github.com/rust-lang/crates.io-index" 336 | checksum = "43da5946c66ffcc7745f48db692ffbb10a83bfe0afd96235c5c2a4fb23994929" 337 | 338 | [[package]] 339 | name = "crypto-bigint" 340 | version = "0.5.5" 341 | source = "registry+https://github.com/rust-lang/crates.io-index" 342 | checksum = "0dc92fb57ca44df6db8059111ab3af99a63d5d0f8375d9972e319a379c6bab76" 343 | dependencies = [ 344 | "generic-array", 345 | "rand_core", 346 | "subtle", 347 | "zeroize", 348 | ] 349 | 350 | [[package]] 351 | name = "crypto-common" 352 | version = "0.1.6" 353 | source = "registry+https://github.com/rust-lang/crates.io-index" 354 | checksum = "1bfb12502f3fc46cca1bb51ac28df9d618d813cdc3d2f25b9fe775a34af26bb3" 355 | dependencies = [ 356 | "generic-array", 357 | "typenum", 358 | ] 359 | 360 | [[package]] 361 | name = "der" 362 | version = "0.7.9" 363 | source = "registry+https://github.com/rust-lang/crates.io-index" 364 | checksum = "f55bf8e7b65898637379c1b74eb1551107c8294ed26d855ceb9fd1a09cfc9bc0" 365 | dependencies = [ 366 | "const-oid", 367 | "zeroize", 368 | ] 369 | 370 | [[package]] 371 | name = "derivative" 372 | version = "2.2.0" 373 | source = "registry+https://github.com/rust-lang/crates.io-index" 374 | checksum = "fcc3dd5e9e9c0b295d6e1e4d811fb6f157d5ffd784b8d202fc62eac8035a770b" 375 | dependencies = [ 376 | "proc-macro2", 377 | "quote", 378 | "syn 1.0.109", 379 | ] 380 | 381 | [[package]] 382 | name = "derive_more" 383 | version = "1.0.0" 384 | source = "registry+https://github.com/rust-lang/crates.io-index" 385 | checksum = "4a9b99b9cbbe49445b21764dc0625032a89b145a2642e67603e1c936f5458d05" 386 | dependencies = [ 387 | "derive_more-impl", 388 | ] 389 | 390 | [[package]] 391 | name = "derive_more-impl" 392 | version = "1.0.0" 393 | source = "registry+https://github.com/rust-lang/crates.io-index" 394 | checksum = "cb7330aeadfbe296029522e6c40f315320aba36fc43a5b3632f3795348f3bd22" 395 | dependencies = [ 396 | "proc-macro2", 397 | "quote", 398 | "syn 2.0.96", 399 | "unicode-xid", 400 | ] 401 | 402 | [[package]] 403 | name = "digest" 404 | version = "0.9.0" 405 | source = "registry+https://github.com/rust-lang/crates.io-index" 406 | checksum = "d3dd60d1080a57a05ab032377049e0591415d2b31afd7028356dbf3cc6dcb066" 407 | dependencies = [ 408 | "generic-array", 409 | ] 410 | 411 | [[package]] 412 | name = "digest" 413 | version = "0.10.7" 414 | source = "registry+https://github.com/rust-lang/crates.io-index" 415 | checksum = "9ed9a281f7bc9b7576e61468ba615a66a5c8cfdff42420a70aa82701a3b1e292" 416 | dependencies = [ 417 | "block-buffer", 418 | "const-oid", 419 | "crypto-common", 420 | "subtle", 421 | ] 422 | 423 | [[package]] 424 | name = "ecdsa" 425 | version = "0.16.9" 426 | source = "registry+https://github.com/rust-lang/crates.io-index" 427 | checksum = "ee27f32b5c5292967d2d4a9d7f1e0b0aed2c15daded5a60300e4abb9d8020bca" 428 | dependencies = [ 429 | "der", 430 | "digest 0.10.7", 431 | "elliptic-curve", 432 | "rfc6979", 433 | "signature", 434 | "spki", 435 | ] 436 | 437 | [[package]] 438 | name = "either" 439 | version = "1.13.0" 440 | source = "registry+https://github.com/rust-lang/crates.io-index" 441 | checksum = "60b1af1c220855b6ceac025d3f6ecdd2b7c4894bfe9cd9bda4fbb4bc7c0d4cf0" 442 | 443 | [[package]] 444 | name = "elliptic-curve" 445 | version = "0.13.8" 446 | source = "registry+https://github.com/rust-lang/crates.io-index" 447 | checksum = "b5e6043086bf7973472e0c7dff2142ea0b680d30e18d9cc40f267efbf222bd47" 448 | dependencies = [ 449 | "base16ct", 450 | "crypto-bigint", 451 | "digest 0.10.7", 452 | "ff", 453 | "generic-array", 454 | "group", 455 | "pkcs8", 456 | "rand_core", 457 | "sec1", 458 | "subtle", 459 | "zeroize", 460 | ] 461 | 462 | [[package]] 463 | name = "equivalent" 464 | version = "1.0.1" 465 | source = "registry+https://github.com/rust-lang/crates.io-index" 466 | checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5" 467 | 468 | [[package]] 469 | name = "errno" 470 | version = "0.3.10" 471 | source = "registry+https://github.com/rust-lang/crates.io-index" 472 | checksum = "33d852cb9b869c2a9b3df2f71a3074817f01e1844f839a144f5fcef059a4eb5d" 473 | dependencies = [ 474 | "libc", 475 | "windows-sys", 476 | ] 477 | 478 | [[package]] 479 | name = "eth-binary-tree" 480 | version = "0.1.0" 481 | dependencies = [ 482 | "alloy-primitives", 483 | "blake3", 484 | "hex", 485 | ] 486 | 487 | [[package]] 488 | name = "fastrand" 489 | version = "2.3.0" 490 | source = "registry+https://github.com/rust-lang/crates.io-index" 491 | checksum = "37909eebbb50d72f9059c3b6d82c0463f2ff062c9e95845c43a6c9c0355411be" 492 | 493 | [[package]] 494 | name = "fastrlp" 495 | version = "0.3.1" 496 | source = "registry+https://github.com/rust-lang/crates.io-index" 497 | checksum = "139834ddba373bbdd213dffe02c8d110508dcf1726c2be27e8d1f7d7e1856418" 498 | dependencies = [ 499 | "arrayvec", 500 | "auto_impl", 501 | "bytes", 502 | ] 503 | 504 | [[package]] 505 | name = "fastrlp" 506 | version = "0.4.0" 507 | source = "registry+https://github.com/rust-lang/crates.io-index" 508 | checksum = "ce8dba4714ef14b8274c371879b175aa55b16b30f269663f19d576f380018dc4" 509 | dependencies = [ 510 | "arrayvec", 511 | "auto_impl", 512 | "bytes", 513 | ] 514 | 515 | [[package]] 516 | name = "ff" 517 | version = "0.13.0" 518 | source = "registry+https://github.com/rust-lang/crates.io-index" 519 | checksum = "ded41244b729663b1e574f1b4fb731469f69f79c17667b5d776b16cda0479449" 520 | dependencies = [ 521 | "rand_core", 522 | "subtle", 523 | ] 524 | 525 | [[package]] 526 | name = "fixed-hash" 527 | version = "0.8.0" 528 | source = "registry+https://github.com/rust-lang/crates.io-index" 529 | checksum = "835c052cb0c08c1acf6ffd71c022172e18723949c8282f2b9f27efbc51e64534" 530 | dependencies = [ 531 | "byteorder", 532 | "rand", 533 | "rustc-hex", 534 | "static_assertions", 535 | ] 536 | 537 | [[package]] 538 | name = "fnv" 539 | version = "1.0.7" 540 | source = "registry+https://github.com/rust-lang/crates.io-index" 541 | checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" 542 | 543 | [[package]] 544 | name = "foldhash" 545 | version = "0.1.4" 546 | source = "registry+https://github.com/rust-lang/crates.io-index" 547 | checksum = "a0d2fde1f7b3d48b8395d5f2de76c18a528bd6a9cdde438df747bfcba3e05d6f" 548 | 549 | [[package]] 550 | name = "funty" 551 | version = "2.0.0" 552 | source = "registry+https://github.com/rust-lang/crates.io-index" 553 | checksum = "e6d5a32815ae3f33302d95fdcb2ce17862f8c65363dcfd29360480ba1001fc9c" 554 | 555 | [[package]] 556 | name = "generic-array" 557 | version = "0.14.7" 558 | source = "registry+https://github.com/rust-lang/crates.io-index" 559 | checksum = "85649ca51fd72272d7821adaf274ad91c288277713d9c18820d8499a7ff69e9a" 560 | dependencies = [ 561 | "typenum", 562 | "version_check", 563 | "zeroize", 564 | ] 565 | 566 | [[package]] 567 | name = "getrandom" 568 | version = "0.2.15" 569 | source = "registry+https://github.com/rust-lang/crates.io-index" 570 | checksum = "c4567c8db10ae91089c99af84c68c38da3ec2f087c3f82960bcdbf3656b6f4d7" 571 | dependencies = [ 572 | "cfg-if", 573 | "libc", 574 | "wasi", 575 | ] 576 | 577 | [[package]] 578 | name = "group" 579 | version = "0.13.0" 580 | source = "registry+https://github.com/rust-lang/crates.io-index" 581 | checksum = "f0f9ef7462f7c099f518d754361858f86d8a07af53ba9af0fe635bbccb151a63" 582 | dependencies = [ 583 | "ff", 584 | "rand_core", 585 | "subtle", 586 | ] 587 | 588 | [[package]] 589 | name = "hashbrown" 590 | version = "0.15.2" 591 | source = "registry+https://github.com/rust-lang/crates.io-index" 592 | checksum = "bf151400ff0baff5465007dd2f3e717f3fe502074ca563069ce3a6629d07b289" 593 | dependencies = [ 594 | "foldhash", 595 | "serde", 596 | ] 597 | 598 | [[package]] 599 | name = "hex" 600 | version = "0.4.3" 601 | source = "registry+https://github.com/rust-lang/crates.io-index" 602 | checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70" 603 | dependencies = [ 604 | "serde", 605 | ] 606 | 607 | [[package]] 608 | name = "hmac" 609 | version = "0.12.1" 610 | source = "registry+https://github.com/rust-lang/crates.io-index" 611 | checksum = "6c49c37c09c17a53d937dfbb742eb3a961d65a994e6bcdcf37e7399d0cc8ab5e" 612 | dependencies = [ 613 | "digest 0.10.7", 614 | ] 615 | 616 | [[package]] 617 | name = "impl-codec" 618 | version = "0.6.0" 619 | source = "registry+https://github.com/rust-lang/crates.io-index" 620 | checksum = "ba6a270039626615617f3f36d15fc827041df3b78c439da2cadfa47455a77f2f" 621 | dependencies = [ 622 | "parity-scale-codec", 623 | ] 624 | 625 | [[package]] 626 | name = "impl-trait-for-tuples" 627 | version = "0.2.3" 628 | source = "registry+https://github.com/rust-lang/crates.io-index" 629 | checksum = "a0eb5a3343abf848c0984fe4604b2b105da9539376e24fc0a3b0007411ae4fd9" 630 | dependencies = [ 631 | "proc-macro2", 632 | "quote", 633 | "syn 2.0.96", 634 | ] 635 | 636 | [[package]] 637 | name = "indexmap" 638 | version = "2.7.1" 639 | source = "registry+https://github.com/rust-lang/crates.io-index" 640 | checksum = "8c9c992b02b5b4c94ea26e32fe5bccb7aa7d9f390ab5c1221ff895bc7ea8b652" 641 | dependencies = [ 642 | "equivalent", 643 | "hashbrown", 644 | "serde", 645 | ] 646 | 647 | [[package]] 648 | name = "itertools" 649 | version = "0.10.5" 650 | source = "registry+https://github.com/rust-lang/crates.io-index" 651 | checksum = "b0fd2260e829bddf4cb6ea802289de2f86d6a7a690192fbe91b3f46e0f2c8473" 652 | dependencies = [ 653 | "either", 654 | ] 655 | 656 | [[package]] 657 | name = "itoa" 658 | version = "1.0.14" 659 | source = "registry+https://github.com/rust-lang/crates.io-index" 660 | checksum = "d75a2a4b1b190afb6f5425f10f6a8f959d2ea0b9c2b1d79553551850539e4674" 661 | 662 | [[package]] 663 | name = "k256" 664 | version = "0.13.4" 665 | source = "registry+https://github.com/rust-lang/crates.io-index" 666 | checksum = "f6e3919bbaa2945715f0bb6d3934a173d1e9a59ac23767fbaaef277265a7411b" 667 | dependencies = [ 668 | "cfg-if", 669 | "ecdsa", 670 | "elliptic-curve", 671 | "once_cell", 672 | "sha2", 673 | ] 674 | 675 | [[package]] 676 | name = "keccak" 677 | version = "0.1.5" 678 | source = "registry+https://github.com/rust-lang/crates.io-index" 679 | checksum = "ecc2af9a1119c51f12a14607e783cb977bde58bc069ff0c3da1095e635d70654" 680 | dependencies = [ 681 | "cpufeatures", 682 | ] 683 | 684 | [[package]] 685 | name = "keccak-asm" 686 | version = "0.1.4" 687 | source = "registry+https://github.com/rust-lang/crates.io-index" 688 | checksum = "505d1856a39b200489082f90d897c3f07c455563880bc5952e38eabf731c83b6" 689 | dependencies = [ 690 | "digest 0.10.7", 691 | "sha3-asm", 692 | ] 693 | 694 | [[package]] 695 | name = "lazy_static" 696 | version = "1.5.0" 697 | source = "registry+https://github.com/rust-lang/crates.io-index" 698 | checksum = "bbd2bcb4c963f2ddae06a2efc7e9f3591312473c50c6685e1f298068316e66fe" 699 | 700 | [[package]] 701 | name = "libc" 702 | version = "0.2.169" 703 | source = "registry+https://github.com/rust-lang/crates.io-index" 704 | checksum = "b5aba8db14291edd000dfcc4d620c7ebfb122c613afb886ca8803fa4e128a20a" 705 | 706 | [[package]] 707 | name = "libm" 708 | version = "0.2.11" 709 | source = "registry+https://github.com/rust-lang/crates.io-index" 710 | checksum = "8355be11b20d696c8f18f6cc018c4e372165b1fa8126cef092399c9951984ffa" 711 | 712 | [[package]] 713 | name = "linux-raw-sys" 714 | version = "0.4.15" 715 | source = "registry+https://github.com/rust-lang/crates.io-index" 716 | checksum = "d26c52dbd32dccf2d10cac7725f8eae5296885fb5703b261f7d0a0739ec807ab" 717 | 718 | [[package]] 719 | name = "memchr" 720 | version = "2.7.4" 721 | source = "registry+https://github.com/rust-lang/crates.io-index" 722 | checksum = "78ca9ab1a0babb1e7d5695e3530886289c18cf2f87ec19a575a0abdce112e3a3" 723 | 724 | [[package]] 725 | name = "num-bigint" 726 | version = "0.4.6" 727 | source = "registry+https://github.com/rust-lang/crates.io-index" 728 | checksum = "a5e44f723f1133c9deac646763579fdb3ac745e418f2a7af9cd0c431da1f20b9" 729 | dependencies = [ 730 | "num-integer", 731 | "num-traits", 732 | ] 733 | 734 | [[package]] 735 | name = "num-integer" 736 | version = "0.1.46" 737 | source = "registry+https://github.com/rust-lang/crates.io-index" 738 | checksum = "7969661fd2958a5cb096e56c8e1ad0444ac2bbcd0061bd28660485a44879858f" 739 | dependencies = [ 740 | "num-traits", 741 | ] 742 | 743 | [[package]] 744 | name = "num-traits" 745 | version = "0.2.19" 746 | source = "registry+https://github.com/rust-lang/crates.io-index" 747 | checksum = "071dfc062690e90b734c0b2273ce72ad0ffa95f0c74596bc250dcfd960262841" 748 | dependencies = [ 749 | "autocfg", 750 | "libm", 751 | ] 752 | 753 | [[package]] 754 | name = "once_cell" 755 | version = "1.20.2" 756 | source = "registry+https://github.com/rust-lang/crates.io-index" 757 | checksum = "1261fe7e33c73b354eab43b1273a57c8f967d0391e80353e51f764ac02cf6775" 758 | 759 | [[package]] 760 | name = "parity-scale-codec" 761 | version = "3.6.12" 762 | source = "registry+https://github.com/rust-lang/crates.io-index" 763 | checksum = "306800abfa29c7f16596b5970a588435e3d5b3149683d00c12b699cc19f895ee" 764 | dependencies = [ 765 | "arrayvec", 766 | "bitvec", 767 | "byte-slice-cast", 768 | "impl-trait-for-tuples", 769 | "parity-scale-codec-derive", 770 | "serde", 771 | ] 772 | 773 | [[package]] 774 | name = "parity-scale-codec-derive" 775 | version = "3.6.12" 776 | source = "registry+https://github.com/rust-lang/crates.io-index" 777 | checksum = "d830939c76d294956402033aee57a6da7b438f2294eb94864c37b0569053a42c" 778 | dependencies = [ 779 | "proc-macro-crate", 780 | "proc-macro2", 781 | "quote", 782 | "syn 1.0.109", 783 | ] 784 | 785 | [[package]] 786 | name = "paste" 787 | version = "1.0.15" 788 | source = "registry+https://github.com/rust-lang/crates.io-index" 789 | checksum = "57c0d7b74b563b49d38dae00a0c37d4d6de9b432382b2892f0574ddcae73fd0a" 790 | 791 | [[package]] 792 | name = "pest" 793 | version = "2.7.15" 794 | source = "registry+https://github.com/rust-lang/crates.io-index" 795 | checksum = "8b7cafe60d6cf8e62e1b9b2ea516a089c008945bb5a275416789e7db0bc199dc" 796 | dependencies = [ 797 | "memchr", 798 | "thiserror", 799 | "ucd-trie", 800 | ] 801 | 802 | [[package]] 803 | name = "pkcs8" 804 | version = "0.10.2" 805 | source = "registry+https://github.com/rust-lang/crates.io-index" 806 | checksum = "f950b2377845cebe5cf8b5165cb3cc1a5e0fa5cfa3e1f7f55707d8fd82e0a7b7" 807 | dependencies = [ 808 | "der", 809 | "spki", 810 | ] 811 | 812 | [[package]] 813 | name = "ppv-lite86" 814 | version = "0.2.20" 815 | source = "registry+https://github.com/rust-lang/crates.io-index" 816 | checksum = "77957b295656769bb8ad2b6a6b09d897d94f05c41b069aede1fcdaa675eaea04" 817 | dependencies = [ 818 | "zerocopy", 819 | ] 820 | 821 | [[package]] 822 | name = "primitive-types" 823 | version = "0.12.2" 824 | source = "registry+https://github.com/rust-lang/crates.io-index" 825 | checksum = "0b34d9fd68ae0b74a41b21c03c2f62847aa0ffea044eee893b4c140b37e244e2" 826 | dependencies = [ 827 | "fixed-hash", 828 | "impl-codec", 829 | "uint", 830 | ] 831 | 832 | [[package]] 833 | name = "proc-macro-crate" 834 | version = "3.2.0" 835 | source = "registry+https://github.com/rust-lang/crates.io-index" 836 | checksum = "8ecf48c7ca261d60b74ab1a7b20da18bede46776b2e55535cb958eb595c5fa7b" 837 | dependencies = [ 838 | "toml_edit", 839 | ] 840 | 841 | [[package]] 842 | name = "proc-macro2" 843 | version = "1.0.93" 844 | source = "registry+https://github.com/rust-lang/crates.io-index" 845 | checksum = "60946a68e5f9d28b0dc1c21bb8a97ee7d018a8b322fa57838ba31cc878e22d99" 846 | dependencies = [ 847 | "unicode-ident", 848 | ] 849 | 850 | [[package]] 851 | name = "proptest" 852 | version = "1.5.0" 853 | source = "registry+https://github.com/rust-lang/crates.io-index" 854 | checksum = "b4c2511913b88df1637da85cc8d96ec8e43a3f8bb8ccb71ee1ac240d6f3df58d" 855 | dependencies = [ 856 | "bit-set", 857 | "bit-vec", 858 | "bitflags", 859 | "lazy_static", 860 | "num-traits", 861 | "rand", 862 | "rand_chacha", 863 | "rand_xorshift", 864 | "regex-syntax", 865 | "rusty-fork", 866 | "tempfile", 867 | "unarray", 868 | ] 869 | 870 | [[package]] 871 | name = "quick-error" 872 | version = "1.2.3" 873 | source = "registry+https://github.com/rust-lang/crates.io-index" 874 | checksum = "a1d01941d82fa2ab50be1e79e6714289dd7cde78eba4c074bc5a4374f650dfe0" 875 | 876 | [[package]] 877 | name = "quote" 878 | version = "1.0.38" 879 | source = "registry+https://github.com/rust-lang/crates.io-index" 880 | checksum = "0e4dccaaaf89514f546c693ddc140f729f958c247918a13380cccc6078391acc" 881 | dependencies = [ 882 | "proc-macro2", 883 | ] 884 | 885 | [[package]] 886 | name = "radium" 887 | version = "0.7.0" 888 | source = "registry+https://github.com/rust-lang/crates.io-index" 889 | checksum = "dc33ff2d4973d518d823d61aa239014831e521c75da58e3df4840d3f47749d09" 890 | 891 | [[package]] 892 | name = "rand" 893 | version = "0.8.5" 894 | source = "registry+https://github.com/rust-lang/crates.io-index" 895 | checksum = "34af8d1a0e25924bc5b7c43c079c942339d8f0a8b57c39049bef581b46327404" 896 | dependencies = [ 897 | "libc", 898 | "rand_chacha", 899 | "rand_core", 900 | "serde", 901 | ] 902 | 903 | [[package]] 904 | name = "rand_chacha" 905 | version = "0.3.1" 906 | source = "registry+https://github.com/rust-lang/crates.io-index" 907 | checksum = "e6c10a63a0fa32252be49d21e7709d4d4baf8d231c2dbce1eaa8141b9b127d88" 908 | dependencies = [ 909 | "ppv-lite86", 910 | "rand_core", 911 | ] 912 | 913 | [[package]] 914 | name = "rand_core" 915 | version = "0.6.4" 916 | source = "registry+https://github.com/rust-lang/crates.io-index" 917 | checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c" 918 | dependencies = [ 919 | "getrandom", 920 | ] 921 | 922 | [[package]] 923 | name = "rand_xorshift" 924 | version = "0.3.0" 925 | source = "registry+https://github.com/rust-lang/crates.io-index" 926 | checksum = "d25bf25ec5ae4a3f1b92f929810509a2f53d7dca2f50b794ff57e3face536c8f" 927 | dependencies = [ 928 | "rand_core", 929 | ] 930 | 931 | [[package]] 932 | name = "regex-syntax" 933 | version = "0.8.5" 934 | source = "registry+https://github.com/rust-lang/crates.io-index" 935 | checksum = "2b15c43186be67a4fd63bee50d0303afffcef381492ebe2c5d87f324e1b8815c" 936 | 937 | [[package]] 938 | name = "rfc6979" 939 | version = "0.4.0" 940 | source = "registry+https://github.com/rust-lang/crates.io-index" 941 | checksum = "f8dd2a808d456c4a54e300a23e9f5a67e122c3024119acbfd73e3bf664491cb2" 942 | dependencies = [ 943 | "hmac", 944 | "subtle", 945 | ] 946 | 947 | [[package]] 948 | name = "rlp" 949 | version = "0.5.2" 950 | source = "registry+https://github.com/rust-lang/crates.io-index" 951 | checksum = "bb919243f34364b6bd2fc10ef797edbfa75f33c252e7998527479c6d6b47e1ec" 952 | dependencies = [ 953 | "bytes", 954 | "rustc-hex", 955 | ] 956 | 957 | [[package]] 958 | name = "ruint" 959 | version = "1.12.4" 960 | source = "registry+https://github.com/rust-lang/crates.io-index" 961 | checksum = "f5ef8fb1dd8de3870cb8400d51b4c2023854bbafd5431a3ac7e7317243e22d2f" 962 | dependencies = [ 963 | "alloy-rlp", 964 | "ark-ff 0.3.0", 965 | "ark-ff 0.4.2", 966 | "bytes", 967 | "fastrlp 0.3.1", 968 | "fastrlp 0.4.0", 969 | "num-bigint", 970 | "num-integer", 971 | "num-traits", 972 | "parity-scale-codec", 973 | "primitive-types", 974 | "proptest", 975 | "rand", 976 | "rlp", 977 | "ruint-macro", 978 | "serde", 979 | "valuable", 980 | "zeroize", 981 | ] 982 | 983 | [[package]] 984 | name = "ruint-macro" 985 | version = "1.2.1" 986 | source = "registry+https://github.com/rust-lang/crates.io-index" 987 | checksum = "48fd7bd8a6377e15ad9d42a8ec25371b94ddc67abe7c8b9127bec79bebaaae18" 988 | 989 | [[package]] 990 | name = "rustc-hash" 991 | version = "2.1.0" 992 | source = "registry+https://github.com/rust-lang/crates.io-index" 993 | checksum = "c7fb8039b3032c191086b10f11f319a6e99e1e82889c5cc6046f515c9db1d497" 994 | 995 | [[package]] 996 | name = "rustc-hex" 997 | version = "2.1.0" 998 | source = "registry+https://github.com/rust-lang/crates.io-index" 999 | checksum = "3e75f6a532d0fd9f7f13144f392b6ad56a32696bfcd9c78f797f16bbb6f072d6" 1000 | 1001 | [[package]] 1002 | name = "rustc_version" 1003 | version = "0.3.3" 1004 | source = "registry+https://github.com/rust-lang/crates.io-index" 1005 | checksum = "f0dfe2087c51c460008730de8b57e6a320782fbfb312e1f4d520e6c6fae155ee" 1006 | dependencies = [ 1007 | "semver 0.11.0", 1008 | ] 1009 | 1010 | [[package]] 1011 | name = "rustc_version" 1012 | version = "0.4.1" 1013 | source = "registry+https://github.com/rust-lang/crates.io-index" 1014 | checksum = "cfcb3a22ef46e85b45de6ee7e79d063319ebb6594faafcf1c225ea92ab6e9b92" 1015 | dependencies = [ 1016 | "semver 1.0.25", 1017 | ] 1018 | 1019 | [[package]] 1020 | name = "rustix" 1021 | version = "0.38.44" 1022 | source = "registry+https://github.com/rust-lang/crates.io-index" 1023 | checksum = "fdb5bc1ae2baa591800df16c9ca78619bf65c0488b41b96ccec5d11220d8c154" 1024 | dependencies = [ 1025 | "bitflags", 1026 | "errno", 1027 | "libc", 1028 | "linux-raw-sys", 1029 | "windows-sys", 1030 | ] 1031 | 1032 | [[package]] 1033 | name = "rusty-fork" 1034 | version = "0.3.0" 1035 | source = "registry+https://github.com/rust-lang/crates.io-index" 1036 | checksum = "cb3dcc6e454c328bb824492db107ab7c0ae8fcffe4ad210136ef014458c1bc4f" 1037 | dependencies = [ 1038 | "fnv", 1039 | "quick-error", 1040 | "tempfile", 1041 | "wait-timeout", 1042 | ] 1043 | 1044 | [[package]] 1045 | name = "sec1" 1046 | version = "0.7.3" 1047 | source = "registry+https://github.com/rust-lang/crates.io-index" 1048 | checksum = "d3e97a565f76233a6003f9f5c54be1d9c5bdfa3eccfb189469f11ec4901c47dc" 1049 | dependencies = [ 1050 | "base16ct", 1051 | "der", 1052 | "generic-array", 1053 | "pkcs8", 1054 | "subtle", 1055 | "zeroize", 1056 | ] 1057 | 1058 | [[package]] 1059 | name = "semver" 1060 | version = "0.11.0" 1061 | source = "registry+https://github.com/rust-lang/crates.io-index" 1062 | checksum = "f301af10236f6df4160f7c3f04eec6dbc70ace82d23326abad5edee88801c6b6" 1063 | dependencies = [ 1064 | "semver-parser", 1065 | ] 1066 | 1067 | [[package]] 1068 | name = "semver" 1069 | version = "1.0.25" 1070 | source = "registry+https://github.com/rust-lang/crates.io-index" 1071 | checksum = "f79dfe2d285b0488816f30e700a7438c5a73d816b5b7d3ac72fbc48b0d185e03" 1072 | 1073 | [[package]] 1074 | name = "semver-parser" 1075 | version = "0.10.3" 1076 | source = "registry+https://github.com/rust-lang/crates.io-index" 1077 | checksum = "9900206b54a3527fdc7b8a938bffd94a568bac4f4aa8113b209df75a09c0dec2" 1078 | dependencies = [ 1079 | "pest", 1080 | ] 1081 | 1082 | [[package]] 1083 | name = "serde" 1084 | version = "1.0.217" 1085 | source = "registry+https://github.com/rust-lang/crates.io-index" 1086 | checksum = "02fc4265df13d6fa1d00ecff087228cc0a2b5f3c0e87e258d8b94a156e984c70" 1087 | dependencies = [ 1088 | "serde_derive", 1089 | ] 1090 | 1091 | [[package]] 1092 | name = "serde_derive" 1093 | version = "1.0.217" 1094 | source = "registry+https://github.com/rust-lang/crates.io-index" 1095 | checksum = "5a9bf7cf98d04a2b28aead066b7496853d4779c9cc183c440dbac457641e19a0" 1096 | dependencies = [ 1097 | "proc-macro2", 1098 | "quote", 1099 | "syn 2.0.96", 1100 | ] 1101 | 1102 | [[package]] 1103 | name = "sha2" 1104 | version = "0.10.8" 1105 | source = "registry+https://github.com/rust-lang/crates.io-index" 1106 | checksum = "793db75ad2bcafc3ffa7c68b215fee268f537982cd901d132f89c6343f3a3dc8" 1107 | dependencies = [ 1108 | "cfg-if", 1109 | "cpufeatures", 1110 | "digest 0.10.7", 1111 | ] 1112 | 1113 | [[package]] 1114 | name = "sha3" 1115 | version = "0.10.8" 1116 | source = "registry+https://github.com/rust-lang/crates.io-index" 1117 | checksum = "75872d278a8f37ef87fa0ddbda7802605cb18344497949862c0d4dcb291eba60" 1118 | dependencies = [ 1119 | "digest 0.10.7", 1120 | "keccak", 1121 | ] 1122 | 1123 | [[package]] 1124 | name = "sha3-asm" 1125 | version = "0.1.4" 1126 | source = "registry+https://github.com/rust-lang/crates.io-index" 1127 | checksum = "c28efc5e327c837aa837c59eae585fc250715ef939ac32881bcc11677cd02d46" 1128 | dependencies = [ 1129 | "cc", 1130 | "cfg-if", 1131 | ] 1132 | 1133 | [[package]] 1134 | name = "shlex" 1135 | version = "1.3.0" 1136 | source = "registry+https://github.com/rust-lang/crates.io-index" 1137 | checksum = "0fda2ff0d084019ba4d7c6f371c95d8fd75ce3524c3cb8fb653a3023f6323e64" 1138 | 1139 | [[package]] 1140 | name = "signature" 1141 | version = "2.2.0" 1142 | source = "registry+https://github.com/rust-lang/crates.io-index" 1143 | checksum = "77549399552de45a898a580c1b41d445bf730df867cc44e6c0233bbc4b8329de" 1144 | dependencies = [ 1145 | "digest 0.10.7", 1146 | "rand_core", 1147 | ] 1148 | 1149 | [[package]] 1150 | name = "spki" 1151 | version = "0.7.3" 1152 | source = "registry+https://github.com/rust-lang/crates.io-index" 1153 | checksum = "d91ed6c858b01f942cd56b37a94b3e0a1798290327d1236e4d9cf4eaca44d29d" 1154 | dependencies = [ 1155 | "base64ct", 1156 | "der", 1157 | ] 1158 | 1159 | [[package]] 1160 | name = "static_assertions" 1161 | version = "1.1.0" 1162 | source = "registry+https://github.com/rust-lang/crates.io-index" 1163 | checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f" 1164 | 1165 | [[package]] 1166 | name = "subtle" 1167 | version = "2.6.1" 1168 | source = "registry+https://github.com/rust-lang/crates.io-index" 1169 | checksum = "13c2bddecc57b384dee18652358fb23172facb8a2c51ccc10d74c157bdea3292" 1170 | 1171 | [[package]] 1172 | name = "syn" 1173 | version = "1.0.109" 1174 | source = "registry+https://github.com/rust-lang/crates.io-index" 1175 | checksum = "72b64191b275b66ffe2469e8af2c1cfe3bafa67b529ead792a6d0160888b4237" 1176 | dependencies = [ 1177 | "proc-macro2", 1178 | "quote", 1179 | "unicode-ident", 1180 | ] 1181 | 1182 | [[package]] 1183 | name = "syn" 1184 | version = "2.0.96" 1185 | source = "registry+https://github.com/rust-lang/crates.io-index" 1186 | checksum = "d5d0adab1ae378d7f53bdebc67a39f1f151407ef230f0ce2883572f5d8985c80" 1187 | dependencies = [ 1188 | "proc-macro2", 1189 | "quote", 1190 | "unicode-ident", 1191 | ] 1192 | 1193 | [[package]] 1194 | name = "tap" 1195 | version = "1.0.1" 1196 | source = "registry+https://github.com/rust-lang/crates.io-index" 1197 | checksum = "55937e1799185b12863d447f42597ed69d9928686b8d88a1df17376a097d8369" 1198 | 1199 | [[package]] 1200 | name = "tempfile" 1201 | version = "3.15.0" 1202 | source = "registry+https://github.com/rust-lang/crates.io-index" 1203 | checksum = "9a8a559c81686f576e8cd0290cd2a24a2a9ad80c98b3478856500fcbd7acd704" 1204 | dependencies = [ 1205 | "cfg-if", 1206 | "fastrand", 1207 | "getrandom", 1208 | "once_cell", 1209 | "rustix", 1210 | "windows-sys", 1211 | ] 1212 | 1213 | [[package]] 1214 | name = "thiserror" 1215 | version = "2.0.11" 1216 | source = "registry+https://github.com/rust-lang/crates.io-index" 1217 | checksum = "d452f284b73e6d76dd36758a0c8684b1d5be31f92b89d07fd5822175732206fc" 1218 | dependencies = [ 1219 | "thiserror-impl", 1220 | ] 1221 | 1222 | [[package]] 1223 | name = "thiserror-impl" 1224 | version = "2.0.11" 1225 | source = "registry+https://github.com/rust-lang/crates.io-index" 1226 | checksum = "26afc1baea8a989337eeb52b6e72a039780ce45c3edfcc9c5b9d112feeb173c2" 1227 | dependencies = [ 1228 | "proc-macro2", 1229 | "quote", 1230 | "syn 2.0.96", 1231 | ] 1232 | 1233 | [[package]] 1234 | name = "tiny-keccak" 1235 | version = "2.0.2" 1236 | source = "registry+https://github.com/rust-lang/crates.io-index" 1237 | checksum = "2c9d3793400a45f954c52e73d068316d76b6f4e36977e3fcebb13a2721e80237" 1238 | dependencies = [ 1239 | "crunchy", 1240 | ] 1241 | 1242 | [[package]] 1243 | name = "toml_datetime" 1244 | version = "0.6.8" 1245 | source = "registry+https://github.com/rust-lang/crates.io-index" 1246 | checksum = "0dd7358ecb8fc2f8d014bf86f6f638ce72ba252a2c3a2572f2a795f1d23efb41" 1247 | 1248 | [[package]] 1249 | name = "toml_edit" 1250 | version = "0.22.22" 1251 | source = "registry+https://github.com/rust-lang/crates.io-index" 1252 | checksum = "4ae48d6208a266e853d946088ed816055e556cc6028c5e8e2b84d9fa5dd7c7f5" 1253 | dependencies = [ 1254 | "indexmap", 1255 | "toml_datetime", 1256 | "winnow", 1257 | ] 1258 | 1259 | [[package]] 1260 | name = "typenum" 1261 | version = "1.17.0" 1262 | source = "registry+https://github.com/rust-lang/crates.io-index" 1263 | checksum = "42ff0bf0c66b8238c6f3b578df37d0b7848e55df8577b3f74f92a69acceeb825" 1264 | 1265 | [[package]] 1266 | name = "ucd-trie" 1267 | version = "0.1.7" 1268 | source = "registry+https://github.com/rust-lang/crates.io-index" 1269 | checksum = "2896d95c02a80c6d6a5d6e953d479f5ddf2dfdb6a244441010e373ac0fb88971" 1270 | 1271 | [[package]] 1272 | name = "uint" 1273 | version = "0.9.5" 1274 | source = "registry+https://github.com/rust-lang/crates.io-index" 1275 | checksum = "76f64bba2c53b04fcab63c01a7d7427eadc821e3bc48c34dc9ba29c501164b52" 1276 | dependencies = [ 1277 | "byteorder", 1278 | "crunchy", 1279 | "hex", 1280 | "static_assertions", 1281 | ] 1282 | 1283 | [[package]] 1284 | name = "unarray" 1285 | version = "0.1.4" 1286 | source = "registry+https://github.com/rust-lang/crates.io-index" 1287 | checksum = "eaea85b334db583fe3274d12b4cd1880032beab409c0d774be044d4480ab9a94" 1288 | 1289 | [[package]] 1290 | name = "unicode-ident" 1291 | version = "1.0.15" 1292 | source = "registry+https://github.com/rust-lang/crates.io-index" 1293 | checksum = "11cd88e12b17c6494200a9c1b683a04fcac9573ed74cd1b62aeb2727c5592243" 1294 | 1295 | [[package]] 1296 | name = "unicode-xid" 1297 | version = "0.2.6" 1298 | source = "registry+https://github.com/rust-lang/crates.io-index" 1299 | checksum = "ebc1c04c71510c7f702b52b7c350734c9ff1295c464a03335b00bb84fc54f853" 1300 | 1301 | [[package]] 1302 | name = "valuable" 1303 | version = "0.1.1" 1304 | source = "registry+https://github.com/rust-lang/crates.io-index" 1305 | checksum = "ba73ea9cf16a25df0c8caa16c51acb937d5712a8429db78a3ee29d5dcacd3a65" 1306 | 1307 | [[package]] 1308 | name = "version_check" 1309 | version = "0.9.5" 1310 | source = "registry+https://github.com/rust-lang/crates.io-index" 1311 | checksum = "0b928f33d975fc6ad9f86c8f283853ad26bdd5b10b7f1542aa2fa15e2289105a" 1312 | 1313 | [[package]] 1314 | name = "wait-timeout" 1315 | version = "0.2.0" 1316 | source = "registry+https://github.com/rust-lang/crates.io-index" 1317 | checksum = "9f200f5b12eb75f8c1ed65abd4b2db8a6e1b138a20de009dacee265a2498f3f6" 1318 | dependencies = [ 1319 | "libc", 1320 | ] 1321 | 1322 | [[package]] 1323 | name = "wasi" 1324 | version = "0.11.0+wasi-snapshot-preview1" 1325 | source = "registry+https://github.com/rust-lang/crates.io-index" 1326 | checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" 1327 | 1328 | [[package]] 1329 | name = "windows-sys" 1330 | version = "0.59.0" 1331 | source = "registry+https://github.com/rust-lang/crates.io-index" 1332 | checksum = "1e38bc4d79ed67fd075bcc251a1c39b32a1776bbe92e5bef1f0bf1f8c531853b" 1333 | dependencies = [ 1334 | "windows-targets", 1335 | ] 1336 | 1337 | [[package]] 1338 | name = "windows-targets" 1339 | version = "0.52.6" 1340 | source = "registry+https://github.com/rust-lang/crates.io-index" 1341 | checksum = "9b724f72796e036ab90c1021d4780d4d3d648aca59e491e6b98e725b84e99973" 1342 | dependencies = [ 1343 | "windows_aarch64_gnullvm", 1344 | "windows_aarch64_msvc", 1345 | "windows_i686_gnu", 1346 | "windows_i686_gnullvm", 1347 | "windows_i686_msvc", 1348 | "windows_x86_64_gnu", 1349 | "windows_x86_64_gnullvm", 1350 | "windows_x86_64_msvc", 1351 | ] 1352 | 1353 | [[package]] 1354 | name = "windows_aarch64_gnullvm" 1355 | version = "0.52.6" 1356 | source = "registry+https://github.com/rust-lang/crates.io-index" 1357 | checksum = "32a4622180e7a0ec044bb555404c800bc9fd9ec262ec147edd5989ccd0c02cd3" 1358 | 1359 | [[package]] 1360 | name = "windows_aarch64_msvc" 1361 | version = "0.52.6" 1362 | source = "registry+https://github.com/rust-lang/crates.io-index" 1363 | checksum = "09ec2a7bb152e2252b53fa7803150007879548bc709c039df7627cabbd05d469" 1364 | 1365 | [[package]] 1366 | name = "windows_i686_gnu" 1367 | version = "0.52.6" 1368 | source = "registry+https://github.com/rust-lang/crates.io-index" 1369 | checksum = "8e9b5ad5ab802e97eb8e295ac6720e509ee4c243f69d781394014ebfe8bbfa0b" 1370 | 1371 | [[package]] 1372 | name = "windows_i686_gnullvm" 1373 | version = "0.52.6" 1374 | source = "registry+https://github.com/rust-lang/crates.io-index" 1375 | checksum = "0eee52d38c090b3caa76c563b86c3a4bd71ef1a819287c19d586d7334ae8ed66" 1376 | 1377 | [[package]] 1378 | name = "windows_i686_msvc" 1379 | version = "0.52.6" 1380 | source = "registry+https://github.com/rust-lang/crates.io-index" 1381 | checksum = "240948bc05c5e7c6dabba28bf89d89ffce3e303022809e73deaefe4f6ec56c66" 1382 | 1383 | [[package]] 1384 | name = "windows_x86_64_gnu" 1385 | version = "0.52.6" 1386 | source = "registry+https://github.com/rust-lang/crates.io-index" 1387 | checksum = "147a5c80aabfbf0c7d901cb5895d1de30ef2907eb21fbbab29ca94c5b08b1a78" 1388 | 1389 | [[package]] 1390 | name = "windows_x86_64_gnullvm" 1391 | version = "0.52.6" 1392 | source = "registry+https://github.com/rust-lang/crates.io-index" 1393 | checksum = "24d5b23dc417412679681396f2b49f3de8c1473deb516bd34410872eff51ed0d" 1394 | 1395 | [[package]] 1396 | name = "windows_x86_64_msvc" 1397 | version = "0.52.6" 1398 | source = "registry+https://github.com/rust-lang/crates.io-index" 1399 | checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec" 1400 | 1401 | [[package]] 1402 | name = "winnow" 1403 | version = "0.6.24" 1404 | source = "registry+https://github.com/rust-lang/crates.io-index" 1405 | checksum = "c8d71a593cc5c42ad7876e2c1fda56f314f3754c084128833e64f1345ff8a03a" 1406 | dependencies = [ 1407 | "memchr", 1408 | ] 1409 | 1410 | [[package]] 1411 | name = "wyz" 1412 | version = "0.5.1" 1413 | source = "registry+https://github.com/rust-lang/crates.io-index" 1414 | checksum = "05f360fc0b24296329c78fda852a1e9ae82de9cf7b27dae4b7f62f118f77b9ed" 1415 | dependencies = [ 1416 | "tap", 1417 | ] 1418 | 1419 | [[package]] 1420 | name = "zerocopy" 1421 | version = "0.7.35" 1422 | source = "registry+https://github.com/rust-lang/crates.io-index" 1423 | checksum = "1b9b4fd18abc82b8136838da5d50bae7bdea537c574d8dc1a34ed098d6c166f0" 1424 | dependencies = [ 1425 | "byteorder", 1426 | "zerocopy-derive", 1427 | ] 1428 | 1429 | [[package]] 1430 | name = "zerocopy-derive" 1431 | version = "0.7.35" 1432 | source = "registry+https://github.com/rust-lang/crates.io-index" 1433 | checksum = "fa4f8080344d4671fb4e831a13ad1e68092748387dfc4f55e356242fae12ce3e" 1434 | dependencies = [ 1435 | "proc-macro2", 1436 | "quote", 1437 | "syn 2.0.96", 1438 | ] 1439 | 1440 | [[package]] 1441 | name = "zeroize" 1442 | version = "1.8.1" 1443 | source = "registry+https://github.com/rust-lang/crates.io-index" 1444 | checksum = "ced3678a2879b30306d323f4542626697a464a97c0a07c9aebf7ebca65cd4dde" 1445 | dependencies = [ 1446 | "zeroize_derive", 1447 | ] 1448 | 1449 | [[package]] 1450 | name = "zeroize_derive" 1451 | version = "1.4.2" 1452 | source = "registry+https://github.com/rust-lang/crates.io-index" 1453 | checksum = "ce36e65b0d2999d2aafac989fb249189a141aee1f53c612c1f37d72631959f69" 1454 | dependencies = [ 1455 | "proc-macro2", 1456 | "quote", 1457 | "syn 2.0.96", 1458 | ] 1459 | -------------------------------------------------------------------------------- /Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "eth-binary-tree" 3 | version = "0.1.0" 4 | edition = "2021" 5 | 6 | [dependencies] 7 | blake3 = "1.5.5" 8 | hex = "0.4.3" 9 | alloy-primitives = { version = "0.8.15", features = ['serde'] } -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Rust Implementation of Ethereum Binary Tree EIP-7864 2 | 3 | This EIP proposes a new binary state tree to replace the current hexary Patricia trees in Ethereum. The new structure merges account and storage tries into a single tree with 32-byte keys, aiming to improve the efficiency and simplicity of state proofs. The proposal seeks to enhance Ethereum's ability to support validity proofs, reduce the size of Merkle proofs, and improve the overall performance of the network. The binary tree structure is designed to be more SNARK-friendly and post-quantum secure, with a focus on using the BLAKE3 hash function for merkelization 4 | 5 | Check out actual proposal [EIP-7864](https://eips.ethereum.org/EIPS/eip-7864) 6 | 7 | Longer Explainer thread on [Ethereum Magicians](https://ethereum-magicians.org/t/eip-7864-ethereum-state-using-a-unified-binary-tree/22611) 8 | 9 | Shoutout to:
10 | -Vitalik Buterin
11 | -Guillaume Ballet
12 | -Dankrad Feist
13 | -Ignacio Hagopian
14 | -Kevaundray Wedderburn
15 | -Tanishq Jasoria
16 | -Gajinder Singh
17 | -Danno Ferrin
18 | -Piper Merriam
19 | -Gottfried Herold
20 | 21 | For the original proposal 22 | 23 | 24 | Now contains the implementation of both the `tree` and `embedding`. 25 | 26 | ### Disclaimer: This is just a minimal conversion of the python specs from the original proposal created as a POC. Do not use in production. -------------------------------------------------------------------------------- /src/embedding.rs: -------------------------------------------------------------------------------- 1 | use alloy_primitives::{aliases::B256, Address}; 2 | use blake3::Hasher; 3 | use std::convert::TryInto; 4 | 5 | type Address32 = B256; 6 | type Bytes32 = B256; 7 | 8 | pub const BASIC_DATA_LEAF_KEY: u8 = 0; 9 | pub const CODE_HASH_LEAF_KEY: u8 = 1; 10 | pub const HEADER_STORAGE_OFFSET: u64 = 64; 11 | pub const CODE_OFFSET: u64 = 128; 12 | pub const STEM_SUBTREE_WIDTH: u64 = 256; 13 | pub const MAIN_STORAGE_OFFSET: u64 = 256; 14 | 15 | pub const PUSH_OFFSET: u8 = 95; 16 | pub const PUSH1: u8 = PUSH_OFFSET + 1; 17 | pub const PUSH32: u8 = PUSH_OFFSET + 32; 18 | 19 | pub fn old_style_address_to_address32(address: &Address) -> Address32 { 20 | let mut address32 = [0u8; 32]; 21 | address32[12..].copy_from_slice(address.as_slice()); 22 | Address32::from(address32) 23 | } 24 | 25 | pub fn tree_hash(inp: &[u8]) -> Bytes32 { 26 | let mut hasher = Hasher::new(); 27 | hasher.update(inp); 28 | hasher 29 | .finalize() 30 | .as_bytes() 31 | .try_into() 32 | .expect("Hash should be 32 bytes") 33 | } 34 | 35 | pub fn get_tree_key(address: &Address32, tree_index: u64, sub_index: u8) -> [u8; 32] { 36 | let mut key_input = vec![]; 37 | key_input.extend_from_slice(address.as_slice()); 38 | key_input.extend_from_slice(&tree_index.to_le_bytes()); 39 | let hash = tree_hash(&key_input); 40 | 41 | let mut key = [0u8; 32]; 42 | key[..31].copy_from_slice(&hash[..31]); 43 | key[31] = sub_index; 44 | key 45 | } 46 | 47 | pub fn get_tree_key_for_basic_data(address: &Address32) -> [u8; 32] { 48 | get_tree_key(address, 0, BASIC_DATA_LEAF_KEY) 49 | } 50 | 51 | pub fn get_tree_key_for_code_hash(address: &Address32) -> [u8; 32] { 52 | get_tree_key(address, 0, CODE_HASH_LEAF_KEY) 53 | } 54 | 55 | pub fn get_tree_key_for_storage_slot(address: &Address32, storage_key: u64) -> [u8; 32] { 56 | let pos = if storage_key < (CODE_OFFSET - HEADER_STORAGE_OFFSET) { 57 | HEADER_STORAGE_OFFSET + storage_key 58 | } else { 59 | MAIN_STORAGE_OFFSET + storage_key 60 | }; 61 | 62 | get_tree_key( 63 | address, 64 | pos / STEM_SUBTREE_WIDTH, 65 | (pos % STEM_SUBTREE_WIDTH) as u8, 66 | ) 67 | } 68 | 69 | pub fn get_tree_key_for_code_chunk(address: &Address32, chunk_id: u64) -> [u8; 32] { 70 | get_tree_key( 71 | address, 72 | (CODE_OFFSET + chunk_id) / STEM_SUBTREE_WIDTH, 73 | ((CODE_OFFSET + chunk_id) % STEM_SUBTREE_WIDTH) as u8, 74 | ) 75 | } 76 | 77 | pub fn chunkify_code(code: &[u8]) -> Vec { 78 | let mut padded_code = code.to_vec(); 79 | if code.len() % 31 != 0 { 80 | padded_code.extend(vec![0; 31 - (code.len() % 31)]); 81 | } 82 | 83 | let mut bytes_to_exec_data = vec![0u8; padded_code.len() + 32]; 84 | let mut pos = 0; 85 | 86 | while pos < padded_code.len() { 87 | let pushdata_bytes = if (PUSH1..=PUSH32).contains(&padded_code[pos]) { 88 | padded_code[pos] - PUSH_OFFSET 89 | } else { 90 | 0 91 | }; 92 | 93 | pos += 1; 94 | for x in 0..pushdata_bytes { 95 | if let Some(val) = bytes_to_exec_data.get_mut(pos + x as usize) { 96 | *val = pushdata_bytes - x; 97 | } 98 | } 99 | pos += pushdata_bytes as usize; 100 | } 101 | 102 | padded_code 103 | .chunks(31) 104 | .enumerate() 105 | .map(|(i, chunk)| { 106 | let exec_data_byte = bytes_to_exec_data[i * 31] as u8; 107 | let mut array = [0u8; 32]; 108 | array[0] = exec_data_byte; 109 | array[1..(1 + chunk.len())].copy_from_slice(chunk); 110 | 111 | B256::from(array) 112 | }) 113 | .collect() 114 | } 115 | -------------------------------------------------------------------------------- /src/lib.rs: -------------------------------------------------------------------------------- 1 | pub mod embedding; 2 | pub mod tree; 3 | -------------------------------------------------------------------------------- /src/tree.rs: -------------------------------------------------------------------------------- 1 | use blake3::Hasher; 2 | 3 | #[derive(Debug, Clone)] 4 | pub struct StemNode { 5 | stem: [u8; 31], 6 | pub values: [Option>; 256], 7 | } 8 | 9 | impl StemNode { 10 | pub fn new(stem: [u8; 31]) -> Self { 11 | Self { 12 | stem, 13 | values: [const { None }; 256], 14 | } 15 | } 16 | 17 | pub fn set_value(&mut self, index: usize, value: Vec) { 18 | self.values[index] = Some(value); 19 | } 20 | } 21 | 22 | #[derive(Debug, Clone)] 23 | pub struct InternalNode { 24 | pub left: Option>, 25 | pub right: Option>, 26 | } 27 | 28 | impl InternalNode { 29 | pub fn new() -> Self { 30 | Self { 31 | left: None, 32 | right: None, 33 | } 34 | } 35 | } 36 | 37 | #[derive(Debug, Clone)] 38 | pub enum TreeNode { 39 | Stem(StemNode), 40 | Internal(InternalNode), 41 | } 42 | 43 | #[derive(Debug)] 44 | pub struct BinaryTree { 45 | pub root: Option, 46 | } 47 | 48 | impl BinaryTree { 49 | pub fn new() -> Self { 50 | Self { root: None } 51 | } 52 | 53 | pub fn insert(&mut self, key: [u8; 32], value: [u8; 32]) { 54 | let stem: [u8; 31] = key[..31] 55 | .try_into() 56 | .expect("Failed to convert slice to array of size 31"); 57 | let subindex = key[31] as usize; 58 | 59 | if self.root.is_none() { 60 | let mut node = StemNode::new(stem.try_into().unwrap()); 61 | node.set_value(subindex, value.to_vec()); 62 | self.root = Some(TreeNode::Stem(node)); 63 | return; 64 | } 65 | 66 | let root = self.root.take(); 67 | self.root = Some(self.insert_rec(root, stem, subindex, value.to_vec(), 0)); 68 | } 69 | 70 | fn insert_rec( 71 | &self, 72 | node: Option, 73 | stem: [u8; 31], 74 | subindex: usize, 75 | value: Vec, 76 | depth: usize, 77 | ) -> TreeNode { 78 | assert!(depth < 248, "depth must be less than 248"); 79 | 80 | if node.is_none() { 81 | let mut new_node = StemNode::new(stem); 82 | new_node.set_value(subindex, value); 83 | return TreeNode::Stem(new_node); 84 | } 85 | 86 | match node.unwrap() { 87 | TreeNode::Stem(mut leaf) => { 88 | if leaf.stem == stem { 89 | leaf.set_value(subindex, value); 90 | return TreeNode::Stem(leaf); 91 | } 92 | let existing_stem_bits = self.bytes_to_bits(&leaf.stem); 93 | self.split_leaf(leaf, stem, subindex, value, existing_stem_bits, depth) 94 | } 95 | TreeNode::Internal(mut internal) => { 96 | let stem_bits = self.bytes_to_bits(&stem); 97 | let bit = stem_bits[depth]; 98 | if bit == 0 { 99 | internal.left = Some(Box::new(self.insert_rec( 100 | internal.left.map(|node| *node), 101 | stem, 102 | subindex, 103 | value, 104 | depth + 1, 105 | ))); 106 | } else { 107 | internal.right = Some(Box::new(self.insert_rec( 108 | internal.right.map(|node| *node), 109 | stem, 110 | subindex, 111 | value, 112 | depth + 1, 113 | ))); 114 | } 115 | TreeNode::Internal(internal) 116 | } 117 | } 118 | } 119 | 120 | fn split_leaf( 121 | &self, 122 | leaf: StemNode, 123 | stem: [u8; 31], 124 | subindex: usize, 125 | value: Vec, 126 | existing_stem_bits: Vec, 127 | depth: usize, 128 | ) -> TreeNode { 129 | let stem_bits = self.bytes_to_bits(&stem); 130 | if stem_bits[depth] == existing_stem_bits[depth] { 131 | let mut internal = InternalNode::new(); 132 | let bit = stem_bits[depth]; 133 | if bit == 0 { 134 | internal.left = Some(Box::new(self.split_leaf( 135 | leaf, 136 | stem, 137 | subindex, 138 | value, 139 | existing_stem_bits, 140 | depth + 1, 141 | ))); 142 | } else { 143 | internal.right = Some(Box::new(self.split_leaf( 144 | leaf, 145 | stem, 146 | subindex, 147 | value, 148 | existing_stem_bits, 149 | depth + 1, 150 | ))); 151 | } 152 | TreeNode::Internal(internal) 153 | } else { 154 | let mut internal = InternalNode::new(); 155 | let bit = stem_bits[depth]; 156 | let mut new_stem_node = StemNode::new(stem); 157 | new_stem_node.set_value(subindex, value); 158 | if bit == 0 { 159 | internal.left = Some(Box::new(TreeNode::Stem(new_stem_node))); 160 | internal.right = Some(Box::new(TreeNode::Stem(leaf))); 161 | } else { 162 | internal.right = Some(Box::new(TreeNode::Stem(new_stem_node))); 163 | internal.left = Some(Box::new(TreeNode::Stem(leaf))); 164 | } 165 | TreeNode::Internal(internal) 166 | } 167 | } 168 | 169 | fn bytes_to_bits(&self, bytes: &[u8]) -> Vec { 170 | bytes 171 | .iter() 172 | .flat_map(|byte| (0..8).rev().map(move |i| (byte >> i) & 1)) 173 | .collect() 174 | } 175 | 176 | fn hash(data: &[u8]) -> [u8; 32] { 177 | if data.is_empty() || data == [0; 64] { 178 | [0; 32] 179 | } else { 180 | let mut hasher = Hasher::new(); 181 | hasher.update(data); 182 | *hasher.finalize().as_bytes() 183 | } 184 | } 185 | 186 | pub fn merkelize(&self) -> [u8; 32] { 187 | fn _merkelize(tree: &Option, hash_fn: &dyn Fn(&[u8]) -> [u8; 32]) -> [u8; 32] { 188 | match tree { 189 | None => [0; 32], 190 | Some(TreeNode::Internal(node)) => { 191 | let left_hash = _merkelize(&node.left.as_ref().map(|l| *l.clone()), hash_fn); 192 | let right_hash = _merkelize(&node.right.as_ref().map(|r| *r.clone()), hash_fn); 193 | let mut combined = Vec::with_capacity(64); // 32 bytes for each hash 194 | combined.extend_from_slice(&left_hash); 195 | combined.extend_from_slice(&right_hash); 196 | hash_fn(&combined) 197 | } 198 | Some(TreeNode::Stem(node)) => { 199 | let mut level: Vec<[u8; 32]> = node 200 | .values 201 | .iter() 202 | .map(|opt| hash_fn(opt.as_deref().unwrap_or(&[0; 64]))) 203 | .collect(); 204 | 205 | while level.len() > 1 { 206 | let mut new_level = Vec::new(); 207 | for pair in level.chunks(2) { 208 | let combined = match pair { 209 | [a, b] => [&a[..], &b[..]].concat(), 210 | [a] => a.to_vec(), 211 | _ => vec![], 212 | }; 213 | new_level.push(hash_fn(&combined)); 214 | } 215 | level = new_level; 216 | } 217 | 218 | let mut buffer = Vec::with_capacity(31 + 1 + 32); 219 | buffer.extend_from_slice(&node.stem); 220 | buffer.push(0); 221 | buffer.extend_from_slice(&level[0]); 222 | let stem_hash = hash_fn(&buffer); 223 | stem_hash 224 | } 225 | } 226 | } 227 | 228 | _merkelize(&self.root, &Self::hash) 229 | } 230 | } 231 | -------------------------------------------------------------------------------- /tests/embedding_test.rs: -------------------------------------------------------------------------------- 1 | #[cfg(test)] 2 | mod tests { 3 | use alloy_primitives::B256; 4 | use eth_binary_tree::embedding::*; 5 | 6 | fn address32_example() -> B256 { 7 | B256::from([0x42; 32]) 8 | } 9 | 10 | #[test] 11 | fn test_get_tree_key_for_basic_data() { 12 | let address = address32_example(); 13 | let result = get_tree_key_for_basic_data(&address); 14 | assert_eq!(result.len(), 32); 15 | assert_eq!(result[31], BASIC_DATA_LEAF_KEY); 16 | } 17 | 18 | #[test] 19 | fn test_get_tree_key_for_code_hash() { 20 | let address = address32_example(); 21 | let result = get_tree_key_for_code_hash(&address); 22 | assert_eq!(result.len(), 32); 23 | assert_eq!(result[31], CODE_HASH_LEAF_KEY); 24 | } 25 | 26 | #[test] 27 | fn test_get_tree_key_for_storage_slot_below_threshold() { 28 | let address = address32_example(); 29 | let header_keys: Vec = (0..HEADER_STORAGE_OFFSET) 30 | .map(|storage_key| { 31 | let key = get_tree_key_for_storage_slot(&address, storage_key); 32 | B256::from(key) 33 | }) 34 | .collect(); 35 | 36 | let stems: Vec<_> = header_keys.iter().map(|key| &key[..31]).collect(); 37 | let unique_stems: std::collections::HashSet<_> = stems.iter().collect(); 38 | assert_eq!(unique_stems.len(), 1); 39 | 40 | for (i, key) in header_keys.iter().enumerate() { 41 | assert_eq!(key[31], i as u8 + 64); 42 | } 43 | 44 | let storage_slot = 64; 45 | let outside_key = get_tree_key_for_storage_slot(&address, storage_slot); 46 | assert_ne!(header_keys[0], outside_key); 47 | } 48 | 49 | #[test] 50 | fn test_get_tree_key_for_code_chunk() { 51 | let address = address32_example(); 52 | let code_keys: Vec = (0..128) 53 | .map(|chunk_id| { 54 | let key = get_tree_key_for_code_chunk(&address, chunk_id); 55 | B256::from(key) 56 | }) 57 | .collect(); 58 | 59 | let stems: Vec<_> = code_keys.iter().map(|key| &key[..31]).collect(); 60 | let unique_stems: std::collections::HashSet<_> = stems.iter().collect(); 61 | assert_eq!(unique_stems.len(), 1); 62 | 63 | for (i, key) in code_keys.iter().enumerate() { 64 | assert_eq!(key[31], i as u8 + 128); 65 | } 66 | 67 | let chunk_id = 256; 68 | let outside_key = get_tree_key_for_code_chunk(&address, chunk_id); 69 | assert_ne!(code_keys[0], outside_key); 70 | } 71 | } 72 | -------------------------------------------------------------------------------- /tests/tree_test.rs: -------------------------------------------------------------------------------- 1 | #[cfg(test)] 2 | mod tests { 3 | use eth_binary_tree::tree::{BinaryTree, InternalNode, TreeNode}; 4 | use hex; 5 | 6 | fn get_height(node: Option<&TreeNode>) -> usize { 7 | match node { 8 | None => 0, 9 | Some(TreeNode::Stem(_)) => 1, 10 | Some(TreeNode::Internal(internal)) => { 11 | 1 + usize::max( 12 | get_height(internal.left.as_deref()), 13 | get_height(internal.right.as_deref()), 14 | ) 15 | } 16 | } 17 | } 18 | 19 | #[test] 20 | fn test_single_entry() { 21 | let mut tree = BinaryTree::new(); 22 | tree.insert([0u8; 32], [1u8; 32]); 23 | assert_eq!(get_height(tree.root.as_ref()), 1); 24 | assert_eq!( 25 | hex::encode(tree.merkelize()), 26 | "694545468677064fd833cddc8455762fe6b21c6cabe2fc172529e0f573181cd5" 27 | ); 28 | } 29 | 30 | #[test] 31 | fn test_two_entries_diff_first_bit() { 32 | let mut tree = BinaryTree::new(); 33 | tree.insert([0u8; 32], [1u8; 32]); 34 | tree.insert( 35 | { 36 | let mut key = [0u8; 32]; 37 | key[0] = 0x80; 38 | key 39 | }, 40 | [2u8; 32], 41 | ); 42 | assert_eq!(get_height(tree.root.as_ref()), 2); 43 | assert_eq!( 44 | hex::encode(tree.merkelize()), 45 | "85fc622076752a6fcda2c886c18058d639066a83473d9684704b5a29455ed2ed" 46 | ); 47 | } 48 | 49 | #[test] 50 | fn test_one_stem_colocated_values() { 51 | let mut tree = BinaryTree::new(); 52 | tree.insert( 53 | { 54 | let mut key = [0u8; 32]; 55 | key[31] = 3; 56 | key 57 | }, 58 | [1u8; 32], 59 | ); 60 | tree.insert( 61 | { 62 | let mut key = [0u8; 32]; 63 | key[31] = 4; 64 | key 65 | }, 66 | [2u8; 32], 67 | ); 68 | tree.insert( 69 | { 70 | let mut key = [0u8; 32]; 71 | key[31] = 9; 72 | key 73 | }, 74 | [3u8; 32], 75 | ); 76 | tree.insert( 77 | { 78 | let mut key = [0u8; 32]; 79 | key[31] = 255; 80 | key 81 | }, 82 | [4u8; 32], 83 | ); 84 | 85 | assert_eq!(get_height(tree.root.as_ref()), 1); 86 | } 87 | 88 | #[test] 89 | fn test_two_stem_colocated_values() { 90 | let mut tree = BinaryTree::new(); 91 | tree.insert( 92 | { 93 | let mut key = [0u8; 32]; 94 | key[31] = 3; 95 | key 96 | }, 97 | [1u8; 32], 98 | ); 99 | tree.insert( 100 | { 101 | let mut key = [0u8; 32]; 102 | key[31] = 4; 103 | key 104 | }, 105 | [2u8; 32], 106 | ); 107 | tree.insert( 108 | { 109 | let mut key = [0x80u8; 32]; 110 | key[31] = 3; 111 | key 112 | }, 113 | [1u8; 32], 114 | ); 115 | tree.insert( 116 | { 117 | let mut key = [0x80u8; 32]; 118 | key[31] = 4; 119 | key 120 | }, 121 | [2u8; 32], 122 | ); 123 | 124 | assert_eq!(get_height(tree.root.as_ref()), 2); 125 | } 126 | 127 | #[test] 128 | fn test_two_keys_match_first_42_bits() { 129 | let mut tree = BinaryTree::new(); 130 | let mut key1 = [0u8; 32]; 131 | key1[5..32].copy_from_slice(&[0xC0u8; 27]); 132 | 133 | let mut key2 = [0u8; 32]; 134 | key2[5] = 0xE0; 135 | key2[6..32].copy_from_slice(&[0u8; 26]); 136 | tree.insert(key1, [1u8; 32]); 137 | tree.insert(key2, [2u8; 32]); 138 | assert_eq!(get_height(tree.root.as_ref()), 1 + 42 + 1); 139 | } 140 | 141 | #[test] 142 | fn test_insert_duplicate_key() { 143 | let mut tree = BinaryTree::new(); 144 | tree.insert([1u8; 32], [1u8; 32]); 145 | tree.insert([1u8; 32], [2u8; 32]); 146 | assert_eq!(get_height(tree.root.as_ref()), 1); 147 | if let Some(TreeNode::Stem(stem)) = tree.root.as_ref() { 148 | assert_eq!(stem.values[1], Some([2u8; 32].to_vec())); 149 | } 150 | } 151 | 152 | #[test] 153 | fn test_large_number_of_entries() { 154 | let mut tree = BinaryTree::new(); 155 | for i in 0..(1 << 8) { 156 | let mut key = [0u8; 32]; 157 | key[0] = i as u8; 158 | tree.insert(key, [0xFFu8; 32]); 159 | } 160 | assert_eq!(get_height(tree.root.as_ref()), 1 + 8); 161 | } 162 | 163 | #[test] 164 | fn test_merkleize_multiple_entries() { 165 | let mut tree = BinaryTree::new(); 166 | 167 | let keys = vec![ 168 | [0u8; 32], 169 | { 170 | let mut key = [0u8; 32]; 171 | key[0] = 0x80; 172 | key 173 | }, 174 | { 175 | let mut key = [0u8; 32]; 176 | key[0] = 0x01; 177 | key 178 | }, 179 | { 180 | let mut key = [0u8; 32]; 181 | key[0] = 0x81; 182 | key 183 | }, 184 | ]; 185 | 186 | for (i, key) in keys.iter().enumerate() { 187 | let mut value = [0u8; 32]; 188 | value[0] = (i + 1) as u8; 189 | tree.insert(*key, value); 190 | } 191 | let got = tree.merkelize(); 192 | 193 | let expected = "e93c209026b8b00d76062638102ece415028bd104e1d892d5399375a323f2218"; 194 | 195 | assert_eq!(hex::encode(got), expected); 196 | } 197 | } 198 | --------------------------------------------------------------------------------