diff --git a/Cargo.lock b/Cargo.lock index f5e43ff38..1cf232079 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1,211 +1,827 @@ # This file is automatically @generated by Cargo. # It is not intended for manual editing. version = 3 [[package]] name = "abc-rust-error" version = "0.1.0" dependencies = [ "abc-rust-lint", "eyre", "stable-eyre", "thiserror", ] [[package]] name = "abc-rust-lint" version = "0.1.0" [[package]] name = "addr2line" version = "0.17.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b9ecd88a8c8378ca913a680cd98f0f13ac67383d35993f86c90a70e3f137816b" dependencies = [ "gimli", ] [[package]] name = "adler" version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe" +[[package]] +name = "aho-corasick" +version = "0.7.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1e37cfd5e7657ada45f742d6e99ca5788580b5c529dc78faf11ece6dc702656f" +dependencies = [ + "memchr", +] + +[[package]] +name = "ansi_term" +version = "0.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d52a9bb7ec0cf484c551830a7ce27bd20d67eac647e1befb56b0be4ee39a55d2" +dependencies = [ + "winapi", +] + +[[package]] +name = "atomic-polyfill" +version = "0.1.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e14bf7b4f565e5e717d7a7a65b2a05c0b8c96e4db636d6f780f03b15108cdd1b" +dependencies = [ + "critical-section", +] + +[[package]] +name = "autocfg" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" + [[package]] name = "backtrace" version = "0.3.66" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cab84319d616cfb654d03394f38ab7e6f0919e181b1b57e1fd15e7fb4077d9a7" dependencies = [ "addr2line", "cc", "cfg-if", "libc", "miniz_oxide", "object", "rustc-demangle", ] +[[package]] +name = "bare-metal" +version = "0.2.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5deb64efa5bd81e31fcd1938615a6d98c82eafcbcd787162b6f63b91d6bac5b3" +dependencies = [ + "rustc_version 0.2.3", +] + +[[package]] +name = "bare-metal" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f8fe8f5a8a398345e52358e18ff07cc17a568fbca5c6f73873d3a62056309603" + +[[package]] +name = "bindgen" +version = "0.59.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2bd2a9a458e8f4304c52c43ebb0cfbd520289f8379a52e329a38afda99bf8eb8" +dependencies = [ + "bitflags", + "cexpr", + "clang-sys", + "lazy_static", + "lazycell", + "peeking_take_while", + "proc-macro2", + "quote", + "regex", + "rustc-hash", + "shlex", +] + +[[package]] +name = "bit_field" +version = "0.10.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dcb6dd1c2376d2e096796e234a70e17e94cc2d5d54ff8ce42b28cef1d0d359a4" + [[package]] name = "bitcoinsuite-core" version = "0.1.0" dependencies = [ "abc-rust-lint", "hex", "hex-literal", "thiserror", ] +[[package]] +name = "bitfield" +version = "0.13.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "46afbd2983a5d5a7bd740ccb198caf5b82f45c40c09c0eed36052d91cb92e719" + +[[package]] +name = "bitflags" +version = "1.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" + +[[package]] +name = "byteorder" +version = "1.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "14c189c53d098945499cdfa7ecc63567cf3886b3332b312a5b4585d8d3a6a610" + +[[package]] +name = "bzip2-sys" +version = "0.1.11+1.0.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "736a955f3fa7875102d57c82b8cac37ec45224a07fd32d58f9f7a186b6cd4cdc" +dependencies = [ + "cc", + "libc", + "pkg-config", +] + [[package]] name = "cc" version = "1.0.73" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2fff2a6927b3bb87f9595d67196a70493f627687a71d87a0d692242c33f58c11" +dependencies = [ + "jobserver", +] + +[[package]] +name = "cexpr" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6fac387a98bb7c37292057cffc56d62ecb629900026402633ae9160df93a8766" +dependencies = [ + "nom", +] [[package]] name = "cfg-if" version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" +[[package]] +name = "chronik-db" +version = "0.1.0" +dependencies = [ + "abc-rust-error", + "bitcoinsuite-core", + "postcard", + "pretty_assertions", + "rocksdb", + "serde", + "tempdir", + "thiserror", +] + +[[package]] +name = "clang-sys" +version = "1.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5a050e2153c5be08febd6734e29298e844fdb0fa21aeddd63b4eb7baa106c69b" +dependencies = [ + "glob", + "libc", + "libloading", +] + +[[package]] +name = "cobs" +version = "0.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "67ba02a97a2bd10f4b59b25c7973101c79642302776489e030cd13cdab09ed15" + +[[package]] +name = "cortex-m" +version = "0.7.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cd20d4ac4aa86f4f75f239d59e542ef67de87cce2c282818dc6e84155d3ea126" +dependencies = [ + "bare-metal 0.2.5", + "bitfield", + "embedded-hal", + "volatile-register", +] + +[[package]] +name = "critical-section" +version = "0.2.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "95da181745b56d4bd339530ec393508910c909c784e8962d15d722bacf0bcbcd" +dependencies = [ + "bare-metal 1.0.0", + "cfg-if", + "cortex-m", + "riscv", +] + +[[package]] +name = "ctor" +version = "0.1.22" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f877be4f7c9f246b183111634f75baa039715e3f46ce860677d3b19a69fb229c" +dependencies = [ + "quote", + "syn", +] + +[[package]] +name = "diff" +version = "0.1.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "56254986775e3233ffa9c4d7d3faaf6d36a2c09d30b20687e9f88bc8bafc16c8" + +[[package]] +name = "embedded-hal" +version = "0.2.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "35949884794ad573cf46071e41c9b60efb0cb311e3ca01f7af807af1debc66ff" +dependencies = [ + "nb 0.1.3", + "void", +] + [[package]] name = "eyre" version = "0.6.8" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4c2b6b5a29c02cdc822728b7d7b8ae1bab3e3b05d44522770ddd49722eeac7eb" dependencies = [ "indenter", "once_cell", ] +[[package]] +name = "fuchsia-cprng" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a06f77d526c1a601b7c4cdd98f54b5eaabffc14d5f2f0296febdc7f357c6d3ba" + [[package]] name = "gimli" version = "0.26.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "22030e2c5a68ec659fde1e949a745124b48e6fa8b045b7ed5bd1fe4ccc5c4e5d" +[[package]] +name = "glob" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9b919933a397b79c37e33b77bb2aa3dc8eb6e165ad809e58ff75bc7db2e34574" + +[[package]] +name = "hash32" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b0c35f58762feb77d74ebe43bdbc3210f09be9fe6742234d573bacc26ed92b67" +dependencies = [ + "byteorder", +] + +[[package]] +name = "heapless" +version = "0.7.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9f6733da246dc2af610133c8be0667170fd68e8ca5630936b520300eee8846f9" +dependencies = [ + "atomic-polyfill", + "hash32", + "rustc_version 0.4.0", + "serde", + "spin", + "stable_deref_trait", +] + [[package]] name = "hex" version = "0.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70" [[package]] name = "hex-literal" version = "0.3.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7ebdb29d2ea9ed0083cd8cece49bbd968021bd99b0849edb4a9a7ee0fdf6a4e0" [[package]] name = "indenter" version = "0.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ce23b50ad8242c51a442f3ff322d56b02f08852c77e4c0b4d3fd684abc89c683" +[[package]] +name = "jobserver" +version = "0.1.24" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "af25a77299a7f711a01975c35a6a424eb6862092cc2d6c72c4ed6cbc56dfc1fa" +dependencies = [ + "libc", +] + +[[package]] +name = "lazy_static" +version = "1.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" + +[[package]] +name = "lazycell" +version = "1.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "830d08ce1d1d941e6b30645f1a0eb5643013d835ce3779a5fc208261dbe10f55" + [[package]] name = "libc" version = "0.2.126" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "349d5a591cd28b49e1d1037471617a32ddcda5731b99419008085f72d5a53836" +[[package]] +name = "libloading" +version = "0.7.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "efbc0f03f9a775e9f6aed295c6a1ba2253c5757a9e03d55c6caa46a681abcddd" +dependencies = [ + "cfg-if", + "winapi", +] + +[[package]] +name = "librocksdb-sys" +version = "0.6.1+6.28.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "81bc587013734dadb7cf23468e531aa120788b87243648be42e2d3a072186291" +dependencies = [ + "bindgen", + "bzip2-sys", + "cc", + "glob", + "libc", + "libz-sys", +] + +[[package]] +name = "libz-sys" +version = "1.1.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9702761c3935f8cc2f101793272e202c72b99da8f4224a19ddcf1279a6450bbf" +dependencies = [ + "cc", + "pkg-config", + "vcpkg", +] + +[[package]] +name = "lock_api" +version = "0.4.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "327fa5b6a6940e4699ec49a9beae1ea4845c6bab9314e4f84ac68742139d8c53" +dependencies = [ + "autocfg", + "scopeguard", +] + [[package]] name = "memchr" version = "2.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2dffe52ecf27772e601905b7522cb4ef790d2cc203488bbd0e2fe85fcb74566d" +[[package]] +name = "minimal-lexical" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "68354c5c6bd36d73ff3feceb05efa59b6acb7626617f4962be322a825e61f79a" + [[package]] name = "miniz_oxide" version = "0.5.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6f5c75688da582b8ffc1f1799e9db273f32133c49e048f614d22ec3256773ccc" dependencies = [ "adler", ] +[[package]] +name = "nb" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "801d31da0513b6ec5214e9bf433a77966320625a37860f910be265be6e18d06f" +dependencies = [ + "nb 1.0.0", +] + +[[package]] +name = "nb" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "546c37ac5d9e56f55e73b677106873d9d9f5190605e41a856503623648488cae" + +[[package]] +name = "nom" +version = "7.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a8903e5a29a317527874d0402f867152a3d21c908bb0b933e416c65e301d4c36" +dependencies = [ + "memchr", + "minimal-lexical", +] + [[package]] name = "object" version = "0.29.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "21158b2c33aa6d4561f1c0a6ea283ca92bc54802a93b263e910746d679a7eb53" dependencies = [ "memchr", ] [[package]] name = "once_cell" version = "1.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "18a6dbe30758c9f83eb00cbea4ac95966305f5a7772f3f42ebfc7fc7eddbd8e1" +[[package]] +name = "output_vt100" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "628223faebab4e3e40667ee0b2336d34a5b960ff60ea743ddfdbcf7770bcfb66" +dependencies = [ + "winapi", +] + +[[package]] +name = "peeking_take_while" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "19b17cddbe7ec3f8bc800887bab5e717348c95ea2ca0b1bf0837fb964dc67099" + +[[package]] +name = "pkg-config" +version = "0.3.25" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1df8c4ec4b0627e53bdf214615ad287367e482558cf84b109250b37464dc03ae" + +[[package]] +name = "postcard" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "41f5465c5e5a38e04552d8fb53ebcf4f58124ab3bbd0c02add043b33f82792e5" +dependencies = [ + "cobs", + "heapless", + "serde", +] + +[[package]] +name = "pretty_assertions" +version = "1.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c89f989ac94207d048d92db058e4f6ec7342b0971fc58d1271ca148b799b3563" +dependencies = [ + "ansi_term", + "ctor", + "diff", + "output_vt100", +] + [[package]] name = "proc-macro2" version = "1.0.40" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "dd96a1e8ed2596c337f8eae5f24924ec83f5ad5ab21ea8e455d3566c69fbcaf7" dependencies = [ "unicode-ident", ] [[package]] name = "quote" version = "1.0.20" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3bcdf212e9776fbcb2d23ab029360416bb1706b1aea2d1a5ba002727cbcab804" dependencies = [ "proc-macro2", ] +[[package]] +name = "rand" +version = "0.4.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "552840b97013b1a26992c11eac34bdd778e464601a4c2054b5f0bff7c6761293" +dependencies = [ + "fuchsia-cprng", + "libc", + "rand_core 0.3.1", + "rdrand", + "winapi", +] + +[[package]] +name = "rand_core" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7a6fdeb83b075e8266dcc8762c22776f6877a63111121f5f8c7411e5be7eed4b" +dependencies = [ + "rand_core 0.4.2", +] + +[[package]] +name = "rand_core" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9c33a3c44ca05fa6f1807d8e6743f3824e8509beca625669633be0acbdf509dc" + +[[package]] +name = "rdrand" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "678054eb77286b51581ba43620cc911abf02758c91f93f479767aed0f90458b2" +dependencies = [ + "rand_core 0.3.1", +] + +[[package]] +name = "regex" +version = "1.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4c4eb3267174b8c6c2f654116623910a0fef09c4753f8dd83db29c48a0df988b" +dependencies = [ + "aho-corasick", + "memchr", + "regex-syntax", +] + +[[package]] +name = "regex-syntax" +version = "0.6.27" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a3f87b73ce11b1619a3c6332f45341e0047173771e8b8b73f87bfeefb7b56244" + +[[package]] +name = "remove_dir_all" +version = "0.5.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3acd125665422973a33ac9d3dd2df85edad0f4ae9b00dafb1a05e43a9f5ef8e7" +dependencies = [ + "winapi", +] + +[[package]] +name = "riscv" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6907ccdd7a31012b70faf2af85cd9e5ba97657cc3987c4f13f8e4d2c2a088aba" +dependencies = [ + "bare-metal 1.0.0", + "bit_field", + "riscv-target", +] + +[[package]] +name = "riscv-target" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "88aa938cda42a0cf62a20cfe8d139ff1af20c2e681212b5b34adb5a58333f222" +dependencies = [ + "lazy_static", + "regex", +] + +[[package]] +name = "rocksdb" +version = "0.18.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "620f4129485ff1a7128d184bc687470c21c7951b64779ebc9cfdad3dcd920290" +dependencies = [ + "libc", + "librocksdb-sys", +] + [[package]] name = "rustc-demangle" version = "0.1.21" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7ef03e0a2b150c7a90d01faf6254c9c48a41e95fb2a8c2ac1c6f0d2b9aefc342" +[[package]] +name = "rustc-hash" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "08d43f7aa6b08d49f382cde6a7982047c3426db949b1424bc4b7ec9ae12c6ce2" + +[[package]] +name = "rustc_version" +version = "0.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "138e3e0acb6c9fb258b19b67cb8abd63c00679d2851805ea151465464fe9030a" +dependencies = [ + "semver 0.9.0", +] + +[[package]] +name = "rustc_version" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bfa0f585226d2e68097d4f95d113b15b83a82e819ab25717ec0590d9584ef366" +dependencies = [ + "semver 1.0.12", +] + +[[package]] +name = "scopeguard" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d29ab0c6d3fc0ee92fe66e2d99f700eab17a8d57d1c1d3b748380fb20baa78cd" + +[[package]] +name = "semver" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1d7eb9ef2c18661902cc47e535f9bc51b78acd254da71d375c2f6720d9a40403" +dependencies = [ + "semver-parser", +] + +[[package]] +name = "semver" +version = "1.0.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a2333e6df6d6598f2b1974829f853c2b4c5f4a6e503c10af918081aa6f8564e1" + +[[package]] +name = "semver-parser" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3" + +[[package]] +name = "serde" +version = "1.0.140" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fc855a42c7967b7c369eb5860f7164ef1f6f81c20c7cc1141f2a604e18723b03" +dependencies = [ + "serde_derive", +] + +[[package]] +name = "serde_derive" +version = "1.0.140" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6f2122636b9fe3b81f1cb25099fcf2d3f542cdb1d45940d56c713158884a05da" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "shlex" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "43b2853a4d09f215c24cc5489c992ce46052d359b5109343cbafbf26bc62f8a3" + +[[package]] +name = "spin" +version = "0.9.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7f6002a767bff9e83f8eeecf883ecb8011875a21ae8da43bffb817a57e78cc09" +dependencies = [ + "lock_api", +] + [[package]] name = "stable-eyre" version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "556fec8c2da34c70b75f16d88df8a8cd7e652e567ff097b7e9df0022c8695cc4" dependencies = [ "backtrace", "eyre", "indenter", ] +[[package]] +name = "stable_deref_trait" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a8f112729512f8e442d81f95a8a7ddf2b7c6b8a1a6f509a95864142b30cab2d3" + [[package]] name = "syn" version = "1.0.98" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c50aef8a904de4c23c788f104b7dddc7d6f79c647c7c8ce4cc8f73eb0ca773dd" dependencies = [ "proc-macro2", "quote", "unicode-ident", ] +[[package]] +name = "tempdir" +version = "0.3.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "15f2b5fb00ccdf689e0149d1b1b3c03fead81c2b37735d812fa8bddbbf41b6d8" +dependencies = [ + "rand", + "remove_dir_all", +] + [[package]] name = "thiserror" version = "1.0.31" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bd829fe32373d27f76265620b5309d0340cb8550f523c1dda251d6298069069a" dependencies = [ "thiserror-impl", ] [[package]] name = "thiserror-impl" version = "1.0.31" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0396bc89e626244658bef819e22d0cc459e795a5ebe878e6ec336d1674a8d79a" dependencies = [ "proc-macro2", "quote", "syn", ] [[package]] name = "unicode-ident" -version = "1.0.1" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "15c61ba63f9235225a22310255a29b806b907c9b8c964bcbd0a2c70f3f2deea7" + +[[package]] +name = "vcell" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "77439c1b53d2303b20d9459b1ade71a83c716e3f9c34f3228c00e6f185d6c002" + +[[package]] +name = "vcpkg" +version = "0.2.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "accd4ea62f7bb7a82fe23066fb0957d48ef677f6eeb8215f372f52e48bb32426" + +[[package]] +name = "void" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6a02e4885ed3bc0f2de90ea6dd45ebcbb66dacffe03547fadbb0eeae2770887d" + +[[package]] +name = "volatile-register" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9ee8f19f9d74293faf70901bc20ad067dc1ad390d2cbf1e3f75f721ffee908b6" +dependencies = [ + "vcell", +] + +[[package]] +name = "winapi" +version = "0.3.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419" +dependencies = [ + "winapi-i686-pc-windows-gnu", + "winapi-x86_64-pc-windows-gnu", +] + +[[package]] +name = "winapi-i686-pc-windows-gnu" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" + +[[package]] +name = "winapi-x86_64-pc-windows-gnu" +version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5bd2fe26506023ed7b5e1e315add59d6f584c621d037f9368fea9cfb988f368c" +checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" diff --git a/Cargo.toml b/Cargo.toml index b66b85d99..ee4e377e1 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,9 +1,10 @@ # Copyright (c) 2022 The Bitcoin developers [workspace] members = [ "chronik/abc-rust-error", "chronik/abc-rust-lint", "chronik/bitcoinsuite-core", + "chronik/chronik-db", ] diff --git a/chronik/CMakeLists.txt b/chronik/CMakeLists.txt index 9ec2d1f5a..fdc1b0362 100644 --- a/chronik/CMakeLists.txt +++ b/chronik/CMakeLists.txt @@ -1,71 +1,72 @@ # Copyright (c) 2022 The Bitcoin developers find_package(Corrosion 0.2.0 REQUIRED) set(REQUIRED_RUST_VERSION "1.61.0") if(Rust_VERSION VERSION_LESS REQUIRED_RUST_VERSION) message(FATAL_ERROR "Minimum required Rust version is " "${REQUIRED_RUST_VERSION}, but found ${Rust_VERSION}") endif() set(CARGO_BUILD_DIR "${CMAKE_CURRENT_BINARY_DIR}/cargo/build") set_property(DIRECTORY "${CMAKE_SOURCE_DIR}" APPEND PROPERTY ADDITIONAL_CLEAN_FILES "${CARGO_BUILD_DIR}" ) get_property( RUSTC_EXECUTABLE TARGET Rust::Rustc PROPERTY IMPORTED_LOCATION ) get_filename_component(RUST_BIN_DIR ${RUSTC_EXECUTABLE} DIRECTORY) include(DoOrFail) find_program_or_fail(RUSTDOC_EXECUTABLE rustdoc PATHS "${RUST_BIN_DIR}" ) function(add_cargo_custom_target TARGET) add_custom_target(${TARGET} COMMAND "${CMAKE_COMMAND}" -E env CARGO_TARGET_DIR="${CARGO_BUILD_DIR}" CARGO_BUILD_RUSTC="$" CARGO_BUILD_RUSTDOC="${RUSTDOC_EXECUTABLE}" "$" ${ARGN} WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}" ) endfunction() function(add_crate_test_targets CRATE) set(CRATE_TEST_TARGET "check-crate-${CRATE}") add_custom_target("${CRATE_TEST_TARGET}") set(CLIPPY_TARGET "${CRATE_TEST_TARGET}-clippy") add_cargo_custom_target("${CLIPPY_TARGET}" clippy --package "${CRATE}-*" -- -D warnings ) set(TEST_TARGET "${CRATE_TEST_TARGET}-test") add_cargo_custom_target("${TEST_TARGET}" test --package "${CRATE}-*" ) add_dependencies("${CRATE_TEST_TARGET}" "${CLIPPY_TARGET}" "${TEST_TARGET}" ) add_dependencies("check-crates" "${CRATE_TEST_TARGET}" ) endfunction() add_custom_target("check-crates") -add_crate_test_targets(bitcoinsuite) add_crate_test_targets(abc-rust) +add_crate_test_targets(bitcoinsuite) +add_crate_test_targets(chronik) diff --git a/chronik/chronik-db/Cargo.toml b/chronik/chronik-db/Cargo.toml new file mode 100644 index 000000000..4b2e5b1ae --- /dev/null +++ b/chronik/chronik-db/Cargo.toml @@ -0,0 +1,31 @@ +# Copyright (c) 2022 The Bitcoin developers + +[package] +name = "chronik-db" +version = "0.1.0" +edition = "2021" +rust-version = "1.61.0" +license = "MIT" + +[dependencies] +abc-rust-error = { path = "../abc-rust-error" } +bitcoinsuite-core = { path = "../bitcoinsuite-core" } + +# Compact and fast serialization +postcard = { version = "1.0", features = ["alloc"] } + +# Key-value database +rocksdb = { version = "0.18", default-features = false } + +# Serialize structs +serde = { version = "1.0", features = ["derive"] } + +# Derive error enums +thiserror = "1.0" + +[dev-dependencies] +# Colorful diffs for assertions +pretty_assertions = "1.0" + +# Temporary directory that's deleted when dropped +tempdir = "0.3" diff --git a/chronik/chronik-db/src/db.rs b/chronik/chronik-db/src/db.rs new file mode 100644 index 000000000..68630fad4 --- /dev/null +++ b/chronik/chronik-db/src/db.rs @@ -0,0 +1,88 @@ +// Copyright (c) 2022 The Bitcoin developers +// Distributed under the MIT software license, see the accompanying +// file COPYING or http://www.opensource.org/licenses/mit-license.php. + +//! Module containing [`Db`] and errors, which encapsulates a database. +//! Read and write operations should exclusively be done with dedicated writers +//! and readers, such as [`crate::io::BlockWriter`]. + +use std::path::Path; + +use abc_rust_error::Result; +use rocksdb::ColumnFamilyDescriptor; +use thiserror::Error; + +use crate::io::BlockWriter; + +// All column family names used by Chronik should be defined here +pub(crate) const CF_BLK: &str = "blk"; + +pub(crate) type CF = rocksdb::ColumnFamily; + +/// Indexer database. +/// Owns the underlying [`rocksdb::DB`] instance. +#[derive(Debug)] +pub struct Db { + db: rocksdb::DB, +} + +/// Errors indicating something went wrong with the database itself. +#[derive(Debug, Error)] +pub enum DbError { + /// Column family requested but not defined during `Db::open`. + #[error("Column family {0} doesn't exist")] + NoSuchColumnFamily(String), + + /// Error with RocksDB itself, e.g. db inconsistency. + #[error("RocksDB error: {0}")] + RocksDb(rocksdb::Error), +} + +use self::DbError::*; + +impl Db { + /// Opens the database under the specified path. + /// Creates the database file and necessary column families if necessary. + pub fn open(path: impl AsRef) -> Result { + let mut cfs = Vec::new(); + BlockWriter::add_cfs(&mut cfs); + Self::open_with_cfs(path, cfs) + } + + pub(crate) fn open_with_cfs( + path: impl AsRef, + cfs: Vec, + ) -> Result { + let mut db_options = rocksdb::Options::default(); + db_options.create_if_missing(true); + db_options.create_missing_column_families(true); + let db = rocksdb::DB::open_cf_descriptors(&db_options, path, cfs) + .map_err(RocksDb)?; + Ok(Db { db }) + } + + pub(crate) fn cf(&self, name: &str) -> Result<&CF> { + Ok(self + .db + .cf_handle(name) + .ok_or_else(|| NoSuchColumnFamily(name.to_string()))?) + } + + #[cfg(test)] + pub(crate) fn get( + &self, + cf: &CF, + key: impl AsRef<[u8]>, + ) -> Result>> { + Ok(self.db.get_pinned_cf(cf, key).map_err(RocksDb)?) + } + + #[cfg(test)] + pub(crate) fn write_batch( + &self, + write_batch: rocksdb::WriteBatch, + ) -> Result<()> { + self.db.write(write_batch).map_err(RocksDb)?; + Ok(()) + } +} diff --git a/chronik/chronik-db/src/io/blocks.rs b/chronik/chronik-db/src/io/blocks.rs new file mode 100644 index 000000000..cac9d1738 --- /dev/null +++ b/chronik/chronik-db/src/io/blocks.rs @@ -0,0 +1,190 @@ +// Copyright (c) 2022 The Bitcoin developers +// Distributed under the MIT software license, see the accompanying +// file COPYING or http://www.opensource.org/licenses/mit-license.php. + +use abc_rust_error::Result; +use bitcoinsuite_core::block::BlockHash; +use rocksdb::ColumnFamilyDescriptor; +use serde::{Deserialize, Serialize}; + +use crate::db::{Db, CF, CF_BLK}; + +/// Height of a block in the chain. Genesis block has height 0. +/// -1 indicates "not part of the chain". +pub type BlockHeight = i32; + +/// Writes block data to the database. +pub struct BlockWriter<'a> { + cf: &'a CF, +} + +/// Block data to/from the database. +#[derive(Clone, Debug, Eq, PartialEq, Hash, Default)] +pub struct DbBlock { + /// Hash of the block. + pub hash: BlockHash, + /// Hash of the previous block of the block. + pub prev_hash: BlockHash, + /// Height of the block in the chain. + pub height: BlockHeight, + /// `nBits` field of the block; encodes the target compactly. + pub n_bits: u32, + /// Timestamp field of the block. + pub timestamp: i64, + /// Number of the node's blk?????.dat flat file where the block is stored. + pub file_num: u32, + /// Location in the flat file where the first byte of the block is stored, + /// starting at the header. + pub data_pos: u32, +} + +#[derive(Clone, Debug, Deserialize, PartialEq, Serialize)] +struct SerBlock { + hash: [u8; 32], + n_bits: u32, + timestamp: i64, + file_num: u32, + data_pos: u32, +} + +fn bh_to_bytes(height: BlockHeight) -> [u8; 4] { + // big-endian, so blocks are sorted ascendingly + height.to_be_bytes() +} + +impl<'a> BlockWriter<'a> { + /// Create writer to the database for blocks. + pub fn new(db: &'a Db) -> Result { + let cf = db.cf(CF_BLK)?; + Ok(BlockWriter { cf }) + } + + /// Add a new block to the database. + pub fn insert( + &self, + batch: &mut rocksdb::WriteBatch, + block: &DbBlock, + ) -> Result<()> { + // Use `postcard` to serialize the block data + let data = postcard::to_allocvec(&SerBlock { + hash: block.hash.to_bytes(), + n_bits: block.n_bits, + timestamp: block.timestamp, + file_num: block.file_num, + data_pos: block.data_pos, + })?; + batch.put_cf(self.cf, bh_to_bytes(block.height), &data); + Ok(()) + } + + /// Remove a block by height from the database. + pub fn delete_by_height( + &self, + batch: &mut rocksdb::WriteBatch, + height: BlockHeight, + ) -> Result<()> { + batch.delete_cf(self.cf, bh_to_bytes(height)); + Ok(()) + } + + pub(crate) fn add_cfs(columns: &mut Vec) { + columns.push(ColumnFamilyDescriptor::new( + CF_BLK, + rocksdb::Options::default(), + )); + } +} + +impl std::fmt::Debug for BlockWriter<'_> { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + write!(f, "BlockWriter {{ ... }}") + } +} + +#[cfg(test)] +mod tests { + use abc_rust_error::Result; + use bitcoinsuite_core::block::BlockHash; + + use crate::{ + db::{Db, CF_BLK}, + io::{blocks::SerBlock, BlockWriter, DbBlock}, + }; + + #[test] + fn test_blocks() -> Result<()> { + abc_rust_error::install(); + + let tempdir = tempdir::TempDir::new("chronik-db--blocks")?; + let db = Db::open(tempdir.path())?; + let writer = BlockWriter::new(&db)?; + let block0 = DbBlock { + hash: BlockHash::from([44; 32]), + prev_hash: BlockHash::from([0; 32]), + height: 0, + n_bits: 0x1c100000, + timestamp: 1600000000, + file_num: 6, + data_pos: 100, + }; + let block1 = DbBlock { + hash: BlockHash::from([22; 32]), + prev_hash: BlockHash::from([44; 32]), + height: 1, + n_bits: 0x1c100001, + timestamp: 1600000001, + file_num: 7, + data_pos: 200, + }; + let cf = db.cf(CF_BLK)?; + { + let mut batch = rocksdb::WriteBatch::default(); + writer.insert(&mut batch, &block0)?; + db.write_batch(batch)?; + assert_eq!( + postcard::from_bytes::( + &db.get(cf, [0, 0, 0, 0])?.unwrap() + )?, + SerBlock { + hash: block0.hash.to_bytes(), + n_bits: block0.n_bits, + timestamp: block0.timestamp, + file_num: block0.file_num, + data_pos: block0.data_pos, + }, + ); + } + { + let mut batch = rocksdb::WriteBatch::default(); + writer.insert(&mut batch, &block1)?; + db.write_batch(batch)?; + assert_eq!( + postcard::from_bytes::( + &db.get(cf, [0, 0, 0, 1])?.unwrap(), + )?, + SerBlock { + hash: block1.hash.to_bytes(), + n_bits: block1.n_bits, + timestamp: block1.timestamp, + file_num: block1.file_num, + data_pos: block1.data_pos, + }, + ); + } + { + let mut batch = rocksdb::WriteBatch::default(); + writer.delete_by_height(&mut batch, 1)?; + db.write_batch(batch)?; + assert_eq!(db.get(cf, [0, 0, 0, 1])?.as_deref(), None); + assert!(db.get(cf, [0, 0, 0, 0])?.is_some()); + } + { + let mut batch = rocksdb::WriteBatch::default(); + writer.delete_by_height(&mut batch, 0)?; + db.write_batch(batch)?; + assert_eq!(db.get(cf, [0, 0, 0, 1])?.as_deref(), None); + assert_eq!(db.get(cf, [0, 0, 0, 0])?.as_deref(), None); + } + Ok(()) + } +} diff --git a/chronik/chronik-db/src/io/mod.rs b/chronik/chronik-db/src/io/mod.rs new file mode 100644 index 000000000..be8b52192 --- /dev/null +++ b/chronik/chronik-db/src/io/mod.rs @@ -0,0 +1,9 @@ +// Copyright (c) 2022 The Bitcoin developers +// Distributed under the MIT software license, see the accompanying +// file COPYING or http://www.opensource.org/licenses/mit-license.php. + +//! Module containing readers and writers for the database used by Chronik. + +mod blocks; + +pub use self::blocks::*; diff --git a/chronik/chronik-db/src/lib.rs b/chronik/chronik-db/src/lib.rs new file mode 100644 index 000000000..0ec65f8f3 --- /dev/null +++ b/chronik/chronik-db/src/lib.rs @@ -0,0 +1,32 @@ +// Copyright (c) 2022 The Bitcoin developers +// Distributed under the MIT software license, see the accompanying +// file COPYING or http://www.opensource.org/licenses/mit-license.php. + +#![deny(unsafe_code)] +#![warn( + const_err, + explicit_outlives_requirements, + improper_ctypes, + keyword_idents, + missing_debug_implementations, + missing_docs, + no_mangle_generic_items, + non_ascii_idents, + non_shorthand_field_patterns, + noop_method_call, + overflowing_literals, + path_statements, + patterns_in_fns_without_body, + private_in_public, + rust_2018_idioms, + unconditional_recursion, + unreachable_pub, + unused_comparisons, + unused, + while_true +)] + +//! Stores and retrieves data for Chronik in a database. + +pub mod db; +pub mod io;