├── .env.example ├── .github └── workflows │ ├── cargo.yml │ └── test.yml ├── .gitignore ├── Cargo.lock ├── Cargo.toml ├── README.md ├── assets ├── alt_rsnode.png └── rsnode.png ├── backend ├── Cargo.lock ├── Cargo.toml ├── src │ ├── benchdb.rs │ ├── dblock.rs │ ├── lib.rs │ └── types.rs └── tests │ ├── common.rs │ └── dblock.rs ├── crates ├── client │ ├── Cargo.toml │ └── src │ │ ├── lib.rs │ │ ├── rpc_provider.rs │ │ └── types.rs ├── core │ ├── Cargo.toml │ └── src │ │ ├── chain_config.rs │ │ ├── id.rs │ │ ├── lib.rs │ │ └── types.rs ├── derivation │ ├── Cargo.toml │ └── src │ │ ├── batch.rs │ │ ├── batch_queue.rs │ │ ├── channel.rs │ │ ├── channel_bank.rs │ │ ├── data.rs.bak │ │ ├── derivation.rs │ │ ├── frame.rs │ │ ├── lib.rs │ │ └── read_adapter.rs └── mpt │ ├── Cargo.toml │ ├── fuzz │ ├── .gitignore │ ├── Cargo.lock │ ├── Cargo.toml │ └── fuzz_targets │ │ └── mpt_insert_get.rs │ └── src │ ├── display.rs │ ├── lib.rs │ ├── misc.rs │ └── test.rs ├── rnode ├── Cargo.toml └── src │ └── main.rs ├── rust-toolchain.toml ├── rustfmt.toml └── tests ├── client.rs └── types.rs /.env.example: -------------------------------------------------------------------------------- 1 | # L1 Goerli RPC 2 | RPC= 3 | -------------------------------------------------------------------------------- /.github/workflows/cargo.yml: -------------------------------------------------------------------------------- 1 | name: cargo command 2 | 3 | on: 4 | workflow_call: 5 | inputs: 6 | command: 7 | required: true 8 | type: string 9 | 10 | jobs: 11 | job: 12 | runs-on: ubuntu-latest 13 | steps: 14 | - uses: actions/checkout@v3 15 | - uses: actions-rs/toolchain@v1 16 | with: 17 | profile: minimal 18 | toolchain: nightly 19 | override: true 20 | components: clippy, rustfmt 21 | - uses: Swatinem/rust-cache@v2 22 | with: 23 | shared-key: "rust-cache" 24 | - run: ${{ inputs.command }} -------------------------------------------------------------------------------- /.github/workflows/test.yml: -------------------------------------------------------------------------------- 1 | name: test 2 | 3 | on: 4 | push: 5 | branches: 6 | - master 7 | pull_request: 8 | 9 | jobs: 10 | check: 11 | uses: ./.github/workflows/cargo.yml 12 | with: 13 | command: cargo check --all 14 | 15 | test: 16 | uses: ./.github/workflows/cargo.yml 17 | with: 18 | command: cargo test --all 19 | 20 | build: 21 | uses: ./.github/workflows/cargo.yml 22 | with: 23 | command: cargo build --all 24 | 25 | fmt: 26 | uses: ./.github/workflows/cargo.yml 27 | with: 28 | command: cargo fmt --all -- --check 29 | 30 | clippy: 31 | uses: ./.github/workflows/cargo.yml 32 | with: 33 | command: cargo clippy --all -- -D warnings 34 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | target 3 | *.env 4 | -------------------------------------------------------------------------------- /Cargo.toml: -------------------------------------------------------------------------------- 1 | [workspace] 2 | members = [ 3 | "rnode", 4 | "crates/client", 5 | "crates/core", 6 | "crates/derivation", 7 | "crates/mpt", 8 | ] 9 | 10 | default-members = ["rnode"] 11 | 12 | # We need to patch these crates because reth does so as well 13 | # and we rely on reth for primitives, hashing, & RLP. 14 | [patch.crates-io] 15 | # revm = { git = "https://github.com/bluealloy/revm" } 16 | revm-primitives = { git = "https://github.com/bluealloy/revm" } 17 | # patched for quantity U256 responses 18 | ruint = { git = "https://github.com/paradigmxyz/uint" } -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | # rnode • [![tests](https://github.com/trianglesphere/rnode/actions/workflows/test.yml/badge.svg?label=tests)](https://github.com/trianglesphere/rnode/actions/workflows/test.yml) ![license](https://img.shields.io/github/license/trianglesphere/rnode?label=license) 4 | 5 | `rnode` is an experimental version of the optimism protocol built specifically to be 6 | a fault proof program. It must go through the pre-image oracle & be fully determinisitic 7 | with no multi-threaded or networked parts inside the core of derivation. 8 | 9 | ### Checklist 10 | 11 | - [ ] Derivation Pipeline 12 | - [ ] System Config 13 | - [x] Inbox Address check 14 | - [x] Filter from authorized batcher 15 | - [x] Parse frames (basic) 16 | - [x] Parse frames (resilient to malformed data) 17 | - [x] Channel from frames 18 | - [x] Decode batches from channel 19 | - [ ] RLP bytes limit on channel 20 | - [ ] Batch Queue stage 21 | - [ ] Batch -> Attributes 22 | - [ ] Execution revm Backend 23 | - [ ] New Deposit Transaction Type 24 | - [ ] State processing of deposits 25 | - [ ] Fee modifications 26 | - [ ] L1 Cost on non-deposits 27 | - [ ] Basefee to address 28 | - [ ] Execute transactions 29 | - [ ] Create post state 30 | - [ ] L1 Preimage Oracle 31 | - [ ] MPT for transaction/receipts 32 | - [ ] Persist pre-images to disk 33 | - [ ] Run in online or offline pre-image mode 34 | - [ ] Run in pre-image generation mode 35 | - [ ] L2 Preimage Oracle 36 | - [ ] State DB for execution 37 | - [ ] Implement pre-image oracle of MPT 38 | 39 | ### TODO 40 | 41 | - Fake RPC provider for tests 42 | - Use own block types 43 | - Remove ethers core RLP & use reth-rlp 44 | - Finish MPT 45 | - Finish derivation 46 | - Client / L1 Preimage Oracle API 47 | - Will be several layers here 48 | - CLI command + usage 49 | 50 | ### Usage 51 | 52 | TODO 53 | 54 | ### License 55 | 56 | TODO 57 | 58 | -------------------------------------------------------------------------------- /assets/alt_rsnode.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/trianglesphere/rnode/a46ec22e3b0a95704773633fdbe4ec86a1059577/assets/alt_rsnode.png -------------------------------------------------------------------------------- /assets/rsnode.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/trianglesphere/rnode/a46ec22e3b0a95704773633fdbe4ec86a1059577/assets/rsnode.png -------------------------------------------------------------------------------- /backend/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 = "ahash" 7 | version = "0.8.3" 8 | source = "registry+https://github.com/rust-lang/crates.io-index" 9 | checksum = "2c99f64d1e06488f620f932677e24bc6e2897582980441ae90a671415bd7ec2f" 10 | dependencies = [ 11 | "cfg-if", 12 | "once_cell", 13 | "version_check", 14 | ] 15 | 16 | [[package]] 17 | name = "aho-corasick" 18 | version = "0.7.20" 19 | source = "registry+https://github.com/rust-lang/crates.io-index" 20 | checksum = "cc936419f96fa211c1b9166887b38e5e40b19958e5b895be7c1f93adec7071ac" 21 | dependencies = [ 22 | "memchr", 23 | ] 24 | 25 | [[package]] 26 | name = "arrayvec" 27 | version = "0.7.2" 28 | source = "registry+https://github.com/rust-lang/crates.io-index" 29 | checksum = "8da52d66c7071e2e3fa2a1e5c6d088fec47b593032b254f5e980de8ea54454d6" 30 | 31 | [[package]] 32 | name = "auto_impl" 33 | version = "1.0.1" 34 | source = "registry+https://github.com/rust-lang/crates.io-index" 35 | checksum = "8a8c1df849285fbacd587de7818cc7d13be6cd2cbcd47a04fb1801b0e2706e33" 36 | dependencies = [ 37 | "proc-macro-error", 38 | "proc-macro2", 39 | "quote", 40 | "syn", 41 | ] 42 | 43 | [[package]] 44 | name = "autocfg" 45 | version = "1.1.0" 46 | source = "registry+https://github.com/rust-lang/crates.io-index" 47 | checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" 48 | 49 | [[package]] 50 | name = "backend" 51 | version = "0.1.0" 52 | dependencies = [ 53 | "ethers-core", 54 | "eyre", 55 | "revm", 56 | "serde", 57 | "serde_json", 58 | ] 59 | 60 | [[package]] 61 | name = "base16ct" 62 | version = "0.1.1" 63 | source = "registry+https://github.com/rust-lang/crates.io-index" 64 | checksum = "349a06037c7bf932dd7e7d1f653678b2038b9ad46a74102f1fc7bd7872678cce" 65 | 66 | [[package]] 67 | name = "base64ct" 68 | version = "1.5.3" 69 | source = "registry+https://github.com/rust-lang/crates.io-index" 70 | checksum = "b645a089122eccb6111b4f81cbc1a49f5900ac4666bb93ac027feaecf15607bf" 71 | 72 | [[package]] 73 | name = "bitvec" 74 | version = "1.0.1" 75 | source = "registry+https://github.com/rust-lang/crates.io-index" 76 | checksum = "1bc2832c24239b0141d5674bb9174f9d68a8b5b3f2753311927c172ca46f7e9c" 77 | dependencies = [ 78 | "funty", 79 | "radium", 80 | "tap", 81 | "wyz", 82 | ] 83 | 84 | [[package]] 85 | name = "block-buffer" 86 | version = "0.10.3" 87 | source = "registry+https://github.com/rust-lang/crates.io-index" 88 | checksum = "69cce20737498f97b993470a6e536b8523f0af7892a4f928cceb1ac5e52ebe7e" 89 | dependencies = [ 90 | "generic-array", 91 | ] 92 | 93 | [[package]] 94 | name = "byte-slice-cast" 95 | version = "1.2.2" 96 | source = "registry+https://github.com/rust-lang/crates.io-index" 97 | checksum = "c3ac9f8b63eca6fd385229b3675f6cc0dc5c8a5c8a54a59d4f52ffd670d87b0c" 98 | 99 | [[package]] 100 | name = "byteorder" 101 | version = "1.4.3" 102 | source = "registry+https://github.com/rust-lang/crates.io-index" 103 | checksum = "14c189c53d098945499cdfa7ecc63567cf3886b3332b312a5b4585d8d3a6a610" 104 | 105 | [[package]] 106 | name = "bytes" 107 | version = "1.4.0" 108 | source = "registry+https://github.com/rust-lang/crates.io-index" 109 | checksum = "89b2fd2a0dcf38d7971e2194b6b6eebab45ae01067456a7fd93d5547a61b70be" 110 | dependencies = [ 111 | "serde", 112 | ] 113 | 114 | [[package]] 115 | name = "cc" 116 | version = "1.0.79" 117 | source = "registry+https://github.com/rust-lang/crates.io-index" 118 | checksum = "50d30906286121d95be3d479533b458f87493b30a4b5f79a607db8f5d11aa91f" 119 | 120 | [[package]] 121 | name = "cfg-if" 122 | version = "1.0.0" 123 | source = "registry+https://github.com/rust-lang/crates.io-index" 124 | checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" 125 | 126 | [[package]] 127 | name = "chrono" 128 | version = "0.4.23" 129 | source = "registry+https://github.com/rust-lang/crates.io-index" 130 | checksum = "16b0a3d9ed01224b22057780a37bb8c5dbfe1be8ba48678e7bf57ec4b385411f" 131 | dependencies = [ 132 | "num-integer", 133 | "num-traits", 134 | ] 135 | 136 | [[package]] 137 | name = "const-oid" 138 | version = "0.9.1" 139 | source = "registry+https://github.com/rust-lang/crates.io-index" 140 | checksum = "cec318a675afcb6a1ea1d4340e2d377e56e47c266f28043ceccbf4412ddfdd3b" 141 | 142 | [[package]] 143 | name = "convert_case" 144 | version = "0.4.0" 145 | source = "registry+https://github.com/rust-lang/crates.io-index" 146 | checksum = "6245d59a3e82a7fc217c5828a6692dbc6dfb63a0c8c90495621f7b9d79704a0e" 147 | 148 | [[package]] 149 | name = "cpufeatures" 150 | version = "0.2.5" 151 | source = "registry+https://github.com/rust-lang/crates.io-index" 152 | checksum = "28d997bd5e24a5928dd43e46dc529867e207907fe0b239c3477d924f7f2ca320" 153 | dependencies = [ 154 | "libc", 155 | ] 156 | 157 | [[package]] 158 | name = "crunchy" 159 | version = "0.2.2" 160 | source = "registry+https://github.com/rust-lang/crates.io-index" 161 | checksum = "7a81dae078cea95a014a339291cec439d2f232ebe854a9d672b796c6afafa9b7" 162 | 163 | [[package]] 164 | name = "crypto-bigint" 165 | version = "0.4.9" 166 | source = "registry+https://github.com/rust-lang/crates.io-index" 167 | checksum = "ef2b4b23cddf68b89b8f8069890e8c270d54e2d5fe1b143820234805e4cb17ef" 168 | dependencies = [ 169 | "generic-array", 170 | "rand_core", 171 | "subtle", 172 | "zeroize", 173 | ] 174 | 175 | [[package]] 176 | name = "crypto-common" 177 | version = "0.1.6" 178 | source = "registry+https://github.com/rust-lang/crates.io-index" 179 | checksum = "1bfb12502f3fc46cca1bb51ac28df9d618d813cdc3d2f25b9fe775a34af26bb3" 180 | dependencies = [ 181 | "generic-array", 182 | "typenum", 183 | ] 184 | 185 | [[package]] 186 | name = "der" 187 | version = "0.6.1" 188 | source = "registry+https://github.com/rust-lang/crates.io-index" 189 | checksum = "f1a467a65c5e759bce6e65eaf91cc29f466cdc57cb65777bd646872a8a1fd4de" 190 | dependencies = [ 191 | "const-oid", 192 | "zeroize", 193 | ] 194 | 195 | [[package]] 196 | name = "derive_more" 197 | version = "0.99.17" 198 | source = "registry+https://github.com/rust-lang/crates.io-index" 199 | checksum = "4fb810d30a7c1953f91334de7244731fc3f3c10d7fe163338a35b9f640960321" 200 | dependencies = [ 201 | "convert_case", 202 | "proc-macro2", 203 | "quote", 204 | "rustc_version", 205 | "syn", 206 | ] 207 | 208 | [[package]] 209 | name = "digest" 210 | version = "0.10.6" 211 | source = "registry+https://github.com/rust-lang/crates.io-index" 212 | checksum = "8168378f4e5023e7218c89c891c0fd8ecdb5e5e4f18cb78f38cf245dd021e76f" 213 | dependencies = [ 214 | "block-buffer", 215 | "crypto-common", 216 | "subtle", 217 | ] 218 | 219 | [[package]] 220 | name = "ecdsa" 221 | version = "0.14.8" 222 | source = "registry+https://github.com/rust-lang/crates.io-index" 223 | checksum = "413301934810f597c1d19ca71c8710e99a3f1ba28a0d2ebc01551a2daeea3c5c" 224 | dependencies = [ 225 | "der", 226 | "elliptic-curve", 227 | "rfc6979", 228 | "signature", 229 | ] 230 | 231 | [[package]] 232 | name = "elliptic-curve" 233 | version = "0.12.3" 234 | source = "registry+https://github.com/rust-lang/crates.io-index" 235 | checksum = "e7bb888ab5300a19b8e5bceef25ac745ad065f3c9f7efc6de1b91958110891d3" 236 | dependencies = [ 237 | "base16ct", 238 | "crypto-bigint", 239 | "der", 240 | "digest", 241 | "ff", 242 | "generic-array", 243 | "group", 244 | "rand_core", 245 | "sec1", 246 | "subtle", 247 | "zeroize", 248 | ] 249 | 250 | [[package]] 251 | name = "enumn" 252 | version = "0.1.6" 253 | source = "registry+https://github.com/rust-lang/crates.io-index" 254 | checksum = "e88bcb3a067a6555d577aba299e75eff9942da276e6506fc6274327daa026132" 255 | dependencies = [ 256 | "proc-macro2", 257 | "quote", 258 | "syn", 259 | ] 260 | 261 | [[package]] 262 | name = "ethabi" 263 | version = "18.0.0" 264 | source = "registry+https://github.com/rust-lang/crates.io-index" 265 | checksum = "7413c5f74cc903ea37386a8965a936cbeb334bd270862fdece542c1b2dcbc898" 266 | dependencies = [ 267 | "ethereum-types", 268 | "hex", 269 | "once_cell", 270 | "regex", 271 | "serde", 272 | "serde_json", 273 | "sha3", 274 | "thiserror", 275 | "uint", 276 | ] 277 | 278 | [[package]] 279 | name = "ethbloom" 280 | version = "0.13.0" 281 | source = "registry+https://github.com/rust-lang/crates.io-index" 282 | checksum = "c22d4b5885b6aa2fe5e8b9329fb8d232bf739e434e6b87347c63bdd00c120f60" 283 | dependencies = [ 284 | "crunchy", 285 | "fixed-hash", 286 | "impl-codec", 287 | "impl-rlp", 288 | "impl-serde", 289 | "scale-info", 290 | "tiny-keccak", 291 | ] 292 | 293 | [[package]] 294 | name = "ethereum-types" 295 | version = "0.14.1" 296 | source = "registry+https://github.com/rust-lang/crates.io-index" 297 | checksum = "02d215cbf040552efcbe99a38372fe80ab9d00268e20012b79fcd0f073edd8ee" 298 | dependencies = [ 299 | "ethbloom", 300 | "fixed-hash", 301 | "impl-codec", 302 | "impl-rlp", 303 | "impl-serde", 304 | "primitive-types", 305 | "scale-info", 306 | "uint", 307 | ] 308 | 309 | [[package]] 310 | name = "ethers-core" 311 | version = "1.0.2" 312 | source = "registry+https://github.com/rust-lang/crates.io-index" 313 | checksum = "ade3e9c97727343984e1ceada4fdab11142d2ee3472d2c67027d56b1251d4f15" 314 | dependencies = [ 315 | "arrayvec", 316 | "bytes", 317 | "chrono", 318 | "elliptic-curve", 319 | "ethabi", 320 | "generic-array", 321 | "hex", 322 | "k256", 323 | "open-fastrlp", 324 | "rand", 325 | "rlp", 326 | "rlp-derive", 327 | "serde", 328 | "serde_json", 329 | "strum", 330 | "thiserror", 331 | "tiny-keccak", 332 | "unicode-xid", 333 | ] 334 | 335 | [[package]] 336 | name = "eyre" 337 | version = "0.6.8" 338 | source = "registry+https://github.com/rust-lang/crates.io-index" 339 | checksum = "4c2b6b5a29c02cdc822728b7d7b8ae1bab3e3b05d44522770ddd49722eeac7eb" 340 | dependencies = [ 341 | "indenter", 342 | "once_cell", 343 | ] 344 | 345 | [[package]] 346 | name = "ff" 347 | version = "0.12.1" 348 | source = "registry+https://github.com/rust-lang/crates.io-index" 349 | checksum = "d013fc25338cc558c5c2cfbad646908fb23591e2404481826742b651c9af7160" 350 | dependencies = [ 351 | "rand_core", 352 | "subtle", 353 | ] 354 | 355 | [[package]] 356 | name = "fixed-hash" 357 | version = "0.8.0" 358 | source = "registry+https://github.com/rust-lang/crates.io-index" 359 | checksum = "835c052cb0c08c1acf6ffd71c022172e18723949c8282f2b9f27efbc51e64534" 360 | dependencies = [ 361 | "byteorder", 362 | "rand", 363 | "rustc-hex", 364 | "static_assertions", 365 | ] 366 | 367 | [[package]] 368 | name = "funty" 369 | version = "2.0.0" 370 | source = "registry+https://github.com/rust-lang/crates.io-index" 371 | checksum = "e6d5a32815ae3f33302d95fdcb2ce17862f8c65363dcfd29360480ba1001fc9c" 372 | 373 | [[package]] 374 | name = "generic-array" 375 | version = "0.14.6" 376 | source = "registry+https://github.com/rust-lang/crates.io-index" 377 | checksum = "bff49e947297f3312447abdca79f45f4738097cc82b06e72054d2223f601f1b9" 378 | dependencies = [ 379 | "typenum", 380 | "version_check", 381 | ] 382 | 383 | [[package]] 384 | name = "getrandom" 385 | version = "0.2.8" 386 | source = "registry+https://github.com/rust-lang/crates.io-index" 387 | checksum = "c05aeb6a22b8f62540c194aac980f2115af067bfe15a0734d7277a768d396b31" 388 | dependencies = [ 389 | "cfg-if", 390 | "libc", 391 | "wasi", 392 | ] 393 | 394 | [[package]] 395 | name = "group" 396 | version = "0.12.1" 397 | source = "registry+https://github.com/rust-lang/crates.io-index" 398 | checksum = "5dfbfb3a6cfbd390d5c9564ab283a0349b9b9fcd46a706c1eb10e0db70bfbac7" 399 | dependencies = [ 400 | "ff", 401 | "rand_core", 402 | "subtle", 403 | ] 404 | 405 | [[package]] 406 | name = "hashbrown" 407 | version = "0.12.3" 408 | source = "registry+https://github.com/rust-lang/crates.io-index" 409 | checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888" 410 | 411 | [[package]] 412 | name = "hashbrown" 413 | version = "0.13.2" 414 | source = "registry+https://github.com/rust-lang/crates.io-index" 415 | checksum = "43a3c133739dddd0d2990f9a4bdf8eb4b21ef50e4851ca85ab661199821d510e" 416 | dependencies = [ 417 | "ahash", 418 | ] 419 | 420 | [[package]] 421 | name = "heck" 422 | version = "0.4.1" 423 | source = "registry+https://github.com/rust-lang/crates.io-index" 424 | checksum = "95505c38b4572b2d910cecb0281560f54b440a19336cbbcb27bf6ce6adc6f5a8" 425 | 426 | [[package]] 427 | name = "hex" 428 | version = "0.4.3" 429 | source = "registry+https://github.com/rust-lang/crates.io-index" 430 | checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70" 431 | 432 | [[package]] 433 | name = "hex-literal" 434 | version = "0.3.4" 435 | source = "registry+https://github.com/rust-lang/crates.io-index" 436 | checksum = "7ebdb29d2ea9ed0083cd8cece49bbd968021bd99b0849edb4a9a7ee0fdf6a4e0" 437 | 438 | [[package]] 439 | name = "hmac" 440 | version = "0.12.1" 441 | source = "registry+https://github.com/rust-lang/crates.io-index" 442 | checksum = "6c49c37c09c17a53d937dfbb742eb3a961d65a994e6bcdcf37e7399d0cc8ab5e" 443 | dependencies = [ 444 | "digest", 445 | ] 446 | 447 | [[package]] 448 | name = "impl-codec" 449 | version = "0.6.0" 450 | source = "registry+https://github.com/rust-lang/crates.io-index" 451 | checksum = "ba6a270039626615617f3f36d15fc827041df3b78c439da2cadfa47455a77f2f" 452 | dependencies = [ 453 | "parity-scale-codec", 454 | ] 455 | 456 | [[package]] 457 | name = "impl-rlp" 458 | version = "0.3.0" 459 | source = "registry+https://github.com/rust-lang/crates.io-index" 460 | checksum = "f28220f89297a075ddc7245cd538076ee98b01f2a9c23a53a4f1105d5a322808" 461 | dependencies = [ 462 | "rlp", 463 | ] 464 | 465 | [[package]] 466 | name = "impl-serde" 467 | version = "0.4.0" 468 | source = "registry+https://github.com/rust-lang/crates.io-index" 469 | checksum = "ebc88fc67028ae3db0c853baa36269d398d5f45b6982f95549ff5def78c935cd" 470 | dependencies = [ 471 | "serde", 472 | ] 473 | 474 | [[package]] 475 | name = "impl-trait-for-tuples" 476 | version = "0.2.2" 477 | source = "registry+https://github.com/rust-lang/crates.io-index" 478 | checksum = "11d7a9f6330b71fea57921c9b61c47ee6e84f72d394754eff6163ae67e7395eb" 479 | dependencies = [ 480 | "proc-macro2", 481 | "quote", 482 | "syn", 483 | ] 484 | 485 | [[package]] 486 | name = "indenter" 487 | version = "0.3.3" 488 | source = "registry+https://github.com/rust-lang/crates.io-index" 489 | checksum = "ce23b50ad8242c51a442f3ff322d56b02f08852c77e4c0b4d3fd684abc89c683" 490 | 491 | [[package]] 492 | name = "indexmap" 493 | version = "1.9.2" 494 | source = "registry+https://github.com/rust-lang/crates.io-index" 495 | checksum = "1885e79c1fc4b10f0e172c475f458b7f7b93061064d98c3293e98c5ba0c8b399" 496 | dependencies = [ 497 | "autocfg", 498 | "hashbrown 0.12.3", 499 | ] 500 | 501 | [[package]] 502 | name = "itoa" 503 | version = "1.0.5" 504 | source = "registry+https://github.com/rust-lang/crates.io-index" 505 | checksum = "fad582f4b9e86b6caa621cabeb0963332d92eea04729ab12892c2533951e6440" 506 | 507 | [[package]] 508 | name = "k256" 509 | version = "0.11.6" 510 | source = "registry+https://github.com/rust-lang/crates.io-index" 511 | checksum = "72c1e0b51e7ec0a97369623508396067a486bd0cbed95a2659a4b863d28cfc8b" 512 | dependencies = [ 513 | "cfg-if", 514 | "ecdsa", 515 | "elliptic-curve", 516 | "sha2", 517 | "sha3", 518 | ] 519 | 520 | [[package]] 521 | name = "keccak" 522 | version = "0.1.3" 523 | source = "registry+https://github.com/rust-lang/crates.io-index" 524 | checksum = "3afef3b6eff9ce9d8ff9b3601125eec7f0c8cbac7abd14f355d053fa56c98768" 525 | dependencies = [ 526 | "cpufeatures", 527 | ] 528 | 529 | [[package]] 530 | name = "lazy_static" 531 | version = "1.4.0" 532 | source = "registry+https://github.com/rust-lang/crates.io-index" 533 | checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" 534 | dependencies = [ 535 | "spin", 536 | ] 537 | 538 | [[package]] 539 | name = "libc" 540 | version = "0.2.139" 541 | source = "registry+https://github.com/rust-lang/crates.io-index" 542 | checksum = "201de327520df007757c1f0adce6e827fe8562fbc28bfd9c15571c66ca1f5f79" 543 | 544 | [[package]] 545 | name = "memchr" 546 | version = "2.5.0" 547 | source = "registry+https://github.com/rust-lang/crates.io-index" 548 | checksum = "2dffe52ecf27772e601905b7522cb4ef790d2cc203488bbd0e2fe85fcb74566d" 549 | 550 | [[package]] 551 | name = "nom8" 552 | version = "0.2.0" 553 | source = "registry+https://github.com/rust-lang/crates.io-index" 554 | checksum = "ae01545c9c7fc4486ab7debaf2aad7003ac19431791868fb2e8066df97fad2f8" 555 | dependencies = [ 556 | "memchr", 557 | ] 558 | 559 | [[package]] 560 | name = "num" 561 | version = "0.4.0" 562 | source = "registry+https://github.com/rust-lang/crates.io-index" 563 | checksum = "43db66d1170d347f9a065114077f7dccb00c1b9478c89384490a3425279a4606" 564 | dependencies = [ 565 | "num-bigint", 566 | "num-complex", 567 | "num-integer", 568 | "num-iter", 569 | "num-rational", 570 | "num-traits", 571 | ] 572 | 573 | [[package]] 574 | name = "num-bigint" 575 | version = "0.4.3" 576 | source = "registry+https://github.com/rust-lang/crates.io-index" 577 | checksum = "f93ab6289c7b344a8a9f60f88d80aa20032336fe78da341afc91c8a2341fc75f" 578 | dependencies = [ 579 | "autocfg", 580 | "num-integer", 581 | "num-traits", 582 | ] 583 | 584 | [[package]] 585 | name = "num-complex" 586 | version = "0.4.3" 587 | source = "registry+https://github.com/rust-lang/crates.io-index" 588 | checksum = "02e0d21255c828d6f128a1e41534206671e8c3ea0c62f32291e808dc82cff17d" 589 | dependencies = [ 590 | "num-traits", 591 | ] 592 | 593 | [[package]] 594 | name = "num-integer" 595 | version = "0.1.45" 596 | source = "registry+https://github.com/rust-lang/crates.io-index" 597 | checksum = "225d3389fb3509a24c93f5c29eb6bde2586b98d9f016636dff58d7c6f7569cd9" 598 | dependencies = [ 599 | "autocfg", 600 | "num-traits", 601 | ] 602 | 603 | [[package]] 604 | name = "num-iter" 605 | version = "0.1.43" 606 | source = "registry+https://github.com/rust-lang/crates.io-index" 607 | checksum = "7d03e6c028c5dc5cac6e2dec0efda81fc887605bb3d884578bb6d6bf7514e252" 608 | dependencies = [ 609 | "autocfg", 610 | "num-integer", 611 | "num-traits", 612 | ] 613 | 614 | [[package]] 615 | name = "num-rational" 616 | version = "0.4.1" 617 | source = "registry+https://github.com/rust-lang/crates.io-index" 618 | checksum = "0638a1c9d0a3c0914158145bc76cff373a75a627e6ecbfb71cbe6f453a5a19b0" 619 | dependencies = [ 620 | "autocfg", 621 | "num-bigint", 622 | "num-integer", 623 | "num-traits", 624 | ] 625 | 626 | [[package]] 627 | name = "num-traits" 628 | version = "0.2.15" 629 | source = "registry+https://github.com/rust-lang/crates.io-index" 630 | checksum = "578ede34cf02f8924ab9447f50c28075b4d3e5b269972345e7e0372b38c6cdcd" 631 | dependencies = [ 632 | "autocfg", 633 | ] 634 | 635 | [[package]] 636 | name = "once_cell" 637 | version = "1.17.0" 638 | source = "registry+https://github.com/rust-lang/crates.io-index" 639 | checksum = "6f61fba1741ea2b3d6a1e3178721804bb716a68a6aeba1149b5d52e3d464ea66" 640 | 641 | [[package]] 642 | name = "open-fastrlp" 643 | version = "0.1.4" 644 | source = "registry+https://github.com/rust-lang/crates.io-index" 645 | checksum = "786393f80485445794f6043fd3138854dd109cc6c4bd1a6383db304c9ce9b9ce" 646 | dependencies = [ 647 | "arrayvec", 648 | "auto_impl", 649 | "bytes", 650 | "ethereum-types", 651 | "open-fastrlp-derive", 652 | ] 653 | 654 | [[package]] 655 | name = "open-fastrlp-derive" 656 | version = "0.1.1" 657 | source = "registry+https://github.com/rust-lang/crates.io-index" 658 | checksum = "003b2be5c6c53c1cfeb0a238b8a1c3915cd410feb684457a36c10038f764bb1c" 659 | dependencies = [ 660 | "bytes", 661 | "proc-macro2", 662 | "quote", 663 | "syn", 664 | ] 665 | 666 | [[package]] 667 | name = "parity-scale-codec" 668 | version = "3.3.0" 669 | source = "registry+https://github.com/rust-lang/crates.io-index" 670 | checksum = "c3840933452adf7b3b9145e27086a5a3376c619dca1a21b1e5a5af0d54979bed" 671 | dependencies = [ 672 | "arrayvec", 673 | "bitvec", 674 | "byte-slice-cast", 675 | "impl-trait-for-tuples", 676 | "parity-scale-codec-derive", 677 | "serde", 678 | ] 679 | 680 | [[package]] 681 | name = "parity-scale-codec-derive" 682 | version = "3.1.4" 683 | source = "registry+https://github.com/rust-lang/crates.io-index" 684 | checksum = "86b26a931f824dd4eca30b3e43bb4f31cd5f0d3a403c5f5ff27106b805bfde7b" 685 | dependencies = [ 686 | "proc-macro-crate", 687 | "proc-macro2", 688 | "quote", 689 | "syn", 690 | ] 691 | 692 | [[package]] 693 | name = "pkcs8" 694 | version = "0.9.0" 695 | source = "registry+https://github.com/rust-lang/crates.io-index" 696 | checksum = "9eca2c590a5f85da82668fa685c09ce2888b9430e83299debf1f34b65fd4a4ba" 697 | dependencies = [ 698 | "der", 699 | "spki", 700 | ] 701 | 702 | [[package]] 703 | name = "ppv-lite86" 704 | version = "0.2.17" 705 | source = "registry+https://github.com/rust-lang/crates.io-index" 706 | checksum = "5b40af805b3121feab8a3c29f04d8ad262fa8e0561883e7653e024ae4479e6de" 707 | 708 | [[package]] 709 | name = "primitive-types" 710 | version = "0.12.1" 711 | source = "registry+https://github.com/rust-lang/crates.io-index" 712 | checksum = "9f3486ccba82358b11a77516035647c34ba167dfa53312630de83b12bd4f3d66" 713 | dependencies = [ 714 | "fixed-hash", 715 | "impl-codec", 716 | "impl-rlp", 717 | "impl-serde", 718 | "scale-info", 719 | "uint", 720 | ] 721 | 722 | [[package]] 723 | name = "proc-macro-crate" 724 | version = "1.3.0" 725 | source = "registry+https://github.com/rust-lang/crates.io-index" 726 | checksum = "66618389e4ec1c7afe67d51a9bf34ff9236480f8d51e7489b7d5ab0303c13f34" 727 | dependencies = [ 728 | "once_cell", 729 | "toml_edit", 730 | ] 731 | 732 | [[package]] 733 | name = "proc-macro-error" 734 | version = "1.0.4" 735 | source = "registry+https://github.com/rust-lang/crates.io-index" 736 | checksum = "da25490ff9892aab3fcf7c36f08cfb902dd3e71ca0f9f9517bea02a73a5ce38c" 737 | dependencies = [ 738 | "proc-macro-error-attr", 739 | "proc-macro2", 740 | "quote", 741 | "syn", 742 | "version_check", 743 | ] 744 | 745 | [[package]] 746 | name = "proc-macro-error-attr" 747 | version = "1.0.4" 748 | source = "registry+https://github.com/rust-lang/crates.io-index" 749 | checksum = "a1be40180e52ecc98ad80b184934baf3d0d29f979574e439af5a55274b35f869" 750 | dependencies = [ 751 | "proc-macro2", 752 | "quote", 753 | "version_check", 754 | ] 755 | 756 | [[package]] 757 | name = "proc-macro2" 758 | version = "1.0.51" 759 | source = "registry+https://github.com/rust-lang/crates.io-index" 760 | checksum = "5d727cae5b39d21da60fa540906919ad737832fe0b1c165da3a34d6548c849d6" 761 | dependencies = [ 762 | "unicode-ident", 763 | ] 764 | 765 | [[package]] 766 | name = "quote" 767 | version = "1.0.23" 768 | source = "registry+https://github.com/rust-lang/crates.io-index" 769 | checksum = "8856d8364d252a14d474036ea1358d63c9e6965c8e5c1885c18f73d70bff9c7b" 770 | dependencies = [ 771 | "proc-macro2", 772 | ] 773 | 774 | [[package]] 775 | name = "radium" 776 | version = "0.7.0" 777 | source = "registry+https://github.com/rust-lang/crates.io-index" 778 | checksum = "dc33ff2d4973d518d823d61aa239014831e521c75da58e3df4840d3f47749d09" 779 | 780 | [[package]] 781 | name = "rand" 782 | version = "0.8.5" 783 | source = "registry+https://github.com/rust-lang/crates.io-index" 784 | checksum = "34af8d1a0e25924bc5b7c43c079c942339d8f0a8b57c39049bef581b46327404" 785 | dependencies = [ 786 | "libc", 787 | "rand_chacha", 788 | "rand_core", 789 | ] 790 | 791 | [[package]] 792 | name = "rand_chacha" 793 | version = "0.3.1" 794 | source = "registry+https://github.com/rust-lang/crates.io-index" 795 | checksum = "e6c10a63a0fa32252be49d21e7709d4d4baf8d231c2dbce1eaa8141b9b127d88" 796 | dependencies = [ 797 | "ppv-lite86", 798 | "rand_core", 799 | ] 800 | 801 | [[package]] 802 | name = "rand_core" 803 | version = "0.6.4" 804 | source = "registry+https://github.com/rust-lang/crates.io-index" 805 | checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c" 806 | dependencies = [ 807 | "getrandom", 808 | ] 809 | 810 | [[package]] 811 | name = "regex" 812 | version = "1.7.1" 813 | source = "registry+https://github.com/rust-lang/crates.io-index" 814 | checksum = "48aaa5748ba571fb95cd2c85c09f629215d3a6ece942baa100950af03a34f733" 815 | dependencies = [ 816 | "aho-corasick", 817 | "memchr", 818 | "regex-syntax", 819 | ] 820 | 821 | [[package]] 822 | name = "regex-syntax" 823 | version = "0.6.28" 824 | source = "registry+https://github.com/rust-lang/crates.io-index" 825 | checksum = "456c603be3e8d448b072f410900c09faf164fbce2d480456f50eea6e25f9c848" 826 | 827 | [[package]] 828 | name = "revm" 829 | version = "3.0.0" 830 | source = "registry+https://github.com/rust-lang/crates.io-index" 831 | checksum = "284747ad0324ed0e805dcf8f412e2beccb7a547fbd84f0607865001b8719c515" 832 | dependencies = [ 833 | "auto_impl", 834 | "revm-interpreter", 835 | "revm-precompile", 836 | ] 837 | 838 | [[package]] 839 | name = "revm-interpreter" 840 | version = "1.0.0" 841 | source = "registry+https://github.com/rust-lang/crates.io-index" 842 | checksum = "db1b86f1d21d1852b40ec8ac9b6d31ac8a7c000875155809d41ce68f6369dc56" 843 | dependencies = [ 844 | "derive_more", 845 | "enumn", 846 | "revm-primitives", 847 | "sha3", 848 | ] 849 | 850 | [[package]] 851 | name = "revm-precompile" 852 | version = "2.0.0" 853 | source = "registry+https://github.com/rust-lang/crates.io-index" 854 | checksum = "66837781605c6dcb7f07ad87604eeab3119dae9149d69d8839073dd6f188673d" 855 | dependencies = [ 856 | "k256", 857 | "num", 858 | "once_cell", 859 | "revm-primitives", 860 | "ripemd", 861 | "secp256k1", 862 | "sha2", 863 | "sha3", 864 | "substrate-bn", 865 | ] 866 | 867 | [[package]] 868 | name = "revm-primitives" 869 | version = "1.0.0" 870 | source = "registry+https://github.com/rust-lang/crates.io-index" 871 | checksum = "ad165d3f69e4d14405d82c6625864ee48c162dcebdf170322e6dd80398226a9e" 872 | dependencies = [ 873 | "auto_impl", 874 | "bytes", 875 | "derive_more", 876 | "enumn", 877 | "fixed-hash", 878 | "hashbrown 0.13.2", 879 | "hex", 880 | "hex-literal", 881 | "rlp", 882 | "ruint", 883 | "sha3", 884 | ] 885 | 886 | [[package]] 887 | name = "rfc6979" 888 | version = "0.3.1" 889 | source = "registry+https://github.com/rust-lang/crates.io-index" 890 | checksum = "7743f17af12fa0b03b803ba12cd6a8d9483a587e89c69445e3909655c0b9fabb" 891 | dependencies = [ 892 | "crypto-bigint", 893 | "hmac", 894 | "zeroize", 895 | ] 896 | 897 | [[package]] 898 | name = "ripemd" 899 | version = "0.1.3" 900 | source = "registry+https://github.com/rust-lang/crates.io-index" 901 | checksum = "bd124222d17ad93a644ed9d011a40f4fb64aa54275c08cc216524a9ea82fb09f" 902 | dependencies = [ 903 | "digest", 904 | ] 905 | 906 | [[package]] 907 | name = "rlp" 908 | version = "0.5.2" 909 | source = "registry+https://github.com/rust-lang/crates.io-index" 910 | checksum = "bb919243f34364b6bd2fc10ef797edbfa75f33c252e7998527479c6d6b47e1ec" 911 | dependencies = [ 912 | "bytes", 913 | "rustc-hex", 914 | ] 915 | 916 | [[package]] 917 | name = "rlp-derive" 918 | version = "0.1.0" 919 | source = "registry+https://github.com/rust-lang/crates.io-index" 920 | checksum = "e33d7b2abe0c340d8797fe2907d3f20d3b5ea5908683618bfe80df7f621f672a" 921 | dependencies = [ 922 | "proc-macro2", 923 | "quote", 924 | "syn", 925 | ] 926 | 927 | [[package]] 928 | name = "ruint" 929 | version = "1.7.0" 930 | source = "registry+https://github.com/rust-lang/crates.io-index" 931 | checksum = "0ad3a104dc8c3867f653b0fec89c65e00b0ceb752718ad282177a7e0f33257ac" 932 | dependencies = [ 933 | "derive_more", 934 | "primitive-types", 935 | "rlp", 936 | "ruint-macro", 937 | "rustc_version", 938 | "thiserror", 939 | ] 940 | 941 | [[package]] 942 | name = "ruint-macro" 943 | version = "1.0.2" 944 | source = "registry+https://github.com/rust-lang/crates.io-index" 945 | checksum = "62cc5760263ea229d367e7dff3c0cbf09e4797a125bd87059a6c095804f3b2d1" 946 | 947 | [[package]] 948 | name = "rustc-hex" 949 | version = "2.1.0" 950 | source = "registry+https://github.com/rust-lang/crates.io-index" 951 | checksum = "3e75f6a532d0fd9f7f13144f392b6ad56a32696bfcd9c78f797f16bbb6f072d6" 952 | 953 | [[package]] 954 | name = "rustc_version" 955 | version = "0.4.0" 956 | source = "registry+https://github.com/rust-lang/crates.io-index" 957 | checksum = "bfa0f585226d2e68097d4f95d113b15b83a82e819ab25717ec0590d9584ef366" 958 | dependencies = [ 959 | "semver", 960 | ] 961 | 962 | [[package]] 963 | name = "rustversion" 964 | version = "1.0.11" 965 | source = "registry+https://github.com/rust-lang/crates.io-index" 966 | checksum = "5583e89e108996506031660fe09baa5011b9dd0341b89029313006d1fb508d70" 967 | 968 | [[package]] 969 | name = "ryu" 970 | version = "1.0.12" 971 | source = "registry+https://github.com/rust-lang/crates.io-index" 972 | checksum = "7b4b9743ed687d4b4bcedf9ff5eaa7398495ae14e61cba0a295704edbc7decde" 973 | 974 | [[package]] 975 | name = "scale-info" 976 | version = "2.3.1" 977 | source = "registry+https://github.com/rust-lang/crates.io-index" 978 | checksum = "001cf62ece89779fd16105b5f515ad0e5cedcd5440d3dd806bb067978e7c3608" 979 | dependencies = [ 980 | "cfg-if", 981 | "derive_more", 982 | "parity-scale-codec", 983 | "scale-info-derive", 984 | ] 985 | 986 | [[package]] 987 | name = "scale-info-derive" 988 | version = "2.3.1" 989 | source = "registry+https://github.com/rust-lang/crates.io-index" 990 | checksum = "303959cf613a6f6efd19ed4b4ad5bf79966a13352716299ad532cfb115f4205c" 991 | dependencies = [ 992 | "proc-macro-crate", 993 | "proc-macro2", 994 | "quote", 995 | "syn", 996 | ] 997 | 998 | [[package]] 999 | name = "sec1" 1000 | version = "0.3.0" 1001 | source = "registry+https://github.com/rust-lang/crates.io-index" 1002 | checksum = "3be24c1842290c45df0a7bf069e0c268a747ad05a192f2fd7dcfdbc1cba40928" 1003 | dependencies = [ 1004 | "base16ct", 1005 | "der", 1006 | "generic-array", 1007 | "pkcs8", 1008 | "subtle", 1009 | "zeroize", 1010 | ] 1011 | 1012 | [[package]] 1013 | name = "secp256k1" 1014 | version = "0.26.0" 1015 | source = "registry+https://github.com/rust-lang/crates.io-index" 1016 | checksum = "4124a35fe33ae14259c490fd70fa199a32b9ce9502f2ee6bc4f81ec06fa65894" 1017 | dependencies = [ 1018 | "secp256k1-sys", 1019 | ] 1020 | 1021 | [[package]] 1022 | name = "secp256k1-sys" 1023 | version = "0.8.0" 1024 | source = "registry+https://github.com/rust-lang/crates.io-index" 1025 | checksum = "642a62736682fdd8c71da0eb273e453c8ac74e33b9fb310e22ba5b03ec7651ff" 1026 | dependencies = [ 1027 | "cc", 1028 | ] 1029 | 1030 | [[package]] 1031 | name = "semver" 1032 | version = "1.0.16" 1033 | source = "registry+https://github.com/rust-lang/crates.io-index" 1034 | checksum = "58bc9567378fc7690d6b2addae4e60ac2eeea07becb2c64b9f218b53865cba2a" 1035 | 1036 | [[package]] 1037 | name = "serde" 1038 | version = "1.0.152" 1039 | source = "registry+https://github.com/rust-lang/crates.io-index" 1040 | checksum = "bb7d1f0d3021d347a83e556fc4683dea2ea09d87bccdf88ff5c12545d89d5efb" 1041 | dependencies = [ 1042 | "serde_derive", 1043 | ] 1044 | 1045 | [[package]] 1046 | name = "serde_derive" 1047 | version = "1.0.152" 1048 | source = "registry+https://github.com/rust-lang/crates.io-index" 1049 | checksum = "af487d118eecd09402d70a5d72551860e788df87b464af30e5ea6a38c75c541e" 1050 | dependencies = [ 1051 | "proc-macro2", 1052 | "quote", 1053 | "syn", 1054 | ] 1055 | 1056 | [[package]] 1057 | name = "serde_json" 1058 | version = "1.0.93" 1059 | source = "registry+https://github.com/rust-lang/crates.io-index" 1060 | checksum = "cad406b69c91885b5107daf2c29572f6c8cdb3c66826821e286c533490c0bc76" 1061 | dependencies = [ 1062 | "itoa", 1063 | "ryu", 1064 | "serde", 1065 | ] 1066 | 1067 | [[package]] 1068 | name = "sha2" 1069 | version = "0.10.6" 1070 | source = "registry+https://github.com/rust-lang/crates.io-index" 1071 | checksum = "82e6b795fe2e3b1e845bafcb27aa35405c4d47cdfc92af5fc8d3002f76cebdc0" 1072 | dependencies = [ 1073 | "cfg-if", 1074 | "cpufeatures", 1075 | "digest", 1076 | ] 1077 | 1078 | [[package]] 1079 | name = "sha3" 1080 | version = "0.10.6" 1081 | source = "registry+https://github.com/rust-lang/crates.io-index" 1082 | checksum = "bdf0c33fae925bdc080598b84bc15c55e7b9a4a43b3c704da051f977469691c9" 1083 | dependencies = [ 1084 | "digest", 1085 | "keccak", 1086 | ] 1087 | 1088 | [[package]] 1089 | name = "signature" 1090 | version = "1.6.4" 1091 | source = "registry+https://github.com/rust-lang/crates.io-index" 1092 | checksum = "74233d3b3b2f6d4b006dc19dee745e73e2a6bfb6f93607cd3b02bd5b00797d7c" 1093 | dependencies = [ 1094 | "digest", 1095 | "rand_core", 1096 | ] 1097 | 1098 | [[package]] 1099 | name = "spin" 1100 | version = "0.5.2" 1101 | source = "registry+https://github.com/rust-lang/crates.io-index" 1102 | checksum = "6e63cff320ae2c57904679ba7cb63280a3dc4613885beafb148ee7bf9aa9042d" 1103 | 1104 | [[package]] 1105 | name = "spki" 1106 | version = "0.6.0" 1107 | source = "registry+https://github.com/rust-lang/crates.io-index" 1108 | checksum = "67cf02bbac7a337dc36e4f5a693db6c21e7863f45070f7064577eb4367a3212b" 1109 | dependencies = [ 1110 | "base64ct", 1111 | "der", 1112 | ] 1113 | 1114 | [[package]] 1115 | name = "static_assertions" 1116 | version = "1.1.0" 1117 | source = "registry+https://github.com/rust-lang/crates.io-index" 1118 | checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f" 1119 | 1120 | [[package]] 1121 | name = "strum" 1122 | version = "0.24.1" 1123 | source = "registry+https://github.com/rust-lang/crates.io-index" 1124 | checksum = "063e6045c0e62079840579a7e47a355ae92f60eb74daaf156fb1e84ba164e63f" 1125 | dependencies = [ 1126 | "strum_macros", 1127 | ] 1128 | 1129 | [[package]] 1130 | name = "strum_macros" 1131 | version = "0.24.3" 1132 | source = "registry+https://github.com/rust-lang/crates.io-index" 1133 | checksum = "1e385be0d24f186b4ce2f9982191e7101bb737312ad61c1f2f984f34bcf85d59" 1134 | dependencies = [ 1135 | "heck", 1136 | "proc-macro2", 1137 | "quote", 1138 | "rustversion", 1139 | "syn", 1140 | ] 1141 | 1142 | [[package]] 1143 | name = "substrate-bn" 1144 | version = "0.6.0" 1145 | source = "registry+https://github.com/rust-lang/crates.io-index" 1146 | checksum = "72b5bbfa79abbae15dd642ea8176a21a635ff3c00059961d1ea27ad04e5b441c" 1147 | dependencies = [ 1148 | "byteorder", 1149 | "crunchy", 1150 | "lazy_static", 1151 | "rand", 1152 | "rustc-hex", 1153 | ] 1154 | 1155 | [[package]] 1156 | name = "subtle" 1157 | version = "2.4.1" 1158 | source = "registry+https://github.com/rust-lang/crates.io-index" 1159 | checksum = "6bdef32e8150c2a081110b42772ffe7d7c9032b606bc226c8260fd97e0976601" 1160 | 1161 | [[package]] 1162 | name = "syn" 1163 | version = "1.0.107" 1164 | source = "registry+https://github.com/rust-lang/crates.io-index" 1165 | checksum = "1f4064b5b16e03ae50984a5a8ed5d4f8803e6bc1fd170a3cda91a1be4b18e3f5" 1166 | dependencies = [ 1167 | "proc-macro2", 1168 | "quote", 1169 | "unicode-ident", 1170 | ] 1171 | 1172 | [[package]] 1173 | name = "tap" 1174 | version = "1.0.1" 1175 | source = "registry+https://github.com/rust-lang/crates.io-index" 1176 | checksum = "55937e1799185b12863d447f42597ed69d9928686b8d88a1df17376a097d8369" 1177 | 1178 | [[package]] 1179 | name = "thiserror" 1180 | version = "1.0.38" 1181 | source = "registry+https://github.com/rust-lang/crates.io-index" 1182 | checksum = "6a9cd18aa97d5c45c6603caea1da6628790b37f7a34b6ca89522331c5180fed0" 1183 | dependencies = [ 1184 | "thiserror-impl", 1185 | ] 1186 | 1187 | [[package]] 1188 | name = "thiserror-impl" 1189 | version = "1.0.38" 1190 | source = "registry+https://github.com/rust-lang/crates.io-index" 1191 | checksum = "1fb327af4685e4d03fa8cbcf1716380da910eeb2bb8be417e7f9fd3fb164f36f" 1192 | dependencies = [ 1193 | "proc-macro2", 1194 | "quote", 1195 | "syn", 1196 | ] 1197 | 1198 | [[package]] 1199 | name = "tiny-keccak" 1200 | version = "2.0.2" 1201 | source = "registry+https://github.com/rust-lang/crates.io-index" 1202 | checksum = "2c9d3793400a45f954c52e73d068316d76b6f4e36977e3fcebb13a2721e80237" 1203 | dependencies = [ 1204 | "crunchy", 1205 | ] 1206 | 1207 | [[package]] 1208 | name = "toml_datetime" 1209 | version = "0.5.1" 1210 | source = "registry+https://github.com/rust-lang/crates.io-index" 1211 | checksum = "4553f467ac8e3d374bc9a177a26801e5d0f9b211aa1673fb137a403afd1c9cf5" 1212 | 1213 | [[package]] 1214 | name = "toml_edit" 1215 | version = "0.18.1" 1216 | source = "registry+https://github.com/rust-lang/crates.io-index" 1217 | checksum = "56c59d8dd7d0dcbc6428bf7aa2f0e823e26e43b3c9aca15bbc9475d23e5fa12b" 1218 | dependencies = [ 1219 | "indexmap", 1220 | "nom8", 1221 | "toml_datetime", 1222 | ] 1223 | 1224 | [[package]] 1225 | name = "typenum" 1226 | version = "1.16.0" 1227 | source = "registry+https://github.com/rust-lang/crates.io-index" 1228 | checksum = "497961ef93d974e23eb6f433eb5fe1b7930b659f06d12dec6fc44a8f554c0bba" 1229 | 1230 | [[package]] 1231 | name = "uint" 1232 | version = "0.9.5" 1233 | source = "registry+https://github.com/rust-lang/crates.io-index" 1234 | checksum = "76f64bba2c53b04fcab63c01a7d7427eadc821e3bc48c34dc9ba29c501164b52" 1235 | dependencies = [ 1236 | "byteorder", 1237 | "crunchy", 1238 | "hex", 1239 | "static_assertions", 1240 | ] 1241 | 1242 | [[package]] 1243 | name = "unicode-ident" 1244 | version = "1.0.6" 1245 | source = "registry+https://github.com/rust-lang/crates.io-index" 1246 | checksum = "84a22b9f218b40614adcb3f4ff08b703773ad44fa9423e4e0d346d5db86e4ebc" 1247 | 1248 | [[package]] 1249 | name = "unicode-xid" 1250 | version = "0.2.4" 1251 | source = "registry+https://github.com/rust-lang/crates.io-index" 1252 | checksum = "f962df74c8c05a667b5ee8bcf162993134c104e96440b663c8daa176dc772d8c" 1253 | 1254 | [[package]] 1255 | name = "version_check" 1256 | version = "0.9.4" 1257 | source = "registry+https://github.com/rust-lang/crates.io-index" 1258 | checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f" 1259 | 1260 | [[package]] 1261 | name = "wasi" 1262 | version = "0.11.0+wasi-snapshot-preview1" 1263 | source = "registry+https://github.com/rust-lang/crates.io-index" 1264 | checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" 1265 | 1266 | [[package]] 1267 | name = "wyz" 1268 | version = "0.5.1" 1269 | source = "registry+https://github.com/rust-lang/crates.io-index" 1270 | checksum = "05f360fc0b24296329c78fda852a1e9ae82de9cf7b27dae4b7f62f118f77b9ed" 1271 | dependencies = [ 1272 | "tap", 1273 | ] 1274 | 1275 | [[package]] 1276 | name = "zeroize" 1277 | version = "1.5.7" 1278 | source = "registry+https://github.com/rust-lang/crates.io-index" 1279 | checksum = "c394b5bd0c6f669e7275d9c20aa90ae064cb22e75a1cad54e1b34088034b149f" 1280 | -------------------------------------------------------------------------------- /backend/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "backend" 3 | version = "0.1.0" 4 | edition = "2021" 5 | 6 | [dependencies] 7 | ethers-core = "1.0.2" 8 | serde = { version = "1.0.152", features = ["derive"] } 9 | serde_json = "1.0.92" 10 | eyre = "0.6.8" 11 | revm = "3.0.0" -------------------------------------------------------------------------------- /backend/src/benchdb.rs: -------------------------------------------------------------------------------- 1 | use crate::types::{BlockHash, BlockNumber, BlockWithReceipts, Database, DbResult}; 2 | 3 | use ethers_core::types::{Block, Transaction, TransactionReceipt}; 4 | 5 | /// Benchmark backend that records reads and writes. 6 | #[derive(Debug, Clone, Default)] 7 | pub struct BenchDb { 8 | /// A counter for writes. 9 | pub writes: usize, 10 | /// A counter for reads. 11 | pub reads: usize, 12 | } 13 | 14 | impl BenchDb { 15 | /// Creates a new instance of [BenchDb](crate::BenchDb). 16 | pub fn new() -> Self { 17 | Self { writes: 0, reads: 0 } 18 | } 19 | } 20 | 21 | impl Database for BenchDb { 22 | /// Mocks a write to the database storage. 23 | fn write_block(&mut self, _block: BlockWithReceipts) -> DbResult<()> { 24 | self.writes += 1; 25 | Ok(()) 26 | } 27 | 28 | /// Mocks a read from the database storage. 29 | fn read_block(&mut self, hash: BlockHash) -> DbResult { 30 | self.reads += 1; 31 | Ok(BlockWithReceipts { 32 | block: Block { 33 | hash: Some(hash), 34 | number: Some(BlockNumber::from(0)), 35 | transactions: vec![Transaction { 36 | hash, 37 | ..Default::default() 38 | }], 39 | ..Default::default() 40 | }, 41 | receipts: vec![TransactionReceipt { 42 | transaction_hash: hash, 43 | ..Default::default() 44 | }], 45 | }) 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /backend/src/dblock.rs: -------------------------------------------------------------------------------- 1 | use std::collections::HashMap; 2 | 3 | use crate::types::{BlockHash, BlockNumber, BlockWithReceipts, Database, DbResult}; 4 | 5 | /// Memory backend to store blocks and transactions. 6 | #[derive(Debug, Default, Clone)] 7 | pub struct DBlock { 8 | /// A map of block hash to the block object. 9 | pub blocks: HashMap, 10 | /// A map from block number to block hash. 11 | pub hashes: HashMap, 12 | /// The internal database store. 13 | pub db: ExtDB, 14 | } 15 | 16 | impl DBlock { 17 | /// Creates a new instance of [DBlock](crate::DBlock). 18 | pub fn new(db: ExtDB) -> Self { 19 | Self { 20 | blocks: HashMap::new(), 21 | hashes: HashMap::new(), 22 | db, 23 | } 24 | } 25 | } 26 | 27 | impl Database for DBlock { 28 | /// Writes a block to the database storage. 29 | fn write_block(&mut self, block: BlockWithReceipts) -> DbResult<()> { 30 | let hash = block.block.hash.ok_or_else(|| eyre::eyre!("missing block hash"))?; 31 | let receipts = self.db.read_block(hash)?; 32 | let block_number = block.block.number.ok_or_else(|| eyre::eyre!("missing block number"))?; 33 | self.blocks.insert( 34 | hash, 35 | BlockWithReceipts { 36 | block: block.block, 37 | ..receipts 38 | }, 39 | ); 40 | self.hashes.insert(block_number, hash); 41 | Ok(()) 42 | } 43 | 44 | /// Reads a block from the database storage. 45 | fn read_block(&mut self, hash: BlockHash) -> DbResult { 46 | if let Some(block) = self.blocks.get(&hash) { 47 | return Ok(block.clone()); 48 | } 49 | let block = self.db.read_block(hash)?; 50 | self.blocks.insert(hash, block.clone()); 51 | Ok(block) 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /backend/src/lib.rs: -------------------------------------------------------------------------------- 1 | #![warn(missing_debug_implementations, rust_2018_idioms, unreachable_pub)] 2 | #![deny(rustdoc::broken_intra_doc_links)] 3 | #![doc(test(no_crate_inject, attr(deny(warnings, rust_2018_idioms), allow(dead_code, unused_variables))))] 4 | 5 | //! # Revm Database Implementation 6 | //! 7 | //! This crate exposes a database implementation for reading and writing 8 | //! [BlockWithReceipts](crate::types::BlockWithReceipts) to persistent storage. 9 | //! 10 | //! Uses [revm](https://github.com/bluealloy/revm)'s [Database](revm::Database) trait. 11 | //! 12 | //! ## Example 13 | //! 14 | //! ```rust 15 | //! use backend::dblock::{DBlock}; 16 | //! use backend::benchdb::{BenchDb}; 17 | //! use backend::types::{BlockHash, BlockNumber, Database}; 18 | //! use ethers_core::types::{H256}; 19 | //! use ethers_core::abi::AbiDecode; 20 | //! 21 | //! let block_number = BlockNumber::from(42); 22 | //! let block_hash: BlockHash = H256::decode_hex("1d2b0bda21d56b8bd12d4f94ebacffdfb35f5e226f84b461103bb8beab6353be").unwrap(); 23 | //! let mut database = DBlock::new(BenchDb::default()); 24 | //! let block = database.read_block(block_hash).unwrap(); 25 | //! assert_eq!(block.block.number, Some(BlockNumber::from(0))); 26 | //! ``` 27 | 28 | /// A block database. 29 | pub mod dblock; 30 | 31 | /// Common types 32 | pub mod types; 33 | 34 | /// A benchmark database. 35 | pub mod benchdb; 36 | 37 | /// Prelude of common types for easy usage of the [backend](crate) crate. 38 | pub mod prelude { 39 | pub use super::benchdb::*; 40 | pub use super::dblock::*; 41 | pub use super::types::*; 42 | } 43 | -------------------------------------------------------------------------------- /backend/src/types.rs: -------------------------------------------------------------------------------- 1 | use ethers_core::types::{Block, Transaction, TransactionReceipt}; 2 | use ethers_core::types::{H256, U64}; 3 | use serde::{Deserialize, Serialize}; 4 | 5 | // TODO: remove this and use upper-level type 6 | #[derive(Serialize, Deserialize, Debug, Clone)] 7 | pub struct BlockWithReceipts { 8 | /// Block 9 | pub block: Block, 10 | /// Block Receipts 11 | pub receipts: Vec, 12 | } 13 | 14 | /// A Database read-write result. 15 | pub type DbResult = eyre::Result; 16 | 17 | pub type BlockHash = H256; 18 | pub type BlockNumber = U64; 19 | 20 | /// Database is a trait that defines the interface for a persistent, on-disk database store. 21 | pub trait Database { 22 | /// Writes a block to the database storage. 23 | fn write_block(&mut self, block: BlockWithReceipts) -> DbResult<()>; 24 | /// Reads a block from the database storage. 25 | fn read_block(&mut self, hash: BlockHash) -> DbResult; 26 | } 27 | -------------------------------------------------------------------------------- /backend/tests/common.rs: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /backend/tests/dblock.rs: -------------------------------------------------------------------------------- 1 | use backend::benchdb::BenchDb; 2 | use backend::dblock::DBlock; 3 | use backend::types::{BlockHash, BlockNumber, BlockWithReceipts, Database}; 4 | use ethers_core::abi::AbiDecode; 5 | use ethers_core::types::Block; 6 | use ethers_core::types::H256; 7 | 8 | #[test] 9 | pub fn test_phantom_read() { 10 | let block_hash: BlockHash = H256::decode_hex("1d2b0bda21d56b8bd12d4f94ebacffdfb35f5e226f84b461103bb8beab6353be").unwrap(); 11 | let bencher = BenchDb::default(); 12 | let mut database = DBlock::new(bencher); 13 | let block = database.read_block(block_hash).unwrap(); 14 | assert_eq!(block.block.number, Some(BlockNumber::from(0))); 15 | assert_eq!(database.db.reads, 1); 16 | } 17 | 18 | #[test] 19 | pub fn test_write() { 20 | let block_number = BlockNumber::from(42); 21 | let block_hash: BlockHash = H256::decode_hex("1d2b0bda21d56b8bd12d4f94ebacffdfb35f5e226f84b461103bb8beab6353be").unwrap(); 22 | let bencher = BenchDb::default(); 23 | let mut database = DBlock::new(bencher); 24 | database.write_block(BlockWithReceipts { 25 | block: Block { 26 | number: Some(block_number), 27 | hash: Some(block_hash), 28 | ..Default::default() 29 | }, 30 | receipts: vec![], 31 | }) 32 | .unwrap(); 33 | } 34 | 35 | #[test] 36 | pub fn test_write_read() { 37 | let block_number = BlockNumber::from(42); 38 | let block_hash: BlockHash = H256::decode_hex("1d2b0bda21d56b8bd12d4f94ebacffdfb35f5e226f84b461103bb8beab6353be").unwrap(); 39 | let bencher = BenchDb::default(); 40 | let mut database = DBlock::new(bencher); 41 | database.write_block(BlockWithReceipts { 42 | block: Block { 43 | number: Some(block_number), 44 | hash: Some(block_hash), 45 | ..Default::default() 46 | }, 47 | receipts: vec![], 48 | }) 49 | .unwrap(); 50 | let block = database.read_block(block_hash).unwrap(); 51 | assert_eq!(block.block.number, Some(block_number)); 52 | assert_eq!(database.db.reads, 1); 53 | } 54 | -------------------------------------------------------------------------------- /crates/client/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "client" 3 | version = "0.1.0" 4 | edition = "2021" 5 | 6 | 7 | [dependencies] 8 | 9 | # Local 10 | core = {path = "../core"} 11 | 12 | # Non-Local 13 | ethers-core = "1.0.2" 14 | ethers-providers = "1.0.2" 15 | tokio = { version = "1.25.0", features = ["macros", "rt-multi-thread"] } 16 | eyre = "0.6.8" 17 | reth-primitives = { git = "https://github.com/paradigmxyz/reth", features = [] } 18 | -------------------------------------------------------------------------------- /crates/client/src/lib.rs: -------------------------------------------------------------------------------- 1 | use core::types::{Hash, Header, Receipt, Transaction}; 2 | use eyre::Result; 3 | 4 | pub trait Provider { 5 | fn get_header(&mut self, hash: Hash) -> Result
; 6 | fn get_header_by_number(&mut self, n: u64) -> Result
; 7 | fn get_receipts_by_root(&self, root: Hash) -> Result>; 8 | fn get_transactions_by_root(&self, root: Hash) -> Result>; 9 | } 10 | 11 | pub mod rpc_provider; 12 | mod types; 13 | 14 | pub mod prelude { 15 | pub use crate::rpc_provider::Client; 16 | pub use crate::Provider; 17 | } 18 | -------------------------------------------------------------------------------- /crates/client/src/rpc_provider.rs: -------------------------------------------------------------------------------- 1 | use crate::Provider; 2 | use core::prelude::*; 3 | use core::types::{Hash, Header}; 4 | 5 | use ethers_providers::{Http, Middleware, Provider as RPCProvider}; 6 | use eyre::Result; 7 | use std::{collections::HashMap, convert::TryFrom}; 8 | use tokio::runtime::Runtime; 9 | 10 | /// Client wraps a web3 provider to provide L1 pre-image oracle support. 11 | #[derive(Debug)] 12 | pub struct Client { 13 | /// The internal web3 provider 14 | pub provider: RPCProvider, 15 | /// The client runtime 16 | pub rt: Runtime, 17 | /// Store of receipts from Receipt Root to Receipts 18 | pub receipts: HashMap>, 19 | /// Store of transactions from Transaction Root to Transactions 20 | pub transactions: HashMap>, 21 | } 22 | 23 | impl Provider for Client { 24 | /// Gets a block header by block hash 25 | fn get_header(&mut self, hash: Hash) -> Result
{ 26 | let hash: ethers_core::types::H256 = hash.into(); 27 | let block = self.rt.block_on(self.provider.get_block_with_txs(hash))?; 28 | let block = block.ok_or(eyre::eyre!("did not find the block"))?; 29 | 30 | let txs: Vec = block.transactions.clone().into_iter().map(|t| t.into()).collect(); 31 | let tx_root = block.transactions_root.into(); 32 | 33 | // let receipts = self.get_receipts_by_transactions(&txs)?; 34 | // let receipt_root = block.receipts_root.into(); 35 | 36 | self.transactions.insert(tx_root, txs); 37 | // self.receipts.insert(receipt_root, receipts); 38 | 39 | let header = crate::types::header_from_block(block)?; 40 | Ok(header) 41 | } 42 | 43 | /// Gets a block header by block number 44 | fn get_header_by_number(&mut self, n: u64) -> Result
{ 45 | let block = self.rt.block_on(self.provider.get_block_with_txs(n))?; 46 | let block = block.ok_or(eyre::eyre!("did not find the block"))?; 47 | 48 | let txs: Vec = block.transactions.clone().into_iter().map(|t| t.into()).collect(); 49 | let tx_root = block.transactions_root.into(); 50 | 51 | // let receipts = self.get_receipts_by_transactions(&txs)?; 52 | // let receipt_root = block.receipts_root.into(); 53 | 54 | self.transactions.insert(tx_root, txs); 55 | // self.receipts.insert(receipt_root, receipts); 56 | 57 | let header = crate::types::header_from_block(block)?; 58 | Ok(header) 59 | } 60 | 61 | /// Get receipts by the recipt root 62 | fn get_receipts_by_root(&self, root: Hash) -> Result> { 63 | self.receipts 64 | .get(&root) 65 | .ok_or(eyre::eyre!("missing receipts for given root in internal store")) 66 | .cloned() 67 | } 68 | 69 | /// Get transactions by the transaction root 70 | fn get_transactions_by_root(&self, root: Hash) -> Result> { 71 | self.transactions 72 | .get(&root) 73 | .ok_or(eyre::eyre!("missing transactions for given root in internal store")) 74 | .cloned() 75 | } 76 | } 77 | 78 | impl Client { 79 | /// Constructs a new client 80 | pub fn new(url: &str) -> Result { 81 | let provider = RPCProvider::::try_from(url)?; 82 | let rt = tokio::runtime::Builder::new_current_thread().enable_all().build()?; 83 | 84 | Ok(Client { 85 | rt, 86 | provider, 87 | receipts: HashMap::new(), 88 | transactions: HashMap::new(), 89 | }) 90 | } 91 | 92 | // /// Get transaction receipts for a list of transactions 93 | // fn get_receipts_by_transactions(&self, transactions: &[Transaction]) -> Result> { 94 | // let mut receipts = Vec::anew(); 95 | // for tx in transactions.iter() { 96 | // let receipt = self.get_transaction_receipt(tx.hash)?; 97 | // receipts.push(receipt) 98 | // } 99 | // Ok(receipts) 100 | // } 101 | 102 | // /// Gets a transaction receipt by transaction hash 103 | // fn_get_transaction_receipt(&self, transaction_hash: Hash) -> Result { 104 | // let transaction_hash: ethers_core::types::H256 = transaction_hash.into(); 105 | // let receipt = self.rt.block_on(self.provider.get_transaction_receipt(transaction_hash))?; 106 | // let receipt = receipt.ok_or(eyre::eyre!("did not find the receipt"))?; 107 | // Ok(receipt) 108 | // } 109 | } 110 | -------------------------------------------------------------------------------- /crates/client/src/types.rs: -------------------------------------------------------------------------------- 1 | use core::types::Header; 2 | use ethers_core::types::{Block, Transaction}; 3 | 4 | /// Constructs a header from a given block 5 | pub fn header_from_block(block: Block) -> eyre::Result
{ 6 | let author = block.author.ok_or_else(|| eyre::eyre!("block author is not set"))?; 7 | let number = block.number.ok_or_else(|| eyre::eyre!("block number is not set"))?; 8 | let bloom = block.logs_bloom.ok_or_else(|| eyre::eyre!("block logs bloom is not set"))?; 9 | let mix_hash = block 10 | .mix_hash 11 | .map(|h| reth_primitives::H256::from(h.as_fixed_bytes())) 12 | .ok_or_else(|| eyre::eyre!("block mix hash is not set"))?; 13 | let nonce = block.nonce.ok_or_else(|| eyre::eyre!("block nonce is not set"))?; 14 | let nonce = nonce.to_low_u64_be(); 15 | Ok(Header { 16 | parent_hash: reth_primitives::H256::from(block.parent_hash.as_fixed_bytes()), 17 | ommers_hash: reth_primitives::H256::from(block.uncles_hash.as_fixed_bytes()), 18 | state_root: reth_primitives::H256::from(block.state_root.as_fixed_bytes()), 19 | beneficiary: reth_primitives::H160::from(author.as_fixed_bytes()), 20 | transactions_root: reth_primitives::H256::from(block.transactions_root.as_fixed_bytes()), 21 | receipts_root: reth_primitives::H256::from(block.receipts_root.as_fixed_bytes()), 22 | number: number.as_u64(), 23 | logs_bloom: reth_primitives::Bloom::from(bloom.as_fixed_bytes()), 24 | gas_used: block.gas_used.as_u64(), 25 | gas_limit: block.gas_limit.as_u64(), 26 | extra_data: reth_primitives::Bytes::from(block.extra_data.to_vec()), 27 | timestamp: block.timestamp.as_u64(), 28 | difficulty: block.difficulty.into(), 29 | mix_hash, 30 | nonce, 31 | base_fee_per_gas: block.base_fee_per_gas.map(|b| b.as_u64()), 32 | withdrawals_root: None, 33 | }) 34 | } 35 | -------------------------------------------------------------------------------- /crates/core/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "core" 3 | version = "0.1.0" 4 | edition = "2021" 5 | 6 | [dependencies] 7 | 8 | ethers-core = "1.0.2" 9 | reth-primitives = { git = "https://github.com/paradigmxyz/reth", features = [] } 10 | hex-literal = "0.4.1" -------------------------------------------------------------------------------- /crates/core/src/chain_config.rs: -------------------------------------------------------------------------------- 1 | use crate::{address_literal, hash_literal, id::BlockID, types::*}; 2 | 3 | #[derive(Debug, Clone, Copy)] 4 | pub struct SystemConfig { 5 | pub batcher_address: Address, 6 | pub overhead: Hash, 7 | pub scalar: Hash, 8 | pub gas_limit: u64, 9 | } 10 | 11 | #[derive(Debug, Clone, Copy)] 12 | pub struct RollupConfig { 13 | pub l1_genesis: BlockID, 14 | pub l2_genesis: BlockID, 15 | pub l2_genesis_time: u64, 16 | pub system_config: SystemConfig, 17 | pub l2_block_time: u64, 18 | pub max_sequencer_drift: u64, 19 | pub seq_window_size: u64, 20 | pub channel_timeout: u64, 21 | pub l1_chain_id: u64, 22 | pub l2_chain_id: u64, 23 | pub batch_inbox_address: Address, 24 | pub deposit_contract_address: Address, 25 | pub l1_system_config_addres: Address, 26 | pub regolith_time: Option, 27 | } 28 | 29 | pub const GOERLI_CONFIG: RollupConfig = RollupConfig { 30 | l1_genesis: BlockID { 31 | hash: hash_literal!("6ffc1bf3754c01f6bb9fe057c1578b87a8571ce2e9be5ca14bace6eccfd336c7"), 32 | number: 8300214, 33 | }, 34 | l2_genesis: BlockID { 35 | hash: hash_literal!("0f783549ea4313b784eadd9b8e8a69913b368b7366363ea814d7707ac505175f"), 36 | number: 4061224, 37 | }, 38 | l2_genesis_time: 1673550516, 39 | system_config: SystemConfig { 40 | batcher_address: address_literal!("7431310e026B69BFC676C0013E12A1A11411EEc9"), 41 | overhead: hash_literal!("0000000000000000000000000000000000000000000000000000000000000834"), 42 | scalar: hash_literal!("00000000000000000000000000000000000000000000000000000000000f4240"), 43 | gas_limit: 25_000_000, 44 | }, 45 | l2_block_time: 2, 46 | max_sequencer_drift: 600, 47 | seq_window_size: 3600, 48 | channel_timeout: 300, 49 | l1_chain_id: 5, 50 | l2_chain_id: 420, 51 | batch_inbox_address: address_literal!("ff00000000000000000000000000000000000420"), 52 | deposit_contract_address: address_literal!("5b47E1A08Ea6d985D6649300584e6722Ec4B1383"), 53 | l1_system_config_addres: address_literal!("Ae851f927Ee40dE99aaBb7461C00f9622ab91d60"), 54 | regolith_time: Some(1679079600), 55 | }; 56 | -------------------------------------------------------------------------------- /crates/core/src/id.rs: -------------------------------------------------------------------------------- 1 | use crate::types::*; 2 | 3 | #[derive(Debug, Clone, Copy, Default, Eq, PartialEq, Hash)] 4 | pub struct BlockID { 5 | pub hash: Hash, 6 | pub number: u64, 7 | } 8 | 9 | impl Ord for BlockID { 10 | fn cmp(&self, other: &Self) -> std::cmp::Ordering { 11 | self.number.cmp(&other.number) 12 | } 13 | } 14 | 15 | impl PartialOrd for BlockID { 16 | fn partial_cmp(&self, other: &Self) -> Option { 17 | Some(self.number.cmp(&other.number)) 18 | } 19 | } 20 | 21 | #[derive(Debug, Clone, Copy, Default)] 22 | pub struct L1BlockRef { 23 | pub hash: Hash, 24 | pub number: u64, 25 | pub parent_hash: Hash, 26 | pub time: u64, 27 | } 28 | 29 | #[derive(Debug, Clone, Copy, Default)] 30 | pub struct L2BlockRef { 31 | pub hash: Hash, 32 | pub number: u64, 33 | pub parent_hash: Hash, 34 | pub time: u64, 35 | pub l1_origin: BlockID, 36 | pub sequence_number: u64, 37 | } 38 | 39 | impl From
for BlockID { 40 | fn from(h: Header) -> Self { 41 | Self { 42 | hash: h.hash_slow().into(), 43 | number: h.number, 44 | } 45 | } 46 | } 47 | 48 | impl From for BlockID { 49 | fn from(h: L1BlockRef) -> Self { 50 | Self { 51 | hash: h.hash, 52 | number: h.number, 53 | } 54 | } 55 | } 56 | 57 | impl From
for L1BlockRef { 58 | fn from(h: Header) -> Self { 59 | Self { 60 | hash: h.hash_slow().into(), 61 | number: h.number, 62 | parent_hash: h.parent_hash.into(), 63 | time: h.timestamp, 64 | } 65 | } 66 | } 67 | -------------------------------------------------------------------------------- /crates/core/src/lib.rs: -------------------------------------------------------------------------------- 1 | pub mod chain_config; 2 | pub mod id; 3 | pub mod types; 4 | 5 | use ethers_core::types::Transaction; 6 | 7 | #[derive(Debug)] 8 | pub struct L2BlockCandidate { 9 | pub number: u64, 10 | pub timestamp: u64, 11 | pub transactions: Vec, 12 | // TODO: tx root 13 | } 14 | 15 | pub mod prelude { 16 | pub use crate::chain_config::RollupConfig; 17 | pub use crate::id::BlockID; 18 | pub use crate::id::L1BlockRef; 19 | pub use crate::id::L2BlockRef; 20 | pub use crate::types::Address; 21 | pub use crate::types::ChannelID; 22 | pub use crate::types::Hash; 23 | pub use crate::types::Receipt; 24 | pub use crate::types::Transaction; 25 | pub use crate::L2BlockCandidate; // TODO: remove 26 | } 27 | -------------------------------------------------------------------------------- /crates/core/src/types.rs: -------------------------------------------------------------------------------- 1 | #[derive(Debug, Clone, Copy, Default, Eq, PartialEq, Hash)] 2 | pub struct ChannelID([u8; 16]); 3 | 4 | impl ChannelID { 5 | pub fn new(id: [u8; 16]) -> Self { 6 | Self(id) 7 | } 8 | } 9 | 10 | impl TryFrom<&[u8]> for ChannelID { 11 | type Error = std::array::TryFromSliceError; 12 | fn try_from(value: &[u8]) -> Result { 13 | Ok(Self::new(value.try_into()?)) 14 | } 15 | } 16 | 17 | #[derive(Debug, Clone, Copy, Default, Eq, PartialEq, Hash)] 18 | pub struct Address([u8; 20]); 19 | 20 | impl Address { 21 | pub const fn new(v: [u8; 20]) -> Self { 22 | Self(v) 23 | } 24 | } 25 | 26 | impl From for Address { 27 | fn from(value: reth_primitives::H160) -> Self { 28 | Self(value.to_fixed_bytes()) 29 | } 30 | } 31 | 32 | impl From for Address { 33 | fn from(value: ethers_core::types::H160) -> Self { 34 | Self(value.to_fixed_bytes()) 35 | } 36 | } 37 | 38 | #[macro_export] 39 | macro_rules! address_literal { 40 | ($s:literal) => { 41 | Address::new(hex_literal::hex!($s)) 42 | }; 43 | } 44 | 45 | #[derive(Debug, Clone, Copy, Default, Eq, PartialEq, Hash)] 46 | pub struct Hash([u8; 32]); 47 | 48 | impl Hash { 49 | pub const fn new(v: [u8; 32]) -> Self { 50 | Self(v) 51 | } 52 | pub fn to_vec(self) -> Vec { 53 | Vec::from(self.0) 54 | } 55 | } 56 | 57 | impl From for Hash { 58 | fn from(value: reth_primitives::H256) -> Self { 59 | Self(value.to_fixed_bytes()) 60 | } 61 | } 62 | 63 | impl From for Hash { 64 | fn from(value: ethers_core::types::H256) -> Self { 65 | Self(value.to_fixed_bytes()) 66 | } 67 | } 68 | 69 | impl From for ethers_core::types::H256 { 70 | fn from(val: Hash) -> Self { 71 | ethers_core::types::H256::from(val.0) 72 | } 73 | } 74 | 75 | #[macro_export] 76 | macro_rules! hash_literal { 77 | ($s:literal) => { 78 | Hash::new(hex_literal::hex!($s)) 79 | }; 80 | } 81 | 82 | pub type Header = reth_primitives::Header; 83 | pub type Receipt = ethers_core::types::TransactionReceipt; 84 | 85 | #[derive(Debug, Clone)] 86 | pub struct Transaction { 87 | pub hash: Hash, 88 | pub to: Option
, 89 | pub from: Address, 90 | pub input: Vec, 91 | } 92 | 93 | impl From for Transaction { 94 | fn from(value: ethers_core::types::Transaction) -> Self { 95 | Transaction { 96 | hash: value.hash.into(), 97 | to: value.to.map(Address::from), 98 | from: value.from.into(), 99 | input: value.input.to_vec(), 100 | } 101 | } 102 | } 103 | 104 | pub fn keccak(data: impl AsRef<[u8]>) -> Hash { 105 | reth_primitives::keccak256(data).into() 106 | } 107 | -------------------------------------------------------------------------------- /crates/derivation/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "derivation" 3 | version = "0.1.0" 4 | edition = "2021" 5 | 6 | [dependencies] 7 | core = {path = "../core"} 8 | client = {path = "../client"} 9 | ethers-core = "1.0.2" 10 | eyre = "0.6.8" 11 | flate2 = "1.0.25" 12 | hex-literal = "0.4.1" 13 | nom = "7.1.3" 14 | -------------------------------------------------------------------------------- /crates/derivation/src/batch.rs: -------------------------------------------------------------------------------- 1 | use ethers_core::{ 2 | types::H256, // Use ethers core H256 b/c it implements decodable 3 | utils::rlp::{decode, Decodable, DecoderError, Rlp}, 4 | }; 5 | use eyre::Result; 6 | 7 | #[derive(Debug)] 8 | pub struct BatchV1 { 9 | pub parent_hash: H256, 10 | pub epoch_num: u64, 11 | pub epoch_hash: H256, 12 | pub timestamp: u64, 13 | pub transactions: Vec>, 14 | } 15 | 16 | #[derive(Debug)] 17 | pub struct Batch { 18 | pub batch: BatchV1, 19 | // TODO: Metadata here 20 | } 21 | 22 | impl Decodable for Batch { 23 | fn decode(rlp: &Rlp) -> Result { 24 | // TODO: Make this more robust 25 | let first = rlp.as_raw()[0]; 26 | if first != 0 { 27 | return Err(DecoderError::Custom("invalid version byte")); 28 | } 29 | let batch: BatchV1 = decode(&rlp.as_raw()[1..])?; 30 | Ok(Batch { batch }) 31 | } 32 | } 33 | 34 | impl Decodable for BatchV1 { 35 | fn decode(rlp: &Rlp) -> Result { 36 | let parent_hash: H256 = rlp.val_at(0)?; 37 | let epoch_num: u64 = rlp.val_at(1)?; 38 | let epoch_hash: H256 = rlp.val_at(2)?; 39 | let timestamp: u64 = rlp.val_at(3)?; 40 | let transactions: Vec> = rlp.list_at(4)?; 41 | 42 | Ok(BatchV1 { 43 | parent_hash, 44 | epoch_num, 45 | epoch_hash, 46 | timestamp, 47 | transactions, 48 | }) 49 | } 50 | } 51 | 52 | pub fn parse_batches(data: Vec) -> Vec { 53 | // TODO: Truncate data to 10KB (post compression) 54 | // The data we received is an RLP encoded string. Before decoding the batch itself, 55 | // we need to decode the string to get the actual batch data. 56 | let mut decoded_batches: Vec> = Vec::new(); 57 | let mut buf: &[u8] = &data; 58 | 59 | loop { 60 | let rlp = Rlp::new(buf); 61 | let size = rlp.size(); 62 | 63 | match rlp.as_val() { 64 | Ok(b) => { 65 | decoded_batches.push(b); 66 | buf = &buf[size..]; 67 | } 68 | Err(_) => break, 69 | } 70 | } 71 | decoded_batches.iter().filter_map(|b| decode(b).ok()).collect() 72 | } 73 | -------------------------------------------------------------------------------- /crates/derivation/src/batch_queue.rs: -------------------------------------------------------------------------------- 1 | use ethers_core::{types::Transaction, utils::rlp::decode}; 2 | use std::collections::{HashMap, VecDeque}; 3 | 4 | use super::batch::Batch; 5 | use core::prelude::*; 6 | 7 | #[derive(Debug)] 8 | pub struct BatchQueue { 9 | l1_blocks: VecDeque, 10 | // Map batch timestamp to batches in order that they were received 11 | batches: HashMap>, 12 | 13 | l2_block_time: u64, 14 | // seq_window_size: u64, 15 | // max_sequencer_drift: u64, 16 | } 17 | 18 | impl BatchQueue { 19 | pub fn new(cfg: RollupConfig) -> Self { 20 | BatchQueue { 21 | l1_blocks: VecDeque::default(), 22 | batches: HashMap::default(), 23 | l2_block_time: cfg.l2_block_time, 24 | // seq_window_size: cfg.seq_window_size, 25 | // max_sequencer_drift: cfg.max_sequencer_drift, 26 | } 27 | } 28 | pub fn load_batches(&mut self, batches: impl Iterator, l1_origin: L1BlockRef) { 29 | self.l1_blocks.push_back(l1_origin); 30 | for b in batches { 31 | self.batches.entry(b.batch.timestamp).or_default().push_back(b); 32 | } 33 | } 34 | 35 | pub fn get_block_candidate(&mut self, l2_head: L2BlockRef) -> Option { 36 | let next_timestamp = l2_head.time + self.l2_block_time; 37 | if let Some(candidates) = self.batches.get(&next_timestamp) { 38 | #[allow(clippy::never_loop)] 39 | for b in candidates { 40 | // TODO: Do this step earlier 41 | let txns = b.batch.transactions.iter().map(|t| decode::(t).unwrap()).collect(); 42 | self.batches.remove(&next_timestamp); 43 | // TODO: deposits, seq number, transactions from batches 44 | return Some(L2BlockCandidate { 45 | number: l2_head.number + 1, 46 | timestamp: next_timestamp, 47 | transactions: txns, 48 | }); 49 | } 50 | } 51 | 52 | None 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /crates/derivation/src/channel.rs: -------------------------------------------------------------------------------- 1 | use crate::frame::Frame; 2 | use core::prelude::*; 3 | use std::cmp::max; 4 | use std::collections::HashMap; 5 | 6 | #[derive(Debug)] 7 | pub struct Channel { 8 | frames: HashMap, 9 | id: ChannelID, 10 | size: u64, 11 | highest_frame: u16, 12 | end_frame: Option, 13 | lowest_l1_block: BlockID, 14 | highest_l1_block: BlockID, 15 | } 16 | 17 | impl Channel { 18 | pub fn new(id: ChannelID, l1_block: BlockID) -> Self { 19 | Self { 20 | frames: HashMap::new(), 21 | id, 22 | size: 0, 23 | highest_frame: 0, 24 | end_frame: None, 25 | lowest_l1_block: l1_block, 26 | highest_l1_block: l1_block, 27 | } 28 | } 29 | 30 | pub fn add_frame(&mut self, frame: Frame, l1_block: BlockID) { 31 | // These checks are specififed & cannot be changed without a HF 32 | if self.id != frame.id 33 | || self.closed() && frame.is_last 34 | || self.frames.contains_key(&frame.number) 35 | || self.closed() && frame.number > self.highest_frame 36 | { 37 | return; 38 | } 39 | // Will always succeed at this point 40 | if frame.is_last { 41 | self.end_frame = Some(frame.number); 42 | // Prune higher frames if this is the closing frame 43 | if frame.number > self.highest_frame { 44 | self.frames.drain_filter(|k, _| *k > frame.number).for_each(|(_, v)| { 45 | self.size -= v.size(); 46 | }); 47 | self.highest_frame = frame.number 48 | } 49 | } 50 | 51 | self.highest_frame = max(self.highest_frame, frame.number); 52 | self.highest_l1_block = max(self.highest_l1_block, l1_block); 53 | self.size += frame.size(); 54 | self.frames.insert(frame.number, frame); 55 | } 56 | 57 | pub fn is_ready(&self) -> bool { 58 | let last = match self.end_frame { 59 | Some(n) => n, 60 | None => return false, 61 | }; 62 | (0..=last).map(|i| self.frames.contains_key(&i)).all(|a| a) 63 | } 64 | 65 | /// data returns the channel data. It will panic if `is_ready` is false. 66 | /// This fully consumes the channel. 67 | pub fn data(mut self) -> impl Iterator { 68 | (0..=self.end_frame.unwrap()).flat_map(move |i| self.frames.remove(&i).unwrap().data) 69 | } 70 | 71 | fn closed(&self) -> bool { 72 | self.end_frame.is_some() 73 | } 74 | 75 | pub fn is_timed_out(&self, timeout: u64) -> bool { 76 | // TODO: > or >= here? 77 | self.highest_l1_block.number - self.lowest_l1_block.number > timeout 78 | } 79 | 80 | pub fn size(&self) -> u64 { 81 | self.size 82 | } 83 | } 84 | -------------------------------------------------------------------------------- /crates/derivation/src/channel_bank.rs: -------------------------------------------------------------------------------- 1 | use crate::channel::Channel; 2 | use crate::frame::Frame; 3 | use core::prelude::*; 4 | 5 | use core::types::ChannelID; 6 | use std::collections::{HashMap, VecDeque}; 7 | 8 | const MAX_CHANNEL_BANK_SIZE: u64 = 100_000_000; 9 | 10 | #[derive(Debug)] 11 | /// ChannelBank stores all pending transactions 12 | pub struct ChannelBank { 13 | channels_map: HashMap, 14 | channels_by_creation: VecDeque, 15 | channel_timeout: u64, 16 | } 17 | 18 | impl ChannelBank { 19 | pub fn new(cfg: RollupConfig) -> Self { 20 | Self { 21 | channels_map: HashMap::default(), 22 | channels_by_creation: VecDeque::default(), 23 | channel_timeout: cfg.channel_timeout, 24 | } 25 | } 26 | /// load_frame adds a frame to the channel bank. 27 | /// The caller must maintain the invariant that get_ready_channel is called until there 28 | /// are no more ready channels before adding more frames. 29 | /// This function will panic (via assert) if this invariant is not maintained. 30 | pub fn load_frame(&mut self, frame: Frame, l1_block: BlockID) { 31 | assert!( 32 | !self.peek().is_some_and(|c| c.is_ready()), 33 | "Specs Violation: must pull data before loading more in the channel bank" 34 | ); 35 | 36 | self.channels_map 37 | .entry(frame.id) 38 | .or_insert_with(|| { 39 | self.channels_by_creation.push_back(frame.id); 40 | Channel::new(frame.id, l1_block) 41 | }) 42 | .add_frame(frame, l1_block); 43 | self.prune(); 44 | } 45 | 46 | /// get_ready_channel returns the first ready channel. 47 | pub fn get_ready_channel(&mut self) -> Option { 48 | // TODO: this should be a while loop. See if there is a test or fuzzing to catch this. 49 | if self.peek()?.is_ready() { 50 | let ch = self.remove().unwrap(); 51 | if !ch.is_timed_out(self.channel_timeout) { 52 | return Some(ch); 53 | } 54 | } 55 | None 56 | } 57 | 58 | fn peek(&self) -> Option<&Channel> { 59 | self.channels_map.get(self.channels_by_creation.front()?) 60 | } 61 | 62 | fn remove(&mut self) -> Option { 63 | self.channels_map.remove(&self.channels_by_creation.pop_front()?) 64 | } 65 | 66 | fn prune(&mut self) { 67 | while self.total_size() > MAX_CHANNEL_BANK_SIZE { 68 | self.remove().expect("Should have removed a channel"); 69 | } 70 | } 71 | 72 | fn total_size(&self) -> u64 { 73 | self.channels_map.values().map(|c| c.size()).sum() 74 | } 75 | } 76 | 77 | /// ChannelBankAdapter providers an iterator for outputting ready channels. 78 | pub struct ChannelBankAdapter<'a, I> { 79 | inner: I, 80 | cb: &'a mut ChannelBank, 81 | l1_block: BlockID, 82 | } 83 | 84 | impl<'a, I: Iterator> Iterator for ChannelBankAdapter<'a, I> { 85 | type Item = Channel; 86 | 87 | fn next(&mut self) -> Option { 88 | loop { 89 | if let Some(ch) = self.cb.get_ready_channel() { 90 | return Some(ch); 91 | } 92 | self.cb.load_frame(self.inner.next()?, self.l1_block); 93 | } 94 | } 95 | } 96 | 97 | impl<'a, I> ChannelBankAdapter<'a, I> { 98 | pub fn new(iter: I, cb: &'a mut ChannelBank, l1_block: BlockID) -> Self { 99 | Self { inner: iter, cb, l1_block } 100 | } 101 | } 102 | 103 | /// ChannelBankAdapterIteratorExt allows ChannelBankAdapter to be chained onto an iterator of frames. 104 | pub trait ChannelBankAdapterIteratorExt<'a, I>: Iterator + Sized { 105 | fn reassemble_channels(self, cb: &'a mut ChannelBank, l1_block: BlockID) -> ChannelBankAdapter<'a, Self> { 106 | ChannelBankAdapter::new(self, cb, l1_block) 107 | } 108 | } 109 | 110 | impl<'a, I: Iterator> ChannelBankAdapterIteratorExt<'a, I> for I {} 111 | -------------------------------------------------------------------------------- /crates/derivation/src/data.rs.bak: -------------------------------------------------------------------------------- 1 | use ethers_core::{ 2 | types::{H128, H256}, 3 | utils::rlp::{decode, Decodable, DecoderError, Rlp}, 4 | }; 5 | 6 | // // ConfigUpdateEventABI = "ConfigUpdate(uint256,uint8,bytes)" 7 | // // ConfigUpdateEventABIHash = crypto.Keccak256Hash([]byte(ConfigUpdateEventABI)) 8 | // // ConfigUpdateEventVersion0 = common.Hash{} 9 | 10 | // struct SystemConfig { 11 | // batcher_addr: Address, 12 | // overhead: H256, 13 | // scalar: H256, 14 | // gas_limit: u64, 15 | // } 16 | 17 | // fn system_config_from_receipts(receipts: Vec, prev: SystemConfig) -> SystemConfig { 18 | // let l1_system_config_addr = Address::from_str("").unwrap(); 19 | // let config_update_abi = H256::from_str("1d2b0bda21d56b8bd12d4f94ebacffdfb35f5e226f84b461103bb8beab6353be").unwrap(); 20 | // let _logs: Vec<&Log> = receipts 21 | // .iter() 22 | // .filter(|r| r.status == Some(1.into())) 23 | // .flat_map(|r| r.logs.iter()) 24 | // .filter(|l| l.address == l1_system_config_addr) 25 | // .filter(|l| l.topics.len() > 1 && l.topics[0] == config_update_abi) 26 | // .collect(); 27 | // prev 28 | // } 29 | -------------------------------------------------------------------------------- /crates/derivation/src/derivation.rs: -------------------------------------------------------------------------------- 1 | use crate::batch::parse_batches; 2 | use crate::batch_queue::*; 3 | use crate::channel_bank::*; 4 | use crate::frame::parse_frames; 5 | use crate::read_adapter::ReadAdpater; 6 | 7 | use core::prelude::*; 8 | 9 | use flate2::read::ZlibDecoder; 10 | use std::io::Read; 11 | 12 | #[derive(Debug)] 13 | pub struct Derivation { 14 | channel_bank: ChannelBank, 15 | batch_queue: BatchQueue, 16 | config: RollupConfig, 17 | } 18 | 19 | impl Derivation { 20 | pub fn new(cfg: RollupConfig) -> Self { 21 | Self { 22 | channel_bank: ChannelBank::new(cfg), 23 | batch_queue: BatchQueue::new(cfg), 24 | config: cfg, 25 | } 26 | } 27 | pub fn load_l1_data(&mut self, l1_block: L1BlockRef, transactions: Vec, _receipts: Vec) { 28 | // TODO: update system config from receipts 29 | 30 | let sys_config = self.config.system_config; 31 | 32 | let batches = transactions 33 | .into_iter() 34 | .filter(|tx| tx.to == Some(self.config.batch_inbox_address)) 35 | .filter(|tx| tx.from == sys_config.batcher_address) 36 | .flat_map(|tx| parse_frames(&tx.input)) 37 | .reassemble_channels(&mut self.channel_bank, l1_block.into()) 38 | .map(|c| c.data()) 39 | .map(ReadAdpater::new) 40 | .map(decompress) 41 | .flat_map(parse_batches); 42 | self.batch_queue.load_batches(batches, l1_block); 43 | } 44 | 45 | pub fn next_l2_attributes(&mut self, l2_head: L2BlockRef) -> Option { 46 | self.batch_queue.get_block_candidate(l2_head) 47 | } 48 | 49 | pub fn run(&mut self, start_l1_block: u64, end_l1_block: u64, l1_provider: &mut impl client::Provider) { 50 | for i in start_l1_block..end_l1_block { 51 | let header = l1_provider.get_header_by_number(i).unwrap(); 52 | let transactions = l1_provider.get_transactions_by_root(header.transactions_root.into()).unwrap(); 53 | self.load_l1_data(header.into(), transactions, Vec::default()); 54 | let mut l2_head = L2BlockRef { 55 | time: self.config.l2_genesis_time, 56 | ..Default::default() 57 | }; 58 | while let Some(candidate) = self.next_l2_attributes(l2_head) { 59 | println!("{:?}", candidate); 60 | l2_head.time = candidate.timestamp; 61 | } 62 | } 63 | } 64 | } 65 | 66 | fn decompress(r: impl Read) -> Vec { 67 | let mut decomp = ZlibDecoder::new(r); 68 | let mut buffer = Vec::default(); 69 | 70 | // TODO: Handle this error 71 | // Decompress the passed data with zlib 72 | decomp.read_to_end(&mut buffer).unwrap(); 73 | buffer 74 | } 75 | -------------------------------------------------------------------------------- /crates/derivation/src/frame.rs: -------------------------------------------------------------------------------- 1 | use core::types::ChannelID; 2 | use nom::{ 3 | branch::alt, 4 | bytes::complete::{tag, take}, 5 | combinator::{map, map_res}, 6 | multi::many0, 7 | number::complete::{be_u16, be_u32}, 8 | IResult, 9 | }; 10 | 11 | #[derive(Debug)] 12 | pub struct Frame { 13 | pub id: ChannelID, 14 | pub number: u16, 15 | pub data: Vec, 16 | pub is_last: bool, 17 | } 18 | 19 | impl Frame { 20 | pub fn size(&self) -> u64 { 21 | self.data.len() as u64 + 200 22 | } 23 | } 24 | 25 | pub fn parse_frames(tx_data: &[u8]) -> Vec { 26 | parse_frames_nom(tx_data).map(|(_, frames)| frames).unwrap_or_default() 27 | } 28 | 29 | fn parse_frames_nom(i: &[u8]) -> IResult<&[u8], Vec> { 30 | let (i, _) = tag([0])(i)?; 31 | let (i, frames) = many0(parse_frame)(i)?; 32 | Ok((i, frames)) 33 | } 34 | 35 | fn parse_frame(i: &[u8]) -> IResult<&[u8], Frame> { 36 | let (i, id) = map_res(take(4usize), ChannelID::try_from)(i)?; 37 | let (i, number) = be_u16(i)?; 38 | let (i, data_len) = be_u32(i)?; 39 | // TODO: Validate data_len against MAX_DATA_LEN 40 | let (i, data) = take(data_len as usize)(i)?; 41 | let (i, is_last) = parse_bool(i)?; 42 | Ok(( 43 | i, 44 | Frame { 45 | id, 46 | number, 47 | data: data.to_vec(), 48 | is_last, 49 | }, 50 | )) 51 | } 52 | 53 | fn parse_bool(i: &[u8]) -> IResult<&[u8], bool> { 54 | alt((map(tag([0]), |_| false), map(tag([1]), |_| true)))(i) 55 | } 56 | 57 | #[cfg(test)] 58 | mod tests { 59 | use super::*; 60 | 61 | #[test] 62 | fn test_parse_bool_true() { 63 | assert_eq!(parse_bool(&[1]), Ok((&[][..], true))); 64 | } 65 | 66 | #[test] 67 | fn test_parse_bool_false() { 68 | assert_eq!(parse_bool(&[0]), Ok((&[][..], false))); 69 | } 70 | 71 | #[test] 72 | fn test_parse_bool_invalid() { 73 | assert!(parse_bool(&[]).is_err()); 74 | assert!(parse_bool(&[2]).is_err()); 75 | } 76 | } 77 | -------------------------------------------------------------------------------- /crates/derivation/src/lib.rs: -------------------------------------------------------------------------------- 1 | #![feature(hash_drain_filter)] 2 | #![feature(let_chains)] 3 | 4 | pub mod derivation; 5 | 6 | mod batch; 7 | mod batch_queue; 8 | mod channel; 9 | mod channel_bank; 10 | mod frame; 11 | mod read_adapter; 12 | -------------------------------------------------------------------------------- /crates/derivation/src/read_adapter.rs: -------------------------------------------------------------------------------- 1 | /// ReadAdapter provides a Read method for Iterator objects. 2 | pub struct ReadAdpater { 3 | iter: I, 4 | } 5 | 6 | // TODO: Should I be Iterator>? 7 | impl ReadAdpater { 8 | pub fn new(iter: I) -> Self { 9 | Self { iter } 10 | } 11 | } 12 | 13 | impl> std::io::Read for ReadAdpater { 14 | fn read(&mut self, buf: &mut [u8]) -> std::io::Result { 15 | let max = buf.len(); 16 | let mut i: usize = 0; 17 | while i < max && let Some(b) = self.iter.next() { 18 | buf[i] = b; 19 | i +=1; 20 | } 21 | Ok(i) 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /crates/mpt/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "mpt" 3 | version = "0.1.0" 4 | edition = "2021" 5 | 6 | # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html 7 | 8 | [dependencies] 9 | core = {path = "../core"} 10 | reth-rlp = { git = "https://github.com/paradigmxyz/reth" } 11 | reth-primitives = { git = "https://github.com/paradigmxyz/reth" } 12 | hex = "0.4.3" 13 | hex-literal = "0.4.1" 14 | -------------------------------------------------------------------------------- /crates/mpt/fuzz/.gitignore: -------------------------------------------------------------------------------- 1 | target 2 | corpus 3 | artifacts 4 | coverage 5 | -------------------------------------------------------------------------------- /crates/mpt/fuzz/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 = "ahash" 7 | version = "0.8.3" 8 | source = "registry+https://github.com/rust-lang/crates.io-index" 9 | checksum = "2c99f64d1e06488f620f932677e24bc6e2897582980441ae90a671415bd7ec2f" 10 | dependencies = [ 11 | "cfg-if", 12 | "once_cell", 13 | "version_check", 14 | ] 15 | 16 | [[package]] 17 | name = "aho-corasick" 18 | version = "0.7.20" 19 | source = "registry+https://github.com/rust-lang/crates.io-index" 20 | checksum = "cc936419f96fa211c1b9166887b38e5e40b19958e5b895be7c1f93adec7071ac" 21 | dependencies = [ 22 | "memchr", 23 | ] 24 | 25 | [[package]] 26 | name = "android_system_properties" 27 | version = "0.1.5" 28 | source = "registry+https://github.com/rust-lang/crates.io-index" 29 | checksum = "819e7219dbd41043ac279b19830f2efc897156490d7fd6ea916720117ee66311" 30 | dependencies = [ 31 | "libc", 32 | ] 33 | 34 | [[package]] 35 | name = "anyhow" 36 | version = "1.0.70" 37 | source = "registry+https://github.com/rust-lang/crates.io-index" 38 | checksum = "7de8ce5e0f9f8d88245311066a578d72b7af3e7088f32783804676302df237e4" 39 | 40 | [[package]] 41 | name = "arbitrary" 42 | version = "1.3.0" 43 | source = "registry+https://github.com/rust-lang/crates.io-index" 44 | checksum = "e2d098ff73c1ca148721f37baad5ea6a465a13f9573aba8641fbbbae8164a54e" 45 | 46 | [[package]] 47 | name = "arrayvec" 48 | version = "0.7.2" 49 | source = "registry+https://github.com/rust-lang/crates.io-index" 50 | checksum = "8da52d66c7071e2e3fa2a1e5c6d088fec47b593032b254f5e980de8ea54454d6" 51 | 52 | [[package]] 53 | name = "auto_impl" 54 | version = "1.0.1" 55 | source = "registry+https://github.com/rust-lang/crates.io-index" 56 | checksum = "8a8c1df849285fbacd587de7818cc7d13be6cd2cbcd47a04fb1801b0e2706e33" 57 | dependencies = [ 58 | "proc-macro-error", 59 | "proc-macro2", 60 | "quote", 61 | "syn 1.0.109", 62 | ] 63 | 64 | [[package]] 65 | name = "autocfg" 66 | version = "1.1.0" 67 | source = "registry+https://github.com/rust-lang/crates.io-index" 68 | checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" 69 | 70 | [[package]] 71 | name = "base16ct" 72 | version = "0.1.1" 73 | source = "registry+https://github.com/rust-lang/crates.io-index" 74 | checksum = "349a06037c7bf932dd7e7d1f653678b2038b9ad46a74102f1fc7bd7872678cce" 75 | 76 | [[package]] 77 | name = "base16ct" 78 | version = "0.2.0" 79 | source = "registry+https://github.com/rust-lang/crates.io-index" 80 | checksum = "4c7f02d4ea65f2c1853089ffd8d2787bdbc63de2f0d29dedbcf8ccdfa0ccd4cf" 81 | 82 | [[package]] 83 | name = "base64" 84 | version = "0.13.1" 85 | source = "registry+https://github.com/rust-lang/crates.io-index" 86 | checksum = "9e1b586273c5702936fe7b7d6896644d8be71e6314cfe09d3167c95f712589e8" 87 | 88 | [[package]] 89 | name = "base64ct" 90 | version = "1.6.0" 91 | source = "registry+https://github.com/rust-lang/crates.io-index" 92 | checksum = "8c3c1a368f70d6cf7302d78f8f7093da241fb8e8807c05cc9e51a125895a6d5b" 93 | 94 | [[package]] 95 | name = "bitflags" 96 | version = "1.3.2" 97 | source = "registry+https://github.com/rust-lang/crates.io-index" 98 | checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" 99 | 100 | [[package]] 101 | name = "bitvec" 102 | version = "1.0.1" 103 | source = "registry+https://github.com/rust-lang/crates.io-index" 104 | checksum = "1bc2832c24239b0141d5674bb9174f9d68a8b5b3f2753311927c172ca46f7e9c" 105 | dependencies = [ 106 | "funty", 107 | "radium", 108 | "serde", 109 | "tap", 110 | "wyz", 111 | ] 112 | 113 | [[package]] 114 | name = "block-buffer" 115 | version = "0.10.4" 116 | source = "registry+https://github.com/rust-lang/crates.io-index" 117 | checksum = "3078c7629b62d3f0439517fa394996acacc5cbc91c5a20d8c658e77abd503a71" 118 | dependencies = [ 119 | "generic-array", 120 | ] 121 | 122 | [[package]] 123 | name = "bumpalo" 124 | version = "3.12.0" 125 | source = "registry+https://github.com/rust-lang/crates.io-index" 126 | checksum = "0d261e256854913907f67ed06efbc3338dfe6179796deefc1ff763fc1aee5535" 127 | 128 | [[package]] 129 | name = "byte-slice-cast" 130 | version = "1.2.2" 131 | source = "registry+https://github.com/rust-lang/crates.io-index" 132 | checksum = "c3ac9f8b63eca6fd385229b3675f6cc0dc5c8a5c8a54a59d4f52ffd670d87b0c" 133 | 134 | [[package]] 135 | name = "byteorder" 136 | version = "1.4.3" 137 | source = "registry+https://github.com/rust-lang/crates.io-index" 138 | checksum = "14c189c53d098945499cdfa7ecc63567cf3886b3332b312a5b4585d8d3a6a610" 139 | 140 | [[package]] 141 | name = "bytes" 142 | version = "1.4.0" 143 | source = "registry+https://github.com/rust-lang/crates.io-index" 144 | checksum = "89b2fd2a0dcf38d7971e2194b6b6eebab45ae01067456a7fd93d5547a61b70be" 145 | dependencies = [ 146 | "serde", 147 | ] 148 | 149 | [[package]] 150 | name = "cc" 151 | version = "1.0.79" 152 | source = "registry+https://github.com/rust-lang/crates.io-index" 153 | checksum = "50d30906286121d95be3d479533b458f87493b30a4b5f79a607db8f5d11aa91f" 154 | dependencies = [ 155 | "jobserver", 156 | ] 157 | 158 | [[package]] 159 | name = "cfg-if" 160 | version = "1.0.0" 161 | source = "registry+https://github.com/rust-lang/crates.io-index" 162 | checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" 163 | 164 | [[package]] 165 | name = "chrono" 166 | version = "0.4.24" 167 | source = "registry+https://github.com/rust-lang/crates.io-index" 168 | checksum = "4e3c5919066adf22df73762e50cffcde3a758f2a848b113b586d1f86728b673b" 169 | dependencies = [ 170 | "iana-time-zone", 171 | "num-integer", 172 | "num-traits", 173 | "serde", 174 | "winapi", 175 | ] 176 | 177 | [[package]] 178 | name = "codecs-derive" 179 | version = "0.1.0" 180 | source = "git+https://github.com/paradigmxyz/reth#b44391776eca11a8de4039b8fb7b2c463acdb8bc" 181 | dependencies = [ 182 | "convert_case 0.6.0", 183 | "parity-scale-codec", 184 | "proc-macro2", 185 | "quote", 186 | "serde", 187 | "syn 2.0.6", 188 | ] 189 | 190 | [[package]] 191 | name = "codespan-reporting" 192 | version = "0.11.1" 193 | source = "registry+https://github.com/rust-lang/crates.io-index" 194 | checksum = "3538270d33cc669650c4b093848450d380def10c331d38c768e34cac80576e6e" 195 | dependencies = [ 196 | "termcolor", 197 | "unicode-width", 198 | ] 199 | 200 | [[package]] 201 | name = "const-oid" 202 | version = "0.9.2" 203 | source = "registry+https://github.com/rust-lang/crates.io-index" 204 | checksum = "520fbf3c07483f94e3e3ca9d0cfd913d7718ef2483d2cfd91c0d9e91474ab913" 205 | 206 | [[package]] 207 | name = "convert_case" 208 | version = "0.4.0" 209 | source = "registry+https://github.com/rust-lang/crates.io-index" 210 | checksum = "6245d59a3e82a7fc217c5828a6692dbc6dfb63a0c8c90495621f7b9d79704a0e" 211 | 212 | [[package]] 213 | name = "convert_case" 214 | version = "0.6.0" 215 | source = "registry+https://github.com/rust-lang/crates.io-index" 216 | checksum = "ec182b0ca2f35d8fc196cf3404988fd8b8c739a4d270ff118a398feb0cbec1ca" 217 | dependencies = [ 218 | "unicode-segmentation", 219 | ] 220 | 221 | [[package]] 222 | name = "core" 223 | version = "0.1.0" 224 | dependencies = [ 225 | "ethers-core 1.0.2", 226 | "reth-primitives", 227 | ] 228 | 229 | [[package]] 230 | name = "core-foundation-sys" 231 | version = "0.8.3" 232 | source = "registry+https://github.com/rust-lang/crates.io-index" 233 | checksum = "5827cebf4670468b8772dd191856768aedcb1b0278a04f989f7766351917b9dc" 234 | 235 | [[package]] 236 | name = "cpufeatures" 237 | version = "0.2.5" 238 | source = "registry+https://github.com/rust-lang/crates.io-index" 239 | checksum = "28d997bd5e24a5928dd43e46dc529867e207907fe0b239c3477d924f7f2ca320" 240 | dependencies = [ 241 | "libc", 242 | ] 243 | 244 | [[package]] 245 | name = "crc" 246 | version = "3.0.1" 247 | source = "registry+https://github.com/rust-lang/crates.io-index" 248 | checksum = "86ec7a15cbe22e59248fc7eadb1907dab5ba09372595da4d73dd805ed4417dfe" 249 | dependencies = [ 250 | "crc-catalog", 251 | ] 252 | 253 | [[package]] 254 | name = "crc-catalog" 255 | version = "2.2.0" 256 | source = "registry+https://github.com/rust-lang/crates.io-index" 257 | checksum = "9cace84e55f07e7301bae1c519df89cdad8cc3cd868413d3fdbdeca9ff3db484" 258 | 259 | [[package]] 260 | name = "crunchy" 261 | version = "0.2.2" 262 | source = "registry+https://github.com/rust-lang/crates.io-index" 263 | checksum = "7a81dae078cea95a014a339291cec439d2f232ebe854a9d672b796c6afafa9b7" 264 | 265 | [[package]] 266 | name = "crypto-bigint" 267 | version = "0.4.9" 268 | source = "registry+https://github.com/rust-lang/crates.io-index" 269 | checksum = "ef2b4b23cddf68b89b8f8069890e8c270d54e2d5fe1b143820234805e4cb17ef" 270 | dependencies = [ 271 | "generic-array", 272 | "rand_core", 273 | "subtle", 274 | "zeroize", 275 | ] 276 | 277 | [[package]] 278 | name = "crypto-bigint" 279 | version = "0.5.1" 280 | source = "registry+https://github.com/rust-lang/crates.io-index" 281 | checksum = "7c2538c4e68e52548bacb3e83ac549f903d44f011ac9d5abb5e132e67d0808f7" 282 | dependencies = [ 283 | "generic-array", 284 | "rand_core", 285 | "subtle", 286 | "zeroize", 287 | ] 288 | 289 | [[package]] 290 | name = "crypto-common" 291 | version = "0.1.6" 292 | source = "registry+https://github.com/rust-lang/crates.io-index" 293 | checksum = "1bfb12502f3fc46cca1bb51ac28df9d618d813cdc3d2f25b9fe775a34af26bb3" 294 | dependencies = [ 295 | "generic-array", 296 | "typenum", 297 | ] 298 | 299 | [[package]] 300 | name = "cxx" 301 | version = "1.0.93" 302 | source = "registry+https://github.com/rust-lang/crates.io-index" 303 | checksum = "a9c00419335c41018365ddf7e4d5f1c12ee3659ddcf3e01974650ba1de73d038" 304 | dependencies = [ 305 | "cc", 306 | "cxxbridge-flags", 307 | "cxxbridge-macro", 308 | "link-cplusplus", 309 | ] 310 | 311 | [[package]] 312 | name = "cxx-build" 313 | version = "1.0.93" 314 | source = "registry+https://github.com/rust-lang/crates.io-index" 315 | checksum = "fb8307ad413a98fff033c8545ecf133e3257747b3bae935e7602aab8aa92d4ca" 316 | dependencies = [ 317 | "cc", 318 | "codespan-reporting", 319 | "once_cell", 320 | "proc-macro2", 321 | "quote", 322 | "scratch", 323 | "syn 2.0.6", 324 | ] 325 | 326 | [[package]] 327 | name = "cxxbridge-flags" 328 | version = "1.0.93" 329 | source = "registry+https://github.com/rust-lang/crates.io-index" 330 | checksum = "edc52e2eb08915cb12596d29d55f0b5384f00d697a646dbd269b6ecb0fbd9d31" 331 | 332 | [[package]] 333 | name = "cxxbridge-macro" 334 | version = "1.0.93" 335 | source = "registry+https://github.com/rust-lang/crates.io-index" 336 | checksum = "631569015d0d8d54e6c241733f944042623ab6df7bc3be7466874b05fcdb1c5f" 337 | dependencies = [ 338 | "proc-macro2", 339 | "quote", 340 | "syn 2.0.6", 341 | ] 342 | 343 | [[package]] 344 | name = "darling" 345 | version = "0.14.4" 346 | source = "registry+https://github.com/rust-lang/crates.io-index" 347 | checksum = "7b750cb3417fd1b327431a470f388520309479ab0bf5e323505daf0290cd3850" 348 | dependencies = [ 349 | "darling_core", 350 | "darling_macro", 351 | ] 352 | 353 | [[package]] 354 | name = "darling_core" 355 | version = "0.14.4" 356 | source = "registry+https://github.com/rust-lang/crates.io-index" 357 | checksum = "109c1ca6e6b7f82cc233a97004ea8ed7ca123a9af07a8230878fcfda9b158bf0" 358 | dependencies = [ 359 | "fnv", 360 | "ident_case", 361 | "proc-macro2", 362 | "quote", 363 | "strsim", 364 | "syn 1.0.109", 365 | ] 366 | 367 | [[package]] 368 | name = "darling_macro" 369 | version = "0.14.4" 370 | source = "registry+https://github.com/rust-lang/crates.io-index" 371 | checksum = "a4aab4dbc9f7611d8b55048a3a16d2d010c2c8334e46304b40ac1cc14bf3b48e" 372 | dependencies = [ 373 | "darling_core", 374 | "quote", 375 | "syn 1.0.109", 376 | ] 377 | 378 | [[package]] 379 | name = "der" 380 | version = "0.6.1" 381 | source = "registry+https://github.com/rust-lang/crates.io-index" 382 | checksum = "f1a467a65c5e759bce6e65eaf91cc29f466cdc57cb65777bd646872a8a1fd4de" 383 | dependencies = [ 384 | "const-oid", 385 | "zeroize", 386 | ] 387 | 388 | [[package]] 389 | name = "der" 390 | version = "0.7.1" 391 | source = "registry+https://github.com/rust-lang/crates.io-index" 392 | checksum = "bc906908ea6458456e5eaa160a9c08543ec3d1e6f71e2235cedd660cb65f9df0" 393 | dependencies = [ 394 | "const-oid", 395 | "zeroize", 396 | ] 397 | 398 | [[package]] 399 | name = "derive_more" 400 | version = "0.99.17" 401 | source = "registry+https://github.com/rust-lang/crates.io-index" 402 | checksum = "4fb810d30a7c1953f91334de7244731fc3f3c10d7fe163338a35b9f640960321" 403 | dependencies = [ 404 | "convert_case 0.4.0", 405 | "proc-macro2", 406 | "quote", 407 | "rustc_version", 408 | "syn 1.0.109", 409 | ] 410 | 411 | [[package]] 412 | name = "digest" 413 | version = "0.10.6" 414 | source = "registry+https://github.com/rust-lang/crates.io-index" 415 | checksum = "8168378f4e5023e7218c89c891c0fd8ecdb5e5e4f18cb78f38cf245dd021e76f" 416 | dependencies = [ 417 | "block-buffer", 418 | "crypto-common", 419 | "subtle", 420 | ] 421 | 422 | [[package]] 423 | name = "ecdsa" 424 | version = "0.14.8" 425 | source = "registry+https://github.com/rust-lang/crates.io-index" 426 | checksum = "413301934810f597c1d19ca71c8710e99a3f1ba28a0d2ebc01551a2daeea3c5c" 427 | dependencies = [ 428 | "der 0.6.1", 429 | "elliptic-curve 0.12.3", 430 | "rfc6979 0.3.1", 431 | "signature 1.6.4", 432 | ] 433 | 434 | [[package]] 435 | name = "ecdsa" 436 | version = "0.16.1" 437 | source = "registry+https://github.com/rust-lang/crates.io-index" 438 | checksum = "d1b0a1222f8072619e8a6b667a854020a03d363738303203c09468b3424a420a" 439 | dependencies = [ 440 | "der 0.7.1", 441 | "elliptic-curve 0.13.2", 442 | "rfc6979 0.4.0", 443 | "signature 2.0.0", 444 | ] 445 | 446 | [[package]] 447 | name = "elliptic-curve" 448 | version = "0.12.3" 449 | source = "registry+https://github.com/rust-lang/crates.io-index" 450 | checksum = "e7bb888ab5300a19b8e5bceef25ac745ad065f3c9f7efc6de1b91958110891d3" 451 | dependencies = [ 452 | "base16ct 0.1.1", 453 | "crypto-bigint 0.4.9", 454 | "der 0.6.1", 455 | "digest", 456 | "ff 0.12.1", 457 | "generic-array", 458 | "group 0.12.1", 459 | "rand_core", 460 | "sec1 0.3.0", 461 | "subtle", 462 | "zeroize", 463 | ] 464 | 465 | [[package]] 466 | name = "elliptic-curve" 467 | version = "0.13.2" 468 | source = "registry+https://github.com/rust-lang/crates.io-index" 469 | checksum = "6ea5a92946e8614bb585254898bb7dd1ddad241ace60c52149e3765e34cc039d" 470 | dependencies = [ 471 | "base16ct 0.2.0", 472 | "crypto-bigint 0.5.1", 473 | "digest", 474 | "ff 0.13.0", 475 | "generic-array", 476 | "group 0.13.0", 477 | "pkcs8 0.10.1", 478 | "rand_core", 479 | "sec1 0.7.1", 480 | "subtle", 481 | "zeroize", 482 | ] 483 | 484 | [[package]] 485 | name = "enumn" 486 | version = "0.1.8" 487 | source = "registry+https://github.com/rust-lang/crates.io-index" 488 | checksum = "48016319042fb7c87b78d2993084a831793a897a5cd1a2a67cab9d1eeb4b7d76" 489 | dependencies = [ 490 | "proc-macro2", 491 | "quote", 492 | "syn 2.0.6", 493 | ] 494 | 495 | [[package]] 496 | name = "errno" 497 | version = "0.2.8" 498 | source = "registry+https://github.com/rust-lang/crates.io-index" 499 | checksum = "f639046355ee4f37944e44f60642c6f3a7efa3cf6b78c78a0d989a8ce6c396a1" 500 | dependencies = [ 501 | "errno-dragonfly", 502 | "libc", 503 | "winapi", 504 | ] 505 | 506 | [[package]] 507 | name = "errno-dragonfly" 508 | version = "0.1.2" 509 | source = "registry+https://github.com/rust-lang/crates.io-index" 510 | checksum = "aa68f1b12764fab894d2755d2518754e71b4fd80ecfb822714a1206c2aab39bf" 511 | dependencies = [ 512 | "cc", 513 | "libc", 514 | ] 515 | 516 | [[package]] 517 | name = "ethabi" 518 | version = "18.0.0" 519 | source = "registry+https://github.com/rust-lang/crates.io-index" 520 | checksum = "7413c5f74cc903ea37386a8965a936cbeb334bd270862fdece542c1b2dcbc898" 521 | dependencies = [ 522 | "ethereum-types", 523 | "hex", 524 | "once_cell", 525 | "regex", 526 | "serde", 527 | "serde_json", 528 | "sha3", 529 | "thiserror", 530 | "uint", 531 | ] 532 | 533 | [[package]] 534 | name = "ethbloom" 535 | version = "0.13.0" 536 | source = "registry+https://github.com/rust-lang/crates.io-index" 537 | checksum = "c22d4b5885b6aa2fe5e8b9329fb8d232bf739e434e6b87347c63bdd00c120f60" 538 | dependencies = [ 539 | "crunchy", 540 | "fixed-hash", 541 | "impl-codec", 542 | "impl-rlp", 543 | "impl-serde", 544 | "scale-info", 545 | "tiny-keccak", 546 | ] 547 | 548 | [[package]] 549 | name = "ethereum-types" 550 | version = "0.14.1" 551 | source = "registry+https://github.com/rust-lang/crates.io-index" 552 | checksum = "02d215cbf040552efcbe99a38372fe80ab9d00268e20012b79fcd0f073edd8ee" 553 | dependencies = [ 554 | "ethbloom", 555 | "fixed-hash", 556 | "impl-codec", 557 | "impl-rlp", 558 | "impl-serde", 559 | "primitive-types", 560 | "scale-info", 561 | "uint", 562 | ] 563 | 564 | [[package]] 565 | name = "ethers-core" 566 | version = "1.0.2" 567 | source = "registry+https://github.com/rust-lang/crates.io-index" 568 | checksum = "ade3e9c97727343984e1ceada4fdab11142d2ee3472d2c67027d56b1251d4f15" 569 | dependencies = [ 570 | "arrayvec", 571 | "bytes", 572 | "chrono", 573 | "elliptic-curve 0.12.3", 574 | "ethabi", 575 | "generic-array", 576 | "hex", 577 | "k256 0.11.6", 578 | "open-fastrlp", 579 | "rand", 580 | "rlp", 581 | "rlp-derive", 582 | "serde", 583 | "serde_json", 584 | "strum", 585 | "thiserror", 586 | "tiny-keccak", 587 | "unicode-xid", 588 | ] 589 | 590 | [[package]] 591 | name = "ethers-core" 592 | version = "2.0.1" 593 | source = "git+https://github.com/gakonst/ethers-rs#16f9fab75cb43e2d9e4c2b74b68afde7577f0e2f" 594 | dependencies = [ 595 | "arrayvec", 596 | "bytes", 597 | "chrono", 598 | "elliptic-curve 0.13.2", 599 | "ethabi", 600 | "generic-array", 601 | "getrandom", 602 | "hex", 603 | "k256 0.13.0", 604 | "num_enum", 605 | "open-fastrlp", 606 | "rand", 607 | "rlp", 608 | "serde", 609 | "serde_json", 610 | "strum", 611 | "tempfile", 612 | "thiserror", 613 | "tiny-keccak", 614 | "unicode-xid", 615 | ] 616 | 617 | [[package]] 618 | name = "fastrand" 619 | version = "1.9.0" 620 | source = "registry+https://github.com/rust-lang/crates.io-index" 621 | checksum = "e51093e27b0797c359783294ca4f0a911c270184cb10f85783b118614a1501be" 622 | dependencies = [ 623 | "instant", 624 | ] 625 | 626 | [[package]] 627 | name = "ff" 628 | version = "0.12.1" 629 | source = "registry+https://github.com/rust-lang/crates.io-index" 630 | checksum = "d013fc25338cc558c5c2cfbad646908fb23591e2404481826742b651c9af7160" 631 | dependencies = [ 632 | "rand_core", 633 | "subtle", 634 | ] 635 | 636 | [[package]] 637 | name = "ff" 638 | version = "0.13.0" 639 | source = "registry+https://github.com/rust-lang/crates.io-index" 640 | checksum = "ded41244b729663b1e574f1b4fb731469f69f79c17667b5d776b16cda0479449" 641 | dependencies = [ 642 | "rand_core", 643 | "subtle", 644 | ] 645 | 646 | [[package]] 647 | name = "fixed-hash" 648 | version = "0.8.0" 649 | source = "registry+https://github.com/rust-lang/crates.io-index" 650 | checksum = "835c052cb0c08c1acf6ffd71c022172e18723949c8282f2b9f27efbc51e64534" 651 | dependencies = [ 652 | "byteorder", 653 | "rand", 654 | "rustc-hex", 655 | "static_assertions", 656 | ] 657 | 658 | [[package]] 659 | name = "fnv" 660 | version = "1.0.7" 661 | source = "registry+https://github.com/rust-lang/crates.io-index" 662 | checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" 663 | 664 | [[package]] 665 | name = "form_urlencoded" 666 | version = "1.1.0" 667 | source = "registry+https://github.com/rust-lang/crates.io-index" 668 | checksum = "a9c384f161156f5260c24a097c56119f9be8c798586aecc13afbcbe7b7e26bf8" 669 | dependencies = [ 670 | "percent-encoding", 671 | ] 672 | 673 | [[package]] 674 | name = "funty" 675 | version = "2.0.0" 676 | source = "registry+https://github.com/rust-lang/crates.io-index" 677 | checksum = "e6d5a32815ae3f33302d95fdcb2ce17862f8c65363dcfd29360480ba1001fc9c" 678 | 679 | [[package]] 680 | name = "generic-array" 681 | version = "0.14.6" 682 | source = "registry+https://github.com/rust-lang/crates.io-index" 683 | checksum = "bff49e947297f3312447abdca79f45f4738097cc82b06e72054d2223f601f1b9" 684 | dependencies = [ 685 | "typenum", 686 | "version_check", 687 | "zeroize", 688 | ] 689 | 690 | [[package]] 691 | name = "getrandom" 692 | version = "0.2.8" 693 | source = "registry+https://github.com/rust-lang/crates.io-index" 694 | checksum = "c05aeb6a22b8f62540c194aac980f2115af067bfe15a0734d7277a768d396b31" 695 | dependencies = [ 696 | "cfg-if", 697 | "js-sys", 698 | "libc", 699 | "wasi", 700 | "wasm-bindgen", 701 | ] 702 | 703 | [[package]] 704 | name = "group" 705 | version = "0.12.1" 706 | source = "registry+https://github.com/rust-lang/crates.io-index" 707 | checksum = "5dfbfb3a6cfbd390d5c9564ab283a0349b9b9fcd46a706c1eb10e0db70bfbac7" 708 | dependencies = [ 709 | "ff 0.12.1", 710 | "rand_core", 711 | "subtle", 712 | ] 713 | 714 | [[package]] 715 | name = "group" 716 | version = "0.13.0" 717 | source = "registry+https://github.com/rust-lang/crates.io-index" 718 | checksum = "f0f9ef7462f7c099f518d754361858f86d8a07af53ba9af0fe635bbccb151a63" 719 | dependencies = [ 720 | "ff 0.13.0", 721 | "rand_core", 722 | "subtle", 723 | ] 724 | 725 | [[package]] 726 | name = "hash-db" 727 | version = "0.15.2" 728 | source = "registry+https://github.com/rust-lang/crates.io-index" 729 | checksum = "d23bd4e7b5eda0d0f3a307e8b381fdc8ba9000f26fbe912250c0a4cc3956364a" 730 | 731 | [[package]] 732 | name = "hashbrown" 733 | version = "0.12.3" 734 | source = "registry+https://github.com/rust-lang/crates.io-index" 735 | checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888" 736 | 737 | [[package]] 738 | name = "hashbrown" 739 | version = "0.13.2" 740 | source = "registry+https://github.com/rust-lang/crates.io-index" 741 | checksum = "43a3c133739dddd0d2990f9a4bdf8eb4b21ef50e4851ca85ab661199821d510e" 742 | dependencies = [ 743 | "ahash", 744 | "serde", 745 | ] 746 | 747 | [[package]] 748 | name = "heck" 749 | version = "0.4.1" 750 | source = "registry+https://github.com/rust-lang/crates.io-index" 751 | checksum = "95505c38b4572b2d910cecb0281560f54b440a19336cbbcb27bf6ce6adc6f5a8" 752 | 753 | [[package]] 754 | name = "hermit-abi" 755 | version = "0.3.1" 756 | source = "registry+https://github.com/rust-lang/crates.io-index" 757 | checksum = "fed44880c466736ef9a5c5b5facefb5ed0785676d0c02d612db14e54f0d84286" 758 | 759 | [[package]] 760 | name = "hex" 761 | version = "0.4.3" 762 | source = "registry+https://github.com/rust-lang/crates.io-index" 763 | checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70" 764 | dependencies = [ 765 | "serde", 766 | ] 767 | 768 | [[package]] 769 | name = "hex-literal" 770 | version = "0.3.4" 771 | source = "registry+https://github.com/rust-lang/crates.io-index" 772 | checksum = "7ebdb29d2ea9ed0083cd8cece49bbd968021bd99b0849edb4a9a7ee0fdf6a4e0" 773 | 774 | [[package]] 775 | name = "hmac" 776 | version = "0.12.1" 777 | source = "registry+https://github.com/rust-lang/crates.io-index" 778 | checksum = "6c49c37c09c17a53d937dfbb742eb3a961d65a994e6bcdcf37e7399d0cc8ab5e" 779 | dependencies = [ 780 | "digest", 781 | ] 782 | 783 | [[package]] 784 | name = "iana-time-zone" 785 | version = "0.1.54" 786 | source = "registry+https://github.com/rust-lang/crates.io-index" 787 | checksum = "0c17cc76786e99f8d2f055c11159e7f0091c42474dcc3189fbab96072e873e6d" 788 | dependencies = [ 789 | "android_system_properties", 790 | "core-foundation-sys", 791 | "iana-time-zone-haiku", 792 | "js-sys", 793 | "wasm-bindgen", 794 | "windows", 795 | ] 796 | 797 | [[package]] 798 | name = "iana-time-zone-haiku" 799 | version = "0.1.1" 800 | source = "registry+https://github.com/rust-lang/crates.io-index" 801 | checksum = "0703ae284fc167426161c2e3f1da3ea71d94b21bedbcc9494e92b28e334e3dca" 802 | dependencies = [ 803 | "cxx", 804 | "cxx-build", 805 | ] 806 | 807 | [[package]] 808 | name = "ident_case" 809 | version = "1.0.1" 810 | source = "registry+https://github.com/rust-lang/crates.io-index" 811 | checksum = "b9e0384b61958566e926dc50660321d12159025e767c18e043daf26b70104c39" 812 | 813 | [[package]] 814 | name = "idna" 815 | version = "0.3.0" 816 | source = "registry+https://github.com/rust-lang/crates.io-index" 817 | checksum = "e14ddfc70884202db2244c223200c204c2bda1bc6e0998d11b5e024d657209e6" 818 | dependencies = [ 819 | "unicode-bidi", 820 | "unicode-normalization", 821 | ] 822 | 823 | [[package]] 824 | name = "impl-codec" 825 | version = "0.6.0" 826 | source = "registry+https://github.com/rust-lang/crates.io-index" 827 | checksum = "ba6a270039626615617f3f36d15fc827041df3b78c439da2cadfa47455a77f2f" 828 | dependencies = [ 829 | "parity-scale-codec", 830 | ] 831 | 832 | [[package]] 833 | name = "impl-rlp" 834 | version = "0.3.0" 835 | source = "registry+https://github.com/rust-lang/crates.io-index" 836 | checksum = "f28220f89297a075ddc7245cd538076ee98b01f2a9c23a53a4f1105d5a322808" 837 | dependencies = [ 838 | "rlp", 839 | ] 840 | 841 | [[package]] 842 | name = "impl-serde" 843 | version = "0.4.0" 844 | source = "registry+https://github.com/rust-lang/crates.io-index" 845 | checksum = "ebc88fc67028ae3db0c853baa36269d398d5f45b6982f95549ff5def78c935cd" 846 | dependencies = [ 847 | "serde", 848 | ] 849 | 850 | [[package]] 851 | name = "impl-trait-for-tuples" 852 | version = "0.2.2" 853 | source = "registry+https://github.com/rust-lang/crates.io-index" 854 | checksum = "11d7a9f6330b71fea57921c9b61c47ee6e84f72d394754eff6163ae67e7395eb" 855 | dependencies = [ 856 | "proc-macro2", 857 | "quote", 858 | "syn 1.0.109", 859 | ] 860 | 861 | [[package]] 862 | name = "indexmap" 863 | version = "1.9.2" 864 | source = "registry+https://github.com/rust-lang/crates.io-index" 865 | checksum = "1885e79c1fc4b10f0e172c475f458b7f7b93061064d98c3293e98c5ba0c8b399" 866 | dependencies = [ 867 | "autocfg", 868 | "hashbrown 0.12.3", 869 | "serde", 870 | ] 871 | 872 | [[package]] 873 | name = "instant" 874 | version = "0.1.12" 875 | source = "registry+https://github.com/rust-lang/crates.io-index" 876 | checksum = "7a5bbe824c507c5da5956355e86a746d82e0e1464f65d862cc5e71da70e94b2c" 877 | dependencies = [ 878 | "cfg-if", 879 | ] 880 | 881 | [[package]] 882 | name = "io-lifetimes" 883 | version = "1.0.9" 884 | source = "registry+https://github.com/rust-lang/crates.io-index" 885 | checksum = "09270fd4fa1111bc614ed2246c7ef56239a3063d5be0d1ec3b589c505d400aeb" 886 | dependencies = [ 887 | "hermit-abi", 888 | "libc", 889 | "windows-sys 0.45.0", 890 | ] 891 | 892 | [[package]] 893 | name = "itoa" 894 | version = "1.0.6" 895 | source = "registry+https://github.com/rust-lang/crates.io-index" 896 | checksum = "453ad9f582a441959e5f0d088b02ce04cfe8d51a8eaf077f12ac6d3e94164ca6" 897 | 898 | [[package]] 899 | name = "jobserver" 900 | version = "0.1.26" 901 | source = "registry+https://github.com/rust-lang/crates.io-index" 902 | checksum = "936cfd212a0155903bcbc060e316fb6cc7cbf2e1907329391ebadc1fe0ce77c2" 903 | dependencies = [ 904 | "libc", 905 | ] 906 | 907 | [[package]] 908 | name = "js-sys" 909 | version = "0.3.61" 910 | source = "registry+https://github.com/rust-lang/crates.io-index" 911 | checksum = "445dde2150c55e483f3d8416706b97ec8e8237c307e5b7b4b8dd15e6af2a0730" 912 | dependencies = [ 913 | "wasm-bindgen", 914 | ] 915 | 916 | [[package]] 917 | name = "k256" 918 | version = "0.11.6" 919 | source = "registry+https://github.com/rust-lang/crates.io-index" 920 | checksum = "72c1e0b51e7ec0a97369623508396067a486bd0cbed95a2659a4b863d28cfc8b" 921 | dependencies = [ 922 | "cfg-if", 923 | "ecdsa 0.14.8", 924 | "elliptic-curve 0.12.3", 925 | "sha2", 926 | "sha3", 927 | ] 928 | 929 | [[package]] 930 | name = "k256" 931 | version = "0.13.0" 932 | source = "registry+https://github.com/rust-lang/crates.io-index" 933 | checksum = "955890845095ccf31ef83ad41a05aabb4d8cc23dc3cac5a9f5c89cf26dd0da75" 934 | dependencies = [ 935 | "cfg-if", 936 | "ecdsa 0.16.1", 937 | "elliptic-curve 0.13.2", 938 | "once_cell", 939 | "sha2", 940 | ] 941 | 942 | [[package]] 943 | name = "keccak" 944 | version = "0.1.3" 945 | source = "registry+https://github.com/rust-lang/crates.io-index" 946 | checksum = "3afef3b6eff9ce9d8ff9b3601125eec7f0c8cbac7abd14f355d053fa56c98768" 947 | dependencies = [ 948 | "cpufeatures", 949 | ] 950 | 951 | [[package]] 952 | name = "libc" 953 | version = "0.2.140" 954 | source = "registry+https://github.com/rust-lang/crates.io-index" 955 | checksum = "99227334921fae1a979cf0bfdfcc6b3e5ce376ef57e16fb6fb3ea2ed6095f80c" 956 | 957 | [[package]] 958 | name = "libfuzzer-sys" 959 | version = "0.4.6" 960 | source = "registry+https://github.com/rust-lang/crates.io-index" 961 | checksum = "beb09950ae85a0a94b27676cccf37da5ff13f27076aa1adbc6545dd0d0e1bd4e" 962 | dependencies = [ 963 | "arbitrary", 964 | "cc", 965 | "once_cell", 966 | ] 967 | 968 | [[package]] 969 | name = "link-cplusplus" 970 | version = "1.0.8" 971 | source = "registry+https://github.com/rust-lang/crates.io-index" 972 | checksum = "ecd207c9c713c34f95a097a5b029ac2ce6010530c7b49d7fea24d977dede04f5" 973 | dependencies = [ 974 | "cc", 975 | ] 976 | 977 | [[package]] 978 | name = "linux-raw-sys" 979 | version = "0.1.4" 980 | source = "registry+https://github.com/rust-lang/crates.io-index" 981 | checksum = "f051f77a7c8e6957c0696eac88f26b0117e54f52d3fc682ab19397a8812846a4" 982 | 983 | [[package]] 984 | name = "log" 985 | version = "0.4.17" 986 | source = "registry+https://github.com/rust-lang/crates.io-index" 987 | checksum = "abb12e687cfb44aa40f41fc3978ef76448f9b6038cad6aef4259d3c095a2382e" 988 | dependencies = [ 989 | "cfg-if", 990 | ] 991 | 992 | [[package]] 993 | name = "memchr" 994 | version = "2.5.0" 995 | source = "registry+https://github.com/rust-lang/crates.io-index" 996 | checksum = "2dffe52ecf27772e601905b7522cb4ef790d2cc203488bbd0e2fe85fcb74566d" 997 | 998 | [[package]] 999 | name = "modular-bitfield" 1000 | version = "0.11.2" 1001 | source = "registry+https://github.com/rust-lang/crates.io-index" 1002 | checksum = "a53d79ba8304ac1c4f9eb3b9d281f21f7be9d4626f72ce7df4ad8fbde4f38a74" 1003 | dependencies = [ 1004 | "modular-bitfield-impl", 1005 | "static_assertions", 1006 | ] 1007 | 1008 | [[package]] 1009 | name = "modular-bitfield-impl" 1010 | version = "0.11.2" 1011 | source = "registry+https://github.com/rust-lang/crates.io-index" 1012 | checksum = "5a7d5f7076603ebc68de2dc6a650ec331a062a13abaa346975be747bbfa4b789" 1013 | dependencies = [ 1014 | "proc-macro2", 1015 | "quote", 1016 | "syn 1.0.109", 1017 | ] 1018 | 1019 | [[package]] 1020 | name = "mpt" 1021 | version = "0.1.0" 1022 | dependencies = [ 1023 | "core", 1024 | "hex", 1025 | "reth-primitives", 1026 | "reth-rlp", 1027 | ] 1028 | 1029 | [[package]] 1030 | name = "mpt-fuzz" 1031 | version = "0.0.0" 1032 | dependencies = [ 1033 | "libfuzzer-sys", 1034 | "mpt", 1035 | ] 1036 | 1037 | [[package]] 1038 | name = "num-integer" 1039 | version = "0.1.45" 1040 | source = "registry+https://github.com/rust-lang/crates.io-index" 1041 | checksum = "225d3389fb3509a24c93f5c29eb6bde2586b98d9f016636dff58d7c6f7569cd9" 1042 | dependencies = [ 1043 | "autocfg", 1044 | "num-traits", 1045 | ] 1046 | 1047 | [[package]] 1048 | name = "num-traits" 1049 | version = "0.2.15" 1050 | source = "registry+https://github.com/rust-lang/crates.io-index" 1051 | checksum = "578ede34cf02f8924ab9447f50c28075b4d3e5b269972345e7e0372b38c6cdcd" 1052 | dependencies = [ 1053 | "autocfg", 1054 | ] 1055 | 1056 | [[package]] 1057 | name = "num_enum" 1058 | version = "0.5.11" 1059 | source = "registry+https://github.com/rust-lang/crates.io-index" 1060 | checksum = "1f646caf906c20226733ed5b1374287eb97e3c2a5c227ce668c1f2ce20ae57c9" 1061 | dependencies = [ 1062 | "num_enum_derive", 1063 | ] 1064 | 1065 | [[package]] 1066 | name = "num_enum_derive" 1067 | version = "0.5.11" 1068 | source = "registry+https://github.com/rust-lang/crates.io-index" 1069 | checksum = "dcbff9bc912032c62bf65ef1d5aea88983b420f4f839db1e9b0c281a25c9c799" 1070 | dependencies = [ 1071 | "proc-macro-crate", 1072 | "proc-macro2", 1073 | "quote", 1074 | "syn 1.0.109", 1075 | ] 1076 | 1077 | [[package]] 1078 | name = "once_cell" 1079 | version = "1.17.1" 1080 | source = "registry+https://github.com/rust-lang/crates.io-index" 1081 | checksum = "b7e5500299e16ebb147ae15a00a942af264cf3688f47923b8fc2cd5858f23ad3" 1082 | 1083 | [[package]] 1084 | name = "open-fastrlp" 1085 | version = "0.1.4" 1086 | source = "registry+https://github.com/rust-lang/crates.io-index" 1087 | checksum = "786393f80485445794f6043fd3138854dd109cc6c4bd1a6383db304c9ce9b9ce" 1088 | dependencies = [ 1089 | "arrayvec", 1090 | "auto_impl", 1091 | "bytes", 1092 | "ethereum-types", 1093 | "open-fastrlp-derive", 1094 | ] 1095 | 1096 | [[package]] 1097 | name = "open-fastrlp-derive" 1098 | version = "0.1.1" 1099 | source = "registry+https://github.com/rust-lang/crates.io-index" 1100 | checksum = "003b2be5c6c53c1cfeb0a238b8a1c3915cd410feb684457a36c10038f764bb1c" 1101 | dependencies = [ 1102 | "bytes", 1103 | "proc-macro2", 1104 | "quote", 1105 | "syn 1.0.109", 1106 | ] 1107 | 1108 | [[package]] 1109 | name = "parity-scale-codec" 1110 | version = "3.4.0" 1111 | source = "registry+https://github.com/rust-lang/crates.io-index" 1112 | checksum = "637935964ff85a605d114591d4d2c13c5d1ba2806dae97cea6bf180238a749ac" 1113 | dependencies = [ 1114 | "arrayvec", 1115 | "bitvec", 1116 | "byte-slice-cast", 1117 | "bytes", 1118 | "impl-trait-for-tuples", 1119 | "parity-scale-codec-derive", 1120 | "serde", 1121 | ] 1122 | 1123 | [[package]] 1124 | name = "parity-scale-codec-derive" 1125 | version = "3.1.4" 1126 | source = "registry+https://github.com/rust-lang/crates.io-index" 1127 | checksum = "86b26a931f824dd4eca30b3e43bb4f31cd5f0d3a403c5f5ff27106b805bfde7b" 1128 | dependencies = [ 1129 | "proc-macro-crate", 1130 | "proc-macro2", 1131 | "quote", 1132 | "syn 1.0.109", 1133 | ] 1134 | 1135 | [[package]] 1136 | name = "percent-encoding" 1137 | version = "2.2.0" 1138 | source = "registry+https://github.com/rust-lang/crates.io-index" 1139 | checksum = "478c572c3d73181ff3c2539045f6eb99e5491218eae919370993b890cdbdd98e" 1140 | 1141 | [[package]] 1142 | name = "pkcs8" 1143 | version = "0.9.0" 1144 | source = "registry+https://github.com/rust-lang/crates.io-index" 1145 | checksum = "9eca2c590a5f85da82668fa685c09ce2888b9430e83299debf1f34b65fd4a4ba" 1146 | dependencies = [ 1147 | "der 0.6.1", 1148 | "spki 0.6.0", 1149 | ] 1150 | 1151 | [[package]] 1152 | name = "pkcs8" 1153 | version = "0.10.1" 1154 | source = "registry+https://github.com/rust-lang/crates.io-index" 1155 | checksum = "3d2820d87d2b008616e5c27212dd9e0e694fb4c6b522de06094106813328cb49" 1156 | dependencies = [ 1157 | "der 0.7.1", 1158 | "spki 0.7.0", 1159 | ] 1160 | 1161 | [[package]] 1162 | name = "plain_hasher" 1163 | version = "0.2.3" 1164 | source = "registry+https://github.com/rust-lang/crates.io-index" 1165 | checksum = "1e19e6491bdde87c2c43d70f4c194bc8a758f2eb732df00f61e43f7362e3b4cc" 1166 | dependencies = [ 1167 | "crunchy", 1168 | ] 1169 | 1170 | [[package]] 1171 | name = "ppv-lite86" 1172 | version = "0.2.17" 1173 | source = "registry+https://github.com/rust-lang/crates.io-index" 1174 | checksum = "5b40af805b3121feab8a3c29f04d8ad262fa8e0561883e7653e024ae4479e6de" 1175 | 1176 | [[package]] 1177 | name = "primitive-types" 1178 | version = "0.12.1" 1179 | source = "registry+https://github.com/rust-lang/crates.io-index" 1180 | checksum = "9f3486ccba82358b11a77516035647c34ba167dfa53312630de83b12bd4f3d66" 1181 | dependencies = [ 1182 | "fixed-hash", 1183 | "impl-codec", 1184 | "impl-rlp", 1185 | "impl-serde", 1186 | "scale-info", 1187 | "uint", 1188 | ] 1189 | 1190 | [[package]] 1191 | name = "proc-macro-crate" 1192 | version = "1.3.1" 1193 | source = "registry+https://github.com/rust-lang/crates.io-index" 1194 | checksum = "7f4c021e1093a56626774e81216a4ce732a735e5bad4868a03f3ed65ca0c3919" 1195 | dependencies = [ 1196 | "once_cell", 1197 | "toml_edit", 1198 | ] 1199 | 1200 | [[package]] 1201 | name = "proc-macro-error" 1202 | version = "1.0.4" 1203 | source = "registry+https://github.com/rust-lang/crates.io-index" 1204 | checksum = "da25490ff9892aab3fcf7c36f08cfb902dd3e71ca0f9f9517bea02a73a5ce38c" 1205 | dependencies = [ 1206 | "proc-macro-error-attr", 1207 | "proc-macro2", 1208 | "quote", 1209 | "syn 1.0.109", 1210 | "version_check", 1211 | ] 1212 | 1213 | [[package]] 1214 | name = "proc-macro-error-attr" 1215 | version = "1.0.4" 1216 | source = "registry+https://github.com/rust-lang/crates.io-index" 1217 | checksum = "a1be40180e52ecc98ad80b184934baf3d0d29f979574e439af5a55274b35f869" 1218 | dependencies = [ 1219 | "proc-macro2", 1220 | "quote", 1221 | "version_check", 1222 | ] 1223 | 1224 | [[package]] 1225 | name = "proc-macro2" 1226 | version = "1.0.53" 1227 | source = "registry+https://github.com/rust-lang/crates.io-index" 1228 | checksum = "ba466839c78239c09faf015484e5cc04860f88242cff4d03eb038f04b4699b73" 1229 | dependencies = [ 1230 | "unicode-ident", 1231 | ] 1232 | 1233 | [[package]] 1234 | name = "quote" 1235 | version = "1.0.26" 1236 | source = "registry+https://github.com/rust-lang/crates.io-index" 1237 | checksum = "4424af4bf778aae2051a77b60283332f386554255d722233d09fbfc7e30da2fc" 1238 | dependencies = [ 1239 | "proc-macro2", 1240 | ] 1241 | 1242 | [[package]] 1243 | name = "radium" 1244 | version = "0.7.0" 1245 | source = "registry+https://github.com/rust-lang/crates.io-index" 1246 | checksum = "dc33ff2d4973d518d823d61aa239014831e521c75da58e3df4840d3f47749d09" 1247 | 1248 | [[package]] 1249 | name = "rand" 1250 | version = "0.8.5" 1251 | source = "registry+https://github.com/rust-lang/crates.io-index" 1252 | checksum = "34af8d1a0e25924bc5b7c43c079c942339d8f0a8b57c39049bef581b46327404" 1253 | dependencies = [ 1254 | "libc", 1255 | "rand_chacha", 1256 | "rand_core", 1257 | ] 1258 | 1259 | [[package]] 1260 | name = "rand_chacha" 1261 | version = "0.3.1" 1262 | source = "registry+https://github.com/rust-lang/crates.io-index" 1263 | checksum = "e6c10a63a0fa32252be49d21e7709d4d4baf8d231c2dbce1eaa8141b9b127d88" 1264 | dependencies = [ 1265 | "ppv-lite86", 1266 | "rand_core", 1267 | ] 1268 | 1269 | [[package]] 1270 | name = "rand_core" 1271 | version = "0.6.4" 1272 | source = "registry+https://github.com/rust-lang/crates.io-index" 1273 | checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c" 1274 | dependencies = [ 1275 | "getrandom", 1276 | ] 1277 | 1278 | [[package]] 1279 | name = "redox_syscall" 1280 | version = "0.2.16" 1281 | source = "registry+https://github.com/rust-lang/crates.io-index" 1282 | checksum = "fb5a58c1855b4b6819d59012155603f0b22ad30cad752600aadfcb695265519a" 1283 | dependencies = [ 1284 | "bitflags", 1285 | ] 1286 | 1287 | [[package]] 1288 | name = "regex" 1289 | version = "1.7.2" 1290 | source = "registry+https://github.com/rust-lang/crates.io-index" 1291 | checksum = "cce168fea28d3e05f158bda4576cf0c844d5045bc2cc3620fa0292ed5bb5814c" 1292 | dependencies = [ 1293 | "aho-corasick", 1294 | "memchr", 1295 | "regex-syntax", 1296 | ] 1297 | 1298 | [[package]] 1299 | name = "regex-syntax" 1300 | version = "0.6.29" 1301 | source = "registry+https://github.com/rust-lang/crates.io-index" 1302 | checksum = "f162c6dd7b008981e4d40210aca20b4bd0f9b60ca9271061b07f78537722f2e1" 1303 | 1304 | [[package]] 1305 | name = "reth-codecs" 1306 | version = "0.1.0" 1307 | source = "git+https://github.com/paradigmxyz/reth#b44391776eca11a8de4039b8fb7b2c463acdb8bc" 1308 | dependencies = [ 1309 | "bytes", 1310 | "codecs-derive", 1311 | "revm-primitives", 1312 | ] 1313 | 1314 | [[package]] 1315 | name = "reth-primitives" 1316 | version = "0.1.0" 1317 | source = "git+https://github.com/paradigmxyz/reth#b44391776eca11a8de4039b8fb7b2c463acdb8bc" 1318 | dependencies = [ 1319 | "bytes", 1320 | "crc", 1321 | "crunchy", 1322 | "derive_more", 1323 | "ethers-core 2.0.1", 1324 | "fixed-hash", 1325 | "hash-db", 1326 | "hex", 1327 | "hex-literal", 1328 | "impl-serde", 1329 | "modular-bitfield", 1330 | "once_cell", 1331 | "plain_hasher", 1332 | "reth-codecs", 1333 | "reth-rlp", 1334 | "reth-rlp-derive", 1335 | "revm-primitives", 1336 | "secp256k1", 1337 | "serde", 1338 | "serde_json", 1339 | "serde_with", 1340 | "strum", 1341 | "sucds", 1342 | "thiserror", 1343 | "tiny-keccak", 1344 | "triehash", 1345 | "url", 1346 | ] 1347 | 1348 | [[package]] 1349 | name = "reth-rlp" 1350 | version = "0.1.2" 1351 | source = "git+https://github.com/paradigmxyz/reth#b44391776eca11a8de4039b8fb7b2c463acdb8bc" 1352 | dependencies = [ 1353 | "arrayvec", 1354 | "auto_impl", 1355 | "bytes", 1356 | "ethereum-types", 1357 | "reth-rlp-derive", 1358 | "revm-primitives", 1359 | ] 1360 | 1361 | [[package]] 1362 | name = "reth-rlp-derive" 1363 | version = "0.1.1" 1364 | source = "git+https://github.com/paradigmxyz/reth#b44391776eca11a8de4039b8fb7b2c463acdb8bc" 1365 | dependencies = [ 1366 | "proc-macro2", 1367 | "quote", 1368 | "syn 2.0.6", 1369 | ] 1370 | 1371 | [[package]] 1372 | name = "revm-primitives" 1373 | version = "1.0.0" 1374 | source = "git+https://github.com/bluealloy/revm#0eff6a74741c0b90ab9854770aabff4259257460" 1375 | dependencies = [ 1376 | "auto_impl", 1377 | "bitvec", 1378 | "bytes", 1379 | "derive_more", 1380 | "enumn", 1381 | "fixed-hash", 1382 | "hashbrown 0.13.2", 1383 | "hex", 1384 | "hex-literal", 1385 | "primitive-types", 1386 | "rlp", 1387 | "ruint", 1388 | "serde", 1389 | "sha3", 1390 | ] 1391 | 1392 | [[package]] 1393 | name = "rfc6979" 1394 | version = "0.3.1" 1395 | source = "registry+https://github.com/rust-lang/crates.io-index" 1396 | checksum = "7743f17af12fa0b03b803ba12cd6a8d9483a587e89c69445e3909655c0b9fabb" 1397 | dependencies = [ 1398 | "crypto-bigint 0.4.9", 1399 | "hmac", 1400 | "zeroize", 1401 | ] 1402 | 1403 | [[package]] 1404 | name = "rfc6979" 1405 | version = "0.4.0" 1406 | source = "registry+https://github.com/rust-lang/crates.io-index" 1407 | checksum = "f8dd2a808d456c4a54e300a23e9f5a67e122c3024119acbfd73e3bf664491cb2" 1408 | dependencies = [ 1409 | "hmac", 1410 | "subtle", 1411 | ] 1412 | 1413 | [[package]] 1414 | name = "rlp" 1415 | version = "0.5.2" 1416 | source = "registry+https://github.com/rust-lang/crates.io-index" 1417 | checksum = "bb919243f34364b6bd2fc10ef797edbfa75f33c252e7998527479c6d6b47e1ec" 1418 | dependencies = [ 1419 | "bytes", 1420 | "rlp-derive", 1421 | "rustc-hex", 1422 | ] 1423 | 1424 | [[package]] 1425 | name = "rlp-derive" 1426 | version = "0.1.0" 1427 | source = "registry+https://github.com/rust-lang/crates.io-index" 1428 | checksum = "e33d7b2abe0c340d8797fe2907d3f20d3b5ea5908683618bfe80df7f621f672a" 1429 | dependencies = [ 1430 | "proc-macro2", 1431 | "quote", 1432 | "syn 1.0.109", 1433 | ] 1434 | 1435 | [[package]] 1436 | name = "ruint" 1437 | version = "1.7.0" 1438 | source = "git+https://github.com/paradigmxyz/uint#c14ed24f9611546e6614b6f9b3524de11cb35ea5" 1439 | dependencies = [ 1440 | "derive_more", 1441 | "primitive-types", 1442 | "rlp", 1443 | "ruint-macro", 1444 | "rustc_version", 1445 | "serde", 1446 | "thiserror", 1447 | ] 1448 | 1449 | [[package]] 1450 | name = "ruint-macro" 1451 | version = "1.0.2" 1452 | source = "git+https://github.com/paradigmxyz/uint#c14ed24f9611546e6614b6f9b3524de11cb35ea5" 1453 | 1454 | [[package]] 1455 | name = "rustc-hex" 1456 | version = "2.1.0" 1457 | source = "registry+https://github.com/rust-lang/crates.io-index" 1458 | checksum = "3e75f6a532d0fd9f7f13144f392b6ad56a32696bfcd9c78f797f16bbb6f072d6" 1459 | 1460 | [[package]] 1461 | name = "rustc_version" 1462 | version = "0.4.0" 1463 | source = "registry+https://github.com/rust-lang/crates.io-index" 1464 | checksum = "bfa0f585226d2e68097d4f95d113b15b83a82e819ab25717ec0590d9584ef366" 1465 | dependencies = [ 1466 | "semver", 1467 | ] 1468 | 1469 | [[package]] 1470 | name = "rustix" 1471 | version = "0.36.11" 1472 | source = "registry+https://github.com/rust-lang/crates.io-index" 1473 | checksum = "db4165c9963ab29e422d6c26fbc1d37f15bace6b2810221f9d925023480fcf0e" 1474 | dependencies = [ 1475 | "bitflags", 1476 | "errno", 1477 | "io-lifetimes", 1478 | "libc", 1479 | "linux-raw-sys", 1480 | "windows-sys 0.45.0", 1481 | ] 1482 | 1483 | [[package]] 1484 | name = "rustversion" 1485 | version = "1.0.12" 1486 | source = "registry+https://github.com/rust-lang/crates.io-index" 1487 | checksum = "4f3208ce4d8448b3f3e7d168a73f5e0c43a61e32930de3bceeccedb388b6bf06" 1488 | 1489 | [[package]] 1490 | name = "ryu" 1491 | version = "1.0.13" 1492 | source = "registry+https://github.com/rust-lang/crates.io-index" 1493 | checksum = "f91339c0467de62360649f8d3e185ca8de4224ff281f66000de5eb2a77a79041" 1494 | 1495 | [[package]] 1496 | name = "scale-info" 1497 | version = "2.3.1" 1498 | source = "registry+https://github.com/rust-lang/crates.io-index" 1499 | checksum = "001cf62ece89779fd16105b5f515ad0e5cedcd5440d3dd806bb067978e7c3608" 1500 | dependencies = [ 1501 | "cfg-if", 1502 | "derive_more", 1503 | "parity-scale-codec", 1504 | "scale-info-derive", 1505 | ] 1506 | 1507 | [[package]] 1508 | name = "scale-info-derive" 1509 | version = "2.3.1" 1510 | source = "registry+https://github.com/rust-lang/crates.io-index" 1511 | checksum = "303959cf613a6f6efd19ed4b4ad5bf79966a13352716299ad532cfb115f4205c" 1512 | dependencies = [ 1513 | "proc-macro-crate", 1514 | "proc-macro2", 1515 | "quote", 1516 | "syn 1.0.109", 1517 | ] 1518 | 1519 | [[package]] 1520 | name = "scratch" 1521 | version = "1.0.5" 1522 | source = "registry+https://github.com/rust-lang/crates.io-index" 1523 | checksum = "1792db035ce95be60c3f8853017b3999209281c24e2ba5bc8e59bf97a0c590c1" 1524 | 1525 | [[package]] 1526 | name = "sec1" 1527 | version = "0.3.0" 1528 | source = "registry+https://github.com/rust-lang/crates.io-index" 1529 | checksum = "3be24c1842290c45df0a7bf069e0c268a747ad05a192f2fd7dcfdbc1cba40928" 1530 | dependencies = [ 1531 | "base16ct 0.1.1", 1532 | "der 0.6.1", 1533 | "generic-array", 1534 | "pkcs8 0.9.0", 1535 | "subtle", 1536 | "zeroize", 1537 | ] 1538 | 1539 | [[package]] 1540 | name = "sec1" 1541 | version = "0.7.1" 1542 | source = "registry+https://github.com/rust-lang/crates.io-index" 1543 | checksum = "48518a2b5775ba8ca5b46596aae011caa431e6ce7e4a67ead66d92f08884220e" 1544 | dependencies = [ 1545 | "base16ct 0.2.0", 1546 | "der 0.7.1", 1547 | "generic-array", 1548 | "pkcs8 0.10.1", 1549 | "subtle", 1550 | "zeroize", 1551 | ] 1552 | 1553 | [[package]] 1554 | name = "secp256k1" 1555 | version = "0.26.0" 1556 | source = "registry+https://github.com/rust-lang/crates.io-index" 1557 | checksum = "4124a35fe33ae14259c490fd70fa199a32b9ce9502f2ee6bc4f81ec06fa65894" 1558 | dependencies = [ 1559 | "secp256k1-sys", 1560 | ] 1561 | 1562 | [[package]] 1563 | name = "secp256k1-sys" 1564 | version = "0.8.1" 1565 | source = "registry+https://github.com/rust-lang/crates.io-index" 1566 | checksum = "70a129b9e9efbfb223753b9163c4ab3b13cff7fd9c7f010fbac25ab4099fa07e" 1567 | dependencies = [ 1568 | "cc", 1569 | ] 1570 | 1571 | [[package]] 1572 | name = "semver" 1573 | version = "1.0.17" 1574 | source = "registry+https://github.com/rust-lang/crates.io-index" 1575 | checksum = "bebd363326d05ec3e2f532ab7660680f3b02130d780c299bca73469d521bc0ed" 1576 | 1577 | [[package]] 1578 | name = "serde" 1579 | version = "1.0.158" 1580 | source = "registry+https://github.com/rust-lang/crates.io-index" 1581 | checksum = "771d4d9c4163ee138805e12c710dd365e4f44be8be0503cb1bb9eb989425d9c9" 1582 | dependencies = [ 1583 | "serde_derive", 1584 | ] 1585 | 1586 | [[package]] 1587 | name = "serde_derive" 1588 | version = "1.0.158" 1589 | source = "registry+https://github.com/rust-lang/crates.io-index" 1590 | checksum = "e801c1712f48475582b7696ac71e0ca34ebb30e09338425384269d9717c62cad" 1591 | dependencies = [ 1592 | "proc-macro2", 1593 | "quote", 1594 | "syn 2.0.6", 1595 | ] 1596 | 1597 | [[package]] 1598 | name = "serde_json" 1599 | version = "1.0.94" 1600 | source = "registry+https://github.com/rust-lang/crates.io-index" 1601 | checksum = "1c533a59c9d8a93a09c6ab31f0fd5e5f4dd1b8fc9434804029839884765d04ea" 1602 | dependencies = [ 1603 | "itoa", 1604 | "ryu", 1605 | "serde", 1606 | ] 1607 | 1608 | [[package]] 1609 | name = "serde_with" 1610 | version = "2.3.1" 1611 | source = "registry+https://github.com/rust-lang/crates.io-index" 1612 | checksum = "85456ffac572dc8826334164f2fb6fb40a7c766aebe195a2a21ee69ee2885ecf" 1613 | dependencies = [ 1614 | "base64", 1615 | "chrono", 1616 | "hex", 1617 | "indexmap", 1618 | "serde", 1619 | "serde_json", 1620 | "serde_with_macros", 1621 | "time", 1622 | ] 1623 | 1624 | [[package]] 1625 | name = "serde_with_macros" 1626 | version = "2.3.1" 1627 | source = "registry+https://github.com/rust-lang/crates.io-index" 1628 | checksum = "7cbcd6104f8a4ab6af7f6be2a0da6be86b9de3c401f6e86bb856ab2af739232f" 1629 | dependencies = [ 1630 | "darling", 1631 | "proc-macro2", 1632 | "quote", 1633 | "syn 1.0.109", 1634 | ] 1635 | 1636 | [[package]] 1637 | name = "sha2" 1638 | version = "0.10.6" 1639 | source = "registry+https://github.com/rust-lang/crates.io-index" 1640 | checksum = "82e6b795fe2e3b1e845bafcb27aa35405c4d47cdfc92af5fc8d3002f76cebdc0" 1641 | dependencies = [ 1642 | "cfg-if", 1643 | "cpufeatures", 1644 | "digest", 1645 | ] 1646 | 1647 | [[package]] 1648 | name = "sha3" 1649 | version = "0.10.6" 1650 | source = "registry+https://github.com/rust-lang/crates.io-index" 1651 | checksum = "bdf0c33fae925bdc080598b84bc15c55e7b9a4a43b3c704da051f977469691c9" 1652 | dependencies = [ 1653 | "digest", 1654 | "keccak", 1655 | ] 1656 | 1657 | [[package]] 1658 | name = "signature" 1659 | version = "1.6.4" 1660 | source = "registry+https://github.com/rust-lang/crates.io-index" 1661 | checksum = "74233d3b3b2f6d4b006dc19dee745e73e2a6bfb6f93607cd3b02bd5b00797d7c" 1662 | dependencies = [ 1663 | "digest", 1664 | "rand_core", 1665 | ] 1666 | 1667 | [[package]] 1668 | name = "signature" 1669 | version = "2.0.0" 1670 | source = "registry+https://github.com/rust-lang/crates.io-index" 1671 | checksum = "8fe458c98333f9c8152221191a77e2a44e8325d0193484af2e9421a53019e57d" 1672 | dependencies = [ 1673 | "digest", 1674 | "rand_core", 1675 | ] 1676 | 1677 | [[package]] 1678 | name = "spki" 1679 | version = "0.6.0" 1680 | source = "registry+https://github.com/rust-lang/crates.io-index" 1681 | checksum = "67cf02bbac7a337dc36e4f5a693db6c21e7863f45070f7064577eb4367a3212b" 1682 | dependencies = [ 1683 | "base64ct", 1684 | "der 0.6.1", 1685 | ] 1686 | 1687 | [[package]] 1688 | name = "spki" 1689 | version = "0.7.0" 1690 | source = "registry+https://github.com/rust-lang/crates.io-index" 1691 | checksum = "c0445c905640145c7ea8c1993555957f65e7c46d0535b91ba501bc9bfc85522f" 1692 | dependencies = [ 1693 | "base64ct", 1694 | "der 0.7.1", 1695 | ] 1696 | 1697 | [[package]] 1698 | name = "static_assertions" 1699 | version = "1.1.0" 1700 | source = "registry+https://github.com/rust-lang/crates.io-index" 1701 | checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f" 1702 | 1703 | [[package]] 1704 | name = "strsim" 1705 | version = "0.10.0" 1706 | source = "registry+https://github.com/rust-lang/crates.io-index" 1707 | checksum = "73473c0e59e6d5812c5dfe2a064a6444949f089e20eec9a2e5506596494e4623" 1708 | 1709 | [[package]] 1710 | name = "strum" 1711 | version = "0.24.1" 1712 | source = "registry+https://github.com/rust-lang/crates.io-index" 1713 | checksum = "063e6045c0e62079840579a7e47a355ae92f60eb74daaf156fb1e84ba164e63f" 1714 | dependencies = [ 1715 | "strum_macros", 1716 | ] 1717 | 1718 | [[package]] 1719 | name = "strum_macros" 1720 | version = "0.24.3" 1721 | source = "registry+https://github.com/rust-lang/crates.io-index" 1722 | checksum = "1e385be0d24f186b4ce2f9982191e7101bb737312ad61c1f2f984f34bcf85d59" 1723 | dependencies = [ 1724 | "heck", 1725 | "proc-macro2", 1726 | "quote", 1727 | "rustversion", 1728 | "syn 1.0.109", 1729 | ] 1730 | 1731 | [[package]] 1732 | name = "subtle" 1733 | version = "2.4.1" 1734 | source = "registry+https://github.com/rust-lang/crates.io-index" 1735 | checksum = "6bdef32e8150c2a081110b42772ffe7d7c9032b606bc226c8260fd97e0976601" 1736 | 1737 | [[package]] 1738 | name = "sucds" 1739 | version = "0.5.0" 1740 | source = "registry+https://github.com/rust-lang/crates.io-index" 1741 | checksum = "6c1c7f814471a34d2355f9eb25ef3517ec491ac243612b1c83137739998c5444" 1742 | dependencies = [ 1743 | "anyhow", 1744 | ] 1745 | 1746 | [[package]] 1747 | name = "syn" 1748 | version = "1.0.109" 1749 | source = "registry+https://github.com/rust-lang/crates.io-index" 1750 | checksum = "72b64191b275b66ffe2469e8af2c1cfe3bafa67b529ead792a6d0160888b4237" 1751 | dependencies = [ 1752 | "proc-macro2", 1753 | "quote", 1754 | "unicode-ident", 1755 | ] 1756 | 1757 | [[package]] 1758 | name = "syn" 1759 | version = "2.0.6" 1760 | source = "registry+https://github.com/rust-lang/crates.io-index" 1761 | checksum = "ece519cfaf36269ea69d16c363fa1d59ceba8296bbfbfc003c3176d01f2816ee" 1762 | dependencies = [ 1763 | "proc-macro2", 1764 | "quote", 1765 | "unicode-ident", 1766 | ] 1767 | 1768 | [[package]] 1769 | name = "tap" 1770 | version = "1.0.1" 1771 | source = "registry+https://github.com/rust-lang/crates.io-index" 1772 | checksum = "55937e1799185b12863d447f42597ed69d9928686b8d88a1df17376a097d8369" 1773 | 1774 | [[package]] 1775 | name = "tempfile" 1776 | version = "3.4.0" 1777 | source = "registry+https://github.com/rust-lang/crates.io-index" 1778 | checksum = "af18f7ae1acd354b992402e9ec5864359d693cd8a79dcbef59f76891701c1e95" 1779 | dependencies = [ 1780 | "cfg-if", 1781 | "fastrand", 1782 | "redox_syscall", 1783 | "rustix", 1784 | "windows-sys 0.42.0", 1785 | ] 1786 | 1787 | [[package]] 1788 | name = "termcolor" 1789 | version = "1.2.0" 1790 | source = "registry+https://github.com/rust-lang/crates.io-index" 1791 | checksum = "be55cf8942feac5c765c2c993422806843c9a9a45d4d5c407ad6dd2ea95eb9b6" 1792 | dependencies = [ 1793 | "winapi-util", 1794 | ] 1795 | 1796 | [[package]] 1797 | name = "thiserror" 1798 | version = "1.0.40" 1799 | source = "registry+https://github.com/rust-lang/crates.io-index" 1800 | checksum = "978c9a314bd8dc99be594bc3c175faaa9794be04a5a5e153caba6915336cebac" 1801 | dependencies = [ 1802 | "thiserror-impl", 1803 | ] 1804 | 1805 | [[package]] 1806 | name = "thiserror-impl" 1807 | version = "1.0.40" 1808 | source = "registry+https://github.com/rust-lang/crates.io-index" 1809 | checksum = "f9456a42c5b0d803c8cd86e73dd7cc9edd429499f37a3550d286d5e86720569f" 1810 | dependencies = [ 1811 | "proc-macro2", 1812 | "quote", 1813 | "syn 2.0.6", 1814 | ] 1815 | 1816 | [[package]] 1817 | name = "time" 1818 | version = "0.3.20" 1819 | source = "registry+https://github.com/rust-lang/crates.io-index" 1820 | checksum = "cd0cbfecb4d19b5ea75bb31ad904eb5b9fa13f21079c3b92017ebdf4999a5890" 1821 | dependencies = [ 1822 | "itoa", 1823 | "serde", 1824 | "time-core", 1825 | "time-macros", 1826 | ] 1827 | 1828 | [[package]] 1829 | name = "time-core" 1830 | version = "0.1.0" 1831 | source = "registry+https://github.com/rust-lang/crates.io-index" 1832 | checksum = "2e153e1f1acaef8acc537e68b44906d2db6436e2b35ac2c6b42640fff91f00fd" 1833 | 1834 | [[package]] 1835 | name = "time-macros" 1836 | version = "0.2.8" 1837 | source = "registry+https://github.com/rust-lang/crates.io-index" 1838 | checksum = "fd80a657e71da814b8e5d60d3374fc6d35045062245d80224748ae522dd76f36" 1839 | dependencies = [ 1840 | "time-core", 1841 | ] 1842 | 1843 | [[package]] 1844 | name = "tiny-keccak" 1845 | version = "2.0.2" 1846 | source = "registry+https://github.com/rust-lang/crates.io-index" 1847 | checksum = "2c9d3793400a45f954c52e73d068316d76b6f4e36977e3fcebb13a2721e80237" 1848 | dependencies = [ 1849 | "crunchy", 1850 | ] 1851 | 1852 | [[package]] 1853 | name = "tinyvec" 1854 | version = "1.6.0" 1855 | source = "registry+https://github.com/rust-lang/crates.io-index" 1856 | checksum = "87cc5ceb3875bb20c2890005a4e226a4651264a5c75edb2421b52861a0a0cb50" 1857 | dependencies = [ 1858 | "tinyvec_macros", 1859 | ] 1860 | 1861 | [[package]] 1862 | name = "tinyvec_macros" 1863 | version = "0.1.1" 1864 | source = "registry+https://github.com/rust-lang/crates.io-index" 1865 | checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20" 1866 | 1867 | [[package]] 1868 | name = "toml_datetime" 1869 | version = "0.6.1" 1870 | source = "registry+https://github.com/rust-lang/crates.io-index" 1871 | checksum = "3ab8ed2edee10b50132aed5f331333428b011c99402b5a534154ed15746f9622" 1872 | 1873 | [[package]] 1874 | name = "toml_edit" 1875 | version = "0.19.7" 1876 | source = "registry+https://github.com/rust-lang/crates.io-index" 1877 | checksum = "dc18466501acd8ac6a3f615dd29a3438f8ca6bb3b19537138b3106e575621274" 1878 | dependencies = [ 1879 | "indexmap", 1880 | "toml_datetime", 1881 | "winnow", 1882 | ] 1883 | 1884 | [[package]] 1885 | name = "triehash" 1886 | version = "0.8.4" 1887 | source = "registry+https://github.com/rust-lang/crates.io-index" 1888 | checksum = "a1631b201eb031b563d2e85ca18ec8092508e262a3196ce9bd10a67ec87b9f5c" 1889 | dependencies = [ 1890 | "hash-db", 1891 | "rlp", 1892 | ] 1893 | 1894 | [[package]] 1895 | name = "typenum" 1896 | version = "1.16.0" 1897 | source = "registry+https://github.com/rust-lang/crates.io-index" 1898 | checksum = "497961ef93d974e23eb6f433eb5fe1b7930b659f06d12dec6fc44a8f554c0bba" 1899 | 1900 | [[package]] 1901 | name = "uint" 1902 | version = "0.9.5" 1903 | source = "registry+https://github.com/rust-lang/crates.io-index" 1904 | checksum = "76f64bba2c53b04fcab63c01a7d7427eadc821e3bc48c34dc9ba29c501164b52" 1905 | dependencies = [ 1906 | "byteorder", 1907 | "crunchy", 1908 | "hex", 1909 | "static_assertions", 1910 | ] 1911 | 1912 | [[package]] 1913 | name = "unicode-bidi" 1914 | version = "0.3.13" 1915 | source = "registry+https://github.com/rust-lang/crates.io-index" 1916 | checksum = "92888ba5573ff080736b3648696b70cafad7d250551175acbaa4e0385b3e1460" 1917 | 1918 | [[package]] 1919 | name = "unicode-ident" 1920 | version = "1.0.8" 1921 | source = "registry+https://github.com/rust-lang/crates.io-index" 1922 | checksum = "e5464a87b239f13a63a501f2701565754bae92d243d4bb7eb12f6d57d2269bf4" 1923 | 1924 | [[package]] 1925 | name = "unicode-normalization" 1926 | version = "0.1.22" 1927 | source = "registry+https://github.com/rust-lang/crates.io-index" 1928 | checksum = "5c5713f0fc4b5db668a2ac63cdb7bb4469d8c9fed047b1d0292cc7b0ce2ba921" 1929 | dependencies = [ 1930 | "tinyvec", 1931 | ] 1932 | 1933 | [[package]] 1934 | name = "unicode-segmentation" 1935 | version = "1.10.1" 1936 | source = "registry+https://github.com/rust-lang/crates.io-index" 1937 | checksum = "1dd624098567895118886609431a7c3b8f516e41d30e0643f03d94592a147e36" 1938 | 1939 | [[package]] 1940 | name = "unicode-width" 1941 | version = "0.1.10" 1942 | source = "registry+https://github.com/rust-lang/crates.io-index" 1943 | checksum = "c0edd1e5b14653f783770bce4a4dabb4a5108a5370a5f5d8cfe8710c361f6c8b" 1944 | 1945 | [[package]] 1946 | name = "unicode-xid" 1947 | version = "0.2.4" 1948 | source = "registry+https://github.com/rust-lang/crates.io-index" 1949 | checksum = "f962df74c8c05a667b5ee8bcf162993134c104e96440b663c8daa176dc772d8c" 1950 | 1951 | [[package]] 1952 | name = "url" 1953 | version = "2.3.1" 1954 | source = "registry+https://github.com/rust-lang/crates.io-index" 1955 | checksum = "0d68c799ae75762b8c3fe375feb6600ef5602c883c5d21eb51c09f22b83c4643" 1956 | dependencies = [ 1957 | "form_urlencoded", 1958 | "idna", 1959 | "percent-encoding", 1960 | ] 1961 | 1962 | [[package]] 1963 | name = "version_check" 1964 | version = "0.9.4" 1965 | source = "registry+https://github.com/rust-lang/crates.io-index" 1966 | checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f" 1967 | 1968 | [[package]] 1969 | name = "wasi" 1970 | version = "0.11.0+wasi-snapshot-preview1" 1971 | source = "registry+https://github.com/rust-lang/crates.io-index" 1972 | checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" 1973 | 1974 | [[package]] 1975 | name = "wasm-bindgen" 1976 | version = "0.2.84" 1977 | source = "registry+https://github.com/rust-lang/crates.io-index" 1978 | checksum = "31f8dcbc21f30d9b8f2ea926ecb58f6b91192c17e9d33594b3df58b2007ca53b" 1979 | dependencies = [ 1980 | "cfg-if", 1981 | "wasm-bindgen-macro", 1982 | ] 1983 | 1984 | [[package]] 1985 | name = "wasm-bindgen-backend" 1986 | version = "0.2.84" 1987 | source = "registry+https://github.com/rust-lang/crates.io-index" 1988 | checksum = "95ce90fd5bcc06af55a641a86428ee4229e44e07033963a2290a8e241607ccb9" 1989 | dependencies = [ 1990 | "bumpalo", 1991 | "log", 1992 | "once_cell", 1993 | "proc-macro2", 1994 | "quote", 1995 | "syn 1.0.109", 1996 | "wasm-bindgen-shared", 1997 | ] 1998 | 1999 | [[package]] 2000 | name = "wasm-bindgen-macro" 2001 | version = "0.2.84" 2002 | source = "registry+https://github.com/rust-lang/crates.io-index" 2003 | checksum = "4c21f77c0bedc37fd5dc21f897894a5ca01e7bb159884559461862ae90c0b4c5" 2004 | dependencies = [ 2005 | "quote", 2006 | "wasm-bindgen-macro-support", 2007 | ] 2008 | 2009 | [[package]] 2010 | name = "wasm-bindgen-macro-support" 2011 | version = "0.2.84" 2012 | source = "registry+https://github.com/rust-lang/crates.io-index" 2013 | checksum = "2aff81306fcac3c7515ad4e177f521b5c9a15f2b08f4e32d823066102f35a5f6" 2014 | dependencies = [ 2015 | "proc-macro2", 2016 | "quote", 2017 | "syn 1.0.109", 2018 | "wasm-bindgen-backend", 2019 | "wasm-bindgen-shared", 2020 | ] 2021 | 2022 | [[package]] 2023 | name = "wasm-bindgen-shared" 2024 | version = "0.2.84" 2025 | source = "registry+https://github.com/rust-lang/crates.io-index" 2026 | checksum = "0046fef7e28c3804e5e38bfa31ea2a0f73905319b677e57ebe37e49358989b5d" 2027 | 2028 | [[package]] 2029 | name = "winapi" 2030 | version = "0.3.9" 2031 | source = "registry+https://github.com/rust-lang/crates.io-index" 2032 | checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419" 2033 | dependencies = [ 2034 | "winapi-i686-pc-windows-gnu", 2035 | "winapi-x86_64-pc-windows-gnu", 2036 | ] 2037 | 2038 | [[package]] 2039 | name = "winapi-i686-pc-windows-gnu" 2040 | version = "0.4.0" 2041 | source = "registry+https://github.com/rust-lang/crates.io-index" 2042 | checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" 2043 | 2044 | [[package]] 2045 | name = "winapi-util" 2046 | version = "0.1.5" 2047 | source = "registry+https://github.com/rust-lang/crates.io-index" 2048 | checksum = "70ec6ce85bb158151cae5e5c87f95a8e97d2c0c4b001223f33a334e3ce5de178" 2049 | dependencies = [ 2050 | "winapi", 2051 | ] 2052 | 2053 | [[package]] 2054 | name = "winapi-x86_64-pc-windows-gnu" 2055 | version = "0.4.0" 2056 | source = "registry+https://github.com/rust-lang/crates.io-index" 2057 | checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" 2058 | 2059 | [[package]] 2060 | name = "windows" 2061 | version = "0.46.0" 2062 | source = "registry+https://github.com/rust-lang/crates.io-index" 2063 | checksum = "cdacb41e6a96a052c6cb63a144f24900236121c6f63f4f8219fef5977ecb0c25" 2064 | dependencies = [ 2065 | "windows-targets", 2066 | ] 2067 | 2068 | [[package]] 2069 | name = "windows-sys" 2070 | version = "0.42.0" 2071 | source = "registry+https://github.com/rust-lang/crates.io-index" 2072 | checksum = "5a3e1820f08b8513f676f7ab6c1f99ff312fb97b553d30ff4dd86f9f15728aa7" 2073 | dependencies = [ 2074 | "windows_aarch64_gnullvm", 2075 | "windows_aarch64_msvc", 2076 | "windows_i686_gnu", 2077 | "windows_i686_msvc", 2078 | "windows_x86_64_gnu", 2079 | "windows_x86_64_gnullvm", 2080 | "windows_x86_64_msvc", 2081 | ] 2082 | 2083 | [[package]] 2084 | name = "windows-sys" 2085 | version = "0.45.0" 2086 | source = "registry+https://github.com/rust-lang/crates.io-index" 2087 | checksum = "75283be5efb2831d37ea142365f009c02ec203cd29a3ebecbc093d52315b66d0" 2088 | dependencies = [ 2089 | "windows-targets", 2090 | ] 2091 | 2092 | [[package]] 2093 | name = "windows-targets" 2094 | version = "0.42.2" 2095 | source = "registry+https://github.com/rust-lang/crates.io-index" 2096 | checksum = "8e5180c00cd44c9b1c88adb3693291f1cd93605ded80c250a75d472756b4d071" 2097 | dependencies = [ 2098 | "windows_aarch64_gnullvm", 2099 | "windows_aarch64_msvc", 2100 | "windows_i686_gnu", 2101 | "windows_i686_msvc", 2102 | "windows_x86_64_gnu", 2103 | "windows_x86_64_gnullvm", 2104 | "windows_x86_64_msvc", 2105 | ] 2106 | 2107 | [[package]] 2108 | name = "windows_aarch64_gnullvm" 2109 | version = "0.42.2" 2110 | source = "registry+https://github.com/rust-lang/crates.io-index" 2111 | checksum = "597a5118570b68bc08d8d59125332c54f1ba9d9adeedeef5b99b02ba2b0698f8" 2112 | 2113 | [[package]] 2114 | name = "windows_aarch64_msvc" 2115 | version = "0.42.2" 2116 | source = "registry+https://github.com/rust-lang/crates.io-index" 2117 | checksum = "e08e8864a60f06ef0d0ff4ba04124db8b0fb3be5776a5cd47641e942e58c4d43" 2118 | 2119 | [[package]] 2120 | name = "windows_i686_gnu" 2121 | version = "0.42.2" 2122 | source = "registry+https://github.com/rust-lang/crates.io-index" 2123 | checksum = "c61d927d8da41da96a81f029489353e68739737d3beca43145c8afec9a31a84f" 2124 | 2125 | [[package]] 2126 | name = "windows_i686_msvc" 2127 | version = "0.42.2" 2128 | source = "registry+https://github.com/rust-lang/crates.io-index" 2129 | checksum = "44d840b6ec649f480a41c8d80f9c65108b92d89345dd94027bfe06ac444d1060" 2130 | 2131 | [[package]] 2132 | name = "windows_x86_64_gnu" 2133 | version = "0.42.2" 2134 | source = "registry+https://github.com/rust-lang/crates.io-index" 2135 | checksum = "8de912b8b8feb55c064867cf047dda097f92d51efad5b491dfb98f6bbb70cb36" 2136 | 2137 | [[package]] 2138 | name = "windows_x86_64_gnullvm" 2139 | version = "0.42.2" 2140 | source = "registry+https://github.com/rust-lang/crates.io-index" 2141 | checksum = "26d41b46a36d453748aedef1486d5c7a85db22e56aff34643984ea85514e94a3" 2142 | 2143 | [[package]] 2144 | name = "windows_x86_64_msvc" 2145 | version = "0.42.2" 2146 | source = "registry+https://github.com/rust-lang/crates.io-index" 2147 | checksum = "9aec5da331524158c6d1a4ac0ab1541149c0b9505fde06423b02f5ef0106b9f0" 2148 | 2149 | [[package]] 2150 | name = "winnow" 2151 | version = "0.3.6" 2152 | source = "registry+https://github.com/rust-lang/crates.io-index" 2153 | checksum = "23d020b441f92996c80d94ae9166e8501e59c7bb56121189dc9eab3bd8216966" 2154 | dependencies = [ 2155 | "memchr", 2156 | ] 2157 | 2158 | [[package]] 2159 | name = "wyz" 2160 | version = "0.5.1" 2161 | source = "registry+https://github.com/rust-lang/crates.io-index" 2162 | checksum = "05f360fc0b24296329c78fda852a1e9ae82de9cf7b27dae4b7f62f118f77b9ed" 2163 | dependencies = [ 2164 | "tap", 2165 | ] 2166 | 2167 | [[package]] 2168 | name = "zeroize" 2169 | version = "1.5.7" 2170 | source = "registry+https://github.com/rust-lang/crates.io-index" 2171 | checksum = "c394b5bd0c6f669e7275d9c20aa90ae064cb22e75a1cad54e1b34088034b149f" 2172 | -------------------------------------------------------------------------------- /crates/mpt/fuzz/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "mpt-fuzz" 3 | version = "0.0.0" 4 | publish = false 5 | edition = "2021" 6 | 7 | [package.metadata] 8 | cargo-fuzz = true 9 | 10 | [dependencies] 11 | libfuzzer-sys = "0.4" 12 | 13 | [dependencies.mpt] 14 | path = ".." 15 | 16 | # Prevent this from interfering with workspaces 17 | [workspace] 18 | members = ["."] 19 | 20 | [profile.release] 21 | debug = 1 22 | 23 | # We need to patch these crates because reth does so as well 24 | # and we rely on reth for primitives, hashing, & RLP. 25 | [patch.crates-io] 26 | # revm = { git = "https://github.com/bluealloy/revm" } 27 | revm-primitives = { git = "https://github.com/bluealloy/revm" } 28 | # patched for quantity U256 responses 29 | ruint = { git = "https://github.com/paradigmxyz/uint" } 30 | 31 | [[bin]] 32 | name = "mpt_insert_get" 33 | path = "fuzz_targets/mpt_insert_get.rs" 34 | test = false 35 | doc = false 36 | -------------------------------------------------------------------------------- /crates/mpt/fuzz/fuzz_targets/mpt_insert_get.rs: -------------------------------------------------------------------------------- 1 | #![no_main] 2 | 3 | use libfuzzer_sys::fuzz_target; 4 | use mpt::MPT; 5 | use std::collections::HashMap; 6 | 7 | fuzz_target!(|input: Vec<(Vec, Vec)>| { 8 | let mut map = HashMap::new(); 9 | let mut mpt = MPT::default(); 10 | for (k, v) in input.iter() { 11 | map.insert(k.clone(), v.clone()); 12 | mpt.insert(k.clone(), v.clone()); 13 | } 14 | for (k, v) in map { 15 | let stored = mpt.get(k.clone()).unwrap(); 16 | assert_eq!(stored, &v[..], "MPT value != input value"); 17 | } 18 | }); 19 | -------------------------------------------------------------------------------- /crates/mpt/src/display.rs: -------------------------------------------------------------------------------- 1 | use crate::{BranchNode, ExtensionNode, ValueNode, MPT}; 2 | use std::fmt::Debug; 3 | 4 | impl Debug for MPT { 5 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { 6 | f.write_fmt(format_args!("root: {:#?}\n", &self.root))?; 7 | for (k, v) in self.db.iter() { 8 | f.write_fmt(format_args!("{k:?}\t0x{}\n", hex::encode(v)))?; 9 | } 10 | Ok(()) 11 | } 12 | } 13 | 14 | impl Debug for BranchNode { 15 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { 16 | // TODO: Use f.alternate() 17 | for (i, v) in self.children.iter().enumerate() { 18 | f.write_fmt(format_args!("{i:x}: {v:#?}\n"))?; 19 | } 20 | f.write_fmt(format_args!("value: {:#?}", self.branch_value))?; 21 | Ok(()) 22 | } 23 | } 24 | 25 | impl Debug for ExtensionNode { 26 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { 27 | f.write_fmt(format_args!("nibbles: {:x?}\n", &self.nibbles))?; 28 | f.write_fmt(format_args!("compact: {:x?}\n", self.compact()))?; 29 | f.write_fmt(format_args!("child: {:#?}", self.child))?; 30 | Ok(()) 31 | } 32 | } 33 | 34 | impl Debug for ValueNode { 35 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { 36 | f.write_fmt(format_args!("{:x?}", &self.value))?; 37 | Ok(()) 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /crates/mpt/src/lib.rs: -------------------------------------------------------------------------------- 1 | use crate::misc::*; 2 | use core::types::{keccak, Hash}; 3 | use std::{collections::HashMap, fmt::Debug}; 4 | 5 | mod display; 6 | mod misc; 7 | #[cfg(test)] 8 | mod test; 9 | 10 | #[derive(Default)] 11 | pub struct MPT { 12 | root: Node, 13 | db: HashMap>, 14 | } 15 | 16 | impl MPT { 17 | pub fn hash(&mut self) -> Hash { 18 | keccak(self.root.rlp_bytes(&mut self.db)) 19 | } 20 | 21 | pub fn insert(&mut self, k: Vec, v: Vec) { 22 | let k = bytes_to_nibbles(&k); 23 | let root = std::mem::take(&mut self.root); 24 | self.root = root.insert(&k, v); 25 | } 26 | 27 | pub fn get(&self, k: Vec) -> Option<&[u8]> { 28 | self.root.get(&bytes_to_nibbles(&k)) 29 | } 30 | } 31 | 32 | #[derive(Debug)] 33 | enum Node { 34 | Empty, 35 | Branch(BranchNode), 36 | Extension(ExtensionNode), 37 | Value(ValueNode), 38 | } 39 | 40 | impl Node { 41 | fn new(nibbles: &[u8], child: Node) -> Self { 42 | if nibbles.is_empty() { 43 | child 44 | } else { 45 | ExtensionNode::new_node(nibbles.to_owned(), Box::new(child)) 46 | } 47 | } 48 | 49 | fn new_value(value: Vec) -> Self { 50 | Node::Value(ValueNode::new(value)) 51 | } 52 | 53 | fn insert(self, nibbles: &[u8], value: Vec) -> Self { 54 | match self { 55 | Node::Empty => Node::new(nibbles, Node::new_value(value)), 56 | Node::Branch(node) => node.insert(nibbles, value), 57 | Node::Extension(node) => node.insert(nibbles, value), 58 | Node::Value(node) => { 59 | if nibbles.is_empty() { 60 | Node::new_value(value) 61 | } else { 62 | BranchNode::new_with_value(node).insert(nibbles, value) 63 | } 64 | } 65 | } 66 | } 67 | 68 | fn get(&self, nibbles: &[u8]) -> Option<&[u8]> { 69 | match self { 70 | Node::Empty => None, 71 | Node::Branch(node) => node.get(nibbles), 72 | Node::Extension(node) => node.get(nibbles), 73 | Node::Value(node) => node.get(nibbles), 74 | } 75 | } 76 | 77 | fn rlp_bytes(&mut self, db: &mut HashMap>) -> Vec { 78 | match self { 79 | Node::Empty => vec![0x80], 80 | Node::Branch(node) => node.rlp_bytes(db), 81 | Node::Extension(node) => node.rlp_bytes(db), 82 | Node::Value(node) => node.rlp_bytes(db), 83 | } 84 | } 85 | } 86 | 87 | impl Default for Node { 88 | fn default() -> Self { 89 | Self::Empty 90 | } 91 | } 92 | 93 | #[derive(Default)] 94 | struct BranchNode { 95 | children: [Box; 16], 96 | branch_value: Option, 97 | } 98 | 99 | impl BranchNode { 100 | // inserts adds a key/value to a branch node as either a sub-node or as a value. 101 | // It returns none if there is an error. 102 | fn insert(mut self, nibbles: &[u8], value: Vec) -> Node { 103 | if nibbles.is_empty() { 104 | self.branch_value = Some(ValueNode::new(value)); 105 | } else { 106 | let i = nibbles[0] as usize; 107 | *self.children[i] = std::mem::take(&mut self.children[i]).insert(&nibbles[1..], value); 108 | }; 109 | self.into() 110 | } 111 | 112 | fn get(&self, nibbles: &[u8]) -> Option<&[u8]> { 113 | if nibbles.is_empty() { 114 | self.branch_value.as_ref().map(|v| &v.value[..]) 115 | } else { 116 | self.children[nibbles[0] as usize].get(&nibbles[1..]) 117 | } 118 | } 119 | 120 | // new_with_node creates a new branch node that contains a given child node. 121 | fn new_with_node(key: u8, node: Box) -> Self { 122 | let mut branch_node = BranchNode::default(); 123 | branch_node.children[key as usize] = node; 124 | branch_node 125 | } 126 | 127 | // new_with_value creates a new branch node that contains the given value. 128 | fn new_with_value(value: ValueNode) -> Self { 129 | BranchNode { 130 | branch_value: Some(value), 131 | ..Default::default() 132 | } 133 | } 134 | 135 | fn rlp_bytes(&mut self, db: &mut HashMap>) -> Vec { 136 | let mut list: Vec = Vec::new(); 137 | let mut bytes = Vec::new(); 138 | for child in self.children.iter_mut() { 139 | list.push(mpt_hash(&child.rlp_bytes(db), db)); 140 | } 141 | match &self.branch_value { 142 | Some(value) => list.push(mpt_hash(&value.rlp_bytes(db), db)), 143 | None => list.push(RLPEncodeableWrapper::EmptyString), 144 | } 145 | reth_rlp::encode_list(&list, &mut bytes); 146 | bytes 147 | } 148 | } 149 | 150 | impl From for Node { 151 | fn from(value: BranchNode) -> Self { 152 | Node::Branch(value) 153 | } 154 | } 155 | 156 | struct ExtensionNode { 157 | nibbles: Vec, 158 | child: Box, 159 | } 160 | 161 | impl ExtensionNode { 162 | fn new_node(nibbles: Vec, child: Box) -> Node { 163 | Node::Extension(Self { nibbles, child }) 164 | } 165 | 166 | fn compact(&self) -> Vec { 167 | let extension = match *self.child { 168 | Node::Empty => panic!("Cannot point to an empty node in an extension"), 169 | Node::Extension(..) => panic!("Cannot point to an extension node in an extension node"), 170 | Node::Value(..) => false, 171 | Node::Branch(..) => true, 172 | }; 173 | nibbles_to_compact(&self.nibbles, extension) 174 | } 175 | 176 | fn insert(self, nibbles: &[u8], value: Vec) -> Node { 177 | let (common, new_nibbles, old_nibbles) = match_paths(nibbles, &self.nibbles); 178 | if new_nibbles.is_empty() && old_nibbles.is_empty() { 179 | return ExtensionNode::new_node(common, Box::new(self.child.insert(&[], value))); 180 | } 181 | // Inserting here will alwasy create branch node. 182 | // Turn the existing node into that branch node then insert the new value. 183 | let branch_node = if old_nibbles.is_empty() { 184 | match *self.child { 185 | Node::Empty => panic!("Cannot point to an empty node in an extension"), 186 | Node::Extension(..) => panic!("Cannot point to an extension node in an extension node"), 187 | Node::Value(child) => BranchNode::new_with_value(child), 188 | Node::Branch(child) => child, 189 | } 190 | } else { 191 | let child = Box::new(Node::new(&old_nibbles[1..], *(self.child))); 192 | BranchNode::new_with_node(old_nibbles[0], child) 193 | } 194 | .insert(new_nibbles, value); 195 | // Create an extension node based on the common part if needed. 196 | if common.is_empty() { 197 | branch_node 198 | } else { 199 | ExtensionNode::new_node(common, Box::new(branch_node)) 200 | } 201 | } 202 | 203 | fn get(&self, nibbles: &[u8]) -> Option<&[u8]> { 204 | let (_, new_nibbles, old_nibbles) = match_paths(nibbles, &self.nibbles); 205 | if old_nibbles.is_empty() { 206 | self.child.get(new_nibbles) 207 | } else { 208 | None 209 | } 210 | } 211 | 212 | fn rlp_bytes(&mut self, db: &mut HashMap>) -> Vec { 213 | let mut bytes = Vec::new(); 214 | let list = vec![RLPEncodeableWrapper::Bytes(self.compact()), mpt_hash(&self.child.rlp_bytes(db), db)]; 215 | reth_rlp::encode_list(&list, &mut bytes); 216 | bytes 217 | } 218 | } 219 | 220 | struct ValueNode { 221 | value: Vec, 222 | } 223 | 224 | impl ValueNode { 225 | fn new(value: Vec) -> Self { 226 | Self { value } 227 | } 228 | fn get(&self, _nibbles: &[u8]) -> Option<&[u8]> { 229 | if _nibbles.is_empty() { 230 | Some(&self.value) 231 | } else { 232 | None 233 | } 234 | // // TODO: Intentional bug to see if fuzzing will catch it. 235 | // // It did not b/c I did not fuzz by querying with known missing keys. 236 | // Some(&self.value) 237 | } 238 | fn rlp_bytes(&self, _: &mut HashMap>) -> Vec { 239 | encode_bytes(self.value.clone()) 240 | } 241 | } 242 | -------------------------------------------------------------------------------- /crates/mpt/src/misc.rs: -------------------------------------------------------------------------------- 1 | use core::types::{keccak, Hash}; 2 | use reth_primitives::Bytes; 3 | use reth_rlp::Encodable; 4 | use std::{collections::HashMap, fmt::Debug, iter::zip}; 5 | 6 | #[derive(Debug)] 7 | pub enum RLPEncodeableWrapper { 8 | EmptyString, 9 | Bytes(Vec), 10 | Raw(Vec), 11 | } 12 | 13 | impl Encodable for RLPEncodeableWrapper { 14 | fn encode(&self, out: &mut dyn reth_rlp::BufMut) { 15 | match self { 16 | Self::EmptyString => out.put_u8(0x80), 17 | Self::Bytes(value) => out.put_slice(&encode_bytes(value.clone())), 18 | Self::Raw(value) => out.put_slice(value), 19 | } 20 | } 21 | } 22 | 23 | // encode_bytes encodes a vec as a byte string instead of a list of u8s. 24 | pub fn encode_bytes(x: Vec) -> Vec { 25 | let mut out = Vec::new(); 26 | let b: Bytes = x.into(); 27 | b.encode(&mut out); 28 | out 29 | } 30 | 31 | // mpt_hash implements H(x) as used in the MPT. 32 | pub fn mpt_hash(x: &[u8], db: &mut HashMap>) -> RLPEncodeableWrapper { 33 | if x.len() < 32 { 34 | RLPEncodeableWrapper::Raw(x.to_vec()) 35 | } else { 36 | let h = keccak(x); 37 | db.insert(h, x.to_vec()); 38 | RLPEncodeableWrapper::Bytes(h.to_vec()) 39 | } 40 | } 41 | 42 | // match_paths is a helper function that returns the shared bytes between a & b as well 43 | // the remaining bytes in a & b. 44 | pub fn match_paths<'a, 'b>(key: &'a [u8], path: &'b [u8]) -> (Vec, &'a [u8], &'b [u8]) { 45 | let mut common = Vec::new(); 46 | for (a, b) in zip(key, path) { 47 | if a == b { 48 | common.push(*a) 49 | } else { 50 | break; 51 | } 52 | } 53 | let i = common.len(); 54 | (common, &key[i..], &path[i..]) 55 | } 56 | 57 | // bytes_to_nibbles splits a list of bytes into a list of nibbles 58 | pub fn bytes_to_nibbles(key: &[u8]) -> Vec { 59 | let mut out = Vec::new(); 60 | for byte in key { 61 | out.push(byte >> 4); 62 | out.push(byte & 0x0f); 63 | } 64 | out 65 | } 66 | 67 | // nibbles_to_compact turns a list of nibbles into Ethereum's compact encoding scheme. 68 | // It prefixes the parity of the nibbles length & if it's an extension into the first nibble 69 | // and then folds the nibbles into bytes. 70 | pub fn nibbles_to_compact(nibbles: &[u8], extension: bool) -> Vec { 71 | let mut key = nibbles; 72 | let mut out = Vec::new(); 73 | let even = key.len() % 2 == 0; 74 | let mut first = match (extension, even) { 75 | (true, true) => 0, 76 | (true, false) => 1, 77 | (false, true) => 2, 78 | (false, false) => 3, 79 | } << 4; 80 | if !key.is_empty() && !even { 81 | first |= key[0]; 82 | key = &key[1..]; 83 | } 84 | out.push(first); 85 | for a in key.chunks_exact(2) { 86 | out.push(a[0] << 4 | a[1]); 87 | } 88 | out 89 | } 90 | 91 | // compact_to_nibbles decodes Ethereum's compact encoding into the original nibbles 92 | // array and also returns if the path was an extension or not. 93 | #[allow(dead_code)] 94 | pub fn compact_to_nibbles(compact: &[u8]) -> (Vec, bool) { 95 | let (extension, even) = match compact[0] >> 4 { 96 | 0 => (true, true), 97 | 1 => (true, false), 98 | 2 => (false, true), 99 | 3 => (false, false), 100 | _ => panic!("out of range"), 101 | }; 102 | let mut nibbles = Vec::new(); 103 | if !even { 104 | nibbles.push(compact[0] & 0x0f); 105 | } 106 | for b in &compact[1..] { 107 | nibbles.push(b >> 4); 108 | nibbles.push(b & 0x0f); 109 | } 110 | (nibbles, extension) 111 | } 112 | -------------------------------------------------------------------------------- /crates/mpt/src/test.rs: -------------------------------------------------------------------------------- 1 | use crate::*; 2 | use core::hash_literal; 3 | 4 | struct NibblesCompactTestCase { 5 | nibbles: Vec, 6 | compact: Vec, 7 | extension: bool, 8 | } 9 | 10 | #[test] 11 | fn test_nibbles_compact_conversions() { 12 | let tests = vec![ 13 | NibblesCompactTestCase { 14 | nibbles: vec![1, 2, 3, 4, 5], 15 | compact: vec![0x11, 0x23, 0x45], 16 | extension: true, 17 | }, 18 | NibblesCompactTestCase { 19 | nibbles: vec![0, 1, 2, 3, 4, 5], 20 | compact: vec![0x00, 0x01, 0x23, 0x45], 21 | extension: true, 22 | }, 23 | NibblesCompactTestCase { 24 | nibbles: vec![], 25 | compact: vec![0x00], 26 | extension: true, 27 | }, 28 | NibblesCompactTestCase { 29 | nibbles: vec![1], 30 | compact: vec![0x11], 31 | extension: true, 32 | }, 33 | NibblesCompactTestCase { 34 | nibbles: vec![1, 2], 35 | compact: vec![0x00, 0x12], 36 | extension: true, 37 | }, 38 | NibblesCompactTestCase { 39 | nibbles: vec![0x00, 0x0f, 0x01, 0x0c, 0x0b, 0x08], 40 | compact: vec![0x20, 0x0f, 0x1c, 0xb8], 41 | extension: false, 42 | }, 43 | NibblesCompactTestCase { 44 | nibbles: vec![0x0f, 0x01, 0x0c, 0x0b, 0x08], 45 | compact: vec![0x3f, 0x1c, 0xb8], 46 | extension: false, 47 | }, 48 | NibblesCompactTestCase { 49 | nibbles: vec![], 50 | compact: vec![0x20], 51 | extension: false, 52 | }, 53 | NibblesCompactTestCase { 54 | nibbles: vec![1], 55 | compact: vec![0x31], 56 | extension: false, 57 | }, 58 | NibblesCompactTestCase { 59 | nibbles: vec![1, 2], 60 | compact: vec![0x20, 0x12], 61 | extension: false, 62 | }, 63 | ]; 64 | 65 | for test in tests { 66 | let actual_compact = nibbles_to_compact(&test.nibbles, test.extension); 67 | assert_eq!(test.compact, actual_compact); 68 | let (actual_nibbles, actual_ext) = compact_to_nibbles(&test.compact); 69 | assert_eq!(test.nibbles, actual_nibbles); 70 | assert_eq!(test.extension, actual_ext); 71 | } 72 | } 73 | 74 | #[test] 75 | fn test_empty_root_hash() { 76 | let mut mpt = MPT::default(); 77 | let hash = mpt.hash(); 78 | let expected = hash_literal!("56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421"); 79 | assert_eq!(hash, expected); 80 | } 81 | 82 | #[test] 83 | fn test_mpt_get() { 84 | let mut mpt = MPT::default(); 85 | let inputs = vec![("do", "verb"), ("dog", "puppy"), ("doge", "coin"), ("horse", "stallion")]; 86 | for (k, v) in inputs.iter() { 87 | mpt.insert(k.as_bytes().to_vec(), v.as_bytes().to_vec()); 88 | } 89 | for (k, v) in inputs { 90 | assert_eq!(mpt.get(k.into()), Some(v.as_bytes())); 91 | } 92 | assert_eq!(mpt.get("".into()), None); 93 | assert_eq!(mpt.get("dogf".into()), None); 94 | assert_eq!(mpt.get("hors".into()), None); 95 | // assert_eq!(mpt.get("horses".into()), None); // TODO: Find this bug with fuzzing. 96 | } 97 | 98 | #[test] 99 | // Found via fuzzing 100 | fn test_mpt_empty_overwrite() { 101 | let mut mpt = MPT::default(); 102 | mpt.insert(vec![], vec![]); 103 | mpt.insert(vec![2], vec![0]); 104 | mpt.insert(vec![], vec![]); 105 | 106 | assert_eq!(mpt.get(vec![]), Some(vec![].as_slice())); 107 | assert_eq!(mpt.get(vec![2]), Some(vec![0].as_slice())); 108 | } 109 | 110 | #[test] 111 | // Found via fuzzing 112 | fn test_mpt_overwrite_value_of_extension_node() { 113 | let mut mpt = MPT::default(); 114 | mpt.insert(vec![0], vec![]); 115 | mpt.insert(vec![0], vec![0]); 116 | mpt.insert(vec![], vec![]); 117 | 118 | assert_eq!(mpt.get(vec![]), Some(vec![].as_slice())); 119 | assert_eq!(mpt.get(vec![0]), Some(vec![0].as_slice())); 120 | } 121 | 122 | #[test] 123 | fn test_mpt_overwrite() { 124 | let mut mpt = MPT::default(); 125 | let inputs = vec![ 126 | ("do", "verb"), 127 | ("dog", "puppy"), 128 | ("doge", "coin"), 129 | ("horse", "stallion"), 130 | ("doge", "moon"), 131 | ("horse", "mare"), 132 | ]; 133 | for (k, v) in inputs.iter() { 134 | mpt.insert(k.as_bytes().to_vec(), v.as_bytes().to_vec()); 135 | } 136 | assert_eq!(mpt.get("doge".into()), Some("moon".as_bytes())); 137 | assert_eq!(mpt.get("horse".into()), Some("mare".as_bytes())); 138 | } 139 | 140 | #[test] 141 | fn test_mpt_prefix_get() { 142 | let mut mpt = MPT::default(); 143 | let inputs = vec![("do", "verb"), ("dog", "puppy"), ("doge", "coin"), ("horse", "stallion")]; 144 | for (k, v) in inputs.iter() { 145 | mpt.insert(k.as_bytes().to_vec(), v.as_bytes().to_vec()); 146 | } 147 | assert_eq!(mpt.get("d".into()), None); 148 | assert_eq!(mpt.get("dodo".into()), None); 149 | assert_eq!(mpt.get("doges".into()), None); 150 | assert_eq!(mpt.get("horses".into()), None); 151 | } 152 | 153 | // Test MPT from https://ethereum.org/en/developers/docs/data-structures-and-encoding/patricia-merkle-trie/ 154 | // ('do', 'verb'), ('dog', 'puppy'), ('doge', 'coin'), ('horse', 'stallion'). 155 | // <64 6f> : 'verb' 156 | // <64 6f 67> : 'puppy' 157 | // <64 6f 67 65> : 'coin' 158 | // <68 6f 72 73 65> : 'stallion' 159 | // 160 | // Now, we build such a trie with the following key/value pairs in the underlying DB: 161 | // 162 | // rootHash: [ <16>, hashA ] 163 | // hashA: [ <>, <>, <>, <>, hashB, <>, <>, <>, [ <20 6f 72 73 65>, 'stallion' ], <>, <>, <>, <>, <>, <>, <>, <> ] 164 | // hashB: [ <00 6f>, hashD ] 165 | // hashD: [ <>, <>, <>, <>, <>, <>, hashE, <>, <>, <>, <>, <>, <>, <>, <>, <>, 'verb' ] 166 | // hashE: [ <17>, [ <>, <>, <>, <>, <>, <>, [ <35>, 'coin' ], <>, <>, <>, <>, <>, <>, <>, <>, <>, 'puppy' ] ] 167 | // Script to generate the hashes 168 | // // go 1.19 169 | // // require github.com/ethereum/go-ethereum v1.11.2 170 | // package main 171 | 172 | // import ( 173 | // "fmt" 174 | 175 | // "github.com/ethereum/go-ethereum/trie" 176 | // "github.com/ethereum/go-ethereum/core/rawdb" 177 | // ) 178 | 179 | // func main() { 180 | // // ('do', 'verb'), ('dog', 'puppy'), ('doge', 'coin'), ('horse', 'stallion'). 181 | // t := trie.NewEmpty(trie.NewDatabase(rawdb.NewMemoryDatabase())) 182 | // t.Update([]byte("do"), []byte("verb")) 183 | // t.Update([]byte("dog"), []byte("puppy")) 184 | // t.Update([]byte("doge"), []byte("coin")) 185 | // t.Update([]byte("horse"), []byte("stallion")) 186 | // fmt.Println(t.Hash()) 187 | // } 188 | #[test] 189 | fn test_mpt_hash() { 190 | let mut mpt = MPT::default(); 191 | 192 | mpt.insert("do".into(), "verb".into()); 193 | let hash = mpt.hash(); 194 | let expected_hash: Hash = hash_literal!("014f07ed95e2e028804d915e0dbd4ed451e394e1acfd29e463c11a060b2ddef7"); 195 | assert_eq!(expected_hash, hash); 196 | 197 | mpt.insert("dog".into(), "puppy".into()); 198 | let hash = mpt.hash(); 199 | let expected_hash: Hash = hash_literal!("779db3986dd4f38416bfde49750ef7b13c6ecb3e2221620bcad9267e94604d36"); 200 | assert_eq!(expected_hash, hash); 201 | 202 | mpt.insert("doge".into(), "coin".into()); 203 | let hash = mpt.hash(); 204 | let expected_hash: Hash = hash_literal!("ef7b2fe20f5d2c30c46ad4d83c39811bcbf1721aef2e805c0e107947320888b6"); 205 | assert_eq!(expected_hash, hash); 206 | 207 | mpt.insert("horse".into(), "stallion".into()); 208 | let hash = mpt.hash(); 209 | let expected_hash: Hash = hash_literal!("5991bb8c6514148a29db676a14ac506cd2cd5775ace63c30a4fe457715e9ac84"); 210 | assert_eq!(expected_hash, hash); 211 | } 212 | -------------------------------------------------------------------------------- /rnode/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "rnode" 3 | version = "0.1.0" 4 | edition = "2021" 5 | 6 | 7 | [dependencies] 8 | client = {path = "../crates/client"} 9 | core = {path = "../crates/core"} 10 | derivation = {path = "../crates/derivation"} 11 | mpt = {path = "../crates/mpt"} 12 | 13 | eyre = "0.6.8" 14 | dotenv = "0.15.0" 15 | hex-literal = "0.4.1" 16 | -------------------------------------------------------------------------------- /rnode/src/main.rs: -------------------------------------------------------------------------------- 1 | use dotenv::dotenv; 2 | use eyre::Result; 3 | 4 | use client::prelude::*; 5 | use derivation::derivation::Derivation; 6 | 7 | fn main() -> Result<()> { 8 | // Load environment variables from local ".env" file 9 | dotenv().ok(); 10 | 11 | let provider = std::env::var("RPC")?; 12 | let mut provider = Client::new(&provider)?; 13 | 14 | let mut derivation = Derivation::new(core::chain_config::GOERLI_CONFIG); 15 | derivation.run(8300532, 8300533, &mut provider); 16 | 17 | Ok(()) 18 | } 19 | -------------------------------------------------------------------------------- /rust-toolchain.toml: -------------------------------------------------------------------------------- 1 | [toolchain] 2 | channel = "nightly" 3 | 4 | -------------------------------------------------------------------------------- /rustfmt.toml: -------------------------------------------------------------------------------- 1 | max_width=140 2 | tab_spaces=8 3 | hard_tabs=true 4 | -------------------------------------------------------------------------------- /tests/client.rs: -------------------------------------------------------------------------------- 1 | use std::str::FromStr; 2 | 3 | use ethers_core::abi::AbiDecode; 4 | use ethers_core::types::H256; 5 | use rs_node::client::*; 6 | 7 | #[test] 8 | pub fn test_get_header() { 9 | let rpc_url = "https://eth-goerli.g.alchemy.com/v2/ktzxXAN_NDkz_5ikfCnPf_TzoQXEF53m"; 10 | let mut client = Client::new(rpc_url).unwrap(); 11 | let hash = H256::decode_hex("0xee9dd94ebc06b50d5d5c0f72299a3cc56737e459ce41ddb44f0411870f86b1a3").unwrap(); 12 | let header = client.get_header(hash).unwrap(); 13 | let expected_hash = reth_primitives::H256::from(hash.as_fixed_bytes()); 14 | assert_eq!(header.hash_slow(), expected_hash); 15 | } 16 | 17 | #[test] 18 | pub fn test_get_transactions_by_root() { 19 | let rpc_url = "https://eth-goerli.g.alchemy.com/v2/ktzxXAN_NDkz_5ikfCnPf_TzoQXEF53m"; 20 | let mut client = Client::new(rpc_url).unwrap(); 21 | 22 | // We shouldn't be able to get transactions for a block that doesn't exist 23 | let expected_transactions_root_hash = H256::from_str("0x9c2887743fb87670295f144bb2b82b47e7a2b446f116a5be967c597dd3a9c60c").unwrap(); 24 | let missing_txs = client.get_transactions_by_root(expected_transactions_root_hash); 25 | assert!(missing_txs.is_err()); 26 | 27 | // Now let's load the header, then fetch the transactions by the transactions root hash 28 | let hash = H256::decode_hex("0xee9dd94ebc06b50d5d5c0f72299a3cc56737e459ce41ddb44f0411870f86b1a3").unwrap(); 29 | let header = client.get_header(hash).unwrap(); 30 | let tx_root_hash = ethers_core::types::H256::from(header.transactions_root.as_fixed_bytes()); 31 | let transactions = client.get_transactions_by_root(tx_root_hash).unwrap(); 32 | assert_eq!(transactions.len(), 8); 33 | } 34 | 35 | #[test] 36 | pub fn test_get_receipts_by_root() { 37 | let rpc_url = "https://eth-goerli.g.alchemy.com/v2/ktzxXAN_NDkz_5ikfCnPf_TzoQXEF53m"; 38 | let mut client = Client::new(rpc_url).unwrap(); 39 | 40 | // We shouldn't be able to get receipts for a block that doesn't exist 41 | let expected_receipts_root_hash = H256::from_str("0x4ee5bd14490683c247268211c96b8bf1ddc52aa8a209676cb7db147deebff9b0").unwrap(); 42 | let missing_receipts = client.get_receipts_by_root(expected_receipts_root_hash); 43 | assert!(missing_receipts.is_err()); 44 | 45 | // Now let's load the header, then fetch the receipts by the receipts root hash 46 | let hash = H256::decode_hex("0xee9dd94ebc06b50d5d5c0f72299a3cc56737e459ce41ddb44f0411870f86b1a3").unwrap(); 47 | let header = client.get_header(hash).unwrap(); 48 | let receipt_root_hash = ethers_core::types::H256::from(header.receipts_root.as_fixed_bytes()); 49 | assert_eq!(receipt_root_hash, expected_receipts_root_hash); 50 | let receipts = client.get_receipts_by_root(receipt_root_hash).unwrap(); 51 | assert_eq!(receipts.len(), 8); 52 | } 53 | -------------------------------------------------------------------------------- /tests/types.rs: -------------------------------------------------------------------------------- 1 | use ethers_core::utils::hex; 2 | use std::str::FromStr; 3 | 4 | use reth_rlp::Encodable; 5 | 6 | use rs_node::types::*; 7 | 8 | // Taken from: reth 9 | // Test vector from: https://eips.ethereum.org/EIPS/eip-2481 10 | #[test] 11 | fn test_encode_header() { 12 | let expected = hex::decode("f901f9a00000000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000000940000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000000b90100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008208ae820d0582115c8215b3821a0a827788a00000000000000000000000000000000000000000000000000000000000000000880000000000000000").unwrap(); 13 | let header = Header { 14 | difficulty: U256::from(0x8ae_u64), 15 | number: 0xd05_u64, 16 | gas_limit: 0x115c_u64, 17 | gas_used: 0x15b3_u64, 18 | timestamp: 0x1a0a_u64, 19 | extra_data: Bytes::from_str("7788").unwrap(), 20 | ommers_hash: H256::zero(), 21 | state_root: H256::zero(), 22 | transactions_root: H256::zero(), 23 | receipts_root: H256::zero(), 24 | ..Default::default() 25 | }; 26 | let mut data = vec![]; 27 | header.encode(&mut data); 28 | let expected_hash = H256::from_str("0x8c2f2af15b7b563b6ab1e09bed0e9caade7ed730aec98b70a993597a797579a9").unwrap(); 29 | assert_eq!(header.hash_slow(), expected_hash); 30 | assert_eq!(hex::encode(&data), hex::encode(expected)); 31 | assert_eq!(header.length(), data.len()); 32 | } 33 | --------------------------------------------------------------------------------